Friday, January 6, 2023

Coleco Telstar Arcade Repair




The Telstar Arcade was a cartridge based video game console released by Coleco in 1977. Unlike later cartridge based systems the cartridges for this system didn't just contain program code, but instead used the MOS Technology MPS-7600-00x chip series which contained a simple CPU, code ROM and some custom hardware for generating video that may have been different in each cartridge. You can find a good article here about this chip:

http://oldvcr.blogspot.com/2022/09/confirmed-mos-76007601-pong-chip-is.html

I acquired one of these systems a long time ago but never bothered to try it out. I recently dug it out and tried powering it up. I could not find the power supply for it which is 9VDC 200ma, so instead I used an Atari 2600 power supply which if 9VDC 400ma and has the same connector and polarity. 

I connected it to a TV and when I powered it up I got no change in the display. Even if a video game system has major problems you will usually see some change in the screen. I disassembled the unit and checked the connections between the boards and everything looked ok. The next step was to check the power. 

The power from AC adapters enters the main board on pins 10 and 11 of connect J3. That is the left side of the connector in this picture.


With the power switch off I can see the 9VDC at this connector and it also makes it to the switch. When I turned the switch on the input power dropped so something was pulling it down. Before I continued troubleshooting I traced out the circuit for the power regulator on the main board:

This is a simple voltage regulator based on a Zener diode, CR3. Here is a picture of that part of the board. The leg on the transistor is lifted because I took this picture when I was testing something. 


With the circuit mapped out I check the components with an ohm meter but nothing looked obviously bad. I tried lifting the emitter leg of the transistor to see if that helped but I was still not getting anything out of it. I ordered some replacement transistors and replaced the one on the board with one of those. When I powered it up I still wasn't getting any output from the transistor, and then I started seeing smoke from the component side of the board. Took me a bit to find the burning component, but it turned out to be the CR3 Zener diode and this also burned out the new transistor. 

Now I had a problem. The diode was burned so bad that I could not read the whole part number, all I could see was 1N75 which told me it was a Zener diode but the last two digits tell you it's operating voltage. I also could not find schematics for the system, so I have no way of knowing what voltage the Zener is. 

I happened to have some surplus 1N75 series diodes so I put in a 1N7532 which is a 5.6v Zener and replaced the transistor one more time. With those changes I finally got a 4.4V output from the transistor. This is as far as I have taken the troubleshooting for now. I would like to figure out what the proper diode is. If you are reading this and have access to one of these I need to either know the full part numbers on CR3, or need a measurement of the voltage between the two points shown below.






Sunday, December 18, 2022

1541 Drive Repair - Part 2




In my last post I began the process of repairing a Commodore 1541 disk drive. In that post I got the power on self test to pass but the drive would have some other problems that needed to be resolved. 

To continue the troubleshooting process I decided to write a test program using my IF65 in-circuit emulator. There are other ways I could have tested the drive, but I choose this options for two reason. First, I used the IF65 to do this sort of testing at my first electronics job, so there was some nostalgia for doing it this way. Second, this would give me a tool I could use to quickly troubleshoot other drives. 

The IF65 allows the 6502 code to communicate with a terminal so this made it easy to build a interactive test program. Here is a look at the menu for the test program. 


The first test was pretty simple, by pressing 'O' of 'F' on the terminal keyboard it would turn the activity LED on and off with a simple write to one of the 6522 VIAs. The motor test worked the same way to turn the spindle motor on and off. The write protect test continuously displayed the state of the write protect sensor. The last of the first batch of tests I wrote was the head test which allowed me to move the read/write head in and out. 

On the unit under test all of these tests passed except the head test, it was unable to move the head in either direction. I carefully checked the signals in the stepper drive circuit and everything looked ok, so I tried turning the motor manually and it would not move. I finally used a pair of pliers to grab the motor shaft and I able to break it loose. 

