home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / MISC / ZEN1_10.ZIP / DEVICE.SRC < prev    next >
Encoding:
Text File  |  1989-12-30  |  4.4 KB  |  240 lines

  1. \*
  2.  *   ZEN 1.10 Device drivers for MSDOS 2.0 or later
  3.  *     C 1990  by Martin Tracy
  4.  *             Last modified  1.1.90
  5.  *\
  6.  
  7. \ Read word at segment:offset.
  8. CODE L@ ( off seg - w)
  9.         mov   es,bx
  10.         pop   bx
  11.         mov   bx,es:[bx]
  12.         NEXT
  13. END-CODE
  14.  
  15. \ Write word to segment:offset.
  16. CODE L! ( w off seg)
  17.         mov   es,bx
  18.         pop   bx
  19.         pop   es:[bx]
  20.         pop   bx
  21.         NEXT
  22. END-CODE
  23.  
  24. \ Fetch byte value at segment:offset.
  25. CODE LC@ ( off seg - b)
  26.         mov   es,bx
  27.         pop   bx
  28.         mov   bl,es:[bx]
  29.         sub   bh,bh
  30.         NEXT
  31. END-CODE
  32.  
  33. \ Store lower byte value at segment:offset.
  34. CODE LC! ( w off seg)
  35.         mov   es,bx
  36.         pop   bx
  37.         pop   ax
  38.         mov   es:[bx],al
  39.         pop   bx
  40.         NEXT
  41. END-CODE
  42.  
  43. \ Move u bytes from seg:off to seg:off2, leftmost byte first
  44. CODE LCMOVE ( off seg off2 seg2 u)
  45.         mov   cx,bx
  46.         mov   bx,si
  47.         mov   dx,ds
  48.         pop   es
  49.         pop   di
  50.         pop   ds
  51.         pop   si
  52.         jcxz  LCmo1
  53.         rep movsb
  54. LCmo1:  mov   si,bx
  55.         mov   ds,dx
  56.         pop   bx
  57.         NEXT
  58. END-CODE
  59.  
  60.  
  61. \ Push code segment register.
  62. CODE CSEG ( - seg)
  63.         push  bx
  64.         mov   bx,cs
  65.         NEXT
  66. END-CODE
  67.  
  68. \ Push data segment register.
  69. CODE DSEG ( - seg)
  70.         push  bx
  71.         mov   bx,ds
  72.         NEXT
  73. END-CODE
  74.  
  75.  
  76. 3 EQU #CFA   \ code field size in address units.  See also PFA
  77.  
  78. \ Convert execution token into parameter field address.
  79. CODE PFA ( cfa - pfa)
  80.         add   bx,3
  81.         NEXT
  82. END-CODE
  83.  
  84.  
  85. 8   EQU BSP#  \ backspace
  86. 127 EQU DEL#  \ delete
  87. 13  EQU EOL#  \ end of line character
  88.  
  89. | CREATE BACKSP   \ Backspace sequence
  90. 3 C, BSP# C, BL C, BSP# C,
  91.  
  92. CREATE CRLF       \ End of line sequence
  93. 2 C, EOL# C, 10 C,
  94.  
  95. 32 CONSTANT BL    \ ASCII blank  EXT CORE
  96.  
  97. \ Alter string to suppress trailing blanks
  98. : -TRAILING ( a +n - a2 +n2) \ CORE
  99.    BL SKIP> ;
  100.  
  101.  
  102. \ Defined here far from INTERNAL.SRC to force a 3-byte jump.
  103. LOX? \IF  | VARIABLE LX   \ Local pointer pseudo register
  104. MUX? \IF    VARIABLE MX   \ Entry to cooperative multitasker
  105.  
  106.  
  107. MUX? \*IF
  108. \ Enter cooperative multitasker
  109. : PAUSE
  110.    MX PERFORM ;
  111. *\
  112.  
  113.  
  114. \ Output a string via Int 21h service 40h
  115. | CODE TDOS ( addr u)
  116.         mov   cx,bx
  117.         pop   dx
  118.         mov   bx,1
  119.         mov   ah,40h
  120.         int   21h
  121.         pop   bx
  122. END-CODE
  123. MUX? \*IF
  124. ASSEMBLER
  125.         mov   ax,[MXv]
  126.         jmp   ax
  127. END-CODE
  128. *\
  129. MUX? NOT \*IF
  130. ASSEMBLER
  131.         NEXT
  132. END-CODE
  133. *\
  134.  
  135. \ Check for key pressed via Int 21h service 6
  136. \ If key is special, get second key via Int 21h service 7
  137. \ Special keys are returned in high byte with low byte zeroed
  138. | CODE KDOS ( - key -1 | 0)
  139.         push  bx
  140.         mov   dl,0FFh
  141.         mov   ah,6
  142.         int   21h
  143.         mov   bx,0
  144.         je    KDOS2
  145.         sub   ah,ah      ; special key?
  146.         or    al,al
  147.         jnz   KDOS1
  148.         mov   ah,7
  149.         int   21h
  150.         sub   ah,ah
  151.         xchg  al,ah
  152. KDOS1:  push  ax
  153.         mov   bx,TRUTH
  154. KDOS2:
  155. END-CODE
  156. MUX? \*IF
  157. ASSEMBLER
  158.         mov   ax,[MXv]
  159.         jmp   ax
  160. END-CODE
  161. *\
  162. MUX? NOT \*IF
  163. ASSEMBLER
  164.         NEXT
  165. END-CODE
  166. *\
  167.  
  168.  
  169. \ Carriage return
  170. | : (CR) ( )
  171.    CRLF COUNT TDOS ;
  172.  
  173. \ Page eject
  174. | : (PAGE) ( )
  175.    25 0 DO  CR  LOOP ;
  176.  
  177. \ Move cursor to given x y coordinates
  178. | : (CORO) ( n n2)
  179.    CR  DROP SPACES ;
  180.  
  181. \ Like TYPE but highlight if possible
  182. | : (MARK) ( a n)
  183.    ." ^"  TDOS ;
  184.  
  185. \ Audible alert
  186. | : (BEEP)
  187.    7 EMIT ;
  188.  
  189.  
  190. \ IO transfer vectors.  Keep together.
  191.   VARIABLE 'TYPE
  192. | VARIABLE '?KEY
  193. | VARIABLE 'CR
  194. | VARIABLE 'PAGE
  195. | VARIABLE 'CORO
  196. | VARIABLE 'MARK
  197. | VARIABLE 'BEEP
  198. | VARIABLE 'SPARE
  199.  
  200. \ Type a string
  201. : TYPE ( addr u) \ CORE
  202.  'TYPE PERFORM ;
  203.  
  204. \ Return true and key if key is available;
  205. \ otherwise return only false.
  206. : ?KEY ( - key -1 | 0) \ CORE
  207.  '?KEY PERFORM ;
  208.  
  209. \ Read a key
  210. : KEY ( - c) \ CORE
  211.    BEGIN  ?KEY UNTIL ;
  212.  
  213. \ Carriage return
  214. : CR ( ) \ CORE
  215.  'CR PERFORM ;
  216.  
  217. \ Page eject
  218. : PAGE ( ) \ CORE
  219.  'PAGE PERFORM ;
  220.  
  221. \ Move cursor to given x y coordinates
  222. : >COLROW ( n n2)
  223.   'CORO PERFORM ;
  224.  
  225. \ Like TYPE but highlight if possible
  226. : MARK ( a n)
  227.  'MARK PERFORM ;
  228.  
  229. \ Audible alert
  230. : BEEP
  231.  'BEEP PERFORM ;
  232.  
  233. \ IO vector in dictionary space.
  234. | : IO
  235.    TDOS KDOS (CR) (PAGE) (CORO) (MARK) (BEEP) ( EXIT:) ;
  236.  
  237. \ Initialize all IO commands for dumb terminal.
  238. : DUMB
  239.    ['] IO PFA CSEG 'TYPE DSEG 8 CELLS LCMOVE ;
  240.