Ngaro can emulate a number of I/O devices. Retro can detect the virtual hardware being emulated and adjusts the I/O words automatically.
A minimal Ngaro implementation will provide a console for output and keyboard for input. Some implementations provide a graphical console (as a framebuffer), but most only provide a traditional text console. The console device has a built in character generator to handle basic textual output. Additional devices may be provided, but should be treated with care as implementations are not required to provide them.
I/O Ports
The I/O devices are accessed through a set of I/O ports. The first 13 ports (0 - 12) are reserved for common functionality expected to be supported by all implementations. Ports above 12 can be claimed by implementers for custom devices.
Port 0
This is used to determine if Ngaro should enter a wait for hardware event loop. It should be set to 0, then use the wait instruction.
Port 1
This is used to read a value from the keyboard. Wait, then read the key value from port 1.
Port 2
Use the hardware character generator to display a character. This will take data off the stack, so you should make sure there are enough values on the stack before using it.
Port 3
This is used to force video updates. Ngaro implementations may cache output and only update the display periodically. If they do, then they should respond to this by immediately updating the display.
Port 4
This port is used to save the image. Allowing saving of images is not required, but is strongly recommended if the underlying host platform will support it. To save, set port 4 to 1 and wait.
Port 5
This port is a fairly new addition and is used to allow images to query the capabilities of the Ngaro implementation. It is a read/write port, you pass it a given value, wait, then read back from it to obtain the results of your query. The following queries are currently supported on the stable Ngaro implementations:
- -1 Amount of memory being provided
- -2 Address of framebuffer (0 if none)
- -3 Width of framebuffer
- -4 Height of framebuffer
- -5 Data Stack Depth
- -6 Address Stack Depth