aboutsummaryrefslogtreecommitdiffstats
path: root/engine/movie
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2020-07-03 09:38:52 -0400
committerGitHub <noreply@github.com>2020-07-03 09:38:52 -0400
commitc85050497c1bd062e9cd40bf5b32fa3beca366cc (patch)
tree9593ddd3ab820223ab580d5fc0ae133b485b8315 /engine/movie
parentActually run .travis/webhook.sh (diff)
parentAdd engine/movie/oak_speech/ subdirectory (diff)
downloadpokeyellow-c85050497c1bd062e9cd40bf5b32fa3beca366cc.tar.gz
pokeyellow-c85050497c1bd062e9cd40bf5b32fa3beca366cc.tar.xz
pokeyellow-c85050497c1bd062e9cd40bf5b32fa3beca366cc.zip
Merge pull request #256 from Rangi42/master
Add subdirectories to engine/ similar to pokecrystal
Diffstat (limited to 'engine/movie')
-rwxr-xr-xengine/movie/credits.asm270
-rwxr-xr-xengine/movie/evolution.asm160
-rwxr-xr-xengine/movie/gamefreak.asm243
-rwxr-xr-xengine/movie/hall_of_fame.asm288
-rwxr-xr-xengine/movie/intro.asm470
-rwxr-xr-xengine/movie/oak_speech/clear_save.asm23
-rw-r--r--engine/movie/oak_speech/init_player_data.asm55
-rwxr-xr-xengine/movie/oak_speech/oak_speech.asm233
-rwxr-xr-xengine/movie/oak_speech/oak_speech2.asm219
-rwxr-xr-xengine/movie/titlescreen.asm403
-rwxr-xr-xengine/movie/titlescreen2.asm120
-rwxr-xr-xengine/movie/trade.asm853
-rwxr-xr-xengine/movie/trade2.asm48
13 files changed, 3385 insertions, 0 deletions
diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm
new file mode 100755
index 00000000..f820aae3
--- /dev/null
+++ b/engine/movie/credits.asm
@@ -0,0 +1,270 @@
+HallOfFamePC:
+ callba AnimateHallOfFame
+ call ClearScreen
+ ld c, 100
+ call DelayFrames
+ call DisableLCD
+ ld hl, vFont
+ ld bc, $800 / 2
+ call ZeroMemory
+ ld hl, vChars2 + $600
+ ld bc, $200 / 2
+ call ZeroMemory
+ ld hl, vChars2 + $7e0
+ ld bc, $10
+ ld a, $ff
+ call FillMemory
+ coord hl, 0, 0
+ call FillFourRowsWithBlack
+ coord hl, 0, 14
+ call FillFourRowsWithBlack
+ ld a, %11000000
+ ld [rBGP], a
+ call EnableLCD
+ ld a, $ff
+ call PlaySoundWaitForCurrent
+ ld c, BANK(Music_Credits)
+ ld a, MUSIC_CREDITS
+ call PlayMusic
+ ld c, 128
+ call DelayFrames
+ xor a
+ ld [wUnusedCD3D], a ; not read
+ ld [wNumCreditsMonsDisplayed], a
+ jp Credits
+
+FadeInCreditsText:
+ ld hl, HoFGBPalettes
+ ld b, 4
+.loop
+ ld a, [hli]
+ ld [rBGP], a
+ ld c, 5
+ call DelayFrames
+ dec b
+ jr nz, .loop
+ ret
+
+DisplayCreditsMon:
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call SaveScreenTilesToBuffer1
+ call FillMiddleOfScreenWithWhite
+
+ ; display the next monster from CreditsMons
+ ld hl, wNumCreditsMonsDisplayed
+ ld c, [hl] ; how many monsters have we displayed so far?
+ inc [hl]
+ ld b, 0
+ ld hl, CreditsMons
+ add hl, bc ; go that far in the list of monsters and get the next one
+ ld a, [hl]
+ ld [wcf91], a
+ ld [wd0b5], a
+ coord hl, 8, 6
+ call GetMonHeader
+ call LoadFrontSpriteByMonIndex
+ ld hl, vBGMap0 + $c
+ call CreditsCopyTileMapToVRAM
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call LoadScreenTilesFromBuffer1
+ ld hl, vBGMap0
+ call CreditsCopyTileMapToVRAM
+ ld a, $A7
+ ld [rWX], a
+ ld hl, vBGMap1
+ call CreditsCopyTileMapToVRAM
+ call FillMiddleOfScreenWithWhite
+ ld a, %11111100 ; make the mon a black silhouette
+ ld [rBGP], a
+
+; scroll the mon left by one tile 7 times
+ ld bc, 7
+.scrollLoop1
+ call ScrollCreditsMonLeft
+ dec c
+ jr nz, .scrollLoop1
+
+; scroll the mon left by one tile 20 times
+; This time, we have to move the window left too in order to hide the text that
+; is wrapping around to the right side of the screen.
+ ld c, 20
+.scrollLoop2
+ call ScrollCreditsMonLeft
+ ld a, [rWX]
+ sub 8
+ ld [rWX], a
+ dec c
+ jr nz, .scrollLoop2
+
+ xor a
+ ld [hWY], a
+ ld a, %11000000
+ ld [rBGP], a
+ ret
+
+INCLUDE "data/credit_mons.asm"
+
+ScrollCreditsMonLeft:
+ ld h, b
+ ld l, $20
+ call ScrollCreditsMonLeft_SetSCX
+ ld h, $0
+ ld l, $70
+ call ScrollCreditsMonLeft_SetSCX
+ ld a, b
+ add $8
+ ld b, a
+ ret
+
+ScrollCreditsMonLeft_SetSCX:
+ ld a, [rLY]
+ cp l
+ jr nz, ScrollCreditsMonLeft_SetSCX
+ ld a, h
+ ld [rSCX], a
+.loop
+ ld a, [rLY]
+ cp h
+ jr z, .loop
+ ret
+
+HoFGBPalettes:
+ db %11000000
+ db %11010000
+ db %11100000
+ db %11110000
+
+CreditsCopyTileMapToVRAM:
+ ld a, l
+ ld [H_AUTOBGTRANSFERDEST], a
+ ld a, h
+ ld [H_AUTOBGTRANSFERDEST + 1], a
+ ld a, 1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ jp Delay3
+
+ZeroMemory:
+; zero bc bytes at hl
+ ld [hl], 0
+ inc hl
+ inc hl
+ dec bc
+ ld a, b
+ or c
+ jr nz, ZeroMemory
+ ret
+
+FillFourRowsWithBlack:
+ ld bc, SCREEN_WIDTH * 4
+ ld a, $7e
+ jp FillMemory
+
+FillMiddleOfScreenWithWhite:
+ coord hl, 0, 4
+ ld bc, SCREEN_WIDTH * 10
+ ld a, " "
+ jp FillMemory
+
+Credits:
+ ld de, CreditsOrder
+ push de
+.nextCreditsScreen
+ pop de
+ coord hl, 9, 6
+ push hl
+ call FillMiddleOfScreenWithWhite
+ pop hl
+.nextCreditsCommand
+ ld a, [de]
+ inc de
+ push de
+ cp $ff
+ jr z, .fadeInTextAndShowMon
+ cp $fe
+ jr z, .showTextAndShowMon
+ cp $fd
+ jr z, .fadeInText
+ cp $fc
+ jr z, .showText
+ cp $fb
+ jr z, .showCopyrightText
+ cp $fa
+ jr z, .showTheEnd
+ push hl
+ push hl
+ ld hl, CreditsTextPointers
+ add a
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld a, [de]
+ inc de
+ ld c, a
+ ld b, $ff
+ pop hl
+ add hl, bc
+ call PlaceString
+ pop hl
+ ld bc, SCREEN_WIDTH * 2
+ add hl, bc
+ pop de
+ jr .nextCreditsCommand
+.fadeInTextAndShowMon
+ call FadeInCreditsText
+ ld c, 90
+ jr .next1
+.showTextAndShowMon
+ ld c, 110
+.next1
+ call DelayFrames
+ call DisplayCreditsMon
+ jr .nextCreditsScreen
+.fadeInText
+ call FadeInCreditsText
+ ld c, 120
+ jr .next2
+.showText
+ ld c, 140
+.next2
+ call DelayFrames
+ jr .nextCreditsScreen
+.showCopyrightText
+ push de
+ callba LoadCopyrightTiles
+ pop de
+ pop de
+ jr .nextCreditsCommand
+.showTheEnd
+ ld c, 16
+ call DelayFrames
+ call FillMiddleOfScreenWithWhite
+ pop de
+ ld de, TheEndGfx
+ ld hl, vChars2 + $600
+ lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / $10
+ call CopyVideoData
+ coord hl, 4, 8
+ ld de, TheEndTextString
+ call PlaceString
+ coord hl, 4, 9
+ inc de
+ call PlaceString
+ jp FadeInCreditsText
+
+TheEndTextString:
+; "T H E E N D"
+ db $60," ",$62," ",$64," ",$64," ",$66," ",$68,"@"
+ db $61," ",$63," ",$65," ",$65," ",$67," ",$69,"@"
+
+INCLUDE "data/credits_order.asm"
+
+INCLUDE "text/credits_text.asm"
+
+TheEndGfx:
+ INCBIN "gfx/intro_credits/the_end.2bpp"
+TheEndGfxEnd:
diff --git a/engine/movie/evolution.asm b/engine/movie/evolution.asm
new file mode 100755
index 00000000..731735c5
--- /dev/null
+++ b/engine/movie/evolution.asm
@@ -0,0 +1,160 @@
+EvolveMon:
+ push hl
+ push de
+ push bc
+ ld a, [wcf91]
+ push af
+ ld a, [wd0b5]
+ push af
+ xor a
+ ld [wLowHealthAlarm], a
+ ld [wChannelSoundIDs + Ch5], a
+ dec a
+ ld [wNewSoundID], a
+ call PlaySound
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld a, SFX_TINK
+ call PlaySound
+ call Delay3
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld [hTilesetType], a
+ ld a, [wEvoOldSpecies]
+ ld [wWholeScreenPaletteMonSpecies], a
+ ld c, 0
+ call EvolutionSetWholeScreenPalette
+ ld a, [wEvoNewSpecies]
+ ld [wcf91], a
+ ld [wd0b5], a
+ call Evolution_LoadPic
+ ld de, vFrontPic
+ ld hl, vBackPic
+ ld bc, 7 * 7
+ call CopyVideoData
+ ld a, [wEvoOldSpecies]
+ ld [wcf91], a
+ ld [wd0b5], a
+ call Evolution_LoadPic
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld a, [wEvoOldSpecies]
+ call PlayCry
+ call WaitForSoundToFinish
+ ld c, BANK(Music_SafariZone)
+ ld a, MUSIC_SAFARI_ZONE
+ call PlayMusic
+ ld c, 80
+ call DelayFrames
+ ld c, 1 ; set PAL_BLACK instead of mon palette
+ call EvolutionSetWholeScreenPalette
+ lb bc, $1, $10
+.animLoop
+ push bc
+ call Evolution_CheckForCancel
+ jr c, .evolutionCancelled
+ call Evolution_BackAndForthAnim
+ pop bc
+ inc b
+ dec c
+ dec c
+ jr nz, .animLoop
+ xor a
+ ld [wEvoCancelled], a
+ ld a, $31
+ ld [wEvoMonTileOffset], a
+ call Evolution_ChangeMonPic ; show the new species pic
+ ld a, [wEvoNewSpecies]
+.done
+ ld [wWholeScreenPaletteMonSpecies], a
+ ld a, $ff
+ ld [wNewSoundID], a
+ call PlaySound
+ ld a, [wWholeScreenPaletteMonSpecies]
+ call PlayCry
+ ld c, 0
+ call EvolutionSetWholeScreenPalette
+ pop af
+ ld [wd0b5], a
+ pop af
+ ld [wcf91], a
+ pop bc
+ pop de
+ pop hl
+ ld a, [wEvoCancelled]
+ and a
+ ret z
+ scf
+ ret
+.evolutionCancelled
+ pop bc
+ ld a, 1
+ ld [wEvoCancelled], a
+ ld a, [wEvoOldSpecies]
+ jr .done
+
+EvolutionSetWholeScreenPalette:
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ jp RunPaletteCommand
+
+Evolution_LoadPic:
+ call GetMonHeader
+ coord hl, 7, 2
+ jp LoadFlippedFrontSpriteByMonIndex
+
+Evolution_BackAndForthAnim:
+; show the mon change back and forth between the new and old species b times
+ ld a, $31
+ ld [wEvoMonTileOffset], a
+ call Evolution_ChangeMonPic
+ ld a, -$31
+ ld [wEvoMonTileOffset], a
+ call Evolution_ChangeMonPic
+ dec b
+ jr nz, Evolution_BackAndForthAnim
+ ret
+
+Evolution_ChangeMonPic:
+ push bc
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ coord hl, 7, 2
+ lb bc, 7, 7
+ ld de, SCREEN_WIDTH - 7
+.loop
+ push bc
+.innerLoop
+ ld a, [wEvoMonTileOffset]
+ add [hl]
+ ld [hli], a
+ dec c
+ jr nz, .innerLoop
+ pop bc
+ add hl, de
+ dec b
+ jr nz, .loop
+ ld a, 1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call Delay3
+ pop bc
+ ret
+
+Evolution_CheckForCancel:
+ call DelayFrame
+ push bc
+ call JoypadLowSensitivity
+ ld a, [hJoy5]
+ pop bc
+ and B_BUTTON
+ jr nz, .pressedB
+.notAllowedToCancel
+ dec c
+ jr nz, Evolution_CheckForCancel
+ and a
+ ret
+.pressedB
+ ld a, [wForceEvolution]
+ and a
+ jr nz, .notAllowedToCancel
+ scf
+ ret
diff --git a/engine/movie/gamefreak.asm b/engine/movie/gamefreak.asm
new file mode 100755
index 00000000..78e48384
--- /dev/null
+++ b/engine/movie/gamefreak.asm
@@ -0,0 +1,243 @@
+LoadShootingStarGraphics:
+ ld a, $f9
+ ld [rOBP0], a
+ ld a, $a4
+ ld [rOBP1], a
+ ld de, AnimationTileset2 + $30 ; star tile (top left quadrant)
+ ld hl, vChars1 + $200
+ lb bc, BANK(AnimationTileset2), $01
+ call CopyVideoData
+ ld de, AnimationTileset2 + $130 ; star tile (bottom left quadrant)
+ ld hl, vChars1 + $210
+ lb bc, BANK(AnimationTileset2), $01
+ call CopyVideoData
+ ld de, FallingStar
+ ld hl, vChars1 + $220
+ lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10
+ call CopyVideoData
+ ld hl, GameFreakLogoOAMData
+ ld de, wOAMBuffer + $60
+ ld bc, GameFreakLogoOAMDataEnd - GameFreakLogoOAMData
+ call CopyData
+ ld hl, GameFreakShootingStarOAMData
+ ld de, wOAMBuffer
+ ld bc, GameFreakShootingStarOAMDataEnd - GameFreakShootingStarOAMData
+ jp CopyData
+
+AnimateShootingStar:
+ call LoadShootingStarGraphics
+ ld a, SFX_SHOOTING_STAR
+ call PlaySound
+
+; Move the big star down and left across the screen.
+ ld hl, wOAMBuffer
+ lb bc, $a0, $4
+.bigStarLoop
+ push hl
+ push bc
+.bigStarInnerLoop
+ ld a, [hl] ; Y
+ add 4
+ ld [hli], a
+ ld a, [hl] ; X
+ add -4
+ ld [hli], a
+ inc hl
+ inc hl
+ dec c
+ jr nz, .bigStarInnerLoop
+ ld c, 1
+ call CheckForUserInterruption
+ pop bc
+ pop hl
+ ret c
+ ld a, [hl]
+ cp 80
+ jr nz, .next
+ jr .bigStarLoop
+.next
+ cp b
+ jr nz, .bigStarLoop
+
+; Clear big star OAM.
+ ld hl, wOAMBuffer
+ ld c, 4
+ ld de, 4
+.clearOAMLoop
+ ld [hl], 160
+ add hl, de
+ dec c
+ jr nz, .clearOAMLoop
+
+; Make Gamefreak logo flash.
+ ld b, 3
+.flashLogoLoop
+ ld hl, rOBP0
+ rrc [hl]
+ rrc [hl]
+ ld c, 10
+ call CheckForUserInterruption
+ ret c
+ dec b
+ jr nz, .flashLogoLoop
+
+; Copy 24 instances of the small stars OAM data.
+; Note that their coordinates put them off-screen.
+ ld de, wOAMBuffer
+ ld a, 24
+.initSmallStarsOAMLoop
+ push af
+ ld hl, SmallStarsOAM
+ ld bc, SmallStarsOAMEnd - SmallStarsOAM
+ call CopyData
+ pop af
+ dec a
+ jr nz, .initSmallStarsOAMLoop
+
+; Animate the small stars falling from the Gamefreak logo.
+ xor a
+ ld [wMoveDownSmallStarsOAMCount], a
+ ld hl, SmallStarsWaveCoordsPointerTable
+ ld c, 6
+.smallStarsLoop
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ push bc
+ push hl
+ ld hl, wOAMBuffer + $50
+ ld c, 4
+.smallStarsInnerLoop ; introduce new wave of 4 small stars OAM entries
+ ld a, [de]
+ cp $ff
+ jr z, .next2
+ ld [hli], a ; Y
+ inc de
+ ld a, [de]
+ ld [hli], a ; X
+ inc de
+ inc hl
+ inc hl
+ dec c
+ jr nz, .smallStarsInnerLoop
+ ld a, [wMoveDownSmallStarsOAMCount]
+ cp 24
+ jr z, .next2
+ add 6 ; should be 4, but the extra 2 aren't visible on screen
+ ld [wMoveDownSmallStarsOAMCount], a
+.next2
+ call MoveDownSmallStars
+ push af
+
+; shift the existing OAM entries down to make room for the next wave
+ ld hl, wOAMBuffer + $10
+ ld de, wOAMBuffer
+ ld bc, $50
+ call CopyData
+
+ pop af
+ pop hl
+ pop bc
+ ret c
+ dec c
+ jr nz, .smallStarsLoop
+ and a
+ ret
+
+SmallStarsOAM:
+ db $00,$00,$A2,$90
+SmallStarsOAMEnd:
+
+SmallStarsWaveCoordsPointerTable:
+ dw SmallStarsWave1Coords
+ dw SmallStarsWave2Coords
+ dw SmallStarsWave3Coords
+ dw SmallStarsWave4Coords
+ dw SmallStarsEmptyWave
+ dw SmallStarsEmptyWave
+
+; The stars that fall from the Gamefreak logo come in 4 waves of 4 OAM entries.
+; These arrays contain the Y and X coordinates of each OAM entry.
+
+SmallStarsWave1Coords:
+ db $68,$30
+ db $68,$40
+ db $68,$58
+ db $68,$78
+
+SmallStarsWave2Coords:
+ db $68,$38
+ db $68,$48
+ db $68,$60
+ db $68,$70
+
+SmallStarsWave3Coords:
+ db $68,$34
+ db $68,$4C
+ db $68,$54
+ db $68,$64
+
+SmallStarsWave4Coords:
+ db $68,$3C
+ db $68,$5C
+ db $68,$6C
+ db $68,$74
+
+SmallStarsEmptyWave:
+ db $FF
+
+MoveDownSmallStars:
+ ld b, 8
+.loop
+ ld hl, wOAMBuffer + $5c
+ ld a, [wMoveDownSmallStarsOAMCount]
+ ld de, -4
+ ld c, a
+.innerLoop
+ inc [hl] ; Y
+ add hl, de
+ dec c
+ jr nz, .innerLoop
+; Toggle the palette so that the lower star in the small stars tile blinks in
+; and out.
+ ld a, [rOBP1]
+ xor %10100000
+ ld [rOBP1], a
+
+ ld c, 3
+ call CheckForUserInterruption
+ ret c
+ dec b
+ jr nz, .loop
+ ret
+
+GameFreakLogoOAMData:
+ db $48,$50,$8D,$00
+ db $48,$58,$8E,$00
+ db $50,$50,$8F,$00
+ db $50,$58,$90,$00
+ db $58,$50,$91,$00
+ db $58,$58,$92,$00
+ db $60,$30,$80,$00
+ db $60,$38,$81,$00
+ db $60,$40,$82,$00
+ db $60,$48,$83,$00
+ db $60,$50,$93,$00
+ db $60,$58,$84,$00
+ db $60,$60,$85,$00
+ db $60,$68,$83,$00
+ db $60,$70,$81,$00
+ db $60,$78,$86,$00
+GameFreakLogoOAMDataEnd:
+
+GameFreakShootingStarOAMData:
+ db $00,$A0,$A0,$10
+ db $00,$A8,$A0,$30
+ db $08,$A0,$A1,$10
+ db $08,$A8,$A1,$30
+GameFreakShootingStarOAMDataEnd:
+
+FallingStar:
+ INCBIN "gfx/intro_credits/falling_star.2bpp"
+FallingStarEnd:
diff --git a/engine/movie/hall_of_fame.asm b/engine/movie/hall_of_fame.asm
new file mode 100755
index 00000000..3c9b1723
--- /dev/null
+++ b/engine/movie/hall_of_fame.asm
@@ -0,0 +1,288 @@
+AnimateHallOfFame:
+ call HoFFadeOutScreenAndMusic
+ call ClearScreen
+ ld c, 100
+ call DelayFrames
+ call LoadFontTilePatterns
+ call LoadTextBoxTilePatterns
+ call DisableLCD
+ ld hl, vBGMap0
+ ld bc, $800
+ ld a, " "
+ call FillMemory
+ call EnableLCD
+ ld hl, rLCDC
+ set 3, [hl]
+ xor a
+ ld hl, wHallOfFame
+ ld bc, HOF_TEAM
+ call FillMemory
+ xor a
+ ld [wUpdateSpritesEnabled], a
+ ld [hTilesetType], a
+ ld [wSpriteFlipped], a
+ ld [wLetterPrintingDelayFlags], a ; no delay
+ ld [wHoFMonOrPlayer], a ; mon
+ inc a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld hl, wNumHoFTeams
+ ld a, [hl]
+ inc a
+ jr z, .skipInc ; don't wrap around to 0
+ inc [hl]
+.skipInc
+ ld a, $90
+ ld [hWY], a
+ ld c, BANK(Music_HallOfFame)
+ ld a, MUSIC_HALL_OF_FAME
+ call PlayMusic
+ ld hl, wPartySpecies
+ ld c, $ff
+.partyMonLoop
+ ld a, [hli]
+ cp $ff
+ jr z, .doneShowingParty
+ inc c
+ push hl
+ push bc
+ ld [wHoFMonSpecies], a
+ ld a, c
+ ld [wHoFPartyMonIndex], a
+ ld hl, wPartyMon1Level
+ ld bc, wPartyMon2 - wPartyMon1
+ call AddNTimes
+ ld a, [hl]
+ ld [wHoFMonLevel], a
+ call HoFShowMonOrPlayer
+ call HoFDisplayAndRecordMonInfo
+ ld c, 80
+ call DelayFrames
+ coord hl, 2, 13
+ ld b, 3
+ ld c, 14
+ call TextBoxBorder
+ coord hl, 4, 15
+ ld de, HallOfFameText
+ call PlaceString
+ ld c, 180
+ call DelayFrames
+ call GBFadeOutToWhite
+ pop bc
+ pop hl
+ jr .partyMonLoop
+.doneShowingParty
+ ld a, c
+ inc a
+ ld hl, wHallOfFame
+ ld bc, HOF_MON
+ call AddNTimes
+ ld [hl], $ff
+ call SaveHallOfFameTeams
+ xor a
+ ld [wHoFMonSpecies], a
+ inc a
+ ld [wHoFMonOrPlayer], a ; player
+ call HoFShowMonOrPlayer
+ call HoFDisplayPlayerStats
+ call HoFFadeOutScreenAndMusic
+ xor a
+ ld [hWY], a
+ ld hl, rLCDC
+ res 3, [hl]
+ ret
+
+HallOfFameText:
+ db "HALL OF FAME@"
+
+HoFShowMonOrPlayer:
+ call ClearScreen
+ ld a, $d0
+ ld [hSCY], a
+ ld a, $c0
+ ld [hSCX], a
+ ld a, [wHoFMonSpecies]
+ ld [wcf91], a
+ ld [wd0b5], a
+ ld [wBattleMonSpecies2], a
+ ld [wWholeScreenPaletteMonSpecies], a
+ ld a, [wHoFMonOrPlayer]
+ and a
+ jr z, .showMon
+; show player
+ call HoFLoadPlayerPics
+ jr .next1
+.showMon
+ coord hl, 12, 5
+ call GetMonHeader
+ call LoadFrontSpriteByMonIndex
+ predef LoadMonBackPic
+.next1
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ ld c, 0
+ call RunPaletteCommand
+ ld a, %11100100
+ ld [rBGP], a
+ ld c, $31 ; back pic
+ call HoFLoadMonPlayerPicTileIDs
+ ld d, $a0
+ ld e, 4
+ ld a, [wOnSGB]
+ and a
+ jr z, .next2
+ sla e ; scroll more slowly on SGB
+.next2
+ call .ScrollPic ; scroll back pic left
+ xor a
+ ld [hSCY], a
+ ld c, a ; front pic
+ call HoFLoadMonPlayerPicTileIDs
+ ld d, 0
+ ld e, -4
+; scroll front pic right
+
+.ScrollPic
+ call DelayFrame
+ ld a, [hSCX]
+ add e
+ ld [hSCX], a
+ cp d
+ jr nz, .ScrollPic
+ ret
+
+HoFDisplayAndRecordMonInfo:
+ ld a, [wHoFPartyMonIndex]
+ ld hl, wPartyMonNicks
+ call GetPartyMonName
+ call HoFDisplayMonInfo
+ jp HoFRecordMonInfo
+
+HoFDisplayMonInfo:
+ coord hl, 0, 2
+ ld b, 9
+ ld c, 10
+ call TextBoxBorder
+ coord hl, 2, 6
+ ld de, HoFMonInfoText
+ call PlaceString
+ coord hl, 1, 4
+ ld de, wcd6d
+ call PlaceString
+ ld a, [wHoFMonLevel]
+ coord hl, 8, 7
+ call PrintLevelCommon
+ ld a, [wHoFMonSpecies]
+ ld [wd0b5], a
+ coord hl, 3, 9
+ predef PrintMonType
+ ld a, [wHoFMonSpecies]
+ jp PlayCry
+
+HoFMonInfoText:
+ db "LEVEL/"
+ next "TYPE1/"
+ next "TYPE2/@"
+
+HoFLoadPlayerPics:
+ ld de, RedPicFront
+ ld a, BANK(RedPicFront)
+ call UncompressSpriteFromDE
+ ld hl, sSpriteBuffer1
+ ld de, sSpriteBuffer0
+ ld bc, $310
+ call CopyData
+ ld de, vFrontPic
+ call InterlaceMergeSpriteBuffers
+ ld de, RedPicBack
+ ld a, BANK(RedPicBack)
+ call UncompressSpriteFromDE
+ predef ScaleSpriteByTwo
+ ld de, vBackPic
+ call InterlaceMergeSpriteBuffers
+ ld c, $1
+
+HoFLoadMonPlayerPicTileIDs:
+; c = base tile ID
+ ld b, 0
+ coord hl, 12, 5
+ predef_jump CopyTileIDsFromList
+
+HoFDisplayPlayerStats:
+ SetEvent EVENT_HALL_OF_FAME_DEX_RATING
+ predef DisplayDexRating
+ coord hl, 0, 4
+ ld b, 6
+ ld c, 10
+ call TextBoxBorder
+ coord hl, 5, 0
+ ld b, 2
+ ld c, 9
+ call TextBoxBorder
+ coord hl, 7, 2
+ ld de, wPlayerName
+ call PlaceString
+ coord hl, 1, 6
+ ld de, HoFPlayTimeText
+ call PlaceString
+ coord hl, 5, 7
+ ld de, wPlayTimeHours
+ lb bc, 1, 3
+ call PrintNumber
+ ld [hl], $6d
+ inc hl
+ ld de, wPlayTimeMinutes
+ lb bc, LEADING_ZEROES | 1, 2
+ call PrintNumber
+ coord hl, 1, 9
+ ld de, HoFMoneyText
+ call PlaceString
+ coord hl, 4, 10
+ ld de, wPlayerMoney
+ ld c, $a3
+ call PrintBCDNumber
+ ld hl, DexSeenOwnedText
+ call HoFPrintTextAndDelay
+ ld hl, DexRatingText
+ call HoFPrintTextAndDelay
+ ld hl, wDexRatingText
+
+HoFPrintTextAndDelay:
+ call PrintText
+ ld c, 120
+ jp DelayFrames
+
+HoFPlayTimeText:
+ db "PLAY TIME@"
+
+HoFMoneyText:
+ db "MONEY@"
+
+DexSeenOwnedText:
+ TX_FAR _DexSeenOwnedText
+ db "@"
+
+DexRatingText:
+ TX_FAR _DexRatingText
+ db "@"
+
+HoFRecordMonInfo:
+ ld hl, wHallOfFame
+ ld bc, HOF_MON
+ ld a, [wHoFPartyMonIndex]
+ call AddNTimes
+ ld a, [wHoFMonSpecies]
+ ld [hli], a
+ ld a, [wHoFMonLevel]
+ ld [hli], a
+ ld e, l
+ ld d, h
+ ld hl, wcd6d
+ ld bc, NAME_LENGTH
+ jp CopyData
+
+HoFFadeOutScreenAndMusic:
+ ld a, 10
+ ld [wAudioFadeOutCounterReloadValue], a
+ ld [wAudioFadeOutCounter], a
+ ld a, $ff
+ ld [wAudioFadeOutControl], a
+ jp GBFadeOutToWhite
diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm
new file mode 100755
index 00000000..9a13c96f
--- /dev/null
+++ b/engine/movie/intro.asm
@@ -0,0 +1,470 @@
+const_value = -1
+ const MOVE_NIDORINO_RIGHT
+ const MOVE_GENGAR_RIGHT
+ const MOVE_GENGAR_LEFT
+
+ANIMATION_END EQU 80
+
+const_value = 3
+ const GENGAR_INTRO_TILES1
+ const GENGAR_INTRO_TILES2
+ const GENGAR_INTRO_TILES3
+
+PlayIntro:
+ xor a
+ ld [hJoyHeld], a
+ inc a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call PlayShootingStar
+ call PlayIntroScene
+ call GBFadeOutToWhite
+ xor a
+ ld [hSCX], a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call ClearSprites
+ call DelayFrame
+ ret
+
+PlayIntroScene:
+ ld b, SET_PAL_NIDORINO_INTRO
+ call RunPaletteCommand
+ ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE
+ ld [rBGP], a
+ ld [rOBP0], a
+ ld [rOBP1], a
+ xor a
+ ld [hSCX], a
+ ld b, GENGAR_INTRO_TILES1
+ call IntroCopyTiles
+ ld a, 0
+ ld [wBaseCoordX], a
+ ld a, 80
+ ld [wBaseCoordY], a
+ lb bc, 6, 6
+ call InitIntroNidorinoOAM
+ lb de, 80 / 2, MOVE_NIDORINO_RIGHT
+ call IntroMoveMon
+ ret c
+
+; hip
+ ld a, SFX_INTRO_HIP
+ call PlaySound
+ xor a
+ ld [wIntroNidorinoBaseTile], a
+ ld de, IntroNidorinoAnimation1
+ call AnimateIntroNidorino
+; hop
+ ld a, SFX_INTRO_HOP
+ call PlaySound
+ ld de, IntroNidorinoAnimation2
+ call AnimateIntroNidorino
+ ld c, 10
+ call CheckForUserInterruption
+ ret c
+
+; hip
+ ld a, SFX_INTRO_HIP
+ call PlaySound
+ ld de, IntroNidorinoAnimation1
+ call AnimateIntroNidorino
+; hop
+ ld a, SFX_INTRO_HOP
+ call PlaySound
+ ld de, IntroNidorinoAnimation2
+ call AnimateIntroNidorino
+ ld c, 30
+ call CheckForUserInterruption
+ ret c
+
+; raise
+ ld b, GENGAR_INTRO_TILES2
+ call IntroCopyTiles
+ ld a, SFX_INTRO_RAISE
+ call PlaySound
+ lb de, 8 / 2, MOVE_GENGAR_LEFT
+ call IntroMoveMon
+ ld c, 30
+ call CheckForUserInterruption
+ ret c
+
+; slash
+ ld b, GENGAR_INTRO_TILES3
+ call IntroCopyTiles
+ ld a, SFX_INTRO_CRASH
+ call PlaySound
+ lb de, 16 / 2, MOVE_GENGAR_RIGHT
+ call IntroMoveMon
+; hip
+ ld a, SFX_INTRO_HIP
+ call PlaySound
+ ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / BYTES_PER_TILE
+ ld [wIntroNidorinoBaseTile], a
+ ld de, IntroNidorinoAnimation3
+ call AnimateIntroNidorino
+ ld c, 30
+ call CheckForUserInterruption
+ ret c
+
+ lb de, 8 / 2, MOVE_GENGAR_LEFT
+ call IntroMoveMon
+ ld b, GENGAR_INTRO_TILES1
+ call IntroCopyTiles
+ ld c, 60
+ call CheckForUserInterruption
+ ret c
+
+; hip
+ ld a, SFX_INTRO_HIP
+ call PlaySound
+ xor a
+ ld [wIntroNidorinoBaseTile], a
+ ld de, IntroNidorinoAnimation4
+ call AnimateIntroNidorino
+; hop
+ ld a, SFX_INTRO_HOP
+ call PlaySound
+ ld de, IntroNidorinoAnimation5
+ call AnimateIntroNidorino
+ ld c, 20
+ call CheckForUserInterruption
+ ret c
+
+ ld a, (FightIntroFrontMon2 - FightIntroFrontMon) / BYTES_PER_TILE
+ ld [wIntroNidorinoBaseTile], a
+ ld de, IntroNidorinoAnimation6
+ call AnimateIntroNidorino
+ ld c, 30
+ call CheckForUserInterruption
+ ret c
+
+; lunge
+ ld a, SFX_INTRO_LUNGE
+ call PlaySound
+ ld a, (FightIntroFrontMon3 - FightIntroFrontMon) / BYTES_PER_TILE
+ ld [wIntroNidorinoBaseTile], a
+ ld de, IntroNidorinoAnimation7
+ jp AnimateIntroNidorino
+
+AnimateIntroNidorino:
+ ld a, [de]
+ cp ANIMATION_END
+ ret z
+ ld [wBaseCoordY], a
+ inc de
+ ld a, [de]
+ ld [wBaseCoordX], a
+ push de
+ ld c, 6 * 6
+ call UpdateIntroNidorinoOAM
+ ld c, 5
+ call DelayFrames
+ pop de
+ inc de
+ jr AnimateIntroNidorino
+
+UpdateIntroNidorinoOAM:
+ ld hl, wOAMBuffer
+ ld a, [wIntroNidorinoBaseTile]
+ ld d, a
+.loop
+ ld a, [wBaseCoordY]
+ add [hl]
+ ld [hli], a ; Y
+ ld a, [wBaseCoordX]
+ add [hl]
+ ld [hli], a ; X
+ ld a, d
+ ld [hli], a ; tile
+ inc hl
+ inc d
+ dec c
+ jr nz, .loop
+ ret
+
+InitIntroNidorinoOAM:
+ ld hl, wOAMBuffer
+ ld d, 0
+.loop
+ push bc
+ ld a, [wBaseCoordY]
+ ld e, a
+.innerLoop
+ ld a, e
+ add 8
+ ld e, a
+ ld [hli], a ; Y
+ ld a, [wBaseCoordX]
+ ld [hli], a ; X
+ ld a, d
+ ld [hli], a ; tile
+ ld a, OAM_BEHIND_BG
+ ld [hli], a ; attributes
+ inc d
+ dec c
+ jr nz, .innerLoop
+ ld a, [wBaseCoordX]
+ add 8
+ ld [wBaseCoordX], a
+ pop bc
+ dec b
+ jr nz, .loop
+ ret
+
+IntroClearScreen:
+ ld hl, vBGMap1
+ ld bc, BG_MAP_WIDTH * SCREEN_HEIGHT
+ jr IntroClearCommon
+
+IntroClearMiddleOfScreen:
+; clear the area of the tile map between the black bars on the top and bottom
+ coord hl, 0, 4
+ ld bc, SCREEN_WIDTH * 10
+
+IntroClearCommon:
+ ld [hl], 0
+ inc hl
+ dec bc
+ ld a, b
+ or c
+ jr nz, IntroClearCommon
+ ret
+
+IntroPlaceBlackTiles:
+ ld a, 1
+.loop
+ ld [hli], a
+ dec c
+ jr nz, .loop
+ ret
+
+IntroMoveMon:
+; d = number of times to move the mon (2 pixels each time)
+ ld a, e
+ cp MOVE_NIDORINO_RIGHT
+ jr z, .moveNidorinoRight
+ cp MOVE_GENGAR_LEFT
+ jr z, .moveGengarLeft
+; move Gengar right
+ ld a, [hSCX]
+ dec a
+ dec a
+ jr .next
+.moveNidorinoRight
+ push de
+ ld a, 2
+ ld [wBaseCoordX], a
+ xor a
+ ld [wBaseCoordY], a
+ ld c, 6 * 6
+ call UpdateIntroNidorinoOAM
+ pop de
+.moveGengarLeft
+ ld a, [hSCX]
+ inc a
+ inc a
+.next
+ ld [hSCX], a
+ push de
+ ld c, 2
+ call CheckForUserInterruption
+ pop de
+ ret c
+ dec d
+ jr nz, IntroMoveMon
+ ret
+
+IntroCopyTiles:
+ coord hl, 13, 7
+
+CopyTileIDsFromList_ZeroBaseTileID:
+ ld c, 0
+ predef_jump CopyTileIDsFromList
+
+PlayMoveSoundB:
+; unused
+ predef GetMoveSoundB
+ ld a, b
+ jp PlaySound
+
+LoadIntroGraphics:
+ ld hl, FightIntroBackMon
+ ld de, vChars2
+ ld bc, FightIntroBackMonEnd - FightIntroBackMon
+ ld a, BANK(FightIntroBackMon)
+ call FarCopyData2
+ ld hl, GameFreakIntro
+ ld de, vChars2 + (FightIntroBackMonEnd - FightIntroBackMon)
+ ld bc, GameFreakIntroEnd - GameFreakIntro
+ ld a, BANK(GameFreakIntro)
+ call FarCopyData2
+ ld hl, GameFreakIntro
+ ld de, vChars1
+ ld bc, GameFreakIntroEnd - GameFreakIntro
+ ld a, BANK(GameFreakIntro)
+ call FarCopyData2
+ ld hl, FightIntroFrontMon
+ ld de, vChars0
+ ld bc, FightIntroFrontMonEnd - FightIntroFrontMon
+ ld a, BANK(FightIntroFrontMon)
+ jp FarCopyData2
+
+PlayShootingStar:
+ ld b, SET_PAL_GAME_FREAK_INTRO
+ call RunPaletteCommand
+ callba LoadCopyrightAndTextBoxTiles
+ ldPal a, BLACK, DARK_GRAY, LIGHT_GRAY, WHITE
+ ld [rBGP], a
+ ld c, 180
+ call DelayFrames
+ call ClearScreen
+ call DisableLCD
+ xor a
+ ld [wCurOpponent], a
+ call IntroDrawBlackBars
+ call LoadIntroGraphics
+ call EnableLCD
+ ld hl, rLCDC
+ res 5, [hl]
+ set 3, [hl]
+ ld c, 64
+ call DelayFrames
+ callba AnimateShootingStar
+ push af
+ pop af
+ jr c, .next ; skip the delay if the user interrupted the animation
+ ld c, 40
+ call DelayFrames
+.next
+ ld a, BANK(Music_IntroBattle)
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
+ ld a, MUSIC_INTRO_BATTLE
+ ld [wNewSoundID], a
+ call PlaySound
+ call IntroClearMiddleOfScreen
+ call ClearSprites
+ jp Delay3
+
+IntroDrawBlackBars:
+; clear the screen and draw black bars on the top and bottom
+ call IntroClearScreen
+ coord hl, 0, 0
+ ld c, SCREEN_WIDTH * 4
+ call IntroPlaceBlackTiles
+ coord hl, 0, 14
+ ld c, SCREEN_WIDTH * 4
+ call IntroPlaceBlackTiles
+ ld hl, vBGMap1
+ ld c, BG_MAP_WIDTH * 4
+ call IntroPlaceBlackTiles
+ ld hl, vBGMap1 + BG_MAP_WIDTH * 14
+ ld c, BG_MAP_WIDTH * 4
+ jp IntroPlaceBlackTiles
+
+EmptyFunc4:
+ ret
+
+IntroNidorinoAnimation0:
+ db 0, 0
+ db ANIMATION_END
+
+IntroNidorinoAnimation1:
+; This is a sequence of pixel movements for part of the Nidorino animation. This
+; list describes how Nidorino should hop.
+; First byte is y movement, second byte is x movement
+ db 0, 0
+ db -2, 2
+ db -1, 2
+ db 1, 2
+ db 2, 2
+ db ANIMATION_END
+
+IntroNidorinoAnimation2:
+; This is a sequence of pixel movements for part of the Nidorino animation.
+; First byte is y movement, second byte is x movement
+ db 0, 0
+ db -2, -2
+ db -1, -2
+ db 1, -2
+ db 2, -2
+ db ANIMATION_END
+
+IntroNidorinoAnimation3:
+; This is a sequence of pixel movements for part of the Nidorino animation.
+; First byte is y movement, second byte is x movement
+ db 0, 0
+ db -12, 6
+ db -8, 6
+ db 8, 6
+ db 12, 6
+ db ANIMATION_END
+
+IntroNidorinoAnimation4:
+; This is a sequence of pixel movements for part of the Nidorino animation.
+; First byte is y movement, second byte is x movement
+ db 0, 0
+ db -8, -4
+ db -4, -4
+ db 4, -4
+ db 8, -4
+ db ANIMATION_END
+
+IntroNidorinoAnimation5:
+; This is a sequence of pixel movements for part of the Nidorino animation.
+; First byte is y movement, second byte is x movement
+ db 0, 0
+ db -8, 4
+ db -4, 4
+ db 4, 4
+ db 8, 4
+ db ANIMATION_END
+
+IntroNidorinoAnimation6:
+; This is a sequence of pixel movements for part of the Nidorino animation.
+; First byte is y movement, second byte is x movement
+ db 0, 0
+ db 2, 0
+ db 2, 0
+ db 0, 0
+ db ANIMATION_END
+
+IntroNidorinoAnimation7:
+; This is a sequence of pixel movements for part of the Nidorino animation.
+; First byte is y movement, second byte is x movement
+ db -8, -16
+ db -7, -14
+ db -6, -12
+ db -4, -10
+ db ANIMATION_END
+
+GameFreakIntro:
+ INCBIN "gfx/intro_credits/gamefreak_presents.2bpp"
+ INCBIN "gfx/intro_credits/gamefreak_logo.2bpp"
+ ds 16, $00 ; blank tile
+GameFreakIntroEnd:
+
+FightIntroBackMon:
+ INCBIN "gfx/intro_credits/gengar.2bpp"
+FightIntroBackMonEnd:
+
+FightIntroFrontMon:
+
+IF DEF(_RED)
+ INCBIN "gfx/intro_credits/red_nidorino_1.2bpp"
+FightIntroFrontMon2:
+ INCBIN "gfx/intro_credits/red_nidorino_2.2bpp"
+FightIntroFrontMon3:
+ INCBIN "gfx/intro_credits/red_nidorino_3.2bpp"
+ENDC
+
+IF DEF(_BLUE)
+ INCBIN "gfx/intro_credits/blue_jigglypuff_1.2bpp"
+FightIntroFrontMon2:
+ INCBIN "gfx/intro_credits/blue_jigglypuff_2.2bpp"
+FightIntroFrontMon3:
+ INCBIN "gfx/intro_credits/blue_jigglypuff_3.2bpp"
+ENDC
+
+FightIntroFrontMonEnd:
+
+ ds 16, $00 ; blank tile
diff --git a/engine/movie/oak_speech/clear_save.asm b/engine/movie/oak_speech/clear_save.asm
new file mode 100755
index 00000000..b47cd6c4
--- /dev/null
+++ b/engine/movie/oak_speech/clear_save.asm
@@ -0,0 +1,23 @@
+DoClearSaveDialogue:
+ call ClearScreen
+ call RunDefaultPaletteCommand
+ call LoadFontTilePatterns
+ call LoadTextBoxTilePatterns
+ ld hl, ClearSaveDataText
+ call PrintText
+ coord hl, 14, 7
+ lb bc, 8, 15
+ ld a, NO_YES_MENU
+ ld [wTwoOptionMenuID], a
+ ld a, TWO_OPTION_MENU
+ ld [wTextBoxID], a
+ call DisplayTextBoxID
+ ld a, [wCurrentMenuItem]
+ and a
+ jp z, Init
+ callba ClearSAV
+ jp Init
+
+ClearSaveDataText:
+ TX_FAR _ClearSaveDataText
+ db "@"
diff --git a/engine/movie/oak_speech/init_player_data.asm b/engine/movie/oak_speech/init_player_data.asm
new file mode 100644
index 00000000..c576e65a
--- /dev/null
+++ b/engine/movie/oak_speech/init_player_data.asm
@@ -0,0 +1,55 @@
+InitPlayerData:
+InitPlayerData2:
+
+ call Random
+ ld a, [hRandomSub]
+ ld [wPlayerID], a
+
+ call Random
+ ld a, [hRandomAdd]
+ ld [wPlayerID + 1], a
+
+ ld a, $ff
+ ld [wUnusedD71B], a
+
+ ld hl, wPartyCount
+ call InitializeEmptyList
+ ld hl, wNumInBox
+ call InitializeEmptyList
+ ld hl, wNumBagItems
+ call InitializeEmptyList
+ ld hl, wNumBoxItems
+ call InitializeEmptyList
+
+START_MONEY EQU $3000
+ ld hl, wPlayerMoney + 1
+ ld a, START_MONEY / $100
+ ld [hld], a
+ xor a
+ ld [hli], a
+ inc hl
+ ld [hl], a
+
+ ld [wMonDataLocation], a
+
+ ld hl, wObtainedBadges
+ ld [hli], a
+
+ ld [hl], a
+
+ ld hl, wPlayerCoins
+ ld [hli], a
+ ld [hl], a
+
+ ld hl, wGameProgressFlags
+ ld bc, wGameProgressFlagsEnd - wGameProgressFlags
+ call FillMemory ; clear all game progress flags
+
+ jp InitializeMissableObjectsFlags
+
+InitializeEmptyList:
+ xor a ; count
+ ld [hli], a
+ dec a ; terminator
+ ld [hl], a
+ ret
diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm
new file mode 100755
index 00000000..b1acfb65
--- /dev/null
+++ b/engine/movie/oak_speech/oak_speech.asm
@@ -0,0 +1,233 @@
+SetDefaultNames:
+ ld a, [wLetterPrintingDelayFlags]
+ push af
+ ld a, [wOptions]
+ push af
+ ld a, [wd732]
+ push af
+ ld hl, wPlayerName
+ ld bc, wBoxDataEnd - wPlayerName
+ xor a
+ call FillMemory
+ ld hl, wSpriteStateData1
+ ld bc, $200
+ xor a
+ call FillMemory
+ pop af
+ ld [wd732], a
+ pop af
+ ld [wOptions], a
+ pop af
+ ld [wLetterPrintingDelayFlags], a
+ ld a, [wOptionsInitialized]
+ and a
+ call z, InitOptions
+ ld hl, NintenText
+ ld de, wPlayerName
+ ld bc, NAME_LENGTH
+ call CopyData
+ ld hl, SonyText
+ ld de, wRivalName
+ ld bc, NAME_LENGTH
+ jp CopyData
+
+OakSpeech:
+ ld a, $FF
+ call PlaySound ; stop music
+ ld a, BANK(Music_Routes2)
+ ld c, a
+ ld a, MUSIC_ROUTES2
+ call PlayMusic
+ call ClearScreen
+ call LoadTextBoxTilePatterns
+ call SetDefaultNames
+ predef InitPlayerData2
+ ld hl, wNumBoxItems
+ ld a, POTION
+ ld [wcf91], a
+ ld a, 1
+ ld [wItemQuantity], a
+ call AddItemToInventory ; give one potion
+ ld a, [wDefaultMap]
+ ld [wDestinationMap], a
+ call SpecialWarpIn
+ xor a
+ ld [hTilesetType], a
+ ld a, [wd732]
+ bit 1, a ; possibly a debug mode bit
+ jp nz, .skipChoosingNames
+ ld de, ProfOakPic
+ lb bc, Bank(ProfOakPic), $00
+ call IntroDisplayPicCenteredOrUpperRight
+ call FadeInIntroPic
+ ld hl, OakSpeechText1
+ call PrintText
+ call GBFadeOutToWhite
+ call ClearScreen
+ ld a, NIDORINO
+ ld [wd0b5], a
+ ld [wcf91], a
+ call GetMonHeader
+ coord hl, 6, 4
+ call LoadFlippedFrontSpriteByMonIndex
+ call MovePicLeft
+ ld hl, OakSpeechText2
+ call PrintText
+ call GBFadeOutToWhite
+ call ClearScreen
+ ld de, RedPicFront
+ lb bc, Bank(RedPicFront), $00
+ call IntroDisplayPicCenteredOrUpperRight
+ call MovePicLeft
+ ld hl, IntroducePlayerText
+ call PrintText
+ call ChoosePlayerName
+ call GBFadeOutToWhite
+ call ClearScreen
+ ld de, Rival1Pic
+ lb bc, Bank(Rival1Pic), $00
+ call IntroDisplayPicCenteredOrUpperRight
+ call FadeInIntroPic
+ ld hl, IntroduceRivalText
+ call PrintText
+ call ChooseRivalName
+.skipChoosingNames
+ call GBFadeOutToWhite
+ call ClearScreen
+ ld de, RedPicFront
+ lb bc, Bank(RedPicFront), $00
+ call IntroDisplayPicCenteredOrUpperRight
+ call GBFadeInFromWhite
+ ld a, [wd72d]
+ and a
+ jr nz, .next
+ ld hl, OakSpeechText3
+ call PrintText
+.next
+ ld a, [H_LOADEDROMBANK]
+ push af
+ ld a, SFX_SHRINK
+ call PlaySound
+ pop af
+ ld [H_LOADEDROMBANK], a
+ ld [MBC1RomBank], a
+ ld c, 4
+ call DelayFrames
+ ld de, RedSprite
+ ld hl, vSprites
+ lb bc, BANK(RedSprite), $0C
+ call CopyVideoData
+ ld de, ShrinkPic1
+ lb bc, BANK(ShrinkPic1), $00
+ call IntroDisplayPicCenteredOrUpperRight
+ ld c, 4
+ call DelayFrames
+ ld de, ShrinkPic2
+ lb bc, BANK(ShrinkPic2), $00
+ call IntroDisplayPicCenteredOrUpperRight
+ call ResetPlayerSpriteData
+ ld a, [H_LOADEDROMBANK]
+ push af
+ ld a, BANK(Music_PalletTown)
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
+ ld a, 10
+ ld [wAudioFadeOutControl], a
+ ld a, $FF
+ ld [wNewSoundID], a
+ call PlaySound ; stop music
+ pop af
+ ld [H_LOADEDROMBANK], a
+ ld [MBC1RomBank], a
+ ld c, 20
+ call DelayFrames
+ coord hl, 6, 5
+ ld b, 7
+ ld c, 7
+ call ClearScreenArea
+ call LoadTextBoxTilePatterns
+ ld a, 1
+ ld [wUpdateSpritesEnabled], a
+ ld c, 50
+ call DelayFrames
+ call GBFadeOutToWhite
+ jp ClearScreen
+OakSpeechText1:
+ TX_FAR _OakSpeechText1
+ db "@"
+OakSpeechText2:
+ TX_FAR _OakSpeechText2A
+ TX_CRY_NIDORINA
+ TX_FAR _OakSpeechText2B
+ db "@"
+IntroducePlayerText:
+ TX_FAR _IntroducePlayerText
+ db "@"
+IntroduceRivalText:
+ TX_FAR _IntroduceRivalText
+ db "@"
+OakSpeechText3:
+ TX_FAR _OakSpeechText3
+ db "@"
+
+FadeInIntroPic:
+ ld hl, IntroFadePalettes
+ ld b, 6
+.next
+ ld a, [hli]
+ ld [rBGP], a
+ ld c, 10
+ call DelayFrames
+ dec b
+ jr nz, .next
+ ret
+
+IntroFadePalettes:
+ db %01010100
+ db %10101000
+ db %11111100
+ db %11111000
+ db %11110100
+ db %11100100
+
+MovePicLeft:
+ ld a, 119
+ ld [rWX], a
+ call DelayFrame
+
+ ld a, %11100100
+ ld [rBGP], a
+.next
+ call DelayFrame
+ ld a, [rWX]
+ sub 8
+ cp $FF
+ ret z
+ ld [rWX], a
+ jr .next
+
+DisplayPicCenteredOrUpperRight:
+ call GetPredefRegisters
+IntroDisplayPicCenteredOrUpperRight:
+; b = bank
+; de = address of compressed pic
+; c: 0 = centred, non-zero = upper-right
+ push bc
+ ld a, b
+ call UncompressSpriteFromDE
+ ld hl, sSpriteBuffer1
+ ld de, sSpriteBuffer0
+ ld bc, $310
+ call CopyData
+ ld de, vFrontPic
+ call InterlaceMergeSpriteBuffers
+ pop bc
+ ld a, c
+ and a
+ coord hl, 15, 1
+ jr nz, .next
+ coord hl, 6, 4
+.next
+ xor a
+ ld [hStartTileID], a
+ predef_jump CopyUncompressedPicToTilemap
diff --git a/engine/movie/oak_speech/oak_speech2.asm b/engine/movie/oak_speech/oak_speech2.asm
new file mode 100755
index 00000000..fdc9ffa3
--- /dev/null
+++ b/engine/movie/oak_speech/oak_speech2.asm
@@ -0,0 +1,219 @@
+ChoosePlayerName:
+ call OakSpeechSlidePicRight
+ ld de, DefaultNamesPlayer
+ call DisplayIntroNameTextBox
+ ld a, [wCurrentMenuItem]
+ and a
+ jr z, .customName
+ ld hl, DefaultNamesPlayerList
+ call GetDefaultName
+ ld de, wPlayerName
+ call OakSpeechSlidePicLeft
+ jr .done
+.customName
+ ld hl, wPlayerName
+ xor a ; NAME_PLAYER_SCREEN
+ ld [wNamingScreenType], a
+ call DisplayNamingScreen
+ ld a, [wcf4b]
+ cp "@"
+ jr z, .customName
+ call ClearScreen
+ call Delay3
+ ld de, RedPicFront
+ ld b, BANK(RedPicFront)
+ call IntroDisplayPicCenteredOrUpperRight
+.done
+ ld hl, YourNameIsText
+ jp PrintText
+
+YourNameIsText:
+ TX_FAR _YourNameIsText
+ db "@"
+
+ChooseRivalName:
+ call OakSpeechSlidePicRight
+ ld de, DefaultNamesRival
+ call DisplayIntroNameTextBox
+ ld a, [wCurrentMenuItem]
+ and a
+ jr z, .customName
+ ld hl, DefaultNamesRivalList
+ call GetDefaultName
+ ld de, wRivalName
+ call OakSpeechSlidePicLeft
+ jr .done
+.customName
+ ld hl, wRivalName
+ ld a, NAME_RIVAL_SCREEN
+ ld [wNamingScreenType], a
+ call DisplayNamingScreen
+ ld a, [wcf4b]
+ cp "@"
+ jr z, .customName
+ call ClearScreen
+ call Delay3
+ ld de, Rival1Pic
+ ld b, $13
+ call IntroDisplayPicCenteredOrUpperRight
+.done
+ ld hl, HisNameIsText
+ jp PrintText
+
+HisNameIsText:
+ TX_FAR _HisNameIsText
+ db "@"
+
+OakSpeechSlidePicLeft:
+ push de
+ coord hl, 0, 0
+ lb bc, 12, 11
+ call ClearScreenArea ; clear the name list text box
+ ld c, 10
+ call DelayFrames
+ pop de
+ ld hl, wcd6d
+ ld bc, NAME_LENGTH
+ call CopyData
+ call Delay3
+ coord hl, 12, 4
+ lb de, 6, 6 * SCREEN_WIDTH + 5
+ ld a, $ff
+ jr OakSpeechSlidePicCommon
+
+OakSpeechSlidePicRight:
+ coord hl, 5, 4
+ lb de, 6, 6 * SCREEN_WIDTH + 5
+ xor a
+
+OakSpeechSlidePicCommon:
+ push hl
+ push de
+ push bc
+ ld [hSlideDirection], a
+ ld a, d
+ ld [hSlideAmount], a
+ ld a, e
+ ld [hSlidingRegionSize], a
+ ld c, a
+ ld a, [hSlideDirection]
+ and a
+ jr nz, .next
+; If sliding right, point hl to the end of the pic's tiles.
+ ld d, 0
+ add hl, de
+.next
+ ld d, h
+ ld e, l
+.loop
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld a, [hSlideDirection]
+ and a
+ jr nz, .slideLeft
+; sliding right
+ ld a, [hli]
+ ld [hld], a
+ dec hl
+ jr .next2
+.slideLeft
+ ld a, [hld]
+ ld [hli], a
+ inc hl
+.next2
+ dec c
+ jr nz, .loop
+ ld a, [hSlideDirection]
+ and a
+ jr z, .next3
+; If sliding left, we need to zero the last tile in the pic (there is no need
+; to take a corresponding action when sliding right because hl initially points
+; to a 0 tile in that case).
+ xor a
+ dec hl
+ ld [hl], a
+.next3
+ ld a, 1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call Delay3
+ ld a, [hSlidingRegionSize]
+ ld c, a
+ ld h, d
+ ld l, e
+ ld a, [hSlideDirection]
+ and a
+ jr nz, .slideLeft2
+ inc hl
+ jr .next4
+.slideLeft2
+ dec hl
+.next4
+ ld d, h
+ ld e, l
+ ld a, [hSlideAmount]
+ dec a
+ ld [hSlideAmount], a
+ jr nz, .loop
+ pop bc
+ pop de
+ pop hl
+ ret
+
+DisplayIntroNameTextBox:
+ push de
+ coord hl, 0, 0
+ ld b, $a
+ ld c, $9
+ call TextBoxBorder
+ coord hl, 3, 0
+ ld de, .namestring
+ call PlaceString
+ pop de
+ coord hl, 2, 2
+ call PlaceString
+ call UpdateSprites
+ xor a
+ ld [wCurrentMenuItem], a
+ ld [wLastMenuItem], a
+ inc a
+ ld [wTopMenuItemX], a
+ ld [wMenuWatchedKeys], a ; A_BUTTON
+ inc a
+ ld [wTopMenuItemY], a
+ inc a
+ ld [wMaxMenuItem], a
+ jp HandleMenuInput
+
+.namestring
+ db "NAME@"
+
+INCLUDE "text/player_names.asm"
+
+GetDefaultName:
+; a = name index
+; hl = name list
+ ld b, a
+ ld c, 0
+.loop
+ ld d, h
+ ld e, l
+.innerLoop
+ ld a, [hli]
+ cp "@"
+ jr nz, .innerLoop
+ ld a, b
+ cp c
+ jr z, .foundName
+ inc c
+ jr .loop
+.foundName
+ ld h, d
+ ld l, e
+ ld de, wcd6d
+ ld bc, $14
+ jp CopyData
+
+INCLUDE "text/player_names_list.asm"
+
+TextTerminator_6b20:
+ db "@"
diff --git a/engine/movie/titlescreen.asm b/engine/movie/titlescreen.asm
new file mode 100755
index 00000000..c30f83a9
--- /dev/null
+++ b/engine/movie/titlescreen.asm
@@ -0,0 +1,403 @@
+; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...)
+CopyFixedLengthText:
+ ld bc, NAME_LENGTH
+ jp CopyData
+
+SetDefaultNamesBeforeTitlescreen::
+ ld hl, NintenText
+ ld de, wPlayerName
+ call CopyFixedLengthText
+ ld hl, SonyText
+ ld de, wRivalName
+ call CopyFixedLengthText
+ xor a
+ ld [hWY], a
+ ld [wLetterPrintingDelayFlags], a
+ ld hl, wd732
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld a, BANK(Music_TitleScreen)
+ ld [wAudioROMBank], a
+ ld [wAudioSavedROMBank], a
+
+DisplayTitleScreen:
+ call GBPalWhiteOut
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ xor a
+ ld [hTilesetType], a
+ ld [hSCX], a
+ ld a, $40
+ ld [hSCY], a
+ ld a, $90
+ ld [hWY], a
+ call ClearScreen
+ call DisableLCD
+ call LoadFontTilePatterns
+ ld hl, NintendoCopyrightLogoGraphics
+ ld de, vTitleLogo2 + $100
+ ld bc, $50
+ ld a, BANK(NintendoCopyrightLogoGraphics)
+ call FarCopyData2
+ ld hl, GamefreakLogoGraphics
+ ld de, vTitleLogo2 + $100 + $50
+ ld bc, $90
+ ld a, BANK(GamefreakLogoGraphics)
+ call FarCopyData2
+ ld hl, PokemonLogoGraphics
+ ld de, vTitleLogo
+ ld bc, $600
+ ld a, BANK(PokemonLogoGraphics)
+ call FarCopyData2 ; first chunk
+ ld hl, PokemonLogoGraphics+$600
+ ld de, vTitleLogo2
+ ld bc, $100
+ ld a, BANK(PokemonLogoGraphics)
+ call FarCopyData2 ; second chunk
+ ld hl, Version_GFX
+ ld de, vChars2 + $600 - (Version_GFXEnd - Version_GFX - $50)
+ ld bc, Version_GFXEnd - Version_GFX
+ ld a, BANK(Version_GFX)
+ call FarCopyDataDouble
+ call ClearBothBGMaps
+
+; place tiles for pokemon logo (except for the last row)
+ coord hl, 2, 1
+ ld a, $80
+ ld de, SCREEN_WIDTH
+ ld c, 6
+.pokemonLogoTileLoop
+ ld b, $10
+ push hl
+.pokemonLogoTileRowLoop ; place tiles for one row
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, .pokemonLogoTileRowLoop
+ pop hl
+ add hl, de
+ dec c
+ jr nz, .pokemonLogoTileLoop
+
+; place tiles for the last row of the pokemon logo
+ coord hl, 2, 7
+ ld a, $31
+ ld b, $10
+.pokemonLogoLastTileRowLoop
+ ld [hli], a
+ inc a
+ dec b
+ jr nz, .pokemonLogoLastTileRowLoop
+
+ call DrawPlayerCharacter
+
+; put a pokeball in the player's hand
+ ld hl, wOAMBuffer + $28
+ ld a, $74
+ ld [hl], a
+
+; place tiles for title screen copyright
+ coord hl, 2, 17
+ ld de, .tileScreenCopyrightTiles
+ ld b, $10
+.tileScreenCopyrightTilesLoop
+ ld a, [de]
+ ld [hli], a
+ inc de
+ dec b
+ jr nz, .tileScreenCopyrightTilesLoop
+
+ jr .next
+
+.tileScreenCopyrightTiles
+ db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc.
+
+.next
+ call SaveScreenTilesToBuffer2
+ call LoadScreenTilesFromBuffer2
+ call EnableLCD
+IF DEF(_RED)
+ ld a, CHARMANDER ; which Pokemon to show first on the title screen
+ENDC
+IF DEF(_BLUE)
+ ld a, SQUIRTLE ; which Pokemon to show first on the title screen
+ENDC
+
+ ld [wTitleMonSpecies], a
+ call LoadTitleMonSprite
+ ld a, (vBGMap0 + $300) / $100
+ call TitleScreenCopyTileMapToVRAM
+ call SaveScreenTilesToBuffer1
+ ld a, $40
+ ld [hWY], a
+ call LoadScreenTilesFromBuffer2
+ ld a, vBGMap0 / $100
+ call TitleScreenCopyTileMapToVRAM
+ ld b, SET_PAL_TITLE_SCREEN
+ call RunPaletteCommand
+ call GBPalNormal
+ ld a, %11100100
+ ld [rOBP0], a
+
+; make pokemon logo bounce up and down
+ ld bc, hSCY ; background scroll Y
+ ld hl, .TitleScreenPokemonLogoYScrolls
+.bouncePokemonLogoLoop
+ ld a, [hli]
+ and a
+ jr z, .finishedBouncingPokemonLogo
+ ld d, a
+ cp -3
+ jr nz, .skipPlayingSound
+ ld a, SFX_INTRO_CRASH
+ call PlaySound
+.skipPlayingSound
+ ld a, [hli]
+ ld e, a
+ call .ScrollTitleScreenPokemonLogo
+ jr .bouncePokemonLogoLoop
+
+.TitleScreenPokemonLogoYScrolls:
+; Controls the bouncing effect of the Pokemon logo on the title screen
+ db -4,16 ; y scroll amount, number of times to scroll
+ db 3,4
+ db -3,4
+ db 2,2
+ db -2,2
+ db 1,2
+ db -1,2
+ db 0 ; terminate list with 0
+
+.ScrollTitleScreenPokemonLogo:
+; Scrolls the Pokemon logo on the title screen to create the bouncing effect
+; Scrolls d pixels e times
+ call DelayFrame
+ ld a, [bc] ; background scroll Y
+ add d
+ ld [bc], a
+ dec e
+ jr nz, .ScrollTitleScreenPokemonLogo
+ ret
+
+.finishedBouncingPokemonLogo
+ call LoadScreenTilesFromBuffer1
+ ld c, 36
+ call DelayFrames
+ ld a, SFX_INTRO_WHOOSH
+ call PlaySound
+
+; scroll game version in from the right
+ call PrintGameVersionOnTitleScreen
+ ld a, SCREEN_HEIGHT_PIXELS
+ ld [hWY], a
+ ld d, 144
+.scrollTitleScreenGameVersionLoop
+ ld h, d
+ ld l, 64
+ call ScrollTitleScreenGameVersion
+ ld h, 0
+ ld l, 80
+ call ScrollTitleScreenGameVersion
+ ld a, d
+ add 4
+ ld d, a
+ and a
+ jr nz, .scrollTitleScreenGameVersionLoop
+
+ ld a, vBGMap1 / $100
+ call TitleScreenCopyTileMapToVRAM
+ call LoadScreenTilesFromBuffer2
+ call PrintGameVersionOnTitleScreen
+ call Delay3
+ call WaitForSoundToFinish
+ ld a, MUSIC_TITLE_SCREEN
+ ld [wNewSoundID], a
+ call PlaySound
+ xor a
+ ld [wUnusedCC5B], a
+
+; Keep scrolling in new mons indefinitely until the user performs input.
+.awaitUserInterruptionLoop
+ ld c, 200
+ call CheckForUserInterruption
+ jr c, .finishedWaiting
+ call TitleScreenScrollInMon
+ ld c, 1
+ call CheckForUserInterruption
+ jr c, .finishedWaiting
+ callba TitleScreenAnimateBallIfStarterOut
+ call TitleScreenPickNewMon
+ jr .awaitUserInterruptionLoop
+
+.finishedWaiting
+ ld a, [wTitleMonSpecies]
+ call PlayCry
+ call WaitForSoundToFinish
+ call GBPalWhiteOutWithDelay3
+ call ClearSprites
+ xor a
+ ld [hWY], a
+ inc a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call ClearScreen
+ ld a, vBGMap0 / $100
+ call TitleScreenCopyTileMapToVRAM
+ ld a, vBGMap1 / $100
+ call TitleScreenCopyTileMapToVRAM
+ call Delay3
+ call LoadGBPal
+ ld a, [hJoyHeld]
+ ld b, a
+ and D_UP | SELECT | B_BUTTON
+ cp D_UP | SELECT | B_BUTTON
+ jp z, .doClearSaveDialogue
+ jp MainMenu
+
+.doClearSaveDialogue
+ jpba DoClearSaveDialogue
+
+TitleScreenPickNewMon:
+ ld a, vBGMap0 / $100
+ call TitleScreenCopyTileMapToVRAM
+
+.loop
+; Keep looping until a mon different from the current one is picked.
+ call Random
+ and $f
+ ld c, a
+ ld b, 0
+ ld hl, TitleMons
+ add hl, bc
+ ld a, [hl]
+ ld hl, wTitleMonSpecies
+
+; Can't be the same as before.
+ cp [hl]
+ jr z, .loop
+
+ ld [hl], a
+ call LoadTitleMonSprite
+
+ ld a, $90
+ ld [hWY], a
+ ld d, 1 ; scroll out
+ callba TitleScroll
+ ret
+
+TitleScreenScrollInMon:
+ ld d, 0 ; scroll in
+ callba TitleScroll
+ xor a
+ ld [hWY], a
+ ret
+
+ScrollTitleScreenGameVersion:
+.wait
+ ld a, [rLY]
+ cp l
+ jr nz, .wait
+
+ ld a, h
+ ld [rSCX], a
+
+.wait2
+ ld a, [rLY]
+ cp h
+ jr z, .wait2
+ ret
+
+DrawPlayerCharacter:
+ ld hl, PlayerCharacterTitleGraphics
+ ld de, vSprites
+ ld bc, PlayerCharacterTitleGraphicsEnd - PlayerCharacterTitleGraphics
+ ld a, BANK(PlayerCharacterTitleGraphics)
+ call FarCopyData2
+ call ClearSprites
+ xor a
+ ld [wPlayerCharacterOAMTile], a
+ ld hl, wOAMBuffer
+ ld de, $605a
+ ld b, 7
+.loop
+ push de
+ ld c, 5
+.innerLoop
+ ld a, d
+ ld [hli], a ; Y
+ ld a, e
+ ld [hli], a ; X
+ add 8
+ ld e, a
+ ld a, [wPlayerCharacterOAMTile]
+ ld [hli], a ; tile
+ inc a
+ ld [wPlayerCharacterOAMTile], a
+ inc hl
+ dec c
+ jr nz, .innerLoop
+ pop de
+ ld a, 8
+ add d
+ ld d, a
+ dec b
+ jr nz, .loop
+ ret
+
+ClearBothBGMaps:
+ ld hl, vBGMap0
+ ld bc, $400 * 2
+ ld a, " "
+ jp FillMemory
+
+LoadTitleMonSprite:
+ ld [wcf91], a
+ ld [wd0b5], a
+ coord hl, 5, 10
+ call GetMonHeader
+ jp LoadFrontSpriteByMonIndex
+
+TitleScreenCopyTileMapToVRAM:
+ ld [H_AUTOBGTRANSFERDEST + 1], a
+ jp Delay3
+
+LoadCopyrightAndTextBoxTiles:
+ xor a
+ ld [hWY], a
+ call ClearScreen
+ call LoadTextBoxTilePatterns
+
+LoadCopyrightTiles:
+ ld de, NintendoCopyrightLogoGraphics
+ ld hl, vChars2 + $600
+ lb bc, BANK(NintendoCopyrightLogoGraphics), (GamefreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10
+ call CopyVideoData
+ coord hl, 2, 7
+ ld de, CopyrightTextString
+ jp PlaceString
+
+CopyrightTextString:
+ db $60,$61,$62,$61,$63,$61,$64,$7F,$65,$66,$67,$68,$69,$6A ; ©'95.'96.'98 Nintendo
+ next $60,$61,$62,$61,$63,$61,$64,$7F,$6B,$6C,$6D,$6E,$6F,$70,$71,$72 ; ©'95.'96.'98 Creatures inc.
+ next $60,$61,$62,$61,$63,$61,$64,$7F,$73,$74,$75,$76,$77,$78,$79,$7A,$7B ; ©'95.'96.'98 GAME FREAK inc.
+ db "@"
+
+INCLUDE "data/title_mons.asm"
+
+; prints version text (red, blue)
+PrintGameVersionOnTitleScreen:
+ coord hl, 7, 8
+ ld de, VersionOnTitleScreenText
+ jp PlaceString
+
+; these point to special tiles specifically loaded for that purpose and are not usual text
+VersionOnTitleScreenText:
+IF DEF(_RED)
+ db $60,$61,$7F,$65,$66,$67,$68,$69,"@" ; "Red Version"
+ENDC
+IF DEF(_BLUE)
+ db $61,$62,$63,$64,$65,$66,$67,$68,"@" ; "Blue Version"
+ENDC
+
+NintenText: db "NINTEN@"
+SonyText: db "SONY@"
diff --git a/engine/movie/titlescreen2.asm b/engine/movie/titlescreen2.asm
new file mode 100755
index 00000000..2346fcc5
--- /dev/null
+++ b/engine/movie/titlescreen2.asm
@@ -0,0 +1,120 @@
+TitleScroll_WaitBall:
+; Wait around for the TitleBall animation to play out.
+; hi: speed
+; lo: duration
+ db $05, $05, 0
+
+TitleScroll_In:
+; Scroll a TitleMon in from the right.
+; hi: speed
+; lo: duration
+ db $a2, $94, $84, $63, $52, $31, $11, 0
+
+TitleScroll_Out:
+; Scroll a TitleMon out to the left.
+; hi: speed
+; lo: duration
+ db $12, $22, $32, $42, $52, $62, $83, $93, 0
+
+TitleScroll:
+ ld a, d
+
+ ld bc, TitleScroll_In
+ ld d, $88
+ ld e, 0 ; don't animate titleball
+
+ and a
+ jr nz, .ok
+
+ ld bc, TitleScroll_Out
+ ld d, $00
+ ld e, 0 ; don't animate titleball
+.ok
+
+_TitleScroll:
+ ld a, [bc]
+ and a
+ ret z
+
+ inc bc
+ push bc
+
+ ld b, a
+ and $f
+ ld c, a
+ ld a, b
+ and $f0
+ swap a
+ ld b, a
+
+.loop
+ ld h, d
+ ld l, $48
+ call .ScrollBetween
+
+ ld h, $00
+ ld l, $88
+ call .ScrollBetween
+
+ ld a, d
+ add b
+ ld d, a
+
+ call GetTitleBallY
+ dec c
+ jr nz, .loop
+
+ pop bc
+ jr _TitleScroll
+
+.ScrollBetween:
+.wait
+ ld a, [rLY] ; rLY
+ cp l
+ jr nz, .wait
+
+ ld a, h
+ ld [rSCX], a
+
+.wait2
+ ld a, [rLY] ; rLY
+ cp h
+ jr z, .wait2
+ ret
+
+TitleBallYTable:
+; OBJ y-positions for the Poke Ball held by Red in the title screen.
+; This is really two 0-terminated lists. Initiated with an index of 1.
+ db 0, $71, $6f, $6e, $6d, $6c, $6d, $6e, $6f, $71, $74, 0
+
+TitleScreenAnimateBallIfStarterOut:
+; Animate the TitleBall if a starter just got scrolled out.
+ ld a, [wTitleMonSpecies]
+ cp STARTER1
+ jr z, .ok
+ cp STARTER2
+ jr z, .ok
+ cp STARTER3
+ ret nz
+.ok
+ ld e, 1 ; animate titleball
+ ld bc, TitleScroll_WaitBall
+ ld d, 0
+ jp _TitleScroll
+
+GetTitleBallY:
+; Get position e from TitleBallYTable
+ push de
+ push hl
+ xor a
+ ld d, a
+ ld hl, TitleBallYTable
+ add hl, de
+ ld a, [hl]
+ pop hl
+ pop de
+ and a
+ ret z
+ ld [wOAMBuffer + $28], a
+ inc e
+ ret
diff --git a/engine/movie/trade.asm b/engine/movie/trade.asm
new file mode 100755
index 00000000..8bc8e3bc
--- /dev/null
+++ b/engine/movie/trade.asm
@@ -0,0 +1,853 @@
+InternalClockTradeAnim:
+; Do the trading animation with the player's gameboy on the left.
+; In-game trades and internally clocked link cable trades use this.
+ ld a, [wTradedPlayerMonSpecies]
+ ld [wLeftGBMonSpecies], a
+ ld a, [wTradedEnemyMonSpecies]
+ ld [wRightGBMonSpecies], a
+ ld de, InternalClockTradeFuncSequence
+ jr TradeAnimCommon
+
+ExternalClockTradeAnim:
+; Do the trading animation with the player's gameboy on the right.
+; Externally clocked link cable trades use this.
+ ld a, [wTradedEnemyMonSpecies]
+ ld [wLeftGBMonSpecies], a
+ ld a, [wTradedPlayerMonSpecies]
+ ld [wRightGBMonSpecies], a
+ ld de, ExternalClockTradeFuncSequence
+
+TradeAnimCommon:
+ ld a, [wOptions]
+ push af
+ ld a, [hSCY]
+ push af
+ ld a, [hSCX]
+ push af
+ xor a
+ ld [wOptions], a
+ ld [hSCY], a
+ ld [hSCX], a
+ push de
+.loop
+ pop de
+ ld a, [de]
+ cp $ff
+ jr z, .done
+ inc de
+ push de
+ ld hl, TradeFuncPointerTable
+ add a
+ ld c, a
+ ld b, $0
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, .loop
+ push de
+ jp hl ; call trade func, which will return to the top of the loop
+.done
+ pop af
+ ld [hSCX], a
+ pop af
+ ld [hSCY], a
+ pop af
+ ld [wOptions], a
+ ret
+
+addtradefunc: MACRO
+\1TradeFunc::
+ dw \1
+ ENDM
+
+tradefunc: MACRO
+ db (\1TradeFunc - TradeFuncPointerTable) / 2
+ ENDM
+
+; The functions in the sequences below are executed in order by TradeFuncCommon.
+; They are from opposite perspectives. The external clock one makes use of
+; Trade_SwapNames to swap the player and enemy names for some functions.
+
+InternalClockTradeFuncSequence:
+ tradefunc LoadTradingGFXAndMonNames
+ tradefunc Trade_ShowPlayerMon
+ tradefunc Trade_DrawOpenEndOfLinkCable
+ tradefunc Trade_AnimateBallEnteringLinkCable
+ tradefunc Trade_AnimLeftToRight
+ tradefunc Trade_Delay100
+ tradefunc Trade_ShowClearedWindow
+ tradefunc PrintTradeWentToText
+ tradefunc PrintTradeForSendsText
+ tradefunc PrintTradeFarewellText
+ tradefunc Trade_AnimRightToLeft
+ tradefunc Trade_ShowClearedWindow
+ tradefunc Trade_DrawOpenEndOfLinkCable
+ tradefunc Trade_ShowEnemyMon
+ tradefunc Trade_Delay100
+ tradefunc Trade_Cleanup
+ db $FF
+
+ExternalClockTradeFuncSequence:
+ tradefunc LoadTradingGFXAndMonNames
+ tradefunc Trade_ShowClearedWindow
+ tradefunc PrintTradeWillTradeText
+ tradefunc PrintTradeFarewellText
+ tradefunc Trade_SwapNames
+ tradefunc Trade_AnimLeftToRight
+ tradefunc Trade_SwapNames
+ tradefunc Trade_ShowClearedWindow
+ tradefunc Trade_DrawOpenEndOfLinkCable
+ tradefunc Trade_ShowEnemyMon
+ tradefunc Trade_SlideTextBoxOffScreen
+ tradefunc Trade_ShowPlayerMon
+ tradefunc Trade_DrawOpenEndOfLinkCable
+ tradefunc Trade_AnimateBallEnteringLinkCable
+ tradefunc Trade_SwapNames
+ tradefunc Trade_AnimRightToLeft
+ tradefunc Trade_SwapNames
+ tradefunc Trade_Delay100
+ tradefunc Trade_ShowClearedWindow
+ tradefunc PrintTradeWentToText
+ tradefunc Trade_Cleanup
+ db $FF
+
+TradeFuncPointerTable:
+ addtradefunc LoadTradingGFXAndMonNames
+ addtradefunc Trade_ShowPlayerMon
+ addtradefunc Trade_DrawOpenEndOfLinkCable
+ addtradefunc Trade_AnimateBallEnteringLinkCable
+ addtradefunc Trade_ShowEnemyMon
+ addtradefunc Trade_AnimLeftToRight
+ addtradefunc Trade_AnimRightToLeft
+ addtradefunc Trade_Delay100
+ addtradefunc Trade_ShowClearedWindow
+ addtradefunc PrintTradeWentToText
+ addtradefunc PrintTradeForSendsText
+ addtradefunc PrintTradeFarewellText
+ addtradefunc PrintTradeTakeCareText
+ addtradefunc PrintTradeWillTradeText
+ addtradefunc Trade_Cleanup
+ addtradefunc Trade_SlideTextBoxOffScreen
+ addtradefunc Trade_SwapNames
+
+Trade_Delay100:
+ ld c, 100
+ jp DelayFrames
+
+Trade_CopyTileMapToVRAM:
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call Delay3
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ret
+
+Trade_Delay80:
+ ld c, 80
+ jp DelayFrames
+
+Trade_ClearTileMap:
+ coord hl, 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, " "
+ jp FillMemory
+
+LoadTradingGFXAndMonNames:
+ call Trade_ClearTileMap
+ call DisableLCD
+ ld hl, TradingAnimationGraphics
+ ld de, vChars2 + $310
+ ld bc, TradingAnimationGraphicsEnd - TradingAnimationGraphics
+ ld a, BANK(TradingAnimationGraphics)
+ call FarCopyData2
+ ld hl, TradingAnimationGraphics2
+ ld de, vSprites + $7c0
+ ld bc, TradingAnimationGraphics2End - TradingAnimationGraphics2
+ ld a, BANK(TradingAnimationGraphics2)
+ call FarCopyData2
+ ld hl, vBGMap0
+ ld bc, $800
+ ld a, " "
+ call FillMemory
+ call ClearSprites
+ ld a, $ff
+ ld [wUpdateSpritesEnabled], a
+ ld hl, wd730
+ set 6, [hl] ; turn on instant text printing
+ ld a, [wOnSGB]
+ and a
+ ld a, $e4 ; non-SGB OBP0
+ jr z, .next
+ ld a, $f0 ; SGB OBP0
+.next
+ ld [rOBP0], a
+ call EnableLCD
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld a, [wTradedPlayerMonSpecies]
+ ld [wd11e], a
+ call GetMonName
+ ld hl, wcd6d
+ ld de, wcf4b
+ ld bc, NAME_LENGTH
+ call CopyData
+ ld a, [wTradedEnemyMonSpecies]
+ ld [wd11e], a
+ jp GetMonName
+
+Trade_LoadMonPartySpriteGfx:
+ ld a, %11010000
+ ld [rOBP1], a
+ jpba LoadMonPartySpriteGfx
+
+Trade_SwapNames:
+ ld hl, wPlayerName
+ ld de, wBuffer
+ ld bc, NAME_LENGTH
+ call CopyData
+ ld hl, wLinkEnemyTrainerName
+ ld de, wPlayerName
+ ld bc, NAME_LENGTH
+ call CopyData
+ ld hl, wBuffer
+ ld de, wLinkEnemyTrainerName
+ ld bc, NAME_LENGTH
+ jp CopyData
+
+Trade_Cleanup:
+ xor a
+ call LoadGBPal
+ ld hl, wd730
+ res 6, [hl] ; turn off instant text printing
+ ret
+
+Trade_ShowPlayerMon:
+ ld a, %10101011
+ ld [rLCDC], a
+ ld a, $50
+ ld [hWY], a
+ ld a, $86
+ ld [rWX], a
+ ld [hSCX], a
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ coord hl, 4, 0
+ ld b, 6
+ ld c, 10
+ call TextBoxBorder
+ call Trade_PrintPlayerMonInfoText
+ ld b, vBGMap0 / $100
+ call CopyScreenTileBufferToVRAM
+ call ClearScreen
+ ld a, [wTradedPlayerMonSpecies]
+ call Trade_LoadMonSprite
+ ld a, $7e
+.slideScreenLoop
+ push af
+ call DelayFrame
+ pop af
+ ld [rWX], a
+ ld [hSCX], a
+ dec a
+ dec a
+ and a
+ jr nz, .slideScreenLoop
+ call Trade_Delay80
+ ld a, TRADE_BALL_POOF_ANIM
+ call Trade_ShowAnimation
+ ld a, TRADE_BALL_DROP_ANIM
+ call Trade_ShowAnimation ; clears mon pic
+ ld a, [wTradedPlayerMonSpecies]
+ call PlayCry
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ret
+
+Trade_DrawOpenEndOfLinkCable:
+ call Trade_ClearTileMap
+ ld b, vBGMap0 / $100
+ call CopyScreenTileBufferToVRAM
+ ld b, SET_PAL_GENERIC
+ call RunPaletteCommand
+
+; This function call is pointless. It just copies blank tiles to VRAM that was
+; already filled with blank tiles.
+ ld hl, vBGMap1 + $8c
+ call Trade_CopyCableTilesOffScreen
+
+ ld a, $a0
+ ld [hSCX], a
+ call DelayFrame
+ ld a, %10001011
+ ld [rLCDC], a
+ coord hl, 6, 2
+ ld b, $7 ; open end of link cable tile ID list index
+ call CopyTileIDsFromList_ZeroBaseTileID
+ call Trade_CopyTileMapToVRAM
+ ld a, SFX_HEAL_HP
+ call PlaySound
+ ld c, 20
+.loop
+ ld a, [hSCX]
+ add 4
+ ld [hSCX], a
+ dec c
+ jr nz, .loop
+ ret
+
+Trade_AnimateBallEnteringLinkCable:
+ ld a, TRADE_BALL_SHAKE_ANIM
+ call Trade_ShowAnimation
+ ld c, 10
+ call DelayFrames
+ ld a, %11100100
+ ld [rOBP0], a
+ xor a
+ ld [wLinkCableAnimBulgeToggle], a
+ lb bc, $20, $60
+.moveBallInsideLinkCableLoop
+ push bc
+ xor a
+ ld de, Trade_BallInsideLinkCableOAM
+ call WriteOAMBlock
+ ld a, [wLinkCableAnimBulgeToggle]
+ xor $1
+ ld [wLinkCableAnimBulgeToggle], a
+ add $7e
+ ld hl, wOAMBuffer + $02
+ ld de, 4
+ ld c, e
+.cycleLinkCableBulgeTile
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .cycleLinkCableBulgeTile
+ call Delay3
+ pop bc
+ ld a, c
+ add $4
+ ld c, a
+ cp $a0
+ jr nc, .ballSpriteReachedEdgeOfScreen
+ ld a, SFX_TINK
+ call PlaySound
+ jr .moveBallInsideLinkCableLoop
+.ballSpriteReachedEdgeOfScreen
+ call ClearSprites
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call ClearScreen
+ ld b, $98
+ call CopyScreenTileBufferToVRAM
+ call Delay3
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ret
+
+Trade_BallInsideLinkCableOAM:
+ db $7E,$00,$7E,$20
+ db $7E,$40,$7E,$60
+
+Trade_ShowEnemyMon:
+ ld a, TRADE_BALL_TILT_ANIM
+ call Trade_ShowAnimation
+ call Trade_ShowClearedWindow
+ coord hl, 4, 10
+ ld b, 6
+ ld c, 10
+ call TextBoxBorder
+ call Trade_PrintEnemyMonInfoText
+ call Trade_CopyTileMapToVRAM
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld a, [wTradedEnemyMonSpecies]
+ call Trade_LoadMonSprite
+ ld a, TRADE_BALL_POOF_ANIM
+ call Trade_ShowAnimation
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ ld a, [wTradedEnemyMonSpecies]
+ call PlayCry
+ call Trade_Delay100
+ coord hl, 4, 10
+ lb bc, 8, 12
+ call ClearScreenArea
+ jp PrintTradeTakeCareText
+
+Trade_AnimLeftToRight:
+; Animates the mon moving from the left GB to the right one.
+ call Trade_InitGameboyTransferGfx
+ ld a, $1
+ ld [wTradedMonMovingRight], a
+ ld a, %11100100
+ ld [rOBP0], a
+ ld a, $54
+ ld [wBaseCoordX], a
+ ld a, $1c
+ ld [wBaseCoordY], a
+ ld a, [wLeftGBMonSpecies]
+ ld [wMonPartySpriteSpecies], a
+ call Trade_WriteCircledMonOAM
+ call Trade_DrawLeftGameboy
+ call Trade_CopyTileMapToVRAM
+ call Trade_DrawCableAcrossScreen
+ ld hl, vBGMap1 + $8c
+ call Trade_CopyCableTilesOffScreen
+ ld b, $6
+ call Trade_AnimMonMoveHorizontal
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call Trade_DrawCableAcrossScreen
+ ld b, $4
+ call Trade_AnimMonMoveHorizontal
+ call Trade_DrawRightGameboy
+ ld b, $6
+ call Trade_AnimMonMoveHorizontal
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call Trade_AnimMonMoveVertical
+ jp ClearSprites
+
+Trade_AnimRightToLeft:
+; Animates the mon moving from the right GB to the left one.
+ call Trade_InitGameboyTransferGfx
+ xor a
+ ld [wTradedMonMovingRight], a
+ ld a, $64
+ ld [wBaseCoordX], a
+ ld a, $44
+ ld [wBaseCoordY], a
+ ld a, [wRightGBMonSpecies]
+ ld [wMonPartySpriteSpecies], a
+ call Trade_WriteCircledMonOAM
+ call Trade_DrawRightGameboy
+ call Trade_CopyTileMapToVRAM
+ call Trade_DrawCableAcrossScreen
+ ld hl, vBGMap1 + $94
+ call Trade_CopyCableTilesOffScreen
+ call Trade_AnimMonMoveVertical
+ ld b, $6
+ call Trade_AnimMonMoveHorizontal
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call Trade_DrawCableAcrossScreen
+ ld b, $4
+ call Trade_AnimMonMoveHorizontal
+ call Trade_DrawLeftGameboy
+ ld b, $6
+ call Trade_AnimMonMoveHorizontal
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ jp ClearSprites
+
+Trade_InitGameboyTransferGfx:
+; Initialises the graphics for showing a mon moving between gameboys.
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call ClearScreen
+ xor a
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call Trade_LoadMonPartySpriteGfx
+ call DelayFrame
+ ld a, %10101011
+ ld [rLCDC], a
+ xor a
+ ld [hSCX], a
+ ld a, $90
+ ld [hWY], a
+ ret
+
+Trade_DrawLeftGameboy:
+ call Trade_ClearTileMap
+
+; draw link cable
+ coord hl, 11, 4
+ ld a, $5d
+ ld [hli], a
+ ld a, $5e
+ ld c, 8
+.loop
+ ld [hli], a
+ dec c
+ jr nz, .loop
+
+; draw gameboy pic
+ coord hl, 5, 3
+ ld b, $6
+ call CopyTileIDsFromList_ZeroBaseTileID
+
+; draw text box with player name below gameboy pic
+ coord hl, 4, 12
+ ld b, 2
+ ld c, 7
+ call TextBoxBorder
+ coord hl, 5, 14
+ ld de, wPlayerName
+ call PlaceString
+
+ jp DelayFrame
+
+Trade_DrawRightGameboy:
+ call Trade_ClearTileMap
+
+; draw horizontal segment of link cable
+ coord hl, 0, 4
+ ld a, $5e
+ ld c, $e
+.loop
+ ld [hli], a
+ dec c
+ jr nz, .loop
+
+; draw vertical segment of link cable
+ ld a, $5f
+ ld [hl], a
+ ld de, SCREEN_WIDTH
+ add hl, de
+ ld a, $61
+ ld [hl], a
+ add hl, de
+ ld [hl], a
+ add hl, de
+ ld [hl], a
+ add hl, de
+ ld [hl], a
+ add hl, de
+ ld a, $60
+ ld [hld], a
+ ld a, $5d
+ ld [hl], a
+
+; draw gameboy pic
+ coord hl, 7, 8
+ ld b, $6
+ call CopyTileIDsFromList_ZeroBaseTileID
+
+; draw text box with enemy name above link cable
+ coord hl, 6, 0
+ ld b, 2
+ ld c, 7
+ call TextBoxBorder
+ coord hl, 7, 2
+ ld de, wLinkEnemyTrainerName
+ call PlaceString
+
+ jp DelayFrame
+
+Trade_DrawCableAcrossScreen:
+; Draws the link cable across the screen.
+ call Trade_ClearTileMap
+ coord hl, 0, 4
+ ld a, $5e
+ ld c, SCREEN_WIDTH
+.loop
+ ld [hli], a
+ dec c
+ jr nz, .loop
+ ret
+
+Trade_CopyCableTilesOffScreen:
+; This is used to copy the link cable tiles off screen so that the cable
+; continues when the screen is scrolled.
+ push hl
+ coord hl, 0, 4
+ call CopyToRedrawRowOrColumnSrcTiles
+ pop hl
+ ld a, h
+ ld [hRedrawRowOrColumnDest + 1], a
+ ld a, l
+ ld [hRedrawRowOrColumnDest], a
+ ld a, REDRAW_ROW
+ ld [hRedrawRowOrColumnMode], a
+ ld c, 10
+ jp DelayFrames
+
+Trade_AnimMonMoveHorizontal:
+; Animates the mon going through the link cable horizontally over a distance of
+; b 16-pixel units.
+ ld a, [wTradedMonMovingRight]
+ ld e, a
+ ld d, $8
+.scrollLoop
+ ld a, e
+ dec a
+ jr z, .movingRight
+; moving left
+ ld a, [hSCX]
+ sub $2
+ jr .next
+.movingRight
+ ld a, [hSCX]
+ add $2
+.next
+ ld [hSCX], a
+ call DelayFrame
+ dec d
+ jr nz, .scrollLoop
+ call Trade_AnimCircledMon
+ dec b
+ jr nz, Trade_AnimMonMoveHorizontal
+ ret
+
+Trade_AnimCircledMon:
+; Cycles between the two animation frames of the mon party sprite, cycles
+; between a circle and an oval around the mon sprite, and makes the cable flash.
+ push de
+ push bc
+ push hl
+ ld a, [rBGP]
+ xor $3c ; make link cable flash
+ ld [rBGP], a
+ ld hl, wOAMBuffer + $02
+ ld de, $4
+ ld c, $14
+.loop
+ ld a, [hl]
+ xor $40
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .loop
+ pop hl
+ pop bc
+ pop de
+ ret
+
+Trade_WriteCircledMonOAM:
+ callba WriteMonPartySpriteOAMBySpecies
+ call Trade_WriteCircleOAM
+
+Trade_AddOffsetsToOAMCoords:
+ ld hl, wOAMBuffer
+ ld c, $14
+.loop
+ ld a, [wBaseCoordY]
+ add [hl]
+ ld [hli], a
+ ld a, [wBaseCoordX]
+ add [hl]
+ ld [hli], a
+ inc hl
+ inc hl
+ dec c
+ jr nz, .loop
+ ret
+
+Trade_AnimMonMoveVertical:
+; Animates the mon going through the link cable vertically as well as
+; horizontally for a bit. The last bit of horizontal movement (when moving
+; right) or the first bit of horizontal movement (when moving left) are done
+; here instead of Trade_AnimMonMoveHorizontal because this function moves the
+; sprite itself rather than scrolling the screen around the sprite. Moving the
+; sprite itself is necessary because the vertical segment of the link cable is
+; to the right of the screen position that the mon sprite has when
+; Trade_AnimMonMoveHorizontal is executing.
+ ld a, [wTradedMonMovingRight]
+ and a
+ jr z, .movingLeft
+; moving right
+ lb bc, 4, 0 ; move right
+ call .doAnim
+ lb bc, 0, 10 ; move down
+ jr .doAnim
+.movingLeft
+ lb bc, 0, -10 ; move up
+ call .doAnim
+ lb bc, -4, 0 ; move left
+.doAnim
+ ld a, b
+ ld [wBaseCoordX], a
+ ld a, c
+ ld [wBaseCoordY], a
+ ld d, $4
+.loop
+ call Trade_AddOffsetsToOAMCoords
+ call Trade_AnimCircledMon
+ ld c, 8
+ call DelayFrames
+ dec d
+ jr nz, .loop
+ ret
+
+Trade_WriteCircleOAM:
+; Writes the OAM blocks for the circle around the traded mon as it passes
+; the link cable.
+ ld hl, Trade_CircleOAMPointers
+ ld c, $4
+ xor a
+.loop
+ push bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+ inc hl
+ push hl
+ inc a
+ push af
+ call WriteOAMBlock
+ pop af
+ pop hl
+ pop bc
+ dec c
+ jr nz, .loop
+ ret
+
+Trade_CircleOAMPointers:
+ dw Trade_CircleOAM0
+ db $08,$08
+ dw Trade_CircleOAM1
+ db $18,$08
+ dw Trade_CircleOAM2
+ db $08,$18
+ dw Trade_CircleOAM3
+ db $18,$18
+
+Trade_CircleOAM0:
+ db $38,$10,$39,$10
+ db $3A,$10,$3B,$10
+
+Trade_CircleOAM1:
+ db $39,$30,$38,$30
+ db $3B,$30,$3A,$30
+
+Trade_CircleOAM2:
+ db $3A,$50,$3B,$50
+ db $38,$50,$39,$50
+
+Trade_CircleOAM3:
+ db $3B,$70,$3A,$70
+ db $39,$70,$38,$70
+
+; a = species
+Trade_LoadMonSprite:
+ ld [wcf91], a
+ ld [wd0b5], a
+ ld [wWholeScreenPaletteMonSpecies], a
+ ld b, SET_PAL_POKEMON_WHOLE_SCREEN
+ ld c, 0
+ call RunPaletteCommand
+ ld a, [H_AUTOBGTRANSFERENABLED]
+ xor $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call GetMonHeader
+ coord hl, 7, 2
+ call LoadFlippedFrontSpriteByMonIndex
+ ld c, 10
+ jp DelayFrames
+
+Trade_ShowClearedWindow:
+; clears the window and covers the BG entirely with the window
+ ld a, $1
+ ld [H_AUTOBGTRANSFERENABLED], a
+ call ClearScreen
+ ld a, %11100011
+ ld [rLCDC], a
+ ld a, $7
+ ld [rWX], a
+ xor a
+ ld [hWY], a
+ ld a, $90
+ ld [hSCX], a
+ ret
+
+Trade_SlideTextBoxOffScreen:
+; Slides the window right until it's off screen. The window usually just has
+; a text box at the bottom when this is called. However, when this is called
+; after Trade_ShowEnemyMon in the external clock sequence, there is a mon pic
+; above the text box and it is also scrolled off the screen.
+ ld c, 50
+ call DelayFrames
+.loop
+ call DelayFrame
+ ld a, [rWX]
+ inc a
+ inc a
+ ld [rWX], a
+ cp $a1
+ jr nz, .loop
+ call Trade_ClearTileMap
+ ld c, 10
+ call DelayFrames
+ ld a, $7
+ ld [rWX], a
+ ret
+
+PrintTradeWentToText:
+ ld hl, TradeWentToText
+ call PrintText
+ ld c, 200
+ call DelayFrames
+ jp Trade_SlideTextBoxOffScreen
+
+TradeWentToText:
+ TX_FAR _TradeWentToText
+ db "@"
+
+PrintTradeForSendsText:
+ ld hl, TradeForText
+ call PrintText
+ call Trade_Delay80
+ ld hl, TradeSendsText
+ call PrintText
+ jp Trade_Delay80
+
+TradeForText:
+ TX_FAR _TradeForText
+ db "@"
+
+TradeSendsText:
+ TX_FAR _TradeSendsText
+ db "@"
+
+PrintTradeFarewellText:
+ ld hl, TradeWavesFarewellText
+ call PrintText
+ call Trade_Delay80
+ ld hl, TradeTransferredText
+ call PrintText
+ call Trade_Delay80
+ jp Trade_SlideTextBoxOffScreen
+
+TradeWavesFarewellText:
+ TX_FAR _TradeWavesFarewellText
+ db "@"
+
+TradeTransferredText:
+ TX_FAR _TradeTransferredText
+ db "@"
+
+PrintTradeTakeCareText:
+ ld hl, TradeTakeCareText
+ call PrintText
+ jp Trade_Delay80
+
+TradeTakeCareText:
+ TX_FAR _TradeTakeCareText
+ db "@"
+
+PrintTradeWillTradeText:
+ ld hl, TradeWillTradeText
+ call PrintText
+ call Trade_Delay80
+ ld hl, TradeforText
+ call PrintText
+ jp Trade_Delay80
+
+TradeWillTradeText:
+ TX_FAR _TradeWillTradeText
+ db "@"
+
+TradeforText:
+ TX_FAR _TradeforText
+ db "@"
+
+Trade_ShowAnimation:
+ ld [wAnimationID], a
+ xor a
+ ld [wAnimationType], a
+ predef_jump MoveAnimation
diff --git a/engine/movie/trade2.asm b/engine/movie/trade2.asm
new file mode 100755
index 00000000..2c79e077
--- /dev/null
+++ b/engine/movie/trade2.asm
@@ -0,0 +1,48 @@
+Trade_PrintPlayerMonInfoText:
+ coord hl, 5, 0
+ ld de, Trade_MonInfoText
+ call PlaceString
+ ld a, [wTradedPlayerMonSpecies]
+ ld [wd11e], a
+ predef IndexToPokedex
+ coord hl, 9, 0
+ ld de, wd11e
+ lb bc, LEADING_ZEROES | 1, 3
+ call PrintNumber
+ coord hl, 5, 2
+ ld de, wcf4b
+ call PlaceString
+ coord hl, 8, 4
+ ld de, wTradedPlayerMonOT
+ call PlaceString
+ coord hl, 8, 6
+ ld de, wTradedPlayerMonOTID
+ lb bc, LEADING_ZEROES | 2, 5
+ jp PrintNumber
+
+Trade_PrintEnemyMonInfoText:
+ coord hl, 5, 10
+ ld de, Trade_MonInfoText
+ call PlaceString
+ ld a, [wTradedEnemyMonSpecies]
+ ld [wd11e], a
+ predef IndexToPokedex
+ coord hl, 9, 10
+ ld de, wd11e
+ lb bc, LEADING_ZEROES | 1, 3
+ call PrintNumber
+ coord hl, 5, 12
+ ld de, wcd6d
+ call PlaceString
+ coord hl, 8, 14
+ ld de, wTradedEnemyMonOT
+ call PlaceString
+ coord hl, 8, 16
+ ld de, wTradedEnemyMonOTID
+ lb bc, LEADING_ZEROES | 2, 5
+ jp PrintNumber
+
+Trade_MonInfoText:
+ db "──№⠄",$4E
+ next "OT/"
+ next $73,"№⠄","@"