bugfixes, cd/Memory.s
authornotaz <notasas@gmail.com>
Mon, 19 Mar 2007 18:55:28 +0000 (18:55 +0000)
committernotaz <notasas@gmail.com>
Mon, 19 Mar 2007 18:55:28 +0000 (18:55 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@70 be3aeb3a-fb24-0410-a615-afba39da0efa

gp2x/940ctl.c
gp2x/Makefile
gp2x/emu.c
gp2x/menu.c

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