diff options
Diffstat (limited to 'source/spec.c')
-rw-r--r-- | source/spec.c | 90 |
1 files changed, 73 insertions, 17 deletions
diff --git a/source/spec.c b/source/spec.c index 7137834..10a5d0a 100644 --- a/source/spec.c +++ b/source/spec.c @@ -114,9 +114,49 @@ static struct */ static Z80Byte matrix[8]; +static struct +{ + int row; + int bit; +} key_matrix[]= + { + {3,0x01}, {3,0x02}, {3,0x04}, {3,0x08}, {3,0x10}, /* 1 - 5 */ + {4,0x10}, {4,0x08}, {4,0x04}, {4,0x02}, {4,0x01}, /* 6 - 0 */ + {2,0x01}, {2,0x02}, {2,0x04}, {2,0x08}, {2,0x10}, /* Q - T */ + {5,0x10}, {5,0x08}, {5,0x04}, {5,0x02}, {5,0x01}, /* Y - P */ + {1,0x01}, {1,0x02}, {1,0x04}, {1,0x08}, {1,0x10}, /* A - G */ + {6,0x10}, {6,0x08}, {6,0x04}, {6,0x02}, {6,0x01}, /* H - NL */ + {0,0x01}, {0,0x02}, {0,0x04}, {0,0x08}, {0,0x10}, /* CAPS - V */ + {7,0x10}, {7,0x08}, {7,0x04}, {7,0x02}, {7,0x01} /* B - SPACE */ + }; + +static int debug_matrix = FALSE; + /* ---------------------------------------- PRIVATE FUNCTIONS */ +static void FillBox(int x, int y, int w, int h, int colour) +{ + int f; + uint16 *base; + + colour|=0x8000; + + base=vram+x+y*256; + + while(h--) + { + for(f=0;f<w;f++) + { + *(base+f)=colour; + } + + base+=256; + } +} + + + static void DrawScreen(void) { int f,r; @@ -170,6 +210,31 @@ static void DrawScreen(void) } } } + + if (debug_matrix) + { + int m; + int b; + + for(m=0;m<8;m++) + { + for(b=0;b<8;b++) + { + uint16 col; + + if (matrix[m]&(1<<b)) + { + col=RGB15(0,31,0); + } + else + { + col=RGB15(31,0,0); + } + + FillBox((7-b)*5,150+m*5,4,4,col); + } + } + } } static void RomPatch(void) @@ -314,34 +379,25 @@ void SPECInit(uint16 *v, Z80 *z80) void SPECHandleKey(SoftKey key, int is_pressed) { - if (key<=SK_SPACE) + if (key<SK_CONFIG) { - int row; - int bit; - - row=key/5; - - if (row&1) - { - bit=5-(key%5); - } - else - { - bit=(key%5); - } - if (is_pressed) { - matrix[row]&=~bit; + matrix[key_matrix[key].row]&=~key_matrix[key].bit; } else { - matrix[row]|=bit; + matrix[key_matrix[key].row]|=key_matrix[key].bit; } } else { /* TODO: Joysticks! */ + + if (is_pressed && key==SK_PAD_SELECT) + { + debug_matrix = !debug_matrix; + } } } |