It is currently Mon Dec 18, 2017 1:17 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: png2chr, chr2png
PostPosted: Tue Oct 06, 2015 10:28 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 610
Cheers forum. I work on Linux, there were close to no tools, so I wrote a png2chr converter and its reverse. I did find python scripts for that, but who uses python :P

https://github.com/clbr/nes

With this I can edit in gimp/mtpaint and be happy. It uses the palette index directly - palette 0 is bg, 1, 2 and 3 are passed on as-is. Save the PNG as indexed, and it will be accepted if it has 4 or less colors total.

Probably will run on Windows as-is, but again, who uses that. It's quite sad most tools are closed source and provided for Windows only.

Memblers wrote:
And something like a PNG2CHR converter hopefully could be provided in exe format.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Tue Oct 06, 2015 6:45 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 298
I knew there had to be other NES enthusiasts on Linux. Cheers. :beer: :)

I got started on writing some tools of my own before I got sidetracked by the lack of a decent NSF player, but all I have to show for it is a simple nametable viewer (no editing yet; I've been using NESST in Wine) and a tool to convert nametables into the map format used by my scrolling engine. If I ever do get anything done, I'll be sure to share it.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Tue Oct 06, 2015 6:48 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6543
Location: Seattle
My own analog (uses PGMs instead): viewtopic.php?p=117763#p117763


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Tue Oct 06, 2015 7:00 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19356
Location: NE Indiana, USA (NTSC)
A little bit of code review:

Code:
if (cols * rows > 512) die("Too large to fit in the 8kb CHR ROM\n")

This limit is unnecessary for three reasons: MMC, CHR RAM, and post-processing tools that generate a nametable.

Code:
if (pix > 3) die("Palette has too many colors (%u) at %u,%u\n", pix, x, y);

But why? I want to use colors 5, 6, 7, 9, 10, 11, 13, 14, and 15 to remind myself of in which palette a particular object should be drawn.

Do you plan on adding 8x16 tile support or support for CHR formats other than that of the NES? Because I wrote a converter in Python that uses format strings: NES is 0;1, Game Boy is 0;1, SMS is 0,1,2,3, Genesis is 3210, Super NES is 0,1;2,3, Super NES 3-bit is 0,1;2, Mode 7 is 76543210, etc. It's included with my project templates for NES and Super NES.

Rahsennor wrote:
I knew there had to be other NES enthusiasts on Linux.

I use Xubuntu.

Rahsennor wrote:
I got started on writing some tools of my own before I got sidetracked by the lack of a decent NSF player

Let me guess: You're on Fedora, and you're feeling Red Hat's fear of Nintendo's legal department. Here on Debian family distributions, I can just sudo apt-get install fceux and then fceux Thwaite.nsf.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Tue Oct 06, 2015 7:38 pm 
Offline

Joined: Thu Aug 20, 2015 3:09 am
Posts: 298
tepples wrote:
I use Xubuntu.
Me too, until I got tired of Canonical breaking everything they possibly could and switched to Debian. It's missing some bells and whistles, but at least I can expect the programs in the official repositories to actually work. :roll:

tepples wrote:
Let me guess: You're on Fedora, and you're feeling Red Hat's fear of Nintendo's legal department. Here on Debian family distributions, I can just sudo apt-get install fceux and then fceux Thwaite.nsf.
I have a lot of homebrew NSFs in my collection that use non-standard rates. Otherwise, yes, FCEUX does the trick. I prefer blargg's synth, but it's woefully broken, and I can't make heads or tails out of the source to fix it myself.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Wed Oct 07, 2015 1:56 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 610
tepples wrote:
Code:
if (cols * rows > 512) die("Too large to fit in the 8kb CHR ROM\n")

This limit is unnecessary for three reasons: MMC, CHR RAM, and post-processing tools that generate a nametable.


Yes, but my current project does not use any mappers or tricks, only the basic nes cart. So I want it to bail if too large, by default - maybe options could be added for other settings.

Quote:
Code:
if (pix > 3) die("Palette has too many colors (%u) at %u,%u\n", pix, x, y);

But why? I want to use colors 5, 6, 7, 9, 10, 11, 13, 14, and 15 to remind myself of in which palette a particular object should be drawn.


The assumption is that there is an error in the image in that case, and the output would be broken/unexpected.

Quote:
Do you plan on adding 8x16 tile support or support for CHR formats other than that of the NES? Because I wrote a converter in Python that uses format strings: NES is 0;1, Game Boy is 0;1, SMS is 0,1,2,3, Genesis is 3210, Super NES is 0,1;2,3, Super NES 3-bit is 0,1;2, Mode 7 is 76543210, etc. It's included with my project templates for NES and Super NES.


Not at the moment.


OT, but how can I get famitone2-compatible music created? I don't trust the closed binaries enough to run them in Wine, only in a no-network VM, and that's too much of a PITA to set up for anything NT-based (3.11 and 9x are small enough to not take gigs of space and hours to install, but I don't think famitracker would run?). Seems no DOS tracker can export to it either.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Thu Oct 08, 2015 12:27 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 610
Just confirming that Famitracker requires XP minimum. Sigh.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Thu Oct 08, 2015 9:13 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19356
Location: NE Indiana, USA (NTSC)
Continuing security updates require Vista minimum. If you're stuck on Windows 98, I recommend using FamiTracker in Wine in Linux. How is FamiTracker "closed binaries"? Is it that building the project from its source archive requires the use of a non-free compiler, and you're worried about a backdoored compiler? And how is Wine in Linux in a VM unacceptable?


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Thu Oct 08, 2015 1:25 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1312
I'm sensing a bitterness towards Windows here. I'd rather not use it, but if there's a tool you need that requires it and you aren't willing to port or reimplement it on your own, then what's the problem with using WINE? Part of my development workflow for my game (unfortunately) has one script that uses WINE to run a few conversion tools that aren't easily brought to Linux. If this is a matter of security concerns, reconsider the appropriateness of this paranoia high level of security consciousness for what you're doing.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Thu Oct 08, 2015 5:04 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19356
Location: NE Indiana, USA (NTSC)
For what it's worth:

Today, while working on this, I discovered the FamiTone2 tools work correctly in Wine. So if you can spin up a Linux instance with Wine, there shouldn't be much of a problem.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Fri Oct 09, 2015 12:24 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 610
Oh I already setup an XP VM. Took only an hour to install and 5 gigs of space, such efficiency.

@mikejmoffitt

I've been on the dark side in a past life, I know what can be done. So, nowadays I do not allow anything untrusted access to my data, or the network.

@tepples

I had read reports that FamiTracker did not fully work in Wine, that it crashed occasionally and sometimes did not play all sounds. That would have prevented a Linux VM with Wine.

The source being available does not mean the binary corresponds to the published source. That combined with the reports it does not work in Wine fully meant building it myself would not have been useful.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Fri Oct 09, 2015 7:36 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19356
Location: NE Indiana, USA (NTSC)
calima wrote:
I had read reports that FamiTracker did not fully work in Wine

How many years old were those reports? The version of Wine in Ubuntu 14.04 LTS runs it fine. Though I had to turn down the frequency and turn up the buffer length to get things like ModPlug Tracker and FamiTracker to run, I'm not sure whether that's a Wine bug or a limit of the 1-core, 2-thread Atom N450 CPU in my laptop.


Top
 Profile  
 
 Post subject: Re: png2chr, chr2png
PostPosted: Fri Oct 09, 2015 10:59 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 610
Small flexibility update, and added an identical tiles checker. It immediately pointed out my current font has an identical 0 and O, tsk tsk.

@tepples

Many reports, but yeah, possibly old.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group