What do you need help on? Cancel X

Jump to:
Would you recommend this Guide? Yes No Hide
Send Skip Hide

FAQ by DBM11085

Version: 1.0 | Updated: 03/18/2010

                              Family Basic FAQ
                        Viewable in Shift-JIS Format
                            For the NES/Famicom
                      Version 1.0 (Created 3/17/2010)
                              By Devin Morgan

      This file is Copyright (c)2010 Devin Morgan. All rights reserved.


Table of Contents

1. What's New
2. Introduction
3. Overview
4. Grammar Guide
5. Error Messages
6. Control Codes
7. Memory Map
8. Credits
9. Copyright Notice


-=  1. What's New -=

Version 1.0 (3/17/10): The first version.


-=  2. Introduction -=

Family Basic was one of the first versions of the programming "game" released 
for the Famicom. It made use of the Family Basic Keyboard, as well as the 
Famicom Data Recorder to save your programs. The language is a form of BASIC 
made specially for this release, but there are many similarities. In fact, 
you can get by quite nicely in this game if you have knowledge of old-school 
BASIC programming, even other variants of BASIC. It is a fun yet basic (no 
pun intended) game, where kids and adults can dabble in simple programming, 
even using some pre-made Nintendo character sprites and sounds in their 
programs! If you are not technically or logically savvy, this is definitely 
not for you. But for all you programmers out there, this is worth checking 
out for sure.


-=  3. Overview -=

General Information

Family Basic is a game released only in Japan on the Famicom, with the 
premise of introducing programming to the user. It makes use of a variant of 
the BASIC programming language called NS-HUBASIC (Nintendo/Sharp-Hudson 
BASIC). If you are familiar with BASIC programming, the syntax and most 
statements/keywords/functions are the same across the board. Being that BASIC 
is not my usual programming langauge, I tried my best to describe every 
available option in the NS-HUBASIC language in the sections below. For more 
detailed information, I found this to be a good resource:


There are other good resources available if you search around for BASIC 
programming books and tutorials. Granted, modern-day Visual Basic has its 
differences so materials may be hard to come by, but it should be easy enough 
to piece together in relation to this game regardless.

In order to save your work, you will need to have the Famicom Data Recorder 
connected and functioning. That is the only way to save (and then load) 
anything you do in this game.

Game Interface

In the original Family Basic (the version covered in this FAQ), when you 
first start up the game, you will go to a simulated computer interface, 
complete with the screen lighting up. It will prompt you to type in your 
name, so do that and hit Enter. Once you do that, the interface will cycle 
through each of the game modes you can access. At each option, you will have 
four choices you can make by pressing F1-F4 when prompted. Those options are:

F1 = Yes (ハイ)
F2 = No (イイエ)
F3 = Hello (コンニチハ)
F4 = End (オワリ)

When you press any of the buttons, you will have to press Enter to finalize 
your option, or you can use Ctrl + H to clear what was entered into the box. 
If you select F3 (Hello), you will be asked if you want your fortune told 
(ウラナイ). Say Yes and you will be asked to enter your age, and then your 
fortune will be told (it seems to keep looping for me, so if anyone can tell 
me what I am missing, it will be much appreciated).

Here is a quick rundown of each game mode you can access from the main 
screen. If you want to go to the next one, simply enter No; otherwise enter 
Yes. You can exit out of these modes once you are in them by pressing the ESC 
key. In all modes except for GAME BASIC, you can press Enter to "re-ink" your 
pen cursor. It is only there for effect; you won't actually run out of ink!

GAME BASIC: Press 1 to enter BASIC programming mode, 2 to enter BG GRAPHIC
            mode (where you can cycle through sprites and design something),
            or 3 to go back to the main screen. To exit out of BG GRAPHIC
            mode, press the ESC key followed by the END key.

Calculator Board (カリキュレータ ボード): Perform calculations by typing in
                                          numbers and symbols either manually
                                          or with the function keys.

Music Board (ミュージック ボード): Make sound effects and music by using the
                                   keyboard and function keys to arrange and
                                   experiment with the notes. Press F8 to
                                   play your composition, using Left/Right to
                                   speed up or slow the tempo while playing.
                                   F1-F7 will be the actual musical notes.

Message Board (メッセージ ボード): Type notes on this empty board using the

After cycling to the Message Board option, it will loop back to GAME BASIC. 
If you want to "log out" select End (F4) and you will be prompted to enter 
your name again to start over.

System Specifications/Limitations

ROM: 8-bit x 16K x 2 (Program ROM)
     8-bit x 8K (Character Generator)
RAM: 8-bit x 2K S-RAM

Characters: 8x8 dot matrix characters (letters, numbers, Katakana and English
            signs, symbols, and special characters)

