home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / cbgi111 / src / lib / d_putpix.asm < prev    next >
Encoding:
Assembly Source File  |  1990-06-15  |  2.4 KB  |  108 lines

  1. ideal            ; Set up in ideal mode
  2. model    tiny        ; This is done in tiny model
  3.  
  4. ;******************* _dispatch_putpix ************************************
  5. ;  Interfaces BGI driver code to the calling interface.  Save old DS and 
  6. ;     sets up a new one for the driver to use.  Restores the old DS and
  7. ;     does a far return on exit.  It passes and returns the parameters in
  8. ;     the conventional 'C' fashion.  This makes it much easier to write
  9. ;     the main driver in C and let the compiler optimize to its hearts 
  10. ;     content.  The function is prefixed with an underscore so that the
  11. ;     main driver can place it into a structure using C in a transparent
  12. ;     fashion.
  13. ;
  14. ;        INPUT:    ax    -- X coordinate of the pixel.
  15. ;            bx    -- Y coordinate of the pixel.
  16. ;            dl    -- colour to set pixel to.
  17. ;
  18. ;        OUTPUT:    none
  19. ;
  20. ;    V 1.00 25/06/89  Robert Adsett.
  21. ;    V 1.01 15/06/90  Robert Adsett.  Eliminate DOSSEG ordering.
  22. ;
  23. ;  (C) Robert Adsett 1989,1990
  24. ;*************************************************************************
  25.  
  26. codeseg            ; Start of the code segment
  27.  
  28. ;*************************************************************************
  29. ;    Declare publics and externals.
  30. ;*************************************************************************
  31.  
  32. extrn    _putpix        : near        ;external function, does actual 
  33.                     ;  work.
  34. extrn    STACK_SEG    :word
  35. extrn    STACK_PTR    :word
  36. extrn    regbx        :word
  37. extrn    regdx        :word
  38. extrn    regsi        :word
  39. extrn    regdi        :word
  40. extrn   _stack_        :word
  41.  
  42. public    _dispatch_putpix        ;make this routine public so it
  43.                     ;  can be hooked.
  44.  
  45.  
  46. proc _dispatch_putpix  far
  47.  
  48.     push    ds            ;save old ds
  49.     push    cs
  50.     pop    ds            ;new ds = cs
  51.  
  52.     mov    [regbx],bx
  53.     mov    [regdx],dx
  54.     mov    [regsi],si
  55.     mov    [regdi],di
  56.  
  57.     mov    dx,ds
  58.  
  59.         mov    di,ss
  60.         mov    si,sp
  61.     mov    [STACK_SEG],di
  62.     mov    [STACK_PTR],si
  63.  
  64.     mov    bx, offset DGROUP:_stack_
  65.  
  66. ;    Set the program stack
  67.  
  68.     cli            ;Borland does not do this
  69.     
  70.     mov    ss, dx
  71.                       ; Problem due to small RAM size.
  72.     mov    sp, bx        ; Stack goes here.
  73.  
  74.     sti
  75.  
  76.     mov    bx,[regbx]
  77.     mov    dx,[regdx]
  78.     mov    si,[regsi]
  79.     mov    di,[regdi]
  80. ;;;;
  81.  
  82.     xor    dh,dh            ;don't let garbage in dh interfere
  83.     push    dx            ;colour
  84.     push    bx            ;Y coordinate
  85.     push    ax            ;X coordinate
  86.     call    _putpix            ;call 'C' driver
  87.     add    sp,6            ;restore stack
  88. ;;;;
  89.     mov    si,[STACK_SEG]
  90.     mov    di,[STACK_PTR]
  91.  
  92.     cli
  93.     mov    ss,si
  94.     mov    sp,di
  95.     sti
  96.  
  97.     pop    ds            ;restore ds
  98.     ret                ;return to caller
  99.  
  100. endp
  101.  
  102. ends
  103. end
  104.  
  105.  
  106.  
  107. 
  108.