More info on MAPS.BSA needed

A place to discuss and ask questions about the second part of The Elder Scrolls series
Post Reply
Sephiroth
Layman
Layman
Posts: 8
Joined: Wed Oct 11, 2006 6:53 pm
UESPoints: 0
Location: Elizabethtown, NC

More info on MAPS.BSA needed

Post by Sephiroth »

I'm working on an online version of Daggerfall using my Daggerfall GL (DFGL) engine, and have come to a stop at the MAPS.BSA file. I've got the file formats information, but one part is unclear and is preventing me from moving forward with the project.

My engine can currently read and even precache the directories in the MAPS.BSA archive, but then I get to the data after the four-byte header at the top of the file. The information I have says that the first thing I encounter is a list of long values which are offset pointers to the location data. The thing is, at this point I don't know how many locations are contained in that region, so how do I know how many long values to read in?

I had thought about reading one long value, jumping to that offset and reading in the locational data, then jumping back to the start of the file plus four bytes for the header and an additional four bytes for every offset I have read, but after I get so many locations read, I'll jump into the first location instead of a four-byte long value. How would I determine the number of locations so I can read in that many pointers, and then how would I do the same for the dungeons? Thanks in advance.
Image
Sephiroth
Layman
Layman
Posts: 8
Joined: Wed Oct 11, 2006 6:53 pm
UESPoints: 0
Location: Elizabethtown, NC

Post by Sephiroth »

Alright, either this forum just isn't viewed, or nobody knows anything about C++. I'm going to post my current region-loading method. It works up to the point of reading in the pointers, but since there is no way to figure out how many pointers there are, I am stumped.

Code: Select all

Region* BSAData::LoadMapItem(char *pResource)
{
  long lOffset;
  Region *pRegion;

  if(strlen(pResource) > 14)
  {
    pLog->Write("Warning: Attempted to load a map resource with a filename longer than 14 characters");
    return NULL;
  }

  lOffset = 0; //Offset of our region data relative to the top of the file
  for(long lResID = 0; lResID < sDirCount; lResID++)
  {
    if(strncmp(pLongDir[lResID]->pFilename, pResource, strlen(pResource)) == 0)
    {
      lOffset += 4; //This is our region, so add four bytes for the BSA header and break the loop
      break;
    }

    lOffset += pLongDir[lResID]->lDataSize; //Since this wasn't our region, add it's size to our offset
  }

  if((pRegion = (Region*)malloc(sizeof(Region))) == NULL)
  {
    pLog->Write("Warning: Failed to allocate memory for a region structure");
    return NULL;
  }

  fseek(pFile, lOffset, SEEK_SET); //Jump to the start of our region data
  //Now we need to read in an unknown number of offset pointers
  //After that we read in the records based on the pointers

  return pRegion;
}
If anybody can figure this out, let me know. This is my only major hold-up in a working engine for Daggerfall.
Image
User avatar
Magnus
Initiate
Initiate
Posts: 33
Joined: Sun Feb 19, 2006 12:56 am
ES Games: Arena through Oblivion, spinoffs and mobile included
Platform: PC
Status: Vaguely here once a year
Location: Nova Scotia, Canada.
Contact:

Post by Magnus »

Hey, this is really neat what your doing and I hope it gets finished, an online port in opengl for Daggerfall would be... different.

However, you're probably not going to find much information on this site about the fileformat, or much help on the matter here since it seems most of the forums population like the newer games more. But! There is hope, you could try signing up at the Daggerfall Workshop and asking there, I'm almost 100% sure that you'll be able to get the help you need there, since most of the people who decoded it are probably there. :)
Visit my personal website, or perhaps one of my many hobby sites.
User avatar
Quiglesigles
Warder
Warder
Posts: 562
Joined: Mon Nov 06, 2006 11:58 am
UESPoints: 0
Location: Owning at fight pits

Post by Quiglesigles »

yea that is a really cool idea. i do know c++ but i can't help you.
Image
Sephiroth
Layman
Layman
Posts: 8
Joined: Wed Oct 11, 2006 6:53 pm
UESPoints: 0
Location: Elizabethtown, NC

Post by Sephiroth »

I have a version up and running now. I am still having issues with the BSA file format, but used tools to extract the data I needed and have a semi-working engine now. I have it on Google Video now, but Google ruins it by trying to run it in a huge resolution. If you watch it, click on the down-arrow in the lower-right of the player and choose "double size". You can find the video by searching for "DaggerfallGL".
Image
Post Reply