Area: Quik_Bas Msg: #72 Date: 07-23-92 06:46 (Public) From: Steve Gartrell To: All Subject: Graphic Screen Printing
'$DYNAMIC DEFINT A-Z '$INCLUDE: 'qbx.bi' 'OR 'QB.BI' DECLARE SUB LandScape () DECLARE SUB Portrait () DECLARE SUB VidConfig () CONST False% = 0, True% = NOT False% CONST C$ = "Recreated 7/22/92 by Steve Gartrell." DIM SHARED Rows%, Cols%, GrayScale%(1 TO 4, 0 TO 8) DIM SHARED LandDPI%, PortDPI% ' These are the "IBM" standard codes as listed by my ' Tandy 9-pin printer manual ' 75 = 60 DPI density ' 76 = 120 DPI density half speed (better row alignment) ' 89 = 120 DPI density normal speed ' 90 = 240 DPI density LandDPI% = 75 PortDPI% = 76 'Place the colors to print here!! '(Remember, at least one mode only has four colors, which ' are returned by POINT as 0, 1, 2, and 3. The two color ' [B&W] modes only have _1_ color and the background.) GrayScale%(1, 8) = 1 'blue GrayScale%(2, 8) = 2 'green GrayScale%(3, 8) = 4 'red GrayScale%(4, 8) = 14 'yellow 'Construct the dot patterns to emulate "newsphoto" grayscaling FOR cnt% = 0 TO 7 GrayScale%(1, cnt%) = &HFF NEXT GrayScale%(2, 0) = &HAA FOR cnt% = 1 TO 7 GrayScale%(2, cnt%) = NOT (GrayScale%(2, cnt% - 1)) MOD 256 NEXT GrayScale%(3, 0) = &H88 GrayScale%(3, 1) = &H0 GrayScale%(3, 2) = &H22 GrayScale%(3, 3) = &H0 GrayScale%(3, 4) = &H88 GrayScale%(3, 5) = &H0 GrayScale%(3, 6) = &H22 GrayScale%(3, 7) = &H0 GrayScale%(4, 0) = &H0 GrayScale%(4, 1) = &H20 GrayScale%(4, 2) = &H0 GrayScale%(4, 3) = &H0 GrayScale%(4, 4) = &H0 GrayScale%(4, 5) = &H0 GrayScale%(4, 6) = &H2 GrayScale%(4, 7) = &H0 SCREEN 7 VidConfig IF Rows% < 0 OR Cols% < 0 THEN 'bad mode? SCREEN 0 WIDTH 80 END END IF 'Borrowed this random pattern generator from Rich Geldreich!! 'Perverted it to limit it to the four chosen colors!! FOR A = 1 TO 400 RANDOMIZE TIMER IF RND > .05 THEN LINE -(RND * Cols%, RND * Rows%), GrayScale%(CINT(RND * 3) + 1, 8) ELSE LINE -(RND * Cols%, RND * Rows%), GrayScale%(CINT(RND * 3) + 1, 8), BF END IF NEXT 'Portrait LandScape DO: LOOP UNTIL LEN(INKEY$): SCREEN 0: WIDTH 80: END SUB LandScape 'Ordinarily, unremark VidConfig so it's called immediately 'before printing 'VidConfig DIM regs AS RegType intnum% = &H17 one% = FREEFILE OPEN "LPT1:BIN" FOR OUTPUT AS one% '1/9" LF PRINT #one%, CHR$(15); CHR$(27); CHR$(51); CHR$(24); 'CR/LF PRINT #one%, CHR$(13); CHR$(10); pixels% = 0 FOR x% = 0 TO Cols% STEP 8 REDIM ColorArray%(x% TO x% + 7, 0 TO Rows%) FOR PixRow% = 0 TO Rows% FOR PixColumn% = x% TO x% + 7 ColorArray%(PixColumn%, PixRow%) = POINT(PixColumn%, PixRow%) NEXT NEXT FOR Hue% = 1 TO 4 PRINT #one%, CHR$(27); CHR$(LandDPI%); PRINT #one%, CHR$((Rows% + 1) MOD 256); PRINT #one%, CHR$((Rows% + 1) \ 256); FOR y% = Rows% TO 0 STEP -1 cnt% = 7 FOR PixelColumn% = x% TO x% + 7 IF ColorArray%(PixelColumn%, y%) = GrayScale%(Hue%, 8) THEN pixels% = pixels% OR 2 ^ cnt% END IF cnt% = cnt% - 1 NEXT PixelColumn% pixels% = pixels% AND GrayScale%(Hue%, y% MOD 8) regs.ax = pixels% regs.dx = 0 CALL Interrupt(intnum%, regs, regs) pixels% = 0 NEXT y% PRINT #one%, CHR$(13); NEXT Hue% PRINT #one%, CHR$(10); NEXT x% 'back to 1/6" LF PRINT #one%, CHR$(27); CHR$(50); 'select standard font PRINT #one%, CHR$(27); CHR$(73), CHR$(1); 'select 10 CPI PRINT #one%, CHR$(27); CHR$(77); 'select bidirectional printing PRINT #one%, CHR$(27); CHR$(85); CHR$(0); 'form feed PRINT #one%, CHR$(12); CLOSE #one% END SUB REM $STATIC SUB Portrait 'Ordinarily, unremark VidConfig so it's called immediately 'before printing 'VidConfig DIM regs AS RegType intnum% = &H17 one% = FREEFILE OPEN "lpt1:BIN" FOR OUTPUT AS one% 'BIN stops auto CR/LF '1/9" LF PRINT #one%, CHR$(15); CHR$(27); CHR$(51); CHR$(24); 'CR/LF PRINT #one%, CHR$(13); CHR$(10); pixels% = 0 ' FOR y% = 0 TO Rows% - 8 STEP 8 REDIM ColorArray%(y% TO y% + 7, 0 TO Cols%) FOR PixRow% = y% TO y% + 7 FOR PixColumn% = 0 TO Cols% ColorArray%(PixRow%, PixColumn%) = POINT(PixColumn%, PixRow%) NEXT NEXT FOR Hue% = 1 TO 4 PRINT #one%, CHR$(27); CHR$(PortDPI%); PRINT #one%, CHR$((Cols% + 1) MOD 256); PRINT #one%, CHR$((Cols% + 1) \ 256); -end-
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET