changeset 910:c030e4af32b7

Mouse X and Y are 9-bit 2's complement not 8-bit magnitude + sign bit like I thought. Fixed mouse Y direction.
author Michael Pavone <pavone@retrodev.com>
date Sat, 05 Dec 2015 18:40:34 -0800
parents e60eb88d7b09
children 73732ae76fa8
files io.c menu.s68
diffstat 2 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/io.c	Sat Dec 05 00:17:15 2015 -0800
+++ b/io.c	Sat Dec 05 18:40:34 2015 -0800
@@ -1229,7 +1229,7 @@
 				//it would be unfortunate if our event handler updated cur_x or cur_y in the middle
 				//of the mouse poll sequence, so we save the delta here
 				port->device.mouse.delta_x = port->device.mouse.cur_x - port->device.mouse.last_read_x;
-				port->device.mouse.delta_y = port->device.mouse.cur_y - port->device.mouse.last_read_y;
+				port->device.mouse.delta_y = port->device.mouse.last_read_y - port->device.mouse.cur_y;
 				if (port->device.mouse.delta_y > 255 || port->device.mouse.delta_y < -255) {
 					input |= 8;
 				}
@@ -1247,16 +1247,16 @@
 				input = port->input[0];
 				break;
 			case 5:
-				input = abs(port->device.mouse.delta_x) >> 4 & 0xF;
+				input = port->device.mouse.delta_x >> 4 & 0xF;
 				break;
 			case 6:
-				input = abs(port->device.mouse.delta_x) & 0xF;
+				input = port->device.mouse.delta_x & 0xF;
 				break;
 			case 7:
-				input = abs(port->device.mouse.delta_y) >> 4 & 0xF;
+				input = port->device.mouse.delta_y >> 4 & 0xF;
 				break;
 			case 8:
-				input = abs(port->device.mouse.delta_y) & 0xF;
+				input = port->device.mouse.delta_y & 0xF;
 				//need to figure out when this actually happens
 				port->device.mouse.last_read_x = port->device.mouse.cur_x;
 				port->device.mouse.last_read_y = port->device.mouse.cur_y;
--- a/menu.s68	Sat Dec 05 00:17:15 2015 -0800
+++ b/menu.s68	Sat Dec 05 18:40:34 2015 -0800
@@ -364,6 +364,7 @@
 	move.b #1, mouse_shown.w
 
 .skip_show_check
+	neg.w d1
 	move.l mouse_sprite.w, a2
 	add.w d1, (a2)
 	add.w d0, mouse_x.w
@@ -505,11 +506,11 @@
 
 	btst #4, d3
 	beq xpos
-	neg.w d0
+	or.w #$FF00, d0
 xpos
 	btst #5, d3
 	beq ypos
-	neg.w d1
+	or.w #$FF00, d1
 ypos
 	;set port config back to normal controller mode
 	move.b #$40, (PAD1_CTRL-PAD1_DATA, a2)