gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > PAGfxConverter : bg/sprite converter for DS

#61257 - Mollusk - Fri Nov 18, 2005 2:47 pm

Hi !

I know there are already tons of sprite converters for gba/ds, but I just don't seem to find the one that suits me perfectly. So I decided to do my own...
It uses the .Net FrameWork, so I'm pretty sure I'm going to get flamed for that, but I don't care, it was the easiest solution :p

Here's my latest creation, a background/sprite converter for Nintendo DS !
Download : http://sourceforge.net/project/showfiles.php?group_id=142901&package_id=169947

If you don't have the latest framework, please download it here : http://www.microsoft.com/downloads/details.aspx?FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5&DisplayLang=en

How does it work ?
Using an ini file, named PAGfx.ini
In it, you'll find the following information :


#TranspColor Black (the color you want to be transparent : White, Black, Green, or Fuchsia (or Magenta))

pretty basic, to choose which color is the transparent color. That way the colors doesn't need to be the first color in the palette index, the program will do it for you when converting


#Sprites : the current format is spritefile colormode (256colors or 16bit) palettename (multiple files can have the same palette...)
firstsprite.bmp 256colors sprite0
test.jpg 256colors sprite1
ship.jpg 16bit

In this example, you see how to use 256colors or 16bit sprites. Just give the filename, the color mode, and then the palette number (from 0 to the last palette number)


#Backgrounds : backgroundfile bgmode (for bitmaps, 8bit or 16bit; TileBg, RotBg, LargeMap) palettename
bg0.bmp TileBg bg0
bitmap.bmp 8bit bg0

Works the same way as the sprites, but with different backgrounds modes...

// In the works :
Texture sizes : 8 -> 1024
Formats 8bit or 16bit



Changelog

v0.5

- New Frontend, by Kleevah !!
- Better Text output
- Completely rewrote lots of the code, new ini format and parser,
- Added support for RotScale backgrounds, though untested it should work :)
- Faster sprite and background conversions, but tile optimising remains desperately slow for backgrounds of more than 1024x1024
- Simplified the code, reduced it's size (alot)
- Fixed a bug for TileBgs (used to write tons of line breaks for nothing)
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...


Last edited by Mollusk on Tue Nov 22, 2005 1:50 pm; edited 5 times in total

#61269 - Mollusk - Fri Nov 18, 2005 5:05 pm

Updated to version 0.2, supports 16bit sprites, fixes a bug for non-square sprites (typo), and creates all_gfx.c and all_gfx.h, to make life easier
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#61281 - dovoto - Fri Nov 18, 2005 6:42 pm

Awesome. Nice to see some new tools coming about. And as far as I am concerned .NET is ideal for tool creation (I am sure linux fans will dissagree of course).

Now make me a map editor! :)
_________________
www.drunkencoders.com

#61294 - Mollusk - Fri Nov 18, 2005 8:44 pm

Map Editor ? Hum... not now :p I'll go working on tiled map output, now that the sprites seem to work ok
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#61340 - NoMis - Sat Nov 19, 2005 1:26 am

dovoto wrote:
Awesome. Nice to see some new tools coming about. And as far as I am concerned .NET is ideal for tool creation (I am sure linux fans will dissagree of course).

Now make me a map editor! :)


Why? Mono rocks and runs very nice on linux. Mono is the better .NET imo because of the OS and platform indepandance.

NoMis
_________________
www.gamedev.at - The austrian gamedev site
hde.gamedev.at - The Handheld Dev Env plugins for Eclipse

#61342 - dovoto - Sat Nov 19, 2005 1:49 am

well....mono works but I would not say it is the "better" ;) and last i heard it does not do 2.0. But if they truely get it implemented on linux that would be pretty slick. Like java only not quite as shitty ;)
_________________
www.drunkencoders.com

#61343 - Mollusk - Sat Nov 19, 2005 1:52 am

Ok, here comes v0.3, a pretty big update, mainly for background support...

- Added support for tiled backgrounds, with tile optimisations (HFlip/VFlip), and DMA Copy for TiledBg (LargeMap is a tilebg without DMACopy optimisation)
- Added support for 8bit bitmaps...
- Added support for 16bit bitmaps ! (with BIT15 set on, not like gfx2gba, so you can do a nice and quick DMA_Copy...)
- Better all_gfx.c and .h files, added palettes in them, organized a little more with comments
- You can now put Magenta or Fuschia, same thing
- Speed up the whole program (like 4 times faster when converting)
- Added error codes for basic ini typos : wrong palette number, wrong file name... That way you know why it crashes :)
- Slightly bigger window size
- Added #ifndef...#endif to the header file

I also renamed it to PAGfxConverter, now that it does more than sprites...

www.palib.info/files/PAGfxConverter.zip
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#61346 - josath - Sat Nov 19, 2005 2:42 am

wow, three versions in under 12 hours.

#61361 - LOst? - Sat Nov 19, 2005 7:21 am

It says I need a specific version of .NET

So I have decided to simply ignore this tool. Sorry.
_________________
Exceptions are fun

#61363 - Volta - Sat Nov 19, 2005 7:56 am

Just download the new version - a link should appear in the alert box.

Anyway, you will have to download it one day or another.

#61365 - LOst? - Sat Nov 19, 2005 8:27 am

Volta wrote:
Just download the new version - a link should appear in the alert box.

Anyway, you will have to download it one day or another.


Yea
_________________
Exceptions are fun

#61368 - NoMis - Sat Nov 19, 2005 9:53 am

Nice to see so much progress done on this tool.

dovoto wrote:
well....mono works but I would not say it is the "better" ;) and last i heard it does not do 2.0. But if they truely get it implemented on linux that would be pretty slick. Like java only not quite as shitty ;)


Yeah it's true that they will always be behind with feature completness. But the C# Compiler is already 2.0 compliant as well as the CLI and JIT. But there are a lot of 2.0 libraraies missing at the moment.
The reason why I think it's the better .NET is because I of the freedom of choice in OS and platform. I think portability is a very important feature these days. In mono you also have a lot of languages to choose from. There is C# and VB.NET of course but there are also additional languages like JScript.net, nemerle, boo and few others.

If you always want to have access to the newsest class libraries then Microsoft is the way to go. But if platform and os indepandence is more important to you (it is to me) than mono is the way to go.

NoMis
_________________
www.gamedev.at - The austrian gamedev site
hde.gamedev.at - The Handheld Dev Env plugins for Eclipse

#61370 - Mollusk - Sat Nov 19, 2005 11:10 am

Are there lots of changes to do to adapt the code to mono ? Or should I just download it and pray that it compiles my current code ?

Quote:

Just download the new version - a link should appear in the alert box.
Anyway, you will have to download it one day or another.


True... I know it's kind of a pain to have to install stuff to get this to work, but more and more applications are going to use .Net anyway...
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#61373 - Mollusk - Sat Nov 19, 2005 12:58 pm

On a side note, I also made a DS File System this week, integrated to PAlib, but it only has 2 files, so it can be used independtly. Why ? Because GBFS didn't maange folders and subfolders, so I made a system with folder management...
It's in .Net too.

I'll also do a modified version this week to have it include files in Ram, that way you could use it with WMB
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#61377 - Mollusk - Sat Nov 19, 2005 2:42 pm

I added rotscale backgrounds, so I put in pretty much everything...
I'll add 16 colors sprites, I guess, just for the heck of it, it's not like it's long to do...

I'm now looking at textures and the different format, and wanted to have some details, as the info I found wasn't that great.

In the ndslib doc (kind of old), it says that the only supported formats are 16bit (with BIT15 on ?), and 8bit (with the palette immediately following the data), and sizes from 8 to 1024 pixels....

Is that all there is to do for textures (not much, shouldn't be too hard :p) or is there more ?

Edit : the last idea I had, which could be cool, would be a tiled background with 16 256 colors palettes, since the DS can do that... It might kind of slow to convert, as for each tile it would have to check which palette suits it best, but could allow way more than 256 colors without taking as much space as 16bit backgrounds
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#61385 - NoMis - Sat Nov 19, 2005 6:09 pm

Mollusk wrote:
Are there lots of changes to do to adapt the code to mono ? Or should I just download it and pray that it compiles my current code ?


Since you used .NET 2.0 Framework the chances are very slim that it will run under mono. .NET 2 Features are under heavy development and come with mono 2.

If you have a .NET 1.1 Application it depands on what you used if it will run under mono. But the class status is pretty much complete for 1.1.
Things you should avoid if you want to port .net applications to mono are Win API calls and COM. If you programm in pure .net then it will work.
This will of course also affect any library that you will reference. If one of these is not mono complaiant it wont run.

You don't have to recompile btw. to run your app in mono. The cool thing is that you can use the same binary under windows and linux :)

For more on that subject take a look at the Mono Technical FAQ.

NoMis
_________________
www.gamedev.at - The austrian gamedev site
hde.gamedev.at - The Handheld Dev Env plugins for Eclipse

#61440 - dovoto - Sun Nov 20, 2005 5:33 am

My doc does not explain all the texture formats for DS. For 8 and 16 bit a converter is almost unecessary as you can grab the data from any graphics file. It is the others that need tools :) I should follow this with specifics but instead I must sleep :)
_________________
www.drunkencoders.com

