Wee Basic

From GameBrew - a wiki dedicated to Video Game Homebrew.

Wee Basic

Wee Basic is a BASIC interpreter for The Nintendo DS. It can be used for programming and create NDS homebrew. The Basic interpreter now also comes equipped with a simple command to break infinite loops, and all keys are now supported for key operator.

Wee Basic 0.4 was submitted to the NEO Spring Coding Compo 2008 and ranked 9th. Version 0.6 was an entry to the NEO Spring Coding Compo 2009 under APP section.


  • New dashboard with save, run, and load icons.
  • 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.


Change the file extension to .rar to unpack and extract file.

DLDI patch it if required.

Put Wee and and sample.txt into the root directory of your card.

Press A to start.

User guide

File names must be valid gif files and you must specify the full file name.Gif files must be kept in the root directory of your card.Don't try to move or delete sprites that you haven't created.

Each screen has its own numbered sprites, so you can specify the number 1 for a sprite on the top and bottom screens but don't specify the same number for sprites on the same screen.

Manual for Wee Basic can be found from the official site.



D-Pad - Use keyboard (e.g. type, delete)

A/Start - Start to run program

X - Load file

Y - Save file


weebasic2.png weebasic3.png


Version 0.81

  • 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, example below):
for <variable>=<numexpression> to <numexpression> [<numexpression>]
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, e.g.
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.

Version 0.8

  • New dashboard with save, run and load icons (touch to enable).
  • Cursor is off the screen for save and load.
  • Key combination to break: you can now hold ‘A’ and ‘Start’ at the same time to break a running program (eg if you get stuck in an infinite loop).
  • All keys are now supported for key() operator, including L and R keys and Start and Select keys. Summary of values returned by key():
    • X: 200
    • Y: 201
    • A: 202
    • B: 203
    • Left: 204
    • Right: 205
    • Up: 206
    • Down: 207
    • L: 208
    • R: 209
    • Start: 210
    • Select: 211
  • Input statement bugs fixed.

Version 0.7

  • Editor bugs inserting text and backspacing fixed: many thanks to Peter Reissner (aka s54boc) for fixing these.
  • New splash screen.
  • Cursor starts in correct position on launching wee basic.
  • Comments can now be made in program. Just start with ‘rem’ and everything is ignored until a ‘* ’. For example:
rem this will be ignored * 
print 1 “This will not be ignored”
  • Cursor is now off-screen while a BASIC program is running.

Version 0.6


  • Editor has been completely revamped thanks to Alan’s txtwriter source code. See 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). Example:
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.

Version 0.5


  • SOUND (can play mp3s).
  • You can record and play from the DS MICROPHONE.

Version 0.4


  • Bugs with nested ifs.


  • Neo splash screen.
  • Sprites on both screens (must be gif files).
  • Backgrounds on both screens (must be gif files).
  • Can uses start or A to start a program running.
  • New commands:
    • loadspr number,screen,x,y,,width,height,file name (creates a sprite specified by the file name on the screen specified at the specified coordinates)
    • movspr number, screen, x,y (moves an existing sprite specified by the number to new coordinates x and Y on the screen)
    • delspr number, screen (deletes the specified sprite)
    • backgr screen, file name (creates a background on the specified screen with the gif file specified by the file name)

Version 0.3


  • Editor: return key swallowing a character.
  • Editor: hopefully fixed remaining save bugs.


  • Basic programs now have access to both DS screens and stylus input.
  • Hide or show keyboard with commands ‘keyhide’ and ‘keyshow’.
  • You must hide the keyboard before printing to, or using graphics on, the bottom screen.
  • cls, print, plot and line can now be used on both DS screens. You must specify a screen number. Syntax is now (s= screen number 0 or 1):
print s [at x,y] <string or variable>
plot s x,y,colour
line s x1,y1,x2,y2,colour
cls s
(s = screen number 0 or 1)
  • Stylus coordinates can be obtained using stx() and sty(), eg:
let sx=stx() let sxy=sty()
  • Check whether bottom screen has been touched with stt(), eg:
let touched=stt()
stt() returns 1 for touched and 0 for not touched
  • New example showing the above features.

Alpha 2


  • No longer crashes when loading a file that doesn’t exist.


  • Variable names are no longer restricted to 1 character. Wee Basic now supports variable names of up to 8 characters, starting with a letter but can otherwise use a combination of letters and numbers, e.g.
test, a1, string12, a1b1, hello$
  • One dimensional string and numerical arrays are now supported. To use them you first have to declare them with the “dim” statement, eg:
dim a1(10) dim hello$(5)
  • There is a maximum of 100 numerical and 100 string variables.
  • Each string array is limited to 30 members.
  • Each numerical array is limited to 100 members.
  • You can print at a particular position on the screen using the “print at x,y”, where each of x and y is a numerical expression.

External links