Object code modules for decompression and display of Spectrum pictures Note: these modules can not be used as part of any commercial product without approval of Trio Engineering, inc. The modules can be executed from any program that passes parameters on the stack like in C (examples below are in GFA Basic). They work in both medium and low resolution (color only). If you want to show an .SPU (uncompressed) Spectrum picture, you can do it right away with the SHOW512.O module. .SPC (compressed) picture files have to be decompressed first using DECOMP.O module. First thing you should do is to reserve memory for the module(s) and the picture files. The amount of memory required by the modules themselves is equal to their size as disk files. Each uncompressed Spectrum picture takes 51104 bytes. Compressed files can be anywhere from 2K to 50014 bytes. Next load the modules themselves. The code is position-independent, so you can load them simply as data files with BLOAD. The starting address for each module must be even, of course. If you want to decompress an .SPC file first load it to memory (even address!). The decompressor works memory-to-memory, it does not load files from disk. Call the decompressor with the following command: A=C:DECOM%(L:SPC%,L:BITM%,L:COLM%) DECOM%=Address of the DECOMP.O module SPC%=address of the SPC file BITM%=address of the decompressed bit map (must be divisible by 256) COLM%=address of the decompressed color map (must be even) A=0 if OK, -1 if decompression error (bad SPC file) The decompressor creates two separate blocks of data: 32000-byte bit map at BITM% and 19104-byte color map at COLM%. You can put them anywhere you want, they don't have to follow immediately one another (although this is one of the obvious possibilities). An .SPU file is simply a bit map followed immediately by a color map. Load it at any address in memory divisible by 256 (SPU%), and then you'll have: BITM%=SPU% COLM%=SPU%+32000 You also can load the first 32000 bytes of the .SPU file separately from the last 19104 bytes, to two different locations in memory. When both the bitmap and the color map are in memory you can call the SHOW512.O module to display the picture on the screen. Here's the command to do it: VOID C:SHOW%(1,L:BITM%,L:COLM%) SHOW%=address of the SHOW512.O module To turn the 512-color display off call the SHOW512.O module with the single parameter 0: VOID C:SHOW%(0) When you turn the 512-color display off, SHOW512.O switches to the initial screen (restoring the color palette and resolution if necessary). The initial screen itself will not be altered, unless you used it to store the bit map portion of the .SPC or .SPU file (which is perfectly all right to do). In this case make your program redraw its main screen. The mouse is disabled while the 512-color display is on. You should not try to enable it during this period - it will not work properly anyway. You can only use the keyboard to control the program while the 512 display is on. If you have several pictures in memory at the same time you can switch between them instantly without turning the 512-color display off. First, you have to load each of them to a separate location in memory (and decompress if necessary). Start to show the first picture as described above, then continue to call the SHOW512.O module in exactly the same way: VOID C:SHOW%(1,L:BITM2%,L:COLM2%) Use different addresses BITM% and COLM% with each new call. At the end turn the 512 display off as described above. Of course, you can make the display time for each picture very short to create page-flip animations. It's easy to control the timing precisely. When you call the SHOW512.O module it returns control to your program with a 1/60 sec delay. Therefore, if you just make a series of calls: VOID C:SHOW%(1,L:BITM1%,L:COLM1%) VOID C:SHOW%(1,L:BITM2%,L:COLM2%) ................................ you'll have a 60 frames per second animation. To slow it down make one or more VSYNC calls between calls to the SHOW512.O module. Each VSYNC delays the previous picture display for another 1/60 of a second. VSYNC is the same as VOID XBIOS(37). If you want to synchronize picture switching with some other process (Stereotek glasses, for instance) keep in mind that the SHOW512.O module always delays switching for one frame. Here's the timetable: (1) You call SHOW512.O with the new picture address. It always happens when the electron beam is somewhere between the 200-th line and the screen bottom (at any other time the 512-color interrupt routine is executed and your program stands still). (2) The current scan continues to the bottom of the screen (3) The next scan starts - still showing the _old_ picture (4) The 200-th line is reached. SHOW512.O returns control to your program. The next scan will show the new picture. If you use GFA Basic do not call the SHOW512.O module from the direct mode. After executing any direct command GFA Basic returns the screen resolution to medium, overriding the low resolution mode selected by SHOW512.O. For the same reason you should write your Basic program in such a way that it always turns the 512-color display off before returning control to the user.