You are not logged in.
Lost Password?


Register To Post



 Bottom   Previous Topic   Next Topic

#1
Multiple BMP to BGMap/charset converter
Posted on: 2013/1/26 23:17
PVB Elite
Joined 2008/12/28
Slovenia
629 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
There have been many utilities written over time to convert graphics to the charset and BGMap formats used on the Virtual Boy. However, they are either poorly documented and hard to use or they have little or no support for BGMaps, forcing programmers to use inefficient ways of storing graphics, like having a separate charset for each BGMap.

This program, however, can take multiple BMP files at once and convert them to BGMaps that all share the same charset, with the charset only containing as many characters as needed to conserve space and the BGMaps only containing as many tiles as needed, not all 64 by 64.

Attach file:


zip vbimgc.zip Size: 22.61 KB; Hits: 208
Edited by HorvatM on 2013/1/26 23:55
Top

#2
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/1/26 23:49
PVB Elite
Joined 2011/7/1
Germany
1115 Posts
CoderContributorTop10 PosterLong Time User (8 Years) App CoderPVBCC 2013 Entry
Sounds pretty cool. Have to give it a try.
Top

#3
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/6/24 21:27
PVB Elite
Joined 2011/7/1
Germany
1115 Posts
CoderContributorTop10 PosterLong Time User (8 Years) App CoderPVBCC 2013 Entry
I just had a look at this again. This really solves allot issues. Until I started with all of the ROM hacks I didn't realize how un-efficiently I treat the BGMaps and CharSeq.
Top

#4
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/9/9 11:05
PVB Elite
Joined 2003/7/26
USA
1465 Posts
PVBCC EntryCoderContributorSpecial AchievementTop10 PosterHOTY09 EntryLong Time User (15 Years) App Coder20+ Game RatingsPVBCC 2013 Entry
Although I haven't yet had need to try it, from the docs it seems to have a few limitations. While none of these is a "deal-breaker", they can make it a bit harder to use.

1) Limited to Windows BMP files for input

You might want to check out FreeImage. It's cross-platform, very easy to use, and supports tons of input formats! It even has handy auxiliary functions; e.g. to reduce colors or convert an image to greyscale.

2) User is required to specify all filenames, without extensions

This makes it harder to use in a makefile.

3) Only C or raw binary output

C takes longer to parse, and binary requires an asm "stub" to link. GNU assembly output shouldn't be too hard to add, right?

4) Not open-source

Top

#5
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/9/9 13:59
PVB Elite
Joined 2008/12/28
Slovenia
629 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
Quote:
RunnerPack wrote:
1) Limited to Windows BMP files for input

I'm trying to keep it simple. If you need other formats, you can use ImageMagick or something to convert them. I'll add support for images with fewer colors though so you won't have to waste space with 24-bit BMPs. Although NTFS compression works quite well on them.
Quote:
2) User is required to specify all filenames, without extensions

This makes it harder to use in a makefile.

What's your proposed alternative?
Quote:
3) Only C or raw binary output

C takes longer to parse, and binary requires an asm "stub" to link. GNU assembly output shouldn't be too hard to add, right?

Right. What does it need? A label and a list of .dbs? I'm not very familiar with the GNU assembler - I've only used it with the asm() macro in C code.
Quote:
4) Not open-source


No comment on that.
Top

#6
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/9/10 5:19
PVB Elite
Joined 2003/7/26
USA
1465 Posts
PVBCC EntryCoderContributorSpecial AchievementTop10 PosterHOTY09 EntryLong Time User (15 Years) App Coder20+ Game RatingsPVBCC 2013 Entry
Quote:

HorvatM wrote:

Quote:

RunnerPack wrote:

2) User is required to specify all filenames, without extensions

This makes it harder to use in a makefile.


What's your proposed alternative?


Well, being the programmer, I would say that's really your decision, but here's what I know:

