Skip to content

Commit

Permalink
Merge pull request #684 from notyourav/tiles
Browse files Browse the repository at this point in the history
Tiles documentation
  • Loading branch information
hytopoulos committed Jan 1, 2024
2 parents 72c27b5 + 37ac9cb commit 48fdf9d
Show file tree
Hide file tree
Showing 210 changed files with 1,119 additions and 1,063 deletions.
22 changes: 12 additions & 10 deletions asm/src/code_08001A7C.s
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,8 @@ _0800271A:
bne _0800270A
pop {r4, r5, r6, pc}

thumb_func_start sub_08002724
sub_08002724: @ 0x08002724
thumb_func_start UnpackTextNibbles
UnpackTextNibbles: @ 0x08002724
push {r4, r5, lr}
movs r2, #0x10
movs r3, #0xf
Expand Down Expand Up @@ -1019,24 +1019,25 @@ _080027E6:
movs r0, #4
bx lr

// almost identical to LinearMoveDirection
// r0 = Entity*
// r1 = speed
// r2 = direction
non_word_aligned_thumb_func_start sub_080027EA
sub_080027EA: @ 0x080027EA
non_word_aligned_thumb_func_start LinearMoveDirectionOLD
LinearMoveDirectionOLD: @ 0x080027EA
push {r4, r5, r6, r7, lr}
movs r3, #0x80
tst r2, r3
bne _08002860
movs r4, #0x2a
ldrh r3, [r0, r4]
ldrh r3, [r0, r4] // collisions
movs r4, #7
tst r2, r4
bne _08002812
push {r0, r1, r2, r3}
adds r0, r2, #0
adds r1, r3, #0
bl sub_08002864
bl CalcCollisionDirectionOLD
adds r4, r0, #0
pop {r0, r1, r2, r3}
cmp r2, r4
Expand All @@ -1063,7 +1064,7 @@ _08002812:
_08002834:
adds r4, r0, #0
pop {r0, r1, r2, r3}
ldr r5, [r0, #0x2c]
ldr r5, [r0, #0x2c] // x
adds r5, r5, r4
str r5, [r0, #0x2c]
_0800283E:
Expand All @@ -1081,15 +1082,16 @@ _0800283E:
_08002856:
adds r4, r0, #0
pop {r0, r1, r2, r3}
ldr r5, [r0, #0x30]
ldr r5, [r0, #0x30] // y
subs r5, r5, r4
str r5, [r0, #0x30]
_08002860:
adds r1, r6, #0
pop {r4, r5, r6, r7, pc}

thumb_func_start sub_08002864
sub_08002864: @ 0x08002864
// collision related, probably leftover from FS
thumb_func_start CalcCollisionDirectionOLD
CalcCollisionDirectionOLD: @ 0x08002864
adds r2, r0, #0
lsrs r2, r2, #3
cmp r2, #0
Expand Down
48 changes: 24 additions & 24 deletions asm/src/code_08003FC4.s
Original file line number Diff line number Diff line change
Expand Up @@ -621,37 +621,37 @@ _0800439C: .4byte gSpritePtrs
_080043A0: .4byte gSpritePtrs
_080043A4: .4byte gGFXSlots+4

thumb_func_start sub_080043A8
sub_080043A8: @ 0x080043A8
movs r1, #0xb
b _080043B6

thumb_func_start CreateChestSpawner
CreateChestSpawner: @ 0x080043AC
movs r1, #0xc
b _080043B6

thumb_func_start sub_080043B0
sub_080043B0: @ 0x080043AC
movs r1, #0x52
b _080043B6

thumb_func_start CreateItemOnGround
CreateItemOnGround: @ 0x080043B4
movs r1, #0

_080043B6:
thumb_func_start CreateDrownFX
CreateDrownFX: @ 0x080043A8
movs r1, #0xb // FX_WATER_SPLASH
b create_fx

thumb_func_start CreateLavaDrownFX
CreateLavaDrownFX: @ 0x080043AC
movs r1, #0xc // FX_LAVA_SPLASH
b create_fx

thumb_func_start CreateSwampDrownFX
CreateSwampDrownFX: @ 0x080043AC
movs r1, #0x52 // FX_GREEN_SPLASH
b create_fx

thumb_func_start CreatePitFallFX
CreatePitFallFX: @ 0x080043B4
movs r1, #0 // FX_FALL_DOWN

create_fx:
push {r4, lr}
adds r4, r0, #0
movs r0, #0xf
movs r2, #0
bl CreateObject

cmp r0, #0
beq _080043E0 @ Branch if entity could not be created
beq _080043E0

movs r1, #0x48
ldr r1, [r4, r1] @ Unused?
ldr r1, [r4, r1] // load hitbox (unused)

ldrh r3, [r4, #0x2e]
strh r3, [r0, #0x2e]
Expand All @@ -664,11 +664,11 @@ _080043B6:

ldrb r3, [r4, #8]

cmp r3, #3 @ Is the spawner an enemy?
cmp r3, #3 // is parent entity an enemy?
bne _080043E0

movs r1, #1
strb r1, [r0, #0xb] @ Set base parameter
strb r1, [r0, #0xb] // copy entity.type2

_080043E0:
adds r0, r4, #0
Expand Down
65 changes: 38 additions & 27 deletions asm/src/code_080043E8.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,67 @@

.text

thumb_func_start sub_080043E8
sub_080043E8: @ 0x080043E8
.macro hazard_tile tile:req, hazard_type:req
.short \tile
.short \hazard_type
.endm

thumb_func_start GetTileHazardType
GetTileHazardType: @ 0x080043E8
push {r4, lr}
ldrb r1, [r0, #0xc]
cmp r1, #0
beq _08004414
beq no_hazard // action == 0
adds r4, r0, #0
bl sub_08016AD2
bl UpdateCollisionLayer
movs r3, #0x36
ldrsh r2, [r4, r3]
cmp r2, #0
bmi _08004414
cmp r0, #0
beq _08004414
add r3, pc, #0x10
_08004404:
bmi no_hazard // collisionLayer is negative
cmp r0, #0 // are we on a tile?
beq no_hazard
adr r3, hazard_list-4
loop:
adds r3, #4
ldrh r1, [r3]
cmp r1, #0
beq _08004414
beq no_hazard
cmp r0, r1
bne _08004404
bne loop
ldrh r0, [r3, #2]
pop {r4, pc}
_08004414:
no_hazard:
movs r0, #0
pop {r4, pc}
_08004418:
.byte 0x0D, 0x00, 0x01, 0x00, 0x10, 0x00, 0x02, 0x00
.byte 0x11, 0x00, 0x02, 0x00, 0x5A, 0x00, 0x03, 0x00, 0x13, 0x00, 0x04, 0x00, 0x00, 0x00

hazard_list:
hazard_tile 0xD, 0x1
hazard_tile 0x10, 0x2
hazard_tile 0x11, 0x2
hazard_tile 0x5A, 0x3
hazard_tile 0x13, 0x4
.short 0x0000

non_word_aligned_thumb_func_start sub_0800442E
sub_0800442E: @ 0x0800442E
push {r0, lr}
bl sub_080043E8
bl GetTileHazardType
cmp r0, #0
beq _08004448
lsls r0, r0, #2
add r1, pc, #0xC
beq not_hazard
lsls r0, #2
adr r1, _0800444C - 4
ldr r1, [r1, r0]
pop {r0}
bl _call_via_r1
movs r0, #1
pop {pc}
_08004448:
not_hazard:
movs r0, #0
pop {r1, pc}
_0800444C: .4byte CreateItemOnGround
_08004450: .4byte sub_080043A8
_08004454: .4byte CreateChestSpawner
_08004458: .4byte sub_080043B0
_0800444C: .4byte CreatePitFallFX
_08004450: .4byte CreateDrownFX
_08004454: .4byte CreateLavaDrownFX
_08004458: .4byte CreateSwampDrownFX

thumb_func_start sub_0800445C
sub_0800445C: @ 0x0800445C
Expand Down Expand Up @@ -171,6 +181,7 @@ _08004516:
adds r0, r2, #0
bx lr

// r0 = Entity*
thumb_func_start sub_0800451C
sub_0800451C: @ 0x0800451C
push {r0, lr}
Expand All @@ -196,17 +207,17 @@ sub_0800451C: @ 0x0800451C
sub_08004542: @ 0x08004542
movs r1, #0x38
movs r2, #2
strb r2, [r0, r1]
strb r2, [r0, r1] // entity->collisionLayer = 2
movs r2, #0xc0
ldrb r1, [r0, #0x1b]
bics r1, r2
adds r1, #0x40
strb r1, [r0, #0x1b]
strb r1, [r0, #0x1b] // update spriteOrientation
movs r2, #0xc0
ldrb r1, [r0, #0x19]
bics r1, r2
adds r1, #0x40
strb r1, [r0, #0x19]
strb r1, [r0, #0x19] // update spriteRendering
bx lr

non_word_aligned_thumb_func_start ResetCollisionLayer
Expand Down
14 changes: 7 additions & 7 deletions asm/src/code_08007CAC.s
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ gUnk_08007CAC:: @ 08007CAC
.endif
.endif

non_word_aligned_thumb_func_start sub_08007DD6
sub_08007DD6: @ 0x08007DD6
non_word_aligned_thumb_func_start ActTileToTile
ActTileToTile: @ 0x08007DD6
push {lr}
bl sub_08007DE0
bl ActTileConv
adds r0, r3, #0
pop {pc}

thumb_func_start sub_08007DE0
sub_08007DE0: @ 0x08007DE0
thumb_func_start ActTileConv
ActTileConv: @ 0x08007DE0
subs r1, #4
_08007DE2:
adds r1, #4
ldrh r3, [r1]
cmp r3, #0
cmp r3, #0 // reached end
beq _08007DF2
cmp r0, r3
cmp r0, r3 // equal
bne _08007DE2
ldrh r3, [r1, #2]
movs r2, #1
Expand Down
14 changes: 7 additions & 7 deletions asm/src/enemy.s
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ _08001230:
ldr r3, _0800135C @ =UpdateAnimationVariableFrames
bx r3
_0800123E:
ldr r3, _08001360 @ =CreateItemOnGround
ldr r3, _08001360 @ =CreatePitFallFX
bx r3

non_word_aligned_thumb_func_start GenericConfused
Expand Down Expand Up @@ -155,19 +155,19 @@ _080012BA:
gUnk_080012C8::
.4byte 0x00000000
_080012CC: .4byte sub_08001214
_080012D0: .4byte sub_080043A8
_080012D4: .4byte CreateChestSpawner
_080012D8: .4byte sub_080043B0
_080012D0: .4byte CreateDrownFX
_080012D4: .4byte CreateLavaDrownFX
_080012D8: .4byte CreateSwampDrownFX

thumb_func_start sub_080012DC
sub_080012DC: @ 0x080012DC
push {r4, r5, lr}
adds r4, r0, #0
movs r5, #0x3a
ldrb r1, [r4, r5]
ldrb r1, [r4, r5] // gust jar state
lsrs r1, r1, #3
bhs _08001302
bl sub_080043E8
bl GetTileHazardType
cmp r0, #4
beq _08001302
cmp r0, #0
Expand Down Expand Up @@ -241,7 +241,7 @@ _08001352:
.align 2, 0
_08001358: .4byte gEnemyFunctions
_0800135C: .4byte UpdateAnimationVariableFrames
_08001360: .4byte CreateItemOnGround
_08001360: .4byte CreatePitFallFX
_08001364: .4byte 0x00001800
_08001368: .4byte gUnk_080012C8
_0800136C: .4byte gUnk_080012C8
Expand Down
4 changes: 2 additions & 2 deletions asm/src/intr.s
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ _080B1A64:
ldrh r0, [r1, r0]
bx lr

arm_func_start arm_GetRelativeCollisionTile
arm_GetRelativeCollisionTile: @ 0x080B1A8C
arm_func_start arm_GetActTileRelative
arm_GetActTileRelative: @ 0x080B1A8C
ldrh r3, [r0, #0x2e]
add r3, r3, r1
ldrh r1, [r0, #0x32]
Expand Down
Loading

0 comments on commit 48fdf9d

Please sign in to comment.