Fixed psyqo-lua problems

This commit is contained in:
2026-03-29 12:47:05 +02:00
parent 92d1a73248
commit 7425d9a5b2
4 changed files with 271 additions and 13 deletions

View File

@@ -22,7 +22,8 @@ src/bvh.cpp \
src/cutscene.cpp \
src/uisystem.cpp \
src/loadingscreen.cpp \
src/memoverlay.cpp
src/memoverlay.cpp \
src/loadbuffer_patch.cpp
# LOADER=cdrom → CD-ROM backend (for ISO builds on real hardware)
# LOADER=pcdrv → PCdrv backend (default, emulator + SIO1)
@@ -58,4 +59,7 @@ LDFLAGS := $(subst psyqo_realloc,lua_oom_realloc,$(LDFLAGS))
# NOPARSER=1 → Use precompiled bytecode, strip Lua parser from runtime (~25KB savings)
ifeq ($(NOPARSER),1)
LIBRARIES := $(subst liblua.a,liblua-noparser.a,$(LIBRARIES))
# Wrap luaL_loadbufferx to intercept psyqo-lua's source-text FixedPoint
# metatable init and redirect it to pre-compiled bytecode.
LDFLAGS += -Wl,--wrap=luaL_loadbufferx
endif

201
src/fixedpoint_patch.h Normal file
View File

