Wee Basic 0.6 Released


Good news for me and myselves. The new version of Wee Basic has arrived.

Where exactly are we on this road map to hell? Wee basic now has:

– backgrounds
– sprites
– sounds
– microphone
– key presses (keyboard and most hardware keys)
– stylus touches (touch recognition and coordinates)
– motion
– primitive graphics
– basic printing and coordinate printing
– both screens can be used
– core basic commands
– usable editor with save/load, using text files

(But don’t pee in your pants yet my lovelies).

Version 0.6


– editor has been completely revamped thanks to Alan’s txtwriter source code. See http://ds.spacemonkeymafia.com.
I modified some of txtwriter’s basic editing code for the Wee Basic editor.
– bug in boolexpressions (for if/while) using strings


– added motion commands (untested)
motion (keyword initializes motion – throws an error if no motion card detected)
motx, moty (motion coordinates)

let x=motx
let y=moty
print 1 “Motionx: “+x
print 1 “Motiony: “+y

– playmp3 now has optional settings
Syntax is playmp3 <filename> <volume>,<pan>,<bitrate> (each is an integer or number variable)
You can still use playmp3 without options if you want to keep it simple

As usual, download wee06.ppt and change extension to zip – enjoy. Usual rider – use at own risk.
Download: wee06


38 thoughts on “Wee Basic 0.6 Released

  1. Pingback: Wee Basic v0.6 (NDS Application) | Nintendo ds

  2. yeeeepyyyyyyyy !
    but i need more to progrmming my mini studio this syntax

    ex Syntax is playmp3

    thx mr freescifistories !!

  3. playmp3 “number of channel”,”file name”,”pan”,”volume”,”bit rate”

    excuse me for my exigence

  4. Yes it’s a good idear to play mp3 sample in polyphonia like a sampler mutitracs!!!

    please mr freescifistories !!!!!!

  5. zomboula,teocomputer: I had a look at “number of channel” but it’s not possible with the sound library I’m using.

  6. I commented in the manual section. Sorry, I should have commented here about problems with editor and labels and nested if/else/endif statements. See comments there.

  7. It’s my understanding that none of the NDS emulators support writing of files/data (other than well known .SAV files). (Don’t know why they can’t include a RAM-drive/virtual filesystem to avoid potential problems.) That implies that WeeBasic can neither load or save programs under an emulator on a PC. If I am wrong, please let me know what I need to do. I have tried iDeaS and no$gba. Thx.

  8. s54boc – thanks. I’ve responded to your other question in the manual section.
    Wee Basic can indeed save and load files in No$GBA. I use a program called fcsrimage (which is actually a collection of dos based programs) that creates and appends a disk image to the nds file. Whatever files you include in the fscr directory are included in the disk image. Also, I believe that DeSmume may be able to at least load files without using fcsrimage. Let me know if you need any more help with this.

  9. Thx for the info on fcsr. I was able to load a program in no$gba. Not yet perfected ability to write. Is there yet a way to extract the contents of the virtual fs image from the tail of the ROM image back to the host OS filesystem? Once there is a way to write to an fs in an emu, want to be able to save it, print it and/or copy it over to the DS. Do you know? In my case, create a prog in basic on emu and put it on my son’s DS. thx

  10. s54boc: I would guess that there is a way to extract the virtual fs image, but I haven’t looked into it so I don’t know how. You could do it the other way around (which is what I do) by typing the program in a text editor, using fcsr to test it on no$gba and then make edits on the text editor as needed. Then you could put the completed and tested text file on your son’s ds. I’m assuming you don’t have a ds of your own as using another ds would be easier.

  11. thx. That makes sense. I’ll automate the re-creation of the weebasic rom and then I can do that. I did find that if I load the weebasic rom into a text editor, I am able to cut out the basic program. Of course, writing to the fs in no$gba will not write to the rom image on disk. Written data would only survive for the life of the no$gba process. But if I were to run it under Linux, I could likely write a tool to memory map to the backing file from another process and extract it that way. On another note, I tried desmume, but it is not working on my PC. I’ve sent them a note about it. I’ve asked them about the chance of simulating a slot-1 flash device as well. Would need to create a desmume.dldi. Similar to or actually run moonshell in the emu.
    Only 1 DS in the family. Should have 3, as I have 2 boys.

  12. s54boc: I also automate the process to append, dldi patch and run in no$gba. Let me know if you have any questions on this. One ds between three must be fun 🙂 but these are tough times.

  13. tried to reproduce the failure I had before with loops and nested if statements. used a real DS. couldn’t dupe, but saw other similar failures. seems to be the editor, not the parser. code is ok. seems that when the program is longer than the # of lines on the screen, inserting lines of code near the bottom makes the text jump, and the cursor disappears. Then it may appear at the top of the screen, but is wrapped and stuck at the bottom of the buffer. tap up arrow to get it back to the bottom of the screen and then down arrow to scroll again. seems inserting text causes parser to fail on what looks like good code. put linefeeds between lines and program ran ok on first iteration and then hung. only loop could have been in waits for touch on screen, but touching no longer worked. have you seen problems with the editor? assigning start key to be a break key might be a good idea.

    here’s my original code, this works…

    let rad=30
    line 0 0,0,255,191,1
    line 0 0,191,255,0,2
    line 0 127,0,127,191,3
    line 0 0,95,255,95,4
    cls 1
    print 1 “To stop this program”
    print 1 “touch the screen outside”
    print 1 “the circle.”
    for d=0 to 90
    let r=4*d*3.1415926535/180
    let x=cos(r)*rad+127
    let y=sin(r)*rad+95
    plot 0 x,y,2
    let clscr=0
    lab loop1:
    while stt()=0
    let bounce=0
    if bounce=1
    goto loop1:
    let bounce=1
    let x=stx()-127
    let y=sty()-95
    if sqrt(x*x+y*y)<rad
    print 1 “POKE”
    goto loop1:
    cls 1
    print 1 “Done”

    Then I edited the program on the DS to create a nested if statement by moving the first endif to follow that last one, just before the end statement, to let the tail of the program be in the else of the 1st if instead of follow it. This gave me syntax error near [ce=0 wend]. So I suspect the editor is adding non-printable characters, it that’s possible on the DS. Another problem with the editor is when backspacing to remove a line. if starting at the front of the next line and backspace, the cursor jumps ahead when the “next” line gets pulled in behind the line to be erased.

  14. Thanks s54boc. The editor is the bane of my existence at the moment. I’ll look into these issues.

  15. thx. Because it would be great to use as a tool to let my 9 yr old try some programming, NOT for me to write programs in BASIC on the PC and copying them to flash. From this perspective, I’m a big fan of WeeBasic, which really brings an educational value to the DS. Just not product-ready for this. I think I’ll dig into the editor src to see what’s there.

  16. Good one s54boc. It’s a good idea to get kids into programming early. I started off on a sharp calculator computer (PC-1401 with a whole 3k of memory) and then moved on to an Apple IIC.

  17. similar history; Radio Shack mgr let me tinker with 1st TRS80 if I also talked to any customers who asked questions. 1st computer was a RS Pocket Computer PC1, then PC2, then Osborne II. Still have the PC2 and Osborne somewhere. Found the src for 0.3.2. Will tinker.

  18. OK. I’ve got Sektor’s modified version (0.3.2) of txtwriter. It doesn’t look like what’s in WeeBasic, but maybe that’s just the visual. If not, you should check it out and perhaps migrate. But my son can use it to create programs in the TXT directory, power cycle the DS and start WeeBasic and load TXT/prog.txt. Worked fine. DSOrganize gives the same option, too. But these are just workarounds. Hopefully you can flush out any bugs in your editor quickly.

  19. Oh no. I wrote too soon. I discovered that txtwriter0.3.2 does suffer from some of the same problems when inserting lines near the bottom of the screen.

  20. Wow s54boc, I was so envious of RS PC1 and PC2 (sharp equivalents) because they were faster and I think had ready made software on tape. Txtwriter has a different look and feel because I only used (and modified slightly) the core editor code, not the font, backgrounds, keyboard, sprites etc. It’s a shame that it has the same issues but at least it isn’t my modifications that are responsible. I’ve started checking into this but it’s hard to debug because there is no professional debugger for DS homebrew (No$ has a debugger but the guy that programmed No$ is MIA and the professional version with source level debugging is $1,750).

  21. It’s tough debugging embedded s/w on cross platform development. Good emus are indispensible. I had a chance to see a professional emu framework that was being used by one of the major gaming platform makers. That was 10 years ago or more. That was so they, I think it was Sony, could develop h/w and s/w in parallel. Very cool. I will code inspect txtwriter, recompile, see if I find anything. Let you know.

  22. Thanks s54boc. I was thinking of creating a simple dos version of the txtwriter code for debugging. I’ve done this occasionally for Wee Basic with all of the hardware functionality omitted.

  23. Found one bug in txtwriter. Can’t seem to build the src as it comes, so can recompile yet. But look at insert_buffer(). console.start_line is reset to 0 whenever a character is typed into the middle of a line. console.start_line value should be preserved. Causes the editor to put first line at top of screen after insertion, but cursor is still where character was inserted. Could be several lines off the visible screen. Text should not move on visible screen. The whole fcn is rather inefficient, and can be improved a lot.
    To text, insert a character (e.g. return) in a line other than last line while the first line in program has been scrolled off the top of visible window. Especially if line number is greater than fits on same screen as first line.

    Another problem I still will look at is regarding use of backspace which brings line to end of previous line. Cursor position gets corrupted. Should be fixed.

  24. Many thanks s54boc. I haven’t had a lot of free time to attend to the editor yet, but your help is very much appreciated.

  25. Found 2nd bug. Related to 1st bug. Is in both weebasic and txtwriter.
    Example text… where @ represents the cursor …

    @cls 1

    now hit backspace, I would expect to see this …

    keyhide@cls 1

    but instead we get this …

    keyhidecls 1@

    This time the bug is in execKey().
    Hitting a backspace (BSP) causes insert_buffer(c) to be called. insert_buffer() regenerates the sbuffer structure with the proper character deleted, but then the code in execKey() that follows places the cursor at the end of the regenerated row instead of where the previous line used to end. Solution is to save the length of the previous line before calling insert_buffer() and then using it to restore the lateral cursor position if((c==BSP && (–console.edit_col < 0))
    Send me an email that I can reply to and I’ll send you function replacements for execKey() and insert_buffer() that I think should do the trick for both bugs.

  26. I can’t compile the gba_nds_fat code for txtwriter because I’m missing some macros … ARM9_OWNS_ROM and ARM9_OWNS_CARD, and maybe more once I get past this error. Not defined in txtwriter or devkitpro. Any help is appreciated.

  27. Wow s54boc, that’s great detective work. I’m not sure which version of devkitpro you’re using but gba_nds_fat isn’t used anymore. libfat is now standard because it’s DLDI compatible. See: http://forum.gbadev.org/viewtopic.php?t=10289&sid=9b36d2ca2ed5db5a5aaedaf9d6e65cdc

    This is why the code won’t compile. Wee Basic also uses libfat. The include file is fat.h

    You need to initialise libfat and then use normal c file input/output.

    Sorry I haven’t released source for Wee Basic but I need to use the parser/interpreter for other projects. I’m sending you an email with the console stuff.

  28. Cool. Thanks for the tip on libfat. I’ll grab it and I replace it in txtwriter. Using the most recent version of devkitpro.

  29. Hi there…

    Nice work dude .
    I like to make smal progs on the ds when I go by train.

    Please don`t stop to work on wee basic give us a version 0.7 and lots of more !!!
    Thank you man .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s