pokered/engine/gamefreak.asm

245 lines
4.5 KiB
NASM
Raw Normal View History

2014-05-22 22:13:20 +00:00
LoadShootingStarGraphics: ; 70000 (1c:4000)
ld a, $f9
ld [rOBP0], a
2014-05-22 22:13:20 +00:00
ld a, $a4
ld [rOBP1], a
ld de, AnimationTileset2 + $30 ; star tile (top left quadrant)
2014-05-29 08:31:46 +00:00
ld hl, vChars1 + $200
2015-08-05 21:20:29 +00:00
lb bc, BANK(AnimationTileset2), $01
2014-05-22 22:13:20 +00:00
call CopyVideoData
ld de, AnimationTileset2 + $130 ; star tile (bottom left quadrant)
2014-05-29 08:31:46 +00:00
ld hl, vChars1 + $210
2015-08-05 21:20:29 +00:00
lb bc, BANK(AnimationTileset2), $01
2014-05-22 22:13:20 +00:00
call CopyVideoData
ld de, FallingStar
2014-05-29 08:31:46 +00:00
ld hl, vChars1 + $220
2015-08-10 04:56:20 +00:00
lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10
2014-05-22 22:13:20 +00:00
call CopyVideoData
ld hl, GameFreakLogoOAMData
2014-05-22 22:13:20 +00:00
ld de, wOAMBuffer + $60
2015-08-10 04:56:20 +00:00
ld bc, GameFreakLogoOAMDataEnd - GameFreakLogoOAMData
2014-05-22 22:13:20 +00:00
call CopyData
ld hl, GameFreakShootingStarOAMData
2014-05-22 22:13:20 +00:00
ld de, wOAMBuffer
2015-08-10 04:56:20 +00:00
ld bc, GameFreakShootingStarOAMDataEnd - GameFreakShootingStarOAMData
2014-05-22 22:13:20 +00:00
jp CopyData
AnimateShootingStar: ; 70044 (1c:4044)
call LoadShootingStarGraphics
2015-07-19 08:46:12 +00:00
ld a, SFX_SHOOTING_STAR
2014-05-22 22:13:20 +00:00
call PlaySound
2015-07-17 05:08:34 +00:00
; Move the big star down and left across the screen.
2014-05-22 22:13:20 +00:00
ld hl, wOAMBuffer
2015-08-05 21:20:29 +00:00
lb bc, $a0, $4
2015-07-17 05:08:34 +00:00
.bigStarLoop
2014-05-22 22:13:20 +00:00
push hl
push bc
2015-07-17 05:08:34 +00:00
.bigStarInnerLoop
ld a, [hl] ; Y
add 4
2014-05-22 22:13:20 +00:00
ld [hli], a
2015-07-17 05:08:34 +00:00
ld a, [hl] ; X
add -4
2014-05-22 22:13:20 +00:00
ld [hli], a
inc hl
inc hl
dec c
2015-07-17 05:08:34 +00:00
jr nz, .bigStarInnerLoop
ld c, 1
2014-05-22 22:13:20 +00:00
call CheckForUserInterruption
pop bc
pop hl
ret c
ld a, [hl]
2015-07-17 05:08:34 +00:00
cp 80
jr nz, .next
jr .bigStarLoop
.next
2014-05-22 22:13:20 +00:00
cp b
2015-07-17 05:08:34 +00:00
jr nz, .bigStarLoop
; Clear big star OAM.
2014-05-22 22:13:20 +00:00
ld hl, wOAMBuffer
2015-07-17 05:08:34 +00:00
ld c, 4
ld de, 4
.clearOAMLoop
ld [hl], 160
2014-05-22 22:13:20 +00:00
add hl, de
dec c
2015-07-17 05:08:34 +00:00
jr nz, .clearOAMLoop
; Make Gamefreak logo flash.
ld b, 3
.flashLogoLoop
ld hl, rOBP0
2014-05-22 22:13:20 +00:00
rrc [hl]
rrc [hl]
2015-07-17 05:08:34 +00:00
ld c, 10
2014-05-22 22:13:20 +00:00
call CheckForUserInterruption
ret c
dec b
2015-07-17 05:08:34 +00:00
jr nz, .flashLogoLoop
; Copy 24 instances of the small stars OAM data.
; Note that their coordinates put them off-screen.
2014-05-22 22:13:20 +00:00
ld de, wOAMBuffer
2015-07-17 05:08:34 +00:00
ld a, 24
.initSmallStarsOAMLoop
2014-05-22 22:13:20 +00:00
push af
2015-07-17 05:08:34 +00:00
ld hl, SmallStarsOAM
2015-08-10 04:56:20 +00:00
ld bc, SmallStarsOAMEnd - SmallStarsOAM
2014-05-22 22:13:20 +00:00
call CopyData
pop af
dec a
2015-07-17 05:08:34 +00:00
jr nz, .initSmallStarsOAMLoop
; Animate the small stars falling from the Gamefreak logo.
2014-05-22 22:13:20 +00:00
xor a
2015-07-17 05:08:34 +00:00
ld [wMoveDownSmallStarsOAMCount], a
ld hl, SmallStarsWaveCoordsPointerTable
ld c, 6
.smallStarsLoop
2014-05-22 22:13:20 +00:00
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
push bc
push hl
ld hl, wOAMBuffer + $50
2015-07-17 05:08:34 +00:00
ld c, 4
.smallStarsInnerLoop ; introduce new wave of 4 small stars OAM entries
2014-05-22 22:13:20 +00:00
ld a, [de]
cp $ff
2015-07-17 05:08:34 +00:00
jr z, .next2
ld [hli], a ; Y
2014-05-22 22:13:20 +00:00
inc de
ld a, [de]
2015-07-17 05:08:34 +00:00
ld [hli], a ; X
2014-05-22 22:13:20 +00:00
inc de
inc hl
inc hl
dec c
2015-07-17 05:08:34 +00:00
jr nz, .smallStarsInnerLoop
ld a, [wMoveDownSmallStarsOAMCount]
cp 24
jr z, .next2
add 6 ; should be 4, but the extra 2 aren't visible on screen
ld [wMoveDownSmallStarsOAMCount], a
.next2
call MoveDownSmallStars
2014-05-22 22:13:20 +00:00
push af
2015-07-17 05:08:34 +00:00
; shift the existing OAM entries down to make room for the next wave
ld hl, wOAMBuffer + $10
2014-05-22 22:13:20 +00:00
ld de, wOAMBuffer
ld bc, $50
call CopyData
2015-07-17 05:08:34 +00:00
2014-05-22 22:13:20 +00:00
pop af
pop hl
pop bc
ret c
dec c
2015-07-17 05:08:34 +00:00
jr nz, .smallStarsLoop
2014-05-22 22:13:20 +00:00
and a
ret
2015-07-17 05:08:34 +00:00
SmallStarsOAM: ; 700ee (1c:40ee)
2014-05-22 22:13:20 +00:00
db $00,$00,$A2,$90
2015-08-10 04:56:20 +00:00
SmallStarsOAMEnd:
2014-05-22 22:13:20 +00:00
2015-07-17 05:08:34 +00:00
SmallStarsWaveCoordsPointerTable: ; 700f2 (1c:40f2)
dw SmallStarsWave1Coords
dw SmallStarsWave2Coords
dw SmallStarsWave3Coords
dw SmallStarsWave4Coords
dw SmallStarsEmptyWave
dw SmallStarsEmptyWave
2014-05-22 22:13:20 +00:00
2015-07-17 05:08:34 +00:00
; The stars that fall from the Gamefreak logo come in 4 waves of 4 OAM entries.
; These arrays contain the Y and X coordinates of each OAM entry.
SmallStarsWave1Coords: ; 700fe (1c:40fe)
2014-05-22 22:13:20 +00:00
db $68,$30
db $68,$40
db $68,$58
db $68,$78
2015-07-17 05:08:34 +00:00
SmallStarsWave2Coords: ; 70106 (1c:4106)
2014-05-22 22:13:20 +00:00
db $68,$38
db $68,$48
db $68,$60
db $68,$70
2015-07-17 05:08:34 +00:00
SmallStarsWave3Coords: ; 7010e (1c:410e)
2014-05-22 22:13:20 +00:00
db $68,$34
db $68,$4C
db $68,$54
db $68,$64
2015-07-17 05:08:34 +00:00
SmallStarsWave4Coords: ; 70116 (1c:4116)
2014-05-22 22:13:20 +00:00
db $68,$3C
db $68,$5C
db $68,$6C
db $68,$74
2015-07-17 05:08:34 +00:00
SmallStarsEmptyWave: ; 7011e (1c:411e)
2014-05-22 22:13:20 +00:00
db $FF
2015-07-17 05:08:34 +00:00
MoveDownSmallStars: ; 7011f (1c:411f)
ld b, 8
.loop
ld hl, wOAMBuffer + $5c
2015-07-17 05:08:34 +00:00
ld a, [wMoveDownSmallStarsOAMCount]
ld de, -4
2014-05-22 22:13:20 +00:00
ld c, a
2015-07-17 05:08:34 +00:00
.innerLoop
inc [hl] ; Y
2014-05-22 22:13:20 +00:00
add hl, de
dec c
2015-07-17 05:08:34 +00:00
jr nz, .innerLoop
; Toggle the palette so that the lower star in the small stars tile blinks in
; and out.
ld a, [rOBP1]
2015-07-17 05:08:34 +00:00
xor %10100000
ld [rOBP1], a
2015-07-17 05:08:34 +00:00
ld c, 3
2014-05-22 22:13:20 +00:00
call CheckForUserInterruption
ret c
dec b
2015-07-17 05:08:34 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
GameFreakLogoOAMData: ; 70140 (1c:4140)
db $48,$50,$8D,$00
db $48,$58,$8E,$00
db $50,$50,$8F,$00
db $50,$58,$90,$00
db $58,$50,$91,$00
db $58,$58,$92,$00
db $60,$30,$80,$00
db $60,$38,$81,$00
db $60,$40,$82,$00
db $60,$48,$83,$00
db $60,$50,$93,$00
db $60,$58,$84,$00
db $60,$60,$85,$00
db $60,$68,$83,$00
db $60,$70,$81,$00
db $60,$78,$86,$00
2015-08-10 04:56:20 +00:00
GameFreakLogoOAMDataEnd:
2014-05-22 22:13:20 +00:00
GameFreakShootingStarOAMData: ; 70180 (1c:4180)
db $00,$A0,$A0,$10
db $00,$A8,$A0,$30
db $08,$A0,$A1,$10
db $08,$A8,$A1,$30
2015-08-10 04:56:20 +00:00
GameFreakShootingStarOAMDataEnd:
2014-05-22 22:13:20 +00:00
FallingStar: ; 70190 (1c:4190)
INCBIN "gfx/falling_star.2bpp"
2015-08-10 04:56:20 +00:00
FallingStarEnd: