TMX file format help

Get your graphics formats figures out here! Got details for others? Post here!
PersonaRipper
n00b
Posts: 14
Joined: Mon May 03, 2010 6:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: TMX file format help

Post by PersonaRipper » Sat May 08, 2010 5:30 pm

Holy ****! :eek: *Totally outclassed* Maybe I should rip up that previously mentioned degree in programming.

I wonder what social link I need to max to summon you at will! :keke:

Edit: Now I wonder, is .bmp the best format to save as? These tmx files have a lot of transparency in them after all. I guess I'll have to actually run the prog and see first.

bbrcher
beginner
Posts: 22
Joined: Mon Sep 07, 2009 7:27 pm
Has thanked: 4 times
Been thanked: 9 times

Re: TMX file format help

Post by bbrcher » Sat May 08, 2010 8:03 pm

Nope, BMP is the worst :P

But, it is the easiest. TGA should be just as easy, but since I didn't have any examples around to test with and I was unsure if it was supported by default I just used BMP. GIMP and other graphics programs should be able to batch convert the BMPs to something else as well--ImageMagick comes to mind as a command line option.

What format do you use in your tool? Could probably set that up easily.

PersonaRipper
n00b
Posts: 14
Joined: Mon May 03, 2010 6:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: TMX file format help

Post by PersonaRipper » Sat May 08, 2010 9:02 pm

I've just been using the .png format.

I'm puttering on the code to do it, using a png made by GGD and a png reference manual. I'm finding it a bit of a headache, but no effort, no reward!

PersonaRipper
n00b
Posts: 14
Joined: Mon May 03, 2010 6:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: TMX file format help

Post by PersonaRipper » Sun May 09, 2010 1:07 am

Well, I think .png is a bit out of my grasp. I'll be putting it on the list of things I don't really need to know but would like to.

Turns out that the .BMP files created by bbrcher's version of the extractor does create bitmaps that do not have transparency. However, GIMP (horray for linux!) still reads those bytes as transparent. Since I will likely rename the files, I'll just use GIMP to do so, and save the .bmp as .png to let the transparency shine through! Furthermore, GIMP already has a batch mode, so with a little bit more research I think it will easily batch convert bmp to png. :)

I am still interested in seeing other solutions, but I find myself fairly frustrated with all the hex editing and whatnot the last few days.

bbrcher
beginner
Posts: 22
Joined: Mon Sep 07, 2009 7:27 pm
Has thanked: 4 times
Been thanked: 9 times

Re: TMX file format help

Post by bbrcher » Sun May 09, 2010 1:14 am

I did state that the transparency is there, just not supported by most programs--24b BMP's are the norm, not 32b. GIMP will see it but windows will not for example. If you figure out how to make it so it's more compatible, let me know though ;P

PersonaRipper
n00b
Posts: 14
Joined: Mon May 03, 2010 6:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: TMX file format help

Post by PersonaRipper » Sun May 09, 2010 4:02 am

Yeah you totally did mention that..... I don't know how I managed to miss it. I think I assumed you meant GIMP could make it a png, but not necessarily maintain the transparency when the origin file was .bmp. Guess I'm just in a rush. I'm testing a small script for batching GIMP bmp->png, hopefully this thing will be 'solved' soon.

bbrcher
beginner
Posts: 22
Joined: Mon Sep 07, 2009 7:27 pm
Has thanked: 4 times
Been thanked: 9 times

Re: TMX file format help

Post by bbrcher » Sun May 09, 2010 6:20 am

Don't burn yourself out. This is suppose to be fun ;)

PersonaRipper
n00b
Posts: 14
Joined: Mon May 03, 2010 6:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: TMX file format help

Post by PersonaRipper » Sun May 09, 2010 7:12 am

It is fun! Well, parts of it. I like programming until I get to a problem that is overwhelming and I am unsure of where to start or how to break it down into manageable parts. I've always been a bit high-octane regardless.

I've now finished the GIMP script! It is based off a similar script I found as an example, but this actually does what I wanted. :-p Technically it will convert any GIMP compatible format into .png. Thankfully I learned LISP and Scheme in college. For once I got to use it without wanting to eviscerate something. :mrgreen:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; any2pngbatch.scm
;; - By PersonaRipper, XaNTeX forums and http://tiredtracks.is-a-geek.com:8080/
;;
;;	Used to run GIMP in batch mode and convert all .BMP(or other 
;;		graphic formats) to .png format.
;;	To use:
;;		Place this file in gimp's script folder and run the following command
;;			in the desired folder.
;;	gimp -i -b '(any2pngbatch "*.BMP")' -b '(gimp-quit 0)'
;;
;; Old files not removed. New files are the old filename with .png appended.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define (any2pngbatch pattern)
	(let* 
		((filelist (cadr (file-glob pattern 1)))) ;Get the file list.
		(while (not (null? filelist)) ;Iterate the file list
			(let* ( ; Set up variables for this iteration.
					(filename (car filelist))
					; Read the image data in.
					(image (car (gimp-file-load RUN-NONINTERACTIVE 
													filename filename)))
					; Handle to the editable image
					(drawable (car (gimp-image-get-active-layer image)))
					(outputfile (string-append filename ".png")))
				; Write out the new file.
				(file-png-save RUN-NONINTERACTIVE 
								image drawable 
								outputfile outputfile 0 9 0 0 0 0 0)
				(gimp-image-delete image))
			; Move to the next element in the list.
			(set! filelist (cdr filelist)))))
I think we may call that a wrap. >.> I've enjoyed the collaboration here. It WAS fun afterall.

bbrcher
beginner
Posts: 22
Joined: Mon Sep 07, 2009 7:27 pm
Has thanked: 4 times
Been thanked: 9 times

Re: TMX file format help

Post by bbrcher » Sun May 09, 2010 8:37 am

Looks good, glad I could help 8)

PersonaRipper
n00b
Posts: 14
Joined: Mon May 03, 2010 6:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: TMX file format help

Post by PersonaRipper » Sun May 09, 2010 9:46 pm

One last thing I forgot to mention. In bbrcher's extractTmx.cpp, I could not get it to compile unedited. I got the error:
extractTmx.cpp: In function ‘void convertTMXtoBMP(std::ifstream&, char*)’:
extractTmx.cpp:104: error: ‘memcpy’ was not declared in this scope
extractTmx.cpp:147: error: ‘memcpy’ was not declared in this scope

Which means I needed to add the line
#include <cstring>
near the top of the file.

I'm sure different compilers handle it differently, but g++ needed this extra line.

bbrcher
beginner
Posts: 22
Joined: Mon Sep 07, 2009 7:27 pm
Has thanked: 4 times
Been thanked: 9 times

Re: TMX file format help

Post by bbrcher » Mon May 10, 2010 9:10 pm

Not sure how I got away with that :scaredy:

PersonaRipper
n00b
Posts: 14
Joined: Mon May 03, 2010 6:07 pm
Has thanked: 2 times
Been thanked: 2 times

Re: TMX file format help

Post by PersonaRipper » Thu May 13, 2010 9:52 pm

No worries, like I said: different compilers handle these things differently. Some enforce as many rules as they can, others are more lax. Maybe your compiler considers cstrings as a required library and always imports it, or imports it if it finds it is required.

It just happens I use one of the stricter compilers it seems!

User avatar
Blyss
n00b
Posts: 17
Joined: Fri May 07, 2010 1:18 am
Has thanked: 4 times
Been thanked: 9 times

Re: TMX file format help

Post by Blyss » Thu May 20, 2010 6:49 pm

See below posts for later versions!
Update: Okay so it was admittedly stupid to leave a bug in that would take 5 minutes to fix, whether I'm interested in the project or not. So I fixed it and it will no longer hang if there are no input files. Also cleaned the code a tiny bit, removed some unused variable declarations and merged an if statement.

Hey everyone~ I've been monitoring this topic for a while, and it took forever to get my account activated but I have something to add. Thanks to help from PersonaRipper (who I contacted via email) I made a somewhat useful application called TMX Explorer which I will release in hopes it is useful to somebody. About it:

Features:
Written in FreeBASIC
Let's you "Explore" *.tmx and *.bin files visually, so you can see what you are getting before you extract it
Exports directly to PNG with transparency

Limitations:
Probably slower than it should be, but you really shouldn't notice it
Code is not terribly great, I am a novice after all
Operates only on the directory it is executed from.

License:
Do (almost) whatever you want license
Source is included, feel free to modify it and all that, please don't remove any contributors credit though
Don't sell it
Don't use it for evil purposes
Don't try to eat it

