Commander X16

From C64-Wiki
Jump to navigationJump to search
Commander X16
Type: Home Computer
Producer: http://www.CommanderX16.com
Price: Varies
Released: 2023
Discontinued:
Processor: WDC 65C02 at 8-MHz
Memory: 512K ROM + 40K program RAM + 512K banked RAM*
OS: Enhanced KERNAL and enhanced BASIC 2.0.
Info:

The Commander X16 (colloquially known as the X16) is a modern hardware platform under development. It is intended to be a hobby computer built from modern, mostly off-the-shelf parts, with KERNAL compatibility with the Commodore family of computers. It is the brainchild of David "the 8 Bit Guy" Murray, who wanted an accessible and affordable platform with late-80s sound and graphics. In his own words:

I wanted a computer that was similar to the Commodore 64, but made from all off-the-shelf components.

Its hardware includes a real 65C02 CPU. It is simple enough that someone can understand the entire system. It is capable enough to create a wide retro ecosystem. Its largely off-the-shelf hardware solves retro-computing problems of today: namely, ever-increasing costs, auction site price gouging/sniping, and the unreliability of 40-year old hardware.[1]

Origin[edit | edit source]

In 2019, the popular YouTube program The 8-Bit Guy posted two videos titled "Building My Dream Computer", where he discussed hardware considerations in building a modern 8-bit computer. By the end of the second video, he had settled on a 6502-derived CPU, the Commodore 64 KERNAL, and an architecture based loosely on the VIC-20. He discussed requirements for sound and proposed potential sound chips.[2][3]

KERNAL Compatibility[edit | edit source]

The project's goal is not to create a C64 clone. However, a primary goal is to use a 6502 processor, the Commodore KERNAL and an extended BASIC 2.0. Thus the machine is generally KERNAL-compatible with Commodore machines. Serial IEC allows file transfer by floppy diskette, and an SD card slot permits file transfer by SD2IEC.

VERA's Proof of Concept[edit | edit source]

A follow-on possibility is in repackaging the X16's graphics FPGA "VERA" to extend the graphics and sound capabilities of Commodore and non-Commodore machines, including the C64 and the VIC-20.

Hardware specifications[edit | edit source]

Physically the system is a Micro ATX motherboard with all-DIP socketed chips.

CPU & Clock[edit | edit source]

  • Western Design Center 65C02S, a static descendant of the 6502, running at 8 MHz.
  • Battery-backed Microchip MCP7940N real-time-clock chip. It provide a real-time clock/calendar, two alarms and 64 bytes of RAM. It is accessible through the I2C bus.

I/O[edit | edit source]

The X16 has four expansion slots with access to the CPU data bus. Device #1 is an SD card, instead of the Commodore Datasette. Like the C64 and the VIC-20, the system contains an IEC compatible disk drive port, as well as an I2C bus. It also has two exposed SNES game controller connectors, with two internal pin headers that can support two more connectors. It accepts a PS/2 keyboard and mouse.[1]

Memory and Operating System[edit | edit source]

The memory model is inspired by the VIC-20 with 40k of "low RAM". 1 KB of this used by the system for I/O. A 512K ROM is split into 32 banks of 16K each; Bank 0 holds the Commodore KERNAL, with DOS functions and a 16 bit ABI, and an upgraded BASIC 2.0. The X16 also ships with 512K "high" static RAM, which is split into banks of 8K. High RAM is expandable up to 2MiB. Bank 0 is a scratch space for the operating system.

The memory map is inspired by the VIC-20, which had a no-fuss division of RAM, I/O addresses, and ROM. The Commander X16 builds on this concept by using an 8K window for banked RAM, and using the top 16K of memory for banked ROM:memory map-02.png

Banking logic allows up to 2MB of high RAM for data, machine language, etc, and 128K for ROM. Commander X16 Memory Map

