*****************************************************************************
Family Basic V3 FAQ
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. Secrets/Tips and Tricks
9. Credits
10. Copyright Notice
*****************************************************************************
-=-=-=-=-=-=-=-=-=-=
-= 1. What's New -=
-=-=-=-=-=-=-=-=-=-=
Version 1.0 (3/17/10): The first version.
*****************************************************************************
-=-=-=-=-=-=-=-=-=-=-=
-= 2. Introduction -=
-=-=-=-=-=-=-=-=-=-=-=
Family Basic V3 was the latest version 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:
http://msdn.microsoft.com/en-us/library/sh9ywfdk%28VS.80%29.aspx
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 this version, there is no graphical interface; you go right to a black
screen where you can begin typing right away. There are, however, some built-
in games which you can access (see the Secrets section of the guide).
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.
=================================
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
=========
Variables
=========
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):
NEW
10 FOR I = 1 TO 5 STEP 1
20 GOTO 30
30 PRINT "HELLO, WORLD"
40 NEXT
50 PRINT "LOOP COMPLETE!"
RUN
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!
========
Commands
========
CLEAR
Description: Clear the data at a specific memory address.
Syntax: CLEAR & H****
CONT
Description: Resume running the current program.
Syntax: RUN [*]
LIST
Description: Display your program's code on the screen (the optional
value is for you to specify a line number to view).
Syntax: LIST [*]
LOAD
Description: Load a program from the tape.
Syntax: LOAD ["filename"]
LOAD?
Description: Save the program with the loaded filename.
Syntax: LOAD? ["filename"]
NEW
Description: Start a new program, clearing the currently open one.
Syntax: NEW
RUN
Description: Run the current program.
Syntax: RUN [*]
SAVE
Description: Save the current program.
Syntax: SAVE ["filename"]
==================
General Statements
==================
CLEAR
Description: Clear data from an array or variable.
Syntax: CLEAR
DATA
Description: Stores the values to be used by the READ statement.
Syntax: DATA * [, *, * ...]
DIM
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 (* [, *]) [, *(* [, *]) ]
END
Description: Declares the end of the program.
Syntax: END
FOR .. TO .. STEP
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 *]
GOSUB
Description: Jump to a specified subroutine.
Syntax: GOSUB *
GOTO
Description: Jump to a specified line of code.
Syntax: GOTO *
IF .. THEN
Description: Create a conditional statement where if some expression is
true, then the value after THEN will be executed.
Syntax: IF (expression) THEN *
INPUT
Description: Receive input from the user's keyboard while the program is
running.
Syntax: INPUT [*] [; [*] ... ]
LINPUT
Description: Receive input from the user's keyboard while the program is
running, except the line terminator(s).
Syntax: LINPUT [*] [; [*] ]
NEXT
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
expression.
Syntax: ON (value) GOSUB/GOTO/RESTORE/RETURN *[, *, * ...]
POKE
Description: Changes the data in a specific memory location.
Syntax: POKE @, * [, *, * ...]
PRINT
Description: Print the entered value on the screen.
Syntax: PRINT [*] [; [*] ... ]
READ
Description: Reads the values stored in the variable(s) specified using
the DATA statement.
Syntax: READ * [, *, * ...]
REM
Description: Add a comment to the code (add at the start of a line, and
that line will not be executed).
Syntax: REM [comment]
RESTORE
Description: Allows the same values used by the DATA statement to be used
by the READ statement again.
Syntax: RESTORE [*]
RETURN
Description: Return from the subroutine (use with GOSUB).
Syntax: RETURN [*]
STOP
Description: Stop the running of the program.
Syntax: STOP
SWAP
Description: Replace the value of a variable.
Syntax: SWAP *, *
=========================
Screen Control Statements
=========================
CGEN
Description: Specify the character sprites to be displayed in the
background.
Syntax: CGEN *
CGSET
Description: Specify the background assigned to the sprites.
Syntax: CGSET * [, *]
CLS
Description: Clear the screen.
Syntax: CLS
COLOR
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 *, *, *
LOCATE
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 *, *
PALET
Description: Set the color code to be used.
Syntax: PALET [B or S] *, *, *, *, *
=================
Movement Commands
=================
CUT
Description: Stops the movement of the character sprite.
Syntax: CUT * [, *, *, *, *, *, *, *]
DEF MOVE
Description: Defines the character sprite and its movement.
Syntax: DEF MOVE (*) = SPRITE (*,*,*,*,*,*)
ERA
Description: Stop the movement of the character sprite and remove it from
the screen.
Syntax: ERA * [, *, *, *, *, *, *, *]
MOVE
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
location.
Syntax: MOVE (*)
POSITION
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 *, *, *
XPOS
Description: Get the value of the horizontal coordinate of the character
sprite defined with DEF MOVE.
Syntax: XPOS(*)
YPOS
Description: Get the value of the vertical coordinate of the character
sprite defined with DEF MOVE.
Syntax: YPOS(*)
==================
Special Statements
==================
KEY
Description: Define a string to a function key (F1-F8, defined as 1-8).
Syntax: KEY *, "string"
KEYLIST
Description: Display the list of definitions mapped to the function keys.
Syntax: KEYLIST
PAUSE
Description: Temporarily pause the execution of the program (the optional
value determines the number of milliseconds the pause is).
Syntax: PAUSE [*]
SYSTEM
Description: Enter BASIC mode (if you do a hard reset, you will go into
Hot Start mode).
Syntax: SYSTEM
VIEW
Description: Display the background graphics in the foreground.
Syntax: VIEW
========================
Sound Control Statements
========================
BEEP
Description: Make a beep sound.
Syntax: BEEP
PLAY
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
=========================
DEF SPRITE
Description: Define the characters displayed in a sprite.
Syntax: DEF SPRITE *, (*, *, *, *, *) = *
SPRITE
Description: Specify the location of a defined sprite.
Syntax: * [, *, *]
SPRITE OFF
Description: Stops the display of sprites on the screen.
Syntax: SPRITE OFF
SPRITE ON
Description: Allows the display of sprites on the screen.
Syntax: SPRITE ON
===============
Value Functions
===============
ABS
Description: Returns the absolute value of the specified number entered.
Syntax: ABS (*)
RND
Description: Returns a randomly generated number given the specified
argument.
Syntax: RND (*)
SGN
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
===================
ASC
Description: Converts the specified character into its ASCII value (for
example, ASC("A") will output 65).
Syntax: ASC ("*")
CHR$
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$ (*)
HEX$
Description: Converts the specified 16-digit hexadecimal code into its
value as a string (for example, HEX$(0000000000000010)
outputs A).
Syntax: HEX$ (*)
LEFT$
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, #)
LEN
Description: Prints the length of the specified string.
Syntax: LEN (string)
MID$
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, # [, #])
RIGHT$
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, #)
STR$
Description: Converts a numeric value into a string variable type (any
non-numeric value will return 0).
Syntax: STR$ (*)
VAL
Description: Displays the numeric value of the specified input (for
example, VAL("A") outputs 0, while VAL("66") outputs 66).
Syntax: VAL ("*")
=================
Special Functions
=================
CSRLIN
Description: Returns the current vertical position of the cursor.
Syntax: CSRLIN
CSRPOS
Description: Returns the current horizontal position of the cursor.
Syntax: CSRPOS
FRE
Description: Returns the amount of free memory space remaining, in bytes.
Syntax: FRE
PEEK
Description: Read the value stored at a specific memory location (used in
conjunction with POKE).
Syntax: PEEK @
SCR$
Description: Displays any background sprites at a specified location
(first two values determine the sprites, the third value is
the line number).
Syntax: SCR$ (*, *, *)
STICK
Description: Returns the value of the Control Pad input.
Syntax: STICK (*)
STRIG
Description: Returns the value of the controller button input.
Syntax: STRIG (*)
========================
Character Input Function
========================
INKEY$
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. Secrets/Tips and Tricks -=
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=========================
Access the Built-In Games
=========================
On the prompt screen, you can type in commands to access the four built-in
games included in the game:
Command Game
------- ----
GAME 0 Heart Game
GAME 1 Number Game
GAME 2 Mario Game
GAME 3 Star Killer Game
*****************************************************************************
-=-=-=-=-=-=-=-=-=
-= 9. Credits -=
-=-=-=-=-=-=-=-=-=
http://page.freett.com/familybasic/: For lots of excellent information about
the Family Basic games.
*****************************************************************************
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-= 10. 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:
http://www.freewebs.com/dbmfaqs/allowlist.html
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!
http://www.gamefaqs.com/features/recognition/3579.html
=- End of File -=