Category : Forth Source Code
Archive   : SMILY46H.ZIP
Filename : INVERT.SEQ

 
Output of file : INVERT.SEQ contained in archive : SMILY46H.ZIP
\ INVERT.SEQ Invert colors of image in graphics buffer. 2Nov88mds
\ Requires VGA.SEQ and GRAPHSAV.SEQ to be loaded first.

comment:
Usage Sequence:
1) Create a graphics image.
2) Copy it to the graphics buffer with VID>BUF.
(of course the graphics buffer had better be allocated first)
3) Execute INVERT.COLORS, this converts black to white and white to
black in the graphics buffer by toggling each bit of each word in
that buffer. (In color modes, colors will switch, including the
background color. e.g. in VGA320 mode, color 255 becomes color 0
and vice versa.)
4) Copy the graphics buffer back to the screen with BUF>VID.
You may also want to add a KEY DROP, so the system will not
corrupt the image until after you have hit a key, thus try:
RES BUF>VID KEY DROP
all on the same line.

BUF.SEG is now a VALUE, rather than a variable 21Oct89mds
Now BRECALL>BUF and INVERT.GBUF make some of this easier. 2Nov88mds

comment;

ANEW INVERTING

assembler inlineon \ speeds up assembler words

comment:
\ This works, but it is slower than the routine below.
: OLD.INVERT.COLORS
BUF.SEG
BUF.SIZE @ 2/ 0 DO
DUP I @L NOT OVER I !L
2 +LOOP
DROP ;
: IC1 OLD.INVERT.COLORS BUF>VID ;
comment;

CODE INVERT.COLORS
CLEAR_LABELS
MOV CX, BUF.SIZE \ must do before the next line !
\ MOV DS, BUF.SEG \ graphics buffer segment
mov ds, ' buf.seg 3 + #)
XOR BX, BX \ BX=offset 0
SHR CX \ BUF.SIZE/2 = # words to invert
1 $:
MOV AX, 0 [BX] \ move a word into AX
NOT AX \ bitwise invert it
MOV 0 [BX], AX \ store the word back into the
\ graphics buffer
INC BX \ increment the offset
INC BX \ to point to the next word
LOOP 1 $
MOV BX, CS MOV DS, BX \ restore DS
NEXT END-CODE

\ invert screen colors and put image on the screen.

: INVERT.GBUF INVERT.COLORS BUF>VID ;


: BRECALL>BUF BRECALL VID>BUF ;

comment:
BRECALL>BUF
recalls an image from disk to the screen, then copies it into the
buffer for later use by such words as INVERT.GBUF. BRECALL>BUF
needs to be a word, since the sequence of words that make up its
definition won't execute properly when entered by themselves on a
single line.
comment;



assembler inlineoff \ speeds up assembler words
forth



  3 Responses to “Category : Forth Source Code
Archive   : SMILY46H.ZIP
Filename : INVERT.SEQ

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/