(path: Path, data: BackupData)
| 493 | |
| 494 | |
| 495 | def write_save(path: Path, data: BackupData) -> None: |
| 496 | blob = data.pack() |
| 497 | # Build the full 32 KiB SRAM image with both slots populated. |
| 498 | out = bytearray(SRAM_FILE_SIZE) |
| 499 | out[SLOT_A_OFFSET:SLOT_A_OFFSET + BACKUP_SIZE] = blob |
| 500 | out[SLOT_B_OFFSET:SLOT_B_OFFSET + BACKUP_SIZE] = blob |
| 501 | |
| 502 | path.parent.mkdir(parents=True, exist_ok=True) |
| 503 | path.write_bytes(bytes(out)) |
| 504 | |
| 505 | |
| 506 | # --------------------------------------------------------------------------- |