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 15 years, 5 months ago by VirtualChris.
Level 18 has been added. The game will be 2MB when it’s done. Can someone show me how to program sound into a VB program? Does the Virtual Boy have a library of sound effects I can pick and choose from, or is it something different?
Attachments:
Sound is not an easy task. Some people have gotten sound to work in their homebrews, but noone released any code yet. Better finish the game first, release it without sound, and create a version 1.1 if you ever get sound working.
Changed the walls to coral and added a level 19.
Cool… looking good. Do you plan on making any game changes? Like adding enemies, floating mines, current, or anything? How about a speed setting? I haven’t tried it on hardware, but it seems pretty slow (and therefore easy) in RB.
Also, I noticed after you die, you have two GOSUB logos on the title screen.
DogP
I’d like to add an octopus that moves randomly and could get in your way, but I don’t know how since I’m using all 4 character segments right now (0, 1, 2 & 3.) I’ll see if i can speed up the sub a little.
Got rid of the double GoSub death logo and sped up the sub a little.
Attachments:
Well, there’s no reason they all need to be in different char segments. A really easy modification would be to move the player and treasure chest into the same charseg, and the octopus could be in that same one as well.
For ease of use, you can make them all in their own world, which would be a limiting factor, but you have 32 of them… there’s no reason you need individual charsegs, and that definitely shouldn’t be your limiting factor.
I assume you’re using VIDE to make your graphics? If so, just merge your graphics for the sub, treasure chest, and octopus into the same bmp, then convert. To draw it, just change the MX and MY value from 0, 0 to whatever the offset in the bmp is.
BTW, that speed is better IMO. Oh, and that’s some major abuse of the C language :P.
Edit: Something that would be pretty cool if you added would be moving obstacles (walls, mines, etc)… either free randomly floating obstacles, walls that bounce back in a linear path, or a rotating bar (like the fire bars in Bowser’s Castles in Mario Bros). The appearing/disappearing walls are definitely the most interesting part of your game, but you can just stall in front of them until you get the timing right… something that forces you to keep moving along would make it more exciting.
DogP
If i were to combine the sub and the treasure chest into one image, wouldn’t I have to redo the wall collision code?
I think I did it, but the collision detection doesn’t work on one side. To see what I mean, start on level 1 and make the sub’s left side ram into the first line of coral that juts out. Notice how it doesn’t completely touch the coral at all before it thinks you’ve lost a life.
Attachments:
I didn’t look at the source code, but my first guess is that it looks like the sub image you put in with the treasure chest is smaller than the image you used to have in its own charseg. Since your collision detection is hardcoded for the size and shape of the sub, if you’re gonna change the sub, you’ll need to change the collision detection. If you leave the sub the same size/shape, you should be fine.
DogP
OK, I now have an octopus here, but he doesn’t move and he doesn’t hurt your sub. In order to move him, I need to know if or how you get a variable to generate a random number.
Attachments:
Well, there’s lots of pseudo random number functions out there, but you need to “seed” them with something that’s truely random for it to work well. Basically, if you have the same seed, you’ll get the same sequence, so the idea is that you need to seed it with something that can’t be purposely reproduced, then the sequence will be different every time.
One common and easy to use seed is while waiting for the user to press start, have a counter running. The counter will run REALLY fast (probably somewhere around 1 million times/sec), so it’d be very difficult for someone to time their keypress to get the same predicted sequence. Of course you have to make sure you force them to wait (if someone’s holding start, wait for them to release it before counting and accepting a keypress). This is important since if they hold the start button and you allow that, you’ll get a count of 0.
I don’t have any good links for a pseudo random number generator off hand, but you can do a search on google, or just come up with something “good enough”, and just call it as a function, then when you decide you want something better, just replace that function.
A crappy method, but very easy to visualize and implement for a temporary PRNG is the middle-square method. Just take your first number, square it, then take the middle section. It’s easiest to visualize as hex… your first number is 4 hex digits, square it and you get 8 hex digits, return the middle 4 hex digits (shift right 8 bits, AND 0xFFFF). That number is your random number and input to the next random. That can easily get stuck on numbers (like 0000), which have the same output, so you should check that the previous value was different than the current value, and if not, do something (like add your original number, or multiply the previous by the original, or whatever you want).
Or… just do a search on google, you’ll find plenty of examples… probably many that you can just copy/paste. The only specific implementation is the seeding… most PC based ones use a clock or something similar… the VB doesn’t really have anything like that easily accessible, so the counter on human input works pretty well.
DogP
So there’s no (for example) octox=rand like there is in some BASIC programming?
Like DogP said, no. Just use the method he first described: let a counter run in the background, increment it every CPU cycle and use its current value (or a value derived from it) as random number. I did the same in my games, works good enough. 😉
Here’s what I was thinking of doing. I was going to have a random number indicate which way the octopus was going, dividing the highest number the random thing can go by 4 (for the four directions), like I do when I’m programming my Atari 2600 games. Here’s what I’d do in Batari BASIC (where the highest number rand can get is 255):
x=rand/64
if x=0 then octox=octox+1
if x=1 then octox=octox-1
if x=2 then octoy=octoy+1
if x=3 then octoy=octoy-1
What I need to figure out is either how to stop the timer at a random time so it can determine the octopus’s movement, or a completely different way of going about this.
Level 21 added.
About the octopus:
I want to use DogP’s method of random programming (have a counter running when a user presses a key), but I’d need the counter to go all the time if I want the octopus to move all the time (which I do) to determine which of the four directions it could go. Here’s what I want to do: After 2 or 3 seconds or so, have the octopus change its direction (or keep going the way it was) depending on what a random variable says. How would I go about doing that?
Attachments:
I went Googling for random number generators in C and found this page:
http://www.ciphersbyritter.com/NEWS4/RANDC.HTM
I put in the first example, and it seems to like it except for when I compile it, it says there is a parse error before void in line 435. Problem is, there is a blank line before the word “void”, and the line before that looks to be correct. I’ve included my c file, but be warned that it probably won’t compile because of that error. What do i need to do to make this work?
UPDATE: I got the octopus moving! Huzzah!
Attachments:
OK, it’s not really a reason to celebrate, as the octopus always moves one way (down). I guess what I need to do is either find another way to get a random number or omit the octopus all together. Any suggestions in C language?
I don’t have time to try to figure out exactly what the random function does, but I see on line 445, you shouldn’t have the ; after the for line… it should be:
for(m=0;m<256;m++) t[m]=KISS;
I assume that loop initializes your random table, but as you have it in your code, your entire table is uninitialized, and you're clobbering the next address in memory, which is likely n. But what are you using to seed the generator? Without seeding, it'll be the same sequence every time.
DogP