Skip to content

Commit

Permalink
Merge branch 'master' into uintptr
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaMech authored Sep 11, 2024
2 parents 87c2a48 + 3f353d7 commit e682f68
Show file tree
Hide file tree
Showing 18 changed files with 277 additions and 469 deletions.
11 changes: 6 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
FROM ubuntu:22.04 as build
FROM ubuntu:24.04 as build

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
apt-get upgrade -y && \
apt-get install -y \
binutils-mips-linux-gnu \
build-essential \
cmake \
git \
libaudiofile-dev \
libcapstone-dev \
git \
pkg-config \
python3 \
wget \
zlib1g-dev

RUN mkdir /mk64
WORKDIR /mk64

CMD echo 'Usage: docker run -it --rm -v ${PWD}:/mk64 mk64 make\n'\
CMD echo 'Usage: docker run --rm -v ${PWD}:/mk64 mk64 make\n'\
'See https://github.com/n64decomp/mk64/blob/master/README.md for more information'
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,20 @@ GLOBAL_ASM_RACING_O_FILES = $(foreach file,$(GLOBAL_ASM_RACING_C_FILES),$(BUILD_

# detect prefix for MIPS toolchain
ifneq ($(CROSS),)
else ifneq ($(call find-command,mips-linux-gnu-ld),)
CROSS := mips-linux-gnu-
else ifneq ($(call find-command,mips64-linux-gnu-ld),)
CROSS := mips64-linux-gnu-
else ifneq ($(call find-command,mips64-elf-ld),)
CROSS := mips64-elf-
CROSS := mips64-elf-
# else ifneq ($(call find-command,mips-n64-ld),)
# CROSS := mips-n64-
else ifneq ($(call find-command,mips64-ld),)
CROSS := mips64-
else ifneq ($(call find-command,mips-linux-gnu-ld),)
CROSS := mips-linux-gnu-
else ifneq ($(call find-command,mips64-linux-gnu-ld),)
CROSS := mips64-linux-gnu-
else ifneq ($(call find-command,mips-ld),)
CROSS := mips-
else
$(error Unable to detect a suitable MIPS toolchain installed)
$(error Unable to detect a suitable MIPS toolchain installed)
endif

AS := $(CROSS)as
Expand Down
4 changes: 2 additions & 2 deletions asm/non_matchings/code_80091750/func_8009F5E0.s
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,15 @@ glabel L8009FE9C
/* 0A0AC4 8009FEC4 01625823 */ subu $t3, $t3, $v0
/* 0A0AC8 8009FEC8 00037080 */ sll $t6, $v1, 2
/* 0A0ACC 8009FECC 01AE7821 */ addu $t7, $t5, $t6
/* 0A0AD0 8009FED0 3C05800F */ lui $a1, %hi(gGameModeFromNumPlayersAndRowSelection) # 0x800f
/* 0A0AD0 8009FED0 3C05800F */ lui $a1, %hi((gGameModePlayerSelection - 0xC)) # 0x800f
/* 0A0AD4 8009FED4 2518FFEE */ addiu $t8, $t0, -0x12
/* 0A0AD8 8009FED8 01636021 */ addu $t4, $t3, $v1
/* 0A0ADC 8009FEDC 00CC3021 */ addu $a2, $a2, $t4
/* 0A0AE0 8009FEE0 00AF2821 */ addu $a1, $a1, $t7
/* 0A0AE4 8009FEE4 2F010008 */ sltiu $at, $t8, 8
/* 0A0AE8 8009FEE8 80C686AD */ lb $a2, %lo((D_800E86B0 - 3))($a2) # -0x7953($a2)
/* 0A0AEC 8009FEEC 10200037 */ beqz $at, .L8009FFCC
/* 0A0AF0 8009FEF0 8CA52B70 */ lw $a1, %lo(gGameModeFromNumPlayersAndRowSelection)($a1) # 0x2b70($a1)
/* 0A0AF0 8009FEF0 8CA52B70 */ lw $a1, %lo((gGameModePlayerSelection - 0xC))($a1) # 0x2b70($a1)
/* 0A0AF4 8009FEF4 0018C080 */ sll $t8, $t8, 2
/* 0A0AF8 8009FEF8 3C01800F */ lui $at, %hi(jpt_800F1AD0)
/* 0A0AFC 8009FEFC 00380821 */ addu $at, $at, $t8
Expand Down
92 changes: 46 additions & 46 deletions asm/non_matchings/menus/main_menu_act.s

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mk64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ SECTIONS
BUILD_DIR/src/os/osContInit.o(.bss*);
BUILD_DIR/src/os/osPfsIsPlug.o(.bss*);
BUILD_DIR/src/os/guRotateF.o(.bss*);
BUILD_DIR/src/os/leointerrupt.o(.bss*);
BUILD_DIR/src/os/__osLeoInterrupt.o(.bss*);
BUILD_DIR/src/os/osTimer.o(.bss*);
BUILD_DIR/src/os/__osPiCreateAccessQueue.o(.bss*);
BUILD_DIR/src/os/__osSiCreateAccessQueue.o(.bss*);
Expand Down
48 changes: 34 additions & 14 deletions src/code_80091750.c
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,9 @@ Gfx* func_800959F8(Gfx* displayListHead, Vtx* arg1) {
return displayListHead;
}

#ifdef AVOID_UB
#define MTX_TYPE Mtx
#else
typedef struct {
u16 i[4][4];
u16 f[4][4];
Expand All @@ -2557,28 +2560,42 @@ typedef union {
s32 w;
} TheWhyUnion;

#define MTX_TYPE Mtx2
#endif

// Why... Why... Why... This function is so bad it's not going in the header.
void func_80095AE0(Mtx2* arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
void func_80095AE0(MTX_TYPE* arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
#ifdef AVOID_UB
// Use Mat4 array to set matrix values using guMtxF2L. This helps little-endian systems.
Mat4 src;
src[0][0] = arg3;
src[0][1] = 0.0f;
src[0][2] = 0.0f;
src[0][3] = 0.0f;
src[1][0] = 0.0f;
src[1][1] = arg4;
src[1][2] = 0.0f;
src[1][3] = 0.0f;
src[2][0] = 0.0f;
src[2][1] = 0.0f;
src[2][2] = 1.0f;
src[2][3] = 0.0f;
src[3][0] = arg1;
src[3][1] = arg2;
src[3][2] = 0.0f;
src[3][3] = 1.0f;
guMtxF2L(src, arg0);
#else
TheWhyUnion sp14;
TheWhyUnion sp10;
TheWhyUnion spC;
TheWhyUnion sp8;
s32 i;

#ifdef AVOID_UB
size_t row;
size_t col;
for (row = 0; row < 4; row++) {
for (col = 0; col < 4; col++) {
arg0->m[row][col] = 0;
}
}
#else
// clang-format off
// should be inline
for(i = 0; i < 16; i++) { arg0->m[0][i] = 0; }
// clang-format on
#endif

sp14.w = arg3 * 65536.0f;
sp10.w = arg4 * 65536.0f;
Expand All @@ -2594,8 +2611,11 @@ void func_80095AE0(Mtx2* arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) {
arg0->u.f[1][1] = sp10.s[1];
arg0->u.f[3][0] = spC.s[1];
arg0->u.f[3][1] = sp8.s[1];
#endif
}

#undef MTX_TYPE

Gfx* func_80095BD0(Gfx* displayListHead, u8* arg1, f32 arg2, f32 arg3, u32 arg4, u32 arg5, f32 arg6, f32 arg7) {
Vtx* var_a1;
Mtx* sp28;
Expand Down Expand Up @@ -5906,7 +5926,7 @@ void func_8009F5E0(struct_8018D9E0_entry* arg0) {
case 0x18: /* switch 6 */
case 0x19: /* switch 6 */
var_v1 = D_800E86B0[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
var_a1 = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
var_a1 = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
switch (arg0->type) { /* switch 5 */
case 0x12: /* switch 5 */
case 0x13: /* switch 5 */
Expand Down Expand Up @@ -8843,7 +8863,7 @@ void func_800A8270(s32 arg0, struct_8018D9E0_entry* arg1) {
} else {
gDisplayListHead = func_80098FC8(gDisplayListHead, var_s3, var_s0, var_s4, var_s0 + 0x35);
}
for (var_s0 += 0x41, var_s2 = 0; var_s2 <= D_800F2B60[0][arg0]; var_s2++, var_s0 += 0x12) {
for (var_s0 += 0x41, var_s2 = 0; var_s2 <= gPlayerModeSelection[arg0]; var_s2++, var_s0 += 0x12) {
if ((var_s2 == D_800E86AC[arg0]) && ((arg0 + 1) == gPlayerCount) && (gMainMenuSelectionDepth >= 4)) {
if (gMainMenuSelectionDepth == GAME_MODE_SELECTION) {
gDisplayListHead =
Expand Down Expand Up @@ -9520,7 +9540,7 @@ void func_800A9E58(struct_8018D9E0_entry* arg0) {
break;
}

temp_a1 = gGameModeFromNumPlayersAndRowSelection[gPlayerCount][D_800E86AC[gPlayerCount - 1]];
temp_a1 = gGameModePlayerSelection[gPlayerCount - 1][D_800E86AC[gPlayerCount - 1]];
switch (arg0->cursor) { /* switch 5; irregular */
case 0: /* switch 5 */
if ((temp_a1 != sp20) && (temp_a1 != sp1C)) {
Expand Down
Loading

0 comments on commit e682f68

Please sign in to comment.