Example #1
0
void Ingame_Menu(void)
{
    char *temp;
    int i,selection = 0;
    oldselect = -1;
    char stateoption[16];
    strcpy(stateoption,"State number: ");

    int option_changed = 0;

    int menu_x1 = gsGlobal->Width*0.25;
    int menu_y1 = gsGlobal->Height*0.15;
    int menu_x2 = gsGlobal->Width*0.75;
    int menu_y2 = gsGlobal->Height*0.85+FONT_HEIGHT;

    int text_line = menu_y1 + 4;

    char options[14][23] = {
        { "State number: " },
        { "Save State" },
        { "Load State" },
        { "Filtering: "},
        { "LowPass: "******"Configure Input" },
        { "Rapidfire Switch: "},
        { "RapidFire P1: " },
        { "RapidFire P2: " },
        { "Reset Game" },
        { "Exit Game" },
        { "Exit Menu" },
        { "Palette:" },
        { "" }
    };

    for(i=0;i<14;i++) {
        switch(i) {
            case 0:
                sprintf(options[i],"%s%d",options[i],statenum);
                break;
            case 3:
                if(!Settings.filter)
                    sprintf(options[i],"%s%s",options[i],"Off");
                else
                    sprintf(options[i],"%s%s",options[i],"On");
                break;
            case 4:
                if(!Settings.lowpass)
                    sprintf(options[i],"%s%s",options[i],"Off");
                else
                    sprintf(options[i],"%s%s",options[i],"On");
                break;
            case 6:
                if(!Settings.turbo) {
                    sprintf(options[i],"%s%s",options[i],"Off");
                }
                else {
                    sprintf(options[i],"%s%s",options[i],"On");
                }
                break;
            case 7:
                switch(aorborab[0]) {
                    case 0:
                        sprintf(options[i],"%s%s",options[i],"Off");
                        break;
                    case 1:
                        sprintf(options[i],"%s%s",options[i],"A");
                        break;
                    case 2:
                        sprintf(options[i],"%s%s",options[i],"B");
                        break;
                    case 3:
                        sprintf(options[i],"%s%s",options[i],"AB");
                        break;
                }
                break;
            case 8:
                switch(aorborab[1]) {
                    case 0:
                        sprintf(options[i],"%s%s",options[i],"Off");
                        break;
                    case 1:
                        sprintf(options[i],"%s%s",options[i],"A");
                        break;
                    case 2:
                        sprintf(options[i],"%s%s",options[i],"B");
                        break;
                    case 3:
                        sprintf(options[i],"%s%s",options[i],"AB");
                        break;
                }
				break;
            case 13:
				sprintf(options[i],"%s%s",options[i],palette_names[Settings.current_palette - 1].name);
                break;
        }
    }

#ifdef SOUND_ON
    audsrv_stop_audio();
#endif
    gsKit_mode_switch(gsGlobal, GS_ONESHOT);
    gsGlobal->DrawOrder = GS_PER_OS;

    while(1) {
        selected = 0; //clear selected flag
        selection += menu_input(0,0);

		if(selection == 12 && oldselect == 11) { selection++; } //12 is palette
        if(selection == 12 && oldselect == 13) { selection--; }
        if(selection > 13) { selection = 0; }
        if(selection < 0) { selection = 13; }

        if(oldselect != selection || option_changed) {
            i = 0x10000;
            while(i--) asm("nop\nnop\nnop\nnop");
            gsKit_queue_reset(gsGlobal->Os_Queue);

            option_changed = 0;

            menu_primitive("Options", &MENU_TEX, menu_x1, menu_y1, menu_x2, menu_y2);

            for(i=0;i<14;i++) {
                if(selection == i) {
                    //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, DarkYellowFont, options[i]);
                    printXY(options[i],menu_x1+10,text_line + i*FONT_HEIGHT, 4, FCEUSkin.highlight, 1, 0);
                }
                else {
                    //font_print(gsGlobal, menu_x1+10.0f, text_line + i*FONT_HEIGHT, 2, WhiteFont, options[i]);
                    printXY(options[i],menu_x1+10,text_line + i*FONT_HEIGHT, 4, FCEUSkin.textcolor, 1, 0);
                }
            }

            DrawScreen(gsGlobal);
        }

        oldselect = selection;

        if(selected) {
            if(selected == 2) { //menu combo pressed again
                selection = 11;
            }
            i = selection;
            switch(i) {
                case 0: //State Number
                    statenum++;
                    if(statenum > 9) {statenum = 0;}
                    sprintf(options[i],"%s%d",stateoption,statenum);
                    FCEUI_SelectState(statenum);
                    option_changed = 1;
                    break;
                case 1:
                    FCEUI_SaveState(NULL);
                    SetupNESGS();
                    return;
                case 2:
                    FCEUI_LoadState(NULL);
                    SetupNESGS();
                    return;
                case 3:
                    Settings.filter ^= 1;
                    if(Settings.filter) {
                        temp = strstr(options[i],"Off");
                        *temp = 0;
                        strcat(options[i],"On");
                    }
                    else {
                        temp = strstr(options[i],"On");
                        *temp = 0;
                        strcat(options[i],"Off");
                    }
                    option_changed = 1;
                    break;
                case 4:
                    Settings.lowpass ^= 1;
                    if(Settings.lowpass) {
                        FCEUI_SetLowPass(Settings.lowpass);
                        temp = strstr(options[i],"Off");
                        *temp = 0;
                        strcat(options[i],"On");
                    }
                    else {
                        FCEUI_SetLowPass(Settings.lowpass);
                        temp = strstr(options[i],"On");
                        *temp = 0;
                        strcat(options[i],"Off");
                    }
                    option_changed = 1;
                    break;
                case 6:
                    Settings.turbo ^= 1;
                    if(Settings.turbo) {
                        temp = strstr(options[i],"Off");
                        *temp = 0;
                        strcat(options[i],"On");
                    }
                    else {
                        temp = strstr(options[i],"On");
                        *temp = 0;
                        strcat(options[i],"Off");
                    }
                    option_changed = 1;
                    break;
                case 7:
                    aorborab[0]++;
                    if(aorborab[0] > 3)
                        aorborab[0] = 0;
                    switch(aorborab[0]) {
                        case 0: //Off
                            rapidfire_a[0] = 0;
                            rapidfire_b[0] = 0;
                            temp = strstr(options[i],"AB");
                            *temp = 0;
                            strcat(options[i],"Off");
                            break;
                        case 1: //A
                            rapidfire_a[0] = 1;
                            rapidfire_b[0] = 0;
                            temp = strstr(options[i],"Off");
                            *temp = 0;
                            strcat(options[i],"A");
                            break;
                        case 2: //B
                            rapidfire_a[0] = 0;
                            rapidfire_b[0] = 1;
                            temp = strstr(options[i]," A");
                            *temp = 0;
                            strcat(options[i]," B");
                            break;
                        case 3: //AB
                            rapidfire_a[0] = 1;
                            rapidfire_b[0] = 1;
                            temp = strstr(options[i]," B");
                            *temp = 0;
                            strcat(options[i]," AB");
                            break;
                    }
                    option_changed = 1;
                    break;
                case 8:
                    aorborab[1]++;
                    if(aorborab[1] > 3)
                        aorborab[1] = 0;
                    switch(aorborab[1]) {
                        case 0: //Off
                            rapidfire_a[1] = 0;
                            rapidfire_b[1] = 0;
                            temp = strstr(options[i],"AB");
                            *temp = 0;
                            strcat(options[i],"Off");
                            break;
                        case 1: //A
                            rapidfire_a[1] = 1;
                            rapidfire_b[1] = 0;
                            temp = strstr(options[i],"Off");
                            *temp = 0;
                            strcat(options[i],"A");
                            break;
                        case 2: //B
                            rapidfire_a[1] = 0;
                            rapidfire_b[1] = 1;
                            temp = strstr(options[i]," A");
                            *temp = 0;
                            strcat(options[i]," B");
                            break;
                        case 3: //AB
                            rapidfire_a[1] = 1;
                            rapidfire_b[1] = 1;
                            temp = strstr(options[i]," B");
                            *temp = 0;
                            strcat(options[i]," AB");
                            break;
                    }
                    option_changed = 1;
                    break;
                case 9:
                    FCEUI_ResetNES();
                    SetupNESGS();
                    return;
                case 10:
                    fdsswap = 0;
                    statenum = 0;
                    exitgame = 1;
                    selected = 0;
                    return;
                case 11:
                    SetupNESGS();
                    return;
                case 13:
                    Settings.current_palette++;
                    if(Settings.current_palette > MAXPAL) {Settings.current_palette = 1;}
					sprintf(options[i],"%s",palette_names[Settings.current_palette - 1].name);
					SetupNESTexture();
					option_changed = 1;
                    break;
            }
        }
    }
}
/////////////////////////////////////////////////////////////
//                         MAIN                            //
/////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
	PS2_Init();

   audsrv_init();

	format.bits = 16;
	format.freq = 44100;
	format.channels = 2;
   audsrv_set_format(&format);

	guiFadeOut(4);
   DisplayIntroBox(APP_NAME);
	guiFadeIn(4);
	guiFadeOut(4);

	for ( int i = 0; i < 160*144; i++ )
      g_BitmapData[i] = 0;

   PS2_LoadButtonsConfig(ButtonsConfigPath);
   Load_CNF(ConfigPath);

   if ( SoundEnabled )
      audsrv_set_volume(MAX_VOLUME);
   else
      audsrv_set_volume(MIN_VOLUME);

   // Main Loop
   while ( true ) {
      g_SamplePos = 0;

      dwKeyPad1 = 0;
      dwKeyPad2 = 0;

      if ( !auto_ROM_flag ) {
         MenuBrowser();
      } else {
         // KarasQ: Here preselected ROM path is already
         // copied to g_FilePath (look function Load_CNF)
         auto_ROM_flag = 0;
      }

      int res = infogb_load_rom(g_FilePath);

      // KarasQ: display error and return to
      // browser if ROM is not loaded successfully
      if ( res < 1 ) {
         infogb_close();
      }

      switch ( res ) {
         case 0:
            DisplayMessageBox
            (
               "\nERROR!\n\n"
               "Could not load ROM\n"
               "Failed opening file\n"
               "File not found!",
               MSG_VOID
            );
            continue;
         case -1:
            DisplayMessageBox
            (
               "\nWARNING!\n\n"
               "Could not load ROM\n"
               "Unknown ROM type!",
               MSG_VOID
            );
            continue;
         case -2:
            DisplayMessageBox
            (
               "\nWARNING!\n\n"
               "Could not load ROM\n"
               "Unknown ROM size!",
               MSG_VOID
            );
            continue;
         case -3:
            DisplayMessageBox
            (
               "\nWARNING!\n\n"
               "Could not load ROM\n"
               "Unknown RAM size!",
               MSG_VOID
            );
            continue;
         case -4:
            DisplayMessageBox
            (
               "\nWARNING!\n\n"
               "File name of this ROM is longer\n"
               "than 32 characters! It's better\n"
               "to change it before playing!",
               MSG_VOID
            );
            continue;
         case -5:
            DisplayMessageBox
            (
               "\nERROR!\n\n"
               "Could not extract file archive\n",
               MSG_VOID
            );
            continue;
      }
      CDVD_Stop();

      infogb_init();

      gameboy_cpu_hardreset();
      gameboy_cpu_run();

      audsrv_stop_audio();

      infogb_close();
   }

	return 0;
}
Example #3
0
/** RPC command handler.
    @param func     command (one of AUDSRV_x)
    @param data     pointer to data array
    @param size     size of data array (in bytes)
    @returns value depends on function invoked

    This is a single rpc handler, it unpacks the data array and calls
    local functions.
*/
static void *rpc_command(int func, unsigned *data, int size)
{
	int ret;

	/* printf("audsrv: rpc command %d\n", func); */
	switch(func)
	{
		case AUDSRV_INIT:
		ret = audsrv_init();
		break;

		case AUDSRV_FORMAT_OK:
		ret = audsrv_format_ok(data[0], data[1], data[2]);
		break;

		case AUDSRV_SET_FORMAT:
		ret = audsrv_set_format(data[0], data[1], data[2]);
		break;

		case AUDSRV_WAIT_AUDIO:
		ret = audsrv_wait_audio(data[0]);
		break;

		case AUDSRV_PLAY_AUDIO:
		ret = audsrv_play_audio((const char *)&data[1], data[0]);
		break;

		case AUDSRV_STOP_AUDIO:
		ret = audsrv_stop_audio();
		break;

		case AUDSRV_SET_VOLUME:
		ret = audsrv_set_volume(data[0]);
		break;

		case AUDSRV_QUIT:
		ret = audsrv_quit();
		break;

		case AUDSRV_PLAY_CD:
		ret = audsrv_play_cd(data[0]);
		break;

		case AUDSRV_STOP_CD:
		ret = audsrv_stop_cd();
		break;

		case AUDSRV_GET_CDPOS:
		ret = audsrv_get_cdpos();
		break;

		case AUDSRV_GET_TRACKPOS:
		ret = audsrv_get_trackpos();
		break;

		case AUDSRV_SET_THRESHOLD:
		ret = audsrv_set_threshold(data[0]);
		break;

		case AUDSRV_GET_NUMTRACKS:
		ret = audsrv_get_numtracks();
		break;

		case AUDSRV_GET_TRACKOFFSET:
		ret = audsrv_get_track_offset(data[0]);
		break;

		case AUDSRV_PLAY_SECTORS:
		ret = audsrv_cd_play_sectors(data[0], data[1]);
		break;

		case AUDSRV_GET_CD_STATUS:
		ret = audsrv_get_cd_status();
		break;

		case AUDSRV_GET_CD_TYPE:
		ret = audsrv_get_cd_type();
		break;

		case AUDSRV_PAUSE_CD:
		ret = audsrv_cd_pause();
		break;

		case AUDSRV_RESUME_CD:
		ret = audsrv_cd_resume();
		break;

		case AUDSRV_INIT_ADPCM:
		ret = audsrv_adpcm_init();
		break;

		case AUDSRV_LOAD_ADPCM:
		return audsrv_load_adpcm((u32*)data[0], data[1], data[2]);

		case AUDSRV_PLAY_ADPCM:
		ret = audsrv_play_adpcm(data[0]);
		break;

		default:
		ret = -1;
		break;
	}

	data[0] = ret;
	return data;
}