etherforth_logo

Node 513

In this node we generate bitmap slices from characters for each scan line.

Source code

usb node 613 node 514 node 512 node 513
513 text list
shift 00 n-n a for 2* unext 2/ 1F000 and ;
slice 04 lh-xn -if a -10 . + -if drop dup or ;
then a! then a 15 or if 10 and .
if drop drop a -18 . + a! dup shift ; then drop shift ;
then drop shift over 2/ 2/ 2/ 7000 and or ;
in 1A -n right b! @b ;
out 1C n up b! !b ;
spaces 1E begin dup out next drop ;
chars 21 n-n 49 for dup a! in -if spaces ;
then left b! dup push 3F and !b @b @b slice
tag pop 2/ 2/ 2/ 2/ 2/ 2/ 2/ or out drop next in drop ;
row 34 9 for chars chars 5 . + next ;
go 3C 0 row go ; 3F

init go ; 40

1 d 4 r 0 ether

Definitions

shift
Shift n by A bits left, keep one slice in bits 16-11 by masking other bits off.
slice
Start with two slice words on stack (lh). It returns slice n in bits 16-11. If descender bit set (in h), generate zero for first two slices (evaluates slice index in A). If index is equal to 15 (15 or) we shift h 15 bits left, then l 3 bits right, mask all other bits in l and combine the two words into a slice. If index >15 (10 or) drop h and shift l left by A-18 bits. If index <15 then shift h by A bits left. In each case we leave a word with the selected slice in bits T16-T11, and current slice index in S.
in
Get n from RIGHT using B.
out
Send n to UP using B.
spaces
Use a loop index already on return stack from chars. Send out number of spaces till the end of line. Space is sent as a negative number.
chars
Parameter n is a slice index. Display slices of 50 characters in a row. Place index in A, fetch from RIGHT, if negative (end-of-line format mark) display spaces, else keep duplicate of character fetched from RIGHT on return stack, mask off color bits so we get character code, use it as an address to get two words from node 514 and 515 and call slices. Then we pop the character from return stack, shift color to bits 3-0, combine with a slice and send out.
row
Run ten double scan lines, in each line call chars and incremnt slice index by 5 (so it has values: 00 05 0A 0F 14 19 1E).
go
Reset slice index, jump to row, then repeat.
init
Jump to go.

Description

This node receives words encoding color and character for each row, twenty times the same row, so that we can generate 20 scan lines. In order to know what slice (bit pattern displayed in one scan line) of a character bitmap to display, we keep an index on stack, and increment it by 5 for each double scan line displayed.

For each character we fetch two words from nodes 514 and 515, which contain whole character bitmap (5×7 bits plus one descender bit gives 36 bits, i.e. two 18-bit words). From these 36 bits we extract appropriate slice (5×1 bits) in word slice with help of the index.

Each bitmap slice is combined with color bits in one word, which is sent to RGB signal generators. Format of the word sent out is following:

0bbbbb00000000tttt

bbbbb
Bits of the current bitmap slice. For each bit set the tag color is displayed, otherwise the pixel is black.
tttt
Tag color used for this bitmap slice.