Skip to content

Commit

Permalink
Merge pull request #690 from octorock/tilemap-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
hytopoulos committed Jan 12, 2024
2 parents 6fb8b41 + 1ecc23d commit 320d446
Show file tree
Hide file tree
Showing 454 changed files with 29,567 additions and 25,934 deletions.
6 changes: 3 additions & 3 deletions asm/lib/libgcc.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@ custom libgcc implementation

.code 16
_08000ED8:
_divide_by_zero:
movs r0, #0
movs r1, #0
movs r2, #0
Expand All @@ -17,14 +17,14 @@ _08000ED8:
thumb_func_start __divsi3
__divsi3: @ 0x08000EE0
cmp r1, #0
beq _08000ED8
beq _divide_by_zero
svc #6
bx lr

thumb_func_start __modsi3
__modsi3: @ 0x08000EE8
cmp r1, #0
beq _08000ED8
beq _divide_by_zero
svc #6
adds r0, r1, #0
bx lr
Expand Down
4 changes: 2 additions & 2 deletions asm/macros/entity.inc
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@
.2byte \paramB, \paramC, \paramD
.endm

.macro chest type, id, item, subnum, tileset_id
.macro chest type, id, item, subnum, tileSet_id
.2byte (\map_x) << 4
.2byte (\map_y) << 4
.2byte \pixel_width
.2byte \pixel_height
.2byte \tileset_id
.2byte \tileSet_id
.endm

.macro delayed_entity_raw subtype:req, paramA=0, paramB=0, layer=0, x=0, y=0, paramC=0, paramD=0, conditions=0
Expand Down
36 changes: 18 additions & 18 deletions asm/macros/map.inc
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@

.set TOP_TILEDATA, gMapTop+0x4
.set TOP_COLLISIONDATA, gMapTop+0x2004
.set TOP_TILEDATACLONE, gMapTop+0x3004
.set TOP_METATILETYPES, gMapTop+0x5004
.set TOP_UNKDATA2, gMapTop+0x6004
.set TOP_METATILES, gMapTop+0x7004
.set TOP_UNKDATA3, gMapTop+0xb004
.set TOP_TILEDATAORIGINAL, gMapTop+0x3004
.set TOP_TILETYPES, gMapTop+0x5004
.set TOP_TILEINDICES, gMapTop+0x6004
.set TOP_TILES, gMapTop+0x7004
.set TOP_ACTTILES, gMapTop+0xb004
.set BOTTOM_TILEDATA, gMapBottom+0x4
.set BOTTOM_COLLISIONDATA, gMapBottom+0x2004
.set BOTTOM_TILEDATACLONE, gMapBottom+0x3004
.set BOTTOM_METATILETYPES, gMapBottom+0x5004
.set BOTTOM_UNKDATA2, gMapBottom+0x6004
.set BOTTOM_METATILES, gMapBottom+0x7004
.set BOTTOM_UNKDATA3, gMapBottom+0xb004
.set BOTTOM_TILEDATAORIGINAL, gMapBottom+0x3004
.set BOTTOM_TILETYPES, gMapBottom+0x5004
.set BOTTOM_TILEINDICES, gMapBottom+0x6004
.set BOTTOM_TILES, gMapBottom+0x7004
.set BOTTOM_ACTTILES, gMapBottom+0xb004

.macro room_header map_x, map_y, pixel_width, pixel_height, tileset_id
.macro room_header map_x, map_y, pixel_width, pixel_height, tileSet_id
.2byte (\map_x) << 4
.2byte (\map_y) << 4
.2byte \pixel_width
.2byte \pixel_height
.2byte \tileset_id
.2byte \tileSet_id
.endm


Expand All @@ -31,29 +31,29 @@
.4byte (\compressed << 0x1F) | (\size)
.endm

.macro tileset_tiles src_offset, dest, size, compressed, terminator=0
.macro tileSet_tiles src_offset, dest, size, compressed, terminator=0
map_data \src_offset, \dest, \size, \compressed, \terminator
.endm

.macro tileset_palette_set id, terminator=0
.macro tileSet_palette_set id, terminator=0
.4byte (!(\terminator) << 0x1F) | (\id)
.4byte 0x0
.4byte 0x0
.endm

.macro metatiles_bottom src_offset, size, compressed, terminator=0
.macro tiles_bottom src_offset, size, compressed, terminator=0
map_data \src_offset, gMapBottom+0x7004, \size, \compressed, \terminator
.endm

