Author Topic: N64 Development Tools  (Read 35945 times)

0 Members and 1 Guest are viewing this topic.

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
N64 Development Tools
« on: January 20, 2010, 01:32:06 PM »
Okay, if you want to work on N64 homebrew, you need decent tools. You need a compiler, and some libraries. I just finished making an up-to-date toolchain, using it to compile a few libraries and scummvm as a test.

This is the big one - the toolchain. This is gcc 4.4.2 with bintools 2.20. It's compiled for x86 under Xubuntu 9.04, but it should work on any reasonably recent distro in 32 or 64 bits. It has a few libraries already in the SDK directory - namely, the ones needed to compile scummvm.
n64dev-20100119.7z

It's organize like most of my toolchains - copy the n64dev directory to wherever you want it, and set a few envvars before using it.

Code: [Select]
export N64DEV=/home/jlfenton/Tools/n64dev
export PATH=$N64DEV/mips64/bin:$N64DEV/bin:$PATH
export LD_LIBRARY_PATH=$N64DEV/mips64/bin

Obviously, you'd change the path to n64dev to wherever you copied it. Here's the source for the libraries included so far.

libn64-20100119.zip
tremor-20100119.zip
zlib-20100119.zip

As I add more libraries, they'll get added to this post. The normal way to compile these is to do

Code: [Select]
make
make install

If there is a Makefile.n64 file present, then do

Code: [Select]
make -f Makefile.n64
make install -f Makefile.n64

If you wish to build your own toolchain, here's the makefile I made to do that. It's derived from the makefile used to build the toolchain for the Dreamcast.

make-tools-20100119.zip

Note: each library will have it's own license. Please abide by them. For example, the libn64 library is GPL v3. You cannot use it for closed source programs. I can use it for the menu because, like most other code here, the menu is MIT licensed, which is compatible with the GPL license. If you aren't sure what is or is not compatible, consult the GNU page on the matter.

http://www.gnu.org/licenses/license-list.html

If you want an example of making a major app with this, look at scummvm. First checkout the latest code from their repo.

Code: [Select]
svn co https://scummvm.svn.sourceforge.net/svnroot/scummvm scummvm
You'll find most of the N64 code in "backends/platforms/n64". I changed the Makefile just a smidgen to work with the layout of my toolchain. The makefile I used to compile scummvm is:

Code: [Select]
TOOLPATH = $(N64DEV)/mips64
LIBN64PATH = $(TOOLPATH)/sdk
GCCN64PREFIX = $(TOOLPATH)/bin/

srcdir = ../../..
VPATH = $(srcdir)

CC = $(GCCN64PREFIX)gcc
CXX = $(GCCN64PREFIX)g++
AS = $(GCCN64PREFIX)as
LD = $(GCCN64PREFIX)g++
OBJCOPY = $(GCCN64PREFIX)objcopy
AR = $(GCCN64PREFIX)ar cru
RANLIB = $(GCCN64PREFIX)ranlib

DEFINES += -D__N64__ -DLIMIT_FPS -DNONSTANDARD_PORT -DDISABLE_DEFAULT_SAVEFILEMANAGER -DDISABLE_TEXT_CONSOLE \
-DDISABLE_COMMAND_LINE -DDISABLE_FANCY_THEMES -DDISABLE_DOSBOX_OPL -DENABLE_VKEYBD -DUSE_ZLIB
LIBS += -lpakfs -lframfs -ln64 -ln64utils -lromfs

DEFINES += -D_ENABLE_DEBUG_
#DEFINES += -D_NORMAL_N64_DELAY_

USE_LIBMAD=0
USE_LIBOGG=1

ifeq ($(USE_LIBMAD),1)
DEFINES += -DUSE_MAD
LIBS += -lmad
endif
ifeq ($(USE_LIBOGG), 1)
DEFINES += -DUSE_VORBIS -DUSE_TREMOR
LIBS += -lvorbisidec
endif

LIBS += -lm -lstdc++ -lc -lgcc -lz -lnosys

CXXFLAGS = -g -O2 -fomit-frame-pointer -march=vr4300 -mtune=vr4300 -mno-extern-sdata -fno-rtti -fno-exceptions \
-Wno-multichar -Wshadow -I$(LIBN64PATH)/include -I$(TOOLPATH)/include -I./ -I$(srcdir) -I$(srcdir)/engines
LDFLAGS = -g -march=vr4300 -mtune=vr4300 -nodefaultlibs -nostartfiles -mno-crt0 \
-L$(LIBN64PATH)/lib -L$(TOOLPATH)/lib $(LIBS) -T $(TOOLPATH)/lib/n64ld_cpp.x -Xlinker -Map -Xlinker scummvm.map

