[comp.sys.amiga] Turning off the pointer

cmcmanis@pepper.UUCP (09/02/87)

A couple of BIX were wondering what the 'noise' was on the screen
when they ran certain programs. This often happens to those of us
with fast RAM because the programmer failed to specify MEMF_CHIP
to his/her pointer imagery. Since I have often espoused the answer
(but never tested it) I decided to put my keyboard where my mouth
was and came up with this (NoPointer.C) which is a silly little 
example of how to turn the mouse pointer completely Off when your
window is the active one on the screen. It should be of special 
interest to those of you writing Killer Demos who don't want the
pointer in the way. It compiles under Lattice 3.10 and uses the
Intuitiopn function SetPointer() [which may be a 1.2ism]
--Chuck

-------------------snip here it's short----------------------------------------
/* This program demonstrates one way of making the Intuition pointer 
 * disappear. It uses CHIP ram so that it will always work correctly
 * even when the user has extra 'fast' memory.
 *
 * It uses AllocMem to get some Chip ram for the pointer. You must free
 * this memory before exiting the program.
 */

#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>

struct IntuitionBase	*IntuitionBase;	/* Intuition Pointer */
 
struct NewWindow nw = {10,10,300,100,1,2,CLOSEWINDOW, 
			 WINDOWDRAG+WINDOWCLOSE,0,0,
			"This Window has no Pointer!",0,0,
		        300,100,300,100,WBENCHSCREEN};

void
main()

{
  USHORT *Pointer;
  struct Window *win;
 
  /* Open Intuition so that we can open our Window */
  IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
  if (IntuitionBase == NULL) {
    printf("Intuition wouldn't open.\n");
    goto Abort;
  }

  /* Allocate some RAM in CHIP memory and then zero it */
  Pointer = (USHORT *)AllocMem(8 ,MEMF_CHIP+MEMF_CLEAR);
  if (Pointer == NULL) {
    printf("Couldn't get any memory for the new pointer!\n");
    goto Abort;
  }

  /* Open our application window. */
  win = (struct Window *)OpenWindow(&nw);
  if (win == NULL) {
    printf("Couldn't open a window on the workbench screen!\n");
    goto Abort;
  }
 
  /* Now clear the pointer. It becomes a 1X1 transparent pointer */
  SetPointer(win,Pointer,1,1,0,0);
  
  /* Wait for a signal to clean up. */
  Wait(1 << win->UserPort->mp_SigBit);
  
  ClearPointer(win);
  CloseWindow(win);

  /* Jump here if we had problems earlier. */
Abort:
  if (IntuitionBase == NULL) exit(1);
  CloseLibrary(IntuitionBase);
  if (Pointer == NULL) exit(1);
  FreeMem(Pointer,8);
  exit(0);
}

--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.