# ROM HackBit-related question about .NCGR and .NCLR files

#### Nowa

##### New Member
OP
Newbie
Hello everyone, it's my first post here. I've been recently playing around with nds games extraction and more particularly Lego Battles, a game dear to me. So much good memories during my childhood!

Anyway, I've read documentation about basic extractions using tools like Tinke and CT2. So far so good, I successfully managed to extract many assets like ost, 3d models, sprites, palettes...

Out of curiosity, I've analyzed the raw data in NCGR and NCLR files of the game to compare theory to practice (theory being the documentation on romhacking net about nds formats) and something caught my attention. To explain myself, please refer to this picture first:

In the upper part of the picture, we can see I exported the sprite on a grid of 8px of space. The last line of the sprite being one single color (let's call it color1), we can easily found the corresponding bytes in the file (n.b.: in the picture I removed header and information from the file to keep only the DATA). Now in the lower part of the picture, we can observe one patter repeating itself 3 times on the file. The pattern is composed as follow: 1x color1, 6x color6 and 1x color1 (color6 being the black pixels). The file has a tile bit depth of 4 bits btw.

When comparing the pattern with the corresponding bytes (0x50555550), my only conclusion is that one byte contains color for 2 pixels in a row (which is normal bc the palette has 16 colors and 2 pixels can fit in 1 byte) but not in the correct order. e.g.: the two first pixels of the pattern (color1 and color6) are stored as 0x50 which, if we cut the byte by 2, is 5 and 0 in decimal. That's exactly the 1st and the 6th colors of the palette.

So first question: why are the bits not arranged in a logical order ? (why do we have to make an inversion ?)

My second point is basically of the same nature as my first observation. This time it concerns the palette (NCLR file). Again, a picture to support my explanation:

On the upper left, a representation of the full palette and the raw file on the right side. Same proceeding as previous point: find a frequently repeated pattern and its bytes. Here, we see that color are stored in 2 bytes. Let's take the very first pixel (the green one) that is present on many lines and its 8bit color code (#087030). Now let's take the value as encoded in the file (0xC119). If we invert the two bytes and group the bits 5 by 5 as illustrated, we can make a link with the 8bit color code. We can observe that the color depth of the palette is 5bit, which explains the division by 8 for the RGB value (proof: 2⁸ / 2⁵ = 2³ = 8).

My second question is the following: again, why do we make an inversion with the two bytes ?

All this reasoning may seem pointless but I prefer to explain myself clearly before asking questions. I'm really sorry if I didn't make myself clear enough or if my post is a bit too long, but again it's just because I'm curious on how things work. I attached the files for those who are interested.

TL;DR: given the color depth of the palette (5bit), is it normal that colors encoded in the NCLR file and pixel in the NCGR one are "reversed" ? If not, is that some liberty that the studio that developed the game could have taken ?

#### Attachments

• files.zip
1.3 KB · Views: 28

#### Nowa

##### New Member
OP
Newbie
wow that explains a lot, it all makes sense now! Thx for your answer

Replies
0
Views
879
Replies
1
Views
3K
Replies
0
Views
3K
Replies
0
Views
345
Replies
0
Views
2K

1. 28K views

## Modders hint at potential kernel exploit hack for Xbox One consoles

It's been a while since Microsoft released the Xbox One, and despite its age, there haven't been any reliable softmod methods to hack the console. Until now. A post...
2. 22K views

## Majora’s Mask PC port 2Ship2Harkinian gets its first release

After several months of work, the Harbour Masters 64 team have released their first public build of 2Ship2Harkinian, a feature-rich Majora's Mask PC port. This comes...
3. 18K views

## The founder of Oculus is releasing a \$199 FPGA Game Boy system

Palmer Luckey is known for his pursuits into the world of virtual reality, having founded Oculus and designed the Rift VR headset. Prior to the \$2 billion dollar...
4. 16K views

## Doom for SNES full source code released by former Sculptured Software employees

The complete source code for the Super Nintendo Entertainment System (SNES) version of Doom has been released on archive.org. Although some of the code was partially...
5. 16K views

## Nintendo takes down the Breath of the Wild randomizer mod from Gamebanana

Another day, another Nintendo DMCA takedown against fan-made content. Just a few minutes ago, Nintendo issued a DMCA takedown notice against a widely known and...
6. 15K views

## The Kingdom Hearts games are coming to Steam

After a little more than three years of exclusivity with the Epic Games Store, Square Enix has decided to bring their beloved Kingdom Hearts franchise to Steam. The...
7. 13K views

## Select PlayStation 2 games are coming to PlayStation 5

Sony is once more attempting to reintroduce players to their older library of games by re-releasing classic PlayStation 2 titles onto the PlayStation Store. During...
8. 12K views

## Skyward Sword HD randomizer announced with release date and trailer

Skyward Sword is a divisive title in the Zelda series. Hailed with praise at launch with a 93 Metacritic average, the game since received criticism for the...
9. 10K views

## PlayStation State of Play May 2024 showcase - God of War: Ragnarok coming to PC

The latest State of Play is here. This is PlayStation's Summer showcase, providing updates to new updates on upcoming games and brand new reveals. The 35-minute...
10. 10K views

## Give-away Win a RG35XX SP Retro handheld with KeepRetro.com

We're super excited to announce that we have one of the new RG35XX SP retro emulation handhelds to give away to one lucky GBAtemp member! If you haven't checked out...
1. 169 replies

## The founder of Oculus is releasing a \$199 FPGA Game Boy system

Palmer Luckey is known for his pursuits into the world of virtual reality, having founded Oculus and designed the Rift VR headset. Prior to the \$2 billion dollar...
2. 132 replies

## Modders hint at potential kernel exploit hack for Xbox One consoles

It's been a while since Microsoft released the Xbox One, and despite its age, there haven't been any reliable softmod methods to hack the console. Until now. A post...
3. 123 replies

## Nintendo Direct - June 18, 2024 - new Mario Party, Mario & Luigi game, and more

That's right! It's time for the Summer showcase you've all been waiting for. A Nintendo Direct is about to air, bringing us 40 minutes of Nintendo Switch content. The...
4. 108 replies

## Majora’s Mask PC port 2Ship2Harkinian gets its first release

After several months of work, the Harbour Masters 64 team have released their first public build of 2Ship2Harkinian, a feature-rich Majora's Mask PC port. This comes...
5. 106 replies

## Nintendo takes down the Breath of the Wild randomizer mod from Gamebanana

Another day, another Nintendo DMCA takedown against fan-made content. Just a few minutes ago, Nintendo issued a DMCA takedown notice against a widely known and...
6. 92 replies

## Nintendo Direct announced for tomorrow, June 18th, 2024

Nintendo have officially announced a Nintendo Direct for tomorrow, June 18th. The show will focus on Switch titles releasing this year and they have explicitly...
7. 91 replies

## The Kingdom Hearts games are coming to Steam

After a little more than three years of exclusivity with the Epic Games Store, Square Enix has decided to bring their beloved Kingdom Hearts franchise to Steam. The...
8. 88 replies

## Metroid Prime 4 gets new trailer, releases next year

After all the waiting, Metroid Prime 4 has finally gotten a new trailer. A two-minute teaser shows off some long-awaited gameplay, and the visuals. The game also now...
9. 84 replies

## Select PlayStation 2 games are coming to PlayStation 5

Sony is once more attempting to reintroduce players to their older library of games by re-releasing classic PlayStation 2 titles onto the PlayStation Store. During...
10. 64 replies

## PlayStation State of Play May 2024 showcase - God of War: Ragnarok coming to PC

The latest State of Play is here. This is PlayStation's Summer showcase, providing updates to new updates on upcoming games and brand new reveals. The 35-minute...

## Hardware Visual DSi Diagnostic Guide

### Recent Content

12. #### Hello Everyone

Help Users
• No one is chatting at the moment.
• @ K3Nv2:
@Sicklyboy, 3ds batteries are fairly cheap just don't overspend on oem
• @ Sicklyboy:
Yeah I just like this massive extended battery lol
• @ K3Nv2:
Lol length
• @ K3Nv2:
I remember those psp batteries that came with bulged psp battery covers
• @ Sicklyboy:
my PSP battery started swelling up AGES ago
• @ Sicklyboy:
As in I got rid of the battery when I noticed
• @ K3Nv2:
People were hacking batteries just to cfw them
I got blocked.
That's perfect.
Anyway. I'm playing Dragon Ball Adventures from GBA.
I got stuck in some part.
Anyone played that game?
• @ Sicklyboy:
Only one I played was the DBZ trading card game game on the GBA
• @ K3Nv2:
Sparking zero is looking pretty good but not \$70 good
okay
• @ BakerMan:
isn't sparking zero supposed to be accurate to their canon power too?
• @ BakerMan:
meaning unlike dbfz a weaker character like nappa wouldn't stand a chance against someone stronger like broly
• @ BakerMan:
aaalllright then, i guess i should hit the hay
• @ K3Nv2:
People are complaining about flying in it I'm like wut that's half of what it is
+1
• @ BigOnYa:
Surprise surprise, @HiradeGirl is back today
• @ BigOnYa:
Alright @SylverReZ you win, lets go double or nothing.
@ K3Nv2: https://youtube.com/shorts/WUOq1dlZWxI?si=LBlEJwZfwtWShljP lol Denmark can't handle the spice