Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3685df9
WIP
Ryan-Myers Dec 4, 2025
fa70995
makefile up to date
Ryan-Myers Dec 4, 2025
b0eafd8
Get the first match for math_util!
Ryan-Myers Dec 4, 2025
2b4f8fc
Do some cleanup and documenting
Ryan-Myers Dec 8, 2025
297ae08
slightly better comments now
Ryan-Myers Dec 8, 2025
f4a5e3e
Document mtxf_transform_dir
Ryan-Myers Dec 8, 2025
05e8b29
2 more hasm docs
Ryan-Myers Dec 8, 2025
420c70d
vec3s_reflect
Ryan-Myers Dec 8, 2025
2e709c1
mtx_to_mtxs_2
Ryan-Myers Dec 8, 2025
ffc8588
Document mtxs_transform_point
Ryan-Myers Dec 9, 2025
1cb7ca5
mtxs_transform_point and mtxs_transform_dir
Ryan-Myers Dec 9, 2025
a90fb2d
Better vec3s_reflect
Ryan-Myers Dec 9, 2025
28a1e19
Better matches with docs
Ryan-Myers Dec 10, 2025
6f2e827
Doc mtxf_from_inverse_transform
Ryan-Myers Dec 10, 2025
8ed99df
Doc func_80070058
Ryan-Myers Dec 10, 2025
1d33668
Doc mtxf_billboard
Ryan-Myers Dec 10, 2025
975780e
Doc vec3f_rotate
Ryan-Myers Dec 11, 2025
8cbd4fd
Doc vec3f_rotate_ypr
Ryan-Myers Dec 11, 2025
87cc91f
Doc vec3f_rotate_py
Ryan-Myers Dec 11, 2025
49dc753
Doc mtxf_from_translation
Ryan-Myers Dec 11, 2025
6332bb5
Doc mtxf_from_scale
Ryan-Myers Dec 11, 2025
f9f72c3
Doc atan2s
Ryan-Myers Dec 11, 2025
bc6aeb5
Doc arctan2_f
Ryan-Myers Dec 11, 2025
9f8a688
more docs
Ryan-Myers Dec 11, 2025
9f5a675
calc_dyn_lighting_for_level_segment cleanup
Ryan-Myers Dec 12, 2025
8a95294
fix build
Ryan-Myers Dec 18, 2025
4e89b90
Document area_triangle_2d
Ryan-Myers Dec 18, 2025
00c2a66
more docs
Ryan-Myers Dec 18, 2025
661e805
dmacopy_doubleword
Ryan-Myers Dec 18, 2025
fa58226
more docs
Ryan-Myers Dec 19, 2025
f0dc6d2
work on standardizing some comments
Ryan-Myers Dec 19, 2025
5da8969
small cleanup for calc_dyn_lighting_for_level_segment
Ryan-Myers Dec 19, 2025
f42dae2
sins funcs cleanup and mild docs
Ryan-Myers Dec 19, 2025
de6900c
Remove old file
Ryan-Myers Dec 19, 2025
06a9051
Fix yamls
Ryan-Myers Dec 19, 2025
8f42b3e
woops, data too
Ryan-Myers Dec 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ BUILD_DIR = build
SRC_DIR = src
LIBULTRA_DIR = libultra
ASM_DIRS = asm asm/data asm/assets asm/nonmatchings
HASM_DIRS = $(SRC_DIR)/hasm $(LIBULTRA_DIR)/src/os $(LIBULTRA_DIR)/src/gu $(LIBULTRA_DIR)/src/libc
HASM_DIRS = $(SRC_DIR)/hasm $(SRC_DIR)/hasm/ido $(LIBULTRA_DIR)/src/os $(LIBULTRA_DIR)/src/gu $(LIBULTRA_DIR)/src/libc
LIBULTRA_SRC_DIRS = $(LIBULTRA_DIR) $(LIBULTRA_DIR)/src $(LIBULTRA_DIR)/src/audio $(LIBULTRA_DIR)/src/audio/mips1
LIBULTRA_SRC_DIRS += $(LIBULTRA_DIR)/src/debug $(LIBULTRA_DIR)/src/gu $(LIBULTRA_DIR)/src/io
LIBULTRA_SRC_DIRS += $(LIBULTRA_DIR)/src/libc $(LIBULTRA_DIR)/src/os $(LIBULTRA_DIR)/src/sc
Expand Down Expand Up @@ -188,6 +188,7 @@ C_DEFINES += -DCIC_ID=$(BOOT_CIC)
INCLUDE_CFLAGS = -I . -I include -I include/libc -I include/PR -I include/sys -I $(BIN_DIRS) -I $(SRC_DIR) -I $(LIBULTRA_DIR)
INCLUDE_CFLAGS += -I $(LIBULTRA_DIR)/src/gu -I $(LIBULTRA_DIR)/src/libc -I $(LIBULTRA_DIR)/src/io -I $(LIBULTRA_DIR)/src/sc
INCLUDE_CFLAGS += -I $(LIBULTRA_DIR)/src/audio -I $(LIBULTRA_DIR)/src/os
INCLUDE_CFLAGS += -I $(SRC_DIR)/hasm -I $(SRC_DIR)/hasm/ido

