gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Linear Texture Mapping

#1998 - CoderArt - Mon Jan 27, 2003 2:29 pm

Whats the fastest code for texture mapping on the gba?

is it something along the lines of:

*screen=Texture[((tu>>16)& 31)+((tv>>11)&0x3e0)];

or is there a better way of doing this?


CoderARt!

#2053 - zeuhl - Tue Jan 28, 2003 12:56 pm

well, your code looks okay for 16-bit mode display. unfortunately, 16-bit mode doesn't allow double-buffering, without having to reduce the screen resolution.

for 8-bit mode (this time with double buffering ability), you have to write two consecutive pixels at a time, due to the gba's 16-bit architecture of the VRAM, which doesn't support 8-bit accesses.

hence that code :

Code:
pix1 = Texture[foo];
pix2 = Texture[bar];
*screen++ = pix1 | (pix2<<8);


fortunately, this is rather quick code, since the ARM can perform one ALU (like OR) and one shift operation in a single ARM instruction.

#2086 - Maddox - Wed Jan 29, 2003 5:16 am

You both lose. If you want that code to be awesome you WILL HAVE TO use assembly, especially since you are probably using GCC. Don't cry because you can still use all those nice features like barrel shifters and conditional execution, whatever.

Put that code in internal work ram and make sure it's ARM code not THUMB or you will lose again. This would be a good excercise for you to do on your own. Post back your assignment when you finish and I'll grade it. You just might learn something!
_________________
You probably suck. I hope you're is not a game programmer.

#2106 - tepples - Wed Jan 29, 2003 4:08 pm

Maddox wrote:
This would be a good excercise for you to do on your own. Post back your assignment when you finish and I'll grade it. You just might learn something!

Most professors at the school I'm at will run through enough theory to make it straightforward for the students to complete a given assignment. Got any helpful URLs?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#5650 - funkeejeffou - Mon May 05, 2003 1:18 am

Well maddox, you seem to have a great solution to perform a fast texture mapping, but why don't you share it?
I am really curious about your code, even if I agree that the codes before aren't the fastest...
Have you written a 3D engine for GBA?