Homogenizing format

This commit is contained in:
Sergio Martin 2024-01-22 18:50:52 +01:00
parent 54255d59f2
commit 9802883fee
9 changed files with 23 additions and 141 deletions

View File

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

View File

@ -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;

View File

@ -4,14 +4,6 @@
#include "utils.hpp"
#include <cstdlib>
#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);

View File

@ -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 <bool _is152>
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<Mapper_74x161x162x32<true>>(70);
}

@ -1 +1 @@
Subproject commit cedf1f63cc904a2737d26cd1ed006915ecadac22
Subproject commit c41d8eff29132553e374abc15108c552b6d4a942

View File

@ -2,18 +2,20 @@
#include <Nes_Emu.h>
#include <Nes_State.h>
#include <emuInstance.hpp>
#include <emuInstanceBase.hpp>
#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;

View File

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

View File

@ -1,18 +1,17 @@
#pragma once
#include <core/emu.hpp>
#include <emuInstance.hpp>
#include <emuInstanceBase.hpp>
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

View File

@ -2,19 +2,12 @@
#include "nlohmann/json.hpp"
#include "sha1/sha1.hpp"
#include "utils.hpp"
#include "emuInstance.hpp"
#include <chrono>
#include <sstream>
#include <vector>
#include <string>
#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<std::string>();
// 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);