NES in BASIC?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
ludditesoft
Posts: 5
Joined: Tue Jan 08, 2008 3:41 pm

NES in BASIC?

Post by ludditesoft »

Hi there,

This is my first post. I'm wondering if it's possible to write a game completely in BASIC? I found this:


http://os4depot.net/index.php?function= ... es_dev.lha

And as I understand it, you can write a game in BASIC and have it converted to Assembler. Is that true? How bad are the limitations? I'm only beginning BASIC right now so, I have ways to go. I was hoping someone could give me input before I commit to this.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

It certainly is possible to have programs written in high-level languages (such as C or BASIC) compiled into NES code, as long as someone has programmed such a compiler. I'm not sure if there is anything specific for the NES, but I know of C compilers that output 6502 code.

I also know that some sort of BASIC dialect is being used to write Atari 2600 software (batari Basic or something), and since the 2600 isa much more limited machine than the NES (it has only 128 bytes of built-in RAM, for example), I assume you could write NES software in BASIC, yes.

As I said, I don't know if there exists such a compiler for the NES, someone else will have to answer you that. If there is, you should keep in mind that it probably won't be possible to write a game similar to, say, SMB3. In processors like the 6502, compiled code is much slower than human-written assembly code. This sort of speed limitation will get in the way of many things, from having a lot of enemies on screen at once to performing a large ammount of screen updates.

EDIT: Oh, just a quick note: Assembler is the program that converts assembly code into machine code. So, the name of the language is assembly, not assembler. It annoys me a bit when people mix up the two of them... =)

EDIT 2: Oh, now I remember nbasic... I don't know if it's any good though. Most people who get into nesdev'ing decide to go with assembly from the start.
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

EDIT: Oh, just a quick note: Assembler is the program that converts assembly code into machine code. So, the name of the language is assembly, not assembler. It annoys me a bit when people mix up the two of them... =)
True, but in French we use the same word for both of them.

And once you've learned (and mastered) a programming language it is very easy to learn another one. I've started with basic and learn the basic of assembly quickly. However assembly is hard to master as there is SO many small little tricks that can increase the performance of your code and so on. However, conventionnal assembly techniques aren't hard to learn, and you'll end up loving find those little tricks that makes your code more efficient that are unique to assembly language :wink:
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

tokumaru wrote:It certainly is possible to have programs written in high-level languages (such as C or BASIC) compiled into NES code, as long as someone has programmed such a compiler. I'm not sure if there is anything specific for the NES, but I know of C compilers that output 6502 code.
Like CC65 itself. A lot of us including myself use CC65's assembler. But few use its C compiler because 1. it isn't Free per DFSG/OSD and more importantly 2. it doesn't try to optimize much.
As I said, I don't know if there exists such a compiler for the NES, someone else will have to answer you that. If there is, you should keep in mind that it probably won't be possible to write a game similar to, say, SMB3.
Not everyone wants to make Recca. Some people just want to make I Can Remember.
In processors like the 6502, compiled code is much slower than human-written assembly code.
Some of this comes from the fact that C was designed for 16-bit or larger machines. Specifically, per the standard, short must be 16-bit or bigger, int must be short or bigger, and lots of operations promote their operands from char to int.
This sort of speed limitation will get in the way of many things, from having a lot of enemies on screen at once to performing a large ammount of screen updates.
Unless your code to blast a transfer buffer to VRAM is in a library written in assembly language and the rest is in BASIC. I myself learned 6502 assembly language by making graphics subroutines for my Applesoft BASIC programs.
EDIT 2: Oh, now I remember nbasic
And Family BASIC.
ludditesoft
Posts: 5
Joined: Tue Jan 08, 2008 3:41 pm

Post by ludditesoft »

Thank you for the input everyone. I asked because I'm only now learning batari basic and was hoping to make a NES game after that. I wasn't sure how hard of a task it would be to learn assembly. I'm by no means inclined in computer science or computer languages except HTML :P Is assembly something I could pick up simultaneously with BASIC or should I work on that BASIC project first?
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

If you know HTML, try writing a bit of JavaScript. If you can make tic-tac-toe or 1970s video tennis in JavaScript, you will more easily understand where to go next.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Bregalad wrote:True, but in French we use the same word for both of them.
Here in Brazil most people use the word "assembler" to talk about the language, and that annoys me. Very few people I know/knew have used the correct terms.
And once you've learned (and mastered) a programming language it is very easy to learn another one.
That is true. Although switching from high-level to assembly is a bit frustrating at first, if you know nothing about computer architecture. But in the case of the NES or the 2600, for example, even if you use some sort of high-level language, you have to be aware of some lower-level details. You can't really abstract everything.
However, conventionnal assembly techniques aren't hard to learn, and you'll end up loving find those little tricks that makes your code more efficient that are unique to assembly language :wink:
I agree.
tepples wrote:Not everyone wants to make Recca. Some people just want to make I Can Remember.
Sure, sure... I was just pointing out the limitations, that's all.
Unless your code to blast a transfer buffer to VRAM is in a library written in assembly language and the rest is in BASIC.
Yes... In the case of batari Basic, because of how complex it is to output graphics with the 2600, they even coded a full graphics kernel that works for a few different types of games, so that the programmer doesn't need to worry about updating the screen, he just has to set up all the data necessary for this. That should be easy enough foe beginners.
And Family BASIC.
How powerful is Family BASIC? Is it really possible to program a game with it? And I don't mean text games... I'm talking about games that are graphically nice, even if they are not very fast. And in order to make a standalone ROM, would you have to rip the interpreter and pack it along with your game?
atari2600a
Posts: 324
Joined: Fri Jun 29, 2007 10:25 pm
Location: Earth, Milkyway Galaxy, The Universe, M-Theory
Contact:

Post by atari2600a »

tokumaru wrote:How powerful is Family BASIC? Is it really possible to program a game with it? And I don't mean text games... I'm talking about games that are graphically nice, even if they are not very fast. And in order to make a standalone ROM, would you have to rip the interpreter and pack it along with your game?
Wikipedia's article's External Links led to this: http://nindb.classicgaming.gamespy.com/hvc-fb.shtml

I guess it'd roughly show the powerfulness...

Any Famicom owners (or *gasp* ROM pirates /shame) ever use this cartandkeyboard/ROMwithkeyboardsupportemulator?

Code: Select all

          *=$0000
loop      JMP loop
          .eof
User avatar
Hamtaro126
Posts: 786
Joined: Thu Jan 19, 2006 5:08 pm

Re: NES in BASIC?

Post by Hamtaro126 »

ludditesoft wrote:Hi there,

This is my first post. I'm wondering if it's possible to write a game completely in BASIC? I found this:


http://os4depot.net/index.php?function= ... es_dev.lha

And as I understand it, you can write a game in BASIC and have it converted to Assembler. Is that true? How bad are the limitations? I'm only beginning BASIC right now so, I have ways to go. I was hoping someone could give me input before I commit to this.
You can use Batari Basic, I was known as Atarihacker (and still am) in Atariage, To get Batari Basic, Go to Atariage.com and look for the link (or Google it.) Batari Basic is also written in C/C++. and has a easy setup to start working on it,

There is another NBASIC (Diffrend than the one mentioned) at the archived NESDEV main page that also includes a few useful tools. But I heard it is no longer good unless someone is picking it up for a fix/enhancement release!

Family basic might be too hard to control. unless someone makes a rewrite/disassembly and I do not request for it!

Other than that, You could be better off writing your own!

-Hamtaro126
Post Reply