Skip to content

davervw/c-simple-emu6502-cbm

Repository files navigation

c-simple-emu-cbm

Here is a simple Commodore 64/128 and 6502 Emulator I wrote from scratch, ported to C++ from my C# simple-emu-c64 project. Runs in a text console window. Optionally can specify a binary Commodore program to load, BASIC programs will auto-run. Requires Commodore ROMs (not included) present in the roms folder. More details may be relevant from the simple-emu-c64 project.

roms/c128/basichi
roms/c128/basiclo
roms/c128/chargen
roms/c128/kernal
roms/c64/basic
roms/c64/chargen
roms/c64/kernal
roms/pet/basic1
roms/pet/characters.bin
roms/pet/characters2.bin
roms/pet/edit1g
roms/pet/kernal1
roms/ted/basic
roms/ted/kernal
roms/test/6502test.bin
roms/vic20/basic
roms/vic20/chargen
roms/vic20/kernal

C++ Version

This is a mostly object-oriented version to more closely match the C# version now including PET model 2001, Vic-20, Commodore 64, Commodore 128, Commodore 16, Commodore Plus/4. But goodbye plain old C; we will miss you. Long live C++. (The original port from C# to C is still available in the commit history.)

GO 128

Special feature is called GO 128. Just like the counterpart GO 64 implemented in the C128 ROMs, GO 128 will reset the system from 64 to 128 mode. And GO 64 and GO 128 both work in their respective environments to completely reset them, not retaining any memory or state (except disk state). Switching to other systems works too!

Note that unlike the real C128, in this emulator GO 64 will not retain any memory between the environments, nor does the C64 environment share any extras from the C128 system.

GO 2001
GO 20
GO 64
GO 128
GO 16
GO 4

Cross platform

This portable version (master branch unless otherwise specified) has been tested with:

The following branches have been consolidated into a single Unified branch for improved sharing of code and features. It is recommended to follow the unified branch instead of individual branches.

  • Teensy_LCD branch from Arduino, keyboard mapping from STM32
  • M5 branch branched from Teensy_LCD for M5FireIoT, M5Core2, M5CoreS3, with merges from cpp branch for maximum features
  • lilygo-t-display-s3 branch for LilyGo T-Display-S3
  • ESP32-8048S070-7inch branch for Sunton ESP32-8048S070

Only CHRIN/CHROUT/READY(for startup program)/SETLFS/SETNAM/LOAD/SAVE are hooked for terminal version, so no, it won't run your favorite games, only maybe simple ASCII text adventures or such. Sorry no PETSCII either (except LCD versions). Some versions (Windows, Linux, Teensy, M5) with lots of RAM available also have D64 support for simple emulation of 1541 disk images so you can have a persistant collection of files that should be compatible with other emulators.

Usage

c-simple-emu-cbm
c-simple-emu-cbm samples.d64
c-simple-emu-cbm hello.prg

If a .prg is loaded from the command line, it will create a new disk with the same name and extension .d64 unless it already exists.

circle.bas

Credits

Thanks to Lars Gregori for clock changes, using system time as available on Windows, Linux, etc. (C64 only for now)

gettimeofday.c is also under MIT License:

  • Copyright (c) 2003 SRA, Inc.
  • Copyright (c) 2003 SKC, Inc.