Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo data format definition #7

Open
EuanKirkhope opened this issue Apr 15, 2021 · 0 comments
Open

Demo data format definition #7

EuanKirkhope opened this issue Apr 15, 2021 · 0 comments

Comments

@EuanKirkhope
Copy link

EuanKirkhope commented Apr 15, 2021

I noticed in the rosetta stone info that there is no details on the demodata level data.

From my decompile of a TR1 exe that I'm playing with this is the usage of demo data:

LoadLevel()
{
...
  g_demoDataIndex = 0;
  g_pDemoData = (tr_demodata *)GameMalloc(36000,0x1b);  // load 36000 bytes from file, 0x1B is string "Load Demo Buffer"
...
}

// g_pDemoData is referenced in only 3 functions
// GameDemoSetCurrentEntity:00415d03(R)
// GameDemoRunTimer:00415d7e(R),
// LoadLevel:0041b36c(W), 

void GameDemoRunTimer(void)
{
  if (g_demoRunTime < 9000) {
    g_gameInputCmds = g_pDemoData[g_demoDataIndex]; // gets first tr_demodata field
  }
  else {
    g_gameInputCmds = 0xffffffff;
  }
  if (g_gameInputCmds != 0xffffffff) {
    g_demoDataIndex= g_demoDataIndex+ 1;  // moves demodata to the entity camera / position information
  }
  return;
}

void xGameDemoSetCurrentEntity(void)

{
  short height;
  tr1_room_sector *pSector;
  short room;
  tr1_entity *pEnt;
  
  pEnt = g_pCurrentEntity;
  g_pCurrentEntity->x = g_pDemoData[0];
  pEnt->y = g_pDemoData[1];
  pEnt->z = g_pDemoData[2];
  pEnt->rotateY = *(short *)(g_pDemoData + 3);
  pEnt->rotateX = *(short *)(g_pDemoData + 4);
  pEnt->rotateZ = *(short *)(g_pDemoData + 5);
  room = *(short *)(g_pDemoData + 6);

  if (pEnt->Room != room) {
    GameSetEntityItemRoom(g_currentEntityIndex, room);
  }

  pSector = GameClipToRoom(pEnt->x,pEnt->y,pEnt->z,&room);
  height = GameGetHeight(pSector,pEnt->x,pEnt->y,pEnt->z);
  g_pCurrentEntity.height = height;

  g_demoDataIndex = g_demoDataIndex + 7;  // increment demodata index to next flags field for GameDemoRunTimer()

  return;
}

/* structure definition 

struct tr_demodata
    int32_t flags; 
    struct tr_demodata_entitypos
    {
        int32_t x;
        int32_t y;
        int32_t z;
        int16_t rotX;
        int16_t reseverved1; // alignment padding
        int16_t rotY;
        int16_t reseverved2;
        int16_t rotZ;
        int16_t reseverved3;
        int16_t roomId;
        int16_t reseverved4;
    }
}

*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant