From 58bc38688ea0ec7e5d72566fc87aee7e56589edf Mon Sep 17 00:00:00 2001 From: Sergio Martin Date: Fri, 19 Jan 2024 20:27:00 +0100 Subject: [PATCH] More refactoring --- source/quickerNES/Nes_Cart.h | 2 - source/quickerNES/Nes_Core.h | 122 +------- source/quickerNES/Nes_Cpu.h | 115 ++++--- source/quickerNES/Nes_Emu.cpp | 2 +- source/quickerNES/Nes_Mapper.cpp | 166 ---------- source/quickerNES/Nes_Ppu.cpp | 1 - source/quickerNES/audio/meson.build | 17 - source/quickerNES/audio/vrc7/apu.cpp | 1 - source/quickerNES/audio/vrc7/apu.h | 2 + source/quickerNES/mappers/mapper.cpp | 290 ++++++++++++++++++ .../{Nes_Mapper.h => mappers/mapper.h} | 2 + source/quickerNES/mappers/mapper000.hpp | 2 +- source/quickerNES/mappers/mapper001.hpp | 2 +- source/quickerNES/mappers/mapper002.hpp | 2 +- source/quickerNES/mappers/mapper003.hpp | 2 +- source/quickerNES/mappers/mapper004.hpp | 2 +- source/quickerNES/mappers/mapper005.hpp | 2 +- source/quickerNES/mappers/mapper007.hpp | 2 +- source/quickerNES/mappers/mapper009.hpp | 2 +- source/quickerNES/mappers/mapper010.hpp | 2 +- source/quickerNES/mappers/mapper011.hpp | 2 +- source/quickerNES/mappers/mapper015.hpp | 2 +- source/quickerNES/mappers/mapper019.hpp | 2 +- source/quickerNES/mappers/mapper021.hpp | 2 +- source/quickerNES/mappers/mapper022.hpp | 2 +- source/quickerNES/mappers/mapper023.hpp | 2 +- source/quickerNES/mappers/mapper024.hpp | 2 +- source/quickerNES/mappers/mapper025.hpp | 2 +- source/quickerNES/mappers/mapper026.hpp | 2 +- source/quickerNES/mappers/mapper030.hpp | 2 +- source/quickerNES/mappers/mapper032.hpp | 2 +- source/quickerNES/mappers/mapper033.hpp | 2 +- source/quickerNES/mappers/mapper034.hpp | 2 +- source/quickerNES/mappers/mapper060.hpp | 2 +- source/quickerNES/mappers/mapper066.hpp | 2 +- source/quickerNES/mappers/mapper069.hpp | 2 +- source/quickerNES/mappers/mapper070.hpp | 2 +- source/quickerNES/mappers/mapper071.hpp | 2 +- source/quickerNES/mappers/mapper073.hpp | 2 +- source/quickerNES/mappers/mapper075.hpp | 2 +- source/quickerNES/mappers/mapper078.hpp | 2 +- source/quickerNES/mappers/mapper079.hpp | 2 +- source/quickerNES/mappers/mapper085.hpp | 2 +- source/quickerNES/mappers/mapper087.hpp | 2 +- source/quickerNES/mappers/mapper088.hpp | 2 +- source/quickerNES/mappers/mapper089.hpp | 2 +- source/quickerNES/mappers/mapper093.hpp | 2 +- source/quickerNES/mappers/mapper094.hpp | 2 +- source/quickerNES/mappers/mapper097.hpp | 2 +- source/quickerNES/mappers/mapper140.hpp | 2 +- source/quickerNES/mappers/mapper156.hpp | 2 +- source/quickerNES/mappers/mapper180.hpp | 2 +- source/quickerNES/mappers/mapper184.hpp | 2 +- source/quickerNES/mappers/mapper190.hpp | 2 +- source/quickerNES/mappers/mapper193.hpp | 2 +- source/quickerNES/mappers/mapper206.hpp | 2 +- source/quickerNES/mappers/mapper207.hpp | 2 +- source/quickerNES/mappers/mapper232.hpp | 2 +- source/quickerNES/mappers/mapper240.hpp | 2 +- source/quickerNES/mappers/mapper241.hpp | 2 +- source/quickerNES/mappers/mapper244.hpp | 2 +- source/quickerNES/mappers/mapper246.hpp | 2 +- source/quickerNES/meson.build | 18 +- source/quickerNES/quickerNESInstance.hpp | 4 +- 64 files changed, 425 insertions(+), 419 deletions(-) delete mode 100644 source/quickerNES/Nes_Mapper.cpp delete mode 100644 source/quickerNES/audio/meson.build create mode 100644 source/quickerNES/mappers/mapper.cpp rename source/quickerNES/{Nes_Mapper.h => mappers/mapper.h} (99%) diff --git a/source/quickerNES/Nes_Cart.h b/source/quickerNES/Nes_Cart.h index 0de8fd2..1957cae 100644 --- a/source/quickerNES/Nes_Cart.h +++ b/source/quickerNES/Nes_Cart.h @@ -96,7 +96,5 @@ private: long prg_size_; long chr_size_; unsigned mapper; - - }; diff --git a/source/quickerNES/Nes_Core.h b/source/quickerNES/Nes_Core.h index be99902..4631c87 100644 --- a/source/quickerNES/Nes_Core.h +++ b/source/quickerNES/Nes_Core.h @@ -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); diff --git a/source/quickerNES/Nes_Cpu.h b/source/quickerNES/Nes_Cpu.h index 7b32c6b..7e65a4e 100644 --- a/source/quickerNES/Nes_Cpu.h +++ b/source/quickerNES/Nes_Cpu.h @@ -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; -} diff --git a/source/quickerNES/Nes_Emu.cpp b/source/quickerNES/Nes_Emu.cpp index 88026b1..c2188e2 100644 --- a/source/quickerNES/Nes_Emu.cpp +++ b/source/quickerNES/Nes_Emu.cpp @@ -1,7 +1,7 @@ // Nes_Emu 0.7.0. http://www.slack.net/~ant/ #include -#include "Nes_Mapper.h" +#include "mappers/mapper.h" #include "Nes_Emu.h" /* Copyright (C) 2004-2006 Shay Green. This module is free software; you diff --git a/source/quickerNES/Nes_Mapper.cpp b/source/quickerNES/Nes_Mapper.cpp deleted file mode 100644 index 675a73e..0000000 --- a/source/quickerNES/Nes_Mapper.cpp +++ /dev/null @@ -1,166 +0,0 @@ - -// Nes_Emu 0.7.0. http://www.slack.net/~ant/ - -#include -#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 ); -} \ No newline at end of file diff --git a/source/quickerNES/Nes_Ppu.cpp b/source/quickerNES/Nes_Ppu.cpp index ba22c13..d459fe3 100644 --- a/source/quickerNES/Nes_Ppu.cpp +++ b/source/quickerNES/Nes_Ppu.cpp @@ -5,7 +5,6 @@ #include #include "Nes_Ppu.h" -#include "Nes_Mapper.h" #include "Nes_Core.h" /* Copyright (C) 2004-2006 Shay Green. This module is free software; you diff --git a/source/quickerNES/audio/meson.build b/source/quickerNES/audio/meson.build deleted file mode 100644 index 11ec518..0000000 --- a/source/quickerNES/audio/meson.build +++ /dev/null @@ -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', -] diff --git a/source/quickerNES/audio/vrc7/apu.cpp b/source/quickerNES/audio/vrc7/apu.cpp index d9894ca..0ee49fe 100644 --- a/source/quickerNES/audio/vrc7/apu.cpp +++ b/source/quickerNES/audio/vrc7/apu.cpp @@ -1,4 +1,3 @@ -#include "Nes_Mapper.h" #include "audio/vrc7/apu.h" #include "audio/vrc7/emu2413.h" #include diff --git a/source/quickerNES/audio/vrc7/apu.h b/source/quickerNES/audio/vrc7/apu.h index 956235d..3646d4b 100644 --- a/source/quickerNES/audio/vrc7/apu.h +++ b/source/quickerNES/audio/vrc7/apu.h @@ -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 #include "audio/vrc7/emu2413_state.h" #include "audio/Blip_Buffer.h" struct vrc7_snapshot_t; +typedef long nes_time_t; class Nes_Vrc7 { public: diff --git a/source/quickerNES/mappers/mapper.cpp b/source/quickerNES/mappers/mapper.cpp new file mode 100644 index 0000000..a486055 --- /dev/null +++ b/source/quickerNES/mappers/mapper.cpp @@ -0,0 +1,290 @@ + +// Nes_Emu 0.7.0. http://www.slack.net/~ant/ + +#include +#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; +} \ No newline at end of file diff --git a/source/quickerNES/Nes_Mapper.h b/source/quickerNES/mappers/mapper.h similarity index 99% rename from source/quickerNES/Nes_Mapper.h rename to source/quickerNES/mappers/mapper.h index 06c064f..db2b78f 100644 --- a/source/quickerNES/Nes_Mapper.h +++ b/source/quickerNES/mappers/mapper.h @@ -181,6 +181,8 @@ protected: virtual void apply_mapping() = 0; void default_reset_state(); + + static Nes_Mapper* getMapperFromCode(const int mapperCode); }; diff --git a/source/quickerNES/mappers/mapper000.hpp b/source/quickerNES/mappers/mapper000.hpp index b288063..3ec01e6 100644 --- a/source/quickerNES/mappers/mapper000.hpp +++ b/source/quickerNES/mappers/mapper000.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper001.hpp b/source/quickerNES/mappers/mapper001.hpp index 19e94bd..4a97cf5 100644 --- a/source/quickerNES/mappers/mapper001.hpp +++ b/source/quickerNES/mappers/mapper001.hpp @@ -2,7 +2,7 @@ // Nes_Emu 0.7.0. http://www.slack.net/~ant/ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" #include /* Copyright (C) 2004-2006 Shay Green. This module is free software; you diff --git a/source/quickerNES/mappers/mapper002.hpp b/source/quickerNES/mappers/mapper002.hpp index 517fb73..4377f9e 100644 --- a/source/quickerNES/mappers/mapper002.hpp +++ b/source/quickerNES/mappers/mapper002.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper003.hpp b/source/quickerNES/mappers/mapper003.hpp index 8a31e5d..d6b99cb 100644 --- a/source/quickerNES/mappers/mapper003.hpp +++ b/source/quickerNES/mappers/mapper003.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper004.hpp b/source/quickerNES/mappers/mapper004.hpp index 7c75251..3637dc4 100644 --- a/source/quickerNES/mappers/mapper004.hpp +++ b/source/quickerNES/mappers/mapper004.hpp @@ -2,7 +2,7 @@ // Nes_Emu 0.7.0. http://www.slack.net/~ant/ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" #include #include "Nes_Core.h" diff --git a/source/quickerNES/mappers/mapper005.hpp b/source/quickerNES/mappers/mapper005.hpp index 80b360b..89cb804 100644 --- a/source/quickerNES/mappers/mapper005.hpp +++ b/source/quickerNES/mappers/mapper005.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper007.hpp b/source/quickerNES/mappers/mapper007.hpp index 96db2ac..4b22eae 100644 --- a/source/quickerNES/mappers/mapper007.hpp +++ b/source/quickerNES/mappers/mapper007.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper009.hpp b/source/quickerNES/mappers/mapper009.hpp index 92517bc..4fe2d14 100644 --- a/source/quickerNES/mappers/mapper009.hpp +++ b/source/quickerNES/mappers/mapper009.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // MMC2 diff --git a/source/quickerNES/mappers/mapper010.hpp b/source/quickerNES/mappers/mapper010.hpp index f77baed..6e2679b 100644 --- a/source/quickerNES/mappers/mapper010.hpp +++ b/source/quickerNES/mappers/mapper010.hpp @@ -1,6 +1,6 @@ #pragma once #include -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // MMC4 diff --git a/source/quickerNES/mappers/mapper011.hpp b/source/quickerNES/mappers/mapper011.hpp index 9232c2e..e4a1455 100644 --- a/source/quickerNES/mappers/mapper011.hpp +++ b/source/quickerNES/mappers/mapper011.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper015.hpp b/source/quickerNES/mappers/mapper015.hpp index ca77930..9e92d8b 100644 --- a/source/quickerNES/mappers/mapper015.hpp +++ b/source/quickerNES/mappers/mapper015.hpp @@ -17,7 +17,7 @@ * 100-in-1 Contra Function 16 */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct Mapper015_state_t { diff --git a/source/quickerNES/mappers/mapper019.hpp b/source/quickerNES/mappers/mapper019.hpp index 930cdaa..14a8c94 100644 --- a/source/quickerNES/mappers/mapper019.hpp +++ b/source/quickerNES/mappers/mapper019.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper021.hpp b/source/quickerNES/mappers/mapper021.hpp index ff71a3c..13ed4a0 100644 --- a/source/quickerNES/mappers/mapper021.hpp +++ b/source/quickerNES/mappers/mapper021.hpp @@ -26,7 +26,7 @@ * VRC-2/VRC-4 Konami */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct vrc2_state_t { diff --git a/source/quickerNES/mappers/mapper022.hpp b/source/quickerNES/mappers/mapper022.hpp index ba6a106..0c81c1e 100644 --- a/source/quickerNES/mappers/mapper022.hpp +++ b/source/quickerNES/mappers/mapper022.hpp @@ -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 Mapper022; \ No newline at end of file diff --git a/source/quickerNES/mappers/mapper023.hpp b/source/quickerNES/mappers/mapper023.hpp index 7efff5d..d20bf5f 100644 --- a/source/quickerNES/mappers/mapper023.hpp +++ b/source/quickerNES/mappers/mapper023.hpp @@ -26,6 +26,6 @@ * VRC-2/VRC-4 Konami */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" typedef Mapper_VRC2_4 Mapper023; \ No newline at end of file diff --git a/source/quickerNES/mappers/mapper024.hpp b/source/quickerNES/mappers/mapper024.hpp index 9c921b5..6e9ccb4 100644 --- a/source/quickerNES/mappers/mapper024.hpp +++ b/source/quickerNES/mappers/mapper024.hpp @@ -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 #include "audio/vrc6/apu.h" diff --git a/source/quickerNES/mappers/mapper025.hpp b/source/quickerNES/mappers/mapper025.hpp index ae9af3a..4efa13f 100644 --- a/source/quickerNES/mappers/mapper025.hpp +++ b/source/quickerNES/mappers/mapper025.hpp @@ -26,6 +26,6 @@ * VRC-2/VRC-4 Konami */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" typedef Mapper_VRC2_4 Mapper025; \ No newline at end of file diff --git a/source/quickerNES/mappers/mapper026.hpp b/source/quickerNES/mappers/mapper026.hpp index 1b64f10..d2b091a 100644 --- a/source/quickerNES/mappers/mapper026.hpp +++ b/source/quickerNES/mappers/mapper026.hpp @@ -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; \ No newline at end of file diff --git a/source/quickerNES/mappers/mapper030.hpp b/source/quickerNES/mappers/mapper030.hpp index b855680..06f9b20 100644 --- a/source/quickerNES/mappers/mapper030.hpp +++ b/source/quickerNES/mappers/mapper030.hpp @@ -27,7 +27,7 @@ * Tested only on Troll Burner and Mystic Origins demo. */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Unrom512 diff --git a/source/quickerNES/mappers/mapper032.hpp b/source/quickerNES/mappers/mapper032.hpp index 8b84cba..6ac122e 100644 --- a/source/quickerNES/mappers/mapper032.hpp +++ b/source/quickerNES/mappers/mapper032.hpp @@ -23,7 +23,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct mapper32_state_t { diff --git a/source/quickerNES/mappers/mapper033.hpp b/source/quickerNES/mappers/mapper033.hpp index 0f9a294..894f781 100644 --- a/source/quickerNES/mappers/mapper033.hpp +++ b/source/quickerNES/mappers/mapper033.hpp @@ -23,7 +23,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct tc0190_state_t { diff --git a/source/quickerNES/mappers/mapper034.hpp b/source/quickerNES/mappers/mapper034.hpp index 1f5da44..c874eb6 100644 --- a/source/quickerNES/mappers/mapper034.hpp +++ b/source/quickerNES/mappers/mapper034.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper060.hpp b/source/quickerNES/mappers/mapper060.hpp index 7531e8c..84b6643 100644 --- a/source/quickerNES/mappers/mapper060.hpp +++ b/source/quickerNES/mappers/mapper060.hpp @@ -17,7 +17,7 @@ * 4-in-1 Multicart ( Reset-based ) */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // NROM-128 4-in-1 multicart diff --git a/source/quickerNES/mappers/mapper066.hpp b/source/quickerNES/mappers/mapper066.hpp index 3b4a7d0..b99a842 100644 --- a/source/quickerNES/mappers/mapper066.hpp +++ b/source/quickerNES/mappers/mapper066.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper069.hpp b/source/quickerNES/mappers/mapper069.hpp index ed094f8..9bb33fa 100644 --- a/source/quickerNES/mappers/mapper069.hpp +++ b/source/quickerNES/mappers/mapper069.hpp @@ -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 */ diff --git a/source/quickerNES/mappers/mapper070.hpp b/source/quickerNES/mappers/mapper070.hpp index 5bf031e..eadc6d0 100644 --- a/source/quickerNES/mappers/mapper070.hpp +++ b/source/quickerNES/mappers/mapper070.hpp @@ -23,7 +23,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Mapper_74x161x162x32 diff --git a/source/quickerNES/mappers/mapper071.hpp b/source/quickerNES/mappers/mapper071.hpp index cac80c4..c90a199 100644 --- a/source/quickerNES/mappers/mapper071.hpp +++ b/source/quickerNES/mappers/mapper071.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper073.hpp b/source/quickerNES/mappers/mapper073.hpp index b487229..e0c013a 100644 --- a/source/quickerNES/mappers/mapper073.hpp +++ b/source/quickerNES/mappers/mapper073.hpp @@ -23,7 +23,7 @@ * VRC-3 Konami, Salamander */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct vrc3_state_t { diff --git a/source/quickerNES/mappers/mapper075.hpp b/source/quickerNES/mappers/mapper075.hpp index 97db8b3..dd0e62f 100644 --- a/source/quickerNES/mappers/mapper075.hpp +++ b/source/quickerNES/mappers/mapper075.hpp @@ -17,7 +17,7 @@ * VRC-1 Konami */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct vrc1_state_t { diff --git a/source/quickerNES/mappers/mapper078.hpp b/source/quickerNES/mappers/mapper078.hpp index 9ba71dd..0590040 100644 --- a/source/quickerNES/mappers/mapper078.hpp +++ b/source/quickerNES/mappers/mapper078.hpp @@ -1,6 +1,6 @@ #pragma once -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Holy Diver and Uchuusen - Cosmo Carrier. diff --git a/source/quickerNES/mappers/mapper079.hpp b/source/quickerNES/mappers/mapper079.hpp index 1f3e119..a7f752d 100644 --- a/source/quickerNES/mappers/mapper079.hpp +++ b/source/quickerNES/mappers/mapper079.hpp @@ -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 { diff --git a/source/quickerNES/mappers/mapper085.hpp b/source/quickerNES/mappers/mapper085.hpp index 538ab37..c4ba770 100644 --- a/source/quickerNES/mappers/mapper085.hpp +++ b/source/quickerNES/mappers/mapper085.hpp @@ -3,7 +3,7 @@ // Nes_Emu 0.5.4. http://www.slack.net/~ant/ #include -#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 diff --git a/source/quickerNES/mappers/mapper087.hpp b/source/quickerNES/mappers/mapper087.hpp index bf50fcf..abf0d1e 100644 --- a/source/quickerNES/mappers/mapper087.hpp +++ b/source/quickerNES/mappers/mapper087.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper088.hpp b/source/quickerNES/mappers/mapper088.hpp index eff8908..bfa9e01 100644 --- a/source/quickerNES/mappers/mapper088.hpp +++ b/source/quickerNES/mappers/mapper088.hpp @@ -25,7 +25,7 @@ * Mapper 206 */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct namco_34x3_state_t { diff --git a/source/quickerNES/mappers/mapper089.hpp b/source/quickerNES/mappers/mapper089.hpp index 9501a82..0937828 100644 --- a/source/quickerNES/mappers/mapper089.hpp +++ b/source/quickerNES/mappers/mapper089.hpp @@ -22,7 +22,7 @@ * Mapper 93 - Sunsoft-2 */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Sunsoft2b diff --git a/source/quickerNES/mappers/mapper093.hpp b/source/quickerNES/mappers/mapper093.hpp index b8da0ef..7d2284d 100644 --- a/source/quickerNES/mappers/mapper093.hpp +++ b/source/quickerNES/mappers/mapper093.hpp @@ -22,7 +22,7 @@ * Mapper 93 - Sunsoft-2 */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Sunsoft2a diff --git a/source/quickerNES/mappers/mapper094.hpp b/source/quickerNES/mappers/mapper094.hpp index 6ba0aec..cf64887 100644 --- a/source/quickerNES/mappers/mapper094.hpp +++ b/source/quickerNES/mappers/mapper094.hpp @@ -24,7 +24,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Un1rom diff --git a/source/quickerNES/mappers/mapper097.hpp b/source/quickerNES/mappers/mapper097.hpp index c28806a..a452089 100644 --- a/source/quickerNES/mappers/mapper097.hpp +++ b/source/quickerNES/mappers/mapper097.hpp @@ -23,7 +23,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Irem_Tam_S1 diff --git a/source/quickerNES/mappers/mapper140.hpp b/source/quickerNES/mappers/mapper140.hpp index fea7493..ece1c8c 100644 --- a/source/quickerNES/mappers/mapper140.hpp +++ b/source/quickerNES/mappers/mapper140.hpp @@ -24,7 +24,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Jaleco_JF11 diff --git a/source/quickerNES/mappers/mapper156.hpp b/source/quickerNES/mappers/mapper156.hpp index 2dfccf2..2f93dde 100644 --- a/source/quickerNES/mappers/mapper156.hpp +++ b/source/quickerNES/mappers/mapper156.hpp @@ -1,6 +1,6 @@ #pragma once -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // DIS23C01 DAOU ROM CONTROLLER diff --git a/source/quickerNES/mappers/mapper180.hpp b/source/quickerNES/mappers/mapper180.hpp index 3ca06ed..f2c01c6 100644 --- a/source/quickerNES/mappers/mapper180.hpp +++ b/source/quickerNES/mappers/mapper180.hpp @@ -23,7 +23,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // UxROM (inverted) diff --git a/source/quickerNES/mappers/mapper184.hpp b/source/quickerNES/mappers/mapper184.hpp index 388b310..96b8b97 100644 --- a/source/quickerNES/mappers/mapper184.hpp +++ b/source/quickerNES/mappers/mapper184.hpp @@ -22,7 +22,7 @@ * Mapper 184 - Sunsoft-1 */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Sunsoft1 diff --git a/source/quickerNES/mappers/mapper190.hpp b/source/quickerNES/mappers/mapper190.hpp index 9d9a58a..5d09320 100644 --- a/source/quickerNES/mappers/mapper190.hpp +++ b/source/quickerNES/mappers/mapper190.hpp @@ -1,6 +1,6 @@ #pragma once -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // Magic Kid Googoo diff --git a/source/quickerNES/mappers/mapper193.hpp b/source/quickerNES/mappers/mapper193.hpp index bd53925..e2b2dfa 100644 --- a/source/quickerNES/mappers/mapper193.hpp +++ b/source/quickerNES/mappers/mapper193.hpp @@ -25,7 +25,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // NTDEC's TC-112 mapper IC. diff --git a/source/quickerNES/mappers/mapper206.hpp b/source/quickerNES/mappers/mapper206.hpp index b172682..35a00a3 100644 --- a/source/quickerNES/mappers/mapper206.hpp +++ b/source/quickerNES/mappers/mapper206.hpp @@ -25,7 +25,7 @@ * Mapper 206 */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct namco_34xx_state_t { diff --git a/source/quickerNES/mappers/mapper207.hpp b/source/quickerNES/mappers/mapper207.hpp index fb0fae7..cb3c159 100644 --- a/source/quickerNES/mappers/mapper207.hpp +++ b/source/quickerNES/mappers/mapper207.hpp @@ -23,7 +23,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" struct taito_x1005_state_t { diff --git a/source/quickerNES/mappers/mapper232.hpp b/source/quickerNES/mappers/mapper232.hpp index cdf554b..b8d465f 100644 --- a/source/quickerNES/mappers/mapper232.hpp +++ b/source/quickerNES/mappers/mapper232.hpp @@ -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 diff --git a/source/quickerNES/mappers/mapper240.hpp b/source/quickerNES/mappers/mapper240.hpp index af8a0ca..f2817b3 100644 --- a/source/quickerNES/mappers/mapper240.hpp +++ b/source/quickerNES/mappers/mapper240.hpp @@ -21,7 +21,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // https://www.nesdev.org/wiki/INES_Mapper240 diff --git a/source/quickerNES/mappers/mapper241.hpp b/source/quickerNES/mappers/mapper241.hpp index 626b33f..02db4b7 100644 --- a/source/quickerNES/mappers/mapper241.hpp +++ b/source/quickerNES/mappers/mapper241.hpp @@ -21,7 +21,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // https://www.nesdev.org/wiki/INES_Mapper241 diff --git a/source/quickerNES/mappers/mapper244.hpp b/source/quickerNES/mappers/mapper244.hpp index 509a7ef..038dfa3 100644 --- a/source/quickerNES/mappers/mapper244.hpp +++ b/source/quickerNES/mappers/mapper244.hpp @@ -23,7 +23,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // https://www.nesdev.org/wiki/INES_Mapper244 diff --git a/source/quickerNES/mappers/mapper246.hpp b/source/quickerNES/mappers/mapper246.hpp index 8fbc335..bd9d8a9 100644 --- a/source/quickerNES/mappers/mapper246.hpp +++ b/source/quickerNES/mappers/mapper246.hpp @@ -23,7 +23,7 @@ * */ -#include "Nes_Mapper.h" +#include "mappers/mapper.h" // https://www.nesdev.org/wiki/INES_Mapper246 diff --git a/source/quickerNES/meson.build b/source/quickerNES/meson.build index 12b803e..3d64e02 100644 --- a/source/quickerNES/meson.build +++ b/source/quickerNES/meson.build @@ -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' ] diff --git a/source/quickerNES/quickerNESInstance.hpp b/source/quickerNES/quickerNESInstance.hpp index fa789fb..8d504c5 100644 --- a/source/quickerNES/quickerNESInstance.hpp +++ b/source/quickerNES/quickerNESInstance.hpp @@ -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); }