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

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