Skip to content

Commit

Permalink
Matches and stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
escape209 committed Sep 24, 2024
1 parent b6cbed8 commit 7e2d5b6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 62 deletions.
32 changes: 16 additions & 16 deletions src/SB/Core/gc/iSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ extern void* MemoryFunctions[4];
extern U16 last_error;
extern OSContext* last_context;

extern char stringBase0[];

void** psGetMemoryFunctions()
{
return MemoryFunctions;
Expand All @@ -40,8 +42,6 @@ U16 my_dsc(U16 dsc)
return dsc;
}

//

void MemoryProtectionErrorHandler(U16 last, OSContext* ctx, U64 unk1, U64 unk2)
{
last_error = last;
Expand All @@ -68,7 +68,13 @@ void TRCInit()

#endif

/*
S32 RenderWareExit()
{
RwEngineStop();
RwEngineClose();
return RwEngineTerm();
}

void iSystemExit()
{
xDebugExit();
Expand All @@ -79,14 +85,12 @@ void iSystemExit()
iFileExit();
iTimeExit();
xMemExit();
}
*/

S32 RenderWareExit()
{
RwEngineStop();
RwEngineClose();
return RwEngineTerm();
OSPanic
(
stringBase0 + 0x113, // "iSystem.cpp"
0x21d,
stringBase0 + 0x144 // "(With apologies to Jim Morrison) This the end, my only friend, The End."
);
}

void null_func()
Expand Down Expand Up @@ -135,11 +139,7 @@ void _rwDolphinHeapFree(void* __ptr)
}
if (__ptr != NULL)
{
// TODO: clear this up
// some number is compared against 0xbeef in the assembly.
// 0xbeef was probably a hardcoded constant Heavy iron used.
// if (*(U32*)((S32)__ptr + -4) + 0x2153 == 0xbeef)
if (*(S32*)((S32)__ptr + -4) == -0x21524111)
if ( *(S32*)((S32)__ptr - 4) == 0xDEADBEEF )
{
free((void*)((S32)__ptr - 32));
}
Expand Down
5 changes: 2 additions & 3 deletions src/SB/Core/x/xFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3136,12 +3136,11 @@ namespace

namespace
{
#if 0
xVec2 get_texture_size(RwRaster& raster)
{
// todo: uses int-to-float conversion
xVec2 vec = { raster.width / 640.0f, raster.height / 480.0f };
return vec;
}
#endif

void reset_tag_tex(xtextbox::jot&, const xtextbox&, const xtextbox&, const xtextbox::split_tag&)
{
Expand Down
15 changes: 4 additions & 11 deletions src/SB/Core/x/xLightKit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
#include <types.h>
#include <string.h>

extern xLightKit* gLastLightKit;
extern S32 iModelHack_DisablePrelight;
S32 iModelHack_DisablePrelight;
xLightKit* gLastLightKit;

#if 0
F32 MAX_COLOR = 1.0f;
#endif

#ifdef NON_MATCHING
// Will match once able to use float literals
xLightKit* xLightKit_Prepare(void* data)
{
xLightKit* lkit = (xLightKit*)data;
Expand All @@ -27,8 +21,8 @@ xLightKit* xLightKit_Prepare(void* data)
}

// If any of the colors is greater than 1.0, normalize back to 0-1
if (currlight->color.red > MAX_COLOR || currlight->color.green > MAX_COLOR ||
currlight->color.blue > MAX_COLOR)
if (currlight->color.red > 1.0f || currlight->color.green > 1.0f ||
currlight->color.blue > 1.0f)
{
F32 s;
s = MAX(MAX(currlight->color.red, currlight->color.green), currlight->color.blue);
Expand Down Expand Up @@ -93,7 +87,6 @@ xLightKit* xLightKit_Prepare(void* data)

return (xLightKit*)data;
}
#endif

void xLightKit_Enable(xLightKit* lkit, RpWorld* world)
{
Expand Down
61 changes: 30 additions & 31 deletions src/SB/Core/x/xordarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
extern F32 lbl_803CCEE8; // 0.95f
extern F32 lbl_803CCEF0; // 176f

#if 0
// Can't figure out how to match the bottom part due to the weird float stuff going on.
void XOrdInit(st_XORDEREDARRAY* array, S32 size, S32 tempAlloc)
{
U32 cnt = 1;
Expand All @@ -21,7 +19,7 @@ void XOrdInit(st_XORDEREDARRAY* array, S32 size, S32 tempAlloc)
}
else
{
array->list = (void**)xMemAlloc(cnt << 2);
array->list = (void**)xMemAlloc(gActiveHeap, cnt << 2, 0);
}
array->cnt = 0;
array->max = cnt;
Expand All @@ -33,8 +31,6 @@ void XOrdInit(st_XORDEREDARRAY* array, S32 size, S32 tempAlloc)
}
}

#endif

void XOrdReset(st_XORDEREDARRAY* array)
{
array->cnt = 0;
Expand Down Expand Up @@ -89,8 +85,8 @@ void XOrdInsert(st_XORDEREDARRAY* array, void* elt, XOrdCompareCallback compare)

#endif

#if 0
// WIP. The comparisons are probably wrong.


void* XOrdRemove(st_XORDEREDARRAY* array, void* elt, S32 index)
{
if (elt == NULL)
Expand All @@ -99,41 +95,44 @@ void* XOrdRemove(st_XORDEREDARRAY* array, void* elt, S32 index)
{
return NULL;
}
else if (index >= array->max)
if (index >= array->max)
{
return NULL;
}
}
if (index >= 0)

if ((index >= 0) && (index < array->max))
{
if (index < array->max)
{
elt = array->list[index]
}
else
elt = array->list[index];
}
else if (elt != NULL)
{
index = -1;
int iVar4 = 0;
for (int i = array->cnt; i > 0; i--)
{
if (elt != NULL)
if (array->list[iVar4] == elt)
{
// LOOP.
}
else
{
if (index < 0)
{
return NULL;
}
else
{
// ANOTHER LOOP :>
return elt;
}
index = iVar4;
break;
}
iVar4++;
}
}
return NULL;
}

#endif
if (index < 0)
{
return NULL;
}

array->cnt--;
for (; index < array->cnt; index++)
{
array->list[index] = array->list[index + 1];
}

return elt;
}

#if 0
S32 XOrdLookup(st_XORDEREDARRAY* array, const void* key, XOrdTestCallback test)
Expand Down
2 changes: 1 addition & 1 deletion src/SB/Core/x/xordarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct st_XORDEREDARRAY
};

typedef S32 (*XOrdCompareCallback)(void* vkey, void* vitem);
typedef S32 (*XOrdTestCallback)(const void* vkey, void* vitem);
typedef S32 (*XOrdTestCallback)(void* vkey, void* vitem);

void XOrdInit(st_XORDEREDARRAY* array, S32 size, S32 tempAlloc);
void XOrdReset(st_XORDEREDARRAY* array);
Expand Down

0 comments on commit 7e2d5b6

Please sign in to comment.