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 2008-03-25 22:04:56

Shiny
Member
Registered: 2008-03-17
Posts: 21

GBDK compiler, is there anything better?

After having worked with GBDK's compiler (lcc, specifically), I have come to the conclusion that it just plain sucks! Its error messages are so vague that I have no idea what it's trying to tell me most of the time and I keep getting this abysmal "error *** FATAL Compiler Internal Error in file 'gen.c' line number '349' : code generator internal error Contact Author with source code" error; after which the compiler crashes.

This has really been bothering me for a while and I'm starting to get frustrated. Has anyone else had this problem? Is there a way to fix it? I don't thinking contacting the author will do any good because GBDK hasn't been updated in ages so it's pretty much abandonware.

Is there a better C compiler that I should be using instead or that anyone would recommend? It must be one that's compatible with the GBDK libraries of course.

Offline

 

#2 2008-03-26 06:51:51

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

Re: GBDK compiler, is there anything better?

Exactly what causes the bug? Have you tried to pinpoint the problem?
You can probably boil it down to a certain statement that cuases the bug. Care to post some code?


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

Offline

 

#3 2008-03-26 09:12:36

dox
New member
Registered: 2008-02-24
Posts: 4

Re: GBDK compiler, is there anything better?

Afair there's no other C compiler available.  Check the other thread about C vs Asm.

Offline

 

#4 2008-03-26 17:28:46

Shiny
Member
Registered: 2008-03-17
Posts: 21

Re: GBDK compiler, is there anything better?

dox wrote:

Check the other thread about C vs Asm.

I looked and there is no information in that thread about it.

nitro2k01 wrote:

Exactly what causes the bug? Have you tried to pinpoint the problem?
You can probably boil it down to a certain statement that cuases the bug. Care to post some code?

Yes, I've tried pinpointing it, but I always get strange results. Commenting out certain lines will fix it, but that's definately not an ideal solution.

Here is some similar stripped down code that has the same problem:

Code:

#include <gb\gb.h>

void init(void);

typedef struct tObj_
{
    UINT8 inUse;
    UINT8 offset;
}tObj;

typedef struct tGroup_
{
    UINT8 x, y;
    tObj objs[10];
}tGroup;
tGroup groups[8];

void main(void)
{
    init();
    
    for (;;)
        {wait_vbl_done();}
}

void init(void)
{
    UINT8 i, t;
    
    groups[0].x = 0;
    groups[1].y = 2; // comment out this line and it compiles fine O_o
    
    for (i=0; i!=8; i++)
    {
        for (t=0; t!=10; t++)
        {
            groups[i].objs[t].inUse = 0; // comment out this line and it compiles fine O_o
        }
    }
}

lcc's output is as follows:

lcc wrote:

main.c(33):error *** FATAL Compiler Internal Error in file 'gen.c' line number '349' : code generator internal error
Contact Author with source code

And then it crashes with the usual "sdcc.exe has encountered a problem and needs to close.  We are sorry for the inconvenience." error.

Offline

 

#5 2008-03-26 18:13:30

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

Re: GBDK compiler, is there anything better?

Just a wild, untested guess, but what if you put x and y on separate lines in the struct?

Code:

UINT8 x;
UINT8 y;

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

Offline

 

#6 2008-03-26 18:20:34

Shiny
Member
Registered: 2008-03-17
Posts: 21

Re: GBDK compiler, is there anything better?

nitro2k01 wrote:

Just a wild, untested guess, but what if you put x and y on separate lines in the struct?

Doesn't work ):

Offline

 

#7 2008-04-04 07:23:16

www.BoumPower.ch
Member
Registered: 2008-04-04
Posts: 20
Website

Re: GBDK compiler, is there anything better?

I use GBDK and I'm not efficient with C (I write a lot with Borland Delphi-Pascal)

I'm currently writing a GB simulator (not emulator) that can help for writing GBDK software.

