sxtv
Sxtv is the Sphinx TV driver. It displays 13 lines of 40 characters. It is functionally very similar to the standard tv_text driver from Parallax, but it maintains its screen buffer in cog memory. Once installed, it occupies no hub memory except for a single long.
Programs that just want to use sxtv's functionality should use the sxtv interface object, isxtv. Only programs that need to install the sxtv driver, such as sphinx.bin, should use the sxtv object itself.
Spin interface methods
PUB start(basepin, rv) -- Sphinx.bin calls this to start the driver. The first parameter is the video base pin (this is hard-coded into sphinx.spin at installation). The second parameter is the rendezvous location, defined in Sphinx as $7ffc (but in theory you could use sxtv in your own programs and use any long as the rendezvous).
PUB stop -- stops the driver.
PUB GetBasepin -- returns the video base pin (set by the call to start).
PUB str(stringptr) -- prints the null-terminated string at address stringptr.
PUB dec(value) -- prints value as a decimal number.
PUB hex(value, digits) -- prints value as a hexadecimal number of digits digits.
PUB bin(value, digits) -- prints value as a binary number of digits bits.
PUB out(c) -- prints the character c. $08 is interpreted as backspace, $0d is interpreted as a carriage return.
Implementation notes
Once sxtv is installed by sphinx.bin, it monitors the long at hub address $7ffc (known as the rendezvous, as in a meeting place; this is where sxtv and the rest of the Propeller meet to exchange information). As long as that long is 0, sxtv does nothing. Generally, sxtv waits for a non-0 value, does something with that value, then resets the long to 0 and resumes waiting.
Conversely, a program that wants to send information to sxtv waits for the rendezvous long to become 0, then sets it to a non-0 value.
If the long is a number between 1 and 255, sxtv prints the corresponding character (ASCII plus special Parallax characters) on the screen. Sxtv interprets backspace ($08) and carriage return ($0d) only.
If the long is "D"<<8, sxtv disables its video output. It still updates its internal screen buffer. This is useful for programs such as ed that use their own video drivers.
If the long is "E"<<8, sxtv enables its video output. This is the default state.
If the long is -1, sxtv sets the long to basepin<<8 and does not clear it. In this one situation, the long is used to convey information out from sxtv. Typically sphinx.bin uses this to determine whether sxtv is already running. Ed uses this to retrieve which pins the video hardware uses.
The preceding details are hidden by convenient PUB methods; however, note that communication with sxtv is not limited to Spin programs. Any cog can access the rendezvous location. This means that a PASM program can output to the screen (very handy for debugging).
Sxtv.spn is a heavily modified version of tv.spin by Chip Gracey.