CYAN Loader V1: Difference between revisions

From Software Archive
Jump to navigation Jump to search
No edit summary
Description of the CYAN Loader protection (loader, check, disk signature, failure, variants, emulation)
Line 1: Line 1:
track 40
The CYAN Loader is a fast loader with a built-in disk protection, used from 1985 to 1991 on releases by Gremlin Graphics, U.S. Gold and others. There are two generations of the protection check:


==== Pages that refer to this protection ====
* '''[[CYAN Loader V1]]''' (1985-1987): a signature byte in the gap after sector 16 of '''track 40'''. Described on this page.
* '''[[CYAN Loader V2]]''' (1987-1991): unstable bits (weak bits) after sector 1 of '''track 32'''. The signature on the disk comes in two layouts, [[CYAN Loader A]] and [[CYAN Loader B]].
 
Both generations use the same loader frame. Only the check itself and the disk signature differ.
 
== Loader ==
 
The boot file loads a small routine into a drive buffer (block-buffer commands <code>#</code> / <code>B-</code>), which reads further code from the disk:
 
# '''Stage 1''' (track 5 sector 5) runs at $0300 in the drive. It decrypts itself (EOR with $38 and $39, the DOS block marks $07 and $08, i.e. key $0F), reads '''track 3 sector 0''' into buffer $0400, decrypts it the same way and runs it.
# '''Stage 2''' (track 3 sector 0) performs the protection check and returns the result in $3B.
# If the check passed, stage 1 continues with track 2 sector 0 (the actual loader). Otherwise it loads track 5 sector 7.
# The loader then uploads the fast loader into the drive (more <code>#</code> / <code>B-</code> blocks, started with <code>M-E</code> at $07A8) and loads the program.
 
The check runs once when the program is loaded.
 
== Disk signature ==
 
* Track 40 is a fully formatted track with 17 sectors and the normal disk ID. On most disks it is recorded at the bit rate of speed zone 2 (3.50 µs per bit, as on tracks 18-24); on some (e.g. [[Infiltrator]], [[Jack the Nipper]], [[Superstar Ping Pong]], [[Parallax]], [[Knight Rider]], [[BreakThru]]) at about 3.2 µs per bit. G64 images of these disks have a track 40 of about 7800 bytes.
* In the gap after the data block of '''sector 16''', the first six gap bytes are the usual $55, followed by bytes '''$56''' instead of $55. Counted from the end of the data block sync, GCR bytes 326-331 are $55 and bytes 332-336 are $56. Some disks have <code>6B 5A D6 56 56</code> at bytes 332-336 instead; byte 335 is $56 in every case.
 
The zone 2 rate is not an extra trick. The 1541 DOS selects zone 0 for tracks 31-35, but for tracks 36 and above its table lookup at $F33C runs past the end of the table and sets the zone bits to 2. A real 1541 therefore reads track 40 at the zone 2 rate, matching the recording.
 
== Check ==
 
Stage 2 runs an EXECUTE job ($E0) for track 40 sector 16:
 
<pre>
JSR $F50A          find the header of 40/16 and wait for the data block sync (leaves Y = 0)
read 256 + 76 + 3 GCR bytes without decoding them
CMP #$56          byte 335 after the sync must be $56 (the 10th byte of the gap)
-> $3B = 1 and back to the job loop; otherwise LED on and an endless loop in the drive
</pre>
 
== If the check fails ==
 
The drive turns the LED on and hangs in an endless loop. The screen stays black and the computer waits forever. Nothing is written to the disk. Tested in VICE with a G64 where the $56 bytes were replaced by $55.
 
== Variants ==
 
All releases use identical stage 2 code. Variants found in stage 1 (track 5 sector 5):
* The common version reads stage 2 from track 3 sector 0 and continues with track 2 sector 0.
* [[Go For the Gold]]: stage 2 is on track 5 sector 4, and the loader continues with track 5 sector 6.
* [[Leviathan]]: the result of the check is ignored (the branch is replaced by two NOPs), so the program loads even without the signature.
* [[Beyond the Forbidden Forest]] (source 2): track 40 check combined with the stage 1 of [[CYAN Loader V2]].
 
== Emulation ==
 
G64 images that contain track 40 work in VICE (tested with VICE 3.10). The check is deterministic and passes on the first read. A D64, or a G64 without track 40, hangs at the black screen.
 
The check is relative to the data block sync of sector 16, so it does not depend on the angular position of track 40 in the G64.
 
On a real 1541 the check passes deterministically as well. This was simulated from the KryoFlux streams with a model of the 1541 read electronics: at the zone 2 rate the header is found and byte 335 is $56 every time, also for the disks recorded at about 3.2 µs. All 49 disk sides with a track 40 signature in the streams show $56 at byte 335 in every revolution.
 
== Pages that refer to this protection ==


{{Special:Whatlinkshere/CYAN Loader V1}}
{{Special:Whatlinkshere/CYAN Loader V1}}

Revision as of 08:33, 9 November 2026

The CYAN Loader is a fast loader with a built-in disk protection, used from 1985 to 1991 on releases by Gremlin Graphics, U.S. Gold and others. There are two generations of the protection check:

  • CYAN Loader V1 (1985-1987): a signature byte in the gap after sector 16 of track 40. Described on this page.
  • CYAN Loader V2 (1987-1991): unstable bits (weak bits) after sector 1 of track 32. The signature on the disk comes in two layouts, CYAN Loader A and CYAN Loader B.

Both generations use the same loader frame. Only the check itself and the disk signature differ.

Loader

The boot file loads a small routine into a drive buffer (block-buffer commands # / B-), which reads further code from the disk:

  1. Stage 1 (track 5 sector 5) runs at $0300 in the drive. It decrypts itself (EOR with $38 and $39, the DOS block marks $07 and $08, i.e. key $0F), reads track 3 sector 0 into buffer $0400, decrypts it the same way and runs it.
  2. Stage 2 (track 3 sector 0) performs the protection check and returns the result in $3B.
  3. If the check passed, stage 1 continues with track 2 sector 0 (the actual loader). Otherwise it loads track 5 sector 7.
  4. The loader then uploads the fast loader into the drive (more # / B- blocks, started with M-E at $07A8) and loads the program.

The check runs once when the program is loaded.

Disk signature

  • Track 40 is a fully formatted track with 17 sectors and the normal disk ID. On most disks it is recorded at the bit rate of speed zone 2 (3.50 µs per bit, as on tracks 18-24); on some (e.g. Infiltrator, Jack the Nipper, Superstar Ping Pong, Parallax, Knight Rider, BreakThru) at about 3.2 µs per bit. G64 images of these disks have a track 40 of about 7800 bytes.
  • In the gap after the data block of sector 16, the first six gap bytes are the usual $55, followed by bytes $56 instead of $55. Counted from the end of the data block sync, GCR bytes 326-331 are $55 and bytes 332-336 are $56. Some disks have 6B 5A D6 56 56 at bytes 332-336 instead; byte 335 is $56 in every case.

The zone 2 rate is not an extra trick. The 1541 DOS selects zone 0 for tracks 31-35, but for tracks 36 and above its table lookup at $F33C runs past the end of the table and sets the zone bits to 2. A real 1541 therefore reads track 40 at the zone 2 rate, matching the recording.

Check

Stage 2 runs an EXECUTE job ($E0) for track 40 sector 16:

JSR $F50A          find the header of 40/16 and wait for the data block sync (leaves Y = 0)
read 256 + 76 + 3 GCR bytes without decoding them
CMP #$56           byte 335 after the sync must be $56 (the 10th byte of the gap)
-> $3B = 1 and back to the job loop; otherwise LED on and an endless loop in the drive

If the check fails

The drive turns the LED on and hangs in an endless loop. The screen stays black and the computer waits forever. Nothing is written to the disk. Tested in VICE with a G64 where the $56 bytes were replaced by $55.

Variants

All releases use identical stage 2 code. Variants found in stage 1 (track 5 sector 5):

  • The common version reads stage 2 from track 3 sector 0 and continues with track 2 sector 0.
  • Go For the Gold: stage 2 is on track 5 sector 4, and the loader continues with track 5 sector 6.
  • Leviathan: the result of the check is ignored (the branch is replaced by two NOPs), so the program loads even without the signature.
  • Beyond the Forbidden Forest (source 2): track 40 check combined with the stage 1 of CYAN Loader V2.

Emulation

G64 images that contain track 40 work in VICE (tested with VICE 3.10). The check is deterministic and passes on the first read. A D64, or a G64 without track 40, hangs at the black screen.

The check is relative to the data block sync of sector 16, so it does not depend on the angular position of track 40 in the G64.

On a real 1541 the check passes deterministically as well. This was simulated from the KryoFlux streams with a model of the 1541 read electronics: at the zone 2 rate the header is found and byte 335 is $56 every time, also for the disks recorded at about 3.2 µs. All 49 disk sides with a track 40 signature in the streams show $56 at byte 335 in every revolution.

Pages that refer to this protection