Trivial Pursuit is a computer program which is played much like the original board version. In addition to the initial program load, there are 6 further blocks of code which may be loaded, to provide additional game questions. Capturing the initial program to the Larken disk format was relatively easy. Simply a matter of doing an NMI-type SAVE. However, the matter of modifying the program to load the code blocks was more formidable. This article will describe the approach taken.
First, a search was made of the Trivial Pursuit program to locate the LOAD code. The program was broken into by attempting an NMI save to a protected disk. This produced a “disk protected” error report, and we were back in Basic, though with the TR. PURS. code still in the computer. In the possibility that the program used a Spectrum call to the LOAD routine at address 1366, a short for/next program loop was used to look for any sequence of 5 and 86 (5*256+86) in the program. As luck would have it one was found at address 42932. Then a disassembler program was loaded. I used a TIMACHINE-compiled Spectramon program (“spec48.Cc”, on club Larken disk #17) loaded at address 48000. On the first attempt the computer locked up. I retried it, this time doing a CLEAR 65000 before loading the disassembler. Seems as though the stack was in the area where the disassembler went. The CLEAR 65000 moved it up out of the way.
I then looked through the code looking for JUMPs to the loading call at 42931. I found several. The LOAD routine is very involved. It is designed to cope with any tape loading errors. If a LOAD error occurs the program will put out a message to that effect, and get back into the LOAD mode again. Hence I found several JUMPs to the loading code. After a number of false starts I settled on address 42647 to insert a CALL to my “disk save” routine.
I should mention that I had written a suitable routine to handle the disk LOAD function. I had also located an empty area in the TR. PURS. code at about address 65360. The starting address for this code would be 65370.
The address 42647 that I mentioned earlier containd a CALL to display a tape load instruction on the screen. Immediately following it was an instruction which when followed led to the CALL to the LOAD routine in the Spectrum ROM. I decided to substitute the existing call (at 42647) with one that would CALL my disk LOAD routine at 65370.
In trying out this change I found that the disk save worked. However it was followed by a tape load attempt. The next thing to do was to bypass this tape load function. In searching the code I found that there were several CALLs in the code which led to address 42931, i.e. the Spectrum ROM loading routine. After a number of false starts I decided to delete the actual CALL to the Spectrum ROM. I inserted three 0’s, starting at address 42931. It worked. It seems as though the CALLS to the ROM were bypassed, which was what was hoped for.
Of course I mention that it worked. It was not quite so simple as this. I had to save the blocks of code (the “questions” code) to disk. Although these blocks had a header, the code refused to load into the computer on its own. Further, none of my header reader programs could pick up the header. Nor could they identify the starting address. All they could identify was the code length. Each block of code was a different length, though they were all about 16700 bytes long.
I located the starting address as follows. First I made a false header by entering a direct command SAVE “test” CODE 30000,16695; and saving the first header part to a separate tape. Then I reloaded this header, moved the TR.PURS. code tape to just past it’s header, and loaded the second part of the code. It loaded. I then looked at the first three or four addresses at 30000, and wrote them down.
I mention that I had no knowledge of where the starting address might be. This is not quite correct. In looking at the code with the disassembler I had come across several bits of code which looked as though they might be part of the loading process. The address 43008 was included in several places
The next thing to do, was to confirm that this suspicion was correct. I loaded the program TR. PURS. into the computer from tape, and then loaded the first block of (questions) code. Then I broke into the program and inspected it for the newly loaded code. The first time I tried that I was unsuccessful. The sequence that I had written down was not to be found. Most peculiar. I suspected that the code had been modified in some way or transferred immediately after completion of the load.
On my next try I stopped the computer (using the NMI-save/protected disk routine) whilst in the middle of the tape loading process. This time I was successful. I found the code started at the anticipated address 43008.
Now to deal with the code loading routine from disk that I had written. If you look at the disassembled code you can see that first there is a Disable Interrupt instruction at 65370. This prevents the keyboard from interrupting the disk load process. The CALL 98 calls up the Larken DOS, then there is a m/c LDIR routine that transfers the name “genus2.C1” from address 65427 into the Larken DOS at address 8226. After the LDIR routine, the actual load takes place. Following that, at address 65414, there is a routine to increment the number “2” in the title “genus2.C1″(at address 65432) to “3”. This is so that the program will load successive code blocks. These code blocks were given the same name, “genusx.C1”; the “x” being “2” for the first block, “3” for the next, and so on with the last block containing a “7”.
The code loader ends by returning from the Larken DOS at 65421, finishing with the RET at address 65422 which returned program operation back to address 42650 in the TR. PURS.
TRIVIAL PURSUIT Disk Loading Code
65370 F3 DI
65371 00 NOP
65372 00 NOP
65373 00 NOP
65374 CD6200 CALL 98
65377 2193FF LD HL,65427
65380 112220 LD DE,8226
65383 010A00 LD BC,10
65386 EDB0 LDIR
65388 3E0B LD A,11
65390 320220 LD (8194),A
65393 CDC600 CALL 198
65396 2100A8 LD HL,43008
65399 223320 LD (8243),HL
65402 213D41 LD HL,16701
65405 223120 LD (8241),HL
65408 CDC900 CALL 201
65411 3A6400 LD A,(100)
65414 3A98FF LD A,(65432)
65417 3C INC A
65418 3298FF LD (65432),A
65421 FB EI
65422 C9 RET
65423 00 NOP
65424 00 NOP
65425 00 NOP
65426 00 NOP
65427 103 g
65428 101 e
65429 110 n
65430 117 u
65431 115 s
65432 50 2
65433 46 .
65434 67 C
65435 49 1
65436 32
65437 0
65438 0
65439 0