BMP -> VMU screen code?
- Freeze
- DCEmu Respected
- Posts: 351
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: Munich and Nuremberg / Germany
- Has thanked: 0
- Been thanked: 0
- Contact:
BMP -> VMU screen code?
Hey guys,
I want to include my previously drawn 48x30 icons to a code to run it on the VMU. The coding is not the problem this time, more how I convert my BMP to the array.
As Quzar just told me, I have to make an array that is of "+" or ".". A "+" means a filled pixel and "." an empty pixel.
Seems a bit hard to me since I have a few flowting around here. Isn't there a tool out there which could convert it?
Cheers,
-Max
I want to include my previously drawn 48x30 icons to a code to run it on the VMU. The coding is not the problem this time, more how I convert my BMP to the array.
As Quzar just told me, I have to make an array that is of "+" or ".". A "+" means a filled pixel and "." an empty pixel.
Seems a bit hard to me since I have a few flowting around here. Isn't there a tool out there which could convert it?
Cheers,
-Max
- JS Lemming
- Insane DCEmu
- Posts: 202
- Joined: Mon Apr 04, 2005 8:08 am
- Location: C:\CON\CON
- Has thanked: 0
- Been thanked: 0
- Contact:
- JS Lemming
- Insane DCEmu
- Posts: 202
- Joined: Mon Apr 04, 2005 8:08 am
- Location: C:\CON\CON
- Has thanked: 0
- Been thanked: 0
- Contact:
-
- DC Developer
- Posts: 200
- Joined: Wed Oct 17, 2001 7:44 pm
- Location: East Windsor, NJ
- Has thanked: 0
- Been thanked: 0
- Contact:
In the KOS source, there's an example that loads XPM files onto the VMU LCD. It's located in examples/dreamcast/libdream/lcd.
Here's the thing, though: drawing to the LCD is slow. If you draw the LCD image once, nothing appears on newly-inserted VMUs. If you draw it every frame, your framerate will suffer. Here's my solution (again, anyone can feel free to use this however they want, regardless of the GPL license attached to the DCBlap project): replace the KOS VMU handler with one that sends your icon when the VMU is inserted. You can grab the code here:
http://svn.c99.org/viewcvs/DCBlap/trunk ... iew=markup
This is a modified version of the KOS XPM demo, and it requires modifying your XPM slightly after saving it. All you need to do is remove the color palette information, and stick all the data into 1 string. For an example, see http://svn.c99.org/viewcvs/DCBlap/trunk ... iew=markup
Let me know if you have any questions, I know that file isn't very well commented (ok, not commented at all).
-Sam
Edit: Call dcb_vmu_init(); to initialize the driver and replace the default KOS driver. Then call update_lcds(); during your game loop. This will send the LCD image to any newly-inserted VMUs that haven't already recieved it.
Here's the thing, though: drawing to the LCD is slow. If you draw the LCD image once, nothing appears on newly-inserted VMUs. If you draw it every frame, your framerate will suffer. Here's my solution (again, anyone can feel free to use this however they want, regardless of the GPL license attached to the DCBlap project): replace the KOS VMU handler with one that sends your icon when the VMU is inserted. You can grab the code here:
http://svn.c99.org/viewcvs/DCBlap/trunk ... iew=markup
This is a modified version of the KOS XPM demo, and it requires modifying your XPM slightly after saving it. All you need to do is remove the color palette information, and stick all the data into 1 string. For an example, see http://svn.c99.org/viewcvs/DCBlap/trunk ... iew=markup
Let me know if you have any questions, I know that file isn't very well commented (ok, not commented at all).
-Sam
Edit: Call dcb_vmu_init(); to initialize the driver and replace the default KOS driver. Then call update_lcds(); during your game loop. This will send the LCD image to any newly-inserted VMUs that haven't already recieved it.
- JS Lemming
- Insane DCEmu
- Posts: 202
- Joined: Mon Apr 04, 2005 8:08 am
- Location: C:\CON\CON
- Has thanked: 0
- Been thanked: 0
- Contact:
Aight, here it be: VmuGx v2.0
Note: I made that with Win98 so I'm hoping it'll look and work the same on XP. The program had an icon I made for it but it randomly didn't show up on my compoot (can you tell me if it does on yours?).
So, all you have to do is open up the program, go to Options -> Bitmap to VMU. Choose the bmp you want. Then do File -> Save to create a text file containing the "+.+.++.+...." huha. And if you want to use the editor, left click places, right click erases.
Tell me if you run into any problems or if the program fails somehow.
Note: I made that with Win98 so I'm hoping it'll look and work the same on XP. The program had an icon I made for it but it randomly didn't show up on my compoot (can you tell me if it does on yours?).
So, all you have to do is open up the program, go to Options -> Bitmap to VMU. Choose the bmp you want. Then do File -> Save to create a text file containing the "+.+.++.+...." huha. And if you want to use the editor, left click places, right click erases.
Tell me if you run into any problems or if the program fails somehow.
- JS Lemming
- Insane DCEmu
- Posts: 202
- Joined: Mon Apr 04, 2005 8:08 am
- Location: C:\CON\CON
- Has thanked: 0
- Been thanked: 0
- Contact:
-
- DCEmu Banned
- Posts: 1876
- Joined: Mon Mar 22, 2004 4:55 pm
- Location: #%^&*!!!11one Super Sonic
- Has thanked: 82 times
- Been thanked: 64 times
- Contact:
- JS Lemming
- Insane DCEmu
- Posts: 202
- Joined: Mon Apr 04, 2005 8:08 am
- Location: C:\CON\CON
- Has thanked: 0
- Been thanked: 0
- Contact:
- bucanero
- DC Developer
- Posts: 120
- Joined: Sat Apr 05, 2003 4:58 pm
- Location: Rapture
- Has thanked: 1 time
- Been thanked: 2 times
- Contact:
I did a pretty simple RAW->XPM convert utility so I could display images in the VMU screen easily... First I create the black/white image I wanted (48x32 pixels) and then saved it as .RAW image. (256 colour palette)
here's the code:
here's the code:
Code: Select all
/* Converts a RAW icon image file (48x32) into a XPM char array (for inclusion in
a source file)
(c)2005 Damian Parrino
*/
#include <stdio.h>
void convert(char *ifn, char *ofn, char *prefix) {
FILE *i, *o;
char x;
int j;
i = fopen(ifn, "rb");
o = fopen(ofn, "w");
if (!i || !o) {
printf("error: can't open input or output file\n");
return;
}
fprintf(o, "/* XPM */\n");
fprintf(o, "static char *%s_xpm =\n", prefix);
j=0;
while((x=getc(i)) != EOF) {
if (j == 0) putc('"', o);
if (x == 0) {
putc('.', o);
} else {
putc('+', o);
}
j++;
if (j == 48) {
fprintf(o, "\"\n");
j=0;
}
}
fprintf(o, ";\n");
fclose(i);
fclose(o);
}
int main(int argc, char **argv) {
char *prefix;
argc--;
if (argc != 2 && argc != 3) {
printf("usage: bin2c <input> <output> [prefix]\n");
return 0;
}
prefix = (argc == 3) ? argv[3] : "vmu_icon";
convert(argv[1], argv[2], prefix);
return 0;
}