pokecrystal-board/engine/movie/title.asm

375 lines
5.4 KiB
NASM
Raw Normal View History

2018-06-24 07:09:41 -07:00
_TitleScreen:
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
call ClearSprites
call ClearTilemap
; Turn BG Map update off
xor a
ldh [hBGMapMode], a
; Reset timing variables
2015-10-24 16:49:19 -07:00
ld hl, wJumptableIndex
ld [hli], a ; wJumptableIndex
ld [hli], a ; wTitleScreenSelectedOption
ld [hli], a ; wTitleScreenTimer
ld [hl], a ; wTitleScreenTimer + 1
; Turn LCD off
call DisableLCD
; VRAM bank 1
ld a, 1
ldh [rVBK], a
; Decompress running Suicune gfx
ld hl, TitleSuicuneGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles1
call Decompress
; Clear screen palettes
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 0
ld bc, 20 * BG_MAP_WIDTH
xor a
call ByteFill
; Fill tile palettes:
; BG Map 1:
; line 0 (copyright)
2017-12-28 04:32:33 -08:00
hlbgcoord 0, 0, vBGMap1
ld bc, BG_MAP_WIDTH
ld a, 7 ; palette
call ByteFill
; BG Map 0:
; Apply logo gradient:
; lines 3-4
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 3
ld bc, 2 * BG_MAP_WIDTH
ld a, 2
call ByteFill
; line 5
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 5
ld bc, BG_MAP_WIDTH
ld a, 3
call ByteFill
; line 6
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 6
ld bc, BG_MAP_WIDTH
ld a, 4
call ByteFill
; line 7
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 7
ld bc, BG_MAP_WIDTH
ld a, 5
call ByteFill
; lines 8-9
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 8
ld bc, 2 * BG_MAP_WIDTH
ld a, 6
call ByteFill
; 'CRYSTAL VERSION'
2015-11-20 08:47:52 -08:00
hlbgcoord 5, 9
2020-08-03 13:55:50 -07:00
ld bc, 11 ; length of version text
ld a, 1
call ByteFill
; Suicune gfx
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 12
ld bc, 6 * BG_MAP_WIDTH ; the rest of the screen
2017-12-27 17:43:56 -08:00
ld a, 0 | VRAM_BANK_1
call ByteFill
; Back to VRAM bank 0
2020-08-03 13:55:50 -07:00
ld a, 0
ldh [rVBK], a
; Decompress logo
ld hl, TitleLogoGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles1
call Decompress
; Decompress background crystal
ld hl, TitleCrystalGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles0
call Decompress
; Clear screen tiles
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 0
ld bc, 64 * BG_MAP_WIDTH
2015-11-20 08:47:52 -08:00
ld a, " "
call ByteFill
; Draw Pokemon logo
hlcoord 0, 3
lb bc, 7, 20
ld d, $80
2020-08-03 13:55:50 -07:00
ld e, 20
call DrawTitleGraphic
; Draw copyright text
2017-12-28 04:32:33 -08:00
hlbgcoord 3, 0, vBGMap1
lb bc, 1, 13
ld d, $c
2020-08-03 13:55:50 -07:00
ld e, 16
call DrawTitleGraphic
; Initialize running Suicune?
ld d, $0
2015-10-19 13:49:29 -07:00
call LoadSuicuneFrame
; Initialize background crystal
2015-10-19 13:49:29 -07:00
call InitializeBackground
2020-08-03 13:55:50 -07:00
; Update palette colors
ldh a, [rSVBK]
push af
ld a, BANK(wBGPals1)
ldh [rSVBK], a
ld hl, TitleScreenPalettes
2018-01-01 06:08:21 -08:00
ld de, wBGPals1
ld bc, 16 palettes
call CopyBytes
ld hl, TitleScreenPalettes
2018-01-01 06:08:21 -08:00
ld de, wBGPals2
ld bc, 16 palettes
call CopyBytes
pop af
ldh [rSVBK], a
; LY/SCX trickery starts here
ldh a, [rSVBK]
push af
2018-01-23 14:39:09 -08:00
ld a, BANK(wLYOverrides)
ldh [rSVBK], a
; Make alternating lines come in from opposite sides
2018-01-09 19:44:06 -08:00
; (This part is actually totally pointless, you can't
; see anything until these values are overwritten!)
ld b, 80 / 2 ; alternate for 80 lines
2018-01-23 14:39:09 -08:00
ld hl, wLYOverrides
.loop
; $00 is the middle position
ld [hl], +112 ; coming from the left
inc hl
ld [hl], -112 ; coming from the right
inc hl
dec b
jr nz, .loop
; Make sure the rest of the buffer is empty
2018-01-23 14:39:09 -08:00
ld hl, wLYOverrides + 80
xor a
2018-01-23 14:39:09 -08:00
ld bc, wLYOverridesEnd - (wLYOverrides + 80)
call ByteFill
; Let LCD Stat know we're messing around with SCX
2018-08-25 11:34:25 -07:00
ld a, LOW(rSCX)
ldh [hLCDCPointer], a
pop af
ldh [rSVBK], a
; Reset audio
call ChannelsOff
call EnableLCD
; Set sprite size to 8x16
ldh a, [rLCDC]
2017-12-29 09:53:21 -08:00
set rLCDC_SPRITE_SIZE, a
ldh [rLCDC], a
ld a, +112
ldh [hSCX], a
ld a, 8
ldh [hSCY], a
ld a, 7
ldh [hWX], a
ld a, -112
ldh [hWY], a
2020-08-03 13:55:50 -07:00
ld a, 1
ldh [hCGBPalUpdate], a
; Update BG Map 0 (bank 0)
ldh [hBGMapMode], a
xor a
ld [wSuicuneFrame], a
; Play starting sound effect
call SFXChannelsOff
ld de, SFX_TITLE_SCREEN_ENTRANCE
2013-10-08 10:10:36 -07:00
call PlaySFX
ret
2018-06-24 07:09:41 -07:00
SuicuneFrameIterator:
ld hl, wSuicuneFrame
ld a, [hl]
ld c, a
inc [hl]
2015-10-19 13:49:29 -07:00
; Only do this once every eight frames
2018-01-09 14:20:47 -08:00
and %111
ret nz
2015-10-19 13:49:29 -07:00
ld a, c
2018-01-09 14:20:47 -08:00
and %11000
sla a
swap a
ld e, a
ld d, $0
2015-10-19 13:49:29 -07:00
ld hl, .Frames
add hl, de
ld d, [hl]
xor a
ldh [hBGMapMode], a
2015-10-19 13:49:29 -07:00
call LoadSuicuneFrame
ld a, $1
ldh [hBGMapMode], a
ld a, $3
ldh [hBGMapThird], a
ret
2018-06-24 07:09:41 -07:00
.Frames:
2018-07-15 08:58:01 -07:00
db $80 ; vTiles3 tile $80
db $88 ; vTiles3 tile $88
2017-12-28 04:32:33 -08:00
db $00 ; vTiles5 tile $00
db $08 ; vTiles5 tile $08
2018-06-24 07:09:41 -07:00
LoadSuicuneFrame:
hlcoord 6, 12
2015-10-19 13:49:29 -07:00
ld b, 6
2015-11-20 08:47:52 -08:00
.bgrows
2015-10-19 13:49:29 -07:00
ld c, 8
.col
ld a, d
ld [hli], a
inc d
dec c
2015-10-19 13:49:29 -07:00
jr nz, .col
ld a, SCREEN_WIDTH - 8
add l
ld l, a
2015-10-19 13:49:29 -07:00
ld a, 0
adc h
ld h, a
2015-10-19 13:49:29 -07:00
ld a, 8
add d
ld d, a
dec b
2015-11-20 08:47:52 -08:00
jr nz, .bgrows
ret
2018-06-24 07:09:41 -07:00
DrawTitleGraphic:
; input:
; hl: draw location
; b: height
; c: width
; d: tile to start drawing from
2015-11-20 08:47:52 -08:00
; e: number of tiles to advance for each bgrows
.bgrows
push de
push bc
push hl
2015-10-19 13:49:29 -07:00
.col
ld a, d
ld [hli], a
inc d
dec c
2015-10-19 13:49:29 -07:00
jr nz, .col
pop hl
2015-10-19 13:49:29 -07:00
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
pop de
ld a, e
add d
ld d, a
dec b
2015-11-20 08:47:52 -08:00
jr nz, .bgrows
ret
2018-06-24 07:09:41 -07:00
InitializeBackground:
2018-01-30 11:52:46 -08:00
ld hl, wVirtualOAMSprite00
2015-10-19 13:49:29 -07:00
ld d, -$22
ld e, $0
2015-10-19 13:49:29 -07:00
ld c, 5
.loop
push bc
2015-10-19 13:49:29 -07:00
call .InitColumn
pop bc
ld a, $10
add d
ld d, a
dec c
2015-10-19 13:49:29 -07:00
jr nz, .loop
ret
2018-06-24 07:09:41 -07:00
.InitColumn:
ld c, $6
ld b, $40
.loop2
ld a, d
2018-01-10 10:47:57 -08:00
ld [hli], a ; y
ld a, b
2018-01-10 10:47:57 -08:00
ld [hli], a ; x
add $8
ld b, a
ld a, e
2018-01-10 10:47:57 -08:00
ld [hli], a ; tile id
inc e
inc e
2018-01-11 20:50:44 -08:00
ld a, 0 | PRIORITY
2018-01-10 10:47:57 -08:00
ld [hli], a ; attributes
dec c
jr nz, .loop2
ret
2018-06-24 07:09:41 -07:00
AnimateTitleCrystal:
; Move the title screen crystal downward until it's fully visible
; Stop at y=6
; y is really from the bottom of the sprite, which is two tiles high
2018-01-30 11:52:46 -08:00
ld hl, wVirtualOAMSprite00YCoord
ld a, [hl]
2018-01-10 10:47:57 -08:00
cp 6 + 2 * TILE_WIDTH
ret z
; Move all 30 parts of the crystal down by 2
ld c, 30
.loop
ld a, [hl]
add 2
2018-01-10 10:47:57 -08:00
ld [hli], a ; y
rept SPRITEOAMSTRUCT_LENGTH - 1
inc hl
2018-01-10 10:47:57 -08:00
endr
dec c
jr nz, .loop
ret
2018-06-24 07:09:41 -07:00
TitleSuicuneGFX:
2017-06-21 20:45:01 -07:00
INCBIN "gfx/title/suicune.2bpp.lz"
2018-06-24 07:09:41 -07:00
TitleLogoGFX:
2017-06-21 20:45:01 -07:00
INCBIN "gfx/title/logo.2bpp.lz"
2018-06-24 07:09:41 -07:00
TitleCrystalGFX:
2017-06-21 20:45:01 -07:00
INCBIN "gfx/title/crystal.2bpp.lz"
TitleScreenPalettes:
INCLUDE "gfx/title/title.pal"