You've already forked pokecrystal-board
mirror of
https://gitlab.com/xCrystal/pokecrystal-board.git
synced 2025-12-11 05:02:16 -08:00
Use labels instead of constants for HRAM
Use explicit ldh instruction to access HRAM locations, don't rely on optimizing ld
This commit is contained in:
@@ -10,10 +10,10 @@ Function1700ba:
|
||||
ret
|
||||
|
||||
Function1700c4:
|
||||
ld a, [rSVBK]
|
||||
ldh a, [rSVBK]
|
||||
push af
|
||||
ld a, $3
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
|
||||
call Function17042c
|
||||
|
||||
@@ -47,7 +47,7 @@ Function1700c4:
|
||||
call CopyBytes
|
||||
call CloseSRAM
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
ret
|
||||
|
||||
Function170114:
|
||||
@@ -556,10 +556,10 @@ INCLUDE "data/battle_tower/unknown_levels.asm"
|
||||
|
||||
CopyBTTrainer_FromBT_OT_TowBT_OTTemp:
|
||||
; copy the BattleTower-Trainer data that lies at 'wBT_OTTrainer' to 'wBT_OTTemp'
|
||||
ld a, [rSVBK]
|
||||
ldh a, [rSVBK]
|
||||
push af
|
||||
ld a, BANK(wBT_OTTrainer)
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
|
||||
ld hl, wBT_OTTrainer
|
||||
ld de, wBT_OTTemp
|
||||
@@ -567,7 +567,7 @@ CopyBTTrainer_FromBT_OT_TowBT_OTTemp:
|
||||
call CopyBytes
|
||||
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
|
||||
ld a, BANK(sBattleTowerChallengeState)
|
||||
call GetSRAMBank
|
||||
@@ -982,7 +982,7 @@ BattleTower_RandomlyChooseReward: ; BattleTowerAction $1e
|
||||
; Generate a random stat boosting item.
|
||||
.loop
|
||||
call Random
|
||||
ld a, [hRandomAdd]
|
||||
ldh a, [hRandomAdd]
|
||||
and $7
|
||||
cp 6
|
||||
jr c, .okay
|
||||
@@ -1153,28 +1153,28 @@ Function17081d: ; BattleTowerAction $17
|
||||
SaveBattleTowerLevelGroup: ; BattleTowerAction $07
|
||||
ld a, BANK(sBTChoiceOfLevelGroup)
|
||||
call GetSRAMBank
|
||||
ld a, [rSVBK]
|
||||
ldh a, [rSVBK]
|
||||
push af
|
||||
ld a, $3
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
ld a, [wBTChoiceOfLvlGroup]
|
||||
ld [sBTChoiceOfLevelGroup], a
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
call CloseSRAM
|
||||
ret
|
||||
|
||||
LoadBattleTowerLevelGroup: ; BattleTowerAction $08 ; Load level group choice
|
||||
ld a, BANK(sBTChoiceOfLevelGroup)
|
||||
call GetSRAMBank
|
||||
ld a, [rSVBK]
|
||||
ldh a, [rSVBK]
|
||||
push af
|
||||
ld a, $3
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
ld a, [sBTChoiceOfLevelGroup]
|
||||
ld [wBTChoiceOfLvlGroup], a
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
call CloseSRAM
|
||||
ret
|
||||
|
||||
@@ -1336,14 +1336,14 @@ String_MysteryJP:
|
||||
db "なぞナゾ@@" ; MYSTERY
|
||||
|
||||
Function1709aa: ; BattleTowerAction $0f
|
||||
ld a, [rSVBK]
|
||||
ldh a, [rSVBK]
|
||||
push af
|
||||
ld a, BANK(w3_d090)
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
ld a, [w3_d090]
|
||||
ld [wScriptVar], a
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
ret
|
||||
|
||||
Function1709bb: ; BattleTowerAction $10
|
||||
@@ -1557,17 +1557,17 @@ BattleTowerAction_UbersCheck: ; BattleTowerAction $19
|
||||
|
||||
LoadOpponentTrainerAndPokemonWithOTSprite:
|
||||
farcall Function_LoadOpponentTrainerAndPokemons
|
||||
ld a, [rSVBK]
|
||||
ldh a, [rSVBK]
|
||||
push af
|
||||
ld a, $3
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
ld hl, wBT_OTTrainerClass
|
||||
ld a, [hl]
|
||||
dec a
|
||||
ld c, a
|
||||
ld b, $0
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
ld hl, BTTrainerClassSprites
|
||||
add hl, bc
|
||||
ld a, [hl]
|
||||
@@ -1593,9 +1593,9 @@ LoadOpponentTrainerAndPokemonWithOTSprite:
|
||||
ld hl, wUsedSprites
|
||||
add hl, de
|
||||
ld [hli], a
|
||||
ld [hUsedSpriteIndex], a
|
||||
ldh [hUsedSpriteIndex], a
|
||||
ld a, [hl]
|
||||
ld [hUsedSpriteTile], a
|
||||
ldh [hUsedSpriteTile], a
|
||||
farcall GetUsedSprite
|
||||
ret
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Function_LoadOpponentTrainerAndPokemons:
|
||||
ld a, [rSVBK]
|
||||
ldh a, [rSVBK]
|
||||
push af
|
||||
ld a, BANK(wBT_OTTrainer)
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
|
||||
; Fill wBT_OTTrainer with zeros
|
||||
xor a
|
||||
@@ -19,11 +19,11 @@ Function_LoadOpponentTrainerAndPokemons:
|
||||
; Set wBT_OTTrainer as start address to write the following data to
|
||||
ld de, wBT_OTTrainer
|
||||
|
||||
ld a, [hRandomAdd]
|
||||
ldh a, [hRandomAdd]
|
||||
ld b, a
|
||||
.resample ; loop to find a random trainer
|
||||
call Random
|
||||
ld a, [hRandomAdd]
|
||||
ldh a, [hRandomAdd]
|
||||
add b
|
||||
ld b, a ; b contains the nr of the trainer
|
||||
if DEF(_CRYSTAL11)
|
||||
@@ -87,7 +87,7 @@ endc
|
||||
jr nz, .copy_bt_trainer_data_loop
|
||||
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
|
||||
ret
|
||||
|
||||
@@ -107,11 +107,11 @@ Function_LoadRandomBattleTowerMon:
|
||||
ld bc, BattleTowerMons2 - BattleTowerMons1 ; size of one level group
|
||||
call AddNTimes
|
||||
|
||||
ld a, [hRandomAdd]
|
||||
ldh a, [hRandomAdd]
|
||||
ld b, a
|
||||
.resample
|
||||
call Random
|
||||
ld a, [hRandomAdd]
|
||||
ldh a, [hRandomAdd]
|
||||
add b
|
||||
ld b, a
|
||||
maskbits BATTLETOWER_NUM_UNIQUE_MON
|
||||
|
||||
@@ -3,10 +3,10 @@ BattleTowerText::
|
||||
; 1: Intro text
|
||||
; 2: Player lost
|
||||
; 3: Player won
|
||||
ld a, [rSVBK]
|
||||
ldh a, [rSVBK]
|
||||
push af
|
||||
ld a, BANK(wBT_OTTrainerClass)
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
if DEF(_CRYSTAL11)
|
||||
ld hl, wBT_OTTrainerClass
|
||||
else
|
||||
@@ -28,7 +28,7 @@ endc
|
||||
and a
|
||||
jr nz, .female
|
||||
; generate a random number between 0 and 24
|
||||
ld a, [hRandomAdd]
|
||||
ldh a, [hRandomAdd]
|
||||
and $1f
|
||||
cp 25
|
||||
jr c, .okay0
|
||||
@@ -40,7 +40,7 @@ endc
|
||||
|
||||
.female
|
||||
; generate a random number between 0 and 14
|
||||
ld a, [hRandomAdd]
|
||||
ldh a, [hRandomAdd]
|
||||
and $f
|
||||
cp 15
|
||||
jr c, .okay1
|
||||
@@ -80,7 +80,7 @@ endc
|
||||
ld h, a
|
||||
bccoord 1, 14
|
||||
pop af
|
||||
ld [rSVBK], a
|
||||
ldh [rSVBK], a
|
||||
call PlaceHLTextAtBC
|
||||
ret
|
||||
|
||||
|
||||
Reference in New Issue
Block a user