Update decomp (#63)

* update libultra asm (#648)

* update libultra asm

* fix gcc __osThreadTail

---------

Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>

* Document Vehicles (#641)

* start doc collision

* fix merge

* finish rename fonction related to vehicle

* document around waypoint of vehicle

* make some modification

* make some change and rename one

* copy_ to oldPos

* doc smoke ferry and train

* some rename

* fix some renaming

* precise index

* rename a funciton

* simplify waypoint_vehicles

* change some name

* change some name

* rename move_to_point_direction

* fix some conflict

* Update code_80005FD0.c

* Update code_80005FD0.h

---------

Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>

* Label a save info loop (#645)

* save info

* more gcc progress

* fix a value and do a rename (#669)

* fix error of compilation

---------

Co-authored-by: MegaMech <MegaMech@users.noreply.github.com>
This commit is contained in:
coco875 2024-08-25 02:39:52 +02:00 committed by GitHub
parent e135178097
commit 848b31c01e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
60 changed files with 2743 additions and 1326 deletions

View File

@ -81,6 +81,7 @@ endif
ifeq ($(COMPILER),ido)
MIPSISET := -mips2
else ifeq ($(COMPILER),gcc)
DEFINES += AVOID_UB=1 NON_MATCHING=1
NON_MATCHING := 1
VERSION_ASFLAGS := --defsym AVOID_UB=1
MIPSISET := -mips3
@ -633,7 +634,7 @@ $(GLOBAL_ASM_RACING_O_FILES): CC := $(PYTHON) $(TOOLS_DIR)/asm_processor/build.p
$(BUILD_DIR)/src/os/%.o: OPT_FLAGS :=
$(BUILD_DIR)/src/os/math/%.o: OPT_FLAGS := -O2
$(BUILD_DIR)/src/os/math/ll%.o: OPT_FLAGS :=
$(BUILD_DIR)/src/os/math/ll%.o: MIPSISET := -mips3 -32
$(BUILD_DIR)/src/os/math/ll%.o: MIPSISET := -mips3
$(BUILD_DIR)/src/os/ldiv.o: OPT_FLAGS := -O2
$(BUILD_DIR)/src/os/string.o: OPT_FLAGS := -O2
$(BUILD_DIR)/src/os/gu%.o: OPT_FLAGS := -O3

View File

@ -19,8 +19,8 @@ glabel ipl3_entry # 0xA4000040
mtc0 $zero, $13
mtc0 $zero, $9
mtc0 $zero, $11
lui $t0, %hi(RI_MODE_REG)
addiu $t0, %lo(RI_MODE_REG)
lui $t0, %hi(PHYS_TO_K1|RI_MODE_REG)
addiu $t0, %lo(PHYS_TO_K1|RI_MODE_REG)
lw $t1, 0xc($t0)
bnez $t1, .LA4000410
nop
@ -30,12 +30,12 @@ glabel ipl3_entry # 0xA4000040
sw $s5, 8($sp)
sw $s6, 0xc($sp)
sw $s7, 0x10($sp)
lui $t0, %hi(RI_MODE_REG)
addiu $t0, %lo(RI_MODE_REG)
lui $t0, %hi(PHYS_TO_K1|RI_MODE_REG)
addiu $t0, %lo(PHYS_TO_K1|RI_MODE_REG)
lui $t2, (0xa3f80000 >> 16)
lui $t3, (0xa3f00000 >> 16)
lui $t4, %hi(MI_MODE_REG)
addiu $t4, %lo(MI_MODE_REG)
lui $t4, %hi(PHYS_TO_K1|MI_MODE_REG)
addiu $t4, %lo(PHYS_TO_K1|MI_MODE_REG)
ori $t1, $zero, 64
sw $t1, 4($t0)
li $s1, 8000
@ -81,8 +81,8 @@ glabel ipl3_entry # 0xA4000040
lui $s4, (0xA0000000 >> 16)
addiu $sp, $sp, -0x48
move $fp, $sp
lui $s0, %hi(MI_VERSION_REG)
lw $s0, %lo(MI_VERSION_REG)($s0)
lui $s0, %hi(PHYS_TO_K1|MI_VERSION_REG)
lw $s0, %lo(PHYS_TO_K1|MI_VERSION_REG)($s0)
lui $s1, (0x01010101 >> 16)
addiu $s1, (0x01010101 & 0xFFFF)
bne $s0, $s1, .LA4000160
@ -232,13 +232,13 @@ glabel ipl3_entry # 0xA4000040
slt $t0, $v1, $t5
bnez $t0, .LA4000274
nop
lui $t2, %hi(RI_REFRESH_REG)
lui $t2, %hi(PHYS_TO_K1|RI_REFRESH_REG)
sll $s2, $s2, 0x13
lui $t1, (0x00063634 >> 16)
ori $t1, (0x00063634 & 0xFFFF)
or $t1, $t1, $s2
sw $t1, %lo(RI_REFRESH_REG)($t2)
lw $t1, %lo(RI_REFRESH_REG)($t2)
sw $t1, %lo(PHYS_TO_K1|RI_REFRESH_REG)($t2)
lw $t1, %lo(PHYS_TO_K1|RI_REFRESH_REG)($t2)
lui $t0, (0xA0000300 >> 16)
ori $t0, (0xA0000300 & 0xFFFF)
lui $t1, (0x0FFFFFFF >> 16)
@ -328,24 +328,24 @@ glabel ipl3_entry # 0xA4000040
lw $t1, %lo(D_B0000008)($t3)
lui $t2, (0x1FFFFFFF >> 16)
ori $t2, (0x1FFFFFFF & 0xFFFF)
lui $at, %hi(PI_DRAM_ADDR_REG)
lui $at, %hi(PHYS_TO_K1|PI_DRAM_ADDR_REG)
and $t1, $t1, $t2
sw $t1, %lo(PI_DRAM_ADDR_REG)($at)
lui $t0, %hi(PI_STATUS_REG)
sw $t1, %lo(PHYS_TO_K1|PI_DRAM_ADDR_REG)($at)
lui $t0, %hi(PHYS_TO_K1|PI_STATUS_REG)
.LA40004D0:
lw $t0, %lo(PI_STATUS_REG)($t0)
lw $t0, %lo(PHYS_TO_K1|PI_STATUS_REG)($t0)
andi $t0, $t0, 2
bnezl $t0, .LA40004D0
lui $t0, %hi(PI_STATUS_REG)
lui $t0, %hi(PHYS_TO_K1|PI_STATUS_REG)
li $t0, 0x1000
add $t0, $t0, $t3
and $t0, $t0, $t2
lui $at, %hi(PI_CART_ADDR_REG)
sw $t0, %lo(PI_CART_ADDR_REG)($at)
lui $at, %hi(PHYS_TO_K1|PI_CART_ADDR_REG)
sw $t0, %lo(PHYS_TO_K1|PI_CART_ADDR_REG)($at)
lui $t2, 0x0010
addiu $t2, 0xFFFF
lui $at, %hi(PI_WR_LEN_REG)
sw $t2, %lo(PI_WR_LEN_REG)($at)
lui $at, %hi(PHYS_TO_K1|PI_WR_LEN_REG)
sw $t2, %lo(PHYS_TO_K1|PI_WR_LEN_REG)($at)
.LA4000514:
nop
@ -376,8 +376,8 @@ glabel ipl3_entry # 0xA4000040
nop
nop
nop
lui $t3, %hi(PI_STATUS_REG)
lw $t3, %lo(PI_STATUS_REG)($t3)
lui $t3, %hi(PHYS_TO_K1|PI_STATUS_REG)
lw $t3, %lo(PHYS_TO_K1|PI_STATUS_REG)($t3)
andi $t3, $t3, 0x1
bnez $t3, .LA4000514
nop
@ -451,37 +451,37 @@ halt: # checksum fail
nop
func_A4000690:
lui $t1, %hi(SP_PC)
lw $t1, %lo(SP_PC)($t1)
lui $t1, %hi(PHYS_TO_K1|SP_PC_REG)
lw $t1, %lo(PHYS_TO_K1|SP_PC_REG)($t1)
lw $s0, 0x14($sp)
lw $ra, 0x1c($sp)
beqz $t1, .LA40006BC
addiu $sp, $sp, 0x20
li $t2, 65
lui $at, %hi(SP_STATUS_REG)
sw $t2, %lo(SP_STATUS_REG)($at)
lui $at, %hi(SP_PC)
sw $zero, %lo(SP_PC)($at)
lui $at, %hi(PHYS_TO_K1|SP_STATUS_REG)
sw $t2, %lo(PHYS_TO_K1|SP_STATUS_REG)($at)
lui $at, %hi(PHYS_TO_K1|SP_PC_REG)
sw $zero, %lo(PHYS_TO_K1|SP_PC_REG)($at)
.LA40006BC:
lui $t3, (0x00AAAAAE >> 16)
ori $t3, (0x00AAAAAE & 0xFFFF)
lui $at, %hi(SP_STATUS_REG)
sw $t3, %lo(SP_STATUS_REG)($at)
lui $at, %hi(MI_INTR_MASK_REG)
lui $at, %hi(PHYS_TO_K1|SP_STATUS_REG)
sw $t3, %lo(PHYS_TO_K1|SP_STATUS_REG)($at)
lui $at, %hi(PHYS_TO_K1|MI_INTR_MASK_REG)
li $t0, 1365
sw $t0, %lo(MI_INTR_MASK_REG)($at)
lui $at, %hi(SI_STATUS_REG)
sw $zero, %lo(SI_STATUS_REG)($at)
lui $at, %hi(AI_STATUS_REG)
sw $zero, %lo(AI_STATUS_REG)($at)
lui $at, %hi(MI_MODE_REG)
sw $t0, %lo(PHYS_TO_K1|MI_INTR_MASK_REG)($at)
lui $at, %hi(PHYS_TO_K1|SI_STATUS_REG)
sw $zero, %lo(PHYS_TO_K1|SI_STATUS_REG)($at)
lui $at, %hi(PHYS_TO_K1|AI_STATUS_REG)
sw $zero, %lo(PHYS_TO_K1|AI_STATUS_REG)($at)
lui $at, %hi(PHYS_TO_K1|MI_MODE_REG)
li $t1, 2048
sw $t1, %lo(MI_MODE_REG)($at)
sw $t1, %lo(PHYS_TO_K1|MI_MODE_REG)($at)
li $t1, 2
lui $at, %hi(PI_STATUS_REG)
lui $at, %hi(PHYS_TO_K1|PI_STATUS_REG)
lui $t0, (0xA0000300 >> 16)
ori $t0, (0xA0000300 & 0xFFFF)
sw $t1, %lo(PI_STATUS_REG)($at)
sw $t1, %lo(PHYS_TO_K1|PI_STATUS_REG)($at)
sw $s7, 0x14($t0)
sw $s5, 0xc($t0)
sw $s3, 0x4($t0)
@ -747,8 +747,8 @@ func_A4000A40:
li $k1, 1
bne $a1, $k1, .LA4000AC0
sw $t7, ($s5)
lui $k0, %hi(MI_MODE_REG)
sw $zero, %lo(MI_MODE_REG)($k0)
lui $k0, %hi(PHYS_TO_K1|MI_MODE_REG)
sw $zero, %lo(PHYS_TO_K1|MI_MODE_REG)($k0)
.LA4000AC0:
lw $ra, 0x1c($sp)
addiu $sp, $sp, 0x28
@ -759,12 +759,12 @@ func_A4000AD0:
addiu $sp, $sp, -0x28
sw $ra, 0x1c($sp)
li $k0, 0x2000
lui $k1, %hi(MI_MODE_REG)
sw $k0, %lo(MI_MODE_REG)($k1)
lui $k1, %hi(PHYS_TO_K1|MI_MODE_REG)
sw $k0, %lo(PHYS_TO_K1|MI_MODE_REG)($k1)
move $fp, $zero
lw $fp, ($s5)
li $k0, 0x1000
sw $k0, %lo(MI_MODE_REG)($k1)
sw $k0, %lo(PHYS_TO_K1|MI_MODE_REG)($k1)
li $k1, 0x40
and $k1, $k1, $fp
srl $k1, $k1, 6

View File

@ -18,7 +18,7 @@ glabel audio_init
/* BCD08 800BC108 3C04800F */ lui $a0, %hi(gAudioHeapSize)
/* BCD0C 800BC10C 8C84A710 */ lw $a0, %lo(gAudioHeapSize)($a0)
/* BCD10 800BC110 00001825 */ or $v1, $zero, $zero
/* BCD14 800BC114 3C0A803B */ lui $t2, %hi(D_803B71A0)
/* BCD14 800BC114 3C0A803B */ lui $t2, %hi(gAudioGlobalsEndMarker)
/* BCD18 800BC118 04810003 */ bgez $a0, .L800BC128
/* BCD1C 800BC11C 000478C3 */ sra $t7, $a0, 3
/* BCD20 800BC120 24810007 */ addiu $at, $a0, 0x7
@ -40,7 +40,7 @@ glabel audio_init
/* BCD58 800BC158 AC48FFF8 */ sw $t0, -0x8($v0)
.L800BC15C:
/* BCD5C 800BC15C 2482F780 */ addiu $v0, $a0, %lo(gGfxSPTaskOutputBufferSize)
/* BCD60 800BC160 254A71A0 */ addiu $t2, $t2, %lo(D_803B71A0)
/* BCD60 800BC160 254A71A0 */ addiu $t2, $t2, %lo(gAudioGlobalsEndMarker)
/* BCD64 800BC164 01421823 */ subu $v1, $t2, $v0
/* BCD68 800BC168 000380C2 */ srl $s0, $v1, 3
/* BCD6C 800BC16C 06000008 */ bltz $s0, .L800BC190

View File

@ -26,7 +26,7 @@ glabel audio_init
/* 0BCD08 800BC108 3C04800F */ lui $a0, %hi(gAudioHeapSize) # $a0, 0x800f
/* 0BCD0C 800BC10C 8C84A5D0 */ lw $a0, %lo(gAudioHeapSize)($a0)
/* 0BCD10 800BC110 00001825 */ move $v1, $zero
/* 0BCD14 800BC114 3C0A803B */ lui $t2, %hi(D_803B71A0) # $t2, 0x803b
/* 0BCD14 800BC114 3C0A803B */ lui $t2, %hi(gAudioGlobalsEndMarker) # $t2, 0x803b
/* 0BCD18 800BC118 04810003 */ bgez $a0, .L800BC128
/* 0BCD1C 800BC11C 000478C3 */ sra $t7, $a0, 3
/* 0BCD20 800BC120 24810007 */ addiu $at, $a0, 7
@ -48,7 +48,7 @@ glabel audio_init
/* 0BCD58 800BC158 AC48FFF8 */ sw $t0, -8($v0)
.L800BC15C:
/* 0BCD5C 800BC15C 2482F780 */ addiu $v0, $a0, %lo(gGfxSPTaskOutputBufferSize) # -0x880
/* 0BCD60 800BC160 254A71A0 */ addiu $t2, %lo(D_803B71A0) # addiu $t2, $t2, 0x71a0
/* 0BCD60 800BC160 254A71A0 */ addiu $t2, %lo(gAudioGlobalsEndMarker) # addiu $t2, $t2, 0x71a0
/* 0BCD64 800BC164 01421823 */ subu $v1, $t2, $v0
/* 0BCD68 800BC168 000380C2 */ srl $s0, $v1, 3
/* 0BCD6C 800BC16C 06000007 */ bltz $s0, .L800BC18C

View File

@ -8,10 +8,10 @@
glabel __osDisableInt
mfc0 $t0, $12
and $t1, $t0, -2
mtc0 $t1, $12
andi $v0, $t0, 1
mfc0 $t0, C0_SR
and $t1, $t0, ~SR_IE
mtc0 $t1, C0_SR
andi $v0, $t0, SR_IE
nop
jr $ra
nop

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
.section .text, "ax"
glabel __osGetSR
mfc0 $v0, $12
mfc0 $v0, C0_SR
jr $ra
nop

View File

@ -8,20 +8,20 @@
.section .text, "ax"
glabel __osProbeTLB
mfc0 $t0, $10
andi $t1, $t0, 0xff
li $at, -8192
mfc0 $t0, C0_ENTRYHI
andi $t1, $t0, TLBHI_PIDMASK
li $at, TLBHI_VPN2MASK
and $t2, $a0, $at
or $t1, $t1, $t2
mtc0 $t1, $10
mtc0 $t1, C0_ENTRYHI
nop
nop
nop
tlbp
nop
nop
mfc0 $t3, $0
lui $at, 0x8000
mfc0 $t3, C0_INX
lui $at, %hi(TLBINX_PROBE)
and $t3, $t3, $at
bnez $t3, .L8032A0D8
nop
@ -29,25 +29,25 @@ glabel __osProbeTLB
nop
nop
nop
mfc0 $t3, $5
addi $t3, $t3, 0x2000
mfc0 $t3, C0_PAGEMASK
addi $t3, $t3, DCACHE_SIZE
srl $t3, $t3, 1
and $t4, $t3, $a0
bnez $t4, .L8032A0A8
addi $t3, $t3, -1
mfc0 $v0, $2
mfc0 $v0, C0_ENTRYLO0
b .L8032A0AC
nop
.L8032A0A8:
mfc0 $v0, $3
mfc0 $v0, C0_ENTRYLO1
.L8032A0AC:
andi $t5, $v0, 2
andi $t5, $v0, TLBLO_V
beqz $t5, .L8032A0D8
nop
lui $at, (0x3FFFFFC0 >> 16) # lui $at, 0x3fff
ori $at, (0x3FFFFFC0 & 0xFFFF) # ori $at, $at, 0xffc0
lui $at, (TLBLO_PFNMASK >> 16) # lui $at, 0x3fff
ori $at, %lo(TLBLO_PFNMASK) # ori $at, $at, 0xffc0
and $v0, $v0, $at
sll $v0, $v0, 6
sll $v0, $v0, TLBLO_PFNSHIFT
and $t5, $a0, $t3
add $v0, $v0, $t5
b .L8032A0DC
@ -55,7 +55,7 @@ glabel __osProbeTLB
.L8032A0D8:
li $v0, -1
.L8032A0DC:
mtc0 $t0, $10
mtc0 $t0, C0_ENTRYHI
jr $ra
nop

View File

@ -7,9 +7,9 @@
.section .text, "ax"
glabel __osRestoreInt
mfc0 $t0, $12
mfc0 $t0, C0_SR
or $t0, $t0, $a0
mtc0 $t0, $12
mtc0 $t0, C0_SR
nop
nop
jr $ra

View File

@ -7,7 +7,7 @@
.section .text, "ax"
glabel __osSetCompare
mtc0 $a0, $11
mtc0 $a0, C0_COMPARE
jr $ra
nop

View File

@ -7,7 +7,7 @@
.section .text, "ax"
glabel __osSetSR
mtc0 $a0, $12
mtc0 $a0, C0_SR
nop
jr $ra
nop

View File

@ -8,28 +8,28 @@
.section .text, "ax"
glabel bcopy
beqz $a2, .L80323A4C
beqz $a2, ret
move $a3, $a1
beq $a0, $a1, .L80323A4C
beq $a0, $a1, ret
slt $at, $a1, $a0
bnezl $at, .L80323A14
bnezl $at, goforwards
slti $at, $a2, 0x10
add $v0, $a0, $a2
slt $at, $a1, $v0
beql $at, $zero, .L80323A14
beql $at, $zero, goforwards
slti $at, $a2, 0x10
b .L80323B78
b gobackwards
slti $at, $a2, 0x10
slti $at, $a2, 0x10
.L80323A14:
bnez $at, .L80323A2C
goforwards:
bnez $at, forwards_bytecopy
nop
andi $v0, $a0, 3
andi $v1, $a1, 3
beq $v0, $v1, .L80323A54
beq $v0, $v1, forwalignable
nop
.L80323A2C:
beqz $a2, .L80323A4C
forwards_bytecopy:
beqz $a2, ret
nop
addu $v1, $a0, $a2
.L80323A38:
@ -38,31 +38,31 @@ glabel bcopy
addiu $a1, $a1, 1
bne $a0, $v1, .L80323A38
sb $v0, -1($a1)
.L80323A4C:
ret:
jr $ra
move $v0, $a3
.L80323A54:
beqz $v0, .L80323AB8
forwalignable:
beqz $v0, forwards
li $at, 1
beq $v0, $at, .L80323A9C
beq $v0, $at, forw_copy3
li $at, 2
beql $v0, $at, .L80323A88
beql $v0, $at, forw_copy2
lh $v0, ($a0)
lb $v0, ($a0)
addiu $a0, $a0, 1
addiu $a1, $a1, 1
addiu $a2, $a2, -1
b .L80323AB8
b forwards
sb $v0, -1($a1)
lh $v0, ($a0)
.L80323A88:
forw_copy2:
addiu $a0, $a0, 2
addiu $a1, $a1, 2
addiu $a2, $a2, -2
b .L80323AB8
b forwards
sh $v0, -2($a1)
.L80323A9C:
forw_copy3:
lb $v0, ($a0)
lh $v1, 1($a0)
addiu $a0, $a0, 3
@ -70,9 +70,9 @@ glabel bcopy
addiu $a2, $a2, -3
sb $v0, -3($a1)
sh $v1, -2($a1)
.L80323AB8:
forwards:
slti $at, $a2, 0x20
bnezl $at, .L80323B18
bnezl $at, forwards_16
slti $at, $a2, 0x10
lw $v0, ($a0)
lw $v1, 4($a0)
@ -92,11 +92,11 @@ glabel bcopy
sw $t2, -0x10($a1)
sw $t3, -0xc($a1)
sw $t4, -8($a1)
b .L80323AB8
b forwards
sw $t5, -4($a1)
.L80323B14:
slti $at, $a2, 0x10
.L80323B18:
forwards_16:
bnezl $at, .L80323B54
slti $at, $a2, 4
lw $v0, ($a0)
@ -111,19 +111,19 @@ glabel bcopy
sw $t0, -8($a1)
b .L80323B14
sw $t1, -4($a1)
.L80323B50:
forwards_4:
slti $at, $a2, 4
.L80323B54:
bnez $at, .L80323A2C
bnez $at, forwards_bytecopy
nop
lw $v0, ($a0)
addiu $a0, $a0, 4
addiu $a1, $a1, 4
addiu $a2, $a2, -4
b .L80323B50
b forwards_4
sw $v0, -4($a1)
slti $at, $a2, 0x10
.L80323B78:
gobackwards:
add $a0, $a0, $a2
bnez $at, .L80323B94
add $a1, $a1, $a2
@ -132,7 +132,7 @@ glabel bcopy
beq $v0, $v1, .L80323BC4
nop
.L80323B94:
beqz $a2, .L80323A4C
beqz $a2, ret
nop
addiu $a0, $a0, -1
addiu $a1, $a1, -1
@ -147,7 +147,7 @@ glabel bcopy
move $v0, $a3
.L80323BC4:
beqz $v0, .L80323C28
beqz $v0, backwards_32
li $at, 3
beq $v0, $at, .L80323C0C
li $at, 2
@ -157,14 +157,14 @@ glabel bcopy
addiu $a0, $a0, -1
addiu $a1, $a1, -1
addiu $a2, $a2, -1
b .L80323C28
b backwards_32
sb $v0, ($a1)
lh $v0, -2($a0)
.L80323BF8:
addiu $a0, $a0, -2
addiu $a1, $a1, -2
addiu $a2, $a2, -2
b .L80323C28
b backwards_32
sh $v0, ($a1)
.L80323C0C:
lb $v0, -1($a0)
@ -174,7 +174,7 @@ glabel bcopy
addiu $a2, $a2, -3
sb $v0, 2($a1)
sh $v1, ($a1)
.L80323C28:
backwards_32:
slti $at, $a2, 0x20
bnezl $at, .L80323C88
slti $at, $a2, 0x10
@ -196,9 +196,9 @@ glabel bcopy
sw $t2, 0xc($a1)
sw $t3, 8($a1)
sw $t4, 4($a1)
b .L80323C28
b backwards_32
sw $t5, ($a1)
.L80323C84:
backwards_16:
slti $at, $a2, 0x10
.L80323C88:
bnezl $at, .L80323CC4
@ -213,9 +213,9 @@ glabel bcopy
sw $v0, 0xc($a1)
sw $v1, 8($a1)
sw $t0, 4($a1)
b .L80323C84
b backwards_16
sw $t1, ($a1)
.L80323CC0:
backwards_4:
slti $at, $a2, 4
.L80323CC4:
bnez $at, .L80323B94
@ -224,7 +224,7 @@ glabel bcopy
addiu $a0, $a0, -4
addiu $a1, $a1, -4
addiu $a2, $a2, -4
b .L80323CC0
b backwards_4
sw $v0, ($a1)
nop
nop

View File

@ -11,17 +11,17 @@
glabel bzero
/* 0CE660 800CDA60 28A1000C */ slti $at, $a1, 0xc
/* 0CE664 800CDA64 1420001D */ bnez $at, .L800CDADC
/* 0CE664 800CDA64 1420001D */ bnez $at, bytezero
/* 0CE668 800CDA68 00041823 */ negu $v1, $a0
/* 0CE66C 800CDA6C 30630003 */ andi $v1, $v1, 3
/* 0CE670 800CDA70 10600003 */ beqz $v1, .L800CDA80
/* 0CE670 800CDA70 10600003 */ beqz $v1, blkzero
/* 0CE674 800CDA74 00A32823 */ subu $a1, $a1, $v1
/* 0CE678 800CDA78 A8800000 */ swl $zero, ($a0)
/* 0CE67C 800CDA7C 00832021 */ addu $a0, $a0, $v1
.L800CDA80:
blkzero:
/* 0CE680 800CDA80 2401FFE0 */ li $at, -32
/* 0CE684 800CDA84 00A13824 */ and $a3, $a1, $at
/* 0CE688 800CDA88 10E0000C */ beqz $a3, .L800CDABC
/* 0CE688 800CDA88 10E0000C */ beqz $a3, wordzero
/* 0CE68C 800CDA8C 00A72823 */ subu $a1, $a1, $a3
/* 0CE690 800CDA90 00E43821 */ addu $a3, $a3, $a0
.L800CDA94:
@ -35,25 +35,25 @@ glabel bzero
/* 0CE6B0 800CDAB0 AC80FFF8 */ sw $zero, -8($a0)
/* 0CE6B4 800CDAB4 1487FFF7 */ bne $a0, $a3, .L800CDA94
/* 0CE6B8 800CDAB8 AC80FFFC */ sw $zero, -4($a0)
.L800CDABC:
wordzero:
/* 0CE6BC 800CDABC 2401FFFC */ li $at, -4
/* 0CE6C0 800CDAC0 00A13824 */ and $a3, $a1, $at
/* 0CE6C4 800CDAC4 10E00005 */ beqz $a3, .L800CDADC
/* 0CE6C4 800CDAC4 10E00005 */ beqz $a3, bytezero
/* 0CE6C8 800CDAC8 00A72823 */ subu $a1, $a1, $a3
/* 0CE6CC 800CDACC 00E43821 */ addu $a3, $a3, $a0
.L800CDAD0:
/* 0CE6D0 800CDAD0 24840004 */ addiu $a0, $a0, 4
/* 0CE6D4 800CDAD4 1487FFFE */ bne $a0, $a3, .L800CDAD0
/* 0CE6D8 800CDAD8 AC80FFFC */ sw $zero, -4($a0)
.L800CDADC:
/* 0CE6DC 800CDADC 18A00005 */ blez $a1, .L800CDAF4
bytezero:
/* 0CE6DC 800CDADC 18A00005 */ blez $a1, zerodone
/* 0CE6E0 800CDAE0 00000000 */ nop
/* 0CE6E4 800CDAE4 00A42821 */ addu $a1, $a1, $a0
.L800CDAE8:
/* 0CE6E8 800CDAE8 24840001 */ addiu $a0, $a0, 1
/* 0CE6EC 800CDAEC 1485FFFE */ bne $a0, $a1, .L800CDAE8
/* 0CE6F0 800CDAF0 A080FFFF */ sb $zero, -1($a0)
.L800CDAF4:
zerodone:
/* 0CE6F4 800CDAF4 03E00008 */ jr $ra
/* 0CE6F8 800CDAF8 00000000 */ nop

View File

@ -11,7 +11,7 @@
glabel osInvalDCache
/* 0CE780 800CDB80 18A0001F */ blez $a1, .L800CDC00
/* 0CE784 800CDB84 00000000 */ nop
/* 0CE788 800CDB88 240B2000 */ li $t3, 8192
/* 0CE788 800CDB88 240B2000 */ li $t3, DCACHE_SIZE
/* 0CE78C 800CDB8C 00AB082B */ sltu $at, $a1, $t3
/* 0CE790 800CDB90 1020001D */ beqz $at, .L800CDC08
/* 0CE794 800CDB94 00000000 */ nop
@ -20,42 +20,42 @@ glabel osInvalDCache
/* 0CE7A0 800CDBA0 0109082B */ sltu $at, $t0, $t1
/* 0CE7A4 800CDBA4 10200016 */ beqz $at, .L800CDC00
/* 0CE7A8 800CDBA8 00000000 */ nop
/* 0CE7AC 800CDBAC 310A000F */ andi $t2, $t0, 0xf
/* 0CE7AC 800CDBAC 310A000F */ andi $t2, $t0, DCACHE_LINEMASK
/* 0CE7B0 800CDBB0 11400007 */ beqz $t2, .L800CDBD0
/* 0CE7B4 800CDBB4 2529FFF0 */ addiu $t1, $t1, -0x10
/* 0CE7B4 800CDBB4 2529FFF0 */ addiu $t1, $t1, -DCACHE_LINESIZE
/* 0CE7B8 800CDBB8 010A4023 */ subu $t0, $t0, $t2
/* 0CE7BC 800CDBBC BD150000 */ cache 0x15, ($t0)
/* 0CE7BC 800CDBBC BD150000 */ cache (C_HWBINV|CACH_PD), ($t0)
/* 0CE7C0 800CDBC0 0109082B */ sltu $at, $t0, $t1
/* 0CE7C4 800CDBC4 1020000E */ beqz $at, .L800CDC00
/* 0CE7C8 800CDBC8 00000000 */ nop
/* 0CE7CC 800CDBCC 25080010 */ addiu $t0, $t0, 0x10
/* 0CE7CC 800CDBCC 25080010 */ addiu $t0, $t0, DCACHE_LINESIZE
.L800CDBD0:
/* 0CE7D0 800CDBD0 312A000F */ andi $t2, $t1, 0xf
/* 0CE7D0 800CDBD0 312A000F */ andi $t2, $t1, DCACHE_LINEMASK
/* 0CE7D4 800CDBD4 11400006 */ beqz $t2, .L800CDBF0
/* 0CE7D8 800CDBD8 00000000 */ nop
/* 0CE7DC 800CDBDC 012A4823 */ subu $t1, $t1, $t2
/* 0CE7E0 800CDBE0 BD350010 */ cache 0x15, 0x10($t1)
/* 0CE7E0 800CDBE0 BD350010 */ cache C_HWBINV|CACH_PD, 0x10($t1)
/* 0CE7E4 800CDBE4 0128082B */ sltu $at, $t1, $t0
/* 0CE7E8 800CDBE8 14200005 */ bnez $at, .L800CDC00
/* 0CE7EC 800CDBEC 00000000 */ nop
.L800CDBF0:
/* 0CE7F0 800CDBF0 BD110000 */ cache 0x11, ($t0)
/* 0CE7F0 800CDBF0 BD110000 */ cache C_HINV|CACH_PD, ($t0)
/* 0CE7F4 800CDBF4 0109082B */ sltu $at, $t0, $t1
/* 0CE7F8 800CDBF8 1420FFFD */ bnez $at, .L800CDBF0
/* 0CE7FC 800CDBFC 25080010 */ addiu $t0, $t0, 0x10
/* 0CE7FC 800CDBFC 25080010 */ addiu $t0, $t0, DCACHE_LINESIZE
.L800CDC00:
/* 0CE800 800CDC00 03E00008 */ jr $ra
/* 0CE804 800CDC04 00000000 */ nop
.L800CDC08:
/* 0CE808 800CDC08 3C088000 */ li $t0, 0x80000000
/* 0CE808 800CDC08 3C088000 */ li $t0, KUSIZE
/* 0CE80C 800CDC0C 010B4821 */ addu $t1, $t0, $t3
/* 0CE810 800CDC10 2529FFF0 */ addiu $t1, $t1, -0x10
/* 0CE810 800CDC10 2529FFF0 */ addiu $t1, $t1, -DCACHE_LINESIZE
.L800CDC14:
/* 0CE814 800CDC14 BD010000 */ cache 1, ($t0)
/* 0CE818 800CDC18 0109082B */ sltu $at, $t0, $t1
/* 0CE81C 800CDC1C 1420FFFD */ bnez $at, .L800CDC14
/* 0CE820 800CDC20 25080010 */ addiu $t0, $t0, 0x10
/* 0CE820 800CDC20 25080010 */ addiu $t0, $t0, DCACHE_LINESIZE
/* 0CE824 800CDC24 03E00008 */ jr $ra
/* 0CE828 800CDC28 00000000 */ nop

View File

@ -12,7 +12,7 @@
glabel osInvalICache
/* 0CE700 800CDB00 18A00011 */ blez $a1, .L800CDB48
/* 0CE704 800CDB04 00000000 */ nop
/* 0CE708 800CDB08 240B4000 */ li $t3, 16384
/* 0CE708 800CDB08 240B4000 */ li $t3, ICACHE_SIZE
/* 0CE70C 800CDB0C 00AB082B */ sltu $at, $a1, $t3
/* 0CE710 800CDB10 1020000F */ beqz $at, .L800CDB50
/* 0CE714 800CDB14 00000000 */ nop
@ -21,27 +21,27 @@ glabel osInvalICache
/* 0CE720 800CDB20 0109082B */ sltu $at, $t0, $t1
/* 0CE724 800CDB24 10200008 */ beqz $at, .L800CDB48
/* 0CE728 800CDB28 00000000 */ nop
/* 0CE72C 800CDB2C 310A001F */ andi $t2, $t0, 0x1f
/* 0CE730 800CDB30 2529FFE0 */ addiu $t1, $t1, -0x20
/* 0CE72C 800CDB2C 310A001F */ andi $t2, $t0, ICACHE_LINEMASK
/* 0CE730 800CDB30 2529FFE0 */ addiu $t1, $t1, -ICACHE_LINESIZE
/* 0CE734 800CDB34 010A4023 */ subu $t0, $t0, $t2
.L800CDB38:
/* 0CE738 800CDB38 BD100000 */ cache 0x10, ($t0)
/* 0CE738 800CDB38 BD100000 */ cache C_HINV|CACH_PI, ($t0)
/* 0CE73C 800CDB3C 0109082B */ sltu $at, $t0, $t1
/* 0CE740 800CDB40 1420FFFD */ bnez $at, .L800CDB38
/* 0CE744 800CDB44 25080020 */ addiu $t0, $t0, 0x20
/* 0CE744 800CDB44 25080020 */ addiu $t0, $t0, ICACHE_LINESIZE
.L800CDB48:
/* 0CE748 800CDB48 03E00008 */ jr $ra
/* 0CE74C 800CDB4C 00000000 */ nop
.L800CDB50:
/* 0CE750 800CDB50 3C088000 */ li $t0, 0x80000000
/* 0CE750 800CDB50 3C088000 */ li $t0, KUSIZE
/* 0CE754 800CDB54 010B4821 */ addu $t1, $t0, $t3
/* 0CE758 800CDB58 2529FFE0 */ addiu $t1, $t1, -0x20
/* 0CE758 800CDB58 2529FFE0 */ addiu $t1, $t1, -ICACHE_LINESIZE
.L800CDB5C:
/* 0CE75C 800CDB5C BD000000 */ cache 0, ($t0)
/* 0CE75C 800CDB5C BD000000 */ cache C_IINV|CACH_PI, ($t0)
/* 0CE760 800CDB60 0109082B */ sltu $at, $t0, $t1
/* 0CE764 800CDB64 1420FFFD */ bnez $at, .L800CDB5C
/* 0CE768 800CDB68 25080020 */ addiu $t0, $t0, 0x20
/* 0CE768 800CDB68 25080020 */ addiu $t0, $t0, ICACHE_LINESIZE
/* 0CE76C 800CDB6C 03E00008 */ jr $ra
/* 0CE770 800CDB70 00000000 */ nop

View File

@ -8,26 +8,26 @@
.section .text, "ax"
glabel osMapTLBRdb
mfc0 $t0, $10
mfc0 $t0, C0_ENTRYHI
li $t1, 31
mtc0 $t1, $0
mtc0 $zero, $5
li $t2, 23
lui $t1, 0xc000
mtc0 $t1, $10
lui $t1, 0x8000
srl $t3, $t1, 6
mtc0 $t1, C0_INX
mtc0 $zero, C0_PAGEMASK
li $t2, TLBLO_UNCACHED | TLBLO_D | TLBLO_V | TLBLO_G
lui $t1, K2BASE >> 16
mtc0 $t1, C0_ENTRYHI
lui $t1, KUSIZE >> 16
srl $t3, $t1, TLBLO_PFNSHIFT
or $t3, $t3, $t2
mtc0 $t3, $2
li $t1, 1
mtc0 $t1, $3
mtc0 $t3, C0_ENTRYLO0
li $t1, TLBLO_G
mtc0 $t1, C0_ENTRYLO1
nop
tlbwi
nop
nop
nop
nop
mtc0 $t0, $10
mtc0 $t0, C0_ENTRYHI
jr $ra
nop

View File

@ -4,66 +4,64 @@
.include "macros.inc"
.eqv MI_INTR_MASK_REG, 0xA430000C
.set VERSION_EU_SH, 1
.section .text, "ax"
glabel osSetIntMask
.ifdef VERSION_EU_SH
mfc0 $t4, $12
andi $v0, $t4, 0xff01
mfc0 $t4, C0_SR
andi $v0, $t4, OS_IM_CPU
lui $t0, %hi(__OSGlobalIntMask) # $t0, 0x8030
addiu $t0, %lo(__OSGlobalIntMask) # addiu $t0, $t0, 0x208c
lw $t3, ($t0)
li $at, -1
xor $t0, $t3, $at
andi $t0, $t0, 0xff00
andi $t0, $t0, SR_IMASK
or $v0, $v0, $t0
.else
mfc0 $t1, $12
andi $v0, $t1, 0xff01
mfc0 $t1, C0_SR
andi $v0, $t1, OS_IM_CPU
.endif
lui $t2, %hi(MI_INTR_MASK_REG) # $t2, 0xa430
lw $t2, %lo(MI_INTR_MASK_REG)($t2)
lui $t2, %hi(PHYS_TO_K1|MI_INTR_MASK_REG) # $t2, 0xa430
lw $t2, %lo(PHYS_TO_K1|MI_INTR_MASK_REG)($t2)
.ifdef VERSION_EU_SH
beqz $t2, .L80200074
srl $t1, $t3, 0x10
li $at, -1
xor $t1, $t1, $at
andi $t1, $t1, 0x3f
andi $t1, $t1, MI_INTR_MASK
or $t2, $t2, $t1
.L80200074:
.endif
sll $t2, $t2, 0x10
or $v0, $v0, $t2
lui $at, 0x3f
lui $at, MI_INTR_MASK
and $t0, $a0, $at
.ifdef VERSION_EU_SH
and $t0, $t0, $t3
.endif
srl $t0, $t0, 0xf
lui $t2, %hi(D_800F3C10)
lui $t2, %hi(__osRcpImTable)
addu $t2, $t2, $t0
lhu $t2, %lo(D_800F3C10)($t2)
lui $at, %hi(MI_INTR_MASK_REG) # $at, 0xa430
sw $t2, %lo(MI_INTR_MASK_REG)($at)
andi $t0, $a0, 0xff01
lhu $t2, %lo(__osRcpImTable)($t2)
lui $at, %hi(PHYS_TO_K1|MI_INTR_MASK_REG) # $at, 0xa430
sw $t2, %lo(PHYS_TO_K1|MI_INTR_MASK_REG)($at)
andi $t0, $a0, OS_IM_CPU
.ifdef VERSION_EU_SH
andi $t1, $t3, 0xff00
andi $t1, $t3, SR_IMASK
and $t0, $t0, $t1
.endif
lui $at, (0xFFFF00FF >> 16) # lui $at, 0xffff
ori $at, (0xFFFF00FF & 0xFFFF) # ori $at, $at, 0xff
lui $at, %hi(~SR_IMASK) # lui $at, 0xffff
ori $at, %lo(~SR_IMASK) # ori $at, $at, 0xff
.ifdef VERSION_EU_SH
and $t4, $t4, $at
or $t4, $t4, $t0
mtc0 $t4, $12
mtc0 $t4, C0_SR
.else
and $t1, $t1, $at
or $t1, $t1, $t0
mtc0 $t1, $12
mtc0 $t1, C0_SR
.endif
nop
nop
@ -73,68 +71,85 @@ glabel osSetIntMask
.section .rodata
glabel D_800F3C10
.half 0x0555
.half 0x0556
.half 0x0559
.half 0x055A
.half 0x0565
.half 0x0566
.half 0x0569
.half 0x056A
.half 0x0595
.half 0x0596
.half 0x0599
.half 0x059A
.half 0x05A5
.half 0x05A6
.half 0x05A9
.half 0x05AA
.half 0x0655
.half 0x0656
.half 0x0659
.half 0x065A
.half 0x0665
.half 0x0666
.half 0x0669
.half 0x066A
.half 0x0695
.half 0x0696
.half 0x0699
.half 0x069A
.half 0x06A5
.half 0x06A6
.half 0x06A9
.half 0x06AA
.half 0x0955
.half 0x0956
.half 0x0959
.half 0x095A
.half 0x0965
.half 0x0966
.half 0x0969
.half 0x096A
.half 0x0995
.half 0x0996
.half 0x0999
.half 0x099A
.half 0x09A5
.half 0x09A6
.half 0x09A9
.half 0x09AA
.half 0x0A55
.half 0x0A56
.half 0x0A59
.half 0x0A5A
.half 0x0A65
.half 0x0A66
.half 0x0A69
.half 0x0A6A
.half 0x0A95
.half 0x0A96
.half 0x0A99
.half 0x0A9A
.half 0x0AA5
.half 0x0AA6
.half 0x0AA9
.half 0x0AAA
.set MI_INTR_MASK, 0x3f
.set CLR_SP, 0x0001
.set SET_SP, 0x0002
.set CLR_SI, 0x0004
.set SET_SI, 0x0008
.set CLR_AI, 0x0010
.set SET_AI, 0x0020
.set CLR_VI, 0x0040
.set SET_VI, 0x0080
.set CLR_PI, 0x0100
.set SET_PI, 0x0200
.set CLR_DP, 0x0400
.set SET_DP, 0x0800
glabel __osRcpImTable
/* LUT to convert between MI_INTR and MI_INTR_MASK */
/* MI_INTR is status for each interrupt whereas */
/* MI_INTR_MASK has seperate bits for set/clr */
.half CLR_SP | CLR_SI | CLR_AI | CLR_VI | CLR_PI | CLR_DP
.half SET_SP | CLR_SI | CLR_AI | CLR_VI | CLR_PI | CLR_DP
.half CLR_SP | SET_SI | CLR_AI | CLR_VI | CLR_PI | CLR_DP
.half SET_SP | SET_SI | CLR_AI | CLR_VI | CLR_PI | CLR_DP
.half CLR_SP | CLR_SI | SET_AI | CLR_VI | CLR_PI | CLR_DP
.half SET_SP | CLR_SI | SET_AI | CLR_VI | CLR_PI | CLR_DP
.half CLR_SP | SET_SI | SET_AI | CLR_VI | CLR_PI | CLR_DP
.half SET_SP | SET_SI | SET_AI | CLR_VI | CLR_PI | CLR_DP
.half CLR_SP | CLR_SI | CLR_AI | SET_VI | CLR_PI | CLR_DP
.half SET_SP | CLR_SI | CLR_AI | SET_VI | CLR_PI | CLR_DP
.half CLR_SP | SET_SI | CLR_AI | SET_VI | CLR_PI | CLR_DP
.half SET_SP | SET_SI | CLR_AI | SET_VI | CLR_PI | CLR_DP
.half CLR_SP | CLR_SI | SET_AI | SET_VI | CLR_PI | CLR_DP
.half SET_SP | CLR_SI | SET_AI | SET_VI | CLR_PI | CLR_DP
.half CLR_SP | SET_SI | SET_AI | SET_VI | CLR_PI | CLR_DP
.half SET_SP | SET_SI | SET_AI | SET_VI | CLR_PI | CLR_DP
.half CLR_SP | CLR_SI | CLR_AI | CLR_VI | SET_PI | CLR_DP
.half SET_SP | CLR_SI | CLR_AI | CLR_VI | SET_PI | CLR_DP
.half CLR_SP | SET_SI | CLR_AI | CLR_VI | SET_PI | CLR_DP
.half SET_SP | SET_SI | CLR_AI | CLR_VI | SET_PI | CLR_DP
.half CLR_SP | CLR_SI | SET_AI | CLR_VI | SET_PI | CLR_DP
.half SET_SP | CLR_SI | SET_AI | CLR_VI | SET_PI | CLR_DP
.half CLR_SP | SET_SI | SET_AI | CLR_VI | SET_PI | CLR_DP
.half SET_SP | SET_SI | SET_AI | CLR_VI | SET_PI | CLR_DP
.half CLR_SP | CLR_SI | CLR_AI | SET_VI | SET_PI | CLR_DP
.half SET_SP | CLR_SI | CLR_AI | SET_VI | SET_PI | CLR_DP
.half CLR_SP | SET_SI | CLR_AI | SET_VI | SET_PI | CLR_DP
.half SET_SP | SET_SI | CLR_AI | SET_VI | SET_PI | CLR_DP
.half CLR_SP | CLR_SI | SET_AI | SET_VI | SET_PI | CLR_DP
.half SET_SP | CLR_SI | SET_AI | SET_VI | SET_PI | CLR_DP
.half CLR_SP | SET_SI | SET_AI | SET_VI | SET_PI | CLR_DP
.half SET_SP | SET_SI | SET_AI | SET_VI | SET_PI | CLR_DP
.half CLR_SP | CLR_SI | CLR_AI | CLR_VI | CLR_PI | SET_DP
.half SET_SP | CLR_SI | CLR_AI | CLR_VI | CLR_PI | SET_DP
.half CLR_SP | SET_SI | CLR_AI | CLR_VI | CLR_PI | SET_DP
.half SET_SP | SET_SI | CLR_AI | CLR_VI | CLR_PI | SET_DP
.half CLR_SP | CLR_SI | SET_AI | CLR_VI | CLR_PI | SET_DP
.half SET_SP | CLR_SI | SET_AI | CLR_VI | CLR_PI | SET_DP
.half CLR_SP | SET_SI | SET_AI | CLR_VI | CLR_PI | SET_DP
.half SET_SP | SET_SI | SET_AI | CLR_VI | CLR_PI | SET_DP
.half CLR_SP | CLR_SI | CLR_AI | SET_VI | CLR_PI | SET_DP
.half SET_SP | CLR_SI | CLR_AI | SET_VI | CLR_PI | SET_DP
.half CLR_SP | SET_SI | CLR_AI | SET_VI | CLR_PI | SET_DP
.half SET_SP | SET_SI | CLR_AI | SET_VI | CLR_PI | SET_DP
.half CLR_SP | CLR_SI | SET_AI | SET_VI | CLR_PI | SET_DP
.half SET_SP | CLR_SI | SET_AI | SET_VI | CLR_PI | SET_DP
.half CLR_SP | SET_SI | SET_AI | SET_VI | CLR_PI | SET_DP
.half SET_SP | SET_SI | SET_AI | SET_VI | CLR_PI | SET_DP
.half CLR_SP | CLR_SI | CLR_AI | CLR_VI | SET_PI | SET_DP
.half SET_SP | CLR_SI | CLR_AI | CLR_VI | SET_PI | SET_DP
.half CLR_SP | SET_SI | CLR_AI | CLR_VI | SET_PI | SET_DP
.half SET_SP | SET_SI | CLR_AI | CLR_VI | SET_PI | SET_DP
.half CLR_SP | CLR_SI | SET_AI | CLR_VI | SET_PI | SET_DP
.half SET_SP | CLR_SI | SET_AI | CLR_VI | SET_PI | SET_DP
.half CLR_SP | SET_SI | SET_AI | CLR_VI | SET_PI | SET_DP
.half SET_SP | SET_SI | SET_AI | CLR_VI | SET_PI | SET_DP
.half CLR_SP | CLR_SI | CLR_AI | SET_VI | SET_PI | SET_DP
.half SET_SP | CLR_SI | CLR_AI | SET_VI | SET_PI | SET_DP
.half CLR_SP | SET_SI | CLR_AI | SET_VI | SET_PI | SET_DP
.half SET_SP | SET_SI | CLR_AI | SET_VI | SET_PI | SET_DP
.half CLR_SP | CLR_SI | SET_AI | SET_VI | SET_PI | SET_DP
.half SET_SP | CLR_SI | SET_AI | SET_VI | SET_PI | SET_DP
.half CLR_SP | SET_SI | SET_AI | SET_VI | SET_PI | SET_DP
.half SET_SP | SET_SI | SET_AI | SET_VI | SET_PI | SET_DP

View File

@ -9,18 +9,18 @@
glabel osWritebackDCache
blez $a1, .osWritebackDCacheReturn
nop
li $t3, 8192
li $t3, DCACHE_SIZE
bgeu $a1, $t3, .L80324E40
nop
move $t0, $a0
addu $t1, $a0, $a1
bgeu $t0, $t1, .osWritebackDCacheReturn
nop
andi $t2, $t0, 0xf
addiu $t1, $t1, -0x10
andi $t2, $t0, DCACHE_LINEMASK
addiu $t1, $t1, -DCACHE_LINESIZE
subu $t0, $t0, $t2
.L80324E28:
cache 0x19, ($t0)
cache C_HWB|CACH_PD, ($t0)
bltu $t0, $t1, .L80324E28
addiu $t0, $t0, 0x10
.osWritebackDCacheReturn:
@ -28,12 +28,12 @@ glabel osWritebackDCache
nop
.L80324E40:
lui $t0, 0x8000
li $t0, KUSIZE
addu $t1, $t0, $t3
addiu $t1, $t1, -0x10
addiu $t1, $t1, -DCACHE_LINESIZE
.L80324E4C:
cache 1, ($t0)
cache C_IWBINV|CACH_PD, ($t0)
bltu $t0, $t1, .L80324E4C
addiu $t0, 0x10 # addiu $t0, $t0, 0x10
addiu $t0, DCACHE_LINESIZE # addiu $t0, $t0, 0x10
jr $ra
nop

View File

@ -9,15 +9,15 @@
.section .text, "ax"
glabel osWritebackDCacheAll
/* 0CE490 800CD890 3C088000 */ li $t0, 0x80000000 # $t0, 0x8000
/* 0CE494 800CD894 240A2000 */ li $t2, 8192
/* 0CE490 800CD890 3C088000 */ li $t0, KUSIZE # $t0, 0x8000
/* 0CE494 800CD894 240A2000 */ li $t2, DCACHE_SIZE
/* 0CE498 800CD898 010A4821 */ addu $t1, $t0, $t2
/* 0CE49C 800CD89C 2529FFF0 */ addiu $t1, $t1, -0x10
/* 0CE49C 800CD89C 2529FFF0 */ addiu $t1, $t1, -DCACHE_LINESIZE
.L800CD8A0:
/* 0CE4A0 800CD8A0 BD010000 */ cache 1, ($t0)
/* 0CE4A0 800CD8A0 BD010000 */ cache C_IWBINV | CACH_PD, ($t0)
/* 0CE4A4 800CD8A4 0109082B */ sltu $at, $t0, $t1
/* 0CE4A8 800CD8A8 1420FFFD */ bnez $at, .L800CD8A0
/* 0CE4AC 800CD8AC 25080010 */ addiu $t0, $t0, 0x10
/* 0CE4AC 800CD8AC 25080010 */ addiu $t0, $t0, DCACHE_LINESIZE
/* 0CE4B0 800CD8B0 03E00008 */ jr $ra
/* 0CE4B4 800CD8B4 00000000 */ nop

View File

@ -264,9 +264,7 @@ typedef struct {
/* 0x0010 */ s16 currentItemCopy; // Has no effect on what item the players has, It is just a synced copy
/* 0x0012 */ s16 unk_012;
/* 0x0014 */ Vec3f pos;
/* 0x0020 */ f32 copy_rotation_x;
/* 0x0024 */ f32 copy_rotation_y;
/* 0x0028 */ f32 copy_rotation_z;
/* 0x0020 */ Vec3f oldPos;
/* 0x002C */ Vec3s rotation;
/* 0x0032 */ char unk_032[0x2];
/* 0x0034 */ Vec3f velocity;

View File

@ -33,6 +33,13 @@
#define NORETURN
#endif
// Avoid undefined behaviour for non-returning functions
#ifdef __GNUC__
#define NO_REORDER __attribute__((no_reorder))
#else
#define NO_REORDER
#endif
// Static assertions
#ifdef __GNUC__
#define STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,12 @@
Configuration
=======================*/
#define AUDIO_HEAP_SIZE 0x48C00
#define AUDIO_HEAP_INIT_SIZE 0x2600
#define DOUBLE_SIZE_ON_64_BIT(size) ((size) * (sizeof(void *) / 4))
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240

View File

@ -35,12 +35,17 @@ typedef struct {
u8 unknownBytes[8];
} OnlyBestTimeTrialRecords; // size = 0x38
typedef struct {
// GP Points scored for each CC mode
// 1st place is 3 points, 2nd is 2, etc.
// Lowest dibit is the Mushroom Cup, 2nd dibit is the Flower Cup, etc
u8 grandPrixPoints[4];
u8 soundMode;
} SaveInfo;
typedef struct {
SaveInfo saveInfo;
// It's unknown what the first byte is used for
u8 checksum[3];
} Stuff; // size = 0x8

View File

@ -49,7 +49,7 @@ typedef struct {
/* 0x000 */ TrainCarStuff locomotive;
/* 0x024 */ TrainCarStuff tender;
/* 0x048 */ TrainCarStuff passengerCars[NUM_PASSENGER_CAR_ENTRIES];
/* 0x0FC */ f32 someMultiplier;
/* 0x0FC */ f32 speed;
/* 0x100 */ s32 someFlags;
/* 0x104 */ s32 numCars; // Non-locomotive car count?
/* 0x108 */ s32 unused; // Not read or written. Could be padding?
@ -62,7 +62,7 @@ typedef struct {
/* 0x10 */ Vec3f velocity; //
/* 0x1C */ u16 waypointIndex; //
/* 0x1E */ s16 actorIndex; //
/* 0x20 */ f32 someMultiplier; //
/* 0x20 */ f32 speed; //
/* 0x24 */ s16 rotY; // Only Y rotation is tracked in this struct
/* 0x26 */ // s16 compilerPadding2;
/**
@ -79,7 +79,7 @@ typedef struct {
/* 0x10 */ Vec3f velocity;
/* 0x1C */ u16 waypointIndex;
/* 0x1E */ s16 actorIndex;
/* 0x20 */ f32 someMultiplier; //
/* 0x20 */ f32 speed; //
/* 0x24 */ f32 someMultiplierTheSequel; //
/* 0x28 */ Vec3s rotation;
/* 0x2E */ s16 someType; //

View File

@ -7,7 +7,7 @@ typedef struct {
/* 0x00 */ s16 posX;
/* 0x02 */ s16 posY;
/* 0x04 */ s16 posZ;
/* 0x06 */ u16 trackSegment;
/* 0x06 */ u16 trackSectionId;
} TrackWaypoint; // size = 0x08
/**

View File

@ -316,8 +316,8 @@ SECTIONS
BUILD_DIR/src/os/_Printf.o(.rodata*);
BUILD_DIR/asm/os/osSetIntMask.o(.rodata);
BUILD_DIR/src/os/_Ldtob.o(.rodata*);
BUILD_DIR/data/rsp.o(.data);
BUILD_DIR/src/audio/data.o(.data);
BUILD_DIR/data/rsp.o(.data*);
BUILD_DIR/src/audio/data.o(.data*);
}
END_SEG(main)
@ -424,6 +424,7 @@ SECTIONS
BUILD_DIR/src/audio/heap.o(.bss*);
BUILD_DIR/src/audio/load.o(.bss*);
BUILD_DIR/src/audio/data.o(.bss*);
BUILD_DIR/src/buffers/audio_heap.o(.bss*);
. = ALIGN(0x8);
}
END_NOLOAD(buffers)
@ -579,7 +580,8 @@ SECTIONS
#define COURSE_OFFSETS_SEG(dir, name) \
BEGIN_SEG(name, 0x09000000) \
{ \
BUILD_DIR/courses/dir/course_offsets.o(.data); \
BUILD_DIR/courses/dir/course_offsets.o(.data*); \
BUILD_DIR/courses/dir/course_offsets.o(.rodata*); \
. = ALIGN(0x10); \
} \
END_SEG(name)

View File

@ -7,9 +7,11 @@ SAFE_C_FILES := \
build/us/src/code_80091440.o \
build/us/src/effects.o \
build/us/src/code_80057C60_var.o \
build/us/src/code_80091750.o \
build/us/src/code_800029B0.o \
build/us/src/animation.o \
build/us/src/player_controller.o \
build/us/src/code_80005FD0.o \
build/us/src/profiler.o \
build/us/src/render_player.o \
build/us/src/code_80086E70.o \
@ -18,6 +20,7 @@ SAFE_C_FILES := \
build/us/src/kart_dma.o \
build/us/src/math_util_2.o \
build/us/src/main.o \
build/us/src/data/some_data.o \
build/us/src/data/kart_attributes.o \
build/us/src/data/path_spawn_metadata.o \
build/us/src/data/textures.o \
@ -27,6 +30,7 @@ SAFE_C_FILES := \
build/us/src/audio/heap.o \
build/us/src/audio/effects.o \
build/us/src/audio/playback.o \
build/us/src/audio/data.o \
build/us/src/audio/audio_session_presets.o \
build/us/src/audio/port_eu.o \
build/us/src/buffers/gfx_output_buffer.o \
@ -164,4 +168,14 @@ SAFE_C_FILES := \
build/us/src/os/math/llconv.o \
build/us/src/os/math/cosf.o \
build/us/src/os/math/llmuldiv.o \
build/us/src/os/math/sinf.o \
build/us/src/os/math/sinf.o \
# build/us/src/save.o
# build/us/src/crash_screen.o
# build/us/src/code_8006E9C0.o
# build/us/src/audio/synthesis.o
# build/us/src/code_80057C60.o
# build/us/src/menus.o
# build/us/src/render_objects.o
# build/us/src/code_800AF9B0.o
# build/us/src/update_objects.o

169
safe_gcc_old.mk Normal file
View File

@ -0,0 +1,169 @@
# This file is auto-generated. DO NOT MODIFY!
SAFE_C_FILES := \
build/us/src/camera.o \
build/us/src/spawn_players.o \
build/us/src/code_8003DC40.o \
build/us/src/code_80091440.o \
build/us/src/effects.o \
build/us/src/code_80057C60_var.o \
build/us/src/code_800029B0.o \
build/us/src/code_80004740.o \
build/us/src/player_controller.o \
build/us/src/profiler.o \
build/us/src/render_player.o \
build/us/src/code_80086E70.o \
build/us/src/staff_ghosts.o \
build/us/src/gbiMacro.o \
build/us/src/kart_dma.o \
build/us/src/math_util_2.o \
build/us/src/main.o \
build/us/src/data/kart_attributes.o \
build/us/src/data/path_spawn_metadata.o \
build/us/src/data/textures.o \
build/us/src/data/trig_tables_bss.o \
build/us/src/data/data_segment2.o \
build/us/src/audio/seqplayer.o \
build/us/src/audio/heap.o \
build/us/src/audio/effects.o \
build/us/src/audio/playback.o \
build/us/src/audio/audio_session_presets.o \
build/us/src/audio/port_eu.o \
build/us/src/buffers/gfx_output_buffer.o \
build/us/src/buffers/trig_tables.o \
build/us/src/buffers/buffers.o \
build/us/src/buffers/random.o \
build/us/src/buffers/trig_tables_bss.o \
build/us/src/buffers/memory_pool.o \
build/us/src/ending/credits.o \
build/us/src/ending/code_80280000.o \
build/us/src/ending/ceremony_and_credits.o \
build/us/src/ending/dl_unk_80284EE0.o \
build/us/src/ending/code_80281780.o \
build/us/src/ending/podium_ceremony_actors.o \
build/us/src/ending/code_80281C40.o \
build/us/src/ending/camera_junk.o \
build/us/src/debug/debug.o \
build/us/src/debug/crash_screen_enhancement.o \
build/us/src/racing/collision.o \
build/us/src/racing/skybox_and_splitscreen.o \
build/us/src/racing/memory.o \
build/us/src/racing/race_logic.o \
build/us/src/racing/actors_extended.o \
build/us/src/racing/render_courses.o \
build/us/src/racing/actors.o \
build/us/src/os/guOrthoF.o \
build/us/src/os/guLookAtF.o \
build/us/src/os/__osSiDeviceBusy.o \
build/us/src/os/_Litob.o \
build/us/src/os/osContInit.o \
build/us/src/os/osInitialize.o \
build/us/src/os/osAiSetNextBuffer.o \
build/us/src/os/guMtxCatL.o \
build/us/src/os/__osAiDeviceBusy.o \
build/us/src/os/contramread.o \
build/us/src/os/osSpTaskLoadGo.o \
build/us/src/os/crc.o \
build/us/src/os/osCreateMesgQueue.o \
build/us/src/os/guRotateF.o \
build/us/src/os/__osLeoInterrupt.o \
build/us/src/os/osContStartReadData.o \
build/us/src/os/osGetThreadPri.o \
build/us/src/os/osPfsNumFiles.o \
build/us/src/os/__osSiRawReadIo.o \
build/us/src/os/osSpTaskYield.o \
build/us/src/os/osStartThread.o \
build/us/src/os/osViData.o \
build/us/src/os/osPfsFileState.o \
build/us/src/os/contpfs.o \
build/us/src/os/leointerrupt.o \
build/us/src/os/osPfsAllocateFile.o \
build/us/src/os/ldiv.o \
build/us/src/os/osSpTaskYielded.o \
build/us/src/os/__osSpSetPc.o \
build/us/src/os/osSetTime.o \
build/us/src/os/osYieldThread.o \
build/us/src/os/osPiRawStartDma.o \
build/us/src/os/osSetTimer.o \
build/us/src/os/osPfsDeleteFile.o \
build/us/src/os/__osSpDeviceBusy.o \
build/us/src/os/osEepromRead.o \
build/us/src/os/osPiRawReadIo.o \
build/us/src/os/osSetEventMesg.o \
build/us/src/os/NaN.o \
build/us/src/os/osJamMesg.o \
build/us/src/os/osPfsChecker.o \
build/us/src/os/sprintf.o \
build/us/src/os/_Printf.o \
build/us/src/os/osViTable.o \
build/us/src/os/osEepromLongWrite.o \
build/us/src/os/__osEPiRawWriteIo.o \
build/us/src/os/osViSetEvent.o \
build/us/src/os/__osGetCurrFaultedThread.o \
build/us/src/os/osCreatePiManager.o \
build/us/src/os/epidma.o \
build/us/src/os/osCartRomInit.o \
build/us/src/os/osPfsFreeBlocks.o \
build/us/src/os/osPfsSearchFile.o \
build/us/src/os/__osAtomicDec.o \
build/us/src/os/osViBlack.o \
build/us/src/os/__osViInit.o \
build/us/src/os/osEepromWrite.o \
build/us/src/os/osAiSetFrequency.o \
build/us/src/os/__osEPiRawReadIo.o \
build/us/src/os/guLookAtRef.o \
build/us/src/os/guPerspectiveF.o \
build/us/src/os/contramwrite.o \
build/us/src/os/osGetTime.o \
build/us/src/os/__osViSwapContext.o \
build/us/src/os/alBnkfNew.o \
build/us/src/os/__osSpSetStatus.o \
build/us/src/os/osPfsReadWriteFile.o \
build/us/src/os/osPiStartDma.o \
build/us/src/os/osRecvMesg.o \
build/us/src/os/osDestroyThread.o \
build/us/src/os/string.o \
build/us/src/os/__osSiRawWriteIo.o \
build/us/src/os/osPfsInit.o \
build/us/src/os/guMtxCatF.o \
build/us/src/os/osPfsIsPlug.o \
build/us/src/os/__osDequeueThread.o \
build/us/src/os/__osSiCreateAccessQueue.o \
build/us/src/os/osViSwapBuffer.o \
build/us/src/os/is_debug.o \
build/us/src/os/__osViGetCurrentContext.o \
build/us/src/os/__osPiCreateAccessQueue.o \
build/us/src/os/__osSpRawStartDma.o \
build/us/src/os/__osSyncPutChars.o \
build/us/src/os/osSendMesg.o \
build/us/src/os/osSyncPrintf.o \
build/us/src/os/__osResetGlobalIntMask.o \
build/us/src/os/guScaleF.o \
build/us/src/os/osSetThreadPri.o \
build/us/src/os/__osDevMgrMain.o \
build/us/src/os/osVirtualToPhysical.o \
build/us/src/os/osViSetMode.o \
build/us/src/os/__osSetHWIntrRoutine.o \
build/us/src/os/osCreateViManager.o \
build/us/src/os/__osSiRawStartDma.o \
build/us/src/os/guNormalize.o \
build/us/src/os/osLeoDiskInit.o \
build/us/src/os/__osSpGetStatus.o \
build/us/src/os/osEepromLongRead.o \
build/us/src/os/_Ldtob.o \
build/us/src/os/guMtxF2L.o \
build/us/src/os/osEPiRawStartDma.o \
build/us/src/os/osPiGetCmdQueue.o \
build/us/src/os/osAiGetLength.o \
build/us/src/os/osViSetSpecialFeatures.o \
build/us/src/os/osCreateThread.o \
build/us/src/os/osTimer.o \
build/us/src/os/osEepromProbe.o \
build/us/src/os/__osSetGlobalIntMask.o \
build/us/src/os/guTranslateF.o \
build/us/src/os/math/llconv.o \
build/us/src/os/math/cosf.o \
build/us/src/os/math/llmuldiv.o \
build/us/src/os/math/sinf.o \
build/us/assets/code/common_data/common_data.o\
build/us/assets/code/common_data/common_data.mio0.o\

View File

@ -3,6 +3,7 @@
#include "internal.h"
#include "data.h"
#include "../buffers/audio_heap.h"
struct ReverbSettingsEU sReverbSettings[] = {
{0x01, 0x28, 0x4fff},
@ -33,8 +34,8 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
s8 gUnusedCount800EA5C8 = 0x1c;
s16 gTatumsPerBeat = TATUMS_PER_BEAT;
s32 gAudioHeapSize = 0x00048c00;
s32 gAudioInitPoolSize = 0x00002600;
s32 gAudioHeapSize = AUDIO_HEAP_SIZE;
s32 gAudioInitPoolSize = AUDIO_HEAP_INIT_SIZE;
s32 D_800EA5D8 = 0;
volatile s32 gAudioLoadLock = 0;

View File

@ -1,5 +1,6 @@
#include <libultra/types.h>
#include <macros.h>
#include <mk64.h>
#include "data.h"
#include "effects.h"
@ -435,10 +436,9 @@ struct SPTask *gAudioTask; // gAudioTask?
struct SPTask gAudioTasks[2]; // gAudioTasks?
f32 D_803B7178;
s32 gRefreshRate;
s16 *gAiBuffers[3]; // unconfirmed, osAiSetNextBuffer vaddr
s16 *gAiBuffers[NUMAIBUFFERS]; // unconfirmed, osAiSetNextBuffer vaddr
s16 gAiBufferLengths[NUMAIBUFFERS]; // osAiSetNextBuffer nbytes
u16 D_803B7192; // unconfirmed
u32 gAudioRandom;
s32 gAudioErrorFlags;
u32 D_803B71A0[4]; // unconfirmed
ALIGNED8 u8 gAudioHeap[4]; // unconfirmed
u64 gAudioGlobalsEndMarker;

View File

@ -51,12 +51,12 @@ extern struct SPTask *gAudioTask; // D_803B70D4
extern struct SPTask gAudioTasks[2]; // D_803B70D8
extern f32 D_803B7178;
extern s32 gRefreshRate;
extern s16 *gAiBuffers[NUMAIBUFFERS]; // D_803B7180
extern s16 gAiBufferLengths[NUMAIBUFFERS]; // osAiSetNextBuffer nbytes
extern s16 *gAiBuffers[]; // D_803B7180
extern s16 gAiBufferLengths[]; // osAiSetNextBuffer nbytes
extern u16 D_803B7192; // unconfirmed
extern u32 gAudioRandom;
extern s32 gAudioErrorFlags;
extern u32 D_803B71A0[]; // unconfirmed
extern u64 gAudioGlobalsEndMarker; // unconfirmed
extern u8 gAudioHeap[]; // unconfirmed
extern struct ReverbSettingsEU sReverbSettings[];

View File

@ -795,7 +795,7 @@ void audio_init(void) {
#ifdef TARGET_N64
// It seems boot.s doesn't clear the .bss area for audio, so do it here.
ptr64 = (u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer));
for (i = ((uintptr_t) &D_803B71A0 - (uintptr_t) ((u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer))) ) / 8; i >= 0; i--) {
for (i = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) ((u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer))) ) / 8; i >= 0; i--) {
*ptr64++ = 0;
}
#endif

View File

@ -113,11 +113,12 @@ struct SPTask *create_next_audio_frame_task(void) {
gAudioCmd = gAudioCmdBuffers[gAudioTaskIndex];
index = gCurrAiBufferIndex;
currAiBuffer = gAiBuffers[index];
gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI + EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xF) + SAMPLES_TO_OVERPRODUCE;
gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI +
EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xF) + SAMPLES_TO_OVERPRODUCE;
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength) {
gAiBufferLengths[index] = gAudioBufferParameters.minAiBufferLength;
}
if (gAudioBufferParameters.maxAiBufferLength < gAiBufferLengths[index]) {
if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength) {
gAiBufferLengths[index] = gAudioBufferParameters.maxAiBufferLength;
}
if (osRecvMesg(D_800EA3AC, &sp54, 0) != -1) {
@ -136,12 +137,12 @@ struct SPTask *create_next_audio_frame_task(void) {
task = &gAudioTask->task.t;
task->type = M_AUDTASK;
task->flags = 0;
//task->ucode_boot = rspF3DBootStart;
//task->ucode_boot_size = (u8*) rspF3DBootEnd - (u8*) rspF3DBootStart;
//task->ucode = rspAspMainStart;
//task->ucode_data = rspAspMainDataStart;
task->ucode_size = 0x00001000;
//task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
// task->ucode_boot = rspF3DBootStart;
// task->ucode_boot_size = (u8*) rspF3DBootEnd - (u8*) rspF3DBootStart;
// task->ucode = rspAspMainStart;
// task->ucode_data = rspAspMainDataStart;
task->ucode_size = 0x1000; // (This size is ignored (according to sm64))
// task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
task->dram_stack = NULL;
task->dram_stack_size = 0;
task->output_buff = NULL;

9
src/buffers/audio_heap.c Normal file
View File

@ -0,0 +1,9 @@
#include <libultra/types.h>
#include <macros.h>
#include <mk64.h>
#include "audio_heap.h"
#include "audio/data.h"
ALIGNED8 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(AUDIO_HEAP_SIZE)];

10
src/buffers/audio_heap.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef AUDIO_HEAP_H
#define AUDIO_HEAP_H
#include <libultra/types.h>
#include <mk64.h>
#define AUDIO_HEAP_SIZE 0x48C00
#define AUDIO_HEAP_INIT_SIZE 0x2600
#endif // AUDIO_HEAP_H

File diff suppressed because it is too large Load Diff

View File

@ -56,13 +56,13 @@ typedef struct {
typedef struct {
s16 x;
s16 z;
} PathNoY;
} Path2D;
/* Function Prototypes */
s16 func_80005FD0(Vec3f, Vec3f);
s16 get_angle_between_waypoints(Vec3f, Vec3f);
s32 func_80006018(f32, f32, f32, f32, f32, f32, f32, f32);
void func_80006114(Vec3f, Vec3f, s16);
void adjust_position_by_angle(Vec3f, Vec3f, s16);
s32 set_vehicle_render_distance_flags(Vec3f, f32, s32);
void func_800065D0(s32, Player*);
void set_places(void);
@ -97,15 +97,15 @@ void func_8000BA14(u16, f32, f32, s16);
void func_8000BBD8(u16, f32, s16);
s16 func_8000BD94(f32, f32, f32, s32);
s16 func_8000C0BC(f32, f32, f32, u16, s32*);
s16 find_closest_waypoint_track_section(f32, f32, f32, u16, s32*);
s16 func_8000C884(f32, f32, f32, s16, s32, u16);
s16 func_8000C9DC(f32, f32, f32, s16, s32);
s16 find_closest_waypoint_with_previous_waypoint(f32, f32, f32, s16, s32);
void func_8000CBA4(f32, f32, f32, s16*, s32);
void func_8000CBF8(f32, f32, f32, s16*, s32);
s16 func_8000CC88(f32, f32, f32, Player*, s32, s32*);
s16 func_8000CD24(f32, f32, f32, s16, Player*, s32, s32);
s16 func_8000D100(f32, f32, f32, s16);
s16 find_closest_vehicles_waypoint(f32, f32, f32, s16);
s16 func_8000D24C(f32, f32, f32, s32*);
s16 func_8000D2B4(f32, f32, f32, s16, s32);
s16 func_8000D33C(f32, f32, f32, s16, s32);
@ -113,7 +113,7 @@ f32 func_8000D3B8(s32);
void func_8000D438(s32, u16);
s16 func_8000D6D0(Vec3f, s16*, f32, f32, s16, s16);
s16 func_8000D940(Vec3f, s16*, f32, f32, s16);
s16 func_8000DBAC(Vec3f, s16*, f32);
s16 update_vehicle_following_waypoint(Vec3f, s16*, f32);
void set_bomb_kart_spawn_positions(void);
void func_8000DF8C(s32);
@ -143,7 +143,7 @@ f32 func_80010FA0(f32, f32, f32, s32, s32);
s32 func_80011014(TrackWaypoint *, TrackWaypoint *, s32, s32);
s32 process_path_data(TrackWaypoint*, TrackWaypoint*);
s32 func_8001168C(PathNoY*, TrackWaypoint*, s32);
s32 generate_2d_path(Path2D*, TrackWaypoint*, s32);
void copy_courses_kart_ai_behaviour(void);
void reset_kart_ai_behaviour_none(s32);
void reset_kart_ai_behaviour(s32);
@ -152,42 +152,42 @@ void kart_ai_behaviour_end(s32, Player*);
void kart_ai_behaviour(s32);
void func_80011EC0(s32, Player*, s32, u16);
void func_800120C8(void);
void func_80012190(void);
void func_80012220(VehicleStuff*);
void init_course_vehicles(void);
void func_80012780(TrainCarStuff*, PathNoY *, u16);
void func_800127E0(void);
void func_80012A48(TrainCarStuff*, s16);
void generate_train_waypoints(void);
void generate_ferry_waypoints(void);
void spawn_vehicle_on_road(VehicleStuff*);
void spawn_course_vehicles(void);
void set_vehicle_pos_waypoint(TrainCarStuff*, Path2D*, u16);
void init_vehicles_trains(void);
void sync_train_components(TrainCarStuff*, s16);
void update_vehicle_trains(void);
void func_80012DC0(s32, Player*);
void func_80013054(void);
void check_ai_crossing_distance(s32);
void func_800132F4(void);
void init_vehicles_ferry(void);
void update_vehicle_paddle_boats(void);
void func_80013854(Player*);
void func_800139E4(f32, f32, s32, s32, VehicleStuff*, TrackWaypoint*);
void initialize_toads_turnpike_vehicle(f32, f32, s32, s32, VehicleStuff*, TrackWaypoint*);
f32 func_80013C74(s16, s16);
void func_80013D20(VehicleStuff*);
void update_vehicle_follow_waypoint(VehicleStuff*);
void func_80013F7C(s32, Player*, VehicleStuff*, f32, f32, s32, u32);
f32 func_800145A8(s16, f32, s16);
void func_800146B8(s32, s32, VehicleStuff*);
void func_800147E0(void);
void func_8001487C(void);
void init_vehicles_box_trucks(void);
void update_vehicle_box_trucks(void);
void func_800148C4(s32, Player*);
void func_8001490C(s32);
void func_80014934(void);
void func_800149D0(void);
void init_vehicles_school_buses(void);
void update_vehicle_school_bus(void);
void func_80014A18(s32, Player*);
void func_80014A60(s32);
void func_80014A88(void);
void func_80014B24(void);
void init_vehicles_trucks(void);
void update_vehicle_tanker_trucks(void);
void func_80014B6C(s32, Player*);
void func_80014BB4(s32);
void func_80014BDC(void);
void func_80014C78(void);
void init_vehicles_cars(void);
void update_vehicle_cars(void);
void func_80014CC0(s32, Player*);
void func_80014D08(s32);
void func_80014D30(s32, s32);
@ -264,7 +264,7 @@ extern s16 D_80162F50[];
extern Vec3f D_80162FA0;
extern Vec3f D_80162FB0;
extern Vec3f D_80162FC0;
extern s16 D_80162FCC;
extern s16 gTrainSmokeTimer;
extern s16 D_80162FD0;
extern f32 gCourseCompletionPercentByRank[]; // D_80162FD8
extern s16 D_80162FF8[];
@ -277,7 +277,7 @@ extern s32 D_801630B8[];
extern u16 D_801630E0;
extern s16 D_801630E2;
extern s16 D_801630E8[];
extern s16 D_801630FC;
extern s16 gFerrySmokeTimer;
extern s32 D_80163100[];
extern s32 D_80163128[];
extern s32 D_80163150[];
@ -357,8 +357,8 @@ extern s16 D_801634EC;
extern s32 D_801634F0;
extern s32 D_801634F4;
extern Test D_801634F8[];
extern PathNoY *D_80163598;
extern s32 D_8016359C;
extern Path2D *gVehicle2DWaypoint;
extern s32 gVehicle2DWaypointLength;
extern u16 isCrossingTriggeredByIndex[];
extern u16 sCrossingActiveTimer[];
extern s32 D_80163DD8[];

View File

@ -312,11 +312,18 @@ s32 gObjectParticle1[gObjectParticle2_SIZE];
Collision D_8018C3B0;
/**
* List of object list indices used for:
* Bats in Banshee's Boardwalk (but only 1 player mode?)
* - Bats in Banshee's Boardwalk (but only 1 player mode?)
* - Train index 0 smoke in Kalimari Desert
* - Ferry index 0 smoke in DK Jungle
*/
s32 gObjectParticle2[gObjectParticle2_SIZE];
// Maybe some unused Collision?
UNUSED Collision D_8018C5F0;
/**
* List of object list indices used for:
* - Train index 1 smoke in Kalimari Desert
* - Ferry index 1 smoke in DK Jungle
*/
s32 gObjectParticle3[gObjectParticle3_SIZE];
Collision D_8018C830;
/**
@ -761,7 +768,7 @@ void render_object_for_player(s32 cameraId) {
case COURSE_TOADS_TURNPIKE:
break;
case COURSE_KALAMARI_DESERT:
render_object_train_smoke_particles(cameraId);
render_object_trains_smoke_particles(cameraId);
break;
case COURSE_SHERBET_LAND:
if (gGamestate != CREDITS_SEQUENCE) {

View File

@ -1415,11 +1415,11 @@ UNUSED void func_8008A850(s32 arg0) {
}
UNUSED s32 func_8008A870(Player *player) {
return get_section_id(player->collision.meshIndexZX);
return get_track_section_id(player->collision.meshIndexZX);
}
s32 func_8008A890(Camera *camera) {
return get_section_id(camera->collision.meshIndexZX);
return get_track_section_id(camera->collision.meshIndexZX);
}
s32 func_8008A8B0(s16 arg0, s16 arg1) {

View File

@ -1897,7 +1897,7 @@ void func_80090970(Player *player, s8 playerId, s8 arg2) {
player->unk_0CA &= ~0x0001;
}
} else {
move_f32_towards(&player->pos[1], player->copy_rotation_y + 40.0f, 0.02f);
move_f32_towards(&player->pos[1], player->oldPos[1] + 40.0f, 0.02f);
player->unk_0C6 -= 8;
if (player->unk_0C6 < 9) {
player->unk_0C6 = 0;

View File

@ -261,7 +261,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) {
sp38->unk8 = -1;
}
if (sp2C && gSoundMode != sp38->cursor) {
gSaveData.main.soundMode = gSoundMode;
gSaveData.main.saveInfo.soundMode = gSoundMode;
write_save_data_grand_prix_points_and_sound_mode();
update_save_data_backup();
sp38->cursor = gSoundMode;
@ -270,7 +270,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) {
func_8009E280();
play_sound2(SOUND_MENU_GO_BACK);
if (gSoundMode != sp38->cursor) {
gSaveData.main.soundMode = gSoundMode;
gSaveData.main.saveInfo.soundMode = gSoundMode;
write_save_data_grand_prix_points_and_sound_mode();
update_save_data_backup();
sp38->cursor = gSoundMode;
@ -1124,7 +1124,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) {
}
play_sound2(SOUND_MENU_CURSOR_MOVE);
func_800B44BC();
gSaveData.main.soundMode = gSoundMode;
gSaveData.main.saveInfo.soundMode = gSoundMode;
write_save_data_grand_prix_points_and_sound_mode();
update_save_data_backup();
}
@ -1135,7 +1135,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) {
}
play_sound2(SOUND_MENU_CURSOR_MOVE);
func_800B44BC();
gSaveData.main.soundMode = gSoundMode;
gSaveData.main.saveInfo.soundMode = gSoundMode;
write_save_data_grand_prix_points_and_sound_mode();
}
if (btnAndStick & U_JPAD) {

View File

@ -1,15 +1,11 @@
#include "libultra_internal.h"
#ifndef AVOID_UB
OSThread *__osThreadTail = NULL;
u32 __osTest = -1;
OSThread *__osRunQueue = (OSThread *) &__osThreadTail;
OSThread *__osActiveQueue = (OSThread *) &__osThreadTail;
NO_REORDER OSThread *__osThreadTail = NULL;
NO_REORDER u32 __osTest = -1;
NO_REORDER OSThread *__osRunQueue = (OSThread *) &__osThreadTail;
NO_REORDER OSThread *__osActiveQueue = (OSThread *) &__osThreadTail;
OSThread *__osRunningThread = NULL;
OSThread *__osFaultedThread = NULL;
#else
OSThread_ListHead __osThreadTail_fix = {NULL, -1, (OSThread *) &__osThreadTail_fix, (OSThread *) &__osThreadTail_fix, NULL, 0};
#endif
void __osDequeueThread(OSThread **queue, OSThread *thread) {
register OSThread **a2;

View File

@ -3,10 +3,21 @@
#include <libultraship.h>
#include "macros.h"
#ifdef TARGET_N64
typedef struct __OSEventState
{
OSMesgQueue *messageQueue;
OSMesg message;
} __OSEventState;
#endif
typedef struct __osThreadTail
{
OSThread *next;
OSPri priority;
/* 0x00 */ OSThread *next;
/* 0x04 */ OSPri priority;
/* 0x08 */ OSThread *queue;
/* 0x0c */ OSThread *tlnext;
} OSThreadTail;
/*
@ -24,23 +35,12 @@ typedef struct
/*0x10*/ struct OSThread_s *unk10;
/*0x14*/ u32 unk14;
} OSThread_ListHead;
#ifdef AVOID_UB
// Now fix the symbols to the new one.
extern OSThread_ListHead __osThreadTail_fix;
#define __osThreadTail __osThreadTail_fix.next
#define D_80334894 __osThreadTail_fix.priority
#define __osRunQueue __osThreadTail_fix.queue
#define __osActiveQueue __osThreadTail_fix.tlnext
#define __osRunningThread __osThreadTail_fix.unk10
#else
// Original OSThread_ListHead definitions
extern OSThread *__osThreadTail;
extern OSThread *__osActiveQueue;
extern OSThread *__osRunQueue;
extern OSThread *__osRunningThread;
#endif
// Original EEPROM definitions
extern u32 D_80365E00[15];

View File

@ -15,7 +15,7 @@ typedef struct {
u32 D_80194040;
u64 osClockRate = 62500000;
u32 D_800EA5E8 = 0;
u32 __osShutdown = 0;
u32 __OSGlobalIntMask = OS_IM_ALL;
u32 D_800EA5F0 = 0;

View File

@ -16,14 +16,10 @@ extern void __osTimerInterrupt(void);
extern u32 __osProbeTLB(void *);
extern int __osSpDeviceBusy(void);
#ifdef AVOID_UB
extern OSThread_ListHead __osThreadTail_fix;
#else
extern OSThread *__osRunningThread;
extern OSThread *__osActiveQueue;
extern OSThread *__osFaultedThread;
extern OSThread *__osRunQueue;
#endif
extern OSTimer *__osTimerList;
extern OSTimer __osBaseTimer;

View File

@ -873,9 +873,9 @@ void func_8002934C(Player *player, Camera *camera, s8 screenId, s8 playerId) {
}
else {
if (((player->animFrameSelector[screenId]) >= 0) && ((player->animFrameSelector[screenId]) < 0x101)) {
var_f0 = player->copy_rotation_y - player->pos[1];
var_f0 = player->oldPos[1] - player->pos[1];
} else {
var_f0 = player->pos[1] - player->copy_rotation_y;
var_f0 = player->pos[1] - player->oldPos[1];
}
player->unk_0D4[screenId] = (s16) ((s32) (((f64) func_802B7C40(var_f0 / temp_f2)) * 0.5));
}
@ -1027,7 +1027,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) {
player->tyres[FRONT_LEFT].pos[0] = player->pos[0] + sp8C[0];
player->tyres[FRONT_LEFT].pos[1] = player->pos[1] + sp8C[1];
player->tyres[FRONT_LEFT].pos[2] = player->pos[2] + sp8C[2];
process_collision(player, &player->tyres[FRONT_LEFT], sp80[0], sp80[1], sp80[2]);
player_terrain_collision(player, &player->tyres[FRONT_LEFT], sp80[0], sp80[1], sp80[2]);
sp8C[0] = (-var_f12) + 3.6;
sp8C[1] = -player->boundingBoxSize;
sp8C[2] = var_f12 - 2.0f;
@ -1038,7 +1038,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) {
player->tyres[FRONT_RIGHT].pos[0] = player->pos[0] + sp8C[0];
player->tyres[FRONT_RIGHT].pos[1] = player->pos[1] + sp8C[1];
player->tyres[FRONT_RIGHT].pos[2] = player->pos[2] + sp8C[2];
process_collision(player, &player->tyres[FRONT_RIGHT], sp80[0], sp80[1], sp80[2]);
player_terrain_collision(player, &player->tyres[FRONT_RIGHT], sp80[0], sp80[1], sp80[2]);
sp8C[0] = var_f12 - 2.6;
sp8C[1] = -player->boundingBoxSize;
sp8C[2] = (-var_f12) + 4.0f;
@ -1049,7 +1049,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) {
player->tyres[BACK_LEFT].pos[0] = player->pos[0] + sp8C[0];
player->tyres[BACK_LEFT].pos[1] = player->pos[1] + sp8C[1];
player->tyres[BACK_LEFT].pos[2] = player->pos[2] + sp8C[2];
process_collision(player, &player->tyres[BACK_LEFT], sp80[0], sp80[1], sp80[2]);
player_terrain_collision(player, &player->tyres[BACK_LEFT], sp80[0], sp80[1], sp80[2]);
sp8C[0] = (-var_f12) + 2.6;
sp8C[1] = -player->boundingBoxSize;
sp8C[2] = (-var_f12) + 4.0f;
@ -1060,7 +1060,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) {
player->tyres[BACK_RIGHT].pos[0] = player->pos[0] + sp8C[0];
player->tyres[BACK_RIGHT].pos[1] = player->pos[1] + sp8C[1];
player->tyres[BACK_RIGHT].pos[2] = player->pos[2] + sp8C[2];
process_collision(player, &player->tyres[BACK_RIGHT], sp80[0], sp80[1], sp80[2]);
player_terrain_collision(player, &player->tyres[BACK_RIGHT], sp80[0], sp80[1], sp80[2]);
if (!(player->effects & 8)) {
a = (player->tyres[BACK_LEFT].baseHeight + player->tyres[FRONT_LEFT].baseHeight) / 2;
move_f32_towards(&player->unk_230, a, 0.5f);
@ -1085,7 +1085,7 @@ void func_80029B4C(Player *player, UNUSED f32 arg1, f32 arg2, UNUSED f32 arg3) {
move_s16_towards(&player->slopeAccel, func_802B7C40(temp_f0_2 / temp_f2_3), 0.5f);
}
else {
temp_f0_2 = player->copy_rotation_y - arg2;
temp_f0_2 = player->oldPos[1] - arg2;
temp_v0 = func_802B7C40(temp_f0_2 / temp_f2_3);
if (temp_f0_2 >= 0.0f) {
temp_v0 /= 4;
@ -1165,7 +1165,7 @@ void func_8002A194(Player *player, f32 arg1, f32 arg2, f32 arg3) {
temp_f0 = (player->unk_1F8 - player->unk_1FC);
move_s16_towards(&player->slopeAccel, func_802B7C40(temp_f0 / var_f20), 0.5f);
} else {
temp_f0 = player->copy_rotation_y - arg2;
temp_f0 = player->oldPos[1] - arg2;
temp_v0 = func_802B7C40(temp_f0 / var_f20);
if (temp_f0 >= 0.0f) {
var_a1 = temp_v0 * 2;
@ -1691,7 +1691,7 @@ void func_8002B9CC(Player *player, s8 arg1, UNUSED s32 arg2) {
func_8008C73C(player, arg1);
}
}
temp = (-(s16)get_angle_between_two_vectors(player->pos, &player->copy_rotation_x));
temp = (-(s16)get_angle_between_two_vectors(player->pos, &player->oldPos[0]));
temp2 = (player->rotation[1] - player->unk_0C0);
temp = temp - temp2;
player->unk_234 = temp / 182;
@ -1728,9 +1728,9 @@ void func_8002BB9C(Player *player, f32 *arg1, f32 *arg2, UNUSED s8 arg3, UNUSED
mtxf_translate_vec3f_mat3(sp58, sp64);
sp4C[0] = player->copy_rotation_x;
sp4C[0] = player->oldPos[0];
sp4C[1] = 0;
sp4C[2] = player->copy_rotation_z;
sp4C[2] = player->oldPos[2];
mtxf_translate_vec3f_mat3(sp4C, sp64);
@ -2203,9 +2203,9 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player
Vec3f sp160 = {0.0, 0.0, 0.0};
f32 sp104[] = {0.825, 0.8, 0.725, 0.625, 0.425, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3};
f32 temp;
f32 spFC;
f32 spF8;
f32 spF4;
f32 nextX;
f32 nextY;
f32 nextZ;
f32 posX;
f32 posY;
f32 posZ;
@ -2269,7 +2269,7 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player
spB0 = -1 * player->kartGravity;
spAC = 0 * (player->unk_064[2] + sp16C[2]);
}
temp_f2_2 = ((player->copy_rotation_z - player->pos[2]) * coss(player->rotation[1] + player->unk_0C0)) + (-(player->copy_rotation_x - player->pos[0]) * sins(player->rotation[1] + player->unk_0C0));
temp_f2_2 = ((player->oldPos[2] - player->pos[2]) * coss(player->rotation[1] + player->unk_0C0)) + (-(player->oldPos[0] - player->pos[0]) * sins(player->rotation[1] + player->unk_0C0));
if (temp_f2_2 > 0.1) {
player->unk_044 |= 8;
} else {
@ -2321,22 +2321,22 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player
posY = player->pos[1];
posZ = player->pos[2];
player->copy_rotation_x = player->pos[0];
player->copy_rotation_z = player->pos[2];
player->copy_rotation_y = player->pos[1];
spFC = posX + player->velocity[0] + D_8018CE10[playerId].unk_04[0];
spF8 = posY + player->velocity[1];
spF4 = posZ + player->velocity[2] + D_8018CE10[playerId].unk_04[2];
player->oldPos[0] = player->pos[0];
player->oldPos[2] = player->pos[2];
player->oldPos[1] = player->pos[1];
nextX = posX + player->velocity[0] + D_8018CE10[playerId].unk_04[0];
nextY = posY + player->velocity[1];
nextZ = posZ + player->velocity[2] + D_8018CE10[playerId].unk_04[2];
if (((((player->unk_0CA & 2) != 2)
&& ((player->unk_0CA & 8) != 8))
&& ((player->effects & HIT_EFFECT) != HIT_EFFECT))
&& (!(player->unk_0CA & 1))) {
func_8002AAC0(player);
spF8 += player->kartHopVelocity;
spF8 -= 0.02;
nextY += player->kartHopVelocity;
nextY -= 0.02;
}
actor_terrain_collision(&player->collision, player->boundingBoxSize, spFC, spF8, spF4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z);
actor_terrain_collision(&player->collision, player->boundingBoxSize, nextX, nextY, nextZ, player->oldPos[0], player->oldPos[1], player->oldPos[2]);
player->unk_058 = 0.0f;
player->unk_060 = 0.0f;
player->unk_05C = 1.0f;
@ -2400,16 +2400,16 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player
}
temp_var = player->collision.surfaceDistance[2];
if (temp_var <= 0.0f) {
func_8003F46C(player, sp8C, sp98, sp178, &temp_var, &spFC, &spF8, &spF4);
func_8003F46C(player, sp8C, sp98, sp178, &temp_var, &nextX, &nextY, &nextZ);
}
temp_var = player->collision.surfaceDistance[0];
if (temp_var < 0.0f) {
func_8003F734(player, sp8C, sp98, &temp_var, &spFC, &spF8, &spF4);
func_8003F734(player, sp8C, sp98, &temp_var, &nextX, &nextY, &nextZ);
func_8002C954(player, playerId, sp98);
}
temp_var = player->collision.surfaceDistance[1];
if (temp_var < 0.0f) {
func_8003FBAC(player, sp8C, sp98, &temp_var, &spFC, &spF8, &spF4);
func_8003FBAC(player, sp8C, sp98, &temp_var, &nextX, &nextY, &nextZ);
func_8002C954(player, playerId, sp98);
}
temp_var = player->collision.surfaceDistance[0];
@ -2433,13 +2433,13 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player
} else if (((!(player->effects & 8)) && (func_802ABDB8(player->collision.meshIndexZX) == 0)) && (player->effects & 0x10000)) {
func_8008F5A4(player, playerId);
}
player->unk_074 = calculate_surface_height(spFC, spF8, spF4, player->collision.meshIndexZX);
player->unk_074 = calculate_surface_height(nextX, nextY, nextZ, player->collision.meshIndexZX);
if (((player->type & PLAYER_HUMAN) == PLAYER_HUMAN) && (((gActiveScreenMode == SCREEN_MODE_1P) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_VERTICAL)) || (gActiveScreenMode == SCREEN_MODE_2P_SPLITSCREEN_HORIZONTAL))) {
func_80029B4C(player, spFC, spF8, spF4);
func_80029B4C(player, nextX, nextY, nextZ);
} else {
func_8002A194(player, spFC, spF8, spF4);
func_8002A194(player, nextX, nextY, nextZ);
}
func_8002AE38(player, playerId, posX, posZ, spFC, spF4);
func_8002AE38(player, playerId, posX, posZ, nextX, nextZ);
temp2 = (sp98[0] * sp98[0]) + (sp98[2] * sp98[2]);
player->unk_22C = player->unk_094;
@ -2452,12 +2452,12 @@ void func_8002D268(Player *player, UNUSED Camera *camera, s8 screenId, s8 player
sp98[0] = sp98[0] + (-1 * sp98[0]);
sp98[2] = sp98[2] + (-1 * sp98[2]);
} else {
player->pos[0] = spFC;
player->pos[2] = spF4;
player->pos[0] = nextX;
player->pos[2] = nextZ;
}
player->pos[1] = spF8;
player->pos[1] = nextY;
if ((player->type & PLAYER_HUMAN) && (!(player->type & PLAYER_KART_AI))) {
func_8002BB9C(player, &spFC, &spF4, screenId, playerId, sp98);
func_8002BB9C(player, &nextX, &nextZ, screenId, playerId, sp98);
}
player->unk_064[0] = sp178[0];
player->unk_064[2] = sp178[2];
@ -2500,7 +2500,7 @@ void func_8002E4C4(Player *player) {
player->kartHopVelocity = 0.0f;
player->pos[1] = spawn_actor_on_surface(player->pos[0], D_80164510[player_index] + 10.0f, player->pos[2]) + player->boundingBoxSize;
if (((player->pos[1] - D_80164510[player_index]) > 1200.0f) || ((player->pos[1] - D_80164510[player_index]) < -1200.0f)) {
player->pos[1] = player->copy_rotation_y;
player->pos[1] = player->oldPos[1];
}
player->velocity[1] = 0.0f;
}
@ -2592,16 +2592,16 @@ void func_8002E594(Player *player, UNUSED Camera *camera, s8 screenId, s8 player
posY = player->pos[1];
posZ = player->pos[2];
player->copy_rotation_x = player->pos[0];
player->copy_rotation_y = player->pos[1];
player->copy_rotation_z = player->pos[2];
player->oldPos[0] = player->pos[0];
player->oldPos[1] = player->pos[1];
player->oldPos[2] = player->pos[2];
spD0 = posX + player->velocity[0] + D_8018CE10[playerId].unk_04[0];
spCC = posY + player->velocity[1];
spC8 = posZ + player->velocity[2] + D_8018CE10[playerId].unk_04[2];
func_8002AAC0(player);
spCC += player->kartHopVelocity;
actor_terrain_collision(&player->collision, player->boundingBoxSize, spD0, spCC, spC8, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z);
actor_terrain_collision(&player->collision, player->boundingBoxSize, spD0, spCC, spC8, player->oldPos[0], player->oldPos[1], player->oldPos[2]);
player->effects |= 8;
player->unk_0C2 += 1;
player->unk_058 = 0.0f;
@ -2785,9 +2785,9 @@ void control_kart_ai_movement(Player *player, UNUSED Camera *camera, s8 arg2, s8
sp68[2] = player->velocity[2];
sp68[0] += (((spF4[0] + sp84) + spD0[0]) - (sp68[0] * (0.12 * player->kartFriction))) / 6000.0;
sp68[2] += (((spF4[2] + sp7C) + spD0[2]) - (sp68[2] * (0.12 * player->kartFriction))) / 6000.0;
player->copy_rotation_x = player->pos[0];
player->copy_rotation_y = test;
player->copy_rotation_z = player->pos[2];
player->oldPos[0] = player->pos[0];
player->oldPos[1] = test;
player->oldPos[2] = player->pos[2];
spCC = player->pos[0] + player->velocity[0];
spC4 = player->pos[2] + player->velocity[2];
player->unk_0C0 = 0;
@ -2866,9 +2866,9 @@ void func_8002F730(Player *player, UNUSED Camera *camera, UNUSED s8 screenId, s8
spB8 = player->pos[2];
player->copy_rotation_x = player->pos[0];
player->copy_rotation_y = player->pos[1];
player->copy_rotation_z = player->pos[2];
player->oldPos[0] = player->pos[0];
player->oldPos[1] = player->pos[1];
player->oldPos[2] = player->pos[2];
spCC = player->velocity[0] + spC0;
spC8 = player->velocity[1] + sp44;
@ -2877,7 +2877,7 @@ void func_8002F730(Player *player, UNUSED Camera *camera, UNUSED s8 screenId, s8
func_8002AAC0(player);
spC8 += player->kartHopVelocity;
actor_terrain_collision(&player->collision, player->boundingBoxSize, spCC, spC8, spC4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z);
actor_terrain_collision(&player->collision, player->boundingBoxSize, spCC, spC8, spC4, player->oldPos[0], player->oldPos[1], player->oldPos[2]);
player->unk_058 = 0.0f;
player->unk_05C = 1.0f;
player->unk_060 = 0.0f;
@ -4997,9 +4997,9 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId)
posY = player->pos[1];
posZ = player->pos[2];
player->copy_rotation_x = player->pos[0];
player->copy_rotation_y = player->pos[1];
player->copy_rotation_z = player->pos[2];
player->oldPos[0] = player->pos[0];
player->oldPos[1] = player->pos[1];
player->oldPos[2] = player->pos[2];
spEC = posX + player->velocity[0];
spE8 = posY + player->velocity[1];
@ -5007,7 +5007,7 @@ void func_80038C6C(Player *player, UNUSED Camera *camera, s8 arg2, s8 playerId)
func_8002AAC0(player);
spE8 += player->kartHopVelocity;
spE8 -= 0.02;
actor_terrain_collision(&player->collision, player->boundingBoxSize, spEC, spE8, spE4, player->copy_rotation_x, player->copy_rotation_y, player->copy_rotation_z);
actor_terrain_collision(&player->collision, player->boundingBoxSize, spEC, spE8, spE4, player->oldPos[0], player->oldPos[1], player->oldPos[2]);
player->unk_058 = 0;
player->unk_060 = 0;
player->unk_05C = 1.0f;

View File

@ -1148,8 +1148,8 @@ void spawn_course_actors(void) {
/**
* @brief Loads actor textures, course specific actor textures.
* Calls to init_course_vehicles and place_course_actors
*
* Calls to spawn_course_vehicles and place_course_actors
*
*/
void init_actors_and_load_textures(void) {
set_segment_base_addr_x64(3, (void *) gNextFreeMemoryAddress);
@ -1249,7 +1249,7 @@ void init_actors_and_load_textures(void) {
init_red_shell_texture();
destroy_all_actors();
spawn_course_actors();
init_course_vehicles();
spawn_course_vehicles();
}
void play_sound_before_despawn(struct Actor *actor) {

View File

@ -80,7 +80,7 @@ f32 func_802AAB4C(Player *player) {
}
return D_8015F8E4;
case COURSE_DK_JUNGLE:
temp_v1 = get_section_id(player->collision.meshIndexZX) & 0xFF;
temp_v1 = get_track_section_id(player->collision.meshIndexZX) & 0xFF;
if (temp_v1 == 0xFF) {
if ((get_surface_type(player->collision.meshIndexZX) & 0xFF) == CAVE) {
return -475.0f;
@ -498,7 +498,7 @@ s8 get_surface_type(u16 index) {
return triangle->surfaceType;
}
s16 get_section_id(u16 index) {
s16 get_track_section_id(u16 index) {
CollisionTriangle *triangle = &gCollisionMesh[index];
return triangle->flags & 0xFF;
}
@ -750,7 +750,7 @@ UNUSED s32 detect_tyre_collision(KartTyre *tyre) {
// depending on which (if any) if statements were entered on the loop's last cycle
}
s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 index, f32 posX, f32 posY, f32 posZ) {
s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize, f32 newX, f32 newY, f32 newZ, u16 index, f32 oldX, f32 oldY, f32 oldZ) {
CollisionTriangle *triangle = &gCollisionMesh[index];
UNUSED s32 pad;
f32 x4;
@ -770,19 +770,19 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize
f32 area3;
s32 flag = 1;
if (triangle->minX > x1) {
if (triangle->minX > newX) {
return 0;
}
if (triangle->minZ > z1) {
if (triangle->minZ > newZ) {
return 0;
}
if (triangle->maxX < x1) {
if (triangle->maxX < newX) {
return 0;
}
if (triangle->maxZ < z1) {
if (triangle->maxZ < newZ) {
return 0;
}
if ((triangle->minY - boundingBoxSize * 3.0f) > y1) {
if ((triangle->minY - boundingBoxSize * 3.0f) > newY) {
return 0;
}
@ -795,22 +795,22 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize
x4 = (f32) triangle->vtx3->v.ob[0];
z4 = (f32) triangle->vtx3->v.ob[2];
area = (z2 - z1) * (x3 - x1) - (x2 - x1) * (z3 - z1);
area = (z2 - newZ) * (x3 - newX) - (x2 - newX) * (z3 - newZ);
if (area == 0) {
area2 = (z3 - z1) * (x4 - x1) - (x3 - x1) * (z4 - z1);
area3 = (z4 - z1) * (x2 - x1) - (x4 - x1) * (z2 - z1);
area2 = (z3 - newZ) * (x4 - newX) - (x3 - newX) * (z4 - newZ);
area3 = (z4 - newZ) * (x2 - newX) - (x4 - newX) * (z2 - newZ);
if (area2 * area3 < 0.0f) {
flag = 0;
}
} else {
area2 = (z3 - z1) * (x4 - x1) - (x3 - x1) * (z4 - z1);
area2 = (z3 - newZ) * (x4 - newX) - (x3 - newX) * (z4 - newZ);
if (area2 == 0) {
area3 = (z4 - z1) * (x2 - x1) - (x4 - x1) * (z2 - z1);
area3 = (z4 - newZ) * (x2 - newX) - (x4 - newX) * (z2 - newZ);
if (area * area3 < 0.0f) {
flag = 0;
@ -819,7 +819,7 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize
if ((area * area2) < 0.0f) {
flag = 0;
} else {
area3 = (z4- z1) * (x2 - x1) - (x4 - x1) * (z2 - z1);
area3 = (z4- newZ) * (x2 - newX) - (x4 - newX) * (z2 - newZ);
if (area3 != 0) {
if (area2 * area3 < 0.0f) {
flag = 0;
@ -832,7 +832,7 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize
return 0;
}
surfaceDistance = (triangle->normalX * x1) + (triangle->normalY * y1) + (triangle->normalZ * z1) + triangle->distance;
surfaceDistance = (triangle->normalX * newX) + (triangle->normalY * newY) + (triangle->normalZ * newZ) + triangle->distance;
if (surfaceDistance > boundingBoxSize) {
if (collision->surfaceDistance[2] > surfaceDistance) {
@ -846,25 +846,26 @@ s32 is_colliding_with_drivable_surface(Collision *collision, f32 boundingBoxSize
return 0;
}
temp = (triangle->normalX * posX) + (triangle->normalY * posY) + (triangle->normalZ * posZ) + triangle->distance;
temp = (triangle->normalX * oldX) + (triangle->normalY * oldY) + (triangle->normalZ * oldZ) + triangle->distance;
if (temp < 0.0f) {
return 0;
}
collision->unk34 = 1;
collision->meshIndexZX = index;
collision->surfaceDistance[2] = surfaceDistance - boundingBoxSize;
collision->orientationVector[0] = triangle->normalX;
collision->orientationVector[1] = triangle->normalY;
collision->orientationVector[2] = triangle->normalZ;
return 1;
collision->unk34 = 1;
collision->meshIndexZX = index;
collision->surfaceDistance[2] = surfaceDistance - boundingBoxSize;
collision->orientationVector[0] = triangle->normalX;
collision->orientationVector[1] = triangle->normalY;
collision->orientationVector[2] = triangle->normalZ;
return 1;
}
/**
* Wall collision
*/
s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 arg5, f32 arg6, f32 arg7, f32 arg8) {
CollisionTriangle *triangle = &gCollisionMesh[arg5];
s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 surfaceIndex, f32 posX, f32 posY, f32 posZ) {
CollisionTriangle *triangle = &gCollisionMesh[surfaceIndex];
UNUSED s32 pad[6];
f32 x4;
f32 y4;
@ -881,22 +882,22 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1,
f32 area3;
s32 flag = true;
if (triangle->minX > x1) {
return 0;
return NO_COLLISION;
}
if (triangle->maxX < x1) {
return 0;
return NO_COLLISION;
}
if (triangle->maxY < y1) {
return 0;
return NO_COLLISION;
}
if (triangle->minY > y1) {
return 0;
return NO_COLLISION;
}
if ((triangle->minZ - boundingBoxSize * 3.0f) > z1) {
return 0;
return NO_COLLISION;
}
if ((triangle->maxZ + boundingBoxSize * 3.0f) < z1) {
return 0;
return NO_COLLISION;
}
x2 = (f32) triangle->vtx1->v.ob[0];
@ -943,107 +944,108 @@ s32 is_colliding_with_wall2(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1,
}
}
}
if (!flag) {
return 0;
return NO_COLLISION;
}
distanceToSurface = ((triangle->normalX * x1) + (triangle->normalY * y1) + (triangle->normalZ * z1)) + triangle->distance;
if (triangle->flags & 0x200) {
distanceToSurface2 = ((triangle->normalX * arg6) + (triangle->normalY * arg7) + (triangle->normalZ * arg8)) + triangle->distance;
distanceToSurface2 = ((triangle->normalX * posX) + (triangle->normalY * posY) + (triangle->normalZ * posZ)) + triangle->distance;
if ((distanceToSurface > 0.0f) && (distanceToSurface2 > 0.0f)) {
if (distanceToSurface < boundingBoxSize) {
arg->unk30 = 1;
arg->meshIndexYX = arg5;
arg->meshIndexYX = surfaceIndex;
arg->surfaceDistance[0] = distanceToSurface - boundingBoxSize;
arg->unk48[0] = triangle->normalX;
arg->unk48[1] = triangle->normalY;
arg->unk48[2] = triangle->normalZ;
return 1;
return COLLISION;
}
return 0;
return NO_COLLISION;
}
if ((distanceToSurface < 0.0f) && (distanceToSurface2 < 0.0f)) {
distanceToSurface *= -1.0f;
if (distanceToSurface < boundingBoxSize) {
arg->unk30 = 1;
arg->meshIndexYX = arg5;
arg->meshIndexYX = surfaceIndex;
arg->surfaceDistance[0] = distanceToSurface - boundingBoxSize;
arg->unk48[0] = -triangle->normalX;
arg->unk48[1] = -triangle->normalY;
arg->unk48[2] = -triangle->normalZ;
return 1;
}
return 0;
return NO_COLLISION;
}
if ((distanceToSurface > 0.0f) && (distanceToSurface2 < 0.0f)) {
arg->unk30 = 1;
arg->meshIndexYX = arg5;
arg->meshIndexYX = surfaceIndex;
arg->surfaceDistance[0] = -(distanceToSurface + boundingBoxSize);
arg->unk48[0] = -triangle->normalX;
arg->unk48[1] = -triangle->normalY;
arg->unk48[2] = -triangle->normalZ;
return 1;
return COLLISION;
}
if ((distanceToSurface < 0.0f) && (distanceToSurface2 > 0.0f)) {
arg->unk30 = 1;
arg->meshIndexYX = arg5;
arg->meshIndexYX = surfaceIndex;
arg->surfaceDistance[0] = distanceToSurface + boundingBoxSize;
arg->unk48[0] = triangle->normalX;
arg->unk48[1] = triangle->normalY;
arg->unk48[2] = triangle->normalZ;
return 1;
return COLLISION;
}
if (distanceToSurface == 0.0f) {
if (distanceToSurface2 >= 0.0f) {
arg->unk30 = 1;
arg->meshIndexYX = arg5;
arg->meshIndexYX = surfaceIndex;
arg->surfaceDistance[0] = distanceToSurface2 + boundingBoxSize;
arg->unk48[0] = triangle->normalX;
arg->unk48[1] = triangle->normalY;
arg->unk48[2] = triangle->normalZ;
return 1;
return COLLISION;
}
arg->unk30 = 1;
arg->meshIndexYX = arg5;
arg->meshIndexYX = surfaceIndex;
arg->surfaceDistance[0] = -(distanceToSurface2 + boundingBoxSize);
arg->unk48[0] = triangle->normalX;
arg->unk48[1] = triangle->normalY;
arg->unk48[2] = triangle->normalZ;
return 1;
return COLLISION;
}
return 0;
return NO_COLLISION;
}
if (distanceToSurface > boundingBoxSize) {
if (distanceToSurface < arg->surfaceDistance[0]) {
arg->unk30 = 1;
arg->meshIndexYX = arg5;
arg->meshIndexYX = surfaceIndex;
arg->surfaceDistance[0] = distanceToSurface - boundingBoxSize;
arg->unk48[0] = triangle->normalX;
arg->unk48[1] = triangle->normalY;
arg->unk48[2] = triangle->normalZ;
}
return 0;
return NO_COLLISION;
}
distanceToSurface2 = (triangle->normalX * arg6) + (triangle->normalY * arg7) + (triangle->normalZ * arg8) + triangle->distance;
distanceToSurface2 = (triangle->normalX * posX) + (triangle->normalY * posY) + (triangle->normalZ * posZ) + triangle->distance;
if (distanceToSurface2 < 0.0f) {
return 0;
return NO_COLLISION;
}
arg->unk30 = 1;
arg->meshIndexYX = arg5;
arg->meshIndexYX = surfaceIndex;
arg->surfaceDistance[0] = distanceToSurface - boundingBoxSize;
arg->unk48[0] = triangle->normalX;
arg->unk48[1] = triangle->normalY;
arg->unk48[2] = triangle->normalZ;
return 1;
return COLLISION;
}
/**
* This is actually more like colliding with face X/Y/Z
*/
s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 arg5, f32 arg6, f32 arg7, f32 arg8) {
CollisionTriangle *triangle = &gCollisionMesh[arg5];
s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, u16 surfaceIndex, f32 posX, f32 posY, f32 posZ) {
CollisionTriangle *triangle = &gCollisionMesh[surfaceIndex];
s32 flag = 1;
UNUSED s32 pad[7];
f32 y4;
@ -1061,22 +1063,22 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1,
f32 area3;
if (triangle->minZ > z1) {
return 0;
return NO_COLLISION;
}
if (triangle->maxZ < z1) {
return 0;
return NO_COLLISION;
}
if (triangle->maxY < y1) {
return 0;
return NO_COLLISION;
}
if (triangle->minY > y1) {
return 0;
return NO_COLLISION;
}
if ((triangle->minX - boundingBoxSize * 3.0f) > x1) {
return 0;
return NO_COLLISION;
}
if ((triangle->maxX + boundingBoxSize * 3.0f) < x1) {
return 0;
return NO_COLLISION;
}
z2 = (f32) triangle->vtx1->v.ob[2];
@ -1124,103 +1126,103 @@ s32 is_colliding_with_wall1(Collision *arg, f32 boundingBoxSize, f32 x1, f32 y1,
}
}
if (flag == 0) {
return 0;
return NO_COLLISION;
}
distanceToSurface = ((triangle->normalX * x1) + (triangle->normalY * y1) + (triangle->normalZ * z1)) + triangle->distance;
if (triangle->flags & 0x200) {
distanceToSurface2 = ((triangle->normalX * arg6) + (triangle->normalY * arg7) + (triangle->normalZ * arg8)) + triangle->distance;
distanceToSurface2 = ((triangle->normalX * posX) + (triangle->normalY * posY) + (triangle->normalZ * posZ)) + triangle->distance;
//sp48 = temp_f4_2;
if ((distanceToSurface > 0.0f) && (distanceToSurface2 > 0.0f)) {
if (distanceToSurface < boundingBoxSize) {
arg->unk32 = 1;
arg->meshIndexZY = arg5;
arg->meshIndexZY = surfaceIndex;
arg->surfaceDistance[1] = distanceToSurface - boundingBoxSize;
arg->unk54[0] = triangle->normalX;
arg->unk54[1] = triangle->normalY;
arg->unk54[2] = triangle->normalZ;
return 1;
return COLLISION;
}
return 0;
return NO_COLLISION;
}
if ((distanceToSurface < 0.0f) && (distanceToSurface2 < 0.0f)) {
distanceToSurface *= -1.0f;
if (distanceToSurface < boundingBoxSize) {
arg->unk32 = 1;
arg->meshIndexZY = arg5;
arg->meshIndexZY = surfaceIndex;
arg->surfaceDistance[1] = distanceToSurface - boundingBoxSize;
arg->unk54[0] = -triangle->normalX;
arg->unk54[1] = -triangle->normalY;
arg->unk54[2] = -triangle->normalZ;
return 1;
}
return 0;
return NO_COLLISION;
}
if ((distanceToSurface > 0.0f) && (distanceToSurface2 < 0.0f)) {
arg->unk32 = 1;
arg->meshIndexZY = arg5;
arg->meshIndexZY = surfaceIndex;
arg->surfaceDistance[1] = -(distanceToSurface + boundingBoxSize);
arg->unk54[0] = -triangle->normalX;
arg->unk54[1] = -triangle->normalY;
arg->unk54[2] = -triangle->normalZ;
return 1;
return COLLISION;
}
if ((distanceToSurface < 0.0f) && (distanceToSurface2 > 0.0f)) {
arg->unk32 = 1;
arg->meshIndexZY = arg5;
arg->meshIndexZY = surfaceIndex;
arg->surfaceDistance[1] = distanceToSurface + boundingBoxSize;
arg->unk54[0] = triangle->normalX;
arg->unk54[1] = triangle->normalY;
arg->unk54[2] = triangle->normalZ;
return 1;
return COLLISION;
}
if (distanceToSurface == 0.0f) {
if (distanceToSurface2 >= 0.0f) {
arg->unk32 = 1;
arg->meshIndexZY = arg5;
arg->meshIndexZY = surfaceIndex;
arg->surfaceDistance[1] = distanceToSurface2 + boundingBoxSize;
arg->unk54[0] = triangle->normalX;
arg->unk54[1] = triangle->normalY;
arg->unk54[2] = triangle->normalZ;
return 1;
return COLLISION;
}
arg->unk32 = 1;
arg->meshIndexZY = arg5;
arg->meshIndexZY = surfaceIndex;
arg->surfaceDistance[1] = -(distanceToSurface2 + boundingBoxSize);
arg->unk54[0] = triangle->normalX;
arg->unk54[1] = triangle->normalY;
arg->unk54[2] = triangle->normalZ;
return 1;
return COLLISION;
}
return 0;
return NO_COLLISION;
}
if (distanceToSurface > boundingBoxSize) {
if (arg->surfaceDistance[1] > distanceToSurface) {
arg->unk32 = 1;
arg->meshIndexZY = arg5;
arg->meshIndexZY = surfaceIndex;
arg->surfaceDistance[1] = distanceToSurface - boundingBoxSize;
arg->unk54[0] = triangle->normalX;
arg->unk54[1] = triangle->normalY;
arg->unk54[2] = triangle->normalZ;
}
return 0;
return NO_COLLISION;
}
distanceToSurface2 = (triangle->normalX * arg6) + (triangle->normalY * arg7) + (triangle->normalZ * arg8) + triangle->distance;
distanceToSurface2 = (triangle->normalX * posX) + (triangle->normalY * posY) + (triangle->normalZ * posZ) + triangle->distance;
if (distanceToSurface2 < 0.0f) {
return 0;
return NO_COLLISION;
}
arg->unk32 = 1;
arg->meshIndexZY = arg5;
arg->meshIndexZY = surfaceIndex;
arg->surfaceDistance[1] = distanceToSurface - boundingBoxSize;
arg->unk54[0] = triangle->normalX;
arg->unk54[1] = triangle->normalY;
arg->unk54[2] = triangle->normalZ;
return 1;
return COLLISION;
}
u16 actor_terrain_collision(Collision *collision, f32 boundingBoxSize, f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2) {
u16 actor_terrain_collision(Collision *collision, f32 boundingBoxSize, f32 newX, f32 newY, f32 newZ, f32 oldX, f32 oldY, f32 oldZ) {
s32 courseLengthX;
s32 courseLengthZ;
s16 sectionIndexX;
@ -1245,19 +1247,19 @@ u16 actor_terrain_collision(Collision *collision, f32 boundingBoxSize, f32 x1, f
// Check if an intersection test has already been performed.
if ((s32) collision->meshIndexZX < (s32) gCollisionMeshCount) {
if (is_colliding_with_drivable_surface(collision, boundingBoxSize, x1, y1, z1, collision->meshIndexZX, x2, y2, z2) == 1) {
if (is_colliding_with_drivable_surface(collision, boundingBoxSize, newX, newY, newZ, collision->meshIndexZX, oldX, oldY, oldZ) == COLLISION) {
flags |= FACING_Y_AXIS;
}
}
if ((s32) collision->meshIndexYX < (s32) gCollisionMeshCount) {
if (is_colliding_with_wall2(collision, boundingBoxSize, x1, y1, z1, collision->meshIndexYX, x2, y2, z2) == 1) {
if (is_colliding_with_wall2(collision, boundingBoxSize, newX, newY, newZ, collision->meshIndexYX, oldX, oldY, oldZ) == COLLISION) {
flags |= FACING_Z_AXIS;
}
}
if ((s32) collision->meshIndexZY < (s32) gCollisionMeshCount) {
if (is_colliding_with_wall1(collision, boundingBoxSize, x1, y1, z1, collision->meshIndexZY, x2, y2, z2) == 1) {
if (is_colliding_with_wall1(collision, boundingBoxSize, newX, newY, newZ, collision->meshIndexZY, oldX, oldY, oldZ) == COLLISION) {
flags |= FACING_X_AXIS;
}
}
@ -1272,9 +1274,9 @@ u16 actor_terrain_collision(Collision *collision, f32 boundingBoxSize, f32 x1, f
sectionX = courseLengthX / GRID_SIZE;
sectionZ = courseLengthZ / GRID_SIZE;
sectionIndexX = (x1 - gCourseMinX) / sectionX;
sectionIndexZ = (z1 - gCourseMinZ) / sectionZ;
sectionIndexX = (newX - gCourseMinX) / sectionX;
sectionIndexZ = (newZ - gCourseMinZ) / sectionZ;
if (sectionIndexX < 0) {
return 0;
}
@ -1307,7 +1309,7 @@ u16 actor_terrain_collision(Collision *collision, f32 boundingBoxSize, f32 x1, f
if ((gCollisionMesh[collisionIndex].flags & FACING_Y_AXIS)) {
if ((flags & FACING_Y_AXIS) == 0) {
if (collisionIndex != collision->meshIndexZX) {
if (is_colliding_with_drivable_surface(collision, boundingBoxSize, x1, y1, z1, collisionIndex, x2, y2, z2) == 1) {
if (is_colliding_with_drivable_surface(collision, boundingBoxSize, newX, newY, newZ, collisionIndex, oldX, oldY, oldZ) == COLLISION) {
flags |= FACING_Y_AXIS;
}
}
@ -1315,14 +1317,14 @@ u16 actor_terrain_collision(Collision *collision, f32 boundingBoxSize, f32 x1, f
} else if ((gCollisionMesh[collisionIndex].flags & FACING_X_AXIS) != 0) {
if ((flags & FACING_X_AXIS) == 0) {
if (collisionIndex != collision->meshIndexZY) {
if (is_colliding_with_wall1(collision, boundingBoxSize, x1, y1, z1, collisionIndex, x2, y2, z2) == 1) {
if (is_colliding_with_wall1(collision, boundingBoxSize, newX, newY, newZ, collisionIndex, oldX, oldY, oldZ) == COLLISION) {
flags |= FACING_X_AXIS;
}
}
}
} else if ((flags & FACING_Z_AXIS) == 0) {
if (collisionIndex != collision->meshIndexYX) {
if (is_colliding_with_wall2(collision, boundingBoxSize, x1, y1, z1, collisionIndex, x2, y2, z2) == 1) {
if (is_colliding_with_wall2(collision, boundingBoxSize, newX, newY, newZ, collisionIndex, oldX, oldY, oldZ) == COLLISION) {
flags |= FACING_Z_AXIS;
}
}
@ -2138,7 +2140,7 @@ void subtract_scaled_vector(Vec3f pos1, f32 boundingBoxSize, Vec3f pos2) {
pos2[2] -= pos1[2] * boundingBoxSize;
}
u16 process_collision(Player *player, KartTyre *tyre, f32 tyre2X, f32 tyre2Y, f32 tyre2Z) {
u16 player_terrain_collision(Player *player, KartTyre *tyre, f32 tyre2X, f32 tyre2Y, f32 tyre2Z) {
Collision wtf;
Collision *collision = &wtf;
UNUSED s32 pad;

View File

@ -13,7 +13,7 @@ s32 check_collision_zx(Collision*, f32, f32, f32, f32, u16);
s32 check_collision_yx(Collision*, f32, f32, f32, f32, u16);
s32 check_collision_zy(Collision*, f32, f32, f32, f32, u16);
s8 get_surface_type(u16);
s16 get_section_id(u16);
s16 get_track_section_id(u16);
s16 func_802ABD7C(u16);
s16 func_802ABDB8(u16);
s16 func_802ABDF4(u16);
@ -21,7 +21,7 @@ f32 calculate_surface_height(f32, f32, f32, u16);
f32 func_802ABEAC(Collision*, Vec3f);
void shell_collision(Collision *, Vec3f);
void process_shell_collision(Vec3f, f32, Vec3f, f32);
u16 process_collision(Player*, KartTyre*, f32, f32, f32);
u16 player_terrain_collision(Player*, KartTyre*, f32, f32, f32);
void adjust_pos_orthogonally(Vec3f, f32, Vec3f, f32);
s32 detect_tyre_collision(KartTyre*);
u16 actor_terrain_collision(Collision*, f32, f32, f32, f32, f32, f32, f32);

View File

@ -936,6 +936,7 @@ f32 atan2f(f32 arg0, f32 arg1) {
return atan2s(arg0, arg1);
}
#ifndef NON_MATCHING // The decomp does not support fabs
UNUSED f32 func_802B79F0(f32 arg0, f32 arg1) {
f64 halfpi;
f32 temp_f0;
@ -970,6 +971,7 @@ UNUSED f32 func_802B79F0(f32 arg0, f32 arg1) {
}
return var_f2;
}
#endif
UNUSED u16 func_802B7B50(f32 arg0, f32 arg1) {
return ((atan2f(arg0, arg1) * 32768.0f) / M_PI);

View File

@ -501,7 +501,7 @@ void start_race(void) {
f32 func_8028EE8C(s32 arg0) {
f32 temp_v0 = gPlayers[arg0].pos[2];
f32 temp_v1 = gPlayers[arg0].copy_rotation_z;
f32 temp_v1 = gPlayers[arg0].oldPos[2];
f32 temp_f14 = D_8015F8D0[2] - temp_v0;
f32 temp_f16 = temp_v1 - D_8015F8D0[2];
return gCourseTimer - ((COURSE_TIMER_ITER_f * temp_f14) / (temp_f14 + temp_f16));

View File

@ -114,8 +114,8 @@ void render_course_segments(const char* addr[], struct UnkStruct_800DC5EC *arg1)
arg1->playerDirection = var_a3;
if (D_80152300[camera - camera1] == 1) {
sp1E = get_section_id(camera->collision.meshIndexZX);
temp_v0_3 = get_section_id(player->collision.meshIndexZX);
sp1E = get_track_section_id(camera->collision.meshIndexZX);
temp_v0_3 = get_track_section_id(player->collision.meshIndexZX);
index = sp1E - temp_v0_3;
if ((index < 2) && (index >= -1)) {
if (sp1E == 255) {
@ -168,7 +168,7 @@ void render_course_segments(const char* addr[], struct UnkStruct_800DC5EC *arg1)
}
}
} else {
index = get_section_id(camera->collision.meshIndexZX);
index = get_track_section_id(camera->collision.meshIndexZX);
if (camera->collision.surfaceDistance[2] > 30.0f) {
index = arg1->pathCounter;
} else if (index == 255) {

View File

@ -3668,8 +3668,8 @@ void render_object_train_smoke_particle(s32 objectIndex, s32 cameraId) {
}
}
// Train smoke?
void render_object_train_smoke_particles(s32 cameraId) {
// Trains smoke particles.
void render_object_trains_smoke_particles(s32 cameraId) {
UNUSED s32 pad;
UNUSED s32 j;
Camera *camera;

View File

@ -349,7 +349,7 @@ void func_80053D74(s32, s32, s32);
void func_80053E6C(s32);
void render_object_train_smoke_particle(s32, s32);
void render_object_train_smoke_particles(s32);
void render_object_trains_smoke_particles(s32);
void render_object_paddle_boat_smoke_particle(s32, s32);
void render_object_paddle_boat_smoke_particles(s32);
void render_object_bowser_flame_particle(s32, s32);

View File

@ -91,9 +91,9 @@ void reset_save_data_grand_prix_points_and_sound_mode(void) {
s32 cup_index;
Stuff *main = &gSaveData.main;
for (cup_index = 0; cup_index < 4; cup_index++) {
main->grandPrixPoints[cup_index] = 0;
main->saveInfo.grandPrixPoints[cup_index] = 0;
}
main->soundMode = SOUND_STEREO;
main->saveInfo.soundMode = SOUND_STEREO;
gSoundMode = SOUND_STEREO;
func_800B44BC();
write_save_data_grand_prix_points_and_sound_mode();
@ -121,11 +121,11 @@ u8 checksum_time_trial_records(s32 courseIdx) {
u8 compute_save_data_checksum_1(void) {
u8 *grandPrixPoints = (u8 *) &gSaveData.main.grandPrixPoints;
u8 *grandPrixPoints = (u8 *) &gSaveData.main.saveInfo.grandPrixPoints;
s32 i;
s32 crc = 0;
for (i = 0; i < 5; i++) {
for (i = 0; i < sizeof(SaveInfo); i++) {
crc += ((grandPrixPoints[i] + 1) * (i + 1)) + i;
}
@ -148,7 +148,7 @@ void load_save_data(void) {
validate_save_data();
gSoundMode = gSaveData.main.soundMode;
gSoundMode = gSaveData.main.saveInfo.soundMode;
if (gSoundMode >= NUM_SOUND_MODES) {
gSoundMode = SOUND_MONO;
}
@ -213,10 +213,10 @@ void validate_save_data(void) {
if (validate_save_data_checksum_backup() == 0) {
for (cup_index = 0; cup_index < 4; cup_index++) {
main->grandPrixPoints[cup_index] = backup->grandPrixPoints[cup_index];
main->saveInfo.grandPrixPoints[cup_index] = backup->saveInfo.grandPrixPoints[cup_index];
}
main->soundMode = backup->soundMode;
main->saveInfo.soundMode = backup->saveInfo.soundMode;
main->checksum[1] = compute_save_data_checksum_backup_1();
main->checksum[2] = compute_save_data_checksum_backup_2();
osEepromLongWrite(&gSIEventMesgQueue, EEPROM_ADDR(main), (u8 *) main, sizeof(Stuff));
@ -385,8 +385,7 @@ void func_800B536C(s32 arg0) {
s32 tmp2;
if (arg0 >= 0) {
points = &gSaveData.main.grandPrixPoints[gCCSelection];
points = &gSaveData.main.saveInfo.grandPrixPoints[gCCSelection];
tmp = func_800B54EC(gCupSelection, *points);
tmp2 = 3 - arg0;
if ((arg0 < 3) && (tmp < (3-arg0))) {
@ -407,7 +406,7 @@ void func_800B5404(s32 arg0, s32 arg1)
if (arg0 >= 0) {
temp2 = arg1 / 4;
points = &gSaveData.main.grandPrixPoints[arg1 % 4];
points = &gSaveData.main.saveInfo.grandPrixPoints[arg1 % 4];
temp = func_800B54EC(temp2, *points);
if ((arg0 < 3) && (temp < (temp_a0 = 3 - arg0))) {
@ -421,7 +420,7 @@ void func_800B5404(s32 arg0, s32 arg1)
// Get Grand Prix points for a given cup and CC mode
u8 func_800B54C0(s32 cup, s32 cc_mode) {
return func_800B54EC(cup, gSaveData.main.grandPrixPoints[cc_mode]);
return func_800B54EC(cup, gSaveData.main.saveInfo.grandPrixPoints[cc_mode]);
}
// Get Grand Prix points scored for a given cup
@ -450,7 +449,7 @@ u8 func_800B5508(s32 cup, s32 ccGrandPrixPoints, s32 points_scored) {
// Check if all 4 cups have gold cups scored
// for a given CC mode
s32 func_800B5530(s32 cc_mode) {
if (gSaveData.main.grandPrixPoints[cc_mode] == 0xFF) {
if (gSaveData.main.saveInfo.grandPrixPoints[cc_mode] == 0xFF) {
return 1;
}
return 0;
@ -549,21 +548,21 @@ void update_save_data_backup(void) {
s32 cup_index;
Stuff *main = &gSaveData.main;
Stuff *backup = &gSaveData.backup;
for (cup_index = 0; cup_index < 4; cup_index++) {
backup->grandPrixPoints[cup_index] = main->grandPrixPoints[cup_index];
for (cup_index = 0; cup_index < NUM_CUPS - 1; cup_index++) {
backup->saveInfo.grandPrixPoints[cup_index] = main->saveInfo.grandPrixPoints[cup_index];
}
backup->soundMode = main->soundMode;
backup->saveInfo.soundMode = main->saveInfo.soundMode;
backup->checksum[1] = compute_save_data_checksum_backup_1();
backup->checksum[2] = compute_save_data_checksum_backup_2();
osEepromLongWrite(&gSIEventMesgQueue, EEPROM_ADDR(backup), (u8 *) backup, sizeof(Stuff));
}
u8 compute_save_data_checksum_backup_1(void) {
u8 *backupGrandPrixPoints = gSaveData.backup.grandPrixPoints;
u8 *backupGrandPrixPoints = gSaveData.backup.saveInfo.grandPrixPoints;
s32 i;
s32 crc = 0;
for (i = 0; i < 5; i++) {
for (i = 0; i < sizeof(SaveInfo); i++) {
crc += ((backupGrandPrixPoints[i] + 1) * (i + 1)) + i;
}

View File

@ -115,14 +115,14 @@ void spawn_player(Player *player, s8 playerIndex, f32 startingRow, f32 startingC
ret = spawn_actor_on_surface(startingRow, arg4 + 50.0f, startingColumn) + player->boundingBoxSize;
player->pos[2] = startingColumn;
player->pos[1] = ret;
player->copy_rotation_x = startingRow;
player->copy_rotation_y = ret;
player->oldPos[0] = startingRow;
player->oldPos[1] = ret;
D_80164510[playerIndex] = ret;
player->rotation[0] = 0;
player->copy_rotation_z = startingColumn;
player->oldPos[2] = startingColumn;
player->unk_05C = 1.0f;
player->unk_058 = 0.0f;
player->unk_060 = 0.0f;

View File

@ -1526,31 +1526,31 @@ void func_8007542C(s32 arg0) {
}
}
void func_80075574(s32 objectIndex, Vec3f arg1, f32 arg2) {
void init_train_smoke(s32 objectIndex, Vec3f pos, f32 velocity) {
Object *object;
UNUSED s32 pad[2];
init_object(objectIndex, 0);
object = &gObjectList[objectIndex];
object->origin_pos[0] = arg1[0];
object->origin_pos[1] = arg1[1];
object->origin_pos[2] = arg1[2];
object->velocity[1] = arg2;
object->origin_pos[0] = pos[0];
object->origin_pos[1] = pos[1];
object->origin_pos[2] = pos[2];
object->velocity[1] = velocity;
object->type = random_int(0x0064U) + 0x1E;
}
s32 func_800755FC(s32 arg0, Vec3f arg1, f32 arg2) {
s32 spawn_train_smoke(s32 trainIndex, Vec3f pos, f32 velocity) {
s32 objectIndex;
if (arg0 == 0) {
if (trainIndex == 0) {
objectIndex = add_unused_obj_index(gObjectParticle2, &gNextFreeObjectParticle2, gObjectParticle2_SIZE);
if (objectIndex != NULL_OBJECT_ID) {
func_80075574(objectIndex, arg1, arg2);
init_train_smoke(objectIndex, pos, velocity);
}
} else {
objectIndex = add_unused_obj_index(gObjectParticle3, &gNextFreeObjectParticle3, gObjectParticle3_SIZE);
if (objectIndex != NULL_OBJECT_ID) {
func_80075574(objectIndex, arg1, arg2);
init_train_smoke(objectIndex, pos, velocity);
}
}
return objectIndex;
@ -1646,31 +1646,31 @@ void update_train_smoke(void) {
}
}
void func_800759EC(s32 objectIndex, Vec3f arg1, f32 arg2) {
void init_ferry_smoke(s32 objectIndex, Vec3f pos, f32 velocity) {
Object *object;
init_object(objectIndex, 0);
object = &gObjectList[objectIndex];
object->origin_pos[0] = arg1[0];
object->origin_pos[1] = arg1[1];
object->origin_pos[2] = arg1[2];
object->velocity[1] = arg2;
object->origin_pos[0] = pos[0];
object->origin_pos[1] = pos[1];
object->origin_pos[2] = pos[2];
object->velocity[1] = velocity;
object->type = 0x00FF;
object->unk_0A2 = 0x0096;
}
s32 func_80075A6C(s32 arg0, Vec3f arg1, f32 arg2) {
s32 spawn_ferry_smoke(s32 ferryIndex, Vec3f pos, f32 velocity) {
s32 objectIndex;
if (arg0 == 0) {
if (ferryIndex == 0) {
objectIndex = add_unused_obj_index(gObjectParticle2, &gNextFreeObjectParticle2, gObjectParticle2_SIZE);
if (objectIndex != NULL_OBJECT_ID) {
func_800759EC(objectIndex, arg1, arg2);
init_ferry_smoke(objectIndex, pos, velocity);
}
} else {
objectIndex = add_unused_obj_index(gObjectParticle3, &gNextFreeObjectParticle3, gObjectParticle3_SIZE);
if (objectIndex != NULL_OBJECT_ID) {
func_800759EC(objectIndex, arg1, arg2);
init_ferry_smoke(objectIndex, pos, velocity);
}
}

View File

@ -120,14 +120,14 @@ void func_80074FD8(s32);
void func_800750D8(s32, s32, Vec3f, s32, s32);
void func_80075304(Vec3f, s32, s32, s32);
void func_8007542C(s32);
void func_80075574(s32, Vec3f, f32);
s32 func_800755FC(s32, Vec3f, f32);
void init_train_smoke(s32, Vec3f, f32);
s32 spawn_train_smoke(s32, Vec3f, f32);
void func_80075698(s32);
void func_80075714(s32);
void update_train_smoke(void);
void func_80075838(void);
void func_800759EC(s32, Vec3f, f32);
s32 func_80075A6C(s32, Vec3f, f32);
void init_ferry_smoke(s32, Vec3f, f32);
s32 spawn_ferry_smoke(s32, Vec3f, f32);
void func_80075B08(s32);
void func_80075B84(s32);
void update_ferries_smoke_particle(void);

View File

@ -13,39 +13,6 @@ SP_DMEM = 0xA4000000;
SP_DMEM_UNK0 = 0xA40004C0;
SP_DMEM_UNK1 = 0xA4000774;
SP_IMEM = 0xA4001000;
SP_STATUS_REG = 0xA4040010;
SP_PC = 0xA4080000;
/* MI */
MI_MODE_REG = 0xA4300000;
MI_VERSION_REG = 0xA4300004;
MI_INTR_REG = 0xA4300008;
MI_INTR_MASK_REG = 0xA430000C;
/* VI */
VI_CURRENT_REG = 0xA4400010;
/* AI */
AI_STATUS_REG = 0xA450000C;
/* PI */
PI_DRAM_ADDR_REG = 0xA4600000;
PI_CART_ADDR_REG = 0xA4600004;
PI_WR_LEN_REG = 0xA460000C;
PI_STATUS_REG = 0xA4600010;
/* RI */
RI_MODE_REG = 0xA4700000;
RI_REFRESH_REG = 0xA4700010;
/* SI */
SI_STATUS_REG = 0xA4800018;
/* Unknown */
@ -73,41 +40,6 @@ D_05FF8DB8 = 0x05FF8DB8;
D_0B002A00 = 0x0B002A00;
D_A4040004 = 0xA4040004;
D_A4040008 = 0xA4040008;
D_A404000C = 0xA404000C;
D_A4040010 = 0xA4040010;
D_A4300008 = 0xA4300008;
D_A430000C = 0xA430000C;
D_A4400004 = 0xA4400004;
D_A4400008 = 0xA4400008;
D_A440000C = 0xA440000C;
D_A4400010 = 0xA4400010;
D_A4400014 = 0xA4400014;
D_A4400018 = 0xA4400018;
D_A440001C = 0xA440001C;
D_A4400020 = 0xA4400020;
D_A4400024 = 0xA4400024;
D_A4400028 = 0xA4400028;
D_A440002C = 0xA440002C;
D_A4400030 = 0xA4400030;
D_A4400034 = 0xA4400034;
D_A4500004 = 0xA4500004;
D_A4500008 = 0xA4500008;
D_A450000C = 0xA450000C;
D_A4500010 = 0xA4500010;
D_A4500014 = 0xA4500014;
D_A4600004 = 0xA4600004;
D_A4600008 = 0xA4600008;
D_A460000C = 0xA460000C;
D_A4600010 = 0xA4600010;
D_A4600024 = 0xA4600024;
D_A4600028 = 0xA4600028;
D_A460002C = 0xA460002C;
D_A4600030 = 0xA4600030;
D_A4800004 = 0xA4800004;
D_A4800010 = 0xA4800010;
D_A4800018 = 0xA4800018;
D_A5000508 = 0xA5000508;
D_A5000510 = 0xA5000510;
D_E6FFFFFC = 0xE6FFFFFC;