From 9802883fee6a96d3f1c66422577a39e58a170b6c Mon Sep 17 00:00:00 2001 From: Sergio Martin Date: Mon, 22 Jan 2024 18:50:52 +0100 Subject: [PATCH] Homogenizing format --- .../{emuInstance.hpp => emuInstanceBase.hpp} | 6 +- source/playbackInstance.hpp | 9 --- source/player.cpp | 18 +---- source/quickNES/Mapper_70.cpp | 81 ------------------- source/quickNES/core | 2 +- .../{quickNESInstance.hpp => emuInstance.hpp} | 8 +- source/quickNES/meson.build | 6 +- ...quickerNESInstance.hpp => emuInstance.hpp} | 17 ++-- source/tester.cpp | 17 +--- 9 files changed, 23 insertions(+), 141 deletions(-) rename source/{emuInstance.hpp => emuInstanceBase.hpp} (98%) delete mode 100644 source/quickNES/Mapper_70.cpp rename source/quickNES/{quickNESInstance.hpp => emuInstance.hpp} (95%) rename source/quickerNES/{quickerNESInstance.hpp => emuInstance.hpp} (90%) diff --git a/source/emuInstance.hpp b/source/emuInstanceBase.hpp similarity index 98% rename from source/emuInstance.hpp rename to source/emuInstanceBase.hpp index 77e94f9..f99678d 100644 --- a/source/emuInstance.hpp +++ b/source/emuInstanceBase.hpp @@ -12,12 +12,12 @@ static const uint16_t image_width = 256; static const uint16_t image_height = 240; -class EmuInstance +class EmuInstanceBase { public: - EmuInstance() = default; - virtual ~EmuInstance() = default; + EmuInstanceBase() = default; + virtual ~EmuInstanceBase() = default; inline void advanceState(const std::string &move) { diff --git a/source/playbackInstance.hpp b/source/playbackInstance.hpp index db8ab38..c499488 100644 --- a/source/playbackInstance.hpp +++ b/source/playbackInstance.hpp @@ -11,15 +11,6 @@ #define _INVERSE_FRAME_RATE 16667 -// Creating emulator instance -#ifdef _USE_QUICKNES - typedef Nes_Emu emulator_t; -#endif - -#ifdef _USE_QUICKERNES - typedef quickerNES::Emu emulator_t; -#endif - struct stepData_t { std::string input; diff --git a/source/player.cpp b/source/player.cpp index d404d97..b00507a 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -4,14 +4,6 @@ #include "utils.hpp" #include -#ifdef _USE_QUICKNES - #include "quickNESInstance.hpp" -#endif - -#ifdef _USE_QUICKERNES - #include "quickerNESInstance.hpp" -#endif - int main(int argc, char *argv[]) { // Parsing command line arguments @@ -98,14 +90,8 @@ int main(int argc, char *argv[]) refreshTerminal(); -// Creating emulator instance -#ifdef _USE_QUICKNES - auto e = QuickNESInstance(); -#endif - -#ifdef _USE_QUICKERNES - auto e = quickerNES::QuickerNESInstance(); -#endif + // Creating emulator instance + EmuInstance e; // Setting controller types e.setController1Type(controller1Type); diff --git a/source/quickNES/Mapper_70.cpp b/source/quickNES/Mapper_70.cpp deleted file mode 100644 index 00abf8d..0000000 --- a/source/quickNES/Mapper_70.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* 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 180 Crazy Climber - * - */ - -#include "Nes_Mapper.h" - -template -class Mapper_74x161x162x32 : public Nes_Mapper -{ - public: - Mapper_74x161x162x32() - { - register_state(&bank, 1); - } - - virtual void reset_state() - { - if (_is152 == 0) - bank = ~0; - } - - virtual void apply_mapping() - { - if (_is152) - write(0, 0, bank); - else - { - intercept_writes(0x6000, 1); - write_intercepted(0, 0x6000, bank); - } - } - - virtual bool write_intercepted(nes_time_t, nes_addr_t addr, int data) - { - if ((addr != 0x6000) || _is152) - return false; - - bank = data; - set_prg_bank(0x8000, bank_32k, (bank >> 4) & 0x03); - set_chr_bank(0x0000, bank_8k, ((bank >> 4) & 0x04) | (bank & 0x03)); - - return true; - } - - virtual void write(nes_time_t, nes_addr_t addr, int data) - { - if (_is152 == 0) return; - - bank = handle_bus_conflict(addr, data); - set_prg_bank(0x8000, bank_16k, (bank >> 4) & 0x07); - set_chr_bank(0x0000, bank_8k, bank & 0x0F); - mirror_single((bank >> 7) & 0x01); - } - - uint8_t bank; -}; - -void register_mapper_70(); -void register_mapper_70() -{ - register_mapper>(70); -} diff --git a/source/quickNES/core b/source/quickNES/core index cedf1f6..c41d8ef 160000 --- a/source/quickNES/core +++ b/source/quickNES/core @@ -1 +1 @@ -Subproject commit cedf1f63cc904a2737d26cd1ed006915ecadac22 +Subproject commit c41d8eff29132553e374abc15108c552b6d4a942 diff --git a/source/quickNES/quickNESInstance.hpp b/source/quickNES/emuInstance.hpp similarity index 95% rename from source/quickNES/quickNESInstance.hpp rename to source/quickNES/emuInstance.hpp index e7d0f4f..9655020 100644 --- a/source/quickNES/quickNESInstance.hpp +++ b/source/quickNES/emuInstance.hpp @@ -2,18 +2,20 @@ #include #include -#include +#include #define _DUMMY_SIZE 65536 +typedef Nes_Emu emulator_t; + extern void register_misc_mappers(); extern void register_extra_mappers(); extern void register_mapper_70(); -class QuickNESInstance : public EmuInstance +class EmuInstance : public EmuInstanceBase { public: - QuickNESInstance() : EmuInstance() + EmuInstance() : EmuInstanceBase() { // Creating new emulator _nes = new Nes_Emu; diff --git a/source/quickNES/meson.build b/source/quickNES/meson.build index bcdbbf6..039c536 100644 --- a/source/quickNES/meson.build +++ b/source/quickNES/meson.build @@ -27,6 +27,7 @@ quickNESSrc = [ 'core/nes_emu/nes_mappers.cpp', 'core/nes_emu/Nes_Mmc1.cpp', 'core/nes_emu/Nes_Mmc3.cpp', + 'core/nes_emu/Mapper_70.cpp', 'core/nes_emu/Mapper_Misc.cpp', 'core/nes_emu/Mapper_Unrom512.cpp', 'core/nes_emu/Mapper_Vrc1.cpp', @@ -64,8 +65,7 @@ quickNESSrc = [ 'core/nes_emu/Mapper_TaitoX1005.cpp', 'core/nes_emu/Mapper_TaitoTC0190.cpp', 'core/nes_emu/Mapper_Un1rom.cpp', - 'core/nes_emu/nes_ntsc.cpp', - 'Mapper_70.cpp' + 'core/nes_emu/nes_ntsc.cpp' ] # quickNES Core Configuration @@ -74,4 +74,4 @@ quickNESSrc = [ compile_args : [ '-D_USE_QUICKNES' ], include_directories : include_directories(['.', 'core/nes_emu']), sources : [ quickNESSrc ] - ) \ No newline at end of file + ) diff --git a/source/quickerNES/quickerNESInstance.hpp b/source/quickerNES/emuInstance.hpp similarity index 90% rename from source/quickerNES/quickerNESInstance.hpp rename to source/quickerNES/emuInstance.hpp index a226b73..335ff98 100644 --- a/source/quickerNES/quickerNESInstance.hpp +++ b/source/quickerNES/emuInstance.hpp @@ -1,18 +1,17 @@ #pragma once #include -#include +#include -namespace quickerNES -{ +typedef quickerNES::Emu emulator_t; -class QuickerNESInstance : public EmuInstance +class EmuInstance : public EmuInstanceBase { public: - QuickerNESInstance() : EmuInstance() + EmuInstance() : EmuInstanceBase() { // Creating new emulator - _nes = new Emu; + _nes = new emulator_t; // Allocating video buffer video_buffer = (uint8_t *)malloc(image_width * image_height); @@ -21,7 +20,7 @@ class QuickerNESInstance : public EmuInstance _nes->set_pixels(video_buffer, image_width + 8); } - ~QuickerNESInstance() = default; + ~EmuInstance() = default; virtual bool loadROMFileImpl(const std::string &romData) override { @@ -64,7 +63,5 @@ class QuickerNESInstance : public EmuInstance uint8_t *video_buffer; // Emulator instance - Emu *_nes; + emulator_t *_nes; }; - -} // namespace quickNES \ No newline at end of file diff --git a/source/tester.cpp b/source/tester.cpp index cee43d4..5fff1eb 100644 --- a/source/tester.cpp +++ b/source/tester.cpp @@ -2,19 +2,12 @@ #include "nlohmann/json.hpp" #include "sha1/sha1.hpp" #include "utils.hpp" +#include "emuInstance.hpp" #include #include #include #include -#ifdef _USE_QUICKNES - #include "quickNESInstance.hpp" -#endif - -#ifdef _USE_QUICKERNES - #include "quickerNESInstance.hpp" -#endif - int main(int argc, char *argv[]) { // Parsing command line arguments @@ -101,13 +94,7 @@ int main(int argc, char *argv[]) std::string controller2Type = scriptJson["Controller 2 Type"].get(); // Creating emulator instance - #ifdef _USE_QUICKNES - auto e = QuickNESInstance(); - #endif - - #ifdef _USE_QUICKERNES - auto e = quickerNES::QuickerNESInstance(); - #endif + EmuInstance e; // Setting controller types e.setController1Type(controller1Type);