mirror of
https://github.com/libretro/QuickNES_Core.git
synced 2024-11-27 02:10:48 +00:00
Restructuring of NES mappers into a homogeneous format.
This commit is contained in:
parent
0baad4d890
commit
91272aa184
@ -38,39 +38,4 @@ SOURCES_CXX := \
|
||||
$(CORE_DIR)/nes_emu/nes_util.cpp \
|
||||
$(CORE_DIR)/nes_emu/Nes_Vrc6_Apu.cpp \
|
||||
$(CORE_DIR)/nes_emu/Data_Reader.cpp \
|
||||
$(CORE_DIR)/nes_emu/nes_ntsc.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mmc24.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mappers.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Misc.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Unrom512.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Vrc1.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Vrc3.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Vrc2_4.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Vrc7.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Nes_Mmc1.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Nes_Mmc3.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/nes_mappers.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Fme7.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Mmc5.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Namco106.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Vrc6.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/misc_mappers.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_15.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_60.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_74x161x162x32.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_180.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_193.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_240.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_241.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_244.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_246.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_AveNina.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_IremG101.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_IremTamS1.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_JalecoJF11.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Namco54xx.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Sunsoft1.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Sunsoft2.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_TaitoX1005.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_TaitoTC0190.cpp \
|
||||
$(CORE_DIR)/nes_emu/mappers/Mapper_Un1rom.cpp
|
||||
$(CORE_DIR)/nes_emu/nes_ntsc.cpp
|
||||
|
@ -1319,9 +1319,6 @@ bool retro_load_game(const struct retro_game_info *info)
|
||||
return false;
|
||||
|
||||
emu = new Nes_Emu;
|
||||
register_optional_mappers();
|
||||
register_extra_mappers();
|
||||
|
||||
check_variables();
|
||||
|
||||
update_audio_mode(); //calls set_sample_rate and set_equalizer
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <string.h>
|
||||
#include "Nes_Core.h"
|
||||
|
||||
@ -19,6 +20,66 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
/*
|
||||
New mapping distribution by Sergio Martin (eien86)
|
||||
https://github.com/SergioMartin86/jaffarPlus
|
||||
*/
|
||||
#include "mappers/mapper000.hpp"
|
||||
#include "mappers/mapper001.hpp"
|
||||
#include "mappers/mapper002.hpp"
|
||||
#include "mappers/mapper003.hpp"
|
||||
#include "mappers/mapper004.hpp"
|
||||
#include "mappers/mapper005.hpp"
|
||||
#include "mappers/mapper007.hpp"
|
||||
#include "mappers/mapper009.hpp"
|
||||
#include "mappers/mapper010.hpp"
|
||||
#include "mappers/mapper011.hpp"
|
||||
#include "mappers/mapper015.hpp"
|
||||
#include "mappers/mapper019.hpp"
|
||||
#include "mappers/mapper021.hpp"
|
||||
#include "mappers/mapper022.hpp"
|
||||
#include "mappers/mapper023.hpp"
|
||||
#include "mappers/mapper024.hpp"
|
||||
#include "mappers/mapper025.hpp"
|
||||
#include "mappers/mapper026.hpp"
|
||||
#include "mappers/mapper030.hpp"
|
||||
#include "mappers/mapper032.hpp"
|
||||
#include "mappers/mapper033.hpp"
|
||||
#include "mappers/mapper034.hpp"
|
||||
#include "mappers/mapper060.hpp"
|
||||
#include "mappers/mapper066.hpp"
|
||||
#include "mappers/mapper069.hpp"
|
||||
#include "mappers/mapper070.hpp"
|
||||
#include "mappers/mapper071.hpp"
|
||||
#include "mappers/mapper073.hpp"
|
||||
#include "mappers/mapper075.hpp"
|
||||
#include "mappers/mapper078.hpp"
|
||||
#include "mappers/mapper079.hpp"
|
||||
#include "mappers/mapper085.hpp"
|
||||
#include "mappers/mapper086.hpp"
|
||||
#include "mappers/mapper087.hpp"
|
||||
#include "mappers/mapper088.hpp"
|
||||
#include "mappers/mapper089.hpp"
|
||||
#include "mappers/mapper093.hpp"
|
||||
#include "mappers/mapper094.hpp"
|
||||
#include "mappers/mapper097.hpp"
|
||||
#include "mappers/mapper113.hpp"
|
||||
#include "mappers/mapper140.hpp"
|
||||
#include "mappers/mapper152.hpp"
|
||||
#include "mappers/mapper154.hpp"
|
||||
#include "mappers/mapper156.hpp"
|
||||
#include "mappers/mapper180.hpp"
|
||||
#include "mappers/mapper184.hpp"
|
||||
#include "mappers/mapper190.hpp"
|
||||
#include "mappers/mapper193.hpp"
|
||||
#include "mappers/mapper206.hpp"
|
||||
#include "mappers/mapper207.hpp"
|
||||
#include "mappers/mapper232.hpp"
|
||||
#include "mappers/mapper240.hpp"
|
||||
#include "mappers/mapper241.hpp"
|
||||
#include "mappers/mapper244.hpp"
|
||||
#include "mappers/mapper246.hpp"
|
||||
|
||||
Nes_Mapper::Nes_Mapper()
|
||||
{
|
||||
emu_ = NULL;
|
||||
@ -159,49 +220,83 @@ int Nes_Mapper::handle_bus_conflict( nes_addr_t addr, int data )
|
||||
}
|
||||
#endif
|
||||
|
||||
// Mapper registration
|
||||
|
||||
int const max_mappers = 64;
|
||||
Nes_Mapper::mapping_t Nes_Mapper::mappers [max_mappers] =
|
||||
{
|
||||
{ 0, Nes_Mapper::make_nrom },
|
||||
{ 1, Nes_Mapper::make_mmc1 },
|
||||
{ 2, Nes_Mapper::make_unrom },
|
||||
{ 3, Nes_Mapper::make_cnrom },
|
||||
{ 4, Nes_Mapper::make_mmc3 },
|
||||
{ 7, Nes_Mapper::make_aorom }
|
||||
};
|
||||
static int mapper_count = 6; // to do: keep synchronized with pre-supplied mappers above
|
||||
|
||||
Nes_Mapper::creator_func_t Nes_Mapper::get_mapper_creator( int code )
|
||||
{
|
||||
for ( int i = 0; i < mapper_count; i++ )
|
||||
{
|
||||
if ( mappers [i].code == code )
|
||||
return mappers [i].func;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Nes_Mapper::register_mapper( int code, creator_func_t func )
|
||||
{
|
||||
mapping_t& m = mappers [mapper_count++];
|
||||
m.code = code;
|
||||
m.func = func;
|
||||
}
|
||||
|
||||
Nes_Mapper* Nes_Mapper::create( Nes_Cart const* cart, Nes_Core* emu )
|
||||
{
|
||||
Nes_Mapper::creator_func_t func = get_mapper_creator( cart->mapper_code() );
|
||||
if ( !func )
|
||||
return NULL;
|
||||
// Getting cartdrige mapper code
|
||||
auto mapperCode = cart->mapper_code();
|
||||
|
||||
// to do: out of memory will be reported as unsupported mapper
|
||||
Nes_Mapper* mapper = func();
|
||||
if ( mapper )
|
||||
{
|
||||
mapper->cart_ = cart;
|
||||
mapper->emu_ = emu;
|
||||
}
|
||||
return mapper;
|
||||
// Storage for the mapper, NULL by default
|
||||
Nes_Mapper* mapper = NULL;
|
||||
|
||||
// Now checking if the detected mapper code is supported
|
||||
if (mapperCode == 0) mapper = new Mapper000();
|
||||
if (mapperCode == 1) mapper = new Mapper001();
|
||||
if (mapperCode == 2) mapper = new Mapper002();
|
||||
if (mapperCode == 3) mapper = new Mapper003();
|
||||
if (mapperCode == 4) mapper = new Mapper004();
|
||||
if (mapperCode == 5) mapper = new Mapper005();
|
||||
if (mapperCode == 7) mapper = new Mapper007();
|
||||
if (mapperCode == 9) mapper = new Mapper009();
|
||||
if (mapperCode == 10) mapper = new Mapper010();
|
||||
if (mapperCode == 11) mapper = new Mapper011();
|
||||
if (mapperCode == 15) mapper = new Mapper015();
|
||||
if (mapperCode == 19) mapper = new Mapper019();
|
||||
if (mapperCode == 21) mapper = new Mapper021();
|
||||
if (mapperCode == 22) mapper = new Mapper022();
|
||||
if (mapperCode == 23) mapper = new Mapper023();
|
||||
if (mapperCode == 24) mapper = new Mapper024();
|
||||
if (mapperCode == 25) mapper = new Mapper025();
|
||||
if (mapperCode == 26) mapper = new Mapper026();
|
||||
if (mapperCode == 30) mapper = new Mapper030();
|
||||
if (mapperCode == 32) mapper = new Mapper032();
|
||||
if (mapperCode == 33) mapper = new Mapper033();
|
||||
if (mapperCode == 34) mapper = new Mapper034();
|
||||
if (mapperCode == 60) mapper = new Mapper060();
|
||||
if (mapperCode == 66) mapper = new Mapper066();
|
||||
if (mapperCode == 69) mapper = new Mapper069();
|
||||
if (mapperCode == 70) mapper = new Mapper070();
|
||||
if (mapperCode == 71) mapper = new Mapper071();
|
||||
if (mapperCode == 73) mapper = new Mapper073();
|
||||
if (mapperCode == 75) mapper = new Mapper075();
|
||||
if (mapperCode == 78) mapper = new Mapper078();
|
||||
if (mapperCode == 79) mapper = new Mapper079();
|
||||
if (mapperCode == 85) mapper = new Mapper085();
|
||||
if (mapperCode == 86) mapper = new Mapper086();
|
||||
if (mapperCode == 87) mapper = new Mapper087();
|
||||
if (mapperCode == 88) mapper = new Mapper088();
|
||||
if (mapperCode == 89) mapper = new Mapper089();
|
||||
if (mapperCode == 93) mapper = new Mapper093();
|
||||
if (mapperCode == 94) mapper = new Mapper094();
|
||||
if (mapperCode == 97) mapper = new Mapper097();
|
||||
if (mapperCode == 113) mapper = new Mapper113();
|
||||
if (mapperCode == 140) mapper = new Mapper140();
|
||||
if (mapperCode == 152) mapper = new Mapper152();
|
||||
if (mapperCode == 154) mapper = new Mapper154();
|
||||
if (mapperCode == 156) mapper = new Mapper156();
|
||||
if (mapperCode == 180) mapper = new Mapper180();
|
||||
if (mapperCode == 184) mapper = new Mapper184();
|
||||
if (mapperCode == 190) mapper = new Mapper190();
|
||||
if (mapperCode == 193) mapper = new Mapper193();
|
||||
if (mapperCode == 206) mapper = new Mapper206();
|
||||
if (mapperCode == 207) mapper = new Mapper207();
|
||||
if (mapperCode == 232) mapper = new Mapper232();
|
||||
if (mapperCode == 240) mapper = new Mapper240();
|
||||
if (mapperCode == 241) mapper = new Mapper241();
|
||||
if (mapperCode == 244) mapper = new Mapper244();
|
||||
if (mapperCode == 246) mapper = new Mapper246();
|
||||
|
||||
// If no mapper was found, return null (error) now
|
||||
if (mapper == NULL)
|
||||
{
|
||||
fprintf(stderr, "Could not find mapper for code: %u\n", mapperCode);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Assigning backwards pointers to cartdrige and emulator now
|
||||
mapper->cart_ = cart;
|
||||
mapper->emu_ = emu;
|
||||
|
||||
// Returning successfully created mapper
|
||||
return mapper;
|
||||
}
|
||||
|
@ -173,28 +173,8 @@ private:
|
||||
Nes_Cart const* cart_;
|
||||
|
||||
void default_reset_state();
|
||||
|
||||
struct mapping_t {
|
||||
int code;
|
||||
Nes_Mapper::creator_func_t func;
|
||||
};
|
||||
static mapping_t mappers [];
|
||||
static creator_func_t get_mapper_creator( int code );
|
||||
|
||||
// built-in mappers
|
||||
static Nes_Mapper* make_nrom();
|
||||
static Nes_Mapper* make_unrom();
|
||||
static Nes_Mapper* make_aorom();
|
||||
static Nes_Mapper* make_cnrom();
|
||||
static Nes_Mapper* make_mmc1();
|
||||
static Nes_Mapper* make_mmc3();
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct register_mapper {
|
||||
/*void*/ register_mapper( int code ) { Nes_Mapper::register_mapper( code, create ); }
|
||||
static Nes_Mapper* create() { return new T; }
|
||||
};
|
||||
|
||||
#ifdef NDEBUG
|
||||
inline int Nes_Mapper::handle_bus_conflict( nes_addr_t addr, int data ) { return data; }
|
||||
|
@ -1,182 +0,0 @@
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct m156_state_t
|
||||
{
|
||||
uint8_t prg_bank;
|
||||
uint8_t chr_banks [8];
|
||||
};
|
||||
BOOST_STATIC_ASSERT( sizeof (m156_state_t) == 9 );
|
||||
|
||||
class Mapper_156 : public Nes_Mapper, m156_state_t {
|
||||
public:
|
||||
Mapper_156()
|
||||
{
|
||||
m156_state_t * state = this;
|
||||
register_state( state, sizeof * state );
|
||||
}
|
||||
|
||||
void reset_state()
|
||||
{
|
||||
prg_bank = 0;
|
||||
for ( unsigned i = 0; i < 8; i++ ) chr_banks [i] = i;
|
||||
enable_sram();
|
||||
apply_mapping();
|
||||
}
|
||||
|
||||
void apply_mapping()
|
||||
{
|
||||
mirror_single( 0 );
|
||||
set_prg_bank( 0x8000, bank_16k, prg_bank );
|
||||
|
||||
for ( int i = 0; i < (int) sizeof chr_banks; i++ )
|
||||
set_chr_bank( i * 0x400, bank_1k, chr_banks [i] );
|
||||
}
|
||||
|
||||
void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
unsigned int reg = addr - 0xC000;
|
||||
if ( addr == 0xC010 )
|
||||
{
|
||||
prg_bank = data;
|
||||
set_prg_bank( 0x8000, bank_16k, data );
|
||||
}
|
||||
else if ( reg < 4 )
|
||||
{
|
||||
chr_banks [reg] = data;
|
||||
set_chr_bank( reg * 0x400, bank_1k, data );
|
||||
}
|
||||
else if ( ( reg - 8 ) < 4 )
|
||||
{
|
||||
reg -= 4;
|
||||
chr_banks [reg] = data;
|
||||
set_chr_bank( reg * 0x400, bank_1k, data );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Mapper_78 : public Nes_Mapper {
|
||||
// lower 8 bits are the reg at 8000:ffff
|
||||
// next two bits are autodetecting type
|
||||
// 0 = unknown 1 = cosmo carrier 2 = holy diver
|
||||
int reg;
|
||||
void writeinternal(int data, int changed)
|
||||
{
|
||||
reg &= 0x300;
|
||||
reg |= data;
|
||||
|
||||
if (changed & 0x07)
|
||||
set_prg_bank(0x8000, bank_16k, reg & 0x07);
|
||||
if (changed & 0xf0)
|
||||
set_chr_bank(0x0000, bank_8k, (reg >> 4) & 0x0f);
|
||||
if (changed & 0x08)
|
||||
{
|
||||
// set mirroring based on memorized board type
|
||||
if (reg & 0x100)
|
||||
{
|
||||
mirror_single((reg >> 3) & 1);
|
||||
}
|
||||
else if (reg & 0x200)
|
||||
{
|
||||
if (reg & 0x08)
|
||||
mirror_vert();
|
||||
else
|
||||
mirror_horiz();
|
||||
}
|
||||
else
|
||||
{
|
||||
// if you don't set something here, holy diver dumps with 4sc set will
|
||||
// savestate as 4k NTRAM. then when you later set H\V mapping, state size mismatch.
|
||||
mirror_single(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
Mapper_78()
|
||||
{
|
||||
register_state(®, 4);
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
reg = 0;
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
writeinternal(reg, 0xff);
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data)
|
||||
{
|
||||
// heuristic: if the first write ever to the register is 0,
|
||||
// we're on holy diver, otherwise, carrier. it works for these two games...
|
||||
if (!(reg & 0x300))
|
||||
{
|
||||
reg |= data ? 0x100 : 0x200;
|
||||
writeinternal(data, 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeinternal(data, reg ^ data);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Magic Kid Googoo
|
||||
class Mapper_190: public Nes_Mapper {
|
||||
public:
|
||||
Mapper_190()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
mirror_vert();
|
||||
enable_sram();
|
||||
set_prg_bank( 0xc000, bank_16k, 0);
|
||||
}
|
||||
|
||||
virtual void write(nes_time_t, nes_addr_t addr, int data)
|
||||
{
|
||||
switch ( addr >> 12 )
|
||||
{
|
||||
case 0x8:
|
||||
case 0x9:
|
||||
case 0xc:
|
||||
case 0xd:
|
||||
set_prg_bank( 0x8000, bank_16k, ( ( ( addr >> 11 ) & 8 ) | ( data & 7 ) ) );
|
||||
break;
|
||||
case 0xa:
|
||||
case 0xb:
|
||||
switch ( addr & 3 )
|
||||
{
|
||||
case 0:
|
||||
set_chr_bank( 0x0000, bank_2k, data );
|
||||
break;
|
||||
case 1:
|
||||
set_chr_bank( 0x0800, bank_2k, data );
|
||||
break;
|
||||
case 2:
|
||||
set_chr_bank( 0x1000, bank_2k, data );
|
||||
break;
|
||||
case 3:
|
||||
set_chr_bank( 0x1800, bank_2k, data );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void register_more_mappers();
|
||||
void register_more_mappers()
|
||||
{
|
||||
register_mapper< Mapper_156 > ( 156 );
|
||||
register_mapper< Mapper_78 > ( 78 );
|
||||
register_mapper< Mapper_190 > ( 190 );
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
extern void register_mapper_74x161x162x32();
|
||||
extern void register_mapper_180();
|
||||
extern void register_mapper_193();
|
||||
extern void register_mapper_234();
|
||||
extern void register_mapper_235();
|
||||
extern void register_mapper_240();
|
||||
extern void register_mapper_241();
|
||||
extern void register_mapper_244();
|
||||
extern void register_mapper_246();
|
||||
extern void register_mapper_avenina();
|
||||
extern void register_mapper_irem_g101();
|
||||
extern void register_mapper_irem_tamS1();
|
||||
extern void register_mapper_jaleco_jf11();
|
||||
extern void register_mapper_namco_34xx();
|
||||
extern void register_mapper_sunsoft1();
|
||||
extern void register_mapper_sunsoft2();
|
||||
extern void register_mapper_taito_tc0190();
|
||||
extern void register_mapper_taito_x1005();
|
||||
extern void register_mapper_un1rom();
|
||||
|
||||
void register_extra_mappers();
|
||||
void register_extra_mappers()
|
||||
{
|
||||
// Mapper 32
|
||||
register_mapper_irem_g101();
|
||||
|
||||
// Mapper 33
|
||||
register_mapper_taito_tc0190();
|
||||
|
||||
// Mapper 79, 113
|
||||
register_mapper_avenina();
|
||||
|
||||
// Mapper 94
|
||||
register_mapper_un1rom();
|
||||
|
||||
// Mapper 97
|
||||
register_mapper_irem_tamS1();
|
||||
|
||||
// Mapper 140
|
||||
register_mapper_jaleco_jf11();
|
||||
|
||||
// Mapper 184
|
||||
register_mapper_sunsoft1();
|
||||
|
||||
// Mapper 89, 93
|
||||
register_mapper_sunsoft2();
|
||||
|
||||
// Mapper 86, 152
|
||||
register_mapper_74x161x162x32();
|
||||
|
||||
// Mapper 180
|
||||
register_mapper_180();
|
||||
|
||||
// Mapper 193
|
||||
register_mapper_193();
|
||||
|
||||
// Mapper 207
|
||||
register_mapper_taito_x1005();
|
||||
|
||||
// Mapper 088, 154, 206
|
||||
register_mapper_namco_34xx();
|
||||
|
||||
// Mapper 240
|
||||
register_mapper_240();
|
||||
|
||||
// Mapper 241
|
||||
register_mapper_241();
|
||||
|
||||
// Mapper 244
|
||||
register_mapper_244();
|
||||
|
||||
// Mapper 246
|
||||
register_mapper_246();
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
#include "Nes_Mapper.h"
|
||||
#include "blargg_source.h"
|
||||
|
||||
#include "Mmc24.h"
|
||||
|
||||
|
||||
class MMC2: public Nes_Mapper
|
||||
{
|
||||
uint8_t regs[6]; // A,B,C,D,E,F
|
||||
|
||||
void mirror(uint8_t val)
|
||||
{
|
||||
if (val & 1)
|
||||
mirror_horiz();
|
||||
else
|
||||
mirror_vert();
|
||||
}
|
||||
|
||||
public:
|
||||
MMC2()
|
||||
{
|
||||
register_state(regs, sizeof(regs));
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
regs[0] = regs[1] = regs[2] = regs[3] = regs[4] = regs[5] = 0;
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
mirror(regs[5]);
|
||||
set_prg_bank(0x8000, bank_8k, regs[0]);
|
||||
set_prg_bank(0xa000, bank_8k, 13);
|
||||
set_prg_bank(0xc000, bank_8k, 14);
|
||||
set_prg_bank(0xe000, bank_8k, 15);
|
||||
|
||||
set_chr_bank(0x0000, bank_4k, regs[1]);
|
||||
set_chr_bank(0x1000, bank_4k, regs[3]);
|
||||
|
||||
set_chr_bank_ex(0x0000, bank_4k, regs[2]);
|
||||
set_chr_bank_ex(0x1000, bank_4k, regs[4]);
|
||||
}
|
||||
|
||||
virtual void write(nes_time_t, nes_addr_t addr, int data)
|
||||
{
|
||||
switch (addr >> 12)
|
||||
{
|
||||
case 0xa: regs[0] = data; set_prg_bank(0x8000, bank_8k, data); break;
|
||||
case 0xb: regs[1] = data; set_chr_bank(0x0000, bank_4k, data); break;
|
||||
case 0xc: regs[2] = data; set_chr_bank_ex(0x0000, bank_4k, data); break;
|
||||
case 0xd: regs[3] = data; set_chr_bank(0x1000, bank_4k, data); break;
|
||||
case 0xe: regs[4] = data; set_chr_bank_ex(0x1000, bank_4k, data); break;
|
||||
case 0xf: regs[5] = data; mirror(data); break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class MMC4: public Nes_Mapper
|
||||
{
|
||||
uint8_t regs[6]; // A,B,C,D,E,F
|
||||
|
||||
void mirror(uint8_t val)
|
||||
{
|
||||
if (val & 1)
|
||||
mirror_horiz();
|
||||
else
|
||||
mirror_vert();
|
||||
}
|
||||
|
||||
public:
|
||||
MMC4()
|
||||
{
|
||||
register_state(regs, sizeof(regs));
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
regs[0] = regs[1] = regs[2] = regs[3] = regs[4] = regs[5] = 0;
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
enable_sram();
|
||||
|
||||
mirror(regs[5]);
|
||||
set_prg_bank(0x8000, bank_16k, regs[0]);
|
||||
|
||||
set_chr_bank(0x0000, bank_4k, regs[1]);
|
||||
set_chr_bank(0x1000, bank_4k, regs[3]);
|
||||
|
||||
set_chr_bank_ex(0x0000, bank_4k, regs[2]);
|
||||
set_chr_bank_ex(0x1000, bank_4k, regs[4]);
|
||||
}
|
||||
|
||||
virtual void write(nes_time_t, nes_addr_t addr, int data)
|
||||
{
|
||||
switch (addr >> 12)
|
||||
{
|
||||
case 0xa: regs[0] = data; set_prg_bank(0x8000, bank_16k, data); break;
|
||||
case 0xb: regs[1] = data; set_chr_bank(0x0000, bank_4k, data); break;
|
||||
case 0xc: regs[2] = data; set_chr_bank_ex(0x0000, bank_4k, data); break;
|
||||
case 0xd: regs[3] = data; set_chr_bank(0x1000, bank_4k, data); break;
|
||||
case 0xe: regs[4] = data; set_chr_bank_ex(0x1000, bank_4k, data); break;
|
||||
case 0xf: regs[5] = data; mirror(data); break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void register_mmc24()
|
||||
{
|
||||
register_mapper<MMC2>(9);
|
||||
register_mapper<MMC4>(10);
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#ifndef MMC24_H
|
||||
#define MMC24_H
|
||||
|
||||
|
||||
void register_mmc24();
|
||||
|
||||
#endif
|
34
nes_emu/mappers/mapper000.hpp
Normal file
34
nes_emu/mappers/mapper000.hpp
Normal file
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
// Common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// NROM
|
||||
|
||||
class Mapper000 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper000() { }
|
||||
|
||||
virtual void apply_mapping() { }
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
};
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
@ -18,9 +19,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
class Mapper_Mmc1 : public Nes_Mapper, mmc1_state_t {
|
||||
// MMC1
|
||||
|
||||
class Mapper001 : public Nes_Mapper, mmc1_state_t {
|
||||
public:
|
||||
Mapper_Mmc1()
|
||||
Mapper001()
|
||||
{
|
||||
mmc1_state_t* state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -70,7 +73,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void Mapper_Mmc1::register_changed( int reg )
|
||||
void Mapper001::register_changed( int reg )
|
||||
{
|
||||
// Mirroring
|
||||
if ( reg == 0 )
|
||||
@ -116,7 +119,3 @@ void Mapper_Mmc1::register_changed( int reg )
|
||||
}
|
||||
}
|
||||
|
||||
Nes_Mapper* Nes_Mapper::make_mmc1()
|
||||
{
|
||||
return new Mapper_Mmc1;
|
||||
}
|
44
nes_emu/mappers/mapper002.hpp
Normal file
44
nes_emu/mappers/mapper002.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
// Common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// UNROM
|
||||
|
||||
class Mapper002 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper002()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
enable_sram(); // at least one UNROM game needs sram (Bomberman 2)
|
||||
set_prg_bank( 0x8000, bank_16k, bank );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
bank = handle_bus_conflict( addr, data );
|
||||
set_prg_bank( 0x8000, bank_16k, bank );
|
||||
}
|
||||
};
|
||||
|
43
nes_emu/mappers/mapper003.hpp
Normal file
43
nes_emu/mappers/mapper003.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
// Common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// CNROM
|
||||
|
||||
class Mapper003 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper003()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
set_chr_bank( 0, bank_8k, bank & 7 );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
bank = handle_bus_conflict( addr, data );
|
||||
set_chr_bank( 0, bank_8k, bank & 7 );
|
||||
}
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
@ -25,9 +26,11 @@ int const irq_fine_tune = 268;
|
||||
nes_time_t const first_scanline = 20 * Nes_Ppu::scanline_len + irq_fine_tune;
|
||||
nes_time_t const last_scanline = first_scanline + 240 * Nes_Ppu::scanline_len;
|
||||
|
||||
class Mapper_Mmc3 : public Nes_Mapper, mmc3_state_t {
|
||||
// MMC3
|
||||
|
||||
class Mapper004 : public Nes_Mapper, mmc3_state_t {
|
||||
public:
|
||||
Mapper_Mmc3()
|
||||
Mapper004()
|
||||
{
|
||||
mmc3_state_t* state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -126,10 +129,12 @@ public:
|
||||
int counter_just_clocked; // used only for debugging
|
||||
};
|
||||
|
||||
void Mapper_Mmc3::run_until( nes_time_t end_time )
|
||||
void Mapper004::run_until( nes_time_t end_time )
|
||||
{
|
||||
bool bg_enabled = ppu_enabled();
|
||||
|
||||
if (next_time < 0) next_time = 0;
|
||||
|
||||
end_time *= ppu_overclock;
|
||||
while ( next_time < end_time && next_time <= last_scanline )
|
||||
{
|
||||
@ -139,7 +144,7 @@ void Mapper_Mmc3::run_until( nes_time_t end_time )
|
||||
}
|
||||
}
|
||||
|
||||
void Mapper_Mmc3::update_chr_banks()
|
||||
void Mapper004::update_chr_banks()
|
||||
{
|
||||
int chr_xor = (mode >> 7 & 1) * 0x1000;
|
||||
set_chr_bank( 0x0000 ^ chr_xor, bank_2k, banks [0] >> 1 );
|
||||
@ -150,7 +155,7 @@ void Mapper_Mmc3::update_chr_banks()
|
||||
set_chr_bank( 0x1c00 ^ chr_xor, bank_1k, banks [5] );
|
||||
}
|
||||
|
||||
void Mapper_Mmc3::update_prg_banks()
|
||||
void Mapper004::update_prg_banks()
|
||||
{
|
||||
set_prg_bank( 0xA000, bank_8k, banks [7] );
|
||||
nes_addr_t addr = 0x8000 + 0x4000 * (mode >> 6 & 1);
|
||||
@ -158,7 +163,7 @@ void Mapper_Mmc3::update_prg_banks()
|
||||
set_prg_bank( addr ^ 0x4000, bank_8k, last_bank - 1 );
|
||||
}
|
||||
|
||||
void Mapper_Mmc3::write_irq( nes_addr_t addr, int data )
|
||||
void Mapper004::write_irq( nes_addr_t addr, int data )
|
||||
{
|
||||
switch ( addr & 0xE001 )
|
||||
{
|
||||
@ -186,7 +191,7 @@ void Mapper_Mmc3::write_irq( nes_addr_t addr, int data )
|
||||
irq_changed();
|
||||
}
|
||||
|
||||
void Mapper_Mmc3::write( nes_time_t time, nes_addr_t addr, int data )
|
||||
void Mapper004::write( nes_time_t time, nes_addr_t addr, int data )
|
||||
{
|
||||
switch ( addr & 0xE001 )
|
||||
{
|
||||
@ -239,8 +244,3 @@ void Mapper_Mmc3::write( nes_time_t time, nes_addr_t addr, int data )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Nes_Mapper* Nes_Mapper::make_mmc3()
|
||||
{
|
||||
return new Mapper_Mmc3;
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
// NES MMC5 mapper, currently only tailored for Castlevania 3 (U)
|
||||
|
||||
@ -21,6 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
|
||||
struct mmc5_state_t
|
||||
{
|
||||
enum { reg_count = 0x30 };
|
||||
@ -30,9 +32,11 @@ struct mmc5_state_t
|
||||
// to do: finalize state format
|
||||
BOOST_STATIC_ASSERT( sizeof (mmc5_state_t) == 0x31 );
|
||||
|
||||
class Mapper_Mmc5 : public Nes_Mapper, mmc5_state_t {
|
||||
// MMC5
|
||||
|
||||
class Mapper005 : public Nes_Mapper, mmc5_state_t {
|
||||
public:
|
||||
Mapper_Mmc5()
|
||||
Mapper005()
|
||||
{
|
||||
mmc5_state_t* state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -132,7 +136,7 @@ public:
|
||||
nes_time_t irq_time;
|
||||
};
|
||||
|
||||
void Mapper_Mmc5::apply_mapping()
|
||||
void Mapper005::apply_mapping()
|
||||
{
|
||||
static unsigned char list [] = {
|
||||
0x05, 0x15, 0x16, 0x17,
|
||||
@ -145,8 +149,3 @@ void Mapper_Mmc5::apply_mapping()
|
||||
intercept_writes( 0x5100, 0x200 );
|
||||
}
|
||||
|
||||
void register_mmc5_mapper();
|
||||
void register_mmc5_mapper()
|
||||
{
|
||||
register_mapper<Mapper_Mmc5>( 5 );
|
||||
}
|
52
nes_emu/mappers/mapper007.hpp
Normal file
52
nes_emu/mappers/mapper007.hpp
Normal file
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
// Common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// AOROM
|
||||
|
||||
class Mapper007 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper007()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
int b = bank;
|
||||
bank = ~b; // force update
|
||||
write( 0, 0, b );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int data )
|
||||
{
|
||||
int changed = bank ^ data;
|
||||
bank = data;
|
||||
|
||||
if ( changed & 0x10 )
|
||||
mirror_single( bank >> 4 & 1 );
|
||||
|
||||
if ( changed & 0x0f )
|
||||
set_prg_bank( 0x8000, bank_32k, bank & 7 );
|
||||
}
|
||||
};
|
||||
|
||||
|
61
nes_emu/mappers/mapper009.hpp
Normal file
61
nes_emu/mappers/mapper009.hpp
Normal file
@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
#include "blargg_source.h"
|
||||
|
||||
// MMC2
|
||||
|
||||
class Mapper009: public Nes_Mapper
|
||||
{
|
||||
uint8_t regs[6]; // A,B,C,D,E,F
|
||||
|
||||
void mirror(uint8_t val)
|
||||
{
|
||||
if (val & 1)
|
||||
mirror_horiz();
|
||||
else
|
||||
mirror_vert();
|
||||
}
|
||||
|
||||
public:
|
||||
Mapper009()
|
||||
{
|
||||
register_state(regs, sizeof(regs));
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
std::memset(regs, 0, sizeof(regs));
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
mirror(regs[5]);
|
||||
set_prg_bank(0x8000, bank_8k, regs[0]);
|
||||
set_prg_bank(0xa000, bank_8k, 13);
|
||||
set_prg_bank(0xc000, bank_8k, 14);
|
||||
set_prg_bank(0xe000, bank_8k, 15);
|
||||
|
||||
set_chr_bank(0x0000, bank_4k, regs[1]);
|
||||
set_chr_bank(0x1000, bank_4k, regs[3]);
|
||||
|
||||
set_chr_bank_ex(0x0000, bank_4k, regs[2]);
|
||||
set_chr_bank_ex(0x1000, bank_4k, regs[4]);
|
||||
}
|
||||
|
||||
virtual void write(nes_time_t, nes_addr_t addr, int data)
|
||||
{
|
||||
switch (addr >> 12)
|
||||
{
|
||||
case 0xa: regs[0] = data; set_prg_bank(0x8000, bank_8k, data); break;
|
||||
case 0xb: regs[1] = data; set_chr_bank(0x0000, bank_4k, data); break;
|
||||
case 0xc: regs[2] = data; set_chr_bank_ex(0x0000, bank_4k, data); break;
|
||||
case 0xd: regs[3] = data; set_chr_bank(0x1000, bank_4k, data); break;
|
||||
case 0xe: regs[4] = data; set_chr_bank_ex(0x1000, bank_4k, data); break;
|
||||
case 0xf: regs[5] = data; mirror(data); break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
58
nes_emu/mappers/mapper010.hpp
Normal file
58
nes_emu/mappers/mapper010.hpp
Normal file
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#include <cstring>
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
#include "blargg_source.h"
|
||||
|
||||
// MMC4
|
||||
|
||||
class Mapper010: public Nes_Mapper
|
||||
{
|
||||
uint8_t regs[6]; // A,B,C,D,E,F
|
||||
|
||||
void mirror(uint8_t val)
|
||||
{
|
||||
if (val & 1)
|
||||
mirror_horiz();
|
||||
else
|
||||
mirror_vert();
|
||||
}
|
||||
|
||||
public:
|
||||
Mapper010()
|
||||
{
|
||||
register_state(regs, sizeof(regs));
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
std::memset(regs, 0, sizeof(regs));
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
enable_sram();
|
||||
|
||||
mirror(regs[5]);
|
||||
set_prg_bank(0x8000, bank_16k, regs[0]);
|
||||
|
||||
set_chr_bank(0x0000, bank_4k, regs[1]);
|
||||
set_chr_bank(0x1000, bank_4k, regs[3]);
|
||||
|
||||
set_chr_bank_ex(0x0000, bank_4k, regs[2]);
|
||||
set_chr_bank_ex(0x1000, bank_4k, regs[4]);
|
||||
}
|
||||
|
||||
virtual void write(nes_time_t, nes_addr_t addr, int data)
|
||||
{
|
||||
switch (addr >> 12)
|
||||
{
|
||||
case 0xa: regs[0] = data; set_prg_bank(0x8000, bank_16k, data); break;
|
||||
case 0xb: regs[1] = data; set_chr_bank(0x0000, bank_4k, data); break;
|
||||
case 0xc: regs[2] = data; set_chr_bank_ex(0x0000, bank_4k, data); break;
|
||||
case 0xd: regs[3] = data; set_chr_bank(0x1000, bank_4k, data); break;
|
||||
case 0xe: regs[4] = data; set_chr_bank_ex(0x1000, bank_4k, data); break;
|
||||
case 0xf: regs[5] = data; mirror(data); break;
|
||||
}
|
||||
}
|
||||
};
|
50
nes_emu/mappers/mapper011.hpp
Normal file
50
nes_emu/mappers/mapper011.hpp
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
// Optional less-common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// Color Dreams
|
||||
|
||||
class Mapper011 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper011()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
int b = bank;
|
||||
bank = ~b;
|
||||
write( 0, 0, b );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int data )
|
||||
{
|
||||
int changed = bank ^ data;
|
||||
bank = data;
|
||||
|
||||
if ( changed & 0x0f )
|
||||
set_prg_bank( 0x8000, bank_32k, bank & 0x0f );
|
||||
|
||||
if ( changed & 0xf0 )
|
||||
set_chr_bank( 0, bank_8k, bank >> 4 );
|
||||
}
|
||||
};
|
@ -15,22 +15,26 @@
|
||||
* 100-in-1 Contra Function 16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct mapper_15_state_t
|
||||
struct Mapper015_state_t
|
||||
{
|
||||
uint8_t prg_bank [ 4 ];
|
||||
uint8_t mirroring;
|
||||
};
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof (mapper_15_state_t) == 5 );
|
||||
BOOST_STATIC_ASSERT( sizeof (Mapper015_state_t) == 5 );
|
||||
|
||||
class Mapper_15 : public Nes_Mapper, mapper_15_state_t {
|
||||
// K-1029, K-1030P
|
||||
|
||||
class Mapper015 : public Nes_Mapper, Mapper015_state_t {
|
||||
public:
|
||||
Mapper_15()
|
||||
Mapper015()
|
||||
{
|
||||
i = 0;
|
||||
mapper_15_state_t* state = this;
|
||||
Mapper015_state_t* state = this;
|
||||
register_state( state, sizeof *state );
|
||||
}
|
||||
|
||||
@ -82,11 +86,7 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
int i;
|
||||
|
||||
unsigned long int i;
|
||||
};
|
||||
|
||||
void register_mapper_15();
|
||||
void register_mapper_15()
|
||||
{
|
||||
register_mapper< Mapper_15 > ( 15 );
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
// Namco 106 mapper
|
||||
|
||||
@ -35,9 +36,11 @@ struct namco106_state_t
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof (namco106_state_t) == 20 + sizeof (namco_state_t) );
|
||||
|
||||
class Mapper_Namco106 : public Nes_Mapper, namco106_state_t {
|
||||
// Namco106
|
||||
|
||||
class Mapper019 : public Nes_Mapper, namco106_state_t {
|
||||
public:
|
||||
Mapper_Namco106()
|
||||
Mapper019()
|
||||
{
|
||||
namco106_state_t* state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -200,7 +203,7 @@ void namco106_state_t::swap()
|
||||
set_le16( &sound_state.delays [i], sound_state.delays [i] );
|
||||
}
|
||||
|
||||
void Mapper_Namco106::save_state( mapper_state_t& out )
|
||||
void Mapper019::save_state( mapper_state_t& out )
|
||||
{
|
||||
sound.save_state( &sound_state );
|
||||
namco106_state_t::swap();
|
||||
@ -208,62 +211,10 @@ void Mapper_Namco106::save_state( mapper_state_t& out )
|
||||
namco106_state_t::swap();
|
||||
}
|
||||
|
||||
void Mapper_Namco106::read_state( mapper_state_t const& in )
|
||||
void Mapper019::read_state( mapper_state_t const& in )
|
||||
{
|
||||
Nes_Mapper::read_state( in );
|
||||
namco106_state_t::swap();
|
||||
sound.load_state( sound_state );
|
||||
}
|
||||
|
||||
void register_namco106_mapper();
|
||||
void register_namco106_mapper()
|
||||
{
|
||||
register_mapper<Mapper_Namco106>( 19 );
|
||||
}
|
||||
|
||||
// in the most obscure place in case crappy linker is used
|
||||
void register_optional_mappers();
|
||||
void register_optional_mappers()
|
||||
{
|
||||
extern void register_misc_mappers();
|
||||
register_misc_mappers();
|
||||
|
||||
extern void register_more_mappers();
|
||||
register_more_mappers();
|
||||
|
||||
extern void register_unrom512_mapper();
|
||||
register_unrom512_mapper();
|
||||
|
||||
extern void register_vrc6_mapper();
|
||||
register_vrc6_mapper();
|
||||
|
||||
extern void register_mmc5_mapper();
|
||||
register_mmc5_mapper();
|
||||
|
||||
extern void register_fme7_mapper();
|
||||
register_fme7_mapper();
|
||||
|
||||
extern void register_namco106_mapper();
|
||||
register_namco106_mapper();
|
||||
|
||||
extern void register_mmc24();
|
||||
register_mmc24();
|
||||
|
||||
extern void register_vrc1_mapper();
|
||||
register_vrc1_mapper();
|
||||
|
||||
extern void register_vrc3_mapper();
|
||||
register_vrc3_mapper();
|
||||
|
||||
extern void register_vrc2_4_mapper();
|
||||
register_vrc2_4_mapper();
|
||||
|
||||
extern void register_vrc7_mapper();
|
||||
register_vrc7_mapper();
|
||||
|
||||
extern void register_mapper_15();
|
||||
register_mapper_15();
|
||||
|
||||
extern void register_mapper_60();
|
||||
register_mapper_60();
|
||||
}
|
@ -24,6 +24,7 @@
|
||||
* VRC-2/VRC-4 Konami
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct vrc2_state_t
|
||||
@ -245,11 +246,5 @@ void Mapper_VRC2_4<type_a, type_b>::write_irq( nes_time_t time,
|
||||
irq_changed();
|
||||
}
|
||||
|
||||
void register_vrc2_4_mapper();
|
||||
void register_vrc2_4_mapper()
|
||||
{
|
||||
register_mapper< Mapper_VRC2_4<true, true> > ( 21 );
|
||||
register_mapper< Mapper_VRC2_4<false, true> > ( 22 );
|
||||
register_mapper< Mapper_VRC2_4<false, false> > ( 23 );
|
||||
register_mapper< Mapper_VRC2_4<true, false> > ( 25 );
|
||||
}
|
||||
|
||||
typedef Mapper_VRC2_4<true,true> Mapper021;
|
31
nes_emu/mappers/mapper022.hpp
Normal file
31
nes_emu/mappers/mapper022.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2004-2006 Shay Green
|
||||
* Copyright (C) 2007 CaH4e3
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* General code is from FCEUX https://sourceforge.net/p/fceultra/code/HEAD/tree/fceu/trunk/src/boards/vrc2and4.cpp
|
||||
* IRQ portion is from existing VRC6/VRC7 by Shay Green
|
||||
* This mapper was ported by retrowertz for Libretro port of QuickNES.
|
||||
* 3-19-2018
|
||||
*
|
||||
* VRC-2/VRC-4 Konami
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Nes_Mapper.h"
|
||||
#include "mappers/mapper021.hpp"
|
||||
|
||||
typedef Mapper_VRC2_4<false,true> Mapper022;
|
30
nes_emu/mappers/mapper023.hpp
Normal file
30
nes_emu/mappers/mapper023.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2004-2006 Shay Green
|
||||
* Copyright (C) 2007 CaH4e3
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* General code is from FCEUX https://sourceforge.net/p/fceultra/code/HEAD/tree/fceu/trunk/src/boards/vrc2and4.cpp
|
||||
* IRQ portion is from existing VRC6/VRC7 by Shay Green
|
||||
* This mapper was ported by retrowertz for Libretro port of QuickNES.
|
||||
* 3-19-2018
|
||||
*
|
||||
* VRC-2/VRC-4 Konami
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
typedef Mapper_VRC2_4<false, false> Mapper023;
|
@ -53,11 +53,12 @@ void vrc6_state_t::swap()
|
||||
set_le16( &sound_state.delays [i], sound_state.delays [i] );
|
||||
}
|
||||
|
||||
template <int swapMask>
|
||||
class Mapper_Vrc6 : public Nes_Mapper, vrc6_state_t {
|
||||
public:
|
||||
Mapper_Vrc6( int sm )
|
||||
Mapper_Vrc6( )
|
||||
{
|
||||
swap_mask = sm;
|
||||
swap_mask = swapMask;
|
||||
vrc6_state_t* state = this;
|
||||
register_state( state, sizeof *state );
|
||||
}
|
||||
@ -82,8 +83,6 @@ public:
|
||||
vrc6_state_t::swap(); // to do: kind of hacky to swap in place
|
||||
}
|
||||
|
||||
virtual void read_state( mapper_state_t const& in );
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
enable_sram();
|
||||
@ -135,9 +134,6 @@ public:
|
||||
return no_irq;
|
||||
}
|
||||
|
||||
void write_bank( nes_addr_t, int data );
|
||||
void write_irq( nes_time_t, nes_addr_t, int data );
|
||||
|
||||
virtual void write( nes_time_t time, nes_addr_t addr, int data )
|
||||
{
|
||||
int osc = unsigned (addr - sound.base_addr) / sound.addr_step;
|
||||
@ -156,9 +152,9 @@ public:
|
||||
int swap_mask;
|
||||
Nes_Vrc6_Apu sound;
|
||||
enum { timer_period = 113 * 4 + 3 };
|
||||
};
|
||||
|
||||
void Mapper_Vrc6::read_state( mapper_state_t const& in )
|
||||
|
||||
void read_state( mapper_state_t const& in )
|
||||
{
|
||||
Nes_Mapper::read_state( in );
|
||||
vrc6_state_t::swap();
|
||||
@ -176,7 +172,7 @@ void Mapper_Vrc6::read_state( mapper_state_t const& in )
|
||||
sound.load_state( sound_state );
|
||||
}
|
||||
|
||||
void Mapper_Vrc6::write_irq( nes_time_t time, nes_addr_t addr, int data )
|
||||
void write_irq( nes_time_t time, nes_addr_t addr, int data )
|
||||
{
|
||||
// IRQ
|
||||
run_until( time );
|
||||
@ -202,7 +198,7 @@ void Mapper_Vrc6::write_irq( nes_time_t time, nes_addr_t addr, int data )
|
||||
irq_changed();
|
||||
}
|
||||
|
||||
void Mapper_Vrc6::write_bank( nes_addr_t addr, int data )
|
||||
void write_bank( nes_addr_t addr, int data )
|
||||
{
|
||||
switch ( addr & 0xf003 )
|
||||
{
|
||||
@ -241,21 +237,8 @@ void Mapper_Vrc6::write_bank( nes_addr_t addr, int data )
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static Nes_Mapper* make_vrc6a(void)
|
||||
{
|
||||
return new Mapper_Vrc6( 0 );
|
||||
}
|
||||
|
||||
static Nes_Mapper* make_vrc6b(void)
|
||||
{
|
||||
return new Mapper_Vrc6( 3 );
|
||||
}
|
||||
|
||||
void register_vrc6_mapper();
|
||||
void register_vrc6_mapper()
|
||||
{
|
||||
Nes_Mapper::register_mapper( 24, make_vrc6a );
|
||||
Nes_Mapper::register_mapper( 26, make_vrc6b );
|
||||
}
|
||||
typedef Mapper_Vrc6<0> Mapper024;
|
30
nes_emu/mappers/mapper025.hpp
Normal file
30
nes_emu/mappers/mapper025.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2004-2006 Shay Green
|
||||
* Copyright (C) 2007 CaH4e3
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* General code is from FCEUX https://sourceforge.net/p/fceultra/code/HEAD/tree/fceu/trunk/src/boards/vrc2and4.cpp
|
||||
* IRQ portion is from existing VRC6/VRC7 by Shay Green
|
||||
* This mapper was ported by retrowertz for Libretro port of QuickNES.
|
||||
* 3-19-2018
|
||||
*
|
||||
* VRC-2/VRC-4 Konami
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
typedef Mapper_VRC2_4<true,false> Mapper025;
|
9
nes_emu/mappers/mapper026.hpp
Normal file
9
nes_emu/mappers/mapper026.hpp
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// Konami VRC6 mapper
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
typedef Mapper_Vrc6<3> Mapper026;
|
@ -25,11 +25,15 @@
|
||||
* Tested only on Troll Burner and Mystic Origins demo.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_Unrom512 : public Nes_Mapper {
|
||||
// Unrom512
|
||||
|
||||
class Mapper030 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_Unrom512() { }
|
||||
Mapper030() { }
|
||||
|
||||
void reset_state() { }
|
||||
|
||||
@ -45,8 +49,3 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void register_unrom512_mapper();
|
||||
void register_unrom512_mapper()
|
||||
{
|
||||
register_mapper< Mapper_Unrom512> ( 30 );
|
||||
}
|
@ -21,6 +21,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct mapper32_state_t
|
||||
@ -33,9 +35,11 @@ struct mapper32_state_t
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof ( mapper32_state_t ) == 12 );
|
||||
|
||||
class Mapper_Irem_G101 : public Nes_Mapper, mapper32_state_t {
|
||||
// Irem_G101
|
||||
|
||||
class Mapper032 : public Nes_Mapper, mapper32_state_t {
|
||||
public:
|
||||
Mapper_Irem_G101()
|
||||
Mapper032()
|
||||
{
|
||||
mapper32_state_t * state = this;
|
||||
register_state( state, sizeof * state );
|
||||
@ -65,7 +69,7 @@ public:
|
||||
set_prg_bank ( 0xE000, bank_8k, ~0 );
|
||||
}
|
||||
|
||||
for ( int i = 0; i < sizeof chr_bank; i++)
|
||||
for ( unsigned long int i = 0; i < sizeof chr_bank; i++)
|
||||
set_chr_bank( ( i << 10 ), bank_1k, chr_bank [ i ] );
|
||||
|
||||
switch ( mirr )
|
||||
@ -113,8 +117,3 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void register_mapper_irem_g101();
|
||||
void register_mapper_irem_g101()
|
||||
{
|
||||
register_mapper< Mapper_Irem_G101 > ( 32 );
|
||||
}
|
@ -21,6 +21,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct tc0190_state_t
|
||||
@ -32,9 +34,11 @@ struct tc0190_state_t
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof ( tc0190_state_t ) == 9 );
|
||||
|
||||
class Mapper_TaitoTC0190 : public Nes_Mapper, tc0190_state_t {
|
||||
// TaitoTC0190
|
||||
|
||||
class Mapper033 : public Nes_Mapper, tc0190_state_t {
|
||||
public:
|
||||
Mapper_TaitoTC0190()
|
||||
Mapper033()
|
||||
{
|
||||
tc0190_state_t *state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -87,9 +91,3 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void register_mapper_taito_tc0190();
|
||||
void register_mapper_taito_tc0190()
|
||||
{
|
||||
register_mapper< Mapper_TaitoTC0190 > ( 33 );
|
||||
}
|
43
nes_emu/mappers/mapper034.hpp
Normal file
43
nes_emu/mappers/mapper034.hpp
Normal file
@ -0,0 +1,43 @@
|
||||
#pragma once
|
||||
|
||||
// Optional less-common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// Nina-1 (Deadly Towers only)
|
||||
|
||||
class Mapper034 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper034()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
write( 0, 0, bank );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int data )
|
||||
{
|
||||
bank = data;
|
||||
set_prg_bank( 0x8000, bank_32k, bank );
|
||||
}
|
||||
};
|
||||
|
@ -15,11 +15,15 @@
|
||||
* 4-in-1 Multicart ( Reset-based )
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_60 : public Nes_Mapper {
|
||||
// NROM-128 4-in-1 multicart
|
||||
|
||||
class Mapper060 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_60()
|
||||
Mapper060()
|
||||
{
|
||||
last_game = 2;
|
||||
register_state( &game_sel, 1 );
|
||||
@ -44,9 +48,3 @@ public:
|
||||
|
||||
uint8_t game_sel, last_game;
|
||||
};
|
||||
|
||||
void register_mapper_60();
|
||||
void register_mapper_60()
|
||||
{
|
||||
register_mapper< Mapper_60 > ( 60 );
|
||||
}
|
51
nes_emu/mappers/mapper066.hpp
Normal file
51
nes_emu/mappers/mapper066.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
// Optional less-common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// GNROM
|
||||
|
||||
class Mapper066 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper066()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
int b = bank;
|
||||
bank = ~b;
|
||||
write( 0, 0, b );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int data )
|
||||
{
|
||||
int changed = bank ^ data;
|
||||
bank = data;
|
||||
|
||||
if ( changed & 0x30 )
|
||||
set_prg_bank( 0x8000, bank_32k, bank >> 4 & 3 );
|
||||
|
||||
if ( changed & 0x03 )
|
||||
set_chr_bank( 0, bank_8k, bank & 3 );
|
||||
}
|
||||
};
|
||||
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
// Sunsoft FME-7 mapper
|
||||
|
||||
@ -44,9 +45,11 @@ void fme7_state_t::swap()
|
||||
set_le16( &sound_state.delays [i], sound_state.delays [i] );
|
||||
}
|
||||
|
||||
class Mapper_Fme7 : public Nes_Mapper, fme7_state_t {
|
||||
// Fme7
|
||||
|
||||
class Mapper069 : public Nes_Mapper, fme7_state_t {
|
||||
public:
|
||||
Mapper_Fme7()
|
||||
Mapper069()
|
||||
{
|
||||
fme7_state_t* state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -153,7 +156,7 @@ public:
|
||||
Nes_Fme7_Apu sound;
|
||||
};
|
||||
|
||||
void Mapper_Fme7::write_irq( nes_time_t time, int index, int data )
|
||||
void Mapper069::write_irq( nes_time_t time, int index, int data )
|
||||
{
|
||||
run_until( time );
|
||||
switch ( index )
|
||||
@ -174,7 +177,7 @@ void Mapper_Fme7::write_irq( nes_time_t time, int index, int data )
|
||||
}
|
||||
}
|
||||
|
||||
void Mapper_Fme7::write_register( int index, int data )
|
||||
void Mapper069::write_register( int index, int data )
|
||||
{
|
||||
regs [index] = data;
|
||||
int prg_bank = index - 0x09;
|
||||
@ -203,8 +206,3 @@ void Mapper_Fme7::write_register( int index, int data )
|
||||
}
|
||||
}
|
||||
|
||||
void register_fme7_mapper();
|
||||
void register_fme7_mapper()
|
||||
{
|
||||
register_mapper<Mapper_Fme7>( 69 );
|
||||
}
|
@ -21,9 +21,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
template < bool _is152 >
|
||||
// Mapper_74x161x162x32
|
||||
|
||||
template < int mapperId >
|
||||
class Mapper_74x161x162x32 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_74x161x162x32()
|
||||
@ -33,15 +37,15 @@ public:
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
if ( _is152 == 0 )
|
||||
if ( mapperId == 86 )
|
||||
bank = ~0;
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
if ( _is152 )
|
||||
write( 0, 0, bank );
|
||||
else
|
||||
if ( mapperId == 152 ) write( 0, 0, bank );
|
||||
if ( mapperId == 70 ) write( 0, 0, bank );
|
||||
if ( mapperId == 86 )
|
||||
{
|
||||
intercept_writes( 0x6000, 1 );
|
||||
write_intercepted( 0, 0x6000, bank );
|
||||
@ -50,8 +54,9 @@ public:
|
||||
|
||||
virtual bool write_intercepted( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
if ( ( addr != 0x6000 ) || _is152 )
|
||||
return false;
|
||||
if ( addr != 0x6000 ) return false;
|
||||
if ( mapperId == 152 ) return false;
|
||||
if ( mapperId == 70 ) return false;
|
||||
|
||||
bank = data;
|
||||
set_prg_bank( 0x8000, bank_32k, ( bank >> 4 ) & 0x03 );
|
||||
@ -62,7 +67,7 @@ public:
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
if ( _is152 == 0) return;
|
||||
if ( mapperId == 86) return;
|
||||
|
||||
bank = handle_bus_conflict (addr, data );
|
||||
set_prg_bank( 0x8000, bank_16k, ( bank >> 4 ) & 0x07 );
|
||||
@ -73,9 +78,4 @@ public:
|
||||
uint8_t bank;
|
||||
};
|
||||
|
||||
void register_mapper_74x161x162x32();
|
||||
void register_mapper_74x161x162x32()
|
||||
{
|
||||
register_mapper< Mapper_74x161x162x32 <true> > ( 152 );
|
||||
register_mapper< Mapper_74x161x162x32 <false> > ( 86 );
|
||||
}
|
||||
typedef Mapper_74x161x162x32<70> Mapper070;
|
56
nes_emu/mappers/mapper071.hpp
Normal file
56
nes_emu/mappers/mapper071.hpp
Normal file
@ -0,0 +1,56 @@
|
||||
// Optional less-common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// Camerica
|
||||
|
||||
class Mapper071 : public Nes_Mapper {
|
||||
uint8_t regs [3];
|
||||
public:
|
||||
Mapper071()
|
||||
{
|
||||
register_state( regs, sizeof regs );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
write( 0, 0xc000, regs [0] );
|
||||
if ( regs [1] & 0x80 )
|
||||
write( 0, 0x9000, regs [1] );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
if ( addr >= 0xc000 )
|
||||
{
|
||||
regs [0] = data;
|
||||
set_prg_bank( 0x8000, bank_16k, data );
|
||||
}
|
||||
else if ( (addr & 0xf000) == 0x9000 )
|
||||
{
|
||||
regs [1] = 0x80 | data;
|
||||
mirror_single( (data >> 4) & 1 );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
* VRC-3 Konami, Salamander
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct vrc3_state_t
|
||||
@ -34,9 +36,11 @@ struct vrc3_state_t
|
||||
uint16_t next_time;
|
||||
};
|
||||
|
||||
class Mapper_VRC3 : public Nes_Mapper, vrc3_state_t {
|
||||
// VRC3
|
||||
|
||||
class Mapper073 : public Nes_Mapper, vrc3_state_t {
|
||||
public:
|
||||
Mapper_VRC3()
|
||||
Mapper073()
|
||||
{
|
||||
vrc3_state_t * state = this;
|
||||
register_state( state, sizeof * state );
|
||||
@ -126,8 +130,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void register_vrc3_mapper();
|
||||
void register_vrc3_mapper()
|
||||
{
|
||||
register_mapper< Mapper_VRC3> ( 73 );
|
||||
}
|
||||
// void register_vrc3_mapper();
|
||||
// void register_vrc3_mapper()
|
||||
// {
|
||||
// register_mapper< Mapper073> ( 73 );
|
||||
// }
|
@ -15,6 +15,8 @@
|
||||
* VRC-1 Konami
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct vrc1_state_t
|
||||
@ -27,9 +29,11 @@ struct vrc1_state_t
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof ( vrc1_state_t ) == 8 );
|
||||
|
||||
class Mapper_VRC1 : public Nes_Mapper, vrc1_state_t {
|
||||
// VRC1
|
||||
|
||||
class Mapper075 : public Nes_Mapper, vrc1_state_t {
|
||||
public:
|
||||
Mapper_VRC1()
|
||||
Mapper075()
|
||||
{
|
||||
vrc1_state_t * state = this;
|
||||
register_state( state, sizeof * state );
|
||||
@ -85,20 +89,20 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void Mapper_VRC1::update_prg_banks()
|
||||
void Mapper075::update_prg_banks()
|
||||
{
|
||||
set_prg_bank( 0x8000, bank_8k, prg_banks [ 0 ] );
|
||||
set_prg_bank( 0xa000, bank_8k, prg_banks [ 1 ] );
|
||||
set_prg_bank( 0xc000, bank_8k, prg_banks [ 2 ] );
|
||||
}
|
||||
|
||||
void Mapper_VRC1::update_chr_banks()
|
||||
void Mapper075::update_chr_banks()
|
||||
{
|
||||
set_chr_bank( 0x0000, bank_4k, chr_banks [ 0 ] | chr_banks_hi [ 0 ] );
|
||||
set_chr_bank( 0x1000, bank_4k, chr_banks [ 1 ] | chr_banks_hi [ 1 ] );
|
||||
}
|
||||
|
||||
void Mapper_VRC1::update_mirroring()
|
||||
void Mapper075::update_mirroring()
|
||||
{
|
||||
switch ( mirroring & 1 )
|
||||
{
|
||||
@ -106,9 +110,3 @@ void Mapper_VRC1::update_mirroring()
|
||||
case 0: mirror_vert(); break;
|
||||
}
|
||||
}
|
||||
|
||||
void register_vrc1_mapper();
|
||||
void register_vrc1_mapper()
|
||||
{
|
||||
register_mapper< Mapper_VRC1> ( 75 );
|
||||
}
|
74
nes_emu/mappers/mapper078.hpp
Normal file
74
nes_emu/mappers/mapper078.hpp
Normal file
@ -0,0 +1,74 @@
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
// Holy Diver and Uchuusen - Cosmo Carrier.
|
||||
|
||||
class Mapper078 : public Nes_Mapper {
|
||||
// lower 8 bits are the reg at 8000:ffff
|
||||
// next two bits are autodetecting type
|
||||
// 0 = unknown 1 = cosmo carrier 2 = holy diver
|
||||
int reg;
|
||||
void writeinternal(int data, int changed)
|
||||
{
|
||||
reg &= 0x300;
|
||||
reg |= data;
|
||||
|
||||
if (changed & 0x07)
|
||||
set_prg_bank(0x8000, bank_16k, reg & 0x07);
|
||||
if (changed & 0xf0)
|
||||
set_chr_bank(0x0000, bank_8k, (reg >> 4) & 0x0f);
|
||||
if (changed & 0x08)
|
||||
{
|
||||
// set mirroring based on memorized board type
|
||||
if (reg & 0x100)
|
||||
{
|
||||
mirror_single((reg >> 3) & 1);
|
||||
}
|
||||
else if (reg & 0x200)
|
||||
{
|
||||
if (reg & 0x08)
|
||||
mirror_vert();
|
||||
else
|
||||
mirror_horiz();
|
||||
}
|
||||
else
|
||||
{
|
||||
// if you don't set something here, holy diver dumps with 4sc set will
|
||||
// savestate as 4k NTRAM. then when you later set H\V mapping, state size mismatch.
|
||||
mirror_single(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
Mapper078()
|
||||
{
|
||||
register_state(®, 4);
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
reg = 0;
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
writeinternal(reg, 0xff);
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data)
|
||||
{
|
||||
// heuristic: if the first write ever to the register is 0,
|
||||
// we're on holy diver, otherwise, carrier. it works for these two games...
|
||||
if (!(reg & 0x300))
|
||||
{
|
||||
reg |= data ? 0x100 : 0x200;
|
||||
writeinternal(data, 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
writeinternal(data, reg ^ data);
|
||||
}
|
||||
}
|
||||
};
|
@ -25,6 +25,8 @@
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
template < bool multicart >
|
||||
class Mapper_AveNina : public Nes_Mapper {
|
||||
public:
|
||||
@ -85,9 +87,4 @@ void Mapper_AveNina< multicart >::write_regs()
|
||||
}
|
||||
}
|
||||
|
||||
void register_mapper_avenina();
|
||||
void register_mapper_avenina()
|
||||
{
|
||||
register_mapper < Mapper_AveNina < false > > ( 79 );
|
||||
register_mapper < Mapper_AveNina < true > > ( 113 );
|
||||
}
|
||||
typedef Mapper_AveNina<false> Mapper079;
|
@ -5,6 +5,8 @@
|
||||
#include "blargg_endian.h"
|
||||
#include <string.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
/* Copyright (C) 2004-2005 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
@ -34,9 +36,11 @@ struct vrc7_state_t
|
||||
};
|
||||
BOOST_STATIC_ASSERT( sizeof (vrc7_state_t) == 20 + sizeof (vrc7_snapshot_t) );
|
||||
|
||||
class Mapper_Vrc7 : public Nes_Mapper, vrc7_state_t {
|
||||
// Vrc7
|
||||
|
||||
class Mapper085 : public Nes_Mapper, vrc7_state_t {
|
||||
public:
|
||||
Mapper_Vrc7()
|
||||
Mapper085()
|
||||
{
|
||||
vrc7_state_t* state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -115,7 +119,7 @@ public:
|
||||
|
||||
void apply_mapping()
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for ( i = 0; i < sizeof prg_banks; i++ )
|
||||
write_prg_bank( i, prg_banks [i] );
|
||||
@ -218,8 +222,3 @@ public:
|
||||
enum { timer_period = 113 * 4 + 3 };
|
||||
};
|
||||
|
||||
void register_vrc7_mapper();
|
||||
void register_vrc7_mapper()
|
||||
{
|
||||
register_mapper< Mapper_Vrc7 > ( 85 );
|
||||
}
|
24
nes_emu/mappers/mapper086.hpp
Normal file
24
nes_emu/mappers/mapper086.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2018
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* This mapper was added by retrowertz for Libretro port of QuickNES.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef Mapper_74x161x162x32<86> Mapper086;
|
51
nes_emu/mappers/mapper087.hpp
Normal file
51
nes_emu/mappers/mapper087.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
// Optional less-common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// Jaleco/Konami/Taito
|
||||
|
||||
class Mapper087 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper087()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
void apply_mapping()
|
||||
{
|
||||
intercept_writes( 0x6000, 1 );
|
||||
write( 0, 0x6000, bank );
|
||||
}
|
||||
|
||||
bool write_intercepted( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
if ( addr != 0x6000 )
|
||||
return false;
|
||||
|
||||
bank = data;
|
||||
set_chr_bank( 0, bank_8k, data >> 1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
void write( nes_time_t, nes_addr_t, int ) { }
|
||||
};
|
||||
|
@ -23,23 +23,25 @@
|
||||
* Mapper 206
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct namco_34xx_state_t
|
||||
struct namco_34x3_state_t
|
||||
{
|
||||
uint8_t bank [ 8 ];
|
||||
uint8_t mirr;
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof (namco_34xx_state_t) == 10 );
|
||||
BOOST_STATIC_ASSERT( sizeof (namco_34x3_state_t) == 10 );
|
||||
|
||||
template < bool _is154 >
|
||||
class Mapper_Namco_34x3 : public Nes_Mapper, namco_34xx_state_t {
|
||||
class Mapper_Namco_34x3 : public Nes_Mapper, namco_34x3_state_t {
|
||||
public:
|
||||
Mapper_Namco_34x3()
|
||||
{
|
||||
namco_34xx_state_t *state = this;
|
||||
namco_34x3_state_t *state = this;
|
||||
register_state( state, sizeof *state );
|
||||
}
|
||||
|
||||
@ -98,63 +100,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class Mapper_Namco_34xx : public Nes_Mapper, namco_34xx_state_t {
|
||||
public:
|
||||
Mapper_Namco_34xx()
|
||||
{
|
||||
namco_34xx_state_t *state = this;
|
||||
register_state( state, sizeof *state );
|
||||
}
|
||||
typedef Mapper_Namco_34x3<false> Mapper088;
|
||||
|
||||
virtual void reset_state()
|
||||
{ }
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
set_chr_bank( 0x0000, bank_2k, bank [ 0 ] );
|
||||
set_chr_bank( 0x0800, bank_2k, bank [ 1 ] );
|
||||
for ( int i = 0; i < 4; i++ )
|
||||
set_chr_bank( 0x1000 + ( i << 10 ), bank_1k, bank [ i + 2 ] );
|
||||
|
||||
set_prg_bank( 0x8000, bank_8k, bank [ 6 ] );
|
||||
set_prg_bank( 0xA000, bank_8k, bank [ 7 ] );
|
||||
set_prg_bank( 0xC000, bank_8k, ~1 );
|
||||
set_prg_bank( 0xE000, bank_8k, ~0 );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
switch ( addr & 0xE001 )
|
||||
{
|
||||
case 0x8000:
|
||||
mode = data;
|
||||
break;
|
||||
case 0x8001:
|
||||
mode &= 0x07;
|
||||
switch ( mode )
|
||||
{
|
||||
case 0: case 1:
|
||||
bank [ mode ] = data >> 1;
|
||||
set_chr_bank( 0x0000 + ( mode << 11 ), bank_2k, bank [ mode ] );
|
||||
break;
|
||||
case 2: case 3: case 4: case 5:
|
||||
bank [ mode ] = data;
|
||||
set_chr_bank( 0x1000 + ( ( mode - 2 ) << 10 ), bank_1k, bank [ mode ] );
|
||||
break;
|
||||
case 6: case 7:
|
||||
bank [ mode ] = data;
|
||||
set_prg_bank( 0x8000 + ( ( mode - 6 ) << 13 ), bank_8k, bank [ mode ] );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void register_mapper_namco_34xx();
|
||||
void register_mapper_namco_34xx()
|
||||
{
|
||||
register_mapper< Mapper_Namco_34x3 <false> > ( 88 );
|
||||
register_mapper< Mapper_Namco_34x3 <true> > ( 154 );
|
||||
register_mapper< Mapper_Namco_34xx > ( 206 );
|
||||
}
|
||||
// void register_mapper_namco_34xx();
|
||||
// void register_mapper_namco_34xx()
|
||||
// {
|
||||
// register_mapper< Mapper_Namco_34x3 <false> > ( 88 );
|
||||
// register_mapper< Mapper_Namco_34x3 <true> > ( 154 );
|
||||
// register_mapper< Mapper_Namco_34xx > ( 206 );
|
||||
// }
|
@ -20,38 +20,15 @@
|
||||
* Mapper 93 - Sunsoft-2
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_Sunsoft2a : public Nes_Mapper {
|
||||
// Sunsoft2b
|
||||
|
||||
class Mapper089 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_Sunsoft2a()
|
||||
{
|
||||
register_state( ®s, 1 );
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
set_prg_bank( 0xC000, bank_16k, last_bank );
|
||||
write( 0, 0x8000, regs );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
regs = handle_bus_conflict( addr, data );
|
||||
|
||||
set_chr_bank( 0x0000, bank_8k, data & 0x0F );
|
||||
set_prg_bank( 0x8000, bank_16k, ( data >> 4 ) & 0x07 );
|
||||
}
|
||||
|
||||
uint8_t regs;
|
||||
};
|
||||
|
||||
class Mapper_Sunsoft2b : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_Sunsoft2b()
|
||||
Mapper089()
|
||||
{
|
||||
register_state( ®s, 1 );
|
||||
}
|
||||
@ -76,10 +53,3 @@ public:
|
||||
|
||||
uint8_t regs;
|
||||
};
|
||||
|
||||
void register_mapper_sunsoft2();
|
||||
void register_mapper_sunsoft2()
|
||||
{
|
||||
register_mapper< Mapper_Sunsoft2a > ( 93 );
|
||||
register_mapper< Mapper_Sunsoft2b > ( 89 );
|
||||
}
|
54
nes_emu/mappers/mapper093.hpp
Normal file
54
nes_emu/mappers/mapper093.hpp
Normal file
@ -0,0 +1,54 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2018
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* This mapper was added by retrowertz for Libretro port of QuickNES.
|
||||
*
|
||||
* Mapper 93 - Sunsoft-2
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
// Sunsoft2a
|
||||
|
||||
class Mapper093 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper093()
|
||||
{
|
||||
register_state( ®s, 1 );
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
set_prg_bank( 0xC000, bank_16k, last_bank );
|
||||
write( 0, 0x8000, regs );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
regs = handle_bus_conflict( addr, data );
|
||||
|
||||
set_chr_bank( 0x0000, bank_8k, data & 0x0F );
|
||||
set_prg_bank( 0x8000, bank_16k, ( data >> 4 ) & 0x07 );
|
||||
}
|
||||
|
||||
uint8_t regs;
|
||||
};
|
@ -22,11 +22,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_Un1rom : public Nes_Mapper {
|
||||
// Un1rom
|
||||
|
||||
class Mapper094 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_Un1rom()
|
||||
Mapper094()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
@ -47,9 +51,3 @@ public:
|
||||
|
||||
uint8_t bank;
|
||||
};
|
||||
|
||||
void register_mapper_un1rom();
|
||||
void register_mapper_un1rom()
|
||||
{
|
||||
register_mapper< Mapper_Un1rom > ( 94 );
|
||||
}
|
@ -21,11 +21,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_Irem_Tam_S1 : public Nes_Mapper {
|
||||
// Irem_Tam_S1
|
||||
|
||||
class Mapper097 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_Irem_Tam_S1()
|
||||
Mapper097()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
@ -57,9 +61,3 @@ public:
|
||||
|
||||
uint8_t bank;
|
||||
};
|
||||
|
||||
void register_mapper_irem_tamS1();
|
||||
void register_mapper_irem_tamS1()
|
||||
{
|
||||
register_mapper< Mapper_Irem_Tam_S1 > ( 97 );
|
||||
}
|
28
nes_emu/mappers/mapper113.hpp
Normal file
28
nes_emu/mappers/mapper113.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2018
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*
|
||||
* This mapper was added by retrowertz for Libretro port of QuickNES.
|
||||
*
|
||||
* Mapper 079
|
||||
* Mapper 113
|
||||
* Nina-03 / Nina-06
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef Mapper_AveNina<true> Mapper113;
|
@ -22,11 +22,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_Jaleco_JF11 : public Nes_Mapper {
|
||||
// Jaleco_JF11
|
||||
|
||||
class Mapper140 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_Jaleco_JF11()
|
||||
Mapper140()
|
||||
{
|
||||
register_state( ®s, 1 );
|
||||
}
|
||||
@ -57,9 +61,3 @@ public:
|
||||
|
||||
uint8_t regs;
|
||||
};
|
||||
|
||||
void register_mapper_jaleco_jf11();
|
||||
void register_mapper_jaleco_jf11()
|
||||
{
|
||||
register_mapper< Mapper_Jaleco_JF11 > ( 140 );
|
||||
}
|
24
nes_emu/mappers/mapper152.hpp
Normal file
24
nes_emu/mappers/mapper152.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2018
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* This mapper was added by retrowertz for Libretro port of QuickNES.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef Mapper_74x161x162x32<152> Mapper152;
|
28
nes_emu/mappers/mapper154.hpp
Normal file
28
nes_emu/mappers/mapper154.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2018
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* This mapper was added by retrowertz for Libretro port of QuickNES.
|
||||
* 3/24/18
|
||||
*
|
||||
* Mapper 88
|
||||
* Mapper 154
|
||||
* Mapper 206
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef Mapper_Namco_34x3<true> Mapper154;
|
59
nes_emu/mappers/mapper156.hpp
Normal file
59
nes_emu/mappers/mapper156.hpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
// DIS23C01 DAOU ROM CONTROLLER
|
||||
|
||||
struct m156_state_t
|
||||
{
|
||||
uint8_t prg_bank;
|
||||
uint8_t chr_banks [8];
|
||||
};
|
||||
BOOST_STATIC_ASSERT( sizeof (m156_state_t) == 9 );
|
||||
|
||||
class Mapper156 : public Nes_Mapper, m156_state_t {
|
||||
public:
|
||||
Mapper156()
|
||||
{
|
||||
m156_state_t * state = this;
|
||||
register_state( state, sizeof * state );
|
||||
}
|
||||
|
||||
void reset_state()
|
||||
{
|
||||
prg_bank = 0;
|
||||
for ( unsigned i = 0; i < 8; i++ ) chr_banks [i] = i;
|
||||
enable_sram();
|
||||
apply_mapping();
|
||||
}
|
||||
|
||||
void apply_mapping()
|
||||
{
|
||||
mirror_single( 0 );
|
||||
set_prg_bank( 0x8000, bank_16k, prg_bank );
|
||||
|
||||
for ( int i = 0; i < (int) sizeof chr_banks; i++ )
|
||||
set_chr_bank( i * 0x400, bank_1k, chr_banks [i] );
|
||||
}
|
||||
|
||||
void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
unsigned int reg = addr - 0xC000;
|
||||
if ( addr == 0xC010 )
|
||||
{
|
||||
prg_bank = data;
|
||||
set_prg_bank( 0x8000, bank_16k, data );
|
||||
}
|
||||
else if ( reg < 4 )
|
||||
{
|
||||
chr_banks [reg] = data;
|
||||
set_chr_bank( reg * 0x400, bank_1k, data );
|
||||
}
|
||||
else if ( ( reg - 8 ) < 4 )
|
||||
{
|
||||
reg -= 4;
|
||||
chr_banks [reg] = data;
|
||||
set_chr_bank( reg * 0x400, bank_1k, data );
|
||||
}
|
||||
}
|
||||
};
|
@ -21,11 +21,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_180 : public Nes_Mapper {
|
||||
// UxROM (inverted)
|
||||
|
||||
class Mapper180 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_180()
|
||||
Mapper180()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
@ -47,9 +51,3 @@ public:
|
||||
|
||||
uint8_t bank;
|
||||
};
|
||||
|
||||
void register_mapper_180();
|
||||
void register_mapper_180()
|
||||
{
|
||||
register_mapper< Mapper_180 > ( 180 );
|
||||
}
|
@ -20,11 +20,15 @@
|
||||
* Mapper 184 - Sunsoft-1
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_Sunsoft1 : public Nes_Mapper {
|
||||
// Sunsoft1
|
||||
|
||||
class Mapper184 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_Sunsoft1()
|
||||
Mapper184()
|
||||
{
|
||||
register_state( ®s, 1 );
|
||||
}
|
||||
@ -57,8 +61,3 @@ public:
|
||||
uint8_t regs;
|
||||
};
|
||||
|
||||
void register_mapper_sunsoft1();
|
||||
void register_mapper_sunsoft1()
|
||||
{
|
||||
register_mapper< Mapper_Sunsoft1 > ( 184 );
|
||||
}
|
55
nes_emu/mappers/mapper190.hpp
Normal file
55
nes_emu/mappers/mapper190.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
// Magic Kid Googoo
|
||||
|
||||
class Mapper190: public Nes_Mapper {
|
||||
public:
|
||||
Mapper190()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
mirror_vert();
|
||||
enable_sram();
|
||||
set_prg_bank( 0xc000, bank_16k, 0);
|
||||
}
|
||||
|
||||
virtual void write(nes_time_t, nes_addr_t addr, int data)
|
||||
{
|
||||
switch ( addr >> 12 )
|
||||
{
|
||||
case 0x8:
|
||||
case 0x9:
|
||||
case 0xc:
|
||||
case 0xd:
|
||||
set_prg_bank( 0x8000, bank_16k, ( ( ( addr >> 11 ) & 8 ) | ( data & 7 ) ) );
|
||||
break;
|
||||
case 0xa:
|
||||
case 0xb:
|
||||
switch ( addr & 3 )
|
||||
{
|
||||
case 0:
|
||||
set_chr_bank( 0x0000, bank_2k, data );
|
||||
break;
|
||||
case 1:
|
||||
set_chr_bank( 0x0800, bank_2k, data );
|
||||
break;
|
||||
case 2:
|
||||
set_chr_bank( 0x1000, bank_2k, data );
|
||||
break;
|
||||
case 3:
|
||||
set_chr_bank( 0x1800, bank_2k, data );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -23,11 +23,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_193 : public Nes_Mapper {
|
||||
// NTDEC's TC-112 mapper IC.
|
||||
|
||||
class Mapper193 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_193()
|
||||
Mapper193()
|
||||
{
|
||||
register_state( regs, sizeof regs );
|
||||
}
|
||||
@ -37,7 +41,7 @@ public:
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
for ( int i = 0; i < sizeof regs; i++ )
|
||||
for ( size_t i = 0; i < sizeof regs; i++ )
|
||||
write_intercepted( 0, 0x6000 + i, regs [ i ] );
|
||||
set_prg_bank( 0xA000, bank_8k, ~2 );
|
||||
set_prg_bank( 0xC000, bank_8k, ~1 );
|
||||
@ -68,8 +72,3 @@ public:
|
||||
uint8_t regs [ 4 ];
|
||||
};
|
||||
|
||||
void register_mapper_193();
|
||||
void register_mapper_193()
|
||||
{
|
||||
register_mapper< Mapper_193 > ( 193 );
|
||||
}
|
93
nes_emu/mappers/mapper206.hpp
Normal file
93
nes_emu/mappers/mapper206.hpp
Normal file
@ -0,0 +1,93 @@
|
||||
/* Copyright notice for this file:
|
||||
* Copyright (C) 2018
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* This mapper was added by retrowertz for Libretro port of QuickNES.
|
||||
* 3/24/18
|
||||
*
|
||||
* Mapper 88
|
||||
* Mapper 154
|
||||
* Mapper 206
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct namco_34xx_state_t
|
||||
{
|
||||
uint8_t bank [ 8 ];
|
||||
uint8_t mirr;
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof (namco_34xx_state_t) == 10 );
|
||||
|
||||
// Namco_34xx
|
||||
|
||||
class Mapper206 : public Nes_Mapper, namco_34xx_state_t {
|
||||
public:
|
||||
Mapper206()
|
||||
{
|
||||
namco_34xx_state_t *state = this;
|
||||
register_state( state, sizeof *state );
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{ }
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
set_chr_bank( 0x0000, bank_2k, bank [ 0 ] );
|
||||
set_chr_bank( 0x0800, bank_2k, bank [ 1 ] );
|
||||
for ( int i = 0; i < 4; i++ )
|
||||
set_chr_bank( 0x1000 + ( i << 10 ), bank_1k, bank [ i + 2 ] );
|
||||
|
||||
set_prg_bank( 0x8000, bank_8k, bank [ 6 ] );
|
||||
set_prg_bank( 0xA000, bank_8k, bank [ 7 ] );
|
||||
set_prg_bank( 0xC000, bank_8k, ~1 );
|
||||
set_prg_bank( 0xE000, bank_8k, ~0 );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
switch ( addr & 0xE001 )
|
||||
{
|
||||
case 0x8000:
|
||||
mode = data;
|
||||
break;
|
||||
case 0x8001:
|
||||
mode &= 0x07;
|
||||
switch ( mode )
|
||||
{
|
||||
case 0: case 1:
|
||||
bank [ mode ] = data >> 1;
|
||||
set_chr_bank( 0x0000 + ( mode << 11 ), bank_2k, bank [ mode ] );
|
||||
break;
|
||||
case 2: case 3: case 4: case 5:
|
||||
bank [ mode ] = data;
|
||||
set_chr_bank( 0x1000 + ( ( mode - 2 ) << 10 ), bank_1k, bank [ mode ] );
|
||||
break;
|
||||
case 6: case 7:
|
||||
bank [ mode ] = data;
|
||||
set_prg_bank( 0x8000 + ( ( mode - 6 ) << 13 ), bank_8k, bank [ mode ] );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -21,6 +21,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
struct taito_x1005_state_t
|
||||
@ -32,9 +34,11 @@ struct taito_x1005_state_t
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof (taito_x1005_state_t) == 11 );
|
||||
|
||||
class Mapper_TaitoX1005 : public Nes_Mapper, taito_x1005_state_t {
|
||||
// TaitoX1005
|
||||
|
||||
class Mapper207 : public Nes_Mapper, taito_x1005_state_t {
|
||||
public:
|
||||
Mapper_TaitoX1005()
|
||||
Mapper207()
|
||||
{
|
||||
taito_x1005_state_t *state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -85,8 +89,3 @@ public:
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data ) { }
|
||||
};
|
||||
|
||||
void register_mapper_taito_x1005();
|
||||
void register_mapper_taito_x1005()
|
||||
{
|
||||
register_mapper< Mapper_TaitoX1005 > ( 207 );
|
||||
}
|
55
nes_emu/mappers/mapper232.hpp
Normal file
55
nes_emu/mappers/mapper232.hpp
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// Optional less-common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// Quattro
|
||||
|
||||
class Mapper232 : public Nes_Mapper {
|
||||
uint8_t regs [2];
|
||||
public:
|
||||
Mapper232()
|
||||
{
|
||||
register_state( regs, sizeof regs );
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
regs [0] = 0;
|
||||
regs [1] = 3;
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
int bank = regs [0] >> 1 & 0x0c;
|
||||
set_prg_bank( 0x8000, bank_16k, bank + (regs [1] & 3) );
|
||||
set_prg_bank( 0xC000, bank_16k, bank + 3 );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
if ( addr < 0xc000 )
|
||||
regs [0] = data;
|
||||
else
|
||||
regs [1] = data;
|
||||
Mapper232::apply_mapping();
|
||||
}
|
||||
};
|
||||
|
@ -19,11 +19,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_240 : public Nes_Mapper {
|
||||
// https://www.nesdev.org/wiki/INES_Mapper240
|
||||
|
||||
class Mapper240 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_240()
|
||||
Mapper240()
|
||||
{
|
||||
register_state( ®s, 1 );
|
||||
}
|
||||
@ -56,9 +60,3 @@ public:
|
||||
|
||||
uint8_t regs;
|
||||
};
|
||||
|
||||
void register_mapper_240();
|
||||
void register_mapper_240()
|
||||
{
|
||||
register_mapper< Mapper_240 > ( 240 );
|
||||
}
|
@ -19,11 +19,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_241 : public Nes_Mapper {
|
||||
// https://www.nesdev.org/wiki/INES_Mapper241
|
||||
|
||||
class Mapper241 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_241()
|
||||
Mapper241()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
@ -45,9 +49,3 @@ public:
|
||||
|
||||
uint8_t bank;
|
||||
};
|
||||
|
||||
void register_mapper_241();
|
||||
void register_mapper_241()
|
||||
{
|
||||
register_mapper< Mapper_241 > ( 241 );
|
||||
}
|
@ -21,8 +21,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
// https://www.nesdev.org/wiki/INES_Mapper244
|
||||
|
||||
struct mapper244_state_t
|
||||
{
|
||||
uint8_t preg;
|
||||
@ -31,9 +35,9 @@ struct mapper244_state_t
|
||||
|
||||
BOOST_STATIC_ASSERT( sizeof (mapper244_state_t) == 2 );
|
||||
|
||||
class Mapper_244 : public Nes_Mapper, mapper244_state_t {
|
||||
class Mapper244 : public Nes_Mapper, mapper244_state_t {
|
||||
public:
|
||||
Mapper_244()
|
||||
Mapper244()
|
||||
{
|
||||
mapper244_state_t *state = this;
|
||||
register_state( state, sizeof *state );
|
||||
@ -63,9 +67,3 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void register_mapper_244();
|
||||
void register_mapper_244()
|
||||
{
|
||||
register_mapper< Mapper_244 > ( 244 );
|
||||
}
|
@ -21,11 +21,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
class Mapper_246 : public Nes_Mapper {
|
||||
// https://www.nesdev.org/wiki/INES_Mapper246
|
||||
|
||||
class Mapper246 : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_246()
|
||||
Mapper246()
|
||||
{
|
||||
register_state( regs, sizeof regs );
|
||||
}
|
||||
@ -39,7 +43,7 @@ public:
|
||||
{
|
||||
enable_sram();
|
||||
intercept_writes( 0x6000, 0x07 );
|
||||
for ( int i = 0; i < sizeof regs; i++ )
|
||||
for ( size_t i = 0; i < sizeof regs; i++ )
|
||||
write_intercepted( 0, 0x6000 + i, regs [ i ] );
|
||||
}
|
||||
|
||||
@ -68,8 +72,3 @@ public:
|
||||
uint8_t regs [ 8 ];
|
||||
};
|
||||
|
||||
void register_mapper_246();
|
||||
void register_mapper_246()
|
||||
{
|
||||
register_mapper< Mapper_246 > ( 246 );
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
|
||||
// Optional less-common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// Nina-1 (Deadly Towers only)
|
||||
|
||||
class Mapper_Nina1 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper_Nina1()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
write( 0, 0, bank );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int data )
|
||||
{
|
||||
bank = data;
|
||||
set_prg_bank( 0x8000, bank_32k, bank );
|
||||
}
|
||||
};
|
||||
|
||||
// GNROM
|
||||
|
||||
class Mapper_Gnrom : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper_Gnrom()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
int b = bank;
|
||||
bank = ~b;
|
||||
write( 0, 0, b );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int data )
|
||||
{
|
||||
int changed = bank ^ data;
|
||||
bank = data;
|
||||
|
||||
if ( changed & 0x30 )
|
||||
set_prg_bank( 0x8000, bank_32k, bank >> 4 & 3 );
|
||||
|
||||
if ( changed & 0x03 )
|
||||
set_chr_bank( 0, bank_8k, bank & 3 );
|
||||
}
|
||||
};
|
||||
|
||||
// Color Dreams
|
||||
|
||||
class Mapper_Color_Dreams : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper_Color_Dreams()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
int b = bank;
|
||||
bank = ~b;
|
||||
write( 0, 0, b );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int data )
|
||||
{
|
||||
int changed = bank ^ data;
|
||||
bank = data;
|
||||
|
||||
if ( changed & 0x0f )
|
||||
set_prg_bank( 0x8000, bank_32k, bank & 0x0f );
|
||||
|
||||
if ( changed & 0xf0 )
|
||||
set_chr_bank( 0, bank_8k, bank >> 4 );
|
||||
}
|
||||
};
|
||||
|
||||
// Jaleco/Konami
|
||||
|
||||
class Mapper_87 : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper_87()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
void apply_mapping()
|
||||
{
|
||||
intercept_writes( 0x6000, 1 );
|
||||
write( 0, 0x6000, bank );
|
||||
}
|
||||
|
||||
bool write_intercepted( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
if ( addr != 0x6000 )
|
||||
return false;
|
||||
|
||||
bank = data;
|
||||
set_chr_bank( 0, bank_8k, data >> 1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
void write( nes_time_t, nes_addr_t, int ) { }
|
||||
};
|
||||
|
||||
// Camerica
|
||||
|
||||
class Mapper_Camerica : public Nes_Mapper {
|
||||
uint8_t regs [3];
|
||||
public:
|
||||
Mapper_Camerica()
|
||||
{
|
||||
register_state( regs, sizeof regs );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
write( 0, 0xc000, regs [0] );
|
||||
if ( regs [1] & 0x80 )
|
||||
write( 0, 0x9000, regs [1] );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
if ( addr >= 0xc000 )
|
||||
{
|
||||
regs [0] = data;
|
||||
set_prg_bank( 0x8000, bank_16k, data );
|
||||
}
|
||||
else if ( (addr & 0xf000) == 0x9000 )
|
||||
{
|
||||
regs [1] = 0x80 | data;
|
||||
mirror_single( (data >> 4) & 1 );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Quattro
|
||||
|
||||
class Mapper_Quattro : public Nes_Mapper {
|
||||
uint8_t regs [2];
|
||||
public:
|
||||
Mapper_Quattro()
|
||||
{
|
||||
register_state( regs, sizeof regs );
|
||||
}
|
||||
|
||||
virtual void reset_state()
|
||||
{
|
||||
regs [0] = 0;
|
||||
regs [1] = 3;
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
int bank = regs [0] >> 1 & 0x0c;
|
||||
set_prg_bank( 0x8000, bank_16k, bank + (regs [1] & 3) );
|
||||
set_prg_bank( 0xC000, bank_16k, bank + 3 );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
if ( addr < 0xc000 )
|
||||
regs [0] = data;
|
||||
else
|
||||
regs [1] = data;
|
||||
Mapper_Quattro::apply_mapping();
|
||||
}
|
||||
};
|
||||
|
||||
void register_misc_mappers();
|
||||
void register_misc_mappers()
|
||||
{
|
||||
register_mapper<Mapper_Color_Dreams>( 11 );
|
||||
register_mapper<Mapper_Nina1>( 34 );
|
||||
register_mapper<Mapper_Gnrom>( 66 );
|
||||
register_mapper<Mapper_Camerica>( 71 );
|
||||
register_mapper<Mapper_87>( 87 );
|
||||
register_mapper<Mapper_Quattro>( 232 );
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
|
||||
// Common simple mappers
|
||||
|
||||
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
|
||||
|
||||
#include "Nes_Mapper.h"
|
||||
|
||||
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you
|
||||
can redistribute it and/or modify it under the terms of the GNU Lesser
|
||||
General Public License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version. This
|
||||
module 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 Lesser General Public License for
|
||||
more details. You should have received a copy of the GNU Lesser General
|
||||
Public License along with this module; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#include "blargg_source.h"
|
||||
|
||||
// NROM
|
||||
|
||||
class Mapper_Nrom : public Nes_Mapper {
|
||||
public:
|
||||
Mapper_Nrom() { }
|
||||
|
||||
virtual void apply_mapping() { }
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int )
|
||||
{
|
||||
// empty
|
||||
}
|
||||
};
|
||||
|
||||
Nes_Mapper* Nes_Mapper::make_nrom() { return new Mapper_Nrom; }
|
||||
|
||||
// UNROM
|
||||
|
||||
class Mapper_Unrom : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper_Unrom()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
enable_sram(); // at least one UNROM game needs sram (Bomberman 2)
|
||||
set_prg_bank( 0x8000, bank_16k, bank );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
bank = handle_bus_conflict( addr, data );
|
||||
set_prg_bank( 0x8000, bank_16k, bank );
|
||||
}
|
||||
};
|
||||
|
||||
Nes_Mapper* Nes_Mapper::make_unrom() { return new Mapper_Unrom; }
|
||||
|
||||
// AOROM
|
||||
|
||||
class Mapper_Aorom : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper_Aorom()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
int b = bank;
|
||||
bank = ~b; // force update
|
||||
write( 0, 0, b );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t, int data )
|
||||
{
|
||||
int changed = bank ^ data;
|
||||
bank = data;
|
||||
|
||||
if ( changed & 0x10 )
|
||||
mirror_single( bank >> 4 & 1 );
|
||||
|
||||
if ( changed & 0x0f )
|
||||
set_prg_bank( 0x8000, bank_32k, bank & 7 );
|
||||
}
|
||||
};
|
||||
|
||||
Nes_Mapper* Nes_Mapper::make_aorom() { return new Mapper_Aorom; }
|
||||
|
||||
// CNROM
|
||||
|
||||
class Mapper_Cnrom : public Nes_Mapper {
|
||||
uint8_t bank;
|
||||
public:
|
||||
Mapper_Cnrom()
|
||||
{
|
||||
register_state( &bank, 1 );
|
||||
}
|
||||
|
||||
virtual void apply_mapping()
|
||||
{
|
||||
set_chr_bank( 0, bank_8k, bank & 7 );
|
||||
}
|
||||
|
||||
virtual void write( nes_time_t, nes_addr_t addr, int data )
|
||||
{
|
||||
bank = handle_bus_conflict( addr, data );
|
||||
set_chr_bank( 0, bank_8k, bank & 7 );
|
||||
}
|
||||
};
|
||||
|
||||
Nes_Mapper* Nes_Mapper::make_cnrom() { return new Mapper_Cnrom; }
|
Loading…
Reference in New Issue
Block a user