<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://preservation64.de/index.php?action=history&amp;feed=atom&amp;title=Sector_Gap_Check</id>
	<title>Sector Gap Check - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://preservation64.de/index.php?action=history&amp;feed=atom&amp;title=Sector_Gap_Check"/>
	<link rel="alternate" type="text/html" href="https://preservation64.de/index.php?title=Sector_Gap_Check&amp;action=history"/>
	<updated>2026-11-22T18:05:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://preservation64.de/index.php?title=Sector_Gap_Check&amp;diff=85661&amp;oldid=prev</id>
		<title>Enigma: New protection page: gap check drive program used by about 80 releases (formerly described under Data East Protection / Mindscape Protection)</title>
		<link rel="alternate" type="text/html" href="https://preservation64.de/index.php?title=Sector_Gap_Check&amp;diff=85661&amp;oldid=prev"/>
		<updated>2026-11-22T17:30:58Z</updated>

		<summary type="html">&lt;p&gt;New protection page: gap check drive program used by about 80 releases (formerly described under Data East Protection / Mindscape Protection)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Sector Gap Check =&lt;br /&gt;
&lt;br /&gt;
This analysis is based on the state of the wiki from 23 Nov 2026.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Sector Gap Check&amp;#039;&amp;#039;&amp;#039; is a disk check found on about 80 releases on this wiki, most of them&lt;br /&gt;
US releases from 1986 to 1990 by many publishers (Data East, Brøderbund, Epyx, Mindscape,&lt;br /&gt;
Capcom, Accolade, Maxis and others). The disks contain only standard CBM DOS sectors&lt;br /&gt;
without read errors, so a sector copy can be made, but it does not run.&lt;br /&gt;
&lt;br /&gt;
In short: &amp;#039;&amp;#039;&amp;#039;a small drive program measures the gaps between the blocks of one track.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
It counts the bytes from each sync mark to the next one and notes the bytes directly&lt;br /&gt;
before and after the sync mark. The numbers are not compared with fixed values. They&lt;br /&gt;
are part of the key that decrypts 256 bytes of the game, which the C64 then fetches&lt;br /&gt;
from the drive. On a disk with other gaps the game gets garbage.&lt;br /&gt;
&lt;br /&gt;
The check relies on how the disks were mastered. On the originals all gaps of a track&lt;br /&gt;
have exactly the same length, and they are filled with a pattern that decodes as&lt;br /&gt;
&amp;lt;code&amp;gt;$00&amp;lt;/code&amp;gt; bytes, where the 1541 writes &amp;lt;code&amp;gt;$55&amp;lt;/code&amp;gt;. A 1541 that rewrites a&lt;br /&gt;
sector leaves a different gap behind it.&lt;br /&gt;
&lt;br /&gt;
== The drive program ==&lt;br /&gt;
&lt;br /&gt;
The drive program is 256 bytes long and stored in one sector of the disk, mostly on&lt;br /&gt;
track 18. The sector is encrypted: every byte is the EOR of a program byte with the&lt;br /&gt;
program byte before it; the start value differs from title to title. The game lets&lt;br /&gt;
the drive read this sector to &amp;lt;code&amp;gt;$0300&amp;lt;/code&amp;gt;, sends a short routine that decrypts&lt;br /&gt;
it and jumps to &amp;lt;code&amp;gt;$0371&amp;lt;/code&amp;gt;, and afterwards reads the result with&lt;br /&gt;
&amp;lt;code&amp;gt;M-R&amp;lt;/code&amp;gt; from &amp;lt;code&amp;gt;$0500&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The measuring part runs as an EXECUTE job on the track to check (from Fairlight;&lt;br /&gt;
decrypted from track 19 sector 11):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$0300  20 0A F5   JSR $F50A      ; ROM: find the header of the sector in the job table, wait for the data sync&lt;br /&gt;
$0303  98         TYA&lt;br /&gt;
$0304  50 FE      BVC $0304      ; skip two bytes&lt;br /&gt;
$0306  B8         CLV&lt;br /&gt;
$0307  50 FE      BVC $0307&lt;br /&gt;
$0309  84 85      STY $85        ; ($85 = 0: counter of the sync marks)&lt;br /&gt;
$030B  85 0C      STA $0C&lt;br /&gt;
$030D  A0 00      LDY #$00       ; byte counter low (Y) and high ($0D)&lt;br /&gt;
$030F  84 0D      STY $0D&lt;br /&gt;
$0311  EA         NOP            ; 3 NOP; later versions: LDX $EAEA&lt;br /&gt;
$0312  EA         NOP&lt;br /&gt;
$0313  EA         NOP&lt;br /&gt;
$0314  B8         CLV&lt;br /&gt;
$0315  AE 00 1C   LDX $1C00      ; sync mark?&lt;br /&gt;
$0318  10 0C      BPL $0326      ; yes: end of the block&lt;br /&gt;
$031A  50 FE      BVC $031A      ; wait for the next byte&lt;br /&gt;
$031C  AD 01 1C   LDA $1C01      ; A = last byte read&lt;br /&gt;
$031F  C8         INY            ; count it&lt;br /&gt;
$0320  D0 EF      BNE $0311&lt;br /&gt;
$0322  E6 0D      INC $0D&lt;br /&gt;
$0324  D0 EE      BNE $0314&lt;br /&gt;
$0326  A6 0C      LDX $0C        ; X = index into the table&lt;br /&gt;
$0328  9D C2 04   STA $04C2,X    ; last byte before the sync mark (gap byte)&lt;br /&gt;
$032B  98         TYA&lt;br /&gt;
$032C  9D C0 04   STA $04C0,X    ; number of bytes, low&lt;br /&gt;
$032F  A5 0D      LDA $0D&lt;br /&gt;
$0331  9D C1 04   STA $04C1,X    ; number of bytes, high&lt;br /&gt;
$0334  18         CLC&lt;br /&gt;
$0335  A4 85      LDY $85&lt;br /&gt;
$0337  B8         CLV&lt;br /&gt;
$0338  50 FE      BVC $0338      ; first byte after the sync mark&lt;br /&gt;
$033A  B8         CLV&lt;br /&gt;
$033B  AD 01 1C   LDA $1C01&lt;br /&gt;
$033E  9D C3 04   STA $04C3,X    ; (block ID in GCR: $52 header, $55 data)&lt;br /&gt;
$0341  8A         TXA&lt;br /&gt;
$0342  69 04      ADC #$04&lt;br /&gt;
$0344  C8         INY&lt;br /&gt;
$0345  C0 10      CPY #$10       ; 16 sync marks = 8 headers and 8 data blocks&lt;br /&gt;
$0347  90 BE      BCC $0307&lt;br /&gt;
$0349  A0 37      LDY #$37       ; compare the values of sync marks 1-14&lt;br /&gt;
$034B  B9 C0 04   LDA $04C0,Y&lt;br /&gt;
$034E  D9 C8 04   CMP $04C8,Y    ; with those of sync marks 3-16&lt;br /&gt;
$0351  D0 13      BNE $0366      ; different: try again&lt;br /&gt;
$0353  88         DEY&lt;br /&gt;
$0354  10 F5      BPL $034B&lt;br /&gt;
$0356  A5 0B      LDA $0B        ; equal: mix a byte of the command into the checksum&lt;br /&gt;
$0358  4D 05 02   EOR $0205&lt;br /&gt;
$035B  85 0B      STA $0B&lt;br /&gt;
$035D  A2 80      LDX #$80&lt;br /&gt;
$035F  86 02      STX $02&lt;br /&gt;
$0361  A9 01      LDA #$01       ; job done, no error&lt;br /&gt;
$0363  4C 69 F9   JMP $F969&lt;br /&gt;
$0366  C6 09      DEC $09        ; retry counter&lt;br /&gt;
$0368  F0 F7      BEQ $0361      ; used up: end anyway&lt;br /&gt;
$036A  4C 00 03   JMP $0300&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For every sync mark four values are stored: the number of bytes since the last sync&lt;br /&gt;
mark (two bytes), the last byte before the sync mark and the first byte after it. As&lt;br /&gt;
headers and data blocks alternate, the values repeat with a period of two sync marks&lt;br /&gt;
on an original track. The comparison at &amp;lt;code&amp;gt;$0349&amp;lt;/code&amp;gt; only checks this&lt;br /&gt;
regularity; it does not know the expected numbers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$0371  84 0C      STY $0C        ; ---- main part: checksum over the 256 bytes of this code ----&lt;br /&gt;
$0373  B9 00 03   LDA $0300,Y&lt;br /&gt;
$0376  85 0D      STA $0D&lt;br /&gt;
$0378  A0 08      LDY #$08&lt;br /&gt;
$037A  06 0D      ASL $0D&lt;br /&gt;
$037C  6A         ROR A&lt;br /&gt;
$037D  29 80      AND #$80&lt;br /&gt;
$037F  45 0A      EOR $0A&lt;br /&gt;
$0381  06 0B      ASL $0B&lt;br /&gt;
$0383  2A         ROL A&lt;br /&gt;
$0384  90 0A      BCC $0390&lt;br /&gt;
$0386  AA         TAX&lt;br /&gt;
$0387  A5 0B      LDA $0B&lt;br /&gt;
$0389  49 05      EOR #$05&lt;br /&gt;
$038B  85 0B      STA $0B&lt;br /&gt;
$038D  8A         TXA&lt;br /&gt;
$038E  49 80      EOR #$80&lt;br /&gt;
$0390  85 0A      STA $0A&lt;br /&gt;
$0392  88         DEY&lt;br /&gt;
$0393  D0 E5      BNE $037A&lt;br /&gt;
$0395  A4 0C      LDY $0C&lt;br /&gt;
$0397  C8         INY&lt;br /&gt;
$0398  D0 D7      BNE $0371&lt;br /&gt;
$039A  84 07      STY $07&lt;br /&gt;
$039C  4D 06 02   EOR $0206      ; mix in another byte of the command&lt;br /&gt;
$039F  85 0A      STA $0A&lt;br /&gt;
$03A1  A9 E0      LDA #$E0       ; run the job at $0300 (EXECUTE) on the track to check&lt;br /&gt;
$03A3  20 1E 02   JSR $021E&lt;br /&gt;
$03A6  B0 F9      BCS $03A1&lt;br /&gt;
$03A8  A5 02      LDA $02&lt;br /&gt;
$03AA  30 FC      BMI $03A8&lt;br /&gt;
$03AC  A0 1D      LDY #$1D       ; clear the command buffer&lt;br /&gt;
$03AE  99 00 02   STA $0200,Y&lt;br /&gt;
$03B1  88         DEY&lt;br /&gt;
$03B2  10 FA      BPL $03AE&lt;br /&gt;
$03B4  C8         INY&lt;br /&gt;
$03B5  B9 00 05   LDA $0500,Y    ; the 256 bytes at $0500 are decrypted with&lt;br /&gt;
$03B8  59 C0 04   EOR $04C0,Y    ; the measured values ($04C0...) and&lt;br /&gt;
$03BB  59 00 03   EOR $0300,Y    ; this code ($0300...)&lt;br /&gt;
$03BE  99 00 05   STA $0500,Y&lt;br /&gt;
$03C1  C8         INY&lt;br /&gt;
$03C2  D0 F1      BNE $03B5&lt;br /&gt;
$03C4  A9 12      LDA #$12       ; track for the job table afterwards (see the versions)&lt;br /&gt;
$03C6  85 06      STA $06&lt;br /&gt;
$03C8  85 08      STA $08&lt;br /&gt;
$03CA  84 09      STY $09&lt;br /&gt;
$03CC  85 0A      STA $0A&lt;br /&gt;
$03CE  84 0B      STY $0B&lt;br /&gt;
$03D0  A9 80      LDA #$80       ; read job: move the head there&lt;br /&gt;
$03D2  85 01      STA $01&lt;br /&gt;
$03D4  4C 1E 02   JMP $021E      ; wait for the job, back to DOS&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* The checksum runs over the drive program itself, so a patched program changes the key as well.&lt;br /&gt;
* The 256 bytes at &amp;lt;code&amp;gt;$0500&amp;lt;/code&amp;gt; are game code. There is no compare-and-branch on the C64 side that could be patched; a wrong measurement gives wrong code.&lt;br /&gt;
* The area behind the program (from &amp;lt;code&amp;gt;$03D7&amp;lt;/code&amp;gt;) holds a text and filler bytes that also go into the checksum.&lt;br /&gt;
&lt;br /&gt;
== Versions ==&lt;br /&gt;
&lt;br /&gt;
The program was decrypted from all 191 images that contain it. Apart from the text&lt;br /&gt;
only two bytes differ:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Byte !! Values !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;$0311&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;EA&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;AE&amp;lt;/code&amp;gt; || Three &amp;lt;code&amp;gt;NOP&amp;lt;/code&amp;gt; in the counting loop, or &amp;lt;code&amp;gt;LDX $EAEA&amp;lt;/code&amp;gt; (same length, two cycles shorter)&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;$03C5&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;$12&amp;lt;/code&amp;gt; (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).&lt;br /&gt;
|-&lt;br /&gt;
| Text at &amp;lt;code&amp;gt;$03D7&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;NEW TWIST&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;HI MIKE!&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;I&amp;#039;M BEN!!&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;LATER!!!&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;OLD HAT!&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;WHATS NEW&amp;lt;/code&amp;gt; || &amp;lt;code&amp;gt;HI MIKE!&amp;lt;/code&amp;gt; is by far the most common. Some titles overwrite the text with data.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! &amp;lt;code&amp;gt;$0311&amp;lt;/code&amp;gt; !! &amp;lt;code&amp;gt;$03C5&amp;lt;/code&amp;gt; !! Titles&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EA&amp;lt;/code&amp;gt; || 18 || Fairlight, Bop&amp;#039;n Wrestle, Dark Castle, Future Knight, Implosion, Indoor Sports, Kid Niki: Radical Ninja, Leviathan, SuperStar Soccer, Tetris, The World&amp;#039;s Greatest Baseball Game, Thinking Cap, Where in the World Is Carmen Sandiego?, Winter Challenge, Wizball&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;AE&amp;lt;/code&amp;gt; || 18 || 4th &amp;amp; Inches, Arcade Double Feature!, Bop&amp;#039;n Wrestle, Cauldron I &amp;amp; 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&amp;#039;n Attack / Yie Ar Kung-Fu, Speed Buggy, Superbike Challenge, Top Gun, Uridium, Where in the USA Is Carmen Sandiego?&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;EA&amp;lt;/code&amp;gt; || 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?&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;AE&amp;lt;/code&amp;gt; || 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-&amp;#039;Em-Up Construction Kit, Star Wars, The Cycles, Warlock&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;AE&amp;lt;/code&amp;gt; || 16 || Jackal, Rolling Thunder, SimCity, Space Harrier&lt;br /&gt;
|-&lt;br /&gt;
| 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)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Plasmatron and Tag Team Wrestling contain a changed program. Karate Champ uses a&lt;br /&gt;
related check that compares the values of the first sector with those of the&lt;br /&gt;
following sectors instead of using them as a key; it was not found by this scan.&lt;br /&gt;
&lt;br /&gt;
== Copying ==&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* 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).&lt;br /&gt;
* Fairlight also runs when all tracks are rotated against each other, so the position of the tracks is not checked.&lt;br /&gt;
&lt;br /&gt;
== Verification on this wiki ==&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
* Under VICE the program was stopped at the end of the measurement on Fairlight (track 19) and Infiltrator (track 16).&lt;br /&gt;
* 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 &amp;lt;code&amp;gt;$03C5&amp;lt;/code&amp;gt; they agree with that number in nearly all cases.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
==== Pages that refer to this protection ====&lt;br /&gt;
&lt;br /&gt;
{{Special:Whatlinkshere/Sector Gap Check}}&lt;/div&gt;</summary>
		<author><name>Enigma</name></author>
	</entry>
</feed>