Sector Gap Check
Sector Gap Check
This analysis is based on the state of the wiki from 23 Nov 2026.
Sector Gap Check is a disk check found on about 80 releases on this wiki, most of them US releases from 1986 to 1990 by many publishers (Data East, Brøderbund, Epyx, Mindscape, Capcom, Accolade, Maxis and others). The disks contain only standard CBM DOS sectors without read errors, so a sector copy can be made, but it does not run.
In short: a small drive program measures the gaps between the blocks of one track. It counts the bytes from each sync mark to the next one and notes the bytes directly before and after the sync mark. The numbers are not compared with fixed values. They are part of the key that decrypts 256 bytes of the game, which the C64 then fetches from the drive. On a disk with other gaps the game gets garbage.
The check relies on how the disks were mastered. On the originals all gaps of a track
have exactly the same length, and they are filled with a pattern that decodes as
$00 bytes, where the 1541 writes $55. A 1541 that rewrites a
sector leaves a different gap behind it.
The drive program
The drive program is 256 bytes long and stored in one sector of the disk, mostly on
track 18. The sector is encrypted: every byte is the EOR of a program byte with the
program byte before it; the start value differs from title to title. The game lets
the drive read this sector to $0300, sends a short routine that decrypts
it and jumps to $0371, and afterwards reads the result with
M-R from $0500.
The measuring part runs as an EXECUTE job on the track to check (from Fairlight; decrypted from track 19 sector 11):
$0300 20 0A F5 JSR $F50A ; ROM: find the header of the sector in the job table, wait for the data sync $0303 98 TYA $0304 50 FE BVC $0304 ; skip two bytes $0306 B8 CLV $0307 50 FE BVC $0307 $0309 84 85 STY $85 ; ($85 = 0: counter of the sync marks) $030B 85 0C STA $0C $030D A0 00 LDY #$00 ; byte counter low (Y) and high ($0D) $030F 84 0D STY $0D $0311 EA NOP ; 3 NOP; later versions: LDX $EAEA $0312 EA NOP $0313 EA NOP $0314 B8 CLV $0315 AE 00 1C LDX $1C00 ; sync mark? $0318 10 0C BPL $0326 ; yes: end of the block $031A 50 FE BVC $031A ; wait for the next byte $031C AD 01 1C LDA $1C01 ; A = last byte read $031F C8 INY ; count it $0320 D0 EF BNE $0311 $0322 E6 0D INC $0D $0324 D0 EE BNE $0314 $0326 A6 0C LDX $0C ; X = index into the table $0328 9D C2 04 STA $04C2,X ; last byte before the sync mark (gap byte) $032B 98 TYA $032C 9D C0 04 STA $04C0,X ; number of bytes, low $032F A5 0D LDA $0D $0331 9D C1 04 STA $04C1,X ; number of bytes, high $0334 18 CLC $0335 A4 85 LDY $85 $0337 B8 CLV $0338 50 FE BVC $0338 ; first byte after the sync mark $033A B8 CLV $033B AD 01 1C LDA $1C01 $033E 9D C3 04 STA $04C3,X ; (block ID in GCR: $52 header, $55 data) $0341 8A TXA $0342 69 04 ADC #$04 $0344 C8 INY $0345 C0 10 CPY #$10 ; 16 sync marks = 8 headers and 8 data blocks $0347 90 BE BCC $0307 $0349 A0 37 LDY #$37 ; compare the values of sync marks 1-14 $034B B9 C0 04 LDA $04C0,Y $034E D9 C8 04 CMP $04C8,Y ; with those of sync marks 3-16 $0351 D0 13 BNE $0366 ; different: try again $0353 88 DEY $0354 10 F5 BPL $034B $0356 A5 0B LDA $0B ; equal: mix a byte of the command into the checksum $0358 4D 05 02 EOR $0205 $035B 85 0B STA $0B $035D A2 80 LDX #$80 $035F 86 02 STX $02 $0361 A9 01 LDA #$01 ; job done, no error $0363 4C 69 F9 JMP $F969 $0366 C6 09 DEC $09 ; retry counter $0368 F0 F7 BEQ $0361 ; used up: end anyway $036A 4C 00 03 JMP $0300
For every sync mark four values are stored: the number of bytes since the last sync
mark (two bytes), the last byte before the sync mark and the first byte after it. As
headers and data blocks alternate, the values repeat with a period of two sync marks
on an original track. The comparison at $0349 only checks this
regularity; it does not know the expected numbers.
$0371 84 0C STY $0C ; ---- main part: checksum over the 256 bytes of this code ---- $0373 B9 00 03 LDA $0300,Y $0376 85 0D STA $0D $0378 A0 08 LDY #$08 $037A 06 0D ASL $0D $037C 6A ROR A $037D 29 80 AND #$80 $037F 45 0A EOR $0A $0381 06 0B ASL $0B $0383 2A ROL A $0384 90 0A BCC $0390 $0386 AA TAX $0387 A5 0B LDA $0B $0389 49 05 EOR #$05 $038B 85 0B STA $0B $038D 8A TXA $038E 49 80 EOR #$80 $0390 85 0A STA $0A $0392 88 DEY $0393 D0 E5 BNE $037A $0395 A4 0C LDY $0C $0397 C8 INY $0398 D0 D7 BNE $0371 $039A 84 07 STY $07 $039C 4D 06 02 EOR $0206 ; mix in another byte of the command $039F 85 0A STA $0A $03A1 A9 E0 LDA #$E0 ; run the job at $0300 (EXECUTE) on the track to check $03A3 20 1E 02 JSR $021E $03A6 B0 F9 BCS $03A1 $03A8 A5 02 LDA $02 $03AA 30 FC BMI $03A8 $03AC A0 1D LDY #$1D ; clear the command buffer $03AE 99 00 02 STA $0200,Y $03B1 88 DEY $03B2 10 FA BPL $03AE $03B4 C8 INY $03B5 B9 00 05 LDA $0500,Y ; the 256 bytes at $0500 are decrypted with $03B8 59 C0 04 EOR $04C0,Y ; the measured values ($04C0...) and $03BB 59 00 03 EOR $0300,Y ; this code ($0300...) $03BE 99 00 05 STA $0500,Y $03C1 C8 INY $03C2 D0 F1 BNE $03B5 $03C4 A9 12 LDA #$12 ; track for the job table afterwards (see the versions) $03C6 85 06 STA $06 $03C8 85 08 STA $08 $03CA 84 09 STY $09 $03CC 85 0A STA $0A $03CE 84 0B STY $0B $03D0 A9 80 LDA #$80 ; read job: move the head there $03D2 85 01 STA $01 $03D4 4C 1E 02 JMP $021E ; wait for the job, back to DOS
- The checksum runs over the drive program itself, so a patched program changes the key as well.
- The 256 bytes at
$0500are game code. There is no compare-and-branch on the C64 side that could be patched; a wrong measurement gives wrong code. - The area behind the program (from
$03D7) holds a text and filler bytes that also go into the checksum.
Versions
The program was decrypted from all 191 images that contain it. Apart from the text only two bytes differ:
| Byte | Values | Meaning |
|---|---|---|
$0311 |
EA or AE |
Three NOP in the counting loop, or LDX $EAEA (same length, two cycles shorter)
|
$03C5 |
$12 (18) or another track number |
The track that is entered into the job table after the check. With the value 18 the checked track is chosen by the routine that the game sends. In the versions with another value it is the number of the track that the release checks (5, 9, 13 to 17, 19, 20 or 21). |
Text at $03D7 |
NEW TWIST, HI MIKE!, I'M BEN!!, LATER!!!, OLD HAT!, WHATS NEW |
HI MIKE! is by far the most common. Some titles overwrite the text with data.
|
$0311 |
$03C5 |
Titles |
|---|---|---|
EA |
18 | Fairlight, Bop'n Wrestle, Dark Castle, Future Knight, Implosion, Indoor Sports, Kid Niki: Radical Ninja, Leviathan, SuperStar Soccer, Tetris, The World's Greatest Baseball Game, Thinking Cap, Where in the World Is Carmen Sandiego?, Winter Challenge, Wizball |
AE |
18 | 4th & Inches, Arcade Double Feature!, Bop'n Wrestle, Cauldron I & II, Commando, Express Raider, Gateway to Apshai, Ikari Warriors, Indoor Sports, Infiltrator, Jumpman Junior, Karateka, Kung-Fu Master, Lode Runner, Magnetron, Paradroid, Pitstop, Rambo: First Blood Part II, Rush'n Attack / Yie Ar Kung-Fu, Speed Buggy, Superbike Challenge, Top Gun, Uridium, Where in the USA Is Carmen Sandiego? |
EA |
19 | 1943: The Battle of Midway, Batman, Boot Camp, Cabal, Centauri Alliance, Forgotten Worlds, Frightmare, Ikari Warriors II: Victory Road, Mini-Putt, OutRun, Platoon, Where in Europe is Carmen Sandiego? |
AE |
17 | 007: Licence to Kill, 1943: The Battle of Midway, Arcade Game Construction Kit, Bad Dudes, Batman: The Caped Crusader, Bubble Ghost, Life Force, Maniac Mansion, RoboCop, Shoot-'Em-Up Construction Kit, Star Wars, The Cycles, Warlock |
AE |
16 | Jackal, Rolling Thunder, SimCity, Space Harrier |
| other | 5, 9, 13, 14, 15, 20, 21 | Mutants and Platoon (5), Tank and The Great Escape (9), Street Fighter (13), Mental Blocks (14), Jet-Boys (15), Karnov and Pac-Man (Thunder Mountain) (20), Star Control (21) |
Plasmatron and Tag Team Wrestling contain a changed program. Karate Champ uses a related check that compares the values of the first sector with those of the following sectors instead of using them as a key; it was not found by this scan.
Copying
- A sector copy on a disk formatted by a 1541 has other gap lengths and gap bytes, so the key is wrong. The game then crashes or shows a black screen.
- Only the checked track has to match. A copy that takes this track unchanged from the original and all other tracks as sectors runs (tested on Fairlight with track 19).
- Fairlight also runs when all tracks are rotated against each other, so the position of the tracks is not checked.
Verification on this wiki
- The sector data of all G64 images on the wiki (9084 files) was searched for the encrypted program. The search is independent of the start value of the encryption. It finds 191 images of 81 releases.
- Under VICE the program was stopped at the end of the measurement on Fairlight (track 19) and Infiltrator (track 16).
- The track numbers in the Protection fields of the releases were found before by exchanging single tracks between the original and a sector copy. For the versions with a track number at
$03C5they agree with that number in nearly all cases. - On some releases the program is on the disk, but the page lists another protection or none (Arcade Game Construction Kit, Bubble Ghost, Dark Castle, Future Knight, Jet-Boys, Tank, Tetris). Whether these releases run it was not checked.
Pages that refer to this protection
- Top Gun (← links)
- Descriptions of old disk copy protections (← links)
- Bop'n Wrestle (← links)
- The Cycles (← links)
- Jet-Boys (← links)
- Mindscape Protection (← links)
- Platoon (← links)
- SuperStar Soccer (← links)
- 007: Licence to Kill (← links)
- Infiltrator (← links)
- Frightmare (← links)
- Rolling Thunder (← links)
- Mutants (← links)
- Indoor Sports (← links)
- Ikari Warriors (← links)
- Cabal (← links)
- Maniac Mansion (← links)
- Batman: The Caped Crusader (← links)
- Batman (← links)
- SimCity (← links)
- Paradroid (← links)
- Uridium (← links)
- Kung-Fu Master (← links)
- Shoot-'Em-Up Construction Kit (← links)
- 1943: The Battle of Midway (← links)
- Commando (← links)
- Forgotten Worlds (← links)
- Leviathan (← links)
- Magnetron (← links)
- Plasmatron (← links)
- Rambo: First Blood Part II (← links)
- Express Raider (← links)
- Where in Europe is Carmen Sandiego? (← links)
- RoboCop (← links)
- Mini-Putt (← links)
- Lode Runner (← links)
- Pac-Man (← links)
- Karnov (← links)
- Jumpman Junior (← links)
- Star Wars (← links)
- OutRun (NTSC) (← links)
- Star Control (← links)
- Implosion (← links)
- The Great Escape (← links)
- Winter Challenge: World Class Competition (← links)
- Wizball (← links)
- Warlock (← links)
- 4th & Inches (← links)
- Arcade Double Feature! (← links)
- Bad Dudes (← links)