From cae5def9e62d0fac1585eb1cb034b0febd232549 Mon Sep 17 00:00:00 2001 From: sssiba Date: Sun, 18 Nov 2018 01:44:59 +0900 Subject: [PATCH] [NES] Add mapper185 --- .../components/nofrendo/mappers/map185.c | 81 +++++++++++++++++++ nesemu-go/components/nofrendo/nes/mmclist.c | 2 + nesemu-go/components/nofrendo/nes/nes_ppu.c | 7 +- 3 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 nesemu-go/components/nofrendo/mappers/map185.c diff --git a/nesemu-go/components/nofrendo/mappers/map185.c b/nesemu-go/components/nofrendo/mappers/map185.c new file mode 100644 index 0000000..2ecf286 --- /dev/null +++ b/nesemu-go/components/nofrendo/mappers/map185.c @@ -0,0 +1,81 @@ +/* +** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com) +** +** +** This program is free software; you can redistribute it and/or +** modify it under the terms of version 2 of the GNU Library General +** Public License as published by the Free Software Foundation. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** Library General Public License for more details. To obtain a +** copy of the GNU Library General Public License, write to the Free +** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +** +** Any permitted reproduction of these routines, in whole or in part, +** must bear this legend. +** +** +** map185.c +** +** mapper 185 interface +*/ + +#include +#include +#include +#include + +static uint8 dummyvrom[0x400]; +static uint8 chk; + +static void map185_init(void) +{ + uint8* p = mmc_getinfo()->rom; + if( p[0] == 0x78 && p[1] == 0xd8 && p[2] == 0xa2 && p[3] == 0x00 && + p[4] == 0x8e && p[5] == 0x00 && p[6] == 0x20 && p[7] == 0xad) + { //Spy Vs Spy + chk = 0x21; + } + else + { + chk = 0x03; + } + + memset(dummyvrom, 0xff, sizeof(dummyvrom)); +} + +static void map185_write(uint32 address, uint8 value) +{ + UNUSED(address); + + if (((chk == 0x03) && (value & chk)) || ((chk != 0x03) && (value == chk))) + { + mmc_bankvrom(8, 0, 0); + } + else + { + ppu_setpage(8, 0, dummyvrom); + } +} + +static map_memwrite map185_memwrite[] = +{ + { 0x8000, 0xFFFF, map185_write }, + { -1, -1, NULL } +}; + +mapintf_t map185_intf = +{ + 185, /* mapper number */ + "CNROM(protect)", /* mapper name */ + map185_init, /* init routine */ + NULL, /* vblank callback */ + NULL, /* hblank callback */ + NULL, /* get state (snss) */ + NULL, /* set state (snss) */ + NULL, /* memory read structure */ + map185_memwrite, /* memory write structure */ + NULL /* external sound device */ +}; diff --git a/nesemu-go/components/nofrendo/nes/mmclist.c b/nesemu-go/components/nofrendo/nes/mmclist.c index 376f135..b8d02af 100644 --- a/nesemu-go/components/nofrendo/nes/mmclist.c +++ b/nesemu-go/components/nofrendo/nes/mmclist.c @@ -61,6 +61,7 @@ extern mapintf_t map79_intf; extern mapintf_t map85_intf; extern mapintf_t map94_intf; extern mapintf_t map99_intf; +extern mapintf_t map185_intf; extern mapintf_t map231_intf; /* implemented mapper interfaces */ @@ -100,6 +101,7 @@ const mapintf_t *mappers[] = &map85_intf, &map94_intf, &map99_intf, + &map185_intf, &map231_intf, NULL }; diff --git a/nesemu-go/components/nofrendo/nes/nes_ppu.c b/nesemu-go/components/nofrendo/nes/nes_ppu.c index fd7851e..560a490 100644 --- a/nesemu-go/components/nofrendo/nes/nes_ppu.c +++ b/nesemu-go/components/nofrendo/nes/nes_ppu.c @@ -173,7 +173,7 @@ void ppu_setpage(int size, int page_num, uint8 *location) case 2: ppu.page[page_num++] = location; case 1: - ppu.page[page_num++] = location; + ppu.page[page_num] = location; break; } } @@ -496,7 +496,10 @@ void ppu_write(uint32 address, uint8 value) if (false == ppu.vram_present && addr >= 0x3000) ppu.vaddr -= 0x1000; - PPU_MEM(addr) = value; + if( ppu.vram_present || (!ppu.vram_present && (addr >= 0x2000)) ) + { + PPU_MEM(addr) = value; + } } } else