O2Hawk: various bug fixes
This commit is contained in:
parent
f090d75c9d
commit
0e7e93b205
|
@ -15,6 +15,8 @@ SHA1:DE888B7AA2716C3134CFF812A4E07E86B2479537 D Shoot the B O2 US
|
|||
SHA1:85A44A99B254D92A7433EE46E4CAA91483D7FEA2 D Go Sub 2 O2 US
|
||||
SHA1:2B34EF0E1A8C0371F00A33D6950E0807F3CB886E D Happy Emu O2 US
|
||||
SHA1:03C846187581A44CE4F7B056C05186520C2DB1B4 D Happy Bird O2 US
|
||||
SHA1:42AD0C57BD16B7F24C242F60B5C0E9988D8DFBA8 D Kill The Attacking Aliens O2 US
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -513,7 +513,7 @@ namespace BizHawk.Emulation.Cores.Components.I8048
|
|||
|
||||
public Action<TraceInfo> TraceCallback;
|
||||
|
||||
public string TraceHeader => "MC6809: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (CAFBIFT0T1TFR)";
|
||||
public string TraceHeader => "I8048: PC, machine code, mnemonic, operands, registers (A, B, X, Y, US, SP, DP, CC), Cy, flags (CAFBIFT0T1TFR)";
|
||||
|
||||
public TraceInfo State(bool disassemble = true)
|
||||
{
|
||||
|
|
|
@ -1,58 +1,45 @@
|
|||
using BizHawk.Emulation.Cores.Components.I8048;
|
||||
using System;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Cores.Components.I8048;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
||||
{
|
||||
// Default mapper with no bank switching
|
||||
public class MapperDefault : MapperBase
|
||||
{
|
||||
public int ROM_mask;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
// nothing to initialize
|
||||
// roms come in 3 sizes, but the last size is a degenerate case
|
||||
if (Core._rom.Length == 0x3000)
|
||||
{
|
||||
ROM_mask = 0x3FFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
ROM_mask = Core._rom.Length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public override byte ReadMemory(ushort addr)
|
||||
{
|
||||
if (addr < 0x8000)
|
||||
{
|
||||
return Core._rom[addr & (Core._rom.Length - 1)];
|
||||
}
|
||||
|
||||
if (Core.cart_RAM != null)
|
||||
{
|
||||
return Core.cart_RAM[addr - 0xA000];
|
||||
}
|
||||
|
||||
return 0;
|
||||
return Core._rom[addr & ROM_mask];
|
||||
}
|
||||
|
||||
public override void MapCDL(ushort addr, I8048.eCDLogMemFlags flags)
|
||||
{
|
||||
if (addr < 0x8000)
|
||||
{
|
||||
SetCDLROM(flags, addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Core.cart_RAM != null)
|
||||
{
|
||||
SetCDLRAM(flags, addr - 0xA000);
|
||||
}
|
||||
}
|
||||
SetCDLROM(flags, addr);
|
||||
}
|
||||
|
||||
public override void WriteMemory(ushort addr, byte value)
|
||||
{
|
||||
if (addr < 0x8000)
|
||||
{
|
||||
// no mapping hardware available
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Core.cart_RAM != null)
|
||||
{
|
||||
Core.cart_RAM[addr - 0xA000] = value;
|
||||
}
|
||||
}
|
||||
// no mapping hardware available
|
||||
}
|
||||
|
||||
public override void SyncState(Serializer ser)
|
||||
{
|
||||
ser.Sync(nameof(ROM_mask), ref ROM_mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
return _bios[addr];
|
||||
}
|
||||
|
||||
return mapper.ReadMemory((ushort)((addr - 0x400) | rom_bank));
|
||||
return mapper.ReadMemory((ushort)((addr - 0x400) + bank_size * rom_bank));
|
||||
}
|
||||
|
||||
public void WriteMemory(ushort addr, byte value)
|
||||
|
@ -46,7 +46,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
return _bios[addr];
|
||||
}
|
||||
|
||||
return mapper.PeekMemory((ushort)(addr - 0x400));
|
||||
return mapper.PeekMemory((ushort)((addr - 0x400) + bank_size * rom_bank));
|
||||
}
|
||||
|
||||
public byte ReadPort(ushort port)
|
||||
|
@ -155,12 +155,12 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
|
||||
rom_bank = (ushort)(cart_b0 ? 1 : 0);
|
||||
rom_bank |= (ushort)(cart_b1 ? 2 : 0);
|
||||
rom_bank = (ushort)(rom_bank << 11);
|
||||
//rom_bank = (ushort)(rom_bank << 12);
|
||||
|
||||
ppu.bg_brightness = !ppu.lum_en ? 8 : 0;
|
||||
ppu.grid_brightness = (!ppu.lum_en | ppu.VDC_color.Bit(6)) ? 8 : 0;
|
||||
|
||||
//Console.WriteLine("main ctrl: " + value + " " + ppu.lum_en + " " + ppu_en + " " + RAM_en + " " + cpu.TotalExecutedCycles + " " + ppu.LY);
|
||||
//Console.WriteLine("main ctrl: " + value + " " + ppu.lum_en + " " + ppu_en + " " + RAM_en + " " + cpu.TotalExecutedCycles + " " + ppu.LY + " " + rom_bank);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
"PPU",
|
||||
256,
|
||||
MemoryDomain.Endian.Little,
|
||||
addr => ppu.ReadReg((int)addr),
|
||||
addr => ppu.PeekReg((int)addr),
|
||||
(addr, value) => ppu.WriteReg((int)addr, value),
|
||||
1)
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
ser.Sync(nameof(copy_en), ref copy_en);
|
||||
ser.Sync(nameof(kybrd_en), ref kybrd_en);
|
||||
ser.Sync(nameof(rom_bank), ref rom_bank);
|
||||
ser.Sync(nameof(bank_size), ref bank_size);
|
||||
|
||||
// memory domains
|
||||
ser.Sync(nameof(RAM), ref RAM, false);
|
||||
|
|
|
@ -21,6 +21,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
public byte kb_byte;
|
||||
public bool ppu_en, RAM_en, kybrd_en, copy_en, cart_b0, cart_b1;
|
||||
public ushort rom_bank;
|
||||
public ushort bank_size;
|
||||
|
||||
public byte[] _bios;
|
||||
public readonly byte[] _rom;
|
||||
|
@ -155,6 +156,19 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
{
|
||||
Core = this
|
||||
};
|
||||
|
||||
mapper.Initialize();
|
||||
|
||||
// bank size is different for 12 k carts, it uses all 3k per bank. Note that A11 is held low by the CPU during interrupts
|
||||
// so this means 12k games use the upper 1k outside of vbl
|
||||
if (_rom.Length == 0x3000)
|
||||
{
|
||||
bank_size = 0xC00;
|
||||
}
|
||||
else
|
||||
{
|
||||
bank_size = 0x800;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
{
|
||||
ret = VDC_status;
|
||||
// reading status clears IRQ request
|
||||
VDC_status &= 0xF7;
|
||||
VDC_status &= 0xF3;
|
||||
Core.cpu.IRQPending = false;
|
||||
}
|
||||
else if (addr == 0xA2)
|
||||
|
@ -136,6 +136,47 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
return ret;
|
||||
}
|
||||
|
||||
//Peek method for memory domains that doesn't effect IRQ
|
||||
public byte PeekReg(int addr)
|
||||
{
|
||||
byte ret = 0;
|
||||
|
||||
if (addr < 0x10) { ret = Sprites[addr]; }
|
||||
else if (addr < 0x40) { ret = Foreground[addr - 0x10]; }
|
||||
else if (addr < 0x80) { ret = Quad_Chars[addr - 0x40]; }
|
||||
else if (addr < 0xA0) { ret = Sprite_Shapes[addr - 0x80]; }
|
||||
else if (addr == 0xA0) { ret = VDC_ctrl; }
|
||||
else if (addr == 0xA1) { ret = VDC_status; }
|
||||
else if (addr == 0xA2)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (VDC_collision.Bit(i))
|
||||
{
|
||||
ret |= VDC_col_ret[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (addr == 0xA3) { ret = VDC_color; }
|
||||
else if (addr == 0xA4)
|
||||
{
|
||||
if (latch_x_y) { ret = A4_latch; }
|
||||
else { ret = (byte)((LY_ret >= 0) ? LY_ret : 0); }
|
||||
}
|
||||
else if (addr == 0xA5)
|
||||
{
|
||||
// reading the x reg clears the latch
|
||||
if (latch_x_y) { ret = A5_latch; }
|
||||
else { ret = (byte)(cycle); }
|
||||
}
|
||||
else if (addr <= 0xAA) { ret = AudioReadReg(addr); }
|
||||
else if ((addr >= 0xC0) && (addr <= 0xC8)) { ret = Grid_H[addr - 0xC0]; }
|
||||
else if ((addr >= 0xD0) && (addr <= 0xD8)) { ret = Grid_H[addr - 0xD0 + 9]; }
|
||||
else if ((addr >= 0xE0) && (addr <= 0xE9)) { ret = Grid_V[addr - 0xE0]; }
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void WriteReg(int addr, byte value)
|
||||
{
|
||||
if (addr < 0x10)
|
||||
|
@ -834,19 +875,19 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
public static readonly byte[] Internal_Graphics = { 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 00, // 0 0x00
|
||||
0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x3C, 00, // 1 0x01
|
||||
0x3C, 0x66, 0x0C, 0x18, 0x30, 0x60, 0x7E, 00, // 2 0x02
|
||||
0x3C, 0x66, 0x06, 0x1C, 0x06, 0x66, 0x3C, 00, // 3 0x03
|
||||
0x7C, 0xC6, 0x06, 0x3C, 0x06, 0xC6, 0x7C, 00, // 3 0x03
|
||||
0xCC, 0xCC, 0xCC, 0xFE, 0x0C, 0x0C, 0x0C, 00, // 4 0x04
|
||||
0x7E, 0x60, 0x60, 0x3C, 0x06, 0x66, 0x3C, 00, // 5 0x05
|
||||
0x3C, 0x66, 0x60, 0x7C, 0x66, 0x66, 0x3C, 00, // 6 0x06
|
||||
0xFE, 0xC0, 0xC0, 0x7C, 0x06, 0xC6, 0x7C, 00, // 5 0x05
|
||||
0x7C, 0xC6, 0xC0, 0xFC, 0xC6, 0xC6, 0x7C, 00, // 6 0x06
|
||||
0xFE, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 00, // 7 0x07
|
||||
0x3C, 0x66, 0x66, 0x3C, 0x66, 0x66, 0x3C, 00, // 8 0x08
|
||||
0x3C, 0x66, 0x66, 0x3E, 0x02, 0x66, 0x3C, 00, // 9 0x09
|
||||
0x7C, 0xC6, 0xC6, 0x7C, 0xC6, 0xC6, 0x7C, 00, // 8 0x08
|
||||
0x7C, 0xC6, 0xC6, 0x7E, 0x06, 0xC6, 0x7C, 00, // 9 0x09
|
||||
0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 00, // : 0x0A
|
||||
0x18, 0x7E, 0x58, 0x7E, 0x1A, 0x7E, 0x18, 00, // $ 0x0B
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 00, // 0x0C
|
||||
0x3C, 0x66, 0x0C, 0x18, 0x18, 0x00, 0x18, 00, // ? 0x0D
|
||||
0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xFE, 00, // L 0x0E
|
||||
0x7C, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 00, // P 0x0F
|
||||
0xFC, 0xC6, 0xC6, 0xFC, 0xC0, 0xC0, 0xC0, 00, // P 0x0F
|
||||
0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 00, // + 0x10
|
||||
0xC6, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC6, 00, // W 0x11
|
||||
0xFE, 0xC0, 0xC0, 0xFC, 0xC0, 0xC0, 0xFE, 00, // E 0x12
|
||||
|
@ -855,9 +896,9 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 00, // U 0x15
|
||||
0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 00, // I 0x16
|
||||
0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 00, // O 0x17
|
||||
0x7C, 0xC6, 0xC6, 0xC6, 0xD6, 0xCC, 0x76, 00, // Q 0x18
|
||||
0x7C, 0xC6, 0xC6, 0xC6, 0xDE, 0xCC, 0x76, 00, // Q 0x18
|
||||
0x7C, 0xC6, 0xC0, 0x7C, 0x06, 0xC6, 0x7C, 00, // S 0x19
|
||||
0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 00, // D 0x1A
|
||||
0xFC, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFC, 00, // D 0x1A
|
||||
0xFE, 0xC0, 0xC0, 0xF8, 0xC0, 0xC0, 0xC0, 00, // F 0x1B
|
||||
0x7C, 0xC6, 0xC0, 0xC0, 0xCE, 0xC6, 0x7E, 00, // G 0x1C
|
||||
0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 00, // H 0x1D
|
||||
|
@ -868,7 +909,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
0xC6, 0xC6, 0x6C, 0x38, 0x6C, 0xC6, 0xC6, 00, // X 0x22
|
||||
0x7C, 0xC6, 0xC0, 0xC0, 0xC0, 0xC6, 0x7C, 00, // C 0x23
|
||||
0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 00, // V 0x24
|
||||
0x7C, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x7C, 00, // B 0x25
|
||||
0xFC, 0xC6, 0xC6, 0xFC, 0xC6, 0xC6, 0xFC, 00, // B 0x25
|
||||
0xC6, 0xEE, 0xFE, 0xD6, 0xC6, 0xC6, 0xC6, 00, // M 0x26
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x38, 00, // . 0x27
|
||||
0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 00, // - 0x28
|
||||
|
@ -881,7 +922,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 00, // (box) 0x2F
|
||||
0xCE, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0xCE, 00, // 10 0x30
|
||||
0x00, 0x00, 0x3C, 0x7E, 0x7E, 0x7E, 0x3C, 00, // (ball) 0x31
|
||||
0x38, 0x38, 0x30, 0x3C, 0x30, 0x30, 0x38, 00, // (person R) 0x32
|
||||
0x1C, 0x1C, 0x18, 0x1E, 0x18, 0x18, 0x1C, 00, // (person R) 0x32
|
||||
0x1C, 0x1C, 0x18, 0x1E, 0x18, 0x34, 0x26, 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
|
||||
|
@ -891,7 +932,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFF, 00, // (ramp L) 0x39
|
||||
0x38, 0x38, 0x12, 0xFE, 0xB8, 0x28, 0x6C, 00, // (person F) 0x3A
|
||||
0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 00, // \ 0x3B
|
||||
0x00, 0x00, 0x18, 0x10, 0x10, 0xFF, 0x7E, 00, // (boat 1) 0x3C
|
||||
0x00, 0x00, 0x0C, 0x08, 0x08, 0xFF, 0x7E, 00, // (boat 1) 0x3C
|
||||
0x00, 0x03, 0x63, 0xFF, 0xFF, 0x18, 0x08, 00, // (plane) 0x3D
|
||||
0x00, 0x00, 0x00, 0x10, 0x38, 0xFF, 0x7E, 00, // (boat 2) 0x3E
|
||||
0x00, 0x00, 0x00, 0x06, 0x6E, 0xFF, 0x7E, 00 // (boat 3) 0x3F
|
||||
|
@ -900,10 +941,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
public static readonly uint[] Color_Palette_SPR =
|
||||
{
|
||||
0xFF676767, // grey
|
||||
0xFFC75151, // light red
|
||||
0xFF56C469, // light green
|
||||
0xFFC6B869, // light yellow
|
||||
0xFF5C80F6, // light blue
|
||||
0xFFFF4141, // light red
|
||||
0xFF56FF69, // light green
|
||||
0xFFFFCC66, // light yellow
|
||||
0xFF3595FF, // light blue
|
||||
0xFFDC84D4, // light violet
|
||||
0xFF77E6EB, // light blue-green
|
||||
0xFFFFFFFF, // white
|
||||
|
@ -912,20 +953,20 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
public static readonly uint[] Color_Palette_BG =
|
||||
{
|
||||
0xFF000000, // black
|
||||
0xFF1A37BE, // blue
|
||||
0xFF006D07, // green
|
||||
0xFF1A37E0, // blue
|
||||
0xFF008000, // green
|
||||
0xFF2AAABE, // blue-green
|
||||
0xFF790000, // red
|
||||
0xFFC00000, // red
|
||||
0xFF94309F, // violet
|
||||
0xFF77670B, // yellow
|
||||
0xFF676767, // grey
|
||||
0xFF676767, // grey
|
||||
0xFF5C80F6, // light blue
|
||||
0xFF56C469, // light green
|
||||
0xFF3595FF, // light blue
|
||||
0xFF56FF69, // light green
|
||||
0xFF77E6EB, // light blue-green
|
||||
0xFFC75151, // light red
|
||||
0xFFFF4141, // light red
|
||||
0xFFDC84D4, // light violet
|
||||
0xFFC6B869, // light yellow
|
||||
0xFFFFCC66, // light yellow
|
||||
0xFFFFFFFF, // white
|
||||
};
|
||||
|
||||
|
@ -1041,6 +1082,13 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
|
|||
shift_2 = shift_reg_2;
|
||||
}
|
||||
|
||||
// audio interrupt for empy shift regs
|
||||
if (VDC_ctrl.Bit(2))
|
||||
{
|
||||
VDC_status |= 4;
|
||||
Core.cpu.IRQPending = true;
|
||||
}
|
||||
|
||||
shift_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue