home *** CD-ROM | disk | FTP | other *** search
- DATA SEGMENT WORD PUBLIC
- EXTRN VidWidth:WORD,BaseAddr:WORD,CheckSnow:BYTE
- DATA ENDS
-
- CODE SEGMENT BYTE PUBLIC
- ASSUME CS:CODE, DS:DATA
- PUBLIC MoveNoSnow
- PUBLIC MoveFast
- PUBLIC MovWindow
-
-
- ToAddr EQU DWORD PTR [BP+6] ; Target parameter
- FromAddr EQU DWORD PTR [BP+10] ; Source parameter
- Count EQU WORD PTR [BP+14] ; Number of words to move
-
- ; MoveNoSnow ( Count : Word;FromAddr, ToAddr : Pointer );
- MoveNoSnow PROC FAR
- push bp ; Standard Turbo Pascal entry code
- mov bp,sp ; "
-
- push ds ; Save DS
- les di,FromAddr ; Move source address into ES:DI
- lds si,ToAddr ; Move target address into DS:SI
- cld ; Clear direction flag
- mov cx,Count ; Put number of words to be moved into CX
- jcxz MoveNSDone ; If no words to move, then exit now
-
- mov dx,3DAh ; Put CGA status port value in DX
-
- AnotherChar:
- cli ; Stop interrupts, timing critical
-
- VerticleSync:
- in al,dx ;* Get CGA status byte
- test al,8 ;** Test verticle sync bit
- jnz DisplayChar ;** If bit not set: jump to display the char
- rcr al,1 ;* Else: rotate bit 0 to the carry flag
- jc VerticleSync ;* If carry flag set, loop again
-
- DisplayEnable:
- in al,dx ; Get CGA status byte
- rcr al,1 ; Rotate bit 0 to the carry flag
- jnc DisplayEnable ; Loop until carry flag not set
-
- DisplayChar:
- lodsw ; Get word from string into AX
- sti ; Okay to do interrupts again
- stosw ; Move word from AX to destination address
- loop AnotherChar ; Loop until no more words to display
-
- MoveNSDone:
- pop ds ; Restore DS
- pop bp ; Restore BP
- retf 10 ; Far return, 10 bytes of parameters
- MoveNoSnow ENDP
-
-
- ; Procedure MoveFast ( Count : Word; FromAddr, ToAddr : Pointer );
- MoveFast PROC FAR
- push bp ; Standard Turbo Pascal entry code
- mov bp,sp ; "
- les di,FromAddr ; Move source address into ES:DI
-
- mov cx,Count ; Move number of words to be moved to CX
- push ds ; Save DS
- lds si,ToAddr ; Move target address into DS:SI
- rep movsw ; Move CX words from ES:DI to DS:SI
-
- pop ds ; Restore DS
- pop bp ; Restore BP
- retf 10 ; Far return, 10 bytes of parameters
- MoveFast ENDP
-
-
- ; Procedure MovWindow ( ToScreen : Boolean; X1, Y1, X2, Y2 : Word;
- ; Buff : Pointer );
- MovWindow PROC FAR ; Begin Procedure MovWindow
- push bp ; Standard Turbo Pascal Entry code
- mov bp,sp ;
-
- ; Calculate number of word to move per line
- mov ax,[bp+12] ; move X2 to AX
- sub ax,[bp+16] ; AX = X2 - X1
- inc ax ; AX = X2 - X1 + 1
- push ax ; [BP-2] = X2 - X1 + 1
-
- ; Calculate number of lines to move
- mov ax,[bp+10] ; move Y2 to AX
- sub ax,[bp+14] ; AX = Y2 - Y1
- inc ax ; AX = Y2 - Y1 + 1
- push ax ; [BP-4] = Y2 - Y1 + 1
-
- ; Calculate number of bytes per line on screen
- mov ax,VidWidth ;
- shl ax,1 ; AX = VidWidth * 2
- push ax ; [BP-6] = VidWidth * 2
-
- ; Calculate Offset of window
- mov ax,[bp+14] ; AX = Y1
- dec ax ; AX = Y1 - 1
- mul WORD PTR [BP-06]; AX = (Y1 - 1) * (VidWidth * 2)
- mov dx,[bp+16] ; DX = X1
- dec dx ; DX = X1 - 1
- shl dx,1 ; DX = (X1 - 1) * 2
- add ax,dx ; AX = ((Y1 - 1) * (VidWidth * 2)) + ((X1 - 1) *2)
- push ax ; [BP-8] = above formula
-
- AnotherLine:
- mov al,[bp+18] ;
- cmp al,0 ; See if we copy to screen
- jne CopyFromScr ;
-
- push [bp-2] ; Put number of words to move onto stack
- push [bp+8] ; Move buffer to stack
- push [bp+6] ; Move buffer to stack
- push BaseAddr ; Move video segment to stack
- push [bp-8] ; Move video offset to stack
- jmp Check4SnowCheck;
-
- CopyFromScr:
- push [bp-2] ; Put number of words to move onto stack
- push BaseAddr ; Move video segment to stack
- push [bp-8] ; Move video offset to stack
- push [bp+8] ; Move buffer to stack
- push [bp+6] ; Move buffer to stack
-
- Check4SnowCheck:
- mov al,CheckSnow ;
- cmp al,0 ; Check the boolean variable CheckSnow
- jne SnowChecking ;
- call MoveFast ; If CheckSnow = FALSE then use MoveFast
- jmp SkipSnow ;
- SnowChecking:
- call MoveNoSnow ; If CheckSnow = TRUE then use MoveNoSnow
-
- SkipSnow:
- mov ax,[bp-8] ; AX := Video Offset
- add ax,[bp-6] ; AX := Video Offset + ScreenWidth
- mov [bp-8],ax ; Video Offset := Video Offset + ScreenWidth
-
- mov ax,[bp-2] ; AX := Words to move
- shl ax,1 ; AX := AX * 2
- add ax,[bp+6] ; AX := AX + Buffer Offset
- mov [bp+6],ax ; Buffer Offset := Buffer Offset + bytes to move
-
- mov ax,[bp-4] ;
- dec ax ;
- mov [bp-4],ax ; Lines := Lines - 1
- cmp ax,0 ; If Lines <> 0 then
- jnz AnotherLine ; Goto display another line
-
- mov sp,bp ; Standard Turbo Pascal Exit Code
- pop bp ;
- retf 14 ;
- MovWindow ENDP ; End of Procedure MovWindow
-
- CODE ENDS
- END