This example parses a string appended to the SYS command on Commodore 64
Saturday, May 14, 2022
One wonderful feature of the Commodore 128 was its compatibility with the Commodore 64. It was an evolution of the Commodore 64 and still supported all the software and hardware from before. For me it was a no-brainer to buy. 80 columns, plus new features, plus CP/M. Adding a mouse, GEOS 128, REU 512K, and 3.5" floppy, and I thought it was the best place to be this side of heaven.
There were multiple ways to go into Commodore 64 mode.
- Start with a Commodore 64 cartridge
- Boot/reset with the Commodore key held
- Commodore 128 boot disk that switched to Commodore 64 mode
- Switch MMU to Commodore 64 mode
- GO 64 command
PET 2001 2K to 64K supported
Vic-20 5K to 39K supported in hardware supported increments, not all available to BASIC64 RAM 3K to 64K supported not all available to BASIC
Commodore 16 and Plus/4 support 16K, 32K, or 64KCommodore 128 fixed at 128K (KERNAL does not do RAM test)
Limitations? Oh, sorry. This emulator is text only. No full screen editor. Doh! No screen pokes either (well not displayed). Nor PETSCII and commodore graphics characters. But does support console history editor on Windows. Linux and MAC builds (you can build from my open source project) provide only simple line editing capability. Does provide accurate 6502/6510/8502 emulation, RAM banking, etc. according to the platform. So pop into the MONITOR on C128 or C16, Plus/4, or SUPERMON on other platforms to write and edit machine code. And because using console window, the text display size is not as limited, 88 columns for Vic-20 and 160 columns for C128.
|Resizable text console - 132x50 text screen on Commodore 128|
|Bil Herd, Ted/C128 hardware design project lead (left) and Dave Van Wagner, geek (right)|
Wednesday, May 4, 2022
The Commodore 128 is a favorite system of mine. I've owned a DCR model (cost reduced with embedded disk drive, the metal case) since around 1987. And it still works fine!
But this article is about emulation. I already wrote a C#/.NET based emulator that supports PET/Vic-20/64/16/Plus/4, and just recently have added 128 support. I thought it would be difficult with the C128 custom MMU and VDC. There was a learning curve. And I faked enough of it to boot and work (even with no Z80).
This simple emulator is a text based emulator run from a console window. It provides only text input and output, in addition to LOAD/SAVE support to the local disk as .PRG files (just a common extension for Commodore program files, unformatted binary data).
Feed the emulator some Commodore ROMs (not included, recommend grab these from Vice) and it can map ROM/RAM into the 6502 memory space and execute 6502 instructions. There are some common KERNAL entry points for character in, character out, check for stop, and load/verify/save operations. These calls are hooked to redirect console input/output to the emulated 6502. Effectively the Commodore computers are running in software.
These emulated systems don't do the fancy video games. There is a long list of things they don't do, including no PETSCII graphics either. No graphics. No sound. No timers. No color. They don't even do full screen editing. They are stuck using the console editing features. Not great, but it works -- cursor up to recall a previous command in the current screen line editor. And the Windows console editor even survives restarting the program or restarting the Commodore. Please note it is best to use Caps Lock as the Commodore expects uppercase commands most of the time.
What this does function as is a good text BASIC interpreter, and 6502 machine language environment. Some of the Commodore systems such as the C128 and Plus/4 include their own machine language monitor (MONITOR command). On the PET, Vic-20, and C64, you can load the appropriate SUPERMON for that system.
Since we're using a Windows console in this case (or Linux or MAC... .NET supports them too!), it can be sized to screens larger than 40x25 as well. Imagine the capability of full screen text written in BASIC! Or a long disassembly listing in the monitor. Wow!
Here's how to get started.
1. Grab the sources from github
2. Grab the roms from vice, (a much larger more complete and more accurate emulator, but why would you want that much fun?). Put these in a c128 directory from which you will run the simple emulator. While you're at it, create subdirectories and copy roms for the other systems too.
c128: kernal, basiclo, basichi, chargen
c64: kernal, basic, chargen
vic20: kernal, basic, chargen
ted: kernal, basic
pet: basic1, edit1g, kernal1
3. Compile using Visual Studio or dotnet.
4. Run with the command line argument: c128
Why do this? To me this was a challenge to first emulate the 6502, and a challenge to minimally support Commodore BASIC. I thought what is the least amount of support that is needed to have a useful Commodore computer? I knew about the Kernal jump table definition by Commodore. I had seen others do it successfully. And I wanted to do it my way. It was just a mountain to climb, and since I love 6502 and Commodore computers, it is an enjoyable part of my hobby.