diff options
author | entrpntr <12521136+entrpntr@users.noreply.github.com> | 2020-06-12 10:04:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 10:04:31 -0400 |
commit | f8a6b98eedbcdf3aa89209897c80452037355754 (patch) | |
tree | 4e89b30f492cff405d8fcea0886faadff94d1804 | |
parent | f2e472b14173521b0f73fa917e5fb75a54a000dd (diff) | |
parent | 0c0f9b42bc1426f2dcdff9f9016bb3fa946b4d49 (diff) |
Merge pull request #48 from entrpntr/bank39
Disassemble bank $39, kill the baserom dependency
48 files changed, 2424 insertions, 522 deletions
@@ -66,6 +66,7 @@ gfx/pokedex/question_mark.2bpp gfx/tilesets/*.2bpp gfx/battle_anims/*.2bpp gfx/title/*.2bpp +!gfx/title/title_trail_*.2bpp gfx/card_flip/card_flip_*.2bpp gfx/diploma/diploma.2bpp gfx/dummy_game/dummy_game.2bpp @@ -75,3 +76,4 @@ gfx/unown_puzzle/hooh.2bpp gfx/unown_puzzle/kabuto.2bpp gfx/unown_puzzle/omanyte.2bpp gfx/unown_puzzle/start_cancel.2bpp +gfx/intro/*.2bpp @@ -2,10 +2,6 @@ These instructions explain how to set up the tools required to build **pokegold**, including [**rgbds**](https://github.com/rednex/rgbds), which assembles the source files into a ROM. -Currently building requires that you provide a base ROM for both versions. You can find the sha1 for each version in [README.md](README.md) to confirm you have the right one. - -You will need to rename the Gold ROM to **baserom-gold.gbc** and the Silver ROM to **baserom-silver.gbc** in order to build either version. - If you run into trouble, ask for help on IRC or Discord (see [README.md](README.md)). ## Windows 10 @@ -156,4 +152,4 @@ To build both ROMs: ```bash make -```
\ No newline at end of file +``` diff --git a/constants/sprite_anim_constants.asm b/constants/sprite_anim_constants.asm index 3181da67..2ca59e0f 100644 --- a/constants/sprite_anim_constants.asm +++ b/constants/sprite_anim_constants.asm @@ -25,8 +25,8 @@ NUM_SPRITE_ANIM_STRUCTS EQU 10 ; see wSpriteAnimationStructs const SPRITE_ANIM_INDEX_GS_INTRO_BUBBLE ; 01 const SPRITE_ANIM_INDEX_GS_INTRO_SHELLDER ; 02 const SPRITE_ANIM_INDEX_GS_INTRO_MAGIKARP ; 03 - const SPRITE_ANIM_INDEX_GS_INTRO_LAPRAS ; 04 - const SPRITE_ANIM_INDEX_GS_INTRO_LAPRAS_2 ; 05 + const SPRITE_ANIM_INDEX_UNUSED_LAPRAS ; 04 + const SPRITE_ANIM_INDEX_GS_INTRO_LAPRAS ; 05 const SPRITE_ANIM_INDEX_GS_INTRO_NOTE ; 06 const SPRITE_ANIM_INDEX_GS_INTRO_INVISIBLE_NOTE ; 07 const SPRITE_ANIM_INDEX_GS_INTRO_JIGGLYPUFF ; 08 @@ -78,8 +78,8 @@ NUM_SPRITE_ANIM_STRUCTS EQU 10 ; see wSpriteAnimationStructs const SPRITE_ANIM_SEQ_GS_INTRO_BUBBLE ; 04 const SPRITE_ANIM_SEQ_GS_INTRO_SHELLDER ; 05 const SPRITE_ANIM_SEQ_GS_INTRO_MAGIKARP ; 06 - const SPRITE_ANIM_SEQ_GS_INTRO_LAPRAS ; 07 - const SPRITE_ANIM_SEQ_GS_INTRO_LAPRAS_2 ; 08 + const SPRITE_ANIM_SEQ_UNUSED_LAPRAS ; 07 + const SPRITE_ANIM_SEQ_GS_INTRO_LAPRAS ; 08 const SPRITE_ANIM_SEQ_GS_INTRO_NOTE ; 09 const SPRITE_ANIM_SEQ_GS_INTRO_JIGGLYPUFF ; 0a const SPRITE_ANIM_SEQ_GS_INTRO_PIKACHU ; 0b @@ -123,8 +123,8 @@ NUM_SPRITE_ANIM_STRUCTS EQU 10 ; see wSpriteAnimationStructs const SPRITE_ANIM_FRAMESET_GS_INTRO_BUBBLE ; 04 const SPRITE_ANIM_FRAMESET_GS_INTRO_SHELLDER ; 05 const SPRITE_ANIM_FRAMESET_GS_INTRO_MAGIKARP ; 06 - const SPRITE_ANIM_FRAMESET_GS_INTRO_LAPRAS ; 07 - const SPRITE_ANIM_FRAMESET_GS_INTRO_LAPRAS_2 ; 08 + const SPRITE_ANIM_FRAMESET_UNUSED_LAPRAS ; 07 + const SPRITE_ANIM_FRAMESET_GS_INTRO_LAPRAS ; 08 const SPRITE_ANIM_FRAMESET_GS_INTRO_NOTE ; 09 const SPRITE_ANIM_FRAMESET_GS_INTRO_INVISIBLE_NOTE ; 0a const SPRITE_ANIM_FRAMESET_GS_INTRO_JIGGLYPUFF ; 0b @@ -183,10 +183,10 @@ NUM_SPRITE_ANIM_STRUCTS EQU 10 ; see wSpriteAnimationStructs const SPRITE_ANIM_OAMSET_GS_INTRO_SHELLDER_2 ; 05 const SPRITE_ANIM_OAMSET_GS_INTRO_MAGIKARP_1 ; 06 const SPRITE_ANIM_OAMSET_GS_INTRO_MAGIKARP_2 ; 07 - const SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_1 ; 08 - const SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_2 ; 09 - const SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_3 ; 0a - const SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_4 ; 0b + const SPRITE_ANIM_OAMSET_UNUSED_LAPRAS ; 08 + const SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_1 ; 09 + const SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_2 ; 0a + const SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_3 ; 0b const SPRITE_ANIM_OAMSET_GS_INTRO_NOTE ; 0c const SPRITE_ANIM_OAMSET_GS_INTRO_INVISIBLE_NOTE ; 0d const SPRITE_ANIM_OAMSET_GS_INTRO_JIGGLYPUFF_1 ; 0e diff --git a/data/sprite_anims/framesets.asm b/data/sprite_anims/framesets.asm index 0f05fdda..78969b87 100644 --- a/data/sprite_anims/framesets.asm +++ b/data/sprite_anims/framesets.asm @@ -7,8 +7,8 @@ SpriteAnimFrameData: dw .Frameset_GSIntroBubble dw .Frameset_GSIntroShellder dw .Frameset_GSIntroMagikarp + dw .Frameset_UnusedLapras dw .Frameset_GSIntroLapras - dw .Frameset_GSIntroLapras2 dw .Frameset_GSIntroNote dw .Frameset_GSIntroInvisibleNote dw .Frameset_GSIntroJigglypuff @@ -98,15 +98,15 @@ SpriteAnimFrameData: frame SPRITE_ANIM_OAMSET_GS_INTRO_MAGIKARP_2, $41 dorestart -.Frameset_GSIntroLapras: - frame SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_1, $47 +.Frameset_UnusedLapras: + frame SPRITE_ANIM_OAMSET_UNUSED_LAPRAS, $47 endanim -.Frameset_GSIntroLapras2: +.Frameset_GSIntroLapras: + frame SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_1, 7 frame SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_2, 7 frame SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_3, 7 - frame SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_4, 7 - frame SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_2, 7 + frame SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_1, 7 dorestart .Frameset_GSIntroNote: diff --git a/data/sprite_anims/oam.asm b/data/sprite_anims/oam.asm index dde96fca..91175fb0 100644 --- a/data/sprite_anims/oam.asm +++ b/data/sprite_anims/oam.asm @@ -9,10 +9,10 @@ SpriteAnimOAMData: dbw $6e, .OAMData_GSIntroShellder ; SPRITE_ANIM_OAMSET_GS_INTRO_SHELLDER_2 dbw $2d, .OAMData_GSIntroMagikarp ; SPRITE_ANIM_OAMSET_GS_INTRO_MAGIKARP_1 dbw $4d, .OAMData_GSIntroMagikarp ; SPRITE_ANIM_OAMSET_GS_INTRO_MAGIKARP_2 - dbw $60, .OAMData_GSIntroLapras1 ; SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_1 + dbw $60, .OAMData_UnusedLapras ; SPRITE_ANIM_OAMSET_UNUSED_LAPRAS + dbw $00, .OAMData_GSIntroLapras1 ; SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_1 dbw $00, .OAMData_GSIntroLapras2 ; SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_2 - dbw $00, .OAMData_GSIntroLapras3 ; SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_3 - dbw $06, .OAMData_GSIntroLapras4 ; SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_4 + dbw $06, .OAMData_GSIntroLapras3 ; SPRITE_ANIM_OAMSET_GS_INTRO_LAPRAS_3 dbw $0c, .OAMData_GSIntroNote ; SPRITE_ANIM_OAMSET_GS_INTRO_NOTE dbw $0d, .OAMData_1x1_Palette0 ; SPRITE_ANIM_OAMSET_GS_INTRO_INVISIBLE_NOTE dbw $00, .OAMData_GSIntroJigglypuffPikachu ; SPRITE_ANIM_OAMSET_GS_INTRO_JIGGLYPUFF_1 @@ -355,7 +355,7 @@ ENDC dbsprite -1, 0, 4, 0, $11, 1 dbsprite 0, 0, 4, 0, $12, 1 -.OAMData_GSIntroLapras1: +.OAMData_UnusedLapras: db 10 dbsprite -2, -2, 0, 4, $00, 0 dbsprite -1, -2, 0, 4, $01, 0 @@ -368,7 +368,7 @@ ENDC dbsprite -1, 0, 0, 4, $09, 0 dbsprite 0, 0, 0, 4, $0a, 0 -.OAMData_GSIntroLapras2: +.OAMData_GSIntroLapras1: db 27 dbsprite -3, -3, 0, 0, $00, 0 dbsprite -2, -3, 0, 0, $01, 0 @@ -398,7 +398,7 @@ ENDC dbsprite 1, 2, 0, 0, $54, 0 | PRIORITY dbsprite 2, 2, 0, 0, $55, 0 | PRIORITY -.OAMData_GSIntroLapras3: +.OAMData_GSIntroLapras2: db 27 dbsprite -3, -3, 0, 0, $0d, 0 dbsprite -2, -3, 0, 0, $0e, 0 @@ -428,7 +428,7 @@ ENDC dbsprite 1, 2, 0, 0, $54, 0 | PRIORITY dbsprite 2, 2, 0, 0, $55, 0 | PRIORITY -.OAMData_GSIntroLapras4: +.OAMData_GSIntroLapras3: db 29 dbsprite -3, -3, 0, 0, $00, 0 dbsprite -2, -3, 0, 0, $01, 0 diff --git a/data/sprite_anims/sequences.asm b/data/sprite_anims/sequences.asm index 2c240d24..581d7268 100644 --- a/data/sprite_anims/sequences.asm +++ b/data/sprite_anims/sequences.asm @@ -5,8 +5,8 @@ SpriteAnimSeqData: db SPRITE_ANIM_FRAMESET_GS_INTRO_BUBBLE, SPRITE_ANIM_SEQ_GS_INTRO_BUBBLE, $00 ; SPRITE_ANIM_INDEX_GS_INTRO_BUBBLE db SPRITE_ANIM_FRAMESET_GS_INTRO_SHELLDER, SPRITE_ANIM_SEQ_GS_INTRO_SHELLDER, $00 ; SPRITE_ANIM_INDEX_GS_INTRO_SHELLDER db SPRITE_ANIM_FRAMESET_GS_INTRO_MAGIKARP, SPRITE_ANIM_SEQ_GS_INTRO_MAGIKARP, $00 ; SPRITE_ANIM_INDEX_GS_INTRO_MAGIKARP + db SPRITE_ANIM_FRAMESET_UNUSED_LAPRAS, SPRITE_ANIM_SEQ_UNUSED_LAPRAS, $00 ; SPRITE_ANIM_INDEX_UNUSED_LAPRAS db SPRITE_ANIM_FRAMESET_GS_INTRO_LAPRAS, SPRITE_ANIM_SEQ_GS_INTRO_LAPRAS, $00 ; SPRITE_ANIM_INDEX_GS_INTRO_LAPRAS - db SPRITE_ANIM_FRAMESET_GS_INTRO_LAPRAS_2, SPRITE_ANIM_SEQ_GS_INTRO_LAPRAS_2, $00 ; SPRITE_ANIM_INDEX_GS_INTRO_LAPRAS_2 db SPRITE_ANIM_FRAMESET_GS_INTRO_NOTE, SPRITE_ANIM_SEQ_GS_INTRO_NOTE, $01 ; SPRITE_ANIM_INDEX_GS_INTRO_NOTE db SPRITE_ANIM_FRAMESET_GS_INTRO_INVISIBLE_NOTE, SPRITE_ANIM_SEQ_GS_INTRO_NOTE, $01 ; SPRITE_ANIM_INDEX_GS_INTRO_INVISIBLE_NOTE db SPRITE_ANIM_FRAMESET_GS_INTRO_JIGGLYPUFF, SPRITE_ANIM_SEQ_GS_INTRO_JIGGLYPUFF, $01 ; SPRITE_ANIM_INDEX_GS_INTRO_JIGGLYPUFF 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 diff --git a/gfx/intro/charizard1.2bpp.lz b/gfx/intro/charizard1.2bpp.lz Binary files differnew file mode 100644 index 00000000..dbcfd4b4 --- /dev/null +++ b/gfx/intro/charizard1.2bpp.lz diff --git a/gfx/intro/charizard1.png b/gfx/intro/charizard1.png Binary files differnew file mode 100644 index 00000000..79b8dfa0 --- /dev/null +++ b/gfx/intro/charizard1.png diff --git a/gfx/intro/charizard2.2bpp.lz b/gfx/intro/charizard2.2bpp.lz Binary files differnew file mode 100644 index 00000000..1fc35fd5 --- /dev/null +++ b/gfx/intro/charizard2.2bpp.lz diff --git a/gfx/intro/charizard2.png b/gfx/intro/charizard2.png Binary files differnew file mode 100644 index 00000000..e6ec2139 --- /dev/null +++ b/gfx/intro/charizard2.png diff --git a/gfx/intro/charizard3.2bpp.lz b/gfx/intro/charizard3.2bpp.lz Binary files differnew file mode 100644 index 00000000..c4de8391 --- /dev/null +++ b/gfx/intro/charizard3.2bpp.lz diff --git a/gfx/intro/charizard3.png b/gfx/intro/charizard3.png Binary files differnew file mode 100644 index 00000000..ff4f656c --- /dev/null +++ b/gfx/intro/charizard3.png diff --git a/gfx/intro/grass.bin b/gfx/intro/grass.bin Binary files differnew file mode 100644 index 00000000..f2edef78 --- /dev/null +++ b/gfx/intro/grass.bin diff --git a/gfx/intro/grass.tilemap b/gfx/intro/grass.tilemap new file mode 100644 index 00000000..c3a84204 --- /dev/null +++ b/gfx/intro/grass.tilemap @@ -0,0 +1,128 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gfx/intro/grass1.2bpp.lz b/gfx/intro/grass1.2bpp.lz Binary files differnew file mode 100644 index 00000000..e10c760e --- /dev/null +++ b/gfx/intro/grass1.2bpp.lz diff --git a/gfx/intro/grass1.png b/gfx/intro/grass1.png Binary files differnew file mode 100644 index 00000000..a639be51 --- /dev/null +++ b/gfx/intro/grass1.png diff --git a/gfx/intro/grass2.2bpp.lz b/gfx/intro/grass2.2bpp.lz Binary files differnew file mode 100644 index 00000000..32ee96d2 --- /dev/null +++ b/gfx/intro/grass2.2bpp.lz diff --git a/gfx/intro/grass2.png b/gfx/intro/grass2.png Binary files differnew file mode 100644 index 00000000..2530ec02 --- /dev/null +++ b/gfx/intro/grass2.png diff --git a/gfx/intro/water.bin b/gfx/intro/water.bin Binary files differnew file mode 100644 index 00000000..1ef6980b --- /dev/null +++ b/gfx/intro/water.bin diff --git a/gfx/intro/water.tilemap b/gfx/intro/water.tilemap new file mode 100644 index 00000000..e4114905 --- /dev/null +++ b/gfx/intro/water.tilemap @@ -0,0 +1,2 @@ + !"#$%& !"#$%&()*+,-.()*+,-.''$%&'$%&'',-.''''',-.''' +
\ No newline at end of file diff --git a/gfx/intro/water1.2bpp.lz b/gfx/intro/water1.2bpp.lz Binary files differnew file mode 100644 index 00000000..b1d0c164 --- /dev/null +++ b/gfx/intro/water1.2bpp.lz diff --git a/gfx/intro/water1.png b/gfx/intro/water1.png Binary files differnew file mode 100644 index 00000000..1b09ef44 --- /dev/null +++ b/gfx/intro/water1.png diff --git a/gfx/intro/water2.2bpp.lz b/gfx/intro/water2.2bpp.lz Binary files differnew file mode 100644 index 00000000..e6c59440 --- /dev/null +++ b/gfx/intro/water2.2bpp.lz diff --git a/gfx/intro/water2.png b/gfx/intro/water2.png Binary files differnew file mode 100644 index 00000000..1481b66f --- /dev/null +++ b/gfx/intro/water2.png diff --git a/gfx/title/hooh_gold.2bpp.lz b/gfx/title/hooh_gold.2bpp.lz Binary files differnew file mode 100644 index 00000000..e7fa5b54 --- /dev/null +++ b/gfx/title/hooh_gold.2bpp.lz diff --git a/gfx/title/hooh_gold.png b/gfx/title/hooh_gold.png Binary files differnew file mode 100644 index 00000000..646166b1 --- /dev/null +++ b/gfx/title/hooh_gold.png diff --git a/gfx/title/lugia_silver.2bpp.lz b/gfx/title/lugia_silver.2bpp.lz Binary files differnew file mode 100644 index 00000000..14ce9337 --- /dev/null +++ b/gfx/title/lugia_silver.2bpp.lz diff --git a/gfx/title/lugia_silver.png b/gfx/title/lugia_silver.png Binary files differnew file mode 100644 index 00000000..7edb8538 --- /dev/null +++ b/gfx/title/lugia_silver.png diff --git a/gfx/title/title_trail_gold.2bpp b/gfx/title/title_trail_gold.2bpp Binary files differnew file mode 100644 index 00000000..bd70b678 --- /dev/null +++ b/gfx/title/title_trail_gold.2bpp diff --git a/gfx/title/title_trail_gold.png b/gfx/title/title_trail_gold.png Binary files differnew file mode 100644 index 00000000..1661ede0 --- /dev/null +++ b/gfx/title/title_trail_gold.png diff --git a/gfx/title/title_trail_silver.2bpp b/gfx/title/title_trail_silver.2bpp new file mode 100644 index 00000000..7bf46752 --- /dev/null +++ b/gfx/title/title_trail_silver.2bpp @@ -0,0 +1 @@ +????ÿÿÿÿÿÿÿÿ????ÀÀððüüüüþþþþÿÿÿÿÿÿÿÿþþþþüüüüððÀÀ
\ No newline at end of file diff --git a/gfx/title/title_trail_silver.png b/gfx/title/title_trail_silver.png Binary files differnew file mode 100644 index 00000000..b044701d --- /dev/null +++ b/gfx/title/title_trail_silver.png @@ -20,11 +20,3 @@ INCLUDE "macros/scripts/gfx_anims.asm" ; - Leave out for now so no code depending on legacy macros gets introduced ; ; INCLUDE "macros/legacy.asm" - -dr: macro -IF DEF(_GOLD) -INCBIN "baserom-gold.gbc", \1, \2 - \1 -ELIF DEF(_SILVER) -INCBIN "baserom-silver.gbc", \1, \2 - \1 -ENDC -ENDM @@ -254,19 +254,19 @@ INCLUDE "engine/games/slot_machine.asm" SECTION "bank26", ROMX IF DEF(_GOLD) -TitleScreenGFX1:: +TitleScreenGFX1: INCBIN "gfx/title/logo_bottom_gold.2bpp.lz" -TitleScreenGFX2:: +TitleScreenGFX2: INCBIN "gfx/title/logo_top_gold.2bpp.lz" ELIF DEF(_SILVER) -TitleScreenGFX1:: +TitleScreenGFX1: INCBIN "gfx/title/logo_bottom_silver.2bpp.lz" -TitleScreenGFX2:: +TitleScreenGFX2: INCBIN "gfx/title/logo_top_silver.2bpp.lz" ENDC -TitleScreenTilemap:: +TitleScreenTilemap: INCBIN "gfx/title/logo.tilemap" @@ -330,32 +330,20 @@ CopyrightGFX:: INCBIN "gfx/intro/copyright.2bpp" IF DEF(_GOLD) -TitleScreenGFX3:: - dr $e41e0, $e4260 -TitleScreenGFX4:: - dr $e4260, $e4608 -_OptionsMenu:: - dr $e4608, $e49a8 +TitleScreenGFX3: +INCBIN "gfx/title/title_trail_gold.2bpp" +TitleScreenGFX4: +INCBIN "gfx/title/hooh_gold.2bpp.lz" ELIF DEF(_SILVER) -TitleScreenGFX3:: - dr $e41e0, $e4220 -TitleScreenGFX4:: - dr $e4220, $e4450 -_OptionsMenu:: - dr $e4450, $e47f0 +TitleScreenGFX3: +INCBIN "gfx/title/title_trail_silver.2bpp" +TitleScreenGFX4: +INCBIN "gfx/title/lugia_silver.2bpp.lz" ENDC -INCLUDE "engine/movie/gamefreak_presents.asm" - -IF DEF(_GOLD) -GoldSilverIntro:: - dr $e4cb1, $e7678 - -ELIF DEF(_SILVER) -GoldSilverIntro:: - dr $e4af9, $e74c0 -ENDC +INCLUDE "engine/menus/options_menu.asm" +INCLUDE "engine/movie/gold_silver_intro.asm" SECTION "bank3E", ROMX diff --git a/tools/compare-gold.sh b/tools/compare-gold.sh deleted file mode 100755 index e75cb743..00000000 --- a/tools/compare-gold.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# Compares baserom-gold.gbc and pokegold.gbc - -# create baserom-gold.txt if necessary -if [ ! -f baserom-gold.txt ]; then - hexdump -C baserom-gold.gbc > baserom-gold.txt -fi - -hexdump -C pokegold.gbc > pokegold.txt - -diff -u baserom-gold.txt pokegold.txt | less diff --git a/tools/compare-silver.sh b/tools/compare-silver.sh deleted file mode 100755 index f8881cd2..00000000 --- a/tools/compare-silver.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# Compares baserom-silver.gbc and pokesilver.gbc - -# create baserom-silver.txt if necessary -if [ ! -f baserom-silver.txt ]; then - hexdump -C baserom-silver.gbc > baserom-silver.txt -fi - -hexdump -C pokesilver.gbc > pokesilver.txt - -diff -u baserom-silver.txt pokesilver.txt | less diff --git a/tools/gfx.py b/tools/gfx.py index c53110a7..7007d37e 100644 --- a/tools/gfx.py +++ b/tools/gfx.py @@ -163,6 +163,23 @@ def filepath_rules(filepath): args['width'] = 104 elif name == 'copyright': args['width'] = 240 + elif name == 'charizard1': + args['width'] = 72 + args['rows'] = [ + (1, 8), (1, 8), (1, 8), (1, 8), (1, 8), (1, 8), (1, 8), (1, 8), + (0, 9), (0, 9), (0, 9), (0, 9), (0, 9), (0, 9), (0, 9) + ] + elif name == 'charizard2': + args['width'] = 72 + args['pad_indices'] = [0] + elif name == 'charizard3': + args['width'] = 64 + args['rows'] = [ + (0, 8), (0, 8), (0, 0), (1, 6), (1, 6), (1, 6), (1, 6), (1, 6), (1, 6), + (1, 6), (1, 6), (1, 6), (1, 6), (1, 6), (1, 6), (1, 6), (1, 6) + ] + elif name in ['grass1', 'grass2', 'water1', 'water2']: + args['width'] = 128 elif 'gfx/mail' in filedir: if name in mail_px8: @@ -272,6 +289,14 @@ def filepath_rules(filepath): elif 'gfx/title' in filedir: if name in ['logo_bottom_gold', 'logo_bottom_silver', 'logo_top_gold', 'logo_top_silver']: args['width'] = 160 + elif name == 'lugia_silver': + args['width'] = 64 + args['pic_dimensions'] = 8, 4 + elif name == 'hooh_gold': + args['width'] = 64 + args['pic_dimensions'] = 8, 6 + elif name in ['title_trail_gold', 'title_trail_silver']: + args['width'] = 32 elif 'gfx/trainer_card' in filedir: if name in ['badges', 'trainer_card']: @@ -352,7 +377,16 @@ def to_2bpp(filename, **kwargs): def to_png(filename, **kwargs): name, ext = os.path.splitext(filename) - if ext == '.1bpp': gfx.export_1bpp_to_png(filename, **kwargs) + if ext == '.1bpp': + basedir, basename = os.path.split(filename) + name, ext = os.path.splitext(basename) + # Ignoring these for convenience only + if basedir in ['gfx/footprints', 'gfx/font']: + return + # Ignoring these for convenience only + if name in ['hp_exp_bar_border']: + return + gfx.export_1bpp_to_png(filename, **kwargs) elif ext == '.2bpp': basedir, basename = os.path.split(filename) name, ext = os.path.splitext(basename) @@ -362,6 +396,9 @@ def to_png(filename, **kwargs): # TODO: same question for most/all battle anims if basedir == 'gfx/battle_anims': return + # Ignoring these for convenience only + if basedir == 'gfx/font': + return if name in ['back_gold', 'back_silver']: kwargs['fileout'] = os.path.join(basedir, 'back.png') gfx.export_2bpp_to_png(filename, **kwargs) diff --git a/tools/scan_includes.py b/tools/scan_includes.py deleted file mode 100644 index 60929d3f..00000000 --- a/tools/scan_includes.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/python -# coding: utf-8 - -""" -Recursively scan an asm file for dependencies. -""" - -import sys -import argparse - -includes = set() - -def scan_file(filename): - for line in open(filename): - if 'INC' not in line: - continue - line = line.split(';')[0] - if 'INCLUDE' in line: - include = line.split('"')[1] - includes.add(include) - scan_file(include) - elif 'INCBIN' in line: - include = line.split('"')[1] - includes.add(include) - -def main(): - ap = argparse.ArgumentParser() - ap.add_argument('filenames', nargs='*') - args = ap.parse_args() - for filename in set(args.filenames): - scan_file(filename) - sys.stdout.write(' '.join(includes)) - -if __name__ == '__main__': - main() diff --git a/tools/unused_sources.sh b/tools/unused_sources.sh deleted file mode 100755 index b0b9e368..00000000 --- a/tools/unused_sources.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# Finds files that aren't included in the build - -# top-level sources listed in Makefile -toplevel='audio.asm data/text/common.asm data/pokemon/dex_entries.asm wram.asm -main.asm home.asm gfx/sprites.asm gfx/pics_gold.asm gfx/pics_silver.asm -data/maps/map_data.asm engine/overworld/events.asm rgbdscheck.asm -data/pokemon/egg_moves.asm data/pokemon/evos_attacks.asm gfx/tilesets.asm -engine/movie/credits.asm' - -for asm in $toplevel; do - echo "$asm" - python tools/scan_includes.py "$asm" - echo -done | tr ' ' '\n' | sort -u > includes.txt -git ls-files | grep -E '\.(asm|gbcpal|pal|lz|[1,2]bpp|blk|bin|rle|attrmap|tilemap|dimensions)$' | sort -u > sources.txt -comm -23 sources.txt includes.txt -rm sources.txt includes.txt @@ -612,10 +612,18 @@ wc8f9:: ds 7 NEXTU ; c700 ; LCD expects wLYOverrides to have an alignment of $100 wLYOverrides:: ds SCREEN_HEIGHT_PX -wLYOverridesEnd:: ds 112 +wLYOverridesEnd:: +UNION ; c790 + ds 16 +wLYOverrides2:: ds SCREEN_HEIGHT_PX +wLYOverrides2End:: + +NEXTU ; c790 + ds $100 - SCREEN_HEIGHT_PX wLYOverridesBackup:: ds SCREEN_HEIGHT_PX -wLYOverridesBackupEnd:: ds 112 +wLYOverridesBackupEnd:: ds $100 - SCREEN_HEIGHT_PX +ENDU UNION ; c900 ; blank credits tile buffer @@ -720,8 +728,22 @@ wPlayerMoveStruct:: move_struct wPlayerMoveStruct wEnemyMonNick:: ds MON_NAME_LENGTH ; caf6 wBattleMonNick:: ds MON_NAME_LENGTH ; cb01 +UNION ; cb0c +; battle mon wBattleMon:: battle_struct wBattleMon ; cb0c +NEXTU ; cb0c +; intro water/grass/fire cutscene data + ds 4 +wIntroJumptableIndex:: db +wIntroBGMapPointer:: dw +wIntroTilemapPointer:: dw +wIntroTilesPointer:: dw +wIntroFrameCounter1:: db +wIntroFrameCounter2:: db +wcb19:: db +ENDU ; cb2c + wcb2c:: ds 1 ; cb2c wcb2d:: ds 1 ; cb2d wEnemyTrainerItem1:: db ; cb2e @@ -1114,7 +1136,7 @@ wce65:: db wce66:: db NEXTU ; ce64 -; intro and title data +; gfpresents, title, and intro menu timers wIntroSceneFrameCounter:: db UNION ; ce65 wIntroSceneTimer:: db |