home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / egagraph.zip / PLOT.ASM < prev    next >
Assembly Source File  |  1987-07-23  |  3KB  |  99 lines

  1. ; PLOT.ASM    EGA point plotting routine (mode 2)
  2.  
  3. ; PROCEDURE Plot(x,y,Color : INTEGER);
  4.  
  5. ; This routine is designed to be called from Turbo Pascal.
  6. ; It has been tested on both EGA and 640x480 modes on the
  7. ; Video 7 graphics board. This routine draws at about 84,000
  8. ; pixels per second on a 10 mhz, 1 wait state, 286 machine.
  9. ; If you find a way to make it faster, let me know.
  10.  
  11. ; James Billmeyer
  12. ; Soft-Touch Computer Systems
  13. ; 7716 Balboa Blvd., Unit D
  14. ; Van Nuys, Ca. 91406
  15. ; (818) 781-4400
  16.  
  17. ; LINE.ASM   EGA line drawing routine
  18.  
  19. ; This routine is designed to be called from Turbo Pascal.
  20. ; It has been tested on both EGA and 640x480 modes on the
  21. ; Video 7 graphics board. If you find a way to make it faster,
  22. ; let me know.
  23.  
  24. ; James Billmeyer
  25. ; Soft-Touch Computer Systems
  26. ; 7716 Balboa Blvd., Unit D
  27. ; Van Nuys, Ca. 91406
  28. ; (818) 781-4400
  29.  
  30. cseg      segment  byte          ; start of code segment
  31.           assume   cs:cseg
  32.  
  33. Plot      proc     near
  34.           int      1
  35.           push     bp            ; save bp register
  36.           mov      bp,sp         ; get top of stack
  37.           mov      dx,0A000h     ; ds := EGA buffer segment address
  38.           mov      es,dx
  39.           mov      ax,[bp+6]     ; address := (y * 80) + (x / 8)
  40.           mov      dx,80
  41.           mul      dx
  42.           mov      cx,3
  43.           mov      di,[bp+8]
  44.           shr      di,cl
  45.           add      di,ax
  46.           mov      cx,[bp+8]     ; mask := 1 shl (7 - x mod 8)
  47.           and      cl,7
  48.           xor      cl,7
  49.           mov      ch,1
  50.           shl      ch,cl
  51.           mov      bl,ch
  52.  
  53. ; Select Write Mode 2
  54.  
  55.           mov      dx,3CEh       ; select mode register
  56.           mov      ax,5
  57.           out      dx,al
  58.           mov      dx,3CFh       ; set to write mode 2
  59.           mov      ax,2
  60.           out      dx,al
  61.  
  62. ; Set Bit Mask Register
  63.  
  64.           mov      dx,3CEh       ; select register 8
  65.           mov      ax,8
  66.           out      dx,al
  67.           mov      dx,3CFh       ; output bit mask to register 8
  68.           mov      al,bl
  69.           out      dx,al
  70.  
  71. ; Latch all four bit planes
  72.  
  73.           mov      al,es:[di]    ; latches all four bit planes
  74.  
  75. ; Write Pixel
  76.  
  77.           mov      ax,[bp+4]     ; get color
  78.           mov      es:[di],al
  79.  
  80. ; Restore defualt EGA graphics status
  81.  
  82.           mov      dx,3CEh
  83.           mov      ax,5
  84.           out      dx,al
  85.           mov      dx,3CFh
  86.           mov      ax,0
  87.           out      dx,al
  88.           mov      dx,3CEh
  89.           mov      ax,8
  90.           out      dx,al
  91.           mov      dx,3CFh
  92.           mov      ax,0FFh
  93.           out      dx,al
  94.           pop      bp
  95.           ret      6
  96. plot      endp
  97. cseg      ends
  98.           end
  99.