in cores/genesis/gcw0/main.c [835:1866]
static int gcw0menu(void)
{
SDL_PauseAudio(1);
/* display menu */
// change video mode
sdl_video.surf_screen = SDL_SetVideoMode(320,240, 32, SDL_HWSURFACE |
#ifdef SDL_TRIPLEBUF
SDL_TRIPLEBUF);
#else
SDL_DOUBLEBUF);
#endif
// blank screen
SDL_FillRect(sdl_video.surf_screen, 0, 0);
enum {MAINMENU = 0, GRAPHICS_OPTIONS = 1, REMAP_OPTIONS = 2, SAVE_STATE = 3, LOAD_STATE = 4, MISC_OPTIONS = 5};
static int menustate = MAINMENU;
// Menu text
const char *gcw0menu_mainlist[9]=
{
"Resume game",
"Save state",
"Load state",
"Graphics options",
"Remap buttons",
"Misc. Options",
"", //spacer
"Reset",
"Quit"
};
const char *gcw0menu_gfxlist[6]=
{
"Scaling",
"Keep aspect ratio",
"Scanlines (GG)",
"Mask left bar (SMS)",
"Frameskip",
"Return to main menu",
};
const char *gcw0menu_numericlist[4]=
{
"0",
"1",
"2",
"3",
};
const char *gcw0menu_onofflist[2]=
{
"Off",
"On",
};
const char *gcw0menu_remapoptionslist[9]=
{
"A",
"B",
"C",
"X",
"Y",
"Z",
"Start",
"Mode",
"Return to main menu",
};
const char *gcw0menu_savestate[10]=
{
"Back to main menu",
"Save state 1 (Quicksave)",
"Save state 2",
"Save state 3",
"Save state 4",
"Save state 5",
"Save state 6",
"Save state 7",
"Save state 8",
"Save state 9",
};
const char *gcw0menu_loadstate[10]=
{
"Back to main menu",
"Load state 1 (Quickload)",
"Load state 2",
"Load state 3",
"Load state 4",
"Load state 5",
"Load state 6",
"Load state 7",
"Load state 8",
"Load state 9",
};
const char *gcw0menu_misc[7]=
{
"Back to main menu",
"Resume on Save/Load",
"A-stick",
"Lock-on",
"FM sound (SMS)",
"Lightgun speed",
"Lightgun Cursor",
};
const char *lock_on_desc[4]=
{
" Off",
" Game Genie",
" Action Replay",
"Sonic & Knuckles",
};
// start menu loop
bitmap.viewport.changed=1; //change screen res if required
while(gotomenu)
{
// set up menu surface
SDL_Surface *menuSurface = NULL;
menuSurface = SDL_CreateRGBSurface(SDL_HWSURFACE, 320, 240, 16, 0, 0, 0, 0);
// identify system we are using to show correct background just cos we can :P
if ( system_hw == SYSTEM_PICO) //Sega Pico
{
SDL_Surface *tempbgSurface;
SDL_Surface *bgSurface;
tempbgSurface = IMG_Load( "./PICO.png" );
bgSurface = SDL_DisplayFormat( tempbgSurface );
SDL_BlitSurface(bgSurface, NULL, menuSurface, NULL);
SDL_FreeSurface(tempbgSurface);
SDL_FreeSurface(bgSurface);
}
else if ( (system_hw == SYSTEM_SG) || (system_hw == SYSTEM_SGII) ) //SG-1000 I&II
{
SDL_Surface *tempbgSurface;
SDL_Surface *bgSurface;
tempbgSurface = IMG_Load( "./SG1000.png" );
bgSurface = SDL_DisplayFormat( tempbgSurface );
SDL_BlitSurface(bgSurface, NULL, menuSurface, NULL);
SDL_FreeSurface(tempbgSurface);
SDL_FreeSurface(bgSurface);
}
else if ( (system_hw == SYSTEM_MARKIII) || (system_hw == SYSTEM_SMS) || ( system_hw == SYSTEM_GGMS) || (system_hw == SYSTEM_SMS2) || (system_hw == SYSTEM_PBC) ) //Mark III & Sega Master System I&II & Megadrive with power base converter
{
SDL_Surface *tempbgSurface;
SDL_Surface *bgSurface;
tempbgSurface = IMG_Load( "./SMS.png" );
bgSurface = SDL_DisplayFormat( tempbgSurface );
SDL_BlitSurface(bgSurface, NULL, menuSurface, NULL);
SDL_FreeSurface(tempbgSurface);
SDL_FreeSurface(bgSurface);
}
else if (system_hw == SYSTEM_GG)
{
SDL_Surface *tempbgSurface;
SDL_Surface *bgSurface;
tempbgSurface = IMG_Load( "./GG.png" );
bgSurface = SDL_DisplayFormat( tempbgSurface );
SDL_BlitSurface(bgSurface, NULL, menuSurface, NULL);
SDL_FreeSurface(tempbgSurface);
SDL_FreeSurface(bgSurface);
}
else if ( system_hw == SYSTEM_MD) //Megadrive
{
SDL_Surface *tempbgSurface;
SDL_Surface *bgSurface;
tempbgSurface = IMG_Load( "./MD.png" );
bgSurface = SDL_DisplayFormat( tempbgSurface );
SDL_BlitSurface(bgSurface, NULL, menuSurface, NULL);
SDL_FreeSurface(tempbgSurface);
SDL_FreeSurface(bgSurface);
}
else if ( system_hw == SYSTEM_MCD) //MegaCD
{
SDL_Surface *tempbgSurface;
SDL_Surface *bgSurface;
tempbgSurface = IMG_Load( "./MCD.png" );
bgSurface = SDL_DisplayFormat( tempbgSurface );
SDL_BlitSurface(bgSurface, NULL, menuSurface, NULL);
SDL_FreeSurface(tempbgSurface);
SDL_FreeSurface(bgSurface);
}
// show menu
TTF_Init();
TTF_Font *ttffont = NULL;
SDL_Color text_color = {180, 180, 180};
SDL_Color selected_text_color = {23, 86, 155}; //selected colour = Sega blue ;)
SDL_Surface *textSurface;
int i;
static int selectedoption = 0;
// Fill menu box
SDL_Surface *MenuBackground;
if (menustate == REMAP_OPTIONS)
{
MenuBackground = SDL_CreateRGBSurface(SDL_HWSURFACE, 320, 185, 16, 0, 0, 0, 0);
SDL_Rect rect;
rect.x = 0;
rect.y = 35;
rect.w = 320;
rect.h = 185;
SDL_FillRect(MenuBackground, 0, 0);
SDL_SetAlpha(MenuBackground, SDL_SRCALPHA, 50);
SDL_BlitSurface(MenuBackground, NULL, menuSurface, &rect);
SDL_FreeSurface(MenuBackground);
}
else
{
MenuBackground = SDL_CreateRGBSurface(SDL_HWSURFACE, 180, 185, 16, 0, 0, 0, 0);
SDL_Rect rect;
rect.x = 60;
rect.y = 35;
rect.w = 180;
rect.h = 185;
SDL_FillRect(MenuBackground, 0, 0);
SDL_SetAlpha(MenuBackground, SDL_SRCALPHA, 50);
SDL_BlitSurface(MenuBackground, NULL, menuSurface, &rect);
SDL_FreeSurface(MenuBackground);
}
// Show title
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
SDL_Rect destination;
destination.x = 80;
destination.y = 40;
destination.w = 100;
destination.h = 50;
textSurface = TTF_RenderText_Solid(ttffont, "Genesis Plus GX", text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
TTF_CloseFont (ttffont);
if (menustate == MAINMENU)
{
//there's no need to open/close font each cycle :P
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
for(i=0; i<9; i++)
{
SDL_Rect destination;
destination.x = 80;
destination.y = 70+(15*i);
destination.w = 100;
destination.h = 50;
if (i == selectedoption)
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_mainlist[i], selected_text_color);
else
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_mainlist[i], text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
}
TTF_CloseFont (ttffont);
}
else if (menustate == GRAPHICS_OPTIONS)
{
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
for(i=0; i<6; i++)
{
SDL_Rect destination;
destination.x = 80;
destination.y = 70+(15*i);
destination.w = 100;
destination.h = 50;
if ((i+10) == selectedoption)
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_gfxlist[i], selected_text_color);
else
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_gfxlist[i], text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
}
/* Display On/Off */
SDL_Rect destination;
destination.x = 220;
destination.w = 100;
destination.h = 50;
// Scaling
destination.y = 70+(15*0);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_onofflist[config.gcw0_fullscreen], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
// Aspect ratio
destination.y = 70+(15*1);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_onofflist[config.keepaspectratio], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
// Scanlines
destination.y = 70+(15*2);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_onofflist[config.gg_scanlines], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
// Mask left bar
destination.y = 70+(15*3);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_onofflist[config.smsmaskleftbar], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
// Frameskip
destination.y = 70+(15*4);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_numericlist[config.gcw0_frameskip], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
TTF_CloseFont (ttffont);
}
else if (menustate == REMAP_OPTIONS)
{
char* remap_text[256];
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
sprintf(remap_text, "%s%25s", "GenPlus", "GCW-Zero");
SDL_Rect destination = {30, 60, 100, 50};
textSurface = TTF_RenderText_Solid(ttffont, remap_text, text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
for(i=0; i < 9; i++)
{
if (i < 8)
{
sprintf(remap_text, "%-5s %-7s", gcw0menu_remapoptionslist[i], gcw0_get_key_name(config.buttons[i]));
} else
{
sprintf(remap_text, gcw0menu_remapoptionslist[i]); // for return option
}
SDL_Rect destination = {30, 80 + (15 * i), 100, 50};
if ((i+20) == selectedoption)
{
textSurface = TTF_RenderText_Solid(ttffont, remap_text, selected_text_color);
} else
{
textSurface = TTF_RenderText_Solid(ttffont, remap_text, text_color);
}
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
}
TTF_CloseFont (ttffont);
}
else if (menustate == SAVE_STATE)
{
//Show saved BMP as background if available
SDL_Surface* screenshot;
char load_state_screenshot[256];
sprintf(load_state_screenshot,"%s/%s.%d.bmp", get_save_directory(), rom_filename, selectedoption-30);
screenshot = SDL_LoadBMP(load_state_screenshot);
if (screenshot)
{
SDL_Rect destination;
destination.x = (320 - screenshot->w) / 2;
destination.y = (240 - screenshot->h) / 2;
destination.w = 320;
destination.h = 240;
SDL_BlitSurface(screenshot, NULL, menuSurface, &destination);
// Fill menu box
SDL_Surface *MenuBackground = SDL_CreateRGBSurface(SDL_HWSURFACE, 180, 185, 16, 0, 0, 0, 0);
SDL_Rect rect;
rect.x = 60;
rect.y = 35;
rect.w = 180;
rect.h = 185;
SDL_FillRect(MenuBackground, 0, 0);
SDL_SetAlpha(MenuBackground, SDL_SRCALPHA, 180);
SDL_BlitSurface(MenuBackground, NULL, menuSurface, &rect);
SDL_FreeSurface(MenuBackground);
}
SDL_FreeSurface(screenshot);
// Show title
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
SDL_Rect destination;
destination.x = 80;
destination.y = 40;
destination.w = 100;
destination.h = 50;
textSurface = TTF_RenderText_Solid(ttffont, "Genesis Plus GX", text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
TTF_CloseFont (ttffont);
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
for(i=0; i<10; i++)
{
SDL_Rect destination;
destination.x = 80;
destination.y = 70+(15*i);
destination.w = 100;
destination.h = 50;
if ((i+30) == selectedoption)
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_savestate[i], selected_text_color);
else
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_savestate[i], text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
}
TTF_CloseFont (ttffont);
}
else if (menustate == LOAD_STATE)
{
//Show saved BMP as background if available
SDL_Surface* screenshot;
char load_state_screenshot[256];
sprintf(load_state_screenshot,"%s/%s.%d.bmp", get_save_directory(), rom_filename, selectedoption-40);
screenshot = SDL_LoadBMP(load_state_screenshot);
if (screenshot)
{
SDL_Rect destination;
destination.x = (320 - screenshot->w) / 2;
destination.y = (240 - screenshot->h) / 2;
destination.w = 320;
destination.h = 240;
SDL_BlitSurface(screenshot, NULL, menuSurface, &destination);
// Fill menu box
SDL_Surface *MenuBackground = SDL_CreateRGBSurface(SDL_HWSURFACE, 180, 185, 16, 0, 0, 0, 0);
SDL_Rect rect;
rect.x = 60;
rect.y = 35;
rect.w = 180;
rect.h = 185;
SDL_FillRect(MenuBackground, 0, 0);
SDL_SetAlpha(MenuBackground, SDL_SRCALPHA, 180);
SDL_BlitSurface(MenuBackground, NULL, menuSurface, &rect);
SDL_FreeSurface(MenuBackground);
}
SDL_FreeSurface(screenshot);
// Show title
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
SDL_Rect destination;
destination.x = 80;
destination.y = 40;
destination.w = 100;
destination.h = 50;
textSurface = TTF_RenderText_Solid(ttffont, "Genesis Plus GX", text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
TTF_CloseFont (ttffont);
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
for(i=0; i<10; i++)
{
SDL_Rect destination;
destination.x = 80;
destination.y = 70+(15*i);
destination.w = 100;
destination.h = 50;
if ((i+40) == selectedoption)
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_loadstate[i], selected_text_color);
else
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_loadstate[i], text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
}
TTF_CloseFont (ttffont);
}
else if (menustate == MISC_OPTIONS)
{
ttffont = TTF_OpenFont("./ProggyTiny.ttf", 16);
for(i=0; i<7; i++)
{
SDL_Rect destination;
destination.x = 80;
destination.y = 70+(15*i);
destination.w = 100;
destination.h = 50;
if ((i+50) == selectedoption)
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_misc[i], selected_text_color);
else
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_misc[i], text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
}
/* Display On/Off */
SDL_Rect destination;
destination.x = 220;
destination.w = 100;
destination.h = 50;
// Save/load autoresume
destination.y = 70+(15*1);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_onofflist[config.sl_autoresume], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
// A-stick
destination.y = 70+(15*2);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_onofflist[config.a_stick], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
/* Display Lock-on Types */
destination.x = 142;
destination.y = 70+(15*3);
textSurface = TTF_RenderText_Solid(ttffont, lock_on_desc[config.lock_on], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
// FM sound(SMS)
destination.x = 220;
destination.y = 70+(15*4);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_onofflist[config.ym2413], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
// Lightgun speed
destination.x = 220;
destination.y = 70+(15*5);
textSurface = TTF_RenderText_Solid(ttffont, gcw0menu_numericlist[config.lightgun_speed], selected_text_color);
SDL_BlitSurface(textSurface, NULL, menuSurface, &destination);
SDL_FreeSurface(textSurface);
// Lightgun Cursor
destination.y = 70+(15*6);
SDL_Surface *lightgunSurface;
lightgunSurface = IMG_Load(cursor[config.cursor]);
static lightgun_af_demo = 0;
SDL_Rect srect;
srect.x = 0;
srect.y = 0;
srect.w = 15;
srect.h = 15;
if (lightgun_af_demo >= 10 && config.cursor != 0)
{
srect.x = 15;
}
lightgun_af_demo++;
if (lightgun_af_demo == 20) lightgun_af_demo = 0;
SDL_BlitSurface(lightgunSurface, &srect, menuSurface, &destination);
SDL_FreeSurface(lightgunSurface);
TTF_CloseFont (ttffont);
}
//TODO other menu's go here
/* Update display */
SDL_Rect dest;
dest.w = 320;
dest.h = 240;
dest.x = 0;
dest.y = 0;
SDL_BlitSurface(menuSurface, NULL, sdl_video.surf_screen, &dest);
SDL_FreeSurface(menuSurface);
SDL_Flip(sdl_video.surf_screen);
/* Check for user input */
SDL_EnableKeyRepeat(0,0);
static int keyheld=0;
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_KEYDOWN:
sdl_control_update(event.key.keysym.sym);
break;
case SDL_KEYUP:
keyheld = 0;
break;
default:
break;
}
}
if (event.type == SDL_KEYDOWN && !keyheld)
{
keyheld++;
uint8 *keystate2;
keystate2 = SDL_GetKeyState(NULL);
if(keystate2[SDLK_DOWN])
{
if (selectedoption > 9 && selectedoption < 20) //graphics menu
{
selectedoption++;
if (selectedoption == 16) selectedoption = 10;
}
else if (selectedoption > 19 && selectedoption < 30) //remap menu
{
selectedoption++;
if (selectedoption == 29) selectedoption = 20;
}
else if (selectedoption > 29 && selectedoption < 40) //save menu
{
selectedoption++;
if (selectedoption == 40) selectedoption = 30;
}
else if (selectedoption > 39 && selectedoption < 50) //load menu
{
selectedoption++;
if (selectedoption == 50) selectedoption = 40;
}
else if (selectedoption > 49 && selectedoption < 60) //misc menu
{
selectedoption++;
if (selectedoption == 57) selectedoption = 50;
}
else //main menu
{
selectedoption++;
if (selectedoption == 6) selectedoption = 7;
if (selectedoption > 8) selectedoption=0;
}
SDL_Delay(100);
}
else if(keystate2[SDLK_UP])
{
if (selectedoption > 9 && selectedoption < 20) //graphics menu
{
selectedoption--;
if (selectedoption == 9) selectedoption = 15;
}
else if (selectedoption > 19 && selectedoption < 30) //remap menu
{
selectedoption--;
if (selectedoption == 19) selectedoption = 28;
}
else if (selectedoption > 29 && selectedoption < 40) //save menu
{
selectedoption--;
if (selectedoption == 29) selectedoption = 39;
}
else if (selectedoption > 39 && selectedoption < 50) //load menu
{
selectedoption--;
if (selectedoption == 39) selectedoption = 49;
}
else if (selectedoption > 49 && selectedoption < 60) //misc menu
{
selectedoption--;
if (selectedoption == 49) selectedoption = 56;
}
else
{ //main menu
if (!selectedoption) selectedoption = 8;
else selectedoption--;
if (selectedoption == 6) selectedoption = 5;
}
SDL_Delay(100);
}
else if(keystate2[SDLK_LALT] && menustate != REMAP_OPTIONS) //back to last menu or quit menu
{
if (menustate == GRAPHICS_OPTIONS)
{
menustate = MAINMENU;
selectedoption = 3;
SDL_Delay(130);
}
else if (menustate == SAVE_STATE)
{
menustate = MAINMENU;
selectedoption = 1;
SDL_Delay(130);
}
else if (menustate == LOAD_STATE)
{
menustate = MAINMENU;
selectedoption = 2;
SDL_Delay(130);
}
else if (menustate == MISC_OPTIONS)
{
menustate = MAINMENU;
selectedoption = 5;
SDL_Delay(130);
}
else if (menustate == MAINMENU)
{
gotomenu=0;
selectedoption=0;
SDL_Delay(130);
break;
}
}
else if(keystate2[SDLK_LCTRL] && menustate != REMAP_OPTIONS)
{
if (selectedoption == 0)
{ //Resume
gotomenu=0;
selectedoption=0;
SDL_Delay(130);
break;
}
else if (selectedoption == 1) //Save
{
menustate = SAVE_STATE;
selectedoption = 30;
SDL_Delay(130);
}
else if (selectedoption == 2) //Load
{
menustate = LOAD_STATE;
selectedoption = 40;
SDL_Delay(130);
}
else if (selectedoption == 3) //Graphics
{
menustate = GRAPHICS_OPTIONS;
selectedoption = 10;
SDL_Delay(200);
}
else if (selectedoption == 4) //Remap
{
menustate = REMAP_OPTIONS;
selectedoption=20;
SDL_Delay(200);
}
else if (selectedoption == 5) //Misc.
{
menustate = MISC_OPTIONS;
selectedoption=50;
SDL_Delay(200);
}
else if (selectedoption == 7) //Reset
{
gotomenu = 0;
selectedoption=0;
system_reset();
SDL_Delay(130);
break;
}
else if (selectedoption == 8) //Quit
{
exit(0);
SDL_Delay(130);
break;
}
else if (selectedoption == 10)
{ //Scaling
config.gcw0_fullscreen = !config.gcw0_fullscreen;
SDL_Delay(130);
config_save();
}
else if (selectedoption == 11)
{ //Keep aspect ratio
SDL_Delay(130);
config.keepaspectratio = !config.keepaspectratio;
config_save();
do_once = 1;
}
else if (selectedoption == 12)
{ //Scanlines (GG)
SDL_Delay(130);
config.gg_scanlines = !config.gg_scanlines;
config_save();
}
else if (selectedoption == 13)
{ //Mask left bar
SDL_Delay(130);
config.smsmaskleftbar = !config.smsmaskleftbar;
config_save();
}
else if (selectedoption == 14)
{ //Frameskip
SDL_Delay(130);
config.gcw0_frameskip ++;
if (config.gcw0_frameskip == 4) config.gcw0_frameskip = 0;
config_save();
}
else if (selectedoption == 15)
{ //Back to main menu
menustate = MAINMENU;
selectedoption = 3;
SDL_Delay(130);
}
else if (selectedoption == 30)
{
//Return to main menu
menustate = MAINMENU;
selectedoption = 1;
SDL_Delay(130);
}
else if (selectedoption > 30 && selectedoption < 40)
{
//save to selected savestate
char save_state_file[256];
sprintf(save_state_file,"%s/%s.gp%d", get_save_directory(), rom_filename, selectedoption-30);
FILE *f = fopen(save_state_file,"wb");
if (f)
{
uint8 buf[STATE_SIZE];
int len = state_save(buf);
fwrite(&buf, len, 1, f);
fclose(f);
}
//Save BMP screenshot
char save_state_screenshot[256];
sprintf(save_state_screenshot,"%s/%s.%d.bmp", get_save_directory(), rom_filename, selectedoption-30);
SDL_Surface* screenshot;
if (!config.gcw0_fullscreen)
{
screenshot = SDL_CreateRGBSurface(SDL_HWSURFACE, sdl_video.srect.w, sdl_video.srect.h, 16, 0, 0, 0, 0);
SDL_Rect temp;
temp.x = 0;
temp.y = 0;
temp.w = sdl_video.srect.w;
temp.h = sdl_video.srect.h;
SDL_BlitSurface(sdl_video.surf_bitmap, &temp, screenshot, &temp);
SDL_SaveBMP(screenshot, save_state_screenshot);
SDL_FreeSurface(screenshot);
}
else
{
screenshot = SDL_CreateRGBSurface(SDL_HWSURFACE, gcw0_w, gcw0_h, 16, 0, 0, 0, 0);
SDL_Rect temp;
temp.x = 0;
temp.y = 0;
temp.w = gcw0_w;
temp.h = gcw0_h;
SDL_BlitSurface(sdl_video.surf_bitmap, &temp, screenshot, &temp);
SDL_SaveBMP(screenshot, save_state_screenshot);
SDL_FreeSurface(screenshot);
}
SDL_Delay(250);
if (config.sl_autoresume)
{
menustate = MAINMENU;
selectedoption = 0;
gotomenu = 0;
break;
}
}
else if (selectedoption == 40)
{
//return to main menu
menustate = MAINMENU;
selectedoption = 2;
SDL_Delay(130);
}
else if (selectedoption > 40 && selectedoption < 50)
{
//load selected loadstate
char save_state_file[256];
sprintf(save_state_file,"%s/%s.gp%d", get_save_directory(), rom_filename, selectedoption-40 );
FILE *f = fopen(save_state_file,"rb");
if (f)
{
uint8 buf[STATE_SIZE];
fread(&buf, STATE_SIZE, 1, f);
state_load(buf);
fclose(f);
}
if (config.sl_autoresume)
{
gotomenu = 0;
menustate = MAINMENU;
selectedoption = 0;
SDL_Delay(250);
break;
}
}
else if (selectedoption == 50)
{
//return to main menu
menustate = MAINMENU;
selectedoption = 5;
SDL_Delay(130);
}
else if (selectedoption == 51)
{
//toggle auto resume when save/loading
config.sl_autoresume=!config.sl_autoresume;
config_save();
SDL_Delay(130);
}
else if (selectedoption == 52)
{
//toggle A-Stick
config.a_stick=!config.a_stick;
config_save();
SDL_Delay(130);
}
else if (selectedoption == 53)
{
config.lock_on = (++config.lock_on == 4)? 0 : config.lock_on;
config_save();
SDL_Delay(130);
}
else if (selectedoption == 54)
{
config.ym2413 = !config.ym2413;
config_save();
SDL_Delay(130);
}
else if (selectedoption == 55)
{
config.lightgun_speed++;
if (config.lightgun_speed == 4)
config.lightgun_speed = 1;
config_save();
SDL_Delay(130);
}
else if (selectedoption == 56)
{
config.cursor++;
if (config.cursor == 4)
config.cursor = 0;
config_save();
SDL_Delay(130);
}
}
else if(menustate == REMAP_OPTIONS)
{// REMAP_OPTIONS needs to capture all input
SDLKey pressed_key = 0;
if (keystate2[SDLK_RETURN])
pressed_key = SDLK_RETURN;
else if (keystate2[SDLK_LCTRL])
pressed_key = SDLK_LCTRL;
else if (keystate2[SDLK_LALT])
pressed_key = SDLK_LALT;
else if (keystate2[SDLK_LSHIFT])
pressed_key = SDLK_LSHIFT;
else if (keystate2[SDLK_SPACE])
pressed_key = SDLK_SPACE;
else if (keystate2[SDLK_TAB])
pressed_key = SDLK_TAB;
else if (keystate2[SDLK_BACKSPACE])
pressed_key = SDLK_BACKSPACE;
else if (keystate2[SDLK_ESCAPE])
pressed_key = SDLK_ESCAPE;
if (pressed_key)
{
if (selectedoption == 20)
{
//button a remap
config.buttons[A] = (pressed_key==SDLK_ESCAPE)? 0: pressed_key;
config_save();
SDL_Delay(130);
selectedoption++;
}
else if (selectedoption == 21)
{
//button b remap
config.buttons[B] = (pressed_key==SDLK_ESCAPE)? 0: pressed_key;
config_save();
SDL_Delay(130);
selectedoption++;
}
else if (selectedoption == 22)
{
//button c remap
config.buttons[C] = (pressed_key==SDLK_ESCAPE)? 0: pressed_key;
config_save();
SDL_Delay(130);
selectedoption++;
}
else if (selectedoption == 23)
{
//button x remap
config.buttons[X] = (pressed_key==SDLK_ESCAPE)? 0: pressed_key;
config_save();
SDL_Delay(130);
selectedoption++;
}
else if (selectedoption == 24)
{
//button y remap
config.buttons[Y] = (pressed_key==SDLK_ESCAPE)? 0: pressed_key;
config_save();
SDL_Delay(130);
selectedoption++;
}
else if (selectedoption == 25)
{
//button z remap
config.buttons[Z] = (pressed_key==SDLK_ESCAPE)? 0: pressed_key;
config_save();
SDL_Delay(130);
selectedoption++;
}
else if (selectedoption == 26)
{
//button start remap
config.buttons[START] = (pressed_key==SDLK_ESCAPE)? 0: pressed_key;
config_save();
SDL_Delay(130);
selectedoption++;
}
else if (selectedoption == 27)
{
//button mode remap
config.buttons[MODE] = pressed_key;
config_save();
SDL_Delay(130);
selectedoption++;
}
else if (selectedoption == 28)
{
//return to main menu
menustate = MAINMENU;
selectedoption = 4;
SDL_Delay(130);
}
}
}
}
}//menu loop
SDL_PauseAudio(0);
if(config.gcw0_fullscreen) {
if ( (system_hw == SYSTEM_MARKIII) || (system_hw == SYSTEM_SMS) || (system_hw == SYSTEM_SMS2) || (system_hw == SYSTEM_PBC) )
{
gcw0_w=sdl_video.drect.w;
gcw0_h=sdl_video.drect.h;
sdl_video.surf_screen = SDL_SetVideoMode(256,gcw0_h, 16, SDL_HWSURFACE |
#ifdef SDL_TRIPLEBUF
SDL_TRIPLEBUF);
#else
SDL_DOUBLEBUF);
#endif
}
else
{
sdl_video.drect.w = sdl_video.srect.w;
sdl_video.drect.h = sdl_video.srect.h;
sdl_video.drect.x = 0;
sdl_video.drect.y = 0;
gcw0_w=sdl_video.drect.w;
gcw0_h=sdl_video.drect.h;
sdl_video.surf_screen = SDL_SetVideoMode(gcw0_w,gcw0_h, 16, SDL_HWSURFACE |
#ifdef SDL_TRIPLEBUF
SDL_TRIPLEBUF);
#else
SDL_DOUBLEBUF);
#endif
}
} else {
SDL_FillRect(sdl_video.surf_screen, 0, 0);
SDL_Flip(sdl_video.surf_screen);
SDL_FillRect(sdl_video.surf_screen, 0, 0);
SDL_Flip(sdl_video.surf_screen);
SDL_FillRect(sdl_video.surf_screen, 0, 0);
SDL_Flip(sdl_video.surf_screen);
}
return 1;
}