Garhoogin / NitroPaint

General Purpose DS Sprite, BG, and Texture Editor
BSD 2-Clause "Simplified" License
61 stars 5 forks source link

Trouble with Files from LEGO Battles #3

Closed opiter09 closed 2 years ago

opiter09 commented 2 years ago

I am attempting to use this wonderful program to look at files from the game "LEGO Battles" (https://en.m.wikipedia.org/wiki/Lego_Battles). NCLR Palette files open perfectly. However, NCGR and NCBR almost universally will not load at all, I double-click on them and then literally nothing happens. If I then try to open the same-named NCER and NANR files (many of them don't have these, but I'm gonna ignore those because from what I've read that is an unusual setup), they open fine, but the windows report that there is nothing--no objects anywhere, and no frames beyond 00 which has no picture, respectively. I do appreciate that this is a niche game, and I would not be surprised if this is the result of me doing something wrong somehow, but I would appreciate any time at all you could expend on this.

PS: This game also has "nsbmd" files, they seem to open perfectly.

Garhoogin commented 2 years ago

Hello,

thanks for the appreciation, it means a lot :) For the issue of NCGR and NCBR files not opening, have you tried drag+dropping them onto the program window? To see anything in the NCGR and NCBR viewer you do also need to have an NCLR loaded at the same time. As for the NCER and NANR files, those I would need to take a closer look at. For those that don't have an associated NCER, do they have an NSCR? An NCBR shouldn't need one, but an NCGR might. It should also be noted that NitroPaint does not edit the model (MDL0) part of the NSBMD, just the textures (TEX0).

Hope this helps!

opiter09 commented 2 years ago
  1. Drag and Drop does not seem to help.
  2. I should clarify this--when I open the game's NCGR files, I literally do not get the viewer to appear. Absolutely nothing happens, NCLR loaded or no.
  3. There are occasional NSCR's, but nowhere near as many as the other types. But then again I'm pretty new to this, I am unsure if an NSCR can be associated to multiple files of different names or something.
Garhoogin commented 2 years ago

I just took a look at some files from the LEGO Battles game, and I can see the problem you're having. It seems many of the files in the game seem to have some compression header before the NCGR header, I haven't seen one that looks like that before. Looks to be the bytes "PMOC", the uncompressed size, some 4-byte field, 4-byte compressed data size (twice?), followed by the compressed contents. I imagine this is done because the graphics files aren't stored in any compressed archive, so this was how they were compressed. This is something that I can add support for in the next release hopefully. Sorry for the inconvenience!

opiter09 commented 2 years ago

Thank you for looking into this! I sure know I wouldn't have been able to figure any of that out.

acemon33 commented 2 years ago

Thanks very very much for such a nice tool,

In the case of digimon story lost evolution, ncgr, nclr & nanr can open well but it cannot open ncer properly, the grachpics cells are scattered around

The same files can be opened nicely with Console Tool but cannot save

Garhoogin commented 2 years ago

Hello, sorry to hear that the NCER files aren't showing properly. I'm suspecting perhaps the graphics are 8bpp, because there is an issue in the current build that impacts the ability to properly render cells for 8bpp sprites. This was fixed in a recent commit however, so hopefully that will solve the problem for you when it is released, which I may do soon. Sorry for any inconvenience caused in the meantime.

acemon33 commented 2 years ago

Hello, sorry to hear that the NCER files aren't showing properly. I'm suspecting perhaps the graphics are 8bpp, because there is an issue in the current build that impacts the ability to properly render cells for 8bpp sprites. This was fixed in a recent commit however, so hopefully that will solve the problem for you when it is released, which I may do soon. Sorry for any inconvenience caused in the meantime.

Thanks Mr. We look forward to the new release

Garhoogin commented 2 years ago

An update to the lego battles thing, I was wrong, the compression looks to be LZ11 which I'll need to implement first. And some files have bigger compression headers than others, so that is also something I'll need to look into.

opiter09 commented 2 years ago

Well, take all the time you need on this, the game isn't going anywhere lol. Again, thanks for responding and looking into this.

Garhoogin commented 2 years ago

I started looking more closely at the more complex files, and it seems like they broke up the file into multiple separate compressed chunks. As of now I'm unsure of why they do that, maybe so they can more easily pick and choose segments of the file to actually load. The maximum length of a compressed run looks to be 0x1000 bytes, based on what they seemed to do. It looks that at offset 0xC holds the size of the largest compressed run, perhaps so some buffer can be allocated to hold any compressed segment in the file. So in total, the structure of the file looks to be:

Offset    Size    Meaning
0x00      0x4     Magic 'COMP' bytes
0x04      0x4     Total uncompressed file size
0x08      0x4     Number of compressed segments
0x0C      0x4     Size of largest compressed run
0x10      ...     Array of compressed segment sizes
...       ...     Compressed segments
opiter09 commented 2 years ago

Fascinating!

Garhoogin commented 2 years ago

I've finished up code for handling the Lego Battles files, can read and write them. I think all is well for that, so for now I'll close the issue, but feel free to reopen if you have problems in the future.