diff options
author | Marcus Huderle <huderlem@gmail.com> | 2017-07-09 19:41:39 -0700 |
---|---|---|
committer | Marcus Huderle <huderlem@gmail.com> | 2017-07-09 19:41:39 -0700 |
commit | 43cf288a358c84cee0b119eaedfec6d839a5a8d1 (patch) | |
tree | cb2d1ab7bdf225c54bbbd0d0e96973bfc92f759a /engine | |
parent | 50240b834c959de010d50d296ccdd4f07fd83a32 (diff) |
More main.asm cleanup
Diffstat (limited to 'engine')
-rw-r--r-- | engine/pinball_game.asm | 4 | ||||
-rw-r--r-- | engine/pinball_game/ball_loss/ball_loss.asm | 10 | ||||
-rw-r--r-- | engine/pinball_game/ball_loss/ball_loss_blue_field.asm | 8 | ||||
-rw-r--r-- | engine/pinball_game/ball_loss/ball_loss_red_field.asm | 8 | ||||
-rwxr-xr-x | engine/pinball_game/draw_num_party_mons_icon.asm | 36 | ||||
-rwxr-xr-x | engine/pinball_game/draw_pikachu_saver_icon.asm | 11 | ||||
-rw-r--r-- | engine/pinball_game/draw_sprites/draw_sprites.asm | 28 | ||||
-rwxr-xr-x | engine/pinball_game/evolution_mode.asm | 916 | ||||
-rwxr-xr-x | engine/pinball_game/map_move.asm | 729 |
9 files changed, 1740 insertions, 10 deletions
diff --git a/engine/pinball_game.asm b/engine/pinball_game.asm index 670457c..3adce56 100644 --- a/engine/pinball_game.asm +++ b/engine/pinball_game.asm @@ -153,8 +153,8 @@ GameScreenFunction_HandleBallPhysics: ; 0xd909 callba HideScoreIfBallLow
callba Func_8645
call Func_dba9
- call Func_dc7c
- call Func_dcb4
+ call DrawNumPartyMonsIcon
+ call DrawPikachuSaverLightningBoltIcon
.asm_d9e9
ld a, [wTimerActive]
and a
diff --git a/engine/pinball_game/ball_loss/ball_loss.asm b/engine/pinball_game/ball_loss/ball_loss.asm index 06b0cda..0a3d8d9 100644 --- a/engine/pinball_game/ball_loss/ball_loss.asm +++ b/engine/pinball_game/ball_loss/ball_loss.asm @@ -32,3 +32,13 @@ CallTable_dc4d: ; 0xdc4d dw HandleBallLossSeelBonus
; STAGE_SEEL_BONUS
dw HandleBallLossSeelBonus
+
+ShowBallLossText: ; 0xdc6d
+; Input: de = pointer to scrolling text header
+ push de
+ call FillBottomMessageBufferWithBlackTile
+ call Func_30db
+ ld hl, wScrollingText3
+ pop de
+ call LoadScrollingText
+ ret
diff --git a/engine/pinball_game/ball_loss/ball_loss_blue_field.asm b/engine/pinball_game/ball_loss/ball_loss_blue_field.asm index 0d241fb..a6aee69 100644 --- a/engine/pinball_game/ball_loss/ball_loss_blue_field.asm +++ b/engine/pinball_game/ball_loss/ball_loss_blue_field.asm @@ -10,7 +10,7 @@ HandleBallLossBlueField: ; 0xde4f ld [wNumTimesBallSavedTextWillDisplay], a
push af
ld de, BallSavedText
- call Func_dc6d
+ call ShowBallLossText
pop af
jr nz, .skip_save_text
ld a, $1
@@ -43,7 +43,7 @@ HandleBallLossBlueField: ; 0xde4f ld a, $1
ld [wd49c], a ; Extra Ball
ld de, EndOfBallBonusText
- call Func_dc6d
+ call ShowBallLossText
ret
.noExtraBall
@@ -54,12 +54,12 @@ HandleBallLossBlueField: ; 0xde4f inc a
ld [wd49d], a
ld de, EndOfBallBonusText
- call Func_dc6d
+ call ShowBallLossText
ret
.gameOver
ld de, EndOfBallBonusText
- call Func_dc6d
+ call ShowBallLossText
ld a, $1
ld [wGameOver], a
ret
diff --git a/engine/pinball_game/ball_loss/ball_loss_red_field.asm b/engine/pinball_game/ball_loss/ball_loss_red_field.asm index fc9895e..03b2252 100644 --- a/engine/pinball_game/ball_loss/ball_loss_red_field.asm +++ b/engine/pinball_game/ball_loss/ball_loss_red_field.asm @@ -10,7 +10,7 @@ HandleBallLossRedField: ; 0xdd76 ld [wNumTimesBallSavedTextWillDisplay], a
push af
ld de, BallSavedText
- call Func_dc6d
+ call ShowBallLossText
pop af
jr nz, .skip_save_text
ld a, $1
@@ -43,7 +43,7 @@ HandleBallLossRedField: ; 0xdd76 ld a, $1
ld [wd49c], a
ld de, EndOfBallBonusText
- call Func_dc6d
+ call ShowBallLossText
ret
.asm_dddd
@@ -54,12 +54,12 @@ HandleBallLossRedField: ; 0xdd76 inc a
ld [wd49d], a
ld de, EndOfBallBonusText
- call Func_dc6d
+ call ShowBallLossText
ret
.gameOver
ld de, EndOfBallBonusText
- call Func_dc6d
+ call ShowBallLossText
ld a, $1
ld [wGameOver], a
ret
diff --git a/engine/pinball_game/draw_num_party_mons_icon.asm b/engine/pinball_game/draw_num_party_mons_icon.asm new file mode 100755 index 0000000..66ad891 --- /dev/null +++ b/engine/pinball_game/draw_num_party_mons_icon.asm @@ -0,0 +1,36 @@ +DrawNumPartyMonsIcon: ; 0xdc7c
+; Draws the number of party Pokemon on the left side of the score bar on the bottom of the screen.
+ ld hl, wBottomMessageBuffer + $40
+ ld a, $83
+ ld [hli], a
+ ld a, $81
+ ld [hli], a
+ ld a, $81
+ ld [hl], a
+ ld a, [wNumPartyMons]
+ call ConvertHexByteToDecWord
+ ld hl, wBottomMessageBuffer + $41
+ ld c, $1
+ ld a, d
+ call .drawDigit
+ ld a, e
+ swap a
+ call .drawDigit
+ ld a, e
+ ld c, $0
+.drawDigit
+ and $f
+ jr nz, .asm_dca7
+ ld a, c
+ and a
+ ret nz
+.asm_dca7
+ ld c, $0
+ add $86
+ ld [hli], a
+ ret
+
+UnusedData_dcad:
+; BCD powers of 2
+; unused
+ db $01, $02, $04, $08, $16, $32, $64
diff --git a/engine/pinball_game/draw_pikachu_saver_icon.asm b/engine/pinball_game/draw_pikachu_saver_icon.asm new file mode 100755 index 0000000..2b915c4 --- /dev/null +++ b/engine/pinball_game/draw_pikachu_saver_icon.asm @@ -0,0 +1,11 @@ +DrawPikachuSaverLightningBoltIcon: ; 0xdcb4
+; Draws the lightning bolt icon when Pikachu saver has been fully charged.
+; The ligntning bolt is drawn in the score bar at the bottom of the screen.
+ ld a, [wPikachuSaverCharge]
+ cp MAX_PIKACHU_SAVER_CHARGE
+ ld a, $81
+ jr nz, .drawIcon
+ ld a, $84
+.drawIcon
+ ld [wBottomMessageBuffer + $46], a
+ ret
diff --git a/engine/pinball_game/draw_sprites/draw_sprites.asm b/engine/pinball_game/draw_sprites/draw_sprites.asm index e9dc693..f526080 100644 --- a/engine/pinball_game/draw_sprites/draw_sprites.asm +++ b/engine/pinball_game/draw_sprites/draw_sprites.asm @@ -19,3 +19,31 @@ CallTable_84bd: ; 0x84bd padded_dab DrawSpritesDiglettBonus ; STAGE_DIGLETT_BONUS
padded_dab DrawSpritesSeelBonus ; STAGE_SEEL_BONUS
padded_dab DrawSpritesSeelBonus ; STAGE_SEEL_BONUS
+
+UnusedFunc_84fd:
+; unused
+ ld a, [hGameBoyColorFlag]
+ and a
+ jr z, .not_cgb
+ ld a, $1
+ ld [rVBK], a
+ xor a
+ call .FillAttrsOrBGMap
+ xor a
+ ld [rVBK], a
+.not_cgb
+ ld a, $81
+ call .FillAttrsOrBGMap
+ ld de, wBottomMessageBuffer + $47
+ call Func_8524
+ ret
+
+.FillAttrsOrBGMap: ; 8519 (2:4519)
+ hlCoord 0, 0, vBGWin
+ ld b, $20
+.loop
+ ld [hli], a
+ ld [hli], a
+ dec b
+ jr nz, .loop
+ ret
diff --git a/engine/pinball_game/evolution_mode.asm b/engine/pinball_game/evolution_mode.asm new file mode 100755 index 0000000..8cc2523 --- /dev/null +++ b/engine/pinball_game/evolution_mode.asm @@ -0,0 +1,916 @@ +Func_10a95: ; 0x19a95
+ ld a, [wCurrentStage]
+ call CallInFollowingTable
+PointerTable_10a9b: ; 0x10a9b
+ padded_dab Func_20581 ; STAGE_RED_FIELD_TOP
+ padded_dab Func_20581 ; STAGE_RED_FIELD_BOTTOM
+ padded_dab Func_20581
+ padded_dab Func_20581
+ padded_dab Func_20bae ; STAGE_BLUE_FIELD_TOP
+ padded_dab Func_20bae ; STAGE_BLUE_FIELD_BOTTOM
+
+StartEvolutionMode: ; 0x10ab3
+ ld a, [wInSpecialMode]
+ and a
+ ret nz
+ ld a, [wCurrentStage]
+ rst JumpTable ; calls JumpToFuncInTable
+StartEvolutionMode_CallTable: ; 0x10abc
+ dw StartEvolutionMode_RedField ; STAGE_RED_FIELD_TOP
+ dw StartEvolutionMode_RedField ; STAGE_RED_FIELD_BOTTOM
+ dw StartEvolutionMode_UnusedField
+ dw StartEvolutionMode_UnusedField
+ dw StartEvolutionMode_BlueField ; STAGE_BLUE_FIELD_TOP
+ dw StartEvolutionMode_BlueField ; STAGE_BLUE_FIELD_BOTTOM
+
+ConcludeEvolutionMode: ; 0x10ac8
+ xor a
+ ld [wd5ca], a
+ call FillBottomMessageBufferWithBlackTile
+ xor a
+ ld [wInSpecialMode], a
+ ld [wWildMonIsHittable], a
+ ld [wd5b6], a
+ ld [wNumMonHits], a
+ ld [wd551], a
+ ld [wd554], a
+ call ClearWildMonCollisionMask
+ callba StopTimer
+ ld a, [wCurrentStage]
+ rst JumpTable ; calls JumpToFuncInTable
+ConcludeEvolutionMode_CallTable: ; 0x10af3
+ dw ConcludeEvolutionMode_RedField ; STAGE_RED_FIELD_TOP
+ dw ConcludeEvolutionMode_RedField ; STAGE_RED_FIELD_BOTTOM
+ dw DoNothing_11060
+ dw DoNothing_11060
+ dw ConcludeEvolutionMode_BlueField ; STAGE_BLUE_FIELD_TOP
+ dw ConcludeEvolutionMode_BlueField ; STAGE_BLUE_FIELD_TOP
+
+LoadRedFieldTopGraphics: ; 0x10aff
+ ld a, [wCurrentStage]
+ res 0, a
+ ld c, a
+ ld b, $0
+ srl c
+ sla a
+ sla a
+ sla a
+ sub c
+ ld c, a
+ ld hl, VideoData_10b2a
+ add hl, bc
+ ld a, [hli]
+ ld c, a
+ ld a, [hli]
+ ld b, a
+ ld a, [hli]
+ push af
+ push bc
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ ld a, [hli]
+ ld c, a
+ ld a, [hli]
+ ld b, a
+ pop hl
+ pop af
+ call LoadVRAMData
+ ret
+
+VideoData_10b2a: ; 0x10b2a
+ dab StageRedFieldTopGfx3
+ dw $8900
+ dw $E0
+ dab StageRedFieldTopGfx3
+ dw $8900
+ dw $E0
+ dab StageRedFieldTopGfx3
+ dw $8900
+ dw $E0
+
+Func_10b3f: ; 0x10b3f
+ call FillBottomMessageBufferWithBlackTile
+ call Func_30db
+ ld hl, wScrollingText1
+ ld a, [wCurrentEvolutionType]
+ cp EVO_EXPERIENCE
+ ld de, StartTrainingText
+ jr z, .asm_10b55
+ ld de, FindItemsText
+.asm_10b55
+ call LoadScrollingText
+ ret
+
+InitEvolutionSelectionMenu: ; 0x10b59
+; Initializes the list menu, which the player uses to select which pokemon to evolve.
+ xor a
+ ld [wDrawBottomMessageBox], a
+ ld hl, wBottomMessageText
+ ld a, $81
+ ld b, $30
+.clearLoop
+ ld [hli], a ; load spaces into bottom text. repeat 192 times
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ dec b
+ jr nz, .clearLoop
+ ld hl, wPartyMons
+ call LoadMonNamesIntoEvolutionSelectionList
+ ld a, BANK(InGameMenuSymbolsGfx)
+ ld hl, InGameMenuSymbolsGfx + $50
+ ld de, vTilesSH tile $08
+ ld bc, $0030
+ call LoadVRAMData
+ ld a, $0
+ ld hl, wBottomMessageText
+ deCoord 0, 0, vBGWin
+ ld bc, $00c0
+ call LoadVRAMData
+ ret
+
+LoadMonNamesIntoEvolutionSelectionList: ; 0x10b8e
+; Loads 6 pokemon names into the list that allows the player to select which pokemon to evolve.
+; Input: hl = pointer to a list of pokemon ids. (an offset of wPartyMons)
+ ld a, [wNumPartyMons]
+ ld c, $0
+ ld b, a
+.loop
+ ld a, [hli]
+ call LoadMonNameIntoEvolutionSelectionList
+ inc c
+ ld a, c
+ cp $6
+ jr z, .done
+ dec b
+ jr nz, .loop
+.done
+ ret
+
+LoadMonNameIntoEvolutionSelectionList: ; 0x10ba2
+; Loads a single pokemon name into the list of pokemon to evolve.
+; Input: c = index of the list
+; a = pokemon id
+ push bc
+ push hl
+ swap c ;c* 32, does wird things if c starts >15
+ sla c
+ ld b, $0
+ ld hl, wBottomMessageText
+ add hl, bc ;goes down text as many times as new c
+ ld d, h
+ ld e, l
+ ld c, a ;c now equals paerty mon, HL stored in de
+ ld b, $0
+ sla c
+ rl b
+ sla c
+ rl b
+ sla c
+ rl b
+ sla c
+ rl b ;multiplies party mon by 16, then jumps to correct name in the table
+ ld hl, PokemonNames ;names are 16 chars long
+ add hl, bc
+ ld a, $81
+ ld [de], a
+ inc de
+ ld a, $81
+ ld [de], a
+ inc de
+ ld a, $81
+ ld [de], a
+ inc de
+ ld a, $81
+ ld [de], a ; loaded 4 spaces into de
+ inc de
+ call LoadMonNameIntoBottomMessageBufferList
+.loadBlankCharacterLoop
+ ld a, e
+ and $1f
+ cp $14
+ jr nc, .done
+ ld a, $81
+ ld [de], a
+ inc de
+ jr .loadBlankCharacterLoop
+
+.done
+ pop hl
+ pop bc
+ ret
+
+SelectPokemonToEvolveMenu: ; 0x10bea
+; Drivers the menu that allows the player to select a pokemon to evolve.
+ xor a
+ ld [wCurSelectedPartyMon], a
+ ld [wCurSelectedPartyMonScrollOffset], a
+ ld [wPartySelectionCursorCounter], a
+.loop
+ call MoveEvolutionSelectionCursor
+ call ClearPersistentJoypadStates
+ call UpdateEvolutionSelectionList
+ rst AdvanceFrame
+ ld a, [wNewlyPressedButtonsPersistent]
+ bit BIT_A_BUTTON, a
+ jr z, .loop
+ lb de, $00, $01
+ call PlaySoundEffect
+ ret
+
+MoveEvolutionSelectionCursor: ; 0x10c0c
+ ld a, [wPressedButtonsPersistent]
+ ld b, a
+ ld a, [wNumPartyMons]
+ ld c, a
+ ld a, [wCurSelectedPartyMon]
+ bit BIT_D_UP, b
+ jr z, .didntPressUp
+ and a
+ ret z
+ ; move the cursor up
+ dec a
+ ld [wCurSelectedPartyMon], a
+ lb de, $00, $03
+ call PlaySoundEffect
+ ret
+
+.didntPressUp
+ bit BIT_D_DOWN, b
+ ret z
+ inc a
+ cp c
+ ret z
+ ; move the cursor down
+ ld [wCurSelectedPartyMon], a
+ lb de, $00, $03
+ call PlaySoundEffect
+ ret
+
+UpdateEvolutionSelectionList: ; 0x10c38
+ ld a, [wCurSelectedPartyMon]
+ ld hl, wCurSelectedPartyMonScrollOffset
+ sub [hl]
+ jr nc, .asm_10c45
+ dec [hl]
+ xor a
+ jr .asm_10c4c
+
+.asm_10c45
+ cp $6
+ jr c, .asm_10c4c
+ inc [hl]
+ ld a, $5
+.asm_10c4c
+ ld c, a
+ push bc
+ ld a, [hl]
+ ld c, a
+ ld b, $0
+ ld hl, wPartyMons
+ add hl, bc
+ call LoadMonNamesIntoEvolutionSelectionList
+ ld a, [hJoypadState]
+ and a
+ ld a, [wPartySelectionCursorCounter]
+ jr z, .asm_10c62
+ xor a
+.asm_10c62
+ inc a
+ ld [wPartySelectionCursorCounter], a
+ bit 3, a
+ pop bc
+ jr nz, .asm_10c78
+ swap c
+ sla c
+ ld b, $0
+ ld hl, wBottomMessageText + $03
+ add hl, bc
+ ld a, $88
+ ld [hl], a
+.asm_10c78
+ ld a, [wCurSelectedPartyMonScrollOffset]
+ and a
+ jr z, .asm_10c83
+ ld a, $8a
+ ld [wBottomMessageText + $11], a
+.asm_10c83
+ ld a, [wCurSelectedPartyMonScrollOffset]
+ add $7
+ jr z, .asm_10c96
+ ld c, a
+ ld a, [wNumPartyMons]
+ cp c
+ jr c, .asm_10c96
+ ld a, $89
+ ld [wBottomMessageText + $b1], a
+.asm_10c96
+ ld a, $0
+ ld hl, wBottomMessageText
+ deCoord 0, 0, vBGWin
+ ld bc, $00c0
+ call LoadVRAMData
+ ret
+
+PlaceEvolutionInParty: ; 0x10ca5
+ ld a, [wCurSelectedPartyMon]
+ ld c, a
+ ld b, $0
+ ld hl, wPartyMons
+ add hl, bc
+ ld a, [wCurrentEvolutionMon]
+ cp $ff
+ ret z
+ ld [hl], a
+ ret
+
+SelectPokemonToEvolve: ; 0x10cb7
+ call FillBottomMessageBufferWithBlackTile
+ call InitEvolutionSelectionMenu
+ ld a, $60
+ ld [hWY], a
+ dec a
+ ld [hLYC], a
+ ld a, $fd
+ ld [hLCDCMask], a
+ call SelectPokemonToEvolveMenu
+ ld a, $86
+ ld [hWY], a
+ ld a, $83
+ ld [hLYC], a
+ ld [hLastLYC], a
+ ld a, $ff
+ ld [hLCDCMask], a
+ ld a, [hGameBoyColorFlag]
+ and a
+ jr nz, .gameboyColor
+ ld a, BANK(StageRedFieldTopStatusBarSymbolsGfx_GameBoy)
+ ld hl, StageRedFieldTopStatusBarSymbolsGfx_GameBoy + $80
+ ld de, vTilesSH tile $08
+ ld bc, $0030
+ call LoadVRAMData
+ jr .asm_10cfc
+
+.gameboyColor
+ ld a, BANK(StageRedFieldTopStatusBarSymbolsGfx_GameBoyColor)
+ ld hl, StageRedFieldTopStatusBarSymbolsGfx_GameBoyColor + $80
+ ld de, vTilesSH tile $08
+ ld bc, $0030
+ call LoadVRAMData
+.asm_10cfc
+ call FillBottomMessageBufferWithBlackTile
+ ld a, SPECIAL_MODE_CATCHEM
+ ld [wDrawBottomMessageBox], a
+ ld [wInSpecialMode], a
+ ld [wSpecialMode], a
+ xor a
+ ld [wd54d], a
+ ld a, [wCurSelectedPartyMon]
+ ld c, a
+ ld b, $0
+ ld hl, wPartyMons
+ add hl, bc
+ ld a, [hl]
+ ld [wCurrentCatchEmMon], a
+ ret
+
+InitEvolutionModeForMon: ; 0x10d1d
+ ld hl, wd586
+ ld b, $18
+.asm_10d22
+ ld a, $1
+ ld [hli], a
+ xor a
+ ld [hli], a
+ dec b
+ jr nz, .asm_10d22
+ ld a, [wCurrentCatchEmMon]
+ ld c, a
+ ld b, $0
+ ld hl, Data_1298b
+ add hl, bc
+ ld a, [hl]
+ add $2
+ ld [wd555], a
+ xor a
+ ld hl, wd566
+ ld b, $13
+.asm_10d40
+ ld [hli], a
+ dec b
+ jr nz, .asm_10d40
+ ld a, [wCurrentCatchEmMon]
+ ld c, a
+ ld b, $0
+ sla c
+ rl b
+ ld hl, CatchEmTimerData
+ add hl, bc
+ ld a, [hli]
+ ld c, a
+ ld a, [hl]
+ ld b, a
+ callba StartTimer
+ ld a, [wCurrentCatchEmMon]
+ ld c, a
+ ld b, $0
+ sla c ; multiply mon id by 6
+ rl b
+ add c
+ ld c, a
+ jr nc, .noCarry
+ inc b
+.noCarry
+ sla c
+ rl b
+ ld hl, MonEvolutions
+ add hl, bc
+ push hl
+ ld bc, $03ff
+.countMonEvolutionsLoop
+ ld a, [hli]
+ and a
+ jr z, .noEvolution
+ inc c
+.noEvolution
+ inc hl
+ dec b
+ jr nz, .countMonEvolutionsLoop
+ ld a, c
+ cp $ff
+ jr nz, .asm_10d8a
+ xor a
+.asm_10d8a
+ call Func_a21
+ sla a
+ ld c, a
+ pop hl
+ add hl, bc ; hl points to one of three entries in mon's evolution data
+ ld a, [hli] ; a = mon id of evolution
+ dec a
+ ld [wCurrentEvolutionMon], a
+ ld a, [hl] ; a = evoluion type id
+ ld [wCurrentEvolutionType], a
+ xor a
+ ld [wd554], a
+ ld [wd556], a
+ ld [wd557], a
+ ld hl, wd55c
+ ld a, $1
+ ld b, $3
+.asm_10dac
+ ld [hli], a
+ dec b
+ jr nz, .asm_10dac
+ xor a
+ ld b, $7
+.asm_10db3
+ ld [hli], a
+ dec b
+ jr nz, .asm_10db3
+ ld de, wd55c
+ ld a, [wd555]
+ ld c, a
+ inc a
+ ld b, a
+.asm_10dc0
+ push bc
+ ld a, c
+ call Func_a21
+ ld c, a
+ ld b, $0
+ ld hl, wd55c
+ add hl, bc
+ ld c, [hl]
+ ld a, [de]
+ ld [hl], a
+ ld a, c
+ ld [de], a
+ pop bc
+ inc de
+ dec b
+ jr nz, .asm_10dc0
+ callba InitBallSaverForCatchEmMode
+ call Func_10b3f
+ call Func_3579
+ ld a, [wCurrentStage]
+ bit 0, a
+ jr z, .asm_10e09
+ ld a, BANK(StageRedFieldBottomBaseGameBoyColorGfx)
+ ld hl, StageRedFieldBottomBaseGameBoyColorGfx + $300
+ ld de, vTilesSH tile $2e
+ ld bc, $0020
+ call LoadOrCopyVRAMData
+ ld a, $0
+ ld hl, CatchBarTiles
+ deCoord 6, 8, vBGMap
+ ld bc, (CatchBarTilesEnd - CatchBarTiles)
+ call LoadOrCopyVRAMData
+.asm_10e09
+ ret
+
+Func_10e0a: ; 0x10e0a
+ ld a, [wCurrentEvolutionMon]
+ cp $ff
+ jp z, Func_10e8b
+ ld c, a
+ ld b, $0
+ sla c
+ rl b
+ sla c
+ rl b
+ sla c
+ rl b
+ sla c
+ rl b
+ ld hl, PokemonNames + 1
+ add hl, bc
+ ld de, ItEvolvedIntoAnText ; "It evolved into an"
+ ld bc, Data_2b34
+ ld a, [hl]
+ ; check if mon's name starts with a vowel, so it can print "an", instead of "a"
+ cp "A"
+ jr z, .nameStartsWithVowel
+ cp "I"
+ jr z, .nameStartsWithVowel
+ cp "U"
+ jr z, .nameStartsWithVowel
+ cp "E"
+ jr z, .nameStartsWithVowel
+ cp "O"
+ jr z, .nameStartsWithVowel
+ ld de, ItEvolvedIntoAText ; "It evolved into a"
+ ld bc, Data_2b1c
+.nameStartsWithVowel
+ push hl
+ push bc
+ push de
+ call FillBottomMessageBufferWithBlackTile
+ call Func_30db
+ ld hl, wScrollingText1
+ pop de
+ call LoadScrollingText
+ ld hl, wScrollingText2
+ pop de
+ call LoadScrollingText
+ pop hl
+ ld de, wBottomMessageText + $20
+ ld b, $0
+.asm_10e67
+ ld a, [hli]
+ and a
+ jr z, .asm_10e70
+ ld [de], a
+ inc de
+ inc b
+ jr .asm_10e67
+
+.asm_10e70
+ ld a, $20
+ ld [de], a
+ inc de
+ xor a
+ ld [de], a
+ ld a, [wScrollingText2ScrollStepsRemaining]
+ add b
+ ld [wScrollingText2ScrollStepsRemaining], a
+ ld a, $14
+ sub b
+ srl a
+ ld b, a
+ ld a, [wScrollingText2StopOffset]
+ add b
+ ld [wScrollingText2StopOffset], a
+ ret
+
+Func_10e8b: ; 0x10e8b
+ ld bc, OneMillionPoints
+ callba AddBigBCD6FromQueue
+ ld bc, $0100
+ ld de, $0000
+ push bc
+ push de
+ call FillBottomMessageBufferWithBlackTile
+ call Func_30db
+ ld hl, wScrollingText2
+ ld de, Data_2b6b
+ call Func_32cc
+ pop de
+ pop bc
+ ld hl, wScrollingText1
+ ld de, EvolutionSpecialBonusText
+ call LoadScrollingText
+ ret
+
+StartEvolutionMode_RedField: ; 0x10ebb
+ ld a, [wNumPartyMons]
+ and a
+ ret z
+ call SelectPokemonToEvolve
+ call InitEvolutionModeForMon
+ ld a, [wd555]
+ sub $2
+ ld c, a
+ sla c
+ ld hl, IndicatorStatesPointerTable_10f3b
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wIndicatorStates
+ ld b, $13
+.loop
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .loop
+ xor a
+ ld [wLeftAlleyCount], a
+ call Func_107b0
+ ld a, $2
+ ld [wd7ad], a
+ ld de, $0002
+ call PlaySong
+ call SetPokemonSeenFlag
+ ld a, [wCurrentStage]
+ bit 0, a
+ jr nz, .asm_10f0b
+ ld a, BANK(EvolutionTrinketsGfx)
+ ld hl, EvolutionTrinketsGfx
+ ld de, vTilesSH tile $10
+ ld bc, $00e0
+ call LoadOrCopyVRAMData
+ ret
+
+.asm_10f0b
+ ld a, BANK(EvolutionTrinketsGfx)
+ ld hl, EvolutionTrinketsGfx
+ ld de, vTilesOB tile $20
+ ld bc, $00e0
+ call LoadOrCopyVRAMData
+ callba Func_14135
+ callba Func_10184
+ ld a, [hGameBoyColorFlag]
+ and a
+ callba nz, Func_102bc
+ ret
+
+IndicatorStatesPointerTable_10f3b: ; 0x10f3b
+ dw IndicatorStates_10f4b
+ dw IndicatorStates_10f5e
+ dw IndicatorStates_10f71
+ dw IndicatorStates_10f84
+ dw IndicatorStates_10f97
+ dw IndicatorStates_10faa
+ dw IndicatorStates_10fbd
+ dw IndicatorStates_10fd0
+
+IndicatorStates_10f4b: ; 0x10f4b
+ db $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $00, $00, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_10f5e: ; 0x10f5e
+ db $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $01, $00, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_10f71: ; 0x10f71
+ db $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_10f84: ; 0x10f84
+ db $00, $00, $00, $00, $00, $00, $00, $00, $01, $01, $00, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_10f97: ; 0x10f97
+ db $00, $00, $00, $80, $00, $00, $00, $00, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_10faa: ; 0x10faa
+ db $00, $00, $80, $80, $00, $00, $00, $00, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_10fbd: ; 0x10fbd
+ db $00, $00, $80, $80, $00, $00, $00, $01, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_10fd0: ; 0x10fd0
+ db $00, $00, $80, $80, $00, $00, $01, $01, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00
+
+ConcludeEvolutionMode_RedField: ; 0x10fe3
+ call ResetIndicatorStates
+ call Func_107c2
+ call SetLeftAndRightAlleyArrowIndicatorStates_RedField
+ call Func_107e9
+ ld a, [wCurrentStage]
+ bit 0, a
+ jp z, LoadRedFieldTopGraphics
+ callba Func_14135
+ callba LoadSlotCaveCoverGraphics_RedField
+ callba LoadMapBillboardTileData
+ ld a, BANK(StageSharedBonusSlotGlowGfx)
+ ld hl, StageSharedBonusSlotGlowGfx + $60
+ ld de, vTilesOB tile $20
+ ld bc, $00e0
+ call LoadVRAMData
+ ld a, [hGameBoyColorFlag]
+ and a
+ jr z, .asm_11036
+ ld a, BANK(StageRedFieldBottomOBJPalette7)
+ ld hl, StageRedFieldBottomOBJPalette7
+ ld de, $0078
+ ld bc, $0008
+ call Func_7dc
+.asm_11036
+ ld hl, BlankSaverSpaceTileDataRedField
+ ld a, BANK(BlankSaverSpaceTileDataRedField)
+ call Func_10aa
+ ld a, [wPreviousNumPokeballs]
+ callba LoadPokeballsGraphics_RedField
+ ld hl, CaughtPokeballTileDataPointers
+ ld a, BANK(CaughtPokeballTileDataPointers)
+ call Func_10aa
+ ret
+
+StartEvolutionMode_UnusedField: ; 0x11054
+ ld a, [wNumPartyMons]
+ and a
+ ret z
+ call SelectPokemonToEvolve
+ call InitEvolutionModeForMon
+ ret
+
+DoNothing_11060: ; 0x11060
+ ret
+
+StartEvolutionMode_BlueField: ; 0x11061
+ ld a, [wNumPartyMons]
+ and a
+ ret z
+ call SelectPokemonToEvolve
+ call InitEvolutionModeForMon
+ ld a, $1
+ ld [wd643], a
+ ld a, [wd555]
+ sub $2
+ ld c, a
+ sla c
+ ld hl, IndicatorStatesPointerTable_110ed
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wIndicatorStates
+ ld b, $13
+.asm_11085
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .asm_11085
+ xor a
+ ld [wLeftAlleyCount], a
+ callba CloseSlotCave
+ ld a, $2
+ ld [wd7ad], a
+ ld de, $0002
+ call PlaySong
+ call SetPokemonSeenFlag
+ ld a, [wCurrentStage]
+ bit 0, a
+ jr nz, .asm_110bd
+ ld a, BANK(EvolutionTrinketsGfx)
+ ld hl, EvolutionTrinketsGfx
+ ld de, vTilesOB tile $60
+ ld bc, $00e0
+ call LoadOrCopyVRAMData
+ ret
+
+.asm_110bd
+ ld a, BANK(EvolutionTrinketsGfx)
+ ld hl, EvolutionTrinketsGfx
+ ld de, vTilesOB tile $20
+ ld bc, $00e0
+ call LoadOrCopyVRAMData
+ callba Func_1c2cb
+ callba Func_10184
+ ld a, [hGameBoyColorFlag]
+ and a
+ callba nz, Func_102bc
+ ret
+
+IndicatorStatesPointerTable_110ed: ; 0x110ed
+ dw IndicatorStates_110fd
+ dw IndicatorStates_11110
+ dw IndicatorStates_11123
+ dw IndicatorStates_11136
+ dw IndicatorStates_11149
+ dw IndicatorStates_1115c
+ dw IndicatorStates_1116f
+ dw IndicatorStates_11182
+
+IndicatorStates_110fd: ; 0x110fd
+ db $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $00, $00, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_11110: ; 0x11110
+ db $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $01, $00, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_11123: ; 0x11123
+ db $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $00, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_11136: ; 0x11136
+ db $00, $00, $80, $00, $00, $00, $00, $00, $01, $01, $00, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_11149: ; 0x11149
+ db $00, $00, $80, $80, $00, $00, $00, $00, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_1115c: ; 0x1115c
+ db $00, $00, $80, $80, $00, $00, $00, $00, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_1116f: ; 0x1116f
+ db $80, $00, $80, $80, $00, $00, $00, $01, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00
+
+IndicatorStates_11182: ; 0x11182
+ db $80, $00, $80, $80, $00, $00, $01, $01, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00
+
+ConcludeEvolutionMode_BlueField: ; 0x11195
+ xor a
+ ld [wd643], a
+ call ResetIndicatorStates
+ call Func_107c2
+ callba SetLeftAndRightAlleyArrowIndicatorStates_BlueField
+ ld a, [wCurrentStage]
+ bit 0, a
+ jp z, LoadBlueFieldTopGraphics
+ callba Func_1c2cb
+ callba LoadSlotCaveCoverGraphics_BlueField
+ callba LoadMapBillboardTileData
+ ld a, Bank(StageSharedBonusSlotGlowGfx)
+ ld hl, StageSharedBonusSlotGlowGfx + $60
+ ld de, vTilesOB tile $20
+ ld bc, $00e0
+ call LoadVRAMData
+ ld a, [hGameBoyColorFlag]
+ and a
+ jr z, .asm_111f0
+ ld a, BANK(StageBlueFieldBottomOBJPalette7)
+ ld hl, StageBlueFieldBottomOBJPalette7
+ ld de, $0078
+ ld bc, $0008
+ call Func_7dc
+.asm_111f0
+ ld hl, BlankSaverSpaceTileDataBlueField
+ ld a, BANK(BlankSaverSpaceTileDataBlueField)
+ call Func_10aa
+ ld a, [wPreviousNumPokeballs]
+ callba LoadPokeballsGraphics_RedField
+ ld hl, Data_10a88
+ ld a, BANK(Data_10a88)
+ call Func_10aa
+ ret
+
+LoadBlueFieldTopGraphics: ; 0x1120e
+ ld a, [wCurrentStage]
+ sub $4
+ res 0, a
+ ld c, a
+ ld b, $0
+ srl c
+ sla a
+ sla a
+ sla a
+ sub c
+ ld c, a
+ ld hl, VRAMData_1123b
+ add hl, bc
+ ld a, [hli]
+ ld c, a
+ ld a, [hli]
+ ld b, a
+ ld a, [hli]
+ push af
+ push bc
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ ld a, [hli]
+ ld c, a
+ ld a, [hli]
+ ld b, a
+ pop hl
+ pop af
+ call LoadVRAMData
+ ret
+
+VRAMData_1123b: ; 0x1123b
+; This doesn't seem very useful...
+ dab StageBlueFieldTopGfx3
+ dw $8600, $E0
+ dab StageBlueFieldTopGfx3
+ dw $8600, $E0
+ dab StageBlueFieldTopGfx3
+ dw $8600, $E0
+ dab StageBlueFieldTopGfx3
+ dw $8600, $E0
+ dab StageBlueFieldTopGfx3
+ dw $8600, $E0
+ dab StageBlueFieldTopGfx3
+ dw $8600, $E0
+ dab StageBlueFieldTopGfx3
+ dw $8600, $E0
diff --git a/engine/pinball_game/map_move.asm b/engine/pinball_game/map_move.asm new file mode 100755 index 0000000..68d2f50 --- /dev/null +++ b/engine/pinball_game/map_move.asm @@ -0,0 +1,729 @@ +Func_301ce: ; 0x301ce
+ ld a, [wCurrentStage]
+ call CallInFollowingTable
+PointerTable_301d4: ; 0x301d4
+ padded_dab Func_314ae ; STAGE_RED_FIELD_TOP
+ padded_dab Func_314ae ; STAGE_RED_FIELD_BOTTOM
+ padded_dab Func_314ae
+ padded_dab Func_314ae
+ padded_dab Func_3161b ; STAGE_BLUE_FIELD_TOP
+ padded_dab Func_3161b ; STAGE_BLUE_FIELD_BOTTOM
+
+StartMapMoveMode: ; 0x301ec
+ ld a, [wInSpecialMode]
+ and a
+ ret nz
+ ld a, $1
+ ld [wInSpecialMode], a
+ ld a, SPECIAL_MODE_MAP_MOVE
+ ld [wSpecialMode], a
+ xor a
+ ld [wd54d], a
+ ld bc, $0030 ; 30 seconds
+ callba StartTimer
+ ld a, [wCurrentStage]
+ bit 0, a
+ jr z, .asm_3021b
+ ld a, [wMapMoveDirection]
+ add $12
+ call LoadBillboardTileData
+.asm_3021b
+ ld a, [wCurrentStage]
+ rst JumpTable ; calls JumpToFuncInTable
+CallTable_3021f: ; 0x3021f
+ dw Func_311b4 ; STAGE_RED_FIELD_TOP
+ dw Func_311b4 ; STAGE_RED_FIELD_BOTTOM
+ dw DoNothing_31324
+ dw DoNothing_31324
+ dw Func_31326 ; STAGE_BLUE_FIELD_TOP
+ dw Func_31326 ; STAGE_BLUE_FIELD_BOTTOM
+
+Func_3022b: ; 0x3022b
+ xor a
+ ld [wd5ca], a ;turn text off
+ call FillBottomMessageBufferWithBlackTile ;clear text
+ xor a
+ ld [wInSpecialMode], a
+ ld [wSpecialMode], a ;no longer in special modes
+ callba StopTimer
+ ld a, [wCurrentStage]
+ rst JumpTable ; calls JumpToFuncInTable
+CallTable_30247: ; 0x30247
+ dw Func_31234 ; STAGE_RED_FIELD_TOP
+ dw Func_31234 ; STAGE_RED_FIELD_BOTTOM
+ dw DoNothing_31325
+ dw DoNothing_31325
+ dw Func_313c3 ; STAGE_BLUE_FIELD_TOP
+ dw Func_313c3 ; STAGE_BLUE_FIELD_TOP
+
+INCLUDE "engine/pinball_game/billboard_tiledata.asm"
+
+LoadScrollingMapNameText: ; 0x3118f
+; Loads the scrolling message that displays the current map's name.
+; Input: bc = pointer to prefix scrolling text
+ push bc
+ call FillBottomMessageBufferWithBlackTile
+ call Func_30db
+ ld a, [wCurrentMap]
+ sla a
+ ld c, a
+ ld b, $0
+ ld hl, MapNames
+ add hl, bc
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ ld hl, wScrollingText2
+ call LoadScrollingText
+ pop de
+ ld hl, wScrollingText1
+ call LoadScrollingText
+ ret
+
+Func_311b4: ; 0x311b4
+ ld a, [wMapMoveDirection]
+ and a
+ jr nz, .asm_311ce
+ ld a, $80
+ ld [wIndicatorStates], a
+ ld [wIndicatorStates + 2], a
+ xor a
+ ld [wIndicatorStates + 1], a
+ ld [wIndicatorStates + 3], a
+ ld [wIndicatorStates + 4], a
+ jr .asm_311e2
+
+.asm_311ce
+ ld a, $80
+ ld [wIndicatorStates + 1], a
+ ld [wIndicatorStates + 3], a
+ xor a
+ ld [wIndicatorStates], a
+ ld [wIndicatorStates + 2], a
+ ld [wIndicatorStates + 4], a
+ jr .asm_311e2
+
+.asm_311e2
+ ld a, $2
+ callba LoadDiglettGraphics
+ ld a, $5
+ callba LoadDiglettGraphics
+ ld a, $6a
+ ld [wStageCollisionMap + $f0], a
+ ld a, $6b
+ ld [wStageCollisionMap + $110], a
+ ld a, $66
+ ld [wStageCollisionMap + $e3], a
+ ld a, $67
+ ld [wStageCollisionMap + $103], a
+ callba Func_107b0
+ ld a, $4
+ ld [wd7ad], a
+ ld de, $0003
+ call PlaySong
+ ld a, [wCurrentStage]
+ bit 0, a
+ ret z
+ callba Func_14135
+ ret
+
+Func_31234: ; 0x31234
+ callba ResetIndicatorStates
+ callba Func_107c2
+ callba SetLeftAndRightAlleyArrowIndicatorStates_RedField
+ callba Func_107e9
+ ld a, [wCurrentStage]
+ bit 0, a
+ ret z
+ callba Func_14135
+ callba LoadSlotCaveCoverGraphics_RedField
+ callba LoadMapBillboardTileData
+ ret
+
+ChooseNextMap_RedField: ; 0x31282
+; Picks the next map to perform a map move.
+; Also records which maps have been visited.
+ ld a, [wNumMapMoves]
+ inc a
+ cp $6
+ jr c, .dontReset
+ ld a, $ff
+ ld [wVisitedMaps], a
+ ld [wVisitedMaps + 1], a
+ ld [wVisitedMaps + 2], a
+ ld [wVisitedMaps + 3], a
+ ld [wVisitedMaps + 4], a
+ ld [wVisitedMaps + 5], a
+ xor a
+.dontReset
+ ld [wNumMapMoves], a
+ cp $3
+ jr c, .chooseMapFromArea1
+ cp $5
+ jr c, .chooseMapFromArea2
+ ld a, INDIGO_PLATEAU
+ ld [wCurrentMap], a
+ ld [wVisitedMaps + 5], a
+ ret
+
+.chooseMapFromArea1
+ call GenRandom
+ and $7
+ cp $7
+ jr nc, .chooseMapFromArea1
+ ld c, a
+ ld b, $0
+ ld hl, FirstMapMoveSet_RedField
+ add hl, bc
+ ld c, [hl]
+ ld hl, wVisitedMaps
+ ld a, [wNumMapMoves]
+ and a
+ jr z, .asm_312d4
+ ld b, a
+.asm_312cd
+ ld a, [hli]
+ cp c
+ jr z, .chooseMapFromArea1
+ dec b
+ jr nz, .asm_312cd
+.asm_312d4
+ ld a, c
+ ld [wCurrentMap], a
+ ld a, [wNumMapMoves]
+ ld c, a
+ ld b, $0
+ ld hl, wVisitedMaps
+ add hl, bc
+ ld a, [wCurrentMap]
+ ld [hl], a
+ ret
+
+.chooseMapFromArea2
+ call GenRandom
+ and $3
+ ld c, a
+ ld b, $0
+ ld hl, SecondMapMoveSet_RedField
+ add hl, bc
+ ld c, [hl]
+ ld hl, wVisitedMaps + 3
+ ld a, [wNumMapMoves]
+ sub $3
+ jr z, .asm_31306
+ ld b, a
+.asm_312ff
+ ld a, [hli]
+ cp c
+ jr z, .chooseMapFromArea2
+ dec b
+ jr nz, .asm_312ff
+.asm_31306
+ ld a, c
+ ld [wCurrentMap], a
+ ld a, [wNumMapMoves]
+ ld c, a
+ ld b, $0
+ ld hl, wVisitedMaps
+ add hl, bc
+ ld a, [wCurrentMap]
+ ld [hl], a
+ ret
+
+FirstMapMoveSet_RedField:
+ db PALLET_TOWN
+ db VIRIDIAN_FOREST
+ db PEWTER_CITY
+ db CERULEAN_CITY
+ db VERMILION_SEASIDE
+ db ROCK_MOUNTAIN
+ db LAVENDER_TOWN
+
+SecondMapMoveSet_RedField:
+ db CYCLING_ROAD
+ db SAFARI_ZONE
+ db SEAFOAM_ISLANDS
+ db CINNABAR_ISLAND
+
+DoNothing_31324: ; 0x31324
+ ret
+
+DoNothing_31325: ; 0x31325
+ ret
+
+Func_31326: ; 0x31326
+ ld a, [wMapMoveDirection]
+ and a
+ jr nz, .asm_3134c
+ ld a, $80
+ ld [wIndicatorStates], a
+ ld [wIndicatorStates + 2], a
+ xor a
+ ld [wIndicatorStates + 1], a
+ ld [wIndicatorStates + 3], a
+ ld [wIndicatorStates + 4], a
+ ld a, $3
+ callba LoadPsyduckOrPoliwagGraphics
+ jr .asm_31382
+
+.asm_3134c
+ ld a, $80
+ ld [wIndicatorStates + 1], a
+ ld [wIndicatorStates + 3], a
+ xor a
+ ld [wIndicatorStates], a
+ ld [wIndicatorStates + 2], a
+ ld [wIndicatorStates + 4], a
+ ld a, $1
+ callba LoadPsyduckOrPoliwagGraphics
+ ld a, $6
+ callba LoadPsyduckOrPoliwagGraphics
+ ld a, $7
+ callba LoadPsyduckOrPoliwagNumberGraphics
+.asm_31382
+ ld a, [wCurrentStage]
+ bit 0, a
+ jr z, .asm_3139d
+ ld a, $54
+ ld [wStageCollisionMap + $e3], a
+ ld a, $55
+ ld [wStageCollisionMap + $103], a
+ ld a, $52
+ ld [wStageCollisionMap + $f0], a
+ ld a, $53
+ ld [wStageCollisionMap + $110], a
+.asm_3139d
+ ld a, $1
+ ld [wd644], a
+ callba CloseSlotCave
+ ld de, $0003
+ call PlaySong
+ ld a, [wCurrentStage]
+ bit 0, a
+ ret z
+ callba Func_1c2cb
+ ret
+
+Func_313c3: ; 0x313c3
+ callba ResetIndicatorStates
+ callba Func_107c2
+ callba SetLeftAndRightAlleyArrowIndicatorStates_BlueField
+ ld a, $0
+ ld [wd644], a
+ ld a, [wCurrentStage]
+ bit 0, a
+ ret z
+ callba Func_1c2cb
+ callba LoadSlotCaveCoverGraphics_BlueField
+ callba LoadMapBillboardTileData
+ ret
+
+ChooseNextMap_BlueField: ; 0x3140b
+; Picks the next map to perform a map move.
+; Also records which maps have been visited.
+ ld a, [wNumMapMoves]
+ inc a
+ cp $6
+ jr c, .dontReset
+ ld a, $ff
+ ld [wVisitedMaps], a
+ ld [wVisitedMaps + 1], a
+ ld [wVisitedMaps + 2], a
+ ld [wVisitedMaps + 3], a
+ ld [wVisitedMaps + 4], a
+ ld [wVisitedMaps + 5], a
+ xor a
+.dontReset
+ ld [wNumMapMoves], a
+ cp $3
+ jr c, .chooseMapFromArea1
+ cp $5
+ jr c, .chooseMapFromArea2
+ ld a, INDIGO_PLATEAU
+ ld [wCurrentMap], a
+ ld [wVisitedMaps + 5], a
+ ret
+
+.chooseMapFromArea1
+ call GenRandom
+ and $7
+ cp $7
+ jr nc, .chooseMapFromArea1
+ ld c, a
+ ld b, $0
+ ld hl, FirstMapMoveSet_BlueField
+ add hl, bc
+ ld c, [hl]
+ ld hl, wVisitedMaps
+ ld a, [wNumMapMoves]
+ and a
+ jr z, .asm_3145e
+ ld b, a
+.asm_31457
+ ld a, [hli]
+ cp c
+ jr z, .chooseMapFromArea1
+ dec b
+ jr nz, .asm_31457
+.asm_3145e
+ ld a, c
+ ld [wCurrentMap], a
+ ld a, [wNumMapMoves]
+ ld c, a
+ ld b, $0
+ ld hl, wVisitedMaps
+ add hl, bc
+ ld a, [wCurrentMap]
+ ld [hl], a
+ ret
+
+.chooseMapFromArea2
+ call GenRandom
+ and $3
+ ld c, a
+ ld b, $0
+ ld hl, SecondMapMoveSet_BlueField
+ add hl, bc
+ ld c, [hl]
+ ld hl, wVisitedMaps + 3
+ ld a, [wNumMapMoves]
+ sub $3
+ jr z, .asm_31490
+ ld b, a
+.asm_31489
+ ld a, [hli]
+ cp c
+ jr z, .chooseMapFromArea2
+ dec b
+ jr nz, .asm_31489
+.asm_31490
+ ld a, c
+ ld [wCurrentMap], a
+ ld a, [wNumMapMoves]
+ ld c, a
+ ld b, $0
+ ld hl, wVisitedMaps
+ add hl, bc
+ ld a, [wCurrentMap]
+ ld [hl], a
+ ret
+
+FirstMapMoveSet_BlueField:
+ db VIRIDIAN_CITY
+ db VIRIDIAN_FOREST
+ db MT_MOON
+ db CERULEAN_CITY
+ db VERMILION_STREETS
+ db ROCK_MOUNTAIN
+ db CELADON_CITY
+
+SecondMapMoveSet_BlueField:
+ db FUCHSIA_CITY
+ db SAFARI_ZONE
+ db SAFFRON_CITY
+ db CINNABAR_ISLAND
+
+Func_314ae: ; 0x314ae
+ ld a, [wTimerActive]
+ and a
+ ld a, [wd54c]
+ jr z, .asm_314d0
+ cp $1
+ jp z, Func_31591
+ cp $3
+ jp z, Func_31591
+ cp $2
+ jp z, Func_315b3
+ cp $5
+ jp z, Func_315b3
+ cp $d
+ jp z, Func_315d5
+.asm_314d0
+ cp $0
+ jr z, .asm_314d6
+ scf
+ ret
+
+.asm_314d6
+ call Func_3151f
+ ld a, [wd54d]
+ call CallInFollowingTable
+PointerTable_314df: ; 0xd13df
+ padded_dab Func_314ef
+ padded_dab Func_314f1
+ padded_dab Func_314f3
+ padded_dab Func_31505
+
+Func_314ef: ; 0x314ef
+ scf
+ ret
+
+Func_314f1: ; 0x314f1
+ scf
+ ret
+
+Func_314f3: ; 0x314f3
+ callba Func_3022b
+ ld de, $0001
+ call PlaySong
+ scf
+ ret
+
+Func_31505: ; 0x31505
+ ld a, [wd5ca]
+ and a
+ ret nz
+ call FillBottomMessageBufferWithBlackTile
+ callba Func_3022b
+ ld de, $0001
+ call PlaySong
+ scf
+ ret
+
+Func_3151f: ; 0x3151f
+ ld a, $50
+ ld [wd4ef], a
+ ld [wd4f1], a
+ callba Func_107f8
+ ld a, [wd57e]
+ and a
+ ret z
+ xor a
+ ld [wd57e], a
+ ld a, $3
+ ld [wd54d], a
+ xor a
+ ld [wSlotIsOpen], a
+ ld [wIndicatorStates], a
+ ld [wIndicatorStates + 1], a
+ ld [wIndicatorStates + 2], a
+ ld [wIndicatorStates + 3], a
+ ld [wIndicatorStates + 4], a
+ ld a, [wCurrentStage]
+ bit 0, a
+ jr z, .asm_31577
+ callba Func_14135
+ callba LoadSlotCaveCoverGraphics_RedField
+ callba LoadMapBillboardTileData
+.asm_31577
+ callba StopTimer
+ call FillBottomMessageBufferWithBlackTile
+ call Func_30db
+ ld hl, wScrollingText1
+ ld de, MapMoveFailedText
+ call LoadScrollingText
+ ret
+
+Func_31591: ; 0x31591
+ ld a, [wMapMoveDirection]
+ and a
+ jr nz, .asm_315b1
+ ld a, [wIndicatorStates]
+ and a
+ jr z, .asm_315b1
+ xor a
+ ld [wIndicatorStates], a
+ ld [wIndicatorStates + 2], a
+ ld a, $80
+ ld [wIndicatorStates + 4], a
+ ld a, $1
+ ld [wSlotIsOpen], a
+ ld [wd54d], a
+.asm_315b1
+ scf
+ ret
+
+Func_315b3: ; 0x315b3
+ ld a, [wMapMoveDirection]
+ and a
+ jr z, .asm_315d3
+ ld a, [wIndicatorStates + 1]
+ and a
+ jr z, .asm_315d3
+ xor a
+ ld [wIndicatorStates + 1], a
+ ld [wIndicatorStates + 3], a
+ ld a, $80
+ ld [wIndicatorStates + 4], a
+ ld a, $1
+ ld [wSlotIsOpen], a
+ ld [wd54d], a
+.asm_315d3
+ scf
+ ret
+
+Func_315d5: ; 0x315d5
+ ld de, $0000
+ call PlaySong
+ rst AdvanceFrame
+ callba ChooseNextMap_RedField
+ callba LoadMapBillboardTileData
+ lb de, $25, $25
+ call PlaySoundEffect
+ ld bc, ArrivedAtMapText
+ callba LoadScrollingMapNameText
+.asm_31603
+ callba Func_33e3
+ rst AdvanceFrame
+ ld a, [wd5ca]
+ and a
+ jr nz, .asm_31603
+ ld a, $2
+ ld [wd54d], a
+ scf
+ ret
+
+Func_3161b: ; 0x3161b
+ ld a, [wTimerActive]
+ and a
+ ld a, [wd54c]
+ jr z, .asm_3163d
+ cp $1
+ jp z, Func_31708
+ cp $f
+ jp z, Func_31708
+ cp $2
+ jp z, Func_3172a
+ cp $e
+ jp z, Func_3172a
+ cp $d
+ jp z, Func_3174c
+.asm_3163d
+ cp $0
+ jr z, .asm_31643
+ scf
+ ret
+
+.asm_31643
+ call Func_3168c
+ ld a, [wd54d]
+ call CallInFollowingTable
+PointerTable_3164c: ; 0x3164c
+ padded_dab Func_3165c
+ padded_dab Func_3165e
+ padded_dab Func_31660
+ padded_dab Func_31672
+
+Func_3165c: ; 0x3165c
+ scf
+ ret
+
+Func_3165e: ; 0x3165e
+ scf
+ ret
+
+Func_31660: ; 0x31660
+ callba Func_3022b
+ ld de, $0001
+ call PlaySong
+ scf
+ ret
+
+Func_31672: ; 0x31672
+ ld a, [wd5ca] ;if text is off
+ and a
+ ret nz
+ call FillBottomMessageBufferWithBlackTile
+ callba Func_3022b
+ ld de, $0001
+ call PlaySong
+ scf
+ ret
+
+Func_3168c: ; 0x3168c
+ ld a, $50
+ ld [wLeftMapMoveDiglettAnimationCounter], a
+ ld [wRightMapMoveDiglettFrame], a
+ ld a, $3
+ ld [wd645], a
+ ld a, $1
+ ld [wd646], a
+ callba Func_107f8
+ ld a, [wd57e]
+ and a
+ ret z
+ xor a
+ ld [wd57e], a
+ ld a, $3
+ ld [wd54d], a
+ xor a
+ ld [wSlotIsOpen], a
+ ld [wIndicatorStates], a
+ ld [wIndicatorStates + 1], a
+ ld [wIndicatorStates + 2], a
+ ld [wIndicatorStates + 3], a
+ ld [wIndicatorStates + 4], a
+ ld a, [wCurrentStage]
+ bit 0, a
+ jr z, .asm_316ee
+ callba Func_1c2cb
+ callba LoadSlotCaveCoverGraphics_BlueField
+ callba LoadMapBillboardTileData
+.asm_316ee
+ callba StopTimer
+ call FillBottomMessageBufferWithBlackTile
+ call Func_30db
+ ld hl, wScrollingText1
+ ld de, MapMoveFailedText
+ call LoadScrollingText
+ ret
+
+Func_31708: ; 0x31708
+ ld a, [wMapMoveDirection]
+ and a
+ jr nz, .asm_31728
+ ld a, [wIndicatorStates]
+ and a
+ jr z, .asm_31728
+ xor a
+ ld [wIndicatorStates], a
+ ld [wIndicatorStates + 2], a
+ ld a, $80
+ ld [wIndicatorStates + 4], a
+ ld a, $1
+ ld [wSlotIsOpen], a
+ ld [wd54d], a
+.asm_31728
+ scf
+ ret
+
+Func_3172a: ; 0x3172a
+ ld a, [wMapMoveDirection]
+ and a
+ jr z, .asm_3174a
+ ld a, [wIndicatorStates + 1]
+ and a
+ jr z, .asm_3174a
+ xor a
+ ld [wIndicatorStates + 1], a
+ ld [wIndicatorStates + 3], a
+ ld a, $80
+ ld [wIndicatorStates + 4], a
+ ld a, $1
+ ld [wSlotIsOpen], a
+ ld [wd54d], a
+.asm_3174a
+ scf
+ ret
+
+Func_3174c: ; 0x3174c
+ ld de, $0000
+ call PlaySong
+ rst AdvanceFrame
+ callba ChooseNextMap_BlueField
+ callba LoadMapBillboardTileData
+ lb de, $25, $25
+ call PlaySoundEffect
+ ld bc, ArrivedAtMapText
+ callba LoadScrollingMapNameText
+.asm_3177a
+ callba Func_33e3
+ rst AdvanceFrame
+ ld a, [wd5ca]
+ and a
+ jr nz, .asm_3177a
+ ld a, $2
+ ld [wd54d], a
+ scf
+ ret
|