| 1 |
; |
| 2 |
;Notes |
| 3 |
; This module should probably be ifdef'd for RUNTIME |
| 4 |
;Modified |
| 5 |
; 12/05/90 JEras - fix ossgmx() for non-EGA type monitors |
| 6 |
; 11/25/90 JEras - add ossgmx() |
| 7 |
; 09/14/90 SMcAdams - fix bug in detecting monochrome monitor |
| 8 |
; 03/27/90 JEras - optimize ossdsp() a little |
| 9 |
; 03/23/90 JEras - add ossmon() and ossdsp() for OS/2 compatibility |
| 10 |
; |
| 11 |
|
| 12 |
BIOSINT equ 10h ; BIOS interrupt number |
| 13 |
|
| 14 |
EXTRN _scrbase:DWORD ; Screen base pointer, from os.c |
| 15 |
EXTRN _usebios:WORD ; flag: use BIOS for output, not direct i/o |
| 16 |
|
| 17 |
oss_text segment public 'code' |
| 18 |
assume cs:oss_text |
| 19 |
|
| 20 |
|
| 21 |
; oss_con_init(void) - initialize console |
| 22 |
; |
| 23 |
public _oss_con_init |
| 24 |
_oss_con_init proc far |
| 25 |
; we don't need to do anything special - just return |
| 26 |
ret |
| 27 |
_oss_con_init endp |
| 28 |
|
| 29 |
; oss_con_uninit(void) - uninitialize console |
| 30 |
; |
| 31 |
public _oss_con_uninit |
| 32 |
_oss_con_uninit proc far |
| 33 |
; nothing special here |
| 34 |
ret |
| 35 |
_oss_con_uninit endp |
| 36 |
|
| 37 |
; oss_set_plain_mode(void) - set plain console mode |
| 38 |
; |
| 39 |
public _oss_set_plain_mode |
| 40 |
_oss_set_plain_mode proc far |
| 41 |
; nothing special here |
| 42 |
ret |
| 43 |
_oss_set_plain_mode endp |
| 44 |
|
| 45 |
; |
| 46 |
; ossscu( top_line, left_column, bottom_line, right_column, blank_color ) |
| 47 |
; -- scroll region down a line |
| 48 |
; line/column numbering starts at zero (0) |
| 49 |
; |
| 50 |
public _ossscu |
| 51 |
_ossscu proc far |
| 52 |
push bp |
| 53 |
mov bp, sp |
| 54 |
push si |
| 55 |
push di |
| 56 |
|
| 57 |
mov ch, [bp+6] ; top line |
| 58 |
mov cl, [bp+8] ; left column |
| 59 |
mov dh, [bp+10] ; bottom line |
| 60 |
mov dl, [bp+12] ; right column |
| 61 |
mov ax, 0701h ; function = scroll down 1 line |
| 62 |
mov bh, [bp+14] ; color in bh |
| 63 |
int BIOSINT |
| 64 |
|
| 65 |
pop di |
| 66 |
pop si |
| 67 |
pop bp |
| 68 |
ret |
| 69 |
_ossscu endp |
| 70 |
|
| 71 |
|
| 72 |
; |
| 73 |
; ossscr( top_line, left_column, bottom_line, right_column, blank_color ) |
| 74 |
; -- scroll region up a line |
| 75 |
; line/column numbering starts at zero (0) |
| 76 |
; |
| 77 |
public _ossscr |
| 78 |
_ossscr proc far |
| 79 |
push bp |
| 80 |
mov bp, sp |
| 81 |
push si |
| 82 |
push di |
| 83 |
|
| 84 |
mov ch, [bp+6] ; top line |
| 85 |
mov cl, [bp+8] ; left column |
| 86 |
mov dh, [bp+10] ; bottom line |
| 87 |
mov dl, [bp+12] ; right column |
| 88 |
mov ax, 0601h ; function = scroll up 1 line |
| 89 |
mov bh, [bp+14] ; color in bh |
| 90 |
int BIOSINT |
| 91 |
|
| 92 |
pop di |
| 93 |
pop si |
| 94 |
pop bp |
| 95 |
ret |
| 96 |
_ossscr endp |
| 97 |
|
| 98 |
; |
| 99 |
; ossclr( top, left, bottom, right, color ) |
| 100 |
; -- clear the given region of the screen |
| 101 |
; |
| 102 |
public _ossclr |
| 103 |
_ossclr proc far |
| 104 |
push bp |
| 105 |
mov bp, sp |
| 106 |
push si |
| 107 |
push di |
| 108 |
|
| 109 |
mov ch, [bp+6] ; top line |
| 110 |
mov cl, [bp+8] ; left column |
| 111 |
mov dh, [bp+10] ; bottom line |
| 112 |
mov dl, [bp+12] ; right column |
| 113 |
mov ax, 0600h ; function = clear region |
| 114 |
mov bh, [bp+14] ; color in bh |
| 115 |
int BIOSINT |
| 116 |
|
| 117 |
pop di |
| 118 |
pop si |
| 119 |
pop bp |
| 120 |
ret |
| 121 |
_ossclr endp |
| 122 |
|
| 123 |
; |
| 124 |
; ossloc( line, column ) |
| 125 |
; -- locate cursor at given line and column |
| 126 |
; line/column numbers start at zero (0) |
| 127 |
; |
| 128 |
public _ossloc |
| 129 |
_ossloc proc far |
| 130 |
push bp |
| 131 |
mov bp, sp |
| 132 |
push di |
| 133 |
push si |
| 134 |
|
| 135 |
mov dh, [bp+6] ; row |
| 136 |
mov dl, [bp+8] ; column |
| 137 |
mov ah, 2 ; function = set cursor position |
| 138 |
mov bh, 0 ; page = 0 |
| 139 |
int BIOSINT |
| 140 |
|
| 141 |
pop si |
| 142 |
pop di |
| 143 |
pop bp |
| 144 |
ret |
| 145 |
_ossloc endp |
| 146 |
|
| 147 |
; |
| 148 |
; int ossmon() |
| 149 |
; -- return 1 if screen is monochrome, 0 otherwise |
| 150 |
; assumes caller wants return value in AX |
| 151 |
; |
| 152 |
public _ossmon |
| 153 |
_ossmon proc far |
| 154 |
push ds |
| 155 |
push si |
| 156 |
mov ax, 40h |
| 157 |
mov ds, ax |
| 158 |
mov si, 10h ; byte to check is actually at 40:10 |
| 159 |
mov ax, [si] |
| 160 |
and ax, 30h |
| 161 |
cmp ax, 30h |
| 162 |
jz mono |
| 163 |
xor ax, ax |
| 164 |
jmp monret |
| 165 |
mono: |
| 166 |
mov ax, 1 |
| 167 |
monret: |
| 168 |
pop si |
| 169 |
pop ds |
| 170 |
ret |
| 171 |
_ossmon endp |
| 172 |
|
| 173 |
; |
| 174 |
; ossdsp( int line, int column, int color, char *msg ) |
| 175 |
; -- display msg with color at coordinates (line,column) |
| 176 |
; this routine could probably be optimized some, but it seems to work okay |
| 177 |
; assumes large model |
| 178 |
; |
| 179 |
public _ossdsp |
| 180 |
_ossdsp proc far |
| 181 |
push bp |
| 182 |
mov bp, sp |
| 183 |
push ds |
| 184 |
push es |
| 185 |
push si |
| 186 |
|
| 187 |
cmp [_usebios], 0 |
| 188 |
je use_direct_io |
| 189 |
|
| 190 |
; use BIOS to output the characters |
| 191 |
lds si, [bp+12] ; get the string pointer |
| 192 |
|
| 193 |
bios_loop: |
| 194 |
; locate the cursor |
| 195 |
push word ptr [bp+8] |
| 196 |
push word ptr [bp+6] |
| 197 |
call _ossloc |
| 198 |
add sp, 4 |
| 199 |
|
| 200 |
inc word ptr [bp+8] |
| 201 |
|
| 202 |
; write the next character |
| 203 |
mov bl, [bp+10] ; get the color |
| 204 |
mov ah, 9 ; function = display character |
| 205 |
mov bh, 0 ; page = 0 |
| 206 |
mov cx, 1 ; count = 1 |
| 207 |
lodsb ; get next character (mov al, es:[si++]) |
| 208 |
cmp al, 0 ; done? |
| 209 |
je dspret ; yes, quit |
| 210 |
|
| 211 |
int BIOSINT |
| 212 |
jmp bios_loop |
| 213 |
|
| 214 |
use_direct_io: |
| 215 |
lds si, [_scrbase] |
| 216 |
mov ax, [bp+6] |
| 217 |
mov cx, 80 |
| 218 |
mul cx |
| 219 |
add ax, [bp+8] |
| 220 |
shl ax, 1 |
| 221 |
add si, ax |
| 222 |
|
| 223 |
les bx, [bp+12] |
| 224 |
mov ah, [bp+10] |
| 225 |
dsploop: |
| 226 |
mov al, es:[bx] |
| 227 |
cmp al, 0 |
| 228 |
jz dspret |
| 229 |
mov [si], ax |
| 230 |
add si, 2 |
| 231 |
inc bx |
| 232 |
jmp dsploop |
| 233 |
dspret: |
| 234 |
pop si |
| 235 |
pop es |
| 236 |
pop ds |
| 237 |
pop bp |
| 238 |
ret |
| 239 |
_ossdsp endp |
| 240 |
|
| 241 |
; |
| 242 |
; ossgmx( int *max_line, int *max_column ) |
| 243 |
; -- return max screen size in *max_line and *max_column |
| 244 |
; assumes large data model |
| 245 |
; |
| 246 |
public _ossgmx |
| 247 |
_ossgmx proc far |
| 248 |
push bp |
| 249 |
mov bp, sp |
| 250 |
|
| 251 |
push es |
| 252 |
push di |
| 253 |
|
| 254 |
mov dl, 18h ; 24 rows by default (bias of 0) |
| 255 |
xor bh, bh |
| 256 |
mov ax, 1130h ; get font info |
| 257 |
push bp |
| 258 |
int BIOSINT |
| 259 |
pop bp |
| 260 |
les di, [bp+6] ; load max_line address |
| 261 |
mov byte ptr es:[di], dl ; DL=rows on screen, save it |
| 262 |
mov byte ptr es:[di+1], 0 |
| 263 |
|
| 264 |
mov ah, 0fh ; get current video mode |
| 265 |
int BIOSINT |
| 266 |
dec ah ; AH=columns on screen - 1 |
| 267 |
les di, [bp+10] ; get max_column address |
| 268 |
mov byte ptr es:[di], ah ; save columns |
| 269 |
mov byte ptr es:[di+1], 0 |
| 270 |
|
| 271 |
pop di |
| 272 |
pop es |
| 273 |
|
| 274 |
pop bp |
| 275 |
ret |
| 276 |
_ossgmx endp |
| 277 |
|
| 278 |
oss_text ends |
| 279 |
end |