★ APPLICATIONS ★ DIVERS ★ SCREEN COMPACTER (COMPUTING WITH THE AMSTRAD) ★![]() |
Screen Compacter (Computing With the Amstrad) | Applications Divers |
ROLAND WADDILOVE offers a short machine code routine to speed loading a screen from tape LOADING programs from tape can take quite a long time, running into several minutes with a lengthy listing. To relieve the boredom arising from this, commercial software often employs the use of an interesting title screen. However, have you ever tried saving the screen to tape? Takes a long time doesn't it? Plus when you load it back again it seems to take even longer. To solve the problem, here's a very short machine code routine that will reduce the time, and frustration, by half. The reason it normally takes so long to load or save is that the screen display requires 16k of RAM. The whole of &C000 to &FFFF is used to store the data. If we could reduce this in some way, then the process could be speeded up considerably. Often there are quite large plain areas of colour that have little detail. If you looked at the screen memory, then you would find a lot of similar bytes corresponding to the large plain areas. What we could do is to get a byte from the screen memory and count how many similar ones there are. Then the byte and the count could be saved. In this way we could save two bytes instead of many. Then, after saving the first byte and count, the process is repeated with the second, different byte, which may be 100 bytes further on. say. No doubt some of you will have spotted that if every adjacent byte is different then the screen compact routine will actually expand it to double its normal size. This is because one byte is required for the data and one for the count. However the savings with a simple screen are fantastic. It's not unusual to save 8k or more. Obviously it's going to be much quicker to save and load 7 or 8k than 16k. Program I pokes the machine code to &9000, above HIMEM which is lowered to &9000-1. After storing the code the loader is no longer needed and can be deleted using NEW. Listing II can be entered if you have an assembler. To use the code, first draw your picture and set up the screen display, taking care not to scroll the screen. Scrolling the screen will not do any harm, but when it loads back, unless the screen has been scrolled by exactly the same amount, then it will be a bit skew-whiff. Call &9000 to save a compacted version of the screen, and Call &9045 to load it back, making sure you're in the same mode. Again it will not do any harm if you're not in the same mode. In fact, it's actually quite interesting. Incidentally, the routine won't work for disc, unfortunately. It appears to find the end of file earlier than it should. It particularly doesn't like &1A as a screen byte. Can anyone explain why? Still, with the speed of disc drives you won't need to worry about the size of screen you're saving, will you? DISASSEMBLED LISTING
CWTA
|