menusystem.asm 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. /*
  2. tiny menu system for snes by d4s in 2006
  3. depends on:
  4. printstring.asm, function: LoadTextString
  5. execute with:
  6. ldx.w #number_of_menu_file_to_load
  7. jsr LoadMenuFile
  8. features:
  9. -1 column, x rows
  10. -seperate bytes and bits manipulation
  11. -print text and menu options with palette highlighting
  12. -subroutine jump upon option change
  13. -load complete menu from table, no hardcoded stuff
  14. -menus tables should be compressable, relative pointers only!
  15. menu table format:
  16. byte function
  17. 2 starting position of first option text on bg3 tilemap
  18. 1 relative starting position of first option variable(*2+starting position of first option text on bg3 tilemap)
  19. 1 number of seperating rows between options
  20. 1 number of rows/options
  21. 2xrow quantity relative pointer to data for each row
  22. row table format:
  23. 1 option data type (maximum number:7)
  24. 0x0=no options, only exec subroutine
  25. 0x1=1 byte
  26. 0x2=8 bits
  27. 0x3=2 interchangeable options with description text (eg: "sound: mono/stereo)
  28. 1 bitmask for changeable bits if data type=0x2; bitmask(usually only one bit) to determine the string to choose if data type=0x3(if zero=string 1, if not zero=string 2)
  29. 1 minimum value for option, wrap to maximum value if changed value equals this
  30. 1 maximum value for option, wrap to minimum value if changed value equals this
  31. 3 24bit adress of option byte to change
  32. 1 number of subroutine to execute when option is changed(push status and registers before executing)
  33. 1 palette number when unselected
  34. 1 palette number when selected
  35. 1 number of option text strings(max=3, AND with 0x3)
  36. 2xstring quant. relative pointer to text string
  37. x option text string(s), #$00 terminated
  38. processing flow:
  39. 1. setup pointer to menu file
  40. 2. load all general menu options and save to variables
  41. 3. process and draw each option string onto screen once
  42. -setup pointer to row table
  43. -draw each option with corresponding option value once
  44. 4. go to first option
  45. -if up pressed, redraw current line in unselected, decrease current line, redraw new current line in selected
  46. -if down pressed, redraw current line in unselected, increase current line, redraw new current line in selected
  47. -if right pressed, increase options variable pointer
  48. -if left pressed, decrease options variable pointer
  49. data files:
  50. MenuFiles
  51. Pointer Tables
  52. MenuFilesPTable
  53. variables:
  54. MenuFileThreeBytePointerLo
  55. MenuFileThreeBytePointerHi
  56. MenuFileThreeBytePointerBank
  57. MenuRowsThreeBytePointerLo
  58. MenuRowsThreeBytePointerHi
  59. MenuRowsThreeBytePointerBank
  60. MenuRowsThreeByteOptionPointerLo
  61. MenuRowsThreeByteOptionPointerHi
  62. MenuRowsThreeByteOptionPointerBank
  63. MenuRowsThreeByteCodePointerLo
  64. MenuRowsThreeByteCodePointerHi
  65. MenuRowsThreeByteCodePointerBank
  66. LoadMenuInitialOffset
  67. LoadMenuInitialOptionOffset
  68. LoadMenuVerticalSpacing
  69. LoadMenuNumberOfRows
  70. LoadMenuCurrentRow
  71. LoadMenuStringPosLo
  72. ram areas:
  73. LoadMenuStringBuffer(16bytes)
  74. string printing area, 16 bytes:
  75. 0 - LoadMenuStringBuffer
  76. 1 - LoadMenuStringSetOff ;always #$01, set new position
  77. 2 - LoadMenuStringPosLo ;position of string
  78. 3 - LoadMenuStringPosHi
  79. 4 - LoadMenuStringSetPal ;always #$07, set palette
  80. 5 - LoadMenuStringPal ;palette number
  81. 6 - LoadMenuStringNewAddr ;draw variable length string, always #$04
  82. 7 - LoadMenuStringVectLo
  83. 8 - LoadMenuStringVectHi
  84. 9 - LoadMenuStringVectBa
  85. a - LoadMenuStringSetOff2
  86. b - LoadMenuStringPosLo2 ;position of string
  87. c - LoadMenuStringPosHi2
  88. d - LoadMenuStringByte/binary/string
  89. ;this is the textstring for the text buffer of the menu system
  90. TextString20:
  91. .dw $0000 ;offset on bg1 tilemap
  92. .db $04 ;terminator
  93. .dw LoadMenuStringBuffer
  94. .db $7e
  95. */
  96. LoadMenuFile:
  97. php
  98. sep #$20
  99. phb ;set data bank = wram
  100. lda.b #$7e
  101. pha
  102. plb
  103. lda.b LoadMenuDoInit ;check if menu was already initialized
  104. bne LoadMenuFileAlreadyInitialized
  105. lda #(:MenuFiles+BaseAdress>>16) ;get source bank of strings
  106. sta MenuFileThreeBytePointerBank ;
  107. rep #$30 ;accu 16bit
  108. txa ;get number of string
  109. asl ;multiply by 2 to get pointertable entry
  110. tax
  111. lda.l (MenuFilesPTable+BaseAdress),x ;get source offset of string
  112. sta MenuFileThreeBytePointerLo
  113. ldy.w #$0000
  114. lda [MenuFileThreeBytePointerLo],y ;get target buffer in wram
  115. iny ;increment source position, word
  116. iny
  117. and.w #$fffe ;mask off bit 0 to ensure text is word-formatted properly
  118. sta.b LoadMenuInitialOffset
  119. lda.b [MenuFileThreeBytePointerLo],y ;get option position
  120. iny
  121. clc
  122. sep #$20
  123. asl a
  124. sta.b LoadMenuInitialOptionOffset ;store in variable
  125. lda.b [MenuFileThreeBytePointerLo],y ;get vertical spacing position
  126. iny
  127. and.b #$0f ;maximum range:16
  128. inc a
  129. tax
  130. lda.b #$00
  131. LoadMenuCalcVerticalSpacingLoop:
  132. clc
  133. adc.b #$40
  134. dex
  135. bne LoadMenuCalcVerticalSpacingLoop ;add one tileline for every loop, but do it at least once
  136. sta.b LoadMenuVerticalSpacing
  137. lda.b [MenuFileThreeBytePointerLo],y ;get number of rows/options
  138. iny
  139. and.b #$1f ;maximum number:32
  140. bne LoadMenuNumberOfRowsNotZero
  141. plb ;exit if number of rows=0
  142. plp
  143. rts
  144. LoadMenuNumberOfRowsNotZero:
  145. sta.b LoadMenuNumberOfRows
  146. stz.b LoadMenuCurrentRow ;start processing at first row
  147. stz.b LoadMenuPalUnselSel ;draw unselected palette
  148. LoadMenuInitialOptionDrawLoop:
  149. jsr LoadMenuSetupRowPointer
  150. jsr LoadMenuDrawDescString
  151. jsr LoadMenuDrawOptionValue
  152. sep #$20
  153. lda.b LoadMenuCurrentRow
  154. inc a
  155. sta.b LoadMenuCurrentRow
  156. cmp.b LoadMenuNumberOfRows
  157. bne LoadMenuInitialOptionDrawLoop
  158. stz.b LoadMenuCurrentRow ;start at row 1
  159. inc.b LoadMenuDoInit ;store "menu initialized"
  160. lda.b #$01
  161. sta.b LoadMenuPalUnselSel ;draw first row highlighted
  162. jsr LoadMenuSetupRowPointer
  163. jsr LoadMenuDrawDescString
  164. jsr LoadMenuDrawOptionValue
  165. LoadMenuFileAlreadyInitialized:
  166. sep #$20
  167. jsr LoadMenuSetupRowPointer
  168. jsr LoadMenuDrawOptionValue
  169. rep #$31
  170. lda.w JoyPortBufferTrigger&$ffff
  171. ldx.w #$ffff ;clear number of loaded button-1
  172. LoadMenuFileCheckNextButton:
  173. inx
  174. cpx.w #$0010 ;check if all buttons have been checked
  175. beq LoadMenuFileCheckNextButtonDone
  176. lsr a ;start at button bit 0
  177. bcc LoadMenuFileCheckNextButton
  178. pha
  179. phx
  180. txa
  181. clc
  182. asl a
  183. tax
  184. jsr (LoadMenuFileCheckNextButtonJumpTbl,x)
  185. plx
  186. pla
  187. bra LoadMenuFileCheckNextButton
  188. LoadMenuFileCheckNextButtonDone:
  189. plb ;exit if number of rows=0
  190. plp
  191. rts
  192. LoadMenuFileCheckNextButtonJumpTbl:
  193. .dw LoadMenuButtonVoid
  194. .dw LoadMenuButtonVoid
  195. .dw LoadMenuButtonVoid
  196. .dw LoadMenuButtonVoid
  197. .dw LoadMenuButtonVoid ;r
  198. .dw LoadMenuButtonVoid ;l
  199. .dw LoadMenuButtonVoid ;x
  200. .dw LoadMenuExecuteSubroutine ;a
  201. .dw LoadMenuIncreaseOption ;right
  202. .dw LoadMenuDecreaseOption ;left
  203. .dw LoadMenuIncreaseRow ;down
  204. .dw LoadMenuDecreaseRow ;up
  205. .dw LoadMenuButtonVoid ;start
  206. .dw LoadMenuButtonVoid ;select
  207. .dw LoadMenuButtonVoid ;a
  208. .dw LoadMenuButtonVoid ;b
  209. .dw LoadMenuButtonVoid
  210. LoadMenuButtonVoid:
  211. rts
  212. LoadMenuIncreaseRow:
  213. php
  214. rep #$31
  215. sep #$20
  216. stz.b LoadMenuPalUnselSel ;draw current row unselected
  217. jsr LoadMenuSetupRowPointer
  218. jsr LoadMenuDrawDescString
  219. jsr LoadMenuDrawOptionValue
  220. lda.b LoadMenuCurrentRow
  221. inc a
  222. cmp.b LoadMenuNumberOfRows
  223. bcc LoadMenuIncreaseRowNoOverflow
  224. lda.b #$00 ;wrap around to zero if maximum number of options is reached
  225. LoadMenuIncreaseRowNoOverflow:
  226. sta.b LoadMenuCurrentRow
  227. lda.b #$01
  228. sta.b LoadMenuPalUnselSel ;draw current row
  229. jsr LoadMenuSetupRowPointer
  230. jsr LoadMenuDrawDescString
  231. jsr LoadMenuDrawOptionValue
  232. plp
  233. rts
  234. LoadMenuDecreaseRow:
  235. php
  236. rep #$31
  237. sep #$20
  238. stz.b LoadMenuPalUnselSel ;draw current row unselected
  239. jsr LoadMenuSetupRowPointer
  240. jsr LoadMenuDrawDescString
  241. jsr LoadMenuDrawOptionValue
  242. lda.b LoadMenuCurrentRow
  243. dec a
  244. bpl LoadMenuIncreaseRowNoOverflow
  245. lda.b LoadMenuNumberOfRows ;wrap around to highest row if minimum number of options is reached
  246. dec a
  247. LoadMenuDecreaseRowNoOverflow:
  248. sta.b LoadMenuCurrentRow
  249. lda.b #$01
  250. sta.b LoadMenuPalUnselSel ;draw current row
  251. jsr LoadMenuSetupRowPointer
  252. jsr LoadMenuDrawDescString
  253. jsr LoadMenuDrawOptionValue
  254. plp
  255. rts
  256. LoadMenuIncreaseOption:
  257. phy
  258. php
  259. rep #$31
  260. sep #$20
  261. jsr LoadMenuSetupRowPointer
  262. ldy.w #$0000
  263. lda.b [MenuRowsThreeBytePointerLo],y ;do nothing if were processing a subroutine-only option
  264. bne LoadMenuIncreaseOptionNoEnd
  265. plp
  266. ply
  267. rts
  268. LoadMenuIncreaseOptionNoEnd:
  269. ldy.w #$0000
  270. lda.b [MenuRowsThreeByteOptionPointerLo],y ;get byte, increase it and compare if its greater than the maximum value
  271. ldy.w #$0003
  272. cmp.b [MenuRowsThreeBytePointerLo],y
  273. bcc LoadMenuIncreaseOptionNoOverflow
  274. dey
  275. lda.b [MenuRowsThreeBytePointerLo],y ;get minimum value if wrap around
  276. dec a
  277. LoadMenuIncreaseOptionNoOverflow:
  278. ldy.w #$0000
  279. inc a
  280. sta.b [MenuRowsThreeByteOptionPointerLo],y ;save back changed value
  281. ; ldy.w #0
  282. lda.b [MenuRowsThreeBytePointerLo],y
  283. cmp.b #1
  284. bne LoadMenuIncNoByte ;only check for b if we're processing a byte-option
  285. lda.w JoyPortBufferTrigger&$ffff+1
  286. bpl LoadMenuIncNoByte
  287. clc
  288. lda.b [MenuRowsThreeByteOptionPointerLo],y ;save back changed value
  289. adc.b #$f ;add a whole nibble if b is pressed
  290. sta.b [MenuRowsThreeByteOptionPointerLo],y
  291. LoadMenuIncNoByte:
  292. lda.b #$01
  293. sta.b LoadMenuPalUnselSel ;redraw current option
  294. jsr LoadMenuDrawDescString
  295. jsr LoadMenuDrawOptionValue
  296. plp
  297. ply
  298. rts
  299. LoadMenuDecreaseOption:
  300. phy
  301. php
  302. rep #$31
  303. sep #$20
  304. jsr LoadMenuSetupRowPointer
  305. ldy.w #$0000
  306. lda.b [MenuRowsThreeBytePointerLo],y ;do nothing if were processing a subroutine-only option
  307. bne LoadMenuDecreaseOptionNoEnd
  308. plp
  309. ply
  310. rts
  311. LoadMenuDecreaseOptionNoEnd:
  312. ldy.w #$0000
  313. ; lda.b [MenuRowsThreeByteOptionPointerLo],y ;get byte, increase it and compare if its greater than the maximum value
  314. lda.b [MenuRowsThreeBytePointerLo],y
  315. cmp.b #1
  316. bne LoadMenuDecNoByte ;only check for b if we're processing a byte-option
  317. lda.w JoyPortBufferTrigger&$ffff+1
  318. bpl LoadMenuDecNoByte
  319. sec
  320. lda.b [MenuRowsThreeByteOptionPointerLo],y ;save back changed value
  321. sbc.b #$f ;add a whole nibble if b is pressed
  322. sta.b [MenuRowsThreeByteOptionPointerLo],y
  323. LoadMenuDecNoByte:
  324. lda.b [MenuRowsThreeByteOptionPointerLo],y ;get byte, increase it and compare if its greater than the maximum value
  325. dec a
  326. cmp.b #$ff
  327. beq LoadMenuDecreaseOptionOverflow
  328. ldy.w #$0002
  329. cmp.b [MenuRowsThreeBytePointerLo],y
  330. bcs LoadMenuDecreaseOptionNoOverflow
  331. LoadMenuDecreaseOptionOverflow:
  332. ldy.w #$0003
  333. lda.b [MenuRowsThreeBytePointerLo],y ;get minimum value if wrap around
  334. LoadMenuDecreaseOptionNoOverflow:
  335. ldy.w #$0000
  336. sta.b [MenuRowsThreeByteOptionPointerLo],y ;save back changed value
  337. lda.b #$01
  338. sta.b LoadMenuPalUnselSel ;redraw current option
  339. jsr LoadMenuDrawDescString
  340. jsr LoadMenuDrawOptionValue
  341. plp
  342. ply
  343. rts
  344. LoadMenuExecuteSubroutine:
  345. pha
  346. phy
  347. phx
  348. php
  349. phd
  350. phb
  351. rep #$31
  352. sep #$20
  353. lda.b #$7e
  354. pha
  355. plb
  356. ldy.w #0007
  357. lda.b [MenuRowsThreeBytePointerLo],y ;get number of subroutine to execute
  358. clc
  359. asl a
  360. tax
  361. jsr (MenuSubroutineLUT,x)
  362. plb
  363. pld
  364. plp
  365. plx
  366. ply
  367. pla
  368. rts
  369. MenuDataTypeVoid:
  370. MenuDataType0:
  371. rts ;no action if theres no string to draw
  372. MenuDataType1:
  373. phx
  374. phy
  375. php
  376. rep #$31
  377. lda.b LoadMenuInitialOptionOffset ;get relative offset of option
  378. and.w #$00ff
  379. adc.b LoadMenuStringPosLo ;add offset of current row
  380. sta.w LoadMenuStringBuffer&$ffff+1 ;store in string position
  381. ldy.w #$0004
  382. lda.b [MenuRowsThreeBytePointerLo],y ;get pointer to byte
  383. sta.w LoadMenuStringBuffer&$ffff+6
  384. sep #$20
  385. iny
  386. iny
  387. lda.b [MenuRowsThreeBytePointerLo],y ;get bank pointer to byte
  388. sta.w LoadMenuStringBuffer&$ffff+8
  389. lda.b #$05 ;write "draw byte" command"
  390. sta.w LoadMenuStringBuffer&$ffff+5
  391. ldx.w #2 ;print to screen
  392. jsr LoadTextString
  393. plp
  394. ply
  395. plx
  396. rts
  397. MenuDataType2:
  398. phx
  399. phy
  400. php
  401. rep #$31
  402. lda.b LoadMenuInitialOptionOffset ;get relative offset of option
  403. and.w #$00ff
  404. adc.b LoadMenuStringPosLo ;add offset of current row
  405. sta.w LoadMenuStringBuffer&$ffff+1 ;store in string position
  406. ldy.w #$0004
  407. lda.b [MenuRowsThreeBytePointerLo],y ;get pointer to byte
  408. sta.w LoadMenuStringBuffer&$ffff+6
  409. sep #$20
  410. iny
  411. iny
  412. lda.b [MenuRowsThreeBytePointerLo],y ;get bank pointer to byte
  413. sta.w LoadMenuStringBuffer&$ffff+8
  414. lda.b #$06 ;write "draw byte" command"
  415. sta.w LoadMenuStringBuffer&$ffff+5
  416. ldx.w #2 ;print to screen
  417. jsr LoadTextString
  418. plp
  419. ply
  420. plx
  421. rts
  422. MenuDataType3:
  423. phx
  424. phy
  425. php
  426. rep #$31
  427. lda.b LoadMenuInitialOptionOffset ;get relative offset of option
  428. and.w #$00ff
  429. adc.b LoadMenuStringPosLo ;add offset of current row
  430. sta.w LoadMenuStringBuffer&$ffff+1 ;store in string position
  431. lda.w #$0000 ;clear a
  432. sep #$20
  433. ldy.w #$0001
  434. lda.b [MenuRowsThreeBytePointerLo],y ;get bitmask
  435. sta.w LoadMenuStringBuffer&$ffff+6 ;just a temporary buffer
  436. ldy.w #$0000
  437. lda.b [MenuRowsThreeByteOptionPointerLo],y
  438. and.w LoadMenuStringBuffer&$ffff+6 ;check which string to choose
  439. rep #$31 ;if string1, a=0
  440. and.w #$ff
  441. ; beq MenuDataType3String1
  442. ; lda.b #$02 ;load textstring 2, two byte pointer
  443. ;MenuDataType3String1:
  444. asl a ;2byte pointer
  445. adc.w #0012 ;add until we're at pointer for string 1 or 2
  446. tay
  447. lda.b [MenuRowsThreeBytePointerLo],y ;get relative string pointer
  448. clc
  449. adc.b MenuFileThreeBytePointerLo ;add file offset to get real pointer
  450. sta.w LoadMenuStringBuffer&$ffff+6
  451. sep #$20
  452. lda.b MenuFileThreeBytePointerBank
  453. sta.w LoadMenuStringBuffer&$ffff+8
  454. lda.b #$04 ;write "draw string from adress" command"
  455. sta.w LoadMenuStringBuffer&$ffff+5
  456. ldx.w #2 ;print to screen
  457. jsr LoadTextString
  458. plp
  459. ply
  460. plx
  461. rts
  462. LoadMenuInitialOptionDrawDataTypeJumpTable:
  463. .dw MenuDataType0
  464. .dw MenuDataType1
  465. .dw MenuDataType2
  466. .dw MenuDataType3
  467. .dw MenuDataTypeVoid
  468. .dw MenuDataTypeVoid
  469. .dw MenuDataTypeVoid
  470. .dw MenuDataTypeVoid
  471. LoadMenuDrawDescString:
  472. phy
  473. phx
  474. php
  475. rep #$31 ;16bit and carry clear
  476. lda.w #$0000
  477. tax
  478. LoadMenuDrawDescStringClearBufferLoop:
  479. sta.w LoadMenuStringBuffer&$ffff,x
  480. inx
  481. inx
  482. cpx.w #$0008 ;clear 16 bytes of string buffer
  483. bcc LoadMenuDrawDescStringClearBufferLoop
  484. lda.b LoadMenuCurrentRow
  485. and.w #$001f
  486. tax
  487. lda.w #$0000
  488. LoadMenuDrawDescStringVertPosLoop:
  489. cpx.w #$0000
  490. beq LoadMenuDrawDescStringVertPosLoopExit
  491. clc
  492. adc.b LoadMenuVerticalSpacing
  493. dex
  494. bra LoadMenuDrawDescStringVertPosLoop
  495. LoadMenuDrawDescStringVertPosLoopExit:
  496. clc
  497. adc.b LoadMenuInitialOffset ;add offset of whole menu
  498. sta.b LoadMenuStringPosLo ;store in initial offset of current row
  499. sta.w LoadMenuStringBuffer&$ffff+1
  500. lda.b LoadMenuPalUnselSel
  501. and.b #$0001 ;only get lowest bit to check if we should draw highlighted or not
  502. clc
  503. adc.w #0008 ;get palette number 10=unselected, 11=selected
  504. tay
  505. sep #$20
  506. lda.b [MenuRowsThreeBytePointerLo],y
  507. sta.w LoadMenuStringBuffer&$ffff+4
  508. lda.b #$04 ;script command "set string adress"
  509. sta.w LoadMenuStringBuffer&$ffff+5
  510. inc.w LoadMenuStringBuffer&$ffff ;script command "set position" for description text
  511. lda.b #$07 ;script command "set palette"
  512. sta.w LoadMenuStringBuffer&$ffff+3
  513. rep #$31
  514. ldy.w #0010 ;get string offset
  515. lda.b [MenuRowsThreeBytePointerLo],y
  516. adc.b MenuFileThreeBytePointerLo ;add file offset to get real pointer
  517. sta.w LoadMenuStringBuffer&$ffff+6
  518. sep #$20
  519. lda.b MenuFileThreeBytePointerBank
  520. sta.w LoadMenuStringBuffer&$ffff+8
  521. ldx.w #2 ;print to screen
  522. jsr LoadTextString
  523. plp
  524. plx
  525. ply
  526. rts
  527. LoadMenuSetupRowPointer:
  528. phy
  529. php
  530. rep #$31 ;16bit and carry clear
  531. lda.b LoadMenuCurrentRow
  532. and.w #$001f
  533. asl a
  534. adc.w #$0005 ;add offset of relative pointertable in menu file
  535. tay
  536. lda.b [MenuFileThreeBytePointerLo],y
  537. adc.b MenuFileThreeBytePointerLo ;add file offset to get real pointer
  538. sta.b MenuRowsThreeBytePointerLo
  539. sep #$20
  540. lda.b MenuFileThreeBytePointerBank
  541. sta.b MenuRowsThreeBytePointerBank
  542. ldy.w #$0006 ;get option byte bank pointer
  543. lda.b [MenuRowsThreeBytePointerLo],y
  544. sta.b MenuRowsThreeByteOptionPointerBank
  545. rep #$30
  546. ldy.w #$0004 ;get option byte pointer
  547. lda.b [MenuRowsThreeBytePointerLo],y
  548. sta.b MenuRowsThreeByteOptionPointerLo
  549. sep #$20
  550. /*
  551. ldy.w #$0009 ;get options subroutine byte bank pointer
  552. lda.b [MenuRowsThreeBytePointerLo],y
  553. sta.b MenuRowsThreeByteCodePointerBank
  554. rep #$30
  555. ldy.w #$0007 ;get options subroutine byte pointer
  556. lda.b [MenuRowsThreeBytePointerLo],y
  557. sta.b MenuRowsThreeByteCodePointerLo
  558. sep #$20
  559. */
  560. plp
  561. ply
  562. rts
  563. LoadMenuDrawOptionValue:
  564. phy
  565. phx
  566. php
  567. rep #$31
  568. ldy.w #0000 ;get option data type
  569. tya
  570. sep #$20
  571. lda.b [MenuRowsThreeBytePointerLo],y
  572. and.b #$07 ;maximum number of types=7
  573. asl
  574. tax
  575. jsr (LoadMenuInitialOptionDrawDataTypeJumpTable,x)
  576. plp
  577. plx
  578. ply
  579. rts