startmenu.z80 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. startmenu__:
  2. ;need to add in the options at the bottom
  3. ;add title at the top
  4. ;Need to set the filter flags
  5. ;Need to draw the menu box
  6. ;Need to show <status><name><type>
  7. ;Show 7 programs at a time
  8. ;First we set up the initial data and pointers
  9. call SetUpData
  10. ;Delete temp programs (archived progs are copied to temp programs)
  11. bcall(_DeleteTempPrograms)
  12. ;Sort the VAT, but put the calc in 15MHz mode if possible in order to speed it up
  13. ld c,1
  14. call SetSpeed
  15. ;Set up some pointers for VAT traversal
  16. ld hl,sortVAT
  17. ld (next_page_call_address),hl
  18. call next_page_call
  19. ;Set the default gbuf to appBackUpScreen and clear it
  20. ld hl,appBackUpScreen
  21. ld (gbuf_temp),hl
  22. ld (BufPtr),hl
  23. ld (GrayBufPtr),hl
  24. call ZeroMem768
  25. ;Set speed to 6MHz, take advantage of A=0 fom ZeroMem768
  26. out (20h),a
  27. ;now we are going to draw the top and bottom fields
  28. ;Top line
  29. ;ld a,-1
  30. dec a ;A is zero from ZeroMem768
  31. ld hl,appBackUpScreen+672
  32. ld b,12
  33. call SetSmallMem
  34. ;bottom line
  35. ld hl,appBackUpScreen+96
  36. ld b,12
  37. call SetSmallMem
  38. ;Header text (version number)
  39. ld hl,StrVersion
  40. ld bc,$0301
  41. call GPutSS
  42. ;Options
  43. ld hl,58
  44. ld (TextRow),hl
  45. call GPutSI
  46. .db "Gram AppV Asm Exit More",0
  47. ;draw the bars between the options
  48. ld de,$0111
  49. _:
  50. ld bc,0838h
  51. push de
  52. ld a,d
  53. call DrawRectToGraph
  54. pop de
  55. ld a,e
  56. add a,20
  57. ld e,a
  58. cp 96
  59. jr c,-_
  60. ;highlight the 'Grammer' filter option
  61. call highlight_Gram
  62. ;Need to set the filter flags.
  63. ld (iy+34),8
  64. ;Draw the menu box
  65. call DrawRectToGraphI \ .db 16,10,44,64,1
  66. call DrawRectToGraphI \ .db 15,11,42,66,2
  67. redraw_menu:
  68. ; Erase contents of the menu box
  69. call DrawRectToGraphI \ .db 16,11,42,64,0
  70. ;Reset the menu data
  71. ld hl,(progPtr)
  72. ld (VATptr),hl
  73. ; ld (VATptr_next),hl
  74. call VATPtrToOP1
  75. ld hl,0
  76. ld (main_menu_cursor),hl ;L=cursor, h=cursor_max
  77. ld (main_menu_index),hl
  78. ;Load the first seven entries (if possible)
  79. _:
  80. call isStartMenu_valid
  81. jr nz,+_
  82. ld hl,(VATPtr)
  83. ld (VATPtr_next),hl ;just a safe place to store it
  84. call NextVAT_valid_draw_advance_stepin
  85. jr startVATloop
  86. _:
  87. call NextVAT_valid_draw
  88. jr c,main_menu_loop
  89. ld hl,(VATPtr)
  90. ld (VATPtr_next),hl ;just a safe place to store it
  91. startVATloop:
  92. call NextVAT_valid_draw
  93. jr c,+_
  94. ld a,(main_menu_cursor_max)
  95. cp 7
  96. jr nz,startVATloop
  97. _:
  98. ld de,(VATPtr_next)
  99. ld hl,(VATPtr)
  100. ld (VATPtr_next),hl
  101. ld (VATPtr),de
  102. main_menu_loop:
  103. ;here we need to draw the cursor highlight
  104. ld a,(main_menu_cursor)
  105. ld l,a
  106. add a,a
  107. add a,l
  108. add a,a
  109. add a,11 ;y coord
  110. ld b,6
  111. ld c,a
  112. ld de,$4010
  113. push bc
  114. ld a,2
  115. call DrawRectToGraph
  116. call GraphToLCD
  117. pop bc
  118. ld de,$4010
  119. ld a,2
  120. call DrawRectToGraph
  121. main_menu_ui_loop:
  122. in a,(4)
  123. and 8
  124. ret z
  125. call GetKeyDebounce
  126. or a
  127. jr z,main_menu_ui_loop
  128. cp 15 \ ret z ;clear
  129. cp 50 \ ret z ;F4 (Exit)
  130. cp 49
  131. jr z,$+6
  132. cp 55
  133. jr nz,+_
  134. ld hl,modemenu
  135. ld (next_page_call_address),hl
  136. call next_page_call
  137. jp startmenu__
  138. _:
  139. cp 53 \ jr nz,+_ ;F1 (Gram)
  140. ld a,(flags+34)
  141. xor 8
  142. ld (flags+34),a
  143. ld de,$1100
  144. jr highlight_option
  145. _:
  146. cp 52 \ jr nz,+_ ;F2 (AppV)
  147. ld a,(flags+34)
  148. xor 64
  149. ld (flags+34),a
  150. ld de,1312h
  151. highlight_option:
  152. call highlight
  153. jp redraw_menu
  154. _:
  155. cp 51 \ jr nz,+_ ;F3
  156. ld a,(flags+34)
  157. xor 4
  158. ld (flags+34),a
  159. ld de,1326h
  160. jr highlight_option
  161. _:
  162. ld hl,main_menu_cursor
  163. cp 54 ;[2nd]
  164. jr z,+_
  165. cp 12 ;[*]
  166. jp z,main_menu_archunarch
  167. dec a \ jr z,cur_dn ;down
  168. sub 3 \ jp z,cur_up ;up
  169. cp 5 ;[Enter]-4
  170. jp nz,main_menu_ui_loop
  171. _:
  172. ;here ENTER is pressed
  173. ;need to load the variable name into OP1
  174. call main_menu_get_var_name
  175. call isStartMenu_valid
  176. call z,SelectedProgOP1
  177. jp startmenu__
  178. main_menu_get_var_name:
  179. ld a,(hl)
  180. or a
  181. jr z,selected_entry
  182. _:
  183. push af
  184. call NextVAT_valid
  185. pop af
  186. dec a
  187. jr nz,-_
  188. selected_entry:
  189. ld hl,(VATPtr)
  190. jp VATPtrToOP1
  191. cur_dn:
  192. ld a,(hl)
  193. inc a
  194. inc hl
  195. cp (hl)
  196. jr nc,+_
  197. dec hl
  198. ld (hl),a
  199. jp main_menu_loop
  200. _:
  201. cp 7
  202. jp nz,main_menu_ui_loop
  203. ;here we need to scroll down.
  204. ;This means we need to advance VATPtr and VATPtr_next
  205. ;draw VATPtr_next
  206. ;first, advance VATPtr_next
  207. ld hl,(VATPtr)
  208. push hl
  209. ld hl,(VATPtr_next)
  210. ld (VATPtr),hl
  211. call NextVAT_valid
  212. pop hl
  213. ld de,(VATPtr)
  214. ld (VATPtr),hl
  215. jp c,main_menu_ui_loop
  216. _:
  217. ld (VATPtr_next),de
  218. ;now we know there are more entries
  219. ;shift the menu up, then draw the entry, then advance VATPtr
  220. ld de,appBackUpScreen+134
  221. ld hl,appBackUpScreen+206
  222. ld a,36
  223. _:
  224. call mov8
  225. inc l \ inc hl
  226. inc l \ inc hl
  227. inc e \ inc de
  228. inc e \ inc de
  229. dec a
  230. jr nz,-_
  231. ;We need to clear the bottom 6 rows of pixels
  232. call DrawRectToGraphI \ .db 16,47,6,64,0
  233. ld a,6
  234. call draw_var_name
  235. call NextVAT_valid
  236. ld hl,(main_menu_index)
  237. inc hl
  238. ld (main_menu_index),hl
  239. jp main_menu_loop
  240. cur_up:
  241. ld a,(hl)
  242. or a
  243. jr z,+_
  244. dec (hl)
  245. jp main_menu_loop
  246. _:
  247. ;now we need to scroll up. Verify that main_menu_index!=0
  248. ld hl,(main_menu_index)
  249. ld a,h
  250. or l
  251. jp z,main_menu_ui_loop
  252. dec hl
  253. ld (main_menu_index),hl
  254. ld hl,(VATPtr)
  255. push hl
  256. ld de,(VATPtr_next)
  257. call PrevVAT_valid_with_start
  258. ; call PrevVAT_with_start
  259. ld hl,(VATPtr)
  260. ld (VATPtr_next),hl
  261. pop hl
  262. ld (VATPtr),hl
  263. call PrevVAT_valid
  264. ;need to shift the screen up
  265. ld hl,appBackUpScreen+561
  266. ld de,appBackUpScreen+633
  267. ld a,36
  268. _:
  269. ldd \ ldd \ ldd \ ldd
  270. ldd \ ldd \ ldd \ ldd
  271. dec l \ dec hl
  272. dec l \ dec hl
  273. dec e \ dec de
  274. dec e \ dec de
  275. dec a
  276. jr nz,-_
  277. call DrawRectToGraphI \ .db 16,11,6,64,0
  278. call draw_var_name
  279. jp main_menu_loop
  280. highlight_Gram:
  281. ld de,$1100
  282. highlight:
  283. ld bc,0739h
  284. ld a,2
  285. jp DrawRectToGraph
  286. NextVAT_valid_draw:
  287. call NextVAT_valid
  288. ret c
  289. NextVAT_valid_draw_advance_stepin:
  290. ld hl,main_menu_cursor_max
  291. ld a,(hl)
  292. inc (hl)
  293. call draw_var_name
  294. or a
  295. ret
  296. NextVAT_valid:
  297. ld hl,(VATPtr)
  298. push hl
  299. call +_
  300. pop hl
  301. ret nc
  302. ld (VATPtr),hl
  303. ret
  304. _:
  305. call NextVAT
  306. ret c
  307. call isStartMenu_valid
  308. jr nz,-_
  309. or a
  310. ret
  311. draw_var_name:
  312. push af
  313. bcall(_ChkFindSym)
  314. pop af
  315. ld h,b
  316. call calculate_text_coord
  317. xor a
  318. ld (OP1+9),a
  319. or h
  320. ld a,' '
  321. jr z,+_
  322. ld a,'*'
  323. _:
  324. call PutSC
  325. ld hl,OP1+1
  326. call GPutS
  327. ld a,16
  328. ld (textCol),a
  329. ld a,(OP1)
  330. cp 15h
  331. ld hl,s_appv
  332. jr z,+_
  333. ld hl,s_prog
  334. _:
  335. jp GPutS
  336. main_menu_archunarch:
  337. ; Calculate the text text coord for the archive status symbol
  338. ld a,(hl)
  339. push af
  340. call calculate_text_coord
  341. pop af
  342. call main_menu_get_var_name
  343. call isStartMenu_valid
  344. jp nz,main_menu_loop
  345. ; ld a,(OP1)
  346. ; push af
  347. bcall(_Arc_Unarc)
  348. ; Need to fix the RAM code after archiving/unarchiving.
  349. call setup_readarc
  350. ; pop af
  351. ; ld (OP1),a
  352. ;
  353. ; ; Need to overwrite the archive status symbol
  354. ; bcall(_ChkFindSym)
  355. ; inc b
  356. ; dec b
  357. ; ld a,' '
  358. ; jr z,+_
  359. ; ld a,'*'
  360. ; _:
  361. ; call PutSC
  362. jp redraw_menu
  363. calculate_text_coord:
  364. ld c,a
  365. add a,a
  366. add a,c
  367. add a,a
  368. add a,11 ;y coord
  369. ld c,a
  370. ld b,4
  371. ld (textRow),bc
  372. ret