VMU icons

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

VMU icons

Post by Quzar » Mon Oct 24, 2005 1:54 am

How does one go about making both VMU icons (ones that are displayed on the VMU itself) and save icons for games (in the save file manager so that they have an icon).

I know how to implement them in code, but am completely in the dark as to what tools are used to make such things.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has liked: 0
Been liked: 0

Post by BlackAura » Mon Oct 24, 2005 5:39 am

Here's what I'd do for the save icons:

Draw them in a paint program, and save them as a PNG. Convert the PNG to whatever format you need using kmgenc (probably RGB565, disable twiddling). Load the KMG file using the KMG loader library, then copy the image data directly into the VMU file.

You could also just load a PNG using the PNG library. That'll automatically convert to RGB565. If you wanted a paletted image, I'd just use a PCX file instead, because they're nice and easy to read.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Tue Nov 01, 2005 12:08 am

If i don't use a palleted image, what do i put in the space for it? Also, do you have any example of the code? The only place I have ever seen it is in the vmu code for NeoDC which looks like this:

Code: Select all

uint16 palette[16] = { 
0xF07B, 0xFFC4, 0xF000, 0xFFFF, 0x0000, 0x0000, 0x0000, 0x0000, 
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 
}; 

uint16 bitmap[256] = { 
0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 
0x3233, 0x3322, 0x2222, 0x2233, 0x3333, 0x2233, 0x2223, 0x3323, 
0x3233, 0x2333, 0x3323, 0x3332, 0x3323, 0x3332, 0x2333, 0x3332, 
0x3233, 0x2333, 0x2322, 0x3332, 0x2223, 0x3332, 0x2333, 0x3332, 
0x3233, 0x2333, 0x3323, 0x3332, 0x2223, 0x3332, 0x2333, 0x3332, 
0x3233, 0x2333, 0x2222, 0x2233, 0x3333, 0x2233, 0x2223, 0x3323, 
0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 
0x3333, 0x3333, 0x3233, 0x3222, 0x3322, 0x3323, 0x3333, 0x3333, 
0x3333, 0x3333, 0x2333, 0x3233, 0x2333, 0x3323, 0x3333, 0x3333, 
0x3333, 0x3333, 0x3233, 0x3223, 0x2333, 0x3323, 0x3333, 0x3333, 
0x3333, 0x3333, 0x3333, 0x3232, 0x2333, 0x3323, 0x3333, 0x3333, 
0x3333, 0x3333, 0x2233, 0x3223, 0x3322, 0x2322, 0x3333, 0x3333, 
0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 
0x3333, 0x2233, 0x3333, 0x3333, 0x2232, 0x2222, 0x3323, 0x3333, 
0x3333, 0x1132, 0x3323, 0x3333, 0x2222, 0x2222, 0x3322, 0x3333, 
0x3333, 0x1121, 0x3312, 0x3233, 0x2222, 0x2222, 0x2322, 0x3333, 
0x3233, 0x1111, 0x2311, 0x2233, 0x2222, 0x0220, 0x2222, 0x3333, 
0x2133, 0x1111, 0x1211, 0x2232, 0x2222, 0x0220, 0x2222, 0x3323, 
0x2133, 0x1111, 0x1111, 0x2222, 0x0220, 0x2222, 0x2222, 0x3322, 
0x2133, 0x1111, 0x1122, 0x2222, 0x0020, 0x2222, 0x2222, 0x3322, 
0x2133, 0x1111, 0x1122, 0x2222, 0x0022, 0x2222, 0x2222, 0x3322, 
0x2133, 0x1111, 0x1111, 0x2222, 0x2222, 0x2222, 0x0220, 0x3322, 
0x2133, 0x2111, 0x1111, 0x2222, 0x2222, 0x2222, 0x0220, 0x3322, 
0x2133, 0x2111, 0x1111, 0x1111, 0x2212, 0x2222, 0x0200, 0x3322, 
0x2133, 0x1111, 0x1111, 0x1112, 0x2211, 0x2022, 0x2200, 0x3322, 
0x2133, 0x1111, 0x1111, 0x1112, 0x1211, 0x2022, 0x2202, 0x3322, 
0x3233, 0x1111, 0x1111, 0x1122, 0x1111, 0x2222, 0x2222, 0x3322, 
0x3333, 0x1121, 0x1211, 0x1121, 0x1211, 0x2232, 0x2222, 0x3323, 
0x3333, 0x1132, 0x2212, 0x1111, 0x2311, 0x2233, 0x2222, 0x3333, 
0x3333, 0x2133, 0x1111, 0x1111, 0x3312, 0x3233, 0x2322, 0x3333, 
0x3333, 0x3233, 0x2222, 0x2222, 0x3323, 0x3333, 0x3322, 0x3333, 
0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333, 0x3333 
}; 