Display: 28 columns x 24 lines
Colors: 52 (including black and white)
Sprites: 8
Sound: 2 single square waves, 1 triangular wave, 1 sound effect


When you declare a variable, you simply make up a name for it (it can be a 
single letter or a word) and set it equal to some value. If it is non-
numeric, like a string, the $ symbol must appear at the end of the variable 
name or it will be invalid. Otherwise, you don't need the $ symbol.

Example: NAME$ = "DEVIN"
         NUMBER = 24

Conditional Operators

When using programming logic in your IF .. THEN statements, you know that you 
need to provide an expression to be logically checked against. There are a 
lot of different conditional operators that can be used to compare two values 
in this game, and they are:

= (equal)
> (greater than)
< (less than)
>= (greater or equal)
<= (less or equal)
<> (not equal)

Writing Programs

In Family Basic, of course the main premise is to be able to write your own 
programs. This guide is not meant to teach you programming theory; you can 
learn that on your own. The sections below will give you information about 
the various statements and functions available to you; it's up to you to make 
something out of them. In this version of BASIC, you need to write line 
numbers before each line of code. A sample program will be as follows (if you 
don't type a line number, the program will not work and that line will be 
executed immediately):

10 FOR I = 1 TO 5 STEP 1
20 GOTO 30

After you are done typing your program, run it by typing RUN (no line number 
is required for that). If you want to stop your program while it is running, 
you can hit the Backspace key. If you want to edit the program you just 
wrote, simply move the cursor and type over the line you want to replace. Of 
course the above is a sample program designed to give an idea of how programs 
are written; feel free to make more complex ones of course!

One thing to note: you don't need to stick to having only one statement on 
each line! You can separate statements on the same line number by using a 
colon (:) symbol. Also, in most programming languages, the first value when 
counting is 0, but in some of the functions available to you, the first 
number is 1 (presumably for simplicity).


-=  4. Grammar Guide  -=

NOTE: Any value in brackets [ ] is optional; you don't need to enter a value
      in order for the code to be valid. * signifies a variable (numeric or
      otherwise), appropriate for the command/statement being used. An
      expression means something like A < B. The @ symbol represents a
      specified memory location in format & H####.

      Also, I tried my best to explain every command/statement/function, but
      if you know something I do not or can explain something much better, by
      all means contact me!


    Description: Clear the data at a specific memory address.
    Syntax: CLEAR & H****

    Description: Resume running the current program.
    Syntax: RUN [*]

    Description: Display your program's code on the screen (the optional
                 value is for you to specify a line number to view).
    Syntax: LIST [*]

    Description: Load a program from the tape.
    Syntax: LOAD ["filename"]

    Description: Save the program with the loaded filename.
    Syntax: LOAD? ["filename"]

    Description: Start a new program, clearing the currently open one.
    Syntax: NEW

    Description: Run the current program.
    Syntax: RUN [*]

    Description: Save the current program.
    Syntax: SAVE ["filename"]

General Statements

    Description: Clear data from an array or variable.
    Syntax: CLEAR

    Description: Stores the values to be used by the READ statement.
    Syntax: DATA * [, *, * ...]

    Description: Declare an array of specified length (varName is the name
                 you give to the array, with the numeric value following it
                 representing the length of the array).
    Syntax: DIM varName (* [, *]) [, *(* [, *]) ]

    Description: Declares the end of the program.
    Syntax: END

    Description: Create a looping conditional statement where the loop
                 continues as long as $i=* is valid. The value after TO is
                 the final iteration, and the optional STEP determines how
                 $i increments or decrements after each loop.
    Syntax: FOR $i=* TO * [STEP *]

    Description: Jump to a specified subroutine.
    Syntax: GOSUB *

    Description: Jump to a specified line of code.
    Syntax: GOTO *

    Description: Create a conditional statement where if some expression is
                 true, then the value after THEN will be executed.
    Syntax: IF (expression) THEN *

    Description: Receive input from the user's keyboard while the program is
    Syntax: INPUT [*] [; [*] ... ]

    Description: Receive input from the user's keyboard while the program is
                 running, except the line terminator(s).
    Syntax: LINPUT [*] [; [*] ]

    Description: Continue the program after the FOR loop ends.
    Syntax: NEXT

ON ..
    Description: Jump to a specified line of code to get a value for an
    Syntax: ON (value) GOSUB/GOTO/RESTORE/RETURN *[, *, * ...]

    Description: Changes the data in a specific memory location.
    Syntax: POKE @, * [, *, * ...]

    Description: Print the entered value on the screen.
    Syntax: PRINT [*] [; [*] ... ]

    Description: Reads the values stored in the variable(s) specified using
                 the DATA statement.
    Syntax: READ * [, *, * ...]

    Description: Add a comment to the code (add at the start of a line, and
                 that line will not be executed).
    Syntax: REM [comment]

    Description: Allows the same values used by the DATA statement to be used
                 by the READ statement again.
    Syntax: RESTORE [*]

    Description: Return from the subroutine (use with GOSUB).
    Syntax: RETURN [*]

    Description: Stop the running of the program.
    Syntax: STOP

    Description: Replace the value of a variable.
    Syntax: SWAP *, *

