# HG changeset patch # User Michael Pavone # Date 1642579681 28800 # Node ID 27bbfcb7850a4dc0c8f7c90050ce2cc9892b89fb # Parent c4d066d798c401659f432a069d4a8790aebcc44c Fix byte write behavior on a few gate array regs to pass the VAR test in mcd-verificator diff -r c4d066d798c4 -r 27bbfcb7850a segacd.c --- a/segacd.c Tue Jan 18 23:54:02 2022 -0800 +++ b/segacd.c Wed Jan 19 00:08:01 2022 -0800 @@ -377,10 +377,22 @@ segacd_context *cd = m68k->system; uint32_t reg = (address & 0x1FF) >> 1; uint16_t value16; - if (address & 1) { - value16 = cd->gate_array[reg] & 0xFF00 | value; - } else { - value16 = cd->gate_array[reg] & 0xFF | (value << 8); + switch (address >> 1) + { + case GA_CDC_HOST_DATA: + case GA_CDC_DMA_ADDR: + case GA_STOP_WATCH: + case GA_COMM_FLAG: + case GA_CDD_FADER: + //these registers treat all writes as word-wide + value16 = value | (value << 8); + break; + default: + if (address & 1) { + value16 = cd->gate_array[reg] & 0xFF00 | value; + } else { + value16 = cd->gate_array[reg] & 0xFF | (value << 8); + } } return sub_gate_write16(address, vcontext, value16); } @@ -588,10 +600,19 @@ segacd_context *cd = gen->expansion; uint32_t reg = (address & 0x1FF) >> 1; uint16_t value16; - if (address & 1) { - value16 = cd->gate_array[reg] & 0xFF00 | value; - } else { - value16 = cd->gate_array[reg] & 0xFF | (value << 8); + switch (reg >> 1) + { + case GA_HINT_VECTOR: + case GA_COMM_FLAG: + //writes to these regs are always treated as word wide + value16 = value | (value << 8); + break; + default: + if (address & 1) { + value16 = cd->gate_array[reg] & 0xFF00 | value; + } else { + value16 = cd->gate_array[reg] & 0xFF | (value << 8); + } } return main_gate_write16(address, vcontext, value16); }