int i; 
file_t f; 
//FILE   *fp; 
uint8 buffer[4]; 

f = fs_open("/vmu/a1/memcard.bin", O_WRONLY); 
if (!f) return; 

//start of the header 
fs_write(f, "Neo Geo Emu     ", 16);         //vmdesc 
fs_write(f, "Memory Card                     ", 32);   //dcdesc 
fs_write(f, "NeoCD           ", 16);         //appname 

buffer[0]=1; 
buffer[1]=0; 
fs_write(f, buffer, 2);               //icons num 
fs_write(f, buffer, 2);               //anim speed 

buffer[0] = 0; 
fs_write(f, buffer, 2);               //eyecatch 
fs_write(f, buffer, 2);               //crc 

buffer[0]=0; 
buffer[1]=0; 
buffer[2]=0; 
buffer[3]=0; 
fs_write(f, buffer, 4);               //data length 

buffer[0] = 0; 
for (i=0; i<20; i+=2) 
fs_write(f, buffer, 2);            //reserved 
for (i=0; i<16; i++) { 
   buffer[0] = palette[i] % 256; 
   buffer[1] = palette[i] / 256; 
   fs_write(f, buffer, 2);            //icons pal 
} 
for (i=0; i<256; i++) { 
   buffer[0] = bitmap[i] % 256;    
   buffer[1] = bitmap[i] / 256; 
   fs_write(f, buffer, 2);            //icons bitmap 
} 

//actual content start here 
fs_write(f, neogeo_memorycard,  8192); 

fs_close(f);
If I were to do a palleted image, how would I get the data about the pallette?
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has liked: 0
Been liked: 0

Post by BlackAura » Tue Nov 01, 2005 3:59 am

You could make use of the VMU packaging functions (see kernel/arch/dreamcast/include/dc/vmu_pkg.h) to build the header for you. Makes it a lot easier to both pack and unpack a VMU save. Deals with putting the header, colour palettes (or not), icon and eyecatch data, and then the main data.

For a non-paletted image, you just omit the colour palette.

For a paletted image, you need to get the image data from somewhere. Obviously. The catch is that all of the KOS image loaders automatically convert up to RGB565 or ARGB4444. Which is kind of not useful.

You could probably hack the KOS PCX loader to load 256 colour PCX files and give you the raw image data and palette. You'd then need to convert the palette to ARGB4444. There should be a macro somewhere to calculate that.

If course, it'd be better if a KMG could contain a paletted image, which it can't at the moment.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Tue Nov 01, 2005 5:21 am

What is the 'eyecatch' compared to the icon? I won't use palletted stuff if it's gonna be a hassle, I just didn't know how not to =P.

hrm, thanks for all the help by the way, I appreciate it greatly.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has liked: 0
Been liked: 0

Post by BlackAura » Tue Nov 01, 2005 7:13 am

The eyecatch is the larger image that appears on the VMU manager screen when you have the save selected, to the left of the file information (name, description, whatever). Not many games use it, because it increases the size of the save file by rather a lot.
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Tue Nov 01, 2005 10:21 am

oooooohhhh. I have about 20 saves on my vmus and didn't see any of those =P

Well, time to get to work at it i guess.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5393
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 12 times
Contact:

Post by BlueCrab » Tue Nov 01, 2005 12:35 pm

You could look at the ljsdcdev code as well. It uses KallistiOS' built-in vmu_pkg routines and has a rather simple to understand icon file format (which I could post the code to the creator for them, when I manage to dig it up) for specifying the vmu icons.

I might actually go about putting it in KallistiOS, if I can find it.....
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1808
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has liked: 0
Been liked: 0
Contact:

Post by GyroVorbis » Tue Nov 01, 2005 8:26 pm

I just thought I'd thank everybody who participated in this thread because I would have asked the exact same question sooner or later.
Thanks.
Elysian Shadows - "Next-Gen" 2D/3D RPG coming to Sega Dreamcast, Steam, OUYA, and Smartphones
Image
http://www.elysianshadows.com
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Wed Nov 02, 2005 3:15 pm

OK, well, i can't figure out what is going wrong. I was able to convert my graphic to a kmg and all, but now, no icon shows up =\.

Code: Select all

void StoreHS()
{ 
	kos_img_t* icon;
	file_t		f;
	f = fs_open("/rd/icon.kmg",O_RDONLY);
	fs_read(f, icon, sizeof(kos_img_t));
	fs_close(f);

	f = fs_open( "/vmu/a1/shippy", O_WRONLY );

	if ( !f )
		return;

	int i;
	uint8 buffer[4];
	//start of the header 
	fs_write(f, "Shippy          ", 16);         //vmdesc 
	fs_write(f, "High Score                      ", 32);   //dcdesc 
	fs_write(f, "Shippy          ", 16);         //appname 

	buffer[0]=1; 
	buffer[1]=0; 
	fs_write(f, buffer, 2);               //icons num 
	fs_write(f, buffer, 2);               //anim speed 

	buffer[0] = 0; 
	fs_write(f, buffer, 2);               //eyecatch 
	fs_write(f, buffer, 2);               //crc 

	buffer[0]=0; 
	buffer[1]=0; 
	buffer[2]=0; 
	buffer[3]=0; 
	fs_write(f, buffer, 4);               //data length 

	buffer[0] = 0;

	for (i=0; i<20; i+=2) 
		fs_write(f, buffer, 2);            //reserved

	for (i=0; i<16; i++) { 
		fs_write(f, buffer, 2);            //icons pal 
	} 

	fs_write(f, icon->data, 256*2);            //icons bitmap 

	//actual content start here 
	fs_write(f, winners,  sizeof(struct HISCORE)*(MAXSCORE-1)); 
	fs_close( f );
	return;

}
i converted it from a 16x16 png with no alpha. I decided not to mess around with the vmu_pkg stuff since it would pretty much require the same thing (except my way I barely have to modify the file read), the only big difference is the many individual vmu writes.

is there any windows program i can use to view my kmg file? (note i also tried this with on the fly png conversion to the same effect).

EDIT: nm, that actually crashes the DC o_O.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
c99koder
DC Developer
DC Developer
Posts: 200
Joined: Wed Oct 17, 2001 7:44 pm
Location: East Windsor, NJ
Has liked: 0
Been liked: 0
Contact:

Post by c99koder » Wed Nov 02, 2005 9:18 pm

