home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / shell / zshell / zshell.s < prev    next >
Text File  |  1995-01-02  |  197KB  |  9,709 lines

  1.  
  2. ****************************************************
  3. ********   ZSHELL (C) 1990,91 Paul Hayter   ********
  4. ********  updated to V2.2 by Martin Gierich ********
  5. ********    First major change: 08.06.93    ********
  6. ********    Last change: 02.01.95        ********
  7. ****************************************************
  8.  
  9. ***        TABSIZE = 8 Chars         ***
  10. ***     Local Labels named .A to .Z         ***
  11.  
  12. VERSION            equ    $1234
  13.  
  14. FIB            equ    260        ;FileInfoBlock
  15. ACCESS_READ        equ    -2
  16. ACCESS_WRITE        equ    -1
  17. MODE_READWRITE        equ    1004
  18. MODE_OLDFILE        equ    1005
  19. MODE_NEWFILE        equ    1006
  20.  
  21. * DOS LIBRARY
  22. dl_A2            equ    42
  23.  
  24. SIGBREAKB_CTRL_C    equ    $C
  25. SIGBREAKB_CTRL_D    equ    $D
  26. SIGBREAKB_CTRL_E    equ    $E
  27. SIGBREAKB_CTRL_F    equ    $F
  28.     
  29. * FILE INFO BLOCK
  30. fib_DiskKey        equ  $0000
  31. fib_DirEntryType    equ  $0004
  32. fib_FileName        equ  $0008
  33. fib_Protection        equ  $0074
  34. fib_EntryType        equ  $0078
  35. fib_Size        equ  $007c
  36. fib_NumBlocks        equ  $0080
  37. fib_Date        equ  $0084
  38. fib_Comment        equ  $0090
  39. fib_Reserved        equ  $00e0
  40.  
  41. * INFO DATA STRUCTURE
  42. id_NumSoftErrors    equ    0
  43. id_UnitNumber        equ    4
  44. id_DiskState        equ    8
  45. id_NumBlocks        equ    12
  46. id_NumBlocksUsed    equ    16
  47. id_BytesPerBlock    equ    20
  48. id_DiskType        equ    24
  49. id_VolumeNode        equ    28
  50. id_InUse        equ    32
  51.  
  52. * TASK
  53. tc_State        equ    15
  54. tc_SigWait        equ    22
  55.  
  56. * PROCESS
  57.  
  58. pr_MsgPort        equ    92
  59. pr_SegList        equ    128
  60. pr_StackSize        equ    132
  61. pr_GlobVec        equ    136
  62. pr_TaskNum        equ    140
  63. pr_StackBase        equ    144
  64. pr_Result2        equ    148
  65. pr_CurrentDir        equ    152
  66. pr_CIS            equ    156
  67. pr_COS            equ    160
  68. pr_ConsoleTask        equ    164
  69. pr_FileSystemTask    equ    168
  70. pr_CLI            equ    172
  71. pr_ReturnAddr        equ    176
  72. pr_PktWait        equ    180
  73. pr_WindowPtr        equ    184
  74. pr_HomeDir        equ    188    KS2
  75. pr_Flags        equ    192
  76.  
  77. * COMMAND LINE INTERFACE
  78. cli_Result        equ    0
  79. cli_SetName        equ    4
  80. cli_CommandDir        equ    8
  81. cli_ReturnCode        equ    12
  82. cli_CommandName        equ    16
  83. cli_FailLevel        equ    20
  84. cli_Prompt        equ    24
  85. cli_StandardInput    equ    28
  86. cli_CurrentInput    equ    32
  87. cli_CommandFile        equ    36
  88. cli_Interactive        equ    40
  89. cli_Background        equ    44
  90. cli_CurrentOutput    equ    48
  91. cli_DefaultStack    equ    52
  92. cli_StandardOutput    equ    56
  93. cli_Module        equ    60
  94.  
  95. * FILE HANDLE
  96. fh_Link            equ    0
  97. fh_Port            equ    4
  98. fh_Type            equ    8
  99. fh_Buf            equ    12
  100. fh_Pos            equ    16
  101. fh_End            equ    20
  102.  
  103. * FILE LOCK
  104. fl_Link            equ    0
  105. fl_Key            equ    4
  106. fl_Access        equ    8
  107. fl_Task            equ    12
  108. fl_Volume        equ    16
  109.  
  110. * DATESTAMP
  111. ds_Days            equ    0
  112. ds_Minute        equ    4
  113. ds_Tick            equ    8
  114.  
  115. RETURN_OK        EQU  0
  116. RETURN_WARN        EQU  5
  117. RETURN_ERROR        EQU  10
  118. RETURN_BAD        EQU  15
  119. RETURN_FAIL        EQU  20
  120.  
  121. *Assign Stuff
  122. dl_Root        equ    34    APTR
  123. rn_Info        equ    24    BPTR
  124. di_DevInfo    equ    4    BPTR
  125. di_NetHand    equ    16    BPTR
  126. dvi_Next    equ    0    BPTR
  127. dvi_Type    equ    4    LONG
  128. dvi_Task    equ    8    APTR
  129. dvi_Lock    equ    12    BPTR
  130. dvi_Handler    equ    16
  131. dvi_StackSize    equ    20
  132. dvi_Priority    equ    24
  133. dvi_Startup    equ    28
  134. dvi_SegList    equ    32
  135. dvi_GlobVec    equ    36
  136. dvi_Name    equ    40    BSTR
  137. dt_device    equ    0    <-- contents of dvi_Type
  138. dt_dir        equ    1
  139. dt_volume    equ    2
  140.  
  141. *Resident Stuff
  142. resi_link    equ    0    ;BPTR
  143. resi_usecount    equ    4    ;LONG
  144. resi_seglist    equ    8    ;BPTR
  145. resi_name    equ    12    ;BSTR
  146. resi_length    equ    4+4+4
  147.  
  148. *Icon Lib Stuff
  149. sm_Process    equ    $14
  150. sm_Segment    equ    $18
  151. sm_NumArgs    equ    $1c
  152. sm_ToolWindow    equ    $20
  153. sm_ArgList    equ    $24
  154. wa_Lock        equ    0
  155. wa_Name        equ    4
  156. do_Magic    equ    0    ;must be $e310
  157. do_Type        equ    $30
  158. do_ToolTypes    equ    $36
  159. do_ToolWindow    equ    $46
  160. do_StackSize    equ    $4a
  161.  
  162. * AVAIL STUFF
  163. MEMF_PUBLIC        equ 1
  164. MEMF_CHIP        equ 2
  165. MEMF_FAST        equ 4
  166. MEMF_CLEAR        equ $10000
  167. MEMF_LARGEST        equ $20000
  168.  
  169. * ACTIONS
  170. ACTION_SCREEN_MODE    EQU    994
  171. ACTION_INHIBIT        EQU    31
  172. ACTION_MORE_CACHE    EQU    18
  173. ACTION_RENAME_DISK    EQU    9
  174. ACTION_DIE        EQU    5
  175. ACTION_DISK_CHANGE    EQU    33
  176. ACTION_SET_DATE        EQU    34
  177. ACTION_DISK_INFO    EQU    25
  178. ACTION_WRITE_PROTECT    EQU    1023
  179. ACTION_FLUSH        EQU    27
  180.  
  181. dp_Link        EQU  $00   ;DosPacket Structure
  182. dp_Port        EQU  $04
  183. dp_Type        EQU  $08
  184. dp_Arg1        EQU  $14
  185. dp_SIZEOF    EQU  $30
  186.  
  187. sp_Msg        EQU  $00   ;StandardPacket Structure
  188. sp_Pkt        EQU  $14
  189. sp_SIZEOF    EQU  $44
  190.  
  191. LH_HEAD        equ    0
  192. LH_TAIL        equ    4
  193. LH_TAILPRED    equ    8
  194. LH_TYPE        equ    12
  195. LH_PAD        equ    13
  196. LH_SIZE        equ    14
  197.  
  198. LN_SUCC        equ    0
  199. LN_PRED        equ    4
  200. LN_TYPE        equ    8
  201. LN_PRI        equ    9
  202. LN_NAME        equ    10
  203. LN_SIZE        equ    14
  204.  
  205. NT_MSGPORT    EQU  4
  206.  
  207. MP_FLAGS    EQU  $0E   ;Message Port Structure
  208. MP_SIGBIT    EQU  $0F   ;Signal bit number
  209. MP_SIGTASK    EQU  $10   ;Task to be signalled
  210. MP_MSGLIST    EQU  $14   ;Message linked list
  211. MP_SIZE        EQU  $22
  212.  
  213. mn_ReplyPort    equ    14
  214. mn_Length    equ    18
  215. mn_Size        equ    20
  216.  
  217. PA_SIGNAL    EQU  0       ;PutAction messages
  218.  
  219.     
  220. * LIBRARY CALLS
  221. * EXEC
  222. _LVOOpenLibrary        equ    -552
  223. _LVOOldOpenLibrary    equ    -408
  224. _LVOCloseLibrary    equ    -414
  225. _LVOSetFunction        equ    -420
  226. _LVOAllocMem        equ    -198
  227. _LVOFreeMem        equ    -210
  228. _LVORawDoFmt        equ    -522
  229. _LVORawMayGetChar    equ    -510
  230. _LVOFindTask        equ    -294
  231. _LVOSetTaskPri        equ    -300
  232. _LVOAddTask        equ    -282
  233. _LVOForbid        equ    -132
  234. _LVOPermit        equ    -138
  235. _LVOAvailMem        equ    -216
  236. _LVOAddPort        equ    -354
  237. _LVORemPort        equ    -360
  238. _LVOFindPort        equ    -390
  239. _LVOPutMsg        equ    -366
  240. _LVOGetMsg        equ    -372
  241. _LVOReplyMsg        equ    -378
  242. _LVOWaitPort        equ    -384
  243. _LVOWait        equ    -318
  244. _LVOSignal        equ    -324
  245. _LVOSetSignal        equ    -306
  246. _LVOAllocSignal        equ    -330
  247. _LVOFreeSignal        equ    -336
  248. _LVOOpenDev        equ    -444
  249. _LVOCloseDev        equ    -450
  250. _LVODoIO        equ    -456
  251.  
  252. * DOS
  253. _LVOSetProtection    equ    -186
  254. _LVOOutput        equ    -60
  255. _LVOWrite        equ    -48
  256. _LVOLock        equ    -84
  257. _LVOUnLock        equ    -90
  258. _LVODupLock        equ    -96
  259. _LVOExamine        equ    -102
  260. _LVOExNext        equ    -108
  261. _LVOOpen        equ    -30
  262. _LVOClose        equ    -36
  263. _LVORead        equ    -42
  264. _LVOInput        equ    -54
  265. _LVODeleteFile        equ    -72
  266. _LVORename        equ    -78
  267. _LVOCreateDir        equ    -120
  268. _LVOCurrentDir        equ    -126
  269. _LVOIoErr        equ    -132
  270. _LVOParentDir        equ    -210
  271. _LVOLoadSeg        equ    -150
  272. _LVOUnLoadSeg        equ    -156
  273. _LVOCreateProc        equ    -138
  274. _LVOInfo        equ    -114
  275. _LVODateStamp        equ    -192
  276. _LVOSeek        equ    -66
  277. _LVODeviceProc        equ    -174
  278. _LVODelay        equ    -198
  279. _LVOSetComment        equ    -180
  280. _LVOIsInteractive    equ    -216
  281.  
  282. *Intuition
  283. _LVOPrintIText        equ    -216
  284. _LVODisplayBeep        equ    -96
  285. _LVOLockIBase        equ    -414
  286. _LVOUnlockIBase        equ    -420
  287. _LVORefreshWindowFrame    equ    -456
  288. _LVOSizeWindow        equ    -288
  289. _LVOMoveWindow        equ    -168
  290. _LVORemakeDisplay    equ    -384
  291. _LVOMakeScreen        equ    -378
  292. _LVORethinkDisplay    equ    -390
  293.  
  294. *Icon
  295. _LVOGetDiskObject    equ    -78
  296. _LVOFreeDiskObject    equ    -90
  297. _LVOFindToolType    equ    -96
  298. _LVOMatchToolValue    equ    -102
  299.  
  300.  
  301. * NEED THESE 2 MACROS FOR A68K ASSEMBLER
  302. ;blo    macro
  303. ;    bcs \1
  304. ;    endm
  305.     
  306. ;bhs    macro
  307. ;    bcc \1
  308. ;    endm
  309.  
  310. *SYSTEM0 stuff!!!!!!!!!!
  311. REG_SysBase    equr a6
  312.  
  313. callsys    macro
  314.     jsr _LVO\1(REG_SysBase)
  315.     endm
  316.  
  317. * parameter offsets & stack
  318. ;SAVED_REGS    reg    a2-a6/d2-d3
  319. DELTA        equ    7*4
  320. ARG_NAME    equ    4+DELTA
  321. ARG_SEGLIST    equ    8+DELTA
  322. ARG_ARGS    equ    12+DELTA
  323.  
  324. * additional return codes
  325. NO_CLI        equ    -1
  326. NO_MEM        equ    -2
  327.  
  328. * local constants
  329. MAXBSTR        equ    255
  330. LF        equ    10
  331.  
  332. * register usage
  333. REG_Result    equr    d3
  334. REG_Process    equr    a2      ;may not be A4, see below!
  335. REG_CLI        equr    a3
  336. REG_CIS        equr    a4      ;may not be A3, see below!
  337. REG_PrevStack    equr    a1    ;V2.0 changed from a5 to a1
  338.  
  339. * local stack frame
  340. * STRUCTURE      StackFrame,0
  341. sf_CommandName    equ    0
  342. sf_CommandArgs    equ    MAXBSTR+1        ;BSTR, length byte!
  343. sf_PrevStack    equ    sf_CommandArgs+MAXBSTR+1        ;not a BSTR, LF-terminated!
  344. sf_SaveReturnAddr    equ    sf_PrevStack+4
  345. sf_SaveModule    equ    sf_SaveReturnAddr+4
  346. sf_SaveCommandName    equ    sf_SaveModule+4
  347. sf_StackBase    equ    sf_SaveCommandName+4
  348. sf_StackSize    equ    sf_StackBase+4
  349. sf_PushSize    equ    sf_StackSize+4
  350. sf_Process    equ    sf_PushSize+4
  351. sf_CLI        equ    sf_Process+4
  352. sf_CIS        equ    sf_CLI+4
  353. sf_SCB_Buf    equ    sf_CIS+4
  354. sf_SCB_Pos    equ    sf_SCB_Buf+4
  355. sf_SCB_End    equ    sf_SCB_Pos+4
  356. sf_Membase    equ    sf_SCB_End+4
  357. sf_SIZEOF    equ    sf_Membase+4
  358.  
  359. *Constants (only LONGS!)
  360. SHELLINE_SIZE    equ    256    V1.30
  361. CLIBUF_SIZE    equ    256
  362. NEWPRINTSIZE    equ    200
  363. PATH_SIZE    equ    256    V1.30
  364. HISTORY_SIZE    equ    1024    MUST BE POWER OF 2
  365. SEARCH_STRING_SIZE    equ    60
  366. DEST_LABEL_SIZE    equ    60
  367.  
  368. * THE GENERAL MEMORY BLOCK (LONGS!)
  369. blockbase    equ    0    ;the fib or info goes here
  370. sp_node        equ    blockbase+260    ;DOSpacket
  371. sp_reply    equ    sp_node+14
  372. sp_length    equ    sp_reply+4
  373. ;sp_ptr        equ    ;sp_ptr+4
  374. sp_link        equ    sp_length+2
  375. sp_port        equ    sp_link+4
  376. packettype    equ    sp_port+4
  377. sp_res1        equ    packettype+4
  378. sp_res2        equ    sp_res1+4
  379. myArg1        equ    sp_res2+4
  380. myArg2        equ    myArg1+4
  381. myArg3        equ    myArg2+4
  382. myArg4        equ    myArg3+4
  383. myArg5        equ    myArg4+4
  384. myArg6        equ    myArg5+4
  385. myArg7        equ    myArg6+4
  386. packettask    equ    myArg7+4
  387. devproc        equ    packettask+4
  388. dirlock        equ    devproc+4
  389. last_failcode    equ    dirlock+4
  390. outhandle    equ    last_failcode+4    ;Handles
  391. inhandle    equ    outhandle+4
  392. nonstdin    equ    inhandle+4    Allow 40 bytes
  393. nonstdout    equ    nonstdin+40    Allow 40 bytes
  394. stdout        equ    nonstdout+40
  395. stdin        equ    stdout+4
  396. EntryA0        equ    stdin+4
  397. better_Seglist    equ    EntryA0+4
  398. parm1        equ    better_Seglist+4 ;addr of each parameter within shelline
  399. parm2        equ    parm1+4
  400. parm3        equ    parm2+4
  401. parm4        equ    parm3+4
  402. parm5        equ    parm4+4
  403. parm6        equ    parm5+4
  404. parm7        equ    parm6+4
  405. parm8        equ    parm7+4
  406. parm9        equ    parm8+4
  407. parm10        equ    parm9+4
  408. parm11        equ    parm10+4
  409. parm12        equ    parm11+4
  410. parm13        equ    parm12+4
  411. parm14        equ    parm13+4
  412. parm15        equ    parm14+4
  413. endofparms    equ    parm15+4+4*10    10 extra parms
  414.  
  415. shelline    equ    endofparms+4    for NULL-end        
  416. endofshelline    equ    shelline+SHELLINE_SIZE
  417.  
  418. CLIbuf        equ    endofshelline
  419. NewPrintBuffer    equ    CLIbuf+CLIBUF_SIZE
  420. errorstack    equ    NewPrintBuffer+NEWPRINTSIZE
  421. topstack    equ    errorstack+4
  422. stacksize    equ    topstack+4
  423. temp1        equ    stacksize+4
  424. temp2        equ    temp1+4
  425. temp3        equ    temp2+4
  426. temp4        equ    temp3+4
  427. tempbuf        equ    temp4+4        double shellinesizebuffer
  428. temp2buf    equ    tempbuf+2*SHELLINE_SIZE    ;80 char temp buffer
  429. dosbase        equ    temp2buf+80
  430. intuibase    equ    dosbase+4
  431. Result2        equ    intuibase+4
  432. kickver        equ    Result2+4
  433. old_prompt    equ    kickver+2
  434. old_setname    equ    old_prompt+4
  435. old_homedir    equ    old_setname+4
  436. Unused        equ    old_homedir+4
  437. count_line    equ    Unused+18
  438. ignoreit    equ    count_line+4    for filenamecompletition
  439. OldCTask    equ    ignoreit+SEARCH_STRING_SIZE    for the future
  440. OldCIS        equ    OldCTask+4
  441. OldCOS        equ    OldCIS+4
  442. bordersize    equ    OldCOS+4
  443. scsize        equ    bordersize+4
  444. scaddr        equ    scsize+4
  445. scptr        equ    scaddr+4
  446. scflag        equ    scptr+4        new v1.29
  447. openwin_flag    equ    scflag+1
  448. noresi_flag    equ    openwin_flag+1
  449. noreview_flag    equ    noresi_flag+1
  450. ReviewMem    equ    noreview_flag+1
  451. ReviewPtr    equ    ReviewMem+4
  452. ReviewSize    equ    ReviewPtr+4
  453. patharea    equ    ReviewSize+4
  454. now        equ    patharea+PATH_SIZE
  455. nost        equ    now+4
  456. then        equ    nost+4
  457. past        equ    then+4    ;history buffer=1024 bytes
  458. thistask    equ    past+HISTORY_SIZE
  459. gather_ptr    equ    thistask+4
  460. gather        equ    gather_ptr+4 ;CSI string=40 bytes
  461. tempbytes    equ    gather+40
  462. first_set_defn    equ    tempbytes+2
  463. set_search_string    equ    first_set_defn+4
  464. mem_addr    equ    set_search_string+SEARCH_STRING_SIZE
  465. wild_flag    equ    mem_addr+4
  466. stat_mode_flag    equ    wild_flag+1
  467. wild_string    equ    stat_mode_flag+1    allow 80 chars for wildcard
  468. date_mark    equ    wild_string+80    3 lwords
  469. mem_mark    equ    date_mark+12    3 lwords chip/fast/total
  470. CD_string    equ    mem_mark+12    Allow 80 bytes.
  471. prompt_string    equ    CD_string+80    Allow 80 bytes.
  472. prompt_args    equ    prompt_string+80    Allow 40 bytes
  473. line_count    equ    prompt_args+40    Allow 40 bytes
  474. mult_comm_flag    equ    line_count+2    
  475. next_comm_ptr    equ    mult_comm_flag+2
  476. ctrl_c_flag    equ    next_comm_ptr+4
  477. failat_level    equ    ctrl_c_flag+2    word size
  478. cd_block    equ    failat_level+2
  479. cd_volnode    equ    cd_block+4
  480. recurs_flag    equ    cd_volnode+4
  481. indent_count    equ    recurs_flag+2
  482. resi_flag    equ    indent_count+2
  483. forcediskflag    equ    resi_flag+1
  484. CLIflag        equ    forcediskflag+1
  485. WBflag        equ    CLIflag+1
  486. window_old    equ    WBflag+1
  487. wb_msg        equ    window_old+4
  488. iconbase    equ    wb_msg+4
  489. diskobj        equ    iconbase+4
  490. filesys_old    equ    diskobj+4
  491. cdir_old    equ    filesys_old+4
  492. cdback        equ    cdir_old+4
  493. ctrl_codes    equ    cdback+4    Keyboard-CTRL-Codes
  494. if_flag        equ    ctrl_codes+16
  495. if_condition_flag    equ    if_flag+1
  496. goto_flag    equ    if_condition_flag+1
  497. unused        equ    goto_flag+1
  498. dest_label    equ    unused+1
  499. please_close_me    equ    dest_label+DEST_LABEL_SIZE
  500. mem_offset_addr    equ    please_close_me+4
  501. io_Message    equ    mem_offset_addr+4    ;io-request (timer)
  502. io_Device    equ    io_Message+20
  503. io_Unit        equ    io_Device+4
  504. io_Command    equ    io_Unit+4
  505. io_Flags    equ    io_Command+2
  506. io_Error    equ    io_Flags+1
  507. tv_secs        equ    io_Error+1
  508. tv_micro    equ    tv_secs+4
  509. io_pad        equ    tv_micro+4    ;don't remove
  510.     
  511. stackbot    equ    io_pad+8
  512. sizeofblk    equ    stackbot
  513.  
  514.  
  515.  
  516. ********************************************
  517.  
  518. ;    SECTION    MYSHELL,CODE
  519.     
  520. ;Try to open dos then do the shell
  521. start    moveq    #-1,d7
  522.     move.l    a0,a3
  523.     move.l    4.w,a6
  524.     move.l    #sizeofblk,d0
  525.     move.l    #1+1<<16,d1        "memf_public" & clear it
  526.     jsr    _LVOAllocMem(a6)    alloc general mem block
  527.     tst.l    d0
  528.     beq    blkfail
  529.     move.l    d0,a5            A5=MEMBASE
  530.     move.l    sp,topstack(a5)
  531.     move.l    a3,EntryA0(a5)
  532.     move.w    20(a6),kickver(a5)        Kickstart-Version
  533.     lea    intuiname(pc),a1
  534.     jsr    _LVOOldOpenLibrary(a6)
  535.     tst.l    d0
  536.     beq    intfail
  537.     move.l    d0,intuibase(a5)
  538.     lea    dosname(pc),a1
  539.     jsr    _LVOOldOpenLibrary(a6)
  540.     tst.l    d0
  541.     beq    dosfail
  542.     move.l    d0,dosbase(a5)
  543.     clr.w    CLIflag(a5)        delete CLI&WBflag
  544.     sub.l    a1,a1
  545.     jsr    _LVOFindTask(a6)
  546.     move.l    d0,thistask(a5)        save this task address
  547.     move.l    d0,a2
  548.     move.l    pr_CLI(a2),d0
  549.     bne.s    .A
  550.     subq.w    #1,CLIflag(a5)        WB-Start
  551.  
  552.     move.l    #-1,d0
  553. .AA    nop
  554.     dbra    d0,.AA
  555.  
  556.     lea    pr_MsgPort(a2),a0
  557. ;    jsr    _LVOWaitPort(a6)    !!!
  558.     lea    pr_MsgPort(a2),a0
  559.     jsr    _LVOGetMsg(a6)
  560.     move.l    d0,wb_msg(a5)
  561.     beq.s    .C
  562.     move.l    d0,a0
  563.     clr.l    sm_Segment(a0)        Clear Seg-Descriptor
  564. .C    move.l    pr_StackSize(a2),stacksize(a5)
  565.     move.l    pr_SegList(a2),d0
  566.     beq.s    .B
  567.     lsl.l    #2,d0
  568.     move.l    d0,a0
  569.     clr.l    12(a0)            Clear SegPointer
  570.     bra.s    .B
  571. .A    lsl.l    #2,d0            CLI-Start
  572.     move.l    d0,a2
  573.     move.l    cli_DefaultStack(a2),d0
  574.     lsl.l    #2,d0
  575.     move.l    d0,stacksize(a5)    save stacksize
  576.     clr.l    cli_Module(a2)        do not free seglist
  577.     cmp.b    #"r",1(a3)
  578.     bne.s    .B
  579.     addq.b    #1,noresi_flag(a5)
  580. .B    move.l    dosbase(a5),a6        A6=DOSBASE
  581.     tst.b    noresi_flag(a5)
  582.     bne.s    doIT
  583.     lea    ZShellName(pc),a4
  584.     bsr    search_res2
  585.     lea    start-4(pc),a1
  586.     tst.l    d0
  587.     bra.s    doIT            !!!
  588.     beq.s    cresi
  589.     lsl.l    #2,d0
  590.     move.l    d0,a2
  591.     nop
  592.     nop
  593. VCheck    cmp.w    #VERSION,VCheck-start+6(a2)
  594.     bne    normex
  595.     addq.l    #1,resi_usecount(a0)
  596.     cmp.l    a1,a2
  597.     beq.s    doIT        running as resident
  598.     jmp    JumpIn-start+4(a2) Jump to JumpIn, but in the resident Code
  599. JumpIn    move.l    a1,d1    here it arrives
  600.     lsr.l    #2,d1
  601.     jsr    _LVOUnLoadSeg(a6)    free old mem
  602.     bra.s    doIT
  603. cresi    move.l    a1,d3
  604.     lsr.l    #2,d3
  605.     bsr    create_resi    make zshell resident
  606.     bne    crfail
  607.     addq.l    #1,resi_usecount(a2)
  608. doIT    bsr    shell            ***    DO IT    ***
  609.     bsr    deallocate_sets
  610.     bsr    clkoff
  611.     bsr    reviewend
  612.     bsr    RemoveCLI
  613.     lea    start-4(pc),a0
  614.     move.l    a0,d6
  615.     lsr.l    #2,d6
  616.     tst.b    noresi_flag(a5)
  617.     bne.s    normex
  618.     lea    ZShellName(pc),a4
  619.     bsr    search_res2
  620.     tst.l    d0
  621.     beq.s    crfail
  622.     subq.l    #1,resi_usecount(a0)
  623.     tst.l    d7
  624.     bne.s    crfail
  625.     moveq    #1,d1
  626.     cmp.l    resi_usecount(a0),d1
  627.     bne.s    crfail
  628.     move.l    d0,d6    kill the ZShell-Resident
  629.     move.l    a0,a2
  630.     move.l    d2,a0
  631.     move.l    resi_link(a2),resi_link(a0)
  632.     clr.l    resi_link(a2)
  633.     move.l    a2,d1
  634.     lsr.l    #2,d1
  635.     jsr    _LVOUnLoadSeg(a6)
  636. normex    bsr    giveman        free manualmem
  637.     move.l    thistask(a5),a0
  638.     tst.b    CLIflag(a5)    How to UnLoad the Segment
  639.     beq.s    .A
  640.     move.l    pr_SegList(a0),d0
  641.     beq.s    .B
  642.     lsl.l    #2,d0
  643.     move.l    d0,a0
  644.     move.l    d6,12(a0)    Store Segment in SegPointer (WB/RUN)
  645. .B    move.l    wb_msg(a5),d0
  646.     beq.s    crfail
  647.     move.l    d0,a0
  648.     move.l    d6,sm_Segment(a0)    and in Seg-Descriptor    (WB)
  649.     bra.s    crfail
  650. .A    move.l    pr_CLI(a0),a0
  651.     add.l    a0,a0
  652.     add.l    a0,a0
  653.     move.l    d6,cli_Module(a0)    Store Segment in Module    (CLI)
  654. crfail    move.l    dosbase(a5),a1
  655.     move.l    4.w,a6
  656.     jsr    _LVOCloseLibrary(a6)
  657. dosfail    move.l    intuibase(a5),a1
  658.     jsr    _LVOCloseLibrary(a6)
  659. intfail    move.l    wb_msg(a5),d2
  660.     move.l    a5,a1
  661.     move.l    #sizeofblk,d0
  662.     jsr    _LVOFreeMem(a6)
  663.     tst.l    d2
  664.     beq.s    .A
  665.     jsr    _LVOForbid(a6)    (what for ?)
  666.     move.l    d2,a1        WB-Message
  667.     jmp    _LVOReplyMsg(a6)    never returns !
  668. .A    moveq    #0,d0
  669.     rts
  670. blkfail    moveq    #RETURN_ERROR,d0
  671.     rts
  672.  
  673. initialise_default
  674.     move.w    #16,failat_level(a5)
  675.     move.b    #LF,past(a5)
  676.     lea    defpath1(pc),a0    initialise_default_paths
  677.     lea    patharea(a5),a1
  678. .A    move.b    (a0)+,(a1)+
  679.     bne.s    .A
  680.     tst.b    (a0)
  681.     bne.s    .A
  682.     clr.b    (a1)    make sure 2 zero bytes at end
  683.     lea    prompt_args_tx(pc),a0    init prompt
  684.     lea    prompt_args(a5),a1
  685. .C    move.b    (a0)+,(a1)+
  686.     bne.s    .C
  687.     moveq    #ctrl_inite-ctrl_init-1,d0
  688.     lea    ctrl_init(pc),a0
  689.     lea    ctrl_codes(a5),a1
  690. .B    move.b    (a0)+,(a1)+        init ctrl-codes
  691.     dbra    d0,.B
  692.     rts
  693.     
  694. * PRINT DECIMAL print D0 as decimal
  695. print10    movem.l    d0/a0-a1,-(sp)
  696.     move.l    d0,-(sp)
  697.     move.l    sp,a1
  698.     lea    format(pc),a0
  699.     bsr    new_print
  700.     lea    4(sp),sp
  701.     movem.l    (sp)+,d0/a0-a1
  702.     rts
  703.  
  704. * PRINT HEXADECIMAL address in D0
  705. printADR movem.l    d0/a0-a1,-(sp)
  706.     move.l    d0,-(sp)
  707.     move.l    sp,a1
  708.     lea    formatADR(pc),a0
  709.     bsr    new_print
  710.     lea    4(sp),sp
  711.     movem.l    (sp)+,d0/a0-a1
  712.     rts
  713.  
  714. *PRINT STRING at a1    ;saves some of the important low registers
  715. pr_space lea    space(pc),a1
  716.     bra.s    pr_string
  717. pr_tab    lea tab(pc),a1
  718.     bra.s pr_string
  719. pr_prompt lea prompt_string(a5),a1
  720.     bra.s pr_string    
  721. pr_lf    lea lf(pc),a1
  722. pr_string movem.l    d0-d3/a0-a3,-(sp)    print String in a1
  723.     move.l    a1,d2
  724.     moveq    #-1,d3
  725. .A    addq.l    #1,d3
  726.     tst.b    (a1)+
  727.     bne.s    .A
  728.     move.l    outhandle(a5),d1
  729.     beq.s    .B
  730.     jsr    _LVOWrite(a6)
  731. .B    movem.l    (sp)+,d0-d3/a0-a3
  732.     rts
  733.  
  734. *CHECK WHETHER A SCRIPT NAME WAS TYPED ON ENTRY TO ZSHELL
  735. execscr    move.l    EntryA0(a5),d0
  736.     beq.s    .C
  737.     move.l    d0,a0
  738.     tst.b    (a0)
  739.     bne    xz2    ;NB this is OK, xz2 will pop the return addr 
  740.             ;and jump to chorus
  741.     rts
  742. .C    moveq    #-1,d1        handle DEFAULT SCRIPT FILE s:zstart
  743.     bsr    changeWindowPtr    disable volume requesters
  744.     lea    defscript(pc),a2
  745.     move.l    a2,d1
  746.     moveq    #ACCESS_READ,d2
  747.     jsr    _LVOLock(a6)
  748.     tst.l    d0
  749.     beq.s    .B
  750.     move.l    d0,d1
  751.     jsr    _LVOUnLock(a6)
  752.     move.l    a2,a0
  753.     moveq    #0,d1
  754.     bsr    changeWindowPtr
  755.     bra    xz2
  756. .B    moveq    #0,d1
  757.     bsr    changeWindowPtr
  758.     rts
  759.  
  760.  
  761. *********************************
  762. *    MAIN BIT        *
  763. *********************************
  764. shell    move.l    sp,errorstack(a5)
  765.     bsr    CreateCLI
  766.     bne    cloga            exit on error
  767.     lea    prompt_args(a5),a0
  768.     move.l    a0,d0
  769.     lsr.l    #2,d0
  770.     move.l    d0,cli_Prompt(a2)
  771.     lea    CD_string(a5),a0
  772.     move.l    a0,d0
  773.     lsr.l    #2,d0
  774.     move.l    d0,cli_SetName(a2)
  775.     cmp.w    #36,kickver(a5)
  776.     blo.s    .C
  777.     move.l    pr_HomeDir(a3),old_homedir(a5)
  778.     clr.l    pr_HomeDir(a3)
  779. .C    bsr    raw_on
  780. ;    clr.l    first_set_defn(a5)    V2.0 all CLR removed
  781. ;    clr.b    stat_mode_flag(a5)        V1.09
  782. ;    clr.b    if_flag(a5)        No IF
  783. ;    clr.l    please_close_me(a5)
  784. ;    clr.b    goto_flag(a5)
  785. ;    clr.b    scflag(a5)
  786. ;    clr.l    then(a5)
  787. ;    clr.l    now(a5)
  788. ;    clr.l    nost(a5)
  789. ;    clr.b    nonstdin(a5)
  790. ;    clr.b    nonstdout(a5)
  791. ;    clr.b    mult_comm_flag(a5)
  792.     move.w    #19,line_count(a5)
  793.     jsr    _LVOOutput(a6)    SAVE THE CONSOLE HANDLERS
  794.     move.l    d0,outhandle(a5)
  795.     move.l    d0,stdout(a5)    V1.13
  796.     jsr    _LVOInput(a6)
  797.     move.l    d0,inhandle(a5)
  798.     move.l    d0,stdin(a5)
  799.     move.l    thistask(a5),a0
  800.     move.l    pr_CurrentDir(a0),d1
  801.     jsr    _LVODupLock(a6)
  802.     move.l    d0,cdback(a5)
  803.     cmp.b    #1,WBflag(a5)
  804.     beq.s    notini        run/newcli
  805.     bsr    initialise_default
  806. notini    bsr    eval_CD
  807.     bsr    execscr    
  808. chorus    bsr    close_redirection    HERE BEGINS THE MAIN LOOP
  809.     bsr    raw_on        MAKE SURE RAW MODE IS ON
  810.     clr.b    noreview_flag(a5)
  811.     bsr    compose_prompt
  812.     bsr    get_line
  813.     clr.b    ctrl_c_flag(a5)
  814.     move.l    4.w,a6
  815.     moveq    #0,d0        clear signals c&d
  816.     moveq    #0,d1
  817.     bset    #SIGBREAKB_CTRL_C,d1
  818.     bset    #SIGBREAKB_CTRL_D,d1
  819.     jsr    _LVOSetSignal(a6)
  820.     move.l    dosbase(a5),a6
  821.     clr.b    forcediskflag(a5)
  822.     move.l    parm1(a5),a0
  823.     move.b    (a0),d0
  824.     cmp.b    ctrl_codes+15(a5),d0
  825.     bne.s    .A
  826.     addq.l    #1,a0
  827.     tst.b    (a0)
  828.     bne.s    .B
  829.     move.l    cdback(a5),d1    dir back
  830.     jsr    _LVODupLock(a6)
  831.     move.l    d0,d1
  832.     bsr    chdir
  833.     bra.s    chorus
  834. .B    move.l    a0,parm1(a5)
  835.     addq.b    #1,forcediskflag(a5)
  836.     bra    notfound    force disk-command
  837. .A    cmp.b    #"#",(a0)    #-sign for ;#comment
  838.     beq    chorus
  839.     move.l    a0,d7        check for ? (help sign)
  840.     tst.b    1(a0)
  841.     bne.s    .C
  842.     cmp.b    #"?",(a0)
  843.     bne.s    .C
  844.     bsr    help_man    ? as command
  845.     bra    chorus
  846. .C    lea    comtext(pc),a1
  847.     lea    comoffs(pc),a2
  848. mtch    bsr    match
  849.     tst.l    d0
  850.     beq.s    notfound
  851.     move.l    parm1(a5),d7        check for ? (help sign)
  852.     move.l    parm2(a5),a1
  853.     tst.b    1(a1)
  854.     bne.s    .D
  855.     cmp.b    #"?",(a1)
  856.     bne.s    .D
  857.     bsr    rawh_off
  858.     bsr    help_man    ? as arg
  859.     bra    chorus
  860. .D    move.l    sp,errorstack(a5)    important in scripts ?
  861.     lea    start(pc),a0
  862. intern    jsr    0(a0,d0.w)    call internal command
  863.     tst.b    ctrl_c_flag(a5)
  864.     bne.s    com_break
  865. chkfail    move.l    d0,last_failcode(a5)
  866.     cmp.w    failat_level(a5),d0    ALL COMMANDS MUST RETURN D0=0 unless failure
  867.     blo    chorus
  868. com_fail move.l    d0,-(sp)
  869.     move.l    sp,a1
  870.     lea    failertx(pc),a0
  871.     bsr    new_print
  872.     move.l    (sp)+,d0
  873. com_break clr.b    mult_comm_flag(a5)
  874.     tst.b    scflag(a5)
  875.     beq    chorus
  876.     bsr    kill_script
  877.     bra    chorus
  878. notfound bsr    archie3        TRY DISK
  879.     move.l    d0,-(sp)
  880.     move.l    thistask(a5),a0
  881.     move.l    cd_volnode(a5),d0
  882.     move.l    pr_CurrentDir(a0),a1
  883.     add.l    a1,a1
  884.     add.l    a1,a1
  885.     cmp.l    fl_Volume(a1),d0    check volume node
  886.     bne.s    .A
  887.     move.l    cd_block(a5),d0
  888.     cmp.l    fl_Key(a1),d0    check disk block number
  889.     beq.s    .B
  890. .A    bsr    eval_CD        If command changes cd then change prompt.
  891. .B    move.l    (sp)+,d0
  892.     bra.s    chkfail
  893.  
  894.     
  895. *Match the string pointed to by A0 to one in a table pted to by a1
  896. *The number of the matched string is linked to an offset table pted to by
  897. *A2.  return with 
  898. *D0 holding offset from 'start' so a jsr 0(a0,d0.w) can be done
  899. *Entry    A1 pts to Command text table  A2 pts to command offset table
  900.  
  901. match    moveq    #0,d1    ;command count
  902.     move.l    a0,a3    ;save command
  903. mat2    move.b    (a0)+,d0
  904.     cmp.b    ctrl_codes+15(a5),d0    ;check "."
  905.     bne.s    .A
  906.     tst.b    (a0)
  907.     beq.s    foundit    ;shortcut
  908. .A    cmp.b    (a1),d0    ;V1.01
  909.     beq.s    mat3
  910.     add.b    #$20,d0    ;'A' -> 'a'    handle commands typed in UCase
  911.     cmp.b    (a1),d0
  912.     bne.s    nextcom    ;if any character wrong then check next
  913. mat3    addq.l    #1,a1
  914.     tst.b    -1(a0)    ;check whether 0 was last compared
  915.     beq.s    foundit    ;if it was then success
  916.     bra.s    mat2
  917. nextcom    tst.b    (a1)+
  918.     bne.s    nextcom
  919.     addq.l    #2,d1    ;each offset is a word
  920.     move.l    a3,a0
  921.     tst.b    (a1)    ;put 0,0 at end of com table
  922.     bne.s    mat2
  923.     moveq    #0,d0    ;D0 = 0 if command not found
  924.     rts
  925. foundit    move.w    0(a2,d1.l),d0    ;get offset
  926.     rts
  927.  
  928.  
  929. * Subroutine for complet, limiting chars:":","/","""," " *
  930. cjk1    cmp.b    #":",-1(a1)
  931.     beq.s    cjke
  932.     cmp.b    #"/",-1(a1)
  933.     beq.s    cjke
  934. cjk2    cmp.b    #$22,-1(a1)
  935.     beq.s    cjke
  936.     cmp.b    #" ",-1(a1)
  937. cjke    rts
  938.  
  939. * Complete Filename in Shelline *
  940. * a2 points to part of filename, d6 length of part *
  941. * d4: linmax , d5:linhere *
  942. complet    move.l    d5,d6
  943.     clr.b    temp2buf(a5)
  944.     lea    shelline(a5),a1
  945.     move.l    a1,a0
  946.     add.l    d5,a1
  947.     bsr    cjk1
  948.     beq.s    .C
  949. .A    subq.l    #1,a1        look for begin of filename
  950.     cmp.l    a1,a0
  951.     beq.s    .B    
  952.     bsr    cjk1
  953.     bne.s    .A
  954. .B    move.l    a1,a2        filename-pos. in a2
  955.     sub.l    a0,a1
  956.     sub.l    a1,d6        length in d6
  957.     move.b    (a2),d3        save char
  958.     clr.b    (a2)        null-end pathname
  959.     move.l    a2,a1
  960.     bra.s    .F
  961. .D    subq.l    #1,a1        look for begin of path
  962. .F    cmp.l    a1,a0
  963.     beq.s    .E
  964.     bsr    cjk2
  965.     bne.s    .D
  966. .E    move.l    a1,d1
  967.     moveq    #-2,d2
  968.     jsr    _LVOLock(a6)    lock path
  969.     move.b    d3,(a2)        replace null-char by old one
  970.     move.l    d0,d7        save lock
  971.     beq.s    .C
  972.     move.l    d0,d1
  973.     lea    blockbase(a5),a0
  974.     move.l    a0,d2
  975.     jsr    _LVOExamine(a6)        get dir
  976.     tst.l    d0
  977.     beq.s    .G
  978.     tst.l    fib_DirEntryType(a5)
  979.     bpl.s    wdhcpl        if plus,is directory
  980. .G    move.l    d7,d1
  981.     jsr    _LVOUnLock(a6)
  982. .C    rts            an error occured
  983. wdhcpl    bsr    fibexnx        repeat to search whole dir
  984.     tst.l    d0        next filename or dirname
  985.     beq.s    endcpl
  986.     lea    fib_FileName(a5),a0
  987.     move.l    a0,a3
  988.     lea    ignoreit(a5),a1
  989.     tst.b    (a1)
  990.     beq.s    .F
  991.     bsr    wildmatch        ;wildcheck
  992.     tst.b    d0
  993.     beq.s    wdhcpl
  994. .F    move.l    a3,a0
  995.     move.l    a2,a1
  996.     move.l    d6,d2
  997.     subq.l    #1,d2
  998. .A    move.b    (a0)+,d0
  999.     move.b    (a1)+,d1
  1000.     bsr    compD1D0nocase        does it fit ?
  1001.     bne.s    wdhcpl
  1002.     dbra    d2,.A
  1003.     lea    temp2buf(a5),a0
  1004.     tst.b    (a0)
  1005.     bne.s    .B
  1006. .C    move.b    (a3)+,(a0)+    first time: copy filename
  1007.     bne.s    .C
  1008.     move.b    #" ",-1(a0)    add a space at the end (files)
  1009.     clr.b    (a0)
  1010.     tst.l    fib_DirEntryType(a5)
  1011.     bmi.s    .E        if plus,is directory
  1012.     move.b    #"/",-1(a0)    add a / at the end (dirs)
  1013. .E    bra.s    wdhcpl
  1014. .B    move.b    (a0)+,d0
  1015.     move.b    (a3)+,d1
  1016.     bsr    compD1D0nocase    next time: find longest common part
  1017.     bne.s    .D
  1018.     tst.b    -1(a0)
  1019.     beq.s    .D
  1020.     tst.b    -1(a3)
  1021.     bne.s    .B
  1022. .D    clr.b    -1(a0)
  1023.     bra.s    wdhcpl        repeat with all filenames
  1024.  
  1025. endcpl    move.l    d7,d1
  1026.     jsr    _LVOUnLock(a6)
  1027.     lea    temp2buf(a5),a0
  1028.     moveq    #-1,d3
  1029. .G    addq.l    #1,d3
  1030.     tst.b    (a0)+
  1031.     bne.s    .G
  1032.     subq.l    #1,a0
  1033.     sub.l    d6,d3        D3=length
  1034.     bmi.s    .H
  1035.     cmp.w    #SHELLINE_SIZE-2,d4    make sure line is not too long
  1036.     bhi.s    .H
  1037.     lea    shelline(a5),a1    ethel
  1038.     lea    1(a1,d4.w),a3    A3=linmax
  1039.     move.l    a3,a2
  1040.     add.l    d3,a2        A2=linmax+length
  1041.     lea    0(a1,d5.w),a1    linhere
  1042. .A    move.b    -(a3),-(a2)    insert chars into shelline
  1043.     cmp.l    a3,a1
  1044.     bne.s    .A
  1045.     move.l    d3,d0
  1046.     add.l    d6,d0    
  1047.     bra.s    .C
  1048. .D    move.b    -(a0),-(a2)    copy found filename
  1049. .C    dbra    d0,.D
  1050.     add.l    d3,d5
  1051.     add.l    d3,d4
  1052.     lea    shelline(a5),a2
  1053.     bsr    gimme3        print shelline
  1054.     move.l    d4,d0
  1055.     sub.l    d5,d0
  1056.     lea    tempbuf(a5),a1
  1057.     move.l    a1,a0
  1058.     bra.s    .E
  1059. .F    move.w    #$9b<<8+"D",(a0)+    left cursor
  1060. .E    dbra    d0,.F        
  1061.     clr.b    (a0)
  1062.     bsr    pr_string    restore cursorpos
  1063. .B    rts
  1064. .H    move.l    intuibase(a5),a6
  1065.     suba.l    a0,a0
  1066.     jsr    _LVODisplayBeep(a6)
  1067.     move.l    dosbase(a5),a6
  1068.     rts
  1069.  
  1070.  
  1071. get_one_char
  1072. read_kbd
  1073. ;    moveq    #0,d0
  1074. ;    moveq    #0,d1
  1075. ;    move.l    4.w,a6
  1076. ;    bset    #SIGBREAKB_CTRL_F,d1
  1077. ;    jsr    _LVOSetSignal(a6)
  1078. ;    btst    #SIGBREAKB_CTRL_F,d0
  1079. ;    bne    cloga
  1080. ;    move.l    dosbase(a5),a6
  1081.     lea    tempbytes(a5),a0
  1082.     move.l    a0,d2
  1083.     move.l    inhandle(a5),d1
  1084.     beq    cloga
  1085.     moveq    #1,d3
  1086.     jsr    _LVORead(a6)
  1087.     tst.l    d0
  1088.     bmi    cloga
  1089.     beq    cloga
  1090.     move.b    tempbytes(a5),d6
  1091.     rts
  1092.  
  1093. * A1 pts to past, d0=nost
  1094. gimme    lea    shelline(a5),a2
  1095.     move.l    d0,nost(a5)
  1096.     cmp.l    now(a5),d0
  1097.     bne.s    gimme2
  1098.     moveq    #0,d4        clear linmax
  1099.     moveq    #0,d5        clear linhere
  1100.     lea    delete_line(pc),a1
  1101.     bsr    pr_string
  1102.     bsr    pr_prompt
  1103.     rts
  1104. gimme2    moveq    #0,d5        linhere = 0
  1105.  
  1106. gimme5    addq.l    #1,d0        copy to shelline
  1107.     and.l    #HISTORY_SIZE-1,d0
  1108.     cmp.b    #LF,0(a1,d0.l)
  1109.     beq.s    .A
  1110.     move.b    0(a1,d0.l),0(a2,d5.l)
  1111.     addq.l    #1,d5
  1112.     bra.s    gimme5
  1113. .A    move.l    d5,d4        linmax=linhere
  1114. gimme3    lea    delete_line(pc),a1
  1115.     bsr    pr_string
  1116.     bsr    pr_prompt
  1117.     clr.b    0(a2,d4.l)    clear last
  1118.     move.l    a2,a1
  1119.     bra    pr_string
  1120.  
  1121.  
  1122. * READ TEXT LINE from keyboard or script into buffer pointed to by a0,
  1123. * and clear last byte. NOTE A0 is essentially ignored, and shelline is the
  1124. * assumed address. Return with a0 same, and d0=length of text read
  1125. type_in    tst.b    scflag(a5)        ;check whether we're doing a script
  1126.     bne    scr_in
  1127. type_in2    move.l a0,-(sp)
  1128. type_in3    moveq    #0,d5        D5=linhere
  1129.     moveq    #0,d4        D4=linmax
  1130. next_ch    bsr    get_one_char
  1131.     cmp.b    #$9b,d6
  1132.     bne    not_csi
  1133.     clr.l    gather_ptr(a5)
  1134. fetch_csi    bsr    get_one_char
  1135.     lea    gather(a5),a0
  1136.     move.l    gather_ptr(a5),d0
  1137.     move.b    d6,0(a0,d0.l)        ;save byte from CSI sequence.
  1138.     addq.l    #1,gather_ptr(a5)
  1139.     moveq    #32,d1
  1140.     cmp.l    d1,d0
  1141.     blo.s    .A
  1142.     clr.l    gather_ptr(a5)
  1143. .A    cmp.b    #'@',d6
  1144.     blo.s    fetch_csi        ;keep gathering if char < @
  1145.     cmp.b    #'~',d6
  1146.     bhi.s    fetch_csi        ;keep gathering if char > ~
  1147.  
  1148.     cmp.b    #"|",d6        CHECK CLOSE GADGET
  1149.     bne.s    not_cloga
  1150. cloga    move.l    dosbase(a5),a6    totally-exit-routine
  1151.     move.l    errorstack(a5),sp    ;kill return address on stack
  1152.     tst.l    outhandle(a5)
  1153.     beq    .B
  1154.     bsr    raw_off
  1155. .B    moveq    #-1,d7
  1156.     tst.b    scflag(a5)
  1157.     beq.s    .A
  1158.     bsr    kill_script
  1159. .A    rts
  1160.  
  1161. not_cloga
  1162.     cmp.b    #'D',d6        CHECK LEFT ARROW    <CSI>D
  1163.     bne.s    not_left
  1164.     tst.l    d5
  1165.     beq.s    not_left
  1166.     subq.l    #1,d5
  1167.     lea    left_cursor(pc),a1
  1168.     bsr    pr_string
  1169.     bra    next_ch
  1170.     
  1171. not_left    cmp.b    #'Z',d6    CHECK TAB & SHIFT    <CSI> Z
  1172.     bne.s    not_tab_left
  1173. v_buffer
  1174.     tst.l    ReviewSize(a5)
  1175.     beq    next_ch
  1176.     sub.l    a3,a3
  1177.     bsr    viewbuffer
  1178.     move.l    errorstack(a5),sp
  1179.     bra    chorus
  1180.  
  1181. not_tab_left    cmp.b    #'A',d6
  1182.     bne.s    not_sh_left
  1183.     cmp.b    #' ',gather(a5)    CHECK SHIFT LEFT ARROW    <CSI> A
  1184.     bne.s    not_sh_left
  1185.     move.l    d5,d0
  1186.     lea    tempbuf(a5),a1
  1187.     move.l    a1,a0
  1188.     bra.s    .A
  1189. .B    move.w    #$9b<<8+"D",(a0)+    left cursor
  1190. .A    dbra    d0,.B
  1191.     clr.b    (a0)
  1192.     bsr    pr_string
  1193.     moveq    #0,d5
  1194.     bra    next_ch
  1195.  
  1196. not_sh_left
  1197.     cmp.b    #'C',d6        CHECK RIGHT ARROW    <CSI>C
  1198.     bne.s    not_right
  1199.     cmp.l    d4,d5
  1200.     bhs.s    not_right
  1201.     addq.l    #1,d5
  1202.     lea    right_cursor(pc),a1
  1203.     bsr    pr_string
  1204.     bra    next_ch
  1205.  
  1206. not_right    cmp.b    #'@',d6
  1207.     bne.s    not_sh_right
  1208.     cmp.b    #' ',gather(a5)    CHECK SHIFT RIGHT ARROW    <CSI> @
  1209.     bne.s    not_sh_right
  1210.     move.l    d4,d0
  1211.     sub.l    d5,d0
  1212.     lea    tempbuf(a5),a1
  1213.     move.l    a1,a0
  1214.     bra.s    .A
  1215. .B    move.w    #$9b<<8+"C",(a0)+    right cursor
  1216. .A    dbra    d0,.B
  1217.     clr.b    (a0)
  1218.     bsr    pr_string
  1219.     move.l    d4,d5
  1220.     bra    next_ch
  1221.  
  1222. not_sh_right
  1223.     cmp.b    #'A',d6        CHECK UP ARROW
  1224.     bne.s    not_up
  1225.     lea    past(a5),a1
  1226.     move.l    nost(a5),d0
  1227.     cmp.l    then(a5),d0
  1228.     beq.s    .B
  1229. .A    subq.l    #1,d0
  1230.     and.l    #HISTORY_SIZE-1,d0        WRAP AROUND
  1231.     cmp.b    #LF,0(a1,d0.l)
  1232.     bne.s    .A
  1233. .B    bsr    gimme
  1234.     bra    next_ch
  1235.  
  1236. not_up    cmp.b    #'B',d6        CHECK DOWN ARROW
  1237.     bne.s    not_down
  1238. up_bit    lea    past(a5),a1    CALLED BY SHIFT DOWN BIT
  1239.     move.l    nost(a5),d0
  1240.     cmp.l    now(a5),d0
  1241.     beq.s    .B
  1242. .A    addq.l    #1,d0
  1243.     and.l    #HISTORY_SIZE-1,d0
  1244.     cmp.b    #LF,0(a1,d0.l)
  1245.     bne.s    .A
  1246. .B    bsr    gimme
  1247.     bra    next_ch
  1248.  
  1249. not_down    cmp.b    #'T',d6        CHECK SHIFT UP
  1250.     bne    not_sh_up
  1251.     lea    past(a5),a1
  1252.     tst.l    d5
  1253.     bne.s    search_his
  1254.     move.l    then(a5),nost(a5)    nost = then (the top)
  1255.     move.l    nost(a5),d0
  1256.     bsr    gimme
  1257.     bra    next_ch
  1258. search_his            ;search shelline in history    V2.0
  1259.     move.l    nost(a5),d0
  1260. .C    cmp.l    then(a5),d0
  1261.     bne.s    .A
  1262.     move.l    nost(a5),d0
  1263.     bra.s    end_seh
  1264. .A    subq.l    #1,d0
  1265.     and.l    #HISTORY_SIZE-1,d0
  1266.     cmp.b    #LF,0(a1,d0.l)
  1267.     bne.s    .A
  1268.  
  1269.     lea    shelline(a5),a0
  1270.     move.l    d5,d1
  1271.     subq.l    #1,d1
  1272.     move.l    d0,d2
  1273. .D    addq.l    #1,d2
  1274.     and.l    #HISTORY_SIZE-1,d2
  1275.     movem.l    d0/d1,-(sp)
  1276.     move.b    0(a1,d2.l),d0
  1277.     move.b    (a0),d1
  1278.     bsr    compD1D0nocase
  1279.     movem.l    (sp)+,d0/d1
  1280.     bne.s    .C
  1281.     addq.l    #1,a0
  1282.     dbra    d1,.D
  1283. end_seh    move.l    d5,d1        save d5
  1284.     bsr    gimme
  1285.     move.l    d5,d0
  1286.     sub.l    d1,d0
  1287.     bmi.s    .C
  1288.     lea    tempbuf(a5),a1
  1289.     move.l    a1,a0
  1290.     bra.s    .A
  1291. .B    move.w    #$9b<<8+"D",(a0)+    left cursor
  1292. .A    dbra    d0,.B
  1293.     clr.b    (a0)
  1294.     bsr    pr_string
  1295.     move.l    d1,d5
  1296. .C    bra    next_ch
  1297.  
  1298.  
  1299. not_sh_up    cmp.b    #'S',d6        CHECK SHIFT DOWN
  1300.     bne.s    not_sh_down
  1301.     move.l    now(a5),nost(a5)    nost = now (the bottom)
  1302.     bra    up_bit
  1303.     
  1304. not_sh_down            ;NOTE V1.05
  1305.     cmp.b    #'~',d6        CHECK FUNCTION KEYS AND HELP KEY
  1306.     bne    next_ch
  1307.     cmp.b    #'?',gather(a5)
  1308.     bne.s    process_the_func_key
  1309.     lea    help_ret(pc),a1
  1310.     move.l    d0,-(sp)    need crap on stack to call print_def
  1311.     bsr    print_def    will rip last 2 addrs off stack
  1312. * never gets to this line
  1313. process_the_func_key
  1314.     bsr    translate_func_key
  1315.     bra    next_ch
  1316.         
  1317. * Was not a CSI code
  1318. not_csi    cmp.b    ctrl_codes+6(a5),d6        CHECK ESCAPE (ctrl+[)
  1319.     beq    cloga        exit immediately
  1320.  
  1321.     cmp.b    ctrl_codes+7(a5),d6    CHECK TAB (ctrl+I)
  1322.     bne.s    not_tab_right
  1323. .A    cmp.l    d4,d5
  1324.     bhs    next_ch
  1325.     addq.l    #1,d5
  1326.     lea    right_cursor(pc),a1
  1327.     bsr    pr_string
  1328.     lea    shelline-1(a5),a0
  1329.     bsr    tab_check
  1330.     bne.s    .A
  1331.     bra    next_ch
  1332.     
  1333. not_tab_right
  1334.     cmp.b    ctrl_codes+8(a5),d6        CHECK CTRL Y
  1335.     beq    v_buffer        same as shift&tab
  1336.  
  1337.     cmp.b    ctrl_codes+9(a5),d6        CHECK BACKSPACE (ctrl+H)
  1338.     bne.s    not_bs
  1339.     tst.l    d5
  1340.     beq.s    not_bs
  1341.     subq.l    #1,d5
  1342.     lea    backspace_it(pc),a1
  1343.     bsr    pr_string
  1344.     bsr    del_str
  1345.     bra    next_ch
  1346.  
  1347. del_str    lea    shelline(a5),a4
  1348.     lea    SHELLINE_SIZE+shelline(a5),a1    NOTE SHELLINE SIZE!!!
  1349.     lea    0(a4,d5.w),a0
  1350.     lea    1(a0),a2
  1351. .A    move.b    (a2)+,(a0)+
  1352.     cmp.l    a2,a1
  1353.     bne.s    .A
  1354.     subq.l    #1,d4
  1355.     rts
  1356.  
  1357. not_bs    cmp.b    #$7f,d6                CHECK DELETE
  1358.     bne.s    not_del
  1359.     cmp.l    d4,d5
  1360.     bhs.s    not_del
  1361.     lea    delete_it(pc),a1
  1362.     bsr    pr_string
  1363.     bsr    del_str
  1364.     bra    next_ch
  1365.     
  1366. not_del    cmp.b    ctrl_codes+5(a5),d6        CHECK CTRL X
  1367.     bne.s    not_ctrlx
  1368.     moveq    #0,d5        delete shelline
  1369.     moveq    #0,d4
  1370.     lea    delete_line2(pc),a1
  1371.     bsr    pr_string
  1372.     bsr    pr_prompt
  1373.     bra    next_ch
  1374.     
  1375. not_ctrlx
  1376.     cmp.b    ctrl_codes+3(a5),d6        CHECK CTRL E
  1377.     bne.s    not_ctrle
  1378. .A    cmp.l    d4,d5        delete to end of line
  1379.     bhs    next_ch
  1380.     lea    delete_it(pc),a1
  1381.     bsr    pr_string
  1382.     bsr    del_str
  1383.     bra.s    .A
  1384.     
  1385. not_ctrle
  1386.     cmp.b    ctrl_codes+2(a5),d6        CHECK CTRL S
  1387.     bne.s    not_ctrls
  1388. .A    tst.l    d5        delete to start of line
  1389.     beq    next_ch
  1390.     subq.l    #1,d5
  1391.     lea    backspace_it(pc),a1
  1392.     bsr    pr_string
  1393.     bsr    del_str
  1394.     bra.s    .A
  1395.     
  1396. not_ctrls
  1397.     cmp.b    ctrl_codes+1(a5),d6        CHECK CTRL W
  1398.     bne.s    not_ctrlw
  1399. .A    tst.l    d5        delete last word
  1400.     beq    next_ch
  1401.     subq.l    #1,d5
  1402.     lea    backspace_it(pc),a1
  1403.     bsr    pr_string
  1404.     bsr    del_str
  1405.     lea    shelline-1(a5),a0
  1406.     bsr    tab_check
  1407.     bne.s    .A
  1408.     bra    next_ch
  1409.  
  1410. not_ctrlw
  1411.     cmp.b    ctrl_codes+0(a5),d6        CHECK CTRL Q
  1412.     bne.s    not_ctrlq
  1413. .A    cmp.l    d4,d5        delete next word
  1414.     bhs    next_ch
  1415.     lea    delete_it(pc),a1
  1416.     bsr    pr_string
  1417.     bsr    del_str
  1418.     lea    shelline+0(a5),a0
  1419.     bsr    tab_check
  1420.     bne.s    .A
  1421.     bra    next_ch
  1422.  
  1423. not_ctrlq
  1424.     cmp.b    ctrl_codes+4(a5),d6        CHECK CTRL A
  1425.     bne.s    not_ctrla
  1426.     tst.l    d5
  1427.     beq    next_ch
  1428.     movem.l    d3/d6/d7/a3,-(sp)
  1429.     bsr    complet        complete filename
  1430.     movem.l    (sp)+,d3/d6/d7/a3
  1431.     bra    next_ch
  1432.  
  1433. not_ctrla
  1434.     cmp.b    ctrl_codes+10(a5),d6        CHECK CTRL J
  1435.     bne.s    not_ctrlj
  1436.     bsr    do_cr2
  1437.     move.l    errorstack(a5),sp
  1438.     bra    chorus
  1439.  
  1440. not_ctrlj
  1441.     cmp.b    ctrl_codes+12(a5),d6        CHECK CTRL L
  1442.     bne.s    not_ctrll
  1443.     lea    clrtx(pc),a1
  1444.     bsr    pr_string    clear window
  1445.     move.l    errorstack(a5),sp
  1446.     bra    chorus
  1447.  
  1448. not_ctrll
  1449.     cmp.b    ctrl_codes+13(a5),d6        CHECK CTRL R
  1450.     bne.s    not_ctrlr
  1451. tab_left tst.l    d5
  1452.     beq    next_ch
  1453.     subq.l    #1,d5
  1454.     lea    left_cursor(pc),a1
  1455.     bsr    pr_string
  1456.     lea    shelline-1(a5),a0
  1457.     bsr    tab_check
  1458.     bne.s    tab_left
  1459.     bra    next_ch
  1460.  
  1461. tab_check cmp.b    #' ',(a0,d5.w) words are separated by / . : or space
  1462.     beq.s    .A
  1463.     cmp.b    #':',(a0,d5.w)
  1464.     beq.s    .A
  1465.     cmp.b    #'.',(a0,d5.w)
  1466.     beq.s    .A
  1467.     cmp.b    #'/',(a0,d5.w)
  1468. .A    rts
  1469.  
  1470. not_ctrlr
  1471.     cmp.b    ctrl_codes+14(a5),d6        CHECK CTRL V
  1472.     bne.s    not_ctrlv
  1473.     lea    past(a5),a2
  1474.     move.l    now(a5),d3
  1475.     move.l    #HISTORY_SIZE,d2
  1476.     sub.l    a3,a3
  1477.     bsr    viewhist
  1478.     move.l    errorstack(a5),sp
  1479.     bra    chorus
  1480.  
  1481. not_ctrlv
  1482.     cmp.b    ctrl_codes+11(a5),d6        CHECK CTRL M
  1483.     beq.s    do_cr
  1484.     cmp.b    #$d,d6        CHECK CR
  1485.     bne    no_cr
  1486. do_cr    move.l    (sp)+,a2
  1487. do_cr2    lea    return_it(pc),a1
  1488.     bsr    pr_string
  1489.     lea    shelline(a5),a4
  1490.     move.b    #LF,0(a4,d4.w)    HACK JOB    (MUST END IN LF 0)
  1491.     clr.b    1(a4,d4.w)    FOR ALIAS STUFF
  1492.     tst.l    d4        CHECK IF NOTHING TYPED
  1493.     bne.s    history_it
  1494.     bsr    pr_prompt        IF JUST HIT RETURN, THEN START AGAIN
  1495.     move.l    a2,-(sp)
  1496.     bra    type_in3
  1497. history_it
  1498.     lea    past(a5),a1    CHECK IF LAST ENTRY IS SAME AS CURRENT
  1499.     move.l    now(a5),d0
  1500.     cmp.l    then(a5),d0
  1501.     beq.s    .B
  1502.     move.l    d0,nost(a5)
  1503. .A    subq.l    #1,d0        FIND LAST
  1504.     and.l    #HISTORY_SIZE-1,d0    WRAP AROUND
  1505.     cmp.b    #LF,0(a1,d0.l)
  1506.     bne.s    .A
  1507.     lea    (a4),a0
  1508.     bra.s    .C
  1509. .D    cmp.b    #LF,d1        COMPARE LAST TO SHELLINE
  1510.     beq    finland
  1511. .C    addq.l    #1,d0
  1512.     and.l    #HISTORY_SIZE-1,d0
  1513.     move.b    (a0)+,d1
  1514.     cmp.b    0(a1,d0.l),d1
  1515.     beq.s    .D
  1516.  
  1517. .B    move.l    a4,a3    lin    COPY LINE TO HISTORY  BUFFER
  1518.     move.l    now(a5),d3    pts to the last LF
  1519.  
  1520. .E    addq.l    #1,d3
  1521.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  1522.     move.b    (a3)+,d0
  1523.     move.b    d0,0(a1,d3.l)
  1524.     cmp.b    #LF,d0
  1525.     bne.s    .E
  1526. ;dumped_hist
  1527.     move.l    d3,nost(a5)    nost = now
  1528.     move.l    d3,now(a5)
  1529.     move.l    then(a5),d1
  1530.     cmp.b    #LF,0(a1,d1.l)
  1531.     bne.s    .G    BRANCH IF WRAPPED AROUND
  1532.     cmp.l    d3,d1
  1533.     bne.s    finland    BRANCH IF THEN = (10) & THEN <> NOW
  1534. .G    
  1535. *    move.l    d3,then(a5)    then=now
  1536. .H    addq.l    #1,d3    SEARCH FOR NEXT LF (NEW TOP OF HISTORY)
  1537.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  1538.     move.b    0(a1,d3.l),d0
  1539.     cmp.b    #LF,d0
  1540.     bne.s    .H        ***
  1541.     move.l    d3,then(a5) SET NEW THEN (TOP OF HISTORY)
  1542.  
  1543. ******* 
  1544. finland    tst.b    scflag(a5)
  1545.     bne.s    .D
  1546.     clr.b    noreview_flag(a5)    write to review-buffer
  1547.     lea    prompt_string(a5),a1
  1548.     move.l    a1,d2
  1549.     moveq    #-1,d3
  1550. .E    addq.l    #1,d3
  1551.     tst.b    (a1)+
  1552.     bne.s    .E
  1553.     bsr    toreview
  1554.     move.l    a2,d2
  1555.     move.l    d4,d3
  1556.     addq.l    #1,d3
  1557.     bsr    toreview
  1558. .D    move.l    a2,a0
  1559.     move.l    d4,d0
  1560.     rts
  1561.  
  1562. no_cr    cmp.b    #' ',d6        check for special chars
  1563.     blo.w    dunno_it
  1564.     cmp.b    #'~',d6
  1565.     bls.s    nochkum
  1566. chkum    moveq    #umlautend-umlaut-1,d0    V2.0
  1567.     lea    umlaut(pc),a0
  1568. .A    cmp.b    (a0)+,d6
  1569.     beq.s    nochkum
  1570.     dbra    d0,.A
  1571.     bra    dunno_it
  1572. nochkum    bsr    ins_char
  1573. dunno_it bra    next_ch
  1574.  
  1575. * insert a char in the shelline
  1576. ins_char cmp.w    #SHELLINE_SIZE-2,d4    make sure line is not too long
  1577.     bhi.w    dunno_it
  1578.     lea    tempbuf(a5),a1
  1579.     move.w    #$9b<<8+"@",(a1)
  1580.     clr.b    3(a1)
  1581.     move.b    d6,2(a1)    shove printable char after insert seq
  1582.     bsr    pr_string        insert space for char
  1583.     lea    shelline(a5),a1    ethel
  1584.     lea    1(a1,d4.w),a0    linmax
  1585.     lea    1(a0),a2        A2=linmax+1
  1586.     lea    0(a1,d5.w),a1    linhere
  1587. tc_1    move.b    -(a0),-(a2)    insert char into shelline
  1588.     cmp.l    a0,a1
  1589.     bne.s    tc_1
  1590. plop_ch    lea    shelline(a5),a4
  1591.     move.b    d6,0(a4,d5.w)
  1592.     addq.l    #1,d5
  1593.     addq.l    #1,d4
  1594.     rts
  1595.  
  1596. * TRANSLATE FUNC CODE TO F1,F2 ETC AND SET UP POINTERS
  1597. translate_func_key
  1598.     lea    gather(a5),a0
  1599.     move.l    gather_ptr(a5),d0
  1600.     cmp.b    #3,d0        CHECK IF TWO CODES EG '12'
  1601.     beq    process_shift_func
  1602. unshifted_func_key
  1603.     cmp.b    #2,d0
  1604.     bne    translate_func_fail
  1605.     move.b    (A0),d0
  1606.     moveq    #'f',d1
  1607. act_sh    bsr    convert_to_set_name
  1608.     bsr    search_sets    returns D0 pointer to set
  1609.     bsr    print_func_defn
  1610.     rts
  1611. process_shift_func
  1612.     move.b    1(A0),d0
  1613.     moveq    #'F',d1
  1614.     bra.s    act_sh
  1615. translate_func_fail
  1616.     rts
  1617.  
  1618. *d0=set ptr
  1619. print_func_defn
  1620.     tst.l    d0
  1621.     beq    do_not_print_func
  1622.     move.l    d0,a1
  1623.     lea    set_defn(a1),a1
  1624. print_def    lea    shelline(a5),a2
  1625.     bra.s    .B
  1626. .A    addq.l    #1,d5        copy defn to shelline
  1627. .B    move.b    (a1)+,0(a2,d5.l)
  1628.     bne.s    .A
  1629.     cmp.b    #'M',-1(a2,d5.l)    check for auto return ^M
  1630.     bne.s    .C
  1631.     cmp.b    #'^',-2(a2,d5.l)
  1632.     bne.s    .C
  1633.     subq.l    #2,d5
  1634.     move.l    d5,d4
  1635.     bsr    gimme3        print it
  1636.     movem.l    (sp)+,d0-d1    get rid of last 2 return addresses
  1637.     bra    do_cr        do a carriage return
  1638.  
  1639. .C    move.l    d5,d4        linmax=linhere
  1640.     bra    gimme3        show prompt,new line
  1641. do_not_print_func
  1642.     rts
  1643.     
  1644. convert_to_set_name
  1645.     lea    set_search_string(a5),a1
  1646.     move.b    d1,(a1)+
  1647.     addq.b    #1,d0
  1648.     move.b    d0,(a1)+
  1649.     cmp.b    #':',d0
  1650.     bne    not_func10
  1651.     move.b    #'1',-1(a1)
  1652.     move.b    #'0',(a1)+
  1653. not_func10
  1654.     clr.b    (a1)
  1655.     rts
  1656.  
  1657. search_sets
  1658. * uses set_search_string, EXIT: D0 ptr to the associated set. D1 pts to prior set
  1659. * RETURN D0=0 IF NOT FOUND.
  1660.     movem.l    d2-d4/a1-a2,-(sp)
  1661.     lea    set_search_string(a5),a1
  1662.     move.l    a1,d2
  1663.     lea    first_set_defn(a5),a2
  1664.     move.l    a2,d4        NOTE PRIOR SET 
  1665.     move.l    (a2),d3
  1666. search_next_set
  1667.     beq    .B
  1668.     move.l    d3,a2
  1669.     lea    set_name(a2),a2    A2=current set name
  1670.     move.l    d2,a1        A1=name to match
  1671.     bra.s    .C
  1672. .A    tst.b    d0
  1673.     beq.s    .B
  1674. .C    move.b    (a1)+,d0
  1675.     move.b    (a2)+,d1
  1676.     bsr    compD1D0nocase
  1677.     beq.s    .A
  1678.  
  1679.     move.l    d3,a2
  1680.     move.l    d3,d4
  1681.     move.l    (a2),d3
  1682.     bra    search_next_set
  1683. .B    move.l    d3,d0
  1684.     move.l    d4,d1
  1685.     
  1686.     movem.l    (sp)+,d2-d4/a1-a2
  1687.     rts
  1688.  
  1689.  
  1690. * DO SCRIPT FILE STUFF   ENTRY A0 -> input line
  1691. scr_in    movem.l    a0-a1/a6,-(sp)
  1692.     clr.b    ctrl_c_flag(a5)
  1693.     move.l    4.w,a6
  1694.     moveq    #0,d0
  1695.     moveq    #0,d1
  1696.     bset    #SIGBREAKB_CTRL_D,d1
  1697.     jsr    _LVOSetSignal(a6)
  1698.     movem.l    (sp)+,a0-a1/a6
  1699.     btst    #SIGBREAKB_CTRL_D,d0    ;checks if CTRL_D pressed
  1700.     beq.s    .B
  1701.     move.l    a0,-(sp)
  1702.     lea    breaktx(pc),a0
  1703.     bsr    new_print
  1704.     move.b    #1,ctrl_c_flag(a5)
  1705.     move.l    (sp)+,a0
  1706.     bra.s    terminate_script
  1707. .B    move.l    scsize(a5),d0    ;read a line from the script file
  1708.     add.l    scaddr(a5),d0
  1709.     cmp.l    scptr(a5),d0
  1710.     bgt.s    scr_in2
  1711. terminate_script
  1712.     bsr    kill_script
  1713.     bsr    pr_prompt
  1714.     bra    type_in2
  1715. scr_in2    move.l    a0,a2
  1716.     moveq    #0,d0
  1717.     move.l    scptr(a5),a1
  1718. .A    move.b    (a1)+,(a2)+
  1719.     addq.l    #1,d0
  1720.     cmp.b    #LF,(a1)
  1721.     bne.s    .A
  1722.     move.b    (a1)+,(a2)+    LF
  1723.     clr.b    (a2)        0
  1724.     move.l    a1,scptr(a5)
  1725.     rts
  1726.  
  1727. kill_script
  1728.     move.l    a0,-(sp)
  1729.     clr.b    scflag(a5)    clean up if no more lines left
  1730.     clr.b    if_flag(a5)    Make sure if structure ends
  1731.     clr.b    goto_flag(a5)    Make sure goto is terminated
  1732.     move.l    scaddr(a5),a1
  1733.     move.l    scsize(a5),d0
  1734.     bsr    givemem
  1735.     move.l    (sp)+,a0
  1736.     rts
  1737.  
  1738. ** SAME AS compare_strings EXCEPT
  1739. ** ALLOWS FOR A1 ENDING IN LF
  1740. lf_compare_strings
  1741.     movem.l    d0-d1/a0-a1,-(sp)
  1742.     bra.s    .A
  1743. .B    tst.b    d0
  1744.     beq.s    .C    RETURN EQ
  1745. .A    move.b    (a0)+,d0
  1746.     move.b    (a1)+,d1
  1747.     bsr    compD1D0nocase
  1748.     beq.s    .B    return NE
  1749.     tst.b    d0
  1750.     bne.s    .C
  1751.     cmp.b    #LF,d1
  1752. .C    movem.l    (sp)+,d0-d1/a0-a1
  1753.     rts
  1754.  
  1755.     
  1756. ** CASE INDEPENDENT STRING COMPARE. COMPARES (A0) TO (A1)
  1757. ** RETURN EQ IF SAME
  1758. compare_strings
  1759.     movem.l    d0-d1/a0-a1,-(sp)
  1760.     bra.s    .A
  1761. .B    tst.b    d0
  1762.     beq.s    .C    RETURN EQ
  1763. .A    move.b    (a0)+,d0
  1764.     move.b    (a1)+,d1
  1765.     bsr    compD1D0nocase
  1766.     beq.s    .B    return NE
  1767. .C    movem.l    (sp)+,d0-d1/a0-a1
  1768.     rts
  1769.  
  1770.     
  1771. * COPY STRING :copys null ending string from A0 to A1, Return with D0=length+1
  1772. cp_string    movem.l a0-a1,-(sp)
  1773.     moveq #0,d0
  1774. cp_str1    addq.l #1,d0
  1775.     move.b (a0)+,(a1)+
  1776.     bne.s cp_str1
  1777.     movem.l (sp)+,a0-a1
  1778.     rts
  1779.  
  1780. *Get line of text and seperate into up to 6 parameters    
  1781. get_line    addq.l    #1,count_line(a5)
  1782.     bsr    clr_parms
  1783.     lea    shelline(a5),a0
  1784.     tst.b    mult_comm_flag(a5) SKIP PROMPT IF SCRIPT OR MULT COMMANDS
  1785.     bne.s    .A
  1786.     tst.b    scflag(a5)
  1787.     bne.s    .B
  1788.     addq.b    #1,noreview_flag(a5)
  1789.     bsr    pr_prompt
  1790. .B    bsr    type_in    NOTE HISTORY STUFF ASSUMES SHELLINE HOLDS THE LINE
  1791.     cmp.b    #';',(a0)        ;is 1st character a ';'
  1792.     beq.s    .C
  1793.     cmp.b    #'*',(a0)
  1794.     beq.s    .C
  1795.     cmp.b    #'#',(a0)
  1796.     bne.s    .A
  1797. .C    move.l    (sp)+,d0        ;kill return address
  1798.     bra    chorus        ;do next line if comment
  1799. .A    bsr    handle_mult_comms    MAYBE ALTER A0
  1800.     bsr    handle_command_alias
  1801. *    move.l    a0,-(sp)        TEST STUFF
  1802. *    move.l    a0,a1
  1803. *    bsr    pr_string
  1804. *    move.l    (sp)+,a0
  1805.     bsr    handle_redirection
  1806. gl16    lea    parm1(a5),a2 do 1st parm seperate to establish CLI residue
  1807.     bsr    get_parm
  1808.     move.l    a0,d7
  1809.     tst.l    d2
  1810.     beq    gl3            if no parms at all
  1811.     tst.b    goto_flag(a5)    CHECK IF IN GOTO SEARCH MODE
  1812.     beq.s    test_ifs
  1813.     move.l    a0,-(sp)
  1814.     lea    label_tx(pc),a0
  1815.     bsr    lf_compare_strings
  1816.     bne    skipline
  1817.     move.l    (sp)+,a0
  1818.  
  1819. * Script-IF handling
  1820. test_ifs    tst.b    if_flag(a5)    0 if if encountered earlier
  1821.     beq.s    no_ifs
  1822.     tst.b    if_condition_flag(a5)    0 if condition TRUE
  1823.     beq    no_ifs
  1824. if_false    move.l    a0,-(sp)        push ptr to next
  1825.     lea    else_tx(pc),a0
  1826.     bsr    lf_compare_strings
  1827.     bne.s    try_endif
  1828.     not.b    if_condition_flag(a5)    flip condition flag
  1829. skipline    movem.l    (sp)+,d0-d1    get rid of last plus return address
  1830.     bra    chorus
  1831. try_endif    lea    endif_tx(pc),a0
  1832.     bsr    lf_compare_strings
  1833.     bne.s    skipline
  1834.     clr.b    if_flag(a5)
  1835.     bra.s    skipline
  1836.  
  1837. no_ifs    move.l    a1,(a2)+    save address of parm1
  1838.  
  1839.     lea    CLIbuf(a5),a1
  1840.     bra.s    .A
  1841. .B    move.b    d0,(a1)+
  1842. .A    move.b    (a0)+,d0    copy sudoCLIresidue out
  1843.     cmp.b    #LF,d0        only look for LF end
  1844.     bne.s    .B
  1845.     clr.b    (a1)        null end the copy
  1846.     move.l    d7,a0
  1847.     lea    endofparms(a5),a4    establish end of parms block
  1848. gl4    bsr    get_parm        
  1849.     tst.l    d2
  1850.     beq.s    gl3
  1851.     move.l    a1,(a2)+
  1852.     cmp.l    a2,a4        get out if more than 25 parms
  1853.     bne.s    gl4
  1854.     clr.b    (a0)        make sure parm ends in 0
  1855. gl3    rts
  1856.  
  1857. endifz    clr.b    if_flag(a5)
  1858.     moveq    #RETURN_OK,d0
  1859.     rts
  1860. elsez    not.b    if_condition_flag(a5)
  1861.     moveq    #RETURN_OK,d0
  1862.     rts
  1863.  
  1864. *************************
  1865. *        SKIP         *
  1866. *************************
  1867.  
  1868. skipz    move.l    parm2(a5),d1
  1869.     bne    test_gs
  1870. skip_err    lea    goto_error_tx(pc),a1
  1871.     bsr    pr_string
  1872.     moveq    #RETURN_ERROR,d0
  1873.     rts
  1874. test_gs    tst.b    scflag(a5)    CAN ONLY GOTO FROM WITHIN SCRIPT
  1875.     beq    skip_err
  1876.  
  1877.     move.l    d1,a0
  1878.     lea    dest_label(a5),a1
  1879. .B    move.b    (a0)+,(a1)+
  1880.     bne.s    .B
  1881.     move.l    scaddr(a5),scptr(a5)  RESET TO START OF SCRIPT
  1882.     move.b    #$ff,goto_flag(a5)
  1883.     clr.b    if_flag(a5)    MAKE SURE IF IS TERMINATED
  1884.     moveq    #RETURN_OK,d0
  1885.     rts
  1886.  
  1887. *************************
  1888. *    LABEL        *     DOES NOTHING IF NOT IN GOTO SEARCH MODE
  1889. *************************
  1890. labelz    tst.b    goto_flag(a5)
  1891.     bne.s    .A
  1892. .B    moveq    #RETURN_OK,D0
  1893.     RTS
  1894. .A    move.l    parm2(a5),d0
  1895.     beq.s    .B
  1896.     move.l    d0,a0
  1897.     lea    dest_label(a5),a1
  1898.     bsr    compare_strings
  1899.     bne    .B
  1900.     clr.b    goto_flag(a5)
  1901.     bra.s    .B
  1902.     
  1903.     
  1904. *ENTRY A0=shelline    ONLY HANDLES ALIASES OF FIRST KEYWORD.
  1905. handle_command_alias
  1906.     movem.l    d0-d2/a1-a4,-(sp)
  1907.     cmp.b    #LF,(a0)
  1908.     beq    hca_nothing_typed
  1909.     move.l    a0,a1
  1910.     lea    tempbuf(a5),a3
  1911.     move.b    #LF,(a3)
  1912.     clr.b    1(a3)    must be null end string
  1913.     lea    set_search_string(a5),a2    COPY PARM AT A0 TO SEARCH STR
  1914. .B    move.b    (a1)+,(a2)+
  1915.     cmp.b    #LF,(a1)
  1916.     beq.s    .D        hca_one_parm
  1917.     cmp.b    #$20,(a1)
  1918.     bne.s    .B
  1919. .D    move.b    (a1)+,(a3)+    COPY FROM SPACE ONWARDS to tempbuf
  1920.     bne.s    .D    WHOLE LINE ENDS IN NULL.
  1921. hca_one_parm
  1922.     clr.b    (a2)    null end search string
  1923.  
  1924. hca_find_it
  1925.     move.l    a0,-(sp)
  1926.     bsr    search_sets
  1927.     move.l    (sp)+,a0
  1928.     tst.l    d0
  1929.     beq    hca_nothing_typed
  1930.     move.l    d0,a2
  1931.  
  1932.     lea    set_defn(a2),a2    A2=set defn
  1933.     lea    tempbuf(a5),a3    A3=line after alias
  1934.     move.l    a0,a1        A1=shelline ptr
  1935.     moveq    #7,d0
  1936. .F    clr.l    -(sp)        push down eight times 0=no entry.
  1937.     dbra    d0,.F
  1938. .E    move.b    (a2)+,d0        handle %1...$1
  1939.     beq    not_much_of_an_alias
  1940.     cmp.b    #$20,d0        skip spaces
  1941.     beq.s    .E
  1942.     cmp.b    #'%',d0
  1943.     bne.s    no_extra_parms
  1944.     move.b    (a2)+,d0
  1945.     and.w    #$0007,d0        only allow %0 --> %7
  1946. .A    move.b    (a3)+,d1        find where the next param starts
  1947.     cmp.b    #LF,d1
  1948.     beq.s    .C        if no param then pt A3 to lf again
  1949.     cmp.b    #$20,d1
  1950.     beq.s    .A
  1951. .D    lsl.w    #2,d0        x 4
  1952.     move.l    a3,0(sp,d0.w)
  1953.     subq.l    #1,0(sp,d0.w)    put address of param on stack
  1954. .B    move.b    (a3)+,d1        get a3 to pt to next space
  1955.     cmp.b    #LF,d1
  1956.     beq    .C
  1957.     cmp.b    #$20,d1
  1958.     bne.s    .B
  1959. .C    lea    -1(a3),a3        a3 ts to space
  1960.     bra.s    .E        do for more params
  1961. get_next_character
  1962.     move.b    (a2)+,d0
  1963. no_extra_parms
  1964.     cmp.b    #'$',d0
  1965.     bne.s    .A
  1966.     move.b    (a2)+,d0        grab number after $
  1967.     beq.s    not_much_of_an_alias
  1968.     and.w    #$0007,d0
  1969.     lsl.w    #2,d0        x 4
  1970.     move.l    0(sp,d0.w),d1
  1971.     beq.s    get_next_character
  1972.     move.l    d1,a4
  1973. .B    move.b    (a4)+,(a1)+    copy param N
  1974.     cmp.b    #LF,(a4)
  1975.     beq.s    .C
  1976.     cmp.b    #$20,(a4)
  1977.     bne.s    .B
  1978. .C    bra.s    get_next_character
  1979. .A    move.b    d0,(a1)+        copy DEFN -> SHELLINE
  1980.     tst.b    d0
  1981.     bne.s    get_next_character
  1982.  
  1983.     lea    -1(a1),a1
  1984. not_much_of_an_alias
  1985.     lea    32(sp),sp        ** NOTE STACK CHANGE
  1986. .D    move.b    (a3)+,(a1)+    copy tempbuf onto end
  1987.     bne.s    .D
  1988.     clr.b    mult_comm_flag(a5)
  1989.     bsr    handle_mult_comms
  1990.     bsr    handle_command_alias
  1991.     clr.b    mult_comm_flag(a5)
  1992.     bsr    handle_mult_comms    put LF at end Allow for aliases with ;'s
  1993.     
  1994. hca_nothing_typed
  1995.     movem.l    (sp)+,d0-d2/a1-a4
  1996.     rts
  1997.  
  1998.  
  1999.     
  2000. clr_parms    movem.l    a0-a1,-(sp)
  2001.     lea    parm1(a5),a0
  2002.     lea    endofparms(a5),a1
  2003. clr_loop1    clr.l    (a0)+
  2004.     cmp.l    a0,a1
  2005.     bne.s    clr_loop1
  2006.     movem.l    (sp)+,a0-a1
  2007.     rts
  2008.  
  2009. * GET PARM line pted to by A0
  2010. * LINE MUST END IN LF THEN 0
  2011. * returns A1 pointing to the address where the parm starts
  2012. * puts a 0 over the space or lf where it ends .A0 pts to next bit on end
  2013. * return d2=0 if got all possible commands from line
  2014. get_parm    moveq    #$20,d2    D2=delimiter
  2015. get_parm1    move.l    a0,a1    ;make sure we can get the address before
  2016.     move.b    (a0)+,d1    ;skip spaces
  2017.     beq.s    last_parm2
  2018.     cmp.b    #$20,d1
  2019.     beq.s    get_parm1
  2020.     cmp.b    #$9,d1    skip tabs
  2021.     beq.s    get_parm1
  2022.     cmp.b    #LF,d1    ;handle idiots who type spaces at end of line
  2023.     beq.s    last_parm
  2024.     cmp.b    #'"',d1    ;handle double quotes
  2025.     bne.s    gp2
  2026.     addq.l    #1,a1
  2027.     moveq    #'"',d2    SET DELIMITER = "
  2028.     bra.s    gp2
  2029. gp4    addq.l    #1,a0    ;make sure pts to after quotes d1 is dummy
  2030. gp2    move.b    (a0)+,d1    ;a0 pts to after the space on exit
  2031.     cmp.b    #LF,d1
  2032.     beq.s    gp3
  2033.     cmp.b    #$5c,d1    allow for \" (nested quotes)
  2034.     beq.s    gp4
  2035.     cmp.b    d2,d1
  2036.     bne.s    gp2
  2037.     clr.b -1(a0)    ;make sure last byte is 0
  2038.     rts
  2039. last_parm    clr.b -1(a0)
  2040. last_parm2    moveq #0,d2    ;signify the end
  2041.         rts
  2042. gp3    lea -1(a0),a0 if ends in LF then dont null end, catch that next time
  2043.     rts
  2044.  
  2045. close_redirection
  2046.     tst.b    nonstdin(a5)
  2047.     beq    cls_outred
  2048.     move.l    thistask(a5),a0
  2049.     move.l    pr_CIS(a0),d1
  2050.     move.l    stdin(a5),pr_CIS(a0)    restore old stdin
  2051.     move.l    stdin(a5),inhandle(a5)
  2052.     jsr    _LVOClose(a6)
  2053.     clr.b    nonstdin(a5)
  2054. cls_outred
  2055.     tst.b    nonstdout(a5)
  2056.     beq    cls_nothing
  2057.     move.l    thistask(a5),a0
  2058.     move.l    pr_COS(a0),d1
  2059.     move.l    stdout(a5),pr_COS(a0)    restore old stdout
  2060.     move.l    stdout(a5),outhandle(a5)    
  2061.     jsr    _LVOClose(a6)
  2062.     clr.b    nonstdout(a5)
  2063. cls_nothing
  2064.     rts
  2065.     
  2066. * entry A0 pts to shelline
  2067. handle_redirection
  2068.     movem.l    d0/a0-a2,-(sp)
  2069. redir_2    move.b    (a0)+,d0    CHECK FOR REDIRECTION CHARS < >
  2070.     cmp.b    #LF,d0
  2071.     beq    redir_fin
  2072.     cmp.b    #'"',d0    HANDLE QUOTES
  2073.     bne.s    .A
  2074. *    bsr    new_print
  2075. .B    move.b    (a0)+,d0
  2076.     cmp.b    #LF,d0
  2077.     beq    redir_fin
  2078.     cmp.b    #'"',d0
  2079.     bne.s    .B
  2080. .A    cmp.b    #$20,d0
  2081.     bne.s    redir_2
  2082.     move.b    (a0),d0    TEST CHAR AFTER SPACE.
  2083.     cmp.b    #'>',d0
  2084.     beq.s    redir_out
  2085.     cmp.b    #'<',d0
  2086.     bne.s    redir_2
  2087. redir_in    lea    nonstdin(a5),a2
  2088.     move.l    #MODE_OLDFILE,d2
  2089.     bsr    redir_open
  2090.     move.l    thistask(a5),a0
  2091.     move.l    d0,pr_CIS(a0)    MAKE STDIN DIFFERENT.
  2092.     move.l    d0,inhandle(a5)
  2093.     move.l    a3,a0
  2094.     bra    redir_2        KEEP SEARCHING
  2095. redir_out    cmp.b    #'>',1(a0)
  2096.     beq.s    redir_append
  2097.     lea    nonstdout(a5),a2
  2098.     move.l    #MODE_NEWFILE,d2
  2099.     bsr    redir_open
  2100.     bsr    ChngOut
  2101.     move.l    a3,a0
  2102.     bra    redir_2
  2103. redir_append
  2104.     lea    nonstdout(a5),a2
  2105.     move.l    #MODE_OLDFILE,d2
  2106.     bsr    redir_open
  2107.     bsr    ChngOut
  2108.     move.l    d0,d1
  2109.     moveq    #0,d2    set position
  2110.     moveq    #1,d3    set mode
  2111.     jsr    _LVOSeek(a6)
  2112.     move.l    a3,a0
  2113.     bra    redir_2
  2114.     
  2115. redir_fin
  2116.     movem.l    (sp)+,d0/a0-a2
  2117.     rts
  2118.  
  2119. ChngOut
  2120.     move.l    thistask(a5),a0
  2121.     move.l    d0,pr_COS(a0)
  2122.     move.l    d0,outhandle(a5)
  2123.     rts
  2124.  
  2125. redir_open
  2126.     lea    -1(a0),a3        ALIGN WITH SPACE
  2127.     bsr    copy_redirector
  2128.     move.l    a2,d1
  2129.     jsr    _LVOOpen(a6)
  2130.     tst.l    d0
  2131.     bne.s    redopefin
  2132.     clr.b    (a2)
  2133.     bra    DOSerr
  2134. redopefin    rts
  2135.     
  2136. ** ENTRY A0 pts redirection symbol. A2 pts to area to save redirection name
  2137. ** EXIT A2 area holds null end string and redirection name is deleted from
  2138. **      shelline
  2139. copy_redirector
  2140.     movem.l    a0-a2,-(sp)
  2141.     move.l    a0,a1    SAVE START OF REDIRECTION STRING
  2142.     move.b    (a0)+,d0    BUMP PAST '<' or '>'
  2143. cpred3    move.b    (a0)+,d0
  2144.     cmp.b    #$20,d0
  2145.     beq.s    cpredsp
  2146.     cmp.b    #LF,d0
  2147.     beq.s    cpredlf
  2148.     cmp.b    #'>',d0    HANDLE APPEND REDIRECTION PROPERLY
  2149.     beq.s    cpred3
  2150.     move.b    d0,(a2)+    COPY NEWSTDIN/OUT TO NONSTDIN/OUT
  2151.     bra.s    cpred3
  2152. cpredlf    lea    -1(a0),a0
  2153.     lea    -1(a1),a1
  2154. cpredsp    clr.b    (a2)+    A0 should point to after the space or lf
  2155.     lea    shelline+SHELLINE_SIZE(a5),a2
  2156.     move.l    a1,d0
  2157.     sub.l    a0,d0
  2158.     add.l    d0,next_comm_ptr(a5)    offset next_comm_ptr
  2159. cpred5    move.b    (a0)+,(a1)+    delete redirection string from shelline
  2160.     cmp.l    a0,a2
  2161.     bhi.s    cpred5
  2162.     movem.l    (sp)+,a0-a2
  2163.     rts
  2164.  
  2165. ** V1.14 multiple commands on command line. Delimit by ';'
  2166. * ENTRY A0 pts to shelline, EXIT A0 pts to start of next bit on line.
  2167. handle_mult_comms
  2168.     movem.l    d0/a1,-(sp)
  2169.     tst.b    mult_comm_flag(a5)
  2170.     beq.s    .A
  2171.     move.l    next_comm_ptr(a5),a0
  2172. .A    move.l    a0,a1
  2173. .B    move.b    (a1)+,d0
  2174.     cmp.b    #$5c,d0        is it \ ?
  2175.     beq.s    .E
  2176.     cmp.b    #'"',d0    ignore semi-colons between quotes
  2177.     bne.s    .C
  2178. .D    move.b    (a1)+,d0
  2179.     beq.s    endofline    END OF LINE IS NULL.
  2180.     cmp.b    #LF,d0
  2181.     beq.s    fndret
  2182.     cmp.b    #'"',d0
  2183.     bne.s    .D
  2184.     bra.s    .B
  2185. .E    move.b    (a1)+,d0
  2186.     bra.s    .F
  2187. .C    cmp.b    #';',d0
  2188.     beq    fndsemi
  2189. .F    cmp.b    #LF,d0
  2190.     bne.s    .B
  2191. fndret    tst.b    (a1)    IF NULL FOLLOWS LF THEN AT END OF LINE
  2192.     bne.s    fndsemi
  2193. endofline    clr.b    mult_comm_flag(a5)
  2194.     movem.l    (sp)+,d0/a1
  2195.     rts
  2196. fndsemi    move.b    #LF,-1(a1)    REPLACE ; or LF WITH LF
  2197.     move.l    a1,next_comm_ptr(a5)
  2198.     move.b    #1,mult_comm_flag(a5)
  2199.     movem.l    (sp)+,d0/a1
  2200.     rts
  2201.  
  2202.  
  2203. * Create CLI-Interface-Structure    V2.0 *
  2204. CreateCLI
  2205.     move.l    thistask(a5),a3
  2206.     move.l    pr_WindowPtr(a3),window_old(a5)
  2207.     tst.b    CLIflag(a5)
  2208.     beq    CCli3
  2209.     clr.l    EntryA0(a5)        started from WB
  2210.     move.l    #64,d0
  2211.     move.l    #MEMF_CLEAR+1,d1    memory for CLI
  2212.     bsr    iwantmem
  2213.     beq    CCli2
  2214.     move.l    d0,a2
  2215.     lsr.l    #2,d0
  2216.     move.l    d0,pr_CLI(a3)
  2217.     move.l    dl_Root(a6),a0
  2218.     move.l    (a0),a0
  2219.     add.l    a0,a0
  2220.     add.l    a0,a0
  2221.     moveq    #0,d1
  2222.     move.l    (a0),d0
  2223.     subq.l    #1,d0
  2224. .C    addq.l    #1,d1
  2225.     addq.l    #4,a0
  2226.     tst.l    (a0)        look for free CLI-Number
  2227.     dbeq    d0,.C
  2228.     tst.l    (a0)
  2229.     bne    CCli2
  2230.     lea    pr_MsgPort(a3),a1
  2231.     move.l    a1,(a0)
  2232.     move.l    d1,pr_TaskNum(a3)
  2233.     move.l    #LF,cli_FailLevel(a2)
  2234.     move.l    #-1,cli_Interactive(a2)
  2235.     move.l    #1000,cli_DefaultStack(a2)    1000 LONGs
  2236.     move.l    pr_FileSystemTask(a3),filesys_old(a5)
  2237.     tst.l    wb_msg(a5)
  2238.     beq    CreateCLI2    no WB-Msg -> CreateCLI2
  2239.     move.l    wb_msg(a5),a0
  2240.     tst.l    sm_Process(a0)
  2241.     beq    CreateCLI3    newcli/run -> CreateCLI3
  2242.     move.l    sm_ArgList(a0),a1
  2243.     moveq    #2,d0
  2244.     cmp.l    sm_NumArgs(a0),d0
  2245.     bhi.s    .H        Project ?
  2246.     addq.l    #8,a1
  2247. .H    move.l    (a1),a0        Lock on Current Dir
  2248.     move.l    a0,d1
  2249.     beq    CCli2
  2250.     add.l    a0,a0
  2251.     add.l    a0,a0
  2252.     move.l    fl_Task(a0),pr_FileSystemTask(a3)
  2253.     move.l    dosbase(a5),a6
  2254.     jsr    _LVODupLock(a6)        WB wants to free its own lock
  2255.     move.l    d0,d1
  2256.     jsr    _LVOCurrentDir(a6)
  2257.     move.l    d0,cdir_old(a5)
  2258. .E    move.l    4.w,a6
  2259.     moveq    #0,d0
  2260.     lea    iconname(pc),a1
  2261.     jsr    _LVOOpenLibrary(a6)    icon-library
  2262.     move.l    d0,iconbase(a5)
  2263.     beq    CCli2
  2264.     move.l    d0,a4
  2265.     move.l    wb_msg(a5),a0
  2266.     move.l    sm_ArgList(a0),a1
  2267.     moveq    #2,d0
  2268.     cmp.l    sm_NumArgs(a0),d0
  2269.     bhi.s    .I            Project ?
  2270.     move.l    12(a1),d0
  2271.     beq.s    .I
  2272.     move.l    d0,EntryA0(a5)        Name of Project as Script
  2273.     addq.l    #8,a1
  2274. .I    move.l    4(a1),a0        Name of Process
  2275.     move.l    a4,a6
  2276.     jsr    _LVOGetDiskObject(a6)
  2277.     move.l    d0,diskobj(a5)
  2278.     beq    CCli2
  2279.     move.l    d0,a0
  2280.     move.l    do_ToolTypes(a0),a0
  2281.     lea    wintool(pc),a1
  2282.     jsr    _LVOFindToolType(a6)    Look for WINDOW-ToolType
  2283.     lea    conname(pc),a0
  2284.     tst.l    d0
  2285.     beq.s    .D
  2286.     move.l    d0,a0
  2287. .D    move.l    a0,d1
  2288.     move.l    dosbase(a5),a6
  2289.     bsr    openwin            Open Window
  2290.     beq    CCli2
  2291.     move.l    diskobj(a5),a0
  2292.     move.l    do_ToolTypes(a0),a0
  2293.     lea    scripttool(pc),a1
  2294.     move.l    a4,a6
  2295.     jsr    _LVOFindToolType(a6)    Look for SCRIPT-ToolType
  2296.     tst.l    d0
  2297.     beq.s    .F
  2298.     move.l    d0,a0
  2299.     lea    prompt_string(a5),a1    there is enough place
  2300.     move.l    a1,EntryA0(a5)
  2301. .G    move.b    (a0)+,(a1)+    copy it
  2302.     bne.s    .G
  2303.     move.b    #LF,-1(a1)    LF-End it
  2304. .F    move.l    diskobj(a5),a0
  2305.     jsr    _LVOFreeDiskObject(a6)
  2306.     clr.l    diskobj(a5)
  2307.     move.l    a4,a1
  2308.     move.l    4.w,a6
  2309.     jsr    _LVOCloseLibrary(a6)
  2310.     clr.l    iconbase(a5)
  2311. CCli1    move.l    dosbase(a5),a6
  2312.     moveq    #0,d0
  2313.     rts
  2314. CCli2    move.l    dosbase(a5),a6
  2315.     moveq    #-1,d0
  2316.     rts
  2317.  
  2318. CCli3    move.l    pr_COS(a3),outhandle(a5)    started from CLI
  2319.     move.l    pr_CLI(a3),a2
  2320.     add.l    a2,a2
  2321.     add.l    a2,a2
  2322.     move.l    cli_Prompt(a2),old_prompt(a5)
  2323.     move.l    cli_SetName(a2),old_setname(a5)
  2324.     move.l    EntryA0(a5),d0    process CLI-Command-Line
  2325.     beq.s    CCli1
  2326.     clr.l    EntryA0(a5)
  2327.     move.l    d0,a0
  2328.     lea    parm2(a5),a2
  2329.     lea    endofparms(a5),a4    establish end of parms block
  2330. .A    bsr    get_parm        
  2331.     tst.l    d2
  2332.     beq.s    .B
  2333.     move.l    a1,(a2)+
  2334.     cmp.l    a2,a4        get out if more than 25 parms
  2335.     bne.s    .A
  2336.     clr.b    (a0)        make sure last parm ends in 0
  2337. .B    lea    parm2(a5),a1
  2338.     bsr.s    StartOpts
  2339.     bne.s    CCli2
  2340.     tst.l    d1
  2341.     beq.s    CCli1
  2342.     move.l    thistask(a5),a3
  2343.     move.l    pr_CLI(a3),a2
  2344.     add.l    a2,a2
  2345.     add.l    a2,a2
  2346.     bsr    openwin
  2347.     tst.l    d0
  2348.     beq.s    CCli2
  2349.     bra.s    CCli1
  2350.  
  2351. StartOpts        ;examine startup-options, parms in a1
  2352.     moveq    #0,d1
  2353.     moveq    #0,d2
  2354. .A    move.l    (a1)+,d0    ;returns window in d1, script in EntryA0
  2355.     beq.s    Com2Script    ;and start-command in d2
  2356.     move.l    d0,a0
  2357.     cmp.b    #"-",(a0)+
  2358.     bne.s    .H
  2359.     move.b    (a0)+,d0
  2360.     or.b    #$20,d0
  2361.     cmp.b    #"s",d0        -s for Script
  2362.     bne.s    .B
  2363.     move.l    a0,EntryA0(a5)
  2364.     bra.s    .A
  2365. .B    cmp.b    #"w",d0        -w for Window
  2366.     bne.s    .C
  2367.     move.l    a0,d1
  2368.     bra.s    .A
  2369. .C    cmp.b    #"c",d0        -c for Command
  2370.     bne.s    .D
  2371.     move.l    a0,d2
  2372.     bra.s    .A
  2373. .D    cmp.b    #"d",d0        -c for detach
  2374.     bne.s    .E
  2375.     clr.l    -4(a1)
  2376.     bsr    initialise_default
  2377.     bsr    newcliz
  2378.     bra    CCli2    end it
  2379. .E    cmp.b    #"r",d0        -r for not resident
  2380.     bne.s    .H
  2381.     bra.s    .A
  2382. .H    lea    useit(pc),a1
  2383.     bsr    pr_stringlf
  2384.     bra    CCli2
  2385.  
  2386. Com2Script        ;Makes a command to script, d2=command
  2387.     move.l    d1,-(sp)
  2388.     moveq    #1,d0
  2389.     tst.l    d2
  2390.     beq.s    .B
  2391.     lea    null(pc),a0
  2392.     move.l    a0,EntryA0(A5)
  2393.     move.l    d2,a0
  2394.     moveq    #0,d0
  2395. .A    addq.l    #1,d0
  2396.     tst.b    (a0)+
  2397.     bne.s    .A
  2398.     move.l    d0,scsize(a5)
  2399.     moveq    #1,d1
  2400.     bsr    iwantmem
  2401.     beq.s    .B
  2402.     move.l    d0,scaddr(a5)
  2403.     move.l    d0,scptr(a5)
  2404.     move.b    #1,scflag(a5)    make shell think text lines are in memory
  2405.     move.l    d0,a1
  2406.     move.l    d2,a0
  2407. .C    move.b    (a0)+,(a1)+
  2408.     bne.s    .C
  2409.     move.b    #LF,-1(a1)
  2410.     moveq    #1,d0
  2411. .B    move.l    (sp)+,d1
  2412.     subq.l    #1,d0
  2413.     rts
  2414.  
  2415.  
  2416. * Open Window for both Input and Output, Name in d1 , a2,a3 *
  2417. openwin    move.l    dosbase(a5),a6
  2418.     moveq    #0,d0
  2419.     cmp.b    #1,openwin_flag(a5)
  2420.     beq.s    .B
  2421.     move.b    #1,openwin_flag(a5)
  2422.     move.l    pr_CIS(a3),OldCIS(a5)
  2423.     move.l    pr_COS(a3),OldCOS(a5)
  2424.     clr.l    pr_CIS(a3)        avoid freeing it
  2425.     clr.l    pr_COS(a3)
  2426.     move.l    pr_ConsoleTask(a3),OldCTask(a5)
  2427.     move.l    d1,a0
  2428.     tst.b    (a0)
  2429.     beq.s    .A            NIL:
  2430.     move.l    #MODE_NEWFILE,d2
  2431.     jsr    _LVOOpen(a6)        open output-Window
  2432.     move.l    d0,pr_COS(a3)
  2433.     beq    .B
  2434.     move.l    d0,d1
  2435.     move.l    d0,cli_StandardOutput(a2)
  2436.     move.l    d0,cli_CurrentOutput(a2)
  2437. ;    move.l    d0,outhandle(a5)
  2438.     lsl.l    #2,d0
  2439.     move.l    d0,a0
  2440.     move.l    fh_Type(a0),pr_ConsoleTask(a3)
  2441.     jsr    _LVOIsInteractive(a6)
  2442.     tst.l    d0
  2443.     beq.s    .B
  2444.     lea    cone(pc),a0
  2445.     move.l    a0,d1
  2446.     move.l    #MODE_OLDFILE,d2
  2447.     jsr    _LVOOpen(a6)        open input-window
  2448.     move.l    d0,pr_CIS(a3)
  2449.     beq    .B
  2450.     move.l    d0,cli_StandardInput(a2)
  2451.     move.l    d0,cli_CurrentInput(a2)
  2452. .A    moveq    #-1,d0
  2453. .B    rts            d0=0 on Error
  2454.  
  2455. * Create CLI-Interface-Structure without WB-Message    V2.0 *
  2456. CreateCLI2
  2457.     lea    conname(pc),a0
  2458.     move.l    a0,d1
  2459.     bsr    openwin
  2460.     beq.s    .B
  2461.     lea    sysdisk(pc),a0
  2462.     move.l    a0,d1
  2463.     moveq    #-2,d2
  2464.     jsr    _LVOLock(a6)
  2465.     tst.l    d0
  2466.     beq    .B
  2467.     move.l    d0,a0
  2468.     add.l    a0,a0
  2469.     add.l    a0,a0
  2470.     move.l    fl_Task(a0),pr_FileSystemTask(a3)
  2471.     move.l    d0,d1
  2472.     jsr    _LVOCurrentDir(a6)
  2473.     move.l    d0,cdir_old(a5)
  2474.     moveq    #0,d0
  2475.     rts
  2476. .B    moveq    #-1,d0
  2477.     rts
  2478.  
  2479. * Create CLI-Interface-Structure with special message    V2.0 *
  2480. *    a3:Process    a2:CLI_Struct    *
  2481. *sm_NumArgs:    General Memory Block
  2482. *sm_ToolWindow:    Current Dir
  2483. CreateCLI3
  2484.     move.b    #1,WBflag(a5)    not started from WB
  2485.     move.l    sm_NumArgs(a0),a4    wb_msg in a0
  2486.     move.l    sm_ToolWindow(a0),d1
  2487.     jsr    _LVODupLock(a6)        COPY CD
  2488.     tst.l    d0
  2489.     beq    cce3
  2490.     move.l    d0,a0
  2491.     add.l    a0,a0
  2492.     add.l    a0,a0
  2493.     move.l    fl_Task(a0),pr_FileSystemTask(a3)
  2494.     move.l    d0,d1
  2495.     jsr    _LVOCurrentDir(a6)
  2496.     move.l    d0,cdir_old(a5)
  2497.     move.l    outhandle(a4),outhandle(a5)    PROCESS PARMS
  2498.     lea    parm2(a4),a1
  2499.     bsr    StartOpts
  2500.     clr.l    outhandle(a5)
  2501.     tst.l    d0
  2502.     bne    cce3
  2503.     clr.l    pr_ConsoleTask(a3)    OPEN WINDOW
  2504.     lea    conname(pc),a0
  2505.     tst.l    d1
  2506.     bne.s    .H
  2507.     move.l    a0,d1
  2508. .H    bsr    openwin
  2509.     beq    cce3
  2510.     lea    patharea(a4),a0        COPY SEARCH-PATHS
  2511.     lea    patharea(a5),a1
  2512.     bra.s    .C
  2513. .A    move.b    (a0)+,(a1)+
  2514.     bne.s    .A
  2515. .C    tst.b    (a0)
  2516.     bne.s    .A
  2517.     clr.b    (a1)
  2518.     lea    prompt_args(a4),a0    COPY PROMPT
  2519.     lea    prompt_args(a5),a1
  2520. .G    move.b    (a0)+,(a1)+
  2521.     bne.s    .G
  2522.     lea    now(a4),a0        COPY HISTORY
  2523.     lea    now(a5),a1
  2524.     move.w    #HISTORY_SIZE+12-1,d0
  2525. .D    move.b    (a0)+,(a1)+
  2526.     dbra    d0,.D
  2527.     move.l    failat_level(a4),failat_level(a5)
  2528.     moveq    #ctrl_inite-ctrl_init-1,d0    COPY CTRL-CODES
  2529.     lea    ctrl_codes(a4),a0
  2530.     lea    ctrl_codes(a5),a1
  2531. .E    move.b    (a0)+,(a1)+
  2532.     dbra    d0,.E
  2533.     lea    ignoreit(a4),a0
  2534.     lea    ignoreit(a5),a1
  2535. .F    move.b    (a0)+,(a1)+
  2536.     bne    .F
  2537. ccs3    movem.l    a2-a4,-(sp)    COPY ALL ALIASES
  2538.     moveq    #0,d3        Link Pointer
  2539.     move.l    first_set_defn(a4),d0    old aliases
  2540.     beq    .A
  2541. .B    move.l    d0,a3
  2542.     move.l    set_size(a3),d0
  2543.     move.l    d0,d2
  2544.     moveq    #1,d1
  2545.     bsr    iwantmem    get mem for set
  2546.     beq.s    .A
  2547.     move.l    d0,a2
  2548.     move.l    a3,a0        copy whole set
  2549.     move.l    a2,a1
  2550.     move.l    d2,d1
  2551.     subq.l    #1,d2
  2552. .C    move.b    (a0)+,(a1)+
  2553.     dbra    d2,.C
  2554.     move.l    d1,set_size(a2)    init set
  2555.     move.l    d3,(a2)
  2556.     move.l    a2,d3
  2557.     move.l    (a3),d0        check next set address
  2558.     bne    .B
  2559. .A    move.l    d3,first_set_defn(a5)
  2560.     move.l    ReviewSize(a4),d0    CREATE REVIEW-BUFFER
  2561.     beq.s    .D
  2562.     bsr    MakeReview
  2563. .D    movem.l    (sp)+,a2-a4
  2564.     move.l    EntryA0(a5),d0        SCRIPT GIVEN ?
  2565.     beq.s    .H
  2566.     move.l    d0,a0
  2567.     lea    prompt_string(a5),a1    there is enough place
  2568.     move.l    a1,EntryA0(a5)
  2569. .F    move.b    (a0)+,(a1)+    Copy Script-Parm
  2570.     bne.s    .F
  2571. .H    move.l    4.w,a6
  2572.     move.l    wb_msg(a5),a1
  2573.     jsr    _LVOReplyMsg(a6)
  2574.     clr.l    wb_msg(a5)
  2575.     move.l    dosbase(a5),a6
  2576.     moveq    #0,d0
  2577.     rts
  2578. cce3    moveq    #-1,d0
  2579.     rts
  2580.  
  2581.  
  2582. * Remove CLI-Interface-Structure    V2.0 *
  2583. RemoveCLI
  2584.     move.l    thistask(a5),a3
  2585.     move.l    window_old(a5),pr_WindowPtr(a3)
  2586.     move.l    old_homedir(a5),d0
  2587.     beq.s    .I
  2588.     move.l    d0,pr_HomeDir(a3)
  2589. .I    tst.b    openwin_flag(a5)
  2590.     beq.s    .G
  2591.     move.l    pr_CIS(a3),d1
  2592.     beq.s    .C
  2593.     jsr    _LVOClose(a6)    close input-window
  2594. .C    move.l    pr_COS(a3),d1
  2595.     beq.s    .D
  2596.     jsr    _LVOClose(a6)    close output-window
  2597. .D    move.l    OldCIS(a5),d0
  2598.     move.l    d0,pr_CIS(a3)
  2599.     move.l    OldCOS(a5),d1
  2600.     move.l    d1,pr_COS(a3)
  2601.     move.l    OldCTask(a5),pr_ConsoleTask(a3)
  2602.     tst.l    pr_CLI(a3)
  2603.     beq.s    .G
  2604.     move.l    pr_CLI(a3),a2
  2605.     add.l    a2,a2
  2606.     add.l    a2,a2
  2607.     move.l    d0,cli_StandardInput(a2)
  2608.     move.l    d0,cli_CurrentInput(a2)
  2609.     move.l    d1,cli_StandardOutput(a2)
  2610.     move.l    d1,cli_CurrentOutput(a2)
  2611. .G    move.l    cdback(a5),d1
  2612.     beq.s    .H
  2613.     jsr    _LVOUnLock(a6)
  2614. .H    move.l    pr_CLI(a3),d0
  2615.     beq    .A
  2616.     lsl.l    #2,d0
  2617.     move.l    d0,a2
  2618.     move.l    old_prompt(a5),cli_Prompt(a2)
  2619.     move.l    old_setname(a5),cli_SetName(a2)
  2620.     tst.b    CLIflag(a5)
  2621.     beq    .A
  2622.     clr.l    pr_CLI(a3)    clear CLI-Pointer
  2623.     move.l    pr_TaskNum(a3),d0
  2624.     beq.s    .E
  2625.     lsl.l    #2,d0
  2626.     move.l    dl_Root(a6),a0
  2627.     move.l    (a0),a0
  2628.     add.l    a0,a0
  2629.     add.l    a0,a0
  2630.     add.l    d0,a0
  2631.     clr.l    (a0)        free task-number
  2632.     clr.l    pr_TaskNum(a3)
  2633. .E    move.l    cdir_old(a5),d1
  2634.     jsr    _LVOCurrentDir(a6)
  2635.     move.l    d0,d1
  2636.     beq.s    .B
  2637.     jsr    _LVOUnLock(a6)
  2638. .B    move.l    filesys_old(a5),pr_FileSystemTask(a3)
  2639.     clr.l    pr_Result2(a3)
  2640.     move.l    #64,d0
  2641.     move.l    a2,a1
  2642.     bsr    givemem        free memory of CLI
  2643.     move.l    diskobj(a5),d0
  2644.     beq.s    .F
  2645.     move.l    d0,a0
  2646.     move.l    iconbase(a5),a6
  2647.     jsr    _LVOFreeDiskObject(a6)
  2648. .F    move.l    iconbase(a5),d0
  2649.     beq.s    .A
  2650.     move.l    d0,a1
  2651.     move.l    4.w,a6
  2652.     jsr    _LVOCloseLibrary(a6)
  2653. .A    move.l    dosbase(a5),a6
  2654.     rts
  2655.  
  2656. *CHECK WHETHER THERE IS ENOUGH STACK FREE    V2.0 *
  2657. ;d0=requested stacksize
  2658. stacktest movem.l    d0-d1/a0-a1,-(sp)
  2659.     move.l    topstack(a5),a0
  2660.     sub.l    sp,a0
  2661.     move.l    a0,d1
  2662.     add.l    d0,d1
  2663.     add.l    #1600,d1    ;allow some bytes for DOS
  2664.     cmp.l    stacksize(a5),d1
  2665.     blo.s    .A
  2666.     lea    stack_tx(pc),a1
  2667.     bsr    pr_stringlf
  2668.     moveq    #-1,d0
  2669.     bra.s    .B
  2670. .A    moveq    #0,d0
  2671. .B    movem.l    (sp)+,d0-d1/a0-a1
  2672.     rts
  2673.  
  2674. too_less_args
  2675.     lea    less_args_tx(pc),a1
  2676.     bsr    pr_stringlf
  2677.     move.l    #RETURN_BAD,d0
  2678.     rts
  2679.  
  2680. *SendPacket-Error-Tester
  2681. PKTerr    tst.l    sp_res1(a5)
  2682.     bne    .A
  2683.     move.l    sp_res2(a5),d0
  2684.     bsr.s    pr_DOSerr
  2685.     bra.s    galactic
  2686. .A    rts
  2687. *DOSERRor but Unlock first using D7 as the lock
  2688. DOSerrUL    move.l d7,d1        ;Assume D7=lock
  2689.     jsr _LVOUnLock(a6)        ;NB the last DOS error may be destroyed
  2690. ;DON'T PUT ANYTHING HERE
  2691. *DOSERRor handler D0=0 on entry
  2692. DOSerr    jsr    _LVOIoErr(a6)
  2693.     cmp.l    #232,d0
  2694.     bne.s    .A
  2695.     moveq    #0,d0
  2696.     rts            ;Return if ERROR_NO_MORE_ENTRIES
  2697. .A    bsr.s    pr_DOSerr    ;entry for dospacket
  2698. galactic    move.l    errorstack(a5),sp    ;restore stack
  2699.     moveq    #RETURN_BAD,d0
  2700.     bra    chkfail        ;reenter shell loop
  2701.  
  2702. * ENTRY D0=dos error number
  2703. pr_DOSerr    tst.l    d0
  2704.     beq.s    .D
  2705.     lea    doserrtx(pc),a1
  2706.     bsr    pr_string
  2707.     lea    doserror_text(pc),a1    v1.21 handle textual errors
  2708.     bra.s    .C
  2709. .B    tst.b    (a1)+
  2710.     bne.s    .B
  2711. .C    move.b    (a1)+,d1
  2712.     beq.s    .A
  2713.     cmp.b    d1,d0
  2714.     bne.s    .B
  2715.     bsr    pr_string
  2716. .A    bsr    print10
  2717.     bsr    pr_lf
  2718. .D    rts
  2719.     
  2720. * fix up parameters that exist or not
  2721. fixpam32    move.l parm3(a5),d0
  2722.     move.l    d0,a1
  2723.     bne.s    fixpam2
  2724.     lea    null(pc),a1
  2725.     move.l    a1,parm3(a5)
  2726. fixpam2    move.l    parm2(a5),d0
  2727.     move.l    d0,a0
  2728.     bne.s    fxpam
  2729.     lea    null(pc),a0
  2730.     move.l    a0,parm2(a5)
  2731. fxpam    rts
  2732.     
  2733. *************************
  2734. *    RENAME        *
  2735. *************************
  2736. renamez    bsr fixpam32
  2737. ;DON'T PUT ANYTHING HERE
  2738.     * A0-> oldname  A1-> newname
  2739. rename    move.l a0,d1
  2740.     move.l a1,d2
  2741.     jsr _LVORename(a6)
  2742.     tst.l d0
  2743.     beq DOSerr
  2744.     moveq    #RETURN_OK,d0
  2745.     rts
  2746.  
  2747. *************************
  2748. *    MAKEDIR        *
  2749. *************************
  2750. makedirz    lea    parm2(a5),a4
  2751. .A    move.l    (a4)+,d1
  2752.     beq.s    .B
  2753.     bsr.s    mkdir
  2754.     bra.s    .A
  2755. .B    moveq    #RETURN_OK,d0
  2756.     rts
  2757.     
  2758. *MAKEDIR D1-> directory name
  2759. mkdir    jsr    _LVOCreateDir(a6)
  2760.     tst.l    d0
  2761.     beq    DOSerr
  2762.     move.l    d0,d1
  2763.     jsr    _LVOUnLock(a6)
  2764. *    moveq    #0,d0
  2765.     rts
  2766.  
  2767. ** CHECK DIRECTORY DESCRIPTION IN (A0) AND CONVERTS INTO DIRNAME[0] AND PUTS
  2768. ** THE WILD CARD IN WILD_STRING. ALSO SETS WILD_FLAG
  2769. handle_wild_dirs
  2770.     clr.b    wild_flag(a5)
  2771.     bsr    check_wild
  2772.     tst.b    d0
  2773.     bne.s    .A
  2774.     lea    wild_string(a5),a1
  2775.     bsr    split_wild
  2776.     move.b    #1,wild_flag(a5)
  2777. .A    rts    
  2778.  
  2779. *************************
  2780. *    DELETE        *
  2781. *************************
  2782. deletez    lea    parm2(a5),a4    v1.21 delete as many as you like.
  2783.     move.l    (a4),a0
  2784.     bsr    check_recurs
  2785.     tst.b    recurs_flag(a5)
  2786.     beq.s    .A
  2787.     addq.l    #4,a4
  2788. .A    move.l    (a4)+,d1
  2789.     beq.s    del_end
  2790.     bsr.s    delete2
  2791.     bra.s    .A
  2792. del_end    moveq    #RETURN_OK,d0
  2793.     rts
  2794.     
  2795. ;DON'T PUT ANYTING HERE
  2796. *DELETE FILE D1-> filename
  2797. delete2    clr.w    indent_count(a5)
  2798.     move.l    d1,-(sp)            ;NOTE D1 is pushed
  2799.     move.l    d1,a0
  2800.     bsr    handle_wild_dirs
  2801.     bsr    fibexam            LOCK DIRECTORY OR FILE
  2802.     tst.l    fib_DirEntryType(a5)
  2803.     bpl.s    delete_dir
  2804.     move.l    d7,d1
  2805.     jsr    _LVOUnLock(a6)        
  2806.     move.l    (sp)+,d1            ;FIXED V1.05
  2807.     move.l    d1,a1
  2808.     bsr    prindent        PRINT NAME OF SINGLE FILE TO GO
  2809.     bra    del1file
  2810. delete_dir
  2811.     moveq    #0,d6            ;init cd count
  2812. delete_dir2
  2813.     move.l    d7,d1
  2814.     jsr    _LVOCurrentDir(a6)        CD to the directory
  2815.     tst.l    d6
  2816.     bne.s    this_is_a_sub_dir
  2817.     move.l    d0,temp2(a5)        ;save original directory lock
  2818.     bra.s    dd3        DONT UNLOCK THE ORIGINAL LOCK (YET)
  2819. this_is_a_sub_dir
  2820.     move.l    d0,d1            ;unlock old entry dir.
  2821.     jsr    _LVOUnLock(a6)
  2822. dd3    bsr    check_c
  2823.     bne    del_die_safely
  2824.     bsr    fibexnx
  2825.     tst.l    d0
  2826.     beq    del_dir_finished
  2827.  
  2828.     tst.b    wild_flag(a5)
  2829.     beq.s    ddx500
  2830.     lea    fib_FileName(a5),a0
  2831.     lea    wild_string(a5),a1
  2832.     bsr    wildmatch
  2833.     tst.b    d0
  2834.     bne.s    dd3
  2835.  
  2836. ddx500    lea    fib_FileName(a5),a0
  2837.     lea    tempbuf(a5),a1
  2838.     bsr    cp_string            ;copy filename to tempbuf
  2839.     move.l    fib_DirEntryType(a5),temp1(a5) ;save type
  2840. delete_d2    bsr    check_c
  2841.     bne    del_die_safely
  2842.     bsr    fibexnx            ;get next entry
  2843.     tst.l    d0
  2844.     beq.s    ddx501
  2845.     tst.b    wild_flag(a5)
  2846.     beq.s    ddx501
  2847.     move.l    d0,d4
  2848.     lea    fib_FileName(a5),a0
  2849.     lea    wild_string(a5),a1
  2850.     bsr    wildmatch
  2851.     tst.b    d0
  2852.     bne.s    delete_d2
  2853.     move.l    d4,d0
  2854. ddx501    move.l    d0,-(sp)        push exnext result
  2855.     lea    -84(sp),sp        ;alloc 84 bytes on stack
  2856.     lea    fib_FileName(a5),a0
  2857.     lea    4(sp),a1
  2858.     bsr    cp_string        ;copy filename to stack
  2859.  
  2860.     move.l    fib_DirEntryType(a5),(sp)
  2861.  
  2862.     bsr    del_filet        DELETE PRIOR ENTRY
  2863.     
  2864.     move.l    (sp),temp1(a5)    grab dirtype
  2865.     lea    4(sp),a0
  2866.     lea    tempbuf(a5),a1
  2867.     bsr    cp_string        ;copy stack to temp
  2868.     lea    84(sp),sp        ;dealloc 84 bytes on stack
  2869.     move.l    (sp)+,d0
  2870.     tst.l    d0
  2871.     beq.s    del_dir_finished
  2872.     bra    delete_d2
  2873.  
  2874. del_filet lea    tempbuf(a5),a1    delete file (in tempbuf) or enter new dir
  2875.     tst.l    temp1(a5)
  2876.     bmi.s    del_print_file
  2877.     tst.b    recurs_flag(a5)
  2878.     bne.s    .A
  2879. .B    rts
  2880. .A    move.l    #230,d0    ;(88+80+subs)
  2881.     bsr    stacktest
  2882.     bne.s    .B
  2883.     lea    farb3(pc),a1
  2884.     bsr    pr_string
  2885.     lea    tempbuf(a5),a1
  2886. del_print_file
  2887.     bsr    prindent        PRINT FILE OR DIR NAME
  2888.     lea    tempbuf(a5),a1
  2889.     move.l    a1,d1
  2890.     tst.l    temp1(a5)            ;check dir type
  2891.     bmi    del1file
  2892. del_new_dir
  2893.     bsr    pr_tab
  2894.     lea    dirtext(pc),a1    PRINT "DIR"
  2895.     bsr    pr_stringlf
  2896.     addq.w    #2,indent_count(a5)
  2897.     addq.l    #1,d6
  2898.     lea    tempbuf(a5),a0        A0=tempbuf
  2899.     bsr    fibexam
  2900.     lea    -80(sp),sp
  2901.     lea    (sp),a1
  2902.     lea    fib_FileName(a5),a0
  2903.     bsr    cp_string        ;copy dirname to stack
  2904.     bra    delete_dir2    recurs
  2905.  
  2906. * IF CTRLC CHECKING CALLS HERE IT WILL ONLY BREAK THE DELETION IN THE CURRENT DIR
  2907. del_dir_finished
  2908.     tst.l    d6
  2909.     bne.s    not_back_enough
  2910.     move.l    temp2(a5),d1
  2911.     jsr    _LVOCurrentDir(a6)
  2912.     move.l    d0,d1            ;unlock old.
  2913.     jsr    _LVOUnLock(a6)
  2914.     move.l    (sp)+,d1
  2915.     jsr    _LVODeleteFile(a6)        ;delete directory name
  2916.     tst.l    d0
  2917.     beq    DOSerr
  2918.     bra    pr_lf
  2919.  
  2920. not_back_enough
  2921.     subq.l    #1,d6
  2922.     subq.w    #2,indent_count(a5)
  2923.     lea    backslash(pc),a0
  2924.     bsr    fibexam
  2925.     move.l    d7,d1
  2926.     jsr    _LVOCurrentDir(a6)
  2927.     move.l    d0,d1            ;unlock old.
  2928.     jsr    _LVOUnLock(a6)
  2929.     lea    (sp),a1
  2930.     move.l    a1,d1
  2931.     jsr    _LVODeleteFile(a6)        ;delete directory name
  2932.     lea    80(sp),sp
  2933.     tst.l    d0
  2934.     beq    DOSerr
  2935.     move.l    d7,d0
  2936.     bsr    fibexam2
  2937.     bsr    fibexnx
  2938.     rts
  2939.  
  2940. del1file
  2941.     movem.l    d2-d4/a2,-(sp)
  2942. ;    move.l    d1,d4
  2943. ;    lea    temp2buf(a5),a2
  2944. ;    clr.b    (a2)
  2945. ;    move.l    a2,d2
  2946. ;    moveq    #20,d3    read only 1 char
  2947. ;    move.l    inhandle(a5),d1
  2948. ;    beq.s    .C
  2949. ;    jsr    _LVORead(a6)
  2950. ;    or.b    #$20,(a2)
  2951. ;    cmp.b    #"y",(a2)    yes ?
  2952. ;    beq.s    .C
  2953. ;    cmp.b    #"j",(a2)
  2954. ;    bne.s    .B
  2955. ;.C    move.l    d4,d1
  2956.     jsr    _LVODeleteFile(a6)
  2957.     tst.l    d0
  2958.     beq.s    .A
  2959.     lea    deletedtx(pc),a1    PRINT "...DELETED"
  2960.     bsr    pr_string
  2961. .B    bsr    pr_lf
  2962.     movem.l    (sp)+,d2-d4/a2
  2963.     rts
  2964. .A    jsr    _LVOIoErr(a6)    IF FILE IS PROTECTED OR SOMETHING
  2965.     bsr    pr_DOSerr        THEN GET OUT TO OLD DIRECTLY LEVEL
  2966. del_die_safely
  2967. .C    tst.l    d6        CLEANLY.
  2968.     bne.s    .B
  2969.     move.l    temp2(a5),d1
  2970.     jsr    _LVOCurrentDir(a6)
  2971.     move.l    d0,d1            ;unlock old.
  2972.     jsr    _LVOUnLock(a6)
  2973.     bsr    pr_lf
  2974.     bra    galactic        GET BACK TO ORIGINAL STACK LEVEL
  2975. *                AND GET TO MAIN LOOP
  2976. .B    subq.l    #1,d6
  2977.     lea    backslash(pc),a0
  2978.     bsr    fibexam
  2979.     move.l    d7,d1
  2980.     jsr    _LVOCurrentDir(a6)
  2981.     move.l    d0,d1            ;unlock old.
  2982.     jsr    _LVOUnLock(a6)
  2983.     bra.s    .C
  2984.  
  2985. **************    
  2986. compose_prompt
  2987.     lea    prompt_string(a5),a1
  2988.     lea    farb3(pc),a0
  2989. .C    move.b    (a0)+,(a1)+    copy highlight colour
  2990.     bne.s    .C
  2991.     lea    -1(a1),a1
  2992.     lea    prompt_args+1(a5),a0
  2993. cpro3    move.b    (a0)+,d0
  2994.     beq    composer3
  2995.     cmp.b    #$5c,d0 ;\
  2996.     bne.s    .A
  2997.     move.b    (a0)+,d0
  2998.     bra    composer2
  2999. .A    cmp.b    #'%',d0
  3000.     bne    composer2
  3001.     move.b    (a0)+,d0
  3002.     bset    #5,d0
  3003.     cmp.b    #'p',d0        check if %p
  3004.     bne.s    try_halfcd
  3005.     lea    CD_string+1(a5),a2
  3006. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  3007.     bne.s    .B
  3008.     lea    -1(a1),a1
  3009.     bra    cpro3
  3010. try_halfcd
  3011.     cmp.b    #'s',d0        check if %s
  3012.     bne.s    try_line_num
  3013.     lea    CD_string+1(a5),a2
  3014.     move.l    a2,d1
  3015. .A    tst.b    (a2)+
  3016.     bne.s    .A
  3017.     subq.l    #2,a2
  3018.     bra.s    .D
  3019. .C    move.b    -(a2),d0
  3020. .D    cmp.l    a2,d1
  3021.     bhi.s    .E
  3022.     cmp.b    #"/",d0
  3023.     beq.s    .E
  3024.     cmp.b    #":",d0
  3025.     bne.s    .C
  3026. .E    addq.l    #1,a2
  3027. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  3028.     bne.s    .B
  3029.     lea    -1(a1),a1
  3030.     bra    cpro3
  3031. try_line_num
  3032.     cmp.b    #'l',d0        check if %l
  3033.     bne.s    try_oldcmd
  3034.     move.l    count_line(a5),d0
  3035.     moveq    #0,d1
  3036.     move.l    a1,a2
  3037.     bsr    qdecpr        insert current line number
  3038.     move.l    a2,a1
  3039.     bra    cpro3
  3040. try_oldcmd
  3041.     cmp.b    #'c',d0        check if %c
  3042.     bne.s    try_task_num
  3043.     lea    shelline(a5),a2
  3044. .B    move.b    (a2)+,(a1)+
  3045.     bne.s    .B
  3046.     lea    -1(a1),a1
  3047.     bra    cpro3
  3048. try_task_num
  3049.     cmp.b    #'n',d0        check if %n
  3050.     bne.s    composer2
  3051.     move.l    thistask(a5),a2
  3052.     move.l    pr_TaskNum(a2),d0
  3053.     add.b    #$30,d0
  3054. composer2    move.b    d0,(a1)+
  3055.     bra    cpro3
  3056. composer3    lea    farb1(pc),a0
  3057. .A    move.b    (a0)+,(a1)+
  3058.     bne.s    .A
  3059.     rts
  3060.  
  3061. *************************
  3062. *    PROMPT        *
  3063. *************************
  3064. promptz    tst.l    parm2(a5)
  3065.     beq.s    promptz2
  3066.     move.l    parm2(a5),a0
  3067.     lea    prompt_args(a5),a2
  3068.     lea    1(a2),a1
  3069.     moveq    #-1,d0
  3070. promptz3    addq.b    #1,d0
  3071.     move.b    (a0)+,(a1)+
  3072.     bne.s    promptz3
  3073.     move.b    d0,(a2)
  3074.     MOVEQ    #RETURN_OK,D0
  3075.     rts
  3076. promptz2    lea    prompt_args+1(a5),a1
  3077.     bsr    pr_stringlf
  3078.     moveq    #RETURN_OK,d0
  3079.     rts
  3080.     
  3081.     
  3082. *FILL FIB WITH EXAMINE A0-> directory name ,D7=filelock on return
  3083. fibexam    move.l    a0,-(sp)
  3084.     moveq    #ACCESS_READ,d2
  3085. fibexam3 move.l a0,d1
  3086.     jsr    _LVOLock(a6)
  3087.     tst.l    d0
  3088.     beq    DOSerr
  3089.     bsr    fibexam2
  3090.     move.l    (sp)+,a0
  3091.     rts
  3092. fibexam2 move.l    d0,d7
  3093.     move.l    d0,d1
  3094.     move.l    a5,d2
  3095.     jsr    _LVOExamine(a6)
  3096.     tst.l    d0
  3097.     beq    DOSerrUL
  3098.     rts
  3099.  
  3100. *****************
  3101. *    CD    *
  3102. *****************
  3103. cdz    tst.l    parm2(a5)
  3104.     beq    querycd
  3105.     move.l    parm2(a5),a0
  3106. *CHANGE DIRECTORY A0-> new current directory
  3107.     bsr    fibexam
  3108.     tst.l    fib_DirEntryType(a5)    ;check entry OK
  3109.     bpl.s    .A
  3110.     lea    cderrtx(pc),a1
  3111.     bsr    pr_string
  3112.     move.l    d7,d1
  3113.     jsr    _LVOUnLock(a6)
  3114.     moveq    #RETURN_ERROR,d0
  3115.     rts
  3116. .A    move.l    d7,d1
  3117. chdir    jsr    _LVOCurrentDir(a6)
  3118.     move.l    cdback(a5),d1
  3119.     move.l    d0,cdback(a5)    remember old directory
  3120.     jsr    _LVOUnLock(a6)    unlock the old directory
  3121.     bsr    eval_CD        update cd string
  3122.     moveq    #RETURN_OK,d0
  3123.     rts
  3124.     
  3125. querycd    bsr    eval_CD
  3126.     lea    CD_string+1(a5),a1
  3127.     bsr    pr_stringlf
  3128.     moveq    #RETURN_OK,d0
  3129.     rts
  3130.  
  3131.  
  3132. ** Evaluate entire name of current directory and put in CD_string
  3133. eval_CD    clr.b    CD_string+1(a5)
  3134.     lea    null(pc),a0
  3135.     move.l    a0,d1
  3136.     moveq    #ACCESS_READ,d2
  3137.     jsr    _LVOLock(a6)
  3138.     tst.l    d0
  3139.     beq.s    .A
  3140.     move.l    d0,a0
  3141.     add.l    a0,a0
  3142.     add.l    a0,a0
  3143.     move.l    fl_Key(a0),cd_block(a5)
  3144.     move.l    fl_Volume(a0),cd_volnode(a5)
  3145.     lea    CD_string+1(a5),a0
  3146.     bsr    eval_full_path
  3147.     jsr    _LVOUnLock(a6)
  3148. .A    moveq    #-1,d0
  3149.     lea    CD_string(a5),a0
  3150.     lea    1(a0),a1
  3151. .B    addq.b    #1,d0
  3152.     tst.b    (a1)+
  3153.     bne.s    .B
  3154.     move.b    d0,(a0)
  3155.     rts
  3156.     
  3157. ** evaluate entire name associated with lock in D0, store string in A0
  3158. ** Return D1 = last lock to unlock
  3159. ** Reg usage:a0,d0,d1,d2,a3 (must not use A2)
  3160. eval_full_path
  3161.     lea    -88(sp),sp
  3162.     move.l    a0,4(sp)        save address of string
  3163.     move.l    d0,(sp)        save original lock on stack
  3164.     move.l    d0,d1
  3165.     move.l    a5,d2
  3166.     jsr    _LVOExamine(a6)
  3167.     move.l    4(sp),a1
  3168.     lea    fib_FileName(a5),a0
  3169. evx1    move.b    (a0)+,(a1)+    COPY FILENAME TO deststring
  3170.     bne.s    evx1
  3171.     lea    -1(a1),a3
  3172. evcd2    move.l    (sp),d1        get lock
  3173.     jsr    _LVOParentDir(a6)
  3174.     tst.l    d0
  3175.     beq.s    root_found
  3176.     move.l    (sp),d1
  3177.     move.l    d0,(sp)
  3178.     jsr    _LVOUnLock(a6)    unlock last
  3179.     move.l    (sp),d1
  3180.     move.l    a5,d2
  3181.     jsr    _LVOExamine(a6)
  3182.     lea    fib_FileName(a5),a0
  3183.     lea    8(sp),a1
  3184. evx2    move.b    (a0)+,(a1)+    stackbuf = filename
  3185.     bne.s    evx2
  3186.     move.b    #'/',-1(a1)
  3187.     move.l    4(sp),a0
  3188. evx3    move.b    (a0)+,(a1)+    stackbuf = filename/CD_string
  3189.     bne.s    evx3
  3190.     move.l    4(sp),a1
  3191.     lea    8(sp),a0
  3192. evx4    move.b    (a0)+,d0
  3193.     move.b    d0,(a1)+
  3194.     cmp.b    #'/',d0
  3195.     bne.s    evx4
  3196.     lea    -1(a1),a3
  3197. evx5    move.b    (a0)+,(a1)+    dest string = stackbuf
  3198.     bne.s    evx5
  3199.     bra    evcd2
  3200. root_found
  3201.     move.l    (sp),d1
  3202.     tst.b    (a3)
  3203.     bne.s    root2
  3204.     clr.b    1(a3)
  3205. root2    move.b    #':',(a3)
  3206.     lea    88(sp),sp
  3207.     rts
  3208.  
  3209. *ADDPATH A0-> path  A1-> parameter  A2-> destination for string
  3210. ** eg. (A0)='df0:libs',0  (A1)='arp.library',0  (A2)='df0:libs/arp.library',0
  3211. addpath    movem.l a0-a2,-(sp)
  3212.     move.b (a0),d0
  3213.     beq.s addp4
  3214. addp1    move.b (a0)+,d0
  3215.     beq.s addp2
  3216.     move.b d0,(a2)+
  3217.     bra.s addp1
  3218. addp2    move.b -2(a0),d0
  3219.     cmp.b #':',d0
  3220.     beq.s addp4
  3221.     cmp.b #'/',d0
  3222.     beq.s addp4
  3223.     move.b #'/',(a2)+
  3224. addp4    move.l a1,a0
  3225.     move.l a2,a1
  3226.     bsr cp_string
  3227.     movem.l (sp)+,a0-a2
  3228.     rts
  3229.  
  3230.  
  3231. * Search Resident list for command    V2.0:Global resi's
  3232. * RETURN D0=seglist OR 0 if not found
  3233. *    A0=addr of node        D2=addr of Vorgänger
  3234. search_res    move.l    parm1(a5),a4
  3235. search_res2
  3236.     bsr    resi_hand
  3237.     beq.s    .D
  3238.     move.l    a0,d2
  3239. .A    lsl.l    #2,d0
  3240.     move.l    a4,a1            string
  3241.     move.l    d0,a2
  3242.     lea    resi_name(a2),a0    BSTR
  3243.     moveq    #0,d3
  3244.     move.b    (a0)+,d3
  3245.     subq.w    #1,d3
  3246. .B    move.b    (a0)+,d0
  3247.     move.b    (a1)+,d1
  3248.     cmp.b    ctrl_codes+15(a5),d1
  3249.     bne.s    .F
  3250.     tst.b    (a1)
  3251.     beq.s    .C
  3252. .F    bsr    compD1D0nocase
  3253.     dbne    d3,.B
  3254.     bne.s    .E    not equal
  3255.     tst.b    (a1)
  3256.     beq.s    .C    the (null-)END
  3257. .E    move.l    a2,d2
  3258.     move.l    resi_link(a2),d0    get link
  3259.     bne.s    .A
  3260. .D    moveq    #0,d0
  3261.     rts
  3262. .C    moveq    #-1,d1
  3263.     cmp.l    resi_usecount(a2),d1    is it a system-resi ?
  3264.     beq.s    .D
  3265.     move.l    resi_seglist(a2),d0    get seglist
  3266.     move.l    a2,a0
  3267.     rts
  3268.  
  3269.  
  3270. *Search paths for command
  3271. spaths    move.l    parm1(a5),a4    A4=parm1
  3272. spaths2    moveq    #0,d4
  3273.     move.l    a4,a2
  3274.     bsr    lock_or_load    search current
  3275.     tst.l    d0
  3276.     bne    gotit
  3277.     tst.l    d7
  3278.     beq.s    .C
  3279.     tst.b    forcediskflag(a5)
  3280.     bne.s    .D        do not change dir
  3281.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  3282.     bmi.s    .D            no !
  3283.     addq.l    #4,sp        return from archie3
  3284.     move.l    a2,d1
  3285.     moveq    #ACCESS_READ,d2
  3286.     jsr    _LVOLock(a6)
  3287.     move.l    d0,d1
  3288.     bra    chdir
  3289.  
  3290. .D    bsr    s_flagset    exec script ?
  3291. .C    move.l    a4,a0
  3292. .F    move.b    (a0)+,d0    are there path-specific chars in the name
  3293.     cmp.b    #"/",d0
  3294.     beq    no_more_paths
  3295.     cmp.b    #":",d0
  3296.     beq    no_more_paths
  3297.     tst.b    d0
  3298.     bne.s    .F
  3299.     moveq    #-1,d1
  3300.     bsr    changeWindowPtr        no requesters
  3301.     lea    patharea(a5),a0
  3302. .A    tst.b    (a0)
  3303.     beq.s    no_more_paths    CHECK IF PATH LIST IS EMPTY
  3304.     move.l    a0,d4
  3305. * path(a0) + parm1 -> tempbuf
  3306.     move.l    a4,a1
  3307.     lea    tempbuf(a5),a2
  3308.     bsr    addpath
  3309.     move.l    a2,d1
  3310.     bsr    lock_or_load
  3311.     tst.l    d0
  3312.     bne.s    gotit
  3313.     tst.l    d7
  3314.     beq.s    .E
  3315.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  3316.     bpl.s    .E
  3317.     bsr    s_flagset    exec script
  3318. .E    move.l    d4,a0
  3319. .B    tst.b    (a0)+
  3320.     bne.s    .B
  3321.     bra.s    .A
  3322. no_more_paths
  3323.     moveq    #0,d0
  3324. gotit    moveq    #0,d1
  3325.     bra    changeWindowPtr
  3326.  
  3327. lock_or_load
  3328.     move.l    a2,d1
  3329.     moveq    #ACCESS_READ,d2
  3330.     jsr    _LVOLock(a6)
  3331.     move.l    d0,d7
  3332.     beq.s    .A
  3333.     move.l    a2,d1
  3334.     jsr    _LVOLoadSeg(a6)
  3335.     tst.l    d0
  3336.     bne.s    .B
  3337.     move.l d7,d1
  3338.     move.l a5,d2
  3339.     jsr    _LVOExamine(a6)
  3340.     tst.l    d0
  3341.     bne.s    .C
  3342.     move.l    d7,d1
  3343.     jsr    _LVOUnLock(a6)
  3344. .A    moveq    #0,d7        file not found
  3345.     moveq    #0,d0
  3346.     rts
  3347. .C    moveq    #0,d0        file is a script or dir
  3348. .B    move.l    d0,-(sp)    file is executable
  3349.     move.l    d7,d1
  3350.     jsr    _LVOUnLock(a6)
  3351.     move.l    (sp)+,d0
  3352.     rts
  3353.  
  3354. s_flagset    move.l    fib_Protection(a5),d0
  3355.     btst    #6,d0
  3356.     beq.s    .A
  3357.     bsr    readpathfile        ;A2 pts to filename
  3358.     addq.l    #8,sp    ;kill return addresses (archie3,spaths,s_flagset)
  3359.     addq.l    #4,sp
  3360.     bra    xz3
  3361. .A    rts
  3362.  
  3363. * ARCHIE 3 calls system0 to execute non internal commands
  3364. archie3    tst.l    parm1(a5)    ;exit if nothing typed
  3365.     beq    noarch31
  3366.     bsr    save_mem
  3367.     clr.b    resi_flag(a5)    =0 if resident
  3368.     bsr    search_res    search resident list first
  3369.     tst.l    d0
  3370.     bne.s    .A
  3371.     addq.b    #1,resi_flag(a5)    =1 if not resident
  3372.     bsr    spaths        ;load the command
  3373.     tst.l    d0
  3374.     beq    noarch32        ;could not load
  3375.     cmp.w    #36,kickver(a5)
  3376.     blo.s    .A
  3377.     move.l    d0,-(sp)
  3378.     move.l    thistask(a5),a3
  3379.     tst.l    d4
  3380.     bne.s    .E
  3381.     move.l    parm1(a5),d4
  3382.     move.l    d4,d1
  3383.     jsr    -876(a6)    _LVOPathPart
  3384.     move.l    d0,a2
  3385.     move.b    (a2),d3
  3386.     clr.b    (a2)        Hack !
  3387.     move.l    d4,d1
  3388.     moveq    #-2,d2
  3389.     jsr    _LVOLock(a6)
  3390.     move.b    d3,(a2)
  3391.     bra.s    .F
  3392. .E    move.l    d4,d1
  3393.     moveq    #-2,d2
  3394.     jsr    _LVOLock(a6)
  3395. .F    move.l    d0,pr_HomeDir(a3)
  3396.     move.l    (sp)+,d0
  3397. .A    move.l    d0,temp1(a5)        ;save the segment
  3398.     bsr    raw_off
  3399.     bsr    save_time
  3400.     lea    CLIbuf(a5),a0
  3401.     move.l    a0,-(sp)    ;push arg_args ptr.
  3402.     move.l    d0,-(sp)    ;push seglist
  3403.     move.l    parm1(a5),d0
  3404.     move.l    d0,-(sp)    ;push arg_name
  3405.     bsr    _System0    TAKES 3 PARMS(ARG_NAME,SEGLIST,ARGS)
  3406.     lea    12(sp),sp
  3407.     move.l    d0,-(sp)
  3408.     cmp.w    #36,kickver(a5)
  3409.     blo.s    .G
  3410.     move.l    thistask(a5),a3
  3411.     move.l    pr_HomeDir(a3),d1
  3412.     beq.s    .G
  3413.     jsr    _LVOUnLock(a6)
  3414.     clr.l    pr_HomeDir(a3)
  3415. .G    jsr    _LVOIoErr(a6)
  3416.     move.l    d0,Result2(a5)
  3417.     tst.b    resi_flag(a5)
  3418.     beq.s    .B
  3419.     move.l    better_Seglist(a5),d1
  3420.     jsr    _LVOUnLoadSeg(a6)
  3421. .B    tst.b    stat_mode_flag(a5)
  3422.     beq.s    .C
  3423.     bsr    show_status
  3424. .C    bsr    raw_on
  3425.     move.l    (sp)+,d2    RESULT IN D2
  3426.     beq.s    .D
  3427.     move.l    Result2(a5),d0
  3428.     bsr    pr_DOSerr    if result > 0 print error
  3429. .D    move.l    d2,d0    
  3430. noarch31    rts
  3431. noarch32    lea badcomm(pc),a1
  3432.     moveq    #RETURN_BAD,d0    return d0 bad    V1.30
  3433.     bra pr_string
  3434.  
  3435.  
  3436. *****    SYSTEM0 execute command from disk from Sozobon C distribution.
  3437. _System0
  3438.     movem.l    d2-d3/a2-a6,-(sp)    ;SAVED_REGS
  3439.     moveq    #NO_CLI,REG_Result      ;#-1,d3 ERROR - not a CLI task
  3440.     move.l    4.w,REG_SysBase    ;4,a6
  3441.     move.l    thistask(a5),REG_Process    ;a2
  3442.     move.l    pr_CLI(REG_Process),d0
  3443.     beq    quit0
  3444.  
  3445. * build local stack frame & save some values
  3446.     lsl.l    #2,d0
  3447.     move.l    d0,REG_CLI    ;a3
  3448.     move.l    sp,REG_PrevStack        ;a1 save old stack pointer
  3449.     move.l    sp,d0
  3450.     and.b    #$fc,d0 ;make SP longword-aligned for BPTRs
  3451.     move.l    d0,sp
  3452.     sub.l    #sf_SIZEOF,sp    ;stack-frame-struct
  3453.     move.l    REG_PrevStack,sf_PrevStack(sp)
  3454.     move.l    REG_Process,sf_Process(sp)
  3455.     move.l    REG_CLI,sf_CLI(sp)
  3456.     move.l  pr_ReturnAddr(REG_Process),sf_SaveReturnAddr(sp)
  3457.  
  3458. * allocate space for stack
  3459.     moveq    #NO_MEM,REG_Result    ;ERROR - no memory for STACK
  3460.     move.l    cli_DefaultStack(REG_CLI),d0    ;in longwords for "VEC"
  3461.     lsl.l    #2,d0
  3462.     move.l    d0,sf_PushSize(sp)
  3463.     addq.l    #4,d0    ;one additional longword
  3464.     move.l    d0,sf_StackSize(sp)
  3465.     moveq    #1,d1    ;intentionally NOT "MEMF_PUBLIC"!; V2.0 Why not ?
  3466.     callsys    AllocMem
  3467.     tst.l    d0
  3468.     beq    quit1
  3469.     move.l    d0,sf_StackBase(sp)    ;save result
  3470.  
  3471. * save old command pointer, build new BCPL command name
  3472.     move.l    cli_CommandName(REG_CLI),sf_SaveCommandName(sp)
  3473.     move.l    sf_PrevStack(sp),REG_PrevStack
  3474.     move.l    ARG_NAME(REG_PrevStack),a0 ;first parameter to "System0()"
  3475.     lea    sf_CommandName(sp),a1 ;BSTR
  3476.     move.w    #MAXBSTR-2,d0
  3477.     bsr    cpBSTR
  3478.     move.l    d0,cli_CommandName(REG_CLI)
  3479. * save contents of Current Input Stream
  3480.     move.l    pr_CIS(REG_Process),d0
  3481.     lsl.l    #2,d0
  3482.     move.l    d0,REG_CIS
  3483.     move.l    REG_CIS,sf_CIS(sp)
  3484.     move.l    fh_Buf(REG_CIS),sf_SCB_Buf(sp)
  3485.     move.l    fh_Pos(REG_CIS),sf_SCB_Pos(sp)
  3486.     move.l    fh_End(REG_CIS),sf_SCB_End(sp)
  3487.  
  3488. * convert argument to LF-terminated string
  3489.     move.l    sf_PrevStack(sp),REG_PrevStack
  3490.     move.l    ARG_ARGS(REG_PrevStack),a0 ;third argument to "System0()"
  3491.     lea    sf_CommandArgs(sp),a1    ;first buffer location
  3492.     move.l    a1,d0
  3493.     lsr.l    #2,d0
  3494.     move.l    d0,fh_Buf(REG_CIS)
  3495.     move.w    #MAXBSTR-1,d0    ;leave some room for terminating LF
  3496.     bra.s    .D
  3497. .C    move.b    d1,(a1)+
  3498. .D    move.b    (a0)+,d1
  3499.     dbeq    d0,.C
  3500.     move.b    #LF,(a1)
  3501.     move.l    sf_PrevStack(sp),REG_PrevStack
  3502.     sub.l    ARG_ARGS(REG_PrevStack),a0    ;subtract first position
  3503.     move.l    a0,d0    ;do NOT subtract 1, LF need this byte
  3504. * setup start/end indices in Stream Control Block
  3505.     clr.l   fh_Pos(REG_CIS)
  3506.     move.l  d0,fh_End(REG_CIS)
  3507.  
  3508. * misc setup
  3509.     clr.l    pr_Result2(REG_Process)    ;clear secondary result
  3510.     move.l    a5,sf_Membase(sp)    ;save membase
  3511. ;    moveq    #0,d0
  3512. ;    moveq    #0,d1
  3513. ;    bset    #SIGBREAKB_CTRL_C,d1
  3514. ;    callsys    SetSignal    ;clear CTRL-C flag
  3515.  
  3516. * handle seglist and start address
  3517.     move.l    cli_Module(REG_CLI),sf_SaveModule(sp)
  3518.     move.l    sf_PrevStack(sp),REG_PrevStack
  3519.     move.l    ARG_SEGLIST(REG_PrevStack),d0 ;second argument to "System0()"
  3520.     move.l    d0,cli_Module(REG_CLI)
  3521.     lsl.l    #2,d0
  3522.     move.l    d0,a3
  3523. * setup processor registers & C-interface
  3524.     lea    sf_CommandArgs(sp),a0
  3525.     move.l    fh_End(REG_CIS),d0
  3526. * setup processor registers, BCPL-interface, stack & return address for "Exit()"
  3527.     move.l    sf_StackBase(sp),a1    ;BCPL stack, low end
  3528.     move.l    sf_PushSize(sp),d2
  3529.     lea    4(a1,d2.l),a4    ;must not destroy REG_Process!
  3530.     move.l    sp,-(a4)    ;previous stack frame
  3531.     move.l    d2,-(a4)    :stack size in bytes
  3532.     move.l    a4,pr_ReturnAddr(REG_Process)
  3533.     move.l    a4,sp
  3534.     move.l    dosbase(a5),a4    ;V2.0 small data
  3535.     movem.l    dl_A2(a4),a2/a5/a6
  3536.  
  3537. * now call the command at its entry point
  3538.     jsr    4(a3)    ;code starts one longword behind segment pointer
  3539.     move.l    d0,REG_Result    ;save return code
  3540.  
  3541. * get old stackframe & reload old register contents
  3542.     move.l    4(sp),sp    ;old stack frame
  3543.     move.l    sf_Membase(sp),a5
  3544.     move.l    sf_Process(sp),a0
  3545.     move.l    sf_SaveReturnAddr(sp),pr_ReturnAddr(a0)
  3546.     move.l    sf_CIS(sp),d0
  3547.     move.l    d0,a1
  3548.     lsr.l    #2,d0
  3549.     move.l    d0,pr_CIS(a0)    ;V2.0 restore CIS
  3550.     move.l    sf_CLI(sp),a0
  3551.     move.l    sf_SaveCommandName(sp),cli_CommandName(a0)
  3552. * Next line makes powerpacker programs deallocate memory properly
  3553.     move.l    cli_Module(a0),better_Seglist(a5)    ;V2.0 small data
  3554.     move.l    sf_SaveModule(sp),cli_Module(a0)
  3555. * restore original contents of Current Input Stream
  3556.     move.l    sf_CIS(sp),a0
  3557.     lea    sf_CommandArgs(sp),a1
  3558.     move.l    a1,d0
  3559.     lsr.l    #2,d0
  3560.     cmp.l    fh_Buf(a0),d0    ;still the same?
  3561.     bne.s    .E    ;no: don't restore
  3562.     move.l    sf_SCB_Buf(sp),fh_Buf(a0)
  3563. .E    move.l    sf_SCB_Pos(sp),fh_Pos(a0)
  3564.     tst.l    fh_End(a0)    ;end index set?
  3565.     beq.s    .F    ;no: don't restore
  3566.     move.l    sf_SCB_End(sp),fh_End(a0)
  3567.  
  3568. * free temporary stack
  3569. .F    move.l    4.w,REG_SysBase
  3570.     move.l    sf_StackBase(sp),a1
  3571.     move.l    sf_StackSize(sp),d0
  3572.     callsys    FreeMem
  3573.  
  3574. quit1    move.l    sf_PrevStack(sp),sp    ;UNLINK local variables
  3575. quit0    move.l    REG_Result,d0
  3576.     movem.l    (sp)+,d2-d3/a2-a6    ;SAVED_REGS
  3577. quitx    rts
  3578.  
  3579.  
  3580. *************************
  3581. *    HELP        *
  3582. *************************
  3583. helpz    bsr    rawh_off
  3584.     move.l    parm2(a5),d7
  3585.     bne    help_man
  3586.     lea    help_tx1(pc),a1
  3587.     bsr    pr_stringlf
  3588.     lea    comtext(pc),a4
  3589.     lea    tempbuf(a5),a3
  3590. .D    moveq    #5,d3
  3591. .C    move.l    a3,a2
  3592.     tst.b    (a4)        
  3593.     beq    .E
  3594.     moveq    #12,d2
  3595. .B    subq.l    #1,d2
  3596.     move.b    (a4)+,(a2)+
  3597.     bne.s    .B
  3598.     tst.b    -(a2)    bump    back
  3599. .A    move.b    #$20,(a2)+
  3600.     dbra    d2,.A
  3601.     clr.b    (a2)
  3602.     move.l    a3,a1
  3603.     bsr    pr_string
  3604.     dbra    d3,.C
  3605.     bsr    pr_lf
  3606.     bra    .D
  3607. .E    bsr    pr_lf
  3608.     lea    help_tx2(pc),a1
  3609.     bsr    pr_string
  3610.     lea    help_tx3(pc),a1
  3611.     bsr    pr_stringlf
  3612.     moveq    #RETURN_OK,D0
  3613.     rts
  3614.  
  3615. * print out part of manual, d7 points to topic
  3616. help_man lea    manadr(pc),a2    global variable
  3617.     move.l    4(a2),d1
  3618.     move.l    (a2),d0
  3619.     bne.s    .A
  3620.     lea    helpload(pc),a1
  3621.     bsr    pr_string
  3622.     lea    helpman(pc),a0
  3623.     bsr    readfile    load manual
  3624.     move.l    d0,(a2)        manadr
  3625.     move.l    d1,4(a2)    mansize
  3626. .A    move.l    d0,a3
  3627.     move.l    d1,d5
  3628.     add.l    a3,d5
  3629.     move.l    a3,a2
  3630.     move.l    d7,a1        type all ?
  3631.     cmp.b    #"?",(a1)
  3632.     beq    make_screen    type all !
  3633. .B    move.l    d7,a1
  3634.     move.l    d5,a0
  3635.     addq.l    #1,a2
  3636.     bsr    searchSTR    search topic in manual
  3637.     cmp.b    #LF,d0
  3638.     bne.s    .C
  3639.     cmp.b    #"-",-2(a2)    there must be a lot of "-" before topic
  3640.     bne.s    .B
  3641.     cmp.b    #"-",-3(a2)
  3642.     bne.s    .B
  3643.     move.l    a1,d4
  3644. .E    bsr    check_c        ctrl-c ?
  3645.     bne.s    .C
  3646. .D    cmp.l    d5,a1
  3647.     bhi.s    .C
  3648.     cmp.b    #LF,(a1)+    print lines separately
  3649.     bne.s    .D
  3650.     move.l    d4,d2
  3651.     move.l    a1,d3
  3652.     sub.l    d2,d3
  3653.     move.l    a1,d4
  3654.     move.l    outhandle(a5),d1
  3655.     jsr    _LVOWrite(a6)
  3656.     move.l    d4,a1
  3657.     cmp.b    #"-",-2(a1)    search next lot of "-"
  3658.     bne.s    .E
  3659.     cmp.b    #"-",-3(a1)
  3660.     bne.s    .E
  3661.     bra.s    .B        another fitting topic ?
  3662. .C    moveq    #RETURN_OK,D0
  3663.     rts
  3664.  
  3665. giveman    movem.l    d0/d1/a0/a1,-(sp)    free manual-memory
  3666.     lea    manadr(pc),a0
  3667.     tst.l    (a0)
  3668.     beq.s    .A
  3669.     move.l    (a0),a1
  3670.     clr.l    (a0)
  3671.     move.l    4(a0),d0
  3672.     bsr    givemem
  3673. .A    movem.l    (sp)+,d0/d1/a0/a1
  3674.     rts
  3675.  
  3676.  
  3677. * PRINT A STRING BUT PUT A LINEFEED AFTER IT
  3678. pr_stringlf    bsr pr_string
  3679.         bra pr_lf
  3680.  
  3681. showpath    bsr    rawh_off
  3682.     lea    pcurrent(pc),a1
  3683.     bsr    pr_stringlf
  3684.     lea    patharea(a5),a1
  3685. sh_p3    tst.b    (a1)
  3686.     beq.s    sh_p1
  3687.     move.l    a1,d4
  3688.     bsr    pr_stringlf
  3689.     move.l    d4,a1
  3690. sh_p2    tst.b    (a1)+
  3691.     bne.s    sh_p2
  3692.     bra.s    sh_p3
  3693. sh_p1    moveq    #RETURN_OK,d0
  3694.     bra    pr_lf
  3695.  
  3696. *****************    
  3697. *    PATH    *     Assign path or show it.
  3698. *****************
  3699. pathz    tst.l    parm2(a5)    see whether any parameters
  3700.     beq.s    showpath
  3701.     move.l    parm2(a5),a0
  3702.     bsr    return_dash_option
  3703.     lea    parm2(a5),a0
  3704.     lea    patharea(a5),a1
  3705.     cmp.b    #'C',d0
  3706.     bne.s    pc_jo
  3707.     clr.w    (a1)
  3708.     tst.l    (a0)+        dummy bump
  3709.     bra.s    pc_x2
  3710. pc_jo    tst.b    (a1)+
  3711.     bne.s    pc_jo
  3712.     tst.b    (a1)        test if 2 nulls
  3713.     bne.s    pc_jo
  3714. pc_x2    move.l    (a0),a2        go through each additional parameter
  3715.     tst.l    (a0)+
  3716.     beq.s    pc_x3
  3717.     
  3718. pc_x1    move.b    (a2)+,(a1)+
  3719.     bne.s    pc_x1
  3720.     bra.s    pc_x2
  3721. pc_x3    clr.b    (a1)
  3722.     moveq    #RETURN_OK,d0
  3723.     rts
  3724.  
  3725.  
  3726. *****************
  3727. *    INFO    *
  3728. *****************
  3729. infoz    bsr    rawh_off        ;V2.0 (fully new)
  3730.     lea    inform_tx(pc),a1
  3731.     bsr    pr_stringlf
  3732.     move.l    $22(a6),a0    ;rootnode
  3733.     move.l    $18(a0),a0    ;dosinfo
  3734.     add.l    a0,a0
  3735.     add.l    a0,a0
  3736.     move.l    4(a0),d6    ;devicelist
  3737. jajo    tst.l    d6
  3738.     bne    .B
  3739.     moveq    #RETURN_OK,d0
  3740.     rts
  3741.  
  3742. .B    lsl.l    #2,d6    ;BPTR
  3743.     move.l    d6,a4
  3744.     move.l    (a4),d6        ;next
  3745.     tst.l    4(a4)        ;type
  3746.     bne.s    jajo    ;was volume or assign
  3747.     tst.l    8(a4)        ;task
  3748.     beq.s    jajo    ;was non-disk-device
  3749. didev    move.l    $28(a4),a0    ;name
  3750.     add.l    a0,a0
  3751.     add.l    a0,a0
  3752.     moveq    #0,d0
  3753.     move.b    (a0)+,d0
  3754.     lea    tempbuf(a5),a3
  3755.     move.l    a3,a2
  3756.     bra.s    .D
  3757. .C    move.b    (a0)+,(a2)+
  3758. .D    dbra    d0,.C
  3759.     move.b    #":",(a2)+
  3760.     clr.b    (a2)
  3761.     bsr    clearArgs
  3762.     move.l    8(a4),packettask(a5)    ;aptr task
  3763.     moveq    #ACTION_DISK_INFO,d0
  3764.     move.l    d0,packettype(a5)
  3765.     move.l    a5,d0
  3766.     lsr.l    #2,d0
  3767.     move.l    d0,myArg1(a5)    ;use FIB as INFO (bptr)
  3768.     bsr    sendpacket
  3769.     bsr    PKTerr
  3770.     bsr    do_forbid
  3771.     move.l    id_DiskType(a5),d0
  3772.     move.l    d0,d1
  3773.     clr.b    d1
  3774.     cmp.l    #"DOS"<<8,d1
  3775.     beq.s    itsDos        ;DOS-Disk
  3776.     lea    nodisk(pc),a0
  3777.     moveq    #-1,d1
  3778.     cmp.l    d1,d0
  3779.     beq.s    .F
  3780.     lea    baddisk(pc),a0
  3781.     cmp.l    #"BAD"<<8,d0
  3782.     beq.s    .F
  3783.     lea    nodos(pc),a0
  3784.     cmp.l    #"NDOS",d0
  3785.     beq.s    .F
  3786.     lea    kickdisk(pc),a0
  3787.     cmp.l    #"KICK",d0
  3788.     beq.s    .F
  3789.     lea    statun(pc),a0
  3790. .F    move.l    a0,-(sp)
  3791.     move.l    id_UnitNumber(a5),-(sp)
  3792.     move.l    a3,-(sp)
  3793.     bsr    do_permit
  3794.     lea    (sp),a1
  3795.     lea    inform2(pc),a0
  3796.     bsr    new_print
  3797.     lea    12(sp),sp
  3798.     bra    jajo
  3799.  
  3800. itsDos    move.l    id_VolumeNode(a5),a0    ;DOS-Disk
  3801.     add.l    a0,a0
  3802.     add.l    a0,a0
  3803.     move.l    $28(a0),a0        ;name    (hope, it is NULL-ending)
  3804.     add.l    a0,a0
  3805.     add.l    a0,a0
  3806.     addq.l    #1,a0
  3807.     move.l    a0,-(sp)
  3808.     move.l    id_NumSoftErrors(a5),-(sp)    ;SoftErrors
  3809.     move.l    id_DiskState(a5),d0
  3810.     lea    statro(pc),a0
  3811.     moveq    #80,d1
  3812.     cmp.l    d1,d0
  3813.     beq.s    .H
  3814.     lea    statrw(pc),a0
  3815.     moveq    #82,d1
  3816.     cmp.l    d1,d0
  3817.     beq.s    .H
  3818.     lea    statval(pc),a0
  3819.     moveq    #81,d1
  3820.     cmp.l    d1,d0
  3821.     beq.s    .H
  3822.     lea    statun(pc),a0
  3823. .H    move.l    a0,-(sp)        ;Status
  3824.     move.l    id_BytesPerBlock(a5),d1
  3825.     move.l    d1,-(sp)        ;BlockSize
  3826.     move.l    id_NumBlocks(a5),d0
  3827.     bsr    mult_32x32
  3828.     lsr.l    #8,d0
  3829.     lsr.l    #2,d0
  3830.     move.l    d0,d2
  3831.     move.l    id_NumBlocksUsed(a5),d0
  3832.     bsr    mult_32x32
  3833.     lsr.l    #8,d0
  3834.     lsr.l    #2,d0
  3835.     move.l    d2,d3
  3836.     sub.l    d0,d3
  3837.     moveq    #100,d1
  3838.     bsr    mult_32x32
  3839.     move.l    d2,d1
  3840.     beq.s    .D
  3841.     bsr    div_32    ;%
  3842. .D    exg    d0,d2
  3843.     move.l    d3,d1
  3844.     movem.l    d0-d2,-(sp)        ;Sizes
  3845.     lea    msd_tx(pc),a0    messydos ?
  3846.     move.l    $1c(a4),d0    dn_Startup
  3847.     moveq    #2,d1
  3848.     cmp.l    d1,d0
  3849.     bls.s    .A
  3850.     lsl.l    #2,d0
  3851.     move.l    d0,a1
  3852.     move.l    8(a1),d0    fssm_Environ
  3853.     beq.s    .A
  3854.     lsl.l    #2,d0
  3855.     move.l    d0,a1
  3856.     move.l    64(a1),d0    de_DosType
  3857.     cmp.l    #"MSD"<<8,d0    CrossDos ?
  3858.     beq.s    .C
  3859. .A    move.l    id_DiskType(a5),d0
  3860.     lea    quest_tx(pc),a0
  3861.     cmp.b    #5,d0
  3862.     bhi.s    .C    unknown
  3863.     ext.w    d0
  3864.     ext.l    d0
  3865.     lea    ofs_tx(pc),a0
  3866.     lsl.l    #2,d0
  3867.     add.l    d0,a0    d0*4+a0    access table
  3868. .C    move.l    a0,-(sp)        ;System
  3869.     move.l    id_UnitNumber(a5),-(sp)    ;Unit
  3870.     move.l    a3,-(sp)        ;Name
  3871.     bsr    do_permit
  3872.     lea    (sp),a1
  3873.     lea    inform(pc),a0
  3874.     bsr    new_print
  3875.     lea    40(sp),sp
  3876.     bra    jajo
  3877.  
  3878.  
  3879.  
  3880. *****************
  3881. *    ENDCLI    *    EXIT FROM ZSHELL TO CLI.
  3882. *****************    IF WE EXIT FROM SCRIPT THEN FREE SCRIPT MEMORY
  3883. endcliz    bsr    raw_off
  3884.     move.l    parm2(a5),a0
  3885.     bsr    return_dash_option
  3886.     moveq    #-1,d7
  3887.     cmp.b    #'C',d0
  3888.     bne.s    .A
  3889.     moveq    #0,d7
  3890. .A    tst.b    scflag(a5)
  3891.     beq.s    byebye
  3892.     bsr    kill_script
  3893. byebye    move.l    (sp)+,d0    ;kill return address on stack
  3894.     rts
  3895.  
  3896. ** SPLIT STRING(A0) INTO DIRECTORY PATH AND WILDCARD DESCRIPTION
  3897. ** NULL END THE PATH, AND MOVE THE WILDCARD TO (A1)
  3898. * eg. ram:c/*.info -> ram:c0 + *.info0
  3899.     
  3900. split_wild
  3901.     movem.l    d0-d1/a0-a2,-(sp)
  3902.     move.l    a0,d1
  3903. sp_w2    move.l    a0,a2    a2=temp
  3904. sp_w3    move.b    (a0)+,d0
  3905.     beq.s    sp_w4
  3906.     cmp.b    #':',d0
  3907.     beq.s    sp_w2    A0= 1 after :
  3908.     cmp.b    #'/',d0
  3909.     beq.s    sp_w2
  3910.     bra.s    sp_w3
  3911. sp_w4    cmp.l    a2,d1
  3912.     beq.s    sp_mis
  3913.     cmp.b    #':',-1(a2)
  3914.     bne.s    sp_w5
  3915. sp_mis    move.l    a2,d1    SAVE POSITION
  3916. sp_w6    move.b    (a2)+,(a1)+
  3917.     bne.s    sp_w6
  3918.     move.l    d1,a2
  3919.     clr.b    (a2)
  3920.     movem.l    (sp)+,d0-d1/a0-a2
  3921.     rts
  3922. sp_w5    clr.b    -1(a2)
  3923. sp_w7    move.b    (a2)+,(a1)+
  3924.     bne.s    sp_w7
  3925.     movem.l    (sp)+,d0-d1/a0-a2
  3926.     rts
  3927.     
  3928. ** CHECK STRING(A0) IF IT CONTAINS WILDCARD SPECIFIC CHARS
  3929. ** RETURN D0=0 IF WILDS FOUND
  3930. check_wild
  3931.     move.l    a0,-(sp)
  3932. chk_w3    move.b    (a0)+,d0
  3933.     beq.s    chk_w2
  3934.     cmp.b    #'*',d0
  3935.     beq.s    chk_w4
  3936.     cmp.b    #'~',d0    special not char
  3937.     beq.s    chk_w4
  3938.     cmp.b    #'[',d0
  3939.     beq.s    chk_w4
  3940.     cmp.b    #']',d0
  3941.     beq.s    chk_w4
  3942.     cmp.b    #'|',d0 or char
  3943.     beq.s    chk_w4
  3944.     cmp.b    #'?',d0
  3945.     bne.s    chk_w3
  3946. chk_w4    moveq    #0,d0
  3947.     move.l    (sp)+,a0
  3948.     rts
  3949. chk_w2    moveq    #1,d0
  3950.     move.l    (sp)+,a0
  3951.     rts
  3952.  
  3953. * NOTE this wildmatcher only handles cases where the wildcard has one * in it.
  3954. ** WILDCARD MATCHER. CHECK IF STRING(A0) MATCHES WILDCARD(A1)
  3955. ** RETURN D0=0 IF MATCH
  3956. wildmatch movem.l    d2/a2-a3,-(sp)
  3957.     move.b    (a1),d2
  3958.     cmp.b    #"~",d2        ;check if all is negated
  3959.     bne.s    .C
  3960.     addq.l    #1,a1
  3961. .C    move.l    a1,a2
  3962.     move.l    a0,a3
  3963. .A    move.b    (a2)+,d0
  3964.     beq.s    .B
  3965.     cmp.b    #"|",d0        ;or-symbol  V2.0
  3966.     bne.s    .A
  3967.     move.b    #0,-1(a2)    ;change wildcard to end
  3968.     bsr.s    wildermatch
  3969.     move.b    #"|",-1(a2)    ;restore
  3970.     tst.l    d0
  3971.     beq.s    gut
  3972.     lea    (a3),a0
  3973.     lea    (a2),a1
  3974.     bra.s    .A
  3975. .B    bsr.s    wildermatch
  3976. gut    cmp.b    #"~",d2
  3977.     bne.s    .D
  3978.     subq.l    #1,d0
  3979. .D    movem.l    (sp)+,d2/a2-a3
  3980.     rts
  3981.  
  3982. wildermatch
  3983.     cmp.b    #'~',(a1)        check for NOT specifier
  3984.     bne.s    wm_1
  3985.     move.b    (a1)+,d0
  3986.     bsr.s    wm_1
  3987.     subq.l    #1,d0    0 --> -1     1 --> 0
  3988.     rts
  3989.     
  3990. wm_1    move.b    (a0)+,d0
  3991.     beq    source_fin1
  3992.     move.b    (a1)+,d1
  3993.     cmp.b    #'*',d1
  3994.     beq.s    wild_run
  3995.     cmp.b    #'[',d1        handle character classes
  3996.     bne.s    .A
  3997. .B    move.b    (a1)+,d1
  3998.     beq.s    wild_fail
  3999.     cmp.b    #']',d1
  4000.     beq.s    wild_fail
  4001.     bsr    compD1D0nocase
  4002.     bne.s    .B
  4003. .C    move.b    (a1)+,d1
  4004.     beq.s    wild_fail
  4005.     cmp.b    #']',d1
  4006.     bne.s    .C
  4007.     bra.s    wm_1
  4008. .A    cmp.b    #'?',d1
  4009.     beq.s    wm_1
  4010.     bsr    compD1D0nocase
  4011.     beq.s    wm_1
  4012.     
  4013. wild_fail    moveq    #1,d0
  4014.     rts
  4015. wild_run    
  4016. wr_3    tst.b    (a0)+    GOTO END OF STRING
  4017.     bne.s    wr_3
  4018. wr_4    tst.b    (a1)+    GOTO END OF WILDCARD
  4019.     bne.s    wr_4
  4020. wr_5    move.b    -(a1),d0    get tail of wildcard (1st should be null)
  4021.     move.b    -(a0),d1
  4022.     cmp.b    #'*',d0
  4023.     beq.s    source_fin2
  4024.     cmp.b    #']',d0        handle class [xyz]
  4025.     bne.s    .A
  4026. .B    move.b    -(a1),d0
  4027.     cmp.b    #'*',d0
  4028.     beq.s    wild_fail
  4029.     cmp.b    #'[',d0
  4030.     beq.s    wild_fail
  4031.     bsr    compD1D0nocase
  4032.     bne.s    .B
  4033. .C    move.b    -(a1),d0
  4034.     beq.s    wild_fail    should never happen but should leave in
  4035.     cmp.b    #'[',d0
  4036.     bne.s    .C
  4037.     bra.s    wr_5
  4038. .A    cmp.b    #'?',d0
  4039.     beq.s    wr_5
  4040.     bsr    compD1D0nocase
  4041.     beq.s    wr_5
  4042.     bra.s    wild_fail
  4043. source_fin1
  4044.     tst.b    (a1)
  4045.     beq.s    source_fin2
  4046.     cmp.b    #'*',(a1)
  4047.     bne.s    wild_fail
  4048. source_fin2
  4049.     moveq    #0,d0
  4050.     rts
  4051.  
  4052. compD1D0nocase ;lowercase d0 and d1 then compare them
  4053.     cmp.b    #'Z',d1
  4054.     bhi.s    D1_OK
  4055.     cmp.b    #'A',d1
  4056.     blo.s    D1_OK
  4057.     add.b    #$20,d1
  4058. D1_OK    cmp.b    #'Z',d0
  4059.     bhi.s    D0_OK
  4060.     cmp.b    #'A',d0
  4061.     blo.s    D0_OK
  4062.     add.b    #$20,d0
  4063. D0_OK    cmp.b    d1,d0
  4064.     rts
  4065.     
  4066. fibexnx    move.l    d7,d1
  4067.     move.l    a5,d2
  4068.     jsr    _LVOExNext(a6)
  4069.     rts
  4070.  
  4071. *************************
  4072. *    RECOPY        *
  4073. *************************
  4074. rcsize    equ    50000        V2.0
  4075. recopyz    move.l    parm2(a5),a0        ;RECOPY DIR
  4076.     bsr    check_recurs
  4077.     tst.b    recurs_flag(a5)        ;RECURS-option ?
  4078.     beq    .A
  4079.     move.l    parm3(a5),parm2(a5)
  4080.     move.l    parm4(a5),parm3(a5)
  4081. .A    moveq    #0,d0
  4082.     bset.l    #29,d0        ;bit 29=recopy flag
  4083.     move.l    d0,temp2(a5)
  4084.     move.l    #rcsize,d0    ;50KB copy buffer
  4085.     moveq    #1,d1
  4086.     bsr    iwantmem
  4087.     move.l    d0,temp4(a5)
  4088.     beq.s    rece
  4089.     lea    date_mark(a5),a0
  4090.     bsr    get_time
  4091.     move.l    a0,a1
  4092.     lea    -14(sp),sp
  4093.     lea    (sp),a0
  4094.     bsr    convert_time
  4095.     lea    (sp),a1
  4096.     lea    time_text(pc),a0
  4097.     bsr    new_print
  4098.     lea    14(sp),sp
  4099.     bsr    directory         ;call it
  4100.     move.l    temp4(a5),a1
  4101.     move.l    #rcsize,d0
  4102.     bsr    givemem
  4103. rece    rts
  4104.  
  4105. *********************************
  4106. *    DIRECTORY LISTER    *
  4107. *********************************
  4108. dirz    clr.b    recurs_flag(a5)        ;WIDE DIR
  4109.     moveq    #1,d0
  4110.     bset.l    #31,d0        ;bit 31=wide flag
  4111.     move.l    d0,temp2(a5)
  4112.     bra.s    directory
  4113.     
  4114. listz    clr.l    temp2(a5)        ;NARROW DIR, clear wide flag
  4115. ;DON'T PUT ANYTHING HERE
  4116. *PRINT DIRECTORY A0-> name of directory
  4117. directory        ;V2.0:many things better (sort!)
  4118.     move.l    parm2(a5),a0
  4119.     bsr    check_recurs
  4120.     tst.b    recurs_flag(a5)        ;RECURS-option ?
  4121.     beq    .A
  4122.     move.l    parm3(a5),parm2(a5)
  4123.     move.l    parm4(a5),parm3(a5)
  4124. .A    bset.l    #30,temp2(a5)
  4125.     btst.l    #29,temp2(a5)    ;no quick recopy (will GURU !)
  4126.     bne.s    .B
  4127.     move.l    parm2(a5),a0
  4128.     bsr    return_dash_option
  4129.     cmp.b    #"Q",d0            ;QUICK-option ?
  4130.     bne.s    .B
  4131.     bclr.l    #30,temp2(a5)    ;bit 30=quick flag
  4132.     move.l    parm3(a5),parm2(a5)
  4133.     move.l    parm4(a5),parm3(a5)
  4134. .B    move.l    parm2(a5),a0
  4135.     bsr    return_dash_option
  4136.     cmp.b    #"R",d0            ;RECURS-option ?
  4137.     bne    .D
  4138.     move.b    #1,recurs_flag(a5)
  4139.     move.l    parm3(a5),parm2(a5)
  4140. .D    bsr    fixpam2
  4141.     bsr    rawh_off        V0.15
  4142.     clr.l    temp1(a5)            ;init total size
  4143.     clr.l    temp3(a5)
  4144.     clr.w    indent_count(a5)
  4145.     bsr    handle_wild_dirs
  4146.     move.l    a0,d1
  4147.     jsr    _LVODeviceProc(a6)
  4148.     tst.l    d0
  4149.     beq    DOSerr
  4150.     move.l    d0,devproc(a5)
  4151.     move.l    parm2(a5),a0
  4152.     lea    tempbuf(a5),a4
  4153. .C    move.b    (a0)+,(a4)+
  4154.     bne.s    .C
  4155.     bsr    pr_dir            ;print the dir
  4156. pr_size    movem.l    d0-d2,-(sp)
  4157.     move.l    temp2(a5),d0        ;are we printing wide
  4158.     bpl.s    .B
  4159.     btst.l    #0,d0
  4160.     bne.s    .B
  4161.     bsr    pr_lf
  4162. .B    lea    (sp),a1
  4163.     lea    totsize(pc),a0
  4164.     bsr    new_print
  4165.     lea    12(sp),sp
  4166.     moveq    #RETURN_OK,d0
  4167.     rts
  4168.  
  4169. fname    equ    40
  4170.  
  4171. pr_dir    sub.l    a3,a3    ;clr a3
  4172.     lea    tempbuf(a5),a0
  4173.     bsr    fibexam
  4174.     tst.l    fib_DirEntryType(a5)    ;check entry OK
  4175.     bpl.s    prd20            ;Directory V1.05
  4176.     btst.l    #29,temp2(a5)
  4177.     bne.s    .A
  4178.     bsr    pr_it            ;was a file
  4179. .A    bra    unlock            ;make sure to unlock
  4180.  
  4181. prd20    tst.w    indent_count(a5)        ;was a dir
  4182.     bne.s    prd2
  4183.     bsr    num_spc
  4184.     clr.b    (a2)
  4185.     lea    temp2buf(a5),a1
  4186.     bsr    pr_string
  4187.     lea    dirof(pc),a1
  4188.     bsr    pr_string
  4189.     lea    fib_FileName(a5),a1
  4190.     bsr    pr_stringlf        ;print dircetory's name
  4191. prd2
  4192.     bsr    check_c
  4193.     bne    unlock1
  4194.     bsr    fibexnx
  4195.     tst.l    d0
  4196.     beq    unlk        ;sort ?
  4197.     move.l    temp2(a5),d0
  4198.     btst    #31,d0
  4199.     beq.s    .C
  4200.     move.l    fib_Protection(a5),d0
  4201.     btst    #7,d0
  4202.     bne.s    prd2    hide if hide flag is set in wide dir lister
  4203.     lea    ignoreit(a5),a1        hide ctrl-ignore
  4204.     tst.b    (a1)
  4205.     beq.s    .C
  4206.     lea    fib_FileName(a5),a0
  4207.     bsr    wildmatch        ;wildcheck
  4208.     tst.b    d0
  4209.     beq.s    prd2
  4210. .C    tst.b    wild_flag(a5)
  4211.     beq.s    dozel
  4212.     tst.b    recurs_flag(a5)
  4213.     beq.s    .A
  4214.     tst.l    fib_DirEntryType(a5)
  4215.     bpl.s    dozel
  4216. .A    lea    fib_FileName(a5),a0
  4217.     lea    wild_string(a5),a1
  4218.     bsr    wildmatch        ;wildcheck
  4219.     tst.b    d0
  4220.     bne.s    prd2
  4221. dozel    btst.l    #30,temp2(a5)
  4222.     bne.s    collect
  4223.     bsr    zelma
  4224.     tst.l    d3
  4225.     bne    unlock2        CTRL-C pressed
  4226.     bra.s    prd2
  4227.  
  4228. collect moveq    #fname,d0        ;collect files to sort  V2.0
  4229.     lea    fib_FileName(a5),a0
  4230.     lea    (a0),a2
  4231. .A    addq.l    #1,d0
  4232.     tst.b    (a0)+
  4233.     bne.s    .A
  4234.     lea    fib_Comment(a5),a0
  4235. .B    addq.l    #1,d0
  4236.     tst.b    (a0)+
  4237.     bne.s    .B
  4238.     moveq    #1,d1
  4239.     bsr    iwantmem
  4240.     beq    unlock
  4241.     move.l    d0,a0
  4242.     move.l    a3,(a0)+
  4243.     lea    -4(a0),a3
  4244.     lea    fib_DiskKey(a5),a1    ;store fib in mem
  4245.     move.l    (a1)+,(a0)+
  4246.     move.l    (a1)+,(a0)+
  4247.     lea    fib_Protection(a5),a1
  4248.     moveq    #6,d1
  4249. .C    move.l    (a1)+,(a0)+
  4250.     dbra    d1,.C
  4251. .D    move.b    (a2)+,(a0)+    ;name
  4252.     bne.s    .D
  4253. .E    move.b    (a1)+,(a0)+    ;comment
  4254.     bne.s    .E
  4255.     bra    prd2
  4256.  
  4257. unlk    btst.l    #30,temp2(a5)
  4258.     beq    unlock
  4259.     move.l    a3,d0    
  4260.     beq    unlock    ;no files
  4261.  
  4262.     movem.l    a4-a6,-(sp)
  4263.     lea    (a3),a0        ;INSERTION SORT  V2.0   (ooohuuooo)
  4264. aussort    lea    (a3),a1
  4265.     move.l    (a0),a2    ;remove (a0->) a2
  4266.     move.l    a2,d0
  4267.     beq.s    snull    ;end of list
  4268.     move.l    (a2),(a0)
  4269.     bsr    strcmp    ;compare a1 and a2
  4270.     bne.s    insort    ;insert a2 (old place)
  4271.     move.l    a2,a3    ;a2->start
  4272.     move.l    a1,(a2)    ;a1=old start
  4273.     bra.s    aussort    ;next
  4274. insort    move.l    a1,a4    ;reminder
  4275.     move.l    (a1),a1    ;next a1
  4276.     cmp.l    a0,a4
  4277.     beq.s    inold
  4278. shno    bsr    strcmp    ;compare a1 and a2
  4279.     bne.s    insort    ;go on
  4280.     move.l    a2,(a4)    ;insert a2
  4281.     move.l    a1,(a2)    ;a4->a2->a1
  4282.     bra.s    aussort
  4283. inold    move.l    (a0),(a2) ;a2 back at old place
  4284.     move.l    a2,(a0)    ;a0->a2->next
  4285.     move.l    a2,a0    ;next a0
  4286.     bra.s    aussort
  4287. snull    movem.l    (sp)+,a4-a6    ;FINISHED !!!
  4288.  
  4289.     tst.l    temp2(a5)    for normal DIR
  4290.     bpl.s    nextfi
  4291.     tst.b    recurs_flag(a5)
  4292.     bne.s    nextfi
  4293.     moveq    #1,d0        prepare for printing in 2 columns
  4294.     move.l    a3,d1
  4295. .A    addq.l    #1,d0
  4296.     move.l    d1,a0
  4297.     move.l    (a0),d1
  4298.     bne.s    .A        count number of entries (d0)
  4299.     lsr.l    #1,d0        divide by two
  4300.     move.l    a3,a2
  4301.     bra.s    .B
  4302. .C    move.l    a2,a0
  4303.     move.l    (a2),a2
  4304. .B    dbra    d0,.C        find the middle    (a2 ,precedor in a0)
  4305.     clr.l    (a0)
  4306.  
  4307. nextfi    bsr    check_c    ;print all files
  4308.     bne    unlock1
  4309.     lea    4(a3),a1
  4310.     lea    fib_DiskKey(a5),a0    ;restore fib from mem
  4311.     move.l    (a1)+,(a0)+
  4312.     move.l    (a1)+,(a0)+
  4313.     lea    fib_Protection(a5),a0
  4314.     moveq    #6,d1
  4315. .F    move.l    (a1)+,(a0)+
  4316.     dbra    d1,.F
  4317.     moveq    #fname,d0
  4318.     lea    fib_FileName(a5),a0
  4319. .H    addq.l    #1,d0
  4320.     move.b    (a1)+,(a0)+    ;name
  4321.     bne.s    .H
  4322.     lea    fib_Comment(a5),a0
  4323. .B    addq.l    #1,d0
  4324.     move.b    (a1)+,(a0)+    ;comment
  4325.     bne.s    .B
  4326.     movem.l    d0/a2/a3,-(sp)
  4327.     bsr    zelma
  4328.     movem.l    (sp)+,d0/a2/a3
  4329.     move.l    (a3),d2
  4330.     lea    (a3),a1
  4331.     bsr    givemem
  4332.     move.l    d2,a3
  4333.     tst.l    temp2(a5)
  4334.     bpl.s    .A
  4335.     tst.b    recurs_flag(a5)
  4336.     bne.s    .A
  4337.     move.l    a2,a0        swap lower and upper list
  4338.     move.l    a3,a2
  4339.     move.l    a0,a3
  4340. .A    tst.l    d3
  4341.     bne.s    unlock2        CTRL-C pressed
  4342.     move.l    a3,d0        tst.l    a3
  4343.     bne    nextfi
  4344.  
  4345. unlock    moveq    #0,d3
  4346. unlock2    move.l    d7,d1
  4347.     jsr    _LVOUnLock(a6)
  4348.     move.l    temp1(a5),d0    ;total size
  4349.     move.l    temp2(a5),d1    ;No. of files and dirs
  4350.     btst.l    #31,d1
  4351.     beq.s    .A
  4352.     subq.l    #1,d1
  4353. .A    and.l    #$00ffffff,d1    ;16777215 files max. should be enough
  4354.     move.l    temp3(a5),d2    ;No. of dirs
  4355.     sub.l    d2,d1
  4356.     rts
  4357.  
  4358. unlock1    moveq    #1,d3
  4359.     bra    unlock2
  4360.  
  4361. strcmp    move.l    8(a1),d0
  4362.     move.l    8(a2),d1
  4363.     cmp.l    d0,d1        ;files prefered
  4364.     blo.s    donoth        ;a2:file, a1:dir
  4365.     bhi.s    inseit        ;a2:dir,  a1:file
  4366.     lea    fname(a1),a5
  4367.     lea    fname(a2),a6
  4368. stcmp    move.b    (a5)+,d1    ;compare strings in a3 and a4
  4369.     beq.s    donoth
  4370.     move.b    (a6)+,d0
  4371.     beq.s    inseit
  4372.     bsr    compD1D0nocase
  4373.     beq.s    stcmp
  4374.     bhi.s    donoth
  4375. inseit    moveq    #0,d0        ;insert it !
  4376.     rts
  4377. donoth    moveq    #1,d0        ;do nothing !
  4378.     rts
  4379.  
  4380.  
  4381. zelma    bsr    pr_it            ;print fib
  4382.     moveq    #0,d3
  4383.     tst.l    fib_DirEntryType(a5)    ;       recursively
  4384.     bmi.s    .B
  4385.     tst.b    recurs_flag(a5)
  4386.     bne.s    .C
  4387. .B    rts
  4388. .C    moveq    #100,d0    ;(24bytes per recurs + subs)
  4389.     bsr    stacktest
  4390.     bne    .B
  4391. ;    lea    fib_Date(a5),a0        ;save fib in stack
  4392. ;    moveq    #2,d0
  4393. ;.A    move.l    (a0)+,-(sp)
  4394. ;    dbra    d0,.A
  4395.     move.l    fib_DiskKey(a5),d0
  4396.     movem.l    d0/d7/a4,-(sp)
  4397.     lea    fib_FileName(a5),a0
  4398.     lea    -1(a4),a4
  4399.     lea    tempbuf(a5),a1
  4400.     cmp.l    a1,a4
  4401.     beq.s    jo
  4402.     cmp.b    #":",-1(a4)
  4403.     beq.s    jo
  4404.     move.b    #"/",(a4)
  4405.     lea    1(a4),a4
  4406. jo    move.b    (a0)+,(a4)+        ;addpath
  4407.     bne.s    jo
  4408.     addq.w    #2,indent_count(a5)
  4409. jojo    bsr    pr_dir            RECURSION    V2.0
  4410.     subq.w    #2,indent_count(a5)
  4411.     movem.l    (sp)+,d0/d7/a4
  4412.     move.l    d0,fib_DiskKey(a5)    ;restore fib
  4413.     lea    -1(a4),a0
  4414.     cmp.b    #"/",(a0)
  4415.     bne.s    .D
  4416.     clr.b    (a0)
  4417.     lea    1(a0),a0
  4418. .D    lea    (a0),a2
  4419.     lea    fib_FileName(a5),a1
  4420. je    move.b    (a0)+,(a1)+
  4421.     bne.s    je
  4422.     clr.b    (a2)
  4423.     moveq    #2,d0
  4424.     move.l    d0,fib_DirEntryType(a5)
  4425.     move.l    d0,fib_EntryType(a5)
  4426.     moveq    #0,d0
  4427.     move.l    d0,fib_Size(a5)
  4428.     move.l    d0,fib_NumBlocks(a5)
  4429. ;    lea    fib_Date+12(a5),a0
  4430. ;    moveq    #2,d0
  4431. ;.B    move.l    (sp)+,-(a0)
  4432. ;    dbra    d0,.B
  4433.     rts
  4434.  
  4435. pr_it    bsr    num_spc            ;print file or dir
  4436.     tst.l    fib_DirEntryType(a5)    ;check whether is dir
  4437.     bmi.s    .A            ;if plus,is directory
  4438.     move.l    temp2(a5),d0        ;check for "DIR -R"
  4439.     bpl.s    .G
  4440.     tst.b    recurs_flag(a5)
  4441.     beq.s    .G
  4442.     btst    #0,d0
  4443.     bne.s    .H
  4444.     subq.l    #1,temp2(a5)
  4445.     bsr    pr_lf            ;for DIR -R directories
  4446. .H    addq.l    #1,temp2(a5)
  4447. .G    lea    farb3(pc),a1        ;change foregnd colour
  4448.     bsr    addstring
  4449.     addq.l    #1,temp3(a5)        ;one dir more
  4450. .A    lea    fib_FileName(a5),a1
  4451.     move.l    a1,a0
  4452.     moveq    #-1,d2
  4453.     add.w    indent_count(a5),d2
  4454. .B    addq    #1,d2
  4455.     tst.b    (a0)+
  4456.     bne.s    .B
  4457.     bsr     addstring        ;print filename
  4458.     tst.l    fib_DirEntryType(a5)
  4459.     bpl.s    .C
  4460.     move.l    fib_Size(a5),d0
  4461.     add.l    d0,temp1(a5)        ;increase total size
  4462.     move.b    #" ",(a2)+
  4463.     moveq    #34,d1
  4464.     sub.w    d2,d1
  4465.     bsr    qdecpr
  4466.     bra.s    .E
  4467. .C    moveq    #29,d1
  4468.     sub.w    d2,d1
  4469.     bpl.s    .D
  4470.     moveq    #0,d1
  4471. .D    move.b    #" ",(a2)+
  4472.     dbra    d1,.D
  4473.     lea    dirtext(pc),a1
  4474.     bsr    addstring
  4475. .E    move.b    #" ",(a2)+
  4476.     move.b    #0,(a2)
  4477.     addq.l    #1,temp2(a5)
  4478.     move.l    temp2(a5),d0        ;are we printing wide
  4479.     bpl.s    wpro
  4480.     btst.l    #0,d0
  4481.     beq.s    .F
  4482.     move.b    #LF,(a2)+
  4483.     clr.b    (a2)
  4484.     lea    temp2buf(a5),a1
  4485.     bra    pr_string        ;print string&return and return
  4486. .F    move.b    #" ",(a2)+
  4487.     move.b    #" ",(a2)+
  4488.     move.b    #" ",(a2)+
  4489.     clr.b    (a2)
  4490.     lea    temp2buf(a5),a1
  4491.     bra    pr_string        ;send tab and return
  4492.  
  4493. wpro    lea    temp2buf(a5),a1
  4494.     bsr    pr_string
  4495.     bsr    pr_prot            print protection V2.0
  4496.     lea    fib_Date(a5),a1        (goes to temp2buf)
  4497.     lea    -14(sp),sp
  4498.     lea    (sp),a0
  4499.     bsr    convert_time
  4500.     lea    temp2buf(a5),a1
  4501.     addq.l    #8,a1            protect uses 8 bytes
  4502.     move.b    #" ",(a1)+
  4503.     bsr    qprint10
  4504.     move.b    #".",(a1)+
  4505.     bsr    qprint10
  4506.     move.b    #".",(a1)+
  4507.     bsr    qprint10
  4508.     move.b    #" ",(a1)+
  4509.     move.b    #" ",(a1)+
  4510.     bsr    qprint10
  4511.     move.b    #":",(a1)+
  4512.     bsr    qprint10
  4513.     move.b    #":",(a1)+
  4514.     bsr    qprint10
  4515.     clr.b    (a1)
  4516.     lea    14(sp),sp
  4517.     lea    temp2buf(a5),a1
  4518.     bsr    pr_string        ;print date/time V2.0
  4519.  
  4520.     btst.l    #29,temp2(a5)
  4521.     beq    fort2        ;recopy flag not set
  4522.     tst.l    fib_DirEntryType(a5)
  4523.     bpl    fort2        ;don't recopy dirs
  4524. hardo    movem.l    d4-d7/a2-a4,-(sp)    ;DO RECOPY V2.0
  4525.     move.l    d7,dirlock(a5)
  4526.     move.l    d7,d1
  4527.     jsr    _LVOCurrentDir(a6)    ;set current path
  4528.     move.l    d0,d7
  4529.     lea    fib_FileName(a5),a2
  4530.     lea    temp2buf(a5),a3
  4531.     moveq    #0,d6
  4532.     move.l    a2,a0
  4533.     move.l    a3,a1
  4534. .A    move.b    (a0)+,(a1)+
  4535.     bne.s    .A
  4536.     lea    -1(a1),a1
  4537.     lea    append(pc),a0
  4538. .B    move.b    (a0)+,(a1)+
  4539.     bne.s    .B
  4540.     move.l    a2,d1
  4541. dbrc    move.l    #MODE_OLDFILE,d2
  4542.     jsr    _LVOOpen(a6)    ;open fib file
  4543.     move.l    d0,d4
  4544.     beq    perr1        ;access_write lock ?
  4545.     move.l    a3,d1
  4546.     move.l    #MODE_NEWFILE,d2
  4547.     jsr    _LVOOpen(a6)    ;open new file (*.rcy)
  4548.     move.l    d0,d5
  4549.     beq    perr3        ;disk full ?
  4550. doreco    move.l    d4,d1
  4551.     move.l    temp4(a5),d2
  4552.     move.l    #rcsize,d3
  4553.     jsr    _LVORead(a6)
  4554.     move.l    d0,d3
  4555.     bmi    perr3        ;read error ?
  4556.     beq.s    recoend
  4557.     move.l    d3,-(sp)
  4558.     move.l    d5,d1
  4559.     move.l    temp4(a5),d2
  4560.     jsr    _LVOWrite(a6)
  4561.     move.l    (sp)+,d3
  4562.     tst.l    d0
  4563.     bmi    perr3        ;disk full ?
  4564.     cmp.l    d0,d3
  4565.     bne    perr3        ;disk full
  4566.     add.l    d0,d6
  4567.     bra.s    doreco
  4568. recoend    bsr    closett
  4569.     move.l    a2,d1
  4570.     moveq    #$0,d2
  4571.     jsr    _LVOSetProtection(a6)
  4572.     tst.l    d0
  4573.     beq    perr1
  4574.     move.l    a2,d1
  4575.     jsr    _LVODeleteFile(a6)    ;delete fib file
  4576.     tst.l    d0
  4577.     beq    perr1        ;is there a lock on it ?
  4578.     move.l    a3,d1
  4579.     move.l    a2,d2
  4580.     jsr    _LVORename(a6)
  4581.     tst.l    d0
  4582.     beq    perr1        ;?
  4583.     move.l    a2,d1
  4584.     move.l    fib_Protection(a5),d2
  4585.     jsr    _LVOSetProtection(a6)    ;set old protection
  4586.     tst.l    d0
  4587.     beq    perr1
  4588.     move.l    a2,d1
  4589.     lea    fib_Comment(a5),a0    ;copy comment
  4590.     move.l    a0,d2
  4591.     jsr    _LVOSetComment(a6)
  4592.     tst.l    d0
  4593.     beq    perr1
  4594.     bsr    clearArgs        ;set old date
  4595.     lea    fib_Date(a5),a0
  4596.     move.l    a0,myArg4(a5)
  4597.     move.l    devproc(a5),packettask(a5)
  4598.     move.l    dirlock(a5),myArg2(a5)
  4599.     lea    temp2buf(a5),a1
  4600.     move.l    a1,d2
  4601.     lsr.l    #2,d2
  4602.     move.l    d2,myArg3(a5)
  4603.     addq.l    #1,a1
  4604.     moveq    #-1,d0
  4605. .B    addq.l    #1,d0
  4606.     move.b    (a2)+,(a1)+
  4607.     bne.s    .B
  4608.     move.b    d0,temp2buf(a5)
  4609.     moveq    #ACTION_SET_DATE,d0
  4610.     move.l    d0,packettype(A5)
  4611.     bsr    sendpacket
  4612.     tst.l    sp_res1(a5)
  4613.     beq    perr1
  4614.     move.l    d7,d1
  4615.     jsr    _LVOCurrentDir(a6)    ;reset path
  4616.     cmp.l    fib_Size(a5),d6
  4617.     beq.s    sizok
  4618.     lea    errsiz(pc),a1    ;wrong size
  4619.     bsr    pr_string
  4620.     move.l    d6,d0
  4621.     bsr    print10
  4622.     bra.s    nsizeok
  4623. sizok    lea    prok(pc),a1    ;all OK
  4624.     bsr    pr_string
  4625. nsizeok    movem.l    (sp)+,d4-d7/a2-a4
  4626.  
  4627. fort2    bsr    pr_lf    ;hello again !
  4628.     tst.b    fib_Comment(a5)
  4629.     beq.s    fort
  4630.     bsr    num_spc
  4631.     lea    farb2(pc),a1
  4632.     bsr    pr_string
  4633.     lea    fib_Comment(a5),a1    ;print Comment V2.0
  4634.     bsr    pr_string
  4635.     lea    farb1(pc),a1
  4636.     bsr    pr_stringlf
  4637. fort    rts
  4638.  
  4639. perr3    bsr    closett
  4640. perr1    jsr    _LVOIoErr(a6)
  4641.     move.l    d0,-(sp)
  4642.     lea    errnum(pc),a1    ;errornumber
  4643.     bsr    pr_string
  4644.     move.l    (sp)+,d0
  4645.     bsr    print10
  4646. perr2    move.l    d7,d1
  4647.     jsr    _LVOCurrentDir(a6)    ;reset path
  4648.     movem.l    (sp)+,d4-d7/a2-a4
  4649.     bra.s    fort2
  4650.  
  4651. closett    move.l    d4,d1    ;close files in d4 & d5
  4652.     beq.s    .A
  4653.     jsr    _LVOClose(a6)
  4654. .A    move.l    d5,d1
  4655.     beq.s    .B
  4656.     jsr    _LVOClose(a6)
  4657. .B    rts
  4658.  
  4659. qprint10 move.w    (a0)+,d0    V2.0
  4660. qpr10    ext.l    d0    (also used by more)
  4661.     divu    #LF,d0    Value in d0 , Buffer in a1
  4662.     add.b    #"0",d0
  4663.     move.b    d0,(a1)+
  4664.     swap    d0
  4665.     add.b    #"0",d0
  4666.     move.b    d0,(a1)+
  4667.     rts
  4668.  
  4669. num_spc    lea    temp2buf(a5),a2        V2.0
  4670.     move.w    indent_count(a5),d0
  4671.     moveq    #$3f,d1
  4672.     and.l    d1,d0
  4673.     bra.s    .B
  4674. .A    move.b    #" ",(a2)+    the preceding spaces
  4675. .B    dbra    d0,.A
  4676. ;    move.b    #0,(a2)
  4677. ;    lea    temp2buf(a5),a1
  4678. ;    bsr    pr_string    ;print some spaces (fast)
  4679.     rts
  4680.  
  4681. addstring move.b (a1)+,(a2)+
  4682.     bne.s    addstring
  4683.     subq.l    #1,a2
  4684.     rts
  4685.  
  4686. qdecpr    * Number in d0.l , Length in d1.w , adds string to buffer in a2
  4687.     movem.l    d2/d3/a0,-(sp)    ;Prints Decimal Number in (a2)
  4688.     lea    -12(sp),sp
  4689.     move.l    sp,a0
  4690.     move.l    d1,d3
  4691.     moveq    #0,d2
  4692. .A    moveq    #LF,d1
  4693.     bsr    div_32
  4694.     add.b    #$30,d1
  4695.     move.b    d1,(a0)+
  4696.     addq.w    #1,d2
  4697.     tst.l    d0
  4698.     bne.s    .A
  4699.     sub.w    d2,d3
  4700.     subq.w    #1,d3
  4701.     bmi.s    .B
  4702. .D    move.b    #" ",(a2)+
  4703.     dbra    d3,.D
  4704. .B    subq.w    #1,d2
  4705. .C    move.b    -(a0),(a2)+
  4706.     dbra    d2,.C
  4707.     lea    12(sp),sp
  4708.     movem.l    (sp)+,d2/d3/a0
  4709.     rts
  4710.  
  4711.  
  4712.  
  4713. *** CHECK CTRL_C
  4714. ** RETURN NE if ctrl c, EQ if not
  4715. check_c    movem.l    d0-d1/a0-a1/a6,-(sp)    checks if CTRL_C pressed
  4716.     moveq    #0,d0
  4717.     moveq    #0,d1
  4718.     move.l    4.w,a6
  4719.     bset    #SIGBREAKB_CTRL_C,d1
  4720.     jsr    _LVOSetSignal(a6)
  4721.     btst    #SIGBREAKB_CTRL_C,d0
  4722.     beq.s    ck_nostop
  4723. ;    moveq    #0,d0
  4724. ;    moveq    #0,d1
  4725. ;    bset    #SIGBREAKB_CTRL_C,d1
  4726. ;    jsr    _LVOSetSignal(a6)
  4727.     move.l    dosbase(a5),a6
  4728.     lea    breaktx(pc),a0
  4729.     bsr    new_print
  4730.     moveq    #1,d0            NE: STOP!!!
  4731.     move.b    d0,ctrl_c_flag(a5)
  4732.     movem.l    (sp)+,d0-d1/a0-a1/a6
  4733.     rts
  4734. ck_nostop
  4735.     clr.b    ctrl_c_flag(a5)
  4736.     moveq    #0,d0            EQ: no stop
  4737.     movem.l    (sp)+,d0-d1/a0-a1/a6
  4738.     rts
  4739.  
  4740.  
  4741. *ALLOCATE MEMORY D0=size D1=type
  4742. iwantmem    movem.l d1/a0-a1,-(sp)
  4743.     move.l 4.w,a6
  4744.     jsr _LVOAllocMem(a6)
  4745.     move.l dosbase(a5),a6
  4746.     movem.l (sp)+,d1/a0-a1
  4747.     tst.l    d0
  4748.     rts
  4749. *FREEMEM A1=ptr to mem block D0=size
  4750. givemem    move.l    4.w,a6
  4751.     jsr    _LVOFreeMem(a6)
  4752.     move.l    dosbase(a5),a6
  4753.     rts
  4754.     
  4755.  
  4756. *REMOVE PATH A0-> source A1->destination
  4757. rempath    movem.l d0/a0-a2,-(sp)
  4758. rempath1    move.l a0,a2
  4759. rempath2    move.b (a0)+,d0
  4760.     cmp.b #'/',d0
  4761.     beq.s rempath1
  4762.     cmp.b #':',d0
  4763.     beq.s rempath1
  4764.     tst.b d0
  4765.     bne.s rempath2
  4766.     move.l a2,a0
  4767.     bsr cp_string
  4768.     movem.l (sp)+,d0/a0-a2
  4769.     rts
  4770.  
  4771.  
  4772. ** PRINT STRING (A1) USING indent_count(a5) AS A SPACE INDENT COUNT
  4773. prindent    movem.l    d7/a0-a1,-(sp)
  4774.     move.w    indent_count(a5),d7
  4775.     move.l    a1,a0
  4776.     and.w    #$3f,d7
  4777.     beq.s    .A
  4778.     bra.s    .B
  4779. .C    bsr    pr_space    print d7 spaces
  4780. .B    dbra    d7,.C
  4781.     move.l    a0,a1
  4782. .A    bsr    pr_string
  4783.     movem.l    (sp)+,d7/a0-a1
  4784.     rts
  4785.  
  4786. ** ENTRY A0 pts to parameter.
  4787. ** EXIT D0=lower case char after dash OR 0 if no dash command.
  4788. return_dash_option
  4789.     moveq    #0,d0
  4790.     cmp.b    #'-',(a0)
  4791.     bne.s    .B
  4792. .A    move.b    1(a0),d0
  4793.     cmp.b    #'a',d0
  4794.     blo.s    .B
  4795.     cmp.b    #'z',d0
  4796.     bhi.s    .B
  4797.     sub.b    #$20,d0
  4798. .B    rts
  4799.  
  4800. ** ENTRY A0 pts to parameter. If it is -r then set "recurs_flag, otherwise clr it
  4801. check_recurs
  4802.     move.l    d0,-(sp)
  4803.     clr.b    recurs_flag(a5)
  4804.     bsr    return_dash_option
  4805.     cmp.b    #'R',d0
  4806.     bne.s    .A
  4807.     move.b    #1,recurs_flag(a5)
  4808. .A    move.l    (sp)+,d0
  4809.     rts
  4810.  
  4811. *********************************
  4812. *    THE COPY COMMAND    *
  4813. *********************************
  4814. ** V1.23 major alterations to allow recursive file copying
  4815. copyz    lea    parm2(a5),a2
  4816.     tst.l    4(a2)        check if only 2 parameters
  4817.     beq    too_less_args
  4818.     move.l    (a2),a0
  4819.     bsr    check_recurs
  4820.     tst.b    recurs_flag(a5)
  4821.     beq.s    .A
  4822.     move.l    (a2)+,d0        bump the pointer
  4823. .A    tst.l    8(a2)        CHECK PARM4 IF DOING MULTIPLE FILE COPY
  4824.     beq.s    .B
  4825. .D    move.l    (a2)+,a3        multiple files to directory copy
  4826.     lea    -4(a2),a1
  4827. .C    move.l    (a1)+,d0        search for end
  4828.     bne.s    .C
  4829.     move.l    -8(a1),a4        grab dest directory
  4830.     cmp.l    a4,a3
  4831.     beq    copy_fin
  4832.     move.l    a2,-(sp)
  4833.     bsr.s    .E        do one copy
  4834.     move.l    (sp)+,a2
  4835.     tst.l    d0
  4836.     bne.s    copy_fail
  4837.     bra.s    .D
  4838.     
  4839. .B    move.l    (a2)+,a3        SOURCE
  4840.     move.l    (a2),a4        DEST
  4841. .E    move.l    a4,d1
  4842.     jsr    _LVODeviceProc(a6)
  4843.     tst.l    d0
  4844.     beq    DOSerr
  4845.     move.l    d0,devproc(a5)
  4846.     moveq    #0,d6
  4847.     clr.w    indent_count(a5)
  4848.     bsr    perform_copy
  4849.     tst.l    d6
  4850.     bne.s    copy_fail
  4851. copy_fin    moveq    #RETURN_OK,D0
  4852.     rts
  4853. copy_fail    moveq    #RETURN_ERROR,D0
  4854.     rts
  4855.  
  4856. ***  SUPPLEMENTARY COPY ROUTINES ***
  4857. ** ENTRY A2=fib, RETURN D0=address
  4858. alloc_file_space
  4859.     move.l    fib_Size(a2),d0
  4860.     move.l    d0,4+cp_filesize(sp)
  4861.     moveq    #1,d1
  4862.     bsr    iwantmem        ALLOCATE SPACE FOR FILE
  4863.     move.l    d0,4+cp_fileaddr(sp)    save 0 if failure
  4864.     rts
  4865.     
  4866. ** ENTRY D1=name, RETURN D0=handle
  4867. open_read_file
  4868.     move.l    #MODE_OLDFILE,d2
  4869.     jsr    _LVOOpen(a6)    OPEN FILE
  4870.     move.l    d0,4+cp_ropen(sp)    save the handle
  4871.     rts
  4872.  
  4873. **ENTRY D0=handle
  4874. read_to_mem
  4875.     move.l    d0,d1
  4876.     move.l    4+cp_fileaddr(sp),d2
  4877.     move.l    4+cp_filesize(sp),d3
  4878.     jsr    _LVORead(a6)    READ FILE returns -1 if error
  4879.     rts
  4880.  
  4881. close_read_file
  4882.     move.l    4+cp_ropen(sp),d1
  4883.     jsr    _LVOClose(a6)    CLOSE FILE
  4884.     clr.l    4+cp_ropen(sp)        null it incase later dos errs
  4885.     rts
  4886.  
  4887. **ENTRY D1=name, RETURN D0=handle
  4888. open_write_file
  4889.     move.l    #MODE_NEWFILE,d2
  4890.     jsr    _LVOOpen(a6)    OPEN FILE
  4891.     move.l    d0,4+cp_wopen(sp)    save the handle
  4892.     rts
  4893.  
  4894. **ENTRY D0=handle
  4895. write_from_mem
  4896.     move.l    d0,d1
  4897.     move.l    4+cp_fileaddr(sp),d2
  4898.     move.l    4+cp_filesize(sp),d3
  4899.     jsr    _LVOWrite(a6)    WRITE FILE returns -1 if error
  4900.     rts
  4901.  
  4902. close_write_file
  4903.     move.l    4+cp_wopen(sp),d1
  4904.     jsr    _LVOClose(a6)    CLOSE FILE
  4905.     clr.l    4+cp_wopen(sp)
  4906.     rts
  4907.  
  4908. dealloc_file_space
  4909.     move.l    4+cp_fileaddr(sp),a1
  4910.     move.l    4+cp_filesize(sp),d0
  4911.     bsr    givemem        DEALLOCATE FILE SPACE
  4912.     clr.l    4+cp_fileaddr(sp)
  4913.     rts
  4914.  
  4915. ;restorethings        ;does not work
  4916. ;    movem.l    a2-a3,-(sp)
  4917. ;    lea    fib_FileName(a2),a3
  4918. ;    move.l    a3,d1
  4919. ;    move.l    fib_Protection(a2),d2
  4920. ;    jsr    _LVOSetProtection(a6)    ;set old protection
  4921. ;    tst.l    d0
  4922. ;    beq    cerr1
  4923. ;    move.l    a3,d1
  4924. ;    lea    fib_Comment(a2),a0    ;copy comment
  4925. ;    move.l    a0,d2
  4926. ;    jsr    _LVOSetComment(a6)
  4927. ;    tst.l    d0
  4928. ;    beq    cerr1
  4929. ;    bsr    clearArgs        ;set old date
  4930. ;    lea    fib_Date(a2),a0
  4931. ;    move.l    a0,myArg4(a5)
  4932. ;    move.l    devproc(a5),packettask(a5)
  4933. ;    move.l    d7,myArg2(a5)
  4934. ;    lea    temp2buf(a5),a1
  4935. ;    move.l    a1,d2
  4936. ;    lsr.l    #2,d2
  4937. ;    move.l    d2,myArg3(a5)
  4938. ;    addq.l    #1,a1
  4939. ;    moveq    #-1,d0
  4940. ;.B    addq.l    #1,d0
  4941. ;    move.b    (a3)+,(a1)+
  4942. ;    bne.s    .B
  4943. ;    move.b    d0,temp2buf(a5)
  4944. ;    moveq    #ACTION_SET_DATE,d0
  4945. ;    move.l    d0,packettype(a5)
  4946. ;    bsr    sendpacket
  4947. ;    tst.l    sp_res1(a5)
  4948. ;    beq    cerr1
  4949. ;    movem.l    (sp)+,a2-a3
  4950. ;    moveq    #0,d0
  4951. ;    rts
  4952. ;cerr1    movem.l    (sp)+,a2-a3
  4953. ;    moveq    #-1,d0
  4954. ;    rts
  4955.  
  4956. print_copyOK
  4957.     lea    copyOK(pc),a1
  4958.     bsr    pr_string        ;print '...copied'
  4959.     rts
  4960.     
  4961. *STACK STUFF
  4962. cp_fibaddr    equ    0
  4963. cp_srclock    equ    cp_fibaddr+4
  4964. cp_fileaddr    equ    cp_srclock+4
  4965. cp_filesize    equ    cp_fileaddr+4
  4966. cp_ropen        equ    cp_filesize+4
  4967. cp_wopen        equ    cp_ropen+4
  4968. cp_fname        equ    cp_wopen+4    allow 128 bytes
  4969.     
  4970. cp_size        equ    cp_fname+128
  4971.  
  4972. ** RECURSIVE STACK FRAME
  4973. nth_srcname    equ    0
  4974. nth_destname    equ    128
  4975. nth_size        equ    256
  4976.     
  4977. ** ENTRY A3 = source   A4 = destination  D6=0 no errors yet, NE just exit
  4978. ** indent_count(a5) is used
  4979. perform_copy
  4980.     tst.l    d6
  4981.     beq.s    .A    exit if D6<>0
  4982.     rts
  4983. .A    lea    -cp_size(sp),sp    ALLOCATE STACK SPACE
  4984.     move.l    sp,a0
  4985.     lea    cp_fname(sp),a1
  4986. .B    clr.b    (a0)+        clear all parameters on stack
  4987.     cmp.l    a1,a0
  4988.     blo.s    .B
  4989.     move.l    a3,a0
  4990.     bsr    handle_wild_dirs
  4991.     move.l    a3,d1
  4992.     moveq    #ACCESS_READ,d2
  4993.     jsr    _LVOLock(a6)
  4994.     move.l    d0,cp_srclock(sp)    store 0 if failure
  4995.     tst.l    d0
  4996.     beq    kill_copyDOS
  4997. * ALLOCATE FILEINFOBLOCK
  4998.     move.l    #FIB,D0
  4999.     moveq    #1,d1
  5000.     bsr    iwantmem
  5001.     move.l    d0,cp_fibaddr(sp)    store 0 if failure ,save fib addr
  5002.     beq    kill_copy
  5003. * EXAMINE SOURCE
  5004.     move.l    cp_srclock(sp),d1
  5005.     move.l    cp_fibaddr(sp),d2
  5006.     move.l    d2,a2        A2=fibaddr
  5007.     jsr    _LVOExamine(a6)    EXAMINE SOURCE
  5008.     tst.l    d0
  5009.     beq    kill_copyDOS
  5010.     lea    fib_FileName(a2),a1
  5011. *    bsr    pr_string
  5012.     tst.l    fib_DirEntryType(a2)
  5013.     bpl    next_dir_entry    if source is dir then attempt dir to dir
  5014.  
  5015. * HANDLE FILE TO FILE or FILE TO DIR
  5016.     move.l    a3,a1
  5017.  
  5018.     bsr    prindent        PRINT NAME OF FILE BEING COPIED
  5019.     move.l    cp_fibaddr(sp),a2    reset a2 to fibaddr
  5020.     bsr    alloc_file_space
  5021.  
  5022.     tst.l    d0
  5023.     beq    kill_copy
  5024.     move.l    a3,d1
  5025.     bsr    open_read_file
  5026.  
  5027.     tst.l    d0
  5028.     beq    kill_copyDOS
  5029.     bsr    read_to_mem
  5030.  
  5031.     tst.l    d0
  5032.     bmi    kill_copyDOS
  5033.     bsr    close_read_file
  5034.     
  5035.     move.l    a3,a0
  5036.     lea    cp_fname(sp),a1
  5037.     bsr    rempath        REMOVE PATH FROM SRC NAME
  5038.     move.l    a4,d1
  5039.     moveq    #ACCESS_READ,d2
  5040.     jsr    _LVOLock(a6)    LOCK DEST
  5041.     move.l    d0,d7
  5042.     beq    do_file_to_file
  5043.     move.l    d0,d1
  5044.     move.l    d0,d5        D5=lock temporary
  5045.     move.l    cp_fibaddr(sp),d2
  5046.     move.l    d2,a2        A2=fibaddr
  5047.     jsr    _LVOExamine(a6)    EXAMINE SOURCE  assume does not fail
  5048.     move.l    fib_DirEntryType(a2),d4
  5049.     move.l    d5,d1
  5050.     jsr    _LVOUnLock(a6)
  5051.     tst.l    d4
  5052.     bmi    do_file_to_file
  5053.     move.l    a4,a0        DO ONLY IF FILE TO DIR
  5054.     lea    cp_fname(sp),a1
  5055.     lea    fib_FileName(a2),a2    !!!! USING FIB AS TEMPORARY FOR NEW FNAME
  5056.     bsr    addpath
  5057.     move.l    a2,d1
  5058.     bra.s    go_open
  5059. do_file_to_file
  5060.     move.l    a4,d1        destination = new filename
  5061. go_open    bsr    open_write_file
  5062.     tst.l    d0
  5063.     beq    kill_copyDOS
  5064.     move.l    cp_fibaddr(sp),a2    reset a2 to fibaddr
  5065.     bsr    write_from_mem
  5066.     tst.l    d0
  5067.     bmi    kill_copyDOS
  5068. ;    bsr    restorethings
  5069. ;    bne    kill_copyDOS
  5070.     bsr    close_write_file
  5071.     bsr    dealloc_file_space
  5072.     bsr    print_copyOK
  5073.     bra    exit_cp
  5074.  
  5075. ** MAIN LOOP FOR DIR TO DIR COPYING STARTS HERE
  5076. next_dir_entry
  5077.     bsr    check_c
  5078.     bne    kill_copy
  5079.     move.l    cp_srclock(sp),d1
  5080.     move.l    cp_fibaddr(sp),d2
  5081.     move.l    d2,a2        guarantee a2=fibaddr
  5082.     jsr    _LVOExNext(a6)    get next entry
  5083.     tst.l    d0
  5084.     beq.s    exit_cp
  5085.     
  5086.     tst.b    wild_flag(a5)
  5087.     beq    test_if_file
  5088.     lea    fib_FileName(a2),a0
  5089.     lea    wild_string(a5),a1
  5090.     bsr    wildmatch
  5091.     tst.b    d0
  5092.     bne.s    next_dir_entry
  5093.     bra    test_if_file
  5094.  
  5095. exit_cp    move.l    cp_srclock(sp),d1    if no more entries then exit
  5096.     jsr    _LVOUnLock(a6)
  5097.     move.l    cp_fibaddr(sp),a1
  5098.     move.l    #FIB,d0
  5099.     bsr    givemem
  5100.     lea    cp_size(sp),sp
  5101.     rts            EXIT BACK
  5102. test_if_file
  5103.     tst.l    fib_DirEntryType(a2)
  5104.     bpl    must_be_dir
  5105.     move.l    a3,a0        *** COPY A FILE ***
  5106.     lea    fib_FileName(a2),a1
  5107.     lea    cp_fname(sp),a2
  5108.     bsr    addpath        add src dir path to filename
  5109.     move.l    a2,a1
  5110.     bsr    prindent        PRINT NAME OF FILE BEING COPIED
  5111.     move.l    cp_fibaddr(sp),a2    reset a2 to fibaddr
  5112.     bsr    alloc_file_space
  5113.  
  5114.     tst.l    d0
  5115.     beq    kill_copy
  5116.     lea    cp_fname(sp),a0
  5117.     move.l    a0,d1
  5118.     bsr    open_read_file
  5119.     tst.l    d0
  5120.     beq    kill_copyDOS
  5121.     bsr    read_to_mem
  5122.     tst.l    d0
  5123.     bmi    kill_copyDOS
  5124.     bsr    close_read_file
  5125.     
  5126.     move.l    a4,a0        dest name
  5127.     lea    fib_FileName(a2),a1
  5128.     lea    cp_fname(sp),a2
  5129.     bsr    addpath        add dest dir path to filename
  5130.     
  5131.     move.l    a2,d1
  5132.     bsr    open_write_file
  5133.  
  5134.     tst.l    d0
  5135.     beq    kill_copyDOS
  5136.     move.l    cp_fibaddr(sp),a2    reset a2 to fibaddr
  5137.     bsr    write_from_mem
  5138.  
  5139.     tst.l    d0
  5140.     bmi    kill_copyDOS
  5141.     bsr    close_write_file
  5142.     bsr    dealloc_file_space
  5143.     bsr    print_copyOK
  5144.     BRA    next_dir_entry
  5145. must_be_dir
  5146.     tst.b    recurs_flag(a5)
  5147.     beq    next_dir_entry
  5148.     move.l    #520,d0    ;(nth_size+cp_size+subs)
  5149.     bsr    stacktest
  5150.     bne    next_dir_entry
  5151.     lea    -nth_size(sp),sp
  5152.     move.l    a4,a0
  5153.     lea    fib_FileName(a2),a1
  5154.     lea    nth_destname(sp),a2    NEW DESTINATION DIRECTORY
  5155.     bsr    addpath        add dest dir path to filename
  5156.     
  5157.     move.l    a2,d1
  5158.     jsr    _LVOCreateDir(a6)    dont care if error is reported
  5159.     move.l    d0,d1             (will be picked up later)
  5160.     beq.s    .A
  5161.     jsr    _LVOUnLock(a6)
  5162. .A    move.l    cp_fibaddr+nth_size(sp),a2
  5163.     move.l    a3,a0
  5164.     lea    fib_FileName(a2),a1
  5165.     lea    nth_srcname(sp),a2    NEW SOURCE DIRECTORY
  5166.     bsr    addpath
  5167.     move.l    a2,a1
  5168.     bsr    prindent        PRINT NAME OF NEW DIR
  5169.     bsr    pr_lf
  5170.     addq.w    #2,indent_count(a5)
  5171.     MOVEM.L    a3-a4,-(sp)    save old source and dest
  5172.     lea    8+nth_srcname(sp),a3
  5173.     lea    8+nth_destname(sp),a4
  5174.     bsr    perform_copy    RECURSION!!!!
  5175.     MOVEM.L    (SP)+,A3-A4
  5176.     lea    nth_size(sp),sp
  5177.     subq.w    #2,indent_count(a5)
  5178.     tst.l    d6
  5179.     bne    kill_copy
  5180.     bra    next_dir_entry
  5181.  
  5182.     
  5183. *** SAFELY HANDLE ERRORS
  5184. kill_copyDOS
  5185.     jsr    _LVOIoErr(a6)
  5186.     bsr    pr_DOSerr        print error
  5187. kill_copy    move.l    cp_fibaddr(sp),d0
  5188.     beq.s    .A
  5189.     move.l    d0,a1
  5190.     move.l    #FIB,d0
  5191.     bsr    givemem
  5192. .A    move.l    cp_srclock(sp),d1
  5193.     beq.s    .B
  5194.     jsr    _LVOUnLock(a6)
  5195. .B    move.l    cp_fileaddr(sp),d0
  5196.     beq.s    .C
  5197.     move.l    d0,a1
  5198.     move.l    cp_filesize(sp),d0
  5199.     bsr    givemem
  5200. .C    move.l    cp_ropen(sp),d1
  5201.     beq.s    .D    open return D0=0 if failure
  5202.     jsr    _LVOClose(a6)
  5203. .D    move.l    cp_wopen(sp),d1
  5204.     beq.s    .E
  5205.     jsr    _LVOClose(a6)
  5206. .E    MOVEQ    #1,D6        SET THE ERROR FLAG!!!!!
  5207.     lea    cp_size(sp),sp
  5208.     rts            EXIT BACK
  5209.  
  5210. ***    END oF COPY    ***
  5211.  
  5212.  
  5213. ** ENTRY A0=name
  5214. ** EXIT  D0=address, D1=size
  5215. readfile    movem.l    d2-d6/a0-a4,-(sp)
  5216.     move.l    a0,d1
  5217.     move.l    a0,a4
  5218.     move.l    #MODE_OLDFILE,d2
  5219.     jsr    _LVOOpen(a6)    OPEN FILE
  5220.     move.l    d0,d4    d4=handle
  5221.     bne.s    gotop
  5222.     moveq    #-1,d1        Don't request
  5223.     bsr    changeWindowPtr
  5224.     lea    patharea(a5),a0    CHECK PATH LIST  V2.0
  5225. rpa_3    tst.b    (a0)
  5226.     beq    readerr    CHECK IF PATH LIST IS EMPTY
  5227.     move.l    a0,d5
  5228.     move.l    a4,a1
  5229.     lea    tempbuf(a5),a2        ;use temp buffer
  5230.     bsr    addpath
  5231.     bra.s    rpa_2
  5232. readpathfile        ;entry:    a2=name with path (must exist)
  5233.     movem.l    d2-d6/a0-a4,-(sp)
  5234. rpa_2    move.l    a2,d1
  5235.     move.l    #MODE_OLDFILE,d2
  5236.     jsr    _LVOOpen(a6)
  5237.     move.l    d0,d4
  5238.     bne.s    gotop
  5239.     move.l    d5,a0
  5240. rpa_1    tst.b    (a0)+
  5241.     bne.s    rpa_1
  5242.     bra.s    rpa_3
  5243. gotop    moveq    #0,d1
  5244.     bsr    changeWindowPtr
  5245.     moveq    #1,d3
  5246.     moveq    #0,d2
  5247.     move.l    d4,d1
  5248.     jsr    _LVOSeek(a6)
  5249.     moveq    #-1,d3
  5250.     moveq    #0,d2
  5251.     move.l    d4,d1
  5252.     jsr    _LVOSeek(a6)
  5253.     move.l    d0,d5    d5=size    ;handles also powerpacked files
  5254.     moveq    #1,d1
  5255.     bsr    iwantmem
  5256.     beq    readerr2
  5257.     move.l    d0,d6    d6=addr
  5258.     move.l    d6,d2
  5259.     move.l    d5,d3
  5260.     move.l    d4,d1
  5261.     jsr    _LVORead(a6)    READ IT
  5262.     tst.l    d0
  5263.     bmi    readerr3
  5264.     move.l    d4,d1
  5265.     jsr    _LVOClose(a6)
  5266.     move.l    d6,d0
  5267.     move.l    d5,d1
  5268.     movem.l    (sp)+,d2-d6/a0-a4
  5269.     rts
  5270. readerr3    move.l    d6,a1
  5271.     move.l    d5,d0
  5272.     bsr    givemem        ;NB won't work correctly if memory fail occurs.
  5273.                  ;Will try to print DOS error for this
  5274. readerr2    move.l    d4,d1
  5275.     jsr    _LVOClose(a6)
  5276. readerr        moveq    #0,d1
  5277.     bsr    changeWindowPtr
  5278.     move.l    please_close_me(a5),d1    V1.29 Allows for additional
  5279.     beq.s    .A            file closure. Needed for
  5280.     jsr    _LVOClose(a6)        JOIN command
  5281.     clr.l    please_close_me(a5)
  5282. .A    bra    DOSerr
  5283.  
  5284. *****************
  5285. *    MORE    *
  5286. *****************
  5287. morez    tst.l    parm2(a5)
  5288.     beq    too_less_args
  5289.     move.w    line_count(a5),d4
  5290.     move.l    parm3(a5),d0
  5291.     beq    .C
  5292.     move.l    d0,a1
  5293.     bsr    convert_ASCII_to_num
  5294.     beq    bad_number_error
  5295.     tst.w    d0
  5296.     beq.s    .C
  5297.     subq.w    #1,d0
  5298.     move.w    d0,d4
  5299. .C    move.w    d4,line_count(a5)
  5300.  
  5301.     move.l    parm2(a5),a0
  5302.     bsr    readfile
  5303.     moveq    #0,d2
  5304. ViewMore        ;Jump-In to review the buffer
  5305.     move.l    d0,-(sp)    push address
  5306.     move.l    d1,-(sp)    push size
  5307.     addq.b    #1,noreview_flag(a5)
  5308.     bsr    make_screen
  5309.     clr.b    noreview_flag(a5)
  5310.     move.l    (sp)+,d0
  5311.     move.l    (sp)+,a1
  5312.     bsr    givemem
  5313.     moveq    #RETURN_OK,D0
  5314.     RTS
  5315.  
  5316. make_screen    * more main-routine, also used for help
  5317.     move.l    d0,d5    d5=start
  5318.     move.l    d0,a4    a4=ptr
  5319.     move.l    d0,a3
  5320.     move.l     d0,d6
  5321.     add.l    d1,d6    d6=end addr
  5322.     tst.l    d2
  5323.     beq.s    mk_screen
  5324.     move.l    d6,a4
  5325.     bra    look_back
  5326. mk_screen
  5327.     lea    clrhide(pc),a1
  5328.     bsr    pr_string
  5329.     move.w    line_count(a5),d2
  5330.     move.l    a4,-(sp)
  5331.     moveq    #0,d0
  5332.     bra.s    .A
  5333. .C    moveq    #1,d0    PRINT SCREEN FULL OF LINES
  5334. .A;    bsr    pr_line
  5335. .B    cmp.l    d6,a4    check against end
  5336.     beq.s    .E
  5337.     move.b    (a4)+,d0
  5338.     cmp.b    #LF,d0
  5339.     bne.s    .B
  5340.     dbra    d2,.C
  5341.     move.l    a4,a3    A3 points to end of page marker    
  5342. .E    move.l    a4,d7    D7 points to end
  5343.     move.l    (sp)+,a4
  5344. ;    bra    waitabit
  5345.  
  5346.     move.l    a4,d2
  5347.     move.l    outhandle(a5),d1
  5348.     beq.s    waitabit
  5349.     move.l    d7,d3
  5350.     sub.l    a4,d3
  5351.     subq.l    #1,d3
  5352.     bmi.s    waitabit    don't print if 0
  5353.     cmp.l    d7,d6
  5354.     bne.s    .D
  5355.     cmp.l    a3,d7
  5356.     beq.s    .D
  5357.     addq.l    #1,d3
  5358. .D    jsr    _LVOWrite(a6)
  5359.  
  5360. waitabit    
  5361.     move.l    inhandle(a5),d1
  5362.     beq    cloga
  5363.     lea    tempbytes(a5),a0
  5364.     move.l    a0,d2
  5365.     moveq    #1,d3
  5366.     jsr    _LVORead(a6)        wait for space key
  5367. .A    moveq    #0,d0            clear top bytes
  5368.     move.b    tempbytes(a5),d0    test byte of input line
  5369.     cmp.b    #$9b,d0
  5370.     beq.s    waitabit        CSI ? Try again !
  5371. tastes    cmp.b    #'a',d0
  5372. ;    blo.s    go_upper
  5373. ;    sub.b    #$20,d0
  5374.  
  5375. go_upper    cmp.b    #$42,d0        cursor down ?
  5376.     bne.s    ck_up
  5377.     cmp.l    d7,d6
  5378.     beq    waitabit
  5379.     lea    scroll_up_tx(pc),a1    SCROLL UP ONE LINE,
  5380.     bsr    pr_string    SEND CURSOR TO START OF LINE
  5381. .B    cmp.l    d6,a4    advance one line
  5382.     beq.s    .C
  5383.     move.b    (a4)+,d0
  5384.     cmp.b    #LF,d0
  5385.     bne.s    .B
  5386. .C    cmp.l    d6,a3    move a3 down one line too
  5387.     beq.s    .D
  5388.     move.b    (a3)+,d0
  5389.     cmp.b    #LF,d0
  5390.     bne.s    .C
  5391. .D    move.l    a4,-(sp)
  5392.     move.l    d7,a4
  5393. ;    cmp.l    d7,d6
  5394. ;    beq.s    .A
  5395.     moveq    #0,d0
  5396.     bsr    pr_line    print line from d7
  5397. .A    cmp.l    d6,a4    advance D7 one line
  5398.     beq.s    .E
  5399.     move.b    (a4)+,d0
  5400.     cmp.b    #LF,d0
  5401.     bne.s    .A
  5402. .E    move.l    a4,d7
  5403.     move.l    (sp)+,a4
  5404.     bra    waitabit
  5405.  
  5406. ck_up    cmp.b    #$41,d0        V2.0    cursor up ?
  5407.     bne.s    ck_fwd
  5408.     cmp.l    d5,a4
  5409.     beq    waitabit
  5410.     lea    scroll_down_tx(pc),a1    SCROLL DOWN ONE LINE,
  5411.     bsr    pr_string    SEND CURSOR TO TOP LEFT
  5412.     cmp.l    d5,a4
  5413.     bls.s    .E
  5414.     subq.l    #1,a4
  5415. .B    cmp.l    d5,a4
  5416.     beq.s    .A
  5417.     cmp.b    #LF,-(a4)
  5418.     bne.s    .B
  5419.     addq.l    #1,a4
  5420. .A    moveq    #0,d0
  5421.     bsr    pr_line
  5422. .E    move.l    d7,a3
  5423.     cmp.l    d5,a3
  5424.     beq.s    .C
  5425.     subq.l    #1,a3
  5426. .D    cmp.l    d5,a3
  5427.     beq.s    .C
  5428.     cmp.b    #LF,-(a3)
  5429.     bne.s    .D
  5430.     addq.l    #1,a3
  5431. .C    move.l    a3,d7
  5432.     lea    temp2buf(a5),a1
  5433.     move.b    #$9b,(a1)+
  5434.     move.w    line_count(a5),d0
  5435.     addq.w    #1,d0
  5436.     bsr    qpr10
  5437.     move.b    #"H",(a1)+
  5438.     clr.b    (a1)
  5439.     lea    temp2buf(a5),a1
  5440.     bsr    pr_string    CURSOR some lines down
  5441.     bra    waitabit
  5442.  
  5443. ck_fwd    cmp.b    #$43,d0            cursor right ?
  5444.     bne.s    ck_top
  5445.     cmp.l    d7,d6
  5446.     beq    waitabit
  5447.     move.l    a3,a4
  5448.     bra    mk_screen
  5449. ck_top    cmp.b    #$54,d0            cursor left ?
  5450.     bne.s    ck_bot
  5451.     cmp.l    d5,a4
  5452.     beq    waitabit
  5453.     move.l    d5,a4
  5454.     bra    mk_screen
  5455. ck_bot    cmp.b    #$53,d0            shift cursor down ?
  5456.     bne.s    ck_back
  5457.     cmp.l    a3,d6
  5458.     beq    waitabit
  5459.     move.l    d6,a4
  5460.     bra.s    look_back
  5461. ck_back    cmp.b    #$44,d0            shift cursor up ?
  5462.     bne.s    ck_skey
  5463.     cmp.l    d5,a4
  5464.     beq    waitabit
  5465. look_back
  5466.     move.w    line_count(a5),d1
  5467.     addq.w    #1,d1
  5468. .F    cmp.l    d5,a4    check against start
  5469.     beq.s    .E
  5470.     move.b    -(a4),d0
  5471.     cmp.b    #LF,d0
  5472.     bne.s    .F
  5473.     dbra    d1,.F
  5474.     lea    1(a4),a4
  5475. .E    bra    mk_screen
  5476.  
  5477. ck_skey    cmp.b    #"s",d0        V2.0    search string ?
  5478.     bne.s    ck_pkey
  5479.     bsr    raw_off
  5480.     lea    msearch(pc),a1
  5481.     bsr    pr_string
  5482.     lea    tempbuf(a5),a2
  5483.     move.b    (a2),d4        save first char
  5484.     move.l    a2,d2
  5485.     moveq    #120,d3
  5486.     move.l    inhandle(a5),d1
  5487.     beq.s    .A
  5488.     jsr    _LVORead(a6)
  5489.     tst.l    d0
  5490.     bmi.s    .A
  5491.     move.l    a2,a1
  5492.     add.l    d0,a2
  5493.     subq.l    #1,a2
  5494.     move.b    d4,(a2)
  5495.     cmp.l    a1,a2        just pressed return ?
  5496.     beq.s    .B
  5497.     clr.b    (a2)    no
  5498. .B    move.l    d5,a3
  5499.     move.l    a4,a0
  5500.     bsr    find_end_of_line
  5501.     move.l    a0,a2
  5502.     move.l    d6,a0
  5503.     bsr    searchSTR
  5504.     cmp.b    #LF,d0
  5505.     bne.s    .A
  5506.     move.l    a1,a4    set begin of line on top
  5507.     bra.s    .C
  5508. .A    move.l    intuibase(a5),a6
  5509.     suba.l    a0,a0
  5510.     jsr    _LVODisplayBeep(a6)
  5511.     move.l    dosbase(a5),a6
  5512. .C    bsr    raw_on
  5513.     lea    hide_cursor(pc),a1
  5514.     bsr    pr_string
  5515.     bra    mk_screen
  5516.  
  5517. ck_pkey    cmp.b    #"p",d0        V2.0    print text ?
  5518.     bne.s    unknown_key
  5519.     lea    prtdev(pc),a0
  5520.     move.l    a0,d1
  5521.     move.l    #MODE_OLDFILE,d2
  5522.     jsr    _LVOOpen(a6)
  5523.     move.l    d0,d4
  5524.     beq.s    .A
  5525.     lea    prtit(pc),a1
  5526.     bsr    pr_string
  5527.     move.l    d4,d1
  5528.     move.l    d5,d2
  5529.     move.l    d6,d3
  5530.     sub.l    d2,d3
  5531.     jsr    _LVOWrite(a6)
  5532.     move.l    d4,d1
  5533.     jsr    _LVOClose(a6)
  5534. .A    bra    mk_screen
  5535.  
  5536. unknown_key
  5537.     lea    show_cursor(pc),a1    unknown key to exit !
  5538.     bsr    pr_stringlf
  5539.     moveq    #RETURN_OK,d0
  5540.     rts
  5541.  
  5542. find_end_of_line
  5543. .B    cmp.l    d6,a0    check against end
  5544.     bhs.s    .A
  5545.     move.b    (a0)+,d0
  5546.     cmp.b    #LF,d0
  5547.     bne.s    .B
  5548.     lea    -1(a0),a0
  5549. .A    rts
  5550.  
  5551. ** PRINT STRING AT A4 ENDING IN LF
  5552. pr_line    movem.l    d0-d4/a0,-(sp)
  5553.     move.l    d0,d4
  5554.     move.l    a4,d2
  5555.     move.l    outhandle(a5),d1
  5556.     beq.s    .C
  5557.     move.l    a4,a0
  5558.     bsr    find_end_of_line
  5559.     sub.l    a4,a0
  5560.     move.l    a0,d3
  5561.     tst.l    d4
  5562.     beq.s    .A
  5563.     subq.l    #1,d2
  5564.     addq.l    #1,d3
  5565. .A    tst.l    d3
  5566.     beq.s    .C    don't print if 0
  5567.     jsr    _LVOWrite(a6)
  5568. .C    movem.l    (sp)+,d0-d4/a0
  5569.     rts
  5570.  
  5571.  
  5572. ** ENTRY D6=end of file A4=current pos
  5573. pr_screen    bsr    check_c
  5574.     bne    type_break
  5575.     moveq    #0,d0
  5576.     bsr    pr_line
  5577.     bsr    pr_lf
  5578. .B    cmp.l    d6,a4    check against end
  5579.     bhs.s    type_break
  5580.     move.b    (a4)+,d0
  5581.     cmp.b    #LF,d0
  5582.     bne.s    .B
  5583.     bra.s    pr_screen
  5584. type_break
  5585.     moveq    #RETURN_OK,D0
  5586.     rts
  5587.  
  5588. *****************
  5589. *    TYPE    *        Type out ASCII file command    
  5590. *****************
  5591. typez    tst.l    parm2(a5)
  5592.     beq    too_less_args
  5593.     move.l    parm2(a5),a0
  5594.     bsr    readfile
  5595.     bsr    rawh_off    MAKE SURE YOU CAN PRESS SPACE TO HOLD IT
  5596.     move.l    d0,-(sp)    push address
  5597.     move.l    d1,-(sp)    push size
  5598.     move.l    d0,a4    a4=ptr
  5599.     move.l     d0,d6
  5600.     add.l    d1,d6    d6=end addr
  5601. next_scr    bsr    pr_screen
  5602. freef1    move.l    (sp)+,d0
  5603.     move.l    (sp)+,a1
  5604.     bsr    givemem
  5605.     moveq    #RETURN_OK,D0
  5606.     RTS
  5607.  
  5608. ***********************
  5609. * EXECUTE SCRIPT FILE *
  5610. ***********************
  5611. executez    tst.l    parm2(a5)
  5612.     beq    too_less_args
  5613.     bsr    fixpam2
  5614. xz2    bsr    readfile    A0 pts to filename
  5615.     move.l    d0,a0
  5616.     cmp.l    #$000003f3,(a0)    is it executable ?
  5617.     beq.s    exerr
  5618.     addq.l    #4,sp        kill return address
  5619. xz3    move.l    d0,a0
  5620.     cmp.w    #"/*",(a0)
  5621.     beq.s    xrexx
  5622.     move.l    d1,scsize(a5)
  5623.     move.l    d0,scaddr(a5)
  5624.     move.l    d0,scptr(a5)
  5625.     move.b    #1,scflag(a5)    make shell think text lines are in memory
  5626.     clr.b    mult_comm_flag(a5)
  5627.     bra    chorus
  5628. exerr    moveq    #RETURN_ERROR,d0
  5629.     rts
  5630. xrexx    move.l    d0,a1        execute AREXX-script
  5631.     move.l    d1,d0
  5632.     bsr    givemem        kill script
  5633.     lea    rexxtx(pc),a1
  5634.     move.l    a1,parm1(a5)
  5635.     bra    notfound    execute archie3
  5636.  
  5637. *****************
  5638. *    ECHO    *
  5639. *****************
  5640. echoz    lea    parm2(a5),a3
  5641.     move.l    (a3)+,d0
  5642.     beq.s    echo3
  5643.     bra.s    echo5
  5644. echo2    move.l    (a3)+,d0
  5645.     bne.s    echo4
  5646. echo3    moveq    #RETURN_OK,d0
  5647.     rts
  5648. echo4    bsr    pr_space
  5649. echo5    move.l    d0,a0
  5650.     move.l    a0,a1
  5651.     move.l    a0,a2
  5652.     bra.s    .C
  5653. .B    move.b    d0,(a2)+
  5654. .C    move.b    (a0)+,d0
  5655.     beq.s    .A
  5656.     cmp.b    #$5c,d0 ;\    Ignore Specialchar
  5657.     bne.s    .D
  5658.     move.b    (a0)+,d0
  5659.     bra.s    .B
  5660. .D    cmp.b    #'^',d0        ^-Character
  5661.     bne.s    .B
  5662.     move.b    (a0)+,d0
  5663.     cmp.b    #"$",d0        Number given ?
  5664.     beq.s    .F
  5665.     cmp.b    #"%",d0
  5666.     beq.s    .F
  5667.     cmp.b    #"0",d0
  5668.     blo.s    .E
  5669.     cmp.b    #"9",d0
  5670.     bhi.s    .E
  5671. .F    subq.l    #1,a0
  5672.     movem.l    d1/d2/a1,-(sp)
  5673.     move.l    a0,a1
  5674.     bsr    convert_ASCII_to_num
  5675.     lea    -1(a1),a0
  5676.     movem.l    (sp)+,d1/d2/a1
  5677.     cmp.b    #".",(a0)
  5678.     bne.s    .B
  5679.     addq.l    #1,a0
  5680.     bra.s    .B        Number was given
  5681. .E    and.b    #$3f,d0        Control Char
  5682.     bra.s    .B
  5683. .A    clr.b    (a2)+
  5684.     bsr    pr_string
  5685.     bra    echo2
  5686.  
  5687. *****************
  5688. *    CLS    *
  5689. *****************
  5690. clsz    lea    clstx(pc),a1
  5691.     bsr    pr_string
  5692.     moveq    #RETURN_OK,d0
  5693.     rts
  5694.  
  5695. ** MEM INFO :RETURN 3 LONGWORDS AT A0 -> FREE CHIP,FAST,TOTAL
  5696. memory_info
  5697.     movem.l    a0-a2/a6,-(sp)
  5698.     move.l    a0,a2
  5699.     move.l    4.w,a6
  5700.     jsr    _LVOForbid(a6)    ; don't let 'em change while we ask
  5701.     move.l    #MEMF_CHIP,d1    ; ok, check free chip
  5702.     jsr    _LVOAvailMem(a6)    ; ask system how much there is
  5703.     move.l    d0,(a2)
  5704.     move.l    #MEMF_FAST,d1    ; check fast mem avail
  5705.     jsr    _LVOAvailMem(a6)
  5706.     move.l    d0,4(a2)
  5707.     move.l    #MEMF_PUBLIC,d1     ; get all available memory
  5708.     jsr    _LVOAvailMem(a6)
  5709.     move.l    d0,8(a2)
  5710.     jsr    _LVOPermit(a6)
  5711.     movem.l    (sp)+,a0-a2/a6
  5712.     rts
  5713.  
  5714. *****************
  5715. *    AVAIL    *
  5716. *****************
  5717. availz    tst.l    parm2(a5)
  5718.     beq.s    .A
  5719.     move.l    parm2(a5),a0
  5720.     bsr    return_dash_option
  5721.     cmp.b    #'C',d0
  5722.     bne.s    .A
  5723.     bsr    giveman        free some memory
  5724.     move.l    4.w,a6
  5725.     moveq    #-1,d0        Free mem
  5726.     move.l    #$00002711,d1    MAGIC NUMBER (from FIDO-net)
  5727.     jsr    _LVOAllocMem(a6)
  5728.     jsr    _LVOForbid(a6)
  5729.     movea.l    a6,a0
  5730.     moveq    #72,d0
  5731.     add.l    d0,a0
  5732.     moveq    #15,d0        free 16 interrupts
  5733.     moveq    #-1,d1
  5734.     moveq    #12,d2
  5735. .B    add.l    d2,a0
  5736.     cmp.l    (a0),d1
  5737.     bne.s    .C
  5738.     cmp.l    4(a0),d1
  5739.     bne.s    .C
  5740.     clr.l    (a0)
  5741.     clr.l    4(a0)
  5742. .C    dbra    d0,.B
  5743.     jsr    _LVOPermit(a6)
  5744.     move.l    dosbase(a5),a6
  5745. .A    lea    -12(sp),sp    show mem
  5746.     lea    (sp),a0
  5747.     bsr    memory_info
  5748.     move.l    a0,a1
  5749.     lea    memess(pc),a0
  5750.     bsr    new_print    show memory
  5751.     lea    12(sp),sp
  5752.     moveq    #RETURN_OK,d0
  5753.     rts
  5754.  
  5755.  
  5756. * ALTER WINDOW PTR FOR THIS PROCESS. USE TO DISABLE REQUESTERS POPPING UP.
  5757. * ENTRY D1=0 (NORMAL)  D1=-1 (SUBNORMAL, no requesters).
  5758. changeWindowPtr
  5759.     movem.l    d1/a0,-(sp)
  5760.     tst.l    d1
  5761.     bne.s    .A
  5762.     move.l    window_old(a5),d1
  5763. .A    move.l    thistask(a5),a0
  5764.     move.l    d1,pr_WindowPtr(a0)
  5765.     movem.l    (sp)+,d1/a0
  5766.     rts
  5767.  
  5768. raw_on    movem.l    d6/a1,-(sp)    switch console to raw mode
  5769.     lea    show_cursor(pc),a1
  5770.     bsr    pr_string
  5771.     moveq    #-1,d6
  5772.     bra.s    raw_switch
  5773.  
  5774. rawh_off    movem.l    d6/a1,-(sp)    like raw_off,but hides the cursor
  5775.     lea    hide_cursor(pc),a1
  5776.     bsr    pr_string
  5777.     moveq    #0,d6
  5778.     bra.s    raw_switch
  5779.  
  5780. raw_off    movem.l    d6/a1,-(sp)    switch console to normal mode
  5781.     moveq    #0,d6
  5782. ;    bra.s    raw_switch
  5783.  
  5784. *WINDOW TYPE CHANGER    
  5785. raw_switch
  5786.     move.l    thistask(a5),a1
  5787.     move.l    pr_ConsoleTask(a1),packettask(a5)
  5788.     bsr    clearArgs
  5789.     move.l    #ACTION_SCREEN_MODE,packettype(a5)
  5790.     move.l    d6,myArg1(a5)
  5791.     bsr    sendpacket
  5792.     movem.l    (sp)+,d6/a1
  5793.     rts
  5794.  
  5795. clearArgs movem.l    d0/a0,-(sp)
  5796.     lea    sp_node(a5),a0
  5797.     moveq    #16,d0    ;68bytes
  5798. .A    clr.l    (a0)+
  5799.     dbra    d0,.A
  5800.     movem.l    (sp)+,d0/a0
  5801.     rts
  5802.     
  5803. ** ENTRY Uses myArg1-myArg7, and packettask, packettype
  5804. sendpacket    tst.l    packettask(a5)
  5805.     beq.s    .A
  5806.     movem.l    d0-d1/a0-a2,-(sp)    V2.0 (new written)
  5807.     move.l    4.w,a6
  5808.     move.b    #5,LN_TYPE+sp_node(a5)    ;message
  5809.     move.l    thistask(a5),a2
  5810.     lea    pr_MsgPort(a2),a2    ;Process-MsgPort !
  5811.     move.l    a2,sp_reply(a5)        ;Replyport
  5812.     move.l    a2,sp_port(a5)
  5813.     move.w    #dp_SIZEOF+4,sp_length(a5)
  5814.     lea    sp_link(a5),a0
  5815. ;    move.l    a0,sp_ptr(a5)
  5816.     move.l    a0,LN_NAME+sp_node(a5)    ;points to link
  5817.     lea    sp_node(a5),a1
  5818.     move.l    a1,sp_link(a5)        ;linked to itself
  5819.     move.l    packettask(a5),a0
  5820.     jsr    _LVOPutMsg(a6)
  5821.     move.l    a2,a0
  5822.     jsr    _LVOWaitPort(a6)
  5823.     move.l    a2,a0
  5824.     jsr    _LVOGetMsg(a6)
  5825.     move.l    dosbase(a5),a6
  5826.     movem.l    (sp)+,d0-d1/a0-a2
  5827. .A    rts
  5828.  
  5829.  
  5830. *************************
  5831. *    RELABEL     *
  5832. *************************
  5833. relabelz    tst.l    parm3(a5)
  5834.     beq    too_less_args
  5835.     move.l    parm2(a5),a0
  5836.     bsr    check_for_colon
  5837.     beq.s    .D
  5838.     lea    no_colon_tx(pc),a1
  5839.     bsr    pr_string
  5840.     moveq    #RETURN_ERROR,D0
  5841.     rts
  5842. .D    move.l    parm2(a5),d1    PARM2=DF0: etc
  5843.     jsr    _LVODeviceProc(a6)
  5844.     tst.l    d0
  5845.     beq    DOSerr
  5846.     move.l    d0,packettask(a5)
  5847.     move.l    #256,d0
  5848.     moveq    #1,d1
  5849.     bsr    iwantmem        ASSUME GETS 256 BYTES
  5850.     move.l    d0,a2        A2=destination
  5851.     lsr.l    #2,d0
  5852.     bsr    clearArgs
  5853.     move.l    d0,myArg1(a5)    BPTR to my string
  5854.     move.l    parm3(a5),a0    NewName
  5855.     lea    1(a2),a1        A1=after count
  5856.     moveq    #0,d0
  5857. .A    move.b    (a0)+,(a1)+
  5858.     addq.l    #1,d0
  5859.     cmp.b    #':',(a0)        ALLOW FOR IDIOTS WHO PUT : ON END
  5860.     beq.s    .C
  5861.     tst.b    (a0)
  5862.     bne.s    .A
  5863. .C    clr.b    (a1)
  5864.     move.b    d0,(a2)
  5865.     moveq    #ACTION_RENAME_DISK,d0
  5866.     move.l    d0,packettype(a5)    TYPE=RENAME_DISK
  5867.     bsr    sendpacket
  5868.     move.l    a2,a1
  5869.     move.l    #256,d0
  5870.     bsr    givemem
  5871.     bsr    changedisk    ;(moved to dc)
  5872. *    bsr    eval_CD        -IS MORE ELEGANT IF I LEAVE OUT.
  5873.     moveq    #RETURN_OK,d0    USER WILL HAVE TO TYPE CD TO CHANGE
  5874.     rts            PROPER.
  5875.  
  5876. *************************
  5877. *    ADDBUFFERS    *
  5878. *************************
  5879. addbuffersz
  5880.     tst.l    parm3(a5)
  5881.     beq    too_less_args
  5882.     bsr    clearArgs
  5883.     move.l    parm3(a5),a1
  5884.     bsr    convert_ASCII_to_num
  5885.     beq    bad_number_error
  5886.     cmp.l    #32767,d0
  5887.     bhi    bad_number_error
  5888.     move.l    d0,myArg1(a5)
  5889.     move.l    parm2(a5),d1    PARM2=DF0: etc
  5890.     jsr    _LVODeviceProc(a6)
  5891.     tst.l    d0
  5892.     beq    DOSerr
  5893.     move.l    d0,packettask(a5)
  5894.     moveq    #ACTION_MORE_CACHE,d0
  5895.     move.l    d0,packettype(A5)
  5896.     bsr    sendpacket
  5897.     bsr    PKTerr
  5898.     moveq    #RETURN_OK,d0
  5899.     rts
  5900.  
  5901. *************************
  5902. *    DIE-Handler    *
  5903. *************************
  5904. diez    tst.l    parm2(a5)
  5905.     beq    too_less_args
  5906.     bsr    clearArgs
  5907.     move.l    parm2(a5),d1    PARM2=DF0: etc
  5908.     jsr    _LVODeviceProc(a6)
  5909.     tst.l    d0
  5910.     beq    DOSerr
  5911.     move.l    d0,packettask(a5)
  5912.     moveq    #ACTION_DIE,d0
  5913.     move.l    d0,packettype(A5)
  5914.     bsr    sendpacket
  5915.     moveq    #RETURN_OK,d0
  5916.     rts
  5917.  
  5918. *************************
  5919. *    SETDATE        *
  5920. *************************
  5921. setdatez tst.l    parm2(a5)
  5922.     beq    too_less_args
  5923.     move.l    parm2(a5),a2
  5924.     bsr    clearArgs
  5925.     lea    date_mark(a5),a0
  5926.     lea    (a0),a3
  5927.     move.l    a0,myArg4(a5)    ;APTR datestamp
  5928.     bsr    get_time
  5929.     tst.l    parm3(a5)
  5930.     beq    nospda
  5931.     move.l    a2,d1
  5932.     moveq    #ACCESS_READ,d2
  5933.     jsr    _LVOLock(a6)
  5934.     move.l    d0,d7
  5935.     beq    DOSerr
  5936.     move.l    d0,d1
  5937.     lea    fib_DiskKey(a5),a0
  5938.     move.l    a0,d2
  5939.     jsr    _LVOExamine(a6)
  5940.     tst.l    d0
  5941.     beq    DOSerrUL
  5942.     move.l    d7,d1
  5943.     jsr    _LVOUnLock(a6)
  5944.     lea    -14(sp),sp
  5945.     lea    (sp),a0
  5946.     lea    fib_Date(a5),a1
  5947.     bsr    convert_time
  5948.     lea    parm3(a5),a0
  5949.     lea    (sp),a1
  5950.     bsr    settime
  5951.     move.w    12(sp),d1
  5952.     lea    14(sp),sp
  5953.     tst.l    d0
  5954.     beq    .B
  5955.     rts
  5956.  
  5957. .B    lea    (a3),a0
  5958.     move.l    d5,(a0)+    ;days
  5959.     divu    #60,d6
  5960.     move.w    d6,d0
  5961.     ext.l    d0
  5962.     move.l    d0,(a0)+    ;mins
  5963.     swap    d6
  5964.     mulu    #50,d6
  5965.     add.l    d1,d6
  5966.     move.l    d6,(a0)        ;ticks
  5967. nospda    move.l    a2,d1    ;filename
  5968.     jsr    _LVODeviceProc(a6)
  5969.     tst.l    d0
  5970.     beq    DOSerr
  5971.     move.l    d0,packettask(a5)
  5972.     move.l    a2,a0
  5973.     lea    temp2buf(a5),a1
  5974.     move.l    a1,a3
  5975.     bsr    split_wild    ;No wildcard ! Only separates filename !
  5976.     move.l    a2,d1
  5977.     moveq    #ACCESS_READ,d2
  5978.     jsr    _LVOLock(a6)
  5979.     move.l    d0,d7
  5980.     beq    DOSerr
  5981.     move.l    d0,myArg2(a5)    ;BPTR lock
  5982.     move.l    a3,a0
  5983.     lea    tempbuf(a5),a1
  5984.     moveq    #-1,d0
  5985.     bsr    cpBSTR
  5986.     move.l    d0,myArg3(a5)    ;BSTR filename
  5987.     moveq    #ACTION_SET_DATE,d0
  5988.     move.l    d0,packettype(A5)
  5989.     bsr    sendpacket
  5990.     move.l    d7,d1
  5991.     jsr    _LVOUnLock(a6)
  5992.     bsr    PKTerr
  5993.     moveq    #RETURN_OK,d0
  5994.     rts
  5995.  
  5996. *************************
  5997. *    DISKCHANGE    *
  5998. *************************
  5999. diskchangez
  6000.     tst.l    parm2(a5)
  6001.     beq    too_less_args
  6002.     move.l    parm2(a5),d1    PARM2=DF0: etc
  6003.     jsr    _LVODeviceProc(a6)
  6004.     tst.l    d0
  6005.     beq    DOSerr
  6006.     move.l    d0,packettask(a5)
  6007.     bsr    changedisk
  6008.     moveq    #RETURN_OK,d0
  6009.     rts
  6010.  
  6011. ** USES task in packettask
  6012. changedisk
  6013.     bsr    clearArgs
  6014.     moveq    #ACTION_INHIBIT,d0
  6015.     move.l    d0,packettype(a5)
  6016.     moveq    #-1,d0    ;1?
  6017.     move.l    d0,myArg1(a5)
  6018.     bsr    sendpacket
  6019.     bsr    PKTerr
  6020.     clr.l    myArg1(a5)
  6021.     bsr    sendpacket
  6022.     bsr    PKTerr
  6023.     rts
  6024.  
  6025. *************************
  6026. *    LOCK        *
  6027. *************************
  6028. lockz    tst.l    parm2(a5)
  6029.     beq    too_less_args
  6030.     tst.l    parm3(a5)
  6031.     beq    help_status
  6032.     move.l    parm3(a5),a0
  6033.     moveq    #-1,d7
  6034.     move.b    1(a0),d0
  6035.     bset    #5,d0
  6036.     cmp.b    #"n",d0    ;oN
  6037.     beq.s    .B
  6038.     moveq    #0,d7
  6039. .B    move.l    parm2(a5),d1    PARM2=DF0: etc
  6040.     jsr    _LVODeviceProc(a6)
  6041.     tst.l    d0
  6042.     beq    DOSerr
  6043.     move.l    d0,packettask(a5)
  6044.     bsr    clearArgs
  6045.     move.l    #ACTION_WRITE_PROTECT,d0
  6046.     move.l    d0,packettype(a5)
  6047.     move.l    d7,myArg1(a5)
  6048.     bsr    sendpacket
  6049.     bsr    PKTerr
  6050.     moveq    #RETURN_OK,d0
  6051.     rts
  6052.  
  6053. *********************************
  6054. *    UNSET VARIABLE        *
  6055. *********************************
  6056. unsetz    lea    parm2(a5),a3
  6057. .A    tst.l    (a3)
  6058.     beq    no_more_unsets
  6059.     move.l    (a3)+,a0
  6060.     bsr    check_if_set_already_there
  6061.     tst.l    d0
  6062.     beq    unset_failure
  6063.     move.l    d0,a1
  6064.     move.l    (a1),d2    GRAB NEXT SET POINTER
  6065.     move.l    set_size(a1),d0
  6066.     move.l    d1,a0    D1=prior set
  6067.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  6068.     bsr    givemem
  6069.     bra    .A
  6070. no_more_unsets
  6071.     moveq    #RETURN_OK,d0
  6072.     rts
  6073. unset_failure
  6074.     lea    set_search_string(a5),a1
  6075.     bsr    pr_string
  6076.     lea    bad_unset_tx(pc),a1
  6077.     bsr    pr_string
  6078.     moveq    #RETURN_ERROR,d0
  6079.     rts
  6080.  
  6081. *********************************
  6082. *    SET VARIABLE KEY    *
  6083. *********************************
  6084. set_link    equ    0
  6085. set_size    equ    4
  6086. set_name    equ    8
  6087. set_defn    equ    24
  6088.  
  6089. set_funcz    tst.l    parm2(a5)        SEE IF ANY PARAMETERS TYPED
  6090.     beq    show_current_sets
  6091.     bsr    fixpam32        A0=parm2 A1=parm3
  6092.     bsr    check_if_set_already_there
  6093.     tst.l    d0
  6094.     beq    create_new_set
  6095.     bra    update_old_set
  6096.  
  6097. show_current_sets
  6098.     bsr    rawh_off
  6099.     move.l    first_set_defn(a5),d0
  6100.     beq    no_sets_to_show
  6101. show_next_set
  6102.     move.l    d0,a3
  6103.     lea    set_name(a3),a1
  6104.     bsr    pr_string
  6105.     bsr    pr_tab
  6106.     lea    set_defn(a3),a1
  6107.     bsr    pr_stringlf
  6108.     move.l    (a3),d0        CHECK NEXT SET ADDRESS
  6109.     bne    show_next_set
  6110. no_sets_to_show
  6111.     moveq    #RETURN_OK,d0
  6112.     rts
  6113.  
  6114. create_new_set        ;a0=name a1=def
  6115.     lea    tempbuf(a5),a3        GET BIG BLOCK
  6116.     bsr    copy_func_defn_to_space
  6117.     move.l    a1,d4        D4=after end
  6118.     sub.l    a3,a1        WORK OUT HOW BIG IS ACTUALLY
  6119.     move.l    a1,d0
  6120.     moveq    #1,d1
  6121.     bsr    iwantmem    allocate block big enough for everything
  6122.     beq.s    .A
  6123.     move.l    d0,a2
  6124.     move.l    a1,set_size(a2)
  6125.     bsr    insert_new_set
  6126.     lea    set_name(a2),a1    new block
  6127.     lea    set_name(a3),a0    temp block
  6128. .B    move.b    (a0)+,(a1)+
  6129.     cmp.l    a0,d4
  6130.     bne.s    .B
  6131. .A    moveq    #RETURN_OK,d0
  6132.     rts
  6133.     
  6134.  
  6135. check_if_set_already_there
  6136. * A0= set name
  6137.     movem.l    a0-a1,-(sp)
  6138.     lea    set_search_string(a5),a1
  6139.     bsr    cp_string
  6140.     bsr    search_sets
  6141.     movem.l    (sp)+,a0-a1
  6142.     rts
  6143.  
  6144. update_old_set
  6145. * first delete old one
  6146.     movem.l    a0-a1,-(sp)
  6147.     move.l    d0,a1
  6148.     move.l    (a1),d2    GRAB NEXT SET POINTER
  6149.     move.l    set_size(a1),d0
  6150.     move.l    d1,a0    D1=prior set
  6151.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  6152.     bsr    givemem
  6153.     movem.l    (sp)+,a0-a1
  6154. * and replace with new set
  6155.     bra    create_new_set
  6156.  
  6157. deallocate_sets
  6158.     move.l    first_set_defn(a5),d3
  6159.     beq    no_sets_to_lose
  6160. lose_next_set
  6161.     move.l    d3,a1
  6162.     move.l    (a1),-(sp)
  6163.     move.l    set_size(a1),d0
  6164.     bsr    givemem
  6165.     move.l    (sp)+,d3
  6166.     bne    lose_next_set
  6167. no_sets_to_lose
  6168.     rts
  6169.  
  6170. insert_new_set
  6171.     move.l    a3,-(sp)
  6172.     move.l    d0,a3            A3=new space
  6173.     move.l    first_set_defn(a5),d1
  6174.     move.l    d1,(a3)            new pts to old
  6175.     move.l    a3,first_set_defn(a5)
  6176.     move.l    (sp)+,a3
  6177.     rts
  6178.  
  6179. ** ENTRY a3=space, A0=name, A1=defn
  6180. ** EXIT A1=after zero in dest, A3=space
  6181. copy_func_defn_to_space
  6182.     move.l    a1,-(sp)
  6183.     lea    set_name(a3),a1
  6184.     bsr    cp_string        COPY SET NAME TO SPACE
  6185.     move.l    (sp)+,a0
  6186.     lea    set_defn(a3),a1
  6187.     bra    cp_string_special    COPY SET DEFN TO SPACE
  6188.  
  6189. * THIS STRING COPY COPYS A0->A1 BUT CONVERTS ALL \n to n
  6190. * RETURN A0 = after zero in src, A1 = after zero in dest
  6191. cp_string_special
  6192.     move.l    d0,-(sp)
  6193.     bra.s    .B
  6194. .A    cmp.b    #$5c,d0 ;\
  6195.     beq.s    .B
  6196.     move.b    d0,(a1)+
  6197. .B    move.b    (a0)+,d0
  6198.     bne.s    .A
  6199.     move.b    d0,(a1)+
  6200.     move.l    (sp)+,d0
  6201.     rts
  6202.     
  6203.     
  6204. *************************
  6205. *    RESIDENT    *    V2.0:uses the GLOBAL resident-list
  6206. *************************    (many things changed)
  6207. residentz    move.l    parm2(a5),d0    SEE IF ANY PARAMETERS TYPED
  6208.     beq    show_current_residents
  6209.     lea    parm2(a5),a3
  6210.     move.l    (a3),a0
  6211.     bsr    return_dash_option
  6212.     cmp.b    #'C',d0
  6213.     beq    kill_resi
  6214. next_resi    move.l    (a3)+,d0
  6215.     bne.s    .B
  6216.     moveq    #RETURN_OK,d0
  6217.     rts
  6218. .B    move.l    d0,a4        A4=parmName
  6219.     bsr    spaths2        SEARCH PATHS FOR THE COMMAND
  6220.     tst.l    d0
  6221.     beq    resi_not_found
  6222.     move.l    d0,-(sp)    push seglist
  6223.     move.l    a4,a0
  6224.     move.l    a4,a1
  6225.     bsr    rempath        SRC = DEST is OK
  6226.     bsr    search_res2    find if same name is on resi list
  6227.     move.l    (sp)+,d3
  6228.     move.l    d0,d1
  6229.     bne.s    .A
  6230.     bsr    create_resi
  6231.     bra.s    next_resi
  6232. .A    moveq    #1,d0
  6233.     cmp.l    resi_usecount(a0),d0
  6234.     bne.s    resi_inuse
  6235.     move.l    d0,resi_usecount(a0)
  6236.     move.l    d3,resi_seglist(a0)    new seglist
  6237.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  6238.     bra.s    next_resi
  6239.  
  6240. kill_resi    tst.l    (a3)+
  6241. .B    move.l    (a3)+,d0
  6242.     bne.s    .A
  6243.     moveq    #RETURN_OK,d0
  6244.     rts
  6245. .A    move.l    d0,a4
  6246.     move.l    a4,a0
  6247.     move.l    a4,a1
  6248.     bsr    rempath        SRC = DEST is OK
  6249.     bsr    search_res2    find if same name is on resi list
  6250.     move.l    d0,d1        gives d0,a0,d2
  6251.     beq.s    resi_not_found
  6252.     moveq    #1,d0
  6253.     cmp.l    resi_usecount(a0),d0
  6254.     bne.s    resi_inuse
  6255.     move.l    a0,a2
  6256.     move.l    d2,a0
  6257.     move.l    resi_link(a2),resi_link(a0)
  6258.     clr.l    resi_link(a2)
  6259.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  6260.     move.l    a2,d1
  6261.     lsr.l    #2,d1
  6262.     jsr    _LVOUnLoadSeg(a6)
  6263.     bra.s    .B
  6264.  
  6265. resi_not_found
  6266.     lea    badcomm(pc),a1
  6267.     bsr    pr_string
  6268.     bra.s    resi_error
  6269. resi_no_mem
  6270.     lea    resi_no_mem_tx(pc),a1
  6271.     bsr    pr_stringlf
  6272.     bra.s    resi_error
  6273. resi_inuse
  6274.     lea    resi_inuse_tx(pc),a1
  6275.     bsr    pr_stringlf
  6276. resi_error
  6277.     moveq    #RETURN_ERROR,d0
  6278.     rts
  6279.  
  6280. create_resi        ;D3:SegList, A4:Name
  6281.     moveq    #resi_length,d0
  6282.     move.l    a4,a0
  6283. .A    addq.l    #1,d0    one more for lenght-byte
  6284.     tst.b    (a0)+
  6285.     bne.s    .A
  6286.     addq.l    #4,d0    4 more for segment-length
  6287.     addq.l    #7,d0    (7 more for and'ing needed by UnLoadSeg)
  6288.     moveq    #-4,d1
  6289.     and.l    d1,d0
  6290.     move.l    d0,d2
  6291.     moveq    #1,d1
  6292.     bsr    iwantmem
  6293.     beq.s    resi_no_mem
  6294.     addq.l    #4,d0
  6295.     move.l    d0,a2        D0=addr of resi_list_node
  6296.     move.l    d2,-4(a2)    save segment-length
  6297.     bsr    do_forbid
  6298.     bsr    resi_hand
  6299.     move.l    d0,resi_link(a2)
  6300.     move.l    a2,d0
  6301.     lsr.l    #2,d0
  6302.     move.l    d0,(a0)
  6303.     moveq    #1,d0
  6304.     move.l    d0,resi_usecount(a2)
  6305.     move.l    d3,resi_seglist(a2)
  6306.     lea    resi_name(a2),a1
  6307.     move.l    a4,a0
  6308.     moveq    #-1,d0
  6309.     bsr    cpBSTR
  6310.     bsr    do_permit
  6311.     moveq    #0,d0
  6312.     rts
  6313.  
  6314. resi_hand    move.l    dl_Root(a6),a0
  6315.     move.l    rn_Info(a0),a0
  6316.     add.l    a0,a0
  6317.     add.l    a0,a0
  6318.     lea    di_NetHand(a0),a0    NetHand in A0
  6319.     move.l    (a0),d0        Start of Resi-List in D0
  6320.     rts
  6321.  
  6322. show_current_residents
  6323.     lea    residetx(pc),a1
  6324.     bsr    pr_stringlf
  6325.     bsr    rawh_off
  6326.     bsr    resi_hand
  6327.     beq    no_resis_to_show
  6328. .A    lsl.l    #2,d0
  6329.     move.l    d0,a3
  6330.     move.l    resi_usecount(a3),d0
  6331.     subq.l    #1,d0
  6332.     bsr    print10
  6333.     bsr    pr_space
  6334.     move.l    a3,d0
  6335.     bsr    printADR
  6336.     bsr    pr_space
  6337.     lea    resi_name(a3),a1
  6338.     moveq    #0,d3
  6339.     move.b    (a1)+,d3
  6340.     move.l    a1,d2
  6341.     move.l    outhandle(a5),d1
  6342.     beq.s    .B
  6343.     jsr    _LVOWrite(a6)
  6344.     bsr    pr_lf
  6345. .B    bsr    check_c
  6346.     bne.s    no_resis_to_show
  6347.     move.l    resi_link(a3),d0
  6348.     bne    .A
  6349. no_resis_to_show
  6350.     moveq    #RETURN_OK,d0
  6351.     rts
  6352.  
  6353. ******    Copy String from A0 to BSTR A1
  6354. cpBSTR    movem.l    d1-d2/a0-a2,-(sp)    max. Length-2 in D0
  6355.     lea    1(a1),a2
  6356.     moveq    #0,d2
  6357.     bra.s    .B
  6358. .A    move.b    d1,(a2)+
  6359.     addq.l    #1,d2
  6360. .B    move.b    (a0)+,d1
  6361.     dbeq    d0,.A
  6362.     clr.b    (a2)    ;NULL-end it
  6363.     move.b    d2,(a1)
  6364.     move.l    a1,d0
  6365.     lsr.l    #2,d0
  6366.     movem.l    (sp)+,d1-d2/a0-a2    D0 is BPTR to the BSTR
  6367.     rts
  6368.  
  6369.  
  6370. *************************
  6371. *    PROTECT        *
  6372. *************************
  6373. protectz    bsr    fixpam32
  6374.     tst.b    (a1)
  6375.     beq    check_existing_protection
  6376.     bsr    get_protection_bits
  6377.     bsr    alter_protection_bits
  6378.     moveq    #RETURN_OK,d0
  6379.     rts
  6380.  
  6381. alter_protection_bits
  6382. * A1-> rwed etc.   A2-> prot table  A0-> filename  D3=old prot bits.
  6383.     lea    prot_bits_table(pc),a2
  6384.     tst.b    (a1)
  6385.     beq    set_the_protection
  6386. apb_loop    move.b    (a2)+,d1    get letter from table
  6387.     bne.s    .A
  6388.     lea    bad_prot_bits_tx(pc),a1
  6389.     bsr    pr_string
  6390.     moveq    #RETURN_ERROR,D0
  6391.     rts
  6392.  
  6393. .A    move.b    (a2)+,d2    get code from table
  6394.     move.b    (a1),d0
  6395.     bsr    compD1D0nocase
  6396.     bne.s    apb_loop
  6397.     eor.b    d2,d3
  6398.     move.b    (a1)+,d1    dummy,bump ptr
  6399.     bra    alter_protection_bits
  6400. set_the_protection
  6401.     move.l    d3,d2
  6402.     move.l    a0,d1
  6403.     jsr    _LVOSetProtection(a6)
  6404.     rts
  6405.  
  6406. check_existing_protection
  6407.     bsr    get_protection_bits
  6408.     bsr    translate_prot_bits
  6409.     moveq    #RETURN_OK,d0
  6410.     rts
  6411.  
  6412. get_protection_bits
  6413.     movem.l    a0-a1,-(sp)
  6414.     bsr    fibexam
  6415.     move.l    fib_Protection(a5),d3
  6416.     bsr    unlock
  6417.     movem.l    (sp)+,a0-a1
  6418.     rts
  6419.     
  6420. translate_prot_bits
  6421.     lea    fib_FileName(a5),a1
  6422.     bsr    pr_string
  6423.     bsr    pr_tab
  6424.     bsr    pr_prot
  6425.     bra    pr_stringlf
  6426.  
  6427. pr_prot    moveq    #7,d0            V2.0
  6428.     move.l    fib_Protection(a5),d1
  6429.     eor.b    #$0f,d1
  6430.     lea    temp2buf(a5),a0
  6431. .A    move.b    #"-",(a0)+
  6432.     btst    d0,d1
  6433.     beq.s    .B
  6434.     move.b    protflags(pc,d0.w),-1(a0)
  6435. .B    dbra    d0,.A
  6436.     clr.b    (a0)
  6437.     lea    temp2buf(a5),a1
  6438.     rts
  6439.  
  6440. protflags    dc.b    'dewrapsh'
  6441. prot_bits_table
  6442.     dc.b    'h',$80
  6443.     dc.b    's',$40
  6444.     dc.b    'p',$20
  6445.     dc.b    'a',$10
  6446.     dc.b    'r',$08
  6447.     dc.b    'w',$04
  6448.     dc.b    'e',$02
  6449.     dc.b    'd',$01
  6450.     dc.w    0
  6451.  
  6452. *********************************
  6453. *    RPN CALCULATOR        *
  6454. *********************************
  6455. evalz    lea    parm2(a5),a4
  6456.     move.l    sp,d5        remember the stack ptr
  6457. rpn_loop1    move.l    (a4)+,d1
  6458.     beq    show_rpn_result
  6459.     lea    endofparms(a5),a1
  6460.     cmp.l    a1,a4
  6461.     bhi    show_rpn_result
  6462.     move.l    d1,a1
  6463.     lea    8(sp),a0
  6464.     cmp.l    a0,d5
  6465.     blo    not_poke32
  6466.  
  6467.     cmp.b    #'+',(a1)        
  6468.     bne.s    not_add        
  6469.     move.l    (sp)+,d0        DO ADD
  6470.     add.l    d0,(sp)
  6471.     bra    rpn_loop1
  6472. not_add    cmp.b    #'-',(a1)
  6473.     bne.s    not_sub
  6474.     move.l    (sp)+,d0
  6475.     sub.l    d0,(sp)
  6476.     bra    rpn_loop1
  6477.     
  6478. not_sub    cmp.b    #'*',(a1)
  6479.     bne.s    not_mult
  6480.     move.l    (sp)+,d0    last    DO MULT
  6481.     move.l    (sp)+,d1    2nd last
  6482.     bsr    mult_32x32
  6483.     move.l    d0,-(sp)
  6484.     bra    rpn_loop1
  6485. not_mult    cmp.b    #'/',(a1)
  6486.     bne.s    not_div
  6487.     move.l    (sp)+,d1    last    DO DIVIDE
  6488.     move.l    (sp)+,d0    2nd last
  6489.     tst.l    d1
  6490.     beq    rpn_error        NO DIVIDE BY ZERO
  6491.     bsr    div_32
  6492.     move.l    d0,-(sp)
  6493.     bra    rpn_loop1
  6494. not_div    cmp.b    #'&',(a1)
  6495.     bne.s    not_and
  6496.     move.l    (sp)+,d0
  6497.     and.l    d0,(sp)
  6498.     bra    rpn_loop1
  6499. not_and    cmp.b    #"|",(a1)
  6500.     bne.s    not_or
  6501.     move.l    (sp)+,d0
  6502.     or.l    d0,(sp)
  6503.     bra    rpn_loop1
  6504. not_or    cmp.b    #'!',(a1)
  6505.     bne.s    not_poke32
  6506.     move.l    (sp)+,d0    GET ADDR        DO POKE 32
  6507.     move.l    (sp)+,d1    GET VALUE
  6508.     and.b    #$fe,d0
  6509.     move.l    d0,a0
  6510.     move.l    d1,(a0)
  6511.     bra    rpn_loop1
  6512. not_poke32
  6513.     cmp.b    #'@',(a1)
  6514.     bne.s    not_peek32
  6515.     move.l    (sp)+,d0    ADDR    DO PEEK 32
  6516.     cmp.l    sp,d5
  6517.     blo    rpn_error
  6518.     and.b    #$fe,d0
  6519.     move.l    d0,a0
  6520.     move.l    (a0),-(sp)
  6521.     bra    rpn_loop1
  6522.  
  6523. not_peek32
  6524.     bsr    convert_ASCII_to_num
  6525.     beq    rpn_error
  6526.     move.l    d0,-(sp)
  6527.     bra    rpn_loop1
  6528. rpn_error    move.l    d5,sp
  6529.     rts
  6530.  
  6531. show_rpn_result
  6532.     move.l    (sp),-(sp)
  6533.     moveq    #RETURN_ERROR,d7    error on equal
  6534.     tst.l    (sp)
  6535.     beq.s    .B
  6536.     bpl.s    .C
  6537.     moveq    #RETURN_WARN,d7        warn on minus
  6538.     bra.s    .B
  6539. .C    moveq    #RETURN_OK,d7        ok on plus
  6540. .B    lea    (sp),a1
  6541.     move.l    sp,a1
  6542.     lea    rpn_result_tx(pc),a0    print hex & dec
  6543.     move.l    outhandle(a5),d0
  6544.     cmp.l    stdout(a5),d0    output redirected ?
  6545.     beq.s    .A
  6546.     moveq    #RETURN_OK,d7
  6547.     lea    rpn_res2(pc),a0    print only number
  6548. .A    bsr    new_print
  6549.     move.l    d5,sp
  6550.     move.l    d7,d0
  6551.     rts
  6552.  
  6553. div_32    movem.l    d2-d4,-(sp)
  6554.     moveq    #0,d2
  6555.     moveq    #31,d4
  6556. _divu1    roxl.l    #1,d0    ; divident
  6557.     roxl.l    #1,d2    ; work accum
  6558.     cmp.l    d1,d2    ; cmp with divisor
  6559.     blo.s    _divu2
  6560.     sub.l    d1,d2
  6561.     dc.l    $003c0010    ;ori.b    #16,CCR    ;setx
  6562. _divu2    roxl.l    #1,d3    ; result
  6563.     dbf    d4,_divu1
  6564.     move.l    d3,d0
  6565.     move.l    d2,d1
  6566.     movem.l    (sp)+,d2-d4    ;result:d0 rest:d1
  6567.     rts
  6568.  
  6569.  
  6570. mult_32x32
  6571. * D1 = 32 bit, D0 = 32 bit (result)
  6572.     movem.l    d1-d3,-(sp)
  6573.     move.l    d0,d2
  6574.     move.l    d0,d3
  6575.     mulu    d1,d0    save intermediate result
  6576.     swap    d3
  6577.     mulu    d1,d3
  6578.     swap    d3
  6579.     clr.w    d3
  6580.     add.l    d3,d0
  6581.     swap    d1
  6582.     mulu    d1,d2
  6583.     swap    d2
  6584.     clr.w    d2
  6585.     add.l    d2,d0
  6586.     movem.l    (sp)+,d1-d3
  6587.     rts
  6588.  
  6589. * Convert null ending ASCII number(A1) to 32bit number in D0
  6590. * Return D1=0 if bad number (a1:current pos)
  6591. convert_ASCII_to_num    
  6592.     movem.l    d2/d3/a0,-(sp)
  6593.     moveq    #0,d3    SET POSITIVE
  6594.     moveq    #0,d1    RESET BASE
  6595. .A    cmp.b    #'|',(a1)
  6596.     bne.s    convnor
  6597.     lea    1(a1),a0
  6598.     bsr    readfile
  6599.     cmp.w    #NEWPRINTSIZE-2,d1
  6600.     bhs    conversion_finished
  6601.     move.l    d0,a0
  6602.     lea    NewPrintBuffer(a5),a1
  6603.     move.l    d1,d2
  6604.     subq.w    #1,d2
  6605. .B    move.b    (a0)+,(a1)+
  6606.     dbra    d2,.B
  6607.     clr.b    (a1)
  6608.     move.l    d0,a1
  6609.     move.l    d1,d0
  6610.     bsr    givemem
  6611.     lea    NewPrintBuffer(a5),a1
  6612. ;    bset    #0,d3
  6613.     bra.s    .A
  6614. convnor    moveq    #0,d0    RESET RESULT
  6615.     moveq    #0,d1    RESET BASE
  6616.     tst.b    (a1)
  6617.     beq    conversion_finished
  6618.     moveq    #LF,d1    SET THE BASE
  6619.     cmp.b    #'-',(a1)    negative sign
  6620.     bne.s    .A
  6621.     bset    #3,d3
  6622. .D    addq.l    #1,a1
  6623. .A    cmp.b    #'+',(a1)    positive sign
  6624.     beq.s    .D
  6625.     cmp.b    #'&',(a1)    for APTR (hex!) -> BPTR
  6626.     bne.s    .B
  6627.     addq.l    #1,a1
  6628.     bset    #1,d3
  6629.     moveq    #16,d1    SET RADIX16
  6630.     bra    same_base
  6631. .B    cmp.b    #'§',(a1)    for BPTR (hex!) -> APTR
  6632.     bne.s    .C
  6633.     addq.l    #1,a1
  6634.     bset    #2,d3
  6635.     moveq    #16,d1    SET RADIX16
  6636.     bra    same_base
  6637. .C    cmp.b    #'$',(a1)
  6638.     bne.s    other_base
  6639.     move.b    (a1)+,d2    DUMMY BUMP
  6640.     moveq    #16,d1    SET RADIX16
  6641.     bra    same_base
  6642.  
  6643. other_base
  6644.     cmp.b    #'%',(a1)
  6645.     bne.s    same_base
  6646.     move.b    (a1)+,d2
  6647.     moveq    #2,d1    SET RADIX2
  6648. same_base    moveq    #0,d2
  6649.     move.b    (a1)+,d2
  6650.     beq    conversion_finished
  6651.     bsr    convert_D2_to_num
  6652.     tst.l    d1
  6653.     beq.s    conversion_finished
  6654.     bsr    mult_32x32
  6655.     add.l    d2,d0
  6656.     bra    same_base
  6657. conversion_finished
  6658.     btst    #3,d3
  6659.     beq.s    .A
  6660.     neg.l    d0
  6661. .A    btst    #1,d3
  6662.     beq.s    .B
  6663.     lsr.l    #2,d0
  6664. .B    btst    #2,d3
  6665.     beq.s    .C
  6666.     lsl.l    #2,d0
  6667. .C    movem.l    (sp)+,d2/d3/a0
  6668.     tst.b    d1
  6669.     rts
  6670.     
  6671. convert_D2_to_num
  6672.     cmp.b    #'0',d2
  6673.     blo.s    bad_number
  6674.     cmp.b    #'9',d2
  6675.     bhi.s    check_hex
  6676.     sub.b    #'0',d2
  6677.     rts
  6678. check_hex    cmp.b    #16,d1
  6679.     bne.s    bad_number
  6680.     cmp.b    #'f',d2
  6681.     bhi.s    bad_number
  6682.     cmp.b    #'A',d2
  6683.     blo.s    bad_number
  6684.     cmp.b    #'F',d2
  6685.     bhi.s    check_upper_hex
  6686.     sub.b    #55,d2
  6687.     rts
  6688. check_upper_hex
  6689.     cmp.b    #'a',d2
  6690.     blo.s    bad_number
  6691.     sub.b    #87,d2
  6692.     rts
  6693. bad_number
  6694.     moveq    #0,d1    FLAG ERROR thru silly base
  6695.     rts
  6696.  
  6697. *********************************
  6698. *    MEMORY EXAMINE        *
  6699. *********************************
  6700. memexamz    clr.l    mem_offset_addr(a5)
  6701.     moveq    #0,d7
  6702.     tst.l    parm2(a5)        CHECK IF NO ADDRESS.
  6703.     bne.s    .E
  6704.     moveq    #8,d7
  6705.     bra    show_mempage
  6706. .E    bsr    fixpam32
  6707.     tst.b    (a1)
  6708.     beq.s    .A
  6709.     move.l    a0,-(sp)
  6710.     bsr    convert_ASCII_to_num    convert 2nd num
  6711.     move.l    (sp)+,a0
  6712.     tst.b    d1
  6713.     beq    bad_number_error
  6714.     move.l    d0,d7            D7=2nd num
  6715. .A    move.l    a0,a1
  6716.     bsr    convert_ASCII_to_num    convert 1st num
  6717.     beq    bad_number_error
  6718. .C    tst.l    d7
  6719.     bne.s    .D
  6720.     moveq    #8,d7
  6721.     bra.s    memex2
  6722. .D    sub.l    d0,d7
  6723.     lsr.l    #4,d7
  6724.     addq.l    #1,d7
  6725.  
  6726. memex2    move.l    d0,mem_addr(a5)
  6727. show_mempage
  6728.     and.b    #$fe,mem_addr+3(a5)    MAKE SURE EVEN ADDRESS
  6729. *    moveq    #19,d7        D7=count
  6730. shmem2    bsr    check_c
  6731.     bne    .A
  6732.     bsr    show_16_locs
  6733.     subq.l    #1,d7
  6734.     bne.s    shmem2
  6735. .A    moveq    #RETURN_OK,d0
  6736.     rts
  6737.     
  6738. show_16_locs
  6739.     move.l    mem_addr(a5),a1
  6740.     lea    CLIbuf(a5),a3
  6741.     move.l    a3,a0
  6742.     moveq    #15,d0
  6743. sh_16_1    move.b    (a1)+,d1
  6744.     move.b    #'.',(a0)+
  6745.     move.b    d1,d2
  6746.     bclr    #7,d2
  6747.     cmp.b    #' ',d2
  6748.     blo.s    sh_16_2
  6749.     move.b    d1,-1(a0)
  6750. sh_16_2    dbra    d0,sh_16_1
  6751.     clr.b    (a0)
  6752.     move.l    a3,-(sp)        PUSH STRING ADDR
  6753.     move.l    -(a1),-(sp)    PUSH LAST BYTES
  6754.     move.l    -(a1),-(sp)
  6755.     move.l    -(a1),-(sp)
  6756.     move.l    -(a1),-(sp)    PUSH FIRST BYTES
  6757.     move.l    mem_addr(a5),d0
  6758.     sub.l    mem_offset_addr(a5),d0
  6759.     move.l    d0,-(sp)
  6760.     lea    mem_line(pc),a0
  6761.     lea    (sp),a1
  6762.     bsr    new_print
  6763.     movem.l    (sp)+,d0-d5    DUMMY
  6764.     add.l    #16,mem_addr(a5)
  6765.     rts
  6766.  
  6767. * ENTRY A0=FORMATSTRING A1=DATASTREAM.
  6768. new_print    ;v2.0 small data
  6769.     movem.l    d0-d3/a0-a3,-(sp)
  6770.     lea    NewPrintBuffer(a5),a3    ;V2.0 not on stack
  6771.     lea    KPutChar(pc),a2
  6772.     move.l    4.w,a6
  6773.     jsr    _LVORawDoFmt(a6)
  6774.     move.l    dosbase(a5),a6
  6775.     move.l    outhandle(a5),d1
  6776.     beq.s    .B
  6777.     lea    NewPrintBuffer(a5),a0
  6778.     move.l    a0,d2
  6779.     moveq    #-1,d3
  6780. .A    addq.l    #1,d3
  6781.     tst.b    (a0)+
  6782.     bne.s    .A
  6783.     jsr    _LVOWrite(a6)
  6784. .B    movem.l    (sp)+,d0-d3/a0-a3
  6785.     rts
  6786.  
  6787. KPutChar move.b    d0,(a3)+
  6788.     rts
  6789.  
  6790. *************************
  6791. *    VEC/RESET    *
  6792. *************************
  6793. resetz    lea    resask(pc),a1
  6794.     bsr    pr_string
  6795.     bsr    rask    ;ask politely V2.0
  6796.     tst.l    d0
  6797.     bne.s    BigCrash
  6798.     moveq    #RETURN_FAIL,d0
  6799.     rts
  6800. BigCrash move.l    (4).w,a6
  6801.     clr.l    $0026(A6)
  6802.     move.l    #$00FC00D2,$0080
  6803.     trap    #$00
  6804.     rts    ;will never arrive
  6805.  
  6806. eb_CoolCapture    equ    46
  6807. eb_ColdCapture    equ    42
  6808. eb_WarmCapture    equ    50
  6809. eb_KickMemPtr    equ    546
  6810. eb_KickTagPtr    equ    550
  6811. eb_KickCheckSum    equ    554
  6812.  
  6813. vecz    move.l    4.w,a0
  6814.     move.l    eb_KickCheckSum(a0),-(sp)
  6815.     move.l    eb_KickMemPtr(a0),-(sp)
  6816.     move.l    eb_KickTagPtr(a0),-(sp)
  6817.     move.l    eb_ColdCapture(a0),-(sp)
  6818.     move.l    eb_CoolCapture(a0),-(sp)
  6819.     move.l    eb_WarmCapture(a0),-(sp)
  6820.     lea    (sp),a1
  6821.     lea    vec_line(pc),a0
  6822.     bsr    new_print
  6823.     moveq    #RETURN_ERROR,d0
  6824.     moveq    #5,d1
  6825.     move.l    sp,a0
  6826. .A    tst.l    (a0)+
  6827.     bne.s    .B
  6828.     dbra    d1,.A
  6829.     moveq    #RETURN_OK,d0
  6830. .B    movem.l    (sp)+,d1-d6    get rid of trash
  6831.     rts
  6832.  
  6833. ** SAVE STATS store current time in date mark, and current memory use in mem mark
  6834. save_time
  6835.     movem.l    d0-d1/a0,-(sp)
  6836.     lea    date_mark(a5),a0
  6837.     bsr    get_time
  6838.     movem.l    (sp)+,d0-d1/a0
  6839.     rts
  6840. save_mem    movem.l    d0-d1/a0,-(sp)
  6841.     lea    mem_mark(a5),a0
  6842.     bsr    memory_info    
  6843.     movem.l    (sp)+,d0-d1/a0
  6844.     rts
  6845.  
  6846. ** DISPLAY TIME ELAPSED SINCE LAST CALL TO SAVE TIME AND
  6847. **  ALSO CHANGE IN MEMORY AVAILABLE. EXPECTS RETURN CODE TO BE ABOVE RETURN
  6848. **  ADDRESS ON STACK ie 4(sp)
  6849. show_status
  6850.     jsr    _LVOIoErr(a6)
  6851.     lea    -34(sp),sp
  6852.     lea    (sp),a0        A0=time area
  6853.     move.l    d0,(a0)+    ;-4(a0) result2
  6854.     bsr    get_time    
  6855.     lea    date_mark(a5),a1
  6856.     move.l    ds_Tick(a0),d0
  6857.     sub.l    ds_Tick(a1),d0
  6858.     bpl.s    no_tick_carry
  6859.     add.l    #3000,d0
  6860.     subq.l    #1,ds_Minute(a0)
  6861. no_tick_carry
  6862.     move.l    d0,ds_Tick(a1)    store in datemark
  6863.     move.l    ds_Minute(a0),d0
  6864.     sub.l    ds_Minute(a1),d0
  6865.     move.l    d0,ds_Minute(a1)
  6866.     bsr    convert_time    A0=4+3 words of time
  6867. do_mem_deltas
  6868.     lea    14(a0),a0
  6869.     bsr    memory_info
  6870.     lea    mem_mark(a5),a1
  6871.     move.l    (a1),d0
  6872.     sub.l    d0,(a0)    subtract old from new    ;chip
  6873.     move.l    4(a1),d0
  6874.     sub.l    d0,4(a0)            ;fast
  6875.     move.l    8(a1),d0
  6876.     sub.l    d0,8(a0)            ;total
  6877.     lea    -12(a0),a1
  6878.     move.l    -18(a0),(a1)
  6879.     lea    stat_text(pc),a0
  6880.     bsr    new_print
  6881.     lea    34(sp),sp
  6882.     rts
  6883.  
  6884. *************************    
  6885. *    DATE/TIME    *
  6886. *************************
  6887. datez    lea    date_mark(a5),a2
  6888.     move.l    a2,a0
  6889.     bsr    get_time
  6890.     move.l    a2,a1
  6891.     lea    -14(sp),sp
  6892.     lea    (sp),a0
  6893.     bsr    convert_time
  6894.     tst.l    parm2(a5)
  6895.     beq.s    .A
  6896.     lea    parm2(a5),a0
  6897.     lea    (sp),a1
  6898.     bsr.s    settime
  6899.     lea    14(sp),sp
  6900.     bne.s    .B
  6901.     bsr    tset
  6902.     clr.l    parm2(a5)
  6903.     bra.s    datez    ;now print date/time
  6904. .A    lea    (sp),a1
  6905.     lea    time_text(pc),a0
  6906.     bsr    new_print
  6907.     lea    14(sp),sp
  6908.     moveq    #RETURN_OK,d0
  6909. .B    rts
  6910.  
  6911. settime    movem.l    d1-d4/a0-a4,-(sp)    V2.0
  6912.     move.l    a0,a4        ;a0=parameters
  6913.     move.l    a1,temp1(a5)    ;a1=date/time
  6914. settim    move.l    (a4)+,a0
  6915.     lea    temp2buf(a5),a2
  6916.     moveq    #2,d3
  6917. aa1    move.l    a0,a1
  6918.     bsr    gab
  6919.     move.b    d0,d4
  6920.     beq.s    bb1
  6921.     clr.b    -1(a0)
  6922.     cmp.b    #".",d0        ;day.month.year
  6923.     bne.s    dat2
  6924. bb1    bsr    convert_ASCII_to_num
  6925.     cmp.w    #99,d0    ;rough check
  6926.     bhi    muell
  6927.     move.w    d0,(a2)+
  6928.     tst.l    d1
  6929.     beq    muell
  6930.     tst.b    d4
  6931.     dbeq    d3,aa1
  6932. mull1    tst.w    d3
  6933.     bne    muell
  6934.     lea    temp2buf(a5),a2
  6935.     move.l    temp1(a5),a1
  6936.     moveq    #2,d3
  6937. .B    move.w    (a2)+,(a1)+
  6938.     dbra    d3,.B
  6939.     bra    oktt
  6940. aa2    move.l    a0,a1
  6941.     bsr    gab
  6942.     move.b    d0,d4
  6943.     beq.s    bb2
  6944.     clr.b    -1(a0)
  6945. dat2    cmp.b    #":",d0        ;hour:minute:second
  6946.     bne.s    dat3
  6947. bb2    bsr    convert_ASCII_to_num
  6948.     cmp.w    #99,d0
  6949.     bhi    muell
  6950.     move.w    d0,(a2)+
  6951.     tst.l    d1
  6952.     beq    muell
  6953.     tst.b    d4
  6954.     dbeq    d3,aa2
  6955. mull2    tst.w    d3
  6956.     bne    muell
  6957.     lea    temp2buf(a5),a2
  6958.     move.l    temp1(a5),a1
  6959.     lea    6(a1),a1
  6960.     moveq    #2,d3
  6961. .B    move.w    (a2)+,(a1)+
  6962.     dbra    d3,.B
  6963.     bra    oktt
  6964.     moveq    #2,d3
  6965. aa3    move.l    a0,a1
  6966.     bsr    gab
  6967.     move.b    d0,d4
  6968.     beq.s    bb3
  6969.     clr.b    -1(a0)
  6970. dat3    cmp.b    #"-",d0        ;month-day-year
  6971.     bne    muell
  6972. bb3    bsr    convert_ASCII_to_num
  6973.     cmp.w    #99,d0
  6974.     bhi    muell
  6975.     move.w    d0,(a2)+
  6976.     tst.l    d1
  6977.     beq    muell
  6978.     tst.b    d4
  6979.     dbeq    d3,aa3
  6980. mull3    tst.w    d3
  6981.     bne    muell
  6982.     lea    temp2buf(a5),a2
  6983.     move.l    temp1(a5),a1
  6984.     move.w    (a2)+,2(a1)
  6985.     move.w    (a2)+,(a1)
  6986.     move.w    (a2)+,4(a1)
  6987. oktt    tst.l    (a4)
  6988.     bne    settim
  6989.     lea    chaotab(pc),a0
  6990.     move.l    temp1(a5),a1
  6991.     lea    temp2buf(a5),a3
  6992.     moveq    #5,d0
  6993.     moveq    #0,d1
  6994. .A    move.b    (a0)+,d1
  6995.     move.w    0(a1,d1),d2
  6996.     move.b    d2,(a3)+
  6997.     dbra    d0,.A
  6998.     lea    temp2buf(a5),a3
  6999.     bsr    calcsec
  7000.     movem.l    (sp)+,d1-d4/a0-a4
  7001.     moveq    #RETURN_OK,d0
  7002.     rts    ;result in d5-d7
  7003.  
  7004. muell    lea    muell_tx(pc),a1
  7005.     bsr    pr_stringlf
  7006.     movem.l    (sp)+,d1-d4/a0-a4
  7007.     moveq    #RETURN_ERROR,d0
  7008.     rts
  7009.  
  7010. gab    move.b    (a0)+,d0
  7011.     cmp.b    #$30,d0
  7012.     blo.s    .A
  7013.     cmp.b    #$39,d0
  7014.     bls.s    gab
  7015. .A    cmp.b    #"%",d0    ;handle bin (that's fun !)
  7016.     beq.s    gab
  7017.     rts
  7018.  
  7019. ** GET TIME STORE DAYS,MINUTES,TICKS AT A0
  7020. get_time    move.l    a0,-(sp)
  7021.     move.l    a0,d1
  7022.     jsr    _LVODateStamp(a6)
  7023.     move.l    (sp)+,a0
  7024.     rts
  7025.  
  7026. ** ENTRY A0 pts to 7 words of storage, A1 pts to date stamp
  7027. ** send time to A0 --> 13(A0)
  7028. convert_time
  7029.     movem.l    d0-d3/a0-a2,-(sp)
  7030.     move.l    ds_Tick(a1),d0
  7031.     divu    #50,d0
  7032.     move.w    d0,4+6(a0)        seconds
  7033.     swap    d0
  7034.     asl.w    #1,d0
  7035.     move.w    d0,6+6(a0)        hundredths
  7036.     move.l    ds_Minute(a1),d0
  7037.     divu    #60,d0
  7038.     move.w    d0,0+6(a0)        hours
  7039.     swap    d0    
  7040.     move.w    d0,2+6(a0)        minutes
  7041.     move.l    ds_Days(a1),d0
  7042.     move.w    #365,d1        V2.0:year, day, month
  7043.     move.w    #77,d2
  7044. wdhj    addq.w    #1,d2
  7045.     sub.w    d1,d0
  7046.     bcs.s    mon
  7047.     move.w    d2,d3
  7048.     and.w    #3,d3
  7049.     bne.s    wdhj
  7050.     cmp.w    #100,d2
  7051.     blo.s    ork
  7052.     moveq    #1,d3
  7053.     addq.w    #1,d0
  7054.     sub.w    #100,d2
  7055. ork    subq.w    #1,d0
  7056.     bcc.s    wdhj
  7057.     addq.w    #1,d0
  7058. mon    add.w    d1,d0
  7059.     move.w    d2,4(a0)    year (lots of work)
  7060.     moveq    #0,d2
  7061.     lea    montab(pc),a2
  7062. wdhm    addq.w    #1,d2
  7063.     moveq    #0,d1
  7064.     move.b    (a2)+,d1
  7065.     sub.w    d1,d0
  7066.     bcs.s    tag
  7067.     cmp.w    #2,d2
  7068.     bne.s    wdhm
  7069.     move.w    4(a0),d3
  7070.     beq.s    wdhm
  7071.     and.w    #3,d3
  7072.     bne.s    wdhm
  7073.     subq.w    #1,d0
  7074.     bcc.s    wdhm
  7075.     addq.w    #1,d0
  7076. tag    add.w    d1,d0
  7077.     addq.w    #1,d0
  7078.     move.w    d2,2(a0)    month (i don't like february)
  7079.     move.w    d0,(a0)        day
  7080.     movem.l    (sp)+,d0-d3/a0-a2
  7081.     rts
  7082.  
  7083. montab    dc.b    31,28,31,30,31,30,31,31,30,31,30,31
  7084.  
  7085. *************************
  7086. *    CHECK        *    ALLOWS DIS/ENABLING OF STATUS DISPLAY
  7087. *************************
  7088. checkz    tst.l    parm2(a5)
  7089.     beq.s    help_status
  7090.     move.l    parm2(a5),a0
  7091.     clr.b    stat_mode_flag(a5)    =00
  7092.     move.b    1(a0),d0
  7093.     bset    #5,d0
  7094.     cmp.b    #"n",d0    ;oN
  7095.     bne.s    say_OK
  7096. stat_yes    not.b    stat_mode_flag(a5)    =FF
  7097. say_OK    lea    OK_text(pc),a1
  7098.     bsr    pr_string
  7099.     moveq    #RETURN_OK,d0
  7100.     rts
  7101. help_status
  7102.     lea    chkuse(pc),a1
  7103.     bsr    pr_stringlf
  7104.     moveq    #RETURN_BAD,d0
  7105.     rts
  7106.  
  7107. *************************
  7108. *    STACK        *
  7109. *************************
  7110. stackz    move.l    thistask(a5),a0
  7111.     move.l    pr_CLI(a0),a4
  7112.     add.l    a4,a4
  7113.     add.l    a4,a4        A4=cli ptr
  7114.  
  7115.     move.l    cli_DefaultStack(a4),d7
  7116.     lsl.l    #2,d7
  7117.     tst.l    parm2(a5)
  7118.     beq.s    show_stack
  7119.     move.l    parm2(a5),a1
  7120.     bsr    convert_ASCII_to_num
  7121.     beq    bad_number_error
  7122. stk_num_OK
  7123.     move.l    d0,d6
  7124.     cmpi.l    #1600,d6  ;allow 1600 bytes for DOS
  7125.     blt.s    stoosmall
  7126.     move.l    d6,d0
  7127.     moveq    #1,d1   
  7128.     bsr    iwantmem 
  7129.     beq.s    stoobig   
  7130.     move.l    d0,a1   
  7131.     move.l    d6,d0   
  7132.     bsr    givemem  
  7133.     
  7134.     lsr.l    #2,d6
  7135.     move.l    d6,cli_DefaultStack(a4)
  7136.     moveq    #RETURN_OK,d0
  7137.     rts
  7138. stoosmall    lea    stk_too_small_tx(pc),a0
  7139.     moveq    #RETURN_ERROR,d0
  7140.     bra    new_print
  7141. stoobig    lea    stk_too_big_tx(pc),a0
  7142.     moveq    #RETURN_ERROR,d0
  7143.     bra    new_print
  7144. show_stack
  7145.     move.l    d7,-(sp)
  7146.     lea    (sp),a1
  7147.     lea    stk_size_tx(pc),a0
  7148.     bsr    new_print
  7149.     move.l    (sp)+,d0
  7150.     moveq    #RETURN_OK,d0
  7151.     rts
  7152.  
  7153. ** CHECK STRING A0 IF ENDING IN :
  7154. ** RETURN EQ IF DOES END IN COLON
  7155. check_for_colon
  7156. .A    tst.b    (a0)+    MAKE SURE ENDS IN :
  7157.     bne.s    .A
  7158.     move.b    -2(a0),d0
  7159.     cmp.b    #':',d0
  7160.     rts
  7161.  
  7162. do_forbid    move.l    4.w,a6
  7163.     jsr    _LVOForbid(a6)
  7164.     move.l    dosbase(a5),a6
  7165.     rts
  7166. do_permit    move.l    4.w,a6
  7167.     jsr    _LVOPermit(a6)
  7168.     move.l    dosbase(a5),a6
  7169.     rts
  7170.     
  7171. *************************
  7172. *    ASSIGN         *
  7173. *************************
  7174. assignz    bsr    do_forbid        FORBID
  7175.     bsr    get_first_devinfo
  7176.     tst.l    parm2(a5)
  7177.     beq    show_assigns
  7178.     tst.l    parm3(a5)
  7179.     beq    exit_assignf    ONLY TWO PARMS TYPED (NEED 3)
  7180.     move.l    parm2(a5),a0
  7181.     bsr    check_for_colon
  7182.     beq    .B
  7183.     bsr    do_permit
  7184.     lea    no_colon_tx(pc),a1
  7185.     bsr    pr_string
  7186.     moveq    #RETURN_ERROR,d0
  7187.     rts
  7188.     
  7189. .B    moveq    #dt_dir,d1    CREATE/MODIFY ASSIGN ******
  7190.     bsr    find_next_assign
  7191.     tst.l    d0
  7192.     bne    no_more_dir_assigns
  7193.     move.l    a0,d5
  7194.     move.l    parm2(a5),a0    A0=assigned name[0]
  7195.     moveq    #0,d2
  7196.     move.b    (a1)+,d2        get char count
  7197. .A    move.b    (a1)+,d0
  7198.     move.b    (a0)+,d1
  7199.     beq.s    .B
  7200.     subq.l    #1,d2
  7201.     bmi.s    .C
  7202.     bsr    compD1D0nocase
  7203.     beq.s    .A
  7204. .D    bra.s    .B
  7205.  
  7206. .C    cmp.b    #':',d1    CHANGE EXISTING
  7207.     bne.s    .D
  7208.     bsr    do_permit        PERMIT
  7209.     move.l    d5,a2        GOT A MATCH
  7210.     moveq    #ACCESS_READ,d2
  7211.     move.l    parm3(a5),d1
  7212.     jsr    _LVOLock(a6)
  7213.     tst.l    d0
  7214.     beq    exit_assignp
  7215.     move.l    d0,a3
  7216.     bsr    do_forbid        FORBID
  7217.     move.l    dvi_Lock(a2),d4
  7218.     move.l    a3,dvi_Lock(a2)    new lock
  7219.     add.l    a3,a3
  7220.     add.l    a3,a3
  7221.     move.l    fl_Task(a3),dvi_Task(a2)
  7222.     clr.l    dvi_Handler(a2)
  7223.     clr.l    dvi_StackSize(a2)
  7224.     clr.l    dvi_Priority(a2)
  7225.     clr.l    dvi_Startup(a2)
  7226.     clr.l    dvi_SegList(a2)
  7227.     clr.l    dvi_GlobVec(a2)
  7228.     bsr    do_permit
  7229.     move.l    d4,d1
  7230.     jsr    _LVOUnLock(a6)
  7231.     bra    exit_assignp
  7232.     
  7233. no_more_dir_assigns
  7234.     bsr    do_permit        CREATE NEW ASSIGN
  7235.     moveq    #48,d0
  7236.     move.l    #MEMF_CLEAR+1,d1
  7237.     bsr    iwantmem
  7238.     beq    exit_assignp
  7239.     move.l    d0,a4
  7240.     move.l    #48,(a4)+        save size byte
  7241.     move.l    parm2(a5),a0
  7242.     moveq    #4,d0    4+1 extra bytes for dos(nb: : is ignored)
  7243. .A    addq.l    #1,d0
  7244.     tst.b    (a0)+
  7245.     bne.s    .A
  7246.     move.l    d0,d3    D3=size+5+1    (block size|char_count|chars)
  7247.     moveq    #1,d1
  7248.     bsr    iwantmem
  7249.     beq    rem_dvi
  7250.     move.l    d0,a3
  7251.     move.l    d0,d4        D4=string ptr
  7252.     move.l    d3,(a3)+        save size byte
  7253.     subq.l    #6,d3
  7254.     move.b    d3,(a3)+        save char_count
  7255.     move.l    parm2(a5),a0
  7256.     bra.s    .C
  7257. .B    move.b    d1,(a3)+        copy string to NAME
  7258. .C    move.b    (a0)+,d1
  7259.     cmp.b    #':',d1
  7260.     bne.s    .B
  7261.     clr.b    (a3)        ;NULL-ending V2.0
  7262.     addq.l    #4,d0
  7263.     lsr.l    #2,d0    convert to bstr
  7264.     move.l    d0,dvi_Name(a4)
  7265.     move.l    #dt_dir,dvi_Type(a4)
  7266.     moveq    #ACCESS_READ,d2
  7267.     move.l    parm3(a5),d1
  7268.     jsr    _LVOLock(a6)
  7269.     tst.l    d0
  7270.     beq    rem_str
  7271.     move.l    d0,dvi_Lock(a4)
  7272.     lsl.l    #2,d0        x 4
  7273.     move.l    d0,a0
  7274.     move.l    fl_Task(a0),dvi_Task(a4)
  7275.     bsr    do_forbid
  7276.     bsr    get_first_devinfo    RETURNS A1 pts info substr, A2 pts 1st devinfo
  7277.     move.l    a2,dvi_Next(a4)
  7278.     move.l    a4,d0
  7279.     lsr.l    #2,d0
  7280.     move.l    d0,di_DevInfo(a1)    Insert new top of chain
  7281.     bsr    do_permit
  7282.     
  7283.     bra.s    exit_assignp
  7284. rem_str    move.l    d4,a1
  7285.     move.l    (a1),d0
  7286.     bsr    givemem
  7287. rem_dvi    lea    -4(a4),a1
  7288.     moveq    #48,d0
  7289.     bsr    givemem
  7290. exit_assignp
  7291.     moveq    #RETURN_OK,d0
  7292.     rts
  7293. exit_assignf
  7294.     bsr    do_permit
  7295.     moveq    #RETURN_OK,d0
  7296.     rts
  7297.     
  7298. * SHOW ASSIGNS    ALREADY IN FORBID STATE
  7299. show_assigns
  7300.     lea    -8(sp),sp
  7301.     move.l    a2,(sp)        0(sp)= BPTR of first devinfo
  7302.     move.l    #1024,d0
  7303.     moveq    #1,d1
  7304.     bsr    iwantmem        allocate big block
  7305.     beq    asg_fail
  7306.     move.l    d0,a4        A4 = string block
  7307.     move.l    d0,4(sp)        4(sp) = string block
  7308.     lea    volume_tx(pc),a0    PRINT VOLUMES:
  7309.     bsr    copy_name
  7310.     moveq    #dt_volume,d1
  7311. do_volumes
  7312. .E    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  7313.     tst.l    d0         TO THE BIG STRING
  7314.     bne.s    do_devices
  7315.     bsr    copy_bstr
  7316.     move.b    #$20,(a4)+    seperate with spaces
  7317.     tst.l    dvi_Task(a0)
  7318.     beq.s    .H
  7319.     lea    mounted_tx(pc),a0
  7320.     bsr    copy_name
  7321. .H    move.b    #LF,(a4)+
  7322.     bra.s    .E
  7323. do_devices    
  7324.     move.l    (sp),a2        restart at first devinfo
  7325.     lea    device_tx(pc),a0    PRINT DEVICES:
  7326.     bsr    copy_name
  7327.     moveq    #dt_device,d1
  7328.     bsr    store_mult_entries
  7329.     move.l    (sp),a2
  7330. do_dirs
  7331.     lea    assign_tx(pc),a0    PRINT DIRECTORIES
  7332.     bsr    copy_name
  7333.     move.l    #-1,-(sp)        PUSH NEGATIVE ON STACK
  7334. .B    moveq    #dt_dir,d1
  7335.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  7336.     tst.l    d0         TO THE BIG STRING
  7337.     bne.s    get_nxt_lock
  7338.     lea    -38(sp),sp    ALLOW 38 BYTES FOR STRING
  7339.     move.l    dvi_Lock(a0),-(sp)    push lock
  7340.     lea    4(sp),a0
  7341.     move.b    (a1)+,d0
  7342.     bra.s    .J
  7343. .H    move.b    (a1)+,(a0)+    copy name onto stack
  7344. .J    dbra    d0,.H
  7345.     clr.b    (a0)+
  7346.     bra.s    .B
  7347.  
  7348. get_nxt_lock
  7349.     move.l    (sp)+,d1        get lock
  7350.     bmi    .A
  7351.     lea    (sp),a0
  7352. .F    move.b    (a0)+,(a4)+    copy name to store
  7353.     bne.s    .F
  7354.     lea    38(sp),sp
  7355.     move.b    #$9,-1(a4)
  7356.     tst.l    d1
  7357.     beq    .C        no lock
  7358.     move.l    d1,a0
  7359.     add.l    a0,a0
  7360.     add.l    a0,a0
  7361.     move.l    fl_Volume(a0),a0
  7362.     add.l    a0,a0
  7363.     add.l    a0,a0
  7364.     tst.l    dvi_Task(a0)
  7365.     bne.s    .E
  7366.     lea    unmounted_tx(pc),a0
  7367.     bsr    copy_name
  7368.     bra.s    get_nxt_lock
  7369. .E    bsr    do_permit
  7370.     jsr    _LVODupLock(a6)    copy lock(D1) --> (D0)
  7371.     move.l    a4,a0
  7372.     bsr    eval_full_path
  7373.     jsr    _LVOUnLock(a6)
  7374.     bsr    do_forbid
  7375. .D    tst.b    (a4)+
  7376.     bne.s    .D
  7377. .C    move.b    #LF,-1(a4)    overwrite null or tab
  7378.     bra.s    get_nxt_lock
  7379. .A    move.b    #LF,(a4)+    linefeed at end
  7380.  
  7381.     clr.b    (a4)+
  7382.     bsr    do_permit
  7383.     move.l    4(sp),a1
  7384.     bsr    pr_string
  7385.     move.l    4(sp),a1
  7386.     move.l    #1024,d0
  7387.     bsr    givemem
  7388.     bra.s    asg_fail2
  7389. asg_fail    bsr    do_permit
  7390. asg_fail2    lea    8(sp),sp
  7391.     moveq    #RETURN_OK,d0
  7392.     rts
  7393.  
  7394.  
  7395. store_mult_entries
  7396. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  7397.     tst.l    d0         TO THE BIG STRING
  7398.     bne.s    .A
  7399.     bsr    copy_bstr
  7400.     move.b    #$20,(a4)+    seperate with spaces
  7401.     move.b    #$20,(a4)+
  7402.     bra.s    .B
  7403. .A    move.b    #LF,(a4)+    linefeed at end
  7404.     rts
  7405.  
  7406. get_first_devinfo
  7407.     move.l    dl_Root(a6),a1
  7408.     move.l    rn_Info(a1),a1
  7409.     add.l    a1,a1
  7410.     add.l    a1,a1
  7411.     move.l    di_DevInfo(a1),a2    A2=BPTR to first devinfo
  7412.     rts
  7413.  
  7414. copy_name    move.b    (a0)+,(a4)+
  7415.     bne.s    copy_name
  7416.     lea    -1(a4),a4
  7417.     rts
  7418.  
  7419. **COPY BSTR FROM A1 TO A4, DONT NULL END
  7420. copy_bstr    move.b    (a1)+,d0
  7421.     bra.s    .C
  7422. .B    move.b    (a1)+,(a4)+
  7423. .C    dbra    d0,.B
  7424.     rts
  7425.     
  7426. **ENTRY: D1=type ,A2=Bptr of devinfo, EXIT: A2=Bptr to next ,D0=0 if found
  7427. **EXIT: D2=lock, D1=type, A1 pts to string, A0 pts devinfo struct
  7428. find_next_assign
  7429. .A    add.l    a2,a2    FIND NEXT DEVINFO THAT MATCHES THE TYPE (D1)
  7430.     add.l    a2,a2        A2 pts to first devinfo structure
  7431.     move.l    a2,d0        tst.l    (a2)
  7432.     beq.s    .B
  7433.     move.l    a2,a0
  7434.     move.l    dvi_Name(a2),a1
  7435.     move.l    dvi_Lock(a2),d2
  7436.     move.l    dvi_Type(a2),d0
  7437.     move.l    (a2),a2
  7438.     cmp.l    d0,d1
  7439.     bne.s    .A
  7440.     add.l    a1,a1
  7441.     add.l    a1,a1
  7442.     moveq    #0,d0
  7443.     rts
  7444. .B    moveq    #1,d0
  7445.     rts
  7446.  
  7447. bad_number_error
  7448.     move.l    a1,-(sp)
  7449.     lea    bad_number_tx(pc),a1
  7450.     bsr    pr_stringlf
  7451.     move.l    (sp)+,a1
  7452.     moveq    #RETURN_ERROR,D0
  7453.     rts
  7454.  
  7455. *************************
  7456. *    FAILAT         *
  7457. *************************
  7458. failatz    tst.l    parm2(a5)
  7459.     beq.s    show_failat
  7460.     move.l    parm2(a5),a1
  7461.     bsr    convert_ASCII_to_num
  7462.     bne.s    failat_OK
  7463.     bra    bad_number_error
  7464. failat_OK    move.w    d0,failat_level(a5)
  7465.     moveq    #RETURN_OK,d0
  7466.     RTS
  7467. show_failat
  7468.     lea    failat_level(a5),a1
  7469.     lea    failat_tx(pc),a0
  7470.     bsr    new_print
  7471.     moveq    #RETURN_OK,d0
  7472.     rts
  7473.  
  7474. *************************
  7475. *    IF         *
  7476. *************************
  7477. ifz    move.b    #$ff,if_flag(a5)
  7478.     move.b    #$ff,if_condition_flag(a5)    set FALSE
  7479.     lea    parm2(a5),a4
  7480.     moveq    #0,d4        not state
  7481. .C    move.l    (a4)+,d0
  7482.     beq    if_fail
  7483.     move.l    d0,a0
  7484.     lea    not_tx(pc),a1
  7485.     bsr    compare_strings
  7486.     bne.s    .B
  7487.     not.b    d4        set D4=FF if not
  7488.     bra    .C
  7489. .B    lea    exists_tx(pc),a1
  7490.     bsr    compare_strings
  7491.     bne.s    try_warn    IF NOT AN EXISTS TYPE COMPARE
  7492.     move.l    (a4)+,d1
  7493.     beq    if_fail
  7494.     moveq    #0,d3        d3=0    doesnt exist
  7495.     moveq    #ACCESS_READ,d2
  7496.     jsr    _LVOLock(a6)
  7497.     tst.l    d0
  7498.     beq.s    save_state
  7499.     move.l    d0,d1
  7500.     jsr    _LVOUnLock(a6)
  7501.     not.b    d3        d3=ff    exists
  7502. save_state
  7503.     not.b    d3        d3=0    true
  7504.     eor.b    d4,d3
  7505.     move.b    d3,if_condition_flag(a5)
  7506.     moveq    #RETURN_OK,D0
  7507.     RTS
  7508. try_warn    move.l    last_failcode(a5),d5
  7509.     moveq    #RETURN_WARN,d6
  7510.     lea    warn_tx(pc),a1    CHECK IF 'IF WARN'
  7511.     bsr    compare_strings
  7512.     bne    try_error
  7513. set_error_state
  7514.     moveq    #0,d3
  7515.     cmp.l    d6,d5
  7516.     bne    save_state
  7517.     not.b    d3
  7518.     bra    save_state
  7519. try_error    lea    error_tx(pc),a1
  7520.     bsr    compare_strings
  7521.     bne    try_fail
  7522.     moveq    #RETURN_ERROR,d6
  7523.     bra    set_error_state
  7524. try_fail    lea    fail_tx(pc),a1
  7525.     bsr    compare_strings
  7526.     bne    if_fail
  7527.     moveq    #RETURN_FAIL,d6
  7528.     bra    set_error_state
  7529. if_fail    not.b    if_flag(a5)    clear it
  7530.     lea    if_error_tx(pc),a1
  7531.     bsr    pr_string
  7532.     MOVEQ    #RETURN_ERROR,D0
  7533.     RTS
  7534.  
  7535. *************************
  7536. *    ASK         *
  7537. *************************
  7538. askz    bsr    echoz        print the parm same as echo does
  7539. rask    bsr    raw_off
  7540.     move.l    inhandle(a5),d1
  7541.     beq.s    .A
  7542.     lea    tempbuf(a5),a4    a4:tempbuf
  7543.     clr.b    (a4)
  7544.     move.l    a4,d2
  7545.     moveq    #120,d3
  7546.     jsr    _LVORead(a6)    read input
  7547.     tst.l    d0
  7548.     bmi.s    .A
  7549.     beq.s    .A
  7550.     move.l    outhandle(a5),d1
  7551.     cmp.l    stdout(a5),d1    output redirected ?
  7552.     beq.s    .C
  7553.     move.l    a4,a0
  7554.     add.l    d0,a0
  7555.     subq.l    #1,a0
  7556.     clr.b    (a0)    Null-End
  7557.     move.l    a4,a1
  7558.     bsr    pr_string    repeat input
  7559.     bra    .A
  7560. .C    or.b    #$20,(a4)
  7561.     moveq    #RETURN_FAIL,d0
  7562.     cmp.b    #'f',(a4)    V2.0
  7563.     beq    .B
  7564.     moveq    #RETURN_ERROR,d0
  7565.     cmp.b    #'e',(a4)    V2.0
  7566.     beq    .B
  7567.     moveq    #RETURN_WARN,d0
  7568.     cmp.b    #'j',(a4)    V2.0
  7569.     beq    .B
  7570.     cmp.b    #'y',(a4)
  7571.     beq    .B
  7572. .A    moveq    #RETURN_OK,D0
  7573. .B    rts
  7574.  
  7575. *************************
  7576. *    WAIT         *
  7577. *************************
  7578. waitz    move.l    parm2(a5),d0
  7579.     beq    too_less_args
  7580.     move.l    d0,a1
  7581.     bsr    convert_ASCII_to_num
  7582.     beq    bad_number_error
  7583.     move.l    d0,d4
  7584.     lsl.l    #2,d4        d4*4
  7585.     add.l    d0,d4        d4:=d0*5 (d4*4+d4)
  7586. .C    bsr    check_c
  7587.     bne.s    .E
  7588.     moveq    #LF,d1        1/5 second
  7589.     jsr    _LVODelay(a6)
  7590.     subq.l    #1,d4
  7591.     bne.s    .C
  7592. .E    moveq    #RETURN_OK,D0
  7593.     RTS
  7594.  
  7595. *************************
  7596. *    QUIT         *
  7597. *************************
  7598. * only returns from script files.
  7599. quitz    tst.b    scflag(a5)
  7600.     bne.s    .A
  7601.     moveq    #RETURN_OK,D0
  7602.     RTS
  7603. .A    move.l    parm2(a5),d0
  7604.     beq    .B
  7605.     move.l    d0,a1
  7606.     bsr    convert_ASCII_to_num
  7607.     bne    .B
  7608.     bsr    bad_number_error
  7609. .B    move.l    d0,-(sp)
  7610.     bsr    kill_script    guarantee that script is dead
  7611.     move.l    (sp)+,d0
  7612.     rts
  7613.     
  7614. *************************
  7615. *    JOIN         *
  7616. *************************
  7617. joinz    lea    parm2(a5),a4
  7618.     move.l    a4,a3
  7619.     tst.l    4(a3)    must have at least 2 parameters
  7620.     beq    too_less_args
  7621. .A    tst.l    (a3)+        FIND LAST PARAMETER
  7622.     bne.s    .A
  7623.     lea    -8(a3),a3        A3=last parm ie the write file
  7624.     move.l    (a3),d1
  7625.     move.l    #MODE_NEWFILE,D2
  7626.     jsr    _LVOOpen(a6)
  7627.     tst.l    d0
  7628.     beq    DOSjoin_failure
  7629.     move.l    d0,please_close_me(a5)    write handle
  7630.     
  7631. .B    cmp.l    a4,a3
  7632.     beq    finish_join
  7633.     move.l    (a4)+,a0
  7634.     bsr    readfile
  7635.     move.l    d0,d2
  7636.     move.l    d0,d5    D5=addr
  7637.     move.l    d1,d3
  7638.     move.l    d1,d6    D6=size
  7639.     move.l    please_close_me(a5),d1
  7640.     jsr    _LVOWrite(a6)
  7641.     tst.l    d0
  7642.     bmi    DOSjoin_failure3
  7643.     bsr    free_joiner
  7644.     bra    .B
  7645. finish_join
  7646.     bsr    close_the_joined
  7647.     moveq    #RETURN_OK,D0
  7648.     RTS
  7649.     
  7650. DOSjoin_failure3
  7651.     bsr    free_joiner        dealloc readfile
  7652.     bsr    close_the_joined
  7653. DOSjoin_failure
  7654.     bra    DOSerr
  7655.  
  7656. free_joiner
  7657.     move.l    d5,a1
  7658.     move.l    d6,d0
  7659.     bra    givemem        dealloc readfile
  7660.  
  7661. close_the_joined
  7662.     move.l    please_close_me(a5),d1
  7663.     jsr    _LVOClose(a6)    close write file
  7664.     clr.l    please_close_me(a5)
  7665.     rts
  7666.  
  7667. *************************
  7668. *    HTYPE         *
  7669. *************************
  7670. htypez    move.l    parm2(a5),d1
  7671.     beq    too_less_args
  7672.     move.l    d1,a0
  7673.     bsr    readfile
  7674.     move.l    d0,mem_addr(a5)
  7675.     move.l    d0,mem_offset_addr(a5)
  7676.     move.l    d1,temp1(a5)
  7677.     add.l    d0,d1
  7678.     move.l    d1,d7        end marker
  7679.     bsr    rawh_off
  7680. .B    bsr    check_c
  7681.     bne    htype_end
  7682.     bsr    show_16_locs
  7683.     cmp.l    mem_addr(a5),d7
  7684.     bhi    .B
  7685. htype_end    move.l    mem_offset_addr(a5),a1
  7686.     move.l    temp1(a5),d0
  7687.     bsr    givemem
  7688.     moveq    #RETURN_OK,D0
  7689.     RTS
  7690.  
  7691. *************************
  7692. *    STRINGS     *
  7693. *************************
  7694. stringsz    move.l    parm2(a5),d0
  7695.     beq    too_less_args
  7696.     moveq    #7,d7        default 7
  7697.     move.l    parm3(a5),d0
  7698.     beq.s    .B
  7699.     move.l    d0,a1
  7700.     bsr    convert_ASCII_to_num
  7701.     beq    bad_number_error
  7702.     
  7703.     move.l    d0,d7        D7=min_string
  7704. .B    move.l    parm2(a5),a0
  7705.     bsr    readfile
  7706.     move.l    d0,a4        A4=addr of file
  7707.     move.l    a4,a3
  7708.     move.l    d1,d6        D6=size of file
  7709.     add.l    d0,d1
  7710.     move.l    d1,d4        D4=max addr
  7711.     movem.l    d4-d7/a3-a4,-(sp)
  7712.     bsr    rawh_off
  7713.     movem.l    (sp)+,d4-d7/a3-a4
  7714. str_next    bsr    check_c
  7715.     bne    kill_string_file
  7716.     moveq    #0,d5        D5=current string size
  7717.     move.l    a3,a2
  7718. valid_ch    cmp.l    a3,d4
  7719.     beq    string_fin
  7720.     move.b    (a3)+,d0
  7721.     cmp.b    #' ',d0
  7722.     blo.s    not_valid_char
  7723.     cmp.b    #$7f,d0
  7724.     bhi.s    not_valid_char
  7725.     addq.l    #1,d5
  7726.     bra    valid_ch
  7727. not_valid_char
  7728.     cmp.l    d7,d5
  7729.     blo    str_next
  7730.     bsr    write_my_string
  7731.     bra    str_next
  7732.  
  7733. string_fin
  7734.     cmp.l    d7,d5
  7735.     blo    kill_string_file
  7736.     bsr    write_my_string
  7737. kill_string_file
  7738.     move.l    a4,a1
  7739.     move.l    d6,d0
  7740.     bsr    givemem
  7741.     moveq    #RETURN_OK,D0
  7742.     RTS
  7743.     
  7744. write_my_string
  7745.     move.l    outhandle(a5),d1
  7746.     beq.s    .A
  7747.     move.l    a2,d2
  7748.     move.l    d5,d3
  7749.     jsr    _LVOWrite(a6)
  7750. .A    bra    pr_lf
  7751.  
  7752. *************************
  7753. *    FILENOTE    *
  7754. *************************
  7755. filenotez bsr    fixpam32        V2.0
  7756.     move.l    a0,d1
  7757.     move.l    a1,d2
  7758.     move.l    a1,a2
  7759.     moveq    #78,d0
  7760. .A    tst.b    (a2)+
  7761.     beq.s    fnok
  7762.     dbra    d0,.A
  7763.     moveq    #RETURN_ERROR,d0    ;more than 80 chars
  7764.     rts
  7765. fnok    jsr    _LVOSetComment(a6)
  7766.     addq.l    #1,d0
  7767.     bne    DOSerr
  7768.     rts
  7769.  
  7770. *************************
  7771. *    SEARCH        *    Searches a string in a file
  7772. *************************
  7773. searchz    bsr    rawh_off        V2.0
  7774.     bsr    fixpam32
  7775.     tst.b    (a1)
  7776.     beq    too_less_args
  7777.     move.l    a1,d7
  7778.     bsr    readfile    get file
  7779.     move.l    d1,d5        push size
  7780.     move.l    d0,d6
  7781.     add.l    d1,d6
  7782.     move.l    d0,a2
  7783.     move.l    d0,a3        a3:start of file
  7784. .A    move.l    d7,a1        d7:search string
  7785.     move.l    d6,a0        d6:end of file
  7786.     bsr    searchSTR    a2:current searchpos
  7787.     cmp.b    #1,d0
  7788.     beq.s    .B
  7789.     move.l    a0,-(sp)
  7790.     move.l    d7,a0
  7791.     moveq    #-1,d4
  7792. .D    addq.l    #1,d4
  7793.     tst.b    (a0)+        length of searchstr.
  7794.     bne.s    .D
  7795.     move.l    a1,d2
  7796.     move.l    a2,d3
  7797.     sub.l    d2,d3
  7798.     beq.s    .C
  7799.     move.l    outhandle(a5),d1
  7800.     jsr    _LVOWrite(a6)    write part before searchstr.
  7801. .C    lea    farb3(pc),a1
  7802.     bsr    pr_string
  7803.     move.l    a2,d2
  7804.     move.l    d4,d3
  7805.     move.l    outhandle(a5),d1
  7806.     jsr    _LVOWrite(a6)    write searchstr.
  7807.     lea    farb1(pc),a1
  7808.     bsr    pr_string
  7809.     move.l    (sp)+,a0
  7810.     move.l    a2,d2
  7811.     add.l    d4,d2
  7812.     move.l    a0,d3
  7813.     sub.l    d2,d3
  7814.     beq.s    .E
  7815.     move.l    outhandle(a5),d1
  7816.     jsr    _LVOWrite(a6)    write part after searchstr.
  7817. .E    bsr    pr_lf
  7818.     addq.l    #1,a2
  7819.     bsr    check_c
  7820.     beq.s    .A
  7821. .B    move.l    d5,d0
  7822.     move.l    a3,a1
  7823.     bsr    givemem        free file
  7824. endse    moveq    #RETURN_OK,d0
  7825.     rts
  7826.  
  7827. * Searches for a string
  7828. * ENTRY:a1 points to the string to search for (ends in NULL)
  7829. *     a2 points to start position, a0 to end of file, a3 to start
  7830. * EXIT: a2  to found-position, a0 to NULL- or LF-end, a1 to LF-start
  7831. *    d0=1 not found, d0= found NULL-ended, d0=10 found LF-ended
  7832. searchSTR
  7833.     movem.l    d1-d3/a3-a4,-(sp)
  7834.     move.b    (a1),d0
  7835.     cmp.b    ctrl_codes+15(a5),d0
  7836.     bne.s    .I
  7837.     move.b    #LF,(a1)    begins with LineFeed
  7838. .I    move.l    a3,d3
  7839.     moveq    #0,d0
  7840.     moveq    #1,d2
  7841. .A    move.b    (a1),d0
  7842.     cmp.l    a0,a2
  7843.     bhi    .E
  7844.     move.b    (a2)+,d1
  7845.     bsr    compD1D0nocase    search first char
  7846.     bne.s    .A
  7847.     move.l    a1,a3
  7848.     addq.l    #1,a3
  7849.     move.l    a2,a4
  7850. .B    move.b    (a3)+,d0
  7851.     beq.s    .C
  7852.     cmp.l    a0,a4
  7853.     bhi    .E
  7854.     move.b    (a4)+,d1
  7855.     bsr    compD1D0nocase    compare other chars
  7856.     bne.s    .A
  7857.     bra.s    .B
  7858. .C    subq.l    #1,a2
  7859.     move.l    a2,a1
  7860. .D    cmp.l    a0,a4
  7861.     bhi    .E
  7862.     move.b    (a4)+,d1    search end
  7863.     beq.s    .G
  7864.     cmp.b    #LF,d1
  7865.     bne.s    .D
  7866.     cmp.b    #LF,(a1)
  7867.     beq.s    .H
  7868. .F    cmp.l    d3,a1
  7869.     bls    .G
  7870.     move.b    -(a1),d0
  7871.     beq.s    .H
  7872.     cmp.b    #LF,d0        search beginning (if LF)
  7873.     bne.s    .F
  7874. .H    addq.l    #1,a1
  7875. .G    move.b    d1,d2
  7876.     lea    -1(a4),a0
  7877. .E    move.l    d2,d0
  7878.     movem.l    (sp)+,d1-d3/a3-a4
  7879.     rts
  7880.  
  7881.  
  7882. *****************
  7883. *    FAULT    *
  7884. *****************
  7885. faultz    move.l    parm2(a5),d0            V2.0
  7886.     beq    too_less_args
  7887.     move.l    d0,a1
  7888.     bsr    convert_ASCII_to_num
  7889.     beq    bad_number_error
  7890.     bsr    pr_DOSerr
  7891. .A    moveq    #RETURN_OK,d0
  7892.     rts
  7893.  
  7894. *************************
  7895. *    SETCLOCK    *
  7896. *************************
  7897. setclockz lea    $dc0000,a4    ;clockbase    V2.0
  7898.     move.b    1(a4),d4
  7899.     moveq    #75,d1
  7900.     jsr    _LVODelay(a6)
  7901.     cmp.b    1(a4),d4    ;secs changed ?
  7902.     beq.s    noclk
  7903.     move.l parm2(a5),a0
  7904.     move.b    (a0),d0
  7905.     bset.l    #5,d0
  7906.     cmp.b    #"l",d0
  7907.     beq    clkload
  7908.     cmp.b    #"s",d0
  7909.     beq.s    clksave
  7910.     lea    clk_tx(pc),a1
  7911.     bsr    pr_stringlf
  7912. uu    moveq    #RETURN_ERROR,d0
  7913.     rts
  7914. noclk    lea    noclk_tx(pc),a1
  7915.     bsr    pr_stringlf
  7916.     bra.s    uu
  7917.  
  7918. clksave    lea    date_mark(a5),a2
  7919.     move.l    a2,a0
  7920.     bsr    get_time
  7921.     move.l    a2,a1
  7922.     lea    -14(sp),sp
  7923.     lea    (sp),a0
  7924.     bsr    convert_time
  7925.     move.b    61(a4),d0    ;reset clock
  7926.     or.b    #1,d0        ;(don't use bset or bclr !)
  7927.     move.b    d0,61(a4)
  7928.     move.b    #0,57(a4)
  7929.     move.b    #5,61(a4)
  7930.     move.b    #4,61(a4)
  7931.     move.b    53(a4),d0    ;hold clock
  7932.     or.b    #1,d0
  7933.     move.b    d0,53(a4)
  7934. clks    btst    #1,53(a4)
  7935.     bne.s    clks
  7936.     lea    (sp),a0
  7937.     lea    chaotab(pc),a1
  7938.     moveq    #1,d6
  7939.     moveq    #0,d1
  7940.     moveq    #5,d0
  7941. .A    move.b    (a1)+,d1
  7942.     moveq    #0,d2
  7943.     move.w    0(a0,d1),d2
  7944.     divu    #LF,d2
  7945.     swap    d2
  7946.     move.b    d2,0(a4,d6)
  7947.     swap    d2
  7948.     move.b    d2,4(a4,d6)
  7949.     addq.l    #8,d6
  7950.     dbra    d0,.A
  7951.     move.b    53(a4),d0
  7952.     and.b    #$0e,d0
  7953.     move.b    d0,53(a4)    ;run clock
  7954.     lea    14(sp),sp
  7955.     moveq    #RETURN_OK,d0
  7956.     rts
  7957.  
  7958. chaotab    dc.b    10,8,6,0,2,4
  7959.  
  7960. getclk    move.b    0(a4,d6),d1    ;Read realtimeclock
  7961.     move.b    4(a4,d6),d0    ;(adress in a4,offset in d6)
  7962.     addq.l    #8,d6
  7963.     and.w    #$f,d0
  7964.     and.w    #$f,d1
  7965.     mulu    #LF,d0
  7966.     add.w    d1,d0
  7967.     ext.l    d0    ;result
  7968.     rts
  7969.  
  7970.         ;load current time from realtime-clock
  7971. clkload    move.b    53(a4),d0
  7972.     or.b    #1,d0
  7973.     move.b    d0,53(a4)
  7974. clkw    btst    #1,53(a4)
  7975.     bne.s    clkw
  7976.     lea    -6(sp),sp
  7977.     lea    (sp),a3
  7978.     moveq    #5,d2
  7979.     moveq    #1,d6
  7980. .A    bsr    getclk
  7981.     move.b    d0,(a3)+
  7982.     dbra    d2,.A
  7983.     lea    (sp),a3
  7984.     bsr    calcsec        ;how many secs ?
  7985.     move.b    53(a4),d0
  7986.     and.b    #$0e,d0
  7987.     move.b    d0,53(a4)
  7988.     lea    6(sp),sp
  7989.     bsr    tset        ;give it to system
  7990.     moveq    #RETURN_OK,d0
  7991.     rts
  7992.  
  7993. calcsec    moveq    #0,d7        ;a3->points to 6 bytes of date/time
  7994.     moveq    #1,d6                    V2.0
  7995.     move.b    (a3)+,d7    ;sec (collect secs in d7)
  7996.     moveq    #0,d0
  7997.     move.b    (a3)+,d0    ;min
  7998.     mulu    #smin,d0
  7999.     add.l    d0,d7
  8000.     moveq    #0,d0
  8001.     move.b    (a3)+,d0    ;std
  8002.     mulu    #sst,d0
  8003.     add.l    d0,d7
  8004.     moveq    #0,d0
  8005.     move.b    (a3)+,d0    ;tag
  8006.     subq.l    #1,d0
  8007.     move.l    d0,d5        ;collect days in d5
  8008.     moveq    #0,d2
  8009.     move.b    (a3)+,d2    ;monat
  8010.     lea    montab(pc),a0
  8011.     moveq    #0,d3
  8012.     move.b    (a3)+,d3    ;jahr
  8013.     move.l    d3,d0
  8014.     and.w    #3,d0
  8015.     bne.s    nosj
  8016.     move.b    #29,1(a0)    ;change montab
  8017. nosj    subq.l    #2,d2
  8018.     bmi.s    jan
  8019. madd    moveq    #0,d0
  8020.     move.b    0(a0,d2),d0
  8021.     add.w    d0,d5
  8022.     dbra    d2,madd
  8023. jan    cmp.b    #78,d3
  8024.     beq.s    tset
  8025.     subq.l    #1,d3
  8026.     moveq    #0,d1
  8027. jadd    add.w    #tjahr,d5
  8028.     move.l    d3,d0
  8029.     and.w    #3,d0
  8030.     bne.s    nosj2
  8031.     addq.l    #1,d5
  8032. nosj2    cmp.b    #78,d3
  8033.     dbeq    d3,jadd
  8034.     move.b    #28,1(a0)
  8035.     move.l    #stag,d1
  8036.     move.l    d5,d0
  8037.     bsr    mult_32x32
  8038.     move.l    d7,d6        ;d6=secs, d5=days
  8039.     add.l    d0,d7        ;d7=all seconds since 1.1.78
  8040.     rts
  8041.  
  8042. clrio    lea    io_Message(a5),a1    ;initialisiert IO-Request  V2.0
  8043.     move.l    a1,a0
  8044.     moveq    #$2f,d0
  8045. clst3    clr.b    (a0)+
  8046.     dbra    d0,clst3
  8047.     move.b    #5,io_Message+8(a5)
  8048.     move.l    thistask(a5),a0
  8049.     lea    pr_MsgPort(a0),a0
  8050.     move.l    a0,io_Message+14(a5)
  8051.     move.w    #$30,io_Message+18(a5)
  8052.     rts        ;a1:IO-Request a0:Msg-Port
  8053.  
  8054. tset    move.l    4.w,a6        ;set time with timer-device (secs in d7)
  8055.     bsr    clrio                V2.0
  8056.     move.w    #40,io_Message+18(a5)
  8057.     lea    timdev(pc),a0
  8058.     moveq    #1,d0
  8059.     moveq    #0,d1
  8060.     jsr    _LVOOpenDev(a6)
  8061.     tst.l    d0
  8062.     bne    tmfehl
  8063.     lea    io_Message(a5),a1
  8064.     move.w    #11,io_Command(a5)
  8065.     clr.w    io_Flags(a5)
  8066.     move.l    d7,tv_secs(a5)
  8067.     clr.l    tv_micro(a5)
  8068.     jsr    _LVODoIO(a6)
  8069.     tst.l    d0
  8070. ;    bne.s    tmfehl    ;better leave out
  8071.     lea    io_Message(a5),a1
  8072.     clr.l    io_Command(a5)
  8073.     jsr    _LVOCloseDev(a6)
  8074. tmfehl    move.l    dosbase(a5),a6
  8075.     rts
  8076.  
  8077. smin    equ    60
  8078. sst    equ    60*smin
  8079. stag    equ    24*sst
  8080. tjahr    equ    365
  8081.  
  8082.  
  8083. *************************
  8084. *    SHOW        *
  8085. *************************
  8086. showz    bsr    rawh_off            V2.0
  8087.     move.l    parm2(a5),d0
  8088.     beq    sdft
  8089.     move.l    d0,a0
  8090.     move.b    (a0),d1
  8091.     bset    #5,d1
  8092.     cmp.b    #"t",d1
  8093.     beq    shtask
  8094.     lea    styp(pc),a0
  8095.     moveq    #6,d0    ;7 Lists
  8096. .D    cmp.b    0(a0,d0.w),d1
  8097.     dbeq    d0,.D
  8098.     move.w    d0,d7
  8099.     bmi    sdft
  8100.     lea    show_tx(pc),a1
  8101.     cmp.w    #2,d7
  8102.     bhi.s    .C
  8103.     lea    show2_tx(pc),a1
  8104. .C    bsr    pr_stringlf
  8105.     bsr    do_forbid
  8106.     add.w    d0,d0
  8107.     lea    soffs(pc),a0
  8108.     move.w    0(a0,d0.w),d0
  8109.     move.l    4.w,a4
  8110.     move.l    0(a4,d0.w),a1
  8111. ;    move.l    8(a4,d0.w),a2
  8112.     lea    tempbuf(a5),a3
  8113. .A    tst.l    (a1)
  8114.     beq.s    .B
  8115.     move.l    a1,(a3)+
  8116.     move.l    (a1),a1
  8117.     bra.s    .A
  8118. .B    clr.l    (a3)
  8119.     bsr    do_permit
  8120.     lea    tempbuf(a5),a3
  8121. da    tst.l    (a3)
  8122.     beq    sdf
  8123.     move.l    (a3)+,a2
  8124.     move.l    10(a2),-(sp)
  8125.     lea    shform(pc),a0
  8126.     cmp.w    #2,d7
  8127.     bhi.s    .E
  8128.     lea    shform2(pc),a0
  8129.     move.w    22(a2),-(sp)
  8130.     move.w    20(a2),-(sp)
  8131. .E    move.b    9(a2),d0
  8132.     ext.w    d0
  8133.     move.w    d0,-(sp)
  8134.     move.l    a2,-(sp)
  8135.     lea    (sp),a1
  8136.     bsr    new_print
  8137.     lea    10(sp),sp
  8138.     cmp.w    #2,d7
  8139.     bhi.s    da
  8140.     addq.l    #4,sp
  8141.     bra.s    da
  8142. sdft    lea    shuse_tx(pc),a1
  8143.     bsr    pr_stringlf
  8144.     moveq    #RETURN_BAD,d0
  8145.     rts
  8146. sdf    moveq    #RETURN_OK,d0
  8147.     rts
  8148.  
  8149. shtask    lea    tempbuf(a5),a3    ;enough for 96 tasks
  8150.     move.l    4.w,a6
  8151.     jsr    _LVOForbid(a6)
  8152.     lea    420(a6),a0
  8153.     move.l    (a0),a1
  8154. .A    tst.l    (a1)
  8155.     beq.s    .B
  8156.     move.l    a1,(a3)+
  8157.     move.l    (a1),a1
  8158.     bra.s    .A
  8159. .B    lea    406(a6),a0
  8160.     move.l    (a0),a1
  8161. .C    tst.l    (a1)
  8162.     beq.s    .D
  8163.     move.l    a1,(a3)+
  8164.     move.l    (a1),a1
  8165.     bra.s    .C
  8166. .D    move.l    276(a6),(a3)+
  8167.     clr.l    (a3)
  8168.     jsr    _LVOPermit(a6)
  8169.     move.l    dosbase(a5),a6
  8170.     lea    shta_tx(pc),a1
  8171.     bsr    pr_stringlf
  8172.     lea    tempbuf(a5),a3
  8173. prsht    move.l    (a3)+,a2
  8174.     move.l    10(a2),-(sp)
  8175.     move.l    pr_MsgPort+MP_SIGTASK(a2),a4
  8176.     move.l    #$00540061,d0    ;Task
  8177.     cmp.l    a4,a2
  8178.     bne.s    .C
  8179.     sub.l    a4,a4        clear a4
  8180.     move.l    #$0054006d,d0    ;Task with Message-Port
  8181.     move.l    pr_CLI(a2),d1
  8182.     beq.s    .D
  8183.     lsl.l    #2,d1
  8184.     move.l    d1,a0
  8185.     move.l    cli_DefaultStack(a0),d2
  8186.     lsl.l    #2,d2
  8187.     move.l    62(a2),d1        ;62:tc_SPUpper
  8188.     sub.l    58(a2),d1
  8189.     cmp.l    d1,d2
  8190.     beq.s    .I
  8191. .D    move.l    pr_StackBase(a2),d1
  8192.     lsl.l    #2,d1
  8193.     cmp.l    58(a2),d1        ;58:tc_SPLower
  8194.     bne.s    .C
  8195.     move.l    62(a2),d1        ;62:tc_SPUpper
  8196.     sub.l    58(a2),d1
  8197.     cmp.l    pr_StackSize(a2),d1
  8198.     bne.s    .C
  8199. .I    move.l    a2,a4
  8200.     move.l    #$00500072,d0    ;Process
  8201. .C    move.w    d0,-(sp)
  8202.     swap    d0
  8203.     move.w    d0,-(sp)
  8204.     move.l    tc_SigWait(a2),-(sp)
  8205.     moveq    #0,d0
  8206.     move.b    tc_State(a2),d0
  8207.     lea    ttyp(pc),a0
  8208.     bra.s    .A
  8209. .B    tst.b    (a0)+
  8210.     bne.s    .B
  8211. .A    dbra    d0,.B
  8212.     move.l    a0,-(sp)
  8213.     move.b    LN_PRI(a2),d0
  8214.     ext.w    d0
  8215.     move.w    d0,-(sp)
  8216.     move.l    a2,-(sp)
  8217.     lea    (sp),a1
  8218.     lea    shtaform(pc),a0
  8219.     bsr    new_print        ;Print it
  8220.     lea    22(sp),sp
  8221.     cmp.l    a4,a2
  8222.     bne.s    snocli
  8223.     move.l    pr_TaskNum(a2),d0
  8224.     cmp.l    #60,d0
  8225. ;    bhi.s    snocli
  8226.     move.l    pr_CLI(a2),d1
  8227.     beq.s    snocli
  8228.     lsl.l    #2,d1    ;cli-process
  8229.     move.l    d1,a0
  8230.     tst.l    cli_CommandName(a0)
  8231.     bne.s    .G
  8232.     lea    null(pc),a1
  8233.     move.l    a1,-(sp)
  8234.     bra.s    .H
  8235. .G    move.l    cli_CommandName(a0),a0
  8236.     add.l    a0,a0
  8237.     add.l    a0,a0
  8238.     lea    temp2buf(a5),a1        ;BSTR
  8239.     move.l    a1,-(sp)
  8240.     moveq    #0,d1
  8241.     move.b    (a0)+,d1
  8242.     bra.s    .E
  8243. .F    move.b    (a0)+,(a1)+
  8244. .E    dbra    d1,.F
  8245.     clr.b    (a1)
  8246. .H    move.l    d0,-(sp)
  8247.     lea    proform(pc),a0
  8248.     lea    (sp),a1
  8249.     bsr    new_print        ;Print CLI-Add
  8250.     lea    8(sp),sp
  8251. snocli    bsr    pr_lf
  8252.     tst.l    (a3)
  8253.     bne    prsht    ;at least one task
  8254.     move.l    d6,d0
  8255. shtok    moveq    #RETURN_OK,D0
  8256.     rts
  8257.  
  8258. soffs    dc.w    378,336,350,364,322,392,532
  8259.  
  8260.  
  8261. *************************
  8262. *    MemClock    *    V2.0
  8263. *************************
  8264.  
  8265. ckstackSIZE    equ    2000
  8266. cktask    equ    0        ;Task-Struct
  8267. ckport    equ    cktask+92    ;MsgPort
  8268. ckstack    equ    ckport+34    ;Stack
  8269. ckustack equ    ckstack+ckstackSIZE
  8270. ckdos    equ    ckustack    ;DOSBase
  8271. ckint    equ    ckdos+4        ;Intuitionbase
  8272. ckitxt    equ    ckint+4        ;IntuiTextStruct
  8273. ckdate    equ    ckitxt+20    ;DateStamp
  8274. ckrawdo    equ    ckdate+12    ;DataStream
  8275. ckcook    equ    ckrawdo+6+8    ;Formatted String
  8276. ckrast    equ    ckcook+40    ;Rastports of all Windows
  8277. cknum    equ    ckrast+20*4    ;Number of Windows
  8278. ckalarm    equ    cknum+4        ;Alarm-Time
  8279. ckpad    equ    ckalarm+8
  8280. cksize    equ    ckpad+2
  8281.  
  8282. mlnode    equ    0        ;Memory-List
  8283. mlnum    equ    mlnode+14
  8284. mladdr    equ    mlnum+2
  8285. mllen    equ    mladdr+4
  8286. mlsize    equ    mllen+4
  8287.  
  8288. memclkz    move.l    parm2(a5),a0
  8289.     move.l    a0,d0
  8290.     beq.s    .A
  8291.     move.b    (a0),d0
  8292.     bset    #5,d0
  8293.     cmp.b    #"a",d0    ;alarm
  8294.     beq    clkalm
  8295.     move.b    1(a0),d0
  8296.     bset    #5,d0
  8297.     cmp.b    #"n",d0    ;oN
  8298.     beq    clkon
  8299.     cmp.b    #"f",d0    ;oFF
  8300.     beq    clkoff
  8301. .A    lea    clkuse(pc),a1
  8302.     bsr    pr_stringlf
  8303.     moveq    #RETURN_BAD,d0
  8304.     rts
  8305.  
  8306. clkon    move.l    4.w,a6        ;switch it on
  8307.     lea    clktask(pc),a1
  8308.     jsr    _LVOFindTask(a6)
  8309.     move.l    d0,a4
  8310.     tst.l    d0
  8311.     beq.s    .A    ;not already running
  8312.     bsr    winclk
  8313.     move.l    dosbase(a5),a6
  8314. .B    moveq    #RETURN_OK,d0
  8315.     rts
  8316. .A    move.l    #cksize,d0
  8317.     move.l    #1+1<<16,d1
  8318.     jsr    _LVOAllocMem(a6)
  8319.     tst.l    d0
  8320.     beq.s    .B
  8321.     move.l    d0,a4
  8322.     move.w    #$0104,cktask+8(a4)    ;type/pri
  8323.     lea    clktask(pc),a0
  8324.     move.l    a0,cktask+10(a4)    ;name
  8325.     lea    ckstack(a4),a0
  8326.     lea    ckustack(a4),a1
  8327.     move.l    a1,cktask+54(a4)    ;SPreg
  8328.     move.l    a0,cktask+58(a4)    ;lowerstack
  8329.     move.l    a1,cktask+62(a4)    ;upperstack
  8330.     move.l    a4,ckport+16(a4)    ;sigtask
  8331.     lea    ckport+20+4(a4),a0
  8332.     move.l    a0,ckport+20(a4)
  8333.     lea    ckport+20(a4),a0
  8334.     move.l    a0,ckport+20+8(a4)
  8335.     move.l    #mlsize,d0
  8336.     move.l    #1+1<<16,d1
  8337.     jsr    _LVOAllocMem(a6)
  8338.     tst.l    d0
  8339.     beq.s    .B
  8340.     move.l    d0,a2
  8341.     moveq    #1,d0
  8342.     move.w    d0,mlnum(a2)
  8343.     move.l    a4,mladdr(a2)
  8344.     move.l    #cksize,mllen(a2)
  8345.     lea    mlnode(a2),a0
  8346.     lea    cktask+78(a4),a1
  8347.     move.l    a0,-4(a1)
  8348.     move.l    a0,4(a1)
  8349.     move.l    a1,(a0)
  8350.     move.l    a1,4(a0)
  8351.     move.l    dosbase(a5),ckdos(a4)
  8352.     move.l    intuibase(a5),ckint(a4)
  8353.     bsr    winclk
  8354.     move.l    a4,a1
  8355.     lea    clkstart(pc),a2
  8356.     moveq    #0,d0
  8357.     move.l    d0,a3
  8358.     jsr    _LVOAddTask(a6)
  8359.     move.l    dosbase(a5),a6
  8360.     moveq    #RETURN_OK,d0
  8361.     rts
  8362.  
  8363. winclk    bsr    findrast    ;check if rastport already exists,
  8364.     tst.w    d1        ;else move rastport in table
  8365.     bpl.s    .C
  8366.     moveq    #19,d1
  8367. .B    tst.l    (a1)+
  8368.     dbeq    d1,.B
  8369.     bne.s    .C
  8370.     move.l    d0,-4(a1)
  8371. .C    rts
  8372.  
  8373. findrast    move.l    intuibase(a5),a0
  8374.     move.l    $34(a0),a0    ;active window
  8375.     move.l    $32(a0),d0    ;rastport
  8376.     lea    ckrast(a4),a0
  8377.     move.l    a0,a1
  8378.     moveq    #19,d1
  8379. .A    cmp.l    (a0)+,d0
  8380.     dbeq    d1,.A
  8381.     rts
  8382.  
  8383. clkoff    move.l    4.w,a6        ;switch it off
  8384.     lea    clktask(pc),a1
  8385.     jsr    _LVOFindTask(a6)
  8386.     move.l    d0,a4
  8387.     tst.l    d0
  8388.     beq.s    .A
  8389.     bsr    findrast
  8390.     tst.w    d1
  8391.     bmi.s    .A
  8392.     moveq    #0,d0
  8393.     move.l    d0,-4(a0)
  8394. .A    move.l    dosbase(a5),a6
  8395.     moveq    #RETURN_OK,d0
  8396.     rts    
  8397.  
  8398. clkalm    move.l    4.w,a6        ;set alarm-time
  8399.     lea    clktask(pc),a1
  8400.     jsr    _LVOFindTask(a6)
  8401.     move.l    dosbase(a5),a6
  8402.     move.l    d0,a4
  8403.     tst.l    d0
  8404.     beq.s    .A
  8405.     tst.l    parm3(a5)
  8406.     bne.s    .B
  8407.     lea    ckalarm(a4),a1
  8408.     bsr    pr_stringlf    show alarm
  8409.     bra.s    .A
  8410. .B    move.l    parm3(a5),a0
  8411.     lea    ckalarm(a4),a1
  8412.     moveq    #7,d0
  8413. .C    move.b    (a0)+,(a1)+    set alarm
  8414.     dbra    d0,.C
  8415. .A    moveq    #RETURN_OK,d0
  8416.     rts    
  8417.  
  8418. clkstart sub.l    a1,a1    ;Here starts the MemClockTaskCode !
  8419.     move.l    4.w,a6
  8420.     jsr    _LVOFindTask(a6)
  8421.     move.l    d0,a5
  8422.     move.l    #$00010100,ckitxt(a5)
  8423. .A    move.l    d5,cknum(a5)    ;teststuff
  8424.     lea    ckdate(a5),a0
  8425.     move.l    a0,d1
  8426.     move.l    ckdos(a5),a6
  8427.     jsr    _LVODateStamp(a6)
  8428.     move.l    ckdate+4(a5),d0        ;mins
  8429.     divu    #60,d0
  8430.     move.w    d0,ckrawdo+8(a5)
  8431.     swap    d0
  8432.     move.w    d0,ckrawdo+10(a5)
  8433.     move.l    ckdate+8(a5),d0        ;secs
  8434.     divu    #50,d0
  8435.     move.w    d0,ckrawdo+12(a5)
  8436.     moveq    #2,d1
  8437.     move.l    4.w,a6
  8438.     jsr    _LVOAvailMem(a6)    ;memory
  8439.     move.l    d0,ckrawdo+4(a5)
  8440.     moveq    #1,d1
  8441.     jsr    _LVOAvailMem(a6)
  8442.     move.l    d0,ckrawdo+0(a5)
  8443.     lea    clkform(pc),a0
  8444.     lea    ckrawdo(a5),a1
  8445.     lea    KPutChar(pc),a2
  8446.     lea    ckcook(a5),a3
  8447.     jsr    _LVORawDoFmt(a6)    ;rawdofmt
  8448.     lea    ckcook+26(a5),a0
  8449.     lea    ckalarm(a5),a1
  8450.     moveq    #7,d0
  8451. .D    move.b    (a0)+,d1
  8452.     cmp.b    (a1)+,d1
  8453.     bne.s    .E
  8454.     dbra    d0,.D
  8455.     move.l    ckint(a5),a6
  8456.     suba.l    a0,a0
  8457.     jsr    _LVODisplayBeep(a6)
  8458. .E    lea    ckcook(a5),a0
  8459.     move.l    a0,ckitxt+12(a5)
  8460.     lea    ckrast(a5),a2
  8461.     moveq    #0,d5
  8462.     moveq    #19,d4
  8463. .B    move.l    (a2)+,a0        ;check all 20 Rastports
  8464.     move.l    a0,d0
  8465.     beq.s    .C
  8466.     addq.l    #1,d5
  8467.     lea    ckitxt(a5),a1
  8468.     moveq    #0,d0
  8469.     moveq    #1,d1
  8470.     move.l    ckint(a5),a6
  8471.     jsr    _LVOPrintIText(a6)
  8472. .C    dbra    d4,.B
  8473.     moveq    #LF,d1
  8474.     move.l    ckdos(a5),a6
  8475.     jsr    _LVODelay(a6)        ;wait 1/5 sec
  8476.     tst.l    d5
  8477.     bne    .A
  8478.     move.l    4.w,a6
  8479.     rts
  8480.  
  8481.  
  8482. *************************
  8483. *    CTRL        *    V2.0
  8484. *************************    set or show ctrl-codes
  8485. ctrlz    move.l    parm2(a5),d0
  8486.     beq.s    .A
  8487.     move.l    d0,a0
  8488.     bsr    return_dash_option
  8489.     cmp.b    #'C',d0        option -COMPLET ?
  8490.     beq.s    ctrlcpl
  8491.     cmp.b    #'R',d0        option -RECOLOR ?
  8492.     beq.s    recolor
  8493.     lea    ctrl_codes(a5),a1
  8494.     moveq    #ctrl_inite-ctrl_init-1,d1
  8495. .B    move.b    (a0)+,d0
  8496.     beq.s    .A
  8497.     and.b    #$3f,d0        set ctrl codes
  8498.     move.b    d0,(a1)+
  8499.     dbra    d1,.B
  8500. .A    lea    ctrl_tx(pc),a1    show ctrl codes
  8501.     bsr    pr_string
  8502.     lea    ctrl_codes(a5),a0
  8503.     lea    tempbuf(a5),a1
  8504.     move.l    a1,a2
  8505.     moveq    #ctrl_inite-ctrl_init-1,d1
  8506. .C    move.b    (a0)+,d0
  8507.     add.b    #$40,d0
  8508.     move.b    d0,(a2)+
  8509.     dbra    d1,.C
  8510.     clr.b    (a2)
  8511.     bsr    pr_stringlf
  8512. ctrlend    moveq    #RETURN_OK,d0
  8513.     rts
  8514.  
  8515. ctrlcpl    lea    ignoreit(a5),a1    set or show exeptions of
  8516.     move.l    parm3(a5),d0    filenamecompletition
  8517.     beq.s    .A
  8518.     move.l    d0,a0
  8519.     moveq    #SEARCH_STRING_SIZE-1,d0
  8520. .B    move.b    (a0)+,(a1)+
  8521.     beq.s    ctrlend
  8522.     dbra    d0,.B
  8523.     bra.s    ctrlend
  8524. .A    bsr    pr_stringlf
  8525.     bra.s    ctrlend
  8526.  
  8527. recolor    move.l    parm3(a5),d0
  8528.     beq    too_less_args
  8529.     move.l    d0,a3
  8530.     lea    start(pc),a0
  8531.     lea    recol1(pc),a1
  8532.     lea    recol2(pc),a2
  8533.     moveq    #0,d2
  8534.     moveq    #(recol2-recol1)/2-1,d0
  8535. .A    move.w    (a1)+,d1
  8536.     move.b    (a2)+,d2
  8537.     move.b    0(a3,d2.w),d3
  8538.     move.b    d3,0(a0,d1.w)
  8539.     dbra    d0,.A
  8540.     bra    clsz
  8541.  
  8542. *************************
  8543. *    Locate        *    V2.0
  8544. ************************* Show the Path and Filename of a Lock-Struct
  8545. locatez            ;or lock object or delete lock
  8546.     bsr    fixpam32
  8547.     move.l    a0,a3
  8548.     move.l    a1,a2
  8549.     move.l    a0,a1    ;parm2
  8550.     moveq    #0,d7
  8551.     bsr    return_dash_option
  8552.     cmp.b    #"C",d0
  8553.     bne.s    .F
  8554.     moveq    #-1,d7        delete lock after showing
  8555.     move.l    a2,a1
  8556. .F    bsr    convert_ASCII_to_num
  8557.     bne.s    .D
  8558.     moveq    #ACCESS_READ,d2
  8559.     move.l    a2,a1    ;parm3    create lock
  8560.     bsr    convert_ASCII_to_num
  8561.     beq.s    .E
  8562.     move.l    d0,d2
  8563. .E    move.l    a3,d1    ;parm2
  8564.     jsr    _LVOLock(a6)
  8565.     tst.l    d0
  8566.     beq    .A
  8567. .D    move.l    d0,a2        write out name
  8568.     move.l    d0,d6
  8569.     add.l    a2,a2
  8570.     add.l    a2,a2
  8571.     moveq    #ACCESS_WRITE,d1
  8572.     cmp.l    fl_Access(a2),d1    what kind of lock
  8573.     bne.s    .B
  8574.     lea    lockwrite(pc),a1
  8575.     bra.s    .C
  8576. .B    subq.l    #1,d1
  8577.     cmp.l    fl_Access(a2),d1
  8578.     bne.s    .A
  8579.     lea    lockread(pc),a1
  8580. .C    lea    -16(sp),sp
  8581.     move.l    a1,(sp)
  8582.     move.l    fl_Link(a2),12(sp)
  8583.     move.l    d6,8(sp)
  8584.     move.l    d0,d1
  8585.     jsr    _LVODupLock(a6)
  8586.     lea    tempbuf(a5),a0
  8587.     move.l    a0,4(sp)
  8588.     bsr    eval_full_path    evaluate the full name
  8589.     jsr    _LVOUnLock(a6)
  8590.     move.l    sp,a1
  8591.     lea    locktext(pc),a0
  8592.     bsr    new_print
  8593.     lea    16(sp),sp
  8594.     tst.l    d7
  8595.     beq.s    .G
  8596.     move.l    d6,d1
  8597.     jsr    _LVOUnLock(a6)
  8598.     lea    deletedtx(pc),a1
  8599.     bsr    pr_string
  8600. .G    moveq    #RETURN_OK,d0
  8601.     rts
  8602. .A    lea    lockntx(pc),a1
  8603.     bsr    pr_stringlf
  8604. lkerr    moveq    #RETURN_ERROR,d0
  8605.     rts
  8606.  
  8607. *************************
  8608. *    NewCLI        *    V2.0
  8609. *************************
  8610. newcliz    lea    ZShellName(pc),a0
  8611.     move.l    a0,d1        process-name
  8612.     moveq    #0,d2        priority
  8613.     lea    start-4(pc),a0
  8614.     move.l    a0,d3        
  8615.     lsr.l    #2,d3        seglist
  8616.     move.l    #4000,d4    stacksize
  8617.     jsr    _LVOCreateProc(a6)
  8618.     tst.l    d0
  8619.     beq.s    lkerr
  8620.     move.l    d0,a4        a4:new process
  8621.     moveq    #$24,d0
  8622.     move.l    #MEMF_CLEAR+1,d1    memory for Message
  8623.     bsr    iwantmem
  8624.     beq.s    lkerr
  8625.     move.l    d0,a1        a1,a3:message
  8626.     move.l    a1,a3
  8627.     move.b    #5,LN_TYPE(a1)
  8628.     move.l    thistask(a5),a0
  8629.     lea    pr_MsgPort(a0),a2    a2:msgport of this task
  8630.     move.l    a2,mn_ReplyPort(a1)
  8631.     move.w    #$24,mn_Length(a1)
  8632.     move.l    pr_CurrentDir(a0),sm_ToolWindow(a1)
  8633.     move.l    a5,sm_NumArgs(a1)
  8634.     move.l    a4,a0
  8635.     move.l    4.w,a6
  8636.     jsr    _LVOPutMsg(a6)
  8637. .A    move.l    a2,a0
  8638.     jsr    _LVOWaitPort(a6)
  8639.     move.l    a2,a0
  8640.     jsr    _LVOGetMsg(a6)
  8641.     cmp.l    a3,d0
  8642.     bne    .A
  8643. ;    move.l    dosbase(a5),a6
  8644.     move.l    d0,a1
  8645.     moveq    #$24,d0
  8646.     bsr    givemem
  8647.     moveq    #RETURN_OK,d0
  8648.     rts
  8649.  
  8650. *************************
  8651. *    RUN        *    V2.2
  8652. *************************
  8653. runz    clr.l    parm3(a5)
  8654.     move.l    parm2(a5),a0
  8655.     bsr    return_dash_option
  8656.     lea    CLIbuf(a5),a1
  8657.     cmp.b    #'C',d0
  8658.     bne.s    .C
  8659.     lea    runnil(pc),a0
  8660.     move.l    a0,parm3(a5)
  8661.     clr.l    parm4(a5)
  8662.     addq.l    #3,a1
  8663. .C    lea    tempbuf(a5),a0
  8664.     move.l    a0,parm2(a5)
  8665.     move.w    #'-c',(a0)+
  8666.     moveq    #0,d1
  8667. .A    move.b    (a1)+,d0
  8668.     cmp.b    #"\",d1
  8669.     bne.s    .D
  8670.     cmp.b    #";",d0
  8671.     bne.s    .D
  8672.     subq.l    #1,a0
  8673. .D    move.b    d0,(a0)+
  8674.     move.b    d0,d1
  8675.     bne.s    .A
  8676.     subq.l    #1,a0
  8677.     lea    runit(pc),a1
  8678. .B    move.b    (a1)+,(a0)+
  8679.     bne.s    .B
  8680.     bra    newcliz
  8681.  
  8682. *************************
  8683. *    TaskPri        *    V2.0
  8684. *************************
  8685. taskpriz bsr    fixpam32
  8686.     move.l    a1,a2
  8687.     move.l    a0,a1
  8688.     tst.b    (a1)
  8689.     beq    too_less_args
  8690.     bsr    convert_ASCII_to_num
  8691.     beq    bad_number_error
  8692.     move.l    d0,d7
  8693.     bsr    findtsk
  8694.     beq.s    tskfail
  8695.     move.l    a0,a1
  8696.     move.b    d7,d0
  8697.     move.l    4.w,a6
  8698.     jsr    _LVOSetTaskPri(a6)
  8699. tskok    move.l    dosbase(a5),a6
  8700.     lea    OK_text(pc),a1
  8701.     bsr    pr_string
  8702.     moveq    #RETURN_OK,d0
  8703.     rts
  8704. tskfail    lea    notasktx(pc),a1
  8705.     bsr    pr_stringlf
  8706. tkfail    moveq    #RETURN_ERROR,d0
  8707.     rts
  8708.  
  8709. * Find Task given in a2 (ptr,string,cli-number,null)
  8710. * RETURN: d0,a0 address (0 if not found)
  8711. findtsk    move.l    a2,a1
  8712.     moveq    #0,d0
  8713.     tst.b    (a1)
  8714.     beq.s    .E
  8715.     bsr    convert_ASCII_to_num
  8716.     beq.s    .C
  8717. .E    cmp.l    #20,d0
  8718.     bhi.s    .A        is address
  8719.     move.l    d0,a1
  8720.     tst.l    d0        0 means own task
  8721.     beq.s    .D
  8722.     lsl.l    #2,d0        is a cli-number
  8723.     move.l    dl_Root(a6),a0
  8724.     move.l    (a0),a0
  8725.     add.l    a0,a0
  8726.     add.l    a0,a0
  8727.     add.l    d0,a0
  8728.     move.l    (a0),d0
  8729.     beq.s    .B
  8730.     sub.l    #pr_MsgPort,d0
  8731.     bra.s    .A
  8732. .C    move.l    a2,a1
  8733. .D    move.l    4.w,a6
  8734.     jsr    _LVOFindTask(a6)    search name
  8735.     move.l    dosbase(a5),a6
  8736. .A    tst.l    d0
  8737.     beq.s    .B
  8738.     move.l    d0,a0
  8739.     cmp.b    #01,LN_TYPE(a0)    is it a TASK-struct ?
  8740.     beq.s    .B
  8741.     cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  8742.     beq.s    .B
  8743.     moveq    #0,d0
  8744. .B    tst.l    d0
  8745.     rts
  8746.  
  8747. *************************
  8748. *    Break        *    V2.0
  8749. *************************
  8750. breakz    bsr    fixpam32
  8751.     move.l    a0,a2
  8752.     move.l    a1,a3
  8753.     tst.b    (a2)
  8754.     beq    too_less_args
  8755.     bsr    findtsk
  8756.     beq.s    tskfail
  8757.     move.l    a3,a1
  8758.     move.l    a0,a2
  8759.     tst.b    (a1)
  8760.     beq.s    .B
  8761.     bsr    convert_ASCII_to_num
  8762.     bne.s    .C
  8763.     move.b    (a3),d1
  8764.     bclr    #5,d1
  8765.     cmp.b    #"C",d1
  8766.     blo    tkfail
  8767.     cmp.b    #"F",d1
  8768.     bhi    tkfail
  8769.     sub.b    #55,d1
  8770.     moveq    #0,d0
  8771.     bset    d1,d0
  8772.     bra.s    .C
  8773. .B    move.l    tc_SigWait(a2),d0
  8774. .C    move.l    a2,a1
  8775.     move.l    4.w,a6
  8776.     jsr    _LVOSignal(a6)    set signals given in mask
  8777.     bra    tskok
  8778.  
  8779. *************************
  8780. *    PutMsg        *    V2.0
  8781. *************************
  8782. putmsgz    move.l    parm2(a5),d7
  8783.     beq    printa5
  8784.     move.l    d7,a1
  8785.     bsr    convert_ASCII_to_num
  8786.     bne.s    .D
  8787.     move.l    d7,a1
  8788.     move.l    4.w,a6
  8789.     jsr    _LVOFindPort(a6)    search name
  8790.     move.l    dosbase(a5),a6
  8791.     tst.l    d0
  8792.     beq.s    .B
  8793.     move.l    d0,a0
  8794.     bra.s    .E
  8795. .D    move.l    d0,a0
  8796.     cmp.l    #20,d0
  8797.     bls.s    .B
  8798.     cmp.b    #04,LN_TYPE(a0)    is it a MSGPORT-struct ?
  8799.     beq.s    .E
  8800. .B    move.l    d7,a2
  8801.     bsr    findtsk        search task
  8802.     bne.s    .C
  8803. .A    lea    noporttx(pc),a1
  8804.     bsr    pr_stringlf
  8805.     moveq    #RETURN_ERROR,d0
  8806.     rts
  8807. .C    cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  8808.     bne.s    .A
  8809.     lea    pr_MsgPort(a0),a0
  8810. .E    bsr    clearArgs
  8811.     move.l    thistask(a5),a2
  8812.     lea    pr_MsgPort(a2),a2
  8813.     move.l    a2,sp_reply(a5)
  8814.     move.b    #5,LN_TYPE+sp_node(a5)
  8815.     lea    parm3(a5),a2
  8816.     lea    sp_link(a5),a3
  8817.     moveq    #mn_Size,d2
  8818. .G    move.l    (a2)+,d3
  8819.     beq.s    .F
  8820.     move.l    d3,a1
  8821.     bsr    convert_ASCII_to_num
  8822.     bne.s    .H
  8823.     move.l    d3,d0
  8824. .H    move.l    d0,(a3)+
  8825.     addq.w    #4,d2
  8826.     bra.s    .G
  8827. .F    move.w    d2,sp_length(a5)
  8828.     move.l    sp_link(a5),a1
  8829.     move.b    (a1),d0
  8830.     cmp.b    ctrl_codes+15(a5),d0
  8831.     bne.s    .I
  8832.     lea    sp_link(a5),a1        for DOSpackets
  8833.     move.l    a1,LN_NAME+sp_node(a5)
  8834.     lea    sp_node(a5),a1
  8835.     move.l    a1,sp_link(a5)
  8836.     move.l    sp_reply(a5),sp_port(a5)
  8837. .I    lea    msendtx(pc),a1
  8838.     bsr    pr_stringlf
  8839.     lea    sp_node(a5),a1        message
  8840.     move.l    4.w,a6
  8841.     jsr    _LVOPutMsg(a6)
  8842.     move.l    dosbase(a5),a6
  8843.     clr.l    parm2(a5)
  8844.     bra.s    getmsg1
  8845.  
  8846. *************************
  8847. *    GetMsg        *    V2.0
  8848. *************************
  8849. getmsgz    moveq    #0,d7
  8850.     moveq    #0,d6
  8851.     move.l    parm2(a5),d2
  8852.     beq.s    getmsg1
  8853.     move.l    d2,a1
  8854.     move.l    4.w,a6
  8855.     jsr    _LVOFindPort(a6)    does it already exist ?
  8856.     tst.l    d0
  8857.     bne.s    getmsg1
  8858.     move.l    thistask(a5),a1
  8859.     lea    pr_MsgPort(a1),a1
  8860.     move.l    d2,LN_NAME(a1)
  8861.     jsr    _LVOAddPort(a6)
  8862.     moveq    #1,d6
  8863. getmsg1    move.l    thistask(a5),a2
  8864.     lea    pr_MsgPort(a2),a2
  8865.     move.l    4.w,a6
  8866.     move.l    a2,a0
  8867.     jsr    _LVOGetMsg(a6)
  8868.     tst.l    d0
  8869.     bne.s    .A
  8870.     moveq    #0,d2
  8871.     move.b    MP_SIGBIT(a2),d1
  8872.     bset    d1,d2
  8873.     bset    #SIGBREAKB_CTRL_C,d2
  8874.     move.l    d2,d1
  8875. ;    moveq    #0,d0
  8876.     jsr    _LVOSetSignal(a6)    clear signals
  8877.     move.l    d2,d0
  8878.     jsr    _LVOWait(a6)    wait for msgport or ctrl-c
  8879.     move.l    a2,a0
  8880.     jsr    _LVOGetMsg(a6)
  8881. .A    move.l    dosbase(a5),a6
  8882.     tst.l    d0
  8883.     beq    msgfail
  8884.     move.l    d0,a2
  8885.     move.w    mn_Length(a2),d2
  8886.     move.w    d2,-(sp)
  8887.     move.l    a2,-(sp)
  8888.     lea    msgtx(pc),a0
  8889.     move.l    sp,a1
  8890.     bsr    new_print
  8891.     addq.l    #6,sp
  8892.     sub.w    #mn_Size,d2
  8893.     lsr.w    #2,d2
  8894.     lea    mn_Size(a2),a3
  8895.     bra.s    .D
  8896. .C    move.l    (a3)+,d0
  8897.     cmp.l    #$dfe000,d0
  8898.     bhs.s    .E
  8899.     cmp.l    #$a00000,d0
  8900.     blo.s    .F
  8901.     cmp.l    #$c00000,d0
  8902.     blo.s    .E
  8903. .F    move.l    d0,a0
  8904.     moveq    #79,d1
  8905. .H    move.b    (a0)+,d3
  8906.     beq.s    .G
  8907.     cmp.b    #" ",d3
  8908.     blo.s    .E
  8909.     cmp.b    #"~",d3
  8910.     bhi.s    .E
  8911.     dbra    d1,.H
  8912.     bra.s    .E
  8913. .G    cmp.w    #76,d1
  8914.     bhs.s    .E
  8915.     bsr    printADR
  8916.     bsr    pr_space
  8917.     move.l    d0,a1
  8918.     bsr    pr_stringlf
  8919.     bra.s    .D
  8920. .E    bsr    printADR
  8921.     bsr    pr_lf
  8922. .D    dbra    d2,.C
  8923.     tst.l    d7
  8924.     bne.s    .B
  8925.     tst.l    d6
  8926.     beq.s    .I
  8927.     move.l    thistask(a5),a1
  8928.     lea    pr_MsgPort(a1),a1
  8929.     move.l    4.w,a6
  8930.     jsr    _LVORemPort(a6)
  8931.     move.l    dosbase(a5),a6
  8932. .I    lea    replytx(pc),a1
  8933.     bsr    pr_string
  8934.     bsr    rask
  8935.     move.l    d0,d2
  8936.     beq.s    .B
  8937.     move.l    4.w,a6
  8938.     move.l    a2,a1
  8939.     jsr    _LVOReplyMsg(a6)
  8940.     move.l    dosbase(a5),a6
  8941.     cmp.b    #RETURN_ERROR,d2
  8942.     beq    getmsg1
  8943. .B    moveq    #RETURN_OK,d0
  8944.     rts
  8945. printa5    move.l    a5,-(sp)
  8946.     move.l    sp,a1
  8947.     lea    pra5tx(pc),a0
  8948.     bsr    new_print
  8949.     addq.l    #4,sp
  8950.     move.l    intuibase(a5),a6
  8951.     suba.l    a0,a0
  8952.     jsr    _LVODisplayBeep(a6)
  8953.     move.l    dosbase(a5),a6
  8954. msgfail    moveq    #RETURN_ERROR,d0
  8955.     rts
  8956.  
  8957. *************************
  8958. *    Border        *    V2.0
  8959. *************************
  8960. wd_BorderLeft    equ    54
  8961. wd_Flags    equ    24
  8962.  
  8963. borderz    move.l    intuibase(a5),a6
  8964.     moveq    #0,d0
  8965.     jsr    _LVOLockIBase(a6)
  8966.     move.l    d0,d7
  8967.     move.l    $34(a6),a4    active window
  8968.     move.l    parm2(a5),a0
  8969.     move.l    a0,d0
  8970.     beq.s    .A
  8971.     move.b    1(a0),d0
  8972.     bset    #5,d0
  8973.     cmp.b    #"n",d0    ;oN
  8974.     beq    bordon
  8975.     cmp.b    #"f",d0    ;oFF
  8976.     beq    bordoff
  8977. .A    bsr    borne
  8978.     bra    help_status
  8979.  
  8980. bordon    tst.l    bordersize(a5)
  8981.     beq.s    borne
  8982.     bclr    #11,wd_Flags+2(a4)    unset noborder
  8983.     move.l    bordersize(a5),wd_BorderLeft(a4)
  8984.     bra.s    borjo
  8985.  
  8986. bordoff    tst.l    wd_BorderLeft(a4)
  8987.     beq.s    borjo
  8988.     bset    #11,wd_Flags+2(a4)    set noborder-window
  8989.     move.l    wd_BorderLeft(a4),bordersize(a5)
  8990.     clr.l    wd_BorderLeft(a4)
  8991. borjo    moveq    #$00,d0        null resize
  8992.     moveq    #$00,d1
  8993.     move.l    a4,a0
  8994.     jsr    _LVOSizeWindow(a6)
  8995.     move.l    a4,a0
  8996.     jsr    _LVORefreshWindowFrame(a6)    redraw
  8997. borne    move.l    d7,a0
  8998.     jsr    _LVOUnlockIBase(a6)
  8999.     move.l    parm3(a5),d0
  9000.     beq.s    nosiz
  9001.     move.l    d0,a1
  9002.     bsr    convert_ASCII_to_num
  9003.     tst.l    d1
  9004.     beq.s    nosiz
  9005.                 ;resize window to fill screen
  9006.     move.l    $2e(a4),a1    points to screen
  9007.     move.l    d0,d4    width of menubar
  9008.     bpl.s    .A
  9009.     moveq    #0,d4
  9010.     move.b    30(a1),d4
  9011.     add.b    31(a1),d4
  9012. .A    moveq    #-1,d2
  9013.     move.l    12(a1),d3
  9014.     sub.w    10(a4),d3
  9015.     sub.w    d4,d3
  9016.     move.w    d3,d1
  9017.     bpl.s    bklein
  9018.     moveq    #0,d2
  9019.     moveq    #0,d0
  9020.     move.l    a4,a0
  9021.     jsr    _LVOSizeWindow(a6)
  9022. bklein    moveq    #0,d0
  9023.     sub.w    4(a4),d0
  9024.     move.l    d4,d1
  9025.     sub.w    6(a4),d1
  9026.     move.l    a4,a0
  9027.     jsr    _LVOMoveWindow(a6)
  9028.     moveq    #0,d1
  9029.     tst.b    d2
  9030.     beq.s    bgross
  9031.     move.w    d3,d1
  9032. bgross    swap    d3
  9033.     sub.w    8(a4),d3
  9034.     move.w    d3,d0
  9035.     move.l    a4,a0
  9036.     jsr    _LVOSizeWindow(a6)
  9037.     jsr    _LVORethinkDisplay(a6)
  9038.     
  9039. nosiz    move.l    dosbase(a5),a6
  9040.     moveq    #LF,d1        wait more than 1/10 sec
  9041.     jsr    _LVODelay(a6)
  9042.     moveq    #RETURN_OK,d0
  9043.     rts
  9044.  
  9045. *************************
  9046. *    Review        *    V2.0
  9047. *************************
  9048. reviewz    move.l    parm2(a5),d0
  9049.     beq.s    ShowReview
  9050.     move.l    d0,a1
  9051.     move.l    d0,a2
  9052.     bsr    convert_ASCII_to_num
  9053.     bne.s    MakeReview
  9054.     or.b    #$20,(a2)        Save review-buffer ?
  9055.     cmp.b    #"s",(a2)
  9056.     bne.s    ShowReview
  9057.     move.l    parm3(a5),d0
  9058.     beq    too_less_args
  9059.     tst    ReviewSize(a5)
  9060.     beq.s    ShowReview
  9061.     move.l    d0,a3
  9062.     bra    viewbuffer
  9063.  
  9064. ShowReview
  9065.     move.l    ReviewMem(a5),d0    Show review-info
  9066.     bsr    printADR
  9067.     move.l    ReviewSize(a5),d0
  9068.     bsr    print10
  9069.     lea    view1_tx(pc),a1
  9070.     bsr    pr_string
  9071.     bra    reviewOK
  9072.  
  9073. MakeReview
  9074.     tst.l    d0            Add review-buffer
  9075.     beq    reviewend
  9076.     tst.l    ReviewSize(a5)
  9077.     beq.s    .F
  9078.     move.l    d0,-(sp)
  9079.     bsr    reviewend
  9080.     move.l    (sp)+,d0
  9081. .F    move.l    d0,d2
  9082.     moveq    #1,d1
  9083.     bsr    iwantmem
  9084.     beq    ShowReview
  9085.     move.l    d0,ReviewMem(a5)
  9086.     move.l    d2,ReviewSize(a5)
  9087.     move.l    d0,a0
  9088.     move.l    d2,d1
  9089.     swap    d1
  9090.     bra.s    .D
  9091. .E    move.b    #" ",(a0)+    Fill with spaces
  9092. .D    dbra    d2,.E
  9093.     dbra    d1,.E
  9094.     move.b    #LF,-1(a0)    Last char is LF
  9095.     clr.l    ReviewPtr(a5)
  9096.     clr.b    noreview_flag(a5)
  9097.     lea    RHa3(pc),a3        Look for a5-Table
  9098.     tst.l    (a3)
  9099.     bne.s    entryA5
  9100.     moveq    #80,d0
  9101.     move.l    #1+1<<16,d1        "memf_public" & clear it
  9102.     bsr    iwantmem
  9103.     beq    reviewend
  9104.     move.l    d0,(a3)
  9105. APatch    moveq    #_LVOWrite,d2        Add review-patch to DOS Write
  9106.     move.w    #$4ef9,d3
  9107.     move.l    a6,a2
  9108.     add.l    d2,a2
  9109.     moveq    #0,d1
  9110.     cmp.w    (a2),d3
  9111.     bne.s    .B
  9112.     move.l    2(a2),a0
  9113.     lea    RCode(pc),a1
  9114.     cmp.l    a1,a0
  9115.     beq.s    entryA5
  9116.     moveq    #-1,d1
  9117.     bra.s    .C
  9118. .B    cmp.w    #$6000,2(a2)
  9119.     bne.s    reviewend
  9120. .C    movem.l    d0-d1/a0-a1,-(sp)
  9121.     bsr    do_forbid
  9122.     movem.l    (sp)+,d0-d1/a0-a1
  9123.     lea    RHa1(pc),a1
  9124.     move.w    (a2),(a1)
  9125.     move.l    2(a2),2(a1)
  9126.     tst.w    d1
  9127.     bne.s    .D
  9128.     lea    4(a2),a0
  9129.     move.w    (a0),d0
  9130.     ext.l    d0
  9131.     add.l    d0,a0
  9132.     move.l    a0,4(a1)
  9133.     move.w    d3,2(a1)
  9134. .D    lea    RCode(pc),a0
  9135.     move.w    d3,(a2)
  9136.     move.l    a0,2(a2)
  9137.     bsr    do_permit
  9138. entryA5    move.l    (a3),a3            Add a5-table entry
  9139.     moveq    #20-1,d0
  9140. .F    tst.l    (a3)+
  9141.     beq.s    .G
  9142.     dbra    d0,.F
  9143.     bra    reviewend
  9144. .G    move.l    a5,-4(a3)
  9145.     bra    reviewOK
  9146.  
  9147. reviewend        ;Remove review-buffer
  9148.     move.l    RHa3(pc),d0        Remove a5-table entry
  9149.     beq.s    remmem2
  9150.     move.l    d0,a0
  9151.     move.l    a0,a1
  9152.     move.l    a0,a2
  9153.     moveq    #20-1,d0
  9154. .A    cmp.l    (a0)+,a5
  9155.     beq.s    .B
  9156.     dbra    d0,.A
  9157.     bra.s    .D
  9158. .B    clr.l    -4(a0)
  9159. .D    moveq    #20-1,d0    look for other entries
  9160. .C    tst.l    (a2)+
  9161.     bne.s    remmem2
  9162.     dbra    d0,.C
  9163.     bsr    do_forbid
  9164.     lea    RHa3(pc),a0
  9165.     clr.l    (a0)
  9166.     moveq    #80,d0        last entry
  9167.     bsr    givemem
  9168.     moveq    #_LVOWrite,d0        Remove DOS Write Patch
  9169.     move.l    a6,a3
  9170.     add.l    d0,a3
  9171.     move.l    2(a3),a0
  9172.     lea    RCode(pc),a1
  9173.     cmp.l    a0,a1
  9174.     bne.s    remmem
  9175.     lea    RHa1(pc),a1
  9176.     move.w    (a1),(a3)
  9177.     move.l    2(a1),2(a3)
  9178.     cmp.w    #$4ef9,(a1)
  9179.     beq.s    remmem
  9180.     move.w    #$6000,2(a3)
  9181.     lea    4(a3),a2
  9182.     move.l    4(a1),d0
  9183.     sub.l    a2,d0
  9184.     move.w    d0,(a2)
  9185. remmem    bsr    do_permit
  9186. remmem2    move.l    ReviewSize(a5),d0    Remove buffer-memory
  9187.     beq.s    reviewOK
  9188.     move.l    ReviewMem(a5),a1
  9189.     bsr    givemem
  9190.     clr.l    ReviewSize(a5)
  9191. reviewOK
  9192.     moveq    #RETURN_OK,d0
  9193.     rts
  9194.  
  9195. viewbuffer        ;Show the review-buffer using more
  9196.     move.l    ReviewMem(a5),a2
  9197.     move.l    ReviewPtr(a5),d3
  9198.     move.l    ReviewSize(a5),d2
  9199. viewhist    ;;Show a circular buffer using more
  9200.     move.l    d2,d4
  9201.     moveq    #0,d1
  9202.     move.b    #LF,0(a2,d3.l)
  9203.     addq.l    #1,d3
  9204.     cmp.l    d3,d2
  9205.     bhi.s    .A
  9206.     clr.l    d3
  9207. .A    move.b    0(a2,d3.l),d0
  9208.     addq.l    #1,d3
  9209.     cmp.l    d3,d2
  9210.     bhi.s    .B
  9211.     clr.l    d3
  9212. .B    addq.l    #1,d1
  9213.     cmp.b    #LF,d0
  9214.     beq.s    .C
  9215.     cmp.b    #12,d0
  9216.     bne.s    .A
  9217. .C    sub.l    d1,d2
  9218.     move.l    d2,d0
  9219.     beq.s    reviewOK
  9220.     moveq    #1,d1
  9221.     bsr    iwantmem
  9222.     beq.s    reviewOK
  9223.     move.l    d0,a0
  9224.     move.l    a0,a1
  9225.     move.l    d4,d1
  9226.     move.l    d2,d4
  9227.     bra.s    .E
  9228. .D    move.b    0(a2,d3.l),d0
  9229.     cmp.b    #12,d0
  9230.     bne.s    .G
  9231.     move.b    #LF,d0
  9232. .G    cmp.b    #"c",d0
  9233.     bne.s    .H
  9234.     cmp.b    #27,-1(a0)
  9235.     bne.s    .H
  9236.     move.b    #" ",-1(a0)
  9237.     move.b    #LF,d0
  9238. .H    move.b    d0,(a0)+
  9239.     addq.l    #1,d3
  9240.     cmp.l    d3,d1
  9241.     bhi.s    .E
  9242.     clr.l    d3
  9243. .E    dbra    d2,.D
  9244.     move.l    a3,d0
  9245.     bne.s    viewwrite
  9246.     move.l    a1,d0
  9247.     move.l    d4,d1
  9248.     moveq    #-1,d2
  9249.     bra    ViewMore
  9250. viewwrite        ;write buffer to file
  9251.     move.l    a1,a2
  9252.     move.l    a3,d1
  9253.     move.l    #MODE_NEWFILE,d2
  9254.     jsr    _LVOOpen(a6)
  9255.     tst.l    d0
  9256.     beq.s    .A
  9257.     move.l    d0,a3
  9258.     move.l    a3,d1
  9259.     move.l    a2,d2
  9260.     move.l    d4,d3
  9261.     move.l    d3,-(sp)
  9262.     jsr    _LVOWrite(a6)
  9263.     move.l    (sp)+,d3
  9264.     sub.l    d0,d3
  9265.     move.l    a3,d1
  9266.     jsr    _LVOClose(a6)
  9267.     moveq    #1,d0
  9268.     tst.l    d3
  9269.     beq.s    .A
  9270.     moveq    #0,d0
  9271. .A    move.l    d0,d2
  9272.     move.l    d4,d0
  9273.     move.l    a2,a1
  9274.     bsr    givemem
  9275.     tst.l    d2
  9276.     beq    DOSerr
  9277.     bra    reviewOK
  9278.  
  9279.     
  9280.  
  9281. *****    ReviewHandler    ********
  9282. RHa1    dc.w    $4ef9    JMP
  9283. RHa2    dcb.w    3    Return-Code
  9284. RHa3    dcb.l    1    Memory-Base-Table
  9285.  
  9286. RCode    movem.l    d0-d3/a5-a6,-(sp)    ;Is called by the DOS Write fkt.
  9287.     move.l    RHa3(pc),d0
  9288.     beq.s    .C
  9289.     move.l    d0,a0
  9290.     moveq    #20-1,d0
  9291. .B    move.l    (a0)+,a5
  9292.     cmp.l    outhandle(a5),d1
  9293.     beq.s    .A
  9294.     dbra    d0,.B
  9295.     bra.s    .C
  9296. .A    tst.b    noreview_flag(a5)
  9297.     bne.s    .C
  9298.     bsr    toreview
  9299. .C    movem.l    (sp)+,d0-d3/a5-a6
  9300.     bra.s    RHa1
  9301.  
  9302. toreview    ;Writes data to review-buffer,Entry: d2=Adress, d3=Length
  9303.     move.l    d2,a0
  9304.     move.l    ReviewMem(a5),a1
  9305.     move.l    ReviewPtr(a5),d1
  9306.     move.l    ReviewSize(a5),d2
  9307.     beq.s    .C
  9308.     bra.s    .B
  9309. .A    move.b    (a0)+,d0
  9310.     move.b    d0,0(a1,d1.l)
  9311.     addq.l    #1,d1
  9312.     cmp.l    d1,d2
  9313.     bhi.s    .B
  9314.     clr.l    d1
  9315. .B    dbra    d3,.A
  9316.     move.l    d1,ReviewPtr(a5)
  9317. .C    rts
  9318.  
  9319.  
  9320. recol1    dc.w    residetx+2-start,assign_tx+3-start,volume_tx+2-start
  9321.     dc.w    device_tx+3-start,breaktx+3-start,locktext+13-start
  9322.     dc.w    show_tx+2-start,show2_tx+2-start,shta_tx+2-start
  9323.     dc.w    proform+4-start,inform_tx+2-start,inform+24-start
  9324.     dc.w    inform2+15-start,stat_text+2-start,totsize+2-start
  9325.     dc.w    dirof+2-start,errsiz+2-start,errnum+2-start
  9326.     dc.w    farb2+2-start,farb3+2-start,doserrtx+2-start
  9327. recol2    ;Recolour-table to switch globally to one colour
  9328.     dc.b    2,2,2,2,6,3,2,2,2,3,2,7,5,7,7,6,2,2,2,3,6
  9329.  
  9330.  
  9331. doserror_text        ;V2.0:extended
  9332.     dc.b    103,'NO FREE STORE',0
  9333.     dc.b    105,'TASK TABLE FULL',0
  9334.     dc.b    114,'BAD TEMPLATE',0
  9335.     dc.b    115,'BAD NUMBER',0
  9336.     dc.b    116,'REQUIRED ARG MISSING',0
  9337.     dc.b    117,'KEY NEEDS ARG',0
  9338.     dc.b    118,'TOO MANY ARGS',0
  9339.     dc.b    119,'UNMATCHED QUOTES',0
  9340.     dc.b    120,'LINE TOO LONG',0
  9341.     dc.b    121,'FILE NOT OBJECT',0
  9342.     dc.b    122,'INVALID RESIDENT LIB',0
  9343.     dc.b    201,'NO DEFAULT DIR',0
  9344.     dc.b    202,'OBJECT IN USE',0
  9345.     dc.b    203,'OBJECT EXISTS',0
  9346.     dc.b    204,'DIR NOT FOUND',0
  9347.     dc.b    205,'OBJECT NOT FOUND',0
  9348.     dc.b    206,'BAD STREAM NAME',0
  9349.     dc.b    207,'OBJECT TOO LARGE',0
  9350.     dc.b    209,'ACTION NOT KNOWN',0
  9351.     dc.b    210,'INVALID COMPONENT NAME',0
  9352.     dc.b    211,'INVALID LOCK',0
  9353.     dc.b    212,'OBJECT WRONG TYPE',0
  9354.     dc.b    213,'DISK NOT VALIDATED',0
  9355.     dc.b    214,'DISK WRITE PROTECTED',0
  9356.     dc.b    215,'RENAME ACROSS DEVICES',0  
  9357.     dc.b    216,'DIRECTORY NOT EMPTY',0
  9358.     dc.b    217,'TOO MANY LEVELS',0
  9359.     dc.b    218,'DEVICE NOT MOUNTED',0
  9360.     dc.b    219,'SEEK ERROR',0
  9361.     dc.b    220,'COMMENT TOO BIG',0
  9362.     dc.b    221,'DISK FULL',0
  9363.     dc.b    222,'DELETE PROTECTED',0
  9364.     dc.b    223,'WRITE PROTECTED',0
  9365.     dc.b    224,'READ PROTECTED',0
  9366.     dc.b    225,'NOT A DOS DISK',0
  9367.     dc.b    226,'NO  DISK',0
  9368.     dc.b    232,'NO MORE ENTRIES',0
  9369.     dc.b    233,'IS SOFT LINK',0
  9370.     dc.b    234,'OBJECT LINKED',0
  9371.     dc.b    235,'BAD HUNK',0
  9372.     dc.b    236,'NOT IMPLEMENTED',0
  9373.     dc.b    240,'RECORD NOT LOCKED',0
  9374.     dc.b    241,'LOCK COLLOSION',0
  9375.     dc.b    242,'LOCK TIMEOUT',0
  9376.     dc.b    243,'UNLOCK ERROR',0
  9377.     dc.b    47,'BUFFER OVERFLOW',0        303
  9378.     dc.b    48,'BREAK',0            304
  9379.     dc.b    49,'NOT EXECUTABLE',0        305
  9380.     dc.b    0
  9381.  
  9382. ZShellName    dc.b    'ZShell',0
  9383. dosname        dc.b    'dos.library',0
  9384. intuiname    dc.b    'intuition.library',0
  9385. iconname    dc.b    'icon.library',0
  9386. timdev        dc.b    'timer.device',0
  9387. conname        dc.b    'CON:0/10/640/190/ZShell V2.2/CLOSE',0
  9388. cone        dc.b    '*',0
  9389. sysdisk        dc.b    'SYS:',0
  9390. wintool        dc.b    'WINDOW',0
  9391. scripttool    dc.b    'SCRIPT',0
  9392. clktask        dc.b    'MemClock',0
  9393. clkform        dc.b    ' Mem:%7ld Chip:%6ld  %02d:%02d:%02d ',0
  9394. clkuse        dc.b    'Use ON, OFF or ALARM',0
  9395. chkuse        dc.b    'Use ON or OFF',0
  9396. useit        dc.b    'Usage: ZShell [-Wwindow] [-Sscript]'
  9397.         dc.b    ' [-Ccommand] [-R] [-D]',0
  9398. runit        dc.b    ';ask Press RETURN;endcli',0
  9399. runnil        dc.b    '-w',0
  9400. bad_number_tx    dc.b    'Cannot understand number',0
  9401. less_args_tx    dc.b    'Not enough arguments',0
  9402. goto_error_tx    dc.b    'GOTO statement error',10,0
  9403. if_error_tx    dc.b    'IF statement error',10,0
  9404. warn_tx        dc.b    'warn',0
  9405. error_tx    dc.b    'error',0
  9406. fail_tx        dc.b    'fail',0
  9407. not_tx        dc.b    'not',0
  9408. exists_tx    dc.b    'exists',0
  9409. view1_tx    dc.b    ' Bytes',10,0
  9410. bad_prot_bits_tx    dc.b    'Unknown protection bit',10,0
  9411. no_colon_tx    dc.b    'Name MUST end in :',10,0
  9412. residetx    dc.b    $9b,'32mUsecount  Adress Name',$9b,'m',0
  9413. resi_no_mem_tx    dc.b    'Not enough memory',0
  9414. resi_inuse_tx    dc.b    'Resident is used',0
  9415. rpn_result_tx    dc.b    'RESULT: Dec %ld  Hex $%08lx',10,0
  9416. rpn_res2    dc.b    '%ld',0
  9417. failat_tx    dc.b    'Failat: %d',10,0
  9418. defscript    dc.b    'S:ZStart',0    ;changed V2.0
  9419. rexxtx        dc.b    'REXX:RX',0
  9420. unmounted_tx    dc.b    '[UnMounted]',10,0
  9421. mounted_tx    dc.b    '[Mounted]',0
  9422. assign_tx    dc.b    10,$9b,'32mAssigns:',$9b,'m',10,0
  9423. volume_tx    dc.b    $9b,'32mVolumes:',$9b,'m',10,0
  9424. device_tx    dc.b    10,$9b,'32mDevices:',$9b,'m',10,0
  9425. bad_unset_tx    dc.b    ' could not be unset!',10,0
  9426. breaktx        dc.b    10,$9b,'36m*** BREAK ***',$9b,'m',10,0
  9427. prompt_args_tx    dc.b    4,'%s> ',0
  9428. stk_too_small_tx    dc.b    'Too Small',10,0
  9429. stk_too_big_tx    dc.b    'Too Big',10,0
  9430. stk_size_tx    dc.b    'Current Stack: %ld bytes',10,0
  9431. stack_tx    dc.b    'Stack overflow',0
  9432. lockntx        dc.b    'Give LOCK-BPTR or NAME',0
  9433. lockread    dc.b    'READ',0
  9434. lockwrite    dc.b    'WRITE',0
  9435. locktext    dc.b    '%s-Lock on ',$9b,'33m%s',$9b,'m'
  9436.         dc.b    10,'This Lock: $%06lx  Next: $%06lx',10,0
  9437. clk_tx        dc.b    'Use LOAD or SAVE',0
  9438. noclk_tx    dc.b    'No Clock found',0
  9439. muell_tx    dc.b    'Format: DD.MM.YY or MM-DD-YY or HH:MM:SS',0
  9440. styp        dc.b    'lrdimps'
  9441. shuse_tx    dc.b    'Use D,I,L,M,P,R,S or T',0
  9442. show_tx        dc.b    $9b,'32mAdress Pri Name',$9b,'m',0
  9443. show2_tx    dc.b    $9b,'32mAdress Pri Ver Rev Name',$9b,'m',0
  9444. shform        dc.b    '%06lx%4d %s',10,0
  9445. shform2        dc.b    '%06lx%4d%4d%4d %s',10,0
  9446. shta_tx        dc.b    $9b,'32mAdress Pri State SignWait PT '
  9447.         dc.b    'Name',$9b,'m',0
  9448. shtaform    dc.b    '%06lx%4d %-5s %08lx %c%c %s',0
  9449. proform        dc.b    32,9,$9b,'33m->CLI %ld:',$9b,'m %s',0
  9450. ttyp        dc.b    "Inval",0,"Added",0,"Run",0,"Ready",0
  9451.         dc.b    "Wait",0,"Exept",0,"Remov",0
  9452. inform_tx    dc.b    $9b,'32mName Unit Sys    Size    Free Full Block'
  9453.         dc.b    '   Status   Err  Volume',$9b,'m',0
  9454. inform        dc.b    '%-7s%2ld %3s%7ldK%7ldK',$9b,'37m%4ld%%',$9b
  9455.         dc.b    'm%6ld %-10s%3ld   %s',10,0
  9456. inform2        dc.b    '%-7s%2ld     ',$9b,'35m%s',$9b,'m',10,0
  9457. statro        dc.b    "Read only",0
  9458. statrw        dc.b    "Read/Write",0
  9459. statval        dc.b    "Validating",0
  9460. statun        dc.b    "Unknown",0
  9461. nodisk        dc.b    "No Disk present",0
  9462. baddisk        dc.b    "Unreadable Disk",0
  9463. nodos        dc.b    "Not a DOS-Disk",0
  9464. kickdisk    dc.b    "Kickstart-Disk",0
  9465. ofs_tx        dc.b    "OFS",0    OldFilesystem
  9466.         dc.b    "FFS",0    FastFilesystem
  9467.         dc.b    "OIN",0    International OFS
  9468.         dc.b    "FIN",0    International FFS
  9469.         dc.b    "ODC",0    Dir Cache OFS
  9470.         dc.b    "FDC",0 Dir Cache FFS
  9471. msd_tx        dc.b    "MSD",0    MessyDOS
  9472. quest_tx    dc.b    "???",0    Unknown
  9473. OK_text        dc.b    "OK.",10,0
  9474. notasktx    dc.b    "Task not found",0
  9475. noporttx    dc.b    "Port not found",0
  9476. msendtx        dc.b    "send",0
  9477. pra5tx        dc.b    "A5=%06lx",10,0
  9478. msgtx        dc.b    "Message=%06lx  Length=%d",10,0
  9479. time_text    dc.b    "Date: %02d.%02d.%02d    "
  9480.         dc.b    "Time: %02d:%02d:%02d.%02d",10,0
  9481. stat_text    dc.b    $9b,"37mResult2=%ld  Time=%02d:%02d:%02d.%02d"
  9482.         dc.b    "  Changes-> Chip:%ld  Fast:%ld  Total:%ld"
  9483.         dc.b    $9b,"m",10,0
  9484. failertx    dc.b    $9b,"1mFail-Level: %ld",$9b,"m",10,0
  9485. replytx        dc.b    "Reply? ",0
  9486. mem_line    dc.b    "%08lx: %08lx %08lx %08lx %08lx   '%s'",10,0
  9487. vec_line    dc.b    "WarmCapture  $%06lx",10,"CoolCapture  $%06lx",10
  9488.         dc.b    "ColdCapture  $%06lx",10,"KickTagPtr   $%06lx",10
  9489.         dc.b    "KickMemPtr   $%06lx",10,"KickCheckSum $%06lx",10,0
  9490. format        dc.b    '%8ld',0    ;print a longw right justified
  9491. formatADR    dc.b    '$%06lx',0    ;print address 
  9492. totsize        dc.b    $9b,'37mTotal Bytes: %ld   Files: %ld   '
  9493.         dc.b    'Dirs: %ld',$9b,'m',10,0
  9494. dirtext        dc.b    '(Dir)',$9b,'m',0
  9495. cderrtx        dc.b    'Where ?',10,0
  9496. dirof        dc.b    $9b,'36mDirectory of -> ',$9b,'m',0
  9497. defpath1    dc.b    'RAM:',0
  9498.         dc.b    'C:',0
  9499.         dc.b    'SYS:',0
  9500.         dc.b    'DF0:',0
  9501.         dc.b    's:',0
  9502.         dc.b    0
  9503. pcurrent    dc.b    'Current',0
  9504. helpload    dc.b    'Loading ZShell.doc ...',10,0
  9505. msearch        dc.b    12,$9b,'BSearch: ',$9b," p",0
  9506. prtdev        dc.b    'PRT:',0
  9507. prtit        dc.b    12,$9b,'BPrinting',0
  9508. badcomm        dc.b    'Command not found',10,0
  9509. copyOK        dc.b    ' ...copied',10,0
  9510. deletedtx    dc.b    ' ...deleted',0
  9511. memess        dc.b    "Chip: %ld   Fast: %ld   Total Free: %ld",10,0
  9512. resask        dc.b    'Really RESET ? ',0
  9513. append        dc.b    '.rcy',0
  9514. errsiz        dc.b    $9b,'32m Size:',$9b,'m',0
  9515. errnum        dc.b    $9b,'33m ERROR',$9b,'m',0
  9516. prok        dc.b    '  OK',0
  9517. farb1        dc.b    $9b,'m',0
  9518. farb2        dc.b    $9b,'32m',0
  9519. farb3        dc.b    $9b,'33m',0
  9520. lf        dc.b    10,0
  9521. tab        dc.b    9,0
  9522. backspace_it    dc.b    8        DON'T SEPERATE
  9523. delete_it    dc.b    $9b,'P',0        THESE LINES
  9524. return_it    dc.b    13,10,0
  9525. right_cursor    dc.b    $9b,'C',0
  9526. left_cursor    dc.b    $9b,'D',0
  9527. delete_line    dc.b    13,$9b,'M',0
  9528. delete_line2    dc.b    $9b,'M',13,0
  9529. backslash    dc.b    '/',0
  9530. help_ret    dc.b    'help^M',0
  9531. clstx        dc.b    27,"c",0    reset console
  9532. clrtx        dc.b    12,0    clear screen
  9533. scroll_up_tx    dc.b    $9b,"S",13,0
  9534. scroll_down_tx    dc.b    $9b,"M",$9b,"T",$9b,"1H",0
  9535. clrhide        dc.b    12
  9536. hide_cursor    dc.b    $9b,"0 p",0
  9537. show_cursor    dc.b    $9b," p",0
  9538.  
  9539. umlaut        dc.b    'äÄöÖüÜߧ£'
  9540. umlautend
  9541. ctrl_tx    dc.b    'Actual CTRL-Codes: ',0
  9542. ctrl_init dc.b    23,17,19,5,9,24,27,20,25,8,10,13,12,18,22,46 CTRL-Codes
  9543. ctrl_inite
  9544. doserrtx    dc.b    $9b,'36mERROR:',$9b,'m'    ;DON'T SEPERATE
  9545. space    dc.b    ' '
  9546. null    dc.b    0        ;THESE 3 LINES
  9547.  
  9548. helpman    dc.b    "ZShell.Doc",0
  9549. help_tx1 dc.b    '$VER: ZShell V2.2 (02.01.95)',10
  9550.     dc.b    "(C)1990,91 Paul Hayter (V1.3); "
  9551.     dc.b    "Updated 1993/94 to V2.2 by Martin Gierich.",10
  9552.     dc.b    "Freeware, NO commercial usage !",10
  9553.     dc.b    "Please send your comments to"
  9554.     dc.b    " uj3w@ibm3090.rz.uni-karlsruhe.de",10,10
  9555.     dc.b    "Commands:",0
  9556. help_tx2 dc.b    10,"Options:",10
  9557.     dc.b    "-r/-RECURSIVE (copy,delete,dir,list,recopy,ctrl)",10
  9558.     dc.b    "-c/-CLEAR (avail,ctrl,endcli,locate,path,resident,run)",10
  9559.     dc.b    "-q/-QUICK (dir,list)",10,0
  9560. help_tx3 dc.b    10,"Wildcards: * ? ~ [] |",10
  9561.     dc.b    "Editing: (SHIFT+) Cursor, <-, DEL,"
  9562.     dc.b    " (SHIFT+) TAB, ESC and see ctrl",10
  9563.     dc.b    ". for dir back, force disk or abbreviation",10
  9564.     dc.b    "Type 'help ?' for more help.",0
  9565.  
  9566. *********************************************
  9567.  
  9568. comtext    dc.b    'addbuffers',0    V1.27
  9569.     dc.b    'alias',0
  9570.     dc.b    'ask',0        V1.28
  9571.     dc.b    'assign',0
  9572.     dc.b    'avail',0
  9573.     dc.b    'border',0    V2.0
  9574.     dc.b    'break',0    V2.0
  9575.     dc.b    'cd',0
  9576.     dc.b    'check',0
  9577.     dc.b    'cls',0        V2.0
  9578.     dc.b    'copy',0
  9579.     dc.b    'ctrl',0    V2.0
  9580.     dc.b    'date',0
  9581.     dc.b    'diskchange',0    V2.0
  9582.     dc.b    'delete',0
  9583.     dc.b    'die',0        V2.0
  9584.     dc.b    'dir',0
  9585.     dc.b    'echo',0
  9586. else_tx    dc.b    'else',0    V1.28
  9587.     dc.b    'endcli',0
  9588. endif_tx dc.b    'endif',0    V1.28
  9589.     dc.b    'eval',0
  9590.     dc.b    'execute',0
  9591.     dc.b    'failat',0
  9592.     dc.b    'fault',0    V2.0
  9593.     dc.b    'filenote',0    V2.0
  9594.     dc.b    'getmsg',0    V2.0
  9595.     dc.b    'help',0
  9596.     dc.b    'htype',0    V1.29
  9597.     dc.b    'if',0        V1.28
  9598.     dc.b    'info',0
  9599.     dc.b    'join',0    V1.29
  9600. label_tx dc.b    'lab',0        V1.29
  9601.     dc.b    'list',0
  9602.     dc.b    'locate',0    V2.0
  9603.     dc.b    'lock',0    V2.0
  9604.     dc.b    'm',0
  9605.     dc.b    'makedir',0
  9606.     dc.b    'memclk',0    V2.0
  9607.     dc.b    'more',0    V1.23
  9608.     dc.b    'newcli',0    V2.0
  9609.     dc.b    'path',0
  9610.     dc.b    'prompt',0
  9611.     dc.b    'protect',0
  9612.     dc.b    'putmsg',0    V2.0
  9613.     dc.b    'quit',0    V1.29
  9614.     dc.b    'recopy',0    V2.0
  9615.     dc.b    'relabel',0    V1.27
  9616.     dc.b    'rename',0
  9617.     dc.b    'reset',0
  9618.     dc.b    'resident',0    V1.25
  9619.     dc.b    'review',0    V2.1
  9620.     dc.b    'run',0        V2.2
  9621.     dc.b    'search',0    V2.0
  9622.     dc.b    'setclock',0    V2.0
  9623.     dc.b    'setdate',0    V2.0
  9624.     dc.b    'show',0    V2.0
  9625.     dc.b    'skip',0
  9626.     dc.b    'stack',0
  9627.     dc.b    'strings',0    V1.29
  9628.     dc.b    'taskpri',0    V2.0
  9629.     dc.b    'type',0
  9630.     dc.b    'unalias',0
  9631.     dc.b    'vec',0
  9632.     dc.b    'wait',0
  9633.     dc.b    0
  9634.     
  9635.     
  9636.     cnop    0,2
  9637. comoffs
  9638.     dc.w    addbuffersz-start
  9639.     dc.w    set_funcz-start    ;alias
  9640.     dc.w    askz-start
  9641.     dc.w    assignz-start
  9642.     dc.w    availz-start
  9643.     dc.w    borderz-start
  9644.     dc.w    breakz-start
  9645.     dc.w    cdz-start
  9646.     dc.w    checkz-start
  9647.     dc.w    clsz-start
  9648.     dc.w    copyz-start
  9649.     dc.w    ctrlz-start
  9650.     dc.w    datez-start
  9651.     dc.w    diskchangez-start
  9652.     dc.w    deletez-start
  9653.     dc.w    diez-start
  9654.     dc.w    dirz-start
  9655.     dc.w    echoz-start
  9656.     dc.w    elsez-start
  9657.     dc.w    endcliz-start
  9658.     dc.w    endifz-start
  9659.     dc.w    evalz-start
  9660.     dc.w    executez-start
  9661.     dc.w    failatz-start
  9662.     dc.w    faultz-start
  9663.     dc.w    filenotez-start
  9664.     dc.w    getmsgz-start
  9665.     dc.w    helpz-start
  9666.     dc.w    htypez-start
  9667.     dc.w    ifz-start
  9668.     dc.w    infoz-start
  9669.     dc.w    joinz-start
  9670.     dc.w    labelz-start    ;lab
  9671.     dc.w    listz-start
  9672.     dc.w    locatez-start
  9673.     dc.w    lockz-start
  9674.     dc.w    memexamz-start    ;m
  9675.     dc.w    makedirz-start
  9676.     dc.w    memclkz-start
  9677.     dc.w    morez-start
  9678.     dc.w    newcliz-start
  9679.     dc.w    pathz-start
  9680.     dc.w    promptz-start
  9681.     dc.w    protectz-start
  9682.     dc.w    putmsgz-start
  9683.     dc.w    quitz-start
  9684.     dc.w    recopyz-start
  9685.     dc.w    relabelz-start
  9686.     dc.w    renamez-start
  9687.     dc.w    resetz-start
  9688.     dc.w    residentz-start
  9689.     dc.w    reviewz-start
  9690.     dc.w    runz-start
  9691.     dc.w    searchz-start
  9692.     dc.w    setclockz-start
  9693.     dc.w    setdatez-start
  9694.     dc.w    showz-start
  9695.     dc.w    skipz-start
  9696.     dc.w    stackz-start
  9697.     dc.w    stringsz-start
  9698.     dc.w    taskpriz-start
  9699.     dc.w    typez-start
  9700.     dc.w    unsetz-start    ;unalias
  9701.     dc.w    vecz-start
  9702.     dc.w    waitz-start
  9703.  
  9704. manadr    dc.l    0    here are 2 global variables
  9705. mansize    dc.l    0    because the online-help-manual is used globally
  9706.  
  9707.     end    ;***    here it ends    ***
  9708.  
  9709.