BMP -> VMU screen code?

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
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:

BMP -> VMU screen code?

Post by Freeze » Mon Nov 07, 2005 6:19 am

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
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has liked: 0
Been liked: 0
Contact:

Post by JS Lemming » Mon Nov 07, 2005 8:12 am

I made a program called VmuGx a long time ago. It was a little editor that allowed you to draw vmu "icons" and save them as the "+.+.+...+.+." deal or bmps. If there isn't a program that already exists that does what you want, I can add a bmp to "+.++.+....+." thingy in like 5 minutes.
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 2:39 pm

That would rock. What I have to do? Send my BMPs to your address? Or was your program released to the public?
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has liked: 0
Been liked: 0
Contact:

Post by JS Lemming » Mon Nov 07, 2005 4:16 pm

My program was released to the public, on thechaosrift.com at least. It's not on the site anymore because I guess no one had a use for it. I'll go ahead and make the enhancement and post a link to it up in here.
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 6:34 pm

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.
Image
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has liked: 0
Been liked: 0
Contact:

Post by JS Lemming » Mon Nov 07, 2005 8:26 pm

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.
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has liked: 0
Been liked: 0
Contact:

Post by JS Lemming » Thu Nov 10, 2005 7:49 am

So... Did I just waste my time or something?
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 » Thu Nov 10, 2005 9:31 am

JS Lemming wrote:So... Did I just waste my time or something?
Chill dude, you can't force developers into using your stuff.
Elysian Shadows - "Next-Gen" 2D/3D RPG coming to Sega Dreamcast, Steam, OUYA, and Smartphones
Image
http://www.elysianshadows.com
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 » Thu Nov 10, 2005 3:25 pm

JS Lemming wrote:So... Did I just waste my time or something?
Nope, at least I don't hope so.

Thanks a lot for your efforts! I've downloaded it, but haven't had the time to test it yet. I'm currently at a project which keeps me pretty busy, you'll see what it is in about 4 weeks. :)

Yet again, thanks!
User avatar
JS Lemming
Insane DCEmu
Insane DCEmu
Posts: 202
Joined: Mon Apr 04, 2005 8:08 am
Location: C:\CON\CON
Has liked: 0
Been liked: 0
Contact:

Post by JS Lemming » Thu Nov 10, 2005 4:30 pm

Don't get me wrong. It just appeared that you wanted me to make that upgrade and then didn't. I didn't mean to sound like a jerk if it did sound that way.

You chill Gyro. :| I wasn't trying to force jack.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5384
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 11 times
Contact:

Post by BlueCrab » Thu Nov 10, 2005 7:46 pm

Cool off please... Everyone.

Thanks
- Your friendly Programming Discussion moderator.
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 2:56 pm

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:

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;
}
Image
Post Reply