# 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
873
Replies
1
Views
3K
Replies
0
Views
3K
Replies
0
Views
337
Replies
0
Views
2K

1. 23K 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. 20K views

## Mario Builder 64 is the N64's answer to Super Mario Maker

With the vast success of Super Mario Maker and its Switch sequel Super Mario Maker 2, Nintendo fans have long been calling for "Maker" titles for other iconic genres...
4. 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...
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. 14K 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...
8. 12K 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...
9. 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...
10. 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...
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. 131 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. 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...
4. 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...
5. 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...
6. 86 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. 82 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...
8. 79 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...
9. 66 replies

## Mario Builder 64 is the N64's answer to Super Mario Maker

With the vast success of Super Mario Maker and its Switch sequel Super Mario Maker 2, Nintendo fans have long been calling for "Maker" titles for other iconic genres...
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...

## Project Help with My Pokemon Ranch Project

### Recent Content

12. #### rg35xxsp

Help Users
• @ BakerMan:
New Zelda game starring Zelda, Ace Attorney Investigations collection, meaning finally AAI2 is coming to the west, and this part is huge...
• @ BakerMan:
METROID PRIME 4 AND A NEW MARIO AND LUIGI GAME
• @ Xdqwerty:
@BakerMan, i didnt watch it cuz idc cuz i don't have a switch if you ask
• @ Xdqwerty:
ik i'm retarded
• @ BakerMan:
me neither dude
• @ Xdqwerty:
@BakerMan, then why did you care?
• @ BakerMan:
also there's a new fuckin LOTR game that's kinda like Animal Crossing I guess
• @ Psionic Roshambo:
I need a Lord of the rings game like that lol
• @ Xdqwerty:
Can I ask you guys something?
• @ Xdqwerty:
Nvm it's too awkward
• @ AncientBoi:
Xdqwerty pull on my finger quick
• @ AncientBoi:
party pooper [farrrrrrrrrrrt]
• @ Xdqwerty:
@AncientBoi, no, you were pooping in the party
+1
• @ Psionic Roshambo:
Fer shizzle lol
+2
• @ BakerMan:
btw qwerty, the AAI collection isn't only going to be on switch
• @ Xdqwerty:
@BakerMan, Yea but i bet my PC isnt gonna be able to run it
• @ Psionic Roshambo:
Switch to Nintendo!
• @ Psionic Roshambo:
The commercial, a transexual person walks into the club, techno music is playing loudly. The trans person pulls out a Nintendo switch, turns around revealing that their clothes are mens on one side and women's clothes on the other. "Don't fear the Switch"
+1
• @ Psionic Roshambo:
Controversy ensues, sales and publicity!
+1
• @ Xdqwerty:
@Psionic Roshambo, and retroactively the internet's praise
+1
• @ Xdqwerty:
I wanna wear a skirt
+1
• @ AncientBoi:
Especially in summers
@ AncientBoi: Especially in summers