celadonmartroof.asm 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. CeladonMartRoofScript:
  2. jp EnableAutoTextBoxDrawing
  3. CeladonMartRoofScript_GetDrinksInBag:
  4. ; construct a list of all drinks in the player's bag
  5. xor a
  6. ld [wFilteredBagItemsCount], a
  7. ld de, wFilteredBagItems
  8. ld hl, CeladonMartRoofDrinkList
  9. .loop
  10. ld a, [hli]
  11. and a
  12. jr z, .done
  13. push hl
  14. push de
  15. ld [wd11e], a
  16. ld b, a
  17. predef GetQuantityOfItemInBag
  18. pop de
  19. pop hl
  20. ld a, b
  21. and a
  22. jr z, .loop ; if the item isn't in the bag
  23. ld a, [wd11e]
  24. ld [de], a
  25. inc de
  26. push hl
  27. ld hl, wFilteredBagItemsCount
  28. inc [hl]
  29. pop hl
  30. jr .loop
  31. .done
  32. ld a, $ff
  33. ld [de], a
  34. ret
  35. CeladonMartRoofDrinkList:
  36. db FRESH_WATER
  37. db SODA_POP
  38. db LEMONADE
  39. db $00
  40. CeladonMartRoofScript_GiveDrinkToGirl:
  41. ld hl, wd730
  42. set 6, [hl]
  43. ld hl, CeladonMartRoofText_484ee
  44. call PrintText
  45. xor a
  46. ld [wCurrentMenuItem], a
  47. ld a, A_BUTTON | B_BUTTON
  48. ld [wMenuWatchedKeys], a
  49. ld a, [wFilteredBagItemsCount]
  50. dec a
  51. ld [wMaxMenuItem], a
  52. ld a, 2
  53. ld [wTopMenuItemY], a
  54. ld a, 1
  55. ld [wTopMenuItemX], a
  56. ld a, [wFilteredBagItemsCount]
  57. dec a
  58. ld bc, 2
  59. ld hl, 3
  60. call AddNTimes
  61. dec l
  62. ld b, l
  63. ld c, 12
  64. coord hl, 0, 0
  65. call TextBoxBorder
  66. call UpdateSprites
  67. call CeladonMartRoofScript_PrintDrinksInBag
  68. ld hl, wd730
  69. res 6, [hl]
  70. call HandleMenuInput
  71. bit 1, a ; pressed b
  72. ret nz
  73. ld hl, wFilteredBagItems
  74. ld a, [wCurrentMenuItem]
  75. ld d, 0
  76. ld e, a
  77. add hl, de
  78. ld a, [hl]
  79. ld [hItemToRemoveID], a
  80. cp FRESH_WATER
  81. jr z, .gaveFreshWater
  82. cp SODA_POP
  83. jr z, .gaveSodaPop
  84. ; gave Lemonade
  85. CheckEvent EVENT_GOT_TM49
  86. jr nz, .alreadyGaveDrink
  87. ld hl, CeladonMartRoofText_48515
  88. call PrintText
  89. call RemoveItemByIDBank12
  90. lb bc, TM_49, 1
  91. call GiveItem
  92. jr nc, .bagFull
  93. ld hl, ReceivedTM49Text
  94. call PrintText
  95. SetEvent EVENT_GOT_TM49
  96. ret
  97. .gaveSodaPop
  98. CheckEvent EVENT_GOT_TM48
  99. jr nz, .alreadyGaveDrink
  100. ld hl, CeladonMartRoofText_48504
  101. call PrintText
  102. call RemoveItemByIDBank12
  103. lb bc, TM_48, 1
  104. call GiveItem
  105. jr nc, .bagFull
  106. ld hl, CeladonMartRoofText_4850a
  107. call PrintText
  108. SetEvent EVENT_GOT_TM48
  109. ret
  110. .gaveFreshWater
  111. CheckEvent EVENT_GOT_TM13
  112. jr nz, .alreadyGaveDrink
  113. ld hl, CeladonMartRoofText_484f3
  114. call PrintText
  115. call RemoveItemByIDBank12
  116. lb bc, TM_13, 1
  117. call GiveItem
  118. jr nc, .bagFull
  119. ld hl, CeladonMartRoofText_484f9
  120. call PrintText
  121. SetEvent EVENT_GOT_TM13
  122. ret
  123. .bagFull
  124. ld hl, CeladonMartRoofText_48526
  125. jp PrintText
  126. .alreadyGaveDrink
  127. ld hl, CeladonMartRoofText_4852c
  128. jp PrintText
  129. RemoveItemByIDBank12:
  130. jpba RemoveItemByID
  131. CeladonMartRoofText_484ee:
  132. TX_FAR _CeladonMartRoofText_484ee
  133. db "@"
  134. CeladonMartRoofText_484f3:
  135. TX_FAR _CeladonMartRoofText_484f3
  136. TX_WAIT
  137. db "@"
  138. CeladonMartRoofText_484f9:
  139. TX_FAR _CeladonMartRoofText_484f9
  140. TX_SFX_ITEM_1
  141. TX_FAR _CeladonMartRoofText_484fe
  142. TX_WAIT
  143. db "@"
  144. CeladonMartRoofText_48504:
  145. TX_FAR _CeladonMartRoofText_48504
  146. TX_WAIT
  147. db "@"
  148. CeladonMartRoofText_4850a:
  149. TX_FAR _CeladonMartRoofText_4850a
  150. TX_SFX_ITEM_1
  151. TX_FAR _CeladonMartRoofText_4850f
  152. TX_WAIT
  153. db "@"
  154. CeladonMartRoofText_48515:
  155. TX_FAR _CeladonMartRoofText_48515
  156. TX_WAIT
  157. db "@"
  158. ReceivedTM49Text:
  159. TX_FAR _ReceivedTM49Text
  160. TX_SFX_ITEM_1
  161. TX_FAR _CeladonMartRoofText_48520
  162. TX_WAIT
  163. db "@"
  164. CeladonMartRoofText_48526:
  165. TX_FAR _CeladonMartRoofText_48526
  166. TX_WAIT
  167. db "@"
  168. CeladonMartRoofText_4852c:
  169. TX_FAR _CeladonMartRoofText_4852c
  170. TX_WAIT
  171. db "@"
  172. CeladonMartRoofScript_PrintDrinksInBag:
  173. ld hl, wFilteredBagItems
  174. xor a
  175. ld [hItemCounter], a
  176. .loop
  177. ld a, [hli]
  178. cp $ff
  179. ret z
  180. push hl
  181. ld [wd11e], a
  182. call GetItemName
  183. coord hl, 2, 2
  184. ld a, [hItemCounter]
  185. ld bc, SCREEN_WIDTH * 2
  186. call AddNTimes
  187. ld de, wcd6d
  188. call PlaceString
  189. ld hl, hItemCounter
  190. inc [hl]
  191. pop hl
  192. jr .loop
  193. CeladonMartRoofTextPointers:
  194. dw CeladonMartRoofText1
  195. dw CeladonMartRoofText2
  196. dw CeladonMartRoofText5
  197. dw CeladonMartRoofText5
  198. dw CeladonMartRoofText5
  199. dw CeladonMartRoofText6
  200. CeladonMartRoofText1:
  201. TX_FAR _CeladonMartRoofText1
  202. db "@"
  203. CeladonMartRoofText2:
  204. TX_ASM
  205. call CeladonMartRoofScript_GetDrinksInBag
  206. ld a, [wFilteredBagItemsCount]
  207. and a
  208. jr z, .noDrinksInBag
  209. ld a, 1
  210. ld [wDoNotWaitForButtonPressAfterDisplayingText], a
  211. ld hl, CeladonMartRoofText4
  212. call PrintText
  213. call YesNoChoice
  214. ld a, [wCurrentMenuItem]
  215. and a
  216. jr nz, .done
  217. call CeladonMartRoofScript_GiveDrinkToGirl
  218. jr .done
  219. .noDrinksInBag
  220. ld hl, CeladonMartRoofText3
  221. call PrintText
  222. .done
  223. jp TextScriptEnd
  224. CeladonMartRoofText3:
  225. TX_FAR _CeladonMartRoofText_48598
  226. db "@"
  227. CeladonMartRoofText4:
  228. TX_FAR _CeladonMartRoofText4
  229. db "@"
  230. CeladonMartRoofText5:
  231. TX_VENDING_MACHINE
  232. CeladonMartRoofText6:
  233. TX_FAR _CeladonMartRoofText6
  234. db "@"