dustmop / makechr

makechr is a tool for generating NES graphics
Other
91 stars 8 forks source link

Traceback when testing #1

Closed amigrave closed 8 years ago

amigrave commented 8 years ago

Hi,

I'm trying makechr on a test image (tried an RGB and an indexed palette png):

makechr -o "test%s" test.png

and I got this traceback:

Traceback (most recent call last):
  File "/usr/local/bin/makechr", line 3, in <module>
    makechr.run()
  File "/usr/local/lib/python2.7/site-packages/makechr/makechr.py", line 121, in run
    application.run(img, args)
  File "/usr/local/lib/python2.7/site-packages/makechr/app.py", line 27, in run
    self.create_output(processor.ppu_memory(), args, traversal)
  File "/usr/local/lib/python2.7/site-packages/makechr/app.py", line 76, in create_output
    mem.save_template(out_tmpl, order, args.is_sprite)
  File "/usr/local/lib/python2.7/site-packages/makechr/ppu_memory.py", line 46, in save_template
    self._save_components(components, chr_order)
  File "/usr/local/lib/python2.7/site-packages/makechr/ppu_memory.py", line 75, in _save_components
    self._save_nametable(fout, self.gfx_0.nametable)
  File "/usr/local/lib/python2.7/site-packages/makechr/ppu_memory.py", line 97, in _save_nametable
    fout.write(chr(nt))
ValueError: chr() arg not in range(256)

The value of nt when the exception is raised is 256.

Am I doing something wrong ? The image contains only 4 colors. Am I supposed to do some prior processing on the image ?

PS: Thanks for your NES graphics blog posts, they are great !

dustmop commented 8 years ago

@amigrave I'm very, very sorry for the extremely late reply! For some reason I never got a notification about this issue and also didn't notice it.

The situation you encountered happens when you are using an image that requires more than 256 chr tiles. The error message was improved in 1b8e2fe6a32b7464056f9a4614f416337f6890b2, and now looks like this:

> makechr 257tiles.png
Found 1 error:
NametableOverflow $100 @ tile (8y,0x)
To see errors visually, use -e command-line option.

You can use the -e flag to create an image that let's you see the error visually:

> makechr 257tiles.png -e err.png
Found 1 error:
NametableOverflow $100 @ tile (8y,0x)
Errors displayed in "err.png"

Note that makechr is not designed to compress your input image; if you give it an image with too much detail that cannot be represented in 256 chr tiles, it will always fail with this error.

You can upgrade makechr and get this improved error-handling now.

pip install makechr --upgrade

amigrave commented 8 years ago

Thanks @dustmop !

And by the way, I love your work/game/blog !