diff --git a/src/defs.h b/src/defs.h index df0f1686..586549d5 100644 --- a/src/defs.h +++ b/src/defs.h @@ -122,6 +122,33 @@ enum _cmds { #define EscapePressedR() KeyIsPressedR (SDLK_ESCAPE) #define SpacePressedR() KeyIsPressedR (SDLK_SPACE) +#ifdef GCW0 // GCW0 keys are currently mapped to SDL key by the firmware... +#define Gcw0APressed() (KeyIsPressed(SDLK_LCTRL)) +#define Gcw0BPressed() (KeyIsPressed(SDLK_LALT)) +#define Gcw0XPressed() (KeyIsPressed(SDLK_LSHIFT)) +#define Gcw0YPressed() (KeyIsPressed(SDLK_SPACE)) +#define Gcw0RSPressed() (KeyIsPressed(SDLK_BACKSPACE)) +#define Gcw0LSPressed() (KeyIsPressed(SDLK_TAB)) +#define Gcw0StartPressed() (KeyIsPressed(SDLK_RETURN)) +#define Gcw0SelectPressed() (KeyIsPressed(SDLK_ESCAPE)) + +#define Gcw0AnyButtonPressed() (Gcw0APressed() || Gcw0BPressed()\ + || Gcw0XPressed() || Gcw0YPressed() || Gcw0LSPressed() || Gcw0RSPressed()\ + || Gcw0StartPressed() || Gcw0SelectPressed()) + +#define Gcw0APressedR() (KeyIsPressedR(SDLK_LCTRL)) +#define Gcw0BPressedR() (KeyIsPressedR(SDLK_LALT)) +#define Gcw0XPressedR() (KeyIsPressedR(SDLK_LSHIFT)) +#define Gcw0YPressedR() (KeyIsPressedR(SDLK_SPACE)) +#define Gcw0RSPressedR() (KeyIsPressedR(SDLK_BACKSPACE)) +#define Gcw0LSPressedR() (KeyIsPressedR(SDLK_TAB)) +#define Gcw0StartPressedR() (KeyIsPressedR(SDLK_RETURN)) +#define Gcw0SelectPressedR() (KeyIsPressedR(SDLK_ESCAPE)) + +#define Gcw0AnyButtonPressedR() (Gcw0APressedR() || Gcw0BPressedR()\ + || Gcw0XPressedR() || Gcw0YPressedR() || Gcw0LSPressedR()\ + || Gcw0RSPressedR() || Gcw0StartPressedR() || Gcw0SelectPressedR()) +#endif // GCW0 keys #define UpPressed() (cmd_is_active(CMD_UP)) #define DownPressed() (cmd_is_active(CMD_DOWN)) @@ -136,8 +163,35 @@ enum _cmds { #define LeftPressedR() (cmd_is_activeR(CMD_LEFT)) #define RightPressedR() (cmd_is_activeR(CMD_RIGHT)) +#define AnyCmdActive() (cmd_is_active(CMD_FIRE) || cmd_is_active(CMD_ACTIVATE) || cmd_is_active(CMD_TAKEOVER) ) +#define AnyCmdActiveR() (cmd_is_activeR(CMD_FIRE) || cmd_is_activeR(CMD_ACTIVATE) || cmd_is_activeR(CMD_TAKEOVER) ) + #define wait4key() do {while(1) {if(any_key_pressed()) break; else SDL_Delay(50);}; } while(0) +/* Now that I've added ability to clear binds, one can break Freedroid if one + * unbinds all UP / DOWN keys. That's why I've added these, with a fallback key + * too, so that one can ALWAYS navigate the menu. + * Currently MenuBack is not used. */ +#define MenuUpR() (UpPressedR() || WheelUpPressed() || KeyIsPressedR(SDLK_UP)) +#define MenuDownR() (DownPressedR() || WheelDownPressed() || KeyIsPressedR(SDLK_DOWN) ) +#define MenuChooseR() (FirePressedR() || ReturnPressedR() || SpacePressedR()) +#define MenuLeftR() (LeftPressedR() || MouseLeftPressed() || KeyIsPressedR(SDLK_LEFT)) +#define MenuRightR() (RightPressedR() || MouseRightPressed() || KeyIsPressedR(SDLK_RIGHT) ) +#define MenuBackR() (EscapePressedR()) // Not used ATM; but in the future, we might need in case a device has no Escape... + +// For clearing a key in keyconfig (can be redefined here): +#define ClearBoundKeyR() (KeyIsPressedR(SDLK_BACKSPACE)) // Works for GCW0 too, currently, since backspace = RShoulder + +/* Now for the pressed defines... */ +#define MenuUp() (UpPressed() || WheelUpPressed() || KeyIsPressed(SDLK_UP)) +#define MenuDown() (DownPressed() || WheelDownPressed() || KeyIsPressed(SDLK_DOWN) ) +#define MenuChoose() (FirePressed() || ReturnPressed() || SpacePressed()) +#define MenuLeft() (LeftPressed() || MouseLeftPressed() || KeyIsPressed(SDLK_LEFT)) +#define MenuRight() (RightPressed() || MouseRightPressed() || KeyIsPressed(SDLK_RIGHT) ) +#define MenuBack() (EscapePressed()) // Not used ATM; but in the future, we might need in case a device has no Escape... + +#define ClearBoundKey() (KeyIsPressed(SDLK_BACKSPACE)) // Works for GCW0 too, currently, since backspace = RShoulder + // ---------------------------------------- #define COLLISION_STEPSIZE 0.1 diff --git a/src/highscore.c b/src/highscore.c index cdc33f92..68a67fc1 100644 --- a/src/highscore.c +++ b/src/highscore.c @@ -172,13 +172,18 @@ UpdateHighscores (void) SDL_BlitSurface (pic999, NULL, ne_screen, &dst); h = FontHeight (Para_BFont); DisplayText ("Great Score !", dst.x - h, dst.y - h, &User_Rect); -#ifndef ANDROID +#if !defined ANDROID && !defined ARCADEINPUT DisplayText ("Enter your name: ", dst.x - 5*h, dst.y + dst.h, &User_Rect); +#endif +#ifdef ARCADEINPUT + DisplayText ("Enter with U/D, (L/R skip 5 chars),", dst.x - 6*h, dst.y + dst.h, &User_Rect); + DisplayText ("Act = toggle case, Fire to enter,", dst.x - 5*h, dst.y + dst.h + h, &User_Rect); + DisplayText ("Start when ready: ", dst.x - 5*h, dst.y + dst.h + h*2, &User_Rect); #endif SDL_Flip (ne_screen); SDL_SetClipRect (ne_screen, NULL); -#ifndef ANDROID +#if !defined ANDROID tmp_name = GetString (MAX_NAME_LEN, 2); strcpy (new_entry->name, tmp_name); free (tmp_name); diff --git a/src/influ.c b/src/influ.c index 3d10433a..758a696b 100644 --- a/src/influ.c +++ b/src/influ.c @@ -180,8 +180,9 @@ MoveInfluence (void) if (RightPressed()) Me.speed.x += accel; - if (!SpacePressed()) - Me.status = MOBILE; +// We only need this check if we want held fire to cause activate + if (!AnyCmdActive()) // Used to be !SpacePressed, which causes any fire button != SPACE behave differently than space + Me.status = MOBILE; if (TransferCounter == 1) { @@ -192,8 +193,8 @@ MoveInfluence (void) if (cmd_is_active(CMD_ACTIVATE)) // activate mode for Konsole and Lifts Me.status = ACTIVATE; - if ( (FirePressed ()) && (NoDirectionPressed ()) &&(Me.status != WEAPON) && (Me.status != TRANSFERMODE) ) - TransferCounter += Frame_Time(); + if ( GameConfig.FireHoldTakeover && (FirePressed ()) && (NoDirectionPressed ()) &&(Me.status != WEAPON) && (Me.status != TRANSFERMODE) ) // Proposed FireActivatePressed here... + TransferCounter += Frame_Time(); // Or make it an option! if ( (FirePressed() ) && (!NoDirectionPressed () ) && (Me.status != TRANSFERMODE) ) Me.status = WEAPON; diff --git a/src/init.c b/src/init.c index 01be68e9..379c64b7 100644 --- a/src/init.c +++ b/src/init.c @@ -911,9 +911,14 @@ InitFreedroid (int argc, char *const argv[]) GameConfig.FullUserRect = TRUE; GameConfig.UseFullscreen = FALSE; GameConfig.TakeoverActivates = TRUE; + GameConfig.FireHoldTakeover = TRUE; GameConfig.ShowDecals = FALSE; GameConfig.AllMapVisible = TRUE; // classic setting: map always visible +#ifdef GCW0 + GameConfig.scale = 0.5; // Default for 320x200 device (GCW0) +#else GameConfig.scale = 1.0; // overall scaling of _all_ graphics (e.g. for 320x200 displays) +#endif GameConfig.HogCPU = FALSE; // default to being nice // now load saved options from the config-file diff --git a/src/input.c b/src/input.c index e87856d6..a2ea2eeb 100644 --- a/src/input.c +++ b/src/input.c @@ -61,6 +61,18 @@ int input_state[INPUT_LAST]; // array of states (pressed/released) of all keys int key_cmds[CMD_LAST][3] = // array of mappings {key1,key2,key3 -> cmd} { +#ifdef GCW0 + {SDLK_UP, JOY_UP, 0 }, // CMD_UP + {SDLK_DOWN, JOY_DOWN, 0 }, // CMD_DOWN + {SDLK_LEFT, JOY_LEFT, 0 }, // CMD_LEFT + {SDLK_RIGHT, JOY_RIGHT, 0 }, // CMD_RIGHT + {SDLK_SPACE, SDLK_LCTRL, 0 },// CMD_FIRE + {SDLK_LALT, SDLK_LSHIFT, 0 }, // CMD_ACTIVATE + {SDLK_BACKSPACE, SDLK_TAB, 0 },// CMD_TAKEOVER + {0, 0, 0 }, // CMD_QUIT, + {SDLK_RETURN, 0, 0 }, // CMD_PAUSE, + {0, 0, 0 } // CMD_SCREENSHOT +#else {SDLK_UP, JOY_UP, 'w' }, // CMD_UP {SDLK_DOWN, JOY_DOWN, 's' }, // CMD_DOWN {SDLK_LEFT, JOY_LEFT, 'a' }, // CMD_LEFT @@ -71,6 +83,7 @@ int key_cmds[CMD_LAST][3] = // array of mappings {key1,key2,key3 -> cmd} {'q', 'q', 'q' }, // CMD_QUIT, {SDLK_PAUSE, 'p', 'p' }, // CMD_PAUSE, {SDLK_F12, SDLK_F12, SDLK_F12 } // CMD_SCREENSHOT +#endif }; char *keystr[INPUT_LAST]; @@ -104,13 +117,22 @@ char *cmd_strings[CMD_LAST] = void init_keystr (void) { + keystr[0] = "NONE"; // Empty bind will otherwise crash on some platforms - also, we choose "NONE" as a placeholder... +#ifdef GCW0 // The GCW0 may change to joystick input altogether in the future - which will make these ifdefs unnecessary, I hope... + keystr[SDLK_BACKSPACE] = "RSldr"; + keystr[SDLK_TAB] = "LSldr"; + keystr[SDLK_RETURN] = "Start"; + keystr[SDLK_SPACE] = "Y"; + keystr[SDLK_ESCAPE] = "Select"; +#else keystr[SDLK_BACKSPACE] = "BS"; keystr[SDLK_TAB] = "Tab"; - keystr[SDLK_CLEAR] = "Clear"; keystr[SDLK_RETURN] = "Return"; - keystr[SDLK_PAUSE] = "Pause"; - keystr[SDLK_ESCAPE] = "Esc"; keystr[SDLK_SPACE] = "Space"; + keystr[SDLK_ESCAPE] = "Esc"; +#endif + keystr[SDLK_CLEAR] = "Clear"; + keystr[SDLK_PAUSE] = "Pause"; keystr[SDLK_EXCLAIM] = "!"; keystr[SDLK_QUOTEDBL] = "\""; keystr[SDLK_HASH] = "#"; @@ -228,12 +250,18 @@ init_keystr (void) keystr[SDLK_NUMLOCK] = "NumLock"; keystr[SDLK_CAPSLOCK] = "CapsLock"; keystr[SDLK_SCROLLOCK]= "ScrlLock"; - keystr[SDLK_RSHIFT] = "RShift"; +#ifdef GCW0 + keystr[SDLK_LSHIFT] = "X"; + keystr[SDLK_LCTRL] = "A"; + keystr[SDLK_LALT] = "B"; +#else keystr[SDLK_LSHIFT] = "LShift"; - keystr[SDLK_RCTRL] = "RCtrl"; keystr[SDLK_LCTRL] = "LCtrl"; - keystr[SDLK_RALT] = "RAlt"; keystr[SDLK_LALT] = "LAlt"; +#endif + keystr[SDLK_RSHIFT] = "RShift"; + keystr[SDLK_RCTRL] = "RCtrl"; + keystr[SDLK_RALT] = "RAlt"; keystr[SDLK_RMETA] = "RMeta"; keystr[SDLK_LMETA] = "LMeta"; keystr[SDLK_LSUPER] = "LSuper"; @@ -314,7 +342,7 @@ void ReactToSpecialKeys(void) { - if ( cmd_is_active(CMD_QUIT) ) + if ( cmd_is_activeR(CMD_QUIT) ) QuitGameMenu(); if ( cmd_is_activeR(CMD_PAUSE) ) @@ -360,10 +388,16 @@ update_input (void) case SDL_KEYDOWN: current_modifiers = event.key.keysym.mod; input_state[event.key.keysym.sym] = PRESSED; +#ifdef GCW0 + if ( input_axis.x || input_axis.y ) axis_is_active = TRUE; // 4 GCW-0 ; breaks cursor keys after axis has been active... +#endif break; case SDL_KEYUP: current_modifiers = event.key.keysym.mod; input_state[event.key.keysym.sym] = RELEASED; +#ifdef GCW0 + axis_is_active = FALSE; +#endif break; case SDL_JOYAXISMOTION: diff --git a/src/menu.c b/src/menu.c index b32752e6..911d7754 100644 --- a/src/menu.c +++ b/src/menu.c @@ -120,14 +120,27 @@ QuitGameMenu (void) #ifndef ANDROID InitiateMenu (TRUE); +#ifdef GCW0 + PutString (ne_screen, User_Rect.x + User_Rect.w/3, + User_Rect.y + User_Rect.h/2, "Press A to quit"); +#else PutString (ne_screen, User_Rect.x + User_Rect.w/10, User_Rect.y + User_Rect.h/2, "Do you really want to quit? (y/n) "); +#endif SDL_Flip (ne_screen); - +#ifdef GCW0 + while ( (!Gcw0AnyButtonPressed()) ) SDL_Delay(1); + if ( (Gcw0APressed()) ) { + while ( (!Gcw0AnyButtonPressedR()) ) SDL_Delay(1); // In case FirePressed && !Gcw0APressed() -> would cause a loop otherwise in the menu... + Terminate (OK); + } +#else while ( (!KeyIsPressed('n')) && (!KeyIsPressed('y')) ) SDL_Delay(1); if (KeyIsPressed('y')) -#endif Terminate (OK); +#endif + +#endif // ANDROID } @@ -149,7 +162,7 @@ EscapeMenu (void) #endif POS_LEGACY_OPTIONS, POS_ON_SCREEN_DISPLAYS, -#ifndef ANDROID +#if !defined ANDROID && !defined GCW0 // Haven't looked at level editor keys, if they are feasibly re-defined for GCW0 it could be enabled... POS_LEVEL_EDITOR, #endif POS_HIGHSCORES, @@ -183,7 +196,7 @@ EscapeMenu (void) #endif PutString (ne_screen, OptionsMenu_Rect.x,Menu_Rect.y+(pos++)*fheight,"Legacy Options"); PutString (ne_screen, OptionsMenu_Rect.x,Menu_Rect.y+(pos++)*fheight,"On-Screen Displays" ); -#ifndef ANDROID +#if !defined ANDROID && !defined GCW0 PutString (ne_screen, OptionsMenu_Rect.x,Menu_Rect.y+(pos++)*fheight, "Level Editor"); #endif PutString (ne_screen, OptionsMenu_Rect.x,Menu_Rect.y+(pos++)*fheight, "Highscores"); @@ -206,7 +219,7 @@ EscapeMenu (void) } - if (FirePressedR()||ReturnPressedR()) + if (MenuChooseR()) { MenuItemSelectedSound(); key = TRUE; @@ -226,7 +239,7 @@ EscapeMenu (void) case POS_LEGACY_OPTIONS: Options_Menu(); break; -#ifndef ANDROID +#if !defined ANDROID && !defined GCW0 case POS_LEVEL_EDITOR: LevelEditor(); finished = TRUE; @@ -251,14 +264,14 @@ EscapeMenu (void) } } - if (UpPressedR () || WheelUpPressed() ) + if (MenuUpR()) { key = TRUE; if (MenuPosition > 1) MenuPosition--; else MenuPosition = POS_QUIT; MoveMenuPositionSound(); } - if (DownPressedR() || WheelDownPressed() ) + if (MenuDownR()) { key = TRUE; if ( MenuPosition < POS_QUIT ) MenuPosition++; @@ -316,7 +329,7 @@ Key_Config_Menu (void) key = TRUE; } - if (FirePressedR()||ReturnPressed()) + if (MenuChooseR()) { MenuItemSelectedSound(); key = TRUE; @@ -328,7 +341,7 @@ Key_Config_Menu (void) oldkey = key_cmds[sely-2][selx-1]; key_cmds[sely-2][selx-1] = '_'; Display_Key_Config (selx, sely); - newkey = getchar_raw(); + newkey = getchar_raw(); // || joystick input! if (newkey == SDLK_ESCAPE) key_cmds[sely-2][selx-1] = oldkey; else @@ -337,36 +350,43 @@ Key_Config_Menu (void) } // if FirePressed() - if (UpPressedR() || WheelUpPressed ()) + if (MenuUpR()) { if ( sely > 1 ) sely--; else sely = LastMenuPos; MoveMenuPositionSound(); key = TRUE; } - if (DownPressedR() || WheelDownPressed ()) + if (MenuDownR()) { if ( sely < LastMenuPos ) sely++; else sely = 1; MoveMenuPositionSound(); key = TRUE; } - if (RightPressedR()) + if (MenuRightR()) { if ( selx < 3 ) selx++; else selx = 1; MoveMenuPositionSound(); key = TRUE; } - if (LeftPressedR()) + if (MenuLeftR()) { if ( selx > 1 ) selx--; else selx = 3; MoveMenuPositionSound(); key = TRUE; } + /* There should really be a way to clear a key; this is dirty... + * On a PC, one could just set a "junk" key, but not on a device with + * limited buttons */ + if (ClearBoundKeyR()) // Currently this = backspace, but in the future... + { + key_cmds[sely-2][selx-1] = 0; + } // Hmm, hopefully nothing nasty happens if back is selected... it doesn't seem to do anything - } // while !key + } // while !key /* TODO: A user can't add joystick axises trough this menu! */ } // while !finished @@ -395,6 +415,11 @@ Display_Key_Config (int selx, int sely) // PutInfluence (startx - 1.1*Block_Rect.w, starty + (MenuPosition-1.5)*fheight); PrintStringFont (ne_screen, (sely==1)? Font2_BFont:Font1_BFont, startx, starty+(posy++)*fheight, "Back"); +#ifdef GCW0 + PrintStringFont (ne_screen, Font0_BFont, col1, starty, "(RShldr to clear an entry)"); +#else + PrintStringFont (ne_screen, Font0_BFont, col1, starty, "(Backspace to clear an entry)"); +#endif PrintStringFont (ne_screen, Font0_BFont, startx, starty + (posy)*fheight, "Command"); PrintStringFont (ne_screen, Font0_BFont, col1, starty + (posy)*fheight, "Key1"); @@ -446,6 +471,7 @@ enum POS_SHOW_DECALS, POS_MAP_VISIBLE, POS_TAKEOVER_IS_ACTIVATE, + POS_FIRE_HOLD_TAKEOVER, POS_BACK }; @@ -484,6 +510,9 @@ enum PrintString (ne_screen, OptionsMenu_Rect.x, Menu_Rect.y+(pos++)*fheight, "Transfer = Activate: %s", GameConfig.TakeoverActivates ? "YES":"NO" ); + PrintString (ne_screen, OptionsMenu_Rect.x, Menu_Rect.y+(pos++)*fheight, + "Hold Fire to Transfer: %s", GameConfig.FireHoldTakeover ? "YES":"NO" ); + PrintString (ne_screen, OptionsMenu_Rect.x, Menu_Rect.y+(pos++)*fheight, "Back"); @@ -502,7 +531,7 @@ enum reload_theme = TRUE; } - if (FirePressedR()||ReturnPressedR()) + if (MenuChooseR()) { MenuItemSelectedSound(); key = TRUE; @@ -512,6 +541,7 @@ enum GameConfig.Droid_Talk = FALSE; GameConfig.ShowDecals = FALSE; GameConfig.TakeoverActivates = TRUE; + GameConfig.FireHoldTakeover = TRUE; GameConfig.AllMapVisible = TRUE; GameConfig.FullUserRect = FALSE; Copy_Rect (Classic_User_Rect, User_Rect); @@ -545,6 +575,9 @@ enum case POS_TAKEOVER_IS_ACTIVATE: GameConfig.TakeoverActivates = !GameConfig.TakeoverActivates; break; + case POS_FIRE_HOLD_TAKEOVER: + GameConfig.FireHoldTakeover = !GameConfig.FireHoldTakeover; + break; case POS_BACK: finished = TRUE; @@ -554,7 +587,7 @@ enum } } // if FirePressed - if (UpPressedR() || WheelUpPressed()) + if (MenuUpR()) { if ( MenuPosition > 1 ) MenuPosition--; else MenuPosition = POS_BACK; @@ -563,7 +596,7 @@ enum ReleaseKey (SDLK_RIGHT); // clear any r-l movement ReleaseKey (SDLK_LEFT); } - if (DownPressedR() || WheelDownPressed()) + if (MenuDownR()) { if ( MenuPosition < POS_BACK ) MenuPosition++; else MenuPosition = 1; @@ -574,7 +607,7 @@ enum } - if (LeftPressedR() ) + if (MenuLeftR() ) { switch (MenuPosition) { @@ -592,7 +625,7 @@ enum break; } } - if (RightPressedR() || MouseRightPressedR() ) + if (MenuRightR() ) { switch (MenuPosition) { @@ -668,7 +701,9 @@ enum { SET_BG_MUSIC_VOLUME=1, SET_SOUND_FX_VOLUME, SET_GAMMA_CORRECTION, +#ifndef GCW0 SET_FULLSCREEN_FLAG, +#endif SET_HOG_CPU, BACK }; @@ -691,8 +726,10 @@ enum "Sound Effects: %1.2f", GameConfig.Current_Sound_FX_Volume ); PrintString (ne_screen, OptionsMenu_Rect.x, Menu_Rect.y+(pos++)*fheight, "Gamma: %1.2f", GameConfig.Current_Gamma_Correction ); +#ifndef GCW0 PrintString (ne_screen, OptionsMenu_Rect.x, Menu_Rect.y+(pos++)*fheight, "Fullscreen Mode: %s", GameConfig.UseFullscreen ? "ON" : "OFF"); +#endif PrintString (ne_screen, OptionsMenu_Rect.x, Menu_Rect.y+(pos++)*fheight, "Use 100%% CPU: %s", GameConfig.HogCPU ? "ON" : "OFF"); PrintString (ne_screen, OptionsMenu_Rect.x, Menu_Rect.y+(pos++)*fheight, "Back"); @@ -707,24 +744,26 @@ enum finished = TRUE; key = TRUE; } - if (RightPressed() || LeftPressed() || MouseLeftPressed() || - FirePressed() || ReturnPressed()|| MouseRightPressed()) + if (MenuLeft() || MenuRight() || MenuChoose()) +// if (RightPressed() || LeftPressed() || MouseLeftPressed() || +// FirePressed() || ReturnPressed()|| MouseRightPressed()) key = TRUE; switch (MenuPosition) { +#ifndef GCW0 case SET_FULLSCREEN_FLAG: - if (FirePressedR()||ReturnPressedR()) + if (MenuChooseR()) { toggle_fullscreen(); MenuItemSelectedSound(); } break; - +#endif case SET_HOG_CPU: - if (FirePressedR()||ReturnPressedR()) + if (MenuChooseR()) { GameConfig.HogCPU = !GameConfig.HogCPU; MenuItemSelectedSound(); @@ -732,7 +771,7 @@ enum break; case BACK: - if (FirePressedR()||ReturnPressedR()) + if (MenuChooseR()) { MenuItemSelectedSound(); finished=TRUE; @@ -740,14 +779,14 @@ enum break; case SET_BG_MUSIC_VOLUME: - if (RightPressedR()||MouseRightPressedR()) + if (MenuRightR()) { if ( GameConfig.Current_BG_Music_Volume < 1 ) GameConfig.Current_BG_Music_Volume += 0.05; Set_BG_Music_Volume( GameConfig.Current_BG_Music_Volume ); MoveMenuPositionSound(); } - if (LeftPressedR()||MouseLeftPressedR()) + if (MenuLeftR()) { if ( GameConfig.Current_BG_Music_Volume > 0 ) GameConfig.Current_BG_Music_Volume -= 0.05; @@ -757,14 +796,14 @@ enum break; case SET_SOUND_FX_VOLUME: - if (RightPressedR()||MouseRightPressedR()) + if (MenuRightR()) { if ( GameConfig.Current_Sound_FX_Volume < 1 ) GameConfig.Current_Sound_FX_Volume += 0.05; Set_Sound_FX_Volume( GameConfig.Current_Sound_FX_Volume ); MoveMenuPositionSound(); } - if (LeftPressedR()||MouseLeftPressedR()) + if (MenuLeftR()) { if ( GameConfig.Current_Sound_FX_Volume > 0 ) GameConfig.Current_Sound_FX_Volume -= 0.05; @@ -774,7 +813,7 @@ enum break; case SET_GAMMA_CORRECTION: - if (RightPressedR()||MouseRightPressedR()) + if (MenuRightR()) { GameConfig.Current_Gamma_Correction+=0.05; SDL_SetGamma( GameConfig.Current_Gamma_Correction , @@ -782,7 +821,7 @@ enum GameConfig.Current_Gamma_Correction ); MoveMenuPositionSound(); } - if (LeftPressedR()||MouseLeftPressedR()) + if (MenuLeftR()) { GameConfig.Current_Gamma_Correction-=0.05; SDL_SetGamma( GameConfig.Current_Gamma_Correction , @@ -798,14 +837,14 @@ enum } // switch MenuPosition - if (UpPressedR() || WheelUpPressed ()) + if (MenuUpR()) { key = TRUE; if ( MenuPosition > 1 ) MenuPosition--; else MenuPosition = BACK; MoveMenuPositionSound(); } - if (DownPressedR() || WheelDownPressed()) + if (MenuDownR()) { key = TRUE; if ( MenuPosition < BACK ) MenuPosition++; @@ -873,7 +912,7 @@ enum key = TRUE; } - if (FirePressedR()||ReturnPressed()) + if (MenuChooseR()) { MenuItemSelectedSound(); key = TRUE; @@ -903,14 +942,14 @@ enum } } // if FirePressed() - if (UpPressedR() || WheelUpPressed ()) + if (MenuUpR()) { if ( MenuPosition > 1 ) MenuPosition--; else MenuPosition = BACK; MoveMenuPositionSound(); key = TRUE; } - if (DownPressedR() || WheelDownPressed ()) + if (MenuDownR()) { if ( MenuPosition < BACK ) MenuPosition++; else MenuPosition = 1; diff --git a/src/misc.c b/src/misc.c index efa56b54..2f836e8c 100644 --- a/src/misc.c +++ b/src/misc.c @@ -126,6 +126,7 @@ read_variable (char *data, char *var_name, char *fmt, void *var) #define FULL_USER_RECT "FullUserRect" #define USE_FULLSCREEN "UseFullscreen" #define TAKEOVER_ACTIVATES "TakeoverActivates" +#define FIRE_HOLD_TAKEOVER "FireHoldTakeover" #define SHOW_DECALS "ShowDecals" #define ALL_MAP_VISIBLE "AllMapVisible" #define VID_SCALE_FACTOR "Vid_ScaleFactor" @@ -234,6 +235,7 @@ LoadGameConfig (void) read_variable (data, FULL_USER_RECT, "%d", &GameConfig.FullUserRect); read_variable (data, USE_FULLSCREEN, "%d", &GameConfig.UseFullscreen); read_variable (data, TAKEOVER_ACTIVATES, "%d", &GameConfig.TakeoverActivates); + read_variable (data, FIRE_HOLD_TAKEOVER, "%d", &GameConfig.FireHoldTakeover); read_variable (data, SHOW_DECALS, "%d", &GameConfig.ShowDecals); read_variable (data, ALL_MAP_VISIBLE, "%d", &GameConfig.AllMapVisible); read_variable (data, VID_SCALE_FACTOR, "%f", &GameConfig.scale); @@ -269,7 +271,7 @@ SaveGameConfig (void) sprintf (fname, "%s/config", ConfigDir); if( (fp = fopen (fname, "w")) == NULL) { - DebugPrintf (0, "WARNING: failed to create config-file: %s\n"); + DebugPrintf (0, "WARNING: failed to create config-file: %s\n", fname); return (ERR); } @@ -288,6 +290,7 @@ SaveGameConfig (void) fprintf (fp, "%s = %d\n", FULL_USER_RECT, GameConfig.FullUserRect); fprintf (fp, "%s = %d\n", USE_FULLSCREEN, GameConfig.UseFullscreen); fprintf (fp, "%s = %d\n", TAKEOVER_ACTIVATES, GameConfig.TakeoverActivates); + fprintf (fp, "%s = %d\n", FIRE_HOLD_TAKEOVER, GameConfig.FireHoldTakeover); fprintf (fp, "%s = %d\n", SHOW_DECALS, GameConfig.ShowDecals); fprintf (fp, "%s = %d\n", ALL_MAP_VISIBLE, GameConfig.AllMapVisible); fprintf (fp, "%s = %f\n", VID_SCALE_FACTOR, GameConfig.scale); @@ -745,17 +748,21 @@ Pause (void) SDL_Delay (1); ComputeFPSForThisFrame(); - +#ifdef GCW0 + if (Gcw0LSPressedR() || Gcw0RSPressedR()) +#else if (KeyIsPressedR ('c')) +#endif { if (Me.status != CHEESE) Me.status = CHEESE; else Me.status = PAUSE; Cheese = !Cheese; } /* if (CPressed) */ - if ( SpacePressedR() ) + if ( FirePressedR() || cmd_is_activeR(CMD_PAUSE) ) { + while (cmd_is_active(CMD_PAUSE)) SDL_Delay(1); Pause = FALSE; - + } } /* while (Pause) */ return; diff --git a/src/ship.c b/src/ship.c index 6d60456d..63674425 100644 --- a/src/ship.c +++ b/src/ship.c @@ -295,6 +295,7 @@ EnterKonsole (void) SpacePressedR(); MouseLeftPressedR(); MouseRightPressedR(); + AnyCmdActiveR(); ResetMouseWheel (); diff --git a/src/sound.c b/src/sound.c index 6a223c3f..517a56c8 100644 --- a/src/sound.c +++ b/src/sound.c @@ -86,7 +86,11 @@ char *MusicFiles [NUM_COLORS] = { // we have a background song per color now "starpaws.mod", // YELLOW "The_Last_V8.mod", // GREEN "dreamfish-green_beret.mod", // GRAY - "dreamfish-sanxion.mod", // BLUE +#ifdef GCW0 + "dreamfish-green_beret.mod", // GRAY +#else + "dreamfish-sanxion.mod", // BLUE // CRASHES the GCW0 ??? +#endif "kollaps-tron.mod", // GREENBLUE "dreamfish-uridium2_loader.mod" // DARK }; @@ -217,7 +221,7 @@ Set_Sound_FX_Volume(float NewVolume) // Set the volume IN the loaded files, if SDL is used... // This is done here for the Files 1,2,3 and 4, since these // are background music files. - for ( i=5 ; i #endif +#ifdef GCW0 +#ifndef ARCADEINPUT +#define ARCADEINPUT +#endif +#endif diff --git a/src/takeover.c b/src/takeover.c index 1e58d78f..92d28e65 100644 --- a/src/takeover.c +++ b/src/takeover.c @@ -154,6 +154,7 @@ Takeover (int enemynum) // release fire keys SpacePressedR(); MouseLeftPressedR(); + AnyCmdActiveR(); // Takeover game always uses Classic User_Rect: Copy_Rect (User_Rect, buf); @@ -406,7 +407,7 @@ PlayGame (void) last_movekey_time = SDL_GetTicks(); } - set = set || (SpacePressed() || MouseLeftPressed()); + set = set || FirePressed(); if (WheelUpPressed()) wheel_up ++; if (WheelDownPressed()) wheel_down ++; diff --git a/src/text.c b/src/text.c index 4a55cce1..588507cd 100644 --- a/src/text.c +++ b/src/text.c @@ -43,6 +43,21 @@ #include "global.h" #include "text.h" +#ifdef ARCADEINPUT +/* Characters (ASCII codes) for ARCADEINPUT; comment tells which characters are in question. + * Easy (?) to modify to include other characters (or remove), */ +// Should this be moved to a .h (text.h) ? +#define ARCADEINPUTMAX 69 +static const int arcadeinputchar[ARCADEINPUTMAX+1] = { // So we got 70 characters to choose from... +/* 0-9: */ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, // 0-9 +/* 11: */ 61, // = +/* 12-17: */ 42, 43, 44, 45, 46, 47, // *-+,./ +/* 18-14: */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, // A-Z (25 chars) +/* 43: */ 32, // space // 43 +/* 44-69: */ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122 // a-z +}; +#endif + /* Current text (virtual) "cursor" position */ int MyCursorX; int MyCursorY; @@ -431,7 +446,6 @@ linebreak_needed (char *textpos , const SDL_Rect *clip) } // bool linebreak_needed - /*----------------------------------------------------------------- * @Desc: reads a string of "MaxLen" from User-input, and echos it * either to stdout or using graphics-text, depending on the @@ -474,8 +488,18 @@ GetString (int MaxLen, int echo) /* Speicher fuer Eingabe reservieren */ input = MyMalloc (MaxLen + 5); - - memset (input, '.', MaxLen); +#ifdef ARCADEINPUT + char emptychar=' '; //for "empty" input line / backspace etc... + int blink_time=200; // For adjusting fast <->slow blink; in ms + static Uint32 last_frame_time; // = SDL_GetTicks(); + Uint32 frame_duration; + + int inputchar=17; // initial char = A +#else // NORMAL INPUT + char emptychar='.'; //for "empty" input linue / backspace etc... +#endif // ARCADEINPUT + + memset (input, emptychar, MaxLen); input[MaxLen] = 0; finished = FALSE; @@ -488,6 +512,63 @@ GetString (int MaxLen, int echo) PutString (ne_screen, x0, y0, input); SDL_Flip (ne_screen); +#ifdef ARCADEINPUT + if ( inputchar < 0 ) inputchar+=(ARCADEINPUTMAX+1); //+1 because we chose (>)1 past the point... + if ( inputchar > ARCADEINPUTMAX ) inputchar-=(ARCADEINPUTMAX+1); + key=arcadeinputchar[inputchar]; + + if ( ( frame_duration = SDL_GetTicks() - last_frame_time ) > blink_time/2 ) { + input[curpos] = (char) key; // We want to show the currently chosen character + if ( frame_duration > blink_time ) last_frame_time = SDL_GetTicks(); + } else input[curpos] = emptychar; // Hmm., how to get character widht? If using '.', or any fill character, we'd need to know + + if (KeyIsPressedR(SDLK_RETURN)) // For GCW0, maybe we need a prompt to say [PRESS ENTER WHEN FINISHED], or any other key we may choose... + { + input[curpos] = 0; // The last char is currently shown but, not entered into the string... +// input[curpos] = key; // Not sure which one would be expected by most users; the last blinking char is input or not? + finished = TRUE; + } + else if (UpPressedR()) // UP + /* Currently, the key will work ON RELEASE; we might change this to + * ON PRESS and add a counter / delay after which while holding, will + * scroll trough the chars */ + { + inputchar++; + } + else if (DownPressedR())// DOWN + { + inputchar--; + } + else if (FirePressedR())// FIRE + { + // ADVANCE CURSOR + input[curpos]=(char)key; // Needed in case character has just blinked out... + curpos ++; + // key=startkey; // Reselect A or not? + } + else if (LeftPressedR()) + { + inputchar-=5; + } + else if (RightPressedR()) + { + inputchar+=5; + } + else if (cmd_is_activeR(CMD_ACTIVATE)) // CAPITAL <-> small + { + if ( inputchar >= 17 && inputchar <= 42 ) { + inputchar=44+(inputchar-17); + } else if ( inputchar >= 44 && inputchar <= 69 ) { + inputchar=17+(inputchar-44); + } + } + // else if ... other functions to consider: SPACE + else if (KeyIsPressedR(SDLK_BACKSPACE)) // Or any othe key we choose for the GCW0! + { + input[curpos] = emptychar; + if ( curpos > 0 ) curpos --; + } // (el)ifs Pressed +#else // NORMAL INPUT key = getchar_raw (); if (key == SDLK_RETURN) @@ -506,9 +587,10 @@ GetString (int MaxLen, int echo) if ( curpos > 0 ) curpos --; input[curpos] = '.'; } - +#endif // ARCADEINPUT } /* while(!finished) */ + DebugPrintf (2, "\n\nchar *GetString(..): The final string is:\n"); DebugPrintf (2, input ); DebugPrintf (2, "\n\n"); @@ -518,6 +600,16 @@ GetString (int MaxLen, int echo) } /* GetString() */ +// +/* Proposed: void ShowInstructionsForInput () { + * Show some instructions for using the input method; i.e.: + * up/down to choose, left/right to skip 5 chars, + * FIRE to place char, + * START to finish, + * right shoulder for bspace + * etc. whatever is possible in the function GetString...} */ + + /*----------------------------------------------------------------- * * similar to putchar(), using SDL via the BFont-fct PutChar().