11 March 2016 - Forum Rules

Main Menu

Inquiry into supporting PNG via a faux SNES 'chip'

Started by Kiyoshi Aman, October 31, 2011, 07:42:44 AM

Previous topic - Next topic

Kiyoshi Aman

Earlier today, a discussion was had in #rhdn about repro doods. In the course of that discussion, I suggested a faux chip for SNES games which provides PNG decoding and graphics handling, which incidentally would permit 24-bit colour (with 8-bit alpha channel). Emulator-wise, this should be trivial—most sane emulators already employ libpng in order to take PNG screenshots. The purpose for this post, however, is to determine how it would work in ROM and what would need to happen, precisely, to implement support for it.

(I'm tentatively dubbing this 'chip' the AGU-1 (Aerdan's Graphics Unit), with Agumon for a mascot, but if you folks want to call it something else (aside from 'shit', 'retarded', etc.), feel free.)


I don't believe it's possible. The SNES PPU hardware will not be able to display beyond 15-bit color and short of hijacking the video signal with some really fancy hardware (probably entirely new PPU unit, VRAM, and CGRAM) I don't think any special chip is going to be able to change that either.

If your goal is simply to load PNG files and conform them to the SNES format and color restrictions, they it's entirely possible with a chip that would decompress and convert the PNG data. To do that, you'd design your chip to respond to a few select memory addresses that are both accessible and not mapped elsewhere. The rest is dependent on your design. How many memory addresses does your chip need and what would be the communications protocol to tell it to fetch data and feed the results back. The code in the ROM would access the registers and handle the communications. An emulator would emulate the co-processesor end of things. This is assuming you limit yourself to PNG data sizes that fits in normal ROM space. Otherwise, you'll need to add external media access or something like that.
TransCorp - Over 20 years of community dedication.
Dual Orb 2, Wozz, Emerald Dragon, Tenshi No Uta, Glory of Heracles IV SFC/SNES Translations

Kiyoshi Aman

Yeah, I talked to grinvader & kode54 about it while I was waiting for the post to be approved, and they made many of the same points you did. I'm not really suited for discussing the PPU stuff, though, so I'll take your (and their) word for it.

Beyond that...I think the first version would be limited to just PNG decoding, with an opaque scratch buffer for the decoder itself and another 1-2k of RAM for the game to put PNG data into for processing—I'd have to experiment with 16-bit PNGs to see if this is overkill or not (2k almost certainly will be, but not sure about 1k), though.

(ETA: Okay. Preliminary testing with 8-bit PNGs indicates 1024 bytes for shunting data to the chip isn't enough—48x48 exceeds it. I might actually suggest going as high as 4k bytes of RAM.)

(ETA 2: ...I should've stuck with my original thought of 16k RAM, though double that would probably be safer. 256x256 (actually 256x142, but meh) ends up being over 9k, optimized.)


Kiyoshi Aman

It's open-source, it's lossless, it's already used in most (sane) emulators for screenshot purposes so additional instrumenting won't be difficult beyond that necessary to provide the faux chip to the SNES itself.


I think you may be confusing things here Kiy. Sure emulators support taking PNG screenshots, but that's not part of the emulation itself, it's part of the interface.

It would be like saying that the SNES should be able to load savestates because the emulator supports it.

Kiyoshi Aman

No, I am simply making the assumption that the hard part is not integrating PNG into the emulator, but rather, integrating PNG into the emulator such that ROMs can make use of the format.


Hey are there any updates with this project?
I'm interested in the idea eventhough I'm not sure how it would work programmatically. How would you include the .PNG in the program if ultimately you are going to put it into an snes compatible format? (ie background mode 0 with only 4 colors per layer or other strange cases)
I'm starting to get back into SNES programming and I think it would be really useful "to the community"/future if there was a tool to more easily convert between PNG and SNES file formats. The .PCX converting is strange and archaic and the pcx2snes tool is kind of unreliable/wonky for me especially on windows 7 64-bit. And if you had stuff like custom labels, splitting the bytes in different files...etc that would be amazing.

Kiyoshi Aman

This concept was specifically for injecting PNG images into SNES ROMs and using them directly, not for conversion between PNG and SNES-friendly bitmap formats. It's not actually viable for a number of reasons, one being that PNG-compressed images tend to be bigger than any format used by SNES games.