integration of n64 core
This commit is contained in:
@@ -9,6 +9,8 @@ set(CMAKE_AUTOUIC ON)
|
||||
|
||||
find_package(Qt5 COMPONENTS Widgets REQUIRED)
|
||||
|
||||
add_library(frontend Frontend.hpp)
|
||||
add_library(frontend Frontend.hpp Frontend.cpp)
|
||||
|
||||
target_compile_definitions(frontend PUBLIC FRONTEND_QT)
|
||||
target_include_directories(frontend PUBLIC .)
|
||||
target_link_libraries(frontend PUBLIC Qt5::Widgets)
|
||||
|
||||
@@ -6,5 +6,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
add_library(frontend Frontend.cpp Frontend.hpp)
|
||||
target_include_directories(frontend PUBLIC . ../../core)
|
||||
target_compile_definitions(frontend PUBLIC FRONTEND_SDL)
|
||||
target_include_directories(frontend PUBLIC . ../../core ../../core/gb ../../core/n64)
|
||||
target_link_libraries(frontend PUBLIC SDL2)
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
#include <Frontend.hpp>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <gb/Core.hpp>
|
||||
#include <n64/Core.hpp>
|
||||
|
||||
namespace natsukashii::frontend {
|
||||
App::~App() {
|
||||
@@ -7,16 +11,25 @@ App::~App() {
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
App::App() {
|
||||
App::App(const std::string& rom) {
|
||||
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
|
||||
window = SDL_CreateWindow("natukashii", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN);
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
||||
id = SDL_GetWindowID(window);
|
||||
|
||||
std::string ext{rom.begin() + rom.find_first_of('.') + 1, rom.end()};
|
||||
std::transform(ext.begin(), ext.end(), ext.begin(), [](unsigned char c){
|
||||
return std::tolower(c);
|
||||
});
|
||||
|
||||
if(ext == "gb") core = std::make_unique<gb::core::Core>(rom);
|
||||
else if(ext == "n64") core = std::make_unique<n64::core::Core>(rom);
|
||||
else util::panic("Unimplemented core!");
|
||||
}
|
||||
|
||||
void App::Run() {
|
||||
while(!quit) {
|
||||
gb.Run();
|
||||
core->Run();
|
||||
|
||||
SDL_Event event;
|
||||
SDL_PollEvent(&event);
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
#pragma once
|
||||
#include <SDL2/SDL.h>
|
||||
#include <gb/Core.hpp>
|
||||
#include <BaseCore.hpp>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <util.hpp>
|
||||
|
||||
namespace natsukashii::frontend {
|
||||
using namespace natsukashii::core;
|
||||
struct App {
|
||||
~App();
|
||||
App();
|
||||
App(const std::string&);
|
||||
void Run();
|
||||
private:
|
||||
SDL_Window *window = nullptr;
|
||||
SDL_Renderer *renderer = nullptr;
|
||||
Uint32 id;
|
||||
bool quit = false;
|
||||
core::Core gb;
|
||||
std::unique_ptr<BaseCore> core;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user