CYAN Loader V2: Difference between revisions

From Software Archive
Jump to navigation Jump to search
Created page with "Descriptions needs to be done. ==== Pages that refer to this protection ==== {{Special:Whatlinkshere/CYAN Loader V2}}"
 
Description of the CYAN Loader protection (loader, check, disk signature, failure, variants, emulation)
Line 1: Line 1:
Descriptions needs to be done.
Second generation of the CYAN Loader protection (1987-1991). The loader frame is the same as in [[CYAN Loader V1]], but the check uses '''unstable bits (weak bits) on track 32''' instead of a signature on track 40.


==== Pages that refer to this protection ====
The weak area is placed in one of two layouts. They are described on their own pages:
* [[CYAN Loader A]]: the weak area overwrites the end of the data block of track 32 sector 1. This is by far the most common layout.
* [[CYAN Loader B]]: the data block of track 32 sector 1 is intact, and the weak area follows after the gap.
 
The drive code is identical for both layouts. A release whose layout is unknown (no flux streams available) links to this page.
 
== Loader ==
 
As in [[CYAN Loader V1]]: stage 1 (track 5 sector 5) is decrypted with key $0F and runs at $0300 in the drive. It reads and decrypts stage 2 from track 3 sector 0 and continues with track 2 sector 0 if the check passed, or with track 5 sector 7 otherwise.
 
Before stage 2 starts, the loader sets the high byte of VIA timer 1 ($1C05) to $10, which shortens the interval of the drive's job interrupt.
 
== Disk signature ==
 
* Track 32 is a normal zone 0 track. Sector 1 is an empty block (format pattern $4B $01 $01 ...). At the end of its data block there is an area of several bytes in which the flux transitions do not form valid bits. On every read the drive gets different bits there.
* A G64 cannot hold unstable bits. In G64 images converted with DTC, the area is stored as a run of zero bits (no flux transitions). VICE evidently reads such runs as random bits: the same G64 gives different data on different reads.
 
== Check ==
 
Stage 2 repeats up to 4 rounds:
 
<pre>
JSR $D042          initialise the drive (reads the BAM on track 18, the head moves away)
EXECUTE job for track 32 sector 1:
  JSR $F50A        find the header of 32/1 and wait for the data block sync
  read 256 + 76 GCR bytes, then bytes 333-339 into $0500
  X1 = byte 335 EOR byte 336 EOR byte 337
initialise the drive and read 32/1 again the same way -> X2
X1 <> X2          -> $3B = 1: check passed
X1 = X2            -> next round; after 4 equal rounds $3B = 0: check failed
</pre>
 
So the check does not look for a particular value. It requires that '''two consecutive reads of the same place give different data'''. A copy written with a normal copier has regular bits there and gives the same data every time.
 
== If the check fails ==
 
The loader continues with track 5 sector 7 instead of the program, and the C64 resets to the start screen. Nothing is written to the disk. Tested in VICE with a G64 where the weak area was replaced by regular $55 bytes: 4 rounds with equal data (8 reads), then reset.
 
== Variants ==
 
Stage 2 is identical in all releases, except [[Arcade Force Four]] (disk 1 side 1), which uses the value $10 instead of 1 for "passed" (stage 1 and stage 2 changed accordingly). Stage 1 exists in a version in which the result of the check is ignored: [[Basil the Great Mouse Detective]] (all three sources) and [[10 Great Games II]] (disk 1 side 1) load without checking the signature that is on the disk.
 
