Path: wucfua!wucs1!uunet!husc6!bbn!ulowell!page
From: page@swan.ulowell.edu (Bob Page)
Newsgroups: comp.sources.amiga
Subject: v02i103: oneplane - make workbench screen one plane v1.1
Message-ID: <10939@swan.ulowell.edu>
Date: 28 Dec 88 19:07:53 GMT
Organization: University of Lowell, Computer Science Dept.
Lines: 191
Approved: page@swan.ulowell.edu
Submitted-by: erd@cis.ohio-state.edu (Ethan R. Dicks)
Posting-number: Volume 2, Issue 103
Archive-name: workbench/oneplane11.1
[New version for Lattice v5.0 ..Bob]
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: Shell Archiver
# Run the following text with /bin/sh to create:
# OnePlane.c
# Makefile
# OnePlane.uu
# This archive created: Wed Dec 28 14:04:56 1988
cat << \SHAR_EOF > OnePlane.c
/*
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
#include
#include
#include
#include
#include
#include
#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 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(){}
SHAR_EOF
cat << \SHAR_EOF > Makefile
# -------------------------------------------
# Makefile for Oneplane v1.1
#
# Ethan Dicks 14-Dec-1988
# -------------------------------------------
LCFLAGS = -b0 -v
LNFLAGS = SC SD ND
OnePlane.o: OnePlane.c
lc $(LCFLAGS) OnePlane
OnePlane: OnePlane.o
blink OnePlane.o $(LNFLAGS)
SHAR_EOF
cat << \SHAR_EOF > OnePlane.uu
begin 777 OnePlane
M```#\P`````````#``````````(````X````"0````@```/I````."\"0```!P@42/(````&$/Y`````'``+$A.KOW8(\`````00_D````2Y
M0`````CT0````0B>0````0CC
MZ0`D````"")Y````""/I``0````,(GD````,$BD`!70!L@)C,B0!4P(@>0``,
M``P10@`%0```!A.KO\N+'D`P
M```43J[^@")Y````$"QY````&$ZN_F(B>0```!1.KOYB)!].=4YU```#[```5
M``(````!````+@```!H````4`````@```-(```#(````P@```+@```"N````C
MB@```'8```!P````:````&(```!:````5````$X```!(````0````#H````H@
M````%`````P````&`````````_(```/J````"6=R87!H:6-S+FQI8G)A