diff --git a/libultraship b/libultraship index 2a1ce000..555869b6 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit 2a1ce0001df7383e87f364e89b33358b9e294ab3 +Subproject commit 555869b6c5324805f27f8a62dade9ab6609b3783 diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp index d8c37bca..78893dbb 100644 --- a/src/port/Engine.cpp +++ b/src/port/Engine.cpp @@ -8,18 +8,19 @@ GameEngine* GameEngine::Instance; GameEngine::GameEngine(){ - std::string main = LUS::Context::GetPathRelativeToAppBundle("soh.otr"); - this->context = LUS::Context::CreateInstance("Ghostship", "sm64", "ghostship.cfg.json", {main}, {}, 3); + std::string main = LUS::Context::GetPathRelativeToAppBundle("smcube.otr"); + std::string assets = LUS::Context::GetPathRelativeToAppBundle("soh.otr"); + this->context = LUS::Context::CreateInstance("Ghostship", "sm64", "ghostship.cfg.json", { main, assets }, {}, 3); this->context->GetWindow()->SetTargetFps(30); this->context->GetWindow()->SetMaximumFrameLatency(1); } -void GameEngine::Create(void){ +void GameEngine::Create(){ GameEngine::Instance = new GameEngine(); GameUI::SetupGuiElements(); } -void GameEngine::StartFrame(void){ +void GameEngine::StartFrame() const{ this->context->GetWindow()->StartFrame(); } @@ -28,7 +29,7 @@ void GameEngine::RunCommands(Gfx* Commands) { gfx_end_frame(); } -void GameEngine::ProcessFrame(void (*run_one_game_iter)(void)) { +void GameEngine::ProcessFrame(void (*run_one_game_iter)()) const { this->context->GetWindow()->MainLoop(run_one_game_iter); } diff --git a/src/port/Engine.h b/src/port/Engine.h index 232d822e..ea5c4fb7 100644 --- a/src/port/Engine.h +++ b/src/port/Engine.h @@ -18,9 +18,9 @@ class GameEngine { GameEngine(); ~GameEngine(); static void Create(void); - void StartFrame(void); - void RunCommands(Gfx* Commands); - void ProcessFrame(void (*run_one_game_iter)(void)); + void StartFrame(void) const; + static void RunCommands(Gfx* Commands); + void ProcessFrame(void (*run_one_game_iter)(void)) const; }; #else uint32_t GameEngine_GetSampleRate(void); diff --git a/src/port/Game.cpp b/src/port/Game.cpp index 01aae080..e73b6572 100644 --- a/src/port/Game.cpp +++ b/src/port/Game.cpp @@ -11,7 +11,7 @@ extern "C" { bool sAudioEnabled = true; -void alloc_pool(void) { +void alloc_pool() { static u64 pool[1024 * 1024 * 4]; main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0])); gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT); @@ -19,10 +19,10 @@ void alloc_pool(void) { extern "C" void exec_display_list(SPTask *spTask) { - GameEngine::Instance->RunCommands((Gfx*) spTask->task.t.data_ptr); + GameEngine::RunCommands((Gfx*) spTask->task.t.data_ptr); } -void push_frame(void) { +void push_frame() { GameEngine::Instance->StartFrame(); thread5_iteration(); diff --git a/tools/texture_converter.py b/tools/texture_converter.py new file mode 100644 index 00000000..a9a9009f --- /dev/null +++ b/tools/texture_converter.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 + +import sys +import os +import os.path +import glob +import re +from pathlib import Path +# ALIGNED8 static const Texture chain_ball_seg6_texture_06020AE8[] +prefixes = [ + "ALIGNED8 static const u8", "static const u8", "ALIGNED8 static u8", "ALIGNED8 u8", "ALIGNED8 const u8", "u8", + "ALIGNED8 static const Texture", "static const Texture", "ALIGNED8 static Texture", "ALIGNED8 Texture", "ALIGNED8 const Texture", "Texture", +] + +def parse_model(file, lines, overwrite): + searchInclude = False + searchLineIndex = 0 + searchLineOriginal = "" + needsReplace = False + includePath = "" + for lineIndex, uline in enumerate(lines, 0): + line = uline.strip() + if not searchInclude: + for prefix in prefixes: + if line.rstrip().startswith(prefix) and "[] = {" in line: + searchInclude = True + searchLineIndex = lineIndex + searchLineOriginal = line + else: + if line.startswith("#include"): + includePath = line.replace("#include \"", "\"__OTR__").replace(".inc.c", "").replace(".rgba16", "").replace(".rgba32", "").replace(".ia16", "").replace(".ia1", "").replace(".ia4", "").replace(".ia8", "") + elif line.endswith("};") and includePath != "": + lines[searchLineIndex] = searchLineOriginal.replace("[] = {", f"[] = {includePath};") + lines[searchLineIndex + 1] = "" + lines[searchLineIndex + 2] = "\n" + searchInclude = False + searchLineIndex = 0 + searchLineOriginal = "" + needsReplace = True + includePath = "" + else: + searchInclude = False + nfile = os.path.abspath(file) if overwrite else os.path.abspath(file.replace("\\", "/").replace("sm64-cc02/", "sm64-cc02/overwriten/")) + npath = os.path.dirname(nfile) + + if needsReplace: + if not os.path.isdir(npath): + os.makedirs(npath) + f = open(nfile, "w") + f.writelines(lines) + f.close() + +if not len(sys.argv) > 1: + path = f"{str(Path(__file__).resolve().parents[1])}/**/*.c" + + print(f"Converting repo textures this may take a long time") + + for file in glob.iglob(path, recursive=True): + try: + if not "\\build" in file: + parse_model(file, open(file, 'r').readlines(), False) + except Exception as err: + print(f"Error on {file}") + print(err) +else: + file = os.path.abspath(sys.argv[1]) + try: + if os.path.isfile(file): + print(f"Converting {file} textures") + parse_model(file, open(file, 'r').readlines(), True) + else: + print(f"Invalid Path") + except Exception as err: + print(f"Error on {file}") + print(err) \ No newline at end of file