Original Post

How do I turn a C file into something to run in a Virtual Boy emulator? I was fiddling around with Notepad making a C file and I downloaded gccvb and VIDE, but I can’t find anything that would do this?

  • This topic was modified 13 years, 2 months ago by VirtualChris.
155 Replies

So I get gccvb up and running and i try to make a .vb file out of the sample provided, and I get this.

Anyone have any idea what this means and how to fix it?

Some more information would be useful. Which gccVB version are you using? Looks like the very first release? This error means, that a function (aka macro) “OBJ_YSET” is called in the code, which does not exist. As it seems, the macro in the libgccvb library in that release is still named “OBJ_SET_Y”, which was later renamed tp “OBJ_YSET” as it is called in the sample code. So just change that line in the source and see if it works then.

BTW, could you attach images to forum posts? Uploading them to our server is important for future reference. If you just link and then someday delete the image from your server, the thread will be impossible to follow. It’s also easier than uloading somewhere else. πŸ˜‰

I don’t know what version of gccvb i’m using, as the read-me file that came with it doesn’t say. It makes a reference to v810 patches, if that helps. Anyway, I changed what you said and this is what i got.

Attachments:

Huh? Don’t know what that means. But you should try a different approach and try to compile my Programming Introductory Demo. It is meant specially for beginners, and is very well commented and verified to compile fine in the second release of gccVB (gccVB CVS 06-20-05), probably the first one will work as well.

Oops, my bad. I typed in “samples” instead of “examples.” Now that I did it right, I get back this error:

Something about parse errors sound much better than FATAL! πŸ˜‰

Attachments:

Yep, that looks much better. Now you only got a typo somewhere around line 117. See if you can find it or post those lines here, lines 116 – 118.

Success! Well, sort of. It compiles OK, but I made 20 characters and it only displays the first 9. I figure it has something to do with it only handling the 9 characters in “HELLO, WORLD!”, the c file I modified to make all but 5 letters appear. I want it to read like the alphabet. How can I get all 20 characters to appear?

After a few hours and tons of tinkering, I made this, what i hope to be an intro to an actual game.

Attachments:

Nice! But you don’t need to use objects to have text on the screen, that’s way to complicated. Create an ASCII conform font set in vide, export to font.h, include font.h in your source (‘include “font.h”;’, as with libgccvb), and either use a BGMap with text created in VIDE (as shown in the attached image), or, much better, use the vbPrint() or vbTextOut() functions, which dynamically alter BGMaps to place Chars from your font set. Both can be found in “misc.h” of libgccvb.

Attachments:

How do I use the vbPrint() function? A line of sample code would be good.

Use vbTextOut(), it’s a bit easier. Copy your font to character segment 3 like this for example:

copymem((void*)CharSeg3, (void*)FONT, 8192);

Here’s an example call of vbTextOut(), printing the string “TEST” to BGMap 0, starting at the tile in position x=1, y=2 (from the top left):

vbTextOut(0, 1, 2, “TEST”)

The BGMap shoud then look like this (“0” meaning an empty tile):

000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
0TEST0000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
[…]
000000000000000000000000000000000000000000000000

This is not working. It has a whole bunch of error messages referring to “WAM.”

Hey, this is what I like to see! Way to go, VirtualChris, on taking your first steps! And thanks for using my demo to learn from. πŸ˜‰

But, KR155E’s right; it’s more of an OBJ demo than a standard “Hello, World!” program. I only did it that way because I wanted a stereo effect to show off the VB’s capabilities…

Anyway, just a few comments concerning text output:

1. The BGMap won’t necessarily be set to all 0x00’s by default. You should use setmem() or cls() (if your copy of libgccvb.h has it) to clear it before printing.

setmem((u8*)(BGMap(0)), 0, 8192);

Here’s cls() if you don’t have it (probably 1,001 better ways to do it…):

void cls(int seg) {
    for (int i = (seg * 4096); i < ((seg + 1) * 4096); i++) {
        BGMM[i] = 0x0000;
    }
}

It takes a BGMap segment number from 0 to 13.

2. dasi has a nice routine here if you want to print the contents of variables.

3. "WAM" is the World Attribute Table. I think we really need to work on that unified library... I'll try to at least post what I used on my compo entry. Most things work in it and I know vbTextOut does (I used it for debugging).