Make's job is to make an output file for each input file – whenever the input file is newer or the output file doesn't exist – using a set of rules. When a rule is executed by make, it will insert the name of the input and output files into the rule's command-line(s). You can tell make to provide the name without the extension, but it would be nice if it wasn't necessary.

This is really the only problem, since your goal of making one charset out of a series of images doesn't really mesh with make's idea of calling a tool once for each input file, anyway. I'll write more about this in the gritVB thread...

Quote:
Quote:
3) Only C or raw binary output


Right. What does it need? A label and a list of .dbs?


Yes, the assembly file needs a label and the actual data directives, but you also need a header with the C declaration. Note: while gcc 2.95 does use .db, .dw, and .dd, version 4.x uses .byte, .int, and .word, respectively. I guess these guys never heard the one about not fixing what isn't broken

Here's a before and after example:

The existing C header:

const u16 maptest[] = {
0x0000, ...


The desired ASM code:

.global maptest

maptest
:
    .
dw 0x0000, ...


Or, for GCC 4.x:


.global maptest

maptest
:
    .
int 0x0000, ...


Now, to get the C compiler to see the label, it has to be declared "external" like so:


extern 
const u16 maptest[];


(Not sure about the const part, actually).

Another thing I noticed when I tried VBIMGC is that your headers don't have "guards" around them to prevent multiple declarations, and such. You might want to do something like:


#ifndef _MAPTEST_H_
#define _MAPTEST_H_

const u16 maptest[] = {
0x0000, ...
}

#endif
Top

#7
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/9/11 22:04
PVB Elite
Joined 2011/7/1
Germany
1115 Posts
CoderContributorTop10 PosterLong Time User (8 Years) App CoderPVBCC 2013 Entry
I used this a while ago and I noticed one thing: If you reference your image including a path (like: vbimgc /XC chr bgm horst C:\vbde\image_0) you will have the whole path inside of the header file (const u16 bgmC:\vbde\image_0[] = {).
Top

#8
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/9/11 23:36
PVB Elite
Joined 2008/12/28
Slovenia
629 Posts
Highscore Top ScoreHighscore Top ScoreCoderContributor10+ Game RatingsLong Time User (10 Years) App CoderPVBCC 2010 EntryPVBCC 2013 Entry
I never thought about that. The way I use it is to create a batch file in the same directory as the images and run it each time I want to regenerate the output.

Maybe there should be an option to use a file that contains a list of files to process and how to name the resulting arrays? This way, it would also be possible to specify different settings for each image and different output filenames.
Top

#9
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/9/12 20:34
PVB Elite
Joined 2003/7/26
USA
1465 Posts
PVBCC EntryCoderContributorSpecial AchievementTop10 PosterHOTY09 EntryLong Time User (15 Years) App Coder20+ Game RatingsPVBCC 2013 Entry
Quote:

HorvatM wrote:

Maybe there should be an option to use a file that contains a list of files to process and how to name the resulting arrays? This way, it would also be possible to specify different settings for each image and different output filenames.


That is an excellent idea which I fully support. It sounds pretty easy to implement, too; just pass each line of the file through your command-line argument parser.

BTW, what does your program do when the files you give it generate more than 2048 chars?
Top

#10
Re: Multiple BMP to BGMap/charset converter
Posted on: 2013/9/15 0:28
PVB Elite
Joined 2011/7/1
Germany
1115 Posts
CoderContributorTop10 PosterLong Time User (8 Years) App CoderPVBCC 2013 Entry
I played around with this today and noticed something strange:

- I converted a batch of images
- I did not use the optimization features
- I copied the whole charset to memory
- I copied the whole BGMap of image 1 to bgmap 31
- When pressing a button I would copy the second image bgmap 31
- The first image was bigger then the second one

-> The first image would display correctly
-> The second image would display correctly but you would still see the rests of the first image

I double checked and the generated bgmap of the second image actually contains parts of the first one.

I know that it doesn't really matter as you can set the world attributes to not show the garbage around the image but I though you still might want to know.
Top

 Top   Previous Topic   Next Topic


Register To Post