Added support for SM76's JUMP_AREA, added missing lvl geos, reordered parsing

This commit is contained in:
MysterD 2022-04-07 18:34:44 -07:00
parent 4956f0dd95
commit 8085f53e5a
16 changed files with 257 additions and 151 deletions

View File

@ -764,6 +764,8 @@ s64 DynOS_RecursiveDescent_Parse(const char* expr, bool* success, RDConstantFunc
void DynOS_Read_Source(GfxData *aGfxData, const SysPath &aFilename);
char *DynOS_Read_Buffer(FILE* aFile, GfxData* aGfxData);
s64 DynOS_Misc_ParseInteger(const String& _Arg, bool* found);
void DynOS_Anim_ScanFolder(GfxData *aGfxData, const SysPath &aAnimsFolder);
void DynOS_Anim_Table_Write(FILE* aFile, GfxData* aGfxData);
void DynOS_Anim_Write(FILE* aFile, GfxData* aGfxData);

View File

@ -25,6 +25,13 @@ void ClearGfxDataNodes(DataNodes<T> &aDataNodes) {
static s16 ParseColSymbolArg(GfxData* aGfxData, DataNode<Collision>* aNode, u64& aTokenIndex) {
const String& _Arg = aNode->mTokens[aTokenIndex++];
// Integers
bool integerFound = false;
s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound);
if (integerFound) {
return integerValue;
}
// Surface constants
col_constant(SURFACE_DEFAULT);
col_constant(SURFACE_BURNING);
@ -274,12 +281,6 @@ static s16 ParseColSymbolArg(GfxData* aGfxData, DataNode<Collision>* aNode, u64&
// Other constants
col_constant(NULL);
// Integers
s32 x;
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
return (s16) x;
}
// Unknown
PrintError(" ERROR: Unknown col arg: %s", _Arg.begin());
return 0;

View File

@ -20,6 +20,13 @@ extern "C" {
static s64 ParseGeoSymbolArg(GfxData* aGfxData, DataNode<GeoLayout>* aNode, u64& aTokenIndex) {
const String& _Arg = aNode->mTokens[aTokenIndex++];
// Integers
bool integerFound = false;
s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound);
if (integerFound) {
return integerValue;
}
// Geo functions
void *_GeoFunctionPtr = DynOS_Geo_GetFunctionPointerFromName(_Arg);
if (_GeoFunctionPtr != NULL) {
@ -108,12 +115,6 @@ static s64 ParseGeoSymbolArg(GfxData* aGfxData, DataNode<GeoLayout>* aNode, u64&
}
}
// Integers
s32 x;
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
return (s64) x;
}
// Complex
s32 a;
s32 b;

View File

@ -342,6 +342,13 @@ static s64 ParseGfxSymbolArg(GfxData* aGfxData, DataNode<Gfx>* aNode, u64* pToke
String _Token = (pTokenIndex != NULL ? aNode->mTokens[(*pTokenIndex)++] : "");
String _Arg("%s%s", aPrefix, _Token.begin());
// Integers
bool integerFound = false;
s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound);
if (integerFound) {
return integerValue;
}
bool constantFound = false;
s64 constantValue = DynOS_Gfx_ParseGfxConstants(_Arg, &constantFound);
if (constantFound) {
@ -376,6 +383,27 @@ static s64 ParseGfxSymbolArg(GfxData* aGfxData, DataNode<Gfx>* aNode, u64* pToke
}
}
// Textures
for (auto& _Node : aGfxData->mTextures) {
if (_Arg == _Node->mName) {
return (s64) DynOS_Tex_Parse(aGfxData, _Node);
}
}
// Vertex arrays
for (auto& _Node : aGfxData->mVertices) {
if (_Arg == _Node->mName) {
return (s64) (DynOS_Vtx_Parse(aGfxData, _Node)->mData + _Offset);
}
}
// Display lists
for (auto& _Node : aGfxData->mDisplayLists) {
if (_Arg == _Node->mName) {
return (s64) DynOS_Gfx_Parse(aGfxData, _Node);
}
}
for (auto& _Node : aGfxData->mLightTs) {
// Light pointer
if (_Arg == _Node->mName) {
@ -420,33 +448,6 @@ static s64 ParseGfxSymbolArg(GfxData* aGfxData, DataNode<Gfx>* aNode, u64* pToke
}
}
// Textures
for (auto& _Node : aGfxData->mTextures) {
if (_Arg == _Node->mName) {
return (s64) DynOS_Tex_Parse(aGfxData, _Node);
}
}
// Vertex arrays
for (auto& _Node : aGfxData->mVertices) {
if (_Arg == _Node->mName) {
return (s64) (DynOS_Vtx_Parse(aGfxData, _Node)->mData + _Offset);
}
}
// Display lists
for (auto& _Node : aGfxData->mDisplayLists) {
if (_Arg == _Node->mName) {
return (s64) DynOS_Gfx_Parse(aGfxData, _Node);
}
}
// Integers
s32 x;
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
return (s64) x;
}
// Vanilla textures
auto vanillaTex = DynOS_Mgr_VanillaTex_GetFromName(_Arg.begin());
if (vanillaTex != NULL) {

View File

@ -1406,6 +1406,13 @@ s64 DynOS_Lvl_ParseLevelScriptConstants(const String& _Arg, bool* found) {
static LevelScript ParseLevelScriptSymbolArgInternal(GfxData* aGfxData, DataNode<LevelScript>* aNode, u64& aTokenIndex, bool* found) {
const String& _Arg = aNode->mTokens[aTokenIndex++];
// Integers
bool integerFound = false;
s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound);
if (integerFound) {
return integerValue;
}
// Lvl functions
void *_LvlFunctionPtr = DynOS_Lvl_GetFunctionPointerFromName(_Arg);
if (_LvlFunctionPtr != NULL) {
@ -1489,12 +1496,6 @@ static LevelScript ParseLevelScriptSymbolArgInternal(GfxData* aGfxData, DataNode
return (LevelScript)vanillaGeo;
}
// Integers
s32 x;
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
return (LevelScript) x;
}
// Recursive descent parsing
bool rdSuccess = false;
s64 rdValue = DynOS_RecursiveDescent_Parse(_Arg.begin(), &rdSuccess, DynOS_Lvl_ParseLevelScriptConstants);
@ -1638,6 +1639,7 @@ static void ParseLevelScriptSymbol(GfxData* aGfxData, DataNode<LevelScript>* aNo
lvl_symbol_2(SKIP_IF, 0, 0);
lvl_symbol_0(SKIP);
lvl_symbol_0(SKIP_NOP);
lvl_symbol_3(JUMP_AREA_EXT, 2, 0, 0);
// calls
lvl_symbol_2(CALL, 1, 0);
@ -1798,6 +1800,18 @@ static void ParseLevelScriptSymbol(GfxData* aGfxData, DataNode<LevelScript>* aNo
return;
}
// JUMP_AREA
if (_Symbol == "JUMP_AREA") {
LevelScript _Arg0 = ParseLevelScriptSymbolArg(aGfxData, aNode, aTokenIndex);
LevelScript _Arg1 = ParseLevelScriptSymbolArg(aGfxData, aNode, aTokenIndex);
LevelScript _Arg2 = ParseLevelScriptSymbolArg(aGfxData, aNode, aTokenIndex);
aGfxData->mPointerList.Add(aHead + 2);
LevelScript _Ls[] = { JUMP_AREA_EXT(_Arg0, _Arg1, _Arg2) };
memcpy(aHead, _Ls, sizeof(_Ls));
aHead += (sizeof(_Ls) / sizeof(_Ls[0]));
return;
}
// Unknown
PrintError(" ERROR: Unknown lvl symbol: %s", _Symbol.begin());
}

View File

@ -18,6 +18,13 @@ extern "C" {
static s64 ParseMacroObjectSymbolArg(GfxData* aGfxData, DataNode<MacroObject>* aNode, u64& aTokenIndex) {
const String& _Arg = aNode->mTokens[aTokenIndex++];
// Integers
bool integerFound = false;
s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound);
if (integerFound) {
return integerValue;
}
// Surface constants
macro_object_constant(macro_yellow_coin);
macro_object_constant(macro_yellow_coin_2);
@ -389,12 +396,6 @@ static s64 ParseMacroObjectSymbolArg(GfxData* aGfxData, DataNode<MacroObject>* a
// Other constants
macro_object_constant(NULL);
// Integers
s32 x;
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
return (s64) x;
}
// Check level constants
bool constantFound = false;
s64 constantValue = DynOS_Lvl_ParseLevelScriptConstants(_Arg, &constantFound);

View File

@ -17,6 +17,13 @@ extern "C" {
static s64 ParseMovtexSymbolArg(GfxData* aGfxData, DataNode<Movtex>* aNode, u64& aTokenIndex) {
const String& _Arg = aNode->mTokens[aTokenIndex++];
// Integers
bool integerFound = false;
s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound);
if (integerFound) {
return integerValue;
}
// texture constants
movtex_constant(TEXTURE_WATER);
movtex_constant(TEXTURE_MIST);
@ -32,12 +39,6 @@ static s64 ParseMovtexSymbolArg(GfxData* aGfxData, DataNode<Movtex>* aNode, u64&
// Other constants
movtex_constant(NULL);
// Integers
s32 x;
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
return (s64) x;
}
// Unknown
PrintError(" ERROR: Unknown movtex arg: %s", _Arg.begin());
return 0;

View File

@ -17,15 +17,16 @@ extern "C" {
static s64 ParseTrajectorySymbolArg(GfxData* aGfxData, DataNode<Trajectory>* aNode, u64& aTokenIndex) {
const String& _Arg = aNode->mTokens[aTokenIndex++];
// Integers
bool integerFound = false;
s64 integerValue = DynOS_Misc_ParseInteger(_Arg, &integerFound);
if (integerFound) {
return integerValue;
}
// Other constants
trajectory_constant(NULL);
// Integers
s32 x;
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
return (s64) x;
}
// Unknown
PrintError(" ERROR: Unknown trajectory arg: %s", _Arg.begin());
return 0;

View File

@ -4,6 +4,16 @@
// Misc //
//////////
s64 DynOS_Misc_ParseInteger(const String& _Arg, bool* found) {
s32 x;
if ((_Arg[1] == 'x' && sscanf(_Arg.begin(), "%x", &x) == 1) || (sscanf(_Arg.begin(), "%d", &x) == 1)) {
*found = true;
return (s64) x;
}
*found = false;
return 0;
}
void DynOS_Gfx_Free(GfxData* aGfxData) {
if (aGfxData) {
for (auto& _Node : aGfxData->mLights) {

View File

@ -11,6 +11,7 @@ extern "C" {
extern "C" {
extern const BehaviorScript *sWarpBhvSpawnTable[];
#include "engine/level_script.h"
}
#define DYNOS_LEVEL_TEXT_EMPTY ""
@ -227,7 +228,13 @@ s32 DynOS_Level_GetCourse(s32 aLevel) {
const void *DynOS_Level_GetScript(s32 aLevel) {
DynOS_Level_Init();
if (aLevel != LEVEL_WDW) {
return DynOS_Lvl_Get(""); // DO NOT COMMIT
LevelScript* script = DynOS_Lvl_Get("");
sDynosCurrentLevelNum = aLevel;
sDynosLevelWarps[sDynosCurrentLevelNum].Clear();
DynOS_Level_ParseScript(script, DynOS_Level_PreprocessScript);
gLevelScriptModIndex = DynOS_Lvl_GetModIndex(script);
gLevelScriptActive = (LevelScript*)script;
return script; // DO NOT COMMIT
}
return sDynosLevelScripts[aLevel];
}
@ -705,6 +712,18 @@ static LvlCmd *DynOS_Level_CmdClearDemoPointer(Stack &aStack, LvlCmd *aCmd) {
return (LvlCmd *) DynOS_Level_CmdNext(aCmd, aCmd->mSize);
}
static LvlCmd *DynOS_Level_CmdPlaceObjectExt(Stack &aStack, LvlCmd *aCmd) {
return (LvlCmd *) DynOS_Level_CmdNext(aCmd, aCmd->mSize);
}
static LvlCmd *DynOS_Level_CmdPlaceObjectExt2(Stack &aStack, LvlCmd *aCmd) {
return (LvlCmd *) DynOS_Level_CmdNext(aCmd, aCmd->mSize);
}
static LvlCmd *DynOS_Level_CmdLoadModelFromGeoExt(Stack &aStack, LvlCmd *aCmd) {
return (LvlCmd *) DynOS_Level_CmdNext(aCmd, aCmd->mSize);
}
static LvlCmd *DynOS_Level_CmdJumpArea(Stack &aStack, LvlCmd *aCmd, s32 (*aPreprocessFunction)(u8, void *)) {
DynOS_Level_ParseScript((const void *) DynOS_Level_CmdGet(aCmd, 8), aPreprocessFunction);
return (LvlCmd *) DynOS_Level_CmdNext(aCmd, aCmd->mSize);
@ -715,7 +734,7 @@ static void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFuncti
_Stack.mBaseIndex = -1;
_Stack.mTopIndex = 0;
for (LvlCmd *_Cmd = (LvlCmd *) aScript; _Cmd != NULL;) {
u8 _CmdType = (_Cmd->mType & 0x3F);
u8 _CmdType = (_Cmd->mType & 0xFF);
s32 _Action = aPreprocessFunction(_CmdType, (void *) _Cmd);
switch (_Action) {
case 0:
@ -783,7 +802,11 @@ static void DynOS_Level_ParseScript(const void *aScript, s32 (*aPreprocessFuncti
case 0x3C: _Cmd = DynOS_Level_CmdGetOrSet(_Stack, _Cmd); break;
case 0x3D: _Cmd = DynOS_Level_CmdAdvanceDemo(_Stack, _Cmd); break;
case 0x3E: _Cmd = DynOS_Level_CmdClearDemoPointer(_Stack, _Cmd); break;
case 0x3F: _Cmd = DynOS_Level_CmdJumpArea(_Stack, _Cmd, aPreprocessFunction); break;
// coop
case 0x3F: _Cmd = DynOS_Level_CmdPlaceObjectExt(_Stack, _Cmd); break;
case 0x40: _Cmd = DynOS_Level_CmdPlaceObjectExt2(_Stack, _Cmd); break;
case 0x41: _Cmd = DynOS_Level_CmdLoadModelFromGeoExt(_Stack, _Cmd); break;
case 0x42: _Cmd = DynOS_Level_CmdJumpArea(_Stack, _Cmd, aPreprocessFunction); break;
} break;
case 1:

View File

@ -8,8 +8,12 @@ extern "C" {
#include "levels/bitfs/header.h"
#include "levels/bits/header.h"
#include "levels/bob/header.h"
#include "levels/bowser_1/header.h"
#include "levels/bowser_2/header.h"
#include "levels/bowser_2/header.h"
#include "levels/bowser_3/header.h"
#include "levels/bowser_3/header.h"
#include "levels/castle_courtyard/header.h"
#include "levels/castle_grounds/header.h"
#include "levels/castle_inside/header.h"
#include "levels/ccm/header.h"
@ -17,18 +21,24 @@ extern "C" {
#include "levels/hmc/header.h"
#include "levels/jrb/header.h"
#include "levels/lll/header.h"
#include "levels/pss/header.h"
#include "levels/rr/header.h"
#include "levels/sa/header.h"
#include "levels/sl/header.h"
#include "levels/ssl/header.h"
#include "levels/thi/header.h"
#include "levels/totwc/header.h"
#include "levels/ttc/header.h"
#include "levels/ttm/header.h"
#include "levels/vcutm/header.h"
#include "levels/wdw/header.h"
#include "levels/wf/header.h"
#include "levels/wmotr/header.h"
#include "textures.h"
}
#define MGR_FIND_DATA(_DataTable, _Cast) \
size_t _count = sizeof(_DataTable) / (2 * sizeof(_DataTable[0])); \
for (u32 _i = 0; _i < _count; _i++) { \
@ -89,73 +99,6 @@ const char* DynOS_Mgr_VanillaScriptPtr_GetFromData(const void* aData) {
#define define_vanilla_lvl_geo(tex) (const void*) #tex, (const void*) tex
static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(geo_bbh_0005B0),
define_vanilla_lvl_geo(geo_bbh_0005C8),
define_vanilla_lvl_geo(geo_bbh_0005E0),
define_vanilla_lvl_geo(geo_bbh_0005F8),
define_vanilla_lvl_geo(geo_bbh_000610),
define_vanilla_lvl_geo(geo_bbh_000628),
define_vanilla_lvl_geo(geo_bbh_000640),
define_vanilla_lvl_geo(geo_bbh_000658),
define_vanilla_lvl_geo(geo_bbh_000670),
define_vanilla_lvl_geo(geo_bbh_0006B0),
define_vanilla_lvl_geo(geo_bbh_0006E8),
define_vanilla_lvl_geo(geo_bbh_000730),
define_vanilla_lvl_geo(geo_bbh_000750),
define_vanilla_lvl_geo(geo_bbh_000768),
define_vanilla_lvl_geo(geo_bbh_0007B0),
define_vanilla_lvl_geo(geo_bbh_0007D0),
define_vanilla_lvl_geo(geo_bbh_000800),
define_vanilla_lvl_geo(geo_bbh_000828),
define_vanilla_lvl_geo(geo_bbh_000860),
define_vanilla_lvl_geo(geo_bbh_000888),
define_vanilla_lvl_geo(geo_bbh_0008B0),
define_vanilla_lvl_geo(geo_bbh_0008E8),
define_vanilla_lvl_geo(geo_bbh_000950),
define_vanilla_lvl_geo(geo_bbh_0009C8),
define_vanilla_lvl_geo(geo_bbh_000A18),
define_vanilla_lvl_geo(geo_bbh_000A60),
define_vanilla_lvl_geo(geo_bbh_000AD8),
define_vanilla_lvl_geo(geo_bbh_000B28),
define_vanilla_lvl_geo(geo_bbh_000B88),
define_vanilla_lvl_geo(geo_bbh_000BF0),
define_vanilla_lvl_geo(geo_bbh_000C38),
define_vanilla_lvl_geo(geo_bbh_000C88),
define_vanilla_lvl_geo(geo_bbh_000CE8),
define_vanilla_lvl_geo(geo_bbh_000D20),
define_vanilla_lvl_geo(geo_bbh_000D68),
define_vanilla_lvl_geo(geo_bbh_000DB0),
define_vanilla_lvl_geo(geo_bbh_000DF0),
define_vanilla_lvl_geo(geo_bbh_000E40),
define_vanilla_lvl_geo(geo_bbh_000E80),
define_vanilla_lvl_geo(geo_bbh_000EB0),
define_vanilla_lvl_geo(geo_bbh_000F00),
define_vanilla_lvl_geo(geo_bitdw_0003C0),
define_vanilla_lvl_geo(geo_bitdw_0003D8),
define_vanilla_lvl_geo(geo_bitdw_0003F0),
define_vanilla_lvl_geo(geo_bitdw_000408),
define_vanilla_lvl_geo(geo_bitdw_000420),
define_vanilla_lvl_geo(geo_bitdw_000438),
define_vanilla_lvl_geo(geo_bitdw_000450),
define_vanilla_lvl_geo(geo_bitdw_000468),
define_vanilla_lvl_geo(geo_bitdw_000480),
define_vanilla_lvl_geo(geo_bitdw_000498),
define_vanilla_lvl_geo(geo_bitdw_0004B0),
define_vanilla_lvl_geo(geo_bitdw_0004C8),
define_vanilla_lvl_geo(geo_bitdw_0004E0),
define_vanilla_lvl_geo(geo_bitdw_0004F8),
define_vanilla_lvl_geo(geo_bitdw_000510),
define_vanilla_lvl_geo(geo_bitdw_000528),
define_vanilla_lvl_geo(geo_bitdw_000540),
define_vanilla_lvl_geo(geo_bitdw_000558),
define_vanilla_lvl_geo(geo_bitdw_000570),
define_vanilla_lvl_geo(geo_bitdw_000588),
define_vanilla_lvl_geo(geo_bitdw_0005A0),
define_vanilla_lvl_geo(geo_bitdw_0005B8),
define_vanilla_lvl_geo(geo_bitdw_0005D0),
define_vanilla_lvl_geo(geo_bitdw_0005E8),
define_vanilla_lvl_geo(geo_bitdw_000600),
define_vanilla_lvl_geo(geo_bitdw_000618),
define_vanilla_lvl_geo(bitfs_geo_0004B0),
define_vanilla_lvl_geo(bitfs_geo_0004C8),
define_vanilla_lvl_geo(bitfs_geo_0004E0),
@ -224,25 +167,37 @@ static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(bob_geo_000458),
define_vanilla_lvl_geo(bob_geo_000470),
define_vanilla_lvl_geo(bob_geo_000488),
define_vanilla_lvl_geo(bowser_1_geo_0000D0),
define_vanilla_lvl_geo(bowser_2_geo_000170),
define_vanilla_lvl_geo(bowser_2_geo_000170),
define_vanilla_lvl_geo(bowser_2_geo_000188),
define_vanilla_lvl_geo(bowser_2_geo_000188),
define_vanilla_lvl_geo(bowser_3_geo_000290),
define_vanilla_lvl_geo(bowser_3_geo_000290),
define_vanilla_lvl_geo(bowser_3_geo_0002A8),
define_vanilla_lvl_geo(bowser_3_geo_0002A8),
define_vanilla_lvl_geo(bowser_3_geo_0002C0),
define_vanilla_lvl_geo(bowser_3_geo_0002C0),
define_vanilla_lvl_geo(bowser_3_geo_0002D8),
define_vanilla_lvl_geo(bowser_3_geo_0002D8),
define_vanilla_lvl_geo(bowser_3_geo_0002F0),
define_vanilla_lvl_geo(bowser_3_geo_0002F0),
define_vanilla_lvl_geo(bowser_3_geo_000308),
define_vanilla_lvl_geo(bowser_3_geo_000308),
define_vanilla_lvl_geo(bowser_3_geo_000320),
define_vanilla_lvl_geo(bowser_3_geo_000320),
define_vanilla_lvl_geo(bowser_3_geo_000338),
define_vanilla_lvl_geo(bowser_3_geo_000338),
define_vanilla_lvl_geo(bowser_3_geo_000350),
define_vanilla_lvl_geo(bowser_3_geo_000350),
define_vanilla_lvl_geo(bowser_3_geo_000368),
define_vanilla_lvl_geo(bowser_3_geo_000368),
define_vanilla_lvl_geo(bowser_3_geo_000380),
define_vanilla_lvl_geo(bowser_3_geo_000380),
define_vanilla_lvl_geo(bowser_3_geo_000398),
define_vanilla_lvl_geo(castle_grounds_geo_000660),
define_vanilla_lvl_geo(castle_grounds_geo_0006F4),
define_vanilla_lvl_geo(castle_grounds_geo_00070C),
define_vanilla_lvl_geo(castle_grounds_geo_000724),
define_vanilla_lvl_geo(castle_grounds_geo_00073C),
define_vanilla_lvl_geo(bowser_3_geo_000398),
define_vanilla_lvl_geo(castle_courtyard_geo_000200),
define_vanilla_lvl_geo(castle_courtyard_geo_000218),
define_vanilla_lvl_geo(castle_geo_000F00),
define_vanilla_lvl_geo(castle_geo_000F18),
define_vanilla_lvl_geo(castle_geo_000F30),
@ -290,6 +245,11 @@ static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(castle_geo_001B48),
define_vanilla_lvl_geo(castle_geo_001BB0),
define_vanilla_lvl_geo(castle_geo_001C10),
define_vanilla_lvl_geo(castle_grounds_geo_000660),
define_vanilla_lvl_geo(castle_grounds_geo_0006F4),
define_vanilla_lvl_geo(castle_grounds_geo_00070C),
define_vanilla_lvl_geo(castle_grounds_geo_000724),
define_vanilla_lvl_geo(castle_grounds_geo_00073C),
define_vanilla_lvl_geo(ccm_geo_0003D0),
define_vanilla_lvl_geo(ccm_geo_0003F0),
define_vanilla_lvl_geo(ccm_geo_00040C),
@ -305,6 +265,73 @@ static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(ddd_geo_0004A0),
define_vanilla_lvl_geo(ddd_geo_0004C0),
define_vanilla_lvl_geo(ddd_geo_000570),
define_vanilla_lvl_geo(geo_bbh_0005B0),
define_vanilla_lvl_geo(geo_bbh_0005C8),
define_vanilla_lvl_geo(geo_bbh_0005E0),
define_vanilla_lvl_geo(geo_bbh_0005F8),
define_vanilla_lvl_geo(geo_bbh_000610),
define_vanilla_lvl_geo(geo_bbh_000628),
define_vanilla_lvl_geo(geo_bbh_000640),
define_vanilla_lvl_geo(geo_bbh_000658),
define_vanilla_lvl_geo(geo_bbh_000670),
define_vanilla_lvl_geo(geo_bbh_0006B0),
define_vanilla_lvl_geo(geo_bbh_0006E8),
define_vanilla_lvl_geo(geo_bbh_000730),
define_vanilla_lvl_geo(geo_bbh_000750),
define_vanilla_lvl_geo(geo_bbh_000768),
define_vanilla_lvl_geo(geo_bbh_0007B0),
define_vanilla_lvl_geo(geo_bbh_0007D0),
define_vanilla_lvl_geo(geo_bbh_000800),
define_vanilla_lvl_geo(geo_bbh_000828),
define_vanilla_lvl_geo(geo_bbh_000860),
define_vanilla_lvl_geo(geo_bbh_000888),
define_vanilla_lvl_geo(geo_bbh_0008B0),
define_vanilla_lvl_geo(geo_bbh_0008E8),
define_vanilla_lvl_geo(geo_bbh_000950),
define_vanilla_lvl_geo(geo_bbh_0009C8),
define_vanilla_lvl_geo(geo_bbh_000A18),
define_vanilla_lvl_geo(geo_bbh_000A60),
define_vanilla_lvl_geo(geo_bbh_000AD8),
define_vanilla_lvl_geo(geo_bbh_000B28),
define_vanilla_lvl_geo(geo_bbh_000B88),
define_vanilla_lvl_geo(geo_bbh_000BF0),
define_vanilla_lvl_geo(geo_bbh_000C38),
define_vanilla_lvl_geo(geo_bbh_000C88),
define_vanilla_lvl_geo(geo_bbh_000CE8),
define_vanilla_lvl_geo(geo_bbh_000D20),
define_vanilla_lvl_geo(geo_bbh_000D68),
define_vanilla_lvl_geo(geo_bbh_000DB0),
define_vanilla_lvl_geo(geo_bbh_000DF0),
define_vanilla_lvl_geo(geo_bbh_000E40),
define_vanilla_lvl_geo(geo_bbh_000E80),
define_vanilla_lvl_geo(geo_bbh_000EB0),
define_vanilla_lvl_geo(geo_bbh_000F00),
define_vanilla_lvl_geo(geo_bitdw_0003C0),
define_vanilla_lvl_geo(geo_bitdw_0003D8),
define_vanilla_lvl_geo(geo_bitdw_0003F0),
define_vanilla_lvl_geo(geo_bitdw_000408),
define_vanilla_lvl_geo(geo_bitdw_000420),
define_vanilla_lvl_geo(geo_bitdw_000438),
define_vanilla_lvl_geo(geo_bitdw_000450),
define_vanilla_lvl_geo(geo_bitdw_000468),
define_vanilla_lvl_geo(geo_bitdw_000480),
define_vanilla_lvl_geo(geo_bitdw_000498),
define_vanilla_lvl_geo(geo_bitdw_0004B0),
define_vanilla_lvl_geo(geo_bitdw_0004C8),
define_vanilla_lvl_geo(geo_bitdw_0004E0),
define_vanilla_lvl_geo(geo_bitdw_0004F8),
define_vanilla_lvl_geo(geo_bitdw_000510),
define_vanilla_lvl_geo(geo_bitdw_000528),
define_vanilla_lvl_geo(geo_bitdw_000540),
define_vanilla_lvl_geo(geo_bitdw_000558),
define_vanilla_lvl_geo(geo_bitdw_000570),
define_vanilla_lvl_geo(geo_bitdw_000588),
define_vanilla_lvl_geo(geo_bitdw_0005A0),
define_vanilla_lvl_geo(geo_bitdw_0005B8),
define_vanilla_lvl_geo(geo_bitdw_0005D0),
define_vanilla_lvl_geo(geo_bitdw_0005E8),
define_vanilla_lvl_geo(geo_bitdw_000600),
define_vanilla_lvl_geo(geo_bitdw_000618),
define_vanilla_lvl_geo(hmc_geo_000530),
define_vanilla_lvl_geo(hmc_geo_000548),
define_vanilla_lvl_geo(hmc_geo_000570),
@ -386,6 +413,7 @@ static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(lll_geo_000E00),
define_vanilla_lvl_geo(lll_geo_000EA8),
define_vanilla_lvl_geo(lll_geo_000EC0),
define_vanilla_lvl_geo(pss_geo_000100),
define_vanilla_lvl_geo(rr_geo_000660),
define_vanilla_lvl_geo(rr_geo_000678),
define_vanilla_lvl_geo(rr_geo_000690),
@ -423,6 +451,7 @@ static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(rr_geo_0009A0),
define_vanilla_lvl_geo(rr_geo_0009B8),
define_vanilla_lvl_geo(rr_geo_0009D0),
define_vanilla_lvl_geo(sa_geo_000170),
define_vanilla_lvl_geo(sl_geo_000360),
define_vanilla_lvl_geo(sl_geo_000378),
define_vanilla_lvl_geo(sl_geo_000390),
@ -445,6 +474,8 @@ static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(thi_geo_000608),
define_vanilla_lvl_geo(thi_geo_0006D4),
define_vanilla_lvl_geo(thi_geo_00079C),
define_vanilla_lvl_geo(totwc_geo_000160),
define_vanilla_lvl_geo(totwc_geo_000188),
define_vanilla_lvl_geo(ttc_geo_000240),
define_vanilla_lvl_geo(ttc_geo_000258),
define_vanilla_lvl_geo(ttc_geo_000270),
@ -491,6 +522,8 @@ static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(ttm_geo_000D84),
define_vanilla_lvl_geo(ttm_geo_000DBC),
define_vanilla_lvl_geo(ttm_geo_000DF4),
define_vanilla_lvl_geo(vcutm_geo_0001F0),
define_vanilla_lvl_geo(vcutm_geo_000208),
define_vanilla_lvl_geo(wdw_geo_000580),
define_vanilla_lvl_geo(wdw_geo_000598),
define_vanilla_lvl_geo(wdw_geo_0005C0),
@ -531,6 +564,7 @@ static const void* sDynosVanillaLvlGeos[] = {
define_vanilla_lvl_geo(wf_geo_000BC8),
define_vanilla_lvl_geo(wf_geo_000BE0),
define_vanilla_lvl_geo(wf_geo_000BF8),
define_vanilla_lvl_geo(wmotr_geo_0001F0),
};
const GeoLayout* DynOS_Mgr_VanillaLvlGeo_GetFromName(const char* aDataName) {

View File

@ -659,13 +659,15 @@ void DynOS_Lvl_Add(s32 modIndex, const SysPath &aPackFolder, const char *aLevelN
}
LevelScript* DynOS_Lvl_Get(const char* levelName) {
static u32 index = 0; // DO NOT COMMIT
s32 levelScriptCount = sDynosCustomLevelScripts.Count(); // DO NOT COMMIT
if (levelScriptCount < 1) { return NULL; } // DO NOT COMMIT
index = (index + 1) % levelScriptCount; // DO NOT COMMIT
auto& scripts = sDynosCustomLevelScripts[index].second->mLevelScripts; // DO NOT COMMIT
Print("Going to level: %s\n", scripts[scripts.Count() - 1]->mName); // DO NOT COMMIT
return scripts[scripts.Count() - 1]->mData; // DO NOT COMMIT
if (strlen(levelName) == 0) {
static u32 index = 0; // DO NOT COMMIT
s32 levelScriptCount = sDynosCustomLevelScripts.Count(); // DO NOT COMMIT
if (levelScriptCount < 1) { return NULL; } // DO NOT COMMIT
index = (index + 1) % levelScriptCount; // DO NOT COMMIT
auto& scripts = sDynosCustomLevelScripts[index].second->mLevelScripts; // DO NOT COMMIT
Print("Going to level: %s\n", scripts[scripts.Count() - 1]->mName); // DO NOT COMMIT
return scripts[scripts.Count() - 1]->mData; // DO NOT COMMIT
}
for (s32 i = 0; i < sDynosCustomLevelScripts.Count(); ++i) {
if (!strcmp(sDynosCustomLevelScripts[i].first, levelName)) {

View File

@ -11,7 +11,6 @@ extern "C" {
#include "game/sound_init.h"
#include "game/object_list_processor.h"
#include "game/options_menu.h"
#include "engine/level_script.h"
extern s8 gDialogBoxState;
extern s16 gMenuMode;
extern s32 gWdwWaterLevelSet;
@ -249,10 +248,7 @@ static void *DynOS_Warp_UpdateWarp(void *aCmd, bool aIsLevelInitDone) {
sWarpDest.areaIdx = gCurrAreaIndex;
sWarpDest.nodeId = 0;
sWarpDest.arg = 0;
void* levelScript = (void *) DynOS_Level_GetScript(gCurrLevelNum);
gLevelScriptModIndex = DynOS_Lvl_GetModIndex(levelScript);
gLevelScriptActive = (LevelScript*)levelScript;
return levelScript;
return (void *) DynOS_Level_GetScript(gCurrLevelNum);
} else {

View File

@ -307,4 +307,9 @@
CMD_BBH(0x41, 0x08, model), \
CMD_PTR(geo)
#define JUMP_AREA_EXT(op, arg, target) \
CMD_BBBB(0x42, 0x0C, op, 0x00), \
CMD_W(arg), \
CMD_PTR(target)
#endif // LEVEL_COMMANDS_H

View File

@ -14,6 +14,7 @@
#include "game/profiler.h"
#include "game/save_file.h"
#include "game/sound_init.h"
#include "game/level_update.h"
#include "goddard/renderer.h"
#include "geo_layout.h"
#include "graph_node.h"
@ -59,6 +60,10 @@ static s16 sScriptStatus;
static s32 sRegister;
static struct LevelCommand *sCurrentCmd;
static s32 eval_script_area(s32 arg) {
return (sWarpDest.areaIdx == arg);
}
static s32 eval_script_op(s8 op, s32 arg) {
s32 result = 0;
@ -925,6 +930,14 @@ static void level_cmd_load_model_from_geo_ext(void) {
sCurrentCmd = CMD_NEXT;
}
static void level_cmd_jump_area_ext(void) {
if (eval_script_area(CMD_GET(s32, 4))) {
sCurrentCmd = segmented_to_virtual(CMD_GET(void *, 8));
} else {
sCurrentCmd = CMD_NEXT;
}
}
static void (*LevelScriptJumpTable[])(void) = {
/*00*/ level_cmd_load_and_execute,
/*01*/ level_cmd_exit_and_execute,
@ -994,6 +1007,7 @@ static void (*LevelScriptJumpTable[])(void) = {
/*3F*/ level_cmd_place_object_ext,
/*40*/ level_cmd_place_object_ext2,
/*41*/ level_cmd_load_model_from_geo_ext,
/*42*/ level_cmd_jump_area_ext,
};
struct LevelCommand *level_script_execute(struct LevelCommand *cmd) {

View File

@ -6,7 +6,7 @@
#include "src/pc/platform.h"
#include "mod.h"
#define MAX_MOD_SIZE (10 * 1048576) // 10MB
#define MAX_MOD_SIZE (15 * 1048576) // 15MB
#define TMP_DIRECTORY "tmp"
struct Mods {