Memory map
Address Range Size Description
0x0000-0x0001 2 bytes RAM, ROM bank control bytes
0x0002-0x0021 32 bytes 16 bit ABI registers
0x0022-0x007F 94 bytes User zero page
0x0080-0x00FF 128 bytes KERNAL and BASIC zero page variables
0x0100-0x01FF 256 bytes Accumulator stack
0x0200-0x03FF 512 bytes KERNAL and BASIC variables, vectors
0x0400-0x07FF 1024 bytes User space
0x0800-0x9EFF 38,656 bytes BASIC program/variable RAM
0x9F00-0x9FFF 256 bytes I/O registers
0xA000-0xBFFF 8192 bytes* RAM Bank window (512K total, expandable to 2MB)
0xC000-0xFFFF 16,384 bytes* ROM Bank window (512K total)

ABI[edit | edit source]

The "ABI Registers" are virtual 16 bit registers r0 through r15, which are located in zero page locations $02 through $21: r0 = r0L = $02, r0H = $03, r1 = r1L = $04 etc. (The registers start at $02 instead of $00 to allow compatibility with 65xx systems that have a processor port at $00/$01.)

Banks[edit | edit source]

To switch the current RAM bank:

POKE 0, B

...where B is the bank number, from 0 to 255. Note that Bank 0 is used by the KERNAL for variables and buffers, so user RAM begins at Bank 1.

To switch the current ROM bank:

POKE 1, B

...where B is the bank number, from 0 to 31. Bank 0 is the KERNAL + BASIC.

ROM banks include things such as:

   - KERNAL
   - Monitor
   - Character sets
   - Keyboard layout
   - CBDOS for SD cards
   - GEOS KERNAL
   - BASIC
   - Assembler/Monitor
   - And room for more.

Sound[edit | edit source]

An on-board Yamaha YM2151 provides MIDI-like sound.[1] Additionally, the VERA module has a simpler PSG with some PCM playback and SID-like capability.

VERA[edit | edit source]

A single FGPA module, named VERA, supplies graphics, basic PSG and PCM sound, and SD card access for the X16. It was designed by Frank van den Hoef.

Graphics[edit | edit source]

The graphics capabilities of the X16 are provided by the VERA module. It has 128 KB RAM, and has multiple output formats (including VGA) at a fixed resolution of 640x480@60HZ. It supports two layers with various tile and bitmap modes, and up to 128 sprites. Its color palette is 256 colors, using a total range of 4096 colors.[1]

VERA supports per-tile h-flip, v-flip, 4-bit palette offset, and a 10 bit tile index. All these modes support smooth scrolling.

Sound[edit | edit source]

VERA has a programmable 16-channel stereo sound generator (PSG) based loosely on the SID; it is also capable of PCM playback.[1]

VERA's PSG has 64 registers devoted to 16 voices, from $1F9C0 - $1F9FF:

VERA's Programmable Sound Generator registers
Voice Registers Voice Registers Voice Registers Voice Registers
0 $1F9C0 - $1F9C3 4 $1F9D0 - $1F9D3 8 $1F9E0 - $1F9E3 12 $1F9F0 - $1F9F3
1 $1F9C4 - $1F9C7 5 $1F9D4 - $1F9D7 9 $1F9E4 - $1F9E7 13 $1F9F4 - $1F9F7
2 $1F9C8 - $1F9CB 6 $1F9D8 - $1F9DB 10 $1F9E8 - $1F9EB 14 $1F9F8 - $1F9FB
3 $1F9CC - $1F9CF 7 $1F9DC - $1F9DF 11 $1F9EC - $1F9EF 15 $1F9FC - $1F9FF

Each block of four registers are as follows:

  • Bytes 0 and 1: frequency LSB, MSB
  • Byte 2: channel (right = bit 7, left = bit 6), volume (bits 0-5)
  • Byte 3: waveform (bits 6 and 7), pulse width (bits 0-5)

The waveform bits are defined as:

  • 00 pulse
  • 01 sawtooth
  • 10 triangle
  • 11 noise

There are no ADSR envelope controls in VERA itself, nor filters. ADSR must be managed by software.

