From d0e6441f7b5f7d94b45b014afa7a4adae7307eec Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Sat, 21 Dec 2019 20:59:09 -0500 Subject: [PATCH] O2Hawk: more bug fixes to timing and interrupts --- .../CPUs/Intel8048/I8048.cs | 11 ++++- .../CPUs/Intel8048/OP_Tables.cs | 16 ++++---- .../Magnavox/Odyssey2/O2Hawk.IEmulator.cs | 5 +-- .../Consoles/Magnavox/Odyssey2/PPU.cs | 40 +++++++------------ 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs index 518f44d4a1..9cb2c194b1 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs @@ -184,7 +184,16 @@ namespace BizHawk.Emulation.Common.Components.I8048 reg_l_ad = cur_instr[instr_pntr++]; reg_h_ad = cur_instr[instr_pntr++]; // direct value - Regs[reg_d_ad] = (ushort)(MB | (reg_h_ad << 8) | Regs[reg_l_ad]); + // bit 11 held low during interrupt + if (INT_MSTR) + { + Regs[reg_d_ad] = (ushort)(MB | (reg_h_ad << 8) | Regs[reg_l_ad]); + } + else + { + Regs[reg_d_ad] = (ushort)((reg_h_ad << 8) | Regs[reg_l_ad]); + } + break; case CLRA: Regs[A] = 0; diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/OP_Tables.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/OP_Tables.cs index acc8dd13d7..5b4b708c36 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/OP_Tables.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/OP_Tables.cs @@ -129,14 +129,14 @@ namespace BizHawk.Emulation.Common.Components.I8048 public void BUS_PORT_OUT() { PopulateCURINSTR(IDLE, - IDLE, - IDLE, - IDLE, - IDLE, - IDLE, - IDLE, - IDLE, - WR_P, 0, A); + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + IDLE, + WR_P, 0, A); IRQS = 9; Console.WriteLine("OUT"); diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs index 9f78a61fb3..86cdff16d7 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs @@ -18,7 +18,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk public bool FrameAdvance(IController controller, bool render, bool rendersound) { - // Console.WriteLine("-----------------------FRAME-----------------------"); + //Console.WriteLine("-----------------------FRAME-----------------------"); if (_tracer.Enabled) { @@ -62,7 +62,6 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { ppu.tick(); ppu.tick(); - ppu.DMA_tick(); serialport.serial_transfer_tick(); ppu.Audio_tick(); cpu.ExecuteOne(); @@ -80,10 +79,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { ppu.tick(); ppu.tick(); - ppu.DMA_tick(); serialport.serial_transfer_tick(); ppu.Audio_tick(); cpu.ExecuteOne(); + } public void GetControllerState(IController controller) diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs index c69038a832..2c245e7a96 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics.Eventing.Reader; +using System.Runtime.InteropServices; using BizHawk.Common; using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; @@ -19,7 +20,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk public byte[] Grid_V = new byte[10]; public byte VDC_ctrl, VDC_status, VDC_collision, VDC_col_ret, VDC_color; - public byte Frame_Col, Pixel_Stat; + public byte Pixel_Stat; public int grid_fill; public byte grid_fill_col; @@ -129,6 +130,9 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk else if (addr == 0xA3) { VDC_color = value; + //Console.WriteLine("VDC_color: " + value + " " + Core.cpu.TotalExecutedCycles); + //VDC_color &= 0xF8; + //VDC_color |= 3; } else if (addr == 0xA4) { @@ -178,6 +182,9 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk if (LY < 240) { // background + Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[(VDC_color >> 3) & 0x7]; + + // grid if (grid_fill > 0) { Core._vidbuffer[LY * 186 + (cycle - 43)] = (int)Color_Palette_BG[VDC_color & 0x7]; @@ -389,12 +396,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { cycle = 0; HBL = true; - - - // send T1 pulses - Core.cpu.T1 = true; LY++; + + if (LY == 240) { VBL = true; @@ -412,8 +417,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk VBL = false; VDC_col_ret = 0; Core.in_vblank = false; - if (!VDC_ctrl.Bit(0)) { Core.cpu.IRQPending = false; } - Frame_Col = 0; + } + if (LY < 240) + { + // send T1 pulses + Core.cpu.T1 = true; } } } @@ -424,28 +432,11 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk } - public void render(int render_cycle) - { - - } - public void process_sprite() { } - // normal DMA moves twice as fast in double speed mode on GBC - // So give it it's own function so we can seperate it from PPU tick - public void DMA_tick() - { - - } - - public void OAM_scan(int OAM_cycle) - { - - } - public void Reset() { AudioReset(); @@ -564,7 +555,6 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk ser.Sync(nameof(VDC_collision), ref VDC_collision); ser.Sync(nameof(VDC_col_ret), ref VDC_col_ret); ser.Sync(nameof(VDC_color), ref VDC_color); - ser.Sync(nameof(Frame_Col), ref Frame_Col); ser.Sync(nameof(Pixel_Stat), ref Pixel_Stat); ser.Sync(nameof(grid_fill), ref grid_fill);