Ramsoft presents -= The ZX Spectrum Loaders Guide =- VOLUME 4 The Speedlock 3 Tape-Loader INDEX Introduction........................................... PART I............Basic Knowledges And Signal Structure PART II........The Speedlock 3 Loading Routine Analysis Appendix.......................Frequencies And T-states ------------------------------------------------------------------------------ Introduction Welcome to Ramsoft's ZX Spectrum loader guide. These documents are intended to provide a useful help for anyone interested on learning loader working. All the most common loader types have been treated to give a complete view of the mainly used protection systems. The very first volume of this guide is dedicated to the normal speed loader in the Spectrum ROM, which is the base for understanding loaders like Speedlock and Alkatraz and their amazing effects. NOTE: the author takes NO responsibility and won't be liable, under any circumstances, for copyright infringements or any other direct or indirect damage. Last revised on 10-9-1997 ------------------------------------------------------------------------------ PART I - Basic knowledges and signal structure. Version 3 is the one that brings the features that everyone reminds when talking about Speedlocks: these are the sudden-appearing screenshot and the on-screen timer. The old clicking leader and the mid-syncs are still present so, apart from these new effects, Speedlock 3 is the same as version 2, but the authors have found a better use of the time wasted for waiting edges... So the signal structure is the same as version 2: KLRBC for the first block and KLRB [DB] [DB] ... C for the second where K=clicKing leader, L=Long sync, R=short maRker, B=bytes, D=miD-sync and C=Checksum. ------------------------------------------------------------------------------ PART II - The Speedlock 3 loading routine analysis. We are now going to follow each step of Speedlock 3 loading routine. I took Leviathan 128K as example since is one of the few Speedlock 3 files I have. This routine is very similar to Speedlock 2 loader, so only different parts will have a detailed description; for more details see volume 3 of this guide. Here we go... NOTE: Some of the labels used in this disassembled piece of code are not official, while others are taken from: "The complete ZX Spectrum ROM disassembly" , Melbourne House 1983. by Dr. Ian Logan & Dr. Franklin O'Hara ISBN 0 86759 117 X ------------------------------------------------------------------------------ B000 Ld-Error LD IY,0000h B004 Fill-mem LD (IY+75h),00h B008 INC IY B00A JR B004h (Fill-mem) This piece of code completely resets the computer's memory preserving the locations from FD25h to FFFFh; it is called in case of tape loading error. B00C Ld-Fx-1 EXX B00D EX AF,AF' Here starts the first routine for special loading effects. First of all switch to the alternate register set to preserve the main one B00E LD A,(82FFh) Load the last byte of the attribute loading buffer in A B011 CP 00h Check if the byte has been loaded (loaded byte must be different from 0) B013 LD B,0Ch Set B to lose 101 T B015 JR Z,B02Eh (No-Full) Jump forward if the buffer is not full B017 LD HL,B031h B01A LD (B1F6h),HL (Fx-Call)+1 Otherwise change the address of the second CALL to search the second edge of a bit to the second routine for special effects B01D LD HL,8000h B020 LD DE,5800h B023 LD A,41h Prepare the registers for attributes transfer: HL=start of attributes buffer DE=start of attributes area A=number of transfer repetitions+1 B025 LD B,09h Set B to lose 77 T B027 Waste-1 DJNZ B027h (Waste-1) Waste time B029 EX AF,AF' B02A EXX Restore the main register set B02B JP B106h (Ld-Edge-1) Jump to find the second edge B02E No-Full NOP B02F JR B027h ( Lose 4 T and jump back to waste necessary time B031 Ld-Fx-2 EXX B032 EX AF,AF' This is the second routine for special effects. Swap to alternate register set. B033 DEC A Check if the last transfer has been performed by decreasing repetitions number (that's why A holds rapetitions+1) B034 JR Z,B054h (Xfer-End) Jump forward if the last repetition has been made B036 EX AF,AF' Otherwise AF is swapped, since it won't be used anymore in the routine B037 LDI B039 LDI B03B LDI B03D LDI B03F LDI B041 LDI B043 LDI B045 LDI B047 LDI B049 LDI B04B LDI B04D LDI Transfer 12 attribute bytes at a time from buffer to screen B04F NOP B050 EXX Lose 4 T and restore the main registers set B051 JP B106h (Ld-Edge-1) Jump to load the second edge B054 Xfer-End LD A,01h B056 EX AF,AF' Prepare A for timer initialisation and swap with the main register B057 LD HL,B06Bh B05A LD (B1F6h),HL (Fx-Call)+1 Change the address of the second CALL to search the second edge of a bit to the third routine for special effects B05D XOR A B05E LD (B117h),A (Bord-Clr) Change border colour to fixed BLACK (i.e. turn off border colours) B061 NOP B062 NOP B063 LD B,0Ah Lose 8 T and set B to waste 85 T B065 Waste-2 DJNZ B065h (Waste-2) Waste the necessary time B067 EXX Swap to main register set B068 JP B106h (Ld-Edge-1) Jump to search second edge B06B Ld-Fx-3 EXX B06C EX AF,AF' This is the second routine for special effects; at the first call A holds 1 so the timer is updated and printed to screen Swap to alternate register set; at this point, A and C hold some sort of "commands" for the timer routine: if A=1 then update and dispose things to print timer if 01h< A