Author Topic: SNES C Compiler  (Read 10845 times)

0 Members and 1 Guest are viewing this topic.

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
SNES C Compiler
« on: February 21, 2010, 04:51:33 AM »
Let's start the new forum with some basic tools. Here's a good toolchain that is still being maintained. You can compile it from source for linux with little trouble, but I suggest getting the binaries for Windows - it's a chore to compile for Windows.
 ???

Okay, let's start with the toolchain's project page:
http://code.google.com/p/snes-sdk/
Edit by Conle : Mirror : https://github.com/conleon/snes-sdk

For Windows, download the binaries here (from UnDisbeliever):
http://undisbeliever.snesdev.net/snes-sdk.zip

(EDIT by Conle : Link is dead , get it from : http://www.neoflash.com/forum/index.php?action=dlattach;topic=6025.0;attach=3092  instead)

For linux, start by getting a copy of the repository code:

Code: [Select]
svn checkout http://snes-sdk.googlecode.com/svn/trunk/ snes-sdk
After that, you need to edit some files. First is 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 don't wish to compile the SNES9X emulation bundled with the toolchain, change the line

Code: [Select]
SNES9X=1
to

Code: [Select]
SNES9X=0
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 want to put the toolchain where you have full permissions. Now you should edit the makefile for the snesc example. After the LIBDIR variable, add this line:

Code: [Select]
INCDIR=$(PREFIX)/include
and then change

Code: [Select]
$(CC) $(CFLAGS) -I. -o $@ -c $<
to

Code: [Select]
$(CC) $(CFLAGS) -I. -I$(INCDIR) -o $@ -c $<
You might also change the emulator used to run the example, or comment out the line that runs the emulator altogether.

You are now ready to make and install the emulator.

Code: [Select]
make
make install

Remember that if you left the prefix set to /usr/local, you need to do "sudo make install" or you won't have permission to install.

Then make the example program as a test.

Code: [Select]
cd snesc
make

If you left its makefile set to run the rom in an emulator, it should now be playing. This example also works fine on real hardware with the Neo Myth.

Now you have a pretty nice C toolchain for the SNES!
 ~sm-42.gif~  ;D
« Last Edit: September 30, 2015, 05:40:38 AM by Conle »

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: SNES C Compiler
« Reply #1 on: February 21, 2010, 05:09:07 AM »
Very useful thread ::sm-29.gif::
I hope that Dr.Neo can embed the development board here :
http://www.neoflash.com/forum/index.php/board,60.0.html

Just like with MD/N64 fc.

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: SNES C Compiler
« Reply #2 on: February 21, 2010, 05:58:47 AM »
I like them separate. It makes it easier to tell at a glance if general or development related posts are pending.
 ::sm-09.gif::

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SNES C Compiler
« Reply #3 on: March 19, 2010, 09:13:58 PM »
I noticed that the example game is soundless.
What are the current options for adding sound to a SNES homebrew? and are they in any way compatible with SNESC?

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SNES C Compiler
« Reply #4 on: March 19, 2010, 11:28:47 PM »
The ones I know of that are publicly available are XMSNES and the MOD(?) player that gra wrote for his SNES game. I have no idea if they're compatible with SNESC.

Offline AndiNo

  • Newbie
  • *
  • Posts: 17
  • NEO newbie
Re: SNES C Compiler
« Reply #5 on: March 22, 2010, 11:40:39 PM »
Some months ago I already tried to use this SDK on Windows without success. I then had to use a virtual machine with Linux to be able to use it. Just today I somehow got the SDK working on Windows! :) Did anyone of you use it on Windows? I had to recompile the wlalinker.exe as it had wrong library pathnames hardcoded in it. I wonder why I haven't seen anyone write about this ???
Has anyone used the SDK to create something yet? (a game for example)

Offline spinal

  • Coder of DSision
  • Neo MOD
  • Hero Member
  • *
  • Posts: 796
    • spinalcode
Re: SNES C Compiler
« Reply #6 on: March 23, 2010, 12:46:08 AM »
I'm having a play with it at the moment. I have no idea how (if possible) to do any audio though, so I might have a silent game done eventually.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: SNES C Compiler
« Reply #7 on: March 23, 2010, 01:28:00 AM »
For those who prefer to use trackers to create music there are the options that I mentioned above (XMSNES and gra's MOD player). Since I didn't write them and never used them I don't know if and how they can be used with SNESC.

At some point I'll most likely add SNES support to XPMCK (my MML compiler kit), so that those who prefer MML (probably a minority) can use it to create music for the SPC700. Following tradition, I'll be writing the playback code for WLA-DX, so it might end up being compatible with SNESC, or at least require only minor modifications.  ~sm-51.gif~.gif

Offline AndiNo

  • Newbie
  • *
  • Posts: 17
  • NEO newbie
Re: SNES C Compiler
« Reply #8 on: March 23, 2010, 05:35:22 AM »
I'm having a play with it at the moment.
It would be interesting to see what you can do with it (if you have something to show). I still have to learn much about the SDK and even more about the SNES, so it'll take some time until I have something showable ready.

Following tradition, I'll be writing the playback code for WLA-DX, so it might end up being compatible with SNESC, or at least require only minor modifications.
Although I never heard of MML I like that you keep your software compatible to WLA so there's hope to me I can use it later ;)

Offline KungFuFurby

  • Newbie
  • *
  • Posts: 21
  • NEO newbie
Re: SNES C Compiler
« Reply #9 on: November 27, 2011, 08:07:57 PM »
For those who prefer to use trackers to create music there are the options that I mentioned above (XMSNES and gra's MOD player). Since I didn't write them and never used them I don't know if and how they can be used with SNESC.

At some point I'll most likely add SNES support to XPMCK (my MML compiler kit), so that those who prefer MML (probably a minority) can use it to create music for the SPC700. Following tradition, I'll be writing the playback code for WLA-DX, so it might end up being compatible with SNESC, or at least require only minor modifications.  ~sm-51.gif~.gif

The same person that did XMSNES also did SNESMod, which uses Impulse Tracker files. XMSNES is actually discontinued. I personally ported SNESMod over to the Mac for my own convenience and for those Mac users who want to use it (it is only tested on my Mac, which is an iMac G5 running Mac OS X 10.4.11). However, I haven't gotten any bug reports, and thus I have no idea if it works or not.

SNESMod for Mac