add docs for debug output

This commit is contained in:
2022-05-08 19:47:07 +02:00
parent 8e9bb002bc
commit 599873890a
6 changed files with 44 additions and 27 deletions

2
Cargo.lock generated
View File

@@ -599,7 +599,7 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]] [[package]]
name = "curlywas" name = "curlywas"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/exoticorn/curlywas.git?rev=c22297e#c22297ea82977ac06373d629fb273a795322d788" source = "git+https://github.com/exoticorn/curlywas.git?rev=0a0d90c#0a0d90c8013f1d7856a9b71a19d3d006300f31f9"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ariadne", "ariadne",

View File

@@ -16,7 +16,7 @@ anyhow = "1"
minifb = { version = "0.22", default-features = false, features = ["x11"], optional = true } minifb = { version = "0.22", default-features = false, features = ["x11"], optional = true }
notify = "4" notify = "4"
pico-args = "0.4" pico-args = "0.4"
curlywas = { git = "https://github.com/exoticorn/curlywas.git", rev = "c22297e" } curlywas = { git = "https://github.com/exoticorn/curlywas.git", rev = "0a0d90c" }
wat = "1" wat = "1"
uw8-tool = { path = "uw8-tool" } uw8-tool = { path = "uw8-tool" }
same-file = "1" same-file = "1"

2
platform/Cargo.lock generated
View File

@@ -146,7 +146,7 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
[[package]] [[package]]
name = "curlywas" name = "curlywas"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/exoticorn/curlywas.git?rev=c22297e#c22297ea82977ac06373d629fb273a795322d788" source = "git+https://github.com/exoticorn/curlywas.git?rev=0a0d90c#0a0d90c8013f1d7856a9b71a19d3d006300f31f9"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"ariadne", "ariadne",

View File

@@ -6,7 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
curlywas = { git="https://github.com/exoticorn/curlywas.git", rev="c22297e" } curlywas = { git="https://github.com/exoticorn/curlywas.git", rev="0a0d90c" }
uw8-tool = { path="../uw8-tool" } uw8-tool = { path="../uw8-tool" }
anyhow = "1" anyhow = "1"
lodepng = "3.4" lodepng = "3.4"

View File

@@ -320,8 +320,10 @@ global mut controlCodeLength = 0;
fn printSingleChar(char: i32) { fn printSingleChar(char: i32) {
if char >= 4 & char <= 6 { if char >= 4 & char <= 6 {
outputChannel = char - 4; outputChannel = char - 4;
if !outputChannel {
textCursorX = 0; textCursorX = 0;
textCursorY = 0; textCursorY = 0;
}
return; return;
} }

View File

@@ -226,13 +226,13 @@ Characters 0-31 are control characters and don't print by default. They take the
Avoid the reserved control chars, they are currently NOPs but their behavior can change in later MicroW8 versions. Avoid the reserved control chars, they are currently NOPs but their behavior can change in later MicroW8 versions.
| Code | Parameters | Operation | | Code | Parameters | Operation |
| ----- | ---------- | ------------------------------------ | | ----- | ---------- | ------------------------------------------ |
| 0 | - | Nop | | 0 | - | Nop |
| 1 | char | Print char (including control chars) | | 1 | char | Print char (including control chars) |
| 2-3 | - | Reserved | | 2-3 | - | Reserved |
| 4 | - | Switch to normal mode | | 4 | - | Switch to normal mode, reset cursor to 0,0 |
| 5 | - | Switch to graphics mode | | 5 | - | Switch to graphics mode |
| 6 | - | Reserved | | 6 | - | Switch output to (debug) console |
| 7 | - | Bell / trigger sound channel 0 | | 7 | - | Bell / trigger sound channel 0 |
| 8 | - | Move cursor left | | 8 | - | Move cursor left |
| 9 | - | Move cursor right | | 9 | - | Move cursor right |
@@ -249,6 +249,21 @@ Avoid the reserved control chars, they are currently NOPs but their behavior can
(*) In graphics mode, the x coordinate is doubled when using control char 31 to be able to cover the whole screen with one byte. (*) In graphics mode, the x coordinate is doubled when using control char 31 to be able to cover the whole screen with one byte.
#### Debug output
Control code 6 switches all text output (except codes 4 and 5 to switch output back to the screen) to the console. Where exactly this ends
up (if at all) is an implementation detail of the runtimes. The native dev-runtime writes the debug output to `stdout`, the web runtime to
the debug console using `console.log`. Both implementation buffer the output until they encounter a newline character (10) in the output stream.
There may be future runtimes that ignore the debug output completely.
In CurlyWas, a simple way to log some value might look like this:
```
printChar('\06V: '); // switch to console out, print some prefix
printInt(some_value);
printChar('\n\4'); // newline and switch back to screen
```
### fn printChar(char: i32) ### fn printChar(char: i32)
Prints the character in the lower 8 bits of `char`. If the upper 24 bits are non-zero, right-shifts `char` by 8 bits and loops back to the beginning. Prints the character in the lower 8 bits of `char`. If the upper 24 bits are non-zero, right-shifts `char` by 8 bits and loops back to the beginning.