1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
HandleFieldSelectScreen: ; 0xd6d3
ld a, [wScreenState]
rst JumpTable ; calls JumpToFuncInTable
FieldSelectScreenFunctions: ; 0xd6d7
dw LoadFieldSelectScreen
dw ChooseFieldToPlay
dw ExitFieldSelectScreen
LoadFieldSelectScreen: ; 0xd6dd
ld a, $43
ld [hLCDC], a
ld a, $e4
ld [wBGP], a
ld a, $d2
ld [wOBP0], a
ld [wOBP1], a
xor a
ld [hSCX], a
ld [hSCY], a
ld hl, FieldSelectGfxPointers
ld a, [hGameBoyColorFlag]
call LoadVideoData
call ClearOAMBuffer
ld a, $8
ld [wFieldSelectBlinkingBorderFrame], a
call SetAllPalettesWhite
ld a, Bank(Music_FieldSelect)
call SetSongBank
ld de, MUSIC_FIELD_SELECT
call PlaySong
call EnableLCD
call FadeIn
ld hl, wScreenState
inc [hl]
ret
FieldSelectGfxPointers: ; 0xd71c
dw FieldSelectGfx_GameBoy
dw FieldSelectGfx_GameBoyColor
FieldSelectGfx_GameBoy: ; 0xd720
VIDEO_DATA_TILES FieldSelectScreenGfx, vTilesSH - $100, $d00
VIDEO_DATA_TILEMAP FieldSelectTilemap, vBGMap, $240
db $FF, $FF ; terminators
FieldSelectGfx_GameBoyColor: ; 0xd730
VIDEO_DATA_TILES FieldSelectScreenGfx, vTilesSH - $100, $d00
VIDEO_DATA_TILEMAP FieldSelectTilemap, vBGMap, $240
VIDEO_DATA_BGATTR FieldSelectBGAttributes, vBGMap, $240
VIDEO_DATA_PALETTES FieldSelectScreenPalettes, $48
db $FF, $FF ; terminators
ChooseFieldToPlay: ; 0xd74e
call MoveFieldSelectCursor
ld hl, FieldSelectBorderAnimationData
call AnimateBlinkingFieldSelectBorder
ld a, [hNewlyPressedButtons]
and (A_BUTTON | B_BUTTON)
ret z
ld [wFieldSelectPressedButton], a
ld a, $18 ; number of frames to blink the border after selecting the Field
ld [wFieldSelectBlinkingBorderTimer], a
ld a, $1
ld [wFieldSelectBlinkingBorderFrame], a
lb de, $00, $01
call PlaySoundEffect
ld hl, wScreenState
inc [hl]
ret
ExitFieldSelectScreen: ; 0xd774
ld a, [wFieldSelectPressedButton] ; this holds the button that was pressed (A or B)
bit BIT_A_BUTTON, a
jr z, .didntPressA
ld hl, FieldSelectConfirmationAnimationData
call AnimateBlinkingFieldSelectBorder
ld a, [wFieldSelectBlinkingBorderTimer]
dec a
ld [wFieldSelectBlinkingBorderTimer], a
ret nz
.didntPressA
ld a, [hJoypadState]
push af
call FadeOut
call DisableLCD
ld a, [wFieldSelectPressedButton]
bit BIT_A_BUTTON, a
jr z, .pressedB
ld a, [wSelectedFieldIndex]
ld c, a
ld b, $0
ld hl, StartingStages
add hl, bc
ld a, [hl]
ld [wCurrentStage], a
pop af
xor a
ld [wSavedGame], a
ld hl, wPartyMons
ld de, sSaveGame
ld bc, $04c3
call SaveData
xor a
ld [wLoadingSavedGame], a
; Start a game of Pinball
ld a, SCREEN_PINBALL_GAME
ld [wCurrentScreen], a
xor a
ld [wScreenState], a
ret
.pressedB
pop af
ld a, SCREEN_TITLESCREEN
ld [wCurrentScreen], a
xor a
ld [wScreenState], a
ret
StartingStages: ; 0xd7d1
; wSelectedFieldIndex is used to index this array
db STAGE_RED_FIELD_BOTTOM, STAGE_BLUE_FIELD_BOTTOM
MoveFieldSelectCursor: ; 0xd7d3
; When the player presses Right or Left, the stage is
; illuminated with a blinking border. This function keeps tracks
; of which field is currently selected.
ld a, [hPressedButtons]
ld b, a
ld a, [wSelectedFieldIndex]
bit BIT_D_LEFT, b
jr z, .didntPressLeft
and a
ret z ; if cursor is already hovering over Red stage, don't do anything
dec a ; move cursor over Red stage
ld [wSelectedFieldIndex], a
lb de, $00, $3c
call PlaySoundEffect
ret
.didntPressLeft
bit BIT_D_RIGHT, b
ret z
cp $1
ret z ; if cursor is already hovering over Blue stage, don't do anything
inc a ; move cursor over Red stage
ld [wSelectedFieldIndex], a
lb de, $00, $3d
call PlaySoundEffect
ret
AnimateBlinkingFieldSelectBorder: ; 0xd7fb
; This makes the border of the currently-selected Field blink in the Field Select screen.
push hl
ld a, [wSelectedFieldIndex]
sla a
ld c, a
ld b, $0
ld hl, FieldSelectBorderOAMPixelOffsetData
add hl, bc
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [wd915]
sla a
ld e, a
ld d, $0
pop hl
push hl
add hl, de
ld a, [hl]
call LoadOAMData
ld a, [wFieldSelectBlinkingBorderFrame]
dec a
jr nz, .asm_d838
inc hl
inc hl
ld a, [hl]
and a
jr z, .asm_d82b
ld a, [wd915]
inc a
.asm_d82b
ld [wd915], a
sla a
ld c, a
ld b, $0
pop hl
push hl
inc hl
add hl, bc
ld a, [hl]
.asm_d838
ld [wFieldSelectBlinkingBorderFrame], a
pop hl
ret
FieldSelectBorderAnimationData:
; [OAM id][duration]
db $9e, $08
db $9f, $08
db $9e, $08
db $a0, $08
db $00 ; terminator
FieldSelectConfirmationAnimationData:
; [OAM id][duration]
db $9F, $03
db $A0, $03
db $9F, $03
db $A0, $03
db $00 ; terminator
FieldSelectBorderOAMPixelOffsetData:
dw $2A42
dw $7242
|