ref: 5b7fc7b0fabec8461c9931cc31a15bf0b28cfe86
parent: 0549e3413f61e1166441f1630f4d5f2be25e9974
author: PikalaxALT <PikalaxALT@gmail.com>
date: Tue Dec 8 11:06:13 EST 2015
More battle tower shenanigans
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -753,7 +753,7 @@
ld hl, Channel1Field0x22 - Channel1
add hl, bc
sub [hl]
- jr nc, .asm_e8420
+ jr nc, .greater_than
; ????
ld hl, Channel1Flags3 - Channel1
add hl, bc
@@ -779,9 +779,9 @@
ld a, [hl]
sub d
ld d, a
- jr .asm_e843e
+ jr .resume
-.asm_e8420
+.greater_than
; ????
ld hl, Channel1Flags3 - Channel1
add hl, bc
@@ -806,7 +806,7 @@
add hl, bc
sub [hl]
ld d, a
-.asm_e843e
+.resume
push bc
ld hl, wc297
ld b, 0; loop count
@@ -1419,19 +1419,19 @@
dw Music_ToggleSFX ;
dw MusicE0 ;
dw Music_Vibrato ; vibrato
- dw MusicE2 ;
+ dw MusicE2 ; unused
dw Music_ToggleNoise ; music noise sampling
dw Music_Panning ; force panning
dw Music_Volume ; volume
dw Music_Tone ; tune
- dw MusicE7 ;
- dw MusicE8 ;
- dw Music_GlobalTempo ; global tempo
+ dw MusicE7 ; unused
+ dw MusicE8 ; unused
+ dw Music_TempoRelative ; global tempo
dw Music_RestartChannel ; restart current channel from header
dw Music_NewSong ; new song
dw Music_SFXPriorityOn ; sfx priority on
dw Music_SFXPriorityOff ; sfx priority off
- dw MusicEE ;
+ dw MusicEE ; unused
dw Music_StereoPanning ; stereo panning
dw Music_SFXToggleNoise ; sfx noise sampling
dw MusicF1 ; nothing
@@ -1442,7 +1442,7 @@
dw MusicF6 ; nothing
dw MusicF7 ; nothing
dw MusicF8 ; nothing
- dw MusicF9 ;
+ dw MusicF9 ; unused
dw Music_SetCondition ;
dw Music_JumpIf ;
dw Music_JumpChannel ; jump
@@ -1847,7 +1847,7 @@
; e88f7
MusicE7: ; e88f7
-; shrug
+; unused
; params: 1
ld hl, Channel1Flags2 - Channel1
add hl, bc
@@ -1884,7 +1884,7 @@
; e891e
MusicE8: ; e891e
-; shrug
+; unused
; params: 1
ld hl, Channel1Flags2 - Channel1
add hl, bc
@@ -2106,7 +2106,7 @@
; e89e1
-Music_GlobalTempo: ; e89e1
+Music_TempoRelative: ; e89e1
; set global tempo to current channel tempo +- param
; params: 1 signed
call GetMusicByte
@@ -2304,7 +2304,7 @@
ld a, [hl]
; multiply NoteLength by delay units
ld l, 0; just multiply
- call MultiplySimple
+ call .Multiply
ld a, l ; % $100
; store Tempo in de
ld hl, Channel1Tempo - Channel1
@@ -2317,7 +2317,7 @@
add hl, bc
ld l, [hl]
; multiply Tempo by last result (NoteLength * delay % $100)
- call MultiplySimple
+ call .Multiply
; copy result to de
ld e, l
ld d, h
@@ -2333,7 +2333,7 @@
; e8ab8
-MultiplySimple: ; e8ab8
+.Multiply: ; e8ab8
; multiplies a and de
; adds the result to l
; stores the result in hl
@@ -2363,24 +2363,24 @@
cp CHAN5
jr nc, .sfxchannels
ld bc, Channel1
- call SetTempo
+ call Tempo
ld bc, Channel2
- call SetTempo
+ call Tempo
ld bc, Channel3
- call SetTempo
+ call Tempo
ld bc, Channel4
- call SetTempo
+ call Tempo
jr .end
.sfxchannels
ld bc, Channel5
- call SetTempo
+ call Tempo
ld bc, Channel6
- call SetTempo
+ call Tempo
ld bc, Channel7
- call SetTempo
+ call Tempo
ld bc, Channel8
- call SetTempo
+ call Tempo
.end
pop bc ; restore current channel
ret
@@ -2387,7 +2387,7 @@
; e8b03
-SetTempo: ; e8b03
+Tempo: ; e8b03
; input:
; de: note length
; update Tempo
--- a/constants/battle_tower_constants.asm
+++ b/constants/battle_tower_constants.asm
@@ -2,7 +2,7 @@
const BATTLETOWERACTION_00
const BATTLETOWERACTION_01
const BATTLETOWERACTION_02
- const BATTLETOWERACTION_03
+ const BATTLETOWERACTION_SAVE_AND_QUIT
const BATTLETOWERACTION_CHALLENGECANCELED
const BATTLETOWERACTION_05
const BATTLETOWERACTION_06 ; reset stuff in SRAM bank 5
@@ -13,7 +13,7 @@
const BATTLETOWERACTION_CHECKMOBILEEVENT
const BATTLETOWERACTION_0C ; more time stuff in SRAM bank 5
const BATTLETOWERACTION_0D ; more time stuff in SRAM bank 5
- const BATTLETOWERACTION_0E ; egg ticket
+ const BATTLETOWERACTION_EGGTICKET ; egg ticket
const BATTLETOWERACTION_0F ; check w3_d090
const BATTLETOWERACTION_10 ; jumptable based on 5:a800
const BATTLETOWERACTION_11 ; store 0 in 5:aa8d
@@ -26,11 +26,11 @@
const BATTLETOWERACTION_18 ; level check
const BATTLETOWERACTION_19 ; ubers check
const BATTLETOWERACTION_RESETDATA ; clear data
- const BATTLETOWERACTION_1B ; give reward
+ const BATTLETOWERACTION_GIVEREWARD ; give reward
const BATTLETOWERACTION_1C ; set won challenge
const BATTLETOWERACTION_1D ; set received reward
- const BATTLETOWERACTION_1E ; save options
- const BATTLETOWERACTION_CHOOSEREWARD
+ const BATTLETOWERACTION_CHOOSEREWARD ; save options
+ const BATTLETOWERACTION_SAVEOPTIONS
BATTLETOWER_NO_CHALLENGE EQU 0
BATTLETOWER_SAVED_AND_LEFT EQU 1
--- a/engine/specials.asm
+++ b/engine/specials.asm
@@ -175,7 +175,7 @@
add_special SpecialBeastsCheck
add_special SpecialMonCheck
add_special Special_SetPlayerPalette
- add_special Function170bd2
+ add_special ret_170bd2
add_special Mobile_SelectThreeMons
add_special Function1037eb
add_special Function10383c
--- a/macros/sound.asm
+++ b/macros/sound.asm
@@ -135,9 +135,9 @@
db \1 ; unknown
endm
- enum globaltempo_cmd
-globaltempo: macro
- db globaltempo_cmd
+ enum tempo_relative_cmd
+tempo_relative: macro
+ db tempo_relative_cmd
bigdw \1 ; value
endm
--- a/maps/BattleTower1F.asm
+++ b/maps/BattleTower1F.asm
@@ -97,7 +97,7 @@
writetext Text_RightThisWayToYourBattleRoom
waitbutton
closetext
- writebyte BATTLETOWERACTION_1E
+ writebyte BATTLETOWERACTION_CHOOSEREWARD
special BattleTowerAction
jump Script_WalkToBattleTowerElevator
@@ -124,7 +124,7 @@
Script_GivePlayerHisPrize: ; 0x9e47a
writebyte BATTLETOWERACTION_1C
special BattleTowerAction
- writebyte BATTLETOWERACTION_1B
+ writebyte BATTLETOWERACTION_GIVEREWARD
special BattleTowerAction
if_equal POTION, Script_YourPackIsStuffedFull
itemtotext $0, $1
--- a/maps/BattleTowerBattleRoom.asm
+++ b/maps/BattleTowerBattleRoom.asm
@@ -24,7 +24,7 @@
applymovement PLAYER, MovementData_BattleTowerBattleRoomPlayerWalksIn
; beat all 7 opponents in a row
Script_BattleRoomLoop: ; 0x9f425
- writebyte $2
+ writebyte BATTLETOWERBATTLEROOM_YOUNGSTER
special Function_LoadOpponentTrainerAndPokemonsWithOTSprite
appear BATTLETOWERBATTLEROOM_YOUNGSTER
warpsound
@@ -71,9 +71,9 @@
iffalse Script_DontSaveAndEndTheSession
writebyte BATTLETOWERACTION_SAVELEVELGROUP ; save level group
special BattleTowerAction
- writebyte BATTLETOWERACTION_CHOOSEREWARD ; choose reward
+ writebyte BATTLETOWERACTION_SAVEOPTIONS ; choose reward
special BattleTowerAction
- writebyte BATTLETOWERACTION_03 ; quicksave
+ writebyte BATTLETOWERACTION_SAVE_AND_QUIT ; quicksave
special BattleTowerAction
playsound SFX_SAVE
waitsfx
--- a/misc/battle_tower_5c.asm
+++ b/misc/battle_tower_5c.asm
@@ -1,11 +1,11 @@
Function1700b0: ; 1700b0
- call Bank5c_ClearJumptableRAM
+ call InitBattleTowerChallengeRAM
callba Function118121
ret
; 1700ba
Function1700ba: ; 1700ba
- call Bank5c_ClearJumptableRAM
+ call InitBattleTowerChallengeRAM
callba Function11811a
ret
; 1700c4
@@ -53,7 +53,7 @@
; 170114
Function170114: ; 170114
- call Bank5c_ClearJumptableRAM
+ call InitBattleTowerChallengeRAM
call Function170121
callba Function11805f
ret
@@ -64,7 +64,7 @@
call GetSRAMBank
ld hl, $a948
ld de, wMisc
- ld bc, $00f6
+ ld bc, $00f6 ; 246
call CopyBytes
call CloseSRAM
call Function170c8b
@@ -183,7 +183,7 @@
BattleTowerBattle: ; 170215
xor a
- ld [wcf63], a
+ ld [wBattleTowerBattleEnded], a
call _BattleTowerBattle
ret
; 17021d
@@ -192,10 +192,10 @@
ret
; 17021e
-Bank5c_ClearJumptableRAM: ; 17021e
+InitBattleTowerChallengeRAM: ; 17021e
xor a
- ld [wcf63], a
- ld [wcf64], a
+ ld [wBattleTowerBattleEnded], a
+ ld [wNrOfBeatenBattleTowerTrainers], a
ld [wcf65], a
ld [wcf66], a
ret
@@ -205,7 +205,7 @@
.loop
call .do_jumptable
call DelayFrame
- ld a, [wcf63]
+ ld a, [wBattleTowerBattleEnded]
cp $1
jr nz, .loop
ret
@@ -212,7 +212,7 @@
; 17023a
.do_jumptable: ; 17023a
- ld a, [wcf63]
+ ld a, [wBattleTowerBattleEnded]
ld e, a
ld d, 0
ld hl, .jumptable
@@ -259,10 +259,10 @@
ld a, BANK(sNrOfBeatenBattleTowerTrainers)
call GetSRAMBank
ld a, [sNrOfBeatenBattleTowerTrainers]
- ld [wNrOfBeatenBattleTowerTrainers], a ; wcf64
+ ld [wNrOfBeatenBattleTowerTrainers], a
call CloseSRAM
ld hl, StringBuffer3
- ld a, [wNrOfBeatenBattleTowerTrainers] ; wcf64
+ ld a, [wNrOfBeatenBattleTowerTrainers]
add "1"
ld [hli], a
ld a, "@"
@@ -274,7 +274,7 @@
pop af
ld [Options], a
ld a, $1
- ld [wcf63], a
+ ld [wBattleTowerBattleEnded], a
ret
@@ -661,7 +661,7 @@
; unreferenced special
call SpeechTextBox
call FadeToMenu
- call Bank5c_ClearJumptableRAM
+ call InitBattleTowerChallengeRAM
call .JumptableLoop
call CloseSubmenu
ret
@@ -758,20 +758,20 @@
ret
.pressed_up
- ld a, [wcf64]
+ ld a, [wNrOfBeatenBattleTowerTrainers]
and a
ret z
sub 15
- ld [wcf64], a
+ ld [wNrOfBeatenBattleTowerTrainers], a
call .PlaceTextItems
ret
.pressed_down
- ld a, [wcf64]
+ ld a, [wNrOfBeatenBattleTowerTrainers]
cp 60
ret z
add 15
- ld [wcf64], a
+ ld [wNrOfBeatenBattleTowerTrainers], a
call .PlaceTextItems
ret
@@ -834,7 +834,7 @@
ld a, $50
ld [wcd4e], a
ld hl, wMisc
- ld a, [wcf64]
+ ld a, [wNrOfBeatenBattleTowerTrainers]
ld c, a
xor a
ld b, a
@@ -916,7 +916,7 @@
; 17065d
.PlaceUpDownArrows: ; 17065d
- ld a, [wcf64]
+ ld a, [wNrOfBeatenBattleTowerTrainers]
and a
jr z, .nope
hlcoord 18, 5
@@ -924,7 +924,7 @@
ld [hl], a
.nope
- ld a, [wcf64]
+ ld a, [wNrOfBeatenBattleTowerTrainers]
cp 60
ret z
hlcoord 18, 16
@@ -984,11 +984,11 @@
dw Function170ae8 ; 0x18
dw Function170b16 ; 0x19
dw ResetBattleTowerTrainersSRAM ; 0x1a
- dw Function1706ee ; 0x1b
+ dw BattleTower_GiveReward ; 0x1b
dw Function17071b ; 0x1c
dw Function170729 ; 0x1d
dw BattleTower_RandomlyChooseReward ; 0x1e
- dw Function170737 ; 0x1f
+ dw BattleTower_SaveOptions ; 0x1f
; Reset the save memory for BattleTower-Trainers (Counter and all 7 TrainerBytes)
@@ -1008,7 +1008,7 @@
ret
-Function1706ee: ; 1706ee (5c:46ee) BattleTowerAction $1b
+BattleTower_GiveReward: ; 1706ee (5c:46ee) BattleTowerAction $1b
ld a, BANK(sBattleTowerReward)
call GetSRAMBank
@@ -1053,11 +1053,11 @@
call CloseSRAM
ret
-Function170737: ; 170737 (5c:4737) BattleTowerAction $1e
+BattleTower_SaveOptions: ; 170737 (5c:4737) BattleTowerAction $1f
callba SaveOptions
ret
-BattleTower_RandomlyChooseReward: ; 17073e (5c:473e) BattleTowerAction $1f
+BattleTower_RandomlyChooseReward: ; 17073e (5c:473e) BattleTowerAction $1e
; Generate a random stat boosting item.
.loop
call Random
@@ -1646,3 +1646,134 @@
call CloseSRAM
ld [ScriptVar], a
ret
+
+Function_LoadOpponentTrainerAndPokemonsWithOTSprite: ; 0x170b44
+ callba Function_LoadOpponentTrainerAndPokemons
+ ld a, [rSVBK]
+ push af
+ ld a, $3
+ ld [rSVBK], a
+ ld hl, BT_OTTrainerClass
+ ld a, [hl]
+ dec a
+ ld c, a
+ ld b, $0
+ pop af
+ ld [rSVBK], a
+ ld hl, .Sprites
+ add hl, bc
+ ld a, [hl]
+ ld [wBTTempOTSprite], a
+
+; Load sprite of the opponent trainer
+; because s/he is chosen randomly and appears out of nowhere
+ ld a, [ScriptVar]
+ dec a
+ sla a
+ ld e, a
+ sla a
+ sla a
+ sla a
+ ld c, a
+ ld b, 0
+ ld d, 0
+ ld hl, MapObjects
+ add hl, bc
+ inc hl
+ ld a, [wBTTempOTSprite]
+ ld [hl], a
+ ld hl, UsedSprites
+ add hl, de
+ ld [hli], a
+ ld [hUsedSpriteIndex], a
+ ld a, [hl]
+ ld [hUsedSpriteTile], a
+ callba GetUsedSprite
+ ret
+; 170b90
+
+.Sprites:
+ db SPRITE_FALKNER
+ db SPRITE_WHITNEY
+ db SPRITE_BUGSY
+ db SPRITE_MORTY
+ db SPRITE_PRYCE
+ db SPRITE_JASMINE
+ db SPRITE_CHUCK
+ db SPRITE_CLAIR
+ db SPRITE_SILVER
+ db SPRITE_OAK
+ db SPRITE_WILL
+ db SPRITE_CHRIS
+ db SPRITE_BRUNO
+ db SPRITE_KAREN
+ db SPRITE_KOGA
+ db SPRITE_LANCE
+ db SPRITE_BROCK
+ db SPRITE_MISTY
+ db SPRITE_SURGE
+ db SPRITE_SCIENTIST
+ db SPRITE_ERIKA
+ db SPRITE_YOUNGSTER
+ db SPRITE_YOUNGSTER
+ db SPRITE_YOUNGSTER
+ db SPRITE_LASS
+ db SPRITE_JANINE
+ db SPRITE_COOLTRAINER_M
+ db SPRITE_COOLTRAINER_F
+ db SPRITE_BUENA
+ db SPRITE_SUPER_NERD
+ db SPRITE_ROCKET
+ db SPRITE_GENTLEMAN
+ db SPRITE_BUENA
+ db SPRITE_TEACHER
+ db SPRITE_SABRINA
+ db SPRITE_BUG_CATCHER
+ db SPRITE_FISHER
+ db SPRITE_SUPER_NERD
+ db SPRITE_COOLTRAINER_F
+ db SPRITE_SAILOR
+ db SPRITE_SUPER_NERD
+ db SPRITE_BLUE
+ db SPRITE_ROCKER
+ db SPRITE_POKEFAN_M
+ db SPRITE_BIKER
+ db SPRITE_BLAINE
+ db SPRITE_PHARMACIST
+ db SPRITE_FISHER
+ db SPRITE_SUPER_NERD
+ db SPRITE_BLACK_BELT
+ db SPRITE_ROCKET
+ db SPRITE_YOUNGSTER
+ db SPRITE_LASS
+ db SPRITE_YOUNGSTER
+ db SPRITE_ROCKET_GIRL
+ db SPRITE_SAGE
+ db SPRITE_GRANNY
+ db SPRITE_ROCKER
+ db SPRITE_POKEFAN_M
+ db SPRITE_KIMONO_GIRL
+ db SPRITE_TWIN
+ db SPRITE_POKEFAN_F
+ db SPRITE_RED
+ db SPRITE_BLUE
+ db SPRITE_OFFICER
+ db SPRITE_ROCKET_GIRL
+
+ret_170bd2: ; 170bd2
+ ret
+; 170bd3
+
+SpecialCheckForBattleTowerRules: ; 170bd3
+ callba CheckForBattleTowerRules
+ jr c, .asm_170bde
+ xor a
+ jr .asm_170be0
+
+.asm_170bde
+ ld a, $1
+
+.asm_170be0
+ ld [ScriptVar], a
+ ret
+; 170be4
--- a/misc/mobile_46.asm
+++ b/misc/mobile_46.asm
@@ -1071,7 +1071,7 @@
set 0, [hl]
ld a, $6
ld [rSVBK], a
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
ld a, [hl]
sla a
@@ -1466,7 +1466,7 @@
ld de, wcc60
ld bc, $80
call CopyBytes
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
jp Function118b10
; 118a7a
@@ -1476,7 +1476,7 @@
ld de, wcc60
ld bc, $80
call CopyBytes
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
jp Function118b10
; 118a8f
@@ -1486,7 +1486,7 @@
ld de, wcc60
ld bc, $80
call CopyBytes
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
jp Function118b10
; 118aa4
@@ -1498,7 +1498,7 @@
call CopyBytes
ld a, $5
ld [rSVBK], a
- ld de, LYOverrides
+ ld de, w3_d100
ld bc, $e00
jr Function118b10
; 118abc
@@ -1508,7 +1508,7 @@
ld de, wcc60
ld bc, $80
call CopyBytes
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
jr Function118b10
; 118ad0 (46:4ad0)
@@ -1518,7 +1518,7 @@
ld de, wcc60
ld bc, $80
call CopyBytes
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
jr Function118b10
@@ -1663,7 +1663,8 @@
Function118d35: ; 118d35
- ld hl, LYOverridesBackup
+; unreferenced
+ ld hl, $d200
ld a, [wcd38]
and a
jr nz, .asm_118d6e
@@ -1739,7 +1740,7 @@
ld [wcd3b], a
.asm_118db7
- ld hl, $d800
+ ld hl, w3_d800
ld a, $8
ld [hli], a
ld a, $c6
@@ -1760,7 +1761,7 @@
call Function119ec2
ld a, $40
ld [wcd89], a
- ld hl, $d800
+ ld hl, w3_d800
ld de, $de00
ld bc, $0200
ld a, $2c
@@ -1894,7 +1895,7 @@
ld de, wcc60
call Function1191ad
ret c
- ld de, $d800
+ ld de, w3_d800
ld bc, $0800
jp Function118b10
; 118eb0
@@ -2105,7 +2106,7 @@
ld a, $40
ld [wcd89], a
ld hl, wc314 + 48 + 2
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
ld a, $2c
jp Function119e2b
@@ -2119,9 +2120,9 @@
ld e, a
ld a, [wcd50]
ld d, a
- ld a, [UnknBGPals]
+ ld a, [w3_d000]
ld c, a
- ld a, [wd001]
+ ld a, [w3_d000 + 1]
ld b, a
call Function119192
ret c
@@ -2131,9 +2132,9 @@
ld a, $6
ld [rSVBK], a
ld hl, wd002
- ld a, [UnknBGPals]
+ ld a, [w3_d000]
ld c, a
- ld a, [wd001]
+ ld a, [w3_d000 + 1]
ld b, a
call Function119192
ret c
@@ -2178,7 +2179,7 @@
ld de, wcc60
call Function1191ad
ret c
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
jp Function118b10
; 1190ec
@@ -2198,9 +2199,9 @@
call CloseSRAM
ld a, $6
call GetSRAMBank
- ld a, [UnknBGPals]
+ ld a, [w3_d000]
ld c, a
- ld a, [wd001]
+ ld a, [w3_d000 + 1]
ld b, a
ld hl, wd002
ld de, $a000
@@ -2211,9 +2212,9 @@
jr z, .asm_11913e
ld a, $6
ld [rSVBK], a
- ld a, [UnknBGPals]
+ ld a, [w3_d000]
ld c, a
- ld a, [wd001]
+ ld a, [w3_d000 + 1]
ld b, a
ld hl, wd002
call Function119192
@@ -2330,7 +2331,7 @@
; 1191d3
Function1191d3: ; 1191d3
- ld hl, wd102
+ ld hl, w3_d100 + 2
ld a, l
ld [wcd53], a
ld a, h
@@ -2678,7 +2679,7 @@
ld a, $8
ld [wcd3c], a
call Function119ed8
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
jp Function118b10
; 119413
@@ -2686,9 +2687,9 @@
Function119413: ; 119413
ld a, $6
call GetSRAMBank
- ld a, [UnknBGPals]
+ ld a, [w3_d000]
ld c, a
- ld a, [wd001]
+ ld a, [w3_d000 + 1]
ld b, a
rept 2
dec bc
@@ -2707,7 +2708,7 @@
ld [rSVBK], a
ld a, [wd000]
ld c, a
- ld a, [wd001]
+ ld a, [w3_d000 + 1]
ld b, a
ld hl, wd002
call Function119192
@@ -3043,7 +3044,7 @@
ld [wcd3c], a
call Function119ed8
call Function118b24
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
ld a, $2a
jp Function119e2b
@@ -3338,7 +3339,7 @@
xor a
ld [de], a
call Function118b24
- ld de, UnknBGPals
+ ld de, w3_d000
ld bc, $1000
ld a, $2a
jp Function119e2b
@@ -3459,7 +3460,7 @@
ret nz
ld hl, $c608 + 2
call Function119940
- ld hl, $d800
+ ld hl, w3_d800
ld a, $c608 % $100
ld [hli], a
ld a, $c608 / $100
@@ -3480,7 +3481,7 @@
call Function119ec2
ld a, $40
ld [wcd89], a
- ld hl, $d800
+ ld hl, w3_d800
ld de, $de00
ld bc, $0200
ld a, $2c
@@ -3536,15 +3537,15 @@
ld [wcf64], a
xor a
ld [wcf65], a
- ld [StringBuffer2 + 10], a
- ld de, UnknBGPals
+ ld [w3_d090], a
+ ld de, w3_d000
ld a, $20
jp Function119e2b
; 119987
Function119987: ; 119987
- ld hl, wd001
- ld a, [UnknBGPals]
+ ld hl, w3_d000 + 1
+ ld a, [w3_d000]
or [hl]
jr z, .asm_1199a0
ld a, [wcf64]
@@ -3556,7 +3557,7 @@
jp Function119e2b
.asm_1199a0
- ld a, [StringBuffer2 + 10]
+ ld a, [w3_d090]
and a
jr z, .asm_1199ae
ld a, $16
@@ -3590,7 +3591,7 @@
ld l, a
ld a, [wcf65]
ld h, a
- ld de, LYOverrides
+ ld de, w3_d100
ld bc, $0700
ld a, $28
jp Function119e2b
@@ -3694,27 +3695,27 @@
jp Function119b45
.asm_119aaf
- ld a, [StringBuffer2 + 10]
+ ld a, [w3_d090]
and a
jr nz, .asm_119aa7
- ld a, [wd000 + $895]
+ ld a, [w3_d895]
sub $30
- ld [StringBuffer2 + 10], a
+ ld [w3_d090], a
ld a, [wcf64]
- ld [StringBuffer2 + 11], a
+ ld [w3_d090 + 1], a
ld a, [wcf65]
- ld [StringBuffer2 + 12], a
+ ld [w3_d090 + 2], a
Function119ac9:
- ld a, [UnknBGPals]
+ ld a, [w3_d000]
ld l, a
- ld a, [wd001]
+ ld a, [w3_d000 + 1]
ld h, a
dec hl
ld a, l
- ld [UnknBGPals], a
+ ld [w3_d000], a
ld a, h
- ld [wd001], a
+ ld [w3_d000 + 1], a
ld a, [wcf64]
ld l, a
ld a, [wcf65]
@@ -3738,7 +3739,7 @@
ld a, $8
ld [wcd3c], a
call Function119ed8
- ld a, [StringBuffer2 + 10]
+ ld a, [w3_d090]
cp $1
jr z, .asm_119b23
ld a, $19
@@ -3748,19 +3749,19 @@
.asm_119b23
ld a, $10
ld [wcd89], a
- ld a, [StringBuffer2 + 11]
+ ld a, [w3_d090 + 1]
ld l, a
- ld a, [StringBuffer2 + 12]
+ ld a, [w3_d090 + 2]
ld h, a
- ld de, LYOverrides
+ ld de, w3_d100
ld bc, $0700
ld a, $24
jp Function119e2b
Function119b3b:
- ld a, [StringBuffer2 + 11]
+ ld a, [w3_d090 + 1]
ld l, a
- ld a, [StringBuffer2 + 12]
+ ld a, [w3_d090 + 2]
ld h, a
jr asm_119b4d
@@ -3776,7 +3777,7 @@
; 119b52
Function119b52: ; 119b52
- ld a, [StringBuffer2 + 10]
+ ld a, [w3_d090]
cp $1
jr nz, .asm_119b66
ld a, $5
@@ -3791,19 +3792,19 @@
; 119b6b
Function119b6b: ; 119b6b
- ld a, [StringBuffer2 + 10]
+ ld a, [w3_d090]
cp $1
jr z, .asm_119b75
jp Function119e2e
.asm_119b75
- ld a, [LYOverrides]
+ ld a, [w3_d100]
ld b, a
- ld a, [wd101]
+ ld a, [w3_d100 + 1]
or b
jr z, .asm_119be3
- ld hl, $d800
- ld de, wd102
+ ld hl, w3_d800
+ ld de, w3_d100 + 2
.asm_119b85
ld a, [de]
inc de
@@ -3887,7 +3888,7 @@
ld [$a800], a
call CloseSRAM
xor a
- ld [StringBuffer2 + 10], a
+ ld [w3_d090], a
ret
.asm_119bfa
@@ -3896,10 +3897,10 @@
cp $d
jr nz, .asm_119b93
ld a, l
- cp (wd000 + $800 + $69) % $100
+ cp (w3_d869) % $100
jr nz, .asm_119be3
ld a, h
- cp (wd000 + $800 + $69) / $100
+ cp (w3_d869) / $100
jr nz, .asm_119be3
ld a, $5
call GetSRAMBank
@@ -3907,7 +3908,7 @@
ld [$b090], a
ld a, [wcf65]
ld [$b091], a
- ld hl, $d800
+ ld hl, w3_d800
ld de, $b023
ld bc, $0069
call CopyBytes
@@ -3914,7 +3915,7 @@
ld a, $3
ld [$a800], a
call CloseSRAM
- ld hl, $d800
+ ld hl, w3_d800
ld de, $c608
ld bc, $0069
call CopyBytes
@@ -3953,7 +3954,7 @@
ld [$a800], a
call CloseSRAM
xor a
- ld [StringBuffer2 + 10], a
+ ld [w3_d090], a
scf
ret
@@ -4212,7 +4213,7 @@
Function119e4f: ; 119e4f
push bc
- ld hl, LYOverrides
+ ld hl, w3_d100
ld a, [hli]
ld c, a
ld a, [hli]
@@ -4531,7 +4532,7 @@
ld a, $3
ld [rSVBK], a
ld hl, $c608
- ld de, $d800
+ ld de, w3_d800
ld bc, $00f6
call CopyBytes
ld a, $1
@@ -4541,7 +4542,7 @@
call Function11a9ce
ld a, $3
ld [rSVBK], a
- ld hl, $d800
+ ld hl, w3_d800
ld de, $c608
ld bc, $00f6
call CopyBytes
@@ -6978,16 +6979,69 @@
; 11b350
Unknown_11b350:
- db $1a, $5e, $1a, $66, $1a, $6e, $1a, $76, $1a, $7e, $1a, $86, $1a, $8e
- db $22, $5e, $22, $66, $22, $6e, $22, $76, $22, $7e, $22, $86, $22, $8e
- db $ff
+ dbpixel 3, 11, 2, 6
+ dbpixel 3, 12, 2, 6
+ dbpixel 3, 13, 2, 6
+ dbpixel 3, 14, 2, 6
+ dbpixel 3, 15, 2, 6
+ dbpixel 3, 16, 2, 6
+ dbpixel 3, 17, 2, 6
+ dbpixel 4, 11, 2, 6
+ dbpixel 4, 12, 2, 6
+ dbpixel 4, 13, 2, 6
+ dbpixel 4, 14, 2, 6
+ dbpixel 4, 15, 2, 6
+ dbpixel 4, 16, 2, 6
+ dbpixel 4, 17, 2, 6
+ db -1
Unknown_11b36d:
- db $30, $31, $31, $31, $31, $31, $32, $40, $41, $41, $41, $41, $41, $42
+ db $30
+ db $31
+ db $31
+ db $31
+ db $31
+ db $31
+ db $32
+ db $40
+ db $41
+ db $41
+ db $41
+ db $41
+ db $41
+ db $42
+
Unknown_11b37b:
- db $30, $31, $31, $39, $39, $39, $39, $40, $41, $41, $39, $39, $39, $39
+ db $30
+ db $31
+ db $31
+ db $39
+ db $39
+ db $39
+ db $39
+ db $40
+ db $41
+ db $41
+ db $39
+ db $39
+ db $39
+ db $39
+
Unknown_11b389:
- db $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39, $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
+ db $39
Function11b397: ; 11b397
ld de, Sprites
@@ -6999,12 +7053,14 @@
and $7
swap a
add [hl]
- inc hl
+ inc hl ; 1
ld [de], a
inc de
- ld a, [hli]
+
+ ld a, [hli] ; 2
ld [de], a
inc de
+
ld a, [bc]
inc bc
ld [de], a
@@ -7355,7 +7411,7 @@
Function11b585: ; 11b585
ld a, $3
ld [rSVBK], a
- ld hl, $d800
+ ld hl, w3_d800
ld de, $c608
ld bc, $008f
call CopyBytes
@@ -7482,7 +7538,7 @@
push af
ld a, $3
ld [rSVBK], a
- ld a, [StringBuffer2 + 10]
+ ld a, [w3_d090]
ld b, a
pop af
ld [rSVBK], a
@@ -7506,7 +7562,7 @@
ld a, $3
ld [rSVBK], a
ld a, $2
- ld [StringBuffer2 + 10], a
+ ld [w3_d090], a
pop af
ld [rSVBK], a
--- a/misc/mobile_5c.asm
+++ b/misc/mobile_5c.asm
@@ -34,6 +34,7 @@
ld bc, $008f
call CopyBytes
ret
+
; 17005a
Function17005a: ; 17005a
@@ -71,85 +72,11 @@
ld [wc74e], a
call CloseSRAM
ret
+
; 1700b0
INCLUDE "misc/battle_tower_5c.asm"
-Function_LoadOpponentTrainerAndPokemonsWithOTSprite: ; 0x170b44
- callba Function_LoadOpponentTrainerAndPokemons
- ld a, [rSVBK]
- push af
- ld a, $3
- ld [rSVBK], a
- ld hl, wd10a
- ld a, [hl]
- dec a
- ld c, a
- ld b, $0
- pop af
- ld [rSVBK], a
- ld hl, Unknown_170b90
- add hl, bc
- ld a, [hl]
- ld [wcd49], a
-
-; Load sprite of the opponent trainer
-; because s/he is chosen randomly and appears out of nowhere
- ld a, [ScriptVar]
- dec a
- sla a
- ld e, a
- sla a
- sla a
- sla a
- ld c, a
- ld b, $0
- ld d, $0
- ld hl, MapObjects
- add hl, bc
- inc hl
- ld a, [wcd49]
- ld [hl], a
- ld hl, UsedSprites
- add hl, de
- ld [hli], a
- ld [hUsedSpriteIndex], a
- ld a, [hl]
- ld [hUsedSpriteTile], a
- callba GetUsedSprite
- ret
-; 170b90
-
-Unknown_170b90:
- db $12, $13, $14, $15, $18, $17
- db $16, $19, $04, $05, $11, $01
- db $1c, $1b, $21, $1e, $1a, $1d
- db $1f, $3c, $20, $27, $27, $27
- db $28, $0a, $23, $24, $2a, $2b
- db $35, $40, $2a, $29, $22, $25
- db $3a, $2b, $24, $49, $2b, $07
- db $2c, $2d, $4a, $0d, $4b, $3a
- db $2b, $41, $35, $27, $28, $27
- db $36, $3e, $30, $2c, $2d, $3d
- db $26, $2e, $06, $07, $43, $36
-
-Function170bd2: ; 170bd2
- ret
-; 170bd3
-
-SpecialCheckForBattleTowerRules: ; 170bd3
- callba CheckForBattleTowerRules
- jr c, .asm_170bde
- xor a
- jr .asm_170be0
-
-.asm_170bde
- ld a, $1
-
-.asm_170be0
- ld [ScriptVar], a
- ret
-; 170be4
Function170be4: ; 170be4
ld a, $5
call GetSRAMBank
@@ -159,6 +86,7 @@
call ByteFill
call CloseSRAM
ret
+
; 170bf7
Clears5_a89a: ; 170bf7
@@ -170,6 +98,7 @@
ld [hl], a
call CloseSRAM
ret
+
; 170c06
Function170c06: ; 170c06
@@ -275,6 +204,7 @@
ld [hl], a
call CloseSRAM
ret
+
; 170c8b
Function170c8b: ; 170c8b
@@ -287,6 +217,7 @@
dec b
jr nz, .asm_170c90
ret
+
; 170c98
CheckBTMonMovesForErrors: ; 170c98
@@ -330,6 +261,7 @@
dec c
jr nz, .loop
ret
+
; 170cc6
Function170cc6: ; 170cc6
@@ -338,7 +270,7 @@
ld a, $6
ld [rSVBK], a
ld hl, LZ_170d16
- ld de, wd000
+ ld de, wBackupTilemap
call Decompress
ld a, $1
ld [rVBK], a
@@ -358,6 +290,7 @@
pop af
ld [rSVBK], a
ret
+
; 170d02
Function170d02: ; 170d02
@@ -370,6 +303,7 @@
xor a
ld [rVBK], a
ret
+
; 170d16
LZ_170d16:
@@ -417,15 +351,16 @@
ret
Function171a11: ; 171a11 (5c:5a11)
+.loop
call JoyTextDelay
ld a, [wcd49]
bit 7, a
- jr nz, .asm_171a2c
+ jr nz, .done
call Function171a36
callba PlaySpriteAnimations
callba ReloadMapPart
- jr Function171a11
-.asm_171a2c
+ jr .loop
+.done
callba ClearSpriteAnims
call ClearSprites
ret
@@ -465,6 +400,7 @@
bit 0, a
ret nz
jp Function171c66
+
.asm_171a6a
ld a, $0
call Function3e32
@@ -492,6 +428,7 @@
ld de, String_171aa7
call PlaceString
jp Function171c66
+
; 171aa7 (5c:5aa7)
String_171aa7: ; 171aa7
@@ -626,6 +563,7 @@
ld a, $80
ld [wcd49], a
ret
+
asm_171ba5: ; 171ba5 (5c:5ba5)
ld a, [wcd4a]
and a
@@ -633,6 +571,7 @@
dec a
ld [wcd4a], a
ret
+
asm_171baf: ; 171baf (5c:5baf)
ld a, [wcd4b]
ld c, a
@@ -729,6 +668,7 @@
ld hl, wcd49
inc [hl]
ret
+
; 171c6b (5c:5c6b)
MenuDataHeader_171c6b: ; 171c6b
@@ -807,6 +747,7 @@
hlcoord 3, 16
ld de, String_172e3f
jp PlaceString
+
.asm_171d16
ld hl, Tilemap_1725f9
decoord 0, 7
@@ -841,6 +782,7 @@
ld de, String_172e58
call PlaceString
ret
+
; 171d71 (5c:5d71)
Palette_171d71:
@@ -931,6 +873,7 @@
ld bc, $168
call CopyBytes
ret
+
; 172eb9 (5c:6eb9)
Function172eb9:
@@ -950,6 +893,7 @@
pop af
ld [rSVBK], a
ret
+
; 172edf (5c:6edf)
Palette_172edf:
--- a/wram.asm
+++ b/wram.asm
@@ -213,7 +213,7 @@
wCurTrackIntensity:: ds 1
wCurTrackFrequency:: dw
wc296:: ds 1 ; used only in an unused function
-wc297:: ds 1
+wc297:: ds 1 ; used in MusicE0 and LoadNote
CurMusicByte:: ; c298
ds 1
@@ -306,7 +306,7 @@
CurSFX:: ; c2bf
; id of sfx currently playing
ds 1
-wc2c0::
+
wMapMusic:: ; c2c0
ds 1
@@ -1257,6 +1257,7 @@
BGMapPalBuffer:: ; cd48
ds 1 ; 40
+wBTTempOTSprite::
wcd49:: ds 1
wcd4a:: ds 1
wcd4b:: ds 1
@@ -1365,6 +1366,7 @@
wNamedObjectTypeBuffer:: ds 1
ds 1
wJumptableIndex::
+wBattleTowerBattleEnded::
wcf63:: ds 1
wNrOfBeatenBattleTowerTrainers::
wMomBankDigitCursorPosition::
@@ -3039,7 +3041,9 @@
ds -$22
wBTChoiceOfLvlGroup::
-w3_d800:: ds $400
+w3_d800:: ds $69
+w3_d869:: ds $2c
+w3_d895:: ds $36b
w3_dc00:: ds $168
w3_dd68:: ds $294
w3_dffc:: ds 4