mirror of
https://github.com/izzy2lost/Ghostship.git
synced 2026-06-19 01:17:03 -07:00
First implementation of OTR loading
This commit is contained in:
+1
-1
Submodule libultraship updated: 2a1ce0001d...555869b6c5
+6
-5
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -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);
|
||||
|
||||
+3
-3
@@ -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();
|
||||
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user