1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
|
; bitmap.S is
; Copyright 2001 John Coffman.
; All rights reserved.
;
; Licensed under the terms contained in the file 'COPYING' in the
; source directory.
;
;
; menu_setup:
; main setup menu for LILO boot selection process
;
; replaces code to load & display the message in second.S
;
; exit with DS=ES=CS
;
menu_setup:
pusha
BEG_FS
SEG_FS ! message disabled ?
cmp word ptr par1_msg_len+SSDIFF,#0 ;MSG_OFF+SSDIFF,#0
END_FS
je ms_do_find ! yes -> skip this
BEG_FS
SEG_FS ! load the message file
mov cx,par1_msg+SSDIFF ;MSG_OFF+SSDIFF+2
SEG_FS
mov dx,par1_msg+2+SSDIFF
SEG_FS
mov al,par1_msg+4+SSDIFF
END_FS
mov bx,#MAP
call sread
call loadfile
push #SYSSEG
pop es
xor bx,bx
push es ; save for later
push bx
call _display4 ; ES:BX points to the Message or BITMAP
pop bx
BEG_FS
SEG_FS
xchg bx,par1_msg_len+SSDIFF ;MSG_OFF+SSDIFF
END_FS
cmp ax,#1
jb good_bitmap ; AX==0, bitmap was displayed
pop ds
ja ms_do_find ; AX==2 or 3; "BM" sig found, but
; wrong bitmap or no VGA adapter
; AX==1, no "BM" signature, assume "message"
mov byte ptr (bx),#0
call crlf
xor bx,bx ! display the message
call say
jmp ms_do_find
;--------------------------------------------
good_bitmap:
pop es
inc word [suppress]
mov word [abs_cx],#0x101 ; mark screen in use
ms_do_find:
push cs
pop ds ; make sure DS is good
xor si,si ; number of names
xor di,di ; max. name length
mov cx,#IMAGES ; get max number to search
mov bx,#DESCR0 ; get address to start at
findl1: call strlen ; get length in ax
or ax,ax
jz findl3
cmp ax,di
jb findl2
xchg ax,di
findl2: add bx,#id_size
inc si
loop findl1
findl3: mov [nimage],si
mov [limage],di
xor ax,ax ;display the list of names
;; cmp [abs_cx],ax ; but not if text mode
;; je findl9
mov cx,si
findl4: call lowlite
inc ax
loop findl4
xchg ax,cx
call hilite
findl9:
push cs
pop es ; make sure ES is good on exit
popa
ret
; end of menu_setup subroutine
#if DEBUG_NEW
no_bmp: .ascii " = AL; NOT a bitmap file\n"
.byte 0
#endif
; find_image
; if there is something on the command line
; return the image number it selects
;
; enter with:
; nothing
; exit with:
; If nothing selected:
; Carry Clear
; AX==0
; If an image is selected:
; Carry SET
; AX==#image
; BX==pointer to descriptor
;
;
; side effect:
; The selected image is hi-lited if the menu is displayed
;
find_image:
push cx
push si
push di
mov cx,#IMAGES ! test all names
mov si,#DESCR0
push si
fi_nextn:
mov di,#cmdline
fi_nextc:
mov al,(si) ! get next character in descr
! get the character
#ifdef LCF_IGNORECASE
call upcase
#endif
mov ah,al
mov al,(di) ! get next char in cmdline
#ifdef LCF_IGNORECASE
call upcase
#endif
or ah,ah ! NUL in descriptor name
jz fi_dscend
cmp al,ah ! character equal ?
jne fi_skipn ! no -> try next one
inc si ! test next character
inc di
jmp fi_nextc
fi_dscend:
cmp al,#32 ! space or NUL -> equal
je fi_found
or al,al
jz fi_found
fi_skipn:
pop si
add si,#id_size ! test next name
push si
loop fi_nextn
pop si
xor ax,ax ; clears the carry
fi_exit:
pop di
pop si
pop cx
ret
fi_found:
pop bx ! BX is matched descriptor
mov ax,bx
sub ax,#DESCR0
mov cl,#id_size
div cl
cbw
mov di,[dimage]
cmp ax,di
je fi_nochange
mov [dimage],ax
cmp byte [abs_cx+1],#0 ! see if menu is displayed
je fi_nochange
xchg ax,di
call lowlite
xchg ax,di
call hilite
fi_nochange:
stc
jmp fi_exit
; menu_delline:
; delete the current command line
; common code from original second.S
;
; enter with:
; BX = command line pointer
;
; exit with:
; BX = updated command line pointer
;
;
menu_delline:
cmp bx,#cmdline ! done ?
je mdel9 ! yes -> done
push bx ! display BS,SPC,BS
mov bx,#bs
call say
pop bx
dec bx ! move the pointer
jmp menu_delline ! next one
mdel9: ret
; menu_setcmd:
; set currently selected image to be the command line
;
; enter with:
; AX = image# to select
; BX = cmdline pointer
;
; exit with:
; BX = updated
;
;
menu_setcmd:
push si
push ax
call menu_delline ; delete the current line
pop si ; get image# back
imul si,#id_size
add si,#DESCR0
mset1: lodsb
or al,al
jz mset6
mov (bx),al
inc bx
push bx
call display
pop bx
jmp mset1
mset6:
pop si
ret
; arrow
;
; Code that handles the arrow keys: left, up, down, right
;
;
arrow: cbw ; signed delta vector in AL
mov dx,[dimage] ;
add dx,ax ; new position
or dx,dx
jns arr1
arr0: xor dx,dx ; set to zero if neg.
arr1: mov ax,[nimage]
cmp dx,ax ; compare to max.
jb arr2
mov dx,ax
dec dx
arr2: ; we know the one to hi-lite is in range
mov ax,[dimage]
cmp ax,dx
je arr6
call lowlite ; un-hilite the old
xchg ax,dx
call hilite
call menu_setcmd ; set new command line
arr6:
jmp arr_vector
null: mov al,#1
cmp ah,#0x50 ; down arrow
je arrow
neg al
cmp ah,#0x48 ; up arrow
je arrow
mov dx,[nimage]
cmp ah,#0x4f ; end
je arr1
cmp ah,#0x47 ; home
je arr0
mov al,[nrow]
xchg ax,dx
mov ax,[dimage]
div dl
xchg ax,dx ; DL = cur col.
cmp ah,#0x4d ; right arrow
jne arr8
inc dx ; similar to dec al
cmp dl,[ncol] ; cmp (CUR COL + 1) : (NCOL)
jb arrow
jmp arr9
arr8:
cmp ah,#0x49 ; pg up
jne arr84
neg dh ; remainder [0..(nrow-1)]
mov al,dh
arrow1: jmp arrow
arr84:
cmp ah,#0x51 ; pg dn
jne arr88
not dh
add al,dh
jmp arrow
arr88:
neg al
cmp ah,#0x4b ; left arrow
jne arr9
or dl,dl
jnz arrow1
arr9:
cmp ah,#0x53 ; DEL
jne arr_vector
br delch ; treat as 0177 (rubout)
arr_vector:
br input ; ignore the rest
; menu_exit:
; erase the menu box to black
;
menu_exit:
push es
pusha
#if DEBUG_NEW
call me1
.ascii "menu_exit entered"
.byte 10,0
me1: pop bx
call say
;; call pause
#endif
xor ax,ax
cmp word [abs_cx],ax
mov word [suppress],ax
mov word [abs_cx],ax
je mn_exit_ret
call _done4
#if DEBUG_NEW
call me2
.ascii "called done4"
.byte 10,0
me2: pop bx
call say
;; call pause
#endif
mn_exit_ret:
#if DEBUG_NEW
call me3
.ascii "exit from menu_exit"
.byte 10,0
me3: pop bx
call say
;; call pause
#endif
popa
pop es
ret
#if 0
; menu_form_feed:
; simulate a FF on the console
;
menu_form_feed:
ret
#endif
; timer_display:
; check the timer 'cntdown' and display changes
;
timer_display:
push es
pusha
test byte [KEYTABLE+256+mt_t_row+1],#0xff ; see if not initialized
js timer99
mov dx,#0x2d2d ; get "--" means disabled
mov [tim_min],dx
mov [tim_sec],dx
mov ax,[cntdown] ; get timer countdown location
cmp ax,[tim_tick]
je timer99
mov [tim_tick],ax ; save last tick count
inc ax
jz timer8
mul c55 ; get time remaining in ms.
div c1000 ; convert to seconds
cmp ax,[tim_old]
je timer99
mov [tim_old],ax ; save seconds remaining
xor dx,dx
div c60 ; minutes in AX, seconds in DX
aam
add ax,#0x3030
xchg ah,al
mov [tim_min],ax ; put characters in buffer
xchg ax,dx
aam
add ax,#0x3030
xchg ah,al
mov [tim_sec],ax ; put characters in buffer
timer8:
push ds ;sch-hi
push #KEYTABLE+256+mt_t_fg
push #5 ; len
push ds ; cp -hi
push #tim_min
push word [KEYTABLE+256+mt_t_row]
push word [KEYTABLE+256+mt_t_col]
call _text
add sp,#14
timer99:
popa
pop es
ret
tim_min: db 0,0
.ascii ":"
tim_sec: db 0,0
tim_old: dw 0 ; last # seconds
tim_tick: dw 0 ; last timer tick value examined
c55: .word 2197 ;was 55, now 54.925*40
c1000: .word 40000 ;was 1000, now 40*1000
c60: .word 60
; hilite/lowlite
; enter with:
; AX = number [0..(nimage-1)] of entry to hilite
;
hilite:
push es
pusha
mov [dimage],ax ;remember one hilited
push cs
push #KEYTABLE+256+mt_h_fg
jmp lowlite1
lowlite:
push es
pusha
push cs ; sch hi
push #KEYTABLE+256+mt_fg ; sch low
lowlite1:
cmp BYTE [abs_cx+1],#0
je lowlite9
mov bx,ax ;save argument in BX
mov al,#0x20 ; SP
mov cx,[limage]
inc cx
inc cx
mov di,#im_name
push cx ; len
push ds ; cp hi
push di ; cp low
push ds
pop es
rep
stosb
imul si,bx,#id_size
add si,#DESCR0
mov di,#im_name+1
lowlite2:
lodsb
or al,al
jz lowlite3
stosb
jmp lowlite2
lowlite3:
mov cx,[KEYTABLE+256+mt_col]
mov ax,[KEYTABLE+256+mt_row]
mov si,[KEYTABLE+256+mt_maxcol] ;
lowlite4:
cmp bx,si
jb lowlite5
add cx,[KEYTABLE+256+mt_xpitch]
sub bx,si
jmp lowlite4
lowlite5:
#ifdef PIXADDRESS
shl bx,#4 ;use pixel addressing
#endif
add ax,bx
push ax
push cx
call _text
add sp,#10
lowlite9:
add sp,#4
popa
pop es
ret
im_name: .blkb MAX_IMAGE_NAME+3
.even
dimage: dw 0 ; default image
nimage: dw 0 ; number of images
limage: dw 0 ; longest length of image name
;nrow: dw 0 ; number of rows of selections
nrow equ KEYTABLE+256+mt_maxcol
;ncol: dw 0 ; number of columns (default=2)
ncol equ KEYTABLE+256+mt_ncol
abs_cx: dw 0 ; upper left of scrolling area
; end of bitmap.S
|