summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/game_freak_intro.asm341
-rw-r--r--layout.link3
-rw-r--r--ram/wram.asm2
-rwxr-xr-xshim.sym2
4 files changed, 345 insertions, 3 deletions
diff --git a/engine/game_freak_intro.asm b/engine/game_freak_intro.asm
new file mode 100644
index 0000000..c92baa2
--- /dev/null
+++ b/engine/game_freak_intro.asm
@@ -0,0 +1,341 @@
+INCLUDE "constants.asm"
+
+SECTION "engine/game_freak_intro.asm", ROMX
+
+GameFreakIntro::
+; Copyright screen and Game Freak logo
+
+ call DisableLCD
+ call ClearVRAM
+
+ ld a, HIGH(vBGMap0)
+ ldh [hBGMapAddress + 1], a
+ xor a
+ ldh [hBGMapAddress], a
+ ldh [hJoyState], a
+ ldh [hSCX], a
+ ldh [hSCY], a
+
+ ld a, $90
+ ldh [hWY], a
+
+ call EnableLCD
+
+ ld c, 10
+ call DelayFrames
+ ld b, SGB_GS_TITLE_SCREEN
+ call GetSGBLayout
+
+ callab IntroCopyRightInfo
+
+ ld a, 1
+ ldh [hBGMapMode], a
+ call WaitBGMap
+ call SetPalettes
+
+ ld c, 3 * 60 ; 3 seconds
+ call DelayFrames
+
+ xor a
+ ldh [hWY], a
+ call ClearTileMap
+
+ call .Init
+.loop
+ call .Frame
+ jr nc, .loop
+
+; this was set if user skipped the GF logo by pressing A
+ ld a, [wJumptableIndex]
+ bit 6, a
+ jr nz, .cancelled
+
+; clear carry flag from .PlayFrame
+ and a
+ ret
+
+.cancelled
+ scf
+ ret
+
+.Init:
+ call DisableLCD
+
+ ld hl, vBGMap0
+ ld bc, $0240
+ xor a
+ call ByteFill
+
+ ld de, GameFreakLogoGFX
+ ld hl, vFont
+ ld bc, $391c
+ call Get1bpp
+
+ ld hl, GameFreakLogoSparkleGFX
+ ld de, $89c0
+ ld bc, $0050
+ ld a, $39
+ call FarCopyData
+
+ callba InitEffectObject
+
+ ld hl, wSpriteAnimDict
+ ld a, $27 ; SPRITE_ANIM_DICT_GS_SPLASH
+ 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
+ call EnableLCD
+
+ ld a, %11100100
+ ld a, %11100100 ; redundant
+ ldh [rOBP0], a
+ ld a, %00100100
+ ldh [rOBP1], a
+ ret
+
+
+.Frame:
+; Play one frame of GameFreakPresents sequence.
+; Return carry when the sequence completes or is canceled.
+ ld hl, hJoypadDown
+ ld a, [hl]
+ and %00001111
+ jr nz, .pressed
+
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .Finished
+
+ callba EffectObjectJumpNoDelay
+
+ call GameFreakPresentsScene
+ call DelayFrame
+ and a
+ ret
+
+.pressed
+ ld hl, wJumptableIndex
+ set 6, [hl]
+
+.Finished:
+ callab InitEffectObject
+ call ClearTileMap
+ call ClearSprites
+
+ ld c, 16
+ call DelayFrames
+
+ scf
+ ret
+
+
+GameFreakPresentsScene:
+ jumptable .scenes, wJumptableIndex
+
+.scenes
+ dw GameFreakPresents_Wait64Frames
+ dw GameFreakPresents_Star
+ dw GameFreakPresents_PlaceLogo
+ dw GameFreakPresents_LogoSparkles
+ dw GameFreakPresents_PlacePresents
+ dw GameFreakPresents_WaitForTimer
+ dw GameFreakPresents_SetDoneFlag
+
+GameFreakPresents_NextScene:
+ ld hl, wJumptableIndex
+ inc [hl]
+ ret
+
+GameFreakPresents_Wait64Frames:
+ ld c, $40
+ call DelayFrames
+ call GameFreakPresents_NextScene
+ ret
+
+GameFreakPresents_Star:
+ xor a
+ ld [wIntroSceneFrameCounter], a
+ ld de, $5458
+ ld a, $3b ; SPRITE_ANIM_INDEX_GS_INTRO_STAR
+ call InitSpriteAnimStruct
+
+ ld hl, $000c ; SPRITEANIMSTRUCT_VAR1
+ add hl, bc
+ ld [hl], $a0 ; star path radius
+
+ ld de, $0031 ; SFX_GAME_FREAK_LOGO (metronome?)
+ call PlaySFX
+ call GameFreakPresents_NextScene
+ ret
+
+GameFreakPresents_PlaceLogo:
+ ld a, [wIntroSceneFrameCounter]
+ and a
+ ret z
+
+ ld de, $5458
+ ld a, $3a ; SPRITE_ANIM_INDEX_GAMEFREAK_LOGO
+ call InitSpriteAnimStruct
+ call GameFreakPresents_NextScene
+
+; set timer for the next scene
+ ld a, 128
+ ld [wIntroSceneTimer], a
+ ret
+
+GameFreakPresents_LogoSparkles:
+ ld hl, wIntroSceneTimer
+ ld a, [hl]
+ and a
+ jr z, .done
+ dec [hl]
+
+; add first text when timer passes half
+ cp 63
+ call z, GameFreakPresents_PlaceGameFreak
+
+; add sparkles continuously
+ call GameFreakPresents_Sparkle
+ ret
+
+.done
+; set timer for the next scene and go there
+ ld [hl], 128
+ call GameFreakPresents_NextScene
+ ret
+
+
+GameFreakPresents_PlaceGameFreak:
+ hlcoord 5, 12
+ ld de, .game_freak
+ call PlaceString
+ ret
+
+.game_freak
+; G A M E F R E A K
+ db $80, $81, $82, $83, $8d, $84, $85, $83, $81, $86
+ db "@"
+
+GameFreakPresents_PlacePresents:
+ hlcoord 7, 13
+ ld de, .presents
+ call PlaceString
+ call GameFreakPresents_NextScene
+ ld a, $80
+ ld [wIntroSceneTimer], a
+ ret
+
+.presents
+; P R E S E N T S
+ db $87, $88, $89, $8a, $8b, $8c
+ db "@"
+
+GameFreakPresents_SetDoneFlag:
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+GameFreakPresents_WaitForTimer:
+ ld hl, wIntroSceneTimer
+ ld a, [hl]
+ and a
+ jr z, .done
+ dec [hl]
+ ret
+.done
+ call GameFreakPresents_NextScene
+ ret
+
+GameFreakPresents_UpdateLogoPal:
+; called from sprite animation routine
+
+; 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 $0f
+ ret nz
+
+; rotate OBP1 by one color slot (2 bits)
+ ld hl, rOBP1
+ rrc [hl]
+ rrc [hl]
+ ret
+
+
+GameFreakPresents_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
+ ld de, $5858
+ ld a, $3c
+ 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, .vectors
+ add hl, de
+ add hl, de
+
+; set the angle and distance for this sprite
+ ld e, l
+ ld d, h
+ ld hl, $b ; SPRITEANIMSTRUCT_JUMPTABLE_INDEX
+ add hl, bc
+ ld a, [de]
+ ld [hl], a ; angle
+ inc de
+ ld hl, $c ; SPRITEANIMSTRUCT_VAR1
+ add hl, bc
+ ld [hl], 0
+ inc hl ; SPRITEANIMSTRUCT_VAR2
+ ld a, [de]
+ ld [hl], a ; distance
+ ret
+
+.vectors
+ 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
diff --git a/layout.link b/layout.link
index cce2beb..c29878b 100644
--- a/layout.link
+++ b/layout.link
@@ -895,9 +895,8 @@ ROMX $38
ROMX $39
org $4000
- org $41ff
+ "engine/game_freak_intro.asm"
"gfx.asm@Gamefreak Logo GFX"
- org $432F
"engine/opening_cutscene.asm"
"gfx.asm@Intro Underwater GFX"
"gfx.asm@Intro Forest GFX"
diff --git a/ram/wram.asm b/ram/wram.asm
index f579aa6..2ca1311 100644
--- a/ram/wram.asm
+++ b/ram/wram.asm
@@ -356,10 +356,12 @@ SECTION "CB5E", WRAM0[$CB5E]
wJumptableIndex:: db
wFlyDestination::
+wIntroSceneFrameCounter::
wBattleTransitionCounter:: db
wBattleTransitionSineWaveOffset::
wBattleTransitionSpinQuadrant::
+wIntroSceneTimer::
wcb60:: ds 1
wcb61:: ds 1
diff --git a/shim.sym b/shim.sym
index 2f3baaa..237f5e3 100755
--- a/shim.sym
+++ b/shim.sym
@@ -152,7 +152,7 @@
33:6263 BattleAnim_Cosine_e
38:4000 PikachuMiniGame
-39:4000 GameFreakIntro
+
3A:441D Functione841d
3A:45D8 Functione85d8
3A:47F9 Functione87f9