It’s impossible to calculate it yourself, because any programs you right will mean you get the wrong answer. The only way I can think of to get this value is to load the game as normal, and stop the game with a Multiface as soon as the timer hits 000. Then put a breakpoint at #8C35 and return. Wait a few seconds, then reactivate the Multiface and have a look at the stack. The first value will be #8C35, the second will be the value of HL you want. You should find it’s #4DBD. Carrying on the disassembly..
8C35 21 00 58 LD HL,#5800
8C38 11 01 58 LD DE,#5801
8C3B 01 FF 02 LD BC,#02FF
8C3E 36 00 LD (HL),#00
8C40 ED B0 LDIR
8C42 E1 POP HL
This clears the screen and restores the value of HL, which is used for the following decrypter.
8C43 11 60 8C LD DE,#8C60
8C46 0E 29 LD C,#29
8C48 7C LD A,H
8C49 65 LD H,L
8C4A 47 LD B,A
8C4B 09 ADD HL,BC
8C4C 1A LD A,(DE)
8C4D AD XOR L
8C4E 12 LD (DE),A
8C4F 6F LD L,A
8C50 13 INC DE
8C51 1A LD A,(DE)
8C52 AC XOR H
8C53 12 LD (DE),A
8C54 13 INC DE
8C55 CB 7A BIT 7,D
8C57 20 F0 JR NZ,#8C49
8C59 FB EI
8C5A 67 LD H,A
8C5B 11 70 71 LD DE,#7170
8C5E 19 ADD HL,DE
8C5F E9 JP (HL)
First of all, POKE #8C40, #8C41 and #8C42 with #21, #BD and #4D respectively (so you get the right value of HL), put a breakpoint at #8C5B (nearest place possible to the JP (HL) that we can place a breakpoint), and JP #8C40. On return, the value of HL is #38F5. Add this to #7170 (which is what happens in the next two commands) to get #AA65. This is the start address of the game. So put a JP to your POKEing routine (anywhere from #5B00 to #5BA0 is fine) at #8C5B, and finish your POKEs with a JP #AA65.
You will have to do a stack trace to find infinite lives in the actual game itself. There is a complete hack for this game by myself in YS #78, so why not disassemble it and have a look. It’s slightly different to what we’ve done in that it intercepts the RET at the end of the loading system rather than mimic the first headerless loader, and puts a JP back to the hack at #83C3, but apart from that, it’s more or less everything we’ve discussed above put together.
PAUL OWEN’S PROTECTION SYSTEM
This has been used on a few Ocean games, but is in fact a standard headerless loader in disguise. The value of A to use is always #98. Load in the BASIC loader and the first block of code, then stop it with a Multiface, and use a stack trace to find out the values of IX and DE for each block, and the JP to the game.
SPEEDLOCK
Concluding the look at protection systems, I think it’s only fitting that we end in quite possible the most famous protection system of all time.
Speedlock was first written by two guys called David Looker and David Aubery Jones around late 1983, although it wasn’t commercially used until October 1984, on Daley Thompson’s Decathlon, by which time it had reached it’s third version. Since then, it has been used by many major software companies, especially Ocean. Its also gone many modifications, and can be split into three distinct generations.
I should state at this point that you need to have a Multiface to crack most of these Speedlocks, because they completely disrupt the operating system which will lock up any disassembler which relies on ROM routines. The Multiface relies on its own ROM, which isn’t affected by the Speedlock code.
Type 1 – have one or two BASIC loaders, and load the main code with the infamous “clicking” leader tones (you know, instead of a steady “bleep”, they go “blip, blip, blip, blip” a few times).
Type 2 – have one short BASIC loader, a long CODE block, lots of annoying beeps, then a similar loader to Type 1, minus the clicking leader tones, plus a countdown timer.
Type 3 – as for Type 2, except there is just one very long BASIC loader. The protection system crashes if a Multiface is left switched on. Mazemania on YS #77 covertape used a Type 3.
So, let’s start at the very beginning (a very good place to start) with Type 1. In fact, there are about four different difficulty levels of Type 1 Speedlocks; the difficulty goes in chronological order (as you might expect).
The very first Type Ones were completely different to later ones, having the same initialization routine, but a completely standard decrypter. The only differences between this Speedlock and an ordinary decrypting loader were its initialization routine and its use of the IY register. We came across index registers when we first met headerless loaders. There are, in fact, two index registers, IX and IY. In BASIC, the IX register is free for use in a machine code program run from a USR command, but the IY register must always contain the value #5C3A, which is the base address of the BASIC system variables which are wiped with a NEW command. If you return to BASIC with the value of IY anything other than #5C3A, the computer will crash, even if you use the “exit to BASIC” feature on a Multiface. The value of IY must also be #5C3A whenever a BASIC interrupt occurs. Both Devpac and 007 Disassembler run under the BASIC interrupts. They also use built in ROM routines, such as those to check the keyboard and print text; this is preferable, otherwise they’d have to waste memory rewriting their own versions of the routines. Hence the value of IY must always equal #5C3A. The only safe way of using the IY register is to disable interrupts and write the whole program in RAM without using any built in ROM routines. And Speedlock fits this bill exactly, so it uses the IY register for most of its decrypter calculations.
Speedlock code also uses a lot of undocumented instructions. In theory, you cannot split the sixteen bit IY register into two eight bit registers. But the processor doesn’t understand this, and you can split the IY register into two if you want. You simply put the code #FD on the front of any instructions using H or L. There are no standard names for the two halves of the IY register; but I will refer to them as IYH (Hi part of IY) and IYL (Lo part of IY).
Now let’s hack a Speedlock game. To start with, I’m hacking Knight Lore, but the following games are also suitable: Beach Head, Daley Thompson’s Decathlon, Gilligan’s Gold and Underworld. Anything released after these will be explained later.
So first *Hack the BASIC loader.
KNIGHT LINE 0 LEN 1037
0 BEEP 0.1,1:BEEP 0.1,2:BEEP
0.1,3:BEEP 0.1,4:BEEP 0.1,5:PAPER
0:BORDER 0:INK 0:BRIGHT 1:CLS:PRINT
BRIGHT 1;INK 0;AT 9,5;
"LOADING: KNIGHT LORE";AT
12,10;"PLEASE WAIT"
0 POKE (PEEK 23641+256*PEEK
23642),PEEK 23649:POKE (PEEK 23641+
256*PEEK 23642)+1,PEEK 23650
0 POKE (PEEK 23613+256*PEEK
23614),PEEK 23627:POKE (PEEK 23613+
256*PEEK 23614)+1,PEEK 23628
0 POKE 23662,PEEK 23618:POKE
23663,PEEK 23619:POKE 23664,PEEK 23621
23676 "REM CLOSE #ATTR....
Wait a minute, there’s absolutely no sign of a RANDOMIZE USR command anywhere! There’s just some BASIC which beeps a bit, sets the colours, and prints a message, a whole load of POKEs, and then a load of garbage. Surely the computer will do everything, then report with an error message as soon as it reaches 23676? Well, that’s not actually the case. Look at the third line 0 (the one which starts POKE [PEEK 23613+256* etc.). This system variable is known as ERR SP. What happens is that when an error occurs (and it will do here), the computer jumps to the value in this register. This value is PEEK 23627+256*PEEK 23628. PRINT this value, and there’s the start of the machine code. You might get a different result to me, but I made the start address #60A8. Disassemble this address.
60A8 F3 DI
60A9 FD 25 DEC IYH
60AB FD 7C LD A,IYH
60AD FD AD XOR IYL
The DI is very important, because otherwise the I register can’t be used. Given that IY starts off as being #5C3A, the value in A will end up being #5B XORed with #3A, which is #61.
60AF FD 26 F3 LD IYH,#F3
60B2 FD 2E A6 LD IYL,#A6
60B5 3B DEC SP
60B6 3B DEC SP
60B7 01 54 FE LD BC,#FE54
60BA FD E3 EX (SP),IY
First of all, this loads IY with the value #F3A6. It then decreases the stack pointer by two. By doing this, the stack pointer is now pointing to the start address of the machine code, which is #60A8. EX (SP),IY is a variation to the register exchange commands we’ve already come across. It basically swaps the value in the address pointed by the stack pointer with the value in the IY register. So, after this instruction, IY will contain #60A8, and the value on the top of the stack will be #F3A6.
60BC 21 30 F2 LD HL,#F230
60BF FD 09 ADD IY,BC
60C1 01 AC 01 LD BC,#01AC
60C4 FD 5D LD E,IYL
60C6 FD 54 LD D,IYH
60C8 EB EX DE,HL
Here, HL is being loaded with #F230. The value in BC (#FE54) is added to the value in IY (#60A8), making the value in IY #5EFC. Then BC is loaded with #01AC, and the value in IY is transferred into DE. Then the values of DE and HL are swapped. So, by the end of the code we’ve looked at so far, HL will equal #5EFC, DE will equal #F230, BC will equal #01AC, and A will equal #61. These values are all used in the decrypter which follows.
60C9 AE XOR (HL)
60CA 12 LD (DE),A
60CB 7E LD (HL),A
60CC 23 INC HL
60CD 13 INC DE
60CE 0B DEC BC
60CF FD 6F LD IYL,A
60D1 78 LD A,B
60D2 B1 OR C
60D3 FD 7D LD A,IYL
60D5 20 F2 JR NZ,#60C9
60D7 C9 RET
This is a straightforward decrypter, except the value for A (which is needed throughout the decrypter) is temporarily stored in part of the IY register. The RET is to #F3A6 (the top value on the stack).
To crack this, we can set up the register values manually, CALL the decrypter, and then hack the main loader ourselves. Type out this program:
5B00 F3 DI
5B01 21 FC 5E LD HL,#5EFC
5B04 11 30 F2 LD DE,#F230
5B07 01 AC 01 LD BC,#01AC
5B0A 3E 61 LD A,#61
5B0C CD C9 60 CALL #60C9
5B0F FD 21 3A 5C LD IY,#5C3A
5B13
Notice that we’ve disabled interrupts to avoid crashing, and we need to restore the value of IY to #5C3A afterwards, so your disassembler won’t crash. RUN the program, and have a look at the code at #F3A6. You’ll find it’s just a straightforward headerless loader with absolutely no frills, and you should be able to hack it no problem.
As for the final hack, load the BASIC into address #5CCB, run the decryption routine above, patch the JP in the main turboloader to your POKEs, and start running.
All other Speedlock Type 1s have the same sort of decrypter. The code for the decrypter is very complicated, with the result that I have been unable to reproduce it here. Luckily, you don’t have to touch the code; you can write your own decrypter as long as you have a Multiface.
I’ll be doing Tapper as an example, but any other Speedlock follows this procedure almost exactly. *Hack your game and note down the length of the code (you’ll need it later). I made it 1453, which is #05AD hex. Now look at address #5EFD. The byte at #5EFD is always decrypted to give the byte #42, and the byte at #5EFD is always decrypted to give the byte #55. The decrypter works by XORing the encrypted byte with a number taken from the R register. By inspecting the code before and after running, you’ll see the XORing number starts off as #CB, and increases by #0A each time. If the result is more than #FF, the result has #80 subtracted from it. We can incorporate this into our decrypter. The start of the code is #5EFD, and the length is (PEEK 23627+256*PEEK 23628)-#5EFD, which is #01ED in the case of Tapper. The following code will simulate the decrypter.
LD HL,
LD BC,
LD D,
*** LD A,(HL)
XOR D
LD (HL),A
LD A,D
ADD #0A
SET 7,A
LD D,A
INC HL
DEC BC
JR NZ, ***
Once you’ve done that decrypter, you’ve got to do the whole lot again, starting at #5EFD. The byte there will be decrypted to either #3E or #ED – you’ll have to guess which decrypting value to use. For Tapper, the start is #5F2B, the length is #1BF, and the second decrypter value is #AB.
When you’ve done that, you’ll either get the complete loading system or another decrypter. If you’ve got the loading system, then reload the BASIC loader, and do a stack trace to find out where it should go. You should have no problems with the loader.
If you’ve got another decrpyter, go along five bytes and find a LD DE,(XXXX). Add #2E to this value, and that’s where you move it to. The length is the same as that for the second decrypter. The decrypter itself can be cracked by changing a JP Z in the code about forty bytes later (the value of this is the start of the turboloader), but the decrypter itself uses a byte which is worked out by adding all the memory together in the loading system. Since we’ve got an exact copy of this system elsewhere in memory, just change the value of XXXX in the aforementioned LD DE,(XXXX), and then JP to the start of the decrypter.
If the first decrypting value you used was #CB, then you can just change the JP in the turboloader to your POKEs.
If the value was #CD, then you’ll need to know about the Standard Speedlock patch. Somewhere in the loading system there will be the two bytes ED 53 [LD DE,(XXXX)]. Change the XXXX to the address of your POKEs (#5BA0 is normally safe), and end your POKEs with a JP to the value you overwrote. You’ll have to use this patch for the later Speedlocks as well.
There was a Speedlock Type 1 MultiPOKE in YS#79. RUN the program, press BREAK and disassemble address #5B00 to find out what to do in your own hacks.
Type 2 Speedlocks feature a very easy BASIC loader, and one big block of code, which has six short decrypters and a complex moving routine. The decrypters are all easy peasy, just move them to somewhere else in memory (such as #5B00), bung a RET on the end, and CALL the decrypter from there (but watch out for the third decrypter, which checks for a Multiface and crashes if it finds it. The moving routine fiddles about with the loader. Search for 31, which means LD SP,XXXX. Hopefully, you’ll find a LD SP,#0000, with perhaps a DI right before it. Write down the address and run the moving routine (you may have to restart the tape, because some of the moving routines insist on a signal coming into the tape recorder). Use a stack trace to find out where the code has gone to. Now you can move all the code from the moving routine to the end of the machine code block to where it should be, given that you know where the LD SP,#0000 goes to. Once moved, patch the loader in the same way as the first Speedlock.
Type 3s have just one long BASIC loader, with about 144 decrypters, but that’s nothing to worry about. *Hack the BASIC loader, and have a look at the first bit of code which moves the rest of the code into the right place (you can then use a headerless loader to load this into the right place in memory). The tricky bit is changing a byte in memory so a CALL to the loading system at the very top of the code is changed to a CALL somewhere else once all the decrypters have been run. The only way you can do this is to change the address of the hi byte of this CALL to something else, and RUN the huge load of the decrypters. The computer will crash if you have a Multiface attached, but only after everything’s been decrypted, so then look and see what the CALL’s been changed to. If it’s suitable, remember the patch, position your hack around this, change the CALL to what it should be, and put in the usual Speedlock patch. Look at the start address in the turboloader. This address will be overwritten by a decrypter once loading finishes. This decrypter is nothing special, so just crack it as usual, and watch out for the game moving around.
Jon North’s Pokerama Tapes usually have a Speedlock Type 3 crack on it – load up the Pokerama, choose your POKE, then do a stack trace to find it and have a look at it.
Part 7 – Epilogue
Well folks, I’m sorry to have to break this to you, but I’ve just about told everything you should ever need to know to crack every protection system under the sun. So I’ll just say some final words and credits, and then sign off, okay?
The idea of this book, its production and its writing were done entirely by Richard Swann, from February to June 1992.
Some suggestions and tips came from two people to whom this book is dedicated, Matt Corby from “down-the-road”, and Niall “Mr Incredibly Technical” Daley. Thanks, guys!
Thanks to YS for putting disassemblers and the like on recent covertapes; it saved me the trouble of writing one!
Thanks to Jon North for some of the info on hacking he gave to me on disk recently – much appreciated, mate.
Thanks for YOU for buying this. There aren’t many Speccy hackers around right now, so we need to make the numbers up. Good luck!
What’s that? “I don’t understand this bit at all!” I hear you say. Well, send me any queries that you may have about this book, stating exactly what the problem is, along with an SAE (very important that), and I’ll do my best to reply to them. DON’T write to me asking me to hack a whole list of games for you – I just haven’t got the time. However, I’ve got a big book of Multiface POKEs which you can obtain for £1.50 and an A4 SAE if you want it, so that might come in handy.
Thought for the year: Seven years ago, Spectrum and Commodore owners were at each other’s throats. Spectrum owners would vow never to have anything to do with Commodore. Then why do I hear of so many Spectrum owners that have upgraded to a Commodore Amiga? Personally, I can’t stand the Amiga’s operating system – it’s terrible!
Well, that seems to be about it, so I’ll just leave you know in the hands of a glossary of terms. Happy hacking!
Richard Swann – June 1992
THE END
[C] 1992 NSA Publications. No part of this book may be copied, otherwise I’ll send the Mafia round. Okay?