ref: a8eb44b6e3b2e376491c68efe4a67e8f1badb0e8
parent: 732bb36c8661afdaca765604c75437089930738c
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Sun Jan 21 08:58:16 EST 2018
Separate new_game graphics
--- a/Makefile
+++ b/Makefile
@@ -140,8 +140,8 @@
### Misc file-specific graphics rules
-gfx/shrink/shrink1.2bpp: rgbgfx += -h
-gfx/shrink/shrink2.2bpp: rgbgfx += -h
+gfx/new_game/shrink1.2bpp: rgbgfx += -h
+gfx/new_game/shrink2.2bpp: rgbgfx += -h
gfx/trainers/%.2bpp: rgbgfx += -h
gfx/trainers/%.pal: gfx/trainers/%.gbcpal
--- /dev/null
+++ b/engine/crystal_cgb.asm
@@ -1,0 +1,325 @@
+GetMysteryGift_MobileAdapterLayout: ; 4930f (mobile)
+ ld a, b
+ cp SCGB_RAM
+ jr nz, .not_ram
+ ld a, [SGBPredef]
+.not_ram
+ push af
+ farcall ResetBGPals
+ pop af
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, .dw
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, .done
+ push de
+ jp hl
+.done
+ ret
+; 49330 (12:5330)
+
+.dw ; 49330
+ dw MG_Mobile_Layout00
+ dw MG_Mobile_Layout01
+ dw MG_Mobile_Layout02
+; 49336
+
+MG_Mobile_Layout_FillBox: ; 49336
+.row
+ push bc
+ push hl
+.col
+ ld [hli], a
+ dec c
+ jr nz, .col
+ pop hl
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .row
+ ret
+; 49346
+
+MG_Mobile_Layout_WipeAttrMap: ; 49346 (12:5346)
+ hlcoord 0, 0, AttrMap
+ ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
+ xor a
+ call ByteFill
+ ret
+
+MG_Mobile_Layout_LoadPals: ; 49351 (12:5351)
+ ld de, wBGPals1
+ ld hl, Palette_493e1
+ ld bc, 5 palettes
+ ld a, BANK(wBGPals1)
+ call FarCopyWRAM
+ ld de, wBGPals1 palette PAL_BG_TEXT
+ ld hl, Palette_TextBG7
+ ld bc, 1 palettes
+ ld a, BANK(wBGPals1)
+ call FarCopyWRAM
+ ret
+
+MG_Mobile_Layout00: ; 4936e (12:536e)
+ call MG_Mobile_Layout_LoadPals
+ call MG_Mobile_Layout_WipeAttrMap
+ call MG_Mobile_Layout_CreatePalBoxes
+ farcall ApplyAttrMap
+ farcall ApplyPals
+ ret
+
+MG_Mobile_Layout_CreatePalBoxes: ; 49384 (12:5384)
+ hlcoord 0, 0, AttrMap
+ lb bc, 4, 1
+ ld a, $1
+ call MG_Mobile_Layout_FillBox
+ lb bc, 2, 1
+ ld a, $2
+ call MG_Mobile_Layout_FillBox
+ lb bc, 6, 1
+ ld a, $3
+ call MG_Mobile_Layout_FillBox
+ hlcoord 1, 0, AttrMap
+ ld a, $1
+ lb bc, 3, 18
+ call MG_Mobile_Layout_FillBox
+ lb bc, 2, 18
+ ld a, $2
+ call MG_Mobile_Layout_FillBox
+ lb bc, 12, 18
+ ld a, $3
+ call MG_Mobile_Layout_FillBox
+ hlcoord 19, 0, AttrMap
+ lb bc, 4, 1
+ ld a, $1
+ call MG_Mobile_Layout_FillBox
+ lb bc, 2, 1
+ ld a, $2
+ call MG_Mobile_Layout_FillBox
+ lb bc, 6, 1
+ ld a, $3
+ call MG_Mobile_Layout_FillBox
+ hlcoord 0, 12, AttrMap
+ ld bc, 6 * SCREEN_WIDTH
+ ld a, $7
+ call ByteFill
+ ret
+; 493e1 (12:53e1)
+
+Palette_493e1: ; 493e1
+INCLUDE "gfx/mystery_gift/mg_mobile.pal"
+; 49409
+
+LoadOW_BGPal7:: ; 49409
+ ld hl, Palette_TextBG7
+ ld de, wBGPals1 palette PAL_BG_TEXT
+ ld bc, 1 palettes
+ ld a, BANK(wBGPals1)
+ call FarCopyWRAM
+ ret
+; 49418
+
+Palette_TextBG7: ; 49418
+INCLUDE "gfx/font/bg_text.pal"
+; 49420
+
+Function49420:: ; 49420 (12:5420)
+ ld hl, MansionPalette1 + 8 palettes
+ ld de, wBGPals1 palette PAL_BG_ROOF
+ ld bc, 1 palettes
+ ld a, BANK(wBGPals1)
+ call FarCopyWRAM
+ ret
+; 4942f (12:542f)
+
+MG_Mobile_Layout01: ; 4942f
+ call MG_Mobile_Layout_LoadPals
+ ld de, wBGPals1 palette PAL_BG_TEXT
+ ld hl, .Palette_49478
+ ld bc, 1 palettes
+ ld a, BANK(wBGPals1)
+ call FarCopyWRAM
+ call MG_Mobile_Layout_WipeAttrMap
+ hlcoord 0, 0, AttrMap
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ xor a
+ call ByteFill
+ hlcoord 0, 14, AttrMap
+ ld bc, 4 * SCREEN_WIDTH
+ ld a, $7
+ call ByteFill
+ ld a, [wd002]
+ bit 6, a
+ jr z, .asm_49464
+ call Function49480
+ jr .asm_49467
+
+.asm_49464
+ call Function49496
+
+.asm_49467
+ farcall ApplyAttrMap
+ farcall ApplyPals
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 49478
+
+.Palette_49478: ; 49478
+ RGB 31, 31, 31
+ RGB 26, 31, 00
+ RGB 20, 16, 03
+ RGB 00, 00, 00
+; 49480
+
+Function49480: ; 49480
+ hlcoord 0, 0, AttrMap
+ lb bc, 4, SCREEN_WIDTH
+ ld a, $7
+ call MG_Mobile_Layout_FillBox
+ hlcoord 0, 2, AttrMap
+ ld a, $4
+ ld [hl], a
+ hlcoord 19, 2, AttrMap
+ ld [hl], a
+ ret
+; 49496
+
+Function49496: ; 49496
+ hlcoord 0, 0, AttrMap
+ lb bc, 2, SCREEN_WIDTH
+ ld a, $7
+ call MG_Mobile_Layout_FillBox
+ hlcoord 0, 1, AttrMap
+ ld a, $4
+ ld [hl], a
+ hlcoord 19, 1, AttrMap
+ ld [hl], a
+ ret
+; 494ac
+
+INCLUDE "engine/tileset_palettes.asm"
+
+MG_Mobile_Layout02: ; 49706
+ ld hl, .Palette_49732
+ ld de, wBGPals1
+ ld bc, 1 palettes
+ ld a, BANK(wBGPals1)
+ call FarCopyWRAM
+ farcall ApplyPals
+ call MG_Mobile_Layout_WipeAttrMap
+ farcall ApplyAttrMap
+ ld hl, .Palette_4973a
+ ld de, wOBPals1
+ ld bc, 1 palettes
+ ld a, BANK(wOBPals1)
+ call FarCopyWRAM
+ ret
+; 49732
+
+.Palette_49732: ; 49732
+ RGB 31, 31, 31
+ RGB 23, 16, 07
+ RGB 23, 07, 07
+ RGB 03, 07, 20
+; 4973a
+
+.Palette_4973a: ; 4973a
+ RGB 00, 00, 00
+ RGB 07, 05, 31
+ RGB 14, 18, 31
+ RGB 31, 31, 31
+; 49742
+
+Function49742: ; 49742
+ ld hl, .Palette_49757
+ ld de, wBGPals1
+ ld bc, 8 palettes
+ ld a, BANK(wBGPals1)
+ call FarCopyWRAM
+ farcall ApplyPals
+ ret
+; 49757
+
+.Palette_49757: ; 49757
+INCLUDE "gfx/unknown/49757.pal"
+; 49797
+
+_InitMG_Mobile_LinkTradePalMap: ; 49797
+ hlcoord 0, 0, AttrMap
+ lb bc, 16, 2
+ ld a, $4
+ call MG_Mobile_Layout_FillBox
+ ld a, $3
+ ldcoord_a 0, 1, AttrMap
+ ldcoord_a 0, 14, AttrMap
+ hlcoord 2, 0, AttrMap
+ lb bc, 8, 18
+ ld a, $5
+ call MG_Mobile_Layout_FillBox
+ hlcoord 2, 8, AttrMap
+ lb bc, 8, 18
+ ld a, $6
+ call MG_Mobile_Layout_FillBox
+ hlcoord 0, 16, AttrMap
+ lb bc, 2, SCREEN_WIDTH
+ ld a, $4
+ call MG_Mobile_Layout_FillBox
+ ld a, $3
+ lb bc, 6, 1
+ hlcoord 6, 1, AttrMap
+ call MG_Mobile_Layout_FillBox
+ ld a, $3
+ lb bc, 6, 1
+ hlcoord 17, 1, AttrMap
+ call MG_Mobile_Layout_FillBox
+ ld a, $3
+ lb bc, 6, 1
+ hlcoord 6, 9, AttrMap
+ call MG_Mobile_Layout_FillBox
+ ld a, $3
+ lb bc, 6, 1
+ hlcoord 17, 9, AttrMap
+ call MG_Mobile_Layout_FillBox
+ ld a, $2
+ hlcoord 2, 16, AttrMap
+ ld [hli], a
+ ld a, $7
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld a, $2
+ ld [hl], a
+ hlcoord 2, 17, AttrMap
+ ld a, $3
+ ld bc, 6
+ call ByteFill
+ ret
+; 49811
+
+LoadTradeRoomBGPals: ; 49811
+ ld hl, TradeRoomPalette
+ ld de, wBGPals1 palette PAL_BG_GREEN
+ ld bc, 6 palettes
+ ld a, BANK(wBGPals1)
+ call FarCopyWRAM
+ farcall ApplyPals
+ ret
+; 49826
+
+TradeRoomPalette: ; 49826
+INCLUDE "gfx/trade/border.pal"
+; 49856
+
+InitMG_Mobile_LinkTradePalMap: ; 49856
+ call _InitMG_Mobile_LinkTradePalMap
+ ret
+; 4985a
+
+; unused
+INCLUDE "gfx/unknown/4985a.asm"
--- a/engine/crystal_colors.asm
+++ /dev/null
@@ -1,325 +1,0 @@
-GetMysteryGift_MobileAdapterLayout: ; 4930f (mobile)
- ld a, b
- cp SCGB_RAM
- jr nz, .not_ram
- ld a, [SGBPredef]
-.not_ram
- push af
- farcall ResetBGPals
- pop af
- ld l, a
- ld h, 0
- add hl, hl
- ld de, .dw
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, .done
- push de
- jp hl
-.done
- ret
-; 49330 (12:5330)
-
-.dw ; 49330
- dw MG_Mobile_Layout00
- dw MG_Mobile_Layout01
- dw MG_Mobile_Layout02
-; 49336
-
-MG_Mobile_Layout_FillBox: ; 49336
-.row
- push bc
- push hl
-.col
- ld [hli], a
- dec c
- jr nz, .col
- pop hl
- ld bc, SCREEN_WIDTH
- add hl, bc
- pop bc
- dec b
- jr nz, .row
- ret
-; 49346
-
-MG_Mobile_Layout_WipeAttrMap: ; 49346 (12:5346)
- hlcoord 0, 0, AttrMap
- ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
- xor a
- call ByteFill
- ret
-
-MG_Mobile_Layout_LoadPals: ; 49351 (12:5351)
- ld de, wBGPals1
- ld hl, Palette_493e1
- ld bc, 5 palettes
- ld a, BANK(wBGPals1)
- call FarCopyWRAM
- ld de, wBGPals1 palette PAL_BG_TEXT
- ld hl, Palette_TextBG7
- ld bc, 1 palettes
- ld a, BANK(wBGPals1)
- call FarCopyWRAM
- ret
-
-MG_Mobile_Layout00: ; 4936e (12:536e)
- call MG_Mobile_Layout_LoadPals
- call MG_Mobile_Layout_WipeAttrMap
- call MG_Mobile_Layout_CreatePalBoxes
- farcall ApplyAttrMap
- farcall ApplyPals
- ret
-
-MG_Mobile_Layout_CreatePalBoxes: ; 49384 (12:5384)
- hlcoord 0, 0, AttrMap
- lb bc, 4, 1
- ld a, $1
- call MG_Mobile_Layout_FillBox
- lb bc, 2, 1
- ld a, $2
- call MG_Mobile_Layout_FillBox
- lb bc, 6, 1
- ld a, $3
- call MG_Mobile_Layout_FillBox
- hlcoord 1, 0, AttrMap
- ld a, $1
- lb bc, 3, 18
- call MG_Mobile_Layout_FillBox
- lb bc, 2, 18
- ld a, $2
- call MG_Mobile_Layout_FillBox
- lb bc, 12, 18
- ld a, $3
- call MG_Mobile_Layout_FillBox
- hlcoord 19, 0, AttrMap
- lb bc, 4, 1
- ld a, $1
- call MG_Mobile_Layout_FillBox
- lb bc, 2, 1
- ld a, $2
- call MG_Mobile_Layout_FillBox
- lb bc, 6, 1
- ld a, $3
- call MG_Mobile_Layout_FillBox
- hlcoord 0, 12, AttrMap
- ld bc, 6 * SCREEN_WIDTH
- ld a, $7
- call ByteFill
- ret
-; 493e1 (12:53e1)
-
-Palette_493e1: ; 493e1
-INCLUDE "gfx/mystery_gift/mg_mobile.pal"
-; 49409
-
-LoadOW_BGPal7:: ; 49409
- ld hl, Palette_TextBG7
- ld de, wBGPals1 palette PAL_BG_TEXT
- ld bc, 1 palettes
- ld a, BANK(wBGPals1)
- call FarCopyWRAM
- ret
-; 49418
-
-Palette_TextBG7: ; 49418
-INCLUDE "gfx/font/bg_text.pal"
-; 49420
-
-Function49420:: ; 49420 (12:5420)
- ld hl, MansionPalette1 + 8 palettes
- ld de, wBGPals1 palette PAL_BG_ROOF
- ld bc, 1 palettes
- ld a, BANK(wBGPals1)
- call FarCopyWRAM
- ret
-; 4942f (12:542f)
-
-MG_Mobile_Layout01: ; 4942f
- call MG_Mobile_Layout_LoadPals
- ld de, wBGPals1 palette PAL_BG_TEXT
- ld hl, .Palette_49478
- ld bc, 1 palettes
- ld a, BANK(wBGPals1)
- call FarCopyWRAM
- call MG_Mobile_Layout_WipeAttrMap
- hlcoord 0, 0, AttrMap
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- xor a
- call ByteFill
- hlcoord 0, 14, AttrMap
- ld bc, 4 * SCREEN_WIDTH
- ld a, $7
- call ByteFill
- ld a, [wd002]
- bit 6, a
- jr z, .asm_49464
- call Function49480
- jr .asm_49467
-
-.asm_49464
- call Function49496
-
-.asm_49467
- farcall ApplyAttrMap
- farcall ApplyPals
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-; 49478
-
-.Palette_49478: ; 49478
- RGB 31, 31, 31
- RGB 26, 31, 00
- RGB 20, 16, 03
- RGB 00, 00, 00
-; 49480
-
-Function49480: ; 49480
- hlcoord 0, 0, AttrMap
- lb bc, 4, SCREEN_WIDTH
- ld a, $7
- call MG_Mobile_Layout_FillBox
- hlcoord 0, 2, AttrMap
- ld a, $4
- ld [hl], a
- hlcoord 19, 2, AttrMap
- ld [hl], a
- ret
-; 49496
-
-Function49496: ; 49496
- hlcoord 0, 0, AttrMap
- lb bc, 2, SCREEN_WIDTH
- ld a, $7
- call MG_Mobile_Layout_FillBox
- hlcoord 0, 1, AttrMap
- ld a, $4
- ld [hl], a
- hlcoord 19, 1, AttrMap
- ld [hl], a
- ret
-; 494ac
-
-INCLUDE "engine/tileset_palettes.asm"
-
-MG_Mobile_Layout02: ; 49706
- ld hl, .Palette_49732
- ld de, wBGPals1
- ld bc, 1 palettes
- ld a, BANK(wBGPals1)
- call FarCopyWRAM
- farcall ApplyPals
- call MG_Mobile_Layout_WipeAttrMap
- farcall ApplyAttrMap
- ld hl, .Palette_4973a
- ld de, wOBPals1
- ld bc, 1 palettes
- ld a, BANK(wOBPals1)
- call FarCopyWRAM
- ret
-; 49732
-
-.Palette_49732: ; 49732
- RGB 31, 31, 31
- RGB 23, 16, 07
- RGB 23, 07, 07
- RGB 03, 07, 20
-; 4973a
-
-.Palette_4973a: ; 4973a
- RGB 00, 00, 00
- RGB 07, 05, 31
- RGB 14, 18, 31
- RGB 31, 31, 31
-; 49742
-
-Function49742: ; 49742
- ld hl, .Palette_49757
- ld de, wBGPals1
- ld bc, 8 palettes
- ld a, BANK(wBGPals1)
- call FarCopyWRAM
- farcall ApplyPals
- ret
-; 49757
-
-.Palette_49757: ; 49757
-INCLUDE "gfx/unknown/49757.pal"
-; 49797
-
-_InitMG_Mobile_LinkTradePalMap: ; 49797
- hlcoord 0, 0, AttrMap
- lb bc, 16, 2
- ld a, $4
- call MG_Mobile_Layout_FillBox
- ld a, $3
- ldcoord_a 0, 1, AttrMap
- ldcoord_a 0, 14, AttrMap
- hlcoord 2, 0, AttrMap
- lb bc, 8, 18
- ld a, $5
- call MG_Mobile_Layout_FillBox
- hlcoord 2, 8, AttrMap
- lb bc, 8, 18
- ld a, $6
- call MG_Mobile_Layout_FillBox
- hlcoord 0, 16, AttrMap
- lb bc, 2, SCREEN_WIDTH
- ld a, $4
- call MG_Mobile_Layout_FillBox
- ld a, $3
- lb bc, 6, 1
- hlcoord 6, 1, AttrMap
- call MG_Mobile_Layout_FillBox
- ld a, $3
- lb bc, 6, 1
- hlcoord 17, 1, AttrMap
- call MG_Mobile_Layout_FillBox
- ld a, $3
- lb bc, 6, 1
- hlcoord 6, 9, AttrMap
- call MG_Mobile_Layout_FillBox
- ld a, $3
- lb bc, 6, 1
- hlcoord 17, 9, AttrMap
- call MG_Mobile_Layout_FillBox
- ld a, $2
- hlcoord 2, 16, AttrMap
- ld [hli], a
- ld a, $7
- ld [hli], a
- ld [hli], a
- ld [hli], a
- ld a, $2
- ld [hl], a
- hlcoord 2, 17, AttrMap
- ld a, $3
- ld bc, 6
- call ByteFill
- ret
-; 49811
-
-LoadTradeRoomBGPals: ; 49811
- ld hl, TradeRoomPalette
- ld de, wBGPals1 palette PAL_BG_GREEN
- ld bc, 6 palettes
- ld a, BANK(wBGPals1)
- call FarCopyWRAM
- farcall ApplyPals
- ret
-; 49826
-
-TradeRoomPalette: ; 49826
-INCLUDE "gfx/trade/border.pal"
-; 49856
-
-InitMG_Mobile_LinkTradePalMap: ; 49856
- call _InitMG_Mobile_LinkTradePalMap
- ret
-; 4985a
-
-; unused
-INCLUDE "gfx/unknown/4985a.asm"
--- a/engine/init_gender.asm
+++ b/engine/init_gender.asm
@@ -96,7 +96,7 @@
; 48e5c (12:4e5c)
.Palette: ; 48e5c
-INCLUDE "gfx/intro/gender_screen.pal"
+INCLUDE "gfx/new_game/gender_screen.pal"
; 48e64
LoadGenderScreenLightBlueTile: ; 48e64 (12:4e64)
@@ -108,4 +108,4 @@
; 48e71 (12:4e71)
.LightBlueTile: ; 48e71
-INCBIN "gfx/intro/gender_screen.2bpp"
+INCBIN "gfx/new_game/gender_screen.2bpp"
--- /dev/null
+++ b/engine/naming_screen.asm
@@ -1,0 +1,1467 @@
+NAMINGSCREEN_CURSOR EQU $7e
+
+NAMINGSCREEN_BORDER EQUS "\"■\"" ; $60
+NAMINGSCREEN_MIDDLELINE EQUS "\"→\"" ; $eb
+NAMINGSCREEN_UNDERLINE EQUS "\"<DOT>\"" ; $f2
+
+_NamingScreen: ; 0x116b7
+ call DisableSpriteUpdates
+ call NamingScreen
+ call ReturnToMapWithSpeechTextbox
+ ret
+
+; 0x116c1
+
+NamingScreen: ; 116c1
+ ld hl, wNamingScreenDestinationPointer
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ ld hl, wNamingScreenType
+ 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
+ call .SetUpNamingScreen
+ call DelayFrame
+.loop
+ call NamingScreenJoypadLoop
+ jr nc, .loop
+ pop af
+ ld [hInMenu], a
+ pop af
+ ld [hMapAnims], a
+ pop af
+ ld [Options], a
+ call ClearJoypad
+ ret
+
+; 116f8
+
+.SetUpNamingScreen: ; 116f8
+ call ClearBGPalettes
+ ld b, SCGB_DIPLOMA
+ call GetSGBLayout
+ call DisableLCD
+ call LoadNamingScreenGFX
+ call NamingScreen_InitText
+ ld a, LCDC_DEFAULT
+ ld [rLCDC], a
+ call .GetNamingScreenSetup
+ call WaitBGMap
+ call WaitTop
+ call SetPalettes
+ call NamingScreen_InitNameEntry
+ ret
+
+; 1171d
+
+.GetNamingScreenSetup: ; 1171d
+ ld a, [wNamingScreenType]
+ and 7
+ ld e, a
+ ld d, 0
+ ld hl, .Jumptable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+; 1172e
+
+.Jumptable: ; 1172e (4:572e)
+ dw .Pokemon
+ dw .Player
+ dw .Rival
+ dw .Mom
+ dw .Box
+ dw .Tomodachi
+ dw .Pokemon
+ dw .Pokemon
+
+.Pokemon: ; 1173e (4:573e)
+ ld a, [CurPartySpecies]
+ ld [wd265], a
+ ld hl, LoadMenuMonIcon
+ ld a, BANK(LoadMenuMonIcon)
+ ld e, $1
+ rst FarCall ; ; indirect jump to LoadMenuMonIcon (8e83f (23:683f))
+ ld a, [CurPartySpecies]
+ ld [wd265], a
+ call GetPokemonName
+ hlcoord 5, 2
+ call PlaceString
+ ld l, c
+ ld h, b
+ ld de, .NicknameStrings
+ call PlaceString
+ inc de
+ hlcoord 5, 4
+ call PlaceString
+ farcall GetGender
+ jr c, .genderless
+ ld a, "♂"
+ jr nz, .place_gender
+ ld a, "♀"
+.place_gender
+ hlcoord 1, 2
+ ld [hl], a
+.genderless
+ call .StoreMonIconParams
+ ret
+
+; 11780 (4:5780)
+
+.NicknameStrings: ; 11780
+ db "'S@"
+ db "NICKNAME?@"
+
+; 1178d
+
+.Player: ; 1178d (4:578d)
+ farcall GetPlayerIcon
+ call .LoadSprite
+ hlcoord 5, 2
+ ld de, .PlayerNameString
+ call PlaceString
+ call .StoreSpriteIconParams
+ ret
+
+; 117a3 (4:57a3)
+
+.PlayerNameString: ; 117a3
+ db "YOUR NAME?@"
+
+; 117ae
+
+.Rival: ; 117ae (4:57ae)
+ ld de, SilverSpriteGFX
+ ld b, BANK(SilverSpriteGFX)
+ call .LoadSprite
+ hlcoord 5, 2
+ ld de, .RivalNameString
+ call PlaceString
+ call .StoreSpriteIconParams
+ ret
+
+; 117c3 (4:57c3)
+
+.RivalNameString: ; 117c3
+ db "RIVAL'S NAME?@"
+
+; 117d1
+
+.Mom: ; 117d1 (4:57d1)
+ ld de, MomSpriteGFX
+ ld b, BANK(MomSpriteGFX)
+ call .LoadSprite
+ hlcoord 5, 2
+ ld de, .MomNameString
+ call PlaceString
+ call .StoreSpriteIconParams
+ ret
+
+; 117e6 (4:57e6)
+
+.MomNameString: ; 117e6
+ db "MOTHER'S NAME?@"
+
+; 117f5
+
+.Box: ; 117f5 (4:57f5)
+ ld de, PokeBallSpriteGFX
+ ld hl, vTiles0 tile $00
+ lb bc, BANK(PokeBallSpriteGFX), 4
+ call Request2bpp
+ xor a
+ ld hl, wSpriteAnimDict
+ ld [hli], a
+ ld [hl], a
+ depixel 4, 4, 4, 0
+ ld a, SPRITE_ANIM_INDEX_RED_WALK
+ call _InitSpriteAnimStruct
+ ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
+ add hl, bc
+ ld [hl], $0
+ hlcoord 5, 2
+ ld de, .BoxNameString
+ call PlaceString
+ call .StoreBoxIconParams
+ ret
+
+; 11822 (4:5822)
+
+.BoxNameString: ; 11822
+ db "BOX NAME?@"
+
+; 1182c
+
+.Tomodachi: ; 1182c (4:582c)
+ hlcoord 3, 2
+ ld de, .oTomodachi_no_namae_sutoringu
+ call PlaceString
+ call .StoreSpriteIconParams
+ ret
+
+; 11839 (4:5839)
+
+.oTomodachi_no_namae_sutoringu ; 11839
+ db "おともだち の なまえは?@"
+
+; 11847
+
+.LoadSprite: ; 11847 (4:5847)
+ push de
+ ld hl, vTiles0 tile $00
+ ld c, $4
+ push bc
+ call Request2bpp
+ pop bc
+ ld hl, 12 tiles
+ add hl, de
+ ld e, l
+ ld d, h
+ ld hl, vTiles0 tile $04
+ call Request2bpp
+ xor a
+ ld hl, wSpriteAnimDict
+ ld [hli], a
+ ld [hl], a
+ pop de
+ ld b, SPRITE_ANIM_INDEX_RED_WALK
+ ld a, d
+ cp HIGH(KrisSpriteGFX)
+ jr nz, .not_kris
+ ld a, e
+ cp LOW(KrisSpriteGFX)
+ jr nz, .not_kris
+ ld b, SPRITE_ANIM_INDEX_BLUE_WALK
+.not_kris
+ ld a, b
+ depixel 4, 4, 4, 0
+ call _InitSpriteAnimStruct
+ ret
+
+.StoreMonIconParams: ; 1187b (4:587b)
+ ld a, MON_NAME_LENGTH - 1
+ hlcoord 5, 6
+ jr .StoreParams
+
+.StoreSpriteIconParams: ; 11882 (4:5882)
+ ld a, PLAYER_NAME_LENGTH - 1
+ hlcoord 5, 6
+ jr .StoreParams
+
+.StoreBoxIconParams: ; 11889 (4:5889)
+ ld a, BOX_NAME_LENGTH - 1
+ hlcoord 5, 4
+ jr .StoreParams
+
+.StoreParams: ; 11890 (4:5890)
+ ld [wNamingScreenMaxNameLength], a
+ ld a, l
+ ld [wNamingScreenStringEntryCoord], a
+ ld a, h
+ ld [wNamingScreenStringEntryCoord + 1], a
+ ret
+
+NamingScreen_IsTargetBox: ; 1189c
+ push bc
+ push af
+ ld a, [wNamingScreenType]
+ sub $3
+ ld b, a
+ pop af
+ dec b
+ pop bc
+ ret
+
+; 118a8
+
+NamingScreen_InitText: ; 118a8
+ call WaitTop
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
+ ld a, NAMINGSCREEN_BORDER
+ call ByteFill
+ hlcoord 1, 1
+ lb bc, 6, 18
+ call NamingScreen_IsTargetBox
+ jr nz, .not_box
+ lb bc, 4, 18
+
+.not_box
+ call ClearBox
+ ld de, NameInputUpper
+NamingScreen_ApplyTextInputMode: ; 118ca
+ call NamingScreen_IsTargetBox
+ jr nz, .not_box
+ ld hl, BoxNameInputLower - NameInputLower
+ add hl, de
+ ld d, h
+ ld e, l
+
+.not_box
+ push de
+ hlcoord 1, 8
+ lb bc, 7, 18
+ call NamingScreen_IsTargetBox
+ jr nz, .not_box_2
+ hlcoord 1, 6
+ lb bc, 9, 18
+
+.not_box_2
+ call ClearBox
+ hlcoord 1, 16
+ lb bc, 1, 18
+ call ClearBox
+ pop de
+ hlcoord 2, 8
+ ld b, $5
+ call NamingScreen_IsTargetBox
+ jr nz, .row
+ hlcoord 2, 6
+ ld b, $6
+
+.row
+ ld c, $11
+.col
+ ld a, [de]
+ ld [hli], a
+ inc de
+ dec c
+ jr nz, .col
+ push de
+ ld de, 2 * SCREEN_WIDTH - $11
+ add hl, de
+ pop de
+ dec b
+ jr nz, .row
+ ret
+
+; 11915
+
+NamingScreenJoypadLoop: ; 11915
+ call JoyTextDelay
+ ld a, [wJumptableIndex]
+ bit 7, a
+ jr nz, .quit
+ call .RunJumptable
+ farcall PlaySpriteAnimationsAndDelayFrame
+ call .UpdateStringEntry
+ call DelayFrame
+ and a
+ ret
+
+.quit
+ callfar ClearSpriteAnims
+ call ClearSprites
+ xor a
+ ld [hSCX], a
+ ld [hSCY], a
+ scf
+ ret
+
+; 11940
+
+.UpdateStringEntry: ; 11940
+ xor a
+ ld [hBGMapMode], a
+ hlcoord 1, 5
+ call NamingScreen_IsTargetBox
+ jr nz, .got_coords
+ hlcoord 1, 3
+
+.got_coords
+ lb bc, 1, 18
+ call ClearBox
+ ld hl, wNamingScreenDestinationPointer
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ ld hl, wNamingScreenStringEntryCoord
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call PlaceString
+ ld a, $1
+ ld [hBGMapMode], a
+ ret
+
+; 11968
+
+.RunJumptable: ; 11968
+ ld a, [wJumptableIndex]
+ ld e, a
+ ld d, $0
+ ld hl, .Jumptable
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+; 11977
+
+.Jumptable: ; 11977 (4:5977)
+ dw .InitCursor
+ dw .ReadButtons
+
+.InitCursor: ; 1197b (4:597b)
+ depixel 10, 3
+ call NamingScreen_IsTargetBox
+ jr nz, .got_cursor_position
+ ld d, 8 * 8
+.got_cursor_position
+ ld a, SPRITE_ANIM_INDEX_NAMING_SCREEN_CURSOR
+ 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
+
+.ReadButtons: ; 119a1 (4:59a1)
+ 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 .GetCursorPosition
+ cp $1
+ jr z, .select
+ cp $2
+ jr z, .b
+ cp $3
+ jr z, .end
+ call NamingScreen_GetLastCharacter
+ call NamingScreen_TryAddCharacter
+ ret nc
+
+.start
+ ld hl, wNamingScreenCursorObjectPointer
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld [hl], $8
+ ld hl, SPRITEANIMSTRUCT_0D
+ add hl, bc
+ ld [hl], $4
+ call NamingScreen_IsTargetBox
+ ret nz
+ inc [hl]
+ ret
+
+.b
+ call NamingScreen_DeleteCharacter
+ ret
+
+.end
+ call NamingScreen_StoreEntry
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+.select
+ ld hl, wNamingScreenLetterCase
+ ld a, [hl]
+ xor 1
+ ld [hl], a
+ jr z, .upper
+ ld de, NameInputLower
+ call NamingScreen_ApplyTextInputMode
+ ret
+
+.upper
+ ld de, NameInputUpper
+ call NamingScreen_ApplyTextInputMode
+ ret
+
+.GetCursorPosition: ; 11a0b (4:5a0b)
+ ld hl, wNamingScreenCursorObjectPointer
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+
+NamingScreen_GetCursorPosition: ; 11a11 (4:5a11)
+ ld hl, SPRITEANIMSTRUCT_0D
+ add hl, bc
+ ld a, [hl]
+ push bc
+ ld b, $4
+ call NamingScreen_IsTargetBox
+ jr nz, .not_box
+ inc b
+.not_box
+ cp b
+ pop bc
+ jr nz, .not_bottom_row
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld a, [hl]
+ cp $3
+ jr c, .case_switch
+ cp $6
+ jr c, .delete
+ ld a, $3
+ ret
+
+.case_switch
+ ld a, $1
+ ret
+
+.delete
+ ld a, $2
+ ret
+
+.not_bottom_row
+ xor a
+ ret
+
+NamingScreen_AnimateCursor: ; 11a3b (4:5a3b)
+ call .GetDPad
+ 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
+ ld d, $4
+ call NamingScreen_IsTargetBox
+ jr nz, .ok
+ inc d
+.ok
+ cp d
+ ld de, .LetterEntries
+ ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 0
+ jr nz, .ok2
+ ld de, .CaseDelEnd
+ ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR_BIG - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 1
+.ok2
+ ld hl, SPRITEANIMSTRUCT_0E
+ add hl, bc
+ add [hl] ; default SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR
+ 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
+
+; 11a79 (4:5a79)
+
+.LetterEntries: ; 11a79
+ db $00, $10, $20, $30, $40, $50, $60, $70, $80
+
+.CaseDelEnd: ; 11a82
+ db $00, $00, $00, $30, $30, $30, $60, $60, $60
+
+; 11a8b
+
+.GetDPad: ; 11a8b (4:5a8b)
+ 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 NamingScreen_GetCursorPosition
+ and a
+ jr nz, .asm_11ab7
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld a, [hl]
+ cp $8
+ jr nc, .asm_11ab4
+ inc [hl]
+ ret
+
+.asm_11ab4
+ ld [hl], $0
+ ret
+
+.asm_11ab7
+ cp $3
+ jr nz, .asm_11abc
+ xor a
+.asm_11abc
+ ld e, a
+ add a
+ add e
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld [hl], a
+ ret
+
+.left
+ call NamingScreen_GetCursorPosition
+ and a
+ jr nz, .asm_11ad8
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .asm_11ad5
+ dec [hl]
+ ret
+
+.asm_11ad5
+ ld [hl], $8
+ ret
+
+.asm_11ad8
+ cp $1
+ jr nz, .asm_11ade
+ ld a, $4
+.asm_11ade
+ dec a
+ dec a
+ 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]
+ call NamingScreen_IsTargetBox
+ jr nz, .asm_11af9
+ cp $5
+ jr nc, .asm_11aff
+ inc [hl]
+ ret
+
+.asm_11af9
+ cp $4
+ jr nc, .asm_11aff
+ inc [hl]
+ ret
+
+.asm_11aff
+ ld [hl], $0
+ ret
+
+.up
+ ld hl, SPRITEANIMSTRUCT_0D
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .asm_11b0c
+ dec [hl]
+ ret
+
+.asm_11b0c
+ ld [hl], $4
+ call NamingScreen_IsTargetBox
+ ret nz
+ inc [hl]
+ ret
+
+NamingScreen_TryAddCharacter: ; 11b14 (4:5b14)
+ ld a, [wNamingScreenLastCharacter] ; lost
+MailComposition_TryAddCharacter: ; 11b17 (4:5b17)
+ ld a, [wNamingScreenMaxNameLength]
+ ld c, a
+ ld a, [wNamingScreenCurrNameLength]
+ cp c
+ ret nc
+
+ ld a, [wNamingScreenLastCharacter]
+
+NamingScreen_LoadNextCharacter: ; 11b23
+ call NamingScreen_GetTextCursorPosition
+ ld [hl], a
+
+NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27
+ ld hl, wNamingScreenCurrNameLength
+ inc [hl]
+ call NamingScreen_GetTextCursorPosition
+ ld a, [hl]
+ cp "@"
+ jr z, .end_of_string
+ ld [hl], NAMINGSCREEN_UNDERLINE
+ and a
+ ret
+
+.end_of_string
+ scf
+ ret
+
+; 11b39 (4:5b39)
+
+; unused
+ ld a, [wNamingScreenCurrNameLength]
+ and a
+ ret z
+ push hl
+ ld hl, wNamingScreenCurrNameLength
+ dec [hl]
+ call NamingScreen_GetTextCursorPosition
+ ld c, [hl]
+ pop hl
+
+.loop
+ ld a, [hli]
+ cp $ff
+ jr z, NamingScreen_AdvanceCursor_CheckEndOfString
+ cp c
+ jr z, .done
+ inc hl
+ jr .loop
+
+.done
+ ld a, [hl]
+ jr NamingScreen_LoadNextCharacter
+
+; 11b56
+
+INCLUDE "data/unused/dakutens.asm"
+
+; 11bbc
+
+NamingScreen_DeleteCharacter: ; 11bbc (4:5bbc)
+ ld hl, wNamingScreenCurrNameLength
+ ld a, [hl]
+ and a
+ ret z
+ dec [hl]
+ call NamingScreen_GetTextCursorPosition
+ ld [hl], NAMINGSCREEN_UNDERLINE
+ inc hl
+ ld a, [hl]
+ cp NAMINGSCREEN_UNDERLINE
+ ret nz
+ ld [hl], NAMINGSCREEN_MIDDLELINE
+ ret
+
+NamingScreen_GetTextCursorPosition: ; 11bd0 (4:5bd0)
+ push af
+ ld hl, wNamingScreenDestinationPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wNamingScreenCurrNameLength]
+ ld e, a
+ ld d, 0
+ add hl, de
+ pop af
+ ret
+
+; 11be0
+
+NamingScreen_InitNameEntry: ; 11be0
+; load NAMINGSCREEN_UNDERLINE, (NAMINGSCREEN_MIDDLELINE * [wNamingScreenMaxNameLength]), "@" into the dw address at wNamingScreenDestinationPointer
+ ld hl, wNamingScreenDestinationPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld [hl], NAMINGSCREEN_UNDERLINE
+ inc hl
+ ld a, [wNamingScreenMaxNameLength]
+ dec a
+ ld c, a
+ ld a, NAMINGSCREEN_MIDDLELINE
+.loop
+ ld [hli], a
+ dec c
+ jr nz, .loop
+ ld [hl], "@"
+ ret
+
+; 11bf7
+
+NamingScreen_StoreEntry: ; 11bf7 (4:5bf7)
+ ld hl, wNamingScreenDestinationPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wNamingScreenMaxNameLength]
+ ld c, a
+.loop
+ ld a, [hl]
+ cp NAMINGSCREEN_MIDDLELINE
+ jr z, .terminator
+ cp NAMINGSCREEN_UNDERLINE
+ jr nz, .not_terminator
+.terminator
+ ld [hl], "@"
+.not_terminator
+ inc hl
+ dec c
+ jr nz, .loop
+ ret
+
+NamingScreen_GetLastCharacter: ; 11c11 (4:5c11)
+ ld hl, wNamingScreenCursorObjectPointer
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+ ld hl, SPRITEANIMSTRUCT_XOFFSET
+ add hl, bc
+ ld a, [hl]
+ ld hl, SPRITEANIMSTRUCT_XCOORD
+ add hl, bc
+ add [hl]
+ sub $8
+ srl a
+ srl a
+ srl a
+ ld e, a
+ ld hl, SPRITEANIMSTRUCT_YOFFSET
+ add hl, bc
+ ld a, [hl]
+ ld hl, SPRITEANIMSTRUCT_YCOORD
+ add hl, bc
+ add [hl]
+ sub $10
+ srl a
+ srl a
+ srl a
+ ld d, a
+ hlcoord 0, 0
+ ld bc, SCREEN_WIDTH
+.loop
+ ld a, d
+ and a
+ jr z, .done
+ add hl, bc
+ dec d
+ jr .loop
+
+.done
+ add hl, de
+ ld a, [hl]
+ ld [wNamingScreenLastCharacter], a
+ ret
+
+LoadNamingScreenGFX: ; 11c51
+ call ClearSprites
+ callfar ClearSpriteAnims
+ call LoadStandardFont
+ call LoadFontsExtra
+
+ ld de, NamingScreenGFX_MiddleLine
+ ld hl, vTiles0 tile NAMINGSCREEN_MIDDLELINE
+ lb bc, BANK(NamingScreenGFX_MiddleLine), 1
+ call Get1bpp
+
+ ld de, NamingScreenGFX_UnderLine
+ ld hl, vTiles0 tile NAMINGSCREEN_UNDERLINE
+ lb bc, BANK(NamingScreenGFX_UnderLine), 1
+ call Get1bpp
+
+ ld de, vTiles2 tile NAMINGSCREEN_BORDER
+ ld hl, NamingScreenGFX_Border
+ ld bc, 1 tiles
+ ld a, BANK(NamingScreenGFX_Border)
+ call FarCopyBytes
+
+ ld de, vTiles0 tile NAMINGSCREEN_CURSOR
+ ld hl, NamingScreenGFX_Cursor
+ ld bc, 2 tiles
+ ld a, BANK(NamingScreenGFX_Cursor)
+ call FarCopyBytes
+
+ ld a, $5
+ ld hl, wSpriteAnimDict + 9 * 2
+ ld [hli], a
+ ld [hl], NAMINGSCREEN_CURSOR
+ xor a
+ ld [hSCY], a
+ ld [wGlobalAnimYOffset], a
+ ld [hSCX], a
+ ld [wGlobalAnimXOffset], a
+ ld [wJumptableIndex], a
+ ld [wNamingScreenLetterCase], a
+ ld [hBGMapMode], a
+ ld [wNamingScreenCurrNameLength], a
+ ld a, $7
+ ld [hWX], a
+ ret
+
+; 11cb7
+
+NamingScreenGFX_Border: ; 11cb7
+INCBIN "gfx/naming_screen/border.2bpp"
+; 11cc7
+
+NamingScreenGFX_Cursor: ; 11cc7
+INCBIN "gfx/naming_screen/cursor.2bpp"
+; 11ce7
+
+INCLUDE "data/name_input_chars.asm"
+; 11e5d
+
+NamingScreenGFX_End: ; unused
+INCBIN "gfx/naming_screen/end.1bpp"
+; 11e6d
+
+NamingScreenGFX_MiddleLine:
+INCBIN "gfx/naming_screen/middle_line.1bpp"
+; 11e6d
+
+NamingScreenGFX_UnderLine: ; 11e6d
+INCBIN "gfx/naming_screen/underline.1bpp"
+; 11e75
+
+_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
+ ld de, vTiles0 tile $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
+ call _InitSpriteAnimStruct
+
+ ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
+ add hl, bc
+ ld [hl], $0
+ call .InitCharset
+ ld a, LCDC_DEFAULT
+ ld [rLCDC], a
+ call .initwNamingScreenMaxNameLength
+ ld b, SCGB_DIPLOMA
+ 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, MAIL_LINE_LENGTH
+ add hl, de
+ ld [hl], "<NEXT>"
+ ret
+
+; 11ef4 (4:5ef4)
+
+.MailIcon: ; 11ef4
+INCBIN "gfx/icons/mail_big.2bpp"
+; 11f74
+
+.initwNamingScreenMaxNameLength ; 11f74 (4:5f74)
+ ld a, MAIL_MSG_LENGTH + 1
+ ld [wNamingScreenMaxNameLength], a
+ ret
+
+; 11f7a (4:5f7a)
+
+.UnusedString11f7a:
+ db "メールを かいてね@"
+
+; 11f84
+
+.InitCharset: ; 11f84 (4:5f84)
+ call WaitTop
+ hlcoord 0, 0
+ ld bc, 6 * SCREEN_WIDTH
+ ld a, NAMINGSCREEN_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
+ farcall PlaySpriteAnimationsAndDelayFrame
+ call .Update
+ call DelayFrame
+ and a
+ ret
+
+.exit_mail
+ callfar ClearSpriteAnims
+ 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
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+.Jumptable: ; 12017 (4:6017)
+ dw .init_blinking_cursor
+ dw .process_joypad
+
+.init_blinking_cursor ; 1201b (4:601b)
+ depixel 9, 2
+ ld a, SPRITE_ANIM_INDEX_COMPOSE_MAIL_CURSOR
+ 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)
+ 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
+ cp $1
+ jr z, .select
+ cp $2
+ jr z, .b
+ cp $3
+ jr z, .finished
+ call NamingScreen_GetLastCharacter
+ call MailComposition_TryAddLastCharacter
+ jr c, .start
+ ld hl, wNamingScreenCurrNameLength
+ ld a, [hl]
+ cp MAIL_LINE_LENGTH
+ ret nz
+ inc [hl]
+ call NamingScreen_GetTextCursorPosition
+ ld [hl], NAMINGSCREEN_UNDERLINE
+ dec hl
+ ld [hl], "<NEXT>"
+ 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 MAIL_LINE_LENGTH
+ ret nz
+ dec [hl]
+ call NamingScreen_GetTextCursorPosition
+ ld [hl], NAMINGSCREEN_UNDERLINE
+ inc hl
+ ld [hl], "<NEXT>"
+ ret
+
+.finished
+ call NamingScreen_StoreEntry
+ ld hl, wJumptableIndex
+ set 7, [hl]
+ ret
+
+.select
+ ld hl, wNamingScreenLetterCase
+ 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
+
+ComposeMail_AnimateCursor: ; 120c1 (4:60c1)
+ call .GetDPad
+ 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
+ ld a, 0
+ jr nz, .got_pointer
+ ld de, .CaseDelEnd
+ ld a, 1
+.got_pointer
+ 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
+ db $00, $10, $20, $30, $40, $50, $60, $70, $80, $90
+
+.CaseDelEnd: ; 12102
+ db $00, $00, $00, $30, $30, $30, $60, $60, $60, $60
+
+; 1210c
+
+.GetDPad: ; 1210c (4:610c)
+ 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
+ and a
+ jr nz, .case_del_done_right
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld a, [hl]
+ cp $9
+ jr nc, .wrap_around_letter_right
+ inc [hl]
+ ret
+
+.wrap_around_letter_right
+ ld [hl], $0
+ ret
+
+.case_del_done_right
+ cp $3
+ jr nz, .wrap_around_command_right
+ xor a
+.wrap_around_command_right
+ ld e, a
+ add a
+ add e
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld [hl], a
+ ret
+
+.left
+ call ComposeMail_GetCursorPosition
+ and a
+ jr nz, .caps_del_done_left
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .wrap_around_letter_left
+ dec [hl]
+ ret
+
+.wrap_around_letter_left
+ ld [hl], $9
+ ret
+
+.caps_del_done_left
+ cp $1
+ jr nz, .wrap_around_command_left
+ ld a, $4
+.wrap_around_command_left
+ dec a
+ dec a
+ 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
+ inc [hl]
+ ret
+
+.wrap_around_down
+ ld [hl], $0
+ ret
+
+.up
+ ld hl, SPRITEANIMSTRUCT_0D
+ add hl, bc
+ ld a, [hl]
+ and a
+ jr z, .wrap_around_up
+ dec [hl]
+ ret
+
+.wrap_around_up
+ ld [hl], $5
+ ret
+
+NamingScreen_PressedA_GetCursorCommand: ; 12185 (4:6185)
+ ld hl, wNamingScreenCursorObjectPointer
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+
+ComposeMail_GetCursorPosition: ; 1218b (4:618b)
+ ld hl, SPRITEANIMSTRUCT_0D
+ add hl, bc
+ ld a, [hl]
+ cp $5
+ jr nz, .letter
+ ld hl, SPRITEANIMSTRUCT_0C
+ add hl, bc
+ ld a, [hl]
+ cp $3
+ jr c, .case
+ cp $6
+ jr c, .del
+ ld a, $3
+ ret
+
+.case
+ ld a, $1
+ ret
+
+.del
+ ld a, $2
+ ret
+
+.letter
+ xor a
+ ret
+
+MailComposition_TryAddLastCharacter: ; 121ac (4:61ac)
+ ld a, [wNamingScreenLastCharacter]
+ jp MailComposition_TryAddCharacter
+
+; 121b2 (4:61b2)
+
+; unused
+ ld a, [wNamingScreenCurrNameLength]
+ and a
+ ret z
+ cp $11
+ jr nz, .asm_121c3
+ push hl
+ ld hl, wNamingScreenCurrNameLength
+ dec [hl]
+ dec [hl]
+ 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
+
+; 121dd
+
+INCLUDE "data/mail_input_chars.asm"
+
+; 122c1
--- a/engine/namingscreen.asm
+++ /dev/null
@@ -1,1467 +1,0 @@
-NAMINGSCREEN_CURSOR EQU $7e
-
-NAMINGSCREEN_BORDER EQUS "\"■\"" ; $60
-NAMINGSCREEN_MIDDLELINE EQUS "\"→\"" ; $eb
-NAMINGSCREEN_UNDERLINE EQUS "\"<DOT>\"" ; $f2
-
-_NamingScreen: ; 0x116b7
- call DisableSpriteUpdates
- call NamingScreen
- call ReturnToMapWithSpeechTextbox
- ret
-
-; 0x116c1
-
-NamingScreen: ; 116c1
- ld hl, wNamingScreenDestinationPointer
- ld [hl], e
- inc hl
- ld [hl], d
- ld hl, wNamingScreenType
- 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
- call .SetUpNamingScreen
- call DelayFrame
-.loop
- call NamingScreenJoypadLoop
- jr nc, .loop
- pop af
- ld [hInMenu], a
- pop af
- ld [hMapAnims], a
- pop af
- ld [Options], a
- call ClearJoypad
- ret
-
-; 116f8
-
-.SetUpNamingScreen: ; 116f8
- call ClearBGPalettes
- ld b, SCGB_DIPLOMA
- call GetSGBLayout
- call DisableLCD
- call LoadNamingScreenGFX
- call NamingScreen_InitText
- ld a, LCDC_DEFAULT
- ld [rLCDC], a
- call .GetNamingScreenSetup
- call WaitBGMap
- call WaitTop
- call SetPalettes
- call NamingScreen_InitNameEntry
- ret
-
-; 1171d
-
-.GetNamingScreenSetup: ; 1171d
- ld a, [wNamingScreenType]
- and 7
- ld e, a
- ld d, 0
- ld hl, .Jumptable
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp hl
-
-; 1172e
-
-.Jumptable: ; 1172e (4:572e)
- dw .Pokemon
- dw .Player
- dw .Rival
- dw .Mom
- dw .Box
- dw .Tomodachi
- dw .Pokemon
- dw .Pokemon
-
-.Pokemon: ; 1173e (4:573e)
- ld a, [CurPartySpecies]
- ld [wd265], a
- ld hl, LoadMenuMonIcon
- ld a, BANK(LoadMenuMonIcon)
- ld e, $1
- rst FarCall ; ; indirect jump to LoadMenuMonIcon (8e83f (23:683f))
- ld a, [CurPartySpecies]
- ld [wd265], a
- call GetPokemonName
- hlcoord 5, 2
- call PlaceString
- ld l, c
- ld h, b
- ld de, .NicknameStrings
- call PlaceString
- inc de
- hlcoord 5, 4
- call PlaceString
- farcall GetGender
- jr c, .genderless
- ld a, "♂"
- jr nz, .place_gender
- ld a, "♀"
-.place_gender
- hlcoord 1, 2
- ld [hl], a
-.genderless
- call .StoreMonIconParams
- ret
-
-; 11780 (4:5780)
-
-.NicknameStrings: ; 11780
- db "'S@"
- db "NICKNAME?@"
-
-; 1178d
-
-.Player: ; 1178d (4:578d)
- farcall GetPlayerIcon
- call .LoadSprite
- hlcoord 5, 2
- ld de, .PlayerNameString
- call PlaceString
- call .StoreSpriteIconParams
- ret
-
-; 117a3 (4:57a3)
-
-.PlayerNameString: ; 117a3
- db "YOUR NAME?@"
-
-; 117ae
-
-.Rival: ; 117ae (4:57ae)
- ld de, SilverSpriteGFX
- ld b, BANK(SilverSpriteGFX)
- call .LoadSprite
- hlcoord 5, 2
- ld de, .RivalNameString
- call PlaceString
- call .StoreSpriteIconParams
- ret
-
-; 117c3 (4:57c3)
-
-.RivalNameString: ; 117c3
- db "RIVAL'S NAME?@"
-
-; 117d1
-
-.Mom: ; 117d1 (4:57d1)
- ld de, MomSpriteGFX
- ld b, BANK(MomSpriteGFX)
- call .LoadSprite
- hlcoord 5, 2
- ld de, .MomNameString
- call PlaceString
- call .StoreSpriteIconParams
- ret
-
-; 117e6 (4:57e6)
-
-.MomNameString: ; 117e6
- db "MOTHER'S NAME?@"
-
-; 117f5
-
-.Box: ; 117f5 (4:57f5)
- ld de, PokeBallSpriteGFX
- ld hl, vTiles0 tile $00
- lb bc, BANK(PokeBallSpriteGFX), 4
- call Request2bpp
- xor a
- ld hl, wSpriteAnimDict
- ld [hli], a
- ld [hl], a
- depixel 4, 4, 4, 0
- ld a, SPRITE_ANIM_INDEX_RED_WALK
- call _InitSpriteAnimStruct
- ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
- add hl, bc
- ld [hl], $0
- hlcoord 5, 2
- ld de, .BoxNameString
- call PlaceString
- call .StoreBoxIconParams
- ret
-
-; 11822 (4:5822)
-
-.BoxNameString: ; 11822
- db "BOX NAME?@"
-
-; 1182c
-
-.Tomodachi: ; 1182c (4:582c)
- hlcoord 3, 2
- ld de, .oTomodachi_no_namae_sutoringu
- call PlaceString
- call .StoreSpriteIconParams
- ret
-
-; 11839 (4:5839)
-
-.oTomodachi_no_namae_sutoringu ; 11839
- db "おともだち の なまえは?@"
-
-; 11847
-
-.LoadSprite: ; 11847 (4:5847)
- push de
- ld hl, vTiles0 tile $00
- ld c, $4
- push bc
- call Request2bpp
- pop bc
- ld hl, 12 tiles
- add hl, de
- ld e, l
- ld d, h
- ld hl, vTiles0 tile $04
- call Request2bpp
- xor a
- ld hl, wSpriteAnimDict
- ld [hli], a
- ld [hl], a
- pop de
- ld b, SPRITE_ANIM_INDEX_RED_WALK
- ld a, d
- cp HIGH(KrisSpriteGFX)
- jr nz, .not_kris
- ld a, e
- cp LOW(KrisSpriteGFX)
- jr nz, .not_kris
- ld b, SPRITE_ANIM_INDEX_BLUE_WALK
-.not_kris
- ld a, b
- depixel 4, 4, 4, 0
- call _InitSpriteAnimStruct
- ret
-
-.StoreMonIconParams: ; 1187b (4:587b)
- ld a, MON_NAME_LENGTH - 1
- hlcoord 5, 6
- jr .StoreParams
-
-.StoreSpriteIconParams: ; 11882 (4:5882)
- ld a, PLAYER_NAME_LENGTH - 1
- hlcoord 5, 6
- jr .StoreParams
-
-.StoreBoxIconParams: ; 11889 (4:5889)
- ld a, BOX_NAME_LENGTH - 1
- hlcoord 5, 4
- jr .StoreParams
-
-.StoreParams: ; 11890 (4:5890)
- ld [wNamingScreenMaxNameLength], a
- ld a, l
- ld [wNamingScreenStringEntryCoord], a
- ld a, h
- ld [wNamingScreenStringEntryCoord + 1], a
- ret
-
-NamingScreen_IsTargetBox: ; 1189c
- push bc
- push af
- ld a, [wNamingScreenType]
- sub $3
- ld b, a
- pop af
- dec b
- pop bc
- ret
-
-; 118a8
-
-NamingScreen_InitText: ; 118a8
- call WaitTop
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
- ld a, NAMINGSCREEN_BORDER
- call ByteFill
- hlcoord 1, 1
- lb bc, 6, 18
- call NamingScreen_IsTargetBox
- jr nz, .not_box
- lb bc, 4, 18
-
-.not_box
- call ClearBox
- ld de, NameInputUpper
-NamingScreen_ApplyTextInputMode: ; 118ca
- call NamingScreen_IsTargetBox
- jr nz, .not_box
- ld hl, BoxNameInputLower - NameInputLower
- add hl, de
- ld d, h
- ld e, l
-
-.not_box
- push de
- hlcoord 1, 8
- lb bc, 7, 18
- call NamingScreen_IsTargetBox
- jr nz, .not_box_2
- hlcoord 1, 6
- lb bc, 9, 18
-
-.not_box_2
- call ClearBox
- hlcoord 1, 16
- lb bc, 1, 18
- call ClearBox
- pop de
- hlcoord 2, 8
- ld b, $5
- call NamingScreen_IsTargetBox
- jr nz, .row
- hlcoord 2, 6
- ld b, $6
-
-.row
- ld c, $11
-.col
- ld a, [de]
- ld [hli], a
- inc de
- dec c
- jr nz, .col
- push de
- ld de, 2 * SCREEN_WIDTH - $11
- add hl, de
- pop de
- dec b
- jr nz, .row
- ret
-
-; 11915
-
-NamingScreenJoypadLoop: ; 11915
- call JoyTextDelay
- ld a, [wJumptableIndex]
- bit 7, a
- jr nz, .quit
- call .RunJumptable
- farcall PlaySpriteAnimationsAndDelayFrame
- call .UpdateStringEntry
- call DelayFrame
- and a
- ret
-
-.quit
- callfar ClearSpriteAnims
- call ClearSprites
- xor a
- ld [hSCX], a
- ld [hSCY], a
- scf
- ret
-
-; 11940
-
-.UpdateStringEntry: ; 11940
- xor a
- ld [hBGMapMode], a
- hlcoord 1, 5
- call NamingScreen_IsTargetBox
- jr nz, .got_coords
- hlcoord 1, 3
-
-.got_coords
- lb bc, 1, 18
- call ClearBox
- ld hl, wNamingScreenDestinationPointer
- ld e, [hl]
- inc hl
- ld d, [hl]
- ld hl, wNamingScreenStringEntryCoord
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call PlaceString
- ld a, $1
- ld [hBGMapMode], a
- ret
-
-; 11968
-
-.RunJumptable: ; 11968
- ld a, [wJumptableIndex]
- ld e, a
- ld d, $0
- ld hl, .Jumptable
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp hl
-
-; 11977
-
-.Jumptable: ; 11977 (4:5977)
- dw .InitCursor
- dw .ReadButtons
-
-.InitCursor: ; 1197b (4:597b)
- depixel 10, 3
- call NamingScreen_IsTargetBox
- jr nz, .got_cursor_position
- ld d, 8 * 8
-.got_cursor_position
- ld a, SPRITE_ANIM_INDEX_NAMING_SCREEN_CURSOR
- 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
-
-.ReadButtons: ; 119a1 (4:59a1)
- 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 .GetCursorPosition
- cp $1
- jr z, .select
- cp $2
- jr z, .b
- cp $3
- jr z, .end
- call NamingScreen_GetLastCharacter
- call NamingScreen_TryAddCharacter
- ret nc
-
-.start
- ld hl, wNamingScreenCursorObjectPointer
- ld c, [hl]
- inc hl
- ld b, [hl]
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld [hl], $8
- ld hl, SPRITEANIMSTRUCT_0D
- add hl, bc
- ld [hl], $4
- call NamingScreen_IsTargetBox
- ret nz
- inc [hl]
- ret
-
-.b
- call NamingScreen_DeleteCharacter
- ret
-
-.end
- call NamingScreen_StoreEntry
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-
-.select
- ld hl, wNamingScreenLetterCase
- ld a, [hl]
- xor 1
- ld [hl], a
- jr z, .upper
- ld de, NameInputLower
- call NamingScreen_ApplyTextInputMode
- ret
-
-.upper
- ld de, NameInputUpper
- call NamingScreen_ApplyTextInputMode
- ret
-
-.GetCursorPosition: ; 11a0b (4:5a0b)
- ld hl, wNamingScreenCursorObjectPointer
- ld c, [hl]
- inc hl
- ld b, [hl]
-
-NamingScreen_GetCursorPosition: ; 11a11 (4:5a11)
- ld hl, SPRITEANIMSTRUCT_0D
- add hl, bc
- ld a, [hl]
- push bc
- ld b, $4
- call NamingScreen_IsTargetBox
- jr nz, .not_box
- inc b
-.not_box
- cp b
- pop bc
- jr nz, .not_bottom_row
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld a, [hl]
- cp $3
- jr c, .case_switch
- cp $6
- jr c, .delete
- ld a, $3
- ret
-
-.case_switch
- ld a, $1
- ret
-
-.delete
- ld a, $2
- ret
-
-.not_bottom_row
- xor a
- ret
-
-NamingScreen_AnimateCursor: ; 11a3b (4:5a3b)
- call .GetDPad
- 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
- ld d, $4
- call NamingScreen_IsTargetBox
- jr nz, .ok
- inc d
-.ok
- cp d
- ld de, .LetterEntries
- ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 0
- jr nz, .ok2
- ld de, .CaseDelEnd
- ld a, SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR_BIG - SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR ; 1
-.ok2
- ld hl, SPRITEANIMSTRUCT_0E
- add hl, bc
- add [hl] ; default SPRITE_ANIM_FRAMESET_TEXT_ENTRY_CURSOR
- 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
-
-; 11a79 (4:5a79)
-
-.LetterEntries: ; 11a79
- db $00, $10, $20, $30, $40, $50, $60, $70, $80
-
-.CaseDelEnd: ; 11a82
- db $00, $00, $00, $30, $30, $30, $60, $60, $60
-
-; 11a8b
-
-.GetDPad: ; 11a8b (4:5a8b)
- 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 NamingScreen_GetCursorPosition
- and a
- jr nz, .asm_11ab7
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld a, [hl]
- cp $8
- jr nc, .asm_11ab4
- inc [hl]
- ret
-
-.asm_11ab4
- ld [hl], $0
- ret
-
-.asm_11ab7
- cp $3
- jr nz, .asm_11abc
- xor a
-.asm_11abc
- ld e, a
- add a
- add e
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld [hl], a
- ret
-
-.left
- call NamingScreen_GetCursorPosition
- and a
- jr nz, .asm_11ad8
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld a, [hl]
- and a
- jr z, .asm_11ad5
- dec [hl]
- ret
-
-.asm_11ad5
- ld [hl], $8
- ret
-
-.asm_11ad8
- cp $1
- jr nz, .asm_11ade
- ld a, $4
-.asm_11ade
- dec a
- dec a
- 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]
- call NamingScreen_IsTargetBox
- jr nz, .asm_11af9
- cp $5
- jr nc, .asm_11aff
- inc [hl]
- ret
-
-.asm_11af9
- cp $4
- jr nc, .asm_11aff
- inc [hl]
- ret
-
-.asm_11aff
- ld [hl], $0
- ret
-
-.up
- ld hl, SPRITEANIMSTRUCT_0D
- add hl, bc
- ld a, [hl]
- and a
- jr z, .asm_11b0c
- dec [hl]
- ret
-
-.asm_11b0c
- ld [hl], $4
- call NamingScreen_IsTargetBox
- ret nz
- inc [hl]
- ret
-
-NamingScreen_TryAddCharacter: ; 11b14 (4:5b14)
- ld a, [wNamingScreenLastCharacter] ; lost
-MailComposition_TryAddCharacter: ; 11b17 (4:5b17)
- ld a, [wNamingScreenMaxNameLength]
- ld c, a
- ld a, [wNamingScreenCurrNameLength]
- cp c
- ret nc
-
- ld a, [wNamingScreenLastCharacter]
-
-NamingScreen_LoadNextCharacter: ; 11b23
- call NamingScreen_GetTextCursorPosition
- ld [hl], a
-
-NamingScreen_AdvanceCursor_CheckEndOfString: ; 11b27
- ld hl, wNamingScreenCurrNameLength
- inc [hl]
- call NamingScreen_GetTextCursorPosition
- ld a, [hl]
- cp "@"
- jr z, .end_of_string
- ld [hl], NAMINGSCREEN_UNDERLINE
- and a
- ret
-
-.end_of_string
- scf
- ret
-
-; 11b39 (4:5b39)
-
-; unused
- ld a, [wNamingScreenCurrNameLength]
- and a
- ret z
- push hl
- ld hl, wNamingScreenCurrNameLength
- dec [hl]
- call NamingScreen_GetTextCursorPosition
- ld c, [hl]
- pop hl
-
-.loop
- ld a, [hli]
- cp $ff
- jr z, NamingScreen_AdvanceCursor_CheckEndOfString
- cp c
- jr z, .done
- inc hl
- jr .loop
-
-.done
- ld a, [hl]
- jr NamingScreen_LoadNextCharacter
-
-; 11b56
-
-INCLUDE "data/unused/dakutens.asm"
-
-; 11bbc
-
-NamingScreen_DeleteCharacter: ; 11bbc (4:5bbc)
- ld hl, wNamingScreenCurrNameLength
- ld a, [hl]
- and a
- ret z
- dec [hl]
- call NamingScreen_GetTextCursorPosition
- ld [hl], NAMINGSCREEN_UNDERLINE
- inc hl
- ld a, [hl]
- cp NAMINGSCREEN_UNDERLINE
- ret nz
- ld [hl], NAMINGSCREEN_MIDDLELINE
- ret
-
-NamingScreen_GetTextCursorPosition: ; 11bd0 (4:5bd0)
- push af
- ld hl, wNamingScreenDestinationPointer
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [wNamingScreenCurrNameLength]
- ld e, a
- ld d, 0
- add hl, de
- pop af
- ret
-
-; 11be0
-
-NamingScreen_InitNameEntry: ; 11be0
-; load NAMINGSCREEN_UNDERLINE, (NAMINGSCREEN_MIDDLELINE * [wNamingScreenMaxNameLength]), "@" into the dw address at wNamingScreenDestinationPointer
- ld hl, wNamingScreenDestinationPointer
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld [hl], NAMINGSCREEN_UNDERLINE
- inc hl
- ld a, [wNamingScreenMaxNameLength]
- dec a
- ld c, a
- ld a, NAMINGSCREEN_MIDDLELINE
-.loop
- ld [hli], a
- dec c
- jr nz, .loop
- ld [hl], "@"
- ret
-
-; 11bf7
-
-NamingScreen_StoreEntry: ; 11bf7 (4:5bf7)
- ld hl, wNamingScreenDestinationPointer
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [wNamingScreenMaxNameLength]
- ld c, a
-.loop
- ld a, [hl]
- cp NAMINGSCREEN_MIDDLELINE
- jr z, .terminator
- cp NAMINGSCREEN_UNDERLINE
- jr nz, .not_terminator
-.terminator
- ld [hl], "@"
-.not_terminator
- inc hl
- dec c
- jr nz, .loop
- ret
-
-NamingScreen_GetLastCharacter: ; 11c11 (4:5c11)
- ld hl, wNamingScreenCursorObjectPointer
- ld c, [hl]
- inc hl
- ld b, [hl]
- ld hl, SPRITEANIMSTRUCT_XOFFSET
- add hl, bc
- ld a, [hl]
- ld hl, SPRITEANIMSTRUCT_XCOORD
- add hl, bc
- add [hl]
- sub $8
- srl a
- srl a
- srl a
- ld e, a
- ld hl, SPRITEANIMSTRUCT_YOFFSET
- add hl, bc
- ld a, [hl]
- ld hl, SPRITEANIMSTRUCT_YCOORD
- add hl, bc
- add [hl]
- sub $10
- srl a
- srl a
- srl a
- ld d, a
- hlcoord 0, 0
- ld bc, SCREEN_WIDTH
-.loop
- ld a, d
- and a
- jr z, .done
- add hl, bc
- dec d
- jr .loop
-
-.done
- add hl, de
- ld a, [hl]
- ld [wNamingScreenLastCharacter], a
- ret
-
-LoadNamingScreenGFX: ; 11c51
- call ClearSprites
- callfar ClearSpriteAnims
- call LoadStandardFont
- call LoadFontsExtra
-
- ld de, NamingScreenGFX_MiddleLine
- ld hl, vTiles0 tile NAMINGSCREEN_MIDDLELINE
- lb bc, BANK(NamingScreenGFX_MiddleLine), 1
- call Get1bpp
-
- ld de, NamingScreenGFX_UnderLine
- ld hl, vTiles0 tile NAMINGSCREEN_UNDERLINE
- lb bc, BANK(NamingScreenGFX_UnderLine), 1
- call Get1bpp
-
- ld de, vTiles2 tile NAMINGSCREEN_BORDER
- ld hl, NamingScreenGFX_Border
- ld bc, 1 tiles
- ld a, BANK(NamingScreenGFX_Border)
- call FarCopyBytes
-
- ld de, vTiles0 tile NAMINGSCREEN_CURSOR
- ld hl, NamingScreenGFX_Cursor
- ld bc, 2 tiles
- ld a, BANK(NamingScreenGFX_Cursor)
- call FarCopyBytes
-
- ld a, $5
- ld hl, wSpriteAnimDict + 9 * 2
- ld [hli], a
- ld [hl], NAMINGSCREEN_CURSOR
- xor a
- ld [hSCY], a
- ld [wGlobalAnimYOffset], a
- ld [hSCX], a
- ld [wGlobalAnimXOffset], a
- ld [wJumptableIndex], a
- ld [wNamingScreenLetterCase], a
- ld [hBGMapMode], a
- ld [wNamingScreenCurrNameLength], a
- ld a, $7
- ld [hWX], a
- ret
-
-; 11cb7
-
-NamingScreenGFX_Border: ; 11cb7
-INCBIN "gfx/namingscreen/border.2bpp"
-; 11cc7
-
-NamingScreenGFX_Cursor: ; 11cc7
-INCBIN "gfx/namingscreen/cursor.2bpp"
-; 11ce7
-
-INCLUDE "data/name_input_chars.asm"
-; 11e5d
-
-NamingScreenGFX_End: ; unused
-INCBIN "gfx/namingscreen/end.1bpp"
-; 11e6d
-
-NamingScreenGFX_MiddleLine:
-INCBIN "gfx/namingscreen/middle_line.1bpp"
-; 11e6d
-
-NamingScreenGFX_UnderLine: ; 11e6d
-INCBIN "gfx/namingscreen/underline.1bpp"
-; 11e75
-
-_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
- ld de, vTiles0 tile $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
- call _InitSpriteAnimStruct
-
- ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
- add hl, bc
- ld [hl], $0
- call .InitCharset
- ld a, LCDC_DEFAULT
- ld [rLCDC], a
- call .initwNamingScreenMaxNameLength
- ld b, SCGB_DIPLOMA
- 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, MAIL_LINE_LENGTH
- add hl, de
- ld [hl], "<NEXT>"
- ret
-
-; 11ef4 (4:5ef4)
-
-.MailIcon: ; 11ef4
-INCBIN "gfx/icons/mail2.2bpp"
-; 11f74
-
-.initwNamingScreenMaxNameLength ; 11f74 (4:5f74)
- ld a, MAIL_MSG_LENGTH + 1
- ld [wNamingScreenMaxNameLength], a
- ret
-
-; 11f7a (4:5f7a)
-
-.UnusedString11f7a:
- db "メールを かいてね@"
-
-; 11f84
-
-.InitCharset: ; 11f84 (4:5f84)
- call WaitTop
- hlcoord 0, 0
- ld bc, 6 * SCREEN_WIDTH
- ld a, NAMINGSCREEN_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
- farcall PlaySpriteAnimationsAndDelayFrame
- call .Update
- call DelayFrame
- and a
- ret
-
-.exit_mail
- callfar ClearSpriteAnims
- 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
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp hl
-
-.Jumptable: ; 12017 (4:6017)
- dw .init_blinking_cursor
- dw .process_joypad
-
-.init_blinking_cursor ; 1201b (4:601b)
- depixel 9, 2
- ld a, SPRITE_ANIM_INDEX_COMPOSE_MAIL_CURSOR
- 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)
- 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
- cp $1
- jr z, .select
- cp $2
- jr z, .b
- cp $3
- jr z, .finished
- call NamingScreen_GetLastCharacter
- call MailComposition_TryAddLastCharacter
- jr c, .start
- ld hl, wNamingScreenCurrNameLength
- ld a, [hl]
- cp MAIL_LINE_LENGTH
- ret nz
- inc [hl]
- call NamingScreen_GetTextCursorPosition
- ld [hl], NAMINGSCREEN_UNDERLINE
- dec hl
- ld [hl], "<NEXT>"
- 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 MAIL_LINE_LENGTH
- ret nz
- dec [hl]
- call NamingScreen_GetTextCursorPosition
- ld [hl], NAMINGSCREEN_UNDERLINE
- inc hl
- ld [hl], "<NEXT>"
- ret
-
-.finished
- call NamingScreen_StoreEntry
- ld hl, wJumptableIndex
- set 7, [hl]
- ret
-
-.select
- ld hl, wNamingScreenLetterCase
- 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
-
-ComposeMail_AnimateCursor: ; 120c1 (4:60c1)
- call .GetDPad
- 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
- ld a, 0
- jr nz, .got_pointer
- ld de, .CaseDelEnd
- ld a, 1
-.got_pointer
- 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
- db $00, $10, $20, $30, $40, $50, $60, $70, $80, $90
-
-.CaseDelEnd: ; 12102
- db $00, $00, $00, $30, $30, $30, $60, $60, $60, $60
-
-; 1210c
-
-.GetDPad: ; 1210c (4:610c)
- 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
- and a
- jr nz, .case_del_done_right
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld a, [hl]
- cp $9
- jr nc, .wrap_around_letter_right
- inc [hl]
- ret
-
-.wrap_around_letter_right
- ld [hl], $0
- ret
-
-.case_del_done_right
- cp $3
- jr nz, .wrap_around_command_right
- xor a
-.wrap_around_command_right
- ld e, a
- add a
- add e
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld [hl], a
- ret
-
-.left
- call ComposeMail_GetCursorPosition
- and a
- jr nz, .caps_del_done_left
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld a, [hl]
- and a
- jr z, .wrap_around_letter_left
- dec [hl]
- ret
-
-.wrap_around_letter_left
- ld [hl], $9
- ret
-
-.caps_del_done_left
- cp $1
- jr nz, .wrap_around_command_left
- ld a, $4
-.wrap_around_command_left
- dec a
- dec a
- 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
- inc [hl]
- ret
-
-.wrap_around_down
- ld [hl], $0
- ret
-
-.up
- ld hl, SPRITEANIMSTRUCT_0D
- add hl, bc
- ld a, [hl]
- and a
- jr z, .wrap_around_up
- dec [hl]
- ret
-
-.wrap_around_up
- ld [hl], $5
- ret
-
-NamingScreen_PressedA_GetCursorCommand: ; 12185 (4:6185)
- ld hl, wNamingScreenCursorObjectPointer
- ld c, [hl]
- inc hl
- ld b, [hl]
-
-ComposeMail_GetCursorPosition: ; 1218b (4:618b)
- ld hl, SPRITEANIMSTRUCT_0D
- add hl, bc
- ld a, [hl]
- cp $5
- jr nz, .letter
- ld hl, SPRITEANIMSTRUCT_0C
- add hl, bc
- ld a, [hl]
- cp $3
- jr c, .case
- cp $6
- jr c, .del
- ld a, $3
- ret
-
-.case
- ld a, $1
- ret
-
-.del
- ld a, $2
- ret
-
-.letter
- xor a
- ret
-
-MailComposition_TryAddLastCharacter: ; 121ac (4:61ac)
- ld a, [wNamingScreenLastCharacter]
- jp MailComposition_TryAddCharacter
-
-; 121b2 (4:61b2)
-
-; unused
- ld a, [wNamingScreenCurrNameLength]
- and a
- ret z
- cp $11
- jr nz, .asm_121c3
- push hl
- ld hl, wNamingScreenCurrNameLength
- dec [hl]
- dec [hl]
- 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
-
-; 121dd
-
-INCLUDE "data/mail_input_chars.asm"
-
-; 122c1
--- a/engine/timeset.asm
+++ b/engine/timeset.asm
@@ -400,11 +400,11 @@
; 0x908fb
TimeSetBackgroundGFX: ; 908fb
-INCBIN "gfx/timeset/background.1bpp"
+INCBIN "gfx/new_game/timeset_bg.1bpp"
TimeSetUpArrowGFX: ; 90903
-INCBIN "gfx/timeset/up_arrow.1bpp"
+INCBIN "gfx/new_game/up_arrow.1bpp"
TimeSetDownArrowGFX: ; 9090b
-INCBIN "gfx/timeset/down_arrow.1bpp"
+INCBIN "gfx/new_game/down_arrow.1bpp"
; 90913
Special_SetDayOfWeek: ; 90913
binary files a/gfx/icons/mail2.png /dev/null differ
binary files /dev/null b/gfx/icons/mail_big.png differ
--- a/gfx/intro/gender_screen.pal
+++ /dev/null
@@ -1,4 +1,0 @@
- RGB 31, 31, 31
- RGB 09, 30, 31
- RGB 01, 11, 31
- RGB 00, 00, 00
binary files a/gfx/intro/gender_screen.png /dev/null differ
binary files /dev/null b/gfx/naming_screen/border.png differ
binary files /dev/null b/gfx/naming_screen/cursor.png differ
binary files /dev/null b/gfx/naming_screen/end.png differ
binary files /dev/null b/gfx/naming_screen/middle_line.png differ
binary files /dev/null b/gfx/naming_screen/underline.png differ
binary files a/gfx/namingscreen/border.png /dev/null differ
binary files a/gfx/namingscreen/cursor.png /dev/null differ
binary files a/gfx/namingscreen/end.png /dev/null differ
binary files a/gfx/namingscreen/middle_line.png /dev/null differ
binary files a/gfx/namingscreen/underline.png /dev/null differ
binary files /dev/null b/gfx/new_game/down_arrow.png differ
--- /dev/null
+++ b/gfx/new_game/gender_screen.pal
@@ -1,0 +1,4 @@
+ RGB 31, 31, 31
+ RGB 09, 30, 31
+ RGB 01, 11, 31
+ RGB 00, 00, 00
binary files /dev/null b/gfx/new_game/gender_screen.png differ
binary files /dev/null b/gfx/new_game/shrink1.2bpp.lz.d4443930 differ
binary files /dev/null b/gfx/new_game/shrink1.png differ
binary files /dev/null b/gfx/new_game/shrink2.2bpp.lz.3f58480a differ
binary files /dev/null b/gfx/new_game/shrink2.png differ
binary files /dev/null b/gfx/new_game/timeset_bg.png differ
binary files /dev/null b/gfx/new_game/up_arrow.png differ
binary files a/gfx/shrink/shrink1.2bpp.lz.d4443930 /dev/null differ
binary files a/gfx/shrink/shrink1.png /dev/null differ
binary files a/gfx/shrink/shrink2.2bpp.lz.3f58480a /dev/null differ
binary files a/gfx/shrink/shrink2.png /dev/null differ
binary files a/gfx/timeset/background.png /dev/null differ
binary files a/gfx/timeset/down_arrow.png /dev/null differ
binary files a/gfx/timeset/up_arrow.png /dev/null differ
--- a/main.asm
+++ b/main.asm
@@ -49,7 +49,7 @@
INCLUDE "engine/pack.asm"
INCLUDE "engine/time.asm"
INCLUDE "engine/tmhm.asm"
-INCLUDE "engine/namingscreen.asm"
+INCLUDE "engine/naming_screen.asm"
INCLUDE "engine/events/misc_scripts.asm"
INCLUDE "engine/events/heal_machine_anim.asm"
INCLUDE "engine/events/whiteout.asm"
@@ -194,7 +194,7 @@
INCLUDE "engine/init_gender.asm"
INCLUDE "engine/routines/drawkrispackgfx.asm"
INCLUDE "engine/events/move_tutor.asm"
-INCLUDE "engine/crystal_colors.asm"
+INCLUDE "engine/crystal_cgb.asm"
INCLUDE "engine/events/celebi.asm"
INCLUDE "engine/main_menu.asm"
INCLUDE "mobile/mobile_menu.asm"
@@ -216,10 +216,10 @@
INCLUDE "engine/routines/phonering_copytilemapatonce.asm"
Shrink1Pic: ; 4d249
-INCBIN "gfx/shrink/shrink1.2bpp.lz"
+INCBIN "gfx/new_game/shrink1.2bpp.lz"
Shrink2Pic: ; 4d2d9
-INCBIN "gfx/shrink/shrink2.2bpp.lz"
+INCBIN "gfx/new_game/shrink2.2bpp.lz"
INCLUDE "engine/link_2.asm"
INCLUDE "engine/delete_save_change_clock.asm"