Opening player render window

This commit is contained in:
Sergio Martin 2024-01-10 20:11:49 +01:00
parent 410bbd9338
commit d310134441
7 changed files with 74 additions and 53 deletions

2
extern/hqn/hqn.h vendored
View File

@ -1,7 +1,7 @@
#ifndef __HQN_H__
#define __HQN_H__
#include <Nes_Emu.h>
#include <core/Nes_Emu.h>
#include <cstdint>
#define BLIT_SIZE 65536

View File

@ -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)
{

View File

@ -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 ],

View File

@ -1,10 +1,9 @@
#pragma once
#include <Nes_Emu.h>
#include <Nes_State.h>
#include <utils.hpp>
#include <core/Nes_Emu.h>
#include <core/Nes_State.h>
#include <string>
#include <utils.hpp>
#include <utils.hpp>
#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

View File

@ -5,9 +5,9 @@
#include <SDL.h>
#include <SDL_image.h>
#include <utils.hpp>
#include <hqn/hqn.h>
#include <hqn/hqn.h>
#include <hqn/hqn_gui_controller.h>
#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;

View File

@ -1,7 +1,8 @@
#include <cstdlib>
#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<std::string>("romFile");
// Getting sequence file path
std::string sequenceFile = program.get<std::string>("sequenceFile");
std::string sequenceFilePath = program.get<std::string>("sequenceFile");
// If initial state file is specified, load it
std::string sequenceFile = program.get<std::string>("stateFile");
std::string stateFilePath = program.get<std::string>("stateFile");
// Getting reproduce flag
bool isReproduce = program.get<bool>("--reproduce");
// Getting reproduce flag
bool disableRender = program.get<bool>("--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, "");
}