KN7000 Storage & File System
KN7000 Storage & File System
The KN7000 can load and save its data on three storage media — the built-in
floppy disk drive, an SD-card slot, and a USB link to a PC — all
driven through one File Management Mode (FMM) in the firmware. The SD slot and
USB link are new versus the KN5000 (which had only the floppy drive). This
page documents the storage subsystem from kn7000_program.rom: the media, the
file types, and the file-manager function family, all recovered by name from the
reflection tables.
Storage media
| Medium | Hardware | Firmware |
|---|---|---|
| Floppy disk (FDD) | FDC IC103 (custom C1DB00000607, N82077AA-compatible) |
Disk*, Fmm*Disk*, FDCstop…; formats FAT12/FAT16 |
| SD card | SD-card slot (new) | SdCard* / Sdc* (folders, rename, delete, playlists) |
| USB | USB port (new) | Song Manager PC software over a USB cable |
The floppy formatter writes the standard Technics boot sector — the template
string Technics····NO NAME····FAT12···FAT16 sits at file 0x1BA4BB, so media
are FAT12/FAT16 and interchangeable with a PC. The on-screen prompts confirm
the model: “…work on Floppy Disk!” (0x1D8514), “…to the SD Card brings the
total…” (0x1E4C33), and “…with a USB cable. Please connect… included Song
Manager Software.” (0x1E3538 / 0x2BA8B6).
The SD-card feature set is substantial — the recovered handlers include folder
and song rename (SdcTechnicsFolderRename, SdcTechnicsSongRename,
SdcSmfSongRename, SdcCstSongRename), delete with confirm
(SdcDeleteYes/No, SdcSmfDeleteYes/No), save / overwrite dialogs
(SdcSaveYes/No, SdcOverWriteYes/No), cursor-vs-new save location
(SdcSaveCursorLoc / SdcSaveNewLoc), playlists (SdcPlistNaming), and
naming (SdcCustomFileNaming, SdcTechnicsFileNaming, FormatSdNaming).
File types
FMM handles a family of file types, each with its own load/save path; the
extensions .MID and .CST appear in a type table at 0x2637E4:
| Type | Extension | Contents |
|---|---|---|
| SMF | .MID |
Standard MIDI File (songs) |
| Custom | .CST |
registration / “custom” panel setups |
| Technics song | — | native song format |
| Composer | — | user rhythm/style (see the Composer/TCMP data) |
| Sequence | — | the on-board sequencer’s songs |
| Playlist | — | ordered play sets (FE_SeqPlaylistSetting, 0x4853F009) |
| Picture | .BMP, .JPG |
slide-show pictures (PICTURE LOAD): up to 640 × 480, files up to 0x4D800 bytes |
| Homepage | .HMP |
the HOMEPAGE layout: a 0x18C-byte settings record + a 160 × 100 BMP (17,474 bytes) |
Homepage picture (the firmware’s “Wallpaper”, FmmWallpaperLoadFunc) |
.BMP |
the homepage picture alone: 160 × 100, 2, 16 or 256 colours |
| Custom data | .AST |
the Initial Data / custom-data flash contents, zlib-compressed |
On floppy, the KN7000 wraps most of its files in a small container whose magic starts with
J (the KN6000’s starts with I). 'J KD' (.CMP, .PMT, .MSP, .SQT, .LSW) holds
one or two LZSS parts: an 8 KB ring, 3-to-10-byte matches, each reference an absolute ring
position. 'J K\1' (.AST, .CST) holds a u32 inflated size and one deflate part from the
zlib 1.0.4 the program links, and 'JK \0' (.HMP, .FAV, .MD) is stored. A .CMP is the
TCMP style memory saved whole, and each .AST inflates to one complete custom-data (IC21)
image. The byte layouts, and the six kn7000_flop disks rebuilt from typed source, are on
Floppy Disk Files and Formats.
FMM entry points are named per type: FmmSmfLoadTitleFunc /
FmmSmfSaveTitleFunc, FmmCstLSTitleFunc, FmmComposerLoadFunc,
FmmWallpaperLoadFunc, FmmPictureLoadFunc, FmmSeqSongNameFunc,
FmmPdFileNameFunc, FmmDocFileNameFunc, plus medley loaders
(FmmIntMedleyFunc, FmmSmfMedleyFunc, FmmDiskMedleySelectFunc).
File Management Mode (FMM)
Fmm* is the shared file-manager screen used across all three media. Its
functions cluster into the usual operations:
- Load / Save —
FmmLoadTitleFunc(0x4851CE31),FmmSaveTitleFunc(0x4851D280), with per-type filtersFmmLoadFilterFunc/FmmSaveFilterFunc. - Format / utility —
FmmFormatFunc(0x4851C840),FmmDiskModeFunc,FmmUtilityTitleFunc,FmmPreferenceTitleFunc; disk info viaDiskInfoFunc,DiskNameFunc. - Naming / password —
SaveFileNameFunc,SaveFileNameSmfFunc,SaveFileNameCstFunc,FmmFileNameFunc,FmmPasswordFunc(media can be password-protected).
The file-manager screen strings — - LOAD -, - SAVE -, CHECKING,
SAVE OK, %d KB free (%d%% used) — live around 0x2637E4.
The fmm file layer
Below the screens, most loads and saves go through one small file API, the fmm
calls (a few loaders, such as the custom-data record loader, open and read files through
the file-system layer directly). Each one dispatches on a drive byte at 0x5007125A through a three-entry table:
0 = floppy (the name gets A:\ in front), 1 = SD card (C:\, or the current SD
folder), 2 = a third backend that keeps its own 2 KB buffer at 0x5017317C and is
not the FAT file system (its transport is not identified). SetExtMode (0x48532346)
and ResetExtMode (0x48532355) set the byte around an SD (1) or third-backend (2)
operation; otherwise it is presumably 0 (floppy), inferred from those being its only
writers.
| call | address | what it does |
|---|---|---|
fmmopen |
0x48532390 |
open a file (name, mode such as "rb" or "wb"); one file at a time per backend |
fmmread |
0x48532463 |
read up to n bytes; stops early at end of file |
fmmseek |
0x485324BB |
seek (0 = start, 1 = current, 2 = end) |
fmmtell |
0x48532512 |
current position; after fmmseek(0, 2) it is the file size |
fmmrewind |
0x485324EA |
back to the start |
fmmclose |
0x485323BC |
close |
fmmremove |
0x485323E4 |
delete a file |
fmmerror |
0x48532368 |
the backend’s sticky error code |
The floppy and SD backends read in pieces of at most 0x7FFF bytes through the FAT
layer; whole sectors go straight into the caller’s buffer, partial ones through a
one-sector cache. On the SD card the bytes finally arrive one at a time in
SdSpiRecvBuf, from the SPI shift register 0x9805000C.
Most loaders size their read in one of two ways: they ask for the file size first
(fmmseek to the end, fmmtell, fmmrewind) and read it whole, or they read a fixed
maximum and accept a shorter file. Where each kind of file then lands in RAM — the
picture import’s 310 KB buffer, the slide-show pool, the homepage buffer in the zlib
arena — is listed on the Work RAM Map.
SD subsystem internals
Note before reading the register map: SIO channel 2
(0x34000820) is the MIDI-2 UART, not the SD link (its RX handler is a
standard MIDI parser; the hot status polling seen on SD screens is just the
engine loop’s idle MIDI pump).
The SD stack proper is a layered, DOS-like design:
- A state machine over the state byte
0x50083cd8(SD_GetState/SD_SetState), ticked bySdStateMachineTick(0x485519B7), which the engine loop calls. In state 0 it queries the MILK GUI property system —GetProperty(object 0x0210033F, property 0x60047)— and does nothing while the answer is −1. That property is the firmware’s own “SD present/enabled” source, and it is the gate the emulator must satisfy first. - Once un-gated, mount work is posted as a 16-byte command message to a
dedicated disk worker task (
0x4854ad90, created byDiskInit0x4854aced), which runs card-detect (the polled ICR of external-interrupt group0x1B, register0x3400016Cbit 4, with a software override at0x50005204), card initialisation, and the mount. - Files are reached through a virtual file system: the SD card is device
"d", mounted as drive"C:", through per-device function pointers in a RAM device table (0x500079f8) — the same VFS the floppy uses. The FAT layer sits on top; the fops funnel into a disk-worker command poster (0x4847030e, message type 3) whose read/write commands drive the physical transport below. - Success sets card-ready (
0x50083bc2 = 1) and state 3 (mounted); the SD screens’ “WAIT!” dialog is literally waiting for that state transition, and ERROR 93 (“SD lid is open”) is its failure branch.
The physical transport is a plain byte-wide SPI master, fully identified and
emulated. The 16-bit
register 0x9805000C is one full-duplex SPI shift register to the card slot; each
write clocks eight bits (MSB-first) and a handshake through the ICR of
external-interrupt group 0x1C (register 0x34000170, polled on bit 4) signals
completion. The chip-select is a GPIO latch bit — 0x36008004 bit 1, active-low.
The firmware speaks stock SD SPI (the wake-up 0xFF clocks with CS released,
then CMD0/CMD1/CMD59/CMD9/CMD16/CMD10, CRC7-framed commands, 0xFE
data tokens, CRC16 data blocks), so MAME’s generic spi_sdcard device serves it
directly. Two CRC details had to be right, and both are now in MAME’s spi_sdcard
itself. The SD data-block CRC16 uses an init value of 0x0000 (fixed upstream in
September 2026), and the CSD block carries its CRC16
(mamedev/mame#16394). With a 0xFFFF
init, every CSD read fails.
Emulation status: the card mounts, and load and save both round-trip
The SD card mounts. With a card image attached, the SPI handshake runs its
full init sequence and the mount chain reaches state 3 with card-ready set —
reaching that state reads the boot sector and FAT from the host image, so
sector reads work against a real filesystem. From the SD MENU the SD LOAD
browser is live: it reports the correct free space for the attached image
(123,552KB free for the 121 MB card image used in testing) and paints the
FOLDER / SONG columns with the FOLDER /
ALPHABET / NUMBER sort options and PREV/NEXT navigation. The SD LOAD screen is a
genuine PAGE 1/3 → 2/3 → 3/3 multi-page screen (page 1 is the file browser,
pages 2–3 are the data-type load categories: CURRENT PANEL, PANEL MEMORY,
SEQUENCER, EFFECT MEMORY, FAVORITES, ALL CUSTOM STYLE…), and the emulated PAGE
Up/Down buttons walk it correctly.
The write path works too. A SAVE→LOAD round trip completes entirely in the emulator: SD MENU → SD SAVE MENU (TECHNICS FORMAT / SD-SOUND (SMF) FORMAT) → save the current panel to a slot rewrites 154 sectors in a textbook FAT pattern, the image’s checksum changes, and loading the slot back restores the saved panel state.
The research overlay’s launcher attaches a writable card image by default. Its
run.sh copies a master card image, when one is present, to sdcard_work.img on
first use — the master is kept read-only, and the save path needs a writable file —
and passes
-harddisk sdcard_work.img. Callers can substitute their own image, or pass
-harddisk "" for an empty slot.
This default exists because of a hardware conflation of card-detect signals:
the hinged slot cover switch and the card-present line feed the same
detect input — the polled ICR of external-interrupt group 0x1B
(0x3400016C bit 4) — so the firmware cannot tell an empty slot apart from an
open lid. Both read as bit 4 = 1, and both surface as ERROR 93 (“SD lid is
open”). Consequently a card image is required to satisfy the check even with the
cover modelled closed (SDCOVER, default CLOSED); with no image the same screen
correctly shows ERROR 93 — the firmware’s own no-card branch, not an emulation
bug.
The state machine is edge-driven, so the card is inserted after boot. The SD mount is demand-driven off the debounced transition of the detect line, not its level — a line that reads “present” from power-on never edges, and nothing ever fires. The driver therefore models the slot as empty at power-on and inserts the card a few seconds after boot (an insert timer at t≈6 s), producing the 1→0 detect edge that posts the insert message and kicks off the mount. Toggling the cover switch live reproduces the same edge: closing with a card fires the mount, opening triggers removal and the ERROR 93 gate.
The physical SD path is the byte-wide SPI mailbox described above; it is separate
from the floppy’s FDC (IC103, N82077AA-compatible, memory-mapped at
0x98020000), though both share the disk-worker/VFS command layer higher up.
The FDC (IC103) is located, modelled and exercised at boot. Its interrupt (INTRQ)
reaches the CPU on IRQ2, interrupt group 0x19, not group 0x18 as first modelled;
the schematic and the firmware’s own handler registration agree.
How a sector moves (2026-10-18). DRQ drives the MN103002A’s on-chip DMA channel 0
(registers 0x32000800–0x3200080C), whose far end is the FDC’s DACK port 0x98010000.
The firmware does not let the channel finish the transfer on its own:
| step | KN6000 | KN7000 (941) |
|---|---|---|
count register (0x3200080C) |
length − 1 (0x48510DEE) |
length − 2 (0x484009BE) |
| the channel moves count + 1 bytes | the whole sector | all but the last byte |
end-of-transfer interrupt, group 0x0F |
asserts TC around one dummy DACK read (0x48512476) |
polls IRQ1 (group 0x18) for the last DRQ, moves that byte, then asserts TC (0x4840219C) |
TC is GPIO 0x36008004 bit 4, active low, driven by the firmware. Mainline MAME
(mamedev/mame#16394) moves count + 2 bytes and
pulses TC from the channel: that suits the KN7000 by coincidence (its SP7001 setup reads
BASEEXT.XAP off a floppy) but writes one byte past every KN6000 sector buffer, which
corrupted the KN6000 file system’s memory pool. The project’s overlay driver models the table
above and both firmwares read floppies with it.
How an inserted disk is noticed. The drive’s INDEX line reaches the CPU on IRQ7, group
0x1E (schematic net HDD.INDEX → pin 48). A disk-presence check (KN7000 0x484025DD, KN6000
0x485128A3) reads DSKCHG from the FDC’s DIR register: clear means a disk is present; set
means present only if an INDEX interrupt arrived in the last 0x6E ticks of the 2 ms time
base (220 ms, one revolution at 300 rpm plus a margin). A disk inserted while the instrument
runs keeps DSKCHG set until the next seek, so without the INDEX interrupt the firmware never
sees it, and never posts its disk-in event 0x10708000 (which the DEMONSTRATION screen’s
FEATURE.PRE loader waits for). Mainline MAME does not wire INDEX yet.
With these, a FEATURE.PRE presentation floppy inserted on the DEMONSTRATION screen loads
its song, script and 19 pictures from the drive and plays, with nothing forced
(Slide shows). A disk must be laid out
like a DOS-formatted one: the media check accepts only a FAT starting F0 FF FF or
F9 FF FF, and the KN6000 file system also assumes 9-sector FATs; the floppy images in
MAME’s software lists do not pass (see the slide-show page), and are to be rebuilt on the
instruments’ own formatted disks (Floppy Disk Images).
FORMAT works (tested 2026-10-18 with the fixes above): DISK, DISK TOOLS on a blank disk opens FLOPPY DISK FORMAT; 1.44M, YES, then a message box (EXIT) and DISK NAMING. The disk it writes is described on Floppy Disk Images, and it is byte-identical to what the KN5000 and KN6000 write. Before the DMA and INDEX fixes, FORMAT had failed with ERROR 08 (“an error has occurred while the disk was formatting”) inside the RTOS class-5 disk-task dispatch, before the FDC was touched; that run predates the fixes and was not reproduced. The KN6000 needed one more fix to format: its DMA-end interrupt makes a dummy read of the DMA acknowledge port, and the driver now lets such a read move data only while the controller requests it (otherwise it took FORMAT TRACK’s last sector ID).
⚠ ERROR 08 identifies no decision point. It is FmmFormatFunc’s default message number — any result code absent from the status-to-error table at 0x48663794 produces it (the KN5000’s copy is FileIO_StatusToErrorCode, 0xEA067C), and the format worker’s own -6 maps to 8 as well. The code means “the format returned failure”, nothing more. Reasoning that treats 8 as naming a particular branch is unsound; several earlier notes did.
PC COMMUNICATION: file commands over MIDI
Established from the code on 2026-11-06, not yet run (disassembly
kn7000/notes/presentation-control-probes/song-records.md, section 7, probe sysex_pccom.py). The
KN7000 accepts file commands from a computer as Technics SysEx (F0 50 2C 20 31 1F 7F gg ss .. name 00
cc F7) and shows the screen PC COMMUNICATION (TT_PCCOM) while it runs them: load or save a named file
of one of the file groups, an SMF, a picture import, or one of five SD-card operations. Each frame
carries the SD card’s CRC-7 before F7. The instrument echoes the request, waits for the computer’s
go-ahead (F0 50 23 ..), then answers “done” (F0 50 28 20 31 1F cc F7) or a status code (F0 50 29
20 31 1F ee cc F7). The file data never travels over MIDI: each command names a file the instrument
loads or saves itself. [INFERENCE] The computer side is the CD-ROM’s “Technics SongManager &
AudioRecorder (for KN7000)”, which was not decoded.
Relationship to the KN5000
The floppy/FAT layer and the FMM screen design are shared with the KN5000
(Storage / FDC, Shared Codebase Map).
The KN7000 extends it with the SD-card slot (folders, playlists, rename — a
much richer file model) and the USB Song Manager PC link, neither of which the
KN5000 had. Those additions are visible precisely as the extra Sdc* / USB
handlers layered on top of the common Fmm* core.