Skip to content

Fix PSX raw sector EDC/ECC generation - #215

Merged
sithlord48 merged 2 commits into
sithlord48:masterfrom
DLPB2:fix-psx-sector-edc-ecc
Aug 21, 2026
Merged

Fix PSX raw sector EDC/ECC generation#215
sithlord48 merged 2 commits into
sithlord48:masterfrom
DLPB2:fix-psx-sector-edc-ecc

Conversation

@DLPB2

@DLPB2 DLPB2 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This fixes raw PSX CD-ROM sector integrity when IsoArchive writes or relocates sectors.

The issue was found while investigating myst6re/makoureactor#51. In current ff7tk, IsoArchiveIO::writeSector() constructs a 2352-byte sector with a zero-filled 280-byte footer, writeIso() can change the 2048-byte ISO payload without regenerating EDC/ECC, and copySectors(..., repair=true) reconstructs moved sectors from only their 2048-byte payload.

Changes:

  • generate Mode 2 Form 1 EDC + P/Q ECC for sectors created by writeSector();
  • generate Mode 2 Form 2 EDC (no P/Q ECC);
  • repair only raw sectors whose payload is modified by writeIso();
  • route Primary Volume Descriptor volume-size writes through writeIso();
  • preserve the complete 2352-byte raw sector when relocating existing sectors;
  • update destination MSF when a data sector is relocated;
  • preserve existing Mode 2 XA integrity bytes when only MSF changes, since XA integrity is independent of the address;
  • regenerate Mode 1 integrity when relocating Mode 1, because its address participates in integrity;
  • leave untouched sectors byte-for-byte unchanged.

writeSector() remains limited to ff7tk's existing 24-byte Mode 2 XA header/subheader + 2048-byte payload layout. Existing Mode 1 sectors are handled by the relocation/repair helper rather than constructed through writeSector().

The EDC/ECC algorithm is the same implementation already tested through Makou Reactor on an FF7 PSX image.

Related Makou Reactor PR: myst6re/makoureactor#233

@DLPB2

DLPB2 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

Also do me a fave and add a credit for me :)

Cheers

@sithlord48

sithlord48 commented Aug 20, 2026

Copy link
Copy Markdown
Owner

This needs to be fixed up as we don't do namespaces and the new file is not using Qt Object etc.. Ill get this looked over soon and updated so you guys can retest soon

Edit: since this is a collection of inlines ill leave it as namespace for now.. Added a commit to bump Qt t. 6.9.3 should fix the mac os build issue.

@sithlord48
sithlord48 force-pushed the fix-psx-sector-edc-ecc branch from 6c7b7e8 to 96c2a91 Compare August 21, 2026 22:42
@sithlord48
sithlord48 merged commit cb876ba into sithlord48:master Aug 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants