You've already forked ultrasm64-2
mirror of
https://github.com/HackerN64/ultrasm64-2.git
synced 2026-01-21 10:38:08 -08:00
Add libpl2 support
This commit is contained in:
30
Makefile
30
Makefile
@@ -187,7 +187,7 @@ ifeq ($(filter clean distclean print-%,$(MAKECMDGOALS)),)
|
||||
endif
|
||||
|
||||
$(info Building hackerlibultra...)
|
||||
DUMMY != $(MAKE) -s -C $(LIBULTRA_DIR) >&2 || echo FAIL
|
||||
DUMMY != $(MAKE) -s -C $(LIBULTRA_DIR) VERSION=L >&2 || echo FAIL # We must specify version, or else hackerlibultra will make a build folder for SM64 game version (i.e. build/US/libgultra_rom.a)
|
||||
ifeq ($(DUMMY),FAIL)
|
||||
$(error Failed to build hackerlibultra)
|
||||
endif
|
||||
@@ -220,6 +220,7 @@ BIN_DIRS := bin bin/$(VERSION)
|
||||
|
||||
GODDARD_SRC_DIRS := src/goddard src/goddard/dynlists
|
||||
N64LIBC_SRC_DIRS := lib/n64-libc
|
||||
LIBPL2_SRC_DIRS := lib/libpl2
|
||||
|
||||
# File dependencies and variables for specific files
|
||||
include Makefile.split
|
||||
@@ -230,6 +231,7 @@ C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(LEVEL_C
|
||||
S_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.s))
|
||||
GODDARD_C_FILES := $(foreach dir,$(GODDARD_SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
N64LIBC_C_FILES := $(foreach dir,$(N64LIBC_SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
LIBPL2_C_FILES := $(foreach dir,$(LIBPL2_SRC_DIRS),$(wildcard $(dir)/*.c))
|
||||
GENERATED_C_FILES := $(BUILD_DIR)/assets/mario_anim_data.c $(BUILD_DIR)/assets/demo_data.c
|
||||
|
||||
# Sound files
|
||||
@@ -257,9 +259,10 @@ O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
|
||||
|
||||
GODDARD_O_FILES := $(foreach file,$(GODDARD_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
||||
N64LIBC_O_FILES := $(foreach file,$(N64LIBC_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
||||
LIBPL2_O_FILES := $(foreach file,$(LIBPL2_C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
||||
|
||||
# Automatic dependency files
|
||||
DEP_FILES := $(O_FILES:.o=.d) $(GODDARD_O_FILES:.o=.d) $(N64LIBC_O_FILES:.o=.d) $(BUILD_DIR)/$(LD_SCRIPT).d
|
||||
DEP_FILES := $(O_FILES:.o=.d) $(GODDARD_O_FILES:.o=.d) $(N64LIBC_O_FILES:.o=.d) $(LIBPL2_O_FILES:.o=.d) $(BUILD_DIR)/$(LD_SCRIPT).d
|
||||
|
||||
#==============================================================================#
|
||||
# Compiler Options #
|
||||
@@ -284,7 +287,7 @@ ifeq ($(TARGET_N64),1)
|
||||
CC_CFLAGS := -fno-builtin
|
||||
endif
|
||||
|
||||
INCLUDE_DIRS := include $(BUILD_DIR) $(BUILD_DIR)/include src lib/n64-libc .
|
||||
INCLUDE_DIRS := include $(BUILD_DIR) $(BUILD_DIR)/include src lib/n64-libc lib/libpl2 .
|
||||
ifeq ($(TARGET_N64),1)
|
||||
INCLUDE_DIRS += include/gcc
|
||||
endif
|
||||
@@ -303,11 +306,11 @@ endif
|
||||
|
||||
# C compiler options
|
||||
CFLAGS = -G 0 $(TARGET_CFLAGS) $(DEF_INC_CFLAGS) $(foreach i,$(INCLUDE_DIRS),--embed-dir=$(i))
|
||||
CFLAGS += -std=gnu23 -Wno-unused-variable -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra
|
||||
CFLAGS += -std=gnu23 -fkeep-inline-functions -Wno-unused-variable -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -ffreestanding -fwrapv -Wall -Wextra
|
||||
CFLAGS += -Wno-missing-braces -Wno-maybe-uninitialized
|
||||
|
||||
ASFLAGS := -march=vr4300 -mabi=32 $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(foreach d,$(DEFINES),--defsym $(d))
|
||||
ASMFLAGS := -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) -mips3 $(DEF_INC_CFLAGS) -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -fno-inline-functions -ffreestanding -fwrapv -Wall -Wextra
|
||||
ASMFLAGS := -G 0 $(OPT_FLAGS) $(TARGET_CFLAGS) -mips3 $(DEF_INC_CFLAGS) -mno-shared -march=vr4300 -mfix4300 -mabi=32 -mhard-float -mdivide-breaks -fno-stack-protector -fno-common -fno-zero-initialized-in-bss -fno-PIC -mno-abicalls -fno-strict-aliasing -ffreestanding -fwrapv -Wall -Wextra
|
||||
RSPASMFLAGS := $(foreach d,$(DEFINES),-definelabel $(subst =, ,$(d)))
|
||||
|
||||
# Prevent a crash with -sopt
|
||||
@@ -375,7 +378,7 @@ distclean: clean
|
||||
$(PYTHON) extract_assets.py --clean
|
||||
$(MAKE) -C $(TOOLS_DIR) clean
|
||||
$(MAKE) -C $(TOOLS_DIR)/sm64tools clean
|
||||
$(MAKE) -C $(LIBULTRA_DIR) clean
|
||||
$(MAKE) -C $(LIBULTRA_DIR) distclean
|
||||
|
||||
test: $(ROM)
|
||||
$(EMULATOR) $(EMU_FLAGS) $<
|
||||
@@ -418,7 +421,7 @@ else
|
||||
endif
|
||||
$(BUILD_DIR)/bin/segment2.o: $(BUILD_DIR)/text/debug_text.raw.inc.c
|
||||
|
||||
ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(GODDARD_SRC_DIRS) $(N64LIBC_SRC_DIRS) $(ULTRA_SRC_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) rsp include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION)
|
||||
ALL_DIRS := $(BUILD_DIR) $(addprefix $(BUILD_DIR)/,$(SRC_DIRS) $(GODDARD_SRC_DIRS) $(N64LIBC_SRC_DIRS) $(LIBPL2_SRC_DIRS) $(ULTRA_SRC_DIRS) $(BIN_DIRS) $(TEXTURE_DIRS) $(TEXT_DIRS) $(SOUND_SAMPLE_DIRS) $(addprefix levels/,$(LEVEL_DIRS)) rsp include) $(MIO0_DIR) $(addprefix $(MIO0_DIR)/,$(VERSION)) $(SOUND_BIN_DIR) $(SOUND_BIN_DIR)/sequences/$(VERSION)
|
||||
|
||||
# Make sure build directory exists before compiling anything
|
||||
DUMMY != mkdir -p $(ALL_DIRS)
|
||||
@@ -618,15 +621,20 @@ $(BUILD_DIR)/libgoddard.a: $(GODDARD_O_FILES)
|
||||
@$(PRINT) "$(GREEN)Archiving libgoddard: $(BLUE)$@ $(NO_COL)\n"
|
||||
$(V)$(AR) rcs -o $@ $(GODDARD_O_FILES)
|
||||
|
||||
# Link n64-libc
|
||||
# Bundle n64-libc
|
||||
$(BUILD_DIR)/n64-libc.a: $(N64LIBC_O_FILES)
|
||||
@$(PRINT) "$(GREEN)Archiving n64-libc: $(BLUE)$@ $(NO_COL)\n"
|
||||
@$(PRINT) "$(GREEN)Bundling n64-libc: $(BLUE)$@ $(NO_COL)\n"
|
||||
$(V)$(AR) rcs -o $@ $(N64LIBC_O_FILES)
|
||||
|
||||
# Bundle libpl2
|
||||
$(BUILD_DIR)/libpl2.a: $(LIBPL2_O_FILES)
|
||||
@$(PRINT) "$(GREEN)Bundling libpl2: $(BLUE)$@ $(NO_COL)\n"
|
||||
$(V)$(AR) rcs -o $@ $(LIBPL2_O_FILES)
|
||||
|
||||
# Link SM64 ELF file
|
||||
$(ELF): $(LIBULTRA_BUILD_DIR)/libgultra_rom.a $(O_FILES) $(MIO0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) $(BUILD_DIR)/libgoddard.a $(BUILD_DIR)/n64-libc.a
|
||||
$(ELF): $(LIBULTRA_BUILD_DIR)/libgultra_rom.a $(O_FILES) $(MIO0_OBJ_FILES) $(SEG_FILES) $(BUILD_DIR)/$(LD_SCRIPT) $(BUILD_DIR)/libgoddard.a $(BUILD_DIR)/n64-libc.a $(BUILD_DIR)/libpl2.a
|
||||
@$(PRINT) "$(GREEN)Linking ELF file: $(BLUE)$@ $(NO_COL)\n"
|
||||
$(V)$(LD) -L $(BUILD_DIR) -L $(LIBULTRA_BUILD_DIR) -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -lgultra_rom -lgoddard -l:n64-libc.a
|
||||
$(V)$(LD) -L $(BUILD_DIR) -L $(LIBULTRA_BUILD_DIR) -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -lpl2 -l:n64-libc.a -lgoddard -lgultra_rom
|
||||
|
||||
# Build ROM
|
||||
PAD_TO_GAP_FILL := --pad-to=0x800000 --gap-fill=0xFF
|
||||
|
||||
@@ -41,7 +41,7 @@ CC := $(CROSS)gcc
|
||||
|
||||
WARNINGS := -Wall -Wextra -Wno-format-security -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-builtin-declaration-mismatch
|
||||
WARNINGS += -Wno-int-conversion -Wno-incompatible-pointer-types -Wno-implicit-function-declaration # TODO: Try adjusting code to remove these
|
||||
CFLAGS := -G 0 -c -nostdinc -march=vr4300 -mfix4300 -mabi=32 -mno-abicalls -mdivide-breaks -fno-PIC -fno-common -ffreestanding -fbuiltin -fno-builtin-sinf -fno-builtin-cosf -funsigned-char $(WARNINGS)
|
||||
CFLAGS := -std=gnu23 -G 0 -c -nostdinc -march=vr4300 -mfix4300 -mabi=32 -mno-abicalls -mdivide-breaks -fno-PIC -fno-common -ffreestanding -fbuiltin -fno-builtin-sinf -fno-builtin-cosf -funsigned-char $(WARNINGS)
|
||||
CFLAGS += -fno-strict-aliasing # TODO: Try adjusting code to remove this
|
||||
ASFLAGS := -w -nostdinc -c -G 0 -march=vr4300 -mabi=32 -mgp32 -mfp32 -DMIPSEB -D_LANGUAGE_ASSEMBLY -D_MIPS_SIM=1 -D_ULTRA64
|
||||
CPPFLAGS = -DMODERN_CC -D_MIPS_SZLONG=32 -D__USE_ISOC99 $(GBIDEFINE) $(VERSION_DEFINE) $(DEBUGFLAG)
|
||||
|
||||
@@ -56,7 +56,7 @@ volatile const __lpl2_response *__lpl2_query_string( unsigned short commandId, c
|
||||
volatile const __lpl2_response *__lpl2_query_byte( unsigned short commandId, unsigned char arg ) __attribute__((returns_nonnull));
|
||||
volatile const __lpl2_response *__lpl2_query_uint( unsigned short commandId, unsigned int arg ) __attribute__((returns_nonnull));
|
||||
|
||||
inline __attribute__((always_inline, assume_aligned(4), const)) volatile char *__lpl2_payload_start() { return (volatile char*)0xbffb0004u; }
|
||||
static inline __attribute__((always_inline, assume_aligned(4), const)) volatile char *__lpl2_payload_start() { return (volatile char*)0xbffb0004u; }
|
||||
volatile const __lpl2_response *__lpl2_payload_send( unsigned short commandId, unsigned short payloadSize ) __attribute__((returns_nonnull));
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -163,7 +163,7 @@ lpl2_bool lpl2_get_rhdc_avatar_async( const char *username, lpl2_avatar_options
|
||||
*
|
||||
* @since LPL_ABI_VERSION_7
|
||||
*/
|
||||
inline lpl2_bool __attribute__((warning("Use of blocking libpl call will likely cause the emulator to stutter. Use the async version of the libpl call for a better user experience."), access(write_only, 3), access(write_only, 4))) lpl2_get_rhdc_avatar_blocking( const char *username, lpl2_avatar_options options, void *avatar, lpl2_err *err ) {
|
||||
static inline lpl2_bool __attribute__((warning("Use of blocking libpl call will likely cause the emulator to stutter. Use the async version of the libpl call for a better user experience."), access(write_only, 3), access(write_only, 4))) lpl2_get_rhdc_avatar_blocking( const char *username, lpl2_avatar_options options, void *avatar, lpl2_err *err ) {
|
||||
lpl2_err e = LPL2_ERR_WAIT;
|
||||
while( e == LPL2_ERR_WAIT ) lpl2_get_rhdc_avatar_async( username, options, avatar, &e );
|
||||
if( err ) *err = e;
|
||||
|
||||
@@ -24,7 +24,7 @@ typedef struct {
|
||||
* Returns zero if both versions are the same. \n
|
||||
* Returns a positive number if the first version is later than the second version.
|
||||
*/
|
||||
inline int __attribute__((pure, warn_unused_result)) lpl2_compare_versions( const lpl2_version *first, const lpl2_version *second ) {
|
||||
static inline int __attribute__((pure, warn_unused_result)) lpl2_compare_versions( const lpl2_version *first, const lpl2_version *second ) {
|
||||
int cmp = (int)first->major - (int)second->major;
|
||||
if( cmp != 0 ) return cmp;
|
||||
cmp = (int)first->minor - (int)second->minor;
|
||||
|
||||
0
lib/n64-libc/n64-alloca.c
Normal file
0
lib/n64-libc/n64-alloca.c
Normal file
4
sm64.ld
4
sm64.ld
@@ -53,6 +53,7 @@ SECTIONS
|
||||
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.text);
|
||||
BUILD_DIR/src/audio/external.o(.text);
|
||||
BUILD_DIR/n64-libc.a:*.o(.text);
|
||||
BUILD_DIR/libpl2.a:*.o(.text);
|
||||
BUILD_DIR/lib/rsp.o(.text);
|
||||
|
||||
BUILD_DIR/asm/entry.o(.data*);
|
||||
@@ -63,6 +64,7 @@ SECTIONS
|
||||
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.data*);
|
||||
BUILD_DIR/src/audio/external.o(.data*);
|
||||
BUILD_DIR/n64-libc.a:*.o(.data*);
|
||||
BUILD_DIR/libpl2.a:*.o(.data*);
|
||||
BUILD_DIR/lib/rsp.o(.data*);
|
||||
|
||||
BUILD_DIR/asm/entry.o(.rodata*);
|
||||
@@ -73,6 +75,7 @@ SECTIONS
|
||||
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.rodata*);
|
||||
BUILD_DIR/src/audio/external.o(.rodata*);
|
||||
BUILD_DIR/n64-libc.a:*.o(.rodata*);
|
||||
BUILD_DIR/libpl2.a:*.o(.rodata*);
|
||||
BUILD_DIR/lib/rsp.o(.rodata*);
|
||||
#ifdef LIBDRAGON_IPL3
|
||||
BUILD_DIR/src/game*.o(.text);
|
||||
@@ -97,6 +100,7 @@ SECTIONS
|
||||
AUDIO_DIR*.o(.bss*);
|
||||
BUILD_DIR/src/audio/external.o(.bss*);
|
||||
BUILD_DIR/n64-libc.a:*.o(.bss*);
|
||||
BUILD_DIR/libpl2.a:*.o(.bss*);
|
||||
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.bss*);
|
||||
BUILD_DIR/src/game*.o(.bss*);
|
||||
. = ALIGN(0x10);
|
||||
|
||||
Reference in New Issue
Block a user