.macro metatiles_top src_offset, size, compressed, terminator=0
.macro tiles_top src_offset, size, compressed, terminator=0
map_data \src_offset, gMapTop+0x7004, \size, \compressed, \terminator
.endm

.macro metatile_types_bottom src_offset, size, compressed, terminator=0
.macro tile_types_bottom src_offset, size, compressed, terminator=0
map_data \src_offset, gMapBottom+0x5004, \size, \compressed, \terminator
.endm

.macro metatile_types_top src_offset, size, compressed, terminator=0
.macro tile_types_top src_offset, size, compressed, terminator=0
map_data \src_offset, gMapTop+0x5004, \size, \compressed, \terminator
.endm

Expand Down
10 changes: 5 additions & 5 deletions asm/macros/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -635,27 +635,27 @@
.2byte \c
.endm

.macro _0807EDD4 a:req, b:req
.macro MoveTo a:req, b:req
.2byte 0x0c73
.2byte \a
.2byte \b
.endm

.macro _0807EE04 a:req, b:req
.macro LookAt a:req, b:req
.2byte 0x0c74
.2byte \a
.2byte \b
.endm

.macro _0807EE30
.macro MoveTowardsTarget
.2byte 0x0475
.endm

.macro _0807EEB4
.macro MoveToPlayer
.2byte 0x0476
.endm

.macro _0807EEF4 a:req, b:req
.macro MoveToOffset a:req, b:req
.2byte 0x0c77
.2byte \a
.2byte \b
Expand Down
2 changes: 1 addition & 1 deletion asm/src/code_08000F10.s
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ _08000F18:
bpl _08000F18
pop {r4, r5, r6}
bx lr

// sum 3 drop probabilities, clamp to 0, return scalar sum
thumb_func_start SumDropProbabilities2
SumDropProbabilities2: @ 0x08000F2C
Expand Down
8 changes: 4 additions & 4 deletions asm/src/code_08003FC4.s
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ _080040F2:
movs r3, #0x38
ldrb r3, [r0, r3]
lsls r3, r3, #2
ldr r4, _08004380 @ =gUnk_08000248
ldr r4, _08004380 @ =gCollisionDataPtrs
ldr r3, [r4, r3]
ldrb r4, [r3, r2]
pop {r2, r3}
Expand Down Expand Up @@ -403,7 +403,7 @@ _0800423C:
movs r4, #0x38
ldrb r4, [r0, r4]
lsls r4, r4, #3
ldr r3, _08004394 @ =gUnk_08000228
ldr r3, _08004394 @ =gMapDataPtrs
adds r3, r3, r4
ldr r4, [r3]
ldrh r1, [r4, r2]
Expand Down Expand Up @@ -610,12 +610,12 @@ _08004370: .4byte 0x0000011E
_08004374: .4byte gRoomControls + 6
_08004378: .4byte gRoomControls + 8
_0800437C: .4byte 0x000003F0
_08004380: .4byte gUnk_08000248
_08004380: .4byte gCollisionDataPtrs
_08004384: .4byte 0x000FFFFF
_08004388: .4byte 0x00080000
_0800438C: .4byte 0x0000EE00
_08004390: .4byte 0x00001FFF
_08004394: .4byte gUnk_08000228
_08004394: .4byte gMapDataPtrs
_08004398: .4byte 0x00004000
_0800439C: .4byte gSpritePtrs
_080043A0: .4byte gSpritePtrs
Expand Down
47 changes: 3 additions & 44 deletions asm/src/code_080043E8.s
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ _08004516:
thumb_func_start sub_0800451C
sub_0800451C: @ 0x0800451C
push {r0, lr}
bl GetActTile
bl GetActTileAtEntity
adds r1, r0, #0
pop {r0, r3}
mov lr, r3
Expand Down Expand Up @@ -301,8 +301,8 @@ CalculateDirectionTo: @ 0x080045D4
ldr r3, _08004694 @ =ram_CalcCollisionDirection
bx r3

non_word_aligned_thumb_func_start CalcOffsetAngle
CalcOffsetAngle: @ 0x080045DA
non_word_aligned_thumb_func_start CalculateDirectionFromOffsets
CalculateDirectionFromOffsets: @ 0x080045DA
push {r0, r1, r4, r5, r6, lr}
movs r6, #0x40
cmp r0, #0
Expand Down Expand Up @@ -382,44 +382,3 @@ _08004694: .4byte ram_CalcCollisionDirection
_08004698: .4byte gUnk_080C93E0
_0800469C: .4byte 0x00000106
_080046A0: .4byte 0x00000280

