Skip to content

Commit 975796b

Browse files
authored
Mark pFrame->nMode and pSound->eMode as volatile (#243)
1 parent 3f05bf7 commit 975796b

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

include/emulator/frame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ typedef struct Frame {
300300
/* 0x00080 0x00070 */ f32 rScaleX;
301301
/* 0x00084 0x00074 */ f32 rScaleY;
302302
/* 0x00088 0x00078 */ u32 nCountFrames;
303-
/* 0x0008C 0x0007C */ u32 nMode;
303+
/* 0x0008C 0x0007C */ volatile u32 nMode;
304304
/* 0x00090 0x00080 */ u32 aMode[FMT_COUNT];
305305
/* 0x000B8 0x000A8 */ Viewport viewport;
306306
/* 0x000C8 0x000B8 */ FrameBuffer aBuffer[FBT_COUNT];

include/emulator/soundGCN.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct Sound {
3939
/* 0xA0 */ void* apDataBeep[SOUND_BEEP_COUNT];
4040
/* 0xAC */ s32 iBufferPlay;
4141
/* 0xB0 */ s32 iBufferMake;
42-
/* 0xB4 */ SoundPlayMode eMode;
42+
/* 0xB4 */ volatile SoundPlayMode eMode;
4343
/* 0xB8 */ void* pBufferZero;
4444
/* 0xBC */ void* pBufferHold;
4545
/* 0xC0 */ void* pBufferRampUp;

src/emulator/_frameGCN.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@ static bool frameLoadTexture(Frame* pFrame, FrameTexture* pTexture, s32 iTexture
15101510
bool frameDrawSetup2D(Frame* pFrame) {
15111511
Mtx44 matrix44;
15121512

1513-
if (!(*(volatile u32*)&pFrame->nMode & 0x40000000)) {
1513+
if (!(pFrame->nMode & 0x40000000)) {
15141514
pFrame->nMode |= 0x40000000;
15151515

15161516
GXSetViewport(0.0f, 0.0f, pFrame->anSizeX[1], pFrame->anSizeY[1], 0.0f, 1.0f);
@@ -2716,7 +2716,7 @@ static bool frameDrawRectFill(Frame* pFrame, Rectangle* pRectangle) {
27162716
pFrame->aColor[FCT_FILL].b == 0xF0 && pFrame->aColor[FCT_FILL].a == 0x00) {
27172717
bFlag = true;
27182718
}
2719-
if (bFlag && !(*(volatile u32*)&pFrame->nMode & 0x100000)) {
2719+
if (bFlag && !(pFrame->nMode & 0x100000)) {
27202720
pFrame->nMode |= 0x100000;
27212721
return true;
27222722
}

src/emulator/frame.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ bool frameSetMode(Frame* pFrame, FrameModeType eType, u32 nMode) {
475475
nModeChanged = pFrame->aMode[eType] ^ nMode;
476476
} else {
477477
nModeChanged = 0xFFFFFFFF;
478-
*((volatile u32*)&pFrame->nMode) |= (1 << eType);
478+
pFrame->nMode |= 1 << eType;
479479
}
480480

481481
nFlag = 0;
@@ -596,9 +596,7 @@ bool frameSetMatrix(Frame* pFrame, Mtx44 matrix, FrameMatrixType eType, bool bLo
596596
bLoad = false;
597597
}
598598

599-
// TODO: fake volatile
600-
if (bLoad || !(*(volatile u32*)&pFrame->nMode & 0x4000000) ||
601-
(*(volatile u32*)&pFrame->nMode & 0x10000000)) {
599+
if (bLoad || !(pFrame->nMode & 0x4000000) || (pFrame->nMode & 0x10000000)) {
602600
if (matrix[0][0] == 1.0f && matrix[0][1] == 0.0f && matrix[0][2] == 0.0f && matrix[0][3] == 0.0f &&
603601
matrix[1][0] == 0.0f && matrix[1][1] == 1.0f && matrix[1][2] == 0.0f && matrix[1][3] == 0.0f &&
604602
matrix[2][0] == 0.0f && matrix[2][1] == 0.0f && matrix[2][2] == 1.0f && matrix[2][3] == 0.0f &&
@@ -617,7 +615,7 @@ bool frameSetMatrix(Frame* pFrame, Mtx44 matrix, FrameMatrixType eType, bool bLo
617615
if (!frameGetMatrixHint(pFrame, nAddressN64 | 0x80000000, &pFrame->iHintProjection)) {
618616
pFrame->iHintProjection = -1;
619617
}
620-
} else if (*(volatile u32*)&pFrame->nMode & 0x8000000) {
618+
} else if (pFrame->nMode & 0x8000000) {
621619
PSMTX44Concat(matrix, pFrame->matrixProjectionExtra, pFrame->matrixProjectionExtra);
622620
} else {
623621
pFrame->nMode |= 0x8000000;
@@ -767,8 +765,7 @@ bool frameLoadVertex(Frame* pFrame, void* pBuffer, s32 iVertex0, s32 nCount) {
767765

768766
matrixModel = pFrame->aMatrixModel[pFrame->iMatrixModel];
769767
if (pFrame->nMode & 0x08000000) {
770-
// TODO: volatile hacks
771-
if (!(*(volatile u32*)&pFrame->nMode & 0x400000)) {
768+
if (!(pFrame->nMode & 0x400000)) {
772769
PSMTX44Concat(matrixModel, pFrame->matrixProjectionExtra, pFrame->matrixView);
773770
pFrame->nMode |= 0x400000;
774771
if (pFrame->iHintProjection != -1) {
@@ -779,8 +776,7 @@ bool frameLoadVertex(Frame* pFrame, void* pBuffer, s32 iVertex0, s32 nCount) {
779776
}
780777
}
781778
matrixView = pFrame->matrixView;
782-
// TODO: volatile hacks
783-
} else if (!(*(volatile u32*)&pFrame->nMode & 0x400000) && pFrame->iHintProjection != -1) {
779+
} else if (!(pFrame->nMode & 0x400000) && pFrame->iHintProjection != -1) {
784780
if (!frameScaleMatrix(pFrame->matrixView, matrixModel, pFrame->aMatrixHint[pFrame->iHintProjection].rScale)) {
785781
return false;
786782
}

src/emulator/soundGCN.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ bool soundPlayBuffer(Sound* pSound) {
179179
pSound->iBufferPlay = (iBuffer + 1) % 16;
180180
}
181181
pSound->eMode = SPM_PLAY;
182-
//! TODO: fake match on the following condition?
183-
} else if ((*((volatile SoundPlayMode*)&pSound->eMode) == SPM_RAMPQUEUED) || (pSound->eMode == SPM_RAMPPLAYED)) {
182+
} else if (pSound->eMode == SPM_RAMPQUEUED || pSound->eMode == SPM_RAMPPLAYED) {
184183
pData = pSound->pBufferZero;
185184
nSize = pSound->nSizeZero;
186185
pSound->eMode = SPM_RAMPPLAYED;

0 commit comments

Comments
 (0)