From 2b8524d11e5d8fab33ec5d88ca6520f76246a023 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 8 Nov 2020 08:43:24 -0500 Subject: [PATCH] sms: CPORT_CTL is write-only! why did I think that I could read from it? --- arch/z80/sms/blk/625 | 13 +++++++------ arch/z80/sms/blk/626 | 8 ++++---- arch/z80/sms/xcomp.fs | 3 ++- arch/z80/sms/xcompkbd.fs | 3 ++- arch/z80/sms/xcompsdc.fs | 3 ++- emul/z80/sms.c | 7 +------ emul/z80/sms_ports.c | 5 ----- emul/z80/sms_ports.h | 1 - 8 files changed, 18 insertions(+), 25 deletions(-) diff --git a/arch/z80/sms/blk/625 b/arch/z80/sms/blk/625 index ece50a1..970cf69 100644 --- a/arch/z80/sms/blk/625 +++ b/arch/z80/sms/blk/625 @@ -1,15 +1,16 @@ ( Routines for interacting with SMS controller ports. - Requires CPORT_CTL, CPORT_D1 and CPORT_D2 to be defined. - Will usually be 0x3f, 0xdc, 0xdd. ) + Requires CPORT_MEM, CPORT_CTL, CPORT_D1 and CPORT_D2 to be + defined. CPORT_MEM is a 1 byte buffer for CPORT_CTL. The last + 3 consts will usually be 0x3f, 0xdc, 0xdd. ) ( mode -- set TR pin on mode a on: 0= output low 1=output high 2=input ) CODE _TRA! HL POP, chkPS, ( B0 -> B4, B1 -> B0 ) L RR, RLA, RLA, RLA, RLA, L RR, RLA, - 0x11 ANDi, L A LDrr, CPORT_CTL INAi, - 0xee ANDi, L ORr, CPORT_CTL OUTiA, + 0x11 ANDi, L A LDrr, CPORT_MEM LDA(i), + 0xee ANDi, L ORr, CPORT_CTL OUTiA, CPORT_MEM LD(i)A, ;CODE CODE _THA! HL POP, chkPS, ( B0 -> B5, B1 -> B1 ) L RR, RLA, RLA, RLA, RLA, L RR, RLA, RLA, - 0x22 ANDi, L A LDrr, CPORT_CTL INAi, - 0xdd ANDi, L ORr, CPORT_CTL OUTiA, + 0x22 ANDi, L A LDrr, CPORT_MEM LDA(i), + 0xdd ANDi, L ORr, CPORT_CTL OUTiA, CPORT_MEM LD(i)A, ;CODE diff --git a/arch/z80/sms/blk/626 b/arch/z80/sms/blk/626 index 8d9c2d6..c7f9d10 100644 --- a/arch/z80/sms/blk/626 +++ b/arch/z80/sms/blk/626 @@ -1,12 +1,12 @@ CODE _TRB! HL POP, chkPS, ( B0 -> B6, B1 -> B2 ) L RR, RLA, RLA, RLA, RLA, L RR, RLA, RLA, RLA, - 0x44 ANDi, L A LDrr, CPORT_CTL INAi, - 0xbb ANDi, L ORr, CPORT_CTL OUTiA, + 0x44 ANDi, L A LDrr, CPORT_MEM LDA(i), + 0xbb ANDi, L ORr, CPORT_CTL OUTiA, CPORT_MEM LD(i)A, ;CODE CODE _THB! HL POP, chkPS, ( B0 -> B7, B1 -> B3 ) L RR, RLA, RLA, RLA, RLA, L RR, RLA, RLA, RLA, RLA, - 0x88 ANDi, L A LDrr, CPORT_CTL INAi, - 0x77 ANDi, L ORr, CPORT_CTL OUTiA, + 0x88 ANDi, L A LDrr, CPORT_MEM LDA(i), + 0x77 ANDi, L ORr, CPORT_CTL OUTiA, CPORT_MEM LD(i)A, ;CODE CODE _D1@ CPORT_D1 INAi, PUSHA, ;CODE CODE _D2@ CPORT_D2 INAi, PUSHA, ;CODE diff --git a/arch/z80/sms/xcomp.fs b/arch/z80/sms/xcomp.fs index 2f7f2a7..7dd3d04 100644 --- a/arch/z80/sms/xcomp.fs +++ b/arch/z80/sms/xcomp.fs @@ -9,10 +9,11 @@ SYSVARS 0x70 + CONSTANT VDP_MEM 0xbe CONSTANT VDP_DATAPORT 32 CONSTANT VDP_COLS 24 CONSTANT VDP_ROWS -SYSVARS 0x72 + CONSTANT PAD_MEM +SYSVARS 0x72 + CONSTANT CPORT_MEM 0x3f CONSTANT CPORT_CTL 0xdc CONSTANT CPORT_D1 0xdd CONSTANT CPORT_D2 +SYSVARS 0x73 + CONSTANT PAD_MEM 5 LOAD ( z80 assembler ) : ZFILL, ( u ) 0 DO 0 A, LOOP ; 262 LOAD ( xcomp ) diff --git a/arch/z80/sms/xcompkbd.fs b/arch/z80/sms/xcompkbd.fs index d708b20..6b5e833 100644 --- a/arch/z80/sms/xcompkbd.fs +++ b/arch/z80/sms/xcompkbd.fs @@ -10,10 +10,11 @@ SYSVARS 0x70 + CONSTANT VDP_MEM 0xbe CONSTANT VDP_DATAPORT 32 CONSTANT VDP_COLS 24 CONSTANT VDP_ROWS -SYSVARS 0x72 + CONSTANT PS2_MEM +SYSVARS 0x72 + CONSTANT CPORT_MEM 0x3f CONSTANT CPORT_CTL 0xdc CONSTANT CPORT_D1 0xdd CONSTANT CPORT_D2 +SYSVARS 0x73 + CONSTANT PS2_MEM 5 LOAD ( z80 assembler ) : ZFILL, ( u ) 0 DO 0 A, LOOP ; 262 LOAD ( xcomp ) diff --git a/arch/z80/sms/xcompsdc.fs b/arch/z80/sms/xcompsdc.fs index 27a17b2..ead098a 100644 --- a/arch/z80/sms/xcompsdc.fs +++ b/arch/z80/sms/xcompsdc.fs @@ -11,10 +11,11 @@ SYSVARS 0x70 + CONSTANT VDP_MEM 0xbe CONSTANT VDP_DATAPORT 32 CONSTANT VDP_COLS 24 CONSTANT VDP_ROWS -SYSVARS 0x72 + CONSTANT PS2_MEM +SYSVARS 0x72 + CONSTANT CPORT_MEM 0x3f CONSTANT CPORT_CTL 0xdc CONSTANT CPORT_D1 0xdd CONSTANT CPORT_D2 +SYSVARS 0x73 + CONSTANT PS2_MEM 5 LOAD ( z80 assembler ) : ZFILL, ( u ) 0 DO 0 A, LOOP ; 262 LOAD ( xcomp ) diff --git a/emul/z80/sms.c b/emul/z80/sms.c index 48215c7..23b31d6 100644 --- a/emul/z80/sms.c +++ b/emul/z80/sms.c @@ -76,11 +76,6 @@ static uint8_t iord_kbd() return kbd_rd(&kbd); } -static uint8_t iord_ports_ctl() -{ - return ports_ctl_rd(&ports); -} - static void iowr_vdp_cmd(uint8_t val) { vdp_cmd_wr(&vdp, val); @@ -362,7 +357,7 @@ int main(int argc, char *argv[]) m->iord[VDP_DATA_PORT] = iord_vdp_data; m->iord[PORTS_IO1_PORT] = iord_ports_io1; m->iord[PORTS_IO2_PORT] = iord_ports_io2; - m->iord[PORTS_CTL_PORT] = iord_ports_ctl; + m->iord[PORTS_CTL_PORT] = iord_noop; m->iowr[VDP_CMD_PORT] = iowr_vdp_cmd; m->iowr[VDP_DATA_PORT] = iowr_vdp_data; m->iowr[PORTS_CTL_PORT] = iowr_ports_ctl; diff --git a/emul/z80/sms_ports.c b/emul/z80/sms_ports.c index e0936ff..c827364 100644 --- a/emul/z80/sms_ports.c +++ b/emul/z80/sms_ports.c @@ -9,11 +9,6 @@ void ports_init(Ports *ports) ports->THB = TRI_HIGHZ; } -uint8_t ports_ctl_rd(Ports *ports) -{ - return ports->ctl; -} - void ports_ctl_wr(Ports *ports, uint8_t val) { ports->ctl = val; diff --git a/emul/z80/sms_ports.h b/emul/z80/sms_ports.h index 6c62737..a8ef094 100644 --- a/emul/z80/sms_ports.h +++ b/emul/z80/sms_ports.h @@ -15,7 +15,6 @@ typedef struct { } Ports; void ports_init(Ports *ports); -uint8_t ports_ctl_rd(Ports *ports); void ports_ctl_wr(Ports *ports, uint8_t val); uint8_t ports_A_rd(Ports *ports); uint8_t ports_B_rd(Ports *ports);