home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / PUTRC.ASM < prev    next >
Assembly Source File  |  1992-04-30  |  7KB  |  192 lines

  1.         page    ,132
  2.         title   Copyright (C) 1988 IBM Corp (Written 11/87 by Jim Christensen)
  3.         subttl  Byte Manipulation Routines
  4.         name    BYTES
  5.  
  6.  
  7.         .386
  8. _TEXT   SEGMENT  DWORD USE32 PUBLIC 'CODE'
  9. _TEXT      ENDS
  10. _DATA   SEGMENT  DWORD USE32 PUBLIC 'DATA'
  11. _DATA      ENDS
  12.         ASSUME   CS: FLAT, DS: FLAT, SS: FLAT, ES: FLAT
  13. _DATA   SEGMENT  DWORD USE32 PUBLIC 'DATA'
  14.         extrn    VideoPtr:dword  ;Pointer to logical video buffer
  15.         extrn    VideoMap:dword  ;Pointer to logical to physical attr vector
  16.         extrn    VideoCols:word  ;# of columns per screen row
  17.         extrn    VideoAtr:byte   ;default logical video attribute
  18.         align 4
  19. _DATA      ENDS
  20. EXTRN   Vio32ShowBuf:near
  21. PUBLIC  putrcx                  ; Fix No 400
  22. _TEXT   SEGMENT  DWORD USE32 PUBLIC 'CODE'
  23.  
  24. ;------------------------------------------------------------------------------;
  25. ; name          putrc -- Display at Row,Col
  26. ;
  27. ; synopsis      putrcx( row, col, string );
  28. ;
  29. ;               uint row;       /* row (0..N)                   */
  30. ;               uint col;       /* column (0..N)                */
  31. ;               uchar *string;  /* string of attributes and chars  */
  32. ;
  33. ; description   This routine puts a string at the specified row and column.
  34. ;               Bytes in the string are interpreted depending on their value:
  35. ;
  36. ;               0x00            End of string
  37. ;               0x01 .. 0x7F    Literal character
  38. ;               0x80 .. 0xFE    Logical display attribute (0x80 bit is turned
  39. ;                               off).  The value 0x80 is a special case, and
  40. ;                               uses the existing attributes on the screen.
  41. ;               0xFF            Repeat count byte follows this byte (0..254).
  42. ;                               The byte following the repeat count may be a
  43. ;                               a literal character or display attribute (the
  44. ;                               characters on the screen are not changed).
  45. ;                               A repeat count of 255 is a special case, and
  46. ;                               copies the following character to the display
  47. ;                               regardless of it's value (literal escape).
  48. ;
  49. ;              Note :: The filter through which putrcx gets called can't
  50. ;                      handle multiple rows at a time. So putrcx should
  51. ;                      be called seperately for displaying each row.
  52. ;
  53. ;* History:                                                                  *;
  54. ;*                                                                           *;
  55. ;*   02/08/91 Creation of 32-bit SD86, from 16-bit version.                  *;
  56. ;*                                                                           *;
  57. ;*...Release 1.00 (Pre-release 107 11/13/91)                                 *;
  58. ;*...                                                                        *;
  59. ;*... 11/13/91  400   Srinivas  Vertical Register Display.                   *;
  60. ;*...                                                                        *;
  61. ;-----------------------------------------------------------------------------;
  62.  
  63. EOT = 0
  64. TAB = 9
  65. ATR = 80h
  66. MAXLATR = 27                       ;max value for logical attribute
  67.  
  68. row    = 8
  69. col    = 12
  70. string = 16
  71.  
  72. putrcx  PROC NEAR                 ; Fix No 400
  73.         push    ebp
  74.         mov     ebp,esp
  75.         push    esi
  76.         push    edi
  77.         push    eax
  78.         push    ebx
  79.         push    ecx
  80.         pushfd
  81.         push    es                 ;save flat address
  82.         cld
  83.  
  84.         xor     edi, edi           ;clear working reg
  85.         xor     eax, eax           ;clear working reg
  86.         xor     ecx, ecx           ;clear working reg
  87.         les     di,  VideoPtr
  88.         mov     ax,  VideoCols     ;ax = # of cols per screen
  89.         mul     byte ptr [ebp+row]
  90.         add     ax,  [ebp+col]
  91.         shl     ax, 1
  92.         add     di, ax             ;es:di -> starting video (attr,char)
  93.         push    ax                 ;save starting video buffer offset
  94.         push    di                 ;save starting video buffer address
  95.  
  96.         mov     al,  VideoAtr      ;al = default video attribute
  97.         mov     ebx, VideoMap      ;ds:bx -> logical to physical attr map
  98.         xlat                       ;change al from logical to physical attr
  99.         mov     ah, al             ;ah = default hardware video attribute
  100.  
  101.         mov     esi, [ebp+string]  ;ds:si -> string
  102.         jmp     short rc30
  103. rc10:
  104.         or      al, ATR            ;assume graphics char
  105. rc20:
  106.         stosw
  107. rc30:
  108.         lodsb
  109.         test    al, ATR
  110.         jnz     rc40
  111.         cmp     al, EOT
  112.         jne     rc20
  113. rcxt:
  114.         pop     ax                 ;starting video buffer adddress
  115.         sub     di, ax             ;di = # of bytes changed
  116.         pop     ax                 ;starting screen buffer offset
  117.         pop     es                 ;restore flat address reg
  118.  
  119.         push    00                 ;3rd parm to Vio16ShowBuf
  120.         push    edi                ;2nd parm to Vio16ShowBuf
  121.         push    eax                ;1st parm to Vio16ShowBuf
  122.         call    Vio32ShowBuf
  123.  
  124.         add     esp,0Ch
  125.  
  126.         popfd
  127.         pop     ecx
  128.         pop     ebx
  129.         pop     eax
  130.         pop     edi
  131.         pop     esi
  132.         leave
  133.         ret
  134. rc40:
  135.         cmp     al, 0FFh
  136.         je      rc50               ;jump if repeat count
  137.         and     al, not ATR
  138.         jz      rc45               ;jump if zero (special case)
  139.         cmp     al, MAXLATR
  140.         ja      rc10               ;jump if too big for logical attr
  141.  
  142.         mov     ebx, VideoMap      ;ds:bx -> logical to physical attr map
  143.         xlat                       ;change al from logical to physical attr
  144.         mov     ah, al             ;ah = hardware video attribute
  145.         jmp     rc30
  146. rc45:
  147.         lodsb
  148.         test    al, ATR
  149.         jnz     rc40
  150.         cmp     al, EOT
  151.         je      rcxt
  152.         stosb                      ;change data char only
  153.         inc     di                 ;leave attribute unchanged
  154.         jmp     rc45
  155. rc50:
  156.         lodsb                      ;al = repeat count
  157.         cmp     al, 0FFh           ;if literal escape
  158.         je      rc80               ;then jump (special case)
  159.         mov     cl, al
  160.         xor     ch, ch
  161.         lodsb                      ;char to repeat
  162.         test    al, ATR
  163.         jnz     rc60
  164.         rep     stosw
  165.         jmp     rc30
  166. rc55:
  167.         or      al, ATR            ;assume graphics char
  168.         rep     stosw
  169.         jmp     rc30
  170. rc60:
  171.         and     al, not ATR
  172.         cmp     al, MAXLATR
  173.         ja      rc55               ;jump if too big for logical attr
  174.  
  175.         mov     ebx, VideoMap      ;ds:bx -> logical to physical attr map
  176.         xlat                       ;change al from logical to physical attr
  177.         jcxz    lpend
  178. rc70:
  179.         inc     di                 ;leave data char unchanged
  180.         stosb                      ;change attribute only
  181.         loop    rc70
  182. lpend:
  183.         jmp     rc30               ;loop on next char (default attr same)
  184. rc80:
  185.         lodsb                      ;al = literal character
  186.         jmp     rc20
  187.  
  188. putrcx  endp                       ; Fix No 400
  189.  
  190. _TEXT   ends
  191.         end
  192.