home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / comm / ykh121.zip / YKHSRC.ZIP / TXTLIB.ASM < prev    next >
Assembly Source File  |  1992-11-15  |  7KB  |  461 lines

  1. ;       3C4h index  2  (r/W): Sequencer: Map Mask Register
  2. ;         bit 0  Enable writes to plane 0 if set
  3. ;             1  Enable writes to plane 1 if set
  4. ;             2  Enable writes to plane 2 if set
  5. ;             3  Enable writes to plane 3 if set
  6. ;
  7. ;       3CEh index  4  (r/W): Graphics: Read Map Select Register
  8. ;       bit 0-1  Number of the plane read Mode 0 will read from.
  9.  
  10. .286c
  11.  
  12. INT_10H MACRO
  13.   PUSH BP
  14.   INT 10H
  15.   POP BP
  16. ENDM
  17.  
  18. INT_10HP MACRO
  19.   PUSH AX
  20.   PUSH BX
  21.   PUSH CX
  22.   PUSH DX
  23.   PUSH BP
  24.   PUSH DS
  25.   PUSH ES
  26.   PUSH SI
  27.   PUSH DI
  28.   INT 10H
  29.   POP DI
  30.   POP SI
  31.   POP ES
  32.   POP DS
  33.   POP BP
  34.   POP DX
  35.   POP CX
  36.   POP BX
  37.   POP AX
  38. ENDM
  39.  
  40.  
  41. VIDEOSEG EQU 0B800H
  42.  
  43. TXTLIB_TEXT    segment byte public 'CODE'
  44. TXTLIB_TEXT    ends
  45. DGROUP    group    _DATA,_BSS
  46.     assume    cs:TXTLIB_TEXT,ds:DGROUP
  47. _DATA    segment word public 'DATA'
  48. _DATA    ends
  49. _BSS    segment word public 'BSS'
  50. _BSS    ends
  51. TXTLIB_TEXT    segment byte public 'CODE'
  52.    ;
  53.  
  54. oldmode db ?
  55.  
  56. ;
  57. ;int far TXT_deinit();
  58. ;
  59. _txt_deinit proc far
  60.             mov ax,3
  61.             int 10h
  62.  
  63.             mov dx,3d4h
  64.             mov ax,000ah
  65.             out dx,ax
  66.  
  67. ;       3d4h index  Ah (r/W): CRTC: Cursor Start Register
  68. ;       bit 0-4  First scanline of cursor within character.
  69. ;             5  (VGA) Turns Cursor off if set
  70.  
  71.             xor ax,ax
  72.  
  73.             ret
  74. _txt_deinit endp
  75.  
  76.  
  77.  
  78. ;
  79. ;int far TXT_init(unsigned scanlines,unsigned fg,unsigned bg,char far* filename);
  80. ;
  81. _txt_init proc far
  82.           push bp
  83.           mov bp,sp
  84.  
  85.           mov ax,3
  86.           int 10h
  87.  
  88.           mov dx,3d4h
  89.           mov ax,100ah
  90.           out dx,ax
  91.  
  92. ;       3d4h index  Ah (r/W): CRTC: Cursor Start Register
  93. ;       bit 0-4  First scanline of cursor within character.
  94. ;             5  (VGA) Turns Cursor off if set
  95.  
  96.           xor ax,ax
  97.  
  98.           pop bp
  99.           ret
  100. _txt_init endp
  101.  
  102.  
  103. ;
  104. ; void far TXT_put(unsigned TXT,unsigned scanline, unsigned column)
  105. ;
  106. _txt_put proc far
  107.          push bp
  108.          mov bp,sp
  109.  
  110.          push es
  111.          push di
  112.  
  113.          mov ax,VIDEOSEG
  114.          mov es,ax
  115.  
  116.          mov ax,160
  117.          mul word ptr [bp+8]
  118.          add ax,[bp+10]
  119.          add ax,[bp+10]
  120.          mov di,ax
  121.  
  122.          mov al,'X'       ;AL = TXT character code
  123.          mov ah,30h
  124.          stosw
  125.          stosw
  126.  
  127.          pop di
  128.          pop es
  129.  
  130.          pop bp
  131.          ret
  132. _txt_put endp
  133.  
  134.  
  135. ;
  136. ; void far ascii_put(unsigned ascii,unsigned scanline, unsigned column)
  137. ;
  138. _txt_ascii_put proc far
  139.          push bp
  140.          mov bp,sp
  141.  
  142.          push es
  143.          push di
  144.  
  145.          mov ax,VIDEOSEG
  146.          mov es,ax
  147.  
  148.          mov ax,160
  149.          mul word ptr [bp+8]
  150.          add ax,[bp+10]
  151.          add ax,[bp+10]
  152.          mov di,ax
  153.  
  154.          mov ax,[bp+6]     ;AL = ascii character code
  155.          mov ah,15
  156.          stosw
  157.  
  158.          pop di
  159.          pop es
  160.  
  161.          pop bp
  162.          ret
  163. _txt_ascii_put endp
  164.  
  165.  
  166. ;
  167. ; void far TXT_clear(unsigned scanline, unsigned column,
  168. ;                    unsigned scanlines, unsigned columns);
  169. ;
  170. _txt_clear proc far
  171.            push bp
  172.            mov bp,sp
  173.  
  174.            push es
  175.            push di
  176.  
  177.            mov ax,VIDEOSEG
  178.            mov es,ax
  179.  
  180.            mov ax,160
  181.            mul word ptr [bp+6]
  182.            add ax,[bp+8]
  183.            add ax,[bp+8]
  184.            mov di,ax
  185.  
  186.            mov dx,[bp+12]
  187.  
  188.            xor bx,bx
  189.            sub bx,dx
  190.            sub bx,dx
  191.            add bx,160
  192.  
  193.            xor ax,ax
  194.  
  195. @@clr:       mov cx,dx
  196. rep        stosw
  197.            add di,bx
  198.            dec word ptr [bp+10]
  199.            jnz @@clr
  200.  
  201.            pop di
  202.            pop es
  203.  
  204.            pop bp
  205.            ret
  206. _txt_clear endp
  207.  
  208.  
  209. ;
  210. ; void far TXT_set(unsigned scanline, unsigned column,
  211. ;                  unsigned scanlines, unsigned columns);
  212. ;
  213. _txt_set proc far
  214.          push bp
  215.          mov bp,sp
  216.  
  217.          push es
  218.          push di
  219.  
  220.          mov ax,VIDEOSEG
  221.          mov es,ax
  222.  
  223.          mov ax,160
  224.          mul word ptr [bp+6]
  225.          add ax,[bp+8]
  226.          add ax,[bp+8]
  227.          mov di,ax
  228.  
  229.          mov dx,[bp+12]
  230.  
  231.          xor bx,bx
  232.          sub bx,dx
  233.          sub bx,dx
  234.          add bx,160
  235.  
  236.          mov ax,7fffh
  237.  
  238.          jmp @@clr
  239.          ;
  240.          ; NO RET
  241.          ;
  242. _txt_set endp
  243.  
  244.  
  245. ;
  246. ; void far TXT_xor(unsigned scanline, unsigned column,
  247. ;                  unsigned scanlines, unsigned columns);
  248. ;
  249. _txt_xor proc far
  250. @@xorfoo:
  251.          push bp
  252.          mov bp,sp
  253.  
  254.          push es
  255.          push di
  256.  
  257.          mov ax,VIDEOSEG
  258.          mov es,ax
  259.  
  260.          mov ax,160
  261.          mul word ptr [bp+6]
  262.          add ax,[bp+8]
  263.          add ax,[bp+8]
  264.          mov di,ax
  265.  
  266.          mov dx,[bp+12]
  267.  
  268.          xor bx,bx
  269.          sub bx,dx
  270.          sub bx,dx
  271.          add bx,160
  272.  
  273. @@clx:     mov cx,dx
  274. @@cly:   xor byte ptr es:[di+1],7fh
  275.          add di,2
  276.          loop @@cly
  277.  
  278.          add di,bx
  279.          dec word ptr [bp+10]
  280.          jnz @@clx
  281.  
  282.          pop di
  283.          pop es
  284.  
  285.          pop bp
  286.          ret
  287. _txt_xor endp
  288.  
  289.  
  290. ;
  291. ; void far TXT_gray(unsigned scanline, unsigned column,
  292. ;                   unsigned scanlines, unsigned columns);
  293. ;
  294. _txt_gray proc far
  295.          jmp @@xorfoo
  296.          ret
  297. _txt_gray endp
  298.  
  299.  
  300. ;
  301. ; void far TXT_bold8(unsigned scanline, unsigned column,
  302. ;                    unsigned scanlines, unsigned columns);
  303. ;
  304. _txt_bold8 proc far
  305.          jmp @@xorfoo
  306.          ret
  307. _txt_bold8 endp
  308.  
  309.  
  310. ;
  311. ; void far TXT_underline(unsigned scanline, unsigned column,
  312. ;                        unsigned scanlines, unsigned columns);
  313. ;
  314. _txt_underline proc far
  315.          jmp @@xorfoo
  316.          ret
  317. _txt_underline endp
  318.  
  319.  
  320. ;
  321. ; void far TXT_fcopy(unsigned srcy,   unsigned srcx,
  322. ;                    unsigned desty,  unsigned destx,
  323. ;                    unsigned height, unsigned width  );
  324. ;
  325. _txt_fcopy proc far
  326.          push bp
  327.          mov bp,sp
  328.  
  329.          push ds  ;save data and extra segments
  330.          push si  ;
  331.          push es  ;
  332.          push di  ;
  333.  
  334.          mov si,VIDEOSEG ;set up segments for video transfer
  335.          mov es,si       ;
  336.          mov ds,si       ;
  337.  
  338.          mov ax,160
  339.          mul word ptr [bp+6]
  340.          add ax,[bp+8]
  341.          add ax,[bp+8]
  342.          mov si,ax
  343.  
  344.          mov ax,160
  345.          mul word ptr [bp+10]
  346.          add ax,[bp+12]
  347.          add ax,[bp+12]
  348.          mov di,ax
  349.  
  350.          mov dx,[bp+16]
  351.  
  352.          mov bx,80
  353.          sub bx,dx
  354.          shl bx,1
  355.  
  356.          cld
  357. @@cop1:  mov cx,dx
  358. rep      movsw
  359.  
  360.          add si,bx
  361.          add di,bx
  362.          dec word ptr [bp+14]
  363.          jnz @@cop1
  364.  
  365. @@copend:
  366.          pop di
  367.          pop es
  368.          pop si
  369.          pop ds
  370.          pop bp
  371.          ret
  372. _txt_fcopy endp
  373.  
  374.  
  375. ;
  376. ; void far TXT_bcopy(unsigned srcy,   unsigned srcx,
  377. ;                    unsigned desty,  unsigned destx,
  378. ;                    unsigned height, unsigned width  );
  379. ;
  380. _txt_bcopy proc far
  381.          push bp
  382.          mov bp,sp
  383.  
  384.          push ds  ;save data and extra segments
  385.          push si  ;
  386.          push es  ;
  387.          push di  ;
  388.  
  389.          mov di,VIDEOSEG ;set up segments for video transfer
  390.          mov es,di       ;
  391.          mov ds,di       ;
  392.  
  393.          mov ax,160
  394.          mul word ptr [bp+6]
  395.          add ax,[bp+8]
  396.          add ax,[bp+8]
  397.          mov si,ax
  398.  
  399.          mov ax,160
  400.          mul word ptr [bp+10]
  401.          add ax,[bp+12]
  402.          add ax,[bp+12]
  403.          mov di,ax
  404.  
  405.          mov ax,160
  406.          mul word ptr [bp+14]
  407.          sub ax,160
  408.          add ax,[bp+16]
  409.          add ax,[bp+16]
  410.          dec ax
  411.          dec ax
  412.  
  413.          add si,ax
  414.          add di,ax
  415.  
  416.          mov dx,[bp+16]
  417.  
  418.          mov bx,80
  419.          sub bx,dx
  420.          shl bx,1
  421.  
  422.          std
  423. @@bcop1: mov cx,dx
  424. rep         movsw
  425.  
  426.          sub si,bx
  427.          sub di,bx
  428.          dec word ptr [bp+14]
  429.          jnz @@bcop1
  430.  
  431.          cld
  432.          pop di
  433.          pop es
  434.          pop si
  435.          pop ds
  436.          pop bp
  437.          ret
  438. _txt_bcopy endp
  439.  
  440.  
  441.  
  442.    ;
  443. TXTLIB_TEXT    ends
  444.  
  445.     public    _txt_init
  446.     public    _txt_deinit
  447.     public  _txt_put
  448.     public  _txt_ascii_put
  449.     public  _txt_clear
  450.     public  _txt_set
  451.     public  _txt_xor
  452.     public  _txt_gray
  453.     public  _txt_bold8
  454.     public  _txt_underline
  455.     public  _txt_fcopy
  456.     public  _txt_bcopy
  457.     end
  458.  
  459.  
  460.  
  461.