Vectrex: Fix some bugs

This commit is contained in:
alyosha-tas 2019-07-10 15:42:01 -04:00
parent 9fe277a3ff
commit fd51934ea4
11 changed files with 93 additions and 59 deletions

View File

@ -103,7 +103,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
private void INDEX_OP_ST() private void INDEX_OP_ST()
{ {
PopulateCURINSTR(IDLE, PopulateCURINSTR(ST_16, indexed_op_reg,
WR_HI_INC, IDX_EA, indexed_op_reg, WR_HI_INC, IDX_EA, indexed_op_reg,
WR_DEC_LO, IDX_EA, indexed_op_reg); WR_DEC_LO, IDX_EA, indexed_op_reg);
@ -121,8 +121,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
private void INDEX_OP_STD() private void INDEX_OP_STD()
{ {
PopulateCURINSTR(SET_ADDR, ADDR, A, A, PopulateCURINSTR(ST_16, Dr,
WR_HI_INC, IDX_EA, ADDR, WR_LO_INC, IDX_EA, A,
WR_DEC_LO, IDX_EA, B); WR_DEC_LO, IDX_EA, B);
IRQS = 3; IRQS = 3;
@ -138,7 +138,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
private void INDEX_OP_EX4_ST() private void INDEX_OP_EX4_ST()
{ {
PopulateCURINSTR(IDLE, PopulateCURINSTR(ST_8, indexed_op_reg,
WR, IDX_EA, indexed_op_reg); WR, IDX_EA, indexed_op_reg);
IRQS = 2; IRQS = 2;

View File

@ -62,20 +62,23 @@ namespace BizHawk.Emulation.Common.Components.MC6809
public const ushort WR_DEC_LO_OP = 51; public const ushort WR_DEC_LO_OP = 51;
public const ushort WR_DEC_HI_OP = 52; public const ushort WR_DEC_HI_OP = 52;
public const ushort WR_HI_INC = 53; public const ushort WR_HI_INC = 53;
public const ushort SET_ADDR_PUL = 54; public const ushort WR_LO_INC = 54;
public const ushort SET_F_I = 55; public const ushort SET_ADDR_PUL = 55;
public const ushort SET_I = 56; public const ushort SET_F_I = 56;
public const ushort SET_E = 57; public const ushort SET_I = 57;
public const ushort ANDCC = 58; public const ushort SET_E = 58;
public const ushort CMP8 = 59; public const ushort ANDCC = 59;
public const ushort SUB16 = 60; public const ushort CMP8 = 60;
public const ushort ADD16 = 61; public const ushort SUB16 = 61;
public const ushort CMP16 = 62; public const ushort ADD16 = 62;
public const ushort CMP16D = 63; public const ushort CMP16 = 63;
public const ushort LD_8 = 64; public const ushort CMP16D = 64;
public const ushort LD_16 = 65; public const ushort LD_8 = 65;
public const ushort LEA = 66; public const ushort LD_16 = 66;
public const ushort CLR_E = 67; public const ushort ST_8 = 67;
public const ushort ST_16 = 68;
public const ushort LEA = 69;
public const ushort CLR_E = 70;
public MC6809() public MC6809()
{ {
@ -296,6 +299,9 @@ namespace BizHawk.Emulation.Common.Components.MC6809
case WR_HI_INC: case WR_HI_INC:
Write_Hi_Inc_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); Write_Hi_Inc_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
break; break;
case WR_LO_INC:
Write_Lo_Inc_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
break;
case TR: case TR:
TR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); TR_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
break; break;
@ -305,6 +311,12 @@ namespace BizHawk.Emulation.Common.Components.MC6809
case LD_16: case LD_16:
LD_16_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]); LD_16_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
break; break;
case ST_8:
ST_8_Func(cur_instr[instr_pntr++]);
break;
case ST_16:
ST_16_Func(cur_instr[instr_pntr++]);
break;
case LEA: case LEA:
LEA_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]); LEA_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
break; break;

View File

@ -52,7 +52,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
private void DIRECT_ST_4(ushort dest) private void DIRECT_ST_4(ushort dest)
{ {
PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU,
IDLE, ST_8, dest,
WR, ADDR, dest); WR, ADDR, dest);
IRQS = 3; IRQS = 3;
@ -93,7 +93,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
{ {
PopulateCURINSTR(RD_INC, ALU, PC, PopulateCURINSTR(RD_INC, ALU, PC,
RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2,
IDLE, ST_8, dest,
WR, ADDR, dest); WR, ADDR, dest);
IRQS = 4; IRQS = 4;
@ -168,8 +168,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
private void DIR_OP_ST_16D() private void DIR_OP_ST_16D()
{ {
PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU,
SET_ADDR, ALU, A, A, ST_16, Dr,
WR_HI_INC, ADDR, ALU, WR_LO_INC, ADDR, A,
WR, ADDR, B); WR, ADDR, B);
IRQS = 4; IRQS = 4;
@ -216,7 +216,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
private void DIR_OP_ST_16(ushort src) private void DIR_OP_ST_16(ushort src)
{ {
PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU, PopulateCURINSTR(RD_INC_OP, ALU, PC, SET_ADDR, ADDR, DP, ALU,
IDLE, ST_16, src,
WR_HI_INC, ADDR, src, WR_HI_INC, ADDR, src,
WR_DEC_LO, ADDR, src); WR_DEC_LO, ADDR, src);
@ -238,7 +238,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
{ {
PopulateCURINSTR(RD_INC, ALU, PC, PopulateCURINSTR(RD_INC, ALU, PC,
RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2,
IDLE, ST_16, src,
WR_HI_INC, ADDR, src, WR_HI_INC, ADDR, src,
WR_DEC_LO, ADDR, src); WR_DEC_LO, ADDR, src);
@ -260,8 +260,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
{ {
PopulateCURINSTR(RD_INC, ALU, PC, PopulateCURINSTR(RD_INC, ALU, PC,
RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2, RD_INC_OP, ALU2, PC, SET_ADDR, ADDR, ALU, ALU2,
SET_ADDR, ALU, A, A, ST_16, Dr,
WR_HI_INC, ADDR, ALU, WR_LO_INC, ADDR, A,
WR, ADDR, B); WR, ADDR, B);
IRQS = 5; IRQS = 5;

View File

@ -62,6 +62,13 @@ namespace BizHawk.Emulation.Common.Components.MC6809
Regs[dest]++; Regs[dest]++;
} }
public void Write_Lo_Inc_Func(ushort dest, ushort src)
{
if (CDLCallback != null) CDLCallback(Regs[dest], eCDLogMemFlags.Write | eCDLogMemFlags.Data);
WriteMemory(Regs[dest], (byte)Regs[src]);
Regs[dest]++;
}
public void NEG_8_Func(ushort src) public void NEG_8_Func(ushort src)
{ {
int Reg16_d = 0; int Reg16_d = 0;
@ -94,6 +101,13 @@ namespace BizHawk.Emulation.Common.Components.MC6809
FlagN = (Regs[dest] & 0xFF) > 127; FlagN = (Regs[dest] & 0xFF) > 127;
} }
public void ST_8_Func(ushort dest)
{
FlagZ = (Regs[dest] & 0xFF) == 0;
FlagV = false;
FlagN = (Regs[dest] & 0xFF) > 127;
}
public void LD_16_Func(ushort dest, ushort src_h, ushort src_l) public void LD_16_Func(ushort dest, ushort src_h, ushort src_l)
{ {
Regs[dest] = (ushort)(Regs[src_h] << 8 | Regs[src_l]); Regs[dest] = (ushort)(Regs[src_h] << 8 | Regs[src_l]);
@ -103,6 +117,18 @@ namespace BizHawk.Emulation.Common.Components.MC6809
FlagN = Regs[dest] > 0x7FFF; FlagN = Regs[dest] > 0x7FFF;
} }
public void ST_16_Func(ushort dest)
{
if (dest == Dr)
{
Regs[dest] = D;
}
FlagZ = Regs[dest] == 0;
FlagV = false;
FlagN = Regs[dest] > 0x7FFF;
}
// for LEAX/Y, zero flag can be effected, but not for U/S // for LEAX/Y, zero flag can be effected, but not for U/S
public void LEA_Func(ushort dest, ushort src) public void LEA_Func(ushort dest, ushort src)
{ {

View File

@ -29,6 +29,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
HardReset(); HardReset();
} }
if (controller.IsPressed("Reset"))
{
SoftReset();
}
_islag = true; _islag = true;
// button inputs go to port 14 in the audio registers // button inputs go to port 14 in the audio registers

View File

@ -36,12 +36,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
1), 1),
}; };
if (cart_RAM != null)
{
var CartRam = new MemoryDomainByteArray("Cart RAM", MemoryDomain.Endian.Little, cart_RAM, true, 1);
domains.Add(CartRam);
}
MemoryDomains = new MemoryDomainList(domains); MemoryDomains = new MemoryDomainList(domains);
(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains); (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
} }

View File

@ -6,28 +6,20 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
public partial class VectrexHawk : ISaveRam public partial class VectrexHawk : ISaveRam
{ {
public byte[] CloneSaveRam() public byte[] CloneSaveRam()
{
if (cart_RAM != null)
{
return (byte[])cart_RAM.Clone();
}
else
{ {
return null; return null;
} }
}
public void StoreSaveRam(byte[] data) public void StoreSaveRam(byte[] data)
{ {
Buffer.BlockCopy(data, 0, cart_RAM, 0, data.Length);
Console.WriteLine("loading SRAM here");
} }
public bool SaveRamModified public bool SaveRamModified
{ {
get get
{ {
return has_bat & _syncSettings.Use_SRAM; return false;
} }
} }
} }

View File

@ -91,11 +91,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
} }
} }
[DisplayName("Use Existing SaveRAM")]
[Description("When true, existing SaveRAM will be loaded at boot up")]
[DefaultValue(false)]
public bool Use_SRAM { get; set; }
public VectrexSyncSettings Clone() public VectrexSyncSettings Clone()
{ {
return (VectrexSyncSettings)MemberwiseClone(); return (VectrexSyncSettings)MemberwiseClone();

View File

@ -47,6 +47,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
ms.Close(); ms.Close();
core = ms.ToArray(); core = ms.ToArray();
} }
else
{
_framebuffer = new int[VirtualWidth * VirtualHeight];
}
cpu.SyncState(ser); cpu.SyncState(ser);
mapper.SyncState(ser); mapper.SyncState(ser);
ppu.SyncState(ser); ppu.SyncState(ser);
@ -109,13 +113,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
ser.Sync(nameof(joy2_LR), ref joy2_LR); ser.Sync(nameof(joy2_LR), ref joy2_LR);
ser.Sync(nameof(joy2_UD), ref joy2_UD); ser.Sync(nameof(joy2_UD), ref joy2_UD);
// probably a better way to do this
if (cart_RAM != null)
{
ser.Sync(nameof(cart_RAM), ref cart_RAM, false);
}
ser.EndSection(); ser.EndSection();
} }
} }

