First stab at a Ricoh 2A03: A 6502 minus decimal mode support.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-12-25 23:34:56 +00:00
parent 637c0c68fa
commit 81ed53ce11
9 changed files with 236 additions and 22 deletions

View File

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

View File

@ -11,7 +11,7 @@
#include <Signal.h>
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);

View File

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

17
Ricoh2A03/inc/Ricoh2A03.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include <mos6502.h>
#include <Bus.h>
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;
};
}

1
Ricoh2A03/inc/stdafx.h Normal file
View File

@ -0,0 +1 @@
#pragma once

View File

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

View File

@ -0,0 +1,148 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{CCF67510-C3BD-40FD-BF13-9FA9B9BCFE43}</ProjectGuid>
<RootNamespace>Ricoh2A03</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>..\inc;..\..\M6502\inc;..\..\inc;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>..\inc;..\..\M6502\inc;..\..\inc;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>..\inc;..\..\M6502\inc;..\..\inc;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>..\inc;..\..\M6502\inc;..\..\inc;$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\inc\Ricoh2A03.h" />
<ClInclude Include="..\inc\stdafx.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Ricoh2A03.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\inc\stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\inc\Ricoh2A03.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Ricoh2A03.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>

1
Ricoh2A03/src/stdafx.cpp Normal file
View File

@ -0,0 +1 @@
#include "stdafx.h"