split memories away from Pico
[picodrive.git] / pico / pico_int.h
index 89cccc7..765afaf 100644 (file)
@@ -128,26 +128,18 @@ extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k;
 #endif\r
 #endif // EMU_M68K\r
 \r
-// while running, cnt represents target of current timeslice\r
-// while not in SekRun(), it's actual cycles done\r
-// (but always use SekCyclesDone() if you need current position)\r
-// cnt may change if timeslice is ended prematurely or extended,\r
-// so we use SekCycleAim for the actual target\r
-extern unsigned int SekCycleCnt;\r
-extern unsigned int SekCycleAim;\r
-\r
 // number of cycles done (can be checked anywhere)\r
-#define SekCyclesDone()  (SekCycleCnt - SekCyclesLeft)\r
+#define SekCyclesDone()  (Pico.t.m68c_cnt - SekCyclesLeft)\r
 \r
 // burn cycles while not in SekRun() and while in\r
-#define SekCyclesBurn(c)    SekCycleCnt += c\r
+#define SekCyclesBurn(c)    Pico.t.m68c_cnt += c\r
 #define SekCyclesBurnRun(c) { \\r
   SekCyclesLeft -= c; \\r
 }\r
 \r
 // note: sometimes may extend timeslice to delay an irq\r
 #define SekEndRun(after) { \\r
-  SekCycleCnt -= SekCyclesLeft - (after); \\r
+  Pico.t.m68c_cnt -= SekCyclesLeft - (after); \\r
   SekCyclesLeft = after; \\r
 }\r
 \r
@@ -212,10 +204,10 @@ extern struct DrZ80 drZ80;
 #define Z80_STATE_SIZE 0x60\r
 \r
 #define z80_resetCycles() \\r
-  timing.z80c_cnt = timing.z80c_aim = timing.z80_scanline = 0\r
+  Pico.t.z80c_cnt = Pico.t.z80c_aim = Pico.t.z80_scanline = 0\r
 \r
 #define z80_cyclesDone() \\r
-  (timing.z80c_aim - z80_cyclesLeft)\r
+  (Pico.t.z80c_aim - z80_cyclesLeft)\r
 \r
 #define cycles_68k_to_z80(x) ((x) * 3823 >> 13)\r
 \r
@@ -359,15 +351,16 @@ struct PicoEState
   void *DrawLineDest;          // draw destination\r
   unsigned char *HighCol;\r
   int *HighPreSpr;\r
-  void *Pico_video;\r
-  void *Pico_vram;\r
+  struct Pico *Pico;\r
+  void *PicoMem_vram;\r
+  void *PicoMem_cram;\r
   int  *PicoOpt;\r
   unsigned char *Draw2FB;\r
   unsigned short HighPal[0x100];\r
 };\r
 \r
-// some assembly stuff depend on these, do not touch!\r
-struct Pico\r
+// some assembly stuff still depends on these, do not touch!\r
+struct PicoMem\r
 {\r
   unsigned char ram[0x10000];  // 0x00000 scratch ram\r
   union {                      // vram is byteswapped for easier reads when drawing\r
@@ -379,14 +372,6 @@ struct Pico
   unsigned char pad[0xf0];     // unused\r
   unsigned short cram[0x40];   // 0x22100\r
   unsigned short vsram[0x40];  // 0x22180\r
-\r
-  unsigned char *rom;          // 0x22200\r
-  unsigned int romsize;        // 0x22204 (on 32bits)\r
-\r
-  struct PicoMisc m;\r
-  struct PicoVideo video;\r
-  struct PicoMS ms;\r
-  struct PicoEState est;\r
 };\r
 \r
 // sram\r
@@ -396,7 +381,7 @@ struct Pico
 #define SRF_ENABLED  (1 << 0)\r
 #define SRF_EEPROM   (1 << 1)\r
 \r
-struct PicoSRAM\r
+struct PicoCartSave\r
 {\r
   unsigned char *data;         // actual data\r
   unsigned int start;          // start address in 68k address space\r
@@ -412,6 +397,38 @@ struct PicoSRAM
   unsigned int size;\r
 };\r
 \r
+struct PicoTiming\r
+{\r
+  // while running, cnt represents target of current timeslice\r
+  // while not in SekRun(), it's actual cycles done\r
+  // (but always use SekCyclesDone() if you need current position)\r
+  // _cnt may change if timeslice is ended prematurely or extended,\r
+  // so we use _aim for the actual target\r
+  unsigned int m68c_cnt;\r
+  unsigned int m68c_aim;\r
+  unsigned int m68c_frame_start;        // m68k cycles\r
+  unsigned int m68c_line_start;\r
+\r
+  unsigned int z80c_cnt;                // z80 cycles done (this frame)\r
+  unsigned int z80c_aim;\r
+  int z80_scanline;\r
+};\r
+\r
+// run tools/mkoffsets pico/pico_int_o32.h if you change these\r
+// careful with savestate compat\r
+struct Pico\r
+{\r
+  struct PicoVideo video;\r
+  struct PicoMisc m;\r
+  struct PicoTiming t;\r
+  struct PicoCartSave sv;\r
+  struct PicoEState est;\r
+  struct PicoMS ms;\r
+\r
+  unsigned char *rom;\r
+  unsigned int romsize;\r
+};\r
+\r
 // MCD\r
 #define PCM_MIXBUF_LEN ((12500000 / 384) / 50 + 1)\r
 \r
@@ -592,15 +609,6 @@ struct Pico32xMem
   unsigned short pwm_fifo[2][4];        // [0] - current raw, others - fifo entries\r
 };\r
 \r
-struct PicoTiming\r
-{\r
-  unsigned int m68c_frame_start;        // m68k cycles\r
-  unsigned int z80c_cnt;                // z80 cycles done (this frame)\r
-  unsigned int z80c_aim;\r
-  int z80_scanline;\r
-};\r
-extern struct PicoTiming timing;\r
-\r
 // area.c\r
 extern void (*PicoLoadStateHook)(void);\r
 \r
@@ -699,7 +707,7 @@ void pcd_state_loaded_mem(void);
 \r
 // pico.c\r
 extern struct Pico Pico;\r
-extern struct PicoSRAM SRam;\r
+extern struct PicoMem PicoMem;\r
 extern int PicoPadInt[2];\r
 extern int emustatus;\r
 extern void (*PicoResetHook)(void);\r
@@ -809,7 +817,6 @@ void ym2612_unpack_state(void);
 \r
 \r
 // videoport.c\r
-extern int line_base_cycles;\r
 PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);\r
 PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);\r
 unsigned char PicoVideoRead8DataH(void);\r
@@ -898,7 +905,7 @@ void p32x_event_schedule_sh2(SH2 *sh2, enum p32x_event event, int after);
 void p32x_schedule_hint(SH2 *sh2, int m68k_cycles);\r
 \r
 // 32x/memory.c\r
-struct Pico32xMem *Pico32xMem;\r
+extern struct Pico32xMem *Pico32xMem;\r
 unsigned int PicoRead8_32x(unsigned int a);\r
 unsigned int PicoRead16_32x(unsigned int a);\r
 void PicoWrite8_32x(unsigned int a, unsigned int d);\r