home *** CD-ROM | disk | FTP | other *** search
/ MS DOS Archives 1 / MS-DOS_Archives_Volume_One_Walnut_Creek.iso / msdos / graphics / grafxlib.arc / EGAGRAFA.ASM < prev    next >
Assembly Source File  |  1987-08-31  |  3KB  |  173 lines

  1. ;
  2. ; grafix --- egagrafa.asm
  3. ;
  4. ; stuff to plot points fast in 8086 assembler (BLEECH!!!)
  5. ;
  6. ; Written 4/87 by Scott Snyder (ssnyder@romeo.caltech.edu or @citromeo.bitnet)
  7. ;
  8. ; Modified 5/29/87 by sss to allow for different memory models
  9. ;
  10.  
  11.     title    egagrafa
  12.  
  13. include macros.ah
  14.  
  15.     df EGA_point
  16.     df EGA_write_pix
  17.     df EGA_plot
  18.  
  19. sseg
  20. endss
  21.  
  22. g_linsiz  equ    80
  23. g_pixbyte equ    8
  24. ega_gr_data equ 03cfh
  25.  
  26. dseg
  27.  
  28.     ex g_drawbuf,     dword
  29.     ex g_xor,         word
  30.     ex g_xcliplo,     word
  31.     ex g_xcliphi,     word
  32.     ex g_ycliplo,     word
  33.     ex g_ycliphi,     word
  34.  
  35. endds
  36.  
  37.     exProc EGA_point_set
  38.     exProc EGA_point_res
  39.  
  40. cseg    _egagrafa
  41.  
  42. EGA_plot label byte            ; to get accurate profiling data
  43.  
  44. ; plot a point. ax = y; bl = c; cx = x;
  45.  
  46. pBegin    plot
  47.  
  48.     les    si, g_drawbuf        ; get address of buffer
  49.     mov    dx, g_linsiz        ; y * g_linsiz
  50.     mul    dx
  51.     add    si, ax            ; add to offset
  52.     mov    ax, cx            ; x to AC (ohhh... what symmetry!)
  53.     mov    cx, g_pixbyte        ; move it to use it...
  54.     div    cx
  55.     add    si, ax            ; add quotient to offset (now complete)
  56.     mov    al, 80h            ; make mask
  57.     mov    cx, dx
  58.     shr    ax, cl            ; shift it
  59.     mov    dx, ega_gr_data        ; shove it out to the mask register
  60.     out    dx, al
  61.     mov    al, es:[si]        ; read data into latches
  62.     mov    es:[si], al        ; and do a write
  63.     ret
  64.  
  65. pEnd    plot
  66.  
  67. ;
  68. ; C interface for point plotter
  69. ;
  70. ; EGA_point(x, y, c)
  71. ;
  72.  
  73. pBegin    EGA_point
  74.  
  75.     push    bp
  76.     mov    bp, sp
  77.     push    si
  78.     push    di
  79.  
  80.     push    [bp+argbase+4]            ; call setup routine
  81.     call    EGA_point_set
  82.     add    sp, 2
  83.  
  84.     mov    ax, [bp+argbase+2]
  85.     mov    bx, [bp+argbase+4]
  86.     mov    cx, [bp+argbase]
  87.     call    plot
  88.  
  89.     call    EGA_point_res        ; reset EGA
  90.  
  91.     pop    di
  92.     pop    si
  93.     mov    sp, bp
  94.     pop    bp
  95.     ret
  96.  
  97. pEnd    EGA_point
  98.  
  99. ;
  100. ; write for pixels for circle drawing
  101. ;
  102. ; void EGA_write_pix(x1, y1, x2, y2, c)
  103. ;
  104. ; can just ignore color here 'cause that's all setup at setup time...
  105. ;
  106.  
  107. pBegin    EGA_write_pix
  108.  
  109.     push    bp
  110.     mov    bp, sp
  111.     push    si
  112.     push    di
  113.  
  114.     mov    cx, [bp+argbase]    ; cx = x1
  115.     cmp    cx, g_xcliplo        ; check for clipping
  116.     jb    w2
  117.     cmp    cx, g_xcliphi
  118.     ja    w2
  119.  
  120.     mov    ax, [bp+argbase+2]    ; ax = y1
  121.     cmp    ax, g_ycliplo        ; do clipping
  122.     jb    w1
  123.     cmp    ax, g_ycliphi
  124.     ja    w1
  125.  
  126.     push    cx            ; plot (x1, y1)
  127.     call    plot
  128.     pop    cx
  129.  
  130. w1:    mov    ax, [bp+argbase+6]    ; ax = y2
  131.     cmp    ax, g_ycliplo
  132.     jb    w2
  133.     cmp    ax, g_ycliphi
  134.     ja    w2
  135.  
  136.     call    plot            ; plot (x1, y2)
  137.  
  138. w2:    mov    cx, [bp+argbase+4]    ; cx = x2
  139.     cmp    cx, g_xcliplo
  140.     jb    w4
  141.     cmp    cx, g_xcliphi
  142.     ja    w4
  143.  
  144.     mov    ax, [bp+argbase+2]    ; ax = y1
  145.     cmp    ax, g_ycliplo        ; do clipping
  146.     jb    w3
  147.     cmp    ax, g_ycliphi
  148.     ja    w3
  149.  
  150.     push    cx            ; plot (x2, y1)
  151.     call    plot
  152.     pop    cx
  153.  
  154. w3:    mov    ax, [bp+argbase+6]    ; ax = y2
  155.     cmp    ax, g_ycliplo
  156.     jb    w4
  157.     cmp    ax, g_ycliphi
  158.     ja    w4
  159.  
  160.     call    plot            ; plot (x2, y2)
  161.  
  162. w4:    pop    di
  163.     pop    si
  164.     mov    sp, bp
  165.     pop    bp
  166.     ret
  167.  
  168. pEnd    EGA_write_pix
  169.  
  170. endcs    _egagrafa
  171.  
  172. end
  173.