Pulling model and animation sources from sm64-port repo with script
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
/build/
|
/build/
|
||||||
/libsm64.so
|
/libsm64.so
|
||||||
Makefile
|
Makefile
|
||||||
|
/src/mario
|
||||||
|
|||||||
@@ -7,6 +7,11 @@ CFLAGS='-Wall -fPIC'
|
|||||||
BIN_FILE='libsm64.so'
|
BIN_FILE='libsm64.so'
|
||||||
LDFLAGS=''
|
LDFLAGS=''
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
git submodule update --init --recursive
|
||||||
|
./extract-decomp-source.py
|
||||||
|
}
|
||||||
|
|
||||||
c_to_obj() {
|
c_to_obj() {
|
||||||
printf 'build/'
|
printf 'build/'
|
||||||
echo "$1" | sed 's/cp*$/o/;s:/:_:g'
|
echo "$1" | sed 's/cp*$/o/;s:/:_:g'
|
||||||
@@ -34,9 +39,14 @@ print_makefile() {
|
|||||||
make_cmd "$f"
|
make_cmd "$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo '.PHONY: clean run'
|
echo -e "src/mario/anim_data.inc.c: extract-decomp-source.py\n\t ./extract-decomp-source.py"
|
||||||
|
echo -e "src/mario/geo.inc.c: extract-decomp-source.py\n\t ./extract-decomp-source.py"
|
||||||
|
echo -e "src/mario/model.inc.c: extract-decomp-source.py\n\t ./extract-decomp-source.py"
|
||||||
|
|
||||||
|
echo '.PHONY: clean run .FORCE'
|
||||||
echo -e "clean:\n\t find . -iname '*.o' | xargs rm && rm -f ./$BIN_FILE"
|
echo -e "clean:\n\t find . -iname '*.o' | xargs rm && rm -f ./$BIN_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
print_makefile > Makefile
|
print_makefile > Makefile
|
||||||
Executable
+107
@@ -0,0 +1,107 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
geo_inc_c_header = """
|
||||||
|
#include "../include/sm64.h"
|
||||||
|
#include "../include/types.h"
|
||||||
|
#include "../include/geo_commands.h"
|
||||||
|
#include "../game/rendering_graph_node.h"
|
||||||
|
#include "../shim.h"
|
||||||
|
#include "../game/object_stuff.h"
|
||||||
|
#include "../game/behavior_actions.h"
|
||||||
|
#include "model.inc.h"
|
||||||
|
|
||||||
|
#define SHADOW_CIRCLE_PLAYER 99
|
||||||
|
"""
|
||||||
|
|
||||||
|
geo_inc_c_footer = """
|
||||||
|
const GeoLayout mario_geo_libsm64[] = {
|
||||||
|
GEO_SHADOW(SHADOW_CIRCLE_PLAYER, 0xB4, 100),
|
||||||
|
GEO_OPEN_NODE(),
|
||||||
|
GEO_ZBUFFER(1),
|
||||||
|
GEO_OPEN_NODE(),
|
||||||
|
GEO_SCALE(0x00, 16384),
|
||||||
|
GEO_OPEN_NODE(),
|
||||||
|
GEO_ASM(0, geo_mirror_mario_backface_culling),
|
||||||
|
GEO_ASM(0, geo_mirror_mario_set_alpha),
|
||||||
|
GEO_BRANCH(1, mario_geo_load_body),
|
||||||
|
GEO_ASM(1, geo_mirror_mario_backface_culling),
|
||||||
|
GEO_CLOSE_NODE(),
|
||||||
|
GEO_CLOSE_NODE(),
|
||||||
|
GEO_CLOSE_NODE(),
|
||||||
|
GEO_END(),
|
||||||
|
};
|
||||||
|
|
||||||
|
void *mario_geo_ptr = (void*)mario_geo_libsm64;
|
||||||
|
"""
|
||||||
|
|
||||||
|
geo_inc_h = """
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern void *mario_geo_ptr;
|
||||||
|
"""
|
||||||
|
|
||||||
|
anim_data_h = """
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern void *mario_anims_ptr;
|
||||||
|
"""
|
||||||
|
|
||||||
|
anim_data_c_footer = """
|
||||||
|
void *mario_anims_ptr = &gMarioAnims;
|
||||||
|
"""
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.chdir(os.path.dirname(sys.argv[0]))
|
||||||
|
shutil.rmtree("src/mario", ignore_errors=True)
|
||||||
|
os.makedirs("src/mario", exist_ok=True)
|
||||||
|
|
||||||
|
geo_inc_c = ""
|
||||||
|
model_inc_c = ""
|
||||||
|
model_inc_h_lines = [
|
||||||
|
"#pragma once",
|
||||||
|
'#include "../include/types.h"',
|
||||||
|
'#include "../include/PR/gbi.h"'
|
||||||
|
]
|
||||||
|
|
||||||
|
with open("sm64-port/actors/mario/geo.inc.c", "r") as file:
|
||||||
|
geo_inc_c = file.read()
|
||||||
|
|
||||||
|
with open("sm64-port/actors/mario/model.inc.c", "r") as file:
|
||||||
|
lines = file.read().splitlines()
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if line.startswith("const "):
|
||||||
|
model_inc_h_lines.append("extern " + line.replace(" = {", ";"))
|
||||||
|
|
||||||
|
lines = [ x.replace("#include", "//#include") for x in lines ]
|
||||||
|
lines.insert(0, "#include \"../model_hack.h\"")
|
||||||
|
model_inc_c = "\n".join(lines)
|
||||||
|
|
||||||
|
with open("src/mario/geo.inc.c", "w") as file:
|
||||||
|
file.write(geo_inc_c_header + geo_inc_c + geo_inc_c_footer)
|
||||||
|
|
||||||
|
with open("src/mario/model.inc.c", "w") as file:
|
||||||
|
file.write(model_inc_c)
|
||||||
|
|
||||||
|
with open("src/mario/model.inc.h", "w") as file:
|
||||||
|
file.write("\n".join(model_inc_h_lines))
|
||||||
|
|
||||||
|
with open("src/mario/geo.inc.h", "w") as file:
|
||||||
|
file.write(geo_inc_h)
|
||||||
|
|
||||||
|
os.chdir("sm64-port")
|
||||||
|
mario_anims_pipe = subprocess.run(["tools/mario_anims_converter.py", "-l"], stdout=subprocess.PIPE)
|
||||||
|
mario_anims_string = mario_anims_pipe.stdout.decode('utf-8')
|
||||||
|
os.chdir("..")
|
||||||
|
|
||||||
|
with open("src/mario/anim_data.c", "w") as file:
|
||||||
|
file.write(mario_anims_string.replace('#include "types.h"', '#include "../include/types.h"\n#include "anim_data.h"') + anim_data_c_footer)
|
||||||
|
|
||||||
|
with open("src/mario/anim_data.h", "w") as file:
|
||||||
|
file.write(anim_data_h)
|
||||||
|
|
||||||
|
main()
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#include "behavior_actions.h"
|
||||||
|
#include "rendering_graph_node.h"
|
||||||
|
#include "../shim.h"
|
||||||
|
|
||||||
|
// not sure what this is doing here. not in a behavior file.
|
||||||
|
Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx) {
|
||||||
|
Mat4 sp20;
|
||||||
|
struct Object *sp1C;
|
||||||
|
|
||||||
|
if (run == TRUE) {
|
||||||
|
sp1C = (struct Object *) gCurGraphNodeObject;
|
||||||
|
if (sp1C == gMarioObject && sp1C->prevObj != NULL) {
|
||||||
|
create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr);
|
||||||
|
obj_update_pos_from_parent_transformation(sp20, sp1C->prevObj);
|
||||||
|
obj_set_gfx_pos_from_pos(sp1C->prevObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../include/types.h"
|
||||||
|
#include "../mario/model.inc.h"
|
||||||
|
|
||||||
|
extern Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx);
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "../model/model.inc.h"
|
#include "../mario/model.inc.h"
|
||||||
|
|
||||||
|
|
||||||
// PATCH
|
// PATCH
|
||||||
|
|||||||
+3
-3
@@ -16,9 +16,9 @@
|
|||||||
#include "engine/surface_collision.h"
|
#include "engine/surface_collision.h"
|
||||||
#include "engine/graph_node.h"
|
#include "engine/graph_node.h"
|
||||||
#include "engine/geo_layout.h"
|
#include "engine/geo_layout.h"
|
||||||
#include "assets/mario_anim_data.h"
|
|
||||||
#include "game/rendering_graph_node.h"
|
#include "game/rendering_graph_node.h"
|
||||||
#include "model/geo.inc.h"
|
#include "mario/anim_data.h"
|
||||||
|
#include "mario/geo.inc.h"
|
||||||
#include "gfx_adapter.h"
|
#include "gfx_adapter.h"
|
||||||
|
|
||||||
static struct AllocOnlyPool *s_mario_geo_pool;
|
static struct AllocOnlyPool *s_mario_geo_pool;
|
||||||
@@ -86,7 +86,7 @@ void sm64_global_init( SM64DebugPrintFunctionPtr debugPrintFunction )
|
|||||||
s_mario_geo_pool = alloc_only_pool_init();
|
s_mario_geo_pool = alloc_only_pool_init();
|
||||||
s_mario_graph_node = process_geo_layout( s_mario_geo_pool, mario_geo_ptr );
|
s_mario_graph_node = process_geo_layout( s_mario_geo_pool, mario_geo_ptr );
|
||||||
|
|
||||||
D_80339D10.animDmaTable = (void*)(&gMarioAnims);
|
D_80339D10.animDmaTable = mario_anims_ptr;
|
||||||
D_80339D10.currentAnimAddr = NULL;
|
D_80339D10.currentAnimAddr = NULL;
|
||||||
D_80339D10.targetAnim = malloc( 0x4000 );
|
D_80339D10.targetAnim = malloc( 0x4000 );
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,115 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "include/types.h"
|
||||||
|
#include "gfx_adapter_commands.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Vertex (set up for use with colors)
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
#ifndef GBI_FLOATS
|
||||||
|
short ob[3]; /* x, y, z */
|
||||||
|
#else
|
||||||
|
float ob[3]; /* x, y, z */
|
||||||
|
#endif
|
||||||
|
unsigned short flag;
|
||||||
|
short tc[2]; /* texture coord */
|
||||||
|
unsigned char cn[4]; /* color & alpha */
|
||||||
|
} Vtx_t;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Vertex (set up for use with normals)
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
#ifndef GBI_FLOATS
|
||||||
|
short ob[3]; /* x, y, z */
|
||||||
|
#else
|
||||||
|
float ob[3]; /* x, y, z */
|
||||||
|
#endif
|
||||||
|
unsigned short flag;
|
||||||
|
short tc[2]; /* texture coord */
|
||||||
|
signed char n[3]; /* normal */
|
||||||
|
unsigned char a; /* alpha */
|
||||||
|
} Vtx_tn;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
Vtx_t v; /* Use this one for colors */
|
||||||
|
Vtx_tn n; /* Use this one for normals */
|
||||||
|
long long int force_structure_alignment;
|
||||||
|
} Vtx;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned char col[3]; /* diffuse light value (rgba) */
|
||||||
|
char pad1;
|
||||||
|
unsigned char colc[3]; /* copy of diffuse light value (rgba) */
|
||||||
|
char pad2;
|
||||||
|
signed char dir[3]; /* direction of light (normalized) */
|
||||||
|
char pad3;
|
||||||
|
} Light_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned char col[3]; /* ambient light value (rgba) */
|
||||||
|
char pad1;
|
||||||
|
unsigned char colc[3]; /* copy of ambient light value (rgba) */
|
||||||
|
char pad2;
|
||||||
|
} Ambient_t;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
Light_t l;
|
||||||
|
long long int force_structure_alignment[2];
|
||||||
|
} Light;
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
Ambient_t l;
|
||||||
|
long long int force_structure_alignment[1];
|
||||||
|
} Ambient;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Ambient a;
|
||||||
|
Light l[1];
|
||||||
|
} Lights1;
|
||||||
|
|
||||||
|
//static const Lights1 mario_blue_lights_group = gdSPDefLights1( 0x00, 0x00, 0x7f, 0x00, 0x00, 0xff, 0x28, 0x28, 0x28);
|
||||||
|
#define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) {{{ {ar,ag,ab},0,{ar,ag,ab},0}}, {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} }
|
||||||
|
|
||||||
|
#define gsSPVertex(v, n, v0) \
|
||||||
|
GFXCMD_VertexData, \
|
||||||
|
(int64_t)v, n, v0
|
||||||
|
|
||||||
|
#define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \
|
||||||
|
GFXCMD_Triangle, \
|
||||||
|
v00, v01, v02, flag0, \
|
||||||
|
GFXCMD_Triangle, \
|
||||||
|
v10, v11, v12, flag1
|
||||||
|
|
||||||
|
#define gsSP1Triangle(v00, v01, v02, flag0) \
|
||||||
|
GFXCMD_Triangle, \
|
||||||
|
v00, v01, v02, flag0
|
||||||
|
|
||||||
|
#define gsSPEndDisplayList() \
|
||||||
|
GFXCMD_EndDisplayList
|
||||||
|
|
||||||
|
#define gsSPDisplayList(dl) \
|
||||||
|
GFXCMD_SubDisplayList, \
|
||||||
|
(int64_t)dl
|
||||||
|
|
||||||
|
#define gsSPLight(l, n) \
|
||||||
|
GFXCMD_Light, \
|
||||||
|
(int64_t)l, n
|
||||||
|
|
||||||
|
#define gsDPPipeSync() (GFXCMD_None)
|
||||||
|
#define gsDPSetCombineMode(a, b) (GFXCMD_None)
|
||||||
|
#define gsSPSetGeometryMode(word) (GFXCMD_None)
|
||||||
|
#define gsDPLoadTextureBlock(timg, fmt, siz, width, height, pal, cms, cmt, masks, maskt, shifts, shiftt) (GFXCMD_None)
|
||||||
|
#define gsSPTexture(s, t, level, tile, on) (GFXCMD_None)
|
||||||
|
#define gsSPClearGeometryMode(word) (GFXCMD_None)
|
||||||
|
#define gsDPSetEnvColor(r, g, b, a) (GFXCMD_None)
|
||||||
|
#define gsDPSetAlphaCompare(type) (GFXCMD_None)
|
||||||
|
#define gsDPTileSync() (GFXCMD_None)
|
||||||
|
#define gsDPSetTile(fmt, siz, line, tmem, tile, palette, cmt, maskt, shiftt, cms, masks, shifts) (GFXCMD_None)
|
||||||
|
#define gsDPSetTileSize(t, uls, ult, lrs, lrt) (GFXCMD_None)
|
||||||
|
#define gsDPSetTextureImage(f, s, w, i) (GFXCMD_None)
|
||||||
|
#define gsDPLoadBlock(tile, uls, ult, lrs, dxt) (GFXCMD_None)
|
||||||
|
#define gsDPLoadSync() (GFXCMD_None)
|
||||||
|
|
||||||
|
typedef int64_t Gfx;
|
||||||
Reference in New Issue
Block a user