From 2003126838e077892607af7c755349b99eeaa74c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 17 Nov 2018 22:24:17 +0000 Subject: [PATCH] sam: initial pieces for mouse support --- Kernel/platform-sam/README | 6 ++++- Kernel/platform-sam/devtty.c | 5 ++++ Kernel/platform-sam/devtty.h | 4 +++ Kernel/platform-sam/discard.c | 2 ++ Kernel/platform-sam/sam.s | 48 +++++++++++++++++++++++++++++++++++ 5 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Kernel/platform-sam/README b/Kernel/platform-sam/README index a07372e0..8d24ccd1 100644 --- a/Kernel/platform-sam/README +++ b/Kernel/platform-sam/README @@ -16,9 +16,13 @@ This port provides fairly basic support for the following configurations Joystick Mouse Floppy Disk - Serial I/O + Serial I/O (no emulation so tricky) MegaRAM (as a RAM disc) + No online docs/emulation + Trinity + SID + Memory layout diff --git a/Kernel/platform-sam/devtty.c b/Kernel/platform-sam/devtty.c index a5f4c6c6..50c21797 100644 --- a/Kernel/platform-sam/devtty.c +++ b/Kernel/platform-sam/devtty.c @@ -215,10 +215,15 @@ static void keydecode(void) static uint8_t kbd_timer; +uint8_t mousein[7]; +uint8_t mouse_present; + void kbd_interrupt(void) { newkey = 0; keyproc(); + if (mouse_present) + mousescan(); if (keysdown && keysdown < 3) { if (newkey) { keydecode(); diff --git a/Kernel/platform-sam/devtty.h b/Kernel/platform-sam/devtty.h index d011b945..92c4e784 100644 --- a/Kernel/platform-sam/devtty.h +++ b/Kernel/platform-sam/devtty.h @@ -4,6 +4,10 @@ extern void tty_interrupt(void); extern void kbd_interrupt(void); extern void keyscan(void); +extern void mousescan(void); +extern uint8_t mouse_probe(void); /* 0 means yes */ + +extern uint8_t mouse_present; #define KEY_ROWS 9 #define KEY_COLS 8 diff --git a/Kernel/platform-sam/discard.c b/Kernel/platform-sam/discard.c index 191d99e3..6b3c2c74 100644 --- a/Kernel/platform-sam/discard.c +++ b/Kernel/platform-sam/discard.c @@ -42,6 +42,8 @@ void device_init(void) platform_rtc_probe(); inittod(); #endif + if (!mouse_probe()) + mouse_present = 1; if (atom_probe()) devide_init(); } diff --git a/Kernel/platform-sam/sam.s b/Kernel/platform-sam/sam.s index b1dfd00f..dd2595e0 100644 --- a/Kernel/platform-sam/sam.s +++ b/Kernel/platform-sam/sam.s @@ -22,6 +22,8 @@ .globl _platform_copier_l .globl _platform_copier_h .globl _keyscan + .globl _mousescan + .globl _mouse_probe .globl _int_disabled ; exported debugging tools @@ -37,6 +39,7 @@ .globl unix_syscall_entry .globl outcharhex .globl _keyin + .globl _mousein .globl _vtwipe .globl _vtinit @@ -281,6 +284,51 @@ keyscl: ld (hl), a ret +_mousescan: + ld hl,#0 + ld bc,#0xfffe + in a,(c) + in a,(c) ; should be xxxx1111 + or #0xf0 ; should now be 11111111 + inc a ; cheap way to and 15, cp 15... + ret nz ; was not right - punt return 0 + ld hl,#_mousein + ini ; fetch and store buttons + inc b ; fix up B (needs to be FFFE for the port) + ini ; y256 + inc b + ini ; y16 + inc b + ini ; y1 + inc b + ini ; x256 + inc b + ini ; x16 + inc b + ini ; x1 + inc b + in a,(c) ; end + ret ; hl will be non zero + + .area _DISCARD + +_mouse_probe: + ld bc,#0xfffe + ld hl,#0x0b01 ; 0b for count, 01 so can ret nz + in a,(c) + in a,(c) + or #0xf0 + inc a + ret nz +probe_in: + in a,(c) + dec h + jr nz, probe_in + and #0x0f + ld l,a ; 0 if present + ret + + .area _CODE ; ; Real time clock on port 239 ; -- 2.34.1