VMU icons
- Quzar
- Dream Coder
- Posts: 7499
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Wed Jul 31, 2002 12:14 am
- Location: Miami, FL
- Has thanked: 4 times
- Been thanked: 10 times
- Contact:
VMU icons
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.
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
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
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.
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.
- Quzar
- Dream Coder
- Posts: 7499
- Joined: Wed Jul 31, 2002 12:14 am
- Location: Miami, FL
- Has thanked: 4 times
- Been thanked: 10 times
- Contact:
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:
If I were to do a palleted image, how would I get the data about the pallette?
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);
"When you post fewer lines of text than your signature, consider not posting at all." - A Wise Man
-
- DC Developer
- Posts: 9951
- Joined: Sun Dec 30, 2001 9:02 am
- Has thanked: 0
- Been thanked: 1 time
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.
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.
- BlueCrab
- The Crabby Overlord
- Posts: 5665
- Joined: Mon May 27, 2002 11:31 am
- Location: Sailing the Skies of Arcadia
- Has thanked: 9 times
- Been thanked: 69 times
- Contact:
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.....
I might actually go about putting it in KallistiOS, if I can find it.....
- GyroVorbis
- Elysian Shadows Developer
- Posts: 1874
- Joined: Mon Mar 22, 2004 4:55 pm
- Location: #%^&*!!!11one Super Sonic
- Has thanked: 80 times
- Been thanked: 64 times
- Contact:
- Quzar
- Dream Coder
- Posts: 7499
- Joined: Wed Jul 31, 2002 12:14 am
- Location: Miami, FL
- Has thanked: 4 times
- Been thanked: 10 times
- Contact:
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 =\.
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.
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;
}
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
-
- DC Developer
- Posts: 200
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: East Windsor, NJ
- Has thanked: 0
- Been thanked: 0
- Contact:
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).
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).
-
- DC Developer
- Posts: 200
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: East Windsor, NJ
- Has thanked: 0
- Been thanked: 0
- Contact:
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:
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.
Code: Select all
vmu_hdr_t vmuhdr;
fs_read(fd1,&vmuhdr,128);
fs_seek(fd1,128+(vmuhdr.icon_cnt*512),SEEK_SET);
- bucanero
- DC Developer
- Posts: 120
- Joined: Sat Apr 05, 2003 4:58 pm
- Location: Rapture
- Has thanked: 1 time
- Been thanked: 2 times
- Contact:
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
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
Re: VMU icons
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!
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
- DC Developer
- Posts: 189
- Joined: Fri Mar 30, 2007 12:09 am
- Has thanked: 41 times
- Been thanked: 10 times
Re: VMU icons
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.
*.kmg is an uncompressed image format that can be loaded quickly into the pvr.