Next thing I had to deal with was a minor mechanical problem. The spring for the drive door latch was missing. I didn't have anything that was an exact fit, but I found a spring that was close and cut it shorter to fit. Initially the spring kept popping out so I had the bend the ends in a little to make a tighter fit on the pegs on either end. 


With the basic functions of the drive tested and repaired, next thing was to check the speed. The drive is designed with a very clever way to do this without needing any test software. If you look at the bottom of the drive mechanism you will see this checkboard pattern on the bottom of the spindle motor. When viewed under fluorescent lights it can be used to adjust the drive speed. Fluorescent lights strobe at whatever the AC line frequency is, so there are two tracks on that pattern, one for 60hz as found in the US and the other for 50hz found in other countries. When the speed is correct the marks on the appropriate track will appear to remain stationary. If it's running to fast or slow the pattern will slowly drift in one direction of the other. On the drive PCB there is a potentiometer that is used to adjust the speed. You turn the potentiometer until the pattern stops moving. 


With the speed adjusted I was able to boot a diagnostic disk. I used that disk to double check the speed, and finally do the head alignment. 






Monday, October 31, 2022

Commodore 1541 Drive Repair Part 1




I recently attended a repair workshop at the System Source Computer Museum in Hunt Valley Maryland. This was my first time attending one of these events so I didn't bring anything with me to work on, I figured I might find someone else that needed help, which is exactly what happened. I met someone who had brought a bunch of Commodore 1541 drives and was hoping to find someone who could help repair them. Even though I had never worked on  a 1541 drive I knew they were 6502 based to I thought I would take a crack at it. 

Most of the drives would not even get through their power on self test, indicated by the activity LED flashing. One started to emit a burning smell when we powered it up, so we put that one aside. Another would not power up at all. We swapped chips on a few but didn't make any progress that way. There was one that powered up properly but as we were trying to do further testing with it connected to a C64, the computer failed. So, we didn't make much progress there but I took one of the drives home to work on.

Before I could dig into the drive I needed some documentation. I found this site which has a good collection of schematics for various versions of the drive:

http://www.zimmers.net/anonftp/pub/cbm/schematics/drives/new/1541/index.html

I also found a couple good books on Archive.org:

Commodore 1541 Troubleshooting and Repair Guide

The Anatomy of the 1541 Disk Drive

The first thing I noticed was the C21 tantalum capacitor had burned up. This cap is between the +12V supply and ground so was probably acting as a filter cap. The +12V supply still looked good with the cap burned out so I continued to work on the drive until I was able to get a replacement. 


The next step was to troubleshoot the power on self test problem. In a previous post I talked about the IF65 in-circuit emulator that I used at a previous job. Troubleshooting this sort of failure was a perfect application for this device. I started by connecting it to a known good drive to make sure everything worked ok. 


With the IF65 setup verified I re-connected it to the unit under test. I started by testing the ROM on the bad unit, and that seemed to be ok. Next I ran a RAM test and immediately saw a failure across the whole RAM address range. The errors were pretty random so it didn't look like just a bad data or address line. Next I turned to the IF65's address trap functionality and checked out the chip enable lines which looked good. The addresses lines also looked good, but I was getting very odd signals on the data bus. 

The RAM chip on my good drive was soldered in, so swapping was not an option, so I removed all the other chips on the bad unit that were connected to the data bus, but the RAM test still failed. I started to look through my surplus chips to find an equivalent RAM chip and quickly noticed the problem. The chip in the RAM socket was actually a ROM from another drive and not a RAM chip! Not sure if this happened when we were swapping chips at the repair day or happened during a previous repair attempt. I did find an equivalent RAM chip in my collection, put that one in the drive and it passed the power on self test. 

This was not the extent of the problems with this drive, I will cover more of the repair process in my next post.



Saturday, September 24, 2022

Infotron Systems IF-65

 


