Terminal control/Preserve screen: Difference between revisions

Applesoft BASIC
m (→‎{{header|Sidef}}: minor code simplification)
(Applesoft BASIC)
Line 1:
{{task|Terminal control}}[[Terminal Control::task| ]]
The task is to clear the screen, output something on the display, and then restore the screen to the preserved state that it was in before the task was carried out. There is no requirement to change the font or kerning in this task, however character decorations and attributes are expected to be preserved. If the implementer decides to change the font or kerning during the display of the temporary screen, then these settings need to be restored prior to exit.
 
=={{header|Applesoft BASIC}}==
Restores 40 x 24 TEXT screen, cursor position, display mode, and speed. Adjusts HIMEM to make room to store 1024 bytes aligned to the 256 byte page boundary. POKEs a machine language "copy 4 pages of memory" routine into page 3.
<lang ApplesoftBasic> 10 LET FF = 255:FE = FF - 1
11 LET FD = 253:FC = FD - 1
12 POKE FC, 0 : POKE FE, 0
13 LET R = 768:H = PEEK (116)
14 IF PEEK (R) = 162 GOTO 40
 
15 LET L = PEEK (115) > 0
16 LET H = H - 4 - L
17 HIMEM:H*256
18 LET A = 10:B = 11:C = 12
19 LET D = 13:E = 14:Z = 256
20 POKE R + 0,162: REMLDX
21 POKE R + 1,004: REM #$04
22 POKE R + 2,160: REMLDY
23 POKE R + 3,000: REM #$00
24 LET L = R + 4: REMLOOP
25 POKE L + 0,177: REMLDA
26 POKE L + 1,FC:: REM($FC),Y
27 POKE L + 2,145: REMSTA
28 POKE L + 3,FE:: REM($FE),Y
29 POKE L + 4,200: REMINY
30 POKE L + 5,208: REMBNE
31 POKE L + 6,Z - 7: REMLOOP
32 POKE L + 7,230: REMINC
33 POKE L + 8,FD:: REM $FD
34 POKE L + 9,230: REMINC
35 POKE L + A,FF:: REM $FF
36 POKE L + B,202: REMDEX
37 POKE L + C,208: REMBNE
38 POKE L + D,Z - E: REMLOOP
39 POKE L + E,096: REMRTS
 
40 POKE FD, 4 : POKE FF, H
41 CALL R : S = PEEK(241)
42 LET V = PEEK(37)
43 LET C = PEEK(36)
44 LET M = PEEK(50)
45 LET F = PEEK(243)
 
50 HOME : INVERSE
51 PRINT "ALTERNATE BUFFER"
52 FLASH : SPEED = 125
53 FOR I = 5 TO 1 STEP -1
54 PRINT "GOING BACK IN: "I
55 NEXT I
 
60 POKE FD, H : POKE FF, 4
61 CALL R : POKE 241, S
62 VTAB V + 1 : HTAB C + 1
63 POKE 50, M : POKE 243, F</lang>
 
=={{header|BBC BASIC}}==
413

edits