On several disks the signature is present but the program does not check it:
* the second side of releases that boot from the first side only, e.g. [[Moonwalker]] side 1: the signature is there, but the side has no loader, and the resident fast loader in the drive does not check track 32;
* [[Shirley Muldowney's Top Fuel Challenge]]: the disk has the signature, but the program uses a different loader.
 
== Emulation ==
 
G64 images work in VICE (tested with VICE 3.10). Because VICE generates the random bits from the zero run in the G64, the number of rounds varies from start to start. With some images two reads occasionally give the same data, so a start can fail; reset and load again. Measured in VICE (6 starts each): [[10 Great Games III]] needed 1-3 rounds, [[Rick Dangerous]] 1-4 rounds. That corresponds to roughly 1 % and 13 % failed starts.
 
How reliable the check is on a real 1541 could only be estimated. Simulations from the KryoFlux streams with a model of the 1541 read electronics depend strongly on how much analog noise is assumed in the weak area:
* layout B passes in practically every start in all models;
* layout A passes in most starts for most disks, but some disks give equal data more often, so a start can fail now and then.
 
Exact figures need a test on real hardware.
 
== Pages that refer to this protection ==


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

Revision as of 08:33, 9 November 2026

Second generation of the CYAN Loader protection (1987-1991). The loader frame is the same as in CYAN Loader V1, but the check uses unstable bits (weak bits) on track 32 instead of a signature on track 40.

The weak area is placed in one of two layouts. They are described on their own pages:

  • CYAN Loader A: the weak area overwrites the end of the data block of track 32 sector 1. This is by far the most common layout.
  • CYAN Loader B: the data block of track 32 sector 1 is intact, and the weak area follows after the gap.

The drive code is identical for both layouts. A release whose layout is unknown (no flux streams available) links to this page.

Loader

As in CYAN Loader V1: stage 1 (track 5 sector 5) is decrypted with key $0F and runs at $0300 in the drive. It reads and decrypts stage 2 from track 3 sector 0 and continues with track 2 sector 0 if the check passed, or with track 5 sector 7 otherwise.

Before stage 2 starts, the loader sets the high byte of VIA timer 1 ($1C05) to $10, which shortens the interval of the drive's job interrupt.

Disk signature

  • Track 32 is a normal zone 0 track. Sector 1 is an empty block (format pattern $4B $01 $01 ...). At the end of its data block there is an area of several bytes in which the flux transitions do not form valid bits. On every read the drive gets different bits there.
  • A G64 cannot hold unstable bits. In G64 images converted with DTC, the area is stored as a run of zero bits (no flux transitions). VICE evidently reads such runs as random bits: the same G64 gives different data on different reads.

Check

Stage 2 repeats up to 4 rounds:

JSR $D042          initialise the drive (reads the BAM on track 18, the head moves away)
EXECUTE job for track 32 sector 1:
  JSR $F50A        find the header of 32/1 and wait for the data block sync
  read 256 + 76 GCR bytes, then bytes 333-339 into $0500
  X1 = byte 335 EOR byte 336 EOR byte 337
initialise the drive and read 32/1 again the same way -> X2
X1 <> X2           -> $3B = 1: check passed
X1 = X2            -> next round; after 4 equal rounds $3B = 0: check failed

So the check does not look for a particular value. It requires that two consecutive reads of the same place give different data. A copy written with a normal copier has regular bits there and gives the same data every time.

If the check fails

The loader continues with track 5 sector 7 instead of the program, and the C64 resets to the start screen. Nothing is written to the disk. Tested in VICE with a G64 where the weak area was replaced by regular $55 bytes: 4 rounds with equal data (8 reads), then reset.

Variants

Stage 2 is identical in all releases, except Arcade Force Four (disk 1 side 1), which uses the value $10 instead of 1 for "passed" (stage 1 and stage 2 changed accordingly). Stage 1 exists in a version in which the result of the check is ignored: Basil the Great Mouse Detective (all three sources) and 10 Great Games II (disk 1 side 1) load without checking the signature that is on the disk.

On several disks the signature is present but the program does not check it:

  • the second side of releases that boot from the first side only, e.g. Moonwalker side 1: the signature is there, but the side has no loader, and the resident fast loader in the drive does not check track 32;
  • Shirley Muldowney's Top Fuel Challenge: the disk has the signature, but the program uses a different loader.

Emulation

G64 images work in VICE (tested with VICE 3.10). Because VICE generates the random bits from the zero run in the G64, the number of rounds varies from start to start. With some images two reads occasionally give the same data, so a start can fail; reset and load again. Measured in VICE (6 starts each): 10 Great Games III needed 1-3 rounds, Rick Dangerous 1-4 rounds. That corresponds to roughly 1 % and 13 % failed starts.

How reliable the check is on a real 1541 could only be estimated. Simulations from the KryoFlux streams with a model of the 1541 read electronics depend strongly on how much analog noise is assumed in the weak area:

  • layout B passes in practically every start in all models;
  • layout A passes in most starts for most disks, but some disks give equal data more often, so a start can fail now and then.

Exact figures need a test on real hardware.

Pages that refer to this protection