|★ CODING ★ LISTINGS ★ GAMESLIST ★ GRAPHIC - SCREENS AND WIMPS|THE AMSTRAD USER) ★|
|SCREENS AND WIMPS|
Gary Koh completes his series on graphics by explaining screen manipulation and windowing.
This is the seventh and last part of our series on graphics. To round things off we will be having a quick look at screen manipulation and WIMP environments.
Screen manipulation encompasses quite a large area. As such, the barrier between graphics and screen manipulation is quite foggy. Some things could belong to both categories at the same time. Screen manipulation involves manipulating the screen as opposed to drawing on the screen.
One classic example is scrolling. This involves shifting the entire screen or a part of it in one direction. On the Amstrad this can be accomplished in one of two ways. The easiest and quickest way is to do a hardwire scroll. This simply changes the offset and scrolls the entire screen.
If you want to scroll an area smaller than the screen then you are in a bit of bother. The only way to scroll a portion of the screen is to do a software scroll. If you try software scrolling on large areas of screen you end up with an annoying flicker.
The reason for this is that to accomplish a software scroll you need to shift each byte manually in the area to be scrolled to a new area. A Z80 processor running at 4Mh may sound fast but trying to shift say 10000 odd bytes in less than a frame flyback is a bit beyond it. This is why it is most effective on areas of the screen that are about a quarter of it in size or less. On small areas of the screen you can scroll it in less than a frame flyback which makes the scrolling appear smoother. On larger areas the scrolling cannot be accomplished in a single frame flyback and so you can see it shift halfway during the scrolling making it jerky.
The first listing this month is a machine code loader program. It must be merged with several of the programs this month.
Our second listing this month must be merged with the first (the loader program). There are several routines in the firmware to scroll the screen. Listing 2 is a simple scrolling routine that uses the firmware routine SCR hw roll. Hardware scrolling is easy as there arc several firmware routines to accomplish this.
There is not much support for software scrolling though. The single routine that is provided to do this can only scroll an area of the screen up or down by eight pixels.
There are other things beside scrolling that are connected with screen manipulation. Double height characters and different fonts are also examples of screen manipulation. Listing 3 does some screen swapping. It utilises the firmware routine SCR sot base to change the address of the start of the screen.
Screen manipulation also involves changing the way a picture looks by shifing around pixels. Various actions that do this are mirroring, , rotating and scaling. Listing 4 is a demo in Basic that demonstrates mirroring and turning a picture upside down. It works by testing each pixel and then putting it in a different position in relation to its original position.
Listing 5 is a group of screen swapping commands. It adds 3 commands to the normal Basic commands The first three commands that listing 5 add are |SCHADD , |TOSCREEN and |FROMSCREEN. |SCRADD is the only one which accepts a parameter.
These three commands allow you to set up and use another second screen storage area in memory |SCRADD,a will set the bottom of this second screen to a This second screen occupies 16 Kb of memory. It can be put anywhere in memory as long as it does not overlay any important part of memory. If ROMSCREEN will transfer all the data on the real screen to the second screen. |TOSCREEN does the opposite, transferring the data m the second screen to the real screen. These commands could be used for, say, storing a second screen memory for an art program.
The last listing , listing 6, is a simple WIMP environment shell. It is meant to be driven by other programs. Of course it does not give you the power of a Macintosh but it should prove interesting to you.
Actually it is a combination of two programs. Lines 100-360 make a small demo. The actual WIMP routines are housed from line 60000 onwards. To use Wimper just simply erase the demo part and merge the remaindier into whatever program wish.
To start if off firstly call the initialisation routine at 62010. It will read off some data from a data statement you have to set up. This data tells it what headings to put for the pull down menus. The first number in the data will tell it how many headings there are.
For instance, if you want to have Utility as the first heading,Test as the second and Benchmark as the third just put them in that order in the data statement. The program will sort out the rest of it. Make sure though there are not so many headings that they overload the top window.
After this, the program will setup a few things needed by the other routines. Make sure you do not use the same variables as are used in the program. The initialisation routine will then return control to you.
The next thing you might want to do is move the pointer around. This is what the Move pointer routine at 60080 does. It will take input from the joystick only. When you press fire it will check that you are in the top window. If you are in there it will sort out at which heading you are clicking. It will then return control with you with ms containing the relative number of the heading from the left of which one you selected.
Print shadow windows at 60240 will print a nice shadowed outlined. You have to set up the variables wa, wb , wc , wd and we. These in order represent the window number, left, right, up and down. These are the same parameters the normal window command accepts. To fill up the window with text just define wm$ to whatever string you want.
If you want this to be a pull down menu selection then call Pull down menu selector straight after this at 60310. This will put in a bar in the window. Use up end down joystick to move the bar. Press fire button to select what you want or left and right joystick to cancel the selection, it will return with ss containing the selection you want. If you aborted then ss will contain 10.
The last routine at 60390 adds a bit of font capability to spruce things up. To select the font you want just pass on the variable font. At the moment only 0 (normal character set) and 1 (Broadway) are available. So far Broadway is not yet a full font with only the uppercase and number characters defined.
Wimper is by no means complete and I suggest you do not take it too seriously. I am working on a better version. With any luck it should be completed in a few months. I hope that you have a lot of fun with the series and have learned a little more about the world of Amstrad Graphics.
CPCrulez[Content Management System] v8.7-desktop/cache
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.