hook up C compiler, add slightly modified original assembler, match first C function!

This commit is contained in:
dark-samus 2020-05-11 23:00:21 -04:00
parent cef1b2bb99
commit 6ea42bc324
8 changed files with 108 additions and 98 deletions

View File

@ -28,18 +28,6 @@ O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o)) \
$(foreach file,$(MAP_FILES),$(BUILD_DIR)/$(file:.FS=.FS.o)) \
$(foreach file,$(BGM_FILES),$(BUILD_DIR)/$(file:.bgm=.bgm.o))
##################### Compiler Options #######################
CROSS = mips-linux-gnu-
AS = $(CROSS)as
CC = $(CROSS)gcc
LD = $(CROSS)ld
OBJDUMP = $(CROSS)objdump
OBJCOPY = $(CROSS)objcopy
ASFLAGS = -EB -march=vr4300 -mtune=vr4300
CFLAGS = -Wall -O2 -mtune=vr4300 -march=vr4300 -G 0 -c
LDFLAGS = -T undefined_syms.txt -T $(LD_SCRIPT) -Map $(BUILD_DIR)/papermario.map
####################### Other Tools #########################
# N64 tools
@ -54,6 +42,20 @@ LOADER_FLAGS = -vwf
FixPath = $(subst /,\,$1)
##################### Compiler Options #######################
CROSS = mips-linux-gnu-
CROSS_IRIX = mips-sgi-irix5-
AS = $(CROSS)as
OLD_AS = $(TOOLS_DIR)/mips-nintendo-nu64-as
CC = $(TOOLS_DIR)/cc1
LD = $(CROSS_IRIX)ld
OBJDUMP = $(CROSS)objdump
OBJCOPY = $(CROSS)objcopy
ASFLAGS = -EB -march=vr4300 -mtune=vr4300
CFLAGS = -O2 -quiet
LDFLAGS = -T undefined_syms.txt -T $(LD_SCRIPT) -Map $(BUILD_DIR)/papermario.map
######################## Targets #############################
$(foreach dir,$(SRC_DIRS) $(ASM_DIRS) $(DATA_DIRS) $(COMPRESSED_DIRS) $(MAP_DIRS) $(BGM_DIRS),$(shell mkdir -p build/$(dir)))
@ -64,7 +66,7 @@ default: all
MAKEFILE_SPLIT = Makefile.split
include $(MAKEFILE_SPLIT)
all: fix_asm $(TARGET).z64 verify
all: fix_asm $(BUILD_DIR) $(TARGET).z64 verify
clean:
rm -rf build
@ -74,26 +76,26 @@ print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
$(BUILD_DIR):
mkdir $(BUILD_DIR)
$(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(LD_SCRIPT) $(BUILD_DIR)
$(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(LD_SCRIPT)
@$(LD) $(LDFLAGS) -o $@ $(O_FILES)
$(BUILD_DIR)/%.o: %.s $(BUILD_DIR)
@$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.s
$(AS) $(ASFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c $(BUILD_DIR)
@$(CC) $(CFLAGS) -o $@ $<
$(BUILD_DIR)/%.o: %.c
$(CC) $(CFLAGS) -o - $< | $(OLD_AS) - -o $@
$(BUILD_DIR)/%.o: %.bin $(BUILD_DIR)
@$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/%.o: %.bin
$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/%.yay0.o: %.yay0 $(BUILD_DIR)
@$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/%.yay0.o: %.yay0
$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/%.FS.o: %.FS $(BUILD_DIR)
@$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/%.FS.o: %.FS
$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/%.bgm.o: %.bgm $(BUILD_DIR)
@$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/%.bgm.o: %.bgm
$(LD) -r -b binary -o $@ $<
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf
$(OBJCOPY) $< $@ -O binary

View File

@ -879,7 +879,7 @@ SECTIONS
/* 0x80147230 0DD930-0DDAF0 [1C0] */
.text80147230 0x80147230 : AT(0x0DD930) {
build/asm/code_dd930_len_1c0.o(.text80147230);
build/src/code_dd930_len_1c0.o(.text);
}
/* 0x801473F0 0DDAF0-0DE740 [C50] */

View File

@ -1,31 +1,8 @@
# %s disassembly and split file
# generated by n64split v%s - N64 ROM splitter
# assembler directives
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.set gp=64 # allow use of 64-bit general purpose registers
.include "globals.inc"
.section .text80147230, "ax"
func_80147230:
/* 0DD930 80147230 3C058015 */ lui $a1, 0x8015
/* 0DD934 80147234 24A5F140 */ addiu $a1, $a1, -0xec0
/* 0DD938 80147238 3C048016 */ lui $a0, 0x8016
/* 0DD93C 8014723C 2484C7C0 */ addiu $a0, $a0, -0x3840
/* 0DD940 80147240 8CA20000 */ lw $v0, ($a1)
/* 0DD944 80147244 8CA30004 */ lw $v1, 4($a1)
/* 0DD948 80147248 AC820000 */ sw $v0, ($a0)
/* 0DD94C 8014724C AC830004 */ sw $v1, 4($a0)
/* 0DD950 80147250 8CA20008 */ lw $v0, 8($a1)
/* 0DD954 80147254 8CA3000C */ lw $v1, 0xc($a1)
/* 0DD958 80147258 AC820008 */ sw $v0, 8($a0)
/* 0DD95C 8014725C 03E00008 */ jr $ra
/* 0DD960 80147260 AC83000C */ sw $v1, 0xc($a0)
UpdateMusicPlayers:
/* 0DD964 80147264 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0DD968 80147268 AFB00010 */ sw $s0, 0x10($sp)
@ -44,7 +21,7 @@ UpdateMusicPlayers:
/* 0DD99C 8014729C 00000000 */ nop
.L801472A0:
/* 0DD9A0 801472A0 96020000 */ lhu $v0, ($s0)
/* 0DD9A0 801472A0 96020000 */ lhu $v0, 0($s0)
/* 0DD9A4 801472A4 30420001 */ andi $v0, $v0, 1
/* 0DD9A8 801472A8 1040000D */ beqz $v0, .L801472E0
/* 0DD9AC 801472AC 24020002 */ addiu $v0, $zero, 2
@ -68,7 +45,7 @@ UpdateMusicPlayers:
/* 0DD9E4 801472E4 A6020002 */ sh $v0, 2($s0)
.L801472E8:
/* 0DD9E8 801472E8 96020000 */ lhu $v0, ($s0)
/* 0DD9E8 801472E8 96020000 */ lhu $v0, 0($s0)
/* 0DD9EC 801472EC 30420001 */ andi $v0, $v0, 1
/* 0DD9F0 801472F0 10400008 */ beqz $v0, .L80147314
/* 0DD9F4 801472F4 00000000 */ nop
@ -76,9 +53,9 @@ UpdateMusicPlayers:
/* 0DD9FC 801472FC 0000202D */ daddu $a0, $zero, $zero
/* 0DDA00 80147300 14400015 */ bnez $v0, .L80147358
/* 0DDA04 80147304 00000000 */ nop
/* 0DDA08 80147308 96020000 */ lhu $v0, ($s0)
/* 0DDA08 80147308 96020000 */ lhu $v0, 0($s0)
/* 0DDA0C 8014730C 3042FFFE */ andi $v0, $v0, 0xfffe
/* 0DDA10 80147310 A6020000 */ sh $v0, ($s0)
/* 0DDA10 80147310 A6020000 */ sh $v0, 0($s0)
.L80147314:
/* 0DDA14 80147314 8E040008 */ lw $a0, 8($s0)
/* 0DDA18 80147318 04810003 */ bgez $a0, .L80147328
@ -95,54 +72,12 @@ UpdateMusicPlayers:
/* 0DDA3C 8014733C 0080282D */ daddu $a1, $a0, $zero
/* 0DDA40 80147340 14400005 */ bnez $v0, .L80147358
/* 0DDA44 80147344 00000000 */ nop
/* 0DDA48 80147348 96020000 */ lhu $v0, ($s0)
/* 0DDA48 80147348 96020000 */ lhu $v0, 0($s0)
/* 0DDA4C 8014734C A6000002 */ sh $zero, 2($s0)
/* 0DDA50 80147350 34420001 */ ori $v0, $v0, 1
/* 0DDA54 80147354 A6020000 */ sh $v0, ($s0)
/* 0DDA54 80147354 A6020000 */ sh $v0, 0($s0)
.L80147358:
/* 0DDA58 80147358 8FBF0014 */ lw $ra, 0x14($sp)
/* 0DDA5C 8014735C 8FB00010 */ lw $s0, 0x10($sp)
/* 0DDA60 80147360 03E00008 */ jr $ra
/* 0DDA64 80147364 27BD0018 */ addiu $sp, $sp, 0x18
play_ambient_sounds:
/* 0DDA68 80147368 3C028007 */ lui $v0, 0x8007
/* 0DDA6C 8014736C 8C42419C */ lw $v0, 0x419c($v0)
/* 0DDA70 80147370 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0DDA74 80147374 AFB00010 */ sw $s0, 0x10($sp)
/* 0DDA78 80147378 3C108016 */ lui $s0, 0x8016
/* 0DDA7C 8014737C 2610C7C0 */ addiu $s0, $s0, -0x3840
/* 0DDA80 80147380 AFBF0014 */ sw $ra, 0x14($sp)
/* 0DDA84 80147384 8042007A */ lb $v0, 0x7a($v0)
/* 0DDA88 80147388 14400009 */ bnez $v0, .L801473B0
/* 0DDA8C 8014738C 0200302D */ daddu $a2, $s0, $zero
/* 0DDA90 80147390 8E040008 */ lw $a0, 8($s0)
/* 0DDA94 80147394 0C015529 */ jal func_800554A4
/* 0DDA98 80147398 00000000 */ nop
/* 0DDA9C 8014739C 96030000 */ lhu $v1, ($s0)
/* 0DDAA0 801473A0 24020001 */ addiu $v0, $zero, 1
/* 0DDAA4 801473A4 3063FFFE */ andi $v1, $v1, 0xfffe
/* 0DDAA8 801473A8 08051CF5 */ j .L801473D4
/* 0DDAAC 801473AC A6030000 */ sh $v1, ($s0)
.L801473B0:
/* 0DDAB0 801473B0 8CC20008 */ lw $v0, 8($a2)
/* 0DDAB4 801473B4 10440006 */ beq $v0, $a0, .L801473D0
/* 0DDAB8 801473B8 24020001 */ addiu $v0, $zero, 1
/* 0DDABC 801473BC 0040182D */ daddu $v1, $v0, $zero
/* 0DDAC0 801473C0 ACC40008 */ sw $a0, 8($a2)
/* 0DDAC4 801473C4 ACC50004 */ sw $a1, 4($a2)
/* 0DDAC8 801473C8 08051CF5 */ j .L801473D4
/* 0DDACC 801473CC A4C30002 */ sh $v1, 2($a2)
.L801473D0:
/* 0DDAD0 801473D0 24020002 */ addiu $v0, $zero, 2
.L801473D4:
/* 0DDAD4 801473D4 8FBF0014 */ lw $ra, 0x14($sp)
/* 0DDAD8 801473D8 8FB00010 */ lw $s0, 0x10($sp)
/* 0DDADC 801473DC 03E00008 */ jr $ra
/* 0DDAE0 801473E0 27BD0018 */ addiu $sp, $sp, 0x18
/* 0DDAE4 801473E4 00000000 */ nop
/* 0DDAE8 801473E8 00000000 */ nop
/* 0DDAEC 801473EC 00000000 */ nop

View File

@ -0,0 +1,42 @@
.set noat # allow manual use of $at
.set noreorder # don't insert nops after branches
.include "globals.inc"
play_ambient_sounds:
/* 0DDA68 80147368 3C028007 */ lui $v0, 0x8007
/* 0DDA6C 8014736C 8C42419C */ lw $v0, 0x419c($v0)
/* 0DDA70 80147370 27BDFFE8 */ addiu $sp, $sp, -0x18
/* 0DDA74 80147374 AFB00010 */ sw $s0, 0x10($sp)
/* 0DDA78 80147378 3C108016 */ lui $s0, 0x8016
/* 0DDA7C 8014737C 2610C7C0 */ addiu $s0, $s0, -0x3840
/* 0DDA80 80147380 AFBF0014 */ sw $ra, 0x14($sp)
/* 0DDA84 80147384 8042007A */ lb $v0, 0x7a($v0)
/* 0DDA88 80147388 14400009 */ bnez $v0, .L801473B0
/* 0DDA8C 8014738C 0200302D */ daddu $a2, $s0, $zero
/* 0DDA90 80147390 8E040008 */ lw $a0, 8($s0)
/* 0DDA94 80147394 0C015529 */ jal func_800554A4
/* 0DDA98 80147398 00000000 */ nop
/* 0DDA9C 8014739C 96030000 */ lhu $v1, ($s0)
/* 0DDAA0 801473A0 24020001 */ addiu $v0, $zero, 1
/* 0DDAA4 801473A4 3063FFFE */ andi $v1, $v1, 0xfffe
/* 0DDAA8 801473A8 08051CF5 */ j .L801473D4
/* 0DDAAC 801473AC A6030000 */ sh $v1, ($s0)
.L801473B0:
/* 0DDAB0 801473B0 8CC20008 */ lw $v0, 8($a2)
/* 0DDAB4 801473B4 10440006 */ beq $v0, $a0, .L801473D0
/* 0DDAB8 801473B8 24020001 */ addiu $v0, $zero, 1
/* 0DDABC 801473BC 0040182D */ daddu $v1, $v0, $zero
/* 0DDAC0 801473C0 ACC40008 */ sw $a0, 8($a2)
/* 0DDAC4 801473C4 ACC50004 */ sw $a1, 4($a2)
/* 0DDAC8 801473C8 08051CF5 */ j .L801473D4
/* 0DDACC 801473CC A4C30002 */ sh $v1, 2($a2)
.L801473D0:
/* 0DDAD0 801473D0 24020002 */ addiu $v0, $zero, 2
.L801473D4:
/* 0DDAD4 801473D4 8FBF0014 */ lw $ra, 0x14($sp)
/* 0DDAD8 801473D8 8FB00010 */ lw $s0, 0x10($sp)
/* 0DDADC 801473DC 03E00008 */ jr $ra
/* 0DDAE0 801473E0 27BD0018 */ addiu $sp, $sp, 0x18

View File

@ -0,0 +1,29 @@
typedef struct
{
int unk0;
int unk4;
int unk8;
int unkC;
} struct_80147230;
extern struct_80147230 unk1;
extern struct_80147230 unk2;
void func_80147230(void)
{
unk2 = unk1;
}
void __attribute__((naked)) UpdateMusicPlayers(void)
{
__asm__(
".include \"asm/code_dd930_len_1c0/UpdateMusicPlayers.s\"\n"
);
}
void __attribute__((naked)) play_ambient_sounds(void)
{
__asm__(
".include \"asm/code_dd930_len_1c0/play_ambient_sounds.s\"\n"
);
}

Binary file not shown.

Binary file not shown.

View File

@ -12,3 +12,5 @@ func_80240AA8 = 0x80240AA8;
func_80241190 = 0x80241190;
func_802BD7DC = 0x802BD7DC;
func_802BE070 = 0x802BE070;
unk1 = 0x8014F140;
unk2 = 0x8015C7C0;