Skip to content

Archive

Category: Repair

I have repaired a fair amount of drives, and every time I find myself loading a test or a diagnostic software from disk. This is a bit of a contradiction since the drive being tested, or repaired, might not even be able to load a program. I also have a variety of tools for different purposes and wanted to have everything in one place.

 

This is why i created a 1541 Diagnostic Cartridge.


 

The challenge was to get all these tools to fit into a 8K cart. I wanted to keep the hardware simple and a 16K cart would have overwritten the Basic interpreter.

Therefor I have optimized both code and visual on the tools to keep the size down. Some tools are old, others were written from scratch and a few I rewrote in machine code instead of basic. A couple of the tools are still in Basic, but optimized.

The cartridge is an 8K ROM at $8000-$9FFF

You can also use RESTORE to return to the menu.

You may need to send a “I0:” or turn the drive off/on before running further tests if an previous error has occurred.

 

 
Update 2017.09: The Cartridge is also available at the Protovision shop.
 
Update 2015.12: Upon request from their customers, The Shareware PLUS Commodore 64 & 128 Blog asked me if they could offer the 1541 diagnostic cartridge in their product sortiment. The 1541 Diagnostic Cartridge is now available in their eBay shop.

 

 

This post spawned out of a discussion at a facebook group http://www.facebook.com/groups/retrodatorer/. Thanks to Jonny Hylander, Fredric QJ Blåholtz and Krister Andersson for ideas and suggestions.

Update 2016-07-20 : Thanks to Marty/Radwar for sending me a huge list of different kernal checksums. The diag586220+ v0.4 is able to identify a staggering 49 different kernals, for example Professional Dos, RapiDos, DolphinDos and Speeddos. Download the v0.4 sourcecode for a full list.

Update 2016-11 : KiWi at www.SX-64.de sent me a version that now works correctly on the SX-64. Scroll down for the download and sourcecode. See his page here.

Update 2017-04 : Added a standalone ROM Checksum program with diag586220+ v0.5 tables.

 


 

The diagnostic 586220 does a checksum on the kernal ROM to verify if it is ok. It will only identify the original CBM ROMs. All other (even good, for example JiffyDos) kernals will be marked as “BAD”.

The 586220 was used since i have done an reassembly/disassembly of it earlier.

Code to calculate the checksum.

Depending on $FF80(Kernel revision) the checksum is either $E0 or $E1. This determines if Kernal is marked as “OK” or “BAD” by the diagnostic test.

I remembered that the C128 diagnostic cart displays the checksum. When running the C128 diagnostic(789010) the checksum on the C64 Kernal is reported as $D4. After investigating the code, which is identical to the one above except for the fact that only $1F00 of memory is checked. This is probably a mistake since the kernal is 8K ($2000 bytes).

We shared ideas about how this would be accomplished, but also noticed that some of the different kernals generated the same checksum. This might be deliberate for them to pass a diagnostic test.

 

All code below is compatible with 64tass (i.e. Turbo Assembler compatible).

The new checksum routine. To make a distinction, the address lowbyte is xor:ed and therefor not resulting in an identical checksum.

 

 

…I made a program that can identify the kernal ROM.

 

A table is used for the checksum and a pointer(.word) to the matching ROM name. You can easily add new checksums and ROMs to the code.

 

 


 

Incorporate the checksum with Diagnostic 586220
 
The goal is to replace the original checksum routine with the code above.

As we can see in the disassembly, the routine for ROM tests are at $890E. Further investigations reveal that code between $890E and $8A44 can be replaced. This area also has the routines to check BASIC and CHARACTER ROM.

 

Checksum routine is located a few lines below $8926.

After inserting the code, you can now assemble(compile) the code with c64tass. I won’t go into details about the code itself, but it is presented and downloadable further down on the page.

 

The output file (.o64) can now be written to an eprom. Skip the two first bytes (0x00, 0x80) which is the loadingadress of the file.
 

You can also test the cart in vice by converting it to a crt. Cartconv.exe is included with the Vice emulator.

 

586220-
586220+ diagnostic, it is now possible to identify the kernal ROM.

 

 

Download package with the sourcecode for diag586220+ and original disassembly of the 586220 diagnostic. Compare these two files to see how the implementation was made.

 

Download package for diag586220+ v0.4 by Marty / Radwar. It identifies 49 different kernals.

 

