Skip to content

Commit 7005dd3

Browse files
committed
Label cleanup, add some constants instead of raw numbers
1 parent d98b5e6 commit 7005dd3

File tree

20 files changed

+104
-108
lines changed

20 files changed

+104
-108
lines changed

constants/gfx_constants.asm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
; * LCD enabled
2+
; * Window tile map at $9C00
3+
; * Window display enabled
4+
; * BG and window tile data at $8800
5+
; * BG tile map at $9800
6+
; * 8x8 OBJ size
7+
; * OBJ display enabled
8+
; * BG display enabled
9+
DEF LCDC_DEFAULT EQU LCDC_ON | LCDC_WIN_9C00 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9800 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
10+
111
DEF TILE_1BPP_SIZE EQU TILE_SIZE / 2 ; bytes
212

313
DEF BLOCK_WIDTH EQU 4 ; tiles

data/maps/objects/Route2Gate.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object_const_def
2-
const_export ROUTE2_OAKS_AIDE
3-
const_export ROUTE2_YOUNGSTER
2+
const_export ROUTE2GATE_OAKS_AIDE
3+
const_export ROUTE2GATE_YOUNGSTER
44

55
Route2Gate_Object:
66
db $a ; border block

engine/battle/core.asm

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,30 +3137,30 @@ PlayerCalcMoveDamage:
31373137
jp c, .moveHitTest ; SetDamageEffects moves (e.g. Seismic Toss and Super Fang) skip damage calculation
31383138
call CriticalHitTest
31393139
call HandleCounterMove
3140-
jr z, handleIfPlayerMoveMissed
3140+
jr z, HandleIfPlayerMoveMissed
31413141
call GetDamageVarsForPlayerAttack
31423142
call CalculateDamage
3143-
jp z, playerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
3143+
jp z, PlayerCheckIfFlyOrChargeEffect ; for moves with 0 BP, skip any further damage calculation and, for now, skip MoveHitTest
31443144
; for these moves, accuracy tests will only occur if they are called as part of the effect itself
31453145
call AdjustDamageForMoveType
31463146
call RandomizeDamage
31473147
.moveHitTest
31483148
call MoveHitTest
3149-
handleIfPlayerMoveMissed:
3149+
HandleIfPlayerMoveMissed:
31503150
ld a, [wMoveMissed]
31513151
and a
3152-
jr z, getPlayerAnimationType
3152+
jr z, GetPlayerAnimationType
31533153
ld a, [wPlayerMoveEffect]
31543154
sub EXPLODE_EFFECT
3155-
jr z, playPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
3156-
jr playerCheckIfFlyOrChargeEffect
3157-
getPlayerAnimationType:
3155+
jr z, PlayPlayerMoveAnimation ; don't play any animation if the move missed, unless it was EXPLODE_EFFECT
3156+
jr PlayerCheckIfFlyOrChargeEffect
3157+
GetPlayerAnimationType:
31583158
ld a, [wPlayerMoveEffect]
31593159
and a
31603160
ld a, ANIMATIONTYPE_BLINK_ENEMY_MON_SPRITE ; move has no effect other than dealing damage
3161-
jr z, playPlayerMoveAnimation
3161+
jr z, PlayPlayerMoveAnimation
31623162
ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_LIGHT ; move has effect
3163-
playPlayerMoveAnimation:
3163+
PlayPlayerMoveAnimation:
31643164
push af
31653165
ld a, [wPlayerBattleStatus2]
31663166
bit HAS_SUBSTITUTE_UP, a
@@ -3179,7 +3179,7 @@ playPlayerMoveAnimation:
31793179
ld b, BANK(ReshowSubstituteAnim)
31803180
call nz, Bankswitch
31813181
jr MirrorMoveCheck
3182-
playerCheckIfFlyOrChargeEffect:
3182+
PlayerCheckIfFlyOrChargeEffect:
31833183
ld c, 30
31843184
call DelayFrames
31853185
ld a, [wPlayerMoveEffect]
@@ -3246,7 +3246,7 @@ MirrorMoveCheck:
32463246
ld a, [wPlayerNumAttacksLeft]
32473247
dec a
32483248
ld [wPlayerNumAttacksLeft], a
3249-
jp nz, getPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
3249+
jp nz, GetPlayerAnimationType ; for multi-hit moves, apply attack until PlayerNumAttacksLeft hits 0 or the enemy faints.
32503250
; damage calculation and accuracy tests only happen for the first hit
32513251
res ATTACKING_MULTIPLE_TIMES, [hl] ; clear attacking multiple times status when all attacks are over
32523252
ld hl, MultiHitText
@@ -3523,7 +3523,7 @@ CheckPlayerStatusConditions:
35233523
ld [hl], a
35243524
ld a, BIDE
35253525
ld [wPlayerMoveNum], a
3526-
ld hl, handleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
3526+
ld hl, HandleIfPlayerMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
35273527
jp .returnToHL
35283528