@@ -0,0 +1,201 @@
#pragma once
// Pre-compiled PS1 Lua bytecode for psyqo FixedPoint metatable script.
// Compiled from the R"lua(...)lua" source in psyqo-lua/src/lua.cpp.
// This intercepts the source-text loadBuffer call so NOPARSER builds work.
// 2301 bytes
static const unsigned char FIXEDPOINT_PATCHED_BYTECODE[] = {
0x1b, 0x4c, 0x75, 0x61, 0x52, 0x00, 0x01, 0x04, 0x04, 0x04, 0x04, 0x01,
0x19, 0x93, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00,
0x00, 0x1f, 0x00, 0x00, 0x01, 0x1f, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00,
0x00, 0x01, 0x00, 0x07, 0x25, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x80,
0x65, 0x00, 0x00, 0x00, 0x86, 0x00, 0x40, 0x00, 0x8a, 0x40, 0x80, 0x80,
0x86, 0x80, 0x40, 0x00, 0x87, 0xc0, 0x40, 0x01, 0xc6, 0x80, 0x40, 0x00,
0xc7, 0x00, 0xc1, 0x01, 0x25, 0x41, 0x00, 0x00, 0x46, 0x01, 0x40, 0x00,
0xa5, 0x81, 0x00, 0x00, 0x4a, 0x81, 0x81, 0x82, 0x46, 0x01, 0x40, 0x00,
0xa5, 0xc1, 0x00, 0x00, 0x4a, 0x81, 0x01, 0x83, 0x46, 0x01, 0x40, 0x00,
0xa5, 0x01, 0x01, 0x00, 0x4a, 0x81, 0x81, 0x83, 0x46, 0x01, 0x40, 0x00,
0xa5, 0x41, 0x01, 0x00, 0x4a, 0x81, 0x01, 0x84, 0x46, 0x01, 0x40, 0x00,
0xa5, 0x81, 0x01, 0x00, 0x4a, 0x81, 0x81, 0x84, 0x46, 0x01, 0x40, 0x00,
0xa5, 0xc1, 0x01, 0x00, 0x4a, 0x81, 0x01, 0x85, 0x46, 0x01, 0x40, 0x00,
0xa5, 0x01, 0x02, 0x00, 0x4a, 0x81, 0x81, 0x85, 0x46, 0x01, 0x40, 0x00,
0xa5, 0x41, 0x02, 0x00, 0x4a, 0x81, 0x01, 0x86, 0x46, 0x01, 0x40, 0x00,
0xa5, 0x81, 0x02, 0x00, 0x4a, 0x81, 0x81, 0x86, 0x1f, 0x00, 0x80, 0x00,
0x0e, 0x00, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x69, 0x78,
0x65, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x00, 0x04, 0x0b, 0x00, 0x00,
0x00, 0x6e, 0x65, 0x77, 0x46, 0x72, 0x6f, 0x6d, 0x52, 0x61, 0x77, 0x00,
0x04, 0x06, 0x00, 0x00, 0x00, 0x62, 0x69, 0x74, 0x33, 0x32, 0x00, 0x04,
0x07, 0x00, 0x00, 0x00, 0x6c, 0x73, 0x68, 0x69, 0x66, 0x74, 0x00, 0x04,
0x07, 0x00, 0x00, 0x00, 0x72, 0x73, 0x68, 0x69, 0x66, 0x74, 0x00, 0x04,
0x06, 0x00, 0x00, 0x00, 0x5f, 0x5f, 0x61, 0x64, 0x64, 0x00, 0x04, 0x06,
0x00, 0x00, 0x00, 0x5f, 0x5f, 0x73, 0x75, 0x62, 0x00, 0x04, 0x06, 0x00,
0x00, 0x00, 0x5f, 0x5f, 0x75, 0x6e, 0x6d, 0x00, 0x04, 0x05, 0x00, 0x00,
0x00, 0x5f, 0x5f, 0x65, 0x71, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x5f,
0x5f, 0x6c, 0x74, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x5f, 0x5f, 0x6c,
0x65, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x72, 0x61, 0x77, 0x00, 0x04,
0x09, 0x00, 0x00, 0x00, 0x74, 0x6f, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72,
0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x6e, 0x65, 0x77, 0x00, 0x0b, 0x00,
0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00,
0x04, 0x07, 0x00, 0x00, 0x00, 0x46, 0x00, 0x40, 0x00, 0x8b, 0x40, 0x00,
0x00, 0x8a, 0x00, 0x80, 0x80, 0xc6, 0x80, 0x40, 0x00, 0x5e, 0x00, 0x80,
0x01, 0x5f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00,
0x00, 0x04, 0x0d, 0x00, 0x00, 0x00, 0x73, 0x65, 0x74, 0x6d, 0x65, 0x74,
0x61, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00,
0x5f, 0x72, 0x61, 0x77, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x69,
0x78, 0x65, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x05, 0x07, 0x00,
0x00, 0x00, 0x46, 0x00, 0x40, 0x00, 0x81, 0x40, 0x00, 0x00, 0xc0, 0x00,
0x00, 0x00, 0x01, 0x81, 0x00, 0x00, 0x96, 0x00, 0x01, 0x01, 0x5d, 0x40,
0x00, 0x01, 0x1f, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x06,
0x00, 0x00, 0x00, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x00, 0x04, 0x08, 0x00,
0x00, 0x00, 0x43, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x20, 0x00, 0x04, 0x19,
0x00, 0x00, 0x00, 0x20, 0x46, 0x69, 0x78, 0x65, 0x64, 0x50, 0x6f, 0x69,
0x6e, 0x74, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x69, 0x73, 0x20, 0x74,
0x79, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x1d, 0x00,
0x00, 0x00, 0x02, 0x00, 0x07, 0x21, 0x00, 0x00, 0x00, 0x87, 0x00, 0x40,
0x00, 0xc6, 0x40, 0x40, 0x00, 0x00, 0x01, 0x80, 0x00, 0xdd, 0x80, 0x00,
0x01, 0x18, 0x80, 0xc0, 0x01, 0x17, 0x00, 0x02, 0x80, 0xc5, 0x00, 0x80,
0x00, 0x05, 0x01, 0x00, 0x01, 0x40, 0x01, 0x80, 0x00, 0x81, 0xc1, 0x00,
0x00, 0x1d, 0x81, 0x80, 0x01, 0x0d, 0x01, 0x01, 0x01, 0xde, 0x00, 0x00,
0x01, 0xdf, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x80, 0xc6, 0x40, 0x40,
0x00, 0x00, 0x01, 0x80, 0x00, 0xdd, 0x80, 0x00, 0x01, 0x18, 0x00, 0xc1,
0x01, 0x17, 0x00, 0x02, 0x80, 0xc7, 0x00, 0xc0, 0x00, 0xdb, 0x00, 0x00,
0x00, 0x17, 0x40, 0x01, 0x80, 0xc5, 0x00, 0x80, 0x00, 0x07, 0x01, 0xc0,
0x00, 0x0d, 0x01, 0x01, 0x01, 0xde, 0x00, 0x00, 0x01, 0xdf, 0x00, 0x00,
0x00, 0x17, 0x80, 0x00, 0x80, 0xc5, 0x00, 0x80, 0x01, 0x01, 0x41, 0x01,
0x00, 0xdd, 0x40, 0x00, 0x01, 0x1f, 0x00, 0x80, 0x00, 0x06, 0x00, 0x00,
0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x5f, 0x72, 0x61, 0x77, 0x00, 0x04,
0x05, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x00, 0x04, 0x07, 0x00,
0x00, 0x00, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x00, 0x03, 0x0c, 0x00,
0x00, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x74, 0x61, 0x62, 0x6c, 0x65,
0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x61, 0x64, 0x64, 0x00, 0x00, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02,
0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x2a, 0x00,
0x00, 0x00, 0x02, 0x00, 0x07, 0x21, 0x00, 0x00, 0x00, 0x87, 0x00, 0x40,
0x00, 0xc6, 0x40, 0x40, 0x00, 0x00, 0x01, 0x80, 0x00, 0xdd, 0x80, 0x00,
0x01, 0x18, 0x80, 0xc0, 0x01, 0x17, 0x00, 0x02, 0x80, 0xc5, 0x00, 0x80,
0x00, 0x05, 0x01, 0x00, 0x01, 0x40, 0x01, 0x80, 0x00, 0x81, 0xc1, 0x00,
0x00, 0x1d, 0x81, 0x80, 0x01, 0x0e, 0x01, 0x01, 0x01, 0xde, 0x00, 0x00,
0x01, 0xdf, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x80, 0xc6, 0x40, 0x40,
0x00, 0x00, 0x01, 0x80, 0x00, 0xdd, 0x80, 0x00, 0x01, 0x18, 0x00, 0xc1,
0x01, 0x17, 0x00, 0x02, 0x80, 0xc7, 0x00, 0xc0, 0x00, 0xdb, 0x00, 0x00,
0x00, 0x17, 0x40, 0x01, 0x80, 0xc5, 0x00, 0x80, 0x00, 0x07, 0x01, 0xc0,
0x00, 0x0e, 0x01, 0x01, 0x01, 0xde, 0x00, 0x00, 0x01, 0xdf, 0x00, 0x00,
0x00, 0x17, 0x80, 0x00, 0x80, 0xc5, 0x00, 0x80, 0x01, 0x01, 0x41, 0x01,
0x00, 0xdd, 0x40, 0x00, 0x01, 0x1f, 0x00, 0x80, 0x00, 0x06, 0x00, 0x00,
0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x5f, 0x72, 0x61, 0x77, 0x00, 0x04,
0x05, 0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x00, 0x04, 0x07, 0x00,
0x00, 0x00, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x00, 0x03, 0x0c, 0x00,
0x00, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x74, 0x61, 0x62, 0x6c, 0x65,
0x00, 0x04, 0x09, 0x00, 0x00, 0x00, 0x73, 0x75, 0x62, 0x74, 0x72, 0x61,
0x63, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c,
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x06, 0x00,
0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x87, 0x00, 0x40, 0x00, 0x93, 0x00,
0x00, 0x01, 0x5e, 0x00, 0x00, 0x01, 0x5f, 0x00, 0x00, 0x00, 0x1f, 0x00,
0x80, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x5f,
0x72, 0x61, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3a, 0x00,
0x00, 0x00, 0x02, 0x00, 0x06, 0x23, 0x00, 0x00, 0x00, 0x86, 0x00, 0x40,
0x00, 0xc0, 0x00, 0x80, 0x00, 0x9d, 0x80, 0x00, 0x01, 0x18, 0x40, 0x40,
0x01, 0x17, 0x80, 0x02, 0x80, 0x87, 0x80, 0xc0, 0x00, 0x9b, 0x00, 0x00,
0x00, 0x17, 0xc0, 0x01, 0x80, 0x87, 0x80, 0x40, 0x00, 0xc7, 0x80, 0xc0,
0x00, 0x58, 0xc0, 0x00, 0x01, 0x17, 0x00, 0x00, 0x80, 0x83, 0x40, 0x00,
0x00, 0x83, 0x00, 0x80, 0x00, 0x9f, 0x00, 0x00, 0x01, 0x17, 0x40, 0x04,
0x80, 0x86, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x80, 0x00, 0x9d, 0x80, 0x00,
0x01, 0x18, 0xc0, 0x40, 0x01, 0x17, 0x80, 0x02, 0x80, 0x87, 0x80, 0x40,
0x00, 0xc5, 0x00, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x41, 0x01, 0x01,
0x00, 0xdd, 0x80, 0x80, 0x01, 0x58, 0xc0, 0x00, 0x01, 0x17, 0x00, 0x00,
0x80, 0x83, 0x40, 0x00, 0x00, 0x83, 0x00, 0x80, 0x00, 0x9f, 0x00, 0x00,
0x01, 0x17, 0x40, 0x00, 0x80, 0x83, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00,
0x01, 0x1f, 0x00, 0x80, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00,
0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00,
0x74, 0x61, 0x62, 0x6c, 0x65, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x5f,
0x72, 0x61, 0x77, 0x00, 0x04, 0x07, 0x00, 0x00, 0x00, 0x6e, 0x75, 0x6d,
0x62, 0x65, 0x72, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x3c, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06,
0x24, 0x00, 0x00, 0x00, 0x86, 0x00, 0x40, 0x00, 0xc0, 0x00, 0x80, 0x00,
0x9d, 0x80, 0x00, 0x01, 0x18, 0x40, 0x40, 0x01, 0x17, 0x80, 0x02, 0x80,
0x87, 0x80, 0xc0, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x17, 0xc0, 0x01, 0x80,
0x87, 0x80, 0x40, 0x00, 0xc7, 0x80, 0xc0, 0x00, 0x59, 0xc0, 0x00, 0x01,
0x17, 0x00, 0x00, 0x80, 0x83, 0x40, 0x00, 0x00, 0x83, 0x00, 0x80, 0x00,
0x9f, 0x00, 0x00, 0x01, 0x17, 0x80, 0x04, 0x80, 0x86, 0x00, 0x40, 0x00,
0xc0, 0x00, 0x80, 0x00, 0x9d, 0x80, 0x00, 0x01, 0x18, 0xc0, 0x40, 0x01,
0x17, 0x80, 0x02, 0x80, 0x87, 0x80, 0x40, 0x00, 0xc5, 0x00, 0x80, 0x00,
0x00, 0x01, 0x80, 0x00, 0x41, 0x01, 0x01, 0x00, 0xdd, 0x80, 0x80, 0x01,
0x59, 0xc0, 0x00, 0x01, 0x17, 0x00, 0x00, 0x80, 0x83, 0x40, 0x00, 0x00,
0x83, 0x00, 0x80, 0x00, 0x9f, 0x00, 0x00, 0x01, 0x17, 0x80, 0x00, 0x80,
0x85, 0x00, 0x00, 0x01, 0xc1, 0x40, 0x01, 0x00, 0x9d, 0x40, 0x00, 0x01,
0x1f, 0x00, 0x80, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00, 0x00,
0x00, 0x74, 0x79, 0x70, 0x65, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x74,
0x61, 0x62, 0x6c, 0x65, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x5f, 0x72,
0x61, 0x77, 0x00, 0x04, 0x07, 0x00, 0x00, 0x00, 0x6e, 0x75, 0x6d, 0x62,
0x65, 0x72, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x08, 0x00, 0x00,
0x00, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x02,
0x00, 0x06, 0x24, 0x00, 0x00, 0x00, 0x86, 0x00, 0x40, 0x00, 0xc0, 0x00,
0x80, 0x00, 0x9d, 0x80, 0x00, 0x01, 0x18, 0x40, 0x40, 0x01, 0x17, 0x80,
0x02, 0x80, 0x87, 0x80, 0xc0, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x17, 0xc0,
0x01, 0x80, 0x87, 0x80, 0x40, 0x00, 0xc7, 0x80, 0xc0, 0x00, 0x5a, 0xc0,
0x00, 0x01, 0x17, 0x00, 0x00, 0x80, 0x83, 0x40, 0x00, 0x00, 0x83, 0x00,
0x80, 0x00, 0x9f, 0x00, 0x00, 0x01, 0x17, 0x80, 0x04, 0x80, 0x86, 0x00,
0x40, 0x00, 0xc0, 0x00, 0x80, 0x00, 0x9d, 0x80, 0x00, 0x01, 0x18, 0xc0,
0x40, 0x01, 0x17, 0x80, 0x02, 0x80, 0x87, 0x80, 0x40, 0x00, 0xc5, 0x00,
0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x41, 0x01, 0x01, 0x00, 0xdd, 0x80,
0x80, 0x01, 0x5a, 0xc0, 0x00, 0x01, 0x17, 0x00, 0x00, 0x80, 0x83, 0x40,
0x00, 0x00, 0x83, 0x00, 0x80, 0x00, 0x9f, 0x00, 0x00, 0x01, 0x17, 0x80,
0x00, 0x80, 0x85, 0x00, 0x00, 0x01, 0xc1, 0x40, 0x01, 0x00, 0x9d, 0x40,
0x00, 0x01, 0x1f, 0x00, 0x80, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x05,
0x00, 0x00, 0x00, 0x74, 0x79, 0x70, 0x65, 0x00, 0x04, 0x06, 0x00, 0x00,
0x00, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00,
0x5f, 0x72, 0x61, 0x77, 0x00, 0x04, 0x07, 0x00, 0x00, 0x00, 0x6e, 0x75,
0x6d, 0x62, 0x65, 0x72, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x08,
0x00, 0x00, 0x00, 0x63, 0x6f, 0x6d, 0x70, 0x61, 0x72, 0x65, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x01,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00,
0x00, 0x01, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00, 0x47, 0x00, 0x40, 0x00,
0x5f, 0x00, 0x00, 0x01, 0x1f, 0x00, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00,
0x04, 0x05, 0x00, 0x00, 0x00, 0x5f, 0x72, 0x61, 0x77, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x00,
0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x07, 0x00, 0x00,
0x00, 0x45, 0x00, 0x00, 0x00, 0x87, 0x00, 0x40, 0x00, 0x8d, 0x40, 0x40,
0x01, 0xc1, 0x80, 0x00, 0x00, 0x5e, 0x00, 0x80, 0x01, 0x5f, 0x00, 0x00,
0x00, 0x1f, 0x00, 0x80, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00,
0x00, 0x00, 0x5f, 0x72, 0x61, 0x77, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00,
0x03, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x60,
0x00, 0x00, 0x00, 0x02, 0x00, 0x07, 0x0f, 0x00, 0x00, 0x00, 0x18, 0x00,
0xc0, 0x00, 0x17, 0x00, 0x00, 0x80, 0x41, 0x40, 0x00, 0x00, 0x86, 0x80,
0x40, 0x00, 0xcb, 0x40, 0x00, 0x00, 0x05, 0x01, 0x80, 0x00, 0x40, 0x01,
0x00, 0x00, 0x81, 0x01, 0x01, 0x00, 0x1d, 0x81, 0x80, 0x01, 0x0d, 0x41,
0x00, 0x02, 0xca, 0x00, 0x81, 0x81, 0x06, 0x41, 0x41, 0x00, 0x9e, 0x00,
0x80, 0x01, 0x9f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x80, 0x00, 0x06, 0x00,
0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x0d, 0x00, 0x00,
0x00, 0x73, 0x65, 0x74, 0x6d, 0x65, 0x74, 0x61, 0x74, 0x61, 0x62, 0x6c,
0x65, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x5f, 0x72, 0x61, 0x77, 0x00,
0x03, 0x0c, 0x00, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x00, 0x46, 0x69,
0x78, 0x65, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

48
src/loadbuffer_patch.cpp Normal file
View File

@@ -0,0 +1,48 @@
// Linker --wrap intercept for luaL_loadbufferx.
//
// psyqo-lua's FixedPoint metatable setup (at the pinned nugget commit)
// loads Lua SOURCE text via loadBuffer. With NOPARSER, the parser stub
// rejects it with "parser not loaded". This wrapper intercepts that
// specific call and redirects it to pre-compiled bytecode.
//
// All other loadBuffer calls pass through to the real implementation.
#include "fixedpoint_patch.h"
extern "C" {
// The real luaL_loadbufferx provided by liblua
int __real_luaL_loadbufferx(void* L, const char* buff, unsigned int size,
const char* name, const char* mode);
int __wrap_luaL_loadbufferx(void* L, const char* buff, unsigned int size,
const char* name, const char* mode) {
// Check if this is the fixedpoint script load from psyqo-lua.
// The name is "buffer:fixedPointScript" in the pinned nugget version.
if (name) {
// Compare the first few chars to identify the fixedpoint load
const char* expected = "buffer:fixedPointScript";
const char* a = name;
const char* b = expected;
bool match = true;
while (*b) {
if (*a != *b) { match = false; break; }
a++;
b++;
}
if (match && *a == '\0') {
// Redirect to pre-compiled bytecode
return __real_luaL_loadbufferx(
L,
reinterpret_cast<const char*>(FIXEDPOINT_PATCHED_BYTECODE),
sizeof(FIXEDPOINT_PATCHED_BYTECODE),
"bytecode:fixedPointScript",
mode);
}
}
// All other calls pass through unchanged
return __real_luaL_loadbufferx(L, buff, size, name, mode);
}
} // extern "C"

View File

@@ -608,22 +608,27 @@ void psxsplash::SceneManager::setObjectActive(GameObject* go, bool active) {
}
void psxsplash::SceneManager::processEnableDisableEvents() {
// Process any pending enable/disable flags (for batched operations)
// Process any pending enable/disable flags.
// Uses raw bit manipulation on flagsAsInt instead of the BitField
// accessors to avoid a known issue where the BitSpan get/set
// operations don't behave correctly on the MIPS target.
for (auto* go : m_gameObjects) {
if (!go) continue;
if (go->isPendingEnable()) {
go->setPendingEnable(false);
if (!go->isActive()) {
go->setActive(true);
// Bit 1 = pendingEnable
if (go->flagsAsInt & 0x02) {
go->flagsAsInt &= ~0x02u; // clear pending
if (!(go->flagsAsInt & 0x01)) { // if not already active
go->flagsAsInt |= 0x01; // set active
L.OnEnable(go);
}
}
if (go->isPendingDisable()) {
go->setPendingDisable(false);
if (go->isActive()) {
go->setActive(false);
// Bit 2 = pendingDisable
if (go->flagsAsInt & 0x04) {
go->flagsAsInt &= ~0x04u; // clear pending
if (go->flagsAsInt & 0x01) { // if currently active
go->flagsAsInt &= ~0x01u; // clear active
L.OnDisable(go);
}
}