From 8c50b9774f257727bb7dbc8cc1f741c7b7d61829 Mon Sep 17 00:00:00 2001 From: tgsm Date: Thu, 27 Jun 2024 05:27:03 -0500 Subject: [PATCH] Finish matching xSurface --- configure.py | 2 +- src/SB/Core/x/xSurface.cpp | 34 +++++++++++----------------------- src/SB/Core/x/xSurface.h | 7 +++---- src/SB/Game/zSurface.cpp | 2 +- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/configure.py b/configure.py index 3ff5951f3..0c63c9a9d 100644 --- a/configure.py +++ b/configure.py @@ -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"), diff --git a/src/SB/Core/x/xSurface.cpp b/src/SB/Core/x/xSurface.cpp index 272e106b8..f699ba43c 100644 --- a/src/SB/Core/x/xSurface.cpp +++ b/src/SB/Core/x/xSurface.cpp @@ -3,18 +3,16 @@ #include -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; } @@ -25,11 +23,11 @@ void xSurfaceInit(uint16 num_surfs) } } -#endif +extern "C" { +extern void __copy(void* dst, const void* src, uint32 n); +} -#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; @@ -37,20 +35,10 @@ void xSurface::operator=(const xSurface& ent) 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() @@ -67,7 +55,7 @@ void xSurfaceLoad(xSurface* ent, xSerial* s) xBaseLoad((xBase*)ent, s); } -void xSurfaceReset() +void xSurfaceReset(xSurface* ent) { } diff --git a/src/SB/Core/x/xSurface.h b/src/SB/Core/x/xSurface.h index eafd9294d..b3abcddce 100644 --- a/src/SB/Core/x/xSurface.h +++ b/src/SB/Core/x/xSurface.h @@ -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 @@ -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 \ No newline at end of file +#endif diff --git a/src/SB/Game/zSurface.cpp b/src/SB/Game/zSurface.cpp index ea99264d1..4b3501a4e 100644 --- a/src/SB/Game/zSurface.cpp +++ b/src/SB/Game/zSurface.cpp @@ -48,7 +48,7 @@ void zSurfaceExit() void zSurfaceResetSurface(xSurface* surf) { - xSurfaceReset(); + xSurfaceReset(surf); surf->friction = ((zSurfaceProps*)(surf->moprops))->asset->friction; }