Disk images and the Disk Explorer
Klive opens a disk image as its files. Double-click a .dsk (a ZX Spectrum +3 disk, with the
+3DOS file system), a .trd or a .scl (TR-DOS disks, for the Pentagon 128 and the Scorpion), or
an .mdr (a Microdrive cartridge, for the Interface 1) in the
project explorer, and the Disk Explorer shows what is on it: the file names, what each file
is, its size and load address, and a preview.
New to Klive’s disks? Tutorial: working with disks makes a +3 boot disk and an SD card step by step, with a picture of every step.
Looking at a file
Select a file to see its details beside the list:
- a BASIC program shows its listing and its auto-run line;
- a 6,912-byte code file loaded at 16384 shows as the screen it is;
- other code and headerless files show as bytes.
The buttons above the preview open the file as a memory view, or, for code, as disassembly at its load address.
On a +3DOS disk you can also set a file’s Read-only, System and Archive attributes. The list shows them in the Attr. column, and the User column shows the file’s user area.
Changing the disk
The buttons in the header strip change the disk:
| Button | What it does |
|---|---|
| Add (+) | Puts host files on the disk |
| Save | Saves the selected file to the host |
| Rename | Renames the selected file |
| Delete | Deletes the selected file |
| Compact | (TR-DOS only) Lays the files down again without the deleted ones, as TR-DOS’s MOVE does |
| Show deleted | Lists deleted files too, struck through |
You can also drag files onto the explorer, from the project explorer or from your file manager. What a file becomes on the disk depends on its kind:
- a
.tapputs every file on the tape on the disk, with the header’s name, kind and addresses; - a
.scrbecomes a screen (code at 16384); - a
.bastext file is tokenised into a BASIC program; - anything else becomes code, at the address Klive asks for (32768 suggested).
Names are made to fit the disk: +3DOS takes up to 8 characters, a dot and 3 more (upper case), and TR-DOS takes up to 8 characters and a type letter.
Klive writes the changed disk next to the file and renames it over the original, so a failed write
never leaves half a disk. The first change in a session keeps the original as <name>.bak.
Disks in the machine’s drive
The explorer shows In drive A (or B) when the disk is in one of the emulated machine’s drives.
You can still change it: a running machine pauses, Klive writes the disk and puts it back in the
drive, and the machine runs on. When the machine itself writes to the disk (a SAVE, a FORMAT),
the open explorer shows the change a moment later.
The disk’s layout
The Layout button shows the disk as its tracks and sectors. Each square is one sector, coloured by what it holds: the system tracks, the directory, a file, free space, or space the file system never uses. Hover over a square to see the sector’s ID and what it holds. A square with an outline is a sector the disk image marks as unusual: a CRC error, a deleted data mark, or a weak sector (the image keeps several versions of it, and the real disk read differently each time).
Select a sector to see its position, its ID (C, H, R, N), its status bytes, what it holds and its bytes. When it belongs to a file, the file’s name takes you back to the file. The Show the file’s sectors button in a file’s preview does the opposite: it opens the layout with that file’s sectors marked.
On a .dsk, the Surface switch shows the image as the disk stores it: every track’s header
and sectors, and the raw track as laid on the disk.
A Microdrive cartridge has no tracks: its layout is one row of up to 254 sectors of 512 bytes, in the order they pass the head, each named by its sector number.
A TR-DOS disk has 16 sectors of 256 bytes on every track. Its header strip also shows the disk’s label:
Hard-disk images and SD cards
The Disk Explorer also opens hard-disk images: a raw .img, a RAMsoft .hdf and Klive’s own
.cim (the ZX Spectrum Next’s SD card). Klive reads their FAT16 and FAT32 file systems, with
long file names and folders. A card can be gigabytes, so the explorer reads only the folder and the
file it shows.
- Double-click a folder to open it; Up goes back to the folder above. New folder makes one.
- Add, Save, Rename, Delete and dragging files work as on a floppy, but files go on
the card as they are, under their own names: esxDOS and NextZXOS load a
.tap, a.snaor a.scrstraight from the card. Drop a folder to copy it with everything in it. - A card with several partitions shows a partition picker in the header.
- Attributes show as Read-only, System, Hidden and Archive.
The Layout view shows the volume’s areas - the reserved sectors, the FATs, the root folder and the data - and a map of its clusters in use. The selected file’s clusters are outlined.
Klive changes a hard-disk image in place, without a .bak copy. When the image is the running
machine’s SD card, the machine pauses while Klive writes it.
Make a new card with the disk command - disk new card.img fat16 64 (or fat32, with the size in
MB) - then drop the folders you want on it. The extension picks the format:
.img: the card’s sectors byte for byte, full size from the start, readable by other emulators and your computer, and copyable to a real SD card;.hdf: the same sectors after a RAMsoft header, for emulators that take hard-disk images;.cim: the same sectors as an.img, with the unused ones omitted, so the file grows as the card fills. It is Klive’s own format (the Next’s card is one), takes 64 MB to 16 GB, and only Klive reads it.
Which format: .img, .hdf or .cim?
in the tutorial compares them.
The DivMMC
The DivMMC is an SD card interface for the ZX Spectrum 48K, 128K and +2A/+3, which runs the esxDOS operating system. Klive emulates it on these machines (not on the Pentagon or the Scorpion, which have the Beta 128):
- Klive cannot ship esxDOS. Get it from its authors and name its 8K ROM in Settings › Machine › esxDOS ROM.
- Turn on DivMMC Interface: under Machine › Interfaces on the 48K and the 128K (where it shares the menu with the Interface 1, which it disconnects), under Machine › SD Card on the +2A/+3. The machine restarts with the interface.
- Select SD Card Image in the same menu names the card: an
.img,.hdfor.cimwith a FAT16 or FAT32 file system and esxDOS’sBIN,SYSandTMPfolders on it. You can prepare one in the Disk Explorer.
esxDOS’s dot commands then work as on the real interface (.ls, .cd, .tapein, .snapload).
Press the NMI Button in the same menu opens esxDOS’s NMI menu. While the debugger shows memory,
the interface’s ROM and RAM banks appear as the partitions DR and D0-DF.
From the command prompt
The disk command does the same from the IDE’s command prompt, from scripts and from
automation (klive ide cmd "disk ls game.dsk"):
disk ls game.dsk
disk add game.dsk loader.bas
disk add game.dsk code.bin -start 24000
disk get game.dsk GAME.BIN game.bin
disk mv game.dsk GAME.BIN MAIN.BIN
disk rm game.dsk NOTES.TXT
disk compact magazine.trd
disk new blank.dsk dse80
disk new card.img fat16 64
disk mkdir card.img games/arcade
disk add card.img mygames games
disk ls card.img gamesOn a hard-disk image, add copies a file or a whole folder, and ls lists a folder.
Without a running Klive, klive disk takes the same actions on the image file directly; see
the command line.
Exporting a program to a disk
Export Code (or expc ... -f dsk / -f trd) puts a compiled program on a new disk that boots
it. A .dsk holds a BASIC loader named DISK, which the +3’s Loader menu runs. A .trd holds a
loader named boot, which TR-DOS runs when the disk boots. An .mdr (-f mdr, on the 48K and the
128K) is a formatted Microdrive cartridge with a loader named run, which the Interface 1 runs when
you boot the cartridge. The loader loads the code files (and a
loading screen, if you give one) and starts the program; CLEAR and the border colour work as
they do for a tape.
A program that uses the 128K memory banks cannot be exported to a disk or a cartridge yet: export it as a tape.
Related
- Tutorial: working with disks
- The File Manager: copy files between disks, cards, tapes and this computer, two panes side by side
- TR-DOS disks
- The Interface 1 and Microdrives
- Exporting your program




