home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 318_01 / redouta.asm < prev    next >
Assembly Source File  |  1990-06-18  |  5KB  |  336 lines

  1. ;    Screen output routines for RED text editor.
  2. ;
  3. ;    Assemble this file with Microsoft MASM.
  4. ;
  5. ;    Source:     redouta.c
  6. ;    Started: 12/21/89
  7. ;    Version: 1/18/90
  8. ;
  9.  
  10. ;
  11. ; External variables
  12. ;
  13.     EXTRN    _outx:word
  14.     EXTRN    _outy:word
  15.  
  16. _TEXT    segment    byte public 'CODE'
  17.  
  18. DGROUP    group    _DATA
  19.     assume ds:DGROUP
  20. _TEXT    ends
  21.  
  22. _DATA    segment word public 'DATA'
  23. d@    label    byte
  24. d@w    label    word
  25. _DATA    ends
  26.  
  27. ;
  28. ; Character constants
  29. ;
  30. space        equ 20h        ;ascii space
  31. normal        equ 07h        ;normal video attribute
  32.  
  33. ;
  34. ; Screen constants
  35. ;
  36. maxcol        equ 80        ;columns per line on CRT
  37. maxcol1        equ 79        ;maxcol - 1
  38. maxrow        equ 25        ;rows on CRT
  39. maxrow1        equ 24        ;maxrow - 1
  40.  
  41. _TEXT    SEGMENT    BYTE PUBLIC 'CODE'
  42.         ASSUME cs:_TEXT
  43.  
  44. ;
  45. ;    Output one printable character to the screen.
  46. ;
  47.         PUBLIC _outchar
  48.  
  49. IFDEF NEAR
  50. _outchar    proc near
  51. ELSE
  52. _outchar    proc far
  53. ENDIF
  54.  
  55.     push    bp
  56.     mov    bp,sp
  57.     push    di
  58.     push    si
  59.  
  60.     mov    ah,14        ;write character as TTY
  61.  
  62. IFDEF NEAR
  63.     mov    al,[bp+4]
  64. ELSE
  65.     mov    al,[bp+6]
  66. ENDIF
  67.  
  68.     int    10h
  69.  
  70.     mov    al,byte ptr DGROUP:_outx    ;increment outx
  71.     add    al,1
  72.     mov    byte ptr DGROUP:_outx,al
  73.  
  74.     pop    si
  75.     pop    di
  76.     pop    bp
  77.     ret
  78.  
  79. _outchar    ENDP
  80.  
  81. ;
  82. ;    Clear the screen.
  83. ;
  84.         PUBLIC _outclr
  85.  
  86. IFDEF NEAR
  87. _outclr        proc near
  88. ELSE
  89. _outclr        proc far
  90. ENDIF
  91.  
  92.     push    di
  93.     push    si
  94.  
  95.     mov    ah,15        ;get video mode
  96.     int    10h
  97.  
  98.     cmp    al,3        ;already mode 3?
  99.     je    outclr1        ;yes -->
  100.  
  101. outclr1:
  102.     mov    ah,0        ;set video mode (Bios also clears the screen)
  103.     mov    al,3        ;mode 3 (High res, 80x25, CGA)
  104.     int    10h
  105.     jmp    outclr2        ;-->
  106.  
  107. ;
  108. ; Already in mode 3.  Clear the screen by scrolling it.
  109. ;
  110.     
  111.     mov    ah,6        ;scroll window up
  112.     mov    al,maxrow    ;line count
  113.     mov    bh,normal    ;display attribute, not page
  114.     mov    ch,0        ;top row
  115.     mov    cl,0        ;left column
  116.     mov    dh,maxrow1    ;bottom row
  117.     mov    dl,maxcol1    ;right column
  118.     int    10h
  119.  
  120. outclr2:
  121.     mov    ah,5        ;set display page
  122.     mov    al,0        ;set page 0
  123.     int    10h
  124.  
  125.     pop    si
  126.     pop    di
  127.     ret
  128.  
  129. _outclr        ENDP
  130.  
  131. ;
  132. ;    Delete the line on which the cursor rests.
  133. ;    Leave the cursor at the left margin.
  134. ;
  135.         PUBLIC _outdelln
  136.  
  137. IFDEF NEAR
  138. _outdelln    proc near
  139. ELSE
  140. _outdelln    proc far
  141. ENDIF
  142.  
  143.     push    di
  144.     push    si
  145.  
  146.     mov    ah,3        ;read cursor position
  147.     mov    bh,0        ;page number
  148.     int    10h        ;row number is in dh for set cursor position
  149.  
  150.     mov    ah,2        ;set cursor position
  151.     mov    bh,0        ;page number
  152.     mov    dl,0        ;set x = column number
  153.     int    10h
  154.  
  155.     mov    ah,9        ;write character and attribute
  156.     mov    bh,0        ;page number
  157.     mov    al,space    ;ascii space
  158.     mov    bl,normal    ;attribute
  159.     mov    cx,maxcol1    ;repeat count
  160.     int     10h
  161.  
  162.     pop    si
  163.     pop    di
  164.     ret
  165.  
  166. _outdelln    ENDP
  167.  
  168. ;
  169. ;    Delete to end of line.
  170. ;    Assume the last column is blank.
  171. ;
  172.         PUBLIC _outdeol
  173.  
  174. IFDEF NEAR
  175. _outdeol    proc near
  176. ELSE
  177. _outdeol    proc far
  178. ENDIF
  179.  
  180.     push    di
  181.     push    si
  182.  
  183.     mov    ah,3        ;read cursor position
  184.     mov    bh,0        ;page number
  185.     int    10h        ;put column number in dl
  186.  
  187.     mov    ah,9        ;write character and attribute
  188.     mov    bh,0        ;page number
  189.     mov    al,space    ;ascii space
  190.     mov    bl,normal    ;attribute
  191.     xor    cx,cx        ;repeat count in cx
  192.     mov    cl,maxcol
  193.     sub    cl,dl
  194.     int     10h
  195.  
  196.     pop    si
  197.     pop    di
  198.     ret
  199.  
  200. _outdeol    ENDP
  201.  
  202. ;
  203. ;    Hardware delete line.
  204. ;
  205.         PUBLIC _outdel
  206.  
  207. IFDEF NEAR
  208. _outdel        proc near
  209. ELSE
  210. _outdel        proc far
  211. ENDIF
  212.  
  213.     push    di
  214.     push    si
  215.  
  216.     mov    ah,3        ;read cursor position
  217.     mov    bh,0        ;page number
  218.     int    10h        ;put row number in dh
  219.  
  220.     mov    ah,6        ;scroll window up
  221.     mov    al,1        ;line count
  222.     mov    bh,normal    ;display attribute, not page
  223.     mov    ch,dh        ;top row
  224.     mov    cl,0        ;left column
  225.     mov    dh,maxrow1    ;bottom row
  226.     mov    dl,maxcol1    ;right column
  227.     int    10h
  228.     
  229.     pop    si
  230.     pop    di
  231.     ret
  232.  
  233. _outdel        ENDP
  234.  
  235. ;
  236. ;    Hardware insert line.  Leave cursor alone.
  237. ;
  238.         PUBLIC _outins
  239.  
  240. IFDEF NEAR
  241. _outins        proc near
  242. ELSE
  243. _outins        proc far
  244. ENDIF
  245.  
  246.     push    di
  247.     push    si
  248.  
  249.     mov    ah,3        ;read cursor position
  250.     mov    bh,0        ;page number
  251.     int    10h        ;put row number in dh
  252.  
  253.     mov    ah,7        ;scroll window down
  254.     mov    al,1        ;line count
  255.     mov    bh,normal    ;display attribute, not page
  256.     mov    ch,dh        ;top row
  257.     mov    cl,0        ;left column
  258.     mov    dh,maxrow1    ;bottom row
  259.     mov    dl,maxcol1    ;right column
  260.     int    10h
  261.  
  262.     pop    si
  263.     pop    di
  264.     ret
  265.  
  266. _outins        ENDP
  267.  
  268. ;
  269. ; Scrolling routines are not used
  270. ;
  271.         PUBLIC _outsdn
  272.  
  273. IFDEF NEAR
  274. _outsdn        proc near
  275. ELSE
  276. _outsdn        proc far
  277. ENDIF
  278.         ret        ;not used
  279.  
  280. _outsdn        ENDP
  281.  
  282.         PUBLIC _outsup
  283.  
  284. IFDEF NEAR
  285. _outsup        proc near
  286. ELSE
  287. _outsup        proc far
  288. ENDIF
  289.  
  290.         ret        ;not used
  291.  
  292. _outsup        ENDP
  293.  
  294. ;
  295. ;    Put cursor at row,column.   0,0 is top of screen.
  296. ;
  297.         PUBLIC _outxy
  298.  
  299. IFDEF NEAR
  300. _outxy        proc near
  301. ELSE
  302. _outxy        proc far
  303. ENDIF
  304.  
  305.     push    bp
  306.     mov    bp,sp
  307.     push    di
  308.     push    si
  309.  
  310.     mov    ah,2        ;set cursor position
  311.     mov    bh,0        ;page number
  312.  
  313. IFDEF NEAR
  314.     mov    dl,[bp+4]            ;set x = column number
  315.     mov    byte ptr DGROUP:_outx,dl    ;set global outx
  316.     mov    dh,[bp+6]            ;set y = row number
  317. ELSE
  318.     mov    dl,[bp+6]            ;set x = column number
  319.     mov    byte ptr DGROUP:_outx,dl    ;set global outx
  320.     mov    dh,[bp+8]            ;set y = row number
  321. ENDIF
  322.  
  323.     mov    byte ptr DGROUP:_outy,dh    ;set global outy
  324.     int    10h
  325.  
  326.     pop    si
  327.     pop    di
  328.     pop    bp
  329.     ret
  330.  
  331. _outxy        ENDP
  332.  
  333. _TEXT    ENDS
  334.  
  335.         END
  336.