named labels and commented WRAMVars in battle_tower.asm

This commit is contained in:
JimB16 2015-08-25 17:02:13 +02:00
parent 706f289c70
commit b9c1d1b61e
2 changed files with 68 additions and 43 deletions

View File

@ -14,11 +14,11 @@ Function_LoadOpponentTrainerAndPokemons: ; 1f8000
ld de, w3_d100 ld de, w3_d100
ld a, [hRandomAdd] ld a, [hRandomAdd]
ld b, a ld b, a
.asm_1f8022 .asm_1f8022 ; loop to find a random trainer
call Random call Random
ld a, [hRandomAdd] ld a, [hRandomAdd]
add b add b
ld b, a ld b, a ; b contains the nr of the trainer
IF DEF(CRYSTAL11) IF DEF(CRYSTAL11)
and $7f and $7f
cp $46 cp $46
@ -31,14 +31,14 @@ ENDC
ld a, BANK(sbe46) ld a, BANK(sbe46)
call GetSRAMBank call GetSRAMBank
ld c, $7 ld c, $7
ld hl, sbe48 ld hl, sBTTrainers
.asm_1f803a .asm_1f803a
ld a, [hli] ld a, [hli]
cp b cp b
jr z, .asm_1f8022 jr z, .asm_1f8022
dec c dec c
jr nz, .asm_1f803a jr nz, .asm_1f803a ; c <= 7 initialise all 7 trainers?
ld hl, sbe48 ld hl, sBTTrainers
ld a, [sbe46] ld a, [sbe46]
ld c, a ld c, a
ld a, b ld a, b
@ -77,10 +77,10 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
ld c, $3 ld c, $3
.loop .loop
push bc push bc
ld a, BANK(sbe51) ld a, BANK(sBTPkmnPrevTrainer1)
call GetSRAMBank call GetSRAMBank
.asm_1f8089 .FindARandomBattleTowerPkmn
; From Which LevelGroup are the Pkmn loaded ; From Which LevelGroup are the Pkmn loaded
; a = 1..10 ; a = 1..10
ld a, [$d800] ld a, [$d800]
@ -102,6 +102,8 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
; in register 'a' is the chosen Pkmn of the LevelGroup ; in register 'a' is the chosen Pkmn of the LevelGroup
; Check if Pkmn was already loaded before ; Check if Pkmn was already loaded before
; Check current and the 2 previous teams
; includes check if item is double at the current team
ld bc, $3b ld bc, $3b
call AddNTimes call AddNTimes
ld a, [hli] ld a, [hli]
@ -110,40 +112,40 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
ld c, a ld c, a
ld a, [w3_d100 + $0b] ld a, [w3_d100 + $0b]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [w3_d100 + $0c] ld a, [w3_d100 + $0c]
cp c cp c
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [w3_d100 + $46] ld a, [w3_d100 + $46]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [w3_d100 + $47] ld a, [w3_d100 + $47]
cp c cp c
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [w3_d100 + $81] ld a, [w3_d100 + $81]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [w3_d100 + $82] ld a, [w3_d100 + $82]
cp c cp c
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [sbe51] ld a, [sBTPkmnPrevTrainer1]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [sbe52] ld a, [sBTPkmnPrevTrainer2]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [sbe53] ld a, [sBTPkmnPrevTrainer3]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [sbe54] ld a, [sBTPkmnPrevPrevTrainer1]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [sbe55] ld a, [sBTPkmnPrevPrevTrainer2]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld a, [sbe56] ld a, [sBTPkmnPrevPrevTrainer3]
cp b cp b
jr z, .asm_1f8089 jr z, .FindARandomBattleTowerPkmn
ld bc, $3b ld bc, $3b
call CopyBytes call CopyBytes
@ -170,18 +172,18 @@ Function_LoadRandomBattleTowerPkmn: ; 1f8081
dec c dec c
jp nz, .loop jp nz, .loop
ld a, [sbe51] ld a, [sBTPkmnPrevTrainer1]
ld [sbe54], a ld [sBTPkmnPrevPrevTrainer1], a
ld a, [sbe52] ld a, [sBTPkmnPrevTrainer2]
ld [sbe55], a ld [sBTPkmnPrevPrevTrainer2], a
ld a, [sbe53] ld a, [sBTPkmnPrevTrainer3]
ld [sbe56], a ld [sBTPkmnPrevPrevTrainer3], a
ld a, [w3_d100 + $0b] ld a, [w3_d100 + $0b]
ld [sbe51], a ld [sBTPkmnPrevTrainer1], a
ld a, [w3_d100 + $46] ld a, [w3_d100 + $46]
ld [sbe52], a ld [sBTPkmnPrevTrainer2], a
ld a, [w3_d100 + $81] ld a, [w3_d100 + $81]
ld [sbe53], a ld [sBTPkmnPrevTrainer3], a
call CloseSRAM call CloseSRAM
ret ret
; 1f814e ; 1f814e

View File

@ -2600,8 +2600,24 @@ SECTION "WRAM 3", WRAMX, BANK [3]
ds $100 ds $100
w3_d100:: w3_d100:: ; BattleTower OpponentTrainer-Data (lengt = 0xe0)
ds $700 ds $6
BT_OTTrainerPkmn1:: ; w3_d10b
ds $1
BT_OTTrainerPkmn1Item::
ds $3b-1
BT_OTTrainerPkmn2:: ; w3_d146
ds $1
BT_OTTrainerPkmn2Item::
ds $3b-1
BT_OTTrainerPkmn3:: ; w3_d181
ds $1
BT_OTTrainerPkmn3Item::
ds $3b-1
ds $29
ds $620
w3_d800:: ds 1 w3_d800:: ds 1
@ -2772,17 +2788,24 @@ sCrystalData::
s1_be44:: ds 1 s1_be44:: ds 1
s1_be45:: ds 1 s1_be45:: ds 1
; data of the BattleTower must be in SRAM because you can save and leave between battles
sBattleTower:: ; be46 sBattleTower:: ; be46
sbe46:: ds 1 sbe46:: ds 1
sbe47:: ds 1 sbe47:: ds 1
sbe48:: ds 7 ; The 7 trainers of the BattleTower are saved here, so nobody appears more than once
sBTTrainers:: ; sbe48
ds 7
sbe4f:: ds 2 sbe4f:: ds 2
sbe51:: ds 1 ; Pkmn of previous trainer
sbe52:: ds 1 sBTPkmnOfTrainers::
sbe53:: ds 1 sBTPkmnPrevTrainer1::
sbe54:: ds 1 ds 1
sbe55:: ds 1 sBTPkmnPrevTrainer2:: ds 1
sbe56:: ds 1 sBTPkmnPrevTrainer3:: ds 1
; Pkmn of preprevious trainer
sBTPkmnPrevPrevTrainer1:: ds 1
sBTPkmnPrevPrevTrainer2:: ds 1
sBTPkmnPrevPrevTrainer3:: ds 1
SECTION "Boxes 1-7", SRAM, BANK [2] SECTION "Boxes 1-7", SRAM, BANK [2]