|★ CODING ★ LISTINGS ★ On-screen effects on the CPC464 ★|
|Graphic - Crtc - On - Screen Effects On the CPC464|Popular Computing Weekly)||Coding Listings|
Create some great on-screen effects on the CPC464 with these programs by Brian Cadge
The Amstrad's video display is produced by two pieces of hardware, the Video Gate Array and the CRT controller. The VGA controls the screen mode (resolution), and handles the loading of colours into palette memory. It is also used by the AmstTad to control the bank switching of ROMs.
The second part of the video hardwre is the CRT (Cathode Ray Tube) Controller chip. The Amstrad uses the 6845 CRTC chip to control the positioning and size of the display on the monitor. Although the firmware uses some features of the 6845 hardware, principally for hardware scrolling the screen, there are many other useful features of this chip which the firmware does not support.
The 6845 has a total of 16 internal registers, most of which are Write-Only, that is to say we can output values to them, but we cannot read the current values from them. Two Z80 I/O port addresses are used to control the 6845, these are BCX2"and BDXX. The former is the address port and the latter the data port.
Values are sent to a peripheral chip, such as the 6845, using the Out command in Basic. To send a value to one of the 6845 registers we first of all send out the registers number to the adress port BCXX to tell the chip which register we want to change. The actual data value to be put in the particular 6845 register is then output to the data port. So to send the value 40 to register one in the 6845 we would use the following Basic commands: Out &BC00,1: Out &BD00,40.
Although the address port will keep the value one, it is always advisable to output the register number immediately before the data just in case the firmware has since updated the address port.
So just what are the 6845 registers used for? The table below lists the more useful ones. Those missing are either not implemented by the Amstrad hardware, or are only partly implemented.
It is generally not a good idea to alter any register involved with Sync functions, as this can lead to the loss of picture and you will have to reset the computer. The useful registers have the following functions: Register 0 controls the overall 'height' of the physical monitor screen. Program Four uses this feature to give a 'neon lights'effect that can be very useful for title displays, etc. An interesting feature of changing this register is that it controls when the frame flyback pulse occurs. Making the screen longer (as Program Four does) means it takes longer for the CRT to scan one 'screen' and so the interrupt occurs less frequently.
Register One controls the number of columns displayed on the screen. The Amstrad sets this to 40 (note this value applies to all modes), but this can be changed to display more or less of the border. Similarly, Register Six controls how many text lines are displayed, ini- tially 25. Register Two controls how far left the display starts and Register Seven controls how far down the display starts. Program One uses these positioning registers to allow you to move the text screen around on the monitor using the cursor keys.
Program Two uses the positioning registers and the size registers to repostion the screen in the top left hand corner of the monitor and then expand it to 24 columns by 34 lines in Mode 0. The border is completely concealed as the text screen now covers the whole of the monitor screen. In practice, if you change the size of the screen it will be necessary to check that the new display uses no more than 16K of memory or else wrap-round will occur. The firmware graphics and text routines will not operate as normal on different sizes of screen.
The position of text screen can be moved in all four directions in steps of one Mode 1 character. Register Five allows fine adjustment of the vertical position; this has many uses. For example, hardware smooth scrolling of graphics and text could be implemented. Program Three uses this register to give an 'earthquake' effect that can be used in games. The screen appears to 'shake' as in an earthquake. Try adding a Call &BD19 in Lines 75 and 105 to see an example of smooth scrolling. This firmware routine waits for the current screen scan to complete before returning and can be used to tidy up screen updating.
The four programs presented with this article only show a few of the effects possible by direct manipulation of the CRTC chip. Although some of the effects