Wee Basic 0.81 New version of nintendo ds basic interpreter

Wee81

Version 0.81

(Thanks to banana joe and montesquou for their suggestions in the comments for the last version)

– revamped load screen now lists files in the root directory for you to select (no more typing in file names)
– more colours added to lines and plots
black 1
blue 2
green 3
cyan 4
red 5
magenta 6
brown 7
white 8
gray 9
light blue 10
light green 11
light cyan 12
light red 13
light magenta 14
yellow 15
bright white 16
(colour 0 deletes)
– new sprite functions to flip vertically and horizontally:
* hflip <sprite no>,<screen>
* vflip <sprite no>,<screen>
– for/next now has a step parameter (the step parameter is added in square brackets):
for <variable>=<numexpression> to <numexpression> [<numexpression>]
eg for i = 10 to 1 [-2], for j= 10 to 100 [10]
– you can now use ‘;’ with print to keep on the same line (see sample program)
– new math functions added: sqr, pi, asin, acos, atan, sinh, tanh, cosh and abs
eg let x=pi, let s=sqr(5)+pi-tanh(10)+abs(-10)
– fixed: label errors
– fixed: crash when file is loaded that exceeds editor capacity

Download:WeeBasic81

(Change .ppt to .rar and unpack – as always, use at own risk)

Advertisements

