Sega Genesis Dev Kit (SGDK)
Moderator: Stef
-
- Very interested
- Posts: 81
- Joined: Tue Jul 10, 2007 7:45 pm
- Location: Brazil / USA
- Contact:
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Good ideaKanedaFr wrote:I take the liberty to mod this post as an annoucement, so it will be easier to find it and new users will see it too...
do you think I must move it on "Tools"?
I always go in the "Tools" section when i'm searching for this topic, i think it's definitly where we should find it (i know, i created the topic, i'm the only to fault :p)
This question not relates to devkit itself, but to GCC which this devkit uses.
I moved my project from SGCC to GCC from devkit. Because I already have many code which works with hardware directly, I don't need devkit code itself, so I removed it. I made new makefile.gen without including any libs and with new sega.s (only one change - directly call 'main' instead of 'start'). I changed variables types to correct ones, add volatile keyword to pointers, etc.
Now I have big problem. Project don't work. Base code works. Graphics loading, palette functions, vsync wait, input works. Both music and sound effects players works. But other code does not work.
I noticed that it because code hangs almost anywhere where % operation used, though in some places it works OK (always hangs in one place and not hangs in another, i.e. problem is stable). It hangs on lines like these (variables usually 'unsigned short' and 'short'):
x=(x+1)%40;
ptr=(ptr+1)%mwdt;
Is there something which I don't know about this operation in this compiler? (I often use such operations with many compilers and never had any problems) Or I broke something when remove unneeded devkit code? Or maybe it bug?
I moved my project from SGCC to GCC from devkit. Because I already have many code which works with hardware directly, I don't need devkit code itself, so I removed it. I made new makefile.gen without including any libs and with new sega.s (only one change - directly call 'main' instead of 'start'). I changed variables types to correct ones, add volatile keyword to pointers, etc.
Now I have big problem. Project don't work. Base code works. Graphics loading, palette functions, vsync wait, input works. Both music and sound effects players works. But other code does not work.
I noticed that it because code hangs almost anywhere where % operation used, though in some places it works OK (always hangs in one place and not hangs in another, i.e. problem is stable). It hangs on lines like these (variables usually 'unsigned short' and 'short'):
x=(x+1)%40;
ptr=(ptr+1)%mwdt;
Is there something which I don't know about this operation in this compiler? (I often use such operations with many compilers and never had any problems) Or I broke something when remove unneeded devkit code? Or maybe it bug?
Code: Select all
x=(x+1)%40;
ptr=(ptr+1)%mwdt;
could you test if this work :
Code: Select all
x=((x+1)%40);
ptr=((ptr+1)%mwdt);
Code: Select all
x++;
x%=40;
ptr++
ptr%=mwdt;
Not works.KanedaFr wrote:could you test if this work :Code: Select all
x=((x+1)%40); ptr=((ptr+1)%mwdt);
This works. But.. I also noticed one place where code hangs on:KanedaFr wrote:at least, I assume this works :Code: Select all
x++; x%=40; ptr++ ptr%=mwdt;
Code: Select all
ssy=sy%mhgt;
Code: Select all
ssy=sy;
ssy%=mhgt;
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
I use gcc 4.1.1 for my Genesis compiler and it works fine... as long as you remember to copy the correct libgcc.a file into the libs directory. You need the 68000 version, and the one in that dir by default was 680x0 (020+) version.
The ld file also needed some changes. There's a thread on setting up code::blocks with the devkit where I replied on the changes I did to get it working with gcc 4.
The ld file also needed some changes. There's a thread on setting up code::blocks with the devkit where I replied on the changes I did to get it working with gcc 4.
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
It can sound stupid but are you not simply doing division by 0 exception (%0) ?Shiru wrote:Not works.KanedaFr wrote:could you test if this work :Code: Select all
x=((x+1)%40); ptr=((ptr+1)%mwdt);
This works. But.. I also noticed one place where code hangs on:KanedaFr wrote:at least, I assume this works :Code: Select all
x++; x%=40; ptr++ ptr%=mwdt;
I.e., where result goes not same variable. In this case code like:Code: Select all
ssy=sy%mhgt;
..does not helps.Code: Select all
ssy=sy; ssy%=mhgt;
If not, do you checked the i_ldiv function in sega.s file ? as you don't have the base library you need manual implementation of 32 bits multiplication and division for GCC. Maybe the division code (used by modulo function) is buggy but i'm surprised as i never meet any problems. Did you modified it ?
This was first that I check. Of course not, especially in case %40 in code above.Stef wrote:It can sound stupid but are you not simply doing division by 0 exception (%0) ?
I use sega.s from devkit with only one modification - I replaced jump to 'start' to direct jump to 'main' (only one line).Stef wrote:If not, do you checked the i_ldiv function in sega.s file ? as you don't have the base library you need manual implementation of 32 bits multiplication and division for GCC. Maybe the division code (used by modulo function) is buggy but i'm surprised as i never meet any problems. Did you modified it ?
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
I realised i never replied your last post.Shiru wrote:This was first that I check. Of course not, especially in case %40 in code above.Stef wrote:It can sound stupid but are you not simply doing division by 0 exception (%0) ?
I use sega.s from devkit with only one modification - I replaced jump to 'start' to direct jump to 'main' (only one line).Stef wrote:If not, do you checked the i_ldiv function in sega.s file ? as you don't have the base library you need manual implementation of 32 bits multiplication and division for GCC. Maybe the division code (used by modulo function) is buggy but i'm surprised as i never meet any problems. Did you modified it ?
I think the 32 bits modulo operation is buggy, i guess you're doing it on 32 bits sized variable ? I rarely use modulo but i never meet any problem with division. I'll check the 32 bits modulo code in sega.s file, maybe a stupid bug.
Hi all,
I finally added a tutorial to use Eclipse CDT with Genesis Dev Kit
Check it out and see if it could suit your need...IF Code::Blocks doesn't suit you !
I finally added a tutorial to use Eclipse CDT with Genesis Dev Kit
Check it out and see if it could suit your need...IF Code::Blocks doesn't suit you !