O2Hawk: Expose Core and start running code

This commit is contained in:
alyosha-tas 2019-11-18 17:33:55 -05:00
parent 8b9968da60
commit 61038a13ae
33 changed files with 253 additions and 43 deletions

View File

@ -12,6 +12,7 @@
#include gamedb_msx2.txt
#include gamedb_n64.txt
#include gamedb_nes.txt
#include gamedb_Odyssey2.txt
#include gamedb_pce_cd.txt
#include gamedb_pce_hucards.txt
#include gamedb_psx.txt

View File

@ -0,0 +1,3 @@
SHA1:26A044C68FF08F574F6649B731B82CACA8C0E797 Death Race O2

View File

@ -115,15 +115,17 @@ namespace BizHawk.Client.ApiHawk
return CoreSystem.GB3x;
case "GB4x":
return CoreSystem.GB3x;
return CoreSystem.GB4x;
case "MAME":
return CoreSystem.MAME;
case "O2":
return CoreSystem.Odyssey2;
case "VB":
case "NGP":
case "DNGP":
case "O2":
case "SGB":
case "UZE":
case "PCFX":
@ -235,6 +237,9 @@ namespace BizHawk.Client.ApiHawk
case CoreSystem.AmstradCPC:
return "AmstradCPC";
case CoreSystem.Odyssey2:
return "O2";
default:
throw new IndexOutOfRangeException($"{value} is missing in convert list");
}

View File

@ -37,6 +37,7 @@
GB3x,
GB4x,
ChannelF,
Odyssey2,
MAME
}
}

View File

@ -162,6 +162,8 @@ namespace BizHawk.Client.Common
return SystemInfo.AmstradCPC;
case "ChannelF":
return SystemInfo.ChannelF;
case "O2":
return SystemInfo.O2;
}
}
}

View File

@ -176,7 +176,7 @@ namespace BizHawk.Client.Common
private bool HandleArchiveBinding(HawkFile file)
{
var romExtensions = new[] { "SMS", "SMC", "SFC", "PCE", "SGX", "GG", "SG", "BIN", "GEN", "MD", "SMD", "GB", "NES", "FDS", "ROM", "INT", "GBC", "UNF", "A78", "CRT", "COL", "XML", "Z64", "V64", "N64", "WS", "WSC", "GBA", "32X", "VEC" };
var romExtensions = new[] { "SMS", "SMC", "SFC", "PCE", "SGX", "GG", "SG", "BIN", "GEN", "MD", "SMD", "GB", "NES", "FDS", "ROM", "INT", "GBC", "UNF", "A78", "CRT", "COL", "XML", "Z64", "V64", "N64", "WS", "WSC", "GBA", "32X", "VEC", "O2" };
// try binding normal rom extensions first
if (!file.IsBound)
@ -1178,6 +1178,9 @@ namespace BizHawk.Client.Common
case "VEC":
core = CoreInventory.Instance["VEC", "VectrexHawk"];
break;
case "O2":
core = CoreInventory.Instance["O2", "O2Hawk"];
break;
}
if (core != null)

View File

@ -221,8 +221,13 @@ namespace BizHawk.Client.Common
/// <summary>
/// Gets the <see cref="SystemInfo"/> instance for ChannelF
/// </summary>
///
public static SystemInfo ChannelF { get; } = new SystemInfo("Channel F", CoreSystem.ChannelF, 2);
/// <summary>
/// Gets the <see cref="SystemInfo"/> instance for ChannelF
/// </summary>
///
public static SystemInfo O2 { get; } = new SystemInfo("Odyssey2", CoreSystem.Odyssey2, 2);
/// <summary>
/// Gets the <see cref="SystemInfo"/> instance for MAME
/// </summary>

View File