49 thoughts on “Wee Basic 0.81 New version of nintendo ds basic interpreter

  1. Great progress!

    Would it be possible to have WeeBASIC load and run programs in its own folder (e.g. WeeBASIC, rather than root?

    Also, it would be great to see more programming examples from users.

    Thanks for making such a versatile application!

  2. Great!
    I’ve tested the new features.
    Well done!

    But I have problems with ‘syntax tolerance’.
    If I try the comand loadspr 1,1,100,100,16,16,”wurst.gif”
    it’s a game of try-and-error where the basic needs a space-character at more. So the loadspr hase to typed in as ” loadspr 1 , 1 , 100 , 100 , 16 , 16 , “wurst.gif” “.

  3. Hi freescifi .

    I checked the new version by only some simple tests .
    The improvments are yery good 🙂
    And thank you specialy for the colors …….
    Another wish would be to have also different Backround colors ….

    bye

    Banajoe

  4. I just played a bit with weebasic 0.81. The small sample program works without problem. However, when I load the tictactoe program, it doesn’t load in completely. The last lines loaded are in the sub touch: let sy = sty(). I have tested on a real ds with an acekard 2 and on the desmume emulator. Both show the same behavour. I have also tested with the 0.8 version, and it shows the same behavour. Any ideas what could cause these issue? As there are no sources available, I can’t search for it myself. regards.

  5. Hello,
    using the scripts of nano lua I have made an emulator testing rom, to develop on pc in wee basic. Can you give me an email address, I will send the .rar to you.

    bye,
    mario

  6. Hello freescifistories,

    Awesome work with Wee Basic! Are there going to be any more releases of Wee Windows? I love being able to test programs on the PC before moving them to the DS itself, and updated versions of the interpreter would help a great deal.

  7. Any updates? My son is tinkering with a ZX80, which has a very simple BASIC; I’d like to get him playing with Wee BASIC. Any chance of adding special graphic characters to the font, similar to those of the ZX80/ZX81 to help ease his transition? Do you get the font from the NDS BIOS, it’s two byte UniCode is it not?

    Check out http://www.dsicade.com and http://www.dsibrew.org/wiki/Nintendo_DSi_Browser

    It may have been the CSS3 test, I don’t recall now but somehow I got the DSi to print out every font character it contained… must have been hundreds of characters.

      • KnightFire, I agree it’s probably part of the browser software. For Wee Basic, I would have to design the font myself (or get it as freeware) in the form of a bitmap.

      • Please check out http://www.wearmouth.demon.co.uk/zx80.htm for “An Assembly Listing of the ROM of the Sinclair ZX80”, near the end is the character set, bit by bit.
        This is just a suggestion, the Commodore PET character set is out there too, using character set graphics is an easier step into programming than sprites.
        Or how about the ability to load a TTF instead.

  8. Talking about fonts…
    I notice that you use the same bitmap character for ‘p’ and ‘P’.
    Also capital ‘I’ is also used for small ‘l’.
    That’s weird! Were you working to a strict size for your .nds file or was it a strange form of laziness??!?! 🙂
    Also worth noting is the ‘#’ above number 3 produces a red line and the key to the left of the spacebar, when pressed, also activates the spacebar and produces a space not the inverted commas as illustrated.
    (am I a geek or what?!)

  9. Hi

    Loving programming in Wee Basic. Finding it very simple to create custom programs. I have great difficulty in seeing the font used. Would like to know if there’s any possibility of changing it, maybe on the fly. How about a competition to see if users can create a font to use. In what format would you prefer? Also, is it possible to change the colour of text printed with the print command. I guess not if it’s a bitmap font being used. I would like to see the interpreter ignore “then” if I inadvertently place one after an if statement.

    Could a clg command (clear graphics) be added, as it would be nice to be able to clear text with cls and graphics with clg together. At the moment, if I want to clear the screen I have to wipe it in a for loop drawing lines in colour 0.

    I’d also like to see a circle command, and a way to find out what colour a pixel on the screen at x,y is. I believe I have used a point command in some versions of basic which performs this task. Also, would we be able to find out what the ascii value of the character at x,y is, which would be useful for some scenarios.

    Other than that, a quick question: Are variables created in subroutines global, and is there any way to create local variables.

    Oh and one bug. When entering text in a line command (for example) which flows onto a second line, as the text wraps from the line above sometimes the cursor stays at the end of the new line, other times it stays at the start of the new line, which then means you end up typing the next bit before the existing wrapped text.

    Still, very good and great fun, except when I’ve done something which simply will not compile. One time I ended up with an out of variable space type of error, which I could not solve, then I closed down, opened again and it worked first time!

    Simon

    • Hi Simon. I’m really glad you find Wee Basic useful. Also, love the baby photo!

      The font is a bitmap so the colour of individual letters can’t be changed. If you want to tweak the existing font, feel free. You can download it at http://dl.dropbox.com/u/1889798/newfont.gif

      Send me any new font you come up with and I can compile Wee Basic with it and upload a new version.

      The variables in subroutines are indeed global. Wee Basic has no concept of local variables. Thanks also for pointing out the bugs you’ve discovered. The enhancements you suggest are also good.

      You’ve probably noticed that I haven’t updated Wee Basic for a while. It’s been very difficult to find time given the other projects I’ve got scattered on this blog and also (unfortunately) the demands of my day job. You’d also be surprised how difficult it is to debug a DS program without any official tools – it’s a lot of work.

      Anyway, enough excuses 🙂 Hopefully I’ll have more time soon to work on and improve Wee Basic. Certainly, reading comments like yours ignites a bit of a spark – thanks again.

  10. One other bug I’ve noticed, is if you try to draw lines with x or y co-ordinate less than 0 or greater than 255/191 the screen becomes corrupted but otherwise no errors are thrown. I’d rather receive an error or for no attempt to draw the line or plot to take place (e.g. illegal values ignored). This was caused by me trying to draw an 8×8 square centred on the co-ordinates the user tapped the stylus on the screen for a program I was developing.

    I’d also like the idea of placing all text files and files associated with a program in a sub folder and reference the folder somehow at the start of the program e.g. a ‘directory ‘ command which sets the directory for files to the text contained in and throws an error if that directory doesn’t exist.

    • my directory command got automatically altered. The sentence was supposed to say:

      I’d also like the idea of placing all text files and files associated with a program in a sub folder and reference the folder somehow at the start of the program e.g. a ‘directory [string]‘ command which sets the directory for files to the text contained in [string] and throws an error if that directory doesn’t exist.

  11. Here’s a bit of topical code for the time of year:

    for x=8 to 16
    line 1 x,8,x,64,x
    line 1 x,8,x+20,40,x
    line 1 x+20,40,x+40,8,x
    line 1 x+40,8,x+40,64,x
    line 1 x+56,8,x+56,64,x
    line 1 x+56,x,96,x,x
    line 1 x+56,x+24,88,x+24,x
    line 1 x+56,x+48,96,x+48,x
    line 1 x+96,8,x+96,64,x
    line 1 x+96,x,136-(x/2),x,x
    line 1 136-(x/2),x,144-x,
    8+(x/2),x
    line 1 144-x,8+(x/2),
    144-x,40-(x/2),x
    line 1 144-x,40-(x/2),
    136-(x/2),48-x,x
    line 1 136-(x/2),48-x,
    112,48-x,x
    line 1 112+x,41, 120+x,64,x
    line 1 x+136,8,x+136,64,x
    line 1 x+136,x,176-(x/2),x,x
    line 1 176-(x/2),x,
    184-x,8+(x/2),x
    line 1 184-x,8+(x/2),
    184-x,40-(x/2),x
    line 1 184-x,40-(x/2),
    176-(x/2),48-x,x
    line 1 176-(x/2),48-x,
    152,48-x,x
    line 1 152+x,41,160+x,64,x
    line 1 176+x,8,192+x,40,x
    line 1 192+x,40,192+x,64,x
    line 1 192+x,40,208+x,8,x
    line 1 x,100, x+40, 164,x
    line 1 x,164, x+40, 100,x
    line 1 x+56,100, x+56,164, x
    line 1 x+56,100, x+80,140, x
    line 1 x+80,140, x+104,100,x
    line 1 x+104,100,x+104,164,x
    line 1 x+120,164,x+144,100,x
    line 1 x+144,100,x+168,164,x
    line 1 153-(x/2),124+x,
    159+(x/2),124+x,x
    line 1 208,92+x,248,92+x,x
    line 1 208,92+x,192+x,108,x
    line 1 192+x,108,
    192+x,144-x,x
    line 1 192+x,144-x,
    232+x,144-x,x
    line 1 232+x,144-x,
    232+x,156,x
    line 1 232+x,156,
    240,148+x,x
    line 1 200,148+x,240,148+x,x
    next

    let k=0
    while k=0
    let k=key()
    wend
    end

  12. Hi (not sure if Marovada is a nick name, your actual name. or just something made up)

    I had the dreaded ‘hit backspace and the whole nds locks up with 2 blank screens’ bug a few times now, and it is a little annoying when you get wrapped up into programming something and forget to save, but also the problems with automatic word wrapping and the cursor not going where you’d expect happens at inappropriate times too. I’m certainly a novice when it comes to programming on the nds, having not got into it at all really, but I’m fairly adept at looking at code to try to resolve bugs, so I’d be happy to take a look at the source code and try to work out what’s going wrong, if you’d like.

    I just wanted to say, also, that I programmed the above code directly in the nds, not on an emulator or on the wee editor you provided, so I think that just shows I have far too much time on my hands these days (or I am just too much of a nerd).

    I noticed you are in Australia (saw it on another site) so hope your summer is lovely and warm down under. I’m in the UK and thankfully, unlike last year have had no snow so far.

    Best wishes

    Simon

    • Simon, it sounds like the backspace bug is caused by writing to a wrong memory address. That is a difficult bug to find without a proper debugger. I’ll take a look once I find my dev environment.

      “Marovada’ is my ‘web’ name. Weather is a bit patchy here in Australia on the east coast. It’s been the coolest summer in 40 years! You don’t want snow? I thought everyone’s supposed to dream of a white Christmas 😀

  13. Hi, I’ve just finished writing (or more importantly converting) a mandlebrot program to wee basic, and during conversion I have found one or two minor bugs. First is that you cannot use a variable as the optional ‘step’ parameter in a ‘for’ statement, and secondly, the ‘let’ command will not work if spaces are put either side of the = sign. Will be posting the output and program once I give it one or two tweaks.

    • Thanks Simon – very helpful. I can’t wait to see the program. It’s interesting because, in creating Wee Basic, I didn’t have any idea of all of the possible uses for it. That’s why I’m excited to see the mandelbrot program.

    • Sorry Simon. Whenever there’s a link in the comment, WordPress wants me to manually approve it – the time time difference between Aus and UK means I only got to it now. Your mandelbrot generator is amazing!!

      • Strangely, when pasting the source code here and adding some text, the post didn’t even appear with “awaiting moderator approval” or whatever, but the third time when I simply linked to the source file, the post appeared. It is as if something in the code was causing wordpress to flip out. As soon as I changed it for the third time to the link, the post appeared!

      • Think there’s room for improvement.

        If the ability to use a variable as the step option of a for loop was available (it threw an error) I would have been able to set a variable to 32, and in a while loop used the variable as the step to the two for loops and halved it each time until it reached 1, then the code would have progressively drawn the image so the user could get more of a feel of what the final image would be like.

        Once it was a bit faster, we could have switched the drawing to the other screen, and used the stylus to zoom in to the image and have the routine redraw with new coordinates.

        Not sure if other speed improvements could be made, similar to the old dos ‘fractint’ program which ran quite quickly on old 486 pc’s, etc.

        At least running it in the emulator allows you to use the full speed of the PC to run much faster. Choosing the highest speed option in the emulator, I was able to run at 900% speed on my laptop, thus the image generated much quicker.

        Glad you liked it as it is, though.

  14. Simon,

    Can you give me an example of code and errors (including the error message) for:

    – step not working with a variable
    – spaces around ‘=’ signs

  15. Have not been able to replicate spaces around = signs error. Here is some code (which is irrelevant now you’ve fixed the bug):

    let s=32

    while s>=1
    for x=0 to 255 [s]
    for y=0 to 191 [s]
    plot 0 x,y,16
    next
    next

    let s=s/2
    wend

    end

  16. Hello, i read your blog from time to time and i own a similar one and i was just wondering
    if you get a lot of spam responses? If so how do you prevent it,
    any plugin or anything you can recommend? I get so much lately it’s driving me insane so any assistance is very much appreciated.

  17. Hi

    I’ve had a few issues with multiple if/elseif statements and nested if/else statements, and wonder if there’s a bug.

    Here’s a sample piece of code:

    lab start:
    let n=rnd(100)
    print 1 “Number is “+n
    if n<25
    print 1 "Number between 0 and 24"
    elseif n<50
    print 1 "Number between 25 and 49"
    elseif n<75
    print 1 "Number between 50 and 74"
    else
    print 1 "Number between 75 and 100"
    endif
    let k=0
    while k=0
    let k=key()
    wend
    goto start:

    Now, as you'd expect, only one print line should be printed for each number, but if the number is below 25 you get the first two print statements which isn't right. If you change the first if to:

    if n=-1
    elseif n<25

    then the print statement works as expected. It would appear that you have to include a test that would never be met in order for it to work as expected.

    Also, I was trying to develop a program in which a character would be printed across the screen, then when it reached the right it would start moving down the screen, then when it reached the bottom it would move back left, then when it reached the left it would move back up.

    This was to be performed in a loop while waiting for a key press so here's only a small part of the code that doesn't work:

    print 1 at x,y "#"
    if hd=1
    if x<31
    let x=x+1
    else
    let nhd=2
    endif
    elseif hd=2
    if y1
    let x=x-1
    else
    let nhd=4
    endif
    elseif hd=4
    if y>1
    let y=y-1
    else
    let nhd=3
    endif
    endif
    let hd=nhd

    It just doesn’t change direction after reaching the right hand side (it’s as if the part checking that hd=2 doesn’t get executed).

    I can post the entire code if that helps, or I’d prefer to email it to you personally.

    Simon

    • Simon, I’ll email you so you can send me the code. I haven’t worked on Wee Basic for a while though and there’s no simple way to debug it.

  18. Hi

    Just checking in to see how things are going? Have you had any chance to look at updating WeeBasic?

    Thoroughly enjoyed working on it in the past. Haven’t picked up my DS for such a long time.

    Need a new update of WeeBasic to re-ignite my spark…

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