home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / VDH / XGASCROL.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  74KB  |  1,728 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12.         PAGE    60,132
  13.         TITLE   XGASCROL.ASM -- Common Buffer Scroll Routines for EGA, VGA, BGA
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = XGASCROL.ASM
  18. ;*
  19. ;* DESCRIPTIVE NAME = BUFFERUPDATE scroll routines 
  20. ;*
  21. ;*
  22. ;* VERSION      V2.0
  23. ;*
  24. ;* DATE         
  25. ;*
  26. ;* DESCRIPTION  This module contains routines that run at ring 2 in    
  27. ;*              order to directly access the hardware.
  28. ;*
  29. ;* FUNCTIONS    ScrollUp, ScrollDown     
  30. ;*              ScrollLeft, ScrollRight
  31. ;* 
  32. ;* NOTES        NONE
  33. ;*             
  34. ;* STRUCTURES   NONE
  35. ;*
  36. ;* EXTERNAL REFERENCES
  37. ;*
  38. ;*              NONE
  39. ;*
  40. ;* EXTERNAL FUNCTIONS
  41. ;*
  42. ;*              NONE
  43. ;*
  44. ;* CHANGE ACTIVIY =
  45. ;*   DATE      FLAG        APAR    CHANGE DESCRIPTION
  46. ;*   --------  ----------  -----   --------------------------------------
  47. ;*   mm/dd/yy  @Vr.mpppxx  xxxxx   xxxxxxx
  48. ;*   03/25/89  @P1         D132    PL, DCR 132 changes
  49. ;*   04/11/91              D1348   NAKADA, Enable DBCS support in Vio-Window
  50. ;****************************************************************************/
  51.  
  52.         .286c                           ; 286 protect mode instructions
  53.  
  54.         .xlist
  55.         INCLUDE struc.inc               ; Structure macro
  56.         INCLUDE error2.inc              ; Subsystem error equates
  57.         INCLUDE vdhstruc.inc            ; Buffer update data structures
  58.         INCLUDE vdhctl.inc              ; Conditional Assemply Control  ;MS01
  59.         INCLUDE vdhequ.inc              ; Buffer update equates
  60.         INCLUDE xgamac.inc                                              ;@P1
  61.         .list
  62.  
  63.         EXTRN   SetGenParms:NEAR        ; Set up general buffer update parms @P1
  64.  
  65. IF VDHCGA AND (1 - CGA_ALWAYS_FAST) ; IF VDHCGA AND NOT CGA_ALWAYS_FAST ;@P1
  66.  
  67. ;/*
  68. ;** If CGA video memory accesses may need to wait for retrace,
  69. ;** these routines are necessary. (See MAKEFILE)
  70. ;*/
  71.  
  72.         extrn   CGA_REP_MOVSW:far                                       ;@P1
  73.         extrn   CGA_REP_STOSW:far                                       ;@P1
  74.         extrn   CGA_REP_MOVSB_INCSI_LOOP:far                            ;@P1
  75.         extrn   CGA_REP_MOVSW_STOSW_LOOP:far                            ;@P1
  76.         extrn   CGA_REP_INCDI_STOSB_LOOP:far                            ;@P1
  77.         extrn   CGA_REP_STOSB_INCDI_LOOP:far                            ;@P1
  78.         extrn   CGA_REP_LODSB_STOSW_LOOP:far                            ;@P1
  79.         extrn   CGA_REP_MOVSB_INCDI_LOOP:far                            ;@P1
  80.         extrn   CGA_REP_MOVSW_ADDSI2_LOOP:far                           ;@P1
  81. ENDIF   ;VDHCGA                                                         ;@P1
  82.  
  83. IFDEF D1348 ;BufferUpdate with dbcs bits handling
  84.         extrn   MoveUpLeftWrld:near
  85.         extrn   MoveDownRightWrld:near
  86. ENDIF ;D1348
  87.  
  88. R2CSEG  SEGMENT WORD    PUBLIC 'CODE'
  89.         ASSUME  CS:R2CSEG,DS:NOTHING,ES:NOTHING
  90.  
  91. ;/****************************************************************************
  92. ;*                                                                     
  93. ;* SUBROUTINE NAME:     ScrollLeft                                     
  94. ;*                                                                     
  95. ;* DESCRIPTIVE NAME:    Video device handler scroll left routine       
  96. ;*                                                                     
  97. ;* FUNCTION:    Process scroll left sub-function                       
  98. ;*              Scrolls a portion of the PVB, LVB left a specified     
  99. ;*              number of times and then fill the vacant portion       
  100. ;*              with the user specified cell.                          
  101. ;*                                                                     
  102. ;* ENTRY POINT: ScrollLeft                                             
  103. ;*   LINKAGE:   Near Call from BUFFERUPDATE rouinte                    
  104. ;*                                                                     
  105. ;* INPUT:                                                              
  106. ;*                                                                     
  107. ;* AX = 0                                                              
  108. ;* SS:BP  --->  Stack frame                     (see VDHSTRUC.INC)     
  109. ;* DS:SI  --->  Parameter block buffer          (see XGABUFUP.ASM)     
  110. ;* ES:DI  --->  Mode data in environment buffer (see XGABUFUP.ASM)     
  111. ;*                                                                     
  112. ;* PARAMETER BLOCK FORMAT:                                             
  113. ;*                                                                     
  114. ;*   SIZE   DESCRIPTION                                                
  115. ;*   ----   -----------                                                
  116. ;*                                                                     
  117. ;*   WORD   Parameter length                                           
  118. ;*   WORD   Flags                     (target buffer - LVB, PVB)       
  119. ;*   DWORD  Application data address                                   
  120. ;*   DWORD  Application data2 address (cell to be used to fill void)   
  121. ;*   WORD   Index (5)                                                  
  122. ;*   WORD   Starting row              (top row)                        
  123. ;*   WORD   Starting column           (left column)                    
  124. ;*   WORD   Secondary row             (bottom row)                     
  125. ;*   WORD   Secondary column          (right column)                   
  126. ;*   WORD   RepeatFactor              (# of times to scroll)           
  127. ;*   WORD   LogicalBufSel                                              
  128. ;*                                                                     
  129. ;* OUTPUT:                                                             
  130. ;*                                                                     
  131. ;* EXIT-NORMAL: AX = 0                                                 
  132. ;*                                                                     
  133. ;* EXIT-ERROR:  AX = SetForScroll                                      
  134. ;*                                                                     
  135. ;* EFFECTS:     All                                                    
  136. ;*                                                                     
  137. ;* INTERNAL REFERENCES: SetForScroll,                                  
  138. ;*                                                                     
  139. ;* EXTERNAL REFERENCES: None                                           
  140. ;*                                                                     
  141. ;****************************************************************************/
  142.  
  143.                 PUBLIC  ScrollLeft
  144. ScrollLeft      PROC
  145.  
  146.         mov     bx,LEFT
  147.         call    SetForScroll
  148.         jc      sclfx
  149.  
  150.         test    [bp].ScrollFlags,DOMOVE
  151.         jz      sclf10
  152.  
  153.         push    bx
  154.         call    MoveUpLeft
  155.         pop     bx
  156.  
  157. sclf10: call    FillRectWithCell
  158.         xor     ax,ax
  159.  
  160. sclfx:  ret
  161.  
  162. ScrollLeft      ENDP
  163.  
  164.  
  165. ;/****************************************************************************
  166. ;*                                                                     
  167. ;* SUBROUTINE NAME:     ScrollUp                                       
  168. ;*                                                                     
  169. ;* DESCRIPTIVE NAME:    Video device handler scroll up routine         
  170. ;*                                                                     
  171. ;* FUNCTION:    Process scroll up sub-function                         
  172. ;*              Scrolls a portion of the PVB, LVB up a specified       
  173. ;*              number of times and then fill the vacant portion       
  174. ;*              with the user specified cell.                          
  175. ;*                                                                     
  176. ;* ENTRY POINT: ScrollUp                                               
  177. ;*   LINKAGE:   Near Call from BUFFERUPDATE rouinte                    
  178. ;*                                                                     
  179. ;* INPUT:                                                              
  180. ;*                                                                     
  181. ;* AX = 0                                                              
  182. ;* SS:BP  --->  Stack frame                     (see VDHSTRUC.INC)     
  183. ;* DS:SI  --->  Parameter block buffer          (see XGABUFUP.ASM)     
  184. ;* ES:DI  --->  Mode data in environment buffer (see XGABUFUP.ASM)     
  185. ;*                                                                     
  186. ;* PARAMETER BLOCK FORMAT:                                             
  187. ;*                                                                     
  188. ;*   SIZE   DESCRIPTION                                                
  189. ;*   ----   -----------                                                
  190. ;*                                                                     
  191. ;*   WORD   Parameter length                                           
  192. ;*   WORD   Flags                     (target buffer - LVB, PVB)       
  193. ;*   DWORD  Application data address                                   
  194. ;*   DWORD  Application data2 address (cell to be used to fill void)   
  195. ;*   WORD   Index (3)                                                  
  196. ;*   WORD   Starting row              (top row)                        
  197. ;*   WORD   Starting column           (left column)                    
  198. ;*   WORD   Secondary row             (bottom row)                     
  199. ;*   WORD   Secondary column          (right column)                   
  200. ;*   WORD   RepeatFactor              (# of times to scroll)           
  201. ;*   WORD   LogicalBufSel                                              
  202. ;*                                                                     
  203. ;* OUTPUT:                                                             
  204. ;*                                                                     
  205. ;* EXIT-NORMAL: AX = 0                                                 
  206. ;*                                                                     
  207. ;* EXIT-ERROR:  AX = SetForScroll                                      
  208. ;*                                                                     
  209. ;* EFFECTS:     All                                                    
  210. ;*                                                                     
  211. ;* INTERNAL REFERENCES: SetForScroll,                                  
  212. ;*                                                                     
  213. ;* EXTERNAL REFERENCES: None                                           
  214. ;*                                                                     
  215. ;****************************************************************************/
  216.  
  217.                 PUBLIC  ScrollUp
  218. ScrollUp        PROC
  219.         mov     bx,UP
  220.         call    SetForScroll
  221.         jc      scupx
  222.  
  223.         test    [bp].ScrollFlags,DOMOVE
  224.         jz      scup10
  225.  
  226.         push    bx
  227.         call    MoveUpLeft
  228.         pop     bx
  229.  
  230. scup10: call    FillRectWithCell
  231.         xor     ax,ax
  232.  
  233. scupx:  ret
  234.  
  235. ScrollUp        ENDP
  236.  
  237.  
  238. ;/****************************************************************************
  239. ;*                                                                     
  240. ;* SUBROUTINE NAME:     ScrollRight                                    
  241. ;*                                                                     
  242. ;* DESCRIPTIVE NAME:    Video device handler scroll right routine      
  243. ;*                                                                     
  244. ;* FUNCTION:    Process scroll right sub-function                      
  245. ;*              Scrolls a portion of the PVB, LVB right to a specified 
  246. ;*              number of times and then fill the vacant portion with  
  247. ;*              the user specified cell.                               
  248. ;*                                                                     
  249. ;* ENTRY POINT: ScrollRight                                            
  250. ;*   LINKAGE:   Near Call from BUFFERUPDATE rouinte                    
  251. ;*                                                                     
  252. ;* INPUT:                                                              
  253. ;*                                                                     
  254. ;* AX = 0                                                              
  255. ;* SS:BP  --->  Stack frame                     (see VDHSTRUC.INC)     
  256. ;* DS:SI  --->  Parameter block buffer          (see XGABUFUP.ASM)     
  257. ;* ES:DI  --->  Mode data in environment buffer (see XGABUFUP.ASM)     
  258. ;*                                                                     
  259. ;* PARAMETER BLOCK FORMAT:                                             
  260. ;*                                                                     
  261. ;*   SIZE   DESCRIPTION                                                
  262. ;*   ----   -----------                                                
  263. ;*                                                                     
  264. ;*   WORD   Parameter length                                           
  265. ;*   WORD   Flags                     (target buffer - LVB, PVB)       
  266. ;*   DWORD  Application data address                                   
  267. ;*   DWORD  Application data2 address (cell to be used to fill void)   
  268. ;*   WORD   Index (6)                                                  
  269. ;*   WORD   Starting row              (top row)                        
  270. ;*   WORD   Starting column           (left column)                    
  271. ;*   WORD   Secondary row             (bottom row)                     
  272. ;*   WORD   Secondary column          (right column)                   
  273. ;*   WORD   RepeatFactor              (# of times to scroll)           
  274. ;*   WORD   LogicalBufSel                                              
  275. ;*                                                                     
  276. ;* OUTPUT:                                                             
  277. ;*                                                                     
  278. ;* EXIT-NORMAL: AX = 0                                                 
  279. ;*                                                                     
  280. ;* EXIT-ERROR:  AX = SetForScroll                                      
  281. ;*                                                                     
  282. ;* EFFECTS:     All                                                    
  283. ;*                                                                     
  284. ;* INTERNAL REFERENCES: SetForScroll,                                  
  285. ;*                                                                     
  286. ;* EXTERNAL REFERENCES: None                                           
  287. ;*                                                                     
  288. ;****************************************************************************/
  289.  
  290.                 PUBLIC  ScrollRight
  291. ScrollRight     PROC
  292.  
  293.         mov     bx,RIGHT
  294.         call    SetForScroll
  295.         jc      scrtx
  296.  
  297.         test    [bp].ScrollFlags,DOMOVE
  298.         jz      scrt10
  299.  
  300.         push    bx
  301.         call    MoveDownRight
  302.         pop     bx
  303.  
  304. scrt10: call    FillRectWithCell
  305.         xor     ax,ax
  306.  
  307. scrtx:  ret
  308.  
  309. ScrollRight     ENDP
  310.  
  311.  
  312. ;/****************************************************************************
  313. ;*                                                                     
  314. ;* SUBROUTINE NAME:     ScrollDown                                     
  315. ;*                                                                     
  316. ;* DESCRIPTIVE NAME:    Video device handler scroll down routine       
  317. ;*                                                                     
  318. ;* FUNCTION:    Process scroll down sub-function                       
  319. ;*              Scrolls a portion of the PVB, LVB down a specified     
  320. ;*              number of times and then fill the vacant portion       
  321. ;*              with the user specified cell.                          
  322. ;*                                                                     
  323. ;* ENTRY POINT: ScrollDown                                             
  324. ;*   LINKAGE:   Near Call from BUFFERUPDATE rouinte                    
  325. ;*                                                                     
  326. ;* INPUT:                                                              
  327. ;*                                                                     
  328. ;* AX = 0                                                              
  329. ;* SS:BP  --->  Stack frame                     (see VDHSTRUC.INC)     
  330. ;* DS:SI  --->  Parameter block buffer          (see XGABUFUP.ASM)     
  331. ;* ES:DI  --->  Mode data in environment buffer (see XGABUFUP.ASM)     
  332. ;*                                                                     
  333. ;* PARAMETER BLOCK FORMAT:                                             
  334. ;*                                                                     
  335. ;*   SIZE   DESCRIPTION                                                
  336. ;*   ----   -----------                                                
  337. ;*                                                                     
  338. ;*   WORD   Parameter length                                           
  339. ;*   WORD   Flags                     (target buffer - LVB, PVB)       
  340. ;*   DWORD  Application data address                                   
  341. ;*   DWORD  Application data2 address (cell to be used to fill void)   
  342. ;*   WORD   Index (4)                                                  
  343. ;*   WORD   Starting row              (top row)                        
  344. ;*   WORD   Starting column           (left column)                    
  345. ;*   WORD   Secondary row             (bottom row)                     
  346. ;*   WORD   Secondary column          (right column)                   
  347. ;*   WORD   RepeatFactor              (# of times to scroll)           
  348. ;*   WORD   LogicalBufSel                                              
  349. ;*                                                                     
  350. ;* OUTPUT:                                                             
  351. ;*                                                                     
  352. ;* EXIT-NORMAL: AX = 0                                                 
  353. ;*                                                                     
  354. ;* EXIT-ERROR:  AX = SetForScroll                                      
  355. ;*                                                                     
  356. ;* EFFECTS:     All                                                    
  357. ;*                                                                     
  358. ;* INTERNAL REFERENCES: SetForScroll,                                  
  359. ;*                                                                     
  360. ;* EXTERNAL REFERENCES: None                                           
  361. ;*                                                                     
  362. ;****************************************************************************/
  363.  
  364.                 PUBLIC  ScrollDown
  365. ScrollDown      PROC
  366.  
  367.         mov     bx,DOWN
  368.         call    SetForScroll
  369.         jc      scdnx
  370.  
  371.         test    [bp].ScrollFlags,DOMOVE
  372.         jz      scdn10
  373.  
  374.         push    bx
  375.         call    MoveDownRight
  376.         pop     bx
  377.  
  378. scdn10: call    FillRectWithCell
  379.         xor     ax,ax
  380.  
  381. scdnx:  ret
  382.  
  383. ScrollDown      ENDP
  384.  
  385. ;/****************************************************************************
  386. ;*                                                                     
  387. ;* SUBROUTINE NAME:     LVBToPVB                                       
  388. ;*                                                                     
  389. ;* DESCRIPTIVE NAME:    Video device handler copy LVB rectangle to PVB 
  390. ;*                                                                     
  391. ;* FUNCTION:    Copy a rectangle from an LVB on to the PVB             
  392. ;*                                                                     
  393. ;* ENTRY POINT: LVBToPVB                                               
  394. ;*   LINKAGE:   Near Call from BUFFERUPDATE rouinte                    
  395. ;*                                                                     
  396. ;* INPUT:                                                              
  397. ;*                                                                     
  398. ;* AX = 0                                                              
  399. ;* SS:BP  --->  Stack frame                     (see VDHSTRUC.INC)     
  400. ;* DS:SI  --->  Parameter block buffer          (see XGABUFUP.ASM)     
  401. ;* ES:DI  --->  Mode data in environment buffer (see XGABUFUP.ASM)     
  402. ;*                                                                     
  403. ;* PARAMETER BLOCK FORMAT:                                             
  404. ;*                                                                     
  405. ;*   SIZE   DESCRIPTION                                                
  406. ;*   ----   -----------                                                
  407. ;*                                                                     
  408. ;*   WORD   Parameter length                                           
  409. ;*   WORD   Flags                     (target buffer - LVB, PVB)       
  410. ;*   DWORD  Application data address                                   
  411. ;*   DWORD  Application data2 address (cell to be used to fill void)   
  412. ;*   WORD   Index (4)                                                  
  413. ;*   WORD   Starting row              (top row)                        
  414. ;*   WORD   Starting column           (left column)                    
  415. ;*   WORD   Secondary row             (bottom row)                     
  416. ;*   WORD   Secondary column          (right column)                   
  417. ;*   WORD   RepeatFactor              (# of times to scroll)           
  418. ;*   WORD   LogicalBufSel                                              
  419. ;*                                                                     
  420. ;* OUTPUT:                                                             
  421. ;*                                                                     
  422. ;* EXIT-NORMAL: AX = 0                                                 
  423. ;*                                                                     
  424. ;* EXIT-ERROR:  AX = SetForScroll                                      
  425. ;*                                                                     
  426. ;* EFFECTS:     All                                                    
  427. ;*                                                                     
  428. ;* INTERNAL REFERENCES: SetForScroll,MoveLVBRectToPVB                  
  429. ;*                                                                     
  430. ;* EXTERNAL REFERENCES: None                                           
  431. ;*                                                                     
  432. ;****************************************************************************/
  433.  
  434.                 PUBLIC  LVBToPVB                                ;@P1 begin
  435. LVBToPVB        PROC
  436.  
  437.         xor     ax,ax                   ; clear error code
  438.         push    ds:[si].RepeatFactor    ; save the old repeat factor
  439.         push    ds:[si].Flags           ; save the old flags
  440.         test    [si].Flags, PVB_SEL_BIT ; write to the PVB
  441.         jz      ltpx                    ;   NO, do nothing
  442.  
  443.         or      [si].Flags, LVB_SEL_BIT ; LVB bit needs to be set
  444.  
  445.         mov     ds:[si].RepeatFactor,-1 ; this will be a scroll without move
  446.         mov     bx,LVBPVB               ; pretend to be a scroll function
  447.         call    SetForScroll            ; get the scroll parameters
  448.         jc      ltpx
  449.  
  450.         call    MoveLVBRectToPVB        ; The fill rect is the rect to move
  451.         xor     ax,ax
  452.  
  453. ltpx:   lds     si,[bp].ParmBuf
  454.         pop     ds:[si].Flags           ; restore the old flags
  455.         pop     ds:[si].RepeatFactor    ; 
  456.         ret
  457.  
  458. LVBToPVB        ENDP                                            ;@P1 end
  459.  
  460.  
  461. ;/***************************************************************************
  462. ;*
  463. ;* FUNCTION NAME = SetForScroll
  464. ;*
  465. ;* DESCRIPTION   = 
  466. ;*
  467. ;*      Set up parameters for a scroll
  468. ;*      SetForScroll does range checking and parameter adjustment for
  469. ;*      all scroll functions.  This is valid for 2 and 4 byte cell LVBs
  470. ;*      and for the fill cell supplied as 2 or 4 bytes.
  471. ;*
  472. ;*      All scrolls consist of two basic operations.  The first is
  473. ;*      move a rectangle.  The second is fill a rectangle.  The rectangle
  474. ;*      to be moved will be NULL if the scroll is greater than the
  475. ;*      depth of the rectangle in the direction of movement.
  476. ;*
  477. ;*      This routine calculates the source rectangle and destination
  478. ;*      rectangle for the move.  For UP and LEFT scrolling, the rectangle
  479. ;*      should be copied beginning to end.  For DOWN and RIGHT the copy
  480. ;*      should go from end to beginning.  This routine provides the
  481. ;*      correct buffer offset for the appropriate starting point of
  482. ;*      the rectangle.
  483. ;*
  484. ;* INPUT         = 
  485. ;*
  486. ;*          BX - Flag indicating the type of scroll (UP,DOWN,LEFT,RIGHT)
  487. ;*          SS:BP - local data storage area
  488. ;*          DS:SI - user passed parameter block
  489. ;*          ES:DI - mode data structure
  490. ;*          [bp].minrow - index of top most row in LVB (PVB coordinates)
  491. ;*          [bp].mincol - index of left most row in LVB (PVB coordinates)
  492. ;*          [bp].maxrow - index of bottom most row in LVB (PVB coordinates)
  493. ;*          [bp].maxcol - index of right most row in LVB (PVB coordinates)
  494. ;*              
  495. ;* OUTPUT        = 
  496. ;*
  497. ;*       CARRY CLEAR
  498. ;*           BX = LVB selector if LVB scroll is indicated else 0
  499. ;*
  500. ;*           [bp].PVB_Sel = PVB selector if PVB scroll is indicated else 0
  501. ;*
  502. ;*           [bp].ScrollFlags  = either DOFILL or DOMOVE+DOFILL
  503. ;*
  504. ;*           [bp].RowsToFill   = rows to be filled with the default cell
  505. ;*
  506. ;*           [bp].PVBFillOff   = offset of start of PVB fill rectangle
  507. ;*           [bp].PVBFillCount = # of bytes per fill line in PVB
  508. ;*           [bp].PVBFillSkip  = # of bytes to skip to reach next PVB line
  509. ;*
  510. ;*           [bp].LVBFillOff   = offset of start of LVB fill rectangle
  511. ;*           [bp].LVBFillCount = # of bytes per fill line in LVB
  512. ;*           [bp].LVBFillSkip  = # of bytes to skip to reach next LVB line
  513. ;*
  514. ;*           [bp].FillCellLow  = first word of default fill cell
  515. ;*           [bp].FillCellHigh = second word of default fill cell
  516. ;*
  517. ;*         if DOMOVE is set in ScrollFlags
  518. ;*
  519. ;*           [bp].RowsToMove     = number of rows to move
  520. ;*
  521. ;*           [bp].PVBMoveCount   = # of bytes per PVB row to move
  522. ;*           [bp].PVBMoveSkip    = # of bytes to skip to get to the next row
  523. ;*           [bp].PVBMoveSrcOff  = offset to start of PVB source buffer
  524. ;*           [bp].PVBMoveDestOff = offset to start of PVB destination buffer
  525. ;*
  526. ;*           [bp].LVBMoveCount   = # of bytes per PVB row to move
  527. ;*           [bp].LVBMoveSkip    = # of bytes to skip to get to the next row
  528. ;*           [bp].LVBMoveSrcOff  = offset to start of PVB source buffer
  529. ;*           [bp].LVBMoveDestOff = offset to start of PVB destination buffer
  530. ;*
  531. ;*       CARRY SET
  532. ;*           [bp].ScrollFlags = 0
  533. ;*
  534. ;*   CALLS   SetBaseRects, AdjustRects, CalcMoveValues, CalcFillValues
  535. ;*
  536. ;*   USES    AX,CX,DX,SI,DS,FLAGS
  537. ;*
  538. ;* RETURN-NORMAL = NONE
  539. ;* RETURN-ERROR  = NONE
  540. ;*
  541. ;**************************************************************************/
  542.  
  543.                 PUBLIC  SetForScroll                            ;@P1 begin
  544. SetForScroll    PROC
  545.  
  546.         call    SetGenParms             ; set general parameters for all
  547.                                         ; buffer update functions
  548.         call    SetBaseRects            ; do basic value setting on source,
  549.                                         ; destination and fill rectangles
  550.  
  551.         .if     <nc>                    ; parms from SetBaseRects are good
  552.  
  553.             call    AdjustRects         ; adjust the rectangle values for the
  554.                                         ; specific type of scroll
  555.  
  556.                                         ; At this point we have source and
  557.                                         ; and destination rectangles that are
  558.                                         ; both entirely contained in the LVB.
  559.                                         ; We have also calculated the
  560.                                         ; rectangle that will be left void
  561.                                         ; when the moved rectangle is copied.
  562.  
  563.             test    [bp].ScrollFlags,DOMOVE ; Are move rectangles != NULL?
  564.             .if     <nz>                ;   Yes, calculate the move parms
  565.                 call    CalcMoveValues  ;   and buffer lengths
  566.             .endif
  567.             call    CalcFillValues      ; calculate the fill rectangle parms
  568.             mov     bx, [bp].LVB_SEL    ; (bx) = LVB selector
  569.  
  570.             clc
  571.  
  572.         .endif
  573.  
  574.         ret
  575.  
  576. SetForScroll    ENDP                                            ;@P1 end
  577.  
  578.  
  579. ;/***************************************************************************
  580. ;*
  581. ;* FUNCTION NAME = SetBaseRects
  582. ;*
  583. ;* DESCRIPTION   = 
  584. ;*
  585. ;*      Set default values for source, dest and fill rectangles
  586. ;*
  587. ;*      SetBaseRects does basic rectangle value setting for the source
  588. ;*      and destination rectangles for the rectangle that needs to be
  589. ;*      moved as part of the scroll.  Default values for the fill
  590. ;*      rectangle are also set.
  591. ;*
  592. ;*      This routine also checks and adjusts the RepeatFactor, the number
  593. ;*      of rows or columns to be scrolled.  If it is 0, an error is returned.
  594. ;*
  595. ;* INPUT     =  BX - Flag indicating the type of scroll (UP,DOWN,LEFT,RIGHT)
  596. ;*              SS:BP - local data storage area
  597. ;*              DS:SI - user passed parameter block
  598. ;*              ES:DI - mode data structure
  599. ;*              [bp].minrow - index of top most row in LVB (PVB coordinates)
  600. ;*              [bp].mincol - index of left most row in LVB (PVB coordinates)
  601. ;*              [bp].maxrow - index of bottom most row in LVB (PVB coordinates)
  602. ;*              [bp].maxcol - index of right most row in LVB (PVB coordinates)
  603. ;*
  604. ;* OUTPUT   =
  605. ;*
  606. ;*          CARRY CLEAR
  607. ;*              CX = repeat factor
  608. ;*              [bp].ScrollFlags  = DOMOVE+DOFILL
  609. ;*              [bp].topscroll    = ParmBlock->Row
  610. ;*              [bp].topdest      =   "
  611. ;*              [bp].topfill      =   "
  612. ;*              [bp].leftscroll   = ParmBlock->Col
  613. ;*              [bp].leftdest     =   "
  614. ;*              [bp].leftfill     =   "
  615. ;*              [bp].rightscroll  = ParmBlock->Row2
  616. ;*              [bp].rightdest    =   "
  617. ;*              [bp].rightfill    =   "
  618. ;*              [bp].bottomscroll = ParmBlock->Col2
  619. ;*              [bp].bottomdest   =   "
  620. ;*              [bp].bottomfill   =   "
  621. ;*
  622. ;*          CARRY SET
  623. ;*              [bp].ScrollFlags = 0
  624. ;*
  625. ;*
  626. ;* CALLS   none
  627. ;*
  628. ;* USES    AX,CX,FLAGS
  629. ;*
  630. ;* NOTES
  631. ;*
  632. ;* PSEUDOCODE
  633. ;*
  634. ;*                 topscroll = parmrow
  635. ;*                 leftscroll = parmcol
  636. ;*                 bottomscroll = parmrow2
  637. ;*                 rightscroll = parmcol2
  638. ;*                 topdest = topscroll
  639. ;*                 leftdest = leftscroll
  640. ;*                 bottomdest = bottomscroll
  641. ;*                 rightdest = rightscroll
  642. ;*                 topfill = topscroll
  643. ;*                 leftfill = leftscroll
  644. ;*                 bottomfill = bottomscroll
  645. ;*                 rightfill = rightscroll
  646. ;*                 DoMoveFlag = TRUE
  647. ;*                 DoFillFlag = TRUE
  648. ;*                 if  (RepCount == 0)   
  649. ;*                     DoMoveFlag = FALSE
  650. ;*                     DoFillFlag = FALSE
  651. ;*                     set error
  652. ;*
  653. ;* RETURN-NORMAL = NONE
  654. ;* RETURN-ERROR  = NONE
  655. ;*
  656. ;****************************************************************************/
  657.  
  658.                 PUBLIC  SetBaseRects                            ;@P1 begin
  659. SetBaseRects    PROC
  660.         mov     ax,[si].Row         ; set all of the top coordinates
  661.         .if     <ax b [bp].minrow> near
  662.             mov     ax,[bp].minrow
  663.         .endif
  664.                                         ; BUGBUG this is really should not be
  665.         .if     <ax a [bp].maxrow> near ; here, but it is necessary to pass
  666.             mov     ax,[bp].maxrow      ; the component tests.  Remove it at
  667.         .endif                          ; the first opertunity.
  668.  
  669.         test    bx,LVBPVB
  670.         .if     <z>                     ; NOT LVB to PVB
  671.             .if     <ax b es:[di].ScrlRectTop> near
  672.                 mov     ax,es:[di].ScrlRectTop
  673.             .endif
  674.  
  675.             .if     <ax a es:[di].ScrlRectBottom> near
  676.                 mov     ax,es:[di].ScrlRectBottom
  677.             .endif
  678.         .endif
  679.  
  680.         mov     [bp].topscroll,ax
  681.         mov     [bp].topdest,ax
  682.         mov     [bp].topfill,ax
  683.  
  684.         mov     cx,[si].Row2        ; set all of the bottom coordinates
  685.         .if     <cx a [bp].maxrow> near
  686.             mov     cx,[bp].maxrow
  687.         .endif
  688.         test    bx,LVBPVB
  689.         .if     <z>                     ; NOT LVB to PVB
  690.             .if     <cx a es:[di].ScrlRectBottom> near
  691.                 mov     cx,es:[di].ScrlRectBottom
  692.             .endif
  693.         .endif
  694.  
  695.         mov     [bp].bottomscroll,cx
  696.         mov     [bp].bottomdest,cx
  697.         mov     [bp].bottomfill,cx
  698.  
  699.         .if     <ax a cx> near      ; rectangle is not valid
  700.             mov     ax,ERROR_VIO_ROW
  701.             jmp     sbrerr
  702.         .endif
  703.  
  704.         mov     ax,[si].Col         ; set all of the left coordinates
  705.         .if     <ax b [bp].mincol> near
  706.             mov     ax,[bp].mincol
  707.         .endif
  708.                                         
  709.         .if     <ax a [bp].maxcol> near 
  710.             mov     ax,[bp].maxcol      
  711.         .endif                          
  712.  
  713.         test    bx,LVBPVB
  714.         .if     <z>                     ; NOT LVB to PVB
  715.             .if     <ax b es:[di].ScrlRectLeft> near
  716.                 mov     ax,es:[di].ScrlRectLeft
  717.             .endif
  718.  
  719.             .if     <ax a es:[di].ScrlRectRight> near
  720.                 mov     ax,es:[di].ScrlRectRight
  721.             .endif
  722.         .endif
  723.  
  724.         mov     [bp].leftscroll,ax
  725.         mov     [bp].leftdest,ax
  726.         mov     [bp].leftfill,ax
  727.  
  728.         mov     cx,[si].Col2        ; set all of the right coordinates
  729.         .if     <cx a [bp].maxcol> near
  730.             mov     cx,[bp].maxcol
  731.         .endif
  732.         test    bx,LVBPVB
  733.         .if     <z>                     ; NOT LVB to PVB
  734.             .if     <cx a es:[di].ScrlRectRight> near
  735.                 mov     cx,es:[di].ScrlRectRight
  736.             .endif
  737.         .endif
  738.         mov     [bp].rightscroll,cx
  739.         mov     [bp].rightdest,cx
  740.         mov     [bp].rightfill,cx
  741.  
  742.         .if     <ax a cx> near      ; rectangle is not valid
  743.             mov     ax,ERROR_VIO_COL
  744.             jmp     sbrerr
  745.         .endif
  746.  
  747.         cmp     ds:[si].ParmLength,LVBRowOff; Does caller want the touch rect?
  748.         .if     <ae>                        ;   Yes, return the Touch Rect
  749.             mov     ax,[bp].leftscroll
  750.             mov     ds:[si].TouchXLeft,ax
  751.             mov     ax,[bp].topscroll
  752.             mov     ds:[si].TouchYTop,ax
  753.             mov     ax,[bp].rightscroll
  754.             mov     ds:[si].TouchXRight,ax
  755.             mov     ax,[bp].bottomscroll
  756.             mov     ds:[si].TouchYBottom,ax
  757.         .endif
  758.  
  759.         mov     [bp].ScrollFlags, DOMOVE + DOFILL
  760.         mov     cx, [si].RepeatFactor
  761.         or      cx,cx               ; clears carry
  762.         .if     <z>
  763.             mov     [bp].ScrollFlags,cx ; do not Move or Fill
  764.             xor     ax,ax           ; not an error not to scroll
  765.             stc
  766.         .endif
  767.  
  768. sbrx:   ret
  769.  
  770. sbrerr: stc
  771.         jmp     sbrx
  772.  
  773. SetBaseRects    ENDP                                            ;@P1 end
  774.  
  775.  
  776. ;/***************************************************************************
  777. ;*
  778. ;* FUNCTION NAME = AdjustRects
  779. ;*
  780. ;* DESCRIPTION   = 
  781. ;*
  782. ;*      Adjust values for source, dest and fill rectangles
  783. ;*
  784. ;*      AdjustRects does scroll specific rectangle value setting for the
  785. ;*      source and destination rectangles for the rectangle that needs to
  786. ;*      be moved as part of the scroll.  Values for the fill rectangle are
  787. ;*      also adjusted.
  788. ;*
  789. ;*      This routine also checks and adjusts the RepeatFactor, the number
  790. ;*      of rows or columns to be scrolled.  If the value would clear the
  791. ;*      entire scroll rectangle, (no area left to be moved) the DOMOVE
  792. ;*      flag in the scroll flags is cleared.
  793. ;*
  794. ;*      If the repeat factor is larger than the depth of the scroll rectangle
  795. ;*      in the direction it is being scrolled, the repeat factor is reduced
  796. ;*      to the depth of the scroll rectangle.
  797. ;*
  798. ;*
  799. ;* INPUT    =   BX - Flag indicating the type of scroll (UP,DOWN,LEFT,RIGHT)
  800. ;*              CX = repeat factor
  801. ;*              SS:BP - local data storage area
  802. ;*              DS:SI - user passed parameter block
  803. ;*              ES:DI - mode data structure
  804. ;*              [bp].topscroll  - source rectangle for move set to
  805. ;*              [bp].leftscroll   default values
  806. ;*              [bp].rightscroll
  807. ;*              [bp].bottomscroll
  808. ;*              [bp].topdest    - destination rectangle for move set
  809. ;*              [bp].leftdest     to default values
  810. ;*              [bp].rightdest
  811. ;*              [bp].bottomdest
  812. ;*              [bp].topfill    - rectangle left void by move set to
  813. ;*              [bp].leftfill     default values
  814. ;*              [bp].rightfill
  815. ;*              [bp].bottomfill
  816. ;*
  817. ;* OUTPUT    =
  818. ;*              CX = repeat factor adjusted to MIN (rect depth,repeat factor)
  819. ;*              [bp].ScrollFlags  =  DOMOVE clear if entire rectangle is vacant
  820. ;*
  821. ;*              [bp].topfill      = Rectangle that the scroll leaves vacant
  822. ;*              [bp].leftfill     =     "
  823. ;*              [bp].rightfill    =     "
  824. ;*              [bp].bottomfill   =     "
  825. ;*
  826. ;*            if  DOMOVE is set
  827. ;*              [bp].topscroll    = Rect adjusted to indicate source of move
  828. ;*              [bp].leftscroll   =     "
  829. ;*              [bp].rightscroll  =     "
  830. ;*              [bp].bottomscroll =     "
  831. ;*
  832. ;*              [bp].topdest      = Rect adjusted to indicate dest of move
  833. ;*              [bp].leftdest     =     "
  834. ;*              [bp].rightdest    =     "
  835. ;*              [bp].bottomdest   =     "
  836. ;*
  837. ;* CALLS   none
  838. ;*
  839. ;* USES    AX,CX,FLAGS
  840. ;*
  841. ;* NOTES
  842. ;*
  843. ;* PSEUDOCODE
  844. ;*
  845. ;* UP:
  846. ;* DOWN:
  847. ;*     if (RepCount > bottomscroll - topscroll + 1)
  848. ;*         RepCount = bottomscroll - topscroll + 1
  849. ;*         DoMoveFlag = FALSE
  850. ;*     UP:
  851. ;*         topscroll = topscroll + RepCount
  852. ;*         bottomdest = bottomscroll - RepCount
  853. ;*         topfill = bottomdest + 1
  854. ;*     DOWN:
  855. ;*         bottomscroll = bottomscroll - RepCount
  856. ;*         topdest = topscroll + RepCount
  857. ;*         bottomfill = topdest - 1
  858. ;* LEFT:
  859. ;* RIGHT:
  860. ;*     if (RepCount > rightscroll - leftscroll + 1)
  861. ;*         RepCount = rightscroll - leftscroll + 1
  862. ;*         DoMoveFlag = FALSE
  863. ;*     LEFT:
  864. ;*         leftscroll = leftscroll + RepCount
  865. ;*         rightdest = rightscroll - RepCount
  866. ;*         leftfill = rightdest + 1
  867. ;*     RIGHT:
  868. ;*         rightscroll = rightscroll - RepCount
  869. ;*         leftdest = leftscroll + RepCount
  870. ;*         rightfill = leftdest - 1
  871. ;*
  872. ;* RETURN-NORMAL = NONE
  873. ;* RETURN-ERROR  = NONE
  874. ;*
  875. ;****************************************************************************/
  876.  
  877.                 PUBLIC  AdjustRects                             ;@P1 begin
  878. AdjustRects     PROC
  879.                                     ; correct coordinates for scroll type
  880.  
  881.         test    bx,UP+DOWN          ; Is this a scroll up or scroll down
  882.         .if     <nz>                ;   Yes, do the up-down thing
  883.             mov     ax,[bp].bottomscroll
  884.             sub     ax,[bp].topscroll   ; (ax) = maximum possible scroll w/move
  885.             .if     <cx a ax>
  886.                 and     [bp].ScrollFlags,NOT DOMOVE
  887.                 inc     ax          ; (ax) = scroll to clear entire rect
  888.                 mov     cx,ax       ; (cx) = maximum repcount
  889.             .else
  890.                 test    bx,UP           ; Is this a scroll up?
  891.                 .if     <nz>            ;   Yes, do the up thing
  892.                     add     [bp].topscroll,cx
  893.                     mov     ax,[bp].bottomscroll
  894.                     sub     ax,cx
  895.                     mov     [bp].bottomdest,ax
  896.                     inc     ax
  897.                     mov     [bp].topfill,ax
  898.                 .else
  899.                     sub     [bp].bottomscroll,cx
  900.                     mov     ax,[bp].topscroll
  901.                     add     ax,cx
  902.                     mov     [bp].topdest,ax
  903.                     dec     ax
  904.                     mov     [bp].bottomfill,ax
  905.                 .endif
  906.             .endif
  907.         .else                           ; Do the left-right thing
  908.             mov     ax,[bp].rightscroll
  909.             sub     ax,[bp].leftscroll  ; (ax) = maximum possible scroll w/move
  910.             .if     <cx a ax>
  911.                 and     [bp].ScrollFlags,NOT DOMOVE
  912.                 inc     ax              ; (ax) = scroll to clear entire rect
  913.                 mov     cx,ax           ; (cx) = maximum repcount
  914.             .else
  915.                 test    bx,LEFT         ; Is this a scroll left?
  916.                 .if     <nz>            ;   Yes, do the left thing
  917.                     add     [bp].leftscroll,cx
  918.                     mov     ax,[bp].rightscroll
  919.                     sub     ax,cx
  920.                     mov     [bp].rightdest,ax
  921.                     inc     ax
  922.                     mov     [bp].leftfill,ax
  923.                 .else                   ; Do the Right thing
  924.                     sub     [bp].rightscroll,cx
  925.                     mov     ax,[bp].leftscroll
  926.                     add     ax,cx
  927.                     mov     [bp].leftdest,ax
  928.                     dec     ax
  929.                     mov     [bp].rightfill,ax
  930.                 .endif
  931.             .endif
  932.         .endif
  933.  
  934.         ret
  935.  
  936. AdjustRects     ENDP                                            ;@P1 end
  937.  
  938.  
  939. ;/***************************************************************************
  940. ;*
  941. ;* FUNCTION NAME = CalcMoveValues
  942. ;*
  943. ;* DESCRIPTION   = 
  944. ;*
  945. ;*      Calculate values the move rectangle functions need
  946. ;*
  947. ;*      CalcMoveValues calculates the offsets into the source and destination
  948. ;*      rectangles used by the move functions.  The UP and LEFT scroll
  949. ;*      functions copy from the beginning of the buffer to the end.  The
  950. ;*      DOWN and RIGHT functions copy from the end of the buffer to the
  951. ;*      beginning.  This function provides the correct starting point
  952. ;*      for the scroll requested.
  953. ;*
  954. ;*      This routine also calculates the number of rows that need to
  955. ;*      be copied.  This value will always be at least one.
  956. ;*
  957. ;*      The number of bytes in each row is calculated.  The value of
  958. ;*      this number is always at least one * cellsize (2 or 4 bytes)
  959. ;*      and is always a multiple of cell size.
  960. ;*
  961. ;*      The number of bytes that need to be skipped to reach the start
  962. ;*      of the next row to be copied is calculated.  This value may be
  963. ;*      zero.
  964. ;*
  965. ;*      With the exception of the number of rows to move, all of the
  966. ;*      values above are calculated separately for the LVB and the PVB
  967. ;*      because the cell size may be different between the two.
  968. ;*
  969. ;* INPUT    =   BX - Flag indicating the type of scroll (UP,DOWN,LEFT,RIGHT)
  970. ;*              SS:BP - local data storage area
  971. ;*              DS:SI - user passed parameter block
  972. ;*              ES:DI - mode data structure
  973. ;*              [bp].lvb_width - width of the LVB in cells
  974. ;*              [bp].cellsize - number of bytes per cell in the LVB
  975. ;*
  976. ;*              [bp].minrow - index of top most row in LVB (PVB coordinates)
  977. ;*              [bp].mincol - index of left most row in LVB (PVB coordinates)
  978. ;*              [bp].maxrow - index of bottom most row in LVB (PVB coordinates)
  979. ;*              [bp].maxcol - index of right most row in LVB (PVB coordinates)
  980. ;*
  981. ;*              [bp].topscroll    = Rect adjusted to indicate source of move
  982. ;*              [bp].leftscroll   =     "
  983. ;*              [bp].rightscroll  =     "
  984. ;*              [bp].bottomscroll =     "
  985. ;*
  986. ;*              [bp].topdest      = Rect adjusted to indicate dest of move
  987. ;*              [bp].leftdest     =     "
  988. ;*              [bp].rightdest    =     "
  989. ;*              [bp].bottomdest   =     "
  990. ;*
  991. ;* OUTPUT   =
  992. ;*              [bp].RowsToMove     = number of rows to move
  993. ;*
  994. ;*              [bp].PVBMoveCount   = # of bytes per PVB row to move
  995. ;*              [bp].PVBMoveSkip    = # of bytes to skip to get to the next row
  996. ;*              [bp].PVBMoveSrcOff  = offset to start of PVB source buffer
  997. ;*              [bp].PVBMoveDestOff = offset to start of PVB destination buffer
  998. ;*
  999. ;*              [bp].LVBMoveCount   = # of bytes per PVB row to move
  1000. ;*              [bp].LVBMoveSkip    = # of bytes to skip to get to the next row
  1001. ;*              [bp].LVBMoveSrcOff  = offset to start of PVB source buffer
  1002. ;*              [bp].LVBMoveDestOff = offset to start of PVB destination buffer
  1003. ;*
  1004. ;* CALLS   none
  1005. ;*
  1006. ;* USES    AX,CX,DX,FLAGS
  1007. ;*
  1008. ;* NOTES
  1009. ;*
  1010. ;* PSEUDOCODE
  1011. ;*
  1012. ;*          RowsToMove = bottomscroll - topscroll + 1
  1013. ;*          PVBMoveCount = (rightscroll - leftscroll) * cellsize
  1014. ;*          PVBRowSkip = modeCols * cellsize - PVBMoveCount
  1015. ;*          LVBMoveCount = (rightscroll - leftscroll) * cellsize
  1016. ;*          LVBRowSkip = lvb_width * cellsize - LVBMoveCount
  1017. ;*          UP:
  1018. ;*          LEFT:
  1019. ;*              LVBMoveSrcOff = ((topscroll - minrow) * lvb_width +
  1020. ;*                               (leftscroll - mincol)) * cellsize
  1021. ;*              PVBMoveSrcOff = (topscroll * modeCols + leftscroll) *
  1022. ;*                              cellsize
  1023. ;*              LVBMoveDestOff = ((topdest - minrow) * lvb_width +
  1024. ;*                                (leftdest - mincol)) * cellsize
  1025. ;*              PVBMoveDestOff = (topdest * modeCols + leftdest) *
  1026. ;*                              cellsize
  1027. ;*          DOWN:
  1028. ;*          RIGHT:
  1029. ;*              LVBMoveSrcOff = ((bottomscroll - minrow) * lvb_width +
  1030. ;*                               (rightscroll - mincol)) * cellsize
  1031. ;*              PVBMoveSrcOff = (bottomscroll * modeCols + rightscroll) *
  1032. ;*                              cellsize
  1033. ;*              LVBMoveDestOff = ((bottomdest - minrow) * lvb_width +
  1034. ;*                                (rightdest - mincol)) * cellsize
  1035. ;*              PVBMoveDestOff = (bottomdest * modeCols + rightdest) *
  1036. ;*                              cellsize
  1037. ;*
  1038. ;* RETURN-NORMAL = NONE
  1039. ;* RETURN-ERROR  = NONE
  1040. ;*
  1041. ;****************************************************************************/
  1042.  
  1043.                     PUBLIC  CalcMoveValues                      ;@P1 begin
  1044. CalcMoveValues      PROC
  1045.  
  1046.         mov     ax,[bp].bottomscroll    ; calculate the number of rows
  1047.         sub     ax,[bp].topscroll       ; to move
  1048.         inc     ax
  1049.         mov     [bp].RowsToMove,ax
  1050.  
  1051.         mov     cx,[bp].rightscroll     ; calculate bytes to move in PVB
  1052.         sub     cx,[bp].leftscroll
  1053.         inc     cx
  1054.         shl     cx,1
  1055.         mov     [bp].PVBMoveCount,cx
  1056.  
  1057.  
  1058.         mov     ax,es:[di].TextCols     ; calculate bytes to skip in PVB
  1059.         shl     ax,1
  1060.         sub     ax,cx
  1061.         mov     [bp].PVBMoveSkip,ax
  1062.  
  1063.         mov     ax,[bp].lvb_width       ; calculate bytes to skip in LVB
  1064.         shl     ax,1
  1065.         sub     ax,cx
  1066.         .if     <[bp].cellsize e WorldCellSize>
  1067.             shl     cx,1
  1068.             shl     ax,1
  1069.         .endif
  1070.         mov     [bp].LVBMoveCount,cx    ; bytes to move in LVB
  1071.         mov     [bp].LVBMoveSkip,ax
  1072.                                         ; calculate buffer copy addresses
  1073.         test    bx,UP+LEFT
  1074.         .if     <nz>                    ; Do the UP-LEFT thing
  1075.             mov     ax,[bp].topscroll   ; calculate PVB source offset
  1076.             mul     es:[di].TextCols
  1077.             add     ax,[bp].leftscroll
  1078.             shl     ax,1
  1079.             mov     [bp].PVBMoveSrcOff,ax
  1080.  
  1081.             mov     ax,[bp].topdest     ; calculate PVB destination offset
  1082.             mul     [bp].lvb_width
  1083.             add     ax,[bp].leftdest
  1084.             shl     ax,1
  1085.             mov     [bp].PVBMoveDestOff,ax
  1086.  
  1087.             mov     ax,[bp].topscroll   ; calculate LVB source offset
  1088.             sub     ax,[bp].minrow
  1089.             mul     [bp].lvb_width
  1090.             add     ax,[bp].leftscroll
  1091.             sub     ax,[bp].mincol
  1092.             shl     ax,1                ; (ax) = LVB src off for 2 byte cell
  1093.             mov     [bp].LVBMoveSrcOff,ax
  1094.  
  1095.             mov     ax,[bp].topdest     ; calculate LVB destination offset
  1096.             sub     ax,[bp].minrow
  1097.             mul     [bp].lvb_width
  1098.             add     ax,[bp].leftdest
  1099.             sub     ax,[bp].mincol
  1100.             shl     ax,1                ; (cx)= LVB dest off for 2 byte cell
  1101.             mov     [bp].LVBMoveDestOff,ax
  1102.  
  1103.             .if     <[bp].cellsize e WorldCellSize>
  1104.                 shl     [bp].LVBMoveSrcOff,1    ; 4 bytes per cell
  1105.                 shl     [bp].LVBMoveDestOff,1   ; 4 bytes per cell
  1106.             .endif
  1107.  
  1108.         .else                           ; Do the DOWN-RIGHT thing
  1109.             mov     ax,[bp].bottomscroll; calculate PVB source offset
  1110.             mul     es:[di].TextCols
  1111.             add     ax,[bp].rightscroll
  1112.             shl     ax,1
  1113.             mov     [bp].PVBMoveSrcOff,ax
  1114.  
  1115.             mov     ax,[bp].bottomdest  ; calculate PVB destination offset
  1116.             mul     [bp].lvb_width
  1117.             add     ax,[bp].rightdest
  1118.             shl     ax,1
  1119.             mov     [bp].PVBMoveDestOff,ax
  1120.  
  1121.             mov     ax,[bp].bottomscroll; calculate LVB source offset
  1122.             sub     ax,[bp].minrow
  1123.             mul     [bp].lvb_width
  1124.             add     ax,[bp].rightscroll
  1125.             sub     ax,[bp].mincol
  1126.             shl     ax,1                ; (ax) = LVB src off for 2 byte cell
  1127.             mov     [bp].LVBMoveSrcOff,ax
  1128.  
  1129.             mov     ax,[bp].bottomdest  ; calculate LVB destination offset
  1130.             sub     ax,[bp].minrow
  1131.             mul     [bp].lvb_width
  1132.             add     ax,[bp].rightdest
  1133.             sub     ax,[bp].mincol
  1134.             shl     ax,1                ; (cx)= LVB dest off for 2 byte cell
  1135.             mov     [bp].LVBMoveDestOff,ax
  1136.             .if     <[bp].cellsize e WorldCellSize>
  1137.                 inc     [bp].LVBMoveSrcOff  ; start at last word of cell
  1138.                 inc     [bp].LVBMoveDestOff ; start at last word of cell
  1139.                 shl     [bp].LVBMoveSrcOff,1    ; 4 bytes per cell
  1140.                 shl     [bp].LVBMoveDestOff,1   ; 4 bytes per cell
  1141.             .endif
  1142.  
  1143.         .endif
  1144.         ret
  1145.  
  1146. CalcMoveValues      ENDP                                        ;@P1 end
  1147.  
  1148. ;/***************************************************************************
  1149. ;*
  1150. ;* FUNCTION NAME = CalcFillValues
  1151. ;*
  1152. ;* DESCRIPTION   = 
  1153. ;*
  1154. ;*      Calculate values the fill rectangle function needs
  1155. ;*
  1156. ;*      CalcFillValues calculates the offset into the fill rectangle that
  1157. ;*      is used by the fill function.
  1158. ;*
  1159. ;*      This routine also calculates the number of rows that need to
  1160. ;*      be filled.  This value will always be at least one.
  1161. ;*
  1162. ;*      The number of bytes in each row is calculated.  The value of
  1163. ;*      this number is always at least one * cellsize (2 or 4 bytes)
  1164. ;*      and is always a multiple of cell size.
  1165. ;*
  1166. ;*      The number of bytes that need to be skipped to reach the start
  1167. ;*      of the next row to be copied is calculated.  This value may be
  1168. ;*      zero.
  1169. ;*
  1170. ;*      With the exception of the number of rows to move, all of the
  1171. ;*      values above are calculated separately for the LVB and the PVB
  1172. ;*      because the cell size may be different between the two.
  1173. ;*
  1174. ;* INPUT    =   BX - Flag indicating the type of scroll (UP,DOWN,LEFT,RIGHT)
  1175. ;*              SS:BP - local data storage area
  1176. ;*              DS:SI - user passed parameter block
  1177. ;*              ES:DI - mode data structure
  1178. ;*              [bp].lvb_width - width of the LVB in cells
  1179. ;*              [bp].cellsize - number of bytes per cell in the LVB
  1180. ;*
  1181. ;*              [bp].minrow - index of top most row in LVB (PVB coordinates)
  1182. ;*              [bp].mincol - index of left most row in LVB (PVB coordinates)
  1183. ;*
  1184. ;*              [bp].topfill      = Rect adjusted to indicate fill region
  1185. ;*              [bp].leftfill     =     "
  1186. ;*              [bp].rightfill    =     "
  1187. ;*              [bp].bottomfill   =     "
  1188. ;*
  1189. ;* OUTPUT   =
  1190. ;*              [bp].RowsToFill   = rows to be filled with the default cell
  1191. ;*
  1192. ;*              [bp].PVBFillCount = # of bytes per fill line in PVB
  1193. ;*              [bp].PVBFillSkip  = # of bytes to skip to reach next PVB line
  1194. ;*              [bp].PVBFillOff   = offset of beginning of PVB fill rectangle
  1195. ;*
  1196. ;*              [bp].LVBFillCount = # of bytes per fill line in LVB
  1197. ;*              [bp].LVBFillSkip  = # of bytes to skip to reach next LVB line
  1198. ;*              [bp].LVBFillOff   = offset of beginning of LVB fill rectangle
  1199. ;*
  1200. ;*              [bp].FillCellLow  = first word of default fill cell
  1201. ;*              [bp].FillCellHigh = second word of default fill cell
  1202. ;*
  1203. ;* CALLS   none
  1204. ;*
  1205. ;* USES    AX,CX,DX,SI,FLAGS
  1206. ;*
  1207. ;* NOTES
  1208. ;*
  1209. ;* PSEUDOCODE
  1210. ;*
  1211. ;*       RowsToFill = bottomfill - topfill + 1
  1212. ;*       PVBFillOff = (topfill * modeCols + leftfill) * cellsize
  1213. ;*       PVBFillCount = rightfill - leftfill * cellsize
  1214. ;*       PVBFillSkip = modeCols * cellsize - PVBFillCount
  1215. ;*       LVBFillOff = (leftfill - minrow) * lvb_width +
  1216. ;*                    (topfill - mincol) * cellsize
  1217. ;*       LVBFillCount = rightfill - leftfill * cellsize
  1218. ;*       LVBFillSkip = modeCols * cellsize - LVBFillCount
  1219. ;*       FillCellLow = first word of cell
  1220. ;*       if (inputcellsize = 4)
  1221. ;*           FillCellHigh = second word of cell
  1222. ;*       else
  1223. ;*           FillCellHigh = 0
  1224. ;*
  1225. ;* RETURN-NORMAL = NONE
  1226. ;* RETURN-ERROR  = NONE
  1227. ;*
  1228. ;****************************************************************************/
  1229.  
  1230.                     PUBLIC  CalcFillValues                      ;@P1 begin
  1231. CalcFillValues      PROC
  1232.  
  1233.         mov     ax,[bp].bottomfill      ; calculate the number of rows
  1234.         sub     ax,[bp].topfill         ; to fill
  1235.         inc     ax
  1236.         mov     [bp].RowsToFill,ax
  1237.  
  1238.         mov     ax,[bp].topfill         ; calculate PVB source offset
  1239.         mul     es:[di].TextCols
  1240.         add     ax,[bp].leftfill
  1241.         shl     ax,1
  1242.         mov     [bp].PVBFillOff,ax
  1243.  
  1244.         mov     cx,[bp].rightfill       ; calculate byte per PVB fill row
  1245.         sub     cx,[bp].leftfill
  1246.         inc     cx
  1247.         shl     cx,1
  1248.         mov     [bp].PVBFillCount,cx
  1249.  
  1250.         mov     ax,es:[di].TextCols     ; calculate bytes to skip in PVB
  1251.         shl     ax,1
  1252.         sub     ax,cx
  1253.         mov     [bp].PVBFillSkip,ax
  1254.  
  1255.         mov     ax,[bp].lvb_width       ; calculate bytes to skip in LVB
  1256.         shl     ax,1
  1257.         sub     ax,cx
  1258.         .if     <[bp].cellsize e WorldCellSize>
  1259.             shl     cx,1
  1260.             shl     ax,1
  1261.         .endif
  1262.         mov     [bp].LVBFillCount,cx    ; bytes to fill in LVB
  1263.         mov     [bp].LVBFillSkip,ax
  1264.  
  1265.         mov     ax,[bp].topfill         ; calculate LVB source offset
  1266.         sub     ax,[bp].minrow
  1267.         mul     [bp].lvb_width
  1268.         add     ax,[bp].leftfill
  1269.         sub     ax,[bp].mincol
  1270.         shl     ax,1
  1271.  
  1272.         .if     <[bp].cellsize e WorldCellSize>
  1273.             shl     ax,1
  1274.         .endif
  1275.         mov     [bp].LVBFillOff,ax
  1276.  
  1277.         test    bx,LVBPVB
  1278.         .if     <z>
  1279.             test    [si].Flags,CGAAttr      ; the jump is 5 lines down
  1280.  
  1281.             lds     si,[si].AppCellAddr
  1282.             lodsw
  1283.             mov     [bp].FillCellLow,ax
  1284.             mov     [bp].FillCellHigh,0
  1285.  
  1286.             .if     <z> and
  1287.             .if     <[bp].cellsize e WorldCellSize>
  1288.                 lodsw
  1289.                 mov     [bp].FillCellHigh,ax
  1290.             .endif
  1291.             lds     si,[bp].ParmBuf         ; (ds:si) -> parameter buffer
  1292.         .endif
  1293.  
  1294.         ret
  1295.  
  1296. CalcFillValues      ENDP                                        ;@P1 end
  1297.  
  1298.  
  1299. ;/***************************************************************************
  1300. ;*
  1301. ;* FUNCTION NAME = MoveUpLeft
  1302. ;*
  1303. ;* DESCRIPTION   = 
  1304. ;*
  1305. ;*      Move a rectangle for ScrollUp or ScrollLeft
  1306. ;*
  1307. ;*      MoveUpLeft copys a rectangle in the LVB and/or PVB from beginning
  1308. ;*      to end, one line at a time.
  1309. ;*
  1310. ;* INPUT     =  BX = LVB selector or 0 if no LVB write indicated
  1311. ;*              SS:BP - local data storage area
  1312. ;*
  1313. ;*              [bp].PVB_Sel = PVB selector if PVB scroll is indicated else 0
  1314. ;*
  1315. ;*              [bp].RowsToMove     = number of rows to move
  1316. ;*
  1317. ;*              [bp].PVBMoveCount   = # of bytes per PVB row to move
  1318. ;*              [bp].PVBMoveSkip    = # of bytes to skip to get to the next row
  1319. ;*              [bp].PVBMoveSrcOff  = offset to start of PVB source buffer
  1320. ;*              [bp].PVBMoveDestOff = offset to start of PVB destination buffer
  1321. ;*
  1322. ;*              [bp].LVBMoveCount   = # of bytes per PVB row to move
  1323. ;*              [bp].LVBMoveSkip    = # of bytes to skip to get to the next row
  1324. ;*              [bp].LVBMoveSrcOff  = offset to start of PVB source buffer
  1325. ;*              [bp].LVBMoveDestOff = offset to start of PVB destination buffer
  1326. ;*
  1327. ;* OUTPUT    =
  1328. ;*              The rectangle in the LVB or PVB is moved as appropriate
  1329. ;*
  1330. ;* CALLS   none
  1331. ;*
  1332. ;* USES    AX,BX,CX,DX,SI,DI,DS,ES,FLAGS
  1333. ;*
  1334. ;* NOTES
  1335. ;*
  1336. ;* PSEUDOCODE
  1337. ;*
  1338. ;*        cursrcoff  = FirstMoveSrcOff
  1339. ;*        curdestoff  = FirstMoveDestOff
  1340. ;*        while (RowsToMove--)
  1341. ;*            curcount = MoveCount
  1342. ;*            while (curcount--)
  1343. ;*                *curdestoff++ = *cursrcoff++
  1344. ;*            cursrcoff += NextLineMove
  1345. ;*            curdestoff += NextLineMove
  1346. ;*
  1347. ;* RETURN-NORMAL = NONE
  1348. ;* RETURN-ERROR  = NONE
  1349. ;*
  1350. ;****************************************************************************/
  1351.  
  1352.                 PUBLIC  MoveUpLeft                              ;@P1 begin
  1353. MoveUpLeft      PROC
  1354.  
  1355.         cld                                 ; increment si, di
  1356.         .if     <nonzero bx>
  1357.             mov     ds,bx
  1358.             mov     es,bx
  1359.             mov     bx,[bp].RowsToMove
  1360.             mov     si,[bp].LVBMoveSrcOff
  1361.             mov     di,[bp].LVBMoveDestOff
  1362.             mov     dx,[bp].LVBMoveCount
  1363.             shr     dx,1                    ; convert bytes to words
  1364.  
  1365. mulf10:     mov     cx,dx                   ; (cx) = bytes to move this row
  1366. IFDEF D1348 ;check if DBCS && common lvb.
  1367.             .if    <bit <[bp].flgDBCS> and anyDBCS> and
  1368.             .if    <[bp].j_funcindx eq WorldFmtIndx>
  1369.                 push    bx                  ; save row count
  1370.                 call    MoveUpLeftWrld
  1371.                 pop     bx                  ; restore row count
  1372.             .else
  1373.                 rep     movsw               ; move the line
  1374.             .endif
  1375. ELSE  ;D1348
  1376.             rep     movsw                   ; move the line
  1377. ENDIF ;D1348
  1378.             add     si,[bp].LVBMoveSkip     ; advance to the next source line
  1379.             add     di,[bp].LVBMoveSkip     ; advance to the next dest line
  1380.             dec     bx                      ; Are there more rows to move?
  1381.             jnz     mulf10                  ;   Yes, go do the next one
  1382.  
  1383.         .endif
  1384.         mov     bx,[bp].PVB_SEL
  1385.         .if     <nonzero bx>
  1386.             mov     ds,bx
  1387.             mov     es,bx
  1388.             mov     bx,[bp].RowsToMove
  1389.             mov     si,[bp].PVBMoveSrcOff
  1390.             mov     di,[bp].PVBMoveDestOff
  1391.             mov     dx,[bp].PVBMoveCount
  1392.             shr     dx,1                    ; convert bytes to words
  1393.  
  1394. mulf20:     mov     cx,dx                   ; (cx) = bytes to move this row
  1395.             REP_MOVSW                       ; Use this macro so CGA can share
  1396.                                             ; the same set of sources
  1397.             add     si,[bp].PVBMoveSkip     ; advance to the next source line
  1398.             add     di,[bp].PVBMoveSkip     ; advance to the next dest line
  1399.             dec     bx                      ; Are there more rows to move?
  1400.             jnz     mulf20                  ;   Yes, go do the next one
  1401.  
  1402.         .endif
  1403.  
  1404.         ret
  1405.  
  1406. MoveUpLeft      ENDP                                            ;@P1 end
  1407.  
  1408.  
  1409. ;/***************************************************************************
  1410. ;*
  1411. ;* FUNCTION NAME = MoveDownRight
  1412. ;*
  1413. ;* DESCRIPTION   = 
  1414. ;*
  1415. ;*      Move a rectangle for ScrollDown or ScrollRight
  1416. ;*
  1417. ;*      MoveDownRight copys a rectangle in the LVB and/or PVB from beginning
  1418. ;*      to end, one line at a time.
  1419. ;*
  1420. ;* INPUT     =  BX = LVB selector or 0 if no LVB write indicated
  1421. ;*              SS:BP - local data storage area
  1422. ;*
  1423. ;*              [bp].PVB_Sel = PVB selector if PVB scroll is indicated else 0
  1424. ;*
  1425. ;*              [bp].RowsToMove     = number of rows to move
  1426. ;*
  1427. ;*              [bp].PVBMoveCount   = # of bytes per PVB row to move
  1428. ;*              [bp].PVBMoveSkip    = # of bytes to skip to get to the next row
  1429. ;*              [bp].PVBMoveSrcOff  = offset to start of PVB source buffer
  1430. ;*              [bp].PVBMoveDestOff = offset to start of PVB destination buffer
  1431. ;*
  1432. ;*              [bp].LVBMoveCount   = # of bytes per PVB row to move
  1433. ;*              [bp].LVBMoveSkip    = # of bytes to skip to get to the next row
  1434. ;*              [bp].LVBMoveSrcOff  = offset to start of PVB source buffer
  1435. ;*              [bp].LVBMoveDestOff = offset to start of PVB destination buffer
  1436. ;*
  1437. ;* OUTPUT    =
  1438. ;*              The rectangle in the LVB or PVB is moved as appropriate
  1439. ;*
  1440. ;* CALLS   none
  1441. ;*
  1442. ;* USES    AX,BX,CX,DX,SI,DI,DS,ES,FLAGS
  1443. ;*
  1444. ;* NOTES
  1445. ;*
  1446. ;* PSEUDOCODE
  1447. ;*
  1448. ;*        cursrcoff  = LastMoveSrcOff
  1449. ;*        curdestoff  = LastMoveDestOff
  1450. ;*        while (RowsToMove--)
  1451. ;*            curcount = MoveCount
  1452. ;*            while (curcount--)
  1453. ;*                *curdestoff-- = *cursrcoff--
  1454. ;*            cursrcoff -= NextLineMove
  1455. ;*            curdestoff -= NextLineMove
  1456. ;*
  1457. ;* RETURN-NORMAL = NONE
  1458. ;* RETURN-ERROR  = NONE
  1459. ;*
  1460. ;****************************************************************************/
  1461.  
  1462.                 PUBLIC  MoveDownRight                           ;@P1 begin
  1463. MoveDownRight   PROC
  1464.  
  1465.         std                                 ; decrement si, di
  1466.         .if     <nonzero bx>
  1467.             mov     ds,bx
  1468.             mov     es,bx
  1469.             mov     bx,[bp].RowsToMove
  1470.             mov     si,[bp].LVBMoveSrcOff
  1471.             mov     di,[bp].LVBMoveDestOff
  1472.             mov     dx,[bp].LVBMoveCount
  1473.             shr     dx,1                    ; convert bytes to words
  1474.  
  1475. mdrt10:     mov     cx,dx                   ; (cx) = bytes to move this row
  1476. IFDEF D1348 ;check if DBCS && common lvb.
  1477.             .if    <bit <[bp].flgDBCS> and anyDBCS> and
  1478.             .if    <[bp].j_funcindx eq WorldFmtIndx>
  1479.                 push    bx                  ; save row count
  1480.                 call    MoveDownRightWrld
  1481.                 pop     bx                  ; restore row count
  1482.             .else
  1483.                 rep     movsw               ; move the line
  1484.             .endif
  1485. ELSE  ;D1348
  1486.             rep     movsw                   ; move the line
  1487. ENDIF ;D1348
  1488.             sub     si,[bp].LVBMoveSkip     ; advance to the next source line
  1489.             sub     di,[bp].LVBMoveSkip     ; advance to the next dest line
  1490.             dec     bx                      ; Are there more rows to move?
  1491.             jnz     mdrt10                  ;   Yes, go do the next one
  1492.  
  1493.         .endif
  1494.         mov     bx,[bp].PVB_SEL
  1495.         .if     <nonzero bx>
  1496.             mov     ds,bx
  1497.             mov     es,bx
  1498.             mov     bx,[bp].RowsToMove
  1499.             mov     si,[bp].PVBMoveSrcOff
  1500.             mov     di,[bp].PVBMoveDestOff
  1501.             mov     dx,[bp].PVBMoveCount
  1502.             shr     dx,1                    ; convert bytes to words
  1503.  
  1504. mdrt20:     mov     cx,dx                   ; (cx) = bytes to move this row
  1505.             REP_MOVSW                       ; Use this macro so CGA can share
  1506.                                             ; the same set of sources
  1507.             sub     si,[bp].PVBMoveSkip     ; advance to the next source line
  1508.             sub     di,[bp].PVBMoveSkip     ; advance to the next dest line
  1509.             dec     bx                      ; Are there more rows to move?
  1510.             jnz     mdrt20                  ;   Yes, go do the next one
  1511.  
  1512.         .endif
  1513.  
  1514.         ret
  1515.  
  1516. MoveDownRight   ENDP                                            ;@P1 end
  1517.  
  1518.  
  1519. ;/***************************************************************************
  1520. ;*
  1521. ;* FUNCTION NAME = FillRectWithCell
  1522. ;*
  1523. ;* DESCRIPTION   = 
  1524. ;*
  1525. ;*      Fill a rectangle for with the default cell
  1526. ;*
  1527. ;*      FillRectWithCell fills the specified rectangle in the LVB and/or
  1528. ;*      PVB with the given cell, beginning to end, one line at a time.
  1529. ;*
  1530. ;* INPUT     =  BX = LVB selector or 0 if no LVB write indicated
  1531. ;*              SS:BP - local data storage area
  1532. ;*
  1533. ;*              [bp].PVB_Sel = PVB selector if PVB scroll is indicated else 0
  1534. ;*
  1535. ;*              [bp].RowsToFill   = rows to be filled with the default cell
  1536. ;*
  1537. ;*              [bp].PVBFillCount = # of bytes per fill line in PVB
  1538. ;*              [bp].PVBFillSkip  = # of bytes to skip to reach next PVB line
  1539. ;*              [bp].PVBFillOff   = offset of beginning of PVB fill rectangle
  1540. ;*
  1541. ;*              [bp].LVBFillCount = # of bytes per fill line in LVB
  1542. ;*              [bp].LVBFillSkip  = # of bytes to skip to reach next LVB line
  1543. ;*              [bp].LVBFillOff   = offset of beginning of LVB fill rectangle
  1544. ;*
  1545. ;*              [bp].FillCellLow  = first word of default fill cell
  1546. ;*              [bp].FillCellHigh = second word of default fill cell
  1547. ;*
  1548. ;* OUTPUT     =
  1549. ;*              The rectangle in the LVB or PVB is moved as appropriate
  1550. ;*
  1551. ;*
  1552. ;*      CALLS   none
  1553. ;*
  1554. ;*      USES    AX,BX,CX,DX,SI,DI,DS,ES,FLAGS
  1555. ;*
  1556. ;*      NOTES
  1557. ;*
  1558. ;*      PSEUDOCODE
  1559. ;*
  1560. ;*           curdestoff = FirstFillDestOff
  1561. ;*           while (RowsToFill)
  1562. ;*           for (curline = FirstFillLine; curline <= LastFillLine; curline++)
  1563. ;*               curcount = FillCount
  1564. ;*               while (curcount--)
  1565. ;*                   *curdestoff = fillcell
  1566. ;*               curdestoff += NextLineFill
  1567. ;*
  1568. ;*
  1569. ;* RETURN-NORMAL = NONE
  1570. ;* RETURN-ERROR  = NONE
  1571. ;*
  1572. ;****************************************************************************/
  1573.  
  1574.                 PUBLIC  FillRectWithCell                        ;@P1 begin
  1575. FillRectWithCell    PROC
  1576.  
  1577.         cld                                 ; increment si, di
  1578.         mov     ax,[bp].FillCellLow
  1579.         .if     <nonzero bx>
  1580.             mov     ds,bx
  1581.             mov     es,bx
  1582.             mov     bx,[bp].RowsToFill
  1583.             mov     di,[bp].LVBFillOff
  1584.             mov     dx,[bp].LVBFillCount
  1585.             .if     <[bp].cellsize e WorldCellSize>
  1586.                 mov     si,[bp].FillCellHigh
  1587.                 shr     dx,2                ; convert bytes to cells
  1588.  
  1589. frwc10:         mov     cx,dx               ; (cx) = bytes to move this row
  1590.                 .repeat                     ; fill the line with the cell
  1591.                     stosw
  1592.                     xchg    ax,si
  1593.                     stosw
  1594.                     xchg    ax,si
  1595.                 .loop
  1596.                 add     di,[bp].LVBFillSkip ; advance to the next source line
  1597.                 dec     bx                  ; Are there more rows to move?
  1598.                 jnz     frwc10              ;   Yes, go do the next one
  1599.             .else
  1600.                 shr     dx,1                ; convert bytes to cells
  1601.  
  1602. frwc20:         mov     cx,dx               ; (cx) = bytes to move this row
  1603.                 rep     stosw               ; fill the line with the cell
  1604.                 add     di,[bp].LVBFillSkip ; advance to the next source line
  1605.                 dec     bx                  ; Are there more rows to move?
  1606.                 jnz     frwc20              ;   Yes, go do the next one
  1607.             .endif
  1608.         .endif
  1609.         mov     bx,[bp].PVB_SEL
  1610.         .if     <nonzero bx>
  1611.             mov     ds,bx
  1612.             mov     es,bx
  1613.             mov     bx,[bp].RowsToFill
  1614.             mov     di,[bp].PVBFillOff
  1615.             mov     dx,[bp].PVBFillCount
  1616.             shr     dx,1                    ; convert bytes to words
  1617.  
  1618. frwc30:     mov     cx,dx                   ; (cx) = bytes to move this row
  1619.             REP_STOSW                       ; Use this macro so CGA can share
  1620.                                             ; the same set of sources
  1621.             add     di,[bp].PVBFillSkip     ; advance to the next dest line
  1622.             dec     bx                      ; Are there more rows to move?
  1623.             jnz     frwc30                  ;   Yes, go do the next one
  1624.         .endif
  1625.  
  1626.         ret
  1627.  
  1628. FillRectWithCell    ENDP                                        ;@P1 end
  1629.  
  1630.  
  1631. ;/***************************************************************************
  1632. ;*
  1633. ;* FUNCTION NAME = MoveLVBRectToPVB
  1634. ;*
  1635. ;*      Copy a rectangle from LVB to PVB
  1636. ;*
  1637. ;*      MoveLVBRectToPVB copys the FillRect in the LVB to the FillRect in
  1638. ;*      the PVB.  Conversions for different cell sizes are done at this time.
  1639. ;*
  1640. ;* INPUT    =   BX = LVB selector or 0 if no LVB write indicated
  1641. ;*              SS:BP - local data storage area
  1642. ;*
  1643. ;*              [bp].PVB_Sel = PVB selector if PVB scroll is indicated else 0
  1644. ;*
  1645. ;*              [bp].RowsToFill   = rows to be filled with the default cell
  1646. ;*
  1647. ;*              [bp].PVBFillCount = # of bytes per fill line in PVB
  1648. ;*              [bp].PVBFillSkip  = # of bytes to skip to reach next PVB line
  1649. ;*              [bp].PVBFillOff   = offset of beginning of PVB fill rectangle
  1650. ;*
  1651. ;*              [bp].LVBFillCount = # of bytes per fill line in LVB
  1652. ;*              [bp].LVBFillSkip  = # of bytes to skip to reach next LVB line
  1653. ;*              [bp].LVBFillOff   = offset of beginning of LVB fill rectangle
  1654. ;*
  1655. ;*              [bp].FillCellLow  = first word of default fill cell
  1656. ;*              [bp].FillCellHigh = second word of default fill cell
  1657. ;*
  1658. ;* OUTPUT    =
  1659. ;*              The rectangle in the LVB or PVB is moved as appropriate
  1660. ;*
  1661. ;*
  1662. ;*      CALLS   none
  1663. ;*
  1664. ;*      USES    AX,BX,CX,DX,SI,DI,DS,ES,FLAGS
  1665. ;*
  1666. ;*      NOTES
  1667. ;*
  1668. ;*      PSEUDOCODE
  1669. ;*
  1670. ;*          cursrcoff = LVBFillOff
  1671. ;*          curdestoff = PVBFillOff
  1672. ;*          while (RowsToFill)
  1673. ;*              curcount = FillCount
  1674. ;*              while (curcount--)
  1675. ;*                  *curdestoff = *cursrcoff
  1676. ;*              curdestoff += PVBFillSkip
  1677. ;*              cursrcoff += LVBFillSkip
  1678. ;*        
  1679. ;*
  1680. ;* RETURN-NORMAL = NONE
  1681. ;* RETURN-ERROR  = NONE
  1682. ;*
  1683. ;****************************************************************************/
  1684.  
  1685.                 PUBLIC  MoveLVBRectToPVB                        ;@P1 begin
  1686. MoveLVBRectToPVB    PROC
  1687.  
  1688.         cld                                 ; increment si, di
  1689.         .if     <nonzero bx> and
  1690.         mov     ds,bx                       ; (ds) = LVB segment
  1691.         mov     bx,[bp].PVB_Sel
  1692.         .if     <nonzero bx>
  1693.             mov     es,bx                   ; (es) = PVB segment
  1694.             mov     si,[bp].LVBFillOff      ; (si) = LVB rectangle offset
  1695.             mov     di,[bp].PVBFillOff      ; (di) = PVB rectangle offset
  1696.             mov     bx,[bp].RowsToFill
  1697.             mov     dx,[bp].LVBFillCount
  1698.             .if     <[bp].cellsize e WorldCellSize>
  1699.                 shr     dx,2                ; convert bytes to cells
  1700.  
  1701. lrtp10:         mov     cx,dx               ; (cx) = bytes to move this row
  1702.                 REP_MOVSW_ADDSI2_LOOP       ; Use this macro so CGA can share
  1703.                                             ; the same set of sources
  1704.                 add     si,[bp].LVBFillSkip ; advance to the next LVB line
  1705.                 add     di,[bp].PVBFillSkip ; advance to the next PVB line
  1706.                 dec     bx                  ; Are there more rows to move?
  1707.                 jnz     lrtp10              ;   Yes, go do the next one
  1708.             .else
  1709.                 shr     dx,1                ; convert bytes to cells
  1710.  
  1711. lrtp20:         mov     cx,dx               ; (cx) = bytes to move this row
  1712.                 REP_MOVSW                   ; Use this macro so CGA can share
  1713.                                             ; the same set of sources
  1714.                 add     si,[bp].LVBFillSkip ; advance to the next LVB line
  1715.                 add     di,[bp].PVBFillSkip ; advance to the next PVB line
  1716.                 dec     bx                  ; Are there more rows to move?
  1717.                 jnz     lrtp20              ;   Yes, go do the next one
  1718.             .endif
  1719.         .endif
  1720.  
  1721.         ret
  1722.  
  1723. MoveLVBRectToPVB    ENDP                                        ;@P1 end
  1724.  
  1725. R2CSEG  ENDS
  1726.         END
  1727.  
  1728.