Advertisement
Guest User

TinySB Main

a guest
Sep 9th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. ; PROJECT : TinySBRunTime
  2. ; AUTHOR : Microsoft
  3. ; CREATED : 5/16/2016
  4. ; EDITED : 9/5/2016
  5. ; ---------------------------------------------------------------------
  6. SETFPS 60
  7.  
  8. dim tlist$(16)
  9. tlist$(1)="IF"
  10. tlist$(2)="AND"
  11. tlist$(3)="FOR"
  12. tlist$(4)="ENDIF"
  13. tlist$(5)="DIM"
  14. tlist$(6)="GOTO"
  15. tlist$(7)="GOSUB"
  16. tlist$(8)="DO"
  17. tlist$(9)="WHILE"
  18. tlist$(10)="INPUT"
  19. tlist$(11)="add"
  20. tlist$(12)="sub"
  21. tlist$(13)="mult"
  22. tlist$(14)="div"
  23. tlist$(15)=" "
  24. tlist$(16)="="
  25.  
  26. dim tokenslist_$(100)
  27. tokenamount=1
  28.  
  29.  
  30.  
  31. input$ = "IF 14/2+1-1==7 Then Print hi"
  32. copyinput$ = input$
  33. dim ttlist$(5)
  34. ttlist$(1)="Then"
  35. ttlist$(2)="IF"
  36. ttlist$(3)="Print"
  37. ttlist$(4)="=="
  38. ttlist$(5)=" "
  39. dim tokens$(20)
  40. tokens$()=buildtokenlistfromstring(input$, ttlist$())
  41.  
  42. state, comparison = evaluate_expression(tokenslist_$() )
  43. if state=false then st$="false"
  44. if state=true then st$="true"
  45. print "result of " +copyinput$ + " is " + st$
  46. print comparison
  47.  
  48. sync
  49. waitkey
  50. waitnokey
  51.  
  52.  
  53.  
  54.  
  55. //A Tiny SB TestLoop
  56.  
  57. for tx=0 to 127
  58. for ty=0 to 127
  59. BGPUT(2, tx, ty, tiles(tx+ty) )
  60. if mod(tx, 8)=<12 and mod(ty, 2)=0 then BGPUT(3, tx, ty, tiles(tx+ty*2) )
  61. next ty
  62. next tx
  63.  
  64. Bg3ofX=0
  65. Bg3ofY=0
  66. Bg2ofX=0
  67. Bg2ofY=0
  68. BGSHOW(3)
  69. BGSHOW(4)
  70. main:
  71. inc Bg3OfY
  72. inc Bg2OfX
  73. BGOFS(2, bg2Ofx, 1)
  74. BGOFS(3, 1, Bg3ofY)
  75.  
  76. locate(5, 5)
  77. color_#("#TRED", "#TGREEN");
  78. print_string("Hi this is a test");
  79. color_#("#TYELLOW", "#TTEAL");
  80. locate(5, 6)
  81. print_string("Another color test!! WOOO!!")
  82. locate(5, 7)
  83. color_#("#TGREEN", "#TMAROON")
  84. print_string("And just to be cool")
  85. locate(5, 8)
  86. color_#("#TNAVY", "#TGRAY")
  87. print_string("Cool right")
  88. print "Global Text Background is " +str$(global_textbackground) + "And Global Text Foreground is " +str$(global_textforeground);
  89.  
  90. frame_render()
  91.  
  92. put("@loop")
  93.  
  94. //This might happen after label parsing..
  95. //put a color command in the stack
  96. put("COLOR #TRED, #TGREEN");
  97.  
  98.  
  99. //put a locate in the stack
  100. put("locate 20,7")
  101.  
  102. //put a print in the stack
  103. put("Print hello")
  104.  
  105. put("COLOR #TTEAL, #TYELLOW")
  106.  
  107. put("locate 20, 9")
  108.  
  109. put("Print this is A+ PLUSSER YEAHHH HOOO ")
  110.  
  111.  
  112. //here we're going to try parsing the first loop
  113. put("goto @loop")
  114.  
  115. //Call the Psub to create the label indexes
  116. find_labels()
  117.  
  118. sync
  119. cls rgb(0,0,0)
  120. goto main
  121.  
  122.  
  123. do
  124.  
  125. if pc>program_stack_size
  126. locate(9,25)
  127. print_string( "END OF PROGRAM at " +str$(pc) )
  128.  
  129. frame_render() //render the frame including bg/sprite etc
  130. sync
  131.  
  132. waitkey
  133. waitnokey
  134. end
  135. Endif
  136.  
  137. frame_render() //render the frame including bg/sprite etc
  138. parse_command(pc)
  139.  
  140. step_() //step the program stack
  141.  
  142.  
  143. sync
  144. cls rgb(0,0,0)
  145. loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement