Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish matching xSurface #281

Merged
merged 1 commit into from
Jun 27, 2024
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
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def Rel(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
Object(NonMatching, "SB/Core/x/xSpline.cpp"),
Object(NonMatching, "SB/Core/x/xstransvc.cpp"),
Object(NonMatching, "SB/Core/x/xString.cpp"),
Object(NonMatching, "SB/Core/x/xSurface.cpp"),
Object(Matching, "SB/Core/x/xSurface.cpp"),
Object(NonMatching, "SB/Core/x/xTimer.cpp"),
Object(NonMatching, "SB/Core/x/xTRC.cpp"),
Object(Matching, "SB/Core/x/xutil.cpp"),
Expand Down
34 changes: 11 additions & 23 deletions src/SB/Core/x/xSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@

#include <types.h>

extern xSurface* surfs;
extern uint16 nsurfs;
xSurface* surfs;
uint16 nsurfs;

#if 0
// The for loop is off.
void xSurfaceInit(uint16 num_surfs)
{
nsurfs = num_surfs;
if (num_surfs != 0)
{
surfs = (xSurface*)xMemAllocSize(num_surfs * sizeof(xSurface));
for (int32 i = 0; i < nsurfs; i++)
for (uint16 i = 0; i < nsurfs; i++)
{
surfs[i].idx = i;
}
Expand All @@ -25,32 +23,22 @@ void xSurfaceInit(uint16 num_surfs)
}
}

#endif
extern "C" {
extern void __copy(void* dst, const void* src, uint32 n);
}

Comment on lines +26 to 29
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be declared in intrin.h?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure. It doesn't get replaced with an instruction like the other intrinsics do, and it's implemented in the runtime library.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know either. I don't think it's something that's supposed to be directly included though. The whole assignment function was probably compiler generated, with the default implementation being to call __copy for any arrays. I suppose this fine for now.

#if 0
// Close to being finished.
void xSurface::operator=(const xSurface& ent)
xSurface& xSurface::operator=(const xSurface& ent)
{
xBase::operator=(ent);
this->idx = ent.idx;
this->type = ent.type;
this->ent = ent.ent;
this->friction = ent.friction;
this->state = ent.state;
this->pad = ent.pad; // Make this call __copy();
// FIXME: Is this auto-inserted by the compiler?
__copy(&pad, &ent.pad, 3);
this->moprops = ent.moprops;
}

#endif

void xSurface::operator=(const xBase& ent)
{
this->id = ent.id;
this->baseType = ent.baseType;
this->linkCount = ent.linkCount;
this->baseFlags = ent.baseFlags;
this->link = ent.link;
this->eventFunc = ent.eventFunc;
return *this;
}

void xSurfaceExit()
Expand All @@ -67,7 +55,7 @@ void xSurfaceLoad(xSurface* ent, xSerial* s)
xBaseLoad((xBase*)ent, s);
}

void xSurfaceReset()
void xSurfaceReset(xSurface* ent)
{
}

Expand Down
7 changes: 3 additions & 4 deletions src/SB/Core/x/xSurface.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ struct xSurface : xBase
uint8 pad[3];
void* moprops;

void operator=(const xSurface& ent);
void operator=(const xBase& ent);
xSurface& operator=(const xSurface& ent);
};

#define XSURFACE_TYPE_1 1
Expand All @@ -31,8 +30,8 @@ void xSurfaceInit(uint16 num_surfs);
void xSurfaceExit();
void xSurfaceSave(xSurface* ent, xSerial* s);
void xSurfaceLoad(xSurface* ent, xSerial* s);
void xSurfaceReset();
void xSurfaceReset(xSurface* ent);
uint16 xSurfaceGetNumSurfaces();
xSurface* xSurfaceGetByIdx(uint16 n);

#endif
#endif
2 changes: 1 addition & 1 deletion src/SB/Game/zSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void zSurfaceExit()

void zSurfaceResetSurface(xSurface* surf)
{
xSurfaceReset();
xSurfaceReset(surf);
surf->friction = ((zSurfaceProps*)(surf->moprops))->asset->friction;
}

Expand Down