home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / PUTUP.ASM < prev    next >
Assembly Source File  |  1992-09-17  |  11KB  |  300 lines

  1.         page    64,120
  2.         title   Video Interface Routine
  3.         subttl  Copyright (C) 1988 by IBM (J.E.Christensen)
  4.         name    PUTUP
  5.  
  6.         .386
  7. _TEXT   SEGMENT  DWORD USE32 PUBLIC 'CODE'
  8. _TEXT      ENDS
  9. _DATA   SEGMENT  DWORD USE32 PUBLIC 'DATA'
  10. _DATA      ENDS
  11.         ASSUME   CS: FLAT, DS: FLAT, SS: FLAT, ES: FLAT
  12. _DATA   SEGMENT  DWORD USE32 PUBLIC 'DATA'
  13.         extrn    VideoPtr:dword  ;Pointer to logical video buffer
  14.         extrn    VideoMap:dword  ;Pointer to logical to physical attr vector
  15.         extrn    BoundPtr:dword  ;Pointer to screen bounds.                 400
  16.         extrn    VideoCols:word  ;# of columns per screen row
  17.         align 4
  18. _DATA      ENDS
  19. EXTRN   Vio32ShowBuf:near
  20. PUBLIC  putup
  21. PUBLIC  putxb
  22. _TEXT   SEGMENT  DWORD USE32 PUBLIC 'CODE'
  23.  
  24. LOWZONE         equ 010h
  25. HIGHZONE        equ 0A0h
  26.  
  27. ;------------------------------------------------------------------------------;
  28. ; name          putup -- Format Screen
  29. ;
  30. ; synopsis      putup( buffer, ptrs, top, nlines, column, attrs );
  31. ;
  32. ;               char   *buffer;   /* buffer of ASCIIZ strings             */
  33. ;               ushort ptrs[];    /* vector of buffer offsets             */
  34. ;               uint   top;       /* 1st line of screen to use (0..N)     */
  35. ;               uint   nlines;    /* # of lines to show                   */
  36. ;               uint   column;    /* # of chars to skip each line         */
  37. ;               uchar  attrs[];   /* vector of line logical attributes    */
  38. ;
  39. ; description   This routine formats the display screen with text.
  40. ;
  41. ;*...Release 1.00 (Pre-release 107 11/13/91)                                 *;
  42. ;*...                                                                        *;
  43. ;*... 11/13/91  400   Srinivas  Vertical Register Display.                   *;
  44. ;*...                                                                        *;
  45. ;-----------------------------------------------------------------------------;
  46.  
  47. buffer = 8
  48. ptrs   = 12
  49. top    = 16
  50. nlines = 20
  51. column = 24
  52. attrs  = 28
  53.  
  54. putup   PROC NEAR
  55.         push    ebp
  56.         mov     ebp,esp
  57.         push    esi
  58.         push    edi
  59.         push    edx
  60.         push    ecx
  61.         push    ebx
  62.         push    eax
  63.         pushfd
  64.         push    es                 ;save flat address
  65.         cld
  66.  
  67.                                         ;fix it up.
  68. pu10:
  69.         xor     edi, edi           ;clear working reg
  70.         xor     eax, eax           ;clear working reg
  71.         xor     edx, edx           ;clear working reg
  72.         xor     ecx, ecx           ;clear working reg
  73.         les     di,  VideoPtr
  74.         mov     ax,  VideoCols     ;ax = # of cols per screen
  75.         mul     byte ptr [ebp+top]
  76.         shl     ax,  1
  77.         add     di,  ax             ;es:di -> starting video (attr,char)
  78.         push    ax                 ;save starting video buffer offset
  79.         push    di                 ;save starting video buffer address
  80. pu20:
  81.         mov     esi, [ebp+ptrs]           ;ds:si -> offset vector
  82.         lodsw                           ;ax = next element of offset vector
  83.         mov     [ebp+ptrs], esi         ;update pointer
  84.         xchg    eax,  edx                  ;dx = buffer offset to next line
  85.  
  86.         mov     esi, [ebp+attrs]          ;ds:si -> attribute vector
  87.         lodsb                           ;al = next element of attribute vector
  88.         mov     [ebp+attrs], esi         ;update pointer
  89.  
  90.         mov     ebx, BoundPtr         ;pointer to screen bounds           400
  91.         add     ebx, [ebp+top]        ;position to correct line           400
  92.         mov     cl, byte ptr [ebx]    ;cx = # of cols to be painted       400
  93.         push    cx                    ;save the # of cols                 400
  94.  
  95.         mov     ebx, VideoMap         ;ds:bx -> logical to physical attr map
  96.         xlat                            ;change al from logical to physical attr
  97.         mov     ah,  al                  ;ah = harware video attribute
  98.  
  99.         mov     esi, [ebp+buffer]         ;ds:si -> start of text buffer
  100.         add     esi, edx                  ;ds:si -> start of next line
  101.  
  102.         mov     bx, [ebp+column]         ;bx = starting test column
  103.  
  104.         cmp     cx,0                    ;if number of cols to write is 0  701
  105.         jz      skipit                  ;then don't bother to call.
  106.  
  107.         call    putone                  ;put one line up on the display
  108. skipit:
  109.         xor     ebx, ebx                ;clear working reg                400
  110.         pop     bx                      ;restore the # of cols            400
  111.         mov     ax,  VideoCols          ;ax = # of cols per screen        400
  112.         sub     ax,bx                   ;calculate the diff in bytes      400
  113.         shl     ax,1                    ;double the number                400
  114.         add     di,ax                   ;adjust the di                    400
  115.         inc     byte ptr [ebp+top]      ;increment the top line           400
  116.  
  117.         dec     byte ptr [ebp+nlines]              ;if more lines to go
  118.         jnz     pu20                    ;then loop on next line
  119.  
  120.         pop     ax                      ;starting video buffer adddress
  121.         sub     di, ax                  ;di = # of bytes changed
  122.         pop     ax                      ;starting screen buffer offset
  123.         pop     es                 ;restore flat address reg
  124.  
  125.         push    00                 ;3rd parm to Vio32ShowBuf
  126.         push    edi                ;2nd parm to Vio32ShowBuf
  127.         push    eax                ;1st parm to Vio32ShowBuf
  128.         call    Vio32ShowBuf
  129.         add     esp,0Ch
  130.  
  131.         popfd
  132.         pop     eax
  133.         pop     ebx
  134.         pop     ecx
  135.         pop     edx
  136.         pop     edi
  137.         pop     esi
  138.         leave
  139.         ret
  140. putup   endp
  141.  
  142. ;Input  ds:si -> start of text line
  143. ;       es:di -> start of video line
  144. ;       ah =  hardware video attribute
  145. ;       bx =  # of text chars to skip
  146. ;       cx =  video line length
  147.  
  148. putone          proc near
  149.         xor     dx, dx                  ;current text column
  150.         jmp     short PREcmp
  151. PRErep:
  152.         sub     al, HIGHZONE
  153.         add     dl, al
  154.         adc     dh, 00
  155.         lodsb
  156.         cmp     dx, bx
  157.         jb      PREnxt
  158.  
  159.         sub     dx, bx
  160.         sub     cx, dx
  161.         jbe     PUTful
  162.         xchg    cx, dx
  163.         rep     stosw
  164.         xchg    cx, dx
  165.         jmp     short PUT1st
  166. PREnxt:
  167.         lodsb
  168.         cmp     al, LOWZONE
  169.         jb      PUTend
  170.         cmp     al, HIGHZONE
  171.         jae     PRErep
  172.         inc     dx
  173. PREcmp:
  174.         cmp     dx, bx
  175.         jb      PREnxt
  176. PUT1st:
  177.         xor     dx, dx
  178. PUTnxt:
  179.         lodsb
  180.         cmp     al, LOWZONE
  181.         jb      PUTend
  182.         cmp     al, HIGHZONE
  183.         jae     PUTrep
  184.         stosw
  185.         loop    PUTnxt
  186.         ret
  187. PUTend:
  188.         mov     al, ' '
  189.         rep     stosw
  190.         ret
  191. PUTrep:
  192.         sub     al, HIGHZONE
  193.         mov     dl, al
  194.         lodsb
  195.         sub     cx, dx
  196.         jbe     PUTful
  197.  
  198.         xchg    cx, dx
  199.         rep     stosw
  200.         xchg    cx, dx
  201.         jmp     PUTnxt
  202. PUTful:
  203.         add     cx, dx
  204.         rep     stosw
  205.         ret
  206. putone          endp
  207.  
  208. ;------------------------------------------------------------------------------;
  209. ; name          putxb -- Translate Screen Blanks
  210. ;
  211. ; synopsis      putxb( line, repchr );
  212. ;
  213. ;               uint line;      /* line number to xlate (0..N)          */
  214. ;               char repchr;    /* replacement character for blanks     */
  215. ;
  216. ; description   This routine translates all blanks on the specified line
  217. ;               on the screen to another character.
  218. ;
  219. ;*...Release 1.00 (Pre-release 107 11/13/91)                                 *;
  220. ;*...                                                                        *;
  221. ;*... 11/13/91  400   Srinivas  Vertical Register Display.                   *;
  222. ;*...                                                                        *;
  223. ;------------------------------------------------------------------------------;
  224.  
  225. line   = 8
  226. repchr = 12
  227.  
  228. putxb   PROC NEAR
  229.         push    ebp
  230.         mov     ebp,esp
  231.         push    edi
  232.         push    eax
  233.         push    ebx
  234.         push    ecx
  235.         push    ds                 ;save flat address
  236.         push    es                 ;save flat address
  237.  
  238.         xor     edi, edi           ;clear working reg
  239.         xor     eax, eax           ;clear working reg
  240.         xor     ecx, ecx           ;clear working reg
  241.         xor     ebx, ebx           ;clear working reg                     400
  242.         mov     cx, VideoCols
  243.         mov     ax, [ebp+line]
  244.         mul     cl
  245.         shl     ax, 1
  246.  
  247.         mov     ebx, BoundPtr         ;pointer to screen bounds           400
  248.         add     ebx, [ebp+line]       ;position to correct line           400
  249.         mov     cl, byte ptr [ebx]    ;cx = # of cols to be painted       400
  250.         push    cx                    ;save the # of cols                 400
  251.  
  252.         push    ax                      ;save starting video buffer offset
  253.         lds     di, VideoPtr
  254.         add     di, ax
  255.         mov     ax, ds
  256.         mov     es, ax
  257.         mov     ax, [ebp+repchr]
  258.         jmp     short xb20
  259. xb10:
  260.         inc     di                      ;skip char
  261.         inc     di                      ;skip attr
  262. xb20:
  263.         cmp     byte ptr [di], 20h      ;if not a blank char
  264.         loopne  xb10                    ;then loop on next char
  265.         jcxz    xb40                    ;jump if last char on line
  266. xb30:
  267.         stosb                           ;xlate blank to repchr
  268.         inc     di                      ;skip attr
  269.         cmp     byte ptr [di], 20h
  270.         loope   xb30
  271.         jcxz    xb40                    ;jump if last char on line
  272.         jmp     xb10
  273. xb40:
  274.         jne     xb50                    ;jump if last char on line not blank
  275.         stosb
  276. xb50:
  277.         pop     ax                      ;starting video buffer adddress
  278.         pop     cx                      ;# of cols per video line
  279.         shl     cx, 1
  280.         pop     es                 ;restore flat address reg
  281.         pop     ds                 ;restore flat address reg
  282.  
  283.         push    00                 ;3rd parm to Vio32ShowBuf
  284.         push    ecx                ;2nd parm to Vio32ShowBuf
  285.         push    eax                ;1st parm to Vio32ShowBuf
  286.         call    Vio32ShowBuf
  287.         add     esp,0Ch
  288.  
  289.         pop     ecx
  290.         pop     ebx
  291.         pop     eax
  292.         pop     edi
  293.         leave
  294.         ret
  295. putxb   endp
  296.  
  297. _TEXT   ends
  298.         end
  299.  
  300.