No Login Data Private Local Save

ZX Spectrum Basic Emulator - Online Retro Code Playground

6
0
0
0

ZX Spectrum BASIC Emulator

Online Retro Code Playground β€” Write, Run & Relive the 8-bit Era

Ready BORDER: 0  |  INK: 7  |  PAPER: 0
BASIC Program
Line numbers required for program storage Lines: 0
Examples:
πŸ‘‹ Hello World 🎨 Color Show πŸ”· Pattern πŸ“ Graphics 🎯 Guess Number 〰️ Sine Wave ⏰ Simple Clock
Execution Log
Ready. Click RUN or type a direct command.
Frequently Asked Questions
What is ZX Spectrum BASIC?

ZX Spectrum BASIC is the built-in programming language of the ZX Spectrum home computer, released in 1982 by Sinclair Research. It's a dialect of BASIC (Beginner's All-purpose Symbolic Instruction Code) designed by Steve Vickers. Every ZX Spectrum booted directly into its BASIC interpreter, making programming instantly accessible. Key features include line-numbered program storage, floating-point arithmetic, string handling, and direct screen/color control via commands like INK, PAPER, BORDER, PLOT, and DRAW.

Which BASIC commands does this emulator support?

This emulator supports a comprehensive subset including: PRINT (with AT, TAB, ;, ,), LET, GOTO, IF...THEN, FOR...NEXT (with STEP), GOSUB...RETURN, INPUT, CLS, REM, PAUSE, BEEP, PLOT, DRAW, CIRCLE, BORDER, PAPER, INK, BRIGHT, FLASH, RANDOMIZE, STOP, DIM, and CLEAR. Functions include RND, INT, ABS, SGN, SQR, SIN, COS, TAN, ATN, EXP, LN, LEN, STR$, VAL, CHR$, CODE, and PI.

How accurate is the screen simulation?

The screen simulates the ZX Spectrum's 256Γ—192 pixel resolution with a 32Γ—24 character text grid. Each character cell is 8Γ—8 pixels. Color attributes (INK and PAPER) apply per 8Γ—8 cell block, just like the original hardware. The canvas renders at native 256Γ—192 resolution and is scaled up via CSS with image-rendering: pixelated for an authentic retro look. The rainbow border mimics the classic Spectrum loading screen aesthetic.

Can I use this on mobile devices?

Yes! The emulator is fully responsive. On tablets and phones, the layout stacks vertically with the Spectrum screen on top and the editor below. All buttons are touch-friendly, and the code editor adjusts its height for comfortable typing. The canvas scales down to fit smaller screens while maintaining its 4:3 aspect ratio.

How does INPUT work in the emulator?

When the emulator encounters an INPUT statement, it pauses execution and displays a prompt in a modal dialog. Enter your value and click Submit to continue the program. For INPUT with a prompt string (e.g., INPUT "Enter name:"; n$), the prompt text appears both on the virtual screen and in the dialog. String inputs should be entered without quotes; numeric inputs must be valid numbers.

Why must I use line numbers?

Line numbers are fundamental to ZX Spectrum BASIC. Each program line must begin with a number (1–9999), which determines execution order and serves as a target for GOTO, GOSUB, and FOR...NEXT loops. Lines are executed in ascending numerical order unless a jump instruction redirects flow. Without line numbers, the interpreter cannot store or sequence your program β€” this mirrors the original Spectrum's behaviour exactly.

Is the BEEP sound accurate?

The BEEP duration, pitch command uses the Web Audio API to generate tones. While not a perfect emulation of the Spectrum's single-channel piezo speaker, it produces recognizable beeps with duration in seconds and pitch in Hz (approximate). The original Spectrum used a different pitch encoding, so we've mapped it to frequency values that sound reasonable. Ensure your browser allows audio autoplay for the best experience.

Can I export or share my programs?

Yes! Click the Export button to download your BASIC program as a .bas text file. You can share this file with others or re-import it by pasting the contents back into the editor. The exported file contains plain text with line numbers, making it compatible with other ZX Spectrum tools and emulators. You can also simply copy-paste code between browser sessions.