@ -409,6 +409,13 @@ namespace BizHawk.Client.Common
new PathEntry { System = "VEC", SystemDisplayName = "VEC", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 },
new PathEntry { System = "VEC", SystemDisplayName = "VEC", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry { System = "VEC", SystemDisplayName = "VEC", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
new PathEntry { System = "O2", SystemDisplayName = "VEC", Type = "Base", Path = Path.Combine(".", "O2"), Ordinal = 0 },
new PathEntry { System = "O2", SystemDisplayName = "O2", Type = "ROM", Path = ".", Ordinal = 1 },
new PathEntry { System = "O2", SystemDisplayName = "O2", Type = "Savestates", Path = Path.Combine(".", "State"), Ordinal = 2 },
new PathEntry { System = "O2", SystemDisplayName = "O2", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 },
new PathEntry { System = "O2", SystemDisplayName = "O2", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 },
new PathEntry { System = "O2", SystemDisplayName = "O2", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 },
};
}
}

View File

@ -218,6 +218,7 @@ namespace BizHawk.Client.DBMan
ChannelF,
VEC,
GB3x,
GB4x
GB4x,
O2
}
}

View File

@ -1224,6 +1224,7 @@
<Compile Include="tools\VirtualPads\schema\AppleIISchema.cs" />
<Compile Include="tools\VirtualPads\schema\C64Schema.cs" />
<Compile Include="tools\VirtualPads\schema\ColecoSchema.cs" />
<Compile Include="tools\VirtualPads\schema\O2Schema .cs" />
<Compile Include="tools\VirtualPads\schema\VECSchema.cs" />
<Compile Include="tools\VirtualPads\schema\GGLSchema.cs" />
<Compile Include="tools\VirtualPads\schema\DualGBSchema.cs" />

View File

@ -0,0 +1,97 @@
using System.Collections.Generic;
using System.Drawing;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Cores.Consoles.O2Hawk;
namespace BizHawk.Client.EmuHawk
{
[Schema("O2")]
public class O2Schema : IVirtualPadSchema
{
public IEnumerable<PadSchema> GetPadSchemas(IEmulator core)
{
var O2SyncSettings = ((O2Hawk)core).GetSyncSettings().Clone();
// var port1 = O2SyncSettings.Port1;
// var port2 = O2SyncSettings.Port2;
// if (port1 == "O2 Controller")
// {
yield return StandardController(1);
// }
// if (port2 == "O2 Controller")
// {
yield return StandardController(2);
// }
}
private static PadSchema StandardController(int controller)
{
return new PadSchema
{
IsConsole = false,
DefaultSize = new Size(200, 100),
Buttons = new[]
{
new PadSchema.ButtonSchema
{
Name = $"P{controller} Up",
Icon = Properties.Resources.BlueUp,
Location = new Point(14, 12),
Type = PadSchema.PadInputType.Boolean
},
new PadSchema.ButtonSchema
{
Name = $"P{controller} Down",
Icon = Properties.Resources.BlueDown,
Location = new Point(14, 56),
Type = PadSchema.PadInputType.Boolean
},
new PadSchema.ButtonSchema
{
Name = $"P{controller} Left",
Icon = Properties.Resources.Back,
Location = new Point(2, 34),
Type = PadSchema.PadInputType.Boolean
},
new PadSchema.ButtonSchema
{
Name = $"P{controller} Right",
Icon = Properties.Resources.Forward,
Location = new Point(24, 34),
Type = PadSchema.PadInputType.Boolean
},
new PadSchema.ButtonSchema
{
Name = $"P{controller} Button 1",
DisplayName = "1",
Location = new Point(74, 34),
Type = PadSchema.PadInputType.Boolean
},
new PadSchema.ButtonSchema
{
Name = $"P{controller} Button 2",
DisplayName = "2",
Location = new Point(98, 34),
Type = PadSchema.PadInputType.Boolean
},
new PadSchema.ButtonSchema
{
Name = $"P{controller} Button 3",
DisplayName = "3",
Location = new Point(122, 34),
Type = PadSchema.PadInputType.Boolean
},
new PadSchema.ButtonSchema
{
Name = $"P{controller} Button 4",
DisplayName = "4",
Location = new Point(146, 34),
Type = PadSchema.PadInputType.Boolean
}
}
};
}
}
}

