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

  1. ideal            ; Set up in ideal mode
  2. model    tiny        ; This is done in tiny model
  3.  
  4. ;******************* _dispatch_getpix ************************************
  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. ;
  17. ;        OUTPUT:    dl    -- Colour of the pixel.  Returned in ax
  18. ;                     by '_getpix'.
  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    _getpix        : 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_getpix        ;make this routine public so it
  43.                     ;  can be hooked.
  44.  
  45.  
  46. proc _dispatch_getpix  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.     push    bx            ;Y coordinate
  83.     push    ax            ;X coordinate
  84.     call    _getpix            ;call 'C' driver
  85.     add    sp,4            ;restore stack
  86. ;;;;
  87.     mov    si,[STACK_SEG]
  88.     mov    di,[STACK_PTR]
  89.  
  90.     cli
  91.     mov    ss,si
  92.     mov    sp,di
  93.     sti
  94.  
  95.     pop    ds            ;restore ds
  96.     mov    dl,al            ;move return value to appropriate
  97.                     ; register
  98.     ret                ;return to caller
  99.  
  100. endp
  101.  
  102. ends
  103. end
  104.  
  105.  
  106. 
  107.