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

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