vectrex; more bug fixes
This commit is contained in:
parent
2edf5c08f8
commit
94db48b24f
|
@ -182,8 +182,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
"ADD A,ix16", // ab
|
"ADD A,ix16", // ab
|
||||||
"CMP X,ix16", // ac
|
"CMP X,ix16", // ac
|
||||||
"JSR ix16", // ad
|
"JSR ix16", // ad
|
||||||
"LD X,ex16", // ae
|
"LD X,ix16", // ae
|
||||||
"ST X,ex16", // af
|
"ST X,ix16", // af
|
||||||
"SUB A,ex16", // b0
|
"SUB A,ex16", // b0
|
||||||
"CMP A,ex16", // b1
|
"CMP A,ex16", // b1
|
||||||
"SBC A,ex16", // b2
|
"SBC A,ex16", // b2
|
||||||
|
|
|
@ -32,11 +32,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
public bool PB7, PB6;
|
public bool PB7, PB6;
|
||||||
public bool PB7_prev, PB6_prev;
|
public bool PB7_prev, PB6_prev;
|
||||||
|
|
||||||
|
public bool PB7_last_write;
|
||||||
|
|
||||||
// Port B controls
|
// Port B controls
|
||||||
public bool sw, sel0, sel1, bc1, bdir, compare, shift_start;
|
public bool sw, sel0, sel1, bc1, bdir, compare, shift_start;
|
||||||
|
|
||||||
public byte int_en, int_fl, aux_ctrl, prt_ctrl, shift_reg, shift_reg_wait, shift_count;
|
public byte int_en, int_fl, aux_ctrl, prt_ctrl, shift_reg, shift_reg_wait, shift_count;
|
||||||
|
|
||||||
|
public bool frame_end;
|
||||||
|
|
||||||
public byte Read_Registers(int addr)
|
public byte Read_Registers(int addr)
|
||||||
{
|
{
|
||||||
byte ret = 0;
|
byte ret = 0;
|
||||||
|
@ -44,7 +48,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
switch (addr)
|
switch (addr)
|
||||||
{
|
{
|
||||||
case 0x0:
|
case 0x0:
|
||||||
ret = portB_ret;
|
if (!aux_ctrl.Bit(7))
|
||||||
|
{
|
||||||
|
ret = portB_ret;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = (byte)((portB_ret & 0x7F) | (PB7 ? 0x80 : 0x0));
|
||||||
|
}
|
||||||
|
|
||||||
int_fl &= 0xE7;
|
int_fl &= 0xE7;
|
||||||
update_int_fl();
|
update_int_fl();
|
||||||
|
@ -132,6 +143,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
|
|
||||||
if (aux_ctrl.Bit(7))
|
if (aux_ctrl.Bit(7))
|
||||||
{
|
{
|
||||||
|
PB7_last_write = wrt_val.Bit(7);
|
||||||
wrt_val = (byte)((wrt_val & 0x7F) | (PB7 ? 0x80 : 0x0));
|
wrt_val = (byte)((wrt_val & 0x7F) | (PB7 ? 0x80 : 0x0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +179,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ppu.x_vel = (byte)(portA_ret ^ 0x80);;
|
//ppu.x_vel = ~portA_ret;
|
||||||
|
ppu.x_vel = (byte)(portA_ret ^ 0x80);
|
||||||
|
//ppu.x_vel = portA_ret; if (ppu.x_vel >= 128) { ppu.x_vel -= 128; ppu.x_vel = -ppu.x_vel; }
|
||||||
|
|
||||||
int_fl &= 0xE7;
|
int_fl &= 0xE7;
|
||||||
update_int_fl();
|
update_int_fl();
|
||||||
|
@ -180,7 +194,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
// writing to sound reg
|
// writing to sound reg
|
||||||
if (bdir)
|
if (bdir)
|
||||||
{
|
{
|
||||||
if (bc1) { audio.port_sel = (byte)(portA_ret & 0xf); }
|
if (bc1) { audio.port_sel = (byte)(portA_ret & 0xF); }
|
||||||
else { audio.WriteReg(0, portA_ret); }
|
else { audio.WriteReg(0, portA_ret); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +212,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ppu.x_vel = ~portA_ret;
|
||||||
ppu.x_vel = (byte)(portA_ret ^ 0x80);
|
ppu.x_vel = (byte)(portA_ret ^ 0x80);
|
||||||
|
//ppu.x_vel = portA_ret; if (ppu.x_vel >= 128) { ppu.x_vel -= 128; ppu.x_vel = -ppu.x_vel; }
|
||||||
|
|
||||||
int_fl &= 0xFC;
|
int_fl &= 0xFC;
|
||||||
update_int_fl();
|
update_int_fl();
|
||||||
|
@ -256,7 +272,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
break;
|
break;
|
||||||
case 0xB:
|
case 0xB:
|
||||||
aux_ctrl = value;
|
aux_ctrl = value;
|
||||||
if (!aux_ctrl.Bit(7)) { ppu.ramp_sig = value.Bit(7); }
|
t1_ctrl = aux_ctrl;
|
||||||
|
//if (aux_ctrl.Bit(7)) { ppu.ramp_sig = !PB7; }
|
||||||
|
//else { ppu.ramp_sig = !PB7_last_write; }
|
||||||
break;
|
break;
|
||||||
case 0xC:
|
case 0xC:
|
||||||
prt_ctrl = value;
|
prt_ctrl = value;
|
||||||
|
@ -325,8 +343,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void timer_1_tick()
|
public void internal_state_tick()
|
||||||
{
|
{
|
||||||
|
// Timer 1
|
||||||
t1_counter--;
|
t1_counter--;
|
||||||
|
|
||||||
if (t1_counter < 0)
|
if (t1_counter < 0)
|
||||||
|
@ -356,10 +375,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void timer_2_tick()
|
// Timer 2
|
||||||
{
|
|
||||||
t2_counter--;
|
t2_counter--;
|
||||||
|
|
||||||
if (t2_counter < 0)
|
if (t2_counter < 0)
|
||||||
|
@ -385,11 +402,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
t2_shot_go = false;
|
t2_shot_go = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
frame_end = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void shift_reg_tick()
|
// Shift register
|
||||||
{
|
|
||||||
if (shift_start)
|
if (shift_start)
|
||||||
{
|
{
|
||||||
if (shift_reg_wait > 0)
|
if (shift_reg_wait > 0)
|
||||||
|
@ -405,15 +421,20 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
{
|
{
|
||||||
// reset blank signal back to contorl of peripheral controller
|
// reset blank signal back to contorl of peripheral controller
|
||||||
shift_start = false;
|
shift_start = false;
|
||||||
if ((prt_ctrl & 0xE0) == 0xC0) { ppu.blank_sig = true; }
|
//if ((prt_ctrl & 0xE0) == 0xC0) { ppu.blank_sig = true; }
|
||||||
else { ppu.blank_sig = false; }
|
//else { ppu.blank_sig = false; }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ppu.blank_sig = !shift_reg.Bit(7 - shift_count);
|
ppu.blank_sig = !shift_reg.Bit(7 - shift_count);
|
||||||
shift_count++;
|
shift_count++;
|
||||||
|
shift_reg_wait = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("method 2");
|
||||||
|
}
|
||||||
|
|
||||||
// other clocking modes are not used. Maybe some demos use them?
|
// other clocking modes are not used. Maybe some demos use them?
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
{
|
{
|
||||||
if (addr < 0x8000)
|
if (addr < 0x8000)
|
||||||
{
|
{
|
||||||
return 0xFF;
|
return mapper.ReadMemory(addr);
|
||||||
}
|
}
|
||||||
else if (addr < 0xC800)
|
else if (addr < 0xC800)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,6 +15,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
|
|
||||||
public void tick()
|
public void tick()
|
||||||
{
|
{
|
||||||
|
//Console.WriteLine(ramp_sig + " " + zero_sig + " " + blank_sig + " " + Core.cpu.TotalExecutedCycles + " " + (x_vel - 128.0) + " " + x_pos
|
||||||
|
//+ " " + (y_vel - 128.0) + " " + y_pos + " " + Core.t1_counter + " " + vec_scale);
|
||||||
|
|
||||||
if (ramp_sig && !zero_sig)
|
if (ramp_sig && !zero_sig)
|
||||||
{
|
{
|
||||||
x_pos = x_pos + (x_vel - 128.0) / 256.0 * (vec_scale + 2);
|
x_pos = x_pos + (x_vel - 128.0) / 256.0 * (vec_scale + 2);
|
||||||
|
@ -25,7 +28,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
if (y_pos > 383) { y_pos = 383; }
|
if (y_pos > 383) { y_pos = 383; }
|
||||||
if (y_pos < 0) { y_pos = 0; }
|
if (y_pos < 0) { y_pos = 0; }
|
||||||
|
|
||||||
if (!blank_sig) { Core._vidbuffer[(int)(Math.Floor(x_pos) + 256 * Math.Floor(y_pos))] = (int)br; }
|
if (!blank_sig) { Core._vidbuffer[(int)(Math.Round(x_pos) + 256 * Math.Round(y_pos))] = (int)br; }
|
||||||
}
|
}
|
||||||
else if (zero_sig)
|
else if (zero_sig)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,6 +36,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
audio.Register[14] = (byte)(_controllerDeck.ReadPort1(controller) & 0xF);
|
audio.Register[14] = (byte)(_controllerDeck.ReadPort1(controller) & 0xF);
|
||||||
audio.Register[14] |= (byte)(_controllerDeck.ReadPort2(controller) << 4);
|
audio.Register[14] |= (byte)(_controllerDeck.ReadPort2(controller) << 4);
|
||||||
|
|
||||||
|
frame_end = false;
|
||||||
|
|
||||||
do_frame();
|
do_frame();
|
||||||
|
|
||||||
if (_islag)
|
if (_islag)
|
||||||
|
@ -50,11 +52,10 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
{
|
{
|
||||||
_vidbuffer = new int[VirtualWidth * VirtualHeight];
|
_vidbuffer = new int[VirtualWidth * VirtualHeight];
|
||||||
|
|
||||||
for (int i = 0; i < 25000; i++)
|
//for (int i = 0; i < 1000; i++)
|
||||||
|
while (!frame_end)
|
||||||
{
|
{
|
||||||
timer_1_tick();
|
internal_state_tick();
|
||||||
timer_2_tick();
|
|
||||||
shift_reg_tick();
|
|
||||||
audio.tick();
|
audio.tick();
|
||||||
ppu.tick();
|
ppu.tick();
|
||||||
cpu.ExecuteOne();
|
cpu.ExecuteOne();
|
||||||
|
@ -83,7 +84,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
|
|
||||||
#region Video provider
|
#region Video provider
|
||||||
|
|
||||||
public int _frameHz = 60;
|
public int _frameHz = 50;
|
||||||
|
|
||||||
public int[] _vidbuffer;
|
public int[] _vidbuffer;
|
||||||
|
|
||||||
|
@ -100,10 +101,6 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
public int VsyncNumerator => _frameHz;
|
public int VsyncNumerator => _frameHz;
|
||||||
public int VsyncDenominator => 1;
|
public int VsyncDenominator => 1;
|
||||||
|
|
||||||
public static readonly uint[] color_palette_Gr = { 0xFFA4C505, 0xFF88A905, 0xFF1D551D, 0xFF052505 };
|
|
||||||
|
|
||||||
public uint[] color_palette = new uint[4];
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
ser.Sync(nameof(shift_reg_wait), ref shift_reg_wait);
|
ser.Sync(nameof(shift_reg_wait), ref shift_reg_wait);
|
||||||
ser.Sync(nameof(shift_count), ref shift_count);
|
ser.Sync(nameof(shift_count), ref shift_count);
|
||||||
|
|
||||||
|
ser.Sync(nameof(frame_end), ref frame_end);
|
||||||
|
|
||||||
// probably a better way to do this
|
// probably a better way to do this
|
||||||
if (cart_RAM != null)
|
if (cart_RAM != null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue