6.8 KiB
machine
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
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
types
number (fixed point numbers), symbols (string), cons-pairs (lists)
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
rrrg ggbb xxxx yyyy
triangles
textures
devices
screen
default screen is a single 2 triangle square face with a single dynamic texture that can be drawn on it
keyboard
ASCII/UTF8 encoded values
mouse/joystick
Theoretically a modern controller could be mapped into 3 mouse/joystick devices
A nes controller could be mapped onto 1 mouse/joystick device
x axis -> J1 -> J2 -> Dpad left/right y axis -> J1 -> J2 -> Dpad up/down button 1 -> A -> t1 -> select button 2 -> B -> t2 -> start button 3 -> X -> b2 -> "meta button like controller start" button 4 -> Y -> b2 -> unused
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
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
9p filesystem/network by default.
Have an easy way to network.
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 |