Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2015-07-30 20:11:37

turboboy215
Member
Registered: 2015-07-30
Posts: 15

GBDK: Picture Converter Not Working

Hi, there, I'm turboboy215, and I'm new to Game Boy programming.
After I created several "Hello world" programs, I decided to try and display a full-screen image.

So, I followed this tutorial:
http://gbdev.gg8.se/wiki/articles/Displ … een_images

Here is the original image:
http://firemariofireluigi61.deviantart. … -344301114

Using GIMP, I reduced the colors just like the tutorial said before scaling it, but it ended up looking horrible. I also tried dithering, which didn't look so bad unscaled, but it was terrible scaled. I tried scaling it first and then reducing the colors, with and without dithering, but it still didn't look good. So, I got an idea.

I scaled the image without reducing the colors, saved it as a BMP file, and converted it using the Game Boy Toolkit Preview at the following link (which never got past preview):
http://www.yvan256.net/projects/gameboy/

I didn't have to choose the scaling, so I just adjusted the knobs. Since it saves in a different format than what I needed, I saved the new picture as another BMP.

Using GIMP again, I saved it as a PCX.

Then, I converted it using PCX2GB, and saved it as a tile and map file, named tile.c and map.map, which worked, and ended up with a file identical to the previous BMP.

Then, I copied the exact code, using a file called main.c, in the correct directory, and then tried to compile it using GBDK, with the following command:
lcc -o image.gb main.c


However, every time it tries to convert, it freezes for a long time until it finally responds and says "Abnormal termination".

What's wrong? Is it the image? Is it the conversion? I've got all the files in the correct location, the bin folder of GBDK, so it's definitely where it should be.

Thank you for your help.

Offline

 

#2 2015-07-31 00:48:06

NicklausW
Member
Registered: 2014-02-09
Posts: 22

Re: GBDK: Picture Converter Not Working

Mind posting the code?

Offline

 

#3 2015-07-31 11:55:11

turboboy215
Member
Registered: 2015-07-30
Posts: 15

Re: GBDK: Picture Converter Not Working

Here is my exact example, complete with my original images and a converted PNG of my PCX file (same as final conversion):
https://drive.google.com/folderview?id= … sp=sharing
Just copy all the files to the GBDK BIN directory and run compile.cmd to watch what happens.

Offline

 

#4 2015-07-31 14:54:13

NicklausW
Member
Registered: 2014-02-09
Posts: 22

Re: GBDK: Picture Converter Not Working

The problem is that tiledata[] is WAY too large. Make sure mario2.pcx is no more than 160x160 pixels in size.

Offline

 

#5 2015-08-01 20:56:28

Scazon
Member
From: Boston, MA
Registered: 2015-06-14
Posts: 24
Website

Re: GBDK: Picture Converter Not Working

Your code is mostly correct, but here's a few suggestions:

The tiledata array is theoretically the right size (360 tiles at 16 bytes per tile), and the map file looks to be the right size, too (20x18), however the set_bkg_data() function only accepts UBYTEs as parameters (which go up to 255). Your tiledata array has all unique tiles, or 360 tiles total. The game can't actually load that many tiles at once. You'll have to either shrink/crop the image so there's empty space around it, or use a simpler image that won't use all unique tiles (also I'm not sure if the program you're using will ignore duplicate tiles, which is worth looking into. (edit: it looks like not, because there seem to be multiple "completely black" tiles that are defined more than once in the array).

But the first thing you should do is declare the arrays as const, i.e. "const unsigned char tiledata[]={...". The compiler usually takes a SUPER long time to handle arrays that large. Making them const will speed it up immensely and will keep it from crashing.

Running your code (after making the arrays const) gives this image:
https://i.imgur.com/bax4oXL.png

The map overflows after the 255th tile and redraws the first tiles again.

Last edited by Scazon (2015-08-01 20:58:24)

Offline

 

#6 2015-08-01 21:01:48

NicklausW
Member
Registered: 2014-02-09
Posts: 22

Re: GBDK: Picture Converter Not Working

Huh...It seems I've been corrected. XD

Offline

 

#7 2017-01-15 07:41:35

npzman
Banned
From: Australia
Registered: 2014-11-19
Posts: 197

Re: GBDK: Picture Converter Not Working

I am now having the same issue trying to get this to display
https://drive.google.com/open?id=0B7qrX … GxMNXI2Uk0
for my start screen

Last edited by npzman (2017-01-15 07:52:28)


Avatar is me
Twitter : @Sfeedman please follow
Join : sfeed.club my website please join

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson