-
Notifications
You must be signed in to change notification settings - Fork 0
/
apple-power-lang.html
343 lines (297 loc) · 19 KB
/
apple-power-lang.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>fritzm.github.io - Apple II Plus: power supply and language card</title>
<meta name="description" content="">
<meta name="author" content="Fritz Mueller">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="https://fritzm.github.io/theme/html5.js"></script>
<![endif]-->
<!-- Le styles -->
<link href="https://fritzm.github.io/theme/bootstrap.min.css" rel="stylesheet">
<link href="https://fritzm.github.io/theme/bootstrap.min.responsive.css" rel="stylesheet">
<link href="https://fritzm.github.io/theme/local.css" rel="stylesheet">
<link href="https://fritzm.github.io/theme/pygments.css" rel="stylesheet">
<!-- Photoswipe -->
<link rel="stylesheet" href="https://fritzm.github.io/theme/photoswipe.css">
<link rel="stylesheet" href="https://fritzm.github.io/theme/default-skin/default-skin.css">
<script src="https://fritzm.github.io/theme/photoswipe.min.js"></script>
<script src="https://fritzm.github.io/theme/photoswipe-ui-default.min.js"></script>
<script src="https://fritzm.github.io/galleries.js"></script>
<script type="text/javascript">
var pswipe = function(gname, index) {
var pswpElement = document.querySelectorAll('.pswp')[0];
var items = galleries[gname];
var options = { index: index };
var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();
};
</script>
<!-- So Firefox can bookmark->"abo this site" -->
<link href="https://fritzm.github.io/feeds/all.rss.xml" rel="alternate" title="fritzm.github.io" type="application/rss+xml">
</head>
<body>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="https://fritzm.github.io">fritzm.github.io</a>
<div class="nav-collapse">
<ul class="nav">
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="content">
<div class="row">
<div class="span9">
<div class='article'>
<div class="content-title">
<h1>Apple II Plus: power supply and language card</h1>
Mon 21 March 2022
by <a class="url fn" href="https://fritzm.github.io/author/fritz-mueller.html">Fritz Mueller</a>
</div>
<div><p>Okay, so the Apple II Plus I was using to test the VM4209 monitor worked fine for about a half hour, then
smoked a RIFA cap in its power supply. These are a very common known failure in various old microcomputer
power supplies, and I really should have already caught this on inspection and shotgunned it. Boy, do they
generate a lot of smoke and stink when they go...</p>
<p>Electrolytics in here are also all pushing 40 years at this point and Astec opted for only 85C parts for many
of these, so I went ahead and ordered a <a href="https://console5.com/store/apple-2-power-supply-cap-kit-p-n-605-5703-astec-aa11040b-aa11040-b.html">whole replacement
kit</a> from
Console5. I replaced the front end filters and anything on the back end that was 85C or looked even slightly
bulgy, which ended up being most of them:</p>
<p><img src='/images/micros/apple-ii-rifa_thumbnail_tall.jpeg' title='Blown RIFA capacitor from Apple II Plus power supply' onclick='pswipe("micros",5);'/>
<img src='/images/micros/apple-ii-pwr-before_thumbnail_tall.jpeg' title='Apple II Plus power supply before cap replacements' onclick='pswipe("micros",6);'/>
<img src='/images/micros/apple-ii-pwr-after_thumbnail_tall.jpeg' title='Apple II Plus power supply after cap replacements' onclick='pswipe("micros",7);'/></p>
<p>Put it all back together and back in business, except noticed an additional problem: DOS 3.3 booted but
neither recognized nor loaded the "language card" (soft ROM) present in the machine. Since my machine has
Applesoft BASIC in system ROM, this meant no Integer BASIC (and no ROM mini-assembler) for me until this was
fixed.</p>
<p>For those who might not be familiar with the Apple II language card, it provides several features. An Apple
II or II Plus can have at most 48K of RAM on the system board. The overall memory map looks like this:</p>
<style>
.memmap {
font-family: monospace;
width: 30em;
margin-left: auto;
margin-right: auto;
margin-top: 1rem;
margin-bottom: 2rem;
border-collapse: true;
}
.memmap td {
border: 1px solid black;
padding: .5em;
text-align: center;
}
</style>
<table class="memmap">
<tr><td>$0000-$BFFF</td><td>RAM (48K)</td></tr>
<tr><td>$C000-$CFFF</td><td>IO space (4K)</td></tr>
<tr><td>$D000-$FFFF</td><td>ROM (12K)</td></tr>
</table>
<p>The first thing the language card provides is a 2K ROM which by default overlays whatever ROM is in the system
board socket for addresses <code>$F800</code> to <code>$FFFF</code>. This ROM holds the 6502 reset vector and the boot monitor; the
version provided on the language card has an "autostart" capability that will search for and boot off an
attached Disk II floppy. I am not sure why Apple provided this ROM on the language card since the same ROM
could be upgraded directly on the fully-socketed system board, and indeed everything after the Apple II Plus
came with this autostart ROM pre-installed. Possibly this was done for maximum backward compatibility with
Apple's previously-offered "Firmware Card", which also contained this ROM? Third-parties would later offer
clones of the language card that did <em>not</em> contain the additional/redundant F8 ROM, and nobody seems to have
particularly cared or noticed...</p>
<p>The second thing the language card provides is an additional 16K of RAM. This can be loaded, then
write-protected and mapped over the entire ROM space of the machine from <code>$D000</code> to <code>$FFFF</code>, providing a "soft
ROM" capability. Since the available ROM address space is only 12K, the leftover 4K or RAM on the language
card is bank switchable at address range <code>$D000</code> to <code>$DFFF</code>.</p>
<p>Advanced software which doesn't depend on the system ROMs at all can also map the RAM over the system ROM
address space and leave it in read/write mode, thus gaining access to a full 64K of RAM (with the caveat of
the switched bank at <code>$D000</code>.)</p>
<p>The language card programming interface presents as follows:</p>
<p><br><img style="display:block; margin-left:auto; margin-right:auto" src="/images/micros/apple-ii-lang-controls.png" title="Apple II language card control codes"/><br></p>
<p>My goal is to be able to run the initial (1980) release of Apple DOS 3.3. This version loads up the language
card at boot in soft ROM mode with Integer BASIC and an older version of the F8 monitor ROM, which contains a
few extra niceties like a built in mini-assembler and primitive step/trace capabilities. A system so loaded
can then be conveniently switched back and forth between BASIC and monitor versions with the DOS "INT" and
"FP" commands. But detection of my language card seemed to be failing, so it was never loaded up at boot.
Attempts to manually load and activate it also came to naught.</p>
<p>So, time to dig in and see what's going wrong... DOS 3.3 does initial checks and setup of the language card
via a small machine language program, loaded into RAM at boot by the DOS master disk's <code>HELLO</code> BASIC program.
Machine code is used for this part rather than BASIC so the probe/setup code can be placed and run from RAM
outside the mapping range of the language card (the BASIC interpreter itself running from ROM addresses
<em>within</em> this mapping range). Here is the machine language program, after being <code>POKE</code>d into RAM by <code>HELLO</code>,
listed via the ROM monitor:</p>
<div style="text-align: center"><img style="display:inline-block" src="/images/micros/dos33-hello-1.jpeg"
title="DOS 3.3 language probe, part 1/2"/> <img style="display:inline-block"
src="/images/micros/dos33-hello-2.jpeg" title="DOS 3.3 language probe, part 2/2"/></div>
<p>I interpret the actions of this code as follows:</p>
<ul>
<li>
<p>The code first retrieves and stashes the contents of location <code>$E000</code>, within the mappable address range. A
read of <code>$C081</code> then maps the ROMs on the system board (see programming interface above), and the contents
of <code>$E000</code> are checked again. If the contents now differ, the code assumes the card, now in mapped ROM
mode, was previously in mapped RAM mode, and it jumps to address <code>$0332</code> to put things back the way it found
them and bail out.</p>
</li>
<li>
<p>If not, the code reads from address <code>$C083</code> twice, which puts the card, if present, in writable mapped RAM
mode. Two different values are written to and compared back from location <code>$D000</code>. If a language card is
<em>not</em> present, this location will still be mapped to ROM on the system board, and at least one of these
compares will fail; if either one does, the code jumps to <code>$0332</code> to bail out.</p>
</li>
<li>
<p>Otherwise, we've verified that a card is present and wasn't already in active play. The program now reads
from address <code>$C081</code> twice to move back to mapped ROM mode, but leaving RAM writable to be loaded by the
remainder of the <code>HELLO</code> program after return (in this mode, reads will come from system ROMs, but writes
will go to the corresponding locations in language card RAM). A success return code is loaded, and the code
jumps forward to the exit code at <code>$0334</code> to return to the caller.</p>
</li>
<li>
<p>The bail out routine at <code>$0332</code> just sets up a fail return code, then falls through to <code>$0334</code>. Code here
stores the return code to the return code location and does one last compare between the stashed and current
values at <code>$E000</code> to determine if mapped RAM mode must be restored; if so this is done via a read from
location <code>$C080</code> (RAM is left write-protected). Control is then returned to BASIC.</p>
</li>
</ul>
<p>In any case, the above is what the code <em>does</em>, even if I may have misinterpreted some of its motivations. On
my system, the ROM on the language card seemed to be working correctly (monitor ran fine, but if ROM on
language card was pulled the machine failed to boot, indicating the monitor was in fact running successfully
out of ROM on the card). However, mapped RAM mode seemed never to engage. The machine code snippet above
returned "00" without crashing, and the DOS <code>HELLO</code> program assumed no card present. Manually accessing the
appropriate control registers also had no effect.</p>
<p>The language card design does not seem to be documented in detail, but a schematic is available and it is not
too hard to suss out. The first thing to check would seem to be the register interface. Here is an excerpt
from the schematic, with a couple of annotations added:</p>
<p><br><img style="display:block; margin-left:auto; margin-right:auto" src="/images/micros/apple-ii-lang-schem.png" title="Apple II language card schematic excerpt"/><br></p>
<p>The register interface is principally implemented by a 74LS175 quad flip-flop at D4. These flip-flops share a
common reset at power-on, and a common clock based on the expansion slot DEV_L signal; DEV_L is a
slot-specific signal strobed by the system on any bus cycles to IO address space allocated to that slot.
Examination of the programming interface along with address line decodes feeding the D inputs here leads to
the conclusion that the top-most flip-flop holds RAM/ROM mapping mode, the next one down is RAM bank select,
the next is RAM write-enable, and the last is a one-bit count to support write-enable after only two
successive reads.</p>
<p>Put a chipclip on at D4, and observed behavior of the flip-flops on the logic analyzer while exercising the
control registers via the monitor. Problems were apparent right away: while the bank select and count
flip-flops were responding as expected, the mapping mode and wite-enable flip-flops were not. The shared
reset and clock appeared correct, and all flip-flops themselves were responding logically correctly with
respect to their inputs. The issue was apparently with the incoming D lines to two of the flip-flops.
Starting with the ROM/RAM enable flip-flop, then, that D line is fed via C3 and C4. And a visual inspection
in preparation for clipping these up for the analyzer revealed that, surprisingly, these two chips had
actually been reversed on the board!</p>
<p>The language card is fully socketed, so presumeably this reversal had occured during previous troubleshooting
or service by the former owner? In any case, it was easy to swap the chips back to their correct locations,
and the logic analyzer showed that the entire register interface seemed to be behaving according to design
after that. DOS 3.3 now recognized the card at boot (yay!), but the system would crash after loading and
mapping the RAM. So, maybe a bad RAM chip as well?</p>
<p>To troubleshoot the RAM, I followed a technique described in <a href="https://www.youtube.com/watch?v=wVUWaodwNNI&t=1309s">this
video</a> on the "Adrian's Digital Basement" YouTube
channel. Basically, a couple short machine language programs, entered and executed via the monitor, to copy
ROM contents into the language card RAM, then copy back out to another location in system RAM. This allows a
comparison of source data in ROM and round-tripped data in system RAM; a mismatch indicates a RAM problem on
the card. Here are the two programs I used and, and dumps of the resulting data:</p>
<div style="text-align: center">
<img style="display:inline-block" src="/images/micros/apple-ii-copy-in.jpeg" title="Copy ROM to language card RAM"/>
<img style="display:inline-block" src="/images/micros/apple-ii-copy-out.jpeg" title="Copy language card RAM to system RAM"/>
<img style="display:inline-block" src="/images/micros/apple-ii-data-comp.jpeg" title="ROM data vs round-trip language card data"/>
</div>
<p>And sure enough, it's quite visible here that bit 7 is having problems. Swapped out the 4116 at A2, and
that seems to have done it for this one. Now I need to go find a copy of Choplifter...</p>
<p><img src='/images/micros/apple-ii-lang-card_thumbnail_tall.jpeg' title='Apple II Plus language card repairs: yellow indicates two chips that were found swapped on the card; red indicates a failed 4116 RAM chip that was replaced.' onclick='pswipe("micros",8);'/>
<img src='/images/micros/apple-ii-repaired_thumbnail_tall.jpeg' title='Apple II Plus: Successful DOS 3.3 boot after language card repairs' onclick='pswipe("micros",9);'/></p></div>
<hr>
</div>
</div>
<div class="span3">
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Site
</li>
<li><a href="https://fritzm.github.io/archives.html">Archives</a>
<li><a href="https://fritzm.github.io/tags.html">Tags</a>
<li><a href="https://fritzm.github.io/feeds/all.rss.xml" rel="alternate">RSS feed</a></li>
</ul>
</div>
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Categories
</li>
<li><a href="https://fritzm.github.io/category/arcade-games.html">Arcade Games</a></li>
<li><a href="https://fritzm.github.io/category/math.html">Math</a></li>
<li><a href="https://fritzm.github.io/category/micros.html">Micros</a></li>
<li><a href="https://fritzm.github.io/category/pdp-11.html">PDP-11</a></li>
<li><a href="https://fritzm.github.io/category/programming.html">Programming</a></li>
<li><a href="https://fritzm.github.io/category/radios.html">Radios</a></li>
</ul>
</div>
<div class="social">
<div class="well" style="padding: 8px 0; background-color: #FBFBFB;">
<ul class="nav nav-list">
<li class="nav-header">
Social
</li>
<li><a href="http://facebook.com/fritzmueller">facebook</a></li>
<li><a href="http://instagram.com/infrafritz">Instagram</a></li>
<li><a href="http://www.linkedin.com/pub/fritz-mueller/a/679/62/">LinkedIn</a></li>
<li><a href="http://jsfiddle.net/user/fritzm/fiddles/">JSFiddle</a></li>
<li><a href="https://github.com/fritzm">GitHub</a></li>
</ul>
</div>
</div>
</div>
</div> </div>
<footer>
<br />
<p><a href="https://fritzm.github.io">fritzm.github.io</a> © Fritz Mueller 2023</p>
</footer>
</div> <!-- /container -->
<!-- Photoswipe -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">
<div class="pswp__bg"></div>
<div class="pswp__scroll-wrap">
<div class="pswp__container">
<div class="pswp__item"></div>
<div class="pswp__item"></div>
<div class="pswp__item"></div>
</div>
<div class="pswp__ui pswp__ui--hidden">
<div class="pswp__top-bar">
<div class="pswp__counter"></div>
<button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
<button class="pswp__button pswp__button--share" title="Share"></button>
<button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
<button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
<div class="pswp__preloader">
<div class="pswp__preloader__icn">
<div class="pswp__preloader__cut">
<div class="pswp__preloader__donut"></div>
</div>
</div>
</div>
</div>
<div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
<div class="pswp__share-tooltip"></div>
</div>
<button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
</button>
<button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
</button>
<div class="pswp__caption">
<div class="pswp__caption__center"></div>
</div>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://fritzm.github.io/theme/bootstrap-collapse.js"></script>
</body>
</html>