Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; PROJECT : TinySBRunTime
- ; EDITED : 9/5/2016
- ; ---------------------------------------------------------------------
- #Include "SaveBitmap"
- //Define the constant colors oldschool style :)
- Dim constant_colors$(18)
- //Define the constant rgb values oldschool style :)
- Dim rgb_colors(18)
- constant_colors$(1)="#AQUA"
- constant_colors$(2)="#BLACK"
- constant_colors$(3)="#BLUE"
- constant_colors$(4)="#CYAN"
- constant_colors$(5)="#FUCHSIA"
- constant_colors$(6)="#GRAY"
- constant_colors$(7)="#GREEN"
- constant_colors$(8)="#LIME"
- constant_colors$(9)="#MAGENTA"
- constant_colors$(10)="#MAROON"
- constant_colors$(11)="#NAVY"
- constant_colors$(12)="#OLIVE"
- constant_colors$(13)="#PURPLE"
- constant_colors$(14)="#RED"
- constant_colors$(15)="#SILVER"
- constant_colors$(16)="#TEAL"
- constant_colors$(17)="#WHITE"
- constant_colors$(18)="#YELLOW"
- rgb_colors(1)=rgb(0, 248, 248)
- rgb_colors(2)=rgb(0, 0, 0)
- rgb_colors(3)=rgb(0, 0, 255)
- rgb_colors(4)=rgb(0, 0, 248)
- rgb_colors(5)=rgb(248, 0, 248)
- rgb_colors(6)=rgb(128, 128, 128)
- rgb_colors(7)=rgb(0, 128, 0)
- rgb_colors(8)=rgb(0, 248, 0)
- rgb_colors(9)=rgb(248, 0, 248)
- rgb_colors(10)=rgb(128, 0, 0)
- rgb_colors(11)=rgb(0, 0, 128)
- rgb_colors(12)=rgb(128, 128, 0)
- rgb_colors(13)=rgb(128, 0, 128)
- rgb_colors(14)=rgb(248, 0, 0)
- rgb_colors(15)=rgb(192, 192, 192)
- rgb_colors(16)=rgb(0, 128, 128)
- rgb_colors(17)=rgb(248, 248, 248)
- rgb_colors(18)=rgb(248, 248, 0)
- //Define the text color indexes as rgb values
- dim constant_Tcolors$(15)
- constant_Tcolors$(1) = "#TBLACK" //1
- constant_Tcolors$(2) = "#TMAROON" //2
- constant_Tcolors$(3) = "#TRED" //3
- constant_Tcolors$(4) = "#TGREEN" //4
- constant_Tcolors$(5) = "#TLIME" //5
- constant_Tcolors$(6) = "#TOLIVE" //6
- constant_Tcolors$(7) = "#TYELLOW" //7
- constant_Tcolors$(8) = "#TNAVY" //8
- constant_Tcolors$(9) = "#TBLUE" //9
- constant_Tcolors$(10) = "#TPURPLE" //10
- constant_Tcolors$(11) = "#TMAGENTA" //11
- constant_Tcolors$(12) = "#TTEAL" //12
- constant_Tcolors$(13) = "#TCYAN" //13
- constant_Tcolors$(14) = "#TGRAY" //14
- constant_Tcolors$(15) = "#TWHITE" //15
- //Set the rgb values in the mirror rgb array
- //We may as well just copy the values by their color names from the rgb_colors array
- dim constant_Tcolors(15)
- constant_Tcolors(1) = rgb_colors(2) //#BLACK
- constant_Tcolors(2) = rgb_colors(10) //#MAROON
- constant_Tcolors(3) = rgb_colors(14) //#RED
- constant_Tcolors(4) = rgb_colors(7) //#GREEN
- constant_Tcolors(5) = rgb_colors(8) //#LIME
- constant_Tcolors(6) = rgb_colors(12) //#OLIVE
- constant_Tcolors(7) = rgb_colors(18) //#YELLOW
- constant_Tcolors(8) = rgb_colors(11) //#NAVY
- constant_Tcolors(9) = rgb_colors(3) //#BLUE
- constant_Tcolors(10) = rgb_colors(13) //#PURPLE
- constant_Tcolors(11) = rgb_colors(9) //#MAGENTA
- constant_Tcolors(12) = rgb_colors(16) //#TEAL
- constant_Tcolors(13) = rgb_colors(4) //#CYAN
- constant_Tcolors(14) = rgb_colors(6) //#GRAY
- constant_Tcolors(15) = rgb_colors(17) //#WHITE
- //Define tile_image constants make them all random color squares
- Dim tiles(1024)
- for t=0 to 1024
- tiles(t)=newfximage(16, 16)
- rendertoimage tiles(t)
- cls rndrgb()
- ink rgb(0,0,0)
- circle 8, 8, 8, 1
- next t
- ink rgb(255, 255, 255)
- global global_textbackground=5
- global global_textforeground=6
- global global_textcursorX=0 //These work I think on 8 by 8
- global global_textcursorY=0
- //Create the color tiles
- dim TXTBG(15)
- for t=1 to 15
- TXTBG(t) = newimage(16, 16)
- rendertoimage TXTBG(t)
- cls constant_Tcolors(t)
- next t
- rendertoscreen
- dim graphics_page(2)
- for t=1 to 2
- graphics_page(t)=newfximage(getscreenwidth(), getscreenheight() )
- imagemaskcolour graphics_page(t),rgb(0,0,0) //Black
- next t
- //Just a BIG note when dealing with text.
- //IF YOU EVER want to draw text to an image, for one reason or another using FX images is unreliable
- //ORRRR Playbasic is just fucked in the head.
- global text_page = newimage(getscreenwidth(), getscreenheight() )
- imagemaskcolour text_page, rgb(0, 0, 0) ; black
- rendertoimage text_page
- Print "HELLO THERE" // This line breaks if the type of image text_page is an FXIMAGE
- //Not only that..
- rendertoscreen
- drawimage text_page, 0, 0, 0
- //drawimage text_page, 0, 0, 0
- cls
- //When using CLS or ACLS sometimes we want to only clear the txt not the graphics.
- //To do this we need to draw the text onto our text_page damnit
- //easy change the print command to draw on this page
- //Integrate a framerender function
- //draw everything in it
- global currentGPAGEDSP=1 //Which Gpage to render
- global currentGPAGEDRT=1 //Which Gpage to draw to
- dim commands$(100); //probably more than this but this goes in pre constants
- commands$(1)="BGPUT" //PUT tiles on a bg Layer
- commands$(2)="BGOFS" //BGOFFSET
- commands$(3)="BGSHOW" //Show a bg layer
- commands$(4)="BGHIDE" //Hide a bg layer
- commands$(5)="COLOR" //text colors
- commands$(6)="GCOLOR" //drawing ink color
- commands$(7)="LOCATE" //set the text cursor
- commands$(8)="Print" //needs parsing sometimes can accept any $ parameter, may only need parsing if + str$() is present
- commands$(9)="INC" //Increment
- commands$(10)="DEC" //Decrement
- commands$(11)="BGCLR" //accepts parameter or no parameters
- commands$(12)="DIM " //requires a parameter with parameters
- commands$(13)="CLS" //requires no parameters
- commands$(14)="GCLS" // Clears the screen graphics only. may need a seperate graphics screen painted under everything.
- //Am I really doing this? Ehhhhyeeeep I think so o.o
- //a list of constant math operands we may need them in case we do math parsing down the road
- //Just good to have.
- dim operands$(7)
- operands$(1)="+"
- operands$(2)="-"
- operands$(3)="/"
- operands$(4)="*"
- operands$(5)="="
- operands$(6)=">"
- operands$(7)="<"
- //Program stack stuff
- dim program_stack$(1)
- dim return_stack(1)
- global return_stack_size=1
- global return_stack_index=0 //This is the current stack index
- global last_call=0 //This is the last index in the stack that was called
- global label_list_size=1
- global pc = 0 //This is the program counter it'll be in charge of stepping our program
- global program_stack_size=1 //the program stack size
- dim labels$(1)
- dim label_pointers(1)
- //The PC pointer is the most important in program flow control
- //Inside of TinySB as it takes care of running one command at a time smoothly.
- //To see how it progresses see step.
- //A function to read the program in should resize the Program_stack$() to the same amount
- //as there are readable string line numbers.
Advertisement
Add Comment
Please, Sign In to add comment