Back in the late 80's and early 90's I worked for Infotron Systems (later Gandalf Technologies) which manufactured data communications equipment. A lot of Infotron’s equipment was based on the 6502 microprocessor, so much so that they designed and manufactured their own 6502 in circuit emulator (ICE) the IF65. The IF65 was a great tool for both developing embedded 6502 software and for troubleshooting 6502 hardware. The IF65 was mainly used in house, but I know of at least one other company that Infotron sold them to. Fortunately, I ran across a working IF65 at a flea market a long time ago.


The built in monitor software is accessed through a serial terminal. The monitor provides functions to read/write memory, test RAM, assemble and disassemble code, and access the EPROM programmer.



I worked in the repair department, initially doing manufacturing repair and then eventually customer return repairs. We used the IF65 to run special test programs and as a general troubleshooting tool for 6502 based boards. This version of the IF65 has 64K of static RAM that can be configured to overlay the product's memory in 4K blocks. You would normally set this up to overlay the ROM portion of the product's memory map. Code could then be loaded by reading it from an EPROM using the EPROM programmers, downloaded from a host computer (we used VAX mainframes at Infotron), or even entered using a built in line assembler.



A really useful feature for troubleshooting was the address trap function. If, for example, you wanted to troubleshoot the address decoding hardware you would set the trap address to the address you were trying to test and then set the switches for read, write, and/or opcode access. Now any time that address is accessed you would get a sync pulse output through the connector on the lower right side. You would hook this signal to one channel of an oscilloscope and then use the other channel to probe the circuit and you would see what a signal state was as the moment the memory access was happening. 

Another feature that comes in really handy for running test software is the ability of the 6502 code to access the serial ports on the IF65. This allows the test software to interact with the user even if the unit under test is totally non-functional. This functionality, when enabled, is accessed with the 6502 BRK instruction. The byte after the BRK command contains the command you want to execute and the Accumulator is used to pass data. For example, to print a character you would do this:

LDA #$30
BRK
.BYTE #$11






Sunday, September 4, 2022

HLL65F - INDEN/UNDEN - Mystery Solved

In my previous post I talked about some mysterious code in the macro definitions for the Atari Crystal Castles arcade game source code. Someone responded to my post about this and pointed me to Franz Lanzinger who was one of the original authors of Crystal Castles who in turn pointed me to Dave Shepperd who wrote that assembler. He confirmed that this was a custom assembler developed for Atari:

"Yes, I wrote both versions of mac65. We called it macxx way back when (because it would assemble for the 6502, 65C02, 6800, 68000, and others). The first version was written in PDP11 assembly for RT11 and it used linkm as a linker, the other tool I wrote. We used those tools for a year or so after getting the VAXen. The second and current version was written in C (first DEC C for the VAX, then subsequently others and finally gcc) and compiled on various O/S. I've only been maintaining it on Linux, but it probably will still build on many others, especially those Linux like. Not sure if it would work anymore on 16 bit machines. This version uses another of my tools also written in C: LLF (Link+Locate+Format) as the linker."

He also provided an explanation of how he believes the two mystery lines worked:

.LIST SRC(...S1,1)

The .LIST pseudo op controls what get's output to the listing file. The SRC flag says to turn on the output of the assembler source code and the values in parenthesis after it control the details of the output. The first parameter tells the assembler which columns to start outputting the source on. The second value, if present and not zero, tells the assembler to wait until the next line before changing the output column instead of doing it on the current line.

.PRINT ..NST$(37,1,16,1,38'->')

The .PRINT pseudo op prints text to the listing file. The expression after .PRINT is evaluated and the result it what will be printed. Again, we have a list of parameters to control this output. This is a pretty esoteric command so I am not sure if I would have every figured this out:

37 = Column to start the print on
1 = How many characters of the value to print out 
16 = The radix of the value, in this case it will be printed as hexadecimal
1 = If present and non-zero, print the leading zeros
38=This parameters is usually used to indicate that the sign should be output, but since it has a text string after it it functions differently. In this case the text "->" will be output starting at column 38.

