List of Family BASIC tokens (keywords)

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
rga24
Posts: 2
Joined: Sun Sep 03, 2006 6:01 am
Location: UK
Contact:

List of Family BASIC tokens (keywords)

Post by rga24 »

Hi,

Here's a list of BASIC tokens for Family BASIC V2 and V3. I have 'saved' the programs used to obtain these as screen grabs using FCE Ultra. Contact me if you want the images.

I couldn't find anything like this on teh interweb so set about finding them myself. Some are obvious, others I'm still trying to understand. Unusual, NES-specific ones include "FILTER" on V3 (which sets the colour emphasis bits using an operand from 0 to 7) and "SCREEN" on V3 (which selects one of the two name tables).

One further thing to note is that, although both BASICs are integer BASICs using signed numbers from -32768 to 32767, V2 allows positive numbers to be input from 32768 to 65535 (although it treats them internally as negative), whereas V3 gives an error. Hence the BASIC program for V3 reads from 'negative' memory locations. The tokens seem to be stored in <token number> <ascii representation> format, where the token number is 128 or more.

Hope this is of some use to the Nesdev community. I think V2 uses the internal 2K SRAM only and V3 adds an 8K SRAM at $6000 - $7FFF, although it might in fact be 4K (2 x 2K SRAMs perhaps).

Richard


Family BASIC V2 tokens

GOTO
GOSUB
RUN
RETURN
RESTORE
THEN
LIST
SYSTEM
TO
STEP
SPRITE
PRINT
FOR
NEXT
PAUSE
INPUT
LINPUT
DATA
IF
READ
DIM
REM
STOP
CONT
CLS
CLEAR
ON
OFF
CUT
NEW
POKE
CGSET
VIEW
MOVE
END
PLAY
BEEP
LOAD
SAVE
POSITION
KEY
COLOR
DEF
CGEN
SWAP
CALL
LOCATE
PALET
ERA
XOR
OR
AND
NOT
<>
>=
<=
=
>
<
+
-
MOD
/
*
ABS
ASC
STR$
FRE
LEN
PEEK
RND
SGN
SPC
TAB
MID$
STICK
STRIG
XPOS
YPOS
VAL
POS
CSRLIN
CHR$
HEX$
INKEY$
RIGHT$
LEFT$
SCR$

Family BASIC V3 tokens

GOTO
GOSUB
RUN
RETURN
RESTORE
THEN
LIST
SYSTEM
TO
STEP
SPRITE
PRINT
FOR
NEXT
PAUSE
INPUT
LINPUT
DATA
IF
READ
DIM
REM
STOP
CONT
CLS
CLEAR
ON
OFF
CUT
NEW
POKE
CGSET
VIEW
MOVE
END
PLAY
BEEP
LOAD
SAVE
POSITION
KEY
COLOR
DEF
CGEN
SWAP
CALL
LOCATE
PALET
ERA
TR
FIND
GAME
BGTOOL
AUTO
DELETE
RENUM
FILTER
CLICK
SCREEN
BACKUP
ERROR
RESUME
BGPUT
BGGET
CAN
XOR
OR
AND
NOT
<>
>=
<=
=
>
<
+
-
MOD
/
*
ABS
ASC
STR$
FRE
LEN
PEEK
RND
SGN
SPC
TAB
MID$
STICK
STRIG
XPOS
YPOS
VAL
POS
CSRLIN
CHR$
HEX$
INKEY$
RIGHT$
LEFT$
SCR$
INSTR
CRASH
ERR
ERL
VCT
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers »

I actually made a similar list a while back (not as complete as yours though), it seems that I never released it though. I just got mine from viewing the ROM in a hex editor.

Interesting info. I don't know much about BASIC programming, but I do know the PLAY syntax is similar (if not identical) to MML.

I also know the BASIC was made by Hudon, so manuals for some version of HuBASIC might be interesting perhaps. I think they're all in Japanese though.
rga24
Posts: 2
Joined: Sun Sep 03, 2006 6:01 am
Location: UK
Contact:

Post by rga24 »

I made this list by examining the contents of ROM from BASIC itself, using the PEEK function. Once I'd found out where the tokens began, and the token format, I wrote a short program to parse the tokens and print them out on the screen.

I experimented with PLAY at the weekend. I only managed to get one note playing at once, but I did find the tempo command, the octave command and (most interestingly) a command to change the timbre of the sound. 'Y' takes an operand between 0 and 3, and selects one of the 4 pulse widths.

I'll see if MML can give me any further clues!
User avatar
hap
Posts: 355
Joined: Thu Mar 24, 2005 3:17 pm
Contact:

Post by hap »

I also know the BASIC was made by Hudson, so manuals for some version of HuBASIC might be interesting perhaps. I think they're all in Japanese though.
Most commands are universal, people familiar with or willing to study manuals of GW-BASIC, Q-BASIC, or even MSX-BASIC should have no problem getting used to this version.

The PLAY command:
CDEFGAB sets note, R sets pause. A number after a note sets note length, a # (sharp symbol) before a note sets semitone.
- O sets octave
- M sets mode (0 for bleep, 1 for piano)
- T sets tempo
- Y sets pulse timbre, as noted by rga24
- V sets volume
- : selects new channel (eg. PLAY"CDE:EFA:GAC")

The 3rd channel is the triangle wave, M, Y, V have no effect on it. A string longer than 32 characters seems to be invalid. For an example, look at the GAME 0 listing.

I don't know if there's a method to access the noise channel, and I doubt the DMC channel is supported.
Post Reply