Sonic Adventure Save File Format

This document contains the format of the Sonic Adventure save file, SONICADV_INT. This file is stored on a Sega Dreamcast Visual Memory Unit when playing the game Sonic Adventure. The file saves the position of the game as well as the high scores. I currently know the format for the high scores and other information, but have not yet discovered the format of most of the saved game data.

Note: This information was obtained using a US version of Sonic Adventure.

Contents of SONICADV_INT
Contents of a file slot
References


Contents of SONICADV_INT

SONICADV_INT is 5120 bytes and contains three file slots as follows.

offsetlengthcontent
 $0000  1152VM file header
 $0480  1184File slot - "File 1"
 $0920  1184File slot - "File 2"
 $0DC0  1184File slot - "File 3"
 $1260   416(unknown)
offsets are in hexadecimal from the beginning of the save file. lengths are the number of bytes in decimal.

For information about the VM file header, refer to VMS File Header by Marcus Comstedt.

The file slots contain the information for Files 1, 2, and 3 as listed on the 'Select a File' screen from within the game. The format for a file slot is described below.

Contents of a file slot

Each file slot is 1184 bytes and contains the following information.

offsetlengthdata type          content
  $000     44-byte integer     CRC (only LS 16 bits used)
  $004     44-byte integer     Play time (in 60ths of a second)
  $008   1284-byte integers    Action Stage - Best Scores
  $088    843-byte time codes  Action Stage - Best Times
  $0DC    242-byte integers    Action Stage - Best Weights (in tens of grams)
  $0F4    164-byte integers (?)(unknown)
  $104    642-byte integers    Action Stage - Best Rings
  $144   1084-byte integers    Mini Game - Best Scores
  $1B0   1443-byte time codes  Mini Game - Best Times
  $240    17--                 (unknown)
  $251     1bit-flags          Options
  $252     61-byte integers    Lives
  $258  4520--                 (unknown)
offsets are in hexadecimal from the beginning of the file slot. lengths are the number of bytes in decimal.

All integers are stored in little endian order.
All (?) integers are stored as signed values, but only non-negative values make sense.

CRC

offsetlengthdata type          content
  $000     44-byte integer     CRC (only LS 16 bits used)

Although the CRC is stored as a 4-byte integer, it is only a 16-bit value.
The CRC is calculated over the remaining bytes of the file slot using the following C code:

unsigned int calcCRC(const unsigned char *buffer, int size)
{
  unsigned int byte, bit, remainder;

  remainder = 0xFFFF;
  for (byte = 0; byte < size; ++byte)
  {
    remainder ^= buffer[byte];
    for (bit = 0; bit < 8; ++bit)
    {
      if (remainder & 0x0001)
        remainder = (remainder >> 1) ^ 0x8408;
      else
        remainder = (remainder >> 1);
    }
  }

  remainder ^= 0xFFFF;
  return remainder & 0xFFFF;
}

Play Time

offsetlengthdata type          content
  $004     44-byte integer     Play time (in 60ths of a second)

The total play time (as shown on the 'Select a File' screen) is stored in units of 60ths of a second.

Action Stage - Best Scores

offsetlengthdata type          content
  $008   1284-byte integers    Action Stage - Best Scores

For each stage, the best score is stored.
The order of the stages is as follows:

playerstage
Sonic1 - Emerald Coast
2 - Windy Valley
5 - Twinkle Park
6 - Speed Highway
7 - Red Mountian
8 - Sky Deck
9 - Lost World
4 - Ice Cap
3 - Casinopolis
10 - Final Egg
Tails1 - Windy Valley
5 - Speed Highway
4 - Sky Deck
3 - Ice Cap
2 - Casinopolis
Knuckles1 - Speed Highway
3 - Red Mountain
5 - Sky Deck
4 - Lost World
2 - Casinopolis
Amy1 - Twinkle Park
3 - Final Egg
2 - Hot Shelter
E-1022 - Emerald Coast
3 - Windy Valley
4 - Red Mountain
1 - Final Egg
5 - Hot Shelter
Big3 - Emerald Coast
1 - Twinkle Park
2 - Ice Cap
4 - Hot Shelter

