|★ APPLICATIONS ★ DIVERS ★ The alternative bank manager!|Amstrad Action) ★|
DAVID HOLMES helps you get more from the 6128's 64k extra RAM.
A major feature of the CPC 6128 is the extra 64k of RAM. Unfortunately this memory is not easily accessible from BASIC and requires additional software to enable its use. Amstrad supply the Bank Manager program which allows the memory to be used for the storage of screens or string data. The screen handling commands have several limitations:
In addition to these deficiencies the Bank Manager does not allow the storage of machine code programs which can be called in as required. As the extra banks are not cleared when the system is reset, if programs could be stored in this way they would not be lost unless the power supply was switched off. Only the software to retrieve them needs to be loaded again.
The program below sets up an alternative bank management system which attempts to overcome these limitations. (It does not attempt to replace the string storage facilities of Bank Manager.)
Firstly it is necessary to explain how the screen and extra RAM banks on the CPC6128 may be handled. The 128k of memory consists of eight banks of 16k numbered 0-7. In normal use only banks 0-3 are switched in and bank 3 contains the screen memory from &C000 to &FFFF (see fig.l). This will be referred to as the high screen. It is possible to use bank 1 (&4000 to &7FFF) as an alternative screen (referred to as the low screen) and also to write to one area of screen memory while displaying the other. This is an important feature of the system. The appearance of the screen is determined by two factors:
If several screens are to be stored for display it is easier if all are set up with an offset of zero. This avoids the complication of setting different offsets for each screen before displaying it. The Z80 microprocessor can only address 64k of memory at one time, so to allow the use of banks 4-7 some of the existing memory must be exchanged with the bank which is required. This process is called bank switching.
Seeing is believing
The CPC6128 ROM has a routine at &BD5B called KL_BANK_SWITCH which allows one of banks 4-7 to be switched into position 1. This block of memory can Then be manipulated. The price of being able to manipulate the extra banks more freely than with Bank Manager is that only bank 0,the lower 16k of memory up to &3FFF, can be used for BASIC, although potentially 64k of extra machine code and pictorial memory are released. The program sets up a number of RSX's which allow the banks to be moved, displayed and written to. The new commands are as follows:
Figure 1: dotted lines show possible paths of memory flow >>
|GETBANK, n where n is 4-7 corresponding to the bank required.
This command switches BANK n into position 1 (from &4000 to It may then have a screen loaded into it from disk or tape or be written to as described below. It may also have a machine code program loaded into it or assembled into it directly.
|PUTBANK switches out the bank and restores the memory map to normal.
This should be used to store the screen or machine code immediately after the loading or writing operation has been completed.
|VIEWBANK, n displays bank n on the high screen instantly. This should be executed when the high screen is being displayed. To avoid the 'Venetian blind' effect the screen at &C000 is firstly copied down to &4000. The screen base is then switched to &4000. At this stage the visible screen is not affected. Bank n is then switched in to &4000.
At first thought one might expect bank n to be instantly visible, but this does not oocur so simply. Although it is not obvious from the Firmware Manual only hardware banks 1 and 3 are capable of displaying the screen. If an extra bank is switched in when the low screen is being displayed this screen is still visible but disabled, (iputbank will re-enable the low screen in this situation). To display the selected bank the information is first copied up to bank 3. The new screen is then seen instantly by displaying the high screen Bank n is switched out again without being modified. If required tlie original high screen (currently at &4000) may be recovered by switching to the low screen with |scl or by using icopyhigh (see below). The contents of the original low screen are lost.
|COPYSCREEN. n copies the high screen to bank n. This is used if it is wished to store a newly created or updated visible screen. If the scrcen has been called from store by iviewbank the original screen is still in its bank (from where it was copied). The modified screen can be stored in place of it or in another bank by choosing appropriate values of n.
To achieve this, bank n is switched in to &4000. the information in the screen is copied into it and then the bank is switched out.
|SCH displays the screen starting at &C000 |SCL displays the screen starting at &4Q00
These two commands use the ROM routine SCR_SET_BASE at 4BC08 to tell the hardware which block of memory to use for the screen.
|WRH allows writing only to the high screen.
|WRL allows writing only to the low screen. These two commands use the ROM routine SCR_set_position at &BD55. They also set the screen offset to zero for consistency with other screens. This routine does not inform the hardware of the change in screen position but allows printing, drawing etc. to the relevant block of screen memory even if this is not currently visible. When the screen is constructed it can be displayed instantly by executing either |SCH or |SCL as appropriate. These commands cancel the effect of |WRH and |WRL and allow writing to both screens. It is possible to create smooth animation effects by changing one screen while displaying the other.
|WIPE clears the screen to ink 0 and zeros the screen offset. It is important that the screen offset is set to zero before a screen is con
structed (either visibly or invisibly) or displayed using |VIEWBANK. If this is not done the screen image may be disrupted either on display or following any attempts at further manipulation. A CLS command will not zero the screen offset after rolling.
|WIPE ensures that the screen starts at the correct point and should be used if the screen has or may have rolled. A mode command may be used instead of |WIPE but this destroys any windows that may have been set up. If an invisible screen is being constructed for storage in a bank, or for instantaneous display after issuing a |WRL or |WRH command, CLS must be used if the screen is to be cleared.
(|wrh or |wrl have already set the offset to zero). If |wipe is used it informs the hardware of the screen base and displays the wrong screen. This also occurs if a screen being constructed invisibly is rolled. Rolling a visible screen during construction alters the offset and cause the invisible screen to be disrupted if it is then displayed with |SCL or |sch alone.
Provided that the currently invisible screen was set up with a zero offset it can be rescued by displaying it with |WRL : : |SCL or |WRH : |SCH. If |WRH or |WRL are used alone in this situation to write to the invisible screen without displaying it. the offset is set to zero and this screen can be successfully written to.
The visible screen however is being constructed with an unknown offset and attempts to modify or manipulate it lead to unpredictable results when other commands notify the hardware that the offset has been zeroed. These complications make it worth taking care to avoid rolling during screen development! If a rolled visible screen must be cleared to a paper colour other than 0, cls may be used following the |WIPE command, |copyhigh copies the contents of the low screen to the high screen.
To recover a high screen after |viewbank has moved it down to the low screen or to allow storage of a constructed low screen, first use |SCL to make it visible, |copyhigh to move it and |SCH to display the high screen. It is possible to use |COPYHIGH without using |SCL first but this brings back the 'Venetian blind'!
Once in the high position the screen can be modified if required and stored with |COPYSCREEN.
These commands may 'be used to write invisibly to a stored bank as follows:-
10 |GETBANK, n :REM Where n is the bank to be written to
L'alinéa 8 de l'article L122-5 du Code de la propriété intellectuelle explique que « Lorsque l'œuvre a été divulguée, l'auteur ne peut interdire la reproduction d'une œuvre et sa représentation effectuées à des fins de conservation ou destinées à préserver les conditions de sa consultation à des fins de recherche ou détudes privées par des particuliers, dans les locaux de l'établissement et sur des terminaux dédiés par des bibliothèques accessibles au public, par des musées ou par des services d'archives, sous réserve que ceux-ci ne recherchent aucun avantage économique ou commercial ». Pas de problème donc pour nous!
CPCrulez[Content Management System] v8.7-desktop
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.