X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FPico.c;h=b07af08d508c635c82bc742f147a7c4d30430080;hb=e807ac752b4653487ec5bdf516205e24a1c657eb;hp=9ad226d66fe974910e8d3562bb79dca3055ce04e;hpb=b542be4686241c9e0722ff8e452980f9ac2b4d7c;p=picodrive.git diff --git a/Pico/Pico.c b/Pico/Pico.c index 9ad226d..b07af08 100644 --- a/Pico/Pico.c +++ b/Pico/Pico.c @@ -17,7 +17,9 @@ int PicoSkipFrame=0; // skip rendering frame? int PicoRegionOverride = 0; // override the region detection 0: Auto, 1: Japan NTSC, 2: Japan PAL, 4: US, 8: Europe int PicoAutoRgnOrder = 0; int emustatus = 0; // rapid_ym2612, multi_ym_updates -void (*PicoWriteSound)(int len) = 0; // called once per frame at the best time to send sound buffer (PsndOut) to hardware +void (*PicoWriteSound)(int len) = NULL; // called at the best time to send sound buffer (PsndOut) to hardware +void (*PicoResetHook)(void) = NULL; +void (*PicoLineHook)(int count) = NULL; struct PicoSRAM SRam = {0,}; int z80startCycle, z80stopCycle; // in 68k cycles @@ -36,6 +38,7 @@ int PicoInit(void) z80_init(); // init even if we aren't going to use it PicoInitMCD(); + PicoSVPInit(); SRam.data=0; @@ -139,6 +142,8 @@ int PicoReset(int hard) PsndReset(); // pal must be known here + if (PicoResetHook) PicoResetHook(); + if (PicoMCD & 1) { PicoResetMCD(hard); return 0; @@ -251,6 +256,12 @@ static int CheckIdle(void) // to be called on 224 or line_sample scanlines only static __inline void getSamples(int y) { +#if SIMPLE_WRITE_SOUND + if (y != 224) return; + PsndRender(0, PsndLen); + if (PicoWriteSound) PicoWriteSound(PsndLen); + PsndClear(); +#else static int curr_pos = 0; if(y == 224) { @@ -267,6 +278,7 @@ static __inline void getSamples(int y) emustatus&=~1; curr_pos = PsndRender(0, PsndLen/2); } +#endif } @@ -360,6 +372,7 @@ static int PicoFrameSimple(void) SekRunM68k(cycles_68k_block); PicoRunZ80Simple(line, lines); + if (PicoLineHook) PicoLineHook(lines_step); line=lines; } @@ -373,6 +386,7 @@ static int PicoFrameSimple(void) lines += sects*lines_step; PicoRunZ80Simple(line, lines); + if (PicoLineHook) PicoLineHook(sects*lines_step); } // render screen @@ -436,6 +450,7 @@ static int PicoFrameSimple(void) SekRunM68k(cycles_68k_vblock); PicoRunZ80Simple(line, lines); + if (PicoLineHook) PicoLineHook(lines_step); line=lines; sects--; @@ -446,6 +461,7 @@ static int PicoFrameSimple(void) if (sects) { lines += sects*lines_step; PicoRunZ80Simple(line, lines); + if (PicoLineHook) PicoLineHook(sects*lines_step); } return 0; @@ -487,6 +503,17 @@ void PicoFrameDrawOnly(void) for (y=0;y<224;y++) PicoLine(y); } +int PicoGetStat(pstat_t which) +{ + switch (which) + { + case PS_PAL: return Pico.m.pal; + case PS_40_CELL: return Pico.video.reg[12]&1; + case PS_240_LINES: return Pico.m.pal && (Pico.video.reg[1]&8); + } + return 0; +} + // callback to output message from emu void (*PicoMessage)(const char *msg)=NULL; @@ -573,14 +600,6 @@ char *debugString(void) } #endif -#if 0 - { - FILE *f = fopen("zram", "wb"); - fwrite(Pico.zram, 1, 0x2000, f); - fclose(f); - } -#endif - return dstr; } #endif