Hmm, it looks like my tutorial on using the vmu_pkg functions has disappeared from the consolevision forums :(

Anyway, take a look at (and feel free to use however you want, regardless of the GPL license required by Frotz) my vmuify() function in http://svn.c99.org/viewcvs/FrotzDC/trun ... iew=markup

It basically takes an input file, output file, short description, long description, and creator id, and just tacks the VMU stuff onto an existing file. The way I use it is to save whatever data I want on to /ram, and then call vmuify() to transfer it to the VMU.

As for creating the icons, I use a little PHP script that uses Speud's vmulib to convert a PNG into a binary icon file. Then I run that through bin2c, and #include it when necessary (sav_icon.h in the FrotzDC example). You can view the converter PHP file's source here: http://raz0r.c99.org/~sam/convert.phps and you can grab vmlib.inc from http://raz0r.c99.org/~sam/vmlib.inc (or from Speud's website, if you can find it).
Image
c99koder
DC Developer
DC Developer
Posts: 200
Joined: Wed Oct 17, 2001 7:44 pm
Location: East Windsor, NJ
Has liked: 0
Been liked: 0
Contact:

Post by c99koder » Wed Nov 02, 2005 9:22 pm

Also, for those wondering about the eyecatch, here's one from the Headhunter save file:

Image
c99koder
DC Developer
DC Developer
Posts: 200
Joined: Wed Oct 17, 2001 7:44 pm
Location: East Windsor, NJ
Has liked: 0
Been liked: 0
Contact:

Post by c99koder » Wed Nov 02, 2005 9:31 pm

Last post tonight, I promise! You mentioned reading the file back -- a quick way to skip over the VMU header is to just fs_seek() past it:

Code: Select all

vmu_hdr_t vmuhdr;
fs_read(fd1,&vmuhdr,128);
fs_seek(fd1,128+(vmuhdr.icon_cnt*512),SEEK_SET);
That'll make sure you're in the right place before you start reading data. Also, it's a good idea to use vmuhdr.data_len if you don't know the size of the file you're reading. If you just rely on the file size reported by the VMU, you'll get garbage at the end because it allocates a whole block even if you only save a few bytes. See copy_file() in the same file I linked earlier for an example of this.
Image
User avatar
Quzar
Dream Coder
Dream Coder
Posts: 7486
Joined: Wed Jul 31, 2002 12:14 am
Location: Miami, FL
Has liked: 0
Been liked: 3 times
Contact:

Post by Quzar » Wed Nov 02, 2005 11:09 pm

oooo, thanks, i'll have to look at all that stuff. I've got 5 more things that can use it other than what i released tonight =P.
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
User avatar
Freeze
DCEmu Respected
DCEmu Respected
Posts: 351
Joined: Wed Oct 17, 2001 7:44 pm
Location: Munich and Nuremberg / Germany
Has liked: 0
Been liked: 0
Contact:

Post by Freeze » Mon Nov 07, 2005 3:56 pm

What are the dimensions for the eyecatcher image?
c99koder
DC Developer
DC Developer
Posts: 200
Joined: Wed Oct 17, 2001 7:44 pm
Location: East Windsor, NJ
Has liked: 0
Been liked: 0
Contact:

Post by c99koder » Mon Nov 07, 2005 4:38 pm

User avatar
bucanero
DC Developer
DC Developer
Posts: 119
Joined: Sat Apr 05, 2003 4:58 pm
Location: ARGENTiNA
Has liked: 0
Been liked: 0
Contact:

Post by bucanero » Fri Nov 11, 2005 3:10 pm

talking about VMU icons, I had no problems including VMU icons in my VMZip tool.

check VMzip source code (available at my site & at sourceforge) to see how I used KOS vmu_pkg functions.

Also, for creating the icon arrays I used "BMP2ASM" that converts 16 colours bmp's to ASM includes, that can be easily edited as .C arrays.

bmp2asm is available here: http://virtuamunstaz.de/bmp2asm.zip
Image
ursyy25
DCEmu Newbie
DCEmu Newbie
Posts: 1
Joined: Mon Oct 04, 2010 4:08 am
Has liked: 0
Been liked: 0

Re: VMU icons

Post by ursyy25 » Mon Oct 04, 2010 4:15 am

I know that 5 years had past since the last post in this topic, but I was wondering (as user Quzar also did):
Is there any Windows program that will help me to view *.kmg files? Or can I somehow convert *.kmg file back to *.png?

What type of file *.kmg actually is? Is it created in Linux? I have Windows XP!

Thanks for Your help!
BB Hood
Insane DCEmu
Insane DCEmu
Posts: 170
Joined: Fri Mar 30, 2007 12:09 am
Has liked: 11 times
Been liked: 3 times

Re: VMU icons

Post by BB Hood » Sat Nov 06, 2010 2:04 pm

I believe Dan Potter created the *.kmg file format. Unless you write some plugin for an image program or write a program to convert it to a different format(yourself) there is no way any system can display it by default.

*.kmg is an uncompressed image format that can be loaded quickly into the pvr.
Post Reply