[comp.sys.atari.st.tech] Can't get Setpallete

marco@sys6626.bison.mb.ca (Marco) (04/25/91)

Here's the code I've been trying to use to blank (black) my screen:
----------------------------------------------------------------------
#include <stdio.h>
#include <osbind.h>

main()
{
int i, pal;
for (i=0;i<16;i++)
        pal = i;
Setpallete(pal);
}
---------------------------------------------------------------------
I have tried everything, the spelling, everything. Am I totally on the 
wrong track with this (the purpose, by the way, is to blank the screen to 
prevent burn in). The above program just inverts the screen, when I click 
on the Control panel ACC it is re-inverted back to black on white and the 
first color in the pallete is set all 3 bars at the top. When I pull 
them down the screen goes white on black and running the program does 
nothing. Any suggestions?

      /-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\
      *John Perry; Voice #-204/783-0812; Internet:              *
      *marco%sys6626.bison.mb.ca@niven.cc.umanitoba.ca          *
      *---------------------------------------------------------*
      * "It is an old maxim of mine that when you have excluded *
      *  the impossible, whatever remains, however improbable,  *
      *  must be the truth." -Sir Arthur Conan Doyle            *
      \-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-/

apratt@atari.UUCP (Allan Pratt) (04/30/91)

marco@sys6626.bison.mb.ca (Marco) writes:

>Here's the code I've been trying to use to blank (black) my screen:
>----------------------------------------------------------------------
>#include <stdio.h>
>#include <osbind.h>

>main()
>{
>int i, pal;
>for (i=0;i<16;i++)
>        pal = i;
>Setpallete(pal);
>}

This won't work because Setpallete (sic) takes a LONG argument which is a
POINTER to an ARRAY of 16 INT's.  Check those types in the documentation!
If you look at your code again I think you'll realize that it doesn't make
any sense at all.

main()
{
	int i, pal[16];
	for (i=0; i<16; i++)
		pal[i] = 0;
	Setpallete(pal);
}

Setpallete is a misspelling of Setpallete, and is that way because Atari's
original docs and include files spelled it wrong in the first place.
As has been pointed out, this is now retained by most compilers.

A caveat for Setpallete users: the above program is unreliable because
Setpallete copies its argument to a variable, and the palette registers are
loaded from the 16 int's found there AT THE NEXT VBLANK.  Since the above
program has terminated by the time the next VBLANK rolls around, that means
this memory is not owned by anybody, violating the commandment "Thou shalt
not mess with memory thou ownest not."  I know the "program" is just an
example of this poor slob's problem, but it bears repeating that Setpallete
is a delayed-action call.

============================================
Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt

ajw@watson.hf.intel.com (Alan Waldock) (05/01/91)

In <2919@atari.UUCP> apratt@atari.UUCP (Allan Pratt) writes:

> Setpallete is a misspelling of Setpallete...

That's 'Setpalette'.  Pretty darn confusin', huh?  :-)

> Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
> reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt

But just to reiterate - it's good to receive them, nonetheless.
Thank you.

-- Alan Waldock, from but not on behalf of Intel Corporation
   ajw@watson.hf.intel.com       ...uunet!intelhf!watson!ajw

warwick@cs.uq.oz.au (Warwick Allison) (05/01/91)

In <2919@atari.UUCP> apratt@atari.UUCP (Allan Pratt) writes:

AHA! So, maybe we have the culprit | | | | :-)
                                   v v v v 
>Setpallete is a misspelling of Setpallete, and is that way because Atari's
>original docs and include files spelled it wrong in the first place.
>As has been pointed out, this is now retained by most compilers.

#define Setpalette Setpallete
--
  _-_|\       warwick@cs.uq.oz.au
 /     *  <-- Computer Science Department,
 \_.-._/      University of Queensland,
      v       Brisbane, AUSTRALIA.

bjoern@drdhh.hanse.de (Bjoern Kriews) (05/01/91)

From article <LoiX11w164w@sys6626.bison.mb.ca>, by marco@sys6626.bison.mb.ca (Marco):
> ----------------------------------------------------------------------
> #include <stdio.h>
> #include <osbind.h>
> 
> main()
> {
> int i, pal;         /* pal[16] */
> for (i=0;i<16;i++)
>         pal = i;		/* pal[i] = 0; */
> Setpallete(pal);	
> }

or

for(i=0;i<16;++i)
	Setcolor(i,0);
	
But this will never blank a mono monitor - with color it will do.

Be sure to restore the old color values, get them with old=Setcolor(x,-1);

hth, Bjoern

---
bjoern@drdhh.hanse.de = Bjoern Kriews / Stormsweg 6 / 2000 Hamburg 76 / FRG
"gaaga mahwe Bjoern urgl ufzae Turbo-C bnub"     (J. Willamowius)