View File

@ -36,6 +36,8 @@ namespace BizHawk.Emulation.Common
new SystemInfo { SystemId = "ZXSpectrum", FullName = "Sinclair ZX Spectrum" },
new SystemInfo { SystemId = "AmstradCPC", FullName = "Amstrad CPC" },
new SystemInfo { SystemId = "ChannelF", FullName = "Fairchild Channel F"},
new SystemInfo { SystemId = "O2", FullName = "Odyssey2"},
new SystemInfo { SystemId = "VEC", FullName = "Vectrex"}
};
public SystemInfo this[string systemId]

View File

@ -79,6 +79,9 @@ namespace BizHawk.Emulation.Common.Components.I8048
public const ushort ST_T = 69;
public const ushort SET_ADDR_8 = 70;
public const ushort MEM_ALU = 71;
public const ushort PUSH = 72;
public const ushort PULL = 73;
public const ushort PULL_PC = 74;
public I8048()
{
@ -90,13 +93,13 @@ namespace BizHawk.Emulation.Common.Components.I8048
ResetRegisters();
ResetInterrupts();
TotalExecutedCycles = 0;
Regs[PC] = 0xFFFE;
Regs[PC] = 0x0;
PopulateCURINSTR(IDLE,
IDLE,
IDLE,
RD_INC, ALU, PC,
RD_INC, ALU2, PC,
SET_ADDR, PC, ALU, ALU2);
IDLE,
IDLE,
IDLE);
IRQS = 6;
instr_pntr = irq_pntr = 0;
@ -186,7 +189,7 @@ namespace BizHawk.Emulation.Common.Components.I8048
reg_l_ad = cur_instr[instr_pntr++];
reg_h_ad = cur_instr[instr_pntr++]; // direct value
Regs[reg_d_ad] = (ushort)(MB | reg_h_ad | Regs[reg_l_ad]);
Regs[reg_d_ad] = (ushort)(MB | (reg_h_ad << 8) | Regs[reg_l_ad]);
break;
case TST:
TST_Func(cur_instr[instr_pntr++]);
@ -337,20 +340,28 @@ namespace BizHawk.Emulation.Common.Components.I8048
break;
case ST_CNT:
counter_en = true;
break;
case STP_CNT:
counter_en = timer_en = false;
break;
case ST_T:
timer_en = true;
timer_prescale = 0;
break;
case EI:
IntEn = true;
break;
case EN:
TimIntEn = true;
break;
case DI:
IntEn = false;
break;
case DN:
TimIntEn = false;
TIRQPending = false;
break;
case INCA:
INC8_Func(A);
break;
@ -365,12 +376,37 @@ namespace BizHawk.Emulation.Common.Components.I8048
case MEM_ALU:
Regs[ALU] = Regs[(ushort)(Regs[cur_instr[instr_pntr++]] & 0x3F)];
break;
case PUSH:
Regs[(Regs[PSW] & 0x7) * 2 + 8] = (ushort)(Regs[PC] & 0xFF);
Regs[(Regs[PSW] & 0x7) * 2 + 8 + 1] = (ushort)(((Regs[PC] >> 8) & 0xF) | (Regs[PSW] & 0xF0));
Regs[PSW] = (ushort)((((Regs[PSW] & 0x7) + 1) & 0x7) | (Regs[PSW] & 0xF8));
break;
case PULL:
Regs[PSW] = (ushort)((((Regs[PSW] & 0x7) - 1) & 0x7) | (Regs[PSW] & 0xF8));
Regs[PC] = (ushort)(Regs[(Regs[PSW] & 0x7) * 2 + 8] & 0xFF);
Regs[PC] |= (ushort)((Regs[(Regs[PSW] & 0x7) * 2 + 8 + 1] & 0xF) << 8);
Regs[PSW] &= 0xF;
Regs[PSW] |= (ushort)(Regs[(Regs[PSW] & 0x7) * 2 + 8 + 1] & 0xF0);
break;
case PULL_PC:
Regs[PSW] = (ushort)((((Regs[PSW] & 0x7) - 1) & 0x7) | (Regs[PSW] & 0xF8));
Regs[PC] = (ushort)(Regs[(Regs[PSW] & 0x7) * 2 + 8] & 0xFF);
Regs[PC] |= (ushort)((Regs[(Regs[PSW] & 0x7) * 2 + 8 + 1] & 0xF) << 8);
break;
case MSK:
break;
case SWP:
reg_d_ad = Regs[A];
Regs[A] = (ushort)(Regs[A] >> 4);
Regs[A] |= (ushort)((reg_d_ad << 4) & 0xF0);
break;
}
if (++irq_pntr == IRQS)
{
// then regular IRQ
if (IRQPending && IntEn)
if ((IRQPending && IntEn) | (TIRQPending && TimIntEn))
{
IRQPending = false;
@ -390,6 +426,42 @@ namespace BizHawk.Emulation.Common.Components.I8048
}
TotalExecutedCycles++;
if (timer_en)
{
timer_prescale++;
if (timer_prescale == 32)
{
timer_prescale = 0;
if (Regs[TIM] == 255)
{
TF = true;
if (TimIntEn)
{
TIRQPending = true;
}
}
Regs[TIM] = (ushort)((Regs[TIM] + 1) & 0xFF);
}
}
if (counter_en)
{
if (!T1 && T1_old)
{
if (Regs[TIM] == 255)
{
TF = true;
if (TimIntEn)
{
TIRQPending = true;
}
}
Regs[TIM] = (ushort)((Regs[TIM] + 1) & 0xFF);
}
}
T1_old = T1;
}
// tracer stuff
@ -463,7 +535,9 @@ namespace BizHawk.Emulation.Common.Components.I8048
ser.BeginSection("MC6809");
ser.Sync(nameof(IntEn), ref IntEn);
ser.Sync(nameof(TimIntEn), ref TimIntEn);
ser.Sync(nameof(IRQPending), ref IRQPending);
ser.Sync(nameof(TIRQPending), ref TIRQPending);
ser.Sync(nameof(instr_pntr), ref instr_pntr);
ser.Sync(nameof(cur_instr), ref cur_instr, false);
@ -473,6 +547,8 @@ namespace BizHawk.Emulation.Common.Components.I8048
ser.Sync(nameof(TF), ref TF);
ser.Sync(nameof(timer_en), ref timer_en);
ser.Sync(nameof(counter_en), ref counter_en);
ser.Sync(nameof(timer_prescale), ref timer_prescale);
ser.Sync(nameof(RB), ref RB);
ser.Sync(nameof(RAM_ptr), ref RAM_ptr);
@ -482,6 +558,7 @@ namespace BizHawk.Emulation.Common.Components.I8048
ser.Sync(nameof(F1), ref F1);
ser.Sync(nameof(T0), ref T0);
ser.Sync(nameof(T1), ref T1);
ser.Sync(nameof(T1_old), ref T1_old);
ser.Sync(nameof(TotalExecutedCycles), ref TotalExecutedCycles);

