H4th - Print AT

Programming in Forth
Post Reply
Admin
Site Admin
Posts: 15
Joined: Tue Apr 02, 2019 5:29 pm

H4th - Print AT

Post by Admin » Thu Apr 25, 2019 7:22 pm

These words will print or read a character to/at position X,Y

To print a character A at 10, 15 use 33 10 15 !CAT
To read the character at 10, 15 use 10 15 @CAT the character code is now on the Stack

: !CAT 32 * + FBUF + C! ;
: @CAT 32 * + FBUF + C@ ;


The 0,0 co-ordinate is at the top-left corner and range 0-31, 0-23

The reason that I have used CAT instead of AT is that I plan to write words to print, or read, a string to screen. These will be @SAT and !SAT.

Admin
Site Admin
Posts: 15
Joined: Tue Apr 02, 2019 5:29 pm

Re: H4th - Print AT

Post by Admin » Wed May 01, 2019 6:01 pm

Here's a first attempt at printing a string at any desired position on screen. It can almost certainly be improved.

It is called by " YOUR STRING/MESSAGE HERE" X Y !SAT where X=0-31, Y=0- 23

VARIABLE SRC VARIABLE DST
: !SAT 32 * + FBUF + DST !
64644 @ SRC @ 0 DO SRC @ I +
C@ 32 - DST @ I + C! LOOP ;


If working in HEX 32 would be replaced by 20 and 64644 by FC84,

Post Reply