| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Code FAQ [9 /15 |
'>>> Page 9 of Code FAQ begins here.
DEF SEG = &HFFFF
CALL ABSOLUTE(0)
9) HOW CAN I PUT TEXT ON THE SCREEN IN GRAPHICS MODE WITHOUT
DESTROYING THE BACKGROUND?
The problem with PRINTing text on top of graphics is that
QB blacks out the entire character box for each character
you print. That means that the graphics underneath your
new text are just erased from the screen. Not good, in some
cases. The following routine by Douglas Lusher is a very good
substitute for the PRINT command, as it offers styles for two
different graphics modes. Just "comment-out" the statements
for the mode you don't want to use, and "un-comment" those that
you do want to use. Note: if you use the style for VGA
modes, you must load QB with the /L switch.
[begin]
SUB GPrint (X%, Y%, Text$, Culler%)
'this routine allows printing text at any pixel location
' in the graphics modes without disturbing the background
'by Douglas H. Lusher, 06-08-1996
' 8 x 8 char box, CGA
CharSegment% = &HFFA6: CharOffset% = &HE
CharWid% = 8: CharHgt% = 8
' 8 x 16 char box, VGA
'DIM Register AS RegTypeX
'Register.AX = &H1130
'Register.BX = &H600
'CALL InterruptX(&H10, Register, Register)
'CharSegment% = Register.ES: CharOffset% = Register.BP
'CharWid% = 8: CharHgt% = 16
DEF SEG = CharSegment%
XX% = X%
FOR Char% = 1 TO LEN(Text$)
Ptr% = CharHgt% * ASC(MID$(Text$, Char%, 1)) + CharOffset%
FOR Ln% = 0 TO CharHgt% - 1
BitPattern& = PEEK(Ptr% + Ln%) * 256&
LineFormat% = (BitPattern& - 32768) XOR -32768
LINE (XX%, Y% + Ln%)-STEP(CharWid% - 1, 0), Culler%_
, , LineFormat%
NEXT
XX% = XX% + CharWid%
NEXT
DEF SEG
END SUB
[end]
10) HOW DO I PRINT MY GRAPHICS SCREENS ON A DOT-MATRIX PRINTER?
From David Williams, idea and testing by Mike Ross
The two SUBroutines LCopy11 and LCopy11R both dump whatever monochrome
image is currently on SCREEN 11 to an Epson-type printer. LCopy11 keeps
the orientation "horizontal", so the width (longer dimension) of the
screen is mapped onto the width (shorter dimension) of the paper.
LCopy11R (the "R" stands for "Rotate") turns the image through 90
degrees clockwise, so the left-hand edge of the screen is mapped onto
the top edge of the paper, and the long dimension (width) of the screen
is mapped onto the long dimension (length) of the paper. This rotation
makes the image fit the paper better, especially in the direction of
the width of the paper. At 72 dots per inch, the full 640-pixel width
of the screen will not quite fit onto the 8-inch width of the paper, so
LCopy11 has to leave narrow margins (5% of the width) unprinted at the
two sides. LCopy11R, however, can print the entire screen image.
On the other hand, if other material is LPRINTed onto the same page as
the image, the non-rotating copier keeps everything aligned in the same
direction. With LCopy11R, the LPRINTed text and the image come out at
right angles to each other. So each of the two copiers has both
advantages and disadvantages compared with the other. The user has to
choose the better one for his purpose.
LCopy11R is actually the simpler routine. In screen memory, each byte
represents a set of eight pixels that are aligned horizontally on the
screen, side-by-side. However, the printer has eight pins in the print
head which are aligned vertically, and has to be fed a string of bytes
in each of which the eight bits control these eight pins. By rotating
the image clockwise through 90 degrees, as LCopy11R does, the exact
same bytes as are present in screen memory can be sent to the printer.
All the program has to do is send them in the correct order, scanning
the screen from bottom to top and left to right.
'>>> Page 9 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™.