Western Digital WD1770 FDC
Floppy-disc controller chip used on B+ and Master series. Replaces the original Model B’s 8271 (which was expensive and couldn’t do double-density). The 1770/1772 family supports both FM (single-density) and MFM (double-density) at 250 or 500 kbit/s.
Not present on Electron or Model B (Model B can be upgraded with a 1770 board, replacing the 8271).
Register addresses
The 1770 has 4 registers + 1 external drive-control register:
| Register | B+ addr | Master addr | Read | Write |
|---|---|---|---|---|
| Status / Command | &FE84 | &FE28 | Status | Command |
| Track | &FE85 | &FE29 | Track | Track |
| Sector | &FE86 | &FE2A | Sector | Sector |
| Data | &FE87 | &FE2B | Data | Data |
| Drive control | &FE80 | &FE24 | — | Drive ctrl |
The drive-control register is a separate latch outside the 1770 itself. Bit layouts differ between B+ and Master.
Master drive control (&FE24)
| Bit | Field |
|---|---|
| 0 | DS0 — drive 0 select |
| 1 | DS1 — drive 1 select |
| 2 | /RESET — keep at 1; 0 holds the 1770 in reset |
| 3 | not used (jsbeeb maps nothing to it) |
| 4 | SIDE — 0 = side 0, 1 = side 1 |
| 5 | DENSITY — 0 = double density (MFM), 1 = single density (FM) |
| 6-7 | unused |
Set one of DS0/DS1 at a time. Working values, from the kit’s Master 1770 driver: &25 = drive 0, out of reset, single density (DFS discs are FM), &26 drive 1, +&10 side 1 (&35, &36) (beeb-port-kit-hardware-facts-2026-11, kit lib/qdisc.6502, lib/qdisc_init.6502 qd_cfg_drives; played on real Masters by 1942 and phX). jsbeeb main 2.22.1’s wd-fdc.js _masterRemapVal decodes the same bits: &04 reset, &01 drive 0, &02 drive 1, &10 side, &20 density.
Contradiction (corrected 2026-11-18). This table used to read bit 2 = DS2 (drive 2 select), bit 3 = RES (pulse low ≥50 µs), bit 4 = SEL, as transcribed from NAUG §16.4.2 on naug-ch16-filing. The kit’s driver (run on real Master 128s) and jsbeeb’s Master decode both put /RESET at bit 2 and nothing at bit 3. A program that writes bit 2 low thinking it deselects “drive 2” holds the controller in reset. The transcription has not been re-checked against the NAUG PDF page.
B+ drive control (&FE80)
Different bit assignment — refer to source page naug-ch16-filing §16.4.2 for the B+ layout.
Command types
Commands are written to &FE28 (or &FE84). Four families:
| Type | Commands | Purpose |
|---|---|---|
| I | Restore, Seek, Step, Step-in, Step-out | Head positioning |
| II | Read sector, Write sector | Bulk data transfer |
| III | Read address, Read track, Write track | Format / diagnostic |
| IV | Force interrupt | Abort + state-machine reset |
Type I — head positioning
| Cmd | Hex | Action |
|---|---|---|
| Restore | 0000 hvrr | Seek to track 0 |
| Seek | 0001 hvrr | Seek to track in data register |
| Step | 001u hvrr | Step one track in same direction |
| Step-in | 010u hvrr | Step toward centre |
| Step-out | 011u hvrr | Step toward edge |
Common flags:
- h (bit 3): 0 = enable motor spin-up sequence (6 index pulses ≈ 1.2 s at 300 rpm); 1 = disable spin-up (motor already running).
- v (bit 2): 1 = verify destination by reading next ID field.
- r1, r0 (bits 1-0): stepping rate.
Stepping rates differ between 1770 and 1772:
| r1 r0 | 1770 | 1772 |
|---|---|---|
| 00 | 6 ms | 6 ms |
| 01 | 12 ms | 12 ms |
| 10 | 20 ms | 2 ms |
| 11 | 30 ms | 3 ms |
u (bit 4 on Step variants): update Track register from internal counter.
Take the step rate from the machine, not a constant. The Master’s *CONFIGURE FDRIVE is CMOS byte 11, bits 1-0, and a driver that patches them straight into r1 r0 steps at 2 or 3 ms on a 1772 board. The kit’s driver clamps 2 and 3 to 01 (12 ms on both chips). 1942 stepped drive 0 at 6 ms always: right on jsbeeb and a Gotek (which takes any rate), a hang on a real drive 0 and garbage on drive 1 (1942, KC’s real Master and drive, 2026-10-11; the 1772 clamp from scarybeasts, 2026-10-16 — beeb-port-kit-hardware-facts-2026-11 §6). Ask the DFS for the current drive (OSGBPB 5) before *FX 140. jsbeeb’s Master CMOS is FDRIVE 0 (byte 11 reads &25), so only real hardware exercises the other rates.
Type II — sector R/W
| Cmd | Encoding |
|---|---|
| Read sector | 100m he00 |
| Write sector | 101m hepa0 |
- m (bit 4): 0 = single sector, 1 = multi-sector until end-of-track or Type IV abort.
- e (bit 2): 1 = head-settle delay before the command proper: 30 ms on a 1770, 15 ms on a 1772 (jsbeeb main 2.22.1
wd-fdc.js,Wd1770HeadSettleMs = 30,Wd1772HeadSettleMs = 15, commented “the datasheet figures… 30 ms reproduces the sectors a real Master 128 misses, and 15 ms doesn’t”, jsbeeb #1225). It is paid on every command with E set, motor running or not: 1942 measured a 15-30 ms settle per command on a real Master’s 1770, and background reads that paid it every sector came late. Issue the read without E (&90/&80) and settle only after a seek (1942, KC’s real Master, 2026-10-10 — beeb-port-kit-hardware-facts-2026-11 §6). The same applies to Type III: phX measured READ ADDRESS with E at 36-38 ms to the next ID on jsbeeb 2.10.2.Contradiction: NAUG as transcribed on naug-ch16-filing says “15 ms head-settle delay” with no chip distinction; that is the 1772’s figure. The 1770 in a Master settles 30 ms.
- p (bit 1, write only): 0 = enable write precompensation.
- a0 (bit 0, write only): 0 = normal data address mark, 1 = deleted.
The 1770 generates an NMI for every byte transferred — your NMI handler must read/write the data register within 32 µs (DD) or 64 µs (SD) per byte or the LD (lost data) status bit sets.
Type III — track-level
- Read address (
1100 he00): reads next 6-byte ID field (track / side / sector / sector-length / 2× CRC). - Read track (
1110 he00): dump entire track including gaps/headers — for diagnostics. - Write track (
1111 hep0): format track — full sector layout written from data stream provided by CPU.
Type IV — force interrupt
1101 i3 i2 i1 i0. Common values:
&D0— terminate current command without generating an NMI.&D4— NMI on next index pulse (i2=1).&D8— immediate NMI (i3=1).
Use &D0 to abort gracefully (e.g. canceling a multi-sector read mid-way). Immediate-NMI form (&D8) must be cleared with &D0 before issuing the next command, and you must wait ≥16 µs (SD) or ≥32 µs (DD) before the next command write.
Doubtful pairing (flagged 2026-11-18, not changed). “16 µs SD / 32 µs DD” gives single density the shorter wait, the reverse of every other FM/MFM timing on the chip (FM bytes take 64 µs, MFM 32 µs). No WD1770 datasheet is in
raw/manualsto check it against. phX waits “WD’s 16 µs” (~20 µs in its timing disc) after every FORCE INTERRUPT, FM, and loads on real Masters (phX/docs/hwtest.md“B7”, “F”).
Wait after EVERY FORCE INTERRUPT, then poll BUSY before the next command. A busy 1770 silently ignores a command written to it, including a FORCE INTERRUPT you think is harmless; the kit’s rule is “wait for the status register’s busy bit to clear before every command” (beeb-port-kit-hardware-facts-2026-11 §6; phX met the FORCE INTERRUPT case — gotchas class 6). jsbeeb’s model (_handleForceInterrupt, from tests on a real 1772): the command is aborted at once in every case; &D0 inhibits the completion INTRQ; a FORCE INTERRUPT with the motor off spins it up and enters an idle state that reports the index pulse like a Type I command; interrupt-on-index lasts only for the current command; the two ready-line conditions can never fire on a BBC (READY is tied active).
Status register bits
LDA &FE28 (or &FE84). Bit meanings depend on command type:
| Bit | Type I | Type II/III |
|---|---|---|
| 7 | MON — motor on | MON |
| 6 | WRP — write protect | WRP |
| 5 | SU — spin-up complete | RT — record type (0 = data, 1 = deleted) |
| 4 | RNF — record not found | RNF |
| 3 | CRC — CRC error | CRC |
| 2 | LD — lost data | LD |
| 1 | DRQ — index hole | DRQ — data request |
| 0 | BUSY — command in progress | BUSY |
NAUG’s rule (§16.4.3 p273): don’t poll the status register to check command completion. A read of the status register resets a pending NMI — if you poll right when a byte becomes available, you lose the NMI and the byte. Use the NMI itself as the completion signal.
But on a real Master the completion NMI can itself be lost — check BUSY in the last byte’s NMI. Measured by phX on KC’s two real Masters, 2026-11-15 (beeb-port-kit-hardware-facts-2026-11 §6; phX/docs/hwtest.md “B7”, “F”):
- On the Master’s board the NMI line is DRQ OR INTRQ, and the 6502’s NMI is edge-triggered. An INTRQ that rises while DRQ is still up makes no new edge; one taken by a byte routine that is still armed is treated as a data byte and never acknowledged (status never read, INTRQ never cleared). Either way no NMI comes again.
- A real 1770 raises READ ADDRESS’s INTRQ almost at once after the sixth ID byte; jsbeeb 2.10.2 raises it ~96 µs later (94.5 µs mean over 32 timed after the sixth DRQ). phX’s first published WIP stopped on its loading card that way on KC’s Master, Gotek and real floppy alike, while stock jsbeeb loaded it; a jsbeeb patched to raise that INTRQ 4-32 µs after the sixth byte reproduced the hang (48 µs and later loaded).
- The fix: in the sixth (last) byte’s NMI, disarm the byte routine, then look at BUSY; if the command is already over, read the status (clearing INTRQ) and take the next step there. Never wait on READ ADDRESS’s INTRQ. Put a watchdog over every step (phX: 40 idle fields → seek the track again).
- Measured end-of-command timings (FM, last byte’s DRQ to INTRQ), the jsbeeb maintainer’s Master timed by phX’s 1770 timing disc for jsbeeb 1852: READ ADDRESS 33.0 µs, READ SECTOR 168 µs, WRITE SECTOR 360 µs; jsbeeb main read 33 / 167-168 / 360-361 on the same disc (2026-11-15). jsbeeb main 2.22.1 models it as ½, 2⅝ and 5⅝ byte-times after the last DRQ, “the same in FM and MFM (#1852)”; MFM is not settled on hardware. KC’s own Master’s timing-disc result is not recorded yet (kit §12 open list).
- Disarm the byte routine between transfers. Because a SEEK or RESTORE’s completion also raises an NMI, a byte-store routine left armed stores a junk byte at its pointer. The kit’s routine’s first byte is
RTI(&40) when idle,STA zp(&85) when armed; read the status to clear INTRQ (kit §6).
Nested NMIs happen, so keep A on the stack. A late INTRQ NMI can nest inside the byte routine: phX’s routine that saved A in zero page (&A0) had it overwritten (jsbeeb with READ ADDRESS’s INTRQ forced to 20 µs died at the next part’s entry), and a nested NMI taken as a data byte stores a seventh byte past the ID’s six (phX puts the byte it lands on back). A chain handler entered straight by JMP must push A itself (kit §6, phX/CLAUDE.md Traps).
The NMI handler
The 1770 raises NMI for every byte during a sector read/write. The handler must be tight enough to service it within 32 µs (DD) ≈ 64 CPU cycles at 2 MHz.
Standard pattern (from NAUG §16.4.4 p282-283 example):
; Dialect: generic 6502 (BeebAsm-style labels). Master addresses.
; NMI handler at &0D00 (NMI vector at &FFFA points via OS to here)
PHA ; save A — only the regs you use
LDA &FE28 ; read status (or &FE84 on B+)
AND #&1F ; mask top bits
CMP #&03 ; DRQ + BUSY both = byte available
BNE exit ; not our NMI
LDA &FE2B ; read data register (or &FE87 on B+)
.save STA &2000 ; store — address self-modified
INC save+1 ; advance dest LSB
BNE exit
INC save+2 ; carry into MSB
.exit PLA
RTIThis handler keeps A on the stack (PHA/PLA), which is what survives a nested NMI (above). A measured cost for a byte routine of this kind: ~35 cycles a byte in the NMI (the kit’s qdisc: 35.4; a whole-track read 506,810 cycles, a one-track seek 12,151, jsbeeb 2.10.2, 161 reads over both sides of a patterned disc, 0 bytes wrong — kit §6).
Filing systems (DFS / ADFS) install handlers like this at NMI time and yank back ownership when finished — see paged-roms service calls &0B (NMI release) and &0C (NMI claim).
Programming sequence — read one sector
; Dialect: BBC BASIC assembler style (':' separates statements). Master addresses.
; Assumes drive 0, side 0, double-density (MFM). A DFS (FM) disc wants &25 instead.
LDA #&05 : STA &FE24 ; drive ctrl &05: DS0 (bit 0) + /RESET high (bit 2),
; side 0 (bit 4 clear), MFM (bit 5 clear)
LDA #target_track : STA &FE2B ; load track into data register
LDA #&19 : STA &FE28 ; Seek &19 = 0001 1001: h=1 (no spin-up), v=0, r=01 (12 ms)
.wait_seek
BIT seek_flag ; (set in NMI handler)
BPL wait_seek
LDA #target_track : STA &FE29 ; update Track register (Seek doesn't auto-update reliably)
LDA #target_sector : STA &FE2A ; sector register
LDA #&84 : STA &FE28 ; Read Sector &84 = 1000 0100: m=0, h=0 (spin-up), E=1
; (E costs a 30 ms settle on a 1770, every time)
; Each byte arrives via NMI; handler reads &FE2B and stores at next dest address.
; Final NMI (with BUSY clear): check status for errors. On a Master the NMI is
; DRQ OR INTRQ: look at BUSY in the last byte's NMI rather than wait for INTRQ.
; Wait for BUSY clear before every command written to &FE28.(The comments were corrected 2026-11-18: they had &19 as “h=1, v=1, r=00”, &84 as “h=1, m=0” and &05 as “DS0=1 DDEN=0”; decoded against the command encodings above and the &FE24 table.)
Densities and capacities
| Density | Bits/track | Bytes/sector | Sectors/track | Capacity per side (80-track) |
|---|---|---|---|---|
| Single (FM) | 125 kbit | 256 | 10 | 200 KB |
| Double (MFM) — DFS | 250 kbit | 256 | 18 | 400 KB |
| Double (MFM) — ADFS | 250 kbit | 256 | 16 | 320 KB |
| HD (1772 only, rarely used) | 500 kbit | 512 | 18 | 1.44 MB |
DFS = 18 sectors × 256 bytes per track. ADFS uses different sector layout (16/track, 256 bytes).
Bypass-MOS use cases
- Custom disc image formats — IBM PC discs (NAUG §16.4.4 example), CP/M, Amiga ADF copies.
- Disc repair / sector editor — read raw sectors with CRC errors and patch.
- Format checking — Type III “read track” dumps entire raw track for analysis.
- Faster sequential I/O — DFS’s per-call overhead is significant; for ROM-image work or bulk transfer, direct sector reads can be 2-3× faster.
The trade-off: you take over the NMI vector and risk crashing the machine if your handler is slow or buggy. The NMI page (&0D00) is 256 bytes (one page; the DFS’s routine is &0D00-&0D5F), room for the tight inner loop and little more. (This line said “8 KB” until 2026-11-18.)
Driving the 1770 yourself — measured (Master, 2026)
From beeb-port-kit-hardware-facts-2026-11 §6 (“Driving the 1770 yourself”), 1942 (Master 128, Sept-Oct 2026) and phX (Master 128, Nov 2026), on jsbeeb and real Masters as stated:
- When: after the boot’s last filing-system load,
*FX 140(OSBYTE 140) to detach the DFS, then claim the NMI and drive the chip with your own NMI-driven reader. No OS call follows, so the filing system’s workspace and HAZEL are yours, and loads run with interrupts on and the rupture and sound going. The cost: MMFS and any filing system but a real 1770 (1942 decision 120). See interrupts (NMI ownership), os-workspace. - A non-blocking sector reader (1942): one sector a 25 Hz tick during play, each track walked with a coprime skip, copied via a fixed staging page because the NMI’s target must not move under a ROMSEL or ACCCON write. Keep the motor spinning into a load you know is coming (a same-track seek) and the spin-up is gone: a set load held the picture 2.87 M cycles against the DFS’s 6.75 M (jsbeeb and real hardware, 2026-09-24 to 10-11).
- A loader that runs while a demo plays (phX, every window byte-exact on jsbeeb 2.10.2 and 2.21.1, loading on KC’s Master): a READ ADDRESS after each seek (jsbeeb skews each track ~3 sectors on the last, so sector 0’s position cannot be guessed); then the track in two read commands, the second started in the gap before sector 0’s ID; each next command issued from the NMI chain, because an IRQ longer than that gap costs a revolution (a 5K-cycle draw did); a warm-up seek ~40 fields before each window; a watchdog over every step; reads only behind static screens. phX’s track costs ~12.7 fields on jsbeeb 2.10.2. A double-sided
.dsdcarries side 1 on from the cylinder where side 0’s files end. - Disc NMIs delay IRQs. At 35 cycles a byte, an NMI can push an IRQ past what a stable-raster slide absorbs: phX’s field entry was 0-35 cycles late behind its loading card (0-67 over all four windows), so a line-exact part must not run while the disc loads (jsbeeb, 2026-11-15;
phX/docs/design-backbone.md). - jsbeeb versions: up to 2.3.x jsbeeb settled only after a spin-up, so no emulator saw the per-command E settle (PR #1226 modelled it); 2.10.2 settles 30 ms on every E command; main 2.22.1 reworked the 1770’s timings (#1860). See emulators.
- Put real hardware in the loop at the disc driver’s first step — 1942’s head-settle, step-rate and BREAK bugs and phX’s lost READ ADDRESS INTRQ were all real-hardware-only (gotchas class 6; phX decision 36).
See also
- filing-systems — MOS-level filing-system API (OSFILE/etc).
- naug-ch16-filing — Complete source with worked IBM-disc example.
- disc-formats — DFS / ADFS sector-level layout sitting on top of the WD1770 register interface.
- interrupts — NMI vs IRQ; NMI handler at
&0D00. - os-workspace — NMI area
&0D00-&0D5F.
This wiki is curated by Claude following the LLM-Wiki methodology — a human curates source documents, the LLM compiles structured cross-linked markdown. Content may contain errors, omissions, or stale claims. For authoritative information refer to the original source documents in the bbc-documents GitHub archive.