View File

@ -21,9 +21,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
public byte[] _bios, minestorm; public byte[] _bios, minestorm;
public readonly byte[] _rom; public readonly byte[] _rom;
public byte[] cart_RAM;
public bool has_bat;
private int _frame = 0; private int _frame = 0;
public MapperBase mapper; public MapperBase mapper;
@ -138,6 +135,21 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
ppu.Reset(); ppu.Reset();
audio.Reset(); audio.Reset();
serialport.Reset(); serialport.Reset();
cpu.Reset();
RAM = new byte[0x400];
_vidbuffer = new int[VirtualWidth * VirtualHeight];
_framebuffer = new int[VirtualWidth * VirtualHeight];
}
public void SoftReset()
{
Register_Reset();
ppu.Reset();
audio.Reset();
serialport.Reset();
cpu.Reset();
_vidbuffer = new int[VirtualWidth * VirtualHeight]; _vidbuffer = new int[VirtualWidth * VirtualHeight];
_framebuffer = new int[VirtualWidth * VirtualHeight]; _framebuffer = new int[VirtualWidth * VirtualHeight];

View File

@ -32,7 +32,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
.Concat(Port2.Definition.BoolButtons) .Concat(Port2.Definition.BoolButtons)
.Concat(new[] .Concat(new[]
{ {
"Power" "Power",
"Reset"
}) })
.ToList() .ToList()
}; };