A Python utility for converting between Amstrad GX4000 cartridge ROM formats (CPR ↔ BIN).
This tool allows bi-directional conversion between:
- CPR format (Amstrad GX4000 cartridge ROM dump)
- BIN format (raw ROM data suitable for EPROM burning)
The CPR format is based on RIFF and consists of 16KB blocks with specific headers. This utility handles all the necessary format conversion while maintaining data integrity.
- Bi-directional conversion (CPR → BIN and BIN → CPR)
- Handles multiple 16KB blocks
- Automatic block padding
- Validates file format and headers
- Enforces format constraints (max 512KB/32 blocks)
- Python 3.6 or higher
- Clone this repository:
git clone https://github.com/yourusername/cpr2bin.git
cd cpr2bin- Make the script executable (Unix-like systems):
chmod +x cpr2bin.pypython3 cpr2bin.py --to-bin input.cpr output.binpython3 cpr2bin.py --to-cpr input.bin output.cprUsage: cpr2bin.py <direction> <input_file> <output_file>
direction: --to-bin or --to-cpr
- RIFF header (4 bytes)
- File size (4 bytes)
- AMS! identifier (4 bytes)
- Multiple 16KB blocks, each with:
- Block identifier (4 bytes, "cbXX")
- Block size (4 bytes)
- Block data (up to 16KB)
- Maximum file size: 512KB (32 blocks of 16KB each)
- Block size: Fixed at 16KB (padded with zeros if necessary)