Quantum Basic 7.1
A QuickBASIC / PDS 7.1 compatible compiler for 64-bit Windows. Write BASIC the way you always have, and get a native x64 program out the other end. Old programs that poke video memory or call DOS interrupts keep working, and many QB64 extensions work too.
▼ Download Quantum Basic 7.1QuantumBASIC.zip · Version 1.1.0 · Windows 64-bit
What's new in 1.1.0
- Raw sound streaming:
_SNDRAW,_SNDRATEand_SNDRAWLEN. Programs can now generate their own audio sample by sample (synthesizers, chip-music players, sound effects) and it plays alongside sounds loaded with_SNDOPEN.
What it does
- Compiles QuickBASIC and PDS 7.1 programs to native 64-bit Windows executables
- Supports many QB64 extensions:
_NEWIMAGE,_PUTIMAGE,_LOADIMAGE,_KEYDOWN,_SNDOPEN,_MEMand more - Graphics in every SCREEN mode through an SDL2 window, including 32-bit color screens
- Emulates the DOS memory map, so
DEF SEG,PEEK,POKE,CALL ABSOLUTEandCALL INTERRUPTstill do what they used to - Sound from WAV and OGG files, plus raw sample streaming
- An IDE with editor, color schemes and F1 help in the classic PDS 7.1 blue
How it works
Quantum Basic is a real compiler, not an interpreter. Your program goes through the same stages as a C compiler and ends up as x64 machine code, linked against the Quantum Basic runtime library.
The runtime library (librt.a) is where the BASIC statements actually
do their work. Two of its parts are written specially for Quantum Basic:
rt_graphics_sdl2 and rt_cpu_emu.
rt_graphics_sdl2 — the graphics and sound engine
Every compiled program opens an SDL2 window, and rt_graphics_sdl2
draws everything that appears in it. It recreates the screen modes of a VGA-era
PC pixel for pixel, then scales the picture to fit a modern monitor.
Screen modes and text
SCREEN 0throughSCREEN 13with the original resolutions, colour counts and default palettes, including the 256-colour VGA palette ofSCREEN 13- QB64 32-bit colour screens and off-screen images with
_NEWIMAGE PRINT,LOCATE,COLORandVIEW PRINTin every mode, with the full CP437 character set (box-drawing, accented letters, symbols) in built-in 8×8, 8×14 and 8×16 fonts- Blinking text, and a blinking cursor for
INPUTin graphics modes - TrueType fonts with
_LOADFONTand_FONTwhenSDL2_ttf.dllis present (programs still start without it)
Drawing
PSET,PRESET,LINE(boxes, filled boxes, styled lines),CIRCLE(arcs and ellipses),PAINTandDRAWVIEWviewports,WINDOWcoordinates andPMAPPALETTEandPALETTE USING- Sprites with
GETandPUT(PSET, PRESET, AND, OR, XOR) - Multiple screen pages with
PCOPYfor flicker-free animation
QB64 images, input and window
- Image handles:
_NEWIMAGE,_LOADIMAGE(BMP, PNG, JPG, GIF),_PUTIMAGEwith scaling,_DEST,_SOURCE,_SETALPHA,_FREEIMAGE - Colour functions:
_RGB32,_RGBA32,_RED32and friends - Keyboard:
INKEY$,_KEYDOWN(several keys held at once),_KEYHIT,_KEYCLEAR - Mouse:
_MOUSEINPUT,_MOUSEX,_MOUSEY,_MOUSEBUTTON - Window:
_TITLE,_ICON,_FULLSCREEN,_SCREENMOVE, and smooth game loops with_DISPLAYand_LIMIT - Simple on-screen controls:
BUTTON,CHECKBOX,RADIOBUTTON
Sound
- A 32-voice software mixer: up to 32 sounds play at once, each with its own
volume (
_SNDVOL) and left/right balance (_SNDBAL) - WAV (PCM, float and ADPCM) and Ogg Vorbis files with
_SNDOPEN,_SNDPLAY,_SNDLOOP,_SNDPLAYCOPY,_SNDPLAYFILEand the rest of the QB64 sound set - New in 1.1.0:
_SNDRAWstreams samples you calculate yourself, mixed in with the voices above
' a one-second 440 Hz beep, made sample by sample
FOR i = 1 TO _SNDRATE
_SNDRAW SIN(i / _SNDRATE * 440 * 6.2832) * 0.3
NEXT i
DO: LOOP WHILE _SNDRAWLEN
rt_cpu_emu — the DOS memory and CPU emulator
Many classic BASIC programs reach past BASIC and talk to the PC directly: they
POKE straight into video memory, read the keyboard flags from the BIOS
data area, or run small machine-code routines. On 64-bit Windows those addresses
don't exist, and touching them would crash the program.
rt_cpu_emu is a custom-written layer that recreates that old PC
world inside your program, so the code runs as it did under DOS.
An emulated real-mode memory map
| Address | What happens |
|---|---|
| &HA000 | VGA graphics memory. In SCREEN 13 each byte
you POKE is a pixel, and it shows up in the window in the right
palette colour. PEEK reads it back. |
| &HB800 | Colour text memory: the 80×25 grid of characters and attribute bytes. Programs that draw screens by poking text memory display correctly. |
| &H0000–&H9FFF | Conventional memory, including the interrupt table and the BIOS data area. It starts out filled in the way a real BIOS leaves it: Caps/Num/Scroll Lock state taken from your keyboard, 640K of memory, colour 80-column display. |
| DEF SEG = 0 | Addresses from VARPTR and
SADD go straight to your program's own variables, so the
PEEK/POKE tricks that work on BASIC data still work. |
' fill the SCREEN 13 display through video memory
SCREEN 13
DEF SEG = &HA000
FOR i = 0 TO 63999: POKE i, i MOD 256: NEXT i
DEF SEG
CALL ABSOLUTE and CALL INTERRUPT
CALL ABSOLUTEruns the 16-bit machine code the program built in an array through a small built-in 8086 interpreter, with its own registers and stack. It covers the short routines BASIC programs typically carried: register loads,PUSH/POP,INTcalls andRET.- Interrupts made from that code, or from
CALL INTERRUPTandCALL INTERRUPTXwith aRegTypestructure, are answered by emulated DOS and BIOS services and carried out with Windows: DOS functions (INT 21h), video (INT 10h), the mouse driver (INT 33h) and the printer (INT 17h).
The result: programs written for real DOS hardware in the 1980s and 1990s can be compiled and run as 64-bit Windows programs, usually without changing a line.
Getting started
Download the zip and extract it to a folder. Then use the IDE or the command line.
The IDE: double-click qb71ide.exe. Write your program in the
editor, then compile and run it from there. Press F1 for help on any
keyword.
Important: every new program must be saved before you run it in the IDE.
The command line: open a command prompt in the folder and compile your program:
C:\QuantumBASIC> qb71 program.bas
That makes program.exe in the same folder. Run
qb71 -h to see all the options.
Requirements
- Windows 7 64-bit or later
- Optional:
SDL2_ttf.dllnext to your program for TrueType fonts