So What Techncial Notes
#5

Call Box
Finding a Ports Pixel Image

Written by: William Stephens - February 15,1990

This technical note describes how to find the address to a grafports pixel image. This address is needed for direct accessing of the pixel image.

Grafports, unlike other entities do not have a call to return the handle or pointer to their images. The need will arise from time to time when you need to know this address for some reason like fetching color palettes or SCB's from the grafports pixel image. A grafport in Call Box BASIC differs from the traditional grafport in that the pixel image also includes all the SCB's and all 16 color palettes. When the port is displayed only the SCB's and the majority color palette is used, leaving the other 15 color palettes in the ports pixel image and not in the display pixel image at $El/2000. To access these other palettes you need to know their address. To derive the address of a ports pixel image use the following procedure: (N = Ports Entity Number A = Ports Pixel Image Address)

A = ((PEEK(PO + 120)* 65536)+ 256) + (N * 4)
CALL PE,4,A,A : CALL PE,4,A,A : A = A + 2 : CALL PE,4,A,A


This will find the address of the grafports pixel image and put the results in A. If you want to access the SCB's then add 32,000 to the value A, if you want to access the color tables then add 32,256 to the value A.

Example:
Let's copy all of the color palettes associated with a Call Box Grafport to the display grafport. First you must run the above procedure and then use the Quickdraw II call SetColorTable ($OE04) in a FOR - NEXT loop which sequentially reads palettes 0 through 15:

A = A + 32256 : FOR N = 0 TO 15 : CALL LC,N,_A\$OE04\ A = A + 32 : NEXT

This is just a single example to give you the "feet' of how this technique works. It is handy to know about grafport record structure plus handles and deferencing to fully appreciate the power and flexibility of this type of procedure. Unfortunately ... these things may be hard to understand for the uninitiated. At the very least this tech note will allow you to use this technique without having to fully understand it... for now that is.


Further Reference
Apple IIgs Toolbox Reference Vol 1,2 and 3
Call Box BASIC Manual V2.0


Call Box - So What Software 10221 Slater Ave. Suite 103 Fountain Valley, CA. 92708