# HG changeset patch # User Michael Pavone # Date 1483513410 28800 # Node ID 80ef49539550559bd240bfeda936bbd908f8536d # Parent 06468b25a54373f6fc73a5b65afba5493e4e1a21 Fix reading from second controller port in SMS mode diff -r 06468b25a543 -r 80ef49539550 sms.c --- a/sms.c Tue Jan 03 21:37:36 2017 -0800 +++ b/sms.c Tue Jan 03 23:03:30 2017 -0800 @@ -86,12 +86,12 @@ sms_context *sms = z80->system; if (location == 0xC0 || location == 0xDC) { uint8_t port_a = io_data_read(sms->io.ports, z80->current_cycle); - uint8_t port_b = io_data_read(sms->io.ports, z80->current_cycle); + uint8_t port_b = io_data_read(sms->io.ports+1, z80->current_cycle); return (port_a & 0x3F) | (port_b << 6); } if (location == 0xC1 || location == 0xDD) { uint8_t port_a = io_data_read(sms->io.ports, z80->current_cycle); - uint8_t port_b = io_data_read(sms->io.ports, z80->current_cycle); + uint8_t port_b = io_data_read(sms->io.ports+1, z80->current_cycle); return (port_a & 0x40) | (port_b >> 2 & 0xF) | (port_b << 1 & 0x80) | 0x10; } return 0xFF;