Nintendo 64 console with EverDrive cartridge

Nintendo 64 Part 4: Emulation and Hardware

, Nintendo 64, Programming

This will be a short post, since I am just getting emulators set up and that’s pretty easy.

I’ve been using Mupen64Plus to test my demo ROM. Is this how I should be testing? How accurate are emulators?

My understanding is—software emulators for the Nintendo 64 are either inaccurate or slow. Nearly everyone using an emulator wants to play existing Nintendo 64 games and wants them to work. Even for existing games, the emulators are a bit rough, and there are plenty of games that just don’t seem to work in emulators. Some emulators apparently intercept OS calls rather than making a serious effort to emulate hardware, or hard-code the boot process instead of emulating the boot code on the cartridge.

The risk you take with emulators is that your game might work on the emulator but not work on real hardware. From the Discord:

A: got my game working on hardware again tonight, […]

B: What was wrong that it didn’t work on hardware?

A: oh man, it was a nightmare, I had memory alignment issues

B: Ouch! Not fun to deal with

Experts in the Discord recommended that I use Cen64 and MAME. (MAME has incorporated MESS, so if you read recommendations for MESS, they’re old recommendations).

Setting up MAME

MAME is a beast. It’s a massive project to emulate everything under the sun. To get it working for Nintendo 64, you need to acquire certain Nintendo 64 ROM images (ROMs for the N64 system, not for games).

Without the Nintendo 64 system ROMs, you’ll see the following error when running MAME from the command-line:

$ mame n64 -cart onetri.n64
Error opening translation file English
pifdata.bin NOT FOUND (tried in n64)
normpnt.rom NOT FOUND (tried in n64)
normslp.rom NOT FOUND (tried in n64)
Fatal error: Required files are missing, the machine cannot be run.

To fix this issue, acquire a file named n64.zip which contains those files and install it in one of the MAME ROM folders where MAME will find it, like ~/mame/roms.

Fortunately, a recent version of MAME (0.224, released August 26, 2020) is available from the Debian package repositories, so it’s easy to install. A warning appears when you run MAME:

THIS MACHINE DOESN’T WORK. The emulation for this machine is not yet complete. There is nothing you can do to fix this problem except wait for the developers to improve the emulation.

Once you start working with it, you can see why. The onetri demo performs very well on MAME, but retail Nintendo 64 games seem to be fairly slow. From what I understand, this is because the MAME Nintendo 64 emulator focuses on accuracy so people can use it to understand the hardware better.

Screenshot of MAME running a modified “onetri” demo
MAME running a modified “onetri” demo. Runs at full speed.
Screenshot of MAME running The Legend of Zelda: Majora’s Mask
MAME running The Legend of Zelda: Majora’s Mask (2000). Emulation is slow.

MAME certainly seems visually accurate, so it should be useful for testing. Maybe I can get my game running at full speed in MAME with frameskips?

MAME also supports controllers, which you can configure by pressing tab after the game starts and selecting “Input (this machine)”.

Setting up CEN64

CEN64 advertises itself as a “cycle-accurate Nintendo 64 emulator”, which is a tall order. I’d guess that very few games rely much on exact cycle timings. The MIPS VR4300 is a pipelined processor, has cache, and the attached RDRAM undoubtedly has complicated timing. It’s not like the 6502, where the exact timing for every instruction was written down.

CEN64 also needs the PIF IPL ROM, which is the pifdata.bin file inside the n64.zip file we used for MAME.

Screenshot of CEN64 running a modified “onetri” demo
CEN64 running a modified “onetri” demo. Runs at full speed.
Screenshot of CEN64 running Banjo Kazooie
CEN64 running Banjo Kazooie (1998). Emulation is slow.

The performance of CEN64 and MAME is very similar. The audio is choppy and it’s dropping lots of frames. A -multithread option speeds it up a bit at the cost of accuracy, but even with -multithread enabled it is slow.

Controllers

This is the controller I got for PC.

Off-brand Nintendo 64-style controller for PC

It’s listed on Amazon as a [USB Version] Classic N64 Controller. My plan is to do most of the testing on the PC if I can get away with it, either in an emulator or by building a PC version of the game, and having a reasonable N64 controller is important—mostly just because the N64 controller is so unique.

My system lists it as a SWITCH CO.,LTD. Controller (Dinput), and when I test the button assigments, they seem a bit arbitrary. Maybe there’s some reasoning here I don’t understand, or maybe this just corresponds to how some GPIO pins on the circuit bord got wired.

ButtonIndex
Start12
A1
B2
C⏴3
C⏵8
C⏶9
C⏷0
L4
R5
Z6

Real Hardware

A flashcart lets you test on real hardware. I ordered the EverDrive 64 X7, which costs more than twice as much as a refurbrished Nintendo 64 system from the local video game store, with warranty.

Importantly, the EverDrive 64 X7 model has a USB port, and you can use it to load ROM images directly onto the flash cart while it is in the system. That’s not as important if you want to play pirated games, but it’s a big deal for testing. Not all models have the USB port.

EverDrive 64 X7 cartridge

I don’t have pictures of the EverDrive 64 in use yet because I need to pick up my wife’s Nintendo 64 from her parents’ house. Soon!