From d032c15a906f1d54f49648847b996ce5ed4362e6 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 19 Mar 2007 18:55:28 +0000 Subject: [PATCH] bugfixes, cd/Memory.s git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@70 be3aeb3a-fb24-0410-a615-afba39da0efa --- gp2x/940ctl.c | 10 +++++++++- gp2x/Makefile | 8 ++++++++ gp2x/emu.c | 34 +++++++++++++++------------------- gp2x/menu.c | 2 +- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/gp2x/940ctl.c b/gp2x/940ctl.c index 48ebfa0..b035591 100644 --- a/gp2x/940ctl.c +++ b/gp2x/940ctl.c @@ -99,7 +99,13 @@ int YM2612Write_940(unsigned int a, unsigned int v) switch( a ) { case 0: /* address port 0 */ + if (!addr_A1 && ST_address == v) + return 0; /* address already selected, don't send this command to 940 */ ST_address = v; + /* don't send DAC or timer related address changes to 940 */ + if (!addr_A1 && (v & 0xf0) == 0x20 && + (v == 0x24 || v == 0x25 || v == 0x26 || v == 0x2a)) + return 0; addr_A1 = 0; //ret=0; break; @@ -162,6 +168,8 @@ int YM2612Write_940(unsigned int a, unsigned int v) break; case 2: /* address port 1 */ + if (addr_A1 && ST_address == v) + return 0; ST_address = v; addr_A1 = 1; //ret=0; @@ -186,7 +194,7 @@ int YM2612Write_940(unsigned int a, unsigned int v) shared_ctl->writebuff1[writebuff_ptr++] = (a<<8)|v; } } else { - printf("warning: writebuff_ptr > 2047\n"); + printf("warning: writebuff_ptr > 2047 ([%i] %02x)\n", a, v); } } diff --git a/gp2x/Makefile b/gp2x/Makefile index 7818741..b045c2d 100644 --- a/gp2x/Makefile +++ b/gp2x/Makefile @@ -13,6 +13,7 @@ asm_render = 1 asm_ym2612 = 1 asm_misc = 1 asm_cdpico = 1 +asm_cdmemory = 1 #profile = 1 #use_musashi = 1 #up = 1 @@ -66,6 +67,10 @@ ifeq "$(asm_cdpico)" "1" DEFINC += -D_ASM_CD_PICO_C OBJS += ../../Pico/cd/pico_asm.o endif +ifeq "$(asm_cdmemory)" "1" +DEFINC += -D_ASM_CD_MEMORY_C +OBJS += ../../Pico/cd/memory_asm.o +endif # Pico - sound OBJS += ../../Pico/sound/mix_asm.o OBJS += ../../Pico/sound/sound.o ../../Pico/sound/sn76496.o ../../Pico/sound/ym2612.o @@ -147,6 +152,9 @@ testrefr.gpe : test.o gp2x.o asmutils.o ../../Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s @echo $< @$(AS) $(ASOPT) $< -o $@ +../../Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s + @echo $< + @$(AS) $(ASOPT) $< -o $@ # build Cyclone ../../cpu/Cyclone/proj/Cyclone.s : diff --git a/gp2x/emu.c b/gp2x/emu.c index 033f275..632ad18 100644 --- a/gp2x/emu.c +++ b/gp2x/emu.c @@ -973,21 +973,11 @@ static void updateSound(int len) } -static void SkipFrame(int do_sound) +static void SkipFrame(void) { - void *sndbuff_tmp = 0; - if (PsndOut && !do_sound) { - sndbuff_tmp = PsndOut; - PsndOut = 0; - } - PicoSkipFrame=1; PicoFrame(); PicoSkipFrame=0; - - if (sndbuff_tmp && !do_sound) { - PsndOut = sndbuff_tmp; - } } @@ -1166,7 +1156,7 @@ void emu_Loop(void) // when second changes, but we don't want buffer to starve. if(PsndOut && frames_done < target_fps && frames_done > target_fps-5) { updateKeys(); - SkipFrame(1); frames_done++; + SkipFrame(); frames_done++; } frames_done -= target_fps; if (frames_done < 0) frames_done = 0; @@ -1179,7 +1169,7 @@ void emu_Loop(void) if(currentConfig.Frameskip >= 0) { // frameskip enabled for(i = 0; i < currentConfig.Frameskip; i++) { updateKeys(); - SkipFrame(1); frames_done++; + SkipFrame(); frames_done++; if (PsndOut) { // do framelimitting if sound is enabled gettimeofday(&tval, 0); if(thissec != tval.tv_sec) tval.tv_usec+=1000000; @@ -1191,8 +1181,14 @@ void emu_Loop(void) } } else if(tval.tv_usec > lim_time) { // auto frameskip // no time left for this frame - skip + if (tval.tv_usec - lim_time >= 0x300000) { + /* something caused a slowdown for us (disk access? cache flush?) + * try to recover by resetting timing... */ + reset_timing = 1; + continue; + } updateKeys(); - SkipFrame(tval.tv_usec < lim_time+target_frametime); frames_done++; + SkipFrame(/*tval.tv_usec < lim_time+target_frametime*/); frames_done++; continue; } @@ -1259,14 +1255,14 @@ if (Pico.m.frame_count == 31563) { // check time gettimeofday(&tval, 0); - if(thissec != tval.tv_sec) tval.tv_usec+=1000000; + if (thissec != tval.tv_sec) tval.tv_usec+=1000000; - // sleep if we are still too fast - if(PsndOut != 0 || currentConfig.Frameskip < 0) + if (currentConfig.Frameskip < 0 && tval.tv_usec - lim_time >= 0x300000) // slowdown detection + reset_timing = 1; + else if (PsndOut != NULL || currentConfig.Frameskip < 0) { + // sleep if we are still too fast // usleep sleeps for ~20ms minimum, so it is not a solution here - gettimeofday(&tval, 0); - if(thissec != tval.tv_sec) tval.tv_usec+=1000000; if(tval.tv_usec < lim_time) { // we are too fast diff --git a/gp2x/menu.c b/gp2x/menu.c index 7050b98..5cab760 100644 --- a/gp2x/menu.c +++ b/gp2x/menu.c @@ -744,7 +744,7 @@ static void draw_cd_menu_options(int menu_sel, char *b_us, char *b_eu, char *b_j gp2x_text_out8(tl_x, (y+=10), "CD LEDs %s", (currentConfig.EmuOpt &0x0400)?"ON":"OFF"); // 3 gp2x_text_out8(tl_x, (y+=10), "CDDA audio (using mp3s) %s", (currentConfig.PicoOpt&0x0800)?"ON":"OFF"); // 4 gp2x_text_out8(tl_x, (y+=10), "PCM audio %s", (currentConfig.PicoOpt&0x0400)?"ON":"OFF"); // 5 - gp2x_text_out8(tl_x, (y+=10), "Better sync (slower) %s", (currentConfig.PicoOpt&0x2000)?"ON":"OFF"); // 6 + gp2x_text_out8(tl_x, (y+=10), "Better sync (slow) %s", (currentConfig.PicoOpt&0x2000)?"ON":"OFF"); // 6 gp2x_text_out8(tl_x, (y+=10), "ReadAhead buffer %s", ra_buff); // 7 gp2x_text_out8(tl_x, (y+=10), "Done"); -- 2.39.5