SkillAgentSearch skills...

CVBasic

BASIC language compiler for Colecovision, MSX, SG1000/SMS, Spectravideo SVI-318/328, Creativision, Sord M5, Memotech MTX, Tatung Einstein, Casio PV-2000, Hanimex/Soundic Pencil II, and NES/Famicom.

Install / Use

/learn @nanochess/CVBasic

README

CVBasic compiler v0.9.1

(c) Copyright 2024-2026 Óscar Toledo Gutiérrez https://nanochess.org/

CVBasic is a BASIC language cross-compiler with a syntax alike to QBasic. It supports the following platforms:

  • Colecovision (supporting bank switching with Megacart mapper)
  • Sega SG-1000 / SC-3000 (supporting bank switching with Sega mapper)
  • MSX 1 and MSX 2 (supporting bank switching with ASCII16 mapper)
  • Texas Instruments TI-99/4A (courtesy of @tursilion, supporting bank switching)
  • Spectravideo SVI-318 / 328.
  • Sord M5.
  • Memotech MTX.
  • Vtech Creativision (Dick Smith's Wizzard / Laser 2001).
  • Tatung Einstein.
  • Casio PV2000.
  • Hanimex/Soundic Pencil II.
  • NABU PC.
  • Sega Master System (supporting bank switching with Sega mapper)
  • NES/Famicom (supporting bank switching using mapper 30 - UNROM 512)

The CVBasic compiler can create programs up to 1 MB using the BANK statements (using 16K bank switching on most platforms, 8k on TI-99/4A).

One of the advantages of using CVBasic is that all the programs can be compiled for all the platforms with mostly no modifications at all. Although the compiler started supporting only Z80, now this includes the 6502 based Creativision, and TMS9900 based TI-99/4A. This way it achieves a truly portable BASIC across the common theme: the video processor Texas Instruments TMS9128/9129.

Porting to MSX2 is relatively easy. You only need to use MODE 4 for enabling the extended video mode, and create 16-byte color tables for sprites, and use these with DEFINE SPRITE COLOR.

Currently, Sega Master System and NES/Famicom are the most different in video terms, although the compiler shares the core, the sprites are 8x16 and each pixel can have a different color, so the games aren't directly portable, but very easily translated. The examples include SMS and NES/Famicom versions for every game so you can see the required changes.

The following files compose the compiler:

cvbasic.h                   The CVBasic compiler global definitions.
cvbasic.c                   The CVBasic compiler C language source code.
cpu6502.h                   6502 code headers.
cpu6502.c                   6502 code generation.
cpu9900.h                   TMS9900 code headers.
cpu9900.c                   TMS9900 code generation.
cpuz80.h                    Z80 code headers.
cpuz80.c                    Z80 code generation.
driver.h                    Driver headers.
driver.c                    Driver for all processors.
node.h                      Tree node headers.
node.c                      Tree node creation and optimization.
LICENSE.txt                 Source code license

cvbasic_prologue.asm        Prologue file needed for compiled programs.
cvbasic_epilogue.asm        Epilogue file needed for compiled programs.
cvbasic_6502_prologue.asm   Prologue file needed for Creativision compiled programs.
cvbasic_6502_epilogue.asm   Epilogue file needed for Creativision compiled programs.
cvbasic_9900_prologue.asm   Prologue file needed for TMS9900 compiled programs.
cvbasic_9900_epilogue.asm   Epilogue file needed for TMS9900 compiled programs.
cvbasic_nes_prologue.asm    Prologue file needed for NES/Famicom compiled programs.
cvbasic_nes_epilogue.asm    Epilogue file needed for NES/Famicom compiled programs.

manual.txt                  English manual for CVBasic

README.md                   This file

examples/bank.bas           Bank-switching example.
examples/bank_nes.bas       Bank-switching example (NES/Famicom)
examples/bank_sms.bas       Bank-switching example (Sega Master System)
examples/brinquitos.bas     Jumping game.
examples/brinquitos_nes.bas Jumping game (NES/Famicom)
examples/brinquitos_sms.bas Jumping game (Sega Master System)
examples/controller.bas     Controller test.
examples/controller_nes.bas Controller test (NES)
examples/cats_sms.bas       Cats example (Sega Master System)
examples/demo.bas           Demo of graphics.
examples/demo_nes.bas       Demo of graphics (NES/Famicom)
examples/demo_sms.bas       Demo of graphics (Sega Master System)
examples/face_joystick.bas  Moving face with joystick.
examples/face_joystick_nes.bas  Moving face with joystick (NES/Famicom)
examples/face_joystick_sms.bas  Moving face with joystick (Sega Master System)
examples/happy_face.bas     Bouncing face.
examples/happy_face_nes.bas Bouncing face (NES/Famicom).
examples/happy_face_sms.bas Bouncing face (Sega Master System).
examples/music.bas          Music example.
examples/oscar_compressed.bas  High-resolution graphics example compressed with Pletter.
examples/oscar_compressed_sms.bas  High-resolution graphics example compressed with Pletter (Sega Master System)
examples/oscar.bas          High-resolution graphics example.
examples/oscar_nes.bas      High-resolution graphics example (NES/Famicom)
examples/oscar_sms.bas      High-resolution graphics example (Sega Master System)
examples/palette_msx2.bas   Example of palette support in MSX2
examples/portrait.bas       Data used by demo.bas
examples/portrait_sms.bas   Data used by demo_sms.bas
examples/space_attack.bas   Game example.
examples/space_attack_nes.bas   Game example (NES/Famicom)
examples/space_attack_sms.bas   Game example (Sega Master System)
examples/spinner.bas        Spinner / Roller Controller example (Colecovision)
examples/test1.bas          Moving stars.
examples/test2.bas          Arithmetic test.
examples/test3.bas          Shows usage of SELECT CASE / END CASE
examples/test3_sms.bas      Shows usage of SELECT CASE / END CASE (Sega Master System)
examples/test4.bas          Benchmark and test of multiplication/division
examples/varptr.bas         VARPTR example for redefining graphics.
examples/varptr_sms.bas     VARPTR example for redefining graphics (Sega Master System)
examples/vgm.bas            VGM audio player for SN76489.
examples/vgm_ay.bas         VGM audio player for AY-3-8910.
examples/viboritas.bas      Game example.
examples/viboritas_msx2.bas Game example (MSX2)
examples/viboritas_nes.bas  Game example (NES/Famicom)
examples/viboritas_sms.bas  Game example (Sega Master System)
examples/vramcopy.bas       VRAM copy example.
examples/vramcopy_sms.bas   VRAM copy example (Sega Master System)

Usage guide

Using CVBasic to compile a Colecovision program:

cvbasic game.bas game.asm
gasm80 game.asm -o game.rom -l game.lst

You need to assemble the output file using Gasm80 available from http://github.com/nanochess/gasm80 (this assembler serves for all the platforms, including Creativision based on 6502 CPU)

Using CVBasic to compile a Sega SG1000/SC3000 program:

cvbasic --sg1000 game.bas game.asm
gasm80 game.asm -o game.rom

Using CVBasic to compile an MSX program for 8K RAM (wider compatibility) and 16K RAM:

cvbasic --msx game.bas game.asm
gasm80 game.asm -o game.rom

cvbasic --msx -ram16 game.bas game.asm
gasm80 game.asm -o game.rom

cvbasic --msx -ram16 -konami game.bas game.asm
gasm80 game.asm -o game.rom

For bank-switched programs the default mapper is ASCII16, but you have the option of using a standard Konami 8K mapper using the -konami switch.

Using CVBasic to compile an MSX2 program for 8K RAM (wider compatibility) and 16K RAM:

cvbasic --msx2 game.bas game.asm
gasm80 game.asm -o game.rom

cvbasic --msx2 -ram16 game.bas game.asm
gasm80 game.asm -o game.rom

cvbasic --msx2 -ram16 -konami game.bas game.asm
gasm80 game.asm -o game.rom

For bank-switched programs the default mapper is ASCII16, but you have the option of using a standard Konami 8K mapper using the -konami switch.

Using CVBasic to compile a Colecovision Super Game Module program:

cvbasic --sgm game.bas game.asm
gasm80 game.asm -o game.rom

Using CVBasic to compile a Spectravideo SVI-318/328 program:

cvbasic --svi game.bas game.asm
gasm80 game.asm -o game.rom

Using CVBasic to compile a Sord M5 program (16K ROM):

cvbasic --sord game.bas game.asm
gasm80 game.asm -o game.rom

Using CVBasic to compile a Memotech MTX program:

cvbasic --memotech game.bas game.asm
gasm80 game.asm -o game.run

cvbasic --memotech -cpm game.bas game.asm
gasm80 game.asm -o game.com

Using CVBasic to compile a VTech Creativision (Dick Smith's Wizzard / Vtech Laser 2001) program:

cvbasic --creativision game.bas game.asm
gasm80 game.asm -o game.rom

You can use the -rom16 option to generate a 16K ROM instead of a 32K ROM, and it is provided utility/switch.c to switch the two 8K banks in a 16K ROM and run it with MAME, as MAME doesn't yet support 32K ROM. For 32K ROM you can use the Creativision emulator, and the command line is:

creativision -g -b ..\BIOS\BIOSCV.ROM -r game.rom

Using CVBasic to compile a Hanimex/Soundic Pencil II program (almost exactly like a Colecovision, but with 2K of RAM and different cartridge header):

cvbasic --pencil game.bas game.asm
gasm80 game.asm -o game.rom

Using CVBasic to compile a Tatung Einstein program:

cvbasic --einstein game.bas game.asm
gasm80 game.asm -o game.com

Using CVBasic to compile a Casio PV-2000 program (16k ROM):

cvbasic --pv2000 game.bas game.asm
gasm80 game.asm -o game.rom

Using CVBasic to compile a Texas Instruments TI-99/4A program:

cvbasic --ti994a game.bas game.a99
xas99.py -b -R game.a99
linkticart.py game.bin game_8.bin "CARTNAME"

You require Python3 and the utilities from the xdt99 tool suite: https://github.com/endlos99/xdt99

The target is a stock TI-99/4A system with 32k memory expansion and jo

View on GitHub
GitHub Stars82
CategoryProduct
Updated3d ago
Forks12

Languages

C

Security Score

85/100

Audited on Mar 30, 2026

No findings