Node 312
This node is an interface to block buffer memory. It allows reading of individual words as well as reading and writing of whole blocks. The node also functions as a gate allowing access from Editor to block buffer memory or cursor pointer in node 412.
Source code

pass 00 a ! @ !b ;
write 01 dup or 199 for dup - ! @b ! 1 . + next ;
read 09 dup or 199 for dup ! 1 . + @ !b next ;
nav 11 a io a! @ 2000 dw and over a! if -d-- then ;
cu! 18 n a up a! over ! a! ; 1B
init right a! left b! --l- ; 20
3 d 3 r 0 ether
Definitions
- pass
- Read content from block buffer memory address a and send it LEFT.
- write
- Read 200 words from LEFT and store them in block buffer memory from address zero.
- read
- Read 200 words from block buffer memory starting at address zero and write them to LEFT.
- nav
- Test if node 212 writes to DOWN and if so execute from DOWN.
- cu!
- Send cursor position n to node 412.
- init
- Set registers A and B, and jump to LEFT.
Description
Upon boot up this node starts execution from LEFT port. Therefore, it is controlled by node 311. This node calls word pass (preceded by @p) to read one word from block buffer memory.
Word write is called by node 310 (through a port bridge created temporarily in node 311) when we want to write whole block from SRAM into block buffer. We set up an address counter on stack, starting with zero, and repeatedly send an address (inverted to indicate it is a write operation) and a word from SRAM to block buffer. After each word written the address counter is incremented.
Similarly, word read is called by node 310 when we wish to store block buffer content into SRAM. Again, address counter is set up on stack, addresses are sent to block buffer nodes, and words retrieved are sent back to SRAM.
During vertical blanking period node 311 calls word nav (unless it needs to access block buffer memory itself) to allow node 212 to access block buffer memory or update cursor position in node 412 with word cu!. To this end we check if node 212 attempts to write to DOWN port, and if so we call DOWN with -d--. In order to get back to LEFT execution any code executed in DOWN must end with ; (return) instruction.