home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 238_01 / plottype.asm < prev    next >
Assembly Source File  |  1987-07-28  |  8KB  |  346 lines

  1.         TITLE   PLOTTYPE of GDS
  2.         page    60,132
  3.         .SFCOND
  4. ;
  5. ; *==========================================================*
  6. ; * This file contains the lowest level routine in writing   *
  7. ; * and accessing the frame memory. And some other related   *
  8. ; * routines. Don't write or read the frame memory whenever  *
  9. ; * possible, use these routines.                            *
  10. ; *==========================================================*
  11.  
  12. IFDEF   COLOR
  13.   IFDEF HERC
  14.    .err both display type defined
  15.   ENDIF
  16. else
  17.   IFNDEF HERC
  18.     HERC equ 0
  19.   ENDIF
  20. ENDIF
  21.  
  22. smo     equ     4       ; small model offset value
  23.  
  24. DGROUP  group   _DATA
  25. _DATA   segment word public 'DATA'
  26.         assume  ds:DGROUP
  27.  
  28.         extrn   _CUR_PLOT:word
  29. IFDEF JLASER
  30.         extrn   _CUR_FRAME:word
  31.         public  jlaserseg
  32. ENDIF
  33.  
  34.         public  wrtvec  ; write vector
  35.  
  36. IFDEF JLASER
  37. jpgname db      'EMMXXXX0',0
  38. procid  dw      0
  39. jlaserseg dw    0
  40. dmaln   dw      0
  41. ENDIF
  42.  
  43. owrtvec dw      $write
  44. pltvec  dw      $or
  45.         dw      $and
  46.         dw      $xor
  47. wrtvec  dw      $or     ; default is $or
  48. _DATA   ends
  49.  
  50. _TEXT   segment byte public 'CODE'
  51.         assume  cs:_TEXT,ds:DGROUP
  52.         public  _fr_write,_PlotType,_fr_read
  53.         public  $aread, $read, _writetype, $write
  54.  
  55. IFDEF JLASER
  56.         public  _initjlsr, _cleanjlsr, _dumpjlsr
  57. ENDIF
  58.  
  59. $aread  proc    near
  60. IFDEF JLASER
  61.         cmp     _CUR_FRAME,01h
  62.         jne     ardother
  63.         push    es
  64.         push    dx
  65.         push    ax
  66.         mov     dx,0220h
  67.         mov     ax,es
  68.         out     dx,al
  69.         mov     ax,jlaserseg
  70.         mov     es,ax
  71.         pop     ax
  72.         and     ax,es:[bx]
  73.         pop     dx
  74.         pop     es
  75.         ret
  76. ardother:
  77. ENDIF
  78.         and     ax,es:[bx]
  79.         ret
  80. $aread  endp
  81.  
  82. $read   proc    near
  83. IFDEF JLASER
  84.         cmp     _CUR_FRAME,01h
  85.         jne     rdother
  86.         push    es
  87.         push    dx
  88.         push    ax
  89.         mov     dx,0220h
  90.         mov     ax,es
  91.         out     dx,al
  92.         mov     ax,jlaserseg
  93.         mov     es,ax
  94.         pop     ax
  95.         mov     ax,es:[bx]
  96.         pop     dx
  97.         pop     es
  98.         ret
  99. rdother:
  100. ENDIF
  101.         mov     ax,es:[bx]
  102.         ret
  103. $read   endp
  104.  
  105. ; A C callable routine
  106. ;       ret=fr_read(location);
  107. ;       int ret;
  108. ;       int far *location;
  109. ;
  110. ;       return value is the word at location
  111. _fr_read proc   near     ;public routine
  112.         push    bp
  113.         mov     bp,sp
  114.         les     bx,dword ptr [bp+smo]   ; get address into es:bx
  115.         mov     ax,es:[bx]
  116.         pop     bp
  117.         ret
  118. _fr_read endp
  119.  
  120. ; A C callable routine
  121. ;       ret=fr_write(location, word);
  122. ;       int ret, word;
  123. ;       int far *location;
  124. ;
  125. ;       return value is same as word
  126. _fr_write proc   near    ;public routine
  127.         push bp
  128.         mov     bp,sp
  129.         mov     ax,[bp+smo+4]
  130.         les     bx,dword ptr [bp+smo]   ; get address into es:bx
  131.         pop     bp
  132.         jmp     word ptr wrtvec
  133. _fr_write endp
  134. ;
  135. ; all external accessing of $or, $and or $xor must go
  136. ; through the vector -- wrtvec
  137. $write  proc    near
  138. IFDEF JLASER
  139.         cmp     _CUR_FRAME,01h
  140.         jne     wrtother
  141.         push    es
  142.         push    dx
  143.         push    ax
  144.         mov     dx,0220h
  145.         mov     ax,es
  146.         out     dx,al
  147.         mov     ax,jlaserseg
  148.         mov     es,ax
  149.         pop     ax
  150.         mov     es:[bx],ax
  151.         pop     dx
  152.         pop     es
  153.         ret
  154. wrtother:
  155. ENDIF
  156.         mov     es:[bx],ax
  157.         ret
  158. $write  endp
  159.  
  160. $or     proc    near
  161. IFDEF JLASER
  162.         cmp     _CUR_FRAME,01h
  163.         jne     orother
  164.         push    es
  165.         push    dx
  166.         push    ax
  167.         mov     dx,0220h
  168.         mov     ax,es
  169.         out     dx,al
  170.         mov     ax,jlaserseg
  171.         mov     es,ax
  172.         pop     ax
  173.         or      es:[bx],ax
  174.         pop     dx
  175.         pop     es
  176.         ret
  177. orother:
  178. ENDIF
  179.         or      es:[bx],ax
  180.         ret
  181. $or     endp
  182.  
  183. $and    proc    near
  184. IFDEF JLASER
  185.         cmp     _CUR_FRAME,01h
  186.         jne     andother
  187.         push    es
  188.         push    dx
  189.         push    ax
  190.         mov     dx,0220h
  191.         mov     ax,es
  192.         out     dx,al
  193.         mov     ax,jlaserseg
  194.         mov     es,ax
  195.         pop     ax
  196.         or      es:[bx],ax
  197.         xor     es:[bx],ax
  198.         pop     dx
  199.         pop     es
  200.         ret
  201. andother:
  202. ENDIF
  203.         or      es:[bx],ax      ; reset all corresponding
  204.         xor     es:[bx],ax      ; bit which are 1 in ax to 0
  205.         ret                     ; in the word pointed by es:bx
  206. $and    endp
  207.  
  208. $xor    proc    near
  209. IFDEF JLASER
  210.         cmp     _CUR_FRAME,01h
  211.         jne     xorother
  212.         push    es
  213.         push    dx
  214.         push    ax
  215.         mov     dx,0220h
  216.         mov     ax,es
  217.         out     dx,al
  218.         mov     ax,jlaserseg
  219.         mov     es,ax
  220.         pop     ax
  221.         xor     es:[bx],ax
  222.         pop     dx
  223.         pop     es
  224.         ret
  225. xorother:
  226. ENDIF
  227.         xor     es:[bx],ax
  228.         ret
  229. $xor    endp
  230.  
  231. ; A C callable routine
  232. ;       PlotType(type);
  233. ;       int type;      /* use only the least significant 2 bits */
  234. _PlotType proc   near    ;public routine
  235.         push    bp
  236.         mov     bp,sp
  237.         mov     bx,[bp+smo]     ; get the type
  238.         and     bx,03h
  239.         mov     cx,_CUR_PLOT
  240.         mov     _CUR_PLOT,bx
  241.         shl     bx,1
  242.         mov     ax,pltvec[bx]   ; set up the vector
  243.         mov     wrtvec,ax
  244.         mov     ax,cx
  245.         pop     bp
  246.         ret
  247. _PlotType endp
  248.  
  249. _writetype proc near
  250.         mov     _CUR_PLOT,04h
  251.         mov     ax,owrtvec
  252.         mov     wrtvec,ax
  253.         ret
  254. _writetype endp
  255.  
  256. IFDEF   JLASER
  257. _initjlsr proc  near
  258.         mov     dx,0220h
  259.         mov     al,0f2h
  260.         out     dx,al
  261.         push    ds
  262.         mov     ax,0d000h
  263.         mov     ds,ax
  264.         mov     ax,1
  265.         mov     ds:033a3h,al
  266.         mov     ax,3
  267.         mov     ds:033a3h,al
  268.         pop     ds
  269.         mov     ax,3d00h
  270.         lea     dx,jpgname
  271.         int     21h
  272.         jc      jlsr_err
  273.         xchg    ax,bx
  274.         mov     ax,4407h
  275.         xor     cx,cx
  276.         int     21h
  277.         pushf
  278.         push    ax
  279.         mov     ah,3eh
  280.         int     21h
  281.         pop     ax
  282.         popf
  283.         jc      jlsr_err
  284.         cmp     al,0ffh
  285.         jne     jlsr_err
  286.         mov     ah,40h
  287.         int     67h
  288.         or      ah,ah
  289.         jnz     jlsr_err
  290.         mov     ah,42h
  291.         int     67h
  292.         or      ah,ah
  293.         jnz     jlsr_err
  294.         xchg    ax,bx
  295.         mov     bx,63
  296.         cmp     bx,ax
  297.         ja      jlsr_err
  298.         mov     ah,43h
  299.         int     67h
  300.         or      ah,ah
  301.         jnz     jlsr_err
  302.         mov     procid,dx
  303.         mov     ah,41h
  304.         int     67h
  305.         mov     jlaserseg,bx
  306.         mov     ax,4401h
  307.         xor     bx,bx
  308.         int     67h
  309.         mov     ah,3dh
  310.         mov     dx,procid
  311.         mov     bx,62
  312.         int     67h
  313.         or      ah,ah
  314.         jnz     jlsr_err
  315.         mov     dmaln,bx
  316.         mov     ah,3eh
  317.         int     67h
  318.         or      ah,ah
  319.         jnz     jlsr_err
  320.         ret
  321. jlsr_err:
  322.         mov     ax,0ffffh
  323.         ret
  324. _initjlsr endp
  325.  
  326. _cleanjlsr proc near
  327.         mov     ah,45h
  328.         mov     dx,[procid]
  329.         int     67h
  330.         ret
  331. _cleanjlsr endp
  332.  
  333. _dumpjlsr proc  near
  334.         mov     ah,3fh
  335.         int     67h
  336.         mov     al,ah
  337.         sub     ah,ah
  338.         ret
  339. _dumpjlsr endp
  340.  
  341. ENDIF
  342.  
  343. _TEXT   ends
  344.         end
  345.  
  346.