BBC BASIC for SDL 2.0
Table of Contents
- Introduction and Overview
- Introduction to BBC BASIC
- Overview
- Minimum system requirements
- Specification
- Example programs
- GAMES
- GENERAL
- GRAPHICS
- PHYSICS
- SOUNDS
- TOOLS
- Notices
- Integrated Development Environment
- Introduction to the IDE
- The title bar
- The menu bar
- The toolbar
- The status bar
- Character encoding
- Program length
- Cursor position
- Insert/Overtype
- File menu
- New
- Load
- Save
- Save As
- Insert
- Compare
- Page Setup
- Print
- Recent files
- Exit
- Edit menu
- Undo
- Redo
- Cut
- Copy
- Paste
- Delete
- Select All
- Find
- Find Next
- Replace
- Go To
- Utilities menu
- Renumber
- Compile
- Application
- Crunch
- Embedded files
- Test
- Create Application
- Compiler directives
- List FNs/PROCs
- Include ONs
- Include Labels
- Sort List
- Add-in Utilities
- Options menu
- Syntax Colouring
- Lowercase Keywords
- Indentation
- Unicode
- Set Font
- Set Printer Font
- Set Colours
- Dark Mode
- Run menu
- Run
- Debug
- The List Variables window
- Profile
- Stop
- Pause
- Step Into
- Step Over
- Run To Cursor
- Immediate Mode
- Toggle Breakpoint
- Clear Breakpoints
- Help menu
- Help Topics
- Tutorial
- Email
- Website
- Discussion Group
- Forum
- Wiki
- About BBC BASIC
- The editing pane
- Keyboard commands
- Mouse commands
- Context Menu
- Scroll bars
- General Information
- Line numbers
- Statement separators
- Line continuation
- Expression priority
- Order of evaluation
- Examples
- Array arithmetic
- Initialising arrays
- Variables
- Variable names
- Naming conventions
- Variable types
- Static variables
- Integer numeric variables
- 64-bit integer numeric variables
- Byte numeric variables
- Variant numeric variables
- 64-bit ('double') floating-point variables
- String variables
- Arrays
- Pseudo-variables
- System variables
- The @cmd$ variable
- The @dir$ and @lib$ variables
- The @tmp$ and @usr$ variables
- VDU variables
- Creation of variables
- Structures
- Structure members
- Declaring a structure
- Arrays of structures
- Structure prototypes
- Passing structures to procedures and functions
- LOCAL and PRIVATE structures
- Returning structures from procedures and functions
- Using structures with the Windows and SDL 2.0 APIs
- User-defined data types
- Finding the size of a structure
- Copying a structure
- Assigning a pointer to a structure
- Program flow control
- Introduction
- Program structure limitations
- Leaving program loops
- REPEAT ... UNTIL loops
- Changing the loop variable
- Using the EXIT statement
- Moving the loop into a procedure
- Local arrays
- Indirection
- Introduction
- The ? operator
- Query as a byte variable
- The ! operator
- The ] operator
- The | operator
- The $ operator
- The $$ operator
- Use as binary (dyadic) operators
- Power of indirection operators
- The ^ operator
- Operators and special symbols
- Keywords
- Debugging
- Error handling
- Default error handling
- Reasons for trapping errors
- To make your program more 'friendly'
- To ensure the error message is visible
- To allow clearup operations to take place
- To allow execution to continue
- Error trapping commands
- ON ERROR or ON ERROR LOCAL?
- Error reporting
- Error trapping examples
- Procedures and functions
- Introduction
- Names
- Function and procedure definitions
- Starting a definition
- The function/procedure body
- Ending a definition
- Single line functions/procedures
- Extending the language
- Passing parameters
- Formal and actual parameters
- Local variables
- Recursive functions/procedures
- Passing arrays to functions and procedures
- Passing parameters by reference
- Returning arrays from procedures and functions
- Indirect procedure and function calls
- Passing procedures and functions as parameters
- Input editing
- Copy key editing
- The copy key
- The backspace key
- Hardcopy output to a printer
- Labelling program lines
- Multilingual (Unicode) text output
- Graphics and Colours
- Introduction to graphics
- Display modes
- Available modes
- Colours
- The Palette
- Two colour modes: 0, 4 and 32
- Four colour modes: 1, 5 and 33
- Sixteen colour modes: 2, 3, 6 and 8-31
- Logical colours
- Physical colours
- The physical palette
- 6-bit RGB colours
- 8-bit RGB colours
- Text colours
- Graphics colours
- Drawing on the screen
- Introduction
- Screen dimensions
- The graphics viewport
- Drawing a line
- Moving the graphics cursor
- Plotting modes
- Basic line drawing modes
- Enhanced line drawing modes
- Plot a single point
- Horizontal line fill to non-background
- Triangle plot and fill
- Horizontal line fill to background right
- Rectangle plot and fill
- Horizontal line fill to foreground
- Parallelogram plot and fill
- Horizontal line fill to non-foreground right
- Flood fill to non-background
- Flood fill to foreground
- Draw circle
- Draw solid disc
- Draw circular arc
- Draw solid segment
- Draw solid sector
- Move rectangular block
- Copy rectangular block
- Swap rectangular block
- Draw outline ellipse
- Draw solid ellipse
- Draw relative
- Logical inverse colour
- Reading a pixel's colour
- Text and graphics viewports
- Introduction
- Text viewport
- Define text viewport
- Clear text viewport
- Graphics viewport
- Define graphics viewport
- Clear graphics viewport
- Changing the graphics origin
- Positioning the cursor
- Writing text to the screen
- Text positioning
- Text at text cursor
- Text at graphics cursor
- Changing the font
- Selecting the character set
- Current character
- Character dot pattern
- Capturing the screen contents
- Pixel-perfect graphics
- General considerations
- Straight lines
- Outline shapes
- Solid (filled) shapes
- Plotting single points
- Compatibility limitations
- Compatibility summary
- Keywords
- Introduction to keywords
- Syntax
- Symbols
- ABS
- ACS
- ADVAL
- ADVAL positive argument
- ADVAL zero argument
- ADVAL negative argument
- AND
- ASC
- ASN
- ATN
- BGET#
- BPUT#
- BY
- CALL
- Operating system interface
- Parameter table
- Parameter formats
- Running BASIC code in a separate file
- CASE
- CHAIN
- CHR$
- CIRCLE
- CLEAR
- CLOSE#
- CLG
- CLS
- COLOUR
- COS
- COUNT
- DATA
- DEF
- DEG
- DIM
- Dimensioning arrays
- Declaring structures
- Reserving an area of memory
- Reserving a temporary area of memory
- DIM as a function
- DIV
- DRAW
- ELLIPSE
- ELSE
- END
- ENDCASE
- ENDIF
- ENDPROC
- ENDWHILE
- ENVELOPE
- EOF#
- EOR
- ERL
- ERR
- ERROR
- EVAL
- EXIT
- EXP
- EXT#
- FALSE
- FILL
- FN
- FOR
- GCOL
- GET/GET$
- Reading the keyboard
- Reading the screen
- Reading from a file
- GOSUB
- GOTO
- HIMEM
- IF
- Single-line IF statement
- Multi-line IF statement
- INKEY/INKEY$
- INKEY positive or zero argument
- INKEY negative argument
- INPUT
- INPUT LINE
- INPUT#
- INSTALL
- INSTR
- INT
- LEFT$
- LEN
- LET
- LINE
- LN
- LOCAL
- LOCAL DATA
- LOG
- LOMEM
- MID$
- MOD
- MODE
- MOUSE
- MOUSE ON n
- MOUSE OFF
- MOUSE TO x,y
- MOUSE RECTANGLE l,b,w,h
- MOVE
- NEXT
- NOT
- OF
- OFF
- ON
- Enabling the text cursor
- ON CLOSE
- ON ERROR
- ON ERROR LOCAL
- ON MOUSE
- ON MOVE
- ON SYS
- ON TIME
- Changing the timer period
- Creating additional timers
- Notes on the use of interrupts
- OPENIN
- OPENOUT
- OPENUP
- OPT
- OR
- ORIGIN
- OSCLI
- OTHERWISE
- PAGE
- PI
- PLOT
- POINT
- POS
- PRINT
- Print format control
- The @% system variable
- STR$ format control
- Format selection
- Number of digits
- Zone width
- Changing the Print Control Variable
- Examples
- PRINT#
- PRIVATE
- PROC
- PTR
- QUIT
- RAD
- READ
- READ#
- RECTANGLE
- REM
- REPEAT
- REPORT/REPORT$
- RESTORE
- RESTORE DATA
- RESTORE ERROR
- RESTORE LOCAL
- RETURN
- RIGHT$
- RND
- RUN
- SGN
- SIN
- SOUND
- Channel/Effects
- Amplitude/Envelope
- Pitch
- Duration
- Examples
- SPC
- SQR
- STEP
- STOP
- STR$
- STRING$
- SUM
- SUMLEN
- SWAP
- SYS
- TAB
- TAN
- THEN
- TIME
- TIME$
- TINT
- TO
- TOP
- TRACE
- TRUE
- UNTIL
- USR
- VAL
- VDU
- VPOS
- WAIT
- WHEN
- WHILE
- WIDTH
- VDU Emulation
- Introduction to VDU commands
- VDU code summary
- VDU 0
- VDU 1
- VDU 2
- VDU 3
- VDU 4
- VDU 5
- VDU 6
- VDU 7
- VDU 8
- VDU 9
- VDU 10
- VDU 11
- VDU 12
- VDU 13
- VDU 14
- VDU 15
- VDU 16
- VDU 17
- VDU 18
- VDU 19
- VDU 20
- VDU 21
- VDU 22
- VDU 23
- User-defined characters
- Text cursor control
- Scrolling the window
- Cursor movement control
- MODE 7 extensions
- User-defined modes
- Line thickness
- VDU 24
- VDU 25
- VDU 26
- VDU 27
- VDU 28
- VDU 29
- VDU 30
- VDU 31
- VDU 127
- Operating System interface
- Introduction to star commands
- File specifiers
- Accessing star commands
- Similarly named star commands
- Errors in star commands
- Star command summary
- *BYE
- *CHDIR (*CD)
- *COPY
- *DELETE (*DEL)
- *DIR
- *DISPLAY
- *DUMP
- *EGA
- *ERASE (*ERA)
- *ESC
- *EXEC
- *FLOAT
- *FONT
- *FX
- *GSAVE
- *HARDCOPY
- *HELP
- *HEX
- *INPUT
- *KEY
- *LIST
- *LOAD
- *LOCK
- *LOWERCASE
- *MARGINS
- *MKDIR (*MD)
- *MDISPLAY
- *NOEGA
- *OSK
- *OUTPUT (*OPT)
- *PLAY
- *PRINTER
- *PRINTERFONT
- *QUIT
- *REFRESH
- *RENAME (*REN)
- *RMDIR (*RD)
- *RUN
- *SAVE
- *SCREENSAVE
- *SPOOL
- *SPOOLON
- *STEREO
- *SYS
- *TEMPO
- *TIMER
- *TV
- *TYPE
- *UNLOCK
- *VOICE
- *|
- Additional OS Interfaces
- Read current character
- Read character dot pattern
- Read teletext character dot pattern
- Write teletext character dot pattern
- Assembler access to OS routines
- Files
- Introduction to files
- The structure of files
- File basics
- Serial (sequential) files
- Random access files
- Indexed files
- Files in BBC BASIC
- Introduction
- How data is read/written
- How data is stored
- Numeric data
- How strings are stored
- How files are referred to
- BBC BASIC file access
- File buffering
- Networking - shared files
- File commands
- Introduction
- Filenames
- Data files
- Introduction
- Opening files
- File opening functions
- Serial files
- Character data files
- Writing serial character data
- Reading serial character data
- Appending to character data files
- Mixed numeric/character data files
- Writing a mixed data file
- Reading a mixed data file
- Appending to mixed data files
- Compatible data files
- Writing a compatible data file
- Reading a compatible data file
- Random (relative) files
- Designing the file
- Record structure
- Accessing the records
- Simple random access file
- Simple random access database
- Random access inventory program
- Indexed data files
- Deficiencies of random access files
- The address book program
- File organisation
- Program organisation
- The index
- Indexed database example
- The Binary Chop
- The Assembler
- Introduction to the assembler
- Assembler statements
- Labels
- Comments
- Differences from Intel syntax
- Jumps, calls and returns
- Memory operands
- String operations
- Segment override
- Data size ambiguities
- Loop instructions
- Based-indexed operands
- Indexed memory operands
- Floating-point operands
- Numeric and string constants
- Define byte - DB
- Byte constant
- String constant
- Define word - DW
- Define double-word - DD
- Opcodes
- Floating-point opcodes
- MMX opcodes
- Using BASIC input/output
- Calling the Windows or SDL 2.0 API
- Reserving memory
- The program counter
- Using DIM to reserve memory
- Efficient cache usage
- Length of reserved memory
- The assembly process
- Assembly at a different address
- OPT summary
- How the assembler works
- Conditional assembly and macros
- Introduction
- Conditional assembly
- Macros
- Reference information
- Table of ASCII codes
- Mathematical functions
- Keyword tokens
- Error Messages and Codes
- Editor and compiler errors
- Cannot allocate clipboard memory
- Cannot allocate virtual memory
- Cannot allocate memory for file
- Cannot append program
- Cannot create character map
- Cannot create file
- Cannot create palette
- Cannot create screen bitmap
- Cannot create temporary buffer
- Cannot crunch file
- Cannot determine encoding
- Cannot embed file
- Cannot find BBCTUTOR.CHM
- Cannot find BBCWIN.CHM
- Cannot find icon in file
- Cannot find manifest
- Cannot open clipboard
- Cannot open file
- Cannot open icon file
- Cannot open temporary file
- Cannot print program
- Cannot process resource in file
- Cannot read file
- Cannot read icon file
- Cannot read icon image from file
- Cannot run Sign Tool
- Cannot update resources in file
- Cannot write file
- Cannot write icon
- Crunch failed: assembler syntax error
- Crunch failed: bad variable name
- Crunch failed: calculated line number
- Crunch failed: invalid fast variable
- Crunch failed: invalid keep variable
- Crunch failed: missing \
- Crunch failed: mismatched quotes
- Crunch failed: statement not at start of line
- Directory was changed
- File is not a valid resource file
- HTML Help not installed
- Insufficient memory
- Insufficient memory to crunch file
- Insufficient memory to crunch program
- Invalid file format
- Line too long
- Line too long - truncated!
- Not enough room for file
- Program is too big for allocated memory
- Sign Tool failed or aborted
- Too many files selected
- Run-time errors
- Trappable errors - BASIC
- Trappable errors - OS
- Untrappable errors
- Access denied
- Accuracy lost
- Address out of range
- Bad call
- Bad command
- Bad DIM statement
- Bad directory
- Bad device
- Bad FOR variable
- Bad hex or binary
- Bad key
- Bad library
- Bad MODE
- Bad MOUSE variable
- Bad name
- Bad program
- Bad string
- Bad subscript
- Bad use of array
- Bad use of structure
- Can't match FOR
- DATA not LOCAL
- Device fault
- Device unavailable
- DIM space
- Disk fault
- Disk full
- Disk read only
- Division by zero
- Escape
- Exponent range
- File exists
- File or path not found
- Incorrect arguments
- Invalid channel
- Jump out of range
- Logarithm range
- Missing ,
- Missing "
- Missing )
- Missing #
- Missing \
- Missing ENDCASE
- Missing ENDIF
- Missing OF
- Missing TO
- Mistake
- Multiple label
- Negative root
- No coprocessor
- No room
- No such FN/PROC
- No such font
- No such line
- No such printer
- No such system call
- No such variable
- Not in a FN or PROC
- Not in a FOR loop
- Not in a function
- Not in a procedure
- Not in a REPEAT loop
- Not in a subroutine
- Not in a WHILE loop
- Number too big
- OF not last
- ON ERROR not LOCAL
- ON range
- ON syntax
- Out of DATA
- Size mismatch
- Size needed
- STEP cannot be zero
- String too long
- Syntax error
- Too many open files
- Type mismatch
- Unknown error
- WHEN/OTHERWISE not first
- Format of Data in Memory
- Memory map
- Memory management
- Reducing stack usage
- Limiting the number of variables
- Program storage in memory
- Line length
- Line number
- Statements
- Line terminator
- Variable storage in memory
- Integer variable storage
- Byte variable storage
- Variant numeric storage (80 bit)
- Floating-point numeric storage (64 bit)
- Variant numeric storage (40 bit)
- String variable storage
- Structure storage
- Fixed strings
- Array storage
- Accessing the SDL 2.0 API
- Introduction to the SDL 2.0 API
- Changing the window title
- Finding the display size
- Displaying a message box
- Playing WAV files
- Timing program execution
- Pausing a program
- Discovering an 'unknown error'
- Repositioning the window
- Fixing the window size
- Minimising or maximising the window
- Bringing the window to the front
- Removing the title bar
- Using the entire screen
- Using the clipboard
- Loading or saving part of a file
- Changing the thread priority
- Checking for input focus
- Downloading files from the internet
- Library Routines
- Introduction to libraries
- Array and matrix functions
- PROC_add
- PROC_mul
- PROC_sum
- PROC_dot
- PROC_transpose
- PROC_invert
- FN_mod
- FN_det
- Dialogue boxes and controls
- FN_newdialog
- PROC_button
- PROC_checkbox
- PROC_radiobutton
- PROC_groupbox
- PROC_textbox
- PROC_static
- PROC_listbox
- PROC_combobox
- PROC_trackbar
- FN_showdialog and FN_showdialogex
- FN_polldialog
- Monitoring dialogue box changes
- Updating the contents of a dialogue box
- Updating the text (or image) associated with a control
- Updating the contents of a list box or combo box
- Updating the state of a checkbox or radiobutton
- Disabling and enabling dialogue box items
- Hiding and showing dialogue box items
- Reading the contents of a dialogue box
- Determining when a button is clicked
- PROC_closedialog
- FN_setproc
- Formatting and conversion
- FNusing(format$,value)
- FNlower(string$)
- FNupper(string$)
- Calendar functions
- FN_mjd
- FN_day
- FN_month
- FN_year
- FN_dow
- FN_dim
- FN_today
- FN_date$
- FN_readdate
- 3D graphics
- FN_initgl
- FN_load3d
- Vertex description
- FN_loadtexture
- PROC_release
- FN_f4
- PROC_render
- Plotting angled ellipses
- PROCellipse(x,y,a,b,angle)
- PROCellipsefill(x,y,a,b,angle)
- Sorting data arrays
- FN_sortinit(dir%,smode%)
- Socket (network) connections
- PROC_initsockets
- PROC_exitsockets
- FN_gethostname
- FN_tcplisten
- FN_tcpconnect
- FN_check_connection
- FN_writesocket
- FN_writelinesocket
- FN_readsocket
- FN_readlinesocket
- FN_getpeername
- PROC_closesocket
- FN_socketerror$
- FN_check_connectionM
- FN_sethost
- FN_setport
- FN_udpsocket
- FN_sendtosocket
- FN_recvfromsocket
- Antialiased graphics
- PROC_aaline
- PROC_aapolyline
- PROC_aabezier
- PROC_aapolybezier
- PROC_aafillbezier
- PROC_aaarc
- PROC_aasector
- PROC_aapolygon
- PROC_aaellipse
- PROC_aaellipsefill
- String manipulation
- FN_lower
- FN_upper
- FN_title
- FN_binary
- FN_tobase
- FN_findreplace
- FN_findreplacei
- FN_instrr
- FN_instri
- FN_instrri
- FN_trim
- FN_split
- FN_join
- Multiple output windows
- PROC_multiwin
- FN_createwin
- PROC_selectwin
- PROC_closewin
- No-wait function replacements
- FNget and FNget$
- FNinkey(t%) and FNinkey$(t%)
- PROCwait
- PROCsound
- FNinput
- High speed timers
- FN_ontimer
- PROC_killtimer
- Parsing XML files
- PROC_initXML
- FN_isTag
- FN_nextToken
- FN_getLevel
- FN_skipTo
- FN_skipToRet
- PROC_exitXML
- FN_repEnt
- Extending the 32-bit x86 assembler
- FN_asmext
- FN_cpuid
- More assembler extensions
- 2D image plotting, scaling and rotating
- PROC_imgInit
- PROC_imgExit
- FN_imgLoad
- FN_imgLoadAnimatedGIF
- FN_imgFrame
- PROC_imgMult
- PROC_imgPlot
- PROC_imgSize
- UTF-8 string functions
- Serialised synchronous events
- PROC_eventinit
- PROC_eventregister(WM_xxxx, PROChandler())
- PROC_eventpoll
- Multi-line text editor control
- PROC_editbox
- PROC_seteditboxarray
- PROC_seteditboxchanged
- PROC_seteditboxselect
- PROC_seteditboxscroll
- PROC_editboxedit
- FN_geteditboxlinecount
- FN_iseditboxchanged
- PROC_geteditboxselect
- PROC_geteditboxscroll
- FN_editboxcanundo
- FN_editboxcanredo
- FN_getselectedtext
- File selector dialogue
- FN_filedlg and FN_filedlgex
- Drop-down and popup menus
- PROC_setmenupalette
- FN_createmenubar
- PROC_addmenu
- PROC_drawmenubar
- FN_pollmenu
- FN_openmenu
- MODE 7 alternative character sets
- PROC_saa5050
- PROC_saa5051
- PROC_saa5052
- PROC_saa5053
- PROC_saa5054
- PROC_saa5055
- PROC_saa5056
- PROC_saa5057
- PROC_saa5059
- PROC_saa505x
- High performance 2D graphics for games
- MODE 7 - Teletext
- Introduction to MODE 7
- Implementation
- Character set (MODE 7)
- Control codes
- Control codes summary
- Coloured text (MODE 7)
- Background colour (MODE 7)
- Block graphics
- Blast-through text
- Separated graphics
- Held graphics
- Flashing
- Double height
- Reveal/conceal
- Hints and Tips
- Using windows larger than 2048 x 2048 pixels
- Passing floats to assembler code or DLLs
- Precautions when using LOCAL arrays
- Using DATA in installed modules
- Re-entrant ON MOVE interrupts
- Cunning use of the CASE statement
© Richard Russell