aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FIFO.cpp72
-rw-r--r--FIFO.h60
-rw-r--r--GPU3D.cpp21
-rw-r--r--NDS.cpp8
-rw-r--r--melonDS.cbp1
-rw-r--r--melonDS.depend6
6 files changed, 79 insertions, 89 deletions
diff --git a/FIFO.cpp b/FIFO.cpp
deleted file mode 100644
index e8525eb..0000000
--- a/FIFO.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Copyright 2016-2017 StapleButter
-
- This file is part of melonDS.
-
- melonDS is free software: you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation, either version 3 of the License, or (at your option)
- any later version.
-
- melonDS is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with melonDS. If not, see http://www.gnu.org/licenses/.
-*/
-
-#include "FIFO.h"
-
-
-FIFO::FIFO(u32 num)
-{
- NumEntries = num;
- Entries = new u32[num];
- Clear();
-}
-
-FIFO::~FIFO()
-{
- delete[] Entries;
-}
-
-void FIFO::Clear()
-{
- NumOccupied = 0;
- ReadPos = 0;
- WritePos = 0;
- Entries[ReadPos] = 0;
-}
-
-void FIFO::Write(u32 val)
-{
- if (IsFull()) return;
-
- Entries[WritePos] = val;
-
- WritePos++;
- if (WritePos >= NumEntries)
- WritePos = 0;
-
- NumOccupied++;
-}
-
-u32 FIFO::Read()
-{
- u32 ret = Entries[ReadPos];
- if (IsEmpty())
- return ret;
-
- ReadPos++;
- if (ReadPos >= NumEntries)
- ReadPos = 0;
-
- NumOccupied--;
- return ret;
-}
-
-u32 FIFO::Peek()
-{
- return Entries[ReadPos];
-}
diff --git a/FIFO.h b/FIFO.h
index 98f0079..b0f4182 100644
--- a/FIFO.h
+++ b/FIFO.h
@@ -21,17 +21,63 @@
#include "types.h"
+template<typename T>
class FIFO
{
public:
- FIFO(u32 num);
- ~FIFO();
+ FIFO(u32 num)
+ {
+ NumEntries = num;
+ Entries = new T[num];
+ Clear();
+ }
- void Clear();
+ ~FIFO()
+ {
+ delete[] Entries;
+ }
- void Write(u32 val);
- u32 Read();
- u32 Peek();
+
+ void Clear()
+ {
+ NumOccupied = 0;
+ ReadPos = 0;
+ WritePos = 0;
+ memset(&Entries[ReadPos], 0, sizeof(T));
+ }
+
+
+ void Write(u32 val)
+ {
+ if (IsFull()) return;
+
+ Entries[WritePos] = val;
+
+ WritePos++;
+ if (WritePos >= NumEntries)
+ WritePos = 0;
+
+ NumOccupied++;
+ }
+
+ T Read()
+ {
+ T ret = Entries[ReadPos];
+ if (IsEmpty())
+ return ret;
+
+ ReadPos++;
+ if (ReadPos >= NumEntries)
+ ReadPos = 0;
+
+ NumOccupied--;
+ return ret;
+ }
+
+ T Peek()
+ {
+ return Entries[ReadPos];
+ }
u32 Level() { return NumOccupied; }
bool IsEmpty() { return NumOccupied == 0; }
@@ -39,7 +85,7 @@ public:
private:
u32 NumEntries;
- u32* Entries;
+ T* Entries;
u32 NumOccupied;
u32 ReadPos, WritePos;
};
diff --git a/GPU3D.cpp b/GPU3D.cpp
index c4b7ee8..81b2705 100644
--- a/GPU3D.cpp
+++ b/GPU3D.cpp
@@ -20,24 +20,41 @@
#include <string.h>
#include "NDS.h"
#include "GPU.h"
+#include "FIFO.h"
namespace GPU3D
{
+typedef struct
+{
+ u8 Command;
+ u32 Param;
+
+} CmdFIFOEntry;
+
+FIFO<CmdFIFOEntry>* CmdFIFO;
+FIFO<CmdFIFOEntry>* CmdPIPE;
+
+
bool Init()
{
+ CmdFIFO = new FIFO<CmdFIFOEntry>(256);
+ CmdPIPE = new FIFO<CmdFIFOEntry>(4);
+
return true;
}
void DeInit()
{
- //
+ delete CmdFIFO;
+ delete CmdPIPE;
}
void Reset()
{
- //
+ CmdFIFO->Clear();
+ CmdPIPE->Clear();
}
}
diff --git a/NDS.cpp b/NDS.cpp
index b2d51ca..6761e04 100644
--- a/NDS.cpp
+++ b/NDS.cpp
@@ -91,8 +91,8 @@ u32 DMA9Fill[4];
u16 IPCSync9, IPCSync7;
u16 IPCFIFOCnt9, IPCFIFOCnt7;
-FIFO* IPCFIFO9; // FIFO in which the ARM9 writes
-FIFO* IPCFIFO7;
+FIFO<u32>* IPCFIFO9; // FIFO in which the ARM9 writes
+FIFO<u32>* IPCFIFO7;
u16 DivCnt;
u32 DivNumerator[2];
@@ -125,8 +125,8 @@ bool Init()
DMAs[6] = new DMA(1, 2);
DMAs[7] = new DMA(1, 3);
- IPCFIFO9 = new FIFO(16);
- IPCFIFO7 = new FIFO(16);
+ IPCFIFO9 = new FIFO<u32>(16);
+ IPCFIFO7 = new FIFO<u32>(16);
if (!NDSCart::Init()) return false;
if (!GPU::Init()) return false;
diff --git a/melonDS.cbp b/melonDS.cbp
index 702a9a8..fb32d8b 100644
--- a/melonDS.cbp
+++ b/melonDS.cbp
@@ -51,7 +51,6 @@
<Unit filename="CP15.h" />
<Unit filename="DMA.cpp" />
<Unit filename="DMA.h" />
- <Unit filename="FIFO.cpp" />
<Unit filename="FIFO.h" />
<Unit filename="GPU.cpp" />
<Unit filename="GPU.h" />
diff --git a/melonDS.depend b/melonDS.depend
index cce2416..9c8795b 100644
--- a/melonDS.depend
+++ b/melonDS.depend
@@ -10,7 +10,7 @@
1481161027 c:\documents\sources\melonds\types.h
-1486502137 source:c:\documents\sources\melonds\nds.cpp
+1486503537 source:c:\documents\sources\melonds\nds.cpp
<stdio.h>
<string.h>
"NDS.h"
@@ -80,7 +80,7 @@
1486502258 c:\documents\sources\melonds\spi.h
-1486163389 source:c:\documents\sources\melonds\spi.cpp
+1486502498 source:c:\documents\sources\melonds\spi.cpp
<stdio.h>
<string.h>
"NDS.h"
@@ -105,7 +105,7 @@
1486501225 source:c:\documents\sources\melonds\fifo.cpp
"FIFO.h"
-1486501199 c:\documents\sources\melonds\fifo.h
+1486503492 c:\documents\sources\melonds\fifo.h
"types.h"
1486309616 source:c:\documents\sources\melonds\dma.cpp