delete 8 year old attic files. We can ressurect the attic if need be, but I think these things are officially bit rotted

This commit is contained in:
adelikat 2020-02-22 12:05:02 -06:00
parent 9e7bdd2424
commit 564f0d8557
21 changed files with 0 additions and 4959 deletions

View File

@ -1,198 +0,0 @@
using System;
// Do not modify this file directly! This is GENERATED code.
// Please open the CpuCoreGenerator solution and make your modifications there.
namespace BizHawk.Emulation.CPUs.M6502
{
public partial class MOS6502
{
public string Disassemble(ushort pc, out int bytesToAdvance)
{
byte op = ReadMemory(pc);
switch (op)
{
case 0x00: bytesToAdvance = 1; return "BRK";
case 0x01: bytesToAdvance = 2; return string.Format("ORA (${0:X2},X)", ReadMemory(++pc));
case 0x04: bytesToAdvance = 2; return string.Format("NOP ${0:X2}", ReadMemory(++pc));
case 0x05: bytesToAdvance = 2; return string.Format("ORA ${0:X2}", ReadMemory(++pc));
case 0x06: bytesToAdvance = 2; return string.Format("ASL ${0:X2}", ReadMemory(++pc));
case 0x08: bytesToAdvance = 1; return "PHP";
case 0x09: bytesToAdvance = 2; return string.Format("ORA #${0:X2}", ReadMemory(++pc));
case 0x0A: bytesToAdvance = 1; return "ASL A";
case 0x0C: bytesToAdvance = 3; return string.Format("NOP (${0:X4})", ReadWord(++pc));
case 0x0D: bytesToAdvance = 3; return string.Format("ORA ${0:X4}", ReadWord(++pc));
case 0x0E: bytesToAdvance = 3; return string.Format("ASL ${0:X4}", ReadWord(++pc));
case 0x10: bytesToAdvance = 2; return string.Format("BPL ${0:X4}", pc+2+(sbyte)ReadMemory(++pc));
case 0x11: bytesToAdvance = 2; return string.Format("ORA (${0:X2}),Y *", ReadMemory(++pc));
case 0x14: bytesToAdvance = 2; return string.Format("NOP ${0:X2},X", ReadMemory(++pc));
case 0x15: bytesToAdvance = 2; return string.Format("ORA ${0:X2},X", ReadMemory(++pc));
case 0x16: bytesToAdvance = 2; return string.Format("ASL ${0:X2},X", ReadMemory(++pc));
case 0x18: bytesToAdvance = 1; return "CLC";
case 0x19: bytesToAdvance = 3; return string.Format("ORA ${0:X4},Y *", ReadWord(++pc));
case 0x1A: bytesToAdvance = 1; return "NOP";
case 0x1C: bytesToAdvance = 2; return string.Format("NOP (${0:X2},X)", ReadMemory(++pc));
case 0x1D: bytesToAdvance = 3; return string.Format("ORA ${0:X4},X *", ReadWord(++pc));
case 0x1E: bytesToAdvance = 3; return string.Format("ASL ${0:X4},X", ReadWord(++pc));
case 0x20: bytesToAdvance = 3; return string.Format("JSR ${0:X4}", ReadWord(++pc));
case 0x21: bytesToAdvance = 2; return string.Format("AND (${0:X2},X)", ReadMemory(++pc));
case 0x24: bytesToAdvance = 2; return string.Format("BIT ${0:X2}", ReadMemory(++pc));
case 0x25: bytesToAdvance = 2; return string.Format("AND ${0:X2}", ReadMemory(++pc));
case 0x26: bytesToAdvance = 2; return string.Format("ROL ${0:X2}", ReadMemory(++pc));
case 0x28: bytesToAdvance = 1; return "PLP";
case 0x29: bytesToAdvance = 2; return string.Format("AND #${0:X2}", ReadMemory(++pc));
case 0x2A: bytesToAdvance = 1; return "ROL A";
case 0x2C: bytesToAdvance = 3; return string.Format("BIT ${0:X4}", ReadWord(++pc));
case 0x2D: bytesToAdvance = 3; return string.Format("AND ${0:X4}", ReadWord(++pc));
case 0x2E: bytesToAdvance = 3; return string.Format("ROL ${0:X4}", ReadWord(++pc));
case 0x30: bytesToAdvance = 2; return string.Format("BMI ${0:X4}", pc+2+(sbyte)ReadMemory(++pc));
case 0x31: bytesToAdvance = 2; return string.Format("AND (${0:X2}),Y *", ReadMemory(++pc));
case 0x34: bytesToAdvance = 2; return string.Format("NOP ${0:X2},X", ReadMemory(++pc));
case 0x35: bytesToAdvance = 2; return string.Format("AND ${0:X2},X", ReadMemory(++pc));
case 0x36: bytesToAdvance = 2; return string.Format("ROL ${0:X2},X", ReadMemory(++pc));
case 0x38: bytesToAdvance = 1; return "SEC";
case 0x39: bytesToAdvance = 3; return string.Format("AND ${0:X4},Y *", ReadWord(++pc));
case 0x3A: bytesToAdvance = 1; return "NOP";
case 0x3C: bytesToAdvance = 2; return string.Format("NOP (${0:X2},X)", ReadMemory(++pc));
case 0x3D: bytesToAdvance = 3; return string.Format("AND ${0:X4},X *", ReadWord(++pc));
case 0x3E: bytesToAdvance = 3; return string.Format("ROL ${0:X4},X", ReadWord(++pc));
case 0x40: bytesToAdvance = 1; return "RTI";
case 0x41: bytesToAdvance = 2; return string.Format("EOR (${0:X2},X)", ReadMemory(++pc));
case 0x44: bytesToAdvance = 2; return string.Format("NOP ${0:X2}", ReadMemory(++pc));
case 0x45: bytesToAdvance = 2; return string.Format("EOR ${0:X2}", ReadMemory(++pc));
case 0x46: bytesToAdvance = 2; return string.Format("LSR ${0:X2}", ReadMemory(++pc));
case 0x48: bytesToAdvance = 1; return "PHA";
case 0x49: bytesToAdvance = 2; return string.Format("EOR #${0:X2}", ReadMemory(++pc));
case 0x4A: bytesToAdvance = 1; return "LSR A";
case 0x4C: bytesToAdvance = 3; return string.Format("JMP ${0:X4}", ReadWord(++pc));
case 0x4D: bytesToAdvance = 3; return string.Format("EOR ${0:X4}", ReadWord(++pc));
case 0x4E: bytesToAdvance = 3; return string.Format("LSR ${0:X4}", ReadWord(++pc));
case 0x50: bytesToAdvance = 2; return string.Format("BVC ${0:X4}", pc+2+(sbyte)ReadMemory(++pc));
case 0x51: bytesToAdvance = 2; return string.Format("EOR (${0:X2}),Y *", ReadMemory(++pc));
case 0x54: bytesToAdvance = 2; return string.Format("NOP ${0:X2},X", ReadMemory(++pc));
case 0x55: bytesToAdvance = 2; return string.Format("EOR ${0:X2},X", ReadMemory(++pc));
case 0x56: bytesToAdvance = 2; return string.Format("LSR ${0:X2},X", ReadMemory(++pc));
case 0x58: bytesToAdvance = 1; return "CLI";
case 0x59: bytesToAdvance = 3; return string.Format("EOR ${0:X4},Y *", ReadWord(++pc));
case 0x5A: bytesToAdvance = 1; return "NOP";
case 0x5C: bytesToAdvance = 2; return string.Format("NOP (${0:X2},X)", ReadMemory(++pc));
case 0x5D: bytesToAdvance = 3; return string.Format("EOR ${0:X4},X *", ReadWord(++pc));
case 0x5E: bytesToAdvance = 3; return string.Format("LSR ${0:X4},X", ReadWord(++pc));
case 0x60: bytesToAdvance = 1; return "RTS";
case 0x61: bytesToAdvance = 2; return string.Format("ADC (${0:X2},X)", ReadMemory(++pc));
case 0x64: bytesToAdvance = 2; return string.Format("NOP ${0:X2}", ReadMemory(++pc));
case 0x65: bytesToAdvance = 2; return string.Format("ADC ${0:X2}", ReadMemory(++pc));
case 0x66: bytesToAdvance = 2; return string.Format("ROR ${0:X2}", ReadMemory(++pc));
case 0x68: bytesToAdvance = 1; return "PLA";
case 0x69: bytesToAdvance = 2; return string.Format("ADC #${0:X2}", ReadMemory(++pc));
case 0x6A: bytesToAdvance = 1; return "ROR A";
case 0x6C: bytesToAdvance = 3; return string.Format("JMP (${0:X4})", ReadWord(++pc));
case 0x6D: bytesToAdvance = 3; return string.Format("ADC ${0:X4}", ReadWord(++pc));
case 0x6E: bytesToAdvance = 3; return string.Format("ROR ${0:X4}", ReadWord(++pc));
case 0x70: bytesToAdvance = 2; return string.Format("BVS ${0:X4}", pc+2+(sbyte)ReadMemory(++pc));
case 0x71: bytesToAdvance = 2; return string.Format("ADC (${0:X2}),Y *", ReadMemory(++pc));
case 0x74: bytesToAdvance = 2; return string.Format("NOP ${0:X2},X", ReadMemory(++pc));
case 0x75: bytesToAdvance = 2; return string.Format("ADC ${0:X2},X", ReadMemory(++pc));
case 0x76: bytesToAdvance = 2; return string.Format("ROR ${0:X2},X", ReadMemory(++pc));
case 0x78: bytesToAdvance = 1; return "SEI";
case 0x79: bytesToAdvance = 3; return string.Format("ADC ${0:X4},Y *", ReadWord(++pc));
case 0x7A: bytesToAdvance = 1; return "NOP";
case 0x7C: bytesToAdvance = 2; return string.Format("NOP (${0:X2},X)", ReadMemory(++pc));
case 0x7D: bytesToAdvance = 3; return string.Format("ADC ${0:X4},X *", ReadWord(++pc));
case 0x7E: bytesToAdvance = 3; return string.Format("ROR ${0:X4},X", ReadWord(++pc));
case 0x80: bytesToAdvance = 2; return string.Format("NOP #${0:X2}", ReadMemory(++pc));
case 0x81: bytesToAdvance = 2; return string.Format("STA (${0:X2},X)", ReadMemory(++pc));
case 0x82: bytesToAdvance = 2; return string.Format("NOP #${0:X2}", ReadMemory(++pc));
case 0x84: bytesToAdvance = 2; return string.Format("STY ${0:X2}", ReadMemory(++pc));
case 0x85: bytesToAdvance = 2; return string.Format("STA ${0:X2}", ReadMemory(++pc));
case 0x86: bytesToAdvance = 2; return string.Format("STX ${0:X2}", ReadMemory(++pc));
case 0x88: bytesToAdvance = 1; return "DEY";
case 0x89: bytesToAdvance = 2; return string.Format("NOP #${0:X2}", ReadMemory(++pc));
case 0x8A: bytesToAdvance = 1; return "TXA";
case 0x8C: bytesToAdvance = 3; return string.Format("STY ${0:X4}", ReadWord(++pc));
case 0x8D: bytesToAdvance = 3; return string.Format("STA ${0:X4}", ReadWord(++pc));
case 0x8E: bytesToAdvance = 3; return string.Format("STX ${0:X4}", ReadWord(++pc));
case 0x90: bytesToAdvance = 2; return string.Format("BCC ${0:X4}", pc+2+(sbyte)ReadMemory(++pc));
case 0x91: bytesToAdvance = 2; return string.Format("STA (${0:X2}),Y", ReadMemory(++pc));
case 0x94: bytesToAdvance = 2; return string.Format("STY ${0:X2},X", ReadMemory(++pc));
case 0x95: bytesToAdvance = 2; return string.Format("STA ${0:X2},X", ReadMemory(++pc));
case 0x96: bytesToAdvance = 2; return string.Format("STX ${0:X2},Y", ReadMemory(++pc));
case 0x98: bytesToAdvance = 1; return "TYA";
case 0x99: bytesToAdvance = 3; return string.Format("STA ${0:X4},Y", ReadWord(++pc));
case 0x9A: bytesToAdvance = 1; return "TXS";
case 0x9D: bytesToAdvance = 3; return string.Format("STA ${0:X4},X", ReadWord(++pc));
case 0xA0: bytesToAdvance = 2; return string.Format("LDY #${0:X2}", ReadMemory(++pc));
case 0xA1: bytesToAdvance = 2; return string.Format("LDA (${0:X2},X)", ReadMemory(++pc));
case 0xA2: bytesToAdvance = 2; return string.Format("LDX #${0:X2}", ReadMemory(++pc));
case 0xA4: bytesToAdvance = 2; return string.Format("LDY ${0:X2}", ReadMemory(++pc));
case 0xA5: bytesToAdvance = 2; return string.Format("LDA ${0:X2}", ReadMemory(++pc));
case 0xA6: bytesToAdvance = 2; return string.Format("LDX ${0:X2}", ReadMemory(++pc));
case 0xA8: bytesToAdvance = 1; return "TAY";
case 0xA9: bytesToAdvance = 2; return string.Format("LDA #${0:X2}", ReadMemory(++pc));
case 0xAA: bytesToAdvance = 1; return "TAX";
case 0xAC: bytesToAdvance = 3; return string.Format("LDY ${0:X4}", ReadWord(++pc));
case 0xAD: bytesToAdvance = 3; return string.Format("LDA ${0:X4}", ReadWord(++pc));
case 0xAE: bytesToAdvance = 3; return string.Format("LDX ${0:X4}", ReadWord(++pc));
case 0xB0: bytesToAdvance = 2; return string.Format("BCS ${0:X4}", pc+2+(sbyte)ReadMemory(++pc));
case 0xB1: bytesToAdvance = 2; return string.Format("LDA (${0:X2}),Y *", ReadMemory(++pc));
case 0xB4: bytesToAdvance = 2; return string.Format("LDY ${0:X2},X", ReadMemory(++pc));
case 0xB5: bytesToAdvance = 2; return string.Format("LDA ${0:X2},X", ReadMemory(++pc));
case 0xB6: bytesToAdvance = 2; return string.Format("LDX ${0:X2},Y", ReadMemory(++pc));
case 0xB8: bytesToAdvance = 1; return "CLV";
case 0xB9: bytesToAdvance = 3; return string.Format("LDA ${0:X4},Y *", ReadWord(++pc));
case 0xBA: bytesToAdvance = 1; return "TSX";
case 0xBC: bytesToAdvance = 3; return string.Format("LDY ${0:X4},X *", ReadWord(++pc));
case 0xBD: bytesToAdvance = 3; return string.Format("LDA ${0:X4},X *", ReadWord(++pc));
case 0xBE: bytesToAdvance = 3; return string.Format("LDX ${0:X4},Y *", ReadWord(++pc));
case 0xC0: bytesToAdvance = 2; return string.Format("CPY #${0:X2}", ReadMemory(++pc));
case 0xC1: bytesToAdvance = 2; return string.Format("CMP (${0:X2},X)", ReadMemory(++pc));
case 0xC2: bytesToAdvance = 2; return string.Format("NOP #${0:X2}", ReadMemory(++pc));
case 0xC4: bytesToAdvance = 2; return string.Format("CPY ${0:X2}", ReadMemory(++pc));
case 0xC5: bytesToAdvance = 2; return string.Format("CMP ${0:X2}", ReadMemory(++pc));
case 0xC6: bytesToAdvance = 2; return string.Format("DEC ${0:X2}", ReadMemory(++pc));
case 0xC8: bytesToAdvance = 1; return "INY";
case 0xC9: bytesToAdvance = 2; return string.Format("CMP #${0:X2}", ReadMemory(++pc));
case 0xCA: bytesToAdvance = 1; return "DEX";
case 0xCC: bytesToAdvance = 3; return string.Format("CPY ${0:X4}", ReadWord(++pc));
case 0xCD: bytesToAdvance = 3; return string.Format("CMP ${0:X4}", ReadWord(++pc));
case 0xCE: bytesToAdvance = 3; return string.Format("DEC ${0:X4}", ReadWord(++pc));
case 0xD0: bytesToAdvance = 2; return string.Format("BNE ${0:X4}", pc+2+(sbyte)ReadMemory(++pc));
case 0xD1: bytesToAdvance = 2; return string.Format("CMP (${0:X2}),Y *", ReadMemory(++pc));
case 0xD4: bytesToAdvance = 2; return string.Format("NOP ${0:X2},X", ReadMemory(++pc));
case 0xD5: bytesToAdvance = 2; return string.Format("CMP ${0:X2},X", ReadMemory(++pc));
case 0xD6: bytesToAdvance = 2; return string.Format("DEC ${0:X2},X", ReadMemory(++pc));
case 0xD8: bytesToAdvance = 1; return "CLD";
case 0xD9: bytesToAdvance = 3; return string.Format("CMP ${0:X4},Y *", ReadWord(++pc));
case 0xDA: bytesToAdvance = 1; return "NOP";
case 0xDC: bytesToAdvance = 2; return string.Format("NOP (${0:X2},X)", ReadMemory(++pc));
case 0xDD: bytesToAdvance = 3; return string.Format("CMP ${0:X4},X *", ReadWord(++pc));
case 0xDE: bytesToAdvance = 3; return string.Format("DEC ${0:X4},X", ReadWord(++pc));
case 0xE0: bytesToAdvance = 2; return string.Format("CPX #${0:X2}", ReadMemory(++pc));
case 0xE1: bytesToAdvance = 2; return string.Format("SBC (${0:X2},X)", ReadMemory(++pc));
case 0xE2: bytesToAdvance = 2; return string.Format("NOP #${0:X2}", ReadMemory(++pc));
case 0xE4: bytesToAdvance = 2; return string.Format("CPX ${0:X2}", ReadMemory(++pc));
case 0xE5: bytesToAdvance = 2; return string.Format("SBC ${0:X2}", ReadMemory(++pc));
case 0xE6: bytesToAdvance = 2; return string.Format("INC ${0:X2}", ReadMemory(++pc));
case 0xE8: bytesToAdvance = 1; return "INX";
case 0xE9: bytesToAdvance = 2; return string.Format("SBC #${0:X2}", ReadMemory(++pc));
case 0xEA: bytesToAdvance = 1; return "NOP";
case 0xEC: bytesToAdvance = 3; return string.Format("CPX ${0:X4}", ReadWord(++pc));
case 0xED: bytesToAdvance = 3; return string.Format("SBC ${0:X4}", ReadWord(++pc));
case 0xEE: bytesToAdvance = 3; return string.Format("INC ${0:X4}", ReadWord(++pc));
case 0xF0: bytesToAdvance = 2; return string.Format("BEQ ${0:X4}", pc+2+(sbyte)ReadMemory(++pc));
case 0xF1: bytesToAdvance = 2; return string.Format("SBC (${0:X2}),Y *", ReadMemory(++pc));
case 0xF4: bytesToAdvance = 2; return string.Format("NOP ${0:X2},X", ReadMemory(++pc));
case 0xF5: bytesToAdvance = 2; return string.Format("SBC ${0:X2},X", ReadMemory(++pc));
case 0xF6: bytesToAdvance = 2; return string.Format("INC ${0:X2},X", ReadMemory(++pc));
case 0xF8: bytesToAdvance = 1; return "SED";
case 0xF9: bytesToAdvance = 3; return string.Format("SBC ${0:X4},Y *", ReadWord(++pc));
case 0xFA: bytesToAdvance = 1; return "NOP";
case 0xFC: bytesToAdvance = 2; return string.Format("NOP (${0:X2},X)", ReadMemory(++pc));
case 0xFD: bytesToAdvance = 3; return string.Format("SBC ${0:X4},X *", ReadWord(++pc));
case 0xFE: bytesToAdvance = 3; return string.Format("INC ${0:X4},X", ReadWord(++pc));
}
bytesToAdvance = 1;
return "???";
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,241 +0,0 @@
using System;
using System.Globalization;
using System.IO;
namespace BizHawk.Emulation.CPUs.M6502
{
public sealed partial class MOS6502
{
public MOS6502()
{
//InitTableNZ();
Reset();
}
/*
private byte[] TableNZ;
private void InitTableNZ()
{
TableNZ = new byte[256];
for (int i = 0; i < 256; i++)
{
byte b = 0;
if (i == 0) b |= 0x02;
if (i > 127) b |= 0x80;
TableNZ[i] = b;
}
}*/
public bool debug;
public bool throw_unhandled;
public void Reset()
{
A = 0;
X = 0;
Y = 0;
P = 0;
S = 0;
PC = 0;
PendingCycles = 0;
TotalExecutedCycles = 0;
}
public string State()
{
int notused;
string a = string.Format("{0:X4} {1:X2} {2} ", PC, ReadMemory(PC), Disassemble(PC, out notused)).PadRight(30);
string b = string.Format("A:{0:X2} X:{1:X2} Y:{2:X2} P:{3:X2} SP:{4:X2} Cy:{5}", A, X, Y, P, S, TotalExecutedCycles);
string val = a + b + " ";
if (FlagN) val = val + "N";
if (FlagV) val = val + "V";
if (FlagT) val = val + "T";
if (FlagB) val = val + "B";
if (FlagD) val = val + "D";
if (FlagI) val = val + "I";
if (FlagZ) val = val + "Z";
if (FlagC) val = val + "C";
return val;
}
public const ushort NMIVector = 0xFFFA;
public const ushort ResetVector = 0xFFFC;
public const ushort BRKVector = 0xFFFE;
public const ushort IRQVector = 0xFFFE;
enum ExceptionType
{
BRK, NMI, IRQ
}
void TriggerException(ExceptionType type)
{
if (type == ExceptionType.BRK)
PC++;
WriteMemory((ushort)(S-- + 0x100), (byte)(PC >> 8));
WriteMemory((ushort)(S-- + 0x100), (byte)PC);
FlagB = type == ExceptionType.BRK;
WriteMemory((ushort)(S-- + 0x100), P);
FlagI = true;
switch (type)
{
case ExceptionType.NMI:
PC = ReadWord(NMIVector);
break;
case ExceptionType.IRQ:
PC = ReadWord(IRQVector);
break;
case ExceptionType.BRK:
PC = ReadWord(BRKVector);
break;
default: throw new Exception();
}
PendingCycles -= 7;
}
// ==== CPU State ====
public byte A;
public byte X;
public byte Y;
public byte P;
public ushort PC;
public byte S;
public bool IRQ;
public bool NMI;
public bool CLI_Pending;
public bool SEI_Pending;
public void SyncState(Serializer ser)
{
ser.BeginSection("MOS6502");
ser.Sync("A", ref A);
ser.Sync("X", ref X);
ser.Sync("Y", ref Y);
ser.Sync("P", ref P);
ser.Sync("PC", ref PC);
ser.Sync("S", ref S);
ser.Sync("NMI", ref NMI);
ser.Sync("IRQ", ref IRQ);
ser.Sync("CLI_Pending", ref CLI_Pending);
ser.Sync("SEI_Pending", ref SEI_Pending);
ser.Sync("TotalExecutedCycles", ref TotalExecutedCycles);
ser.Sync("PendingCycles", ref PendingCycles);
ser.EndSection();
}
public void SaveStateBinary(BinaryWriter writer) { SyncState(Serializer.CreateBinaryWriter(writer)); }
public void LoadStateBinary(BinaryReader reader) { SyncState(Serializer.CreateBinaryReader(reader)); }
// ==== End State ====
/// <summary>Carry Flag</summary>
private bool FlagC
{
get { return (P & 0x01) != 0; }
set { P = (byte)((P & ~0x01) | (value ? 0x01 : 0x00)); }
}
/// <summary>Zero Flag</summary>
private bool FlagZ
{
get { return (P & 0x02) != 0; }
set { P = (byte)((P & ~0x02) | (value ? 0x02 : 0x00)); }
}
/// <summary>Interrupt Disable Flag</summary>
public bool FlagI
{
get { return (P & 0x04) != 0; }
set { P = (byte)((P & ~0x04) | (value ? 0x04 : 0x00)); }
}
/// <summary>Decimal Mode Flag</summary>
private bool FlagD
{
get { return (P & 0x08) != 0; }
set { P = (byte)((P & ~0x08) | (value ? 0x08 : 0x00)); }
}
/// <summary>Break Flag</summary>
private bool FlagB
{
get { return (P & 0x10) != 0; }
set { P = (byte)((P & ~0x10) | (value ? 0x10 : 0x00)); }
}
/// <summary>T... Flag</summary>
private bool FlagT
{
get { return (P & 0x20) != 0; }
set { P = (byte)((P & ~0x20) | (value ? 0x20 : 0x00)); }
}
/// <summary>Overflow Flag</summary>
private bool FlagV
{
get { return (P & 0x40) != 0; }
set { P = (byte)((P & ~0x40) | (value ? 0x40 : 0x00)); }
}
/// <summary>Negative Flag</summary>
private bool FlagN
{
get { return (P & 0x80) != 0; }
set { P = (byte)((P & ~0x80) | (value ? 0x80 : 0x00)); }
}
public int TotalExecutedCycles;
public int PendingCycles;
public Func<ushort, byte> ReadMemory;
public Action<ushort, byte> WriteMemory;
public void UnregisterMemoryMapper()
{
ReadMemory = null;
WriteMemory = null;
}
public ushort ReadWord(ushort address)
{
byte l = ReadMemory(address);
byte h = ReadMemory(++address);
return (ushort)((h << 8) | l);
}
private void WriteWord(ushort address, ushort value)
{
byte l = (byte)(value & 0xFF);
byte h = (byte)(value >> 8);
WriteMemory(address, l);
WriteMemory(++address, h);
}
private ushort ReadWordPageWrap(ushort address)
{
ushort highAddress = (ushort)((address & 0xFF00) + ((address + 1) & 0xFF));
return (ushort)(ReadMemory(address) | (ReadMemory(highAddress) << 8));
}
private static readonly byte[] TableNZ =
{
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
};
}
}

View File

@ -1,7 +0,0 @@
This is the original 6502 cpu core. It was replaced by "MOS 6502X".
It's pretty decent. It does its job well.. it wasnt ever validated for the nitty gritty details:
1. spurious memory accesses
2. fine details of irq timing
3. others?
Moreover, this runs instructions one at a time instead of 6502X's one cycle at a time (several iterations for one cpu instruction)
Therefore, this core might be useful for something where the accuracy doesnt matter that much but more speed is warranted.

View File

@ -1,69 +0,0 @@
using System;
using System.IO;
using System.Collections.Generic;
namespace BizHawk.Emulation.Consoles.Calculator
{
[CoreVersion("0.0.1", FriendlyName = "PsxHawk!")]
public class PSX : IEmulator, IVideoProvider, ISoundProvider
{
PsxApi api = new PsxApi();
public string SystemId { get { return "PSX"; } }
public static readonly ControllerDefinition NullController = new ControllerDefinition { Name = "Null Controller" };
private int[] frameBuffer = new int[256 * 192];
private Random rand = new Random();
public CoreInputComm CoreInputComm { get; set; }
public CoreOutputComm CoreOutputComm { get; private set; }
public IVideoProvider VideoProvider { get { return this; } }
public ISoundProvider SoundProvider { get { return this; } }
public PSX()
{
CoreOutputComm = new CoreOutputComm();
CoreInputComm = new CoreInputComm();
}
public void ResetFrameCounter()
{
Frame = 0;
}
public void LoadFile(string file)
{
api.Load_EXE(file);
}
public void FrameAdvance(bool render)
{
if (render == false) return;
for (int i = 0; i < 256 * 192; i++)
frameBuffer[i] = Colors.Luminosity((byte)rand.Next());
api.RunForever();
}
public ControllerDefinition ControllerDefinition { get { return NullController; } }
public IController Controller { get; set; }
public int Frame { get; set; }
public int LagCount { get { return 0; } set { return; } }
public bool IsLagFrame { get { return false; } }
public byte[] SaveRam { get { return new byte[0]; } }
public bool DeterministicEmulation { get; set; }
public bool SaveRamModified { get; set; }
public void SaveStateText(TextWriter writer) { }
public void LoadStateText(TextReader reader) { }
public void SaveStateBinary(BinaryWriter writer) { }
public void LoadStateBinary(BinaryReader reader) { }
public byte[] SaveStateBinary() { return new byte[1]; }
public int[] GetVideoBuffer() { return frameBuffer; }
public int BufferWidth { get { return 256; } }
public int BufferHeight { get { return 192; } }
public int BackgroundColor { get { return 0; } }
public void GetSamples(short[] samples) { }
public void DiscardSamples() { }
public int MaxVolume { get; set; }
public IList<MemoryDomain> MemoryDomains { get { return new List<MemoryDomain>(); } }
public MemoryDomain MainMemory { get { return null; } }
public void Dispose() { }
}
}

View File

@ -1,99 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="api.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PsxHawk.Core\PsxHawk.Core.vcxproj">
<Project>{7b67d95b-29e0-4f9d-9767-42c35cec3f25}</Project>
<Private>true</Private>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{E160DA07-E926-4C7B-8A38-D45F4FE16725}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>PsxHawkAPI</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>false</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(Configuration)\</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../PsxHawk.Core</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../PsxHawk.Core</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="api.cpp" />
</ItemGroup>
</Project>

View File

@ -1,60 +0,0 @@
/*
this c++/cli file implements the bridge between PsxHawk.Core and managed code.
currently this is a miserable little pile of hacks.
*/
#using <mscorlib.dll>
#using <System.dll>
#include <vcclr.h>
#include <msclr/marshal.h>
#include <msclr/marshal_cppstd.h>
#include <string>
#include "psx.h"
#include "loader.h"
using namespace msclr::interop;
public ref class PsxApi
{
public:
PSX *psx;
//this endeavours to fix some issues with routing stdio between .net and the CRT
static void StdioFixes()
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD fileType = GetFileType(handle);
bool shouldReopen = fileType == FILE_TYPE_CHAR;
if(shouldReopen)
freopen("CONOUT$", "w", stdout);
handle = GetStdHandle(STD_ERROR_HANDLE);
fileType = GetFileType(handle);
shouldReopen = fileType == FILE_TYPE_CHAR;
if(shouldReopen)
freopen("CONOUT$", "w", stderr);
}
PsxApi()
{
StdioFixes();
//initialize the psx instance
psx = new PSX();
psx->poweron(PSX::eConsoleType_DTL);
Load_BIOS(*psx, "B:\\svn\\bizhawk4\\BizHawk.MultiClient\\output\\SCPH5500.bin"); //JP bios (apparently thats what region our test programs are, or what mednafen ends up using)
//Load_BIOS(psx, "scph5501.bin");
psx->reset();
}
void Load_EXE(System::String^ str)
{
::Load_EXE(*psx, marshal_as<std::wstring>(str).c_str());
}
void RunForever()
{
psx->RunForever();
}
};

View File

@ -1,186 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="PsxHawk.Core"
ProjectGUID="{7B67D95B-29E0-4F9D-9767-42C35CEC3F25}"
RootNamespace="PsxHawkCore"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\BizHawk.UnmanagedCore"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;PSXHAWKCORE_EXPORTS;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
GenerateMapFile="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(TargetPath) $(SolutionDir)\BizHawk.MultiClient\output"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\BizHawk.UnmanagedCore"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PSXHAWKCORE_EXPORTS;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(TargetPath) $(SolutionDir)\BizHawk.MultiClient\output"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\PsxCore.cpp"
>
</File>
<File
RelativePath=".\PsxCore.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,141 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClInclude Include="asm.h" />
<ClInclude Include="dis.h" />
<ClInclude Include="loader.h" />
<ClInclude Include="psx.h" />
<ClInclude Include="types.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dis.cpp" />
<ClCompile Include="loader.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="psx.cpp" />
<ClCompile Include="psx.sio.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7B67D95B-29E0-4F9D-9767-42C35CEC3F25}</ProjectGuid>
<RootNamespace>PsxHawkCore</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>NotSet</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>false</CLRSupport>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\BizHawk.Multiclient\output\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.dll</TargetExt>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\BizHawk.UnmanagedCore;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;PSXHAWKCORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<CallingConvention>Cdecl</CallingConvention>
<BufferSecurityCheck>false</BufferSecurityCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>Full</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\BizHawk.UnmanagedCore;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;PSXHAWKCORE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>false</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CallingConvention>Cdecl</CallingConvention>
<BufferSecurityCheck>false</BufferSecurityCheck>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<StringPooling>true</StringPooling>
<FloatingPointExceptions>false</FloatingPointExceptions>
<ErrorReporting>None</ErrorReporting>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<LinkStatus>false</LinkStatus>
<AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkErrorReporting>NoErrorReport</LinkErrorReporting>
<RandomizedBaseAddress>true</RandomizedBaseAddress>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,53 +0,0 @@
#pragma once
#include "types.h"
//jtype
#define OPCODE_J 2
#define OPCODE_JAL 3
//rtype
#define FUNCTION_JR 8
#define FUNCTION_BREAK 13
//itype
#define OPCODE_ORI 13
#define OPCODE_LUI 15
inline u32 ASM_JTYPE(const u32 opcode, const u32 target)
{
assert((target&3)==0);
assert(opcode<64);
const u32 _target = target & ~0xF0000000;
return (opcode<<26)|(_target>>2);
}
inline u32 ASM_JAL(const u32 target) { return ASM_JTYPE(OPCODE_JAL,target); }
inline u32 ASM_RTYPE(const u32 function, const u32 rs, const u32 rt, const u32 rd, const u32 sa)
{
assert(function<64);
assert(rs<32);
assert(rt<32);
assert(rd<32);
assert(sa<32);
return (rs<<21)|(rt<<16)|(rd<<11)|(sa<<6)|function;
}
inline u32 ASM_JR(const u32 rs) { return ASM_RTYPE(FUNCTION_JR, rs, 0, 0, 0); }
inline u32 ASM_NOP() { return 0; }
inline u32 ASM_BREAK(const u32 code)
{
assert(code<(1<<20));
return (code<<6)|FUNCTION_BREAK;
}
inline u32 ASM_ITYPE(const u32 opcode, const u32 rs, const u32 rt, const u32 immediate)
{
assert(opcode<64);
assert(rs<32);
assert(rt<32);
assert(immediate<65536);
return (opcode<<26)|(rs<<21)|(rt<<16)|immediate;
}
inline u32 ASM_LUI(const u32 rt, const u32 immediate) { return ASM_ITYPE(OPCODE_LUI,0,rt,immediate); }
inline u32 ASM_ORI(const u32 rt, const u32 rs, const u32 immediate) { return ASM_ITYPE(OPCODE_ORI,rs,rt,immediate); }

View File

@ -1,237 +0,0 @@
/*
this disassembler is courtesy of mednafen
*/
#include "psx.h"
#include "types.h"
#include <string>
#include <string.h>
//TODO - add break opcode to disassembly
namespace MDFN_IEN_PSX
{
struct OpEntry
{
u32 mask;
u32 value;
const char *mnemonic;
const char *format;
};
#define MASK_OP (0x3F << 26)
#define MASK_FUNC (0x3F)
#define MASK_RS (0x1F << 21)
#define MASK_RT (0x1F << 16)
#define MASK_RD (0x1F << 11)
#define MASK_SA (0x1F << 6)
#define MK_OP(mnemonic, format, op, func, extra_mask) { MASK_OP | (op ? 0 : MASK_FUNC) | extra_mask, (op << 26) | func, mnemonic, format }
#define MK_OP_REGIMM(mnemonic, regop) { MASK_OP | MASK_RT, (0x01 << 26) | (regop << 16), mnemonic, "s, p" }
static OpEntry ops[] =
{
MK_OP("nop", "", 0, 0, MASK_RT | MASK_RD | MASK_SA),
MK_OP("sll", "d, t, a", 0, 0, 0),
MK_OP("srl", "d, t, a", 0, 2, 0),
MK_OP("sra", "d, t, a", 0, 3, 0),
MK_OP("sllv", "d, t, s", 0, 4, 0),
MK_OP("srlv", "d, t, s", 0, 6, 0),
MK_OP("srav", "d, t, s", 0, 7, 0),
MK_OP("jr", "s", 0, 8, 0),
MK_OP("jalr", "d, s", 0, 9, 0),
MK_OP("syscall", "", 0, 12, 0), // TODO
MK_OP("break", "", 0, 13, 0), // TODO
MK_OP("mfhi", "d", 0, 16, 0),
MK_OP("mthi", "s", 0, 17, 0),
MK_OP("mflo", "d", 0, 18, 0),
MK_OP("mtlo", "s", 0, 19, 0),
MK_OP("mult", "s, t", 0, 24, 0),
MK_OP("multu", "s, t", 0, 25, 0),
MK_OP("div", "s, t", 0, 26, 0),
MK_OP("divu", "s, t", 0, 27, 0),
MK_OP("add", "d, s, t", 0, 32, 0),
MK_OP("addu", "d, s, t", 0, 33, 0),
MK_OP("sub", "d, s, t", 0, 34, 0),
MK_OP("subu", "d, s, t", 0, 35, 0),
MK_OP("and", "d, s, t", 0, 36, 0),
MK_OP("or", "d, s, t", 0, 37, 0),
MK_OP("xor", "d, s, t", 0, 38, 0),
MK_OP("nor", "d, s, t", 0, 39, 0),
MK_OP("slt", "d, s, t", 0, 42, 0),
MK_OP("sltu", "d, s, t", 0, 43, 0),
MK_OP_REGIMM("bgez", 0x01),
MK_OP_REGIMM("bgezal", 0x11),
MK_OP_REGIMM("bltz", 0x00),
MK_OP_REGIMM("bltzal", 0x10),
MK_OP("j", "P", 2, 0, 0),
MK_OP("jal", "P", 3, 0, 0),
MK_OP("beq", "s, t, p", 4, 0, 0),
MK_OP("bne", "s, t, p", 5, 0, 0),
MK_OP("blez", "s, p", 6, 0, 0),
MK_OP("bgtz", "s, p", 7, 0, 0),
MK_OP("addi", "t, s, i", 8, 0, 0),
MK_OP("addiu", "t, s, i", 9, 0, 0),
MK_OP("slti", "t, s, i", 10, 0, 0),
MK_OP("sltiu", "t, s, i", 11, 0, 0),
MK_OP("andi", "t, s, z", 12, 0, 0),
MK_OP("ori", "t, s, z", 13, 0, 0),
MK_OP("xori", "t, s, z", 14, 0, 0),
MK_OP("lui", "t, z", 15, 0, 0),
// COP0 stuff here
//#define MK_OP(mnemonic, format, op, func, extra_mask) { MASK_OP | (op ? 0 : MASK_FUNC) | extra_mask, (op << 26) | func, mnemonic, format }
#define COPMF(num) ((num)<<21)
MK_OP("mfc0", "t, D", 16, 0, 0x03E00000),
MK_OP("mfc1", "t, D", 17, 0, 0x03E00000),
MK_OP("mfc2", "t, D", 18, 0, 0x03E00000),
MK_OP("mfc3", "t, D", 19, 0, 0x03E00000),
MK_OP("mtc0", "t, D", 16, COPMF(4), 0x03E00000),
MK_OP("mtc1", "t, D", 17, COPMF(4), 0x03E00000),
MK_OP("mtc2", "t, D", 18, COPMF(4), 0x03E00000),
MK_OP("mtc3", "t, D", 19, COPMF(4), 0x03E00000),
//MK_OP("rfe", "", 19, COPMF(4), 0x03E00000), //TODO
MK_OP("lb", "t, i(s)", 32, 0, 0),
MK_OP("lh", "t, i(s)", 33, 0, 0),
MK_OP("lwl", "t, i(s)", 34, 0, 0),
MK_OP("lw", "t, i(s)", 35, 0, 0),
MK_OP("lbu", "t, i(s)", 36, 0, 0),
MK_OP("lhu", "t, i(s)", 37, 0, 0),
MK_OP("lwr", "t, i(s)", 38, 0, 0),
MK_OP("sb", "t, i(s)", 40, 0, 0),
MK_OP("sh", "t, i(s)", 41, 0, 0),
MK_OP("swl", "t, i(s)", 42, 0, 0),
MK_OP("sw", "t, i(s)", 43, 0, 0),
MK_OP("swr", "t, i(s)", 46, 0, 0),
{ 0, 0, NULL, NULL }
};
std::string DisassembleMIPS(u32 PC, u32 instr)
{
std::string ret = "UNKNOWN";
unsigned int rs = (instr >> 21) & 0x1F;
unsigned int rt = (instr >> 16) & 0x1F;
unsigned int rd = (instr >> 11) & 0x1F;
unsigned int shamt = (instr >> 6) & 0x1F;
unsigned int immediate = (s32)(s16)(instr & 0xFFFF);
unsigned int immediate_ze = (instr & 0xFFFF);
unsigned int jt = instr & ((1 << 26) - 1);
static const char *gpr_names[32] =
{
"r0", "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
"s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra"
};
OpEntry *op = ops;
while(op->mnemonic)
{
if((instr & op->mask) == op->value)
{
// a = shift amount
// s = rs
// t = rt
// d = rd
// i = immediate
// z = immediate, zero-extended
// p = PC + 4 + immediate
// P = ((PC + 4) & 0xF0000000) | (26bitval << 2)
char s_a[16];
char s_i[16];
char s_z[16];
char s_p[16];
char s_P[16];
char s_D[16];
_snprintf(s_D, sizeof(s_D), "%d", rd);
_snprintf(s_a, sizeof(s_a), "%d", shamt);
if(immediate < 0)
_snprintf(s_i, sizeof(s_i), "%d", immediate);
else
_snprintf(s_i, sizeof(s_i), "0x%04x", (u32)immediate);
_snprintf(s_z, sizeof(s_z), "0x%04x", immediate_ze);
_snprintf(s_p, sizeof(s_p), "0x%08x", PC + 4 + (immediate << 2));
_snprintf(s_P, sizeof(s_P), "0x%08x", ((PC + 4) & 0xF0000000) | (jt << 2));
ret = std::string(op->mnemonic);
ret.append(10 - ret.size(), ' ');
for(unsigned int i = 0; i < strlen(op->format); i++)
{
switch(op->format[i])
{
case 'a':
ret.append(s_a);
break;
case 'i':
ret.append(s_i);
break;
case 'z':
ret.append(s_z);
break;
case 'p':
ret.append(s_p);
break;
case 'P':
ret.append(s_P);
break;
case 's':
ret.append(gpr_names[rs]);
break;
case 't':
ret.append(gpr_names[rt]);
break;
case 'd':
ret.append(gpr_names[rd]);
break;
case 'D':
ret.append(s_D);
break;
default:
ret.append(1, op->format[i]);
break;
}
}
break;
}
op++;
}
return(ret);
}
}

View File

@ -1,15 +0,0 @@
/*
this disassembler is courtesy of mednafen
*/
#pragma once
#include <string>
#include "types.h"
namespace MDFN_IEN_PSX
{
std::string DisassembleMIPS(u32 PC, u32 instr);
}

View File

@ -1,53 +0,0 @@
/*
this file contains stuff which isn't realistic emulation but is used for loading and bootstrapping things
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "types.h"
#include "loader.h"
#include "asm.h"
void Load_BIOS(PSX& psx, const char* path)
{
FILE* inf = fopen(path,"rb");
fread(psx.bios,1,BIOS_SIZE,inf);
fclose(inf);
}
bool Load_EXE_Check(const char* fname)
{
//check for the PSX EXE signature
FILE* inf = fopen(fname, "rb");
char tmp[8] = {0};
fread(tmp,1,8,inf);
fclose(inf);
return !memcmp(tmp, "PS-X EXE", 8);
}
//TODO - we could load other format EXEs as well, not just PSX-EXE (psxjin appears to do this? check PSXGetFileType and Load() in misc.cpp)
void Load_EXE(PSX& psx, const wchar_t* fname)
{
FILE* inf = _wfopen(fname, L"rb");
PSX_EXE_Header header;
fread(&header,sizeof(PSX_EXE_Header),1,inf);
//load the text section to main memory
u32 text_destination = header.text_load_addr & RAM_MASK; //convert from virtual address to physical
fseek(inf, header.text_exe_offset + 0x800, SEEK_SET); //image addresses are relative to the image section of the file (past the 0x800 header)
fread(psx.ram+text_destination,1,header.text_size,inf);
//now, mednafen patches the bios to run its own routine loaded to PIO which loads the program from fake memory.
//i have a better idea. lets patch it with a special escape code which will run the bootstrapping code in C
psx.patch(0xBFC06990, ASM_BREAK(PSX::eFakeBreakOp_BootEXE));
psx.exeBootHeader = header;
//patch the kernel image section of the bios with traps for our bios hacks
psx.patch(0xBFC10000, ASM_BREAK(PSX::eFakeBreakOp_BiosHack)); //im not sure why we have to include these two. they must get chosen for some other reason to get patched into the kernel
psx.patch(0xBFC10010, ASM_BREAK(PSX::eFakeBreakOp_BiosHack)); //..
psx.patch(0xBFC10020, ASM_BREAK(PSX::eFakeBreakOp_BiosHack)); //this should correspond to 0xA0 in kernel area
psx.patch(0xBFC10030, ASM_BREAK(PSX::eFakeBreakOp_BiosHack)); //this should correspond to 0xB0 in kernel area
}

View File

@ -1,7 +0,0 @@
#pragma once
#include "psx.h"
__declspec(dllexport) bool Load_EXE_Check(const char* fname);
__declspec(dllexport) void Load_EXE(PSX& psx, const wchar_t* fname);
__declspec(dllexport) void Load_BIOS(PSX& psx, const char* path);

View File

@ -1,34 +0,0 @@
//#include <windows.h>
//#include <stdio.h>
//
//#include "psx.h"
//#include "loader.h"
//
//PSX psx;
//
//void main(int argc, char **argv)
//{
// //const char* target = argv[1];
// const char* target = "C:\\psxsdk\\projects\\helloworld\\main-sdk.exe";
//
// //can we load it as a PSX EXE? thats the only format we understand so far
// if(!Load_EXE_Check(target)) return;
//
// //initialize the psx
// psx.poweron(PSX::eConsoleType_DTL);
// Load_BIOS(psx, "SCPH5500.bin"); //JP bios (apparently thats what region our test programs are, or what mednafen ends up using)
// //Load_BIOS(psx, "scph5501.bin");
// //Load_BIOS(psx, "DTLH1100.bin");
// Load_EXE(psx, target);
// psx.reset();
//
// static const int work = 33*1024*1024*10;
// DWORD a = timeGetTime();
// for(;;)
// {
// psx.cpu_exec_cycle();
// if(psx.counter == work) break;
// }
// DWORD b = timeGetTime();
// printf("%d ms\n",b-a);
//}

File diff suppressed because it is too large Load Diff

View File

@ -1,592 +0,0 @@
/*
this file contains the core psx system and cpu emulation declarations.
implementations may be in several places.
*/
#pragma once
//#define NOCASE() __assume(0);
#define NOCASE()
#define ENABLE_CONOUT true
//#define DPRINT(...)
#define NOPRINT(...)
#define DPRINT(...) { fprintf(__VA_ARGS__); }
#define DEBUG(...) { DPRINT(stdout,__VA_ARGS__); }
#define DEBUG_PRINT(...) { NOPRINT(stderr,__VA_ARGS__); }
#define DEBUG_LOAD(...) { NOPRINT(stdout,__VA_ARGS__); }
#define DEBUG_STORE(...) { NOPRINT(stdout,__VA_ARGS__); }
#define DEBUG_TRACE(...) { DPRINT(stdout,__VA_ARGS__); }
#define DEBUG_HWREG(...) { DPRINT(stdout,__VA_ARGS__); }
#define DEBUG_SIO(...) { DPRINT(stdout,__VA_ARGS__); }
#define PSX_CLOCK 33868800
#include "types.h"
enum eOp
{
eOP_NULLIFIED, //nullified by exception
eOP_ILL,
eOP_SLL, eOP_SRL, eOP_SRA, eOP_SLLV,
eOP_SRLV, eOP_SRAV,
eOP_JR, eOP_JALR,
eOP_SYSCALL, eOP_BREAK,
eOP_MFHI, eOP_MTHI, eOP_MFLO, eOP_MTLO,
eOP_MULT, eOP_MULTU, eOP_DIV, eOP_DIVU,
eOP_ADD, eOP_ADDU,
eOP_SUB, eOP_SUBU,
eOP_AND, eOP_OR,
eOP_XOR, eOP_NOR,
eOP_SLT, eOP_SLTU,
eOP_NULL,
eOP_BCOND,
eOP_J, eOP_JAL,
eOP_BEQ, eOP_BNE, eOP_BLEZ, eOP_BGTZ,
eOP_ADDI, eOP_ADDIU,
eOP_SLTI, eOP_SLTIU,
eOP_ANDI, eOP_ORI,
eOP_XORI, eOP_LUI,
eOP_COPROC,
eOP_LB, eOP_LH, eOP_LWL, eOP_LW, eOP_LBU, eOP_LHU, eOP_LWR, eOP_SB, eOP_SH, eOP_SWL, eOP_SW, eOP_SWR,
eOP_LWC0, eOP_LWC1, eOP_LWC2, eOP_LWC3,
eOP_SWC0, eOP_SWC1, eOP_SWC2, eOP_SWC3
};
//reference PSXJIN sources for this
#pragma pack(push,1)
struct PSX_EXE_Header
{
char magic[8]; //PS-X EXE
u32 text_exe_offset; //location of text section in exe image
u32 data_exe_offset; //location of data section in exe image
u32 init_pc; //initial PC of program
u32 init_gp; //initial GP of program
u32 text_load_addr; //detination load address of text section
u32 text_size; //size of text section
u32 data_load_addr; //detination load address of data section
u32 data_size; //size of data section
u32 b_addr, b_size; //unknown
u32 stack_load_addr; //aka init_sp; initial SP of program
u32 stack_size; //stack size (not used?)
u32 saved_sp, saved_fp, saved_gp, saved_ra, saved_so; //not used
};
#pragma pack(pop)
#define RAM_SIZE (8*1024*1024)
#define RAM_MASK (RAM_SIZE-1)
#define VRAM_SIZE (1024*1024)
#define VRAM_MASK (VRAM_SIZE-1)
#define BIOS_SIZE (512*1024)
#define BIOS_MASK (BIOS_SIZE-1)
#define SCRATCH_SIZE (1024)
#define SCRATCH_MASK (SCRATCH_SIZE-1)
#define PIO_SIZE (65536)
#define PIO_MASK (PIO_SIZE-1)
//this class should try to organize all psx system state and methods as compactly as possible.
//let's not mix up anything else in here.
class __declspec(dllexport) PSX
{
public:
u8 vram[VRAM_SIZE];
u8 bios[BIOS_SIZE];
u8 scratch[SCRATCH_SIZE];
u8 pio[PIO_SIZE];
u8 ram[RAM_SIZE];
enum eScheduleItemType
{
eScheduleItemType_NIL, //used as a sentinel for list processing
eScheduleItemType_null,
eScheduleItemType_test, //to be removed later
eScheduleItemType_sio0,
eScheduleItemType_sio1,
eScheduleItemType_gpu,
eScheduleItemType_NUM
};
struct SCHED
{
struct IScheduleItem
{
u32 time;
eScheduleItemType next, prev;
};
union
{
IScheduleItem items[eScheduleItemType_NUM];
struct
{
IScheduleItem NIL, null, test;
IScheduleItem sio[2];
IScheduleItem gpu;
};
};
eScheduleItemType head;
u32 nextTime;
void escape() { nextTime = 0; }
//dequeues the head item from the list.
eScheduleItemType dequeue();
//removes the specified item from the list
void remove(eScheduleItemType todoType);
//inserts this item to the list in sorted order by timestamp
void insert(eScheduleItemType todoType);
} sched;
struct IRQ
{
static const u16 WIRE_MASK = 0x3FD;
union
{
struct
{
u16 vsync:1, gpu:1, cd:1, dma:1, rcnt0:1, rcnt1:1, rcnt2:1, sio0:1, sio1:1, spu:1, extcd:1;
u16 unknown2:6;
};
u16 value;
} flags;
union
{
struct
{
u16 vsync:1, gpu:1, cd:1, dma:1, rcnt0:1, rcnt1:1, rcnt2:1, sio0:1, sio1:1, spu:1, extcd:1;
u16 unknown2:6;
};
u16 value;
} mask;
} irq;
struct SystemRegs
{
//regs starting at 0x1f801000 accessed at bios init and maybe other times.
u32 biosInit[9]; //mednafen knows a little bit about these but doesnt use them for anything
} sysregs;
struct SioController
{
union
{
struct
{
u16 prescaler_type:2;
};
u16 value;
} mode;
union StatusReg
{
struct
{
u16 TX_RDY:1;
u16 RX_RDY:1;
u16 TX_EMPTY:1;
u16 nothing:1;
u16 OVERRUN:1;
u16 nothing2:2;
u16 DSR:1;
u16 nothing3:1;
u16 IRQ:1;
};
u16 value;
};
union ControlReg
{
struct
{
u16 TX_ENA:1;
u16 DTR:1; //this differs from mame's code (this seems to be the actual DTR signal. )
u16 nothing:2;
u16 IACK:1;
u16 nothing2:1;
u16 RESET:1;
u16 nothing3:3;
u16 TX_IENA:1;
u16 RX_IENA:1;
u16 DSR_IENA:1;
u16 PORT_SEL:1; //this differs from mame's code (this seems to be the port select). but that doesnt make sense because the 5x registers should be used for the other port. is the other port the actual serial i/o module?
};
u16 value;
};
StatusReg status;
ControlReg control;
u16 baud_reg;
//this is just used for diagnostic purposes (maybe it should be labeled as such?)
float CalculateBaud();
void Reset();
} sio[2];
struct CPU
{
enum eException //taken from mednafen
{
eException_INT = 0,
eException_MOD = 1,
eException_TLBL = 2,
eException_TLBS = 3,
eException_ADEL = 4, // Address error on load
eException_ADES = 5, // Address error on store
eException_IBE = 6, // Instruction bus error
eException_DBE = 7, // Data bus error
eException_SYSCALL = 8, // System call
eException_BP = 9, // Breakpoint
eException_RI = 10, // Reserved instruction
eException_COPU = 11, // Coprocessor unusable
eException_OV = 12, // Arithmetic overflow
eException_None = 16
};
union
{
struct
{
u32 r0, //should this be called zero or r0? well, psxjin and mednafen call it r0 so we'll stick with it
at, v0, v1, a0, a1, a2, a3,
t0, t1, t2, t3, t4, t5, t6, t7,
s0, s1, s2, s3, s4, s5, s6, s7,
t8, t9, k0, k1, gp,
sp, //29 - stack pointer
s8, //30 - ??
ra, //31 - return address (link register)
lo, hi;
//pc;
};
//Lo, Hi in r[33] and r[34];
//PC in r[35]
u32 r[34];
} regs;
union SR_REG
{
//these bits must be zero when read from the register (not wired to anything) [todo - check whether they cache values]
static const int ZERO_MASK = 0x8D8000C0;
//info taken from http://psx.rules.org/system.txt
struct
{
u32
IEc:1, //Interrupts Enabled current (0=enabled, 1=disabled)
KUc:1, //KUcurrent: privilege level (0=user, 1=kernel)
IEp:1, //?
KUp:1, //KUpushed: KUc pushes here on an exception, rfe pops KUo here
IEo:1, //Interrupts Enabled (0=enabled, 1=disabled) (rfe pops KUp here)
KUo:1, //KUother?: KUp gets pushed here on an exception
zeros:2,
IM:8, //interrupt mask fields (are these used in any way? im not sure. you would expect at least one of them to be) [bit2 maybe?]
IsC:1, //Isolate [data] Cache: unhook data cache from memory. PSX has no data cache, so this causes memory writes to get discarded
SwC:1, //Swap Cache: Not sure what this does on PSX but its suggested to use with IsC to invalidate the I-Cache. May need to investigate this.
PZ:1, //When set cache parity bits are written as 0
CM:1, //something relating to data cache
PE:1, //Cache parity error. Does not cause exception.
TS:1, //TLB shutdown. Gets set if a programm address simultaniously matches 2 TLB entries.
BEV:1, //boot exception vectors (0=ram, 1=rom [kseg1])
zeros_2:2,
RE:1, //reverse endianness. hope nobody uses this!
zeros_3:2,
CU0:1, //coprocessor 0 control (0=kernel mode, 1=user mode); controls access to certain instructions
CU1:1, //coprocessor 1 enabled (does nothing in PSX. should it return zeros?)
CU2:1, //coprocessor 2 enabled
zeros_4:1;
};
u32 value;
};
union CAUSE_REG
{
struct
{
u32 zeros_1:2;
u32 ExcCode:4;
u32 zeros_2:2;
u32 Sw:2; //software interrupts ?
u32 IP:6; //interrupts pending (external interrupts latched? IP[5..0] = Interrupt[5..0] according to r2000 arch doc)
u32 zeros_3:12;
u32 CE:2; //coprocessor error-which coprocessor threw a Coprocessor Unusable exception?
u32 zeros_4:1;
u32 BD:1; //set to 1 if the last exception was taken while executing in a branch delay slot
};
u32 value;
};
union
{
struct
{
u32
Index, Random, EntryLo0, EntryLo1,
Context, PageMask, Wired, Reserved0,
BadVAddr, Count, EntryHi, Compare;
SR_REG SR; //12 - status register
CAUSE_REG Cause; //13 - cause register
u32 EPC; //14 - the PC of the victim
u32 PRid; //15 - ??
u32
Config, LLAddr, WatchLO, WatchHI,
XContext, Reserved1, Reserved2, Reserved3,
Reserved4, Reserved5, ECC, CacheErr,
TagLo, TagHi, ErrorEPC, Reserved6;
};
u32 r[32];
} cp0;
enum eFormat
{
eFormat_IType, eFormat_RType, eFormat_JType_J, eFormat_JType_JAL, eFormat_CType, eFormat_Other
};
struct Instruction_ITYPE
{
u32 immediate:16;
s32 signed_offset() const { return (s16)immediate; }
s32 signed_target() const { return (signed_offset()<<2) + 4; /*hack!!! dunno how this PC accounting is supposed to work*/ }
u32 rt:5;
u32 rs:5;
u32 base() const { return rs; }
u32 opcode:6;
};
struct Instruction_CTYPE
{
u32 function:6;
u32 zeros:5;
u32 rd:5;
u32 rt:5;
u32 format:5;
u32 cpnum:2;
u32 opcode_hi:4;
};
union Instruction_RTYPE
{
struct
{
u32 function:6;
u32 sa:5;
u32 rd:5;
u32 rt:5;
u32 rs:5;
u32 opcode:6;
};
u32 value;
u32 break_code() const { return (value>>6)&0xFFFFF; }
};
struct Instruction_JTYPE
{
u32 target:26;
u32 opcode:6;
};
union Instruction
{
Instruction_ITYPE ITYPE;
Instruction_RTYPE RTYPE;
Instruction_JTYPE JTYPE;
Instruction_CTYPE CTYPE;
u32 value;
};
struct DecodedInstruction
{
Instruction instr;
eOp op;
};
struct {
bool IsRunning() const { return timer>0; }
u32 timer;
u32 lo, hi;
} unit_muldiv;
struct
{
u32 in_fetch_addr;
DecodedInstruction decode; //call this output?
} p_fetch;
struct
{
u32 instr;
u32 regs[3];
} p_rd;
enum eMemOp
{
eMemOp_Unset, eMemOp_None,
eMemOp_StoreWord, eMemOp_StoreHalfword, eMemOp_StoreByte,
eMemOp_LoadWord, eMemOp_LoadHalfwordSigned, eMemOp_LoadHalfwordUnsigned, eMemOp_LoadByteSigned, eMemOp_LoadByteUnsigned,
eMemOp_MTC, eMemOp_MFC,
};
struct ALU_OUTPUT
{
union
{
u32 addr;
};
union {
u32 value;
u32 rt;
};
eMemOp op;
};
struct ALU_PC_OUTPUT
{
u32 pc;
bool enabled;
};
struct P_ALU
{
DecodedInstruction decode;
//TODO its a shame to copy a big alu output every time.. try to avoid that somehow? thats a serious micro-optimization though..
ALU_OUTPUT out_mem;
ALU_PC_OUTPUT out_pc;
u32 in_pc;
CPU::eException exception;
} p_alu;
enum eStall
{
eStall_None=0,
eStall_MulDiv=1,
};
u32 stall_depends;
u32 stall_user;
struct
{
DecodedInstruction decode;
ALU_OUTPUT in_from_alu;
} p_mem;
enum eDelayState
{
eDelayState_None,
eDelayState_Branch, //set PC to a branch target arg
eDelayState_BranchRelative, //set PC relative (arg as s32) to current PC (that will be the PC of the instruction in the branch delay slot)
eDelayState_StoreWord, //store a word arg2 to memory at arg
eDelayState_StoreHalfword, //store a halfword arg2 to memory at arg
eDelayState_StoreByte, //store a byte arg2 to memory at arg
eDelayState_SetGPR, //set GPR arg to value arg2
eDelayState_MTCz, //set MTCz, reg # arg, to value arg2 (z and reg are packed into arg)
};
struct DelayState
{
eDelayState state;
u32 arg,arg2;
} delay;
} cpu;
enum eConsoleType
{
eConsoleType_Normal,
eConsoleType_DTL
};
struct
{
u32 ram_size;
u32 ram_mask;
} config;
void poweron(eConsoleType type);
void reset();
//execs one psx cycle
void exec_cycle();
void exec_shed(eScheduleItemType type);
static CPU::eFormat util_decode_format(u32 opcode);
void TraceALU();
void cpu_break(const u32 code);
void cpu_run_alu_bioshack(); //called once per cycle to implement bios hacks (stdout mostly)
void cpu_run_alu_bioshack_putchar(const u32 regval);
//debug-pokes a value into the psx address space (maybe rename to poke)
//TODO - make a check argument for sanity checking (to keep from patching the wrong thing)
void patch(const u32 addr, const u32 val);
//executes one cpu cycle
void cpu_exec_cycle();
//run each of the pipeline stages
void cpu_run_fetch();
void cpu_run_muldiv();
void cpu_run_alu();
void cpu_run_mem();
void cpu_run_wb();
//trigger an exception
void cpu_exception(CPU::eException ex, u32 pc_victim);
//coprocessor interfaces to be called from the alu pipeline
void cpu_copz_mtc(const u32 z, const u32 rd, const u32 value);
void cpu_cop0_mtc(const u32 rd, const u32 value);
u32 cpu_copz_mfc(const u32 z, const u32 rd);
u32 cpu_cop0_mfc(const u32 rd);
//main memory io interfaces
u32 cpu_fetch(const u32 addr);
template<int size> u32 cpu_rdmem(const u32 addr);
template<int size, bool POKE> void cpu_wrmem(const u32 addr, const u32 val);
template<int size> void cpu_wrmem(const u32 addr, const u32 val);
//memory mapping handlers
void cpu_wr_ram(const int size, const u32 addr, const u32 val);
u32 cpu_rd_ram(const int size, const u32 addr);
void cpu_wr_scratch(const int size, const u32 addr, const u32 val);
u32 cpu_rd_scratch(const int size, const u32 addr);
void cpu_wr_bios(const int size, const u32 addr, const u32 val);
u32 cpu_rd_bios(const int size, const u32 addr);
void cpu_wr_pio(const int size, const u32 addr, const u32 val);
u32 cpu_rd_pio(const int size, const u32 addr);
void cpu_wr_quick(u8* const buf, const int size, const u32 addr, const u32 val);
u32 cpu_rd_quick(const u8* const buf, const int size, const u32 addr);
void cpu_wr_hwreg(const int size, const u32 addr, const u32 val);
u32 cpu_rd_hwreg(const int size, const u32 addr);
void spu_wr(const int size, const u32 addr, const u32 val);
u32 spu_rd(const int size, const u32 addr);
void sio_wr(const int size, const u32 addr, const u32 val);
u32 sio_rd(const int size, const u32 addr);
//sets the dtr rising edge signal for the specified port (e.g. strobe signal; port should latch its values then presumably)
void sio_dtr(const u32 port);
u32 irq_rd(const int size, const u32 addr);
void irq_wr(const int size, const u32 addr, const u32 val);
void irq_update();
//miscellaneous not real stuff
u32 counter;
u64 abscounter;
//this will be used to boot the game if an appropriate signal is received
PSX_EXE_Header exeBootHeader;
enum eFakeBreakOp
{
eFakeBreakOp_None=0,
eFakeBreakOp_BootEXE=1,
eFakeBreakOp_BiosHack=2,
};
void RunForever();
void vblank_trigger();
};

View File

@ -1,102 +0,0 @@
/*
this file contains the sio subsystem emulation.
*/
#include "psx.h"
#include <assert.h>
#include <stdio.h>
#include <stddef.h>
static u8 getPrescaler(const u32 prescaler_type)
{
static const u8 prescalers[] = {0,1,16,64};
return prescalers[prescaler_type];
}
//information in this file is derived from observatoins in mednafen and mame
void PSX::SioController::Reset()
{
status.TX_EMPTY = 1;
status.TX_RDY = 1;
status.RX_RDY = 0;
status.OVERRUN = 0;
status.IRQ = 0;
}
float PSX::SioController::CalculateBaud()
{
return (float)PSX_CLOCK / this->baud_reg / getPrescaler(mode.prescaler_type);
}
void PSX::sio_wr(const int size, const u32 addr, const u32 val)
{
assert(size==2);
assert((addr&1)==0);
DEBUG_SIO("sio write size %d addr %08X = %08X\n",size,addr,val);
const u32 portnum = (addr>>4)&1;
SioController &port = sio[portnum];
switch(addr&0xF)
{
case 0x00:
break;
case 0x08:
port.mode.value = val;
printf("baud set to approx %f\n",port.CalculateBaud());
break;
case 0x0A:
{
SioController::ControlReg reg;
reg.value = val;
if(reg.RESET)
{
DEBUG_SIO("reset port %d\n",portnum);
port.Reset();
}
if(reg.IACK)
{
port.status.IRQ = 0;
port.control.IACK = 0;
//todo - irq sync
}
//check for rising edge of DTR signal and alert the appropriate port
if(port.control.DTR == 0 && reg.DTR == 1)
{
sio_dtr(port.control.PORT_SEL);
}
//replicate stored bits
port.control.TX_IENA = reg.RX_IENA;
port.control.RX_IENA = reg.RX_IENA;
port.control.DSR_IENA = reg.DSR_IENA;
port.control.DTR = reg.DTR;
port.control.PORT_SEL = reg.PORT_SEL;
}
break;
case 0x0E:
port.baud_reg = val;
printf("baud set to approx %f\n",port.CalculateBaud());
break;
default:
DEBUG_SIO("UNHANDLED\n");
}
}
void PSX::sio_dtr(const u32 port)
{
}
u32 PSX::sio_rd(const int size, const u32 addr)
{
assert(size==2);
assert((addr&1)==0);
u32 ret = 0;
DEBUG_SIO("sio read size %d addr %08X = %08X\n",size,addr,ret);
const u32 port = (addr>>4)&1;
return 0;
}

View File

@ -1,22 +0,0 @@
/*
compiler types and configuration
*/
#pragma once
#include <stdlib.h>
typedef __int8 s8;
typedef __int16 s16;
typedef __int32 s32;
typedef __int64 s64;
typedef unsigned __int8 u8;
typedef unsigned __int16 u16;
typedef unsigned __int32 u32;
typedef unsigned __int64 u64;
#define ABORT(message) { printf("%s\n",message); exit(0); }
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#ifndef CTASSERT
#define CTASSERT(x) typedef char __assert ## y[(x) ? 1 : -1]
#endif

View File

@ -1,341 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BizHawk.Emulation.Sound
{
/*
* old VRC6 audio.
* not quite a drop in replacement for the new one.
* doesn't sound right.
*/
class VRC6 : ISoundProvider
{
public void DiscardSamples() { }
public int MaxVolume { get; set; }
public void GetSamples(short[] samples)
{
for (int i = 0; i < samples.Length; )
{
short val = 0;
val = (short)(Pulse1.RenderSample() << 4);
val += (short)(Pulse2.RenderSample() << 7);
val += (short)(Sawtooth.RenderSample() << 7);
samples[i++] = val;
samples[i++] = val;
}
}
public VRC6()
{
MaxVolume = (short.MaxValue / 3);
}
public void SyncState(Serializer ser)
{
Pulse1.SyncState(ser);
Pulse2.SyncState(ser);
Sawtooth.SyncState(ser);
}
public void Write9000(byte value)
{
Pulse1.Write9000(value);
}
public void Write9001(byte value)
{
Pulse1.Write9001(value);
}
public void Write9002(byte value)
{
Pulse1.Write9002(value);
}
public void WriteA000(byte value)
{
Pulse2.WriteA000(value);
}
public void WriteA001(byte value)
{
Pulse2.WriteA001(value);
}
public void WriteA002(byte value)
{
Pulse2.WriteA002(value);
}
public void WriteB000(byte value)
{
Sawtooth.WriteB000(value);
}
public void WriteB001(byte value)
{
Sawtooth.WriteB001(value);
}
public void WriteB002(byte value)
{
Sawtooth.WriteB002(value);
}
private Chn_VRC6Pulse1 Pulse1 = new Chn_VRC6Pulse1();
private Chn_VRC6Pulse2 Pulse2 = new Chn_VRC6Pulse2();
private Chn_VRC6Sawtooth Sawtooth = new Chn_VRC6Sawtooth();
public class Chn_VRC6Pulse1
{
byte _Volume = 0;
double DutyPercentage = 0;
int _DutyCycle = 0;
int _FreqTimer = 0;
bool _Enabled = false;
double _Frequency = 0;
double _SampleCount = 0;
double _RenderedLength = 0;
bool WaveStatus = false;
short OUT = 0;
public void SyncState(Serializer ser)
{
ser.Sync("_Volume", ref _Volume);
//ser.Sync("DutyPercentage", ref DutyPercentage);
ser.Sync("_DutyCycle", ref _DutyCycle);
ser.Sync("_FreqTimer", ref _FreqTimer);
ser.Sync("_Enabled", ref _Enabled);
//ser.Sync("_Frequency", ref _Frequency);
//ser.Sync("_SampleCount", ref _SampleCount);
//ser.Sync("_RenderedLength", ref _RenderedLength);
ser.Sync("WaveStatus", ref WaveStatus);
ser.Sync("OUT", ref OUT);
}
public short RenderSample()
{
if (_Enabled)
{
_SampleCount++;
if (WaveStatus && (_SampleCount > (_RenderedLength * DutyPercentage)))
{
_SampleCount -= _RenderedLength * DutyPercentage;
WaveStatus = !WaveStatus;
}
else if (!WaveStatus && (_SampleCount > (_RenderedLength * (1.0 - DutyPercentage))))
{
_SampleCount -= _RenderedLength * (1.0 - DutyPercentage);
WaveStatus = !WaveStatus;
}
if (WaveStatus)
OUT = (short)(-_Volume);
else
OUT = (short)(_Volume);
return OUT;
}
return 0;
}
public void Write9000(byte data)
{
_Volume = (byte)(data & 0x0F);//Bit 0 - 3
_DutyCycle = (data >> 4); //Bit 4 - 7
if (_DutyCycle == 0)
DutyPercentage = 0.6250;
else if (_DutyCycle == 1)
DutyPercentage = 0.1250;
else if (_DutyCycle == 2)
DutyPercentage = 0.1875;
else if (_DutyCycle == 3)
DutyPercentage = 0.2500;
else if (_DutyCycle == 4)
DutyPercentage = 0.3125;
else if (_DutyCycle == 5)
DutyPercentage = 0.3750;
else if (_DutyCycle == 6)
DutyPercentage = 0.4375;
else if (_DutyCycle == 7)
DutyPercentage = 0.5000;
else
DutyPercentage = 1.0;
}
public void Write9001(byte data)
{
_FreqTimer = (_FreqTimer & 0x0F00) | data;
//Update freq
_Frequency = 1790000 / 16 / (_FreqTimer + 1);
_RenderedLength = 44100 / _Frequency;
}
public void Write9002(byte data)
{
_FreqTimer = (_FreqTimer & 0x00FF) | ((data & 0x0F) << 8);
_Enabled = (data & 0x80) != 0;
//Update freq
_Frequency = 1790000 / 16 / (_FreqTimer + 1);
_RenderedLength = 44100 / _Frequency;
}
}
public class Chn_VRC6Pulse2
{
byte _Volume = 0;
double DutyPercentage = 0;
int _DutyCycle = 0;
int _FreqTimer = 0;
bool _Enabled = false;
double _Frequency = 0;
double _SampleCount = 0;
double _RenderedLength = 0;
bool WaveStatus = false;
short OUT = 0;
public void SyncState(Serializer ser)
{
ser.Sync("_Volume", ref _Volume);
//ser.Sync("DutyPercentage", ref DutyPercentage);
ser.Sync("_DutyCycle", ref _DutyCycle);
ser.Sync("_FreqTimer", ref _FreqTimer);
ser.Sync("_Enabled", ref _Enabled);
//ser.Sync("_Frequency", ref _Frequency);
//ser.Sync("_SampleCount", ref _SampleCount);
//ser.Sync("_RenderedLength", ref _RenderedLength);
ser.Sync("WaveStatus", ref WaveStatus);
ser.Sync("OUT", ref OUT);
}
public short RenderSample()
{
if (_Enabled)
{
_SampleCount++;
if (WaveStatus && (_SampleCount > (_RenderedLength * DutyPercentage)))
{
_SampleCount -= _RenderedLength * DutyPercentage;
WaveStatus = !WaveStatus;
}
else if (!WaveStatus && (_SampleCount > (_RenderedLength * (1.0 - DutyPercentage))))
{
_SampleCount -= _RenderedLength * (1.0 - DutyPercentage);
WaveStatus = !WaveStatus;
}
if (WaveStatus)
OUT = (short)(-_Volume);
else
OUT = (short)(_Volume);
return OUT;
}
return 0;
}
public void WriteA000(byte data)
{
_Volume = (byte)(data & 0x0F);//Bit 0 - 3
_DutyCycle = (data >> 4); //Bit 4 - 7
if (_DutyCycle == 0)
DutyPercentage = 0.6250;
else if (_DutyCycle == 1)
DutyPercentage = 0.1250;
else if (_DutyCycle == 2)
DutyPercentage = 0.1875;
else if (_DutyCycle == 3)
DutyPercentage = 0.2500;
else if (_DutyCycle == 4)
DutyPercentage = 0.3125;
else if (_DutyCycle == 5)
DutyPercentage = 0.3750;
else if (_DutyCycle == 6)
DutyPercentage = 0.4375;
else if (_DutyCycle == 7)
DutyPercentage = 0.5000;
else
DutyPercentage = 1.0;
}
public void WriteA001(byte data)
{
_FreqTimer = (_FreqTimer & 0x0F00) | data;
//Update freq
_Frequency = 1790000 / 16 / (_FreqTimer + 1);
_RenderedLength = 44100 / _Frequency;
}
public void WriteA002(byte data)
{
_FreqTimer = (_FreqTimer & 0x00FF) | ((data & 0x0F) << 8);
_Enabled = (data & 0x80) != 0;
//Update freq
_Frequency = 1790000 / 16 / (_FreqTimer + 1);
_RenderedLength = 44100 / _Frequency;
}
}
public class Chn_VRC6Sawtooth
{
byte AccumRate = 0;
byte AccumStep = 0;
byte Accum = 0;
int _FreqTimer = 0;
bool _Enabled = false;
double _Frequency = 0;
double _SampleCount = 0;
double _RenderedLength = 0;
short OUT = 0;
public void SyncState(Serializer ser)
{
ser.Sync("AccumRate", ref AccumRate);
ser.Sync("AccumStep", ref AccumStep);
ser.Sync("Accum", ref Accum);
ser.Sync("_FreqTimer", ref _FreqTimer);
ser.Sync("_Enabled", ref _Enabled);
//ser.Sync("_Frequency", ref _Frequency);
//ser.Sync("_SampleCount", ref _SampleCount);
//ser.Sync("_RenderedLength", ref _RenderedLength);
ser.Sync("OUT", ref OUT);
}
public short RenderSample()
{
if (_Enabled)
{
_SampleCount++;
if (_SampleCount >= _RenderedLength)
{
_SampleCount -= _RenderedLength;
AccumStep++;
if ((AccumStep & 2) != 0)
Accum += AccumRate;
if (AccumStep >= 14)
AccumStep = Accum = 0;
OUT = (short)(Accum >> 3);
}
return (short)((OUT - 5));
}
return 0;
}
public void WriteB000(byte data)
{
AccumRate = (byte)(data & 0x3F);
}
public void WriteB001(byte data)
{
_FreqTimer = (_FreqTimer & 0x0F00) | data;
//Update freq
_Frequency = 1790000 / (_FreqTimer + 1);
_RenderedLength = 44100 / _Frequency;
}
public void WriteB002(byte data)
{
_FreqTimer = (_FreqTimer & 0x00FF) | ((data & 0x0F) << 8);
_Enabled = (data & 0x80) != 0;
//Update freq
_Frequency = 1790000 / (_FreqTimer + 1);
_RenderedLength = 44100 / _Frequency;
}
}
}
}