players_pc.asm 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. PlayerPC:
  2. ld hl, wd730
  3. set 6, [hl]
  4. ld a, ITEM_NAME
  5. ld [wNameListType], a
  6. call SaveScreenTilesToBuffer1
  7. xor a
  8. ld [wBagSavedMenuItem], a
  9. ld [wParentMenuItem], a
  10. ld a, [wFlags_0xcd60]
  11. bit 3, a ; accessing player's PC through another PC?
  12. jr nz, PlayerPCMenu
  13. ; accessing it directly
  14. ld a, SFX_TURN_ON_PC
  15. call PlaySound
  16. ld hl, TurnedOnPC2Text
  17. call PrintText
  18. PlayerPCMenu:
  19. ld a, [wParentMenuItem]
  20. ld [wCurrentMenuItem], a
  21. ld hl, wFlags_0xcd60
  22. set 5, [hl]
  23. call LoadScreenTilesFromBuffer2
  24. coord hl, 0, 0
  25. ld b, $8
  26. ld c, $e
  27. call TextBoxBorder
  28. call UpdateSprites
  29. coord hl, 2, 2
  30. ld de, PlayersPCMenuEntries
  31. call PlaceString
  32. ld hl, wTopMenuItemY
  33. ld a, 2
  34. ld [hli], a ; wTopMenuItemY
  35. dec a
  36. ld [hli], a ; wTopMenuItemX
  37. inc hl
  38. inc hl
  39. ld a, 3
  40. ld [hli], a ; wMaxMenuItem
  41. ld a, A_BUTTON | B_BUTTON
  42. ld [hli], a ; wMenuWatchedKeys
  43. xor a
  44. ld [hl], a
  45. ld hl, wListScrollOffset
  46. ld [hli], a ; wListScrollOffset
  47. ld [hl], a ; wMenuWatchMovingOutOfBounds
  48. ld [wPlayerMonNumber], a
  49. ld hl, WhatDoYouWantText
  50. call PrintText
  51. call HandleMenuInput
  52. bit 1, a
  53. jp nz, ExitPlayerPC
  54. call PlaceUnfilledArrowMenuCursor
  55. ld a, [wCurrentMenuItem]
  56. ld [wParentMenuItem], a
  57. and a
  58. jp z, PlayerPCWithdraw
  59. dec a
  60. jp z, PlayerPCDeposit
  61. dec a
  62. jp z, PlayerPCToss
  63. ExitPlayerPC:
  64. ld a, [wFlags_0xcd60]
  65. bit 3, a ; accessing player's PC through another PC?
  66. jr nz, .next
  67. ; accessing it directly
  68. ld a, SFX_TURN_OFF_PC
  69. call PlaySound
  70. call WaitForSoundToFinish
  71. .next
  72. ld hl, wFlags_0xcd60
  73. res 5, [hl]
  74. call LoadScreenTilesFromBuffer2
  75. xor a
  76. ld [wListScrollOffset], a
  77. ld [wBagSavedMenuItem], a
  78. ld hl, wd730
  79. res 6, [hl]
  80. xor a
  81. ld [wDoNotWaitForButtonPressAfterDisplayingText], a
  82. ret
  83. PlayerPCDeposit:
  84. xor a
  85. ld [wCurrentMenuItem], a
  86. ld [wListScrollOffset], a
  87. ld a, [wNumBagItems]
  88. and a
  89. jr nz, .loop
  90. ld hl, NothingToDepositText
  91. call PrintText
  92. jp PlayerPCMenu
  93. .loop
  94. ld hl, WhatToDepositText
  95. call PrintText
  96. ld hl, wNumBagItems
  97. ld a, l
  98. ld [wListPointer], a
  99. ld a, h
  100. ld [wListPointer + 1], a
  101. xor a
  102. ld [wPrintItemPrices], a
  103. ld a, ITEMLISTMENU
  104. ld [wListMenuID], a
  105. call DisplayListMenuID
  106. jp c, PlayerPCMenu
  107. call IsKeyItem
  108. ld a, 1
  109. ld [wItemQuantity], a
  110. ld a, [wIsKeyItem]
  111. and a
  112. jr nz, .next
  113. ; if it's not a key item, there can be more than one of the item
  114. ld hl, DepositHowManyText
  115. call PrintText
  116. call DisplayChooseQuantityMenu
  117. cp $ff
  118. jp z, .loop
  119. .next
  120. ld hl, wNumBoxItems
  121. call AddItemToInventory
  122. jr c, .roomAvailable
  123. ld hl, NoRoomToStoreText
  124. call PrintText
  125. jp .loop
  126. .roomAvailable
  127. ld hl, wNumBagItems
  128. call RemoveItemFromInventory
  129. call WaitForSoundToFinish
  130. ld a, SFX_WITHDRAW_DEPOSIT
  131. call PlaySound
  132. call WaitForSoundToFinish
  133. ld hl, ItemWasStoredText
  134. call PrintText
  135. jp .loop
  136. PlayerPCWithdraw:
  137. xor a
  138. ld [wCurrentMenuItem], a
  139. ld [wListScrollOffset], a
  140. ld a, [wNumBoxItems]
  141. and a
  142. jr nz, .loop
  143. ld hl, NothingStoredText
  144. call PrintText
  145. jp PlayerPCMenu
  146. .loop
  147. ld hl, WhatToWithdrawText
  148. call PrintText
  149. ld hl, wNumBoxItems
  150. ld a, l
  151. ld [wListPointer], a
  152. ld a, h
  153. ld [wListPointer + 1], a
  154. xor a
  155. ld [wPrintItemPrices], a
  156. ld a, ITEMLISTMENU
  157. ld [wListMenuID], a
  158. call DisplayListMenuID
  159. jp c, PlayerPCMenu
  160. call IsKeyItem
  161. ld a, 1
  162. ld [wItemQuantity], a
  163. ld a, [wIsKeyItem]
  164. and a
  165. jr nz, .next
  166. ; if it's not a key item, there can be more than one of the item
  167. ld hl, WithdrawHowManyText
  168. call PrintText
  169. call DisplayChooseQuantityMenu
  170. cp $ff
  171. jp z, .loop
  172. .next
  173. ld hl, wNumBagItems
  174. call AddItemToInventory
  175. jr c, .roomAvailable
  176. ld hl, CantCarryMoreText
  177. call PrintText
  178. jp .loop
  179. .roomAvailable
  180. ld hl, wNumBoxItems
  181. call RemoveItemFromInventory
  182. call WaitForSoundToFinish
  183. ld a, SFX_WITHDRAW_DEPOSIT
  184. call PlaySound
  185. call WaitForSoundToFinish
  186. ld hl, WithdrewItemText
  187. call PrintText
  188. jp .loop
  189. PlayerPCToss:
  190. xor a
  191. ld [wCurrentMenuItem], a
  192. ld [wListScrollOffset], a
  193. ld a, [wNumBoxItems]
  194. and a
  195. jr nz, .loop
  196. ld hl, NothingStoredText
  197. call PrintText
  198. jp PlayerPCMenu
  199. .loop
  200. ld hl, WhatToTossText
  201. call PrintText
  202. ld hl, wNumBoxItems
  203. ld a, l
  204. ld [wListPointer], a
  205. ld a, h
  206. ld [wListPointer + 1], a
  207. xor a
  208. ld [wPrintItemPrices], a
  209. ld a, ITEMLISTMENU
  210. ld [wListMenuID], a
  211. push hl
  212. call DisplayListMenuID
  213. pop hl
  214. jp c, PlayerPCMenu
  215. push hl
  216. call IsKeyItem
  217. pop hl
  218. ld a, 1
  219. ld [wItemQuantity], a
  220. ld a, [wIsKeyItem]
  221. and a
  222. jr nz, .next
  223. ld a, [wcf91]
  224. call IsItemHM
  225. jr c, .next
  226. ; if it's not a key item, there can be more than one of the item
  227. push hl
  228. ld hl, TossHowManyText
  229. call PrintText
  230. call DisplayChooseQuantityMenu
  231. pop hl
  232. cp $ff
  233. jp z, .loop
  234. .next
  235. call TossItem ; disallows tossing key items
  236. jp .loop
  237. PlayersPCMenuEntries:
  238. db "WITHDRAW ITEM"
  239. next "DEPOSIT ITEM"
  240. next "TOSS ITEM"
  241. next "LOG OFF@"
  242. TurnedOnPC2Text:
  243. TX_FAR _TurnedOnPC2Text
  244. db "@"
  245. WhatDoYouWantText:
  246. TX_FAR _WhatDoYouWantText
  247. db "@"
  248. WhatToDepositText:
  249. TX_FAR _WhatToDepositText
  250. db "@"
  251. DepositHowManyText:
  252. TX_FAR _DepositHowManyText
  253. db "@"
  254. ItemWasStoredText:
  255. TX_FAR _ItemWasStoredText
  256. db "@"
  257. NothingToDepositText:
  258. TX_FAR _NothingToDepositText
  259. db "@"
  260. NoRoomToStoreText:
  261. TX_FAR _NoRoomToStoreText
  262. db "@"
  263. WhatToWithdrawText:
  264. TX_FAR _WhatToWithdrawText
  265. db "@"
  266. WithdrawHowManyText:
  267. TX_FAR _WithdrawHowManyText
  268. db "@"
  269. WithdrewItemText:
  270. TX_FAR _WithdrewItemText
  271. db "@"
  272. NothingStoredText:
  273. TX_FAR _NothingStoredText
  274. db "@"
  275. CantCarryMoreText:
  276. TX_FAR _CantCarryMoreText
  277. db "@"
  278. WhatToTossText:
  279. TX_FAR _WhatToTossText
  280. db "@"
  281. TossHowManyText:
  282. TX_FAR _TossHowManyText
  283. db "@"