Translator map

Technical discussion for those interested in Supermodel development and Model 3 reverse engineering. Prospective contributors welcome.
Forum rules
Keep it classy!

  • No ROM requests or links.
  • Do not ask to be a play tester.
  • Do not ask about release dates.
  • No drama!

Translator map

Postby Bart » Sun Dec 17, 2017 10:19 pm

I was browsing the Model 2 manual and stumbled upon a description of "Translator map":

Code: Select all
After luminance is applied to texture, the luminance is modulated by a conversion table called "Translator Map." Usually for cases where you don't want to modulate, the function is defined as linear. By making proper use of this table, you can make one texture map appear as if it has several textures. For example, you can make sea texture look like a cloud or rock surface.


So, basically, it's a conversion table. And on Model 2, it seems to operate on texel values after lighting is applied. I wonder if the data I saw being uploaded to the texture FIFO could be this map? In any case, it was always the same.

No further mention of this table is made in the docs except for where it is located in Model 2 memory (where it occupies a 2MB window of the address space, which is probably much larger than the actual table size).
User avatar
Bart
Site Admin
 
Posts: 2188
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Translator map

Postby Ian » Mon Dec 18, 2017 3:05 am

In the sdk, in the constructor for the translator map is this

Code: Select all
PRO_Translator_Map *__userpurge PRO_Translator_Map::PRO_Translator_Map@<eax>(PRO_Translator_Map *this@<ecx>, int a2@<ebx>, int a3@<edi>, int a4@<esi>, __int32 translator_map_number)
{
  int v5; // ST08_4@1
  int v6; // ST04_4@1
  PRO_Translator_Map *v7; // esi@1
  signed int v8; // edi@1
  void *v9; // eax@1
  int v10; // eax@2
  int v11; // eax@3
  int v12; // eax@3
  unsigned int v14; // [sp+4h] [bp-Ch]@1
  _UNKNOWN *v15; // [sp+8h] [bp-8h]@1
  int v16; // [sp+Ch] [bp-4h]@1

  v16 = -1;
  v15 = &_L4445;
  v14 = __readfsdword((signed __int32)&_except_list);
  __writefsdword((signed __int32)&_except_list, (unsigned int)&v14);
  v5 = a4;
  v6 = a3;
  v7 = this;
  v8 = 0;
  PRO_Polygon_Data_Block::PRO_Polygon_Data_Block(264, v6, v5, a2, this);
  v16 = 0;
  *(_DWORD *)v7 = &PRO_Translator_Map::`vftable';
  PRO_Clear((char *)v7, 36, 44);
  *((_DWORD *)v7 + 10) = translator_map_number;
  v9 = malloc(264u);
  *((_DWORD *)v7 + 9) = v9;
  *(_DWORD *)v9 = 524;
  *(_DWORD *)(*((_DWORD *)v7 + 9) + 4) = (translator_map_number | 0xFE000000) << 6;
  do
  {
    v10 = v8 + 3;
    v8 += 4;
    *(_DWORD *)(*((_DWORD *)v7 + 9) + v8 + 4) = v10;
  }
  while ( v8 < 256 );
  v11 = *((_DWORD *)v7 + 9);
  v16 = -1;
  *((_DWORD *)v7 + 8) = v11;
  v12 = *((_DWORD *)v7 + 5) | 1;
  __writefsdword((signed __int32)&_except_list, v14);
  *((_DWORD *)v7 + 5) = v12;
  *((_DWORD *)v7 + 5) = v12 & 0xFFFFFFFD;
  return v7;
}


v9 = malloc(264u);

264 entries in the table?

The set value is unremarkable
Code: Select all
void __thiscall PRO_Translator_Map::SetTranslatorMapEntry(PRO_Translator_Map *this, __int32 entry_index, __int32 entry_value)
{
  *(_DWORD *)(*((_DWORD *)this + 9) + 4 * entry_index + 8) = entry_value;
  PRO_Polygon_Data_Block::NotifyUpdate(this);
}


The hw update
Code: Select all
signed int __thiscall PRO_Translator_Map::WriteDataToHardware(void *this)
{
  void *v1; // esi@1
  int v3; // [sp+4h] [bp-4h]@1

  v1 = this;
  PRO_Polygon_Data_Block::WriteDataToHardware();
  v3 = **((_DWORD **)v1 + 3) >> 2;
  PRO_IO(&v3, 1, 0x90000000, -1, 1);
  return 1;
}


Just sends to texture memory somewhere ..
Ian
 
Posts: 1520
Joined: Tue Feb 23, 2016 9:23 am

Re: Translator map

Postby Bart » Mon Dec 18, 2017 8:56 am

I'm assuming it's actually 256 bytes plus 8 bytes of data either internal to the API struct or some sort of header? If you look at what is transmitted by games at the start (e.g., in my comment here), it looks like 4 tables of 256 bytes each. I didn't see anything interesting in those tables. The values don't seem to match what is being written in the loop there (off by 1) but pretty close. At some point I can try to write some code to examine them and see if any game loads up an unusual table.
User avatar
Bart
Site Admin
 
Posts: 2188
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Translator map

Postby Ian » Mon Dec 18, 2017 11:09 am

Where would they go in the texture sheet? because I haven't noticed any obvious gaps
Ian
 
Posts: 1520
Joined: Tue Feb 23, 2016 9:23 am

Re: Translator map

Postby Bart » Mon Dec 18, 2017 12:38 pm

They don't necessarily have to be in the texture sheet. Could be their own special region of memory. I need to look more closely at how they are uploaded. I *think* the texture header is different from any other type, in which case the hardware would know this is not a texture and route it accordingly.
User avatar
Bart
Site Admin
 
Posts: 2188
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Translator map

Postby HarryTuttle » Mon Dec 18, 2017 1:46 pm

A crazy idea (since translator map is also on my to-do list): what if the so called (from MAME) gamma table is infact the translator map? I mean that other unknown upload mode to Texture RAM, when texture header MSB is set.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am

Re: Translator map

Postby Bart » Tue Dec 19, 2017 8:02 am

That's what I was talking about, Harry :)

I posted the data written here.
User avatar
Bart
Site Admin
 
Posts: 2188
Joined: Thu Sep 01, 2011 2:13 pm
Location: New York City

Re: Translator map

Postby HarryTuttle » Wed Dec 20, 2017 8:12 am

Bart wrote:That's what I was talking about, Harry

Ah, ok! :) I remember that post but I didn't notice you were referring to that sequence.
User avatar
HarryTuttle
 
Posts: 646
Joined: Thu Mar 09, 2017 8:57 am


Return to The Dark Room

Who is online

Users browsing this forum: No registered users and 2 guests

cron