35293529
.ThrashingAboutCheck
@@ -3557,7 +3557,7 @@ CheckPlayerStatusConditions:
35573557
ld a, [wPlayerNumAttacksLeft]
35583558
dec a ; did multi-turn move end?
35593559
ld [wPlayerNumAttacksLeft], a
3560-
ld hl, getPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
3560+
ld hl, GetPlayerAnimationType ; if it didn't, skip damage calculation (deal damage equal to last hit),
35613561
; DecrementPP and MoveHitTest
35623562
jp nz, .returnToHL
35633563
jp .returnToHL
@@ -5567,7 +5567,7 @@ RandomizeDamage:
55675567
.loop
55685568
call BattleRandom
55695569
rrca
5570-
cp 217
5570+
cp 85 percent + 1
55715571
jr c, .loop
55725572
ldh [hMultiplier], a
55735573
call Multiply ; multiply damage by the random number, which is in the range [217, 255]
@@ -5660,7 +5660,7 @@ EnemyCalcMoveDamage:
56605660
jp c, EnemyMoveHitTest
56615661
call CriticalHitTest
56625662
call HandleCounterMove
5663-
jr z, handleIfEnemyMoveMissed
5663+
jr z, HandleIfEnemyMoveMissed
56645664
call SwapPlayerAndEnemyLevels
56655665
call GetDamageVarsForEnemyAttack
56665666
call SwapPlayerAndEnemyLevels
@@ -5671,13 +5671,13 @@ EnemyCalcMoveDamage:
56715671

56725672
EnemyMoveHitTest:
56735673
call MoveHitTest
5674-
handleIfEnemyMoveMissed:
5674+
HandleIfEnemyMoveMissed:
56755675
ld a, [wMoveMissed]
56765676
and a
56775677
jr z, .moveDidNotMiss
56785678
ld a, [wEnemyMoveEffect]
56795679
cp EXPLODE_EFFECT
5680-
jr z, handleExplosionMiss
5680+
jr z, HandleExplosionMiss
56815681
jr EnemyCheckIfFlyOrChargeEffect
56825682
.moveDidNotMiss
56835683
call SwapPlayerAndEnemyLevels
@@ -5686,13 +5686,13 @@ GetEnemyAnimationType:
56865686
ld a, [wEnemyMoveEffect]
56875687
and a
56885688
ld a, ANIMATIONTYPE_SHAKE_SCREEN_VERTICALLY
5689-
jr z, playEnemyMoveAnimation
5689+
jr z, PlayEnemyMoveAnimation
56905690
ld a, ANIMATIONTYPE_SHAKE_SCREEN_HORIZONTALLY_HEAVY
5691-
jr playEnemyMoveAnimation
5692-
handleExplosionMiss:
5691+
jr PlayEnemyMoveAnimation
5692+
HandleExplosionMiss:
56935693
call SwapPlayerAndEnemyLevels
56945694
xor a
5695-
playEnemyMoveAnimation:
5695+
PlayEnemyMoveAnimation:
56965696
push af
56975697
ld a, [wEnemyBattleStatus2]
56985698
bit HAS_SUBSTITUTE_UP, a ; does mon have a substitute?
@@ -6031,7 +6031,7 @@ CheckEnemyStatusConditions:
60316031
ld a, BIDE
60326032
ld [wEnemyMoveNum], a
60336033
call SwapPlayerAndEnemyLevels
6034-
ld hl, handleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
6034+
ld hl, HandleIfEnemyMoveMissed ; skip damage calculation, DecrementPP and MoveHitTest
60356035
jp .enemyReturnToHL
60366036
.checkIfThrashingAbout
60376037
bit THRASHING_ABOUT, [hl] ; is mon using thrash or petal dance?

engine/battle/effects.asm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ _JumpMoveEffect:
77
ldh a, [hWhoseTurn]
88
and a
99
ld a, [wPlayerMoveEffect]
10-
jr z, .next1
10+
jr z, .next
1111
ld a, [wEnemyMoveEffect]
12-
.next1
12+
.next
1313
dec a ; subtract 1, there is no special effect for 00
1414
add a ; x2, 16bit pointers
1515
ld hl, MoveEffectPointerTable
@@ -680,14 +680,14 @@ UpdateLoweredStatDone:
680680
call PrintStatText
681681
pop de
682682
ld a, [de]
683-
cp $44
683+
cp ATTACK_DOWN_SIDE_EFFECT ; for all side effects, move animation has already played, skip it
684684
jr nc, .ApplyBadgeBoostsAndStatusPenalties
685685
call PlayCurrentMoveAnimation2
686686
.ApplyBadgeBoostsAndStatusPenalties
687687
ldh a, [hWhoseTurn]
688688
and a
689689
call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat,
690-
; even to those not affected by the stat-up move (will be boosted further)
690+
; even to those not affected by the stat-down move (will be boosted further)
691691
ld hl, MonsStatsFellText
692692
call PrintText
693693

@@ -1438,9 +1438,9 @@ CheckTargetSubstitute:
14381438
ld hl, wEnemyBattleStatus2
14391439
ldh a, [hWhoseTurn]
14401440
and a
1441-
jr z, .next1
1441+
jr z, .next
14421442
ld hl, wPlayerBattleStatus2
1443-
.next1
1443+
.next
14441444
bit HAS_SUBSTITUTE_UP, [hl]
14451445
pop hl
14461446
ret

engine/events/prize_menu.asm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ CeladonPrizeMenu::
22
ld b, COIN_CASE
33
call IsItemInBag
44
jr nz, .havingCoinCase
5-
ld hl, RequireCoinCaseTextPtr
5+
ld hl, RequireCoinCaseText
66
jp PrintText
77
.havingCoinCase
88
ld hl, wStatusFlags5
99
set BIT_NO_TEXT_DELAY, [hl]
10-
ld hl, ExchangeCoinsForPrizesTextPtr
10+
ld hl, ExchangeCoinsForPrizesText
1111
call PrintText
1212
; the following are the menu settings
1313
xor a
@@ -28,7 +28,7 @@ CeladonPrizeMenu::
2828
call TextBoxBorder
2929
call GetPrizeMenuId
3030
call UpdateSprites
31-
ld hl, WhichPrizeTextPtr
31+
ld hl, WhichPrizeText
3232
call PrintText
3333
call HandleMenuInput ; menu choice handler
3434
bit B_PAD_B, a
@@ -42,16 +42,16 @@ CeladonPrizeMenu::
4242
res BIT_NO_TEXT_DELAY, [hl]
4343
ret
4444

45-
RequireCoinCaseTextPtr:
45+
RequireCoinCaseText:
4646
text_far _RequireCoinCaseText
4747
text_waitbutton
4848
text_end
4949

