summaryrefslogtreecommitdiff
path: root/content/hardware/imc-2001-firmware.md
blob: 8e4aabcc166bce78a38cca87df953dc4bbcb5da8 (plain)
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
+++
title = "IMC-2001 Firmware"
+++

{{< figure src="/images/hardware/imc-2001/romboard.jpg" alt="IMC-2001 ROM card" >}}

# Intro

The ROM consists of two ROM chips. The bigger chip labelled "ROM1" was
broken (it got really hot) and could not be read (it returned all zeroes).
It has no markings on it, so one can only guess it is something AT28C256
compatible.

The ROMs sit in the special "slot 0". The board has two other
unused ROM sockets and an arrow pointing to an additional ROM socket on
the motherboard itself.

On the schematics the slot is not labelled "slot 0" but "ROM" and this
gives away it's special purpose for the machine.

# ROM 2

ROM 2 (sticker with hand-written red 2 on top) is a Mitsubishi M5L2732K,
32k-bit, 4k-ROM, seems very ok during operation (the carvings say
"M5L2732K, 83080L, JAPAN").

## lower-case patch

Comparing ROM2 to the standard Apple autostart ROM 
(https://6502disassembly.com/a2-rom/AutoF8ROM.html) we see only one difference at:

```
FD80 (F800+580)

AutoF8ROM
00000580  90 02 29 df 9d 00 02 c9  8d d0 b2 20 9c fc a9 8d  |..)........ ....|
monitor.rom:
00000580  90 02 ea ea 9d 00 02 c9  8d d0 b2 20 9c fc a9 8d  |........... ....|
```

```
fd80: 90 02                    bcc     ADDINP
fd82: 29 df                    and     #$df            ;shift to upper case
fd84: 9d 00 02     ADDINP      sta     IN,x
fd87: c9 8d                    cmp     #$8d
fd89: d0 b2                    bne     NOTCR
fd8b: 20 9c fc     CROUT1      jsr     CLREOL
fd8e: a9 8d        CROUT       lda     #$8d
fd90: d0 5b                    bne     COUT
```

*EA EA* are 2 nops where the *and #$df* is. This seems to do away with
uppercasing the byte coming from the keyboard, so that lower-case character
work.

# ROM 1

ROM 1 is hard to guess, what it originally contained (as mine got fried).

# addressing mode

I put back the original Autostart ROM, the addressing on the PCB is a little
bit weird. As the monitor was working I could write a test ROM with

```
#!/usr/bin/tcc -run -Werror

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main( int argc, char *argv[] )
{
        FILE *f = fopen( "./pattern.rom", "w" );
        char *buf = malloc( 1024 );
        for( int i = 0; i < 32; i++ ) {
                memset( buf, i, 1024 );
                fwrite( buf, 1024, 1, f );
        }
        fclose( f );
        free( buf );
        return 0;
}
```

and get the following pattern in the monitor:

```
D000 1C
D400 1D
D800 1E
DC00 1F
E000 18
E400 19
E800 1A
EC00 1B
```

So the replacement AT28C256 is arranged as follows:

```
0x6000 18 must contain the second 4k of the apple rom starting with e000 (24k)
0x7000 1c must contain the first 4k of the apple rom d000
```

So I ended up doing this:

```
dd if=/dev/zero of=zero1 bs=1 count=24576
dd if=Applesoft of=apple1 bs=1 skip=4096 count=4096
dd if=Applesoft of=apple2 bs=1 count=4096
cat zero1 apple1 apple2 > newrom1.rom
```

## Unkown difference

When I watched the series on the Apple clone from Adrian's Digital Basement
(he has a nice 3 part mini-series on the fixing of an Apple clone of unknown
origin) I noticed the following difference:

ROMS he published 'Apple\ II\ Clone\ ROM\ E0\ 300854cc.bin' which
has one single difference in the E000 ROM:

```
                   ; Convert FAC to integer.  Must be -32767 <= FAC <= 32767.
e10c: a5 9d        AYINT           lda     FAC               ;exponent of value in FAC
e10e: c9 90                        cmp     #$90              ;abs(value) < 32768?
e110: 90 09                        bcc     MI2               ;yes, okay for integer
e112: a9 fe                        lda     #<NEG32768        ;no; next few lines are supposed
e114: a0 e0                        ldy     #>NEG32768        ;to allow -32768 ($8000), but do not!
e116: 20 b2 eb                     jsr     FCOMP             ;because compared to -32768.00049
                   ; <<< BUG: A=-32768.00049:A%=A is accepted, but PRINT A,A% shows that A=-
                   ; 32768.0005 (ok), A%=32767 (wrong!) >>>
```

instead of *a0e0* it has *a0e5*

```
                   ; <<< meant to be -32768, which would be 9080000000 >>>
                   ; <<< 1 byte short, so picks up $20 from next instruction >>>
e0fe: 90 80 00 00  NEG32768        .bulk   $90,$80,$00,$00   ;-32768.00049 in floating point
```

maybe the variable got moved to *e5fe* for some reasons? hard to tell, especially
as the other ROMs have no differences. I kept mine on the original autostart ROM.

## PIN Layout

Found on https://forum.classic-computing.de/forum/index.php?thread/11666-apple-clon-gtac-fragen/&postID=401752#post457130

```
Slot Rom1 Rom2  Slot Rom1 Rom2

Pin             Pin

26   12   14-12  25     28 24
27        20,18  24
28   22          23
29               22
30               21
31               20
32               19
33               18
34               17
35               16
36               15
37               14    2
38               13    23
39               12    20
40               11    24
41               10    25 23
42                9    3   1
43                8    4   2
44                7    5   3
45                6    6   4
46                5    7   5
47                4    8   6
48                3    9   7
49                2  PIN10 8
50                 1
```

## Links

* https://forum.classic-computing.de/forum/index.php?thread/11666-apple-clon-gtac-fragen/&postID=401752#post457130