pokecrystal-board/engine/menus/naming_screen.asm

1354 lines
21 KiB
NASM
Raw Normal View History

DEF NAMINGSCREEN_CURSOR EQU $7e
DEF NAMINGSCREEN_BORDER EQU "■" ; $ba
DEF NAMINGSCREEN_MIDDLELINE EQU "▲" ; $bb
DEF NAMINGSCREEN_UNDERLINE EQU "☎" ; $bc
_NamingScreen:
2015-11-11 13:11:08 -08:00
call DisableSpriteUpdates
call NamingScreen
2015-12-18 17:07:09 -08:00
call ReturnToMapWithSpeechTextbox
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
NamingScreen:
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenDestinationPointer
2015-11-11 13:11:08 -08:00
ld [hl], e
inc hl
ld [hl], d
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenType
2015-11-11 13:11:08 -08:00
ld [hl], b
2018-01-23 14:39:09 -08:00
ld hl, wOptions
2015-11-11 13:11:08 -08:00
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ldh a, [hMapAnims]
2015-11-11 13:11:08 -08:00
push af
xor a
ldh [hMapAnims], a
ldh a, [hInMenu]
2015-11-11 13:11:08 -08:00
push af
ld a, $1
ldh [hInMenu], a
2016-01-09 13:28:22 -08:00
call .SetUpNamingScreen
2015-11-11 13:11:08 -08:00
call DelayFrame
2016-01-09 13:28:22 -08:00
.loop
call NamingScreenJoypadLoop
jr nc, .loop
2015-11-11 13:11:08 -08:00
pop af
ldh [hInMenu], a
2015-11-11 13:11:08 -08:00
pop af
ldh [hMapAnims], a
2015-11-11 13:11:08 -08:00
pop af
2018-01-23 14:39:09 -08:00
ld [wOptions], a
2015-11-11 13:11:08 -08:00
call ClearJoypad
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.SetUpNamingScreen:
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
ld b, CGB_DIPLOMA
call GetCGBLayout
2015-11-11 13:11:08 -08:00
call DisableLCD
2016-01-09 13:28:22 -08:00
call LoadNamingScreenGFX
call NamingScreen_InitText
2017-12-29 10:22:33 -08:00
ld a, LCDC_DEFAULT
ldh [rLCDC], a
2016-01-09 13:28:22 -08:00
call .GetNamingScreenSetup
2015-11-11 13:11:08 -08:00
call WaitBGMap
call WaitTop
2024-02-10 15:16:00 -08:00
call SetDefaultBGPAndOBP
2016-01-09 13:28:22 -08:00
call NamingScreen_InitNameEntry
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.GetNamingScreenSetup:
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenType]
2018-09-16 13:02:58 -07:00
maskbits NUM_NAME_TYPES
2015-11-11 13:11:08 -08:00
ld e, a
ld d, 0
2016-01-09 13:28:22 -08:00
ld hl, .Jumptable
2015-11-11 13:11:08 -08:00
add hl, de
add hl, de
2015-11-11 13:11:08 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
.Jumptable:
2018-09-16 13:02:58 -07:00
; entries correspond to NAME_* constants
2016-01-09 13:28:22 -08:00
dw .Pokemon
dw .Player
dw .Rival
dw .Mom
dw .Box
dw .Pokemon
2016-01-09 13:28:22 -08:00
dw .Pokemon
dw .Pokemon
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
.Pokemon:
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
ld [wTempIconSpecies], a
2016-03-01 19:31:21 -08:00
ld hl, LoadMenuMonIcon
ld a, BANK(LoadMenuMonIcon)
ld e, MONICON_NAMINGSCREEN
rst FarCall
2018-01-23 14:39:09 -08:00
ld a, [wCurPartySpecies]
ld [wNamedObjectIndex], a
2015-11-11 13:11:08 -08:00
call GetPokemonName
hlcoord 5, 2
call PlaceString
ld l, c
ld h, b
2016-01-09 13:28:22 -08:00
ld de, .NicknameStrings
2015-11-11 13:11:08 -08:00
call PlaceString
inc de
hlcoord 5, 4
call PlaceString
farcall GetGender
2016-01-09 13:28:22 -08:00
jr c, .genderless
ld a, "♂"
jr nz, .place_gender
ld a, "♀"
.place_gender
2015-11-11 13:11:08 -08:00
hlcoord 1, 2
ld [hl], a
2016-01-09 13:28:22 -08:00
.genderless
call .StoreMonIconParams
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.NicknameStrings:
2015-11-11 13:11:08 -08:00
db "'S@"
db "NICKNAME?@"
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Player:
2017-12-24 09:47:30 -08:00
farcall GetPlayerIcon
2016-01-09 13:28:22 -08:00
call .LoadSprite
2015-11-11 13:11:08 -08:00
hlcoord 5, 2
2016-01-09 13:28:22 -08:00
ld de, .PlayerNameString
2015-11-11 13:11:08 -08:00
call PlaceString
2016-01-09 13:28:22 -08:00
call .StoreSpriteIconParams
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.PlayerNameString:
2015-11-11 13:11:08 -08:00
db "YOUR NAME?@"
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Rival:
ld de, RivalSpriteGFX
ld b, BANK(RivalSpriteGFX)
2016-01-09 13:28:22 -08:00
call .LoadSprite
2015-11-11 13:11:08 -08:00
hlcoord 5, 2
2016-01-09 13:28:22 -08:00
ld de, .RivalNameString
2015-11-11 13:11:08 -08:00
call PlaceString
2016-01-09 13:28:22 -08:00
call .StoreSpriteIconParams
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.RivalNameString:
2015-11-11 13:11:08 -08:00
db "RIVAL'S NAME?@"
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Mom:
2015-11-11 13:11:08 -08:00
ld de, MomSpriteGFX
ld b, BANK(MomSpriteGFX)
2016-01-09 13:28:22 -08:00
call .LoadSprite
2015-11-11 13:11:08 -08:00
hlcoord 5, 2
2016-01-09 13:28:22 -08:00
ld de, .MomNameString
2015-11-11 13:11:08 -08:00
call PlaceString
2016-01-09 13:28:22 -08:00
call .StoreSpriteIconParams
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.MomNameString:
2015-11-11 13:11:08 -08:00
db "MOTHER'S NAME?@"
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.Box:
2015-11-11 13:11:08 -08:00
ld de, PokeBallSpriteGFX
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $00
2018-01-14 16:43:35 -08:00
lb bc, BANK(PokeBallSpriteGFX), 4
2015-11-11 13:11:08 -08:00
call Request2bpp
2020-10-30 12:39:08 -07:00
xor a ; SPRITE_ANIM_DICT_DEFAULT and tile offset $00
2016-01-09 20:41:03 -08:00
ld hl, wSpriteAnimDict
2015-11-11 13:11:08 -08:00
ld [hli], a
ld [hl], a
2015-11-18 10:01:55 -08:00
depixel 4, 4, 4, 0
2023-09-24 06:06:19 -07:00
ld a, SPRITE_ANIM_OBJ_RED_WALK
call InitSpriteAnimStruct
2015-12-05 12:38:25 -08:00
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], $0
hlcoord 5, 2
2016-01-09 13:28:22 -08:00
ld de, .BoxNameString
2015-11-11 13:11:08 -08:00
call PlaceString
2016-01-09 13:28:22 -08:00
call .StoreBoxIconParams
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.BoxNameString:
2015-11-11 13:11:08 -08:00
db "BOX NAME?@"
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.LoadSprite:
2015-11-11 13:11:08 -08:00
push de
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $00
2020-06-18 07:11:12 -07:00
ld c, 4
2015-11-11 13:11:08 -08:00
push bc
call Request2bpp
pop bc
2016-01-09 13:28:22 -08:00
ld hl, 12 tiles
2015-11-11 13:11:08 -08:00
add hl, de
ld e, l
ld d, h
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $04
2015-11-11 13:11:08 -08:00
call Request2bpp
2020-10-30 12:39:08 -07:00
xor a ; SPRITE_ANIM_DICT_DEFAULT and tile offset $00
2016-01-09 20:41:03 -08:00
ld hl, wSpriteAnimDict
2015-11-11 13:11:08 -08:00
ld [hli], a
ld [hl], a
pop de
2023-09-24 06:06:19 -07:00
ld b, SPRITE_ANIM_OBJ_RED_WALK
2015-11-11 13:11:08 -08:00
ld a, d
cp HIGH(KrisSpriteGFX)
2016-01-09 13:28:22 -08:00
jr nz, .not_kris
2015-11-11 13:11:08 -08:00
ld a, e
cp LOW(KrisSpriteGFX)
2016-01-09 13:28:22 -08:00
jr nz, .not_kris
2023-09-24 06:06:19 -07:00
ld b, SPRITE_ANIM_OBJ_BLUE_WALK
2016-01-09 13:28:22 -08:00
.not_kris
2015-11-11 13:11:08 -08:00
ld a, b
2015-11-18 10:01:55 -08:00
depixel 4, 4, 4, 0
call InitSpriteAnimStruct
2015-11-11 13:11:08 -08:00
ret
2018-06-24 07:09:41 -07:00
.StoreMonIconParams:
2018-01-20 09:25:55 -08:00
ld a, MON_NAME_LENGTH - 1
2015-11-11 13:11:08 -08:00
hlcoord 5, 6
2016-01-09 13:28:22 -08:00
jr .StoreParams
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
.StoreSpriteIconParams:
2016-01-09 13:28:22 -08:00
ld a, PLAYER_NAME_LENGTH - 1
2015-11-11 13:11:08 -08:00
hlcoord 5, 6
2016-01-09 13:28:22 -08:00
jr .StoreParams
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
.StoreBoxIconParams:
2016-01-09 13:28:22 -08:00
ld a, BOX_NAME_LENGTH - 1
2015-11-11 13:11:08 -08:00
hlcoord 5, 4
2016-01-09 13:28:22 -08:00
jr .StoreParams
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
.StoreParams:
2016-01-09 13:28:22 -08:00
ld [wNamingScreenMaxNameLength], a
2015-11-11 13:11:08 -08:00
ld a, l
2016-01-09 13:28:22 -08:00
ld [wNamingScreenStringEntryCoord], a
2015-11-11 13:11:08 -08:00
ld a, h
2016-01-09 13:28:22 -08:00
ld [wNamingScreenStringEntryCoord + 1], a
2015-11-11 13:11:08 -08:00
ret
2018-06-24 07:09:41 -07:00
NamingScreen_IsTargetBox:
; Return z if [wNamingScreenType] == NAME_BOX.
2015-11-11 13:11:08 -08:00
push bc
push af
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenType]
sub NAME_BOX - 1
2015-11-11 13:11:08 -08:00
ld b, a
pop af
dec b
pop bc
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
NamingScreen_InitText:
2015-11-11 13:11:08 -08:00
call WaitTop
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, NAMINGSCREEN_BORDER
2015-11-11 13:11:08 -08:00
call ByteFill
hlcoord 1, 1
lb bc, 6, 18
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
jr nz, .not_box
2015-11-11 13:11:08 -08:00
lb bc, 4, 18
2016-01-09 13:28:22 -08:00
.not_box
2015-11-11 13:11:08 -08:00
call ClearBox
ld de, NameInputUpper
2018-06-24 07:09:41 -07:00
NamingScreen_ApplyTextInputMode:
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
jr nz, .not_box
assert BoxNameInputLower - NameInputLower == BoxNameInputUpper - NameInputUpper
2015-11-11 13:11:08 -08:00
ld hl, BoxNameInputLower - NameInputLower
add hl, de
ld d, h
ld e, l
2016-01-09 13:28:22 -08:00
.not_box
2015-11-11 13:11:08 -08:00
push de
hlcoord 1, 8
lb bc, 7, 18
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
jr nz, .not_box_2
2015-11-11 13:11:08 -08:00
hlcoord 1, 6
lb bc, 9, 18
2016-01-09 13:28:22 -08:00
.not_box_2
2015-11-11 13:11:08 -08:00
call ClearBox
hlcoord 1, 16
lb bc, 1, 18
call ClearBox
pop de
hlcoord 2, 8
ld b, $5
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
jr nz, .row
2015-11-11 13:11:08 -08:00
hlcoord 2, 6
ld b, $6
2016-01-09 13:28:22 -08:00
.row
2015-11-11 13:11:08 -08:00
ld c, $11
2016-01-09 13:28:22 -08:00
.col
2015-11-11 13:11:08 -08:00
ld a, [de]
ld [hli], a
inc de
dec c
2016-01-09 13:28:22 -08:00
jr nz, .col
2015-11-11 13:11:08 -08:00
push de
2016-01-09 13:28:22 -08:00
ld de, 2 * SCREEN_WIDTH - $11
2015-11-11 13:11:08 -08:00
add hl, de
pop de
dec b
2016-01-09 13:28:22 -08:00
jr nz, .row
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
NamingScreenJoypadLoop:
2015-11-11 13:11:08 -08:00
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
2016-01-09 13:28:22 -08:00
jr nz, .quit
call .RunJumptable
2017-12-24 09:47:30 -08:00
farcall PlaySpriteAnimationsAndDelayFrame
2016-01-09 13:28:22 -08:00
call .UpdateStringEntry
2015-11-11 13:11:08 -08:00
call DelayFrame
and a
ret
2016-01-09 13:28:22 -08:00
.quit
2017-12-24 09:47:30 -08:00
callfar ClearSpriteAnims
2015-11-11 13:11:08 -08:00
call ClearSprites
xor a
ldh [hSCX], a
ldh [hSCY], a
2015-11-11 13:11:08 -08:00
scf
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.UpdateStringEntry:
2015-11-11 13:11:08 -08:00
xor a
ldh [hBGMapMode], a
2015-11-11 13:11:08 -08:00
hlcoord 1, 5
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
jr nz, .got_coords
2015-11-11 13:11:08 -08:00
hlcoord 1, 3
2016-01-09 13:28:22 -08:00
.got_coords
2015-11-11 13:11:08 -08:00
lb bc, 1, 18
call ClearBox
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenDestinationPointer
2015-11-11 13:11:08 -08:00
ld e, [hl]
inc hl
ld d, [hl]
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenStringEntryCoord
2015-11-11 13:11:08 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
call PlaceString
ld a, $1
ldh [hBGMapMode], a
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.RunJumptable:
jumptable .Jumptable, wJumptableIndex
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
.Jumptable:
2016-01-09 13:28:22 -08:00
dw .InitCursor
dw .ReadButtons
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
.InitCursor:
2015-11-18 10:01:55 -08:00
depixel 10, 3
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
jr nz, .got_cursor_position
2023-07-26 17:50:16 -07:00
ld d, 8 * TILE_WIDTH
2016-01-09 13:28:22 -08:00
.got_cursor_position
2023-09-24 06:06:19 -07:00
ld a, SPRITE_ANIM_OBJ_NAMING_SCREEN_CURSOR
call InitSpriteAnimStruct
2015-11-11 13:11:08 -08:00
ld a, c
2016-01-09 13:28:22 -08:00
ld [wNamingScreenCursorObjectPointer], a
2015-11-11 13:11:08 -08:00
ld a, b
2016-01-09 20:41:03 -08:00
ld [wNamingScreenCursorObjectPointer + 1], a
2015-12-05 12:38:25 -08:00
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
ld hl, SPRITEANIMSTRUCT_VAR3
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], a
ld hl, wJumptableIndex
inc [hl]
ret
2018-06-24 07:09:41 -07:00
.ReadButtons:
2018-08-25 11:39:24 -07:00
ld hl, hJoyPressed
2015-11-11 13:11:08 -08:00
ld a, [hl]
and A_BUTTON
jr nz, .a
ld a, [hl]
and B_BUTTON
jr nz, .b
ld a, [hl]
and START
jr nz, .start
ld a, [hl]
and SELECT
jr nz, .select
ret
.a
2016-01-09 13:28:22 -08:00
call .GetCursorPosition
2015-11-11 13:11:08 -08:00
cp $1
jr z, .select
cp $2
jr z, .b
cp $3
2016-01-09 13:28:22 -08:00
jr z, .end
call NamingScreen_GetLastCharacter
call NamingScreen_TryAddCharacter
2015-11-11 13:11:08 -08:00
ret nc
.start
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenCursorObjectPointer
2015-11-11 13:11:08 -08:00
ld c, [hl]
inc hl
ld b, [hl]
ld hl, SPRITEANIMSTRUCT_VAR1
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], $8
ld hl, SPRITEANIMSTRUCT_VAR2
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], $4
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
2015-11-11 13:11:08 -08:00
ret nz
inc [hl]
ret
.b
2016-01-09 13:28:22 -08:00
call NamingScreen_DeleteCharacter
2015-11-11 13:11:08 -08:00
ret
2016-01-09 13:28:22 -08:00
.end
call NamingScreen_StoreEntry
2015-11-11 13:11:08 -08:00
ld hl, wJumptableIndex
set 7, [hl]
ret
.select
2018-01-11 12:36:11 -08:00
ld hl, wNamingScreenLetterCase
2015-11-11 13:11:08 -08:00
ld a, [hl]
xor 1
ld [hl], a
2016-01-09 13:28:22 -08:00
jr z, .upper
2015-11-11 13:11:08 -08:00
ld de, NameInputLower
2016-01-09 13:28:22 -08:00
call NamingScreen_ApplyTextInputMode
2015-11-11 13:11:08 -08:00
ret
2016-01-09 13:28:22 -08:00
.upper
2015-11-11 13:11:08 -08:00
ld de, NameInputUpper
2016-01-09 13:28:22 -08:00
call NamingScreen_ApplyTextInputMode
2015-11-11 13:11:08 -08:00
ret
2018-06-24 07:09:41 -07:00
.GetCursorPosition:
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenCursorObjectPointer
2015-11-11 13:11:08 -08:00
ld c, [hl]
inc hl
ld b, [hl]
2018-06-24 07:09:41 -07:00
NamingScreen_GetCursorPosition:
ld hl, SPRITEANIMSTRUCT_VAR2
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
push bc
ld b, $4
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
jr nz, .not_box
2015-11-11 13:11:08 -08:00
inc b
2016-01-09 13:28:22 -08:00
.not_box
2015-11-11 13:11:08 -08:00
cp b
pop bc
2016-01-09 13:28:22 -08:00
jr nz, .not_bottom_row
ld hl, SPRITEANIMSTRUCT_VAR1
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
cp $3
2016-01-09 13:28:22 -08:00
jr c, .case_switch
2015-11-11 13:11:08 -08:00
cp $6
2016-01-09 13:28:22 -08:00
jr c, .delete
2015-11-11 13:11:08 -08:00
ld a, $3
ret
2016-01-09 13:28:22 -08:00
.case_switch
2015-11-11 13:11:08 -08:00
ld a, $1
ret
2016-01-09 13:28:22 -08:00
.delete
2015-11-11 13:11:08 -08:00
ld a, $2
ret
2016-01-09 13:28:22 -08:00
.not_bottom_row
2015-11-11 13:11:08 -08:00
xor a
ret
2018-06-24 07:09:41 -07:00
NamingScreen_AnimateCursor:
2016-01-09 13:28:22 -08:00
call .GetDPad
ld hl, SPRITEANIMSTRUCT_VAR2
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
ld e, a
swap e
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_YOFFSET
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], e
ld d, $4
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
jr nz, .ok
2015-11-11 13:11:08 -08:00
inc d
2016-01-09 13:28:22 -08:00
.ok
2015-11-11 13:11:08 -08:00
cp d
2016-01-09 13:28:22 -08:00
ld de, .LetterEntries
ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 0
2016-01-09 13:28:22 -08:00
jr nz, .ok2
ld de, .CaseDelEnd
ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR_BIG - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 1
2016-01-09 13:28:22 -08:00
.ok2
ld hl, SPRITEANIMSTRUCT_VAR3
2015-11-11 13:11:08 -08:00
add hl, bc
add [hl] ; default SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR
2015-12-05 12:38:25 -08:00
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], a
ld hl, SPRITEANIMSTRUCT_VAR1
2015-11-11 13:11:08 -08:00
add hl, bc
ld l, [hl]
ld h, $0
add hl, de
ld a, [hl]
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_XOFFSET
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], a
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.LetterEntries:
2015-11-11 13:11:08 -08:00
db $00, $10, $20, $30, $40, $50, $60, $70, $80
2016-01-09 13:28:22 -08:00
2018-06-24 07:09:41 -07:00
.CaseDelEnd:
2015-11-11 13:11:08 -08:00
db $00, $00, $00, $30, $30, $30, $60, $60, $60
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.GetDPad:
2015-11-11 13:11:08 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .up
ld a, [hl]
and D_DOWN
jr nz, .down
ld a, [hl]
and D_LEFT
jr nz, .left
ld a, [hl]
and D_RIGHT
jr nz, .right
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.right
2016-01-09 13:28:22 -08:00
call NamingScreen_GetCursorPosition
2015-11-11 13:11:08 -08:00
and a
2020-10-06 10:50:02 -07:00
jr nz, .target_right
ld hl, SPRITEANIMSTRUCT_VAR1
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
cp $8
2020-10-06 10:50:02 -07:00
jr nc, .wrap_left
2015-11-11 13:11:08 -08:00
inc [hl]
ret
2016-01-09 20:41:03 -08:00
2020-10-06 10:50:02 -07:00
.wrap_left
2015-11-11 13:11:08 -08:00
ld [hl], $0
ret
2016-01-09 20:41:03 -08:00
2020-10-06 10:50:02 -07:00
.target_right
2015-11-11 13:11:08 -08:00
cp $3
2020-10-06 10:50:02 -07:00
jr nz, .no_wrap_target_left
2015-11-11 13:11:08 -08:00
xor a
2020-10-06 10:50:02 -07:00
.no_wrap_target_left
2015-11-11 13:11:08 -08:00
ld e, a
add a
add e
ld hl, SPRITEANIMSTRUCT_VAR1
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], a
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.left
2016-01-09 13:28:22 -08:00
call NamingScreen_GetCursorPosition
2015-11-11 13:11:08 -08:00
and a
2020-10-06 10:50:02 -07:00
jr nz, .target_left
ld hl, SPRITEANIMSTRUCT_VAR1
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
and a
2020-10-06 10:50:02 -07:00
jr z, .wrap_right
2015-11-11 13:11:08 -08:00
dec [hl]
ret
2016-01-09 20:41:03 -08:00
2020-10-06 10:50:02 -07:00
.wrap_right
2015-11-11 13:11:08 -08:00
ld [hl], $8
ret
2016-01-09 20:41:03 -08:00
2020-10-06 10:50:02 -07:00
.target_left
2015-11-11 13:11:08 -08:00
cp $1
2020-10-06 10:50:02 -07:00
jr nz, .no_wrap_target_right
2015-11-11 13:11:08 -08:00
ld a, $4
2020-10-06 10:50:02 -07:00
.no_wrap_target_right
2015-11-11 13:11:08 -08:00
dec a
dec a
2015-11-11 13:11:08 -08:00
ld e, a
add a
add e
ld hl, SPRITEANIMSTRUCT_VAR1
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], a
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.down
ld hl, SPRITEANIMSTRUCT_VAR2
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
2020-10-06 10:50:02 -07:00
jr nz, .not_box
2015-11-11 13:11:08 -08:00
cp $5
2020-10-06 10:50:02 -07:00
jr nc, .wrap_up
2015-11-11 13:11:08 -08:00
inc [hl]
ret
2016-01-09 20:41:03 -08:00
2020-10-06 10:50:02 -07:00
.not_box
2015-11-11 13:11:08 -08:00
cp $4
2020-10-06 10:50:02 -07:00
jr nc, .wrap_up
2015-11-11 13:11:08 -08:00
inc [hl]
ret
2016-01-09 20:41:03 -08:00
2020-10-06 10:50:02 -07:00
.wrap_up
2015-11-11 13:11:08 -08:00
ld [hl], $0
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.up
ld hl, SPRITEANIMSTRUCT_VAR2
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
and a
2020-10-06 10:50:02 -07:00
jr z, .wrap_down
2015-11-11 13:11:08 -08:00
dec [hl]
ret
2016-01-09 20:41:03 -08:00
2020-10-06 10:50:02 -07:00
.wrap_down
2015-11-11 13:11:08 -08:00
ld [hl], $4
2016-01-09 13:28:22 -08:00
call NamingScreen_IsTargetBox
2015-11-11 13:11:08 -08:00
ret nz
inc [hl]
ret
2018-06-24 07:09:41 -07:00
NamingScreen_TryAddCharacter:
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenLastCharacter] ; lost
2018-06-24 07:09:41 -07:00
MailComposition_TryAddCharacter:
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenMaxNameLength]
2015-11-11 13:11:08 -08:00
ld c, a
2018-09-09 12:09:51 -07:00
ld a, [wNamingScreenCurNameLength]
2015-11-11 13:11:08 -08:00
cp c
ret nc
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenLastCharacter]
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
NamingScreen_LoadNextCharacter:
2016-01-09 13:28:22 -08:00
call NamingScreen_GetTextCursorPosition
2015-11-11 13:11:08 -08:00
ld [hl], a
2018-06-24 07:09:41 -07:00
NamingScreen_AdvanceCursor_CheckEndOfString:
2018-09-09 12:09:51 -07:00
ld hl, wNamingScreenCurNameLength
2015-11-11 13:11:08 -08:00
inc [hl]
2016-01-09 13:28:22 -08:00
call NamingScreen_GetTextCursorPosition
2015-11-11 13:11:08 -08:00
ld a, [hl]
2016-01-09 13:28:22 -08:00
cp "@"
jr z, .end_of_string
ld [hl], NAMINGSCREEN_UNDERLINE
2015-11-11 13:11:08 -08:00
and a
ret
2016-01-09 13:28:22 -08:00
.end_of_string
2015-11-11 13:11:08 -08:00
scf
ret
2016-01-09 20:41:03 -08:00
AddDakutenToCharacter: ; unreferenced
2018-09-09 12:09:51 -07:00
ld a, [wNamingScreenCurNameLength]
2015-11-11 13:11:08 -08:00
and a
ret z
push hl
2018-09-09 12:09:51 -07:00
ld hl, wNamingScreenCurNameLength
2015-11-11 13:11:08 -08:00
dec [hl]
2016-01-09 13:28:22 -08:00
call NamingScreen_GetTextCursorPosition
2015-11-11 13:11:08 -08:00
ld c, [hl]
pop hl
2016-01-09 13:28:22 -08:00
.loop
2015-11-11 13:11:08 -08:00
ld a, [hli]
2020-06-18 07:11:12 -07:00
cp -1
2016-01-09 13:28:22 -08:00
jr z, NamingScreen_AdvanceCursor_CheckEndOfString
2015-11-11 13:11:08 -08:00
cp c
2016-01-09 13:28:22 -08:00
jr z, .done
2015-11-11 13:11:08 -08:00
inc hl
2016-01-09 13:28:22 -08:00
jr .loop
2015-11-11 13:11:08 -08:00
2016-01-09 13:28:22 -08:00
.done
2015-11-11 13:11:08 -08:00
ld a, [hl]
2016-01-09 13:28:22 -08:00
jr NamingScreen_LoadNextCharacter
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
NamingScreen_DeleteCharacter:
2018-09-09 12:09:51 -07:00
ld hl, wNamingScreenCurNameLength
2015-11-11 13:11:08 -08:00
ld a, [hl]
and a
ret z
dec [hl]
2016-01-09 13:28:22 -08:00
call NamingScreen_GetTextCursorPosition
ld [hl], NAMINGSCREEN_UNDERLINE
2015-11-11 13:11:08 -08:00
inc hl
ld a, [hl]
cp NAMINGSCREEN_UNDERLINE
2015-11-11 13:11:08 -08:00
ret nz
ld [hl], NAMINGSCREEN_MIDDLELINE
2015-11-11 13:11:08 -08:00
ret
2018-06-24 07:09:41 -07:00
NamingScreen_GetTextCursorPosition:
2015-11-11 13:11:08 -08:00
push af
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenDestinationPointer
2015-11-11 13:11:08 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
2018-09-09 12:09:51 -07:00
ld a, [wNamingScreenCurNameLength]
2015-11-11 13:11:08 -08:00
ld e, a
ld d, 0
add hl, de
pop af
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
NamingScreen_InitNameEntry:
; load NAMINGSCREEN_UNDERLINE, (NAMINGSCREEN_MIDDLELINE * [wNamingScreenMaxNameLength]), "@" into the dw address at wNamingScreenDestinationPointer
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenDestinationPointer
2015-11-11 13:11:08 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
ld [hl], NAMINGSCREEN_UNDERLINE
2015-11-11 13:11:08 -08:00
inc hl
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenMaxNameLength]
2015-11-11 13:11:08 -08:00
dec a
ld c, a
ld a, NAMINGSCREEN_MIDDLELINE
2015-11-11 13:11:08 -08:00
.loop
ld [hli], a
dec c
jr nz, .loop
ld [hl], "@"
ret
2018-06-24 07:09:41 -07:00
NamingScreen_StoreEntry:
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenDestinationPointer
2015-11-11 13:11:08 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenMaxNameLength]
2015-11-11 13:11:08 -08:00
ld c, a
2016-01-09 13:28:22 -08:00
.loop
2015-11-11 13:11:08 -08:00
ld a, [hl]
cp NAMINGSCREEN_MIDDLELINE
2016-01-09 13:28:22 -08:00
jr z, .terminator
cp NAMINGSCREEN_UNDERLINE
2016-01-09 13:28:22 -08:00
jr nz, .not_terminator
.terminator
ld [hl], "@"
.not_terminator
2015-11-11 13:11:08 -08:00
inc hl
dec c
2016-01-09 13:28:22 -08:00
jr nz, .loop
2015-11-11 13:11:08 -08:00
ret
2018-06-24 07:09:41 -07:00
NamingScreen_GetLastCharacter:
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenCursorObjectPointer
2015-11-11 13:11:08 -08:00
ld c, [hl]
inc hl
ld b, [hl]
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_XOFFSET
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_XCOORD
2015-11-11 13:11:08 -08:00
add hl, bc
add [hl]
sub $8
srl a
srl a
srl a
ld e, a
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_YOFFSET
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_YCOORD
2015-11-11 13:11:08 -08:00
add hl, bc
add [hl]
sub $10
srl a
srl a
srl a
ld d, a
hlcoord 0, 0
2016-01-09 13:28:22 -08:00
ld bc, SCREEN_WIDTH
.loop
2015-11-11 13:11:08 -08:00
ld a, d
and a
2016-01-09 13:28:22 -08:00
jr z, .done
2015-11-11 13:11:08 -08:00
add hl, bc
dec d
2016-01-09 13:28:22 -08:00
jr .loop
2016-01-09 20:41:03 -08:00
2016-01-09 13:28:22 -08:00
.done
2015-11-11 13:11:08 -08:00
add hl, de
ld a, [hl]
2016-01-09 13:28:22 -08:00
ld [wNamingScreenLastCharacter], a
2015-11-11 13:11:08 -08:00
ret
2018-06-24 07:09:41 -07:00
LoadNamingScreenGFX:
2015-11-11 13:11:08 -08:00
call ClearSprites
2017-12-24 09:47:30 -08:00
callfar ClearSpriteAnims
2015-11-11 13:11:08 -08:00
call LoadStandardFont
call LoadFrame
2015-11-11 13:11:08 -08:00
2016-01-09 13:28:22 -08:00
ld de, NamingScreenGFX_MiddleLine
ld hl, vTiles0 tile NAMINGSCREEN_MIDDLELINE
2016-01-09 13:28:22 -08:00
lb bc, BANK(NamingScreenGFX_MiddleLine), 1
2015-11-11 13:11:08 -08:00
call Get1bpp
2016-01-09 13:28:22 -08:00
ld de, NamingScreenGFX_UnderLine
ld hl, vTiles0 tile NAMINGSCREEN_UNDERLINE
2016-01-09 13:28:22 -08:00
lb bc, BANK(NamingScreenGFX_UnderLine), 1
2015-11-11 13:11:08 -08:00
call Get1bpp
ld de, vTiles0 tile NAMINGSCREEN_BORDER
2016-01-09 13:28:22 -08:00
ld hl, NamingScreenGFX_Border
ld bc, 1 tiles
ld a, BANK(NamingScreenGFX_Border)
2015-11-11 13:11:08 -08:00
call FarCopyBytes
ld de, vTiles0 tile NAMINGSCREEN_CURSOR
2016-01-09 13:28:22 -08:00
ld hl, NamingScreenGFX_Cursor
ld bc, 2 tiles
ld a, BANK(NamingScreenGFX_Cursor)
2015-11-11 13:11:08 -08:00
call FarCopyBytes
2020-10-30 12:39:08 -07:00
ld a, SPRITE_ANIM_DICT_TEXT_CURSOR
ld hl, wSpriteAnimDict + (NUM_SPRITEANIMDICT_ENTRIES - 1) * 2
2015-11-11 13:11:08 -08:00
ld [hli], a
ld [hl], NAMINGSCREEN_CURSOR
2015-11-11 13:11:08 -08:00
xor a
ldh [hSCY], a
2015-12-02 14:59:05 -08:00
ld [wGlobalAnimYOffset], a
ldh [hSCX], a
2015-12-02 14:59:05 -08:00
ld [wGlobalAnimXOffset], a
2015-11-11 13:11:08 -08:00
ld [wJumptableIndex], a
2018-01-11 12:36:11 -08:00
ld [wNamingScreenLetterCase], a
ldh [hBGMapMode], a
2018-09-09 12:09:51 -07:00
ld [wNamingScreenCurNameLength], a
2015-11-11 13:11:08 -08:00
ld a, $7
ldh [hWX], a
2015-11-11 13:11:08 -08:00
ret
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
NamingScreenGFX_Border:
2018-01-21 10:58:16 -08:00
INCBIN "gfx/naming_screen/border.2bpp"
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
NamingScreenGFX_Cursor:
2018-01-21 10:58:16 -08:00
INCBIN "gfx/naming_screen/cursor.2bpp"
2015-11-11 13:11:08 -08:00
2018-01-22 14:33:52 -08:00
INCLUDE "data/text/name_input_chars.asm"
2015-11-11 13:11:08 -08:00
2016-01-09 13:28:22 -08:00
NamingScreenGFX_MiddleLine:
2018-01-21 10:58:16 -08:00
INCBIN "gfx/naming_screen/middle_line.1bpp"
2015-11-11 13:11:08 -08:00
2018-06-24 07:09:41 -07:00
NamingScreenGFX_UnderLine:
2018-01-21 10:58:16 -08:00
INCBIN "gfx/naming_screen/underline.1bpp"
2016-01-09 13:28:22 -08:00
2018-06-24 18:39:23 -07:00
_ComposeMailMessage:
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenDestinationPointer
ld [hl], e
inc hl
ld [hl], d
ldh a, [hMapAnims]
2016-01-09 13:28:22 -08:00
push af
xor a
ldh [hMapAnims], a
ldh a, [hInMenu]
2016-01-09 13:28:22 -08:00
push af
ld a, $1
ldh [hInMenu], a
2016-01-09 13:28:22 -08:00
call .InitBlankMail
call DelayFrame
.loop
call .DoMailEntry
jr nc, .loop
pop af
ldh [hInMenu], a
2016-01-09 13:28:22 -08:00
pop af
ldh [hMapAnims], a
2016-01-09 13:28:22 -08:00
ret
2018-06-24 07:09:41 -07:00
.InitBlankMail:
2016-01-09 13:28:22 -08:00
call ClearBGPalettes
call DisableLCD
call LoadNamingScreenGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles0 tile $00
2016-01-09 13:28:22 -08:00
ld hl, .MailIcon
ld bc, 8 tiles
ld a, BANK(.MailIcon)
call FarCopyBytes
2020-10-30 12:39:08 -07:00
xor a ; SPRITE_ANIM_DICT_DEFAULT and tile offset $00
2016-01-09 13:28:22 -08:00
ld hl, wSpriteAnimDict
ld [hli], a
ld [hl], a
; init mail icon
depixel 3, 2
2023-09-24 06:06:19 -07:00
ld a, SPRITE_ANIM_OBJ_PARTY_MON
call InitSpriteAnimStruct
2016-01-09 13:28:22 -08:00
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], $0
call .InitCharset
2017-12-29 10:22:33 -08:00
ld a, LCDC_DEFAULT
ldh [rLCDC], a
2016-01-09 13:28:22 -08:00
call .initwNamingScreenMaxNameLength
ld b, CGB_DIPLOMA
call GetCGBLayout
2016-01-09 13:28:22 -08:00
call WaitBGMap
call WaitTop
ld a, %11100100
call DmgToCgbBGPals
ld a, %11100100
call DmgToCgbObjPal0
call NamingScreen_InitNameEntry
ld hl, wNamingScreenDestinationPointer
ld e, [hl]
inc hl
ld d, [hl]
ld hl, MAIL_LINE_LENGTH
2016-01-09 13:28:22 -08:00
add hl, de
ld [hl], "<NEXT>"
2016-01-09 13:28:22 -08:00
ret
2018-06-24 07:09:41 -07:00
.MailIcon:
INCBIN "gfx/naming_screen/mail.2bpp"
2016-01-09 13:28:22 -08:00
2018-06-24 07:09:41 -07:00
.initwNamingScreenMaxNameLength
2016-01-09 13:28:22 -08:00
ld a, MAIL_MSG_LENGTH + 1
ld [wNamingScreenMaxNameLength], a
ret
2018-06-24 07:09:41 -07:00
.InitCharset:
2016-01-09 13:28:22 -08:00
call WaitTop
hlcoord 0, 0
ld bc, 6 * SCREEN_WIDTH
ld a, NAMINGSCREEN_BORDER
2016-01-09 13:28:22 -08:00
call ByteFill
hlcoord 0, 6
ld bc, 12 * SCREEN_WIDTH
ld a, " "
call ByteFill
hlcoord 1, 1
lb bc, 4, SCREEN_WIDTH - 2
call ClearBox
ld de, MailEntry_Uppercase
2018-06-24 07:09:41 -07:00
.PlaceMailCharset:
2016-01-09 13:28:22 -08:00
hlcoord 1, 7
ld b, 6
.next
ld c, SCREEN_WIDTH - 1
.loop_
ld a, [de]
ld [hli], a
inc de
dec c
jr nz, .loop_
push de
ld de, SCREEN_WIDTH + 1
add hl, de
pop de
dec b
jr nz, .next
ret
2018-06-24 07:09:41 -07:00
.DoMailEntry:
2016-01-09 13:28:22 -08:00
call JoyTextDelay
ld a, [wJumptableIndex]
bit 7, a
jr nz, .exit_mail
call .DoJumptable
2017-12-24 09:47:30 -08:00
farcall PlaySpriteAnimationsAndDelayFrame
2016-01-09 13:28:22 -08:00
call .Update
call DelayFrame
and a
ret
.exit_mail
2017-12-24 09:47:30 -08:00
callfar ClearSpriteAnims
2016-01-09 13:28:22 -08:00
call ClearSprites
xor a
ldh [hSCX], a
ldh [hSCY], a
2016-01-09 13:28:22 -08:00
scf
ret
2018-06-24 07:09:41 -07:00
.Update:
2016-01-09 13:28:22 -08:00
xor a
ldh [hBGMapMode], a
2016-01-09 13:28:22 -08:00
hlcoord 1, 1
lb bc, 4, 18
call ClearBox
ld hl, wNamingScreenDestinationPointer
ld e, [hl]
inc hl
ld d, [hl]
hlcoord 2, 2
call PlaceString
ld a, $1
ldh [hBGMapMode], a
2016-01-09 13:28:22 -08:00
ret
2018-06-24 07:09:41 -07:00
.DoJumptable:
jumptable .Jumptable, wJumptableIndex
2016-01-09 13:28:22 -08:00
2018-06-24 07:09:41 -07:00
.Jumptable:
2016-01-09 13:28:22 -08:00
dw .init_blinking_cursor
dw .process_joypad
2018-06-24 07:09:41 -07:00
.init_blinking_cursor
2016-01-09 13:28:22 -08:00
depixel 9, 2
2023-09-24 06:06:19 -07:00
ld a, SPRITE_ANIM_OBJ_COMPOSE_MAIL_CURSOR
call InitSpriteAnimStruct
2016-01-09 13:28:22 -08:00
ld a, c
ld [wNamingScreenCursorObjectPointer], a
ld a, b
ld [wNamingScreenCursorObjectPointer + 1], a
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld a, [hl]
ld hl, SPRITEANIMSTRUCT_VAR3
2016-01-09 13:28:22 -08:00
add hl, bc
ld [hl], a
ld hl, wJumptableIndex
inc [hl]
ret
2018-06-24 07:09:41 -07:00
.process_joypad
2018-08-25 11:39:24 -07:00
ld hl, hJoyPressed
2016-01-09 13:28:22 -08:00
ld a, [hl]
and A_BUTTON
jr nz, .a
ld a, [hl]
and B_BUTTON
jr nz, .b
ld a, [hl]
and START
jr nz, .start
ld a, [hl]
and SELECT
jr nz, .select
ret
.a
call NamingScreen_PressedA_GetCursorCommand
2016-01-09 13:28:22 -08:00
cp $1
jr z, .select
cp $2
jr z, .b
cp $3
jr z, .finished
call NamingScreen_GetLastCharacter
call MailComposition_TryAddLastCharacter
2016-01-09 13:28:22 -08:00
jr c, .start
2018-09-09 12:09:51 -07:00
ld hl, wNamingScreenCurNameLength
2016-01-09 13:28:22 -08:00
ld a, [hl]
cp MAIL_LINE_LENGTH
2016-01-09 13:28:22 -08:00
ret nz
inc [hl]
call NamingScreen_GetTextCursorPosition
ld [hl], NAMINGSCREEN_UNDERLINE
2016-01-09 13:28:22 -08:00
dec hl
ld [hl], "<NEXT>"
2016-01-09 13:28:22 -08:00
ret
.start
ld hl, wNamingScreenCursorObjectPointer
ld c, [hl]
inc hl
ld b, [hl]
ld hl, SPRITEANIMSTRUCT_VAR1
2016-01-09 13:28:22 -08:00
add hl, bc
ld [hl], $9
ld hl, SPRITEANIMSTRUCT_VAR2
2016-01-09 13:28:22 -08:00
add hl, bc
ld [hl], $5
ret
.b
call NamingScreen_DeleteCharacter
2018-09-09 12:09:51 -07:00
ld hl, wNamingScreenCurNameLength
2016-01-09 13:28:22 -08:00
ld a, [hl]
cp MAIL_LINE_LENGTH
2016-01-09 13:28:22 -08:00
ret nz
dec [hl]
call NamingScreen_GetTextCursorPosition
ld [hl], NAMINGSCREEN_UNDERLINE
2016-01-09 13:28:22 -08:00
inc hl
ld [hl], "<NEXT>"
2016-01-09 13:28:22 -08:00
ret
.finished
call NamingScreen_StoreEntry
ld hl, wJumptableIndex
set 7, [hl]
ret
.select
2018-01-11 12:36:11 -08:00
ld hl, wNamingScreenLetterCase
2016-01-09 13:28:22 -08:00
ld a, [hl]
2018-01-11 12:36:11 -08:00
xor 1
2016-01-09 13:28:22 -08:00
ld [hl], a
jr nz, .switch_to_lowercase
ld de, MailEntry_Uppercase
call .PlaceMailCharset
ret
.switch_to_lowercase
ld de, MailEntry_Lowercase
call .PlaceMailCharset
ret
2020-11-17 08:12:21 -08:00
; called from engine/gfx/sprite_anims.asm
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
ComposeMail_AnimateCursor:
call .GetDPad
ld hl, SPRITEANIMSTRUCT_VAR2
2016-01-09 13:28:22 -08:00
add hl, bc
ld a, [hl]
ld e, a
swap e
ld hl, SPRITEANIMSTRUCT_YOFFSET
add hl, bc
ld [hl], e
cp $5
ld de, .LetterEntries
2016-01-09 13:28:22 -08:00
ld a, 0
jr nz, .got_pointer
ld de, .CaseDelEnd
2016-01-09 13:28:22 -08:00
ld a, 1
.got_pointer
ld hl, SPRITEANIMSTRUCT_VAR3
2016-01-09 13:28:22 -08:00
add hl, bc
add [hl]
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ld hl, SPRITEANIMSTRUCT_VAR1
2016-01-09 13:28:22 -08:00
add hl, bc
ld l, [hl]
ld h, 0
add hl, de
ld a, [hl]
ld hl, SPRITEANIMSTRUCT_XOFFSET
add hl, bc
ld [hl], a
ret
2018-06-24 07:09:41 -07:00
.LetterEntries:
2016-01-09 13:28:22 -08:00
db $00, $10, $20, $30, $40, $50, $60, $70, $80, $90
2018-06-24 07:09:41 -07:00
.CaseDelEnd:
2016-01-09 13:28:22 -08:00
db $00, $00, $00, $30, $30, $30, $60, $60, $60, $60
2016-01-09 20:41:03 -08:00
2018-06-24 07:09:41 -07:00
.GetDPad:
2016-01-09 13:28:22 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, .up
ld a, [hl]
and D_DOWN
jr nz, .down
ld a, [hl]
and D_LEFT
jr nz, .left
ld a, [hl]
and D_RIGHT
jr nz, .right
ret
.right
call ComposeMail_GetCursorPosition
2016-01-09 13:28:22 -08:00
and a
jr nz, .case_del_done_right
ld hl, SPRITEANIMSTRUCT_VAR1
2016-01-09 13:28:22 -08:00
add hl, bc
ld a, [hl]
cp $9
jr nc, .wrap_around_letter_right
2016-01-09 13:28:22 -08:00
inc [hl]
ret
.wrap_around_letter_right
2016-01-09 13:28:22 -08:00
ld [hl], $0
ret
.case_del_done_right
2016-01-09 13:28:22 -08:00
cp $3
jr nz, .wrap_around_command_right
2016-01-09 13:28:22 -08:00
xor a
.wrap_around_command_right
2016-01-09 13:28:22 -08:00
ld e, a
add a
add e
ld hl, SPRITEANIMSTRUCT_VAR1
2016-01-09 13:28:22 -08:00
add hl, bc
ld [hl], a
ret
.left
call ComposeMail_GetCursorPosition
2016-01-09 13:28:22 -08:00
and a
jr nz, .caps_del_done_left
ld hl, SPRITEANIMSTRUCT_VAR1
2016-01-09 13:28:22 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .wrap_around_letter_left
2016-01-09 13:28:22 -08:00
dec [hl]
ret
.wrap_around_letter_left
2016-01-09 13:28:22 -08:00
ld [hl], $9
ret
.caps_del_done_left
2016-01-09 13:28:22 -08:00
cp $1
jr nz, .wrap_around_command_left
2016-01-09 13:28:22 -08:00
ld a, $4
.wrap_around_command_left
2016-01-09 13:28:22 -08:00
dec a
dec a
2016-01-09 13:28:22 -08:00
ld e, a
add a
add e
ld hl, SPRITEANIMSTRUCT_VAR1
2016-01-09 13:28:22 -08:00
add hl, bc
ld [hl], a
ret
.down
ld hl, SPRITEANIMSTRUCT_VAR2
2016-01-09 13:28:22 -08:00
add hl, bc
ld a, [hl]
cp $5
jr nc, .wrap_around_down
2016-01-09 13:28:22 -08:00
inc [hl]
ret
.wrap_around_down
2016-01-09 13:28:22 -08:00
ld [hl], $0
ret
.up
ld hl, SPRITEANIMSTRUCT_VAR2
2016-01-09 13:28:22 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .wrap_around_up
2016-01-09 13:28:22 -08:00
dec [hl]
ret
.wrap_around_up
2016-01-09 13:28:22 -08:00
ld [hl], $5
ret
2018-06-24 07:09:41 -07:00
NamingScreen_PressedA_GetCursorCommand:
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenCursorObjectPointer
ld c, [hl]
inc hl
ld b, [hl]
2018-06-24 07:09:41 -07:00
ComposeMail_GetCursorPosition:
ld hl, SPRITEANIMSTRUCT_VAR2
2016-01-09 13:28:22 -08:00
add hl, bc
ld a, [hl]
cp $5
jr nz, .letter
ld hl, SPRITEANIMSTRUCT_VAR1
2016-01-09 13:28:22 -08:00
add hl, bc
ld a, [hl]
cp $3
jr c, .case
2016-01-09 13:28:22 -08:00
cp $6
jr c, .del
2016-01-09 13:28:22 -08:00
ld a, $3
ret
.case
2016-01-09 13:28:22 -08:00
ld a, $1
ret
.del
2016-01-09 13:28:22 -08:00
ld a, $2
ret
.letter
2016-01-09 13:28:22 -08:00
xor a
ret
2018-06-24 07:09:41 -07:00
MailComposition_TryAddLastCharacter:
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenLastCharacter]
jp MailComposition_TryAddCharacter
2016-01-09 20:41:03 -08:00
.add_dakuten ; unreferenced
2018-09-09 12:09:51 -07:00
ld a, [wNamingScreenCurNameLength]
2016-01-09 13:28:22 -08:00
and a
ret z
cp $11
2020-10-06 10:50:02 -07:00
jr nz, .one_back
2016-01-09 13:28:22 -08:00
push hl
2018-09-09 12:09:51 -07:00
ld hl, wNamingScreenCurNameLength
2016-01-09 13:28:22 -08:00
dec [hl]
dec [hl]
2020-10-06 10:50:02 -07:00
jr .continue
2016-01-09 13:28:22 -08:00
2020-10-06 10:50:02 -07:00
.one_back
2016-01-09 13:28:22 -08:00
push hl
2018-09-09 12:09:51 -07:00
ld hl, wNamingScreenCurNameLength
2016-01-09 13:28:22 -08:00
dec [hl]
2020-10-06 10:50:02 -07:00
.continue
2016-01-09 13:28:22 -08:00
call NamingScreen_GetTextCursorPosition
ld c, [hl]
pop hl
2020-10-06 10:50:02 -07:00
.loop
2016-01-09 13:28:22 -08:00
ld a, [hli]
2020-10-06 10:50:02 -07:00
cp -1 ; end?
2016-01-09 13:28:22 -08:00
jp z, NamingScreen_AdvanceCursor_CheckEndOfString
cp c
2020-10-06 10:50:02 -07:00
jr z, .done
2016-01-09 13:28:22 -08:00
inc hl
2020-10-06 10:50:02 -07:00
jr .loop
2016-01-09 13:28:22 -08:00
2020-10-06 10:50:02 -07:00
.done
2016-01-09 13:28:22 -08:00
ld a, [hl]
jp NamingScreen_LoadNextCharacter
2016-01-09 20:41:03 -08:00
2018-01-22 14:33:52 -08:00
INCLUDE "data/text/mail_input_chars.asm"