├── .clang-format ├── .gitignore ├── .gitmodules ├── Makefile ├── README.md ├── diff.py ├── diff_settings.py ├── include ├── PR │ ├── abi.h │ ├── gbi.h │ ├── gu.h │ ├── libaudio.h │ ├── libultra.h │ ├── mbi.h │ ├── os_ai.h │ ├── os_cache.h │ ├── os_cont.h │ ├── os_eeprom.h │ ├── os_exception.h │ ├── os_internal.h │ ├── os_libc.h │ ├── os_message.h │ ├── os_misc.h │ ├── os_pi.h │ ├── os_rdp.h │ ├── os_thread.h │ ├── os_time.h │ ├── os_tlb.h │ ├── os_vi.h │ ├── sptask.h │ ├── ucode.h │ └── ultratypes.h ├── common.h ├── macro.inc ├── macros.h ├── math.h └── ultra64.h ├── marioparty3.sha1 ├── splat.yaml ├── src ├── 1A580.c ├── 1A580.h ├── 1AC70.c ├── 1AC70.h ├── 365E0.c ├── 365E0.h ├── 36650.c ├── 36F80.c ├── 47D60.c ├── 47D60.h ├── 4B120.c ├── 5ACF0.c ├── BCA0.c ├── C1F0.c ├── CE10.c ├── EFC0.c ├── board.h ├── decode.c ├── heap.c ├── heap.h ├── heap_permanent.c ├── heap_permanent.h ├── heap_temporary.c ├── heap_temporary.h ├── lib │ └── hvq.c ├── libultra │ ├── libc │ │ └── string.c │ ├── libultra_internal.h │ └── os │ │ ├── osCreateMesgQueue.c │ │ ├── osGetTime.c │ │ ├── osInitRdb.c │ │ ├── osJamMesg.c │ │ ├── osRecvMesg.c │ │ ├── osSendMesg.c │ │ ├── osSetTimer.c │ │ └── osVirtualToPhysical.c ├── mainfs.c ├── object.h ├── overlays │ ├── board_chillywaters │ │ ├── chillywaters.c │ │ ├── chillywaters2.c │ │ └── chillywaters_main.c │ ├── board_spinydesert │ │ ├── spinydesert.c │ │ └── spinydesert_main.c │ ├── debug_message_check │ │ └── 4F69F0.c │ ├── intro │ │ ├── intro.c │ │ └── intro_main.c │ ├── minigame_results │ │ └── 4E6DC0.c │ ├── minigames │ │ └── swinging_with_sharks │ │ │ └── swinging_with_sharks.c │ ├── overlay100 │ │ └── 460790.c │ ├── overlay101 │ │ └── 464360.c │ ├── overlay110 │ │ └── 4C8050.c │ ├── overlay115 │ │ └── 4F01F0.c │ ├── overlay116 │ │ └── 4F3780.c │ ├── overlay124 │ │ └── 5486A0.c │ ├── overlay125 │ │ └── 54F360.c │ ├── overlay129 │ │ ├── CCD20.c │ │ └── E3CD0.c │ ├── overlay71 │ │ ├── overlay71.c │ │ └── overlay71_main.c │ ├── overlay79 │ │ └── 3B9670.c │ ├── overlay80 │ │ └── 3C27C0.c │ ├── overlay81 │ │ └── 3C6310.c │ ├── overlay83 │ │ └── 3CA800.c │ ├── overlay84 │ │ └── 3CDEC0.c │ ├── overlay98 │ │ └── 4554C0.c │ ├── shared_board │ │ ├── 1006F0.c │ │ ├── 101840.c │ │ ├── 105D50.c │ │ ├── 10C230.c │ │ ├── 113750.c │ │ ├── EA790.c │ │ ├── ECA50.c │ │ ├── F5070.c │ │ ├── F5B90.c │ │ └── FFB10.c │ └── start_screen │ │ └── 524820.c ├── player.h ├── process.c ├── process.h ├── rom.c ├── rom.h ├── setjmp.h ├── spaces.h ├── stubbed.c └── thread3_main.c ├── symbol_addrs.txt ├── tools ├── Makefile ├── README.md ├── libmio0.c ├── libmio0.h ├── libsm64.c ├── libsm64.h ├── m2ctx.py ├── marioparty-binutils-2.7-as ├── mips-binutils-2.7-as ├── mips-cc1 ├── n64cksum.c ├── patches.py ├── run-mips-to-c.py ├── utils.c └── utils.h ├── undefined_funcs.txt ├── undefined_funcs_auto.txt ├── undefined_syms.txt └── undefined_syms_auto.txt /.clang-format: -------------------------------------------------------------------------------- 1 | IndentWidth: 4 2 | Language: Cpp 3 | UseTab: Never 4 | ColumnLimit: 120 5 | BreakBeforeBraces: Attach 6 | SpaceAfterCStyleCast: false 7 | Cpp11BracedListStyle: false 8 | IndentCaseLabels: true 9 | BinPackArguments: true 10 | BinPackParameters: true 11 | AlignAfterOpenBracket: Align 12 | AlignOperands: true 13 | BreakBeforeTernaryOperators: true 14 | BreakBeforeBinaryOperators: None 15 | AllowShortBlocksOnASingleLine: true 16 | AllowShortIfStatementsOnASingleLine: false 17 | AllowShortLoopsOnASingleLine: false 18 | AllowShortCaseLabelsOnASingleLine: false 19 | AllowShortFunctionsOnASingleLine: false 20 | AlignEscapedNewlines: Left 21 | AlignTrailingComments: true 22 | SortIncludes: false 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | assets/* 2 | build/* 3 | bin/* 4 | asm/* 5 | *.z64 6 | *.ld 7 | .splat_cache 8 | include/ld_addrs.h 9 | 10 | # Tools 11 | tools/n64cksum 12 | 13 | # Cache files 14 | __pycache__/ 15 | .pyc 16 | 17 | # Text editor remnants 18 | .vscode/ 19 | .vs/ 20 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/n64splat"] 2 | path = tools/n64splat 3 | url = https://github.com/ethteck/n64splat.git 4 | [submodule "tools/asm-differ"] 5 | path = tools/asm-differ 6 | url = https://github.com/simonlindholm/asm-differ.git 7 | [submodule "tools/mips_to_c"] 8 | path = tools/mips_to_c 9 | url = https://github.com/matt-kempster/mips_to_c.git 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ### Build Options ### 2 | 3 | # Override these options in settings.mk or with `make SETTING=value'. 4 | 5 | BASEROM = baserom.u.z64 6 | TARGET = marioparty3 7 | COMPARE = 1 8 | NON_MATCHING = 0 9 | CHECK = 0 10 | 11 | # Microcode 12 | GRUCODE_CFLAGS := -DF3DEX_GBI_2 13 | GRUCODE_ASFLAGS := --defsym F3DEX_GBI_2=1 14 | 15 | # Patches 16 | # PATCHES_ASFLAGS := --defsym MP_SAVETYPE_PATCH=1 17 | 18 | # Fail early if baserom does not exist 19 | ifeq ($(wildcard $(BASEROM)),) 20 | $(error Baserom `$(BASEROM)' not found.) 21 | endif 22 | 23 | # NON_MATCHING=1 implies COMPARE=0 24 | ifeq ($(NON_MATCHING),1) 25 | override COMPARE=0 26 | endif 27 | 28 | 29 | ### Output ### 30 | 31 | BUILD_DIR := build 32 | ROM := $(BUILD_DIR)/$(TARGET).z64 33 | ELF := $(BUILD_DIR)/$(TARGET).elf 34 | LD_SCRIPT := $(TARGET).ld 35 | LD_MAP := $(BUILD_DIR)/$(TARGET).map 36 | 37 | 38 | ### Tools ### 39 | 40 | PYTHON := python3 41 | N64CKSUM := tools/n64cksum 42 | SPLAT_YAML := splat.yaml 43 | SPLAT = $(PYTHON) tools/n64splat/split.py $(SPLAT_YAML) 44 | PATCHES = $(PYTHON) tools/patches.py 45 | EMULATOR = mupen64plus 46 | SHA1SUM = sha1sum 47 | 48 | 49 | ### Compiler Options ### 50 | 51 | CROSS := mips-linux-gnu- 52 | AS := $(CROSS)as 53 | OLD_AS := tools/marioparty-binutils-2.7-as 54 | CC := tools/mips-cc1 55 | CPP := cpp -P 56 | LD := $(CROSS)ld 57 | OBJCOPY := $(CROSS)objcopy 58 | 59 | CFLAGSCOMMON = -G 0 -quiet -mcpu=r4300 -mips2 60 | 61 | ASFLAGS := -G 0 -I include -mips3 -mabi=32 $(GRUCODE_ASFLAGS) $(PATCHES_ASFLAGS) 62 | OLDASFLAGS := -G 0 -I include -mips2 $(GRUCODE_ASFLAGS) $(PATCHES_ASFLAGS) 63 | CFLAGS := -O1 $(CFLAGSCOMMON) 64 | LDFLAGS := -T undefined_syms.txt -T undefined_funcs.txt -T undefined_funcs_auto.txt -T undefined_syms_auto.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -Map $(LD_MAP) --no-check-sections 65 | 66 | # Check code syntax with host compiler 67 | CC_CHECK := gcc -fsyntax-only -fsigned-char -nostdinc -fno-builtin -I include -I $(BUILD_DIR)/include -I src\ 68 | -D CC_CHECK\ 69 | -std=gnu90 -Wall -Wextra -Wno-format-security -Wno-unused-parameter -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast $(GRUCODE_CFLAGS) 70 | ifneq ($(CHECK),1) 71 | CC_CHECK += -w 72 | endif 73 | 74 | ### Sources ### 75 | 76 | # Object files 77 | OBJECTS = $(shell grep -E 'build.+\.o' marioparty3.ld -o) 78 | 79 | 80 | ### Targets ### 81 | 82 | build/src/libultra/os/%.o: CFLAGS := -O2 $(CFLAGSCOMMON) 83 | build/src/libultra/libc/%.o: CFLAGS := -O2 $(CFLAGSCOMMON) 84 | build/src/lib/%.o: CFLAGS := -O2 $(CFLAGSCOMMON) 85 | 86 | clean: 87 | rm -rf $(BUILD_DIR) 88 | 89 | clean-all: 90 | rm -rf $(BUILD_DIR) asm assets include/ld_addrs.h 91 | 92 | setup: clean submodules split 93 | make -C tools 94 | 95 | submodules: 96 | git submodule update --init --recursive 97 | 98 | split: 99 | rm -rf assets asm 100 | $(SPLAT) 101 | $(PATCHES) 102 | 103 | test: $(ROM) 104 | $(EMULATOR) $< 105 | 106 | $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) 107 | @mkdir -p $(shell dirname $@) 108 | $(CPP) -DBUILD_DIR=$(BUILD_DIR) -o $@ $< 109 | 110 | # Pre-process .c files with the modern cpp. 111 | $(BUILD_DIR)/src/%.i: src/%.c 112 | @mkdir -p $(shell dirname $@) 113 | @$(CC_CHECK) -MMD -MP -MT $@ -MF $@.d $< 114 | $(CPP) -MMD -MP -MT $@ -MF $@.d -I include/ -o $@ $< 115 | 116 | # Go from .i to .s... 117 | $(BUILD_DIR)/src/%.s: $(BUILD_DIR)/src/%.i 118 | @mkdir -p $(shell dirname $@) 119 | $(CC) $(CFLAGS) -o $@ $< 120 | 121 | # Run a separate assembler for src and asm .s files. 122 | $(BUILD_DIR)/src/%.c.o: $(BUILD_DIR)/src/%.s 123 | @mkdir -p $(shell dirname $@) 124 | $(OLD_AS) $(OLDASFLAGS) -o $@ $< 125 | 126 | $(BUILD_DIR)/asm/%.s.o: asm/%.s 127 | @mkdir -p $(shell dirname $@) 128 | $(AS) $(ASFLAGS) -o $@ $< 129 | 130 | $(BUILD_DIR)/data/%.data.o: asm/data/%.data.s 131 | @mkdir -p $(shell dirname $@) 132 | $(AS) $(ASFLAGS) -o $@ $< 133 | 134 | $(BUILD_DIR)/rodata/%.rodata.o: asm/data/%.rodata.s 135 | @mkdir -p $(shell dirname $@) 136 | $(AS) $(ASFLAGS) -o $@ $< 137 | 138 | # Create .o files from .bin files. 139 | $(BUILD_DIR)/%.bin.o: %.bin 140 | @mkdir -p $(shell dirname $@) 141 | $(LD) -r -b binary -o $@ $< 142 | 143 | # Continue the rest of the build... 144 | $(BUILD_DIR)/$(TARGET).elf: $(BUILD_DIR)/$(LD_SCRIPT) $(OBJECTS) 145 | $(LD) $(LDFLAGS) -o $@ 146 | 147 | $(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf 148 | $(OBJCOPY) $< $@ -O binary 149 | 150 | $(ROM): $(BUILD_DIR)/$(TARGET).bin 151 | @cp $< $@ 152 | $(N64CKSUM) $< $@ 153 | ifeq ($(COMPARE),1) 154 | @$(SHA1SUM) -c $(TARGET).sha1 || (echo 'The build succeeded, but did not match the base ROM. This is expected if you are making changes to the game. To skip this check, use "make COMPARE=0".' && false) 155 | endif 156 | 157 | 158 | ### Make Settings ### 159 | 160 | .PHONY: clean test setup submodules split $(ROM) 161 | .DELETE_ON_ERROR: 162 | .SECONDARY: 163 | .PRECIOUS: $(ROM) 164 | .DEFAULT_GOAL := $(ROM) 165 | 166 | # Remove built-in implicit rules to improve performance 167 | MAKEFLAGS += --no-builtin-rules 168 | 169 | # Fail targets if any command in the pipe exits with error 170 | SHELL = /bin/bash -e -o pipefail 171 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mp3 2 | 3 | A WIP decomp of Mario Party 3. 4 | 5 | # Dependencies 6 | 7 | 1. Backup of Mario Party 3 in Big Endian (.z64) format 8 | *Note: This repository does not include the game ROM. You must provide the ROM yourself to build.* 9 | 2. Python3 and PIP 10 | *https://pip.pypa.io/en/stable/installation/* 11 | 3. PIP packages: rabbitizer, spimdisasm, tqdm, pyyaml, colorama, intervaltree, n64img 12 | `sudo pip3 install rabbitizer spimdisasm tqdm pyyaml colorama n64img` 13 | 14 | # To use 15 | 16 | 1. Place the US Mario Party 3 rom into the root of the repository as "baserom.u.z64". 17 | 2. Set up tools and extract the rom: `make setup` 18 | 3. Re-assemble the rom: `make -j` 19 | 20 | After substantial changes, sometimes it is necessary to run: `make clean-all && make setup && make -j` 21 | 22 | # Modifications 23 | 24 | Only a small percentage of the game is decompiled, so it is not possible to modify and recompile 25 | a working game in most cases. However, certain overlays that are fully decompiled can be modified, 26 | since the major sections of the ROM are able to be shifted. For example, you can successfully modify 27 | `intro.c` from the decompiled intro overlay and recompile a working ROM. 28 | 29 | If you want to try this, you need to do a few things: 30 | 31 | 1. In splat.yaml, set `shiftable: True` in the options. 32 | 2. In the Makefile, uncomment the `PATCHES_ASFLAGS` line near the top. (Not strictly necessary, but the save type patch is helpful, else the game tends to not boot in some emulators due to unrecognized checksum.) 33 | 3. Clean and resplit the repo (standard setup, see above). 34 | 4. Make changes to a C file. 35 | 5. Compile. 36 | 6. Use the ROM created at `build/marioparty3.z64`. 37 | -------------------------------------------------------------------------------- /diff_settings.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | def apply(config, args): 4 | config['baseimg'] = 'baserom.u.z64' 5 | config['myimg'] = 'build/marioparty3.z64' 6 | config['mapfile'] = 'build/marioparty3.map' 7 | config['source_directories'] = ['.'] 8 | -------------------------------------------------------------------------------- /include/PR/gu.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_GU_H_ 2 | #define _ULTRA64_GU_H_ 3 | 4 | #define GU_PI 3.1415926 5 | /* Functions */ 6 | 7 | void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, 8 | float near, float far, float scale); 9 | void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, 10 | float far, float scale); 11 | void guOrtho(Mtx *m, float left, float right, float bottom, float top, 12 | float near, float far, float scale); 13 | void guTranslate(Mtx *m, float x, float y, float z); 14 | void guRotate(Mtx *m, float a, float x, float y, float z); 15 | void guScale(Mtx *m, float x, float y, float z); 16 | void guMtxF2L(float mf[4][4], Mtx *m); 17 | void guMtxIdent(Mtx *m); 18 | void guMtxIdentF(float mf[4][4]); 19 | void guMtxL2F(float mf[4][4], Mtx *m); 20 | void guNormalize(float *, float *, float *); 21 | 22 | /* Used only in Fast3DEX2 */ 23 | void guLookAtReflect (Mtx *m, LookAt *l, float xEye, float yEye, float zEye, 24 | float xAt, float yAt, float zAt, 25 | float xUp, float yUp, float zUp); 26 | #endif 27 | -------------------------------------------------------------------------------- /include/PR/libaudio.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_LIBAUDIO_H_ 2 | #define _ULTRA64_LIBAUDIO_H_ 3 | 4 | #include "abi.h" 5 | 6 | typedef struct 7 | { 8 | u8 *offset; 9 | s32 len; 10 | } ALSeqData; 11 | 12 | typedef struct 13 | { 14 | s16 revision; 15 | s16 seqCount; 16 | ALSeqData seqArray[1]; 17 | } ALSeqFile; 18 | 19 | void alSeqFileNew(ALSeqFile *f, u8 *base); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/PR/libultra.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBULTRA_H 2 | #define _LIBULTRA_H 3 | 4 | #define TV_TYPE_NTSC 1 5 | #define TV_TYPE_PAL 0 6 | #define TV_TYPE_MPAL 2 7 | 8 | #define RESET_TYPE_COLD_RESET 0 9 | #define RESET_TYPE_NMI 1 10 | #define RESET_TYPE_BOOT_DISK 2 11 | 12 | extern u32 osTvType; 13 | extern u32 osRomBase; 14 | extern u32 osResetType; 15 | extern u32 osMemSize; 16 | extern u8 osAppNmiBuffer[64]; 17 | 18 | #endif /* _LIBULTRA_H */ 19 | -------------------------------------------------------------------------------- /include/PR/mbi.h: -------------------------------------------------------------------------------- 1 | #ifndef _MBI_H_ 2 | #define _MBI_H_ 3 | 4 | /************************************************************************** 5 | * * 6 | * Copyright (C) 1994, Silicon Graphics, Inc. * 7 | * * 8 | * These coded instructions, statements, and computer programs contain * 9 | * unpublished proprietary information of Silicon Graphics, Inc., and * 10 | * are protected by Federal copyright law. They may not be disclosed * 11 | * to third parties or copied or duplicated in any form, in whole or * 12 | * in part, without the prior written consent of Silicon Graphics, Inc. * 13 | * * 14 | **************************************************************************/ 15 | 16 | /************************************************************************** 17 | * 18 | * $Revision: 1.136 $ 19 | * $Date: 1999/01/05 13:04:00 $ 20 | * $Source: /hosts/gate3/exdisk2/cvs/N64OS/Master/cvsmdev2/PR/include/mbi.h,v $ 21 | * 22 | **************************************************************************/ 23 | 24 | /* 25 | * Header file for the Media Binary Interface 26 | * 27 | * NOTE: This file is included by the RSP microcode, so any C-specific 28 | * constructs must be bracketed by #ifdef _LANGUAGE_C 29 | * 30 | */ 31 | 32 | 33 | /* 34 | * the SHIFT macros are used to build display list commands, inserting 35 | * bit-fields into a 32-bit word. They take a value, a shift amount, 36 | * and a width. 37 | * 38 | * For the left shift, the lower bits of the value are masked, 39 | * then shifted left. 40 | * 41 | * For the right shift, the value is shifted right, then the lower bits 42 | * are masked. 43 | * 44 | * (NOTE: _SHIFTL(v, 0, 32) won't work, just use an assignment) 45 | * 46 | */ 47 | #define _SHIFTL(v, s, w) \ 48 | ((unsigned int) (((unsigned int)(v) & ((0x01 << (w)) - 1)) << (s))) 49 | #define _SHIFTR(v, s, w) \ 50 | ((unsigned int)(((unsigned int)(v) >> (s)) & ((0x01 << (w)) - 1))) 51 | 52 | #define _SHIFT _SHIFTL /* old, for compatibility only */ 53 | 54 | #define G_ON (1) 55 | #define G_OFF (0) 56 | 57 | /************************************************************************** 58 | * 59 | * Graphics Binary Interface 60 | * 61 | **************************************************************************/ 62 | 63 | #ifdef F3D_OLD 64 | #include 65 | #else 66 | #include 67 | #endif 68 | 69 | /************************************************************************** 70 | * 71 | * Audio Binary Interface 72 | * 73 | **************************************************************************/ 74 | 75 | #include 76 | 77 | /************************************************************************** 78 | * 79 | * Task list 80 | * 81 | **************************************************************************/ 82 | 83 | #define M_GFXTASK 1 84 | #define M_AUDTASK 2 85 | #define M_VIDTASK 3 86 | #define M_HVQTASK 6 87 | #define M_HVQMTASK 7 88 | 89 | /************************************************************************** 90 | * 91 | * Segment macros and definitions 92 | * 93 | **************************************************************************/ 94 | 95 | #define NUM_SEGMENTS (16) 96 | #define SEGMENT_OFFSET(a) ((unsigned int)(a) & 0x00ffffff) 97 | #define SEGMENT_NUMBER(a) (((unsigned int)(a) << 4) >> 28) 98 | #define SEGMENT_ADDR(num, off) (((num) << 24) + (off)) 99 | 100 | #ifndef NULL 101 | #define NULL 0 102 | #endif 103 | 104 | #endif /* !_MBI_H_ */ 105 | -------------------------------------------------------------------------------- /include/PR/os_ai.h: -------------------------------------------------------------------------------- 1 | 2 | /*==================================================================== 3 | * os_ai.h 4 | * 5 | * Copyright 1995, Silicon Graphics, Inc. 6 | * All Rights Reserved. 7 | * 8 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 | * Inc.; the contents of this file may not be disclosed to third 10 | * parties, copied or duplicated in any form, in whole or in part, 11 | * without the prior written permission of Silicon Graphics, Inc. 12 | * 13 | * RESTRICTED RIGHTS LEGEND: 14 | * Use, duplication or disclosure by the Government is subject to 15 | * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 | * in Technical Data and Computer Software clause at DFARS 17 | * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 | * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 | * Copyright Laws of the United States. 20 | *====================================================================*/ 21 | 22 | /*---------------------------------------------------------------------* 23 | Copyright (C) 1998 Nintendo. (Originated by SGI) 24 | 25 | $RCSfile: os_ai.h,v $ 26 | $Revision: 1.1 $ 27 | $Date: 1998/10/09 08:01:04 $ 28 | *---------------------------------------------------------------------*/ 29 | 30 | #ifndef _OS_AI_H_ 31 | #define _OS_AI_H_ 32 | 33 | #ifdef _LANGUAGE_C_PLUS_PLUS 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | 39 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 40 | 41 | /************************************************************************** 42 | * 43 | * Type definitions 44 | * 45 | */ 46 | 47 | 48 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 49 | 50 | /************************************************************************** 51 | * 52 | * Global definitions 53 | * 54 | */ 55 | 56 | 57 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 58 | 59 | /************************************************************************** 60 | * 61 | * Macro definitions 62 | * 63 | */ 64 | 65 | 66 | /************************************************************************** 67 | * 68 | * Extern variables 69 | * 70 | */ 71 | 72 | 73 | /************************************************************************** 74 | * 75 | * Function prototypes 76 | * 77 | */ 78 | 79 | /* Audio interface (Ai) */ 80 | extern u32 osAiGetStatus(void); 81 | extern u32 osAiGetLength(void); 82 | extern s32 osAiSetFrequency(u32); 83 | extern s32 osAiSetNextBuffer(void *, u32); 84 | 85 | 86 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 87 | 88 | #ifdef _LANGUAGE_C_PLUS_PLUS 89 | } 90 | #endif 91 | 92 | #endif /* !_OS_AI_H_ */ 93 | -------------------------------------------------------------------------------- /include/PR/os_cache.h: -------------------------------------------------------------------------------- 1 | 2 | /*==================================================================== 3 | * os_cache.h 4 | * 5 | * Copyright 1995, Silicon Graphics, Inc. 6 | * All Rights Reserved. 7 | * 8 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 | * Inc.; the contents of this file may not be disclosed to third 10 | * parties, copied or duplicated in any form, in whole or in part, 11 | * without the prior written permission of Silicon Graphics, Inc. 12 | * 13 | * RESTRICTED RIGHTS LEGEND: 14 | * Use, duplication or disclosure by the Government is subject to 15 | * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 | * in Technical Data and Computer Software clause at DFARS 17 | * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 | * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 | * Copyright Laws of the United States. 20 | *====================================================================*/ 21 | 22 | /*---------------------------------------------------------------------* 23 | Copyright (C) 1998 Nintendo. (Originated by SGI) 24 | 25 | $RCSfile: os_cache.h,v $ 26 | $Revision: 1.1 $ 27 | $Date: 1998/10/09 08:01:04 $ 28 | *---------------------------------------------------------------------*/ 29 | 30 | #ifndef _OS_CACHE_H_ 31 | #define _OS_CACHE_H_ 32 | 33 | #ifdef _LANGUAGE_C_PLUS_PLUS 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | 39 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 40 | 41 | /************************************************************************** 42 | * 43 | * Type definitions 44 | * 45 | */ 46 | 47 | 48 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 49 | 50 | /************************************************************************** 51 | * 52 | * Global definitions 53 | * 54 | */ 55 | 56 | 57 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 58 | 59 | /************************************************************************** 60 | * 61 | * Macro definitions 62 | * 63 | */ 64 | 65 | #define OS_DCACHE_ROUNDUP_ADDR(x) (void *)(((((u32)(x)+0xf)/0x10)*0x10)) 66 | #define OS_DCACHE_ROUNDUP_SIZE(x) (u32)(((((u32)(x)+0xf)/0x10)*0x10)) 67 | 68 | 69 | /************************************************************************** 70 | * 71 | * Extern variables 72 | * 73 | */ 74 | 75 | 76 | /************************************************************************** 77 | * 78 | * Function prototypes 79 | * 80 | */ 81 | 82 | /* Cache operations and macros */ 83 | 84 | extern void osInvalDCache(void *, s32); 85 | extern void osInvalICache(void *, s32); 86 | extern void osWritebackDCache(void *, s32); 87 | extern void osWritebackDCacheAll(void); 88 | 89 | 90 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 91 | 92 | #ifdef _LANGUAGE_C_PLUS_PLUS 93 | } 94 | #endif 95 | 96 | #endif /* !_OS_CACHE_H_ */ 97 | -------------------------------------------------------------------------------- /include/PR/os_cont.h: -------------------------------------------------------------------------------- 1 | 2 | /*==================================================================== 3 | * os_cont.h 4 | * 5 | * Copyright 1995, Silicon Graphics, Inc. 6 | * All Rights Reserved. 7 | * 8 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 | * Inc.; the contents of this file may not be disclosed to third 10 | * parties, copied or duplicated in any form, in whole or in part, 11 | * without the prior written permission of Silicon Graphics, Inc. 12 | * 13 | * RESTRICTED RIGHTS LEGEND: 14 | * Use, duplication or disclosure by the Government is subject to 15 | * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 | * in Technical Data and Computer Software clause at DFARS 17 | * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 | * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 | * Copyright Laws of the United States. 20 | *====================================================================*/ 21 | 22 | /*---------------------------------------------------------------------* 23 | Copyright (C) 1998 Nintendo. (Originated by SGI) 24 | 25 | $RCSfile: os_cont.h,v $ 26 | $Revision: 1.1 $ 27 | $Date: 1998/10/09 08:01:05 $ 28 | *---------------------------------------------------------------------*/ 29 | 30 | #ifndef _OS_CONT_H_ 31 | #define _OS_CONT_H_ 32 | 33 | #ifdef _LANGUAGE_C_PLUS_PLUS 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | #include "os_message.h" 39 | 40 | 41 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 42 | 43 | /************************************************************************** 44 | * 45 | * Type definitions 46 | * 47 | */ 48 | 49 | /* 50 | * Structure for controllers 51 | */ 52 | 53 | typedef struct { 54 | u16 type; /* Controller Type */ 55 | u8 status; /* Controller status */ 56 | u8 errno; 57 | }OSContStatus; 58 | 59 | typedef struct { 60 | u16 button; 61 | s8 stick_x; /* -80 <= stick_x <= 80 */ 62 | s8 stick_y; /* -80 <= stick_y <= 80 */ 63 | u8 errno; 64 | } OSContPad; 65 | 66 | typedef struct { 67 | void *address; /* Ram pad Address: 11 bits */ 68 | u8 databuffer[32]; /* address of the data buffer */ 69 | u8 addressCrc; /* CRC code for address */ 70 | u8 dataCrc; /* CRC code for data */ 71 | u8 errno; 72 | } OSContRamIo; 73 | 74 | 75 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 76 | 77 | /************************************************************************** 78 | * 79 | * Global definitions 80 | * 81 | */ 82 | 83 | /* 84 | * Controllers number 85 | */ 86 | 87 | #ifndef _HW_VERSION_1 88 | #define MAXCONTROLLERS 4 89 | #else 90 | #define MAXCONTROLLERS 6 91 | #endif 92 | 93 | /* controller errors */ 94 | #define CONT_NO_RESPONSE_ERROR 0x8 95 | #define CONT_OVERRUN_ERROR 0x4 96 | #ifdef _HW_VERSION_1 97 | #define CONT_FRAME_ERROR 0x2 98 | #define CONT_COLLISION_ERROR 0x1 99 | #endif 100 | 101 | /* Controller type */ 102 | 103 | #define CONT_ABSOLUTE 0x0001 104 | #define CONT_RELATIVE 0x0002 105 | #define CONT_JOYPORT 0x0004 106 | #define CONT_EEPROM 0x8000 107 | #define CONT_EEP16K 0x4000 108 | #define CONT_TYPE_MASK 0x1f07 109 | #define CONT_TYPE_NORMAL 0x0005 110 | #define CONT_TYPE_MOUSE 0x0002 111 | #define CONT_TYPE_VOICE 0x0100 112 | 113 | /* Controller status */ 114 | 115 | #define CONT_CARD_ON 0x01 116 | #define CONT_CARD_PULL 0x02 117 | #define CONT_ADDR_CRC_ER 0x04 118 | #define CONT_EEPROM_BUSY 0x80 119 | 120 | /* Buttons */ 121 | 122 | #define CONT_A 0x8000 123 | #define CONT_B 0x4000 124 | #define CONT_G 0x2000 125 | #define CONT_START 0x1000 126 | #define CONT_UP 0x0800 127 | #define CONT_DOWN 0x0400 128 | #define CONT_LEFT 0x0200 129 | #define CONT_RIGHT 0x0100 130 | #define CONT_L 0x0020 131 | #define CONT_R 0x0010 132 | #define CONT_E 0x0008 133 | #define CONT_D 0x0004 134 | #define CONT_C 0x0002 135 | #define CONT_F 0x0001 136 | 137 | /* Nintendo's official button names */ 138 | 139 | #define A_BUTTON CONT_A 140 | #define B_BUTTON CONT_B 141 | #define L_TRIG CONT_L 142 | #define R_TRIG CONT_R 143 | #define Z_TRIG CONT_G 144 | #define START_BUTTON CONT_START 145 | #define U_JPAD CONT_UP 146 | #define L_JPAD CONT_LEFT 147 | #define R_JPAD CONT_RIGHT 148 | #define D_JPAD CONT_DOWN 149 | #define U_CBUTTONS CONT_E 150 | #define L_CBUTTONS CONT_C 151 | #define R_CBUTTONS CONT_F 152 | #define D_CBUTTONS CONT_D 153 | 154 | /* Controller error number */ 155 | 156 | #define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */ 157 | #define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */ 158 | #define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */ 159 | #define CONT_ERR_DEVICE PFS_ERR_DEVICE /* 11 */ 160 | #define CONT_ERR_NOT_READY 12 161 | #define CONT_ERR_VOICE_MEMORY 13 162 | #define CONT_ERR_VOICE_WORD 14 163 | #define CONT_ERR_VOICE_NO_RESPONSE 15 164 | 165 | 166 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 167 | 168 | /************************************************************************** 169 | * 170 | * Macro definitions 171 | * 172 | */ 173 | 174 | 175 | /************************************************************************** 176 | * 177 | * Extern variables 178 | * 179 | */ 180 | 181 | 182 | /************************************************************************** 183 | * 184 | * Function prototypes 185 | * 186 | */ 187 | 188 | /* Controller interface */ 189 | 190 | extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *); 191 | extern s32 osContReset(OSMesgQueue *, OSContStatus *); 192 | extern s32 osContStartQuery(OSMesgQueue *); 193 | extern s32 osContStartReadData(OSMesgQueue *); 194 | #ifndef _HW_VERSION_1 195 | extern s32 osContSetCh(u8); 196 | #endif 197 | extern void osContGetQuery(OSContStatus *); 198 | extern void osContGetReadData(OSContPad *); 199 | 200 | 201 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 202 | 203 | #ifdef _LANGUAGE_C_PLUS_PLUS 204 | } 205 | #endif 206 | 207 | #endif /* !_OS_CONT_H_ */ 208 | -------------------------------------------------------------------------------- /include/PR/os_eeprom.h: -------------------------------------------------------------------------------- 1 | 2 | /*==================================================================== 3 | * os_eeprom.h 4 | * 5 | * Copyright 1995, Silicon Graphics, Inc. 6 | * All Rights Reserved. 7 | * 8 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 | * Inc.; the contents of this file may not be disclosed to third 10 | * parties, copied or duplicated in any form, in whole or in part, 11 | * without the prior written permission of Silicon Graphics, Inc. 12 | * 13 | * RESTRICTED RIGHTS LEGEND: 14 | * Use, duplication or disclosure by the Government is subject to 15 | * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 | * in Technical Data and Computer Software clause at DFARS 17 | * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 | * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 | * Copyright Laws of the United States. 20 | *====================================================================*/ 21 | 22 | /*---------------------------------------------------------------------* 23 | Copyright (C) 1998 Nintendo. (Originated by SGI) 24 | 25 | $RCSfile: os_eeprom.h,v $ 26 | $Revision: 1.1 $ 27 | $Date: 1998/10/09 08:01:06 $ 28 | *---------------------------------------------------------------------*/ 29 | 30 | #ifndef _OS_EEPROM_H_ 31 | #define _OS_EEPROM_H_ 32 | 33 | #ifdef _LANGUAGE_C_PLUS_PLUS 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | #include "os_message.h" 39 | 40 | 41 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 42 | 43 | /************************************************************************** 44 | * 45 | * Type definitions 46 | * 47 | */ 48 | 49 | 50 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 51 | 52 | /************************************************************************** 53 | * 54 | * Global definitions 55 | * 56 | */ 57 | 58 | /* EEPROM TYPE */ 59 | 60 | #define EEPROM_TYPE_4K 0x01 61 | #define EEPROM_TYPE_16K 0x02 62 | 63 | /* definition for EEPROM */ 64 | 65 | #define EEPROM_MAXBLOCKS 64 66 | #define EEP16K_MAXBLOCKS 256 67 | #define EEPROM_BLOCK_SIZE 8 68 | 69 | 70 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 71 | 72 | /************************************************************************** 73 | * 74 | * Macro definitions 75 | * 76 | */ 77 | 78 | 79 | /************************************************************************** 80 | * 81 | * Extern variables 82 | * 83 | */ 84 | 85 | 86 | /************************************************************************** 87 | * 88 | * Function prototypes 89 | * 90 | */ 91 | 92 | /* EEPROM interface */ 93 | 94 | extern s32 osEepromProbe(OSMesgQueue *); 95 | extern s32 osEepromRead(OSMesgQueue *, u8, u8 *); 96 | extern s32 osEepromWrite(OSMesgQueue *, u8, u8 *); 97 | extern s32 osEepromLongRead(OSMesgQueue *, u8, u8 *, int); 98 | extern s32 osEepromLongWrite(OSMesgQueue *, u8, u8 *, int); 99 | 100 | 101 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 102 | 103 | #ifdef _LANGUAGE_C_PLUS_PLUS 104 | } 105 | #endif 106 | 107 | #endif /* !_OS_EEPROM_H_ */ 108 | -------------------------------------------------------------------------------- /include/PR/os_exception.h: -------------------------------------------------------------------------------- 1 | 2 | /*==================================================================== 3 | * os_exception.h 4 | * 5 | * Copyright 1995, Silicon Graphics, Inc. 6 | * All Rights Reserved. 7 | * 8 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 | * Inc.; the contents of this file may not be disclosed to third 10 | * parties, copied or duplicated in any form, in whole or in part, 11 | * without the prior written permission of Silicon Graphics, Inc. 12 | * 13 | * RESTRICTED RIGHTS LEGEND: 14 | * Use, duplication or disclosure by the Government is subject to 15 | * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 | * in Technical Data and Computer Software clause at DFARS 17 | * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 | * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 | * Copyright Laws of the United States. 20 | *====================================================================*/ 21 | 22 | /*---------------------------------------------------------------------* 23 | Copyright (C) 1998 Nintendo. (Originated by SGI) 24 | 25 | $RCSfile: os_exception.h,v $ 26 | $Revision: 1.1 $ 27 | $Date: 1998/10/09 08:01:07 $ 28 | *---------------------------------------------------------------------*/ 29 | 30 | #ifndef _OS_EXCEPTION_H_ 31 | #define _OS_EXCEPTION_H_ 32 | 33 | #ifdef _LANGUAGE_C_PLUS_PLUS 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | 39 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 40 | 41 | /************************************************************************** 42 | * 43 | * Type definitions 44 | * 45 | */ 46 | 47 | typedef u32 OSIntMask; 48 | typedef u32 OSHWIntr; 49 | 50 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 51 | 52 | /************************************************************************** 53 | * 54 | * Global definitions 55 | * 56 | */ 57 | 58 | /* Flags for debugging purpose */ 59 | 60 | #define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */ 61 | #define OS_FLAG_FAULT 2 /* CPU fault has occurred */ 62 | 63 | /* Interrupt masks */ 64 | 65 | #define OS_IM_NONE 0x00000001 66 | #define OS_IM_SW1 0x00000501 67 | #define OS_IM_SW2 0x00000601 68 | #define OS_IM_CART 0x00000c01 69 | #define OS_IM_PRENMI 0x00001401 70 | #define OS_IM_RDBWRITE 0x00002401 71 | #define OS_IM_RDBREAD 0x00004401 72 | #define OS_IM_COUNTER 0x00008401 73 | #define OS_IM_CPU 0x0000ff01 74 | #define OS_IM_SP 0x00010401 75 | #define OS_IM_SI 0x00020401 76 | #define OS_IM_AI 0x00040401 77 | #define OS_IM_VI 0x00080401 78 | #define OS_IM_PI 0x00100401 79 | #define OS_IM_DP 0x00200401 80 | #define OS_IM_ALL 0x003fff01 81 | #define RCP_IMASK 0x003f0000 82 | #define RCP_IMASKSHIFT 16 83 | 84 | 85 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 86 | 87 | /************************************************************************** 88 | * 89 | * Macro definitions 90 | * 91 | */ 92 | 93 | 94 | /************************************************************************** 95 | * 96 | * Extern variables 97 | * 98 | */ 99 | 100 | 101 | /************************************************************************** 102 | * 103 | * Function prototypes 104 | * 105 | */ 106 | 107 | /* Interrupt operations */ 108 | 109 | extern OSIntMask osGetIntMask(void); 110 | extern OSIntMask osSetIntMask(OSIntMask); 111 | 112 | 113 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 114 | 115 | #ifdef _LANGUAGE_C_PLUS_PLUS 116 | } 117 | #endif 118 | 119 | #endif /* !_OS_EXCEPTION_H_ */ 120 | -------------------------------------------------------------------------------- /include/PR/os_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_OS_INTERNAL_H_ 2 | #define _ULTRA64_OS_INTERNAL_H_ 3 | 4 | /* Internal functions used by the operating system */ 5 | /* Do not include this header in application code */ 6 | 7 | /* Variables */ 8 | 9 | //extern u64 osClockRate; 10 | 11 | /* Functions */ 12 | 13 | /*u32 __osProbeTLB(void *); 14 | u32 __osDisableInt(void); 15 | void __osRestoreInt(u32);*/ 16 | OSThread *__osGetCurrFaultedThread(void); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/PR/os_libc.h: -------------------------------------------------------------------------------- 1 | #ifndef _OS_LIBC_H_ 2 | #define _OS_LIBC_H_ 3 | 4 | #include "ultratypes.h" 5 | 6 | // Old deprecated functions from strings.h, replaced by memcpy/memset. 7 | extern void bcopy(const void *, void *, size_t); 8 | extern void bzero(void *, size_t); 9 | extern int bcmp(const void *, const void *, int); 10 | 11 | /* Printf */ 12 | 13 | extern int sprintf(char *s, const char *fmt, ...); 14 | extern void osSyncPrintf(const char *fmt, ...); 15 | 16 | #endif /* !_OS_LIBC_H_ */ 17 | -------------------------------------------------------------------------------- /include/PR/os_message.h: -------------------------------------------------------------------------------- 1 | 2 | /*==================================================================== 3 | * os_message.h 4 | * 5 | * Copyright 1995, Silicon Graphics, Inc. 6 | * All Rights Reserved. 7 | * 8 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 | * Inc.; the contents of this file may not be disclosed to third 10 | * parties, copied or duplicated in any form, in whole or in part, 11 | * without the prior written permission of Silicon Graphics, Inc. 12 | * 13 | * RESTRICTED RIGHTS LEGEND: 14 | * Use, duplication or disclosure by the Government is subject to 15 | * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 | * in Technical Data and Computer Software clause at DFARS 17 | * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 | * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 | * Copyright Laws of the United States. 20 | *====================================================================*/ 21 | 22 | /*---------------------------------------------------------------------* 23 | Copyright (C) 1998 Nintendo. (Originated by SGI) 24 | 25 | $RCSfile: os_message.h,v $ 26 | $Revision: 1.1 $ 27 | $Date: 1998/10/09 08:01:15 $ 28 | *---------------------------------------------------------------------*/ 29 | 30 | #ifndef _OS_MESSAGE_H_ 31 | #define _OS_MESSAGE_H_ 32 | 33 | #ifdef _LANGUAGE_C_PLUS_PLUS 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | 39 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 40 | 41 | /************************************************************************** 42 | * 43 | * Type definitions 44 | * 45 | */ 46 | 47 | typedef u32 OSEvent; 48 | 49 | /* 50 | * Structure for message 51 | */ 52 | typedef void * OSMesg; 53 | 54 | /* 55 | * Structure for message queue 56 | */ 57 | typedef struct OSMesgQueue_s { 58 | OSThread *mtqueue; /* Queue to store threads blocked 59 | on empty mailboxes (receive) */ 60 | OSThread *fullqueue; /* Queue to store threads blocked 61 | on full mailboxes (send) */ 62 | s32 validCount; /* Contains number of valid message */ 63 | s32 first; /* Points to first valid message */ 64 | s32 msgCount; /* Contains total # of messages */ 65 | OSMesg *msg; /* Points to message buffer array */ 66 | } OSMesgQueue; 67 | 68 | 69 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 70 | 71 | /************************************************************************** 72 | * 73 | * Global definitions 74 | * 75 | */ 76 | 77 | /* Events */ 78 | #ifdef _FINALROM 79 | #define OS_NUM_EVENTS 15 80 | #else 81 | #define OS_NUM_EVENTS 23 82 | #endif 83 | 84 | #define OS_EVENT_SW1 0 /* CPU SW1 interrupt */ 85 | #define OS_EVENT_SW2 1 /* CPU SW2 interrupt */ 86 | #define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */ 87 | #define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */ 88 | #define OS_EVENT_SP 4 /* SP task done interrupt */ 89 | #define OS_EVENT_SI 5 /* SI (controller) interrupt */ 90 | #define OS_EVENT_AI 6 /* AI interrupt */ 91 | #define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */ 92 | #define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */ 93 | #define OS_EVENT_DP 9 /* DP full sync interrupt */ 94 | #define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */ 95 | #define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */ 96 | #define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */ 97 | #define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */ 98 | #define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */ 99 | #ifndef _FINALROM 100 | #define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */ 101 | #define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */ 102 | #define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */ 103 | #define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */ 104 | #define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */ 105 | #define OS_EVENT_RDB_DBG_DONE 20 106 | #define OS_EVENT_RDB_FLUSH_PROF 21 107 | #define OS_EVENT_RDB_ACK_PROF 22 108 | #endif 109 | 110 | /* Flags to turn blocking on/off when sending/receiving message */ 111 | 112 | #define OS_MESG_NOBLOCK 0 113 | #define OS_MESG_BLOCK 1 114 | 115 | 116 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 117 | 118 | /************************************************************************** 119 | * 120 | * Macro definitions 121 | * 122 | */ 123 | 124 | /* Get count of valid messages in queue */ 125 | #define MQ_GET_COUNT(mq) ((mq)->validCount) 126 | 127 | /* Figure out if message queue is empty or full */ 128 | #define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0) 129 | #define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount) 130 | 131 | 132 | /************************************************************************** 133 | * 134 | * Extern variables 135 | * 136 | */ 137 | 138 | 139 | /************************************************************************** 140 | * 141 | * Function prototypes 142 | * 143 | */ 144 | 145 | /* Message operations */ 146 | 147 | extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32); 148 | extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32); 149 | extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32); 150 | extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32); 151 | 152 | /* Event operations */ 153 | 154 | extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg); 155 | 156 | 157 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 158 | 159 | #ifdef _LANGUAGE_C_PLUS_PLUS 160 | } 161 | #endif 162 | 163 | #endif /* !_OS_MESSAGE_H_ */ 164 | -------------------------------------------------------------------------------- /include/PR/os_misc.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_OS_MISC_H_ 2 | #define _ULTRA64_OS_MISC_H_ 3 | 4 | /* Miscellaneous OS functions */ 5 | 6 | void osInitialize(void); 7 | u32 osGetCount(void); 8 | 9 | u32 osVirtualToPhysical(void *); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/PR/os_pi.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_PI_H_ 2 | #define _ULTRA64_PI_H_ 3 | 4 | /* Ultra64 Parallel Interface */ 5 | 6 | /* Types */ 7 | 8 | typedef struct 9 | { 10 | u32 errStatus; 11 | void *dramAddr; 12 | void *C2Addr; 13 | u32 sectorSize; 14 | u32 C1ErrNum; 15 | u32 C1ErrSector[4]; 16 | } __OSBlockInfo; 17 | 18 | typedef struct 19 | { 20 | u32 cmdType; 21 | u16 transferMode; 22 | u16 blockNum; 23 | s32 sectorNum; 24 | u32 devAddr; 25 | u32 bmCtlShadow; 26 | u32 seqCtlShadow; 27 | __OSBlockInfo block[2]; 28 | } __OSTranxInfo; 29 | 30 | typedef struct OSPiHandle_s 31 | { 32 | struct OSPiHandle_s *next; 33 | u8 type; 34 | u8 latency; 35 | u8 pageSize; 36 | u8 relDuration; 37 | u8 pulse; 38 | u8 domain; 39 | u32 baseAddress; 40 | u32 speed; 41 | __OSTranxInfo transferInfo; 42 | } OSPiHandle; 43 | 44 | typedef struct 45 | { 46 | u8 type; 47 | u32 address; 48 | } OSPiInfo; 49 | 50 | typedef struct 51 | { 52 | u16 type; 53 | u8 pri; 54 | u8 status; 55 | OSMesgQueue *retQueue; 56 | } OSIoMesgHdr; 57 | 58 | typedef struct 59 | { 60 | /*0x00*/ OSIoMesgHdr hdr; 61 | /*0x08*/ void *dramAddr; 62 | /*0x0C*/ u32 devAddr; 63 | /*0x10*/ u32 size; 64 | //OSPiHandle *piHandle; //from the official definition 65 | } OSIoMesg; 66 | 67 | /* Definitions */ 68 | 69 | #define OS_READ 0 // device -> RDRAM 70 | #define OS_WRITE 1 // device <- RDRAM 71 | 72 | #define OS_MESG_PRI_NORMAL 0 73 | #define OS_MESG_PRI_HIGH 1 74 | 75 | /* Functions */ 76 | 77 | s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, 78 | u32 devAddr, void *vAddr, u32 nbytes, OSMesgQueue *mq); 79 | void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, 80 | s32 cmdMsgCnt); 81 | OSMesgQueue *osPiGetCmdQueue(void); 82 | s32 osPiWriteIo(u32 devAddr, u32 data); 83 | s32 osPiReadIo(u32 devAddr, u32 *data); 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /include/PR/os_rdp.h: -------------------------------------------------------------------------------- 1 | 2 | /*==================================================================== 3 | * os_rdp.h 4 | * 5 | * Copyright 1995, Silicon Graphics, Inc. 6 | * All Rights Reserved. 7 | * 8 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 | * Inc.; the contents of this file may not be disclosed to third 10 | * parties, copied or duplicated in any form, in whole or in part, 11 | * without the prior written permission of Silicon Graphics, Inc. 12 | * 13 | * RESTRICTED RIGHTS LEGEND: 14 | * Use, duplication or disclosure by the Government is subject to 15 | * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 | * in Technical Data and Computer Software clause at DFARS 17 | * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 | * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 | * Copyright Laws of the United States. 20 | *====================================================================*/ 21 | 22 | /*---------------------------------------------------------------------* 23 | Copyright (C) 1998 Nintendo. (Originated by SGI) 24 | 25 | $RCSfile: os_rdp.h,v $ 26 | $Revision: 1.1 $ 27 | $Date: 1998/10/09 08:01:16 $ 28 | *---------------------------------------------------------------------*/ 29 | 30 | #ifndef _OS_RDP_H_ 31 | #define _OS_RDP_H_ 32 | 33 | #ifdef _LANGUAGE_C_PLUS_PLUS 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | 39 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 40 | 41 | /************************************************************************** 42 | * 43 | * Type definitions 44 | * 45 | */ 46 | 47 | 48 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 49 | 50 | /************************************************************************** 51 | * 52 | * Global definitions 53 | * 54 | */ 55 | 56 | 57 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 58 | 59 | /************************************************************************** 60 | * 61 | * Macro definitions 62 | * 63 | */ 64 | 65 | 66 | /************************************************************************** 67 | * 68 | * Extern variables 69 | * 70 | */ 71 | 72 | 73 | /************************************************************************** 74 | * 75 | * Function prototypes 76 | * 77 | */ 78 | 79 | /* Display processor interface (Dp) */ 80 | extern u32 osDpGetStatus(void); 81 | extern void osDpSetStatus(u32); 82 | extern void osDpGetCounters(u32 *); 83 | extern s32 osDpSetNextBuffer(void *, u64); 84 | 85 | 86 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 87 | 88 | #ifdef _LANGUAGE_C_PLUS_PLUS 89 | } 90 | #endif 91 | 92 | #endif /* !_OS_RDP_H_ */ 93 | -------------------------------------------------------------------------------- /include/PR/os_thread.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_THREAD_H_ 2 | #define _ULTRA64_THREAD_H_ 3 | 4 | /* Recommended priorities for system threads */ 5 | #define OS_PRIORITY_MAX 255 6 | #define OS_PRIORITY_VIMGR 254 7 | #define OS_PRIORITY_RMON 250 8 | #define OS_PRIORITY_RMONSPIN 200 9 | #define OS_PRIORITY_PIMGR 150 10 | #define OS_PRIORITY_SIMGR 140 11 | #define OS_PRIORITY_APPMAX 127 12 | #define OS_PRIORITY_IDLE 0 13 | 14 | #define OS_STATE_STOPPED 1 15 | #define OS_STATE_RUNNABLE 2 16 | #define OS_STATE_RUNNING 4 17 | #define OS_STATE_WAITING 8 18 | 19 | /* Types */ 20 | 21 | typedef s32 OSPri; 22 | typedef s32 OSId; 23 | 24 | typedef union 25 | { 26 | struct {f32 f_odd; f32 f_even;} f; 27 | } __OSfp; 28 | 29 | typedef struct 30 | { 31 | /* registers */ 32 | /*0x20*/ u64 at, v0, v1, a0, a1, a2, a3; 33 | /*0x58*/ u64 t0, t1, t2, t3, t4, t5, t6, t7; 34 | /*0x98*/ u64 s0, s1, s2, s3, s4, s5, s6, s7; 35 | /*0xD8*/ u64 t8, t9, gp, sp, s8, ra; 36 | /*0x108*/ u64 lo, hi; 37 | /*0x118*/ u32 sr, pc, cause, badvaddr, rcp; 38 | /*0x12C*/ u32 fpcsr; 39 | __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; 40 | __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; 41 | } __OSThreadContext; 42 | 43 | typedef struct 44 | { 45 | u32 flag; 46 | u32 count; 47 | u64 time; 48 | } __OSThreadprofile_s; 49 | 50 | typedef struct OSThread_s 51 | { 52 | /*0x00*/ struct OSThread_s *next; 53 | /*0x04*/ OSPri priority; 54 | /*0x08*/ struct OSThread_s **queue; 55 | /*0x0C*/ struct OSThread_s *tlnext; 56 | /*0x10*/ u16 state; 57 | /*0x12*/ u16 flags; 58 | /*0x14*/ OSId id; 59 | /*0x18*/ int fp; 60 | /*0x1C*/ __OSThreadprofile_s *thprof; 61 | /*0x20*/ __OSThreadContext context; 62 | } OSThread; 63 | 64 | 65 | /* Functions */ 66 | 67 | void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *), 68 | void *arg, void *sp, OSPri pri); 69 | OSId osGetThreadId(OSThread *thread); 70 | OSPri osGetThreadPri(OSThread *thread); 71 | void osSetThreadPri(OSThread *thread, OSPri pri); 72 | void osStartThread(OSThread *thread); 73 | void osStopThread(OSThread *thread); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /include/PR/os_time.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_TIME_H_ 2 | #define _ULTRA64_TIME_H_ 3 | #include 4 | 5 | /* Types */ 6 | 7 | typedef struct OSTimer_str 8 | { 9 | struct OSTimer_str *next; 10 | struct OSTimer_str *prev; 11 | u64 interval; 12 | u64 remaining; 13 | OSMesgQueue *mq; 14 | OSMesg *msg; 15 | } OSTimer; 16 | 17 | typedef u64 OSTime; 18 | 19 | /* Functions */ 20 | 21 | OSTime osGetTime(void); 22 | void osSetTime(OSTime time); 23 | s32 osSetTimer(OSTimer *, OSTime, OSTime, OSMesgQueue *, OSMesg); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /include/PR/os_tlb.h: -------------------------------------------------------------------------------- 1 | 2 | /*==================================================================== 3 | * os_tlb.h 4 | * 5 | * Copyright 1995, Silicon Graphics, Inc. 6 | * All Rights Reserved. 7 | * 8 | * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, 9 | * Inc.; the contents of this file may not be disclosed to third 10 | * parties, copied or duplicated in any form, in whole or in part, 11 | * without the prior written permission of Silicon Graphics, Inc. 12 | * 13 | * RESTRICTED RIGHTS LEGEND: 14 | * Use, duplication or disclosure by the Government is subject to 15 | * restrictions as set forth in subdivision (c)(1)(ii) of the Rights 16 | * in Technical Data and Computer Software clause at DFARS 17 | * 252.227-7013, and/or in similar or successor clauses in the FAR, 18 | * DOD or NASA FAR Supplement. Unpublished - rights reserved under the 19 | * Copyright Laws of the United States. 20 | *====================================================================*/ 21 | 22 | /*---------------------------------------------------------------------* 23 | Copyright (C) 1998 Nintendo. (Originated by SGI) 24 | 25 | $RCSfile: os_tlb.h,v $ 26 | $Revision: 1.1 $ 27 | $Date: 1998/10/09 08:01:20 $ 28 | *---------------------------------------------------------------------*/ 29 | 30 | #ifndef _OS_TLB_H_ 31 | #define _OS_TLB_H_ 32 | 33 | #ifdef _LANGUAGE_C_PLUS_PLUS 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | 39 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 40 | 41 | /************************************************************************** 42 | * 43 | * Type definitions 44 | * 45 | */ 46 | 47 | typedef u32 OSPageMask; 48 | 49 | 50 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 51 | 52 | /************************************************************************** 53 | * 54 | * Global definitions 55 | * 56 | */ 57 | 58 | /* 59 | * Page size argument for TLB routines 60 | */ 61 | #define OS_PM_4K 0x0000000 62 | #define OS_PM_16K 0x0006000 63 | #define OS_PM_64K 0x001e000 64 | #define OS_PM_256K 0x007e000 65 | #define OS_PM_1M 0x01fe000 66 | #define OS_PM_4M 0x07fe000 67 | #define OS_PM_16M 0x1ffe000 68 | 69 | 70 | #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) 71 | 72 | /************************************************************************** 73 | * 74 | * Macro definitions 75 | * 76 | */ 77 | 78 | 79 | /************************************************************************** 80 | * 81 | * Extern variables 82 | * 83 | */ 84 | 85 | 86 | /************************************************************************** 87 | * 88 | * Function prototypes 89 | * 90 | */ 91 | 92 | /* TLB management routines */ 93 | 94 | extern void osMapTLB(s32, OSPageMask, void *, u32, u32, s32); 95 | extern void osMapTLBRdb(void); 96 | extern void osUnmapTLB(s32); 97 | extern void osUnmapTLBAll(void); 98 | extern void osSetTLBASID(s32); 99 | 100 | 101 | #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ 102 | 103 | #ifdef _LANGUAGE_C_PLUS_PLUS 104 | } 105 | #endif 106 | 107 | #endif /* !_OS_TLB_H_ */ 108 | -------------------------------------------------------------------------------- /include/PR/os_vi.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_VI_H_ 2 | #define _ULTRA64_VI_H_ 3 | 4 | /* Ultra64 Video Interface */ 5 | 6 | 7 | /* Special Features */ 8 | #define OS_VI_GAMMA_ON 0x0001 9 | #define OS_VI_GAMMA_OFF 0x0002 10 | #define OS_VI_GAMMA_DITHER_ON 0x0004 11 | #define OS_VI_GAMMA_DITHER_OFF 0x0008 12 | #define OS_VI_DIVOT_ON 0x0010 13 | #define OS_VI_DIVOT_OFF 0x0020 14 | #define OS_VI_DITHER_FILTER_ON 0x0040 15 | #define OS_VI_DITHER_FILTER_OFF 0x0080 16 | 17 | #define OS_VI_GAMMA 0x08 18 | #define OS_VI_GAMMA_DITHER 0x04 19 | #define OS_VI_DIVOT 0x10 20 | #define OS_VI_DITHER_FILTER 0x10000 21 | #define OS_VI_UNK200 0x200 22 | #define OS_VI_UNK100 0x100 23 | 24 | 25 | /* Types */ 26 | 27 | typedef struct 28 | { 29 | u32 ctrl; 30 | u32 width; 31 | u32 burst; 32 | u32 vSync; 33 | u32 hSync; 34 | u32 leap; 35 | u32 hStart; 36 | u32 xScale; 37 | u32 vCurrent; 38 | } OSViCommonRegs; 39 | 40 | typedef struct 41 | { 42 | u32 origin; 43 | u32 yScale; 44 | u32 vStart; 45 | u32 vBurst; 46 | u32 vIntr; 47 | } OSViFieldRegs; 48 | 49 | typedef struct 50 | { 51 | u8 type; 52 | OSViCommonRegs comRegs; 53 | OSViFieldRegs fldRegs[2]; 54 | } OSViMode; 55 | 56 | typedef struct 57 | { 58 | /* 0x00 */ u16 unk00; //some kind of flags. swap buffer sets to 0x10 59 | /* 0x02 */ u16 retraceCount; 60 | /* 0x04 */ void* buffer; 61 | /* 0x08 */ OSViMode *unk08; 62 | /* 0x0c */ u32 features; 63 | /* 0x10 */ OSMesgQueue *mq; 64 | /* 0x14 */ OSMesg *msg; 65 | /* 0x18 */ u32 unk18; 66 | /* 0x1c */ u32 unk1c; 67 | /* 0x20 */ u32 unk20; 68 | /* 0x24 */ f32 unk24; 69 | /* 0x28 */ u16 unk28; 70 | /* 0x2c */ u32 unk2c; 71 | } OSViContext; 72 | 73 | void osCreateViManager(OSPri pri); 74 | void osViSetMode(OSViMode *mode); 75 | void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount); 76 | void osViBlack(u8 active); 77 | void osViSetSpecialFeatures(u32 func); 78 | void osViSwapBuffer(void *vaddr); 79 | 80 | 81 | #define OS_VI_NTSC_LPN1 0 /* NTSC */ 82 | #define OS_VI_NTSC_LPF1 1 83 | #define OS_VI_NTSC_LAN1 2 84 | #define OS_VI_NTSC_LAF1 3 85 | #define OS_VI_NTSC_LPN2 4 86 | #define OS_VI_NTSC_LPF2 5 87 | #define OS_VI_NTSC_LAN2 6 88 | #define OS_VI_NTSC_LAF2 7 89 | #define OS_VI_NTSC_HPN1 8 90 | #define OS_VI_NTSC_HPF1 9 91 | #define OS_VI_NTSC_HAN1 10 92 | #define OS_VI_NTSC_HAF1 11 93 | #define OS_VI_NTSC_HPN2 12 94 | #define OS_VI_NTSC_HPF2 13 95 | 96 | #define OS_VI_PAL_LPN1 14 /* PAL */ 97 | #define OS_VI_PAL_LPF1 15 98 | #define OS_VI_PAL_LAN1 16 99 | #define OS_VI_PAL_LAF1 17 100 | #define OS_VI_PAL_LPN2 18 101 | #define OS_VI_PAL_LPF2 19 102 | #define OS_VI_PAL_LAN2 20 103 | #define OS_VI_PAL_LAF2 21 104 | #define OS_VI_PAL_HPN1 22 105 | #define OS_VI_PAL_HPF1 23 106 | #define OS_VI_PAL_HAN1 24 107 | #define OS_VI_PAL_HAF1 25 108 | #define OS_VI_PAL_HPN2 26 109 | #define OS_VI_PAL_HPF2 27 110 | 111 | extern OSViMode osViModeTable[]; /* Global VI mode table */ 112 | 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /include/PR/sptask.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_SPTASK_H_ 2 | #define _ULTRA64_SPTASK_H_ 3 | 4 | /* Task Types */ 5 | #define M_GFXTASK 1 6 | #define M_AUDTASK 2 7 | #define M_VIDTASK 3 8 | #define M_HVQTASK 6 9 | #define M_HVQMTASK 7 10 | 11 | //gGfxSPTaskYieldBuffer has to be changed for this too 12 | #if (defined(F3DEX_GBI) || defined(F3DLP_GBI) || defined(F3DEX_GBI_2)) 13 | #define OS_YIELD_DATA_SIZE 0xc00 14 | #else 15 | #define OS_YIELD_DATA_SIZE 0x900 16 | #endif 17 | #define OS_YIELD_AUDIO_SIZE 0x400 18 | 19 | /* Flags */ 20 | #define M_TASK_FLAG0 1 21 | #define M_TASK_FLAG1 2 22 | 23 | /* SpStatus */ 24 | #define SPSTATUS_CLEAR_HALT 0x00000001 25 | #define SPSTATUS_SET_HALT 0x00000002 26 | #define SPSTATUS_CLEAR_BROKE 0x00000004 27 | #define SPSTATUS_CLEAR_INTR 0x00000008 28 | #define SPSTATUS_SET_INTR 0x00000010 29 | #define SPSTATUS_CLEAR_SSTEP 0x00000020 30 | #define SPSTATUS_SET_SSTEP 0x00000040 31 | #define SPSTATUS_CLEAR_INTR_ON_BREAK 0x00000080 32 | #define SPSTATUS_SET_INTR_ON_BREAK 0x00000100 33 | #define SPSTATUS_CLEAR_SIGNAL0 0x00000200 34 | #define SPSTATUS_SET_SIGNAL0 0x00000400 35 | #define SPSTATUS_CLEAR_SIGNAL1 0x00000800 36 | #define SPSTATUS_SET_SIGNAL1 0x00001000 37 | #define SPSTATUS_CLEAR_SIGNAL2 0x00002000 38 | #define SPSTATUS_SET_SIGNAL2 0x00004000 39 | #define SPSTATUS_CLEAR_SIGNAL3 0x00008000 40 | #define SPSTATUS_SET_SIGNAL3 0x00010000 41 | #define SPSTATUS_CLEAR_SIGNAL4 0x00020000 42 | #define SPSTATUS_SET_SIGNAL4 0x00040000 43 | #define SPSTATUS_CLEAR_SIGNAL5 0x00080000 44 | #define SPSTATUS_SET_SIGNAL5 0x00100000 45 | #define SPSTATUS_CLEAR_SIGNAL6 0x00200000 46 | #define SPSTATUS_SET_SIGNAL6 0x00800000 47 | #define SPSTATUS_CLEAR_SIGNAL7 0x01000000 48 | #define SPSTATUS_SET_SIGNAL7 0x02000000 49 | 50 | #define SPSTATUS_HALT 0x0001 51 | #define SPSTATUS_BROKE 0x0002 52 | #define SPSTATUS_DMA_BUSY 0x0004 53 | #define SPSTATUS_DMA_FULL 0x0008 54 | #define SPSTATUS_IO_FULL 0x0010 55 | #define SPSTATUS_SINGLE_STEP 0x0020 56 | #define SPSTATUS_INTERRUPT_ON_BREAK 0x0040 57 | #define SPSTATUS_SIGNAL0_SET 0x0080 58 | #define SPSTATUS_SIGNAL1_SET 0x0100 59 | #define SPSTATUS_SIGNAL2_SET 0x0200 60 | #define SPSTATUS_SIGNAL3_SET 0x0400 61 | #define SPSTATUS_SIGNAL4_SET 0x0800 62 | #define SPSTATUS_SIGNAL5_SET 0x1000 63 | #define SPSTATUS_SIGNAL6_SET 0x2000 64 | #define SPSTATUS_SIGNAL7_SET 0x4000 65 | 66 | /* Types */ 67 | /* Types */ 68 | 69 | typedef struct 70 | { 71 | /*0x00*/ u32 type; 72 | /*0x04*/ u32 flags; 73 | 74 | /*0x08*/ u64 *ucode_boot; 75 | /*0x0C*/ u32 ucode_boot_size; 76 | 77 | /*0x10*/ u64 *ucode; 78 | /*0x14*/ u32 ucode_size; 79 | 80 | /*0x18*/ u64 *ucode_data; 81 | /*0x1C*/ u32 ucode_data_size; 82 | 83 | /*0x20*/ u64 *dram_stack; 84 | /*0x24*/ u32 dram_stack_size; 85 | 86 | /*0x28*/ u64 *output_buff; 87 | /*0x2C*/ u64 *output_buff_size; 88 | 89 | /*0x30*/ u64 *data_ptr; 90 | /*0x34*/ u32 data_size; 91 | 92 | /*0x38*/ u64 *yield_data_ptr; 93 | /*0x3C*/ u32 yield_data_size; 94 | } OSTask_t; // size = 0x40 95 | 96 | typedef union { 97 | OSTask_t t; 98 | long long int force_structure_alignment; 99 | } OSTask; 100 | 101 | typedef u32 OSYieldResult; 102 | 103 | /* Functions */ 104 | 105 | #define osSpTaskStart(p) \ 106 | osSpTaskLoad(p); \ 107 | osSpTaskStartGo(p); 108 | 109 | void osSpTaskLoad(OSTask *task); 110 | void osSpTaskStartGo(OSTask *task); 111 | void osSpTaskYield(void); 112 | OSYieldResult osSpTaskYielded(OSTask *task); 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /include/PR/ucode.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_UCODE_H_ 2 | #define _ULTRA64_UCODE_H_ 3 | 4 | #define SP_DRAM_STACK_SIZE8 0x400 5 | #define SP_UCODE_SIZE 0x1000 6 | #define SP_UCODE_DATA_SIZE 0x800 7 | 8 | // standard boot ucode 9 | extern u64 rspF3DBootStart[], rspF3DBootEnd[]; 10 | 11 | // F3D ucode 12 | extern u64 rspF3DStart[], rspF3DEnd[]; 13 | 14 | // F3D ucode data 15 | extern u64 rspF3DDataStart[], rspF3DDataEnd[]; 16 | 17 | // aspMain (audio) ucode 18 | extern u64 rspAspMainStart[], rspAspMainEnd[]; 19 | 20 | // aspMain ucode data 21 | extern u64 rspAspMainDataStart[], rspAspMainDataEnd[]; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /include/PR/ultratypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_TYPES_H_ 2 | #define _ULTRA64_TYPES_H_ 3 | 4 | #ifndef NULL 5 | #define NULL (void *)0 6 | #endif 7 | 8 | #define TRUE 1 9 | #define FALSE 0 10 | 11 | typedef signed char s8; 12 | typedef unsigned char u8; 13 | typedef signed short int s16; 14 | typedef unsigned short int u16; 15 | typedef signed int s32; 16 | typedef unsigned int u32; 17 | typedef signed long long int s64; 18 | typedef unsigned long long int u64; 19 | 20 | typedef volatile u8 vu8; 21 | typedef volatile u16 vu16; 22 | typedef volatile u32 vu32; 23 | typedef volatile u64 vu64; 24 | typedef volatile s8 vs8; 25 | typedef volatile s16 vs16; 26 | typedef volatile s32 vs32; 27 | typedef volatile s64 vs64; 28 | 29 | typedef float f32; 30 | typedef double f64; 31 | 32 | typedef unsigned long size_t; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /include/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H_ 2 | #define _COMMON_H_ 3 | 4 | #include "macros.h" 5 | #include "ld_addrs.h" 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /include/macro.inc: -------------------------------------------------------------------------------- 1 | # Assembly Macros 2 | 3 | .macro glabel label 4 | .global \label 5 | \label: 6 | .endm 7 | -------------------------------------------------------------------------------- /include/macros.h: -------------------------------------------------------------------------------- 1 | #ifndef _MACROS_H_ 2 | #define _MACROS_H_ 3 | 4 | #include "ultra64.h" 5 | 6 | typedef u8* Addr; 7 | 8 | #define INCLUDE_ASM(TYPE, FOLDER, NAME, ARGS...) \ 9 | TYPE __attribute__((naked)) NAME(ARGS) { __asm__(".include \"include/macro.inc\"\n.include \"asm/nonmatchings/"FOLDER"/"#NAME".s\"\n.set reorder\n.set at"); } 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /include/math.h: -------------------------------------------------------------------------------- 1 | #ifndef _MATH_H_ 2 | #define _MATH_H_ 3 | 4 | #define M_PI 3.14159265358979323846 5 | 6 | // TODO: Where are these in libultra, if anywhere? 7 | float sinf(float); 8 | //double sin(double); 9 | float cosf(float); 10 | //double cos(double); 11 | 12 | float sqrtf(float); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/ultra64.h: -------------------------------------------------------------------------------- 1 | #ifndef _ULTRA64_H_ 2 | #define _ULTRA64_H_ 3 | 4 | #include 5 | 6 | #ifndef _LANGUAGE_C 7 | #define _LANGUAGE_C 8 | #endif 9 | 10 | // Shouldn't need this, but can't find a way to pass -DF3DEX_GBI to cc1. 11 | #ifndef F3DEX_GBI_2 12 | #define F3DEX_GBI_2 13 | #endif 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /marioparty3.sha1: -------------------------------------------------------------------------------- 1 | 6BEB80FF822B96BCF85DCDB512E8B2B7969D8259 build/marioparty3.z64 2 | -------------------------------------------------------------------------------- /src/1A580.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "1A580.h" 3 | 4 | void HuMemInit(HuAllocFunc malloc, HuFreeFunc free) { 5 | HuMallocHeader *newBlock; 6 | 7 | gMallocFunc = malloc; 8 | gFreeFunc = free; 9 | 10 | if (gHuMemIsDirty) { 11 | HuMemFreeAll(); 12 | } 13 | 14 | newBlock = gMallocFunc(sizeof(HuMallocHeader)); 15 | gLastMallocBlock = newBlock; 16 | gFirstMallocBlock = newBlock; 17 | 18 | newBlock->data = NULL; 19 | newBlock->tag = -1; 20 | newBlock->prev = newBlock; 21 | newBlock->next = newBlock; 22 | 23 | D_800C993C = 0; 24 | } 25 | 26 | void HuMemAlloc(s32 size) { 27 | HuMemAllocTag(size, 0); 28 | } 29 | 30 | void *HuMemAllocTag(s32 size, s16 tag) { 31 | s32 alignedSize; 32 | void *data; 33 | HuMallocHeader *firstBlk; 34 | HuMallocHeader *newBlk; 35 | 36 | alignedSize = (size + 7) & ~7; 37 | data = gMallocFunc(alignedSize + sizeof(HuMallocHeader)); 38 | newBlk = (HuMallocHeader *)((s32)data + alignedSize); 39 | 40 | firstBlk = gFirstMallocBlock; 41 | 42 | newBlk->prev = firstBlk; 43 | newBlk->next = firstBlk->next; 44 | firstBlk->next->prev = newBlk; 45 | firstBlk->next = newBlk; 46 | 47 | newBlk->tag = tag; 48 | newBlk->size = alignedSize; 49 | newBlk->data = data; 50 | newBlk->unkC = D_800D20AC; 51 | 52 | return newBlk->data; 53 | } 54 | 55 | void HuMemFree(void *data) { 56 | HuMallocHeader *block = gFirstMallocBlock->next; 57 | while (data != block->data) { 58 | block = block->next; 59 | if (block == gLastMallocBlock) { 60 | return; 61 | } 62 | } 63 | HuMemBlockFree(block); 64 | } 65 | 66 | void HuMemBlockFree(HuMallocHeader *block) { 67 | gLastFreedBlock = block; 68 | 69 | block->next->prev = block->prev; 70 | block->prev->next = block->next; 71 | 72 | gFreeFunc(block->data); 73 | } 74 | 75 | void HuMemFreeAllWithTag(s16 tag) { 76 | HuMallocHeader *prevBlk; 77 | HuMallocHeader *block; 78 | 79 | for (block = gFirstMallocBlock->next; block != gLastMallocBlock; block = block->next) { 80 | if (block->tag == tag) { 81 | if (block->tag != -1) { 82 | prevBlk = block->prev; 83 | HuMemBlockFree(block); 84 | block = prevBlk; 85 | } else { 86 | if (--block->unk4 == 0) { 87 | prevBlk = block->prev; 88 | HuMemBlockFree(block); 89 | block = prevBlk; 90 | 91 | if (--D_800C993C <= 0) { 92 | break; 93 | } 94 | } 95 | } 96 | } 97 | } 98 | } 99 | 100 | void func_80019C00(void *data) { 101 | HuMallocHeader *block; 102 | 103 | block = gFirstMallocBlock->next; 104 | while (data != block->data) { 105 | block = block->next; 106 | if (block == gLastMallocBlock) { 107 | return; 108 | } 109 | } 110 | 111 | block->tag = -1; 112 | block->unk4 = D_800D1FF0 + 1; 113 | 114 | ++D_800C993C; 115 | } 116 | 117 | void func_80019C68(s16 arg0) { 118 | HuMallocHeader *block; 119 | 120 | block = gFirstMallocBlock->next; 121 | while (block != gLastMallocBlock) { 122 | if (block->tag == arg0) { 123 | block->tag = -1; 124 | block->unk4 = D_800D1FF0 + 1; 125 | ++D_800C993C; 126 | } 127 | block = block->next; 128 | } 129 | } 130 | 131 | void HuMemSetDirty() { 132 | gHuMemIsDirty = TRUE; 133 | } 134 | 135 | void HuMemFreeAll() { 136 | HuMallocHeader *prevBlk; 137 | HuMallocHeader *block; 138 | 139 | block = gFirstMallocBlock->next; 140 | while (block != gLastMallocBlock) { 141 | prevBlk = block->prev; 142 | HuMemBlockFree(block); 143 | block = prevBlk->next; 144 | } 145 | 146 | gFreeFunc((void *)gLastMallocBlock); 147 | 148 | D_800C993C = 0; 149 | gHuMemIsDirty = FALSE; 150 | } 151 | 152 | void HuMemCleanUp() { 153 | if (gHuMemIsDirty) { 154 | HuMemFreeAll(); 155 | } else if (D_800C993C != 0) { 156 | HuMemFreeAllWithTag(-1); 157 | } 158 | } 159 | 160 | s32 HuMemGetSizeTag(s16 tag) { 161 | HuMallocHeader *block; 162 | s32 size; 163 | 164 | block = gFirstMallocBlock->next; 165 | size = 0; 166 | while (block != gLastMallocBlock) { 167 | if (block->tag == tag) { 168 | size += block->size; 169 | } 170 | block = block->next; 171 | } 172 | return size; 173 | } 174 | 175 | s32 HuMemGetSize() { 176 | HuMallocHeader *block; 177 | s32 size; 178 | 179 | block = gFirstMallocBlock->next; 180 | size = 0; 181 | while (block != gLastMallocBlock) { 182 | size += block->size; 183 | block = block->next; 184 | } 185 | return size; 186 | } 187 | 188 | void HuMemSetTag(void *data, s16 tag) { 189 | HuMallocHeader *block; 190 | 191 | block = gFirstMallocBlock->next; 192 | while (data != block->data) { 193 | block = block->next; 194 | if (block == gLastMallocBlock) { 195 | return; 196 | } 197 | } 198 | block->tag = tag; 199 | } 200 | 201 | s32 HuMemDebugCheck() { 202 | HuMallocHeader *block; 203 | s16 i; 204 | s16 count; 205 | s16 var_v1; 206 | s32 size; 207 | 208 | block = gFirstMallocBlock->next; 209 | size = 0; 210 | count = 0; 211 | while (block != gLastMallocBlock) { 212 | D_800C9950[count] = block->data; 213 | size += block->size; 214 | block = block->next; 215 | count++; 216 | } 217 | 218 | if ((D_800A08A2 != 0) && (D_800A08A2 != count)) { 219 | for (i = 0; i < count; i++) { 220 | for (var_v1 = 0; var_v1 < D_800A08A2; var_v1++) { 221 | if (D_800D2140[var_v1] == D_800C9950[i]) 222 | break; 223 | } 224 | if (var_v1 == D_800A08A2) { 225 | osSyncPrintf("%x\n", D_800C9950[i]); 226 | } 227 | } 228 | } 229 | 230 | D_800A08A2 = count; 231 | for (i = 0; i < count; i++) { 232 | D_800D2140[i] = D_800C9950[i]; 233 | } 234 | return size; 235 | } 236 | -------------------------------------------------------------------------------- /src/1A580.h: -------------------------------------------------------------------------------- 1 | #ifndef _1A580_H 2 | #define _1A580_H 3 | 4 | #include 5 | 6 | typedef struct HuMallocHeader { 7 | void *data; 8 | u8 unk4; 9 | s16 tag; 10 | s32 size; 11 | s32 unkC; 12 | struct HuMallocHeader *prev; 13 | struct HuMallocHeader *next; 14 | } HuMallocHeader; 15 | 16 | typedef HuMallocHeader *(*HuAllocFunc)(u32 size); 17 | typedef void (*HuFreeFunc)(void *ptr); 18 | 19 | extern s16 gHuMemIsDirty; 20 | extern s16 D_800A08A2; 21 | 22 | extern s16 D_800C993C; 23 | extern void *D_800C9950[]; 24 | 25 | extern HuMallocHeader *gLastMallocBlock; 26 | extern HuFreeFunc gFreeFunc; 27 | extern HuMallocHeader *gLastFreedBlock; 28 | extern u8 D_800D1FF0; 29 | extern s32 D_800D20AC; 30 | extern void *D_800D2140[]; 31 | extern HuAllocFunc gMallocFunc; 32 | extern HuMallocHeader *gFirstMallocBlock; 33 | 34 | void HuMemInit(HuAllocFunc malloc, HuFreeFunc free); 35 | void HuMemAlloc(s32 size); 36 | void *HuMemAllocTag(s32 size, s16 tag); 37 | void HuMemFree(void *data); 38 | void HuMemBlockFree(HuMallocHeader *block); 39 | void HuMemFreeAllWithTag(s16 tag); 40 | void func_80019C00_1A800(void *data); 41 | void func_80019C68_1A868(s16 arg0); 42 | void HuMemSetDirty(void); 43 | void HuMemFreeAll(void); 44 | void HuMemCleanUp(void); 45 | 46 | #endif /* _1A580_H */ -------------------------------------------------------------------------------- /src/1AC70.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "1AC70.h" 3 | 4 | // struct strCB8C0 { 5 | // s16 unk0; 6 | // s16 unk2; 7 | // s16 unk4; 8 | // s16 unk6; 9 | // s16 unk8; 10 | // s16 unkA; 11 | // s16 unkC; 12 | // s16 unkE; 13 | // }; 14 | 15 | // extern struct strCB8C0 *D_800CB8C0; 16 | extern s16 D_800CB8CE[]; 17 | 18 | extern s16 D_800CDD6A; 19 | 20 | extern void (*D_800D135C)(u8 *); 21 | extern s16 D_800D5204; 22 | 23 | INCLUDE_ASM(s32, "1AC70", func_8001A070); 24 | 25 | // Loads a model 26 | INCLUDE_ASM(s16, "1AC70", func_8001A150); 27 | 28 | INCLUDE_ASM(s32, "1AC70", func_8001A61C); 29 | 30 | INCLUDE_ASM(s32, "1AC70", func_8001A894); 31 | 32 | INCLUDE_ASM(s32, "1AC70", func_8001ABD4); 33 | 34 | INCLUDE_ASM(s32, "1AC70", func_8001AC34); 35 | 36 | INCLUDE_ASM(s32, "1AC70", func_8001AC8C); 37 | 38 | INCLUDE_ASM(s32, "1AC70", func_8001ACDC); 39 | 40 | INCLUDE_ASM(s32, "1AC70", func_8001AFE4); 41 | 42 | INCLUDE_ASM(s32, "1AC70", func_8001B0B4); 43 | 44 | INCLUDE_ASM(s32, "1AC70", func_8001BD24); 45 | 46 | INCLUDE_ASM(s32, "1AC70", func_8001BF14); 47 | 48 | INCLUDE_ASM(s32, "1AC70", func_8001BF90); 49 | 50 | INCLUDE_ASM(s32, "1AC70", func_8001C0C4); 51 | 52 | INCLUDE_ASM(s32, "1AC70", func_8001C114); 53 | 54 | INCLUDE_ASM(s32, "1AC70", func_8001C150); 55 | 56 | INCLUDE_ASM(s32, "1AC70", func_8001C1A0); 57 | 58 | INCLUDE_ASM(s32, "1AC70", func_8001C1F0); 59 | 60 | INCLUDE_ASM(s32, "1AC70", func_8001C258); 61 | 62 | INCLUDE_ASM(s32, "1AC70", func_8001C2FC); 63 | 64 | INCLUDE_ASM(s32, "1AC70", func_8001C39C); 65 | 66 | INCLUDE_ASM(s32, "1AC70", func_8001C448); 67 | 68 | INCLUDE_ASM(s32, "1AC70", func_8001C514); 69 | 70 | INCLUDE_ASM(s32, "1AC70", func_8001C5B4); 71 | 72 | void func_8001C624(s16 arg0, u8 arg1, s16 arg2, s16 arg3, u16 arg4) { 73 | struct strD03F8 *temp_a0; 74 | 75 | temp_a0 = D_800D03F8 + arg0; 76 | if (temp_a0->unk4 != 0xFF) { 77 | temp_a0->unk2 = temp_a0->unk4; 78 | temp_a0->unk40 = temp_a0->unk4C; 79 | temp_a0->unk3 = temp_a0->unk5; 80 | temp_a0->unk48 = temp_a0->unk54; 81 | } 82 | temp_a0->unk4 = (u8)arg1; 83 | temp_a0->unk4C = arg2; 84 | temp_a0->unkE = (u16)0; 85 | temp_a0->unkC = arg3; 86 | temp_a0->unk5 = (u8)arg4; 87 | temp_a0->unk54 = 0.0f; 88 | } 89 | 90 | INCLUDE_ASM(s32, "1AC70", func_8001C6A8); 91 | 92 | INCLUDE_ASM(s32, "1AC70", func_8001C718); 93 | 94 | INCLUDE_ASM(s32, "1AC70", func_8001C760); 95 | 96 | INCLUDE_ASM(s32, "1AC70", func_8001C7D0); 97 | 98 | INCLUDE_ASM(s32, "1AC70", func_8001C814); 99 | 100 | INCLUDE_ASM(s32, "1AC70", func_8001C8A8); 101 | 102 | INCLUDE_ASM(s32, "1AC70", func_8001C8E4); 103 | 104 | INCLUDE_ASM(s32, "1AC70", func_8001C92C); 105 | 106 | INCLUDE_ASM(s32, "1AC70", func_8001C954); 107 | 108 | INCLUDE_ASM(s32, "1AC70", func_8001CAA4); 109 | 110 | INCLUDE_ASM(s32, "1AC70", func_8001CD34); 111 | 112 | INCLUDE_ASM(s32, "1AC70", func_8001CE28); 113 | 114 | INCLUDE_ASM(s32, "1AC70", func_8001CF1C); 115 | 116 | INCLUDE_ASM(s32, "1AC70", func_8001D330); 117 | 118 | INCLUDE_ASM(s32, "1AC70", func_8001D33C); 119 | 120 | INCLUDE_ASM(s32, "1AC70", func_8001D558); 121 | 122 | INCLUDE_ASM(s32, "1AC70", func_8001D638); 123 | 124 | INCLUDE_ASM(s32, "1AC70", func_8001D874); 125 | 126 | INCLUDE_ASM(s32, "1AC70", func_8001DACC); 127 | 128 | INCLUDE_ASM(s32, "1AC70", func_8001DDB8); 129 | 130 | INCLUDE_ASM(s32, "1AC70", func_8001E500); 131 | 132 | INCLUDE_ASM(s32, "1AC70", func_8001E65C); 133 | 134 | INCLUDE_ASM(s32, "1AC70", func_8001E888); 135 | 136 | INCLUDE_ASM(s32, "1AC70", func_8001EBC0); 137 | 138 | INCLUDE_ASM(s32, "1AC70", func_8001ED54); 139 | 140 | INCLUDE_ASM(s32, "1AC70", func_8001EED8); 141 | 142 | INCLUDE_ASM(s32, "1AC70", func_8001EF24); 143 | 144 | INCLUDE_ASM(s32, "1AC70", func_8001EF60); 145 | 146 | INCLUDE_ASM(s32, "1AC70", func_8001EF6C); 147 | 148 | INCLUDE_ASM(s32, "1AC70", func_8001EFEC); 149 | 150 | INCLUDE_ASM(s32, "1AC70", func_8001F038); 151 | 152 | INCLUDE_ASM(s32, "1AC70", func_8001F154); 153 | 154 | INCLUDE_ASM(s32, "1AC70", func_8001F1FC); 155 | // s16 func_8001F1FC(u8 *mtnx, s16 arg1) { 156 | // s16 temp_s0; 157 | 158 | // if (mtnx[0] != 0x4D || mtnx[1] != 0x54 || mtnx[2] != 0x4E || mtnx[3] != 0x58) { 159 | // D_800D5204 = 0x2810; 160 | // D_800CDD6A = 0x2811; 161 | // D_800CB8CE[0] = 0x2810; 162 | // func_8000F0A0(&D_800CB8CE[0] - 15, mtnx, arg1); 163 | // temp_s0 = func_8002D2D8(mtnx, &D_800CB8CE[0] - 15); 164 | // HuMemFreeAllWithTag(D_800D5204); 165 | // HuMemFreeAllWithTag(D_800CDD6A); 166 | // } 167 | // else { 168 | // temp_s0 = func_8002D3AC(mtnx); 169 | // } 170 | 171 | // if ((arg1 & 8) != 0) { 172 | // D_800D135C(mtnx); 173 | // } 174 | // return temp_s0; 175 | // } 176 | 177 | void func_8001F304(s16 arg0, s8 arg1) { 178 | struct strD03F8 *temp_v0; 179 | f32 zero; 180 | 181 | temp_v0 = D_800D03F8 + arg0; 182 | temp_v0->unk2 = arg1; 183 | temp_v0->unk3 = 0; 184 | zero = 0.0f; 185 | temp_v0->unk40 = zero; 186 | temp_v0->unk48 = zero; 187 | temp_v0->unk44 = 1.0f; 188 | temp_v0->unk4 = 0xFF; 189 | } 190 | 191 | INCLUDE_ASM(s32, "1AC70", func_8001F358); 192 | 193 | INCLUDE_ASM(s32, "1AC70", func_8001F38C); 194 | 195 | INCLUDE_ASM(s32, "1AC70", func_8001F3A8); 196 | 197 | INCLUDE_ASM(s32, "1AC70", func_8001F450); 198 | 199 | INCLUDE_ASM(s32, "1AC70", func_8001F4BC); 200 | 201 | INCLUDE_ASM(s32, "1AC70", func_8001F668); 202 | 203 | INCLUDE_ASM(s32, "1AC70", func_8001F6B0); 204 | 205 | INCLUDE_ASM(s32, "1AC70", func_8001F6BC); 206 | 207 | INCLUDE_ASM(s32, "1AC70", func_8001F6F8); 208 | 209 | INCLUDE_ASM(s32, "1AC70", func_8001F734); 210 | 211 | INCLUDE_ASM(s32, "1AC70", func_8001F95C); 212 | 213 | INCLUDE_ASM(s32, "1AC70", func_8001F974); 214 | 215 | INCLUDE_ASM(s32, "1AC70", func_8001F9E4); 216 | 217 | INCLUDE_ASM(s32, "1AC70", func_8001FA68); 218 | 219 | INCLUDE_ASM(s32, "1AC70", func_8001FB34); 220 | 221 | void func_8001FBBC(s16 arg0, s8 arg1, s8 arg2, s8 arg3) { 222 | struct strD03F8 *other; 223 | 224 | other = (D_800D03F8 + arg0)->unkB4; 225 | if (other != NULL) { 226 | other->unk0 = arg1; 227 | other->unk1 = arg2; 228 | other->unk2 = arg3; 229 | } 230 | } 231 | 232 | INCLUDE_ASM(s32, "1AC70", func_8001FBFC); 233 | 234 | INCLUDE_ASM(s32, "1AC70", func_8001FD08); 235 | 236 | void func_8001FDE8(s16 arg0) { 237 | (D_800D03F8 + arg0)->unk2 = 0xFF; 238 | } 239 | -------------------------------------------------------------------------------- /src/1AC70.h: -------------------------------------------------------------------------------- 1 | #ifndef _1AC70_H 2 | #define _1AC70_H 3 | 4 | #include 5 | 6 | struct strD03F8 { 7 | s8 unk0; 8 | s8 unk1; 9 | u8 unk2; 10 | s8 unk3; 11 | u8 unk4; 12 | s8 unk5; 13 | s8 unk6; 14 | s8 unk7; 15 | s16 unk8; 16 | s16 unkA; 17 | s16 unkC; 18 | s16 unkE; 19 | s8 unks10to40[0x30]; 20 | 21 | f32 unk40; 22 | f32 unk44; 23 | f32 unk48; 24 | f32 unk4C; 25 | f32 unk50; 26 | f32 unk54; 27 | 28 | s8 unks58toB0[0x58]; 29 | 30 | s32 unkB0; 31 | struct strD03F8 *unkB4; 32 | s32 unkB8; 33 | s32 unkBC; 34 | }; // sizeof == 0xC0 35 | extern struct strD03F8 *D_800D03F8; 36 | 37 | #endif /* _1AC70_H */ -------------------------------------------------------------------------------- /src/365E0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "365E0.h" 3 | 4 | // Function called by `main` overlay entrypoints, usually boards, 5 | // that redirects to some particular function based on current state. 6 | void func_800359E0(struct overlay_entrypoint *entrypoints, s16 index) { 7 | struct overlay_entrypoint *curEntrypoint; 8 | 9 | curEntrypoint = entrypoints; 10 | while (curEntrypoint->index >= 0) { 11 | if (curEntrypoint->index == index) { 12 | curEntrypoint->fn(); 13 | } 14 | curEntrypoint++; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/365E0.h: -------------------------------------------------------------------------------- 1 | #ifndef _365E0_H 2 | #define _365E0_H 3 | 4 | #include 5 | 6 | struct overlay_entrypoint { 7 | s16 index; 8 | void (*fn)(); 9 | }; 10 | 11 | #endif /* _365E0_H */ -------------------------------------------------------------------------------- /src/36650.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "board.h" 3 | 4 | extern s32 D_800B1A30; 5 | 6 | extern void *D_800CC0C8; 7 | extern s16 D_800CC0CA[]; 8 | 9 | extern u8 D_800CD0B6; 10 | 11 | extern void *D_800D0308; 12 | 13 | void func_80035A50() { 14 | u8 *D_800CC0C8loc; 15 | 16 | D_800CC0C8loc = (u8 *)&D_800CC0C8; 17 | 18 | bzero(D_800CC0C8loc, 0xA4); 19 | bzero(&D_800D0308, 0x74); 20 | *D_800CC0C8loc = 0x91; 21 | D_800CD058.current_board_index = 0; 22 | D_800CD058.unk10 = 0; 23 | } 24 | 25 | void func_80035AA8(s8 arg0) { 26 | D_800CD058.unk10 = arg0; 27 | } 28 | 29 | INCLUDE_ASM(s32, "36650", func_80035AB4); 30 | 31 | INCLUDE_ASM(s32, "36650", func_80035B2C); 32 | 33 | INCLUDE_ASM(s32, "36650", func_80035B80); 34 | 35 | INCLUDE_ASM(s32, "36650", func_80035BD8); 36 | 37 | void func_80035C20(s16 arg0, s16 arg1) { 38 | if (func_80035EB0(0xF) == 0) { 39 | D_800CC0CA[arg0] = arg1; 40 | } 41 | } 42 | 43 | u16 func_80035C6C(s16 arg0) { 44 | return D_800CC0CA[arg0]; 45 | } 46 | 47 | void func_80035C84(s8 arg0) { 48 | D_800CD058.current_board_index = arg0; 49 | } 50 | 51 | INCLUDE_ASM(u8 *, "36650", func_80035C90); 52 | 53 | u8 func_80035CF8(s16 arg0) { 54 | return *func_80035C90(arg0); 55 | } 56 | 57 | INCLUDE_ASM(s32, "36650", func_80035D1C); 58 | 59 | INCLUDE_ASM(s32, "36650", func_80035DA4); 60 | 61 | INCLUDE_ASM(s32, "36650", func_80035E3C); 62 | 63 | u8 *func_80035E60(s16 arg0) { 64 | u8 *temp_v0 = func_80035C90(arg0); 65 | *temp_v0 = *temp_v0; // ? 66 | return temp_v0; 67 | } 68 | 69 | u8 *func_80035E88(s16 arg0) { 70 | u8 *temp_v0 = func_80035C90(arg0); 71 | *temp_v0 = *temp_v0; // ? 72 | return temp_v0; 73 | } 74 | 75 | INCLUDE_ASM(s32, "36650", func_80035EB0); 76 | 77 | INCLUDE_ASM(s32, "36650", func_80035EF4); 78 | 79 | INCLUDE_ASM(s32, "36650", func_80035F44); 80 | 81 | // IsBoardFeatureFlagSet 82 | s32 func_80035F98(s32 feature) { 83 | s32 a, b; 84 | s32 ret; 85 | 86 | a = feature; 87 | if (feature < 0) { 88 | a += 7; 89 | } 90 | a >>= 3; 91 | 92 | ret = (&D_800CD0B6)[a]; 93 | 94 | if (feature >= 0) { 95 | b = feature; 96 | } else { 97 | b = feature + 7; 98 | } 99 | 100 | b >>= 3; 101 | b <<= 3; 102 | b = feature - b; 103 | 104 | return ret & (1 << b); 105 | } 106 | 107 | INCLUDE_ASM(s32, "36650", func_80035FDC); 108 | 109 | INCLUDE_ASM(s32, "36650", func_8003602C); 110 | 111 | INCLUDE_ASM(s32, "36650", func_80036080); 112 | 113 | s32 func_800360B8() { 114 | return D_800B1A30; 115 | } 116 | -------------------------------------------------------------------------------- /src/36F80.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | // string table parsing code. 4 | 5 | extern void *D_800B1A40; // strings ROM pointer 6 | extern s32 D_800B1A44; // string directory count 7 | extern u32 *D_800B1A48; // string directory table 8 | extern s32 D_800B1A4C; // string directory table size 9 | 10 | void func_80036380(void *stringsRomPtr) { 11 | s32 stringDirTableSize; 12 | u32 *stringDirTable; 13 | u32 *stringsHeader; 14 | 15 | D_800B1A40 = stringsRomPtr; 16 | stringsHeader = MallocPerm(16); 17 | HuRomDmaRead(stringsRomPtr, stringsHeader, 16); 18 | D_800B1A44 = *stringsHeader; 19 | FreePerm(stringsHeader); 20 | stringDirTableSize = D_800B1A44 * 4; 21 | D_800B1A4C = stringDirTableSize; 22 | stringDirTable = MallocPerm(stringDirTableSize); 23 | D_800B1A48 = stringDirTable; 24 | HuRomDmaRead(stringsRomPtr + 4, stringDirTable, D_800B1A4C); 25 | } 26 | 27 | void func_80036414(void *ptr) { 28 | D_800B1A40 = ptr; 29 | HuRomDmaRead(ptr + 4, D_800B1A48, D_800B1A4C); 30 | } 31 | 32 | struct str80036448 { 33 | void *unk0; 34 | s32 unk4; // decompressed size 35 | s32 unk8; // compression type 36 | }; 37 | 38 | struct string_dir_header { 39 | s32 decompressedSize; 40 | s32 compressionType; 41 | }; 42 | 43 | void func_80036448(s32 arg0, struct str80036448 *arg1) { 44 | s32 temp_a0; 45 | struct string_dir_header *dirHeader; 46 | 47 | dirHeader = MallocPerm(16); 48 | temp_a0 = ((s8 *)D_800B1A40) + *(D_800B1A48 + arg0); 49 | arg1->unk0 = temp_a0; 50 | HuRomDmaRead(temp_a0, dirHeader, 16); 51 | arg1->unk0 = arg1->unk0 + 8; 52 | arg1->unk4 = dirHeader->decompressedSize; 53 | arg1->unk8 = dirHeader->compressionType; 54 | FreePerm(dirHeader); 55 | } 56 | 57 | INCLUDE_ASM(s32, "36F80", func_800364DC); 58 | 59 | void func_800365E8(void *ptr) { 60 | if (ptr != NULL) { 61 | FreePerm(ptr); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/47D60.h: -------------------------------------------------------------------------------- 1 | #ifndef _47D60_H 2 | #define _47D60_H 3 | 4 | #include 5 | 6 | struct strD2010 { 7 | s32 overlayIndex; 8 | s16 entrypointIndex; 9 | u16 unk6; 10 | }; 11 | extern struct strD2010 D_800D2010[]; 12 | extern struct strD2010 D_800D20F0[]; 13 | 14 | struct process *InitProcess(void *func, u16 priority, s32 stackSize, s32 extraDataSize); 15 | 16 | struct unk80047620 { 17 | s8 unks[0x14]; 18 | void *unk14; 19 | }; 20 | 21 | #endif /* _47D60_H */ 22 | -------------------------------------------------------------------------------- /src/4B120.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "player.h" 3 | 4 | extern u8 D_800D09A8; 5 | 6 | struct str800D5298 { 7 | s32 unk0; 8 | s32 unk4; 9 | void *unk8; // mbf0 rom 10 | void *unkC; // sbf0 rom 11 | void *unk10; // fxd0 rom 12 | void *unk14; // audio ram location? 13 | s32 unk18; // audio ram size? 14 | s32 unks1C24[3]; 15 | s32 unk28; 16 | s32 unk2C; 17 | s32 unks3040[5]; 18 | s32 unk44; 19 | s32 unks4858[5]; 20 | s32 unk5C; 21 | s32 unk60; 22 | s32 unk64; 23 | s32 unk68; 24 | }; 25 | extern struct str800D5298 D_800D5298; 26 | 27 | INCLUDE_ASM(s32, "4B120", func_8004A520); 28 | 29 | INCLUDE_ASM(s32, "4B120", func_8004A5C4); 30 | 31 | INCLUDE_ASM(s32, "4B120", func_8004A650); 32 | 33 | INCLUDE_ASM(s32, "4B120", func_8004A670); 34 | 35 | INCLUDE_ASM(s32, "4B120", func_8004A72C); 36 | 37 | INCLUDE_ASM(s32, "4B120", func_8004A7C4); 38 | 39 | INCLUDE_ASM(s32, "4B120", func_8004A880); 40 | 41 | INCLUDE_ASM(s32, "4B120", func_8004A918); 42 | 43 | INCLUDE_ASM(s32, "4B120", func_8004A950); 44 | 45 | INCLUDE_ASM(s32, "4B120", func_8004A994); 46 | 47 | INCLUDE_ASM(s32, "4B120", func_8004A9DC); 48 | 49 | INCLUDE_ASM(s32, "4B120", func_8004AA04); 50 | 51 | INCLUDE_ASM(s32, "4B120", func_8004AA38); 52 | 53 | INCLUDE_ASM(s32, "4B120", func_8004AA60); 54 | 55 | INCLUDE_ASM(s32, "4B120", func_8004AA88); 56 | 57 | INCLUDE_ASM(s32, "4B120", func_8004AAD0); 58 | 59 | INCLUDE_ASM(s32, "4B120", func_8004AB0C); 60 | 61 | INCLUDE_ASM(s32, "4B120", func_8004AB7C); 62 | 63 | INCLUDE_ASM(s32, "4B120", func_8004ABE8); 64 | 65 | INCLUDE_ASM(s32, "4B120", func_8004AC10); 66 | 67 | INCLUDE_ASM(s32, "4B120", func_8004AC5C); 68 | 69 | INCLUDE_ASM(s32, "4B120", func_8004AC98); 70 | 71 | INCLUDE_ASM(s32, "4B120", func_8004ACE0); 72 | 73 | INCLUDE_ASM(s32, "4B120", func_8004AD50); 74 | 75 | void func_8004AD70() { 76 | func_80007DD8(-1); 77 | } 78 | 79 | INCLUDE_ASM(s32, "4B120", func_8004AD8C); 80 | 81 | void func_8004ADDC(s16 arg0) { 82 | func_80007C80(-1, arg0); 83 | } 84 | 85 | void func_8004AE00(s16 arg0, s16 arg1) { 86 | func_80007C80(arg0, arg1); 87 | } 88 | 89 | INCLUDE_ASM(s32, "4B120", func_8004AE28); 90 | 91 | INCLUDE_ASM(s32, "4B120", func_8004AEF0); 92 | 93 | INCLUDE_ASM(s32, "4B120", func_8004AFBC); 94 | 95 | INCLUDE_ASM(s32, "4B120", func_8004B0D4); 96 | 97 | INCLUDE_ASM(s32, "4B120", func_8004B1AC); 98 | 99 | void func_8004B25C(s16 arg0, s16 arg1, s16 arg2, s16 arg3) { 100 | if ((gPlayers[arg0].flags & 1) == 0) { 101 | func_8005A674(gPlayers[arg0].controller, arg1, arg2, arg3); 102 | } 103 | } 104 | 105 | s32 func_8004B2C0() { 106 | return 0; 107 | } 108 | 109 | void func_8004B2C8(void) { 110 | struct str800D5298 *temp; 111 | 112 | func_80000EA8(&D_800D5298); 113 | 114 | temp = &D_800D5298; 115 | temp->unk28 = 1; 116 | D_800D5298.unk8 = &bin_audio_mbf0_ROM_START; 117 | D_800D5298.unkC = &bin_audio_sbf0_ROM_START; 118 | 119 | func_8000086C(temp); 120 | 121 | if ((D_800D09A8 & 1) == 0) { 122 | func_80000F30(0); 123 | } 124 | else { 125 | func_80000F30(1); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/CE10.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | // Contains save type check that often hangs emulators 4 | INCLUDE_ASM(s32, "CE10", func_8000C210); 5 | 6 | INCLUDE_ASM(s32, "CE10", func_8000C4AC); 7 | 8 | INCLUDE_ASM(s32, "CE10", func_8000C4DC); 9 | 10 | INCLUDE_ASM(s32, "CE10", func_8000C538); 11 | 12 | INCLUDE_ASM(s32, "CE10", func_8000C638); 13 | 14 | INCLUDE_ASM(s32, "CE10", func_8000C6C0); 15 | 16 | INCLUDE_ASM(s32, "CE10", func_8000C7A0); 17 | 18 | INCLUDE_ASM(s32, "CE10", func_8000C7F4); 19 | 20 | INCLUDE_ASM(s32, "CE10", func_8000C8F0); 21 | 22 | INCLUDE_ASM(s32, "CE10", func_8000C954); 23 | 24 | INCLUDE_ASM(s32, "CE10", func_8000C9C8); 25 | 26 | INCLUDE_ASM(s32, "CE10", func_8000CA3C); 27 | 28 | INCLUDE_ASM(s32, "CE10", func_8000CA64); 29 | 30 | INCLUDE_ASM(s32, "CE10", func_8000CA8C); 31 | 32 | INCLUDE_ASM(s32, "CE10", func_8000CAC0); 33 | 34 | INCLUDE_ASM(s32, "CE10", func_8000CAEC); 35 | 36 | INCLUDE_ASM(s32, "CE10", func_8000CB30); 37 | -------------------------------------------------------------------------------- /src/EFC0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "heap_permanent.h" 3 | #include "process.h" 4 | #include "player.h" 5 | 6 | extern u16 D_800A190C; 7 | extern u16 D_800A190E; 8 | 9 | extern void *D_800CCF38; 10 | extern u8 D_800CCF78[]; 11 | extern f32 D_800CD288[]; 12 | extern u16 D_800CD2F4; 13 | extern s32 D_800CDD50; 14 | extern f32 D_800CE1C8; 15 | extern struct process *D_800D0448; 16 | extern u8 D_800D09A8; 17 | 18 | struct str800D138C { 19 | f32 unk0; 20 | f32 unk4; 21 | f32 unk8; 22 | }; 23 | extern struct str800D138C D_800D138C; 24 | 25 | extern struct process *D_800D170C; 26 | extern u8 D_800D1710; 27 | extern s16 D_800D1F36; 28 | extern u16 D_800D4082; 29 | 30 | struct str800D5298 { 31 | s32 unk0; 32 | s32 unk4; 33 | void *unk8; // mbf0 rom 34 | void *unkC; // sbf0 rom 35 | void *unk10; // fxd0 rom 36 | void *unk14; // audio ram location? 37 | s32 unk18; // audio ram size? 38 | s32 unks1C24[3]; 39 | s32 unk28; 40 | s32 unk2C; 41 | s32 unks3040[5]; 42 | s32 unk44; 43 | s32 unks4858[5]; 44 | s32 unk5C; 45 | s32 unk60; 46 | s32 unk64; 47 | s32 unk68; 48 | }; 49 | extern struct str800D5298 D_800D5298; 50 | 51 | struct triplefloat { 52 | f32 unk0; 53 | f32 unk4; 54 | f32 unk8; 55 | }; 56 | 57 | struct str800D54F8 { 58 | f32 unk0; 59 | f32 unk4; 60 | f32 unk8; 61 | }; 62 | extern struct str800D54F8 D_800D54F8[]; 63 | 64 | extern u16 D_800D6A56; 65 | 66 | struct str800D6ABC { 67 | f32 unk0; 68 | f32 unk4; 69 | f32 unk8; 70 | }; 71 | 72 | extern struct str800D6ABC D_800D6ABC; 73 | 74 | struct str800D6AE0 { 75 | f32 unk0; 76 | f32 unk4; 77 | f32 unk8; 78 | }; 79 | 80 | extern struct str800D6AE0 D_800D6AE0[]; 81 | 82 | extern s32 func_8000985C(s16); 83 | 84 | extern void func_8000E740(); 85 | extern void func_8000E78C(); 86 | extern void func_8000E7B8(); 87 | extern void func_8000E804(); 88 | extern void func_8000E978(); 89 | 90 | void func_8000E3C0() { 91 | s32 i; 92 | f32 zero; 93 | struct str800D6ABC *loc; 94 | 95 | SleepVProcess(); 96 | 97 | func_8004F290(); 98 | 99 | D_800D138C.unk0 = 325.0f; 100 | D_800D138C.unk4 = 0.0f; 101 | D_800D138C.unk8 = 0.0f; 102 | 103 | D_800CE1C8 = 2250.0f; 104 | 105 | loc = &D_800D6ABC; 106 | D_800D6ABC.unk8 = D_800D138C.unk4; 107 | D_800D6ABC.unk4 = D_800D138C.unk4; 108 | loc->unk0 = D_800D138C.unk4; 109 | 110 | for (i = 0; i < 4; i++) { 111 | D_800D6AE0[i].unk0 = 325.0f; 112 | (*(D_800D6AE0 + i)).unk8 = (zero = 0.0f); 113 | D_800D6AE0[i].unk4 = zero; 114 | 115 | D_800CD288[i] = 2250.0f; 116 | 117 | (*(D_800D54F8 + i)).unk8 = zero; 118 | (*(D_800D54F8 + i)).unk4 = zero; 119 | D_800D54F8[i].unk0 = zero; 120 | } 121 | 122 | D_800D1710 = 3; 123 | D_800D4082 = 0x1000; 124 | D_800CD2F4 = 0x2004; 125 | D_800D6A56 = 0x180; 126 | func_80061B50(); 127 | func_8001A070(&MallocPerm, &FreePerm, D_800D4082, D_800CD2F4, D_800D6A56, D_800D1710); 128 | func_80012220(1); 129 | func_8004DC00(); 130 | func_80036380(&bin_strings_jp_ROM_START); // strings 131 | D_800D1F36 = 0; 132 | 133 | loop_3: 134 | if (func_8000985C(D_800D1F36) == 0) { 135 | if (++D_800D1F36 < 4) { 136 | goto loop_3; 137 | } 138 | } 139 | 140 | if (D_800D1F36 == 4) { 141 | D_800D1F36 = -1; 142 | } 143 | 144 | GetAllocatedPermHeapSize(); 145 | D_800D0448 = CreateProcess(&func_8000E740, 0xF000, 0x3000, 0); 146 | CreateProcess(&func_8000E78C, 0x4000, 0x3000, 0); 147 | D_800D170C = CreateProcess(&func_8000E7B8, 0x1000, 0x3000, 0); 148 | 149 | { 150 | s32 temp_s0; 151 | 152 | temp_s0 = func_8004FDC0(); 153 | func_80035A50(); 154 | func_8000E978(); 155 | func_80000EA8(&D_800D5298); 156 | func_80050E78(0); 157 | func_80050800(); 158 | if (temp_s0 != 0) { 159 | func_80048128(0x67, 0, 0x82); 160 | } 161 | else { 162 | func_80048128(0x58, 0, 0x84); 163 | } 164 | } 165 | 166 | D_800D5298.unk8 = &bin_audio_mbf0_ROM_START; 167 | D_800D5298.unkC = &bin_audio_sbf0_ROM_START; 168 | D_800A190E = 0; 169 | D_800A190C = 0; 170 | D_800D5298.unk0 = 0x70418F; 171 | D_800D5298.unk10 = &bin_audio_fxd0_ROM_START; 172 | D_800D5298.unk28 = 1; 173 | D_800D5298.unk2C = 0; 174 | D_800D5298.unk14 = (void *)0x802E0000; 175 | D_800D5298.unk18 = 0x80000; 176 | D_800D5298.unk5C = 0x6E; 177 | D_800D5298.unk60 = 0; 178 | D_800D5298.unk64 = 0; 179 | D_800D5298.unk68 = D_800CDD50; 180 | D_800D5298.unk44 = 0x3C; 181 | func_800007FC(&D_800D5298); 182 | 183 | if ((D_800D09A8 & 1) != 0) { 184 | func_80000F30(1); 185 | } 186 | else { 187 | func_80000F30(0); 188 | } 189 | 190 | KillProcess(GetCurrentProcess()); 191 | 192 | while (TRUE) { 193 | SleepVProcess(); 194 | } 195 | } 196 | 197 | void func_8000E740() { 198 | while (TRUE) { 199 | SleepVProcess(); 200 | func_800224BC(); 201 | func_800143F0(); 202 | func_8001BF90(0x2000000, 0x3D0800); 203 | func_8004DC98(); 204 | } 205 | } 206 | 207 | void func_8000E78C() { 208 | while (TRUE) { 209 | SleepVProcess(); 210 | func_80048504(); 211 | } 212 | } 213 | 214 | void func_8000E7B8() { 215 | while (TRUE) { 216 | SleepVProcess(); 217 | GetRandomByte(); 218 | func_8000BA30(); 219 | func_80014A3C(2); 220 | func_8001B0B4(&D_800CCF38, 2); 221 | } 222 | } 223 | 224 | void func_8000E804() { 225 | s32 i; 226 | 227 | for (i = 0; i < 4; i++) { 228 | func_80087A40(&gPlayers[i], 0, sizeof(struct player)); 229 | if (func_8000985C(i) != 0) { 230 | D_800CCF78[i] = 0; 231 | gPlayers[i].flags &= 0xFE; 232 | } 233 | else { 234 | D_800CCF78[i] = 1; 235 | gPlayers[i].flags |= 0x01; 236 | } 237 | gPlayers[i].controller = i; 238 | gPlayers[i].coins = 10; 239 | gPlayers[i].bonus_coins = 0; 240 | gPlayers[i].id = i; 241 | gPlayers[i].cpu_difficulty = 0; 242 | gPlayers[i].stars = 0; 243 | gPlayers[i].minigame_star = 0; 244 | gPlayers[i].blue_space_count = 0; 245 | gPlayers[i].red_space_count = 0; 246 | gPlayers[i].happening_space_count = 0; 247 | } 248 | } 249 | 250 | void func_8000E978() { 251 | func_8000E804(); 252 | func_80035C20(0, 0x64); 253 | func_80035C20(1, 0xE10); 254 | func_80035C20(2, 0xE10); 255 | func_80035C20(3, 0x708); 256 | func_80035C20(4, 0x3E8); 257 | func_80035C20(5, 0xE10); 258 | func_80035C20(6, 0xE10); 259 | func_80035C20(7, 0xE10); 260 | func_80035C20(8, 0); 261 | func_80035C20(9, 0x1518); 262 | } 263 | -------------------------------------------------------------------------------- /src/board.h: -------------------------------------------------------------------------------- 1 | #ifndef _BOARD_H 2 | #define _BOARD_H 3 | 4 | #include 5 | 6 | struct event_list_entry { 7 | s16 activation_type; 8 | s16 execution_type; 9 | void (*event_fn)(); 10 | }; 11 | 12 | struct event_table_entry { 13 | s16 space_index; 14 | struct event_list_entry *event_list; 15 | }; 16 | 17 | struct strCD058 { 18 | /* 0x00 - 800CD058 */ s8 unk0; 19 | /* 0x01 - 800CD059 */ s8 current_board_index; 20 | /* 0x02 - 800CD05A */ s8 total_turns; 21 | /* 0x03 - 800CD05B */ s8 current_turn; 22 | /* 0x04 - 800CD05C */ s8 current_game_length; // 00=Lite Play,01=Standard Play,02=Full Play,03=Custom Play 23 | /* 0x05 - 800CD05D */ s8 current_star_spawn; // Index of star space (index into star_spawn_indices) 24 | /* 0x06 - 800CD05E */ s8 star_spawn_indices[7]; 25 | /* 0x0D - 800CD065 */ s8 unkD; 26 | /* 0x0E - 800CD066 */ s8 unkE; 27 | /* 0x0F - 800CD067 */ s8 current_player_index; 28 | /* 0x10 - 800CD068 */ s8 unk10; 29 | /* 0x11 - 800CD069 */ s8 current_space_index; 30 | /* 0x12 - 800CD06A */ s8 unk12; 31 | /* 0x13 - 800CD06B */ s8 unk13; 32 | /* 0x14 - 800CD06C */ s8 unk14; 33 | /* 0x15 - 800CD06D */ s8 unk15; 34 | /* 0x16 - 800CD06E */ s8 unk16; 35 | 36 | // 800cd09c flag for re-roll 37 | }; 38 | extern struct strCD058 D_800CD058; 39 | 40 | extern u16 D_800CD0AE; 41 | 42 | #endif /* _BOARD_H */ -------------------------------------------------------------------------------- /src/heap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "heap.h" 3 | 4 | #define HEAP_CONSTANT 0xA5 5 | #define MIN_ALLOC_SIZE 16 6 | 7 | #define MIN_HEAP_NODE_SIZE sizeof(struct heap_node) + MIN_ALLOC_SIZE 8 | 9 | extern s32 D_800A0530; 10 | 11 | /* 12 | * Creates an empty heap of a given size. 13 | */ 14 | void *MakeHeap(void *ptr, u32 size) 15 | { 16 | struct heap_node *heap = (struct heap_node*)ptr; 17 | heap->size = size; 18 | heap->heap_constant = HEAP_CONSTANT; 19 | heap->used = 0; 20 | heap->prev = ptr; 21 | heap->next = ptr; 22 | return heap; 23 | } 24 | 25 | /* 26 | * Allocates the requested size of memory in the given heap. 27 | */ 28 | void *Malloc(struct heap_node *heap, s32 size) 29 | { 30 | struct heap_node *cur_heap; 31 | struct heap_node *new_heap_temp; 32 | 33 | size = size + 0x1F; 34 | size = size & -16; 35 | 36 | cur_heap = heap; 37 | do 38 | { 39 | if (!cur_heap->used) 40 | { 41 | if (cur_heap->size >= size) 42 | { 43 | if ((u32)(cur_heap->size - size) > MIN_HEAP_NODE_SIZE) 44 | { 45 | new_heap_temp = ((void *)cur_heap) + size; 46 | new_heap_temp->size = cur_heap->size - size; 47 | new_heap_temp->heap_constant = HEAP_CONSTANT; 48 | new_heap_temp->used = FALSE; 49 | 50 | cur_heap->next->prev = new_heap_temp; 51 | new_heap_temp->next = cur_heap->next; 52 | cur_heap->next = new_heap_temp; 53 | new_heap_temp->prev = cur_heap; 54 | cur_heap->size = size; 55 | } 56 | 57 | cur_heap->used = TRUE; 58 | return (void *)cur_heap + sizeof(struct heap_node); 59 | } 60 | } 61 | 62 | cur_heap = cur_heap->next; 63 | } 64 | while (cur_heap != heap); 65 | 66 | D_800A0530 = 0x10000; 67 | return NULL; 68 | } 69 | 70 | /* 71 | * Frees the given heap memory pointer. 72 | */ 73 | void Free(void *ptr) 74 | { 75 | struct heap_node *given_heap; 76 | struct heap_node *heap_other; 77 | 78 | if (ptr == NULL) 79 | { 80 | return; 81 | } 82 | 83 | given_heap = (struct heap_node *)(ptr - sizeof(struct heap_node)); 84 | if (given_heap->heap_constant != HEAP_CONSTANT) 85 | { 86 | D_800A0530 = 0x10001; 87 | return; 88 | } 89 | 90 | #pragma GCC diagnostic push 91 | #pragma GCC diagnostic ignored "-Wpointer-to-int-cast" 92 | 93 | heap_other = given_heap->prev; 94 | if (((u32)heap_other < (u32)given_heap) && !heap_other->used) 95 | { 96 | given_heap->next->prev = heap_other; 97 | given_heap->prev->next = given_heap->next; 98 | given_heap->prev->size += given_heap->size; 99 | given_heap = given_heap->prev; 100 | } 101 | 102 | heap_other = given_heap->next; 103 | if (((u32)given_heap < (u32)heap_other) && !heap_other->used) 104 | { 105 | heap_other->next->prev = given_heap; 106 | given_heap->size += given_heap->next->size; 107 | given_heap->next = given_heap->next->next; 108 | } 109 | 110 | #pragma GCC diagnostic pop 111 | 112 | given_heap->used = FALSE; 113 | } 114 | 115 | /* 116 | * Resizes a previously allocated buffer in a heap. 117 | */ 118 | void *Realloc(struct heap_node *heap, void *mem, u32 new_size) 119 | { 120 | void *ret; 121 | struct heap_node *given_heap; 122 | struct heap_node *new_heap; 123 | s32 temp; 124 | 125 | given_heap = (struct heap_node *)(mem - sizeof(struct heap_node)); 126 | temp = new_size + 0x1F; 127 | temp = temp & -16; 128 | 129 | if (given_heap->size >= temp) 130 | { 131 | if ((u32)(given_heap->size - temp) > MIN_HEAP_NODE_SIZE) 132 | { 133 | new_heap = (void *)given_heap + temp; 134 | new_heap->size = given_heap->size - temp; 135 | new_heap->heap_constant = HEAP_CONSTANT; 136 | new_heap->used = FALSE; 137 | given_heap->next->prev = new_heap; 138 | new_heap->next = given_heap->next; 139 | given_heap->next = new_heap; 140 | new_heap->prev = given_heap; 141 | given_heap->size = temp; 142 | } 143 | 144 | return (void *)given_heap + sizeof(struct heap_node); 145 | } 146 | else 147 | { 148 | ret = Malloc(heap, new_size); 149 | if (ret != NULL) 150 | { 151 | bcopy(mem, ret, given_heap->size - sizeof(struct heap_node)); 152 | Free(mem); 153 | } 154 | 155 | return ret; 156 | } 157 | 158 | return NULL; 159 | } 160 | 161 | /* 162 | * Returns the total size of allocated buffers in a heap. 163 | */ 164 | u32 GetAllocatedHeapSize(struct heap_node *heap) 165 | { 166 | struct heap_node *cur_heap; 167 | u32 total_size; 168 | 169 | cur_heap = heap; 170 | total_size = 0; 171 | do 172 | { 173 | if (cur_heap->used == TRUE) 174 | { 175 | total_size += cur_heap->size; 176 | } 177 | cur_heap = cur_heap->next; 178 | } 179 | while (cur_heap != heap); 180 | 181 | return total_size; 182 | } 183 | 184 | /* 185 | * Counts the number of used nodes in the heap's doubly linked list. 186 | */ 187 | u32 GetUsedMemoryBlockCount(struct heap_node *heap) 188 | { 189 | struct heap_node *cur_heap; 190 | u32 count_free; 191 | 192 | cur_heap = heap; 193 | count_free = 0; 194 | do 195 | { 196 | count_free += (cur_heap->used ^ TRUE) == FALSE ? 1 : 0; 197 | cur_heap = cur_heap->next; 198 | } 199 | while (cur_heap != heap); 200 | 201 | return count_free; 202 | } 203 | 204 | /* 205 | * Rounds a value up to align by 16. 206 | */ 207 | s32 GetMemoryAllocSize(s32 value) 208 | { 209 | return (value + 0x1F) & -16; 210 | } 211 | -------------------------------------------------------------------------------- /src/heap.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEAP_H 2 | #define _HEAP_H 3 | 4 | #include 5 | 6 | struct heap_node 7 | { 8 | s32 size; 9 | u8 heap_constant; 10 | u8 used; // bool 11 | struct heap_node *prev; 12 | struct heap_node *next; 13 | }; 14 | 15 | void *MakeHeap(void *ptr, u32 size); 16 | void *Malloc(struct heap_node *heap, s32 size); 17 | void Free(void *ptr); 18 | void *Realloc(struct heap_node *heap, void *mem, u32 new_size); 19 | u32 GetAllocatedHeapSize(struct heap_node *heap); 20 | u32 GetUsedMemoryBlockCount(struct heap_node *heap); 21 | s32 GetMemoryAllocSize(s32 value); 22 | 23 | #endif /* _HEAP_H */ 24 | -------------------------------------------------------------------------------- /src/heap_permanent.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "heap.h" 3 | 4 | /* 5 | * Primary heap. Never reset during gameplay. 6 | */ 7 | extern struct heap_node *perm_heap_addr; 8 | 9 | /* 10 | * Creates the "permanent" heap that is never reset. 11 | * Called once during startup. 12 | */ 13 | struct heap_node *MakePermHeap(void *ptr, u32 size) 14 | { 15 | perm_heap_addr = (struct heap_node *)MakeHeap(ptr, size); 16 | } 17 | 18 | /* 19 | * Allocates memory in the permanent heap. 20 | */ 21 | void *MallocPerm(u32 size) 22 | { 23 | Malloc(perm_heap_addr, size); 24 | } 25 | 26 | /* 27 | * Frees a memory pointer in the permanent heap. 28 | */ 29 | void FreePerm(void *ptr) 30 | { 31 | Free(ptr); 32 | } 33 | 34 | /* 35 | * Resizes a previously allocated permanent heap buffer. 36 | */ 37 | void *ReallocPerm(void *mem, u32 new_size) 38 | { 39 | return (void *)Realloc(perm_heap_addr, mem, new_size); 40 | } 41 | 42 | /* 43 | * Returns the total size of allocated buffers in the permanent heap. 44 | */ 45 | u32 GetAllocatedPermHeapSize(void) 46 | { 47 | return GetAllocatedHeapSize(perm_heap_addr); 48 | } 49 | 50 | u32 GetUsedMemoryBlockCountPerm(void) 51 | { 52 | return GetUsedMemoryBlockCount(perm_heap_addr); 53 | } 54 | -------------------------------------------------------------------------------- /src/heap_permanent.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEAP_PERM_H 2 | #define _HEAP_PERM_H 3 | 4 | #include 5 | 6 | struct heap_node *MakePermHeap(void *ptr, u32 size); 7 | void *MallocPerm(u32 size); 8 | void FreePerm(void *ptr); 9 | void *ReallocPerm(void *mem, u32 new_size); 10 | 11 | #endif /* _HEAP_PERM_H */ 12 | -------------------------------------------------------------------------------- /src/heap_temporary.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "heap.h" 3 | 4 | /* 5 | * Temporary heap. Reset occasionally during gameplay. 6 | */ 7 | 8 | extern struct heap_node *temp_heap_addr; 9 | 10 | /* 11 | * Creates the "temporary" heap. 12 | */ 13 | struct heap_node *MakeTempHeap(void *ptr, u32 size) 14 | { 15 | temp_heap_addr = (struct heap_node *)MakeHeap(ptr, size); 16 | } 17 | 18 | /* 19 | * Allocates memory in the temporary heap. 20 | */ 21 | void *MallocTemp(u32 size) 22 | { 23 | Malloc(temp_heap_addr, size); 24 | } 25 | 26 | /* 27 | * Frees a memory pointer in the temporary heap. 28 | */ 29 | void FreeTemp(void *ptr) 30 | { 31 | Free(ptr); 32 | } 33 | 34 | /* 35 | * Resizes a previously allocated temporary heap buffer. 36 | */ 37 | void *ReallocTemp(void *mem, u32 new_size) 38 | { 39 | return (void *)Realloc(temp_heap_addr, mem, new_size); 40 | } 41 | 42 | /* 43 | * Returns the total size of allocated buffers in the temporary heap. 44 | */ 45 | u32 GetAllocatedTempHeapSize(void) 46 | { 47 | return GetAllocatedHeapSize(temp_heap_addr); 48 | } 49 | 50 | u32 GetUsedMemoryBlockCountTemp(void) 51 | { 52 | return GetUsedMemoryBlockCount(temp_heap_addr); 53 | } 54 | -------------------------------------------------------------------------------- /src/heap_temporary.h: -------------------------------------------------------------------------------- 1 | #ifndef _HEAP_TEMP_H 2 | #define _HEAP_TEMP_H 3 | 4 | #include 5 | 6 | struct heap_node *MakeTempHeap(void *ptr, u32 size); 7 | void *MallocTemp(u32 size); 8 | void FreeTemp(void *ptr); 9 | void *ReallocTemp(void *mem, u32 new_size); 10 | 11 | #endif /* _HEAP_TEMP_H */ 12 | -------------------------------------------------------------------------------- /src/libultra/libc/string.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | INCLUDE_ASM(const u8 *, "libultra/libc/string", strchr, const u8* str, s32 ch); 4 | 5 | size_t strlen(const char *s) { 6 | const char *sc = s; 7 | while (*sc) { 8 | sc++; 9 | } 10 | return sc - s; 11 | } 12 | 13 | void *memcpy(void *s1, const void *s2, size_t n) { 14 | char *su1 = (char *)s1; 15 | const char *su2 = (const char *)s2; 16 | while (n > 0) { 17 | *su1++ = *su2++; 18 | n--; 19 | } 20 | return (void *)s1; 21 | } 22 | -------------------------------------------------------------------------------- /src/libultra/libultra_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _LIBULTRA_INTERNAL_H_ 2 | #define _LIBULTRA_INTERNAL_H_ 3 | #include 4 | 5 | extern OSThread *D_800A2DB0; 6 | extern OSThread *D_800A2DC0; // __osRunningThread 7 | 8 | typedef struct { 9 | u32 initialized; // probably something like initialized? 10 | OSThread *mgrThread; 11 | OSMesgQueue *unk08; 12 | OSMesgQueue *unk0c; 13 | OSMesgQueue *unk10; 14 | s32 (*dma_func)(s32, u32, void *, size_t); 15 | #ifdef VERSION_EU 16 | s32 (*edma_func)(OSPiHandle*, s32, u32, void *, size_t); 17 | #else 18 | u64 force_align; 19 | #endif 20 | } OSMgrArgs; 21 | 22 | s32 __osDisableInt(void); 23 | void __osRestoreInt(s32); 24 | void __osEnqueueAndYield(OSThread **); 25 | void __osDequeueThread(OSThread **, OSThread *); 26 | void __osEnqueueThread(OSThread **, OSThread *); 27 | OSThread *__osPopThread(OSThread **); 28 | s32 __osSiRawStartDma(s32, void *); 29 | void __osSiCreateAccessQueue(void); 30 | void __osSiGetAccess(void); 31 | void __osSiRelAccess(void); 32 | u32 __osProbeTLB(void *); 33 | void __osPiCreateAccessQueue(void); 34 | void __osPiGetAccess(void); 35 | void __osSetSR(u32); 36 | u32 __osGetSR(void); 37 | void __osSetFpcCsr(u32); 38 | s32 __osSiRawReadIo(void *, u32 *); 39 | s32 __osSiRawWriteIo(void *, u32); 40 | s32 osPiRawReadIo(u32 a0, u32 *a1); 41 | void __osSpSetStatus(u32); 42 | u32 __osSpGetStatus(void); 43 | s32 __osSpSetPc(void *); 44 | s32 __osSpDeviceBusy(void); 45 | s32 __osSiDeviceBusy(void); 46 | s32 __osSpRawStartDma(u32 dir, void *sp_ptr, void *dram_ptr, size_t size); 47 | void __osViInit(void); 48 | OSViContext *__osViGetCurrentContext(void); 49 | OSViContext *__osViGetCurrentContext2(void); 50 | void __osViSwapContext(void); 51 | void __osSetTimerIntr(u64); 52 | u64 __osInsertTimer(OSTimer *); 53 | void __osSetCompare(u32); 54 | s32 __osAiDeviceBusy(void); 55 | void __osDispatchThread(void); 56 | u32 __osGetCause(void); 57 | s32 __osAtomicDec(u32 *); 58 | #endif -------------------------------------------------------------------------------- /src/libultra/os/osCreateMesgQueue.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../libultra_internal.h" 3 | 4 | void osCreateMesgQueue(OSMesgQueue *mq, OSMesg *msgBuf, s32 count) { 5 | mq->mtqueue = (OSThread *) &D_800A2DB0; 6 | mq->fullqueue = (OSThread *) &D_800A2DB0; 7 | mq->validCount = 0; 8 | mq->first = 0; 9 | mq->msgCount = count; 10 | mq->msg = msgBuf; 11 | } 12 | -------------------------------------------------------------------------------- /src/libultra/os/osGetTime.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../libultra_internal.h" 3 | 4 | INCLUDE_ASM(OSTime, "libultra/os/osGetTime", osGetTime); 5 | -------------------------------------------------------------------------------- /src/libultra/os/osInitRdb.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../libultra_internal.h" 3 | 4 | extern s32 D_800D5554; 5 | extern s32 D_800CE174; 6 | extern s32 D_800D6A8C; 7 | extern s32 D_800CC43C; 8 | extern s32 D_800D1FC8; 9 | 10 | void osInitRdb(u8 *sendBuf, u32 sendSize) { 11 | register u32 int_disabled; 12 | 13 | sendSize >>= 2; 14 | 15 | if (((u32)sendBuf & 3) != 0) { 16 | sendBuf = ((u32)sendBuf & 3) + 4; 17 | sendSize--; 18 | } 19 | 20 | int_disabled = __osDisableInt(); 21 | 22 | D_800D5554 = sendBuf; 23 | D_800CE174 = sendSize; 24 | D_800D6A8C = 0; 25 | D_800CC43C = 0; 26 | D_800D1FC8 = 0; 27 | 28 | __osRestoreInt(int_disabled); 29 | } 30 | -------------------------------------------------------------------------------- /src/libultra/os/osJamMesg.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../libultra_internal.h" 3 | 4 | s32 osJamMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) { 5 | register s32 int_disabled; 6 | 7 | int_disabled = __osDisableInt(); 8 | 9 | while (mq->validCount >= mq->msgCount) { 10 | if (flag == OS_MESG_BLOCK) { 11 | D_800A2DC0->state = OS_STATE_WAITING; 12 | __osEnqueueAndYield(&mq->fullqueue); 13 | } 14 | else { 15 | __osRestoreInt(int_disabled); 16 | return -1; 17 | } 18 | } 19 | 20 | mq->first = (mq->first + mq->msgCount - 1) % mq->msgCount; 21 | mq->msg[mq->first] = msg; 22 | mq->validCount++; 23 | 24 | if (mq->mtqueue->next != NULL) { 25 | osStartThread(__osPopThread(&mq->mtqueue)); 26 | } 27 | 28 | __osRestoreInt(int_disabled); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/libultra/os/osRecvMesg.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../libultra_internal.h" 3 | 4 | s32 osRecvMesg(OSMesgQueue *mq, OSMesg *msg, s32 flag) { 5 | register u32 int_disabled; 6 | 7 | int_disabled = __osDisableInt(); 8 | 9 | while (!mq->validCount) { 10 | if (!flag) { 11 | __osRestoreInt(int_disabled); 12 | return -1; 13 | } 14 | D_800A2DC0->state = OS_STATE_WAITING; 15 | __osEnqueueAndYield(&mq->mtqueue); 16 | } 17 | 18 | if (msg != NULL) { 19 | *msg = *(mq->first + mq->msg); 20 | } 21 | 22 | mq->first = (mq->first + 1) % mq->msgCount; 23 | mq->validCount--; 24 | 25 | if (mq->fullqueue->next != NULL) { 26 | osStartThread(__osPopThread(&mq->fullqueue)); 27 | } 28 | 29 | __osRestoreInt(int_disabled); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /src/libultra/os/osSendMesg.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../libultra_internal.h" 3 | 4 | s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flag) { 5 | register u32 int_disabled; 6 | register s32 index; 7 | 8 | int_disabled = __osDisableInt(); 9 | 10 | while (mq->validCount >= mq->msgCount) { 11 | if (flag == OS_MESG_BLOCK) { 12 | D_800A2DC0->state = 8; 13 | __osEnqueueAndYield(&mq->fullqueue); 14 | } 15 | else { 16 | __osRestoreInt(int_disabled); 17 | return -1; 18 | } 19 | } 20 | 21 | index = (mq->first + mq->validCount) % mq->msgCount; 22 | mq->msg[index] = msg; 23 | mq->validCount++; 24 | 25 | if (mq->mtqueue->next != NULL) { 26 | osStartThread(__osPopThread(&mq->mtqueue)); 27 | } 28 | 29 | __osRestoreInt(int_disabled); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /src/libultra/os/osSetTimer.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../libultra_internal.h" 3 | 4 | INCLUDE_ASM(s32, "libultra/os/osSetTimer", osSetTimer, OSTimer* timer, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg); 5 | -------------------------------------------------------------------------------- /src/libultra/os/osVirtualToPhysical.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #define K0BASE 0x80000000 4 | #define K1BASE 0xA0000000 5 | #define K2BASE 0xC0000000 6 | 7 | #define IS_KSEG0(x) ((u32)(x) >= (u32)K0BASE && (u32)(x) < (u32)K1BASE) 8 | #define IS_KSEG1(x) ((u32)(x) >= (u32)K1BASE && (u32)(x) < (u32)K2BASE) 9 | 10 | #define K0_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) 11 | #define K1_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) 12 | 13 | INCLUDE_ASM(u32, "libultra/os/osVirtualToPhysical", osVirtualToPhysical, void *addr); 14 | 15 | // FIXME: There's an addu instead of a subu. But the code is right? 16 | // u32 osVirtualToPhysical(void *addr) 17 | // { 18 | // if (IS_KSEG0(addr)) { 19 | // return K0_TO_PHYS(addr); 20 | // } 21 | // else if (IS_KSEG1(addr)) { 22 | // return K1_TO_PHYS(addr); 23 | // } 24 | // else { 25 | // return __osProbeTLB(addr); 26 | // } 27 | // } 28 | 29 | // u32 osVirtualToPhysical(void *addr) { 30 | // if ((u32) addr >= 0x80000000 && (u32) addr < 0xa0000000) { 31 | // return ((u32) addr & 0x1fffffff); 32 | // } else if ((u32) addr >= 0xa0000000 && (u32) addr < 0xc0000000) { 33 | // return ((u32) addr & 0x1fffffff); 34 | // } else { 35 | // return __osProbeTLB(addr); 36 | // } 37 | // } 38 | -------------------------------------------------------------------------------- /src/mainfs.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "heap_permanent.h" 3 | #include "heap_temporary.h" 4 | 5 | extern s16 D_800C9520[]; 6 | extern s16 D_800D0590[]; 7 | extern s16 D_800D10F8[]; 8 | extern s16 D_800D1350[]; 9 | extern s16 D_800D5546[]; 10 | 11 | void func_80009880() { 12 | s16 i; 13 | 14 | for (i = 0; i < 4; ++i) { 15 | D_800D5546[i] = D_800D1350[i] = D_800C9520[i] = D_800D0590[i] = D_800D10F8[i] = 0; 16 | } 17 | } 18 | 19 | INCLUDE_ASM(s32, "mainfs", func_800098FC); 20 | 21 | // Likely file break for mainfs.c 22 | 23 | // 16 byte portion of a directory or file table, which is initially read from ROM. 24 | struct mainfs_table_header { 25 | s32 count; 26 | s32 offsets[3]; // Enough to pad to size 16 27 | }; 28 | 29 | struct mainfs_entry_info { 30 | u8 *file_bytes; 31 | s32 size; 32 | s32 compression_type; 33 | }; 34 | 35 | extern void *D_800ABFC0; // FS ROM location 36 | extern u32 D_800ABFC4; // Directory count 37 | extern s32 *D_800ABFC8; // Directory offset table pointer. 38 | 39 | extern void *D_800ABFCC; // FS ROM location (copy) 40 | extern u32 D_800ABFD0; // Directory count (copy) 41 | extern s32 *D_800ABFD4; // Directory offset table pointer (copy) 42 | 43 | extern struct mainfs_table_header D_800ABFE0; 44 | 45 | extern void *func_80009D4C(s32 type, s32 index); 46 | extern void *func_80009DA8(s32 type, s32 index); 47 | 48 | // Initialize file system from ROM. 49 | void func_80009AC0(void *fs_rom_loc) { 50 | s32 dir_table_size; 51 | struct mainfs_table_header *mainfs_table_header; 52 | 53 | D_800ABFC0 = fs_rom_loc; 54 | mainfs_table_header = &D_800ABFE0; 55 | HuRomDmaRead(fs_rom_loc, mainfs_table_header, 16); // ExecRomCopy 56 | D_800ABFC4 = mainfs_table_header->count; 57 | dir_table_size = mainfs_table_header->count * 4; 58 | D_800ABFC8 = (s32 *)MallocPerm(dir_table_size); 59 | HuRomDmaRead(fs_rom_loc + 4, D_800ABFC8, dir_table_size); 60 | D_800ABFCC = D_800ABFC0; 61 | D_800ABFD0 = D_800ABFC4; 62 | D_800ABFD4 = D_800ABFC8; 63 | } 64 | 65 | void func_80009B64(s32 type, s32 index, struct mainfs_entry_info *info) { 66 | struct mainfs_table_header *mainfs_table_header; 67 | 68 | mainfs_table_header = &D_800ABFE0; 69 | 70 | switch (type) { 71 | case 0x2F: 72 | info->file_bytes = (u8 *)D_800ABFC0 + D_800ABFC8[index]; 73 | break; 74 | case 0x2E: 75 | info->file_bytes = (u8 *)D_800ABFCC + D_800ABFD4[index]; 76 | break; 77 | } 78 | 79 | HuRomDmaRead(info->file_bytes, mainfs_table_header, 16); // ExecRomCopy 80 | info->file_bytes += 8; 81 | info->size = mainfs_table_header->count; 82 | info->compression_type = mainfs_table_header->offsets[0]; 83 | } 84 | 85 | /** 86 | * Reads a file from the main filesystem and decodes it. 87 | * File is in the permanent heap. 88 | */ 89 | void *ReadMainFS(s32 dirAndFile) { 90 | u32 dir; 91 | u32 file; 92 | 93 | dir = dirAndFile >> 16; 94 | file = dirAndFile & 0xFFFF; 95 | 96 | if (dir < D_800ABFC4) { 97 | func_80009EAC(0x2F, dir); 98 | 99 | if (file < D_800ABFD0) { 100 | return func_80009D4C(0x2E, file); 101 | } 102 | } 103 | 104 | return NULL; 105 | } 106 | 107 | /** 108 | * Reads a file from the main filesystem and decodes it. 109 | * Files is in the temporary heap. 110 | */ 111 | void *func_80009C74(s32 dirAndFile) { 112 | u32 dir; 113 | u32 file; 114 | 115 | dir = dirAndFile >> 16; 116 | file = dirAndFile & 0xFFFF; 117 | 118 | if (dir < D_800ABFC4) { 119 | func_80009EAC(0x2F, dir); 120 | 121 | if (file < D_800ABFD0) { 122 | return func_80009DA8(0x2E, file); 123 | } 124 | } 125 | 126 | return NULL; 127 | } 128 | 129 | void *func_80009CD8(s32 dirAndFile, s32 arg1) { 130 | u32 dir; 131 | u32 file; 132 | 133 | dir = dirAndFile >> 16; 134 | file = dirAndFile & 0xFFFF; 135 | 136 | if (dir < D_800ABFC4) { 137 | func_80009EAC(0x2F, dir); 138 | 139 | if (file < D_800ABFD0) { 140 | return func_80009E04(0x2E, file, arg1); 141 | } 142 | } 143 | 144 | return NULL; 145 | } 146 | 147 | /** 148 | * Read file, allocate space in perm heap, decode it. 149 | */ 150 | void *func_80009D4C(s32 type, s32 index) { 151 | struct mainfs_entry_info info; 152 | void *ret; 153 | 154 | func_80009B64(type, index, &info); 155 | ret = MallocPerm((info.size + 1) & -2); 156 | if (ret != NULL) { 157 | HuDecode(info.file_bytes, ret, info.size, info.compression_type); 158 | } 159 | return ret; 160 | } 161 | 162 | /** 163 | * Read file, allocate space in temp heap, decode it. 164 | */ 165 | void *func_80009DA8(s32 type, s32 index) { 166 | struct mainfs_entry_info info; 167 | void *ret; 168 | 169 | func_80009B64(type, index, &info); 170 | ret = MallocTemp((info.size + 1) & -2); 171 | if (ret != NULL) { 172 | HuDecode(info.file_bytes, ret, info.size, info.compression_type); 173 | } 174 | return ret; 175 | } 176 | 177 | INCLUDE_ASM(s32, "mainfs", func_80009E04); 178 | 179 | /** 180 | * Free file previously obtained through ReadMainFS. 181 | */ 182 | void FreeMainFS(void *file) { 183 | if (file != NULL) { 184 | FreePerm(file); 185 | } 186 | } 187 | 188 | void func_80009E8C(void *file) { 189 | if (file != NULL) { 190 | FreePerm(file); //! Should be FreeTemp, but not functionally problematic. 191 | } 192 | } 193 | 194 | INCLUDE_ASM(s32, "mainfs", func_80009EAC); 195 | 196 | struct mainfs_something { 197 | u16 unk0; 198 | s32 unk4; 199 | void *unk8; 200 | u16 unkC; 201 | u16 unkE; 202 | s32 unk10; 203 | s32 unk14; 204 | }; // sizeof === 0x18 205 | 206 | void *func_80009F64(s32 type, s32 index) { 207 | struct mainfs_something *temp_s0; 208 | struct mainfs_entry_info info; 209 | 210 | temp_s0 = MallocPerm(sizeof(struct mainfs_something)); 211 | if (temp_s0 == 0) { 212 | return NULL; 213 | } 214 | 215 | func_80009B64(type, index, &info); 216 | temp_s0->unk4 = info.size; 217 | temp_s0->unk0 = (u16)info.compression_type; 218 | temp_s0->unk8 = MallocPerm(0x400); 219 | temp_s0->unkC = 1; 220 | temp_s0->unkE = 0; 221 | temp_s0->unk10 = temp_s0->unk14 = info.file_bytes; 222 | return temp_s0; 223 | } 224 | 225 | void func_80009FF8(struct mainfs_something *arg0) { 226 | FreePerm(arg0->unk8); 227 | FreePerm(arg0); 228 | } 229 | 230 | INCLUDE_ASM(s32, "mainfs", func_8000A028); 231 | 232 | INCLUDE_ASM(s32, "mainfs", func_8000A0D4); 233 | 234 | INCLUDE_ASM(s32, "mainfs", func_8000A150); 235 | -------------------------------------------------------------------------------- /src/object.h: -------------------------------------------------------------------------------- 1 | #ifndef _OBJECT_H 2 | #define _OBJECT_H 3 | 4 | #include 5 | 6 | struct coords_3d { 7 | f32 x; 8 | f32 y; 9 | f32 z; 10 | }; 11 | 12 | struct object { 13 | /*0x00*/ struct object *prev; // may be NULL 14 | /*0x04*/ struct object *next; 15 | /*0x08*/ u8 unk8; 16 | /*0x09*/ s8 unk9; 17 | /*0x0A*/ u16 unkA; 18 | 19 | /*0x0C*/ struct coords_3d coords; 20 | 21 | f32 unk18; // Rotation? 22 | f32 unk1C; 23 | f32 unk20; 24 | 25 | f32 unk24; // Scale? 26 | f32 unk28; 27 | f32 unk2C; 28 | 29 | f32 unk30; 30 | f32 unk34; 31 | f32 unk38; 32 | 33 | struct object_indirect *unk3C; 34 | struct object_indirect *unk40; // is type right? 35 | s16 unk44; 36 | s16 unk46; 37 | }; 38 | 39 | // What is this, in relation to object? 40 | struct object_indirect { 41 | s16 unk0; 42 | s16 unk2; 43 | s16 unk4; 44 | s16 unk6; 45 | s16 unk8; 46 | s16 unkA; 47 | s16 unkC; 48 | s16 unkE; 49 | s32 unk10; 50 | 51 | void *unk14; 52 | 53 | f32 unk18; 54 | f32 unk1C; 55 | f32 unk20; 56 | 57 | // Rotation? 58 | f32 unk24; 59 | f32 unk28; 60 | f32 unk2C; 61 | 62 | f32 unk30; 63 | f32 unk34; 64 | f32 unk38; 65 | 66 | u16 unk3C; // count of unk40 67 | s16 *unk40; 68 | u16 unk44; // count of unk48 69 | s16 *unk48; 70 | 71 | s32 unk4C; 72 | s32 unk50; 73 | s32 unk54; 74 | s32 unk58; 75 | struct object_indirect3 *unk5C; 76 | }; // sizeof 0x60 77 | 78 | struct object_indirect3 { 79 | struct object *unk0; 80 | f32 unk4; 81 | }; 82 | 83 | 84 | #endif /* _OBJECT_H */ 85 | -------------------------------------------------------------------------------- /src/overlays/board_chillywaters/chillywaters.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../process.h" 3 | #include "../../47D60.h" 4 | #include "../../1A580.h" 5 | 6 | struct unkfunc_801059D0 { 7 | f32 unk0; 8 | f32 unk4; 9 | u32 unk8; 10 | u32 unkC; 11 | u32 unk10; 12 | struct process *unk14; 13 | }; 14 | 15 | s32 func_80105A64_31B5D4(); 16 | 17 | void func_801059D0_31B540(s16 arg0, s16 arg1) { 18 | struct process *process; 19 | struct unkfunc_801059D0 *temp_v0; 20 | 21 | process = InitProcess(&func_80105A64_31B5D4, 0x3F00U, 0x1000, 0); 22 | temp_v0 = (struct unkfunc_801059D0 *)HuMemAllocTag(0x18, 0x7918); 23 | process->user_data = temp_v0; 24 | temp_v0->unk14 = process; 25 | temp_v0->unk0 = (f32)arg0; 26 | temp_v0->unk4 = (f32)arg1; 27 | } 28 | 29 | INCLUDE_ASM(s32, "overlays/board_chillywaters/chillywaters", func_80105A64_31B5D4); 30 | 31 | INCLUDE_ASM(s32, "overlays/board_chillywaters/chillywaters", func_80105DB8_31B928); 32 | 33 | INCLUDE_ASM(s32, "overlays/board_chillywaters/chillywaters", func_80105E20_31B990); 34 | -------------------------------------------------------------------------------- /src/overlays/board_chillywaters/chillywaters_main.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../board.h" 3 | #include "../../365E0.h" 4 | 5 | extern s16 D_800A1764; 6 | extern void func_80107BF4_31D764(); 7 | extern void func_80107C2C_31D79C(); 8 | extern void func_80108014_31DB84(); 9 | extern void func_80108098_31DC08(); 10 | extern void func_8011C58C_3320FC(); 11 | 12 | struct overlay_entrypoint chillywaters_entrypoints[] = { 13 | { 0, func_80107BF4_31D764 }, 14 | { 1, func_80107C2C_31D79C }, 15 | { 2, func_80108014_31DB84 }, 16 | { 3, func_80108098_31DC08 }, 17 | { 4, func_8011C58C_3320FC }, 18 | { -1, NULL } 19 | }; 20 | 21 | void func_801059A0_31B510() { 22 | func_800359E0(chillywaters_entrypoints, D_800A1764); 23 | } 24 | -------------------------------------------------------------------------------- /src/overlays/board_spinydesert/spinydesert_main.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | #include "common.h" 4 | #include "../../board.h" 5 | #include "../../365E0.h" 6 | 7 | extern s16 D_800A1764; 8 | extern void func_80107934_3507A4(); 9 | extern void func_80107970_3507E0(); 10 | extern void D_80107CA4_350B14(); 11 | extern void func_80107D28_350B98(); 12 | extern void func_8011B41C_36428C(); 13 | 14 | struct overlay_entrypoint spinydesert_entrypoints[] = { 15 | { 0, func_80107934_3507A4 }, 16 | { 1, func_80107970_3507E0 }, 17 | { 2, D_80107CA4_350B14 }, 18 | { 3, func_80107D28_350B98 }, 19 | { 4, func_8011B41C_36428C }, 20 | { -1, NULL } 21 | }; 22 | 23 | void func_801059A0_34E810() { 24 | func_800359E0(spinydesert_entrypoints, D_800A1764); 25 | } 26 | -------------------------------------------------------------------------------- /src/overlays/debug_message_check/4F69F0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../object.h" 3 | #include "../../process.h" 4 | #include "../../47D60.h" 5 | 6 | /* Message Check */ 7 | 8 | extern u16 D_800A1760; 9 | extern s16 D_800A1786; 10 | extern u8 D_800CD280; 11 | extern f32 D_800CE1C8; 12 | extern f32 D_800D138C; 13 | extern u16 D_800D530C; 14 | extern f32 D_800D6AC0; 15 | 16 | 17 | extern void func_80019568(s32, f32, f32, f32); 18 | extern void func_8001C0C4(s32, s32, s32, f32); 19 | extern void func_8004819C(s32); 20 | extern void D_8004B340(); 21 | extern s32 GetFadeStatus(); 22 | 23 | extern u16 D_80106500_4F7550; 24 | extern void func_80105B50_4F6BA0(); 25 | extern void func_80106334_4F7384(); 26 | void func_80106390_4F73E0(); 27 | extern s32 func_801063BC_4F740C(); 28 | extern s32 func_80105B8C_4F6BDC(); 29 | 30 | void func_801059A0_4F69F0() { 31 | struct object_indirect *temp_v0; 32 | 33 | func_80012220(1); 34 | func_8001FE20(1); 35 | func_800142A0(0x19); 36 | InitObjSys(0x33, 10); 37 | func_8005A6B0(); 38 | temp_v0 = func_80047620(0x7FDA, 0, 0, -1, D_8004B340); 39 | D_800D6AC0 = 100.0f; 40 | D_800CE1C8 = 600.0f; 41 | D_800D138C = -30.0f; 42 | func_80047B38(temp_v0, 0xA0); 43 | if (D_800A1760 != 0) { 44 | D_800A1760 = 0; 45 | func_8004DEC8(D_800A1786); 46 | D_800A1786 = -1; 47 | } 48 | func_80047620(0x2710, 0, 0, -1, func_80106334_4F7384); 49 | func_80019490(3); 50 | func_80019514(0, 0x78, 0x78, 0x78); 51 | func_80019514(1, 0x40, 0x40, 0x60); 52 | func_80019568(1, -100.0f, 100.0f, 100.0f); 53 | func_80019514(2, 0, 0, 0); 54 | func_80019514(3, 0, 0, 0); 55 | InitProcess(func_80105B50_4F6BA0, 0x3F00, 0x800, 0); 56 | InitProcess(func_801063BC_4F740C, 0x3F00, 0x800, 0); 57 | InitFadeIn(0, 0); 58 | D_800CD280 = 1; 59 | func_8001F38C(0xFF, 0xFF, 0xFF); 60 | } 61 | 62 | void func_80105B50_4F6BA0() { 63 | func_80105B8C_4F6BDC(); 64 | D_80106500_4F7550 = 1; 65 | func_8005F524(); 66 | while (1) { 67 | SleepVProcess(); 68 | } 69 | } 70 | 71 | INCLUDE_ASM(s32, "overlays/debug_message_check/4F69F0", func_80105B8C_4F6BDC); 72 | 73 | void func_80106334_4F7384(struct unk80047620 *arg0) { 74 | if ((D_80106500_4F7550 != 0) || (D_800D530C != 0)) { 75 | InitFadeOut(0, 8); 76 | arg0->unk14 = &func_80106390_4F73E0; 77 | func_8004A994(0x3C); 78 | } 79 | } 80 | 81 | void func_80106390_4F73E0() { 82 | if (GetFadeStatus() == 0) { 83 | func_8004819C(1); 84 | } 85 | } 86 | 87 | INCLUDE_ASM(s32, "overlays/debug_message_check/4F69F0", func_801063BC_4F740C); 88 | // void D_801063BC_4F740C() { 89 | // s16 temp_s0; 90 | // s32 temp_s3; 91 | // s16 phi_s1; 92 | 93 | // temp_s2 = func_8000B108(0x000700A0, 0x2A9); 94 | // temp_s0 = func_8000B108(0x00070001, 8); 95 | // temp_s1 = temp_s2; 96 | // func_8001C5B4(temp_s1, temp_s0); 97 | // func_8001C0C4(temp_s1, 0, 0, 100.0f); 98 | // temp_s3 = func_80016784(temp_s1, 2); 99 | // phi_s1 = (u16)0; 100 | 101 | // while (1) { 102 | // SleepVProcess(); 103 | // if (D_80106500 == 0) { 104 | // temp_s0_2 = phi_s1; 105 | // func_80016FB4(temp_s2, temp_s3, temp_s0_2); 106 | // phi_s1 = (-(s32) ((s32) temp_s0_2 < (s32) ((((temp_s0 * 0xC0) + D_800D03F8)->unk2 * 0x18) + D_800CCF58)->unk2) & phi_s1) + 2; 107 | // continue; 108 | // } 109 | // break; 110 | // } 111 | 112 | // func_80017320(temp_s3); 113 | // while (1) { 114 | // SleepVProcess(); 115 | // } 116 | // } -------------------------------------------------------------------------------- /src/overlays/intro/intro.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../47D60.h" 3 | 4 | extern s16 func_8000B838(s32); 5 | extern s32 func_8000BFEC(s16, s32, s32); 6 | extern void func_8000BBD4(u16, s32, s32); 7 | extern void func_8000BB54(u16); 8 | extern void func_8000BCC8(u16, s32); 9 | extern void func_8000C184(u16); 10 | 11 | extern u16 D_800D530C; 12 | extern u16 D_800D5558; 13 | extern u8 D_800D6A58; 14 | 15 | static s32 D_80105F00_22E660 = 0; 16 | static s32 D_80105F04_2A1994 = 0; 17 | 18 | static struct process *D_80105F10; 19 | 20 | extern void func_80105BA4_3D7354(); 21 | extern void func_80105C80_3D7430(); 22 | extern void func_80105AF0_3D72A0(); 23 | extern void func_80105C14_3D73C4(); 24 | 25 | void func_801059D0_3D7180() { 26 | func_80012220(1); 27 | InitObjSys(0x10, 4); 28 | D_800D6A58 = 1; 29 | if (D_80105F00_22E660 == 0) { 30 | func_80036080(); 31 | D_80105F10 = InitProcess(&func_80105C80_3D7430, 0xA, 0, 0); 32 | func_80047620(0x3E8, 0, 0, -1, func_80105AF0_3D72A0); 33 | } 34 | else { 35 | D_80105F10 = InitProcess(&func_80105C80_3D7430, 0xA, 0, 0); 36 | func_80047620(0x3E8, 0, 0, -1, func_80105AF0_3D72A0); 37 | func_80047620(0xA, 0, 0, -1, func_80105C14_3D73C4); 38 | } 39 | } 40 | 41 | // entrypoint 0 42 | void func_80105AAC_3D725C() { 43 | D_80105F00_22E660 = 0; 44 | func_801059D0_3D7180(); 45 | } 46 | 47 | // entrypoint 1 48 | void func_80105ACC_3D727C() { 49 | D_80105F00_22E660 = 1; 50 | func_801059D0_3D7180(); 51 | } 52 | 53 | void func_80105AF0_3D72A0(struct unk80047620 *arg0) { 54 | if (D_800D530C != 0 || D_80105F04_2A1994 != 0) { 55 | if (GetFadeStatus() == 0) { 56 | func_800620C8(0, 0, 0); 57 | InitFadeOut(0xB, 9); 58 | arg0->unk14 = func_80105BA4_3D7354; 59 | if (D_800D530C != 0) { 60 | if (GetFadeStatus() == 0) { 61 | func_800620C8(0, 0, 0); 62 | InitFadeOut(0xB, 9); 63 | arg0->unk14 = func_80105BA4_3D7354; 64 | } 65 | } 66 | } 67 | } 68 | } 69 | 70 | void func_80105BA4_3D7354() { 71 | if (GetFadeStatus() == 0) { 72 | func_8005F524(); 73 | if (D_80105F00_22E660 != 0) { 74 | func_80048228(0x7A, 2, 0x92); 75 | return; 76 | } 77 | func_80048128(0x7A, 2, 0x92); 78 | func_80048460(1, 0x7A, 2, 0x92); 79 | } 80 | } 81 | 82 | void func_80105C14_3D73C4() { 83 | s32 temp_s0; 84 | s32 temp_v0; 85 | 86 | if (GetFadeStatus() == 0) { 87 | temp_s0 = func_800360B8(); 88 | if (temp_s0 == 1) { 89 | if (func_8000985C(0) != 0) { 90 | temp_v0 = D_800D5558 & 0x1000; 91 | if (temp_v0 != 0) { 92 | D_80105F04_2A1994 = temp_s0; 93 | } 94 | } 95 | } 96 | } 97 | } 98 | 99 | void func_80105C80_3D7430() { 100 | s16 temp_s2; 101 | s32 temp_s1; 102 | 103 | temp_s2 = func_8000B838(0x00110000); 104 | temp_s1 = func_8000BFEC(temp_s2, 0, 1); 105 | func_8000BBD4(temp_s1, 320 / 2, 240 / 2); 106 | func_8000BB54(temp_s1); 107 | func_8000BCC8(temp_s1, 0xFFFF); 108 | 109 | InitFadeIn(0xB, 0x1E); 110 | while (GetFadeStatus() != 0) { 111 | SleepVProcess(); 112 | } 113 | SleepProcess(0x25); 114 | 115 | InitFadeOut(0xB, 9); 116 | while (GetFadeStatus() != 0) { 117 | SleepVProcess(); 118 | } 119 | 120 | func_8000C184(temp_s1); 121 | func_80055670(temp_s2); 122 | SleepProcess(9); 123 | 124 | temp_s2 = func_8000B838(0x00110001); 125 | temp_s1 = func_8000BFEC(temp_s2, 0, 1); 126 | func_8000BBD4(temp_s1, 320 / 2, 240 / 2); 127 | func_8000BB54(temp_s1); 128 | func_8000BCC8(temp_s1, 0xFFFF); 129 | 130 | InitFadeIn(0xB, 9); 131 | while (GetFadeStatus() != 0) { 132 | SleepVProcess(); 133 | } 134 | SleepProcess(0x25); 135 | 136 | InitFadeOut(0xB, 9); 137 | while (GetFadeStatus() != 0) { 138 | SleepVProcess(); 139 | } 140 | 141 | func_8000C184(temp_s1); 142 | func_80055670(temp_s2); 143 | SleepProcess(9); 144 | 145 | temp_s2 = func_8000B838(0x00110002); 146 | temp_s1 = func_8000BFEC(temp_s2, 0, 1); 147 | func_8000BBD4(temp_s1, 320 / 2, 240 / 2); 148 | func_8000BB54(temp_s1); 149 | func_8000BCC8(temp_s1, 0xFFFF); 150 | 151 | InitFadeIn(0xB, 9); 152 | while (GetFadeStatus() != 0) { 153 | SleepVProcess(); 154 | } 155 | SleepProcess(0x25); 156 | 157 | D_800D530C = 1; 158 | 159 | while (1) { 160 | SleepVProcess(); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /src/overlays/intro/intro_main.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../365E0.h" 3 | 4 | extern s16 D_800A1764; 5 | 6 | extern void func_80105AAC_3D725C(); 7 | extern void func_80105ACC_3D727C(); 8 | 9 | static struct overlay_entrypoint intro_entrypoints[] = { 10 | { 0, func_80105AAC_3D725C }, 11 | { 1, func_80105ACC_3D727C }, 12 | { -1, NULL } 13 | }; 14 | 15 | void func_801059A0_3D7150() { 16 | func_800359E0(intro_entrypoints, D_800A1764); 17 | } 18 | -------------------------------------------------------------------------------- /src/overlays/minigame_results/4E6DC0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../board.h" 3 | 4 | extern s32 D_8010AD0C_4EC12C[]; 5 | 6 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_801059A0_4E6DC0); 7 | 8 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80105C08_4E7028); 9 | 10 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80105CE8_4E7108); 11 | 12 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80106A80_4E7EA0); 13 | 14 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80106C80_4E80A0); 15 | 16 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80106D50_4E8170); 17 | 18 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80106D88_4E81A8); 19 | 20 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80106DB8_4E81D8); 21 | 22 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80106DE8_4E8208); 23 | 24 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80106F40_4E8360); 25 | 26 | void func_80106FC8_4E83E8() { 27 | s32 phi_a0; 28 | struct strCD058 *cd058 = &D_800CD058; 29 | 30 | func_800E6630_FA250(&bin_hvq_ROM_START); 31 | phi_a0 = 0x17; 32 | if ((cd058->unk0 & 2) == 0) { 33 | phi_a0 = D_8010AD0C_4EC12C[cd058->current_board_index]; 34 | } 35 | func_800E6720_FA340(phi_a0, 0); 36 | func_80107024_4E8444(); 37 | } 38 | 39 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80107024_4E8444); 40 | 41 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_8010705C_4E847C); 42 | 43 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80107188_4E85A8); 44 | 45 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80107234_4E8654); 46 | 47 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80107650_4E8A70); 48 | 49 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80107800_4E8C20); 50 | 51 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_801079B0_4E8DD0); 52 | 53 | INCLUDE_ASM(s32, "overlays/minigame_results/4E6DC0", func_80107A58_4E8E78); 54 | -------------------------------------------------------------------------------- /src/overlays/overlay100/460790.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../board.h" 3 | #include "../../object.h" 4 | 5 | struct strD_80107530_3C7EA0 6 | { 7 | struct coords_3d unk0; 8 | struct coords_3d unkC; 9 | }; 10 | 11 | extern struct strD_80107530_3C7EA0 D_80109550; 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_801059A0_460790); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80105B3C_46092C); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80105CBC_460AAC); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80105E20_460C10); 20 | 21 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80105FE8_460DD8); 22 | 23 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80106070_460E60); 24 | 25 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_801061C4_460FB4); 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80106294_461084); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80106350_461140); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_801066B8_4614A8); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80106CB4_461AA4); 34 | 35 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80106D18_461B08); 36 | 37 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80108FDC_463DCC); 38 | 39 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_80109050_463E40); 40 | 41 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_801090AC_463E9C); 42 | 43 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_801090F8_463EE8); 44 | 45 | INCLUDE_ASM(s32, "overlays/overlay100/460790", func_8010911C_463F0C); 46 | 47 | void func_80109158_463F48() 48 | { 49 | struct coords_3d temp_s0[2]; 50 | s32 *s0arr = (s32 *)(&temp_s0); 51 | temp_s0[0] = D_80109550.unk0; 52 | temp_s0[1] = D_80109550.unkC; 53 | func_80012220(1, &D_80109550); 54 | func_800E4F50_CCD20(&bin_hvq_ROM_START); 55 | func_800E52DC_CD0AC(s0arr[D_800CD058.current_board_index]); 56 | } 57 | 58 | void func_801091DC_463FCC() 59 | { 60 | func_800E52F8_CD0C8(); 61 | func_800E5000_CCDD0(); 62 | } 63 | -------------------------------------------------------------------------------- /src/overlays/overlay101/464360.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_801059A0_464360); 4 | 5 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80105B54_464514); 6 | 7 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80105CD4_464694); 8 | 9 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80105E38_4647F8); 10 | 11 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80106000_4649C0); 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_8010610C_464ACC); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_801061DC_464B9C); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80106224_464BE4); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_801062E0_464CA0); 20 | 21 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80106808_4651C8); 22 | 23 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_8010686C_46522C); 24 | 25 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80106BF0_4655B0); 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80108774_467134); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_801087B4_467174); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80108810_4671D0); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80108854_467214); 34 | 35 | INCLUDE_ASM(s32, "overlays/overlay101/464360", func_80108880_467240); 36 | 37 | void func_801088C4_467284() { 38 | func_80012220(1); 39 | func_80019514(1, 0xFF, 0xFF, 0xFF); 40 | func_800E4F50_CCD20(&bin_hvq_ROM_START); 41 | func_800E52DC_CD0AC(0x1E); 42 | } 43 | 44 | void func_80108908_4672C8() { 45 | func_800E52F8_CD0C8(); 46 | func_800E5000_CCDD0(); 47 | } -------------------------------------------------------------------------------- /src/overlays/overlay115/4F01F0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | // References hvq rom start 4 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_801059A0_4F01F0); 5 | 6 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80105E90_4F06E0); 7 | 8 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80105FD4_4F0824); 9 | 10 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80106054_4F08A4); 11 | 12 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80106080_4F08D0); 13 | 14 | void func_80106270_4F0AC0(void) { 15 | } 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80106278_4F0AC8); 18 | 19 | void func_80106544_4F0D94(void) { 20 | } 21 | 22 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_8010654C_4F0D9C); 23 | 24 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80106560_4F0DB0); 25 | 26 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80106574_4F0DC4); 27 | 28 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80106730_4F0F80); 29 | 30 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80106744_4F0F94); 31 | 32 | INCLUDE_ASM(s32, "overlays/overlay115/4F01F0", func_80106850_4F10A0); 33 | -------------------------------------------------------------------------------- /src/overlays/overlay116/4F3780.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../board.h" 3 | 4 | extern s32 D_80108908_4F66E8[]; 5 | 6 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_801059A0_4F3780); 7 | 8 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_80105CAC_4F3A8C); 9 | 10 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_80105E0C_4F3BEC); 11 | 12 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_80105E64_4F3C44); 13 | 14 | void func_80105EF4_4F3CD4() { 15 | s32 phi_a0; 16 | struct strCD058 *cd058 = &D_800CD058; 17 | 18 | func_800E6630_FA250(&bin_hvq_ROM_START); 19 | phi_a0 = 0x17; 20 | if ((cd058->unk0 & 2) == 0) { 21 | phi_a0 = D_80108908_4F66E8[cd058->current_board_index]; 22 | } 23 | func_800E6720_FA340(phi_a0, 0); 24 | func_80105F50_4F3D30(); 25 | } 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_80105F50_4F3D30); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_80105F78_4F3D58); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_801060A4_4F3E84); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_80106660_4F4440); 34 | 35 | void func_80106908_4F46E8(void) { 36 | } 37 | 38 | void func_80106910_4F46F0(void) { 39 | } 40 | 41 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_80106918_4F46F8); 42 | 43 | INCLUDE_ASM(s32, "overlays/overlay116/4F3780", func_801069FC_4F47DC); 44 | -------------------------------------------------------------------------------- /src/overlays/overlay124/5486A0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../process.h" 3 | #include "../../47D60.h" 4 | 5 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010BE20_5486A0); 6 | 7 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010BF84_548804); 8 | 9 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010C680_548F00); 10 | 11 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010C8F4_549174); 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010CD74_5495F4); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010CFD4_549854); 16 | 17 | // References hvq rom start. 18 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010D1E8_549A68); 19 | 20 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010D450_549CD0); 21 | 22 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010D580_549E00); 23 | 24 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010D998_54A218); 25 | 26 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010DE50_54A6D0); 27 | 28 | void func_8010DEDC_54A75C(s32 *arg0, s32 arg1) { 29 | *arg0 = arg1; 30 | } 31 | 32 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010DEE4_54A764); 33 | 34 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010DEF4_54A774); 35 | 36 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010DF04_54A784); 37 | 38 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010DF0C_54A78C); 39 | 40 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010DF24_54A7A4); 41 | 42 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010DF2C_54A7AC); 43 | 44 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010DF34_54A7B4); 45 | 46 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010F04C_54B8CC); 47 | 48 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010F3E4_54BC64); 49 | 50 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010F4C4_54BD44); 51 | 52 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010F9D4_54C254); 53 | 54 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010FB28_54C3A8); 55 | 56 | INCLUDE_ASM(s32, "overlays/overlay124/5486A0", func_8010FB88_54C408); 57 | -------------------------------------------------------------------------------- /src/overlays/overlay125/54F360.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | extern s8 D_800CD280; 4 | extern s16 D_8010A910; 5 | extern s16 D_8010A912_552C82; 6 | extern s16 D_8010A914; 7 | extern void *D_8010AB9C_552F0C; 8 | extern s16 D_8010AC28; 9 | extern s16 D_8010AC2A; 10 | 11 | extern void func_800E8180_CFF50(f32, f32); 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80106FF0_54F360); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80107030_54F3A0); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_801070D8_54F448); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80107140_54F4B0); 20 | 21 | // References hvq rom start 22 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80107204_54F574); 23 | 24 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80107920_54FC90); 25 | 26 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010818C_5504FC); 27 | 28 | void func_8010822C_55059C() 29 | { 30 | s16 sp10; 31 | 32 | D_800CD280 = 0; 33 | func_801060D0_54E440(&D_8010AB9C_552F0C); 34 | D_8010A912_552C82 = 1; 35 | func_800E4F50_CCD20(&bin_hvq_ROM_START); 36 | func_800E52DC_CD0AC(0x20); 37 | func_800E8180_CFF50(1000.0f, 10000.0f); 38 | D_8010AC2A = 0xB; 39 | InitFadeIn(0xB, 0x10); 40 | 41 | while (GetFadeStatus() != 0) 42 | { 43 | SleepVProcess(); 44 | } 45 | func_8010818C_5504FC(&sp10, -1); 46 | while ((s32)sp10 >= -1) 47 | { 48 | SleepVProcess(); 49 | } 50 | 51 | D_8010AC2A = 0xB; 52 | D_8010AC28 = 0x36; 53 | D_8010A914 = 2; 54 | D_8010A910 = 1; 55 | 56 | while (TRUE) 57 | { 58 | SleepVProcess(); 59 | } 60 | } 61 | 62 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010832C_55069C); 63 | 64 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_801083A4_550714); 65 | 66 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_801085E8_550958); 67 | 68 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_801086E4_550A54); 69 | 70 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80108884_550BF4); 71 | 72 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80108AC0_550E30); 73 | 74 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80108CB8_551028); 75 | 76 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80108D04_551074); 77 | 78 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80108D34_5510A4); 79 | 80 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_80108F0C_55127C); 81 | 82 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010A370_5526E0); 83 | 84 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010A4A4_552814); 85 | 86 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010A558_5528C8); 87 | 88 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010A5C4_552934); 89 | 90 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010A738_552AA8); 91 | 92 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010A7B0_552B20); 93 | 94 | INCLUDE_ASM(s32, "overlays/overlay125/54F360", func_8010A7EC_552B5C); 95 | -------------------------------------------------------------------------------- /src/overlays/overlay129/CCD20.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | extern void func_800E4F50_CCD20(u8 *); 4 | 5 | INCLUDE_ASM(void, "overlays/overlay129/CCD20", func_800E4F50_CCD20, u8 *hvqPtr); 6 | 7 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E4FF4_CCDC4); 8 | 9 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5000_CCDD0); 10 | 11 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5040_CCE10); 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E52DC_CD0AC); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E52F8_CD0C8); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5360_CD130); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5374_CD144); 20 | 21 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E53B0_CD180); 22 | 23 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E53E8_CD1B8); 24 | 25 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5424_CD1F4); 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E545C_CD22C); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E55E4_CD3B4); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5618_CD3E8); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5690_CD460); 34 | 35 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5784_CD554); 36 | 37 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5860_CD630); 38 | 39 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5954_CD724); 40 | 41 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5964_CD734); 42 | 43 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5974_CD744); 44 | 45 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E59B0_CD780); 46 | 47 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5A00_CD7D0); 48 | 49 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5AC8_CD898); 50 | 51 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5B3C_CD90C); 52 | 53 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5B80_CD950); 54 | 55 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5BE8_CD9B8); 56 | 57 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5C20_CD9F0); 58 | 59 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5C58_CDA28); 60 | 61 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5C70_CDA40); 62 | 63 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5C94_CDA64); 64 | 65 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5CC4_CDA94); 66 | 67 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5CEC_CDABC); 68 | 69 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5D18_CDAE8); 70 | 71 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5DD8_CDBA8); 72 | 73 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E5FB0_CDD80); 74 | 75 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E77D8_CF5A8); 76 | 77 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E7C04_CF9D4); 78 | 79 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E7C10_CF9E0); 80 | 81 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E7C1C_CF9EC); 82 | 83 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E7D18_CFAE8); 84 | 85 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E7D90_CFB60); 86 | 87 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E7E80_CFC50); 88 | 89 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E7EF8_CFCC8); 90 | 91 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8110_CFEE0); 92 | 93 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8164_CFF34); 94 | 95 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8180_CFF50); 96 | 97 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8194_CFF64); 98 | 99 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E856C_D033C); 100 | 101 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8578_D0348); 102 | 103 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8584_D0354); 104 | 105 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8648_D0418); 106 | 107 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E86B8_D0488); 108 | 109 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8704_D04D4); 110 | 111 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E875C_D052C); 112 | 113 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8870_D0640); 114 | 115 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E887C_D064C); 116 | 117 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E88B0_D0680); 118 | 119 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E88E4_D06B4); 120 | 121 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E88F0_D06C0); 122 | 123 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E88FC_D06CC); 124 | 125 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E890C_D06DC); 126 | 127 | void func_800E89CC_D079C() { 128 | func_800E4F50_CCD20(&bin_hvq_ROM_START); 129 | } 130 | 131 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E89EC_D07BC); 132 | 133 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8A1C_D07EC); 134 | 135 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8A44_D0814); 136 | 137 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8AB0_D0880); 138 | 139 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8D10_D0AE0); 140 | 141 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8D54_D0B24); 142 | 143 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E8EE8_D0CB8); 144 | 145 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E9030_D0E00); 146 | 147 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E90B4_D0E84); 148 | 149 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E90F4_D0EC4); 150 | 151 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E9108_D0ED8); 152 | 153 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E911C_D0EEC); 154 | 155 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E9158_D0F28); 156 | 157 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E9180_D0F50); 158 | 159 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E9190_D0F60); 160 | 161 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E919C_D0F6C); 162 | 163 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E9200_D0FD0); 164 | 165 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E9230_D1000); 166 | 167 | INCLUDE_ASM(s32, "overlays/overlay129/CCD20", func_800E924C_D101C); 168 | -------------------------------------------------------------------------------- /src/overlays/overlay129/E3CD0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../player.h" 3 | #include "../../process.h" 4 | 5 | extern s16 D_800D1380; 6 | 7 | extern void *D_80101A8C_E985C; 8 | extern void *D_80101A90_E9860; 9 | extern void *D_80101A94_E9864; 10 | extern void *D_80101A98_E9868; 11 | 12 | extern s16 D_80105494; 13 | extern s16 D_80105496; 14 | 15 | extern struct player *func_800F375C_DB52C(s32); // GetPlayerStructDuel 16 | 17 | extern void func_800F5BB4_DD984(s32); 18 | extern void func_800F5EB0_DDC80(s32); 19 | 20 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FBF00_E3CD0); 21 | 22 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FBFA4_E3D74); 23 | 24 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC030_E3E00); 25 | 26 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC108_E3ED8); 27 | 28 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC114_E3EE4); 29 | 30 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC120_E3EF0); 31 | 32 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC18C_E3F5C); 33 | 34 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC198_E3F68); 35 | 36 | // Called to set up the board. (duel) 37 | void func_800FC260_E4030(s32 bgIndex, s16 boardDefFile) { 38 | struct process *process; 39 | s32 *unkallocated; 40 | s32 i; 41 | 42 | func_800E8D10_D0AE0(); 43 | func_800E4F50_CCD20(&bin_hvq_ROM_START); 44 | if (bgIndex >= 0) { 45 | func_800E52DC_CD0AC(bgIndex); 46 | } 47 | func_800E94D0_D12A0(); 48 | if (boardDefFile >= 0) { 49 | func_800E9B10_D18E0(0x13, boardDefFile); 50 | } 51 | func_800D7EB8_BFC88(); 52 | func_800F3F4C_DBD1C(); 53 | func_800F3DFC_DBBCC(0); 54 | func_800F3DFC_DBBCC(1); 55 | 56 | for (i = 0; i < 2; i++) { 57 | func_800D8944_C0714(func_800F375C_DB52C(i)->obj); 58 | func_800F375C_DB52C(i)->obj->unkA |= 2; 59 | func_800D8E88_C0C58(func_800F375C_DB52C(i)->obj); 60 | } 61 | 62 | func_8001FDE8(*(func_800F375C_DB52C(0)->obj->unk3C->unk40)); 63 | func_8001FDE8(*(func_800F375C_DB52C(1)->obj->unk3C->unk40)); 64 | func_800F8C68_E0A38(0); 65 | func_800F8C68_E0A38(1); 66 | func_800F4300_DC0D0(); 67 | func_800DF1B0_C6F80(); 68 | func_800E0CEC_C8ABC(); 69 | func_800E2870_CA640(); 70 | func_800F6390_DE160(); 71 | 72 | for (i = 0; i < 2; i++) { 73 | { 74 | s32 temp1 = gPlayers[i].game_guy_space_count; 75 | s32 temp2 = gPlayers[i].unk35; 76 | gPlayers[i].game_guy_space_count = 0; 77 | gPlayers[i].unk35 = 0; 78 | func_800F5BB4_DD984(i); 79 | func_800F5EB0_DDC80(i); 80 | gPlayers[i].game_guy_space_count = temp1; 81 | gPlayers[i].unk35 = temp2; 82 | func_800F5BB4_DD984(i); 83 | func_800F5EB0_DDC80(i); 84 | } 85 | } 86 | 87 | func_800DAB1C_C28EC(); 88 | func_8005A6B0(); 89 | func_800EB664_D3434(); 90 | D_80105494 = -1; 91 | D_800D1380 = 0; 92 | D_80105496 = 0; 93 | func_800F4080_DBE50(); 94 | D_80101A8C_E985C = NULL; 95 | D_80101A90_E9860 = NULL; 96 | D_80101A94_E9864 = NULL; 97 | D_80101A98_E9868 = NULL; 98 | 99 | for (i = 0; i < 2; i++) { 100 | process = InitProcess(func_800FC198_E3F68, 0, 0, 0x40); 101 | unkallocated = (s32 *)Malloc(process->heap, 16); // TODO: What type is this? 102 | process->user_data = unkallocated; 103 | *unkallocated = i; 104 | func_80047B80(process, 0xA0); 105 | } 106 | } 107 | 108 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC4E4_E42B4); 109 | 110 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC590_E4360); 111 | 112 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC59C_E436C); 113 | 114 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC5A8_E4378); 115 | 116 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC5B4_E4384); 117 | 118 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC5C0_E4390); 119 | 120 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC5CC_E439C); 121 | 122 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC5D8_E43A8); 123 | 124 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC888_E4658); 125 | 126 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC894_E4664); 127 | 128 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC8A0_E4670); 129 | 130 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC8C4_E4694); 131 | 132 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC8D0_E46A0); 133 | 134 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC8DC_E46AC); 135 | 136 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC8E8_E46B8); 137 | 138 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FC9FC_E47CC); 139 | 140 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FCAB4_E4884); 141 | 142 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FCC84_E4A54); 143 | 144 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FCCCC_E4A9C); 145 | 146 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FCD44_E4B14); 147 | 148 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FCF50_E4D20); 149 | 150 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FD298_E5068); 151 | 152 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FD498_E5268); 153 | 154 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FD4DC_E52AC); 155 | 156 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FD55C_E532C); 157 | 158 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FD5F0_E53C0); 159 | 160 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FD620_E53F0); 161 | 162 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FD6F4_E54C4); 163 | 164 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF420_E71F0); 165 | 166 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF480_E7250); 167 | 168 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF640_E7410); 169 | 170 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF944_E7714); 171 | 172 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF970_E7740); 173 | 174 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF97C_E774C); 175 | 176 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF9AC_E777C); 177 | 178 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF9D8_E77A8); 179 | 180 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FF9E8_E77B8); 181 | 182 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FFA1C_E77EC); 183 | 184 | INCLUDE_ASM(s32, "overlays/overlay129/E3CD0", func_800FFA28_E77F8); 185 | -------------------------------------------------------------------------------- /src/overlays/overlay71/overlay71.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | // entrypoint 0 4 | void func_801059D0_31B3E0() { 5 | if (func_80035EB0(0) != 0) { 6 | func_80035FDC(1); 7 | } 8 | else { 9 | func_8003602C(1); 10 | } 11 | InitObjSys(0xA, 0); 12 | func_800F86B4(); 13 | func_80048228(0x47, 1, 0x192); 14 | func_80048460(0, 0x47, 1, 0x192); 15 | } 16 | 17 | // entrypoint 1 18 | void func_80105A44_31B454() { 19 | InitObjSys(0xA, 0); 20 | func_800F8774(); 21 | } 22 | 23 | void func_80105A6C_31B47C() { 24 | func_8004819C(1); 25 | func_8004849C(); 26 | SleepVProcess(); 27 | } 28 | 29 | // entrypoint 2 30 | void func_80105A98_31B4A8() { 31 | InitObjSys(0xA, 0xA); 32 | func_8004A208(); 33 | InitProcess(func_80105A6C_31B47C, 0x1005, 0, 0); 34 | } 35 | -------------------------------------------------------------------------------- /src/overlays/overlay71/overlay71_main.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../board.h" 3 | #include "../../365E0.h" 4 | 5 | extern s16 D_800A1764; 6 | extern void func_801059D0_31B3E0(); 7 | extern void func_80105A44_31B454(); 8 | extern void func_80105A98_31B4A8(); 9 | 10 | struct overlay_entrypoint overlay71_entrypoints[] = { 11 | { 0, func_801059D0_31B3E0 }, 12 | { 1, func_80105A44_31B454 }, 13 | { 2, func_80105A98_31B4A8 }, 14 | { -1, NULL } 15 | }; 16 | 17 | void func_801059A0_31B3B0() { 18 | func_800359E0(overlay71_entrypoints, D_800A1764); 19 | } 20 | -------------------------------------------------------------------------------- /src/overlays/overlay79/3B9670.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | extern void func_800E8180_CFF50(f32, f32); 4 | 5 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_801059A0_3B9670); 6 | 7 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80105B68_3B9838); 8 | 9 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80105BD8_3B98A8); 10 | 11 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_8010685C_3BA52C); 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80106968_3BA638); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80106A38_3BA708); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80106A80_3BA750); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80106CA8_3BA978); 20 | 21 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80106DA4_3BAA74); 22 | 23 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80106F54_3BAC24); 24 | 25 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_801070F8_3BADC8); 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80107598_3BB268); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_801076A0_3BB370); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80107AB4_3BB784); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80107B50_3BB820); 34 | 35 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80107EE8_3BBBB8); 36 | 37 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80107F84_3BBC54); 38 | 39 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80108378_3BC048); 40 | 41 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80109128_3BCDF8); 42 | 43 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80109320_3BCFF0); 44 | 45 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_8010935C_3BD02C); 46 | 47 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_801094A8_3BD178); 48 | 49 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_80109754_3BD424); 50 | 51 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_8010BA98_3BF768); 52 | 53 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_8010BAD8_3BF7A8); 54 | 55 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_8010BBF0_3BF8C0); 56 | 57 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_8010BC3C_3BF90C); 58 | 59 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_8010BC70_3BF940); 60 | 61 | void func_8010BCA4_3BF974() { 62 | func_80012220(1); 63 | func_80019514(1, 0xFF, 0xFF, 0xFF); 64 | func_800E4F50_CCD20(&bin_hvq_ROM_START); 65 | func_800E52DC_CD0AC(0); 66 | func_800E8180_CFF50(1000.0f, 10000.0f); 67 | } 68 | 69 | INCLUDE_ASM(s32, "overlays/overlay79/3B9670", func_8010BD04_3BF9D4); 70 | -------------------------------------------------------------------------------- /src/overlays/overlay80/3C27C0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | extern void func_800E9344_FCF64(f32, f32); 4 | 5 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_801059A0_3C27C0); 6 | 7 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80105A8C_3C28AC); 8 | 9 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80105AD8_3C28F8); 10 | 11 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80106968_3C3788); 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80106974_3C3794); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80106980_3C37A0); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_8010699C_3C37BC); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80106A54_3C3874); 20 | 21 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80106AB8_3C38D8); 22 | 23 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80106C78_3C3A98); 24 | 25 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80106FC8_3C3DE8); 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80107090_3C3EB0); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80107190_3C3FB0); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80107648_3C4468); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80107658_3C4478); 34 | 35 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_801076CC_3C44EC); 36 | 37 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80107724_3C4544); 38 | 39 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_8010775C_3C457C); 40 | 41 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_8010778C_3C45AC); 42 | 43 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_801078CC_3C46EC); 44 | 45 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80107A9C_3C48BC); 46 | 47 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80107DDC_3C4BFC); 48 | 49 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80108360_3C5180); 50 | 51 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_801085E4_3C5404); 52 | 53 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80108664_3C5484); 54 | 55 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_801086E4_3C5504); 56 | 57 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_801087F0_3C5610); 58 | 59 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80108A2C_3C584C); 60 | 61 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80108BB0_3C59D0); 62 | 63 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80108D2C_3C5B4C); 64 | 65 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_801091C4_3C5FE4); 66 | 67 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80109220_3C6040); 68 | 69 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_8010926C_3C608C); 70 | 71 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_801092A0_3C60C0); 72 | 73 | void func_801092D4_3C60F4() { 74 | func_80012220(1); 75 | func_800E6630_FA250(&bin_hvq_ROM_START); 76 | func_800E69BC_FA5DC(2); 77 | func_800E9344_FCF64(100.0f, 10000.0f); 78 | } 79 | 80 | INCLUDE_ASM(s32, "overlays/overlay80/3C27C0", func_80109320_3C6140); 81 | -------------------------------------------------------------------------------- /src/overlays/overlay81/3C6310.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../board.h" 3 | #include "../../object.h" 4 | 5 | struct strD_80107530_3C7EA0 { 6 | struct coords_3d unk0; 7 | struct coords_3d unkC; 8 | }; 9 | 10 | extern struct strD_80107530_3C7EA0 D_80107530_3C7EA0; 11 | 12 | extern void func_800E69BC_FA5DC(s32); 13 | extern void func_800E9344_FCF64(f32, f32); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_801059A0_3C6310); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80105A68_3C63D8); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80105AAC_3C641C); 20 | 21 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80105B04_3C6474); 22 | 23 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80105C9C_3C660C); 24 | 25 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80105CD4_3C6644); 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80105DEC_3C675C); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80105F9C_3C690C); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_801060A4_3C6A14); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80106100_3C6A70); 34 | 35 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_801066E0_3C7050); 36 | 37 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80106768_3C70D8); 38 | 39 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80107178_3C7AE8); 40 | 41 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_801072B0_3C7C20); 42 | 43 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_801072FC_3C7C6C); 44 | 45 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80107358_3C7CC8); 46 | 47 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80107384_3C7CF4); 48 | 49 | void func_801073B0_3C7D20() { 50 | struct coords_3d temp_s0[2]; 51 | s32 *s0arr = (s32 *)(&temp_s0); 52 | temp_s0[0] = D_80107530_3C7EA0.unk0; 53 | temp_s0[1] = D_80107530_3C7EA0.unkC; 54 | func_80012220(1, &D_80107530_3C7EA0); 55 | func_800E6630_FA250(&bin_hvq_ROM_START); 56 | func_800E69BC_FA5DC(s0arr[D_800CD058.current_board_index]); 57 | func_800E9344_FCF64(1000.0f, 10000.0f); 58 | } 59 | 60 | INCLUDE_ASM(s32, "overlays/overlay81/3C6310", func_80107450_3C7DC0); 61 | -------------------------------------------------------------------------------- /src/overlays/overlay83/3CA800.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "../../board.h" 3 | #include "../../object.h" 4 | 5 | struct strD_80107530_3C7EA0 { 6 | struct coords_3d unk0; 7 | struct coords_3d unkC; 8 | }; 9 | 10 | extern struct strD_80107530_3C7EA0 D_80109048_3CDEA8; 11 | 12 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_801059A0_3CA800); 13 | 14 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80105AE0_3CA940); 15 | 16 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80105C60_3CAAC0); 17 | 18 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80105DC4_3CAC24); 19 | 20 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80105F8C_3CADEC); 21 | 22 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80106014_3CAE74); 23 | 24 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_801060A8_3CAF08); 25 | 26 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_801061FC_3CB05C); 27 | 28 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_801062CC_3CB12C); 29 | 30 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80106388_3CB1E8); 31 | 32 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_801066F0_3CB550); 33 | 34 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80106CFC_3CBB5C); 35 | 36 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_801071F4_3CC054); 37 | 38 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_8010727C_3CC0DC); 39 | 40 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80107580_3CC3E0); 41 | 42 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80107E28_3CCC88); 43 | 44 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80107E58_3CCCB8); 45 | 46 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80108B3C_3CD99C); 47 | 48 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80108BB0_3CDA10); 49 | 50 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80108C0C_3CDA6C); 51 | 52 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80108C58_3CDAB8); 53 | 54 | INCLUDE_ASM(s32, "overlays/overlay83/3CA800", func_80108C8C_3CDAEC); 55 | 56 | void func_80108CC0_3CDB20() { 57 | struct coords_3d temp_s0[2]; 58 | s32 *s0arr = (s32 *)(&temp_s0); 59 | temp_s0[0] = D_80109048_3CDEA8.unk0; 60 | temp_s0[1] = D_80109048_3CDEA8.unkC; 61 | func_80012220(1, &D_80109048_3CDEA8); 62 | func_800E6630_FA250(&bin_hvq_ROM_START); 63 | func_800E69BC_FA5DC(s0arr[D_800CD058.current_board_index]); 64 | } 65 | 66 | void func_80108D44_3CDBA4() { 67 | func_800E69D8_FA5F8(); 68 | func_800E66E0_FA300(); 69 | } 70 | -------------------------------------------------------------------------------- /src/overlays/overlay84/3CDEC0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_801059A0_3CDEC0); 4 | 5 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80105AFC_3CE01C); 6 | 7 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80105C7C_3CE19C); 8 | 9 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80105DE0_3CE300); 10 | 11 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80105FA8_3CE4C8); 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_801060B4_3CE5D4); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80106184_3CE6A4); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_801061CC_3CE6EC); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80106254_3CE774); 20 | 21 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_801062E8_3CE808); 22 | 23 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_801063A4_3CE8C4); 24 | 25 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_801068E4_3CEE04); 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80106990_3CEEB0); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80106F40_3CF460); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80107408_3CF928); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_80107448_3CF968); 34 | 35 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_801074A4_3CF9C4); 36 | 37 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_801074E8_3CFA08); 38 | 39 | INCLUDE_ASM(s32, "overlays/overlay84/3CDEC0", func_8010751C_3CFA3C); 40 | 41 | void func_80107550_3CFA70() { 42 | func_80012220(1); 43 | func_80019514(1, 0xFF, 0xFF, 0xFF); 44 | func_800E6630_FA250(&bin_hvq_ROM_START); 45 | func_800E69BC_FA5DC(0x15); 46 | } 47 | 48 | void func_80107594_3CFAB4() { 49 | func_800E69D8_FA5F8(); 50 | func_800E66E0_FA300(); 51 | } 52 | -------------------------------------------------------------------------------- /src/overlays/overlay98/4554C0.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | extern void func_800E8180_CFF50(f32, f32); 4 | 5 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_801059A0_4554C0); 6 | 7 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80105B60_455680); 8 | 9 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80105BD0_4556F0); 10 | 11 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80106800_456320); 12 | 13 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_8010690C_45642C); 14 | 15 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_801069DC_4564FC); 16 | 17 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80106A24_456544); 18 | 19 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80106C4C_45676C); 20 | 21 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80106D48_456868); 22 | 23 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80106EF8_456A18); 24 | 25 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_8010709C_456BBC); 26 | 27 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_8010753C_45705C); 28 | 29 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80107644_457164); 30 | 31 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80107A58_457578); 32 | 33 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80107AF4_457614); 34 | 35 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80107BC0_4576E0); 36 | 37 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80107E7C_45799C); 38 | 39 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80107F3C_457A5C); 40 | 41 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80108138_457C58); 42 | 43 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_80108174_457C94); 44 | 45 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_801082C0_457DE0); 46 | 47 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_8010856C_45808C); 48 | 49 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_8010A938_45A458); 50 | 51 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_8010A978_45A498); 52 | 53 | INCLUDE_ASM(s32, "overlays/overlay98/4554C0", func_8010AA9C_45A5BC); 54 | 55 | void func_8010AAE8_45A608() { 56 | func_800D7EB8_BFC88(); 57 | func_800F3F4C_DBD1C(); 58 | func_800EF840_D7610(); 59 | func_800F4300_DC0D0(); 60 | } 61 | 62 | void func_8010AB1C_45A63C() { 63 | func_800F4314_DC0E4(); 64 | func_800EF880_D7650(); 65 | func_800F4030_DBE00(); 66 | func_800D7F0C_BFCDC(); 67 | } 68 | 69 | void func_8010AB50_45A670() { 70 | func_80012220(1); 71 | func_80019514(1, 0xFF, 0xFF, 0xFF); 72 | func_800E4F50_CCD20(&bin_hvq_ROM_START); 73 | func_800E52DC_CD0AC(0); 74 | func_800E8180_CFF50(1000.0f, 10000.0f); 75 | } 76 | 77 | void func_8010ABB0_45A6D0() { 78 | func_800E52F8_CD0C8(); 79 | func_800E5000_CCDD0(); 80 | } 81 | -------------------------------------------------------------------------------- /src/overlays/shared_board/113750.c: -------------------------------------------------------------------------------- 1 | 2 | #include "common.h" 3 | #include "../../board.h" 4 | #include "../../player.h" 5 | #include "../../process.h" 6 | 7 | extern s8 D_800CB99C; 8 | 9 | extern s32 D_801056C0; 10 | extern f32 D_801056E8; 11 | extern void *D_801056EC; 12 | 13 | extern f32 func_800E8DC8_FC9E8(); 14 | extern struct process *func_800E8EDC_FCAFC(f32 arg0); 15 | extern void func_800E98E8_FD508(void *arg0); 16 | 17 | INCLUDE_ASM(s32, "overlays/shared_board/113750", func_800FFB30_113750); 18 | 19 | INCLUDE_ASM(s32, "overlays/shared_board/113750", func_800FFD0C_11392C); 20 | 21 | void func_800FFE90_113AB0(s32 arg0) { 22 | func_800479AC(D_801056C0); 23 | func_800F2CA4_1068C4(arg0); 24 | } 25 | 26 | INCLUDE_ASM(s32, "overlays/shared_board/113750", func_800FFEC4_113AE4); 27 | 28 | INCLUDE_ASM(s32, "overlays/shared_board/113750", func_800FFF44_113B64); 29 | 30 | INCLUDE_ASM(s32, "overlays/shared_board/113750", func_80100130_113D50); 31 | 32 | void func_8010020C_113E2C() { 33 | func_800FFF44_113B64(); 34 | } 35 | 36 | void func_80100228_113E48() { 37 | func_80100130_113D50(); 38 | func_800F5DD8_1099F8(); 39 | } 40 | 41 | INCLUDE_ASM(s32, "overlays/shared_board/113750", func_8010024C_113E6C); 42 | 43 | void func_80100630_114250() { 44 | while (TRUE) { 45 | func_800E9748_FD368(&gPlayers[D_800CD058.current_player_index].obj->coords); 46 | SleepVProcess(); 47 | } 48 | } 49 | 50 | // related to showing pause screen overlay. 51 | void func_8010067C_11429C(s32 controller) { 52 | struct process *curProcess; 53 | struct process *process; 54 | 55 | D_801056E8 = func_800E8DC8_FC9E8(); 56 | func_800E98E8_FD508(&D_801056EC); 57 | D_800CB99C = 1; 58 | func_80049FB8(); 59 | func_800E6FCC_FABEC(); 60 | process = InitProcess(func_80100630_114250, 0x1005, 0, 0); 61 | func_80047B80(process, 0x20); 62 | LinkChildProcess(GetCurrentProcess(), func_800E8EDC_FCAFC(1.0f)); 63 | WaitForChildProcess(); 64 | EndProcess(process); 65 | curProcess = GetCurrentProcess(); 66 | process = InitProcess(func_8010024C_113E6C, 0x1005, 0, 0); 67 | process->user_data = controller; 68 | func_80047B80(process, 0x80); 69 | LinkChildProcess(curProcess, process); 70 | WaitForChildProcess(); 71 | func_8004A0E0(); 72 | D_800CB99C = 0; 73 | func_800E6FBC_FABDC(); 74 | } 75 | -------------------------------------------------------------------------------- /src/overlays/shared_board/F5070.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | extern s8 D_80102C48; 4 | 5 | INCLUDE_ASM(s32, "overlays/shared_board/F5070", func_800E1450_F5070); 6 | 7 | INCLUDE_ASM(s32, "overlays/shared_board/F5070", func_800E17B0_F53D0); 8 | 9 | INCLUDE_ASM(s32, "overlays/shared_board/F5070", func_800E1828_F5448); 10 | 11 | INCLUDE_ASM(s32, "overlays/shared_board/F5070", func_800E18FC_F551C); 12 | 13 | INCLUDE_ASM(s32, "overlays/shared_board/F5070", func_800E1934_F5554); 14 | 15 | void func_800E1F28_F5B48() { 16 | D_80102C48 = 0; 17 | func_800E1934_F5554(); 18 | } 19 | 20 | void func_800E1F48_F5B68() { 21 | D_80102C48 = 1; 22 | func_800E1934_F5554(); 23 | } 24 | -------------------------------------------------------------------------------- /src/player.h: -------------------------------------------------------------------------------- 1 | #ifndef _PLAYER_H 2 | #define _PLAYER_H 3 | 4 | #include 5 | #include "object.h" 6 | #include "process.h" 7 | 8 | /** 9 | * Represents a player's state during a game. 10 | */ 11 | struct player { 12 | /* 0 (0x00) 800D1108 */ s8 id; 13 | /* 1 (0x01) 800D1109 */ s8 cpu_difficulty; 14 | /* 2 (0x02) 800D110A */ u8 controller; 15 | /* 3 (0x03) 800D110B */ u8 character; 16 | /** 17 | * Player flags. 18 | * 1: Is CPU player 19 | * 4: ? 20 | */ 21 | /* 4 (0x04) 800D110C */ u8 flags; 22 | s8 pad5[1]; 23 | /** Coins collected in a mini-game. */ 24 | /* 6 (0x06) 800D110E */ s16 bonus_coins; 25 | /** Coins from mini-game wins. */ 26 | /* 8 (0x08) 800D1110 */ s16 coins_won; 27 | /** Current coin count. */ 28 | /* 10 (0x0A) 800D1112 */ s16 coins; 29 | /** Coins obtained during a Mini-Game. */ 30 | /* 12 (0x0C) 800D1114 */ s16 minigame_coins; 31 | /* 14 (0x0E) 800D1116 */ s8 stars; 32 | 33 | /* 15 (0x0F) 800D1117 */ u8 cur_chain_index; 34 | /* 16 (0x10) 800D1118 */ u8 cur_space_index; 35 | /* 17 (0x11) 800D1119 */ u8 next_chain_index; 36 | /* 18 (0x12) 800D111A */ u8 next_space_index; 37 | /* 19 (0x13) 800D111B */ u8 unk1_chain_index; 38 | /* 20 (0x14) 800D111C */ u8 unk1_space_index; 39 | /* 21 (0x15) 800D111D */ s8 reverse_chain_index; 40 | /* 22 (0x16) 800D111E */ s8 reverse_space_index; 41 | 42 | /** 43 | * Movement flags. 44 | * 1: Is moving in reverse. 45 | */ 46 | /* 23 (0x17) 800D111F */ u8 flags2; 47 | /* 24 (0x18) 800D1120 */ s8 items[3]; 48 | /* 27 (0x1B) 800D1123 */ s8 bowser_suit_flag; 49 | /* 28 (0x1C) 800D1124 */ u8 turn_color_status; 50 | /* 29 (0x1D) 800D1125 */ s8 unk1D; 51 | 52 | s8 unks1E1F[2]; // 20 - 31 53 | 54 | /* 32 (0x20) 800D1128 */ struct process *process; 55 | /* 36 (0x24) 800D112C */ struct object *obj; 56 | /* 40 (0x28) 800D1130 */ s16 minigame_star; 57 | /* 42 (0x2A) 800D1132 */ s16 max_coins; 58 | /* 44 (0x2C) 800D1134 */ s8 happening_space_count; 59 | s8 red_space_count; 60 | s8 blue_space_count; 61 | s8 chance_space_count; 62 | /* 48 (0x30) 800D1138 */ s8 bowser_space_count; 63 | s8 battle_space_count; 64 | s8 item_space_count; 65 | s8 bank_space_count; 66 | /* 52 (0x34) 800D113C */ s8 game_guy_space_count; 67 | s8 unk35; 68 | 69 | // s8 pad2[3]; 70 | }; // sizeof == 56 | 0x38 71 | 72 | extern struct player gPlayers[4]; 73 | 74 | s16 GetCurrentPlayerIndex(); 75 | struct player *GetPlayerStruct(s32 index); 76 | // s16 PlayerIsCurrent(s16 index); 77 | // u32 PlayerStructIsCurrent(struct player *player); 78 | // u32 PlayerIsCPU(s16 index); 79 | // void AdjustPlayerCoins(s32 index, s32 count); 80 | // u32 PlayerHasCoins(s32 index, s32 count); 81 | // void SetPlayerAnimation(s32 index, s32 animation, s32 unk); 82 | 83 | #endif /* _PLAYER_H */ 84 | -------------------------------------------------------------------------------- /src/process.h: -------------------------------------------------------------------------------- 1 | #ifndef _PROCESS_H 2 | #define _PROCESS_H 3 | 4 | #include 5 | #include "setjmp.h" 6 | 7 | #define EXEC_PROCESS_DEFAULT 0 8 | #define EXEC_PROCESS_SLEEPING 1 9 | #define EXEC_PROCESS_WATCH 2 10 | #define EXEC_PROCESS_DEAD 3 11 | 12 | typedef void (*process_func)(); 13 | 14 | struct process 15 | { 16 | /*0x00*/ struct process *next; 17 | /*0x04*/ struct process *youngest_child; 18 | /*0x08*/ struct process *oldest_child; 19 | /*0x0C*/ struct process *relative; 20 | /*0x10*/ struct process *parent_oldest_child; 21 | /*0x14*/ struct process *new_process; 22 | /*0x18*/ void *heap; 23 | /*0x1C*/ u16 exec_mode; 24 | /*0x1E*/ u16 stat; 25 | /*0x20*/ u16 priority; 26 | /*0x22*/ s16 dtor_idx; 27 | /*0x24*/ s32 sleep_time; 28 | /*0x28*/ void *base_sp; 29 | /*0x2C*/ jmp_buf prc_jump; 30 | /*0x88*/ process_func destructor; 31 | /*0x8C*/ void *user_data; 32 | }; 33 | 34 | void InitProcessSys(); 35 | void LinkProcess(struct process **root, struct process *process); 36 | void UnlinkProcess(struct process **root, struct process *process); 37 | struct process *CreateProcess(process_func func, u16 priority, s32 stack_size, s32 extra_data_size); 38 | void LinkChildProcess(struct process *process, struct process *child); 39 | void UnlinkChildProcess(struct process *process); 40 | struct process *CreateChildProcess(process_func func, u16 priority, s32 stack_size, s32 extra_data_size, struct process *parent); 41 | void WaitForChildProcess(); 42 | struct process *GetCurrentProcess(); 43 | s32 GetChildProcess(struct process *process); 44 | s32 SetKillStatusProcess(struct process *process); 45 | void KillProcess(struct process *process); 46 | void KillChildProcess(struct process *process); 47 | void TerminateProcess(struct process *process); 48 | void ExitProcess(); 49 | void SleepProcess(s32 time); 50 | void SleepVProcess(); 51 | void WakeupProcess(struct process *process); 52 | void SetProcessDestructor(struct process *process, process_func destructor); 53 | void SetCurrentProcessDestructor(process_func destructor); 54 | // void CallProcess(s32 time); 55 | void *AllocProcessMemory(s32 size); 56 | void FreeProcessMemory(void *ptr); 57 | 58 | #endif /* _PROCESS_H */ 59 | -------------------------------------------------------------------------------- /src/rom.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "rom.h" 3 | 4 | extern OSPiHandle *osCartRomInit(void); 5 | 6 | extern OSPiHandle *D_800CDD50; 7 | extern OSMesgQueue D_800B29F0; 8 | extern void *D_800B2A08; 9 | extern void *D_800CCFA8; 10 | extern OSMesgQueue D_800D6B28; 11 | 12 | void func_8004D9A0(void) { 13 | osCreatePiManager(OS_PRIORITY_PIMGR, &D_800D6B28, &D_800CCFA8, 0x2A); 14 | D_800CDD50 = osCartRomInit(); 15 | osCreateMesgQueue(&D_800B29F0, &D_800B2A08, 0xA); 16 | } 17 | 18 | s32 HuStartDma(OSIoMesg *msg, u8 pri, s32 direction, u32 src, void *dest, u32 size, OSMesgQueue *retQueue) { 19 | msg->hdr.pri = pri; 20 | msg->hdr.retQueue = retQueue; 21 | msg->dramAddr = dest; 22 | msg->devAddr = src; 23 | msg->size = size; 24 | return osEPiStartDma(D_800CDD50, msg, direction); 25 | } 26 | 27 | s32 HuRomDmaRead(void *src, void *dest, s32 size) { 28 | OSIoMesg msg; 29 | s32 var_s1; 30 | u32 var_v1; 31 | s32 err; 32 | 33 | osInvalDCache(dest, OS_DCACHE_ROUNDUP_SIZE(size)); 34 | 35 | var_s1 = 0; 36 | while (size > 0) { 37 | var_v1 = size; 38 | if (size >= 0x4001) { 39 | var_v1 = 0x4000; 40 | } 41 | err = HuStartDma(&msg, 0, 0, src + var_s1, dest + var_s1, var_v1, &D_800B29F0); 42 | 43 | if (err != 0) { 44 | return err; 45 | } 46 | 47 | osRecvMesg(&D_800B29F0, 0, 1); 48 | size -= 0x4000; 49 | var_s1 += 0x4000; 50 | } 51 | return err; 52 | } 53 | 54 | s32 HuRomDmaCodeRead(void *src, void *dest, s32 size) { 55 | OSIoMesg msg; 56 | s32 var_s1; 57 | u32 var_v1; 58 | s32 err; 59 | 60 | osInvalICache(dest, OS_DCACHE_ROUNDUP_SIZE(size)); 61 | osInvalDCache(dest, OS_DCACHE_ROUNDUP_SIZE(size)); 62 | 63 | var_s1 = 0; 64 | while (size > 0) { 65 | var_v1 = size; 66 | if (size >= 0x4001) { 67 | var_v1 = 0x4000; 68 | } 69 | err = HuStartDma(&msg, 0, 0, src + var_s1, dest + var_s1, var_v1, &D_800B29F0); 70 | 71 | if (err != 0) { 72 | return err; 73 | } 74 | 75 | osRecvMesg(&D_800B29F0, 0, 1); 76 | size -= 0x4000; 77 | var_s1 += 0x4000; 78 | } 79 | return err; 80 | } -------------------------------------------------------------------------------- /src/rom.h: -------------------------------------------------------------------------------- 1 | #ifndef __ROM_H 2 | #define __ROM_H 3 | 4 | #include 5 | 6 | s32 HuStartDma(OSIoMesg * msg, u8 pri, s32 direction, u32 src, void * dest, u32 size, OSMesgQueue * retQueue); 7 | s32 HuRomDmaRead(void * src, void * dest, s32 size); 8 | s32 HuRomDmaCodeRead(void * src, void * dest, s32 size); 9 | 10 | #endif -------------------------------------------------------------------------------- /src/setjmp.h: -------------------------------------------------------------------------------- 1 | #ifndef _SETJMP_H 2 | #define _SETJMP_H 3 | 4 | #include 5 | 6 | typedef struct jump_buf 7 | { 8 | void *sp; 9 | void *func; 10 | u32 regs[21]; 11 | } jmp_buf; 12 | 13 | extern s32 setjmp(jmp_buf *jump_buf); 14 | extern s32 longjmp(jmp_buf *jump_buf, s32 val); 15 | 16 | #endif /* _SETJMP_H */ 17 | -------------------------------------------------------------------------------- /src/spaces.h: -------------------------------------------------------------------------------- 1 | #ifndef _SPACES_H 2 | #define _SPACES_H 3 | 4 | #include 5 | #include "object.h" 6 | #include "board.h" 7 | 8 | enum board_space_type { 9 | SPACE_INVISIBLE = 0, 10 | SPACE_BLUE = 1, 11 | SPACE_RED = 2, 12 | SPACE_MINIGAME = 3, 13 | SPACE_HAPPENING = 4, 14 | SPACE_STAR = 5, 15 | SPACE_CHANCE = 6, 16 | SPACE_START = 7, 17 | SPACE_MUSHROOM = 8, 18 | SPACE_BOWSER = 9 19 | }; 20 | 21 | struct space_data { 22 | s8 unk0; 23 | u8 space_type; // enum board_space_type 24 | s16 unk2; 25 | s32 unk4; 26 | struct coords_3d coords; // 0x8 27 | f32 sx; // 0x14 28 | f32 sy; 29 | f32 sz; 30 | struct event_list_entry *event_list; 31 | }; 32 | 33 | struct chain_data { 34 | u16 len; 35 | s16 *space_indices; 36 | }; 37 | 38 | extern struct space_data *GetSpaceData(s16 index); 39 | 40 | #endif /* _SPACES_H */ 41 | -------------------------------------------------------------------------------- /src/stubbed.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | void func_8000E3B0(void) { 4 | } 5 | -------------------------------------------------------------------------------- /src/thread3_main.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "heap_permanent.h" 3 | #include "heap_temporary.h" 4 | #include "process.h" 5 | 6 | extern s32 D_800A08B0; 7 | extern void *D_800A1240[3]; 8 | extern void *D_800A124C; 9 | extern void *D_800A125C; 10 | extern s32 D_800A12A0; 11 | extern u8 D_800CCF52; 12 | extern OSMesgQueue D_800CCF38; 13 | extern OSMesgQueue D_800CCF60; 14 | extern s32 D_800D1F70; 15 | extern u32 D_800D2094; 16 | 17 | #define INTR_MESG_BUF_SIZE 256 18 | #define OTHER_MESG_BUF_SIZE 8 19 | 20 | extern void func_8000E3C0(); 21 | extern s32 func_8004D6AC(s32, s32, s32); 22 | extern void func_800639F8(void *, OSMesgQueue *, s32); 23 | 24 | void func_800354A0() { 25 | s32 iVar5; 26 | s32 stopLooping; 27 | 28 | OSMesg msg; 29 | OSMesg intrMesgBuf[INTR_MESG_BUF_SIZE + 4]; 30 | OSMesg otherMesgBuf[OTHER_MESG_BUF_SIZE + 4]; 31 | OSMesg *msgTempVar; 32 | 33 | iVar5 = 0; 34 | stopLooping = FALSE; 35 | 36 | if (osTvType == TV_TYPE_NTSC) { 37 | func_80050F90(2, 1); 38 | } 39 | else if (osTvType != TV_TYPE_NTSC) { 40 | stopLooping = FALSE; 41 | func_80050F90(0x1E, 1); 42 | } 43 | else { 44 | goto spinloop; 45 | } 46 | 47 | // This is all that MP1 did: 48 | //func_80050F90(osTvType == TV_TYPE_NTSC ? 2 : 0x1E, 1); 49 | 50 | MakePermHeap((void *)0x80140000, 0x1A0000); 51 | MakeTempHeap((void *)0x80128000, 0x18000); 52 | 53 | D_800CCF52 = 3; 54 | 55 | func_8000EA10(&D_800A1240, 3, 2, &D_800A124C, &D_800A125C); 56 | 57 | if (osTvType == TV_TYPE_PAL) { 58 | while (TRUE) {} 59 | } 60 | 61 | func_8004D410(0, 0x20, 0xD2, 0x20, 0xD4); 62 | func_80051750(); 63 | func_80008F3C(4, 1); 64 | func_8005A3C0(); 65 | func_80009880(); 66 | func_8004D9A0(); 67 | 68 | func_80009AC0(&bin_mainfs_ROM_START); 69 | 70 | InitProcessSys(); 71 | 72 | msgTempVar = &intrMesgBuf[4]; 73 | osCreateMesgQueue(&D_800CCF38, msgTempVar, INTR_MESG_BUF_SIZE); 74 | func_800511C4(&intrMesgBuf, &D_800CCF38, 1); 75 | msgTempVar = &otherMesgBuf[4]; 76 | osCreateMesgQueue(&D_800CCF60, msgTempVar, OTHER_MESG_BUF_SIZE); 77 | func_800511C4(&otherMesgBuf, &D_800CCF60, 2); 78 | 79 | func_800094E4(); 80 | func_8007D740(2); 81 | func_8000F094(2); 82 | CreateProcess(func_8000E3C0, 1, 0, 0); 83 | 84 | while (!stopLooping) { 85 | if (osRecvMesg(&D_800CCF60, &msg, OS_MESG_NOBLOCK) != -1) { 86 | 87 | if (D_800D2094) // Mysteriously helpful, courtesy permuter. 88 | { 89 | } 90 | 91 | break; 92 | } 93 | 94 | osRecvMesg(&D_800CCF38, &msg, OS_MESG_BLOCK); 95 | switch ((s32)msg) { 96 | case 1: 97 | { 98 | s32 temp_s0; 99 | s16 temp_s1; 100 | 101 | if (D_800D2094 - iVar5 >= 2) { 102 | iVar5 = D_800D2094; 103 | if (D_800A12A0 < D_800CCF52) { 104 | func_8004D7D8(); 105 | temp_s1 = func_8004D6AC(0xC8, 0, 0); 106 | func_800094E4(); 107 | func_800098FC(); 108 | temp_s0 = D_800A08B0; 109 | CallProcess(1); 110 | if (temp_s0 != D_800A08B0) { 111 | D_800A12A0++; 112 | } 113 | func_8004D6E8(temp_s1); 114 | func_8004D814(); 115 | } 116 | } 117 | } 118 | break; 119 | 120 | case 777: 121 | D_800A12A0--; 122 | D_800D1F70++; 123 | break; 124 | 125 | case 2: 126 | stopLooping = TRUE; 127 | break; 128 | } 129 | } 130 | 131 | spinloop: 132 | while (TRUE) {} 133 | } 134 | 135 | void func_800357AC(s16 count) { 136 | s16 i = 0; 137 | for (i = 0; i < count; i++) { 138 | func_80087A40(*(&D_800A1240[i]), 0, 0x25800); // sizeof(gZBuffer) ? 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /symbol_addrs.txt: -------------------------------------------------------------------------------- 1 | HuDecode = 0x8000B000; 2 | 3 | GetRandomByte = 0x8000B16C; 4 | 5 | ReadMainFS = 0x80009C10; 6 | FreeMainFS = 0x80009E6C; 7 | 8 | HuMemInit = 0x80019980; 9 | HuMemAlloc = 0x800199F8; 10 | HuMemAllocTag = 0x80019A14; 11 | HuMemFree = 0x80019A98; 12 | HuMemBlockFree = 0x80019AF0; 13 | HuMemFreeAllWithTag = 0x80019B34; 14 | HuMemSetDirty = 0x80019CDC; 15 | HuMemFreeAll = 0x80019CEC; 16 | HuMemCleanUp = 0x80019D64; 17 | HuMemGetSizeTag = 0x80019DB0; 18 | HuMemGetSize = 0x80019E04; 19 | HuMemSetTag = 0x80019E40; 20 | HuMemDebugCheck = 0x80019E84; 21 | 22 | // heap.c 23 | MakeHeap = 0x800360D0; 24 | Malloc = 0x800360F0; 25 | Free = 0x80036188; 26 | Realloc = 0x80036248; 27 | GetAllocatedHeapSize = 0x80036310; 28 | GetUsedMemoryBlockCount = 0x80036344; 29 | GetMemoryAllocSize = 0x8003636C; 30 | 31 | // heap_permanent.c 32 | MakePermHeap = 0x80035840; 33 | MallocPerm = 0x80035864; 34 | FreePerm = 0x80035888; 35 | ReallocPerm = 0x800358A4; 36 | GetAllocatedPermHeapSize = 0x800358D0; 37 | GetUsedMemoryBlockCountPerm = 0x800358F0; 38 | 39 | // heap_temporary.c 40 | MakeTempHeap = 0x80035910; 41 | MallocTemp = 0x80035934; 42 | FreeTemp = 0x80035958; 43 | ReallocTemp = 0x80035974; 44 | GetAllocatedTempHeapSize = 0x800359A0; 45 | GetUsedMemoryBlockCountTemp = 0x800359C0; 46 | 47 | // 47D60.c 48 | InitObjSys = 0x80047160; 49 | InitProcess = 0x80047EA0; 50 | EndProcess = 0x80048008; 51 | 52 | HuStartDma = 0x8004D9F8; 53 | HuRomDmaRead = 0x8004DA40; 54 | HuRomDmaCodeRead = 0x8004DB14; 55 | 56 | // process.c 57 | InitProcessSys = 0x8004EB20; 58 | LinkProcess = 0x8004EB34; 59 | UnlinkProcess = 0x8004EBC8; 60 | CreateProcess = 0x8004EC04; 61 | LinkChildProcess = 0x8004ED30; 62 | UnlinkChildProcess = 0x8004ED84; 63 | CreateChildProcess = 0x8004EDD4; 64 | WaitForChildProcess = 0x8004EE18; 65 | GetCurrentProcess = 0x8004EE68; 66 | GetChildProcess = 0x8004EE74; 67 | SetKillStatusProcess = 0x8004EE94; 68 | KillProcess = 0x8004EED8; 69 | KillChildProcess = 0x8004EF0C; 70 | TerminateProcess = 0x8004EF6C; 71 | ExitProcess = 0x8004EFD4; 72 | SleepProcess = 0x8004F010; 73 | SleepVProcess = 0x8004F074; 74 | WakeupProcess = 0x8004F090; 75 | SetProcessDestructor = 0x8004F098; 76 | SetCurrentProcessDestructor = 0x8004F0A0; 77 | CallProcess = 0x8004F0D0; 78 | AllocProcessMemory = 0x8004F23C; 79 | FreeProcessMemory = 0x8004F26C; 80 | 81 | InitFadeIn = 0x80061FE8; 82 | InitFadeOut = 0x80062050; 83 | GetFadeStatus = 0x800620BC; 84 | 85 | setjmp = 0x80066500; 86 | longjmp = 0x80066564; 87 | 88 | osEepromWrite = 0x80072020; 89 | __osPackEepWriteData = 0x800721D4; 90 | __osEepStatus = 0x8007227C; 91 | 92 | osCreatePiManager = 0x800726A0; 93 | 94 | __osEPiRawStartDma = 0x80072950; 95 | 96 | osEPiStartDma = 0x80072B40; 97 | 98 | osCartRomInit = 0x80072BE0; 99 | 100 | osInvalDCache = 0x80078BA0; 101 | osInvalICache = 0x80078C50; 102 | osWritebackDCache = 0x80078CD0; 103 | osWritebackDCacheAll = 0x80078D50; 104 | 105 | osVirtualToPhysical = 0x800792D0; 106 | cosf = 0x80079330; 107 | sinf = 0x8007B530; 108 | 109 | bcopy = 0x8007B970; 110 | bzero = 0x8007BC90; 111 | 112 | osInitRdb = 0x8007B8F0; 113 | strchr = 0x8007BD30; 114 | strlen = 0x8007BD70; 115 | memcpy = 0x8007BD94; 116 | 117 | rmonPrintf_func_8007BE50 = 0x8007BE50; 118 | osSyncPrintf = 0x8007BE80; 119 | osSyncPrintf_func_8007BEC0 = 0x8007BEC0; 120 | 121 | osCreateMesgQueue = 0x8007BF00; 122 | osJamMesg = 0x8007BF30; 123 | osRecvMesg = 0x8007C070; 124 | osSendMesg = 0x8007C1A0; 125 | osGetThreadPri = 0x8007C9F0; 126 | osSetThreadPri = 0x8007CA10; 127 | osStartThread = 0x8007CAE0; 128 | osGetTime = 0x8007CC90; 129 | osSetTimer = 0x8007CD20; 130 | 131 | __osProbeTLB = 0x8007D210; 132 | 133 | __osEnqueueAndYield = 0x8008061C; 134 | __osPopThread = 0x80080774; 135 | __osDisableInt = 0x80080940; 136 | __osRestoreInt = 0x800809B0; 137 | 138 | sqrtf = 0x80081240; 139 | _Printf = 0x80081A40; 140 | osGetCount = 0x800830A0; 141 | 142 | gHuMemIsDirty = 0x800A08A0; 143 | 144 | // 824C0.s, some issue with disassembly of this symbol. 145 | .L800CD1A0 = 0x800CD1A0; 146 | func_800CD1A0 = 0x800CD1A0; 147 | 148 | gLastMallocBlock = 0x800D03F4; 149 | gFreeFunc = 0x800D135C; 150 | gLastFreedBlock = 0x800D1238; 151 | gMallocFunc = 0x800D556C; 152 | gFirstMallocBlock = 0x800D6B68; 153 | 154 | // ROM addresses 155 | bin_hvq_ROM_START = 0x128CC60; // type:data rom:0x128CC60 156 | bin_strings_jp_ROM_START = 0x1209850; // type:data rom:0x1209850 157 | bin_strings_en_ROM_START = 0x121CAA0; // type:data rom:0x121CAA0 158 | bin_strings_fr_ROM_START = 0x124D440; // type:data rom:0x124D440 159 | bin_strings_de_ROM_START = 0x12355C0; // type:data rom:0x12355C0 160 | bin_strings_es_ROM_START = 0x12765F0; // type:data rom:0x12765F0 161 | bin_strings_it_ROM_START = 0x1261F90; // type:data rom:0x1261F90 162 | 163 | // Broken symbols like `jtbl_80111170_overlays/overlay42` are created unless we define these. 164 | // Seems like a bug in either the disassembler or splat. 165 | jtbl_80111170_overlays_overlay42 = 0x80111170; 166 | jtbl_8010C5D8_overlays_overlay68 = 0x8010C5D8; 167 | jtbl_8010CFE8_overlays_overlay69 = 0x8010CFE8; 168 | jtbl_801114D0_overlays_overlay124 = 0x801114D0; 169 | 170 | // shared_board/F5070 171 | PlayerHasEmptyItemSlot = 0x800E49DC; // type:func rom:0xF85FC 172 | FixUpPlayerItemSlots = 0x800E4A08; // type:func rom:0xF8628 173 | GetSpaceData = 0x800EB160; // type:func rom:0xFED80 174 | GetAbsSpaceIndexFromChainSpaceIndex = 0x800EB184; // type:func rom:0xFEDA4 175 | GetChainLength = 0x800EB1B0; // type:func rom:0xFEDD0 176 | GetChainSpaceIndexFromAbsSpaceIndex = 0x800EB1CC; 177 | SetSpaceType = 0x800EB7F0; 178 | SetCurrentSpaceIndex = 0x800EBCBC; // type:func rom:0xFF8DC 179 | GetCurrentSpaceIndex = 0x800EBCC8; // type:func rom:0xFF8E8 180 | 181 | // shared_board/1006F0 182 | SetPlayerOntoChain = 0x800ED91C; // type:func rom:0x10153C 183 | SetNextChainAndSpace = 0x800ED998; 184 | SetPrevChainAndSpace = 0x800ED9F8; 185 | 186 | // shared_board/105D50 187 | GetCurrentPlayerIndex = 0x800F2130; // type:func rom:0x105D50 188 | GetPlayerStruct = 0x800F213C; // type:func rom:0x105D5C 189 | PlayerIsCurrent = 0x800F217C; 190 | PlayerIsCPU = 0x800F2198; // type:func rom:0x105DB8 191 | AdjustPlayerCoins = 0x800F21C0; // type:func rom:0x105DE0 192 | PlayerHasCoins = 0x800F2230; // type:func rom:0x105E50 193 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | CFLAGS := -I . -Wall -Wextra -pedantic -std=c99 -O3 -s 3 | PROGRAMS := n64cksum 4 | 5 | n64cksum_SOURCES := n64cksum.c libmio0.c libsm64.c utils.c 6 | 7 | all: $(PROGRAMS) 8 | cp asm-differ/diff.py ../diff.py 9 | 10 | clean: 11 | $(RM) $(PROGRAMS) 12 | 13 | define COMPILE 14 | $(1): $($1_SOURCES) 15 | $(CC) $(CFLAGS) $($1_CFLAGS) $$^ -lm -o $$@ 16 | endef 17 | 18 | $(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p)))) 19 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # cc1 2 | 3 | This is a build of `cc1` from gcc 2.7.2.1. 4 | 5 | # binutils 6 | 7 | ## marioparty-binutils-2.7-as 8 | 9 | Built from https://github.com/PartyPlanner64/marioparty-binutils-2.7 10 | 11 | This is the current assembler, since it provides register names support ported back to binutils 2.7. 12 | -------------------------------------------------------------------------------- /tools/libmio0.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBMIO0_H_ 2 | #define LIBMIO0_H_ 3 | 4 | // defines 5 | 6 | #define MIO0_HEADER_LENGTH 16 7 | 8 | // typedefs 9 | 10 | typedef struct 11 | { 12 | unsigned int dest_size; 13 | unsigned int comp_offset; 14 | unsigned int uncomp_offset; 15 | } mio0_header_t; 16 | 17 | // function prototypes 18 | 19 | // decode MIO0 header 20 | // returns 1 if valid header, 0 otherwise 21 | int mio0_decode_header(const unsigned char *buf, mio0_header_t *head); 22 | 23 | // encode MIO0 header from struct 24 | void mio0_encode_header(unsigned char *buf, const mio0_header_t *head); 25 | 26 | // decode MIO0 data in memory 27 | // in: buffer containing MIO0 data 28 | // out: buffer for output data 29 | // end: output offset of the last byte decoded from in (set to NULL if unwanted) 30 | // returns bytes extracted to 'out' or negative value on failure 31 | int mio0_decode(const unsigned char *in, unsigned char *out, unsigned int *end); 32 | 33 | // encode MIO0 data in memory 34 | // in: buffer containing raw data 35 | // out: buffer for MIO0 data 36 | // returns size of compressed data in 'out' including MIO0 header 37 | int mio0_encode(const unsigned char *in, unsigned int length, unsigned char *out); 38 | 39 | // decode an entire MIO0 block at an offset from file to output file 40 | // in_file: input filename 41 | // offset: offset to start decoding from in_file 42 | // out_file: output filename 43 | int mio0_decode_file(const char *in_file, unsigned long offset, const char *out_file); 44 | 45 | // encode an entire file 46 | // in_file: input filename containing raw data to be encoded 47 | // out_file: output filename to write MIO0 compressed data to 48 | int mio0_encode_file(const char *in_file, const char *out_file); 49 | 50 | #endif // LIBMIO0_H_ 51 | -------------------------------------------------------------------------------- /tools/libsm64.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBSM64_H_ 2 | #define LIBSM64_H_ 3 | 4 | #define MIO0_DIR "mio0files" 5 | 6 | // typedefs 7 | typedef enum 8 | { 9 | ROM_INVALID, // not valid SM64 ROM 10 | ROM_SM64_BS, // SM64 byte-swapped (BADC) 11 | ROM_SM64_BE, // SM64 big-endian (ABCD) 12 | ROM_SM64_LE, // SM64 little-endian 13 | ROM_SM64_BE_EXT, // SM64 big-endian, extended 14 | } rom_type; 15 | 16 | typedef enum 17 | { 18 | VERSION_UNKNOWN, 19 | VERSION_SM64_U, 20 | VERSION_SM64_E, 21 | VERSION_SM64_J, 22 | VERSION_SM64_SHINDOU, 23 | } rom_version; 24 | 25 | typedef struct 26 | { 27 | char *in_filename; 28 | char *ext_filename; 29 | unsigned int ext_size; 30 | unsigned int padding; 31 | unsigned int alignment; 32 | char fill; 33 | char dump; 34 | } sm64_config; 35 | 36 | // determine ROM type based on data 37 | // buf: buffer containing raw SM64 ROM file data 38 | // length: length of 'buf' 39 | // returns SM64 ROM type or invalid 40 | rom_type sm64_rom_type(unsigned char *buf, unsigned int length); 41 | 42 | // determine SM64 ROM type based on cksum data 43 | // buf: buffer containing raw SM64 ROM file data 44 | // returns SM64 ROM version or unknown 45 | rom_version sm64_rom_version(unsigned char *buf); 46 | 47 | // find and decompress all MIO0 blocks 48 | // config: configuration to determine alignment, padding and size 49 | // in_buf: buffer containing entire contents of SM64 data in big endian 50 | // length: length of in_buf 51 | // out_buf: buffer containing extended SM64 52 | void sm64_decompress_mio0(const sm64_config *config, 53 | unsigned char *in_buf, 54 | unsigned int in_length, 55 | unsigned char *out_buf); 56 | 57 | // update N64 header checksums 58 | // buf: buffer containing ROM data 59 | // checksums are written into the buffer 60 | void sm64_update_checksums(unsigned char *buf); 61 | 62 | #endif // LIBSM64_H_ 63 | -------------------------------------------------------------------------------- /tools/m2ctx.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | # Generates a "context" file for use with mips_to_c 4 | # ./m2ctx.py file.c [output.c] 5 | 6 | import os 7 | import sys 8 | import subprocess 9 | from pathlib import Path 10 | 11 | script_dir = os.path.dirname(os.path.realpath(__file__)) 12 | root_dir = os.path.abspath(os.path.join(script_dir, "..")) 13 | src_dir = root_dir + "src/" 14 | 15 | 16 | def get_c_dir(dirname): 17 | for root, dirs, files in os.walk(src_dir): 18 | for directory in dirs: 19 | if directory == dirname: 20 | return os.path.join(root, directory) 21 | 22 | 23 | def get_c_file(directory): 24 | for root, dirs, files in os.walk(directory): 25 | for file in files: 26 | if file.endswith(".c") and "data" not in file: 27 | return file 28 | 29 | 30 | def import_c_file(in_file): 31 | in_file = os.path.relpath(in_file, root_dir) 32 | cpp_command = ["gcc", "-E", "-P", "-Iinclude", "-Isrc","-D_LANGUAGE_C", 33 | "-ffreestanding", "-DF3DEX_GBI_2", "-D_MIPS_SZLONG=32", "-DSCRIPT(...)={}", in_file] 34 | try: 35 | return subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8") 36 | except subprocess.CalledProcessError: 37 | print( 38 | "Failed to preprocess input file, when running command:\n" 39 | + cpp_command, 40 | file=sys.stderr, 41 | ) 42 | sys.exit(1) 43 | 44 | 45 | def main(): 46 | if len(sys.argv) > 1: 47 | c_file_path = Path.cwd() / sys.argv[1] 48 | if len(sys.argv) > 2: 49 | out_file_path = Path.cwd() / sys.argv[2] 50 | m2ctx(c_file_path, out_file_path) 51 | 52 | 53 | def m2ctx(c_file_path, out_file_path): 54 | processed = import_c_file(c_file_path) 55 | processed_lines = processed.split("\n") 56 | output = [] 57 | 58 | for line in processed_lines: 59 | if ("__attribute__" not in line 60 | and "__asm" not in line): 61 | output.append(line) 62 | 63 | with open(out_file_path, "w", encoding="UTF-8") as f: 64 | f.write("\n".join(output)) 65 | 66 | 67 | if __name__ == "__main__": 68 | main() 69 | -------------------------------------------------------------------------------- /tools/marioparty-binutils-2.7-as: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PartyPlanner64/mp3/d5b7c6a20ed4f7ee6bd0a0c9709c0a75c2958dee/tools/marioparty-binutils-2.7-as -------------------------------------------------------------------------------- /tools/mips-binutils-2.7-as: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PartyPlanner64/mp3/d5b7c6a20ed4f7ee6bd0a0c9709c0a75c2958dee/tools/mips-binutils-2.7-as -------------------------------------------------------------------------------- /tools/mips-cc1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PartyPlanner64/mp3/d5b7c6a20ed4f7ee6bd0a0c9709c0a75c2958dee/tools/mips-cc1 -------------------------------------------------------------------------------- /tools/n64cksum.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "libsm64.h" 5 | #include "utils.h" 6 | 7 | #define N64CKSUM_VERSION "0.1" 8 | 9 | static void print_usage(void) 10 | { 11 | ERROR("Usage: n64cksum ROM [ROM_OUT]\n" 12 | "\n" 13 | "n64cksum v" N64CKSUM_VERSION ": N64 ROM checksum calculator\n" 14 | "\n" 15 | "File arguments:\n" 16 | " ROM input ROM file\n" 17 | " ROM_OUT output ROM file (default: overwrites input ROM)\n"); 18 | } 19 | 20 | int main(int argc, char *argv[]) 21 | { 22 | unsigned char *rom_data; 23 | char *file_in; 24 | char *file_out; 25 | long length; 26 | long write_length; 27 | if (argc < 2) { 28 | print_usage(); 29 | return EXIT_FAILURE; 30 | } 31 | 32 | file_in = argv[1]; 33 | if (argc > 2) { 34 | file_out = argv[2]; 35 | } else { 36 | file_out = argv[1]; 37 | } 38 | 39 | length = read_file(file_in, &rom_data); 40 | if (length < 0) { 41 | ERROR("Error reading input file \"%s\"\n", file_in); 42 | return EXIT_FAILURE; 43 | } 44 | 45 | sm64_update_checksums(rom_data); 46 | 47 | write_length = write_file(file_out, rom_data, length); 48 | 49 | free(rom_data); 50 | 51 | if (write_length != length) { 52 | ERROR("Error writing to output file \"%s\"\n", file_out); 53 | return EXIT_FAILURE; 54 | } 55 | 56 | return EXIT_SUCCESS; 57 | } 58 | -------------------------------------------------------------------------------- /tools/patches.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Applies some manual changes after splitting the ROM. 4 | 5 | # Nonmatching functions accessing HVQ ROM_START are patched to refer to that symbol. 6 | # hvq_asm_files = [ 7 | # "asm/nonmatchings/overlays/overlay110/4C8050/func_8010FC98_4CCEC8.s", 8 | # "asm/nonmatchings/overlays/overlay115/4F01F0/func_801059A0_4F01F0.s", 9 | # "asm/nonmatchings/overlays/overlay124/5486A0/func_8010D1E8_549A68.s", 10 | # "asm/nonmatchings/overlays/overlay125/54F360/func_80107204_54F574.s" 11 | # ] 12 | 13 | # for file_path in hvq_asm_files: 14 | # with open(file_path, 'r') as file : 15 | # filedata = file.read() 16 | 17 | # filedata = filedata.replace('$a0, 0x129', '$a0, %hi(bin_hvq_ROM_START)') 18 | # filedata = filedata.replace('$a0, $a0, -0x33a0', '$a0, $a0, %lo(bin_hvq_ROM_START)') 19 | 20 | # with open(file_path, 'w') as file: 21 | # file.write(filedata) 22 | 23 | # Nonmatching String ROM references are in a single tricky function. 24 | # strings_fn = "asm/nonmatchings/5ACF0/func_8005A6B0.s" 25 | # with open(strings_fn, 'r') as file : 26 | # filedata = file.read() 27 | 28 | # filedata = filedata.replace('$a0, 0x121', '$a0, %hi(bin_strings_jp_ROM_START)') 29 | # filedata = filedata.replace('$a0, $a0, -0x67b0', '$a0, $a0, %lo(bin_strings_jp_ROM_START)') 30 | 31 | # filedata = filedata.replace('$a0, 0x122', '$a0, %hi(bin_strings_en_ROM_START)') 32 | # filedata = filedata.replace('$a0, $a0, -0x3560', '$a0, $a0, %lo(bin_strings_en_ROM_START)') 33 | 34 | # filedata = filedata.replace('$a0, 0x125', '$a0, %hi(bin_strings_fr_ROM_START)') 35 | # filedata = filedata.replace('$a0, $a0, -0x2bc0', '$a0, $a0, %lo(bin_strings_fr_ROM_START)') 36 | 37 | # filedata = filedata.replace('$a0, 0x123', '$a0, %hi(bin_strings_de_ROM_START)') 38 | # filedata = filedata.replace('$a0, $a0, 0x55c0', '$a0, $a0, %lo(bin_strings_de_ROM_START)') 39 | 40 | # filedata = filedata.replace('$a0, 0x127', '$a0, %hi(bin_strings_es_ROM_START)') 41 | # filedata = filedata.replace('$a0, $a0, 0x65f0', '$a0, $a0, %lo(bin_strings_es_ROM_START)') 42 | 43 | # filedata = filedata.replace('$a0, 0x126', '$a0, %hi(bin_strings_it_ROM_START)') 44 | # filedata = filedata.replace('$a0, $a0, 0x1f90', '$a0, $a0, %lo(bin_strings_it_ROM_START)') 45 | 46 | # with open(strings_fn, 'w') as file: 47 | # file.write(filedata) 48 | 49 | 50 | # Make it easy to patch out the save type check. 51 | c210file = "asm/nonmatchings/CE10/func_8000C210.s" 52 | with open(c210file, 'r') as file : 53 | filedata = file.read() 54 | 55 | filedata = filedata.replace('/* CEC0 8000C2C0 080030B0 */ j .L8000C2C0', """ 56 | .ifdef MP_SAVETYPE_PATCH 57 | /* CEC0 8000C2C0 00000000 */ nop 58 | .else 59 | /* CEC0 8000C2C0 080030B0 */ j .L8000C2C0 60 | .endif 61 | """) 62 | 63 | with open(c210file, 'w') as file: 64 | file.write(filedata) 65 | -------------------------------------------------------------------------------- /tools/run-mips-to-c.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # This is a script that executes the mips_to_c decompiler based on given args. 4 | # The intention is to help streamline executing the decompiler. 5 | 6 | # Script takes 3 arguments: 7 | # Git repo root directory ("/home/user/code/mp3") 8 | # Current .c file being edited ("/home/user/code/mp3/src/heap.c") 9 | # Current .c file line (7) 10 | 11 | # For example, you can set up a VS Code Task and key binding to execute this, 12 | # and this script will run mips_to_c for the INCLUDE_ASM that your cursor is 13 | # nearest to. 14 | 15 | # { 16 | # "label": "Run mips_to_c on current function", 17 | # "type": "shell", 18 | # "command": "./tools/run-mips-to-c.py", 19 | # "args": [ 20 | # "${workspaceFolder}", 21 | # "${file}", 22 | # "${lineNumber}" 23 | # ], 24 | # "problemMatcher": [] 25 | # } 26 | 27 | import sys 28 | import re 29 | import subprocess 30 | import m2ctx 31 | import tempfile 32 | 33 | rootDir = sys.argv[1] 34 | cfile = sys.argv[2] 35 | lineNumber = max(0, int(sys.argv[3]) - 1) 36 | 37 | def run_mips_to_c(retType, funcPath, funcName, contextFile): 38 | asmPath = rootDir + "/asm/nonmatchings/" + funcPath + "/" + funcName + ".s" 39 | mipsToCPath = rootDir + "/tools/mips_to_c/m2c.py" 40 | procArgs = [mipsToCPath] 41 | procArgs.append("--context") 42 | procArgs.append(contextFile) 43 | if retType == "void": 44 | procArgs.append("--void") 45 | procArgs.append(asmPath) 46 | subprocess.run(procArgs) 47 | 48 | with tempfile.NamedTemporaryFile() as tmp: 49 | m2ctx.m2ctx(cfile, tmp.name) 50 | 51 | with open(cfile, "r") as infile: 52 | lines = infile.readlines() 53 | while (lineNumber >= 0): 54 | lineText = lines[lineNumber] 55 | x = re.match("^/*INCLUDE_ASM\(([\w\s\*]+),\s\"([/\w]+)\",\s(\w+)", lineText) 56 | if x: 57 | run_mips_to_c(x.group(1), x.group(2), x.group(3), tmp.name) 58 | break 59 | lineNumber = lineNumber - 1 60 | -------------------------------------------------------------------------------- /tools/utils.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #if defined(_MSC_VER) || defined(__MINGW32__) 9 | #include 10 | #include 11 | #else 12 | #include 13 | #include 14 | #endif 15 | 16 | #include "utils.h" 17 | 18 | // global verbosity setting 19 | int g_verbosity = 0; 20 | 21 | int read_s16_be(unsigned char *buf) 22 | { 23 | unsigned tmp = read_u16_be(buf); 24 | int ret; 25 | if (tmp > 0x7FFF) { 26 | ret = -((int)0x10000 - (int)tmp); 27 | } else { 28 | ret = (int)tmp; 29 | } 30 | return ret; 31 | } 32 | 33 | float read_f32_be(unsigned char *buf) 34 | { 35 | union {uint32_t i; float f;} ret; 36 | ret.i = read_u32_be(buf); 37 | return ret.f; 38 | } 39 | 40 | int is_power2(unsigned int val) 41 | { 42 | while (((val & 1) == 0) && (val > 1)) { 43 | val >>= 1; 44 | } 45 | return (val == 1); 46 | } 47 | 48 | void fprint_hex(FILE *fp, const unsigned char *buf, int length) 49 | { 50 | int i; 51 | for (i = 0; i < length; i++) { 52 | fprint_byte(fp, buf[i]); 53 | fputc(' ', fp); 54 | } 55 | } 56 | 57 | void fprint_hex_source(FILE *fp, const unsigned char *buf, int length) 58 | { 59 | int i; 60 | for (i = 0; i < length; i++) { 61 | if (i > 0) fputs(", ", fp); 62 | fputs("0x", fp); 63 | fprint_byte(fp, buf[i]); 64 | } 65 | } 66 | 67 | void print_hex(const unsigned char *buf, int length) 68 | { 69 | fprint_hex(stdout, buf, length); 70 | } 71 | 72 | void swap_bytes(unsigned char *data, long length) 73 | { 74 | long i; 75 | unsigned char tmp; 76 | for (i = 0; i < length; i += 2) { 77 | tmp = data[i]; 78 | data[i] = data[i+1]; 79 | data[i+1] = tmp; 80 | } 81 | } 82 | 83 | void reverse_endian(unsigned char *data, long length) 84 | { 85 | long i; 86 | unsigned char tmp; 87 | for (i = 0; i < length; i += 4) { 88 | tmp = data[i]; 89 | data[i] = data[i+3]; 90 | data[i+3] = tmp; 91 | tmp = data[i+1]; 92 | data[i+1] = data[i+2]; 93 | data[i+2] = tmp; 94 | } 95 | } 96 | 97 | long filesize(const char *filename) 98 | { 99 | struct stat st; 100 | 101 | if (stat(filename, &st) == 0) { 102 | return st.st_size; 103 | } 104 | 105 | return -1; 106 | } 107 | 108 | void touch_file(const char *filename) 109 | { 110 | int fd; 111 | //fd = open(filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666); 112 | fd = open(filename, O_WRONLY|O_CREAT, 0666); 113 | if (fd >= 0) { 114 | utime(filename, NULL); 115 | close(fd); 116 | } 117 | } 118 | 119 | long read_file(const char *file_name, unsigned char **data) 120 | { 121 | FILE *in; 122 | unsigned char *in_buf = NULL; 123 | long file_size; 124 | long bytes_read; 125 | in = fopen(file_name, "rb"); 126 | if (in == NULL) { 127 | return -1; 128 | } 129 | 130 | // allocate buffer to read from offset to end of file 131 | fseek(in, 0, SEEK_END); 132 | file_size = ftell(in); 133 | 134 | // sanity check 135 | if (file_size > 256*MB) { 136 | return -2; 137 | } 138 | 139 | in_buf = malloc(file_size); 140 | fseek(in, 0, SEEK_SET); 141 | 142 | // read bytes 143 | bytes_read = fread(in_buf, 1, file_size, in); 144 | if (bytes_read != file_size) { 145 | return -3; 146 | } 147 | 148 | fclose(in); 149 | *data = in_buf; 150 | return bytes_read; 151 | } 152 | 153 | long write_file(const char *file_name, unsigned char *data, long length) 154 | { 155 | FILE *out; 156 | long bytes_written; 157 | // open output file 158 | out = fopen(file_name, "wb"); 159 | if (out == NULL) { 160 | perror(file_name); 161 | return -1; 162 | } 163 | bytes_written = fwrite(data, 1, length, out); 164 | fclose(out); 165 | return bytes_written; 166 | } 167 | 168 | void generate_filename(const char *in_name, char *out_name, char *extension) 169 | { 170 | char tmp_name[FILENAME_MAX]; 171 | int len; 172 | int i; 173 | strcpy(tmp_name, in_name); 174 | len = strlen(tmp_name); 175 | for (i = len - 1; i > 0; i--) { 176 | if (tmp_name[i] == '.') { 177 | break; 178 | } 179 | } 180 | if (i <= 0) { 181 | i = len; 182 | } 183 | tmp_name[i] = '\0'; 184 | sprintf(out_name, "%s.%s", tmp_name, extension); 185 | } 186 | 187 | char *basename(const char *name) 188 | { 189 | const char *base = name; 190 | while (*name) { 191 | if (*name++ == '/') { 192 | base = name; 193 | } 194 | } 195 | return (char *)base; 196 | } 197 | 198 | void make_dir(const char *dir_name) 199 | { 200 | struct stat st = {0}; 201 | if (stat(dir_name, &st) == -1) { 202 | mkdir(dir_name, 0755); 203 | } 204 | } 205 | 206 | long copy_file(const char *src_name, const char *dst_name) 207 | { 208 | unsigned char *buf; 209 | long bytes_written; 210 | long bytes_read; 211 | 212 | bytes_read = read_file(src_name, &buf); 213 | 214 | if (bytes_read > 0) { 215 | bytes_written = write_file(dst_name, buf, bytes_read); 216 | if (bytes_written != bytes_read) { 217 | bytes_read = -1; 218 | } 219 | free(buf); 220 | } 221 | 222 | return bytes_read; 223 | } 224 | 225 | void dir_list_ext(const char *dir, const char *extension, dir_list *list) 226 | { 227 | char *pool; 228 | char *pool_ptr; 229 | struct dirent *entry; 230 | DIR *dfd; 231 | int idx; 232 | 233 | dfd = opendir(dir); 234 | if (dfd == NULL) { 235 | ERROR("Can't open '%s'\n", dir); 236 | exit(1); 237 | } 238 | 239 | pool = malloc(FILENAME_MAX * MAX_DIR_FILES); 240 | pool_ptr = pool; 241 | 242 | idx = 0; 243 | while ((entry = readdir(dfd)) != NULL && idx < MAX_DIR_FILES) { 244 | if (!extension || str_ends_with(entry->d_name, extension)) { 245 | sprintf(pool_ptr, "%s/%s", dir, entry->d_name); 246 | list->files[idx] = pool_ptr; 247 | pool_ptr += strlen(pool_ptr) + 1; 248 | idx++; 249 | } 250 | } 251 | list->count = idx; 252 | 253 | closedir(dfd); 254 | } 255 | 256 | void dir_list_free(dir_list *list) 257 | { 258 | // assume first entry in array is allocated 259 | if (list->files[0]) { 260 | free(list->files[0]); 261 | list->files[0] = NULL; 262 | } 263 | } 264 | 265 | int str_ends_with(const char *str, const char *suffix) 266 | { 267 | if (!str || !suffix) { 268 | return 0; 269 | } 270 | size_t len_str = strlen(str); 271 | size_t len_suffix = strlen(suffix); 272 | if (len_suffix > len_str) { 273 | return 0; 274 | } 275 | return (0 == strncmp(str + len_str - len_suffix, suffix, len_suffix)); 276 | } 277 | -------------------------------------------------------------------------------- /tools/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H_ 2 | #define UTILS_H_ 3 | 4 | #include 5 | 6 | // defines 7 | 8 | // printing size_t varies by compiler 9 | #if defined(_MSC_VER) || defined(__MINGW32__) 10 | #define SIZE_T_FORMAT "%Iu" 11 | #else 12 | #define SIZE_T_FORMAT "%zu" 13 | #endif 14 | 15 | #define KB 1024 16 | #define MB (1024 * KB) 17 | 18 | // number of elements in statically declared array 19 | #define DIM(S_ARR_) (sizeof(S_ARR_) / sizeof(S_ARR_[0])) 20 | 21 | #define MIN(A_, B_) ((A_) < (B_) ? (A_) : (B_)) 22 | #define MAX(A_, B_) ((A_) > (B_) ? (A_) : (B_)) 23 | 24 | // align value to N-byte boundary 25 | #define ALIGN(VAL_, ALIGNMENT_) (((VAL_) + ((ALIGNMENT_) - 1)) & ~((ALIGNMENT_) - 1)) 26 | 27 | // read/write u32/16 big/little endian 28 | #define read_u32_be(buf) (unsigned int)(((buf)[0] << 24) + ((buf)[1] << 16) + ((buf)[2] << 8) + ((buf)[3])) 29 | #define read_u32_le(buf) (unsigned int)(((buf)[1] << 24) + ((buf)[0] << 16) + ((buf)[3] << 8) + ((buf)[2])) 30 | #define write_u32_be(buf, val) do { \ 31 | (buf)[0] = ((val) >> 24) & 0xFF; \ 32 | (buf)[1] = ((val) >> 16) & 0xFF; \ 33 | (buf)[2] = ((val) >> 8) & 0xFF; \ 34 | (buf)[3] = (val) & 0xFF; \ 35 | } while(0) 36 | #define read_u16_be(buf) (((buf)[0] << 8) + ((buf)[1])) 37 | #define write_u16_be(buf, val) do { \ 38 | (buf)[0] = ((val) >> 8) & 0xFF; \ 39 | (buf)[1] = ((val)) & 0xFF; \ 40 | } while(0) 41 | 42 | // print nibbles and bytes 43 | #define fprint_nibble(FP, NIB_) fputc((NIB_) < 10 ? ('0' + (NIB_)) : ('A' + (NIB_) - 0xA), FP) 44 | #define fprint_byte(FP, BYTE_) do { \ 45 | fprint_nibble(FP, (BYTE_) >> 4); \ 46 | fprint_nibble(FP, (BYTE_) & 0x0F); \ 47 | } while(0) 48 | #define print_nibble(NIB_) fprint_nibble(stdout, NIB_) 49 | #define print_byte(BYTE_) fprint_byte(stdout, BYTE_) 50 | 51 | // Windows compatibility 52 | #if defined(_MSC_VER) || defined(__MINGW32__) 53 | #include 54 | #define mkdir(DIR_, PERM_) _mkdir(DIR_) 55 | #ifndef strcasecmp 56 | #define strcasecmp(A, B) stricmp(A, B) 57 | #endif 58 | #endif 59 | 60 | // typedefs 61 | 62 | #define MAX_DIR_FILES 128 63 | typedef struct 64 | { 65 | char *files[MAX_DIR_FILES]; 66 | int count; 67 | } dir_list; 68 | 69 | // global verbosity setting 70 | extern int g_verbosity; 71 | 72 | #define ERROR(...) fprintf(stderr, __VA_ARGS__) 73 | #define INFO(...) if (g_verbosity) printf(__VA_ARGS__) 74 | #define INFO_HEX(...) if (g_verbosity) print_hex(__VA_ARGS__) 75 | 76 | // functions 77 | 78 | // convert two bytes in big-endian to signed int 79 | int read_s16_be(unsigned char *buf); 80 | 81 | // convert four bytes in big-endian to float 82 | float read_f32_be(unsigned char *buf); 83 | 84 | // determine if value is power of 2 85 | // returns 1 if val is power of 2, 0 otherwise 86 | int is_power2(unsigned int val); 87 | 88 | // print buffer as hex bytes 89 | // fp: file pointer 90 | // buf: buffer to read bytes from 91 | // length: length of buffer to print 92 | void fprint_hex(FILE *fp, const unsigned char *buf, int length); 93 | void fprint_hex_source(FILE *fp, const unsigned char *buf, int length); 94 | void print_hex(const unsigned char *buf, int length); 95 | 96 | // perform byteswapping to convert from v64 to z64 ordering 97 | void swap_bytes(unsigned char *data, long length); 98 | 99 | // reverse endian to convert from n64 to z64 ordering 100 | void reverse_endian(unsigned char *data, long length); 101 | 102 | // get size of file without opening it; 103 | // returns file size or negative on error 104 | long filesize(const char *file_name); 105 | 106 | // update file timestamp to now, creating it if it doesn't exist 107 | void touch_file(const char *filename); 108 | 109 | // read entire contents of file into buffer 110 | // returns file size or negative on error 111 | long read_file(const char *file_name, unsigned char **data); 112 | 113 | // write buffer to file 114 | // returns number of bytes written out or -1 on failure 115 | long write_file(const char *file_name, unsigned char *data, long length); 116 | 117 | // generate an output file name from input name by replacing file extension 118 | // in_name: input file name 119 | // out_name: buffer to write output name in 120 | // extension: new file extension to use 121 | void generate_filename(const char *in_name, char *out_name, char *extension); 122 | 123 | // extract base filename from file path 124 | // name: path to file 125 | // returns just the file name after the last '/' 126 | char *basename(const char *name); 127 | 128 | // make a directory if it doesn't exist 129 | // dir_name: name of the directory 130 | void make_dir(const char *dir_name); 131 | 132 | // copy a file from src_name to dst_name. will not make directories 133 | // src_name: source file name 134 | // dst_name: destination file name 135 | long copy_file(const char *src_name, const char *dst_name); 136 | 137 | // list a directory, optionally filtering files by extension 138 | // dir: directory to list files in 139 | // extension: extension to filter files by (NULL if no filtering) 140 | // list: output list and count 141 | void dir_list_ext(const char *dir, const char *extension, dir_list *list); 142 | 143 | // free associated date from a directory list 144 | // list: directory list filled in by dir_list_ext() call 145 | void dir_list_free(dir_list *list); 146 | 147 | // determine if a string ends with another string 148 | // str: string to check if ends with 'suffix' 149 | // suffix: string to see if 'str' ends with 150 | // returns 1 if 'str' ends with 'suffix' 151 | int str_ends_with(const char *str, const char *suffix); 152 | 153 | #endif // UTILS_H_ 154 | --------------------------------------------------------------------------------