\r
// VDP area (0xc00000 - 0xdfffff)\r
// TODO: verify if lower byte goes to PSG on word writes\r
-static u32 PicoRead8_vdp(u32 a)\r
+u32 PicoRead8_vdp(u32 a)\r
{\r
- if ((a & 0x00e0) == 0x0000)\r
- return PicoVideoRead8(a);\r
+ if ((a & 0x00f0) == 0x0000) {\r
+ switch (a & 0x0d)\r
+ {\r
+ case 0x00: return PicoVideoRead8DataH();\r
+ case 0x01: return PicoVideoRead8DataL();\r
+ case 0x04: return PicoVideoRead8CtlH();\r
+ case 0x05: return PicoVideoRead8CtlL();\r
+ case 0x08:\r
+ case 0x0c: return PicoVideoRead8HV_H();\r
+ case 0x09:\r
+ case 0x0d: return PicoVideoRead8HV_L();\r
+ }\r
+ }\r
\r
elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc);\r
return 0;\r
\r
static unsigned char z80_md_vdp_read(unsigned short a)\r
{\r
- if ((a & 0x00e0) == 0x0000)\r
- return PicoVideoRead8(a); // FIXME: depends on 68k cycles\r
+ if ((a & 0x00f0) == 0x0000) {\r
+ switch (a & 0x0d)\r
+ {\r
+ case 0x00: return PicoVideoRead8DataH();\r
+ case 0x01: return PicoVideoRead8DataL();\r
+ case 0x04: return PicoVideoRead8CtlH();\r
+ case 0x05: return PicoVideoRead8CtlL();\r
+ case 0x08:\r
+ case 0x0c: return get_scanline(1); // FIXME: make it proper\r
+ case 0x09:\r
+ case 0x0d: return Pico.m.rotate++;\r
+ }\r
+ }\r
\r
elprintf(EL_ANOMALY, "z80 invalid r8 [%06x] %02x", a, 0xff);\r
return 0xff;\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
-PICO_INTERNAL_ASM unsigned int PicoVideoRead8(unsigned int a);\r
+unsigned char PicoVideoRead8DataH(void);\r
+unsigned char PicoVideoRead8DataL(void);\r
+unsigned char PicoVideoRead8CtlH(void);\r
+unsigned char PicoVideoRead8CtlL(void);\r
+unsigned char PicoVideoRead8HV_H(void);\r
+unsigned char PicoVideoRead8HV_L(void);\r
extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask);\r
\r
// misc.c\r
return 0;\r
}\r
\r
-unsigned int PicoVideoRead8(unsigned int a)\r
+unsigned char PicoVideoRead8DataH(void)\r
{\r
- unsigned int d;\r
- a&=0x1d;\r
+ return VideoRead() >> 8;\r
+}\r
\r
- switch (a)\r
- {\r
- case 0: return VideoRead() >> 8;\r
- case 1: return VideoRead() & 0xff;\r
- case 4: // control port/status reg\r
- d = Pico.video.status >> 8;\r
- if (d&1) Pico.video.status&=~0x100; // FIFO no longer full\r
- Pico.video.pending = 0;\r
- elprintf(EL_SR, "SR read (h): %02x @ %06x", d, SekPc);\r
- return d;\r
- case 5:\r
- d = Pico.video.status & 0xff;\r
- //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)\r
- d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled\r
- d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending?\r
- if (SekCyclesDone() - line_base_cycles >= 488-88) d |= 4; // H-Blank\r
- Pico.video.pending = 0;\r
- elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc);\r
- return d;\r
- case 8: // hv counter\r
- elprintf(EL_HVCNT, "vcounter: %02x (%i) @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc);\r
- return Pico.video.v_counter;\r
- case 9:\r
- d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME\r
- if (Pico.video.reg[12]&1)\r
- d = hcounts_40[d];\r
- else d = hcounts_32[d];\r
- elprintf(EL_HVCNT, "hcounter: %02x (%i) @ %06x", d, SekCyclesDone(), SekPc);\r
- return d;\r
- }\r
+unsigned char PicoVideoRead8DataL(void)\r
+{\r
+ return VideoRead();\r
+}\r
\r
- return 0;\r
+// FIXME: broken mess\r
+unsigned char PicoVideoRead8CtlH(void)\r
+{\r
+ u8 d = (u8)(Pico.video.status >> 8);\r
+ if (d & 1)\r
+ Pico.video.status &= ~0x100; // FIFO no longer full\r
+ Pico.video.pending = 0;\r
+ elprintf(EL_SR, "SR read (h): %02x @ %06x", d, SekPc);\r
+ return d;\r
+}\r
+\r
+unsigned char PicoVideoRead8CtlL(void)\r
+{\r
+ u8 d = (u8)Pico.video.status;\r
+ //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)\r
+ d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled\r
+ d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending?\r
+ if (SekCyclesDone() - line_base_cycles >= 488-88) d |= 4; // H-Blank\r
+ Pico.video.pending = 0;\r
+ elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc);\r
+ return d;\r
+}\r
+\r
+unsigned char PicoVideoRead8HV_H(void)\r
+{\r
+ elprintf(EL_HVCNT, "vcounter: %02x (%i) @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc);\r
+ return Pico.video.v_counter;\r
+}\r
+\r
+// FIXME: broken\r
+unsigned char PicoVideoRead8HV_L(void)\r
+{\r
+ u32 d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME\r
+ if (Pico.video.reg[12]&1)\r
+ d = hcounts_40[d];\r
+ else d = hcounts_32[d];\r
+ elprintf(EL_HVCNT, "hcounter: %02x (%i) @ %06x", d, SekCyclesDone(), SekPc);\r
+ return d;\r
}\r
\r
// vim:shiftwidth=2:ts=2:expandtab\r