Merge pull request #41 from tehzz/introloader

Add asm-processor and makefile dep generation
This commit is contained in:
Revo
2022-12-29 22:54:26 -05:00
committed by GitHub
20 changed files with 276 additions and 138 deletions

3
.gitmodules vendored
View File

@@ -1,3 +1,6 @@
[submodule "tools/n64splat"]
path = tools/n64splat
url = https://github.com/ethteck/n64splat.git
[submodule "tools/asmproc"]
path = tools/asmproc
url = https://github.com/simonlindholm/asm-processor.git

View File

@@ -1,6 +1,8 @@
BASEROM = baserom.z64
TARGET = pokestadium
NON_MATCHING = 0
NON_MATCHING ?= 0
RUN_CC_CHECK ?= 1
WERROR ?= 0
# Fail early if baserom does not exist
ifeq ($(wildcard $(BASEROM)),)
@@ -13,7 +15,7 @@ ifeq ($(UNAME_S),Linux)
else ifeq ($(UNAME_S),Darwin)
HOST_OS := macos
else
$(error Unsupported buiding OS <$(UNAME_S)>)
$(error Unsupported host/building OS <$(UNAME_S)>)
endif
BUILD_DIR := build
@@ -34,6 +36,8 @@ O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.c.o)) \
$(foreach file,$(S_FILES),$(BUILD_DIR)/$(file:.s=.s.o)) \
$(foreach file,$(DATA_FILES),$(BUILD_DIR)/$(file:.bin=.bin.o)) \
DEP_FILES := $(O_FILES:.o=.d)
SPLAT_YAML := splat.yaml
SPLAT = $(PYTHON) tools/n64splat/split.py $(SPLAT_YAML)
@@ -63,6 +67,8 @@ endif
CC = tools/ido_recomp/$(HOST_OS)/7.1/cc
CC_OLD = tools/ido_recomp/$(HOST_OS)/5.3/cc
ASMPROC = python3 tools/asmproc/build.py
ASMPROC_FLAGS :=
MIPS_VERSION := -mips2
@@ -70,6 +76,39 @@ OPTFLAGS := -O2
OBJDUMP_FLAGS := -d -r -z -Mreg-names=32
# include locations
INC_DIRS := include include/PR include/audio .
IINCS := $(foreach d,$(INC_DIRS),-I$d)
# defines for SGI IDO
CDEFS := -D_LANGUAGE_C -DF3DEX_GBI_2 -DNDEBUG
ifneq ($(RUN_CC_CHECK),0)
CHECK_WARNINGS := -Wall -Wextra
CHECK_DEFS := -D_MIPS_SZLONG=32 -DNON_MATCHING
CHECK_FLAGS := -fno-builtin -funsigned-char -fdiagnostics-color -std=gnu89 $(CDEFS) $(CHECK_DEFS) $(IINCS) -nostdinc
CC_CHECK := gcc -fsyntax-only
ifeq ($(HOST_OS),linux)
CC_CHECK += -m32
endif
ifneq ($(WERROR),0)
CHECK_WARNINGS += -Werror
endif
else
CC_CHECK := @:
endif
######################## Flags #############################
ASFLAGS = -EB -mtune=vr4300 -march=vr4300 $(IINCS) -32
# we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff.
CFLAGS = -G 0 -non_shared -Xfullwarn -Xcpluscomm $(IINCS) -Wab,-r4300_mul $(CDEFS) -woff 649,838,712,807 $(MIPS_VERSION)
LDFLAGS = -T undefined_syms.txt -T undefined_syms_auto.txt -T undefined_funcs_auto.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/$(TARGET).map --no-check-sections
######################## Targets #############################
$(foreach dir,$(SRC_DIRS) $(ASM_DIRS) $(DATA_DIRS) $(COMPRESSED_DIRS) $(MAP_DIRS) $(BGM_DIRS),$(shell mkdir -p build/$(dir)))
@@ -205,14 +244,16 @@ build/src/libultra/io/gbpakreadid.c.o: CC := $(CC_OLD)
build/src/libultra/io/gbpakreadwrite.c.o: CC := $(CC_OLD)
build/src/libultra/io/gbpakselectbank.c.o: CC := $(CC_OLD)
######################## Flags #############################
# run ASM-processor on non-libultra source files
DECOMP_C_OBJS := $(filter %.c.o,$(filter-out $(BUILD_DIR)/src/libultra%,$(O_FILES)))
$(DECOMP_C_OBJS): CC := $(ASMPROC) $(ASMPROC_FLAGS) $(CC) -- $(AS) $(ASFLAGS) --
ASFLAGS = -EB -mtune=vr4300 -march=vr4300 -Iinclude -Iinclude/PR -Iinclude/audio -32
# we support Microsoft extensions such as anonymous structs, which the compiler does support but warns for their usage. Surpress the warnings with -woff.
CFLAGS = -G 0 -non_shared -Xfullwarn -Xcpluscomm -Iinclude -Iinclude/PR -Iinclude/audio -Wab,-r4300_mul -D_LANGUAGE_C -DF3DEX_GBI_2 -DNDEBUG -woff 649,838,712,807 $(MIPS_VERSION)
LDFLAGS = -T undefined_syms.txt -T undefined_syms_auto.txt -T undefined_funcs_auto.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(BUILD_DIR)/$(TARGET).map --no-check-sections
# turn off syntax checking errors for libultra
build/src/libultra/al/%.c.o: CHECK_WARNINGS := -w
build/src/libultra/gu/%.c.o: CHECK_WARNINGS := -w
build/src/libultra/io/%.c.o: CHECK_WARNINGS := -w
build/src/libultra/libc/%.c.o: CHECK_WARNINGS := -w
build/src/libultra/os/%.c.o: CHECK_WARNINGS := -w
######################## Build #############################
@@ -222,16 +263,19 @@ LD_SCRIPT = $(TARGET).ld
all: $(BUILD_DIR) $(BUILD_DIR)/$(ROM) verify
clean:
distclean:
rm -rf asm bin assets $(BUILD_DIR) undefined_syms_auto.txt undefined_funcs_auto.txt
clean:
rm -rf $(BUILD_DIR)
submodules:
git submodule update --init --recursive
split:
rm -rf $(DATA_DIRS) $(ASM_DIRS) && ./tools/n64splat/split.py $(SPLAT_YAML)
setup: clean submodules split
setup: distclean submodules split
$(BUILD_DIR):
echo $(C_FILES)
@@ -248,15 +292,16 @@ $(BUILD_DIR)/$(TARGET).elf: $(O_FILES) $(BUILD_DIR)/$(LD_SCRIPT)
@$(LD) $(LDFLAGS) -o $@
$(BUILD_DIR)/%.c.o: %.c
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $^
$(CC_CHECK) $(CHECK_FLAGS) $(CHECK_WARNINGS) -MMD -MP -MT $@ -MF $(@:.o=.d) $<
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $<
$(BUILD_DIR)/src/libultra/libc/ll.c.o: src/libultra/libc/ll.c
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $^
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $<
python3 tools/set_o32abi_bit.py $@
@$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s)
$(BUILD_DIR)/src/libultra/libc/llcvt.c.o: src/libultra/libc/llcvt.c
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $^
$(CC) -c $(CFLAGS) $(OPTFLAGS) -o $@ $<
python3 tools/set_o32abi_bit.py $@
@$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s)
@@ -273,6 +318,8 @@ $(BUILD_DIR)/$(ROM): $(BUILD_DIR)/$(TARGET).bin
verify: $(BUILD_DIR)/$(ROM)
md5sum -c checksum.md5
.PHONY: all clean default split setup
.PHONY: all clean distclean default split setup
print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true
-include $(DEP_FILES)

View File

@@ -4,6 +4,54 @@
#include "ultra64.h"
extern void func_80057FD0(void *, int);
extern s32 func_8005A990(OSPiHandle*);
extern s32 func_8005A990(OSPiHandle *);
// 3A80.s
extern void func_80002F58(void);
extern void *func_80002FDC(s32);
extern void func_80003004(void *); // type unknown
// 3FB0.s
extern void func_80003B30(void *, s32, s32, s32); // types unknown
// 5580.s
extern void func_80004CC0(void *, s32, s32); // types unknown
extern void func_80004CF4(void *); // types unknown
extern void func_80004D20(void *); // types unknown
extern void func_800052B4(void);
extern void func_800053B4(void *, s32); // types unknown
extern void func_80005328(void *); // types unknown
// 60A0.s
extern void func_800057C0(void);
// 6BC0.s
extern u32 func_80006314(s32, s32, s32, s32, s32); // types unknown
// 9D20.s
extern void func_80009120(s32);
// C030.s
extern s32 func_8000B4C4(void);
// D470.s
extern void func_8000C8F8(void);
extern void func_8000CEE4(s32, s32, void *, OSMesgQueue *);
extern void func_8000D0B4(s32, s32, s32, void *, s32, OSMesgQueue *);
// DDC0.s
extern void func_8000D564(void);
// E570.s
extern void func_8000D970(OSPfs *);
// 29BA0.s
extern void func_8002B274(s32, s32);
// exception_set.s
extern void set_watch_lohi(s32);
// readwrite.s
extern void func_80050FC0(void *, s32, s32, void *, s32, OSMesgQueue *);
#endif

View File

@@ -4,6 +4,13 @@
#define true 1
#define false 0
// Avoid compiler warnings for unused variables
#ifdef __GNUC__
#define UNUSED __attribute__((unused))
#else
#define UNUSED
#endif
#ifndef __sgi
#define GLOBAL_ASM(...)
#endif
@@ -22,6 +29,8 @@
// global typings
typedef unsigned long uintptr_t;
#define INT2VOID(i) ((void *)(uintptr_t)(i))
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240

View File

