|★ APPLICATIONS ★ PROGRAMMATION ★ GRAPHIC - SPLIT MODES|COMPUTING WITH THE AMSTRAD) ★|
|Graphic - Split Modes|Computing With the Amstrad)||Applications Programmation|
SOME of the best software around employs split mode screens in which the top half of the screen is usually Mode 0 whereas the lower half may be Mode 1 or 2.
The advantage of this is that it's possible to have both 16 colours and high resolution graphics - although they must be in separate halves of the screen.
The technique is used in adventures and arcade adventures to enable a 16 colour picture to be drawn in the top half of the screen and text to be printed in either 40 column Mode 1 or 80 column Mode 2 in the lower half of the screen. It might sound difficult but it's actually a lot easier to accomplish than you think.
Way back in the August 1985 issue of Computing with the Amstrad we saw how to use events - a pre-packed form of interrupt. To create a split mode screen display we use the same technique so if you're a bit fuzzy about events then have a read of that article.
The value of the first two bits in the mode and ROM enable register in the video gate array determine how the screen display is built up. Changing bits 1 and 0 to %00 sets the screen mode to 0, %01 is Mode 1 and %10 is Mode 2.
The alternate registers B' and C' are conveniently already set up for writing to the video gate array. The C' register contains a copy of the mode and ROM enable register. So we can switch to the alternate registers, set the appropriate bits of C' and write the new value with:
to change the mode.
What we do is to wait until frame flyback occurs, then set the screen mode. We wait as the screen display is built up and when the top half of the screen has been drawn, a fraction of a second later, we change mode. The lower half is built up according to this new mode.
To achieve this feat we write a short machine code event routine and put it on the frame flyback list. It will then be called as soon as frame flyback occurs.
The mode is set and another event routine initialised and placed on the fast ticker list. This routine is set to go off after the top half of the screen has been displayed and it sets the mode for the lower half of the screen.
Program I is a Basic listing which pokes the machine code into memory. The routine is enabled by calling &A000.
Program II is an Assembly listing. You'll see that it uses three firmware calls: &BCD7 initialises and places a block on the frame flyback list, &BCE0 initialises and puts a block on the fast ticker list and &BCE6 removes it.
The position of the split can be altered by poking &A034 with 2, 3 or 4. This is the delay for the fast ticker event. You may think that this is all there is to it but it isn't quite the end of the story.
Changing these bits alters how the hardware looks at the screen memory but it does not affect the firmware at all. So although you may change from Mode 0 to Mode 1 by writing to the mode and ROM enable register, the firmware - Basic and the lower ROM - still think you're in Mode 0.
They get very confused when you try to print or draw something. For instance, the firmware would think that there were still only 20 characters per line and that there were 160 pixels across the screen. You can see how muddled it would be if there should be 40 characters and 320 pixels across.
We need to be able to write to both sections of the screen, whatever mode they may be. This would be possible if we could change mode without affecting the screen display.
By changing to Mode 0, or whatever mode we've selected, we could write to the top half of the screen, then change mode without clearing or altering the screen in any way and write to the bottom half of the screen.
To do this we need to change one of the screen pack indirections SCR MODE CLEAR at &BDEB. It points to a routine in the lower ROM which, among other things, clears the screen.
The indirection is altered so that it enters the routine after the code which clears the screen, so it does everything but clear the screen. This doesn't affect CLS which can still be used to clear the screen.
There's no excuse for dull adventures and arcade games now - use a split mode screen.