by George Chambers
credits and copyright A. Pennell 1985
The April 1986 issue of YOUR SINCLAIR had an article and a program listing for a feature which provides for a screen black-out if you don’t do anything for a while. It has an adjustable time-out interval of up to 20 minutes.
I found that the program works equally well on the TS2068 and with the Spectrum ROM.
The program works as follows. After a timed interval in which no computer keys are pressed the screen attributes are moved and stored in upper memory, and the attributes area of memory is filled with zeros, giving a black screen. The border is also blacked out. At the same time a flashing white square located in the lower right-hand corner of the screen is displayed as a reminder.
Whenever a key is touched the screen attributes are restored and presto, the screen reappears.
The code occupies a space of about 1200 bytes of upper RAM. The code itself is only about 120 bytes, however space is required to store the 768 bytes of the screen attributes.
This location has been carefully chosen so that the interrupt mode (IM2) which it uses will not be disturbed by computer peripherals. I checked, and it’s operation is not affected by the Larken disk system. Also, the code does not affect the user-defined graphics area of memory.
The article mentions that because of the peculiarity of the IM2 interrupt mode only the brave, or maybe the foolhardy, would attempt to relocate it.
The easiest way to use this utility would be to load the Basic each time, and have it POKE the code into place. This allows you to select the time delay interval desired.
If you can settle for a standard time interval then saving the code and reloading it for each use is entirely practical. In this case you would initialize the feature with a RAND USR 64967.
To turn off the feature use RAND USR 64994.
*************************
1 REM Auto Screen Fade
5 RESTORE
10 CLEAR 64198
1000 FOR i=64967 TO 65023
1010 READ a: POKE i,a
1020 NEXT i
1030 FOR i=65281 TO 65365
1040 READ a: POKE i,a
1050 NEXT i
1060 INPUT "Delay in secs ";S
1070 LET s=s*50: LET t=INT (s/256)
1080 POKE 65287,t: POKE 65286,s-256*t
1090 RANDOMIZE USR 64967
1100 PRINT "USR 64994 to switch off"
110 STOP
2000 DATA 33,0,254,6,0,243
2010 DATA 54,253,35,16,251,54
2020 DATA 253,62,254,237,71,237
2030 DATA 94,251,33,1,0,34
2040 DATA 251,253,201,237,86,201
2050 DATA 255,243,245,229,197,213
2060 DATA 237,91,251,253,205,1
2070 DATA 255,34,251,253,209,193
2080 DATA 225,241,251,201,2,0
2090 DATA 195,229,253
2100 DATA 122,179,40,50,33,232
2110 DATA 3,167,237,82,40,11
2120 DATA 235,35,253,203,1,110
2130 DATA 200,33,1,0,201,33
2140 DATA 0,88,17,199,250,1
2150 DATA 0,3,126,18,54,0
2160 DATA 35,19,11,120,177,32
2170 DATA 245,211,254,62,184,50
2180 DATA 255,90,33,0,0,201
2190 DATA 235,253,203,1,110,200
2200 DATA 33,199,250,17,0,88
2210 DATA 1,0,3,237,176,58
2220 DATA 72,92,230,56,15,15
2230 DATA 15,211,254,33,1,0,201
9000 RANDOMIZE USR 100: SAVE "autofd.B1"
DISASSEMBLY OF AUTO FADE CODE
64967 2100FE LD HL,65024
64970 0600 LD B,0
64972 F3 DI
64973 36FD LD (HL),253
64975 23 INC HL
64976 10FB DJNZ B,64973
64978 36FD LD (HL),253
64980 3EFE LD A,254
64982 ED47 LD I,A
64984 ED5E IM 2
64986 FB EI
64987 210100 LD HL,1
64990 22FBFD LD (65019),HL
64993 C9 RET
64994 ED56 IM 1
64996 C9 RET
64997 FF RST 38H
64998 F3 DI
64999 F5 PUSH AF
65000 E5 PUSH HL
65001 C5 PUSH BC
65002 D5 PUSH DE
65003 ED5BFBFD LD DE,(65019)
65007 CD01FF CALL 65281
65010 22FBFD LD (65019),HL
65013 D1 POP DE
65014 C1 POP BC
65015 E1 POP HL
65016 F1 POP AF
65017 FB EI
65018 C9 RET
65019 02 LD (BC),A
65020 00 NOP
65021 C3E5FD JP 64997
65281 7A LD A,D
65282 B3 OR E
65283 2832 JR Z,65335
65285 21FA00 LD HL,250
65288 A7 AND A
65289 ED52 SBC HL,DE
65291 280B JR Z,65304
65293 EB EX DE,HL
65294 23 INC HL
65295 FDCB016E BIT 5,(IY+1)
65299 C8 RET Z
65300 210100 LD HL,1
65303 C9 RET
65304 210058 LD HL,22528
65307 11C7FA LD DE,64199
65310 010003 LD BC,768
65313 7E LD A,(HL)
65314 12 LD (DE),A
65315 3600 LD (HL),0
65317 23 INC HL
65318 13 INC DE
65319 0B DEC BC
65320 78 LD A,B
65321 B1 OR C
65322 20F5 JR NZ,65313
65324 D3FE OUT (254),A
65326 3EB8 LD A,184
65328 32FF5A LD (23295),A
65331 210000 LD HL,0
65334 C9 RET
65335 EB EX DE,HL
65336 FDCB016E BIT 5,(IY+1)
65340 C8 RET Z
65341 21C7FA LD HL,64199
65344 110058 LD DE,22528
65347 010003 LD BC,768
65350 EDB0 LDIR
65352 3A485C LD A,(23624)
65355 E638 AND 56
65357 0F RRCA
65358 0F RRCA
65359 0F RRCA
65360 D3FE OUT (254),A
65362 210100 LD HL,1
65365 C9 RET
65366 00 NOP
65367 00 NOP
Media
Source Code
1 REM Auto Screen Fade
5 RESTORE
10 CLEAR 64198
1000 FOR i=64967 TO 65023
1010 READ a: POKE i, a
1020 NEXT i
1030 FOR i=65281 TO 65365
1040 READ a: POKE i, a
1050 NEXT i
1060 INPUT "Delay in secs ";s
1070 LET s=s*50: LET t=INT (s/ 256)
1080 POKE 65287, t: POKE 65286, s-256*t
1090 RANDOMIZE USR 64967
1100 PRINT "USR 64994 to switch off"
1110 STOP
2000 DATA 33,0,254,6,0,243
2010 DATA 54,253,35,16,251,54
2020 DATA 253,62,254,237,71,237
2030 DATA 94,251,33,1,0,34
2040 DATA 251,253,201,237,86,201
2050 DATA 255,243,245,229,197,213
2060 DATA 237,91,251,253,205,1
2070 DATA 255,34,251,253,209,193
2080 DATA 225,241,251,201,2,0
2090 DATA 195,229,253
2100 DATA 122,179,40,50,33,232
2110 DATA 3,167,237,82,40,11
2120 DATA 235,35,253,203,1,110
2130 DATA 200,33,1,0,201,33
2140 DATA 0,88,17,199,250,1
2150 DATA 0,3,126,18,54,0
2160 DATA 35,19,11,120,11,36
2170 DATA 245,211,254,62,184,50
2180 DATA 255,90,33,0,0,201
2190 DATA 235,253,203,1,110,200
2200 DATA 33,199,250,17,0,88
2210 DATA 1,0,3,237,176,58
2220 DATA 72,92,230,56,15,15
2230 DATA 15,211,254,33,1,0,201,0,0Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.