
🕹️ RETRO MAGIC
MAGIC compiles to JavaScript. RETRO MAGIC writes BASIC and assembly for three machines.
The Commodore 64, the Apple II, and the TI-99/4A. A script still looks like MAGIC. The C64 and the Apple II share the 6502. The TI-99/4A uses the TMS9900. C64 BASIC is V2, so the listing avoids ELSE. Apple BASIC is Applesoft. TI sprite programs are Extended BASIC. Names in the C64 and Apple listings are two characters, and a REM line maps them back.
@canvas, @terminal, @sound, @hex, @games, and a small text @ui stay. @3d does not fit these machines. The compiler stops and tells you to drop it.
An emoji in a sprite becomes an 8×8 picture. On the C64 that picture is a VIC-II sprite. On the TI-99/4A it is a TMS9918 sprite. The Apple II has no sprite chip, so the same picture is plotted in lo-res.
@c64, @apple2, and @ti99 keep a statement on that machine. @target("c64") picks the machine when the command line does not.
A sprite
@canvas
let engine = new Engine({ width: 320, height: 200 })
let spark = engine.sprite("✦", 40, 90, 28)
engine.motion(spark, 8, 0)
✦ compiles to the same 8×8 bits on every machine. The note in the listing says where it landed: VIC-II, TMS9918, or lo-res.
Commands
npx retro run examples/hello.magic --target c64
npx retro compile examples/scene.magic --target all --as basic
npx retro compile examples/scene.magic --target ti99 --as asm
npx retro basic run examples/add.bas --target apple2
npx retro asm run examples/add.asm --cpu 6502 --target c64
npx retro asm run examples/add.a99 --cpu 9900
retro run is the host screen. It prints what the program prints. retro compile writes the BASIC listing, the assembly listing, or both. retro basic runs, checks, or tokenizes a listing. Tokenize writes a C64 or Applesoft program image. retro asm assembles and runs 6502 or TMS9900 source. The C64 image is a PRG with a SYS stub. The Apple II image has a 4-byte start-and-length header. The TI-99/4A image is a raw binary from >A000.
Text is 40×25 on the C64, 40×24 on the Apple II, and 32×24 on the TI-99/4A. The C64 has 8 VIC-II sprites. The TI-99/4A has 32 TMS9918 sprites. The Apple II plots the emoji in lo-res.
The JavaScript language, with 3D and an Electron window, is MAGIC. The dark window for these three machines is RETRO Studio. The shelf that powers the emulator on is RETRO Center.
MIT. No account. Alpha. It can still change.
The breadbox toolchain
RETRO MAGIC writes the listing. RETRO-Toolchain is the other door. A 6510 assembler, and C, Pascal, and BASIC compilers. JavaScript, no packages, one PRG out the other side. examples/invaders.c is Space Invaders. A and D move the cannon. Space fires. On this machine c64 -autostart is VICE.
The Apple II and the TI-99 get the same shape of toolbox after the C64 has had two passes. The page for that toolbox is RETRO Toolchain.
Four repos
The 8-bit compiler, the window, the C64 toolchain, and the shelf. Roots. Clone them.