home *** CD-ROM | disk | FTP | other *** search
- /*
-
- OnePlane.c - program to steal bottom bitplane from workbench screen
-
- Ethan Dicks
- (c) 15-Nov-1988
-
- Version 1.1
- (c) 14-Dec-1988
-
- This progam is *not* in the public domain, but may be freely redistributed on
- the condition that it is not sold, nor used in any commercial or shareware
- package without express written permission of the author. This program may
- be included in a freely redistributable library, including, but not limited
- to the Fred Fish library collection. In other words, selling this program
- is right out, but giving it away is encouraged.
-
- I got the encouragement for this program from the discussion on comp.sys.amiga
- regarding fast text scrolling. Someone called for a program to reduce the
- Workbench screen to 1 bitplane to enhance the speed of CON: output.
-
- COMPILATION INSTUCTIONS:
-
- This code will compile under either Lattice C, V4.01 or V5.00, although
- V5.00 will produce a 28 byte smaller executable. Currently, Lattice V4.01
- produces a 468 byte executable, and V5.00 produces a 440 byte executable.
- Who says C has to be bloated!
-
- To compile, either use LMK and the provided Makefile or use the commands:
-
- lc -b0 -v oneplane.c
- blink oneplane.o SC SD ND
-
- This is why some of the structure looks odd; I don't link with any external
- files, not even startup code. I know that the program could be made even
- smaller, but what do want for a one night's hack?
-
-
- HOW IT WORKS:
-
- In the structure GfxBase, there is a field, ActView, which describes the
- current ViewPort. This program uses the active viewport information to
- aquire the active BitPlane structure, which contains information about how
- many bitplanes are in use, their location in memory, the number of rows in
- the bitplane, and the number of bytes in each row. With this information,
- is it trival to change the number of bitplanes down by one, and to free
- up the memory held by the highest bitplane. The request is checked in case
- this is the only bitplane allocated. The advantage of this system is that
- the number of bitplanes can be increased and decreased at will, without
- fear of a visit from the GURU.
-
- Most of the information I got came from the RKM graphic primitives section,
- in the Libraries and Devices volume, especially the examples, and most of the
- rest came from picking apart the include files.
-
- */
-
- #include <exec/types.h>
- #include <exec/execbase.h>
- #include <intuition/intuition.h>
- #include <graphics/gfxbase.h>
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
-
- #define MIN_DEPTH 1
-
-
- #pragma libcall ExecBase FreeMem d2 0902
- #pragma libcall IntuitionBase RemakeDisplay 180 00
- #pragma libcall ExecBase CloseLibrary 19e 901
- #pragma libcall ExecBase OpenLibrary 228 0902
-
- struct View *currentview; /* pointer to active View */
- struct ViewPort *currentvp; /* pointer to active ViewPort */
- struct RasInfo *currentri; /* pointer to active RasInfo */
- struct BitMap *b; /* pointer to current BitMap */
-
- /* struct Execbase *ExecBase; */
- struct GfxBase *GfxBase;
- struct IntuitionBase *IntuitionBase;
- struct ExecBase *ExecBase, **EBase;
-
-
-
- /*
- Here goes nuthin'
- */
- void main()
-
- {
- /* Set the ExecBase pointer manually, since we do not link with anybody */
- EBase = (struct ExecBase **)(4L);
- ExecBase = *EBase;
-
- /* Open the graphics.library and the intuition.library */
-
- /* error checking not done, because if they won't open, the system is hosed */
- GfxBase
- = (struct GfxBase *)OpenLibrary("graphics.library",0);
-
- IntuitionBase
- = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
-
- /* Here goes with the pointer game... the idea is to end up at the BitMap */
-
- currentview = GfxBase -> ActiView; /* get current View */
- currentvp = currentview -> ViewPort; /* get current ViewPort */
- currentri = currentvp -> RasInfo; /* get current RasInfo */
- b = currentri -> BitMap; /* get current BitMap */
-
- /* And here is where we fiddle with the numbers */
-
- /* ---> ONLY DO THIS IF THERE ARE BITPLANES LEFT TO REMOVE <--- */
- if ( (b -> Depth) > MIN_DEPTH) {
-
- b -> Depth -= 1;
- FreeMem( (b -> Planes)[(b -> Depth)],
- (b-> Rows) * (b -> BytesPerRow) );
-
- }
-
- /* Now that we are done fiddling with it, redraw the display */
- RemakeDisplay();
-
- /* Now clean up and go home */
- CloseLibrary((struct Library *)GfxBase);
- CloseLibrary((struct Library *)IntuitionBase);
- }
-
- void MemCleanUp(){}
-