The main philosophy is to just add some conditionnal defines in the code and compile with LCC-WIN32 that produce a dll. The dll is linked to the GB simulator and run like a cartridge (on Windows OS). The LCC-WIN32 will probably display better error messages. The simulator will also have powerful debug capabilities but some native Gameboy access or assembly code will not be supported (need to have different code for GB or simulator with conditionnal defines)

Offline

 

#8 2008-04-04 08:27:19

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

Re: GBDK compiler, is there anything better?

www.BoumPower.ch wrote:

I use GBDK and I'm not efficient with C (I write a lot with Borland Delphi-Pascal)

I'm currently writing a GB simulator (not emulator) that can help for writing GBDK software.

The main philosophy is to just add some conditionnal defines in the code and compile with LCC-WIN32 that produce a dll. The dll is linked to the GB simulator and run like a cartridge (on Windows OS). The LCC-WIN32 will probably display better error messages. The simulator will also have powerful debug capabilities but some native Gameboy access or assembly code will not be supported (need to have different code for GB or simulator with conditionnal defines)

Oh cool! Things are starting to cook in the GB dev world! Joshua, a guy who's hanging on the #gbdev IRC channel is currently doing a project called FPGABoy (Not the same as Costis' project) which is aiming for a complete GB clone made using an FPGA (programmable logic)
I've seen the GB-PIC project long ago, but I thought it was dead. Is this project an extension of GP-PIC or something completely new?
One problem I can think of is that there's no way for the cartridge to interrupt the CPU. The closest you can come to that is to hook up something to the serial port and send a byte when you want to go into debug mode.
I think FPGABoy also has a good potential of becoming a nice debug board since you can theoretically single step the CPU and keep all register values and stuff in sync with the code running.
Hmm, now I got another idea too... What if you could have a piece of programmable logic inside a GB which controls the clock rate... That way you could single step the CPU by only sending a certain amount of clock pulses at any one time. You still couldn't set up conditional breakpoints based on (all) reads and writes.
Jaja! Rant mode over.


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

Offline

 

#9 2008-04-04 10:53:07

www.BoumPower.ch
Member
Registered: 2008-04-04
Posts: 20
Website

Re: GBDK compiler, is there anything better?

... GB-PIC project never die.... just run slowly because it's hard to find developpers for the GB side... (We have 50 boards at assembly state, soon ready....)


The GB simulator is an extension. It will be used for running the GB software and will be interfaced with the  PICSimulatorIDE from OshonSoft.com

This will have 3 main purposes :
-    virtually run an application with both sides (GB & PIC)
-    debug PIC with software stable on GB
-    debug GB software

Offline

 

#10 2008-04-05 17:42:46

Shiny
Member
Registered: 2008-03-17
Posts: 21

Re: GBDK compiler, is there anything better?

www.BoumPower.ch wrote:

<snip>

I'm afraid I have no idea what you are talking about (: I'm not very knowledgeable about these things (at all), but to me it sounds like a way to run and debug the same code on both the Gameboy and certain PIC microcontrollers or a way to debug code running on actual hardware.

I don't think I'll be using GBDK anymore anyways since I've become comfortable with RGBDS and the absolute control over the hardware it gives me. Though if it ever becomes stable in the future I might consider using it for writing simpler applications (which is problably all I'll ever write anyways XD).

Good luck with your project (:!

Offline

 

#11 2008-04-07 01:21:46

www.BoumPower.ch
Member
Registered: 2008-04-04
Posts: 20
Website

Re: GBDK compiler, is there anything better?

Shiny wrote:

...way to debug code running...

It's for debugging our hardware that have a PIC16F877 running simultally with the GB. The actual emulators (no$gb, bgb, ...) don't support special hardware, nor interaction possiblities with the PIC simultator.

Shiny wrote:

I don't think I'll be using GBDK anymore anyways since I've become comfortable with RGBDS

Yes... I also prefer assembly code, but I have thinked that they is a greater C programming community...So I had hope finding some programmer for this project. But it's still possible to write the code with RGBDS (if some interest to do it wink )

Last edited by www.BoumPower.ch (2008-04-07 01:23:42)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson