Personal Computer News


Charting A Course In Amstrad's Memory

 
Published in Personal Computer News #078

Charting A Course In Amstrad's Memory

In order to write a program for the Amstrad CPC464 to get a screen dump you need to know how the screen is memory mapped.

This is very complicated for the modes 0 and 1 because, when the screen is poked, not only are pixels illuminated by the same address poked determines the ink used. They are not separately mapped.

If you are only interested in the 80-column mode this is a little less complicated. The first important address is 49152. Poke this with 255 and a short bar 8 pixels long will appear on the screen top left. Now POKE 49152 with 0 and the bar is extinguished. The eight pixels are configured exactly the same as a line of user-defined graphics and what you get depends on the number from 0 to 255 poked to the address.

Poking the next number, 49153, with 255, does not - as one might expect - produce a second bar immediately below the first. Instead, the line produced is a continuation of the last line towards the right. The numbers 49152 to 51151 denote the to lines of each character position. This is a total of 2000 positions, i.e. 25 lines by 80 columns.

You would expect POKEing 51152 with 255 would produce a line in the second line of the first character, but this is not so. There is, in fact, a gap of 49 before we come to the next line: 51200 is the number you want.

Henceforth, everything is as you might expect. Addresses 51200 to 53199 define the second lines (from the top) in the next 2000 character positions. A jump of 49 - 53248 (or 2048 on the second line of the first character position) - brings us to the third line of the first screen character.

Below is a short program to fill the screen line by line, which includes all the useful starts and ends.

 50 REM
 60 REM program to demonstrate screen memory mapping on Amstrad
 70 REM in 80-column mode
 80 REM
 90 MODE 2:CLS
100 FOR i=49152 TO 51151:POKE i,255:NEXT:REM top lines
200 FOR i=51200 TO 53199:POKE i,255:NEXT:REM second lines
300 FOR i=53248 TO 55247:POKE i,255:NEXT:REM third line
400 FOR i=55296 TO 57295:POKE i,255:NEXT:REM fourth line
500 FOR i=57345 TO 59344:POKE i,255:NEXT:REM fifth line
600 FOR i=59393 TO 61392:POKE i,255:NEXT:REM sixth line
700 FOR i=61441 TO 63440:POKE i,255:NEXT:REM seventh line
800 FOR i=63489 TO 65488:POKE i,255:NEXT:REM eighth line
900 GOTO 900:REM press escape twice to break into loop

David Muir
Bourne End, Buckinghamshire

David Muir