#61448 - Mollusk - Sun Nov 20, 2005 11:08 am

Any hint as to where I could get that info ? :p
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#61486 - dovoto - Sun Nov 20, 2005 7:28 pm

I know there are at least three other formats.

there is a compressed texture format (I have no idea how it works although some work has been done on it)

and there are two formats that support an alpha chanel.
One has 5 bits of alpha and 3 bits for a color lookup into a palette.
The other has 3 bits of alpha and 5 bits for a color lookup.

I dont even know which bits come first, alpha or color :)

I have not tested these and the info is kind of second hand. I may try out the 5x3 alpha today and see if i cant fix up my lesson 9 nehe demo.
_________________
www.drunkencoders.com

#61487 - Mollusk - Sun Nov 20, 2005 7:30 pm

cool, thanks for the info :)
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#61522 - LOst? - Mon Nov 21, 2005 4:33 am

dovoto wrote:
and there are two formats that support an alpha chanel.
One has 5 bits of alpha and 3 bits for a color lookup into a palette.
The other has 3 bits of alpha and 5 bits for a color lookup.


So there is support for semi transparent textures then? It was scary to think there was no support at all for it on the DS. The DS is so new that kind of hardware must exist to keep up with all the 3D games nowdays.
_________________
Exceptions are fun

#61661 - Mollusk - Tue Nov 22, 2005 12:15 pm

v0.5 is out, with tons of new stuff :)
Download : http://sourceforge.net/project/showfiles.php?group_id=142901&package_id=169947

- New Frontend, by Kleevah !!
- Better Text output
- Completely rewrote lots of the code, new ini format and parser,
- Added support for RotScale backgrounds, though untested it should work :)
- Faster sprite and background conversions, but tile optimising remains desperately slow for backgrounds of more than 1024x1024
- Simplified the code, reduced it's size (alot)
- Fixed a bug for TileBgs (used to write tons of line breaks for nothing)
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#73224 - LeeC - Thu Feb 23, 2006 11:50 pm

Hi,
I have tried 0.5 and 0.7 and when I click convert and save, I get the error shown below... I suspect it is the files in the GAC_MSIL directory because that doesn't appear to exist on my machine. The .NET 2.0 stuff is fine.

Any idea what the problem might be?

Cheers
Lee C

*************************************************************

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ComponentModel.Win32Exception: The system cannot find the file specified
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at PAGC_Frontend.Form1.toolStripButton5_Click(Object sender, EventArgs e)
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
PAGC Frontend
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///H:/NDS_Projects/PAGfxConverter0.5/PAGC%20Frontend.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

#73264 - Extreme Coder - Fri Feb 24, 2006 6:51 am

When I tried it, I had the same problem as you. Try putting the data you want to convert in the same folder of the program;)

#73278 - Mollusk - Fri Feb 24, 2006 10:23 am

I'll upload a new version, which corrects a few bug (already in PAlib, but not on sourceforge)
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#73336 - LeeC - Fri Feb 24, 2006 10:05 pm

The problem was the fact that the data had to be in the same directory as the .EXE. I should have realised from using PNGCrush which is also a DOS programme.

The front end I wrote for that actually moved the files into the location of the EXE and then rebuilt the directory structure and moved the files where they should be. I might investigate writing a front end for this programme which does a similar process if I get chance.

#73345 - Mollusk - Fri Feb 24, 2006 11:30 pm

at some point I probably broke the directory structures, as it was supposed to open files from pretty much anywhere
_________________
PAlib official forum : http://www.palib.info
PAlib official tutorials: http://www.palib.info/wiki
Updates, help, code examples, tutorials, etc...

#73347 - LeeC - Fri Feb 24, 2006 11:55 pm

Mollusk wrote:
at some point I probably broke the directory structures, as it was supposed to open files from pretty much anywhere

It might be the front end not passing the correct path parameters to your programme, might be worth a quick test without the GUI. I am not familiar with the commandline options for your programme though, so you might be the best person to test it.