map header WIP

This commit is contained in:
Ethan Roseman 2020-10-23 08:31:56 -04:00
parent 2462200b48
commit 98d8bdd789
11 changed files with 65 additions and 11 deletions

View File

@ -1,6 +1,6 @@
#include "common.h"
static ApiStatus AwaitPlayerNearNpc(ScriptInstance* script, s32 isInitialCall) {
ApiStatus AwaitPlayerNearNpc(ScriptInstance* script, s32 isInitialCall) {
PlayerStatus* playerStatus = PLAYER_STATUS;
Npc* npc = get_npc_safe(script->owner2.npcID);

View File

@ -1,6 +1,6 @@
#include "common.h"
static ApiStatus Bandit_DropCoin(ScriptInstance* script, s32 isInitialCall) {
ApiStatus Bandit_DropCoin(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
NpcId npcID;
Npc* npc;

View File

@ -1,6 +1,6 @@
#include "common.h"
static ApiStatus GetItemName(ScriptInstance* script, s32 isInitialCall) {
ApiStatus GetItemName(ScriptInstance* script, s32 isInitialCall) {
Bytecode a0 = *script->ptrReadPos;
s32 itemID = get_variable(script, a0);

View File

@ -1,6 +1,6 @@
#include "common.h"
static ApiStatus GetNpcCollisionHeight(ScriptInstance* script, s32 isInitialCall) {
ApiStatus GetNpcCollisionHeight(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
NpcId npcID = get_variable(script, *args++);
Npc* npc = get_npc_safe(npcID);

View File

@ -1,6 +1,6 @@
#include "common.h"
static ApiStatus Set8009A650_40(ScriptInstance* script, s32 isInitialCall) {
ApiStatus Set8009A650_40(ScriptInstance* script, s32 isInitialCall) {
D_8009A650[0] |= 0x40;
return ApiStatus_DONE2;
}

View File

@ -1,6 +1,6 @@
#include "common.h"
static ApiStatus SetManyVars(ScriptInstance* script, s32 isInitialCall) {
ApiStatus SetManyVars(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
script->varTable[2] = get_variable(script, *args++);

View File

@ -1,7 +1,7 @@
#include "common.h"
#include "map.h"
static ApiStatus func_80240040_9292B0(ScriptInstance* script, s32 isInitialCall) {
ApiStatus func_80240040_9292B0(ScriptInstance* script, s32 isInitialCall) {
script->owner1.enemy->unk_B5 = 3;
return ApiStatus_DONE2;
}

View File

@ -1,13 +1,13 @@
#include "common.h"
static void SomeMatrixOperation(Matrix4f* mtx, f32 arg1, f32 arg2, f32 arg3) {
void SomeMatrixOperation(Matrix4f* mtx, f32 arg1, f32 arg2, f32 arg3) {
guMtxIdentF(mtx);
mtx->mtx[1][0] = arg1 * arg2;
mtx->mtx[1][1] = 1.0f;
mtx->mtx[1][2] = arg1 * arg3;
}
static ApiStatus SomeMatrixOperation2(ScriptInstance* script, s32 isInitialCall) {
ApiStatus SomeMatrixOperation2(ScriptInstance* script, s32 isInitialCall) {
Bytecode* args = script->ptrReadPos;
s32 modelListIndex = get_model_list_index_from_tree_index(get_variable(script, *args++));
f32 temp_f28 = get_float_variable(script, *args++);

View File

@ -1,6 +1,6 @@
#include "common.h"
static ApiStatus SomeXYZFuncTodoRename(ScriptInstance* script) {
ApiStatus SomeXYZFuncTodoRename(ScriptInstance* script) {
PlayerStatus* playerStatus = PLAYER_STATUS;
Bytecode* args = script->ptrReadPos;
s32 xVar = *args++;

View File

@ -1,6 +1,6 @@
#include "common.h"
static ApiStatus SpawnSunEffect(ScriptInstance* script, s32 isInitialCall) {
ApiStatus SpawnSunEffect(ScriptInstance* script, s32 isInitialCall) {
func_80072950(0, 0.0f, 0.0f, 0.0f, 0.0f, 0);
return ApiStatus_DONE2;
}

54
tools/mapheaders.py Executable file
View File

@ -0,0 +1,54 @@
#!/usr/bin/python3
import argparse
from collections import OrderedDict
import os
import re
import pickle
import sys
from pathlib import Path
script_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = script_dir + "/../"
src_dir = root_dir + "src/world/"
asm_dir = root_dir + "asm/nonmatchings/world/"
def sub_func(match):
m_str = match.group()
m_str_split = m_str.split(", ")
func_name = m_str_split[-1][:-2]
path_elems = m_str_split[-2].split("/")[1:]
asmd = os.path.join(asm_dir, path_elems[0], path_elems[1], path_elems[2][:-1])
for root, dirs, files in os.walk(asmd):
for f_name in files:
f_name = f_name[:-2]
if f_name.startswith(func_name) and len(f_name) > len(func_name):
return m_str.replace(func_name, f_name)
return m_str
for root, dirs, files in os.walk(src_dir):
for f_name in files:
if f_name.endswith(".c"):
f_path = os.path.join(root, f_name)
area_name = Path(f_path).parent.name
with open(f_path) as f:
f_text_orig = f.readlines()
f_text = []
if f_name == "DF6A20.c":
dog = 5
for line in f_text_orig:
new_line = re.sub(r"INCLUDE_ASM.*\);", sub_func, line)
f_text.append(new_line)
if f_text != f_text_orig:
with open(f_path, "w", newline="\n") as f:
f.writelines(f_text)