Difference between revisions of "Amstrad Whole Memory Guide - The machine pack"

From CPCWiki - THE Amstrad CPC encyclopedia!
Jump to: navigation, search
(Main Reset: subsection)
(Tags: Mobile edit, Mobile web edit)
(MC Boot Program: BD13,05DC: OCR page 20)
(Tags: Mobile edit, Mobile web edit)
Line 10: Line 10:
  
 
The CRT Controller is then set up. There are two alternative sets of values for this, one for 50 Hz frame scan and the other for 60 Hz. The set to be used is determined by reading port B, bit 4. If this bit is true, 50 Hz values are used, while the 60 Hz values are used if the bit is false, this being determined by the presence of Link 4 on the main printed circuit board.
 
The CRT Controller is then set up. There are two alternative sets of values for this, one for 50 Hz frame scan and the other for 60 Hz. The set to be used is determined by reading port B, bit 4. If this bit is true, 50 Hz values are used, while the 60 Hz values are used if the bit is false, this being determined by the presence of Link 4 on the main printed circuit board.
 +
 +
The tables are read backwards, which can be a little confusing at first, and the outputs alternate between BCXX, which selects the register to be set, and BDXX, which performs the actual setting.
 +
 +
Then MC START PROGRAM is entered at 060E with DE=065C and HL=0000. The contents of DE point to the display routine for the main title, which is called at an appropriate point. The zero value in HL means that ROM 0 will be entered at C006. This will normally invoke the BASIC interpreter, unless an external ROM responds to 0. C006 is the standard upper ROM entry point.
 +
 +
Before discussing MC START PROGRAM, it will be convenient to look at a program which calls it, having first loaded the necessary data:
 +
 +
== MC Boot Program: BD13,05DC ==
 +
 +
On entry to this function, HL must hold the address of a loading routine, which must be designed to return with carry set and the program start address in HL if the load is successful, or with carry clear if the load fails.
 +
 +
The stack is reset by SP=C000, this being the normal stack position, and sound RESET is called to silence the Sound Generator. Interrupt is disabled, and &FF is output to port F8FF, requiring that all external peripherals devices should be reset.
 +
 +
KL CHOKE OFF is called to clear the B100-B1BF area to zeroes, though the previous contents of (B1A9/B) are first saved.  (B1A9/A) holds the last-used foreground ROM entry address, which is copied to DE, while (B1AB) holds the last-used foreground ROM number, which is copied to B. (Note that the number of the ROM in current use is held in (B1A8), which is not preserved here.)  If (B1AB) holds &FF the routine returns with C, D and E all zeroed.
 +
 +
Back in the main BOOT routine, HL is restored to its value on entry and DE, BC and HL are pushed. KM RESET is called to initialise the Key Manager, TXT RESET is called to initialise the text screen, assisted by a call to SCR RESET, and U ROM ENABLE is called to bring the upper ROM into action.
 +
 +
HL is popped, and the loading program it defines is entered, using an odd little subroutine that consists solely of the JP (HL) instruction. BC and DE are popped.
  
 
== Scanned pages ==
 
== Scanned pages ==

Revision as of 14:44, 25 September 2019

Broadly speaking, the Machine Pack is reponsible for the control of hardware peripherals, but it will be convenient to include the main initialisation processes under this heading, since they are largely concerned with peripheral setting-up.

Several of the Machine Pack routines depend on the action of other routines to set up data. To understand this data in full, you need to read 'The Ins and Outs of the AMSTRAD CPC464', which gives full details of the peripheral codes. Only the more essential codes will be defined here.

Main Reset

At switch—on, or in response to instruction code &C7, location 0000 is entered. At switch-on, lower ROM is enabled, but the ROM routines are later copied to the corresponding RAM locations in this area, so the enable state of the lower ROM is then unimportant. However, the first action of the reset routine is to output &89 to the Video Gate array on I/0 address 7FXX, and this enables lower ROM, disables upper ROM, and also sets up Mode 1. There being no further room in the RST Area the routine jumps to 0580 to continue reset action.

Interrupt is disabled, and &82 is output to F7XX. This sets the PPI (Parallel Peripheral Interface) to output on ports A and C, input on port B. Zero outputs to F4XX and F6XX clear ports A and C, while an output of &7F to EFXX initialises the printer port. Bit 7 is low, the other bits are high.

The CRT Controller is then set up. There are two alternative sets of values for this, one for 50 Hz frame scan and the other for 60 Hz. The set to be used is determined by reading port B, bit 4. If this bit is true, 50 Hz values are used, while the 60 Hz values are used if the bit is false, this being determined by the presence of Link 4 on the main printed circuit board.

The tables are read backwards, which can be a little confusing at first, and the outputs alternate between BCXX, which selects the register to be set, and BDXX, which performs the actual setting.

Then MC START PROGRAM is entered at 060E with DE=065C and HL=0000. The contents of DE point to the display routine for the main title, which is called at an appropriate point. The zero value in HL means that ROM 0 will be entered at C006. This will normally invoke the BASIC interpreter, unless an external ROM responds to 0. C006 is the standard upper ROM entry point.

Before discussing MC START PROGRAM, it will be convenient to look at a program which calls it, having first loaded the necessary data:

MC Boot Program: BD13,05DC

On entry to this function, HL must hold the address of a loading routine, which must be designed to return with carry set and the program start address in HL if the load is successful, or with carry clear if the load fails.

The stack is reset by SP=C000, this being the normal stack position, and sound RESET is called to silence the Sound Generator. Interrupt is disabled, and &FF is output to port F8FF, requiring that all external peripherals devices should be reset.

KL CHOKE OFF is called to clear the B100-B1BF area to zeroes, though the previous contents of (B1A9/B) are first saved. (B1A9/A) holds the last-used foreground ROM entry address, which is copied to DE, while (B1AB) holds the last-used foreground ROM number, which is copied to B. (Note that the number of the ROM in current use is held in (B1A8), which is not preserved here.) If (B1AB) holds &FF the routine returns with C, D and E all zeroed.

Back in the main BOOT routine, HL is restored to its value on entry and DE, BC and HL are pushed. KM RESET is called to initialise the Key Manager, TXT RESET is called to initialise the text screen, assisted by a call to SCR RESET, and U ROM ENABLE is called to bring the upper ROM into action.

HL is popped, and the loading program it defines is entered, using an odd little subroutine that consists solely of the JP (HL) instruction. BC and DE are popped.

Scanned pages