The 49 Second Screen Dump
David Newcorn
A machine language routine and a BASIC loader you can append to any graphics program to dump the contents of your screen to an Epson MX-80 printer (with Graftrax) … in only 49 seconds.
If you have an Epson MX-80 printer with Graftrax and an Atari 800 with a beautiful Graphics 8 picture on your screen, then what do you do? Dump it to the printer, of course! How? At first I dumped my pictures to the printer through BASIC by scanning each dot separately with the LOCATE statement. It took about thirty minutes to do one picture. Realizing that this was crazy, I redid the program so it would PEEK into display memory and grab eight pixels (one byte of display memory) at a time instead of only one pixel at a time. This reduced printing time to about four and a half minutes, which is still quite slow. So then I turned to machine language. The routine that follows dumps your Graphics 8 picture to your printer in only 49 seconds! Sure beats tying up your computer for half an hour and waiting around for your picture to be printed.
How It Works
Before I explain how it works, let me refresh your memory on how display memory is organized in Graphics 8. Every eight pixels forms one byte of display memory. So, positions 0,0 through 7,0 would be one byte, and positions 8,0 through 15,0 would be another byte, and so on for 38 more bytes across the screen. The BASIC routine sets up a loop which scans the X axis of display memory, starting with the left byte, and finishing with the 40th byte on the right of the screen (0 to 39 is 40). During each row, control is passed to the machine language subroutine along with the address of the string where the result is to be stored and the base address of the column of display memory to be dumped
The machine language program starts at the bottom of the screen and scans eight bits at a time all the way to the top. After it looks at the current display memory byte, it stores it in the current string address. It then increments the string address and decrements the display memory address by subtracting 40 to move up to the next line. (The display memory is one-dimensional, and the display screen is two-dimensional. That's why it subtracts 40 to move up to the next line. It goes back 40 bytes in memory.) When it finishes at the top of the screen, control is passed back to BASIC. BASIC then prints the string to the printer where each character represents a byte of screen memory. The bit pattern of the character is mapped directly to the printhead. After the string is printed, the current column is incremented in BASIC to pass along to the USeR function for the next go-around. Simple, right? Right. Just append Program 1 to your program which draws the picture, and after it finishes, use a GOTO or GOSUB to this routine. That's all you have to do. Just sit back and enjoy your 49-second picture.
PROGRAM 1. The 49 Second Screen Dump.
500 DIM A$(192) : FOR B = 1 TO 61 : READ N : POKE 1535 + B, N : NEXT B : DM = PEEK(88) + PEEK(89) * 256 : DM = DM + 40 * 191 505 REM POKE IN M/L PROGRAM AND SET UP DISPLAY MEMORY POINTER 510 LPRINT CHR$(27); "A" ; CHR$(8) : FOR X = DM TO DM + 39 515 REM SET LINE SPACING AND MAKE LOOP 520 A$ = CHR$(0) : A$(192) = CHR$(0) : A$(2) = A$ 540 W = USR(1536, X, ADR(A$)) : LPRINT CHR$(27); "K" ; CHR$(192); CHR$(0); A$ 545 REM PASS BOTH VALUES TO M/L PROGRAM, AND PRINT STRING 550 NEXT X 560 DATA 104, 104, 141, 21, 6, 104, 141, 20, 6, 104, 141, 27, 6, 104, 141, 26, 6, 160, 193, 173, 255, 255, 136, 240, 35, 141, 255, 255, 238 570 DATA 26, 6, 240, 21, 173, 20, 6, 56, 233, 40, 141, 20, 6, 144, 4, 24, 76, 19, 6, 206, 21, 6, 76, 19, 6, 238, 27, 6, 76, 33, 6, 96
PROGRAM 2. The 49 Second Screen Dump.
10 ;ATARI 800 SCREEN DUMP UTILITY FOR DUMPING GRAPHICS 8 PICTURES 20 ;TO EPSON MX-80 PRINTERS WITH GRAFTRAX. 30 ;BY DAVID NEWCORN 2/28/82 40 ;ASSEMBLY LANGUAGE LISTING 0100 ADR = $FFFF ;DUMMY ADDRESS(SCREEN MEM ADDR) 0110 STR = $FFF ;DUMMY ADDRESS(STRING ADDR) 0120 * = $600 0130 PLA ;PULL OFF AUX BYTE FROM BASIC 0140 PLA ;PULL HI BYTE OF STRING STORAGE 0150 STA LOA + 2 ;STORE HI BYTE 0160 PLA ;PULL LO BYTE OF STRING STORAGE 0170 STA LOA + 1 ;STORE LO BYTE 0180 PLA ;PULL HI BYTE OF BEGINNING OF SCREEN MEM 0190 STA STO + 2 ;STORE HI BYTE 0200 PLA ;PULL LO BYTE OF SCREEN MEM 0210 STA STO + 1 ;STORE LO BYTE 0220 LDY #193 ;LOAD Y AXIS COUNTER 0230 LOA 0240 LDA ADR ;LOAD SCREEN BYTE 0250 DEY ;DECREMENT COUNTER 0260 BEQ RET ;IF DONE THEN RETURN TO BASIC 0270 STO 0280 STA STR ;STORE SCREEN BYTE IN A$ 0290 INC STO + 1 ;INCREMENT LOW END OF STRING 0300 BEQ BIG1 ;IF LOW END OVERFLOWS, THEN INC HI END 0310 CONT 0320 LDA LOA + 1 ;LORD ACCUM WITH LOW SCREEN ADDRESS 0330 SEC ;SET CRRY BIT FOR SUBTRACT W/O BORROW 0340 SBC #40 ;SUBTRACT 40 (40 BYTES PER SCAN LINE) 0350 SAT LOA + 1 ;STORE RESULT 0360 BCC BIG ;IF UNDERFLOW, DEC HI BYTE OF SCRN MEM 0370 CLC ;CLEAR CARRY 0380 JMP LOA ;LOAD NEXT BYTE 0390 BIG 0400 DEC LOA + 2 ;DECREMENT HI BYTE OF SCREEN MEM 0410 JEP LOA ;LOAD NEXT BYTE 0420 BIG1 0430 INC STO + 2 ;INCREMENT HI BYTE OF STRING STORAGE 0440 JEP CONT ;CONTINUE 0450 RET 0460 RTS ;RETURN TO BASIC
Return to Table of Contents | Previous Section | Next Section