The (unofficial) Family BASIC reference manual *now with new revision!*

Started by infiniteNOP, November 03, 2013, 12:08:36 am

Previous topic - Next topic

infiniteNOP

Hello everyone,
I made a reference manual for Famicom's FAMILY BASIC V3. It is licensed under CC-BY-SA (http://creativecommons.org/licenses/by-sa/3.0/).
You can download it from http://www.filedropper.com/famibasicrefference (PDF file) and http://www.filedropper.com/famibasicrefference_1 (ODT source).
EDIT:Download from attachments section!
The current revision is: 2
Feedback is always appreciated! :)
NOTE:If you cannot see the attachments section, then please log in/register
Previously known as linuxlalala

P

Good job on this Linuxlalala! :)
A few comments.

Correct me if I'm wrong, but although jump instructions like GOTO and GOSUB may be considered bad practice by C programmers, in the case of BASIC and machine languages they are more or less necessary.

RESTORE command is explained in the Family Basic manual (not in the V3 one though). Check my signature for a link to the translated manual. Normally when you use a READ statement it will read the first DATA statement it can find in your program. But if you first use RESTORE [line no.] it will start reading from your specified line number instead.

The SYSTEM command doesn't produce any errors in V3 as far as I know. It should take you to a screen that says something like "Set the Backup Switch to ON if you want data to remain, and then turn off your Famicom". It's not really a system menu or anything but it's included in V3 for V1/V2 users that are used to type SYSTEM before turning off their Famicom. This way you can turn on the backup switch without strange things to happen (which happens if it's on in BASIC mode).

LINPUT is like INPUT but with a few changes:

  • "," can also be used as input data by the user.

  • Only one variable may be inputted by the user.

  • No "?" will be displayed when it waits for user input.

  • The initial character string may only contain max 31 characters, and will also be part of the result (these 31 characters includes data inputted by the user).



More detailed info in the Famibe manual.


Where did you see the OFF command? I can't find it, neither among the 74 commands in Family Basic nor among the 26 new commands in V3.

infiniteNOP

November 08, 2013, 05:13:57 am #2 Last Edit: November 08, 2013, 05:40:34 am by linuxlalala
I don't know Japanese, so that message seemed like an error to me :). The off command was inserted by accident -just confused NS-HUBASIC with some other BASIC...
Anyway, thank you for your corrections P, will enter them in the new revision as soon as I finish writing it!
Previously known as linuxlalala

infiniteNOP

 :pow:BUMP:pow:
New revision out, containing various changes and corrections, useful tables and several new commands.
Download:
PDF File: http://www.filedropper.com/famibasicrefference
ODT Source File: http://www.filedropper.com/famibasicrefference_1
Previously known as linuxlalala

uXe

The file(s) don't seem to be available anymore! :'(

Could you please re-upload? (pretty please!)

P

I have the PDF: http://www.filedropper.com/famibasicrefference



Here's some more feedback for linuxlalala


CLEAR actually has two uses:
1)If used with no parameters, all variable and array values become 0, and all string variable values become "" (null strings).
2) If a memory address is passed as a parameter (&H77FF or less in V2, and &H6FFF or less in V3), memory for your BASIC program and variables will be reserved only up to that address (instead of all the way up to &H77FF/&H6FFF). Useful for inline assembly in which you are supposed to reserve the memory up until where your assembly routine starts (so that your BASIC program doesn't accidentally overwrites your assembly routines). This will also reset variables.
You can check available memory left with "PRINT FRE" or "?FRE" to see that it has decreased after using CLEAR [address].

Here's an example of how to properly use the CALL command:

1)
First you'll need a 6502 assembly routine of course. Here's a simple one for testing:

 NOP
 NOP
 NOP
 RTS

This code will do nothing except waste a few clock cycles of time (too fast to notice it though) but if Family Basic doesn't crash running this code you know that it works.

