Understanding the Basics
* LZ Compression: GBA ROMs frequently use LZ77 compression, which compresses data efficiently. "unLZ-gba" is a tool designed to decompress LZ77-compressed data within GBA ROMs.
* Image Indexing: The "index" in this context refers to a way to map the compressed data within the ROM to its corresponding location within a larger image. This helps the decompression tool find the correct data.
Steps to Index an Image for unLZ-gba
1. Determine Compression: Ensure the image data within your ROM is actually LZ-compressed. You'll need to consult documentation, analyze the ROM structure, or use tools that detect LZ77 compression.
2. Locate the Compressed Data: Identify the exact location within the ROM where the image's compressed data resides. This usually involves looking at the ROM header or using tools to analyze the structure.
3. Create an Index File: You'll need to create a text file that acts as an index. This file tells "unLZ-gba" the following:
* ROM Offset: The starting location of the compressed image data within the ROM.
* Image Dimensions: Width and height of the original image.
* LZ77 Header: If the compressed data includes an LZ77 header, you might need to include this information in the index file as well.
Example Index File:
```
romoffset=0x08000000
width=256
height=192
```
Using "unLZ-gba" with the Index
1. Prepare the ROM: Make a copy of your original ROM file, as "unLZ-gba" may modify it.
2. Run "unLZ-gba": Execute the "unLZ-gba" command line tool with the following parameters:
```
unLZ-gba -i index.txt -o output.bmp rom.gba
```
* `-i index.txt` - The path to your index file.
* `-o output.bmp` - The name and format you want for the decompressed image.
* `rom.gba` - The path to your GBA ROM file.
Key Points:
* ROM Structure: Understanding the ROM structure of the GBA game you're working with is crucial for accurate indexing.
* Tools: Tools like "GBA Rom Tool" or "GBAExplorer" can be helpful for inspecting ROM data and identifying compression types.
* Documentation: If available, consult the documentation for the specific game or ROM to understand its data organization.
Example (GBA ROM Using LZ77 Compression):
Let's say you have a GBA ROM where the background image is LZ77-compressed, starting at address `0x08000000`, with a resolution of 256x192 pixels.
Your index file (e.g., `bg_index.txt`) would contain:
```
romoffset=0x08000000
width=256
height=192
```
You would then run:
```
unLZ-gba -i bg_index.txt -o background.bmp rom.gba
```
This would decompress the LZ77-compressed image data and save it as a BMP image named `background.bmp`.
Remember, this is a general guide. The exact steps and specifics can vary depending on the ROM and the compression scheme used.