Changes

PCN September 29 1984

118 bytes added, 04:08, 2 November 2014
<br />
'''Dumping To Memory For Amstrad Fans'''<br />
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, &4000The 4000 <br /> <br />The machine code routine is as follows:<br />DUMP: <br />LD BC,&4000LD 4000 <br />LD HL,&C000LD C000 <br />LD DE,&6B7ALDIRRETRETRIEVE6B7A <br />LDIRRETRETRIEVE: <br />LD BC,&4000LD 4000 <br />LD HL,&6B7ALD 6B7A <br />LD DE,&C000LDIRRETThe C000 <br />LDIR <br />RET <br /> ---<br /><br />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.
<br />
10 MEMORY &6B5F <br />
423
edits