home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / VDH / CGAWRITE.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  37KB  |  666 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   CGAWRITE.ASM -- CGA Buffer Write Routines
  14.  
  15. ;/*****************************************************************************
  16. ;*
  17. ;* SOURCE FILE NAME = CGAWRITE.ASM
  18. ;*
  19. ;* DESCRIPTIVE NAME = CGA Buffer Write Routines 
  20. ;*
  21. ;*
  22. ;* VERSION      V2.0
  23. ;*
  24. ;* DATE         
  25. ;*
  26. ;* DESCRIPTION  BUFFERUPDATE write routines    
  27. ;*
  28. ;* FUNCTIONS    WriteCellStr, WriteCharStr, WriteCharStrAttr,  
  29. ;*              WriteNChar, WriteNAttr, WriteNCell             
  30. ;*
  31. ;* NOTES        NONE
  32. ;*             
  33. ;* STRUCTURES   NONE
  34. ;*
  35. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in CGAREAD.ASM)  
  36. ;*                      STOSB_SKIP_DI, _MOVSW, MOVSB_STOSB, _STOSW 
  37. ;*                      MOVSB_SKIP_DI                
  38. ;*                                                    
  39. ;* EXTERNAL FUNCTIONS
  40. ;*
  41. ;*              NONE
  42. ;*
  43. ;* CHANGE ACTIVIY =
  44. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  45. ;*   --------  ---------- -----   --------------------------------------
  46. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  47. ;****************************************************************************/
  48.  
  49.         .286c                                     ; 286 protect mode instructions
  50.  
  51.         .xlist
  52.         INCLUDE struc.inc                         ; Structure macro
  53.         INCLUDE error2.inc                        ; Subsystem error equates
  54.         INCLUDE vdhstruc.inc                      ; Buffer update data structures
  55.         INCLUDE vdhequ.inc                        ; Buffer update equates
  56.         .list
  57.  
  58.         EXTRN   LocateBuffAddr : NEAR             ; Determine target/source buffer
  59.         EXTRN   _MOVSW         : FAR              ; Move words from DS:SI to ES:DI
  60.         EXTRN   _STOSW         : FAR              ; Store words from DS:SI to ES:DI
  61.         EXTRN   MOVSB_STOSB    : FAR              ; Move byte from DS:SI to ES:DI
  62.                                                   ;   and store AL to ES:DI
  63.         EXTRN   MOVSB_SKIP_DI  : FAR              ; Move byte DS:SI to ES:DI
  64.         EXTRN   STOSB_SKIP_DI  : FAR              ; Store AL to ES:DI
  65.  
  66.  
  67. R2CSEG  SEGMENT WORD    PUBLIC 'CODE'
  68.         ASSUME  CS:R2CSEG,DS:NOTHING,ES:NOTHING
  69.  
  70. ;/****************************************************************************
  71. ;*                                                    
  72. ;* SUBROUTINE NAME:     WriteCellStr                 
  73. ;*                                                    
  74. ;* DESCRIPTIVE NAME:    Video device handler write cells  
  75. ;*                                                    
  76. ;* FUNCTION:    Process write cells sub-function.   
  77. ;*              The cells are written to the LVB and/or PVB  
  78. ;*              starting at the specified row, column location.  
  79. ;*              Line wrap occurs if the end of a line is reached. 
  80. ;*              Write function is terminated if the end of PVB or 
  81. ;*              LVB is reached.  The number of the char/attr cells 
  82. ;*              written is returned in the RepeatFactor field of 
  83. ;*              the paramter block.                  
  84. ;*                                                    
  85. ;* ENTRY POINT: WriteCellStr                          
  86. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine   
  87. ;*                                                    
  88. ;* INPUT:                                             
  89. ;*                                                    
  90. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC) 
  91. ;* DS:SI  --->  Parameter block buffer            (see CGABUFUP.ASM) 
  92. ;* ES:DI  --->  Mode data in environment buffer (see CGABUFUP.ASM) 
  93. ;*                                                    
  94. ;* PARAMETER BLOCK FORMAT:                            
  95. ;*                                                    
  96. ;*   SIZE   DESCRIPTION                               
  97. ;*   ----   -----------                               
  98. ;*                                                    
  99. ;*   WORD   Parameter length                          
  100. ;*   WORD   Flags                                      (target data buffer - LVB, PVB) 
  101. ;*   DWORD  Application data address  (source data buffer) 
  102. ;*   DWORD  Application data2 address (not used in this call) 
  103. ;*   WORD   Index (7)                                
  104. ;*   WORD   Starting row                               (target row)  
  105. ;*   WORD   Starting column                            (target column)  
  106. ;*   WORD   Secondary row                              (not used in this call)  
  107. ;*   WORD   Secondary column                           (not used in this call)  
  108. ;*   WORD   RepeatFactor                               (input and output length)  
  109. ;*   WORD   LogicalBufSel                             
  110. ;*                                                    
  111. ;* OUTPUT:      LVB and/or PVB = new attributes    
  112. ;*              RepeatFactor = sum of char/attr pairs written  
  113. ;*                                                    
  114. ;* EXIT-NORMAL: AX = 0                                
  115. ;*                                                    
  116. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr      
  117. ;*                                                    
  118. ;* EFFECTS:     All                                   
  119. ;*                                                    
  120. ;* INTERNAL REFERENCES: None                          
  121. ;*                                                    
  122. ;* EXTERNAL REFERENCES: LocateBuffAddr            (in CGAREAD.ASM)  
  123. ;*                      _MOVSW                        
  124. ;*                                                    
  125. ;****************************************************************************/
  126.  
  127.         PUBLIC  WriteCellStr
  128. WriteCellStr    PROC    NEAR
  129.  
  130.         mov     bx, 1                              ; Set indicator for word move
  131.         call    LocateBuffAddr                     ; On exit: BX = sel, AX = off
  132.  
  133. ;/*
  134. ;**   On exit from LocateBuffAddr:                     
  135. ;**     If PVB & LVB flags are set then BX = LVB selector   
  136. ;**        [bp].PVB_Sel = PVB selector 
  137. ;**     else BX = LVB or PVB selector  
  138. ;**                                                     
  139. ;**   If both PVB and LVB are selected then the input cells will be 
  140. ;**   written to the LVB first before the PVB is updated.   
  141. ;*/
  142.  
  143.         .if     <nc>                               ; Continue?
  144.             shr     cx, 1                          ; Adjust for word move
  145.             lds     si, [si].AppDataAddr           ; Setup source address
  146.             mov     es, bx                         ; Setup destination selector
  147.             mov     di, ax                         ; Setup destination offset
  148.             .if     <[bp].PVB_Sel a 0>             ; Write through request?
  149.                 push    cx                         ; Save repeat factor and
  150.                 push    es                         ;   LVB destination address
  151.                 push    di                         ; 
  152.                 sub     bx, bx                     ; Go to LVB first
  153.                 call    _MOVSW                     ; Fill destination buffer
  154.                 mov     es, [bp].PVB_Sel           ; Setup PVB as destination
  155.                 pop     si                         ; 
  156.                 pop     ds                         ; DS:SI -> LVB
  157.                 pop     cx                         ; 
  158.                 mov     di, si                     ; ES:DI -> PVB
  159.                 inc     [bp].Retrace               ; Indicate retrace is required
  160.             .endif                                 ; 
  161.             mov     bx, [bp].Retrace               ; Pass retrace indicator
  162.             call    _MOVSW                         ; Copy cell from DS:SI to ES:DI
  163.             sub     ax, ax                         ; Clear return code
  164.         .endif                                     ; 
  165.         ret                                        ; 
  166.  
  167. WriteCellStr    ENDP
  168.  
  169. ;/****************************************************************************
  170. ;*                                                    
  171. ;* SUBROUTINE NAME:     WriteCharStr                 
  172. ;*                                                    
  173. ;* DESCRIPTIVE NAME:    Video device handler write characters  
  174. ;*                                                    
  175. ;* FUNCTION:    Process write characters sub-function.   
  176. ;*              The characters are read from a user supplied  
  177. ;*              buffer which to be placed starting a the  
  178. ;*              specified row, column location within the PVB  
  179. ;*              and/or LVB.  Line wrap occurs if the end of a  
  180. ;*              line is reached.  Write function is terminated  
  181. ;*              if the end of PVB or LVB is reached.  The number 
  182. ;*              of characters written is returned in the  
  183. ;*              RepeatFacter field of the parameter block.  
  184. ;*                                                    
  185. ;* ENTRY POINT: WriteCharStr                          
  186. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine   
  187. ;*                                                    
  188. ;* INPUT:                                             
  189. ;*                                                    
  190. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC) 
  191. ;* DS:SI  --->  Parameter block buffer            (see CGABUFUP.ASM) 
  192. ;* ES:DI  --->  Mode data in environment buffer (see CGABUFUP.ASM) 
  193. ;*                                                    
  194. ;* PARAMETER BLOCK FORMAT:                            
  195. ;*                                                    
  196. ;*   SIZE   DESCRIPTION                               
  197. ;*   ----   -----------                               
  198. ;*                                                    
  199. ;*   WORD   Parameter length                          
  200. ;*   WORD   Flags                                      (target data buffer - LVB, PVB) 
  201. ;*   DWORD  Application data address  (source data buffer)  
  202. ;*   DWORD  Application data2 address (not used in this call)  
  203. ;*   WORD   Index (8)                                 
  204. ;*   WORD   Starting row                               (target row)   
  205. ;*   WORD   Starting column                            (target column)   
  206. ;*   WORD   Secondary row                              (not used in this call)  
  207. ;*   WORD   Secondary column                           (not used in this call)  
  208. ;*   WORD   RepeatFactor                               (input and output length)  
  209. ;*   WORD   LogicalBufSel                             
  210. ;*                                                    
  211. ;* OUTPUT:      PVB and/or LVB = new characters    
  212. ;*              RepeatFactor = number of characters written  
  213. ;*                                                    
  214. ;* EXIT-NORMAL: AX = 0                                
  215. ;*                                                    
  216. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr      
  217. ;*                                                    
  218. ;* EFFECTS:     AX, BX, DI, SI, DS, ES               
  219. ;*                                                    
  220. ;* INTERNAL REFERENCES: None                          
  221. ;*                                                    
  222. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in VDHREAD.ASM)  
  223. ;*                      MOVSB_SKIP_DI, _MOVSW       
  224. ;*                                                    
  225. ;****************************************************************************/
  226.  
  227.         PUBLIC  WriteCharStr
  228. WriteCharStr    PROC    NEAR
  229.  
  230.         sub     bx, bx                             ; Set indicator for byte move
  231.         call    LocateBuffAddr                     ; On exit: BX = sel, AX = off
  232.         .if     <nc>                               ; Continue?
  233.  
  234. ;/*
  235. ;**    On exit from LocateBuffAddr:                     
  236. ;**      If PVB & LVB flags are set then BX = LVB selector   
  237. ;**         [bp].PVB_Sel = PVB selector 
  238. ;**      else BX = LVB or PVB selector  
  239. ;**                                                      
  240. ;**    If both PVB and LVB are selected then the input characters will 
  241. ;**    be written to the LVB first before the PVB is updated.  
  242. ;*/
  243.  
  244.             lds     si, [si].AppDataAddr           ; Setup source address
  245.             mov     es, bx                         ; Setup destination selector
  246.             mov     di, ax                         ; Setup destination offset
  247.             .if     <[bp].PVB_Sel a 0>             ; Write through request?
  248.                 push    cx                         ; Save repeat factor, source
  249.                 push    si                         ;   and destination offset
  250.                 push    di                         ; 
  251.                 sub     bx, bx                     ; Go to LVB first
  252.                 call    MOVSB_SKIP_DI              ; Fill destination buffer
  253.                 mov     es, [bp].PVB_Sel           ; Setup PVB as destination
  254.                 pop     di                         ; ES:DI -> PVB
  255.                 pop     si                         ; DS:SI -> AppDataAddr
  256.                 pop     cx                         ; 
  257.                 inc     [bp].Retrace               ; Indicate retrace is required
  258.             .endif                                 ; 
  259.             mov     bx, [bp].Retrace               ; Pass retrace indicator
  260.             call    MOVSB_SKIP_DI                  ; Copy cell from DS:SI to ES:DI
  261.             sub     ax, ax                         ; Clear return code
  262.         .endif                                     ; 
  263.         ret                                        ; 
  264.  
  265. WriteCharStr    ENDP
  266.  
  267. ;/****************************************************************************
  268. ;*                                                    
  269. ;* SUBROUTINE NAME:     WriteCharStrAttr            
  270. ;*                                                    
  271. ;* DESCRIPTIVE NAME:    Video device handler write characters  
  272. ;*                      with a constant attribute   
  273. ;*                                                    
  274. ;* FUNCTION:    Process write characters, attribute sub-function. 
  275. ;*              The characters and attribute are read from user  
  276. ;*              supplied buffers which will be placed starting  
  277. ;*              at the specified row, column location within the 
  278. ;*              PVB and/or LVB.  Line wrap occurs if the end of  
  279. ;*              a line is reached.  Write function is terminated 
  280. ;*              if the end of PVB or LVB is reached.  The number 
  281. ;*              of char/attr pairs written is returned in the  
  282. ;*              RepeatFacter field of the parameter block.  
  283. ;*                                                    
  284. ;* ENTRY POINT: WriteCharStrAttr                     
  285. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine   
  286. ;*                                                    
  287. ;* INPUT:                                             
  288. ;*                                                    
  289. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC) 
  290. ;* DS:SI  --->  Parameter block buffer            (see CGABUFUP.ASM) 
  291. ;* ES:DI  --->  Mode data in environment buffer (see CGABUFUP.ASM) 
  292. ;*                                                    
  293. ;* PARAMETER BLOCK FORMAT:                            
  294. ;*                                                    
  295. ;*   SIZE   DESCRIPTION                               
  296. ;*   ----   -----------                               
  297. ;*                                                    
  298. ;*   WORD   Parameter length                          
  299. ;*   WORD   Flags                                      (target data buffer - LVB, PVB) 
  300. ;*   DWORD  Application data address  (source data buffer)  
  301. ;*   DWORD  Application data2 address (source attribue buffer)  
  302. ;*   WORD   Index (9)                                 
  303. ;*   WORD   Starting row                               (target row)   
  304. ;*   WORD   Starting column                            (target column)   
  305. ;*   WORD   Secondary row                              (not used in this call)  
  306. ;*   WORD   Secondary column                           (not used in this call)  
  307. ;*   WORD   RepeatFactor                               (input and output length)  
  308. ;*   WORD   LogicalBufSel                             
  309. ;*                                                    
  310. ;* OUTPUT:      PVB and/or LVB = new characters    
  311. ;*              RepeatFactor = sum of char/attr pairs written  
  312. ;*                                                    
  313. ;* EXIT-NORMAL: AX = 0                                
  314. ;*                                                    
  315. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr      
  316. ;*                                                    
  317. ;* EFFECTS:     AX, BX, DI, SI, DS, ES               
  318. ;*                                                    
  319. ;* INTERNAL REFERENCES: None                          
  320. ;*                                                    
  321. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in VDHREAD.ASM)  
  322. ;*                      MOVSW_STOSB, _MOVSW         
  323. ;*                                                   
  324. ;****************************************************************************/
  325.  
  326.         PUBLIC  WriteCharStrAttr
  327. WriteCharStrAttr        PROC                     NEAR
  328.  
  329.         sub     bx, bx                             ; Setup for byte read
  330.         call    LocateBuffAddr                     ; On exit: BX = sel, AX = off
  331.         .if     <nc>                               ; Continue?
  332.  
  333. ;/*
  334. ;**    On exit from LocateBuffAddr:                     
  335. ;**      If PVB & LVB flags are set then BX = LVB selector   
  336. ;**         [bp].PVB_Sel = PVB selector 
  337. ;**      else BX = LVB or PVB selector  
  338. ;**                                                      
  339. ;**    If both PVB and LVB are selected then the input chars/attr will 
  340. ;**    be written to the LVB first before the PVB is updated.  
  341. ;*/
  342.  
  343.             mov     es, bx                         ; Setup destination selector
  344.             mov     di, ax                         ; Setup destination offset
  345.             lds     si, [si].AppCellAddr           ; Setup address to attribute
  346.             lodsb                                  ; Get attribute
  347.             lds     si, [bp].ParmBuf               ; Setup parameter buffer addr
  348.             lds     si, [si].AppDataAddr           ; Setup source address
  349.             .if     <[bp].PVB_Sel a 0>             ; Write through request?
  350.                 push    cx                         ; Save repeat factor and
  351.                 push    es                         ;   LVB destination address
  352.                 push    di                         ; 
  353.             .endif                                 ; 
  354.             mov     bx, [bp].Retrace               ; Pass retrace indicator
  355.             call    MOVSB_STOSB                    ; Fill character/attribute
  356.             .if     <[bp].PVB_Sel a 0>             ; Write through request?
  357.                 pop     si                         ; Use LVB is now source
  358.                 pop     ds                         ; 
  359.                 pop     cx                         ; 
  360.                 mov     es, [bp].PVB_Sel           ; Setup PVB as destination
  361.                 mov     di, si                     ; 
  362.                 inc     bx                         ; Retrace wait required
  363.                 call    _MOVSW                     ; Copy cell from LVB to PVB
  364.             .endif                                 ; 
  365.             sub     ax, ax                         ; Clear return code
  366.         .endif                                     ; 
  367.         ret                                        ; 
  368.  
  369. WriteCharStrAttr        ENDP
  370.  
  371. ;/****************************************************************************
  372. ;*                                                    
  373. ;* SUBROUTINE NAME:     WriteNChar                   
  374. ;*                                                    
  375. ;* DESCRIPTIVE NAME:    Video device handler repeat characters  
  376. ;*                                                   
  377. ;* FUNCTION:    Process write character sub-function. 
  378. ;*              The characters are written to either PVB or LVB 
  379. ;*              starting at the specified row, column location. 
  380. ;*              Line wrap ocurrs if the end of a line is reached. 
  381. ;*              Write function is terminated if the end of PVB or 
  382. ;*              LVB is reached.  The number of characters written 
  383. ;*              is returned in the RepeatFacter field of the  
  384. ;*              parameter block.                     
  385. ;*                                                    
  386. ;* ENTRY POINT: WriteNChar                            
  387. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine   
  388. ;*                                                    
  389. ;* INPUT:                                             
  390. ;*                                                    
  391. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC) 
  392. ;* DS:SI  --->  Parameter block buffer            (see CGABUFUP.ASM) 
  393. ;* ES:DI  --->  Mode data in environment buffer (see CGABUFUP.ASM) 
  394. ;*                                                    
  395. ;* PARAMETER BLOCK FORMAT:                            
  396. ;*                                                    
  397. ;*   SIZE   DESCRIPTION                               
  398. ;*   ----   -----------                               
  399. ;*                                                    
  400. ;*   WORD   Parameter length                          
  401. ;*   WORD   Flags                                      (target data buffer - LVB, PVB) 
  402. ;*   DWORD  Application data address  (source character buffer)  
  403. ;*   DWORD  Application data2 address (not used in this call)  
  404. ;*   WORD   Index (10)                                
  405. ;*   WORD   Starting row                               (target row)   
  406. ;*   WORD   Starting column                            (target column)   
  407. ;*   WORD   Secondary row                              (not used in this call)  
  408. ;*   WORD   Secondary column                           (not used in this call)  
  409. ;*   WORD   RepeatFactor                               (input and output length)  
  410. ;*   WORD   LogicalBufSel                             
  411. ;*                                                    
  412. ;* OUTPUT:      PVB or LVB = new characters         
  413. ;*              RepeatFactor = number of characters written  
  414. ;*                                                    
  415. ;* EXIT-NORMAL: AX = 0                                
  416. ;*                                                    
  417. ;* EXIT-ERROR:  None                                  
  418. ;*                                                    
  419. ;* EFFECTS:     AX, BX, DI, SI, DS, ES               
  420. ;*                                                    
  421. ;* INTERNAL REFERENCES: None                          
  422. ;*                                                    
  423. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in VDHREAD.ASM)  
  424. ;*                      STOSB_SKIP_DI, _MOVSW       
  425. ;*                                                    
  426. ;****************************************************************************/
  427.  
  428.         PUBLIC  WriteNChar
  429. WriteNChar      PROC    NEAR
  430.  
  431.         sub     bx, bx                             ; Setup indicator for byte move
  432.         call    LocateBuffAddr                     ; On exit: BX = sel, AX = off
  433.         .if     <nc>                               ; Continue?
  434.  
  435. ;/*
  436. ;**    On exit from LocateBuffAddr:                     
  437. ;**      If PVB & LVB flags are set then BX = LVB selector   
  438. ;**         [bp].PVB_Sel = PVB selector 
  439. ;**      else BX = LVB or PVB selector  
  440. ;**                                                      
  441. ;**   If both PVB and LVB are selected then the input character will be
  442. ;**   repeatedly written to the LVB first before the PVB is updated.
  443. ;*/
  444.  
  445.             lds     si, [si].AppDataAddr           ; Setup source address
  446.             mov     es, bx                         ; Setup destination selector
  447.             mov     di, ax                         ; Setup destination offset
  448.             lodsb                                  ; Get source character
  449.             .if     <[bp].PVB_Sel a 0>             ; Write through request?
  450.                 push    cx                         ; Save repeat factor and
  451.                 push    di                         ;   destination offset
  452.                 sub     bx, bx                     ; Go to LVB first
  453.                 call    STOSB_SKIP_DI              ; Fill destination buffer
  454.                 mov     es, [bp].PVB_Sel           ; Setup PVB as destination
  455.                 pop     di                         ; ES:DI -> PVB
  456.                 pop     cx                         ; 
  457.                 inc     [bp].Retrace               ; Indicate retrace is required
  458.             .endif                                 ; 
  459.             mov     bx, [bp].Retrace               ; Pass retrace indicator
  460.             call    STOSB_SKIP_DI                  ; Copy char from AL to ES:DI
  461.             sub     ax, ax                         ; Clear return code
  462.         .endif                                     ; 
  463.         ret                                        ; 
  464.  
  465. WriteNChar      ENDP
  466.  
  467. ;/****************************************************************************
  468. ;*                                                    
  469. ;* SUBROUTINE NAME:     WriteNAttr                   
  470. ;*                                                    
  471. ;* DESCRIPTIVE NAME:    Video device handler repeat attributes  
  472. ;*                                                    
  473. ;* FUNCTION:    Process repeat write attributes sub-function.  
  474. ;*              The attributes are written to either PVB or LVB  
  475. ;*              starting at the specified row, column location.  
  476. ;*              Line wrap occurs if the end of a line is reached. 
  477. ;*              Write function is terminated if the end of PVB or 
  478. ;*              LVB is reached.  The number of the attributes  
  479. ;*              written is returned in the RepeatFactor field  
  480. ;*              of the paramter block.               
  481. ;*                                                    
  482. ;* ENTRY POINT: WriteNAttr                            
  483. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine   
  484. ;*                                                    
  485. ;* INPUT:                                             
  486. ;*                                                    
  487. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC) 
  488. ;* DS:SI  --->  Parameter block buffer            (see CGABUFUP.ASM) 
  489. ;* ES:DI  --->  Mode data in environment buffer (see CGABUFUP.ASM) 
  490. ;*                                                    
  491. ;* PARAMETER BLOCK FORMAT:                            
  492. ;*                                                    
  493. ;*   SIZE   DESCRIPTION                               
  494. ;*   ----   -----------                               
  495. ;*                                                    
  496. ;*   WORD   Parameter length                          
  497. ;*   WORD   Flags                                      (target data buffer - LVB, PVB) 
  498. ;*   DWORD  Application data address  (source attribute buffer)  
  499. ;*   DWORD  Application data2 address (not used in this call)  
  500. ;*   WORD   Index (11)                                
  501. ;*   WORD   Starting row                               (target row)   
  502. ;*   WORD   Starting column                            (target column)   
  503. ;*   WORD   Secondary row                              (not used in this call)  
  504. ;*   WORD   Secondary column                           (not used in this call)  
  505. ;*   WORD   RepeatFactor                               (input and output length)  
  506. ;*   WORD   LogicalBufSel                             
  507. ;*                                                    
  508. ;* OUTPUT:      LVB and/or PVB = new attributes    
  509. ;*              RepeatFactor = number of attributes written  
  510. ;*                                                    
  511. ;* EXIT-NORMAL: AX = 0                                
  512. ;*                                                    
  513. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr      
  514. ;*                                                    
  515. ;* EFFECTS:     All                                   
  516. ;*                                                    
  517. ;* INTERNAL REFERENCES: None                          
  518. ;*                                                    
  519. ;* EXTERNAL REFERENCES: LocateBuffAddr            (in VDHREAD.ASM)  
  520. ;*                      STOSB_SKIP_DI, _MOVSW       
  521. ;*                                                    
  522. ;****************************************************************************/
  523.  
  524.         PUBLIC  WriteNAttr
  525. WriteNAttr      PROC    NEAR
  526.  
  527.         sub     bx, bx                             ; Set indicator for byte move
  528.         call    LocateBuffAddr                     ; On exit: BX = sel, AX = off
  529.  
  530. ;/*
  531. ;**    On exit from LocateBuffAddr:                     
  532. ;**      If PVB & LVB flags are set then BX = LVB selector   
  533. ;**         [bp].PVB_Sel = PVB selector 
  534. ;**      else BX = LVB or PVB selector  
  535. ;**                                                      
  536. ;**   If both PVB and LVB are selected then the input attribute will be
  537. ;**   repeatedly written to the LVB first before the PVB is updated.
  538. ;*/
  539.  
  540.         .if     <nc>                               ; Continue?
  541.             lds     si, [si].AppDataAddr           ; Setup source address
  542.             mov     es, bx                         ; Setup destination selector
  543.             mov     di, ax                         ; Setup destination offset
  544.             lodsb                                  ; Get source attribute
  545.             .if     <[bp].PVB_Sel a 0>             ; Write through request?
  546.                 push    cx                         ; Save repeat factor and
  547.                 push    di                         ;   destination offset
  548.                 inc     di                         ; 
  549.                 sub     bx, bx                     ; Go to LVB first
  550.                 call    STOSB_SKIP_DI              ; Fill destination buffer
  551.                 mov     es, [bp].PVB_Sel           ; Setup PVB as destination
  552.                 pop     di                         ; ES:DI -> PVB
  553.                 pop     cx                         ; 
  554.                 inc     [bp].Retrace               ; Indicate retrace is required
  555.             .endif                                 ; 
  556.             inc     di                             ; 
  557.             mov     bx, [bp].Retrace               ; Pass retrace indicator
  558.             call    STOSB_SKIP_DI                  ; Copy attr from AL to ES:DI
  559.             sub     ax, ax                         ; Clear return code
  560.         .endif                                     ; 
  561.         ret
  562.  
  563. WriteNAttr      ENDP
  564.  
  565. ;/****************************************************************************
  566. ;*                                                    
  567. ;* SUBROUTINE NAME:     WriteNCell                   
  568. ;*                                                    
  569. ;* DESCRIPTIVE NAME:    Video device handler repeat cells  
  570. ;*                                                    
  571. ;* FUNCTION:    Process write cells sub-function.   
  572. ;*              The cells are written to either PVB or LVB  
  573. ;*              starting at the specified row, column location.  
  574. ;*              Line wrap ocurrs if the end of a line is reached. 
  575. ;*              Write function is terminated if the end of PVB  
  576. ;*              or LVB is reached.  The number of cells writte
  577. ;*              is returned in the RepeatFacter field of the  
  578. ;*              parameter block.                     
  579. ;*                                                    
  580. ;* ENTRY POINT: WriteNCell                            
  581. ;*   LINKAGE:   Near Call from BUFFERUPDATE routine   
  582. ;*                                                    
  583. ;* INPUT:                                             
  584. ;*                                                    
  585. ;* SS:BP  --->  Stack frame                        (see VDHSTRUC.INC) 
  586. ;* DS:SI  --->  Parameter block buffer            (see CGABUFUP.ASM) 
  587. ;* ES:DI  --->  Mode data in environment buffer (see CGABUFUP.ASM) 
  588. ;*                                                    
  589. ;* PARAMETER BLOCK FORMAT:                            
  590. ;*                                                    
  591. ;*   SIZE   DESCRIPTION                               
  592. ;*   ----   -----------                               
  593. ;*                                                    
  594. ;*   WORD   Parameter length                          
  595. ;*   WORD   Flags                                      (target data buffer - LVB, PVB) 
  596. ;*   DWORD  Application data address  (source cell buffer)  
  597. ;*   DWORD  Application data2 address (not used in this call)  
  598. ;*   WORD   Index (12)                                
  599. ;*   WORD   Starting row                               (target row)   
  600. ;*   WORD   Starting column                            (target column)   
  601. ;*   WORD   Secondary row                              (not used in this call)  
  602. ;*   WORD   Secondary column                           (not used in this call)  
  603. ;*   WORD   RepeatFactor                               (input and output length)  
  604. ;*   WORD   LogicalBufSel                             
  605. ;*                                                    
  606. ;* OUTPUT:      PVB or LVB = new characters         
  607. ;*              RepeatFactor = sum of char/attr pairs written  
  608. ;*                                                    
  609. ;* EXIT-NORMAL: AX = 0                                
  610. ;*                                                    
  611. ;* EXIT-ERROR:  AX = Error from LocateBuffAddr      
  612. ;*                                                    
  613. ;* EFFECTS:     AX, BX, DI, SI, DS, ES               
  614. ;*                                                    
  615. ;* INTERNAL REFERENCES: None                          
  616. ;*                                                    
  617. ;* EXTERNAL REFERENCES: LocateBuffAddr           (in VDHREAD.ASM)  
  618. ;*                      _STOSW, _MOVSW               
  619. ;*                                                    
  620. ;****************************************************************************/
  621.  
  622.         PUBLIC  WriteNCell
  623. WriteNCell      PROC    NEAR
  624.  
  625.         sub     bx, bx                             ; Set indicator for byte move
  626.         call    LocateBuffAddr                     ; On exit: BX = sel, AX = off
  627.         .if     <nc>                               ; Continue?
  628.  
  629. ;/*
  630. ;**    On exit from LocateBuffAddr:                     
  631. ;**      If PVB & LVB flags are set then BX = LVB selector   
  632. ;**         [bp].PVB_Sel = PVB selector 
  633. ;**      else BX = LVB or PVB selector  
  634. ;**                                                      
  635. ;**   If both PVB and LVB are selected then the input cell will be
  636. ;**   repeatedly written to the LVB first before the PVB is updated.
  637. ;*/
  638.  
  639.             lds     si, [si].AppDataAddr           ; Setup source address
  640.             mov     es, bx                         ; Setup destination selector
  641.             mov     di, ax                         ; Setup destination offset
  642.             lodsw                                  ; Get source character
  643.             .if     <[bp].PVB_Sel a 0>             ; Write through request?
  644.                 push    cx                         ; Save repeat factor and
  645.                 push    es                         ;   LVB destination address
  646.                 push    di                         ; 
  647.                 sub     bx, bx                     ; Go to LVB first
  648.                 call    _STOSW                     ; Fill destination buffer
  649.                 pop     si                         ; Use LVB is now source
  650.                 pop     ds                         ; 
  651.                 pop     cx                         ; 
  652.                 mov     es, [bp].PVB_Sel           ; Setup PVB as destination
  653.                 mov     di, si                     ; 
  654.                 inc     [bp].Retrace               ; Indicate retrace is required
  655.             .endif                                 ; 
  656.             mov     bx, [bp].Retrace               ; Pass retrace indicator
  657.             call    _STOSW                         ; Copy cell from LVB to PVB
  658.             sub     ax, ax                         ; Clear return code
  659.         .endif                                     ; 
  660.         ret                                        ; 
  661.  
  662. WriteNCell      ENDP
  663.  
  664. R2CSEG  ENDS
  665.         END
  666.