diff --git a/extern/hqn/hqn.h b/extern/hqn/hqn.h index 9f1a519..f04c8c2 100644 --- a/extern/hqn/hqn.h +++ b/extern/hqn/hqn.h @@ -1,7 +1,7 @@ #ifndef __HQN_H__ #define __HQN_H__ -#include +#include #include #define BLIT_SIZE 65536 diff --git a/extern/hqn/hqn_gui_controller.cpp b/extern/hqn/hqn_gui_controller.cpp index caf3766..4246ce8 100644 --- a/extern/hqn/hqn_gui_controller.cpp +++ b/extern/hqn/hqn_gui_controller.cpp @@ -218,9 +218,12 @@ void GUIController::update_blit(int32_t* blit, SDL_Surface* base, SDL_Surface* b SDL_RenderClear(m_renderer); SDL_RenderCopy(m_renderer, m_tex, &NES_BLIT_RECT, &m_nesDest); - auto overlayTex = SDL_CreateTextureFromSurface(m_renderer, base); - SDL_RenderCopy(m_renderer, overlayTex, &OVERLAY_BLIT_RECT_SRC, &OVERLAY_BLIT_RECT_DST); - SDL_DestroyTexture(overlayTex); + if (base != NULL) + { + auto overlayTex = SDL_CreateTextureFromSurface(m_renderer, base); + SDL_RenderCopy(m_renderer, overlayTex, &OVERLAY_BLIT_RECT_SRC, &OVERLAY_BLIT_RECT_DST); + SDL_DestroyTexture(overlayTex); + } if (button_a != NULL) { diff --git a/meson.build b/meson.build index edfb93a..1564fa1 100644 --- a/meson.build +++ b/meson.build @@ -7,41 +7,41 @@ project('quickerNES','c','cpp', # quickerNES Core sources quickerNESCoreSrc = [ - 'core/abstract_file.cpp', - 'core/Nes_Apu.cpp', - 'core/Nes_File.cpp', - 'core/Nes_Oscs.cpp', - 'core/apu_state.cpp', - 'core/Nes_Buffer.cpp', - 'core/Nes_Fme7_Apu.cpp', - 'core/Nes_Ppu.cpp', - 'core/Blip_Buffer.cpp', - 'core/Nes_Cart.cpp', - 'core/Nes_Mapper.cpp', - 'core/Nes_Ppu_Impl.cpp', - 'core/Data_Reader.cpp', - 'core/Nes_Core.cpp', - 'core/Nes_Ppu_Rendering.cpp', - 'core/Effects_Buffer.cpp', - 'core/Nes_Cpu.cpp', - 'core/Nes_State.cpp', - 'core/emu2413.cpp', - 'core/nes_data.cpp', - 'core/nes_util.cpp', - 'core/emu2413_state.cpp', - 'core/Nes_Effects_Buffer.cpp', - 'core/Nes_Namco_Apu.cpp', - 'core/Nes_Vrc6_Apu.cpp', - 'core/Multi_Buffer.cpp', - 'core/Nes_Emu.cpp', - 'core/nes_ntsc.cpp', - 'core/Nes_Vrc7.cpp', + 'source/core/abstract_file.cpp', + 'source/core/Nes_Apu.cpp', + 'source/core/Nes_File.cpp', + 'source/core/Nes_Oscs.cpp', + 'source/core/apu_state.cpp', + 'source/core/Nes_Buffer.cpp', + 'source/core/Nes_Fme7_Apu.cpp', + 'source/core/Nes_Ppu.cpp', + 'source/core/Blip_Buffer.cpp', + 'source/core/Nes_Cart.cpp', + 'source/core/Nes_Mapper.cpp', + 'source/core/Nes_Ppu_Impl.cpp', + 'source/core/Data_Reader.cpp', + 'source/core/Nes_Core.cpp', + 'source/core/Nes_Ppu_Rendering.cpp', + 'source/core/Effects_Buffer.cpp', + 'source/core/Nes_Cpu.cpp', + 'source/core/Nes_State.cpp', + 'source/core/emu2413.cpp', + 'source/core/nes_data.cpp', + 'source/core/nes_util.cpp', + 'source/core/emu2413_state.cpp', + 'source/core/Nes_Effects_Buffer.cpp', + 'source/core/Nes_Namco_Apu.cpp', + 'source/core/Nes_Vrc6_Apu.cpp', + 'source/core/Multi_Buffer.cpp', + 'source/core/Nes_Emu.cpp', + 'source/core/nes_ntsc.cpp', + 'source/core/Nes_Vrc7.cpp', ] # quickerNES Core Configuration quickerNESCoreCPPFlags = [ '-Wfatal-errors','-Wall' ] -quickerNESCoreIncludeDirs = include_directories(['core', 'extern/metrohash128', 'extern/argparse', 'extern/phmap']) +quickerNESCoreIncludeDirs = include_directories(['source/core', 'extern']) quickerNESCoreDependencies = [ ] quickerNESCoreCPPFlags = [ ] quickerNESCoreCFlags = [ ] @@ -50,21 +50,21 @@ quickerNESCoreLinkArgs = [ ] # Building playback/validation tool quickerNESPlayerSrc = [ - 'player/hqn/hqn.cpp', - 'player/hqn/hqn_gui_controller.cpp', - 'player/hqn/hqn_surface.cpp', - 'player/hqn/hqn_util.cpp', - 'player/hqn/options.cpp' + 'extern/hqn/hqn.cpp', + 'extern/hqn/hqn_gui_controller.cpp', + 'extern/hqn/hqn_surface.cpp', + 'extern/hqn/hqn_util.cpp', + 'extern/hqn/options.cpp' ] -quickerNESPlayerIncludeDirs = include_directories([ 'player']) +quickerNESPlayerIncludeDirs = include_directories([ 'source']) quickerNESPlayerDependencies = [ dependency('sdl2'), dependency('SDL2_image') ] quickerNESPlayerCPPFlags = [ ] quickerNESPlayerCFlags = [ ] quickerNESPlayerLinkArgs = [ '-lncurses' ] executable('player', - 'player/player.cpp', + 'source/player.cpp', sources: [ quickerNESCoreSrc, quickerNESPlayerSrc ], include_directories: [ quickerNESCoreIncludeDirs, quickerNESPlayerIncludeDirs ], dependencies: [ quickerNESCoreDependencies, quickerNESPlayerDependencies ], diff --git a/source/emuInstance.hpp b/source/emuInstance.hpp index 8061b33..8b4836a 100644 --- a/source/emuInstance.hpp +++ b/source/emuInstance.hpp @@ -1,10 +1,9 @@ #pragma once -#include -#include -#include +#include +#include #include -#include +#include #define _LOW_MEM_SIZE 0x800 #define _HIGH_MEM_SIZE 0x2000 @@ -15,6 +14,11 @@ class EmuInstance typedef uint8_t inputType; + // Deleting default constructors + EmuInstance() = delete; + EmuInstance(EmuInstance& e) = delete; + ~EmuInstance() = default; + EmuInstance(const std::string& romFilePath, const std::string& stateFilePath) { // Creating new emulator diff --git a/source/playbackInstance.hpp b/source/playbackInstance.hpp index 3ad4a1f..c737b3e 100644 --- a/source/playbackInstance.hpp +++ b/source/playbackInstance.hpp @@ -5,9 +5,9 @@ #include #include #include -#include +#include #include -#include "core/emuInstance.hpp" +#include "emuInstance.hpp" #define _INVERSE_FRAME_RATE 16667 @@ -29,7 +29,7 @@ class PlaybackInstance // Overlay info std::string _overlayPath; - SDL_Surface* _overlayBaseSurface; + SDL_Surface* _overlayBaseSurface = NULL; SDL_Surface* _overlayButtonASurface; SDL_Surface* _overlayButtonBSurface; SDL_Surface* _overlayButtonSelectSurface; diff --git a/source/player.cpp b/source/player.cpp index 9a3fe68..de6e135 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -1,7 +1,8 @@ #include -#include "argparse.hpp" +#include "argparse/argparse.hpp" #include "utils.hpp" -#include "core/emuInstance.hpp" +#include "emuInstance.hpp" +#include "playbackInstance.hpp" int main(int argc, char *argv[]) { @@ -18,7 +19,7 @@ int main(int argc, char *argv[]) program.add_argument("stateFile") .help("(Optional) Path to the initial state file to load.") - .default_value(""); + .default_value(std::string("")); program.add_argument("--reproduce") .help("Plays the entire sequence without interruptions and exit at the end.") @@ -38,15 +39,28 @@ int main(int argc, char *argv[]) std::string romFilePath = program.get("romFile"); // Getting sequence file path - std::string sequenceFile = program.get("sequenceFile"); + std::string sequenceFilePath = program.get("sequenceFile"); // If initial state file is specified, load it - std::string sequenceFile = program.get("stateFile"); + std::string stateFilePath = program.get("stateFile"); // Getting reproduce flag bool isReproduce = program.get("--reproduce"); // Getting reproduce flag bool disableRender = program.get("--disableRender"); + + // Printing provided parameters + printf("Rom File Path: %s\n", romFilePath.c_str()); + printf("Sequence File Path: %s\n", sequenceFilePath.c_str()); + printf("State File Path: %s\n", stateFilePath.c_str()); + + // Creating emulator instance + auto e = EmuInstance(romFilePath, stateFilePath); + + // Creating playback instance + auto p = PlaybackInstance(&e); + + while(true) p.renderFrame(0, ""); } diff --git a/source/core/utils.hpp b/source/utils.hpp similarity index 100% rename from source/core/utils.hpp rename to source/utils.hpp