"
#
# Example — include in all builds:
addMZFToROMImageList 1 1 1 0 "${MZB_PATH}/Common/sa-5510_rfs.${SECTORSIZE}.bin"
# Example — RomDisk and picoZ80 only:
addMZFToROMImageList 1 0 1 0 "${MZB_PATH}/MZ-80A/defender.${SECTORSIZE}.bin"
```
Applications are packed in the order listed, filling User ROM 1 first, then User ROM 2 and 3. Place applications you always want available at the top of the list.
### Build Tools Reference
| Script / Tool | Description |
|--------------|-------------|
| `build.sh` | Top-level build script. Runs all steps below in order. Pass `-m` to also reprocess MZF application files. |
| `tools/assemble_rfs.sh` | Assembles `rfs.asm` and `rfs_mrom.asm` → `roms/rfs.rom`, `roms/rfs_mrom.rom`. |
| `tools/assemble_cpm.sh` | Assembles the CP/M 2.2 CBIOS and kernel → `roms/*.rom`. |
| `tools/assemble_roms.sh` | Assembles all monitor ROM variants and MZF application binaries. Handles the four MS-BASIC build variants via a `BUILD_VERSION` EQU written to `include/msbasic_buildversion.asm` before each pass. |
| `tools/make_roms.sh` | Packages ROM and MZF binaries into Flash ROM images for ROMDISK, SFD700 and picoZ80 targets. |
| `tools/make_cpmdisks.sh` | Creates CP/M disk images in RAW format (for SD card) and CPC Extended Disk Format (for floppy emulators or physical copying). |
| `tools/make_sdcard.sh` | Combines RFS drive images and CP/M disk images into a single SD card image. |
| `tools/processMZFfiles.sh` | Converts MZF application files into 128-byte and 256-byte sector-padded images in `MZB/`. |
| `tools/mzftool.pl` | Perl script to create, extract and inspect MZF format images. |
| `tools/sdtool` | Binary tool that builds the RFS SD card directory structure and populates it with MZF / binary applications. |
| `tools/nasconv` | Converts NASCOM cassette image files to MZ-80A loadable format, remapping MS-BASIC token values as needed. |
| `tools/glass.jar` | Bundled GLASS Z80 assembler (Java). Used by all three assembly scripts. |
| `cpmtools/` | cpmtools source (cpmcp, cpmls, cpmrm, etc.). Compiled automatically on first build and installed into `tools/`. |
--------------------------------------------------------------------------------------------------------
## SD Card Filing System
Rather than implementing a FAT file system (which would be too large for the 2 KB and 4 KB ROM banks), RFS uses a purpose-built simple filing system called the SD Card Filing System (SDCFS). Initial v1 boards used a software bit-bang SPI interface; the v2.0 PCB added hardware SPI, giving ROM-level access speeds.
### SDCFS Structure
Each SDCFS image contains a 32-byte-per-entry directory for up to 256 files followed by 256 fixed-size file blocks. Ten SDCFS images (drives 0–9) are stored at the start of the SD card. The remainder of the SD card holds CP/M disk images.
Each directory entry is based on the standard MZF header:
| FLAG1 | FLAG2 | FILE NAME | START SECTOR | SIZE | LOAD ADDR | EXEC ADDR | RESERVED |
|-------|-------|-----------|--------------|------|-----------|-----------|----------|
| 1 Byte | 1 Byte | 17 Bytes | 4 Bytes | 2 Bytes | 2 Bytes | 2 Bytes | 3 Bytes |
| Field | Description |
|-------|-------------|
| FLAG1 | Bit 7 = 1: valid entry. Bit 7 = 0: inactive / deleted. |
| FLAG2 | MZF execution type (0x01 = binary). |
| FILE NAME | Standard 17-character MZF filename. |
| START SECTOR | First sector within this drive image where the file data begins. |
| SIZE | Actual byte count of the file data. |
| LOAD ADDR | RAM address to load the file data to. |
| EXEC ADDR | Auto-execution address for binary files. |
| RESERVED | Not currently used. |
Each file block is a fixed 64 KB, matching the maximum CMT (tape) block size. This keeps the layout simple and allows files to be read or written exactly as if they were on tape, enabling transparent SD↔CMT copy operations.
### SD Card Layout
```
ADDRESS SECTOR CONTENT
00000000 00000 ┌─────────────────────────────────────────────────────────────┐
│ RFS DRIVE 0 │
00000000 00000 │ Directory entry 000 (32 bytes) │
│ ... │
00001FE0 0000F │ Directory entry 255 (32 bytes) │
00002000 00010 │ File block 0 (64 KB) │
│ ... │
00FF2000 7FF90 │ File block 255 (64 KB) │
01001FFF 8000F └─────────────────────────────────────────────────────────────┘
... (RFS drives 1–8 follow the same pattern)
09012000 48090 ┌─────────────────────────────────────────────────────────────┐
│ RFS DRIVE 9 │
0A013FFF 5009F └─────────────────────────────────────────────────────────────┘
... padding to 256 MB boundary ...
10000000 80000 ┌─────────────────────────────────────────────────────────────┐
│ CP/M DISK IMAGE 0 (16 MB, 32 sectors × 1024 tracks) │
11000000 88000 ├─────────────────────────────────────────────────────────────┤
│ CP/M DISK IMAGE 1 │
│ ... │
XX000000 │ CP/M DISK IMAGE n │
└─────────────────────────────────────────────────────────────┘
```
### SD Card Organisation
The SD card image built by the repository tools is pre-populated as follows:
| RFS Drive | Contents |
|-----------|----------|
| 0 | Common and MZ-80A machine code programs. |
| 1 | MZ-80K machine code programs. |
| 2 | MZ-700 machine code programs. |
| 3 | MZ-800 / MZ-1500 machine code programs. |
| 4 | MZ-80B / MZ-2000 machine code programs. |
| 5 | BASIC programs, type 2 (MZ-80A). |
| 6 | BASIC programs, type 2 (MZ-80K). |
| 7 | BASIC programs, type 5 (MZ-700 / MZ-800). |
| 8 | Other / miscellaneous programs. |
| 9 | Other / miscellaneous programs. |
| CP/M Drive | User# | Disk image | Contents |
|-----------|-------|-----------|---------|
| 0 | 0 | CPM00_SYSTEM | CP/M system programs |
| | 1 | CPM01_TURBOP | Turbo Pascal |
| | 2 | CPM02_HI_C | Hi-Soft C |
| | 3 | CPM03_FORTRAN80 | Fortran 80 |
| | 4 | CPM04_MBASIC | Microsoft BASIC 80/85 |
| | 5–7 | CPM05–07_COBOL80 | Cobol v1.3, v2.0, Cobol 80 |
| | 8 | CPM08_Z80FORTH | Z80 Forth |
| | 9 | CPM09_CPMTEX | CP/M TeX |
| | 10 | CPM10_DISKUTILFUNC5 | Disk utilities |
| | 11 | CPM11_MAC80 | Macro Assembler 80 |
| | 12 | CPM29_ZSID_v14 | ZSID Debugger |
| | 13–14 | CPM32–33_ZCPR3 | ZCPR3 CCP enhancement |
| 1 | 0 | CPM12_PASCALMTP_v561 | Pascal v5.61 |
| | 1 | CPM26_TPASCAL_v300a | Turbo Pascal v3.00a |
| | 2–11 | CPM13–22_MTPUG_01–10 | Pascal User Group Disks 01–10 |
| 2 | 0–2 | CPM23–25_PLI / PLI80 | PLI Compiler, PLI 80 v1.3, v1.4 |
| | 3 | CPM28_PLM80 | PLM 80 |
| | 4–6 | CPM27,30,31_WORDSTAR | WordStar v3.0, v3.3, v4.0 |
| 3–6 | 0–9 | CPM_MC_C0–F9 | Grant Searle CP/M collection disks C0–F9 |
--------------------------------------------------------------------------------------------------------
## Manuals
Detailed documentation for the Rom Filing System is available in three separate manuals:
| Manual | Description |
|--------|-------------|
| [User Manual](/sharpmz-upgrades-rfs-usermanual/) | Getting RFS, monitor command reference, using SD drives, BASIC, CP/M, and troubleshooting |
| [Technical Guide](/sharpmz-upgrades-rfs-technicalguide/) | Hardware platforms, memory architecture, bank switching, SDCFS design, CP/M CBIOS, and full build system reference |
| [Developer's Guide](/sharpmz-upgrades-rfs-developersguide/) | Z80 assembly primer, full source module walkthroughs (including bank-switching internals), and guides for adding new commands and hardware targets |
--------------------------------------------------------------------------------------------------------
## Credits
Where any component is based on or derived from a third-party design, the original author's copyright notice is included in the relevant source file header. All third-party software is, to the best of knowledge, open source and freely usable. If any component is found to carry licensing restrictions it will be removed and a suitable link provided instead.
--------------------------------------------------------------------------------------------------------
## Licenses
This design, hardware and software, is licensed under the GNU Public Licence v3.
No commercial use to be made of this design or any hardware/firmware component without express permission from the author. This condition overrides any rights afforded by the GNU GPL 3 license.
### The Gnu Public License v3
The source and binary files in this project marked as GPL v3 are free software: you can redistribute them and-or modify them under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
The source files are distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.