RSS Bot Posted July 25, 2018 Share Posted July 25, 2018 In the last blog entry, I presented a little bit of Perl code to hex dump disk contents, and promised to extend that to allow disk patching. So here we go. The first routine we'll need is something to write a file. Here's a completely generic routine that will write a buffer to a file. So our strategy will be read_file, change the buffer, and then invoke this write_file command. sub sector_offset { 0x10 + ($_[0] - 1) * 0x80;}sub copy_sector { my ($srcFile, $srcSector, $dstFile, $dstSector) = @_; my ($dstBuff, $srcBuff) = (read_file($dstFile), read_file($srcFile)); my ($srcOffset, $dstOffset) = (sector_offset($srcSector), sector_offset($dstSector)); my $sectorSize = 0x80; substr($dstBuff, $dstOffset, $sectorSize) = substr($srcBuff, $srcOffset, $sectorSize); write_file($dstFile, $dstBuff);}Here's copy_sector. It needs a little helper function (sector_offset), which computes the location of a sector in a buffer. It then reads both files, copies a sector from the source to the destination, and then writes it out. Let's try this out. The ABC of CPR Side B had a single corrupted sector, sector 96. The Page 6 disk which has a correct version of the sector is called c06_abccpr_b.atr, so to patch the sector: Link to comment Share on other sites More sharing options...
Recommended Posts