aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-11-04 15:13:01 +0100
committerStapleButter <thetotalworm@gmail.com>2017-11-04 15:13:01 +0100
commit5bea3cc530dfd1e334daeb57069e00a3ed457857 (patch)
tree862e25bc666ceb7442b964f8101b502437c3ea45
parent0a04efc33e97ccfb78d6c7a97350c89866c0f844 (diff)
3D: add support for 8bit accesses to GXSTAT (Golden Sun - Dark Dawn)
-rw-r--r--src/GPU3D.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp
index 0b68706..b890f7f 100644
--- a/src/GPU3D.cpp
+++ b/src/GPU3D.cpp
@@ -1940,6 +1940,33 @@ void WriteToGXFIFO(u32 val)
u8 Read8(u32 addr)
{
+ switch (addr)
+ {
+ case 0x04000600:
+ return GXStat & 0xFF;
+ case 0x04000601:
+ {
+ return ((GXStat >> 8) & 0xFF) |
+ (PosMatrixStackPointer & 0x1F) |
+ ((ProjMatrixStackPointer & 0x1) << 5);
+ }
+ case 0x04000602:
+ {
+ u32 fifolevel = CmdFIFO->Level();
+
+ return fifolevel & 0xFF;
+ }
+ case 0x04000603:
+ {
+ u32 fifolevel = CmdFIFO->Level();
+
+ return ((GXStat >> 24) & 0xFF) |
+ (fifolevel >> 8) |
+ (fifolevel < 128 ? (1<<1) : 0) |
+ (fifolevel == 0 ? (1<<2) : 0);
+ }
+ }
+
printf("unknown GPU3D read8 %08X\n", addr);
return 0;
}
@@ -1954,6 +1981,22 @@ u16 Read16(u32 addr)
case 0x04000320:
return 46; // TODO, eventually
+ case 0x04000600:
+ {
+ return (GXStat & 0xFFFF) |
+ ((PosMatrixStackPointer & 0x1F) << 8) |
+ ((ProjMatrixStackPointer & 0x1) << 13);
+ }
+ case 0x04000602:
+ {
+ u32 fifolevel = CmdFIFO->Level();
+
+ return (GXStat >> 16) |
+ fifolevel |
+ (fifolevel < 128 ? (1<<9) : 0) |
+ (fifolevel == 0 ? (1<<10) : 0);
+ }
+
case 0x04000604:
return NumPolygons;
case 0x04000606:
@@ -2027,6 +2070,22 @@ void Write8(u32 addr, u8 val)
AlphaRefVal = val & 0x1F;
AlphaRef = (DispCnt & (1<<2)) ? AlphaRefVal : 0;
return;
+
+ case 0x04000601:
+ if (val & 0x80)
+ {
+ GXStat &= ~0x8000;
+ ProjMatrixStackPointer = 0;
+ //PosMatrixStackPointer = 0;
+ TexMatrixStackPointer = 0;
+ }
+ return;
+ case 0x04000603:
+ val &= 0xC0;
+ GXStat &= 0x3FFFFFFF;
+ GXStat |= (val << 24);
+ CheckFIFOIRQ();
+ return;
}
if (addr >= 0x04000360 && addr < 0x04000380)
@@ -2076,6 +2135,22 @@ void Write16(u32 addr, u16 val)
case 0x0400035C:
FogOffset = val & 0x7FFF;
return;
+
+ case 0x04000600:
+ if (val & 0x8000)
+ {
+ GXStat &= ~0x8000;
+ ProjMatrixStackPointer = 0;
+ //PosMatrixStackPointer = 0;
+ TexMatrixStackPointer = 0;
+ }
+ return;
+ case 0x04000602:
+ val &= 0xC000;
+ GXStat &= 0x3FFFFFFF;
+ GXStat |= (val << 16);
+ CheckFIFOIRQ();
+ return;
}
if (addr >= 0x04000330 && addr < 0x04000340)