mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-05-24 06:50:43 -04:00
Actually fix compile with offset_ptr for real this time I hope?
This commit is contained in:
@@ -1331,6 +1331,7 @@ set(DUSK_FILES
|
||||
src/dusk/dvd_emu.cpp
|
||||
src/dusk/imgui/imgui.hpp
|
||||
src/dusk/imgui/processes.cpp
|
||||
src/dusk/offset_ptr.cpp
|
||||
src/dolphin/os/OSContext.cpp
|
||||
src/dolphin/os/OSThread.cpp
|
||||
src/dolphin/os/OSMutex.cpp
|
||||
|
||||
@@ -50,7 +50,12 @@ public:
|
||||
|
||||
struct list_class {
|
||||
/* 0x0 */ BE(int) field_0x0;
|
||||
/* 0x4 */ OFFSET_PTR(typeGroupData_c) field_0x4;
|
||||
#if TARGET_PC
|
||||
// idk why but MSVC refused to compile this when using the macro ???
|
||||
/* 0x4 */ OffsetPtrT<typeGroupData_c> field_0x4;
|
||||
#else
|
||||
/* 0x4 */ typeGroupData_c* field_0x4;
|
||||
#endif
|
||||
/* 0x8 */ u8 mNumber;
|
||||
};
|
||||
|
||||
|
||||
@@ -2922,28 +2922,3 @@ void dStage_escapeRestart() {
|
||||
dComIfGp_setNextStage(dComIfGp_getStartStageName(), -2, dComIfGs_getTurnRestartRoomNo(), -1, 0.0f, 0, 0, 9, 0, 1, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_PC
|
||||
bool StageOffsetPtr::isRelocated() {
|
||||
return value & 0x8000'0000;
|
||||
}
|
||||
|
||||
bool StageOffsetPtr::setBase(void* base) {
|
||||
JUT_ASSERT(__LINE__, value != 0);
|
||||
|
||||
if (isRelocated()) {
|
||||
// Already relocated, don't touch it again!
|
||||
return false;
|
||||
}
|
||||
|
||||
ptrdiff_t diff = (u8*)this - (u8*)base;
|
||||
ptrdiff_t newDiff = value - diff;
|
||||
// Check that it's in range given that we use the 31st bit as a flag.
|
||||
if (newDiff < -0x4000'0000 || newDiff > 0x7FFF'FFFF) {
|
||||
OSPanic(__FILE__, __LINE__, "Not enough space in StageOffsetPtr!");
|
||||
}
|
||||
|
||||
value = newDiff | 0x8000'0000;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "dusk/offset_ptr.h"
|
||||
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
|
||||
#if TARGET_PC
|
||||
bool OffsetPtr::isRelocated() {
|
||||
return value & 0x8000'0000;
|
||||
}
|
||||
|
||||
bool OffsetPtr::setBase(void* base) {
|
||||
JUT_ASSERT(__LINE__, value != 0);
|
||||
|
||||
if (isRelocated()) {
|
||||
// Already relocated, don't touch it again!
|
||||
return false;
|
||||
}
|
||||
|
||||
ptrdiff_t diff = (u8*)this - (u8*)base;
|
||||
ptrdiff_t newDiff = value - diff;
|
||||
// Check that it's in range given that we use the 31st bit as a flag.
|
||||
if (newDiff < -0x4000'0000 || newDiff > 0x7FFF'FFFF) {
|
||||
OSPanic(__FILE__, __LINE__, "Not enough space in StageOffsetPtr!");
|
||||
}
|
||||
|
||||
value = newDiff | 0x8000'0000;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user