From 81ed53ce1128dc3609100bf51596d55f05f358df Mon Sep 17 00:00:00 2001 From: Adrian Conlon Date: Mon, 25 Dec 2017 23:34:56 +0000 Subject: [PATCH] First stab at a Ricoh 2A03: A 6502 minus decimal mode support. Signed-off-by: Adrian Conlon --- EightBit.sln | 12 +- M6502/inc/mos6502.h | 18 +-- M6502/src/mos6502.cpp | 15 +-- Ricoh2A03/inc/Ricoh2A03.h | 17 +++ Ricoh2A03/inc/stdafx.h | 1 + Ricoh2A03/src/Ricoh2A03.cpp | 17 +++ Ricoh2A03/src/Ricoh2A03.vcxproj | 148 ++++++++++++++++++++++++ Ricoh2A03/src/Ricoh2A03.vcxproj.filters | 29 +++++ Ricoh2A03/src/stdafx.cpp | 1 + 9 files changed, 236 insertions(+), 22 deletions(-) create mode 100644 Ricoh2A03/inc/Ricoh2A03.h create mode 100644 Ricoh2A03/inc/stdafx.h create mode 100644 Ricoh2A03/src/Ricoh2A03.cpp create mode 100644 Ricoh2A03/src/Ricoh2A03.vcxproj create mode 100644 Ricoh2A03/src/Ricoh2A03.vcxproj.filters create mode 100644 Ricoh2A03/src/stdafx.cpp diff --git a/EightBit.sln b/EightBit.sln index 2533401..0b97d0d 100644 --- a/EightBit.sln +++ b/EightBit.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 -VisualStudioVersion = 15.0.27004.2006 +VisualStudioVersion = 15.0.27130.2010 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EightBit", "src\EightBit.vcxproj", "{A9C24BD9-0CB4-4C84-B09B-46B815F9DA47}" EndProject @@ -23,6 +23,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "M6502", "M6502\src\M6502.vc EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_M6502", "M6502\test_M6502\test_M6502.vcxproj", "{EF6F5840-328E-465A-A78A-E807BC9AEB4C}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Ricoh2A03", "Ricoh2A03\src\Ricoh2A03.vcxproj", "{CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -111,6 +113,14 @@ Global {EF6F5840-328E-465A-A78A-E807BC9AEB4C}.Release|x64.Build.0 = Release|x64 {EF6F5840-328E-465A-A78A-E807BC9AEB4C}.Release|x86.ActiveCfg = Release|Win32 {EF6F5840-328E-465A-A78A-E807BC9AEB4C}.Release|x86.Build.0 = Release|Win32 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}.Debug|x64.ActiveCfg = Debug|x64 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}.Debug|x64.Build.0 = Debug|x64 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}.Debug|x86.ActiveCfg = Debug|Win32 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}.Debug|x86.Build.0 = Debug|Win32 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}.Release|x64.ActiveCfg = Release|x64 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}.Release|x64.Build.0 = Release|x64 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}.Release|x86.ActiveCfg = Release|Win32 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/M6502/inc/mos6502.h b/M6502/inc/mos6502.h index c1cb236..180efec 100644 --- a/M6502/inc/mos6502.h +++ b/M6502/inc/mos6502.h @@ -11,7 +11,7 @@ #include namespace EightBit { - class MOS6502 final : public Processor { + class MOS6502 : public Processor { public: struct opcode_decoded_t { @@ -56,6 +56,14 @@ namespace EightBit { protected: virtual void reset() final; + virtual void SBC(uint8_t data); + void SBC_b(uint8_t data); + void SBC_d(uint8_t data); + + virtual void ADC(uint8_t data); + void ADC_b(uint8_t data); + void ADC_d(uint8_t data); + private: void interrupt(uint16_t vector); @@ -484,16 +492,8 @@ namespace EightBit { void ASL(uint8_t& output); - void SBC(uint8_t data); - void SBC_b(uint8_t data); - void SBC_d(uint8_t data); - void CMP(uint8_t first, uint8_t second); - void ADC(uint8_t data); - void ADC_b(uint8_t data); - void ADC_d(uint8_t data); - void Branch(int8_t displacement); void Branch(bool flag); diff --git a/M6502/src/mos6502.cpp b/M6502/src/mos6502.cpp index 3e8c2a9..38ef66c 100644 --- a/M6502/src/mos6502.cpp +++ b/M6502/src/mos6502.cpp @@ -35,10 +35,10 @@ EightBit::MOS6502::MOS6502(Bus& bus) } int EightBit::MOS6502::step() { - ExecutingInstruction.fire(*this); resetCycles(); auto returned = 0; if (LIKELY(powered())) { + ExecutingInstruction.fire(*this); if (UNLIKELY(lowered(NMI()))) { raise(NMI()); interrupt(NMIvector); @@ -50,10 +50,9 @@ int EightBit::MOS6502::step() { } else if (UNLIKELY(lowered(HALT()))) { execute(0); // NOP ?? returned = 4; // ?? TBC + } else { + returned = execute(fetchByte()); } - - - returned = execute(fetchByte()); ExecutedInstruction.fire(*this); } return returned; @@ -64,14 +63,6 @@ void EightBit::MOS6502::reset() { getWord(RSTvector, PC()); } -//void EightBit::MOS6502::triggerIRQ() { -// interrupt(IRQvector); -//} -// -//void EightBit::MOS6502::triggerNMI() { -// interrupt(NMIvector); -//} - void EightBit::MOS6502::getWord(register16_t& output) { output.low = getByte(); BUS().ADDRESS().word++; diff --git a/Ricoh2A03/inc/Ricoh2A03.h b/Ricoh2A03/inc/Ricoh2A03.h new file mode 100644 index 0000000..cfbc992 --- /dev/null +++ b/Ricoh2A03/inc/Ricoh2A03.h @@ -0,0 +1,17 @@ +#pragma once + +#include + +#include + +namespace EightBit { + class Ricoh2A03 final : public MOS6502 { + public: + Ricoh2A03(Bus& bus); + ~Ricoh2A03(); + + protected: + virtual void SBC(uint8_t data) final; + virtual void ADC(uint8_t data) final; + }; +} \ No newline at end of file diff --git a/Ricoh2A03/inc/stdafx.h b/Ricoh2A03/inc/stdafx.h new file mode 100644 index 0000000..6f70f09 --- /dev/null +++ b/Ricoh2A03/inc/stdafx.h @@ -0,0 +1 @@ +#pragma once diff --git a/Ricoh2A03/src/Ricoh2A03.cpp b/Ricoh2A03/src/Ricoh2A03.cpp new file mode 100644 index 0000000..622c8ef --- /dev/null +++ b/Ricoh2A03/src/Ricoh2A03.cpp @@ -0,0 +1,17 @@ +#include "stdafx.h" +#include "Ricoh2A03.h" + +EightBit::Ricoh2A03::Ricoh2A03(Bus& bus) +: MOS6502(bus) { +} + +EightBit::Ricoh2A03::~Ricoh2A03() { +} + +void EightBit::Ricoh2A03::SBC(uint8_t data) { + MOS6502::SBC_b(data); +} + +void EightBit::Ricoh2A03::ADC(uint8_t data) { + MOS6502::ADC_b(data); +} diff --git a/Ricoh2A03/src/Ricoh2A03.vcxproj b/Ricoh2A03/src/Ricoh2A03.vcxproj new file mode 100644 index 0000000..eb63821 --- /dev/null +++ b/Ricoh2A03/src/Ricoh2A03.vcxproj @@ -0,0 +1,148 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43} + Ricoh2A03 + 8.1 + + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + StaticLibrary + true + v141 + Unicode + + + StaticLibrary + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + ..\inc;..\..\M6502\inc;..\..\inc;$(IncludePath) + + + ..\inc;..\..\M6502\inc;..\..\inc;$(IncludePath) + + + ..\inc;..\..\M6502\inc;..\..\inc;$(IncludePath) + + + ..\inc;..\..\M6502\inc;..\..\inc;$(IncludePath) + + + + Level3 + MaxSpeed + true + true + true + true + Use + + + true + true + + + + + Level3 + Disabled + true + true + Use + + + + + Level3 + Disabled + true + true + Use + + + + + Level3 + MaxSpeed + true + true + true + true + Use + + + true + true + + + + + + + + + + Create + Create + Create + Create + + + + + + \ No newline at end of file diff --git a/Ricoh2A03/src/Ricoh2A03.vcxproj.filters b/Ricoh2A03/src/Ricoh2A03.vcxproj.filters new file mode 100644 index 0000000..351df9f --- /dev/null +++ b/Ricoh2A03/src/Ricoh2A03.vcxproj.filters @@ -0,0 +1,29 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/Ricoh2A03/src/stdafx.cpp b/Ricoh2A03/src/stdafx.cpp new file mode 100644 index 0000000..1577c4e --- /dev/null +++ b/Ricoh2A03/src/stdafx.cpp @@ -0,0 +1 @@ +#include "stdafx.h" \ No newline at end of file