32x: packed pixel mode (works over 68k)
[picodrive.git] / pico / 32x / 32x.c
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   if (!Pico.m.pal)
14     Pico32x.vdp_regs[0] |= P32XV_nPAL;
15
16   emu_32x_startup();
17 }
18
19 void Pico32xInit(void)
20 {
21 }
22
23 void PicoPower32x(void)
24 {
25   memset(&Pico32x, 0, sizeof(Pico32x));
26   Pico32x.regs[0] = 0x0082; // SH2 reset?
27   Pico32x.vdp_regs[0x0a/2] = P32XV_VBLK|P32XV_HBLK|P32XV_PEN;
28 }
29
30 void PicoReset32x(void)
31 {
32 }
33
34 static void p32x_start_blank(void)
35 {
36   // enter vblank
37   Pico32x.vdp_regs[0x0a/2] |= P32XV_VBLK|P32XV_PEN;
38
39   // swap waits until vblank
40   if ((Pico32x.vdp_regs[0x0a/2] ^ Pico32x.pending_fb) & P32XV_FS) {
41     Pico32x.vdp_regs[0x0a/2] &= ~P32XV_FS;
42     Pico32x.vdp_regs[0x0a/2] |= Pico32x.pending_fb;
43     Pico32xSwapDRAM(Pico32x.pending_fb ^ 1);
44   }
45 }
46
47 // FIXME..
48 static __inline void SekRunM68k(int cyc)
49 {
50   int cyc_do;
51   SekCycleAim+=cyc;
52   if ((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return;
53 #if defined(EMU_CORE_DEBUG)
54   // this means we do run-compare
55   SekCycleCnt+=CM_compareRun(cyc_do, 0);
56 #elif defined(EMU_C68K)
57   PicoCpuCM68k.cycles=cyc_do;
58   CycloneRun(&PicoCpuCM68k);
59   SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles;
60 #elif defined(EMU_M68K)
61   SekCycleCnt+=m68k_execute(cyc_do);
62 #elif defined(EMU_F68K)
63   SekCycleCnt+=fm68k_emulate(cyc_do+1, 0, 0);
64 #endif
65 }
66
67 #define PICO_32X
68 #include "../pico_cmn.c"
69
70 void PicoFrame32x(void)
71 {
72   if ((Pico32x.vdp_regs[0] & 3 ) != 0) // no forced blanking
73     Pico32x.vdp_regs[0x0a/2] &= ~(P32XV_VBLK|P32XV_PEN); // get out of vblank
74
75   PicoFrameStart();
76   PicoFrameHints();
77 }