Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 14 additions & 25 deletions src/SB/Core/gc/iMix.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ void MIXInit()
__MIXSoundMode = OSGetSoundMode();
}

void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 param_5,
S32 param_6, S32 param_7, S32 param_8)
void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 param_5, S32 param_6,
S32 param_7, S32 param_8)
{
struct MIXChannel* chan = &__MIXChannel[*(S32*)((S32)param_1 + 0x18)];

Expand Down Expand Up @@ -271,8 +271,7 @@ void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 para
{
*(U16*)(&chan->data[0x12]) = __MIXGetVolume(chan->data[3] + chan->data[10]);
*(U16*)(&chan->data[0x13]) = __MIXGetVolume(chan->data[3] + chan->data[10]);
*(U16*)(&chan->data[0x14]) =
__MIXGetVolume(chan->data[3] + chan->data[11] - 0x3c);
*(U16*)(&chan->data[0x14]) = __MIXGetVolume(chan->data[3] + chan->data[11] - 0x3c);
}
else
{
Expand All @@ -288,8 +287,7 @@ void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 para
{
*(U16*)(&chan->data[0x15]) = __MIXGetVolume(chan->data[4] + chan->data[10]);
*(U16*)(&chan->data[0x16]) = __MIXGetVolume(chan->data[4] + chan->data[10]);
*(U16*)(&chan->data[0x17]) =
__MIXGetVolume(chan->data[4] + chan->data[11] - 0x3c);
*(U16*)(&chan->data[0x17]) = __MIXGetVolume(chan->data[4] + chan->data[11] - 0x3c);
}
else
{
Expand All @@ -305,10 +303,8 @@ void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 para

case 1:
case 2:
*(U16*)(&chan->data[0xf]) =
__MIXGetVolume(chan->data[7] + chan->data[8] + chan->data[10]);
*(U16*)(&chan->data[0x10]) =
__MIXGetVolume(chan->data[7] + chan->data[9] + chan->data[10]);
*(U16*)(&chan->data[0xf]) = __MIXGetVolume(chan->data[7] + chan->data[8] + chan->data[10]);
*(U16*)(&chan->data[0x10]) = __MIXGetVolume(chan->data[7] + chan->data[9] + chan->data[10]);
*(U16*)(&chan->data[0x11]) = __MIXGetVolume(chan->data[7] + chan->data[11]);

if ((chan->data[1] & 1) != 0)
Expand All @@ -317,8 +313,7 @@ void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 para
__MIXGetVolume(chan->data[3] + chan->data[8] + chan->data[10]);
*(U16*)(&chan->data[0x13]) =
__MIXGetVolume(chan->data[3] + chan->data[9] + chan->data[10]);
*(U16*)(&chan->data[0x14]) =
__MIXGetVolume(chan->data[3] + chan->data[11] + -0x3c);
*(U16*)(&chan->data[0x14]) = __MIXGetVolume(chan->data[3] + chan->data[11] + -0x3c);
}
else
{
Expand All @@ -335,8 +330,7 @@ void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 para
__MIXGetVolume(chan->data[4] + chan->data[8] + chan->data[10]);
*(U16*)(&chan->data[0x16]) =
__MIXGetVolume(chan->data[4] + chan->data[9] + chan->data[10]);
*(U16*)(&chan->data[0x17]) =
__MIXGetVolume(chan->data[4] + chan->data[11] + -0x3c);
*(U16*)(&chan->data[0x17]) = __MIXGetVolume(chan->data[4] + chan->data[11] + -0x3c);
}
else
{
Expand All @@ -350,14 +344,10 @@ void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 para
break;

case 3:
*(U16*)(&chan->data[15]) =
__MIXGetVolume(chan->data[7] + chan->data[8] + chan->data[10]);
*(U16*)(&chan->data[16]) =
__MIXGetVolume(chan->data[7] + chan->data[9] + chan->data[10]);
*(U16*)(&chan->data[21]) =
__MIXGetVolume(chan->data[7] + chan->data[12] + chan->data[11]);
*(U16*)(&chan->data[22]) =
__MIXGetVolume(chan->data[7] + chan->data[13] + chan->data[11]);
*(U16*)(&chan->data[15]) = __MIXGetVolume(chan->data[7] + chan->data[8] + chan->data[10]);
*(U16*)(&chan->data[16]) = __MIXGetVolume(chan->data[7] + chan->data[9] + chan->data[10]);
*(U16*)(&chan->data[21]) = __MIXGetVolume(chan->data[7] + chan->data[12] + chan->data[11]);
*(U16*)(&chan->data[22]) = __MIXGetVolume(chan->data[7] + chan->data[13] + chan->data[11]);

if ((chan->data[1] & 1) != 0)
{
Expand Down Expand Up @@ -388,8 +378,7 @@ void MIXInitChannel(S32 param_1, U32 param_2, S32 param_3, S32 param_4, S32 para

int enabled = OSDisableInterrupts();

*(U16*)((S32)param_1 + 0x19c) =
*(U16*)(&chan->data[0xe]);
*(U16*)((S32)param_1 + 0x19c) = *(U16*)(&chan->data[0xe]);
*(U16*)((S32)param_1 + 0x19e) = 0;
if ((*(U16*)((S32)param_1 + 0x14a) = *(U16*)(&chan->data[0xf])))
{
Expand Down Expand Up @@ -496,4 +485,4 @@ S32 MIXGetFader(S32* param_1)
{
S32* handle = &__MIXChannel[*(param_1 + 6)].data[0];
return handle[7];
}
}
64 changes: 64 additions & 0 deletions src/SB/Core/gc/iSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,70 @@ U16 my_dsc(U16 dsc)
return dsc;
}

void FloatingPointErrorHandler(U16 last, OSContext* ctxt, U64 unk1, U64 unk2)
{
U32 uVar2;
uVar2 = (ctxt->fpscr) & 0xf8 << 0x16 | 0x1f80700;
if ((uVar2 & 0x20000000) != 0)
{
OSReport("FPE: Invalid operation: ");

if ((uVar2 & 0x1000000) != 0)
{
OSReport("SNaN\n");
}
if ((uVar2 & 0x800000) != 0)
{
OSReport("Infinity - Infinity\n");
}
if ((uVar2 & 0x400000) != 0)
{
OSReport("Infinity / Infinity\n");
}
if ((uVar2 & 0x200000) != 0)
{
OSReport("0 / 0\n");
}
if ((uVar2 & 0x100000) != 0)
{
OSReport("Infinity * 0\n");
}
if ((uVar2 & 0x80000) != 0)
{
OSReport("Invalid compare\n");
}
if ((uVar2 & 0x400) != 0)
{
OSReport("Software request\n");
}
if ((uVar2 & 0x200) != 0)
{
OSReport("Invalid square root\n");
}
if ((uVar2 & 0x100) != 0)
{
OSReport("Invalid integer convert\n");
}
}
if ((uVar2 & 0x10000000) != 0)
{
OSReport("FPE: Overflow\n");
}
if ((uVar2 & 0x8000000) != 0)
{
OSReport("FPE: Underflow\n");
}
if ((uVar2 & 0x4000000) != 0)
{
OSReport("FPE: Zero division\n");
}
if ((uVar2 & 0x2000000) != 0)
{
OSReport("FPE: Inexact result\n");
}
ctxt->srr0 = ctxt->srr0 + 4;
}

void MemoryProtectionErrorHandler(U16 last, OSContext* ctx, U64 unk1, U64 unk2)
{
last_error = last;
Expand Down
1 change: 1 addition & 0 deletions src/SB/Core/gc/iSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ U16 my_dsc(U16 dsc);
void iSystemInit(U32 options);
void iSystemExit();
void MemoryProtectionErrorHandler(U16 last, OSContext* ctx, U64 unk1, U64 unk2);
void FloatingPointErrorHandler(U16 last, OSContext* ctxt, U64 unk1, U64 unk2);
void TRCInit();

void null_func();
Expand Down
1 change: 1 addition & 0 deletions src/SB/Core/x/containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ template <class T, U32 N> struct fixed_queue

void reset();
void push_front(const T& element);
void push_back();
bool full() const;
void pop_back();
bool empty() const;
Expand Down
153 changes: 153 additions & 0 deletions src/SB/Core/x/xScrFx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,163 @@

#include <types.h>

U8 g_debugRenderSafeArea;

static F32 mLetterboxO;
static F32 mLetterboxTO;
static F32 sLetterBoxSize;
static U8 sLetterBoxAlpha = 255;
F32 sFullScreenGlareIntensity; // Needs to be initialized

static _xFadeData mFade;
xGlare sGlare[10];

extern RwGlobals* RwEngineInstance;
extern RwInt32 RwEngineGetCurrentVideoMode(void);
extern RwVideoMode* RwEngineGetVideoModeInfo(RwVideoMode* modeinfo, RwInt32 modeIndex);

void xScrFxInit()
{
xScrFxFadeInit();
xScrFxLetterBoxInit();
xScrFXGlareInit();
iScrFxInit();
}

void xScrFxReset()
{
xScrFXGlareReset();
}

void xScrFxUpdate(RwCamera* cam, F32 dt)
{
iScrFxBegin();
xScrFxUpdateFade(cam, dt);
xScrFxUpdateLetterBox(cam, dt);
xScrFXGlareUpdate(dt);
xScrFxDistortionUpdate(dt);
}

void xScrFxRender(RwCamera* cam)
{
iScrFxBegin();
xScrFxDistortionRender((RwCamera*)RwEngineInstance->curCamera);
if (g_debugRenderSafeArea != '\0')
{
xScrFxDrawSafeArea();
}
iScrFxEnd();
}

void xScrFxDrawScreenSizeRectangle()
{
// I honestly dont know how to complete this function
// FIXME: First 2 params of xScrFxDrawBox seem to be correct
// The rest of them confuse me.

RwVideoMode video_mode;

F32 x2 = 0;
F32 y2 = 0;
U8 red = 0;
U8 green = 0;
U8 blue = 0;
U8 alpha = 255;
F32 ushift = 0;
F32 vshift = 0;

S32 mode = RwEngineGetCurrentVideoMode();
RwEngineGetVideoModeInfo(&video_mode, mode);
xScrFxDrawBox((F32)video_mode.width, (F32)video_mode.height, x2, y2, red, green, blue, alpha,
ushift, vshift);
}

void xScrFxFadeInit()
{
memset(&mFade, 0, 0x1c);
}

void InterpCol(F32 unk, U8 unk1, U8 unk2)
{
}

void xScrFxFade(iColor_tag* base, iColor_tag* dest, F32 seconds, void (*callback)(), S32 hold)
{
mFade.active = 1;
base->operator=(*(iColor_tag*)dest);
}

void xScrFxStopFade()
{
mFade.active = 0;
}

S32 xScrFxIsFading()
{
return mFade.active;
}

void xScrFxLetterBoxInit()
{
mLetterboxO = 0.0f;
mLetterboxTO = 0.0f;
}

void xScrFxLetterboxReset()
{
mLetterboxO = 0.0f;
mLetterboxTO = 0.0f;
}

void xScrFxLetterBoxSetSize(F32 size)
{
sLetterBoxSize = size;
}

void xScrFxLetterBoxSetAlpha(U8 alpha)
{
sLetterBoxAlpha = alpha;
}

void xScrFxLetterbox(S32 enable)
{
if (zMenuRunning() != 0)
{
enable = 0;
}
if (enable != 0)
{
mLetterboxTO = sLetterBoxSize;
}
else
{
mLetterboxTO = 0.0f;
}
}

S32 xScrFxIsLetterbox()
{
return (((mLetterboxTO > 0.0f) << 2) << 0x1c) >> 0x1e;
}

void xScrFxDistortionAdd(xVec3*, xVec3*, S32)
{
}

void xScrFxDistortionRender(RwCamera*)
{
}

void xScrFXGlareInit()
{
sGlare->flags = 0;
for (S32 i = 1; i < 10; i++)
{
sGlare[i].flags = 0;
}
}

void xScrFXGlareReset()
{
xScrFXGlareInit();
}
Loading