Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2017-02-22 17:37:28

Heigw
Member
From: Michigan-United States
Registered: 2017-02-22
Posts: 14

Help With Goto!

I have been trying to make a menu for a game.  For the entire menu I am only using the text on screen.  Every time I try to compile it with gbdk I get the following errors.  "
STWUH.c(462):error *** 'lvalue' required for 'assignment' operation .
STWUH.c(474):error *** 'lvalue' required for 'assignment' operation .
STWUH.c(488):error *** 'lvalue' required for 'assignment' operation .
STWUH.c(502):error *** 'lvalue' required for 'assignment' operation .
STWUH.c(509):error *** 'lvalue' required for 'assignment' operation .

F:\gbdk\bin>"

I have tried many things and always have recieved similar errors.  This is the code itself.  "
    gprintf("       Menu       "); /* Start menu */
    gotogxy(1,2);
    gprintf("                  ");
    gotogxy(1,3);
    gprintf("Start Adventure   ");
    gotogxy(1,4);
    gprintf("                  ");
    gotogxy(1,5);
    gprintf("Choose Scene      ");
    gotogxy(1,6);
    gprintf("                  ");
    gotogxy(1,7);
    gprintf("View Credits      ");
    gotogxy(1,8);
    gprintf("                  ");
    gotogxy(1,9);
    gprintf("About             ");
    gotogxy(1,10);
    gprintf("                  ");
    gotogxy(1,11);
    gprintf("                  ");
    gotogxy(1,12);
    gprintf("                  ");
    gotogxy(1,13);
    gprintf("                  ");
    gotogxy(1,14);
    gprintf("                  ");
    gotogxy(1,15);
    gprintf("                  ");
    gotogxy(1,16);
    gprintf("                  ");
    gotogxy(1,17);
    gprintf("                  ");
    gotogxy(1,18);
    gprintf("                  ");

Start:
    if(1=1) {
        gotogxy(5,17);
        gprintf("  ");
        gotogxy(3,17);
        gprintf("<-");
        waitpadup();
        if(J_DOWN) goto Scene;
        goto Start;
    }

Scene:
    if(1=1) {
        gotogxy(5,17);
        gprintf("  ");
        gotogxy(9,17);
        gprintf("  ");
        gotogxy(7,17);
        gprintf("<-");
        waitpadup();
        if(J_UP) goto Start;
        if(J_DOWN) goto Credits;
        goto Scene;
    }

Credits:
    if (1=1) {
        gotogxy(7,17);
        gprintf("  ");
        gotogxy(11,17);
        gprintf("  ");
        gotogxy(9,17);
        gprintf("<-");
        waitpadup();
        if (J_UP) goto Scene;
        if (J_DOWN) goto About;
        goto Credits;
     }

About:
    if(1=1) {
        gotogxy(9,17);
        gprintf("  ");
        gotogxy(11,17);
        gprintf("<-");
        waitpadup();
        if (J_UP) goto Credits;
        goto About;
    } "

I know the beginning at the menu is not good in any way, but I just started coding!  I just tried to cover the whole 18*18 tongue

Anyways, help is greatly appreciated.  An alternative to goto or fixing the problem that is causing goto to not work would be great.  Thanks.


I've just started coding in C for the gameboy.  Any help or tutorials would be greatly appreciated.

I am making a game that is an "Interactive Story."  If think you could help in any way or want to check on the progress here is the ROM and source-code.
Story Time... With Uncle Heigw: http://www.filedropper.com/story_2

Offline

 

#2 2017-02-22 19:11:02

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Re: Help With Goto!

goto isn't really all that supported in C. I suggest reading up on C before coding for the Game Boy. What I can tell you is if I can do it, anyone can. And instead of

Code:

goto About

try simply

Code:

About();

Try looking at some sample code, like my Oranges game I'm trying to make.

Last edited by chris (2017-02-22 19:12:36)


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#3 2017-02-22 21:21:32

Heigw
Member
From: Michigan-United States
Registered: 2017-02-22
Posts: 14

Re: Help With Goto!

Thank you for your help, since posting this I have read quite a bit on C programming at http://www.cprogramming.com/.  I will look at the Oranges game as well, maybe I could see some instances of functions I could use on my own projects.  Thank you for the help, but when I changed the instances of "goto About;" and the other gotos to "About();" it gave this error.
https://i.imgur.com/NDzKinb.png

This is the new code "
gprintf("   Story Time     "); /* Start menu */
    gotogxy(1,2);
    gprintf("                  ");
    gotogxy(1,3);
    gprintf("Start Adventure   ");
    gotogxy(1,4);
    gprintf("                  ");
    gotogxy(1,5);
    gprintf("Choose Scene      ");
    gotogxy(1,6);
    gprintf("                  ");
    gotogxy(1,7);
    gprintf("View Credits      ");
    gotogxy(1,8);
    gprintf("                  ");
    gotogxy(1,9);
    gprintf("About             ");
    gotogxy(1,10);
    gprintf("                  ");
    gotogxy(1,11);
    gprintf("                  ");
    gotogxy(1,12);
    gprintf("                  ");
    gotogxy(1,13);
    gprintf("                  ");
    gotogxy(1,14);
    gprintf("                  ");
    gotogxy(1,15);
    gprintf("                  ");
    gotogxy(1,16);
    gprintf("                  ");
    gotogxy(1,17);
    gprintf("                  ");
    gotogxy(1,18);
    gprintf("                  ");

Start:
    if(1=1) {
        gotogxy(5,17);
        gprintf("  ");
        gotogxy(3,17);
        gprintf("<-");
        waitpadup();
        if(J_DOWN) Scene();
        Start();
    }

Scene:
    if(1=1) {
        gotogxy(5,17);
        gprintf("  ");
        gotogxy(9,17);
        gprintf("  ");
        gotogxy(7,17);
        gprintf("<-");
        waitpadup();
        if(J_UP) Start();
        if(J_DOWN) Credits();
        Scene();
    }

Credits:
    if (1=1) {
        gotogxy(7,17);
        gprintf("  ");
        gotogxy(11,17);
        gprintf("  ");
        gotogxy(9,17);
        gprintf("<-");
        waitpadup();
        if (J_UP) Scene();
        if (J_DOWN) About();
        Credits();
     }

About:
    if(1=1) {
        gotogxy(9,17);
        gprintf("  ");
        gotogxy(11,17);
        gprintf("<-");
        waitpadup();
        if (J_UP) Credits();
        About();
    }
"

I did try only changing the single lines of code that were simply "goto place;" and nothing more but leaving the "if(J_BUTTON)" ones.  When I did that I got this error.

https://i.imgur.com/XspqIfm.png

Any suggestions?  Thanks.


I've just started coding in C for the gameboy.  Any help or tutorials would be greatly appreciated.

I am making a game that is an "Interactive Story."  If think you could help in any way or want to check on the progress here is the ROM and source-code.
Story Time... With Uncle Heigw: http://www.filedropper.com/story_2

Offline

 

#4 2017-02-22 21:26:32

chris
Member
From: USA
Registered: 2016-11-27
Posts: 142
Website

Re: Help With Goto!

Each subroutine, like About and stuff, needs to have a void in front of it, like so:

Code:

void About()
{
//code goes here.
}

Also, you need to put somewhere at the beginning of the code, a list of all your subroutines. Like in your code, it would be this:

Code:

void Start();
void Scene();
void Credits();
void About();

Also, it would be a good idea to name the first one main, like above, also you'd need to add void Main(); to the list.


My avatar is from Nintendo Power. I miss those days, so I decided to bring them back.

Offline

 

#5 2017-02-22 21:36:47

Heigw
Member
From: Michigan-United States
Registered: 2017-02-22
Posts: 14

Re: Help With Goto!

I already had a main (saw it on the cprogramming website wink).  After I checked out the oranges game I did that exact thing! going to check if it works now.


I've just started coding in C for the gameboy.  Any help or tutorials would be greatly appreciated.

I am making a game that is an "Interactive Story."  If think you could help in any way or want to check on the progress here is the ROM and source-code.
Story Time... With Uncle Heigw: http://www.filedropper.com/story_2

Offline

 

#6 2017-02-22 21:41:20

Heigw
Member
From: Michigan-United States
Registered: 2017-02-22
Posts: 14

Re: Help With Goto!

This is what I got.
https://i.imgur.com/RxKKToK.png

Thoughts?


I've just started coding in C for the gameboy.  Any help or tutorials would be greatly appreciated.

I am making a game that is an "Interactive Story."  If think you could help in any way or want to check on the progress here is the ROM and source-code.
Story Time... With Uncle Heigw: http://www.filedropper.com/story_2

Offline

 

#7 2017-02-22 21:45:15

Heigw
Member
From: Michigan-United States
Registered: 2017-02-22
Posts: 14

Re: Help With Goto!

Wait, I just tried again taking the void Start and others out of void main and it compiled it with no errors.

Edit: But the game did not turn out so well...  I am going to upload the C file in a sec so you can take a look.

Last edited by Heigw (2017-02-22 21:46:44)


I've just started coding in C for the gameboy.  Any help or tutorials would be greatly appreciated.

I am making a game that is an "Interactive Story."  If think you could help in any way or want to check on the progress here is the ROM and source-code.
Story Time... With Uncle Heigw: http://www.filedropper.com/story_2

Offline

 

#8 2017-02-22 21:52:21

Heigw
Member
From: Michigan-United States
Registered: 2017-02-22
Posts: 14

Re: Help With Goto!

Here is the C file and the GB that worked the last time.  After it boots up and you click A or Start a bunch of times and wait for the start menu to come up, it will then make the screen turn black and then have vertical lines going all along the screen.  I'm not sure what is wrong so it would be greatly appreciated to have a more experienced programmer take a look.  http://www.filedropper.com/story_2

Thanks.


I've just started coding in C for the gameboy.  Any help or tutorials would be greatly appreciated.

I am making a game that is an "Interactive Story."  If think you could help in any way or want to check on the progress here is the ROM and source-code.
Story Time... With Uncle Heigw: http://www.filedropper.com/story_2

Offline

 

#9 2017-02-23 06:45:38

nitro2k01
Administrator
Registered: 2008-02-22
Posts: 244

Re: Help With Goto!

This is a good explanation of how well goto works in C. smile

https://imgs.xkcd.com/comics/goto.png


Blog: Gameboy Genius
"A journey of a thousand miles begins with one small step"
Old Chinese Proverb

Offline

 

#10 2017-02-23 09:25:29

Heigw
Member
From: Michigan-United States
Registered: 2017-02-22
Posts: 14

Re: Help With Goto!

Thats what ive heard, but I decided to use it anyways xD


I've just started coding in C for the gameboy.  Any help or tutorials would be greatly appreciated.

I am making a game that is an "Interactive Story."  If think you could help in any way or want to check on the progress here is the ROM and source-code.
Story Time... With Uncle Heigw: http://www.filedropper.com/story_2

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson