It is currently Fri Oct 19, 2018 5:31 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Oct 01, 2018 9:08 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20674
Location: NE Indiana, USA (NTSC)
I've managed to produce a file that's a valid GB ROM (tested on my GB Pocket) and a valid PNG image.

Attachment:
File comment: This is a ROM.
gbpng.gb.png
gbpng.gb.png [ 32 KiB | Viewed 291 times ]


Rules: Only RST $28, $30, and $38 may be used, not $00-$20, and $28 must start with LD L,L. There must also be enough free space at the end of the ROM to hold the PNG.


Attachments:
File comment: This is a source code.
gbpng-0.01.zip [30.83 KiB]
Downloaded 22 times
Top
 Profile  
 
PostPosted: Tue Oct 02, 2018 6:29 am 
Offline

Joined: Fri Feb 24, 2012 12:09 pm
Posts: 654
Impressive, but the 32Kbyte PNG file is larger than a 160x144pix BMP file? Does it support compressed PNG's, too? Ah, no, got it! It is compressed, with the 32kbyte "png" file containing the decompressor code in first some bytes, and the main part of the image at offset 4000h..4603h? I always thought .gif would compress better at low color depths, but that PNG is actually smaller than the same image stored as 4bpp GIF.

Now I am wondering what happens if you open the image in your gameboy's email client... no, no, never ever never open email attachments on your gameboy ; )


Top
 Profile  
 
PostPosted: Tue Oct 02, 2018 7:06 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20674
Location: NE Indiana, USA (NTSC)
nocash wrote:
Impressive, but the 32Kbyte PNG file is larger than a 160x144pix BMP file?

Yes. The PNG file contains the ROM in a prGm chunk.

nocash wrote:
It is compressed, with the 32kbyte "png" file containing the decompressor code in first some bytes, and the main part of the image at offset 4000h..4603h?

It actually stores two copies of the image: one for the GB to display, compressed with a less space-efficient but more time-efficient codec, and one for PNG viewers to display. The GB ignores the PNG, and PNG viewers ignore the program. The PNG and the pic inside the ROM can look different and usually will in practice. It can be used, for example, to embed a screenshot into the last 4K of a game. Or it can be used to upload (say) yet another port of Magic Floor to forums whose file type whitelist is authoritarian, but not so much that they recompress all uploaded images. I just made them the same because I was lazy time constrained.

Speaking of which, I've got a couple questions about Magic Floor that I'll take to private messages.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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