View File

@ -18,7 +18,9 @@ namespace BizHawk.Emulation.Common.Components.I8048
}
public bool IRQPending;
public bool TIRQPending;
public bool IntEn;
public bool TimIntEn;
public Action IRQCallback = delegate () { };

View File

@ -124,7 +124,7 @@ namespace BizHawk.Emulation.Common.Components.I8048
IDLE,
IDLE,
IDLE,
IDLE,
PULL_PC,
IDLE,
IDLE,
IDLE,
@ -139,7 +139,7 @@ namespace BizHawk.Emulation.Common.Components.I8048
IDLE,
IDLE,
IDLE,
IDLE,
PULL,
IDLE,
IDLE,
IDLE,
@ -305,12 +305,12 @@ namespace BizHawk.Emulation.Common.Components.I8048
PopulateCURINSTR(IDLE,
IDLE,
IDLE,
TR, ALU, A,
RD, ALU, PC,
INC11, PC,
IDLE,
PUSH,
IDLE,
MSK, ALU,
IDLE,
ALU);
SET_ADDR, PC, ALU, dest_h);
IRQS = 9;
}

View File

@ -14,9 +14,11 @@ namespace BizHawk.Emulation.Common.Components.I8048
// The timer flag is set if the timer overflows, testing it resets it to zero
public bool TF;
public bool timer_en;
public bool counter_en;
public int timer_prescale;
// The 8048 has 2 test lines which can be used for conditionals, T0 can be used as an output
public bool T0, T1;
public bool T0, T1, T1_old;
// 8 'registers' but really they point to locations in RAM
public const ushort R0 = 0;

View File

@ -5,7 +5,7 @@ using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common;
using BizHawk.Common.NumberExtensions;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
// Audio Emulation (a 24 bit shift register plus a control register)
public class Audio : ISoundProvider

View File

@ -3,7 +3,7 @@ using System;
using BizHawk.Emulation.Common.Components.I8048;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public class MapperBase
{

View File

@ -4,7 +4,7 @@ using System;
using BizHawk.Emulation.Common.Components.I8048;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
// Default mapper with no bank switching
public class MapperDefault : MapperBase

View File

@ -8,7 +8,7 @@ using BizHawk.Emulation.Common;
$0000-$03FF BIOS
*/
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk
{
@ -24,7 +24,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
}
else
{
return mapper.ReadMemory(addr);
return mapper.ReadMemory((ushort)(addr - 0x400));
}
}
@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
}
else
{
return mapper.PeekMemory(addr);
return mapper.PeekMemory((ushort)(addr - 0x400));
}
}

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
using BizHawk.Emulation.Common;
using BizHawk.Emulation.Common.Components.I8048;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk : ICodeDataLogger
{

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk : IDebuggable
{

View File

@ -3,7 +3,7 @@
using BizHawk.Common.NumberExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk : IEmulator, IVideoProvider
{
@ -50,7 +50,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
public void do_frame(IController controller)
{
for (int i = 0; i < 70224; i++)
for (int i = 0; i < 100; i++)
{
audio.tick();
ppu.tick();

View File

@ -1,6 +1,6 @@
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk : IInputPollable
{

View File

@ -4,7 +4,7 @@ using System.Linq;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk
{

View File

@ -1,7 +1,7 @@
using System;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk : ISaveRam
{

View File

@ -6,7 +6,7 @@ using Newtonsoft.Json;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk : IEmulator, IStatable, ISettable<O2Hawk.O2Settings, O2Hawk.O2SyncSettings>
{

View File

@ -3,7 +3,7 @@
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public partial class O2Hawk : IStatable
{

View File

@ -6,7 +6,7 @@ using BizHawk.Emulation.Common.Components.I8048;
using System.Runtime.InteropServices;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
[Core(
"O2Hawk",
@ -73,7 +73,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
byte[] Bios = null;
Bios = comm.CoreFileProvider.GetFirmware("O2", "World", true, "BIOS Not Found, Cannot Load");
Bios = comm.CoreFileProvider.GetFirmware("O2", "BIOS", true, "BIOS Not Found, Cannot Load");
ppu = new PPU();
if (Bios == null)
@ -139,7 +139,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
private void Setup_Mapper()
{
mapper = new MapperDefault();
mapper.Core = this;
}
}
}

View File

@ -6,7 +6,7 @@ using BizHawk.Common;
using BizHawk.Common.ReflectionExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public class O2HawkControllerDeck
{

View File

@ -6,7 +6,7 @@ using System.Linq;
using BizHawk.Common;
using BizHawk.Emulation.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
/// <summary>
/// Represents a O2 add on

View File

@ -1,7 +1,7 @@
using System;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public class PPU
{

View File

@ -3,7 +3,7 @@ using BizHawk.Emulation.Common;
using BizHawk.Common.NumberExtensions;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Nintendo.O2Hawk
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
public class SerialPort
{