ASFLAGS = -march=vr4300 -32 -G0 $(ASM_DEFINES) $(INCLUDE_CFLAGS)
OBJCOPYFLAGS = -O binary
Expand Down Expand Up @@ -275,6 +276,9 @@ $(BUILD_DIR)/$(LIBULTRA_DIR)/%.s.o: MIPSISET := -mips2
$(BUILD_DIR)/$(LIBULTRA_DIR)/src/libc/%.s.o: OPT_FLAGS := -O2
$(BUILD_DIR)/$(LIBULTRA_DIR)/src/os/exceptasm.s.o: MIPSISET := -mips3 -32

$(BUILD_DIR)/$(SRC_DIR)/hasm/ido/math_util.s.o: OPT_FLAGS := -O2
$(BUILD_DIR)/$(SRC_DIR)/hasm/ido/math_util.s.o: MIPSISET := -mips3 -32

# Allow dollar sign to be used in var names for this file alone
# It allows us to return the current stack pointer
$(BUILD_DIR)/$(SRC_DIR)/get_stack_pointer.c.o: OPT_FLAGS += -dollar
Expand Down Expand Up @@ -464,6 +468,13 @@ $(BUILD_DIR)/$(LIBULTRA_DIR)/%.s.o: $(LIBULTRA_DIR)/%.s | build_assets
@if [ "$(MIPSISET)" = "-mips3 -32" ]; then \
$(PYTHON) $(TOOLS_DIR)/python/patchmips3.py $@ || rm $@; \
fi
$(BUILD_DIR)/$(SRC_DIR)/hasm/ido/%.s.o: $(SRC_DIR)/hasm/ido/%.s | build_assets
$(call print,Assembling IDO:,$<,$@)
$(V)$(CC) -c $(CFLAGS) $(CC_WARNINGS) $(OPT_FLAGS) $(MIPSISET) -o $@ $<
$(V)$(STRIP) --strip-unneeded $@
@if [ "$(MIPSISET)" = "-mips3 -32" ]; then \
$(PYTHON) $(TOOLS_DIR)/python/patchmips3.py $@ || rm $@; \
fi
else
# libultra asm files - Compile with the gcc c compiler
$(BUILD_DIR)/$(LIBULTRA_DIR)/%.s.o: $(LIBULTRA_DIR)/%.s | build_assets
Expand Down
17 changes: 17 additions & 0 deletions src/hasm/ido/asm_macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Define a macro for signed multiplication of two registers, storing the result in a destination register
This is similar to the MUL instruction but is mult instead of multu.
*/
#define MULS(rd, rs, rt) \
mult rs, rt; \
mflo rd \