Emulator[edit | edit source]

An official emulator is being co-developed right along side the hardware. The emulator is supported for Windows, Mac, and Linux.[4]

Unofficial emulators are being developed for iPad[5] and Android[6], derived from the source of the official emulator.

Software Compatibility[edit | edit source]

Applications[edit | edit source]

The X16 has an augmented Commodore KERNAL, improved BASIC 2.0 (with a DOS wedge and additional commands imported from the C128 and other places), a machine language monitor, an assembly language editor, and more.[7][8]

BASIC[edit | edit source]

Commander X16 BASIC 2.0 is largely compatible with VIC-20 and C64 BASIC 2.0, with several new commands. Many routines and hardware addresses are different, breaking compatibility with programs using PEEK, POKE, WAIT, and SYS commands.[9]

BASIC has new support for graphics, I/O, memory, hexadecimal and binary literals, and more. Refer to the system documentation for details. [10] The X16 is "as compatible as possible" with BASIC tokenization through V10. Keywords added to X16 BASIC that also exist in other versions of BASIC match the token, and new keywords are encoded in the ranges $CE-$80+ and $FE-$80+.

KERNAL[edit | edit source]

The X16 contains an augmented C64 KERNAL. It supports the X16's video modes, peripherals, timekeeping and simple memory management.

For applications to remain compatible between different versions of the ROM, they can rely upon the KERNAL API. The KERNAL fully supports the C64 KERNAL API. In addition, the X16 supports a subset of the C128 API.

Binary[edit | edit source]

Most binary programs will rely upon specific addressing, and will thus need to be reassembled or recompiled with corrected addresses. Further, the differences in VERA from the Commodore graphics will require different handling as well, generally rendering binary files incompatible.

Assembler[edit | edit source]

There is a machine language monitor in ROM, based upon that of the Final Cartridge III, and using the same commands. [11]

Cross-Compiler Support[edit | edit source]

The Commander X16 is a supported target in the cc65 cross-compiler.[12]

Legality of the modified KERNAL and BASIC[edit | edit source]

The software of the computer is based on leaked Commodore 64 KERNAL and BASIC source code.[13] David requested permission from the current owners of the software (Cloanto) but didn't get a reply.[14] However, "Peri Fractic" was able to get permission from Cloanto to use the BASIC and KERNAL ROMs.Template:Citation needed

Michael Steil has also added new KERNAL routines, based on routines present in the C128 and other systems, for dealing with sprites, date/time, joysticks, mouse, graphics mode, and memory handling.

Should it ever need them, the Commander X16 emulator project has access to the MEGA 65's open ROMs[15] which are open sourced under the LGPL v3 license.[16].

References[edit | edit source]

  1. 1.0 1.1 1.2 1.3 1.4 [1] Commander X16 FAQ
  2. [2] My Dream Computer - Part 1
  3. [3] My Dream Computer - Part 2
  4. [4] GitHub X-16 emulator
  5. [5] Cx16 Facebook Group announcement
  6. [6] APKPure.com Commander X16 Emulator
  7. [7] Commander X16 FAQ
  8. [8] My Dream Computer - Part 2
  9. [9] Cx16 Programmer's Reference Guide - Compatibility
  10. https://github.com/commanderx16/x16-docs/blob/master/Commander%20X16%20Programmer's%20Reference%20Guide.md
  11. [10] Cx16 Programmer's Reference - Machine Language Monitor
  12. [11] GitHub cc65 — Cx16 page
  13. [12] GitHub: "BASIC and KERNAL are derived from the Commodore 64 versions. GEOS is derived from the C64/C128 version."
  14. [13] Youtube.com: 8Bit Guy — Building my Dream Computer, Part 1.
  15. [14] GitHub: Commander X16 r37 release.
  16. [15] GitHub: MEGA65 Open ROM Repository.

See Also[edit | edit source]

Official Documentation[edit | edit source]

Tools and Tutorials[edit | edit source]

8 Bit Guy X16-Related Videos[edit | edit source]