Page 1 of 3

Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 2:48 am
by RetroSpark
Although many (most?) commercial Sega Genesis games were written in 68000 assembly language, some (including Ecco, The Lion King and Sonic Spinball) were written in C.

Are any commercial SNES games known to have been written in C (or another compiled language), or are they all believed to have used 65816 assembly?

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 3:14 am
by ARM9
Yes, some were written (at least partially) in C, was that all you wanted to know?

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 3:21 am
by Bregalad
I was asking myself the exact same question.

What matters to me however is not a yes/no answer, but a clear and accurate reference to : Game X was programmed with language Y.

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 3:34 am
by RetroSpark
ARM9 wrote:Yes, some were written (at least partially) in C, was that all you wanted to know?
Do you have any examples of games which used C?

Is there a way to know (or to estimate) whether a game made significant use of C, based only on a ROM dump?

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 6:39 am
by tepples
Possibilities:
  • If you see C format strings, then C was likely used. NovaSquirrel found (at least a subset of) C format strings in Koei games.
  • Or if you see the calling conventions of a particular C compiler popular at the time, then C was likely used.
  • Or if you see the characteristic unoptimized instruction sequences of a particular C compiler popular at the time, then C was likely used.

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 8:14 am
by Bregalad
tepples wrote:Possibilities:
  • Or if you see the calling conventions of a particular C compiler popular at the time, then C was likely used.
  • Or if you see the characteristic unoptimized instruction sequences of a particular C compiler popular at the time, then C was likely used.
Which of C compilers were popular at that time ?
What was their calling convention ?

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 8:21 am
by tomaitheous
tepples wrote:Possibilities:
  • If you see C format strings, then C was likely used. NovaSquirrel found (at least a subset of) C format strings in Koei games.
  • Or if you see the calling conventions of a particular C compiler popular at the time, then C was likely used.
  • Or if you see the characteristic unoptimized instruction sequences of a particular C compiler popular at the time, then C was likely used.
How does one identify such a string?

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 8:29 am
by ARM9
The only 65816 C compilers I know of from back then was ORCA/c, the zardoz toolchain and TMorita's lcc retarget (which used ORCA/m for the assembly/linker backend).

They (TMorita) supposedly used C for Zombies ate my neighbors. There was also this obscure japanese puzzle platformer that blatantly used the zardoz compiler (bought by wdc, called wdc816cc these days).
I've heard rumors that square used C in some of their later titles, still haven't seen anything that confirms this though.
Ballz 3D might have been written partially in C, it does a lot of things that imply that C was used.

Yes, it's possible, why do you want to know?
tomaitheous wrote:
tepples wrote:Possibilities:
  • If you see C format strings, then C was likely used. NovaSquirrel found (at least a subset of) C format strings in Koei games.
How does one identify such a string?
I don't think C strings indicate that C was used, C strings end with $00 and sometimes contain modifiers like %d and %s etc. This is a pretty useful format and I'd think assembly programmers back when used it as well.

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 9:20 am
by tepples
For the avoidance of doubt, by format strings I meant strings with format specifiers like "%d" and "%s" in them. These are what Nova found. True, an assembly language implementation of a subset of sprintf() called by pure assembly language could also use format strings. But Koei was trying to target multiple platforms with different instruction sets.

So let me add a fourth heuristic:
  • If the game came out on in several instruction sets (68000, 65816, and whatever the F else), and its code isn't tightly optimized, and it doesn't use a bytecode platform such as SCUMM or Z-machine, C was likely used.

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 11:33 am
by Drew Sebastino
I heard Chrono Trigger was written in C, but I don't remember where I heard it and it's probably false. If the Lion King on the Genesis was written in C, does anyone know if the SNES version is? (I don't know much about C, but this would probably allow for an easy conversion, if I'm right.)

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 12:08 pm
by Bregalad
Espozo wrote:I heard Chrono Trigger was written in C, but I don't remember where I heard it and it's probably false.
I do not know the inner working of the game, but this was maybe about the DS or the Playstation version.

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 2:13 pm
by Sik
Of note that a game programmed in assembly would be more likely to use sentinel values (a non-character value, e.g. 0xFF) than stuff like "%d" in strings, so finding printf-style formatting can hint at it being C (if the program also uses the stack heavily, chances are that's indeed the case). Also having a subset means nothing since games made in C for those consoles usually would have their own implementations of the standard functions and even then only the stuff that was needed (IIRC Sonic Spinball only implemented three format specifiers, for example - yes, I know that isn't SNES but point stands =P).

Re: Were any commercial SNES games written in C?

Posted: Tue Feb 03, 2015 2:51 pm
by koitsu
Bregalad wrote:
Espozo wrote:I heard Chrono Trigger was written in C, but I don't remember where I heard it and it's probably false.
I do not know the inner working of the game, but this was maybe about the DS or the Playstation version.
It was the SNES version I'm fairly sure. Going purely off memory from something discussed like 15 years ago: there are printf()-style strings found within the game code, and some reverse-engineering done by Internet people (whose names I forget) implied a lot of the methodology used looked C-focused, i.e. heavy use of stack-based addressing if I remember right, so that functions/etc. can get called by pushing pointers on the stack + accessing them within the subroutine.

Chrono Trigger is also one of those games where Square did stuff like lda #$2100/tcd just so they could access SNES MMIO registers via DP addressing.

Re: Were any commercial SNES games written in C?

Posted: Fri Feb 06, 2015 11:07 am
by ARM9
I found out what the game written in C was called, it's Sutte Hakkun. If you don't have wdc816cc and want to see what compiled C code for 65816 might look like, have fun.

Re: Were any commercial SNES games written in C?

Posted: Mon Feb 09, 2015 1:44 am
by Bregalad
koitsu wrote: It was the SNES version I'm fairly sure. Going purely off memory from something discussed like 15 years ago: there are printf()-style strings found within the game code
Sorry but no, there is no printf()-style strings in the SNES version of CT. The game doesn't even use ASCII to begin with, and a search for %d or similar in the ROM does not reveal anything.
and some reverse-engineering done by Internet people (whose names I forget) implied a lot of the methodology used looked C-focused, i.e. heavy use of stack-based addressing if I remember right, so that functions/etc. can get called by pushing pointers on the stack + accessing them within the subroutine.
Source, please.
Chrono Trigger is also one of those games where Square did stuff like lda #$2100/tcd just so they could access SNES MMIO registers via DP addressing.
This would rather point to hand-optimised assembly, although this is not necessary contradictory with another part of the game being written in C.