diff options
author | Ian C <ianc@noddybox.co.uk> | 2006-10-10 00:05:34 +0000 |
---|---|---|
committer | Ian C <ianc@noddybox.co.uk> | 2006-10-10 00:05:34 +0000 |
commit | 162c8b864f9c9c98470887d4bc6c03eab222452a (patch) | |
tree | 68ccb03a8eaaa34a62006288a98a354a9a26019d | |
parent | a50b3820e29af6d12b86c55afb8be1aee9091558 (diff) |
Added joypad mappings for pre-defined tapes
-rw-r--r-- | arm9/include/keyboard.h | 2 | ||||
-rw-r--r-- | arm9/source/keyboard.c | 43 | ||||
-rw-r--r-- | arm9/source/main.c | 5 | ||||
-rw-r--r-- | arm9/source/tapes.c | 76 | ||||
-rw-r--r-- | include/keyboard.h | 2 | ||||
-rw-r--r-- | source/keyboard.c | 43 | ||||
-rw-r--r-- | source/main.c | 5 | ||||
-rw-r--r-- | source/tapes.c | 76 |
8 files changed, 224 insertions, 28 deletions
diff --git a/arm9/include/keyboard.h b/arm9/include/keyboard.h index eefde86..862007c 100644 --- a/arm9/include/keyboard.h +++ b/arm9/include/keyboard.h @@ -120,6 +120,6 @@ 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_DefineJoypad(void); +void SK_DefinePad(SoftKey pad, SoftKey key); #endif /* DS81_KEYBOARD_H */ diff --git a/arm9/source/keyboard.c b/arm9/source/keyboard.c index 31b39a1..786b32d 100644 --- a/arm9/source/keyboard.c +++ b/arm9/source/keyboard.c @@ -255,8 +255,49 @@ void SK_ClearKeys(void) } -void SK_DefineJoypad(void) +void SK_DefinePad(SoftKey pad, SoftKey key) { + switch(pad) + { + case SK_PAD_LEFT: + pad_left_key = key; + break; + case SK_PAD_RIGHT: + pad_right_key = key; + break; + case SK_PAD_UP: + pad_up_key = key; + break; + case SK_PAD_DOWN: + pad_down_key = key; + break; + case SK_PAD_A: + pad_A_key = key; + break; + case SK_PAD_B: + pad_B_key = key; + break; + case SK_PAD_X: + pad_X_key = key; + break; + case SK_PAD_Y: + pad_Y_key = key; + break; + case SK_PAD_R: + pad_R_key = key; + break; + case SK_PAD_L: + pad_L_key = key; + break; + case SK_PAD_START: + pad_start_key = key; + break; + case SK_PAD_SELECT: + pad_select_key = key; + break; + default: + break; + } } diff --git a/arm9/source/main.c b/arm9/source/main.c index 78d40c1..05f71df 100644 --- a/arm9/source/main.c +++ b/arm9/source/main.c @@ -42,7 +42,6 @@ static const char *main_menu[]= "Select Tape", "Sticky Shift On", "Sticky Shift Off", - "Define Joystick", "Cancel", NULL }; @@ -53,7 +52,6 @@ typedef enum MenuSelectTape, MenuStickyOn, MenuStickyOff, - MenuDefineJoystick } MenuOpt; @@ -203,9 +201,6 @@ int main(int argc, char *argv[]) case MenuStickyOff: SK_SetSticky(SK_SHIFT,0); break; - - case MenuDefineJoystick: - break; } SK_DisplayKeyboard(BG_GFX_SUB); diff --git a/arm9/source/tapes.c b/arm9/source/tapes.c index adac3b6..ce4082c 100644 --- a/arm9/source/tapes.c +++ b/arm9/source/tapes.c @@ -24,6 +24,7 @@ #include "tapes.h" #include "framebuffer.h" +#include "keyboard.h" #include "zx81.h" #include "maze_bin.h" @@ -41,12 +42,46 @@ typedef struct const u8 *tape; const u32 *tape_len; sImage img; - void *source_pcx; + const void *source_pcx; + SoftKey *keys; const char *text; } Tape; #define NO_TAPES 3 +static SoftKey maze_keys[]= + { + SK_PAD_UP, SK_7, + SK_PAD_LEFT, SK_5, + SK_PAD_RIGHT, SK_8, + SK_PAD_START, SK_C, + SK_PAD_SELECT, SK_A, + NUM_SOFT_KEYS + }; + +static SoftKey cpatrol_keys[]= + { + SK_PAD_UP, SK_F, + SK_PAD_R, SK_J, + SK_PAD_L, SK_N, + SK_PAD_DOWN, SK_V, + SK_PAD_A, SK_0, + NUM_SOFT_KEYS + }; + +static SoftKey sabotage_keys[]= + { + SK_PAD_UP, SK_W, + SK_PAD_LEFT, SK_H, + SK_PAD_RIGHT, SK_J, + SK_PAD_DOWN, SK_S, + SK_PAD_A, SK_E, + SK_PAD_R, SK_1, + SK_PAD_L, SK_2, + SK_PAD_START, SK_0, + NUM_SOFT_KEYS + }; + static Tape tapes[NO_TAPES]= { { @@ -54,32 +89,44 @@ static Tape tapes[NO_TAPES]= &maze_bin_size, {0}, maze_inlay_bin, + maze_keys, "%3d monster maze%\n" "(c) 1983 Malcom E. Evans\n\n" - "Escape the maze and its T-Rex\n" - "\n\n" + "Escape the maze and its T-Rex\n\n" + "use joypad for turning and to\n" + "move forward.\n" + "%start% to start.\n" + "%select% to appeal.\n\n" "%note% when the screen goes grey\n" "for 30-60 seconds this is not a\n" - "problem, and is the game creating\n" - "the lair of rex." + "problem - the game is creating\n" + "the maze." }, { cpatrol_bin, &cpatrol_bin_size, {0}, cpatrol_inlay_bin, + cpatrol_keys, "%city patrol%\n" "(c) 1982 Don Priestley\n\n" "Defend the city from the aliens.\n\n" "yes - that parallax city was\n" "done with a text mode and the\n" - "equivalent of a 0.8mhz z80" + "equivalent of a 0.8mhz z80\n\n" + "the joypad controls up and down.\n" + "the %L% and %R% shoulder buttons\n" + "move left and right.\n" + "when moving left or right use\n" + "the other shoulder button\n" + "to move fast. %A% fires.\n" }, { sabotage_bin, &sabotage_bin_size, {0}, sabotage_inlay_bin, + sabotage_keys, "%sabotage%\n" "(c) 1982 Don Priestley\n\n" "Destroy the boxes before the\n" @@ -90,7 +137,11 @@ static Tape tapes[NO_TAPES]= "the dazzling graphics of other\n" "ZX81 games it more than makes\n" "up with a simply joyous\n" - "gameplay mechanic.\n" + "gameplay mechanic.\n\n" + "The joypad controls the player.\n" + "%A% plants a bomb. %L% shoulder\n" + "to play as the guard, %R% as\n" + "the saboteur." } }; @@ -127,6 +178,9 @@ static void DisplayTape(Tape *t) FB_Print("to choose",0,10,FB_RGB(255,255,255),-1); FB_Print("A to select",0,30,FB_RGB(255,255,255),-1); FB_Print("B to cancel",0,40,FB_RGB(255,255,255),-1); + FB_Print("REMEMBER TO",0,60,FB_RGB(255,255,255),-1); + FB_Print("LOAD \"\"",0,70,FB_RGB(255,255,255),-1); + FB_Print("ON THE ZX81!",0,80,FB_RGB(255,255,255),-1); ZX81DisplayString(t->text); } @@ -163,8 +217,16 @@ void SelectTape(void) } else if (key & KEY_A) { + int f; + done=TRUE; ZX81SetTape(tapes[current].tape,*tapes[current].tape_len); + + for(f=0;tapes[current].keys[f]!=NUM_SOFT_KEYS;f+=2) + { + SK_DefinePad(tapes[current].keys[f], + tapes[current].keys[f+1]); + } } else if (key & KEY_B) { diff --git a/include/keyboard.h b/include/keyboard.h index eefde86..862007c 100644 --- a/include/keyboard.h +++ b/include/keyboard.h @@ -120,6 +120,6 @@ 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_DefineJoypad(void); +void SK_DefinePad(SoftKey pad, SoftKey key); #endif /* DS81_KEYBOARD_H */ diff --git a/source/keyboard.c b/source/keyboard.c index 31b39a1..786b32d 100644 --- a/source/keyboard.c +++ b/source/keyboard.c @@ -255,8 +255,49 @@ void SK_ClearKeys(void) } -void SK_DefineJoypad(void) +void SK_DefinePad(SoftKey pad, SoftKey key) { + switch(pad) + { + case SK_PAD_LEFT: + pad_left_key = key; + break; + case SK_PAD_RIGHT: + pad_right_key = key; + break; + case SK_PAD_UP: + pad_up_key = key; + break; + case SK_PAD_DOWN: + pad_down_key = key; + break; + case SK_PAD_A: + pad_A_key = key; + break; + case SK_PAD_B: + pad_B_key = key; + break; + case SK_PAD_X: + pad_X_key = key; + break; + case SK_PAD_Y: + pad_Y_key = key; + break; + case SK_PAD_R: + pad_R_key = key; + break; + case SK_PAD_L: + pad_L_key = key; + break; + case SK_PAD_START: + pad_start_key = key; + break; + case SK_PAD_SELECT: + pad_select_key = key; + break; + default: + break; + } } diff --git a/source/main.c b/source/main.c index 78d40c1..05f71df 100644 --- a/source/main.c +++ b/source/main.c @@ -42,7 +42,6 @@ static const char *main_menu[]= "Select Tape", "Sticky Shift On", "Sticky Shift Off", - "Define Joystick", "Cancel", NULL }; @@ -53,7 +52,6 @@ typedef enum MenuSelectTape, MenuStickyOn, MenuStickyOff, - MenuDefineJoystick } MenuOpt; @@ -203,9 +201,6 @@ int main(int argc, char *argv[]) case MenuStickyOff: SK_SetSticky(SK_SHIFT,0); break; - - case MenuDefineJoystick: - break; } SK_DisplayKeyboard(BG_GFX_SUB); diff --git a/source/tapes.c b/source/tapes.c index adac3b6..ce4082c 100644 --- a/source/tapes.c +++ b/source/tapes.c @@ -24,6 +24,7 @@ #include "tapes.h" #include "framebuffer.h" +#include "keyboard.h" #include "zx81.h" #include "maze_bin.h" @@ -41,12 +42,46 @@ typedef struct const u8 *tape; const u32 *tape_len; sImage img; - void *source_pcx; + const void *source_pcx; + SoftKey *keys; const char *text; } Tape; #define NO_TAPES 3 +static SoftKey maze_keys[]= + { + SK_PAD_UP, SK_7, + SK_PAD_LEFT, SK_5, + SK_PAD_RIGHT, SK_8, + SK_PAD_START, SK_C, + SK_PAD_SELECT, SK_A, + NUM_SOFT_KEYS + }; + +static SoftKey cpatrol_keys[]= + { + SK_PAD_UP, SK_F, + SK_PAD_R, SK_J, + SK_PAD_L, SK_N, + SK_PAD_DOWN, SK_V, + SK_PAD_A, SK_0, + NUM_SOFT_KEYS + }; + +static SoftKey sabotage_keys[]= + { + SK_PAD_UP, SK_W, + SK_PAD_LEFT, SK_H, + SK_PAD_RIGHT, SK_J, + SK_PAD_DOWN, SK_S, + SK_PAD_A, SK_E, + SK_PAD_R, SK_1, + SK_PAD_L, SK_2, + SK_PAD_START, SK_0, + NUM_SOFT_KEYS + }; + static Tape tapes[NO_TAPES]= { { @@ -54,32 +89,44 @@ static Tape tapes[NO_TAPES]= &maze_bin_size, {0}, maze_inlay_bin, + maze_keys, "%3d monster maze%\n" "(c) 1983 Malcom E. Evans\n\n" - "Escape the maze and its T-Rex\n" - "\n\n" + "Escape the maze and its T-Rex\n\n" + "use joypad for turning and to\n" + "move forward.\n" + "%start% to start.\n" + "%select% to appeal.\n\n" "%note% when the screen goes grey\n" "for 30-60 seconds this is not a\n" - "problem, and is the game creating\n" - "the lair of rex." + "problem - the game is creating\n" + "the maze." }, { cpatrol_bin, &cpatrol_bin_size, {0}, cpatrol_inlay_bin, + cpatrol_keys, "%city patrol%\n" "(c) 1982 Don Priestley\n\n" "Defend the city from the aliens.\n\n" "yes - that parallax city was\n" "done with a text mode and the\n" - "equivalent of a 0.8mhz z80" + "equivalent of a 0.8mhz z80\n\n" + "the joypad controls up and down.\n" + "the %L% and %R% shoulder buttons\n" + "move left and right.\n" + "when moving left or right use\n" + "the other shoulder button\n" + "to move fast. %A% fires.\n" }, { sabotage_bin, &sabotage_bin_size, {0}, sabotage_inlay_bin, + sabotage_keys, "%sabotage%\n" "(c) 1982 Don Priestley\n\n" "Destroy the boxes before the\n" @@ -90,7 +137,11 @@ static Tape tapes[NO_TAPES]= "the dazzling graphics of other\n" "ZX81 games it more than makes\n" "up with a simply joyous\n" - "gameplay mechanic.\n" + "gameplay mechanic.\n\n" + "The joypad controls the player.\n" + "%A% plants a bomb. %L% shoulder\n" + "to play as the guard, %R% as\n" + "the saboteur." } }; @@ -127,6 +178,9 @@ static void DisplayTape(Tape *t) FB_Print("to choose",0,10,FB_RGB(255,255,255),-1); FB_Print("A to select",0,30,FB_RGB(255,255,255),-1); FB_Print("B to cancel",0,40,FB_RGB(255,255,255),-1); + FB_Print("REMEMBER TO",0,60,FB_RGB(255,255,255),-1); + FB_Print("LOAD \"\"",0,70,FB_RGB(255,255,255),-1); + FB_Print("ON THE ZX81!",0,80,FB_RGB(255,255,255),-1); ZX81DisplayString(t->text); } @@ -163,8 +217,16 @@ void SelectTape(void) } else if (key & KEY_A) { + int f; + done=TRUE; ZX81SetTape(tapes[current].tape,*tapes[current].tape_len); + + for(f=0;tapes[current].keys[f]!=NUM_SOFT_KEYS;f+=2) + { + SK_DefinePad(tapes[current].keys[f], + tapes[current].keys[f+1]); + } } else if (key & KEY_B) { |