TARGET = scummvm
DEPDIR = .deps
CXX_UPDATE_DEP_FLAG = -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP
MKDIR = mkdir -p
RM = rm -f
RM_REC = rm -rf

VERBOSE_BUILD=0
HAVE_GCC3=1
DISABLE_SCALERS=1
DISABLE_HQ_SCALER=1
USE_MT32EMU=0
USE_RGB_COLOR=0

ENABLED=STATIC_PLUGIN

#ENABLE_SCUMM = $(ENABLED)
#ENABLE_SCUMM_7_8 = $(ENABLED)
#ENABLE_HE = $(ENABLED)
#ENABLE_AGI = $(ENABLED)
#ENABLE_AGOS = $(ENABLED)
#ENABLE_AGOS2 = $(ENABLED)
#ENABLE_CINE = $(ENABLED)
#ENABLE_CRUISE = $(ENABLED)
#ENABLE_DRACI = $(ENABLED)
#ENABLE_DRASCULA = $(ENABLED)
#ENABLE_GOB = $(ENABLED)
#ENABLE_GROOVIE = $(ENABLED)
#ENABLE_GROOVIE2 = $(ENABLED)
#ENABLE_IHNM = $(ENABLED)
#ENABLE_KYRA = $(ENABLED)
#ENABLE_LOL = $(ENABLED)
ENABLE_LURE = $(ENABLED)
#ENABLE_M4 = $(ENABLED)
#ENABLE_MADE = $(ENABLED)
#ENABLE_PARALLACTION = $(ENABLED)
#ENABLE_QUEEN = $(ENABLED)
#ENABLE_SAGA = $(ENABLED)
#ENABLE_SAGA2 = $(ENABLED)
#ENABLE_SCI = $(ENABLED)
#ENABLE_SCI32 = $(ENABLED)
ENABLE_SKY = $(ENABLED)
#ENABLE_SWORD1 = $(ENABLED)
#ENABLE_SWORD2 = $(ENABLED)
#ENABLE_TEENAGENT = $(ENABLED)
#ENABLE_TINSEL = $(ENABLED)
#ENABLE_TOUCHE = $(ENABLED)
#ENABLE_TUCKER = $(ENABLED)

OBJS := nintendo64.o osys_n64_base.o osys_n64_events.o osys_n64_utilities.o pakfs_save_manager.o framfs_save_manager.o

include $(srcdir)/Makefile.common

MODULE_DIRS += ./

all: $(TARGET).v64

$(TARGET).v64: $(TARGET).bin ROMFS.img bootcode
cat bootcode $(TARGET).bin ROMFS.img > $(TARGET).v64
./pad_rom.sh

ROMFS.img:
genromfs -f ./ROMFS.img -d ./ROMFS -V romtest

$(TARGET).elf: $(OBJS)
$(LD) -o $(TARGET).elf $(OBJS) $(LDFLAGS)

$(TARGET).bin : $(TARGET).elf
$(OBJCOPY) $(TARGET).elf $(TARGET).bin -O binary

spotless : distclean
$(RM) *.bin *.elf *.v64 *.img *.bak *.tmp *.map

The finished result ran fine on my N64 Myth. If you want to learn more about scummvm, visit their web page at:
http://www.scummvm.org/
« Last Edit: January 20, 2010, 01:36:10 PM by ChillyWilly »

Offline Dr.neo

  • Administrator
  • Hero Member
  • *****
  • Posts: 3826
Re: N64 Development Tools
« Reply #1 on: January 20, 2010, 02:54:32 PM »
nice info mate  ~sm-37.gif~
In my world,have 0 and 1 only ......Matrix World......

Offline wraggster

  • Sr. Member
  • ****
  • Posts: 261
    • DCEmu Homebrew Network
Re: N64 Development Tools
« Reply #2 on: January 20, 2010, 05:00:06 PM »
awesome, i personally cant wait to see if anyone will port any emulators/games to the N64.

I know theres Snes, Nes, GB, GG/SMS and MSX Emulators, i must actually try them too, but it would be awesome to see whats doable on the N64.

I wish i was a coder, i would have a go at porting stuff myself


Webmaster of DCEmu

The Worlds Only Homebrew and Gaming Network Covering All Consoles.

Offline wraggster

  • Sr. Member
  • ****
  • Posts: 261
    • DCEmu Homebrew Network
Re: N64 Development Tools
« Reply #3 on: January 20, 2010, 05:04:05 PM »
With all these new carts that Neoflash are releasing i personally think that maybe the coders competitions should incorporate comps for n64/pce engine/snes/ds/gba and maybe even dump the PSP


Webmaster of DCEmu

