Forum
clear ink from attr - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16)
+---- Thread: clear ink from attr (/showthread.php?tid=311)



clear ink from attr - slenkar - 02-22-2011

How do you use print to remove all ink from an attribute (8*8 square)

the opposite is 'print /::' to draw a block but i want to clear all ink away and leave the paper


Re: clear ink from attr - LCD - 02-22-2011

Just " " (space) or "/ " (with two spaces). But if you want only to clear Attr, use and PAPER 8, BRIGHT 8, maybe FLASH 8 and set INK to any colour you like. If you don't want to clear pixels use OVER 1.


Re: clear ink from attr - boriel - 02-22-2011

LCD Wrote:Just " " (space) or "/ " (with two spaces). But if you want only to clear Attr, use and PAPER 8, BRIGHT 8, maybe FLASH 8 and set INK to any colour you like. If you don't want to clear pixels use OVER 1.
There's also a SET_ATTR that, If recall correctly, also do that (e.g. SETATTR(x, y, attr)), but better try LCD's recommendation first. Libraries are ALPHA :mrgreen:


Re: clear ink from attr - LCD - 02-22-2011

SETATTR only for paper needs BAND function to work. I myself use pokes, especialy for the whole screen (768 bytes), but SATATTR is fast too. You will need ATTR to read the Attribute at given coordinate, then binary AND it with a mask (BIN 11000111) to get a value without paper. Then you can use a new paper if it is different than zero by binary OR-ing (BOR) it with Paper shifted to left 3 times ( newpaper<<3 ).


Re: clear ink from attr - boriel - 02-22-2011

LCD Wrote:SETATTR only for paper needs BAND function to work. I myself use pokes, especialy for the whole screen (768 bytes), but SATATTR is fast too. You will need ATTR to read the Attribute at given coordinate, then binary AND it with a mask (BIN 11000111) to get a value without paper. Then you can use a new paper if it is different than zero by binary OR-ing (BOR) it with Paper shifted to left 3 times ( newpaper<<3 ).
BAND is already implemented as an operator! :!: It should be working since 1.2.6 (to say the least).
So
Code:
DIM a as Ubyte = 5
PRINT a bAND 1
Should work and PRINT just 1


Re: clear ink from attr - slenkar - 02-22-2011

Code:
ink 0
DIM a as Ubyte = 5
PRINT at selecty,selectx;a bAND 1

this just prints black ones to the screen

Code:
ink0
PRINT at selecty,selectx;" "

this works Big Grin


Re: clear ink from attr - boriel - 02-22-2011

slenkar Wrote:
Code:
ink 0
DIM a as Ubyte = 5
PRINT at selecty,selectx;a bAND 1

this just prints black ones to the screen
And that's ok.
bAND is an OPERATOR. It calculates (a AND 1). The difference with normal AND is that, AND uses boolean logic (0 = False, any other value = True).
bAND is for BINARY (or BITWISE) operations (hence the 'b' Prefix). You have bAND, bOR, bXOR and bNOT.

For what you want, do as LCD suggested:
Code:
PRINT AT y, x; OVER 1; PAPER 8; INK value; " "
This should do the trick.