Save file format

This page describes the format of the Kbb.dat save file and PhotoFxx.dat/PhotoPxx.dat files.

## Kbb.dat

### Faces informations

You can save up to 49 faces in the game, there's 49 slots in the save file, each one being 64 bytes long, for a total of 3136 bytes. They are stored at 0x0000 to 0x0C3F in the save file. Each slot uses a file with the face image stored in, called PhotoFxx.dat, xx representing the slot number, which is zero-based, so it goes from 00 to 48.

Every face has an unique ID, it ranges from 10 to 4294967295. IDs from 0 to 9 are reserved for UFO crew faces. Trying to use an ID from 0 to 9 will show the face has the dummy face if there's no face with that ID in the UFO crew, or show a face from the UFO crew with the same ID.

The age is stored with set values:

* 0 - Baby
* 1 - Child
* 2 - Young
* 3 - Adult
* 4 - Older adult
* -1 - Not set

The gender is stored with set values too:

* 0 - Male
* 1 - Female
* -1 - Not set

The faces are sorted by their ID. The face with the lowest ID will be the first face in the Face Collection.

### Best score data

There's 10 slots in the save file storing your best scores. They are stored at 0x0C40 to 0x0DF7 in the save file. Each slot is reserved for a stage in the following order:

* Stage 1
* Stage 2
* Stage 3
* Final Stage
* Bonus Stage
* Extra Stage
* Show a Friend Stage 1
* Show a Friend Stage 2
* Show a Friend Bonus Stage
* First time playing Face Raiders

The tenth and last slot is reserved for a duplicate of Show a Friend Stage 1, which you play if it's the first time you ever play Face Raiders. Once you finish the level, your first score is saved to this slot and you will never play this stage again. The real Show a Friend Stage 1 saves to the seventh slot.

The games uses IDs to identify faces.

The stored scores can exceed 999,999, the maximum score the game allows you to get. When loaded, if they exceed 999,999, they will be displayed as 999,999 and during saving, the game will overwrite these scores with 999,999.

This also applies to the max combo, which has a limit of 99 allowed by the game.

### UFO crew faces

There's 10 slots for UFO crew faces. Each one being 40 bytes long, for a total of 400 bytes. They are stored at 0x0DF8 to 0x0F87 in the save file. Each slot uses a file with the face image stored in, called PhotoPxx.dat, xx representing the slot number, which is zero-based, so it goes from 00 to 09.

Most of the data here is still undocumented.

 0x10
 0x24

Each face in UFO crew has an unique ID, it ranges from 0 to 9.

### General parameters

This is a long section. Click show or hide at the right of this template to display or hide the text.

**0x10C8 (bool) -** The game will make UFOs appear in stages if true.

**0x10C9 (byte) -** This is the stage where the UFOs will appear, in the following order:

* Stage 1 (0)
* Stage 2 (1)
* Show a Friend Stage 1 (2)
* Stage 3 (3)
* Final Stage (4)

**0x10CC (u32) -** The next ID the game will give to a face will is stored here.

**0x10D0 (u32) -** The next ID the game will give to a UFO crew face will is stored here.

**0x10E8 (u32) -** Number of friend faces (shown in Show a Friend)

**0x10EC (u32) -** Last title screen scene unlocked, max value is 20.

**0x10F0 (u32) -** This is the last scene that was played. When the game starts, the scene after the one stored in this value will be played.

**0x10F8 (bool) -** If true, sneaky snaps will be enabled.

**0x1100 (bool) -** The game will show the Face Collection if this value is true. If it isn't, you won't have the ability to go in Face Collection.

**0x1103 (bool) -** Unlocks Stage 2.

**0x1105 (bool) -** Unlocks Stage 3.

**0x1106 (bool) -** Unlocks Final Stage.

**0x1107 (bool) -** Unlocks Bonus Stage.

**0x1108 (bool) -** Unlocks Extra Stage.

**0x1109 (bool) -** Unlocks Show a Friend Stage 2.

**0x110A (bool) -** Unlocks Show a Friend Bonus Stage.

**0x110B (bool) -** Unlocks Show a Friend Stage 1

**0x110D (bool) -** Unlocks the ability to select a face before playing Stage 1.

**0x110E (bool) -** Unlocks the ability to select a face before playing Stage 2.

**0x110F (bool) -** Unlocks the ability to select a face before playing Stage 3.

**0x1110 (bool) -** Unlocks the ability to select a face before playing Final Stage.

**0x1128 (bool) -** Shows a red arrow on main menu. This is the arrow you see when you start the game when your save is empty, initialized.

**0x112A (bool) -** If false, Face Collection shows "NEW" and the UFO is absent.

**0x112B (bool) -** If false, the game shows an animation that the Stage 2 is unlocking.

**0x112C (bool) -** If false, the game shows an animation that the Stage 3 is unlocking.

**0x112D (bool) -** If false, the game shows an animation that the Final Stage is unlocking.

**0x112E (bool) -** If false, the game shows an animation that the Bonus Stage is unlocking.

**0x112F (bool) -** If false, the game shows an animation that the Extra Stage is unlocking.

**0x1130 (bool) -** If false, the game shows an animation that the Show a Friend Stage 2 is unlocking.

**0x1131 (bool) -** If false, the game shows an animation that the Show a Friend Bonus Stage is unlocking.

**0x1132 (bool) -** This value is false when you haven't seen the UFO at least once. Once you enter the Face Collection, the game will tell you who the UFO is.

**0x1134 (bool) -** If false, the game shows an animation that the Show a Friend Stage 1 is unlocking.

**0x113A (bool) -** If false, when selecting a stage, the arrow to select a face will play an animation, used when you haven't used that functionality yet.

**0x113B (bool) -** If false, the button to access Show a Friend stages shows "NEW".

**0x113C (bool) -** If false, the game shows an animation that the Stage 1 is unlocking.

**0x1144 (bool) -** If false, the UFO in Face Collection will say "NEW".

**0x1146 (bool) -** If false, the button to access Face Collection shows "NEW".

**0x1147 (bool) -** Unlocks the ability to use sneaky snaps.

### CRC check

To validate the file, the game computes a CRC32 checksum using **0x0000** to **0x1587**, and will be placed at **0x1588** in **Kbb.dat**.

## PhotoFxx.dat and PhotoPxx.dat

Both use the same format. PhotoFxx.dat are used by saved faces, and PhotoPxx.dat files are used by UFO crew faces.

### Data structure

 0x0004
 0x8004

The file stores the face image starting at **0x0004** to **0x8003**, the image has a resolution of 128x128, and the pixel format is RGB565.

If you try to put the pixel data in a bitmap image, the pixels will look scrambled. They are like that because that's how the PICA (the 3DS GPU) sorts them. To convert to a bitmap or PNG image, you need to unscramble the pixels.

### Unscrambling the pixels

The image is divided in 8x8 cells, you need to create a look-up table to sort the pixels:

For each pixel in the 8x8 cell, get the pixel from the raw image specified by the look-up table then put it at the out image pixel with the same number as the current index, do that 64 times.

After that, increate the X cell index by 1, repeat the cell unscrambling process until the X cell index is 16, then reset it to 0 and increment Y cell index by 1. Repeat the processes again, until the Y cell index is at 16, every cell has been processed, the pixel unscrambling process is done.