question about GsMap.index?

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
zolost
Interested PSXDEV User
Interested PSXDEV User
Posts: 6
Joined: Feb 21, 2022
Location: Sweden

question about GsMap.index?

Post by zolost » February 21st, 2022, 2:34 am

Im trying to get a small POC up and running using GsBG. I manage to get the TIM data loaded as well as the cells. But I am confused about what the index property of the GsMAP actually should consist of. The example in the psyq sdk sets it to start at the address of the BG file after the header (if I understood it correctly from the docs and parsing out the data in the header). What I understood from the docs is that index holds the desired order of the cell array. But shouldnt the cell array itself that you pass in as the base property already be ordered correctly?

I tried without using CEL/BG files, and it seams you can achieve everything but the actual index without them. I also tryed to just point it to an avalable place in memory but that didnt work out either.

Im rambling sorry, but yeah main question is, what is the magic that goes into this property?

And yes, I'm aware of GsBG being slow, but I just want something on screen to play with :)

Thank you, and thanks for all the other examples I've seen here. They've been really helpful!

User avatar
mzxtuelkl
Curious PSXDEV User
Curious PSXDEV User
Posts: 20
Joined: Jul 26, 2021
PlayStation Model: SCPH-5501
Location: United States
Contact:

Post by mzxtuelkl » February 23rd, 2022, 12:22 pm

From what I understand, first, each GsCELL is basically just a pair of UV coordinates. You'd make a 1-dimensional array of these GsCELLs (or use a CEL file), then have your GsMAP.base member point to the aforementioned array of GsCELLs. Each element's index in your GsMAP.base array designates a unique sprite within your texture atlas.

GsMAP.index is just a 2d array where each element's value is an index to your 1-dimensional GsMAP.base array. This 2d array can be created manually or you can use a BGD file. You'd compose a level with it.

In other words, the GsMAP.base array is essentially all the sprites from your texture atlas laid out in a straight line, where each sprite is assigned a number (or index). The GsMAP.index array picks out which sprites from that line should be placed in a 2d grid.
Image

zolost
Interested PSXDEV User
Interested PSXDEV User
Posts: 6
Joined: Feb 21, 2022
Location: Sweden

Post by zolost » February 24th, 2022, 8:55 am

That was exactly my conclusion after fiddling around with hex edit with the sony bgd and cel example files. However I composed the index array as a simple array and that did the trick just fine. My base array was already ordered so the index array was just ordered as 0, 1, 2, 3 etc. Quite straight forward in other words :). A 2d array would probably be more convenient however. I just assumed it was a standard array of unsigned shorts since it gets cast into a short pointer in the examples. Thanks for your help!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests