Author Topic: SNES C compiler?  (Read 26287 times)

0 Members and 1 Guest are viewing this topic.

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
SNES C compiler?
« on: February 11, 2010, 05:51:09 AM »
Does anyone know of a C compiler for the SNES? preferably something easy to set up...

I would like to have a try at making some SNES homebrew, but have no idea where to start.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SNES C compiler?
« Reply #1 on: February 11, 2010, 09:43:59 AM »

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SNES C compiler?
« Reply #2 on: February 12, 2010, 05:54:23 AM »
Here is a linux sdk :
http://snesdev.antihero.org/?p=106
 ~sm-42.gif~



Edit , there is also a mingw compiler version:
Quote
#  The UnDisbeliever Says:
April 28th, 2009 at 1:06 am

After playing around with the Makefiles files I managed to compile it for mingw.

The binaries are here: http://undisbeliever.snesdev.net/snes-sdk.zip

You may need to install the minGW runtime files (http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=11598), however since I do not have access to a computer without mingw on it, I cannot say for sure.

You will also need python if you wish to use the optimizer (as it is a python script).

~sm-37.gif~
« Last Edit: February 12, 2010, 06:03:51 AM by Conle »

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1753
  • Just a coding machine.
Re: SNES C compiler?
« Reply #3 on: February 13, 2010, 09:21:43 AM »
How about just posting the home page for SNES-SDK instead of blogs that then redirect you?

http://code.google.com/p/snes-sdk/

 :D

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SNES C compiler?
« Reply #4 on: February 13, 2010, 01:16:15 PM »
How about just posting the home page for SNES-SDK instead of blogs that then redirect you?

http://code.google.com/p/snes-sdk/

 :D

You are right :-\ ::sm-07.gif::

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SNES C compiler?
« Reply #5 on: February 13, 2010, 05:58:38 PM »
How about, for those of us (me) who are not very good at setting stuff like this up, a simple guide to installing and compiling out first program?

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SNES C compiler?
« Reply #6 on: February 13, 2010, 07:38:53 PM »
Not C, but there's a tutorial-style wiki that contains code for WLA-DX: http://en.wikibooks.org/wiki/Super_NES_Programming

Some of the code isn't correct (the SPC loading code comes to mind). But at least it should get you started.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SNES C compiler?
« Reply #7 on: February 13, 2010, 09:18:24 PM »
How about, for those of us (me) who are not very good at setting stuff like this up, a simple guide to installing and compiling out first program?

Its very easy.Just include the libs/includes of the mingW version and make a special configuration in your compiler.

Something like this ->
http://snesdev.antihero.org/?page_id=84

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SNES C compiler?
« Reply #8 on: February 14, 2010, 11:33:33 PM »
Quote
make all
wdc816cc -wl -wp -sop -MS main.c -o main.o
make: wdc816cc: Command not found
make: *** [main.o] Error 127

Am I supposed to have wdc816cc.exe ? If so, where might I find it?

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SNES C compiler?
« Reply #9 on: February 14, 2010, 11:39:27 PM »
Maybe here?

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1753
  • Just a coding machine.
Re: SNES C compiler?
« Reply #10 on: February 15, 2010, 06:43:45 AM »
I just tried the snes-sdk linked above. This is all in Xubuntu 9.04, but should work in any reasonably modern linux distro. For Windows, you'd need a mingw or cygwin setup, or run something like xubuntu in a virtual environment.

First checkout the snes-sdk source.

Code: [Select]
svn checkout http://snes-sdk.googlecode.com/svn/trunk/ snes-sdk
After that, you need to edit one file to get it to compile correctly. The file is "snes-sdk/libs/Makefile" - change the line

Code: [Select]
../tcc-65816/816-tcc $(CFLAGS) -I. -o $@ -c $<

to

Code: [Select]
../tcc-65816/816-tcc $(CFLAGS) -I. -I../tcc-65816/include -o $@ -c $<

Otherwise, the compile fails while trying to compile malloc.c for libc.

If you're like me, you don't care for toolchains that install to /usr/local/. Why? Mainly because anytime you update your distro, you have to reinstall all your toolchains. Instead, I install my toolchains to a Tools directory in my home directory. If you wish to do the same, change two more files: "snes-sdk/Makefile" and ""snes-sdk/snesc/Makefile". In both, just change the "PREFIX" variable to

Code: [Select]
PREFIX = $(HOME)/Tools/snes-sdk

or wherever you wish to install the sdk to. Then it's just a matter of running

Code: [Select]
make
make install

If you chose to leave the sdk to install to /usr/local, you'll need to do "sudo make install" instead of "make install".

Then compile the sample program

Code: [Select]
cd snesc
make

That will make and run the program in an emulator. Quit the emulator and copy the file "snesc.smc" to the SNES directory in the Neo2 Ultra Menu directory, and add it to the SNES Myth. Note - be sure to set snesc.sms to LROM in the menu. It defaulted on my system (in v2.99) to HROM, which won't work as the sample is compiled as a LOROM.

Then boot the SNES Myth, select SNESC and press B. You should now be running the sample (simple breakout clone).
 ::sm-29.gif::

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SNES C compiler?
« Reply #11 on: February 15, 2010, 11:45:12 AM »
Very nice , i will install it soon!

Quote
If you're like me, you don't care for toolchains that install to /usr/local/

I'm like you i guess  ::sm-05::  ::sm-05:: :D

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SNES C compiler?
« Reply #12 on: February 16, 2010, 03:28:11 AM »
I'll give that a try...

[edit]


Any ideas on fixing this? or what even is causing it?
« Last Edit: February 16, 2010, 04:14:20 AM by spinal »

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1753
  • Just a coding machine.
Re: SNES C compiler?
« Reply #13 on: February 16, 2010, 04:18:56 AM »
You're in Windows... you need a path like "/c/Tools/snes-sdk" where you made a directory named "Tools" in the root of drive C:. Windows is case insensitive, so don't worry too much about matching capitalization on the names. The install part of the makefile will make the "snes-sdk" directory in Tools itself. You just need to make the Tools directory.

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SNES C compiler?
« Reply #14 on: February 16, 2010, 04:41:18 AM »
I created the tools directory in the root... didn't fix anything.

[edit] after reinstalling mingw32, I got this...
« Last Edit: February 16, 2010, 05:07:53 AM by spinal »