diff --git a/README.md b/README.md index 0bcd697..50b090f 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Changes ========= - Optimizations made in the CPU emulation core +- Minimize compiled code size to reduce pressure on L1i cache - Sound is no longer emulated during skip frames Credits diff --git a/meson.build b/meson.build index ea62312..60d28b7 100644 --- a/meson.build +++ b/meson.build @@ -41,7 +41,7 @@ quickerNESCoreSrc = [ # quickerNES Core Configuration quickerNESCoreDependency = declare_dependency( - compile_args : [ '-Wfatal-errors', '-Wall', '-Werror', '-Wno-multichar' ], + compile_args : [ '-Wfatal-errors', '-Wall', '-Werror', '-Wno-multichar', '-DNDEBUG' ], include_directories : include_directories(['source', 'source/core', 'extern']), sources : [ quickerNESCoreSrc, 'extern/metrohash128/metrohash128.cpp' ] ) diff --git a/source/core/Nes_Emu.cpp b/source/core/Nes_Emu.cpp index bbc57dd..9057fea 100644 --- a/source/core/Nes_Emu.cpp +++ b/source/core/Nes_Emu.cpp @@ -3,7 +3,8 @@ #include "Nes_Emu.h" -#include +#include +#include #include "Nes_State.h" #include "Nes_Mapper.h" diff --git a/source/core/Nes_Emu.h b/source/core/Nes_Emu.h index 1c552ad..7a2ab46 100644 --- a/source/core/Nes_Emu.h +++ b/source/core/Nes_Emu.h @@ -202,6 +202,10 @@ public: enum { high_mem_size = 0x2000 }; uint8_t* high_mem() { return emu.impl->sram; } + // Sprite memory + uint8_t* spr_mem() { return emu.ppu.getSpriteRAM(); } + uint16_t spr_mem_size() { return emu.ppu.getSpriteRAMSize(); } + // End of public interface public: const char * set_sample_rate( long rate, class Nes_Buffer* ); diff --git a/source/core/Nes_Mapper.cpp b/source/core/Nes_Mapper.cpp index 051535a..9971320 100644 --- a/source/core/Nes_Mapper.cpp +++ b/source/core/Nes_Mapper.cpp @@ -213,13 +213,6 @@ void Nes_Mapper::mirror_manual( int page0, int page1, int page2, int page3 ) emu().ppu.set_nt_banks( page0, page1, page2, page3 ); } -#ifndef NDEBUG -int Nes_Mapper::handle_bus_conflict( nes_addr_t addr, int data ) -{ - return data; -} -#endif - Nes_Mapper* Nes_Mapper::create( Nes_Cart const* cart, Nes_Core* emu ) { diff --git a/source/core/Nes_Mapper.h b/source/core/Nes_Mapper.h index 45e949c..5af2632 100644 --- a/source/core/Nes_Mapper.h +++ b/source/core/Nes_Mapper.h @@ -16,13 +16,6 @@ class Nes_Core; class Nes_Mapper { public: - // Register function that creates mapper for given code. - typedef Nes_Mapper* (*creator_func_t)(); - static void register_mapper( int code, creator_func_t ); - - // Register optional mappers included with Nes_Emu - void register_optional_mappers(); - // Create mapper appropriate for cartridge. Returns NULL if it uses unsupported mapper. static Nes_Mapper* create( Nes_Cart const*, Nes_Core* ); @@ -176,10 +169,7 @@ private: }; -#ifdef NDEBUG inline int Nes_Mapper::handle_bus_conflict( nes_addr_t addr, int data ) { return data; } -#endif - inline void Nes_Mapper::mirror_horiz( int p ) { mirror_manual( p, p, p ^ 1, p ^ 1 ); } inline void Nes_Mapper::mirror_vert( int p ) { mirror_manual( p, p ^ 1, p, p ^ 1 ); } inline void Nes_Mapper::mirror_single( int p ) { mirror_manual( p, p, p, p ); } diff --git a/source/core/Nes_Ppu_Impl.h b/source/core/Nes_Ppu_Impl.h index c336316..cefb34a 100644 --- a/source/core/Nes_Ppu_Impl.h +++ b/source/core/Nes_Ppu_Impl.h @@ -28,7 +28,8 @@ public: static const uint16_t image_left = 8; static const uint16_t buffer_width = image_width + 16; static const uint16_t buffer_height = image_height; - + enum { spr_ram_size = 0x100 }; + int write_2007( int ); // Host palette @@ -64,8 +65,11 @@ public: static const uint16_t scanline_len = 341; + uint8_t* getSpriteRAM () { return spr_ram; } + uint16_t getSpriteRAMSize () { return spr_ram_size; } + protected: - uint8_t spr_ram [0x100]; + uint8_t spr_ram [spr_ram_size]; void begin_frame(); void run_hblank( int ); int sprite_height() const { return (w2000 >> 2 & 8) + 8; } diff --git a/source/core/mappers/mapper002.hpp b/source/core/mappers/mapper002.hpp index 5748828..97888b4 100644 --- a/source/core/mappers/mapper002.hpp +++ b/source/core/mappers/mapper002.hpp @@ -38,7 +38,7 @@ public: 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 ); + set_prg_bank( 0x8000, bank_16k, data ); } }; diff --git a/source/emuInstance.hpp b/source/emuInstance.hpp index 9eb64f3..80e5d5b 100644 --- a/source/emuInstance.hpp +++ b/source/emuInstance.hpp @@ -52,6 +52,8 @@ class EmuInstance uint8_t* getHighMem() { return _nes->high_mem();}; const uint8_t* getChrMem() { return _nes->chr_mem();}; size_t getChrMemSize() { return _nes->chr_size();}; + uint8_t* getSpriteRAM() { return _nes->spr_mem(); } + uint16_t getSpriteRAMSize() { return _nes->spr_mem_size(); } const std::string getRomSHA1() const { return _romSHA1String; };