The Snapshot routines
THE 'NON-MASKABLE INTERRUPT' CONTINUED
This piece of code determines whether the NMI button was pressed or a return from a
CALBAS was made.
0053 NMI_1 LD A,(#3DE5)
0056 CP #47 Check if returning from a CALBAS.
0058 JR NZ,#0060,NMI_2 Jump if not returning from a CALBAS.
005A XOR A
005B LD (#3DE5),A Clear CALBAS executing.
005E POP AF Restore A register and return to the
005F RET calling routine.
0060 NMI_2 LD A,R
0062 PUSH AF Save R register and interrupt status.
0063 JR #0069,SNAPSHOT
0065 DEFB #00
THE 'NON-MASKABLE INTERRUPT' ROUTINE
This is the third point, from address #0000, at which the +D system is paged in. It is
reached either by pressing the 'snapshot' button or when returning from a CALBAS.
0066 NMI PUSH AF Save A register.
0067 JR #0053,NMI_1
THE 'SNAPSHOT' ROUTINE
When the 'snapshot' button is pressed this routine is executed. By pressing the keys 1
or 2 a choice can be made to dump the screen to the printer in small or grey-scale
format. As soon as the system file is loaded it is possible to make snapshots to disk
(See #20A1 and further).
0069 SNAPSHOT LD (#3FFE),SP Use 'internal' stack.
006D LD SP,#3FFE
0070 LD A,I
0072 PUSH AF Save all registers, starting with I.
0073 PUSH HL
0074 PUSH BC
0075 PUSH DE
0076 EX AF,AF' Save alternative registerset.
0077 EXX
0078 PUSH AF
0079 PUSH HL
007A PUSH BC
007B PUSH DE
007C PUSH IX Save the index registers.
007E PUSH IY
0080 DI Disable interrupts in case #0066 was
called normally. When a NMI occurs the
Z80 disables interrupts.
0081 LD HL,#00B1,SNAP_EXIT
0084 PUSH HL RETurn address from snapshot.
0085 LD (#2066),SP Store current stackpointer at D_ERR_SP
so an error will activate SNAP_EXIT.
0089 SNAP_KEYS LD BC,#F7FE Keyboard port and key 1-5 I/O address.
008C IN E,(C)
008E BIT 0,E CASE key OF
0090 JP Z,#12D2,COPS 1: jump to the smallcopy routine.
0093 BIT 1,E
0095 JP Z,#133E,COPS2 2: jump to the greyscale routine.
0098 CALL #0527,SYSTEM_Z System loaded?
009B CALL Z,#20A1,JSNAP Yes, then call system snap routine.
009E INC A END CASE.
009F AND #07
00A1 OUT (C),A Nice stripes in border.
00A3 LD B,#FE CAPS-V I/O address.
00A5 IN E,(C)
00A7 BIT 2,E
00A9 JR NZ,#0089,SNAP_KEYS Test for X, loop if not pressed.
00AB SNAP_KEY1 IN E,(C)
00AD BIT 2,E
00AF JR Z,#00AB,SNAP_KEY1 Wait until X is released again.
THE 'SNAP_EXIT' ROUTINE
This routine is used to return to the snapshotted program.
00B1 SNAP_EXIT DI
00B2 LD HL,#0000 Clear D_ERR_SP.
00B5 LD (#2066),HL
00B8 CALL #168E,BORD_REST
00BB LD SP,#3FEA
00BE POP IY Restore the index registers.
00C0 POP IX
00C2 POP DE Restore the alternate registerset.
00C3 POP BC
00C4 POP HL
00C5 POP AF
00C6 EX AF,AF'
00C7 EXX
00C8 CALL #011D,?_ROMBANK Determine current 'main' ROM bank.
00CB JR NZ,#00F5,SNAP_EX3 Jump if 128K ROM bank.
00CD CALL #0511,REST_PBUF
00D0 POP DE Restore the registerset.
00D1 POP BC
00D2 POP HL
00D3 POP AF
00D4 LD I,A
00D6 CP #00
00D8 JR Z,#00E0,SNAP_EX1
00DA CP #3F When the I register doesn't contain #00
00DC JR Z,#00E0,SNAP_EX1 or #3F, it is most likely that the
00DE IM 2 interrupt mode is 2.
00E0 SNAP_EX1 LD SP,(#3FFE) Restore stack pointer.
00E4 POP AF
00E5 LD R,A Jump if the interupts were disabled
00E7 JP PO,#00F1,SNAP_EX2 when 'SNAPSHOT' was entered.
00EA PUSH HL
00EB LD HL,#004F Otherwise return to snapshotted program
00EE JP #004F,UNPAGE_HL via 'main' ROM "POP HL", "POP AF" and
"EI".
00F1 SNAP_EX2 POP AF Return to the instruction before which
00F2 JP #0050,UNPAGE_1 the snapshot occurred.
This piece of code does almost the same as the above. The only difference is that it
returns to the 128 'main' ROM at a somewhat different address.
00F5 SNAP_EX3 CALL #0511,REST_PBUF
00F8 POP DE
00F9 POP BC
00FA POP HL
00FB POP AF
00FC LD I,A
00FE CP #00
0100 JR Z,#0108,SNAP_EX4
0102 CP #3F
0104 JR Z,#0108,SNAP_EX4
0106 IM 2
0108 SNAP_EX4 LD SP,(#3FFE)
010C POP AF
010D LD R,A
010F JP PO,#0119,SNAP_EX5
0112 PUSH BC
0113 LD BC,#007B
0116 JP #0046,UNPAGE_BC
0119 SNAP_EX5 POP AF
011A JP #0047,UNPAGE_0
THE 'DETERMINE 128K ROM BANK' SUBROUTINE
This routine determines, by examining the byte at address #0001, which bank of the 128K
ROM is selected. Because the +D system is currently paged in the 'main' ROM can't be
accessed directly. So a routine, which pages out the +D, is copied to the printer buffer.
But first the first 10 bytes of the printer buffer are saved.
011D ?_ROMBANK LD HL,23296 Save the 10 bytes needed by the
0120 LD DE,#3BE6 subroutine in +D RAM.
0123 LD BC,10
0126 LDIR
0128 LD HL,#051D,DET_ROM Copy the subroutine to the freed bytes.
012B LD DE,23296,DET_ROM'
012E LD BC,10
0131 LDIR
0133 LD A,#47 Signal 'CALBAS executing' (the NMI
0135 LD (#3DE5),A routine returns immediately).
0138 JP 23296,DET_ROM' Exit via DET_ROM.