F8: more bug hunting

This commit is contained in:
Asnivor 2019-04-26 17:51:45 +01:00
parent 74c6d33f16
commit 356039638a
4 changed files with 74 additions and 39 deletions

View File

@ -10,7 +10,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
public byte[] BIOS01 = new byte[1024];
public byte[] BIOS02 = new byte[1024];
public byte[] FrameBuffer = new byte[2048];
public byte[] FrameBuffer = new byte[0x2000];
public byte[] Cartridge = new byte[0x2000 - 0x800];
@ -31,6 +31,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
else if (addr < 0x2000)
{
// Cart
return 0;
return Cartridge[addr - 0x800];
}
else if (addr < 0x2000 + 2048)

View File

@ -1,4 +1,5 @@
using System;
using BizHawk.Common;
using BizHawk.Common.BufferExtensions;
using BizHawk.Emulation.Common;
@ -6,63 +7,91 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
{
public partial class ChannelF : IVideoProvider, IRegionable
{
public static readonly int[] FPalette =
{
Colors.ARGB(0x10, 0x10, 0x10), // Black
Colors.ARGB(0xFD, 0xFD, 0xFD), // White
Colors.ARGB(0xFF, 0x31, 0x53), // Red
Colors.ARGB(0x02, 0xCC, 0x5D), // Green
Colors.ARGB(0x4B, 0x3F, 0xF3), // Blue
Colors.ARGB(0xE0, 0xE0, 0xE0), // Gray
Colors.ARGB(0x91, 0xFF, 0xA6), // BGreen
Colors.ARGB(0xCE, 0xD0, 0xFF), // BBlue
};
public static readonly int[] CMap =
{
0, 1, 1, 1,
7, 4, 2, 3,
5, 4, 2, 3,
6, 4, 2, 3,
};
public int _frameHz = 60;
public int[] _vidbuffer = new int[102 * 58];
public int[] _vidbuffer = new int[108 * 64];
public int[] GetVideoBuffer()
{
int row;
int col;
int color;
int pal;
int colour;
int a = 0;
int pOff;
// rows
for (int y = 0; y < 64; y++)
{
pOff = ((FrameBuffer[(y * 128) + 125] & 0x3) & 0x02) | ((FrameBuffer[(y * 128) + 126] & 0x3) >> 1) << 2;
for (int x = a; x < a + 128; x++)
{
colour = pOff + (FrameBuffer[x | (y << 7)] & 0x03);
var yM = y * 64;
_vidbuffer[yM + x] = FPalette[CMap[colour]];
}
}
return _vidbuffer;
}
public int VirtualWidth => 102 * 2;
public int VirtualHeight => 58 * 2;
public int BufferWidth => 102;
public int BufferHeight => 58;
public int VirtualWidth => BufferWidth * 2;
public int VirtualHeight => BufferHeight * 2;
public int BufferWidth => 108; // 102
public int BufferHeight => 64; // 58
public int BackgroundColor => unchecked((int)0xFF000000);
public int VsyncNumerator => _frameHz;
public int VsyncDenominator => 1;
private int[] colors = { 0x101010, 0xFDFDFD, 0x5331FF, 0x5DCC02, 0xF33F4B, 0xE0E0E0, 0xA6FF91, 0xD0CEFF };
private int[] palette = {0,1,1,1, 7,2,4,3, 6,2,4,3, 5,2,4,3};
private int[] buffer = new int[8192];
int ARM = 0;
int X = 0;
int Y = 0;
int Color = 2;
private int row = 0;
private int col = 0;
private byte value = 0;
public void VID_PortIN(ushort port, byte val)
{
switch (port)
{
case 0: // ARM
val &= 0x60;
if (val == 0x40 && ARM == 0x60) // Strobed
case 0:
int o;
PortLatch[port] = val;
if ((val & 0x20) != 0)
{
// Write to display buffer
buffer[(Y << 7) + X] = Color;
o = (row * 128) + col;
FrameBuffer[o] = value;
}
ARM = val;
break;
case 1: // Set Color (bits 6 and 7)
Color = ((val ^ 0xFF) >> 6) & 3;
PortLatch[port] = val;
value = (byte)(((val ^ 0xFF) >> 6) & 0x03);
break;
case 4: // X coordinate, inverted (bits 0-6)
X = (val ^ 0xFF) & 0x7F;
PortLatch[2] = val;
col = (val | 0x80) ^ 0xFF;
break;
case 5: // Y coordinate, inverted (bits 0-5)
Y = (val ^ 0xFF) & 0x3F;
PortLatch[3] = val;
//sound TODO
row = (val | 0xC0) ^ 0xFF;
break;
}
}

View File

@ -107,7 +107,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
ALU_ClearFlags();
ALU_ADD8_FLAGSONLY_Func(dest, src);
ALU_SetFlags_SZ(tmp);
Regs[ALU0] = tmp;
ALU_SetFlags_SZ(ALU0);
if (c == 0 && ic == 0)
{
@ -229,7 +230,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
}
*/
public void ADDS_Func(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h)
public void ADDS_FuncX(ushort dest_l, ushort dest_h, ushort src_l, ushort src_h)
{
int Reg16_d = Regs[dest_l];
int Reg16_s = Regs[src_l];

View File

@ -307,9 +307,9 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
// test operand against status register
case OP_BT:
instr_pntr = 0;
if ((Regs[W] & cur_instr[instr_pntr++]) != 0)
{
instr_pntr = 0;
PopulateCURINSTR(
// L
ROMC_01,
@ -326,6 +326,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
}
else
{
instr_pntr = 0;
PopulateCURINSTR(
// S
ROMC_03_S,
@ -342,9 +343,9 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
// Branch based on ISARL
case OP_BR7:
instr_pntr = 0;
if ((Regs[ISAR] & 7) == 7)
{
instr_pntr = 0;
PopulateCURINSTR(
// S
ROMC_03_S, // DB/IO <- ((PC0)); PC0++
@ -359,6 +360,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
}
else
{
instr_pntr = 0;
PopulateCURINSTR(
// L
ROMC_01,
@ -376,9 +378,9 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
// PC0 <- PC0+n+1
case OP_BF:
instr_pntr = 0;
if ((Regs[W] & cur_instr[instr_pntr++]) != 0)
{
instr_pntr = 0;
PopulateCURINSTR(
// S
ROMC_03_S, // DB/IO <- ((PC0)); PC0++
@ -393,6 +395,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
}
else
{
instr_pntr = 0;
PopulateCURINSTR(
// L
ROMC_01,
@ -465,7 +468,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
// CYCLE LENGTH: L
case ROMC_01:
Read_Func(DB, PC0l, PC0h);
ADDS_Func(PC0l, PC0h, DB, ZERO);
RegPC0 += (ushort)((SByte) Regs[DB]);
break;
// The device whose DC0 address addresses a memory word within the address space of that device must place on the data bus the contents
@ -535,7 +538,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
// All devices add the 8-bit value on the data bus, treated as a signed binary number, to the data counter
// CYCLE LENGTH: L
case ROMC_0A:
ADDS_Func(DC0l, DC0h, DB, ZERO);
RegDC0 += (ushort) ((sbyte) Regs[DB]);
break;
// The device whose address space includes the value in PC1 must place the low order byte of PC1 on the data bus
@ -689,12 +692,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
public TraceInfo State(bool disassemble = true)
{
int bytes_read = 0;
string disasm = disassemble ? Disassemble(RegPC0, ReadMemory, out bytes_read) : "---";
ushort pc = (ushort)(RegPC0 - 1);
string disasm = disassemble ? Disassemble(pc, ReadMemory, out bytes_read) : "---";
string byte_code = null;
for (ushort i = 0; i < bytes_read; i++)
{
byte_code += ReadMemory((ushort)(RegPC0 + i)).ToHexString(2);
byte_code += ReadMemory((ushort)(pc + i)).ToHexString(2);
if (i < (bytes_read - 1))
{
byte_code += " ";
@ -705,7 +709,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
{
Disassembly = string.Format(
"{0:X4}: {1} {2}",
RegPC0,
pc,
byte_code.PadRight(12),
disasm.PadRight(26)),
RegisterInfo = string.Format(