Action Stage - Best Times

offsetlengthdata type          content
  $088    843-byte time codes  Action Stage - Best Times

For each stage, the best time is stored.
The order of the stages is the same as listed under the Best Scores section above.
(Note: Big's stages don't have times, but rather weights, see below.)

The times are stored in a 3-byte time code.

The fraction is converted from 60ths of a second to 100ths of a second for display purposes using the following formula [?]

display = (value * 1666) div 1000
where div is an integer division.

Action Stage - Best Weights

offsetlengthdata type          content
  $0DC    242-byte integers    Action Stage - Best Weights (in tens of grams)

For each of Big's stages, the best three weights are stored, highest to lowest. (Three weights are stored, but only the best weight appears in the Trial menu.)
The order of the stages is the same as listed under the Best Scores section above.
Each weight is stored as a 2-byte integer, but the unit is in tens of grams. For example, a stored value of 50 corresponds to 500 g.

Action Stage - Best Rings

offsetlengthdata type          content
  $104    642-byte integers    Action Stage - Best Rings

For each stage, the best number of rings is stored.
The order of the stages is the same as listed under the Best Scores section above.

Mini Game - Best Scores

offsetlengthdata type          content
  $144   1084-byte integers    Mini Game - Best Scores

For each of the mini games below, the best three scores are stored, highest to lowest.
The order of the mini games is as follows:

playermini game
SonicSky Chase 1
TailsSky Chase 1
SonicSky Chase 2
TailsSky Chase 2
SonicIce Cap
TailsIce Cap
SonicSand Hill
TailsSand Hill
AmyHedgehog Hammer

Mini Game - Best Times

offsetlengthdata type          content
  $1B0   1443-byte time codes  Mini Game - Best Times

The times are stored as a three-byte time code as explained in the Action Stage - Best Times section above.

For each of the Twinkle Circuits, five times are stored.
The first three times are the best three times for this player, shortest to longest.
The last two times are the lap checkpoints for the best time. (See below.)

For each of the Boss stages, the best three times are stored, shortest to longest.

The order of the mini games is as follows:

playermini game
SonicTwinkle Circuit
TailsTwinkle Circuit
KnucklesTwinkle Circuit
AmyTwinkle Circuit
E-102Twinkle Circuit
BigTwinkle Circuit
SonicBoss
TailsBoss
KnucklesBoss
AmyBoss
E-102Boss
BigBoss

Lap checkpoint times

For each Twinkle Circuit stage, two lap checkpoint times are stored which go along with the first (best) time stored for that player.
The lap checkpoint times are the times the stopwatch read when the player finished Lap 1 and Lap 2.
The game uses these to display the elapsed time for each lap using the following calculations:

(Lap 1 elapsed time) = (checkpoint 1 time)
(Lap 2 elapsed time) = (checkpoint 2 time) - (checkpoint 1 time)
(Lap 3 elapsed time) = (best total time) - (checkpoint 2 time)

Options

offsetlengthdata type          content
  $251     1bit-flags          Options

The options are stored in a bit-field as follows:

bits
76, 5, 43, 210
zeroText LanguageVoice LanguageMessage Settingszero

Text Language

Controls the language of the subtitles.

valuelanguage
001Japanese Text
010English Text
011French Text
100Spanish Text
101German Text

Voice Language

Controls the language of the vocal dialog, menus, and instruction screens.

valuelanguage
01Japanese Voice
10English Voice

Message Settings

Turns the subtitles on or off.

valuesetting
0Voice and Text
1Voice Only

Lives

offsetlengthdata type          content
  $252     61-byte integers    Lives

For each player, one byte is stored indicating their number of lives. The order of the players is:
Sonic, Tails, Knuckles, Amy, E-102, Big.

References

VMS File Header from Dreamcast Programming by Marcus Comstedt

This document provides the details of the file header present in every Visual Memory file. It also helped by providing me a basic CRC algorithm.

A Painless Guide to CRC Error Detection Algorithms by Ross N. Williams

I used this document to learn enough about CRC algorithms to detect which one the save file was using.

Home > Articles > Sonic Adventure Save File Format

Robert Hart
Updated Aug. 22, 2008