Sunday, March 28, 2021

Family BASIC - Putting the "Computer" into the Family Computer

Courtesy of Wikipedia (taken by Evan Amos)

When Nintendo released its first console, the Famicom, the full name of the system was the Nintendo Family Computer.  In the early 1980s the line between video game consoles and home computers was a fuzzy one.  Some consoles, like the Odyssey^2 had a full (membrane) keyboard but were more like video game consoles.  Some computers like the Commodore 64 had a full-travel keyboard and a disk drive but could also play games via its Expansion Port.  At the Famicom's launch in 1983, the only software available for the machine were arcade game ports.  By the next year (1984) Nintendo had released a new product for the Family Computer which was intended to do more than just play another video game.  This product was released as Family BASIC on July 21, 1984, but was only released in Japan.  Did it succeed in turning the Famicom into a Family Computer?  

Family BASIC Hardware

The Family BASIC package came with two pieces of hardware.  The first was the Family BASIC cartridge.  The second was the Family BASIC keyboard.

Courtesy of the NES Cart Database (taken by bootgod)

The Family BASIC cartridge was unique then and since.  It contains 32KiB of Program (PRG-) ROM and 8KiB of Character (CHR-) ROM.  This is no more read-only memory than any other standard NES or Famicom cartridge uses without a memory mapper chip.  However, depending on the version, Family BASIC comes with either 2KiB or 4KiB of Working (W-) RAM.  There is an extra logic chip to disable the PRG-ROM chip when W-RAM is being read or written to as both memories are located on the CPU's address and data busses.  

There are two more unique features of this cartridge.  The first unique feature is a battery software backup on-off switch.  When the switch is on, the contents of W-RAM are not lost when the power is turned off to the Famicom because the switch disables the chip select on the W-RAM chip.  When the switch is off, then the contents of W-RAM may be lost when the power is turned off to the Famicom but the switch being off allows the Famicom to access the W-RAM, so the Off position is the correct position for normal use.  (NES games handle the issue by requiring the user to press reset while powering off the system, this keeps the CPU from sending spurious writes to the RAM during shutdown.) Only flip the switch on if you are ready to turn off the system and care about the contents of the W-RAM.

The second unique feature is that the batteries are user-replaceable AA batteries held in inside a compartment molded into the case.  Two AA batteries are required to keep the W-RAM powered.  Later cartridges use coin-cell batteries which are soldered to the cartridge PCB and encased in Famicom cartridge shells which are generally difficult to open.

There were four versions of the Family BASIC software released on cartridge.  The first three, v1.0, v2.0A and v2.1A, all look the same externally, using a large black shell.  They contain 2KiB of W-RAM.  Any one of these can be included with the Family BASIC keyboard.  There was also an early version called Playbox BASIC which functions like an alternate v1.0 version of Family BASIC and was only released for the Sharp My Computer C-1 TV.

Courtesy of the NES Cart Database (taken by bootgod)

The final version had significant changes to the underlying program's functionality and was released in 1985 as v3.0.  v3.0 uses a large red cartridge shell and has 4KiB of W-RAM.  It was released separately from the Family BASIC package and is more expensive to find these days.  

The Family BASIC keyboard has a large number of keys, 72, for a "toy".  The keys are full travel but somewhat small for adult western fingers.  The keyboard has certain similarities to a Commodore keyboard, such as having the " over the 2 key and separate @ and * keys.  However, the Family BASIC keyboard is more similar to the keyboard of a Sharp X-1 computer, with the kana and graph keys.  The keyboard connects to the Famicom via the 15-pin expansion port and is compatible with all official variants of the Famicom.  

The keyboard is wired so that it has a matrix two "columns" and eight "rows".  Every key is unique and none of them do anything special, so Left Shift can do something different than Right Shift.  The keyboard is scanned for input column 0, row 0, then column 1, row 0, then column 0, row 1 and so forth.  The column flip is done by the program, but the hardware controls the row increment.

The keyboard finally has a pair of 3.5mm mono audio jacks originally labeled "WRITE" and "READ" but later labeled "SAVE" and "LOAD".  When the names were changed, the SAVE jack was changed from black to red.  These jacks plugged into the Family Computer Data Recorder, which was a separate purchase.  The Data Recorder came with red and black audio cable for easier connections.  The Data Recorder is a standard cassette tape deck and any other standard cassette tape recorder and player could be used with the keyboard.  The Data Recorder was not the best cassette tape deck either, it lacks a tape counter, REMote and AUXillary jacks.  It can work with either 4xAA batteries or a 6v DC input.  I have a GE Personal Portable Recorder and Cassette Player made almost twenty years after the Data Recorders were made and it possesses nearly identical features, right down to the center negative polarity used for the DC input!

