summaryrefslogtreecommitdiff
path: root/scripts/BikeShop.asm
blob: 0c5357d274b9771024f9d85ce85c41c680ee03dc (plain)
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
BikeShop_Script:
	call EnableAutoTextBoxDrawing
	ret

BikeShop_TextPointers:
	dw BikeShopText1
	dw BikeShopText2
	dw BikeShopText3

BikeShopText1:
	text_asm
	CheckEvent EVENT_GOT_BICYCLE
	jr z, .asm_260d4
	ld hl, BikeShopText_1d82f
	call PrintText
	jp .Done
.asm_260d4
	ld b, BIKE_VOUCHER
	call IsItemInBag
	jr z, .asm_41190
	ld hl, BikeShopText_1d81f
	call PrintText
	lb bc, BICYCLE, 1
	call GiveItem
	jr nc, .BagFull
	ld a, BIKE_VOUCHER
	ldh [hItemToRemoveID], a
	farcall RemoveItemByID
	SetEvent EVENT_GOT_BICYCLE
	ld hl, BikeShopText_1d824
	call PrintText
	jr .Done
.BagFull
	ld hl, BikeShopText_1d834
	call PrintText
	jr .Done
.asm_41190
	ld hl, BikeShopText_1d810
	call PrintText
	xor a
	ld [wCurrentMenuItem], a
	ld [wLastMenuItem], a
	ld a, A_BUTTON | B_BUTTON
	ld [wMenuWatchedKeys], a
	ld a, $1
	ld [wMaxMenuItem], a
	ld a, $2
	ld [wTopMenuItemY], a
	ld a, $1
	ld [wTopMenuItemX], a
	ld hl, wd730
	set 6, [hl]
	hlcoord 0, 0
	lb bc, 4, 15
	call TextBoxBorder
	call UpdateSprites
	hlcoord 2, 2
	ld de, BikeShopMenuText
	call PlaceString
	hlcoord 8, 3
	ld de, BikeShopMenuPrice
	call PlaceString
	ld hl, BikeShopText_1d815
	call PrintText
	; This fixes the bike shop instatext glitch
	ld hl, wd730
	res 6, [hl]
	call HandleMenuInput
	bit BIT_B_BUTTON, a
	jr nz, .cancel
	ld a, [wCurrentMenuItem]
	and a
	jr nz, .cancel
	ld hl, BikeShopCantAffordText
	call PrintText
.cancel
	ld hl, BikeShopComeAgainText
	call PrintText
.Done
	jp TextScriptEnd

BikeShopMenuText:
	db   "BICYCLE"
	next "CANCEL@"

BikeShopMenuPrice:
	db "¥1000000@"

BikeShopText_1d810:
	text_far _BikeShopText_1d810
	text_end

BikeShopText_1d815:
	text_far _BikeShopText_1d815
	text_end

BikeShopCantAffordText:
	text_far _BikeShopCantAffordText
	text_end

BikeShopText_1d81f:
	text_far _BikeShopText_1d81f
	text_end

BikeShopText_1d824:
	text_far _BikeShopText_1d824
	sound_get_key_item
	text_end

BikeShopComeAgainText:
	text_far _BikeShopComeAgainText
	text_end

BikeShopText_1d82f:
	text_far _BikeShopText_1d82f
	text_end

BikeShopText_1d834:
	text_far _BikeShopText_1d834
	text_end

BikeShopText2:
	text_asm
	ld hl, BikeShopText_1d843
	call PrintText
	jp TextScriptEnd

BikeShopText_1d843:
	text_far _BikeShopText_1d843
	text_end

BikeShopText3:
	text_asm
	CheckEvent EVENT_GOT_BICYCLE
	ld hl, BikeShopText_1d861
	jr nz, .asm_34d2d
	ld hl, BikeShopText_1d85c
.asm_34d2d
	call PrintText
	jp TextScriptEnd

BikeShopText_1d85c:
	text_far _BikeShopText_1d85c
	text_end

BikeShopText_1d861:
	text_far _BikeShopText_1d861
	text_end