[comp.sys.atari.st] Reading a Lores Screen

bferrer@Bonnie.ICS.UCI.EDU (03/06/91)

  Given a pointer to a lores screen, how can I read a pallete number
from the screen without using the linea routines but with pointer
manipulation?  Can I just write:

    char Color_Number, *Screen;
    int x,y;

    Color_Number = Screen[x/2 + 160*y];

then manipulate the byte to get the pallete number? If possible
please send some example C source code to my email address:

    bferrer@bonnie.ics.uci.edu

thanks....

In a state of confusion,


Bill Ferrer

lsmichae@immd4.informatik.uni-erlangen.de (Lars Michael) (03/07/91)

bferrer@Bonnie.ICS.UCI.EDU writes:


>  Given a pointer to a lores screen, how can I read a pallete number
>from the screen without using the linea routines but with pointer
>manipulation?

A C-routine to get the color index of point (x, y):

int get_pix(int x, int y, char *Screen)
{	int Index;
	int mapnr;

	Screen += 160*y + ((x & 0xfff0) >> 1) + (x>7?:0:1);
        bitnr = 7 - x % 8;
	for (Index=0, mapnr=0; mapnr<4; mapnr+=1, Screen+=2)
		Index |= ((*Screen >> bitnr) & 1) << mapnr;
	return (Index);
}

Have fun !!!


								Lars

+-----------------------------------+----------------------------------+
|  Lars Michael                     |    | | |                         |
|  lsmichae@faui43.uni-erlangen.de  |    | | |   "Down with ATARI,     |
+-----------------------------------+   /  |  \   Long live the ST !"  |
|  "May the Schwartz be with you!"  |  /   |   \                       |
+-----------------------------------+----------------------------------+