Screen Control Statements

    Description: Specify the character sprites to be displayed in the
    Syntax: CGEN *

    Description: Specify the background assigned to the sprites.
    Syntax: CGSET * [, *]

    Description: Clear the screen.
    Syntax: CLS

    Description: Set the color at a specified location on the screen (first
                 value is the column number, second value is row number,
                 third value is color)
    Syntax: COLOR *, *, *

    Description: Move the cursor to the specified coordinates on the screen
                 (the first value is the column number, and second value is
                 the row).
    Syntax: LOCATE *, *

    Description: Set the color code to be used.
    Syntax: PALET [B or S] *, *, *, *, *

Movement Commands

    Description: Stops the movement of the character sprite.
    Syntax: CUT * [, *, *, *, *, *, *, *]

    Description: Defines the character sprite and its movement.
    Syntax: DEF MOVE (*) = SPRITE (*,*,*,*,*,*)

    Description: Stop the movement of the character sprite and remove it from
                 the screen.
    Syntax: ERA * [, *, *, *, *, *, *, *]

    Description: Begin the movement of the specified character defined using
                 DEF MOVE.
    Syntax: MOVE * [, *, *, *, *, *, *, *]

MOVE (*)
    Description: Get the value of the character sprite at the specified
    Syntax: MOVE (*)

    Description: Move the character sprite to the specified coordinates
                 (first value is character sprite, second value is column
                 number, third value is row number)
    Syntax: POSITION *, *, *

    Description: Get the value of the horizontal coordinate of the character
                 sprite defined with DEF MOVE.
    Syntax: XPOS(*)

    Description: Get the value of the vertical coordinate of the character
                 sprite defined with DEF MOVE.
    Syntax: YPOS(*)

Special Statements

    Description: Define a string to a function key (F1-F8, defined as 1-8).
    Syntax: KEY *, "string"

    Description: Display the list of definitions mapped to the function keys.
    Syntax: KEYLIST

    Description: Temporarily pause the execution of the program (the optional
                 value determines the number of milliseconds the pause is).
    Syntax: PAUSE [*]

    Description: Enter BASIC mode (if you do a hard reset, you will go into
                 Hot Start mode).
    Syntax: SYSTEM

    Description: Display the background graphics in the foreground.
    Syntax: VIEW

Sound Control Statements

    Description: Make a beep sound.
    Syntax: BEEP

    Description: Play the selected musical value (Octave notation is valid as
                 in "o1CDE". A Rest value in seconds (R1) is also valid; for
                 example, "CDER1B").
    Syntax: PLAY "*"

Sprite Control Statements

    Description: Define the characters displayed in a sprite.
    Syntax: DEF SPRITE *, (*, *, *, *, *) = *

    Description: Specify the location of a defined sprite.
    Syntax: * [, *, *]

    Description: Stops the display of sprites on the screen.
    Syntax: SPRITE OFF

    Description: Allows the display of sprites on the screen.
    Syntax: SPRITE ON

Value Functions

    Description: Returns the absolute value of the specified number entered.
    Syntax: ABS (*)

    Description: Returns a randomly generated number given the specified
    Syntax: RND (*)

    Description: Returns the signum of the specified number entered. That is,
                 it will return -1 if a negative number, 0 if 0, and 1 if a
                 positive number.
    Syntax: SGN (*)

Character Functions

    Description: Converts the specified character into its ASCII value (for
                 example, ASC("A") will output 65).
    Syntax: ASC ("*")

    Description: Converts the specified numeric ASCII value into its
                 character output; basically the opposite of the ASC function
                 (for example, CHR$(65) outputs A).
    Syntax: CHR$ (*)

    Description: Converts the specified 16-digit hexadecimal code into its
                 value as a string (for example, HEX$(0000000000000010)
                 outputs A).
    Syntax: HEX$ (*)

    Description: Returns a substring of a specified string, reading from the
                 left side of the string for the specified length of
                 characters (first value is the string name, second value is
                 the numeric length value). For example, HELLO$ = "HELLO
                 WORLD", so PRINT LEFT$ (HELLO$,3) prints "HEL" as a result.
    Syntax: LEFT$ (string, #)

    Description: Prints the length of the specified string.
    Syntax: LEN (string)

    Description: Returns a substring of a specified string (first value is
                 the string name, second value is the number of the starting
                 character, third value is an optional substring length
                 number). If no length is specified, the result will be from
                 the starting value to the end of the string. For example,
                 HELLO$ = "HELLO WORLD", so PRINT MID$ (HELLO$,2,6) prints
                 "ELLO W" as a result.
    Syntax: MID$ (string, # [, #])

    Description: Returns a substring of a specified string, reading from the
                 right side of the string for the specified length of
                 characters (first value is the string name, second value is
                 the numeric length value). For example, HELLO$ = "HELLO
                 WORLD", so PRINT RIGHT$ (HELLO$,3) prints "RLD" as a result.
    Syntax: RIGHT$ (string, #)

    Description: Converts a numeric value into a string variable type (any
                 non-numeric value will return 0).
    Syntax: STR$ (*)

    Description: Displays the numeric value of the specified input (for
                 example, VAL("A") outputs 0, while VAL("66") outputs 66).
    Syntax: VAL ("*")

Special Functions

    Description: Returns the current vertical position of the cursor.
    Syntax: CSRLIN

    Description: Returns the current horizontal position of the cursor.
    Syntax: CSRPOS

    Description: Returns the amount of free memory space remaining, in bytes.
    Syntax: FRE

    Description: Read the value stored at a specific memory location (used in
                 conjunction with POKE).
    Syntax: PEEK @

    Description: Displays any background sprites at a specified location
                 (first two values determine the sprites, the third value is
                 the line number).
    Syntax: SCR$ (*, *, *)

    Description: Returns the value of the Control Pad input.
    Syntax: STICK (*)

    Description: Returns the value of the controller button input.
    Syntax: STRIG (*)

Character Input Function

    Description: Stores input from the keyboard to be accessed elsewhere
                 without a prompt.
    Syntax: INKEY$ [(*)]


-=  5. Error Messages -=

Here is a listing of the possible error codes you can receive while 
programming. When they appear, it will appear immediately below the erroneous 
line (for example, "?SN ERROR").

Code    Description
----    -----------
CC      Can not continue executing
DD      Duplicate definition
DZ      Division by zero
FT      Formula is too complex
IL      Illegal function call
MO      Missing operand
NF      NEXT statement without a FOR (when using FOR .. NEXT)
OD      Out of data
OM      Out of memory
OV      Overflow (the result is out of the allowable range)
RG      RETURN statement without a GOSUB
SN      Syntax error
SO      Subscript is out of range
ST      String is too long
TM      Variable type does not match
TP      Tape read error
UL      Undefined line number (when calling a line with IF, GOSUB, GOTO, etc)


-=  6. Control Codes  -=

When doing your programming, you can enter these control codes to achieve an 
immediate result.

Code         Result
----         ------
CTRL + A     Toggle insert/overwrite mode
CTRL + C     Line break
CTRL + D     Revert to default for SPRITE, CGEN, etc.
CTRL + E     Clear rest of line ahead of cursor
CTRL + G     Beep
CTRL + H     Delete previous character
CTRL + J     Line feed/carriage return
CTRL + K     Go to first character of first line (home)
CTRL + L     Clear screen
CTRL + M     Skip a line (only if line is clear)
CTRL + R     Insert a space in front of the cursor
CTRL + V     Switch to Kana input mode
CTRL + W     Switch to Roman letter input mode
CTRL + Z     Clear rest of screen after the cursor


-=  7. Memory Map -=

This section details the memory allocation in the game, in the event that you 
need to know this sort of thing while programming.

Memory Range           Use
------------           ---
& H0000 - & H07FF     Work RAM
& H0800 - & H01FF     Not used
& H2000 - & H5FFF     Used by system
& H6000 - & H6FFF     Not used
& H7000 - & H703F     Used by system
& H7040 - & H77FF     Work RAM (BASIC-free area)
& H7800 - & H7FFF     Not used
& H8000 - & HFFFF     Program ROM


-=  8. Credits  -=

http://page.freett.com/familybasic/: For lots of excellent information about 
the Family Basic games.


-=  9. Copyright Notice -=

This file is Copyright (c)2010 Devin Morgan. All rights reserved. Please view 
the following URL to see the list of sites that are allowed to post my work:


This list is comprised of sites I know and trust well. If your site is not on 
the aforementioned list, you are currently not allowed to post any of my 
files on your site. Please respect my work and do not steal it or post it 
without my permission. I only want my most recent work to be available and I 
do not feel that can be achieved if others take from me without my knowledge 
or permission.

If you are writing a FAQ for this game as well, and would like to use some 
information, credit me for what you use. Please do not rip me off, as that is 
blatant plagiarism and such will not be tolerated.

If you wish to contact me, do so at dbmfaqs(at)gmail(dot)com. Please only 
contact me if there are corrections to be made to information that's 
currently included. Thanks!


=- End of File -=

View in: