Category : Assembly Language Source Code
Archive   : MSCPOPUP.ZIP
Filename : WINDOW1.ASM

 
Output of file : WINDOW1.ASM contained in archive : MSCPOPUP.ZIP
DGROUP group NULL, _DATA

NULL segment para public 'BEGDATA'
NULL ENDS

_DATA segment para public 'DATA'
extrn _vidmseg:word, _vidmoff:word, _scrnbuf:byte
extrn _scrnmap:byte, _attr:byte
extrn _dhandle:word, _scraddr:word, _mapptr:word, _bufaddr:word
extrn _width:word, _height:word, _crt_base:word
_DATA ends

_TEXT segment para public 'CODE'

assume cs:_TEXT, ds:DGROUP

public _copyscrn, _copychar, _dispchar, _redraw
public _mov_pcsr, _csr_off, _csr_on
public _wscrollu, _dispattr, _getvmode

_copyscrn proc near ; copies the current video screen either to
; or from the specified buffer
push bp
mov bp,sp

tofrom equ [bp+4] ; =0 if TO address, =1 if FROM address
addr equ [bp+6] ; offset of start of buffer within DGROUP

cmp word ptr tofrom,0
jne copyfrom

copyto: mov si,_vidmoff ; Copy current video screen to buffer
mov di,addr
push ds
mov ax,_vidmseg
mov ds,ax
mov cx,2000 ;SCRN_ROWS * SCRN_COLS
cld
rep movsw
pop ds
pop bp
ret
copyfrom: ; copy buffer to screen
mov si,addr
mov di,_vidmoff
push es
mov es,_vidmseg
mov cx,2000 ;SCRN_ROWS * SCRN_COLS
cld
rep movsw
pop es
pop bp
ret
_copyscrn endp

_getvmode proc near ; returns current video mode
push si
push di
push bp ; these 3 are destroyed by the BIOS call
mov ah,15
int 10h ; call BIOS to return current video mode
xor ah,ah
pop bp
pop di
pop si
ret
_getvmode endp

_copychar proc near ; takes care of actually writing printed
; characters to screen memory
push es
mov es,_vidmseg
mov di,_scraddr
mov si,_bufaddr
movsw
pop es
ret
_copychar endp

; The following routine is passed a video memory address, a character to
; be printed and the current window handle.
; It looks up the proper byte in scrnmap[] and if the window viewable at
; that character location is the current window, it prints the character.

_dispchar proc near
push bp
mov bp,sp
push si
push di
mov di,[bp+4] ; get addr
mov si,di
shr si,1
add si,offset DGROUP:_scrnmap
mov al,[si] ; get byte from scrnmap[] table
xor ah,ah
cmp ax,[bp+8] ; is it equal to the current window handle?
jne dispch1
push es
mov es,_vidmseg
mov al,[bp+6] ; get character to print
mov ah,_attr
stosw ; print the character
pop es
dispch1:pop di
pop si
pop bp
ret
_dispchar endp

_dispattr proc near
push bp
mov bp,sp
mov bx,[bp+4] ; get addr
mov si,bx
shr si,1
add si,offset DGROUP:_scrnmap
mov al,[si] ; get byte from scrnmap[] table
xor ah,ah
cmp ax,[bp+8] ; is it equal to the current window handle?
jne dispat1
push es
mov es,_vidmseg
mov al,[bp+6] ; get attribute
mov es:[bx+1],al ; store the attribute byte
pop es
dispat1:pop bp
ret
_dispattr endp

_redraw proc near ; redraws a whole window

;di=screen address, si=scrnmap address, bx,buffer addr,
;ch=#rows, cl=#cols

push si
push di ; preserve register variables

mov dx,_dhandle
mov di,_scraddr
mov si,_mapptr
mov bx,_bufaddr
mov cl,byte ptr _width
mov ch,byte ptr _height
push es
mov es,_vidmseg
redraw1:
push di
push si
push cx ;save screen addr, map ptr, x & y counts
redraw2:
cmp dl,[si] ;does scrnmap[] = handle?
jne redraw3
mov ax,[bx] ;if so, copy character.
mov es:[di],ax
redraw3:
inc si ;add sizeof(scrnmap[0]) to si
add bx,2 ;BYTES_CHR
add di,2 ;BYTES_CHR
dec cl
jnz redraw2
pop cx
pop si
pop di
add di,160 ;SCRNCOLS*BYTES_CHR
add si,80 ;SCRNCOLS*sizeof(scrnmap[0])
dec ch
jnz redraw1
pop es
pop di
pop si
ret
_redraw endp

_wscrollu proc near
; wscrollu and wscrolld scroll a screen window on the current active video
; page up or down, respectively; the window's upper left corner is defined
; by dl(X),dh(Y) and its lower right corner by cl(X),ch(Y)

push bp
mov bp,sp
push si
push di

mov dl,[bp+4] ; get x1
mov dh,[bp+6] ; get y1
mov al,160
mul dh
mov bl,dl
xor bh,bh
add ax,bx
add ax,bx ; get 160*y+2*x
mov di,ax
mov cl,[bp+8] ; get x2
mov ch,[bp+10] ; get y2
sub ch,dh ;compute # rows to scroll
mov bl,ch
sub cl,dl ;compute # cols to scroll
inc cl
xor ch,ch
push ds
push es
mov ax,_vidmseg
mov ds,ax
mov es,ax
assume ds:nothing,es:nothing
mov si,di
add si,160
cld
wscu1: push cx
push si
push di
rep movsw ; copy one screen line
pop di
pop si
pop cx
add si,160
add di,160
dec bl
jnz wscu1
mov ax,0720h ;clear vacated line to white-on-black spaces
rep stosw
pop es
pop ds
assume ds:DGROUP
pop di
pop si
pop bp
ret
_wscrollu endp

_mov_pcsr proc near
push bp
mov bp,sp

mov bx,[bp+4] ; get cursor address
shr bx,1
mov dx,_crt_base
mov al,14
out dx,al
inc dx
mov al,bh
out dx,al
dec dx
mov al,15
out dx,al
inc dx
mov al,bl
out dx,al
call _csr_on
pop bp
ret
_mov_pcsr endp

_csr_off proc near
mov dx,_crt_base
mov al,10
out dx,al
inc dx
mov al,15
out dx,al
dec dx
mov al,11
out dx,al
inc dx
mov al,15
out dx,al
ret
_csr_off endp

_csr_on proc near
mov dx,_crt_base
mov al,10
out dx,al
inc dx
mov al,6
out dx,al
dec dx
mov al,11
out dx,al
inc dx
mov al,7
out dx,al
ret
_csr_on endp

_TEXT ends
end


  3 Responses to “Category : Assembly Language Source Code
Archive   : MSCPOPUP.ZIP
Filename : WINDOW1.ASM

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/