diff --git a/README.org b/README.org index 396df08..061ba3a 100644 --- a/README.org +++ b/README.org @@ -92,5 +92,5 @@ ZRE bridges retro-inspired creativity with modern portability for: - Game jams (rapid prototyping + 3D engine). - Indie games (5th/6th-gen aesthetics). - Permacomputing (low-resource, sustainable code). -- Education (simple VM/language design), a language which scales to the developers level. +- Education (simple VM/language design). diff --git a/docs/MACHINE.org b/docs/MACHINE.org index 5dc8fae..4e02d75 100644 --- a/docs/MACHINE.org +++ b/docs/MACHINE.org @@ -1,39 +1,26 @@ * machine :PROPERTIES: -:CUSTOM_ID: machine +:CUSTOM-ID: machine :END: -I like uxn's idea of it being 16 bit because its 0 to 65535 or -32768 to -32767 which fits in your head nicely. ** memory :PROPERTIES: -:CUSTOM_ID: memory +:CUSTOM-ID: memory :END: -ideas for memory (ram) is going to be a giant hashmap of some kind, or -maybe like picolisp? -picolisp has 64 bit machine words, a cell is 2 words +one large uint32 array ** types :PROPERTIES: -:CUSTOM_ID: types +:CUSTOM-ID: types :END: -number (fixed point numbers), symbols (string), cons-pairs (lists) +real (fixed point numbers)| Q16.16 number +int (integer) i32 +nat (unsigned integer) u32 -0000 0000 0000 0000 0000 0000 0000 0000 - -tfff xxxx yyyy zzzz - -0rgb xxxx yyyy zzzz - -mmrr rrrg ggb0 0000 {xxxx xxxx yyyy yyyy zzzz zzzz} {xxxx xxxx yyyy yyyy -zzzz zzzz} vz{xxxx xxxx yyyy yyyy zzzz zzzz} - -rrrx gggy bbbz xxxx yyyy zzzz - -**** 3-3-2 bit rgb + 3-3-2 bit rgb :PROPERTIES: -:CUSTOM_ID: bit-rgb +:CUSTOM-ID: bit-rgb :END: rrrg ggbb xxxx yyyy @@ -41,33 +28,33 @@ triangles textures -** devices + devices :PROPERTIES: -:CUSTOM_ID: devices +:CUSTOM-ID: devices :END: -*** screen +** screen :PROPERTIES: -:CUSTOM_ID: screen +:CUSTOM-ID: screen :END: default screen is a single 2 triangle square face with a single dynamic texture that can be drawn on it -*** keyboard +** keyboard :PROPERTIES: -:CUSTOM_ID: keyboard +:CUSTOM-ID: keyboard :END: -ASCII/UTF8 encoded values +ASCIIUTF8 encoded values -*** mouse/joystick +** mousejoystick :PROPERTIES: -:CUSTOM_ID: mousejoystick +:CUSTOM-ID: mousejoystick :END: -Theoretically a modern controller could be mapped into 3 mouse/joystick +Theoretically a modern controller could be mapped into 3 mousejoystick devices -A nes controller could be mapped onto 1 mouse/joystick device +A nes controller could be mapped onto 1 mousejoystick device -x axis -> J1 -> J2 -> Dpad left/right y axis -> J1 -> J2 -> Dpad up/down +x axis -> J1 -> J2 -> Dpad leftright y axis -> J1 -> J2 -> Dpad updown button 1 -> A -> t1 -> select button 2 -> B -> t2 -> start button 3 -> X -> b2 -> "meta button like controller start" button 4 -> Y -> b2 -> unused @@ -77,52 +64,65 @@ xxxx yyyy 1234 x (4 bits) y (4 bits) 1 is button 1 pressed? 2 is button 2 pressed? 3 is button 3 pressed? 4 is button 4 pressed? -*** sound/music +** soundmusic :PROPERTIES: -:CUSTOM_ID: soundmusic +:CUSTOM-ID: soundmusic :END: -This one is going to be the hardest most likely, but its prolly going to +This one is going to be the hardest most likely| but its prolly going to be something like the backend dac for ORCA. -*** network/filesystem +** networkfilesystem :PROPERTIES: -:CUSTOM_ID: networkfilesystem +:CUSTOM-ID: networkfilesystem :END: -9p filesystem/network by default. +9p filesystemnetwork by default. Have an easy way to network. -*** opcodes +** opcodes -|---------------------------------------------------------------------------------------+------------------------------------------------------------------| -| opcode | description | -|---------------------------------------------------------------------------------------+------------------------------------------------------------------| -| nil | noop/nil/eos | -| *bbbb call | calls the address as a function | -| b syscall | calls a system call based on the opcode | -| bbbb pushReal - | allocates Q16.16 bits on the stack | -| - popReal bbbb | deallocates Q16.16 bits from the stack | -| b *bbbb storeByte - | stores 8 bits from the stack to the address | -| bbbb *bbbb storeReal - | stores 64 bits from the stack to the address | -| *bbbb loadByte b | loads 8 bits from the address to the stack | -| *bbbb loadReal bbbb | loads 64 bits from the address to the stack | -| bbbb bbbb addReal bbbb | adds 64 bits from the stack | -| bbbb bbbb subReal bbbb | subtracts 64 bits from the stack | -| bbbb bbbb mulReal bbbb | multiplies 64 bits from the stack | -| bbbb bbbb divReal bbbb | divides 64 bits from the stack | -| bbbb [bbbb bbbb bbbb] scalevec3 [bbbb bbbb bbbb] | scales the vec3 by the f64 on the stack | -| [bbbb bbbb bbbb] [bbbb bbbb bbbb] addvec3 [bbbb bbbb bbbb] | adds 2 vec3 together from the stack | -| [bbbb bbbb bbbb] [bbbb bbbb bbbb] subvec3 [bbbb bbbb bbbb] | subtracts 2 vec3 together from the stack | -| [bbbb bbbb bbbb] [bbbb bbbb bbbb] mulvec3 [bbbb bbbb bbbb] | multiplies 2 vec3 together from the stack | -| [bbbb bbbb bbbb] [bbbb bbbb bbbb] dotvec3 bbbb | dot product of 2 vec3 together from the stack | -| [bbbb bbbb bbbb] [bbbb bbbb bbbb] crossvec3 [bbbb bbbb bbbb] | cross product of 2 vec3 together from the stack | -| [bbbb bbbb bbbb] normvec3 [bbbb bbbb bbbb] | normalizes a vec3 | -| [[bbbb bbbb bbbb bbbb]*4] invmat4 [[bbbb bbbb bbbb bbbb]*4] | inverts a mat4 from the stack | -| [[bbbb bbbb bbbb bbbb]*4] [[bbbb bbbb bbbb bbbb]*4] mulmat4 [[bbbb bbbb bbbb bbbb]*4] | multiplies 2 mat4's from the stack | -| *triangle-array-ptr nnnn drawtriangles - | drawn 'n' many triangles using a array of vertices and its color | -| *str1 *str2 streq b | checks 2 strings returns a bool of if they are the same | -| *str1 *str2 strcat *str3 | concatinates 2 strings and returns the address of the new string | -| *str strlen bbbb | pushes the length of the string onto the stack | -| | | -| | | -|---------------------------------------------------------------------------------------+------------------------------------------------------------------| +|----------------+------------------------------------------------------| +| opcode | description | +|----------------+------------------------------------------------------| +| HALT | terminate execution | +| ADD-INT | dest = src1 + src2 | +| SUB-INT | dest = src1 - src2 | +| MUL-INT | dest = src1 src2 | +| DIV-INT | dest = src1 src2 | +| JEQ-INT | jump to address dest if src1 as int == src2 as int | +| JGT-INT | jump to address dest if src1 as int > src2 as int | +| JLT-INT | jump to address dest if src1 as int < src2 as int | +| JLE-INT | jump to address dest if src1 as int <= src2 as int | +| JGE-INT | jump to address dest if src1 as int >= src2 as int | +| INT-TO-REAL | dest = src1 as f32 | +| ADD-UINT | dest = src1 + src2 | +| SUB-UINT | dest = src1 - src2 | +| MUL-UINT | dest = src1 src2 | +| DIV-UINT | dest = src1 src2 | +| JEQ-UINT | jump to address dest if src1 as int == src2 as uint | +| JGT-UINT | jump to address dest if src1 as int > src2 as uint | +| JLT-UINT | jump to address dest if src1 as int < src2 as uint | +| JLE-UINT | jump to address dest if src1 as int <= src2 as uint | +| JGE-UINT | jump to address dest if src1 as int >= src2 as uint | +| UINT-TO-REAL | dest = src1 as f32 | +| ADD-REAL | dest = src1 + src2 | +| SUB-REAL | dest = src1 - src2 | +| MUL-REAL | dest = src1 src2 | +| DIV-REAL | dest = src1 src2 | +| JEQ-REAL | jump to address dest if src1 as real == src2 as real | +| JGE-REAL | jump to address dest if src1 as real >= src2 as real | +| JGT-REAL | jump to address dest if src1 as real > src2 as real | +| JLT-REAL | jump to address dest if src1 as real < src2 as real | +| JLE-REAL | jump to address dest if src1 as real <= src2 as real | +| REAL-TO-INT | dest = src1 as int | +| REAL-TO-UINT | dest = src1 as int | +| MOV | dest = src1 | +| JMP | jump to address src1 unconditionally | +| INT-TO-STRING | dest = src1 as str | +| UINT-TO-STRING | dest = src1 as str | +| REAL-TO-STRING | dest = src1 as str | +| READ-STRING | dest = read as str | +| PRINT-STRING | write src1 to stdout | +| CMP-STRING | dest = src1 as str == src2 as str | +| | | +|----------------+------------------------------------------------------| diff --git a/docs/project-syntax-example/src/client.ztl b/docs/project-syntax-example/src/client.zre similarity index 74% rename from docs/project-syntax-example/src/client.ztl rename to docs/project-syntax-example/src/client.zre index e77be3f..30d9fb5 100644 --- a/docs/project-syntax-example/src/client.ztl +++ b/docs/project-syntax-example/src/client.zre @@ -1,13 +1,13 @@ use "common.ztl"; fn main(argc real, argv str[]) { - let screen_width = 800; - let screen_height = 450; + let screen_width = 800; /* implied uint32 */ + let screen_height = 450; /* implied uint32 */ - let username = argv[0]; - let password = argv[1]; + let username = argv[0]; /* implied str */ + let password = argv[1]; /* implied str */ - let me = Player(username, Vec3(0.0, 1.0, 2.0), PURPLE); + let me = Player(username, Vec3(0.0, 1.0, 2.0), PURPLE); /* implied Player struct */ let running = true; while (running) { diff --git a/docs/project-syntax-example/src/common.ztl b/docs/project-syntax-example/src/common.zre similarity index 91% rename from docs/project-syntax-example/src/common.ztl rename to docs/project-syntax-example/src/common.zre index f8d288c..f133264 100644 --- a/docs/project-syntax-example/src/common.ztl +++ b/docs/project-syntax-example/src/common.zre @@ -1,3 +1,8 @@ +/** + * Note that these look like classes but act like structs + * the methods actually have a implied struct as their first argument + */ + /** * Camera . */ diff --git a/docs/project-syntax-example/src/server.ztl b/docs/project-syntax-example/src/server.zre similarity index 100% rename from docs/project-syntax-example/src/server.ztl rename to docs/project-syntax-example/src/server.zre