@@ -10,16 +10,6 @@ struct UnkStruct800006C4_2 {
s32 unk28;
};
struct UnkStruct800006C4_1 {
s16 sp20;
s8 sp22;
OSMesgQueue* sp24;
void* sp28;
s32 sp2C;
s32 sp30;
s32 unk34;
};
struct UnkStruct80000A80 {
LEOCmd cmd;
union {
@@ -53,7 +43,7 @@ void *func_80000A3C(struct UnkStruct800006C4_2* arg0);
void *func_80000A80(struct UnkStruct80000A80* arg0);
void *func_80000AB0(struct UnkStruct80000A80* arg0);
void *func_80000AE0(struct UnkStruct80000A80* arg0);
s32 func_80000B10(struct UnkStruct80000A80* arg0);
void *func_80000B10(struct UnkStruct80000A80* arg0);
void *func_80000B74(struct UnkStruct80000A80* arg0);
void thread20_rsp(void *arg);
void rsp_init(void);

View File

@@ -1,5 +1,6 @@
#include <ultra64.h>
#include "controller.h"
#include "gb_tower.h"
// TODO: Identify/move to header
extern s16 func_8000A360(float, float);

View File

@@ -1,9 +1,13 @@
#include <ultra64.h>
#include <string.h>
#include <PR/xstdio.h>
#include <PR/os_internal_thread.h>
#include "stdarg.h"
#include "crash_screen.h"
#include "memmap.h"
#include "controller.h"
extern u32 D_80068BA0[];
extern void *D_80068BA0[];
CrashScreen gCrashScreen;
@@ -182,7 +186,7 @@ void crash_screen_printf(s32 x, s32 y, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
size = _Printf(crash_screen_copy_to_buf, buf, fmt, args);
size = _Printf(crash_screen_copy_to_buf, (char *)buf, fmt, args);
if (size > 0) {
ptr = buf;
@@ -311,7 +315,7 @@ void crash_screen_draw(OSThread* faultedThread) {
// all of these null terminators needed to pad the rodata section for this file
// can potentially fix this problem in another way?
crash_screen_printf(210, 140, "MM:%08XH", *(u32*)ctx->pc);
crash_screen_printf(210, 140, "MM:%08XH", *(u32 *)(uintptr_t)ctx->pc);
}
OSThread* crash_screen_get_faulted_thread(void) {
@@ -328,7 +332,7 @@ OSThread* crash_screen_get_faulted_thread(void) {
return NULL;
}
void crash_screen_thread_entry(void* unused) {
void crash_screen_thread_entry(UNUSED void* unused) {
OSMesg mesg;
OSThread* faultedThread;
@@ -354,7 +358,7 @@ void crash_screen_set_draw_info(u16* frameBufPtr, u16 width, u16 height) {
}
void crash_screen_init(void) {
gCrashScreen.frameBuf = (u16*)((osMemSize | 0xA0000000) - ((SCREEN_WIDTH * SCREEN_HEIGHT) * 2));
gCrashScreen.frameBuf = (u16*)(uintptr_t)((osMemSize | 0xA0000000) - ((SCREEN_WIDTH * SCREEN_HEIGHT) * 2));
gCrashScreen.width = SCREEN_WIDTH;
gCrashScreen.height = 16;
osCreateMesgQueue(&gCrashScreen.queue, &gCrashScreen.mesg, 1);
@@ -372,7 +376,7 @@ void crash_screen_printf_with_bg(s16 x, s16 y, const char* fmt, ...) {
va_start(args, fmt);
size = _Printf(crash_screen_copy_to_buf, buf, fmt, args);
size = _Printf(crash_screen_copy_to_buf, (char *)buf, fmt, args);
if (size > 0) {
crash_screen_draw_rect(x - 6, y - 6, (size + 2) * 6, 19);

View File

@@ -1,6 +1,7 @@
#include <ultra64.h>
#include "common.h"
#include "dma.h"
#include "rsp.h"
extern u32 D_800818E0;
extern s16 D_80083C1C;
@@ -30,9 +31,9 @@ s32 func_80000F0C(s32 arg0, void *arg1, s32 arg2, s32 arg3, s32 arg4) {
temp_v0 = func_80002FDC(0x2C);
if (temp_v0 != NULL) {
temp_v0->unk0 = 0xF4;
temp_v0->unk1C = arg1;
temp_v0->unk1C = (uintptr_t)arg1;
temp_v0->unk24 = arg2;
temp_v0->unk20 = arg0;
temp_v0->unk20 = (void *)(uintptr_t)arg0;
temp_v0->unk28 = arg3;
func_80000E2C(temp_v0, arg4);
}

View File

@@ -1,5 +1,8 @@
#include <ultra64.h>
#include <PR/os_internal_reg.h>
#include "common.h"
#include "dp_intro.h"
#include "crash_screen.h"
// dp_intro.c
@@ -115,9 +118,9 @@ void func_80001380(struct UnkStruct80001380* arg0) {
arg0->task.t.ucode_data = F3DEX2_data_bin;
arg0->task.t.ucode_size = 0x1000;
arg0->task.t.ucode_data_size = 0x800;
arg0->task.t.dram_stack = ALIGN16((u32)D_80084860);
arg0->task.t.dram_stack = (void *)ALIGN16((uintptr_t)D_80084860);
arg0->task.t.dram_stack_size = 0x400;
arg0->task.t.yield_data_ptr = ALIGN16((u32)D_80084C68);
arg0->task.t.yield_data_ptr = (void *)ALIGN16((uintptr_t)D_80084C68);
arg0->task.t.yield_data_size = 0xC00;
arg0->task.t.output_buff = (D_80085870);
arg0->task.t.output_buff_size = (D_80085870 + (0x20000/sizeof(u64)));
@@ -125,7 +128,7 @@ void func_80001380(struct UnkStruct80001380* arg0) {
}
void func_80001444(struct UnkStruct80001380* arg0, struct UnkArray4* arg1, s32 arg2) {
arg0->task.t.data_ptr = arg1->unk4;
arg0->task.t.data_ptr = (void *)(uintptr_t)arg1->unk4;
arg0->task.t.data_size = arg1->unk8;
func_800053B4(arg0, arg2);
}
@@ -139,7 +142,7 @@ void func_80001474(s8 arg0, s8 arg1) {
var_v0 = (arg0 * 2) + arg1 + 4;
}
osViSetMode(&D_800796E0[D_80068B74[var_v0]]);
osViSetMode(&D_800796E0[(s32)D_80068B74[var_v0]]);
osViSetSpecialFeatures(0x40U);
osViSetSpecialFeatures(2U);
osViSetSpecialFeatures(0x10U);
@@ -191,7 +194,7 @@ void func_800015A8(void) {
} while (D_80083CA0.unk1C8 > 0);
}
if (D_80083CA0.unkAA8 != NULL) {
osViSwapBuffer(D_80083CA0.unkAA8->unk8);
osViSwapBuffer((void *)(uintptr_t)D_80083CA0.unkAA8->unk8);
osViRepeatLine(0);
if ((D_80083CA0.unkA9D != D_80083CA0.unkAAD) || (D_80083CA0.unkA9E != D_80083CA0.unkAAE)) {
func_80001474((s8) D_80083CA0.unkA9D, (s8) D_80083CA0.unkA9E);
@@ -201,10 +204,10 @@ void func_800015A8(void) {
} else {
osViBlack(0U);
}
crash_screen_set_draw_info(D_80083CA0.unkAA8->unk8, *(u16 *)&D_80083CA0.unkAA8->unk4, 0x10);
crash_screen_set_draw_info((void *)(uintptr_t)D_80083CA0.unkAA8->unk8, *(u16 *)&D_80083CA0.unkAA8->unk4, 0x10);
} else {
osViRepeatLine(1);
osViSwapBuffer(D_80083CA0.unk9E0->unk8);
osViSwapBuffer((void *)(uintptr_t)D_80083CA0.unk9E0->unk8);
if ((D_80083CA0.unkA9D != D_80083CA0.unkAAD) || (D_80083CA0.unkA9E != D_80083CA0.unkAAE)) {
func_80001474((s8) D_80083CA0.unkA9D, (s8) D_80083CA0.unkA9E);
}
@@ -228,7 +231,7 @@ void func_800017E4(void) {
func_80004CF4(&D_80083CA0);
}
void func_8000183C(void* arg) {
void func_8000183C(UNUSED void *arg) {
__osSetFpcCsr(0x01000C01);
func_80001C1C(&D_8008474C, 0, 1, 2, 0xFF, 0, 0, 0);
func_80001C1C(&D_8008473C, 0, 1, 2, 0xFF, 0, 0, 0);
@@ -273,25 +276,25 @@ void func_800019C8(void) {
void func_80001AD4(u16 arg0) {
s32 i = 0x280;
u16 *arr = D_80083CA0.unk9E0->unk8;
u16 *arr = (void *)(uintptr_t)D_80083CA0.unk9E0->unk8;
while(i --> 0) {
*(arr)++ = arg0;
}
osWritebackDCache(D_80083CA0.unk9E0->unk8, 0x500);
osWritebackDCache((void *)(uintptr_t)D_80083CA0.unk9E0->unk8, 0x500);
}
u16 func_80001B2C(void) {
// YIKES. What is this typing?!?
u16 *ptr = (u16*)((u32*)D_80084680[0])[2];
u16 *ptr = (u16*)(uintptr_t)((u32 *)(uintptr_t)D_80084680[0])[2];
return *ptr;
}
s32 func_80001B40(void) {
s32 result = 0;
if (osViGetCurrentFramebuffer() == (void*)((u32*)D_80084680[0])[2])
if (osViGetCurrentFramebuffer() == ((void **)(uintptr_t)D_80084680[0])[2])
result = 1;
return result;

9
src/dp_intro.h Normal file
View File

@@ -0,0 +1,9 @@
#ifndef _SRC_DP_INTRO_H_
#define _SRC_DP_INTRO_H_
#include <PR/ultratypes.h>
void func_80001474(s8, s8);
void func_800019C8(void);
#endif /* _SRC_DP_INTRO_H_ */

View File

@@ -28,10 +28,10 @@ s32 func_8000A630(s32 arg0, void* arg1) {
u8 sp47;
u8 sp24[0x20];
s32 sp20 = 0;
u8 padding[8];
UNUSED u8 padding[8];
if ((func_8000AF40(arg0, arg1, 0, 0x20) == 0)
&& (func_8000AEBC(arg0, &sp24, 0, 0x20) == 0)
&& (func_8000AEBC(arg0, (uintptr_t)&sp24, 0, 0x20) == 0)
&& (bcmp(&sp24, arg1, 0x20) == 0)
&& (osGbpakGetStatus(&D_800A8100[arg0], &sp47) == 0))
{
@@ -47,12 +47,12 @@ s32 func_8000A6D8(s32 arg0, u8* arg1) {
if (arg1 == NULL) {
arg1 = sp34;
}
HAL_Memset(arg1, 0x55, 0x20);
HAL_Memset((char *)arg1, 0x55, 0x20);
if (func_8000A630(arg0, arg1) != 0) {
HAL_Memset(arg1, 0xAA, 0x20);
HAL_Memset((char *)arg1, 0xAA, 0x20);
if (func_8000A630(arg0, arg1) != 0) {
s32 i;
for (i = 0; i < sizeof(sp34); i++) {
for (i = 0; i < ARRAY_COUNT(sp34); i++) {
arg1[i] = osGetCount();
}
var_s0 = func_8000A630(arg0, arg1);
@@ -61,7 +61,7 @@ s32 func_8000A6D8(s32 arg0, u8* arg1) {
return var_s0;
}
s32 func_8000A798(s32 arg0, u8* arg1, s32 arg2) {
s32 func_8000A798(s32 arg0, u8 *arg1, u8 *arg2) {
u8 status;
OSGbpakId gbpakId;
s32 sp28 = 0;
@@ -119,16 +119,16 @@ s32 func_8000A9D0(OSGbpakId* header) {
// is the cartridge non-Japanese?
if (header->country_code == 1) {
// Which supported POKeMON version is this?
if (HAL_Strcmp(header->game_title, "POKEMON RED") == 0) {
if (HAL_Strcmp((char *)header->game_title, "POKEMON RED") == 0) {
return 1;
}
if (HAL_Strcmp(header->game_title, "POKEMON GREEN") == 0) {
if (HAL_Strcmp((char *)header->game_title, "POKEMON GREEN") == 0) {
return 1;
}
if (HAL_Strcmp(header->game_title, "POKEMON BLUE") == 0) {
if (HAL_Strcmp((char *)header->game_title, "POKEMON BLUE") == 0) {
return 1;
}
if (HAL_Strcmp(header->game_title, "POKEMON YELLOW") == 0) {
if (HAL_Strcmp((char *)header->game_title, "POKEMON YELLOW") == 0) {
return 1;
}
}
@@ -187,7 +187,7 @@ s32 func_8000AA7C(void) {
s32 func_8000AC7C(s32 arg0) {
u8 status;
s32 ret = osGbpakGetStatus(&D_800A8100[arg0], &status);
u8 filler;
UNUSED u8 filler;
// check the error code returned (if applicable) by the osGbpakGetStatus
// call.
@@ -212,7 +212,7 @@ s32 func_8000ACF4(s32 arg0) {
}
s32 func_8000AD68(s32 arg0) {
u8 filler[4];
UNUSED u8 filler[4];
u8 status;
OSGbpakId sp28;
@@ -235,7 +235,7 @@ s32 func_8000AE28(s32 arg0, void* arg1) {
s32 sp18;
sp18 = 0;
if ((func_8000AEBC(arg0, &sp1C, 0, 0x20) == 0) && (bcmp(&sp1C, arg1, 0x20) == 0)
if ((func_8000AEBC(arg0, (uintptr_t)&sp1C, 0, 0x20) == 0) && (bcmp(&sp1C, arg1, 0x20) == 0)
&& (osGbpakGetStatus(&D_800A8100[arg0], &status) == 0)
&& !(status & OS_GBPAK_RSTB_DETECTION)) {
sp18 = 1;
@@ -258,7 +258,7 @@ s32 func_8000AF40(s32 arg0, void* arg1, u16 arg2, u16 arg3) {
var_v1 = 1;
if (D_800A82A5 & (1 << arg0)) {
var_v1 = func_8000DAFC(&D_800A8100[arg0], 1, arg2, arg1, arg3);
var_v1 = func_8000DAFC(&D_800A8100[arg0], 1, arg2, (uintptr_t)arg1, arg3);
}
return var_v1;
}

8
src/gb_tower.h Normal file
View File

@@ -0,0 +1,8 @@
#ifndef _SRC_GB_TOWER_H_
#define _SRC_GB_TOWER_H_
#include <PR/ultratypes.h>
void func_8000B330(void);
#endif /* _SRC_GB_TOWER_H_ */

View File

@@ -1,4 +1,5 @@
#include <ultra64.h>
#include <string.h>
#include "hal_libc.h"
/*
@@ -16,8 +17,8 @@ char* HAL_Strcpy(char* dest, char* src) {
* Alternate strcpy implementation; return the post-increment altered dest pointer.
*/
char* HAL_Strcpy2(char *dest, char* src) {
size_t c = strlen(dest); // this is completely pointless. the strlen func called
// doesnt alter the pointer.
UNUSED size_t c = strlen(dest); // this is completely pointless. the strlen func called
// doesnt alter the pointer.
while ((*(dest++) = *(src++)) != '\0') {
}
return dest;

View File

@@ -1,6 +1,10 @@
#include <ultra64.h>
extern void thread1_idle(); // thread 1 function
#include "common.h"
#include "dp_intro.h"
#include "crash_screen.h"
#include "rsp.h"
extern void func_8002B330(); // thread 6 function
// entry .bss
@@ -16,7 +20,7 @@ u8 D_800818F8[0x8];
/**
* Initialize hardware, start main thread, then idle.
*/
void thread1_idle(void *arg0) {
void thread1_idle(UNUSED void *arg0) {
osCreateViManager(OS_PRIORITY_VIMGR);
func_80001474(0, 1);
osViBlack(TRUE);

View File

@@ -67,7 +67,7 @@ void Memmap_SetSegments(Gfx** gfxDl) {
Gfx* gfx = *gfxDl;
for(i = 0; i < 16; i++) {
gSPSegment(gfx++, i, osVirtualToPhysical(gSegments[i].vaddr));
gSPSegment(gfx++, i, osVirtualToPhysical((void *)gSegments[i].vaddr));
}
*gfxDl = gfx;
}
@@ -83,12 +83,12 @@ void Memmap_RelocateFragment(u32 id, struct Fragment* fragment) {
u32 *relocDataP;
u32 relocSize;
struct RelocTable* relocInfo;
u32 relocOffset;
UNUSED u32 relocOffset;
u32 reloc;
u32 temp_v0_5;
u32 i;
u32 *regValP;
s32 pad;
UNUSED s32 pad;
relocOffset = fragment->relocOffset;
relocSize = fragment->sizeInRam - fragment->relocOffset;
@@ -96,7 +96,7 @@ void Memmap_RelocateFragment(u32 id, struct Fragment* fragment) {
osInvalICache(fragment, fragment->sizeInRam);
osInvalDCache(fragment, fragment->sizeInRam);
Memmap_SetFragmentMap(id, fragment, fragment->sizeInRam);
Memmap_SetFragmentMap(id, (uintptr_t)fragment, fragment->sizeInRam);
for(i = 0; i < relocInfo->nRelocations; i++) {
reloc = relocInfo->relocations[i];
@@ -138,7 +138,7 @@ void Memmap_RelocateFragment(u32 id, struct Fragment* fragment) {
}
}
if (relocSize != 0) {
bzero(((uintptr_t)fragment->relocOffset + (uintptr_t)fragment), relocSize);
bzero((void *)((uintptr_t)fragment->relocOffset + (uintptr_t)fragment), relocSize);
}
osWritebackDCache(fragment, fragment->sizeInRam);
}
@@ -207,7 +207,7 @@ void Memmap_ClearFragmentMemmap(u32 id) {
*/
uintptr_t Memmap_GetLoadedFragmentVaddr(uintptr_t addr) {
struct MemoryMap* fraglist = gFragments;
int i, j;
int i, UNUSED j;
for(i = 0, fraglist = gFragments; i < 0xF0; i++, fraglist++) {
if (addr >= fraglist->vaddr) {

134
src/rsp.c
View File

@@ -22,8 +22,8 @@ struct UnkStruct80083BD0 D_80083BD0;
s16 D_80083C1C;
s32 func_800005C0(void) {
s32 unused;
s32 unused2[6];
UNUSED s32 unused;
UNUSED s32 unused2[6];
s32 result;
result = LeoCJCreateLeoManager(0x95, 0x96, &D_80083B4C, 0x10);
@@ -40,9 +40,9 @@ OSPiHandle* func_80000628(void) {
static OSPiHandle sramHandle;
void* baseAddr = OS_PHYSICAL_TO_K1(SRAM_START_ADDR);
if (baseAddr != (void*)sramHandle.baseAddress) {
if (baseAddr != (void *)(uintptr_t)sramHandle.baseAddress) {
sramHandle.type = DEVICE_TYPE_SRAM;
sramHandle.baseAddress = baseAddr;
sramHandle.baseAddress = (uintptr_t)baseAddr;
sramHandle.latency = SRAM_latency;
sramHandle.pulse = SRAM_pulse;
sramHandle.pageSize = SRAM_pageSize;
@@ -57,87 +57,93 @@ OSPiHandle* func_80000628(void) {
}
s32 func_800006C4(struct UnkStruct800006C4_2* arg0) {
struct UnkStruct800006C4_1 unkStruct;
s32 unk1C = func_80000628();
OSIoMesg msg;
OSPiHandle *handle = func_80000628();
msg.hdr.pri = 0;
msg.hdr.retQueue = &D_80083BD0.queue2;
msg.dramAddr = arg0->vaddr;
msg.devAddr = arg0->unk1C;
msg.size = arg0->size;
unkStruct.sp22 = 0;
unkStruct.sp24 = &D_80083BD0.queue2;
unkStruct.sp28 = arg0->vaddr;
unkStruct.sp2C = arg0->unk1C;
unkStruct.sp30 = arg0->size;
osInvalDCache(arg0->vaddr, arg0->size);
osEPiStartDma(unk1C, &unkStruct.sp20, 0);
osEPiStartDma(handle, &msg, 0);
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, 1);
return 0;
}
s32 func_8000074C(struct UnkStruct800006C4_2* arg0) {
struct UnkStruct800006C4_1 unkStruct;
s32 unk1C = func_80000628();
OSIoMesg msg;
OSPiHandle *handle = func_80000628();
msg.hdr.pri = 0;
msg.hdr.retQueue = &D_80083BD0.queue2;
msg.dramAddr = arg0->vaddr;
msg.devAddr = arg0->unk1C;
msg.size = arg0->size;
unkStruct.sp22 = 0;
unkStruct.sp24 = &D_80083BD0.queue2;
unkStruct.sp28 = arg0->vaddr;
unkStruct.sp2C = arg0->unk1C;
unkStruct.sp30 = arg0->size;
osWritebackDCache(arg0->vaddr, arg0->size);
osEPiStartDma(unk1C, &unkStruct.sp20, 1);
osEPiStartDma(handle, &msg, 1);
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, OS_MESG_BLOCK);
return 0;
}
s32 func_800007D4(struct UnkStruct800006C4_2* arg0, s32 arg1) {
struct UnkStruct800006C4_1 unkStruct;
OSPiHandle* handle;
if(arg1 == 0) {
OSIoMesg msg;
OSPiHandle *handle;
if (arg1 == 0) {
handle = osCartRomInit();
} else {
handle = osDriveRomInit();
}
unkStruct.sp22 = 0;
unkStruct.sp24 = &D_80083BD0.queue2;
unkStruct.sp28 = arg0->vaddr;
unkStruct.sp2C = arg0->unk1C;
unkStruct.sp30 = arg0->size;
msg.hdr.pri = 0;
msg.hdr.retQueue = &D_80083BD0.queue2;
msg.dramAddr = arg0->vaddr;
msg.devAddr = arg0->unk1C;
msg.size = arg0->size;
osInvalDCache(arg0->vaddr, arg0->size);
osEPiStartDma(handle, &unkStruct.sp20, 0);
osEPiStartDma(handle, &msg, 0);
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, OS_MESG_BLOCK);
return 0;
}
s32 func_8000087C(struct UnkStruct800006C4_2* arg0) {
struct UnkStruct800006C4_1 unkStruct;
OSPiHandle* handle;
OSIoMesg msg;
OSPiHandle *handle;
handle = osCartRomInit();
unkStruct.sp22 = 0;
unkStruct.sp24 = &D_80083BD0.queue2;
unkStruct.sp28 = arg0->vaddr;
unkStruct.sp2C = arg0->unk1C;
unkStruct.sp30 = arg0->size;
msg.hdr.pri = 0;
msg.hdr.retQueue = &D_80083BD0.queue2;
msg.dramAddr = arg0->vaddr;
msg.devAddr = arg0->unk1C;
msg.size = arg0->size;
osWritebackDCache(arg0->vaddr, arg0->size);
osEPiStartDma(handle, &unkStruct.sp20, 1);
osEPiStartDma(handle, &msg, 1);
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, OS_MESG_BLOCK);
return 0;
}
s32 func_80000904(struct UnkStruct800006C4_2* arg0) {
s32 arr[5];
UNUSED s32 arr[5];
s32 sp20;
osInvalDCache(arg0->vaddr, 0x80);
func_8000D0B4(&sp20, 0, arg0->unk1C, arg0->vaddr, 1, &D_80083BD0.queue2);
func_8000D0B4((uintptr_t)&sp20, 0, arg0->unk1C, arg0->vaddr, 1, &D_80083BD0.queue2);
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, OS_MESG_BLOCK);
return 0;
}
s32 func_80000974(struct UnkStruct800006C4_2* arg0) {
s32 arr[5];
UNUSED s32 arr[5];
s32 sp20_4;
s32 sp20_5;
UNUSED s32 sp20_5;
func_8000CEE4(&sp20_4, 0, arg0->vaddr, &D_80083BD0.queue2);
func_8000CEE4((uintptr_t)&sp20_4, 0, arg0->vaddr, &D_80083BD0.queue2);
osRecvMesg(&D_80083BD0.queue2, &D_80083BD0.unk0, OS_MESG_BLOCK);
return 0;
}
@@ -174,12 +180,12 @@ void *func_80000AE0(struct UnkStruct80000A80* arg0) {
return func_800009C8();
}
s32 func_80000B10(struct UnkStruct80000A80* arg0) {
s32 temp_v0;
void *func_80000B10(struct UnkStruct80000A80* arg0) {
void *temp_v0;
LeoReadRTC(&arg0->cmd, &D_80083BD0.queue2);
temp_v0 = func_800009C8();
if (temp_v0 == 0) {
if (temp_v0 == NULL) {
*(LEODiskTime*)arg0->addr = arg0->cmd.data.time;
}
return temp_v0;
@@ -190,9 +196,9 @@ void *func_80000B74(struct UnkStruct80000A80* arg0) {
return func_800009C8();
}
void thread20_rsp(void *arg) {
void thread20_rsp(UNUSED void *arg) {
struct UnkStruct800006C4_2* sp2C;
void* var_v0;
OSMesg var_v0;
func_800005C0();
func_8000C8F8();
@@ -200,31 +206,31 @@ void thread20_rsp(void *arg) {
osRecvMesg(&D_80083BD0.queue1, (void*)&sp2C, OS_MESG_BLOCK);
switch (sp2C->unk0) {
case 0xF0:
var_v0 = func_800007D4(sp2C, 0);
var_v0 = (OSMesg)INT2VOID(func_800007D4(sp2C, 0));
break;
case 0xF1:
var_v0 = func_800007D4(sp2C, 1);
var_v0 = (OSMesg)INT2VOID(func_800007D4(sp2C, 1));
break;
case 0xF2:
var_v0 = func_800006C4(sp2C);
var_v0 = (OSMesg)INT2VOID(func_800006C4(sp2C));
break;
case 0xF3:
var_v0 = func_8000074C(sp2C);
var_v0 = (OSMesg)INT2VOID(func_8000074C(sp2C));
break;
case 0xF4:
var_v0 = func_8000087C(sp2C);
var_v0 = (OSMesg)INT2VOID(func_8000087C(sp2C));
break;
case 0xF5:
var_v0 = func_80000904(sp2C);
var_v0 = (OSMesg)INT2VOID(func_80000904(sp2C));
break;
case 0xF6:
var_v0 = func_80000974(sp2C);
var_v0 = (OSMesg)INT2VOID(func_80000974(sp2C));
break;
case 0x5:
var_v0 = func_800009F8(sp2C);
var_v0 = (OSMesg)func_800009F8(sp2C);
break;
case 0x6:
var_v0 = func_80000A3C(sp2C);
var_v0 = (OSMesg)func_80000A3C(sp2C);
break;
case 0xC:
/*
@@ -232,23 +238,23 @@ void thread20_rsp(void *arg) {
* there is very tenuous aliasing going on due to s16 and u8 overlap where
* there should be word loads. What is going on here?
*/
var_v0 = func_80000A80((struct UnkStruct80000A80 *)sp2C);
var_v0 = (OSMesg)func_80000A80((struct UnkStruct80000A80 *)sp2C);
break;
case 0x7:
var_v0 = func_80000AB0((struct UnkStruct80000A80 *)sp2C);
var_v0 = (OSMesg)func_80000AB0((struct UnkStruct80000A80 *)sp2C);
break;
case 0x8:
var_v0 = func_80000AE0((struct UnkStruct80000A80 *)sp2C);
var_v0 = (OSMesg)func_80000AE0((struct UnkStruct80000A80 *)sp2C);
break;
case 0xD:
var_v0 = func_80000B10((struct UnkStruct80000A80 *)sp2C);
var_v0 = (OSMesg)func_80000B10((struct UnkStruct80000A80 *)sp2C);
break;
case 0xE:
var_v0 = func_80000B74((struct UnkStruct80000A80 *)sp2C);
var_v0 = (OSMesg)func_80000B74((struct UnkStruct80000A80 *)sp2C);
break;
}
if ((OSMesgQueue*)sp2C->unk28 != NULL) {
osSendMesg(sp2C->unk28, var_v0, 0);
if ((OSMesgQueue *)INT2VOID(sp2C->unk28) != NULL) {
osSendMesg(INT2VOID(sp2C->unk28), var_v0, 0);
}
func_80003004(sp2C);
}
@@ -257,7 +263,7 @@ void thread20_rsp(void *arg) {
void rsp_init(void) {
osCreateMesgQueue(&D_80083BD0.queue2, &D_80083BCC, 1);
osCreateMesgQueue(&D_80083BD0.queue1, &D_80083B8C, 16);
osCreatePiManager(0x96, &D_80083BD0.unk4, &gRspThreadStack[0x1C], 0x20);
osCreatePiManager(0x96, (void *)&D_80083BD0.unk4, (OSMesg)&gRspThreadStack[0x1C], 0x20);
osCreateThread(&gRspThread, 20, thread20_rsp, NULL, gRspThreadStack, 90);
osStartThread(&gRspThread);
}

View File

@@ -1,4 +1,5 @@
#include <ultra64.h>
#include <macros.h>
// used for padding. Splat cant auto gen these I guess
static u8 unk_bss[0x800A7320-0x80083CA0];
UNUSED static u8 unk_bss[0x800A7320-0x80083CA0];

View File

@@ -1,3 +1,4 @@
#include <ultra64.h>
#include <macros.h>
static u8 unk_bss[0x80103880-0x800A7EA0];
UNUSED static u8 unk_bss[0x80103880-0x800A7EA0];

View File

@@ -1,4 +1,5 @@
#include <ultra64.h>
#include <macros.h>
// used for padding. Splat cant auto gen these I guess
static u8 unk_bss[0x800A74C0-0x800A7420];
UNUSED static u8 unk_bss[0x800A74C0-0x800A7420];

1
tools/asmproc Submodule

Submodule tools/asmproc added at 742406e7dc