ref: dc76bf804f86f884933e9d5a8820e3122b2771ae
parent: ebf3bfb6b289bf684941a86cafe1286d8ce212fe
author: Remy Oukaour <[email protected]>
date: Fri Dec 15 08:21:47 EST 2017
Move all misc/ and unknown/ files to meaningful directories
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,6 @@
data/pokemon/egg_moves.o \
data/pokemon/evos_attacks.o \
data/pokemon/dex_entries.o \
-misc/crystal_misc.o \
text/common_text.o \
gfx/pics.o
@@ -202,8 +201,8 @@
gfx/unknown/ascii_font.2bpp: tools/gfx += --trim-whitespace
gfx/unknown/bold_font.1bpp: tools/gfx += --trim-whitespace
-gfx/unknown/egg_animated.2bpp: tools/gfx += --trim-whitespace
-gfx/unknown/egg_animated_nonmatching.2bpp: tools/gfx += --remove-duplicates --remove-xflip
+gfx/unknown/electro_ball.2bpp: tools/gfx += --trim-whitespace
+gfx/unknown/electro_ball_nonmatching.2bpp: tools/gfx += --remove-duplicates --remove-xflip
gfx/unknown/mobile_splash.2bpp: tools/gfx += --remove-duplicates --remove-xflip
gfx/unknown/pichu_animated.2bpp: tools/gfx += --trim-whitespace
gfx/unknown/unknown_egg.2bpp: rgbgfx += -h
--- a/constants/battle_tower_constants.asm
+++ b/constants/battle_tower_constants.asm
@@ -1,4 +1,4 @@
-; BattleTowerAction arguments (see misc/battle_tower_5c.asm)
+; BattleTowerAction arguments (see mobile/battle_tower_5c.asm)
const_def
const BATTLETOWERACTION_CHECK_EXPLANATION_READ
const BATTLETOWERACTION_SET_EXPLANATION_READ
--- a/data/battle_tower.asm
+++ b/data/battle_tower.asm
@@ -1,7 +1,7 @@
BattleTowerTrainers: ; 1f814e
; The trainer class is not used in Crystal 1.0 due to a bug.
; Instead, the sixth character in the trainer's name is used.
-; See misc/battle_tower_47.asm
+; See mobile/battle_tower_47.asm
db "HANSON@@@@", FISHER
db "SAWYER@@@@", POKEMANIAC
db "MASUDA@@@@", GUITARIST
--- a/gfx/font.asm
+++ b/gfx/font.asm
@@ -55,7 +55,7 @@
; f8f24
OverworldPhoneIconGFX: ; f8f24
-INCBIN "gfx/mobile/overworld_phone_icon.2bpp"
+INCBIN "gfx/font/overworld_phone_icon.2bpp"
; f8f34
GFX_f8f34: ; unused bold letters + unown chars
binary files /dev/null b/gfx/font/overworld_phone_icon.png differ
binary files a/gfx/mobile/overworld_phone_icon.png /dev/null differ
binary files a/gfx/unknown/egg_animated.2bpp.lz.3eaf004f /dev/null differ
binary files a/gfx/unknown/egg_animated.png /dev/null differ
binary files a/gfx/unknown/egg_animated_nonmatching.png /dev/null differ
binary files /dev/null b/gfx/unknown/electro_ball.2bpp.lz.3eaf004f differ
binary files /dev/null b/gfx/unknown/electro_ball.png differ
binary files /dev/null b/gfx/unknown/electro_ball_nonmatching.png differ
--- a/macros/charmap.asm
+++ b/macros/charmap.asm
@@ -32,7 +32,7 @@
charmap "<ROCKET>", $5e ; "ROCKET"
charmap "<DEXEND>", $5f
-; Actual characters (from gfx/misc/font_extra.png)
+; Actual characters (from gfx/font/font_extra.png)
charmap "<BOLD_A>", $60 ; unused
charmap "<BOLD_B>", $61 ; unused
@@ -68,7 +68,7 @@
charmap "┘", $7e
charmap " ", $7f
-; Actual characters (from gfx/misc/font_battle_extra.png)
+; Actual characters (from gfx/font/font_battle_extra.png)
charmap "<LV>", $6e
@@ -86,13 +86,13 @@
charmap "<BLACK>", $60 ; from gfx/mobile/phone_tiles.2bpp
charmap "▲", $61 ; gfx/font/up_arrow.png
- charmap "<PHONE>", $62 ; gfx/mobile/overworld_phone_icon.2bpp
+ charmap "<PHONE>", $62 ; gfx/font/overworld_phone_icon.2bpp
charmap "_", $62 ; from gfx/battle/hp_exp_bar_border.1bpp
charmap "′", $6e ; gfx/font/feet_inches.png
charmap "″", $6f ; gfx/font/feet_inches.png
-; Actual characters (from gfx/misc/font.png)
+; Actual characters (from gfx/font/font.png)
charmap "A", $80
charmap "B", $81
--- a/main.asm
+++ b/main.asm
@@ -563,8 +563,236 @@
INCLUDE "event/bug_contest_2.asm"
-INCLUDE "unknown/013a47.asm"
+CorrectErrorsInPlayerParty: ; unreferenced
+ ld hl, PartyCount
+ ld a, [hl]
+ and a
+ ret z
+ cp PARTY_LENGTH + 1
+ jr c, .party_length_okay
+ ld a, PARTY_LENGTH
+ ld [hl], a
+.party_length_okay
+ inc hl
+
+ ld b, a
+ ld c, 0
+.loop1
+ ld a, [hl]
+ and a
+ jr z, .invalid_species
+ cp NUM_POKEMON + 1
+ jr z, .invalid_species
+ cp EGG + 1
+ jr c, .next_species
+
+.invalid_species
+ ld [hl], SMEARGLE
+ push hl
+ push bc
+ ld a, c
+ ld hl, PartyMon1Species
+ call GetPartyLocation
+ ld [hl], SMEARGLE
+ pop bc
+ pop hl
+
+.next_species
+ inc hl
+ inc c
+ dec b
+ jr nz, .loop1
+ ld [hl], $ff
+
+ ld hl, PartyMon1
+ ld a, [PartyCount]
+ ld d, a
+ ld e, 0
+.loop2
+ push de
+ push hl
+ ld b, h
+ ld c, l
+ ld a, [hl]
+ and a
+ jr z, .invalid_species_2
+ cp NUM_POKEMON + 1
+ jr c, .check_level
+
+.invalid_species_2
+ ld [hl], SMEARGLE
+ push de
+ ld d, 0
+ ld hl, PartySpecies
+ add hl, de
+ pop de
+ ld a, SMEARGLE
+ ld [hl], a
+
+.check_level
+ ld [CurSpecies], a
+ call GetBaseData
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [hl]
+ cp MIN_LEVEL
+ ld a, MIN_LEVEL
+ jr c, .invalid_level
+ ld a, [hl]
+ cp MAX_LEVEL
+ jr c, .load_level
+ ld a, MAX_LEVEL
+.invalid_level
+ ld [hl], a
+.load_level
+ ld [CurPartyLevel], a
+
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld d, h
+ ld e, l
+ ld hl, MON_STAT_EXP - 1
+ add hl, bc
+ ld b, $1
+ predef CalcPkmnStats
+ pop hl
+ ld bc, PARTYMON_STRUCT_LENGTH
+ add hl, bc
+ pop de
+ inc e
+ dec d
+ jr nz, .loop2
+
+ ld de, PartyMonNicknames
+ ld a, [PartyCount]
+ ld b, a
+ ld c, 0
+.loop3
+ push bc
+ call .GetLengthOfStringWith6CharCap
+ push de
+ callba CheckStringForErrors
+ pop hl
+ pop bc
+ jr nc, .valid_nickname
+
+ push bc
+ push hl
+ ld hl, PartySpecies
+ push bc
+ ld b, 0
+ add hl, bc
+ pop bc
+ ld a, [hl]
+ cp EGG
+ ld hl, .TAMAGO
+ jr z, .got_nickname
+ ld [wd265], a
+ call GetPokemonName
+ ld hl, StringBuffer1
+.got_nickname
+ pop de
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+ pop bc
+
+.valid_nickname
+ inc c
+ dec b
+ jr nz, .loop3
+
+ ld de, PartyMonOT
+ ld a, [PartyCount]
+ ld b, a
+ ld c, 0
+.loop4
+ push bc
+ call .GetLengthOfStringWith6CharCap
+ push de
+ callba CheckStringForErrors
+ pop hl
+ jr nc, .valid_ot_name
+ ld d, h
+ ld e, l
+ ld hl, PlayerName
+ ld bc, NAME_LENGTH
+ call CopyBytes
+.valid_ot_name
+ pop bc
+ inc c
+ dec b
+ jr nz, .loop4
+
+ ld hl, PartyMon1Moves
+ ld a, [PartyCount]
+ ld b, a
+.loop5
+ push hl
+ ld c, NUM_MOVES
+ ld a, [hl]
+ and a
+ jr z, .invalid_move
+ cp NUM_ATTACKS + 1
+ jr c, .moves_loop
+.invalid_move
+ ld [hl], POUND
+
+.moves_loop
+ ld a, [hl]
+ and a
+ jr z, .fill_invalid_moves
+ cp NUM_ATTACKS + 1
+ jr c, .next_move
+
+.fill_invalid_moves
+ xor a
+ ld [hli], a
+ dec c
+ jr nz, .fill_invalid_moves
+ jr .next_pokemon
+
+.next_move
+ inc hl
+ dec c
+ jr nz, .moves_loop
+
+.next_pokemon
+ pop hl
+ push bc
+ ld bc, PARTYMON_STRUCT_LENGTH
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .loop5
+ ret
+; 13b6b
+
+.TAMAGO: ; 13b6b
+ db "タマゴ@@@"
+; 13b71
+
+.GetLengthOfStringWith6CharCap: ; 13b71
+ push de
+ ld c, 1
+ ld b, NAME_LENGTH_JAPANESE
+.search_loop
+ ld a, [de]
+ cp "@"
+ jr z, .done
+ inc de
+ inc c
+ dec b
+ jr nz, .search_loop
+ dec c
+ dec de
+ ld a, "@"
+ ld [de], a
+.done
+ pop de
+ ret
+; 13b87
+
GetSquareRoot: ; 13b87
; Return the square root of de in b.
@@ -5139,7 +5367,7 @@
SECTION "battle_tower_47", ROMX
-INCLUDE "misc/battle_tower_47.asm"
+INCLUDE "mobile/battle_tower_47.asm"
SECTION "bank5B", ROMX
@@ -5170,6 +5398,8 @@
callba FinishBattleAnim
ret
+INCLUDE "mobile/mobile_5e.asm"
+
INCLUDE "mobile/mobile_5f.asm"
@@ -5655,52 +5885,11 @@
INCLUDE "data/battle_tower_2.asm"
-SECTION "bank7D", ROMX
+SECTION "Mobile News Data", ROMX
- db $cc, $6b, $1e ; XXX
+INCLUDE "mobile/news/news.asm"
-Function1f4003: ; 1f4003
-; XXX
- ld a, $6
- call GetSRAMBank
- ld hl, .unknown_data
- ld de, $a000
- ld bc, $1000
- call CopyBytes
- call CloseSRAM
- ret
-.unknown_data
-INCBIN "unknown/1f4018.bin"
-
-Function1f4dbe: ; 1f4dbe
-; XXX
- ld a, $6
- call GetSRAMBank
- ld hl, .unknown_data
- ld de, $a000
- ld bc, $1000
- call CopyBytes
- call CloseSRAM
- ret
-
-.unknown_data
-INCBIN "unknown/1f4dd3.bin"
-
-Function1f5d9f: ; 1f5d9f
- ld a, $6
- call GetSRAMBank
- ld hl, .unknown_data
- ld de, $a000
- ld bc, $1000
- call CopyBytes
- call CloseSRAM
- ret
-
-.unknown_data
-INCBIN "unknown/1f5db4.bin"
-
-
SECTION "bank7E", ROMX
INCLUDE "engine/battle_tower.asm"
@@ -5710,10 +5899,10 @@
SECTION "bank7F", ROMX
-SECTION "stadium2", ROMX
+SECTION "Mobile Stadium 2", ROMX
IF DEF(CRYSTAL11)
-INCBIN "misc/stadium2_2.bin"
+INCBIN "mobile/stadium/stadium2_2.bin"
ELSE
-INCBIN "misc/stadium2_1.bin"
+INCBIN "mobile/stadium/stadium2_1.bin"
ENDC
--- a/misc/battle_tower_47.asm
+++ /dev/null
@@ -1,784 +1,0 @@
-BattleTowerText:: ; 11c000
-; Print text c for trainer [BT_OTTrainerClass]
-; 1: Intro text
-; 2: Player lost
-; 3: Player won
- ld a, [rSVBK]
- push af
- ld a, 3 ; BANK(BT_OTTrainerClass)
- ld [rSVBK], a
-IF DEF(CRYSTAL11)
- ld hl, BT_OTTrainerClass
-ELSE
- ld hl, BT_OTName + 5
-; BUG ALERT
-; Instead of loading the Trainer Class, this routine
-; loads the 6th character in the Trainer's name, then
-; uses it to get the gender of the trainer.
-; As a consequence, the enemy trainer's dialog will
-; always be sampled from the female array.
-ENDC
- ld a, [hl]
- dec a
- ld e, a
- ld d, 0
- ld hl, BTTrainerClassGenders
- add hl, de
- ld a, [hl]
- and a
- jr nz, .female
- ; generate a random number between 0 and 24
- ld a, [hRandomAdd]
- and $1f
- cp 25
- jr c, .okay0
- sub 25
-
-.okay0
- ld hl, BTMaleTrainerTexts
- jr .proceed
-
-.female
- ; generate a random number between 0 and 14
- ld a, [hRandomAdd]
- and $f
- cp 15
- jr c, .okay1
- sub 15
-
-.okay1
- ld hl, BTFemaleTrainerTexts
-
-.proceed
- ld b, 0
- dec c
- jr nz, .restore
- ld [BT_TrainerTextIndex], a
- jr .okay2
-
-.restore
- ld a, [BT_TrainerTextIndex]
-
-.okay2
- push af
- add hl, bc
- add hl, bc
- ld a, [hli]
- ld c, a
- ld a, [hl]
- ld h, a
- ld l, c
- pop af
- ld c, a
- ld b, 0
- add hl, bc
- add hl, bc
- ld a, [hli]
- ld c, a
- ld a, [hl]
- ld l, c
- ld h, a
- bccoord 1, 14
- pop af
- ld [rSVBK], a
- call PlaceHLTextAtBC
- ret
-; 11c05d
-
-INCLUDE "mobile/fixed_words.asm"
-
-BTTrainerClassGenders: ; 11f2f0
- db MALE ; FALKNER
- db FEMALE ; WHITNEY
- db FEMALE ; BUGSY
- db MALE ; MORTY
- db MALE ; PRYCE
- db FEMALE ; JASMINE
- db MALE ; CHUCK
- db FEMALE ; CLAIR
- db MALE ; RIVAL1
- db MALE ; POKEMON_PROF
- db FEMALE ; WILL
- db MALE ; CAL
- db MALE ; BRUNO
- db FEMALE ; KAREN
- db MALE ; KOGA
- db MALE ; CHAMPION
- db MALE ; BROCK
- db FEMALE ; MISTY
- db MALE ; LT_SURGE
- db MALE ; SCIENTIST
- db FEMALE ; ERIKA
- db MALE ; YOUNGSTER
- db MALE ; SCHOOLBOY
- db MALE ; BIRD_KEEPER
- db FEMALE ; LASS
- db FEMALE ; JANINE
- db MALE ; COOLTRAINERM
- db FEMALE ; COOLTRAINERF
- db FEMALE ; BEAUTY
- db MALE ; POKEMANIAC
- db MALE ; GRUNTM
- db MALE ; GENTLEMAN
- db FEMALE ; SKIER
- db FEMALE ; TEACHER
- db FEMALE ; SABRINA
- db MALE ; BUG_CATCHER
- db MALE ; FISHER
- db MALE ; SWIMMERM
- db FEMALE ; SWIMMERF
- db MALE ; SAILOR
- db MALE ; SUPER_NERD
- db MALE ; RIVAL2
- db MALE ; GUITARIST
- db MALE ; HIKER
- db MALE ; BIKER
- db MALE ; BLAINE
- db MALE ; BURGLAR
- db MALE ; FIREBREATHER
- db MALE ; JUGGLER
- db MALE ; BLACKBELT_T
- db MALE ; EXECUTIVEM
- db MALE ; PSYCHIC_T
- db FEMALE ; PICNICKER
- db MALE ; CAMPER
- db FEMALE ; EXECUTIVEF
- db MALE ; SAGE
- db FEMALE ; MEDIUM
- db MALE ; BOARDER
- db MALE ; POKEFANM
- db FEMALE ; KIMONO_GIRL
- db FEMALE ; TWINS
- db FEMALE ; POKEFANF
- db MALE ; RED
- db MALE ; BLUE
- db MALE ; OFFICER
- db FEMALE ; GRUNTF
-
-
-BTMaleTrainerTexts: ; 11f332
- dw .Greetings
- dw .PlayerLost
- dw .PlayerWon
-
-.Greetings: ; 11f338
- dw BTGreetingM1
- dw BTGreetingM2
- dw BTGreetingM3
- dw BTGreetingM4
- dw BTGreetingM5
- dw BTGreetingM6
- dw BTGreetingM7
- dw BTGreetingM8
- dw BTGreetingM9
- dw BTGreetingM10
- dw BTGreetingM11
- dw BTGreetingM12
- dw BTGreetingM13
- dw BTGreetingM14
- dw BTGreetingM15
- dw BTGreetingM16
- dw BTGreetingM17
- dw BTGreetingM18
- dw BTGreetingM19
- dw BTGreetingM20
- dw BTGreetingM21
- dw BTGreetingM22
- dw BTGreetingM23
- dw BTGreetingM24
- dw BTGreetingM25
-
-.PlayerLost: ; 11f36a
- dw BTLossM1
- dw BTLossM2
- dw BTLossM3
- dw BTLossM4
- dw BTLossM5
- dw BTLossM6
- dw BTLossM7
- dw BTLossM8
- dw BTLossM9
- dw BTLossM10
- dw BTLossM11
- dw BTLossM12
- dw BTLossM13
- dw BTLossM14
- dw BTLossM15
- dw BTLossM16
- dw BTLossM17
- dw BTLossM18
- dw BTLossM19
- dw BTLossM20
- dw BTLossM21
- dw BTLossM22
- dw BTLossM23
- dw BTLossM24
- dw BTLossM25
-
-.PlayerWon: ; 11f39c
- dw BTWinM1
- dw BTWinM2
- dw BTWinM3
- dw BTWinM4
- dw BTWinM5
- dw BTWinM6
- dw BTWinM7
- dw BTWinM8
- dw BTWinM9
- dw BTWinM10
- dw BTWinM11
- dw BTWinM12
- dw BTWinM13
- dw BTWinM14
- dw BTWinM15
- dw BTWinM16
- dw BTWinM17
- dw BTWinM18
- dw BTWinM19
- dw BTWinM20
- dw BTWinM21
- dw BTWinM22
- dw BTWinM23
- dw BTWinM24
- dw BTWinM25
-
-
-BTFemaleTrainerTexts:
- dw .Greetings
- dw .PlayerLost
- dw .PlayerWon
-
-.Greetings: ; 11f3d4
- dw BTGreetingF1
- dw BTGreetingF2
- dw BTGreetingF3
- dw BTGreetingF4
- dw BTGreetingF5
- dw BTGreetingF6
- dw BTGreetingF7
- dw BTGreetingF8
- dw BTGreetingF9
- dw BTGreetingF10
- dw BTGreetingF11
- dw BTGreetingF12
- dw BTGreetingF13
- dw BTGreetingF14
- dw BTGreetingF15
-
-.PlayerLost: ; 11f3f2
- dw BTLossF1
- dw BTLossF2
- dw BTLossF3
- dw BTLossF4
- dw BTLossF5
- dw BTLossF6
- dw BTLossF7
- dw BTLossF8
- dw BTLossF9
- dw BTLossF10
- dw BTLossF11
- dw BTLossF12
- dw BTLossF13
- dw BTLossF14
- dw BTLossF15
-
-.PlayerWon: ; 11f410
- dw BTWinF1
- dw BTWinF2
- dw BTWinF3
- dw BTWinF4
- dw BTWinF5
- dw BTWinF6
- dw BTWinF7
- dw BTWinF8
- dw BTWinF9
- dw BTWinF10
- dw BTWinF11
- dw BTWinF12
- dw BTWinF13
- dw BTWinF14
- dw BTWinF15
-
-
-BTGreetingM1: ; 0x11f42e
- text_jump BattleTowerText_0x1ec000
- db "@"
-
-BTLossM1: ; 0x11f433
- text_jump BattleTowerText_0x1ec03b
- db "@"
-
-BTWinM1: ; 0x11f438
- text_jump UnknownText_0x1ec060
- db "@"
-
-BTGreetingM2: ; 0x11f43d
- text_jump BattleTowerText_0x1ec080
- db "@"
-
-BTLossM2: ; 0x11f442
- text_jump UnknownText_0x1ec0a3
- db "@"
-
-BTWinM2: ; 0x11f447
- text_jump UnknownText_0x1ec0c4
- db "@"
-
-BTGreetingM3: ; 0x11f44c
- text_jump UnknownText_0x1ec0e1
- db "@"
-
-BTLossM3: ; 0x11f451
- text_jump UnknownText_0x1ec108
- db "@"
-
-BTWinM3: ; 0x11f456
- text_jump UnknownText_0x1ec12a
- db "@"
-
-BTGreetingM4: ; 0x11f45b
- text_jump UnknownText_0x1ec14d
- db "@"
-
-BTLossM4: ; 0x11f460
- text_jump UnknownText_0x1ec16f
- db "@"
-
-BTWinM4: ; 0x11f465
- text_jump UnknownText_0x1ec190
- db "@"
-
-BTGreetingM5: ; 0x11f46a
- text_jump UnknownText_0x1ec1ae
- db "@"
-
-BTLossM5: ; 0x11f46f
- text_jump UnknownText_0x1ec1d0
- db "@"
-
-BTWinM5: ; 0x11f474
- text_jump UnknownText_0x1ec1f4
- db "@"
-
-BTGreetingM6: ; 0x11f479
- text_jump UnknownText_0x1ec216
- db "@"
-
-BTLossM6: ; 0x11f47e
- text_jump UnknownText_0x1ec238
- db "@"
-
-BTWinM6: ; 0x11f483
- text_jump UnknownText_0x1ec259
- db "@"
-
-BTGreetingM7: ; 0x11f488
- text_jump UnknownText_0x1ec27b
- db "@"
-
-BTLossM7: ; 0x11f48d
- text_jump UnknownText_0x1ec2a0
- db "@"
-
-BTWinM7: ; 0x11f492
- text_jump UnknownText_0x1ec2c0
- db "@"
-
-BTGreetingM8: ; 0x11f497
- text_jump UnknownText_0x1ec2d9
- db "@"
-
-BTLossM8: ; 0x11f49c
- text_jump UnknownText_0x1ec2fe
- db "@"
-
-BTWinM8: ; 0x11f4a1
- text_jump UnknownText_0x1ec320
- db "@"
-
-BTGreetingM9: ; 0x11f4a6
- text_jump UnknownText_0x1ec33f
- db "@"
-
-BTLossM9: ; 0x11f4ab
- text_jump UnknownText_0x1ec36c
- db "@"
-
-BTWinM9: ; 0x11f4b0
- text_jump UnknownText_0x1ec389
- db "@"
-
-BTGreetingM10: ; 0x11f4b5
- text_jump UnknownText_0x1ec3ad
- db "@"
-
-BTLossM10: ; 0x11f4ba
- text_jump UnknownText_0x1ec3c5
- db "@"
-
-BTWinM10: ; 0x11f4bf
- text_jump UnknownText_0x1ec3e5
- db "@"
-
-BTGreetingM11: ; 0x11f4c4
- text_jump UnknownText_0x1ec402
- db "@"
-
-BTLossM11: ; 0x11f4c9
- text_jump UnknownText_0x1ec411
- db "@"
-
-BTWinM11: ; 0x11f4ce
- text_jump UnknownText_0x1ec41f
- db "@"
-
-BTGreetingM12: ; 0x11f4d3
- text_jump UnknownText_0x1ec42e
- db "@"
-
-BTLossM12: ; 0x11f4d8
- text_jump UnknownText_0x1ec461
- db "@"
-
-BTWinM12: ; 0x11f4dd
- text_jump UnknownText_0x1ec4a0
- db "@"
-
-BTGreetingM13: ; 0x11f4e2
- text_jump UnknownText_0x1ec4d6
- db "@"
-
-BTLossM13: ; 0x11f4e7
- text_jump UnknownText_0x1ec4f5
- db "@"
-
-BTWinM13: ; 0x11f4ec
- text_jump UnknownText_0x1ec512
- db "@"
-
-BTGreetingM14: ; 0x11f4f1
- text_jump UnknownText_0x1ec532
- db "@"
-
-BTLossM14: ; 0x11f4f6
- text_jump UnknownText_0x1ec54b
- db "@"
-
-BTWinM14: ; 0x11f4fb
- text_jump UnknownText_0x1ec565
- db "@"
-
-BTGreetingM15: ; 0x11f500
- text_jump UnknownText_0x1ec580
- db "@"
-
-BTLossM15: ; 0x11f505
- text_jump UnknownText_0x1ec59d
- db "@"
-
-BTWinM15: ; 0x11f50a
- text_jump UnknownText_0x1ec5b5
- db "@"
-
-BTGreetingM16: ; 0x11f50f
- text_jump UnknownText_0x1ec5d3
- db "@"
-
-BTLossM16: ; 0x11f514
- text_jump UnknownText_0x1ec5ee
- db "@"
-
-BTWinM16: ; 0x11f519
- text_jump UnknownText_0x1ec60d
- db "@"
-
-BTGreetingM17: ; 0x11f51e
- text_jump UnknownText_0x1ec631
- db "@"
-
-BTLossM17: ; 0x11f523
- text_jump UnknownText_0x1ec651
- db "@"
-
-BTWinM17: ; 0x11f528
- text_jump UnknownText_0x1ec68f
- db "@"
-
-BTGreetingM18: ; 0x11f52d
- text_jump UnknownText_0x1ec6b1
- db "@"
-
-BTLossM18: ; 0x11f532
- text_jump UnknownText_0x1ec6d0
- db "@"
-
-BTWinM18: ; 0x11f537
- text_jump UnknownText_0x1ec708
- db "@"
-
-BTGreetingM19: ; 0x11f53c
- text_jump UnknownText_0x1ec720
- db "@"
-
-BTLossM19: ; 0x11f541
- text_jump UnknownText_0x1ec73e
- db "@"
-
-BTWinM19: ; 0x11f546
- text_jump UnknownText_0x1ec75b
- db "@"
-
-BTGreetingM20: ; 0x11f54b
- text_jump UnknownText_0x1ec77f
- db "@"
-
-BTLossM20: ; 0x11f550
- text_jump UnknownText_0x1ec798
- db "@"
-
-BTWinM20: ; 0x11f555
- text_jump UnknownText_0x1ec7bb
- db "@"
-
-BTGreetingM21: ; 0x11f55a
- text_jump UnknownText_0x1ec7d8
- db "@"
-
-BTLossM21: ; 0x11f55f
- text_jump UnknownText_0x1ec818
- db "@"
-
-BTWinM21: ; 0x11f564
- text_jump UnknownText_0x1ec837
- db "@"
-
-BTGreetingM22: ; 0x11f569
- text_jump UnknownText_0x1ec858
- db "@"
-
-BTLossM22: ; 0x11f56e
- text_jump UnknownText_0x1ec876
- db "@"
-
-BTWinM22: ; 0x11f573
- text_jump UnknownText_0x1ec898
- db "@"
-
-BTGreetingM23: ; 0x11f578
- text_jump UnknownText_0x1ec8b1
- db "@"
-
-BTLossM23: ; 0x11f57d
- text_jump UnknownText_0x1ec8d5
- db "@"
-
-BTWinM23: ; 0x11f582
- text_jump UnknownText_0x1ec8f0
- db "@"
-
-BTGreetingM24: ; 0x11f587
- text_jump UnknownText_0x1ec911
- db "@"
-
-BTLossM24: ; 0x11f58c
- text_jump UnknownText_0x1ec928
- db "@"
-
-BTWinM24: ; 0x11f591
- text_jump UnknownText_0x1ec949
- db "@"
-
-BTGreetingM25: ; 0x11f596
- text_jump UnknownText_0x1ec969
- db "@"
-
-BTLossM25: ; 0x11f59b
- text_jump UnknownText_0x1ec986
- db "@"
-
-BTWinM25: ; 0x11f5a0
- text_jump UnknownText_0x1ec99b
- db "@"
-
-
-
-
-BTGreetingF1: ; 0x11f5a5
- text_jump UnknownText_0x1ec9bd
- db "@"
-
-BTLossF1: ; 0x11f5aa
- text_jump UnknownText_0x1ec9d9
- db "@"
-
-BTWinF1: ; 0x11f5af
- text_jump UnknownText_0x1ec9f7
- db "@"
-
-BTGreetingF2: ; 0x11f5b4
- text_jump UnknownText_0x1eca0a
- db "@"
-
-BTLossF2: ; 0x11f5b9
- text_jump UnknownText_0x1eca2a
- db "@"
-
-BTWinF2: ; 0x11f5be
- text_jump UnknownText_0x1eca47
- db "@"
-
-BTGreetingF3: ; 0x11f5c3
- text_jump UnknownText_0x1eca64
- db "@"
-
-BTLossF3: ; 0x11f5c8
- text_jump UnknownText_0x1eca82
- db "@"
-
-BTWinF3: ; 0x11f5cd
- text_jump UnknownText_0x1eca9d
- db "@"
-
-BTGreetingF4: ; 0x11f5d2
- text_jump UnknownText_0x1ecabf
- db "@"
-
-BTLossF4: ; 0x11f5d7
- text_jump UnknownText_0x1ecade
- db "@"
-
-BTWinF4: ; 0x11f5dc
- text_jump UnknownText_0x1ecafa
- db "@"
-
-BTGreetingF5: ; 0x11f5e1
- text_jump UnknownText_0x1ecb19
- db "@"
-
-BTLossF5: ; 0x11f5e6
- text_jump UnknownText_0x1ecb37
- db "@"
-
-BTWinF5: ; 0x11f5eb
- text_jump UnknownText_0x1ecb55
- db "@"
-
-BTGreetingF6: ; 0x11f5f0
- text_jump UnknownText_0x1ecb70
- db "@"
-
-BTLossF6: ; 0x11f5f5
- text_jump UnknownText_0x1ecb92
- db "@"
-
-BTWinF6: ; 0x11f5fa
- text_jump UnknownText_0x1ecbb6
- db "@"
-
-BTGreetingF7: ; 0x11f5ff
- text_jump UnknownText_0x1ecbd9
- db "@"
-
-BTLossF7: ; 0x11f604
- text_jump UnknownText_0x1ecbf3
- db "@"
-
-BTWinF7: ; 0x11f609
- text_jump UnknownText_0x1ecc15
- db "@"
-
-BTGreetingF8: ; 0x11f60e
- text_jump UnknownText_0x1ecc39
- db "@"
-
-BTLossF8: ; 0x11f613
- text_jump UnknownText_0x1ecc55
- db "@"
-
-BTWinF8: ; 0x11f618
- text_jump UnknownText_0x1ecc75
- db "@"
-
-BTGreetingF9: ; 0x11f61d
- text_jump UnknownText_0x1ecc92
- db "@"
-
-BTLossF9: ; 0x11f622
- text_jump UnknownText_0x1ecca7
- db "@"
-
-BTWinF9: ; 0x11f627
- text_jump UnknownText_0x1eccc1
- db "@"
-
-BTGreetingF10: ; 0x11f62c
- text_jump UnknownText_0x1eccd7
- db "@"
-
-BTLossF10: ; 0x11f631
- text_jump UnknownText_0x1eccef
- db "@"
-
-BTWinF10: ; 0x11f636
- text_jump UnknownText_0x1ecd0e
- db "@"
-
-BTGreetingF11: ; 0x11f63b
- text_jump UnknownText_0x1ecd2b
- db "@"
-
-BTLossF11: ; 0x11f640
- text_jump UnknownText_0x1ecd4d
- db "@"
-
-BTWinF11: ; 0x11f645
- text_jump UnknownText_0x1ecd6b
- db "@"
-
-BTGreetingF12: ; 0x11f64a
- text_jump UnknownText_0x1ecd8d
- db "@"
-
-BTLossF12: ; 0x11f64f
- text_jump UnknownText_0x1ecdaf
- db "@"
-
-BTWinF12: ; 0x11f654
- text_jump UnknownText_0x1ecdcf
- db "@"
-
-BTGreetingF13: ; 0x11f659
- text_jump UnknownText_0x1ecded
- db "@"
-
-BTLossF13: ; 0x11f65e
- text_jump UnknownText_0x1ece0d
- db "@"
-
-BTWinF13: ; 0x11f663
- text_jump UnknownText_0x1ece2a
- db "@"
-
-BTGreetingF14: ; 0x11f668
- text_jump UnknownText_0x1ece4b
- db "@"
-
-BTLossF14: ; 0x11f66d
- text_jump UnknownText_0x1ece70
- db "@"
-
-BTWinF14: ; 0x11f672
- text_jump UnknownText_0x1ece8a
- db "@"
-
-BTGreetingF15: ; 0x11f677
- text_jump UnknownText_0x1ecea8
- db "@"
-
-BTLossF15: ; 0x11f67c
- text_jump UnknownText_0x1ecec9
- db "@"
-
-BTWinF15: ; 0x11f681
- text_jump UnknownText_0x1ecee8
- db "@"
--- a/misc/battle_tower_5c.asm
+++ /dev/null
@@ -1,1772 +1,0 @@
-BattleTowerRoomMenu: ; 1700b0
-; special
- call InitBattleTowerChallengeRAM
- callba _BattleTowerRoomMenu
- ret
-; 1700ba
-
-Function1700ba: ; 1700ba
- call InitBattleTowerChallengeRAM
- callba Function11811a
- ret
-; 1700c4
-
-Function1700c4: ; 1700c4
- ld a, [rSVBK]
- push af
- ld a, $3
- ld [rSVBK], a
-
- call Function17042c
-
- ld a, $5
- call GetSRAMBank
- ld a, $1
- ld [$be45], a
- xor a
- ld [$be46], a
- ld hl, w3_dffc
- ld de, $aa41
- ld bc, 4
- call CopyBytes
- ld hl, w3_d202Name
- ld de, $aa8e
- ld bc, 7 * $cc ; length of battle tower struct from japanese games?
- call CopyBytes
- ld hl, $aa5d ; some sort of count
- ld a, [hl]
- inc [hl]
- inc hl
- sla a
- sla a
- ld e, a
- ld d, $0
- add hl, de
- ld e, l
- ld d, h
- ld hl, w3_dffc
- ld bc, 4
- call CopyBytes
- call CloseSRAM
- pop af
- ld [rSVBK], a
- ret
-; 170114
-
-Function170114: ; 170114
- call InitBattleTowerChallengeRAM
- call .Function170121
- callba Function11805f
- ret
-; 170121
-
-.Function170121: ; 170121
- ld a, $5
- call GetSRAMBank
- ld hl, $a948
- ld de, wMisc
- ld bc, $f6 ; 246
- call CopyBytes
- call CloseSRAM
- call Function170c8b
- ret
-; 170139
-
-Function170139: ; 170139
-; Convert the 4-digit decimal number at 5:aa41 into binary
- ld a, $5
- call GetSRAMBank
- ld de, $aa41
- ld h, $0
- ld l, h
- ld bc, 1000
- call .DecToBin
- ld bc, 100
- call .DecToBin
- ld bc, 10
- call .DecToBin
- ld a, [de]
- ld c, a
- ld b, $0
- add hl, bc
- call CloseSRAM
-; Store that number in wMisc
- ld a, h
- ld [wMisc], a
- ld a, l
- ld [wMisc + 1], a
- ld hl, wBT_OTTempPkmn1DVs
- ld a, [PlayerID]
- ld [hli], a
- ld a, [PlayerID + 1]
- ld [hli], a
- ld a, [wSecretID]
- ld [hli], a
- ld a, [wSecretID + 1]
- ld [hli], a
- ld e, l
- ld d, h
- ld hl, PlayerName
- ld bc, 5 ; Japanese name length
- call CopyBytes
- ld bc, PlayerID
- ld de, PlayerGender
- callba GetMobileOTTrainerClass
- ld de, wBT_OTTempPkmn1CaughtGender
- ld a, c
- ld [de], a
- inc de
- ld a, PartyMons % $100
- ld [wcd49], a
- ld a, PartyMons / $100
- ld [wcd4a], a
- ld a, PartyMonNicknames % $100
- ld [wcd4b], a
- ld a, PartyMonNicknames / $100
- ld [wcd4c], a
- ld a, 3
-.CopyLoop:
- push af
- ld a, [wcd49]
- ld l, a
- ld a, [wcd4a]
- ld h, a
- ld bc, PARTYMON_STRUCT_LENGTH
- call CopyBytes
- ld a, l
- ld [wcd49], a
- ld a, h
- ld [wcd4a], a
- ld a, [wcd4b]
- ld l, a
- ld a, [wcd4c]
- ld h, a
- ld bc, $0006
- call CopyBytes
- ld a, l
- ld [wcd4b], a
- ld a, h
- ld [wcd4c], a
- pop af
- dec a
- jr nz, .CopyLoop
- ld a, $4
- call GetSRAMBank
- ld hl, $a013
- ld bc, $24
- call CopyBytes
- call CloseSRAM
- ld a, $5
- call GetSRAMBank
- ld hl, $a894
- ld bc, 6
- call CopyBytes
- ld hl, wMisc
- ld de, $a948
- ld bc, $f6
- call CopyBytes
- call CloseSRAM
- ret
-; 17020c
-
-.DecToBin: ; 17020c
- ld a, [de]
- inc de
- and a
- ret z
-
-.digit_loop
- add hl, bc
- dec a
- jr nz, .digit_loop
- ret
-; 170215
-
-BattleTowerBattle: ; 170215
- xor a
- ld [wBattleTowerBattleEnded], a
- call _BattleTowerBattle
- ret
-; 17021d
-
-EmptySpecial_17021d: ; 17021d
- ret
-; 17021e
-
-InitBattleTowerChallengeRAM: ; 17021e
- xor a
- ld [wBattleTowerBattleEnded], a
- ld [wNrOfBeatenBattleTowerTrainers], a
- ld [wcf65], a
- ld [wcf66], a
- ret
-; 17022c
-
-_BattleTowerBattle: ; 17022c
-.loop
- call .do_dw
- call DelayFrame
- ld a, [wBattleTowerBattleEnded]
- cp $1
- jr nz, .loop
- ret
-; 17023a
-
-.do_dw ; 17023a
- ld a, [wBattleTowerBattleEnded]
- ld e, a
- ld d, 0
- ld hl, .dw
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp hl
-; 170249
-
-.dw ; 170249
- dw RunBattleTowerTrainer
- dw SkipBattleTowerTrainer
-; 17024d
-
-RunBattleTowerTrainer: ; 17024d
- ld a, [Options]
- push af
- ld hl, Options
- set BATTLE_SHIFT, [hl] ; SET MODE
-
- ld a, [InBattleTowerBattle]
- push af
- or $1
- ld [InBattleTowerBattle], a
-
- xor a
- ld [wLinkMode], a
- callba TrainerRankings_Healings
- callba HealParty
- call ReadBTTrainerParty
- call Clears5_a89a
-
- predef StartBattle
-
- callba LoadPokemonData
- callba HealParty
- ld a, [wBattleResult]
- ld [ScriptVar], a
- and a
- jr nz, .lost
- ld a, BANK(sNrOfBeatenBattleTowerTrainers)
- call GetSRAMBank
- ld a, [sNrOfBeatenBattleTowerTrainers]
- ld [wNrOfBeatenBattleTowerTrainers], a
- call CloseSRAM
- ld hl, StringBuffer3
- ld a, [wNrOfBeatenBattleTowerTrainers]
- add "1"
- ld [hli], a
- ld a, "@"
- ld [hl], a
-
-.lost
- pop af
- ld [InBattleTowerBattle], a
- pop af
- ld [Options], a
- ld a, $1
- ld [wBattleTowerBattleEnded], a
- ret
-
-
-ReadBTTrainerParty: ; 1702b7
-; Initialise the BattleTower-Trainer and his Pkmn
- call CopyBTTrainer_FromBT_OT_TowBT_OTTemp
-
-; Check the nicknames for illegal characters, and replace bad nicknames
-; with their species names.
- ld de, wBT_OTTempPkmn1Name ; $c643
- ld c, PKMN_NAME_LENGTH
- callba CheckStringForErrors
- jr nc, .skip_mon_1
-
- ld a, [wBT_OTTempPkmn1]
- ld [wNamedObjectIndexBuffer], a
- call GetPokemonName
- ld l, e
- ld h, d
- ld de, wBT_OTTempPkmn1Name ; $c643
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
-
-.skip_mon_1
- ld de, wBT_OTTempPkmn2Name ; $c67e
- ld c, PKMN_NAME_LENGTH
- callba CheckStringForErrors
- jr nc, .skip_mon_2
- ld a, [wBT_OTTempPkmn2] ; [$c64e]
- ld [wNamedObjectIndexBuffer], a
- call GetPokemonName
- ld l, e
- ld h, d
- ld de, wBT_OTTempPkmn2Name ; $c67e
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
-
-.skip_mon_2
- ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9
- ld c, PKMN_NAME_LENGTH
- callba CheckStringForErrors
- jr nc, .skip_mon_3
- ld a, [wBT_OTTempPkmn3] ; [$c689]
- ld [wNamedObjectIndexBuffer], a
- call GetPokemonName
- ld l, e
- ld h, d
- ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
-
-.skip_mon_3
-; Add the terminator character to each of these names
- ld a, "@"
- ld [wBT_OTTempPkmn1NameEnd - 1], a ; $c64d
- ld [wBT_OTTempPkmn2NameEnd - 1], a ; $c688
- ld [wBT_OTTempPkmn3NameEnd - 1], a ; $c68a + 57 = $c6c3
-; Fix errors in the movesets
- call CheckBTMonMovesForErrors
-; Repair the trainer name if needed, then copy it to OTPlayerName
- ld de, wBT_OTTempName
- ld c, NAME_LENGTH - 1
- callba CheckStringForErrors
- jr nc, .trainer_name_okay
- ld hl, BT_ChrisName
- jr .done_trainer_name
-
-.trainer_name_okay
- ld hl, wBT_OTTempName ; 0xc608
-
-.done_trainer_name
- ld de, OTPlayerName
- ld bc, NAME_LENGTH - 1
- call CopyBytes
- ld a, "@"
- ld [de], a
-
- ld hl, wBT_OTTempTrainerClass
- ld a, [hli]
- ld [OtherTrainerClass], a
- ld a, OTPartyMonNicknames % $100
- ld [BGMapBuffer], a
- ld a, OTPartyMonNicknames / $100
- ld [BGMapBuffer + 1], a
-
- ; Copy Pkmn into Memory from the address in hl
- ld de, OTPartyMon1Species
- ld bc, OTPartyCount
- ld a, BATTLETOWER_NROFPKMNS ; Number of Pkmn the BattleTower-Trainer has
- ld [bc], a
- inc bc
-.otpartymon_loop
- push af
- ld a, [hl]
- ld [bc], a
- inc bc
- push bc
- ld bc, PARTYMON_STRUCT_LENGTH
- call CopyBytes
- push de
- ld a, [BGMapBuffer]
- ld e, a
- ld a, [BGMapBuffer + 1]
- ld d, a
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
- ld a, e
- ld [BGMapBuffer], a
- ld a, d
- ld [BGMapBuffer + 1], a
- pop de
- pop bc
- pop af
- dec a
- and a
- jr nz, .otpartymon_loop
- ld a, -1
- ld [bc], a
- ret
-; 170394
-
-ValidateBTParty: ; 170394
-; Check for and fix errors in party data
- ld hl, wBT_OTTempPkmn1Species
- ld d, BATTLETOWER_NROFPKMNS
-.pkmn_loop
- push de
- push hl
- ld b, h
- ld c, l
- ld a, [hl]
- and a
-idx = $ff
-rept ($ff +- NUM_POKEMON)
- jr z, .invalid
- cp idx
-idx = idx +- 1
-endr
- jr nz, .valid
-
-.invalid
- ld a, SMEARGLE
- ld [hl], a
-
-.valid
- ld [CurSpecies], a
- call GetBaseData
- ld a, $5
- call GetSRAMBank
- ld a, [$b2fb] ; s5_b2fb ; max level?
- call CloseSRAM
- ld e, a
- ld hl, MON_LEVEL
- add hl, bc
- ld a, [hl]
- cp MIN_LEVEL
- ld a, MIN_LEVEL
- jr c, .load
- ld a, [hl]
- cp e
- jr c, .dont_load
- ld a, e
-
-.load
- ld [hl], a
-
-.dont_load
- ld [CurPartyLevel], a
- ld hl, MON_MOVES
- add hl, bc
- ld d, NUM_MOVES - 1
- ld a, [hli]
- and a
- jr z, .not_move
- cp NUM_ATTACKS + 1
- jr nc, .not_move
- jr .valid_move
-
-.not_move
- dec hl
- ld a, POUND
- ld [hli], a
- xor a
- ld [hli], a
- ld [hli], a
- ld [hl], a
- jr .done_moves
-
-.valid_move
- ld a, [hl]
- cp NUM_ATTACKS + 1
- jr c, .next
- ld [hl], $0
-
-.next
- inc hl
- dec d
- jr nz, .valid_move
-
-.done_moves
- ld hl, MON_MAXHP
- add hl, bc
- ld d, h
- ld e, l
- push hl
- push de
- ld hl, MON_STAT_EXP - 1
- add hl, bc
- ld b, $1
- predef CalcPkmnStats
- pop de
- pop hl
- dec de
- dec de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- pop hl
- ld bc, PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH
- add hl, bc
- pop de
- dec d
- jp nz, .pkmn_loop
- ret
-; 170426
-
-BT_ChrisName: ; 170426
- db "CHRIS@"
-; 17042c
-
-Function17042c: ; 17042c
- ld hl, w3_d202TrainerData
- ld a, BATTLETOWER_NROFTRAINERS
-.loop
- push af
- push hl
- ld c, BATTLETOWER_TRAINERDATALENGTH / 2
-.loop2
- ; First byte is a comparison value.
- ld a, [hli]
- ld b, a
- ; Second byte is a lookup index.
- ld a, [hli]
- and a
- jr z, .empty
- cp 15
- jr nc, .copy_data
-
- push hl
- ld hl, Unknown_170470
- dec a
- ld e, a
- ld d, 0
- add hl, de
- ld a, [hl]
- pop hl
-
- ; If Unknown_170470[a-1] <= b, overwrite the current trainer's data
- ; with Unknown17047e, and exit the inner loop.
- cp b
- jr c, .copy_data
- jr z, .copy_data
- jr .next_iteration
-
-.empty
- ; If a == 0 and b >= $fc, overwrite the current trainer's data with
- ; Unknown17047e, and exit the inner loop.
- ld a, b
- cp $fc
- jr nc, .copy_data
-
-.next_iteration
- dec c
- jr nz, .loop2
- jr .next_trainer
-
-.copy_data
- pop de
- push de
- ld hl, Unknown_17047e
- ld bc, BATTLETOWER_TRAINERDATALENGTH
- call CopyBytes
-
-.next_trainer
- pop hl
- ld de, BATTLE_TOWER_STRUCT_LENGTH
- add hl, de
- pop af
- dec a
- jr nz, .loop
- ret
-; 170470
-
-Unknown_170470:
- db $12
- db $24
- db $45
- db $45
- db $42
- db $42
- db $45
- db $42
- db $27
- db $27
- db $45
- db $27
- db $42
- db $24
-
-Unknown_17047e:
-; see data/battle_tower_2.asm
- db $03, 4
- db $05, 8
- db $03, 5
- db $0e, 6
- db $03, 2
- db $00, 0
- db $39, 7
- db $07, 4
- db $00, 5
- db $04, 7
- db $01, 5
- db $00, 0
- db $0f, 5
- db $14, 7
- db $05, 5
- db $11, 12
- db $0c, 6
- db $06, 4
-
-
-CopyBTTrainer_FromBT_OT_TowBT_OTTemp: ; 1704a2
-; copy the BattleTower-Trainer data that lies at 'BT_OTTrainer' to 'wBT_OTTemp'
- ld a, [rSVBK]
- push af
- ld a, $3 ; BANK(BT_OTTrainer)
- ld [rSVBK], a
-
- ld hl, BT_OTTrainer ; $d100
- ld de, wBT_OTTemp ; wMisc
- ld bc, BATTLE_TOWER_STRUCT_LENGTH
- call CopyBytes
-
- pop af
- ld [rSVBK], a
-
- ld a, BANK(sBattleTowerChallengeState)
- call GetSRAMBank
- ld a, BATTLETOWER_CHALLENGE_IN_PROGESS
- ld [sBattleTowerChallengeState], a
- ld hl, sNrOfBeatenBattleTowerTrainers
- inc [hl]
- call CloseSRAM
-SkipBattleTowerTrainer: ; 1704c9
- ret
-; 1704ca
-
-Function1704ca: ; 1704ca
-; unreferenced mobile function
- ld a, [$be46]
- cp $7
- jr c, .asm_1704d3
- ld a, $6
-
-.asm_1704d3
- ld hl, $afce
- ld de, -$e0
-.asm_1704d9
- and a
- jr z, .asm_1704e0
- add hl, de
- dec a
- jr .asm_1704d9
-
-.asm_1704e0
- ret
-; 1704e1
-
-Function1704e1: ; 1704e1
-; unreferenced special
- call SpeechTextBox
- call FadeToMenu
- call InitBattleTowerChallengeRAM
- call .JumptableLoop
- call CloseSubmenu
- ret
-; 1704f1
-
-.JumptableLoop: ; 1704f1
- call ClearBGPalettes
- call ClearSprites
- call ClearScreen
-.loop
- call JoyTextDelay
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .done
- call .DoJumptable
- callba ReloadMapPart
- jr .loop
-
-.done
- ret
-; 170510
-
-.DoJumptable: ; 170510
- ld a, [wJumptableIndex]
- ld e, a
- ld d, 0
- ld hl, .dw
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp hl
-; 17051f
-
-.dw ; 17051f
- dw .Jumptable_0
- dw .Jumptable_1
- dw .Jumptable_2
-; 170525
-
-.Jumptable_0: ; 170525
- ld a, $5
- call GetSRAMBank
-
- ld hl, $a89c
- ld de, StringBuffer3
- ld bc, $16
- call CopyBytes
-
- ld hl, $a8b2
- ld de, wMisc
- ld bc, $0096
- call CopyBytes
-
- call CloseSRAM
- hlcoord 1, 1
- ld de, StringBuffer3
- call PlaceString
- hlcoord 1, 3
- ld de, .String_Mail
- call PlaceString
- hlcoord 4, 3
- ld de, StringBuffer4
- call PlaceString
- hlcoord 8, 3
- ld de, .String_PastReaders
- call PlaceString
- call .DrawBorder
- call .PlaceTextItems
- jr .NextJumptableFunction
-
-
-.Jumptable_1:
- call SetPalettes
- call .NextJumptableFunction
-
-
-.Jumptable_2:
- ld hl, hJoyPressed
- ld a, [hl]
- and A_BUTTON
- jr nz, .pressed_a_or_b
- ld a, [hl]
- and B_BUTTON
- jr nz, .pressed_a_or_b
- ld a, [hl]
- and D_UP
- jr nz, .pressed_up
- ld a, [hl]
- and D_DOWN
- jr nz, .pressed_down
- ret
-
-.pressed_up
- ld a, [wNrOfBeatenBattleTowerTrainers]
- and a
- ret z
- sub 15
- ld [wNrOfBeatenBattleTowerTrainers], a
- call .PlaceTextItems
- ret
-
-.pressed_down
- ld a, [wNrOfBeatenBattleTowerTrainers]
- cp 60
- ret z
- add 15
- ld [wNrOfBeatenBattleTowerTrainers], a
- call .PlaceTextItems
- ret
-
-.pressed_a_or_b
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-
-.NextJumptableFunction:
- ld hl, wJumptableIndex
- inc [hl]
- ret
-; 1705b7
-
-.DrawBorder: ; 1705b7
- hlcoord 0, 4
- ld a, $79
- ld [hli], a
- ld c, SCREEN_WIDTH - 2
-.top_border_loop
- ld a, $7a
- ld [hli], a
- dec c
- jr nz, .top_border_loop
- ld a, $7b
- ld [hli], a
- ld de, SCREEN_WIDTH
- ld c, 12
-.left_border_loop
- ld a, $7c
- ld [hl], a
- add hl, de
- dec c
- jr nz, .left_border_loop
- ld a, $7d
- ld [hli], a
- ld c, SCREEN_WIDTH - 2
-.bottom_border_loop
- ld a, $7a
- ld [hli], a
- dec c
- jr nz, .bottom_border_loop
- ld a, $7e
- ld [hl], a
- ld de, -SCREEN_WIDTH
- add hl, de
- ld c, 12
-.right_border_loop
- ld a, $7c
- ld [hl], a
- add hl, de
- dec c
- jr nz, .right_border_loop
- ret
-; 1705f0
-
-.PlaceTextItems: ; 1705f0
- call .ClearBox
- call .PlaceUpDownArrows
- ld a, $50
- ld [wcd4e], a
- ld hl, wMisc
- ld a, [wNrOfBeatenBattleTowerTrainers]
- ld c, a
- xor a
- ld b, a
- add hl, bc
- push hl
- pop bc
- hlcoord 1, 6
- ld a, 6
-.loop1
- push af
- push hl
- ld a, 3
-.loop2
- push af
- ld de, wcd49
- ld a, [bc]
- and a
- jr z, .fill_with_e3
-; .copy
- ld a, 5
-.loop3a
- push af
- ld a, [bc]
- ld [de], a
- inc bc
- inc de
- pop af
- dec a
- jr nz, .loop3a
- jr .rejoin
-
-.fill_with_e3
- ld a, 5
-.loop3b
- push af
- ld a, $e3
- ld [de], a
- inc de
- inc bc
- pop af
- dec a
- jr nz, .loop3b
-
-.rejoin
- ld de, wcd49
- push bc
- call PlaceString
- ld de, 6
- add hl, de
- pop bc
- pop af
- dec a
- jr nz, .loop2
- pop hl
- ld de, $28
- add hl, de
- pop af
- dec a
- jr nz, .loop1
- ret
-; 17064b
-
-.ClearBox: ; 17064b
- hlcoord 1, 5
- xor a
- ld b, 12
-.clearbox_row
- ld c, SCREEN_WIDTH - 2
-.clearbox_column
- ld [hli], a
- dec c
- jr nz, .clearbox_column
- inc hl
- inc hl
- dec b
- jr nz, .clearbox_row
- ret
-; 17065d
-
-.PlaceUpDownArrows: ; 17065d
- ld a, [wNrOfBeatenBattleTowerTrainers]
- and a
- jr z, .nope
- hlcoord 18, 5
- ld a, "▲"
- ld [hl], a
-
-.nope
- ld a, [wNrOfBeatenBattleTowerTrainers]
- cp 60
- ret z
- hlcoord 18, 16
- ld a, "▼"
- ld [hl], a
- ret
-; 170676
-
-.String_Mail: ; 170676
- db "ルーム@"
-; 17067a
-
-.String_PastReaders: ; 17067a
- db "れきだいりーダーいちらん@"
-; 170687
-
-BattleTowerAction: ; 170687
- ld a, [ScriptVar]
- ld e, a
- ld d, 0
- ld hl, .dw
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp hl
-; 170696
-
-
-.dw ; 170696 (5c:4696)
- dw BattleTowerAction_CheckExplanationRead ; 0x00
- dw BattleTowerAction_SetExplanationRead ; 0x01
- dw BattleTowerAction_GetChallengeState ; 0x02
- dw BattleTowerAction_SetByteToQuickSaveChallenge ; 0x03
- dw BattleTowerAction_SetByteToCancelChallenge ; 0x04
- dw Function1707ac ; 0x05
- dw Function1707f4 ; 0x06
- dw SaveBattleTowerLevelGroup ; 0x07
- dw LoadBattleTowerLevelGroup ; 0x08
- dw BattleTower_CheckSaveFileExistsAndIsYours ; 0x09
- dw Function1708b1 ; 0x0a
- dw CheckMobileEventIndex ; 0x0b
- dw Function1708c8 ; 0x0c
- dw Function1708f0 ; 0x0d
- dw BattleTowerAction_EggTicket ; 0x0e
- dw Function1709aa ; 0x0f
- dw Function1709bb ; 0x10
- dw Function170a9c ; 0x11
- dw Function170aa0 ; 0x12
- dw Function170aaf ; 0x13
- dw Function170abe ; 0x14
- dw Function170ad7 ; 0x15
- dw Function170807 ; 0x16
- dw Function17081d ; 0x17
- dw BattleTowerAction_LevelCheck ; 0x18
- dw BattleTowerAction_UbersCheck ; 0x19
- dw ResetBattleTowerTrainersSRAM ; 0x1a
- dw BattleTower_GiveReward ; 0x1b
- dw Function17071b ; 0x1c
- dw Function170729 ; 0x1d
- dw BattleTower_RandomlyChooseReward ; 0x1e
- dw BattleTower_SaveOptions ; 0x1f
-
-
-; Reset the save memory for BattleTower-Trainers (Counter and all 7 TrainerBytes)
-ResetBattleTowerTrainersSRAM: ; 1706d6 (5c:46d6) BattleTowerAction $1a
- ld a, BANK(sBTTrainers)
- call GetSRAMBank
-
- ld a, $ff
- ld hl, sBTTrainers
- ld bc, BATTLETOWER_NROFTRAINERS
- call ByteFill
-
- xor a
- ld [sNrOfBeatenBattleTowerTrainers], a
-
- call CloseSRAM
-
- ret
-
-BattleTower_GiveReward: ; 1706ee (5c:46ee) BattleTowerAction $1b
- ld a, BANK(sBattleTowerReward)
- call GetSRAMBank
-
- ld a, [sBattleTowerReward]
- call CloseSRAM
- ld [ScriptVar], a
- ld hl, NumItems
- ld a, [hli]
- cp MAX_ITEMS
- ret c
- ld b, MAX_ITEMS
- ld a, [ScriptVar]
- ld c, a
-.loop
- ld a, [hli]
- cp c
- jr nz, .next
- ld a, [hl]
- cp 95
- ret c
-.next
- inc hl
- dec b
- jr nz, .loop
- ld a, POTION
- ld [ScriptVar], a
- ret
-
-Function17071b: ; 17071b (5c:471b) BattleTowerAction $1c
- ld a, BANK(sBattleTowerChallengeState)
- call GetSRAMBank
- ld a, BATTLETOWER_WON_CHALLENGE
- ld [sBattleTowerChallengeState], a
- call CloseSRAM
- ret
-
-Function170729: ; 170729 (5c:4729) BattleTowerAction $1d
- ld a, BANK(sBattleTowerChallengeState)
- call GetSRAMBank
- ld a, BATTLETOWER_RECEIVED_REWARD
- ld [sBattleTowerChallengeState], a
- call CloseSRAM
- ret
-
-BattleTower_SaveOptions: ; 170737 (5c:4737) BattleTowerAction $1f
- callba SaveOptions
- ret
-
-BattleTower_RandomlyChooseReward: ; 17073e (5c:473e) BattleTowerAction $1e
-; Generate a random stat boosting item.
-.loop
- call Random
- ld a, [hRandomAdd]
- and $7
- cp 6
- jr c, .okay
- sub 6
-.okay
- add HP_UP
- cp LUCKY_PUNCH
- jr z, .loop
- push af
- ld a, BANK(sBattleTowerReward)
- call GetSRAMBank
- pop af
- ld [sBattleTowerReward], a
- call CloseSRAM
- ret
-
-BattleTowerAction_CheckExplanationRead: ; 17075f (5c:475f) BattleTowerAction $00
- call BattleTower_CheckSaveFileExistsAndIsYours
- ld a, [ScriptVar]
- and a
- ret z
-
- ld a, BANK(s1_be4f)
- call GetSRAMBank
- ld a, [s1_be4f]
- and $2
- ld [ScriptVar], a
- call CloseSRAM
- ret
-
-BattleTowerAction_GetChallengeState: ; 170778 (5c:4778) BattleTowerAction $02
- ld hl, sBattleTowerChallengeState
- ld a, BANK(sBattleTowerChallengeState)
- call GetSRAMBank
- ld a, [hl]
- ld [ScriptVar], a
- call CloseSRAM
- ret
-
-BattleTowerAction_SetExplanationRead: ; 170788 (5c:4788) BattleTowerAction $01
- ld a, BANK(s1_be4f)
- call GetSRAMBank
- ld a, [s1_be4f]
- or $2
- ld [s1_be4f], a
- call CloseSRAM
- ret
-
-BattleTowerAction_SetByteToQuickSaveChallenge: ; 170799 (5c:4799) BattleTowerAction $03
- ld c, BATTLETOWER_SAVED_AND_LEFT
- jr asm_17079f
-
-BattleTowerAction_SetByteToCancelChallenge: ; 17079d (5c:479d) BattleTowerAction $04
- ld c, BATTLETOWER_NO_CHALLENGE
-asm_17079f: ; 17079f (5c:479f)
- ld a, BANK(sBattleTowerChallengeState)
- call GetSRAMBank
- ld a, c
- ld [sBattleTowerChallengeState], a
- call CloseSRAM
- ret
-
-Function1707ac: ; 1707ac (5c:47ac) BattleTowerAction $05
- ld a, $5
- call GetSRAMBank
- ld a, [$aa8c]
- ld b, a
- ld a, [$be46]
- ld [ScriptVar], a
- call CloseSRAM
- and a
- ret z
- ld a, b
- cp $2
- jr nc, .asm_1707ef
- push bc
- call UpdateTime
- pop bc
- ld a, $5
- call GetSRAMBank
- ld a, [$aa8b]
- call CloseSRAM
- ld c, a
- ld a, [CurDay]
- sub c
- jr c, .asm_1707e5
- cp $8
- jr nc, .asm_1707ef
- ld a, b
- and a
- jr nz, .asm_1707ef
- ret
-.asm_1707e5
- ld hl, CurDay
- ld a, $8c
- sub c
- add [hl]
- cp $8
- ret c
-.asm_1707ef
- ld a, $8
- ld [ScriptVar], a
-
-Function1707f4: ; 1707f4 (5c:47f4) BattleTowerAction $06
- ld a, $5
- call GetSRAMBank
- xor a
- ld [$be46], a
- ld [$aa8b], a
- ld [$aa8c], a
- call CloseSRAM
- ret
-
-Function170807: ; 170807 (5c:4807) BattleTowerAction $16
- call UpdateTime
- ld a, $5
- call GetSRAMBank
- ld a, [CurDay]
- ld [$b2f9], a
- xor a
- ld [$b2fa], a
- call CloseSRAM
- ret
-
-Function17081d: ; 17081d (5c:481d) BattleTowerAction $17
- xor a
- ld [ScriptVar], a
- ld a, $5
- call GetSRAMBank
- ld a, [$b2f9]
- ld c, a
- ld a, [$b2fa]
- ld b, a
- call CloseSRAM
- cp $2
- jr nc, .asm_170853
- push bc
- call UpdateTime
- pop bc
- ld a, [CurDay]
- sub c
- jr c, .asm_170849
- cp $b
- jr nc, .asm_170853
- ld a, b
- and a
- jr nz, .asm_170853
- ret
-
-.asm_170849
- ld hl, CurDay
- ld a, 140
- sub c
- add [hl]
- cp $b
- ret c
-.asm_170853
- ld a, $1
- ld [ScriptVar], a
- ld a, $5
- call GetSRAMBank
- xor a
- ld [$b2f9], a
- ld [$b2fa], a
- call CloseSRAM
- ret
-
-SaveBattleTowerLevelGroup: ; 170868 (5c:4868) BattleTowerAction $07
- ld a, BANK(sBTChoiceOfLevelGroup)
- call GetSRAMBank
- ld a, [rSVBK]
- push af
- ld a, $3
- ld [rSVBK], a
- ld a, [wBTChoiceOfLvlGroup]
- ld [sBTChoiceOfLevelGroup], a
- pop af
- ld [rSVBK], a
- call CloseSRAM
- ret
-
-LoadBattleTowerLevelGroup: ; 170881 (5c:4881) BattleTowerAction $08 ; Load level group choice
- ld a, BANK(sBTChoiceOfLevelGroup)
- call GetSRAMBank
- ld a, [rSVBK]
- push af
- ld a, $3
- ld [rSVBK], a
- ld a, [sBTChoiceOfLevelGroup]
- ld [wBTChoiceOfLvlGroup], a
- pop af
- ld [rSVBK], a
- call CloseSRAM
- ret
-
-BattleTower_CheckSaveFileExistsAndIsYours: ; 17089a BattleTowerAction $09
- ld a, [wSaveFileExists]
- and a
- jr z, .nope
- callba CompareLoadedAndSavedPlayerID
- jr z, .yes
- xor a
- jr .nope
-
-.yes
- ld a, $1
-
-.nope
- ld [ScriptVar], a
- ret
-; 1708b1
-
-
-Function1708b1: ; 1708b1 (5c:48b1) BattleTowerAction $0a
- xor a
- ld [MusicFade], a
- call MaxVolume
- ret
-
-CheckMobileEventIndex: ; 1708b9 (5c:48b9) BattleTowerAction $0b something to do with GS Ball
- ld a, BANK(sMobileEventIndex)
- call GetSRAMBank
- ld a, [sMobileEventIndex]
- ld [ScriptVar], a
- call CloseSRAM
- ret
-
-Function1708c8: ; 1708c8 (5c:48c8) BattleTowerAction $0c
- call UpdateTime
- ld a, $5
- call GetSRAMBank
- ld a, [CurDay]
- ld [$aa8b], a
- xor a
- ld [$aa8c], a
- ld a, [$aa5d]
- cp $2
- jr nc, .asm_1708ec
- ld a, [CurDay]
- ld [$aa48], a
- ld a, $1
- ld [$aa47], a
-.asm_1708ec
- call CloseSRAM
- ret
-
-Function1708f0: ; 1708f0 (5c:48f0) BattleTowerAction $0d
- xor a
- ld [ScriptVar], a
- call UpdateTime
- ld a, $5
- call GetSRAMBank
- ld a, [$aa48]
- ld c, a
- ld a, [$aa47]
- call CloseSRAM
- and a
- ret z
- ld hl, CurDay
- ld a, c
- cp [hl]
- jr nz, Function170923
- ld a, $5
- call GetSRAMBank
- ld a, [$aa5d]
- call CloseSRAM
- cp $5
- ret c
- ld a, $1
- ld [ScriptVar], a
- ret
-
-
-Function170923: ; 170923
- ld a, $5
- call GetSRAMBank
- xor a
- ld [$aa48], a
- ld [$aa47], a
- ld hl, $aa5d
- ld bc, $0011
- call ByteFill
- call CloseSRAM
- ret
-; 17093c
-
-
-BattleTowerAction_EggTicket: ; 17093c (5c:493c) BattleTowerAction $0e
- xor a
- ld [ScriptVar], a
- ld a, EGG_TICKET
- ld [CurItem], a
- ld hl, NumItems
- call CheckItem
- ret nc
- ld a, [PartyCount]
- ld b, 0
- ld c, a
- ld hl, PartySpecies
-.loop
- ld a, [hli]
- cp EGG
- jr nz, .not_egg
- push hl
- ld hl, PartyMonOT
- ld de, $6 ; NAME_LENGTH
- ld a, b
- and a
- jr z, .skip
-.loop2
- add hl, de
- dec a
- jr nz, .loop2
-.skip
- ld de, String_1709a4
- ld a, $6 ; NAME_LENGTH
-.compare_loop
- push af
- ld a, [de]
- inc de
- cp [hl]
- inc hl
- jr nz, .different
- pop af
- dec a
- jr nz, .compare_loop
-rept 4
- dec hl
-endr
- ld a, "@"
- ld [hli], a
- ld [hli], a
- pop hl
- ld a, EGG_TICKET
- ld [CurItem], a
- ld a, 1
- ld [wItemQuantityChangeBuffer], a
- ld a, -1
- ld [CurItemQuantity], a
- ld hl, NumItems
- call TossItem
- ld a, $1
- ld [ScriptVar], a
- ret
-
-.different
- pop af
- pop hl
-.not_egg
- inc b
- dec c
- jr nz, .loop
- ret
-; 1709a4 (5c:49a4)
-
-String_1709a4: ; 1709a4
- db "なぞナゾ@@"
-
-Function1709aa: ; 1709aa (5c:49aa) BattleTowerAction $0f
- ld a, [rSVBK]
- push af
- ld a, BANK(w3_d090)
- ld [rSVBK], a
- ld a, [w3_d090]
- ld [ScriptVar], a
- pop af
- ld [rSVBK], a
- ret
-
-Function1709bb: ; 1709bb (5c:49bb) BattleTowerAction $10
- xor a
- ld [ScriptVar], a
- ld a, $5
- call GetSRAMBank
- ld a, [$a800]
- call CloseSRAM
- cp 6
- jr nc, .invalid
- ld e, a
- ld d, 0
- ld hl, Jumptable_1709e7
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp hl
-
-.invalid
- ld a, $5
- call GetSRAMBank
- xor a
- ld [$a800], a
- call CloseSRAM
- ret
-; 1709e7 (5c:49e7)
-
-Jumptable_1709e7: ; 1709e7
- dw .NoAction
- dw .NoAction
- dw .DoAction1
- dw .DoAction1
- dw .Action4
- dw .Action5
-; 1709f3
-
-.DoAction1: ; 1709f3
- ld a, $5
- call GetSRAMBank
- ld a, $1
- ld [$a800], a
- call CloseSRAM
-
-.NoAction: ; 170a00
- ret
-; 170a01
-
-.Action4: ; 170a01
- ld a, $5
- call GetSRAMBank
- ld hl, $b023
- ld de, wMisc
- ld bc, $0069
- call CopyBytes
- ld a, [$a825]
- ld [wcd30], a
- ld a, [$a826]
- ld [wcd31], a
- call CloseSRAM
- callba Function11b6b4
- callba Function17d0f3
- ld a, $1
- ld [ScriptVar], a
- ret
-; 170a33
-
-.Action5: ; 170a33
- ld a, $0
- call GetSRAMBank
- ld hl, wRTC
- ld de, wMisc
- ld bc, $0004
- call CopyBytes
- call CloseSRAM
- ld a, $5
- call GetSRAMBank
- ld hl, $b08c
- ld de, wMisc
- ld c, $4
-.compare_loop
- ld a, [de]
- inc de
- cp [hl]
- jr nz, .different
- inc hl
- dec c
- jr nz, .compare_loop
- call CloseSRAM
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
- call GetMapTrigger
- ld a, d
- or e
- jr z, .no_trigger
- ld a, [de]
- and a
- ret nz
-
-.no_trigger
- ld a, $1
- ld [ScriptVar], a
- ret
-
-.different
- call CloseSRAM
- ld a, $5
- call GetSRAMBank
- xor a
- ld [$a800], a
- call CloseSRAM
- ld [ScriptVar], a
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
- call GetMapTrigger
- ld a, d
- or e
- jr z, .no_trigger_2
- xor a
- ld [de], a
-
-.no_trigger_2
- ret
-; 170a9c
-
-Function170a9c: ; 170a9c (5c:4a9c) BattleTowerAction $11
- ld c, $0
- jr asm_170aa2
-
-Function170aa0: ; 170aa0 (5c:4aa0) BattleTowerAction $12
- ld c, $1
-asm_170aa2: ; 170aa2 (5c:4aa2)
- ld a, $5
- call GetSRAMBank
- ld a, c
- ld [$aa8d], a
- call CloseSRAM
- ret
-
-Function170aaf: ; 170aaf (5c:4aaf) BattleTowerAction $13
- ld a, $5
- call GetSRAMBank
- ld a, [$aa8d]
- ld [ScriptVar], a
- call CloseSRAM
- ret
-
-Function170abe: ; 170abe (5c:4abe) BattleTowerAction $14
- call BattleTower_CheckSaveFileExistsAndIsYours
- ld a, [ScriptVar]
- and a
- ret z
-
- ld a, BANK(s1_be4f)
- call GetSRAMBank
- ld a, [s1_be4f]
- and $1
- ld [ScriptVar], a
- call CloseSRAM
- ret
-
-Function170ad7: ; 170ad7 (5c:4ad7) BattleTowerAction $15
- ld a, BANK(s1_be4f)
- call GetSRAMBank
- ld a, [s1_be4f]
- or $1
- ld [s1_be4f], a
- call CloseSRAM
- ret
-
-BattleTowerAction_LevelCheck: ; 170ae8 (5c:4ae8) BattleTowerAction $18
- ld a, $5
- call GetSRAMBank
- ld a, [$b2fb]
- call CloseSRAM
- ld c, 10
- call SimpleDivide
- ld a, b
- ld [wcd4f], a
- xor a
- ld [ScriptVar], a
- callba BattleTower_LevelCheck ; level check
- ret nc
- ld a, $5
- call GetSRAMBank
- ld a, [$b2fb]
- call CloseSRAM
- ld [ScriptVar], a
- ret
-
-BattleTowerAction_UbersCheck: ; 170b16 (5c:4b16) BattleTowerAction $19
- ld a, $5
- call GetSRAMBank
- ld a, [$b2fb]
- call CloseSRAM
- ld c, 10
- call SimpleDivide
- ld a, b
- ld [wcd4f], a
- xor a
- ld [ScriptVar], a
- callba BattleTower_UbersCheck
- ret nc
- ld a, $5
- call GetSRAMBank
- ld a, [$b2fb]
- 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/crystal_misc.asm
+++ /dev/null
@@ -1,931 +1,0 @@
-INCLUDE "includes.asm"
-
-
-SECTION "Misc Crystal", ROMX
-
-MobileAdapterGFX::
-INCBIN "gfx/mobile/mobile_adapter.2bpp"
-
-
-Function17a68f:: ; 17a68f (5e:668f)
- call Function17a6a8
- call Function17a751
- ld hl, $d088
- bit 5, [hl]
- jr z, .asm_17a6a6
- ld de, StringBuffer1 ; $d073
- push de
- call Function17a721
- pop de
- xor a
- ret
-
-.asm_17a6a6
- scf
- ret
-
-Function17a6a8: ; 17a6a8 (5e:66a8)
- push de
- push bc
- ld hl, StringBuffer2 ; $d086
- ld bc, $a
- xor a
- call ByteFill
- ld hl, Buffer1
- ld bc, $10
- ld a, $ff
- call ByteFill
- pop bc
- ld a, c
- and a
- jr z, .asm_17a6c9
- ld hl, $d088
- set 4, [hl]
-.asm_17a6c9
- pop de
- call Function17a6f5
- call Function17aba0
- callba Function106464
- call Function17ac0c
- callba HDMATransferAttrMapAndTileMapToWRAMBank3
- call Function17abcf
- callba LoadOW_BGPal7
- callba Function49420
- call SetPalettes
- call DelayFrame
- ret
-
-Function17a6f5: ; 17a6f5 (5e:66f5)
- ld hl, Buffer1
- ld c, $0
- ld b, $8
-.asm_17a6fc
- ld a, [de]
- call Function17a713
- jr c, .asm_17a70e
- ld a, [de]
- swap a
- call Function17a713
- jr c, .asm_17a70e
- inc de
- dec b
- jr nz, .asm_17a6fc
-.asm_17a70e
- ld a, c
- ld [$d08c], a
- ret
-
-Function17a713: ; 17a713 (5e:6713)
- and $f
- cp $a
- jr nc, .asm_17a71d
- ld [hli], a
- inc c
- and a
- ret
-
-.asm_17a71d
- ld [hl], $ff
- scf
- ret
-
-Function17a721: ; 17a721 (5e:6721)
- push de
- ld h, d
- ld l, e
- ld bc, $8
- ld a, $ff
- call ByteFill
- pop de
- ld hl, Buffer1
- ld b, $8
-.asm_17a732
- ld c, $0
- ld a, [hli]
- cp $a
- jr nc, .asm_17a748
- ld c, a
- ld a, [hli]
- cp $a
- jr nc, .asm_17a74c
- swap a
- or c
- ld [de], a
- inc de
- dec b
- jr nz, .asm_17a732
- ret
-
-.asm_17a748
- ld a, $ff
- ld [de], a
- ret
-
-.asm_17a74c
- ld a, $f0
- or c
- ld [de], a
- ret
-
-Function17a751: ; 17a751 (5e:6751)
- xor a
- ld [$d087], a
-.asm_17a755
- call Function17a781
- call Function17a7ae
- call Function17a97b
- call Function17a770
- call Function17a78f
- ld hl, $d08f
- inc [hl]
- ld a, [$d087]
- bit 7, a
- jr z, .asm_17a755
- ret
-
-Function17a770: ; 17a770 (5e:6770)
- ld a, [hOAMUpdate]
- push af
- ld a, $1
- ld [hOAMUpdate], a
- call HideSprites
- call Function17a9cb
- pop af
- ld [hOAMUpdate], a
- ret
-
-Function17a781: ; 17a781 (5e:6781)
- ld a, [hInMenu]
- push af
- ld a, $1
- ld [hInMenu], a
- call JoyTextDelay
- pop af
- ld [hInMenu], a
- ret
-
-Function17a78f: ; 17a78f (5e:678f)
- ld hl, $d088
- bit 7, [hl]
- res 7, [hl]
- jr nz, .asm_17a79f
- callba HDMATransferTileMapToWRAMBank3
- ret
-
-.asm_17a79f
- callba ReloadMapPart
- ret
-; 17a7a6 (5e:67a6)
-
-Function17a7a6: ; 17a7a6
- ld a, [$d087]
- inc a
- ld [$d087], a
- ret
-
-Function17a7ae: ; 17a7ae (5e:67ae)
- ld a, [$d087]
- ld hl, Jumptable_17a7b6
- rst JumpTable
- ret
-
-Jumptable_17a7b6: ; 17a7b6 (5e:67b6)
- dw Function17a7c2
- dw Function17a7cd
- dw Function17a7d8
- dw Function17a7ff
- dw Function17a81a
- dw Function17a7f4
-
-
-Function17a7c2: ; 17a7c2 (5e:67c2)
- ld a, $4
- call Function17aad3
- ld a, $1
- ld [$d087], a
- ret
-
-Function17a7cd: ; 17a7cd (5e:67cd)
- call Function17a83c
- call Function17a8ae
- ret c
- call Function17a848
- ret
-
-Function17a7d8: ; 17a7d8 (5e:67d8)
- call Function17a83c
- call Function17a848
- ld hl, $d08b
- dec [hl]
- ret nz
- call Function17ac1d
- call Function17ac2a
- ld hl, $d088
- set 7, [hl]
- ld a, $1
- ld [$d087], a
- ret
-
-Function17a7f4: ; 17a7f4 (5e:67f4)
- ld hl, $d08b
- dec [hl]
- ret nz
- ld hl, $d087
- set 7, [hl]
- ret
-
-Function17a7ff: ; 17a7ff (5e:67ff)
- ld hl, $d08b
- dec [hl]
- ret nz
- call Function17ac1d
- call Function17ac2a
- ld hl, $d088
- set 7, [hl]
- ld hl, $d088
- set 5, [hl]
- ld hl, $d087
- set 7, [hl]
- ret
-
-Function17a81a: ; 17a81a (5e:681a)
- call IsSFXPlaying
- ret nc
- ld a, [hJoyPressed]
- and $3
- ret z
- call ExitMenu
- call Function17ac1d
- call Function17ac2a
- ld hl, $d088
- set 7, [hl]
- ld hl, $d088
- res 6, [hl]
- ld a, $1
- ld [$d087], a
- ret
-
-Function17a83c: ; 17a83c (5e:683c)
- ld a, [hJoyLast]
- and $f0
- ld c, a
- ld a, [hJoyPressed]
- and $b
- or c
- ld c, a
- ret
-
-Function17a848: ; 17a848 (5e:6848)
- ld a, c
- and $60
- cp $60
- jr z, .asm_17a876
- ld a, c
- and $50
- cp $50
- jr z, .asm_17a87d
- ld a, c
- and $a0
- cp $a0
- jr z, .asm_17a884
- ld a, c
- and $90
- cp $90
- jr z, .asm_17a88b
- bit 6, c
- jr nz, .asm_17a892
- bit 7, c
- jr nz, .asm_17a899
- bit 5, c
- jr nz, .asm_17a8a0
- bit 4, c
- jr nz, .asm_17a8a7
- xor a
- ret
-
-.asm_17a876
- ld a, $9
- call Function17aad0
- scf
- ret
-
-.asm_17a87d
- ld a, $a
- call Function17aad0
- scf
- ret
-
-.asm_17a884
- ld a, $b
- call Function17aad0
- scf
- ret
-
-.asm_17a88b
- ld a, $c
- call Function17aad0
- scf
- ret
-
-.asm_17a892
- ld a, $5
- call Function17aad0
- scf
- ret
-
-.asm_17a899
- ld a, $6
- call Function17aad0
- scf
- ret
-
-.asm_17a8a0
- ld a, $7
- call Function17aad0
- scf
- ret
-
-.asm_17a8a7
- ld a, $8
- call Function17aad0
- scf
- ret
-
-Function17a8ae: ; 17a8ae (5e:68ae)
- bit 1, c
- jr nz, .asm_17a8bc
- bit 0, c
- jr nz, .asm_17a8cc
- bit 3, c
- jr nz, .asm_17a8d7
- xor a
- ret
-
-.asm_17a8bc
- ld a, $b
- ld [$d08a], a
- call Function17aa98
- call Function17a943
- call Function17aa88
- scf
- ret
-
-.asm_17a8cc
- call Function17aad7
- call Function17aa98
- call Function17a8de
- scf
- ret
-
-.asm_17a8d7
- ld a, $c
- call Function17aad3
- scf
- ret
-
-Function17a8de: ; 17a8de (5e:68de)
- ld a, $2
- call Function17aae0
- ld a, [hl]
- cp $f1
- jr z, .asm_17a8fd
- cp $f0
- jr z, .asm_17a904
- cp $f2
- jr z, .asm_17a911
- ld e, a
- call Function17a964
- ld a, $2
- ld [$d087], a
- call Function17aa88
- ret
-
-.asm_17a8fd
- call Function17a943
- call Function17aa88
- ret
-
-.asm_17a904
- call Function17aad7
- call Function17aa98
- call Function17a91e
- call Function17aa88
- ret
-
-.asm_17a911
- call Function17aa98
- ld a, $5
- ld [$d087], a
- xor a
- call Function17aa88
- ret
-
-Function17a91e: ; 17a91e (5e:691e)
- ld a, [$d08c]
- cp $7
- jr c, .asm_17a92c
- ld a, $3
- ld [$d087], a
- xor a
- ret
-
-.asm_17a92c
- call LoadStandardMenuDataHeader
- call Function17a99e
- ld hl, $d088
- set 7, [hl]
- ld hl, $d088
- set 6, [hl]
- ld a, $4
- ld [$d087], a
- scf
- ret
-
-Function17a943: ; 17a943 (5e:6943)
- ld a, [$d08c]
- and a
- jr z, .asm_17a95d
- dec a
- ld [$d08c], a
- ld c, a
- ld b, $0
- ld hl, Buffer1
- add hl, bc
- ld [hl], $ff
- ld a, $2
- ld [$d087], a
- and a
- ret
-
-.asm_17a95d
- ld a, $5
- ld [$d087], a
- xor a
- ret
-
-Function17a964: ; 17a964 (5e:6964)
- ld a, [$d08c]
- cp $10
- jr nc, .asm_17a979
- ld c, a
- ld b, $0
- inc a
- ld [$d08c], a
- ld hl, Buffer1
- add hl, bc
- ld [hl], e
- and a
- ret
-
-.asm_17a979
- scf
- ret
-
-Function17a97b: ; 17a97b (5e:697b)
- hlcoord 1, 1
- lb bc, 2, 18
- call ClearBox
- hlcoord 3, 2
- ld de, Buffer1
- ld a, [$d08c]
- and a
- ret z
- ld c, a
-.asm_17a990
- ld a, [de]
- inc de
- cp $a
- jr nc, .asm_17a99d
- add $f6
- ld [hli], a
- dec c
- jr nz, .asm_17a990
- ret
-
-.asm_17a99d
- ret
-
-Function17a99e: ; 17a99e (5e:699e)
- hlcoord 0, 12
- ld b, $4
- ld c, $12
- call Function17ac46
- hlcoord 2, 14
- ld de, String_17a9b2
- call PlaceString
- ret
-; 17a9b2 (5e:69b2)
-
-String_17a9b2: ; 17a9b2
- db "でんわばんごうが ただしく"
- next "はいって いません!"
- db "@"
-; 17a9cb
-
-Function17a9cb: ; 17a9cb (5e:69cb)
- ld de, Sprites ; $c400
- ld hl, $d088
- bit 6, [hl]
- jr nz, .bit_6_set
- call Function17a9e3
- call Function17aa22
- call Function17a9f5
- ret
-
-.bit_6_set
- call Function17a9e3
- ret
-
-Function17a9e3: ; 17a9e3 (5e:69e3)
- ld a, $3
- ld [$d08e], a
- ld hl, Unknown_17aa77
- ld b, $8
- ld c, $8
- ld a, $5
- call Function17aa4a
- ret
-
-Function17a9f5: ; 17a9f5 (5e:69f5)
- ld a, [$d08c]
- cp $10
- ret nc
- ld a, [$d08f]
- swap a
- and $1
- add $1
- ld [$d08e], a
- ld a, [$d08c]
- cp $10
- jr c, .okay
- dec a
-.okay
- ld c, $8
- call SimpleMultiply
- add $18
- ld b, a
- ld c, $11
- ld hl, Unknown_17aa72
- ld a, $4
- call Function17aa4a
- ret
-
-Function17aa22: ; 17aa22 (5e:6a22)
- ld a, $0
- ld [$d08e], a
- push de
- ld a, $3
- call Function17aae0
- add a
- add a
- add a
- add $0
- push af
- ld a, $4
- call Function17aae0
- add a
- add a
- add a
- add $8
- ld c, a
- pop af
- ld b, a
- pop de
- ld a, $0
- ld hl, Unknown_17aa77
- call Function17aa4a
- ret
-
-Function17aa4a: ; 17aa4a (5e:6a4a)
- ld [$d08d], a
- ld a, b
- add $8
- ld b, a
- ld a, c
- add $10
- ld c, a
- ld a, [hli]
-.loop
- push af
- ld a, [hli]
- add c
- ld [de], a
- inc de
- ld a, [hli]
- add b
- ld [de], a
- inc de
- ld a, [$d08d]
- add [hl]
- inc hl
- ld [de], a
- inc de
- ld a, [$d08e]
- or [hl]
- inc hl
- ld [de], a
- inc de
- pop af
- dec a
- jr nz, .loop
- ret
-; 17aa72 (5e:6a72)
-
-Unknown_17aa72: ; 17aa72
- db 1
- db 0, 0, 0, 0
-; 17aa77
-
-Unknown_17aa77: ; 17aa77
- db 4
- db 0, 0, 0, 0
- db 0, 8, 1, 0
- db 8, 0, 2, 0
- db 8, 8, 3, 0
-; 17aa88
-
-Function17aa88: ; 17aa88 (5e:6a88)
- jr c, asm_17aa91
- ld de, SFX_SWITCH_POKEMON
- call PlaySFX
- ret
-
-asm_17aa91: ; 17aa91 (5e:6a91)
- ld de, SFX_WRONG
- call PlaySFX
- ret
-
-Function17aa98: ; 17aa98 (5e:6a98)
- ld a, $5
- ld [$d08b], a
- call Function17aaa9
- call Function17aac3
- ld hl, $d088
- set 7, [hl]
- ret
-
-Function17aaa9: ; 17aaa9 (5e:6aa9)
- ld a, $3
- call Function17aae3
- ld c, a
- ld b, $0
- hlcoord 0, 0, AttrMap
- add hl, bc
- push hl
- ld a, $4
- call Function17aae3
- ld bc, $14
- pop hl
- call AddNTimes
- ret
-
-Function17aac3: ; 17aac3 (5e:6ac3)
- ld a, $b
- push hl
- ld [hli], a
- ld [hli], a
- pop hl
- ld de, SCREEN_WIDTH
- add hl, de
- ld [hli], a
- ld [hli], a
- ret
-
-Function17aad0: ; 17aad0 (5e:6ad0)
- call Function17aae0
-
-Function17aad3: ; 17aad3 (5e:6ad3)
- ld [$d089], a
- ret
-
-Function17aad7: ; 17aad7 (5e:6ad7)
- push af
- ld a, [$d089]
- ld [$d08a], a
- pop af
- ret
-
-Function17aae0: ; 17aae0 (5e:6ae0)
- call Function17aad7
-
-Function17aae3: ; 17aae3 (5e:6ae3)
- push af
- ld a, [$d08a]
- ld bc, $d
- ld hl, Unknown_17aaf7
- call AddNTimes
- pop af
- ld c, a
- ld b, $0
- add hl, bc
- ld a, [hl]
- ret
-; 17aaf7 (5e:6af7)
-
-Unknown_17aaf7: ; 17aaf7
- db $0, $0, $1, $6, $5, $9, $3, $2, $1, $2, $1, $2, $4
- db $0, $0, $2, $9, $5, $a, $4, $0, $2, $a, $a, $3, $5
- db $0, $0, $3, $c, $5, $b, $5, $1, $0, $1, $0, $4, $0
- db $0, $0, $4, $6, $8, $0, $6, $5, $4, $5, $1, $5, $7
- db $0, $0, $5, $9, $8, $1, $7, $3, $5, $0, $2, $6, $8
- db $0, $0, $6, $c, $8, $2, $8, $4, $3, $1, $3, $7, $3
- db $0, $0, $7, $6, $b, $3, $9, $8, $7, $8, $4, $8, $a
- db $0, $0, $8, $9, $b, $4, $a, $6, $8, $3, $5, $9, $b
- db $0, $0, $9, $c, $b, $5, $b, $7, $6, $4, $6, $a, $6
- db $0, $0,$f2, $6, $e, $6, $0, $c, $a, $c, $7, $c, $0
- db $0, $0, $0, $9, $e, $7, $1, $9, $b, $6, $8, $1, $1
- db $0, $0,$f1, $c, $e, $8, $2, $a, $c, $7, $c, $2, $c
- db $0, $0,$f0,$10, $e, $c, $c, $b, $9, $b, $9, $b, $9
-; 17aba0
-
-Function17aba0: ; 17aba0 (5e:6ba0)
- ld a, [rVBK]
- push af
- ld a, $1
- ld [rVBK], a
-
- ld hl, VTiles5 tile $00
- ld de, GFX_17afa5
- lb bc, BANK(GFX_17afa5), $80
- call Get2bpp
-
- pop af
- ld [rVBK], a
-
- ld hl, VTiles0 tile $00
- ld de, GFX_17afa5 + $4c0
- lb bc, BANK(GFX_17afa5), 5
- call Get2bpp
-
- ld hl, VTiles0 tile $05
- ld de, GFX_11601a
- lb bc, BANK(GFX_11601a), 4
- call Get2bpp
- ret
-
-Function17abcf: ; 17abcf (5e:6bcf)
- ld a, [rSVBK]
- push af
- ld a, BANK(UnknBGPals)
- ld [rSVBK], a
-
- ld hl, Palette_17ac55
- ld de, UnknBGPals ; $d000
- ld bc, $30
- call CopyBytes
-
- ld hl, Palette_17ac95
- ld de, UnknOBPals
- ld bc, $40
- call CopyBytes
-
- ld hl, GFX_17afa5 + $510
- ld de, UnknOBPals + 2 * 4
- ld bc, $10
- call CopyBytes
-
- ld hl, MapObjectPals + 8
- ld de, UnknOBPals + 6 * 4
- ld bc, $8
- ld a, BANK(MapObjectPals)
- call FarCopyBytes
-
- pop af
- ld [rSVBK], a
- ret
-
-Function17ac0c: ; 17ac0c (5e:6c0c)
- call Function17ac1d
- call Function17ac2a
- hlcoord 0, 0
- ld b, 2
- ld c, SCREEN_WIDTH - 2
- call Function17ac46
- ret
-
-Function17ac1d: ; 17ac1d (5e:6c1d)
- ld hl, Tilemap_17acd5
- decoord 0, 4
- ld bc, (SCREEN_HEIGHT - 4) * SCREEN_WIDTH
- call CopyBytes
- ret
-
-Function17ac2a: ; 17ac2a (5e:6c2a)
- ld hl, Tilemap_17ae3d
- decoord 0, 4, AttrMap
- ld bc, (SCREEN_HEIGHT - 4) * SCREEN_WIDTH
- call CopyBytes
- hlcoord 0, 4, AttrMap
- ld bc, (SCREEN_HEIGHT - 4) * SCREEN_WIDTH
-.loop
- ld a, [hl]
- or $8
- ld [hli], a
- dec bc
- ld a, b
- or c
- jr nz, .loop
- ret
-
-Function17ac46: ; 17ac46 (5e:6c46)
- ld a, [$d088]
- bit 4, a
- jr nz, .bit_4_set
- call TextBox
- ret
-
-.bit_4_set
- call Function3eea
- ret
-; 17ac55 (5e:6c55)
-
-Palette_17ac55: ; 17ac55
- RGB 0, 0, 0
- RGB 9, 10, 25
- RGB 16, 19, 31
- RGB 31, 31, 31
-
- RGB 5, 11, 9
- RGB 7, 14, 12
- RGB 17, 24, 22
- RGB 28, 31, 31
-
- RGB 0, 0, 0
- RGB 3, 0, 10
- RGB 3, 3, 16
- RGB 6, 8, 25
-
- RGB 5, 11, 9
- RGB 28, 31, 31
- RGB 7, 14, 12
- RGB 17, 24, 22
-
- RGB 0, 0, 0
- RGB 5, 2, 16
- RGB 8, 8, 26
- RGB 13, 9, 17
-
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
-
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
-
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
- RGB 0, 0, 0
-
-Palette_17ac95: ; 17ac95
- RGB 31, 31, 31
- RGB 4, 3, 3
- RGB 31, 13, 0
- RGB 31, 31, 31
-
- RGB 31, 31, 31
- RGB 0, 0, 0
- RGB 31, 31, 31
- RGB 31, 31, 31
-
- RGB 31, 0, 0
- RGB 16, 3, 0
- RGB 28, 19, 11
- RGB 31, 31, 31
-
- RGB 31, 16, 0
- RGB 9, 6, 4
- RGB 31, 16, 0
- RGB 31, 24, 0
-
- RGB 31, 18, 6
- RGB 0, 3, 0
- RGB 0, 9, 0
- RGB 0, 12, 0
-
- RGB 0, 16, 0
- RGB 0, 22, 0
- RGB 0, 25, 0
- RGB 0, 27, 0
-
- RGB 0, 31, 0
- RGB 3, 31, 0
- RGB 8, 31, 0
- RGB 14, 31, 0
-
- RGB 16, 31, 0
- RGB 22, 31, 0
- RGB 27, 31, 0
- RGB 31, 31, 0
-
-Tilemap_17acd5: ; 17acd5
-INCBIN "gfx/unknown/17acd5.tilemap"
-
-Tilemap_17ae3d: ; 17ae3d
-INCBIN "gfx/unknown/17ae3d.tilemap"
-
-GFX_17afa5:: ; 17afa5
-INCBIN "gfx/unknown/17afa5.2bpp"
binary files a/misc/stadium2_1.bin /dev/null differ
binary files a/misc/stadium2_2.bin /dev/null differ
--- /dev/null
+++ b/mobile/battle_tower_47.asm
@@ -1,0 +1,784 @@
+BattleTowerText:: ; 11c000
+; Print text c for trainer [BT_OTTrainerClass]
+; 1: Intro text
+; 2: Player lost
+; 3: Player won
+ ld a, [rSVBK]
+ push af
+ ld a, 3 ; BANK(BT_OTTrainerClass)
+ ld [rSVBK], a
+IF DEF(CRYSTAL11)
+ ld hl, BT_OTTrainerClass
+ELSE
+ ld hl, BT_OTName + 5
+; BUG ALERT
+; Instead of loading the Trainer Class, this routine
+; loads the 6th character in the Trainer's name, then
+; uses it to get the gender of the trainer.
+; As a consequence, the enemy trainer's dialog will
+; always be sampled from the female array.
+ENDC
+ ld a, [hl]
+ dec a
+ ld e, a
+ ld d, 0
+ ld hl, BTTrainerClassGenders
+ add hl, de
+ ld a, [hl]
+ and a
+ jr nz, .female
+ ; generate a random number between 0 and 24
+ ld a, [hRandomAdd]
+ and $1f
+ cp 25
+ jr c, .okay0
+ sub 25
+
+.okay0
+ ld hl, BTMaleTrainerTexts
+ jr .proceed
+
+.female
+ ; generate a random number between 0 and 14
+ ld a, [hRandomAdd]
+ and $f
+ cp 15
+ jr c, .okay1
+ sub 15
+
+.okay1
+ ld hl, BTFemaleTrainerTexts
+
+.proceed
+ ld b, 0
+ dec c
+ jr nz, .restore
+ ld [BT_TrainerTextIndex], a
+ jr .okay2
+
+.restore
+ ld a, [BT_TrainerTextIndex]
+
+.okay2
+ push af
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld c, a
+ ld a, [hl]
+ ld h, a
+ ld l, c
+ pop af
+ ld c, a
+ ld b, 0
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld c, a
+ ld a, [hl]
+ ld l, c
+ ld h, a
+ bccoord 1, 14
+ pop af
+ ld [rSVBK], a
+ call PlaceHLTextAtBC
+ ret
+; 11c05d
+
+INCLUDE "mobile/fixed_words.asm"
+
+BTTrainerClassGenders: ; 11f2f0
+ db MALE ; FALKNER
+ db FEMALE ; WHITNEY
+ db FEMALE ; BUGSY
+ db MALE ; MORTY
+ db MALE ; PRYCE
+ db FEMALE ; JASMINE
+ db MALE ; CHUCK
+ db FEMALE ; CLAIR
+ db MALE ; RIVAL1
+ db MALE ; POKEMON_PROF
+ db FEMALE ; WILL
+ db MALE ; CAL
+ db MALE ; BRUNO
+ db FEMALE ; KAREN
+ db MALE ; KOGA
+ db MALE ; CHAMPION
+ db MALE ; BROCK
+ db FEMALE ; MISTY
+ db MALE ; LT_SURGE
+ db MALE ; SCIENTIST
+ db FEMALE ; ERIKA
+ db MALE ; YOUNGSTER
+ db MALE ; SCHOOLBOY
+ db MALE ; BIRD_KEEPER
+ db FEMALE ; LASS
+ db FEMALE ; JANINE
+ db MALE ; COOLTRAINERM
+ db FEMALE ; COOLTRAINERF
+ db FEMALE ; BEAUTY
+ db MALE ; POKEMANIAC
+ db MALE ; GRUNTM
+ db MALE ; GENTLEMAN
+ db FEMALE ; SKIER
+ db FEMALE ; TEACHER
+ db FEMALE ; SABRINA
+ db MALE ; BUG_CATCHER
+ db MALE ; FISHER
+ db MALE ; SWIMMERM
+ db FEMALE ; SWIMMERF
+ db MALE ; SAILOR
+ db MALE ; SUPER_NERD
+ db MALE ; RIVAL2
+ db MALE ; GUITARIST
+ db MALE ; HIKER
+ db MALE ; BIKER
+ db MALE ; BLAINE
+ db MALE ; BURGLAR
+ db MALE ; FIREBREATHER
+ db MALE ; JUGGLER
+ db MALE ; BLACKBELT_T
+ db MALE ; EXECUTIVEM
+ db MALE ; PSYCHIC_T
+ db FEMALE ; PICNICKER
+ db MALE ; CAMPER
+ db FEMALE ; EXECUTIVEF
+ db MALE ; SAGE
+ db FEMALE ; MEDIUM
+ db MALE ; BOARDER
+ db MALE ; POKEFANM
+ db FEMALE ; KIMONO_GIRL
+ db FEMALE ; TWINS
+ db FEMALE ; POKEFANF
+ db MALE ; RED
+ db MALE ; BLUE
+ db MALE ; OFFICER
+ db FEMALE ; GRUNTF
+
+
+BTMaleTrainerTexts: ; 11f332
+ dw .Greetings
+ dw .PlayerLost
+ dw .PlayerWon
+
+.Greetings: ; 11f338
+ dw BTGreetingM1
+ dw BTGreetingM2
+ dw BTGreetingM3
+ dw BTGreetingM4
+ dw BTGreetingM5
+ dw BTGreetingM6
+ dw BTGreetingM7
+ dw BTGreetingM8
+ dw BTGreetingM9
+ dw BTGreetingM10
+ dw BTGreetingM11
+ dw BTGreetingM12
+ dw BTGreetingM13
+ dw BTGreetingM14
+ dw BTGreetingM15
+ dw BTGreetingM16
+ dw BTGreetingM17
+ dw BTGreetingM18
+ dw BTGreetingM19
+ dw BTGreetingM20
+ dw BTGreetingM21
+ dw BTGreetingM22
+ dw BTGreetingM23
+ dw BTGreetingM24
+ dw BTGreetingM25
+
+.PlayerLost: ; 11f36a
+ dw BTLossM1
+ dw BTLossM2
+ dw BTLossM3
+ dw BTLossM4
+ dw BTLossM5
+ dw BTLossM6
+ dw BTLossM7
+ dw BTLossM8
+ dw BTLossM9
+ dw BTLossM10
+ dw BTLossM11
+ dw BTLossM12
+ dw BTLossM13
+ dw BTLossM14
+ dw BTLossM15
+ dw BTLossM16
+ dw BTLossM17
+ dw BTLossM18
+ dw BTLossM19
+ dw BTLossM20
+ dw BTLossM21
+ dw BTLossM22
+ dw BTLossM23
+ dw BTLossM24
+ dw BTLossM25
+
+.PlayerWon: ; 11f39c
+ dw BTWinM1
+ dw BTWinM2
+ dw BTWinM3
+ dw BTWinM4
+ dw BTWinM5
+ dw BTWinM6
+ dw BTWinM7
+ dw BTWinM8
+ dw BTWinM9
+ dw BTWinM10
+ dw BTWinM11
+ dw BTWinM12
+ dw BTWinM13
+ dw BTWinM14
+ dw BTWinM15
+ dw BTWinM16
+ dw BTWinM17
+ dw BTWinM18
+ dw BTWinM19
+ dw BTWinM20
+ dw BTWinM21
+ dw BTWinM22
+ dw BTWinM23
+ dw BTWinM24
+ dw BTWinM25
+
+
+BTFemaleTrainerTexts:
+ dw .Greetings
+ dw .PlayerLost
+ dw .PlayerWon
+
+.Greetings: ; 11f3d4
+ dw BTGreetingF1
+ dw BTGreetingF2
+ dw BTGreetingF3
+ dw BTGreetingF4
+ dw BTGreetingF5
+ dw BTGreetingF6
+ dw BTGreetingF7
+ dw BTGreetingF8
+ dw BTGreetingF9
+ dw BTGreetingF10
+ dw BTGreetingF11
+ dw BTGreetingF12
+ dw BTGreetingF13
+ dw BTGreetingF14
+ dw BTGreetingF15
+
+.PlayerLost: ; 11f3f2
+ dw BTLossF1
+ dw BTLossF2
+ dw BTLossF3
+ dw BTLossF4
+ dw BTLossF5
+ dw BTLossF6
+ dw BTLossF7
+ dw BTLossF8
+ dw BTLossF9
+ dw BTLossF10
+ dw BTLossF11
+ dw BTLossF12
+ dw BTLossF13
+ dw BTLossF14
+ dw BTLossF15
+
+.PlayerWon: ; 11f410
+ dw BTWinF1
+ dw BTWinF2
+ dw BTWinF3
+ dw BTWinF4
+ dw BTWinF5
+ dw BTWinF6
+ dw BTWinF7
+ dw BTWinF8
+ dw BTWinF9
+ dw BTWinF10
+ dw BTWinF11
+ dw BTWinF12
+ dw BTWinF13
+ dw BTWinF14
+ dw BTWinF15
+
+
+BTGreetingM1: ; 0x11f42e
+ text_jump BattleTowerText_0x1ec000
+ db "@"
+
+BTLossM1: ; 0x11f433
+ text_jump BattleTowerText_0x1ec03b
+ db "@"
+
+BTWinM1: ; 0x11f438
+ text_jump UnknownText_0x1ec060
+ db "@"
+
+BTGreetingM2: ; 0x11f43d
+ text_jump BattleTowerText_0x1ec080
+ db "@"
+
+BTLossM2: ; 0x11f442
+ text_jump UnknownText_0x1ec0a3
+ db "@"
+
+BTWinM2: ; 0x11f447
+ text_jump UnknownText_0x1ec0c4
+ db "@"
+
+BTGreetingM3: ; 0x11f44c
+ text_jump UnknownText_0x1ec0e1
+ db "@"
+
+BTLossM3: ; 0x11f451
+ text_jump UnknownText_0x1ec108
+ db "@"
+
+BTWinM3: ; 0x11f456
+ text_jump UnknownText_0x1ec12a
+ db "@"
+
+BTGreetingM4: ; 0x11f45b
+ text_jump UnknownText_0x1ec14d
+ db "@"
+
+BTLossM4: ; 0x11f460
+ text_jump UnknownText_0x1ec16f
+ db "@"
+
+BTWinM4: ; 0x11f465
+ text_jump UnknownText_0x1ec190
+ db "@"
+
+BTGreetingM5: ; 0x11f46a
+ text_jump UnknownText_0x1ec1ae
+ db "@"
+
+BTLossM5: ; 0x11f46f
+ text_jump UnknownText_0x1ec1d0
+ db "@"
+
+BTWinM5: ; 0x11f474
+ text_jump UnknownText_0x1ec1f4
+ db "@"
+
+BTGreetingM6: ; 0x11f479
+ text_jump UnknownText_0x1ec216
+ db "@"
+
+BTLossM6: ; 0x11f47e
+ text_jump UnknownText_0x1ec238
+ db "@"
+
+BTWinM6: ; 0x11f483
+ text_jump UnknownText_0x1ec259
+ db "@"
+
+BTGreetingM7: ; 0x11f488
+ text_jump UnknownText_0x1ec27b
+ db "@"
+
+BTLossM7: ; 0x11f48d
+ text_jump UnknownText_0x1ec2a0
+ db "@"
+
+BTWinM7: ; 0x11f492
+ text_jump UnknownText_0x1ec2c0
+ db "@"
+
+BTGreetingM8: ; 0x11f497
+ text_jump UnknownText_0x1ec2d9
+ db "@"
+
+BTLossM8: ; 0x11f49c
+ text_jump UnknownText_0x1ec2fe
+ db "@"
+
+BTWinM8: ; 0x11f4a1
+ text_jump UnknownText_0x1ec320
+ db "@"
+
+BTGreetingM9: ; 0x11f4a6
+ text_jump UnknownText_0x1ec33f
+ db "@"
+
+BTLossM9: ; 0x11f4ab
+ text_jump UnknownText_0x1ec36c
+ db "@"
+
+BTWinM9: ; 0x11f4b0
+ text_jump UnknownText_0x1ec389
+ db "@"
+
+BTGreetingM10: ; 0x11f4b5
+ text_jump UnknownText_0x1ec3ad
+ db "@"
+
+BTLossM10: ; 0x11f4ba
+ text_jump UnknownText_0x1ec3c5
+ db "@"
+
+BTWinM10: ; 0x11f4bf
+ text_jump UnknownText_0x1ec3e5
+ db "@"
+
+BTGreetingM11: ; 0x11f4c4
+ text_jump UnknownText_0x1ec402
+ db "@"
+
+BTLossM11: ; 0x11f4c9
+ text_jump UnknownText_0x1ec411
+ db "@"
+
+BTWinM11: ; 0x11f4ce
+ text_jump UnknownText_0x1ec41f
+ db "@"
+
+BTGreetingM12: ; 0x11f4d3
+ text_jump UnknownText_0x1ec42e
+ db "@"
+
+BTLossM12: ; 0x11f4d8
+ text_jump UnknownText_0x1ec461
+ db "@"
+
+BTWinM12: ; 0x11f4dd
+ text_jump UnknownText_0x1ec4a0
+ db "@"
+
+BTGreetingM13: ; 0x11f4e2
+ text_jump UnknownText_0x1ec4d6
+ db "@"
+
+BTLossM13: ; 0x11f4e7
+ text_jump UnknownText_0x1ec4f5
+ db "@"
+
+BTWinM13: ; 0x11f4ec
+ text_jump UnknownText_0x1ec512
+ db "@"
+
+BTGreetingM14: ; 0x11f4f1
+ text_jump UnknownText_0x1ec532
+ db "@"
+
+BTLossM14: ; 0x11f4f6
+ text_jump UnknownText_0x1ec54b
+ db "@"
+
+BTWinM14: ; 0x11f4fb
+ text_jump UnknownText_0x1ec565
+ db "@"
+
+BTGreetingM15: ; 0x11f500
+ text_jump UnknownText_0x1ec580
+ db "@"
+
+BTLossM15: ; 0x11f505
+ text_jump UnknownText_0x1ec59d
+ db "@"
+
+BTWinM15: ; 0x11f50a
+ text_jump UnknownText_0x1ec5b5
+ db "@"
+
+BTGreetingM16: ; 0x11f50f
+ text_jump UnknownText_0x1ec5d3
+ db "@"
+
+BTLossM16: ; 0x11f514
+ text_jump UnknownText_0x1ec5ee
+ db "@"
+
+BTWinM16: ; 0x11f519
+ text_jump UnknownText_0x1ec60d
+ db "@"
+
+BTGreetingM17: ; 0x11f51e
+ text_jump UnknownText_0x1ec631
+ db "@"
+
+BTLossM17: ; 0x11f523
+ text_jump UnknownText_0x1ec651
+ db "@"
+
+BTWinM17: ; 0x11f528
+ text_jump UnknownText_0x1ec68f
+ db "@"
+
+BTGreetingM18: ; 0x11f52d
+ text_jump UnknownText_0x1ec6b1
+ db "@"
+
+BTLossM18: ; 0x11f532
+ text_jump UnknownText_0x1ec6d0
+ db "@"
+
+BTWinM18: ; 0x11f537
+ text_jump UnknownText_0x1ec708
+ db "@"
+
+BTGreetingM19: ; 0x11f53c
+ text_jump UnknownText_0x1ec720
+ db "@"
+
+BTLossM19: ; 0x11f541
+ text_jump UnknownText_0x1ec73e
+ db "@"
+
+BTWinM19: ; 0x11f546
+ text_jump UnknownText_0x1ec75b
+ db "@"
+
+BTGreetingM20: ; 0x11f54b
+ text_jump UnknownText_0x1ec77f
+ db "@"
+
+BTLossM20: ; 0x11f550
+ text_jump UnknownText_0x1ec798
+ db "@"
+
+BTWinM20: ; 0x11f555
+ text_jump UnknownText_0x1ec7bb
+ db "@"
+
+BTGreetingM21: ; 0x11f55a
+ text_jump UnknownText_0x1ec7d8
+ db "@"
+
+BTLossM21: ; 0x11f55f
+ text_jump UnknownText_0x1ec818
+ db "@"
+
+BTWinM21: ; 0x11f564
+ text_jump UnknownText_0x1ec837
+ db "@"
+
+BTGreetingM22: ; 0x11f569
+ text_jump UnknownText_0x1ec858
+ db "@"
+
+BTLossM22: ; 0x11f56e
+ text_jump UnknownText_0x1ec876
+ db "@"
+
+BTWinM22: ; 0x11f573
+ text_jump UnknownText_0x1ec898
+ db "@"
+
+BTGreetingM23: ; 0x11f578
+ text_jump UnknownText_0x1ec8b1
+ db "@"
+
+BTLossM23: ; 0x11f57d
+ text_jump UnknownText_0x1ec8d5
+ db "@"
+
+BTWinM23: ; 0x11f582
+ text_jump UnknownText_0x1ec8f0
+ db "@"
+
+BTGreetingM24: ; 0x11f587
+ text_jump UnknownText_0x1ec911
+ db "@"
+
+BTLossM24: ; 0x11f58c
+ text_jump UnknownText_0x1ec928
+ db "@"
+
+BTWinM24: ; 0x11f591
+ text_jump UnknownText_0x1ec949
+ db "@"
+
+BTGreetingM25: ; 0x11f596
+ text_jump UnknownText_0x1ec969
+ db "@"
+
+BTLossM25: ; 0x11f59b
+ text_jump UnknownText_0x1ec986
+ db "@"
+
+BTWinM25: ; 0x11f5a0
+ text_jump UnknownText_0x1ec99b
+ db "@"
+
+
+
+
+BTGreetingF1: ; 0x11f5a5
+ text_jump UnknownText_0x1ec9bd
+ db "@"
+
+BTLossF1: ; 0x11f5aa
+ text_jump UnknownText_0x1ec9d9
+ db "@"
+
+BTWinF1: ; 0x11f5af
+ text_jump UnknownText_0x1ec9f7
+ db "@"
+
+BTGreetingF2: ; 0x11f5b4
+ text_jump UnknownText_0x1eca0a
+ db "@"
+
+BTLossF2: ; 0x11f5b9
+ text_jump UnknownText_0x1eca2a
+ db "@"
+
+BTWinF2: ; 0x11f5be
+ text_jump UnknownText_0x1eca47
+ db "@"
+
+BTGreetingF3: ; 0x11f5c3
+ text_jump UnknownText_0x1eca64
+ db "@"
+
+BTLossF3: ; 0x11f5c8
+ text_jump UnknownText_0x1eca82
+ db "@"
+
+BTWinF3: ; 0x11f5cd
+ text_jump UnknownText_0x1eca9d
+ db "@"
+
+BTGreetingF4: ; 0x11f5d2
+ text_jump UnknownText_0x1ecabf
+ db "@"
+
+BTLossF4: ; 0x11f5d7
+ text_jump UnknownText_0x1ecade
+ db "@"
+
+BTWinF4: ; 0x11f5dc
+ text_jump UnknownText_0x1ecafa
+ db "@"
+
+BTGreetingF5: ; 0x11f5e1
+ text_jump UnknownText_0x1ecb19
+ db "@"
+
+BTLossF5: ; 0x11f5e6
+ text_jump UnknownText_0x1ecb37
+ db "@"
+
+BTWinF5: ; 0x11f5eb
+ text_jump UnknownText_0x1ecb55
+ db "@"
+
+BTGreetingF6: ; 0x11f5f0
+ text_jump UnknownText_0x1ecb70
+ db "@"
+
+BTLossF6: ; 0x11f5f5
+ text_jump UnknownText_0x1ecb92
+ db "@"
+
+BTWinF6: ; 0x11f5fa
+ text_jump UnknownText_0x1ecbb6
+ db "@"
+
+BTGreetingF7: ; 0x11f5ff
+ text_jump UnknownText_0x1ecbd9
+ db "@"
+
+BTLossF7: ; 0x11f604
+ text_jump UnknownText_0x1ecbf3
+ db "@"
+
+BTWinF7: ; 0x11f609
+ text_jump UnknownText_0x1ecc15
+ db "@"
+
+BTGreetingF8: ; 0x11f60e
+ text_jump UnknownText_0x1ecc39
+ db "@"
+
+BTLossF8: ; 0x11f613
+ text_jump UnknownText_0x1ecc55
+ db "@"
+
+BTWinF8: ; 0x11f618
+ text_jump UnknownText_0x1ecc75
+ db "@"
+
+BTGreetingF9: ; 0x11f61d
+ text_jump UnknownText_0x1ecc92
+ db "@"
+
+BTLossF9: ; 0x11f622
+ text_jump UnknownText_0x1ecca7
+ db "@"
+
+BTWinF9: ; 0x11f627
+ text_jump UnknownText_0x1eccc1
+ db "@"
+
+BTGreetingF10: ; 0x11f62c
+ text_jump UnknownText_0x1eccd7
+ db "@"
+
+BTLossF10: ; 0x11f631
+ text_jump UnknownText_0x1eccef
+ db "@"
+
+BTWinF10: ; 0x11f636
+ text_jump UnknownText_0x1ecd0e
+ db "@"
+
+BTGreetingF11: ; 0x11f63b
+ text_jump UnknownText_0x1ecd2b
+ db "@"
+
+BTLossF11: ; 0x11f640
+ text_jump UnknownText_0x1ecd4d
+ db "@"
+
+BTWinF11: ; 0x11f645
+ text_jump UnknownText_0x1ecd6b
+ db "@"
+
+BTGreetingF12: ; 0x11f64a
+ text_jump UnknownText_0x1ecd8d
+ db "@"
+
+BTLossF12: ; 0x11f64f
+ text_jump UnknownText_0x1ecdaf
+ db "@"
+
+BTWinF12: ; 0x11f654
+ text_jump UnknownText_0x1ecdcf
+ db "@"
+
+BTGreetingF13: ; 0x11f659
+ text_jump UnknownText_0x1ecded
+ db "@"
+
+BTLossF13: ; 0x11f65e
+ text_jump UnknownText_0x1ece0d
+ db "@"
+
+BTWinF13: ; 0x11f663
+ text_jump UnknownText_0x1ece2a
+ db "@"
+
+BTGreetingF14: ; 0x11f668
+ text_jump UnknownText_0x1ece4b
+ db "@"
+
+BTLossF14: ; 0x11f66d
+ text_jump UnknownText_0x1ece70
+ db "@"
+
+BTWinF14: ; 0x11f672
+ text_jump UnknownText_0x1ece8a
+ db "@"
+
+BTGreetingF15: ; 0x11f677
+ text_jump UnknownText_0x1ecea8
+ db "@"
+
+BTLossF15: ; 0x11f67c
+ text_jump UnknownText_0x1ecec9
+ db "@"
+
+BTWinF15: ; 0x11f681
+ text_jump UnknownText_0x1ecee8
+ db "@"
--- /dev/null
+++ b/mobile/battle_tower_5c.asm
@@ -1,0 +1,1772 @@
+BattleTowerRoomMenu: ; 1700b0
+; special
+ call InitBattleTowerChallengeRAM
+ callba _BattleTowerRoomMenu
+ ret
+; 1700ba
+
+Function1700ba: ; 1700ba
+ call InitBattleTowerChallengeRAM
+ callba Function11811a
+ ret
+; 1700c4
+
+Function1700c4: ; 1700c4
+ ld a, [rSVBK]
+ push af
+ ld a, $3
+ ld [rSVBK], a
+
+ call Function17042c
+
+ ld a, $5
+ call GetSRAMBank
+ ld a, $1
+ ld [$be45], a
+ xor a
+ ld [$be46], a
+ ld hl, w3_dffc
+ ld de, $aa41
+ ld bc, 4
+ call CopyBytes
+ ld hl, w3_d202Name
+ ld de, $aa8e
+ ld bc, 7 * $cc ; length of battle tower struct from japanese games?
+ call CopyBytes
+ ld hl, $aa5d ; some sort of count
+ ld a, [hl]
+ inc [hl]
+ inc hl
+ sla a
+ sla a
+ ld e, a
+ ld d, $0
+ add hl, de
+ ld e, l
+ ld d, h
+ ld hl, w3_dffc
+ ld bc, 4
+ call CopyBytes
+ call CloseSRAM
+ pop af
+ ld [rSVBK], a
+ ret
+; 170114
+
+Function170114: ; 170114
+ call InitBattleTowerChallengeRAM
+ call .Function170121
+ callba Function11805f
+ ret
+; 170121
+
+.Function170121: ; 170121
+ ld a, $5
+ call GetSRAMBank
+ ld hl, $a948
+ ld de, wMisc
+ ld bc, $f6 ; 246
+ call CopyBytes
+ call CloseSRAM
+ call Function170c8b
+ ret
+; 170139
+
+Function170139: ; 170139
+; Convert the 4-digit decimal number at 5:aa41 into binary
+ ld a, $5
+ call GetSRAMBank
+ ld de, $aa41
+ ld h, $0
+ ld l, h
+ ld bc, 1000
+ call .DecToBin
+ ld bc, 100
+ call .DecToBin
+ ld bc, 10
+ call .DecToBin
+ ld a, [de]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ call CloseSRAM
+; Store that number in wMisc
+ ld a, h
+ ld [wMisc], a
+ ld a, l
+ ld [wMisc + 1], a
+ ld hl, wBT_OTTempPkmn1DVs
+ ld a, [PlayerID]
+ ld [hli], a
+ ld a, [PlayerID + 1]
+ ld [hli], a
+ ld a, [wSecretID]
+ ld [hli], a
+ ld a, [wSecretID + 1]
+ ld [hli], a
+ ld e, l
+ ld d, h
+ ld hl, PlayerName
+ ld bc, 5 ; Japanese name length
+ call CopyBytes
+ ld bc, PlayerID
+ ld de, PlayerGender
+ callba GetMobileOTTrainerClass
+ ld de, wBT_OTTempPkmn1CaughtGender
+ ld a, c
+ ld [de], a
+ inc de
+ ld a, PartyMons % $100
+ ld [wcd49], a
+ ld a, PartyMons / $100
+ ld [wcd4a], a
+ ld a, PartyMonNicknames % $100
+ ld [wcd4b], a
+ ld a, PartyMonNicknames / $100
+ ld [wcd4c], a
+ ld a, 3
+.CopyLoop:
+ push af
+ ld a, [wcd49]
+ ld l, a
+ ld a, [wcd4a]
+ ld h, a
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+ ld a, l
+ ld [wcd49], a
+ ld a, h
+ ld [wcd4a], a
+ ld a, [wcd4b]
+ ld l, a
+ ld a, [wcd4c]
+ ld h, a
+ ld bc, $0006
+ call CopyBytes
+ ld a, l
+ ld [wcd4b], a
+ ld a, h
+ ld [wcd4c], a
+ pop af
+ dec a
+ jr nz, .CopyLoop
+ ld a, $4
+ call GetSRAMBank
+ ld hl, $a013
+ ld bc, $24
+ call CopyBytes
+ call CloseSRAM
+ ld a, $5
+ call GetSRAMBank
+ ld hl, $a894
+ ld bc, 6
+ call CopyBytes
+ ld hl, wMisc
+ ld de, $a948
+ ld bc, $f6
+ call CopyBytes
+ call CloseSRAM
+ ret
+; 17020c
+
+.DecToBin: ; 17020c
+ ld a, [de]
+ inc de
+ and a
+ ret z
+
+.digit_loop
+ add hl, bc
+ dec a
+ jr nz, .digit_loop
+ ret
+; 170215
+
+BattleTowerBattle: ; 170215
+ xor a
+ ld [wBattleTowerBattleEnded], a
+ call _BattleTowerBattle
+ ret
+; 17021d
+
+EmptySpecial_17021d: ; 17021d
+ ret
+; 17021e
+
+InitBattleTowerChallengeRAM: ; 17021e
+ xor a
+ ld [wBattleTowerBattleEnded], a
+ ld [wNrOfBeatenBattleTowerTrainers], a
+ ld [wcf65], a
+ ld [wcf66], a
+ ret
+; 17022c
+
+_BattleTowerBattle: ; 17022c
+.loop
+ call .do_dw
+ call DelayFrame
+ ld a, [wBattleTowerBattleEnded]
+ cp $1
+ jr nz, .loop
+ ret
+; 17023a
+
+.do_dw ; 17023a
+ ld a, [wBattleTowerBattleEnded]
+ ld e, a
+ ld d, 0
+ ld hl, .dw
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+; 170249
+
+.dw ; 170249
+ dw RunBattleTowerTrainer
+ dw SkipBattleTowerTrainer
+; 17024d
+
+RunBattleTowerTrainer: ; 17024d
+ ld a, [Options]
+ push af
+ ld hl, Options
+ set BATTLE_SHIFT, [hl] ; SET MODE
+
+ ld a, [InBattleTowerBattle]
+ push af
+ or $1
+ ld [InBattleTowerBattle], a
+
+ xor a
+ ld [wLinkMode], a
+ callba TrainerRankings_Healings
+ callba HealParty
+ call ReadBTTrainerParty
+ call Clears5_a89a
+
+ predef StartBattle
+
+ callba LoadPokemonData
+ callba HealParty
+ ld a, [wBattleResult]
+ ld [ScriptVar], a
+ and a
+ jr nz, .lost
+ ld a, BANK(sNrOfBeatenBattleTowerTrainers)
+ call GetSRAMBank
+ ld a, [sNrOfBeatenBattleTowerTrainers]
+ ld [wNrOfBeatenBattleTowerTrainers], a
+ call CloseSRAM
+ ld hl, StringBuffer3
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ add "1"
+ ld [hli], a
+ ld a, "@"
+ ld [hl], a
+
+.lost
+ pop af
+ ld [InBattleTowerBattle], a
+ pop af
+ ld [Options], a
+ ld a, $1
+ ld [wBattleTowerBattleEnded], a
+ ret
+
+
+ReadBTTrainerParty: ; 1702b7
+; Initialise the BattleTower-Trainer and his Pkmn
+ call CopyBTTrainer_FromBT_OT_TowBT_OTTemp
+
+; Check the nicknames for illegal characters, and replace bad nicknames
+; with their species names.
+ ld de, wBT_OTTempPkmn1Name ; $c643
+ ld c, PKMN_NAME_LENGTH
+ callba CheckStringForErrors
+ jr nc, .skip_mon_1
+
+ ld a, [wBT_OTTempPkmn1]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld l, e
+ ld h, d
+ ld de, wBT_OTTempPkmn1Name ; $c643
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+
+.skip_mon_1
+ ld de, wBT_OTTempPkmn2Name ; $c67e
+ ld c, PKMN_NAME_LENGTH
+ callba CheckStringForErrors
+ jr nc, .skip_mon_2
+ ld a, [wBT_OTTempPkmn2] ; [$c64e]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld l, e
+ ld h, d
+ ld de, wBT_OTTempPkmn2Name ; $c67e
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+
+.skip_mon_2
+ ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9
+ ld c, PKMN_NAME_LENGTH
+ callba CheckStringForErrors
+ jr nc, .skip_mon_3
+ ld a, [wBT_OTTempPkmn3] ; [$c689]
+ ld [wNamedObjectIndexBuffer], a
+ call GetPokemonName
+ ld l, e
+ ld h, d
+ ld de, wBT_OTTempPkmn3Name ; $c686 + 51 = $c6b9
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+
+.skip_mon_3
+; Add the terminator character to each of these names
+ ld a, "@"
+ ld [wBT_OTTempPkmn1NameEnd - 1], a ; $c64d
+ ld [wBT_OTTempPkmn2NameEnd - 1], a ; $c688
+ ld [wBT_OTTempPkmn3NameEnd - 1], a ; $c68a + 57 = $c6c3
+; Fix errors in the movesets
+ call CheckBTMonMovesForErrors
+; Repair the trainer name if needed, then copy it to OTPlayerName
+ ld de, wBT_OTTempName
+ ld c, NAME_LENGTH - 1
+ callba CheckStringForErrors
+ jr nc, .trainer_name_okay
+ ld hl, BT_ChrisName
+ jr .done_trainer_name
+
+.trainer_name_okay
+ ld hl, wBT_OTTempName ; 0xc608
+
+.done_trainer_name
+ ld de, OTPlayerName
+ ld bc, NAME_LENGTH - 1
+ call CopyBytes
+ ld a, "@"
+ ld [de], a
+
+ ld hl, wBT_OTTempTrainerClass
+ ld a, [hli]
+ ld [OtherTrainerClass], a
+ ld a, OTPartyMonNicknames % $100
+ ld [BGMapBuffer], a
+ ld a, OTPartyMonNicknames / $100
+ ld [BGMapBuffer + 1], a
+
+ ; Copy Pkmn into Memory from the address in hl
+ ld de, OTPartyMon1Species
+ ld bc, OTPartyCount
+ ld a, BATTLETOWER_NROFPKMNS ; Number of Pkmn the BattleTower-Trainer has
+ ld [bc], a
+ inc bc
+.otpartymon_loop
+ push af
+ ld a, [hl]
+ ld [bc], a
+ inc bc
+ push bc
+ ld bc, PARTYMON_STRUCT_LENGTH
+ call CopyBytes
+ push de
+ ld a, [BGMapBuffer]
+ ld e, a
+ ld a, [BGMapBuffer + 1]
+ ld d, a
+ ld bc, PKMN_NAME_LENGTH
+ call CopyBytes
+ ld a, e
+ ld [BGMapBuffer], a
+ ld a, d
+ ld [BGMapBuffer + 1], a
+ pop de
+ pop bc
+ pop af
+ dec a
+ and a
+ jr nz, .otpartymon_loop
+ ld a, -1
+ ld [bc], a
+ ret
+; 170394
+
+ValidateBTParty: ; 170394
+; Check for and fix errors in party data
+ ld hl, wBT_OTTempPkmn1Species
+ ld d, BATTLETOWER_NROFPKMNS
+.pkmn_loop
+ push de
+ push hl
+ ld b, h
+ ld c, l
+ ld a, [hl]
+ and a
+idx = $ff
+rept ($ff +- NUM_POKEMON)
+ jr z, .invalid
+ cp idx
+idx = idx +- 1
+endr
+ jr nz, .valid
+
+.invalid
+ ld a, SMEARGLE
+ ld [hl], a
+
+.valid
+ ld [CurSpecies], a
+ call GetBaseData
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb] ; s5_b2fb ; max level?
+ call CloseSRAM
+ ld e, a
+ ld hl, MON_LEVEL
+ add hl, bc
+ ld a, [hl]
+ cp MIN_LEVEL
+ ld a, MIN_LEVEL
+ jr c, .load
+ ld a, [hl]
+ cp e
+ jr c, .dont_load
+ ld a, e
+
+.load
+ ld [hl], a
+
+.dont_load
+ ld [CurPartyLevel], a
+ ld hl, MON_MOVES
+ add hl, bc
+ ld d, NUM_MOVES - 1
+ ld a, [hli]
+ and a
+ jr z, .not_move
+ cp NUM_ATTACKS + 1
+ jr nc, .not_move
+ jr .valid_move
+
+.not_move
+ dec hl
+ ld a, POUND
+ ld [hli], a
+ xor a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ jr .done_moves
+
+.valid_move
+ ld a, [hl]
+ cp NUM_ATTACKS + 1
+ jr c, .next
+ ld [hl], $0
+
+.next
+ inc hl
+ dec d
+ jr nz, .valid_move
+
+.done_moves
+ ld hl, MON_MAXHP
+ add hl, bc
+ ld d, h
+ ld e, l
+ push hl
+ push de
+ ld hl, MON_STAT_EXP - 1
+ add hl, bc
+ ld b, $1
+ predef CalcPkmnStats
+ pop de
+ pop hl
+ dec de
+ dec de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ pop hl
+ ld bc, PARTYMON_STRUCT_LENGTH + PKMN_NAME_LENGTH
+ add hl, bc
+ pop de
+ dec d
+ jp nz, .pkmn_loop
+ ret
+; 170426
+
+BT_ChrisName: ; 170426
+ db "CHRIS@"
+; 17042c
+
+Function17042c: ; 17042c
+ ld hl, w3_d202TrainerData
+ ld a, BATTLETOWER_NROFTRAINERS
+.loop
+ push af
+ push hl
+ ld c, BATTLETOWER_TRAINERDATALENGTH / 2
+.loop2
+ ; First byte is a comparison value.
+ ld a, [hli]
+ ld b, a
+ ; Second byte is a lookup index.
+ ld a, [hli]
+ and a
+ jr z, .empty
+ cp 15
+ jr nc, .copy_data
+
+ push hl
+ ld hl, Unknown_170470
+ dec a
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld a, [hl]
+ pop hl
+
+ ; If Unknown_170470[a-1] <= b, overwrite the current trainer's data
+ ; with Unknown17047e, and exit the inner loop.
+ cp b
+ jr c, .copy_data
+ jr z, .copy_data
+ jr .next_iteration
+
+.empty
+ ; If a == 0 and b >= $fc, overwrite the current trainer's data with
+ ; Unknown17047e, and exit the inner loop.
+ ld a, b
+ cp $fc
+ jr nc, .copy_data
+
+.next_iteration
+ dec c
+ jr nz, .loop2
+ jr .next_trainer
+
+.copy_data
+ pop de
+ push de
+ ld hl, Unknown_17047e
+ ld bc, BATTLETOWER_TRAINERDATALENGTH
+ call CopyBytes
+
+.next_trainer
+ pop hl
+ ld de, BATTLE_TOWER_STRUCT_LENGTH
+ add hl, de
+ pop af
+ dec a
+ jr nz, .loop
+ ret
+; 170470
+
+Unknown_170470:
+ db $12
+ db $24
+ db $45
+ db $45
+ db $42
+ db $42
+ db $45
+ db $42
+ db $27
+ db $27
+ db $45
+ db $27
+ db $42
+ db $24
+
+Unknown_17047e:
+; see data/battle_tower_2.asm
+ db $03, 4
+ db $05, 8
+ db $03, 5
+ db $0e, 6
+ db $03, 2
+ db $00, 0
+ db $39, 7
+ db $07, 4
+ db $00, 5
+ db $04, 7
+ db $01, 5
+ db $00, 0
+ db $0f, 5
+ db $14, 7
+ db $05, 5
+ db $11, 12
+ db $0c, 6
+ db $06, 4
+
+
+CopyBTTrainer_FromBT_OT_TowBT_OTTemp: ; 1704a2
+; copy the BattleTower-Trainer data that lies at 'BT_OTTrainer' to 'wBT_OTTemp'
+ ld a, [rSVBK]
+ push af
+ ld a, $3 ; BANK(BT_OTTrainer)
+ ld [rSVBK], a
+
+ ld hl, BT_OTTrainer ; $d100
+ ld de, wBT_OTTemp ; wMisc
+ ld bc, BATTLE_TOWER_STRUCT_LENGTH
+ call CopyBytes
+
+ pop af
+ ld [rSVBK], a
+
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, BATTLETOWER_CHALLENGE_IN_PROGESS
+ ld [sBattleTowerChallengeState], a
+ ld hl, sNrOfBeatenBattleTowerTrainers
+ inc [hl]
+ call CloseSRAM
+SkipBattleTowerTrainer: ; 1704c9
+ ret
+; 1704ca
+
+Function1704ca: ; 1704ca
+; unreferenced mobile function
+ ld a, [$be46]
+ cp $7
+ jr c, .asm_1704d3
+ ld a, $6
+
+.asm_1704d3
+ ld hl, $afce
+ ld de, -$e0
+.asm_1704d9
+ and a
+ jr z, .asm_1704e0
+ add hl, de
+ dec a
+ jr .asm_1704d9
+
+.asm_1704e0
+ ret
+; 1704e1
+
+Function1704e1: ; 1704e1
+; unreferenced special
+ call SpeechTextBox
+ call FadeToMenu
+ call InitBattleTowerChallengeRAM
+ call .JumptableLoop
+ call CloseSubmenu
+ ret
+; 1704f1
+
+.JumptableLoop: ; 1704f1
+ call ClearBGPalettes
+ call ClearSprites
+ call ClearScreen
+.loop
+ call JoyTextDelay
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .done
+ call .DoJumptable
+ callba ReloadMapPart
+ jr .loop
+
+.done
+ ret
+; 170510
+
+.DoJumptable: ; 170510
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, 0
+ ld hl, .dw
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+; 17051f
+
+.dw ; 17051f
+ dw .Jumptable_0
+ dw .Jumptable_1
+ dw .Jumptable_2
+; 170525
+
+.Jumptable_0: ; 170525
+ ld a, $5
+ call GetSRAMBank
+
+ ld hl, $a89c
+ ld de, StringBuffer3
+ ld bc, $16
+ call CopyBytes
+
+ ld hl, $a8b2
+ ld de, wMisc
+ ld bc, $0096
+ call CopyBytes
+
+ call CloseSRAM
+ hlcoord 1, 1
+ ld de, StringBuffer3
+ call PlaceString
+ hlcoord 1, 3
+ ld de, .String_Mail
+ call PlaceString
+ hlcoord 4, 3
+ ld de, StringBuffer4
+ call PlaceString
+ hlcoord 8, 3
+ ld de, .String_PastReaders
+ call PlaceString
+ call .DrawBorder
+ call .PlaceTextItems
+ jr .NextJumptableFunction
+
+
+.Jumptable_1:
+ call SetPalettes
+ call .NextJumptableFunction
+
+
+.Jumptable_2:
+ ld hl, hJoyPressed
+ ld a, [hl]
+ and A_BUTTON
+ jr nz, .pressed_a_or_b
+ ld a, [hl]
+ and B_BUTTON
+ jr nz, .pressed_a_or_b
+ ld a, [hl]
+ and D_UP
+ jr nz, .pressed_up
+ ld a, [hl]
+ and D_DOWN
+ jr nz, .pressed_down
+ ret
+
+.pressed_up
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ and a
+ ret z
+ sub 15
+ ld [wNrOfBeatenBattleTowerTrainers], a
+ call .PlaceTextItems
+ ret
+
+.pressed_down
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ cp 60
+ ret z
+ add 15
+ ld [wNrOfBeatenBattleTowerTrainers], a
+ call .PlaceTextItems
+ ret
+
+.pressed_a_or_b
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+.NextJumptableFunction:
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+; 1705b7
+
+.DrawBorder: ; 1705b7
+ hlcoord 0, 4
+ ld a, $79
+ ld [hli], a
+ ld c, SCREEN_WIDTH - 2
+.top_border_loop
+ ld a, $7a
+ ld [hli], a
+ dec c
+ jr nz, .top_border_loop
+ ld a, $7b
+ ld [hli], a
+ ld de, SCREEN_WIDTH
+ ld c, 12
+.left_border_loop
+ ld a, $7c
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .left_border_loop
+ ld a, $7d
+ ld [hli], a
+ ld c, SCREEN_WIDTH - 2
+.bottom_border_loop
+ ld a, $7a
+ ld [hli], a
+ dec c
+ jr nz, .bottom_border_loop
+ ld a, $7e
+ ld [hl], a
+ ld de, -SCREEN_WIDTH
+ add hl, de
+ ld c, 12
+.right_border_loop
+ ld a, $7c
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .right_border_loop
+ ret
+; 1705f0
+
+.PlaceTextItems: ; 1705f0
+ call .ClearBox
+ call .PlaceUpDownArrows
+ ld a, $50
+ ld [wcd4e], a
+ ld hl, wMisc
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ ld c, a
+ xor a
+ ld b, a
+ add hl, bc
+ push hl
+ pop bc
+ hlcoord 1, 6
+ ld a, 6
+.loop1
+ push af
+ push hl
+ ld a, 3
+.loop2
+ push af
+ ld de, wcd49
+ ld a, [bc]
+ and a
+ jr z, .fill_with_e3
+; .copy
+ ld a, 5
+.loop3a
+ push af
+ ld a, [bc]
+ ld [de], a
+ inc bc
+ inc de
+ pop af
+ dec a
+ jr nz, .loop3a
+ jr .rejoin
+
+.fill_with_e3
+ ld a, 5
+.loop3b
+ push af
+ ld a, $e3
+ ld [de], a
+ inc de
+ inc bc
+ pop af
+ dec a
+ jr nz, .loop3b
+
+.rejoin
+ ld de, wcd49
+ push bc
+ call PlaceString
+ ld de, 6
+ add hl, de
+ pop bc
+ pop af
+ dec a
+ jr nz, .loop2
+ pop hl
+ ld de, $28
+ add hl, de
+ pop af
+ dec a
+ jr nz, .loop1
+ ret
+; 17064b
+
+.ClearBox: ; 17064b
+ hlcoord 1, 5
+ xor a
+ ld b, 12
+.clearbox_row
+ ld c, SCREEN_WIDTH - 2
+.clearbox_column
+ ld [hli], a
+ dec c
+ jr nz, .clearbox_column
+ inc hl
+ inc hl
+ dec b
+ jr nz, .clearbox_row
+ ret
+; 17065d
+
+.PlaceUpDownArrows: ; 17065d
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ and a
+ jr z, .nope
+ hlcoord 18, 5
+ ld a, "▲"
+ ld [hl], a
+
+.nope
+ ld a, [wNrOfBeatenBattleTowerTrainers]
+ cp 60
+ ret z
+ hlcoord 18, 16
+ ld a, "▼"
+ ld [hl], a
+ ret
+; 170676
+
+.String_Mail: ; 170676
+ db "ルーム@"
+; 17067a
+
+.String_PastReaders: ; 17067a
+ db "れきだいりーダーいちらん@"
+; 170687
+
+BattleTowerAction: ; 170687
+ ld a, [ScriptVar]
+ ld e, a
+ ld d, 0
+ ld hl, .dw
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+; 170696
+
+
+.dw ; 170696 (5c:4696)
+ dw BattleTowerAction_CheckExplanationRead ; 0x00
+ dw BattleTowerAction_SetExplanationRead ; 0x01
+ dw BattleTowerAction_GetChallengeState ; 0x02
+ dw BattleTowerAction_SetByteToQuickSaveChallenge ; 0x03
+ dw BattleTowerAction_SetByteToCancelChallenge ; 0x04
+ dw Function1707ac ; 0x05
+ dw Function1707f4 ; 0x06
+ dw SaveBattleTowerLevelGroup ; 0x07
+ dw LoadBattleTowerLevelGroup ; 0x08
+ dw BattleTower_CheckSaveFileExistsAndIsYours ; 0x09
+ dw Function1708b1 ; 0x0a
+ dw CheckMobileEventIndex ; 0x0b
+ dw Function1708c8 ; 0x0c
+ dw Function1708f0 ; 0x0d
+ dw BattleTowerAction_EggTicket ; 0x0e
+ dw Function1709aa ; 0x0f
+ dw Function1709bb ; 0x10
+ dw Function170a9c ; 0x11
+ dw Function170aa0 ; 0x12
+ dw Function170aaf ; 0x13
+ dw Function170abe ; 0x14
+ dw Function170ad7 ; 0x15
+ dw Function170807 ; 0x16
+ dw Function17081d ; 0x17
+ dw BattleTowerAction_LevelCheck ; 0x18
+ dw BattleTowerAction_UbersCheck ; 0x19
+ dw ResetBattleTowerTrainersSRAM ; 0x1a
+ dw BattleTower_GiveReward ; 0x1b
+ dw Function17071b ; 0x1c
+ dw Function170729 ; 0x1d
+ dw BattleTower_RandomlyChooseReward ; 0x1e
+ dw BattleTower_SaveOptions ; 0x1f
+
+
+; Reset the save memory for BattleTower-Trainers (Counter and all 7 TrainerBytes)
+ResetBattleTowerTrainersSRAM: ; 1706d6 (5c:46d6) BattleTowerAction $1a
+ ld a, BANK(sBTTrainers)
+ call GetSRAMBank
+
+ ld a, $ff
+ ld hl, sBTTrainers
+ ld bc, BATTLETOWER_NROFTRAINERS
+ call ByteFill
+
+ xor a
+ ld [sNrOfBeatenBattleTowerTrainers], a
+
+ call CloseSRAM
+
+ ret
+
+BattleTower_GiveReward: ; 1706ee (5c:46ee) BattleTowerAction $1b
+ ld a, BANK(sBattleTowerReward)
+ call GetSRAMBank
+
+ ld a, [sBattleTowerReward]
+ call CloseSRAM
+ ld [ScriptVar], a
+ ld hl, NumItems
+ ld a, [hli]
+ cp MAX_ITEMS
+ ret c
+ ld b, MAX_ITEMS
+ ld a, [ScriptVar]
+ ld c, a
+.loop
+ ld a, [hli]
+ cp c
+ jr nz, .next
+ ld a, [hl]
+ cp 95
+ ret c
+.next
+ inc hl
+ dec b
+ jr nz, .loop
+ ld a, POTION
+ ld [ScriptVar], a
+ ret
+
+Function17071b: ; 17071b (5c:471b) BattleTowerAction $1c
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, BATTLETOWER_WON_CHALLENGE
+ ld [sBattleTowerChallengeState], a
+ call CloseSRAM
+ ret
+
+Function170729: ; 170729 (5c:4729) BattleTowerAction $1d
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, BATTLETOWER_RECEIVED_REWARD
+ ld [sBattleTowerChallengeState], a
+ call CloseSRAM
+ ret
+
+BattleTower_SaveOptions: ; 170737 (5c:4737) BattleTowerAction $1f
+ callba SaveOptions
+ ret
+
+BattleTower_RandomlyChooseReward: ; 17073e (5c:473e) BattleTowerAction $1e
+; Generate a random stat boosting item.
+.loop
+ call Random
+ ld a, [hRandomAdd]
+ and $7
+ cp 6
+ jr c, .okay
+ sub 6
+.okay
+ add HP_UP
+ cp LUCKY_PUNCH
+ jr z, .loop
+ push af
+ ld a, BANK(sBattleTowerReward)
+ call GetSRAMBank
+ pop af
+ ld [sBattleTowerReward], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_CheckExplanationRead: ; 17075f (5c:475f) BattleTowerAction $00
+ call BattleTower_CheckSaveFileExistsAndIsYours
+ ld a, [ScriptVar]
+ and a
+ ret z
+
+ ld a, BANK(s1_be4f)
+ call GetSRAMBank
+ ld a, [s1_be4f]
+ and $2
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_GetChallengeState: ; 170778 (5c:4778) BattleTowerAction $02
+ ld hl, sBattleTowerChallengeState
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, [hl]
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_SetExplanationRead: ; 170788 (5c:4788) BattleTowerAction $01
+ ld a, BANK(s1_be4f)
+ call GetSRAMBank
+ ld a, [s1_be4f]
+ or $2
+ ld [s1_be4f], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_SetByteToQuickSaveChallenge: ; 170799 (5c:4799) BattleTowerAction $03
+ ld c, BATTLETOWER_SAVED_AND_LEFT
+ jr asm_17079f
+
+BattleTowerAction_SetByteToCancelChallenge: ; 17079d (5c:479d) BattleTowerAction $04
+ ld c, BATTLETOWER_NO_CHALLENGE
+asm_17079f: ; 17079f (5c:479f)
+ ld a, BANK(sBattleTowerChallengeState)
+ call GetSRAMBank
+ ld a, c
+ ld [sBattleTowerChallengeState], a
+ call CloseSRAM
+ ret
+
+Function1707ac: ; 1707ac (5c:47ac) BattleTowerAction $05
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa8c]
+ ld b, a
+ ld a, [$be46]
+ ld [ScriptVar], a
+ call CloseSRAM
+ and a
+ ret z
+ ld a, b
+ cp $2
+ jr nc, .asm_1707ef
+ push bc
+ call UpdateTime
+ pop bc
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa8b]
+ call CloseSRAM
+ ld c, a
+ ld a, [CurDay]
+ sub c
+ jr c, .asm_1707e5
+ cp $8
+ jr nc, .asm_1707ef
+ ld a, b
+ and a
+ jr nz, .asm_1707ef
+ ret
+.asm_1707e5
+ ld hl, CurDay
+ ld a, $8c
+ sub c
+ add [hl]
+ cp $8
+ ret c
+.asm_1707ef
+ ld a, $8
+ ld [ScriptVar], a
+
+Function1707f4: ; 1707f4 (5c:47f4) BattleTowerAction $06
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$be46], a
+ ld [$aa8b], a
+ ld [$aa8c], a
+ call CloseSRAM
+ ret
+
+Function170807: ; 170807 (5c:4807) BattleTowerAction $16
+ call UpdateTime
+ ld a, $5
+ call GetSRAMBank
+ ld a, [CurDay]
+ ld [$b2f9], a
+ xor a
+ ld [$b2fa], a
+ call CloseSRAM
+ ret
+
+Function17081d: ; 17081d (5c:481d) BattleTowerAction $17
+ xor a
+ ld [ScriptVar], a
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2f9]
+ ld c, a
+ ld a, [$b2fa]
+ ld b, a
+ call CloseSRAM
+ cp $2
+ jr nc, .asm_170853
+ push bc
+ call UpdateTime
+ pop bc
+ ld a, [CurDay]
+ sub c
+ jr c, .asm_170849
+ cp $b
+ jr nc, .asm_170853
+ ld a, b
+ and a
+ jr nz, .asm_170853
+ ret
+
+.asm_170849
+ ld hl, CurDay
+ ld a, 140
+ sub c
+ add [hl]
+ cp $b
+ ret c
+.asm_170853
+ ld a, $1
+ ld [ScriptVar], a
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$b2f9], a
+ ld [$b2fa], a
+ call CloseSRAM
+ ret
+
+SaveBattleTowerLevelGroup: ; 170868 (5c:4868) BattleTowerAction $07
+ ld a, BANK(sBTChoiceOfLevelGroup)
+ call GetSRAMBank
+ ld a, [rSVBK]
+ push af
+ ld a, $3
+ ld [rSVBK], a
+ ld a, [wBTChoiceOfLvlGroup]
+ ld [sBTChoiceOfLevelGroup], a
+ pop af
+ ld [rSVBK], a
+ call CloseSRAM
+ ret
+
+LoadBattleTowerLevelGroup: ; 170881 (5c:4881) BattleTowerAction $08 ; Load level group choice
+ ld a, BANK(sBTChoiceOfLevelGroup)
+ call GetSRAMBank
+ ld a, [rSVBK]
+ push af
+ ld a, $3
+ ld [rSVBK], a
+ ld a, [sBTChoiceOfLevelGroup]
+ ld [wBTChoiceOfLvlGroup], a
+ pop af
+ ld [rSVBK], a
+ call CloseSRAM
+ ret
+
+BattleTower_CheckSaveFileExistsAndIsYours: ; 17089a BattleTowerAction $09
+ ld a, [wSaveFileExists]
+ and a
+ jr z, .nope
+ callba CompareLoadedAndSavedPlayerID
+ jr z, .yes
+ xor a
+ jr .nope
+
+.yes
+ ld a, $1
+
+.nope
+ ld [ScriptVar], a
+ ret
+; 1708b1
+
+
+Function1708b1: ; 1708b1 (5c:48b1) BattleTowerAction $0a
+ xor a
+ ld [MusicFade], a
+ call MaxVolume
+ ret
+
+CheckMobileEventIndex: ; 1708b9 (5c:48b9) BattleTowerAction $0b something to do with GS Ball
+ ld a, BANK(sMobileEventIndex)
+ call GetSRAMBank
+ ld a, [sMobileEventIndex]
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+Function1708c8: ; 1708c8 (5c:48c8) BattleTowerAction $0c
+ call UpdateTime
+ ld a, $5
+ call GetSRAMBank
+ ld a, [CurDay]
+ ld [$aa8b], a
+ xor a
+ ld [$aa8c], a
+ ld a, [$aa5d]
+ cp $2
+ jr nc, .asm_1708ec
+ ld a, [CurDay]
+ ld [$aa48], a
+ ld a, $1
+ ld [$aa47], a
+.asm_1708ec
+ call CloseSRAM
+ ret
+
+Function1708f0: ; 1708f0 (5c:48f0) BattleTowerAction $0d
+ xor a
+ ld [ScriptVar], a
+ call UpdateTime
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa48]
+ ld c, a
+ ld a, [$aa47]
+ call CloseSRAM
+ and a
+ ret z
+ ld hl, CurDay
+ ld a, c
+ cp [hl]
+ jr nz, Function170923
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa5d]
+ call CloseSRAM
+ cp $5
+ ret c
+ ld a, $1
+ ld [ScriptVar], a
+ ret
+
+
+Function170923: ; 170923
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$aa48], a
+ ld [$aa47], a
+ ld hl, $aa5d
+ ld bc, $0011
+ call ByteFill
+ call CloseSRAM
+ ret
+; 17093c
+
+
+BattleTowerAction_EggTicket: ; 17093c (5c:493c) BattleTowerAction $0e
+ xor a
+ ld [ScriptVar], a
+ ld a, EGG_TICKET
+ ld [CurItem], a
+ ld hl, NumItems
+ call CheckItem
+ ret nc
+ ld a, [PartyCount]
+ ld b, 0
+ ld c, a
+ ld hl, PartySpecies
+.loop
+ ld a, [hli]
+ cp EGG
+ jr nz, .not_egg
+ push hl
+ ld hl, PartyMonOT
+ ld de, $6 ; NAME_LENGTH
+ ld a, b
+ and a
+ jr z, .skip
+.loop2
+ add hl, de
+ dec a
+ jr nz, .loop2
+.skip
+ ld de, String_1709a4
+ ld a, $6 ; NAME_LENGTH
+.compare_loop
+ push af
+ ld a, [de]
+ inc de
+ cp [hl]
+ inc hl
+ jr nz, .different
+ pop af
+ dec a
+ jr nz, .compare_loop
+rept 4
+ dec hl
+endr
+ ld a, "@"
+ ld [hli], a
+ ld [hli], a
+ pop hl
+ ld a, EGG_TICKET
+ ld [CurItem], a
+ ld a, 1
+ ld [wItemQuantityChangeBuffer], a
+ ld a, -1
+ ld [CurItemQuantity], a
+ ld hl, NumItems
+ call TossItem
+ ld a, $1
+ ld [ScriptVar], a
+ ret
+
+.different
+ pop af
+ pop hl
+.not_egg
+ inc b
+ dec c
+ jr nz, .loop
+ ret
+; 1709a4 (5c:49a4)
+
+String_1709a4: ; 1709a4
+ db "なぞナゾ@@"
+
+Function1709aa: ; 1709aa (5c:49aa) BattleTowerAction $0f
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(w3_d090)
+ ld [rSVBK], a
+ ld a, [w3_d090]
+ ld [ScriptVar], a
+ pop af
+ ld [rSVBK], a
+ ret
+
+Function1709bb: ; 1709bb (5c:49bb) BattleTowerAction $10
+ xor a
+ ld [ScriptVar], a
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$a800]
+ call CloseSRAM
+ cp 6
+ jr nc, .invalid
+ ld e, a
+ ld d, 0
+ ld hl, Jumptable_1709e7
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.invalid
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$a800], a
+ call CloseSRAM
+ ret
+; 1709e7 (5c:49e7)
+
+Jumptable_1709e7: ; 1709e7
+ dw .NoAction
+ dw .NoAction
+ dw .DoAction1
+ dw .DoAction1
+ dw .Action4
+ dw .Action5
+; 1709f3
+
+.DoAction1: ; 1709f3
+ ld a, $5
+ call GetSRAMBank
+ ld a, $1
+ ld [$a800], a
+ call CloseSRAM
+
+.NoAction: ; 170a00
+ ret
+; 170a01
+
+.Action4: ; 170a01
+ ld a, $5
+ call GetSRAMBank
+ ld hl, $b023
+ ld de, wMisc
+ ld bc, $0069
+ call CopyBytes
+ ld a, [$a825]
+ ld [wcd30], a
+ ld a, [$a826]
+ ld [wcd31], a
+ call CloseSRAM
+ callba Function11b6b4
+ callba Function17d0f3
+ ld a, $1
+ ld [ScriptVar], a
+ ret
+; 170a33
+
+.Action5: ; 170a33
+ ld a, $0
+ call GetSRAMBank
+ ld hl, wRTC
+ ld de, wMisc
+ ld bc, $0004
+ call CopyBytes
+ call CloseSRAM
+ ld a, $5
+ call GetSRAMBank
+ ld hl, $b08c
+ ld de, wMisc
+ ld c, $4
+.compare_loop
+ ld a, [de]
+ inc de
+ cp [hl]
+ jr nz, .different
+ inc hl
+ dec c
+ jr nz, .compare_loop
+ call CloseSRAM
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ call GetMapTrigger
+ ld a, d
+ or e
+ jr z, .no_trigger
+ ld a, [de]
+ and a
+ ret nz
+
+.no_trigger
+ ld a, $1
+ ld [ScriptVar], a
+ ret
+
+.different
+ call CloseSRAM
+ ld a, $5
+ call GetSRAMBank
+ xor a
+ ld [$a800], a
+ call CloseSRAM
+ ld [ScriptVar], a
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ call GetMapTrigger
+ ld a, d
+ or e
+ jr z, .no_trigger_2
+ xor a
+ ld [de], a
+
+.no_trigger_2
+ ret
+; 170a9c
+
+Function170a9c: ; 170a9c (5c:4a9c) BattleTowerAction $11
+ ld c, $0
+ jr asm_170aa2
+
+Function170aa0: ; 170aa0 (5c:4aa0) BattleTowerAction $12
+ ld c, $1
+asm_170aa2: ; 170aa2 (5c:4aa2)
+ ld a, $5
+ call GetSRAMBank
+ ld a, c
+ ld [$aa8d], a
+ call CloseSRAM
+ ret
+
+Function170aaf: ; 170aaf (5c:4aaf) BattleTowerAction $13
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$aa8d]
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+Function170abe: ; 170abe (5c:4abe) BattleTowerAction $14
+ call BattleTower_CheckSaveFileExistsAndIsYours
+ ld a, [ScriptVar]
+ and a
+ ret z
+
+ ld a, BANK(s1_be4f)
+ call GetSRAMBank
+ ld a, [s1_be4f]
+ and $1
+ ld [ScriptVar], a
+ call CloseSRAM
+ ret
+
+Function170ad7: ; 170ad7 (5c:4ad7) BattleTowerAction $15
+ ld a, BANK(s1_be4f)
+ call GetSRAMBank
+ ld a, [s1_be4f]
+ or $1
+ ld [s1_be4f], a
+ call CloseSRAM
+ ret
+
+BattleTowerAction_LevelCheck: ; 170ae8 (5c:4ae8) BattleTowerAction $18
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb]
+ call CloseSRAM
+ ld c, 10
+ call SimpleDivide
+ ld a, b
+ ld [wcd4f], a
+ xor a
+ ld [ScriptVar], a
+ callba BattleTower_LevelCheck ; level check
+ ret nc
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb]
+ call CloseSRAM
+ ld [ScriptVar], a
+ ret
+
+BattleTowerAction_UbersCheck: ; 170b16 (5c:4b16) BattleTowerAction $19
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb]
+ call CloseSRAM
+ ld c, 10
+ call SimpleDivide
+ ld a, b
+ ld [wcd4f], a
+ xor a
+ ld [ScriptVar], a
+ callba BattleTower_UbersCheck
+ ret nc
+ ld a, $5
+ call GetSRAMBank
+ ld a, [$b2fb]
+ 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/mobile/mobile_5c.asm
+++ b/mobile/mobile_5c.asm
@@ -75,7 +75,7 @@
; 1700b0
-INCLUDE "misc/battle_tower_5c.asm"
+INCLUDE "mobile/battle_tower_5c.asm"
Function170be4: ; 170be4
ld a, $5
--- /dev/null
+++ b/mobile/mobile_5e.asm
@@ -1,0 +1,929 @@
+
+SECTION "Misc Crystal", ROMX
+
+MobileAdapterGFX::
+INCBIN "gfx/mobile/mobile_adapter.2bpp"
+
+
+Function17a68f:: ; 17a68f (5e:668f)
+ call Function17a6a8
+ call Function17a751
+ ld hl, $d088
+ bit 5, [hl]
+ jr z, .asm_17a6a6
+ ld de, StringBuffer1 ; $d073
+ push de
+ call Function17a721
+ pop de
+ xor a
+ ret
+
+.asm_17a6a6
+ scf
+ ret
+
+Function17a6a8: ; 17a6a8 (5e:66a8)
+ push de
+ push bc
+ ld hl, StringBuffer2 ; $d086
+ ld bc, $a
+ xor a
+ call ByteFill
+ ld hl, Buffer1
+ ld bc, $10
+ ld a, $ff
+ call ByteFill
+ pop bc
+ ld a, c
+ and a
+ jr z, .asm_17a6c9
+ ld hl, $d088
+ set 4, [hl]
+.asm_17a6c9
+ pop de
+ call Function17a6f5
+ call Function17aba0
+ callba Function106464
+ call Function17ac0c
+ callba HDMATransferAttrMapAndTileMapToWRAMBank3
+ call Function17abcf
+ callba LoadOW_BGPal7
+ callba Function49420
+ call SetPalettes
+ call DelayFrame
+ ret
+
+Function17a6f5: ; 17a6f5 (5e:66f5)
+ ld hl, Buffer1
+ ld c, $0
+ ld b, $8
+.asm_17a6fc
+ ld a, [de]
+ call Function17a713
+ jr c, .asm_17a70e
+ ld a, [de]
+ swap a
+ call Function17a713
+ jr c, .asm_17a70e
+ inc de
+ dec b
+ jr nz, .asm_17a6fc
+.asm_17a70e
+ ld a, c
+ ld [$d08c], a
+ ret
+
+Function17a713: ; 17a713 (5e:6713)
+ and $f
+ cp $a
+ jr nc, .asm_17a71d
+ ld [hli], a
+ inc c
+ and a
+ ret
+
+.asm_17a71d
+ ld [hl], $ff
+ scf
+ ret
+
+Function17a721: ; 17a721 (5e:6721)
+ push de
+ ld h, d
+ ld l, e
+ ld bc, $8
+ ld a, $ff
+ call ByteFill
+ pop de
+ ld hl, Buffer1
+ ld b, $8
+.asm_17a732
+ ld c, $0
+ ld a, [hli]
+ cp $a
+ jr nc, .asm_17a748
+ ld c, a
+ ld a, [hli]
+ cp $a
+ jr nc, .asm_17a74c
+ swap a
+ or c
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .asm_17a732
+ ret
+
+.asm_17a748
+ ld a, $ff
+ ld [de], a
+ ret
+
+.asm_17a74c
+ ld a, $f0
+ or c
+ ld [de], a
+ ret
+
+Function17a751: ; 17a751 (5e:6751)
+ xor a
+ ld [$d087], a
+.asm_17a755
+ call Function17a781
+ call Function17a7ae
+ call Function17a97b
+ call Function17a770
+ call Function17a78f
+ ld hl, $d08f
+ inc [hl]
+ ld a, [$d087]
+ bit 7, a
+ jr z, .asm_17a755
+ ret
+
+Function17a770: ; 17a770 (5e:6770)
+ ld a, [hOAMUpdate]
+ push af
+ ld a, $1
+ ld [hOAMUpdate], a
+ call HideSprites
+ call Function17a9cb
+ pop af
+ ld [hOAMUpdate], a
+ ret
+
+Function17a781: ; 17a781 (5e:6781)
+ ld a, [hInMenu]
+ push af
+ ld a, $1
+ ld [hInMenu], a
+ call JoyTextDelay
+ pop af
+ ld [hInMenu], a
+ ret
+
+Function17a78f: ; 17a78f (5e:678f)
+ ld hl, $d088
+ bit 7, [hl]
+ res 7, [hl]
+ jr nz, .asm_17a79f
+ callba HDMATransferTileMapToWRAMBank3
+ ret
+
+.asm_17a79f
+ callba ReloadMapPart
+ ret
+; 17a7a6 (5e:67a6)
+
+Function17a7a6: ; 17a7a6
+ ld a, [$d087]
+ inc a
+ ld [$d087], a
+ ret
+
+Function17a7ae: ; 17a7ae (5e:67ae)
+ ld a, [$d087]
+ ld hl, Jumptable_17a7b6
+ rst JumpTable
+ ret
+
+Jumptable_17a7b6: ; 17a7b6 (5e:67b6)
+ dw Function17a7c2
+ dw Function17a7cd
+ dw Function17a7d8
+ dw Function17a7ff
+ dw Function17a81a
+ dw Function17a7f4
+
+
+Function17a7c2: ; 17a7c2 (5e:67c2)
+ ld a, $4
+ call Function17aad3
+ ld a, $1
+ ld [$d087], a
+ ret
+
+Function17a7cd: ; 17a7cd (5e:67cd)
+ call Function17a83c
+ call Function17a8ae
+ ret c
+ call Function17a848
+ ret
+
+Function17a7d8: ; 17a7d8 (5e:67d8)
+ call Function17a83c
+ call Function17a848
+ ld hl, $d08b
+ dec [hl]
+ ret nz
+ call Function17ac1d
+ call Function17ac2a
+ ld hl, $d088
+ set 7, [hl]
+ ld a, $1
+ ld [$d087], a
+ ret
+
+Function17a7f4: ; 17a7f4 (5e:67f4)
+ ld hl, $d08b
+ dec [hl]
+ ret nz
+ ld hl, $d087
+ set 7, [hl]
+ ret
+
+Function17a7ff: ; 17a7ff (5e:67ff)
+ ld hl, $d08b
+ dec [hl]
+ ret nz
+ call Function17ac1d
+ call Function17ac2a
+ ld hl, $d088
+ set 7, [hl]
+ ld hl, $d088
+ set 5, [hl]
+ ld hl, $d087
+ set 7, [hl]
+ ret
+
+Function17a81a: ; 17a81a (5e:681a)
+ call IsSFXPlaying
+ ret nc
+ ld a, [hJoyPressed]
+ and $3
+ ret z
+ call ExitMenu
+ call Function17ac1d
+ call Function17ac2a
+ ld hl, $d088
+ set 7, [hl]
+ ld hl, $d088
+ res 6, [hl]
+ ld a, $1
+ ld [$d087], a
+ ret
+
+Function17a83c: ; 17a83c (5e:683c)
+ ld a, [hJoyLast]
+ and $f0
+ ld c, a
+ ld a, [hJoyPressed]
+ and $b
+ or c
+ ld c, a
+ ret
+
+Function17a848: ; 17a848 (5e:6848)
+ ld a, c
+ and $60
+ cp $60
+ jr z, .asm_17a876
+ ld a, c
+ and $50
+ cp $50
+ jr z, .asm_17a87d
+ ld a, c
+ and $a0
+ cp $a0
+ jr z, .asm_17a884
+ ld a, c
+ and $90
+ cp $90
+ jr z, .asm_17a88b
+ bit 6, c
+ jr nz, .asm_17a892
+ bit 7, c
+ jr nz, .asm_17a899
+ bit 5, c
+ jr nz, .asm_17a8a0
+ bit 4, c
+ jr nz, .asm_17a8a7
+ xor a
+ ret
+
+.asm_17a876
+ ld a, $9
+ call Function17aad0
+ scf
+ ret
+
+.asm_17a87d
+ ld a, $a
+ call Function17aad0
+ scf
+ ret
+
+.asm_17a884
+ ld a, $b
+ call Function17aad0
+ scf
+ ret
+
+.asm_17a88b
+ ld a, $c
+ call Function17aad0
+ scf
+ ret
+
+.asm_17a892
+ ld a, $5
+ call Function17aad0
+ scf
+ ret
+
+.asm_17a899
+ ld a, $6
+ call Function17aad0
+ scf
+ ret
+
+.asm_17a8a0
+ ld a, $7
+ call Function17aad0
+ scf
+ ret
+
+.asm_17a8a7
+ ld a, $8
+ call Function17aad0
+ scf
+ ret
+
+Function17a8ae: ; 17a8ae (5e:68ae)
+ bit 1, c
+ jr nz, .asm_17a8bc
+ bit 0, c
+ jr nz, .asm_17a8cc
+ bit 3, c
+ jr nz, .asm_17a8d7
+ xor a
+ ret
+
+.asm_17a8bc
+ ld a, $b
+ ld [$d08a], a
+ call Function17aa98
+ call Function17a943
+ call Function17aa88
+ scf
+ ret
+
+.asm_17a8cc
+ call Function17aad7
+ call Function17aa98
+ call Function17a8de
+ scf
+ ret
+
+.asm_17a8d7
+ ld a, $c
+ call Function17aad3
+ scf
+ ret
+
+Function17a8de: ; 17a8de (5e:68de)
+ ld a, $2
+ call Function17aae0
+ ld a, [hl]
+ cp $f1
+ jr z, .asm_17a8fd
+ cp $f0
+ jr z, .asm_17a904
+ cp $f2
+ jr z, .asm_17a911
+ ld e, a
+ call Function17a964
+ ld a, $2
+ ld [$d087], a
+ call Function17aa88
+ ret
+
+.asm_17a8fd
+ call Function17a943
+ call Function17aa88
+ ret
+
+.asm_17a904
+ call Function17aad7
+ call Function17aa98
+ call Function17a91e
+ call Function17aa88
+ ret
+
+.asm_17a911
+ call Function17aa98
+ ld a, $5
+ ld [$d087], a
+ xor a
+ call Function17aa88
+ ret
+
+Function17a91e: ; 17a91e (5e:691e)
+ ld a, [$d08c]
+ cp $7
+ jr c, .asm_17a92c
+ ld a, $3
+ ld [$d087], a
+ xor a
+ ret
+
+.asm_17a92c
+ call LoadStandardMenuDataHeader
+ call Function17a99e
+ ld hl, $d088
+ set 7, [hl]
+ ld hl, $d088
+ set 6, [hl]
+ ld a, $4
+ ld [$d087], a
+ scf
+ ret
+
+Function17a943: ; 17a943 (5e:6943)
+ ld a, [$d08c]
+ and a
+ jr z, .asm_17a95d
+ dec a
+ ld [$d08c], a
+ ld c, a
+ ld b, $0
+ ld hl, Buffer1
+ add hl, bc
+ ld [hl], $ff
+ ld a, $2
+ ld [$d087], a
+ and a
+ ret
+
+.asm_17a95d
+ ld a, $5
+ ld [$d087], a
+ xor a
+ ret
+
+Function17a964: ; 17a964 (5e:6964)
+ ld a, [$d08c]
+ cp $10
+ jr nc, .asm_17a979
+ ld c, a
+ ld b, $0
+ inc a
+ ld [$d08c], a
+ ld hl, Buffer1
+ add hl, bc
+ ld [hl], e
+ and a
+ ret
+
+.asm_17a979
+ scf
+ ret
+
+Function17a97b: ; 17a97b (5e:697b)
+ hlcoord 1, 1
+ lb bc, 2, 18
+ call ClearBox
+ hlcoord 3, 2
+ ld de, Buffer1
+ ld a, [$d08c]
+ and a
+ ret z
+ ld c, a
+.asm_17a990
+ ld a, [de]
+ inc de
+ cp $a
+ jr nc, .asm_17a99d
+ add $f6
+ ld [hli], a
+ dec c
+ jr nz, .asm_17a990
+ ret
+
+.asm_17a99d
+ ret
+
+Function17a99e: ; 17a99e (5e:699e)
+ hlcoord 0, 12
+ ld b, $4
+ ld c, $12
+ call Function17ac46
+ hlcoord 2, 14
+ ld de, String_17a9b2
+ call PlaceString
+ ret
+; 17a9b2 (5e:69b2)
+
+String_17a9b2: ; 17a9b2
+ db "でんわばんごうが ただしく"
+ next "はいって いません!"
+ db "@"
+; 17a9cb
+
+Function17a9cb: ; 17a9cb (5e:69cb)
+ ld de, Sprites ; $c400
+ ld hl, $d088
+ bit 6, [hl]
+ jr nz, .bit_6_set
+ call Function17a9e3
+ call Function17aa22
+ call Function17a9f5
+ ret
+
+.bit_6_set
+ call Function17a9e3
+ ret
+
+Function17a9e3: ; 17a9e3 (5e:69e3)
+ ld a, $3
+ ld [$d08e], a
+ ld hl, Unknown_17aa77
+ ld b, $8
+ ld c, $8
+ ld a, $5
+ call Function17aa4a
+ ret
+
+Function17a9f5: ; 17a9f5 (5e:69f5)
+ ld a, [$d08c]
+ cp $10
+ ret nc
+ ld a, [$d08f]
+ swap a
+ and $1
+ add $1
+ ld [$d08e], a
+ ld a, [$d08c]
+ cp $10
+ jr c, .okay
+ dec a
+.okay
+ ld c, $8
+ call SimpleMultiply
+ add $18
+ ld b, a
+ ld c, $11
+ ld hl, Unknown_17aa72
+ ld a, $4
+ call Function17aa4a
+ ret
+
+Function17aa22: ; 17aa22 (5e:6a22)
+ ld a, $0
+ ld [$d08e], a
+ push de
+ ld a, $3
+ call Function17aae0
+ add a
+ add a
+ add a
+ add $0
+ push af
+ ld a, $4
+ call Function17aae0
+ add a
+ add a
+ add a
+ add $8
+ ld c, a
+ pop af
+ ld b, a
+ pop de
+ ld a, $0
+ ld hl, Unknown_17aa77
+ call Function17aa4a
+ ret
+
+Function17aa4a: ; 17aa4a (5e:6a4a)
+ ld [$d08d], a
+ ld a, b
+ add $8
+ ld b, a
+ ld a, c
+ add $10
+ ld c, a
+ ld a, [hli]
+.loop
+ push af
+ ld a, [hli]
+ add c
+ ld [de], a
+ inc de
+ ld a, [hli]
+ add b
+ ld [de], a
+ inc de
+ ld a, [$d08d]
+ add [hl]
+ inc hl
+ ld [de], a
+ inc de
+ ld a, [$d08e]
+ or [hl]
+ inc hl
+ ld [de], a
+ inc de
+ pop af
+ dec a
+ jr nz, .loop
+ ret
+; 17aa72 (5e:6a72)
+
+Unknown_17aa72: ; 17aa72
+ db 1
+ db 0, 0, 0, 0
+; 17aa77
+
+Unknown_17aa77: ; 17aa77
+ db 4
+ db 0, 0, 0, 0
+ db 0, 8, 1, 0
+ db 8, 0, 2, 0
+ db 8, 8, 3, 0
+; 17aa88
+
+Function17aa88: ; 17aa88 (5e:6a88)
+ jr c, asm_17aa91
+ ld de, SFX_SWITCH_POKEMON
+ call PlaySFX
+ ret
+
+asm_17aa91: ; 17aa91 (5e:6a91)
+ ld de, SFX_WRONG
+ call PlaySFX
+ ret
+
+Function17aa98: ; 17aa98 (5e:6a98)
+ ld a, $5
+ ld [$d08b], a
+ call Function17aaa9
+ call Function17aac3
+ ld hl, $d088
+ set 7, [hl]
+ ret
+
+Function17aaa9: ; 17aaa9 (5e:6aa9)
+ ld a, $3
+ call Function17aae3
+ ld c, a
+ ld b, $0
+ hlcoord 0, 0, AttrMap
+ add hl, bc
+ push hl
+ ld a, $4
+ call Function17aae3
+ ld bc, $14
+ pop hl
+ call AddNTimes
+ ret
+
+Function17aac3: ; 17aac3 (5e:6ac3)
+ ld a, $b
+ push hl
+ ld [hli], a
+ ld [hli], a
+ pop hl
+ ld de, SCREEN_WIDTH
+ add hl, de
+ ld [hli], a
+ ld [hli], a
+ ret
+
+Function17aad0: ; 17aad0 (5e:6ad0)
+ call Function17aae0
+
+Function17aad3: ; 17aad3 (5e:6ad3)
+ ld [$d089], a
+ ret
+
+Function17aad7: ; 17aad7 (5e:6ad7)
+ push af
+ ld a, [$d089]
+ ld [$d08a], a
+ pop af
+ ret
+
+Function17aae0: ; 17aae0 (5e:6ae0)
+ call Function17aad7
+
+Function17aae3: ; 17aae3 (5e:6ae3)
+ push af
+ ld a, [$d08a]
+ ld bc, $d
+ ld hl, Unknown_17aaf7
+ call AddNTimes
+ pop af
+ ld c, a
+ ld b, $0
+ add hl, bc
+ ld a, [hl]
+ ret
+; 17aaf7 (5e:6af7)
+
+Unknown_17aaf7: ; 17aaf7
+ db $0, $0, $1, $6, $5, $9, $3, $2, $1, $2, $1, $2, $4
+ db $0, $0, $2, $9, $5, $a, $4, $0, $2, $a, $a, $3, $5
+ db $0, $0, $3, $c, $5, $b, $5, $1, $0, $1, $0, $4, $0
+ db $0, $0, $4, $6, $8, $0, $6, $5, $4, $5, $1, $5, $7
+ db $0, $0, $5, $9, $8, $1, $7, $3, $5, $0, $2, $6, $8
+ db $0, $0, $6, $c, $8, $2, $8, $4, $3, $1, $3, $7, $3
+ db $0, $0, $7, $6, $b, $3, $9, $8, $7, $8, $4, $8, $a
+ db $0, $0, $8, $9, $b, $4, $a, $6, $8, $3, $5, $9, $b
+ db $0, $0, $9, $c, $b, $5, $b, $7, $6, $4, $6, $a, $6
+ db $0, $0,$f2, $6, $e, $6, $0, $c, $a, $c, $7, $c, $0
+ db $0, $0, $0, $9, $e, $7, $1, $9, $b, $6, $8, $1, $1
+ db $0, $0,$f1, $c, $e, $8, $2, $a, $c, $7, $c, $2, $c
+ db $0, $0,$f0,$10, $e, $c, $c, $b, $9, $b, $9, $b, $9
+; 17aba0
+
+Function17aba0: ; 17aba0 (5e:6ba0)
+ ld a, [rVBK]
+ push af
+ ld a, $1
+ ld [rVBK], a
+
+ ld hl, VTiles5 tile $00
+ ld de, GFX_17afa5
+ lb bc, BANK(GFX_17afa5), $80
+ call Get2bpp
+
+ pop af
+ ld [rVBK], a
+
+ ld hl, VTiles0 tile $00
+ ld de, GFX_17afa5 + $4c0
+ lb bc, BANK(GFX_17afa5), 5
+ call Get2bpp
+
+ ld hl, VTiles0 tile $05
+ ld de, GFX_11601a
+ lb bc, BANK(GFX_11601a), 4
+ call Get2bpp
+ ret
+
+Function17abcf: ; 17abcf (5e:6bcf)
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(UnknBGPals)
+ ld [rSVBK], a
+
+ ld hl, Palette_17ac55
+ ld de, UnknBGPals ; $d000
+ ld bc, $30
+ call CopyBytes
+
+ ld hl, Palette_17ac95
+ ld de, UnknOBPals
+ ld bc, $40
+ call CopyBytes
+
+ ld hl, GFX_17afa5 + $510
+ ld de, UnknOBPals + 2 * 4
+ ld bc, $10
+ call CopyBytes
+
+ ld hl, MapObjectPals + 8
+ ld de, UnknOBPals + 6 * 4
+ ld bc, $8
+ ld a, BANK(MapObjectPals)
+ call FarCopyBytes
+
+ pop af
+ ld [rSVBK], a
+ ret
+
+Function17ac0c: ; 17ac0c (5e:6c0c)
+ call Function17ac1d
+ call Function17ac2a
+ hlcoord 0, 0
+ ld b, 2
+ ld c, SCREEN_WIDTH - 2
+ call Function17ac46
+ ret
+
+Function17ac1d: ; 17ac1d (5e:6c1d)
+ ld hl, Tilemap_17acd5
+ decoord 0, 4
+ ld bc, (SCREEN_HEIGHT - 4) * SCREEN_WIDTH
+ call CopyBytes
+ ret
+
+Function17ac2a: ; 17ac2a (5e:6c2a)
+ ld hl, Tilemap_17ae3d
+ decoord 0, 4, AttrMap
+ ld bc, (SCREEN_HEIGHT - 4) * SCREEN_WIDTH
+ call CopyBytes
+ hlcoord 0, 4, AttrMap
+ ld bc, (SCREEN_HEIGHT - 4) * SCREEN_WIDTH
+.loop
+ ld a, [hl]
+ or $8
+ ld [hli], a
+ dec bc
+ ld a, b
+ or c
+ jr nz, .loop
+ ret
+
+Function17ac46: ; 17ac46 (5e:6c46)
+ ld a, [$d088]
+ bit 4, a
+ jr nz, .bit_4_set
+ call TextBox
+ ret
+
+.bit_4_set
+ call Function3eea
+ ret
+; 17ac55 (5e:6c55)
+
+Palette_17ac55: ; 17ac55
+ RGB 0, 0, 0
+ RGB 9, 10, 25
+ RGB 16, 19, 31
+ RGB 31, 31, 31
+
+ RGB 5, 11, 9
+ RGB 7, 14, 12
+ RGB 17, 24, 22
+ RGB 28, 31, 31
+
+ RGB 0, 0, 0
+ RGB 3, 0, 10
+ RGB 3, 3, 16
+ RGB 6, 8, 25
+
+ RGB 5, 11, 9
+ RGB 28, 31, 31
+ RGB 7, 14, 12
+ RGB 17, 24, 22
+
+ RGB 0, 0, 0
+ RGB 5, 2, 16
+ RGB 8, 8, 26
+ RGB 13, 9, 17
+
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+ RGB 0, 0, 0
+
+Palette_17ac95: ; 17ac95
+ RGB 31, 31, 31
+ RGB 4, 3, 3
+ RGB 31, 13, 0
+ RGB 31, 31, 31
+
+ RGB 31, 31, 31
+ RGB 0, 0, 0
+ RGB 31, 31, 31
+ RGB 31, 31, 31
+
+ RGB 31, 0, 0
+ RGB 16, 3, 0
+ RGB 28, 19, 11
+ RGB 31, 31, 31
+
+ RGB 31, 16, 0
+ RGB 9, 6, 4
+ RGB 31, 16, 0
+ RGB 31, 24, 0
+
+ RGB 31, 18, 6
+ RGB 0, 3, 0
+ RGB 0, 9, 0
+ RGB 0, 12, 0
+
+ RGB 0, 16, 0
+ RGB 0, 22, 0
+ RGB 0, 25, 0
+ RGB 0, 27, 0
+
+ RGB 0, 31, 0
+ RGB 3, 31, 0
+ RGB 8, 31, 0
+ RGB 14, 31, 0
+
+ RGB 16, 31, 0
+ RGB 22, 31, 0
+ RGB 27, 31, 0
+ RGB 31, 31, 0
+
+Tilemap_17acd5: ; 17acd5
+INCBIN "gfx/unknown/17acd5.tilemap"
+
+Tilemap_17ae3d: ; 17ae3d
+INCBIN "gfx/unknown/17ae3d.tilemap"
+
+GFX_17afa5:: ; 17afa5
+INCBIN "gfx/unknown/17afa5.2bpp"
--- /dev/null
+++ b/mobile/news/news.asm
@@ -1,0 +1,44 @@
+; http://forums.glitchcity.info/index.php?topic=7509.msg206449#msg206449
+
+ db $cc, $6b, $1e ; XXX
+
+Function1f4003: ; 1f4003
+; XXX
+ ld a, $6
+ call GetSRAMBank
+ ld hl, .news_data
+ ld de, $a000
+ ld bc, $1000
+ call CopyBytes
+ call CloseSRAM
+ ret
+
+.news_data
+INCBIN "mobile/news/news_1.bin"
+
+Function1f4dbe: ; 1f4dbe
+; XXX
+ ld a, $6
+ call GetSRAMBank
+ ld hl, .news_data
+ ld de, $a000
+ ld bc, $1000
+ call CopyBytes
+ call CloseSRAM
+ ret
+
+.news_data
+INCBIN "mobile/news/news_2.bin"
+
+Function1f5d9f: ; 1f5d9f
+ ld a, $6
+ call GetSRAMBank
+ ld hl, .news_data
+ ld de, $a000
+ ld bc, $1000
+ call CopyBytes
+ call CloseSRAM
+ ret
+
+.news_data
+INCBIN "mobile/news/news_3.bin"
binary files /dev/null b/mobile/news/news_1.bin differ
binary files /dev/null b/mobile/news/news_2.bin differ
binary files /dev/null b/mobile/news/news_3.bin differ
binary files /dev/null b/mobile/stadium/stadium2_1.bin differ
binary files /dev/null b/mobile/stadium/stadium2_2.bin differ
--- a/pokecrystal.link
+++ b/pokecrystal.link
@@ -301,13 +301,13 @@
ROMX $7c
"Battle Tower Trainer Data"
ROMX $7d
- "bank7D"
+ "Mobile News Data"
ROMX $7e
"bank7E"
ROMX $7f
"bank7F"
org $7de0
- "stadium2"
+ "Mobile Stadium 2"
WRAM0
"Stack"
"Audio RAM"
--- a/unknown/013a47.asm
+++ /dev/null
@@ -1,229 +1,0 @@
-CorrectErrorsInPlayerParty: ; unreferenced
- ld hl, PartyCount
- ld a, [hl]
- and a
- ret z
-
- cp PARTY_LENGTH + 1
- jr c, .party_length_okay
- ld a, PARTY_LENGTH
- ld [hl], a
-.party_length_okay
- inc hl
-
- ld b, a
- ld c, 0
-.loop1
- ld a, [hl]
- and a
- jr z, .invalid_species
- cp NUM_POKEMON + 1
- jr z, .invalid_species
- cp EGG + 1
- jr c, .next_species
-
-.invalid_species
- ld [hl], SMEARGLE
- push hl
- push bc
- ld a, c
- ld hl, PartyMon1Species
- call GetPartyLocation
- ld [hl], SMEARGLE
- pop bc
- pop hl
-
-.next_species
- inc hl
- inc c
- dec b
- jr nz, .loop1
- ld [hl], $ff
-
- ld hl, PartyMon1
- ld a, [PartyCount]
- ld d, a
- ld e, 0
-.loop2
- push de
- push hl
- ld b, h
- ld c, l
- ld a, [hl]
- and a
- jr z, .invalid_species_2
- cp NUM_POKEMON + 1
- jr c, .check_level
-
-.invalid_species_2
- ld [hl], SMEARGLE
- push de
- ld d, 0
- ld hl, PartySpecies
- add hl, de
- pop de
- ld a, SMEARGLE
- ld [hl], a
-
-.check_level
- ld [CurSpecies], a
- call GetBaseData
- ld hl, MON_LEVEL
- add hl, bc
- ld a, [hl]
- cp MIN_LEVEL
- ld a, MIN_LEVEL
- jr c, .invalid_level
- ld a, [hl]
- cp MAX_LEVEL
- jr c, .load_level
- ld a, MAX_LEVEL
-.invalid_level
- ld [hl], a
-.load_level
- ld [CurPartyLevel], a
-
- ld hl, MON_MAXHP
- add hl, bc
- ld d, h
- ld e, l
- ld hl, MON_STAT_EXP - 1
- add hl, bc
- ld b, $1
- predef CalcPkmnStats
- pop hl
- ld bc, PARTYMON_STRUCT_LENGTH
- add hl, bc
- pop de
- inc e
- dec d
- jr nz, .loop2
-
- ld de, PartyMonNicknames
- ld a, [PartyCount]
- ld b, a
- ld c, 0
-.loop3
- push bc
- call .GetLengthOfStringWith6CharCap
- push de
- callba CheckStringForErrors
- pop hl
- pop bc
- jr nc, .valid_nickname
-
- push bc
- push hl
- ld hl, PartySpecies
- push bc
- ld b, 0
- add hl, bc
- pop bc
- ld a, [hl]
- cp EGG
- ld hl, .TAMAGO
- jr z, .got_nickname
- ld [wd265], a
- call GetPokemonName
- ld hl, StringBuffer1
-.got_nickname
- pop de
- ld bc, PKMN_NAME_LENGTH
- call CopyBytes
- pop bc
-
-.valid_nickname
- inc c
- dec b
- jr nz, .loop3
-
- ld de, PartyMonOT
- ld a, [PartyCount]
- ld b, a
- ld c, 0
-.loop4
- push bc
- call .GetLengthOfStringWith6CharCap
- push de
- callba CheckStringForErrors
- pop hl
- jr nc, .valid_ot_name
- ld d, h
- ld e, l
- ld hl, PlayerName
- ld bc, NAME_LENGTH
- call CopyBytes
-.valid_ot_name
- pop bc
- inc c
- dec b
- jr nz, .loop4
-
- ld hl, PartyMon1Moves
- ld a, [PartyCount]
- ld b, a
-.loop5
- push hl
- ld c, NUM_MOVES
- ld a, [hl]
- and a
- jr z, .invalid_move
- cp NUM_ATTACKS + 1
- jr c, .moves_loop
-.invalid_move
- ld [hl], POUND
-
-.moves_loop
- ld a, [hl]
- and a
- jr z, .fill_invalid_moves
- cp NUM_ATTACKS + 1
- jr c, .next_move
-
-.fill_invalid_moves
- xor a
- ld [hli], a
- dec c
- jr nz, .fill_invalid_moves
- jr .next_pokemon
-
-.next_move
- inc hl
- dec c
- jr nz, .moves_loop
-
-.next_pokemon
- pop hl
- push bc
- ld bc, PARTYMON_STRUCT_LENGTH
- add hl, bc
- pop bc
- dec b
- jr nz, .loop5
- ret
-; 13b6b
-
-.TAMAGO: ; 13b6b
- db "タマゴ@@@"
-; 13b71
-
-.GetLengthOfStringWith6CharCap: ; 13b71
- push de
- ld c, 1
- ld b, 6
-.search_loop
- ld a, [de]
- cp "@"
- jr z, .done
- inc de
- inc c
- dec b
- jr nz, .search_loop
- dec c
- dec de
- ld a, "@"
- ld [de], a
-.done
- pop de
- ret
-; 13b87
binary files a/unknown/1f4018.bin /dev/null differ
binary files a/unknown/1f4dd3.bin /dev/null differ
binary files a/unknown/1f5db4.bin /dev/null differ