diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/Execute.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/Execute.cs index 0353517a6d..5b7e78a495 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/Execute.cs @@ -199,8 +199,8 @@ namespace BizHawk.Emulation.Common.Components.I8048 case 0xAD: OP_R_IMP(MOVAR, R5); break; // MOV R5,A case 0xAE: OP_R_IMP(MOVAR, R6); break; // MOV R6,A case 0xAF: OP_R_IMP(MOVAR, R7); break; // MOV R7,A - case 0xB0: OP_DIR_IR(MOVT_RAM, R0); break; // MOV @R0,# - case 0xB1: OP_DIR_IR(MOVT_RAM, R1); break; // MOV @R1,# + case 0xB0: OP_DIR_IR(MOVT_RAM_D, R0); break; // MOV @R0,# + case 0xB1: OP_DIR_IR(MOVT_RAM_D, R1); break; // MOV @R1,# case 0xB2: JPB(5); break; // JPB 5 case 0xB3: JP_A(); break; // JPP A case 0xB4: CALL(5); break; // CALL diff --git a/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs b/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs index f78def506f..2a4bc06fa9 100644 --- a/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs +++ b/BizHawk.Emulation.Cores/CPUs/Intel8048/I8048.cs @@ -76,6 +76,7 @@ namespace BizHawk.Emulation.Common.Components.I8048 public const ushort EM = 63; public const ushort DM = 64; public const ushort SET_ADDR_M3 = 65; + public const ushort MOVT_RAM_D = 66; public ushort test; @@ -400,6 +401,12 @@ namespace BizHawk.Emulation.Common.Components.I8048 Regs[ALU] &= 0xFF; Regs[ALU] |= 0x300; break; + case MOVT_RAM_D: + reg_d_ad = cur_instr[instr_pntr++]; + reg_d_ad = (ushort)(Regs[reg_d_ad] & 0x3F); + Regs[reg_d_ad] = Regs[cur_instr[instr_pntr++]]; + //Console.WriteLine(reg_d_ad + " " + Regs[reg_d_ad] + " " + Regs[ALU] + " " + TotalExecutedCycles); + break; } if (++irq_pntr == IRQS) diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/MemoryMap.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/MemoryMap.cs index a6e47b66d7..e50980ad56 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/MemoryMap.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/MemoryMap.cs @@ -117,7 +117,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk else { // keyboard - return 0; + return kb_byte; } } @@ -167,7 +167,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk else { // keyboard - kb_byte = value; + kb_byte = (byte)(value & 7); + KB_Scan(); } } } diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs index 16cfe79487..641916d16a 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IEmulator.cs @@ -11,7 +11,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk public ControllerDefinition ControllerDefinition => _controllerDeck.Definition; - public byte controller_state_1, controller_state_2; + public byte controller_state_1, controller_state_2, kb_state_row, kb_state_col; public bool in_vblank_old; public bool in_vblank; public bool vblank_rise; @@ -91,6 +91,68 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk InputCallbacks.Call(); controller_state_1 = _controllerDeck.ReadPort1(controller); controller_state_2 = _controllerDeck.ReadPort2(controller); + + kb_state_row = 8; // nothing pressed + if (controller.IsPressed("0")) { kb_state_row = 0; kb_state_col = 0; } + if (controller.IsPressed("1")) { kb_state_row = 0; kb_state_col = 1; } + if (controller.IsPressed("2")) { kb_state_row = 0; kb_state_col = 2; } + if (controller.IsPressed("3")) { kb_state_row = 0; kb_state_col = 3; } + if (controller.IsPressed("4")) { kb_state_row = 0; kb_state_col = 4; } + if (controller.IsPressed("5")) { kb_state_row = 0; kb_state_col = 5; } + if (controller.IsPressed("6")) { kb_state_row = 0; kb_state_col = 6; } + if (controller.IsPressed("7")) { kb_state_row = 0; kb_state_col = 7; } + if (controller.IsPressed("8")) { kb_state_row = 1; kb_state_col = 0; } + if (controller.IsPressed("9")) { kb_state_row = 1; kb_state_col = 1; } + if (controller.IsPressed("SPC")) { kb_state_row = 1; kb_state_col = 4; } + if (controller.IsPressed("?")) { kb_state_row = 1; kb_state_col = 5; } + if (controller.IsPressed("L")) { kb_state_row = 1; kb_state_col = 6; } + if (controller.IsPressed("P")) { kb_state_row = 1; kb_state_col = 7; } + if (controller.IsPressed("+")) { kb_state_row = 2; kb_state_col = 0; } + if (controller.IsPressed("W")) { kb_state_row = 2; kb_state_col = 1; } + if (controller.IsPressed("E")) { kb_state_row = 2; kb_state_col = 2; } + if (controller.IsPressed("R")) { kb_state_row = 2; kb_state_col = 3; } + if (controller.IsPressed("T")) { kb_state_row = 2; kb_state_col = 4; } + if (controller.IsPressed("U")) { kb_state_row = 2; kb_state_col = 5; } + if (controller.IsPressed("I")) { kb_state_row = 2; kb_state_col = 6; } + if (controller.IsPressed("O")) { kb_state_row = 2; kb_state_col = 7; } + if (controller.IsPressed("Q")) { kb_state_row = 3; kb_state_col = 0; } + if (controller.IsPressed("S")) { kb_state_row = 3; kb_state_col = 1; } + if (controller.IsPressed("D")) { kb_state_row = 3; kb_state_col = 2; } + if (controller.IsPressed("F")) { kb_state_row = 3; kb_state_col = 3; } + if (controller.IsPressed("G")) { kb_state_row = 3; kb_state_col = 4; } + if (controller.IsPressed("H")) { kb_state_row = 3; kb_state_col = 5; } + if (controller.IsPressed("J")) { kb_state_row = 3; kb_state_col = 6; } + if (controller.IsPressed("K")) { kb_state_row = 3; kb_state_col = 7; } + if (controller.IsPressed("A")) { kb_state_row = 4; kb_state_col = 0; } + if (controller.IsPressed("Z")) { kb_state_row = 4; kb_state_col = 1; } + if (controller.IsPressed("X")) { kb_state_row = 4; kb_state_col = 2; } + if (controller.IsPressed("C")) { kb_state_row = 4; kb_state_col = 3; } + if (controller.IsPressed("V")) { kb_state_row = 4; kb_state_col = 4; } + if (controller.IsPressed("B")) { kb_state_row = 4; kb_state_col = 5; } + if (controller.IsPressed("M")) { kb_state_row = 4; kb_state_col = 6; } + if (controller.IsPressed(".")) { kb_state_row = 4; kb_state_col = 7; } + if (controller.IsPressed("-")) { kb_state_row = 5; kb_state_col = 0; } + if (controller.IsPressed("*")) { kb_state_row = 5; kb_state_col = 1; } + if (controller.IsPressed("/")) { kb_state_row = 5; kb_state_col = 2; } + if (controller.IsPressed("=")) { kb_state_row = 5; kb_state_col = 3; } + if (controller.IsPressed("YES")) { kb_state_row = 5; kb_state_col = 4; } + if (controller.IsPressed("NO")) { kb_state_row = 5; kb_state_col = 5; } + if (controller.IsPressed("CLR")) { kb_state_row = 5; kb_state_col = 6; } + if (controller.IsPressed("ENT")) { kb_state_row = 5; kb_state_col = 7; } + + } + + public void KB_Scan() + { + if (kb_byte == kb_state_row) + { + kb_byte &= 0xEF; + kb_byte |= (byte)(kb_state_col << 5); + } + else + { + kb_byte |= 0x10; + } } public int Frame => _frame; @@ -135,7 +197,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk } } - public int VirtualWidth => 186; + public int VirtualWidth => 213; public int VirtualHeight => 240; public int BufferWidth => 186; public int BufferHeight => 240; diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IStatable.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IStatable.cs index 3a36ac178e..e56c91b4be 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IStatable.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2Hawk.IStatable.cs @@ -80,6 +80,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk 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); + ser.Sync(nameof(kb_state_col), ref kb_state_col); ser.Sync(nameof(frame_buffer), ref frame_buffer, false); ser.Sync(nameof(_vidbuffer), ref _vidbuffer, false); diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs index 428e97a577..56ab5c2cc6 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/O2HawkControllerDeck.cs @@ -32,6 +32,12 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk .Concat(Port2.Definition.BoolButtons) .Concat(new[] { + "0", "1", "2", "3", "4", "5", "6", "7", + "8", "9", "SPC", "?", "L", "P", + "+", "W", "E", "R", "T", "U", "I", "O", + "Q", "S", "D", "F", "G", "H", "J", "K", + "A", "Z", "X", "C", "V", "B", "M", ".", + "-", "*", "/", "=", "YES", "NO", "CLR", "ENT", "Power" }) .ToList() diff --git a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs index 68ee4f2588..589974c18c 100644 --- a/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs +++ b/BizHawk.Emulation.Cores/Consoles/Magnavox/Odyssey2/PPU.cs @@ -79,7 +79,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk } else if (addr == 0xA2) { - ret = VDC_collision; + ret = 0;//VDC_collision; //Console.WriteLine("col: " + ret + " " + Core.cpu.TotalExecutedCycles); } else if(addr == 0xA3) @@ -227,7 +227,40 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk } // quads + for (int i = 0; i < 4; i++) + { + if ((LY >= Quad_Chars[i * 16 + 12]) && (LY < (Quad_Chars[i * 16 + 12] + 8))) + { + if (((cycle - 43) >= Quad_Chars[i * 16 + 12 + 1]) && ((cycle - 43) < (Quad_Chars[i * 16 + 12 + 1] + 64))) + { + // sprite is in drawing region, pick a pixel + int offset_y = LY - Quad_Chars[i * 16 + 12]; + int offset_x = 63 - ((cycle - 43) - Quad_Chars[i * 16 + 12 + 1]); + int quad_num = 0; + while (offset_x > 15) + { + offset_x -= 16; + quad_num++; + } + + if (offset_x <= 7) + { + int char_sel = Quad_Chars[i * 16 + 4 * quad_num + 2] + ((Quad_Chars[i * 16 + 4 * quad_num + 3] & 1) << 8); + + int pixel_pick = (Internal_Graphics[(char_sel + offset_y) % 0x200] >> offset_x) & 1; + + if (pixel_pick == 1) + { + Core._vidbuffer[LY * 186 + (cycle - 43)] = (int) Color_Palette_SPR[(Quad_Chars[i * 16 + 4 * quad_num + 3] >> 1) & 0x7]; + Pixel_Stat |= 0x80; + } + } + } + } + } + // background + // calculate collision } @@ -482,8 +515,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk case 0xAA: aud_ctrl = value; break; } - - + //Console.WriteLine((addr - 0xA7) + " " + value); } public void Audio_tick() @@ -510,6 +542,19 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk { shift_0 = (byte)(shift_0 >> 1); } + + if (aud_ctrl.Bit(4)) + { + if (shift_2.Bit(7) == output_bit.Bit(0)) + { + shift_2 &= 0x7F; + } + else + { + shift_2 = (byte)(shift_2 | 0x80); + } + + } } C_final = output_bit;