text_box.asm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. ; function to draw various text boxes
  2. DisplayTextBoxID_:
  3. ld a, [wTextBoxID]
  4. cp TWO_OPTION_MENU
  5. jp z, DisplayTwoOptionMenu
  6. ld c, a
  7. ld hl, TextBoxFunctionTable
  8. ld de, 3
  9. call SearchTextBoxTable
  10. jr c, .functionTableMatch
  11. ld hl, TextBoxCoordTable
  12. ld de, 5
  13. call SearchTextBoxTable
  14. jr c, .coordTableMatch
  15. ld hl, TextBoxTextAndCoordTable
  16. ld de, 9
  17. call SearchTextBoxTable
  18. jr c, .textAndCoordTableMatch
  19. .done
  20. ret
  21. .functionTableMatch
  22. ld a, [hli]
  23. ld h, [hl]
  24. ld l, a ; hl = address of function
  25. ld de, .done
  26. push de
  27. jp hl ; jump to the function
  28. .coordTableMatch
  29. call GetTextBoxIDCoords
  30. call GetAddressOfScreenCoords
  31. call TextBoxBorder
  32. ret
  33. .textAndCoordTableMatch
  34. call GetTextBoxIDCoords
  35. push hl
  36. call GetAddressOfScreenCoords
  37. call TextBoxBorder
  38. pop hl
  39. call GetTextBoxIDText
  40. ld a, [wd730]
  41. push af
  42. ld a, [wd730]
  43. set 6, a ; no pauses between printing each letter
  44. ld [wd730], a
  45. call PlaceString
  46. pop af
  47. ld [wd730], a
  48. call UpdateSprites
  49. ret
  50. ; function to search a table terminated with $ff for a byte matching c in increments of de
  51. ; sets carry flag if a match is found and clears carry flag if not
  52. SearchTextBoxTable:
  53. dec de
  54. .loop
  55. ld a, [hli]
  56. cp $ff
  57. jr z, .notFound
  58. cp c
  59. jr z, .found
  60. add hl, de
  61. jr .loop
  62. .found
  63. scf
  64. .notFound
  65. ret
  66. ; function to load coordinates from the TextBoxCoordTable or the TextBoxTextAndCoordTable
  67. ; INPUT:
  68. ; hl = address of coordinates
  69. ; OUTPUT:
  70. ; b = height
  71. ; c = width
  72. ; d = row of upper left corner
  73. ; e = column of upper left corner
  74. GetTextBoxIDCoords:
  75. ld a, [hli] ; column of upper left corner
  76. ld e, a
  77. ld a, [hli] ; row of upper left corner
  78. ld d, a
  79. ld a, [hli] ; column of lower right corner
  80. sub e
  81. dec a
  82. ld c, a ; c = width
  83. ld a, [hli] ; row of lower right corner
  84. sub d
  85. dec a
  86. ld b, a ; b = height
  87. ret
  88. ; function to load a text address and text coordinates from the TextBoxTextAndCoordTable
  89. GetTextBoxIDText:
  90. ld a, [hli]
  91. ld e, a
  92. ld a, [hli]
  93. ld d, a ; de = address of text
  94. push de ; save text address
  95. ld a, [hli]
  96. ld e, a ; column of upper left corner of text
  97. ld a, [hl]
  98. ld d, a ; row of upper left corner of text
  99. call GetAddressOfScreenCoords
  100. pop de ; restore text address
  101. ret
  102. ; function to point hl to the screen coordinates
  103. ; INPUT:
  104. ; d = row
  105. ; e = column
  106. ; OUTPUT:
  107. ; hl = address of upper left corner of text box
  108. GetAddressOfScreenCoords:
  109. push bc
  110. coord hl, 0, 0
  111. ld bc, 20
  112. .loop ; loop to add d rows to the base address
  113. ld a, d
  114. and a
  115. jr z, .addedRows
  116. add hl, bc
  117. dec d
  118. jr .loop
  119. .addedRows
  120. pop bc
  121. add hl, de
  122. ret
  123. ; Format:
  124. ; 00: text box ID
  125. ; 01-02: function address
  126. TextBoxFunctionTable:
  127. dbw MONEY_BOX, DisplayMoneyBox
  128. dbw BUY_SELL_QUIT_MENU, DoBuySellQuitMenu
  129. dbw FIELD_MOVE_MON_MENU, DisplayFieldMoveMonMenu
  130. db $ff ; terminator
  131. ; Format:
  132. ; 00: text box ID
  133. ; 01: column of upper left corner
  134. ; 02: row of upper left corner
  135. ; 03: column of lower right corner
  136. ; 04: row of lower right corner
  137. TextBoxCoordTable:
  138. db MESSAGE_BOX, 0, 12, 19, 17
  139. db $03, 0, 0, 19, 14
  140. db $07, 0, 0, 11, 6
  141. db LIST_MENU_BOX, 4, 2, 19, 12
  142. db $10, 7, 0, 19, 17
  143. db MON_SPRITE_POPUP, 6, 4, 14, 13
  144. db $ff ; terminator
  145. ; Format:
  146. ; 00: text box ID
  147. ; 01: column of upper left corner
  148. ; 02: row of upper left corner
  149. ; 03: column of lower right corner
  150. ; 04: row of lower right corner
  151. ; 05-06: address of text
  152. ; 07: column of beginning of text
  153. ; 08: row of beginning of text
  154. ; table of window positions and corresponding text [key, start column, start row, end column, end row, text pointer [2 bytes], text column, text row]
  155. TextBoxTextAndCoordTable:
  156. db JP_MOCHIMONO_MENU_TEMPLATE
  157. db 0,0,14,17 ; text box coordinates
  158. dw JapaneseMochimonoText
  159. db 3,0 ; text coordinates
  160. db USE_TOSS_MENU_TEMPLATE
  161. db 13,10,19,14 ; text box coordinates
  162. dw UseTossText
  163. db 15,11 ; text coordinates
  164. db JP_SAVE_MESSAGE_MENU_TEMPLATE
  165. db 0,0,7,5 ; text box coordinates
  166. dw JapaneseSaveMessageText
  167. db 2,2 ; text coordinates
  168. db JP_SPEED_OPTIONS_MENU_TEMPLATE
  169. db 0,6,5,10 ; text box coordinates
  170. dw JapaneseSpeedOptionsText
  171. db 2,7 ; text coordinates
  172. db BATTLE_MENU_TEMPLATE
  173. db 8,12,19,17 ; text box coordinates
  174. dw BattleMenuText
  175. db 10,14 ; text coordinates
  176. db SAFARI_BATTLE_MENU_TEMPLATE
  177. db 0,12,19,17 ; text box coordinates
  178. dw SafariZoneBattleMenuText
  179. db 2,14 ; text coordinates
  180. db SWITCH_STATS_CANCEL_MENU_TEMPLATE
  181. db 11,11,19,17 ; text box coordinates
  182. dw SwitchStatsCancelText
  183. db 13,12 ; text coordinates
  184. db BUY_SELL_QUIT_MENU_TEMPLATE
  185. db 0,0,10,6 ; text box coordinates
  186. dw BuySellQuitText
  187. db 2,1 ; text coordinates
  188. db MONEY_BOX_TEMPLATE
  189. db 11,0,19,2 ; text box coordinates
  190. dw MoneyText
  191. db 13,0 ; text coordinates
  192. db JP_AH_MENU_TEMPLATE
  193. db 7,6,11,10 ; text box coordinates
  194. dw JapaneseAhText
  195. db 8,8 ; text coordinates
  196. db JP_POKEDEX_MENU_TEMPLATE
  197. db 11,8,19,17 ; text box coordinates
  198. dw JapanesePokedexMenu
  199. db 12,10 ; text coordinates
  200. ; note that there is no terminator
  201. BuySellQuitText:
  202. db "BUY"
  203. next "SELL"
  204. next "QUIT@@"
  205. UseTossText:
  206. db "USE"
  207. next "TOSS@"
  208. JapaneseSaveMessageText:
  209. db "きろく"
  210. next "メッセージ@"
  211. JapaneseSpeedOptionsText:
  212. db "はやい"
  213. next "おそい@"
  214. MoneyText:
  215. db "MONEY@"
  216. JapaneseMochimonoText:
  217. db "もちもの@"
  218. JapaneseMainMenuText:
  219. db "つづきから"
  220. next "さいしょから@"
  221. BattleMenuText:
  222. db "FIGHT ",$E1,$E2
  223. next "ITEM RUN@"
  224. SafariZoneBattleMenuText:
  225. db "BALL× BAIT"
  226. next "THROW ROCK RUN@"
  227. SwitchStatsCancelText:
  228. db "SWITCH"
  229. next "STATS"
  230. next "CANCEL@"
  231. JapaneseAhText:
  232. db "アッ!@"
  233. JapanesePokedexMenu:
  234. db "データをみる"
  235. next "なきごえ"
  236. next "ぶんぷをみる"
  237. next "キャンセル@"
  238. DisplayMoneyBox:
  239. ld hl, wd730
  240. set 6, [hl]
  241. ld a, MONEY_BOX_TEMPLATE
  242. ld [wTextBoxID], a
  243. call DisplayTextBoxID
  244. coord hl, 13, 1
  245. ld b, 1
  246. ld c, 6
  247. call ClearScreenArea
  248. coord hl, 12, 1
  249. ld de, wPlayerMoney
  250. ld c, $a3
  251. call PrintBCDNumber
  252. ld hl, wd730
  253. res 6, [hl]
  254. ret
  255. CurrencyString:
  256. db " ¥@"
  257. DoBuySellQuitMenu:
  258. ld a, [wd730]
  259. set 6, a ; no printing delay
  260. ld [wd730], a
  261. xor a
  262. ld [wChosenMenuItem], a
  263. ld a, BUY_SELL_QUIT_MENU_TEMPLATE
  264. ld [wTextBoxID], a
  265. call DisplayTextBoxID
  266. ld a, A_BUTTON | B_BUTTON
  267. ld [wMenuWatchedKeys], a
  268. ld a, $2
  269. ld [wMaxMenuItem], a
  270. ld a, $1
  271. ld [wTopMenuItemY], a
  272. ld a, $1
  273. ld [wTopMenuItemX], a
  274. xor a
  275. ld [wCurrentMenuItem], a
  276. ld [wLastMenuItem], a
  277. ld [wMenuWatchMovingOutOfBounds], a
  278. ld a, [wd730]
  279. res 6, a ; turn on the printing delay
  280. ld [wd730], a
  281. call HandleMenuInput
  282. call PlaceUnfilledArrowMenuCursor
  283. bit 0, a ; was A pressed?
  284. jr nz, .pressedA
  285. bit 1, a ; was B pressed? (always true since only A/B are watched)
  286. jr z, .pressedA
  287. ld a, CANCELLED_MENU
  288. ld [wMenuExitMethod], a
  289. jr .quit
  290. .pressedA
  291. ld a, CHOSE_MENU_ITEM
  292. ld [wMenuExitMethod], a
  293. ld a, [wCurrentMenuItem]
  294. ld [wChosenMenuItem], a
  295. ld b, a
  296. ld a, [wMaxMenuItem]
  297. cp b
  298. jr z, .quit
  299. ret
  300. .quit
  301. ld a, CANCELLED_MENU
  302. ld [wMenuExitMethod], a
  303. ld a, [wCurrentMenuItem]
  304. ld [wChosenMenuItem], a
  305. scf
  306. ret
  307. ; displays a menu with two options to choose from
  308. ; b = Y of upper left corner of text region
  309. ; c = X of upper left corner of text region
  310. ; hl = address where the text box border should be drawn
  311. DisplayTwoOptionMenu:
  312. push hl
  313. ld a, [wd730]
  314. set 6, a ; no printing delay
  315. ld [wd730], a
  316. ; pointless because both values are overwritten before they are read
  317. xor a
  318. ld [wChosenMenuItem], a
  319. ld [wMenuExitMethod], a
  320. ld a, A_BUTTON | B_BUTTON
  321. ld [wMenuWatchedKeys], a
  322. ld a, $1
  323. ld [wMaxMenuItem], a
  324. ld a, b
  325. ld [wTopMenuItemY], a
  326. ld a, c
  327. ld [wTopMenuItemX], a
  328. xor a
  329. ld [wLastMenuItem], a
  330. ld [wMenuWatchMovingOutOfBounds], a
  331. push hl
  332. ld hl, wTwoOptionMenuID
  333. bit 7, [hl] ; select second menu item by default?
  334. res 7, [hl]
  335. jr z, .storeCurrentMenuItem
  336. inc a
  337. .storeCurrentMenuItem
  338. ld [wCurrentMenuItem], a
  339. pop hl
  340. push hl
  341. push hl
  342. call TwoOptionMenu_SaveScreenTiles
  343. ld a, [wTwoOptionMenuID]
  344. ld hl, TwoOptionMenuStrings
  345. ld e, a
  346. ld d, $0
  347. ld a, $5
  348. .menuStringLoop
  349. add hl, de
  350. dec a
  351. jr nz, .menuStringLoop
  352. ld a, [hli]
  353. ld c, a
  354. ld a, [hli]
  355. ld b, a
  356. ld e, l
  357. ld d, h
  358. pop hl
  359. push de
  360. ld a, [wTwoOptionMenuID]
  361. cp TRADE_CANCEL_MENU
  362. jr nz, .notTradeCancelMenu
  363. call CableClub_TextBoxBorder
  364. jr .afterTextBoxBorder
  365. .notTradeCancelMenu
  366. call TextBoxBorder
  367. .afterTextBoxBorder
  368. call UpdateSprites
  369. pop hl
  370. ld a, [hli]
  371. and a ; put blank line before first menu item?
  372. ld bc, 20 + 2
  373. jr z, .noBlankLine
  374. ld bc, 2 * 20 + 2
  375. .noBlankLine
  376. ld a, [hli]
  377. ld e, a
  378. ld a, [hli]
  379. ld d, a
  380. pop hl
  381. add hl, bc
  382. call PlaceString
  383. ld hl, wd730
  384. res 6, [hl] ; turn on the printing delay
  385. ld a, [wTwoOptionMenuID]
  386. cp NO_YES_MENU
  387. jr nz, .notNoYesMenu
  388. ; No/Yes menu
  389. ; this menu type ignores the B button
  390. ; it only seems to be used when confirming the deletion of a save file
  391. xor a
  392. ld [wTwoOptionMenuID], a
  393. ld a, [wFlags_0xcd60]
  394. push af
  395. push hl
  396. ld hl, wFlags_0xcd60
  397. bit 5, [hl]
  398. set 5, [hl] ; don't play sound when A or B is pressed in menu
  399. pop hl
  400. .noYesMenuInputLoop
  401. call HandleMenuInput
  402. bit 1, a ; A button pressed?
  403. jr nz, .noYesMenuInputLoop ; try again if A was not pressed
  404. pop af
  405. pop hl
  406. ld [wFlags_0xcd60], a
  407. ld a, SFX_PRESS_AB
  408. call PlaySound
  409. jr .pressedAButton
  410. .notNoYesMenu
  411. xor a
  412. ld [wTwoOptionMenuID], a
  413. call HandleMenuInput
  414. pop hl
  415. bit 1, a ; A button pressed?
  416. jr nz, .choseSecondMenuItem ; automatically choose the second option if B is pressed
  417. .pressedAButton
  418. ld a, [wCurrentMenuItem]
  419. ld [wChosenMenuItem], a
  420. and a
  421. jr nz, .choseSecondMenuItem
  422. ; chose first menu item
  423. ld a, CHOSE_FIRST_ITEM
  424. ld [wMenuExitMethod], a
  425. ld c, 15
  426. call DelayFrames
  427. call TwoOptionMenu_RestoreScreenTiles
  428. and a
  429. ret
  430. .choseSecondMenuItem
  431. ld a, 1
  432. ld [wCurrentMenuItem], a
  433. ld [wChosenMenuItem], a
  434. ld a, CHOSE_SECOND_ITEM
  435. ld [wMenuExitMethod], a
  436. ld c, 15
  437. call DelayFrames
  438. call TwoOptionMenu_RestoreScreenTiles
  439. scf
  440. ret
  441. ; Some of the wider/taller two option menus will not have the screen areas
  442. ; they cover be fully saved/restored by the two functions below.
  443. ; The bottom and right edges of the menu may remain after the function returns.
  444. TwoOptionMenu_SaveScreenTiles:
  445. ld de, wBuffer
  446. lb bc, 5, 6
  447. .loop
  448. ld a, [hli]
  449. ld [de], a
  450. inc de
  451. dec c
  452. jr nz, .loop
  453. push bc
  454. ld bc, SCREEN_WIDTH - 6
  455. add hl, bc
  456. pop bc
  457. ld c, $6
  458. dec b
  459. jr nz, .loop
  460. ret
  461. TwoOptionMenu_RestoreScreenTiles:
  462. ld de, wBuffer
  463. lb bc, 5, 6
  464. .loop
  465. ld a, [de]
  466. inc de
  467. ld [hli], a
  468. dec c
  469. jr nz, .loop
  470. push bc
  471. ld bc, SCREEN_WIDTH - 6
  472. add hl, bc
  473. pop bc
  474. ld c, 6
  475. dec b
  476. jr nz, .loop
  477. call UpdateSprites
  478. ret
  479. ; Format:
  480. ; 00: byte width
  481. ; 01: byte height
  482. ; 02: byte put blank line before first menu item
  483. ; 03: word text pointer
  484. TwoOptionMenuStrings:
  485. db 4,3,0
  486. dw .YesNoMenu
  487. db 6,3,0
  488. dw .NorthWestMenu
  489. db 6,3,0
  490. dw .SouthEastMenu
  491. db 6,3,0
  492. dw .YesNoMenu
  493. db 6,3,0
  494. dw .NorthEastMenu
  495. db 7,3,0
  496. dw .TradeCancelMenu
  497. db 7,4,1
  498. dw .HealCancelMenu
  499. db 4,3,0
  500. dw .NoYesMenu
  501. .NoYesMenu
  502. db "NO"
  503. next "YES@"
  504. .YesNoMenu
  505. db "YES"
  506. next "NO@"
  507. .NorthWestMenu
  508. db "NORTH"
  509. next "WEST@"
  510. .SouthEastMenu
  511. db "SOUTH"
  512. next "EAST@"
  513. .NorthEastMenu
  514. db "NORTH"
  515. next "EAST@"
  516. .TradeCancelMenu
  517. db "TRADE"
  518. next "CANCEL@"
  519. .HealCancelMenu
  520. db "HEAL"
  521. next "CANCEL@"
  522. DisplayFieldMoveMonMenu:
  523. xor a
  524. ld hl, wFieldMoves
  525. ld [hli], a ; wFieldMoves
  526. ld [hli], a ; wFieldMoves + 1
  527. ld [hli], a ; wFieldMoves + 2
  528. ld [hli], a ; wFieldMoves + 3
  529. ld [hli], a ; wNumFieldMoves
  530. ld [hl], 12 ; wFieldMovesLeftmostXCoord
  531. call GetMonFieldMoves
  532. ld a, [wNumFieldMoves]
  533. and a
  534. jr nz, .fieldMovesExist
  535. ; no field moves
  536. coord hl, 11, 11
  537. ld b, 5
  538. ld c, 7
  539. call TextBoxBorder
  540. call UpdateSprites
  541. ld a, 12
  542. ld [hFieldMoveMonMenuTopMenuItemX], a
  543. coord hl, 13, 12
  544. ld de, PokemonMenuEntries
  545. jp PlaceString
  546. .fieldMovesExist
  547. push af
  548. ; Calculate the text box position and dimensions based on the leftmost X coord
  549. ; of the field move names before adjusting for the number of field moves.
  550. coord hl, 0, 11
  551. ld a, [wFieldMovesLeftmostXCoord]
  552. dec a
  553. ld e, a
  554. ld d, 0
  555. add hl, de
  556. ld b, 5
  557. ld a, 18
  558. sub e
  559. ld c, a
  560. pop af
  561. ; For each field move, move the top of the text box up 2 rows while the leaving
  562. ; the bottom of the text box at the bottom of the screen.
  563. ld de, -SCREEN_WIDTH * 2
  564. .textBoxHeightLoop
  565. add hl, de
  566. inc b
  567. inc b
  568. dec a
  569. jr nz, .textBoxHeightLoop
  570. ; Make space for an extra blank row above the top field move.
  571. ld de, -SCREEN_WIDTH
  572. add hl, de
  573. inc b
  574. call TextBoxBorder
  575. call UpdateSprites
  576. ; Calculate the position of the first field move name to print.
  577. coord hl, 0, 12
  578. ld a, [wFieldMovesLeftmostXCoord]
  579. inc a
  580. ld e, a
  581. ld d, 0
  582. add hl, de
  583. ld de, -SCREEN_WIDTH * 2
  584. ld a, [wNumFieldMoves]
  585. .calcFirstFieldMoveYLoop
  586. add hl, de
  587. dec a
  588. jr nz, .calcFirstFieldMoveYLoop
  589. xor a
  590. ld [wNumFieldMoves], a
  591. ld de, wFieldMoves
  592. .printNamesLoop
  593. push hl
  594. ld hl, FieldMoveNames
  595. ld a, [de]
  596. and a
  597. jr z, .donePrintingNames
  598. inc de
  599. ld b, a ; index of name
  600. .skipNamesLoop ; skip past names before the name we want
  601. dec b
  602. jr z, .reachedName
  603. .skipNameLoop ; skip past current name
  604. ld a, [hli]
  605. cp "@"
  606. jr nz, .skipNameLoop
  607. jr .skipNamesLoop
  608. .reachedName
  609. ld b, h
  610. ld c, l
  611. pop hl
  612. push de
  613. ld d, b
  614. ld e, c
  615. call PlaceString
  616. ld bc, SCREEN_WIDTH * 2
  617. add hl, bc
  618. pop de
  619. jr .printNamesLoop
  620. .donePrintingNames
  621. pop hl
  622. ld a, [wFieldMovesLeftmostXCoord]
  623. ld [hFieldMoveMonMenuTopMenuItemX], a
  624. coord hl, 0, 12
  625. ld a, [wFieldMovesLeftmostXCoord]
  626. inc a
  627. ld e, a
  628. ld d, 0
  629. add hl, de
  630. ld de, PokemonMenuEntries
  631. jp PlaceString
  632. FieldMoveNames:
  633. db "CUT@"
  634. db "FLY@"
  635. db "@"
  636. db "SURF@"
  637. db "STRENGTH@"
  638. db "FLASH@"
  639. db "DIG@"
  640. db "TELEPORT@"
  641. db "SOFTBOILED@"
  642. PokemonMenuEntries:
  643. db "STATS"
  644. next "SWITCH"
  645. next "CANCEL@"
  646. GetMonFieldMoves:
  647. ld a, [wWhichPokemon]
  648. ld hl, wPartyMon1Moves
  649. ld bc, wPartyMon2 - wPartyMon1
  650. call AddNTimes
  651. ld d, h
  652. ld e, l
  653. ld c, NUM_MOVES + 1
  654. ld hl, wFieldMoves
  655. .loop
  656. push hl
  657. .nextMove
  658. dec c
  659. jr z, .done
  660. ld a, [de] ; move ID
  661. and a
  662. jr z, .done
  663. ld b, a
  664. inc de
  665. ld hl, FieldMoveDisplayData
  666. .fieldMoveLoop
  667. ld a, [hli]
  668. cp $ff
  669. jr z, .nextMove ; if the move is not a field move
  670. cp b
  671. jr z, .foundFieldMove
  672. inc hl
  673. inc hl
  674. jr .fieldMoveLoop
  675. .foundFieldMove
  676. ld a, b
  677. ld [wLastFieldMoveID], a
  678. ld a, [hli] ; field move name index
  679. ld b, [hl] ; field move leftmost X coordinate
  680. pop hl
  681. ld [hli], a ; store name index in wFieldMoves
  682. ld a, [wNumFieldMoves]
  683. inc a
  684. ld [wNumFieldMoves], a
  685. ld a, [wFieldMovesLeftmostXCoord]
  686. cp b
  687. jr c, .skipUpdatingLeftmostXCoord
  688. ld a, b
  689. ld [wFieldMovesLeftmostXCoord], a
  690. .skipUpdatingLeftmostXCoord
  691. ld a, [wLastFieldMoveID]
  692. ld b, a
  693. jr .loop
  694. .done
  695. pop hl
  696. ret
  697. ; Format: [Move id], [name index], [leftmost tile]
  698. ; Move id = id of move
  699. ; Name index = index of name in FieldMoveNames
  700. ; Leftmost tile = -1 + tile column in which the first letter of the move's name should be displayed
  701. ; "SOFTBOILED" is $08 because it has 4 more letters than "SURF", for example, whose value is $0C
  702. FieldMoveDisplayData:
  703. db CUT, $01, $0C
  704. db FLY, $02, $0C
  705. db $B4, $03, $0C ; unused field move
  706. db SURF, $04, $0C
  707. db STRENGTH, $05, $0A
  708. db FLASH, $06, $0C
  709. db DIG, $07, $0C
  710. db TELEPORT, $08, $0A
  711. db SOFTBOILED, $09, $08
  712. db $ff ; list terminator