home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB140 / grlib03a.arj / GTEXT.ASM < prev    next >
Assembly Source File  |  1988-12-08  |  6KB  |  273 lines

  1. PAGE ,132
  2. TITLE GTEXT.ASM
  3. ;UPDATE HISTORY
  4. ;==============
  5. ;15 nov 84    Convert to C86 V2.2
  6. ;21-dec-84    fix some things
  7.  
  8.     include    asmc.h
  9.  
  10.     SEGEND    CODE
  11.  
  12.     SEGDEF    DATA
  13.  
  14.     include asmd.h
  15.  
  16. Lj    DW    Lshsw, Lshdw, Ldhsw, Ldhdw
  17.  
  18.     SEGEND    DATA
  19.  
  20.     SEGDEF    CODE
  21.  
  22. PUBLIC    gtext, gchar
  23.  
  24.     IF    @bigmodel
  25. EXTRN    gdc_nb:FAR, chk_col:FAR, a_mode:FAR, a_gbmsk:FAR, a_cur:FAR
  26. EXTRN    fifo_mt:FAR, cxy2cp:FAR
  27.     ELSE
  28. EXTRN    gdc_nb:NEAR, chk_col:NEAR, a_mode:NEAR, a_gbmsk:NEAR, a_cur:NEAR
  29. EXTRN    fifo_mt:NEAR, cxy2cp:NEAR
  30.     ENDIF
  31.  
  32.  
  33. ;************************************************************************
  34. ;*                                    *
  35. ;*      F U N C T I O N    gtext(x, y, string)                *
  36. ;*               int x, y, style;                *
  37. ;*                                    *
  38. ;*      purpose:        print a string of text at a specific 'xy'       *
  39. ;*            position. X & Y are defined as pixel locations  *
  40. ;*            at the bottom left of the character cell.       *
  41. ;*                                    *
  42. ;*    entry:          6[bp] 'x' position                *
  43. ;*              8[bp] 'y' position                *
  44. ;*             10[bp] pointer to NULL terminated string       *
  45. ;*                                    *
  46. ;************************************************************************
  47.  
  48.     PROCDEF    gtext
  49.     push    si
  50.     push    bp
  51.     mov     bp,sp
  52.  
  53.     mov     ax,6[bp]                ;get 'x' position
  54.     mov     WORD PTR t_x,ax        ;and save.
  55.     mov     ax,8[bp]                ;get 'y' position
  56.     mov     WORD PTR t_y,ax        ;and save.
  57.  
  58.     call    gdc_nb
  59.     mov     al,BYTE PTR t_col
  60.     call    chk_col
  61.     mov     si,10[bp]               ;point to start of string
  62.     cld                             ;make sure we inc 'si'.
  63.     test    BYTE PTR gbmod,2
  64.     jz      Lt0                     ;jump if already in text mode else
  65.     and     BYTE PTR gbmod,0FDH    ;assert text mode.
  66.     call    a_mode
  67. Lt0:    lodsb
  68.     or      al,al                   ;check for the end of string.
  69.     jz      Lt1                     ;quit if it is.
  70.     push    ax
  71.     call    gchar
  72.     add     sp,2
  73.     jmp     Lt0
  74.  
  75. Lt1:    pop     bp
  76.     pop     si
  77.     ret
  78.     PROCEND    gtext
  79.  
  80. ;************************************************************************
  81. ;*                                    *
  82. ;*      f u n c t i o n   gchar(char)                    *
  83. ;*                                    *
  84. ;*  purpose:    write graphics text                    *
  85. ;*  entry:    8[bp] character to be written                *
  86. ;*                                    *
  87. ;*  conditions: 1) text cursor is correctly placed            *
  88. ;*        2) fgbg and alups already defined            *
  89. ;*        3) text font has been selected                *
  90. ;*        4) text scale (t_sca) has been set            *
  91. ;*           t_sca will determine the style to be used to    display *
  92. ;*           the character:                    *
  93. ;*            0 = single height, single width            *
  94. ;*            1 = single height, double width            *
  95. ;*            2 = double height, single width            *
  96. ;*            3 = double height, double width            *
  97. ;************************************************************************
  98.  
  99.     PROCDEF    gchar
  100.     push    di
  101.     push    si
  102.     push    bp
  103.     mov     bp,sp
  104.  
  105.     mov    ax,cs:eseg_sav        ;just in case.
  106.     mov    es,ax
  107. ;adjust co-ordinates in t_x & t_y.
  108.     mov     ax,WORD PTR t_x         ;get column number
  109.     and     ax,0FFF0H
  110.     mov    WORD PTR x_start,ax
  111.     mov     ax,WORD PTR ymax
  112.     sub     ax,WORD PTR t_y      ;t_y specified as bot_left of ch cell.
  113.     mov    bx,9
  114.     cmp    BYTE PTR t_sca,2
  115.     js    L0
  116.     add    bx,10
  117. L0:    sub     ax,bx                ;move 'y' to top left of character cell.
  118.     jns     L1
  119.     xor     ax,ax
  120. L1:    mov    WORD PTR y_start,ax
  121.  
  122.     mov     ax, 8[bp]
  123.     xor    ah,ah
  124.     shl     ax,1
  125.     mov     bx,ax                   ;bx = al * 2
  126.     shl     ax,1
  127.     shl     ax,1                    ;ax = al * 8
  128.     add     bx,ax                   ;bx = al * 10
  129.     lea     si, tfonts        ;point to start of font table
  130.     mov     al,BYTE PTR t_font    ;get font type
  131.     xor    ah,ah
  132.     shl    ax,1            ;make it a word offset
  133.     add    si,ax            ;and get the address of the font area
  134.     mov    si,WORD PTR [si]
  135.     add     si,bx            ;si now points to the character in the
  136.     lea    di,gp_buff        ;font area
  137.     test    BYTE PTR t_sca, 1
  138.     jz    L1a
  139.     mov    WORD PTR gbmskl,0000H
  140.     jmp    L1c
  141. L1a:    test    WORD PTR t_x,8
  142.     jnz     L1b
  143.     mov     WORD PTR gbmskl,000FFH
  144.     jmp     L1c
  145. L1b:    mov     WORD PTR gbmskl,0FF00H
  146. L1c:    cld
  147.     mov    al, BYTE PTR t_sca
  148.     and    al,03H
  149.     shl    al,1
  150.     xor    ah,ah
  151.     lea    bx,WORD PTR Lj
  152.     add    bx,ax
  153.     mov    cx,10        ;number of scan lines
  154.     call    [bx]
  155.  
  156. ;output the bytes at gp_buff via the character ram.
  157.  
  158.     call    gdc_nb
  159.     call    a_gbmsk        ;assert the graf board mask
  160.     call    cxy2cp        ;assert the xy drawing position.
  161.  
  162.     add    WORD PTR t_x,8
  163.     test    BYTE PTR t_sca,1
  164.     jz    L1d
  165.     add    WORD PTR t_x,8
  166. L1d:
  167.     lea    si,gp_buff
  168.     cmp    BYTE PTR t_sca,2
  169.     jns    Lgta
  170.     mov    bx,20
  171.     jmp    Lgtb
  172. Lgta:    mov    bx,40
  173. Lgtb:    mov    dl,0
  174. Lgt1:    mov    cx,16        ;always 16 bytes first time round.
  175. Lgt2:    call    gdc_nb
  176.     mov    al,0FEH         ;reset the char ram counter.
  177.     out    53H,al
  178.     out    51H,al
  179.     push    cx
  180. Lgt3:    lodsb            ;load CX number of bytes
  181.     out    52H,al
  182.     loop    Lgt3
  183.     mov    al,0FEH         ;reset the char ram counter.
  184.     out    53H,al
  185.     out    51H,al
  186.  
  187.     mov    al,4CH          ;assert the figs command.
  188.     out    57H,al
  189.     xor     al,al           ;assert the down directinon to write.
  190.     out    56H,al
  191.     pop    ax        ;find the number of word writes - 1
  192.     shr    ax,1
  193.     dec    ax
  194.     out    56H,al
  195.     mov    al,ah
  196.     out    56H,al
  197.     mov    al,22H            ;assert the wdat command.
  198.     out    57H,al
  199.     mov    al,0FFH
  200.     out    56H,al
  201.     out    56H,al
  202.  
  203.     or    dl,dl
  204.     jnz    Lgt4
  205.     sub    bx,16
  206.     cmp    bx,16
  207.     jns    Lgt1
  208.     mov    cx,bx
  209.     mov    dl,1
  210.     jmp    Lgt2
  211.  
  212. Lgt4:    pop     bp
  213.     pop     si
  214.     pop    di
  215.     ret
  216.  
  217. ;The following 4 routines do the bit and byte shuffles with
  218. ;the resulting bytes to output at gp_buff.
  219.  
  220. Lshsw:    lodsb
  221.     mov    ah,al
  222.     stosw
  223.     loop    Lshsw
  224.     ret
  225.  
  226. Lshdw:    push    cx
  227.     mov    cx,8
  228.     lodsb
  229.     xor    dx,dx
  230. Lshdw1:    shr    dx,1
  231.     shr    dx,1
  232.     shr    al,1
  233.     jnc    Lshdw2
  234.     or    dx,0C000H
  235. Lshdw2:    loop    Lshdw1
  236.     mov    ax,dx
  237.     xchg    ah,al
  238.     stosw
  239.     pop    cx
  240.     loop    Lshdw
  241.     ret
  242.  
  243. Ldhsw:    lodsb
  244.     mov    ah,al
  245.     stosw
  246.     stosw
  247.     loop    Ldhsw
  248.     ret
  249.  
  250. Ldhdw:    push    cx
  251.     mov    cx,8
  252.     lodsb
  253.     xor    dx,dx
  254. Ldhdw1:    shr    dx,1
  255.     shr    dx,1
  256.     shr    al,1
  257.     jnc    Ldhdw2
  258.     or    dx,0C000H
  259. Ldhdw2:    loop    Ldhdw1
  260.     mov    ax,dx
  261.     xchg    ah,al
  262.     stosw
  263.     stosw
  264.     pop    cx
  265.     loop    Ldhdw
  266.     ret
  267.  
  268.     PROCEND    gchar
  269.  
  270.     include    epilogue.h
  271.     END
  272. 
  273.