Vectrex: Implement interrupts, fixes Bedlam
This commit is contained in:
parent
b0123ea133
commit
6a5fc8b47e
|
@ -68,7 +68,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
"RTS", // 39
|
"RTS", // 39
|
||||||
"ABX", // 3a
|
"ABX", // 3a
|
||||||
"RTI", // 3b
|
"RTI", // 3b
|
||||||
"CWAI", // 3c
|
"CWAI i8", // 3c
|
||||||
"MUL", // 3d
|
"MUL", // 3d
|
||||||
"???", // 3e
|
"???", // 3e
|
||||||
"SWI1", // 3f
|
"SWI1", // 3f
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
WR_DEC_LO, SP, B,
|
WR_DEC_LO, SP, B,
|
||||||
WR_DEC_LO, SP, A,
|
WR_DEC_LO, SP, A,
|
||||||
WR, SP, CC,
|
WR, SP, CC,
|
||||||
SET_F_I,
|
SET_I,
|
||||||
RD_INC, ALU, ADDR,
|
RD_INC, ALU, ADDR,
|
||||||
RD_INC, ALU2, ADDR,
|
RD_INC, ALU2, ADDR,
|
||||||
SET_ADDR, PC, ALU, ALU2);
|
SET_ADDR, PC, ALU, ALU2);
|
||||||
|
|
|
@ -66,17 +66,18 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
public const ushort WR_DEC_HI_OP = 55;
|
public const ushort WR_DEC_HI_OP = 55;
|
||||||
public const ushort SET_ADDR_PUL = 56;
|
public const ushort SET_ADDR_PUL = 56;
|
||||||
public const ushort SET_F_I = 57;
|
public const ushort SET_F_I = 57;
|
||||||
public const ushort SET_E = 58;
|
public const ushort SET_I = 58;
|
||||||
public const ushort ANDCC = 59;
|
public const ushort SET_E = 59;
|
||||||
public const ushort CMP8 = 60;
|
public const ushort ANDCC = 60;
|
||||||
public const ushort SUB16 = 61;
|
public const ushort CMP8 = 61;
|
||||||
public const ushort ADD16 = 62;
|
public const ushort SUB16 = 62;
|
||||||
public const ushort CMP16 = 63;
|
public const ushort ADD16 = 63;
|
||||||
public const ushort CMP16D = 64;
|
public const ushort CMP16 = 64;
|
||||||
public const ushort WR_HI_INC = 65;
|
public const ushort CMP16D = 65;
|
||||||
public const ushort LD_8 = 66;
|
public const ushort WR_HI_INC = 66;
|
||||||
public const ushort LD_16 = 67;
|
public const ushort LD_8 = 67;
|
||||||
public const ushort LEA = 68;
|
public const ushort LD_16 = 68;
|
||||||
|
public const ushort LEA = 69;
|
||||||
|
|
||||||
public MC6809()
|
public MC6809()
|
||||||
{
|
{
|
||||||
|
@ -231,7 +232,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
Regs[reg_d_ad] = (ushort)((Regs[reg_h_ad] << 8) | Regs[reg_l_ad]);
|
Regs[reg_d_ad] = (ushort)((Regs[reg_h_ad] << 8) | Regs[reg_l_ad]);
|
||||||
break;
|
break;
|
||||||
case JPE:
|
case JPE:
|
||||||
if (!FlagE) { instr_pntr = 45; };
|
if (!FlagE) { instr_pntr = 44; irq_pntr = 10; };
|
||||||
break;
|
break;
|
||||||
case IDX_DCDE:
|
case IDX_DCDE:
|
||||||
Index_decode();
|
Index_decode();
|
||||||
|
@ -353,6 +354,9 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
case SET_F_I:
|
case SET_F_I:
|
||||||
FlagI = true; FlagF = true;
|
FlagI = true; FlagF = true;
|
||||||
break;
|
break;
|
||||||
|
case SET_I:
|
||||||
|
FlagI = true;
|
||||||
|
break;
|
||||||
case SET_E:
|
case SET_E:
|
||||||
FlagE = true;
|
FlagE = true;
|
||||||
break;
|
break;
|
||||||
|
@ -449,6 +453,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
case CWAI:
|
case CWAI:
|
||||||
if (NMIPending)
|
if (NMIPending)
|
||||||
{
|
{
|
||||||
|
NMIPending = false;
|
||||||
|
|
||||||
Regs[ADDR] = 0xFFFC;
|
Regs[ADDR] = 0xFFFC;
|
||||||
PopulateCURINSTR(RD_INC, ALU, ADDR,
|
PopulateCURINSTR(RD_INC, ALU, ADDR,
|
||||||
RD_INC, ALU2, ADDR,
|
RD_INC, ALU2, ADDR,
|
||||||
|
@ -460,6 +466,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
}
|
}
|
||||||
else if (FIRQPending && !FlagF)
|
else if (FIRQPending && !FlagF)
|
||||||
{
|
{
|
||||||
|
FIRQPending = false;
|
||||||
|
|
||||||
Regs[ADDR] = 0xFFF6;
|
Regs[ADDR] = 0xFFF6;
|
||||||
PopulateCURINSTR(RD_INC, ALU, ADDR,
|
PopulateCURINSTR(RD_INC, ALU, ADDR,
|
||||||
RD_INC, ALU2, ADDR,
|
RD_INC, ALU2, ADDR,
|
||||||
|
@ -471,6 +479,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
}
|
}
|
||||||
else if (IRQPending && !FlagI)
|
else if (IRQPending && !FlagI)
|
||||||
{
|
{
|
||||||
|
IRQPending = false;
|
||||||
|
|
||||||
Regs[ADDR] = 0xFFF8;
|
Regs[ADDR] = 0xFFF8;
|
||||||
PopulateCURINSTR(RD_INC, ALU, ADDR,
|
PopulateCURINSTR(RD_INC, ALU, ADDR,
|
||||||
RD_INC, ALU2, ADDR,
|
RD_INC, ALU2, ADDR,
|
||||||
|
@ -542,7 +552,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
PopulateCURINSTR(IDLE);
|
PopulateCURINSTR(IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// then regular IRQ
|
// then regular IRQ
|
||||||
else if (IRQPending && !FlagI)
|
else if (IRQPending && !FlagI)
|
||||||
{
|
{
|
||||||
if (!FlagI)
|
if (!FlagI)
|
||||||
|
@ -567,7 +577,7 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
instr_pntr = irq_pntr = 0;
|
instr_pntr = irq_pntr = 0;
|
||||||
PopulateCURINSTR(IDLE);
|
PopulateCURINSTR(IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// otherwise start the next instruction
|
// otherwise start the next instruction
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,6 +82,8 @@ namespace BizHawk.Emulation.Common.Components.MC6809
|
||||||
{
|
{
|
||||||
Regs[i] = 0;
|
Regs[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlagI = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -417,6 +417,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
{
|
{
|
||||||
int_en &= (byte)((~value) & 0x7F);
|
int_en &= (byte)((~value) & 0x7F);
|
||||||
}
|
}
|
||||||
|
|
||||||
update_int_fl();
|
update_int_fl();
|
||||||
break;
|
break;
|
||||||
case 0xF:
|
case 0xF:
|
||||||
|
@ -468,7 +469,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
|
|
||||||
int_fl |= 0x40;
|
int_fl |= 0x40;
|
||||||
update_int_fl();
|
update_int_fl();
|
||||||
//if (int_en.Bit(6)) { cpu.IRQPending = true; }
|
if (int_en.Bit(6)) { cpu.IRQPending = true; }
|
||||||
|
|
||||||
if (t1_ctrl.Bit(7)) { PB7 = !PB7; ppu.ramp_sig = !PB7; }
|
if (t1_ctrl.Bit(7)) { PB7 = !PB7; ppu.ramp_sig = !PB7; }
|
||||||
}
|
}
|
||||||
|
@ -480,7 +481,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
{
|
{
|
||||||
int_fl |= 0x40;
|
int_fl |= 0x40;
|
||||||
update_int_fl();
|
update_int_fl();
|
||||||
//if (int_en.Bit(6)) { cpu.IRQPending = true; }
|
if (int_en.Bit(6)) { cpu.IRQPending = true; }
|
||||||
if (t1_ctrl.Bit(7)) { PB7 = true; ppu.ramp_sig = false; }
|
if (t1_ctrl.Bit(7)) { PB7 = true; ppu.ramp_sig = false; }
|
||||||
|
|
||||||
t1_shot_go = false;
|
t1_shot_go = false;
|
||||||
|
@ -496,10 +497,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
if (t2_ctrl.Bit(5))
|
if (t2_ctrl.Bit(5))
|
||||||
{
|
{
|
||||||
t2_counter = (t2_high << 8) | t2_low;
|
t2_counter = (t2_high << 8) | t2_low;
|
||||||
|
|
||||||
int_fl |= 0x20;
|
int_fl |= 0x20;
|
||||||
update_int_fl();
|
update_int_fl();
|
||||||
//if (int_en.Bit(6)) { cpu.IRQPending = true; }
|
if (int_en.Bit(5)) { cpu.IRQPending = true; }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -509,7 +509,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
{
|
{
|
||||||
int_fl |= 0x20;
|
int_fl |= 0x20;
|
||||||
update_int_fl();
|
update_int_fl();
|
||||||
//if (int_en.Bit(6)) { cpu.IRQPending = true; }
|
if (int_en.Bit(5)) { cpu.IRQPending = true; }
|
||||||
|
|
||||||
t2_shot_go = false;
|
t2_shot_go = false;
|
||||||
}
|
}
|
||||||
|
@ -564,6 +564,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
test |= int_en.Bit(i) & int_fl.Bit(i);
|
test |= int_en.Bit(i) & int_fl.Bit(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!test) { cpu.IRQPending = false; }
|
||||||
int_fl |= (byte)(test ? 0x80 : 0);
|
int_fl |= (byte)(test ? 0x80 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ namespace BizHawk.Emulation.Cores.Consoles.Vectrex
|
||||||
public void do_frame()
|
public void do_frame()
|
||||||
{
|
{
|
||||||
_vidbuffer = new int[VirtualWidth * VirtualHeight];
|
_vidbuffer = new int[VirtualWidth * VirtualHeight];
|
||||||
//PB7_undriven = true;
|
|
||||||
//for (int i = 0; i < 1000; i++)
|
//for (int i = 0; i < 100; i++)
|
||||||
while (!frame_end)
|
while (!frame_end)
|
||||||
{
|
{
|
||||||
internal_state_tick();
|
internal_state_tick();
|
||||||
|
|
Loading…
Reference in New Issue