From fad248933b6676d30ccf419858b4ee10cc123fc5 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 13 Mar 2008 22:30:34 +0000 Subject: [PATCH] hint-less mode updated for SVP, state load callback, etc git-svn-id: file:///home/notaz/opt/svn/PicoDrive@384 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Area.c | 10 +++++++++- Pico/Cart.c | 1 + Pico/Pico.c | 22 ++++++++++++++++++---- Pico/PicoFrameHints.c | 32 ++++++++++++++++++++++++-------- Pico/PicoInt.h | 1 + Pico/Sek.c | 3 +++ Pico/VideoPort.c | 2 +- Pico/carthw/svp/compiler.c | 13 +++++++++++++ Pico/carthw/svp/gen_arm.c | 2 ++ platform/gp2x/emu.c | 11 +++++++++-- platform/linux/Makefile | 4 +++- 11 files changed, 84 insertions(+), 17 deletions(-) diff --git a/Pico/Area.c b/Pico/Area.c index 68d7c7c..0ec25ec 100644 --- a/Pico/Area.c +++ b/Pico/Area.c @@ -28,6 +28,8 @@ areaeof *areaEof = (areaeof *) 0; areaseek *areaSeek = (areaseek *) 0; areaclose *areaClose = (areaclose *) 0; +void (*PicoLoadStateHook)(void) = NULL; + // Scan one variable and callback static int ScanVar(void *data,int len,char *name,void *PmovFile,int PmovAction) @@ -177,7 +179,11 @@ int PmovState(int PmovAction, void *PmovFile) if ((PicoMCD & 1) || carthw_chunks != NULL) { if (PmovAction&1) return PicoCdSaveState(PmovFile); - if (PmovAction&2) return PicoCdLoadState(PmovFile); + if (PmovAction&2) { + int ret = PicoCdLoadState(PmovFile); + if (PicoLoadStateHook) PicoLoadStateHook(); + return ret; + } } memset(head,0,sizeof(head)); @@ -197,6 +203,8 @@ int PmovState(int PmovAction, void *PmovFile) // Scan memory areas: PicoAreaScan(PmovAction, *(unsigned int *)(head+0x8), PmovFile); + if ((PmovAction&2) && PicoLoadStateHook) PicoLoadStateHook(); + return 0; } diff --git a/Pico/Cart.c b/Pico/Cart.c index 52f5cf5..4b94b47 100644 --- a/Pico/Cart.c +++ b/Pico/Cart.c @@ -504,6 +504,7 @@ int PicoCartInsert(unsigned char *rom,unsigned int romsize) PicoDmaHook = NULL; PicoResetHook = NULL; PicoLineHook = NULL; + PicoLoadStateHook = NULL; carthw_chunks = NULL; PicoMemReset(); diff --git a/Pico/Pico.c b/Pico/Pico.c index a76c9e4..2ebe9c9 100644 --- a/Pico/Pico.c +++ b/Pico/Pico.c @@ -244,12 +244,12 @@ static __inline void SekStep(void) static int CheckIdle(void) { - int i, state[0x22]; + int i, state[0x24]; // See if the state is the same after 2 steps: - SekState(state); SekStep(); SekStep(); SekState(state+0x11); - for (i = 0x10; i >= 0; i--) - if (state[i] != state[i+0x11]) return 0; + SekState(state); SekStep(); SekStep(); SekState(state+0x12); + for (i = 0x11; i >= 0; i--) + if (state[i] != state[i+0x12]) return 0; return 1; } @@ -344,6 +344,10 @@ static int PicoFrameSimple(void) lines_step = 14; } + // a hack for VR, to get it running in fast mode + if (PicoRead16Hook == PicoSVPRead16) + Pico.ram[0xd864^1] = 0x1a; + // we don't emulate DMA timing in this mode if (Pico.m.dma_xfers) { Pico.m.dma_xfers=0; @@ -391,10 +395,19 @@ static int PicoFrameSimple(void) if (PicoLineHook) PicoLineHook(sects*lines_step); } + // another hack for VR (it needs hints to work) + if (PicoRead16Hook == PicoSVPRead16) { + Pico.ram[0xd864^1] = 1; + pv->pending_ints|=0x10; + if (pv->reg[0]&0x10) SekInterrupt(4); + SekRunM68k(160); + } + // render screen if (!PicoSkipFrame) { if (!(PicoOpt&0x10)) + { // Draw the screen #if CAN_HANDLE_240_LINES if (pv->reg[1]&8) { @@ -405,6 +418,7 @@ static int PicoFrameSimple(void) #else for (y=0;y<224;y++) PicoLine(y); #endif + } else PicoFrameFull(); #ifdef DRAW_FINISH_FUNC DRAW_FINISH_FUNC(); diff --git a/Pico/PicoFrameHints.c b/Pico/PicoFrameHints.c index 755ab3d..c8f8946 100644 --- a/Pico/PicoFrameHints.c +++ b/Pico/PicoFrameHints.c @@ -1,5 +1,5 @@ // common code for Pico.c and cd/Pico.c -// (c) Copyright 2007, Grazvydas "notaz" Ignotas +// (c) Copyright 2007,2008 Grazvydas "notaz" Ignotas #define CYCLES_M68K_LINE 488 // suitable for both PAL/NTSC #define CYCLES_M68K_VINT_LAG 68 @@ -60,7 +60,7 @@ static int PicoFrameHints(void) int lines, y, lines_vis = 224, total_z80 = 0, z80CycleAim = 0, line_sample, skip; int hint; // Hint counter - if ((PicoOpt&0x10) && !PicoSkipFrame) { + if ((PicoOpt&0x10) && !PicoSkipFrame && (pv->reg[1]&0x40)) { // fast rend., display enabled // draw a frame just after vblank in alternative render mode // yes, this will cause 1 frame lag, but this is inaccurate mode anyway. PicoFrameFull(); @@ -125,21 +125,37 @@ static int PicoFrameHints(void) } // decide if we draw this line + if (!skip) + { + if (PicoOpt&0x10) { + // find the right moment for fast renderer, when display is no longer blanked + if ((pv->reg[1]&0x40) || y > 100) { + PicoFrameFull(); +#ifdef DRAW_FINISH_FUNC + DRAW_FINISH_FUNC(); +#endif + skip = 1; + } + } + else + { #if CAN_HANDLE_240_LINES - if(!skip && ((!(pv->reg[1]&8) && y<224) || (pv->reg[1]&8)) ) + if (((!(pv->reg[1]&8) && y < 224) || (pv->reg[1]&8)) ) #else - if(!skip && y<224) + if (y < 224) #endif - PicoLine(y); + PicoLine(y); + } + } - if(PicoOpt&1) + if (PicoOpt&1) Psnd_timers_and_dac(y); #ifndef PICO_CD // get samples from sound chips - if(y == 32 && PsndOut) + if (y == 32 && PsndOut) emustatus &= ~1; - else if((y == 224 || y == line_sample) && PsndOut) + else if ((y == 224 || y == line_sample) && PsndOut) getSamples(y); #endif diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index f29c20b..c867c19 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -362,6 +362,7 @@ typedef struct // Area.c PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub); PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub); +extern void (*PicoLoadStateHook)(void); // cd/Area.c PICO_INTERNAL int PicoCdSaveState(void *file); diff --git a/Pico/Sek.c b/Pico/Sek.c index 4bf06d1..e771280 100644 --- a/Pico/Sek.c +++ b/Pico/Sek.c @@ -170,12 +170,15 @@ PICO_INTERNAL void SekState(int *data) { #ifdef EMU_C68K memcpy32(data,(int *)PicoCpuCM68k.d,0x44/4); + data[0x11] = PicoCpuCM68k.flags; #elif defined(EMU_M68K) memcpy32(data, (int *)PicoCpuMM68k.dar, 0x40/4); data[0x10] = PicoCpuMM68k.pc; + data[0x11] = m68k_get_reg(&PicoCpuMM68k, M68K_REG_SR); #elif defined(EMU_F68K) memcpy32(data, (int *)PicoCpuFM68k.dreg, 0x40/4); data[0x10] = PicoCpuFM68k.pc; + data[0x11] = PicoCpuFM68k.sr; #endif } diff --git a/Pico/VideoPort.c b/Pico/VideoPort.c index c448873..cceab7c 100644 --- a/Pico/VideoPort.c +++ b/Pico/VideoPort.c @@ -399,7 +399,7 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) else if(pints & 0x10) irq = 4; SekInterrupt(irq); // update line - if (irq) SekEndRun(24); // make it delayed + if (irq && Pico.m.scanline!=-1) SekEndRun(24); // make it delayed } } #endif diff --git a/Pico/carthw/svp/compiler.c b/Pico/carthw/svp/compiler.c index 63bc9ab..f89ad95 100644 --- a/Pico/carthw/svp/compiler.c +++ b/Pico/carthw/svp/compiler.c @@ -1629,6 +1629,12 @@ void *ssp_translate_block(int pc) // ----------------------------------------------------- +static void ssp1601_state_load(void) +{ + ssp->drc.iram_dirty = 1; + ssp->drc.iram_context = 0; +} + int ssp1601_dyn_startup(void) { memset(tcache, 0, TCACHE_SIZE); @@ -1637,6 +1643,8 @@ int ssp1601_dyn_startup(void) tcache_ptr = tcache; *tcache_ptr++ = 0xffffffff; + PicoLoadStateHook = ssp1601_state_load; + #ifdef ARM // hle'd blocks block_table[0x400] = (void *) ssp_hle_800; @@ -1664,6 +1672,11 @@ void ssp1601_dyn_run(int cycles) { if (ssp->emu_status & SSP_WAIT_MASK) return; +#ifdef DUMP_BLOCK + ssp_translate_block(DUMP_BLOCK >> 1); +#endif +#ifdef ARM ssp_drc_entry(cycles); +#endif } diff --git a/Pico/carthw/svp/gen_arm.c b/Pico/carthw/svp/gen_arm.c index 70b1a8d..909433a 100644 --- a/Pico/carthw/svp/gen_arm.c +++ b/Pico/carthw/svp/gen_arm.c @@ -204,7 +204,9 @@ static void emit_block_epilogue(int cycles) { if (cycles > 0xff) { printf("large cycle count: %i\n", cycles); cycles = 0xff; } EOP_SUB_IMM(11,11,0,cycles); // sub r11, r11, #cycles +#ifdef ARM emit_call(ssp_drc_next); +#endif } static void emit_pc_dump(int pc) diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index a658044..1fd7665 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -291,7 +291,8 @@ static void blit(const char *fps, const char *notice) { int emu_opt = currentConfig.EmuOpt; - if (PicoOpt&0x10) { + if (PicoOpt&0x10) + { // 8bit fast renderer if (Pico.m.dirtyPal) { Pico.m.dirtyPal = 0; @@ -299,8 +300,14 @@ static void blit(const char *fps, const char *notice) // feed new palette to our device gp2x_video_setpalette(localPal, 0x40); } + // a hack for VR + if (PicoRead16Hook == PicoSVPRead16) + memset32((int *)(PicoDraw2FB+328*8+328*223), 0xe0e0e0e0, 328); + // do actual copy vidCpyM2((unsigned char *)gp2x_screen+320*8, PicoDraw2FB+328*8); - } else if (!(emu_opt&0x80)) { + } + else if (!(emu_opt&0x80)) + { // 8bit accurate renderer if (Pico.m.dirtyPal) { Pico.m.dirtyPal = 0; diff --git a/platform/linux/Makefile b/platform/linux/Makefile index 4957a50..19e8823 100644 --- a/platform/linux/Makefile +++ b/platform/linux/Makefile @@ -96,7 +96,9 @@ PicoDrive : $(OBJS) ../common/helix/helix_mp3_x86.a mkdirs: mkdir -p $(DIRS) -Pico/carthw/svp/compiler.o : Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c +Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/gen_arm.c + +Pico/Pico.o : ../../Pico/PicoFrameHints.c ../../cpu/musashi/m68kops.c : @make -C ../../cpu/musashi -- 2.39.2