Page 1 of 1

A tale of two TIMS

Posted: September 20th, 2018, 9:07 am
by ycelik
Hi guys,

I have some questions. I am currently loading two TIMS into memory.
The first TIM is loaded at 0x80180000 and the second one is loaded at (0x80180000 + the file length in bytes of the first TIM). When I initialise both TIMS (set PolyFT4, tpage, and clut) and then add them to the OT, I only see the second POLY_FT4). However, when I comment the second POLY_FT4's initialisation and addition to the OT, I see the first POLY_FT4 again. I have written the code according to the samples found in the PSYQ-SDK, so I just cannot place my finger on what I am doing wrong.
My code can be found here:

Bytheway, I use .bat file wherein I specify two pqbload commands with the TIM files and their respective addresses.

Re: A tale of two TIMS

Posted: September 20th, 2018, 11:29 am
by LameGuy64
Sounds like the TIMs are getting overwritten. Have you checked if the TIMs are positioned at different coordinates in the VRAM using TIMTOOL? If they're on different positions make sure the correct TPage value using getTPage() is set on each POLY_FT4 primitive.

You may also want to check if your textures are page aligned by aligning the upper left corner of the image to the grid in TIMTOOL.

Re: A tale of two TIMS

Posted: September 20th, 2018, 5:50 pm
by ycelik
LameGuy64, thanks for your very helpful reply.
Immediately when I read this after waking up, I directly ran before going to work to the P3 machine to see whether it was such a rookie mistake. Alas, I discovered that I did indeed separate the sprites properly, and it was not a case of overlapping texture pages.
However, your post got me thinking, and I soon discovered the real problem: the CLUT of the first TIM was being overwritten! The reason for this lay in the misconstruction of the double buffer in relation to the texture layout.
In other words, I thought that I was constructing the double buffer adjacently, but apparently I was doing it stacked.

Code: Select all

  
    SetDefDrawEnv(&db[0].draw, 0,   0, 320, 240);
    SetDefDrawEnv(&db[1].draw, 0, 240, 320, 240);
    SetDefDispEnv(&db[0].disp, 0, 240, 320, 240);
    SetDefDispEnv(&db[1].disp, 0,   0, 320, 240);
Now I know why I saw both sprites displayed at first instance, when I stepped through the debugger; once the page flip happened the CLUT was overwritten...
What a rookie mistake, but I am so happy that it is behind me now, because this was holding up so much.
P.s. I saw an old post of Shadow who also had an issue with multiple TIM display; was also a CLUT problem...