Node 512

This node has several functions; it generates blinking cursor at the current cursor position, it displays a blue comma symbol at the end of a row, and it combines color of the current tag with each symbol to be displayed.

Source code

usb node 513 node 412 node 512
512 list
blink 00 ctn-c'tf 2* push push 1 + pop over pop and ;
!tag 04 n @p drop !p ;
char 05 cn-c 1 . + dup 40 and if 2* blink
if swap then drop !b ; then !b drop ;
tag 0D t -if 4AA b, !b !b @ tag ;
then dup 40 and if 2* blink if drop 5B1 cur then then
bl !b F and 2* 2* 2* 2* 2* 2* - 2* - !tag
begin @ 30 over over and or while drop char end
then drop tag ; 25

init right b! down a! @ tag ; 2A

1 d 3 r 0 ether


Cursor-on bit (40) is shifted twice to get 256 as a limit for blink counter. Then we push this limit n and tag t on return stack, increment counter c, pop tag back and leave a flag f on top. If true, we will display a cursor, else a space. Limit value means that cursor is on and off for 256 frames each.
Store n into char as current color. This word behaves like a variable, storing the value as the second word in char, i.e. instead of the literal 1.
Executing this word we first get the current color value stored by word !tag and add it to the character n. Then we check cursor position. If it coincides, we alternate the character with a space at the frequency given by word blink. Whatever we end up with, character or space, it is sent to RIGHT and we return.
First check if tag t is end-of-line format mark (negative value). If so, print blue comma (4AA !b) then send end-of-line format mark, fetch the next tag and return. If not end-of-line, test cursor bit (40) and if set call blink. We return with tag t and a flag f on stack. If the flag is set, we drop it and put cursor glyph (5B1) on stack, else we have zero here, which is displayed as a space bl (either because the tag is not at cursor position or cursor is in the off period). We send the space or cursor glyph to RIGHT.

Then we get color from the tag by masking all but lower four bits off, shift the color bits left by 7 bits, set bit zero high, and store it as first word in char using !tag. Thus, each char code will be 1+ higher (so we can display a space as zero character now). Then we start a loop reading symbols and while not a tag we call char. When we receive a tag we jump to tag.

Set registers A and B, prefetch first tag from DOWN and jump to tag. There is no initial value for blinking cursor counter so whatever value is under the first tag is used as is.


This node receives a stream of symbols from node 412, which may include tags, characters or end-of-line format mark. In case of end-of-line it displays a space followed by a dark blue comma character. The space is important as it is the position where we display cursor glyph when at the end of line.

If we receive a tag, which is expected at the beginning of each frame, we extract color bits, and keep them as a literal in word char. This color is used for all characters that follow until we get another tag.

This node also displays cursor glyph at its current position. The glyph is blinking (alternating with a space) at the frequency of 2.3 Hz (it follows from 256 frames on and 256 frames off, at 60 Hz screen refresh rate, and 20 scan lines per row). Code in word char allows cursor at character position as well, in which case we would see blinking character. It is a remnant from original Chuck's code, where it was possible to modify individual characters of a word using a keypad. If the cursor location had coincided with a tag, we would have seen the cursor glyph blinking at that position. If it had coincided with a character, the character had been blinking.

With the use of a keyboard the editor does not allow to modify individual characters of a word once entered. Thus, normally we should not be able to have cursor at any other position than at a tag. However, due to a bug, which I can't remove due to RAM limitations this may occasionally happen. For that reason I left the code here so we can see where the cursor is even in such a situation.

Output of this node is a word combining the current tag color, cursor indicator bit, and character code incremented by one. The increment is useful as from now on we can use character code zero as a space. Format of the word sent to node 513 is following:


Color bits from the current tag.
Cursor indicator bit. If set, cursor is displayed the this symbol position.
Character bits incremented by one. Zero means a space.