gUnk_080046A4:: @ 080046A4
.incbin "code_080043E8/gUnk_080046A4.bin"

gUnk_080047F6:: @ 080047F6
.incbin "code_080043E8/gUnk_080047F6.bin"

@ TODO PlayerMacros

gUnk_080049D6:: @ 080049D6
.incbin "code_080043E8/gUnk_080049D6.bin"

gUnk_080049F6:: @ 080049F6
.incbin "code_080043E8/gUnk_080049F6.bin"

gUnk_080049FE:: @ gUnk_080049FE
.incbin "code_080043E8/gUnk_080049FE.bin"

gUnk_08004A0C:: @ 08004A0C
.incbin "code_080043E8/gUnk_08004A0C.bin"

gUnk_08004A16:: @ 08004A16
.incbin "code_080043E8/gUnk_08004A16.bin"

gUnk_08004A24:: @ 08004A24
.incbin "code_080043E8/gUnk_08004A24.bin"

gUnk_08004A32:: @ 08004A32
.incbin "code_080043E8/gUnk_08004A32.bin"

gUnk_08004A48:: @ 08004A48
.incbin "code_080043E8/gUnk_08004A48.bin"

gUnk_08004A72:: @ 08004A72
.incbin "code_080043E8/gUnk_08004A72.bin"

gUnk_08004A8C:: @ 08004A8C
.incbin "code_080043E8/gUnk_08004A8C.bin"

gUnk_08004AA6:: @ 08004AA6
.incbin "code_080043E8/gUnk_08004AA6.bin"
70 changes: 32 additions & 38 deletions asm/src/code_08007CAC.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,42 @@

.text

gUnk_08007CAC:: @ 08007CAC
.incbin "code_080043E8/gUnk_08007CAC.bin"
.ifdef DEMO_JP
@ TODO only one byte differs
.incbin "code_080043E8/gUnk_08007CAC_1_DEMO_JP.bin"
.else
.ifdef DEMO_USA
@ TODO only one byte differs
.incbin "code_080043E8/gUnk_08007CAC_2_DEMO_USA.bin"
.else
.ifdef JP
@ TODO only one byte differs
.incbin "code_080043E8/gUnk_08007CAC_3_JP.bin"
.else
.ifdef EU
@ TODO only two bytes differ
.incbin "code_080043E8/gUnk_08007CAC_4_EU.bin"
.else
.incbin "code_080043E8/gUnk_08007CAC_5_USA.bin"
.endif
.endif
.endif
.endif

non_word_aligned_thumb_func_start ActTileToTile
ActTileToTile: @ 0x08007DD6
// TODO cannot add this at the end of mapActTileToSurfaceType.c due to alignment?
.2byte 0

// TODO unused? might also be code?
gUnk_08007DBE:: @ 08007DBE
.byte 0x42, 0x7b, 0x01, 0x32, 0x42, 0x73, 0x70, 0x47, 0x02, 0x73, 0x00, 0x23, 0x43, 0x73, 0x0b, 0x73

// seems unused?
non_word_aligned_thumb_func_start sub_08007DCE
sub_08007DCE:
push {lr}
bl DoPlayerAction
pop {pc}


// Searches for a KeyValuePair with the key in the keyValuePairList and returns its value. Returns 0 if the key is not found.
// r0: key
// r1: keyValuePairList
non_word_aligned_thumb_func_start FindValueForKey
FindValueForKey: @ 0x08007DD6
push {lr}
bl ActTileConv
adds r0, r3, #0
bl FindEntryForKey
adds r0, r3, #0 // move the found value into r0
pop {pc}

thumb_func_start ActTileConv
ActTileConv: @ 0x08007DE0
thumb_func_start FindEntryForKey
FindEntryForKey: @ 0x08007DE0
subs r1, #4
_08007DE2:
adds r1, #4
ldrh r3, [r1]
cmp r3, #0 // reached end
beq _08007DF2
cmp r0, r3 // equal
bne _08007DE2
ldrh r3, [r1, #2]
movs r2, #1
adds r1, #4 // add +4 to r1 at the end of loop
ldrh r3, [r1] // r3: key
cmp r3, #0
beq _08007DF2 // key == 0 -> end of map
cmp r0, r3
bne _08007DE2 // r3 == r0 -> found
ldrh r3, [r1, #2] // r3: value
movs r2, #1 // r2 = 1
_08007DF2:
bx lr
Loading

0 comments on commit 320d446

Please sign in to comment.