Were any commercial SNES games written in C?

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
RetroSpark
Posts: 7
Joined: Tue Feb 03, 2015 2:14 am

Were any commercial SNES games written in C?

Post 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?
ARM9
Posts: 57
Joined: Sun Aug 11, 2013 6:07 am

Re: Were any commercial SNES games written in C?

Post by ARM9 »

Yes, some were written (at least partially) in C, was that all you wanted to know?
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Were any commercial SNES games written in C?

Post 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.
RetroSpark
Posts: 7
Joined: Tue Feb 03, 2015 2:14 am

Re: Were any commercial SNES games written in C?

Post 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?
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Were any commercial SNES games written in C?

Post 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.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Were any commercial SNES games written in C?

Post 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 ?
tomaitheous
Posts: 592
Joined: Thu Aug 28, 2008 1:17 am
Contact:

Re: Were any commercial SNES games written in C?

Post 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?
__________________________
http://pcedev.wordpress.com
ARM9
Posts: 57
Joined: Sun Aug 11, 2013 6:07 am

Re: Were any commercial SNES games written in C?

Post 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.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Were any commercial SNES games written in C?

Post 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.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Were any commercial SNES games written in C?

Post 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.)
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Were any commercial SNES games written in C?

Post 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.
Sik
Posts: 1589
Joined: Thu Aug 12, 2010 3:43 am

Re: Were any commercial SNES games written in C?

Post 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).
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Were any commercial SNES games written in C?

Post 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.
ARM9
Posts: 57
Joined: Sun Aug 11, 2013 6:07 am

Re: Were any commercial SNES games written in C?

Post 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.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Were any commercial SNES games written in C?

Post 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.
Post Reply