Vectrex: Start running the cpu and fixing bugs
This commit is contained in:
parent
41c57e5217
commit
9296092b84
|
@ -21,6 +21,7 @@
|
|||
#include gamedb_sega_md.txt
|
||||
#include gamedb_snes.txt
|
||||
#include gamedb_user.txt
|
||||
#include gamedb_vectrex.txt
|
||||
#include gamedb_ws.txt
|
||||
#include gamedb_wsc.txt
|
||||
#include gamedb_zxspectrum.txt
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
SHA1:67F8513958C04E936B135740ED4EC6E6FA1763D5 Clean Sweep VEC
|
|
@ -93,6 +93,9 @@ namespace BizHawk.Client.ApiHawk
|
|||
case "TI83":
|
||||
return CoreSystem.TI83;
|
||||
|
||||
case "VEC":
|
||||
return CoreSystem.Vectrex;
|
||||
|
||||
case "WSWAN":
|
||||
return CoreSystem.WonderSwan;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
WonderSwan,
|
||||
Libretro,
|
||||
VirtualBoy,
|
||||
Vectrex,
|
||||
NeoGeoPocket,
|
||||
ZXSpectrum,
|
||||
AmstradCPC,
|
||||
|
|
|
@ -28,6 +28,7 @@ using GPGX64 = BizHawk.Emulation.Cores.Consoles.Sega.gpgx;
|
|||
using BizHawk.Emulation.Cores.Consoles.Sega.Saturn;
|
||||
using BizHawk.Emulation.Cores.Consoles.NEC.PCFX;
|
||||
using BizHawk.Emulation.Cores.Computers.AmstradCPC;
|
||||
using BizHawk.Emulation.Cores.Consoles.Vectrex;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
|
|
@ -183,6 +183,11 @@ namespace BizHawk.Client.Common
|
|||
/// </summary>
|
||||
public static SystemInfo VirtualBoy { get; } = new SystemInfo("Virtual Boy", CoreSystem.VirtualBoy, 1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SystemInfo"/> instance for Vectrex
|
||||
/// </summary>
|
||||
public static SystemInfo Vectrex { get; } = new SystemInfo("Vextrex", CoreSystem.Vectrex, 2);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="SystemInfo"/> instance for TI-83
|
||||
/// </summary>
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace BizHawk.Emulation.Common
|
|||
FirmwareAndOption("5A140136A16D1D83E4FF32A19409CA376A8DF874", 16384, "A78", "Bios_PAL", "7800PALBIOS.bin", "PAL Bios");
|
||||
FirmwareAndOption("A3AF676991391A6DD716C79022D4947206B78164", 4096, "A78", "Bios_HSC", "7800highscore.bin", "Highscore Bios");
|
||||
FirmwareAndOption("45BEDC4CBDEAC66C7DF59E9E599195C778D86A92", 8192, "Coleco", "Bios", "ColecoBios.bin", "Bios");
|
||||
FirmwareAndOption("B9BBF5BB0EAC52D039A4A993A2D8064B862C9E28", 4096, "Vectrex", "Bios", "VectrexBios.bin", "Bios");
|
||||
|
||||
var gbaNormal = File("300C20DF6731A33952DED8C436F7F186D25D3492", 16384, "gbabios.rom", "Bios (World)");
|
||||
var gbaJDebug = File("AA98A2AD32B86106340665D1222D7D973A1361C7", 16384, "gbabios.rom", "Bios (J Debug)");
|
||||
|
|
|
@ -596,7 +596,6 @@
|
|||
<Compile Include="Consoles\Belogic\LibUzem.cs" />
|
||||
<Compile Include="Consoles\Belogic\Uzem.cs" />
|
||||
<Compile Include="Consoles\GCE\Vectrex\Audio.cs" />
|
||||
<Compile Include="Consoles\GCE\Vectrex\Vectrex.CpuLink.cs" />
|
||||
<Compile Include="Consoles\GCE\Vectrex\VectrexHawk.cs" />
|
||||
<Compile Include="Consoles\GCE\Vectrex\VectrexHawk.ICodeDataLog.cs" />
|
||||
<Compile Include="Consoles\GCE\Vectrex\VectrexHawk.IDebuggable.cs">
|
||||
|
|
|
@ -793,17 +793,23 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
bytes.Add(reader(addr++));
|
||||
|
||||
string result = table[bytes[0]];
|
||||
if (bytes[0] == 0xcb)
|
||||
if (bytes[0] == 0x10)
|
||||
{
|
||||
bytes.Add(reader(addr++));
|
||||
result = table[bytes[1] + 256];
|
||||
result = table2[bytes[1]];
|
||||
}
|
||||
|
||||
if (result.Contains("d8"))
|
||||
if (bytes[0] == 0x11)
|
||||
{
|
||||
bytes.Add(reader(addr++));
|
||||
result = table3[bytes[1]];
|
||||
}
|
||||
|
||||
if (result.Contains("i8"))
|
||||
{
|
||||
byte d = reader(addr++);
|
||||
bytes.Add(d);
|
||||
result = result.Replace("d8", string.Format("#{0:X2}h", d));
|
||||
result = result.Replace("i8", string.Format("#{0:X2}h", d));
|
||||
}
|
||||
else if (result.Contains("d16"))
|
||||
{
|
||||
|
|
|
@ -8,14 +8,19 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
// variables for executing instructions
|
||||
public int instr_pntr = 0;
|
||||
public ushort[] cur_instr;
|
||||
public int opcode;
|
||||
public ushort[] cur_instr = new ushort[60];
|
||||
public int opcode_see;
|
||||
|
||||
public int IRQS;
|
||||
public int irq_pntr;
|
||||
|
||||
ushort reg_d_ad;
|
||||
ushort reg_h_ad;
|
||||
ushort reg_l_ad;
|
||||
|
||||
public void FetchInstruction(byte opcode)
|
||||
{
|
||||
opcode_see = opcode;
|
||||
switch (opcode)
|
||||
{
|
||||
case 0x00: DIRECT_MEM(NEG); break; // NEG (Direct)
|
||||
|
@ -279,6 +284,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
public void FetchInstruction2(byte opcode)
|
||||
{
|
||||
opcode_see = opcode;
|
||||
switch (opcode)
|
||||
{
|
||||
case 0x21: LBR_(false); break; // BRN (Relative)
|
||||
|
@ -326,6 +332,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
public void FetchInstruction3(byte opcode)
|
||||
{
|
||||
opcode_see = opcode;
|
||||
switch (opcode)
|
||||
{
|
||||
case 0x3F: SWI2_3(3); break; // SWI3 (Inherent)
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
PopulateCURINSTR(RD_INC_OP, ALU, PC, IDX_DCDE);
|
||||
|
||||
IRQS = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
|
||||
private void INDEX_OP_REG(ushort oper, ushort src)
|
||||
|
@ -63,25 +63,25 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
PopulateCURINSTR(RD_INC_OP, ALU, PC, IDX_DCDE);
|
||||
|
||||
IRQS = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
|
||||
private void INDEX_OP_JMP()
|
||||
{
|
||||
PopulateCURINSTR(TR, PC, IDX_EA);
|
||||
|
||||
IRQS = irq_pntr + 2;
|
||||
IRQS = 1;
|
||||
}
|
||||
|
||||
private void INDEX_OP_JSR()
|
||||
{
|
||||
PopulateCURINSTR(IDLE,
|
||||
IDLE,
|
||||
PopulateCURINSTR(TR, ADDR, PC,
|
||||
DEC16, SP,
|
||||
TR, PC, IDX_EA,
|
||||
WR_DEC_LO, SP, ADDR,
|
||||
WR_HI, SP, ADDR);
|
||||
|
||||
IRQS = irq_pntr + 6;
|
||||
IRQS = 5;
|
||||
}
|
||||
|
||||
private void INDEX_OP_LEA(ushort dest)
|
||||
|
@ -89,7 +89,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
PopulateCURINSTR(TR, dest, IDX_EA,
|
||||
IDLE);
|
||||
|
||||
IRQS = irq_pntr + 3;
|
||||
IRQS = 2;
|
||||
}
|
||||
|
||||
private void INDEX_OP_LD()
|
||||
|
@ -98,7 +98,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
RD_INC, ALU, IDX_EA,
|
||||
RD_INC_OP, ALU2, IDX_EA, SET_ADDR, indexed_op_reg, ALU, ALU2);
|
||||
|
||||
IRQS = irq_pntr + 4;
|
||||
IRQS = 3;
|
||||
}
|
||||
|
||||
private void INDEX_OP_ST()
|
||||
|
@ -107,7 +107,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
WR_HI_INC, IDX_EA, indexed_op_reg,
|
||||
WR_DEC_LO, IDX_EA, indexed_op_reg);
|
||||
|
||||
IRQS = irq_pntr + 4;
|
||||
IRQS = 3;
|
||||
}
|
||||
|
||||
private void INDEX_OP_LDD()
|
||||
|
@ -116,7 +116,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
RD_INC, A, IDX_EA,
|
||||
RD_INC, B, IDX_EA);
|
||||
|
||||
IRQS = irq_pntr + 4;
|
||||
IRQS = 3;
|
||||
}
|
||||
|
||||
private void INDEX_OP_STD()
|
||||
|
@ -125,7 +125,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
WR_HI_INC, IDX_EA, ADDR,
|
||||
WR_DEC_LO, IDX_EA, B);
|
||||
|
||||
IRQS = irq_pntr + 4;
|
||||
Console.WriteLine("here");
|
||||
IRQS = 3;
|
||||
}
|
||||
|
||||
private void INDEX_OP_EX4(ushort oper)
|
||||
|
@ -133,7 +134,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
PopulateCURINSTR(IDLE,
|
||||
RD_INC_OP, ALU, IDX_EA, oper, indexed_op_reg, ALU);
|
||||
|
||||
IRQS = irq_pntr + 3;
|
||||
IRQS = 2;
|
||||
}
|
||||
|
||||
private void INDEX_OP_EX4_ST()
|
||||
|
@ -141,7 +142,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
PopulateCURINSTR(IDLE,
|
||||
WR, ALU, IDX_EA, indexed_op_reg);
|
||||
|
||||
IRQS = irq_pntr + 3;
|
||||
IRQS = 2;
|
||||
}
|
||||
|
||||
private void INDEX_OP_EX6(ushort oper)
|
||||
|
@ -151,7 +152,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
oper, ALU,
|
||||
WR, IDX_EA, ALU);
|
||||
|
||||
IRQS = irq_pntr + 5;
|
||||
IRQS = 4;
|
||||
}
|
||||
|
||||
private void INDEX_OP_EX6D(ushort oper)
|
||||
|
@ -161,7 +162,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
RD_INC_OP, ALU2, IDX_EA, SET_ADDR, ADDR, ALU, ALU2,
|
||||
oper, ADDR);
|
||||
|
||||
IRQS = irq_pntr + 5;
|
||||
IRQS = 4;
|
||||
}
|
||||
|
||||
private void INDEX_CMP_EX6(ushort oper)
|
||||
|
@ -171,7 +172,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
RD_INC_OP, ALU2, IDX_EA, SET_ADDR, ADDR, ALU, ALU2,
|
||||
oper, indexed_op_reg, ADDR);
|
||||
|
||||
IRQS = irq_pntr + 5;
|
||||
IRQS = 4;
|
||||
}
|
||||
|
||||
// ALU holds the post byte
|
||||
|
@ -348,6 +349,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
case 0x4:
|
||||
Regs[IDX_EA] = Regs[indexed_reg];
|
||||
Index_Op_Builder();
|
||||
return; // need to return here or else we run into the code below invalidating irq_pntr
|
||||
break;
|
||||
case 0x5:
|
||||
Regs[IDX_EA] = (ushort)(Regs[indexed_reg] + (((Regs[B] & 0x80) == 0x80) ? (Regs[B] | 0xFF00) : Regs[B]));
|
||||
|
@ -447,7 +449,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
}
|
||||
|
||||
instr_pntr = 0;
|
||||
irq_pntr = 100;
|
||||
irq_pntr = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,12 +85,12 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
ResetRegisters();
|
||||
ResetInterrupts();
|
||||
TotalExecutedCycles = 0;
|
||||
Regs[ADDR] = 0xFFFE;
|
||||
Regs[PC] = 0xFFFE;
|
||||
PopulateCURINSTR(IDLE,
|
||||
IDLE,
|
||||
IDLE,
|
||||
RD_INC, ALU, ADDR,
|
||||
RD_INC, ALU2, ADDR,
|
||||
RD_INC, ALU, PC,
|
||||
RD_INC, ALU2, PC,
|
||||
SET_ADDR, PC, ALU, ALU2);
|
||||
|
||||
IRQS = 6;
|
||||
|
@ -148,6 +148,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
// Execute instructions
|
||||
public void ExecuteOne()
|
||||
{
|
||||
Console.Write(opcode_see + " ");
|
||||
switch (cur_instr[instr_pntr++])
|
||||
{
|
||||
case IDLE:
|
||||
|
@ -160,12 +161,17 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
if (CDLCallback != null) CDLCallback(PC, eCDLogMemFlags.FetchFirst);
|
||||
FetchInstruction(ReadMemory(Regs[PC]++));
|
||||
instr_pntr = 0;
|
||||
irq_pntr = -1;
|
||||
break;
|
||||
case OP_PG_2:
|
||||
FetchInstruction2(ReadMemory(Regs[PC]++));
|
||||
instr_pntr = 0;
|
||||
irq_pntr = -1;
|
||||
break;
|
||||
case OP_PG_3:
|
||||
FetchInstruction3(ReadMemory(Regs[PC]++));
|
||||
instr_pntr = 0;
|
||||
irq_pntr = -1;
|
||||
break;
|
||||
case RD:
|
||||
Read_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
|
||||
|
@ -207,8 +213,15 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
case DEC16:
|
||||
DEC16_Func(cur_instr[instr_pntr++]);
|
||||
break;
|
||||
case TR:
|
||||
TR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
|
||||
break;
|
||||
case SET_ADDR:
|
||||
Regs[cur_instr[instr_pntr++]] = (ushort)((Regs[cur_instr[instr_pntr++]] << 8) | Regs[cur_instr[instr_pntr++]]);
|
||||
reg_d_ad = cur_instr[instr_pntr++];
|
||||
reg_h_ad = cur_instr[instr_pntr++];
|
||||
reg_l_ad = cur_instr[instr_pntr++];
|
||||
|
||||
Regs[reg_d_ad] = (ushort)((Regs[reg_h_ad] << 8) | Regs[reg_l_ad]);
|
||||
break;
|
||||
case JPE:
|
||||
if (!FlagE) { instr_pntr = 45; };
|
||||
|
@ -282,7 +295,14 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
TFR_Func(cur_instr[instr_pntr++]);
|
||||
break;
|
||||
case SET_ADDR:
|
||||
Regs[cur_instr[instr_pntr++]] = (ushort)((Regs[cur_instr[instr_pntr++]] << 8) | Regs[cur_instr[instr_pntr++]]);
|
||||
reg_d_ad = cur_instr[instr_pntr++];
|
||||
reg_h_ad = cur_instr[instr_pntr++];
|
||||
reg_l_ad = cur_instr[instr_pntr++];
|
||||
|
||||
// Console.WriteLine(reg_d_ad + " " + reg_h_ad + " " + reg_l_ad);
|
||||
// Console.WriteLine(Regs[reg_d_ad] + " " + Regs[reg_h_ad] + " " + Regs[reg_l_ad]);
|
||||
|
||||
Regs[reg_d_ad] = (ushort)((Regs[reg_h_ad] << 8) | Regs[reg_l_ad]);
|
||||
break;
|
||||
case NEG:
|
||||
NEG_8_Func(cur_instr[instr_pntr++]);
|
||||
|
@ -436,7 +456,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
{
|
||||
PopulateCURINSTR(CWAI);
|
||||
irq_pntr = 0;
|
||||
IRQS = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
instr_pntr = 0;
|
||||
break;
|
||||
|
@ -525,6 +545,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
{
|
||||
PopulateCURINSTR(OP);
|
||||
instr_pntr = irq_pntr = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,7 +569,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
{
|
||||
Disassembly = string.Format(
|
||||
"{0} ",
|
||||
disassemble ? Disassemble(PC, ReadMemory, out notused) : "---").PadRight(40),
|
||||
disassemble ? Disassemble(Regs[PC], ReadMemory, out notused) : "---").PadRight(40),
|
||||
RegisterInfo = string.Format(
|
||||
"A:{0:X2} B:{1:X2} X:{2:X4} Y:{3:X4} US:{4:X4} SP:{5:X4} DP:{6:X2} CC:{7:X2} Cy:{8} {9}{10}{11}{12}{13}{14}{15}{16}",
|
||||
Regs[A],
|
||||
|
@ -621,7 +642,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
ser.Sync("instr_pntr", ref instr_pntr);
|
||||
ser.Sync("cur_instr", ref cur_instr, false);
|
||||
ser.Sync("opcode", ref opcode);
|
||||
ser.Sync("opcode_see", ref opcode_see);
|
||||
ser.Sync("IRQS", ref IRQS);
|
||||
ser.Sync("irq_pntr", ref irq_pntr);
|
||||
|
||||
|
|
|
@ -17,7 +17,10 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
private void ILLEGAL()
|
||||
{
|
||||
throw new Exception("Encountered illegal instruction");
|
||||
//throw new Exception("Encountered illegal instruction");
|
||||
PopulateCURINSTR(IDLE);
|
||||
|
||||
IRQS = 1;
|
||||
}
|
||||
|
||||
private void SYNC_()
|
||||
|
@ -25,7 +28,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
PopulateCURINSTR(IDLE,
|
||||
SYNC);
|
||||
|
||||
IRQS = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
|
||||
private void REG_OP(ushort oper, ushort src)
|
||||
|
@ -278,7 +281,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
private void EXG_()
|
||||
{
|
||||
PopulateCURINSTR(RD_INC, ALU,
|
||||
PopulateCURINSTR(RD_INC, ALU, PC,
|
||||
EXG, ALU,
|
||||
IDLE,
|
||||
IDLE,
|
||||
|
@ -291,7 +294,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
|
||||
private void TFR_()
|
||||
{
|
||||
PopulateCURINSTR(RD_INC, ALU,
|
||||
PopulateCURINSTR(RD_INC, ALU, PC,
|
||||
TFR, ALU,
|
||||
IDLE,
|
||||
IDLE,
|
||||
|
@ -321,7 +324,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
{
|
||||
PopulateCURINSTR(RD_INC, ALU, PC,
|
||||
SET_ADDR, ADDR, DP, ALU,
|
||||
IDLE,
|
||||
DEC16, SP,
|
||||
TR, PC, ADDR,
|
||||
WR_DEC_LO, SP, ADDR,
|
||||
WR_HI, SP, ADDR);
|
||||
|
@ -332,12 +335,12 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
private void JSR_EXT()
|
||||
{
|
||||
PopulateCURINSTR(RD_INC, ALU, PC,
|
||||
RD_INC_OP, ALU2, PC,
|
||||
SET_ADDR, ADDR, ALU, ALU2,
|
||||
IDLE,
|
||||
RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2,
|
||||
TR, ALU, PC,
|
||||
DEC16, SP,
|
||||
TR, PC, ADDR,
|
||||
WR_DEC_LO, SP, ADDR,
|
||||
WR_HI, SP, ADDR);
|
||||
WR_DEC_LO, SP, ALU,
|
||||
WR_HI, SP, ALU);
|
||||
|
||||
IRQS = 7;
|
||||
}
|
||||
|
@ -384,8 +387,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
private void BSR_()
|
||||
{
|
||||
PopulateCURINSTR(RD_INC, ALU, PC,
|
||||
ADD8BR, PC, ALU,
|
||||
TR, ADDR, PC,
|
||||
ADD8BR, PC, ALU,
|
||||
DEC16, SP,
|
||||
WR_DEC_LO, SP, ADDR,
|
||||
WR_HI, SP, ADDR);
|
||||
|
@ -398,11 +401,11 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
PopulateCURINSTR(RD_INC, ALU, PC,
|
||||
RD_INC, ALU2, PC,
|
||||
SET_ADDR, ADDR, ALU, ALU2,
|
||||
TR, ALU, PC,
|
||||
ADD16BR, PC, ADDR,
|
||||
TR, ADDR, PC,
|
||||
DEC16, SP,
|
||||
WR_DEC_LO, SP, ADDR,
|
||||
WR_HI, SP, ADDR);
|
||||
WR_DEC_LO, SP, ALU,
|
||||
WR_HI, SP, ALU);
|
||||
|
||||
IRQS = 8;
|
||||
}
|
||||
|
@ -411,14 +414,14 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
{
|
||||
PopulateCURINSTR(OP_PG_2);
|
||||
|
||||
IRQS = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
|
||||
private void PAGE_3()
|
||||
{
|
||||
PopulateCURINSTR(OP_PG_3);
|
||||
|
||||
IRQS = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
|
||||
private void ABX_()
|
||||
|
@ -482,7 +485,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
DEC16, SP,
|
||||
PSH_n, src);
|
||||
|
||||
IRQS = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
|
||||
// Post byte info is in ALU
|
||||
|
@ -546,6 +549,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
else if (Regs[ALU].Bit(0))
|
||||
{
|
||||
PopulateCURINSTR(WR_DEC_LO_OP, src, CC, PSH_n, src);
|
||||
|
||||
Regs[ALU] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -561,55 +566,54 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
{
|
||||
PopulateCURINSTR(RD_INC, ALU, PC,
|
||||
IDLE,
|
||||
PSH_n, src);
|
||||
PUL_n, src);
|
||||
|
||||
IRQS = 0;
|
||||
IRQS = -1;
|
||||
}
|
||||
|
||||
// Post byte info is in ALU
|
||||
// mask out bits until the end
|
||||
private void PUL_n_BLD(ushort src)
|
||||
{
|
||||
if (Regs[ALU].Bit(7))
|
||||
if (Regs[ALU].Bit(0))
|
||||
{
|
||||
PopulateCURINSTR(RD_INC_OP, CC, src, PUL_n, src);
|
||||
|
||||
Regs[ALU] &= 0x7F;
|
||||
Regs[ALU] &= 0xFE;
|
||||
}
|
||||
else if (Regs[ALU].Bit(6))
|
||||
else if (Regs[ALU].Bit(1))
|
||||
{
|
||||
PopulateCURINSTR(RD_INC_OP, A, src, PUL_n, src);
|
||||
|
||||
Regs[ALU] &= 0x3F;
|
||||
Regs[ALU] &= 0xFC;
|
||||
}
|
||||
else if (Regs[ALU].Bit(5))
|
||||
else if (Regs[ALU].Bit(2))
|
||||
{
|
||||
PopulateCURINSTR(RD_INC_OP, B, src, PUL_n, src);
|
||||
|
||||
|
||||
Regs[ALU] &= 0x1F;
|
||||
Regs[ALU] &= 0xF8;
|
||||
}
|
||||
else if (Regs[ALU].Bit(4))
|
||||
else if (Regs[ALU].Bit(3))
|
||||
{
|
||||
PopulateCURINSTR(RD_INC_OP, DP, src, PUL_n, src);
|
||||
|
||||
Regs[ALU] &= 0xF;
|
||||
Regs[ALU] &= 0xF0;
|
||||
}
|
||||
else if (Regs[ALU].Bit(3))
|
||||
else if (Regs[ALU].Bit(4))
|
||||
{
|
||||
PopulateCURINSTR(RD_INC_OP, ALU2, src,
|
||||
RD_INC_OP, ADDR, src, SET_ADDR_PUL, X, src);
|
||||
|
||||
Regs[ALU] &= 0x7;
|
||||
Regs[ALU] &= 0xE0;
|
||||
}
|
||||
else if (Regs[ALU].Bit(2))
|
||||
else if (Regs[ALU].Bit(5))
|
||||
{
|
||||
PopulateCURINSTR(RD_INC_OP, ALU2, src,
|
||||
RD_INC_OP, ADDR, src, SET_ADDR_PUL, Y, src);
|
||||
|
||||
Regs[ALU] &= 0x3;
|
||||
Regs[ALU] &= 0xC0;
|
||||
}
|
||||
else if (Regs[ALU].Bit(1))
|
||||
else if (Regs[ALU].Bit(6))
|
||||
{
|
||||
if (src == US)
|
||||
{
|
||||
|
@ -622,12 +626,14 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
RD_INC_OP, ADDR, src, SET_ADDR_PUL, US, src);
|
||||
}
|
||||
|
||||
Regs[ALU] &= 0x1;
|
||||
Regs[ALU] &= 0x80;
|
||||
}
|
||||
else if (Regs[ALU].Bit(0))
|
||||
else if (Regs[ALU].Bit(7))
|
||||
{
|
||||
PopulateCURINSTR(RD_INC_OP, ALU2, src,
|
||||
RD_INC_OP, ADDR, src, SET_ADDR_PUL, PC, src);
|
||||
|
||||
Regs[ALU] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -22,9 +22,11 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
if (src == PC) CDLCallback(Regs[src], eCDLogMemFlags.FetchOperand);
|
||||
else CDLCallback(Regs[src], eCDLogMemFlags.Data);
|
||||
}
|
||||
//Console.WriteLine(dest + " " + src + " " + opcode_see);
|
||||
|
||||
Regs[dest] = ReadMemory(Regs[src]);
|
||||
|
||||
Regs[src] = Regs[src]++;
|
||||
Regs[src]++;
|
||||
}
|
||||
|
||||
public void Write_Func(ushort dest_l, ushort dest_h, ushort src)
|
||||
|
@ -698,7 +700,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
|||
}
|
||||
else
|
||||
{
|
||||
Regs[dest] = Regs[dest];
|
||||
Regs[dest] = Regs[src];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ using BizHawk.Common.NumberExtensions;
|
|||
namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||
{
|
||||
// An AY_3_8912
|
||||
|
||||
public class Audio : ISoundProvider
|
||||
{
|
||||
public VectrexHawk Core { get; set; }
|
||||
|
|
|
@ -7,9 +7,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
{
|
||||
public partial class VectrexHawk
|
||||
{
|
||||
// Interact with Hardware registers through these read and write methods
|
||||
// Typically you will only be able to access different parts of the hardware through their available registers
|
||||
// Sending the memory map of these regiesters through here helps keep things organized even though it results in an extra function call
|
||||
public byte Read_Registers(int addr)
|
||||
{
|
||||
byte ret = 0;
|
||||
|
@ -33,7 +30,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
public void Register_Reset()
|
||||
{
|
||||
// Registers will start with a default value at power on, use this funciton to set them
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,30 +15,104 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
{
|
||||
public partial class VectrexHawk
|
||||
{
|
||||
// typically here you have a big if / else if block to decide what to do with memory reads and writes
|
||||
// send hardware register accesses to the Read_register / Write_register methods
|
||||
// make sure you are returning the correct value (typically 0 or 0xFF) for unmapped memory
|
||||
|
||||
// PeekMemory is called by the hex eidtor and other tools to read what's on the bus
|
||||
// make sure it doesn't modify anything in the core or you will be in debugging hell.
|
||||
|
||||
public byte ReadMemory(ushort addr)
|
||||
{
|
||||
// memory callbacks are used for LUA and such
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
|
||||
return 0;
|
||||
if (addr < 0x8000)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else if (addr < 0xC800)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else if (addr < 0xD000)
|
||||
{
|
||||
return RAM[(addr-0xC800) & 0x3FF];
|
||||
}
|
||||
else if (addr < 0xD800)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else if (addr < 0xE000)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else if (addr < 0xF000)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _bios[addr - 0xF000];
|
||||
}
|
||||
}
|
||||
|
||||
public void WriteMemory(ushort addr, byte value)
|
||||
{
|
||||
MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
|
||||
|
||||
if (addr < 0x8000)
|
||||
{
|
||||
|
||||
}
|
||||
else if (addr < 0xC800)
|
||||
{
|
||||
|
||||
}
|
||||
else if (addr < 0xD000)
|
||||
{
|
||||
RAM[(addr - 0xC800) & 0x3FF] = value;
|
||||
}
|
||||
else if (addr < 0xD800)
|
||||
{
|
||||
|
||||
}
|
||||
else if (addr < 0xE000)
|
||||
{
|
||||
|
||||
}
|
||||
else if (addr < 0xF000)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public byte PeekMemory(ushort addr)
|
||||
{
|
||||
return 0;
|
||||
if (addr < 0x8000)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else if (addr < 0xC800)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else if (addr < 0xD000)
|
||||
{
|
||||
return RAM[(addr - 0xC800) & 0x3FF];
|
||||
}
|
||||
else if (addr < 0xD800)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else if (addr < 0xE000)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else if (addr < 0xF000)
|
||||
{
|
||||
return 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
return _bios[addr - 0xF000];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,6 @@ using BizHawk.Common;
|
|||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||
{
|
||||
// Here is where you will write the renderer for the core.
|
||||
// You will probably spend just about all of your time writing this part.
|
||||
// Plan ahead on what types of memory structures you want, and understand how the physical display unit sees data
|
||||
// if you get stuck, probably GBHawk has the cleanest implementation to use for reference
|
||||
|
||||
public class PPU
|
||||
{
|
||||
public VectrexHawk Core { get; set; }
|
||||
|
@ -22,13 +17,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
}
|
||||
|
||||
// you should be able to run the PPU one step at a time through this method.
|
||||
public void tick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// if some values aren't latched immediately, you might need this function to delay their latching
|
||||
public virtual void latch_delay()
|
||||
{
|
||||
|
||||
|
@ -39,7 +32,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
}
|
||||
|
||||
// Reset all values here, should be called along with other reset methods
|
||||
public void Reset()
|
||||
{
|
||||
|
||||
|
|
|
@ -5,11 +5,6 @@ using BizHawk.Common;
|
|||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||
{
|
||||
// your core may have several integral peripherals beyond the usual graphics / sound / controller
|
||||
// here is one such example
|
||||
// Treat it the same way as any other component. you should be able to run it one tick at a time in sync with the
|
||||
// other parts of the core
|
||||
|
||||
public class SerialPort
|
||||
{
|
||||
public VectrexHawk Core { get; set; }
|
||||
|
@ -24,7 +19,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
}
|
||||
|
||||
|
||||
public void serial_transfer_tick()
|
||||
{
|
||||
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
using BizHawk.Emulation.Cores.Components.M6502;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||
{
|
||||
public partial class VectrexHawk
|
||||
{
|
||||
public struct CpuLink : IMOS6502XLink
|
||||
{
|
||||
private readonly VectrexHawk _Vectrex;
|
||||
|
||||
public CpuLink(VectrexHawk Vectrex)
|
||||
{
|
||||
_Vectrex = Vectrex;
|
||||
}
|
||||
|
||||
public byte DummyReadMemory(ushort address) => _Vectrex.ReadMemory(address);
|
||||
|
||||
public void OnExecFetch(ushort address) => _Vectrex.ExecFetch(address);
|
||||
|
||||
public byte PeekMemory(ushort address) => _Vectrex.CDL == null ? _Vectrex.PeekMemory(address) : _Vectrex.FetchMemory_CDL(address);
|
||||
|
||||
public byte ReadMemory(ushort address) => _Vectrex.CDL == null ? _Vectrex.ReadMemory(address) : _Vectrex.ReadMemory_CDL(address);
|
||||
|
||||
public void WriteMemory(ushort address, byte value) => _Vectrex.WriteMemory(address, value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -44,12 +44,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
public void do_frame()
|
||||
{
|
||||
|
||||
for (int i = 0; i < 4500; i++)
|
||||
{
|
||||
cpu.ExecuteOne();
|
||||
}
|
||||
}
|
||||
|
||||
public int Frame => _frame;
|
||||
|
||||
public string SystemId => "VIC20";
|
||||
public string SystemId => "VEC";
|
||||
|
||||
public bool DeterministicEmulation { get; set; }
|
||||
|
||||
|
|
|
@ -17,22 +17,12 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
public partial class VectrexHawk : IEmulator, ISaveRam, IDebuggable, IStatable, IInputPollable, IRegionable,
|
||||
ISettable<VectrexHawk.VectrexSettings, VectrexHawk.VectrexSyncSettings>
|
||||
{
|
||||
// declaractions
|
||||
// put top level core variables here
|
||||
// including things like RAM and BIOS
|
||||
// they will be used in the hex editor and others
|
||||
|
||||
// the following declaraion is only an example
|
||||
// see memoryDomains.cs to see how it is used to define a Memory Domain that you can see in Hex editor
|
||||
// ex:
|
||||
public byte[] RAM = new byte[0x8000];
|
||||
public byte[] RAM = new byte[0x400];
|
||||
|
||||
|
||||
public byte[] _bios;
|
||||
public readonly byte[] _rom;
|
||||
|
||||
// sometimes roms will have a header
|
||||
// the following is only an example in order to demonstrate how to extract the header
|
||||
public readonly byte[] header = new byte[0x50];
|
||||
|
||||
public byte[] cart_RAM;
|
||||
|
@ -49,9 +39,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
public Audio audio;
|
||||
public SerialPort serialport;
|
||||
|
||||
private static byte[] GBA_override = { 0xFF, 0x00, 0xCD, 0x03, 0x35, 0xAA, 0x31, 0x90, 0x94, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
[CoreConstructor("Vectrex")]
|
||||
[CoreConstructor("VEC")]
|
||||
public VectrexHawk(CoreComm comm, GameInfo game, byte[] rom, /*string gameDbFn,*/ object settings, object syncSettings)
|
||||
{
|
||||
var ser = new BasicServiceProvider(this);
|
||||
|
@ -75,30 +63,24 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
_syncSettings = (VectrexSyncSettings)syncSettings ?? new VectrexSyncSettings();
|
||||
_controllerDeck = new VectrexHawkControllerDeck(_syncSettings.Port1);
|
||||
|
||||
// BIOS stuff can be tricky. Sometimes you'll have more then one vailable BIOS or different BIOSes for different regions
|
||||
// for now I suggest just picking one going
|
||||
byte[] Bios = null;
|
||||
//Bios = comm.CoreFileProvider.GetFirmware("Vectrex", "Bios", true, "BIOS Not Found, Cannot Load");
|
||||
Bios = comm.CoreFileProvider.GetFirmware("Vectrex", "Bios", true, "BIOS Not Found, Cannot Load");
|
||||
_bios = Bios;
|
||||
|
||||
// the following few lines are jsut examples of working with a header and hashes
|
||||
Buffer.BlockCopy(rom, 0x100, header, 0, 0x50);
|
||||
string hash_md5 = null;
|
||||
hash_md5 = "md5:" + rom.HashMD5(0, rom.Length);
|
||||
Console.WriteLine(hash_md5);
|
||||
|
||||
// in this case our working ROm has the header removed (might not be the case for your system)
|
||||
_rom = rom;
|
||||
Setup_Mapper();
|
||||
|
||||
_frameHz = 60;
|
||||
|
||||
// usually you want to have a reflected core available to the various components since they share some information
|
||||
audio.Core = this;
|
||||
ppu.Core = this;
|
||||
serialport.Core = this;
|
||||
|
||||
// the following is just interface setup, dont worry to much about it
|
||||
ser.Register<IVideoProvider>(this);
|
||||
ser.Register<ISoundProvider>(audio);
|
||||
ServiceProvider = ser;
|
||||
|
@ -111,6 +93,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
SetupMemoryDomains();
|
||||
HardReset();
|
||||
|
||||
cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory);
|
||||
}
|
||||
|
||||
public DisplayType Region => DisplayType.NTSC;
|
||||
|
@ -132,8 +116,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
MemoryCallbacks.CallExecutes(addr, "System Bus");
|
||||
}
|
||||
|
||||
// most systems have cartridges or other storage media that map memory in more then one way.
|
||||
// Use this ethod to set that stuff up when first starting the core
|
||||
private void Setup_Mapper()
|
||||
{
|
||||
mapper = new MapperDefault();
|
||||
|
|
Loading…
Reference in New Issue