home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / source / devel5 / vdrinte.asm < prev    next >
Encoding:
Assembly Source File  |  1992-10-22  |  4.6 KB  |  223 lines

  1.  
  2.     TITLE    DRIVER - Interface to BIN loadable drivers.
  3.     NAME    VGALINE
  4.  
  5.     COMMENT    $
  6.  
  7.         Written and (c) by Dave Stampe 20/8/92
  8.         Not for commercial use, so get permission
  9.         before marketing code using this stuff!
  10.         For private PD use only.
  11.  
  12.  
  13.      ATTRIBUTION:  If you use any part of this source code or the libraries
  14.      in your projects, you must give attribution to REND386, Dave Stampe,
  15.      and Bernie Roehl in your documentation, source code, and at startup
  16.      of your program.  Let's keep the freeware ball rolling!
  17.  
  18.         This code supports both non-reentrant and
  19.         reentrant functions.  Only vsync(), set_vpage(),
  20.         and VGA_select() are reentrant (may be called from
  21.         an interrupt routine) and must be written in assembler
  22.         with .MODEL TINY FARSTACK or in C (tiny model, DS != SS) with
  23.         NO C LIBRARY CALLS.
  24.  
  25.         All other routines may be written in tiny C and use library calls.
  26.  
  27.         $
  28.  
  29.  
  30.  
  31.         .MODEL large
  32.         .CODE
  33.  
  34.         .386
  35.  
  36. public    _screen_data     ; the C callable stubs
  37. public    _vsync
  38. public    _setup_hdwe
  39. public    _reset_hdwe
  40. public    _clr_page
  41. public    _copy_page
  42. public    _copy_block
  43. public    _clr_block
  44. public    _fastpoly
  45. public    _m_fastpoly
  46. public    _set_gmode
  47. public    _set_drawpage
  48. public    _exit_gmode
  49. public    _set_vpage
  50. public    _clipline
  51. public    _set_clip_rect
  52. public    _printxyr
  53. public    _erase_cursor
  54. public    _draw_cursor
  55. public    _vgaline
  56. public    _vgapoint
  57. public    _load_DAC_colors
  58. public    _read_DAC_colors
  59. public    _VGA_select
  60. public    _vd_spare_1
  61. public    _vd_spare_2
  62. public    _vd_spare_3
  63. public    _vd_spare_4
  64. public    _vd_spare_5
  65. public    _vd_spare_6
  66. public    _vd_spare_7
  67. public    _vd_spare_8
  68.  
  69. _screen_data:
  70.     mov    ax,18
  71.     jmp    nonreentrant
  72. _vsync:
  73.     mov    ax,20
  74.     jmp    reentrant
  75. _setup_hdwe:
  76.     mov    ax,22
  77.     jmp    nonreentrant
  78. _reset_hdwe:
  79.     mov    ax,24
  80.     jmp    nonreentrant
  81. _clr_page:
  82.     mov    ax,26
  83.     jmp    nonreentrant
  84. _copy_page:
  85.     mov    ax,28
  86.     jmp    nonreentrant
  87. _clr_block:
  88.     mov    ax,30
  89.     jmp    nonreentrant
  90. _copy_block:
  91.     mov    ax,32
  92.     jmp    nonreentrant
  93. _fastpoly:
  94.     mov    ax,34
  95.     jmp    nonreentrant
  96. _m_fastpoly:
  97.     mov    ax,36
  98.     jmp    nonreentrant
  99. _set_gmode:
  100.     mov    ax,38
  101.     jmp    nonreentrant
  102. _exit_gmode:
  103.     mov    ax,40
  104.     jmp    nonreentrant
  105. _set_drawpage:
  106.     mov    ax,42
  107.     jmp    nonreentrant
  108. _set_vpage:
  109.     mov    ax,44
  110.     jmp    reentrant
  111. _vgaline:
  112.     mov    ax,46
  113.     jmp    nonreentrant
  114. _vgapoint:
  115.     mov    ax,48
  116.     jmp    nonreentrant
  117. _set_clip_rect:
  118.     mov    ax,50
  119.     jmp    nonreentrant
  120. _clipline:
  121.     mov    ax,52
  122.     jmp    nonreentrant
  123. _printxyr:
  124.     mov    ax,54
  125.     jmp    nonreentrant
  126. _draw_cursor:
  127.     mov    ax,56
  128.     jmp    nonreentrant
  129. _erase_cursor:
  130.     mov    ax,58
  131.     jmp    nonreentrant
  132. _load_DAC_colors:
  133.     mov    ax,60
  134.     jmp    nonreentrant
  135. _read_DAC_colors:
  136.     mov    ax,62
  137.     jmp    nonreentrant
  138. _VGA_select:
  139.     mov    ax,64
  140.     jmp    reentrant
  141. _vd_spare_1:
  142.     mov    ax,66
  143.     jmp    nonreentrant
  144. _vd_spare_2:
  145.     mov    ax,68
  146.     jmp    nonreentrant
  147. _vd_spare_3:
  148.     mov    ax,70
  149.     jmp    nonreentrant
  150. _vd_spare_4:
  151.     mov    ax,72
  152.     jmp    nonreentrant
  153. _vd_spare_5:
  154.     mov    ax,74
  155.     jmp    nonreentrant
  156. _vd_spare_6:
  157.     mov    ax,76
  158.     jmp    nonreentrant
  159. _vd_spare_7:
  160.     mov    ax,78
  161.     jmp    nonreentrant
  162. _vd_spare_8:
  163.     mov    ax,80
  164.     jmp    nonreentrant
  165.  
  166. extrn _v_driver_pointer
  167.  
  168. nonreentrant:
  169.     push    bp
  170.     push    ds
  171.     mov      bp,sp
  172.     mov      dx,ss                  ; save stack seg
  173.     mov      es,dx
  174.     lds   bx,DWORD PTR _v_driver_pointer  ; get routine address
  175.     push    ds                     ; new stack seg
  176.     pop      ss                     ; all int's disabled till next instr..
  177.     mov      sp,2000                ; stack internal to driver
  178.     push    dx                     ; push old stack seg (bp=old stack ptr)
  179.     push    DWORD PTR es:[bp+24]   ; up to 20 bytes of arguments
  180.     push    DWORD PTR es:[bp+20]   ; copy adds 1 uS, but needed
  181.     push    DWORD PTR es:[bp+16]   ; to keep ints from crashing
  182.     push    DWORD PTR es:[bp+12]
  183.     push    DWORD PTR es:[bp+8]
  184.     push    cs                            ; push default return
  185.     push    offset nrtnh
  186.     push    ds
  187.     add   bx,ax                           ; push as call address
  188.     push    ds:[bx]
  189.     retf                                ; "call"
  190.  
  191. nrtnh:
  192.     add    sp,20
  193.     pop    ss                              ; restore stack
  194.     mov    sp,bp
  195.     pop    ds
  196.     pop    bp
  197.     retf                                ; exit
  198.  
  199. reentrant:
  200.     push    bp
  201.     push    ds
  202.     mov    bp,sp
  203.     push    DWORD PTR ss:[bp+24]   ; up to 20 bytes of arguments
  204.     push    DWORD PTR ss:[bp+20]   ; copy adds 1 uS, but needed
  205.     push    DWORD PTR ss:[bp+16]   ; to keep ints from crashing
  206.     push    DWORD PTR ss:[bp+12]
  207.     push    DWORD PTR ss:[bp+8]
  208.     push    cs                              ; push default return
  209.     push    offset rtnh
  210.     lds    bx,DWORD PTR _v_driver_pointer  ; get routine address
  211.     push    ds
  212.     add    bx,ax                           ; push as call address
  213.     push    ds:[bx]
  214.     retf                                    ; "call"
  215.  
  216. rtnh:    mov    sp,bp
  217.     pop    ds
  218.     pop    bp
  219.     retf                                    ; exit
  220.  
  221.  
  222.     end
  223.