X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fkeypad.c;h=5bd5e2ed3ee6352400e6d3a32b7615129b5e491b;hb=HEAD;hp=8ffa664e773a66511481802a2d37d4094f26d012;hpb=27fb8a023fa0572ef4171624781460bc59537d49;p=uccvend-snackrom.git diff --git a/ROM2/keypad.c b/ROM2/keypad.c index 8ffa664..5bd5e2e 100644 --- a/ROM2/keypad.c +++ b/ROM2/keypad.c @@ -16,8 +16,8 @@ const u8 keymap1[3] = {KEY_9, KEY_0, KEY_RESET}; /* reads the keypad and returns the bit number that was turned on in the shift * register (from 0..7). If no bits were turned on, it returns 8 (aka NO_KEY) */ -extern inline u8 keypad_read_row(u8 row) { - u8 i, j, num; +extern inline u8 keypad_read_row(const u8 row) { + u8 i, num; if (row) bset((void*)&_io_ports[M6811_PORTD], PORTD_KEYPAD_ROW); @@ -31,30 +31,15 @@ extern inline u8 keypad_read_row(u8 row) { bclr_misc_output(A3800_DISPLAY_WRITE); /* disable the display clock */ - /* _io_ports[M6811_SPDR] = 0; */ - asm volatile ( - "ldab #0\n" - "stab %0\n" - : "=m" (_io_ports[M6811_SPDR]) - : - : "b" - ); + _io_ports[M6811_SPDR] = 0x55; /* doesn't matter what we send. */ while(!(_io_ports[M6811_SPSR]&M6811_SPIF)); /* wait for completion */ /* SPDR read to clear SPIF flag is performed below: */ i = _io_ports[M6811_SPDR]; - /* print out the row & read in key in binary */ - char msg_buf[11] = "XKXXXXXXXX"; - msg_buf[0] = row?'1':'0'; - for (j = 1, num = 0; num < 8; j = j << 1, num++) { - msg_buf[num+2] = (i & j)?'1':'0'; - } - set_msg(msg_buf); - num = 0; - while (((i & 0x01) == 0) && (num < 8)) { - i = i >> 1; + while (((i & 0x80) == 0) && (num < 8)) { + i = i << 1; num++; }