Documentation
Introduction
Bscript is a programming language that compiles to binary. It is designed to be easy to learn and use, and to be a good first language for beginners. It is also designed to be a good language for teaching computer science concepts, such as how computers work, how programming languages work, and how to write compilers.
Why Bscript?
Bscript it supports variables, no more writing registry adresses manually like in Bssembly. There are also quality of life improvements to locations and jumping.
Specs
Regestries: 256
RAM: 4096 Bytes
ROM: Infinite
Screen: 256x256 = 65536 Pixels
Colors: 24 bits
Datatypes
- pointer = <>
- byte = []
- data = ()
- location (16 bit) = {}
Variables
var foo = 34 var bar = 35 var foobar = 0 foobar = foo + bar out(foobar); -> 69
Functions
var foo = 0 inc(foo) out(foo); -> 1
Jumping and locations
var index = 0 loc:start inc(index) lth(index, 10, to:start) out(index); -> 10
RAM manipulation
var foo = 0 put16(foo, 100u16) inc(foo) ret16(100u16, foo) out(foo); -> 0
16bit locations
Two 8bit registers represented by a single variable.
var foo:u16 = 256u16 var bar:u16 = 1024 var baz = 0 put16(69, foo) ret16(256u16, baz) out(baz); -> 69 out16(bar); -> 1024
Playing sound
Use 5 different waves to make noises.
snd(0, 1, 2, 10);square snd(1, 1, 2, 10);sawtooth snd(2, 1, 2, 10);triangle snd(3, 1, 2, 10);noise snd(4, 1, 2, 10);sine
Instructions
Instructions are the building blocks of Bscript and Bssembly. They are the commands that the computer executes. There are 59 instructions, each with a unique number. The instructions are listed below.
- EXT - exit
- SET - set <target> [byte]
- CLR - clear <target>
- CPY - copy <source> <target>
- ADD - add <source1> <source2> <target>
- SUB - subtract <source1> <source2> <target>
- MLT - multiply <source1> <source2> <target>
- INC - increment <source/target>
- DEC - decrement <source/target>
- JMP - jump TO:"location name"
- BMP - bitmap [width] [height] (image)
- TEX16 - texture <posx> <posy> <width> <height> {<location>}
- CLB - clear bitmap
- OUT - output <source>
- INP - input <target>
- DLY - delay <time (10x ms)>
- IPT16 - import ROM data {<source>} {<target>} {<length>}
- XPT16 - export RAM data {<source>} {<target>} {<length>}
- PUT16 - put <source> {<location>}
- RET16 - retrieve {<location>} <target>
- LOC - jump point LOC:"location name"
- EQL - equals <source1> <source2> TO:"location name"
- LTH - less than <source1> <source2> TO:"location name"
- GTH - greater than <source1> <source2> TO:"location name"
- RGB - color <red> <green> <blue>
- COL - color <source>
- LFT - line <fromx> <fromy> <tox> <toy>
- PNT - point <posx> <posy>
- BTN - is key down <keycode> <target>
- GPBTN - gamepad button value <gamepad> <buttonnr> <target>
- GPJOY - gamepad joystick axis value <gamepad> <axis> <target>
- RND - random number <min> <max> <target>
- BSL - shift left <source> <target>
- BSR - shift right <source> <target>
- TXT - draw char <posx> <posy> <ascii-char>
- TXT16 - draw string <posx> <posy> {<location>} <length>
- DLT - delta time <target>
- SYN - sync with screen refresh
- PSH - save cursor position <offset>
- POP - load cursor position
- NEQ - not equal <source1> <source2> TO:"location name"
- SIN - sinus <angle> <y>
- COS - cosinus <angle> <x>
- MPOS - mouse position <x> <y>
- MBTN - mouse position <button> <pressed>
- SND - play a sound <wave> <tone> <octave> <duration>*10ms
- SET16 - 3
- CLR16 - 1
- CPY16 - 2
- INC16 - 1
- DEC16 - 1
- ADD16 - 3
- SUB16 - 3
- MLT16 - 3
- BSL16 - 2
- BSR16 - 2
- EQL16 - 3
- NEQ16 - 3
- LTH16 - 3
- GTH16 - 3
- INP16 - 1
- OUT16 - 1
- PXL - read a pixel value <x> <y> <red> <green> <blue>