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.

DS development > Reading the current Matrix used by hardware

#105786 - DiscoStew - Wed Oct 11, 2006 10:06 pm

Is it possible?

I see there are ways of writing a matrix for hardware to use, like multiplying a 4x4 matrix with the one currently active, but what about reading a 4x4 matrix?
_________________
DS - It's all about DiscoStew

#105814 - toa - Thu Oct 12, 2006 6:35 am

DiscoStew wrote:
Is it possible?

I see there are ways of writing a matrix for hardware to use, like multiplying a 4x4 matrix with the one currently active, but what about reading a 4x4 matrix?


Hep, it's possible, you can libnds has methods for it "getMatrix" or something as I recall.
Specific hardware-details at:
http://nocash.emubase.de/gbatek.htm#ds3dmatrixloadmultiply
(Look for: CLIPMTX_RESULT and VECMTX_RESULT)

Personally I use CLIPMTX_RESULT for frustum based scene culling calculations and it work pretty sweet.

#105816 - DiscoStew - Thu Oct 12, 2006 6:41 am

lol, my internet went out while I was ready to submit this, and I couldn't see any new posts. I'll give it a try.
_________________
DS - It's all about DiscoStew

#105855 - DiscoStew - Thu Oct 12, 2006 5:34 pm

Hmm, I'm can't seem to get anything from that register array. This is what I'm trying to do to get the Matrix Identity.

Code:

glLoadIdentity();
while(GFX_BUSY);

u32 count = 0;
for ( ; count < 16; count++)
   baseIdentity.m[count] = MATRIX_READ_PROJECTION[count];
iprintf("Matrix[0] = %04X\n", baseIdentity.m[0]);


Just to test, I'm getting the first index, which according to the Matrix Identity and the 1.19.12 fixed-point standard should be 0x00001000, but I get 0.
I've even tried writing to an area of RAM (example: 0x02050000), then used Dualis to view that section. I can see values that I write myself to that specific location, but when I try reading the current matrix as shown above to write to there, all I get are 0s. Am I do something wrong?

EDIT:
Oh, just to let you know, the MATRIX_READ_PROJECTION from the libnds points to the same location as CLIPMTX_RESULT.

EDIT 2:
Well, until I can get a response about this problem I'm having with reading that area of memory, I'll do all of my matrices calculating manually, so I have something to work with until a solution is made.
_________________
DS - It's all about DiscoStew