Fewer uses of 'Thing2 - Thing1' for sizeof(Thing)

This commit is contained in:
Rangi 2018-07-16 15:58:07 -04:00
parent d9b44d4423
commit b23f0b2bda
6 changed files with 22 additions and 27 deletions

View File

@ -55,8 +55,8 @@ OddEgg1:
bigdw 8 ; SAtk bigdw 8 ; SAtk
bigdw 8 ; SDef bigdw 8 ; SDef
db "EGG@@@@@@@@" db "EGG@@@@@@@@"
OddEgg1End:
OddEgg2:
db PICHU db PICHU
db NO_ITEM db NO_ITEM
db THUNDERSHOCK, CHARM, DIZZY_PUNCH, 0 db THUNDERSHOCK, CHARM, DIZZY_PUNCH, 0

View File

@ -3619,10 +3619,10 @@ CheckPlayerPartyForFitMon:
ld e, a ld e, a
xor a xor a
ld hl, wPartyMon1HP ld hl, wPartyMon1HP
ld bc, wPartyMon2 - (wPartyMon1 + 1) ld bc, PARTYMON_STRUCT_LENGTH - 1
.loop .loop
or [hl] or [hl]
inc hl inc hl ; + 1
or [hl] or [hl]
add hl, bc add hl, bc
dec e dec e

View File

@ -104,7 +104,7 @@ Function_LoadRandomBattleTowerMon:
ld a, [wBTChoiceOfLvlGroup] ld a, [wBTChoiceOfLvlGroup]
dec a dec a
ld hl, BattleTowerMons ld hl, BattleTowerMons
ld bc, BattleTowerMons2 - BattleTowerMons1 ld bc, BattleTowerMons2 - BattleTowerMons1 ; size of one level group
call AddNTimes call AddNTimes
ld a, [hRandomAdd] ld a, [hRandomAdd]

View File

@ -39,7 +39,7 @@ _GiveOddEgg:
.done .done
ld hl, OddEggs ld hl, OddEggs
ld a, OddEgg2 - OddEgg1 ld a, OddEgg1End - OddEgg1
call AddNTimes call AddNTimes
ld de, wOddEggSpecies ld de, wOddEggSpecies

View File

@ -2039,7 +2039,7 @@ CheckTimeCapsuleCompatibility:
jr nc, .move_too_new jr nc, .move_too_new
dec c dec c
jr nz, .move_next jr nz, .move_next
ld de, wPartyMon2 - (wPartyMon1 + NUM_MOVES) ld de, PARTYMON_STRUCT_LENGTH - NUM_MOVES
add hl, de add hl, de
dec b dec b
jr nz, .move_loop jr nz, .move_loop

View File

@ -562,8 +562,8 @@ DoPlayerMovement::
.GetAction: .GetAction:
; Poll player input and update movement info. ; Poll player input and update movement info.
ld hl, .table ld hl, .action_table
ld de, .table2 - .table1 ld de, .action_table_1_end - .action_table_1
ld a, [wCurInput] ld a, [wCurInput]
bit D_DOWN_F, a bit D_DOWN_F, a
jr nz, .d_down jr nz, .d_down
@ -597,25 +597,20 @@ DoPlayerMovement::
ld [wWalkingTile], a ld [wWalkingTile], a
ret ret
.table player_action: MACRO
; struct: ; walk direction, facing, x movement, y movement, tile collision pointer
; walk direction db \1, \2, \3, \4
; facing dw \5
; x movement ENDM
; y movement
; tile collision pointer .action_table:
.table1 .action_table_1
db STANDING, FACE_CURRENT, 0, 0 player_action STANDING, FACE_CURRENT, 0, 0, wPlayerStandingTile
dw wPlayerStandingTile .action_table_1_end
.table2 player_action RIGHT, FACE_RIGHT, 1, 0, wTileRight
db RIGHT, FACE_RIGHT, 1, 0 player_action LEFT, FACE_LEFT, -1, 0, wTileLeft
dw wTileRight player_action UP, FACE_UP, 0, -1, wTileUp
db LEFT, FACE_LEFT, -1, 0 player_action DOWN, FACE_DOWN, 0, 1, wTileDown
dw wTileLeft
db UP, FACE_UP, 0, -1
dw wTileUp
db DOWN, FACE_DOWN, 0, 1
dw wTileDown
.CheckNPC: .CheckNPC:
; Returns 0 if there is an NPC in front that you can't move ; Returns 0 if there is an NPC in front that you can't move