The documentation here is currently a bit out of date. Current documentation is in the Retro Handbook (http://doc.retroforth.org) . I'll try to get this current again in the near future. If you'd like to help with this, please contact Charles Childers. (charles dot childers at gmail dot com). Thank you.
The simulated hardware devices provided by Ngaro are mapped to specific ports. You can make use of the IN, OUT, and WAIT instructions to access devices.
Keyboard
The keyboard is mapped to port 1. Read from this port to see what the most recent keypress is. If none, 0 will be returned.
Example
0 # 0 # out, wait, 1 # in,
Video
The video subsystem provides a character generator. This is mapped to port 2. Set to 1 for single character output. The character generator will take three values off the stack: the x coordinate, the y coordinate, and the character value to display.
Example
100 # 100 # char: H # 1 # 2 # out, wait,
You should also tell Ngaro to redraw the screen after updating it:
Example
0 # 3 # out,
This can bring a significant performance increase when used carefully.
Save the Image
Ngaro also provides a way to save the current memory state back to an image. This is done by setting port 4 to 1.
Example
1 # 4 # out, wait,
WAIT
If you look at each of the examples, you will see a reference to WAIT. This is a special instruction which has the system pause execution until the hardware is finished handling an event. It is not necessary in many cases, but it does simplify things. You should always use it when using the character generator functionality to allow the device time to grab what it needs off the stack.