How many objects can be on the screen at once? Because I’m not getting any of this text stuff. Suppose I wanted those words i had in my vb program to bounce around. Would they need to be objects then? Why is it not a good idea to use vbPrint? I actually kind of knew what i was doing with my first program even though I don’t know C, and I’d like to continue and expand on it, add a title screen with something like the coding competition demo picture. (If you don’t know what GoSub is going to be like, you control a submarine and avoid a moving octopus and walls through mazes to get the treasure at the end of each maze.) Through trial and error, i learned on the Oric emulator that characters are made backwards for some reason (for example, when I first did this program, my E looked like a 3.) Anyway, I’m actually thrilled that I did what I did knowing what I know (which is basically almost nothing).

VirtualChris wrote:
How many objects can be on the screen at once?

1024

Because I’m not getting any of this text stuff.

Do you have any specific questions? I don’t know why “WAM” is giving you problems, since I don’t know what exact lib you have. Try looking for/putting this near the top of libgccvb.h as a workaround until I get a new file posted:

u16* WAM = (u16*)0x0003D800;

Suppose I wanted those words i had in my vb program to bounce around. Would they need to be objects then?

Not necessarily. It would probably be easier/less resource consuming if you mean each letter bouncing around, but if it’s whole words, you could probably use BGMaps.

Why is it not a good idea to use vbPrint?

It’s just considered deprecated. I think it also expects the font to be in a different place from vbTextOut, so they don’t “play well together”.

I actually kind of knew what i was doing with my first program even though I don’t know C, and I’d like to continue and expand on it, add a title screen with something like the coding competition demo picture. (If you don’t know what GoSub is going to be like, you control a submarine and avoid a moving octopus and walls through mazes to get the treasure at the end of each maze.)

That sounds like a cool game, but you should probably still use BGMaps for the warning/title screens.

Through trial and error, i learned on the Oric emulator that characters are made backwards for some reason (for example, when I first did this program, my E looked like a 3.)

I have no idea what you mean, unless you’re talking about the order of bits in a byte, and you shouldn’t need to worry about that if you use VIDE or grit for graphics.

Anyway, I’m actually thrilled that I did what I did knowing what I know (which is basically almost nothing).

You should be very proud of even such modest accomplishments. Programming isn’t that easy and you’ve done a great job so far. Please keep tinkering and asking questions when you need to. I really want to play “GoSub”! πŸ˜‰

How do i turn a vep file into an h file? Maybe that’s the problem I’m having, i did it wrong.

VirtualChris schrieb:
How do i turn a vep file into an h file? Maybe that’s the problem I’m having, i did it wrong.

You don’t convert the whole VEP file, this is just a “container” file for your project. In VIDE, you create CharSets or BGMaps, and then export them individually using “Advanced” > “Functions” > “Export to *h” (A VIDE plugin by DanB which you need to install seperately, by just copying it into the “PLUGINS” folder of VIDE. Download here). Place the *.h file in your project directory and include it in the code using the “include ‘file.h'” command. The CharSeg or BGMap can then be referenced by the name you gave it in VIDE (In my example it was “FONT”). Also make sure that, if you use BGMaps you created in VIDE, the CharSet is in the correct CharSeg (As specified when using the “export to *.h” plugin).

RunnerPack schrieb:
I think we really need to work on that unified library… I’ll try to at least post what I used on my compo entry. Most things work in it and I know vbTextOut does (I used it for debugging).

Yes, we really need to get back to that topic. I started compiling one, based on the one from the vbJAEngine and my custom lib I wrote for Blox 2. I will probably work on that some more now that VUE Snake is out. Regarding the current topic, I also wrote a custom text out function, which can print from left to right or right to left, horizontally and vertically and takes the Offset of the font in RAM as input, so more than one font can be used.

  • This reply was modified 13 years, 5 months ago by KR155E.

Could someone please tell me what I’m doing wrong? I keep doing various things but keep getting back various error messages.

Basically, you’re doing everything wrong πŸ˜‰ j/k

Compare the attached file to yours as I describe them:

1. Don’t put any code outside the main() function (unless it’s another function, of course).

2. It’s a waste of time to use vbTextOut() unless you have a World/BGMap/Charset combo ready to display the result.

3. The World has to be set differently if you’re using a BGMap versus using Objects.

4. Remember: C is case-sensitive, so Font is not the same as FONT.

5. Not your fault but you may want to change the FONT array in the include from “static” to “const” to save room in the VB’s dinky WRAM.

EDIT: Oops, forgot to say that I haven’t compiled this (my environment is quite different from yours) so it may still need some tweaking…

I tried to compile this and I got the following:

 

Write a reply

You must be logged in to reply to this topic.