region detection, cd states wip, fixes, stuff

git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@25 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-01-28 22:51:16 +00:00
parent 598e7c06cd
commit 979ba09f05
7 changed files with 136 additions and 105 deletions

View file

@ -27,6 +27,7 @@ static unsigned char *mp3_mem = 0;
int crashed_940 = 0; int crashed_940 = 0;
static FILE *loaded_mp3 = 0;
/***********************************************************/ /***********************************************************/
@ -380,6 +381,8 @@ void YM2612Init_940(int baseclock, int rate)
internal_reset(); internal_reset();
loaded_mp3 = 0;
/* now cause 940 to init it's ym2612 stuff */ /* now cause 940 to init it's ym2612 stuff */
shared_ctl->baseclock = baseclock; shared_ctl->baseclock = baseclock;
shared_ctl->rate = rate; shared_ctl->rate = rate;
@ -468,13 +471,12 @@ static void mix_samples(short *dest_buf, int *ym_buf, short *mp3_buf, int len, i
// here we assume that length is different between games, but constant in one game // here we assume that length is different between games, but constant in one game
static FILE *loaded_mp3 = 0; static int mp3_samples_ready = 0, mp3_buffer_offs = 0;
static int mp3_play_bufsel = 0;
void YM2612UpdateOne_940(short *buffer, int length, int stereo) void YM2612UpdateOne_940(short *buffer, int length, int stereo)
{ {
int cdda_on, *ym_buffer = shared_data->mix_buffer, mp3_job = 0; int cdda_on, *ym_buffer = shared_data->mix_buffer, mp3_job = 0;
static int mp3_samples_ready = 0, mp3_buffer_offs = 0;
static int mp3_play_bufsel = 1;
//printf("YM2612UpdateOne_940()\n"); //printf("YM2612UpdateOne_940()\n");
if (shared_ctl->busy) wait_busy_940(); if (shared_ctl->busy) wait_busy_940();
@ -567,6 +569,10 @@ void mp3_start_play(FILE *f, int pos) // pos is 0-1023
printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len); printf("mp3 pos1024: %i, byte_offs %i/%i\n", pos, byte_offs, shared_ctl->mp3_len);
shared_ctl->mp3_offs = byte_offs; shared_ctl->mp3_offs = byte_offs;
// reset buffer pointers..
mp3_samples_ready = mp3_buffer_offs = mp3_play_bufsel = 0;
shared_ctl->mp3_buffsel = 1; // will change to 0 on first decode
} }

View file

@ -40,7 +40,8 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o
# Pico - CD # Pico - CD
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \ OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
../../Pico/cd/Area.o ../../Pico/cd/Misc.o
# asm stuff # asm stuff
ifeq "$(asm_render)" "1" ifeq "$(asm_render)" "1"
DEFINC += -D_ASM_DRAW_C DEFINC += -D_ASM_DRAW_C

View file

@ -456,6 +456,7 @@ int emu_ReadConfig(int game)
currentConfig.PicoOpt = 0x0f | 0x200; // | use_940 currentConfig.PicoOpt = 0x0f | 0x200; // | use_940
currentConfig.PsndRate = 44100; currentConfig.PsndRate = 44100;
currentConfig.PicoRegion = 0; // auto currentConfig.PicoRegion = 0; // auto
currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP
currentConfig.Frameskip = -1; // auto currentConfig.Frameskip = -1; // auto
currentConfig.CPUclock = 200; currentConfig.CPUclock = 200;
currentConfig.volume = 50; currentConfig.volume = 50;
@ -490,6 +491,7 @@ int emu_ReadConfig(int game)
PicoOpt = currentConfig.PicoOpt; PicoOpt = currentConfig.PicoOpt;
PsndRate = currentConfig.PsndRate; PsndRate = currentConfig.PsndRate;
PicoRegionOverride = currentConfig.PicoRegion; PicoRegionOverride = currentConfig.PicoRegion;
PicoAutoRgnOrder = currentConfig.PicoAutoRgnOrder;
if (PicoOpt & 0x20) { if (PicoOpt & 0x20) {
actionNames[ 8] = "Z"; actionNames[ 9] = "Y"; actionNames[ 8] = "Z"; actionNames[ 9] = "Y";
actionNames[10] = "X"; actionNames[11] = "MODE"; actionNames[10] = "X"; actionNames[11] = "MODE";
@ -527,6 +529,7 @@ int emu_WriteConfig(int game)
currentConfig.PicoOpt = PicoOpt; currentConfig.PicoOpt = PicoOpt;
currentConfig.PsndRate = PsndRate; currentConfig.PsndRate = PsndRate;
currentConfig.PicoRegion = PicoRegionOverride; currentConfig.PicoRegion = PicoRegionOverride;
currentConfig.PicoAutoRgnOrder = PicoAutoRgnOrder;
bwrite = fwrite(&currentConfig, 1, sizeof(currentConfig), f); bwrite = fwrite(&currentConfig, 1, sizeof(currentConfig), f);
fflush(f); fflush(f);
fclose(f); fclose(f);
@ -1231,6 +1234,7 @@ if (Pico.m.frame_count == 31563) {
// save SRAM // save SRAM
if((currentConfig.EmuOpt & 1) && SRam.changed) { if((currentConfig.EmuOpt & 1) && SRam.changed) {
blit("", "Writing SRAM/BRAM..");
emu_SaveLoadGame(0, 1); emu_SaveLoadGame(0, 1);
SRam.changed = 0; SRam.changed = 0;
} }
@ -1321,14 +1325,16 @@ int emu_SaveLoadGame(int load, int sram)
if( (PmovFile = gzopen(saveFname, load ? "rb" : "wb")) ) { if( (PmovFile = gzopen(saveFname, load ? "rb" : "wb")) ) {
areaRead = gzRead2; areaRead = gzRead2;
areaWrite = gzWrite2; areaWrite = gzWrite2;
areaEof = (areaeof *) gzeof;
if(!load) gzsetparams(PmovFile, 9, Z_DEFAULT_STRATEGY); if(!load) gzsetparams(PmovFile, 9, Z_DEFAULT_STRATEGY);
} else } else
saveFname[strlen(saveFname)-3] = 0; saveFname[strlen(saveFname)-3] = 0;
} }
if(!PmovFile) { // gzip failed or was disabled if(!PmovFile) { // gzip failed or was disabled
if( (PmovFile = fopen(saveFname, load ? "rb" : "wb")) ) { if( (PmovFile = fopen(saveFname, load ? "rb" : "wb")) ) {
areaRead = (STATE_SL_FUNC) fread; areaRead = (arearw *) fread;
areaWrite = (STATE_SL_FUNC) fwrite; areaWrite = (arearw *) fwrite;
areaEof = (areaeof *) feof;
} }
} }
if(PmovFile) { if(PmovFile) {

View file

@ -30,6 +30,7 @@ typedef struct {
int volume; int volume;
int gamma; int gamma;
int JoyBinds[4][32]; int JoyBinds[4][32];
int PicoAutoRgnOrder;
} currentConfig_t; } currentConfig_t;
extern char romFileName[]; extern char romFileName[];

View file

@ -562,18 +562,6 @@ static void kc_sel_loop(void)
// order must match that of currentConfig_t
struct {
int EmuOpt;
int PicoOpt;
int PsndRate;
int PicoRegion;
int Frameskip;
int CPUclock;
} tmp_opts;
int tmp_gamma;
// --------- sega/mega cd options ---------- // --------- sega/mega cd options ----------
static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_jp) static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_jp)
@ -585,8 +573,8 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j
gp2x_text_out8(tl_x, y, "USA BIOS: %s", b_us); // 0 gp2x_text_out8(tl_x, y, "USA BIOS: %s", b_us); // 0
gp2x_text_out8(tl_x, (y+=10), "EUR BIOS: %s", b_eu); // 1 gp2x_text_out8(tl_x, (y+=10), "EUR BIOS: %s", b_eu); // 1
gp2x_text_out8(tl_x, (y+=10), "JAP BIOS: %s", b_jp); // 2 gp2x_text_out8(tl_x, (y+=10), "JAP BIOS: %s", b_jp); // 2
gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (tmp_opts.EmuOpt &0x400)?"ON":"OFF"); // 3 gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x400)?"ON":"OFF"); // 3
gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (tmp_opts.EmuOpt &0x800)?"ON":"OFF"); // 4 gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.EmuOpt &0x800)?"ON":"OFF"); // 4
gp2x_text_out8(tl_x, (y+=10), "Done"); gp2x_text_out8(tl_x, (y+=10), "Done");
// draw cursor // draw cursor
@ -629,8 +617,8 @@ static void cd_menu_loop_options(void)
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options
switch (menu_sel) { switch (menu_sel) {
case 3: tmp_opts.EmuOpt ^=0x400; break; case 3: currentConfig.EmuOpt ^=0x400; break;
case 4: tmp_opts.EmuOpt ^=0x800; break; case 4: currentConfig.EmuOpt ^=0x800; break;
case 5: return; case 5: return;
} }
} }
@ -670,16 +658,16 @@ static void draw_amenu_options(int menu_sel)
y = tl_y; y = tl_y;
memset(gp2x_screen, 0, 320*240); memset(gp2x_screen, 0, 320*240);
gp2x_text_out8(tl_x, y, "Scale 32 column mode %s", (tmp_opts.PicoOpt&0x100)?"ON":"OFF"); // 0 gp2x_text_out8(tl_x, y, "Scale 32 column mode %s", (currentConfig.PicoOpt&0x100)?"ON":"OFF"); // 0
gp2x_text_out8(tl_x, (y+=10), "Gamma correction %i.%02i", tmp_gamma / 100, tmp_gamma%100); // 1 gp2x_text_out8(tl_x, (y+=10), "Gamma correction %i.%02i", currentConfig.gamma / 100, currentConfig.gamma%100); // 1
gp2x_text_out8(tl_x, (y+=10), "Emulate Z80 %s", (tmp_opts.PicoOpt&0x004)?"ON":"OFF"); // 2 gp2x_text_out8(tl_x, (y+=10), "Emulate Z80 %s", (currentConfig.PicoOpt&0x004)?"ON":"OFF"); // 2
gp2x_text_out8(tl_x, (y+=10), "Emulate YM2612 (FM) %s", (tmp_opts.PicoOpt&0x001)?"ON":"OFF"); // 3 gp2x_text_out8(tl_x, (y+=10), "Emulate YM2612 (FM) %s", (currentConfig.PicoOpt&0x001)?"ON":"OFF"); // 3
gp2x_text_out8(tl_x, (y+=10), "Emulate SN76496 (PSG) %s", (tmp_opts.PicoOpt&0x002)?"ON":"OFF"); // 4 gp2x_text_out8(tl_x, (y+=10), "Emulate SN76496 (PSG) %s", (currentConfig.PicoOpt&0x002)?"ON":"OFF"); // 4
gp2x_text_out8(tl_x, (y+=10), "gzip savestates %s", (tmp_opts.EmuOpt &0x008)?"ON":"OFF"); // 5 gp2x_text_out8(tl_x, (y+=10), "gzip savestates %s", (currentConfig.EmuOpt &0x008)?"ON":"OFF"); // 5
gp2x_text_out8(tl_x, (y+=10), "Don't save config on exit %s", (tmp_opts.EmuOpt &0x020)?"ON":"OFF"); // 6 gp2x_text_out8(tl_x, (y+=10), "Don't save config on exit %s", (currentConfig.EmuOpt &0x020)?"ON":"OFF"); // 6
gp2x_text_out8(tl_x, (y+=10), "needs restart:"); gp2x_text_out8(tl_x, (y+=10), "needs restart:");
gp2x_text_out8(tl_x, (y+=10), "craigix's RAM timings %s", (tmp_opts.EmuOpt &0x100)?"ON":"OFF"); // 8 gp2x_text_out8(tl_x, (y+=10), "craigix's RAM timings %s", (currentConfig.EmuOpt &0x100)?"ON":"OFF"); // 8
gp2x_text_out8(tl_x, (y+=10), "squidgehack (now %s %s", mms, (tmp_opts.EmuOpt &0x010)?"ON":"OFF"); // 9 gp2x_text_out8(tl_x, (y+=10), "squidgehack (now %s %s", mms, (currentConfig.EmuOpt &0x010)?"ON":"OFF"); // 9
gp2x_text_out8(tl_x, (y+=10), "Done"); gp2x_text_out8(tl_x, (y+=10), "Done");
// draw cursor // draw cursor
@ -701,14 +689,14 @@ static void amenu_loop_options(void)
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options
switch (menu_sel) { switch (menu_sel) {
case 0: tmp_opts.PicoOpt^=0x100; break; case 0: currentConfig.PicoOpt^=0x100; break;
case 2: tmp_opts.PicoOpt^=0x004; break; case 2: currentConfig.PicoOpt^=0x004; break;
case 3: tmp_opts.PicoOpt^=0x001; break; case 3: currentConfig.PicoOpt^=0x001; break;
case 4: tmp_opts.PicoOpt^=0x002; break; case 4: currentConfig.PicoOpt^=0x002; break;
case 5: tmp_opts.EmuOpt ^=0x008; break; case 5: currentConfig.EmuOpt ^=0x008; break;
case 6: tmp_opts.EmuOpt ^=0x020; break; case 6: currentConfig.EmuOpt ^=0x020; break;
case 8: tmp_opts.EmuOpt ^=0x100; break; case 8: currentConfig.EmuOpt ^=0x100; break;
case 9: tmp_opts.EmuOpt ^=0x010; break; case 9: currentConfig.EmuOpt ^=0x010; break;
case 10: return; case 10: return;
} }
} }
@ -717,9 +705,9 @@ static void amenu_loop_options(void)
switch (menu_sel) { switch (menu_sel) {
case 1: case 1:
while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) { while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) {
tmp_gamma += (inp & GP2X_LEFT) ? -1 : 1; currentConfig.gamma += (inp & GP2X_LEFT) ? -1 : 1;
if (tmp_gamma < 1) tmp_gamma = 1; if (currentConfig.gamma < 1) currentConfig.gamma = 1;
if (tmp_gamma > 300) tmp_gamma = 300; if (currentConfig.gamma > 300) currentConfig.gamma = 300;
draw_amenu_options(menu_sel); draw_amenu_options(menu_sel);
usleep(18*1000); usleep(18*1000);
} }
@ -731,14 +719,26 @@ static void amenu_loop_options(void)
// -------------- options -------------- // -------------- options --------------
static char *region_name(unsigned int code) static const char *region_name(unsigned int code)
{ {
char *names[] = { "Auto", "Japan NTSC", "Japan PAL", "USA", "Europe" }; static const char *names[] = { "Auto", " Japan NTSC", " Japan PAL", " USA", " Europe" };
int i = 0; static const char *names_short[] = { "", " JP", " JP", " US", " EU" };
int u, i = 0;
if (code) {
code <<= 1; code <<= 1;
while((code >>=1)) i++; while((code >>= 1)) i++;
if (i > 4) return "unknown"; if (i > 4) return "unknown";
return names[i]; return names[i];
} else {
static char name[24];
strcpy(name, "Auto:");
for (u = 0; u < 3; u++) {
i = 0; code = ((PicoAutoRgnOrder >> u*4) & 0xf) << 1;
while((code >>= 1)) i++;
strcat(name, names_short[i]);
}
return name;
}
} }
static void draw_menu_options(int menu_sel) static void draw_menu_options(int menu_sel)
@ -746,13 +746,13 @@ static void draw_menu_options(int menu_sel)
int tl_x = 25, tl_y = 40, y; int tl_x = 25, tl_y = 40, y;
char monostereo[8], strframeskip[8], *strrend; char monostereo[8], strframeskip[8], *strrend;
strcpy(monostereo, (tmp_opts.PicoOpt&0x08)?"stereo":"mono"); strcpy(monostereo, (currentConfig.PicoOpt&0x08)?"stereo":"mono");
if (tmp_opts.Frameskip < 0) if (currentConfig.Frameskip < 0)
strcpy(strframeskip, "Auto"); strcpy(strframeskip, "Auto");
else sprintf(strframeskip, "%i", tmp_opts.Frameskip); else sprintf(strframeskip, "%i", currentConfig.Frameskip);
if (tmp_opts.PicoOpt&0x10) { if (currentConfig.PicoOpt&0x10) {
strrend = " 8bit fast"; strrend = " 8bit fast";
} else if (tmp_opts.EmuOpt&0x80) { } else if (currentConfig.EmuOpt&0x80) {
strrend = "16bit accurate"; strrend = "16bit accurate";
} else { } else {
strrend = " 8bit accurate"; strrend = " 8bit accurate";
@ -761,19 +761,19 @@ static void draw_menu_options(int menu_sel)
y = tl_y; y = tl_y;
memset(gp2x_screen, 0, 320*240); memset(gp2x_screen, 0, 320*240);
gp2x_text_out8(tl_x, y, "Renderer: %s", strrend); // 0 gp2x_text_out8(tl_x, y, "Renderer: %s", strrend); // 0
gp2x_text_out8(tl_x, (y+=10), "Accurate timing (slower) %s", (tmp_opts.PicoOpt&0x040)?"ON":"OFF"); // 1 gp2x_text_out8(tl_x, (y+=10), "Accurate timing (slower) %s", (currentConfig.PicoOpt&0x040)?"ON":"OFF"); // 1
gp2x_text_out8(tl_x, (y+=10), "Accurate sprites (slower) %s", (tmp_opts.PicoOpt&0x080)?"ON":"OFF"); // 2 gp2x_text_out8(tl_x, (y+=10), "Accurate sprites (slower) %s", (currentConfig.PicoOpt&0x080)?"ON":"OFF"); // 2
gp2x_text_out8(tl_x, (y+=10), "Show FPS %s", (tmp_opts.EmuOpt &0x002)?"ON":"OFF"); // 3 gp2x_text_out8(tl_x, (y+=10), "Show FPS %s", (currentConfig.EmuOpt &0x002)?"ON":"OFF"); // 3
gp2x_text_out8(tl_x, (y+=10), "Frameskip %s", strframeskip); gp2x_text_out8(tl_x, (y+=10), "Frameskip %s", strframeskip);
gp2x_text_out8(tl_x, (y+=10), "Enable sound %s", (tmp_opts.EmuOpt &0x004)?"ON":"OFF"); // 5 gp2x_text_out8(tl_x, (y+=10), "Enable sound %s", (currentConfig.EmuOpt &0x004)?"ON":"OFF"); // 5
gp2x_text_out8(tl_x, (y+=10), "Sound Quality: %5iHz %s", tmp_opts.PsndRate, monostereo); gp2x_text_out8(tl_x, (y+=10), "Sound Quality: %5iHz %s", currentConfig.PsndRate, monostereo);
gp2x_text_out8(tl_x, (y+=10), "Use ARM940 core for sound %s", (tmp_opts.PicoOpt&0x200)?"ON":"OFF"); // 7 gp2x_text_out8(tl_x, (y+=10), "Use ARM940 core for sound %s", (currentConfig.PicoOpt&0x200)?"ON":"OFF"); // 7
gp2x_text_out8(tl_x, (y+=10), "6 button pad %s", (tmp_opts.PicoOpt&0x020)?"ON":"OFF"); // 8 gp2x_text_out8(tl_x, (y+=10), "6 button pad %s", (currentConfig.PicoOpt&0x020)?"ON":"OFF"); // 8
gp2x_text_out8(tl_x, (y+=10), "Genesis Region: %s", region_name(tmp_opts.PicoRegion)); gp2x_text_out8(tl_x, (y+=10), "Genesis Region: %s", region_name(currentConfig.PicoRegion));
gp2x_text_out8(tl_x, (y+=10), "Use SRAM/BRAM savestates %s", (tmp_opts.EmuOpt &0x001)?"ON":"OFF"); // 10 gp2x_text_out8(tl_x, (y+=10), "Use SRAM/BRAM savestates %s", (currentConfig.EmuOpt &0x001)?"ON":"OFF"); // 10
gp2x_text_out8(tl_x, (y+=10), "Confirm save overwrites %s", (tmp_opts.EmuOpt &0x200)?"ON":"OFF"); // 11 gp2x_text_out8(tl_x, (y+=10), "Confirm save overwrites %s", (currentConfig.EmuOpt &0x200)?"ON":"OFF"); // 11
gp2x_text_out8(tl_x, (y+=10), "Save slot %i", state_slot); // 12 gp2x_text_out8(tl_x, (y+=10), "Save slot %i", state_slot); // 12
gp2x_text_out8(tl_x, (y+=10), "GP2X CPU clocks %iMhz", tmp_opts.CPUclock); gp2x_text_out8(tl_x, (y+=10), "GP2X CPU clocks %iMhz", currentConfig.CPUclock);
gp2x_text_out8(tl_x, (y+=10), "[Sega/Mega CD options]"); gp2x_text_out8(tl_x, (y+=10), "[Sega/Mega CD options]");
gp2x_text_out8(tl_x, (y+=10), "[advanced options]"); // 15 gp2x_text_out8(tl_x, (y+=10), "[advanced options]"); // 15
gp2x_text_out8(tl_x, (y+=10), "Save cfg as default"); gp2x_text_out8(tl_x, (y+=10), "Save cfg as default");
@ -799,10 +799,32 @@ static int sndrate_prevnext(int rate, int dir)
return rates[i]; return rates[i];
} }
static void region_prevnext(int right)
{
// jp_ntsc=1, jp_pal=2, usa=4, eu=8
static int rgn_orders[] = { 0x148, 0x184, 0x814, 0x418, 0x841, 0x481 };
int i;
if (right) {
if (!currentConfig.PicoRegion) {
for (i = 0; i < 6; i++)
if (rgn_orders[i] == PicoAutoRgnOrder) break;
if (i < 5) PicoAutoRgnOrder = rgn_orders[i+1];
else currentConfig.PicoRegion=1;
}
else currentConfig.PicoRegion<<=1;
if (currentConfig.PicoRegion > 8) currentConfig.PicoRegion = 8;
} else {
if (!currentConfig.PicoRegion) {
for (i = 0; i < 6; i++)
if (rgn_orders[i] == PicoAutoRgnOrder) break;
if (i > 0) PicoAutoRgnOrder = rgn_orders[i-1];
}
else currentConfig.PicoRegion>>=1;
}
}
static void menu_options_save(void) static void menu_options_save(void)
{ {
memcpy(&currentConfig.EmuOpt, &tmp_opts.EmuOpt, sizeof(tmp_opts));
currentConfig.gamma = tmp_gamma;
PicoOpt = currentConfig.PicoOpt; PicoOpt = currentConfig.PicoOpt;
PsndRate = currentConfig.PsndRate; PsndRate = currentConfig.PsndRate;
PicoRegionOverride = currentConfig.PicoRegion; PicoRegionOverride = currentConfig.PicoRegion;
@ -820,11 +842,9 @@ static int menu_loop_options(void)
unsigned long inp = 0; unsigned long inp = 0;
if (rom_data) menu_sel_max++; if (rom_data) menu_sel_max++;
memcpy(&tmp_opts.EmuOpt, &currentConfig.EmuOpt, sizeof(tmp_opts)); currentConfig.PicoOpt = PicoOpt;
tmp_gamma = currentConfig.gamma; currentConfig.PsndRate = PsndRate;
tmp_opts.PicoOpt = PicoOpt; currentConfig.PicoRegion = PicoRegionOverride;
tmp_opts.PsndRate = PsndRate;
tmp_opts.PicoRegion = PicoRegionOverride;
for(;;) for(;;)
{ {
@ -834,14 +854,14 @@ static int menu_loop_options(void)
if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; } if(inp & GP2X_DOWN) { menu_sel++; if (menu_sel > menu_sel_max) menu_sel = 0; }
if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options if((inp& GP2X_B)||(inp&GP2X_LEFT)||(inp&GP2X_RIGHT)) { // toggleable options
switch (menu_sel) { switch (menu_sel) {
case 1: tmp_opts.PicoOpt^=0x040; break; case 1: currentConfig.PicoOpt^=0x040; break;
case 2: tmp_opts.PicoOpt^=0x080; break; case 2: currentConfig.PicoOpt^=0x080; break;
case 3: tmp_opts.EmuOpt ^=0x002; break; case 3: currentConfig.EmuOpt ^=0x002; break;
case 5: tmp_opts.EmuOpt ^=0x004; break; case 5: currentConfig.EmuOpt ^=0x004; break;
case 7: tmp_opts.PicoOpt^=0x200; break; case 7: currentConfig.PicoOpt^=0x200; break;
case 8: tmp_opts.PicoOpt^=0x020; break; case 8: currentConfig.PicoOpt^=0x020; break;
case 10: tmp_opts.EmuOpt ^=0x001; break; case 10: currentConfig.EmuOpt ^=0x001; break;
case 11: tmp_opts.EmuOpt ^=0x200; break; case 11: currentConfig.EmuOpt ^=0x200; break;
case 14: cd_menu_loop_options(); case 14: cd_menu_loop_options();
if (engineState == PGS_ReloadRom) if (engineState == PGS_ReloadRom)
return 0; // test BIOS return 0; // test BIOS
@ -859,8 +879,7 @@ static int menu_loop_options(void)
return 1; return 1;
} }
} }
if(inp & GP2X_X) return 0; // done (no update or write) if(inp & (GP2X_X|GP2X_A)) {
if(inp & GP2X_A) {
menu_options_save(); menu_options_save();
return 0; // done (update, no write) return 0; // done (update, no write)
} }
@ -868,32 +887,29 @@ static int menu_loop_options(void)
switch (menu_sel) { switch (menu_sel) {
case 0: case 0:
if (inp & GP2X_LEFT) { if (inp & GP2X_LEFT) {
if ( tmp_opts.PicoOpt&0x10) tmp_opts.PicoOpt&= ~0x10; if ( currentConfig.PicoOpt&0x10) currentConfig.PicoOpt&= ~0x10;
else if (!(tmp_opts.EmuOpt &0x80))tmp_opts.EmuOpt |= 0x80; else if (!(currentConfig.EmuOpt &0x80))currentConfig.EmuOpt |= 0x80;
else if ( tmp_opts.EmuOpt &0x80) break; else if ( currentConfig.EmuOpt &0x80) break;
} else { } else {
if ( tmp_opts.PicoOpt&0x10) break; if ( currentConfig.PicoOpt&0x10) break;
else if (!(tmp_opts.EmuOpt &0x80))tmp_opts.PicoOpt|= 0x10; else if (!(currentConfig.EmuOpt &0x80))currentConfig.PicoOpt|= 0x10;
else if ( tmp_opts.EmuOpt &0x80) tmp_opts.EmuOpt &= ~0x80; else if ( currentConfig.EmuOpt &0x80) currentConfig.EmuOpt &= ~0x80;
} }
break; break;
case 4: case 4:
tmp_opts.Frameskip += (inp & GP2X_LEFT) ? -1 : 1; currentConfig.Frameskip += (inp & GP2X_LEFT) ? -1 : 1;
if (tmp_opts.Frameskip < 0) tmp_opts.Frameskip = -1; if (currentConfig.Frameskip < 0) currentConfig.Frameskip = -1;
if (tmp_opts.Frameskip > 32) tmp_opts.Frameskip = 32; if (currentConfig.Frameskip > 32) currentConfig.Frameskip = 32;
break; break;
case 6: case 6:
if ((inp & GP2X_RIGHT) && tmp_opts.PsndRate == 44100 && !(tmp_opts.PicoOpt&0x08)) { if ((inp & GP2X_RIGHT) && currentConfig.PsndRate == 44100 && !(currentConfig.PicoOpt&0x08)) {
tmp_opts.PsndRate = 8000; tmp_opts.PicoOpt|= 0x08; currentConfig.PsndRate = 8000; currentConfig.PicoOpt|= 0x08;
} else if ((inp & GP2X_LEFT) && tmp_opts.PsndRate == 8000 && (tmp_opts.PicoOpt&0x08)) { } else if ((inp & GP2X_LEFT) && currentConfig.PsndRate == 8000 && (currentConfig.PicoOpt&0x08)) {
tmp_opts.PsndRate = 44100; tmp_opts.PicoOpt&=~0x08; currentConfig.PsndRate = 44100; currentConfig.PicoOpt&=~0x08;
} else tmp_opts.PsndRate = sndrate_prevnext(tmp_opts.PsndRate, inp & GP2X_RIGHT); } else currentConfig.PsndRate = sndrate_prevnext(currentConfig.PsndRate, inp & GP2X_RIGHT);
break; break;
case 9: case 9:
if (inp & GP2X_RIGHT) { region_prevnext(inp & GP2X_RIGHT);
if (tmp_opts.PicoRegion) tmp_opts.PicoRegion<<=1; else tmp_opts.PicoRegion=1;
if (tmp_opts.PicoRegion > 8) tmp_opts.PicoRegion = 8;
} else tmp_opts.PicoRegion>>=1;
break; break;
case 12: case 12:
if (inp & GP2X_RIGHT) { if (inp & GP2X_RIGHT) {
@ -903,8 +919,8 @@ static int menu_loop_options(void)
break; break;
case 13: case 13:
while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) { while ((inp = gp2x_joystick_read(1)) & (GP2X_LEFT|GP2X_RIGHT)) {
tmp_opts.CPUclock += (inp & GP2X_LEFT) ? -1 : 1; currentConfig.CPUclock += (inp & GP2X_LEFT) ? -1 : 1;
if (tmp_opts.CPUclock < 1) tmp_opts.CPUclock = 1; if (currentConfig.CPUclock < 1) currentConfig.CPUclock = 1;
draw_menu_options(menu_sel); draw_menu_options(menu_sel);
usleep(50*1000); usleep(50*1000);
} }

View file

@ -23,9 +23,9 @@ YM2612 *ym2612_940 = &ym2612;
int mix_buffer_[44100/50*2]; /* this is where the YM2612 samples will be mixed to */ int mix_buffer_[44100/50*2]; /* this is where the YM2612 samples will be mixed to */
int *mix_buffer = mix_buffer_; int *mix_buffer = mix_buffer_;
static _940_data_t shared_data_; // static _940_data_t shared_data_;
static _940_ctl_t shared_ctl_; static _940_ctl_t shared_ctl_;
static _940_data_t *shared_data = &shared_data_; // static _940_data_t *shared_data = &shared_data_;
static _940_ctl_t *shared_ctl = &shared_ctl_; static _940_ctl_t *shared_ctl = &shared_ctl_;
unsigned char *mp3_mem = 0; unsigned char *mp3_mem = 0;

View file

@ -30,7 +30,8 @@ OBJS += ../../Pico/Area.o ../../Pico/Cart.o ../../Pico/Utils.o ../../Pico/Memory
../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o ../../Pico/Pico.o ../../Pico/Sek.o ../../Pico/VideoPort.o ../../Pico/Draw2.o ../../Pico/Draw.o
# Pico - CD # Pico - CD
OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \ OBJS += ../../Pico/cd/Pico.o ../../Pico/cd/Memory.o ../../Pico/cd/Sek.o ../../Pico/cd/LC89510.o \
../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o ../../Pico/cd/cd_sys.o ../../Pico/cd/cd_file.o ../../Pico/cd/gfx_cd.o \
../../Pico/cd/Area.o ../../Pico/cd/Misc.o
# Pico - sound # Pico - sound
OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o
# zlib # zlib