From 1613ec6c30039ee859b738280856f77576a8feae Mon Sep 17 00:00:00 2001 From: kub Date: Sat, 12 Dec 2020 17:27:30 +0100 Subject: [PATCH] vdp, kludge for z80 access --- pico/memory.c | 20 ++++++++++---------- pico/pico_int.h | 12 ++++++------ pico/videoport.c | 23 ++++++++++++----------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/pico/memory.c b/pico/memory.c index 65643cec..d497a702 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -696,14 +696,14 @@ u32 PicoRead8_vdp(u32 a) if ((a & 0x00f0) == 0x0000) { switch (a & 0x0d) { - case 0x00: return PicoVideoRead8DataH(); - case 0x01: return PicoVideoRead8DataL(); - case 0x04: return PicoVideoRead8CtlH(); - case 0x05: return PicoVideoRead8CtlL(); + case 0x00: return PicoVideoRead8DataH(0); + case 0x01: return PicoVideoRead8DataL(0); + case 0x04: return PicoVideoRead8CtlH(0); + case 0x05: return PicoVideoRead8CtlL(0); case 0x08: - case 0x0c: return PicoVideoRead8HV_H(); + case 0x0c: return PicoVideoRead8HV_H(0); case 0x09: - case 0x0d: return PicoVideoRead8HV_L(); + case 0x0d: return PicoVideoRead8HV_L(0); } } @@ -1195,10 +1195,10 @@ static unsigned char z80_md_vdp_read(unsigned short a) if ((a & 0x00f0) == 0x0000) { switch (a & 0x0d) { - case 0x00: return PicoVideoRead8DataH(); - case 0x01: return PicoVideoRead8DataL(); - case 0x04: return PicoVideoRead8CtlH(); - case 0x05: return PicoVideoRead8CtlL(); + case 0x00: return PicoVideoRead8DataH(1); + case 0x01: return PicoVideoRead8DataL(1); + case 0x04: return PicoVideoRead8CtlH(1); + case 0x05: return PicoVideoRead8CtlL(1); case 0x08: case 0x0c: return get_scanline(1); // FIXME: make it proper case 0x09: diff --git a/pico/pico_int.h b/pico/pico_int.h index ae9f2e11..f6ea29cb 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -864,12 +864,12 @@ static __inline void VideoWriteVRAM(u32 a, u16 d) PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d); PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a); -unsigned char PicoVideoRead8DataH(void); -unsigned char PicoVideoRead8DataL(void); -unsigned char PicoVideoRead8CtlH(void); -unsigned char PicoVideoRead8CtlL(void); -unsigned char PicoVideoRead8HV_H(void); -unsigned char PicoVideoRead8HV_L(void); +unsigned char PicoVideoRead8DataH(int is_from_z80); +unsigned char PicoVideoRead8DataL(int is_from_z80); +unsigned char PicoVideoRead8CtlH(int is_from_z80); +unsigned char PicoVideoRead8CtlL(int is_from_z80); +unsigned char PicoVideoRead8HV_H(int is_from_z80); +unsigned char PicoVideoRead8HV_L(int is_from_z80); extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask); void PicoVideoFIFOSync(int cycles); int PicoVideoFIFOHint(void); diff --git a/pico/videoport.c b/pico/videoport.c index c9221493..06cdccb9 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -362,13 +362,14 @@ static void VideoWrite(u16 d) AutoIncrement(); } -static unsigned int VideoRead(void) +static unsigned int VideoRead(int is_from_z80) { unsigned int a, d = VdpFIFO.fifo_data[(VdpFIFO.fifo_dx+1)&3]; a=Pico.video.addr; a>>=1; - SekCyclesBurnRun(PicoVideoFIFORead()); + if (!is_from_z80) + SekCyclesBurnRun(PicoVideoFIFORead()); switch (Pico.video.type) { case 0: d=PicoMem.vram [a & 0x7fff]; break; @@ -940,23 +941,23 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) if (a==0x00) // data port { - return VideoRead(); + return VideoRead(0); } return 0; } -unsigned char PicoVideoRead8DataH(void) +unsigned char PicoVideoRead8DataH(int is_from_z80) { - return VideoRead() >> 8; + return VideoRead(is_from_z80) >> 8; } -unsigned char PicoVideoRead8DataL(void) +unsigned char PicoVideoRead8DataL(int is_from_z80) { - return VideoRead(); + return VideoRead(is_from_z80); } -unsigned char PicoVideoRead8CtlH(void) +unsigned char PicoVideoRead8CtlH(int is_from_z80) { struct PicoVideo *pv = &Pico.video; u8 d = VideoSr(pv) >> 8; @@ -968,7 +969,7 @@ unsigned char PicoVideoRead8CtlH(void) return d; } -unsigned char PicoVideoRead8CtlL(void) +unsigned char PicoVideoRead8CtlL(int is_from_z80) { struct PicoVideo *pv = &Pico.video; u8 d = VideoSr(pv); @@ -980,14 +981,14 @@ unsigned char PicoVideoRead8CtlL(void) return d; } -unsigned char PicoVideoRead8HV_H(void) +unsigned char PicoVideoRead8HV_H(int is_from_z80) { elprintf(EL_HVCNT, "vcounter: %02x [%u] @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc); return Pico.video.v_counter; } // FIXME: broken -unsigned char PicoVideoRead8HV_L(void) +unsigned char PicoVideoRead8HV_L(int is_from_z80) { u32 d = (SekCyclesDone() - Pico.t.m68c_line_start) & 0x1ff; // FIXME if (Pico.video.reg[0]&2) -- 2.39.5