Let's look at the end result of all of this. Here is a chunk of source code using two nested IF macros:

IFEQ
INX
IFEQ
LDX 40
ENDIF
DEY
ENDIF

The listing output would end up looking something like this:

                                     0->
           F004  D0 FE                      BNE .
   10      F006  E8                         INX
                                     1->
           F007  D0 FE                         BNE .
   12      F009  A6 28                         LDX 40
           F008  02                            .BYTE ...S0
                                     1<-
   14      F00B  88                         DEY
           F005  06                         .BYTE ...S0
                                     0<-





Sunday, August 7, 2022

HLL65F - INDEN/UNDEN

Notes: Since writing this post I have solved the mystery of the two cryptic lines, I wrote another post about this: 

https://dansdigitalarchaeology.blogspot.com/2022/09/hll65f-indenunden-mystery-solved.html

In my last post I introduced the HLL65 high level language 6502 macro library used in the Atari Crystal Castles source code. The macro definitions used macros called INDEN and UNDEN that I assume are for handling indentation of the code in the listing file. Exactly how these work is a little but of a mystery to me. Here is the code for INDEN:

.MACRO $INDEN
.PUSH REGSAV,...S1

.IF LT,..NST$
.ERROR ..NST$ ; STACK UNDERFLOW
..NST$ = 0
.ENDC

...S1 = ..NST$+1*3+..SRC$
.IIF GT,...S1-<9.*3+..SRC$>,...S1 = 9.*3+..SRC$
.LIST SRC(...S1,1)
.PRINT ..NST$(37,1,16,1,38'->')
..NST$ = ..NST$ + 1
.POP REGSAV,...S1
.ENDM

Like most macros is starts by saving a variable on the stack. The ..NST$ variable is used to keep track of the depth of the indent, so the next block of lines checks to be sure the code hasn't undented further then it has indented and if it did it throws an assembler error. 

When the macro library is initialized ..SRC$ is set to 41, so the next line sets ...S1 to 41 + 3 times the current number of indents. The next line checks if ...S1 is beyond 9 indents and if it is, it sets it back to the value for 9 indents. 

The next line is the first one I don't understand. According to documentation I found for a VAX assembler, .LIST is used to control what gets displayed in the listing, but the documentation does not list the argument syntax used in this code. It's possible this is displaying the current line at a specific place on the line. 

The .PRINT pseudo-op is used to write text to the listing output, but the rest of this line is quite cryptic. The string '->' makes sense as an indication of indentation, but I am not sure what the numbers before it do. I also don't understand the parenthesis right after the ..NST$ variable. 

The next line increments the indent counter and finally the value of ...S1 is restored. 

The OUTDEN macro works the exact same way as this macro, but it just reduces the indent. 

If anyone has any ideas about the two cryptic lines, let me know. 




Saturday, August 6, 2022

HLL65F.MAC

HLL65F.MAC is a standard Atari macro library that adds some high-level language constructs to the 6502 assembler. It adds IF/THEN statements, conditional loops and a few other miscellaneous helper macros. Let's start by looking at an example of a conditional:

CPX #78
IFEQ
   ADC #2
ENDIF

First, keep in mind that this is not conditional assembly, there are pseudo ops for that, this is an actual runtime conditional. This macro check if the zero flag is set and if it is the code between the IFEQ and ENDIF is executed. Let's look at how these macros are expanded. First, a macro is used to define the IFEQ macro:

    DEFIF IFEQ,BNE

DEFIF is defined with this macro:

.MACRO DEFIF .1.,.2.

.NOCROSS .1.
  .MACRO .1.
IFXX .2.
.ENDM
.ENDM

It will expand to this:

.NOCROSS IFEQ
.MACRO IFEQ
    IFXX BNE
.ENDM

.NOCROSS tells the assembler not to add this symbol to the cross reference list. The rest of the expansion is the definition of a new macro which is just the IFXX macro with "bne" as the parameter. Here is the IFXX macro:

