celadongamecorner.asm 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. CeladonGameCornerScript:
  2. call CeladonGameCornerScript_48bcf
  3. call CeladonGameCornerScript_48bec
  4. call EnableAutoTextBoxDrawing
  5. ld hl, CeladonGameCornerScriptPointers
  6. ld a, [wCeladonGameCornerCurScript]
  7. jp CallFunctionInTable
  8. CeladonGameCornerScript_48bcf:
  9. ld hl, wCurrentMapScriptFlags
  10. bit 6, [hl]
  11. res 6, [hl]
  12. ret z
  13. call Random
  14. ld a, [hRandomAdd]
  15. cp $7
  16. jr nc, .asm_48be2
  17. ld a, $8
  18. .asm_48be2
  19. srl a
  20. srl a
  21. srl a
  22. ld [wLuckySlotHiddenObjectIndex], a
  23. ret
  24. CeladonGameCornerScript_48bec:
  25. ld hl, wCurrentMapScriptFlags
  26. bit 5, [hl]
  27. res 5, [hl]
  28. ret z
  29. CheckEvent EVENT_FOUND_ROCKET_HIDEOUT
  30. ret nz
  31. ld a, $2a
  32. ld [wNewTileBlockID], a
  33. lb bc, 2, 8
  34. predef_jump ReplaceTileBlock
  35. CeladonGameCornerScript_48c07:
  36. xor a
  37. ld [wJoyIgnore], a
  38. ld [wCeladonGameCornerCurScript], a
  39. ld [wCurMapScript], a
  40. ret
  41. CeladonGameCornerScriptPointers:
  42. dw CeladonGameCornerScript0
  43. dw CeladonGameCornerScript1
  44. dw CeladonGameCornerScript2
  45. CeladonGameCornerScript0:
  46. ret
  47. CeladonGameCornerScript1:
  48. ld a, [wIsInBattle]
  49. cp $ff
  50. jp z, CeladonGameCornerScript_48c07
  51. ld a, $f0
  52. ld [wJoyIgnore], a
  53. ld a, $d
  54. ld [hSpriteIndexOrTextID], a
  55. call DisplayTextID
  56. ld a, $b
  57. ld [H_SPRITEINDEX], a
  58. call SetSpriteMovementBytesToFF
  59. ld de, MovementData_48c5a
  60. ld a, [wYCoord]
  61. cp $6
  62. jr nz, .asm_48c43
  63. ld de, MovementData_48c63
  64. jr .asm_48c4d
  65. .asm_48c43
  66. ld a, [wXCoord]
  67. cp $8
  68. jr nz, .asm_48c4d
  69. ld de, MovementData_48c63
  70. .asm_48c4d
  71. ld a, $b
  72. ld [H_SPRITEINDEX], a
  73. call MoveSprite
  74. ld a, $2
  75. ld [wCeladonGameCornerCurScript], a
  76. ret
  77. MovementData_48c5a:
  78. db NPC_MOVEMENT_DOWN
  79. db NPC_MOVEMENT_RIGHT
  80. db NPC_MOVEMENT_RIGHT
  81. db NPC_MOVEMENT_UP
  82. db NPC_MOVEMENT_RIGHT
  83. db NPC_MOVEMENT_RIGHT
  84. db NPC_MOVEMENT_RIGHT
  85. db NPC_MOVEMENT_RIGHT
  86. db $FF
  87. MovementData_48c63:
  88. db NPC_MOVEMENT_RIGHT
  89. db NPC_MOVEMENT_RIGHT
  90. db NPC_MOVEMENT_RIGHT
  91. db NPC_MOVEMENT_RIGHT
  92. db NPC_MOVEMENT_RIGHT
  93. db $FF
  94. CeladonGameCornerScript2:
  95. ld a, [wd730]
  96. bit 0, a
  97. ret nz
  98. xor a
  99. ld [wJoyIgnore], a
  100. ld a, HS_GAME_CORNER_ROCKET
  101. ld [wMissableObjectIndex], a
  102. predef HideObject
  103. ld hl, wCurrentMapScriptFlags
  104. set 5, [hl]
  105. set 6, [hl]
  106. ld a, $0
  107. ld [wCeladonGameCornerCurScript], a
  108. ret
  109. CeladonGameCornerTextPointers:
  110. dw CeladonGameCornerText1
  111. dw CeladonGameCornerText2
  112. dw CeladonGameCornerText3
  113. dw CeladonGameCornerText4
  114. dw CeladonGameCornerText5
  115. dw CeladonGameCornerText6
  116. dw CeladonGameCornerText7
  117. dw CeladonGameCornerText8
  118. dw CeladonGameCornerText9
  119. dw CeladonGameCornerText10
  120. dw CeladonGameCornerText11
  121. dw CeladonGameCornerText12
  122. dw CeladonGameCornerText13
  123. CeladonGameCornerText1:
  124. TX_FAR _CeladonGameCornerText1
  125. db "@"
  126. CeladonGameCornerText2:
  127. TX_ASM
  128. call CeladonGameCornerScript_48f1e
  129. ld hl, CeladonGameCornerText_48d22
  130. call PrintText
  131. call YesNoChoice
  132. ld a, [wCurrentMenuItem]
  133. and a
  134. jr nz, .asm_48d0f
  135. ld b, COIN_CASE
  136. call IsItemInBag
  137. jr z, .asm_48d19
  138. call Has9990Coins
  139. jr nc, .asm_48d14
  140. xor a
  141. ld [hMoney], a
  142. ld [hMoney + 2], a
  143. ld a, $10
  144. ld [hMoney + 1], a
  145. call HasEnoughMoney
  146. jr nc, .asm_48cdb
  147. ld hl, CeladonGameCornerText_48d31
  148. jr .asm_48d1c
  149. .asm_48cdb
  150. xor a
  151. ld [hMoney], a
  152. ld [hMoney + 2], a
  153. ld a, $10
  154. ld [hMoney + 1], a
  155. ld hl, hMoney + 2
  156. ld de, wPlayerMoney + 2
  157. ld c, $3
  158. predef SubBCDPredef
  159. xor a
  160. ld [hUnusedCoinsByte], a
  161. ld [hCoins], a
  162. ld a, $50
  163. ld [hCoins + 1], a
  164. ld de, wPlayerCoins + 1
  165. ld hl, hCoins + 1
  166. ld c, $2
  167. predef AddBCDPredef
  168. call CeladonGameCornerScript_48f1e
  169. ld hl, CeladonGameCornerText_48d27
  170. jr .asm_48d1c
  171. .asm_48d0f
  172. ld hl, CeladonGameCornerText_48d2c
  173. jr .asm_48d1c
  174. .asm_48d14
  175. ld hl, CeladonGameCornerText_48d36
  176. jr .asm_48d1c
  177. .asm_48d19
  178. ld hl, CeladonGameCornerText_48d3b
  179. .asm_48d1c
  180. call PrintText
  181. jp TextScriptEnd
  182. CeladonGameCornerText_48d22:
  183. TX_FAR _CeladonGameCornerText_48d22
  184. db "@"
  185. CeladonGameCornerText_48d27:
  186. TX_FAR _CeladonGameCornerText_48d27
  187. db "@"
  188. CeladonGameCornerText_48d2c:
  189. TX_FAR _CeladonGameCornerText_48d2c
  190. db "@"
  191. CeladonGameCornerText_48d31:
  192. TX_FAR _CeladonGameCornerText_48d31
  193. db "@"
  194. CeladonGameCornerText_48d36:
  195. TX_FAR _CeladonGameCornerText_48d36
  196. db "@"
  197. CeladonGameCornerText_48d3b:
  198. TX_FAR _CeladonGameCornerText_48d3b
  199. db "@"
  200. CeladonGameCornerText3:
  201. TX_FAR _CeladonGameCornerText3
  202. db "@"
  203. CeladonGameCornerText4:
  204. TX_FAR _CeladonGameCornerText4
  205. db "@"
  206. CeladonGameCornerText5:
  207. TX_ASM
  208. CheckEvent EVENT_GOT_10_COINS
  209. jr nz, .asm_48d89
  210. ld hl, CeladonGameCornerText_48d9c
  211. call PrintText
  212. ld b, COIN_CASE
  213. call IsItemInBag
  214. jr z, .asm_48d93
  215. call Has9990Coins
  216. jr nc, .asm_48d8e
  217. xor a
  218. ld [hUnusedCoinsByte], a
  219. ld [hCoins], a
  220. ld a, $10
  221. ld [hCoins + 1], a
  222. ld de, wPlayerCoins + 1
  223. ld hl, hCoins + 1
  224. ld c, $2
  225. predef AddBCDPredef
  226. SetEvent EVENT_GOT_10_COINS
  227. ld a, $1
  228. ld [wDoNotWaitForButtonPressAfterDisplayingText], a
  229. ld hl, Received10CoinsText
  230. jr .asm_48d96
  231. .asm_48d89
  232. ld hl, CeladonGameCornerText_48dac
  233. jr .asm_48d96
  234. .asm_48d8e
  235. ld hl, CeladonGameCornerText_48da7
  236. jr .asm_48d96
  237. .asm_48d93
  238. ld hl, CeladonGameCornerText_48f19
  239. .asm_48d96
  240. call PrintText
  241. jp TextScriptEnd
  242. CeladonGameCornerText_48d9c:
  243. TX_FAR _CeladonGameCornerText_48d9c
  244. db "@"
  245. Received10CoinsText:
  246. TX_FAR _Received10CoinsText
  247. TX_SFX_ITEM_1
  248. db "@"
  249. CeladonGameCornerText_48da7:
  250. TX_FAR _CeladonGameCornerText_48da7
  251. db "@"
  252. CeladonGameCornerText_48dac:
  253. TX_FAR _CeladonGameCornerText_48dac
  254. db "@"
  255. CeladonGameCornerText6:
  256. TX_FAR _CeladonGameCornerText6
  257. db "@"
  258. CeladonGameCornerText7:
  259. TX_ASM
  260. CheckEvent EVENT_BEAT_ERIKA
  261. ld hl, CeladonGameCornerText_48dca
  262. jr z, .asm_48dc4
  263. ld hl, CeladonGameCornerText_48dcf
  264. .asm_48dc4
  265. call PrintText
  266. jp TextScriptEnd
  267. CeladonGameCornerText_48dca:
  268. TX_FAR _CeladonGameCornerText_48dca
  269. db "@"
  270. CeladonGameCornerText_48dcf:
  271. TX_FAR _CeladonGameCornerText_48dcf
  272. db "@"
  273. CeladonGameCornerText8:
  274. TX_FAR _CeladonGameCornerText8
  275. db "@"
  276. CeladonGameCornerText9:
  277. TX_ASM
  278. CheckEvent EVENT_GOT_20_COINS_2
  279. jr nz, .asm_48e13
  280. ld hl, CeladonGameCornerText_48e26
  281. call PrintText
  282. ld b, COIN_CASE
  283. call IsItemInBag
  284. jr z, .asm_48e1d
  285. call Has9990Coins
  286. jr nc, .asm_48e18
  287. xor a
  288. ld [hUnusedCoinsByte], a
  289. ld [hCoins], a
  290. ld a, $20
  291. ld [hCoins + 1], a
  292. ld de, wPlayerCoins + 1
  293. ld hl, hCoins + 1
  294. ld c, $2
  295. predef AddBCDPredef
  296. SetEvent EVENT_GOT_20_COINS_2
  297. ld hl, Received20CoinsText
  298. jr .asm_48e20
  299. .asm_48e13
  300. ld hl, CeladonGameCornerText_48e36
  301. jr .asm_48e20
  302. .asm_48e18
  303. ld hl, CeladonGameCornerText_48e31
  304. jr .asm_48e20
  305. .asm_48e1d
  306. ld hl, CeladonGameCornerText_48f19
  307. .asm_48e20
  308. call PrintText
  309. jp TextScriptEnd
  310. CeladonGameCornerText_48e26:
  311. TX_FAR _CeladonGameCornerText_48e26
  312. db "@"
  313. Received20CoinsText:
  314. TX_FAR _Received20CoinsText
  315. TX_SFX_ITEM_1
  316. db "@"
  317. CeladonGameCornerText_48e31:
  318. TX_FAR _CeladonGameCornerText_48e31
  319. db "@"
  320. CeladonGameCornerText_48e36:
  321. TX_FAR _CeladonGameCornerText_48e36
  322. db "@"
  323. CeladonGameCornerText10:
  324. TX_ASM
  325. CheckEvent EVENT_GOT_20_COINS
  326. jr nz, .asm_48e75
  327. ld hl, CeladonGameCornerText_48e88
  328. call PrintText
  329. ld b, COIN_CASE
  330. call IsItemInBag
  331. jr z, .asm_48e7f
  332. call Has9990Coins
  333. jr z, .asm_48e7a
  334. xor a
  335. ld [hUnusedCoinsByte], a
  336. ld [hCoins], a
  337. ld a, $20
  338. ld [hCoins + 1], a
  339. ld de, wPlayerCoins + 1
  340. ld hl, hCoins + 1
  341. ld c, $2
  342. predef AddBCDPredef
  343. SetEvent EVENT_GOT_20_COINS
  344. ld hl, CeladonGameCornerText_48e8d
  345. jr .asm_48e82
  346. .asm_48e75
  347. ld hl, CeladonGameCornerText_48e98
  348. jr .asm_48e82
  349. .asm_48e7a
  350. ld hl, CeladonGameCornerText_48e93
  351. jr .asm_48e82
  352. .asm_48e7f
  353. ld hl, CeladonGameCornerText_48f19
  354. .asm_48e82
  355. call PrintText
  356. jp TextScriptEnd
  357. CeladonGameCornerText_48e88:
  358. TX_FAR _CeladonGameCornerText_48e88
  359. db "@"
  360. CeladonGameCornerText_48e8d:
  361. TX_FAR _CeladonGameCornerText_48e8d
  362. TX_SFX_ITEM_1
  363. db "@"
  364. CeladonGameCornerText_48e93:
  365. TX_FAR _CeladonGameCornerText_48e93
  366. db "@"
  367. CeladonGameCornerText_48e98:
  368. TX_FAR _CeladonGameCornerText_48e98
  369. db "@"
  370. CeladonGameCornerText11:
  371. TX_ASM
  372. ld hl, CeladonGameCornerText_48ece
  373. call PrintText
  374. ld hl, wd72d
  375. set 6, [hl]
  376. set 7, [hl]
  377. ld hl, CeladonGameCornerText_48ed3
  378. ld de, CeladonGameCornerText_48ed3
  379. call SaveEndBattleTextPointers
  380. ld a, [H_SPRITEINDEX]
  381. ld [wSpriteIndex], a
  382. call EngageMapTrainer
  383. call InitBattleEnemyParameters
  384. xor a
  385. ld [hJoyHeld], a
  386. ld [hJoyPressed], a
  387. ld [hJoyReleased], a
  388. ld a, $1
  389. ld [wCeladonGameCornerCurScript], a
  390. jp TextScriptEnd
  391. CeladonGameCornerText_48ece:
  392. TX_FAR _CeladonGameCornerText_48ece
  393. db "@"
  394. CeladonGameCornerText_48ed3:
  395. TX_FAR _CeladonGameCornerText_48ed3
  396. db "@"
  397. CeladonGameCornerText13:
  398. TX_FAR _CeladonGameCornerText_48ed8
  399. db "@"
  400. CeladonGameCornerText12:
  401. TX_ASM
  402. ld a, $1
  403. ld [wDoNotWaitForButtonPressAfterDisplayingText], a
  404. ld hl, CeladonGameCornerText_48f09
  405. call PrintText
  406. call WaitForSoundToFinish
  407. ld a, SFX_GO_INSIDE
  408. call PlaySound
  409. call WaitForSoundToFinish
  410. SetEvent EVENT_FOUND_ROCKET_HIDEOUT
  411. ld a, $43
  412. ld [wNewTileBlockID], a
  413. lb bc, 2, 8
  414. predef ReplaceTileBlock
  415. jp TextScriptEnd
  416. CeladonGameCornerText_48f09:
  417. TX_FAR _CeladonGameCornerText_48f09
  418. TX_ASM
  419. ld a, SFX_SWITCH
  420. call PlaySound
  421. call WaitForSoundToFinish
  422. jp TextScriptEnd
  423. CeladonGameCornerText_48f19:
  424. TX_FAR _CeladonGameCornerText_48f19
  425. db "@"
  426. CeladonGameCornerScript_48f1e:
  427. ld hl, wd730
  428. set 6, [hl]
  429. coord hl, 11, 0
  430. ld b, $5
  431. ld c, $7
  432. call TextBoxBorder
  433. call UpdateSprites
  434. coord hl, 12, 1
  435. ld b, 4
  436. ld c, 7
  437. call ClearScreenArea
  438. coord hl, 12, 2
  439. ld de, GameCornerMoneyText
  440. call PlaceString
  441. coord hl, 12, 3
  442. ld de, GameCornerBlankText1
  443. call PlaceString
  444. coord hl, 12, 3
  445. ld de, wPlayerMoney
  446. ld c, $a3
  447. call PrintBCDNumber
  448. coord hl, 12, 4
  449. ld de, GameCornerCoinText
  450. call PlaceString
  451. coord hl, 12, 5
  452. ld de, GameCornerBlankText2
  453. call PlaceString
  454. coord hl, 15, 5
  455. ld de, wPlayerCoins
  456. ld c, $82
  457. call PrintBCDNumber
  458. ld hl, wd730
  459. res 6, [hl]
  460. ret
  461. GameCornerMoneyText:
  462. db "MONEY@"
  463. GameCornerCoinText:
  464. db "COIN@"
  465. GameCornerBlankText1:
  466. db " @"
  467. GameCornerBlankText2:
  468. db " @"
  469. Has9990Coins:
  470. ld a, $99
  471. ld [hCoins], a
  472. ld a, $90
  473. ld [hCoins + 1], a
  474. jp HasEnoughCoins