Nintendo Family BASIC Workflow by Garrett Gilchrist (TygerbugGarrett)

Written by Garrett Gilchrist (TygerbugGarrett)

Requires a ROM of Hudson’s Family BASIC 3 (1985) for the Nintendo Family Computer / Nintendo Entertainment System. Version 3 features 4KB of RAM, compared to 2KB in the more common Version 2.

Requires the Family BASIC Keyboard, or a similar NES Keyboard, or a NES Emulator with the Family BASIC keyboard set up. Not all emulators support the Keyboard.

Family BASIC was a Japan-only release which allowed users to type and run short programs in the BASIC programming language. This was geared toward hobbyists wanting to make simple games in the NES/Famicom style. All games use the same graphics.

A background for the game is created separately using the built-in BGTOOL, or can be pasted into RAM or ROM at 7BE0.

The cartridge was NROM (Mapper 0) with battery save. Programs could be saved to cassette audio tape, or loaded from cassette audio tape, using the Famicom Data Recorder. Some emulators reproduce this function.

Preserving, hacking and reproducing the Family Basic code:

Many Family Basic programs were published as code in hobbyist magazines at the time. Scans are now available via Gaming Alexandria’s ongoing projects.

https://archive.org/details/micomBASIC19841994

Nintendo Family BASIC Type in Games

Many programs use almost all the RAM available, which makes translating them tricky.

It is tempting to convert the images to an OCR text file, but this results in many errors. Since BASIC code will fail on any error, it is better to look closely at the magazine text and retype it by hand, as it requires that level of scrutiny.

Most emulators do not have the necessary functionality to convert a Family Basic text file into an NES ROM. My workflow involves the emulators NesTopia and VirtuaNES.

Many emulators do emulate the Family Basic Keyboard, and sometimes the Data / audiotape recorder for loading/saving programs, but this in itself is not enough.

NinTaco has a lot of features to copy/paste, load/save and autotype Family BASIC code, but the results weren’t working, possibly due to text formatting (UTF?).

NesTopia has an autotype feature, when you hit F12. Type up a text file with all your source code. You will have to remove all special characters, such as Japanese text and graphics, for now. I often replace this with Xes. Copy this to clipboard (Ctrl+C) then hit F12 in Nestopia, with Family Basic V3 running. It will type the program for you.

The Nestopia emulator has no real debug features. It does have a tape record output, which is how we’ll save our program. Start the data/tape recorder function. Type SAVE”(NAMEOFPROGRAM)” and let it run. Shut off the data recorder and/or exit the program. You will see the result as a .TP file under “Saves.” Rename this to .VTP.

I then loaded this into VirtuaNES, renamed as a VTP file, using the Family Basic LOAD command.

The Nestopia .tp file format is a headerless unsigned 8-bit PCM wave file with a 32000 Hz sampling rate. (The VirtuaNES format is identical.) You can do an “Import Raw Data” in Audacity (https://i.imgur.com/cHQGg.png) and save it as a wav file.

If you have audio of a Family Basic program, you can also convert it to this format in Audacity, saving it as raw data. For example, if you hear a Family Basic program being loaded in a Youtube video, that audio can be saved in this WAV format and then loaded in VirtuaNES.

Most emulators are sorely lacking in Family Basic support of this kind, and the best emulators for our purposes have no advanced debug features, like Mesen or FCEUX would have.

VirtuaNES is also lacking in debug features. It has a memory viewer but no output for it. So how do we convert the result to an NES ROM?

A VirtuaNES save state can be converted to NES by a program called STTONES, which you should be able to find via Google search or similar.

The Family Basic ROM I was using doesn’t say it has a battery-backed WRAM segment (the part that stores the game). Therefore VirtuaNES doesn’t have the 0x2000 extra bytes that STTONES wants: You need to set byte 0x6 from 01 to 03 first. Hack this in your hex editor os similar.

You need to have a (hacked) Family Basic V3.0 ROM renamed to FAMIBE_V3.nes and STTONES in the same folder.

Then run FAMIBE_V3 in VirtuaNES, load the code, run the code, and BREAK out of the code (using the End key). Then create a save state in VirtuaNES. It creates a FAMIBE_V3.st0 file that you can drop on STTONES.

Alternately, when you’ve got a Save State, open up your hex editor. There should be program data in the VirtuaNES Save State at about 0A14. Copy all of that data to about 2A14. Some FFs at the beginning will have to become 00s.

Now we run STTONES and have a more or less working file, which we can use for further hacking – for example, adding in special characters as hex, like Japanese text and graphics. All the stuff we had to X out of the source code previously.

Alternately we can use the Python remake STTONED.PY :
Usage: sttoned.py path/to/save_state path/to/family_basic.nes
https://gist.github.com/einstein95/f33906cd4ee0c6e1abae0b4141e08ea9

A background for the game is created separately using the built-in BGTOOL, or can be pasted into RAM or ROM at 7BE0.

Our background graphic can be created or recreated in Shiru’s NES Screen Tool (NESST), or similar tools like Frankengraphics’ NEXTT or Mario NESRocks’ NAW. If we want to hack the graphic tiles we can use YY-CHR.

New code was hacked in using a hex editor and/or the FCEUX emulator hex editor.

About Dustin Hubbard

Founder and owner of Gaming Alexandria. Obsessed with high quality scans of games for all systems as well as preserving games before they are lost.

Leave a Reply

Your email address will not be published. Required fields are marked *