Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - Free as in beer and mind C compiler that produces ROM-able code?

Reply to topic
Author Message
  • Joined: 15 Jul 2010
  • Posts: 15
  • Location: Essen, Germany
Reply with quote
Free as in beer and mind C compiler that produces ROM-able code?
Post Posted: Tue Jul 27, 2010 11:49 am
I dont need that for my current project, but it would be interesting to have for future ones, is there a C compiler out there that can produce ROM-able code without stupid tricks?

I tested z88dk but that one is very weird, not supporting all of Cs syntax, tends to overwrite itself producing the dreaded "SOFTWARE ERROR" on the real thing after a hard-reset.
The SMS library produces strange things on a real VDP as nobody seemed to have tested it on a real machine and i even managed to kill the stack. :3

Small-C has no libc and bootcode for SMS, so that one is out too.

So, what is left that i missed?
My expectation mark is where cc65 is, that one works as expected, optimizes and can produce ROM-able code but sadly just for 65xx CPUs.
  View user's profile Send private message
  • Joined: 27 May 2008
  • Posts: 161
Reply with quote
Post Posted: Tue Jul 27, 2010 12:48 pm
SDCC? I've never used it (or any of the other z80 C compilers) so I can't say anything about how good or bad it is.
  View user's profile Send private message
  • Joined: 15 Jul 2010
  • Posts: 15
  • Location: Essen, Germany
Reply with quote
Post Posted: Tue Jul 27, 2010 12:56 pm
mic_ wrote
SDCC? [...]

Thats what i meant with Small-C, sorry. :)
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14759
  • Location: London
Reply with quote
Post Posted: Tue Jul 27, 2010 12:59 pm
There isn't one. The Z88DK compiler is Small-C (with extensions) only, mainly because the standard library is too large to sensibly use on a system of this size. You could have a go with 8080 compilers, since the 8080 instruction set is supposed to be a subset of Z80.

The Z88DK SMS library could probably use some work. If it overwrites itself then it ought to be easy to figure out where it's doing that (b w 0..bfff in Meka) (and your devcart should have a write protect switch...). VDP issues should be solvable too, since it's probably either bad register settings or bad timing.

cc65 is also Small-C, albeit with some extensions. I think fixing up Z88DK is likely to be the best approach. But then, as a Z88 owner, I'm biased.

Neither Z88DK nor cc65 is great at optimisation. In particular, parameter passing on the stack in Z88DK is rather nasty.
  View user's profile Send private message Visit poster's website
  • Joined: 15 Jul 2010
  • Posts: 15
  • Location: Essen, Germany
Reply with quote
Post Posted: Tue Jul 27, 2010 3:35 pm
Maxim wrote
[...] If it overwrites itself then it ought to be easy to figure out where it's doing that (b w 0..bfff in Meka) (and your devcart should have a write protect switch...).


It does that with global variables as these are created "inside" the program code and not where the RAM is located.
Sure i can get around that with some hacking, ie, creating a variables.c with declaring the variables inside an #asm block. But that shouldn't be the normal way.

Maxim wrote
VDP issues should be solvable too, since it's probably either bad register settings or bad timing.


I think the latter as emulators tend to ignore the "bandwidth" of the VDP and accept every write as it comes. Works for old games as these are made with that in mind, but not if you are new to the system.
A newbie will write his software with an emulator and when he finally tries it on a real system he will conjure the big bad glitch gremlin...
BTW for that, could you implement a warning in Meka when a program tries to access the VDP too fast? :)

Anyway, i think i stick with assembler, its an old 8 bit system after all. And old 8 bit only seems to work good with assembler and/or BASIC, at least IMO. :)
  View user's profile Send private message
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14759
  • Location: London
Reply with quote
Post Posted: Tue Jul 27, 2010 4:07 pm
It ought to be possible, z88dk is supposed to work with ROM-based code. Maybe there's something missing from the SMS parts.
  View user's profile Send private message Visit poster's website
Reply to topic



Back to the top of this page

Back to SMS Power!