Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NES] Add mapper185 #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions nesemu-go/components/nofrendo/mappers/map185.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
** Nofrendo (c) 1998-2000 Matthew Conte ([email protected])
**
**
** 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 <string.h>
#include <noftypes.h>
#include <nes_mmc.h>
#include <nes_ppu.h>

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 */
};
2 changes: 2 additions & 0 deletions nesemu-go/components/nofrendo/nes/mmclist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -100,6 +101,7 @@ const mapintf_t *mappers[] =
&map85_intf,
&map94_intf,
&map99_intf,
&map185_intf,
&map231_intf,
NULL
};
Expand Down
7 changes: 5 additions & 2 deletions nesemu-go/components/nofrendo/nes/nes_ppu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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
Expand Down