Credits:
PersonaRipper for his help with some programming problems and providing me the source to his and bbrchers extractors which I converted to FreeBASIC code for large parts of the program
Simon Nash for FreeBASIC PNG Library and Jean-loup Gailly and Mark Adler for zlib library

Obligatory screenshot:
Image

See below posts for later versions!
Last edited by Blyss on Tue Jul 06, 2010 7:44 pm, edited 3 times in total.
Please check my site Myriad Dreams out! All of my projects are hosted there, plus other stuff I think is neat.

User avatar
Blyss
n00b
Posts: 17
Joined: Fri May 07, 2010 1:18 am
Has thanked: 4 times
Been thanked: 9 times

Re: TMX file format help

Post by Blyss » Fri Jun 04, 2010 1:02 am

New version available in next post!
I made a new version of the TMX explorer.

New Stuff:

You can change directories. The interface is certainly not standard, but it does the job.
File list is no longer generated via a command line "dir *.tmx > tempfile" type command, it is done with internal Freebasic commands
Application no longer closes if no files is in its directory, instead it redirects to the change directory interface.
Application no longer hangs on 0 length files or files with correct extension but no TMX within.

New Thanks:

Thanks to bcohio2001 @ Freebasic forums for directory/file reading code

Notes:

Directory and file code is not commented in the source, aside from the key reading and array writing, I've little idea how the FreeBasic DIR command works with the specified parameters. I just got the code from bcohio2001 hehe.

Hope you find it useful!

~Blyss
Last edited by Blyss on Tue Jul 06, 2010 7:44 pm, edited 2 times in total.
Please check my site Myriad Dreams out! All of my projects are hosted there, plus other stuff I think is neat.

User avatar
Blyss
n00b
Posts: 17
Joined: Fri May 07, 2010 1:18 am
Has thanked: 4 times
Been thanked: 9 times

Re: TMX file format help

Post by Blyss » Tue Jul 06, 2010 7:42 pm

All new versions available at:
viewtopic.php?f=32&t=4830
Tinkered around with the TMX Explorer this morning and updated some stuff.

TMX Explorer 0.7 changes:

Edited directory reading code, file list was incorrect because listoffiles() array was not cleared properly.
Changed directory navigation control, you can no longer select "." and the cursor defaults to ".."
Changed the navigation through bin files, you can now only go through as many TMX as there actually are, not past.
The "deepness" navigation keys no longer work when viewing a straight TMX.
Changed the command "Imagedestroy(curimg)" to "if curimg then imagedestroy(curimg)" to avoid trying to clear memory that was not allocated. I don't think FreeBasic allows that to happen anyway but this is safer.



Update:

Just an update on TMX Explorer compatibility:

Confirmed working with:
Persona 3: FES (confirmed by me)
Persona 3 Portable (confirmed by taleds)
Persona 4 (confirmed by me)

Also a really quick tutorial for anyone who is wondering how you actually get to the TMX/BIN type files.

Note that this tutorial is valid for Persona 3, Persona 3: FES and Persona 4 for Playstation 2. Other games/platforms may or may not be laid out in this manner.

Pop your game disc in your optical drive. Get IsoBuster ---> http://www.isobuster.com/ if you don't have it and fire it up. Go to File --> Open Image File. A dialog box will pop up. In the drop down menu on the right where you can choose a file type pick "All Files (*.*)" Now navigate to your optical drive. You'll see a few files, the ones you are interested in have the extension CVM. All of the game files are within these CVM, which are really just some kind of disc image file with a different extension. For your reference, most of the graphics files are in "DATA.CVM" and "BTL.CVM" in Persona 3/4. If your just playing around and not looking for anything specific, go with "DATA.CVM" Whatever you pick, when you confirm and open it, a directory structure will appear in the right pane of IsoBuster. Now you can just drag and drop whatever directory you want from the window to your desktop or a folder or whatever and IsoBuster will extract it. Again for the record, you will find most of the character portraits in the "BUSTUP" subdirectory of the "DATA.CVM" Anyway, that's how you can get at the stuff.

Request:
So far the TMX Explorer has been tested with Persona 3: FES, Persona 3 Portable and Persona 4. If you own another game that uses the TMX format and try this, let me know if it works or not at my email address in the "about" section of the program, or through a PM please.

~Blyss
Last edited by Blyss on Sun Aug 01, 2010 2:31 am, edited 1 time in total.
Please check my site Myriad Dreams out! All of my projects are hosted there, plus other stuff I think is neat.

Post Reply