Download package for diag586220+ v0.5 by KiWi / www.SX-64.de. Fixes an issue with SX-64.

 

Standalone ROM Checksum program with diag586220+ v0.5 tables

 


 

The new checksum code.

Checksums for BASIC and CHAR are also displayed.

 

 

The C128 Cartridge functionality is different than in the C64. Maximum size has been doubled to 32K and an EPROM socket (U36) has been provided inside the machine in addition to the cartridge port.

An external cartridge is referred as “External(Function ROM)” and the internal EPROM socket is referred as “Internal(Function ROM)”. This will focus on how to create an external cartridge.

A 8-bit machine can only “see” 64K at a time, and the same goes for the C128.

There are two areas in the C128 memory where cartridges can be located; the MID ($8000-$BFFF) and HIGH ($C000-FFFF). A cartridge can be started up in either these 16K areas or single 32K cartridge can be used. It is possible to have both an internal “cartridge” and an external cartridge installed, but the external has preference over the internal.

C128 memory is managed by a chip called the Memory Management Unit(MMU) and does not use the PLA(GAME/EXROM lines) like the C64.

MMU is controlled by its primary registers at $D500- and its secondary registers at $FF00-. The secondary registers are available to make it possible to switch out the I/O area at $D000-DFFF and still be able to access the MMU. This creates a memory “hole” at $FF00-$FF04 which can not be used for code.

Note that both cartridge areas (MID and HIGH) are always switched in together. If you set up a 16K cartridge in MID area and want to access Kernal routines, you will need to bank in Kernal at the HIGH space.

 

Cartridge Autostart
When a C128 is booted, a cartridge presence is checked. First it checks if GAME or EXROM lines are low. If this is the case, a C64 mode cartridge is connected and the machine starts in C64 mode. Otherwise the C128 memory is checked for an identifier(“CBM”) string at $8007 and $c007, this is done both for the external and internal slots. The banks are checked in the following order: External Mid, External High, Internal Mid and Internal High.

 

Code at $E27A- is used to verify if a cartridge is inserted:

 
 

16K Cartridge code example at $8000(MID) with Kernal ROM banked in.

 
Test the code above with WinVICE:

 



C128 16K Cartridge $8000-$BFFF (MID)
 

 
You can add another 27128 and connect RH to /OE on that chip to get 32K.

 

To create a cartridge for your C64 in the simplest form, is wiring a 8K ROM to the expansion port.

The CPU can only see a maximum of 65536 bytes. Adding a cartridge will not give you additional memory, instead it will replace memory at $8000, $A000 or $E000 depending on how ROML, ROMH, EXROM and GAME lines are being handled in the expansion port.

It is possible to bank in and out ROML/ROMH areas to gain access to different banks or RAM. This is how EasyFlash cartriges provide 1MB to the C64, it however only sees 16K of the 1MB at a time.

 

 

There are basically three types of cartridges for the C64:

8K Cartridge, $8000-$9FFF (ROML).
GAME = 1, EXROM = 0
ROML is read only. Basic ROM and Kernal ROM are available.


16K Cartridge, $8000-$9FFF / $A000-$BFFF (ROML / ROMH).
GAME = 0, EXROM = 0
ROML/ROMH are read only, Basic ROM is overwritten by ROMH.


16K Cartridge, $8000-$9FFF / $E000-$FFFF (ROML / ROMH). Ultimax mode.
GAME = 0, EXROM = 1
Ultimax mode is an emulation of the Japanese CBM machine called “MAX”. It is a predecessor of the C64 with less RAM. In Ultimax mode ROMH replaces the kernal at $E000. You do not need ROML for a cartridge to function and can be left out.

 

 

Cartridge autostart
When starting up, the CPU will load the reset vector from $FFFC/$FFFD into the program counter and continue from there. If a normal cartridge is present, it executes the kernal and checks for a cartridge identifier string.

cbm80
Kernal will look for the string “CBM80” at $8004- and will do a “JMP($8000)” if found.

If an Ultimax cartridge is inserted, the kernel is overwritten by ROMH and therefor $FFFC/$FFFD must point to your code.


8/16K Cartridge code example

 

 

Test the code above with WinVICE:

 

 

Commodore 64 Expansion port pinout:

Expansion Port

 


 

8K Cartridge $8000-$9FFF

