Skip to content

Commit

Permalink
wip of property rework
Browse files Browse the repository at this point in the history
  • Loading branch information
gulrak committed Jul 4, 2024
1 parent 235d076 commit 3019cd8
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 114 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ The Supported presets are:
* MegaChip 8 (with Mega8 wrapping/scrolling support if wrapping is enabled)
* XO-CHIP
* VIP-CHIP-8 (CHIP-8 on an emulated COSMAC VIP)
* VIP-CHIP-8 with relative branching ()
* VIP-CHIP-8 TPD (same, but with 64x64 display)
* VIP-HI-RES-CHIP-8 (same, but with 64x128 display)
* VIP-CHIP-8E (same, with CHIP-8E interpreter)
Expand Down
2 changes: 1 addition & 1 deletion cmake/BuildSettings.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
endif()
Expand Down
5 changes: 2 additions & 3 deletions src/emulation/chip8opcodedisass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@

namespace emu {

Chip8OpcodeDisassembler::Chip8OpcodeDisassembler(Chip8EmulatorOptions& options)
: _options(options)
, _opcodeSet(Chip8EmulatorOptions::variantForPreset(options.behaviorBase))
Chip8OpcodeDisassembler::Chip8OpcodeDisassembler()
: _opcodeSet(Chip8EmulatorOptions::variantForPreset(options.behaviorBase))
{
_labelOrAddress = [](uint16_t addr){ return fmt::format("0x{:04X}", addr); };
}
Expand Down
3 changes: 1 addition & 2 deletions src/emulation/chip8opcodedisass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ class Chip8OpcodeDisassembler : public emu::IChip8Emulator
{
public:
using SymbolResolver = std::function<std::string(uint16_t)>;
Chip8OpcodeDisassembler(Chip8EmulatorOptions& options);
Chip8OpcodeDisassembler();
std::tuple<uint16_t, uint16_t, std::string> disassembleInstruction(const uint8_t* code, const uint8_t* end) const override;
protected:
Chip8EmulatorOptions& _options;
SymbolResolver _labelOrAddress;
detail::OpcodeSet _opcodeSet;
};
Expand Down
6 changes: 3 additions & 3 deletions src/emulation/chip8realcorebase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ struct RealCoreSetupInfo {
class Chip8RealCoreBase : public Chip8OpcodeDisassembler
{
public:
Chip8RealCoreBase(Chip8EmulatorHost& host, Chip8EmulatorOptions& options)
: Chip8OpcodeDisassembler(options)
explicit Chip8RealCoreBase(Chip8EmulatorHost& host)
: Chip8OpcodeDisassembler()
, _host(host)
{
}
Expand Down Expand Up @@ -187,7 +187,7 @@ class Chip8RealCoreBase : public Chip8OpcodeDisassembler
bool _backendStopped{false};
bool _isHybridChipMode{true};
mutable CpuState _cpuState{eNORMAL};
std::array<uint8_t,4096> _breakMap;
std::array<uint8_t,4096> _breakMap{};
std::map<uint32_t,BreakpointInfo> _breakpoints;
std::string _errorMessage;
};
Expand Down
189 changes: 94 additions & 95 deletions src/emulation/chip8vip.cpp

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/emulation/chip8vip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ namespace emu {
extern const uint8_t _chip8_cvip[0x200];
extern const uint8_t _rom_cvip[0x200];

enum VIPChip8Interpreter { VC8I_NONE, VC8I_CHIP8, VC8I_CHIP10, VC8I_CHIP8RB, VC8I_CHIP8TPD, VC8I_CHIP8FPD, VC8I_CHIP8X, VC8I_CHIP8XTPD, VC8I_CHIP8XFPD, VC8I_CHIP8E };

class Chip8VIP : public Chip8RealCoreBase, public Cdp1802Bus
{
public:
Chip8VIP(Chip8EmulatorHost& host, Chip8EmulatorOptions& options, IChip8Emulator* other = nullptr);
Chip8VIP(Chip8EmulatorHost& host, Properties& properties, IChip8Emulator* other = nullptr);
~Chip8VIP() override;

void reset() override;
Expand Down Expand Up @@ -85,7 +87,7 @@ class Chip8VIP : public Chip8RealCoreBase, public Cdp1802Bus
static std::vector<uint8_t> getInterpreterCode(const std::string& name);

private:
static uint16_t patchRAM(std::string name, uint8_t* ram, size_t size);
uint16_t patchRAM(VIPChip8Interpreter interpreter, uint8_t* ram, size_t size);
int frameCycle() const;
int videoLine() const;
bool executeCdp1802();
Expand Down
10 changes: 5 additions & 5 deletions src/emulation/hardware/cdp186x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
namespace emu {

const uint32_t Cdp186x::_cdp1862BackgroundColors[4] = { 0x000080FF, 0x000000FF, 0x008000FF, 0x800000FF };
Cdp186x::Cdp186x(Type type, Cdp1802& cpu, const Chip8EmulatorOptions& options)
Cdp186x::Cdp186x(Type type, Cdp1802& cpu, bool traceLog)
: _cpu(cpu)
, _type(type)
, _options(options)
, _traceLog(traceLog)
{
static uint32_t foregroundColors[8] = { 0x181818FF, 0xFF0000FF, 0x0000FFFF, 0xFF00FFFF, 0x00FF00FF, 0xFFFF00FF, 0x00FFFFFF, 0xFFFFFFFF };
_screen.setMode(256, 192, 4); // actual resolution doesn't matter, just needs to be bigger than max resolution, but ratio matters
Expand Down Expand Up @@ -99,7 +99,7 @@ std::pair<int,bool> Cdp186x::executeStep()
}
_frameCycle = fc;
auto lineCycle = _frameCycle % 14;
if(_options.optTraceLog) {
if(_traceLog) {
if (vsync)
Logger::log(Logger::eBACKEND_EMU, _cpu.getCycles(), {_frameCounter, _frameCycle}, fmt::format("{:24} ; {}", "--- VSYNC ---", _cpu.dumpStateLine()).c_str());
else if (lineCycle == 0)
Expand All @@ -110,7 +110,7 @@ std::pair<int,bool> Cdp186x::executeStep()
if(_frameCycle < VIDEO_FIRST_VISIBLE_LINE * 14 && _frameCycle >= (VIDEO_FIRST_VISIBLE_LINE - 2) * 14 + 2 && _cpu.getIE()) {
_displayEnabledLatch = _displayEnabled;
if(_displayEnabled) {
if (_options.optTraceLog)
if (_traceLog)
Logger::log(Logger::eBACKEND_EMU, _cpu.getCycles(), {_frameCounter, _frameCycle}, fmt::format("{:24} ; {}", "--- IRQ ---", _cpu.dumpStateLine()).c_str());
_cpu.triggerInterrupt();
}
Expand All @@ -133,7 +133,7 @@ std::pair<int,bool> Cdp186x::executeStep()
}
}
if (_displayEnabledLatch) {
if(_options.optTraceLog)
if(_traceLog)
Logger::log(Logger::eBACKEND_EMU, _cpu.getCycles(), {_frameCounter, _frameCycle}, fmt::format("DMA: line {:03d} 0x{:04x}-0x{:04x}", line, dmaStart, _cpu.getR(0) - 1).c_str());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/emulation/hardware/cdp186x.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
// src/emulation/cdp186x.hpp
//---------------------------------------------------------------------------------------
//
Expand Down Expand Up @@ -45,7 +45,7 @@ class Cdp186x
enum Type { eCDP1861, eVP590, eCDP1861_C10, eCDP1861_62, eCDP1864 };
enum SubMode { eNONE, eVP590_DEFAULT, eVP590_LORES, eVP590_HIRES};
using VideoType = VideoScreen<uint8_t, 256, 192>; // size for easier inter-operability with other CHIP-8 implementations, it just uses 64x128
Cdp186x(Type type, Cdp1802& cpu, const Chip8EmulatorOptions& options);
Cdp186x(Type type, Cdp1802& cpu, bool traceLog);
void reset();
bool getNEFX() const;
Type getType() const { return _type; }
Expand Down Expand Up @@ -82,14 +82,14 @@ class Cdp186x
Cdp1802& _cpu;
Type _type{eCDP1861};
SubMode _subMode{eNONE};
const Chip8EmulatorOptions& _options;
std::array<uint32_t,256> _cdp1862Palette;
VideoScreen<uint8_t,256,192> _screen;
int _frameCycle{0};
int _frameCounter{0};
int _backgroundColor{0};
bool _displayEnabled{false};
bool _displayEnabledLatch{false};
bool _traceLog{false};
static const uint32_t _cdp1862BackgroundColors[4];
};

Expand Down

0 comments on commit 3019cd8

Please sign in to comment.