		section FreeBitPlane,code

*************************************************************************
*              ****->   WORKBENCH BITPLANE REMOVER    <****-
*
*  This Snippet of code basically Removes a Bitplane from the WorkBench
*  in an attempt to regain some valuble chipmemory ( ALL users who are
*  desperate for EXTRA CHIP memory will find after running this program 
*  they RE-GAIN 21k of memory ) The BAD news is that after running you
*  are only left with (2 colours 1 Bitplane) instead of the normal 4
*  colours 2 Bitplanes arrangement !!
*
*  NOW A BUG !!
*  Only run the proggy once,as running it twice will CRASH the system
*  (the OS will try to remove a bitplane which doesn't exsist!!)
*
*  Maybe you can fix it !!! , Not that hard really !!!
*
*************************************************************************

; Open Gfx and Intuition Libraries

		move.l	4.w,a6		; Get Execbase
		lea	GfxName(pc),a1	; Point to Graphics.library name
		jsr	-$0198(a6)	; Open Gfx Library
		move.l	d0,GfxBase	; Save Gfx Library base address
		beq.s	Quit		; Carn't Open,--> Quit

		lea	IntName(pc),a1	; Point to Intuition.Library name
		jsr	-$0198(a6)	; Open Intuition Library
		move.l	d0,IntBase	; Save Intuition base address
		beq.s	CloseGfx	; Carn't Open,--> Close Gfx,Quit

*************************************************************************
* Free One Bitplane ( Free's 21k of Chipmem )

		move.l	IntBase(pc),a0	; Get Intuition base in a0
		move.l	56(a0),a1	; bitplane ptr 1
		move.l	88(a1),a0	; bitplane ptr 2
		move.b	#1,5(a0)	; remove 1 bitplane

		move.w	12(a1),d0	; width
		move.w	14(a1),d1	; height
		move.l	196(a1),a0	; Bitplane Pointer
		move.l	GfxBase(pc),a6	; Graphics base ptr in a6
		jsr	-$01F2(a6)	; Free Raster

		move.l	IntBase(pc),a6	; Pointer to Intbase in a6
		jsr	-$0180(a6)	; ReMakeDisplay ()

*************************************************************************
* Close Libraries

		move.l	IntBase(pc),a1	; Intuition base ptr in a1
		move.l	4.w,a6		; Get Execbase
		jsr	-$019E(a6)	; Close Intuition Library

CloseGfx	move.l	GfxBase(pc),a1	; Graphics base ptr in a1
		jsr	-$019E(a6)	; Close Graphics Library

Quit		moveq	#0,d0		; No Error Code
		rts			; Quit


IntBase		dc.l	0		; Intuition base address
GfxBase		dc.l	0		; Graphics Base address
IntName		dc.b	'intuition.library',0
GfxName		dc.b	'graphics.library',0


