summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2006-10-30 23:50:04 +0000
committerIan C <ianc@noddybox.co.uk>2006-10-30 23:50:04 +0000
commitf08256be0fb69083175408e9d87173a5107c9977 (patch)
treef869da9dca929124ee952f56325e4e8904d70bda
parenta61e0aa6a31d6028eeb4ff45bb6c71f604641fea (diff)
Completed FAT loading, custom keypad definitions and fixed keyboard hang bug
-rw-r--r--CHANGES11
-rw-r--r--arm9/CHANGES11
-rw-r--r--arm9/include/keyboard.h13
-rw-r--r--arm9/source/keyboard.c108
-rw-r--r--arm9/source/main.c86
-rw-r--r--arm9/source/zx81.c6
-rw-r--r--include/keyboard.h13
-rw-r--r--source/keyboard.c108
-rw-r--r--source/main.c86
-rw-r--r--source/zx81.c6
10 files changed, 318 insertions, 130 deletions
diff --git a/CHANGES b/CHANGES
index ae3637f..5de4334 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,10 +1,7 @@
-Key:
- + Completed
- * In progress
- - Not done.
++ Completed, * In progress, - Not done.
Changes from V1.0 to V1.1
- * Added external FAT file loading.
- - Added Mazogs as a built-in tape (Paul ....)
- - Fixed bug where the ROM input routine locks up -- remove ROM bounce?.
+ + Added external FAT file loading.
+ + Added Mazogs as a built-in tape (Paul Fearnley)
+ + Fixed bug where the ROM input routine locks up.
diff --git a/arm9/CHANGES b/arm9/CHANGES
index ae3637f..5de4334 100644
--- a/arm9/CHANGES
+++ b/arm9/CHANGES
@@ -1,10 +1,7 @@
-Key:
- + Completed
- * In progress
- - Not done.
++ Completed, * In progress, - Not done.
Changes from V1.0 to V1.1
- * Added external FAT file loading.
- - Added Mazogs as a built-in tape (Paul ....)
- - Fixed bug where the ROM input routine locks up -- remove ROM bounce?.
+ + Added external FAT file loading.
+ + Added Mazogs as a built-in tape (Paul Fearnley)
+ + Fixed bug where the ROM input routine locks up.
diff --git a/arm9/include/keyboard.h b/arm9/include/keyboard.h
index c3fab5b..2afb5df 100644
--- a/arm9/include/keyboard.h
+++ b/arm9/include/keyboard.h
@@ -108,18 +108,23 @@ void SK_DisplayKeyboard(uint16 *vram);
*/
int SK_GetEvent(SoftKeyEvent *ev);
+/* Returns TRUE while there are still key events for this cycle. Unlike
+ SK_GetEvent this does not do joypad mappings.
+*/
+int SK_GetBareEvent(SoftKeyEvent *ev);
+
/* Sets a key to be 'sticky' (it will be released automatically on the next
non-sticky press).
*/
void SK_SetSticky(SoftKey key, int is_sticky);
-/* Flush all the keys.
-*/
-void SK_ClearKeys(void);
-
/* Map the joypad to keys. Note that when mapped that both the key and the
joypad code will be generated.
*/
void SK_DefinePad(SoftKey pad, SoftKey key);
+/* Returns a name for key symbols.
+*/
+const char *SK_KeyName(SoftKey pad);
+
#endif /* DS81_KEYBOARD_H */
diff --git a/arm9/source/keyboard.c b/arm9/source/keyboard.c
index 8db8d34..04ae120 100644
--- a/arm9/source/keyboard.c
+++ b/arm9/source/keyboard.c
@@ -61,11 +61,11 @@ static SoftKey pad_select_key = NUM_SOFT_KEYS;
} \
} while(0)
-#define CHECK_STATE(KEYS,BIT,CODE,SHORTCUT) \
+#define CHECK_STATE(KEYS,BIT,CODE,SHORTCUT,USE_SHORTCUT) \
do \
{ \
key_state[CODE].new_state = (KEYS & BIT); \
- if (SHORTCUT != NUM_SOFT_KEYS && \
+ if (USE_SHORTCUT && SHORTCUT != NUM_SOFT_KEYS && \
!key_state[SHORTCUT].handled && (KEYS & BIT)) \
{ \
key_state[SHORTCUT].new_state = TRUE; \
@@ -73,6 +73,33 @@ static SoftKey pad_select_key = NUM_SOFT_KEYS;
} while(0)
+static const char *keynames[]=
+{
+ "1", "2", "3", "4", "5",
+ "6", "7", "8", "9", "0",
+ "Q", "W", "E", "R", "T",
+ "Y", "U", "I", "O", "P",
+ "A", "S", "D", "F", "G",
+ "H", "J", "K", "L", "NEWLINE",
+ "SHIFT", "Z", "X", "C", "V",
+ "B", "N", "M", "PERIOD", "SPACE",
+
+ "ABOUT",
+ "CONFIG",
+ "JOYPAD UP",
+ "JOYPAD DOWN",
+ "JOYPAD LEFT",
+ "JOYPAD RIGHT",
+ "A BUTTON",
+ "B BUTTON",
+ "X BUTTON",
+ "Y BUTTON",
+ "RIGHT SHOULDER BUTTON",
+ "LEFT SHOULDER BUTTON",
+ "START BUTTON",
+ "SELECT BUTTON"
+};
+
/* ---------------------------------------- PRIVATE INTERFACES
*/
static SoftKey LocatePress(const touchPosition *p)
@@ -99,19 +126,7 @@ static SoftKey LocatePress(const touchPosition *p)
}
-/* ---------------------------------------- PUBLIC INTERFACES
-*/
-void SK_DisplayKeyboard(uint16 *vram)
-{
- sImage img;
-
- loadPCX(keyb_bin,&img);
- image8to16(&img);
- dmaCopy(img.data8,vram,SCREEN_WIDTH*SCREEN_HEIGHT*2);
-}
-
-
-int SK_GetEvent(SoftKeyEvent *ev)
+static int GetEvent(SoftKeyEvent *ev, int map)
{
static SoftKey last = NUM_SOFT_KEYS;
static int poll_index = -1;
@@ -187,18 +202,18 @@ int SK_GetEvent(SoftKeyEvent *ev)
/* Check non soft-keyboard controls
*/
- CHECK_STATE(keys, KEY_A, SK_PAD_A, pad_A_key);
- CHECK_STATE(keys, KEY_B, SK_PAD_B, pad_B_key);
- CHECK_STATE(keys, KEY_X, SK_PAD_X, pad_X_key);
- CHECK_STATE(keys, KEY_Y, SK_PAD_Y, pad_Y_key);
- CHECK_STATE(keys, KEY_R, SK_PAD_R, pad_R_key);
- CHECK_STATE(keys, KEY_L, SK_PAD_L, pad_L_key);
- CHECK_STATE(keys, KEY_START, SK_PAD_START, pad_start_key);
- CHECK_STATE(keys, KEY_SELECT, SK_PAD_SELECT, pad_select_key);
- CHECK_STATE(keys, KEY_UP, SK_PAD_UP, pad_up_key);
- CHECK_STATE(keys, KEY_DOWN, SK_PAD_DOWN, pad_down_key);
- CHECK_STATE(keys, KEY_LEFT, SK_PAD_LEFT, pad_left_key);
- CHECK_STATE(keys, KEY_RIGHT, SK_PAD_RIGHT, pad_right_key);
+ CHECK_STATE(keys, KEY_A, SK_PAD_A, pad_A_key, map);
+ CHECK_STATE(keys, KEY_B, SK_PAD_B, pad_B_key, map);
+ CHECK_STATE(keys, KEY_X, SK_PAD_X, pad_X_key, map);
+ CHECK_STATE(keys, KEY_Y, SK_PAD_Y, pad_Y_key, map);
+ CHECK_STATE(keys, KEY_R, SK_PAD_R, pad_R_key, map);
+ CHECK_STATE(keys, KEY_L, SK_PAD_L, pad_L_key, map);
+ CHECK_STATE(keys, KEY_START, SK_PAD_START, pad_start_key, map);
+ CHECK_STATE(keys, KEY_SELECT, SK_PAD_SELECT, pad_select_key, map);
+ CHECK_STATE(keys, KEY_UP, SK_PAD_UP, pad_up_key, map);
+ CHECK_STATE(keys, KEY_DOWN, SK_PAD_DOWN, pad_down_key, map);
+ CHECK_STATE(keys, KEY_LEFT, SK_PAD_LEFT, pad_left_key, map);
+ CHECK_STATE(keys, KEY_RIGHT, SK_PAD_RIGHT, pad_right_key, map);
/* Reset key event poll index
*/
@@ -243,24 +258,37 @@ int SK_GetEvent(SoftKeyEvent *ev)
}
-void SK_SetSticky(SoftKey key, int is_sticky)
+/* ---------------------------------------- PUBLIC INTERFACES
+*/
+void SK_DisplayKeyboard(uint16 *vram)
{
- key_state[key].is_sticky = is_sticky;
+ sImage img;
- if (!is_sticky)
- {
- key_state[key].new_state = FALSE;
- }
+ loadPCX(keyb_bin,&img);
+ image8to16(&img);
+ dmaCopy(img.data8,vram,SCREEN_WIDTH*SCREEN_HEIGHT*2);
}
-void SK_ClearKeys(void)
+int SK_GetEvent(SoftKeyEvent *ev)
+{
+ return GetEvent(ev,TRUE);
+}
+
+
+int SK_GetBareEvent(SoftKeyEvent *ev)
{
- int f;
+ return GetEvent(ev,FALSE);
+}
- for(f=0; f < NUM_SOFT_KEYS; f++)
+
+void SK_SetSticky(SoftKey key, int is_sticky)
+{
+ key_state[key].is_sticky = is_sticky;
+
+ if (!is_sticky)
{
- key_state[f].state = FALSE;
+ key_state[key].new_state = FALSE;
}
}
@@ -311,3 +339,9 @@ void SK_DefinePad(SoftKey pad, SoftKey key)
}
+const char *SK_KeyName(SoftKey k)
+{
+ return keynames[k];
+}
+
+
diff --git a/arm9/source/main.c b/arm9/source/main.c
index 83bc543..38c28f1 100644
--- a/arm9/source/main.c
+++ b/arm9/source/main.c
@@ -99,53 +99,53 @@ static void Splash(void)
FB_Blit(&img,0,0);
- y=10;
+ y = 10;
for(f=0;text[f];f++)
{
FB_Centre(text[f],y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
}
- y+=8;
+ y += 8;
if (fatInitialise(32,true))
{
ZX81EnableFileSystem(TRUE);
FB_Centre("Found a FAT device.",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("If you place .P tape files in",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("the top directory or ZX81TAPE",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("then you should be able to load",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("GAME.P with the command",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("LOAD \"GAME\"",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
}
else
{
ZX81EnableFileSystem(FALSE);
FB_Centre("Sorry, but you don't have a",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("supported FAT device.",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("Only the internal tape",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("files can be used.",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
}
while(!(keysDown() & KEY_A))
@@ -155,6 +155,64 @@ static void Splash(void)
}
+/* ---------------------------------------- JOYPAD MAPPING
+*/
+static void MapJoypad(void)
+{
+ SoftKeyEvent ev;
+ SoftKey pad = NUM_SOFT_KEYS;
+ int done = FALSE;
+ char text[256];
+
+ SK_DisplayKeyboard(BG_GFX_SUB);
+
+ ZX81DisplayString("press the joypad button you want\n"
+ "to define and then the ZX81 key\n"
+ "you want to use.\n\n"
+ "press on the config banner to\n"
+ "finish.");
+
+ while(!done)
+ {
+ while(SK_GetBareEvent(&ev))
+ {
+ if (ev.pressed)
+ {
+ if (ev.key==SK_ABOUT || ev.key==SK_CONFIG)
+ {
+ done = true;
+ }
+ }
+ else
+ {
+ if (ev.key>=SK_PAD_UP && ev.key<=SK_PAD_SELECT)
+ {
+ pad = ev.key;
+
+ /* Now, just how dumb was making % the inverse on/off...
+ */
+ sprintf(text,"defining\n %%%s%%",SK_KeyName(pad));
+ ZX81DisplayString(text);
+ }
+
+ if (ev.key<=SK_SPACE && pad!=NUM_SOFT_KEYS)
+ {
+ sprintf(text,"mapped\n %%%s%%\nto\n %%%s%%",
+ SK_KeyName(pad),SK_KeyName(ev.key));
+ ZX81DisplayString(text);
+
+ SK_DefinePad(pad,ev.key);
+
+ pad = NUM_SOFT_KEYS;
+ }
+ }
+ }
+
+ swiWaitForVBlank();
+ }
+}
+
+
/* ---------------------------------------- MAIN
*/
int main(int argc, char *argv[])
@@ -251,7 +309,7 @@ int main(int argc, char *argv[])
break;
case MenuMapJoypad:
- SK_DisplayKeyboard(BG_GFX_SUB);
+ MapJoypad();
break;
}
diff --git a/arm9/source/zx81.c b/arm9/source/zx81.c
index 6173701..533c382 100644
--- a/arm9/source/zx81.c
+++ b/arm9/source/zx81.c
@@ -446,13 +446,13 @@ static void ZX81HouseKeeping(Z80 *z80)
if (lastk1 && (lastk1!=prev_lk1 || lastk2!=prev_lk2))
{
mem[CDFLAG]|=1;
+
+ mem[LASTK1]=lastk1^0xff;
+ mem[LASTK2]=lastk2^0xff;
}
prev_lk1=lastk1;
prev_lk2=lastk2;
-
- mem[LASTK1]=lastk1^0xff;
- mem[LASTK2]=lastk2^0xff;
}
diff --git a/include/keyboard.h b/include/keyboard.h
index c3fab5b..2afb5df 100644
--- a/include/keyboard.h
+++ b/include/keyboard.h
@@ -108,18 +108,23 @@ void SK_DisplayKeyboard(uint16 *vram);
*/
int SK_GetEvent(SoftKeyEvent *ev);
+/* Returns TRUE while there are still key events for this cycle. Unlike
+ SK_GetEvent this does not do joypad mappings.
+*/
+int SK_GetBareEvent(SoftKeyEvent *ev);
+
/* Sets a key to be 'sticky' (it will be released automatically on the next
non-sticky press).
*/
void SK_SetSticky(SoftKey key, int is_sticky);
-/* Flush all the keys.
-*/
-void SK_ClearKeys(void);
-
/* Map the joypad to keys. Note that when mapped that both the key and the
joypad code will be generated.
*/
void SK_DefinePad(SoftKey pad, SoftKey key);
+/* Returns a name for key symbols.
+*/
+const char *SK_KeyName(SoftKey pad);
+
#endif /* DS81_KEYBOARD_H */
diff --git a/source/keyboard.c b/source/keyboard.c
index 8db8d34..04ae120 100644
--- a/source/keyboard.c
+++ b/source/keyboard.c
@@ -61,11 +61,11 @@ static SoftKey pad_select_key = NUM_SOFT_KEYS;
} \
} while(0)
-#define CHECK_STATE(KEYS,BIT,CODE,SHORTCUT) \
+#define CHECK_STATE(KEYS,BIT,CODE,SHORTCUT,USE_SHORTCUT) \
do \
{ \
key_state[CODE].new_state = (KEYS & BIT); \
- if (SHORTCUT != NUM_SOFT_KEYS && \
+ if (USE_SHORTCUT && SHORTCUT != NUM_SOFT_KEYS && \
!key_state[SHORTCUT].handled && (KEYS & BIT)) \
{ \
key_state[SHORTCUT].new_state = TRUE; \
@@ -73,6 +73,33 @@ static SoftKey pad_select_key = NUM_SOFT_KEYS;
} while(0)
+static const char *keynames[]=
+{
+ "1", "2", "3", "4", "5",
+ "6", "7", "8", "9", "0",
+ "Q", "W", "E", "R", "T",
+ "Y", "U", "I", "O", "P",
+ "A", "S", "D", "F", "G",
+ "H", "J", "K", "L", "NEWLINE",
+ "SHIFT", "Z", "X", "C", "V",
+ "B", "N", "M", "PERIOD", "SPACE",
+
+ "ABOUT",
+ "CONFIG",
+ "JOYPAD UP",
+ "JOYPAD DOWN",
+ "JOYPAD LEFT",
+ "JOYPAD RIGHT",
+ "A BUTTON",
+ "B BUTTON",
+ "X BUTTON",
+ "Y BUTTON",
+ "RIGHT SHOULDER BUTTON",
+ "LEFT SHOULDER BUTTON",
+ "START BUTTON",
+ "SELECT BUTTON"
+};
+
/* ---------------------------------------- PRIVATE INTERFACES
*/
static SoftKey LocatePress(const touchPosition *p)
@@ -99,19 +126,7 @@ static SoftKey LocatePress(const touchPosition *p)
}
-/* ---------------------------------------- PUBLIC INTERFACES
-*/
-void SK_DisplayKeyboard(uint16 *vram)
-{
- sImage img;
-
- loadPCX(keyb_bin,&img);
- image8to16(&img);
- dmaCopy(img.data8,vram,SCREEN_WIDTH*SCREEN_HEIGHT*2);
-}
-
-
-int SK_GetEvent(SoftKeyEvent *ev)
+static int GetEvent(SoftKeyEvent *ev, int map)
{
static SoftKey last = NUM_SOFT_KEYS;
static int poll_index = -1;
@@ -187,18 +202,18 @@ int SK_GetEvent(SoftKeyEvent *ev)
/* Check non soft-keyboard controls
*/
- CHECK_STATE(keys, KEY_A, SK_PAD_A, pad_A_key);
- CHECK_STATE(keys, KEY_B, SK_PAD_B, pad_B_key);
- CHECK_STATE(keys, KEY_X, SK_PAD_X, pad_X_key);
- CHECK_STATE(keys, KEY_Y, SK_PAD_Y, pad_Y_key);
- CHECK_STATE(keys, KEY_R, SK_PAD_R, pad_R_key);
- CHECK_STATE(keys, KEY_L, SK_PAD_L, pad_L_key);
- CHECK_STATE(keys, KEY_START, SK_PAD_START, pad_start_key);
- CHECK_STATE(keys, KEY_SELECT, SK_PAD_SELECT, pad_select_key);
- CHECK_STATE(keys, KEY_UP, SK_PAD_UP, pad_up_key);
- CHECK_STATE(keys, KEY_DOWN, SK_PAD_DOWN, pad_down_key);
- CHECK_STATE(keys, KEY_LEFT, SK_PAD_LEFT, pad_left_key);
- CHECK_STATE(keys, KEY_RIGHT, SK_PAD_RIGHT, pad_right_key);
+ CHECK_STATE(keys, KEY_A, SK_PAD_A, pad_A_key, map);
+ CHECK_STATE(keys, KEY_B, SK_PAD_B, pad_B_key, map);
+ CHECK_STATE(keys, KEY_X, SK_PAD_X, pad_X_key, map);
+ CHECK_STATE(keys, KEY_Y, SK_PAD_Y, pad_Y_key, map);
+ CHECK_STATE(keys, KEY_R, SK_PAD_R, pad_R_key, map);
+ CHECK_STATE(keys, KEY_L, SK_PAD_L, pad_L_key, map);
+ CHECK_STATE(keys, KEY_START, SK_PAD_START, pad_start_key, map);
+ CHECK_STATE(keys, KEY_SELECT, SK_PAD_SELECT, pad_select_key, map);
+ CHECK_STATE(keys, KEY_UP, SK_PAD_UP, pad_up_key, map);
+ CHECK_STATE(keys, KEY_DOWN, SK_PAD_DOWN, pad_down_key, map);
+ CHECK_STATE(keys, KEY_LEFT, SK_PAD_LEFT, pad_left_key, map);
+ CHECK_STATE(keys, KEY_RIGHT, SK_PAD_RIGHT, pad_right_key, map);
/* Reset key event poll index
*/
@@ -243,24 +258,37 @@ int SK_GetEvent(SoftKeyEvent *ev)
}
-void SK_SetSticky(SoftKey key, int is_sticky)
+/* ---------------------------------------- PUBLIC INTERFACES
+*/
+void SK_DisplayKeyboard(uint16 *vram)
{
- key_state[key].is_sticky = is_sticky;
+ sImage img;
- if (!is_sticky)
- {
- key_state[key].new_state = FALSE;
- }
+ loadPCX(keyb_bin,&img);
+ image8to16(&img);
+ dmaCopy(img.data8,vram,SCREEN_WIDTH*SCREEN_HEIGHT*2);
}
-void SK_ClearKeys(void)
+int SK_GetEvent(SoftKeyEvent *ev)
+{
+ return GetEvent(ev,TRUE);
+}
+
+
+int SK_GetBareEvent(SoftKeyEvent *ev)
{
- int f;
+ return GetEvent(ev,FALSE);
+}
- for(f=0; f < NUM_SOFT_KEYS; f++)
+
+void SK_SetSticky(SoftKey key, int is_sticky)
+{
+ key_state[key].is_sticky = is_sticky;
+
+ if (!is_sticky)
{
- key_state[f].state = FALSE;
+ key_state[key].new_state = FALSE;
}
}
@@ -311,3 +339,9 @@ void SK_DefinePad(SoftKey pad, SoftKey key)
}
+const char *SK_KeyName(SoftKey k)
+{
+ return keynames[k];
+}
+
+
diff --git a/source/main.c b/source/main.c
index 83bc543..38c28f1 100644
--- a/source/main.c
+++ b/source/main.c
@@ -99,53 +99,53 @@ static void Splash(void)
FB_Blit(&img,0,0);
- y=10;
+ y = 10;
for(f=0;text[f];f++)
{
FB_Centre(text[f],y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
}
- y+=8;
+ y += 8;
if (fatInitialise(32,true))
{
ZX81EnableFileSystem(TRUE);
FB_Centre("Found a FAT device.",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("If you place .P tape files in",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("the top directory or ZX81TAPE",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("then you should be able to load",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("GAME.P with the command",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("LOAD \"GAME\"",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
}
else
{
ZX81EnableFileSystem(FALSE);
FB_Centre("Sorry, but you don't have a",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("supported FAT device.",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("Only the internal tape",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
FB_Centre("files can be used.",y,FB_RGB(31,31,31),-1);
- y+=8;
+ y += 8;
}
while(!(keysDown() & KEY_A))
@@ -155,6 +155,64 @@ static void Splash(void)
}
+/* ---------------------------------------- JOYPAD MAPPING
+*/
+static void MapJoypad(void)
+{
+ SoftKeyEvent ev;
+ SoftKey pad = NUM_SOFT_KEYS;
+ int done = FALSE;
+ char text[256];
+
+ SK_DisplayKeyboard(BG_GFX_SUB);
+
+ ZX81DisplayString("press the joypad button you want\n"
+ "to define and then the ZX81 key\n"
+ "you want to use.\n\n"
+ "press on the config banner to\n"
+ "finish.");
+
+ while(!done)
+ {
+ while(SK_GetBareEvent(&ev))
+ {
+ if (ev.pressed)
+ {
+ if (ev.key==SK_ABOUT || ev.key==SK_CONFIG)
+ {
+ done = true;
+ }
+ }
+ else
+ {
+ if (ev.key>=SK_PAD_UP && ev.key<=SK_PAD_SELECT)
+ {
+ pad = ev.key;
+
+ /* Now, just how dumb was making % the inverse on/off...
+ */
+ sprintf(text,"defining\n %%%s%%",SK_KeyName(pad));
+ ZX81DisplayString(text);
+ }
+
+ if (ev.key<=SK_SPACE && pad!=NUM_SOFT_KEYS)
+ {
+ sprintf(text,"mapped\n %%%s%%\nto\n %%%s%%",
+ SK_KeyName(pad),SK_KeyName(ev.key));
+ ZX81DisplayString(text);
+
+ SK_DefinePad(pad,ev.key);
+
+ pad = NUM_SOFT_KEYS;
+ }
+ }
+ }
+
+ swiWaitForVBlank();
+ }
+}
+
+
/* ---------------------------------------- MAIN
*/
int main(int argc, char *argv[])
@@ -251,7 +309,7 @@ int main(int argc, char *argv[])
break;
case MenuMapJoypad:
- SK_DisplayKeyboard(BG_GFX_SUB);
+ MapJoypad();
break;
}
diff --git a/source/zx81.c b/source/zx81.c
index 6173701..533c382 100644
--- a/source/zx81.c
+++ b/source/zx81.c
@@ -446,13 +446,13 @@ static void ZX81HouseKeeping(Z80 *z80)
if (lastk1 && (lastk1!=prev_lk1 || lastk2!=prev_lk2))
{
mem[CDFLAG]|=1;
+
+ mem[LASTK1]=lastk1^0xff;
+ mem[LASTK2]=lastk2^0xff;
}
prev_lk1=lastk1;
prev_lk2=lastk2;
-
- mem[LASTK1]=lastk1^0xff;
- mem[LASTK2]=lastk2^0xff;
}