Path: utzoo!attcan!uunet!cbmvax!ken From: ken@cbmvax.commodore.com (Ken Farinsky - CATS) Newsgroups: comp.sys.amiga.tech Subject: Re: ===> Need help with hardware sprites <=== Message-ID: <13892@cbmvax.commodore.com> Date: 20 Aug 90 14:23:25 GMT References: <19919.26cec9ee@merrimack.edu> Reply-To: ken@cbmvax (Ken Farinsky - CATS) Organization: Commodore, West Chester, PA Lines: 73 In article <19919.26cec9ee@merrimack.edu> greenwoode@merrimack.edu (Ed Greenwood) writes: > Using Lattice C (v. 5.04), I have been unable to make more than >one hardware sprite appear on the screen at the same time. Whenever I >place a sprite on the screen, all other sprites will immediately >disappear... I would suggest reading the beginning of the chapter "Graphics: Sprites, Bobs and Animation", from the ROM Kernel Manual: Libraries and Devices. For each sprite that you use, you have to "get" another one from the system. For instance, if you want to use sprites 2 and 3 (note that sprite 0 is the intuition pointer and sprite 1 can be paired with it, avoid these sprites if possible...) you would do something like: struct SimpleSprite sprite2,sprite3; extern UWORD chip sprite_data2,sprite_data3; if (-1 == (sprite_number2 = GetSprite(&sprite2,2)) ; /* error, could not get sprite */ else { /* here we can use sprite2 */ if (-1 == (sprite_number3 = GetSprite(&sprite3,3)) ; /* error, could not get sprite */ else { /* here we can use sprite3 */ ChangeSprite(NULL,&sprite2,sprite_data2); ChangeSprite(NULL,&sprite3,sprite_data3); /* do more stuff here */ rest_of_program(&sprite2,&sprite3); /* after you are done with the sprites, ** free them. */ FreeSprite(sprite_number3); } FreeSprite(sprite_number2); } If you "re-use" a sprite, say sprite 2, and load new data into it, then the old image will go away when the new one appears. >...I know the "-ad" option must be used when compiling a >program that uses sprites, but is there anything else that must be done? You do NOT need to use the -ad flag when using sprites, you simply must insure that the sprite image data is in chip memory. you can do this with the following construct: UWORD chip sprite_data[] = { 0,0, /* position control */ 0xffff, 0xffff, /* image data goes in here */ 0,0, /* after image data must have 0,0 */ }; This is the only part of a sprite that has to go into chip memory. You can use the chip or __chip keywords to tell lattice that the data is to be placed into chip memory. Once you have access to the sprite, install the data with a call to ChangeSprite(). >My knowledge of sprite graphics has come from the book, INSIDE THE AMIGA >WITH C. Are the sprite examples in this correct? Don't know. -- -- Ken Farinsky - CATS - (215) 431-9421 - Commodore Business Machines uucp: ...{uunet,rutgers}!cbmvax!ken bix: kfarinsky