diff options
Diffstat (limited to 'engine')
-rw-r--r-- | engine/battle/battle_transition.asm | 2 | ||||
-rw-r--r-- | engine/gfx/color.asm | 6 | ||||
-rw-r--r-- | engine/gfx/load_pics.asm | 2 | ||||
-rw-r--r-- | engine/gfx/sprite_anims.asm | 18 | ||||
-rw-r--r-- | engine/menus/options_menu.asm | 565 | ||||
-rw-r--r-- | engine/movie/gamefreak_presents.asm | 363 | ||||
-rw-r--r-- | engine/movie/gold_silver_intro.asm | 1604 | ||||
-rw-r--r-- | engine/movie/title.asm | 7 |
8 files changed, 2188 insertions, 379 deletions
diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm index 4de4d347..ad4b359c 100644 --- a/engine/battle/battle_transition.asm +++ b/engine/battle/battle_transition.asm @@ -84,7 +84,7 @@ ConvertTrainerBattlePokeballTilesTo2bpp: jr nz, .loop ld de, wDecompressScratch - ld hl, vBGMap2 + hlbgcoord 0, 0, vBGMap2 ld b, BANK(@) ld c, $28 call Request2bpp diff --git a/engine/gfx/color.asm b/engine/gfx/color.asm index 37b1d7ba..d7998019 100644 --- a/engine/gfx/color.asm +++ b/engine/gfx/color.asm @@ -141,7 +141,7 @@ SGB_ApplyPartyMenuHPPals: ld [hl], e ret -Unreferenced_Function9102: +Function9102: call CheckCGB ret z ; CGB only @@ -172,7 +172,7 @@ Unreferenced_Function9102: RGB 08, 16, 28 RGB 00, 00, 00 -Unreferenced_Function9136: +Function9136: call CheckCGB ret nz ldh a, [hSGB] @@ -211,7 +211,7 @@ Unreferenced_Function915e: call GetPredefPal jp LoadHLPaletteIntoDE -Unreferenced_Function9178: +Intro_LoadMonPalette: call CheckCGB jr nz, .cgb ldh a, [hSGB] diff --git a/engine/gfx/load_pics.asm b/engine/gfx/load_pics.asm index c9ee98b7..8b9f4f6a 100644 --- a/engine/gfx/load_pics.asm +++ b/engine/gfx/load_pics.asm @@ -216,7 +216,7 @@ FixPicBank: db $1f, $2e db -1 -Function1587f: +Intro_GetMonFrontpic: ld a, c push de ld hl, PokemonPicPointers diff --git a/engine/gfx/sprite_anims.asm b/engine/gfx/sprite_anims.asm index a6e717e8..b32a3d27 100644 --- a/engine/gfx/sprite_anims.asm +++ b/engine/gfx/sprite_anims.asm @@ -20,8 +20,8 @@ DoAnimFrame: dw .GSIntroBubble dw .GSIntroShellder dw .GSIntroMagikarp + dw .UnusedLapras dw .GSIntroLapras - dw .GSIntroLapras2 dw .GSIntroNote dw .GSIntroJigglypuff dw .GSIntroPikachu @@ -227,7 +227,7 @@ DoAnimFrame: call DeinitializeSprite ret -.GSIntroLapras +.UnusedLapras ld hl, SPRITEANIMSTRUCT_XCOORD add hl, bc ld a, [hl] @@ -251,7 +251,7 @@ DoAnimFrame: call DeinitializeSprite ret -.GSIntroLapras2 +.GSIntroLapras call .AnonymousJumptable jp hl @@ -309,8 +309,8 @@ DoAnimFrame: .asm_8d602 call DeinitializeSprite - ld a, $1 - ld [wBattleMonLevel], a + ld a, 1 + ld [wcb19], a ret .Function8d60b @@ -392,7 +392,7 @@ DoAnimFrame: dw .Function8d680 .Function8d673 - ld a, [wBattleMonLevel] + ld a, [wcb19] and a ret z call .IncrementJumptableIndex @@ -479,7 +479,7 @@ DoAnimFrame: .asm_8d6e9 ld a, 1 - ld [wBattleMonLevel], a + ld [wcb19], a call .IncrementJumptableIndex ret @@ -562,7 +562,7 @@ DoAnimFrame: jr z, .asm_8d761 dec [hl] dec [hl] - ld a, [wBattleMonLevel] + ld a, [wcb19] and a ret nz dec [hl] @@ -997,7 +997,7 @@ ENDC .asm_8d968 ld a, 1 - ld [wce64], a + ld [wIntroSceneFrameCounter], a call DeinitializeSprite ret diff --git a/engine/menus/options_menu.asm b/engine/menus/options_menu.asm new file mode 100644 index 00000000..d0a6afc5 --- /dev/null +++ b/engine/menus/options_menu.asm @@ -0,0 +1,565 @@ +; GetOptionPointer.Pointers indexes + const_def + const OPT_TEXT_SPEED ; 0 + const OPT_BATTLE_SCENE ; 1 + const OPT_BATTLE_STYLE ; 2 + const OPT_SOUND ; 3 + const OPT_PRINT ; 4 + const OPT_MENU_ACCOUNT ; 5 + const OPT_FRAME ; 6 + const OPT_CANCEL ; 7 +NUM_OPTIONS EQU const_value ; 8 + +_OptionsMenu: + ld hl, hInMenu + ld a, [hl] + push af + ld [hl], TRUE + call ClearBGPalettes + hlcoord 0, 0 + ld b, SCREEN_HEIGHT - 2 + ld c, SCREEN_WIDTH - 2 + call Textbox + hlcoord 2, 2 + ld de, StringOptions + call PlaceString + xor a + ld [wJumptableIndex], a + +; display the settings of each option when the menu is opened + ld c, NUM_OPTIONS - 2 ; omit frame type, the last option +.print_text_loop + push bc + xor a + ldh [hJoyLast], a + call GetOptionPointer + pop bc + ld hl, wJumptableIndex + inc [hl] + dec c + jr nz, .print_text_loop + call UpdateFrame ; display the frame type + + xor a + ld [wJumptableIndex], a + inc a + ldh [hBGMapMode], a + call WaitBGMap + ld b, SCGB_DIPLOMA + call GetSGBLayout + call SetPalettes + +.joypad_loop + call JoyTextDelay + ldh a, [hJoyPressed] + and START | B_BUTTON + jr nz, .ExitOptions + call OptionsControl + jr c, .dpad + call GetOptionPointer + jr c, .ExitOptions + +.dpad + call Options_UpdateCursorPosition + ld c, 3 + call DelayFrames + jr .joypad_loop + +.ExitOptions: + pop af + ldh [hInMenu], a + ret + +StringOptions: + db "TEXT SPEED<LF>" + db " :<LF>" + db "BATTLE SCENE<LF>" + db " :<LF>" + db "BATTLE STYLE<LF>" + db " :<LF>" + db "SOUND<LF>" + db " :<LF>" + db "PRINT<LF>" + db " :<LF>" + db "MENU ACCOUNT<LF>" + db " :<LF>" + db "FRAME<LF>" + db " :TYPE<LF>" + db "CANCEL@" + +GetOptionPointer: + ld a, [wJumptableIndex] + ld e, a + ld d, 0 + ld hl, .Pointers + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.Pointers: +; entries correspond to OPT_* constants + dw Options_TextSpeed + dw Options_BattleScene + dw Options_BattleStyle + dw Options_Sound + dw Options_Print + dw Options_MenuAccount + dw Options_Frame + dw Options_Cancel + + const_def + const OPT_TEXT_SPEED_FAST ; 0 + const OPT_TEXT_SPEED_MED ; 1 + const OPT_TEXT_SPEED_SLOW ; 2 + +Options_TextSpeed: + call GetTextSpeed + ldh a, [hJoyPressed] + bit D_LEFT_F, a + jr nz, .LeftPressed + bit D_RIGHT_F, a + jr z, .NonePressed + ld a, c ; right pressed + cp OPT_TEXT_SPEED_SLOW + jr c, .Increase + ld c, OPT_TEXT_SPEED_FAST - 1 + +.Increase: + inc c + ld a, e + jr .Save + +.LeftPressed: + ld a, c + and a + jr nz, .Decrease + ld c, OPT_TEXT_SPEED_SLOW + 1 + +.Decrease: + dec c + ld a, d + +.Save: + ld b, a + ld a, [wOptions] + and $f0 + or b + ld [wOptions], a + +.NonePressed: + ld b, 0 + ld hl, .Strings + add hl, bc + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 11, 3 + call PlaceString + and a + ret + +.Strings: +; entries correspond to OPT_TEXT_SPEED_* constants + dw .Fast + dw .Mid + dw .Slow + +.Fast: db "FAST@" +.Mid: db "MID @" +.Slow: db "SLOW@" + +GetTextSpeed: +; converts TEXT_DELAY_* value in a to OPT_TEXT_SPEED_* value in c, +; with previous/next TEXT_DELAY_* values in d/e + ld a, [wOptions] + and TEXT_DELAY_MASK + cp TEXT_DELAY_SLOW + jr z, .slow + cp TEXT_DELAY_FAST + jr z, .fast + ; none of the above + ld c, OPT_TEXT_SPEED_MED + lb de, TEXT_DELAY_FAST, TEXT_DELAY_SLOW + ret + +.slow + ld c, OPT_TEXT_SPEED_SLOW + lb de, TEXT_DELAY_MED, TEXT_DELAY_FAST + ret + +.fast + ld c, OPT_TEXT_SPEED_FAST + lb de, TEXT_DELAY_SLOW, TEXT_DELAY_MED + ret + +Options_BattleScene: + ld hl, wOptions + ldh a, [hJoyPressed] + bit D_LEFT_F, a + jr nz, .LeftPressed + bit D_RIGHT_F, a + jr z, .NonePressed + bit BATTLE_SCENE, [hl] + jr nz, .ToggleOn + jr .ToggleOff + +.LeftPressed: + bit BATTLE_SCENE, [hl] + jr z, .ToggleOff + jr .ToggleOn + +.NonePressed: + bit BATTLE_SCENE, [hl] + jr z, .ToggleOn + jr .ToggleOff + +.ToggleOn: + res BATTLE_SCENE, [hl] + ld de, .On + jr .Display + +.ToggleOff: + set BATTLE_SCENE, [hl] + ld de, .Off + +.Display: + hlcoord 11, 5 + call PlaceString + and a + ret + +.On: db "ON @" +.Off: db "OFF@" + +Options_BattleStyle: + ld hl, wOptions + ldh a, [hJoyPressed] + bit D_LEFT_F, a + jr nz, .LeftPressed + bit D_RIGHT_F, a + jr z, .NonePressed + bit BATTLE_SHIFT, [hl] + jr nz, .ToggleShift + jr .ToggleSet + +.LeftPressed: + bit BATTLE_SHIFT, [hl] + jr z, .ToggleSet + jr .ToggleShift + +.NonePressed: + bit BATTLE_SHIFT, [hl] + jr nz, .ToggleSet + +.ToggleShift: + res BATTLE_SHIFT, [hl] + ld de, .Shift + jr .Display + +.ToggleSet: + set BATTLE_SHIFT, [hl] + ld de, .Set + +.Display: + hlcoord 11, 7 + call PlaceString + and a + ret + +.Shift: db "SHIFT@" +.Set: db "SET @" + +Options_Sound: + ld hl, wOptions + ldh a, [hJoyPressed] + bit D_LEFT_F, a + jr nz, .LeftPressed + bit D_RIGHT_F, a + jr z, .NonePressed + bit STEREO, [hl] + jr nz, .SetMono + jr .SetStereo + +.LeftPressed: + bit STEREO, [hl] + jr z, .SetStereo + jr .SetMono + +.NonePressed: + bit STEREO, [hl] + jr nz, .ToggleStereo + jr .ToggleMono + +.SetMono: + res STEREO, [hl] + call RestartMapMusic + +.ToggleMono: + ld de, .Mono + jr .Display + +.SetStereo: + set STEREO, [hl] + call RestartMapMusic + +.ToggleStereo: + ld de, .Stereo + +.Display: + hlcoord 11, 9 + call PlaceString + and a + ret + +.Mono: db "MONO @" +.Stereo: db "STEREO@" + + const_def + const OPT_PRINT_LIGHTEST ; 0 + const OPT_PRINT_LIGHTER ; 1 + const OPT_PRINT_NORMAL ; 2 + const OPT_PRINT_DARKER ; 3 + const OPT_PRINT_DARKEST ; 4 + +Options_Print: + call GetPrinterSetting + ldh a, [hJoyPressed] + bit D_LEFT_F, a + jr nz, .LeftPressed + bit D_RIGHT_F, a + jr z, .NonePressed + ld a, c + cp OPT_PRINT_DARKEST + jr c, .Increase + ld c, OPT_PRINT_LIGHTEST - 1 + +.Increase: + inc c + ld a, e + jr .Save + +.LeftPressed: + ld a, c + and a + jr nz, .Decrease + ld c, OPT_PRINT_DARKEST + 1 + +.Decrease: + dec c + ld a, d + +.Save: + ld b, a + ld [wGBPrinterBrightness], a + +.NonePressed: + ld b, 0 + ld hl, .Strings + add hl, bc + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + hlcoord 11, 11 + call PlaceString + and a + ret + +.Strings: +; entries correspond to OPT_PRINT_* constants + dw .Lightest + dw .Lighter + dw .Normal + dw .Darker + dw .Darkest + +.Lightest: db "LIGHTEST@" +.Lighter: db "LIGHTER @" +.Normal: db "NORMAL @" +.Darker: db "DARKER @" +.Darkest: db "DARKEST @" + +GetPrinterSetting: +; converts GBPRINTER_* value in a to OPT_PRINT_* value in c, +; with previous/next GBPRINTER_* values in d/e + ld a, [wGBPrinterBrightness] + and a + jr z, .IsLightest + cp GBPRINTER_LIGHTER + jr z, .IsLight + cp GBPRINTER_DARKER + jr z, .IsDark + cp GBPRINTER_DARKEST + jr z, .IsDarkest + ; none of the above + ld c, OPT_PRINT_NORMAL + lb de, GBPRINTER_LIGHTER, GBPRINTER_DARKER + ret + +.IsLightest: + ld c, OPT_PRINT_LIGHTEST + lb de, GBPRINTER_DARKEST, GBPRINTER_LIGHTER + ret + +.IsLight: + ld c, OPT_PRINT_LIGHTER + lb de, GBPRINTER_LIGHTEST, GBPRINTER_NORMAL + ret + +.IsDark: + ld c, OPT_PRINT_DARKER + lb de, GBPRINTER_NORMAL, GBPRINTER_DARKEST + ret + +.IsDarkest: + ld c, OPT_PRINT_DARKEST + lb de, GBPRINTER_DARKER, GBPRINTER_LIGHTEST + ret + +Options_MenuAccount: + ld hl, wOptions2 + ldh a, [hJoyPressed] + bit D_LEFT_F, a + jr nz, .LeftPressed + bit D_RIGHT_F, a + jr z, .NonePressed + bit MENU_ACCOUNT, [hl] + jr nz, .ToggleOff + jr .ToggleOn + +.LeftPressed: + bit MENU_ACCOUNT, [hl] + jr z, .ToggleOn + jr .ToggleOff + +.NonePressed: + bit MENU_ACCOUNT, [hl] + jr nz, .ToggleOn + +.ToggleOff: + res MENU_ACCOUNT, [hl] + ld de, .Off + jr .Display + +.ToggleOn: + set MENU_ACCOUNT, [hl] + ld de, .On + +.Display: + hlcoord 11, 13 + call PlaceString + and a + ret + +.Off: db "OFF@" +.On: db "ON @" + +Options_Frame: + ld hl, wTextboxFrame + ldh a, [hJoyPressed] + bit D_LEFT_F, a + jr nz, .LeftPressed + bit D_RIGHT_F, a + jr nz, .RightPressed + and a + ret + +.RightPressed: + ld a, [hl] + inc a + jr .Save + +.LeftPressed: + ld a, [hl] + dec a + +.Save: + maskbits NUM_FRAMES + ld [hl], a +UpdateFrame: + ld a, [wTextboxFrame] + hlcoord 16, 15 ; where on the screen the number is drawn + add "1" + ld [hl], a + call LoadFontsExtra + and a + ret + +Options_Cancel: + ldh a, [hJoyPressed] + and A_BUTTON + jr nz, .Exit + and a + ret + +.Exit: + scf + ret + +OptionsControl: + ld hl, wJumptableIndex + ldh a, [hJoyLast] + cp D_DOWN + jr z, .DownPressed + cp D_UP + jr z, .UpPressed + and a + ret + +.DownPressed: + ld a, [hl] + cp OPT_CANCEL ; maximum option index + jr nz, .CheckMenuAccount + ld [hl], OPT_TEXT_SPEED ; first option + scf + ret + +.CheckMenuAccount: ; I have no idea why this exists... + cp OPT_MENU_ACCOUNT + jr nz, .Increase + ld [hl], OPT_MENU_ACCOUNT + +.Increase: + inc [hl] + scf + ret + +.UpPressed: + ld a, [hl] + +; Another thing where I'm not sure why it exists + cp OPT_FRAME + jr nz, .NotFrame + ld [hl], OPT_MENU_ACCOUNT + scf + ret + +.NotFrame: + and a ; OPT_TEXT_SPEED, minimum option index + jr nz, .Decrease + ld [hl], NUM_OPTIONS ; decrements to OPT_CANCEL, maximum option index + +.Decrease: + dec [hl] + scf + ret + +Options_UpdateCursorPosition: + hlcoord 1, 1 + ld de, SCREEN_WIDTH + ld c, SCREEN_HEIGHT - 2 +.loop + ld [hl], " " + add hl, de + dec c + jr nz, .loop + hlcoord 1, 2 + ld bc, 2 * SCREEN_WIDTH + ld a, [wJumptableIndex] + call AddNTimes + ld [hl], "▶" + ret diff --git a/engine/movie/gamefreak_presents.asm b/engine/movie/gamefreak_presents.asm deleted file mode 100644 index f4c2c5cc..00000000 --- a/engine/movie/gamefreak_presents.asm +++ /dev/null @@ -1,363 +0,0 @@ -Copyright_GFPresents: -; Play the copyright screen and GameFreak Presents sequence. -; Return carry if user cancels animation by pressing a button. - - call ClearBGPalettes - call ClearTilemap - ld a, HIGH(vBGMap0) - ldh [hBGMapAddress + 1], a - xor a ; LOW(vBGMap0) - ldh [hBGMapAddress], a - ldh [hJoyDown], a - ldh [hSCX], a - ldh [hSCY], a - ld a, SCREEN_HEIGHT_PX - ldh [hWY], a - call WaitBGMap - ld b, SCGB_GAMEFREAK_LOGO - call GetSGBLayout - call SetPalettes - ld c, 10 - call DelayFrames - callfar Copyright - call WaitBGMap - ld c, 100 - call DelayFrames - call ClearTilemap - call .GetGFLogoGFX - -.loop - call GFPresents_PlayFrame - jr nc, .loop - - ; high bits of wJumptableIndex are recycled for some flags - ; this was set if user canceled by pressing a button - ld a, [wJumptableIndex] - bit 6, a - jr nz, .canceled - - ; clear carry flag from GFPresents_PlayFrame - and a - ret - -.canceled - scf - ret - -.GetGFLogoGFX: -; Load gfx and initialize variables - - ld de, GFPresentsGFX1 - ld hl, vTiles1 - lb bc, BANK(GFPresentsGFX1), 28 - call Get1bpp - - ld de, GFPresentsGFX2 - ld hl, vTiles1 tile 28 - lb bc, BANK(GFPresentsGFX2), 5 - call Request2bpp - - farcall ClearSpriteAnims - - ld hl, wSpriteAnimDict - ld a, 6 - ld [hli], a - ld a, $8d - ld [hl], a - xor a - ld [wJumptableIndex], a - ld [wIntroSceneFrameCounter], a - ld [wIntroSceneTimer], a - ldh [hSCX], a - ldh [hSCY], a - ld a, 1 - ldh [hBGMapMode], a - ld a, SCREEN_HEIGHT_PX - ldh [hWY], a - lb de, %00100100, %11111000 - call DmgToCgbObjPals - ret - -GFPresents_PlayFrame: -; Play one frame of GFPresents sequence. -; Return carry when the sequence completes or is canceled. - - call JoyTextDelay - ldh a, [hJoyLast] - and BUTTONS - jr nz, .pressed_button - - ; high bits of wJumptableIndex are recycled for some flags - ; this is set when the sequence finished - ld a, [wJumptableIndex] - bit 7, a - jr nz, .finish - - farcall PlaySpriteAnimations - - call GFPresents_HandleFrame - call DelayFrame - - ; ensure carry is cleared - and a - ret - -.pressed_button - ; high bits of wJumptableIndex are recycled for some flags - ld hl, wJumptableIndex - set 6, [hl] - -.finish - callfar ClearSpriteAnims - call ClearTilemap - call ClearSprites - - ld c, 16 - call DelayFrames - - scf - ret - -GFPresents_HandleFrame: -; Dispatch to the current scene handler - - ld a, [wJumptableIndex] - ld e, a - ld d, 0 - ld hl, .scenes - add hl, de - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a - jp hl - -.scenes - dw GFPresents_Star - dw GFPresents_PlaceLogo - dw GFPresents_LogoSparkles - dw GFPresents_PlacePresents - dw GFPresents_WaitForTimer - dw GFPresents_SetDoneFlag - -GFPresents_NextScene: - ld hl, wJumptableIndex - inc [hl] - ret - -; unused? -Functione4a8d: - ld c, 64 - call DelayFrames - call GFPresents_NextScene - ret - -GFPresents_Star: - - ; tell GFPresents_PlaceLogo we haven't finished yet - xor a - ld [wIntroSceneFrameCounter], a - - depixel 10, 11, 4, 0 - ld a, SPRITE_ANIM_INDEX_GS_INTRO_STAR - call InitSpriteAnimStruct - - ; TODO set some flag in the struct? - ld hl, $c - add hl, bc - ld [hl], $80 - - ld de, SFX_GAME_FREAK_LOGO_GS - call PlaySFX - - call GFPresents_NextScene - ret - -GFPresents_PlaceLogo: -; Draw the Game Freak logo (may be initially invisible due to palette) - - ; wait until the star animation completed - ; TODO this is cleared above, but when is it set? - ld a, [wIntroSceneFrameCounter] - and a - ret z - - depixel 10, 11, 4, 0 - ld a, SPRITE_ANIM_INDEX_GAMEFREAK_LOGO - call InitSpriteAnimStruct - - call GFPresents_NextScene - - ; set timer for GFPresents_LogoSparkles - ld a, $80 - ld [wIntroSceneTimer], a - ret - -GFPresents_LogoSparkles: - - ld hl, wIntroSceneTimer - ld a, [hl] - and a - jr z, .done - dec [hl] - - ; add first text when timer passes half - cp $3f - call z, GFPresents_PlaceGameFreak - - ; add sparkles continuously - call GFPresents_Sparkle - ret - -.done - ; set (unused?) timer for GFPresents_PlacePresents - ld [hl], $80 - call GFPresents_NextScene - ret - -GFPresents_PlaceGameFreak: - hlcoord 5, 12 - ld de, .game_freak - call PlaceString - ret - -.game_freak - db $80, $81, $82, $83, $8d, $84, $85, $83, $81, $86 -.end - db "@" - -GFPresents_PlacePresents: - hlcoord 7, 13 - ld de, .presents - call PlaceString - - call GFPresents_NextScene - - ; set timer for GFPresents_WaitForTimer - ld a, $80 - ld [wIntroSceneTimer], a - ret - -.presents - db $87, $88, $89, $8a, $8b, $8c -.end - db "@" - -GFPresents_SetDoneFlag: -; Tell GFPresents_PlayFrame and TitleScreenFrame that we're finished. - - ld hl, wJumptableIndex - set 7, [hl] - ret - -GFPresents_WaitForTimer: - ld hl, wIntroSceneTimer - ld a, [hl] - and a - jr z, .done - dec [hl] - ret -.done - call GFPresents_NextScene - ret - -GFPresents_UpdateLogoPal: -; called from 23:5928 -; OBP1 was initialized at end of GFPresents_Init - - ; once we reached the final state, leave it alone - ldh a, [rOBP1] - cp %10010000 - ret z - - ; wait 16 frames before next change - ld a, [wIntroSceneTimer] - and $f - ret nz - - ; rotate OBP1 by one color slot (2 bits) - ; DMG: logo is white, then light gray, then dark gray - ; CGB: logo is white, then yellow - ldh a, [rOBP1] - rrca - rrca - call DmgToCgbObjPal1 - ret - -GFPresents_Sparkle: -; Initialize and configure a sparkle sprite. -; TODO unclear how this relates to the actual screen display, -; seems to be called more times than there are visible sparkles? - - ; run only every second frame - ld d, a - and 1 - ret nz - - ; shift over so our index is still changing by 1 each time - ld a, d - srl a - - ; set up a new sparkle sprite - push af - depixel 11, 11 - ld a, SPRITE_ANIM_INDEX_GS_INTRO_SPARKLE - call InitSpriteAnimStruct - pop af - - ; take the bottom 4 bits of a as an index into - ; sparkle_vectors (16 entries) - and %00001111 - ld e, a - ld d, 0 - ld hl, .sparkle_vectors - add hl, de - add hl, de - - ; set the angle and distance for this sprite - ; bc+$b <- hl (angle), bc+$c <- 0, bc+$d <- hl+1 (distance) - ld e, l - ld d, h - ld hl, $b - add hl, bc - ld a, [de] - ld [hl], a - inc de - ld hl, $c - add hl, bc - ld [hl], 0 - inc hl - ld a, [de] - ld [hl], a - - ret - -.sparkle_vectors - ; values control final position of each sparkle - ; position is automatically animated along the vector - ; each entry emits two sparkles in opposite directions - ; angle (6 bits) and distance (tiles?) - db $00, $03 - db $08, $04 - db $04, $03 - db $0c, $02 - db $10, $02 - db $18, $03 - db $14, $04 - db $1c, $03 - db $20, $02 - db $28, $02 - db $24, $03 - db $2c, $04 - db $30, $04 - db $38, $03 - db $34, $02 - db $3c, $04 - -GFPresentsGFX1: -INCBIN "gfx/intro/gamefreak_presents.1bpp" -INCBIN "gfx/intro/gamefreak_logo.1bpp" - -GFPresentsGFX2: -INCBIN "gfx/intro/logo_star.2bpp" -INCBIN "gfx/intro/logo_sparkle.2bpp" diff --git a/engine/movie/gold_silver_intro.asm b/engine/movie/gold_silver_intro.asm new file mode 100644 index 00000000..7195e7dc --- /dev/null +++ b/engine/movie/gold_silver_intro.asm @@ -0,0 +1,1604 @@ +Copyright_GFPresents: +; Play the copyright screen and GameFreak Presents sequence. +; Return carry if user cancels animation by pressing a button. + + call ClearBGPalettes + call ClearTilemap + ld a, HIGH(vBGMap0) + ldh [hBGMapAddress + 1], a + xor a ; LOW(vBGMap0) + ldh [hBGMapAddress], a + ldh [hJoyDown], a + ldh [hSCX], a + ldh [hSCY], a + ld a, SCREEN_HEIGHT_PX + ldh [hWY], a + call WaitBGMap + ld b, SCGB_GAMEFREAK_LOGO + call GetSGBLayout + call SetPalettes + ld c, 10 + call DelayFrames + callfar Copyright + call WaitBGMap + ld c, 100 + call DelayFrames + call ClearTilemap + call .GetGFLogoGFX + +.loop + call .PlayFrame + jr nc, .loop + +; high bits of wJumptableIndex are recycled for some flags +; this was set if user canceled by pressing a button + ld a, [wJumptableIndex] + bit 6, a + jr nz, .canceled + +; clear carry flag from GFPresents_PlayFrame + and a + ret + +.canceled + scf + ret + +.GetGFLogoGFX: +; Load gfx and initialize variables + + ld de, GFPresentsGFX1 + ld hl, vTiles1 + lb bc, BANK(GFPresentsGFX1), 28 + call Get1bpp + + ld de, GFPresentsGFX2 + ld hl, vTiles1 tile 28 + lb bc, BANK(GFPresentsGFX2), 5 + call Request2bpp + + farcall ClearSpriteAnims + + ld hl, wSpriteAnimDict + ld a, 6 + ld [hli], a + ld a, $8d + ld [hl], a + xor a + ld [wJumptableIndex], a + ld [wIntroSceneFrameCounter], a + ld [wIntroSceneTimer], a + ldh [hSCX], a + ldh [hSCY], a + ld a, 1 + ldh [hBGMapMode], a + ld a, SCREEN_HEIGHT_PX + ldh [hWY], a + lb de, %00100100, %11111000 + call DmgToCgbObjPals + ret + +.PlayFrame: +; Play one frame of GFPresents sequence. +; Return carry when the sequence completes or is canceled. + + call JoyTextDelay + ldh a, [hJoyLast] + and BUTTONS + jr nz, .pressed_button + +; high bits of wJumptableIndex are recycled for some flags +; this is set when the sequence finished + ld a, [wJumptableIndex] + bit 7, a + jr nz, .finish + + farcall PlaySpriteAnimations + + call GFPresentsJumper + call DelayFrame + +; ensure carry is cleared + and a + ret + +.pressed_button +; high bits of wJumptableIndex are recycled for some flags + ld hl, wJumptableIndex + set 6, [hl] + +.finish + callfar ClearSpriteAnims + call ClearTilemap + call ClearSprites + + ld c, 16 + call DelayFrames + + scf + ret + +GFPresentsJumper: + jumptable .scenes, wJumptableIndex + +.scenes + dw GFPresents_Star + dw GFPresents_PlaceLogo + dw GFPresents_LogoSparkles + dw GFPresents_PlacePresents + dw GFPresents_WaitForTimer + dw GFPresents_SetDoneFlag + +GFPresents_NextScene: + ld hl, wJumptableIndex + inc [hl] + ret + +Unreferenced_Functione4a8d: + ld c, 64 + call DelayFrames + call GFPresents_NextScene + ret + +GFPresents_Star: +; tell GFPresents_PlaceLogo we haven't finished yet + xor a + ld [wIntroSceneFrameCounter], a + + depixel 10, 11, 4, 0 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_STAR + call InitSpriteAnimStruct + + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld [hl], $80 + + ld de, SFX_GAME_FREAK_LOGO_GS + call PlaySFX + + call GFPresents_NextScene + ret + +GFPresents_PlaceLogo: +; Draw the Game Freak logo (may be initially invisible due to palette) + +; wait until the star animation completed +; this counter is set in DoAnimFrame.GSIntroStar in engine/gfx/sprite_anims.asm + ld a, [wIntroSceneFrameCounter] + and a + ret z + + depixel 10, 11, 4, 0 + ld a, SPRITE_ANIM_INDEX_GAMEFREAK_LOGO + call InitSpriteAnimStruct + + call GFPresents_NextScene + +; set timer for GFPresents_LogoSparkles + ld a, $80 + ld [wIntroSceneTimer], a + ret + +GFPresents_LogoSparkles: + ld hl, wIntroSceneTimer + ld a, [hl] + and a + jr z, .done + dec [hl] + +; add first text when timer passes half + cp $3f + call z, GFPresents_PlaceGameFreak + +; add sparkles continuously + call GFPresents_Sparkle + ret + +.done +; set timer for GFPresents_PlacePresents + ld [hl], $80 + call GFPresents_NextScene + ret + +GFPresents_PlaceGameFreak: + hlcoord 5, 12 + ld de, .game_freak + call PlaceString + ret + +.game_freak + db $80, $81, $82, $83, $8d, $84, $85, $83, $81, $86 + db "@" + +GFPresents_PlacePresents: + hlcoord 7, 13 + ld de, .presents + call PlaceString + + call GFPresents_NextScene + +; set timer for GFPresents_WaitForTimer + ld a, $80 + ld [wIntroSceneTimer], a + ret + +.presents + db $87, $88, $89, $8a, $8b, $8c + db "@" + +GFPresents_SetDoneFlag: +; Tell GFPresents_PlayFrame and TitleScreenFrame that we're finished. + + ld hl, wJumptableIndex + set 7, [hl] + ret + +GFPresents_WaitForTimer: + ld hl, wIntroSceneTimer + ld a, [hl] + and a + jr z, .done + dec [hl] + ret +.done + call GFPresents_NextScene + ret + +GFPresents_UpdateLogoPal: +; called from DoAnimFrame.GameFreakLogo +; OBP1 was initialized at end of GFPresents_Init + +; once we reached the final state, leave it alone + ldh a, [rOBP1] + cp %10010000 + ret z + +; wait 16 frames before next change + ld a, [wIntroSceneTimer] + and $f + ret nz + +; rotate OBP1 by one color slot (2 bits) +; DMG: logo is white, then light gray, then dark gray +; CGB: logo is white, then yellow + ldh a, [rOBP1] + rrca + rrca + call DmgToCgbObjPal1 + ret + +GFPresents_Sparkle: +; Initialize and configure a sparkle sprite. + +; run only every second frame + ld d, a + and 1 + ret nz + +; shift over so our index is still changing by 1 each time + ld a, d + srl a + +; set up a new sparkle sprite + push af + depixel 11, 11 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_SPARKLE + call InitSpriteAnimStruct + pop af + +; take the bottom 4 bits of a as an index into +; sparkle_vectors (16 entries) + and %00001111 + ld e, a + ld d, 0 + ld hl, .sparkle_vectors + add hl, de + add hl, de + +; set the angle and distance for this sprite + ld e, l + ld d, h + ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX + add hl, bc + ld a, [de] + ld [hl], a ; angle + inc de + ld hl, SPRITEANIMSTRUCT_0C + add hl, bc + ld [hl], 0 + inc hl ; SPRITEANIMSTRUCT_0D + ld a, [de] + ld [hl], a ; distance + ret + +.sparkle_vectors +; values control final position of each sparkle +; position is automatically animated along the vector +; each entry emits two sparkles in opposite directions +; angle (6 bits) and distance (tiles?) + db $00, $03 + db $08, $04 + db $04, $03 + db $0c, $02 + db $10, $02 + db $18, $03 + db $14, $04 + db $1c, $03 + db $20, $02 + db $28, $02 + db $24, $03 + db $2c, $04 + db $30, $04 + db $38, $03 + db $34, $02 + db $3c, $04 + +GFPresentsGFX1: +INCBIN "gfx/intro/gamefreak_presents.1bpp" +INCBIN "gfx/intro/gamefreak_logo.1bpp" + +GFPresentsGFX2: +INCBIN "gfx/intro/logo_star.2bpp" +INCBIN "gfx/intro/logo_sparkle.2bpp" + + +GoldSilverIntro: + call .Init +.Loop: + call .PlayFrame + jr nc, .Loop + ret + +.Init: + farcall ClearSpriteAnims + xor a + ld [wIntroJumptableIndex], a + ldh [hBGMapMode], a + ret + +.PlayFrame: + call JoyTextDelay + ldh a, [hJoyLast] + and BUTTONS + jr nz, .Finish + +; check done flag + ld a, [wIntroJumptableIndex] + bit 7, a + jr nz, .Finish + + farcall PlaySpriteAnimations + call IntroSceneJumper + call DelayFrame + and a + ret + +.Finish: + callfar ClearSpriteAnims + call ClearSprites + call DelayFrame + xor a + ldh [hSCX], a + ldh [hSCY], a + ldh [hLCDCPointer], a + ldh [hLYOverrideStart], a + ldh [hLYOverrideEnd], a + ld a, %11100100 + call DmgToCgbBGPals + depixel 28, 28, 4, 4 + call DmgToCgbObjPals + scf + ret + +IntroSceneJumper: + jumptable .scenes, wIntroJumptableIndex + +.scenes + dw IntroScene1 + dw IntroScene2 + dw IntroScene3 + dw IntroScene4 + dw IntroScene5 + dw IntroScene6 + dw IntroScene7 + dw IntroScene8 + dw IntroScene9 + dw IntroScene10 + dw IntroScene11 + dw IntroScene12 + dw IntroScene13 + dw IntroScene14 + dw IntroScene15 + dw IntroScene16 + dw IntroScene17 + +IntroScene1: +; Set up water cutscene (Shellders/Magikarp/Lapras) + call ClearBGPalettes + call ClearTilemap + ld hl, wIntroJumptableIndex + inc [hl] ; only run once + call DisableLCD + + xor a + ldh [hBGMapMode], a + callfar ClearSpriteAnims + ld a, 1 + ldh [rVBK], a + hlbgcoord 0, 0, vBGMap2 + lb bc, 4, 0 + + xor a + call ByteFill + ld a, 0 + ldh [rVBK], a + call Intro_ResetLYOverrides + ld de, vTiles2 tile $00 + ld hl, Intro_WaterGFX1 + call Decompress + ld a, LOW(Intro_WaterMeta) + ld [wIntroTilesPointer + 0], a + ld a, HIGH(Intro_WaterMeta) + ld [wIntroTilesPointer + 1], a + hlbgcoord 0, 0, vBGMap2 + ld a, l + ld [wIntroBGMapPointer + 0], a + ld a, h + ld [wIntroBGMapPointer + 1], a + ld de, Intro_WaterTilemap + 15 tiles + ld a, e + ld [wIntroTilemapPointer + 0], a + ld a, d + ld [wIntroTilemapPointer + 1], a + call Intro_DrawBackground + + ld de, vTiles0 tile $00 + ld hl, Intro_WaterGFX2 + call Decompress + ld hl, wSpriteAnimDict + ld a, 0 + ld [hli], a + ld a, 0 + ld [hli], a + xor a + ldh [hSCY], a + ld [wGlobalAnimYOffset], a + ld [wGlobalAnimXOffset], a + ld a, $58 + ldh [hSCX], a + xor a + ld [wIntroFrameCounter2], a + ld a, $80 + ld [wIntroFrameCounter1], a + ld a, $42 + ldh [hLCDCPointer], a + call Functione5095 + + xor a + ld [wcb19], a + call EnableLCD + call DelayFrame + ld b, SCGB_GS_INTRO + ld c, 0 + call GetSGBLayout + ld a, %11100100 + call DmgToCgbBGPals + depixel 28, 28 + call DmgToCgbObjPals + call Intro_InitShellders + ld de, MUSIC_GS_OPENING + call PlayMusic + ret + +IntroScene2: +; shellders underwater + call Functione50af + ld hl, wIntroFrameCounter1 + ld a, [hl] + and a + jr z, .skip_intro + dec [hl] + call Intro_InitBubble + ret + +.skip_intro + ld [hl], $10 + ld hl, wIntroJumptableIndex + inc [hl] + +IntroScene3: +; rise towards the surface + call Functione4e90 + call Functione4e67 + ret nc +; next scene if carry flag is set + call Intro_ResetLYOverrides + ld hl, hSCY + inc [hl] + ld hl, wIntroJumptableIndex + inc [hl] + +IntroScene4: +; at surface; Lapras surfs to left of screen + ld a, [wcb19] + and a + jr nz, .next + ld hl, wIntroFrameCounter2 + inc [hl] + ld a, [hl] + and $f + jr nz, .asm_e4e21 + ld hl, hSCX + dec [hl] + dec [hl] + +.asm_e4e21 + call Functione4fde + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + xor a + ld [wIntroFrameCounter1], a + +IntroScene5: +; fade out + ld hl, wIntroFrameCounter1 + ld a, [hl] + inc [hl] + swap a + and $f + ld e, a + ld d, 0 + ld hl, .palettes + add hl, de + ld a, [hl] + cp -1 + jr z, .next + call DmgToCgbBGPals + call Functione4fde + ld hl, hSCX + dec [hl] + dec [hl] + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + ret + +.palettes + db %11100100, %11100100, %10010000, %01000000, %00000000 + db -1 + +IntroScene17: +; delay a bit before leading into the title screen + ld c, 64 +.loop + call DelayFrame + dec c + jr nz, .loop +; set done flag + ld hl, wIntroJumptableIndex + set 7, [hl] + ret + +Functione4e67: + ld hl, wIntroFrameCounter2 + inc [hl] + ld a, [hl] + and 3 + jr nz, .asm_e4e74 + ld hl, hSCX + dec [hl] + +.asm_e4e74 + and 1 + jr nz, .asm_e4e8c + ld hl, wGlobalAnimYOffset + inc [hl] + ld hl, hSCY + ld a, [hl] + dec [hl] + and $f + call z, Intro_UpdateTilemapAndBGMap + ld a, [wIntroFrameCounter1] + and a + jr z, .asm_e4e8e + +.asm_e4e8c + and a + ret + +.asm_e4e8e + scf + ret + +Functione4e90: + jumptable .dw, wIntroFrameCounter1 + +.dw + dw Functione4eca + dw Functione4eca + dw Functione4eca + dw Functione4ec1 + dw Functione4eca + dw Functione4eca + dw Functione4ece + dw Functione4ece + dw Functione4ece + dw Functione4ed5 + dw Functione4ee8 + dw Functione4eec + dw Functione4eec + dw Functione4eec + dw Functione4eec + dw Functione4eec + dw Functione4eec + +Functione4ec1: + call Intro_InitLapras + depixel 28, 28, 4, 4 + call DmgToCgbObjPals +; fall through + +Functione4eca: + call Functione4fde + ret + +Functione4ece: + call Intro_InitMagikarps + call Functione4fde + ret + +Functione4ed5: + ld hl, wIntroFrameCounter2 + ld a, [hl] + and %00011111 + jr z, .asm_e4ee1 + call Intro_InitMagikarps + ret + +.asm_e4ee1 + callfar Function9102 + ret + +Functione4ee8: + xor a + ldh [hLCDCPointer], a + ret + +Functione4eec: + call Functione50af + ret + +Intro_InitBubble: + ld hl, wIntroFrameCounter1 + ld a, [hl] + and $f + ret nz + ld a, [hl] + and $70 + swap a + ld e, a + ld d, 0 + ld hl, .pixel_table + add hl, de + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld a, SPRITE_ANIM_INDEX_GS_INTRO_BUBBLE + call InitSpriteAnimStruct + ret + +.pixel_table + db 6 * 8, 14 * 8 + 4 + db 14 * 8, 18 * 8 + 4 + db 10 * 8, 16 * 8 + 4 + db 12 * 8, 15 * 8 + db 4 * 8, 13 * 8 + db 8 * 8, 17 * 8 + +Intro_InitMagikarps: + depixel 8, 7, 0, 7 + ldh a, [hSGB] + and a + jr z, .ok + depixel 4, 3, 0, 7 + +.ok + ld hl, wIntroFrameCounter2 + ld a, [hl] + and e + ret nz + ld a, [hl] + and d + jr nz, .asm_e4f41 + depixel 29, 28 + call .InitAnim + depixel 26, 0 + call .InitAnim + depixel 0, 24 + call .InitAnim + ret + +.asm_e4f41 + depixel 28, 30 + call .InitAnim + depixel 31, 24 + call .InitAnim + depixel 2, 28 + call .InitAnim + ret + +.InitAnim: + ld a, SPRITE_ANIM_INDEX_GS_INTRO_MAGIKARP + call InitSpriteAnimStruct + ret + +Intro_InitShellders: + depixel 18, 7 + call .InitAnim + depixel 14, 10 + call .InitAnim + depixel 16, 15 + +.InitAnim: + ld a, SPRITE_ANIM_INDEX_GS_INTRO_SHELLDER + call InitSpriteAnimStruct + ret + +Intro_InitLapras: + ld a, [wIntroFrameCounter2] + and %00011111 + ret nz + depixel 16, 24 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_LAPRAS + call InitSpriteAnimStruct + ret + +Intro_UnusedInitLapras: + depixel 2, 0 + ld a, SPRITE_ANIM_INDEX_UNUSED_LAPRAS + call InitSpriteAnimStruct + ret + +Intro_UpdateTilemapAndBGMap: +; add new tiles to top as water scene scrolls up to surface + push hl + push de + + ld a, [wIntroTilemapPointer + 0] + ld e, a + ld a, [wIntroTilemapPointer + 1] + ld d, a + ld hl, -$10 + add hl, de + ld a, l + ld e, l + ld [wIntroTilemapPointer + 0], a + ld a, h + ld d, h + ld [wIntroTilemapPointer + 1], a + hlcoord 0, 0 + ld c, BG_MAP_WIDTH / 2 + +.loop + call Functione54ae + dec c + jr nz, .loop + + ld a, [wIntroBGMapPointer + 0] + ld e, a + ld a, [wIntroBGMapPointer + 1] + ld d, a + ld hl, hCurSpriteYCoord + add hl, de + ld a, l + ld [wIntroBGMapPointer + 0], a + ld [wRequested2bppDest + 0], a + ld a, h + and %11111011 + or %00001000 + ld [wIntroBGMapPointer + 1], a + ld [wRequested2bppDest + 1], a + ld a, LOW(wTilemap) + ld [wRequested2bppSource + 0], a + ld a, HIGH(wTilemap) + ld [wRequested2bppSource + 1], a + ld a, 4 + ld [wRequested2bppSize], a + ld hl, wIntroFrameCounter1 + dec [hl] + + pop de + pop hl + ret + +Functione4fde: +; something to do with water scene sprite anims? + ld hl, wIntroFrameCounter2 + ld a, [hl] + and 3 + cp 3 + ret z + ld a, [wRequested2bppSize] + and a + ret nz + ld a, [hl] + and $30 + swap a + ld l, a + ld h, 0 +rept 5 + add hl, hl +endr + ld de, .data_e5015 + add hl, de + ld a, l + ld [wRequested2bppSource + 0], a + ld a, h + ld [wRequested2bppSource + 1], a + ld a, LOW(vBGMap0 tile $1e) + ld [wRequested2bppDest + 0], a + ld a, HIGH(vBGMap0 tile $1e) + ld [wRequested2bppDest + 1], a + ld a, 2 + ld [wRequested2bppSize], a + ret + +.data_e5015 +rept 8 + db $70, $71, $72, $73 +endr +rept 8 + db $74, $75, $76, $77 +endr +rept 8 + db $78, $79, $7a, $7b +endr +rept 8 + db $7c, $7d, $7e, $7f +endr + +Functione5095: + ld bc, wLYOverrides2 + ld a, wLYOverrides2End - wLYOverrides2 + ld de, vBGMap1 - vBGMap0 + +.loop + push af + push de + farcall BattleAnim_Sine_e + ld a, e + ld [bc], a + inc bc + pop de + inc e + pop af + dec a + jr nz, .loop + ret + +Functione50af: + ld bc, wLYOverrides + ld e, $10 + +.loop1 + ldh a, [hSCY] + ld [bc], a + inc bc + dec e + jr nz, .loop1 + + ld hl, wLYOverrides2 + ld de, wLYOverrides2 + 1 + ld a, [hl] + push af + ld a, $80 + +.loop2 + push af + ld a, [de] + inc de + ld [hli], a + push hl + ld hl, hSCY + add [hl] + ld [bc], a + inc bc + pop hl + pop af + dec a + jr nz, .loop2 + + pop af + ld [hl], a + ret + +IntroScene6: +; Set up grass cutscene (Pikachu/Jigglypuff) + ld hl, wIntroJumptableIndex + inc [hl] ; only run once + call DisableLCD + callfar ClearSpriteAnims + call Intro_ResetLYOverrides + + ld de, vTiles2 + ld hl, Intro_GrassGFX1 + call Decompress + ld a, LOW(Intro_GrassMeta) + ld [wIntroTilesPointer + 0], a + ld a, HIGH(Intro_GrassMeta) + ld [wIntroTilesPointer + 1], a + hlbgcoord 0, 0 + ld a, l + ld [wIntroBGMapPointer + 0], a + ld a, h + ld [wIntroBGMapPointer + 1], a + ld de, Intro_GrassTilemap + ld a, e + ld [wIntroTilemapPointer + 0], a + ld a, d + ld [wIntroTilemapPointer + 1], a + call Intro_DrawBackground + + ld de, vTiles0 + ld hl, Intro_GrassGFX2 + call Decompress + ld hl, wSpriteAnimDict + ld a, 1 + ld [hli], a + ld a, 0 + ld [hli], a + xor a + ldh [hSCY], a + ld [wGlobalAnimYOffset], a + ld a, $60 + ldh [hSCX], a + ld a, $a0 + ld [wGlobalAnimXOffset], a + + xor a + ld [wIntroFrameCounter2], a + call EnableLCD + ld b, SCGB_GS_INTRO + ld c, 1 + call GetSGBLayout + ld a, %11100100 + call DmgToCgbBGPals + depixel 28, 28, 4, 4 + call DmgToCgbObjPals + call Intro_InitJigglypuff + xor a + ld [wcb19], a + ret + +IntroScene7: +; scroll left to Jigglypuff + call Intro_InitNote + ld hl, wIntroFrameCounter2 + ld a, [hl] + inc [hl] + and 3 + ret z + ld hl, hSCX + ld a, [hl] + and a + jr z, .next + dec [hl] + ld hl, wGlobalAnimXOffset + inc [hl] + ret + +.next + ld a, -1 + ld [wIntroFrameCounter1], a + call Intro_InitPikachu + ld hl, wIntroJumptableIndex + inc [hl] + ret + +IntroScene8: +; stop scrolling, Pikachu attacks + ld hl, wIntroFrameCounter1 + ld a, [hl] + and a + jr z, .next + dec [hl] + call Intro_InitNote + ld hl, wIntroFrameCounter2 + inc [hl] + ret + +.next + xor a + ld [wIntroFrameCounter1], a + ld hl, wIntroJumptableIndex + inc [hl] + callfar Function9136 + ret + +IntroScene9: +; scroll down and fade out + ld hl, wIntroFrameCounter1 + ld a, [hl] + inc [hl] + srl a + srl a + srl a + ld e, a + ld d, 0 + ld hl, .palettes + add hl, de + ld a, [hl] + cp -1 + jr z, .next + call DmgToCgbBGPals + ld hl, hSCY + inc [hl] + ld hl, wGlobalAnimYOffset + dec [hl] + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + ret + +.palettes + db %11100100, %11100100, %11100100, %11100100 + db %11100100, %10010000, %01000000, %00000000 + db -1 + + ret ; unused + +Intro_InitNote: + ld a, [wcb19] + and a + ret nz + ld hl, wIntroFrameCounter2 + ld a, [hl] + and %00111111 + ret nz + ld a, [hl] + and %01111111 + jr z, .invisible + depixel 11, 6, 4, 0 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_NOTE + call InitSpriteAnimStruct + ret + +.invisible + depixel 10, 6, 4, 0 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_INVISIBLE_NOTE + call InitSpriteAnimStruct + ret + +Intro_InitJigglypuff: + depixel 14, 6 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_JIGGLYPUFF + call InitSpriteAnimStruct + ret + +Intro_InitPikachu: + depixel 14, 24 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_PIKACHU + call InitSpriteAnimStruct + depixel 14, 24 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_PIKACHU_TAIL + call InitSpriteAnimStruct + ret + +IntroScene10: +; Set up fireball cutscene (Charizard, Johto starters) + ld hl, wIntroJumptableIndex + inc [hl] ; only run once + call DisableLCD + callfar ClearSpriteAnims + call Intro_ResetLYOverrides + call Intro_BlankTilemapAndBGMap + + ld de, vTiles2 + ld hl, Intro_FireGFX1 + call Decompress + ld de, vTiles1 + ld hl, Intro_FireGFX2 + call Decompress + ld de, vTiles0 + ld hl, Intro_FireGFX3 + ld bc, vTiles1 - vTiles0 + call Decompress + + ld c, CHIKORITA + ld de, vTiles0 tile $10 + farcall Intro_GetMonFrontpic + ld c, CYNDAQUIL + ld de, vTiles0 tile $29 + farcall Intro_GetMonFrontpic + ld c, TOTODILE + ld de, vTiles0 tile $42 + farcall Intro_GetMonFrontpic + + ld hl, wSpriteAnimDict + ld a, 1 + ld [hli], a + ld a, 0 + ld [hli], a + call EnableLCD + ld a, 0 + call Functione5422 + + ld a, $80 + ldh [hSCY], a + xor a + ldh [hSCX], a + ld [wGlobalAnimYOffset], a + ld [wGlobalAnimXOffset], a + + xor a + ld [wIntroFrameCounter2], a + ld b, SCGB_GS_INTRO + ld c, 2 + call GetSGBLayout + ld a, %00111111 + call DmgToCgbBGPals + lb de, %11111111, %11111111 + call DmgToCgbObjPals + ld de, MUSIC_NONE + call PlayMusic + call DelayFrame + ld de, MUSIC_GS_OPENING_2 + call PlayMusic + ret + +IntroScene11: +; scroll up to Charizard silhoutte, flash Johto starters + ld hl, wIntroFrameCounter2 + ld a, [hl] + inc [hl] + and 1 + ret z + call Intro_CheckSCYEvent + ld hl, hSCY + ld a, [hl] + and a + jr z, .next + inc [hl] + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + xor a + ld [wIntroFrameCounter1], a +; fall through + +IntroScene12: +; load Charizard palettes + ld hl, wIntroFrameCounter1 + ld a, [hl] + inc [hl] + srl a + srl a + and 3 + ld e, a + ld d, 0 + ld hl, .palettes + add hl, de + ld a, [hl] + and a + jr z, .next + call DmgToCgbBGPals + ld e, a + ld d, a + call DmgToCgbObjPals + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + ld a, $80 + ld [wIntroFrameCounter1], a + ret + +.palettes + db %01101010, %10100101, %11100100, %00000000 + +IntroScene13: +; Charizard mouth closed + ld hl, wIntroFrameCounter1 + ld a, [hl] + and a + jr z, .next + dec [hl] + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + ld a, 1 + call Functione5422 + ld a, 4 + ld [wIntroFrameCounter1], a + ret + +IntroScene14: +; Charizard mouth open + ld hl, wIntroFrameCounter1 + ld a, [hl] + and a + jr z, .next + dec [hl] + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + ld a, 2 + call Functione5422 + ld a, 64 + ld [wIntroFrameCounter1], a + xor a + ld [wIntroFrameCounter2], a + ld de, SFX_GS_INTRO_CHARIZARD_FIREBALL + call PlaySFX +; fall through + +IntroScene15: +; Charizard mouth wide open / fireball starts + call Functione5473 + ld hl, wIntroFrameCounter1 + ld a, [hl] + and a + jr z, .next + dec [hl] + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + xor a + ld [wIntroFrameCounter1], a + ret + +IntroScene16: +; continue fireball / fade out palettes + call Functione5473 + ld hl, wIntroFrameCounter1 + ld a, [hl] + inc [hl] + swap a + and 7 + ld e, a + ld d, 0 + ld hl, .palettes + add hl, de + ld a, [hl] + cp -1 + jr z, .next + call DmgToCgbBGPals + ld e, a + ld d, a + call DmgToCgbObjPals + ret + +.next + ld hl, wIntroJumptableIndex + inc [hl] + ret + +.palettes + db %11100100, %10010000, %01000000, %00000000 + db -1 + +Intro_BlankTilemapAndBGMap: + hlcoord 0, 0 + ld bc, wTilemapEnd - wTilemap + xor a + call ByteFill + hlbgcoord 0, 0 + ld bc, vBGMap1 - vBGMap0 + xor a + call ByteFill + ret + +Intro_CheckSCYEvent: + ldh a, [hSCY] + ld c, a + ld hl, .scy_jumptable + +.loop + ld a, [hli] + cp -1 + ret z + cp c + jr z, .value_found + inc hl + inc hl + jr .loop + +.value_found + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +.scy_jumptable + dbw $86, Intro_LoadChikoritaPalette + dbw $87, Intro_ChikoritaAppears + dbw $88, Functione53e0 + dbw $98, Functione53eb + dbw $99, Intro_LoadCyndaquilPalette + dbw $af, Intro_CyndaquilAppears + dbw $b0, Functione53e0 + dbw $c0, Functione53eb + dbw $c1, Intro_LoadTotodilePalette + dbw $d7, Intro_TotodileAppears + dbw $d8, Functione53e0 + dbw $e8, Functione53eb + dbw $e9, Functione5412 + db -1 + +Intro_ChikoritaAppears: + ld de, SFX_GS_INTRO_POKEMON_APPEARS + call PlaySFX + depixel 22, 1 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_CHIKORITA + call InitSpriteAnimStruct + ret + +Intro_CyndaquilAppears: + ld de, SFX_GS_INTRO_POKEMON_APPEARS + call PlaySFX + depixel 22, 20 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_CYNDAQUIL + call InitSpriteAnimStruct + ret + +Intro_TotodileAppears: + ld de, SFX_GS_INTRO_POKEMON_APPEARS + call PlaySFX + depixel 22, 1 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_TOTODILE + call InitSpriteAnimStruct + ret + +Functione53e0: + depixel 28, 28, 4, 4 + call DmgToCgbObjPals + xor a + call DmgToCgbBGPals + ret + +Functione53eb: + depixel 31, 31, 7, 7 + call DmgToCgbObjPals + ld a, %00111111 + call DmgToCgbBGPals + ret + +Intro_LoadChikoritaPalette: + ld c, CHIKORITA + farcall Intro_LoadMonPalette + ret + +Intro_LoadCyndaquilPalette: + ld c, CYNDAQUIL + farcall Intro_LoadMonPalette + ret + +Intro_LoadTotodilePalette: + ld c, TOTODILE + farcall Intro_LoadMonPalette + ret + +Functione5412: + ldh a, [hCGB] + and a + ld c, CYNDAQUIL + jr nz, .got_mon + ld c, CHARIZARD +.got_mon + farcall Intro_LoadMonPalette + ret + +Functione5422: + push af + hlcoord 0, 6 + ld c, $a0 + xor a +.loop1 + ld [hli], a + dec c + jr nz, .loop1 + + pop af + ld e, a + ld d, 0 + ld hl, .data_e5464 +rept 5 + add hl, de +endr + ld e, [hl] + inc hl + ld c, [hl] + inc hl + ld b, [hl] + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + ld a, e + +.loop2_outer + push bc + push hl +.loop2_inner + ld [hli], a + inc a + dec c + jr nz, .loop2_inner + + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .loop2_outer + + ld a, 1 + ldh [hBGMapMode], a + call DelayFrame + call DelayFrame + call DelayFrame + xor a + ldh [hBGMapMode], a + ret + +.data_e5464 +; vtile offset, width, height, x, y + db $00, 8, 8 + dwcoord 10, 6 + db $40, 9, 8 + dwcoord 9, 6 + db $88, 9, 8 + dwcoord 8, 6 + +Functione5473: + ld hl, wIntroFrameCounter2 + ld a, [hl] + inc [hl] + and 3 + ret nz + depixel 12, 10, 4, 4 + ld a, SPRITE_ANIM_INDEX_GS_INTRO_FIREBALL + call InitSpriteAnimStruct + ld hl, hSCX + dec [hl] + ld hl, wGlobalAnimXOffset + inc [hl] + ret + +Unreferenced_Functione548c: + ld bc, vTiles1 - vTiles0 +.loop + ld a, [de] + inc de + ld [hli], a + dec bc + ld a, c + or b + jr nz, .loop + ret + +Intro_DrawBackground: + ld b, BG_MAP_WIDTH / 2 + +.outer_loop + push hl + ld c, BG_MAP_HEIGHT / 2 +.inner_loop + call Functione54ae + dec c + jr nz, .inner_loop + + pop hl + push bc + ld bc, 2 * BG_MAP_WIDTH + add hl, bc + pop bc + dec b + jr nz, .outer_loop + + ret + +Functione54ae: +; load tile data into a 2x2 section of the bgmap or tilemap + push bc + push de + push hl + push hl + push hl + + ld a, [de] + ld l, a + ld h, 0 + ld a, [wIntroTilesPointer + 0] + ld e, a + ld a, [wIntroTilesPointer + 1] + ld d, a + add hl, hl + add hl, hl + add hl, de + ld e, l + ld d, h + pop hl + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + pop hl + ld bc, BG_MAP_WIDTH + add hl, bc + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + + pop hl + inc hl + inc hl + pop de + inc de + pop bc + ret + +Intro_ResetLYOverrides: + ld hl, wLYOverrides + xor a + ld c, wLYOverrides2 - wLYOverrides +.loop + ld [hli], a + dec c + jr nz, .loop + ret + +Intro_WaterGFX1: +INCBIN "gfx/intro/water1.2bpp.lz" + +Intro_WaterTilemap: +INCBIN "gfx/intro/water.tilemap" + +Intro_WaterMeta: +INCBIN "gfx/intro/water.bin" + +Intro_WaterGFX2: +INCBIN "gfx/intro/water2.2bpp.lz" + +Intro_GrassGFX1: +INCBIN "gfx/intro/grass1.2bpp.lz" + +Intro_GrassTilemap: +INCBIN "gfx/intro/grass.tilemap" + +Intro_GrassMeta: +INCBIN "gfx/intro/grass.bin" + +Intro_GrassGFX2: +INCBIN "gfx/intro/grass2.2bpp.lz" + +Intro_FireGFX1: +INCBIN "gfx/intro/charizard1.2bpp.lz" + +Intro_FireGFX2: +INCBIN "gfx/intro/charizard2.2bpp.lz" + +Intro_FireGFX3: +INCBIN "gfx/intro/charizard3.2bpp.lz" diff --git a/engine/movie/title.asm b/engine/movie/title.asm index 0ba2720a..e3d93b3d 100644 --- a/engine/movie/title.asm +++ b/engine/movie/title.asm @@ -40,7 +40,10 @@ TitleScreen: ld a, BANK(TitleScreenGFX4) call FarDecompress -; Decompress Ho-Oh/Lugia sparkle +; Ho-Oh/Lugia title trail. +; This should only copy 4 tiles; there are 4 extra whitespace tiles in Gold +; before Ho-Oh gfx, but Silver reads the first 64 bytes of the compressed +; Lugia gfx and writes them to VRAM (but never displays them on screen). ld hl, TitleScreenGFX3 ld de, vTiles1 tile $78 ld bc, 8 tiles @@ -147,7 +150,7 @@ FillTitleScreenPals: ld bc, 18 * BG_MAP_WIDTH xor a call ByteFill - ld hl, vBGMap2 + hlbgcoord 0, 0, vBGMap2 lb bc, 7, SCREEN_WIDTH ld a, 1 call DrawTitleGraphic |