50-
ExchangeCoinsForPrizesTextPtr:
50+
ExchangeCoinsForPrizesText:
5151
text_far _ExchangeCoinsForPrizesText
5252
text_end
5353

54-
WhichPrizeTextPtr:
54+
WhichPrizeText:
5555
text_far _WhichPrizeText
5656
text_end
5757

engine/gfx/palettes.asm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,15 @@ CopyGfxToSuperNintendoVRAM:
523523
call CopySGBBorderTiles
524524
jr .next
525525
.notCopyingTileData
526-
ld bc, $1000
526+
ld bc, 256 tiles
527527
call CopyData
528528
.next
529529
ld hl, vBGMap0
530-
ld de, $c
530+
ld de, TILEMAP_WIDTH - SCREEN_WIDTH
531531
ld a, $80
532-
ld c, $d
532+
ld c, 13 ; enough screen lines to fit 256 tiles
533533
.loop
534-
ld b, $14
534+
ld b, SCREEN_WIDTH
535535
.innerLoop
536536
ld [hli], a
537537
inc a
@@ -540,7 +540,7 @@ CopyGfxToSuperNintendoVRAM:
540540
add hl, de
541541
dec c
542542
jr nz, .loop
543-
ld a, $e3
543+
ld a, LCDC_DEFAULT
544544
ldh [rLCDC], a
545545
pop hl
546546
call SendSGBPacket

engine/menus/display_text_id_init.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ DisplayTextIDInit::
6969
add hl, de
7070
dec c
7171
jr nz, .spriteStandStillLoop
72-
ld b, $9c ; window background address
72+
ld b, HIGH(vBGMap1)
7373
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
7474
xor a
7575
ldh [hWY], a ; put the window on the screen

engine/menus/save.asm

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,11 @@ SAVCheckRandomID:
606606
; checks if Sav file is the same by checking player's name 1st letter
607607
; and the two random numbers generated at game beginning
608608
; (which are stored at wPlayerID)s
609-
ld a, $0a
609+
ld a, RAMG_SRAM_ENABLE
610610
ld [rRAMG], a
611-
ld a, $01
611+
ld a, BMODE_ADVANCED
612612
ld [rBMODE], a
613+
ASSERT BANK("Save Data") == BMODE_ADVANCED
613614
ld [rRAMB], a
614615
ld a, [sPlayerName]
615616
and a
@@ -631,7 +632,7 @@ SAVCheckRandomID:
631632
ld a, [wPlayerID + 1]
632633
cp h
633634
.next
634-
ld a, $00
635+
ld a, RAMG_SRAM_DISABLE ; BMODE_SIMPLE
635636
ld [rBMODE], a
636637
ld [rRAMG], a
637638
ret
@@ -674,7 +675,7 @@ LoadHallOfFameTeams:
674675
HallOfFame_Copy:
675676
ld a, RAMG_SRAM_ENABLE
676677
ld [rRAMG], a
677-
ld a, $1
678+
ld a, BMODE_ADVANCED
678679
ld [rBMODE], a
679680
xor a
680681
ld [rRAMB], a
@@ -687,15 +688,15 @@ HallOfFame_Copy:
687688
ClearSAV:
688689
ld a, RAMG_SRAM_ENABLE
689690
ld [rRAMG], a
690-
ld a, $1
691+
ld a, BMODE_ADVANCED
691692
ld [rBMODE], a
692693
xor a
693694
call PadSRAM_FF
694-
ld a, $1
695+
ld a, BANK("Save Data")
695696
call PadSRAM_FF
696-
ld a, $2
697+
ld a, BANK("Saved Boxes 1")
697698
call PadSRAM_FF
698-
ld a, $3
699+
ld a, BANK("Saved Boxes 2")
699700
call PadSRAM_FF
700701
xor a
701702
ld [rBMODE], a

0 commit comments

Comments
 (0)