diff --git a/Terminal.md b/Terminal.md new file mode 100644 index 0000000..fc8ee53 --- /dev/null +++ b/Terminal.md @@ -0,0 +1,23 @@ +Lemur has a built-in terminal for debugging. Games can write arbitrary text to it, by writing one byte at a time to address `0x02000030`. This address does nothing on hardware, but writing messages still takes precious CPU time, so be sure not to leave any log lines around in your final game. + + +The terminal is available in the menu under Tools > Terminal. You can also pass the flag `--terminal` to the emulator to open it at startup. + +Below are some utility methods. +```c +volatile unsigned char* const STDOUT = (unsigned char*) 0x02000030; + +int putchar(int ch) { + *STDOUT = ch; + return ch; +} + +int puts(const char *str) { + while (*str != 0) { + *STDOUT = *str; + str++; + } + *STDOUT = '\n'; + return 0; +} +``` \ No newline at end of file