The Worlds Only Homebrew and Gaming Network Covering All Consoles.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: N64 Development Tools
« Reply #4 on: January 20, 2010, 05:08:39 PM »
Thanks for this ChillyWilly! ::sm-24.gif::
I was waiting silently to release your full setup  ~sm-43.gif~ ~sm-42.gif~

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: N64 Development Tools
« Reply #5 on: January 20, 2010, 11:48:44 PM »
Okay i will contribute first!

Here are 3 of my libraries :

ELIB - Event library v2.0 ( An advanced & Function stackless event library with exclusive/signal callback support)

LIB Utility v1.1 - Contains all low level support code , like string handling& parsing/comparisons/Binary utilities and everything that you will  ever need.
(This one was developed to support both the SuperN64 Plugin and future versions of the menu)

LIB IO V1.0 - A very portable IO library
(This one was developed to support both the SuperN64 Plugin and future versions of the menu)

All my libraries don't require any linked library at all. 8)
(Except LIB IO , which is up to you!)

Edit : http://www.neoflash.com/forum/index.php/topic,5962.0.html
« Last Edit: January 22, 2010, 07:19:08 PM by Conle »

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: N64 Development Tools
« Reply #6 on: January 21, 2010, 02:03:34 AM »
Okay i will contribute first!

Here are 3 of my libraries :

ELIB - Event library v2.0 ( An advanced & Function stackless event library with exclusive/signal callback support)

LIB Utility v1.1 - Contains all low level support code , like string handling& parsing/comparisons/Binary utilities and everything that you will  ever need.
(This one was developed to support both the SuperN64 Plugin and future versions of the menu)

LIB IO V1.0 - A very portable IO library
(This one was developed to support both the SuperN64 Plugin and future versions of the menu)

All my libraries don't require any linked library at all. 8)
(Except LIB IO , which is up to you!)

Nice! Higher level libraries make the programmer's job easier as well. I was hoping you'd have those ready. Now to combine everything together to get the skeleton code for the menu going. Then we can work it into a working product.
 :D

Do you think these libs should go in the opening post, or do we want higher level libraries in their own thread/post?

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: N64 Development Tools
« Reply #7 on: January 21, 2010, 02:25:05 AM »
Do you think these libs should go in the opening post, or do we want higher level libraries in their own thread/post?

I believe a separate thread strictly for releases(tools/libraries/code snippets/docs) would be much better in order to keep this thread clean from related questions/requests/etc.

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: N64 Development Tools
« Reply #8 on: January 21, 2010, 03:20:47 AM »
I believe a separate thread strictly for releases(tools/libraries/code snippets/docs) would be much better in order to keep this thread clean from related questions/requests/etc.

Sounds good. Cleaner is better for tech threads.  8)

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: N64 Development Tools
« Reply #9 on: January 21, 2010, 03:51:41 AM »
Sounds good. Cleaner is better for tech threads.  8)
:D

By the way , i will release LIB Util v1.2 tomorrow , since i have to provide interface code for :
-Whitespace detection
-Whitespace skipping
-Int <-> String conversions

Of course all these without using any library at all.

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: N64 Development Tools
« Reply #10 on: January 21, 2010, 03:58:03 AM »
By the way , i will release LIB Util v1.2 tomorrow , since i have to provide interface code for :
-Whitespace detection
-Whitespace skipping
-Int <-> String conversions

Nice! I'll probably still be hammering out code, so it's not a problem. When you have it ready tomorrow, start a new sticky thread for libraries and stuff.

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: N64 Development Tools
« Reply #11 on: January 21, 2010, 04:11:16 AM »
Nice! I'll probably still be hammering out code, so it's not a problem. When you have it ready tomorrow, start a new sticky thread for libraries and stuff.


Okay i will do it  ~sm-42.gif~
If you need anything specific to add let me know. ::sm-29.gif::

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: N64 Development Tools
« Reply #12 on: January 25, 2010, 04:27:08 PM »
Quote
It's compiled for x86 under Xubuntu 9.04, but it should work on any reasonably recent distro in 32 or 64 bits.
I run this little distro called Windows.. doesn't seem to be supported.  ;)

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: N64 Development Tools
« Reply #13 on: January 26, 2010, 02:44:26 AM »
I run this little distro called Windows.. doesn't seem to be supported.  ;)

Nope! I suggest using linux in a virtual environment if you just have to stick with Windows. Another thing you could do is set up an old system with linux - that's what I do with Windows: my main system is linux and the old system gets XP.
 ::sm-29.gif::

Your other choice is to hunt around the net for a Windows cross-compiler for MIPS that isn't a hundred years old.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: N64 Development Tools
« Reply #14 on: January 26, 2010, 03:04:41 AM »
Yeah, I've already got a PSP toolchain for Windows. Just thought I'd point out that far from everyone runs Linux.