1 ; *********************************************************** 2 ; * * 3 ; * Copyright, (C) Honeywell Bull Inc., 1987 * 4 ; * * 5 ; * Copyright, (C) Honeywell Information Systems Inc., 1986 * 6 ; * * 7 ; *********************************************************** 8 9 ; HISTORY COMMENTS: 10 ; 1) change(88-03-22,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel): 11 ; Created. 12 ; 2) change(88-09-01,Lee), approve(88-05-16,MCR7897), audit(88-09-19,Flegel): 13 ; Modified to get active page from BIOS segment rather 14 ; than assuming page 0 is the active page. 15 ; END HISTORY COMMENTS 16 ; 17 ;FUNCTION (save_screen,restore_screen) 18 ; 19 ; Save the contents of the display to a user-specified buffer. 20 ; Restore the contents of the display from a user-specified buffer. 21 ; Only the first 24 lines of the screen will be saved. 22 ; 23 ;*/ 24 25 include dos.mac ;Lattice include file 26 27 ;******************************************************************* 28 ; DATA 29 ;******************************************************************* 30 31 ;define variables which are maintained by BIOS in the BIOS segment 32 33 BIOS_SEG SEGMENT AT 0040H 34 org 0050H 35 cursor_posn dw ? ; holds cursor coordinates kept by BIOS 36 org 0062H 37 active_page db ? ; contains current active page 38 39 BIOS_SEG ends 40 41 42 dseg 43 ; constants 44 45 BIOS_VIDEO = 10h ; BIOS video interrupt call 46 BIOS_SET_CURSOR = 2 ; BIOS video set cursor position function number 47 BIOS_GET_CURSOR = 3 ; BIOS video get cursor position function number 48 BIOS_READ_CHR_ATTR = 8 ; BIOS video get character and attributes number 49 BIOS_WRITE_CHR_ATTR = 9 ; BIOS video write character and attributes number 50 DISPLAY_WIDTH = 80 ; number of columns across displayed 51 DISPLAY_HEIGHT = 24 ; number of lines displayed 52 53 endds 54 55 page 56 ;************************************************************************** 57 ; Program mainline 58 ;************************************************************************** 59 ; 60 61 pseg 62 63 public save_screen 64 public restore_screen 65 public get_active_page 66 67 ; save_screen(buffer) 68 69 save_screen proc near 70 push bp ; save registers used 71 push di 72 push dx 73 push cx 74 push bx 75 push es 76 push si 77 mov bp,sp ; set up pointer to arguments 78 mov di,[bp+16] ; fetch argument (pointer to user-buffer) 79 80 mov ax,BIOS_SEG ; BIOS segment 81 mov es,ax ; use es to reference into BIOS segment 82 call get_active_page ; get active page in al 83 mov si,ax ; save active page in si 84 sal si,1 ; times 2 to index word offset 85 mov bh,al ; save current active page 86 mov ah,BIOS_GET_CURSOR ; get cursor position 87 int BIOS_VIDEO ; BIOS video interrupt 88 push dx ; save cursor coordinates 89 xor dx,dx ; set cursor position to 0,0 90 91 save_loop: 92 mov es:cursor_posn[si],dx ; get cursor coordinates 93 mov ah,BIOS_READ_CHR_ATTR ; get character and attribute at position 94 int BIOS_VIDEO 95 mov [di],ax ; save into buffer 96 inc di ; increment buffer pointer 97 inc di 98 inc dl ; increment column position 99 cmp dl,DISPLAY_WIDTH ; past 80th column? 100 jl save_loop 101 mov dl,0 ; reset column to 0 102 inc dh 103 cmp dh,DISPLAY_HEIGHT ; past 24th line? 104 jl save_loop ; repeat for next line if not 105 106 pop dx ; restore previous cursor coordinates 107 mov ah,BIOS_SET_CURSOR 108 int BIOS_VIDEO 109 110 pop si 111 pop es ; restore registers 112 pop bx 113 pop cx 114 pop dx 115 pop di 116 pop bp 117 118 ret ; return to caller 119 120 save_screen endp 121 122 123 ; restore_screen(buffer) 124 125 restore_screen proc near 126 push bp ; save registers used 127 push di 128 push bx 129 push cx 130 push dx 131 push es 132 push si 133 mov bp,sp ; set up pointer to arguments 134 mov di,[bp+16] ; fetch argument (pointer to user buffer) 135 136 mov ax,BIOS_SEG ; BIOS segment 137 mov es,ax ; use es to reference into BIOS segment 138 139 call get_active_page ; get current active page in al 140 mov si,ax ; save active page in si 141 sal si,1 ; times 2 to index word offset 142 mov bh,al ; get from current active page 143 mov ah,BIOS_GET_CURSOR ; get cursor position 144 int BIOS_VIDEO ; BIOS video routine 145 push dx ; save cursor coordinates 146 147 xor dx,dx ; set cursor position to 0,0 148 mov cx,1 ; number of characters for writing character 149 restore_loop: 150 mov es:cursor_posn[si],dx ; get cursor coordinates 151 mov ax,[di] ; get character from buffer 152 mov bl,ah 153 mov ah,BIOS_WRITE_CHR_ATTR ; write character & attributes 154 int BIOS_VIDEO 155 inc di ; increment buffer pointer 156 inc di 157 inc dl ; increment column position 158 cmp dl,DISPLAY_WIDTH ; past 80th column? 159 jl restore_loop 160 mov dl,0 ; reset column to 0 161 inc dh 162 cmp dh,DISPLAY_HEIGHT ; past 24th line? 163 jl restore_loop ; repeat for next line if not 164 165 pop dx ; restore previous cursor coordinates 166 mov ah,BIOS_SET_CURSOR 167 int BIOS_VIDEO 168 169 pop si 170 pop es ; restore registers 171 pop dx 172 pop cx 173 pop bx 174 pop di 175 pop bp 176 177 ret ; return to caller 178 restore_screen endp 179 180 181 ; get_active_page() - this routine returns the active page in register 182 ; al; the active page is obtained from a variable in the BIOS segment. 183 184 get_active_page proc near 185 push es ; save segment register 186 mov ax,BIOS_SEG ; get address of BIOS segment 187 mov es,ax ; reference BIOS segment with es 188 mov al,es:active_page ; fetch active page from BIOS segment 189 pop es ; restore segment register 190 ret 191 get_active_page endp 192 193 endps 194 end 195 ^Z