menu.asm 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. XDEF Menu
  2. XREF __SEG_END_SSTACK,pw_set,disp,display_string,menu_option_num,menu_active,menu_selection
  3. Variables: Section
  4. Constants: Section
  5. Code: Section
  6. Menu: ;push register and accumulator values for retention
  7. PSHA
  8. PSHB
  9. PSHD
  10. PSHX
  11. PSHY
  12. LDAA menu_active ;do nothing if the menu is not active
  13. CMPA #$00
  14. LBEQ Return
  15. PrintTopLine:
  16. ;all menu items print this line
  17. movb #'S',disp
  18. movb #'e',disp+1
  19. movb #'l',disp+2
  20. movb #'e',disp+3
  21. movb #'c',disp+4
  22. movb #'t',disp+5
  23. movb #' ',disp+6
  24. movb #'o',disp+7
  25. movb #'p',disp+8
  26. movb #'t',disp+9
  27. movb #'i',disp+10
  28. movb #'o',disp+11
  29. movb #'n',disp+12
  30. movb #':',disp+13
  31. movb #' ',disp+14
  32. movb #' ',disp+15
  33. ;next line
  34. ;load the menu option and output the correct lower string
  35. LDAA menu_option_num
  36. CMPA #$01
  37. LBEQ PrintOption1
  38. CMPA #$02
  39. LBEQ PrintOption2
  40. CMPA #$03
  41. LBEQ PrintOption3
  42. CMPA #$04
  43. LBEQ PrintOption4
  44. CMPA #$05
  45. LBEQ PrintOption5
  46. CMPA #$06
  47. LBEQ PrintOption6
  48. CMPA #$07
  49. LBEQ PrintOption7
  50. Reset:
  51. MOVB #$01,menu_option_num
  52. LBRA PrintTopLine
  53. ;==================== main menu =======================
  54. ; 1. water the plants
  55. ; 2. show temperature (adjusts when the pot is turned)
  56. ; 3. show time
  57. ; 4. set time (passord protected)
  58. ; 5. change password (password protected)
  59. ;======================================================
  60. PrintOption1:
  61. movb #'1',disp+16
  62. movb #'.',disp+17
  63. movb #' ',disp+18
  64. movb #'W',disp+19
  65. movb #'a',disp+20
  66. movb #'t',disp+21
  67. movb #'e',disp+22
  68. movb #'r',disp+23
  69. movb #' ',disp+24
  70. movb #'p',disp+25
  71. movb #'l',disp+26
  72. movb #'a',disp+27
  73. movb #'n',disp+28
  74. movb #'t',disp+29
  75. movb #'s',disp+30
  76. movb #' ',disp+31
  77. movb #0,disp+32 ;string terminator, acts like '\0'
  78. ;print the prompt string
  79. LDD #disp ;both of these steps are necessary to
  80. jsr display_string ;print to the LCD screen
  81. ;get out of the menu, do not go to PrintOption2
  82. LBRA Return
  83. PrintOption2:
  84. movb #'2',disp+16
  85. movb #'.',disp+17
  86. movb #' ',disp+18
  87. movb #'S',disp+19
  88. movb #'h',disp+20
  89. movb #'o',disp+21
  90. movb #'w',disp+22
  91. movb #' ',disp+23
  92. movb #'t',disp+24
  93. movb #'e',disp+25
  94. movb #'m',disp+26
  95. movb #'p',disp+27
  96. movb #'.',disp+28
  97. movb #' ',disp+29
  98. movb #' ',disp+30
  99. movb #' ',disp+31
  100. movb #0,disp+32 ;string terminator, acts like '\0'
  101. ;print the prompt string
  102. LDD #disp ;both of these steps are necessary to
  103. jsr display_string ;print to the LCD screen
  104. ;get out of the menu, do not go to PrintOption23
  105. LBRA Return
  106. PrintOption3:
  107. movb #'3',disp+16
  108. movb #'.',disp+17
  109. movb #' ',disp+18
  110. movb #'S',disp+19
  111. movb #'h',disp+20
  112. movb #'o',disp+21
  113. movb #'w',disp+22
  114. movb #' ',disp+23
  115. movb #'t',disp+24
  116. movb #'i',disp+25
  117. movb #'m',disp+26
  118. movb #'e',disp+27
  119. movb #' ',disp+28
  120. movb #' ',disp+29
  121. movb #' ',disp+30
  122. movb #' ',disp+31
  123. movb #0,disp+32 ;string terminator, acts like '\0'
  124. ;print the prompt string
  125. LDD #disp ;both of these steps are necessary to
  126. jsr display_string ;print to the LCD screen
  127. ;get out of the menu, do not go to PrintOption23
  128. LBRA Return
  129. PrintOption4:
  130. movb #'4',disp+16
  131. movb #'.',disp+17
  132. movb #' ',disp+18
  133. movb #'S',disp+19
  134. movb #'e',disp+20
  135. movb #'t',disp+21
  136. movb #' ',disp+22
  137. movb #'t',disp+23
  138. movb #'i',disp+24
  139. movb #'m',disp+25
  140. movb #'e',disp+26
  141. movb #' ',disp+27
  142. movb #' ',disp+28
  143. movb #' ',disp+29
  144. movb #' ',disp+30
  145. movb #' ',disp+31
  146. movb #0,disp+32 ;string terminator, acts like '\0'
  147. ;print the prompt string
  148. LDD #disp ;both of these steps are necessary to
  149. jsr display_string ;print to the LCD screen
  150. ;get out of the menu, do not go to PrintOption23
  151. LBRA Return
  152. PrintOption5:
  153. movb #'5',disp+16
  154. movb #'.',disp+17
  155. movb #' ',disp+18
  156. movb #'R',disp+19
  157. movb #'e',disp+20
  158. movb #'s',disp+21
  159. movb #'e',disp+22
  160. movb #'t',disp+23
  161. movb #' ',disp+24
  162. movb #'p',disp+25
  163. movb #'a',disp+26
  164. movb #'s',disp+27
  165. movb #'s',disp+28
  166. movb #'w',disp+29
  167. movb #'d',disp+30
  168. movb #'.',disp+31
  169. movb #0,disp+32 ;string terminator, acts like '\0'
  170. ;print the prompt string
  171. LDD #disp ;both of these steps are necessary to
  172. jsr display_string ;print to the LCD screen
  173. ;get out of the menu, do not go to PrintOption23
  174. LBRA Return
  175. PrintOption6:
  176. movb #'6',disp+16
  177. movb #'.',disp+17
  178. movb #' ',disp+18
  179. movb #'P',disp+19
  180. movb #'l',disp+20
  181. movb #'a',disp+21
  182. movb #'n',disp+22
  183. movb #'t',disp+23
  184. movb #' ',disp+24
  185. movb #'s',disp+25
  186. movb #'e',disp+26
  187. movb #'e',disp+27
  188. movb #'d',disp+28
  189. movb #'s',disp+29
  190. movb #' ',disp+30
  191. movb #' ',disp+31
  192. movb #0,disp+32 ;string terminator, acts like '\0'
  193. ;print the prompt string
  194. LDD #disp ;both of these steps are necessary to
  195. jsr display_string ;print to the LCD screen
  196. ;get out of the menu, do not go to PrintOption6
  197. BRA Return
  198. PrintOption7:
  199. movb #'7',disp+16
  200. movb #'.',disp+17
  201. movb #' ',disp+18
  202. movb #'S',disp+19
  203. movb #'h',disp+20
  204. movb #'o',disp+21
  205. movb #'w',disp+22
  206. movb #' ',disp+23
  207. movb #'p',disp+24
  208. movb #'l',disp+25
  209. movb #'o',disp+26
  210. movb #'t',disp+27
  211. movb #' ',disp+28
  212. movb #' ',disp+29
  213. movb #' ',disp+30
  214. movb #' ',disp+31
  215. movb #0,disp+32 ;string terminator, acts like '\0'
  216. ;print the prompt string
  217. LDD #disp ;both of these steps are necessary to
  218. jsr display_string ;print to the LCD screen
  219. ;get out of the menu, do not go to PrintOption7
  220. BRA Return
  221. Return: ;restore registers and accumulators
  222. PULY
  223. PULX
  224. PULD
  225. PULB
  226. PULA
  227. RTS