gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS Misc > DS BASIC (V2.0)

#83298 - zzo38computer - Mon May 15, 2006 4:16 am

You can run BASIC on Nintendo DS. This program is based on a program called Integer Tiny Basic, I ported it to Nintendo DS and changed a bunch of stuff. You cannot edit programs on DS yet, but you can copy program to CF card and run.

http://zzo38computer.cjb.net/Nitro/dsbasic/
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.


Last edited by zzo38computer on Wed May 24, 2006 3:45 pm; edited 1 time in total

#83304 - tepples - Mon May 15, 2006 5:25 am

zzo38computer wrote:
You cannot edit programs on DS yet, but you can copy program to CF card and run.

Cannot edit programs on DS period, or cannot edit programs on DS without booting back into DSOrganize? If the programs are stored in an ISO 8859 encoding, then the user can edit code in DSOrganize and save it to the CF. But most 8-bit BASIC interpreters stored programs on tape or disk in a bytecode form, where keywords (PRINT, INPUT, LET, FOR, TO, STEP, NEXT, etc) were stored as single bytes with their high bit set.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#83318 - shaz - Mon May 15, 2006 1:02 pm

YES YES YES! I wanted this badly! Thank you zzo38computer
_________________
It's so easy to be wise. Just think of something stupid, then dont do it.

#83326 - zzo38computer - Mon May 15, 2006 4:17 pm

tepples wrote:
zzo38computer wrote:
You cannot edit programs on DS yet, but you can copy program to CF card and run.

Cannot edit programs on DS period, or cannot edit programs on DS without booting back into DSOrganize? If the programs are stored in an ISO 8859 encoding, then the user can edit code in DSOrganize and save it to the CF. But most 8-bit BASIC interpreters stored programs on tape or disk in a bytecode form, where keywords (PRINT, INPUT, LET, FOR, TO, STEP, NEXT, etc) were stored as single bytes with their high bit set.


If DSOrganize can edit text files in DOS format (line end=CRLF) then those files will work in DS BASIC. The programs don't require line numbers, and can be uppercase or lowercase, when edited by a text editor programs. I hope to also lets editing on DS BASIC as well, like some old BASIC, by typing in line numbers and commands.

Some things about DS BASIC:

  • You can press START is short for typing "RUN".
  • If you press SELECT it will list the .BAS files on the card to load.
  • There are no string variables, only numbers.
  • You can not do complex IF statements (as in A=0 OR B=3), but you can do something like IF A*(B-3)=0.
  • Commands or editing (SAVE, NEW, LIST, etc.) don't work yet, but I hope to add them in next weekend.

_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#83329 - Cooleo - Mon May 15, 2006 5:17 pm

I really wanted someone to port Basic to DS,and you have :D
Thank you times a million!

Could you make it so you could build it for flashcarts with programs too?or build on the flash cart?

Cooleo
_________________
Flashed DS and stuff for sale:
http://forum.gbadev.org/viewtopic.php?t=9642

#83333 - zzo38computer - Mon May 15, 2006 6:03 pm

Cooleo wrote:
I really wanted someone to port Basic to DS,and you have :D
Thank you times a million!

Could you make it so you could build it for flashcarts with programs too?or build on the flash cart?

Cooleo


I don't know how to do that, maybe I need to figure out how, or someone else that knows how, tell me how or do it yourself, but wait until I fix this software a bunch of stuff.

(Note: There is one command called FORGET, which is from INTERCAL and has a similar function as the INTERCAL command called FORGET)

I hope to add these new commands on the weekend:

  • ON n GOTO a,b,c,...
  • SOUND freq,duration
  • Editing commands: NEW, SAVE, LIST, etc.
  • Commands to create and manipulate savefiles
  • MENU startrow numrows column = can be used in an expression to display a menu so you can select one (as in: ON MENU 2 5 3 GOTO 100,150,200,250,300)

_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#83336 - Cooleo - Mon May 15, 2006 6:53 pm

Could you add beep and bell aswell?I dont think there is a DS command which can play interernal sounds,so you might have to subsitute it with a sound file!

Cooleo
_________________
Flashed DS and stuff for sale:
http://forum.gbadev.org/viewtopic.php?t=9642

