Version 1.1 - Real CoCo DECB Behavior + Comprehensive Documentation!
A Python tool for managing TRS-80 Color Computer DSK/JVC disk images with authentic hardware behavior. This tool allows you to mount, inspect, and transfer files between Color Computer disk images and your PC, with a Norton Commander-style browser for easy navigation.
-
Clone the repository:
git clone https://github.com/reyco2000/CoCo-DSK-Filesystem.git cd CoCo-DSK-Filesystem -
Install requirements (if needed):
Linux / macOS / WSL:
# No installation needed! Works out of the box with Python 3.6+ python3 coco_commander_v1.pyWindows (Native):
# Install curses support for Windows pip install -r requirements.txt # Then run python coco_commander_v1.py
-
You're ready to go!
# Run CoCo Commander V1 (with detokenization) python3 coco_commander_v1.py # Or use command-line tool python3 coco_dsk.py mydisk.dsk -l
NEW in v1.0! Enhanced text-based UI with integrated BASIC detokenization:
python3 coco_commander_v1.pyFeatures:
- β¨ BASIC Detokenization - Automatically convert tokenized BASIC programs to readable text
- π¨ Color-Coded Selection - Green highlight for active panel, white for inactive
- π Smart Filename Entry - Cursor starts at end for quick editing
- π Enhanced Dialogs - Improved Yes/No dialogs with button navigation
- π― Dual-Pane Interface - PC files β DSK image side-by-side
- π Function Keys - F2: Info | F3: View | F4: Edit | F5: Copy | F6: Rename | F7: Format | F8: Delete
- β¨οΈ Intuitive Navigation - Arrow keys and TAB for panel switching
- ποΈ Built-in Viewers - Hex/text viewer and text editor
- π¨ Norton Commander Style - Familiar dual-pane file management
Requirements: coco_detokenizer.py must be in the same directory
See COCO_COMMANDER_GUIDE.md for complete documentation.
Traditional command-line interface for scripting and automation.
- Mount DSK/JVC disk images - Parse and read Color Computer disk images
- List directory contents - View all files with their types and attributes
- Extract files - Copy files from DSK images to your PC
- Upload files - Add files from your PC to DSK images with flexible type/mode options
- Delete files - Remove files from DSK images and free up space
- Format new disks - Create blank DSK/JVC images with custom geometries
- Free space calculation - See available storage on disk images
- JVC header support - Handles both raw DSK and JVC formats
Version 1.1 implements authentic TRS-80 Color Computer DECB behavior based on real hardware observations:
- Granule Allocation: Files now start allocating from granule 32 (track 16), matching real CoCo DECB behavior
- Directory Entry Formatting: Active entries use
0x00padding in reserved bytes (not0xFF) - Deletion Markers: Deleted entries marked with first byte
0x00only, rest may retain old data - Fresh Format Behavior: Never-used entries filled with
0xFFon fresh formatted disks - FAT Padding: Uses
0x00for FAT sector padding during file operations (bytes 68-255) - Default Format: No JVC header by default (real CoCo standard); use
--add-jvcfor emulator compatibility
Two new professional documentation files:
-
DSK_JVC_FORMAT_SPECIFICATION.md - Complete 1,250+ line technical specification covering:
- Physical disk structure and track/sector format
- Sector interleaving and skip factors
- Detailed FAT and directory structure
- File storage algorithms with working examples
- Common issues and troubleshooting
-
DSK_JVC_PROGRAMMER_GUIDE.md - Concise programmer's reference with:
- Quick reference diagrams
- Implementation code examples
- Real CoCo DECB behavior notes
- Troubleshooting checklist
Flagship feature with integrated BASIC detokenization:
- Automatic BASIC Detection: Recognizes tokenized BASIC files when copying from DSK
- Interactive Choice: Asks if you want to detokenize before saving to PC
- Smart Naming: Auto-suggests
.txtextension for detokenized files - Readable Output: Converts tokenized BASIC to human-readable source code
- Full Token Support: Handles Color BASIC, Extended Color BASIC, and CoCo 3 Super Extended BASIC
- Fallback Protection: If detokenization fails, raw file is still saved
- Color-coded selection bars (green for active panel)
- Improved dialog system with visual button navigation
- Better cursor positioning in input fields
- Tab behavior resets DSK panel to top
coco_commander_v1.py- CoCo Commander with BASIC detokenizationcoco_detokenizer.py- Standalone BASIC detokenizercoco_dsk.py- Command-line DSK tool and Python API with real CoCo behaviorCOCO_COMMANDER_GUIDE.md- Complete user guideDSK_JVC_FORMAT_SPECIFICATION.md- Complete technical specification (1,250+ lines)DSK_JVC_PROGRAMMER_GUIDE.md- Concise programmer's reference
- Python: 3.6 or higher (3.7+ recommended)
- Operating System: Linux, macOS, Windows, or WSL
Good news! No external dependencies required on Linux/macOS/WSL - everything uses Python's standard library.
Windows users: One optional package for curses support:
pip install -r requirements.txtThis installs windows-curses which enables the text-based UI on Windows.
What's included in requirements.txt:
windows-curses>=2.3.0(Windows only)- All other dependencies are part of Python's standard library
- For CoCo Commander V1:
coco_detokenizer.pymust be in the same directory - For Command-line tool:
coco_dsk.pyis standalone
python coco_dsk.py mydisk.dsk -lOutput shows filename, type, mode (ASCII/BIN), and starting granule for each file.
# Copy with specified output name
python coco_dsk.py mydisk.dsk -g HELLO.BAS -o hello.bas
# Copy with default name
python coco_dsk.py mydisk.dsk -g PROGRAM.BIN# Upload as machine code (default type)
python coco_dsk.py mydisk.dsk -p program.bin -n PROG.BIN
# Upload as BASIC program (using string type name)
python coco_dsk.py mydisk.dsk -p hello.bas -n HELLO.BAS -t basic
# Upload as text file in ASCII mode (long form)
python coco_dsk.py mydisk.dsk -p readme.txt -n README.TXT -t text --mode ascii
# Upload as text file in ASCII mode (short form)
python coco_dsk.py mydisk.dsk -p readme.txt -n README.TXT -t text -a
# Upload using numeric type code (backward compatible)
python coco_dsk.py mydisk.dsk -p data.dat -n DATA.DAT -t 1# Delete a file (frees up space)
python coco_dsk.py mydisk.dsk -d HELLO.BAS
# Delete and save to a different file
python coco_dsk.py mydisk.dsk -d OLDFILE.BIN -s cleaned.dsk# Create a standard 160K disk (35 tracks, single-sided, NO JVC header - real CoCo format)
python coco_dsk.py newdisk.dsk --format
# Create with JVC header for emulators
python coco_dsk.py newdisk.dsk --format --add-jvc
# Create a 360K double-sided disk (40 tracks, 2 sides)
python coco_dsk.py bigdisk.dsk --format --tracks 40 --sides 2
# Create an 80-track 720K disk with JVC header
python coco_dsk.py huge.dsk --format --tracks 80 --sides 2 --add-jvcpython coco_dsk.py mydisk.dsk -p newfile.bin -s modified.dsk| Argument | Description |
|---|---|
dsk_file |
DSK/JVC image file (required) |
-l, --list |
List files in DSK image |
| Argument | Description |
|---|---|
-g, --get DSK_FILE |
Copy file from DSK to PC |
-o, --output PC_FILE |
Output filename for -g (default: same as DSK filename) |
| Argument | Description |
|---|---|
-p, --put PC_FILE |
Upload file from PC to DSK |
-n, --name DSK_NAME |
Name to use in DSK for -p (default: PC filename in 8.3 format) |
-t, --type TYPE |
File type: basic, data, ml, text (or 0-3). Default: ml |
--mode MODE |
File mode: binary or ascii (default: binary) |
-a, --ascii |
Shorthand for --mode ascii |
| Argument | Description |
|---|---|
-d, --delete DSK_FILE |
Delete file from DSK image |
| Argument | Description |
|---|---|
--format |
Format a new blank DSK image (no JVC header by default - real CoCo) |
--tracks TRACKS |
Number of tracks for --format (default: 35) |
--sides {1,2} |
Number of sides for --format (default: 1) |
--add-jvc |
Add JVC header when formatting (for emulators) |
--no-jvc |
Deprecated: no header is now the default |
| Argument | Description |
|---|---|
-s, --save OUTPUT_DSK |
Save modified DSK to new file |
When uploading files with -t, use these type names or codes:
| Type Name | Code | Description |
|---|---|---|
basic |
0 | Color BASIC program (tokenized) |
data |
1 | BASIC data file |
ml |
2 | Machine language/binary (default) |
text |
3 | Text/ASCII file |
When uploading files, specify the mode:
| Mode | Description |
|---|---|
binary |
Binary data, no translation (default) |
ascii |
ASCII text, CR/LF handling |
- Sector size: 256 bytes
- Default format: 35 tracks, 18 sectors/track (160K)
- Granule size: 9 sectors (2,304 bytes)
- Granules per disk: 68
- Allocation start: Granule 32 (track 16) - matches real CoCo DECB
- Default header: None (real CoCo standard); JVC headers optional for emulators
- Directory track: Track 17
- FAT: Track 17, Sector 2 (first 68 bytes)
- Directory entries: Track 17, Sectors 3-11
- Entry size: 32 bytes per directory entry
- Max files: 72 (9 sectors Γ 8 entries per sector)
Each 32-byte directory entry contains:
- Bytes 0-7: Filename (8 characters, space-padded)
- First byte
0x00= deleted entry - First byte
0xFF= never used (all subsequent entries also unused) - First byte
0x20-0x7E= active file
- First byte
- Bytes 8-10: Extension (3 characters, space-padded)
- Byte 11: File type (0=BASIC, 1=DATA, 2=ML, 3=TEXT)
- Byte 12: ASCII flag (0xFF=ASCII, 0x00=Binary)
- Byte 13: First granule number (0-67)
- Bytes 14-15: Last sector byte count (big-endian)
- Bytes 16-31: Reserved (
0x00for active entries,0xFFfor fresh format)
This tool implements authentic CoCo behavior:
- Granule allocation: Starts at granule 32, searches 32-67 then wraps to 0-31
- Directory padding: Active entries use
0x00in reserved bytes - Deletion: Only first byte set to
0x00, rest retains old data - Fresh format: All directory entries filled with
0xFF - FAT padding: Bytes 68-255 use
0x00during file operations
For complete technical details, see DSK_JVC_FORMAT_SPECIFICATION.md
# 1. List files on an existing DSK image
python coco_dsk.py games.dsk -l
# 2. Extract a BASIC program
python coco_dsk.py games.dsk -g SNAKE.BAS -o snake.bas
# 3. Upload a modified version back
python coco_dsk.py games.dsk -p snake_fixed.bas -n SNAKE2.BAS -t basic
# 4. Upload a machine language game
python coco_dsk.py games.dsk -p pacman.bin -n PACMAN.BIN -t ml
# 5. Delete the old version
python coco_dsk.py games.dsk -d SNAKE.BAS
# 6. List files again to verify
python coco_dsk.py games.dsk -l# 1. Format a new 160K disk
python coco_dsk.py collection.dsk --format
# 2. Add multiple files
python coco_dsk.py collection.dsk -p game1.bin -n GAME1.BIN -t ml
python coco_dsk.py collection.dsk -p game2.bin -n GAME2.BIN -t ml
python coco_dsk.py collection.dsk -p readme.txt -n README.TXT -t text -a
# 3. List to verify
python coco_dsk.py collection.dsk -l# Create a large 720K disk for more storage
python coco_dsk.py bigdisk.dsk --format --tracks 80 --sides 2
# Create a 360K double-sided disk
python coco_dsk.py medium.dsk --format --tracks 40 --sides 2
# Verify the disk is empty
python coco_dsk.py bigdisk.dsk -lThe tool follows the File Allocation Table (FAT) chain to read multi-granule files:
- FAT entries 0-67: Point to next granule in chain
- FAT entries 0xC0-0xC9: Last granule (lower 4 bits = sectors used)
- FAT entry 0xFF: Free/unused granule
Track 17 is reserved for the directory and FAT. When calculating granule-to-track mappings:
- Granules 0-33 map to tracks 0-16
- Granules 34-67 map to tracks 18-34
- Track 17 is skipped in the mapping
Real CoCo DECB behavior: Files allocate starting from granule 32 (track 16, just before directory track):
- Search order: 32β67 (toward end of disk)
- If needed, wraps to: 0β31 (toward beginning)
- This places new files near the directory track for faster access
The tool automatically detects and parses JVC headers if present. JVC headers are optional and contain:
- Byte 0: Sectors per track
- Byte 1: Side count
- Byte 2: Sector size code
- Byte 3: First sector ID
- Byte 4: Sector attribute flags
You can also use this tool as a Python module:
from coco_dsk import DSKImage
# Format a new disk
dsk = DSKImage.format_disk('newdisk.dsk', tracks=35, sides=1)
# Or mount an existing DSK image
dsk = DSKImage('mydisk.dsk')
if dsk.mount():
# List files
dsk.list_files()
# Extract a file
for entry in dsk.directory:
if entry.filename == 'HELLO':
data = dsk.extract_file(entry)
with open('hello.bas', 'wb') as f:
f.write(data)
# Upload a file (file_type: 0=BASIC, 1=DATA, 2=ML, 3=TEXT)
# ascii_flag: 0x00=binary, 0xFF=ASCII
dsk.upload_from_pc('program.bin', 'PROG.BIN', file_type=0x02, ascii_flag=0x00)
# Delete a file
dsk.delete_file('OLDFILE.BAS')
# Save changes
dsk.save()
# Or save to a new file
dsk.save('modified.dsk')The tool validates:
- File existence before mounting
- Granule numbers (must be 0-67)
- Free space before uploads
- Directory slot availability
- Sector and track bounds
- Only supports DECB (Disk Extended Color Basic) format
- Maximum 72 directory entries per disk
- Filenames limited to 8.3 format (8 char name + 3 char extension)
- No subdirectory support (flat file system)
- No timestamp support in DECB format
Make sure you're using the exact filename as shown in the directory listing (case-insensitive).
The disk is full. Check free space with -l option. You may need to use a larger disk image or remove files.
Maximum 72 files per disk. You'll need to use a new disk image.
-
DSK_JVC_FORMAT_SPECIFICATION.md - Complete 1,250+ line technical specification
- Physical disk structure with track/sector format
- Sector interleaving and skip factors
- Detailed FAT and directory structure
- File storage algorithms with examples
- Common issues and troubleshooting
- Comprehensive reference for developers
-
DSK_JVC_PROGRAMMER_GUIDE.md - Concise programmer's reference
- Quick reference cheatsheets
- Code implementation examples
- Real CoCo DECB behavior notes
- Troubleshooting checklist
- Ideal for quick lookups
-
COCO_COMMANDER_GUIDE.md - CoCo Commander V1 user guide
- Complete UI reference
- Keyboard shortcuts
- BASIC detokenization guide
- Usage examples
- dsktools GitHub Repository - Original C implementation
- TRS-80 Color Computer Archive - Historical preservation
- Disk BASIC File Structure - Official documentation
- JVC Disk Image Format - Format specification
This project is open source and available under the MIT License.
- π§ Real CoCo DECB behavior - Granule allocation from granule 32, authentic padding
- π Comprehensive documentation - 1,250+ line technical specification
- π Programmer's guide - Concise reference with code examples
- π― Default format change - No JVC header by default (real CoCo standard)
- β FAT/Directory behavior - Matches real hardware (0x00 padding, deletion markers)
- π Enhanced docs - Physical track/sector format, interleaving details
- β¨ Released CoCo Commander V1 with integrated BASIC detokenization support
- π¨ Enhanced UI with color-coded panels and improved dialogs
- π Standalone BASIC detokenizer module included
- π Comprehensive user guide and technical documentation
- π§ Improved filename input with cursor positioning
- π― Tab behavior enhancements for better navigation
- π§Ή Simplified to single CoCo Commander version (V1 only)
- Initial release: Command-line DSK tool and prototype CoCo Commander
Made with β€οΈ by Reinaldo Torres β a proud CoCo enthusiast π§ reyco2000@gmail.com
π’ Proud member and co-creator of the CoCoByte Club https://cocobyte.co/
π See more on @ChipShift https://github.com/reyco2000/
Coded with Claude Code - Developed using Anthropic's Claude AI assistant
For issues or improvements related to the underlying disk format handling, please refer to the original dsktools repository.