8Kcart_8000


16K Cartridge $8000-$BFFF


16K Cartridge $8000-$BFFF (Single chip version)

16K cartrige at $8000-$bfff

A 27128 chip and a two input AND gate consisting of two diodes and a resistor. You can also use a 74LS08.


 

8K Cartridge $e000-$FFFF (Ultimax, no ROML at $8000)
You can create a 16K Ultimax cartridge by adding a 8K EPROM and connect it to ROML($8000-$9FFF).

8K cartrige at $e000 (ultimax)


 

Link(s):
Check out SukkoPera’s Open Hardware 8Kb Cartridge at: https://github.com/SukkoPera/OpenC64Cart
 


 

Update 2015.12: Corrected an error in the 16K cart schematic. EXROM/GAME should be connected and not IO2/EXROM. Text was correct but QC slipped on the drawing. Thanks to mATE for notifying me about it.
 
Update 2016.01: Updated Ultimax cart schematic with $e000-$ffff. Text was correct but again QC has slipped on the drawing. Thanks to Bart for the heads up.
 
Update 2017.12: Added single chip 16K schematic.
 


Replacing a 2364 ROM with a 2764 EPROM requires an adapter. You can use a 2364 to 27128 adapter to be able to switch between two different ROMs (ex: cbm original and a floppy speeder kernal).

 

2364 to 2764 adapter

2364to2764

 

2364 to 27128 adapter

2364 to 27128

R1 = 4.7k ohm
J1 = Switch

 



C64 (Breadbox)

Kernal: 8K 2364 ROM chip 901226-0x, where revision number is “x”. Available revisions are : 1,2 or 3(latest).
0000-1FFF = Kernal ROM (901227-03), located at $E000-$FFFF.

This is a 2364 ROM and is NOT pincompatible with a 2764. You will need an adapter to replace the ROM with an EPROM.

 



C64C (C64E, Short board)

Basic and Kernal combined on a 16K chip, U4, 251913-01.
0000-1FFF = Basic ROM (same as 901226-01), located at $A000-$BFFF
2000-3FFF = Kernal ROM (same as 901227-03), located at $E000-$FFFF
Pincompatible with a 27128 eprom.

 

Use 251913-01 ROM or combine basic and kernal yourself:

 

Custom C64-E ROM (32K, switchable between standard and dolphin dos2):

0000-1FFF = Basic ROM (same as 901226-01), located at $A000-$BFFF
2000-3FFF = Kernal ROM (same as 901227-03), located at $E000-$FFFF
4000-5FFF = Basic ROM (same as 901226-01), located at $A000-$BFFF
6000-7FFF = Dolphin DOS 2 Kernal, located at $E000-$FFFF

 


 

 

Diagnostic cartridges for the Commodore 64 / 128.

A bunch of diagnostic carts. Some of the material below is from the web and some of them are from my own collection.

C64
You will probably be fine with the C64 Dead Test (Rev 781220) and C64 Diagnostic Kit 326070-1 (Rev 586220/588220) for the C64. Use the C64 Dead Test if you got a blank(black) screen, it will flash the border according to which RAM circuit is broken.

C128
If you got a C128 with a blank(blank) screen you can use the C64 Dead Test to find faulty (low) memory. When the C64 side is working, use the C128 Diagnostics to verify the upper memory. It is also possible to rewire the high and low memory and then give the C64 Dead Test a second run. C128 Diagnostic Carts use the same harness as the C64 Rev.586220 (326070-01) but with a different keyboard adapter.

Testing in VICE
You can test the carts in vice:
C64: x64.exe -cartcrt [cartname].crt
C128: x128.exe -extfunc -extfrom [romname].bin

Additional credits:
Peter Schepers, Nicolas Welte, DLH’s Commodore Archive, SLC, Zoran

Updates:
2015-01: Added disassembly of the C-64 Diagnostic Rev 4.1.0. This was a bit tricky to disassemble(reassemble) as it crossreferences code between $8000/$1000.
2014-11: I have now included both C128 and C128D keyboard connector schematics for Rev.785260 to avoid misunderstandings. There are also some notes about the connector at position 1.4.8 in the manual.
2015-01: Added C-64 Diagnostic (Box) (324528-02). Thanks to SLC and Zoran.
2015-01: Added C-128 DCR Integral Diag 1.0 and C-128 Diag Rev.588121. Thanks to Zoran.
2015-01: Thanks to Boulderdash for the info about the C128 Serial Adapter.
2015-10: On request, I made a disassembly of the C64 Diag 781220 deadtest.
2016-11: Added Rossmöller / Roßmöller Doctor64 diagnostic. Thanks to DOC64 and Sierohpätsch.

 

