home *** CD-ROM | disk | FTP | other *** search
- ;-----------------------------------------------------------------------------
- ;
- ; MYASM.ASM IS A REPLACEMENT FOR UIASM.ASM
- ;
- ; Copyright (C) 1989 Microsoft Corporation, All Rights Reserved
- ;
- ; GetCopyBox : Gets screen box info and places into string variable
- ; PutCopyBox : Puts screen box info from string variable onto screen
- ; AttrBox : Set attribute for an area of the screen
- ;
- ;DECLARE SUB getcopybox (row1%, col1%, row2%, col2%, buffer$)
- ;DECLARE SUB putcopybox (row%, col%, buffer$)
- ;DECLARE SUB attrbox (row1%, col1%, row2%, col2%, attr%)
- ;
- ; 1991 Raymond E Dixon
- ;
- ; Colorwind : Changes the color attributes of all characters within a box
- ; : Fill with character within a box, space clears window
- ;
- ; Drawwind : draw a window with or without border and clear window
- ;
- ;DECLARE SUB captal (a$) 'CONVERT FIRST LETTER TO UPPER CASE
- ;
- ; Captal a$ : converts first char to U/case and others to l/case
- ; : needed for proper name format
- ; From :"rAyMoNd e DIXON"
- ; To :"Raymond E Dixon"
- ;
- ; ClrKeyBuf : clears keyboard buffer
- ;
- ; "all sub work with far or near strings"
- ;
- ; colorwind is a replacement for attrbox, allows foreground,background
- ; instead of attribute plus fill char.
- ;
- ;DECLARE SUB Colorwind (row1%, col1%, row2%, col2%,char%,fillflag%, foreground%, background%)
- ;
- ; drawwind draws a border with option to clear screen and or fill.
- ; char% = asc(anychar) or char value , char = 176
- ;
- ;DECLARE SUB drawwind (row1%, col1%, row2%, col2%, frame%,clear%)
- ;
- ;DECLARE SUB pnc (a$, row%, col%, foreground%, background%)
- ;
- ; PNC string$,row%,col%,fg%,bg% : print in color
- ;
- ;flag function allow up to 64 flags without using basic data space
- ; flag function from PC MAG
- ;
- ; to use :
- ; const endofpage = 58
- ;
- ; setflag (endofpage)
- ;
- ; if printedlines = getflag(endofpage) then
- ; resetflag(endofpage)
- ; exit print loop
- ; else
- ; print next line
- ; end if
- ;
- ;DECLARE SUB setflag(flag%) 'SET FLAG
- ;DECLARE FUNCTION getflag(flag%) 'GET STATE OF FLAG
- ;DECLARE SUB resetflag(flag%) 'RESET FLAG
- ;DECLARE SUB clearall 'CLEAR ALL FLAGS
- ;
- ;DECLARE FUNCTION CPUcheck% 1 = 8086/88
- ; 2 = 80286
- ; 3 = 386/486
- ;
- ;DECLARE FUNCTION VIDEOcheck% 1 = MDA
- ; 2 = HGC
- ; 3 = CGA
- ; 4 = EGA
- ; 5 = VGA color
- ; 6 = VGA mono
- ; 7 = MCGA
- ; 8 = model 30 color
- ; 9 = model 30 mono
- ;-----------------------------------------------------------------------------
-
- ;NOTE: For optimum speed, these routines write directly to screen memory
- ; without waiting for re-trace. If "snow" is a problem, these routines
- ; will need modification.
-
- include dos.inc
-
- .model medium,basic
-
- extrn STRINGADDRESS:far ;BASIC RTL entry point for string info
- ;returns basic far string address
-
- extrn STRINGLENGTH:far ;BASIC RTL entry point for string info
- ;returns basic far string length
-
- ;-----------------------------------------------------------------------------
-
- .data
- even
-
- fillflag db ? ;fillflag
- fill db ? ;fill char
- attr db ? ;color attribute (colorwind)
- x0 db ? ;x coord of upper-left
- y0 db ? ;y coord of upper-left
- x1 db ? ;x coord of lower-right
- y1 db ? ;y coord of lower-right
- bwidth db ? ;box width
- height db ? ;box height
- strdoff dw ? ;string pointer offset
- strdseg dw ? ;string pointer segment
- scrseg dw ? ;screen segment
- movword dw ? ;word count = char + attr
-
- .code
-
- ;---- place segment of screen memory in SCRSEG
-
- getscrseg proc
-
- push ax ;save value of AX
- mov ah,0Fh
- int 10h ;INT 10H fn. 0Fh - Get Video Mode
- mov dgroup:scrseg,0B800h ;assume COLOR screen for now
- cmp al,07h ;is it MONOCHROME mode?
- jne arnd1
- mov dgroup:scrseg,0B000h ;yes, set for mono screen seg
- arnd1: pop ax ;restore AX
- ret ;and exit
-
- getscrseg endp
-
- ; Given X and Y in AH and AL, find the offset
- ; into screen memory and return in AX
-
- getmemxy proc
-
- push dx ;save DX
- push ax ;save coords
- mov dl,160
- mul dl ;multiply Y by 160
- pop dx ;put coords in DX
- mov dl,dh
- mov dh,0
- add dl,dl ;double X
- add ax,dx ;and add to mult. result for final!
- pop dx ;restore DX
- ret
-
- getmemxy endp
-
- ; This is the routine that copies screen info to the string variable
-
- PUBLIC getcopybox
-
- getcopybox proc far
-
- push bp
- mov bp, sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- getstart:
- mov bx,[bp + 14] ;get y0
- mov ax,[bx]
- mov y0,al
- mov bx,[bp + 12] ;...x0
- mov ax,[bx]
- mov x0,al
- mov bx,[bp + 10] ;...y1
- mov ax,[bx]
- mov y1,al
- mov bx,[bp + 8] ;...x1
- mov ax,[bx]
- mov x1,al
- mov bx,[bp + 6] ;...and the destination str desc.
- push bx
- call STRINGADDRESS ;for both near and far string support
- mov strdoff,ax
- mov strdseg,dx
- dec x0 ;subtract 1 from
- dec y0 ;all coordinates
- dec x1 ;to reflect BASIC's
- dec y1 ;screen base of 1 (not 0)
- getchkscr:
- call getscrseg ;set up screen segment
- getsetstr:
- mov al,x1
- sub al,x0 ;find width of box
- mov bwidth,al ;and save
- add al,1 ;add one to width
- mov ah,0 ;to find # words to move
- mov movword,ax ;MovWord = (width+1)
- mov al,y1
- sub al,y0 ;find height of box
- mov height,al ;and save
- mov ES,strdseg
- mov di,strdoff ;string is the destination
- mov si,offset bwidth ;point to width
- movsb ;put width in string
- mov si,offset height
- movsb ;and the height, too
- getmovstr:
- mov al,y0
- mov ah,x0 ;put coords in AH and AL
- call getmemxy ;and find offset into screen mem
- mov si,ax ;this will be the source
- getdomove:
- mov cx,movword
- push ds
- mov ds,scrseg
- rep movsw ;move a row into the string
- pop ds
- add SI,160
- sub si,movword ;Add 160-(movword*2) to si
- sub si,movword ;to point to next row
- cmp height,0 ;was that the last row?
- je getdone ;yes, we're done
- dec height ;decrement height
- jmp getdomove ;and do another row
- getdone:
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret 10 ;there were 5 parameters
-
- getcopybox endp
-
- ;-----------------------------------------------------------------------------
- ;This is the routine that copies the information stored
- ;in the string to the screen in the specified location
- ;-----------------------------------------------------------------------------
-
- PUBLIC putcopybox
-
- putcopybox proc far
-
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- putstart:
- mov bx,[bp+10] ;get y0
- mov ax,[bx]
- mov y0,al
- mov bx,[bp+8] ;...x0
- mov ax,[bx]
- mov x0,al
- mov bx,[bp+6] ;...and the destination string
-
- push bx
- call STRINGADDRESS ;for both near and far string support
- mov strdoff,ax
- mov strdseg,dx
-
- dec x0 ;subtract 1 from
- dec y0 ;all coordinates
-
- putchkscr:
- call getscrseg ;set up scrseg
-
- putsetstr:
- push ds
- pop es ;equate ES to DS
-
- mov si,strdoff ;point DS:SI to string mem
- push ds
- mov ds,strdseg
- mov di,offset bwidth
- movsb ;get width
- mov di,offset height
- movsb ;and height out of string
- pop ds
-
- mov al,bwidth
- add al,1
- mov ah,0
- mov movword,ax ;set movword to (bwidth+1)
-
- mov ah,x0
- mov al,y0 ;get coords
- call getmemxy ;and find offset into screen mem
- mov DI,ax
- mov es,scrseg ;ES:DI -> screen mem (UL corner)
- putdomove:
- mov cx, movword
- push ds
- mov ds, strdseg
- rep movsw ;move a row onto the screen
- pop ds
- add DI,160
- sub di,movword ;add 160-(movword*2) to DI
- sub di,movword ;to point to next row on screen
- cmp height,0 ;was that the last row?
- je putdone ;yes, we're finished
- dec height
- jmp putdomove ;no, decrement and do again
- putdone:
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret 6 ;pop off 3 parameters
- putcopybox endp
-
- ;-----------------------------------------------------------------------------
- ;This is the routine that changes the attribute of the box's characters
- ;-----------------------------------------------------------------------------
-
- PUBLIC attrbox
-
- attrbox proc far
-
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- atrstart:
- mov bx,[bp+14] ;get y0
- mov ax,[bx]
- mov y0,al
- mov bx,[bp+12] ;...x0
- mov ax,[bx]
- mov x0,al
- mov bx,[bp+10] ;...y1
- mov ax,[bx]
- mov y1,al
- mov bx,[bp+8] ;...x1
- mov ax,[bx]
- mov x1,al
- mov bx,[bp+6] ;...and finally the new color value
- mov ax,[bx]
- mov attr,al
- dec y0 ;subtract 1 from
- dec x0 ;all coordinates
- dec y1 ;to reflect BASIC's
- dec x1 ;screen base of 1 (not 0)
- atrchkscr:
- call getscrseg ;set up screen segment
- atrsetup:
- mov al,x1
- sub al,x0 ;find width of box
- inc al
- xor ah,ah
- mov movword,ax ;(width + 1 = movword)
- mov al,y1
- sub al,y0 ;find height of box
- mov height,al ;and save
- atrchgclr:
- mov al,y0
- mov ah,x0 ;put coords in AH and AL
- call getmemxy ;find offset into screen memory
- mov di,ax ;(which is our destination)
- mov ES,scrseg
- mov al,attr ;get the color value to store
- atrdoit:
- mov cx,movword
- atrloop:
- inc di ;skip the character value
- stosb ;write new color value
- loop atrloop ;cx times
- add di,160 ;add 160-(movword*2) to di
- sub di,movword
- sub di,movword
- cmp height,0 ;was that the last row?
- je atrdone ;yes, we be finished
- dec height ;no, decrement height
- jmp atrdoit
- atrdone:
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
- ret 10 ;pull off 5 paramters and return
- attrbox endp
-
- ;-----------------------------------------------------------------------------
- ; This is the routine that changes the colors of the box's characters fg%,bg%
- ; can also fill with characers
- ; from here down is add to microsoft's uiasm
- ;
- ;-----------------------------------------------------------------------------
-
- PUBLIC colorwind
-
- colorwind proc far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- colorstart:
- mov bx,[bp+20] ;get y0
- mov ax,[bx]
- mov y0,al
- mov bx,[bp+18] ;...x0
- mov ax,[bx]
- mov x0,al
- mov bx,[bp+16] ;...y1
- mov ax,[bx]
- mov y1,al
- mov bx,[bp+14] ;...x1
- mov ax,[bx]
- mov x1,al
- mov bx,[bp+12] ;the new char value
- mov ax,[bx]
- mov fill,al
- mov bx,[bp+10] ;the fill flag
- mov ax,[bx]
- mov fillflag,al
- xor ax,ax
- mov bx,[bp+6] ; background color
- mov ax,[bx] ; load color
- mov cl,04 ; shift length
- shl ax,cl ; shift to proper position
- mov bx,[bp+8] ; foreground color
- mov dx,[bx] ;
- and dl,00010000b ; leave blink attr only
- mov cl,03 ; shift length
- shl dx,cl ; shift blink to correct position
- add ax,dx ; this is attr
- mov dx,[bx] ; reload forground
- and dl,00001111b ; remove blink
- add ax,dx ; completed attr
- mov attr,al ; save it
- cmp byte ptr fillflag,2 ;return if not 0,1,2
- jg fillchgclr
- dec y0 ;subtract 1 from
- dec x0 ;all coordinates
- dec y1 ;to reflect BASIC's
- dec x1 ;screen base of 1 (not 0)
- colorchkscr:
- call getscrseg ;set up screen segment
- cmp byte ptr fillflag,1
- jg fillchgclr ;do char only
- colorsetup:
- mov al,x1
- sub al,x0 ;find width of box
- inc al
- xor ah,ah
- mov movword,ax ;(width + 1 = movword)
- mov al,y1
- sub al,y0 ;find height of box
- mov height,al ;and save
- colorchgclr:
- mov al,y0
- mov ah,x0 ;put coords in AH and AL
- call getmemxy ;find offset into screen memory
- mov di,ax ;which is destination
- mov ES,scrseg
- mov al,attr ;get the color value to store
- colorit:
- mov cx,movword
- colorloop:
- inc di ;skip the character value
- stosb ;write new color value
- loop colorloop ;cx times
- add di,160 ;add 160-(movword*2) to di
- sub di,movword
- sub di,movword
- cmp height, 0 ;was that the last row?
- je colordone ;yes, we be finished
- dec height ;no, decrement height
- jmp colorit
- colordone:
- cmp byte ptr fillflag,1
- je filldone
- fillchgclr:
- mov al,x1
- sub al,x0 ;find width of box
- inc al
- xor ah,ah
- mov movword,ax ;(width + 1 = movword)
- mov al,y1
- sub al,y0 ;find height of box
- mov height,al ;and save
- mov al,y0
- mov ah,x0 ;put coords in AH and AL
- call getmemxy ;find offset into screen memory
- mov di,ax ;(which is our destination)
- mov ES,scrseg
- mov al,fill ;get the color value to store
- filldoit:
- mov cx,movword
- fillloop:
- stosb ;write new char value
- inc di ;skip the attrib value
- loop fillloop ;cx times
- add di,160 ;add 160-(movword*2) to di
- sub di,movword
- sub di,movword
- cmp height,0 ;was that the last row?
- je filldone ;yes, we be finished
- dec height ;no, decrement height
- jmp filldoit
- filldone:
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
- ret 16 ;pull off 8 paramters and return
- colorwind endp
-
- ;----------------------------------------------------------------------------
- ; print in color
- ;----------------------------------------------------------------------------
- PUBLIC PNC
- ;----------------------------------------------------------------------------
- PNC proc far
-
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- pncstart:
- mov bx,[bp+12] ;...y1
- mov ax,[bx]
- mov y0,al
- mov bx,[bp+10] ;...x1
- mov ax,[bx]
- mov x0,al
- xor ax,ax
- mov bx,[bp+6] ; background color
- mov ax,[bx] ; load color
- mov cl,04 ; shift length
- shl ax,cl ; shift to proper position
- mov bx,[bp+8] ; foreground color
- mov dx,[bx] ;
- and dl,00010000b ; leave blink attr only
- mov cl,03 ; shift length
- shl dx,cl ; shift blink to correct position
- add ax,dx ; this is attr
- mov dx,[bx] ; reload forground
- and dl,00001111b ; remove blink
- add ax,dx ; completed attr
- mov attr,al ; save it
- mov bx,[bp+14] ;get the string descriptor
- push bx
- call STRINGADDRESS ;for both near and far string support
- mov strdoff,ax
- mov strdseg,dx
- mov bx,[bp+14] ;get the string descriptor again
- push bx ;save descriptor
- call STRINGLENGTH ;for both near and far string support
- mov movword,ax ;save string length
- mov cx,ax
- jcxz pncdone ;ret if null string
- dec x0 ;subtract 1 from
- dec y0 ;all coordinates
- pncchkscr:
- call getscrseg ;set up scrseg
- pncsetstr:
- mov ah, x0
- mov al,y0 ;get coords
- call getmemxy ;and find offset into screen mem
- mov DI,ax
- mov es,scrseg ;ES:DI -> screen mem (UL corner)
- mov cx,movword ;get length of string
- mov si,strdoff ;point SI to string offset
- mov ah,attr ;get color attribute before seg change
- mov ds,strdseg ;get string segment in DS:
- pncdomove:
- mov al,[si] ;get char to print
- stosw
- inc SI
- loop pncdomove
- pncdone:
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret 10 ;pop off 5 parameters
- PNC endp
-
- ;-----------------------------------------------------------------------------
- PUBLIC Captal
- ;-----------------------------------------------------------------------------
- Blanktog db 0
- leng dw 0
- ;-----------------------------------------------------------------------------
-
- Captal PROC Far
-
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- mov bx,[bp+6] ;descriptor to string into SI
- push bx ;save descriptor
- call STRINGLENGTH ;for both near and far string support
- mov leng,ax ;save string length
- mov cx,ax ;put length into CX
- ;or cx,cx ;is length 0
- jcxz Exit ;exit
- mov bx,[bp+6]
- push bx
- call STRINGADDRESS ;for both near and far string support
- mov cx,leng
- mov si,ax ;address of string in SI
- mov ds,dx
- mov di,si ;set up registers for data move
- push ds
- pop ES
- mov byte ptr Blanktog,00h ;character is blank
- Next: lodsb ;put character into AL
- cmp al,' ' ;is it a blank
- je Fndblnk ;yes set switch
- cmp al,27h ;is it a quote
- jne Noblnk ;no, skip special
- Fndblnk:
- mov byte ptr Blanktog,00h ;character is blank
- jmp Skib
- Noblnk:
- cmp byte ptr Blanktog,0FFh ;is upper case or lower needed
- je Lowcase ;change to lower case
- mov byte ptr Blanktog,0FFh ;reset switch
- jmp Upcase
- Lowcase:
- cmp al,'A' ;is it below "A"?
- jb Skib ;yes, skip
- cmp al,'Z' ;is it above "Z"?
- ja Skib ;yes, skip
- or al,20h ;turn on lower case bit
- jmp Skib
- Upcase:
- cmp al,'a' ;is it below "a"?
- jb Skib ;yes, skip it
- cmp al,'z' ;is it above "z"?
- ja Skib ;yes skip
- and al,0DFh ;turn off lower case bit
- Skib:
- stosb ;put character back in string
- Loop Next ;do all char
- Exit:
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
-
- ret 2 ;pop off 1 parameters
-
- Captal endp
-
- ;-----------------------------------------------------------------------------
- ; This is the routine that draws the box's with characters
- ;-----------------------------------------------------------------------------
- even
-
- tlc db ? ;store top left corner here
- trc db ? ;store top right corner here
- brc db ? ;store bottom right corner here
- blc db ? ;store bottom left corner here
- vbc db ? ;store vertical character here
- htc db ? ;store horiz top character here
- hbc db ? ;store horiz bottom character here
- clear db ? ;store clear flag here
-
- PUBLIC drawwind
-
- ;-----------------------------------------------------------------------------
-
- drawwind proc far
-
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- mov bx,[bp+16] ;get y0
- mov ax,[bx]
- mov y0,al
- mov bx,[bp+14] ;x0
- mov ax,[bx]
- mov x0,al
- mov bx,[bp+12] ;y1
- mov ax,[bx]
- mov y1,al
- mov bx,[bp+10] ;x1
- mov ax,[bx]
- mov x1,al
- mov bx,[bp+6] ;get clear flag first
- mov ax,[bx]
- mov clear,al
- mov bx,[bp+8] ;now get frame type in al
- mov ax,[bx]
-
- ;type 0 clears frame or entire window
-
- cmp al,0 ;type 0 ,see type 4 for definition
- jg type1
- mov tlc,' '
- mov trc,' '
- mov brc,' '
- mov blc,' '
- mov vbc,' '
- mov htc,' '
- mov hbc,' '
- jmp drawstart
-
- ;type 1 is single
-
- type1: cmp al,1 ;type 1
- jg type2
- mov tlc,0dah
- mov trc,0bfh
- mov brc,0d9h
- mov blc,0c0h
- mov vbc,0b3h
- mov htc,0c4h
- mov hbc,0c4h
- jmp drawstart
-
- ;type 2 is double
-
- type2:
- cmp al,2 ;type 2
- jg type3
- mov tlc,0c9h
- mov trc,0bbh
- mov htc,0cdh
- mov brc,0bch
- mov blc,0c8h
- mov vbc,0bah
- mov hbc,0cdh
- jmp drawstart
-
- ;type 3 is double top single sides
-
- type3:
- cmp al,3 ;type 3
- jg type4
- mov tlc,0d5h
- mov trc,0b8h
- mov htc,0cdh
- mov brc,0beh
- mov blc,0d4h
- mov vbc,0b3h
- mov hbc,0cdh
- jmp drawstart
-
- ;add next segment for each type you add and edit and remove comments
-
- ;type 4 is solid top and bottom
-
- type4: ;add your type here
-
- ;cmp al,4 ;add your type number here
- ;jg yourtype ;example type5
- mov tlc,0dbh
- mov trc,0dbh
- mov brc,0dbh
- mov blc,0dbh
- mov vbc,' '
- mov htc,0dbh
- mov hbc,0dbh
-
- ;jmp drawstart ; leave all comments for last type
-
- ;add your type before here
-
- drawstart:
-
- dec y0 ;subtract 1 from
- dec x0 ;all coordinates
- dec y1 ;to reflect BASIC's
- dec x1 ;screen base of 1 (not 0)
- call getscrseg ;set up screen segment
- drawsetup:
- mov al,x1
- sub al,x0 ;find width of box
- inc al
- xor ah,ah
- mov movword,ax ;width + 1 = movword
- mov al,y1
- sub al,y0 ;find height of box
- mov height, al ;and save
- drawchgclr:
- mov al,y0
- mov ah,x0 ;put coords in AH and AL
- call getmemxy ;find offset into screen memory
- mov di,ax ;start pos to print
- mov es,scrseg ; get screen seg
- mov al,tlc ;get top left char
- stosb ;print it
- inc DI
- mov cx,movword ; characters to print per line
- dec cx ; sub left and right char
- dec cx
- mov al,htc ;get horiz top character
- drawtop:
- stosb ;write new char value
- inc di ;skip the attrib value
- loop drawtop ;cx times
- mov al,trc ;get top right character
- stosb
- inc DI
- nextline:
- add di,160 ;add 160-(movword*2) to di
- sub di,movword
- sub di,movword
- mov cx,movword
- dec cx ;adjust width count
- mov al,vbc ;do left side
- cmp byte ptr clear,00h ;clear if 1
- je noclear ; don't clear window
- dosides:
- stosb ;for blank window
- inc DI
- mov al,' ' ;user space char
- loop dosides
- mov al,vbc ;side character
- stosb ;do right side
- inc DI
- dec height ;no, decrement height
- cmp height, 1 ;was that the last row?
- jg nextline
- jmp lastline
- noclear:
- stosb ;do left side first
- dec DI
- dorest:
- inc di ;skip char
- inc di ;skip attr
- loop dorest ; loop width
- mov al,vbc
- stosb ;do right side
- inc di ;skip attr
- dec height ;decrement height
- cmp height,1 ;was that the last row?
- jg nextline
- lastline: ;now do bottom frame
- add di,160 ;add 160-(movword*2) to di
- sub di,movword
- sub di,movword
- mov al,blc ;get bottom left char
- stosb ;print it
- inc DI
- mov cx,movword
- dec cx
- dec cx
- mov al,hbc ;get horiz bottom character
- drawbot:
- stosb ;write new char value
- inc di ;skip the attrib value
- loop drawbot ;cx times
- mov al,brc ;get bottom right corner
- stosb
- drawdone:
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
- ret 10 ;pull off 5 paramters and return
- drawwind endp
-
- ;-----------------------------------------------------------------------------
-
- ClrKeyBuf PROC Far
-
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- mov ah,01h ;check keyboard service
- int 16h ;call BIOS
- ClrKybd:
- jz Exit ;exit if keyboard buffer is clear
- mov ah,00h ;read keyboard service
- int 16h ;call BIOS
- mov ah,01h ;check keyboard service
- int 16h ;call BIOS
- jmp ClrKybd ;check for another key
- Exit:
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
- ret
- ClrKeyBuf endp
-
- ;----------------------------------------------------------------------------
- emmname db 'EMMXXXX0'
- basseg dw ?
- ;---------------------------------------------------------------------------
-
-
- ; RomDate$ ROM revision date
-
- PUBLIC getromdate
-
- getromdate PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
-
- mov bx,[bp+6]
- push bx ;save descriptor
- call STRINGLENGTH ;for both near and far string support
- mov cx,ax ;put length into CX
- cmp cx,8
- jl exit ;exit no room for date
- mov bx,[bp+6]
- push bx
- call STRINGADDRESS ;for both near and far string support
- mov cx,8
- mov di,ax ;address of string in DI
- mov ES,dx
- mov cx,8 ;length of move
- mov si,0FFF5h ;offset of BIOS signature
- mov ax,0F000h; ;segment of BIOS signature
- mov ds,ax ;put it in DS
- cld ;clear direction flag
- rep movsb ;move it to parameter
-
- Exit:
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret 2
- getromdate endp
-
- ; Ram% amount of base RAM
- ; ExtRAM% amount of Extended Memory
- ; ExpRam amount of Expanded memory
-
- PUBLIC getram
-
- getram PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
-
- mov ax,ds ;save basic data segment
- mov basseg,ax
- int 12h ;call BIOS - conventional memory size service
- mov si,[bp+10] ;address of parameter
- mov [si],ax ;move ram size to parameter
- push cs
- pop ds ;restore DS
- mov ah,35h ;get interrupt vector service
- mov al,67h ;EMM vector
- int 21h ;call DOS
- mov di,0Ah ;bump to device name
- mov si,offset emmname ;point to EMM mgr name
- mov cx,8 ;compare length
- cld ;clear direction flag
- repz cmpsb ;it is correct name
- jnz NoEMM ;no
- mov ah,42h ;request number of pages
- int 67h ;call EMM driver
- or ah,ah ;was call successful?
- mov ds,basseg
- jnz NoEMM ;no expanded memory
- mov si,[bp+6] ;point to EMM parm
- mov [si],dx ;DX has number of 16K pages of Exp mem
- jmp GetExtMem ;look for extended memory
-
- NoEMM:
-
- mov ds, basseg
- mov si,[bp+6] ;point to EMM parm
- mov word ptr [si],0 ;indicate no expanded memory
-
- GetExtMem:
-
- mov si,[bp+8] ;Extended memory parm
- mov word ptr [si],0 ;indicate no extended memory
- mov ax,0F000h
- mov ES,ax
- mov di,0fffeh
- mov al,byte ptr es:[di] ;get machine id
- cmp al,0FCh ;is this an AT?
- jne notat ;get number of hard disks
- mov al,31h ;if at get extmem from cmos
- out 70h,al ;setup reg
- jmp $+2 ;delay
- in al,71h
- xchg al,ah
- mov al,30h
- out 70h,al
- jmp $+2 ;delay
- in al,71h
- mov ds,basseg
- mov SI,[bp+8]
- mov [si],ax ;move to parm
- notat:
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret 6
-
- getram endp
-
- ; LPT% number of parallel ports
-
- PUBLIC getnumlpt
-
- getnumlpt PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- int 11h ;call BIOS - equipment list
- and ax,0C000h ;clear all but number of LPT
- mov cl,14 ;shift length
- shr ax,cl ;adjust it
- pop di
- pop si
- pop ES
- pop ds ;restore registers
- pop bp
- ret
- getnumlpt endp
-
- ; Com% number of serial ports
-
- PUBLIC getnumcom
-
- getnumcom PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
-
- int 11h ;call BIOS - equipment list
- and ax,0E00h ;clear all but number of serial ports
- mov cl,9 ;shift length
- shr ax,cl ;adjust it
-
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret
- getnumcom endp
-
- ; GetNoFlop% number of floppy drives
-
- PUBLIC getnumflop
-
- getnumflop PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
-
- int 11h ;call BIOS - equipment list
- and ax,11000000b ;clear all but diskette drives
- mov cl,6 ;shift length
- shr ax,cl ;adjust it
- inc ax ;bump it by one
- nodrives:
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret
- getnumflop endp
-
- ; Gameport% number of game ports
-
- PUBLIC getnumgames
-
- getnumgames PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
-
- int 11h ;call BIOS - equipment list
- and ax,1000000000000b ;clear all but game port
- mov cl,12 ;shift length
- shr ax,cl ;adjust it
-
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret
- getnumgames endp
-
- ; GetNoHard% number of hard disks
-
- PUBLIC getnumhard
-
- getnumhard PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
-
- mov ax,40h ;segment of disk info
- mov es,ax ;initialize ES
- mov bx,75h
- mov al,byte ptr es:[bx] ;nunber of drives
- pop DI
- pop SI
- pop ES
- pop ds ;restore registers
- pop bp
- ret
-
- getnumhard endp
-
- ;---------------------------------
- flags db 8 dup(0)
- ;---------------------------------
- ; set and get flags
- ;---------------------------------
-
- Clearall PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- mov DI,OFFSET cs:flags
- mov cx,4
- xor ax,ax
- rep stosw
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
- ret
-
- Clearall endp
-
- ;-----------------------------------------------------------------------------
-
- Resetflag PROC Far
-
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- mov SI,[bp+6]
- CALL doflags
- jc exitclear
- not al
- and cs:[flags+bx],al
- exitclear:
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
- ret 2
- Resetflag endp
-
- ;-----------------------------------------------------------------------------
-
- Setflag PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- mov SI,[bp+6]
- CALL doflags
- jc exitset
- or cs:[flags+bx],al
- exitset:
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
- ret 2
-
- setflag endp
-
- ;-----------------------------------------------------------------------------
-
- Getflag PROC Far
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
- mov SI,[bp+6]
- CALL doflags
- test cs:[flags+bx], al
- mov ax,0
- jz exitget
- dec ax
- exitget:
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
- ret 2
- Getflag endp
-
- ;---------------------------------------------------------------------------
-
- Doflags proc near
- mov ax,[SI]
- dec ax
- cmp ax,63
- ja doerror
- push ax
- mov cx,8
- xor dx,dx
- div cx
- mov bx,ax
- mov al,1
- pop cx
- rol al,cl
- clc
- ret
- doerror:
- stc
- ret
- doflags endp
-
-
- PUBLIC CPUcheck
- CPUcheck proc FAR ;Test CPU-Type (offical INTEL Method)
-
- push bp
- mov bp,sp
- push ds
- push ES
- push SI
- push di ;preserve registers
-
- xor ax,ax ;Push 0
- push ax ;on Stack
- popf ;pop Flags
- pushf ;Push flags
- pop ax ;0 in AX
- and ax,0F000h ;0 Bits 11-8
- cmp ax,0F000h ;
- je MC_8086 ;8086
-
- mov ax,0F000h ;Push f000
- push ax ;Stack
- popf ;Flags
- pushf ;Stack
- pop ax ;AX from Stack
- and ax,0F000h ;0 Bits 11-8
- jz MC_80286 ;80286
-
- mov ax,3 ;Set AX=3 for 80386/80386SX/80486
- jp CPUdone ;End
-
- mc_80286:
- mov ax,2 ;Set AX=2 for 80286
- jp CPUdone ;end
-
- mc_8086:
- mov ax,1 ;set AX=1 for 8086/8088
-
- CPUdone:
- pop DI
- pop SI
- pop ES
- pop ds
- pop bp ;restore registers
-
- ret ;end
-
- CPUcheck endp
-
-
- PUBLIC VIDEOcheck
-
- VIDEOcheck proc FAR ;Test video adapter
-
- push bp
- mov bp,sp
- push ds
- push es
- push si
- push di ;preserve registers
-
- mov ax,1A00H ;Read display combination code
- int 10h
- cmp al,1AH ;Is VGA or MCGA present?
- jne novga
- mov ax,7 ;Set bit for MCGA adapter
- cmp bl,0BH ;Is it model 30 with mono?
- mov ax,8
- je setbits
- cmp bl,0CH ;Is it model 30 with color?
- mov ax,9
- je setbits
- mov ax,6 ;Set bit for VGA adapter
- cmp bl,7 ;Is it VGA mono?
- je setbits
- cmp bl,8 ;Is it VGA color?
- mov ax,5
- je setbits
-
- novga:
- xor dh,dh
- mov ah,0B8H ;Look for a color adapter
- call lookforcard
- jne nocolor
- mov ax,3 ;Set bit for color adapter
- jmp setbits
- nocolor:
- mov ah,0B0H ;Look for mono adapter
- call lookforcard
- jne nomono
- mov ax,1 ;Set bit for mono adapter
- jmp setbits
- nomono:
- mov ah,12H
- mov bl,10H ;BIOS get EGA info function
- int 10H
- cmp bl,10H ;Did BL change?
- mov ax,0
- je setbits ;If not, no EGA present
- mov ax,4 ;set bit for EGA mono only
-
- setbits:
-
- pop di
- pop si
- pop es
- pop ds
- pop bp ;restore registers
-
- ret ;end
-
- VIDEOcheck endp
-
- ;---------------------------------------------------------------------
- ; This routine examines memory to look for a display card.
- ;---------------------------------------------------------------------
-
- lookforcard proc near
-
- xor si,si ;Look at offset zero
- push ds
- xor al,al
- mov ds,ax ;Load the segment register
- mov ch,[si] ;Store the initial value
- mov al,55H
- mov [si],al ;Write pattern of ones and zeros
- jmp delay ;A short delay
- delay:
- mov ah,[SI] ;Read the byte we just wrote
- mov [si],ch ;Restore the initial value
- pop ds
- cmp al,ah ;Did it match?
- ret
-
- lookforcard endp
-
- end
-
-