More refactoring

This commit is contained in:
Sergio Martin 2024-01-19 20:27:00 +01:00
parent 99d32a4301
commit 58bc38688e
64 changed files with 425 additions and 419 deletions

View File

@ -96,7 +96,5 @@ private:
long prg_size_;
long chr_size_;
unsigned mapper;
};

View File

@ -21,67 +21,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "audio/apu.h"
#include "Nes_Cpu.h"
#include "Nes_Ppu.h"
#include "Nes_Mapper.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"
#include "mappers/mapper.h"
class Nes_Cart;
@ -166,65 +106,11 @@ public:
// Getting cartdrige mapper code
auto mapperCode = new_cart->mapper_code();
// 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();
// Getting mapper corresponding to that code
mapper = Nes_Mapper::getMapperFromCode(mapperCode);
// If no mapper was found, return null (error) now
if (mapper == NULL)
if (mapper == nullptr)
{
fprintf(stderr, "Could not find mapper for code: %u\n", mapperCode);
exit(-1);

View File

@ -10,15 +10,26 @@ typedef unsigned nes_addr_t; // 16-bit address
class Nes_Cpu {
public:
// Clear registers, unmap memory, and map code pages to unmapped_page.
void reset( void const* unmapped_page = 0 );
// NES 6502 registers. *Not* kept updated during a call to run().
struct registers_t {
uint16_t pc; // Should be more than 16 bits to allow overflow detection -- but I (eien86) removed it to maximize performance.
uint8_t a;
uint8_t x;
uint8_t y;
uint8_t status;
uint8_t sp;
};
// Map code memory (memory accessed via the program counter). Start and size
// must be multiple of page_size.
enum { page_bits = 11 };
enum { page_count = 0x10000 >> page_bits };
enum { page_size = 1L << page_bits };
// Clear registers, unmap memory, and map code pages to unmapped_page.
void reset( void const* unmapped_page = 0 );
inline void map_code( nes_addr_t start, unsigned size, const void* data )
{
unsigned first_page = start / page_size;
@ -29,21 +40,14 @@ public:
// Access memory as the emulated CPU does.
int read( nes_addr_t );
void write( nes_addr_t, int data );
uint8_t* get_code( nes_addr_t ); // non-const to allow debugger to modify code
// Push a byte on the stack
void push_byte( int );
// NES 6502 registers. *Not* kept updated during a call to run().
struct registers_t {
uint16_t pc; // Should be more than 16 bits to allow overflow detection -- but I (eien86) removed it to maximize performance.
uint8_t a;
uint8_t x;
uint8_t y;
uint8_t status;
uint8_t sp;
};
//registers_t r;
inline void push_byte( int data )
{
int sp = r.sp;
r.sp = (sp - 1) & 0xFF;
low_mem [0x100 + sp] = data;
}
// Reasons that run() returns
enum result_t {
@ -56,9 +60,26 @@ public:
result_t run( nes_time_t end_time );
nes_time_t time() const { return clock_count; }
void reduce_limit( int offset );
void set_end_time_( nes_time_t t );
void set_irq_time_( nes_time_t t );
inline void reduce_limit( int offset )
{
clock_limit -= offset;
end_time_ -= offset;
irq_time_ -= offset;
}
inline void set_end_time_( nes_time_t t )
{
end_time_ = t;
update_clock_limit();
}
inline void set_irq_time_( nes_time_t t )
{
irq_time_ = t;
update_clock_limit();
}
unsigned long error_count() const { return error_count_; }
// If PC exceeds 0xFFFF and encounters page_wrap_opcode, it will be silently wrapped.
@ -75,50 +96,28 @@ public:
unsigned long error_count_;
enum { irq_inhibit = 0x04 };
void update_clock_limit();
inline void update_clock_limit()
{
nes_time_t t = end_time_;
if ( t > irq_time_ && !(r.status & irq_inhibit) )
t = irq_time_;
clock_limit = t;
}
registers_t r;
bool isCorrectExecution = true;
// low_mem is a full page size so it can be mapped with code_map
uint8_t low_mem [page_size > 0x800 ? page_size : 0x800];
inline uint8_t* get_code( nes_addr_t addr )
{
return (uint8_t*) code_map [addr >> page_bits] + addr;
}
};
inline uint8_t* Nes_Cpu::get_code( nes_addr_t addr )
{
return (uint8_t*) code_map [addr >> page_bits] + addr;
}
inline void Nes_Cpu::update_clock_limit()
{
nes_time_t t = end_time_;
if ( t > irq_time_ && !(r.status & irq_inhibit) )
t = irq_time_;
clock_limit = t;
}
inline void Nes_Cpu::set_end_time_( nes_time_t t )
{
end_time_ = t;
update_clock_limit();
}
inline void Nes_Cpu::set_irq_time_( nes_time_t t )
{
irq_time_ = t;
update_clock_limit();
}
inline void Nes_Cpu::reduce_limit( int offset )
{
clock_limit -= offset;
end_time_ -= offset;
irq_time_ -= offset;
}
inline void Nes_Cpu::push_byte( int data )
{
int sp = r.sp;
r.sp = (sp - 1) & 0xFF;
low_mem [0x100 + sp] = data;
}

View File

@ -1,7 +1,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include <cstring>
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include "Nes_Emu.h"
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you

View File

@ -1,166 +0,0 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include <cstring>
#include "Nes_Mapper.h"
#include "Nes_Core.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 */
Nes_Mapper::Nes_Mapper()
{
emu_ = NULL;
static char c;
state = &c; // TODO: state must not be null?
state_size = 0;
}
Nes_Mapper::~Nes_Mapper()
{
}
// Sets mirroring, maps first 8K CHR in, first and last 16K of PRG,
// intercepts writes to upper half of memory, and clears registered state.
void Nes_Mapper::default_reset_state()
{
int mirroring = cart_->mirroring();
if ( mirroring & 8 )
mirror_full();
else if ( mirroring & 1 )
mirror_vert();
else
mirror_horiz();
set_chr_bank( 0, bank_8k, 0 );
set_prg_bank( 0x8000, bank_16k, 0 );
set_prg_bank( 0xC000, bank_16k, last_bank );
intercept_writes( 0x8000, 0x8000 );
memset( state, 0, state_size );
}
void Nes_Mapper::reset()
{
default_reset_state();
reset_state();
apply_mapping();
}
void mapper_state_t::write( const void* p, unsigned long s )
{
size = s;
memcpy( data, p, s );
}
int mapper_state_t::read( void* p, unsigned long s ) const
{
if ( (long) s > size )
s = size;
memcpy( p, data, s );
return s;
}
void Nes_Mapper::save_state( mapper_state_t& out )
{
out.write( state, state_size );
}
void Nes_Mapper::load_state( mapper_state_t const& in )
{
default_reset_state();
read_state( in );
apply_mapping();
}
void Nes_Mapper::read_state( mapper_state_t const& in )
{
memset( state, 0, state_size );
in.read( state, state_size );
apply_mapping();
}
// Timing
void Nes_Mapper::irq_changed() { emu_->irq_changed(); }
nes_time_t Nes_Mapper::next_irq( nes_time_t ) { return no_irq; }
void Nes_Mapper::a12_clocked() { }
void Nes_Mapper::run_until( nes_time_t ) { }
void Nes_Mapper::end_frame( nes_time_t ) { }
bool Nes_Mapper::ppu_enabled() const { return emu().ppu.w2001 & 0x08; }
// Sound
int Nes_Mapper::channel_count() const { return 0; }
void Nes_Mapper::set_channel_buf( int, Blip_Buffer* ) { }
void Nes_Mapper::set_treble( blip_eq_t const& ) { }
// Memory mapping
void Nes_Mapper::set_prg_bank( nes_addr_t addr, bank_size_t bs, int bank )
{
int bank_size = 1 << bs;
int bank_count = cart_->prg_size() >> bs;
if ( bank < 0 )
bank += bank_count;
if ( bank >= bank_count )
bank %= bank_count;
emu().map_code( addr, bank_size, cart_->prg() + (bank << bs) );
if ( unsigned (addr - 0x6000) < 0x2000 )
emu().enable_prg_6000();
}
void Nes_Mapper::set_chr_bank( nes_addr_t addr, bank_size_t bs, int bank )
{
emu().ppu.render_until( emu().clock() );
emu().ppu.set_chr_bank( addr, 1 << bs, bank << bs );
}
void Nes_Mapper::set_chr_bank_ex( nes_addr_t addr, bank_size_t bs, int bank )
{
emu().ppu.render_until( emu().clock() );
emu().ppu.set_chr_bank_ex( addr, 1 << bs, bank << bs );
}
void Nes_Mapper::mirror_manual( int page0, int page1, int page2, int page3 )
{
emu().ppu.render_bg_until( emu().clock() );
emu().ppu.set_nt_banks( page0, page1, page2, page3 );
}
void Nes_Mapper::intercept_reads( nes_addr_t addr, unsigned size )
{
emu().add_mapper_intercept( addr, size, true, false );
}
void Nes_Mapper::intercept_writes( nes_addr_t addr, unsigned size )
{
emu().add_mapper_intercept( addr, size, false, true );
}
void Nes_Mapper::enable_sram( bool enabled, bool read_only )
{
emu_->enable_sram( enabled, read_only );
}

View File

@ -5,7 +5,6 @@
#include <cstring>
#include "Nes_Ppu.h"
#include "Nes_Mapper.h"
#include "Nes_Core.h"
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you

View File

@ -1,17 +0,0 @@
# quickerNES Audio sources
quickerNESAudioSrc = [
'audio/apu.cpp',
'audio/Nes_Oscs.cpp',
'audio/Nes_Buffer.cpp',
'audio/Blip_Buffer.cpp',
'audio/Effects_Buffer.cpp',
'audio/Nes_Effects_Buffer.cpp',
'audio/Multi_Buffer.cpp',
'audio/namco/apu.cpp',
'audio/vrc6/apu.cpp',
'audio/vrc7/emu2413.cpp',
'audio/vrc7/emu2413_state.cpp',
'audio/vrc7/apu.cpp',
'audio/fme7/apu.cpp',
]

View File

@ -1,4 +1,3 @@
#include "Nes_Mapper.h"
#include "audio/vrc7/apu.h"
#include "audio/vrc7/emu2413.h"
#include <cstring>

View File

@ -4,10 +4,12 @@
// Konami VRC7 sound chip emulator
// Nes_Snd_Emu 0.1.7. Copyright (C) 2003-2005 Shay Green. GNU LGPL license.
#include <cstdint>
#include "audio/vrc7/emu2413_state.h"
#include "audio/Blip_Buffer.h"
struct vrc7_snapshot_t;
typedef long nes_time_t;
class Nes_Vrc7 {
public:

View File

@ -0,0 +1,290 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include <cstring>
#include "mappers/mapper.h"
#include "Nes_Core.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 */
/*
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;
static char c;
state = &c; // TODO: state must not be null?
state_size = 0;
}
Nes_Mapper::~Nes_Mapper()
{
}
// Sets mirroring, maps first 8K CHR in, first and last 16K of PRG,
// intercepts writes to upper half of memory, and clears registered state.
void Nes_Mapper::default_reset_state()
{
int mirroring = cart_->mirroring();
if ( mirroring & 8 )
mirror_full();
else if ( mirroring & 1 )
mirror_vert();
else
mirror_horiz();
set_chr_bank( 0, bank_8k, 0 );
set_prg_bank( 0x8000, bank_16k, 0 );
set_prg_bank( 0xC000, bank_16k, last_bank );
intercept_writes( 0x8000, 0x8000 );
memset( state, 0, state_size );
}
void Nes_Mapper::reset()
{
default_reset_state();
reset_state();
apply_mapping();
}
void mapper_state_t::write( const void* p, unsigned long s )
{
size = s;
memcpy( data, p, s );
}
int mapper_state_t::read( void* p, unsigned long s ) const
{
if ( (long) s > size )
s = size;
memcpy( p, data, s );
return s;
}
void Nes_Mapper::save_state( mapper_state_t& out )
{
out.write( state, state_size );
}
void Nes_Mapper::load_state( mapper_state_t const& in )
{
default_reset_state();
read_state( in );
apply_mapping();
}
void Nes_Mapper::read_state( mapper_state_t const& in )
{
memset( state, 0, state_size );
in.read( state, state_size );
apply_mapping();
}
// Timing
void Nes_Mapper::irq_changed() { emu_->irq_changed(); }
nes_time_t Nes_Mapper::next_irq( nes_time_t ) { return no_irq; }
void Nes_Mapper::a12_clocked() { }
void Nes_Mapper::run_until( nes_time_t ) { }
void Nes_Mapper::end_frame( nes_time_t ) { }
bool Nes_Mapper::ppu_enabled() const { return emu().ppu.w2001 & 0x08; }
// Sound
int Nes_Mapper::channel_count() const { return 0; }
void Nes_Mapper::set_channel_buf( int, Blip_Buffer* ) { }
void Nes_Mapper::set_treble( blip_eq_t const& ) { }
// Memory mapping
void Nes_Mapper::set_prg_bank( nes_addr_t addr, bank_size_t bs, int bank )
{
int bank_size = 1 << bs;
int bank_count = cart_->prg_size() >> bs;
if ( bank < 0 )
bank += bank_count;
if ( bank >= bank_count )
bank %= bank_count;
emu().map_code( addr, bank_size, cart_->prg() + (bank << bs) );
if ( unsigned (addr - 0x6000) < 0x2000 )
emu().enable_prg_6000();
}
void Nes_Mapper::set_chr_bank( nes_addr_t addr, bank_size_t bs, int bank )
{
emu().ppu.render_until( emu().clock() );
emu().ppu.set_chr_bank( addr, 1 << bs, bank << bs );
}
void Nes_Mapper::set_chr_bank_ex( nes_addr_t addr, bank_size_t bs, int bank )
{
emu().ppu.render_until( emu().clock() );
emu().ppu.set_chr_bank_ex( addr, 1 << bs, bank << bs );
}
void Nes_Mapper::mirror_manual( int page0, int page1, int page2, int page3 )
{
emu().ppu.render_bg_until( emu().clock() );
emu().ppu.set_nt_banks( page0, page1, page2, page3 );
}
void Nes_Mapper::intercept_reads( nes_addr_t addr, unsigned size )
{
emu().add_mapper_intercept( addr, size, true, false );
}
void Nes_Mapper::intercept_writes( nes_addr_t addr, unsigned size )
{
emu().add_mapper_intercept( addr, size, false, true );
}
void Nes_Mapper::enable_sram( bool enabled, bool read_only )
{
emu_->enable_sram( enabled, read_only );
}
Nes_Mapper* Nes_Mapper::getMapperFromCode(const int mapperCode)
{
Nes_Mapper* mapper = nullptr;
// 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();
return mapper;
}

View File

@ -181,6 +181,8 @@ protected:
virtual void apply_mapping() = 0;
void default_reset_state();
static Nes_Mapper* getMapperFromCode(const int mapperCode);
};

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -2,7 +2,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include <cstring>
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -2,7 +2,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include <cstring>
#include "Nes_Core.h"

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include "Nes_Core.h"
#include <cstring>

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -1,7 +1,7 @@
#pragma once
#include <cstring>
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// MMC2

View File

@ -1,6 +1,6 @@
#pragma once
#include <cstring>
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// MMC4

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -17,7 +17,7 @@
* 100-in-1 Contra Function 16
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct Mapper015_state_t
{

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include "audio/namco/apu.h"
/* Copyright (C) 2004-2006 Shay Green. This module is free software; you

View File

@ -26,7 +26,7 @@
* VRC-2/VRC-4 Konami
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct vrc2_state_t
{

View File

@ -26,7 +26,7 @@
* VRC-2/VRC-4 Konami
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include "mappers/mapper021.hpp"
typedef Mapper_VRC2_4<false,true> Mapper022;

View File

@ -26,6 +26,6 @@
* VRC-2/VRC-4 Konami
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
typedef Mapper_VRC2_4<false, false> Mapper023;

View File

@ -3,7 +3,7 @@
// Konami VRC6 mapper
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include <string.h>
#include "audio/vrc6/apu.h"

View File

@ -26,6 +26,6 @@
* VRC-2/VRC-4 Konami
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
typedef Mapper_VRC2_4<true,false> Mapper025;

View File

@ -4,6 +4,6 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
typedef Mapper_Vrc6<3> Mapper026;

View File

@ -27,7 +27,7 @@
* Tested only on Troll Burner and Mystic Origins demo.
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Unrom512

View File

@ -23,7 +23,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct mapper32_state_t
{

View File

@ -23,7 +23,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct tc0190_state_t
{

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -17,7 +17,7 @@
* 4-in-1 Multicart ( Reset-based )
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// NROM-128 4-in-1 multicart

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/libs/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include "audio/fme7/apu.h"
/* Copyright (C) 2005 Chris Moeller */

View File

@ -23,7 +23,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Mapper_74x161x162x32

View File

@ -4,7 +4,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -23,7 +23,7 @@
* VRC-3 Konami, Salamander
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct vrc3_state_t
{

View File

@ -17,7 +17,7 @@
* VRC-1 Konami
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct vrc1_state_t
{

View File

@ -1,6 +1,6 @@
#pragma once
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Holy Diver and Uchuusen - Cosmo Carrier.

View File

@ -25,7 +25,7 @@
* Nina-03 / Nina-06
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
template < bool multicart >
class Mapper_AveNina : public Nes_Mapper {

View File

@ -3,7 +3,7 @@
// Nes_Emu 0.5.4. http://www.slack.net/~ant/
#include <cstring>
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
#include "audio/vrc7/apu.h"
/* Copyright (C) 2004-2005 Shay Green. This module is free software; you

View File

@ -3,7 +3,7 @@
// Optional less-common simple mappers
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -25,7 +25,7 @@
* Mapper 206
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct namco_34x3_state_t
{

View File

@ -22,7 +22,7 @@
* Mapper 93 - Sunsoft-2
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Sunsoft2b

View File

@ -22,7 +22,7 @@
* Mapper 93 - Sunsoft-2
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Sunsoft2a

View File

@ -24,7 +24,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Un1rom

View File

@ -23,7 +23,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Irem_Tam_S1

View File

@ -24,7 +24,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Jaleco_JF11

View File

@ -1,6 +1,6 @@
#pragma once
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// DIS23C01 DAOU ROM CONTROLLER

View File

@ -23,7 +23,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// UxROM (inverted)

View File

@ -22,7 +22,7 @@
* Mapper 184 - Sunsoft-1
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Sunsoft1

View File

@ -1,6 +1,6 @@
#pragma once
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// Magic Kid Googoo

View File

@ -25,7 +25,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// NTDEC's TC-112 mapper IC.

View File

@ -25,7 +25,7 @@
* Mapper 206
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct namco_34xx_state_t
{

View File

@ -23,7 +23,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
struct taito_x1005_state_t
{

View File

@ -5,7 +5,7 @@
// Nes_Emu 0.7.0. http://www.slack.net/~ant/
#include "Nes_Mapper.h"
#include "mappers/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

View File

@ -21,7 +21,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// https://www.nesdev.org/wiki/INES_Mapper240

View File

@ -21,7 +21,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// https://www.nesdev.org/wiki/INES_Mapper241

View File

@ -23,7 +23,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// https://www.nesdev.org/wiki/INES_Mapper244

View File

@ -23,7 +23,7 @@
*
*/
#include "Nes_Mapper.h"
#include "mappers/mapper.h"
// https://www.nesdev.org/wiki/INES_Mapper246

View File

@ -1,13 +1,27 @@
# quickerNES Core sources
subdir('audio')
quickerNESAudioSrc = [
'audio/apu.cpp',
'audio/Nes_Oscs.cpp',
'audio/Nes_Buffer.cpp',
'audio/Blip_Buffer.cpp',
'audio/Effects_Buffer.cpp',
'audio/Nes_Effects_Buffer.cpp',
'audio/Multi_Buffer.cpp',
'audio/namco/apu.cpp',
'audio/vrc6/apu.cpp',
'audio/vrc7/emu2413.cpp',
'audio/vrc7/emu2413_state.cpp',
'audio/vrc7/apu.cpp',
'audio/fme7/apu.cpp',
]
quickerNESSrc = quickerNESAudioSrc + [
'mappers/mapper.cpp',
'Nes_Ppu.cpp',
'Nes_Ppu_Impl.cpp',
'Nes_Ppu_Rendering.cpp',
'Nes_Emu.cpp',
'Nes_Mapper.cpp',
'Nes_Cpu.cpp'
]

View File

@ -34,12 +34,12 @@ class QuickerNESInstance : public EmuInstance
const uint8_t* getChrMem() const override { return _nes->chr_mem();};
size_t getChrMemSize() const override { return _nes->chr_size();};
void serializeState(uint8_t* state) const
void serializeState(uint8_t* state) const override
{
_nes->serializeState(state);
}
void deserializeState(const uint8_t* state)
void deserializeState(const uint8_t* state) override
{
_nes->deserializeState(state);
}