Don’t miss the updated Diagnostic 586220+ with kernel detection and other fixes.

 


 

C-64 Dead Test Kit (CBM 314139-03)

dead test
Rev. 781220. Located at $E000 in memory(ultimax) and boots before kernal ROM.

Cartridge ROM: C64 Dead Test Rev 781220 Diagnostic Cartridge (314139-01)
Manual: C64 Dead Test Diagnostic Manual (314139-02)

 


 

C-64 Diagnostic Assembly Kit (CBM 326070-01)

diag-c64_586220

Rev. 586220 (c64)  and 588220 (sx64)

Located at $8000 in memory and requires a harness (some tests work without the harness).
Note: There are atleast 3 variations of the schematic on the net, two of them are missing an interconnected wire in the casetteport.

Cartridge ROM: C64 Diagnostic Rev 586220/588220 Cartridge (314061-01)
Manual: C64 Diagnostic Instruction and Troubleshooting Manual (314061-05)
Harness Schematic: C64 Diagnostic Harness Schematic (314061-02/03/04)

I disassembled the cartridge for studying purposes. It can be compiled(assembled) with 64tass.

 


 

C-64 Diagnostic Rev 4.1.0

CommodoreDiagRev410

Located at $8000- in memory and uses same harness as Rev. 586220(326070-01).

Cartridge ROM: C-64 Diagnostic Rev 4.1.0 Cartridge Image

I disassembled the cartridge for studying purposes. It can be compiled(assembled) with 64tass.

 


 

C-64 Diagnostic (Box) (CBM 324517-02)

Located at $8000- in memory and uses its own harness. See also Roßmöller Doctor64 below.
Cartridge ROM: Prog. for Diagnostic Box (324528-02)

Roßmöller Doctor64

Located at $8000- in memory and uses same harness as Diagnostic Box (324528-02).
The Roßmöller will give a false “Interrupt BAD” on C64C models. Interesting is that the Diagnostic Box (324528-02), which can be found on a Commodore spare parts list, has identical check routines as Doctor64 except for the Interrupt part.

 


 

C-128 Diagnostic Rev. 588121

Rev. 588121
Uses the same harness as the C64 Rev.586220 (326070-01).

 


 

C-128 Diagnostic Assembly Kit (314060-01)

785260_ok

Rev. 785260
Uses the same harness as the C64 Rev.586220 (326070-01).

Cartridge ROM: C128/128D Diagnostic Rev 785260 Cartridge (314061-06)
Manual: C128 Diagnostic Instruction and Troubleshooting Manual (314061-09)
C128 Diagnostic Keyboard Adapter (314061-07).
C128D Diagnostic Keyboard Adapter (314987-01).
Note: C128 Serial Port Connector has Pins 1 and 5 connected.

 


 

C-128 Diagnostic Rev. 789010

789010_ok

Rev. 789010
Uses the same harness as the C64 Rev.586220 (326070-01).

 


 

C-128 Diagnostic Rev 1.1 and 1.4 (325099-01)

C-128 Diagnostic Rev 1.x Uses its own Cart and harness.

 


 

C-128 DCR Integral Diag 1.0 (325109-01)

Cartridge ROM: C-128 DCR Integral Diag 1.0 ROM (325109-10)


 


 

A machine displaying less than 38911 free bytes or “?Out of memory error in 0” is often an indication of malfunctioning RAM. If several RAM-chips are broken, or shorted, you will be greeted with a blank(black) screen.

Free basic memory is verified when the computer boots up. It starts checking the memory from location 2049($0801) and goes upwards. If you get “3 bytes free”, it indicates a problem at address position 2049+3=2052($0804).

Even if RAM-chips are failing, it does not mean that every byte has a failing bit, this is why you need to test a larger area of memory. In the example above, 3 bytes passed the test.

Many fastload cartridges(The Final Cartridge or Action Replay etc.) skip the RAM-test to speed up the boot sequence. These will always display “38911 Basic Bytes free” regardless of RAM status.

