Re: A89: Grayscale Sprites and Pointers...
[Prev][Index][Thread]
Re: A89: Grayscale Sprites and Pointers...
Nope, your solution won't work. this might, tho...
JHill8075@aol.com wrote:
>
> Okay, help me here. I want to have a pointer point to a sprite, then be able
> to add a number to that pointer to make it point to another sprite (i know
> how to do it in ASM, but not in C). Tell me if the code I have below will
> work, and if not, please correct it. Thanks.
>
> /* includes */
> void _main(void)
> {
> static char ball_plane0 = { 0x3C,
> 0x42,
> 0x99,
> 0xA5,
> 0xA5,
> 0x99,
> 0x42,
> 0x3C,
//Note: You now only have 1 array....
/*
This should work because you can't be sure where ball_plane0 and ball_plane1
will be in relation to each other in the stack. this way, (ball+8) points to the
data that would normally be in the second sprite.
*/
> 0x3C,
> 0x7E,
> 0x66,
> 0x66,
> 0x7E,
> 0x3C,
> 0x00};
>
> char *ball=ball_plane0;
> void *plane0, *plane1;
>
> if(!GrayMode(GRAY_ON)) return;
> plane0=GetPlane(0);
> plane1=GetPlane(1);
> SetPlane(0);
> ClrScr();
> SetPlane(1);
> ClrScr();
> Sprite8(0,0,8,ball,plane0,SPRT_XOR); /* put ball_plane0 on plane 0 */
> Sprite8(0,0,8,ball+8,plane1,SPRT_XOR); /* put ball_plane1 on plane 1 */
> ngetchx();
> GrayMode(GRAY_OFF);
> }
--robin
References: