pokecrystal/engine/trainer_card.asm

617 lines
9.5 KiB
NASM
Raw Normal View History

2015-11-17 22:56:49 +00:00
TrainerCard: ; 25105
2015-11-17 20:54:03 +00:00
ld a, [VramState]
push af
xor a
ld [VramState], a
ld hl, Options
ld a, [hl]
push af
set 4, [hl]
2015-12-28 15:57:04 +00:00
call .InitRAM
.loop
2015-11-17 20:54:03 +00:00
call UpdateTime
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
2015-12-28 15:57:04 +00:00
jr nz, .quit
2015-11-17 20:54:03 +00:00
ld a, [hJoyLast]
and B_BUTTON
2015-12-28 15:57:04 +00:00
jr nz, .quit
call .RunJumptable
2015-11-17 20:54:03 +00:00
call DelayFrame
2015-12-28 15:57:04 +00:00
jr .loop
.quit
2015-11-17 20:54:03 +00:00
pop af
ld [Options], a
pop af
ld [VramState], a
ret
2015-12-28 15:57:04 +00:00
.InitRAM: ; 2513b (9:513b)
2015-11-17 20:54:03 +00:00
call ClearBGPalettes
call ClearSprites
call ClearTileMap
call DisableLCD
2015-12-28 15:57:04 +00:00
callba GetCardPic
2015-11-17 20:54:03 +00:00
ld hl, CardRightCornerGFX
ld de, VTiles2 tile $1c
ld bc, 1 tiles
ld a, BANK(CardRightCornerGFX)
call FarCopyBytes
ld hl, CardStatusGFX
ld de, VTiles2 tile $29
2015-12-28 15:57:04 +00:00
ld bc, 86 tiles
2015-11-17 20:54:03 +00:00
ld a, BANK(CardStatusGFX)
call FarCopyBytes
2015-12-28 15:57:04 +00:00
call TrainerCard_PrintTopHalfOfCard
2015-11-17 20:54:03 +00:00
hlcoord 0, 8
2015-12-28 15:57:04 +00:00
ld d, 6
call TrainerCard_InitBorder
2015-11-17 20:54:03 +00:00
call EnableLCD
call WaitBGMap
2015-12-28 15:57:04 +00:00
ld b, SCGB_TRAINER_CARD
2015-11-17 20:54:03 +00:00
call GetSGBLayout
call SetPalettes
call WaitBGMap
ld hl, wJumptableIndex
xor a
rept 3
ld [hli], a
endr
ld [hl], a
ret
2015-12-28 15:57:04 +00:00
.RunJumptable: ; 2518e (9:518e)
jumptable .Jumptable, wJumptableIndex
2015-11-17 20:54:03 +00:00
2015-12-28 15:57:04 +00:00
.Jumptable: ; 2519d (9:519d)
dw TrainerCard_Page1_LoadGFX
dw TrainerCard_Page1_Joypad
dw TrainerCard_Page2_LoadGFX
dw TrainerCard_Page2_Joypad
dw TrainerCard_Page3_LoadGFX
dw TrainerCard_Page3_Joypad
dw TrainerCard_Quit
2015-11-17 20:54:03 +00:00
2015-12-28 15:57:04 +00:00
TrainerCard_IncrementJumptable: ; 251ab (9:51ab)
2015-11-17 20:54:03 +00:00
ld hl, wJumptableIndex
inc [hl]
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Quit: ; 251b0 (9:51b0)
2015-11-17 20:54:03 +00:00
ld hl, wJumptableIndex
set 7, [hl]
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Page1_LoadGFX: ; 251b6 (9:51b6)
2015-11-17 20:54:03 +00:00
call ClearSprites
hlcoord 0, 8
2015-12-28 15:57:04 +00:00
ld d, 6
call TrainerCard_InitBorder
2015-11-17 20:54:03 +00:00
call WaitBGMap
ld de, CardStatusGFX
ld hl, VTiles2 tile $29
2015-12-28 15:57:04 +00:00
lb bc, BANK(CardStatusGFX), 86
2015-11-17 20:54:03 +00:00
call Request2bpp
2015-12-28 15:57:04 +00:00
call TrainerCard_Page1_PrintDexCaught_GameTime
call TrainerCard_IncrementJumptable
2015-11-17 20:54:03 +00:00
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Page1_Joypad: ; 251d7 (9:51d7)
call TrainerCard_Page1_PrintGameTime
2015-11-17 20:54:03 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_RIGHT | A_BUTTON
jr nz, .pressed_right_a
ret
.pressed_right_a
ld a, $2
ld [wJumptableIndex], a
ret
2015-12-28 15:57:04 +00:00
.KantoCheck
; unreferenced
2015-11-17 20:54:03 +00:00
ld a, [KantoBadges]
and a
ret z
ld a, $4
ld [wJumptableIndex], a
ret
2015-12-28 15:57:04 +00:00
2015-11-17 20:54:03 +00:00
; 251f4
2015-12-28 15:57:04 +00:00
TrainerCard_Page2_LoadGFX: ; 251f4 (9:51f4)
2015-11-17 20:54:03 +00:00
call ClearSprites
hlcoord 0, 8
2015-12-28 15:57:04 +00:00
ld d, 6
call TrainerCard_InitBorder
2015-11-17 20:54:03 +00:00
call WaitBGMap
ld de, LeaderGFX
ld hl, VTiles2 tile $29
lb bc, BANK(LeaderGFX), $56
call Request2bpp
ld de, BadgeGFX
ld hl, VTiles0 tile $00
lb bc, BANK(BadgeGFX), $2c
call Request2bpp
2015-12-28 15:57:04 +00:00
call TrainerCard_Page2_3_InitObjectsAndStrings
call TrainerCard_IncrementJumptable
2015-11-17 20:54:03 +00:00
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Page2_Joypad: ; 25221 (9:5221)
ld hl, TrainerCard_JohtoBadgesOAM
call TrainerCard_Page2_3_AnimateBadges
2015-11-17 20:54:03 +00:00
ld hl, hJoyLast
ld a, [hl]
and A_BUTTON
2015-12-28 15:57:04 +00:00
jr nz, .Quit
2015-11-17 20:54:03 +00:00
ld a, [hl]
and D_LEFT
2015-12-28 15:57:04 +00:00
jr nz, .d_left
2015-11-17 20:54:03 +00:00
ret
2015-12-28 15:57:04 +00:00
.d_left
2015-11-17 20:54:03 +00:00
ld a, $0
ld [wJumptableIndex], a
ret
2015-12-28 15:57:04 +00:00
.KantoCheck
; unreferenced
2015-11-17 20:54:03 +00:00
ld a, [KantoBadges]
and a
ret z
ld a, $4
ld [wJumptableIndex], a
ret
2015-12-28 15:57:04 +00:00
.Quit
2015-11-17 20:54:03 +00:00
ld a, $6
ld [wJumptableIndex], a
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Page3_LoadGFX: ; 2524c (9:524c)
2015-11-17 20:54:03 +00:00
call ClearSprites
hlcoord 0, 8
2015-12-28 15:57:04 +00:00
ld d, 6
call TrainerCard_InitBorder
2015-11-17 20:54:03 +00:00
call WaitBGMap
ld de, LeaderGFX2
ld hl, VTiles2 tile $29
lb bc, BANK(LeaderGFX2), $56
call Request2bpp
ld de, BadgeGFX2
ld hl, VTiles0 tile $00
lb bc, BANK(BadgeGFX2), $2c
call Request2bpp
2015-12-28 15:57:04 +00:00
call TrainerCard_Page2_3_InitObjectsAndStrings
call TrainerCard_IncrementJumptable
2015-11-17 20:54:03 +00:00
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Page3_Joypad: ; 25279 (9:5279)
ld hl, TrainerCard_JohtoBadgesOAM
call TrainerCard_Page2_3_AnimateBadges
2015-11-17 20:54:03 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_LEFT
2015-11-17 22:56:49 +00:00
jr nz, .left
2015-11-17 20:54:03 +00:00
ld a, [hl]
and D_RIGHT
2015-11-17 22:56:49 +00:00
jr nz, .right
2015-11-17 20:54:03 +00:00
ret
2015-11-17 22:56:49 +00:00
.left
2015-11-17 20:54:03 +00:00
ld a, $2
ld [wJumptableIndex], a
ret
2015-11-17 22:56:49 +00:00
.right
2015-11-17 20:54:03 +00:00
ld a, $0
ld [wJumptableIndex], a
ret
2015-12-28 15:57:04 +00:00
TrainerCard_PrintTopHalfOfCard: ; 25299 (9:5299)
2015-11-17 20:54:03 +00:00
hlcoord 0, 0
2015-12-28 15:57:04 +00:00
ld d, 5
call TrainerCard_InitBorder
2015-11-17 20:54:03 +00:00
hlcoord 2, 2
2015-12-28 15:57:04 +00:00
ld de, .Name_Money
2015-11-17 20:54:03 +00:00
call PlaceString
hlcoord 2, 4
2015-12-28 15:57:04 +00:00
ld de, .ID_No
call TrainerCardSetup_PlaceTilemapString
2015-11-17 20:54:03 +00:00
hlcoord 7, 2
ld de, PlayerName
call PlaceString
hlcoord 5, 4
ld de, PlayerID
lb bc, PRINTNUM_LEADINGZEROS | 2, 5
call PrintNum
hlcoord 7, 6
ld de, Money
lb bc, PRINTNUM_MONEY | 3, 6
call PrintNum
hlcoord 1, 3
2015-12-28 15:57:04 +00:00
ld de, .HorizontalDivider
call TrainerCardSetup_PlaceTilemapString
2015-11-17 20:54:03 +00:00
hlcoord 14, 1
lb bc, 5, 7
xor a
ld [hFillBox], a
predef FillBox
ret
2015-12-28 15:57:04 +00:00
2015-11-17 20:54:03 +00:00
; 252ec (9:52ec)
2015-12-28 15:57:04 +00:00
.Name_Money: ; 252ec
2015-11-17 20:54:03 +00:00
db "NAME/"
next ""
next "MONEY@"
2015-12-28 15:57:04 +00:00
.ID_No: ; 252f9
2015-11-17 20:54:03 +00:00
db $27, $28, $ff ; ID NO
2015-12-28 15:57:04 +00:00
.HorizontalDivider: ; 252fc
2015-11-17 20:54:03 +00:00
db $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $25, $26, $ff ; ____________>
; 2530a
2015-12-28 15:57:04 +00:00
TrainerCard_Page1_PrintDexCaught_GameTime: ; 2530a (9:530a)
2015-11-17 20:54:03 +00:00
hlcoord 2, 10
2015-12-28 15:57:04 +00:00
ld de, .Dex_PlayTime
2015-11-17 20:54:03 +00:00
call PlaceString
hlcoord 10, 15
2015-12-28 15:57:04 +00:00
ld de, .Badges
2015-11-17 20:54:03 +00:00
call PlaceString
ld hl, PokedexCaught
2015-12-28 15:57:04 +00:00
ld b, EndPokedexCaught - PokedexCaught
2015-11-17 20:54:03 +00:00
call CountSetBits
ld de, wd265
hlcoord 15, 10
lb bc, 1, 3
call PrintNum
2015-12-28 15:57:04 +00:00
call TrainerCard_Page1_PrintGameTime
2015-11-17 20:54:03 +00:00
hlcoord 2, 8
2015-12-28 15:57:04 +00:00
ld de, .StatusTilemap
call TrainerCardSetup_PlaceTilemapString
2015-11-17 20:54:03 +00:00
ld a, [StatusFlags] ; pokedex
bit 0, a
ret nz
hlcoord 1, 9
lb bc, 2, 17
call ClearBox
ret
2015-12-28 15:57:04 +00:00
.Dex_PlayTime
2015-11-17 20:54:03 +00:00
db "#DEX"
2015-12-28 15:57:04 +00:00
next "PLAY TIME@@"
2015-11-17 20:54:03 +00:00
2015-12-28 15:57:04 +00:00
.Badges
2015-11-17 20:54:03 +00:00
db " BADGES▶@"
2015-12-28 15:57:04 +00:00
.StatusTilemap: ; 25366
2015-11-17 20:54:03 +00:00
db $29, $2a, $2b, $2c, $2d, $ff
; 2536c
2015-12-28 15:57:04 +00:00
TrainerCard_Page2_3_InitObjectsAndStrings: ; 2536c (9:536c)
2015-11-17 20:54:03 +00:00
hlcoord 2, 8
2015-12-28 15:57:04 +00:00
ld de, .BadgesTilemap
call TrainerCardSetup_PlaceTilemapString
2015-11-17 20:54:03 +00:00
hlcoord 2, 10
ld a, $29
2015-12-28 15:57:04 +00:00
ld c, 4
.loop
call TrainerCard_Page2_3_PlaceLeadersFaces
2015-11-17 20:54:03 +00:00
rept 4
inc hl
endr
dec c
2015-12-28 15:57:04 +00:00
jr nz, .loop
2015-11-17 20:54:03 +00:00
hlcoord 2, 13
ld a, $51
2015-12-28 15:57:04 +00:00
ld c, 4
.loop2
call TrainerCard_Page2_3_PlaceLeadersFaces
2015-11-17 20:54:03 +00:00
rept 4
inc hl
endr
dec c
2015-12-28 15:57:04 +00:00
jr nz, .loop2
2015-11-17 20:54:03 +00:00
xor a
ld [wcf64], a
2015-12-28 15:57:04 +00:00
ld hl, TrainerCard_JohtoBadgesOAM
call TrainerCard_Page2_3_OAMUpdate
2015-11-17 20:54:03 +00:00
ret
2015-12-28 15:57:04 +00:00
2015-11-17 20:54:03 +00:00
; 253a2 (9:53a2)
2015-12-28 15:57:04 +00:00
.BadgesTilemap: ; 253a2
2015-11-17 20:54:03 +00:00
db $79, $7a, $7b, $7c, $7d, $ff ; "BADGES"
; 253a8
2015-12-28 15:57:04 +00:00
TrainerCardSetup_PlaceTilemapString: ; 253a8 (9:53a8)
.loop
2015-11-17 20:54:03 +00:00
ld a, [de]
cp $ff
ret z
ld [hli], a
inc de
2015-12-28 15:57:04 +00:00
jr .loop
2015-11-17 20:54:03 +00:00
2015-12-28 15:57:04 +00:00
TrainerCard_InitBorder: ; 253b0 (9:53b0)
ld e, 20
.loop1
2015-11-17 20:54:03 +00:00
ld a, $23
ld [hli], a
dec e
2015-12-28 15:57:04 +00:00
jr nz, .loop1
2015-11-17 20:54:03 +00:00
ld a, $23
ld [hli], a
2015-12-28 15:57:04 +00:00
ld e, 17
ld a, " "
.loop2
2015-11-17 20:54:03 +00:00
ld [hli], a
dec e
2015-12-28 15:57:04 +00:00
jr nz, .loop2
2015-11-17 20:54:03 +00:00
ld a, $1c
ld [hli], a
ld a, $23
ld [hli], a
2015-12-28 15:57:04 +00:00
.loop3
2015-11-17 20:54:03 +00:00
ld a, $23
ld [hli], a
2015-12-28 15:57:04 +00:00
ld e, 18
ld a, " "
.loop4
2015-11-17 20:54:03 +00:00
ld [hli], a
dec e
2015-12-28 15:57:04 +00:00
jr nz, .loop4
2015-11-17 20:54:03 +00:00
ld a, $23
ld [hli], a
dec d
2015-12-28 15:57:04 +00:00
jr nz, .loop3
2015-11-17 20:54:03 +00:00
ld a, $23
ld [hli], a
ld a, $24
ld [hli], a
2015-12-28 15:57:04 +00:00
ld e, 17
ld a, " "
.loop5
2015-11-17 20:54:03 +00:00
ld [hli], a
dec e
2015-12-28 15:57:04 +00:00
jr nz, .loop5
2015-11-17 20:54:03 +00:00
ld a, $23
ld [hli], a
2015-12-28 15:57:04 +00:00
ld e, 20
.loop6
2015-11-17 20:54:03 +00:00
ld a, $23
ld [hli], a
dec e
2015-12-28 15:57:04 +00:00
jr nz, .loop6
2015-11-17 20:54:03 +00:00
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Page2_3_PlaceLeadersFaces: ; 253f4 (9:53f4)
2015-11-17 20:54:03 +00:00
push de
push hl
ld [hli], a
inc a
ld [hli], a
inc a
ld [hli], a
inc a
ld [hli], a
inc a
2015-12-28 15:57:04 +00:00
ld de, SCREEN_WIDTH - 3
2015-11-17 20:54:03 +00:00
add hl, de
ld [hli], a
inc a
ld [hli], a
inc a
ld [hli], a
inc a
2015-12-28 15:57:04 +00:00
ld de, SCREEN_WIDTH - 3
2015-11-17 20:54:03 +00:00
add hl, de
ld [hli], a
inc a
ld [hli], a
inc a
ld [hli], a
inc a
pop hl
pop de
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Page1_PrintGameTime: ; 25415 (9:5415)
2015-11-17 20:54:03 +00:00
hlcoord 11, 12
ld de, GameTimeHours
lb bc, 2, 4
call PrintNum
inc hl
ld de, GameTimeMinutes
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
ld a, [hVBlankCounter]
and $1f
ret nz
hlcoord 15, 12
ld a, [hl]
2015-12-28 15:57:04 +00:00
xor %01010001 ; $7F <--> $2E
2015-11-17 20:54:03 +00:00
ld [hl], a
ret
2015-12-28 15:57:04 +00:00
TrainerCard_Page2_3_AnimateBadges: ; 25438 (9:5438)
2015-11-17 20:54:03 +00:00
ld a, [hVBlankCounter]
and $7
ret nz
ld a, [wcf64]
inc a
and $7
ld [wcf64], a
2015-12-28 15:57:04 +00:00
jr TrainerCard_Page2_3_OAMUpdate
2015-11-17 20:54:03 +00:00
2015-12-28 15:57:04 +00:00
TrainerCard_Page2_3_OAMUpdate: ; 25448 (9:5448)
2015-11-17 22:56:49 +00:00
; copy flag array pointer
2015-11-17 20:54:03 +00:00
ld a, [hli]
ld e, a
ld a, [hli]
2015-11-17 22:56:49 +00:00
; get flag array
2015-11-17 20:54:03 +00:00
ld d, a
ld a, [de]
ld c, a
ld de, Sprites
ld b, 8
2015-11-17 22:56:49 +00:00
.loop
2015-11-17 20:54:03 +00:00
srl c
push bc
2015-11-17 22:56:49 +00:00
jr nc, .skip_badge
2015-11-17 20:54:03 +00:00
push hl
2015-11-17 22:56:49 +00:00
ld a, [hli] ; y
2015-11-17 20:54:03 +00:00
ld b, a
2015-11-17 22:56:49 +00:00
ld a, [hli] ; x
2015-11-17 20:54:03 +00:00
ld c, a
2015-11-17 22:56:49 +00:00
ld a, [hli] ; pal
2015-11-17 20:54:03 +00:00
ld [wcf66], a
ld a, [wcf64]
add l
ld l, a
ld a, 0
adc h
ld h, a
ld a, [hl]
ld [wcf65], a
2015-12-28 15:57:04 +00:00
call .PrepOAM
2015-11-17 20:54:03 +00:00
pop hl
2015-11-17 22:56:49 +00:00
.skip_badge
ld bc, $b ; 3 + 2 * 4
2015-11-17 20:54:03 +00:00
add hl, bc
pop bc
dec b
2015-11-17 22:56:49 +00:00
jr nz, .loop
2015-11-17 20:54:03 +00:00
ret
2015-12-28 15:57:04 +00:00
.PrepOAM: ; 2547b (9:547b)
2015-11-17 20:54:03 +00:00
ld a, [wcf65]
and $80
2015-11-17 22:56:49 +00:00
jr nz, .xflip
ld hl, .facing1
2015-12-28 15:57:04 +00:00
jr .loop2
2015-11-17 22:56:49 +00:00
.xflip
ld hl, .facing2
2015-12-28 15:57:04 +00:00
.loop2
2015-11-17 20:54:03 +00:00
ld a, [hli]
cp $ff
ret z
add b
ld [de], a
inc de
2015-11-17 22:56:49 +00:00
2015-11-17 20:54:03 +00:00
ld a, [hli]
add c
ld [de], a
inc de
2015-11-17 22:56:49 +00:00
2015-11-17 20:54:03 +00:00
ld a, [wcf65]
and $7f
add [hl]
ld [de], a
inc hl
inc de
2015-11-17 22:56:49 +00:00
2015-11-17 20:54:03 +00:00
ld a, [wcf66]
add [hl]
ld [de], a
inc hl
inc de
2015-12-28 15:57:04 +00:00
jr .loop2
2015-11-17 20:54:03 +00:00
; 254a7 (9:54a7)
2015-11-17 22:56:49 +00:00
.facing1: ; 254a7
; y, x, tile, OAM attributes
db 0, 0, 0, 0
db 0, 8, 1, 0
db 8, 0, 2, 0
db 8, 8, 3, 0
db -1
.facing2: ; 254b8
db 0, 0, 1, X_FLIP
db 0, 8, 0, X_FLIP
db 8, 0, 3, X_FLIP
db 8, 8, 2, X_FLIP
db -1
2015-11-17 20:54:03 +00:00
2015-12-28 15:57:04 +00:00
TrainerCard_JohtoBadgesOAM: ; 254c9
2015-11-17 20:54:03 +00:00
; Template OAM data for each badge on the trainer card.
; Format:
; y, x, palette
; cycle 1: face tile, in1 tile, in2 tile, in3 tile
; cycle 2: face tile, in1 tile, in2 tile, in3 tile
dw JohtoBadges
; Zephyrbadge
2015-11-17 22:56:49 +00:00
db $68, $18, 0
2015-11-17 20:54:03 +00:00
db $00, $20, $24, $20 | $80
db $00, $20, $24, $20 | $80
; Hivebadge
2015-11-17 22:56:49 +00:00
db $68, $38, 0
2015-11-17 20:54:03 +00:00
db $04, $20, $24, $20 | $80
db $04, $20, $24, $20 | $80
; Plainbadge
2015-11-17 22:56:49 +00:00
db $68, $58, 0
2015-11-17 20:54:03 +00:00
db $08, $20, $24, $20 | $80
db $08, $20, $24, $20 | $80
; Fogbadge
2015-11-17 22:56:49 +00:00
db $68, $78, 0
2015-11-17 20:54:03 +00:00
db $0c, $20, $24, $20 | $80
db $0c, $20, $24, $20 | $80
; Mineralbadge
2015-11-17 22:56:49 +00:00
db $80, $38, 0
2015-11-17 20:54:03 +00:00
db $10, $20, $24, $20 | $80
db $10, $20, $24, $20 | $80
; Stormbadge
2015-11-17 22:56:49 +00:00
db $80, $18, 0
2015-11-17 20:54:03 +00:00
db $14, $20, $24, $20 | $80
db $14, $20, $24, $20 | $80
; Glacierbadge
2015-11-17 22:56:49 +00:00
db $80, $58, 0
2015-11-17 20:54:03 +00:00
db $18, $20, $24, $20 | $80
db $18, $20, $24, $20 | $80
; Risingbadge
; X-flips on alternate cycles.
2015-11-17 22:56:49 +00:00
db $80, $78, 0
2015-11-17 20:54:03 +00:00
db $1c, $20, $24, $20 | $80
db $1c | $80, $20, $24, $20 | $80
; 25523
CardStatusGFX: INCBIN "gfx/misc/card_status.2bpp"
LeaderGFX: INCBIN "gfx/misc/leaders.w24.2bpp"
LeaderGFX2: INCBIN "gfx/misc/leaders.w24.2bpp"
BadgeGFX: INCBIN "gfx/misc/badges.2bpp"
BadgeGFX2: INCBIN "gfx/misc/badges.2bpp"
CardRightCornerGFX: INCBIN "gfx/misc/card_right_corner.2bpp"