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

  1. ideal            ; Set up in ideal mode
  2. model    tiny        ; This is done in tiny model
  3.  
  4. ;************* _dispatch_set_write_mode **********************************
  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 the mode parameter 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. ;        INPUT:    ax    -- write mode to use 1 xor, 0 normal.
  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    _set_write_mode    : 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_set_write_mode    ;make this routine public so it
  41.                     ;  can be hooked.
  42.  
  43.  
  44. proc _dispatch_set_write_mode  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.     push    ax            ;mode
  81.     call    _set_write_mode        ;call 'C' driver
  82.     add    sp,2            ;restore stack
  83. ;;;;
  84.     mov    si,[STACK_SEG]
  85.     mov    di,[STACK_PTR]
  86.  
  87.     cli
  88.     mov    ss,si
  89.     mov    sp,di
  90.     sti
  91.  
  92.     pop    ds            ;restore ds
  93.     ret                ;return to caller
  94.  
  95. endp
  96.  
  97. ends
  98. end
  99. 
  100.