# The serial bus and the 1540/1541 drive: one shared drive repository Read with c64-python's [drive-1541.md](../../c64-python/docs/drive-1541.md) (tonight's C64 Phase 0, which reached the same conclusion first). **DSM** is the 1540/1541 Service Manual 314002-01 (Nov 1985), pinned here too. ## The VIC-20's side of the bus (PRG p. 177, SCH-E) | Line | Out | In | | --- | --- | --- | | ATN | VIA1 PA7 (through a 7406 inverter) | (not read) | | CLK | VIA2 CA2 (inverted) | VIA1 PA0 | | DATA | VIA2 CB2 (inverted) | VIA1 PA1 | | SRQ | | VIA2 CB1 | | RESET | the system reset | | Three open-collector, wired-AND lines; every device pulls low and reads the level. The VIC-20's KERNAL drives them in software (bit-banging): the VIA shift register is not used for the bus (U12 asks to confirm this by reading the KERNAL as a program). ## The drives - **1540**: the VIC-20's own drive; its DOS (325302-01 + 325303-01) is in the No-Intro set (`[BIOS] Commodore 1540 (World)`) and MAME (`c1540`). It differs from the 1541 in its DOS's serial timing (a C64 with the screen on cannot keep up with it: the reason the 1541 exists; a community account, to be checked against the two ROMs' serial routines). - **1541**: works with the VIC-20 too ("C64, VIC 20, SX64, Educator 64, Plus/4, C16", DSM spec page, as c64-python records). MAME attaches one to the VIC-20 by default (IEC device 8; its `ucd5` 6502 runs in every vic20 run: mame-oracle.md). - A 6502 at 1 MHz from its own 16 MHz crystal, two 6522 VIAs, 2K RAM, 16K ROM, GCR read/write logic, a stepper and a spindle motor (DSM). Its own clock domain. DSM places the serial VIA (UC3) at $1C00 and the read/write VIA (UC2) at $1800, the reverse of the common account: c64-python's C5. The DOS ROM is the judge by construction (it must find its VIAs), run on the drive's 6502. ## Proposal: one drive repository, `c1541-python` Agreeing with c64-python's open decision 2, and adding the VIC-20's needs: - **One board repository `c1541-python`**, rows `c1540`, `c1541` (DOS 901229-01/-02/-03/ -05/-06), later `c1541c`, `c1541ii`; pinned by c64-python and vic20-python, each of which exposes an `IecBus` socket. The drive never imports a computer. - **The socket is the three lines and RESET**, each change a timestamped event, so the two domains (computer, drive) meet only there (domains-and-speed.md). - **The 1540 row matters to the VIC-20 first**: a VIC-20 user's "real" drive; the C64 board needs only the 1541. - **Cores it needs:** 6502-python plus an **SO input** (the drive's "byte ready"; 6502- python has none: an upstream request, as c64-python also says), and `mos6522-python` (via.md, open decision 2). - **Judges:** DSM (2), the DOS ROM run (decides addresses and protocol), VICE-testprogs `drive/*` and `drive/viavarious` (tier 3 where their readmes say hardware), MAME's `:iec8:c1541:ucd5` trace (5). - **Interface with the VIC-20's gate:** with nothing on the IEC socket the VIC-20 board's gate must not move when the drive lands (the add-on rule). The shared repository should be created by whichever board reaches its IEC milestone first; its Phase 0 can start from c64-python's drive-1541.md and this page. ## High-level shortcuts (not proposed) A "virtual drive" or KERNAL traps that skip the drive change what software sees (fast loaders and protections fail): a named turbo concession if a host wants one, never the specification.