Guest User

TinySB Pre constants

a guest
Sep 9th, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.46 KB | None | 0 0
  1. ; PROJECT : TinySBRunTime
  2. ; EDITED : 9/5/2016
  3. ; ---------------------------------------------------------------------
  4. #Include "SaveBitmap"
  5.  
  6.  
  7. //Define the constant colors oldschool style :)
  8. Dim constant_colors$(18)
  9. //Define the constant rgb values oldschool style :)
  10. Dim rgb_colors(18)
  11. constant_colors$(1)="#AQUA"
  12. constant_colors$(2)="#BLACK"
  13. constant_colors$(3)="#BLUE"
  14. constant_colors$(4)="#CYAN"
  15. constant_colors$(5)="#FUCHSIA"
  16. constant_colors$(6)="#GRAY"
  17. constant_colors$(7)="#GREEN"
  18. constant_colors$(8)="#LIME"
  19. constant_colors$(9)="#MAGENTA"
  20. constant_colors$(10)="#MAROON"
  21. constant_colors$(11)="#NAVY"
  22. constant_colors$(12)="#OLIVE"
  23. constant_colors$(13)="#PURPLE"
  24. constant_colors$(14)="#RED"
  25. constant_colors$(15)="#SILVER"
  26. constant_colors$(16)="#TEAL"
  27. constant_colors$(17)="#WHITE"
  28. constant_colors$(18)="#YELLOW"
  29.  
  30. rgb_colors(1)=rgb(0, 248, 248)
  31. rgb_colors(2)=rgb(0, 0, 0)
  32. rgb_colors(3)=rgb(0, 0, 255)
  33. rgb_colors(4)=rgb(0, 0, 248)
  34. rgb_colors(5)=rgb(248, 0, 248)
  35. rgb_colors(6)=rgb(128, 128, 128)
  36. rgb_colors(7)=rgb(0, 128, 0)
  37. rgb_colors(8)=rgb(0, 248, 0)
  38. rgb_colors(9)=rgb(248, 0, 248)
  39. rgb_colors(10)=rgb(128, 0, 0)
  40. rgb_colors(11)=rgb(0, 0, 128)
  41. rgb_colors(12)=rgb(128, 128, 0)
  42. rgb_colors(13)=rgb(128, 0, 128)
  43. rgb_colors(14)=rgb(248, 0, 0)
  44. rgb_colors(15)=rgb(192, 192, 192)
  45. rgb_colors(16)=rgb(0, 128, 128)
  46. rgb_colors(17)=rgb(248, 248, 248)
  47. rgb_colors(18)=rgb(248, 248, 0)
  48.  
  49. //Define the text color indexes as rgb values
  50.  
  51. dim constant_Tcolors$(15)
  52. constant_Tcolors$(1) = "#TBLACK" //1
  53. constant_Tcolors$(2) = "#TMAROON" //2
  54. constant_Tcolors$(3) = "#TRED" //3
  55. constant_Tcolors$(4) = "#TGREEN" //4
  56. constant_Tcolors$(5) = "#TLIME" //5
  57. constant_Tcolors$(6) = "#TOLIVE" //6
  58. constant_Tcolors$(7) = "#TYELLOW" //7
  59. constant_Tcolors$(8) = "#TNAVY" //8
  60. constant_Tcolors$(9) = "#TBLUE" //9
  61. constant_Tcolors$(10) = "#TPURPLE" //10
  62. constant_Tcolors$(11) = "#TMAGENTA" //11
  63. constant_Tcolors$(12) = "#TTEAL" //12
  64. constant_Tcolors$(13) = "#TCYAN" //13
  65. constant_Tcolors$(14) = "#TGRAY" //14
  66. constant_Tcolors$(15) = "#TWHITE" //15
  67.  
  68. //Set the rgb values in the mirror rgb array
  69. //We may as well just copy the values by their color names from the rgb_colors array
  70. dim constant_Tcolors(15)
  71. constant_Tcolors(1) = rgb_colors(2) //#BLACK
  72. constant_Tcolors(2) = rgb_colors(10) //#MAROON
  73. constant_Tcolors(3) = rgb_colors(14) //#RED
  74. constant_Tcolors(4) = rgb_colors(7) //#GREEN
  75. constant_Tcolors(5) = rgb_colors(8) //#LIME
  76. constant_Tcolors(6) = rgb_colors(12) //#OLIVE
  77. constant_Tcolors(7) = rgb_colors(18) //#YELLOW
  78. constant_Tcolors(8) = rgb_colors(11) //#NAVY
  79. constant_Tcolors(9) = rgb_colors(3) //#BLUE
  80. constant_Tcolors(10) = rgb_colors(13) //#PURPLE
  81. constant_Tcolors(11) = rgb_colors(9) //#MAGENTA
  82. constant_Tcolors(12) = rgb_colors(16) //#TEAL
  83. constant_Tcolors(13) = rgb_colors(4) //#CYAN
  84. constant_Tcolors(14) = rgb_colors(6) //#GRAY
  85. constant_Tcolors(15) = rgb_colors(17) //#WHITE
  86.  
  87.  
  88.  
  89. //Define tile_image constants make them all random color squares
  90. Dim tiles(1024)
  91. for t=0 to 1024
  92. tiles(t)=newfximage(16, 16)
  93. rendertoimage tiles(t)
  94. cls rndrgb()
  95. ink rgb(0,0,0)
  96. circle 8, 8, 8, 1
  97. next t
  98. ink rgb(255, 255, 255)
  99.  
  100.  
  101.  
  102. global global_textbackground=5
  103. global global_textforeground=6
  104. global global_textcursorX=0 //These work I think on 8 by 8
  105. global global_textcursorY=0
  106.  
  107. //Create the color tiles
  108. dim TXTBG(15)
  109. for t=1 to 15
  110. TXTBG(t) = newimage(16, 16)
  111. rendertoimage TXTBG(t)
  112. cls constant_Tcolors(t)
  113. next t
  114. rendertoscreen
  115.  
  116. dim graphics_page(2)
  117. for t=1 to 2
  118. graphics_page(t)=newfximage(getscreenwidth(), getscreenheight() )
  119. imagemaskcolour graphics_page(t),rgb(0,0,0) //Black
  120. next t
  121.  
  122. //Just a BIG note when dealing with text.
  123. //IF YOU EVER want to draw text to an image, for one reason or another using FX images is unreliable
  124. //ORRRR Playbasic is just fucked in the head.
  125.  
  126. global text_page = newimage(getscreenwidth(), getscreenheight() )
  127. imagemaskcolour text_page, rgb(0, 0, 0) ; black
  128. rendertoimage text_page
  129. Print "HELLO THERE" // This line breaks if the type of image text_page is an FXIMAGE
  130. //Not only that..
  131.  
  132. rendertoscreen
  133. drawimage text_page, 0, 0, 0
  134.  
  135. //drawimage text_page, 0, 0, 0
  136.  
  137. cls
  138. //When using CLS or ACLS sometimes we want to only clear the txt not the graphics.
  139. //To do this we need to draw the text onto our text_page damnit
  140. //easy change the print command to draw on this page
  141. //Integrate a framerender function
  142. //draw everything in it
  143.  
  144. global currentGPAGEDSP=1 //Which Gpage to render
  145. global currentGPAGEDRT=1 //Which Gpage to draw to
  146.  
  147. dim commands$(100); //probably more than this but this goes in pre constants
  148. commands$(1)="BGPUT" //PUT tiles on a bg Layer
  149. commands$(2)="BGOFS" //BGOFFSET
  150. commands$(3)="BGSHOW" //Show a bg layer
  151. commands$(4)="BGHIDE" //Hide a bg layer
  152. commands$(5)="COLOR" //text colors
  153. commands$(6)="GCOLOR" //drawing ink color
  154. commands$(7)="LOCATE" //set the text cursor
  155. commands$(8)="Print" //needs parsing sometimes can accept any $ parameter, may only need parsing if + str$() is present
  156. commands$(9)="INC" //Increment
  157. commands$(10)="DEC" //Decrement
  158. commands$(11)="BGCLR" //accepts parameter or no parameters
  159. commands$(12)="DIM " //requires a parameter with parameters
  160. commands$(13)="CLS" //requires no parameters
  161. commands$(14)="GCLS" // Clears the screen graphics only. may need a seperate graphics screen painted under everything.
  162.  
  163. //Am I really doing this? Ehhhhyeeeep I think so o.o
  164.  
  165. //a list of constant math operands we may need them in case we do math parsing down the road
  166. //Just good to have.
  167. dim operands$(7)
  168. operands$(1)="+"
  169. operands$(2)="-"
  170. operands$(3)="/"
  171. operands$(4)="*"
  172. operands$(5)="="
  173. operands$(6)=">"
  174. operands$(7)="<"
  175.  
  176. //Program stack stuff
  177. dim program_stack$(1)
  178. dim return_stack(1)
  179. global return_stack_size=1
  180. global return_stack_index=0 //This is the current stack index
  181. global last_call=0 //This is the last index in the stack that was called
  182. global label_list_size=1
  183. global pc = 0 //This is the program counter it'll be in charge of stepping our program
  184. global program_stack_size=1 //the program stack size
  185. dim labels$(1)
  186. dim label_pointers(1)
  187.  
  188. //The PC pointer is the most important in program flow control
  189. //Inside of TinySB as it takes care of running one command at a time smoothly.
  190. //To see how it progresses see step.
  191. //A function to read the program in should resize the Program_stack$() to the same amount
  192. //as there are readable string line numbers.
Advertisement
Add Comment
Please, Sign In to add comment