Skip to content

Commit

Permalink
sms, improve pad handling (TR as output)
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Jul 5, 2024
1 parent 13c9a48 commit 4af69a1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pico/sms.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,20 @@ static unsigned char z80_sms_in(unsigned short a)
break;

case 0xc0: /* I/O port A and B */
if (! (PicoIn.AHW & PAHW_SC) || (Pico.ms.io_sg & 7) == 7)
if (! (PicoIn.AHW & PAHW_SC) || (Pico.ms.io_sg & 7) == 7) {
d = ~((PicoIn.pad[0] & 0x3f) | (PicoIn.pad[1] << 6));
else
if (!(Pico.ms.io_ctl & 0x01)) // TR as output
d = (d & ~0x20) | ((Pico.ms.io_ctl << 1) & 0x20);
} else
; // read kbd 8 bits
break;

case 0xc1: /* I/O port B and miscellaneous */
if (! (PicoIn.AHW & PAHW_SC) || (Pico.ms.io_sg & 7) == 7) {
d = (Pico.ms.io_ctl & 0x80) | ((Pico.ms.io_ctl << 1) & 0x40) | 0x30;
d |= ~(PicoIn.pad[1] >> 2) & 0x0f;
if (!(Pico.ms.io_ctl & 0x04)) // TR as output
d = (d & ~0x08) | ((Pico.ms.io_ctl >> 3) & 0x08);
if (Pico.ms.io_ctl & 0x08) d |= 0x80; // TH as input is unconnected
if (Pico.ms.io_ctl & 0x02) d |= 0x40;
} else
Expand Down Expand Up @@ -309,6 +313,7 @@ static void write_bank_sega(unsigned short a, unsigned char d)

elprintf(EL_Z80BNK, "bank sega %04x %02x @ %04x", a, d, z80_pc());
Pico.ms.mapper = PMS_MAP_SEGA;
if (d == Pico.ms.carthw[a & 0x0f]) return;
Pico.ms.carthw[a & 0x0f] = d;

switch (a & 0x0f)
Expand Down Expand Up @@ -348,6 +353,7 @@ static void write_bank_codem(unsigned short a, unsigned char d)
if (Pico.ms.mapper != PMS_MAP_CODEM && (Pico.ms.mapper || (a>>14) == d)) return;
elprintf(EL_Z80BNK, "bank codem %04x %02x @ %04x", a, d, z80_pc());
Pico.ms.mapper = PMS_MAP_CODEM;
if (Pico.ms.carthw[a>>14] == d) return;
Pico.ms.carthw[a>>14] = d;

d &= bank_mask;
Expand Down Expand Up @@ -690,8 +696,9 @@ void PicoResetMS(void)

z80_reset();
PsndReset(); // pal must be known here

Pico.ms.io_ctl = (PicoIn.AHW & (PAHW_SG|PAHW_SC)) ? 0xf5 : 0xff;
Pico.ms.fm_ctl = 0xff;
Pico.m.dirtyPal = 1;

// reset memory mapping
PicoMemSetupMS();
Expand All @@ -708,6 +715,7 @@ void PicoResetMS(void)
Pico.video.reg[8] = 0x00;
Pico.video.reg[9] = 0x00;
Pico.video.reg[10] = 0xff;
Pico.m.dirtyPal = 1;

// BIOS, clear zram (unitialized on Mark-III, cf src/mame/drivers/sms.cpp)
i = !(PicoIn.AHW & PAHW_GG) && (Pico.m.hardware & PMS_HW_JAP) ? 0xf0 : 0x00;
Expand Down

0 comments on commit 4af69a1

Please sign in to comment.