1541IDE
Build an IDE-harddisk inside your 1541!
DISCLAIMER
Copyrights
The big advantage of the above proposal is that there is relatively less soldering to do then when building a real IDE-interface. But you still need to replace the Kernal and power supply.
Another idea is developing a circuit that contains a real IDE-interface plus space for the needed extra RAM and ROM. I'm working on this idea as well but to be honest, I think I favour the above idea as being the most simplest one of the two.
The main idea anyway is to use the original Kernal as much as possible. At the point the Kernal starts to address the hardware for the original floppy disk, we have to break in and JMP/JSR to our own routines. And these new routines will all be placed in the $8000-$BFFF part. So even obsolete original routines won't be overwritten. The reason for this is compatibility; there could be software are around relying on these routines so replacing them could lead to unexpected errors.
There are three solutions:
Both the A-ports will be used to handle the datalines: port A of #1 will handle the databits D0..7, port A of #2 will handle D8..15. Port B of #1 will handle the controllines:
As you can see the original LED is still be used. The IDE-interface has its own pin to connect a LED to but this one will only light up when the HD is active and therefore cannot be used to flash codes or whatever.
The idea is to replace the original "write protect sensor " with a switch, just like the one CMD-harddisk already has. Advantage: I can keep on using the original routines handling the original write-protect sensor.
When cutting lines, makes sure the one to the SO-input of the 6502 is cut as well. Then connect this input to +5V through a 10K resistor. We don't need it right now but the resistor enables us to use it in the future.
In a PC one can connect two devices to one IDE-port. So why can't we? :)
Modern PC's have at least two IDE-ports. This is something that can be realised for our system as well by adding a 74LS139. CA2 and CB2 will steer the AB-inputlines of this 139. Outputs Y0 and Y1 steer the CS0 and CS1 line of the first port and Y2/3 steer CS0/1 of the second port.
As CMD and our Czech friends do supply an RTC with their HD-system, I'm thinking of implementing one as well. I want to use the DS12887 for four reasons:
After some weeks I found out that the task to convert the original ROM into one using the new filesystem was impossible for the moment. So I decided to split up the development in several steps:
The next step was finding the places where the registers PortA2, PortB2 and PCR2 were addressed and analysing the routines that performed the addressing. So where needed I changed the code at that place.
PortA2:
PortB2:
PCR2:
Formatting
Stepping the head
Then I bumped into a small problem. Telling to go to a specified track immediately after powering on (like with LOAD"$",8), it first checks at what track the head is above by reading the header. As the HD-sectors don't have headers, I had to emulate this feature. Default the "head" of 1541IDE is above track 18 at power-on.
What is it - the original idea
The IDE-harddisk has 16 datalines and 7 controllines. Get rid of the floppy disk of your 1541 and you'll end up with two free 6522 ports. Add the unused A-port of the other 6522 and there you'll have the needed 23 lines.
The disadvantage is that, because you control the IDE-HD by software, your data-throughput is lower then with a real IDE-interface. FYI, with this data throughput I mean the dataflow from the onboard 6502 to the IDE-HD or vica versa, not the one from/to the C64 or other IEC-computer!
What every other disadvantages you can think of, don't forget that the biggest advantage still is the huge amount of data you can store on an harddisk !!!
Parallel loaders
Using the free A-port means that we cannot use a number of parallel speedloaders using this port (Speeddos, Dolphin-DOS etc.). On the other hand there exists some excellent serial speedloaders. IMHO it is a matter of making a patch for them.
For those die-hards who insist on having a parallel loader, IMHO one could add an extra 6522 to the system by piggybacking it on top of an other. You'll need an extra 74LS139 decoder to address it.
Additional ideas
I already mentioned to add an extra 6522 for people who need the parallel port. Why not add even a second extra 6522? In this way we solve two minor problems:
Another advantage: maybe it is possible to use both the floppy drive and the harddisk together. In this way we could have a convenient way to copy the contents of a floppy directly to the harddisk!
The Kernal
Whatever system we choose, we'll need a filesystem and software to handle it. The original 16 KB won't do. So we have to replace the original ROM(s) with a 27256. When dealing with a 1541-II, one only needs to replace the original (EP)ROM and to add addressline A14. When dealing with another type of drive, some more work has to be done like using a 24 pin -> 28 pin converter, adding the missing addresslines and using A15 plus an invertor for selecting this EPROM.
Extra RAM needed ???
During the first days of writing code I run into the following problem. A harddisk sector contains 512 bytes. So I decided to place two 1541-sectors on one harddisk-sector. The problem is that, when writing data to an harddisk sector, I have to write ALL 512 bytes. So saving one sector means I first have to read the according harddisksector, then I have to replace the data of the according half and then I have to write these 512 bytes to the harddisk again. The problem is: where do I store these extra 256 bytes???
I already found out that, when using an harddisk, I must store more info then with a normal disk. Some variables used for GCR en/decoding can be used for this purpose. But the moment I want to be able to handle more then one IDE-device and/or partition, I'll surely need more RAM. So I decided to go for the extra RAM option.
The original interface
AFAIK all known versions of the 1540 and 1541 can be used. But the codes on the board for the various ICs vary from version to version. Therefore I will refer to the 6522 handling the floppy disk as #1 and the to the 6522 with free A-port and handling the IEC-bus as #2.
* PB0 : addressline A0
* PB1 : addressline A1
* PB2 : addressline A2
* PB3 : LED
* PB4 : write protect sensor
* PB5 : future use
* PB6 : IOWR
* PB7 : IORD
* CA2 : CS0
* CB2 : CS1
The interface with extra 6522's
The use of the pins is exactly as above with the exception of PB3 (the LED): in this case I will use the original PB3 to drive the LED because no alterations of the original circuit and software are needed.
A real IDE interface
I also designed and partly build a real interface based on the IDE interface I designed for the C64. The biggest advantage is that it is just a matter of placing of the PCB between the original board and and the 6502. The disadvantage is constructing the board, that is, by hand as I did. If you want to spend some money on making a real PCB, then that is a different matter. The design is made in EAGLE 4.11 and free.
The LPT interface
This idea is based on PC-Flop. PC-Flop didn't work out but the basic idea still can be used; we use an altered Kernal. The disadvantage of this idea is that you are stuck with a big PC alongside your 1541. The advantage is, at least for me, the development of software is easier. Handling large harddisks means we need another filesystem. But writing the software for it is another story. I feel that using this configuration I have more grip on the developing of the original idea. Things can be tested much more easily IMHO. And when things work out fine, I can port it to one of the other systems.
Future expansions
The 1541 has 2 KB of RAM onboard. By piggybacking some IC's you can enlarge this number. Extra RAM always comes in handy, certainly because one of my ideas is to let the HD equipped 1541 act as two or more 1541 drives. Read about it in the next section.
Hmmm, what about using CA2 and CB2 of the other 6522 as well? We could end up with 16 devices in this way :)
Those people who are unfamiliar with the DS12887, it is the Dallas-version of the Motorola MC146818, the RTC used in PC's. The main difference is that the DS1287 is an stand-alone IC; you don't need an external battery/accu or crystal anymore. Of course all SW we develop must be able to run on a system without a RTC onboard. This can be realised by first checking if a RTC is onboard and if not, letting all routines concerning the RTC return a "not valid" value.
Filesystem format
A proposal for a filesystem.
Current state
!!! Froosen !!!
I simply have to many projects. I first want to finish CBM-HD.
I finished the sources for step 1 but I am still busy with soldering the cable, so testing has to wait for the moment.
Remark: only harddisks with at least 21 sectors/track can be used.
Question remains if I'm going to use my own 16 MB layout or the one used by the CMD-harddisk (copyrights ???). Have problems understanding the last one so...
My ideas used in the steps
* track (2 bytes)
* sector
* head
* number of sectors
* pointer to area where to read from/write to
I took the liberty to use the zeropage locations starting at $52 as these are in use fro the GCR routines and I was pretty sure I wouldn't need these anymore.
PortA2 is only used when actually transferring data from/to the floppy. I quickly found out that these routines could not be used for the harddisk so I replaced them with new ones. So there was no need to alter the code in the original ones anymore.
The routines for stepping the head and checking for the SYNC-mark are not used anymore. So there was no need IMHO to alter the code here.
Formatting a "disk" is done by formatting track by track. The only thing I had to do is replacing the routine that takes care of formatting a track. FYI: The original routine starts at $FB0C and ends at $FD8B.
The new routine shows I was lazy: instead of formating the normal number of sectors, I formatted 21 sectors on each track. The original 1541 fills the sectors with $01 bytes. AFAIK this is a bug but I saw no reason to fill the sectors with another value.
This one costed me some sweat. The problem is that stepping the head is not one routine. It involves turning the motor on and checking how much tracks are going to be skipped. And if this number is large enough, the drive goes to fast stepping mode.
Then I reasoned that when I know the number of steps, the direction and the starting track, I could calculate the destination.
The next thing I found out was that when searching for a sector, the 1541 compares the header with the info it expects to find. Knowing this it was easy to make sure that the 1541 indeed would find it was looking for.
A bigger problem was the fact that the 1541 extracts the disk-ID from the header. I have thought about changing all the code referring to this ID but then I decided it was much easier to read the BAM first before doing anything else.
The seven bytes mentioned above are used to store the info needed to emulate "reading" the track and ID from the header.
To be continued.....