From 9b8db3343b88bf17ddcbb72b01faa245fed71bee Mon Sep 17 00:00:00 2001 From: DIvan2000 Date: Mon, 22 Sep 2025 19:45:21 +0400 Subject: [PATCH 1/4] Update main.c --- src/main.c | 58 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/src/main.c b/src/main.c index 5d9423d..625483b 100644 --- a/src/main.c +++ b/src/main.c @@ -3,36 +3,46 @@ #define MOUSE_PORT ((volatile u8*)0xA10003) #define Z80_HALT *((volatile u16*)0xA11100) -#define MOUSE_DELAY 32 +#define MOUSE_DELAY 8 -static inline void delay() { - for(int i=0;i Date: Mon, 22 Sep 2025 20:11:18 +0400 Subject: [PATCH 2/4] Update main.c --- src/main.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index 625483b..121e71b 100644 --- a/src/main.c +++ b/src/main.c @@ -3,7 +3,7 @@ #define MOUSE_PORT ((volatile u8*)0xA10003) #define Z80_HALT *((volatile u16*)0xA11100) -#define MOUSE_DELAY 8 +#define MOUSE_DELAY 32 static inline void delay(void) { @@ -25,8 +25,8 @@ int main() { VDP_drawText("Sega Mega Mouse RAW reader", 7, 27); VDP_drawText("RAW nibbles:", 12,0); u8 nibbles[16] = {0}; - int x = 0; - int y = 0; + s16 x = 0; + s16 y = 0; char buf[40]; //буфер строки для вывода на экран @@ -34,6 +34,9 @@ int main() { SYS_doVBlankProcess(); + VDP_clearTextArea(0, 1, 40, 13); + + //опрос мыши Z80_HALT = 0x0100; *MOUSE_PORT = 0x60; delay(); @@ -53,25 +56,23 @@ int main() { //конец опроса мыши // выводим нибблы на экран - VDP_clearTextArea(0, 1, 40, 1); sprintf(buf, "%X%X%X%X %X %X %X%X %X%X", nibbles[0],nibbles[1],nibbles[2],nibbles[3],nibbles[4],nibbles[5],nibbles[6],nibbles[7],nibbles[8],nibbles[9]); VDP_drawText(buf, 13,1); //считаем dx dy - int dx = (nibbles[6] << 4) | nibbles[7]; - int dy = (nibbles[8] << 4) | nibbles[9]; + s16 dx = (nibbles[6] << 4) | nibbles[7]; + s16 dy = (nibbles[8] << 4) | nibbles[9]; if (nibbles[4]&8) dy = 255; if (nibbles[4]&4) dx = 255; - if (nibbles[4]&2) dy = -dy; - if (nibbles[4]&1) dx = -dx; + if (nibbles[4]&2) dy = dy|0xFF00; //sign-extend to 16-bit + if (nibbles[4]&1) dx = dx|0xFF00; x+=dx; y+=dy; //выводим на экран полезные данные - VDP_clearTextArea(0, 10, 40, 3); sprintf(buf, "buttons: %c%c%c%c", (nibbles[5]&8&&1)+'0',(nibbles[5]&4&&1)+'0',(nibbles[5]&2&&1)+'0',(nibbles[5]&1&&1)+'0'); VDP_drawText(buf, 2, 10); - sprintf(buf, "dx: %+04d dy: %+04d x: %+04d y: %+04d", dx,dy,x/64,y/64); + sprintf(buf, "dx: %+04d dy: %+04d x: %+04d y: %+04d", dx,dy,x,y); VDP_drawText(buf, 2, 12); } From 3f43fc65b23c97a17f48fd075fa72fda2aa2b820 Mon Sep 17 00:00:00 2001 From: DIvan2000 Date: Mon, 22 Sep 2025 20:28:33 +0400 Subject: [PATCH 3/4] Update main.c --- src/main.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main.c b/src/main.c index 121e71b..bcfffc9 100644 --- a/src/main.c +++ b/src/main.c @@ -5,7 +5,6 @@ #define MOUSE_DELAY 32 - static inline void delay(void) { __asm__ volatile ( "move.w %0,%%d0\n\t" @@ -17,9 +16,6 @@ static inline void delay(void) { ); } - - - int main() { VDP_setTextPlane(0); VDP_drawText("Sega Mega Mouse RAW reader", 7, 27); @@ -79,5 +75,3 @@ int main() { return 0; } - - From 5e1ba9d749b2131868ea7bde6a5ed137f38a2e56 Mon Sep 17 00:00:00 2001 From: DIvan2000 Date: Mon, 22 Sep 2025 20:33:57 +0400 Subject: [PATCH 4/4] Update main.c --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index bcfffc9..6ecb2ac 100644 --- a/src/main.c +++ b/src/main.c @@ -19,7 +19,7 @@ static inline void delay(void) { int main() { VDP_setTextPlane(0); VDP_drawText("Sega Mega Mouse RAW reader", 7, 27); - VDP_drawText("RAW nibbles:", 12,0); + VDP_drawText("RAW nibbles:", 14,0); u8 nibbles[16] = {0}; s16 x = 0; s16 y = 0;