?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;; Basic writing library ;; Busy soft ;; 14.04.2022 ;;
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  4.  
  5. ;; This library can be used for (relative)
  6. ;; easy writing basic programs in SjASMPlus.
  7. ;;
  8. ;; Macros:
  9. ;;
  10. ;;   LINE ... begin of basic line
  11. ;;   LEND ... end of basic line
  12. ;;   NUM .... include number value into basic
  13. ;;
  14. ;; Control variables:
  15. ;;
  16. ;;   line_useval ... Enable use VAL "..." for macro NUM
  17. ;;   line_number ... Actual line number for actual basic line
  18. ;;   line_step ..... Increment for automatic numbering of lines
  19. ;;
  20. ;; Typical usage ...
  21. ;;
  22. ;;   LINE : db bright : NUM 1        : LEND
  23. ;;   LINE : db print,'"Hello world"' : LEND
  24. ;;
  25. ;; ... generates this program:
  26. ;;
  27. ;;   10 BRIGHT 1
  28. ;;   20 PRINT "Hello world"
  29. ;;
  30. ;; Please see examples for more info.
  31.  
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  33.  
  34. ;; Basic token definitions
  35. ;;
  36. ;;  Note:  absx notx orx andx  are used
  37. ;;  due to conflict with SjASMPlus operators
  38. ;;
  39. ;;  If you have conflict with another labels
  40. ;;  you can encapsulate your basic by this way:
  41. ;;
  42. ;;    MODULE basic
  43. ;;      INCLUDE BasicLib.asm
  44. ;;      LINE : ...... : LEND
  45. ;;      LINE : ...... : LEND
  46. ;;    ENDMODULE
  47.  
  48. spectrum        equ     #A3
  49. play            equ     #A4
  50. rnd             equ     #A5
  51. inkey           equ     #A6
  52. pi              equ     #A7
  53. fn              equ     #A8
  54. point           equ     #A9
  55. screen          equ     #Aa
  56. attr            equ     #Ab
  57. at              equ     #Ac
  58. tab             equ     #Ad
  59. valS            equ     #Ae
  60. code            equ     #Af
  61. val             equ     #B0
  62. len             equ     #B1
  63. sin             equ     #B2
  64. cos             equ     #B3
  65. tan             equ     #B4
  66. asn             equ     #B5
  67. acs             equ     #B6
  68. atn             equ     #B7
  69. ln              equ     #B8
  70. exp             equ     #B9
  71. int             equ     #Ba
  72. sqr             equ     #Bb
  73. sgn             equ     #Bc
  74. absx            equ     #Bd
  75. peek            equ     #Be
  76. in              equ     #Bf
  77. usr             equ     #C0
  78. str             equ     #C1
  79. chr             equ     #C2
  80. notx            equ     #C3
  81. bin             equ     #C4
  82. orx             equ     #C5
  83. andx            equ     #C6
  84. line            equ     #Ca
  85. then            equ     #Cb
  86. to              equ     #Cc
  87. step            equ     #Cd
  88. deffn           equ     #Ce
  89. cat             equ     #Cf
  90. format          equ     #D0
  91. move            equ     #D1
  92. erase           equ     #D2
  93. open            equ     #D3
  94. close           equ     #D4
  95. merge           equ     #D5
  96. verify          equ     #D6
  97. beep            equ     #D7
  98. circle          equ     #D8
  99. ink             equ     #D9
  100. paper           equ     #Da
  101. flash           equ     #Db
  102. bright          equ     #Dc
  103. inverse         equ     #Dd
  104. over            equ     #De
  105. out             equ     #Df
  106. lprint          equ     #E0
  107. llist           equ     #E1
  108. stop            equ     #E2
  109. read            equ     #E3
  110. data            equ     #E4
  111. restore         equ     #E5
  112. new             equ     #E6
  113. border          equ     #E7
  114. cont            equ     #E8
  115. continue        equ     #E8
  116. dim             equ     #E9
  117. rem             equ     #Ea
  118. for             equ     #Eb
  119. goto            equ     #Ec
  120. gosub           equ     #Ed
  121. input           equ     #Ee
  122. load            equ     #Ef
  123. list            equ     #F0
  124. let             equ     #F1
  125. pause           equ     #F2
  126. next            equ     #F3
  127. poke            equ     #F4
  128. print           equ     #F5
  129. plot            equ     #F6
  130. run             equ     #F7
  131. save            equ     #F8
  132. rand            equ     #F9
  133. randomize       equ     #F9
  134. if              equ     #Fa
  135. cls             equ     #Fb
  136. draw            equ     #Fc
  137. clear           equ     #Fd
  138. return          equ     #Fe
  139. copy            equ     #Ff
  140.  
  141. ;; Basic UDG definitions
  142.  
  143. udg_a     equ   #90     ;; 144
  144. udg_b     equ   #91     ;; 145
  145. udg_c     equ   #92     ;; 146
  146. udg_d     equ   #93     ;; 147
  147. udg_e     equ   #94     ;; 148
  148. udg_f     equ   #95     ;; 149
  149. udg_g     equ   #96     ;; 150
  150. udg_h     equ   #97     ;; 151
  151. udg_i     equ   #98     ;; 152
  152. udg_j     equ   #99     ;; 153
  153. udg_k     equ   #9A     ;; 154
  154. udg_l     equ   #9B     ;; 155
  155. udg_m     equ   #9C     ;; 156
  156. udg_n     equ   #9D     ;; 157
  157. udg_o     equ   #9E     ;; 158
  158. udg_p     equ   #9F     ;; 159
  159. udg_q     equ   #A0     ;; 160
  160. udg_r     equ   #A1     ;; 161
  161. udg_s     equ   #A2     ;; 162
  162. udg_t     equ   #A3     ;; 163
  163. udg_u     equ   #A4     ;; 164
  164.  
  165. ;; Basic control codes
  166.  
  167. comma     equ   #06     ;; db print,'"X',comma,'Y"'
  168. left      equ   #08     ;; db print,'"',border,left,left,'L V',border,left,'I"'
  169. right     equ   #09     ;; (does not work due to bug in zx rom)
  170. enter     equ   #0D     ;; end of basic line, cannot be used inside of line normally
  171. number    equ   #0E     ;; db '65535',number,0,0,#FF,#FF,0   ;;   But you can use: NUM 65535
  172. s_ink     equ   #10     ;; db print,'"',s_ink    ,2,'Hello world!"'
  173. s_paper   equ   #11     ;; db print,'"',s_paper  ,5,'Hello world!"'
  174. s_flash   equ   #12     ;; db print,'"',s_flash  ,1,'Hello world!"'
  175. s_bright  equ   #13     ;; db print,'"',s_bright ,1,'Hello world!"'
  176. s_inverse equ   #14     ;; db print,'"',s_inverse,1,'Hello world!"'
  177. s_over    equ   #15     ;; db print,'"',s_over   ,1,'Hello world!"'
  178. s_at      equ   #16     ;; db print,'"',s_at,10,10 ,'Hello world!"'
  179. s_tab     equ   #17     ;; db print,'"',s_tab,10,0 ,'Hello world!"'
  180.  
  181. ;; Default setting of control variables
  182.  
  183. line_useval     =       0
  184. line_number     =       10
  185. line_step       =       10
  186.  
  187. ;; Begin of basic line
  188.  
  189. LINE  MACRO
  190.         ASSERT line_number < #4000 , Line number overflows
  191.         db      high line_number
  192.         db      low line_number
  193.         LUA ALLPASS
  194.         sj.parse_code('dw line_' .. tostring(sj.calc("line_number")) .. '_length')
  195.         sj.parse_line(   'line_' .. tostring(sj.calc("line_number")) .. '_begin')
  196.         ENDLUA
  197.       ENDM
  198.  
  199. ;; End of basic line
  200.  
  201. LEND  MACRO
  202.         db      #0D
  203.         LUA ALLPASS
  204.         sj.parse_line('line_'
  205.                 .. tostring(sj.calc("line_number"))
  206.                 .. '_length = $ - line_'
  207.                 .. tostring(sj.calc("line_number"))
  208.                 .. '_begin')
  209.         ENDLUA
  210. line_number  =  line_number + line_step
  211.       ENDM
  212.  
  213. ;; Include number value into basic line
  214.  
  215. NUM   MACRO     value
  216.         IF line_useval
  217.           db    val,'"'
  218.         ENDIF
  219.           LUA ALLPASS
  220.           sj.parse_code('db     "' .. tostring(sj.calc("value")) .. '"')
  221.           ENDLUA
  222.         IF line_useval
  223.           db    '"'
  224.         ELSE
  225.           db    #0E,0,0
  226.           dw    value
  227.           db    #00
  228.         ENDIF
  229.       ENDM
  230.  
  231. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  232.