Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/menus/display_text_id_init.asm
1271 views
1
; function that performs initialization for DisplayTextID
2
DisplayTextIDInit::
3
xor a
4
ld [wListMenuID], a
5
ld a, [wAutoTextBoxDrawingControl]
6
bit BIT_NO_AUTO_TEXT_BOX, a
7
jr nz, .skipDrawingTextBoxBorder
8
ldh a, [hTextID]
9
and a
10
jr nz, .notStartMenu
11
; if text ID is 0 (i.e. the start menu)
12
; Note that the start menu text border is also drawn in the function directly
13
; below this, so this seems unnecessary.
14
CheckEvent EVENT_GOT_POKEDEX
15
; start menu with pokedex
16
hlcoord 10, 0
17
ld b, $0e
18
ld c, $08
19
jr nz, .drawTextBoxBorder
20
; start menu without pokedex
21
hlcoord 10, 0
22
ld b, $0c
23
ld c, $08
24
jr .drawTextBoxBorder
25
; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
26
.notStartMenu
27
hlcoord 0, 12
28
ld b, $04
29
ld c, $12
30
.drawTextBoxBorder
31
call TextBoxBorder
32
.skipDrawingTextBoxBorder
33
ld hl, wFontLoaded
34
set BIT_FONT_LOADED, [hl]
35
ld hl, wMiscFlags
36
bit BIT_NO_SPRITE_UPDATES, [hl]
37
res BIT_NO_SPRITE_UPDATES, [hl]
38
jr nz, .skipMovingSprites
39
call UpdateSprites
40
.skipMovingSprites
41
; loop to copy [x#SPRITESTATEDATA1_FACINGDIRECTION] to
42
; [x#SPRITESTATEDATA2_ORIGFACINGDIRECTION] for each non-player sprite
43
; this is done because when you talk to an NPC, they turn to look your way
44
; the original direction they were facing must be restored after the dialogue is over
45
ld hl, wSprite01StateData1FacingDirection
46
ld c, $0f
47
ld de, $10
48
.spriteFacingDirectionCopyLoop
49
ld a, [hl] ; x#SPRITESTATEDATA1_FACINGDIRECTION
50
inc h
51
ld [hl], a ; [x#SPRITESTATEDATA2_ORIGFACINGDIRECTION]
52
dec h
53
add hl, de
54
dec c
55
jr nz, .spriteFacingDirectionCopyLoop
56
; loop to force all the sprites in the middle of animation to stand still
57
; (so that they don't like they're frozen mid-step during the dialogue)
58
ld hl, wSpritePlayerStateData1ImageIndex
59
ld de, $10
60
ld c, e
61
.spriteStandStillLoop
62
ld a, [hl]
63
cp $ff ; is the sprite visible?
64
jr z, .nextSprite
65
; if it is visible
66
and $fc
67
ld [hl], a
68
.nextSprite
69
add hl, de
70
dec c
71
jr nz, .spriteStandStillLoop
72
ld b, HIGH(vBGMap1)
73
call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
74
xor a
75
ldh [hWY], a ; put the window on the screen
76
call LoadFontTilePatterns
77
ld a, $01
78
ldh [hAutoBGTransferEnabled], a ; enable continuous WRAM to VRAM transfer each V-blank
79
ret
80
81