home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / BEEHIVE / ZSUS / ZSUS001.LBR / TCJWSPAT.LBR / TCJMRPAT.WZ / TCJMRPAT.WS
Text File  |  2000-06-30  |  10KB  |  364 lines

  1. .mt2
  2. .mb2
  3. ; Program:    WordStar Shell Modification Patches
  4. ; Author:    Jay Sage
  5. ; Date:        August 7, 1988
  6.  
  7. ; Patches to make the WordStar Release 4 'R' command operate as a ZCPR2-type
  8. ; shell.  Several routines in WS.COM and WS.OVR must be changed.
  9. ;
  10. ; 1. WordStar must be prevented from pushing its name onto the Z-System shell
  11. ;    stack.  However, a flag that is used by the 'R' command to determine how
  12. ;    to operate must be set as if WS4 had set itself up as a shell.
  13. ;
  14. ; 2. The popping of the shell stack when WS4 terminates must be disabled.
  15. ;
  16. ; 3. The user input to the prompt from the 'R' command must be handled
  17. ;    differently.  A command to reinvoke WS4 must be appended to the user's
  18. ;    input, and then any commands pending in the multiple command line buffer
  19. ;    must be added as well.  The result is then placed into the command line
  20. ;    buffer.  If overflow occurs, the user command is ignored, and an error
  21. ;    message is displayed until a key is pressed.  The chaining command is of
  22. ;    the form ";DUU:WSNAME ,".  The comma at the end of the command tail is
  23. ;    used as a signal that WS4 was invoked as a ZCPR2 shell.
  24. ;
  25. ; 4. An optional patch can be included to defeat the use of the path for
  26. ;    searching for the overlay files.  An internal path can be specified.
  27.  
  28. ;------------------------------------------------------------
  29.  
  30.         0000        no    equ    0
  31.         FFFF        yes    equ    not no
  32.  
  33. ;*****************************************************************
  34. ;*    MUST change the following equate if not using the MORPAT *
  35. ;*    area of WS4.COM                         *
  36. ;*****************************************************************
  37.         FFFF        morarea    equ    yes          
  38.  
  39.         0000        mload    equ    no        
  40.  
  41.         FFFF        intpath    equ    yes        
  42.  
  43.         0894        ram1st    equ    0894h        
  44.  
  45.         0896        extra    equ    0896h        
  46.  
  47.         FFFF              if     morarea
  48.         045B          morpat    equ    045bh    
  49.                     else
  50.                   endif
  51.  
  52.         04CB        namebuf    equ    morpat+128-16    
  53.                               
  54.         0AA4        envoff    equ    0aa4h        
  55.         2200        zflag    equ    2200h        
  56.         1F38        rcmdbuf    equ    1f38h        
  57.         1F39        rcmd    equ    rcmdbuf+1    
  58.         0386        clrscr    equ    0386h        
  59.         17C7        scrnfn    equ    17c7h        
  60.         0280        conout    equ    0280h        
  61.  
  62.         0007        bell    equ    07        
  63.  
  64. è        FFFF               if    not mload
  65. ;----------------------------------------------------------------------
  66. ;
  67. ;            PATCHES TO WS.OVR
  68. ;
  69. ;----------------------------------------------------------------------
  70.             
  71. ; Modifications to the code that pushes WordStar onto the shell stack.
  72.             
  73. ; This patch prevents the WordStar shell entry from being set up, but it
  74. ; sets the flag in 2200h that makes WordStar think that it has set it up.
  75. ; In this way, the 'R' command will work as it would with shells engaged.
  76. ; The space is used to determine the command line needed to reinvoke
  77. ; WordStar.  The ZCPR33 facility for returning the directory in which the
  78. ; program was located is used to provide an explicit DU: prefix.  The
  79. ; resulting command line is kept at the end of the user patch area.
  80.             
  81.         2380          offset    defl    2380h        
  82.             
  83.         3CBF              org    3cbfh        
  84.             
  85. 3CBF    1E 24              ld    e,24h        
  86. 3CC1    CD A40A              call    envoff        
  87.             
  88. 3CC4    E5              push    hl
  89. 3CC5    11 0D00              ld    de,0dh        
  90. 3CC8    19              add    hl,de
  91. 3CC9    46              ld    b,(hl)        
  92. 3CCA    23              inc    hl
  93. 3CCB    7E              ld    a,(hl)        
  94.             
  95. 3CCC    C6 40              add    a,'A'-1        
  96. 3CCE    21 CB04              ld    hl,namebuf    
  97. 3CD1    36 3B              ld    (hl),';'    
  98. 3CD3    23              inc    hl
  99. 3CD4    77              ld    (hl),a        
  100. 3CD5    23              inc    hl
  101. 3CD6    78              ld    a,b        
  102. 3CD7    0E 2F              ld    c,'0'-1        
  103. 3CD9              tens:
  104. 3CD9    0C              inc    c
  105. 3CDA    D6 0A              sub    10
  106. 3CDC    30 FB              jr    nc,tens
  107. 3CDE    C6 3A              add    10+'0'        
  108. 3CE0    71              ld    (hl),c        
  109. 3CE1    23              inc    hl
  110. 3CE2    77              ld    (hl),a        
  111. 3CE3    23              inc    hl
  112.             
  113. 3CE4    36 3A              ld    (hl),':'    
  114. 3CE6    23              inc    hl
  115.             
  116. 3CE7    D1              pop    de        
  117. 3CE8    06 08              ld    b,8        
  118. 3CEA              copyname:
  119. 3CEA    13              inc    de        
  120. 3CEB    1A              ld    a,(de)
  121. 3CEC    FE 20              cp    ' '
  122. 3CEE    28 05              jr    z,copydone    
  123. 3CF0    77              ld    (hl),a
  124. 3CF1    23              inc    hl
  125. 3CF2    05              dec    bè3CF3    20 F5              jr    nz,copyname    
  126. 3CF5              copydone:
  127. 3CF5    36 20              ld    (hl),' '    
  128. 3CF7    23              inc    hl
  129. 3CF8    36 2C              ld    (hl),','
  130. 3CFA    23              inc    hl
  131. 3CFB    36 00              ld    (hl),0        
  132.             
  133. 3CFD    3E FF              ld    a,0ffh        
  134. 3CFF    32 0022              ld    (zflag),a
  135.        ^
  136.        |------ After you enter this byte in ZPATCH press ^W, then
  137.     move to the next record and resume entering at the "0"
  138.  
  139. 3D02    C3 AA60              jp    60aah
  140.             
  141. 3D05              end1pat:
  142.         3D2A          endaddr    defl    60aah - offset
  143.         0025          free    defl    endaddr - end1pat
  144.         0000               if    $ gt endaddr
  145.                      endif
  146.             
  147. ;------------------------------------------------------------
  148.             
  149. ; This patch takes the user's response to the 'R' command, adds the command
  150. ; to reinvoke WordStar, and appends any pending commands in the command line
  151. ; buffer.  The result is written out to the command line buffer.  This
  152. ; implements a ZCPR2-style shell for the 'R' command.
  153.  
  154. ; If the resulting command line is too long for the MCL, an error message is
  155. ; displayed until a key is pressed, and then WS resumes as if no command line
  156. ; had been entered.
  157.  
  158. ; The first part of this patch replaces code in WS.OVR.  There is not enough
  159. ; space there for all the code, so it continues in the user patch area.
  160.             
  161.         E200          offset    defl    -1e00h    
  162.             
  163.                    endif;    not mload
  164.  
  165.         A000        scratch    equ    0a000h    
  166.  
  167.         FFFF               if    not mload
  168.             
  169.         67B2              org    67b2h        
  170.             
  171. 67B2    21 381F              ld    hl,rcmdbuf    
  172. 67B5    4E              ld    c,(hl)        
  173. 67B6    06 00              ld    b,0
  174. 67B8    23              inc    hl        
  175. 67B9    11 00A0              ld    de,scratch    
  176. 67BC    ED B0              ldir            
  177.             
  178. 67BE    21 CB04              ld    hl,namebuf    
  179. 67C1    CD D113              call    cpy2nul        
  180. 67C4    C3 5B04              jp    morpat        
  181.             
  182. 67C7              end2pat:
  183.         0004          free    defl    67cbh - end2pat
  184.         0000               if    $ gt 67cbh
  185.                      endif
  186.             
  187.                    endif; not mload
  188.  
  189. ;----------------------------------------------------------------------
  190. ;è;            PATCHES TO WS.COM
  191. ;
  192. ;----------------------------------------------------------------------
  193.  
  194.  
  195. ; This is the continuation of the patch in WS.OVR that inserts the user's
  196. ; command line, together with the WS reinvocation command, into the multiple
  197. ; command buffer.
  198.  
  199.         0000               if     (morpat=extra)     ; 
  200.                    endif
  201.  
  202.         045B            org    morpat
  203.  
  204. 045B    D5            push    de        
  205. 045C    1E 18            ld    e,18h        
  206. 045E    CD A40A            call    envoff
  207. 0461    5E            ld    e,(hl)        
  208. 0462    23            inc    hl
  209. 0463    56            ld    d,(hl)
  210. 0464    EB            ex    de,hl        
  211. 0465    D1            pop    de        
  212. 0466    CD D113            call    cpy2nul        
  213.  
  214. 0469    21 8603            ld    hl,clrscr    
  215. 046C    CD C717            call    scrnfn
  216.  
  217. 046F    1E 18            ld    e,18h        
  218. 0471    CD A40A            call    envoff        
  219. 0474    11 00A0            ld    de,scratch    
  220. 0477    47            ld    b,a        
  221. 0478            lenloop:
  222. 0478    1A            ld    a,(de)
  223. 0479    B7            or    a
  224. 047A    28 11            jr    z,oklength
  225. 047C    13            inc    de
  226. 047D    10 F9            djnz    lenloop
  227.  
  228. 047F    11 9F04            ld    de,errmsg    
  229. 0482    0E 09            ld    c,9
  230. 0484    CD 0500            call    0005h
  231. 0487    CD 491A            call    sak        
  232. 048A    C3 4E7F            jp    7f4eh        
  233.  
  234. 048D            oklength:
  235. 048D    11 0400            ld    de,4        
  236. 0490    EB            ex    de,hl        
  237. 0491    19            add    hl,de
  238. 0492    EB            ex    de,hl        
  239. 0493    73            ld    (hl),e        
  240. 0494    23            inc    hl
  241. 0495    72            ld    (hl),d
  242. 0496    21 00A0            ld    hl,scratch    
  243. 0499    CD D113            call    cpy2nul        
  244.  
  245. 049C    C3 F613            jp    13f6h        
  246.  
  247. 049F            errmsg:
  248. 049F    07 4D 4        db    bell,'MCL Ovfl - press any key...$'
  249.  
  250. 04BC            end3pat:
  251.         000F        free    defl    namebuf - end3pat
  252.         0000               if    $ gt namebuf
  253.                    endif
  254.  
  255.  
  256. ;------------------------------------------------------------
  257.  
  258. ; This optional patch causes WS4 to use an internal path to locate
  259. ; its overlay files.
  260.  
  261.         FFFF               if    intpath
  262.             
  263.         0F5F              org    0f5fh        
  264.             
  265. 0F5F    CD D913              call    setpath        
  266. 0F62    00              nop            
  267. 0F63    00              nop
  268.             
  269.                    endif    ;intpath
  270.  
  271. ;------------------------------------------------------------
  272.  
  273.  
  274. ; Modification to the termination routine that pops the shell stack.
  275.  
  276. ; This patch eliminates the popping of the shell stack on exit from
  277. ; WordStar.  The space from the end of this patch to 13f6h is available
  278. ; for other uses (40 bytes).
  279.  
  280.         13CE            org    13ceh
  281.  
  282. 13CE    C3 F613            jp    13f6h    
  283.  
  284.  
  285. ; This routine copies the string pointed to by HL to the address pointed to by
  286. ; DE until a null byte is encountered.  The null byte is copied as well.
  287.  
  288. 13D1            cpy2nul:
  289. 13D1    7E            ld    a,(hl)        
  290. 13D2    12            ld    (de),a        
  291. 13D3    B7            or    a        
  292. 13D4    C8            ret    z        
  293. 13D5    23            inc    hl        
  294. 13D6    13            inc    de
  295. 13D7    18 F8            jr    cpy2nul
  296.  
  297.         FFFF               if    intpath
  298.             
  299. 13D9              setpath:
  300. 13D9    21 E013              ld    hl,path0    
  301. 13DC    7E              ld    a,(hl)
  302. 13DD    23              inc    hl        
  303. 13DE    B7              or    a        
  304. 13DF    C9              ret
  305.             
  306. 13E0    02          path0:    db    2        
  307. 13E1    02               db    2        
  308. 13E2    04              db    4        
  309. 13E3    00              db    0        
  310. 13E4    00              db    0        
  311. 13E5    00              db    0        
  312.             
  313.                    endif    ;intpath
  314.  
  315. 13E6            end4pat:
  316.  
  317.         0010        free    defl    13f6h - end4pat
  318.         0000               if    $ gt 13f6h
  319.                    endif
  320.  
  321. ;------------------------------------------------------------
  322.  
  323. ; Modification to initialization code where WS4 determines if it was
  324. ; invoked as a shell.  We have defined a convention where a comma on
  325. ; the end of the command line signals WS4 to display its shell-wait
  326. ; message and wait for the user to press a key.
  327.  
  328.         1A2F            org    1a2fh
  329.  
  330. 1A2F    21 8000            ld    hl,80h        
  331. 1A32    6E            ld    l,(hl)        
  332. 1A33    CB FD            set    7,l        
  333. 1A35    7E            ld    a,(hl)        
  334. 1A36    FE 2C            cp    ','        
  335. 1A38    20 25            jr    nz,1a5fh    
  336.  
  337. 1A3A    36 20            ld    (hl),' '    
  338.  
  339. 1A3C    11 101B            ld    de,1b10h    
  340. 1A3F    0E 09            ld    c,9        
  341. 1A41    CD 0500            call    0005        
  342. 1A44    CD 491A            call    sak        
  343.  
  344. 1A47    18 16            jr    1a5fh        
  345.  
  346. 1A49            sak:
  347. 1A49    1E FF            ld    e,0ffh        
  348. 1A4B    0E 06            ld    c,6
  349. 1A4D    CD 0500            call    0005
  350. 1A50    B7            or    a
  351. 1A51    28 F6            jr    z,sak        
  352.  
  353. 1A53    1E 0D            ld    e,0dh        
  354. 1A55    0E 06            ld    c,6
  355. 1A57    C3 0500            jp    0005
  356.  
  357. 1A5A            end5pat:
  358.         0005        free    defl    1a5fh - end5pat
  359.         0000               if    $ gt 1a5fh
  360.                    endif
  361.  
  362.  
  363.                     end
  364.