Mountain Valley Software — Australian made text adventure 1981–1987 — tribute site

Copy protection

How Mountain Valley’s Commodore 64 disks were protected: a damaged track, a loader that checks for the damage, and a scrambled game.

The scheme

The disk releases used a protection written by Peter K, who signs himself P.G.K. It has three parts: a deliberately altered track 35, a compiled loader that checks for the alteration, and a main program stored in scrambled form. His master disk of tools and notes survives (below), and so does a 2017 account of how to remaster a disk with it, by Marcus.

Track 35

Two programs on the master disk, DOS and DOS-M/L, rewrite track 35 of the game disk. In the master disk’s own words, they change “the track number to track 36”, changing “the header information”, and alter “the density”. A normal 1541 read of track 35 then fails, and that failure is the signature the loader looks for. A standard copier reproduces the readable data but not the damage. DOS is a program compiled with Blitz!, and DOS-M/L is its machine-code helper.

The loader

The first file on a game disk is the loader, named after the game and compiled with Petspeed. It checks track 35 for the expected error, then loads four data files. Marcus records two versions of it. The retail loader has red text and retries indefinitely if the signature is missing. The one on the master disk, MV.NEW.LOAD, has white text and aborts the load instead, and only that one worked for remastering.

The game files

Each game disk carries four sequential files, listed in the master disk’s PROTECT.INFO:

FileLoads atWhat it is
CODE1$8C00Colour for the loading picture — “COLOR RAM” in the notes, though at this address it is the bitmap’s screen matrix
CODE2$A000The hi-res loading picture
CODE3$0801The game itself, scrambled
CODE4$C000The routine that unscrambles it

The scrambler

MAKE.CODE3 “will create a scrambled version of the main program”. It initialises its machine code with SYS 2664 ($0A68), asks for the filename twice and refuses to go on unless the two match, then pokes the name into memory from $C001 and its length into $C141 (49473). It asks for the source disk and calls SYS 49472 ($C140), which writes the scrambled CODE3. The note in its header warns that “the system will cold start when finished”.

The hardening notes

Four files on the master disk are notes written as REM lines, apparently meant to be merged into each game’s BASIC:

  • LINES.-5.BAS — a five-line header, “written by Mountain Valley, protection by P.G.K”. It disables RUN/STOP and RESTORE, sets the border and background black, prints PLEASE STAND BY., clears $C000–$CFFF, and switches to the upper-case character set (POKE 53272,21).
  • RUN/RES.INFO — POKE 808,234 and POKE 792,193 disable the RUN/STOP and RESTORE keys. The first changes the low byte of the STOP vector and the second points NMI at an RTI at $FEC1. Use them, the note says, “as soon as possible at start of any BASIC program”.
  • KEYBRD.INFO — POKE 56333,127 turns the keyboard off by stopping CIA 1’s interrupts, and POKE 56333,129 turns it back on. Use it around disk access in BASIC, “else DEVICE NOT PRESENT errors break program if the drive is turned off”.
  • DOS.INFO and PROTECT.INFO — the track 35 and file notes quoted above.

The master disk

Peter K’s toolkit, a disk headed MOUNTAIN VALLEY with 574 blocks free: DOS (27 blocks), DOS-M/L (12), MV.NEW.LOAD (36), MAKE.CODE3 (7) and LINES.-5.BAS (7), then KEYBRD.INFO, RUN/RES.INFO and DOS.INFO (2 each) and PROTECT.INFO (1), divided by two empty DEL entries. The disk image itself is not on this site; these are screenshots of its files listed in an emulator.

Emulator windows listing the master disk's directory and each of its programs: dos, mv.new.load, lines.-5.bas, make.code3, dos.info, protect.info, keybrd.info and runres.info
The master disk’s directory, with each program and note listed. Open the image to read it full size.

The sign-off

The protection carries a message from its author, in among its data:

“Disk protection by Peter K. Lots of luck pal its pretty simple if you think a little harder. Dont give up theres a back door to everything. Just keep looking. — P.G.K”

C64 screen reading: Disk protection by Peter K. Lots of luck pal its pretty simple if you think a little harder. Dont give up theres a back door to everything. Just keep looking. P.G.K
The message as captured. Where on the disk it sits is not recorded with the screenshot.

Several of the Commodore 64 loading screens are signed “P.K.” in the corner, and since the loader is what displays them, the protection’s author is an obvious candidate for having drawn them. Nothing yet shows that they are the same person.

On the disks here

The Mermaid and the Crown is the one protected original on this site, kept as a track-level .g64 because a .d64 cannot hold the damage. Read directly, it matches the scheme above. Its first file is a loader named MERMAID, 36 blocks, the same size as MV.NEW.LOAD. The four CODE files follow it. Every sector header on track 35 claims to be track 36. And the directory sector at track 18, sector 1 links to itself.

The other fourteen original disks here are not in this form. Each holds the game as a single program, with no loader and no CODE files, beside the zero-block (C) BRIAN BETTS entry. How they came to be that way is not recorded.

Remastering, 2017

Marcus’s process for making a working protected disk again, from his notes of May 2017. It is summarised here as he gives it and has not been repeated for this site.

  1. Dump the originals with nibtools (nibread, then nibconv to .g64) using a ZoomFloppy and a parallel-modified 1541. The .g64 keeps the protection and runs in VICE and CCS64.
  2. Build a new .d64 in DirMaster. Copy CODE1–CODE4 from the original game disk, and MV.NEW.LOAD from the master disk, renamed to the game’s short name.
  3. Write it to a real floppy with nibwrite.
  4. On a C64, run DOS from the master disk. It alters track 35 of the game disk.
  5. With a sector editor (Di-Sector), change bytes 0–1 of track 18, sector 1 from 00 FF to 12 01. That makes the first directory sector point to itself, track 18 sector 1, as it does on The Mermaid and the Crown.