To connect the keyboard to an audio recording and playback device, connect the READ/LOAD jack on the keyboard to an Ear/Phone or Line Out connector and connect the WRITE/SAVE jack on the keyboard to a Mic or Line In connector.  

Family BASIC Software

Family BASIC was a port of Hudson Soft's HU-BASIC, which was cross-assembled on Sharp's computer line.  HU-BASIC, like most home computer BASICs, is based off Microsoft BASIC.  There will be many familiar commands and conventions to users familiar with a dialect of BASIC descended from Microsoft.  The standard HELLO WORLD program is entered and run in the usual fashion.  LIST, NEW, CLS, SAVE and LOAD work as you expect them to.  (You can use Shift + Clr/Home to clear the screen).


There are commands and differences singular to this dialect of BASIC.  Unlike a Microsoft BASIC, Family BASIC works only with integers, not decimals or floating point.  If you type PRINT 3/2 and press Return, the result is 1, not 1.5.  Lower-case English text is not present, but the kana key will permit you to type in katakana or English on a character-by-character basis.


There is a SPRITE command for defining and displaying sprites, a MOVE command for moving sprites, a PLAY command for playing music, a PALET command for changing the palettes of the sprites or the background/text and STRIG and STICK commands for taking input from the gamepad action and directionals.  

There are two important LOAD and SAVE commands in Family BASIC.  The normal LOAD and SAVE commands either loads a program from tape or saves a program to tape.  Background graphics tile maps are loaded into the internal 2KiB of Video RAM inside the Famicom.  Use the LOADS and SAVES commands to load or save background graphics data from/to tape for Family BASIC v3.

The Family BASIC package came with a thick manual to help teach people how to program in BASIC.  It also had a sheet showing all the graphics available to backgrounds and sprites.  Of course the manuals are in Japanese as is much of the text displayed in the program itself.  Scans and translations of these manuals can be found here.

The first thing to know about any version of Family BASIC is that it will not work at all without a keyboard.  If v1.0-v2.1A do not detect the keyboard, they will only show a black screen.  v3.0 will just show a message essentially telling the user to plug in the keyboard.  You should turn the Famicom off before plugging anything into or out of the Expansion Port.

All versions of Family BASIC allow you to select from 57 sprites, containing many sprites from Mario games prior to Super Mario Bros, 91 background tiles and 152 text characters.

Family BASIC v1.0-v2.1A


For Family BASIC v1.0-v2.1A, you will see a screen with a "Computer" screen, an "Operator" screen and F1-F4 on the bottom.  Press any key to get the Computer to start showing text.  After three screens of text, you will be prompted to type in your name.  You can type in anything here or just press Return.  After some more text, you will be asked if you wish to start "GAME BASIC".  To enter BASIC, press F1 (Yes) and then Return.  This will bring you to a menu were you can go to BASIC or go to the BG Graphic program.   If you hold down the T key as you boot the Famicom, you can bypass the Computer/Operator screen and go directly to the BASIC/BG Graphic Menu (except in v1.0, where it performs a memory test).

The button immediately below Return is the Kana (カナ) button.  This switches the keyboard between Alphanumeric mode and Katakana mode.  In this mode, only Katakana is available from the alphanumeric keys.  If you want numbers or symbols or punctuation (except for what is used in Japanese), you must return to Alphanumeric mode.  The GRPH key will give you the ゛version of the character.  The Shift key is used for kana sharing the YUIOP keys, giving the ゜version of those characters and the smaller version of the character if shown on the keyboard.  If the cursor is a blinking box, then the keyboard is in Katakana mode.  If it is a flashing square, then it is in Alphanumeric mode.


The BG Graphic program permits you to use the navigation keys to display tiles on the screen.  You use the Up/Down/Left/Right arrow keys to position the cursor on the tile you wish to change and press Spacebar to set the tile.  Hold down Spacebar to automatically fill a row of tiles from left to right.  Use Ins and Del to cycle across the eight tiles shown on the screen.  Use Clr/Home to cycle to the next eight tiles and hold Shift Clr/Home to cycle the tiles backwards.  Press Esc to bring up a menu where you can copy or move blocks of tiles, clear the screen, save or load a background or type text characters.  Press Spacebar to make your menu selection.  For the copy and move modes, Ins copies a tile and selects a tile to be moved and Del places the tile.  Most of the function keys will let you cycle through four palette options. The BG Graphic program is also how you save and load background graphics screen data from tape in these versions of BASIC, there is no SAVES or LOADS commands in these versions of Family BASIC.

Family BASIC v1.0-v2.1A also has three other programs you can use, the Calculator Board, the Music Board and the Message Board.  The calculator allows you to solve equations easier than the BASIC prompt, the music board allows you to compose music and the message board lets you write down a note.  The data for these programs can be saved to the W-RAM but not to tape, and they will overwrite any BASIC program in RAM.  The Music Board's data cannot be imported or used by BASIC.  In the Playbox BASIC prototype, there was a program called Biorhythm instead of Message Board included.

