aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2017-02-17 18:59:11 +0100
committerStapleButter <thetotalworm@gmail.com>2017-02-17 18:59:11 +0100
commit97d76addd9c876a3438e8af1f83acc8bd20be70a (patch)
tree155952e412997358d117373105016af2f9c77eb3
parentcca0a71d8178284629d8a9f31fbe4c2538650c9e (diff)
fix a bunch of GXFIFO related bugs.
-rw-r--r--ARM.cpp1
-rw-r--r--DMA.cpp7
-rw-r--r--GPU3D.cpp32
-rw-r--r--NDS.cpp2
-rw-r--r--melonDS.depend8
5 files changed, 25 insertions, 25 deletions
diff --git a/ARM.cpp b/ARM.cpp
index 10b8795..536c78c 100644
--- a/ARM.cpp
+++ b/ARM.cpp
@@ -328,6 +328,7 @@ s32 ARM::Execute()
else
{
Cycles = CyclesToRun;
+ GPU3D::Run(CyclesToRun >> 1);
return Cycles;
}
}
diff --git a/DMA.cpp b/DMA.cpp
index 28f7ddc..629c14f 100644
--- a/DMA.cpp
+++ b/DMA.cpp
@@ -46,7 +46,7 @@ DMA::DMA(u32 cpu, u32 num)
Waitstates[1][i] = 1;
}
- if (!num)
+ if (!cpu)
{
// ARM9
// note: 33MHz cycles
@@ -206,8 +206,6 @@ s32 DMA::Run(s32 cycles)
if (!Running)
return cycles;
- u32 zorp = IterCount;
-
if (!(Cnt & 0x04000000))
{
u16 (*readfn)(u32) = CPU ? NDS::ARM7Read16 : NDS::ARM9Read16;
@@ -250,6 +248,9 @@ s32 DMA::Run(s32 cycles)
{
Running = false;
NDS::StopCPU(CPU, false);
+
+ if (StartMode & 0x07)
+ GPU3D::CheckFIFODMA();
}
return cycles;
diff --git a/GPU3D.cpp b/GPU3D.cpp
index c28ebd0..de860f2 100644
--- a/GPU3D.cpp
+++ b/GPU3D.cpp
@@ -848,7 +848,6 @@ void CmdFIFOWrite(CmdFIFOEntry& entry)
if (CmdFIFO->IsEmpty() && !CmdPIPE->IsFull())
{
CmdPIPE->Write(entry);
- GXStat |= (1<<27);
}
else
{
@@ -890,24 +889,19 @@ void ExecuteCommand()
{
CmdFIFOEntry entry = CmdFIFORead();
- //printf("FIFO: %02X %08X\n", entry.Command, entry.Param);
+ //printf("FIFO: processing %02X %08X. Levels: FIFO=%d, PIPE=%d\n", entry.Command, entry.Param, CmdFIFO->Level(), CmdPIPE->Level());
ExecParams[ExecParamCount] = entry.Param;
ExecParamCount++;
- //if ((entry.Command&0xF0)==0x10)
- // printf("MATRIX CMD %02X %08X\n", entry.Command, entry.Param);
-
if (ExecParamCount >= CmdNumParams[entry.Command])
{
CycleCount += CmdNumCycles[entry.Command];
ExecParamCount = 0;
GXStat &= ~(1<<14);
- //if (CycleCount > 0)
- // GXStat |= (1<<27);
-
- //printf("3D CMD %02X\n", entry.Command);
+ if (CycleCount > 0)
+ GXStat |= (1<<27);
switch (entry.Command)
{
@@ -1268,6 +1262,10 @@ void Run(s32 cycles)
{
if (FlushRequest)
return;
+ if (CycleCount <= 0 && CmdPIPE->IsEmpty())
+ return;
+
+ CycleCount -= cycles;
if (CycleCount <= 0)
{
@@ -1275,12 +1273,10 @@ void Run(s32 cycles)
ExecuteCommand();
}
- CycleCount -= cycles;
-
if (CycleCount <= 0 && CmdPIPE->IsEmpty())
{
CycleCount = 0;
- GXStat &= ~(1<<27);
+ GXStat &= ~((1<<27)|(1<<14));
}
}
@@ -1318,7 +1314,6 @@ void VBlank()
NumPolygons = 0;
FlushRequest = 0;
- GXStat &= ~(1<<27);
}
}
@@ -1410,10 +1405,13 @@ void Write32(u32 addr, u32 val)
for (;;)
{
- CmdFIFOEntry entry;
- entry.Command = CurCommand & 0xFF;
- entry.Param = val;
- CmdFIFOWrite(entry);
+ if ((CurCommand & 0xFF) || (NumCommands == 4))
+ {
+ CmdFIFOEntry entry;
+ entry.Command = CurCommand & 0xFF;
+ entry.Param = val;
+ CmdFIFOWrite(entry);
+ }
if (ParamCount >= TotalParams)
{
diff --git a/NDS.cpp b/NDS.cpp
index 655e7ab..182abe1 100644
--- a/NDS.cpp
+++ b/NDS.cpp
@@ -311,7 +311,7 @@ void Reset()
// test
//LoadROM();
//LoadFirmware();
- if (NDSCart::LoadROM("rom/raving.nds"))
+ if (NDSCart::LoadROM("rom/nsmb.nds"))
Running = true; // hax
}
diff --git a/melonDS.depend b/melonDS.depend
index d862460..bdce235 100644
--- a/melonDS.depend
+++ b/melonDS.depend
@@ -10,7 +10,7 @@
1481161027 c:\documents\sources\melonds\types.h
-1487304040 source:c:\documents\sources\melonds\nds.cpp
+1487349286 source:c:\documents\sources\melonds\nds.cpp
<stdio.h>
<string.h>
"NDS.h"
@@ -24,7 +24,7 @@
"RTC.h"
"Wifi.h"
-1486736660 source:c:\documents\sources\melonds\arm.cpp
+1487349559 source:c:\documents\sources\melonds\arm.cpp
<stdio.h>
"NDS.h"
"ARM.h"
@@ -109,7 +109,7 @@
1486511075 c:\documents\sources\melonds\fifo.h
"types.h"
-1487305720 source:c:\documents\sources\melonds\dma.cpp
+1487354030 source:c:\documents\sources\melonds\dma.cpp
<stdio.h>
"NDS.h"
"DMA.h"
@@ -148,7 +148,7 @@
1487287868 c:\documents\sources\melonds\gpu3d.h
-1487305740 source:c:\documents\sources\melonds\gpu3d.cpp
+1487354054 source:c:\documents\sources\melonds\gpu3d.cpp
<stdio.h>
<string.h>
"NDS.h"