O2 - misc cleanups

This commit is contained in:
adelikat 2020-04-11 09:04:13 -05:00
parent 2304e9dc5b
commit 9eb63cd6c9
4 changed files with 51 additions and 68 deletions

View File

@ -20,10 +20,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
return _bios[addr];
}
else
{
return mapper.ReadMemory((ushort)((addr - 0x400) | rom_bank));
}
return mapper.ReadMemory((ushort)((addr - 0x400) | rom_bank));
}
public void WriteMemory(ushort addr, byte value)
@ -47,10 +45,8 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
return _bios[addr];
}
else
{
return mapper.PeekMemory((ushort)(addr - 0x400));
}
return mapper.PeekMemory((ushort)(addr - 0x400));
}
public byte ReadPort(ushort port)
@ -62,46 +58,43 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
return addr_latch;
}
else
if (RAM_en)
{
if (RAM_en)
if (addr_latch < 0x80)
{
if (addr_latch < 0x80)
{
return RAM[addr_latch & 0x7F];
}
else
{
// voice module would return here
return 0;
}
}
if (ppu_en)
{
return ppu.ReadReg(addr_latch);
return RAM[addr_latch & 0x7F];
}
// if neither RAM or PPU is enabled, then a RD pulse from instruction IN A,BUS will latch controller
// onto the bus, but only if they are enabled correctly using port 2
if (kybrd_en)
{
_islag = false;
if ((kb_byte & 7) == 1)
{
return controller_state_1;
}
if ((kb_byte & 7) == 0)
{
return controller_state_2;
}
}
Console.WriteLine(cpu.TotalExecutedCycles);
// not sure what happens if this case is reached, probably whatever the last value on the bus is
// voice module would return here
return 0;
}
if (ppu_en)
{
return ppu.ReadReg(addr_latch);
}
// if neither RAM or PPU is enabled, then a RD pulse from instruction IN A,BUS will latch controller
// onto the bus, but only if they are enabled correctly using port 2
if (kybrd_en)
{
_islag = false;
if ((kb_byte & 7) == 1)
{
return controller_state_1;
}
if ((kb_byte & 7) == 0)
{
return controller_state_2;
}
}
Console.WriteLine(cpu.TotalExecutedCycles);
// not sure what happens if this case is reached, probably whatever the last value on the bus is
return 0;
}
else if (port == 1)
if (port == 1)
{
// various control pins
return (byte)((ppu.lum_en ? 0x80 : 0) |
@ -113,12 +106,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
(cart_b1 ? 0x02 : 0) |
(cart_b0 ? 0x01 : 0));
}
else
{
// keyboard
_islag = false;
return kb_byte;
}
// keyboard
_islag = false;
return kb_byte;
}
public void WritePort(ushort port, byte value)
@ -175,7 +166,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
// keyboard
kb_byte = (byte)(value & 7);
KB_Scan();
KB_Scan();
}
}
}

View File

@ -1,5 +1,4 @@
using BizHawk.Emulation.Common;
using System;
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
@ -71,10 +70,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{
ticker++;
if ((ticker % 5) == 0)
if (ticker % 5 == 0)
{
ppu.tick();
if ((ticker % 10) == 0)
if (ticker % 10 == 0)
{
ppu.Audio_tick();
}

View File

@ -1,5 +1,4 @@
using System.IO;
using BizHawk.Common;
using BizHawk.Common;
namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
{

View File

@ -60,17 +60,10 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
_syncSettings = (O2SyncSettings)syncSettings ?? new O2SyncSettings();
_controllerDeck = new O2HawkControllerDeck("O2 Controller", "O2 Controller");
byte[] Bios = null;
Bios = comm.CoreFileProvider.GetFirmware("O2", "BIOS", true, "BIOS Not Found, Cannot Load");
ppu = new PPU();
if (Bios == null)
{
throw new MissingFirmwareException("Missing Odyssey2 Bios");
}
_bios = Bios;
_bios = comm.CoreFileProvider.GetFirmware("O2", "BIOS", true, "BIOS Not Found, Cannot Load")
?? throw new MissingFirmwareException("Missing Odyssey2 Bios");
Buffer.BlockCopy(rom, 0x100, header, 0, 0x50);
@ -92,7 +85,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
_syncSettings = (O2SyncSettings)syncSettings ?? new O2SyncSettings();
_tracer = new TraceBuffer { Header = cpu.TraceHeader };
ser.Register<ITraceable>(_tracer);
ser.Register(_tracer);
ser.Register<IStatable>(new StateSerializer(SyncState));
SetupMemoryDomains();
cpu.SetCallbacks(ReadMemory, PeekMemory, PeekMemory, WriteMemory);
@ -104,7 +97,7 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
pic_height = 288;
_frameHz = 50;
if ((game.Region == "US") || (game.Region == "EU-US") || (game.Region == null))
if (game.Region == "US" || game.Region == "EU-US" || game.Region == null)
{
is_pal = false;
pic_height = 240;
@ -113,7 +106,6 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
ppu.set_region(is_pal);
_vidbuffer = new int[372 * pic_height];
frame_buffer = new int[320 * pic_height];
}
@ -151,14 +143,16 @@ namespace BizHawk.Emulation.Cores.Consoles.O2Hawk
private void ExecFetch(ushort addr)
{
uint flags = (uint)(MemoryCallbackFlags.AccessRead);
uint flags = (uint)MemoryCallbackFlags.AccessRead;
MemoryCallbacks.CallMemoryCallbacks(addr, 0, flags, "System Bus");
}
private void Setup_Mapper()
{
mapper = new MapperDefault();
mapper.Core = this;
mapper = new MapperDefault
{
Core = this
};
}
}
}