Path: chuka.playstation.co.uk!scea!sumner From: sumner@austin.metrowerks.com (Joel Sumner) Newsgroups: scee.yaroze.programming.2d_graphics Subject: Re: Having trouble with 2D sprite viewer Date: Mon, 29 Dec 1997 12:32:46 -0600 Organization: Metrowerks Lines: 159 Message-ID: References: <34A62D45.501@hunterlink.net.au> NNTP-Posting-Host: mtwks167.metrowerks.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: Yet Another NewsWatcher 2.4.0 Hi David, I would suggest reading the "Targeting Net Yaroze" manual to learn how to use CodeWarrior. It takes you step by step through most of the things you need to know. It can be found in the documentation folder. Also, if you don't have CodeWarrior for Net Yaroze release 2, please e-mail me your registration number and I will have it sent to you. -Joel In article <34A62D45.501@hunterlink.net.au>, dmtreay@hunterlink.net.au wrote: >I've been trying to make a program to display 2D images as sprites >(taking judicious inspiration from Ira Rainey's SPRITE.C tutorial). The >problem is, when I GCC-compile it and then download it with PSComUtil, I >get a few blue bricks roughly the size of the image instead of the image >loaded in from the TIM file. I have only had the Yaroze for four days, >and consider myself quite lucky to have already written a basic B&W >image display - now I need colour, which is what this program is >supposed to be. BTW, the reason I use GCC to compile and PSComUtil for >downloads is a) I can't get SIOCONS to work, and b) I haven't had time >to learn how to use CodeWarrior. So, can somebody please solve the >riddle of the blue bricks? > >Here's the code. > >#include > >#define SCREEN_WIDTH 320 >#define SCREEN_HEIGHT 240 > >#define NO_SPRITES (1 + 1) > >#define OT_LENGTH 1 > >#define spriteAdd 0x80100000 > >GsOT WorldOT[2]; >GsOT_TAG OTTags[2][1< >PACKET GpuPacketArea[2][NO_SPRITES*sizeof(GsSPRITE)]; > >GsSPRITE SpriteInfo; >int Buffer; > >long userWantsQuit = 0; > >/* Function declaration */ > >void main (); >void InitialiseGraphic (); > >/* MAIN */ > >void main () >{ > int i; > > GsInitGraph(SCREEN_WIDTH,SCREEN_HEIGHT,4,1,0); > GsDefDispBuff(0,0,0,SCREEN_HEIGHT); > > /* Set up the ordering table */ > > for (i = 0; i < 2; i++) > > { > WorldOT[i].length = OT_LENGTH; > WorldOT[i].org = OTTags[i]; > } > > /* Draw up the TIM file */ > > InitialiseGraphic (); > > while (!userWantsQuit) > > { > Buffer = GsGetActiveBuff(); > GsSetWorkBase((PACKET*)GpuPacketArea[Buffer]); > GsClearOt(0,0,&WorldOT[Buffer]); > > GsSortFastSprite(&SpriteInfo,&WorldOT[Buffer],0); > > DrawSync(0); > > VSync(0); > GsSwapDispBuff(); > GsSortClear(0,0,0,&WorldOT[Buffer]); > GsDrawOt(&WorldOT[Buffer]); > > } >} > >/* INITIALISE GRAPHIC */ > >void InitialiseGraphic () >{ > RECT rect; > GsIMAGE ImageSetup; > > GsGetTimInfo ((u_long *)(spriteAdd+4),&ImageSetup); > > rect.x = ImageSetup.px; > rect.y = ImageSetup.py; > rect.w = ImageSetup.pw; > rect.h = ImageSetup.ph; > > LoadImage (&rect, ImageSetup.pixel); > > /* Load up the CLUT table */ > > rect.x = ImageSetup.cx; > rect.y = ImageSetup.cy; > rect.w = ImageSetup.cw; > rect.h = ImageSetup.ch; > > LoadImage (&rect, ImageSetup.clut); > > /* Set up TIM data as a sprite */ > > SpriteInfo.attribute = 0x01000000; > SpriteInfo.x = ((SCREEN_WIDTH/2)-(ImageSetup.pw)); > SpriteInfo.y = ((SCREEN_HEIGHT/2)-(ImageSetup.ph/2)); > SpriteInfo.w = (ImageSetup.pw*2); > SpriteInfo.h = ImageSetup.ph; > SpriteInfo.tpage = GetTPage(1, 0, ImageSetup.px, ImageSetup.py); > SpriteInfo.u = 0; > SpriteInfo.v = 0; > SpriteInfo.cx = ImageSetup.cx; > SpriteInfo.cy = ImageSetup.cy; > SpriteInfo.r = 128; > SpriteInfo.g = 128, > SpriteInfo.b = 128; > SpriteInfo.mx = 0; > SpriteInfo.my = 0; > SpriteInfo.scalex = ONE; > SpriteInfo.scaley = ONE; > SpriteInfo.rotate = 0; > > DrawSync(0); > >} > >It loads with an AUTO.BAT: > >local dload test_spr.tim 80100000 >local dload MAIN // executable >go > >-- > David "DM" Treay (dmtreay@hunterlink.net.au) >SF PRODUCTIONS - Newcastle's only PlayStation developers! > > "Tell me sir... have you confused your cat recently?" -- PlayStation Development Tools Dude Metrowerks