.MACRO IFXX .1.

LOC 0
.1. .
.ENDM

This expands to:


LOC 0
bne .

The first line is another macro which we will look at next. The second line branches back to itself. Since the macro is looking for Equals, this line will branch over the code in the block if the condition is Not Equals. Until the ENDIF is assembled the assembler doesn't know what the actual branch target should be, so the branch to self is used as a placeholder. Here is the LOC macro:

.MACRO LOC type
$INDEN
.PUSH REGSAV,...P0,...S0,...P1,...S1
...P0 = .
...S0 = type
.PUSH PC,...P0,...S0
.POP REGSAV,...S1,...P1,...S0,...P0
.ENDM

and here is the expansion:

$INDEN
.PUSH REGSAV,...P0,...S0,...P1,...S1
...P0 = .
...S0 = 0
.PUSH PC,...P0,...S0
.POP REGSAV,...S1,...P1,...S0,...P0

There are two possible values for the type parameter, 0 for IF blocks and 2 I believe is for a loop block but I haven't figured that one out yet. The INDEN macro is for doing indents in the listing and doesn't impact the code that is generated, I will code this macro in another post since it is a little mysterious. The second line saves a couple variables onto the REGSAV stack. ...P1 and ...S1 aren't  used so they didn't actually have to save then. Next it puts the current program counter into ...P0 and the type into ...S0 and pushes these on the PC stack, these will be used later to end the block. Finally the original variable values are restored from the stack.

Now that the block has been started we need to look at how it ends, in this case with the ENDIF macro:

.MACRO ENDIF
THEN
.ENDM

This macro is simply composed of another macro called THEN. I haven't dug into how you would use THEN by itself. THEN looks like this:

.MACRO THEN
FND
$UNDEN
.ENDM

just like $INDEN, $UNDEN is used for indentation in the list and I will cover this in another post, so that just leaves the FND macro:

.MACRO FND
.PUSH REGSAV,...P0,...S0,...P1,...S1
...P0 = .
.POP PC,...S1,...P1
.if eq,...s1&2
    . = ...P1+1
    .IF EQ,...S1&1
        ...S0 = ...P0-...P1-2
        .IIF GT,...S0-127.,.ERROR ...S0 ; BRANCH OUT OF RANGE
        .IIF LT,...S0+128.,.ERROR ...S0 ; BRANCH OUT OF RANGE
        .BYTE ...S0
    .IFF
        .WORD ...P0
    .ENDC
     . = ...P0
 .iff
     .ERROR TYPE ;inappropriate END for structure type
  .endc
 .POP REGSAV,...S1,...P1,...S0,...P0
.ENDM

This is the workhorse of this entire macro. It is basically going to use the information on the stack to modify the BNE opcode that was assembled in the IF macro so that it will branch past the block of code if the condition wasn't met. 

 First it saves that registers on the REGSAV stack so they can be restored at the end of the macro. Next the type is popped from the stack and stored in ...S1 and the program counter is popped and stored in ...P1. Next it checks if bit 1 or the type is set, in this case it will not be since the type is 0 so the condition will be met since the conditions is "equals zero". The next line will set the current program counter to the original program counter + 1 which will point it to the offset in the BNE opcode. Next bit 0 of the type is checked and again the condition is met. Next the offset for the branch is calculated by subtracting the original program counter from the program counter as it was when the macro started and then subtracting 2 and storing the result in ...S0. The next two lines check if the branch will be out of range, and if it is shows an assembler error.   After the just check is a .BYTE pseudo op that injects the new calculated offset into the BNE opcode that was assembled in the IF part of the macro. After the inner condition the current program counter is restored to where it was at the start of the macro, and then finally the registers are restored. 

These macros are a little complex but they do provide a clever way of implementing run time conditional blocks. The use of the assembler stack in the macros allows you to next IF blocks several levels deep just like in a higher level language.