#83338 - Scorpei - Mon May 15, 2006 6:56 pm

Me wanna play Gorilla again :D.
Sorry about that, ghmhmmh, anyway, I can't get Gorilla.bas to open (maybe it can't be run yet?).
Great job btw, I liked the old Basic games like Gorilla and Nibbles, they rocked!

#83348 - tepples - Mon May 15, 2006 7:32 pm

Cooleo wrote:
Could you add beep and bell aswell?I dont think there is a DS command which can play interernal sounds,so you might have to subsitute it with a sound file!

ARM7 can play a ding of any volume, pan, duty, and pitch through sound channel 13.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#83351 - tssf - Mon May 15, 2006 7:51 pm

Hmm, what tone does this ding consist of?

Now that I've got my DS back after lending it out, I'm thinking about playing with your PSG program, tepples.

Of course finding time is hard since the project I'm with is going to suck so much of it up. Ah well.
_________________
Mathew Valente [TSSF]
------
Chrono Resurrection Musician

#83353 - zzo38computer - Mon May 15, 2006 8:03 pm

Scorpei wrote:
Me wanna play Gorilla again :D.
Sorry about that, ghmhmmh, anyway, I can't get Gorilla.bas to open (maybe it can't be run yet?).
Great job btw, I liked the old Basic games like Gorilla and Nibbles, they rocked!


DS BASIC isn't very compatible with QBASIC, it is a minimal BASIC interpreter I found somewhere in C, and I ported that software to Nintendo DS and added a few commands.
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#83384 - HyperHacker - Tue May 16, 2006 1:23 am

