This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Developing with Family Basic?

Developing with Family Basic?
by on (#12252)
I am (perhaps) a bit interested in getting a FamilyBasic kit...
Has anyone tried to do any developing with the FamilyBasic? Are there any english translations of the manuals available perhaps?
Detailed information on this cool thing seems to be quite rare on google, sadly. :(
Re: Developing with Family Basic?
by on (#98501)
Hello!

First, sorry for my poor English. I only speak Spanish.
In a few weeks I'm trying to start developing a game in style of "Galaga" (or if it's possible, like 1942) using Family Basic. My "guide" code is a game called "Super Penpen". Here's the source:

1 CLS:A=2:B=3:DEFSPRITE1,(0,1,0,0,0)=CHR$(172)+CHR$(173)+CHR$(174)+CHR$(175):DEFSPRITEA,(0,1,0,0,0)=CHR$(104)+CHR$(105)+CHR$(106)+CHR$(107):DEFSPRITEB,(0,1,0,1,0)=CHR$(105)+CHR$(104)+CHR$(107)+CHR$(106):DEFSPRITE4,(1,1,1,0,0)=CHR$(116)+CHR$(117)+CHR$(118)+CHR$(119)
2 PALETS 0,15,48,38,18:PALETS 1,15,48,38,22:R=1:SPRITE1
3 LOCATE10,10PRINT"PUSH START":IFSTRIG(0)<>1THEN3
4 PLAY"T1Y2O5B5GGFERCD:Y2T1O1G5FEGFECD"
5 CLS:X=0:Y=127:LOCATE9,5PRINT"SUPER PENPEN":LOCATE12,7PRINT"ROOM";R:FORN=0TO27:LOCATEN,10PRINTCHR$(192):LOCATEN,15PRINTCHR$(192):NEXT:SPRITEON
6 FORN=0TO24:SWAPA,B:SPRITEA,X,Y:SPRITEB:X=X+1:PAUSE6:NEXT:I=10:FORN=0TO4:LOCATE0,I:PRINTCHR$(192):I=I+1:PLAY"O1C0D":NEXT
7 ONR GOTO8,9,11,12,13
8 W=200:Z=110:J=7:GOTO35
9 W=200:Z=115:J=4:GOTO40
11 W=240:Z=127:J=20:GOTO47
12 W=205:Z=127:GOTO49
13 W=0:Z=127:K=127:SPRITE1,240,K:GOTO51
20 T=STICK(0):IFT=1THENX=X+3:GOSUB23:GOSUB56:IFX>236THEN54
21 IFT=2THENX=X-3:GOSUB23:GOSUB25:IFX<24THENX=24
22 PAUSE6:GOSUB25:GOTO24
23 SWAPA,B:SPRITEA,X,Y:SPRITEB:RETURN
24 SPRITE4,W,Z:RETURN
25 IFX>W-12THEN27
26 RETURN
27 IFX<W+12THEN29
28 RETURN
29 IFY>Z-10THEN31
30 RETURN
31 IFY<Z+10THEN72
32 RETURN
35 J=J-1:Z=Z+J:W=W-5:GOSUB20:IFJ=-7THEN38
36 IFW<24THENW=200
37 GOTO35
38 J=J+1:Z=Z+J:W=W+3:GOSUB20:IFJ=7THEN35
39 GOTO38
40 J=J-1:Z=Z+J:W=W-10:GOSUB20:IFJ=-4THEN43
41 IFW<24THENW=230
42 GOTO40
43 J=J+1:Z=Z+J:GOSUB20:IFJ=4THEN40
44 GOTO43
47 J=J-1:W=W-J:GOSUB20:IFW>235THENW=24:J=20:FORN=0TO44:GOSUB20:NEXT:W=250
48 GOTO47
49 W=W-1:GOSUB20:GOTO49
51 FOR N=0TO14:GOSUB20:NEXT
52 W=W+4:GOSUB20:GOTO52
54 IFR=5THENPLAY"O3B5BBGAO4C":GOTO65
55 R=R+1:SPRITEOFF:SPRITE4:PLAY"O4E5EGFR5DFAEGO5C9":PLAY"O4E5EGF7D5E7C":GOTO5
56 IFR=4THEN58
57 RETURN
58 IFX>150THEN60
59 RETURN
60 IFSTRIG(0)<>1THENRETURN
62 LOCATE17,15PRINT" ":S=0:PLAY"O5B5DGGEC:DFGEC"
63 PAUSE6:S=S+1:Y=Y+S:SPRITEA,X,Y:IFY>235THEN55
64 GOTO63
65 SPRITEA:K=K-1:SPRITE1,240,K:IFK<20THEN67
66 GOTO65
67 SPRITEOFF:CLS:FORN=0TO99:LOCATERND(27),RND(23):PRINTCHR$(205):NEXT
68 LOCATE7,4PRINT"CONGRATULATIONS":LOCATE10,7PRINT"YOU CLEAR!":LOCATE9,13PRINT"SUPER PENPEN"
69 PLAY"O3Y2G6ABGGABR9G6F:O0C8CGCG"
70 PLAY"A9G8F7G4F5A6BAFO5GGG:CDEAGB"
71 GOTO2
72 SPRITE4:PALETS 0,15,5,8,13:PLAY"O0B4AGFEDC":PAUSE100
73 CLS:SPRITEOFF:LOCATE10,10PRINT"GAME OVER":PLAY"O5C5CGGAAGRFFEEDDC":PAUSE100:GOTO2

In this code I found on a Japanese site, and I've only modified the DEF SPRITE's with CHR$ because the original has Japanese letters.
My idea is to edit tiles with "Tile Layer Pro" to create my own sprites.

I was reading that Family Basic has many limitations to do a game, but what are those limitations?

Thank you


[English Fairy was here]
Re: Developing with Family Basic?
by on (#98527)
Sorry, the first two lines are

0 CLS:A=2:B=3:DEFSPRITE1,(0,1,0,0,0)=CHR$(172)+CHR$(173)+CHR$(174)+CHR$(175):DEFSPRITEA,(0,1,0,0,0)=CHR$(104)+CHR$(105)+CHR$(106)+CHR$(107)
1 DEFSPRITEB,(0,1,0,1,0)=CHR$(105)+CHR$(104)+CHR$(107)+CHR$(106):DEFSPRITE4,(1,1,1,0,0)=CHR$(116)+CHR$(117)+CHR$(118)+CHR$(119)

Becuase the line 1 is too large to family basic and not work.
Re: Developing with Family Basic?
by on (#98547)
Well this is my $2 but :
If Family Basic was great we would know it. Since we know basically nothing about it, it probably means this device sucked so much that nobody cared about it.

The cartridge is NROM with 2k SRAM, which means your programs can only fit in 2kb, which is extremely small, and you can't use your own graphics.

That being said, even though it was the first programming language I ever learnt, Basic is horrible, and I probably never want to ever code anything in basic again !
Its even much worse than assembly, those line numbers, lack of any indentation and goto statements that goes everywhere is the most unfriendly possible way to program something (after piercing holes in a piece of paper to represent bits, like they did in the 60's).
Re: Developing with Family Basic?
by on (#98548)
If only the (72 pin) NES had a keyboard, I'd probably have already made some sort of better interpreted language for the NES on a better board (SNROM).
Re: Developing with Family Basic?
by on (#98549)
I think there is a real need for a good BASIC compiler for NES. A cross-interpreter, at least (prepare text on PC, run on the NES). This would serve as an entry level dev tool similar to BasiEgaXorz for Genesis. I personally would like to make one, but my knowledge in compilers design is still insufficient.
Re: Developing with Family Basic?
by on (#98550)
Shiru wrote:
This would serve as an entry level dev tool similar to BasiEgaXorz for Genesis.

Or batari Basic for the Atari 2600. Lots of people use it, and even start to pick up some ASM because of it.

Quote:
I personally would like to make one, but my knowledge in compilers design is still insufficient.

If I'm not mistaken, there are tools that will do all the heavy work of parsing the code for you.
Re: Developing with Family Basic?
by on (#98551)
Yes, lex and yacc and similar things are used these days all the way, but they are way over my head for now, so I would rather go the reinventing the wheel way if I was writing a compiler, and that would likely result in a buggy unsupportable thing.
Re: Developing with Family Basic?
by on (#98559)
I thought there already was a NBASIC or something. That Sac of Flour Heart of Gold game used it.
Re: Developing with Family Basic?
by on (#98563)
Bregalad wrote:
Well this is my $2 but :
If Family Basic was great we would know it. Since we know basically nothing about it, it probably means this device sucked so much that nobody cared about it.

Its even much worse than assembly, those line numbers, lack of any indentation and goto statements that goes everywhere is the most unfriendly possible way to program something (after piercing holes in a piece of paper to represent bits, like they did in the 60's).

BASIC is from the 60s, and was a leap above learning assembly mnemonics in hex. Give it some credit. In 1984, making your own programs do things on your TV screen was exciting and empowering for a lot of kids.

And Family BASIC has AUTO line numbering, anyway.
Re: Developing with Family Basic?
by on (#98565)
MottZilla wrote:
I thought there already was a NBASIC or something. That Sac of Flour Heart of Gold game used it.

NBASIC nbasic isn't really a BASIC.
Re: Developing with Family Basic?
by on (#98569)
thefox wrote:
NBASIC isn't really a BASIC.

batari Basic also has very little to do with BASIC. Then again, "basic" isn't just the name of an old programming language, it's an english adjective that might just be qualifying these newer languages, which are also meant for beginners.
Re: Developing with Family Basic?
by on (#98571)
tokumaru wrote:
thefox wrote:
NBASIC isn't really a BASIC.

batari Basic also has very little to do with BASIC. Then again, "basic" isn't just the name of an old programming language, it's an english adjective that might just be qualifying these newer languages, which are also meant for beginners.

I guess what I was really trying to say is that nbasic isn't very good. :) It provides very little, if any, benefit over doing the same stuff in assembly.
Re: Developing with Family Basic?
by on (#98572)
I see... From what I've heard, it's even buggy to the point of producing code that doesn't work on the NES.
Re: Developing with Family Basic?
by on (#98580)
That game I mentioned didn't obey simple vblank rules and would have corrupted graphics. I actually hacked a fix for it.

But I would agree that it makes more sense to just program in 6502 asm. Or if you want something better, try C.
Re: Developing with Family Basic?
by on (#98591)
tepples wrote:
If only the (72 pin) NES had a keyboard, I'd probably have already made some sort of better interpreted language for the NES on a better board (SNROM).
Possibly it can still be made, using the same protocol keyboard, using adapter if necessary to use on the 72 pin system.
Re: Developing with Family Basic?
by on (#98593)
One would also need an expansion port adapter to be able to plug in a Family Keyboard. The wire protocol is not compatible with the 7-pin connector, as the 7-pin connector does not provide $4017 D1 and D2.
Re: Developing with Family Basic?
by on (#98595)
Yes, make the expansion port adapter as well; that is what I meant.

In addition, if you wanted to, you could make an adapter to translate the PS/2 keyboard signals into Famicom keyboard signals in case you do not have the Family BASIC keyboard (regardless of whether or not you need an expansion port adapter as well), it can also be used with other programs using Famicom keyboard as well.
Re: Developing with Family Basic?
by on (#98675)
I see a real need to allow for more relaxed languages like BASIC for consoles. There maybe two alternatives people haven't considered:

Tying in BCX to cc65. People could code in BASIC and output C which cc65 could compile
http://bcx-basic.sourceforge.net/

Rewriting parts of ZX Basic to compile for NES. Here is a SMS port that's starting to spark interest again:
http://www.smspower.org/forums/viewtopic.php?t=12902
Re: Developing with Family Basic?
by on (#98685)
I actually considered both things a while ago and come to conclusion these aren't the way to go.

The Basic to C converters won't work effectively, because they are designed for well developed, modern C compilers for 32-bit platforms, and you have to use many tricks on the NES to get good perfomance from a C program. There are also various compatibility reasons, and probably difficulties with distribution - you won't want to tell a newcomer how to 'download this there, that there, now configure that and that etc'. It should work out of the box, in a few clicks in an installer, otherwise it makes no sense.

Retargeting an existing compiler is also a problem. First, there are no Basic compilers that were designed to be retargettable. They are designed for a certain platform, mostly modern ones. There are barely any open source compilers at all. Boriel's ZX Basic compiler is probably the only open source 8-bit Basic compiler, but besides not being designed to be retargettable, it is also written in Python, that raises distribution and compatibility problems. It is relatively easy to make a SMS version of the compiler, because both platforms share the same CPU, but changing it to 6502 will be a major pain.

So I'm personally pretty sure the only solution here is to make a new 6502 targeted Basic compiler from scratch.