; READ SNAPSHOT FROM MS-DOS 720KB DISKS ON SPECTRUM +3
; DRIVE B: *MUST* BE A 3.5" DRIVE
; PART TWO THE *LAST CODE MOVER*
; THIS PART RESIDES IN THE SCREEN AND WILL LOAD THE FIRST 15 CLUSTERS 
; TO RAM PAGE 1, THIS IS DUE TO THE SYSTEM-VARIABLES AT #5B00...
;
; THIS PART WILL BE PLACED AFTER THE FIRST 15 CLUSTERS IN RAM 01
; AND WILL MOVE CLUSTER 0-14 IN RAM 01 DOWN
;       MOVE THE SNAPSHOT HEADER DOWN TO #4000
;       MOVE THE LAST PART DOWN TO #401B
;       AND RESTORE SOME OF THE REGISTERS FROM THE .SNA HEADER
;
; ON ENTRY: SP=#4FFF AND INTERRUPT DISABLE
;
; THANKS TO RICHARD SWANN FOR THE +D VERSION
; +3DOS VERSION BY THOMAS KJAER
; EMAIL TAKJAER@DAIMI.AAU.DK
;
SNAPHD	EQU	#4000	; WHERE TO PLACE SNAPHEADER
PART3	EQU	#0017
;
	ORG	60000
MAIN	LD	HL,#C000+27	; START OF SCREEN IN SNAPSHOT
	LD	DE,#4000
	LD	BC,#1FE5	; 8 CLUSTERS - HEADER (27 BYTES)
	LDIR	; MOVE COMPLETE SCREEN+CODE TO RIGHT PLACE
; MOVE THE SNAPSHOT HEADER TO SCREEN
	LD	HL,#C000
	LD	DE,SNAPHD
	LD	BC,#1B
	LDIR	; MOVE SNAP-INFO
; MOVE START ROUTINE TO SCREEN
	LD	HL,END
	LD	DE,SNAPHD+#1B	; AND PLACE IT AFTER HEADER INFO
	LD	BC,PART3	; LENGTH OF PART 3
	LDIR	; MOVE IT
;
; RESTORE SOME OF THE REGISTERS
; THIS PART HAS BEEN DIVIDED IN TWO, TO PREVENT TOO MUCH OF THE SCREEN
; FROM BEEING CORRUPTED
;
RUNSNP	LD	A,(SNAPHD+26)
	OUT	(#FE),A	; SET THE BORDER
	LD	A,(SNAPHD+25)	; FIND INTERRUPT MODE
	CP	#01	; IS IT 'IM 1'?
	JR	NZ,RUNIM2	; NO, JUMP AND TEST FOR 'IM 0/2'
	IM	1	; YES, SET THE INT. MODE
	JR	RUNCNT	; AND CONTINUE
RUNIM2	CP	#02	; IS IT 'IM 2'?
	JR	NZ,RUNIM0	; NO, THEN IT MUST BE 'IM 0'
	IM	2	; YES, SET THE INT MODE
	JR	RUNCNT	; AND CONTINUE
RUNIM0	IM	0	; SET INT. MODE
RUNCNT	LD	SP,SNAPHD-1	; RESTORE THE REGISTERS
	POP	AF
	LD	I,A
	POP	HL
	POP	DE
	POP	BC
	POP	AF
	EXX
	EX	AF,AF'
	POP	HL
	POP	DE
;
	JP	SNAPHD+#1B	; JUMP TO THE SNAPSHOT RUNNER
END
LEN	EQU	END-MAIN
