Vectrex: Start displaying stuff
This commit is contained in:
parent
982dc479e7
commit
84c0126f80
|
@ -33,9 +33,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
public bool PB7_prev, PB6_prev;
|
||||
|
||||
// Port B controls
|
||||
public bool sw, sel0, sel1, bc1, bdir, compare, ramp;
|
||||
public bool sw, sel0, sel1, bc1, bdir, compare, shift_start;
|
||||
|
||||
public byte int_en, int_fl, aux_ctrl;
|
||||
public byte int_en, int_fl, aux_ctrl, prt_ctrl, shift_reg, shift_reg_wait, shift_count;
|
||||
|
||||
public byte Read_Registers(int addr)
|
||||
{
|
||||
|
@ -95,12 +95,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
break;
|
||||
case 0xA:
|
||||
int_fl &= 0xFB;
|
||||
ret = shift_reg;
|
||||
update_int_fl();
|
||||
break;
|
||||
case 0xB:
|
||||
ret = aux_ctrl;
|
||||
break;
|
||||
case 0xC:
|
||||
ret = prt_ctrl;
|
||||
break;
|
||||
case 0xD:
|
||||
ret = int_fl;
|
||||
|
@ -129,14 +131,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
portB_ret = (byte)(wrt_val | (reg_B & ~(dir_ctrl)));
|
||||
|
||||
if (dir_ctrl.Bit(0)) { sw = value.Bit(0); }
|
||||
if (dir_ctrl.Bit(0)) { sw = !value.Bit(0); }
|
||||
if (dir_ctrl.Bit(1)) { sel0 = value.Bit(1); }
|
||||
if (dir_ctrl.Bit(2)) { sel1 = value.Bit(2); }
|
||||
if (dir_ctrl.Bit(3)) { bc1 = value.Bit(3); }
|
||||
if (dir_ctrl.Bit(4)) { bdir = value.Bit(4); }
|
||||
if (dir_ctrl.Bit(5)) { /*compare = value.Bit(5);*/ }
|
||||
if (dir_ctrl.Bit(6)) { /* cart bank switch */ }
|
||||
if (dir_ctrl.Bit(7)) { ramp = !value.Bit(7); }
|
||||
if (dir_ctrl.Bit(7)) { ppu.ramp_sig = !value.Bit(7); }
|
||||
|
||||
// writing to sound reg
|
||||
if (bdir)
|
||||
|
@ -145,6 +147,26 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
else { audio.WriteReg(0, portA_ret); }
|
||||
}
|
||||
|
||||
if (sw)
|
||||
{
|
||||
if (sel0)
|
||||
{
|
||||
if (sel1) {/* sound line? */ }
|
||||
else { ppu.vec_scale = portA_ret; Console.WriteLine("scale " + value + " " + cpu.TotalExecutedCycles); }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sel1) { ppu.bright = portA_ret; }
|
||||
else { ppu.y_vel = (byte)(portA_ret ^ 0x80); Console.WriteLine("y vel " + value + " " + cpu.TotalExecutedCycles); }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu.x_vel = portA_ret; Console.WriteLine("x vel " + value + " " + cpu.TotalExecutedCycles);
|
||||
}
|
||||
|
||||
ppu.x_vel = (byte)(portA_ret ^ 0x80); Console.WriteLine("x vel " + value + " " + cpu.TotalExecutedCycles);
|
||||
|
||||
int_fl &= 0xE7;
|
||||
update_int_fl();
|
||||
break;
|
||||
|
@ -160,6 +182,26 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
else { audio.WriteReg(0, portA_ret); }
|
||||
}
|
||||
|
||||
if (sw)
|
||||
{
|
||||
if (sel0)
|
||||
{
|
||||
if (sel1) {/* sound line? */ }
|
||||
else { ppu.vec_scale = portA_ret; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sel1) { ppu.bright = portA_ret; }
|
||||
else { ppu.y_vel = (byte)(portA_ret ^ 0x80); }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu.x_vel = portA_ret;
|
||||
}
|
||||
|
||||
ppu.x_vel = (byte)(portA_ret ^ 0x80);
|
||||
|
||||
int_fl &= 0xFC;
|
||||
update_int_fl();
|
||||
break;
|
||||
|
@ -180,7 +222,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
if (aux_ctrl.Bit(7)) { PB7 = true; }
|
||||
t1_ctrl = aux_ctrl;
|
||||
|
||||
int_fl &= 0xBF;
|
||||
int_fl &= 0xBF;
|
||||
update_int_fl();
|
||||
break;
|
||||
case 0x6:
|
||||
|
@ -207,12 +249,31 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
break;
|
||||
case 0xA:
|
||||
int_fl &= 0xFB;
|
||||
shift_reg = value;
|
||||
shift_start = true;
|
||||
shift_reg_wait = 2;
|
||||
shift_count = 0;
|
||||
|
||||
update_int_fl();
|
||||
//Console.WriteLine("shift " + value + " " + cpu.TotalExecutedCycles);
|
||||
break;
|
||||
case 0xB:
|
||||
aux_ctrl = value;
|
||||
//Console.WriteLine(value + " " + cpu.TotalExecutedCycles);
|
||||
break;
|
||||
case 0xC:
|
||||
prt_ctrl = value;
|
||||
|
||||
// since CA2 / CB2 are tied to beam controls, most of their functions can be glossed over here
|
||||
// If there are games / demos that make use of other modes, they will have to be accounted for here
|
||||
|
||||
if ((value & 0xE) == 0xC) { ppu.zero_sig = true; }
|
||||
else { ppu.zero_sig = false; }
|
||||
|
||||
if ((value & 0xE0) == 0xC0) { ppu.blank_sig = false; }
|
||||
else { ppu.blank_sig = true; }
|
||||
|
||||
//Console.WriteLine(value + " " + cpu.TotalExecutedCycles);
|
||||
break;
|
||||
case 0xD:
|
||||
// writing to flags does not clear bit 7 directly
|
||||
|
@ -237,6 +298,31 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
portA_ret = (byte)(wrt_val | (reg_A & ~(dir_dac)));
|
||||
|
||||
// writing to sound reg
|
||||
if (bdir)
|
||||
{
|
||||
if (bc1) { audio.port_sel = (byte)(portA_ret & 0xf); }
|
||||
else { audio.WriteReg(0, portA_ret); }
|
||||
}
|
||||
|
||||
if (sw)
|
||||
{
|
||||
if (sel0)
|
||||
{
|
||||
if (sel1) {/* sound line? */ }
|
||||
else { ppu.vec_scale = portA_ret; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sel1) { ppu.bright = portA_ret; }
|
||||
else { ppu.y_vel = portA_ret; }
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu.x_vel = portA_ret;
|
||||
}
|
||||
|
||||
int_fl &= 0xFC;
|
||||
update_int_fl();
|
||||
break;
|
||||
|
@ -306,6 +392,38 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
}
|
||||
}
|
||||
|
||||
public void shift_reg_tick()
|
||||
{
|
||||
if (shift_start)
|
||||
{
|
||||
if (shift_reg_wait > 0)
|
||||
{
|
||||
shift_reg_wait--;
|
||||
}
|
||||
else
|
||||
{
|
||||
// tick on every clock cycle
|
||||
if ((aux_ctrl & 0x1C) == 0x18)
|
||||
{
|
||||
if (shift_count == 8)
|
||||
{
|
||||
// reset blank signal back to contorl of peripheral controller
|
||||
shift_start = false;
|
||||
if ((prt_ctrl & 0xE0) == 0xC0) { ppu.blank_sig = false; }
|
||||
else { ppu.blank_sig = true; }
|
||||
}
|
||||
else
|
||||
{
|
||||
ppu.blank_sig = !shift_reg.Bit(7 - shift_count);
|
||||
shift_count++;
|
||||
}
|
||||
}
|
||||
|
||||
// other clocking modes are not used. Maybe some demos use them?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void update_int_fl()
|
||||
{
|
||||
// bit 7 is (IF.bit(X) & IE.bit(X)) OR'ed together for each bit
|
||||
|
@ -336,6 +454,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
PB6 = PB7_prev = false;
|
||||
|
||||
int_en = int_fl = aux_ctrl = 0;
|
||||
|
||||
shift_reg = shift_reg_wait = 0;
|
||||
shift_start = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,39 +7,57 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
{
|
||||
public VectrexHawk Core { get; set; }
|
||||
|
||||
public byte ReadReg(int addr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
public bool zero_sig, ramp_sig, blank_sig;
|
||||
public byte vec_scale, x_vel, y_vel, bright;
|
||||
public double x_pos, y_pos;
|
||||
|
||||
public void WriteReg(int addr, byte value)
|
||||
{
|
||||
|
||||
}
|
||||
public static uint br = 0xFFA4C505;
|
||||
|
||||
public void tick()
|
||||
{
|
||||
if (ramp_sig && !zero_sig)
|
||||
{
|
||||
x_pos = x_pos + (x_vel - 128.0) / 256.0 * (vec_scale + 1);
|
||||
y_pos = y_pos + (y_vel - 128.0) / 256.0 * (vec_scale + 1);
|
||||
|
||||
}
|
||||
|
||||
public virtual void latch_delay()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void render(int render_cycle)
|
||||
{
|
||||
if (x_pos > 255) { x_pos = 255; }
|
||||
if (x_pos < 0) { x_pos = 0; }
|
||||
if (y_pos > 383) { y_pos = 383; }
|
||||
if (y_pos < 0) { y_pos = 0; }
|
||||
|
||||
if (!blank_sig) { Core._vidbuffer[(int)(Math.Floor(x_pos) + 256 * Math.Floor(y_pos))] = (int)br; }
|
||||
}
|
||||
else if (zero_sig)
|
||||
{
|
||||
x_pos = 128;
|
||||
y_pos = 192;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
zero_sig = true;
|
||||
blank_sig = true;
|
||||
ramp_sig = false;
|
||||
|
||||
vec_scale = x_vel = y_vel = bright = 0;
|
||||
x_pos = 128;
|
||||
y_pos = 192;
|
||||
}
|
||||
|
||||
public void SyncState(Serializer ser)
|
||||
{
|
||||
ser.Sync(nameof(zero_sig), ref zero_sig);
|
||||
ser.Sync(nameof(blank_sig), ref blank_sig);
|
||||
ser.Sync(nameof(ramp_sig), ref ramp_sig);
|
||||
|
||||
ser.Sync(nameof(vec_scale), ref vec_scale);
|
||||
ser.Sync(nameof(x_vel), ref x_vel);
|
||||
ser.Sync(nameof(y_vel), ref y_vel);
|
||||
ser.Sync(nameof(bright), ref bright);
|
||||
|
||||
ser.Sync(nameof(x_pos), ref x_pos);
|
||||
ser.Sync(nameof(y_pos), ref y_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,11 +48,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
|
||||
public void do_frame()
|
||||
{
|
||||
_vidbuffer = new int[VirtualWidth * VirtualHeight];
|
||||
|
||||
for (int i = 0; i < 25000; i++)
|
||||
{
|
||||
timer_1_tick();
|
||||
timer_2_tick();
|
||||
shift_reg_tick();
|
||||
audio.tick();
|
||||
ppu.tick();
|
||||
cpu.ExecuteOne();
|
||||
}
|
||||
}
|
||||
|
@ -88,15 +92,14 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
return _vidbuffer;
|
||||
}
|
||||
|
||||
public int VirtualWidth => 160;
|
||||
public int VirtualHeight => 144;
|
||||
public int BufferWidth => 160;
|
||||
public int BufferHeight => 144;
|
||||
public int VirtualWidth => 256;
|
||||
public int VirtualHeight => 384;
|
||||
public int BufferWidth => 256;
|
||||
public int BufferHeight => 384;
|
||||
public int BackgroundColor => unchecked((int)0xFF000000);
|
||||
public int VsyncNumerator => _frameHz;
|
||||
public int VsyncDenominator => 1;
|
||||
|
||||
public static readonly uint[] color_palette_BW = { 0xFFFFFFFF , 0xFFAAAAAA, 0xFF555555, 0xFF000000 };
|
||||
public static readonly uint[] color_palette_Gr = { 0xFFA4C505, 0xFF88A905, 0xFF1D551D, 0xFF052505 };
|
||||
|
||||
public uint[] color_palette = new uint[4];
|
||||
|
|
|
@ -82,6 +82,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
ser.Sync(nameof(int_en), ref int_en);
|
||||
ser.Sync(nameof(int_fl), ref int_fl);
|
||||
ser.Sync(nameof(aux_ctrl), ref aux_ctrl);
|
||||
ser.Sync(nameof(prt_ctrl), ref prt_ctrl);
|
||||
|
||||
ser.Sync(nameof(sw), ref sw);
|
||||
ser.Sync(nameof(sel0), ref sel0);
|
||||
|
@ -89,13 +90,15 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
|||
ser.Sync(nameof(bc1), ref bc1);
|
||||
ser.Sync(nameof(bdir), ref bdir);
|
||||
ser.Sync(nameof(compare), ref compare);
|
||||
ser.Sync(nameof(ramp), ref ramp);
|
||||
|
||||
ser.Sync(nameof(_frame), ref _frame);
|
||||
ser.Sync(nameof(_lagcount), ref _lagcount);
|
||||
ser.Sync(nameof(_islag), ref _islag);
|
||||
|
||||
|
||||
ser.Sync(nameof(shift_start), ref shift_start);
|
||||
ser.Sync(nameof(shift_reg), ref shift_reg);
|
||||
ser.Sync(nameof(shift_reg_wait), ref shift_reg_wait);
|
||||
ser.Sync(nameof(shift_count), ref shift_count);
|
||||
|
||||
// probably a better way to do this
|
||||
if (cart_RAM != null)
|
||||
|
|
Loading…
Reference in New Issue