Broken RAM is usually a sign of a bad powersupply. The components inside the PSU deteriorates and therefor delivers higher voltage than it should. RAM circuits are sensitive to overvoltage and are often the first to go.

Failed RAM can get very hot(burn-your-fingers-hot) and is easy to find, but that is not always the case. Some machines can even have broken memory that are a mix of “hot and cold” chips.

Depending on the C64 motherboard revision, you either have 2 or 8 RAM-chips. For the C128 it is 4 or  16 chips.
C64: 2 x 41464 (64kbit x 4) / 8 x 4164 (64kbit x 1)
C128: 4  x 41464 (64kbit x 4) / 16 x 4164 (64kbit x 1)

Replacing two chips is not that much of a work, but with 8 or 16 chips you want to know which one(s) are broken.

C64s with 8 memory chips also have two multiplexers; MOS7708(identical to 74257) located at U13 and U25. It is more seldom these fail but they should not be neglected.

 

There are a couple of ways finding failing RAM:


 

1. Piggybacking.
You insert a known working chip on top of a chip on the PCB. All legs must have good contact, bend the legs slightly inwards on the piggyback chip and work your way through all RAM. You can piggyback several IC;s, just make sure your equipment is powered off and that your PSU is working properly(so it won’t burn even more RAM). If the amount of free RAM changes when turning on the computer, replace that RAM-chip.

 


 

2. Calculating BITS

Each BIT on every BYTE is handled by a RAM-chip. Depending on which BIT is malfunctioning, you can determine which RAM-chip is broken.

Test every memoryposition with the byte combinations in TABLE 1. After that use TABLE 2 to determine which chip has failed. Remember that bit 0 is the rightmost and bit 7 is the leftmost bit.

The behavior of the “wrong bits” are because the broken RAM-chip either keep a data line high or low when it shouldn’t.

A couple of ways to figure out which bit is failing:

Visually check bytes on the screen
Inspect the start-up screen(or whats left of it). It is normally mostly filled with “space”-character (hex 0x20). If there are other chars than space, for example “!”-character (hex 0x21) you can determine that there is a failing RAM that handles bit 0, another example is a “%”-character (hex 0x25) indicating that bits 0 and 2 are failing in that specific memory location.

Action Replay monitor (or any other cart)
Use a machine code monitor to fill the memory and find the differing bytes.

Use basic routines POKE and PEEK
In the first example, with problems at address 2052($0804), use the following command: “POKE 2052,x : PRINT PEEK (2052)” where x is from TABLE 1. The result in and out should be the same, if not, take the differing bits and check with TABLE 2.

TABLE 1 – test bytes

binary hex dec binary hex dec
00000000 $00 000 11111111 $FF 255
00000001 $01 001 11111110 $FE 254
00000010 $02 002 11111101 $FD 253
00000100 $04 004 11111011 $FB 251
00001000 $08 008 11110111 $F7 247
00010000 $10 016 11101111 $EF 239
00100000 $20 032 11011111 $DF 223
01000000 $40 064 10111111 $BF 191
10000000 $80 128 01111111 $7F 127
10101010 $AA 170 01010101 $55 085

TABLE 2 – bits vs chips

BIT C64A,B C64B3 C64E C128,C128D C128DCR
0 U21 U10 U10 U38/U46 U38/U40
1 U9 U10 U10 U39/U47 U38/U40
2 U22 U10 U10 U40/U48 U38/U40
3 U10 U10 U10 U41/D49 U38/U40
4 U23 U9 U11 U42/U50 U39/U41
5 U11 U9 U11 U43/U51 U39/U41
6 U24 U9 U11 U44/U52 U39/U41
7 U12 U9 U11 U45/U53 U39/U41

 


 

3. Use a diagnostic program or cart
There are several diagnostic programs that test the memory for you. The Commodore diagnostic cartridges “C64 Dead Test Rev.781220” and “Diagnostic Rev.586220” are both good for this.

The “C64 Dead Test Rev.781220” cartridge is able to find broken RAM even with a blank(black) screen. It flashes the screen according to which bit fails. This one will save you a lot of time and work 🙂

Both cartridges are available at the Diagnostic Carts and Manuals page.
If you are interested to see how the memory is verified, there is also a disassembly of the Diagnostic Rev.586220 cartridge.