Driver:c128d

From MAMEDEV Wiki

Commodore c128 and c128d devices

This page explains working with the MAME emulation of the Commodore 128 and the desktop verion 128d (MAME devices c128 and c128d) - for which this page was started, but both are identical except for the minor difference of the internal drive in the desktop version

* Short excerp from C64-Wiki

Commodore 128
Commodore 128
Commodore 128d with orignal package box
Commodore 128d with orignal package box

The C128D is a C128 but with an integrated power supply and 1571 disk (DOS 3.1) housed in a sheet-metal case and with an external keyboard. It features C64 / 128 KERNALs on a 32 Kbyte ROM and has 64 Kbytes of V-RAM.

It has three modes:

  1. C128 mode with BASIC 7.0 (default on power up)
  2. C64 mode with BASIC 2 (activated by typing GO64 or by resetting with the C= {Std Mame Layout ALT-Key} 'key depressed)
  3. CP/M mode with CP/M 3.0+ (after booting from CP/M system diskette)

Some Short Notes for running the Commodore 128d in Mame

MAME emulates both an 80 column display and the common 40 column display, due to the fact that the c128d was capable of running a dual monitor setup MAME will boot the system with both monitors online

Everything written here can be applied to the c128 device in MAME as well, as these machines are practically the same hardware (except for differences in revisions) plus the internal disk drive on the desktop version

Requirements (fFirmware roms)

Before you can start up the c128d emulation you ill have to make sure that the required firmware roms ar reachable in the rompath searched by MAME (to be configured in mame.ini)

To see qhich roms and their checksums you need you can execute the command


mame c128d -listroms
ROMs required for driver "c128d" (including device "c1571").
Name                                   Size Checksum
251913-01.u32                         16384 CRC(0010ec31) SHA1(765372a0e16cbb0adf23a07b80f6b682b39fbf88)
318018-02.u33                         16384 CRC(2ee6e2fa) SHA1(60e1491e1d5782e3cf109f518eb73427609badc6)
318019-02.u34                         16384 CRC(d551fce0) SHA1(4d223883e866645328f86a904b221464682edc4f)
318020-03.u35                         16384 CRC(1e94bb02) SHA1(e80ffbafae068cc0e42698ec5c5c39af46ac612a)
318018-04.u33                         16384 CRC(9f9c355b) SHA1(d53a7884404f7d18ebd60dd3080c8f8d71067441)
318019-04.u34                         16384 CRC(6e2c91a7) SHA1(c4fb4a714e48a7bf6c28659de0302183a0e0d6c0)
318020-05.u35                         16384 CRC(ba456b8e) SHA1(ceb6e1a1bf7e08eb9cbc651afa29e26adccf38ab)
318018-04.u33                         16384 CRC(9f9c355b) SHA1(d53a7884404f7d18ebd60dd3080c8f8d71067441)
318019-04.u34                         16384 CRC(6e2c91a7) SHA1(c4fb4a714e48a7bf6c28659de0302183a0e0d6c0)
jiffydos c128.u35                     16384 CRC(4b7964de) SHA1(7d1898f32beae4b2ae610d469ce578a588efaa7c)
318018-04.u33                         16384 CRC(9f9c355b) SHA1(d53a7884404f7d18ebd60dd3080c8f8d71067441)
318019-04.u34                         16384 CRC(6e2c91a7) SHA1(c4fb4a714e48a7bf6c28659de0302183a0e0d6c0)
quicksilver128.u35                    16384 CRC(c2e74338) SHA1(916cdcc62eb631073aa7f096815dcf33b3229ca8)
390059-01.u18                          8192 CRC(6aaaafe6) SHA1(29ed066d513f2d5c09ff26d9166ba23c2afb2b3f)
8721r3.u11                             3208 BAD CRC(154db186) SHA1(ccadcdb1db3b62c51dc4ce60fe6f96831586d297) BAD_DUMP
310654-03.u2                          32768 CRC(3889b8b8) SHA1(e649ef4419d65829d2afd65e07d31f3ce147d6eb)
310654-05.u2                          32768 CRC(5755bae3) SHA1(f1be619c106641a685f6609e4d43d6fc9eac1e70)
jiffydos 1571.u2                      32768 CRC(fe6cac6d) SHA1(d4b79b60cf1eaa399d0932200eb7811e00455249)

For the c128d you will need the firmware for the c128, and the floppy c1571 (as noted in the listing above), PAL Firmware ishould be in c128p, but the eumulation may load parts of the rom inside the ntsc set as well (chracter rom for example does not differ and is shared)

For your convenience you can get the needed Firmware files here (all available revisions and language deviations included).

Firmware C128 NTSC

Firmware C128 PAL

Firmware C1571 Floppy

Firmware C1571CR Floppy

Basic MAME keyboard shortcuts for C128d

Useful Keyboard Shortcuts

Link to MAME default Keyboard Layout

While using MAME it is always good to have these ready, note that inside the emulation the keys are not recognised by Mame unless you enable UI mode (default key <Scroll Lk> )!

Keyboard Shortcuts (There are plenty more, read the docs)
Key Description (UI enabled Mode!)
<Scroll Lock> Switch UI enabled/disabled
<ESC> Exit Mame
<F3> Soft Reset
<TAB> Open/Close Mame Menu
P Pause Emulation
Key Description (UI disabled Mode!)
<ALT> <C=>
<F6> <TAB>
<F11> 40/80 Display

Start the 128d in MAME with command line

For NTSC version start with mame c128d and for the pal version you use mame c128dp

Dual Screen (40 and 80 column displays at the same time)

MAME will bring up the system, the default MAME configuration has both available screens activated at the first boot without addidtinall parameters:

CAUTION: MAME Home Computer emulation always starts in GUI disabled mode - all keyboard inputs are managed by the emulated system - as such there is no possibility to exit the emulation in this mode until you switch to UI enabled Mode'#Useful Keyboard Shortcuts

c128 and c128d after powerup in default MAME configuration

Single Screen (40 Column display)

As a historic sidenote I should menttion that the most common configuration the owners started with in the 80's was a single screen setup, since pc monitors were kind of expensive at that time. To start the machine in MAME with the single 40 column Screen that was most often used, you start mame with mame c128d -view "Screen 1 Standard" c128 and c128d in 40 Column Single Monitor Setup

To get a list of all variants, you enter mame c128 -listclones

As of MAME 0.251 the current list of clones available is

mame c128 -listclones
Name:            Clone of:
c128_de          c128
c128_se          c128
c128cr           c128
c128d            c128
c128d81          c128
c128dcr          c128
c128dcr_de       c128
c128dcr_se       c128
c128dcrp         c128
c128dp           c128

Confirmed not working (MAME 0.251)

Currently I am trying to gather a listing about what works in Mame, and what is bugged right now, this list will grow continually

C64 Tapes (incoming fix for next MAME looks good so far)

Everything from the C64 Softwarelist Cassette Source is broken right now, The MAME c64 Device can run those without problem, but the c128 devices are all broken in this regard right now!

Note: While the tape versions on the c128 Device in MAME iscurrently not working, most programs/games have a "cracked" disk version available somewhere on the net - Most often these versions can be run instead of the tape version and will work on MAME c128(d) devices - BUT rtake note that the c128 emulation is noat as far in refinement as the c64 emulation in MAME is - so if you are hard pressed to play a c64 game, at the moment you should use the c64 emulation for it, the c128 emulation in c64 mode tends to show a lot of artifacts while the c64 MAME device manages to emulates it fine

Note2:Just to be safe I also tested the tapes with the vice emulator - and they definitely load and start there like it should be. (From my experience while most c64 games do work on the real hardware, not all did!)

C128 Disk

C128 Disks (Softwarelist)'
Program/Game Marked as working? Notes
Beyond Zork:TheCoconut of Quendor (R47) Yes Beyond Zork 128 Floppy Disk 1 Boot Error Message Same Disk Set works in VICE
GEOS 128 v2.0 Yes GEOS 128 v2.0 Boot Error Message Same disk set works in VICE
The Last V-8 Yes The disk can be read and the game can be started, but after the first screen the game stops working in MAME. Test in VICE with the same disk worked flawless
Elite 128 Not in softwarelist The Disk directory (LOAD"$",8) cannot be read in MAME c128. The Same Disk can be read in VICE and the game can be loaded and started without problems there. NOTE: This Game has to be started in C64 Mode despite being a C128 Game NOTE2: Link to test disk Elite 128 Disk Archive
Tetris 128 Not in softwarelist The disk directory loads fine and the game can be started, but stops immediately with a problem ?device not present (referencing a line in the basic code that executes a bload command). The same Disk can be read in VICE and the game can be loaded and started without problems there. NOTE: PM if you need a test specimen) NOTE2: Afte running the game once, the emulation state is broken and does not recover with resets - the disk remains unreadable until mame is closed and the emulation fully restarted.
The Rocky Horrow Picture Show 128 Yes but this version definitely seems to be broken as it fails in other emulators The Disk from Softwarelist can be loaded, and the game starts loading (binary gibberish visble) but then it shows a broken boot message on the 80 column screen and stays in an infinite loading loop it seems. On Vice it shows nothing on the 80 column screen but also fails to load with the version from the software list. Using a cracked image (not in softlist The Rocky Horror Picture Show 128 meanwhile works ok in MAME (some audio artifacts and some broken sprites) but playable and very well in Vice.

Scratchpad verifying (MAME version checked noted in table)

C128 Disk

Report in the order of the xml

Name Softtlist Name Disk Count Boot Disk? Tested version State if broken works in Vice? protection tag (if given)
A Mind Forever Voyaging (R77) amfv 2 yes MAME 0.251 OK none
Beyond Zork: The Coconut of Quendor (R47) byondzrk 2 yes MAME 0.251 broken yes none
Bureaucracy: A Paranoid Fantasy (R116) bureaucr 2 yes MAME 0.251 OK none
Bureaucracy: A Paranoid Fantasy (R86) bureaucra 2 yes MAME 0.251 OK none
The Last V-8 lastv8 1 no MAME 0.251 broken yes none
The Rocky Horror Show rockyhor 1 no MAME 0.251 broken no (prot?) fat
Thai Boxing thaibxng 1 yes MAME 0.251 broken no (prob prot?), alternative .d64 image works here, but not in MAME fat
High Voltage SID Collection 10 Years 1996-2006 10yrhvsc 1 no MAME 0.251 broken no
BASIC-128 v1.03 basic128 1 yes MAME 0.251 OK none
Big Blue Reader 128 bbr128 1 yes MAME 0.251 broken yes none
Buddy System 128 v10 buddy128 1 no MAME 0.251 broken? seems to be an asembler and i don't know how to correctly use it, might be user error same result, maybe pebkac none
Commodore 128 Tutorial c128tutr 1 no MAME 0.251 OK none
CADPAK-128 cadpak 2 yes MAME 0.251 OK none
Comm Term 64/128 commterm 1 yes MAME 0.251 broken yes none
Data Manager 128 datamgr 2 yes MAME 0.251 broken yes none
Enhanced SidPlayer (128 Version) enhsidpl 1 yes MAME 0.251 OK none
Fast Hack'em 128 v6.00 fasthack 1 yes MAME 0.251 OK none
GEOS 128 v2.0 geos20 6 yes MAME 0.251 broken yes signature
Jane jane 2 yes MAME 0.251 running but unusable (visual artifacts) yes none
MACH 128 Utility Disk mach128 1 no MAME 0.251 broken/pebkac? no / could not attach mame cartridge file /pebkac? none
Merlin 128 Macro Assembler v1.10 merlin 1 yes MAME 0.251 broken yes none
Petspeed 128 v2.2 petspeed 1 no MAME 0.251 broken yes codesheet
Super Pascal 128 v6.1 spascal 1 no MAME 0.251 OK none
Super C 128 v3.02 superc 1 yes MAME 0.251 broken yes none
Paperback Writer 128 pbw128 1 yes MAME 0.251 broken boots, but hangs at loading none
Paperback Writer 128 (Alt) pbw128a 1 yes MAME 0.251 broken boots, but hangs at loading none
Term Paper Writer tpw 1 yes MAME 0.251 OK xemag
The Great War greatwar 1 no MAME 0.251 broken can be started in Vice, but image has read errors in Vice, note game start fails often none
Sylvia Porter's Personal Finance Series - Your Personal Financial Planner 128 ypfp128 2 yes MAME0.251 broken yes none
Commodore 1570/1571 Test Demo 1570demo 1 yes MAME 0.251 OK
Commodore 1570 Test/Demo Diskette with C128 DOS Shell 1570demoa 1 yes MAME 0.251 OK
Commodore Model 1571 Test/Demo-Diskette 1571demo 1 yes MAME 0.251 OK
Commodore 1581 3.5" Disk Drive Demo/Utilities 1581demo 1 no MAME 0.251 OK Note: this will only run on the c128 prototype version with a 1581 (3.5") Drive
Commodore 128 Diagnostic Menu c128diag 1 yes MAME 0.251 OK
Commodore 1700/1750 RAM Expansion Test/Demo Disk (v1.0) 1700demo 1 yes MAME 0.251 broken (loads, but fails with device in slot) no ram expansion to test in Vice?
CP/M Version 3.0 cpm 2 yes MAME 0.251 OK
CP/M Version 3.0 (Alt) cpma 2 yes MAME 0.251 OK
CP/M Version 3.0 (Alt 2) cpmb 2 yes MAME 0.251 OK
CP/M Version 3.0 (Alt 3) cpmc 2 yes MAME 0.251 OK
CP/M Version 3.0 (1 May 1986, Ger) cpm86de 2 yes MAME 0.251 OK
CP/M Version 3.0 (28 May 1987) cpm87 2 yes MAME 0.251 OK
CP/M Version 3.0 (28 May 1987, Alt) cpm87a 2 yes MAME 0.251 OK
CP/M Version 3.0 (1581) cpm1581 1 yes MAME 0.251 broken (boot in MAME currently not possible on 3.5" media on this device) yes
CP/M 3 Version 3.0 cpmplus3 1 yes MAME 0.251 broken yes (disk has to be writable)
CP/M 3 - BDOS 3.0 / FastBIOS 3.0 cpmfast3 1 yes MAME 0.251 broken mixed (needs to be writablw, disk has write errors, but still seems to work ok)
LUnix Next Generation (v0.21) lunix128 1 no MAME 0.251 broken yes
LUnix Next Generation (v0.21, REU) lunix128reu 1 no MAME 0.251 broken no (bad dump?)


  • Jokes on me, I go through the full list now and will take notes here,will update the softlist data when finished.
  • Softwarelist fully checked now, who is maintainer of c128?

Ok jokes aside; I won't list everyhing here from the softwarelist that is marked as working anyway - like for example the infocom 80 column screen Text Adventures.

Generic Notes

As someone else pointed out to me, the main work is being done on the C64 Device, so you will notice in comparison that the C64 in MAME is already quite cycle correct even for demos and other hardware intensive use cases.

Many Games/Demos/Intros will flicker and show visual artifacts when run on the MAME c128 device, while they will run nearly flawless like on the original with the MAME C64 emulation.

Tools

Nibtools (Tool to comvert between several relevant c64/c128 disk formats

Some Debugging Tipps

I found it uswful to be able to have a channel from the device to the outside world of the host's filesystem. Thankfully some helpful people helped me to get a useful commandline set and configuration that enables a stable echange from the emulated device (c128* an also works with c64*) to the emulating host.

mame.exe c128dp -w -user rs232 -user:rs232:rs232 printer -printout out128.txt

Additionally you have to set the rs232 settings in the mame user interface (enable ui mode -> <tab> -> Machine Configuration)

RS232 recommended settings for debug output
RS232 recommended settings for debug output

The following BASIC snippet shows how you can print some data from the device to the file out128.txt (remember that the c128 does not use ascii encoding! so you will have to transalate the data later [some python snippet will follow later] )

OPEN5,2,1,CHR$(8)
FORI=0TO12:PRINT#5,CHR$(I);:NEXT:PRINT#5
CLOSE5

This snippet will print a 13 Byte long file which should contain the following Bytes:

 hexdump -C out128.txt
00000000  00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d        |..............|
0000000e

I noticed some strange translation behavior while using the serial IO, so please refer to C64 Programmers Reference Chapter 06 Input Output Guide for furtther information.

Current findings (testing on MAME 0.251)

Timing issue PAL vs NTSC

Bug report on Mametesters Bug Report

The discrepancies are best shown with starting a pal device c128dp or c128p, so if you start up with a rs232 Interface connected to output into a file ans set to 1200 baud 8n1 in Machine configuration Menu:

mame c128dp -w -user rs232 -user:rs232:rs232 printer -printout out128_bugged.txt

and run a basic output loop to the rs232 (same results in c64 as in c128 mode):

OPEN5,2,0,CHR$(8)
FORI=0TO255:PRINT#5,CHR$(I);:NEXT
CLOSE5

this will result to a bugged output of

hexdump -C out128_bugged.txt
00000000  00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f  |................|
00000010  10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f  |................|
00000020  60 61 62 63 64 65 66 67  68 69 6a 6b 6c 6d 6e 6f  |.abcdefghijklmno|
00000030  70 71 72 73 74 75 76 77  78 79 7a 7b 7c 7d 7e 7f  |pqrstuvwxyz{|}~.|
00000040  80 81 82 83 84 85 86 87  88 89 8a 8b 8c 8d 8e 8f  |................|
00000050  90 91 92 93 94 95 96 97  98 99 9a 9b 9c 9d 9e 9f  |................|
00000060  e0 e1 e2 e3 e4 e5 e6 e7  e8 e9 ea eb ec ed ee ef  |................|
00000070  f0 f1 f2 f3 f4 f5 f6 f7  f8 f9 fa fb fc fd fe ff  |................|
00000080  00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f  |................|
00000090  10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f  |................|
000000a0  60 61 62 63 64 65 66 67  68 69 6a 6b 6c 6d 6e 6f  |.abcdefghijklmno|
000000b0  70 71 72 73 74 75 76 77  78 79 7a 7b 7c 7d 7e 7f  |pqrstuvwxyz{|}~.|
000000c0  80 81 82 83 84 85 86 87  88 89 8a 8b 8c 8d 8e 8f  |................|
000000d0  90 91 92 93 94 95 96 97  98 99 9a 9b 9c 9d 9e 9f  |................|
000000e0  e0 e1 e2 e3 e4 e5 e6 e7  e8 e9 ea eb ec ed ee ef  |................|
000000f0  f0 f1 f2 f3 f4 f5 f6 f7  f8 f9 fa fb fc fd fe ff  |................|

now if you compare the same script running on an NTSC device like c128d or c128 you get the expected output for this loop:

mame c128d -w -user rs232 -user:rs232:rs232 printer -printout out128_correct.txt

results in

hexdump -C out128_correct.txt
00000000  00 01 02 03 04 05 06 07  08 09 0a 0b 0c 0d 0e 0f  |................|
00000010  10 11 12 13 14 15 16 17  18 19 1a 1b 1c 1d 1e 1f  |................|
00000020  20 21 22 23 24 25 26 27  28 29 2a 2b 2c 2d 2e 2f  | !.#$%&'()*+,-./|
00000030  30 31 00 33 34 35 36 37  38 39 3a 3b 3c 3d 3e 3f  |01.3456789:;<=>?|
00000040  40 41 42 43 44 45 46 47  48 49 4a 4b 4c 4d 4e 4f  |@ABCDEFGHIJKLMNO|
00000050  50 51 52 53 54 55 56 57  58 59 5a 5b 5c 5d 5e 5f  |PQRSTUVWXYZ[\]^_|
00000060  60 61 62 63 64 65 66 67  68 69 6a 6b 6c 6d 6e 6f  |.abcdefghijklmno|
00000070  70 71 72 73 74 75 76 77  78 79 7a 7b 7c 7d 7e 7f  |pqrstuvwxyz{|}~.|
00000080  80 81 82 83 84 85 86 87  88 89 8a 8b 8c 8d 8e 8f  |................|
00000090  90 91 92 93 94 95 96 97  98 99 9a 9b 9c 9d 9e 9f  |................|
000000a0  a0 a1 a2 a3 a4 a5 a6 a7  a8 a9 aa ab ac ad ae af  |................|
000000b0  b0 b1 b2 b3 b4 b5 b6 b7  b8 b9 ba bb bc bd be bf  |................|
000000c0  c0 c1 c2 c3 c4 c5 c6 c7  c8 c9 ff cb cc cd ce cf  |................|
000000d0  d0 d1 d2 d3 d4 d5 d6 d7  d8 d9 da db dc dd de df  |................|
000000e0  e0 e1 e2 e3 e4 e5 e6 e7  e8 e9 ea eb ec ed ee ef  |................|
000000f0  f0 f1 f2 f3 f4 f5 f6 f7  f8 f9 fa fb fc fd fe ff  |................|

Documentation

Archive Link to History of Commodore 128 Page

C128 Assembly Language Programming (Archive)

Petspeed 128 Manual

C128 Programming Reference

Service Manuals

a big collection of manuals c64 and c128 related

Commodore 128 CPM Mode Kapitel 7 - Deutsche Ausgabe

C64 Programmers Reference Chapter 06 Input Output Guide

References

C128 on old-computers.com

c128 on oldcomputers.net

128d on C64-wiki.com

Bil Herd's Homepage about his creation