APPLICATIONSPROGRAMMATION ★ Rescue ★

RescueApplications Programmation
★ Ce texte vous est présenté dans sa version originale ★ 
 ★ This text is presented to you in its original version ★ 
 ★ Este texto se presenta en su versión original ★ 
 ★ Dieser Text wird in seiner Originalfassung präsentiert ★ 

Have you ever lost hours of work when your program has crashed? Even the best commercial software contains bugs, and if you have tried your own machine code programming you will, like me, have grown to dread the sudden appearance of the warm-up screen.

Rescue is at hand, however, if you own a CPC6128, or a CPC664/464 with a memory expansion. This program hides in the background of your computer, and keeps it safe in case you crash. If (or when) you crash, Rescue will restore the memory to the exact state it was in when you last saved it.

Type in Program 1, which is a Basic loader. When you run it, any data errors will be pointed out. If there are no errors, it will automatically save the binary program, Rescue, to disk or tape.

To use Rescue, simply load it at any time and then CALL &BF00 whenever you want to save the contents of the memory to the second block of 64k. To rescue the memory contents after a crash, reset the computer with CTRL-SHIFT-ESC, type 'CALL &BF00,1' then ENTER.

When Rescue has been loaded, it will remain in the computer even if you reset it or it crashes, and it will only be lost if you turn the computer off. This means that you do not have to reload Rescue each time your computer crashes or when you reset it with CTRL-SHIFT-ESC.

The program works by saving all the usable memory into the second memory block of 64k, which very few programs use. Obviously, if the program you are using or writing does require the second block of 64k, then you cannot use Rescue. These programs include the better word processors such as TASWORD 128 or rare programs such as MASTERFILE, which run on the CPC6128 but not on the unexpanded CPC664/464.

The second block of memory cannot be addressed directly because the Z80 processor (which is used in all CPCs) can only use 64k at any one time. In order to use any of the second block of memory, some of the original block must be swapped with it so that the total is always 64k. The easiest way of doing this is to swap a bank of 16k of the second block with a 16k bank of the first block.

Swapping memory banks can be done in Basic. The best bank to swap with is the one from &4000 to &7fff. This will not interfere with any Basic programs (unless they are more than 15k long) nor with any machine code programs above &8000. The second block of memory has four banks, and any one of them can be swapped into the first memory block at &4000 with the following short program:

10 bank=1: REM or 2,3 or 4 20 OUT &7F00, 195+bank

The original bank can be restored by:

30 OUT &7F00, 192

This second block of 64k can be used to store data, screens, or, as with this program, the whole contents of the first block of memory. Unlike the first block, it is not cleared when you reset the computer, so information stored there is not destroyed when your computer crashes. The following lines added to the above program will put your name into the second block of memory so that it can then be rescued after you have reset the computer:

24 INPUT "Name:", n$:FOR n = 1 TO LEN (n$):POKE &4000+n, ASC (MID$(n$,n,1)): NEXT
26 OUT $7F00,192

Run this short program, then reset the computer with CTRL-SHIFT-ESC. Run the following program to recover your name:

10 bank=1: REM (or whatever number you used before)
20 OUT &7F00, 195 + bank
30 p= PEEK(&4001+n):IF p31 THEN PRINT CHR$(p);:n = n + 1 :GOTO 30

The machine code listing of Rescue shows how this bank-switching is done in machine code. What Rescue does is to copy each of the four banks of the first block of memory into the corresponding bank in the second block, and then copy them back again. For example, the first step is to place the fourth bank of the second block into memory at &4000, then to copy the contents of the fourth bank of the first block (&C000 to &FFFF) into &4000-&7FFF. This effectively copies the screen (which occupies &C000-&FFFF) into bank four of the second block, so, by studying the listing, you should be able to work out how to save more than one screen and how to call them back.

With a bit of ingenuity, you should also be able to work out how to adapt this program to grab protected programs out of memory and to save them to disk or tape, but I had better not encourage you!

When all the copying and swapping of memory banks has finished, the original bank is restored and the screen mode is set. The only part of the memory which is not copied into the second bank is &BF00-&BFFF, which is where Rescue lies.

Rescue has been placed in the memory at &BF00 because this is not affected when the computer is reset. The area of &BF00 to &BFFF is reserved for use by the stack, but the bottom end of this space is very rarely used. If your program uses so much stack that it overwrites Rescue, then it is likely that it has gone into a continuous loop of CALLing or PUSHing values into the stack. If this happens, CALL &BF00,1 will not restore your crashed program until you have reloaded Rescue.

Now you can hack without a care. If you crash, Rescue is at hand.

Australian Personal Computer

★ PUBLISHER: Australian Personal Computer
★ YEAR: 1988
★ CONFIG: 64K + AMSDOS
★ LANGUAGE:
★ LiCENCE: LISTING
★ AUTHOR: Dave Instone Brewer
 

★ AMSTRAD CPC ★ DOWNLOAD ★

Type-in/Listing:
» Rescue    (Australian  Personal  Computer)    LISTING    ENGLISHDATE: 2018-09-23
DL: 203
TYPE: PDF
SiZE: 131Ko
NOTE: 3 pages/PDFlib v1.6

★ AMSTRAD CPC ★ A voir aussi sur CPCrulez , les sujets suivants pourront vous intéresser...

Lien(s):
» Applications » RSX Sprite (Happy Computer)
» Applications » Neue RSX Left, Right, Down, Up, Overlap , Border , Cls (Markus Adamski/Schneider Aktiv)
» Applications » RSX Text-Basic (CPC Magazin)
» Applications » Interactive Cross-Referencing
» Applications » Golist
» Applications » Comal-80/z80 rev. Amstrad
Je participe au site:
» Pour ce titre nous ne disposons de fichier executable sur CPC (Dump, Saisie du listing) , alors si vous avez ça dans vos cartons ou vous désirez usé vos petit doigts boudinés sur votre clavier faites le nous savoir.
» Vous avez des infos personnel ?
» Vous avez remarqué une erreur dans ce texte ?
» Aidez-nous à améliorer cette page : en nous contactant via le forum ou par email.

CPCrulez[Content Management System] v8.7-desktop/c
Page créée en 378 millisecondes et consultée 960 fois

L'Amstrad CPC est une machine 8 bits à base d'un Z80 à 4MHz. Le premier de la gamme fut le CPC 464 en 1984, équipé d'un lecteur de cassettes intégré il se plaçait en concurrent  du Commodore C64 beaucoup plus compliqué à utiliser et plus cher. Ce fut un réel succès et sorti cette même années le CPC 664 équipé d'un lecteur de disquettes trois pouces intégré. Sa vie fut de courte durée puisqu'en 1985 il fut remplacé par le CPC 6128 qui était plus compact, plus soigné et surtout qui avait 128Ko de RAM au lieu de 64Ko.