From fa21e91ef5eebdbc334e4995054c7f2dd9f2973f Mon Sep 17 00:00:00 2001 From: retro-wertz Date: Thu, 27 Jun 2019 00:56:24 +0800 Subject: [PATCH] UNL-EH8813A: Update based on latest wiki --- src/boards/ax40g.c | 1 + src/boards/eh8813a.c | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/boards/ax40g.c b/src/boards/ax40g.c index 87be2a7..f3fe1d1 100644 --- a/src/boards/ax40g.c +++ b/src/boards/ax40g.c @@ -1,6 +1,7 @@ /* FCEUmm - NES/Famicom Emulator * * Copyright notice for this file: + * Copyright (C) 2019 Libretro Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/src/boards/eh8813a.c b/src/boards/eh8813a.c index ab15b39..d8998a3 100644 --- a/src/boards/eh8813a.c +++ b/src/boards/eh8813a.c @@ -18,36 +18,40 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ + /* Updated 6-27-19 */ + #include "mapinc.h" -static uint16 addrlatch; -static uint8 datalatch, hw_mode; +static uint8 datalatch, addrlatch, lock, hw_mode; static SFORMAT StateRegs[] = { - { &addrlatch, 2, "ADRL" }, + { &addrlatch, 1, "ADRL" }, { &datalatch, 1, "DATL" }, - { &hw_mode, 1, "HWMO" }, + { &hw_mode, 1, "HWMO" }, + { &lock, 1, "LOCK" }, { 0 } }; static void Sync(void) { - uint8 prg = (addrlatch & 7); + uint8 prg = (addrlatch & 0x3F); setchr8(datalatch); - if(addrlatch & 0x80) { + if (addrlatch & 0x80) { setprg16(0x8000,prg); setprg16(0xC000,prg); } else { setprg32(0x8000,prg >> 1); } - setmirror(MI_V); + setmirror(((datalatch >> 7) & 1) ^ 1); } static DECLFW(EH8813AWrite) { - if((addrlatch & 0x100) == 0) { - addrlatch = A & 0x1FF; - datalatch = V & 0xF; + if (lock == 0) { + addrlatch = A & 0xFF; + datalatch = V & 0xFC; + lock = (A & 0x100) >> 8; } + datalatch = (datalatch & ~0x03) | (V & 0x03); Sync(); } @@ -56,16 +60,16 @@ static DECLFR(EH8813ARead) { A= (A & 0xFFF0) + hw_mode; return CartBR(A); } - + static void EH8813APower(void) { - addrlatch = datalatch = hw_mode = 0; + addrlatch = datalatch = hw_mode = lock = 0; Sync(); SetReadHandler(0x8000, 0xFFFF, EH8813ARead); SetWriteHandler(0x8000, 0xFFFF, EH8813AWrite); } static void EH8813AReset(void) { - addrlatch = datalatch = 0; + addrlatch = datalatch = lock = 0; hw_mode = (hw_mode + 1) & 0xF; FCEU_printf("Hardware Switch is %01X\n", hw_mode); Sync();