Path: chuka.playstation.co.uk!news From: "Andrew Partington" Newsgroups: scee.yaroze.beginners Subject: CLUT lookup help! Date: Wed, 8 Sep 1999 20:56:59 +0100 Organization: PlayStation Net Yaroze (SCEE) Lines: 67 Message-ID: <7r7386$23b11@chuka.playstation.co.uk> NNTP-Posting-Host: modem-70.aspirin.dialup.pol.co.uk X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Hi everyone! I'm trying to write a pixel-perfect collision detection routine. I've coded one before in x86 asm on PC in mode13h (ahh, direct framebuffer access, heaven!), but i'm having some trouble on the Yaroze version... I have a 256 colour sprite, and I want to lookup the CLUT entry for each byte of the sprite. I am assuming that in 16 and 256 colour modes, the sprite pixel data is actually an index into the CLUT, which contains the correct colour, like the .PCX picture format. I was expecting a copy of the sprite to be inside the collision area, but when I LoadImage() the collision area back to the visible screen to check what is going on inside the collision area, the sprite I copied in is corrupted (and yes, I am doing a DrawSync(0) after each LoadImage() and StoreImage() operation!). I hope someone can help me out, I can't get my head round what's going on! Below is my code for looking up CLUT entries for 256-colour sprite data, to show what i'm trying to do (probably something daft!) When I get it working, i'll stick the source on my page, so everyone can benefit, and see the way not to do things :) Cheers Andy a.partington@yaroze41.freeserve.co.uk http://www.netyaroze-europe.com/~partinga u_short* collisionArea; //64*64 array (8192 bytes) u_short* clutArea; //malloc()'ed to 512 bytes, containing a CLUT u_char* ufoArea; //16*8 area for enemy pixel data u_byte index; u_short colour; u_short offset; for(ypos=0;ypos<8;ypos++) { for(xpos=0;xpos<16;xpos++) { index=ufoArea[ufoOffset]; //get byte from UFO array colour=clutArea[index]; //look up entry in CLUT collisionArea[offset]=colour; //Put the entry in the collision area ufoOffset++; offset++; } offset+=(64-16); //-16 for sprite width } .... and then when the sprite has been written into the collision area, the collision area is LoadImage()'d back to the visible screen to see whats going on, and DrawSync(0) waited on!