Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/movie/oak_speech/oak_speech2.asm
1271 views
1
ChoosePlayerName:
2
call OakSpeechSlidePicRight
3
ld de, DefaultNamesPlayer
4
call DisplayIntroNameTextBox
5
ld a, [wCurrentMenuItem]
6
and a
7
jr z, .customName
8
ld hl, DefaultNamesPlayerList
9
call GetDefaultName
10
ld de, wPlayerName
11
call OakSpeechSlidePicLeft
12
jr .done
13
.customName
14
ld hl, wPlayerName
15
xor a ; NAME_PLAYER_SCREEN
16
ld [wNamingScreenType], a
17
call DisplayNamingScreen
18
ld a, [wStringBuffer]
19
cp "@"
20
jr z, .customName
21
call ClearScreen
22
call Delay3
23
ld de, RedPicFront
24
ld b, BANK(RedPicFront)
25
call IntroDisplayPicCenteredOrUpperRight
26
.done
27
ld hl, YourNameIsText
28
jp PrintText
29
30
YourNameIsText:
31
text_far _YourNameIsText
32
text_end
33
34
ChooseRivalName:
35
call OakSpeechSlidePicRight
36
ld de, DefaultNamesRival
37
call DisplayIntroNameTextBox
38
ld a, [wCurrentMenuItem]
39
and a
40
jr z, .customName
41
ld hl, DefaultNamesRivalList
42
call GetDefaultName
43
ld de, wRivalName
44
call OakSpeechSlidePicLeft
45
jr .done
46
.customName
47
ld hl, wRivalName
48
ld a, NAME_RIVAL_SCREEN
49
ld [wNamingScreenType], a
50
call DisplayNamingScreen
51
ld a, [wStringBuffer]
52
cp "@"
53
jr z, .customName
54
call ClearScreen
55
call Delay3
56
ld de, Rival1Pic
57
ld b, BANK(Rival1Pic)
58
call IntroDisplayPicCenteredOrUpperRight
59
.done
60
ld hl, HisNameIsText
61
jp PrintText
62
63
HisNameIsText:
64
text_far _HisNameIsText
65
text_end
66
67
OakSpeechSlidePicLeft:
68
push de
69
hlcoord 0, 0
70
lb bc, 12, 11
71
call ClearScreenArea ; clear the name list text box
72
ld c, 10
73
call DelayFrames
74
pop de
75
ld hl, wNameBuffer
76
ld bc, NAME_LENGTH
77
call CopyData
78
call Delay3
79
hlcoord 12, 4
80
lb de, 6, 6 * SCREEN_WIDTH + 5
81
ld a, $ff
82
jr OakSpeechSlidePicCommon
83
84
OakSpeechSlidePicRight:
85
hlcoord 5, 4
86
lb de, 6, 6 * SCREEN_WIDTH + 5
87
xor a
88
89
OakSpeechSlidePicCommon:
90
push hl
91
push de
92
push bc
93
ldh [hSlideDirection], a
94
ld a, d
95
ldh [hSlideAmount], a
96
ld a, e
97
ldh [hSlidingRegionSize], a
98
ld c, a
99
ldh a, [hSlideDirection]
100
and a
101
jr nz, .next
102
; If sliding right, point hl to the end of the pic's tiles.
103
ld d, 0
104
add hl, de
105
.next
106
ld d, h
107
ld e, l
108
.loop
109
xor a
110
ldh [hAutoBGTransferEnabled], a
111
ldh a, [hSlideDirection]
112
and a
113
jr nz, .slideLeft
114
; sliding right
115
ld a, [hli]
116
ld [hld], a
117
dec hl
118
jr .next2
119
.slideLeft
120
ld a, [hld]
121
ld [hli], a
122
inc hl
123
.next2
124
dec c
125
jr nz, .loop
126
ldh a, [hSlideDirection]
127
and a
128
jr z, .next3
129
; If sliding left, we need to zero the last tile in the pic (there is no need
130
; to take a corresponding action when sliding right because hl initially points
131
; to a 0 tile in that case).
132
xor a
133
dec hl
134
ld [hl], a
135
.next3
136
ld a, 1
137
ldh [hAutoBGTransferEnabled], a
138
call Delay3
139
ldh a, [hSlidingRegionSize]
140
ld c, a
141
ld h, d
142
ld l, e
143
ldh a, [hSlideDirection]
144
and a
145
jr nz, .slideLeft2
146
inc hl
147
jr .next4
148
.slideLeft2
149
dec hl
150
.next4
151
ld d, h
152
ld e, l
153
ldh a, [hSlideAmount]
154
dec a
155
ldh [hSlideAmount], a
156
jr nz, .loop
157
pop bc
158
pop de
159
pop hl
160
ret
161
162
DisplayIntroNameTextBox:
163
push de
164
hlcoord 0, 0
165
ld b, $a
166
ld c, $9
167
call TextBoxBorder
168
hlcoord 3, 0
169
ld de, .namestring
170
call PlaceString
171
pop de
172
hlcoord 2, 2
173
call PlaceString
174
call UpdateSprites
175
xor a
176
ld [wCurrentMenuItem], a
177
ld [wLastMenuItem], a
178
inc a
179
ld [wTopMenuItemX], a
180
ld [wMenuWatchedKeys], a ; PAD_A
181
inc a
182
ld [wTopMenuItemY], a
183
inc a
184
ld [wMaxMenuItem], a
185
jp HandleMenuInput
186
187
.namestring
188
db "NAME@"
189
190
INCLUDE "data/player_names.asm"
191
192
GetDefaultName:
193
; a = name index
194
; hl = name list
195
ld b, a
196
ld c, 0
197
.loop
198
ld d, h
199
ld e, l
200
.innerLoop
201
ld a, [hli]
202
cp "@"
203
jr nz, .innerLoop
204
ld a, b
205
cp c
206
jr z, .foundName
207
inc c
208
jr .loop
209
.foundName
210
ld h, d
211
ld l, e
212
ld de, wNameBuffer
213
ld bc, NAME_BUFFER_LENGTH
214
jp CopyData
215
216
INCLUDE "data/player_names_list.asm"
217
218
LinkMenuEmptyText:
219
text_end
220
221