| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Code FAQ [10/15 |
'>>> Page 10 of Code FAQ begins here.
LCopy11, however, has to do some more complex operations in order to
generate a set of "vertical" bytes, to be sent to the printer, from the
"horizontal" ones that are present in screen memory. Essentially, the
image is broken down into a set of squares, each 8x8 pixels. Initially
in each square, there are eight bytes that each represent a *row* of
eight pixels. The program has to generate eight bytes each of which
represents a *column* of eight pixels. The first output byte therefore
consists of the leftmost bits of the eight original bytes. The next
contains the second bits from the left, and so on.
In the program, there is a loop that is executed once for every pixel
in the image, more than a quarter of a million times in total. To
optimize speed, this loop is as simple as I could make it. It uses
concepts that are more familiar in machine language than in BASIC,
treating the variables as shift-registers, shunting the bits left or
right by integer multiplications or divisions by 2, and using the
Boolean operators AND and OR to manipulate individual bits.
Of the two, LCopy11 is certainly the more interesting from a
programming point of view. But which is the more useful is up to the
user.
[begin]
' demo of LCopy routines
DECLARE SUB LCopy11 ()
DECLARE SUB LCopy11R ()
SCREEN 11
' draw demo diagram
CIRCLE (320, 240), 200
LINE (200, 200)-(250, 200)
CIRCLE (420, 200), 20
LINE (320, 220)-(320, 260)
LINE (200, 300)-(320, 350)
LINE (320, 350)-(420, 300)
' copy to printer without rotation
CALL LCopy11
' copy to printer with rotation
CALL LCopy11R
' terminate
SCREEN 0
END
SUB LCopy11
' Copies monochrome SCREEN 11 image to printer, with printed image
' aligned with long axis across the page. Note: To fit on 8-inch
' wide paper, 32-pixel margins on both sides are not printed.
DEFINT A-Y
DEFLNG Z
DIM A(0 TO 7, 4 TO 75) ' columns 0 - 3 and 76 - 79 not printed
F = FREEFILE
OPEN "PRN" FOR BINARY AS F
DEF SEG = &HA000
OUT &H3CE, 4
OUT &H3CF, 0
E$ = CHR$(27) ' ESC character
L$ = E$ + "A" + CHR$(8) ' set printer to 8/72 lpi
PUT F, , L$
B = 0
Z = 4
FOR S = 0 TO 59 ' 60 stripes, each 8 rows deep
N = -1 ' null-stripe flag
FOR R = 0 TO 7 ' read 8 rows into array
FOR C = 4 TO 75
A(R, C) = PEEK(Z)
IF N THEN IF A(R, C) THEN N = 0
Z = Z + 1
NEXT
Z = Z + 8
NEXT
IF NOT N THEN ' not null stripe
'>>> Page 10 of Code FAQ ends here. Continued in next message.
* Brought to you by Greg's Little QBasic Auto-Poster *
--- Maximus 3.01
* Origin: The BandMaster, Vancouver, B.C., Canada (1:153/7715)SEEN-BY: 633/267 270 @PATH: 153/7715 140/1 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.