| 1 | #include "../pico_int.h" |
| 2 | #include "../sound/ym2612.h" |
| 3 | |
| 4 | struct Pico32x Pico32x; |
| 5 | |
| 6 | void Pico32xStartup(void) |
| 7 | { |
| 8 | elprintf(EL_STATUS|EL_32X, "32X startup"); |
| 9 | |
| 10 | PicoAHW |= PAHW_32X; |
| 11 | PicoMemSetup32x(); |
| 12 | |
| 13 | sh2_init(&msh2); |
| 14 | sh2_reset(&msh2); |
| 15 | |
| 16 | sh2_init(&ssh2); |
| 17 | sh2_reset(&ssh2); |
| 18 | |
| 19 | if (!Pico.m.pal) |
| 20 | Pico32x.vdp_regs[0] |= P32XV_nPAL; |
| 21 | |
| 22 | emu_32x_startup(); |
| 23 | } |
| 24 | |
| 25 | void Pico32xInit(void) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | void PicoPower32x(void) |
| 30 | { |
| 31 | memset(&Pico32x, 0, sizeof(Pico32x)); |
| 32 | |
| 33 | Pico32x.regs[0] = 0x0082; // SH2 reset? |
| 34 | Pico32x.vdp_regs[0x0a/2] = P32XV_VBLK|P32XV_HBLK|P32XV_PEN; |
| 35 | } |
| 36 | |
| 37 | void PicoUnload32x(void) |
| 38 | { |
| 39 | if (Pico32xMem != NULL) |
| 40 | free(Pico32xMem); |
| 41 | Pico32xMem = NULL; |
| 42 | |
| 43 | PicoAHW &= ~PAHW_32X; |
| 44 | } |
| 45 | |
| 46 | void PicoReset32x(void) |
| 47 | { |
| 48 | extern int p32x_csum_faked; |
| 49 | p32x_csum_faked = 0; // tmp |
| 50 | } |
| 51 | |
| 52 | static void p32x_start_blank(void) |
| 53 | { |
| 54 | // enter vblank |
| 55 | Pico32x.vdp_regs[0x0a/2] |= P32XV_VBLK|P32XV_PEN; |
| 56 | |
| 57 | // swap waits until vblank |
| 58 | if ((Pico32x.vdp_regs[0x0a/2] ^ Pico32x.pending_fb) & P32XV_FS) { |
| 59 | Pico32x.vdp_regs[0x0a/2] &= ~P32XV_FS; |
| 60 | Pico32x.vdp_regs[0x0a/2] |= Pico32x.pending_fb; |
| 61 | Pico32xSwapDRAM(Pico32x.pending_fb ^ 1); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // FIXME.. |
| 66 | static __inline void SekRunM68k(int cyc) |
| 67 | { |
| 68 | int cyc_do; |
| 69 | SekCycleAim+=cyc; |
| 70 | if ((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return; |
| 71 | #if defined(EMU_CORE_DEBUG) |
| 72 | // this means we do run-compare |
| 73 | SekCycleCnt+=CM_compareRun(cyc_do, 0); |
| 74 | #elif defined(EMU_C68K) |
| 75 | PicoCpuCM68k.cycles=cyc_do; |
| 76 | CycloneRun(&PicoCpuCM68k); |
| 77 | SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles; |
| 78 | #elif defined(EMU_M68K) |
| 79 | SekCycleCnt+=m68k_execute(cyc_do); |
| 80 | #elif defined(EMU_F68K) |
| 81 | SekCycleCnt+=fm68k_emulate(cyc_do+1, 0, 0); |
| 82 | #endif |
| 83 | } |
| 84 | |
| 85 | // ~1463.8, but due to cache misses and slow mem |
| 86 | // it's much lower than that |
| 87 | #define SH2_LINE_CYCLES 700 |
| 88 | |
| 89 | #define PICO_32X |
| 90 | #define RUN_SH2S \ |
| 91 | if (!(Pico32x.emu_flags & P32XF_MSH2POLL)) \ |
| 92 | sh2_execute(&msh2, SH2_LINE_CYCLES); |
| 93 | |
| 94 | #include "../pico_cmn.c" |
| 95 | |
| 96 | void PicoFrame32x(void) |
| 97 | { |
| 98 | if ((Pico32x.vdp_regs[0] & 3 ) != 0) // no forced blanking |
| 99 | Pico32x.vdp_regs[0x0a/2] &= ~(P32XV_VBLK|P32XV_PEN); // get out of vblank |
| 100 | |
| 101 | PicoFrameStart(); |
| 102 | PicoFrameHints(); |
| 103 | } |