I was just thinking it'd be awesome to be able to write BASIC apps on the DS. Of course it'd be even better if you could do more advanced things like wifi and peek/poke (if you can't already).

#83406 - zzo38computer - Tue May 16, 2006 4:35 am

HyperHacker wrote:
I was just thinking it'd be awesome to be able to write BASIC apps on the DS. Of course it'd be even better if you could do more advanced things like wifi and peek/poke (if you can't already).


You can already do PEEK and POKE.

Here is list of all command currently available: (assignment), PRINT, INPUT, IF, THEN, FOR, NEXT, GOTO, GOSUB, RETURN, END, FORGET, PEEK, POKE, LOCATE, COLOR, VBLANK, GETKEY, GETCHR, MAP, LOAD, RUN

There are 26 variables available (A-Z), which can only store integers (no strings), but you can also store things in the maps (4 layers, 0=screen, 1=cursor layer, 2 and 3=hidden, each layer 32x32, but only 32x24 is visible). Line numbers are accepted but not required. You can use ? short for PRINT, but you cannot type LET before an assignment.
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#83419 - Sebbo - Tue May 16, 2006 5:35 am

nice, i might go back through all these Z80 programs i have laying around and see which ones will work
_________________
Here's some ideas I have for when I know enough to act on them, or for others to have a look at when they're bored: www.wayne.sebbens.com/ds_ideas.htm

#83807 - Cooleo - Thu May 18, 2006 6:25 pm

Any updates coming soon?

Cooleo
_________________
Flashed DS and stuff for sale:
http://forum.gbadev.org/viewtopic.php?t=9642

#83809 - zzo38computer - Thu May 18, 2006 6:44 pm

Cooleo wrote:
Any updates coming soon?

Cooleo


Sorry, but I cannot work on it except on the weekend because I am usually nowhere near my computer during Mon-Fri

Anyways, do you know what other new commands I should add?
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#83854 - HyperHacker - Thu May 18, 2006 11:56 pm

How about commands to run a .nds or enter GBA mode?

#84100 - zzo38computer - Sat May 20, 2006 3:52 pm

I tell you what I added so far, I will post it later today.

ON GOTO command:
It works like the old ON GOTO command in some older version of BASIC.
For example: ON A+1 GOTO 25 90 100 120

MENU command:
It display the cursor on the menu you can move cursor and select items
You can do for example: ON MENU 1 2 3 GOTO 40 50 60

MOD command:
This is for self-modifying code. For example:
Code:
5 mod 10 4 = 65
10 ? "!!!"
15 ? #(mod 10 6)+2
20 end

This code will output:
Code:
A!!
#



I still working on program editing/saving.

Also, I think it would be good to add a HTTP library (I found the Wifi lib but I can't figure out how to do it!), so that you can type LOAD "http://example.org/super.bas" and load file from Internet.
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#84114 - tepples - Sat May 20, 2006 4:53 pm

zzo38computer wrote:
MOD command:
This is for self-modifying code.

Ouch. I've always seen MOD used as an infix operator that does the same as C's a % b.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#84121 - zzo38computer - Sat May 20, 2006 5:12 pm

tepples wrote:

Ouch. I've always seen MOD used as an infix operator that does the same as C's a % b.

Yes, I know OUCH, but for some reason Integer Tiny BASIC uses % to do modulo and / to do integer division. Actually, the meaning of , and ; for the PRINT command is also switched. These are just 2 features of Integer Tiny BASIC that differs from other versions, and I decided to leave them as they are.
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#84750 - zzo38computer - Wed May 24, 2006 3:46 pm

Now I posted V2.0

http://zzo38computer.cjb.net/Nitro/dsbasic/

Now you can edit and run program on Nintendo DS, and some things are fixed and some new commands. (You have to type NEW before typing in a new program, though.)

If you find any bugs or anything else, tell me. Also tell me if is good
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#84858 - HyperHacker - Thu May 25, 2006 1:22 am

OK... how do I use this? Pressing Start prints "OK", Select shows a file menu that only lists directories, and entering commands executes them immediately. Typing NEW doesn't seem to do anything.
_________________
I'm a PSP hacker now, but I still <3 DS.

#84862 - tepples - Thu May 25, 2006 1:48 am

What happens if you put 10 before a command?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#84863 - Darkflame - Thu May 25, 2006 2:04 am

Forgetting about mixing up with maths functions, self modifying code is "ouch" enough for me already. :D

Of course its not as bad as;
Befunge
http://en.wikipedia.org/wiki/Befunge

"fun" ;)

#84866 - HyperHacker - Thu May 25, 2006 2:35 am

Hahaha. Maybe when I get bored I'll try to write BefungeDS.
_________________
I'm a PSP hacker now, but I still <3 DS.

#84899 - zzo38computer - Thu May 25, 2006 2:51 pm

HyperHacker wrote:
OK... how do I use this? Pressing Start prints "OK", Select shows a file menu that only lists directories, and entering commands executes them immediately. Typing NEW doesn't seem to do anything.


Typing NEW will clear the buffer so you can enter a new program. You can enter a program by typing the line numbers before the commands you want to enter. Type LIST to view the program you already typed in.

START button runs the program (or type RUN).
SELECT button lists *.BAS files in the card. If you press Y it lists all the files, but they won't work if you select them from this menu because they probably aren't valid BASIC programs.

If you edit programs inside the Nintendo DS using this software, the program requires line-numbers, but if you edit it on your computer using Notepad or vi or something else, it does not require line numbers.
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#84927 - HyperHacker - Thu May 25, 2006 8:29 pm

Ah, I get it now. Cool.
Might I suggest, though, that since there's only a few commands and it requires line numbers, you just have a list of commands on the touch screen (switch back and forth between it and the keyboard perhaps) and an option to automatically add line numbers?
_________________
I'm a PSP hacker now, but I still <3 DS.

#86054 - Darkflame - Sun Jun 04, 2006 3:07 am

HyperHacker wrote:
Hahaha. Maybe when I get bored I'll try to write BefungeDS.


Or http://compsoc.dur.ac.uk/whitespace/index.php ?

:D

I love crazy code
_________________
Darkflames Reviews --
Make your own at;
Rateoholic:Reviews for anything, by anyone.

#86055 - tepples - Sun Jun 04, 2006 3:10 am

If I were to implement an esoteric programming language on the DS, I'd probably do FALSE. Imagine a 1 KB compiler. (Also imagine an editor that expands operators to Forth style keywords.)
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#86061 - MrD - Sun Jun 04, 2006 3:44 am

HyperHacker wrote:
Hahaha. Maybe when I get bored I'll try to write BefungeDS.

Befunge is pretty, I reckon. A handheld editor needs syntax highlighting, but it would be fun. I made a very strange looking Trefunge one once (for PC, that is)... :/
_________________
Not active on this forum. For Lemmings DS help see its website.

#99354 - linkstari - Sun Aug 20, 2006 11:05 pm

hi, i'm trying to use this on a ds with supercard sd and superkey, but it doesnt work, i've press select but it shows me a lot of red points with nothing else.
If the program it's supposed to work on this card, could you please write a how-to?

#99422 - zzo38computer - Mon Aug 21, 2006 2:59 pm

linkstari wrote:
hi, i'm trying to use this on a ds with supercard sd and superkey, but it doesnt work, i've press select but it shows me a lot of red points with nothing else.
If the program it's supposed to work on this card, could you please write a how-to?


You can still write programs and enter commands in immediate mode, but you can't load or save programs using a SD card. You need a CF card to load and save programs. (It isn't my fault that you can't load and save using SD card, it just isn't supported by the gba_nds_fat library).

The SELECT button lists the *.BAS files on the CF card so that you can select which file to load. Move the cursor to the file you want using the d-pad and then press SELECT again to load the program. If you want to list all the files (instead of just *.BAS files), press Y button on the file listing menu (you can press Y button again to cancel this option). Press START to run the program after it is loaded.

You can type in a program either in immediate mode or include line numbers to write a program (you have to type NEW before writing a new program). To run the program you can type RUN or press START.

If you are still confuse you will probably have to look at the source code.
_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#135182 - banjo_oz - Fri Jul 20, 2007 6:19 pm

I recently stumbled across thsi app, which seems an awesome idea to me... but of course it doesn't work on my M3Simply (R4) or other slot-1 flashcarts (it seems to run ok, but won't list the .bas files, much as a previous poster encountered). :(

I was just wondering... has this project been abandoned (I spent a few hours just finding this post about it!) or is there ANY chance that one day it might be updated to work on slot-1 carts?

I just think the possibilities of even basic BASIC on the DS are wonderful!

#135208 - Dood77 - Fri Jul 20, 2007 10:44 pm

Yes, please, update to the newest fat version! Or at least use DragonMinded's libfatdragon, which uses GBA_NDS_FAT but supports DLDI...
_________________
If I use a term wrong or something then feel free to correct, I?m not much of a programmer.

Original DS Phat obtained on day of release + flashme v7
Supercard: miniSD, Kingston 1GB, Kingston 2GB
Ralink chipset PCI NIC

#135272 - wintermute - Sat Jul 21, 2007 6:09 pm

I had a quick look at this and got rid of all the warnings and converted to use libfat so, in theory, all you should need is a suitable dldi for your card. The file selector code needs a bit more work really but it seems to work.

http://devkitpro.sf.net/dsbasic.zip

includes updated source and precompiled nds.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#135312 - Dood77 - Sun Jul 22, 2007 3:31 am

Thanks very much wintermute! Will try it on my SCminiSD ASAP.
_________________
If I use a term wrong or something then feel free to correct, I?m not much of a programmer.

Original DS Phat obtained on day of release + flashme v7
Supercard: miniSD, Kingston 1GB, Kingston 2GB
Ralink chipset PCI NIC

#135321 - banjo_oz - Sun Jul 22, 2007 7:10 am

Thanks HEAPS for undertaking this, Wintermute! I'm very grateful!

As soon as I saw this, I downloaded and gave it a whirl on my DS. Now, DSBasic seems to work as before, but the file system seems to hang on my M3 Simply (slot-1).

I patched the nds with DLDI (R4) first, and that seemed to work fine, and when I press select within the app, it DOES list the directories in the root of the card... but won't let me do anything else, and I have to reset my DS.

I've tried putting the nds file in the root, and in various subdirectories (PROGRAMS, BASIC and DSBASIC) but all seem to cause the same problem.

Any idea if there's something I'm doing wrong? How are others going testing this so far?

In any case, thanks again for taking up the task of getting DSBasic to work on slot-1 cards, Wintermute! :)

#136620 - banjo_oz - Fri Aug 03, 2007 11:20 am

Dood77 wrote:
Will try it on my SCminiSD ASAP.


Dood77, how did your testing go with this? Curious if I'm the only one having problems with it.