X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fgp2x%2Femu.c;h=36408f4807709023337f30c347e8f4889ca06e9e;hb=e11c55481f1703298b3e7e213f73cec8a136f974;hp=e564dfb71629070bdbd83e758af34a3c8315ff03;hpb=4f265db77684ec33f9533e7c76734498df03bba4;p=picodrive.git diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index e564dfb..36408f4 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -48,6 +48,7 @@ unsigned char *rom_data = NULL; extern int crashed_940; +static short sndBuffer[2*44100/50]; static char noticeMsg[64]; // notice msg to draw static struct timeval noticeMsgTime = { 0, 0 }; // when started showing static int reset_timing, osd_fps_x; @@ -455,7 +456,7 @@ int emu_ReadConfig(int game) currentConfig.lastRomFile[0] = 0; currentConfig.EmuOpt = 0x1f | 0x400; // | cd_leds currentConfig.PicoOpt = 0x0f | 0xe00; // | use_940 | cd_pcm | cd_cdda - currentConfig.PsndRate = 44100; + currentConfig.PsndRate = 22050; // 44100; currentConfig.PicoRegion = 0; // auto currentConfig.PicoAutoRgnOrder = 0x184; // US, EU, JP currentConfig.Frameskip = -1; // auto @@ -633,7 +634,7 @@ static int EmuScan8(unsigned int num, void *sdata) return 0; } -static int localPal[0x100]; +int localPal[0x100]; static void (*vidCpyM2)(void *dest, void *src) = NULL; static void blit(char *fps, char *notice) @@ -927,24 +928,10 @@ static void updateKeys(void) prevEvents = (allActions[0] | allActions[1]) >> 16; } -static int snd_excess_add = 0, snd_excess_cnt = 0; // hack -static void updateSound(void) +static void updateSound(int len) { - int len = (PicoOpt&8)?PsndLen*2:PsndLen; - - snd_excess_cnt += snd_excess_add; - if (snd_excess_cnt >= 0x10000) { - snd_excess_cnt -= 0x10000; - if (PicoOpt&8) { - PsndOut[len] = PsndOut[len-2]; - PsndOut[len+1] = PsndOut[len-1]; - len+=2; - } else { - PsndOut[len] = PsndOut[len-1]; - len++; - } - } + if (PicoOpt&8) len<<=1; gp2x_sound_write(PsndOut, len<<1); } @@ -1014,6 +1001,7 @@ void emu_Loop(void) // make sure we are in correct mode vidResetMode(); + Pico.m.dirtyPal = 1; oldmodes = ((Pico.video.reg[12]&1)<<2) ^ 0xc; find_combos(); @@ -1024,22 +1012,23 @@ void emu_Loop(void) // prepare sound stuff if(currentConfig.EmuOpt & 4) { + int snd_excess_add; if(PsndRate != PsndRate_old || (PicoOpt&0x20b) != (PicoOpt_old&0x20b) || Pico.m.pal != pal_old || crashed_940) { /* if 940 is turned off, we need it to be put back to sleep */ if (!(PicoOpt&0x200) && ((PicoOpt^PicoOpt_old)&0x200)) { Reset940(1, 2); Pause940(1); } - sound_rerate(); + sound_rerate(1); } //excess_samples = PsndRate - PsndLen*target_fps; - snd_excess_cnt = 0; snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps; printf("starting audio: %i len: %i (ex: %04x) stereo: %i, pal: %i\n", PsndRate, PsndLen, snd_excess_add, (PicoOpt&8)>>3, Pico.m.pal); gp2x_start_sound(PsndRate, 16, (PicoOpt&8)>>3); gp2x_sound_volume(currentConfig.volume, currentConfig.volume); PicoWriteSound = updateSound; - PsndOut = calloc((PicoOpt&8) ? (PsndLen*4+4) : (PsndLen*2+2), 1); + memset(sndBuffer, 0, sizeof(sndBuffer)); + PsndOut = sndBuffer; PsndRate_old = PsndRate; PsndLen_real = PsndLen; PicoOpt_old = PicoOpt; @@ -1240,9 +1229,12 @@ if (Pico.m.frame_count == 31563) { SRam.changed = 0; } - if (PsndOut != 0) { - free(PsndOut); - PsndOut = 0; + // if in 16bit mode, generate 8it image for menu background + if (!(PicoOpt&0x10) && (currentConfig.EmuOpt&0x80)) { + PicoOpt |= 0x10; + PicoFrameFull(); + blit("", NULL); blit("", NULL); blit("", NULL); blit("", NULL); // be sure buffer3 gets updated + PicoOpt &= ~0x10; } }