From 4619e7a862a0c5caf46037e74829d8ea91b9402f Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Tue, 17 Dec 2019 17:40:57 -0500 Subject: [PATCH] O2Hawk: cleanup and bug fixes --- Assets/gamedb/gamedb_Odyssey2.txt | 2 ++ .../CPUs/Intel8048/Disassembler.cs | 2 +- .../CPUs/Intel8048/I8048.cs | 16 ++++++---------- .../CPUs/Intel8048/OP_Tables.cs | 4 ++-- .../Magnavox/Odyssey2/O2Hawk.IStatable.cs | 2 -- .../Consoles/Magnavox/Odyssey2/O2Hawk.cs | 8 ++------ .../Consoles/Magnavox/Odyssey2/PPU.cs | 18 +++++------------- 7 files changed, 18 insertions(+), 34 deletions(-) diff --git a/Assets/gamedb/gamedb_Odyssey2.txt b/Assets/gamedb/gamedb_Odyssey2.txt index b546e0c9a3..1fb1843ce7 100644 --- a/Assets/gamedb/gamedb_Odyssey2.txt +++ b/Assets/gamedb/gamedb_Odyssey2.txt @@ -2,5 +2,7 @@ SHA1:26A044C68FF08F574F6649B731B82CACA8C0E797 Death Race O2 SHA1:E04D12B6290370B76F90E76D9DE75B6470B4F913 redgreen O2 SHA1:38D4AAB263E10B1DAC3410C120536EE079826BCB Fatso 2 O2 SHA1:3720DD6B5EE3DC62C5AF2EA9D915A2B83DE9463D Chief Chef O2 +SHA1:FEB358E28587DE70D1E89BF0F9A3209CE0B67C57 Haunted House O2 +SHA1:B1D65BEDB56FE7A9CF60AA054A9FD9BB7F65B77C 3D Box O2 diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/Disassembler.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/Disassembler.cs index 86c3c93d52..927ba2c662 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/Disassembler.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/Disassembler.cs @@ -187,7 +187,7 @@ namespace BizHawk.Emulation.Common.Components.I8048 "MOV @R0,i8", // b0 "MOV @R1,i8", // b1 "JPB 5,i8", // b2 - "JPP A,i8", // b3 + "JPP A", // b3 "CALL 5,i8", // b4 "COM F1", // b5 "JP F0,i8", // b6 diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs index 2da10f73fb..45c9c5efdb 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs @@ -78,8 +78,6 @@ namespace BizHawk.Emulation.Common.Components.I8048 public const ushort SET_ADDR_M3 = 65; public const ushort MOVT_RAM_D = 66; - public ushort test; - public I8048() { Reset(); @@ -100,6 +98,7 @@ namespace BizHawk.Emulation.Common.Components.I8048 IRQS = 5; instr_pntr = irq_pntr = 0; Regs[PX + 1] = 0xFF; + Regs[PX + 2] = 0xFF; } // Memory Access @@ -165,7 +164,9 @@ namespace BizHawk.Emulation.Common.Components.I8048 if (OnExecFetch != null) OnExecFetch(PC); if (TraceCallback != null) TraceCallback(State()); if (CDLCallback != null) CDLCallback(PC, eCDLogMemFlags.FetchFirst); - FetchInstruction(ReadMemory(Regs[PC]++)); + FetchInstruction(ReadMemory(Regs[PC])); + Regs[ALU2] = (ushort)(Regs[PC] & 0x800); + Regs[PC] = (ushort)(((Regs[PC] + 1) & 0x7FF) | Regs[ALU2]); instr_pntr = 0; irq_pntr = -1; break; @@ -530,8 +531,7 @@ namespace BizHawk.Emulation.Common.Components.I8048 /// private void PopulateCURINSTR(ushort d0 = 0, ushort d1 = 0, ushort d2 = 0, ushort d3 = 0, ushort d4 = 0, ushort d5 = 0, ushort d6 = 0, ushort d7 = 0, ushort d8 = 0, ushort d9 = 0, ushort d10 = 0, ushort d11 = 0, ushort d12 = 0, ushort d13 = 0, ushort d14 = 0, ushort d15 = 0, ushort d16 = 0, ushort d17 = 0, ushort d18 = 0, - ushort d19 = 0, ushort d20 = 0, ushort d21 = 0, ushort d22 = 0, ushort d23 = 0, ushort d24 = 0, ushort d25 = 0, ushort d26 = 0, ushort d27 = 0, ushort d28 = 0, - ushort d29 = 0, ushort d30 = 0, ushort d31 = 0, ushort d32 = 0, ushort d33 = 0, ushort d34 = 0, ushort d35 = 0, ushort d36 = 0, ushort d37 = 0, ushort d38 = 0) + ushort d19 = 0, ushort d20 = 0, ushort d21 = 0, ushort d22 = 0, ushort d23 = 0, ushort d24 = 0, ushort d25 = 0, ushort d26 = 0) { cur_instr[0] = d0; cur_instr[1] = d1; cur_instr[2] = d2; cur_instr[3] = d3; cur_instr[4] = d4; cur_instr[5] = d5; @@ -542,16 +542,12 @@ namespace BizHawk.Emulation.Common.Components.I8048 cur_instr[18] = d18; cur_instr[19] = d19; cur_instr[20] = d20; cur_instr[21] = d21; cur_instr[22] = d22; cur_instr[23] = d23; cur_instr[24] = d24; cur_instr[25] = d25; cur_instr[26] = d26; - cur_instr[27] = d27; cur_instr[28] = d28; cur_instr[29] = d29; - cur_instr[30] = d30; cur_instr[31] = d31; cur_instr[32] = d32; - cur_instr[33] = d33; cur_instr[34] = d34; cur_instr[35] = d35; - cur_instr[36] = d36; cur_instr[37] = d37; cur_instr[38] = d38; } // State Save/Load public void SyncState(Serializer ser) { - ser.BeginSection("MC6809"); + ser.BeginSection("I8048"); ser.Sync(nameof(IntEn), ref IntEn); ser.Sync(nameof(TimIntEn), ref TimIntEn); diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/OP_Tables.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/OP_Tables.cs index c621e18f68..acc8dd13d7 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/OP_Tables.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/OP_Tables.cs @@ -406,8 +406,8 @@ namespace BizHawk.Emulation.Common.Components.I8048 { PopulateCURINSTR(IDLE, IDLE, - IDLE, - MEM_ALU, A, + SET_ADDR_8, PC, A, + RD, ALU, PC, IDLE, IDLE, IDLE, diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IStatable.cs index 95348f9da8..914c14d42b 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IStatable.cs @@ -76,9 +76,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk // memory domains ser.Sync(nameof(RAM), ref RAM, false); - ser.Sync(nameof(OAM), ref OAM, false); ser.Sync(nameof(_bios), ref _bios, false); - ser.Sync(nameof(RAM_Bank), ref RAM_Bank); ser.Sync(nameof(addr_latch), ref addr_latch); ser.Sync(nameof(kb_byte), ref kb_byte); ser.Sync(nameof(kb_state_row), ref kb_state_row); diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs index 72bbba7a8a..6d53e3658a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.cs @@ -19,14 +19,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk // memory domains public byte[] RAM = new byte[0x80]; - public byte[] OAM = new byte[0xA0]; - - public int RAM_Bank; public byte addr_latch; public byte kb_byte; public bool ppu_en, RAM_en, kybrd_en, copy_en, lum_en, cart_b0, cart_b1; public ushort rom_bank; - public const bool P15 = true; public byte[] _bios; public readonly byte[] _rom; @@ -134,9 +130,9 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk in_vblank = true; // we start off in vblank since the LCD is off in_vblank_old = true; - RAM_Bank = 1; // RAM bank always starts as 1 (even writing zero still sets 1) - + // bank switching carts expect to be in upper bank on boot up, so can't have 0 at ports WritePort(1, 0xFF); + WritePort(2, 0xFF); ppu.Reset(); serialport.Reset(); diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs index d9deaa26d5..8fcbce2edf 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs @@ -20,12 +20,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk public byte VDC_ctrl, VDC_status, VDC_collision, VDC_col_ret, VDC_color; public byte Frame_Col, Pixel_Stat; - - // register variables public int LY; - public byte LY_actual; - public byte LY_inc; - public byte LYC; public int cycle; public bool VBL; public bool HBL; @@ -152,8 +147,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk if (cycle == 43) { HBL = false; - // trigger timer tick if enabled - if (Core.cpu.counter_en) { Core.cpu.T1 = false; } + // Send T1 pulses + Core.cpu.T1 = false; //if (VDC_ctrl.Bit(0)) { Core.cpu.IRQPending = false; } if (LY == 240) { VDC_status |= 0x08; } @@ -356,8 +351,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk HBL = true; - // trigger timer tick if enabled - if (Core.cpu.counter_en) { Core.cpu.T1 = true; } + // send T1 pulses + Core.cpu.T1 = true; LY++; if (LY == 240) @@ -470,7 +465,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk 0x38, 0x38, 0x30, 0x3C, 0x30, 0x68, 0x4C, 00, // (runner R) 0x33 0x38, 0x38, 0x18, 0x78, 0x18, 0x2C, 0x64, 00, // (runner L) 0x34 0x38, 0x38, 0x18, 0x78, 0x18, 0x18, 0x38, 00, // (person L) 0x35 - 0x00, 0x18, 0xC0, 0xF7, 0xC0, 0x18, 0x00, 00, // (arrow R) 0x36 + 0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 00, // (arrow R) 0x36 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0x18, 0x18, 00, // (tree) 0x37 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 00, // (ramp R) 0x38 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 00, // (ramp L) 0x39 @@ -533,9 +528,6 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk ser.Sync(nameof(Pixel_Stat), ref Pixel_Stat); ser.Sync(nameof(LY), ref LY); - ser.Sync(nameof(LY_actual), ref LY_actual); - ser.Sync(nameof(LY_inc), ref LY_inc); - ser.Sync(nameof(LYC), ref LYC); ser.Sync(nameof(cycle), ref cycle); ser.Sync(nameof(VBL), ref VBL); ser.Sync(nameof(HBL), ref HBL);