Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Professor Layton 1 .arc image import #23

Open
MrJPGames opened this issue Dec 7, 2015 · 5 comments
Open

Professor Layton 1 .arc image import #23

MrJPGames opened this issue Dec 7, 2015 · 5 comments

Comments

@MrJPGames
Copy link

In Professor Layton and the Curious Village the images in .arc format can be viewed and exported, but the import functionality is missing.

Are there any plans on adding this functionality, and if not can someone give me the format of the file so I can try to make one myself?

Not sure this is an "issue" per se but I don't know where else to do this.

@pleonex
Copy link
Owner

pleonex commented Dec 9, 2015

This is a valid question issue so don't worry. I am glad to see people using this plugin.

I didn't implement import since nobody asked for that so I will add to the TODO list now. At the moment I am quite busy with other projects so I can't work on that right now. Below are the specification of the files in case you want to give a try. Note that there are two different file types with the same .arc extension but with different purpose: background (in bg folder) and sprite images (in ani folder).

Everything about how to deal with the images is internally handled by Tinke. We just need to create a method to parse the file (from raw bytes to some standard structs) and the reverse (from structs to bytes). As a reference, these are the files that implements read and write for the standard images types: NCLR.cs, NCGR.cs and NSCR.cs.

Compression

All the .arc files are compressed with the standard NDS compressions.

Offset Size Description
0x00 4 Compression type.
0x04 File length - 4 Start of compressed data

You can decompress the files with standard tools like CUE compressors. Tinke also implement the (de)compressor, let me know if you need help about how to use them from code.

BGR555 Color Format

The standard way to specify a color for the Nintendo DS is by using the color encoding BGR555. Two bytes define a color by three number (BGR: Blue Green Red), they are stored in the following form: XBBBBBGGGGGRRRRR where each letter is a bit (5 bits per colour), the X letter is never used (always 0). Note that Tinke contains helper methods to do conversion between this type: Ekona.Images.Actions.BGR555ToColor() and Ekona.Images.Actions.ColorToBGR555().

Background images

  • Files with extensions: .arc, .bgx or .arb.
  • Type implemented at Bg.cs
Size Section Description
4 Palette Number of colors
num_colors * 2 Palette Colors in BGR555 format.
4 Tiles Number of tiles
num_tiles * 0x40 Tiles Tile blocks. A tile is a block of 8x8 pixels. Each byte is the index of the palette color for that pixel.
2 Map Image width
2 Map Image height
width * height / 0x40 Map Map info in NTFS format (see below)

NTFS (Nintendo Tile Format Screen) data

Each structure is 16bits, that is, 2 bytes, and it contains the informations from one tile. The first structure contains the information for the first tile, the second structure for the second tile and soon... The structure has the following format (each char is a bit):

PPPP X Y NNNNNNNNNN

PPPP => Palette number (in the case of 4bpp palettes where there are more than one palette)
X => Boolean value to flip in the X axis
Y => Boolean value to flip in the Y axis
NNNNNNNNNN => Tile number modified by the above values

Tinke contains the helper method Ekona.Images.Actions.MapInfo() to convert between ushort and a NTFS struct and viceversa.

I will add later the specification for the sprites images in another comment since they are more complex.

@MrJPGames
Copy link
Author

Wow! Thank you very much! This is extremely helpful to me! To be honest I wasn't expecting any response on this and am so happy that it has happend.

I will do my best to get this done myself, but if I don't succeed I truly hope you will be able to find the time to implement this feature.

The description is very good, I already had already found some specs in the Sprite.zip (a older version that is closely related to the plugin I believe, as it was on the Tinke Google Code repo), but they were in Spanish and not nearly as clear as these (at least for someone who has to rely on Google translate).

Also thanks for the compression especially, I tried to get it working but just tried the whole file (which didn't work), so hope this info can help me (de)compress the images myself instead of thinking the plugin was just using black magic to decompress the files XD

EDIT: I was able to re-compress the car you see on the title screen and it works (though I did do it manually. I also changed a block of bytes in the file so there's a red square on one of the frames proving it actually worked :) ). Now I don't know if I'll be able to make a proper converter from .png to .arc, but I might be able to do so if I read up on how the NTFS system works, the hardest part (at least for me) is probably going to be the pallet, is there anything in Tinke that allows you to easily generate a pallet of all colours used in a image?

EDIT2: I have setup the environment needed for me to make changes to the plugin. I can't work on it right now, but I hope to be able to get it working this week. It's going to be hard though as I'm not that familiar with the DS, I am however somewhat familiar with the 3DS, so hopefully some of the things stayed the same... Though I'm pretty sure that as far as images are concerned they didn't :(

EDIT 3: I am sad to report that I have failed to understand the way Ekona and the plugin system works in Tinke, I would still like to try but from the complexity of it and because I have barely used cs before I am uncertain if I will be able to even pull it of. I hope that if you are able to find the time you can implement this feature as it would really help me with my fan translation of the game! Thank you for your help again, and I hope this is not too much to ask :)

@MrJPGames
Copy link
Author

I am sad to report that I have failed to understand the way Ekona and the plugin system works in Tinke, I would still like to try but from the complexity of it and because I have barely used cs before I am uncertain if I will be able to even pull it of. I hope that if you are able to find the time you can implement this feature as it would really help me with my fan translation of the game! Thank you for your help again, and I hope this is not too much to ask :)

I reposted this because you don't get notified when I merely update my comment, and I doubt you would check this page every day to see if I updated anything in my post... Sorry if you already saw my edits and this was unneeded!

@pleonex
Copy link
Owner

pleonex commented Feb 28, 2016

No problem!
I want to edit some Layton images too (in my case just for fun) so I will try to implement it soon.

@pleonex pleonex removed the question label Feb 28, 2016
@pleonex pleonex added this to the v0.9.4 milestone Jun 3, 2016
@pleonex pleonex added the images label Jun 3, 2016
@MetLob
Copy link
Contributor

MetLob commented Jun 13, 2017

The issue has been implemented in PR #39

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants