2024-08-16 11:06:40 +08:00
|
|
|
using System;
|
|
|
|
using static Util;
|
|
|
|
|
|
|
|
namespace OptimeGBA
|
|
|
|
{
|
|
|
|
public class Cp15
|
|
|
|
{
|
2024-08-16 14:51:15 +08:00
|
|
|
/*Nds Nds;
|
2024-08-16 11:06:40 +08:00
|
|
|
|
|
|
|
public Cp15(Nds nds)
|
|
|
|
{
|
|
|
|
Nds = nds;
|
2024-08-16 14:51:15 +08:00
|
|
|
}*/
|
2024-08-16 11:06:40 +08:00
|
|
|
|
|
|
|
public uint ControlRegister;
|
|
|
|
|
|
|
|
public uint DataTcmSettings;
|
|
|
|
public uint InstTcmSettings;
|
|
|
|
|
|
|
|
public void TransferTo(uint opcode1, uint rdVal, uint cRn, uint cRm, uint opcode2)
|
|
|
|
{
|
|
|
|
uint reg = ((cRn & 0xF) << 8) | ((cRm & 0xF) << 4) | (opcode2 & 0x7);
|
|
|
|
|
|
|
|
switch (reg)
|
|
|
|
{
|
|
|
|
case 0x100:
|
|
|
|
ControlRegister = rdVal;
|
|
|
|
ControlRegister |= 0b00000000000000000000000001111000;
|
|
|
|
ControlRegister &= 0b00000000000011111111000010000101;
|
2024-08-16 14:51:15 +08:00
|
|
|
//Nds.Mem9.UpdateTcmSettings();
|
2024-08-16 11:06:40 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x704:
|
|
|
|
case 0x782:
|
2024-08-16 14:51:15 +08:00
|
|
|
//Nds.Cpu9.Halted = true;
|
2024-08-16 11:06:40 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 0x910:
|
|
|
|
DataTcmSettings = rdVal;
|
2024-08-16 14:51:15 +08:00
|
|
|
//Nds.Mem9.UpdateTcmSettings();
|
2024-08-16 11:06:40 +08:00
|
|
|
break;
|
|
|
|
case 0x911:
|
|
|
|
InstTcmSettings = rdVal;
|
2024-08-16 14:51:15 +08:00
|
|
|
//Nds.Mem9.UpdateTcmSettings();
|
2024-08-16 11:06:40 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-08-16 14:51:15 +08:00
|
|
|
// Debug.Log($"UNIMPLEMENTED TO CP15 {opcode1},C{cRn},C{cRm},{opcode2}: {HexN(rdVal, 8)}");
|
2024-08-16 11:06:40 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public uint TransferFrom(uint opcode1, uint cRn, uint cRm, uint opcode2)
|
|
|
|
{
|
|
|
|
uint val = 0;
|
|
|
|
|
|
|
|
uint reg = ((cRn & 0xF) << 8) | ((cRm & 0xF) << 4) | (opcode2 & 0x7);
|
|
|
|
switch (reg)
|
|
|
|
{
|
|
|
|
case 0x000: // ID register
|
|
|
|
val = 0x41059461;
|
|
|
|
break;
|
|
|
|
case 0x001:
|
|
|
|
val = 0x0F0D2112;
|
|
|
|
break;
|
|
|
|
case 0x100:
|
|
|
|
val = ControlRegister;
|
|
|
|
break;
|
|
|
|
case 0x910:
|
|
|
|
val = DataTcmSettings;
|
|
|
|
break;
|
|
|
|
case 0x911:
|
|
|
|
val = InstTcmSettings;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2024-08-16 14:51:15 +08:00
|
|
|
//Debug.Log($"UNIMPLEMENTED FROM CP15 {opcode1},C{cRn},C{cRm},{opcode2}");
|
2024-08-16 11:06:40 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|