/*
I think they accidentally used mul instead of mult.
This causes issues if they rd and rs are different registers as
rs would get overwritten by the mult instruction.
It also wastes and extra instruction with the extra mflo at the end.
*/
#define MUL(rd, rs, rt) \
mul rs, rt; \
mflo rd /* (mul pseudo-op already does this, but original has it) */ \
2,696 changes: 2,696 additions & 0 deletions src/hasm/ido/math_util.s

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/hasm/math_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ void vec3f_rotate_py(Vec3s *rotation, Vec3f *vec) {

z = vec->z;

vec->x = z * cosX * sinY;
vec->y = -z * sinX;
vec->x = z * cosY * sinX;
vec->y = -z * sinY;
vec->z = z * cosX * cosY;
}
#else
Expand Down Expand Up @@ -747,6 +747,10 @@ static u16 atan2_lookup(f32 y, f32 x) {
s32 atan2s(s32 xDelta, s32 zDelta) {
u16 ret;

if (xDelta == 0 && yDelta == 0) {
return 0;
}

if (xDelta >= 0) {
if (zDelta >= 0) {
if (zDelta >= xDelta) {
Expand Down Expand Up @@ -897,7 +901,7 @@ GLOBAL_ASM("asm/math_util/area_triangle_2d.s")
GLOBAL_ASM("asm/math_util/set_breakpoint.s")

#ifdef NON_MATCHING
void dmacopy_doubleword(void *src, void *dst, s32 end) {
void dmacopy_doubleword(void *src, void *dst, u32 end) {
s32 size = end - (u32) dst;
memcpy(dst, src, size);
}
Expand Down
1,778 changes: 0 additions & 1,778 deletions src/hasm/math_util.s

This file was deleted.

2 changes: 1 addition & 1 deletion src/math_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void mtxf_from_translation(MtxF *mtx, f32 x, f32 y, f32 z);
void mtxf_from_scale(MtxF *mtx, f32 scaleX, f32 scaleY, f32 scaleZ);
s32 atan2s(s32 xDelta, s32 zDelta);
f32 area_triangle_2d(f32 x0, f32 z0, f32 x1, f32 z1, f32 x2, f32 z2);
void dmacopy_doubleword(void *src, void *dst, s32 end);
void dmacopy_doubleword(void *src, void *dst, u32 end);
StackInfo *stack_pointer(void);
/**
* Zero out the interrupt mask. This stops this thread
Expand Down
2 changes: 1 addition & 1 deletion src/thread3_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ void main_game_loop(void) {
if (osTvType == OS_TV_TYPE_PAL) {
framebufferSize = (s32) ((SCREEN_WIDTH * SCREEN_HEIGHT * 2) * 1.1f);
}
dmacopy_doubleword(gVideoLastFramebuffer, gVideoCurrFramebuffer, (s32) gVideoCurrFramebuffer + framebufferSize);
dmacopy_doubleword(gVideoLastFramebuffer, gVideoCurrFramebuffer, (u32) gVideoCurrFramebuffer + framebufferSize);
}
// tempLogicUpdateRate will be set to a value 2 or higher, based on the framerate.
// the mul factor is hardcapped at 6, which happens at 10FPS. The mul factor
Expand Down
4 changes: 2 additions & 2 deletions ver/splat/dkr.jpn.v79.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ segments:
- [0x6ADD0, c, joypad]
- [0x6B380, c, game]
- [0x6D000, c, thread3_main]
- [0x701F0, hasm, hasm/math_util]
- [0x701F0, hasm, hasm/ido/math_util]
- [0x71810, c, memory]
- [0x72A10, c, ../libultra/src/io/motor]
- [0x72F30, c, save_data]
Expand Down Expand Up @@ -290,7 +290,7 @@ segments:
- [0xDF8A0, .data, joypad]
- [0xDF8B0, .data, game]
- [0xDF8E0, .data, thread3_main]
- [0xDF9D0, .data, hasm/math_util]
- [0xDF9D0, .data, hasm/ido/math_util]
- [0xE09E0, .data, save_data]
- [0xE0A40, .data, rcp_dkr]
- [0xE0CE0, .data, ../libultra/src/sc/sched]
Expand Down
4 changes: 2 additions & 2 deletions ver/splat/dkr.pal.v77.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ segments:
- [0x6AD00, c, joypad]
- [0x6B2B0, c, game]
- [0x6CF30, c, thread3_main]
- [0x70110, hasm, hasm/math_util]
- [0x70110, hasm, hasm/ido/math_util]
- [0x71730, c, memory]
- [0x72930, c, ../libultra/src/io/motor]
- [0x72E50, c, save_data]
Expand Down Expand Up @@ -290,7 +290,7 @@ segments:
- [0xDDF90, .data, joypad]
- [0xDDFA0, .data, game]
- [0xDDFD0, .data, thread3_main]
- [0xDE0C0, .data, hasm/math_util]
- [0xDE0C0, .data, hasm/ido/math_util]
- [0xDF0D0, .data, save_data]
- [0xDF120, .data, rcp_dkr]
- [0xDF3C0, .data, ../libultra/src/sc/sched]
Expand Down
4 changes: 2 additions & 2 deletions ver/splat/dkr.pal.v80.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ segments:
- [0x6AF40, c, joypad]
- [0x6B4F0, c, game]
- [0x6D170, c, thread3_main]
- [0x70350, hasm, hasm/math_util]
- [0x70350, hasm, hasm/ido/math_util]
- [0x71970, c, memory]
- [0x72B70, c, ../libultra/src/io/motor]
- [0x73090, c, save_data]
Expand Down Expand Up @@ -290,7 +290,7 @@ segments:
- [0xDE500, .data, joypad]
- [0xDE510, .data, game]
- [0xDE540, .data, thread3_main]
- [0xDE630, .data, hasm/math_util]
- [0xDE630, .data, hasm/ido/math_util]
- [0xDF640, .data, save_data]
- [0xDF6A0, .data, rcp_dkr]
- [0xDF940, .data, ../libultra/src/sc/sched]
Expand Down
4 changes: 2 additions & 2 deletions ver/splat/dkr.us.v77.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ segments:
- [0x6AD00, c, joypad]
- [0x6B2B0, c, game]
- [0x6CF30, c, thread3_main]
- [0x70110, hasm, hasm/math_util]
- [0x70110, hasm, hasm/ido/math_util]
- [0x71730, c, memory]
- [0x72930, c, ../libultra/src/io/motor]
- [0x72E50, c, save_data]
Expand Down Expand Up @@ -290,7 +290,7 @@ segments:
- [0xDDF00, .data, joypad]
- [0xDDF10, .data, game]
- [0xDDF40, .data, thread3_main]
- [0xDE030, .data, hasm/math_util]
- [0xDE030, .data, hasm/ido/math_util]
- [0xDF040, .data, save_data]
- [0xDF090, .data, rcp_dkr]
- [0xDF330, .data, ../libultra/src/sc/sched]
Expand Down
4 changes: 2 additions & 2 deletions ver/splat/dkr.us.v80.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ segments:
- [0x6AF40, c, joypad]
- [0x6B4F0, c, game]
- [0x6D170, c, thread3_main]
- [0x70350, hasm, hasm/math_util]
- [0x70350, hasm, hasm/ido/math_util]
- [0x71970, c, memory]
- [0x72B70, c, ../libultra/src/io/motor]
- [0x73090, c, save_data]
Expand Down Expand Up @@ -290,7 +290,7 @@ segments:
- [0xDE470, .data, joypad]
- [0xDE480, .data, game]
- [0xDE4B0, .data, thread3_main]
- [0xDE5A0, .data, hasm/math_util]
- [0xDE5A0, .data, hasm/ido/math_util]
- [0xDF5B0, .data, save_data]
- [0xDF610, .data, rcp_dkr]
- [0xDF8B0, .data, ../libultra/src/sc/sched]
Expand Down
1 change: 0 additions & 1 deletion ver/symbols/symbol_addrs.jpn.v79.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,6 @@ sins_s16 = 0x80070910;
coss_2 = 0x8007096C;
sins_2 = 0x80070970;
calc_dyn_lighting_for_level_segment = 0x800709B0;
func_80070A04 = 0x80070AE4;
area_triangle_2d = 0x80070B0C;
set_breakpoint = 0x80070BB8;
dmacopy_doubleword = 0x80070BE4;
Expand Down
1 change: 0 additions & 1 deletion ver/symbols/symbol_addrs.pal.v77.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,6 @@ sins_s16 = 0x80070830;
coss_2 = 0x8007088C;
sins_2 = 0x80070890;
calc_dyn_lighting_for_level_segment = 0x800708D0;
func_80070A04 = 0x80070A04;
area_triangle_2d = 0x80070A2C;
set_breakpoint = 0x80070AD8;
dmacopy_doubleword = 0x80070B04;
Expand Down
1 change: 0 additions & 1 deletion ver/symbols/symbol_addrs.pal.v80.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,6 @@ sins_s16 = 0x80070A70;
coss_2 = 0x80070ACC;
sins_2 = 0x80070AD0;
calc_dyn_lighting_for_level_segment = 0x80070B10;
func_80070A04 = 0x80070C44;
area_triangle_2d = 0x80070C6C;
set_breakpoint = 0x80070D18;
dmacopy_doubleword = 0x80070D44;
Expand Down
1 change: 0 additions & 1 deletion ver/symbols/symbol_addrs.us.v77.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,6 @@ sins_s16 = 0x80070830;
coss_2 = 0x8007088C;
sins_2 = 0x80070890;
calc_dyn_lighting_for_level_segment = 0x800708D0;
func_80070A04 = 0x80070A04;
area_triangle_2d = 0x80070A2C;
set_breakpoint = 0x80070AD8;
dmacopy_doubleword = 0x80070B04;
Expand Down
1 change: 0 additions & 1 deletion ver/symbols/symbol_addrs.us.v80.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,6 @@ sins_s16 = 0x80070A70;
coss_2 = 0x80070ACC;
sins_2 = 0x80070AD0;
calc_dyn_lighting_for_level_segment = 0x80070B10;
func_80070A04 = 0x80070C44;
area_triangle_2d = 0x80070C6C;
set_breakpoint = 0x80070D18;
dmacopy_doubleword = 0x80070D44;
Expand Down