Added support for building on Windows
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
default: test
|
||||
default: lib
|
||||
|
||||
CC := cc
|
||||
CFLAGS := -g -Wall -fPIC
|
||||
@@ -24,6 +24,10 @@ DEP_FILES := $(O_FILES:.o=.d)
|
||||
TEST_SRCS := test/main.c test/context.c test/level.c
|
||||
TEST_OBJS := $(foreach file,$(TEST_SRCS),$(BUILD_DIR)/$(file:.c=.o))
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
LIB_FILE := $(DIST_DIR)/sm64.dll
|
||||
CFLAGS := $(CFLAGS) -DBUILDING_SM64_DLL
|
||||
endif
|
||||
|
||||
DUMMY != mkdir -p $(ALL_DIRS) build/test src/mario $(DIST_DIR)/include
|
||||
|
||||
|
||||
@@ -7,13 +7,19 @@ This project produces a shared library file containing mostly code from the deco
|
||||
and loads an official SM64 ROM at runtime to get Mario's texture and animation data, so any project
|
||||
which makes use of this library must ask the user to provide a ROM for asset extraction.
|
||||
|
||||
## Building
|
||||
## Building on Linux
|
||||
|
||||
Currently only linux is supported. Windows support coming soon. Requires python3 to build the library,
|
||||
and SDL2 + GLEW for the test program.
|
||||
- Ensure python3 is installed.
|
||||
- Ensure the SDL2 and GLEW libraries are installed if you're building the test program (on Ubuntu: libsdl2-dev, libglew-dev)
|
||||
- Run `make` to build
|
||||
- To run the test program you'll need a SM64 US ROM in the root of the repository with the name `baserom.us.z64`.
|
||||
|
||||
- `make lib`: Build the `dist` directory, containing the shared object and public-facing header.
|
||||
- `make test`: (Default) Builds the library `dist` directory as well as the test program.
|
||||
## Building on Windows (test program not supported)
|
||||
- [Follow steps 1-4 for setting up MSYS2 MinGW 64 here](https://github.com/sm64-port/sm64-port#windows), but replace the repository URL with `https://github.com/libsm64/libsm64.git`
|
||||
- Run `make` to build
|
||||
|
||||
## Make targets (all platforms)
|
||||
|
||||
- `make lib`: (Default) Build the `dist` directory, containing the shared object or DLL and public-facing header.
|
||||
- `make test`: Builds the library `dist` directory as well as the test program.
|
||||
- `make run`: Build and run the SDL+OpenGL test program.
|
||||
|
||||
To run the test program you'll need a SM64 US ROM in the root of the repository with the name `baserom.us.z64`.
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import shutil
|
||||
import requests
|
||||
import urllib.request
|
||||
|
||||
GEO_URL = "https://raw.githubusercontent.com/n64decomp/sm64/06ec56df7f951f88da05f468cdcacecba496145a/actors/mario/geo.inc.c"
|
||||
MODEL_URL = "https://raw.githubusercontent.com/n64decomp/sm64/06ec56df7f951f88da05f468cdcacecba496145a/actors/mario/model.inc.c"
|
||||
@@ -61,9 +61,9 @@ def main():
|
||||
os.makedirs("src/mario", exist_ok=True)
|
||||
|
||||
print("Downloading " + GEO_URL)
|
||||
geo_inc_c = requests.get(GEO_URL).text
|
||||
geo_inc_c = urllib.request.urlopen(GEO_URL).read().decode('utf8')
|
||||
print("Downloading " + MODEL_URL)
|
||||
model_inc_c = requests.get(MODEL_URL).text
|
||||
model_inc_c = urllib.request.urlopen(MODEL_URL).read().decode('utf8')
|
||||
|
||||
lines = model_inc_c.splitlines()
|
||||
|
||||
@@ -96,4 +96,4 @@ def main():
|
||||
file.write(geo_inc_h)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import shutil
|
||||
import requests
|
||||
import urllib.request
|
||||
|
||||
BOB_COLLISION_URL = "https://raw.githubusercontent.com/n64decomp/sm64/06ec56df7f951f88da05f468cdcacecba496145a/levels/bob/areas/1/collision.inc.c"
|
||||
|
||||
@@ -15,7 +15,7 @@ extern const size_t surfaces_count;
|
||||
|
||||
def main():
|
||||
print("Downloading " + BOB_COLLISION_URL)
|
||||
in_lines = requests.get(BOB_COLLISION_URL).text.splitlines()
|
||||
in_lines = urllib.request.urlopen(BOB_COLLISION_URL).read().decode('utf8').splitlines()
|
||||
|
||||
verts = []
|
||||
tris = []
|
||||
@@ -29,9 +29,9 @@ def main():
|
||||
|
||||
if tokens[0] == "COL_VERTEX":
|
||||
verts.append([ int(tokens[1]), int(tokens[2]), int(tokens[3]) ])
|
||||
elif tokens[0] == "COL_TRI_INIT":
|
||||
elif tokens[0] == "COL_TRI_INIT":
|
||||
mode = tokens[1]
|
||||
elif tokens[0] == "COL_TRI":
|
||||
elif tokens[0] == "COL_TRI":
|
||||
tris.append([ int(tokens[1]), int(tokens[2]), int(tokens[3]), mode ])
|
||||
|
||||
out_lines = []
|
||||
@@ -55,4 +55,4 @@ def main():
|
||||
file.write(LEVEL_H)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
+9
-9
@@ -78,7 +78,7 @@ static struct Area *hack_build_area( void )
|
||||
return result;
|
||||
}
|
||||
|
||||
void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction )
|
||||
SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction )
|
||||
{
|
||||
s_last_colors_hash = 0;
|
||||
gDebugPrint = debugPrintFunction;
|
||||
@@ -98,13 +98,13 @@ void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunction
|
||||
D_80339D10.targetAnim = NULL;
|
||||
}
|
||||
|
||||
void sm64_load_surfaces( uint16_t terrainType, const struct SM64Surface *surfaceArray, uint32_t numSurfaces )
|
||||
SM64_LIB_FN void sm64_load_surfaces( uint16_t terrainType, const struct SM64Surface *surfaceArray, uint32_t numSurfaces )
|
||||
{
|
||||
surfaces_load_static_libsm64( surfaceArray, numSurfaces );
|
||||
gCurrentArea->terrainType = terrainType;
|
||||
}
|
||||
|
||||
void sm64_mario_reset( int16_t marioX, int16_t marioY, int16_t marioZ )
|
||||
SM64_LIB_FN void sm64_mario_reset( int16_t marioX, int16_t marioY, int16_t marioZ )
|
||||
{
|
||||
gMarioSpawnInfoVal.startPos[0] = marioX;
|
||||
gMarioSpawnInfoVal.startPos[1] = marioY;
|
||||
@@ -147,7 +147,7 @@ static void update_objects( void )
|
||||
update_mario_platform();
|
||||
}
|
||||
|
||||
void sm64_mario_tick( const struct SM64MarioInputs *inputs, struct SM64MarioState *outState, struct SM64MarioGeometryBuffers *outBuffers )
|
||||
SM64_LIB_FN void sm64_mario_tick( const struct SM64MarioInputs *inputs, struct SM64MarioState *outState, struct SM64MarioGeometryBuffers *outBuffers )
|
||||
{
|
||||
update_button( inputs->buttonA, A_BUTTON );
|
||||
update_button( inputs->buttonB, B_BUTTON );
|
||||
@@ -173,23 +173,23 @@ void sm64_mario_tick( const struct SM64MarioInputs *inputs, struct SM64MarioStat
|
||||
outState->faceAngle = (float)gMarioState->faceAngle[1] / 32768.0f * 3.14159f;
|
||||
}
|
||||
|
||||
void sm64_global_terminate( void )
|
||||
SM64_LIB_FN void sm64_global_terminate( void )
|
||||
{
|
||||
// TODO free other things
|
||||
|
||||
surfaces_unload_all();
|
||||
}
|
||||
|
||||
uint32_t sm64_load_surface_object( const struct SM64SurfaceObject *surfaceObject )
|
||||
SM64_LIB_FN uint32_t sm64_load_surface_object( const struct SM64SurfaceObject *surfaceObject )
|
||||
{
|
||||
return surfaces_load_object( surfaceObject );
|
||||
}
|
||||
|
||||
void sm64_move_object( uint32_t id, const struct SM64ObjectTransform *transform )
|
||||
SM64_LIB_FN void sm64_move_object( uint32_t id, const struct SM64ObjectTransform *transform )
|
||||
{
|
||||
surface_object_update_transform( id, transform );
|
||||
}
|
||||
|
||||
void sm64_unload_object( uint32_t id )
|
||||
SM64_LIB_FN void sm64_unload_object( uint32_t id )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
+19
-9
@@ -5,6 +5,16 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef BUILDING_SM64_DLL
|
||||
#define SM64_LIB_FN __declspec(dllexport)
|
||||
#else
|
||||
#define SM64_LIB_FN __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define SM64_LIB_FN
|
||||
#endif
|
||||
|
||||
struct SM64Surface
|
||||
{
|
||||
int16_t type;
|
||||
@@ -58,16 +68,16 @@ enum
|
||||
SM64_GEO_MAX_TRIANGLES = 1024,
|
||||
};
|
||||
|
||||
extern void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction );
|
||||
extern void sm64_load_surfaces( uint16_t terrainType, const struct SM64Surface *surfaceArray, uint32_t numSurfaces );
|
||||
extern SM64_LIB_FN void sm64_global_init( uint8_t *rom, uint8_t *outTexture, SM64DebugPrintFunctionPtr debugPrintFunction );
|
||||
extern SM64_LIB_FN void sm64_load_surfaces( uint16_t terrainType, const struct SM64Surface *surfaceArray, uint32_t numSurfaces );
|
||||
|
||||
extern void sm64_mario_reset( int16_t marioX, int16_t marioY, int16_t marioZ );
|
||||
extern void sm64_mario_tick( const struct SM64MarioInputs *inputs, struct SM64MarioState *outState, struct SM64MarioGeometryBuffers *outBuffers );
|
||||
extern void sm64_global_terminate( void );
|
||||
extern SM64_LIB_FN void sm64_mario_reset( int16_t marioX, int16_t marioY, int16_t marioZ );
|
||||
extern SM64_LIB_FN void sm64_mario_tick( const struct SM64MarioInputs *inputs, struct SM64MarioState *outState, struct SM64MarioGeometryBuffers *outBuffers );
|
||||
extern SM64_LIB_FN void sm64_global_terminate( void );
|
||||
|
||||
extern uint32_t sm64_load_surface_object( const struct SM64SurfaceObject *surfaceObject );
|
||||
extern void sm64_move_object( uint32_t id, const struct SM64ObjectTransform *transform );
|
||||
extern void sm64_unload_object( uint32_t id );
|
||||
extern SM64_LIB_FN uint32_t sm64_load_surface_object( const struct SM64SurfaceObject *surfaceObject );
|
||||
extern SM64_LIB_FN void sm64_move_object( uint32_t id, const struct SM64ObjectTransform *transform );
|
||||
extern SM64_LIB_FN void sm64_unload_object( uint32_t id );
|
||||
|
||||
/*
|
||||
|
||||
@@ -88,4 +98,4 @@ extern void sm64_delete_mario( uint32_t marioId );
|
||||
|
||||
*/
|
||||
|
||||
#endif//__LIB_SM64_H
|
||||
#endif//__LIB_SM64_H
|
||||
|
||||
Reference in New Issue
Block a user