ChannelF: more bugfixes and disam update
This commit is contained in:
parent
47a5ce2798
commit
038bab2bff
|
@ -605,13 +605,13 @@
|
|||
<Compile Include="Consoles\Fairchild\ChannelF\ChannelF.IVideoProvider.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\ChannelF.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\F8\F3850.Operations.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\F8\F3850.ALU.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\F8\F3850.Disassembler.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\F8\F3850.Tables.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\F8\F3850.Registers.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\F8\F3850.Execute.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\F8\F3850.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\Cart.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\Audio.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\Video.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\Ports.cs" />
|
||||
<Compile Include="Consoles\Fairchild\ChannelF\Memory.cs" />
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BizHawk.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio related functions
|
||||
/// </summary>
|
||||
public partial class ChannelF : ISoundProvider
|
||||
{
|
||||
private double SampleRate = 44100;
|
||||
private int SamplesPerFrame;
|
||||
private double Period;
|
||||
private double CyclesPerSample;
|
||||
|
||||
|
||||
private int tone = 0;
|
||||
|
||||
private double[] tone_freqs = new double[] { 0, 1000, 500, 120 };
|
||||
private double amplitude = 0;
|
||||
private double decay = 0.998;
|
||||
private double time = 0;
|
||||
private double cycles = 0;
|
||||
private int samplePos = 0;
|
||||
private int lastCycle = 0;
|
||||
|
||||
private BlipBuffer _blip;
|
||||
|
||||
private short[] SampleBuffer;
|
||||
|
||||
private void SetupAudio()
|
||||
{
|
||||
Period = (double)1 / SampleRate;
|
||||
SamplesPerFrame = (int)(SampleRate / refreshRate);
|
||||
CyclesPerSample = (double)ClockPerFrame / (double)SamplesPerFrame;
|
||||
SampleBuffer = new short[SamplesPerFrame];
|
||||
_blip = new BlipBuffer(SamplesPerFrame);
|
||||
_blip.SetRates(ClockPerFrame * refreshRate, SampleRate);
|
||||
}
|
||||
|
||||
private void AudioChange()
|
||||
{
|
||||
if (tone == 0)
|
||||
{
|
||||
// silence
|
||||
}
|
||||
else
|
||||
{
|
||||
int SamplesPerWave = (int)(SampleRate / tone_freqs[tone]);
|
||||
double RadPerSample = (Math.PI * 2) / (double) SamplesPerWave;
|
||||
double SinVal = 0;
|
||||
|
||||
int NumSamples = (int)(((double)FrameClock - (double)lastCycle) / CyclesPerSample);
|
||||
|
||||
int startPos = lastCycle;
|
||||
|
||||
for (int i = 0; i < NumSamples; i++)
|
||||
{
|
||||
SinVal = Math.Sin(RadPerSample * (double) (i * SamplesPerWave));
|
||||
_blip.AddDelta((uint)startPos, (int) (Math.Floor(SinVal * 127) + 128) * 1024);
|
||||
startPos += (int)CyclesPerSample;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanProvideAsync => false;
|
||||
|
||||
public SyncSoundMode SyncMode => SyncSoundMode.Sync;
|
||||
|
||||
public void SetSyncMode(SyncSoundMode mode)
|
||||
{
|
||||
if (mode != SyncSoundMode.Sync)
|
||||
throw new InvalidOperationException("Only Sync mode is supported.");
|
||||
}
|
||||
|
||||
public void GetSamplesAsync(short[] samples)
|
||||
{
|
||||
throw new NotSupportedException("Async is not available");
|
||||
}
|
||||
|
||||
public void DiscardSamples()
|
||||
{
|
||||
SampleBuffer = new short[SamplesPerFrame];
|
||||
samplePos = 0;
|
||||
lastCycle = 0;
|
||||
}
|
||||
|
||||
public void GetSamplesSync(out short[] samples, out int nsamp)
|
||||
{
|
||||
AudioChange();
|
||||
|
||||
_blip.EndFrame((uint)ClockPerFrame);
|
||||
nsamp = _blip.SamplesAvailable();
|
||||
samples = new short[nsamp * 2];
|
||||
_blip.ReadSamples(samples, nsamp, true);
|
||||
|
||||
for (int i = 0; i < nsamp * 2; i += 2)
|
||||
{
|
||||
samples[i + 1] = samples[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,7 +47,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
if (reg > 63)
|
||||
throw new InvalidOperationException();
|
||||
|
||||
CPU.Regs[reg] = (ushort) value;
|
||||
CPU.Regs[reg] = (byte) value;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -56,13 +56,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
default:
|
||||
throw new InvalidOperationException();
|
||||
case "A":
|
||||
CPU.Regs[CPU.A] = (ushort)value;
|
||||
CPU.Regs[CPU.A] = (byte)value;
|
||||
break;
|
||||
case "W":
|
||||
CPU.Regs[CPU.W] = (ushort)value;
|
||||
CPU.Regs[CPU.W] = (byte)value;
|
||||
break;
|
||||
case "ISAR":
|
||||
CPU.Regs[CPU.ISAR] = (ushort)(value & 0x3F);
|
||||
CPU.Regs[CPU.ISAR] = (byte)(value & 0x3F);
|
||||
break;
|
||||
case "PC0":
|
||||
CPU.RegPC0 = (ushort)value;
|
||||
|
@ -74,25 +74,25 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
CPU.RegDC0 = (ushort)value;
|
||||
break;
|
||||
case "DB":
|
||||
CPU.Regs[CPU.DB] = (ushort)value;
|
||||
CPU.Regs[CPU.DB] = (byte)value;
|
||||
break;
|
||||
case "IO":
|
||||
CPU.Regs[CPU.IO] = (ushort)value;
|
||||
CPU.Regs[CPU.IO] = (byte)value;
|
||||
break;
|
||||
case "J":
|
||||
CPU.Regs[CPU.J] = (ushort)value;
|
||||
CPU.Regs[CPU.J] = (byte)value;
|
||||
break;
|
||||
case "H":
|
||||
CPU.Regs[CPU.Hl] = (ushort)(value & 0xFF);
|
||||
CPU.Regs[CPU.Hh] = (ushort)(value & 0xFF00);
|
||||
CPU.Regs[CPU.Hl] = (byte)(value & 0xFF);
|
||||
CPU.Regs[CPU.Hh] = (byte)(value & 0xFF00);
|
||||
break;
|
||||
case "K":
|
||||
CPU.Regs[CPU.Kl] = (ushort)(value & 0xFF);
|
||||
CPU.Regs[CPU.Kh] = (ushort)(value & 0xFF00);
|
||||
CPU.Regs[CPU.Kl] = (byte)(value & 0xFF);
|
||||
CPU.Regs[CPU.Kh] = (byte)(value & 0xFF00);
|
||||
break;
|
||||
case "Q":
|
||||
CPU.Regs[CPU.Ql] = (ushort)(value & 0xFF);
|
||||
CPU.Regs[CPU.Qh] = (ushort)(value & 0xFF00);
|
||||
CPU.Regs[CPU.Ql] = (byte)(value & 0xFF);
|
||||
CPU.Regs[CPU.Qh] = (byte)(value & 0xFF00);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
|
||||
private void CalcClock()
|
||||
{
|
||||
var c = ((cpuFreq * 1000000) / refreshRate) * 4;
|
||||
var c = ((cpuFreq * 1000000) / refreshRate);
|
||||
ClockPerFrame = (int) c;
|
||||
|
||||
SetupAudio();
|
||||
}
|
||||
|
||||
public bool FrameAdvance(IController controller, bool render, bool renderSound)
|
||||
|
|
|
@ -9,14 +9,14 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
{
|
||||
public int _frameHz = 60;
|
||||
|
||||
public int[] CroppedBuffer = new int[(128*64) * 2]; //new int[102 * 58];
|
||||
public int[] CroppedBuffer = new int[102 * 58];
|
||||
|
||||
#region IVideoProvider
|
||||
|
||||
public int VirtualWidth => BufferWidth * 2;
|
||||
public int VirtualHeight => (int)((double)BufferHeight * 1.5) * 2;
|
||||
public int BufferWidth => 128;// 102;
|
||||
public int BufferHeight => 64; // 58;
|
||||
public int VirtualHeight => (int)((double)BufferHeight * 1.3) * 2;
|
||||
public int BufferWidth => 102; //128
|
||||
public int BufferHeight => 58; //64
|
||||
public int BackgroundColor => Colors.ARGB(0x00, 0x00, 0x00);
|
||||
public int VsyncNumerator => _frameHz;
|
||||
public int VsyncDenominator => 1;
|
||||
|
@ -24,41 +24,32 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public int[] GetVideoBuffer()
|
||||
{
|
||||
BuildFrame();
|
||||
/*
|
||||
for (int i = 0; i < frameBuffer.Length; i++)
|
||||
|
||||
var lBorderWidth = 4;
|
||||
var rBorderWidth = 128 - 102 - lBorderWidth;
|
||||
var tBorderHeight = 4;
|
||||
var bBorderHeight = 64 - 58 - tBorderHeight;
|
||||
var startP = 128 * tBorderHeight;
|
||||
var endP = 128 * bBorderHeight;
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (int i = startP; i < frameBuffer.Length - endP; i += 128)
|
||||
{
|
||||
CroppedBuffer[i] = frameBuffer[i];
|
||||
CroppedBuffer[i + frameBuffer.Length] = frameBuffer[i];
|
||||
}
|
||||
|
||||
return CroppedBuffer;
|
||||
*/
|
||||
return frameBuffer;
|
||||
|
||||
// crop to visible area
|
||||
var lR = 4;
|
||||
var rR = 128 - BufferWidth - lR;
|
||||
var tR = 4;
|
||||
var bR = 64 - BufferHeight - tR;
|
||||
var sW = 128 - lR - rR;
|
||||
var startP = 128 * tR;
|
||||
var endP = 128 * bR;
|
||||
|
||||
int index2 = 0;
|
||||
|
||||
// line by line
|
||||
for (int i = startP; i < CroppedBuffer.Length - endP; i += sW + lR + rR)
|
||||
{
|
||||
// each pixel in each line
|
||||
for (int p = lR; p < sW + lR + rR - rR; p++)
|
||||
for (int p = lBorderWidth; p < 128 - rBorderWidth; p++)
|
||||
{
|
||||
if (index2 == CroppedBuffer.Length)
|
||||
if (index == CroppedBuffer.Length)
|
||||
break;
|
||||
CroppedBuffer[index2++] = frameBuffer[i + p];
|
||||
|
||||
CroppedBuffer[index++] = FPalette[frameBuffer[i + p]];
|
||||
}
|
||||
}
|
||||
|
||||
return CroppedBuffer;
|
||||
|
||||
//return frameBuffer;
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
ser.Register<IVideoProvider>(this);
|
||||
ser.Register<ITraceable>(_tracer);
|
||||
ser.Register<IDisassemblable>(CPU);
|
||||
ser.Register<ISoundProvider>(this);
|
||||
|
||||
SetupMemoryDomains();
|
||||
}
|
||||
|
|
|
@ -1,235 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BizHawk.Common.NumberExtensions;
|
||||
|
||||
namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
||||
{
|
||||
/// <summary>
|
||||
/// ALU Operations
|
||||
/// The arithmetic and logic unit provides all data manipulating logic for the F3850.
|
||||
/// It contains logic that operates on a single 8-bit source data work or combines two 8-bit words of source data
|
||||
/// to generate a single 8-bit result. Additional information is reported in status flags, where appropriate.
|
||||
///
|
||||
/// Operations Performed:
|
||||
/// * Addition
|
||||
/// * Compare
|
||||
/// * AND
|
||||
/// * OR
|
||||
/// * XOR
|
||||
/// </summary>
|
||||
public sealed partial class F3850
|
||||
{
|
||||
/// <summary>
|
||||
/// Clears all status flags (excluding the ICB flag)
|
||||
/// </summary>
|
||||
public void ALU_ClearFlags_()
|
||||
{
|
||||
FlagC = false;
|
||||
FlagO = false;
|
||||
FlagS = false;
|
||||
FlagZ = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the SIGN and ZERO flags based on the supplied byte
|
||||
/// </summary>
|
||||
/// <param name="val"></param>
|
||||
public void ALU_SetFlags_SZ_(ushort src)
|
||||
{
|
||||
FlagZ = (byte)Regs[src] == 0;
|
||||
FlagS = (~((byte)Regs[src]) & 0x80) != 0;
|
||||
}
|
||||
/*
|
||||
/// <summary>
|
||||
/// Performs addition and sets the CARRY and OVERFLOW flags accordingly
|
||||
/// </summary>
|
||||
/// <param name="dest"></param>
|
||||
/// <param name="src"></param>
|
||||
/// <param name="carry"></param>
|
||||
public void ALU_ADD8_Func_(ushort dest, ushort src, bool carry = false)
|
||||
{
|
||||
byte d = (byte)Regs[dest];
|
||||
byte s = (byte)Regs[src];
|
||||
byte c = carry ? (byte)1 : (byte)0;
|
||||
ushort result = (ushort)(d + s + c);
|
||||
|
||||
FlagC = (result & 0x100) != 0;
|
||||
FlagO = ((d ^ result) & (s ^ result) & 0x80) != 0;
|
||||
|
||||
Regs[dest] = (ushort)(result & 0xFF);
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Performs addition and sets the CARRY and OVERFLOW flags accordingly WITHOUT saving to destination
|
||||
/// </summary>
|
||||
/// <param name="dest"></param>
|
||||
/// <param name="src"></param>
|
||||
/// <param name="carry"></param>
|
||||
public void ALU_ADD8_FLAGSONLY_Func(ushort dest, ushort src)
|
||||
{
|
||||
byte d = (byte)Regs[dest];
|
||||
byte s = (byte)Regs[src];
|
||||
ushort result = (ushort)(d + s);
|
||||
|
||||
FlagC = (result & 0x100) != 0;
|
||||
FlagO = ((d ^ result) & (s ^ result) & 0x80) != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs decimal addition based on the two supplied bytes
|
||||
/// (looks like this is only used in the AMD operation)
|
||||
/// </summary>
|
||||
/// <param name="dest"></param>
|
||||
/// <param name="src"></param>
|
||||
|
||||
|
||||
public void ALU_SUB8_Func(ushort dest, ushort src)
|
||||
{
|
||||
byte d = (byte)Regs[dest];
|
||||
byte s = (byte)Regs[src];
|
||||
ushort result = (ushort)(d - s);
|
||||
|
||||
FlagC = (result & 0x100) != 0;
|
||||
FlagO = ((d ^ result) & (s ^ result) & 0x80) != 0;
|
||||
|
||||
int Reg16_d = Regs[dest];
|
||||
Reg16_d -= Regs[src];
|
||||
|
||||
FlagC = Reg16_d.Bit(8);
|
||||
FlagZ = (Reg16_d & 0xFF) == 0;
|
||||
|
||||
ushort ans = (ushort)(Reg16_d & 0xFF);
|
||||
|
||||
FlagO = (Regs[dest].Bit(7) != Regs[src].Bit(7)) && (Regs[dest].Bit(7) != ans.Bit(7));
|
||||
FlagS = ans > 127;
|
||||
|
||||
Regs[dest] = ans;
|
||||
}
|
||||
|
||||
/*
|
||||
public void ALU_SUB8_Func(ushort dest, ushort src)
|
||||
{
|
||||
int Reg16_d = Regs[dest];
|
||||
Reg16_d -= Regs[src];
|
||||
|
||||
FlagC = Reg16_d.Bit(8);
|
||||
FlagZ = (Reg16_d & 0xFF) == 0;
|
||||
|
||||
ushort ans = (ushort)(Reg16_d & 0xFF);
|
||||
|
||||
FlagO = (Regs[dest].Bit(7) != Regs[src].Bit(7)) && (Regs[dest].Bit(7) != ans.Bit(7));
|
||||
FlagS = ans > 127;
|
||||
|
||||
Regs[dest] = ans;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// AND
|
||||
/// </summary>
|
||||
/// <param name="dest"></param>
|
||||
/// <param name="src"></param>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
public void ALU_XOR8C_Func(ushort dest, ushort src)
|
||||
{
|
||||
// TODO
|
||||
Regs[dest] = (ushort)(Regs[dest] ^ Regs[src]);
|
||||
FlagZ = Regs[dest] == 0;
|
||||
FlagC = false;
|
||||
FlagO = false;
|
||||
FlagS = Regs[dest] > 127;
|
||||
}
|
||||
*/
|
||||
|
||||
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];
|
||||
|
||||
Reg16_d += Reg16_s;
|
||||
|
||||
ushort temp = 0;
|
||||
|
||||
// since this is signed addition, calculate the high byte carry appropriately
|
||||
// note that flags are unaffected by this operation
|
||||
if (Reg16_s.Bit(7))
|
||||
{
|
||||
if (((Reg16_d & 0xFF) >= Regs[dest_l]))
|
||||
{
|
||||
temp = 0xFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = (ushort)(Reg16_d.Bit(8) ? 1 : 0);
|
||||
}
|
||||
|
||||
ushort ans_l = (ushort)(Reg16_d & 0xFF);
|
||||
|
||||
Regs[dest_l] = ans_l;
|
||||
Regs[dest_h] += temp;
|
||||
Regs[dest_h] &= 0xFF;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void LR8_Func(ushort dest, ushort src)
|
||||
{
|
||||
if (dest == DB)
|
||||
{
|
||||
// byte storage
|
||||
Regs[dest] = (ushort)(Regs[src] & 0xFF);
|
||||
}
|
||||
else if (dest == W)
|
||||
{
|
||||
// mask for status register
|
||||
Regs[dest] = (ushort)(Regs[src] & 0x1F);
|
||||
}
|
||||
else if (dest == ISAR)
|
||||
{
|
||||
// mask for ISAR register
|
||||
Regs[dest] = (ushort)(Regs[src] & 0x3F);
|
||||
}
|
||||
else
|
||||
{
|
||||
Regs[dest] = Regs[src];
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public void ALU_INC8_Func(ushort src)
|
||||
{
|
||||
int Reg16_d = Regs[src];
|
||||
Reg16_d += 1;
|
||||
|
||||
FlagC = Reg16_d.Bit(8);
|
||||
FlagZ = (Reg16_d & 0xFF) == 0;
|
||||
|
||||
ushort ans = (ushort)(Reg16_d & 0xFF);
|
||||
|
||||
Regs[src] = ans;
|
||||
|
||||
FlagS = Regs[src].Bit(7);
|
||||
FlagO = Regs[src] == 0x80;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -169,14 +169,14 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
"LIS D", // 0x7D
|
||||
"LIS E", // 0x7E
|
||||
"LIS F", // 0x7F
|
||||
"BT 0", // 0x80
|
||||
"BT 1", // 0x81
|
||||
"BT 2", // 0x82
|
||||
"BT 3", // 0x83
|
||||
"BT 4", // 0x84
|
||||
"BT 5", // 0x85
|
||||
"BT 6", // 0x86
|
||||
"BT 7", // 0x87
|
||||
"BT NOBRANCH", // 0x80
|
||||
"BP d", // 0x81
|
||||
"BC d", // 0x82
|
||||
"BP or C d", // 0x83
|
||||
"BZ d", // 0x84
|
||||
"BP d", // 0x85
|
||||
"BZ or C d", // 0x86
|
||||
"BP or C d", // 0x87
|
||||
"AM", // 0x88
|
||||
"AMD", // 0x89
|
||||
"NM", // 0x8A
|
||||
|
@ -185,22 +185,22 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
"CM", // 0x8D
|
||||
"ADC", // 0x8E
|
||||
"BR7 n", // 0x8F
|
||||
"BF 0x0 n", // 0x90
|
||||
"BF 0x1 n", // 0x91
|
||||
"BF 0x2 n", // 0x92
|
||||
"BF 0x3 n", // 0x93
|
||||
"BF 0x4 n", // 0x94
|
||||
"BF 0x5 n", // 0x95
|
||||
"BF 0x6 n", // 0x96
|
||||
"BF 0x7 n", // 0x97
|
||||
"BF 0x8 n", // 0x98
|
||||
"BF 0x9 n", // 0x99
|
||||
"BF 0xA n", // 0x9A
|
||||
"BF 0xB n", // 0x9B
|
||||
"BF 0xC n", // 0x9C
|
||||
"BF 0xD n", // 0x9D
|
||||
"BF 0xE n", // 0x9E
|
||||
"BF 0xF n", // 0x9F
|
||||
"BF UNCON d", // 0x90
|
||||
"BN d", // 0x91
|
||||
"BNC d", // 0x92
|
||||
"BNC & deg d", // 0x93
|
||||
"BNZ d", // 0x94
|
||||
"BN d", // 0x95
|
||||
"BNC & dZ d", // 0x96
|
||||
"BNC & deg d", // 0x97
|
||||
"BNO d", // 0x98
|
||||
"BN & dO d", // 0x99
|
||||
"BNO & dC d", // 0x9A
|
||||
"BNO & dC & deg d", // 0x9B
|
||||
"BNO & dZ d", // 0x9C
|
||||
"BN & dO d", // 0x9D
|
||||
"BNO & dC & dZ d", // 0x9E
|
||||
"BNO & dC & deg d", // 0x9F
|
||||
"INS 0", // 0xA0
|
||||
"INS 1", // 0xA1
|
||||
"ILLEGAL", // 0xA2
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public long TotalExecutedCycles;
|
||||
|
||||
public int instr_pntr = 0;
|
||||
public ushort[] cur_instr = new ushort[MaxInstructionLength]; // fixed size - do not change at runtime
|
||||
public ushort[] cur_romc = new ushort[MaxInstructionLength]; // fixed size - do not change at runtime
|
||||
public byte[] cur_instr = new byte[MaxInstructionLength]; // fixed size - do not change at runtime
|
||||
public byte[] cur_romc = new byte[MaxInstructionLength]; // fixed size - do not change at runtime
|
||||
public byte opcode;
|
||||
|
||||
public void FetchInstruction()
|
||||
|
|
|
@ -12,22 +12,22 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
/// </summary>
|
||||
public sealed partial class F3850
|
||||
{
|
||||
public void Read_Func(ushort dest, ushort src_l, ushort src_h)
|
||||
public void Read_Func(byte dest, byte src_l, byte src_h)
|
||||
{
|
||||
Regs[dest] = ReadMemory((ushort)(Regs[src_l] | (Regs[src_h]) << 8));
|
||||
}
|
||||
|
||||
public void Write_Func(ushort dest_l, ushort dest_h, ushort src)
|
||||
public void Write_Func(byte dest_l, byte dest_h, byte src)
|
||||
{
|
||||
WriteMemory((ushort)(Regs[dest_l] | (Regs[dest_h] << 8)), (byte)Regs[src]);
|
||||
WriteMemory((ushort)(Regs[dest_l] | (Regs[dest_h] << 8)), Regs[src]);
|
||||
}
|
||||
|
||||
public void IN_Func(ushort dest, ushort src)
|
||||
public void IN_Func(byte dest, byte src)
|
||||
{
|
||||
Regs[dest] = ReadHardware(Regs[src]);
|
||||
}
|
||||
|
||||
public void LR_A_IO_Func(ushort dest, ushort src)
|
||||
public void LR_A_IO_Func(byte dest, byte src)
|
||||
{
|
||||
// helper method that simulates transferring DB to accumulator (as part of an IN operation)
|
||||
// this sets flags accordingly
|
||||
|
@ -55,22 +55,22 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
FlagZ = false;
|
||||
}
|
||||
|
||||
public void LR_Func(ushort dest, ushort src)
|
||||
public void LR_Func(byte dest, byte src)
|
||||
{
|
||||
if (dest == DB)
|
||||
{
|
||||
// byte storage
|
||||
Regs[dest] = (ushort)(Regs[src] & 0xFF);
|
||||
Regs[dest] = (byte)(Regs[src] & 0xFF);
|
||||
}
|
||||
else if (dest == W)
|
||||
{
|
||||
// mask for status register
|
||||
Regs[dest] = (ushort)(Regs[src] & 0x1F);
|
||||
Regs[dest] = (byte)(Regs[src] & 0x1F);
|
||||
}
|
||||
else if (dest == ISAR)
|
||||
{
|
||||
// mask for ISAR register
|
||||
Regs[dest] = (ushort)(Regs[src] & 0x3F);
|
||||
Regs[dest] = (byte)(Regs[src] & 0x3F);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -83,13 +83,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
/// </summary>
|
||||
/// <param name="src"></param>
|
||||
/// <param name="shift"></param>
|
||||
public void SR_Func(ushort src, ushort shift)
|
||||
public void SR_Func(byte src, byte shift)
|
||||
{
|
||||
// overflow and carry unconditionally reset
|
||||
FlagO = false;
|
||||
FlagC = false;
|
||||
|
||||
Regs[src] = (ushort)((Regs[src] >> shift) & 0xFF);
|
||||
Regs[src] = (byte)((Regs[src] >> shift) & 0xFF);
|
||||
|
||||
FlagZ = Regs[src] == 0;
|
||||
|
||||
|
@ -104,13 +104,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
/// </summary>
|
||||
/// <param name="src"></param>
|
||||
/// <param name="shift"></param>
|
||||
public void SL_Func(ushort src, ushort shift)
|
||||
public void SL_Func(byte src, byte shift)
|
||||
{
|
||||
// overflow and carry unconditionally reset
|
||||
FlagO = false;
|
||||
FlagC = false;
|
||||
|
||||
Regs[src] = (ushort)((Regs[src] << shift) & 0xFF);
|
||||
Regs[src] = (byte)((Regs[src] << shift) & 0xFF);
|
||||
|
||||
FlagZ = Regs[src] == 0;
|
||||
|
||||
|
@ -120,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
// ICB flag not affected
|
||||
}
|
||||
|
||||
public void ADD_Func(ushort dest, ushort src)
|
||||
public void ADD_Func_(byte dest, byte src)
|
||||
{
|
||||
// addition of 2 signed bytes
|
||||
ushort dest16 = Regs[dest];
|
||||
|
@ -140,16 +140,32 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
var b7c = dest16 >> 8;
|
||||
FlagO = (b6c ^ b7c) != 0;
|
||||
|
||||
Regs[dest] = ans;
|
||||
Regs[dest] = (byte)ans;
|
||||
}
|
||||
|
||||
public void SUB_Func(ushort dest, ushort src)
|
||||
public void ADD_Func(byte dest, byte src)
|
||||
{
|
||||
Regs[ALU0] = (ushort)((Regs[src] ^ 0xff) + 1);
|
||||
// addition of 2 signed bytes
|
||||
var sD = Regs[dest] & 0x80;
|
||||
var sS = Regs[src] & 0x80;
|
||||
var res = Regs[dest] + Regs[src];
|
||||
var sR = res & 0x80;
|
||||
|
||||
FlagS = !((res & 0x80) > 0);
|
||||
FlagZ = (res & 0xff) == 0;
|
||||
FlagO = (sD == sS && sD != sR);
|
||||
FlagC = (res & 0x100) > 0;
|
||||
|
||||
Regs[dest] = (byte) (res & 0xff);
|
||||
}
|
||||
|
||||
public void SUB_Func(byte dest, byte src)
|
||||
{
|
||||
Regs[ALU0] = (byte)((Regs[src] ^ 0xff) + 1);
|
||||
ADD_Func(dest, ALU0);
|
||||
}
|
||||
|
||||
public void ADDD_Func(ushort dest, ushort src)
|
||||
public void ADDD_Func(byte dest, byte src)
|
||||
{
|
||||
var d = Regs[dest];
|
||||
var s = Regs[src];
|
||||
|
@ -173,7 +189,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
bcdRes = (bcdRes + 0xA0);
|
||||
}
|
||||
|
||||
Regs[dest] = (ushort)(bcdRes & 0xFF);
|
||||
Regs[dest] = (byte)(bcdRes & 0xFF);
|
||||
}
|
||||
|
||||
public void CI_Func()
|
||||
|
@ -182,10 +198,11 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
// we need to achieve DB - A + 1
|
||||
// flags set - results not stored
|
||||
var comp = ((Regs[A] ^ 0xFF) + 1);
|
||||
Regs[ALU0] = (ushort)comp;
|
||||
ADD_Func(DB, ALU0);
|
||||
Regs[ALU0] = (byte)comp;
|
||||
Regs[ALU1] = Regs[DB];
|
||||
ADD_Func(ALU1, ALU0);
|
||||
}
|
||||
|
||||
/*
|
||||
public void ADDD_Func_(ushort dest, ushort src)
|
||||
{
|
||||
// from MAME f8.cpp (BSD-3)
|
||||
|
@ -229,14 +246,15 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
|
||||
Regs[dest] = tmp;
|
||||
}
|
||||
*/
|
||||
|
||||
public void AND_Func(ushort dest, ushort src)
|
||||
public void AND_Func(byte dest, byte src)
|
||||
{
|
||||
// overflow and carry unconditionally reset
|
||||
FlagO = false;
|
||||
FlagC = false;
|
||||
|
||||
Regs[dest] = (ushort)(Regs[dest] & Regs[src]);
|
||||
Regs[dest] = (byte)(Regs[dest] & Regs[src]);
|
||||
|
||||
FlagZ = Regs[src] == 0;
|
||||
|
||||
|
@ -246,13 +264,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
// ICB flag not affected
|
||||
}
|
||||
|
||||
public void OR_Func(ushort dest, ushort src)
|
||||
public void OR_Func(byte dest, byte src)
|
||||
{
|
||||
// overflow and carry unconditionally reset
|
||||
FlagO = false;
|
||||
FlagC = false;
|
||||
|
||||
Regs[dest] = (ushort)(Regs[dest] | Regs[src]);
|
||||
Regs[dest] = (byte)(Regs[dest] | Regs[src]);
|
||||
|
||||
FlagZ = Regs[src] == 0;
|
||||
|
||||
|
@ -262,13 +280,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
// ICB flag not affected
|
||||
}
|
||||
|
||||
public void XOR_Func(ushort dest, ushort src)
|
||||
public void XOR_Func(byte dest, byte src)
|
||||
{
|
||||
// overflow and carry unconditionally reset
|
||||
FlagO = false;
|
||||
FlagC = false;
|
||||
|
||||
Regs[dest] = (ushort)(Regs[dest] ^ Regs[src]);
|
||||
Regs[dest] = (byte)(Regs[dest] ^ Regs[src]);
|
||||
|
||||
FlagZ = Regs[src] == 0;
|
||||
|
||||
|
|
|
@ -17,83 +17,83 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
/// <summary>
|
||||
/// Registers (counters and scratchpad)
|
||||
/// </summary>
|
||||
public ushort[] Regs = new ushort[100];
|
||||
public byte[] Regs = new byte[100];
|
||||
|
||||
// scratchpad registers live in Regs 0-64
|
||||
public ushort J = 9;
|
||||
public ushort Hh = 10;
|
||||
public ushort Hl = 11;
|
||||
public ushort Kh = 12;
|
||||
public ushort Kl = 13;
|
||||
public ushort Qh = 14;
|
||||
public ushort Ql = 15;
|
||||
public byte J = 9;
|
||||
public byte Hh = 10;
|
||||
public byte Hl = 11;
|
||||
public byte Kh = 12;
|
||||
public byte Kl = 13;
|
||||
public byte Qh = 14;
|
||||
public byte Ql = 15;
|
||||
|
||||
// Internal CPU counters kept after the scratchpad for ease of implementation
|
||||
/// <summary>
|
||||
/// Accumulator
|
||||
/// </summary>
|
||||
public ushort A = 65;
|
||||
public byte A = 65;
|
||||
/// <summary>
|
||||
/// Status Register
|
||||
/// </summary>
|
||||
public ushort W = 66;
|
||||
public byte W = 66;
|
||||
/// <summary>
|
||||
/// Indirect Scratchpad Address Register
|
||||
/// (6bit)
|
||||
/// </summary>
|
||||
public ushort ISAR = 67;
|
||||
public byte ISAR = 67;
|
||||
/// <summary>
|
||||
/// Primary Program Counter (high byte)
|
||||
/// </summary>
|
||||
public ushort PC0h = 68;
|
||||
public byte PC0h = 68;
|
||||
/// <summary>
|
||||
/// Primary Program Counter (low byte)
|
||||
/// </summary>
|
||||
public ushort PC0l = 69;
|
||||
public byte PC0l = 69;
|
||||
/// <summary>
|
||||
/// Backup Program Counter (high byte)
|
||||
/// </summary>
|
||||
public ushort PC1h = 70;
|
||||
public byte PC1h = 70;
|
||||
/// <summary>
|
||||
/// Backup Program Counter (low byte)
|
||||
/// </summary>
|
||||
public ushort PC1l = 71;
|
||||
public byte PC1l = 71;
|
||||
/// <summary>
|
||||
/// Data counter (high byte)
|
||||
/// </summary>
|
||||
public ushort DC0h = 72;
|
||||
public byte DC0h = 72;
|
||||
/// <summary>
|
||||
/// Data Counter (low byte)
|
||||
/// </summary>
|
||||
public ushort DC0l = 73;
|
||||
public byte DC0l = 73;
|
||||
/// <summary>
|
||||
/// Temporary Arithmetic Storage
|
||||
/// </summary>
|
||||
public ushort ALU0 = 74;
|
||||
public byte ALU0 = 74;
|
||||
/// <summary>
|
||||
/// Temporary Arithmetic Storage
|
||||
/// </summary>
|
||||
public ushort ALU1 = 75;
|
||||
public byte ALU1 = 75;
|
||||
/// <summary>
|
||||
/// Data Bus
|
||||
/// </summary>
|
||||
public ushort DB = 76;
|
||||
public byte DB = 76;
|
||||
/// <summary>
|
||||
/// IO Bus/Latch
|
||||
/// </summary>
|
||||
public ushort IO = 77;
|
||||
public byte IO = 77;
|
||||
/// <summary>
|
||||
/// 0x00 value for arithmetic ops
|
||||
/// </summary>
|
||||
public ushort ZERO = 78;
|
||||
public byte ZERO = 78;
|
||||
/// <summary>
|
||||
/// 0x01 value for arithmetic ops
|
||||
/// </summary>
|
||||
public ushort ONE = 79;
|
||||
public byte ONE = 79;
|
||||
/// <summary>
|
||||
/// 0xFF value for arithmetic ops
|
||||
/// </summary>
|
||||
public ushort BYTE = 80;
|
||||
public byte BYTE = 80;
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -102,7 +102,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public bool FlagS
|
||||
{
|
||||
get { return (Regs[W] & 0x01) != 0; }
|
||||
set { Regs[W] = (ushort)((Regs[W] & ~0x01) | (value ? 0x01 : 0x00)); }
|
||||
set { Regs[W] = (byte)((Regs[W] & ~0x01) | (value ? 0x01 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -111,7 +111,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public bool FlagC
|
||||
{
|
||||
get { return (Regs[W] & 0x02) != 0; }
|
||||
set { Regs[W] = (ushort)((Regs[W] & ~0x02) | (value ? 0x02 : 0x00)); }
|
||||
set { Regs[W] = (byte)((Regs[W] & ~0x02) | (value ? 0x02 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -120,7 +120,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public bool FlagZ
|
||||
{
|
||||
get { return (Regs[W] & 0x04) != 0; }
|
||||
set { Regs[W] = (ushort)((Regs[W] & ~0x04) | (value ? 0x04 : 0x00)); }
|
||||
set { Regs[W] = (byte)((Regs[W] & ~0x04) | (value ? 0x04 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -129,7 +129,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public bool FlagO
|
||||
{
|
||||
get { return (Regs[W] & 0x08) != 0; }
|
||||
set { Regs[W] = (ushort)((Regs[W] & ~0x08) | (value ? 0x08 : 0x00)); }
|
||||
set { Regs[W] = (byte)((Regs[W] & ~0x08) | (value ? 0x08 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -138,7 +138,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public bool FlagICB
|
||||
{
|
||||
get { return (Regs[W] & 0x10) != 0; }
|
||||
set { Regs[W] = (ushort)((Regs[W] & ~0x10) | (value ? 0x10 : 0x00)); }
|
||||
set { Regs[W] = (byte)((Regs[W] & ~0x10) | (value ? 0x10 : 0x00)); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -149,8 +149,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
get { return (ushort)(Regs[PC0l] | (Regs[PC0h] << 8)); }
|
||||
set
|
||||
{
|
||||
Regs[PC0l] = (ushort)(value & 0xFF);
|
||||
Regs[PC0h] = (ushort)((value >> 8) & 0xFF);
|
||||
Regs[PC0l] = (byte)(value & 0xFF);
|
||||
Regs[PC0h] = (byte)((value >> 8) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
get { return (ushort)(Regs[PC1l] | (Regs[PC1h] << 8)); }
|
||||
set
|
||||
{
|
||||
Regs[PC1l] = (ushort)(value & 0xFF);
|
||||
Regs[PC1h] = (ushort)((value >> 8) & 0xFF);
|
||||
Regs[PC1l] = (byte)(value & 0xFF);
|
||||
Regs[PC1h] = (byte)((value >> 8) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,8 +175,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
get { return (ushort)(Regs[DC0l] | (Regs[DC0h] << 8)); }
|
||||
set
|
||||
{
|
||||
Regs[DC0l] = (ushort)(value & 0xFF);
|
||||
Regs[DC0h] = (ushort)((value >> 8) & 0xFF);
|
||||
Regs[DC0l] = (byte)(value & 0xFF);
|
||||
Regs[DC0h] = (byte)((value >> 8) & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void SHIFT_R(ushort index)
|
||||
private void SHIFT_R(byte index)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -316,7 +316,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void SHIFT_L(ushort index)
|
||||
private void SHIFT_L(byte index)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -748,10 +748,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void DS(ushort rIndex)
|
||||
private void DS(byte rIndex)
|
||||
{
|
||||
// only scratch registers 0-16
|
||||
rIndex = (ushort)(rIndex & 0x0F);
|
||||
rIndex = (byte)(rIndex & 0x0F);
|
||||
|
||||
PopulateCURINSTR(
|
||||
// L
|
||||
|
@ -799,10 +799,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void LR_A_R(ushort rIndex)
|
||||
private void LR_A_R(byte rIndex)
|
||||
{
|
||||
// only scratch registers 0-16
|
||||
rIndex = (ushort)(rIndex & 0x0F);
|
||||
rIndex = (byte)(rIndex & 0x0F);
|
||||
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -842,10 +842,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void LR_R_A(ushort rIndex)
|
||||
private void LR_R_A(byte rIndex)
|
||||
{
|
||||
// only scratch registers 0-16
|
||||
rIndex = (ushort)(rIndex & 0x0F);
|
||||
rIndex = (byte)(rIndex & 0x0F);
|
||||
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -885,7 +885,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void LISU(ushort octal)
|
||||
private void LISU(byte octal)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -895,7 +895,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void LISL(ushort octal)
|
||||
private void LISL(byte octal)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -905,7 +905,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void LIS(ushort index)
|
||||
private void LIS(byte index)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -915,7 +915,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void BT(ushort index)
|
||||
private void BT(byte index)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -1050,7 +1050,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
OP_BR7); // no END as there is branching logic within OP_BR7
|
||||
}
|
||||
|
||||
private void BF(ushort index)
|
||||
private void BF(byte index)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -1060,7 +1060,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
OP_BF, index); // no END as there is branching logic within OP_BF
|
||||
}
|
||||
|
||||
private void INS_0(ushort index)
|
||||
private void INS_0(byte index)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -1075,7 +1075,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void INS_1(ushort index)
|
||||
private void INS_1(byte index)
|
||||
{
|
||||
Regs[IO] = index; // latch port index early
|
||||
|
||||
|
@ -1101,7 +1101,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void OUTS_0(ushort index)
|
||||
private void OUTS_0(byte index)
|
||||
{
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -1116,7 +1116,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void OUTS_1(ushort index)
|
||||
private void OUTS_1(byte index)
|
||||
{
|
||||
Regs[IO] = index; // latch port index early
|
||||
|
||||
|
@ -1142,10 +1142,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void AS(ushort rIndex)
|
||||
private void AS(byte rIndex)
|
||||
{
|
||||
// only scratch registers 0-15
|
||||
rIndex = (ushort) (rIndex & 0x0F);
|
||||
rIndex = (byte) (rIndex & 0x0F);
|
||||
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -1188,10 +1188,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void ASD(ushort rIndex)
|
||||
private void ASD(byte rIndex)
|
||||
{
|
||||
// only scratch registers 0-15
|
||||
rIndex = (ushort)(rIndex & 0x0F);
|
||||
rIndex = (byte)(rIndex & 0x0F);
|
||||
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -1251,10 +1251,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void XS(ushort rIndex)
|
||||
private void XS(byte rIndex)
|
||||
{
|
||||
// only scratch registers 0-15
|
||||
rIndex = (ushort)(rIndex & 0x0F);
|
||||
rIndex = (byte)(rIndex & 0x0F);
|
||||
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
@ -1295,10 +1295,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
END);
|
||||
}
|
||||
|
||||
private void NS(ushort rIndex)
|
||||
private void NS(byte rIndex)
|
||||
{
|
||||
// only scratch registers 0-15
|
||||
rIndex = (ushort)(rIndex & 0x0F);
|
||||
rIndex = (byte)(rIndex & 0x0F);
|
||||
|
||||
PopulateCURINSTR(
|
||||
// S
|
||||
|
|
|
@ -40,77 +40,77 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
public sealed partial class F3850
|
||||
{
|
||||
// operations that can take place in an instruction
|
||||
public const ushort ROMC_01 = 1;
|
||||
public const ushort ROMC_02 = 2;
|
||||
public const ushort ROMC_03_S = 3;
|
||||
public const ushort ROMC_04 = 4;
|
||||
public const ushort ROMC_05 = 5;
|
||||
public const ushort ROMC_06 = 6;
|
||||
public const ushort ROMC_07 = 7;
|
||||
public const ushort ROMC_08 = 8;
|
||||
public const ushort ROMC_09 = 9;
|
||||
public const ushort ROMC_0A = 10;
|
||||
public const ushort ROMC_0B = 11;
|
||||
public const ushort ROMC_0C = 12;
|
||||
public const ushort ROMC_0D = 13;
|
||||
public const ushort ROMC_0E = 14;
|
||||
public const ushort ROMC_0F = 15;
|
||||
public const ushort ROMC_10 = 16;
|
||||
public const ushort ROMC_11 = 17;
|
||||
public const ushort ROMC_12 = 18;
|
||||
public const ushort ROMC_13 = 19;
|
||||
public const ushort ROMC_14 = 20;
|
||||
public const ushort ROMC_15 = 21;
|
||||
public const ushort ROMC_16 = 22;
|
||||
public const ushort ROMC_17 = 23;
|
||||
public const ushort ROMC_18 = 24;
|
||||
public const ushort ROMC_19 = 25;
|
||||
public const ushort ROMC_1A = 26;
|
||||
public const ushort ROMC_1B = 27;
|
||||
public const ushort ROMC_1C_S = 28;
|
||||
public const ushort ROMC_1D = 29;
|
||||
public const ushort ROMC_1E = 30;
|
||||
public const ushort ROMC_1F = 31;
|
||||
public const ushort ROMC_00_S = 32;
|
||||
public const ushort ROMC_00_L = 33;
|
||||
public const ushort ROMC_03_L = 34;
|
||||
public const ushort ROMC_1C_L = 35;
|
||||
public const byte ROMC_01 = 1;
|
||||
public const byte ROMC_02 = 2;
|
||||
public const byte ROMC_03_S = 3;
|
||||
public const byte ROMC_04 = 4;
|
||||
public const byte ROMC_05 = 5;
|
||||
public const byte ROMC_06 = 6;
|
||||
public const byte ROMC_07 = 7;
|
||||
public const byte ROMC_08 = 8;
|
||||
public const byte ROMC_09 = 9;
|
||||
public const byte ROMC_0A = 10;
|
||||
public const byte ROMC_0B = 11;
|
||||
public const byte ROMC_0C = 12;
|
||||
public const byte ROMC_0D = 13;
|
||||
public const byte ROMC_0E = 14;
|
||||
public const byte ROMC_0F = 15;
|
||||
public const byte ROMC_10 = 16;
|
||||
public const byte ROMC_11 = 17;
|
||||
public const byte ROMC_12 = 18;
|
||||
public const byte ROMC_13 = 19;
|
||||
public const byte ROMC_14 = 20;
|
||||
public const byte ROMC_15 = 21;
|
||||
public const byte ROMC_16 = 22;
|
||||
public const byte ROMC_17 = 23;
|
||||
public const byte ROMC_18 = 24;
|
||||
public const byte ROMC_19 = 25;
|
||||
public const byte ROMC_1A = 26;
|
||||
public const byte ROMC_1B = 27;
|
||||
public const byte ROMC_1C_S = 28;
|
||||
public const byte ROMC_1D = 29;
|
||||
public const byte ROMC_1E = 30;
|
||||
public const byte ROMC_1F = 31;
|
||||
public const byte ROMC_00_S = 32;
|
||||
public const byte ROMC_00_L = 33;
|
||||
public const byte ROMC_03_L = 34;
|
||||
public const byte ROMC_1C_L = 35;
|
||||
|
||||
public const ushort IDLE = 0;
|
||||
public const ushort END = 51;
|
||||
public const byte IDLE = 0;
|
||||
public const byte END = 51;
|
||||
|
||||
public const ushort OP_LR8 = 100;
|
||||
public const ushort OP_SHFT_R = 101;
|
||||
public const ushort OP_SHFT_L = 102;
|
||||
public const ushort OP_LNK = 103;
|
||||
public const ushort OP_DI = 104;
|
||||
public const ushort OP_EI = 105;
|
||||
public const ushort OP_INC8 = 106;
|
||||
public const ushort OP_AND8 = 107;
|
||||
public const ushort OP_OR8 = 108;
|
||||
public const ushort OP_XOR8 = 109;
|
||||
//public const ushort OP_COM = 110;
|
||||
public const ushort OP_SUB8 = 110;
|
||||
public const ushort OP_ADD8 = 111;
|
||||
public const ushort OP_CI = 112;
|
||||
public const ushort OP_IS_INC = 113;
|
||||
public const ushort OP_IS_DEC = 114;
|
||||
public const ushort OP_LISU = 115;
|
||||
public const ushort OP_LISL = 116;
|
||||
public const ushort OP_BT = 117;
|
||||
public const ushort OP_ADD8D = 118;
|
||||
public const ushort OP_BR7 = 119;
|
||||
public const ushort OP_BF = 120;
|
||||
public const ushort OP_IN = 121;
|
||||
public const ushort OP_OUT = 122;
|
||||
//public const ushort OP_AS_IS = 123;
|
||||
//public const ushort OP_XS_IS = 124;
|
||||
//public const ushort OP_NS_IS = 125;
|
||||
public const ushort OP_LR_A_DB_IO = 126;
|
||||
public const ushort OP_DS = 127;
|
||||
//public const ushort OP_CLEAR_FLAGS = 126;
|
||||
//public const ushort OP_SET_FLAGS_SZ = 127;
|
||||
public const ushort OP_LIS = 128;
|
||||
public const byte OP_LR8 = 100;
|
||||
public const byte OP_SHFT_R = 101;
|
||||
public const byte OP_SHFT_L = 102;
|
||||
public const byte OP_LNK = 103;
|
||||
public const byte OP_DI = 104;
|
||||
public const byte OP_EI = 105;
|
||||
public const byte OP_INC8 = 106;
|
||||
public const byte OP_AND8 = 107;
|
||||
public const byte OP_OR8 = 108;
|
||||
public const byte OP_XOR8 = 109;
|
||||
//public const byte OP_COM = 110;
|
||||
public const byte OP_SUB8 = 110;
|
||||
public const byte OP_ADD8 = 111;
|
||||
public const byte OP_CI = 112;
|
||||
public const byte OP_IS_INC = 113;
|
||||
public const byte OP_IS_DEC = 114;
|
||||
public const byte OP_LISU = 115;
|
||||
public const byte OP_LISL = 116;
|
||||
public const byte OP_BT = 117;
|
||||
public const byte OP_ADD8D = 118;
|
||||
public const byte OP_BR7 = 119;
|
||||
public const byte OP_BF = 120;
|
||||
public const byte OP_IN = 121;
|
||||
public const byte OP_OUT = 122;
|
||||
//public const byte OP_AS_IS = 123;
|
||||
//public const byte OP_XS_IS = 124;
|
||||
//public const byte OP_NS_IS = 125;
|
||||
public const byte OP_LR_A_DB_IO = 126;
|
||||
public const byte OP_DS = 127;
|
||||
//public const byte OP_CLEAR_FLAGS = 126;
|
||||
//public const byte OP_SET_FLAGS_SZ = 127;
|
||||
public const byte OP_LIS = 128;
|
||||
|
||||
|
||||
public F3850()
|
||||
|
@ -208,7 +208,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
|
||||
// loads supplied index value into register
|
||||
case OP_LIS:
|
||||
Regs[ALU1] = (ushort)(cur_instr[instr_pntr++] & 0x0F);
|
||||
Regs[ALU1] = (byte)(cur_instr[instr_pntr++] & 0x0F);
|
||||
LR_Func(A, ALU1);
|
||||
break;
|
||||
|
||||
|
@ -239,7 +239,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
|
||||
// A <- (A) + (C)
|
||||
case OP_LNK:
|
||||
Regs[ALU0] = (ushort)(FlagC ? 1 : 0);
|
||||
Regs[ALU0] = (byte)(FlagC ? 1 : 0);
|
||||
ADD_Func(A, ALU0);
|
||||
break;
|
||||
|
||||
|
@ -280,22 +280,22 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
|
||||
// ISAR is incremented
|
||||
case OP_IS_INC:
|
||||
Regs[ISAR] = (ushort)((Regs[ISAR]& 0x38) | ((Regs[ISAR] + 1) & 0x07));
|
||||
Regs[ISAR] = (byte)((Regs[ISAR]& 0x38) | ((Regs[ISAR] + 1) & 0x07));
|
||||
break;
|
||||
|
||||
// ISAR is decremented
|
||||
case OP_IS_DEC:
|
||||
Regs[ISAR] = (ushort)((Regs[ISAR] & 0x38) | ((Regs[ISAR] - 1) & 0x07));
|
||||
Regs[ISAR] = (byte)((Regs[ISAR] & 0x38) | ((Regs[ISAR] - 1) & 0x07));
|
||||
break;
|
||||
|
||||
// set the upper octal ISAR bits (b3,b4,b5)
|
||||
case OP_LISU:
|
||||
Regs[ISAR] = (ushort)((((Regs[ISAR] & 0x07) | (cur_instr[instr_pntr++] & 0x07) << 3)) & 0x3F);
|
||||
Regs[ISAR] = (byte)((((Regs[ISAR] & 0x07) | (cur_instr[instr_pntr++] & 0x07) << 3)) & 0x3F);
|
||||
break;
|
||||
|
||||
// set the lower octal ISAR bits (b0,b1,b2)
|
||||
case OP_LISL:
|
||||
Regs[ISAR] = (ushort) (((Regs[ISAR] & 0x38) | (cur_instr[instr_pntr++] & 0x07)) & 0x3F);
|
||||
Regs[ISAR] = (byte) (((Regs[ISAR] & 0x38) | (cur_instr[instr_pntr++] & 0x07)) & 0x3F);
|
||||
break;
|
||||
|
||||
// decrement scratchpad byte
|
||||
|
@ -333,8 +333,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
break;
|
||||
|
||||
case 5:
|
||||
// branch if positive (same as t==1)
|
||||
if (FlagS) branchBT = true;
|
||||
// branch if positive and zero
|
||||
if (FlagS || FlagZ) branchBT = true;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
@ -342,8 +342,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
if (FlagZ || FlagC) branchBT = true;
|
||||
break;
|
||||
case 7:
|
||||
// branch if positive or on carry (same as t==3)
|
||||
if (FlagS || FlagC) branchBT = true;
|
||||
// branch if positive or on carry or zero
|
||||
if (FlagS || FlagC || FlagZ) branchBT = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -355,13 +355,13 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
// Branch on ISARL
|
||||
case OP_BR7:
|
||||
instr_pntr = 1; // lose a cycle
|
||||
if (!Regs[ISAR].Bit(0) || !Regs[ISAR].Bit(1) || !Regs[ISAR].Bit(2))
|
||||
if (Regs[ISAR].Bit(0) && Regs[ISAR].Bit(1) && Regs[ISAR].Bit(2))
|
||||
{
|
||||
DO_BRANCH();
|
||||
DONT_BRANCH();
|
||||
}
|
||||
else
|
||||
{
|
||||
DONT_BRANCH();
|
||||
DO_BRANCH();
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -396,8 +396,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
break;
|
||||
|
||||
case 5:
|
||||
// same as t==1
|
||||
if (!FlagS) branchBF = true;
|
||||
// branch if not zero and negative
|
||||
if (!FlagS && !FlagZ) branchBF = true;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
@ -406,8 +406,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
break;
|
||||
|
||||
case 7:
|
||||
// same as t==3
|
||||
if (!FlagS && !FlagC) branchBF = true;
|
||||
// branch if not zero, carry and sign
|
||||
if (!FlagS && !FlagC && !FlagZ) branchBF = true;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
@ -436,8 +436,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
break;
|
||||
|
||||
case 0xD:
|
||||
// same as t==9
|
||||
if (!FlagS && !FlagO) branchBF = true;
|
||||
// branch if no overflow, not zero and neg
|
||||
if (!FlagS && !FlagO && !FlagZ) branchBF = true;
|
||||
break;
|
||||
|
||||
case 0xE:
|
||||
|
@ -446,8 +446,8 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
break;
|
||||
|
||||
case 0xF:
|
||||
// same as t=0xB
|
||||
if (!FlagO && !FlagC && !FlagS) branchBF = true;
|
||||
// all neg
|
||||
if (!FlagO && !FlagC && !FlagS && FlagZ) branchBF = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -461,13 +461,11 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
instr_pntr++; // dest == A
|
||||
Regs[ALU0] = cur_instr[instr_pntr++]; // src
|
||||
IN_Func(A, ALU0);
|
||||
//Regs[cur_instr[instr_pntr++]] = ReadHardware(cur_instr[instr_pntr++]);
|
||||
break;
|
||||
|
||||
// I/O Port 0 or 1 <- (A)
|
||||
case OP_OUT:
|
||||
WriteHardware(cur_instr[instr_pntr++], (byte)cur_instr[instr_pntr++]);
|
||||
//OUT_Func(cur_instr[instr_pntr++], cur_instr[instr_pntr++]);
|
||||
WriteHardware(cur_instr[instr_pntr++], (byte)Regs[cur_instr[instr_pntr++]]);
|
||||
break;
|
||||
|
||||
// instruction fetch
|
||||
|
@ -779,10 +777,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
/// <summary>
|
||||
/// Optimization method to set cur_instr
|
||||
/// </summary>
|
||||
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)
|
||||
private void PopulateCURINSTR(byte d0 = 0, byte d1 = 0, byte d2 = 0, byte d3 = 0, byte d4 = 0, byte d5 = 0, byte d6 = 0, byte d7 = 0, byte d8 = 0,
|
||||
byte d9 = 0, byte d10 = 0, byte d11 = 0, byte d12 = 0, byte d13 = 0, byte d14 = 0, byte d15 = 0, byte d16 = 0, byte d17 = 0, byte d18 = 0,
|
||||
byte d19 = 0, byte d20 = 0, byte d21 = 0, byte d22 = 0, byte d23 = 0, byte d24 = 0, byte d25 = 0, byte d26 = 0, byte d27 = 0, byte d28 = 0,
|
||||
byte d29 = 0, byte d30 = 0, byte d31 = 0, byte d32 = 0, byte d33 = 0, byte d34 = 0, byte d35 = 0, byte d36 = 0, byte d37 = 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;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
else if (addr < 0x2000)
|
||||
{
|
||||
// Cart
|
||||
return 0;
|
||||
//return 0;
|
||||
return Rom[addr - 0x800];
|
||||
}
|
||||
|
||||
|
|
|
@ -35,9 +35,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
/// <returns></returns>
|
||||
public byte ReadPort(ushort addr)
|
||||
{
|
||||
byte port = (byte) (addr & 0x07);
|
||||
|
||||
switch (port)
|
||||
switch (addr)
|
||||
{
|
||||
// Console buttons
|
||||
// b0: TIME
|
||||
|
@ -45,7 +43,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
// b2: HOLD
|
||||
// b3: START
|
||||
case 0:
|
||||
return (byte)((DataConsole ^ 0xFF) & 0x0F);
|
||||
return (byte)((DataConsole ^ 0xff) | PortLatch[PORT0]);
|
||||
|
||||
// Right controller
|
||||
// b0: RIGHT
|
||||
|
@ -57,11 +55,16 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
// b6: PULL
|
||||
// b7: PUSH
|
||||
case 1:
|
||||
if (ControllersEnabled)
|
||||
byte ed1;
|
||||
if ((PortLatch[PORT0] & 0x40) == 0)
|
||||
{
|
||||
return (byte)((DataRight ^ 0xFF) & 0xFF);
|
||||
ed1 = DataRight;
|
||||
}
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
ed1 = (byte) (0xC0 | DataRight);
|
||||
}
|
||||
return (byte) ((ed1 ^ 0xff) | PortLatch[PORT1]);
|
||||
|
||||
// Left controller
|
||||
// b0: RIGHT
|
||||
|
@ -73,14 +76,23 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
// b6: PULL
|
||||
// b7: PUSH
|
||||
case 4:
|
||||
if (ControllersEnabled)
|
||||
byte ed4;
|
||||
if ((PortLatch[PORT0] & 0x40) == 0)
|
||||
{
|
||||
return (byte)((DataLeft ^ 0xFF) & 0xFF);
|
||||
ed4 = DataLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
ed4 = 0xff;
|
||||
}
|
||||
return (byte)((ed4 ^ 0xff) | PortLatch[PORT4]);
|
||||
|
||||
case 5:
|
||||
return (byte) (0 | PortLatch[PORT5]);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -90,97 +102,70 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
/// <param name="value"></param>
|
||||
public void WritePort(ushort addr, byte value)
|
||||
{
|
||||
byte port = (byte)(addr & 0x07);
|
||||
|
||||
switch (port)
|
||||
switch (addr)
|
||||
{
|
||||
case 0:
|
||||
|
||||
ControllersEnabled = (value & 0x40) == 0;
|
||||
|
||||
var val = value & 0x60;
|
||||
if (val == 0x40)// && _arm == 0x60)
|
||||
{
|
||||
VRAM[(128 * _y) + _x] = (byte)_colour;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// RAM WRT - A pulse here executes a write to video RAM
|
||||
bool ramWrt = value.Bit(5);
|
||||
|
||||
// Enable data from controllers (1 equals enable)
|
||||
// also needs pulse to write to video RAM
|
||||
bool controllerDataEnable = value.Bit(6);
|
||||
|
||||
if (ramWrt || controllerDataEnable)
|
||||
{
|
||||
// triggered write to VRAM
|
||||
var yxIndex = (_y * 128) + _x;
|
||||
var byteIndex = yxIndex / 4;
|
||||
var byteRem = yxIndex % 4;
|
||||
|
||||
switch (byteRem)
|
||||
{
|
||||
case 0:
|
||||
VRAM[byteIndex] |= (byte) _colour;
|
||||
break;
|
||||
case 1:
|
||||
VRAM[byteIndex] |= (byte) (_colour << 2);
|
||||
break;
|
||||
case 2:
|
||||
VRAM[byteIndex] |= (byte)(_colour << 4);
|
||||
break;
|
||||
case 3:
|
||||
VRAM[byteIndex] |= (byte)(_colour << 6);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
_arm = value;
|
||||
|
||||
PortLatch[PORT0] = value;
|
||||
|
||||
if ((value & 0x20) != 0)
|
||||
{
|
||||
var offset = _x + (_y * 128);
|
||||
VRAM[offset] = (byte)(_colour);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
||||
PortLatch[PORT1] = value;
|
||||
|
||||
// Write Data0 - indicates that valid data is present for both VRAM ODD0 and EVEN0
|
||||
bool data0 = value.Bit(6);
|
||||
// Write Data1 - indicates that valid data is present for both VRAM ODD1 and EVEN1
|
||||
bool data1 = value.Bit(7);
|
||||
|
||||
_colour = ((value ^ 0xff) >> 6) & 0x03;
|
||||
|
||||
PortLatch[PORT1] = value;
|
||||
|
||||
//_colour = ((value) >> 6) & 3;
|
||||
_colour = ((value ^ 0xff) >> 6) & 0x3;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
PortLatch[PORT4] = value;
|
||||
_x = (value ^ 0xff) & 0x7f;
|
||||
//_x = (value | 0x80) ^ 0xFF;
|
||||
/*
|
||||
|
||||
// video horizontal position
|
||||
// 0 - video select
|
||||
// 1-6 - horiz A-F
|
||||
|
||||
_x = (value ^ 0xff) & 0x7f;
|
||||
|
||||
|
||||
PortLatch[PORT4] = value;
|
||||
*/
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 5:
|
||||
|
||||
PortLatch[PORT5] = value;
|
||||
//_y = (value & 31); // ^ 0xff;
|
||||
//_y = (value | 0xC0) ^ 0xff;
|
||||
|
||||
//_y = (value ^ 0xff) & 0x1f;
|
||||
|
||||
// video vertical position and sound
|
||||
// 0-5 - Vertical A-F
|
||||
// 6 - Tone AN, 7 - Tone BN
|
||||
|
||||
_y = (value ^ 0xff) & 0x3f;
|
||||
|
||||
PortLatch[PORT5] = value;
|
||||
|
||||
// audio
|
||||
var aVal = ((value >> 6) & 0x03); // (value & 0xc0) >> 6;
|
||||
if (aVal != tone)
|
||||
{
|
||||
tone = aVal;
|
||||
time = 0;
|
||||
amplitude = 1;
|
||||
AudioChange();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.CodeDom;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -20,6 +21,10 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
|
||||
public static readonly int[] FPalette =
|
||||
{
|
||||
/*
|
||||
0x101010, 0xFDFDFD, 0x5331FF, 0x5DCC02, 0xF33F4B, 0xE0E0E0, 0xA6FF91, 0xD0CEFF
|
||||
*/
|
||||
|
||||
Colors.ARGB(0x10, 0x10, 0x10), // Black
|
||||
Colors.ARGB(0xFD, 0xFD, 0xFD), // White
|
||||
Colors.ARGB(0xFF, 0x31, 0x53), // Red
|
||||
|
@ -28,6 +33,7 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
Colors.ARGB(0xE0, 0xE0, 0xE0), // Gray
|
||||
Colors.ARGB(0x91, 0xFF, 0xA6), // BGreen
|
||||
Colors.ARGB(0xCE, 0xD0, 0xFF), // BBlue
|
||||
|
||||
};
|
||||
|
||||
public static readonly int[] CMap =
|
||||
|
@ -52,67 +58,21 @@ namespace BizHawk.Emulation.Cores.Consoles.ChannelF
|
|||
for (int row = 0; row < 64; row++)
|
||||
{
|
||||
// columns 125 and 126 hold the palette index modifier for the entire row
|
||||
var rIndex = 64 * row;
|
||||
var c125 = (VRAM[rIndex + 125] & 0x02) >> 1;
|
||||
var rIndex = 128 * row;
|
||||
var c125 = (VRAM[rIndex + 125] & 0x03);
|
||||
var c126 = (VRAM[rIndex + 126] & 0x03);
|
||||
var pModifier = ((c125 | c126) << 2) & 0x0C;
|
||||
var pModifier = (((c126 & 0x02) | c125 >> 1) << 2);
|
||||
|
||||
pModifier = ((VRAM[(row << 7) + 125] & 2) >> 1) | (VRAM[(row << 7) + 126] & 3);
|
||||
pModifier = (pModifier << 2) & 0xc;
|
||||
|
||||
// columns
|
||||
for (int col = 0; col < 128; col++, counter++)
|
||||
{
|
||||
int colour = (VRAM[rIndex + col]) & 0x03;
|
||||
var finalColorIndex = pModifier | colour;
|
||||
var paletteLookup = CMap[finalColorIndex & 0x0f] & 0x07;
|
||||
frameBuffer[counter] = FPalette[paletteLookup];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildFrame1()
|
||||
{
|
||||
int cnt = 0;
|
||||
// rows
|
||||
for (int row = 0; row < 64; row++)
|
||||
{
|
||||
var yIndex = row * 128;
|
||||
var yByte = yIndex / 4;
|
||||
|
||||
// last byte for this row contains palette modifier
|
||||
var pModifier = (byte)(VRAM[yByte + 31] & 0x0C);
|
||||
|
||||
// columns
|
||||
for (int col = 0; col < 128; col++)
|
||||
{
|
||||
var fbIndex = (row * 64) + col;
|
||||
|
||||
var xByte = col / 4;
|
||||
var xRem = col % 4;
|
||||
var xyByte = yByte + xByte;
|
||||
|
||||
// each byte contains 4 pixel colour values, b0b1, b2b3, b4b5, b6b7
|
||||
int colour = 0;
|
||||
|
||||
switch (xRem)
|
||||
{
|
||||
case 0:
|
||||
colour = VRAM[xyByte] & 0x03;
|
||||
break;
|
||||
case 1:
|
||||
colour = VRAM[xyByte] & 0x0C;
|
||||
break;
|
||||
case 2:
|
||||
colour = VRAM[xyByte] & 0x30;
|
||||
break;
|
||||
case 3:
|
||||
colour = VRAM[xyByte] & 0xC0;
|
||||
break;
|
||||
}
|
||||
|
||||
var finalColorIndex = pModifier | colour;
|
||||
var paletteLookup = CMap[finalColorIndex & 0x0f] & 0x07;
|
||||
frameBuffer[fbIndex] = FPalette[paletteLookup];
|
||||
|
||||
cnt++;
|
||||
int cl = (VRAM[(row << 7) + col]) & 0x3;
|
||||
frameBuffer[(row << 7) + col] = CMap[pModifier | cl] & 0x7;
|
||||
//var nCol = pModifier + (VRAM[col | (row << 7)] & 0x03);
|
||||
//frameBuffer[counter] = FPalette[CMap[nCol]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue