Skip to content

Commit 8767d46

Browse files
authored
Merge pull request #2 from rickgaiser/fixes
Fix DMA transfers and add PAL mode to display settings
2 parents e4158bd + 9415310 commit 8767d46

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

include/ps2s/displayenv.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class CDisplayEnv {
104104
unsigned int screenX = 0, unsigned int screenY = 0,
105105
unsigned int magH = 4, unsigned int magV = 1);
106106

107-
inline void GsDisplayModeIs(tDisplayMode mode);
107+
inline void SetDisplayMode(tDisplayMode mode);
108108

109109
// blending the two read circuits
110110
inline void BlendRC1WithBG(void) { gsrPMode.SLBG = 1; }
@@ -156,20 +156,26 @@ class CDisplayEnv {
156156
unsigned int psm);
157157
} __attribute((aligned(16)));
158158

159-
void CDisplayEnv::GsDisplayModeIs(tDisplayMode mode)
159+
void CDisplayEnv::SetDisplayMode(tDisplayMode mode)
160160
{
161161
using namespace DisplayModes;
162+
162163
switch (mode) {
163164
case ntsc:
164165
HorizontalOverScan = 158 * 4;
165166
VerticalOverScan = 50 * 1;
166167
break;
168+
case pal:
169+
HorizontalOverScan = 158 * 4; // untested!
170+
VerticalOverScan = 50 * 1; // untested!
171+
break;
167172
case dtv:
168173
HorizontalOverScan = 302;
169174
VerticalOverScan = 24;
170175
break;
171176
default:
172177
mError("This display mode isn't handled yet..somebody type in the values.");
178+
return;
173179
}
174180
}
175181

src/displayenv.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include "ps2s/displayenv.h"
1212
#include "ps2s/utils.h"
1313

14+
#include <kernel.h>
15+
1416
namespace GS {
1517

1618
/********************************************
@@ -24,7 +26,7 @@ CDisplayEnv::CDisplayEnv(void)
2426
gsrPMode.CRTMD = 0;
2527

2628
// some reasonable (?) defaults
27-
GsDisplayModeIs(DisplayModes::ntsc);
29+
SetDisplayMode(DisplayModes::ntsc);
2830
SetUseReadCircuit1(false);
2931
SetUseReadCircuit2(true);
3032
BlendRC1WithRC2();
@@ -79,12 +81,12 @@ void CDisplayEnv::SetDisplay(tGsrDisplay* displayReg,
7981
void CDisplayEnv::SendSettings(void)
8082
{
8183
using namespace GS::ControlRegs;
82-
//*(tU64*)pmode = *(tU64*)&gsrPMode;
83-
*(tU64*)dispfb1 = *(tU64*)&gsrDispFB1;
84-
*(tU64*)dispfb2 = *(tU64*)&gsrDispFB2;
85-
//*(tU64*)display1 = *(tU64*)&gsrDisplay1;
86-
//*(tU64*)display2 = *(tU64*)&gsrDisplay2;
87-
*(tU64*)bgcolor = *(tU64*)&gsrBGColor;
84+
*(tU64*)pmode = *(tU64*)&gsrPMode;
85+
*(tU64*)dispfb1 = *(tU64*)&gsrDispFB1;
86+
*(tU64*)dispfb2 = *(tU64*)&gsrDispFB2;
87+
*(tU64*)display1 = *(tU64*)&gsrDisplay1;
88+
*(tU64*)display2 = *(tU64*)&gsrDisplay2;
89+
*(tU64*)bgcolor = *(tU64*)&gsrBGColor;
8890
}
8991

9092
} // namespace GS

src/packet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ void CDmaPacket::Send(bool waitForEnd, bool flushCache)
8989
// FlushCache(0);
9090

9191
// clear any memory mappings (this won't work for sp)
92-
dma_channel_fast_waits(dmaChannelId);
92+
dma_channel_wait(dmaChannelId, 1000000);
9393
dma_channel_send_normal(dmaChannelId, (void*)((tU32)pBase & 0x0fffffff), pktQWLength, 0, 0);
9494

9595
if (waitForEnd)
96-
dma_channel_fast_waits(dmaChannelId);
96+
dma_channel_wait(dmaChannelId, 1000000);
9797
}
9898

9999
void CDmaPacket::HexDump(tU32 numQwords)
100100
{
101101
if (numQwords == 0)
102102
numQwords = ((tU32)pNext - (tU32)pBase) / 16;
103103

104-
printf("dumping %d words\n", ((tU32)pNext - (tU32)pBase) / 4);
104+
printf("dumping %d words (%d qwords)\n", ((tU32)pNext - (tU32)pBase) / 4, numQwords);
105105

106106
tU32 i = 0;
107107
for (tU32 *nextWord = (tU32*)pBase; nextWord != (tU32*)pNext; nextWord++, i++) {
@@ -152,11 +152,11 @@ void CSCDmaPacket::Send(bool waitForEnd, bool flushCache)
152152
FlushCache(0);
153153

154154
// clear any memory mappings (this won't work for sp)
155-
dma_channel_fast_waits(dmaChannelId);
155+
dma_channel_wait(dmaChannelId, 1000000);
156156
dma_channel_send_chain(dmaChannelId, (void*)((tU32)pBase & 0x0fffffff), 0, bTTE ? DMA_FLAG_TRANSFERTAG : 0, 0);
157157

158158
if (waitForEnd)
159-
dma_channel_fast_waits(dmaChannelId);
159+
dma_channel_wait(dmaChannelId, 1000000);
160160
}
161161

162162
/********************************************

0 commit comments

Comments
 (0)