slightly better z80 vdp reads

This commit is contained in:
notaz 2017-10-01 00:59:44 +03:00
parent 12f89605e3
commit 75b84e4b7c
4 changed files with 79 additions and 41 deletions

View file

@ -703,10 +703,21 @@ void PicoWrite16_io(u32 a, u32 d)
// VDP area (0xc00000 - 0xdfffff) // VDP area (0xc00000 - 0xdfffff)
// TODO: verify if lower byte goes to PSG on word writes // TODO: verify if lower byte goes to PSG on word writes
static u32 PicoRead8_vdp(u32 a) u32 PicoRead8_vdp(u32 a)
{ {
if ((a & 0x00e0) == 0x0000) if ((a & 0x00f0) == 0x0000) {
return PicoVideoRead8(a); switch (a & 0x0d)
{
case 0x00: return PicoVideoRead8DataH();
case 0x01: return PicoVideoRead8DataL();
case 0x04: return PicoVideoRead8CtlH();
case 0x05: return PicoVideoRead8CtlL();
case 0x08:
case 0x0c: return PicoVideoRead8HV_H();
case 0x09:
case 0x0d: return PicoVideoRead8HV_L();
}
}
elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc); elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc);
return 0; return 0;
@ -1184,8 +1195,19 @@ void PicoWrite16_32x(u32 a, u32 d) {}
static unsigned char z80_md_vdp_read(unsigned short a) static unsigned char z80_md_vdp_read(unsigned short a)
{ {
if ((a & 0x00e0) == 0x0000) if ((a & 0x00f0) == 0x0000) {
return PicoVideoRead8(a); // FIXME: depends on 68k cycles switch (a & 0x0d)
{
case 0x00: return PicoVideoRead8DataH();
case 0x01: return PicoVideoRead8DataL();
case 0x04: return PicoVideoRead8CtlH();
case 0x05: return PicoVideoRead8CtlL();
case 0x08:
case 0x0c: return get_scanline(1); // FIXME: make it proper
case 0x09:
case 0x0d: return Pico.m.rotate++;
}
}
elprintf(EL_ANOMALY, "z80 invalid r8 [%06x] %02x", a, 0xff); elprintf(EL_ANOMALY, "z80 invalid r8 [%06x] %02x", a, 0xff);
return 0xff; return 0xff;

View file

@ -468,7 +468,7 @@ m_read8_vdp:
or $t0, $t1 or $t0, $t1
bnez $t0, m_read_null # invalid address bnez $t0, m_read_null # invalid address
nop nop
j PicoVideoRead8 j PicoRead8_vdp
nop nop
m_read8_ram: m_read8_ram:

View file

@ -793,7 +793,12 @@ void ym2612_unpack_state(void);
extern int line_base_cycles; extern int line_base_cycles;
PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d); PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d);
PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a); PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a);
PICO_INTERNAL_ASM unsigned int PicoVideoRead8(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);
extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask); extern int (*PicoDmaHook)(unsigned int source, int len, unsigned short **base, unsigned int *mask);
// misc.c // misc.c

View file

@ -563,23 +563,30 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a)
return 0; return 0;
} }
unsigned int PicoVideoRead8(unsigned int a) unsigned char PicoVideoRead8DataH(void)
{ {
unsigned int d; return VideoRead() >> 8;
a&=0x1d; }
switch (a) unsigned char PicoVideoRead8DataL(void)
{ {
case 0: return VideoRead() >> 8; return VideoRead();
case 1: return VideoRead() & 0xff; }
case 4: // control port/status reg
d = Pico.video.status >> 8; // FIXME: broken mess
if (d&1) Pico.video.status&=~0x100; // FIFO no longer full unsigned char PicoVideoRead8CtlH(void)
{
u8 d = (u8)(Pico.video.status >> 8);
if (d & 1)
Pico.video.status &= ~0x100; // FIFO no longer full
Pico.video.pending = 0; Pico.video.pending = 0;
elprintf(EL_SR, "SR read (h): %02x @ %06x", d, SekPc); elprintf(EL_SR, "SR read (h): %02x @ %06x", d, SekPc);
return d; return d;
case 5: }
d = Pico.video.status & 0xff;
unsigned char PicoVideoRead8CtlL(void)
{
u8 d = (u8)Pico.video.status;
//if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast) //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast)
d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled
d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending? d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending?
@ -587,19 +594,23 @@ unsigned int PicoVideoRead8(unsigned int a)
Pico.video.pending = 0; Pico.video.pending = 0;
elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc); elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc);
return d; return d;
case 8: // hv counter }
unsigned char PicoVideoRead8HV_H(void)
{
elprintf(EL_HVCNT, "vcounter: %02x (%i) @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc); elprintf(EL_HVCNT, "vcounter: %02x (%i) @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc);
return Pico.video.v_counter; return Pico.video.v_counter;
case 9: }
d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME
// FIXME: broken
unsigned char PicoVideoRead8HV_L(void)
{
u32 d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME
if (Pico.video.reg[12]&1) if (Pico.video.reg[12]&1)
d = hcounts_40[d]; d = hcounts_40[d];
else d = hcounts_32[d]; else d = hcounts_32[d];
elprintf(EL_HVCNT, "hcounter: %02x (%i) @ %06x", d, SekCyclesDone(), SekPc); elprintf(EL_HVCNT, "hcounter: %02x (%i) @ %06x", d, SekCyclesDone(), SekPc);
return d; return d;
}
return 0;
} }
// vim:shiftwidth=2:ts=2:expandtab // vim:shiftwidth=2:ts=2:expandtab