To enter one of these programs, instead of pressing F1 when the computer asks you if you want to use Game BASIC, press F2 (iie/no).  Then it will ask you if you wish to use the Calculator program, then the Music Board program and finally the Message Board program.  Press F1 when it asks you for the program you wish to use.  Alternatively you can select the program without waiting for the correct prompt by typing CAL., MES. or MUS. and pressing Return.  Do not forget the period.  To leave these programs, press Esc.  F3 (kon'nichiwa/hello) starts a dialogue with the computer which will result in the computer telling you your fortune.  

Family BASIC v3

Apparently realizing that the Computer/Operator text prompts were rather annoying to be encountered every time the Famicom was turned on, in v3.0 the cartridge always drops you to the BASIC program so you can begin typing your BASIC program right away.  F1-F4 selects one of the four built-in mini-games.  Alternatively you can enter the command GAME 0, GAME 1, GAME 2, 1 or GAME 3 to select one of the games.  The first game, Heart, requires the microphone on the Famicom's Controller II.  The second and third games, Penpen Maze and Mario World, require you to touch the numbers in order.  The fourth game is a Spacewar! clone called Star Killer.  

To get to the BG Graphic program, you can either type BGTOOL or press F2 and enter N at the prompt.  To leave the BG Graphic program, bring up the menu with Esc and then hit Stop.  This version of the BGTOOL can allow the program to use two screens worth of backgrounds.  

Family BASIC has enhanced commands as well as new ones like CRASH to detect object collisions.  These commands can make BASIC code take up less space.  With only 4KiB available to define the backgrounds and store a program's code, any little extra helps.  To store a single text character in BASIC is one byte, and the 2KiB in earlier versions was simply not enough to really program much of anything.  

In order to save your work to W-RAM, Family BASIC v1.0-2.1 and Family BASIC v3.0 have separate procedures.  In v1.0-2.1, if you are at the BASIC prompt, type the SYSTEM command to return to the menu screen which allows you to select BASIC and the BG Graphic program.  Then select End with the 3 key, which brings you back to the Computer/Operator screen.  When prompted to select GAME BASIC, hit F4 (owari/end).  Once the text ends, you can throw the Memory Protect switch on the cartridge to the On position.  With Family BASIC v3, you need only enter the SYSTEM command and you can safely turn the Memory Protect switch to the On position when the message with the word ON appears.  

If you turn on Family BASIC v3 with the Memory Protect switch On, the program will ask you to turn the switch Off and will do nothing until you do so.  With the previous versions, you will still see that Computer/Operator prompt but the program will still tell you to turn the Switch Off before it will run any programs. Although it seems counterintuitive, it makes sense because with that switch on, the cartridge's RAM is disabled.

The Legacy of Family BASIC

In Japan, the cost of a "true" home computer was very expensive, even for 8-bit machines like Sharp's X-1 or NEC's PC-8801 or Fujitsu's FM-7.  Most Japanese households were not ready for a plunge of thousands of dollars to take the office home with them.  Video game consoles were far, far cheaper devices and could play games as well or better than most home computers.  Family BASIC was priced to be more expensive than a standard video game cartridge, (¥14,800, same price as the Famicom) but not beyond the range of affordability.  Sega also has the SC-3000, a computer which was a modest success and based off the same hardware also used for its SG-1000 console.  Family BASIC was one tool to help keep the children from screaming they wanted a computer every birthday and Christmas season.  

Family BASIC was one of the few pedagogical programs Nintendo released, along with Donkey Kong Jr. Math and Popeye's English Lesson, during the early years of the Famicom.  In the manuals Nintendo had to document how the Famicom worked to a much greater extent than they otherwise needed to explain.  This helped some programmers such as Satoshi Tajiri, the brainchild behind Pokemon, get his start by allowing him to explore the hardware and use the concepts learned to help program his first game, Quinty.  

Family BASIC, while a modest success, did not result in a well-spring of programming interest in the Famicom.  The Famicom, despite its name, was a video game console, not a home computer.  Cassette tape storage was something the U.S. left behind in the 1970s with little nostalgia.  While Family BASIC maxed out at 4KiB, in 1977 the Apple II, the Commodore PET and the TRS-80's minimum configurations came in at 4KiB.  In order for the Family Computer to even attempt to be viable as a home computer, it would need a disk drive.  Nintendo made the Famicom Disk System but never released any kind of programming software for it.  No other games utilized the keyboard except to store custom level data (Arkanoid II, Excitebike, Lode Runner, Mach Rider and Wrecking Crew) or backup progress (Castle Excellent).  Family BASIC v3 was released as a separate product from the Family BASIC system and at ¥9,800, twice the price of a standard cartridge, it was not a big seller.

Nintendo AVS Peripherals on Display at the NYC Nintendo Store, courtesy of Reddit

When Nintendo was planning the launch of the US release of the Famicom, it originally designed a full host of peripherals for the "Advanced Video System", the name used for the prototype hardware before Nintendo decided on the "Nintendo Entertainment System".   Among these were a keyboard and a data cassette recorder.  The keyboard prototype has 72 keys with the katakana symbols removed and the kana key turned into a Caps Lock key.  Presumably if the Family BASIC software was translated into English, it would have had the ability to display lowercase English text.  It was not released and nothing was released for the NES officially or unofficially during its lifetime which even attempted to school users in the rudiments of a programming language.  As far as Nintendo was concerned outside Japan, the NES was a black box into which you inserted other smaller black boxes (one or two articles in Nintendo Power did discuss the workings in slightly greater detail).

If Nintendo released the keyboard for the NES, the keyboard would have had to work very differently.  The NES has fewer input and output ports via its controller ports than the Famicom has via its expansion ports.  Plus the controller ports have to share input lines with the controllers.  With inexpensive 8-bit computers like the Commodore 64 still around in the late 80s, it made little sense to introduce a programming cartridge.  Commodore BASIC could run rings around Family BASIC (mainly due to having nearly 10x the amount of memory available to BASIC).

One other "legacy" of Family BASIC cannot be left unaddressed.  The Chinese company Subor was well-known for making keyboard-based Famiclones.  Its keyboard-based Famiclones often supported a BASIC which looked and behaved suspiciously like Family BASIC.  Its Famiclones also had a dialect of BASIC which could save and load to disk or the interpreter could be loaded from disk.  They also supported floating point math and generally provided 8KiB of BASIC memory, addressing most of the faults of Family BASIC.

Saving and Loading with the Famicom Keyboard

If you have a cassette tape player or deck in working order, then it is easy to save and load programs from/to cassette tape.  However, if you no longer own one of those quaint devices, you need another recording and playback solution.  If you are using a PC, I would suggest recording the signal with Audacity via the line input port with the volume input set to the maximum.  The resulting recording will probably seem very low in volume.  Normalize the recording, you need something audible.  Try playing back the audio with the line out at its maximum volume.

Certain emulators, such as Nestopia, jNES and VirtuaNES can support tape images using the extensions .tp, .tpr, and .vtp, respectively.  Nestopia and VirtuaNES's formats are identical and are just 8-bit unsigned raw audio files with a sample rate of 32,000Hz.  Use Audacity's  "Import Raw Data" function and you can use these images with an original keyboard and its supporting software.

3 comments:

  1. Wow. I never knew this existed! I remember a similar product for the Atari2600, but never used it.

    ReplyDelete
  2. Currently going through a Famicom/NES fixation period, it's super cool to find blogs discussing these topics in 2021! Good job, keep it up

    ReplyDelete
  3. Curious, how is yours in English? I have the first cart and it’s all in Japanese. Am I missing something obvious?

    ReplyDelete