Heureka: Difference between revisions
Rewrite: the check measures the bit rate of one sector (324 bytes of T2..7/S11 and T31/S10), not the track length; drive and BASIC code, acceptance windows, variants, verified release list, corrected G64 patch limits. Based on Stephan Scheuer's analysis (forum64.de thread 83037). |
Rewrite: the check measures the bit rate of one sector (324 bytes of T2..7/S11 and T31/S10), not the track length; drive and BASIC code, acceptance windows, variants, verified release list, corrected G64 patch limits. Based on Stephan Scheuer's analysis (forum64.de thread 83037). |
||
| Line 201: | Line 201: | ||
track usually comes out too short and track 31 too long. This is the average | track usually comes out too short and track 31 too long. This is the average | ||
of the normal and the off-speed sectors. | of the normal and the off-speed sectors. | ||
== Downloads == | |||
* [[Media:Heureka-Protection.zip|Heureka-Protection.zip]]: detailed analysis (Markdown), verification results for all releases, and tools: | |||
** G64 track-length check; | |||
** per-sector speed analysis of KryoFlux streams; | |||
** a C64 harness that runs the original check routine against any image in VICE. | |||
== See also == | == See also == | ||
Revision as of 16:04, 8 November 2026
Heureka
The Heureka protection was used by Heureka-Teachware on its educational software (Learning English, Let's Go, Etudes Françaises, ALi, GEO, OPTI-MA and others). It was probably developed by Martin Pfost.
The protection doesn't use bad sectors, extra tracks or signatures. On two tracks, three sectors were written at a bit rate that none of the four 1541 speed zones uses. A 1541 reads these sectors without errors. The protection check measures how long the drive needs to read one of these sectors. A copy made with a normal copier writes every sector at the zone's nominal speed, so the measured time is wrong.
The programs are compiled BASIC (Austrospeed). The check is hidden inside the compiled program, and the drive code is stored as a BASIC string.
Disk layout
- Tracks 1–35 use the ordinary CBM DOS layout.
- Two tracks contain off-speed sectors:
- the first test track in speed zone 3: track 2, or 2 + the volume number for the numbered series (see Releases);
- track 31 in speed zone 0.
- On both tracks the pattern is the same:
| Sector | Bit cell compared with the zone's nominal value |
|---|---|
| 10 | about 7–8% longer (written slower) |
| 11 | about 4% shorter (written faster) |
| 12 | about 4% shorter (written faster) |
| all others | nominal |
- The slow and the fast sectors roughly cancel out, so the track length stays close to normal.
- All other tracks and sectors are nominal.
- Example from a KryoFlux stream of Learning English, Green Line 1, normalised to 300 rpm:
Track 3 sector 10 +7.5 % sector 11 -3.8 % sector 12 -3.5 % others nominal Track 31 sector 10 +8.0 % sector 11 -4.0 % sector 12 -4.0 % others nominal
Only the program disk is protected. Side 2 of the double-sided releases, and the additional disks of Englische Sprachübungen, have no off-speed sectors.
The check
Drive side
The C64 opens buffer 2 ($0500) and reads the sector to be
measured into it with U1. This also sets the track and sector of
the buffer's job. It then overwrites the buffer with the drive code (sent as
a BASIC string) and starts it with U5. The user vector U5 jumps
to $0506, which queues an EXECUTE job for buffer 2.
$0500 20 0A F5 JSR $F50A ; ROM: find the header of the job's sector, wait for its data block $0503 4C 10 05 JMP $0510 $0506 A9 E0 LDA #$E0 ; U5 entry: EXECUTE job ... $0508 A2 02 LDX #$02 ; ... for buffer 2 $050A 20 7D D5 JSR $D57D $050D 4C 99 D5 JMP $D599 $0510 88 DEY ; Y = $FF $0511 8C 08 18 STY $1808 ; VIA timer 2 low latch $0514 50 FE BVC $0514 ; first byte of the data block $0516 8C 09 18 STY $1809 ; start timer 2 at $FFFF (counts down, 1 MHz) $0519 B8 CLV $051A A2 02 LDX #$02 $051C A0 44 LDY #$44 $051E 20 26 FE JSR $FE26 ; ROM: wait for 324 more bytes $0521 AD 08 18 LDA $1808 $0524 AE 09 18 LDX $1809 $0527 C9 03 CMP #$03 $0529 B0 01 BCS $052C $052B E8 INX ; correct the high byte if the low byte wrapped $052C 8E 41 05 STX $0541 ; result high $052F AA TAX $0530 8E 40 05 STX $0540 ; result low $0533 4C 05 F5 JMP $F505 ; job done
The result is the time the drive needs to read 324 GCR bytes of the data block of that one sector, as a timer value (65535 − µs). It is neither the track length nor the time between two sync marks.
C64 side
The check as decompiled from Learning English, Green Line 1 (by Stephan Scheuer):
8281 mp=2+bd : m1=11 : m2=57646 :rem pass 1: first test track, sector 11 8294 if m6 then mp=31 : m1=10 : m2=54341 :rem pass 2: track 31, sector 10 8308 open1,8,15,"i" : open2,8,2,"#2" 8329 print#1,"u1 2 0";mp;m1 :rem read the sector into buffer 2 8347 m6=-(m6=0) 8352 print#2,c$; :rem drive code into buffer 2 8356 print#1,"u5" :rem run it 8367 print#1,"m-r"chr$(64)chr$(5)chr$(2) :rem read $0540/$0541 8377 get#1,a$ : get#1,b$ 8386 poke 1015,-(abs(asc(a$+chr$(0))+256*asc(b$+chr$(0))-m2)>324) or peek(1015) 8425 if m6 goto 8180 :rem second pass
bdis the volume number, taken from an ID string in the program ("eGL10…" → 1 → track 3).- The measured value must be within ±324 of a fixed reference value:
| Sector | Reference | Accepted timer values | Accepted time for 324 bytes | Nominal 1541 value |
|---|---|---|---|---|
| first test track, sector 11 | 57646 ($E12E, 7,889 µs) |
$DFEA–$E272 |
7,565–8,213 µs | 8,424 µs (zone 3) |
| track 31, sector 10 | 54341 ($D445, 11,194 µs) |
$D301–$D589 |
10,870–11,518 µs | 10,368 µs (zone 0) |
- The result goes to
$03F7(1015). It is ORed with the previous result, so a failure on either track sticks. - Both tracks are always measured.
- When the result isn't 0, the program returns to the main menu instead of continuing, for example when the vocabulary test is selected.
- The check runs in several places in the program, for example after menu selections. The two test sectors are read often and therefore wear out quickly, which is why they are often of poor quality in archived dumps.
Variants
The drive code, the reference values and the tolerance are the same in all decompiled releases. Only the BASIC around them differs:
- First test track:
2+bd(Green Line, Orange Line, Red Line, Let's Go, Etudes Françaises Courte) or fixed 2 (all others). - Result: ORed into
$03F7, or stored without OR. ALi 1000 und eins stores it in a different location. - Learning English, Modern Course Gym 5 additionally contains an encrypted machine-code check (at
$C800, protected by checksums). It only requires sector 11 to be faster than about 8,180 µs and track 31 sector 10 to be slower than about 10,830 µs.
Releases
All releases below were checked: the off-speed sectors in the KryoFlux streams, and the original drive routine run in VICE (true drive emulation) against the P64 images. Every protected disk shows the pattern described above. All 47 P64 images of the program disks pass the check.
The second test track is track 31 on all releases.
Notes:
- No streams were available for Green Line 2 and Etudes Françaises Longue 3 and 4. Their test track was taken from the G64 images.
- OPTI-MA source 1: the patch was applied to the side 2 image (
…_s1.g64, "OPTI-MA SEITE 2") instead of the program side. The file…_[patched]_s0.g64still has the original track lengths and fails the check.
Copying and imaging
- A copy made with a normal disk copier rewrites the sectors at the zone's nominal speed. Both measured times are then out of the window (about 8,420 µs and 10,370 µs).
- The KryoFlux streams of the originals pass with a margin of only about 65–150 µs on the fast sector. A drive running more than about 1% slow can therefore fail the check even with an original disk.
- P64 keeps the timing of every sector. All P64 images of the program disks pass in VICE without changes.
- G64 has one bit rate per track in VICE. The emulator spreads the bytes of a track evenly over one revolution, so the measured time depends only on the track length. A converted G64 therefore has to be patched (see below).
Patching G64 images
Note: the following only makes the check work in an emulator.
In VICE, the time for the 324 bytes is about
324 / track length × 200,000 µs + 19 µs. From the
accepted window follow these track lengths:
| Track | Accepted track length in the G64 | Recommended | Measured in VICE |
|---|---|---|---|
| first test track (2–7) | $1EE5 or longer (up to the maximum track size of the G64, usually $1EF8) |
$1EEF |
8,191–8,206 µs (limit 8,213 µs) |
| track 31 | $1604–$1752 |
$1710 |
10,981–10,996 µs |
The recommended $1EEF for the first test track passes, but with a
margin of only about 10 µs. The G64's maximum track size doesn't allow a
much longer track unless the header is changed.
Procedure with G64Conv:
- Convert the G64 to its text representation.
- The pointer to a track's data is in the G64 header at offset
$0C + (track − 1) × 8:$0014for track 2,$00FCfor track 31. The first two bytes at the position it points to are the track length (low/high). - First test track: append fill bytes (
55) to the track trail until the length is$1EEF. - Track 31: comment out fill bytes after the sector headers, the sector data and in the track trail until the length is
$1752or less, e.g.$1710. You might have to add a few1bits at the end of the track so that its bit count is divisible by 8. - Convert back to G64 and check both track lengths again, e.g. with
heureka_g64check.pyfrom the analysis archive.
When converting from KryoFlux streams or NIBs of a real disk, the first test track usually comes out too short and track 31 too long. This is the average of the normal and the off-speed sectors.
Downloads
- Heureka-Protection.zip: detailed analysis (Markdown), verification results for all releases, and tools:
- G64 track-length check;
- per-sector speed analysis of KryoFlux streams;
- a C64 harness that runs the original check routine against any image in VICE.
See also
- G64Conv
- Stephan Scheuer: "Kopierschutzverfahren gelüftet", forum64.de, thread 83037 (description of the protection, decompiled programs and cracks)
Pages that refer to this protection
- Descriptions of old disk copy protections (← links)
- Learning English, Modern Course Gym 5 (← links)
- Learning English, Orange Line 1 (← links)
- Let's Go 5 (← links)
- Learning English, Modern Course Gym 4 (← links)
- Learning English, Modern Course Gym 3 (← links)
- Learning English, Modern Course 2 (← links)
- Etudes Francaise Echanges Edition Courte 1 (← links)
- Etudes Francaise Echanges Edition Longue 2 (← links)
- Bruchtrainer (← links)
- Learning English, Modern Course Gym 6 (← links)
- Learning English, Green Line 2 (← links)
- Learning English, Green Line 3 (← links)
- Etudes Francaise Echanges Edition Longue 1 (← links)
- Etudes Francaise Echanges Edition Longue 3 (← links)
- Etudes Francaise Echanges Edition Longue 4 (← links)
- ALi: Das intelligente Algebraprogramm V4 (← links)
- ALi: Das intelligente Algebraprogramm 1000 und eins (← links)
- Let's Go 2 (← links)
- Learning English, Green Line 4 (← links)
- Learning English, Orange Line 2 (← links)
- Learning English, Red Line 1 (← links)
- Learning English, Red Line 3 (← links)
- Learning English, Modern Course 1 (← links)
- Englische Sprachübungen 2 bis 3 (← links)
- Englische Sprachübungen 4 bis 6 (← links)
- Learning English, Green Line 1 (← links)
- Let's Go 3 (← links)
- GEO-plus (← links)
- OPTI-MA (← links)
- Learning English, Red Line 4 (← links)
- Learning English, Red Line 2 (← links)
- Learning English, Red Line 5 (← links)
- Der neue Rechenmax (← links)
- GEO (← links)
- File:Heureka-Protection.zip (← links)