PCN September 29 1984

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search

You all know the feeling: after hours, days or even weeks spent on a particular problem you suddenly see the answer. Or, on one of those late-night expeditions through the memory map you find some undiscovered feature. Well, don't keep it to yourself - send it here. We pay £5 for every tip and routine printed and £25 for a genuine Megawave.

Dumping To Memory For Amstrad Fans
Here is a very short but useful routine which would be of interest for Amstrad CPC 464 owners.When writing a program using one screen which was quite complicated, I came up with this routine which allows instant dumping of the screen to memory and virtually instantaneous retrieval at a later stage.It takes only 24 bytes of machine code and a few lines of Basic.It stems from the facility which allows you to save the screen on tape:SAVE "filename." B. &C000, &4000

The machine code routine is as follows:

DUMP:		LD BC,&4000 
		LD HL,&C000 
		LD DE,&6B7A 
LDIRRETRETRIEVE:LD BC,&4000
		LD HL,&6B7A
		LD DE,&C000
		LDIR
		RET

---

The similarity between the cassette SAVE shown above and the machine code can be seen. BC is a counter set to the number of points on the screen, i.e. 16384 (&4000).For the DUMP, HL is the first point of the screen (&C000) and DE is the starting location of the area where the screen will be stored (&6B7A) which is 16K below the top of the Basic memory.The command LDIR loads the contents of the location pointed to by HL into the location pointed to by DE. This is automatically repeated 16384 (&4000) times.The process is simply reversed for retrieval of the screen.The Basic loader for the routine is as follows:Line 10 reserves the top 16K of memory for the saved screen and the machine code routine so that they cannot be overwritten by a Basic program.CALL &6B60 or CALL 27500 will now copy the screen to memory and CALL &6B6C or CALL 27500 will retrieve it.Retrieval is instantaneous but as with the cassette command you should set all PEN and INK colours to the values they held when the screen was stored as this is not taken into account if they are changed. The example we used, the picture shifted to the left when it reappeared on the screen.

10 MEMORY &6B5F 
20 FOR N=&6B60 TO &6B77
30 READ X
40 POKE N,X
50 NEXT N
60 DATA 1,0,64,33,0,192,17,122,107,237,176,201
70 DATA 1,0,64,33,122,107,17,0,192,237,176,201

---

Sound Advice on the Amstrad
Here are a few tips I've come across for the Amstrad CPC 464.The play button is disabled when you are neither loading or saving a program from cassette. The command OUT 512.16 will enable the cassette unit and OUT 512,0 will disable it again. These commands could be useful if you wished to have a sound track accompanying your program.Horizontal scrolling can be achieved with OUT 256,I where I is the character position relative to the left of the screen. The text is not lost since it wraps round to the right hand side of the screen. In mode 1, shifts occur by one whole character position while in mode 2 shifts are by 2 character; mode 0 produces a shift or half a character. As it is a hardware scroll, it is very fast.
Try this command for sound effect:
10 ENT -1,5,5,1,10.-5,1,5,1,120 SOUND 1,500,10000,7,0,1


September 29 1984 issue of Personal Computer News