Commander X16

From C64-Wiki
Jump to navigationJump to search
Commander X16
Type: Home Computer
Producer: http://www.CommanderX16.com
Price: TBD
Released: TBD
Discontinued:
Processor: WDC 65C02 at 8-MHz
Memory: 512K ROM + 40K program RAM + 512K banked RAM (expandable to 2MB)
OS: Enhanced BASIC 2.0.
Info:

The Commander X16 (colloquially known as the X-16) is a modern 8-bit computer currently 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 8-bit hobbyist platform. In his own words:

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

It is intended not only as an educational tool, but also to solve retro-computing problems of today: namely, ever-increasing costs, auction site price gouging/sniping, and unreliability of 30-year old hardware. The X16 is made entirely with off-the-shelf modern parts, ensuring availability without reliability issues. It has a real 8-bit CPU rather than using emulation or an FPGA recreation of a processor. It is intended to be inexpensive enough to promote a critical mass of users, to create its own software ecosystem, yet be simple enough that a single person can understand the entire system.[1]

It has an informal relationship with the MEGA65 and the C256 Foenix.

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 KERNAL, and an architecture based loosely on the VIC-20. He discussed requirements for sound and proposed potential sound chips.[2][3]

While the last Commodore 8-bit computers had BASIC 7.0, the X16 builds on version 2.0. [4]

Applications[edit | edit source]

The X16 is expected to ship with an augmented Commodore KERNAL, BASIC (with a DOS wedge and additional commands), a machine language monitor, an assembly language editor, and more.[5][6]

Hardware specifications[edit | edit source]

  • CPU: Western Design Center 65C02S, a static descendant of the 6502.
  • Speed: 8MHz.
  • Video: The VERA module generates VGA (and other formats) at a fixed resolution of 640x480@60Hz; two layers, both supporting 1/2/4/8 bpp tile and bitmap modes; 128 sprites; 128K video RAM; a palette with 256 colors selected from a total range of 4096 colors.
  • Sound: Yamaha YM2151 sound chip. In addition, the VERA module has a 16-channel stereo Programmable Sound Generator with multiple waveforms (Pulse, Sawtooth, Triangle, Noise), and high quality PCM audio playback from an 4 KB FIFO buffer featuring up to 48kHz 16-bit stereo sound.
  • RAM: 40K "low" or "BASIC" RAM, with 1K of this used by the system for I/O. An additional 512K SRAM (expandable to 2MB) is accessible in 8K banks.
  • ROM: Banked in 16K groups; the default bank zero contains an upgraded Commodore KERNAL, with DOS functions and a 16 bit ABI, and an upgraded BASIC 2.0 with additional functionality.
  • Media: An on-board SD card with native FAT32 support is used for primary storage. IEC device support.
  • Outputs: Two SNES controller ports, plus two additional SNES port headers on the board for expansion. PS/2 keyboard and mouse. VGA. Stereo audio. I2C bus.
  • Inputs: SD; four expansion slots with access to the CPU databus; IEC port; SNES ports; I2C bus.
  • Operating System: Commodore KERNAL and BASIC.
  • 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.
  • Form Factor: Micro-ATX.

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. The 512K ROM is split into 32 banks of 16K each; Bank 0 holds the Commodore KERNAL and BASIC. 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.

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

Ports and sockets[edit | edit source]

The X16 has four expansion slots with access to the CPU databus. 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. 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.[7]

Graphics[edit | edit source]

The graphics capabilities of the X16 are provided by the single FGPA, code named "VERA". VERA has 128 KB of its own RAM, and directly outputs a VGA signal. It has multiple output formats, 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.[8]

The Vera chip supports per-tile h-flip, v-flip, 4-bit palette offset, 10 bit tile index. All these modes support smooth scrolling.

Sound[edit | edit source]

For basic sound, the VERA chip itself has a programmable 16-channel stereo sound generator based loosely on the SID; it is also capable of PCM playback. For MIDI-like sound, there will be a Yamaha YM2151.[9] As of Jan 2021, the SAA1099 has been deleted and will not be used going forward.

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

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

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 is encoded as follows:

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

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

Memory Map[edit | edit source]

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 Size [in KB] Description
0x0000 - Bank control bytes
0x0002 - 16 bit ABI registers
0x0022 - User zero page
0x0080 - KERNAL and BASIC zero page variables
0x0100 - Accumulator stack
0x0200 - KERNAL and BASIC variables, vectors
0x0400 - User space
0x0800 38 BASIC program/variable RAM
0x9F00 0.25 I/O registers
0xA000 8* RAM Bank window (512K total, expandable to 2MB)
0xC000 16* 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.

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.

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.

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.[10]

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

Software Compatibility[edit | edit source]

BASIC[edit | edit source]

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

New statements include:

  • CHAR — graphics mode drawing of text
  • CLS - clear the screen (the same effect as ?CHR$(147);)
  • COLOR — set text mode colors
  • DOS — interact with drives
  • FRAME — graphics mode box drawing
  • GEOS — switch to GEOS
  • JOY — returns gamepad state
  • LINE — graphics mode line drawing
  • MON — enter monitor
  • MOUSE, MB, MX, MY — mouse functions
  • OLD — restore program after new or reset
  • PSET — set pixel
  • RECT — graphics mode filled box drawing
  • RESET — software reset of system
  • SCREEN — set screen mode; multiple text
  • VPEEK, VPOKE — VERA memory access.

Other new features include hexadecimal and binary literals, the ability to load into VRAM, and a default to the last-used IEEE device (or 8).

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 a version of the KERNAL as its operating system in ROM. It contains:

  • a 40/80 character screen driver
  • a PS/2 keyboard driver
  • a PS/2 mouse driver
  • an NES/SNES controller driver
  • a Commodore Serial Bus ("IEC") driver [not yet working]
  • simple memory management
  • timekeeping

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. [14]

Cross-Compiler Support[edit | edit source]

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

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.[16] David requested permission from the current owners of the software (Cloanto) but didn't get a reply.[17] However, "Peri Fractic" was able to get permission from Cloanto to use the BASIC and KERNAL ROMs.Template:Citation needed

The Commander X16 emulator project also has the beginnings of open-source ROMs, based on the MEGA 65's open ROMs[18] which are open sourced under the LGPL v3 license.[19].

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.

References[edit | edit source]

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

Links[edit | edit source]