2)
Assemble your assembly subroutine (web assembler here http://www.e-tradition.net/bytes/6502/assembler.html).
With the example code we get:
EA EA EA 60


3) Now for the BASIC code. First CLEAR the memory area before where you want to put your assembly subroutine. For this example with V2 we'll use address &H7700 for the subroutine, so we type: "CLEAR &H76FF".
If you are using V3 you'll need to put it in between &H6100 and &H6FFF or something.


4) Put your assembled subroutine in memory with POKE: "POKE &H7700,&HEA,&HEA,&HEA,&H60".


5) Finally CALL your subroutine: "CALL &H7700"


In our example it will look like this:

Example code for V2:
10 CLEAR &H76FF
20 POKE (&H7700),&HEA,&HEA,&HEA,&H60
30 CALL &H7700


Example code for V3:
10 CLEAR &H66FF
20 POKE (&H6700),&HEA,&HEA,&HEA,&H60
30 CALL &H6700


Type run and if it says "OK" without crashing it means it worked.

I hope I got everything right. For an assembly subroutine that actually do something, check out UglyJoe's awesome ROB control routine (although he doesn't use CLEAR)! http://www.famicomworld.com/forum/index.php?topic=9691.0

UglyJoe

Quote from: P on January 19, 2014, 06:20:36 pm
(although he doesn't use CLEAR)!


Gasp.  There's no harm since my demo program is so small, but the principal of it is important and I'm surprised that I missed it!  I must have been too caught up in 6502 assembly at the time to remember.


P

Here's a more fun example of a subroutine that actually does something instead of just NOPs (no operation), this time for V3.

 LDA #$5
 STA $6800
 RTS

This assembly code will load (LDA) the number 5 and store (STA) it at the memory location at the address &H6800.

When we assemble it we get the following hexadecimal numbers:
A9 05 8D 00 68 60


Then let's make a program that first POKEs the value 3 into memory at &H6800 and prints it out (using PEEK) to make sure that it has the value 3. Then write our subroutine that changes it to 5 and CALLs it. And finally we print &H6800 out again to make sure that it has changed to 5.
10 CLEAR &H66FF
20 POKE(&H6800),3
30 PRINT PEEK(&H6800)
40 POKE(&H6700),&HA9,&H5,&H8D,&H0,&H68,&H60
50 CALL &H6700
60 PRINT PEEK(&H6800)

When you enter RUN the program should first print out the number 3 and then 5, and there we have our proof that our subroutine actually worked. Of course we could just use POKE again to change the value in a memory location but where's the fun in that??

Advice: In order to make that code work in V2, just add &H1000 to all the addresses in the code (ie. change &H6800 to &H7800) and change the &H68 in the assembly subroutine into &H78.

Issun

Wow, so you can use inline assembly in family basic! I didn't know that. Although with the small amount of RAM and no CHR-RAM (it's only ROM right?) you'd be pretty limited in what you could do. Interesting nonetheless!  :)

P

Yes that makes it much more powerful. And yes it only has CHR ROM so we can't edit graphics in software. My guess is that it's because it's one of the earlier games for Famicom before CHR RAM became more common.

80sFREAK

Each thead about Family asic makes me blow off the dust from my sketches and write couple more lines of code.

[teaser mode on] JF-13 based hardware with 8kB SRAM, but without battery backup. CHR RAM, if there is enough room after removing composer/messagepad. SD card slot. [teaser mode off]
I don't buy, sell or trade at moment.
But my question is how hackers at that time were able to hack those games?(c)krzy

P

Sounds promising. :) But can't you use the V3 ROM? It already has all that other stuff already removed and you can reach BG GRAPHIC directly from the BASIC OS in V3.

zerolanding

Hey there fellas!
  I'm getting my feet wet in family basic, and having a blast with it. Happy to see that there are so many active users of this program. Printed a hard copy of the V.2 manual, and learning a lot. Could someone post a new link for the reference manual?

P