pokecrystal-board/engine/namingscreen.asm

1476 lines
22 KiB
NASM
Raw Normal View History

2015-11-11 13:11:08 -08:00
_NamingScreen: ; 0x116b7
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
2015-11-11 13:11:08 -08:00
; 0x116c1
NamingScreen: ; 116c1
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
ld hl, Options
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld a, [hMapAnims]
push af
xor a
ld [hMapAnims], a
ld a, [hInMenu]
push af
ld a, $1
ld [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
ld [hInMenu], a
pop af
ld [hMapAnims], a
pop af
ld [Options], a
call ClearJoypad
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 116f8
2016-01-09 13:28:22 -08:00
.SetUpNamingScreen: ; 116f8
2015-11-11 20:38:57 -08:00
call ClearBGPalettes
2016-06-06 15:23:00 -07:00
ld b, SCGB_DIPLOMA
2015-11-11 13:11:08 -08:00
call GetSGBLayout
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
2015-11-11 13:11:08 -08:00
ld [rLCDC], a
2016-01-09 13:28:22 -08:00
call .GetNamingScreenSetup
2015-11-11 13:11:08 -08:00
call WaitBGMap
call WaitTop
call SetPalettes
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
2015-11-11 13:11:08 -08:00
; 1171d
2016-01-09 13:28:22 -08:00
.GetNamingScreenSetup: ; 1171d
ld a, [wNamingScreenType]
2015-11-11 13:11:08 -08:00
and 7
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
2016-01-09 20:41:03 -08:00
; 1172e
2015-11-11 13:11:08 -08:00
2016-01-09 13:28:22 -08:00
.Jumptable: ; 1172e (4:572e)
dw .Pokemon
dw .Player
dw .Rival
dw .Mom
dw .Box
dw .Tomodachi
dw .Pokemon
dw .Pokemon
2015-11-11 13:11:08 -08:00
2016-01-09 13:28:22 -08:00
.Pokemon: ; 1173e (4:573e)
2015-11-11 13:11:08 -08:00
ld a, [CurPartySpecies]
ld [wd265], a
2016-03-01 19:31:21 -08:00
ld hl, LoadMenuMonIcon
ld a, BANK(LoadMenuMonIcon)
2015-11-11 13:11:08 -08:00
ld e, $1
2016-03-01 19:31:21 -08:00
rst FarCall ; ; indirect jump to LoadMenuMonIcon (8e83f (23:683f))
2015-11-11 13:11:08 -08:00
ld a, [CurPartySpecies]
ld [wd265], a
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
2017-12-24 09:47:30 -08:00
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
2015-11-11 13:11:08 -08:00
; 11780 (4:5780)
2016-01-09 13:28:22 -08:00
.NicknameStrings: ; 11780
2015-11-11 13:11:08 -08:00
db "'S@"
db "NICKNAME?@"
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 1178d
2016-01-09 13:28:22 -08:00
.Player: ; 1178d (4:578d)
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
2015-11-11 13:11:08 -08:00
; 117a3 (4:57a3)
2016-01-09 13:28:22 -08:00
.PlayerNameString: ; 117a3
2015-11-11 13:11:08 -08:00
db "YOUR NAME?@"
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 117ae
2016-01-09 13:28:22 -08:00
.Rival: ; 117ae (4:57ae)
2015-11-11 13:11:08 -08:00
ld de, SilverSpriteGFX
ld b, BANK(SilverSpriteGFX)
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
2015-11-11 13:11:08 -08:00
; 117c3 (4:57c3)
2016-01-09 13:28:22 -08:00
.RivalNameString: ; 117c3
2015-11-11 13:11:08 -08:00
db "RIVAL'S NAME?@"
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 117d1
2016-01-09 13:28:22 -08:00
.Mom: ; 117d1 (4:57d1)
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
2015-11-11 13:11:08 -08:00
; 117e6 (4:57e6)
2016-01-09 13:28:22 -08:00
.MomNameString: ; 117e6
2015-11-11 13:11:08 -08:00
db "MOTHER'S NAME?@"
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 117f5
2016-01-09 13:28:22 -08:00
.Box: ; 117f5 (4:57f5)
2015-11-11 13:11:08 -08:00
ld de, PokeBallSpriteGFX
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $00
2015-11-11 13:11:08 -08:00
lb bc, BANK(PokeBallSpriteGFX), $4
call Request2bpp
xor a
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
2016-01-09 20:41:03 -08:00
ld a, SPRITE_ANIM_INDEX_RED_WALK
2015-11-13 07:48:49 -08:00
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
2015-11-11 13:11:08 -08:00
; 11822 (4:5822)
2016-01-09 13:28:22 -08:00
.BoxNameString: ; 11822
2015-11-11 13:11:08 -08:00
db "BOX NAME?@"
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 1182c
2016-01-09 13:28:22 -08:00
.Tomodachi: ; 1182c (4:582c)
2015-11-11 13:11:08 -08:00
hlcoord 3, 2
2016-01-09 13:28:22 -08:00
ld de, .oTomodachi_no_namae_sutoringu
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
2015-11-11 13:11:08 -08:00
; 11839 (4:5839)
.oTomodachi_no_namae_sutoringu ; 11839
2015-11-11 13:11:08 -08:00
db "おともだち の なまえは?@"
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 11847
2016-01-09 13:28:22 -08:00
.LoadSprite: ; 11847 (4:5847)
2015-11-11 13:11:08 -08:00
push de
2017-12-28 04:32:33 -08:00
ld hl, vTiles0 tile $00
2015-11-11 13:11:08 -08:00
ld c, $4
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
xor a
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
2016-01-09 20:41:03 -08:00
ld b, SPRITE_ANIM_INDEX_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
2016-01-09 20:41:03 -08:00
ld b, SPRITE_ANIM_INDEX_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
2015-11-13 07:48:49 -08:00
call _InitSpriteAnimStruct
2015-11-11 13:11:08 -08:00
ret
2016-01-09 13:28:22 -08:00
.StoreMonIconParams: ; 1187b (4:587b)
ld a, PKMN_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
2016-01-09 13:28:22 -08:00
.StoreSpriteIconParams: ; 11882 (4:5882)
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
2016-01-09 13:28:22 -08:00
.StoreBoxIconParams: ; 11889 (4:5889)
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
2016-01-09 13:28:22 -08:00
.StoreParams: ; 11890 (4:5890)
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
2016-01-09 13:28:22 -08:00
NamingScreen_IsTargetBox: ; 1189c
2015-11-11 13:11:08 -08:00
push bc
push af
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenType]
2015-11-11 13:11:08 -08:00
sub $3
ld b, a
pop af
dec b
pop bc
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 118a8
2016-01-09 13:28:22 -08:00
NamingScreen_InitText: ; 118a8
2015-11-11 13:11:08 -08:00
call WaitTop
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, $60
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
2016-01-09 13:28:22 -08:00
NamingScreen_ApplyTextInputMode: ; 118ca
call NamingScreen_IsTargetBox
jr nz, .not_box
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
2015-11-11 13:11:08 -08:00
; 11915
2016-01-09 13:28:22 -08:00
NamingScreenJoypadLoop: ; 11915
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
ld [hSCX], a
ld [hSCY], a
scf
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 11940
2016-01-09 13:28:22 -08:00
.UpdateStringEntry: ; 11940
2015-11-11 13:11:08 -08:00
xor a
ld [hBGMapMode], a
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
ld [hBGMapMode], a
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 11968
2016-01-09 13:28:22 -08:00
.RunJumptable: ; 11968
2015-11-11 13:11:08 -08:00
ld a, [wJumptableIndex]
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
2016-01-09 20:41:03 -08:00
; 11977
2015-11-11 13:11:08 -08:00
2016-01-09 13:28:22 -08:00
.Jumptable: ; 11977 (4:5977)
dw .InitCursor
dw .ReadButtons
2015-11-11 13:11:08 -08:00
2016-01-09 13:28:22 -08:00
.InitCursor: ; 1197b (4:597b)
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
2015-11-18 10:01:55 -08:00
ld d, 8 * 8
2016-01-09 13:28:22 -08:00
.got_cursor_position
ld a, SPRITE_ANIM_INDEX_NAMING_SCREEN_CURSOR
2015-11-13 07:48:49 -08:00
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]
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0E
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], a
ld hl, wJumptableIndex
inc [hl]
ret
2016-01-09 13:28:22 -08:00
.ReadButtons: ; 119a1 (4:59a1)
2015-11-11 13:11:08 -08:00
ld hl, hJoyPressed ; $ffa7
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]
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 13:11:08 -08:00
add hl, bc
ld [hl], $8
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0D
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
ld hl, wcf64
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
2016-01-09 13:28:22 -08:00
.GetCursorPosition: ; 11a0b (4:5a0b)
ld hl, wNamingScreenCursorObjectPointer
2015-11-11 13:11:08 -08:00
ld c, [hl]
inc hl
ld b, [hl]
2016-01-09 13:28:22 -08:00
NamingScreen_GetCursorPosition: ; 11a11 (4:5a11)
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0D
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
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0C
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
2016-01-09 13:28:22 -08:00
NamingScreen_AnimateCursor: ; 11a3b (4:5a3b)
call .GetDPad
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0D
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
2015-11-11 13:11:08 -08:00
ld a, $0
2016-01-09 13:28:22 -08:00
jr nz, .ok2
ld de, .CaseDelEnd
2015-11-11 13:11:08 -08:00
ld a, $1
2016-01-09 13:28:22 -08:00
.ok2
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0E
2015-11-11 13:11:08 -08:00
add hl, bc
add [hl]
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
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0C
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
2015-11-11 13:11:08 -08:00
; 11a79 (4:5a79)
2016-01-09 13:28:22 -08:00
.LetterEntries: ; 11a79
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
.CaseDelEnd: ; 11a82
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
2015-11-11 13:11:08 -08:00
; 11a8b
2016-01-09 13:28:22 -08:00
.GetDPad: ; 11a8b (4:5a8b)
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
jr nz, .asm_11ab7
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
cp $8
jr nc, .asm_11ab4
inc [hl]
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.asm_11ab4
ld [hl], $0
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.asm_11ab7
cp $3
jr nz, .asm_11abc
xor a
.asm_11abc
ld e, a
add a
add e
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0C
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
jr nz, .asm_11ad8
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0C
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .asm_11ad5
dec [hl]
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.asm_11ad5
ld [hl], $8
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.asm_11ad8
cp $1
jr nz, .asm_11ade
ld a, $4
.asm_11ade
dec a
dec a
2015-11-11 13:11:08 -08:00
ld e, a
add a
add e
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0C
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
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0D
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
2015-11-11 13:11:08 -08:00
jr nz, .asm_11af9
cp $5
jr nc, .asm_11aff
inc [hl]
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.asm_11af9
cp $4
jr nc, .asm_11aff
inc [hl]
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.asm_11aff
ld [hl], $0
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.up
2015-12-04 05:46:11 -08:00
ld hl, SPRITEANIMSTRUCT_0D
2015-11-11 13:11:08 -08:00
add hl, bc
ld a, [hl]
and a
jr z, .asm_11b0c
dec [hl]
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
.asm_11b0c
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
2016-01-09 13:28:22 -08:00
NamingScreen_TryAddCharacter: ; 11b14 (4:5b14)
ld a, [wNamingScreenLastCharacter] ; lost
MailComposition_TryAddCharacter: ; 11b17 (4:5b17)
ld a, [wNamingScreenMaxNameLength]
2015-11-11 13:11:08 -08:00
ld c, a
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenCurrNameLength]
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
2016-01-09 13:28:22 -08:00
NamingScreen_LoadNextCharacter: ; 11b23
call NamingScreen_GetTextCursorPosition
2015-11-11 13:11:08 -08:00
ld [hl], a
2016-01-09 13:28:22 -08:00
NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27
ld hl, wNamingScreenCurrNameLength
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
2015-11-11 13:11:08 -08:00
ld [hl], $f2
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
2015-11-11 13:11:08 -08:00
; 11b39 (4:5b39)
2016-01-09 13:28:22 -08:00
; XXX
ld a, [wNamingScreenCurrNameLength]
2015-11-11 13:11:08 -08:00
and a
ret z
push hl
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenCurrNameLength
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]
cp $ff
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
2015-11-11 13:11:08 -08:00
; 11b56
Dakutens: ; Dummied out
db "かが", "きぎ", "くぐ", "けげ", "こご"
db "さざ", "しじ", "すず", "せぜ", "そぞ"
db "ただ", "ちぢ", "つづ", "てで", "とど"
db "はば", "ひび", "ふぶ", "へべ", "ほぼ"
db "カガ", "キギ", "クグ", "ケゲ", "コゴ"
db "サザ", "シジ", "スズ", "セゼ", "ソゾ"
db "タダ", "チヂ", "ツヅ", "テデ", "トド"
db "ハバ", "ヒビ", "フブ", "へべ", "ホボ"
db $ff
Handakutens: ; Dummied out
db "はぱ", "ひぴ", "ふぷ", "へぺ", "ほぽ"
db "ハパ", "ヒピ", "フプ", "へぺ", "ホポ"
db $ff
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 11bbc
2016-01-09 13:28:22 -08:00
NamingScreen_DeleteCharacter: ; 11bbc (4:5bbc)
ld hl, wNamingScreenCurrNameLength
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
2015-11-11 13:11:08 -08:00
ld [hl], $f2
inc hl
ld a, [hl]
cp $f2
ret nz
ld [hl], $eb
ret
2016-01-09 13:28:22 -08:00
NamingScreen_GetTextCursorPosition: ; 11bd0 (4:5bd0)
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
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenCurrNameLength]
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
2015-11-11 13:11:08 -08:00
; 11be0
2016-01-09 13:28:22 -08:00
NamingScreen_InitNameEntry: ; 11be0
; load $f2, ($eb * [wNamingScreenMaxNameLength]), $50 into the dw address at wNamingScreenDestinationPointer
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 [hl], $f2
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
2016-01-09 13:28:22 -08:00
ld a, $eb
2015-11-11 13:11:08 -08:00
.loop
ld [hli], a
dec c
jr nz, .loop
ld [hl], "@"
ret
2016-01-09 20:41:03 -08:00
; 11bf7
2015-11-11 13:11:08 -08:00
2016-01-09 13:28:22 -08:00
NamingScreen_StoreEntry: ; 11bf7 (4:5bf7)
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 $eb
2016-01-09 13:28:22 -08:00
jr z, .terminator
2015-11-11 13:11:08 -08:00
cp $f2
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
2016-01-09 13:28:22 -08:00
NamingScreen_GetLastCharacter: ; 11c11 (4:5c11)
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
2016-01-09 13:28:22 -08:00
LoadNamingScreenGFX: ; 11c51
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 LoadFontsExtra
2016-01-09 13:28:22 -08:00
ld de, NamingScreenGFX_MiddleLine
2017-12-28 04:32:33 -08:00
ld hl, vTiles1 tile $6b
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
2017-12-28 04:32:33 -08:00
ld hl, vTiles1 tile $72
2016-01-09 13:28:22 -08:00
lb bc, BANK(NamingScreenGFX_UnderLine), 1
2015-11-11 13:11:08 -08:00
call Get1bpp
2017-12-28 04:32:33 -08:00
ld de, vTiles2 tile $60
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
2017-12-28 04:32:33 -08:00
ld de, vTiles0 tile $7e
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
ld a, $5
2016-01-09 13:28:22 -08:00
ld hl, wSpriteAnimDict + 9 * 2
2015-11-11 13:11:08 -08:00
ld [hli], a
ld [hl], $7e
xor a
ld [hSCY], a
2015-12-02 14:59:05 -08:00
ld [wGlobalAnimYOffset], a
2015-11-11 13:11:08 -08:00
ld [hSCX], a
2015-12-02 14:59:05 -08:00
ld [wGlobalAnimXOffset], a
2015-11-11 13:11:08 -08:00
ld [wJumptableIndex], a
ld [wcf64], a
ld [hBGMapMode], a
2016-01-09 13:28:22 -08:00
ld [wNamingScreenCurrNameLength], a
2015-11-11 13:11:08 -08:00
ld a, $7
ld [hWX], a
ret
2016-01-09 20:41:03 -08:00
2015-11-11 13:11:08 -08:00
; 11cb7
2016-01-09 13:28:22 -08:00
NamingScreenGFX_Border: ; 11cb7
INCBIN "gfx/namingscreen/border.2bpp"
2015-11-11 13:11:08 -08:00
; 11cc7
2016-01-09 13:28:22 -08:00
NamingScreenGFX_Cursor: ; 11cc7
INCBIN "gfx/namingscreen/cursor.2bpp"
2015-11-11 13:11:08 -08:00
; 11ce7
INCLUDE "data/name_input_chars.asm"
2015-11-11 13:11:08 -08:00
; 11e5d
NamingScreenGFX_End: ; unused
INCBIN "gfx/namingscreen/end.1bpp"
2015-11-11 13:11:08 -08:00
; 11e6d
2016-01-09 13:28:22 -08:00
NamingScreenGFX_MiddleLine:
INCBIN "gfx/namingscreen/middle_line.1bpp"
2015-11-11 13:11:08 -08:00
; 11e6d
2016-01-09 13:28:22 -08:00
NamingScreenGFX_UnderLine: ; 11e6d
INCBIN "gfx/namingscreen/underline.1bpp"
2015-11-11 13:11:08 -08:00
; 11e75
2016-01-09 13:28:22 -08:00
_ComposeMailMessage: ; 11e75 (mail?)
ld hl, wNamingScreenDestinationPointer
ld [hl], e
inc hl
ld [hl], d
ld a, [hMapAnims]
push af
xor a
ld [hMapAnims], a
ld a, [hInMenu]
push af
ld a, $1
ld [hInMenu], a
call .InitBlankMail
call DelayFrame
.loop
call .DoMailEntry
jr nc, .loop
pop af
ld [hInMenu], a
pop af
ld [hMapAnims], a
ret
.InitBlankMail: ; 11e9a (4:5e9a)
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
xor a
ld hl, wSpriteAnimDict
ld [hli], a
ld [hl], a
; init mail icon
depixel 3, 2
ld a, SPRITE_ANIM_INDEX_PARTY_MON
2016-01-09 13:28:22 -08:00
call _InitSpriteAnimStruct
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
2016-01-09 13:28:22 -08:00
ld [rLCDC], a
call .initwNamingScreenMaxNameLength
2016-06-06 15:23:00 -07:00
ld b, SCGB_DIPLOMA
2016-01-09 13:28:22 -08:00
call GetSGBLayout
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, $10
add hl, de
ld [hl], $4e
ret
; 11ef4 (4:5ef4)
.MailIcon: ; 11ef4
INCBIN "gfx/icons/mail2.2bpp"
2016-01-09 13:28:22 -08:00
; 11f74
.initwNamingScreenMaxNameLength ; 11f74 (4:5f74)
2016-01-09 13:28:22 -08:00
ld a, MAIL_MSG_LENGTH + 1
ld [wNamingScreenMaxNameLength], a
ret
; 11f7a (4:5f7a)
.Dummy: ; dummied out
db "メールを かいてね@"
2016-01-09 20:41:03 -08:00
2016-01-09 13:28:22 -08:00
; 11f84
.InitCharset: ; 11f84 (4:5f84)
call WaitTop
hlcoord 0, 0
ld bc, 6 * SCREEN_WIDTH
ld a, $60 ; border
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
.PlaceMailCharset: ; 11fa9 (4:5fa9)
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
.DoMailEntry: ; 11fc0 (4:5fc0)
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
ld [hSCX], a
ld [hSCY], a
scf
ret
.Update: ; 11feb (4:5feb)
xor a
ld [hBGMapMode], a
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
ld [hBGMapMode], a
ret
.DoJumptable: ; 12008 (4:6008)
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
2016-01-09 13:28:22 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2016-01-09 13:28:22 -08:00
.Jumptable: ; 12017 (4:6017)
dw .init_blinking_cursor
dw .process_joypad
.init_blinking_cursor ; 1201b (4:601b)
2016-01-09 13:28:22 -08:00
depixel 9, 2
ld a, SPRITE_ANIM_INDEX_COMPOSE_MAIL_CURSOR
2016-01-09 13:28:22 -08:00
call _InitSpriteAnimStruct
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_0E
add hl, bc
ld [hl], a
ld hl, wJumptableIndex
inc [hl]
ret
.process_joypad ; 1203a (4:603a)
2016-01-09 13:28:22 -08:00
ld hl, hJoyPressed ; $ffa7
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
ld hl, wNamingScreenCurrNameLength
ld a, [hl]
cp $10
ret nz
inc [hl]
call NamingScreen_GetTextCursorPosition
ld [hl], $f2
dec hl
ld [hl], $4e
ret
.start
ld hl, wNamingScreenCursorObjectPointer
ld c, [hl]
inc hl
ld b, [hl]
ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], $9
ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld [hl], $5
ret
.b
call NamingScreen_DeleteCharacter
ld hl, wNamingScreenCurrNameLength
ld a, [hl]
cp $10
ret nz
dec [hl]
call NamingScreen_GetTextCursorPosition
ld [hl], $f2
inc hl
ld [hl], $4e
ret
.finished
call NamingScreen_StoreEntry
ld hl, wJumptableIndex
set 7, [hl]
ret
.select
ld hl, wcf64
ld a, [hl]
xor $1
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
; called from engine/sprite_anims.asm
2016-01-09 20:41:03 -08:00
ComposeMail_AnimateCursor: ; 120c1 (4:60c1)
call .GetDPad
2016-01-09 13:28:22 -08:00
ld hl, SPRITEANIMSTRUCT_0D
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
2016-01-09 13:28:22 -08:00
ld hl, SPRITEANIMSTRUCT_0E
add hl, bc
add [hl]
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ld hl, SPRITEANIMSTRUCT_0C
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
; 120f8 (4:60f8)
.LetterEntries: ; 120f8
2016-01-09 13:28:22 -08:00
db $00, $10, $20, $30, $40, $50, $60, $70, $80, $90
.CaseDelEnd: ; 12102
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
2016-01-09 13:28:22 -08:00
; 1210c
.GetDPad: ; 1210c (4:610c)
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
2016-01-09 13:28:22 -08:00
ld hl, SPRITEANIMSTRUCT_0C
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_0C
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
2016-01-09 13:28:22 -08:00
ld hl, SPRITEANIMSTRUCT_0C
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_0C
add hl, bc
ld [hl], a
ret
.down
ld hl, SPRITEANIMSTRUCT_0D
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_0D
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
NamingScreen_PressedA_GetCursorCommand: ; 12185 (4:6185)
2016-01-09 13:28:22 -08:00
ld hl, wNamingScreenCursorObjectPointer
ld c, [hl]
inc hl
ld b, [hl]
ComposeMail_GetCursorPosition: ; 1218b (4:618b)
2016-01-09 13:28:22 -08:00
ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld a, [hl]
cp $5
jr nz, .letter
2016-01-09 13:28:22 -08:00
ld hl, SPRITEANIMSTRUCT_0C
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
MailComposition_TryAddLastCharacter: ; 121ac (4:61ac)
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenLastCharacter]
jp MailComposition_TryAddCharacter
2016-01-09 20:41:03 -08:00
2016-01-09 13:28:22 -08:00
; 121b2 (4:61b2)
; XXX
2016-01-09 13:28:22 -08:00
ld a, [wNamingScreenCurrNameLength]
and a
ret z
cp $11
jr nz, .asm_121c3
push hl
ld hl, wNamingScreenCurrNameLength
dec [hl]
dec [hl]
2016-01-09 13:28:22 -08:00
jr .asm_121c8
.asm_121c3
push hl
ld hl, wNamingScreenCurrNameLength
dec [hl]
.asm_121c8
call NamingScreen_GetTextCursorPosition
ld c, [hl]
pop hl
.asm_121cd
ld a, [hli]
cp $ff
jp z, NamingScreen_AdvanceCursor_CheckEndOfString
cp c
jr z, .asm_121d9
inc hl
jr .asm_121cd
.asm_121d9
ld a, [hl]
jp NamingScreen_LoadNextCharacter
2016-01-09 20:41:03 -08:00
2016-01-09 13:28:22 -08:00
; 121dd
INCLUDE "data/mail_input_chars.asm"
2016-01-09 20:41:03 -08:00
2016-01-09 13:28:22 -08:00
; 122c1