|★ APPLICATIONS ★ DIVERS ★ DOING UP OUR DUMPS ★|
|Screen Dump for Epson (Computing With the Amstrad)||Applications Divers|
ROLAND WADDILOVE updates his screen dump utility
IN the March 1985 Computing with the Amstrad I showed how the screen could be dumped to the printer enabling a hard copy of both text and graphics to be produced. I must admit it is a bit primitive, so I thought it was about time for an update.
The program presented here will produce a large dump - the width of A4 paper and about naif as deep - of a Mode 0 or 1 screen. Each pen is represented by different shades of grey. The Mode 0 dump is in 16 shades and the Mode 1 dump is in four shades.
Unfortunately all printers are different and there's no standard for control codes, so I can guarantee that the dump won't work on some printers. We use Epson FX-80s here in the office and these are about as standard as you can get.
If your printer is Epson compatible there's a good chance of the program working. If it isn't you'll have to substitute different control codes in the assembly listing. Table I shows the codes used.
Program I is a Basic listing with the machine code stored in data statements. If you run this the code is stored above HIM EM which is moved down to &9FFF.
Program II is an assembly listing of the code. If you've got an assembler you can assemble it to a different address if there's a memory clash with any other utilities.
To produce a normal dump of the screen CALL &A000. This is best for graphs and charts, and draws on a white background. Some pictures will look better if drawn on a black background, so CALL & A000,1 for an inverse dump.
How does the dump work? Well it is actually fairly straightforward.
No doubt you are familiar with Basic's SYMBOL command for defining characters to print to the screen - well we can do the same with printers.
Whereas SYMBOL requires eight bytes of data and the character defined is eight pixels wide the printer can accept many bytes of data and the character can be the width of the paper.
If the codes 27,76 are sent to the printer it tells it that the following bytes aren't Ascii codes to print, but are bytes of data instead.
Table I: Printer control codes used
It needs to know how many bytes to expect, so if we are going to send n bytes of data we send n MOD 256 followed by n\256 to the printer. Then we can send the data which is printed in a similar manner to a user-defined character. So if a byte of 65 was subsequently sent we wouldn't see a letter A printed, we would see a pattern of dots corresponding to binary 65 instead, 01000001. By the way, it is actually printed vertically.
Figure 1: The pattern and data for pen 15
At the end of the assembly listing you'll see a block of data. There are 16 rows of six bytes, numbered from 0 to 15. The dump works by scanning each row of pixels across the screen.
If a pixel colour is pen 0 the six bytes of data in row 0 are sent to the printer. If a pixel is pen 1 the data in row 1 is sent. Pen 2 is row 2, pen 3 is row 3 and so on.
So for each pixel on the screen we send six bytes of data which are then interpreted and printed as a binary pattern.
By altering the data you can alter the pattern printed, hence the shade of grey produced for each pen. Figure 1 shows the data and pattern for pen 15, the last 6 bytes of data in the table.
Since there are 160 pixels across the Mode 0 screen there are 160 x 6 or 960 bytes of data sent per scan. Unfortunately we can't tell the printer to expect 960 MOD 256 + 960\256 bytes of data since 960 MOD 256 is 192 and the Amstrad chops off bit 7, sending 64 instead.
Therefore each row of pixels is split in two so that the number of items of data to send in either section MOD 256 is less than 128. This is why you'll see the printer print about 2/3 of the row, pause slightly and then print the rest.
Since only one row of pixels is scanned at a time the paper feed is reduced so that there aren't any gaps left between lines.
A Mode 1 dump is almost identical to a Mode 0 dump, so the routine looks to see what mode it's in and then modifies itself accordingly.
A mode 2 dump is pretty similar, so I'll leave that up to you.