home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / utilities / shell / zshell20.lha / ZShell20 / ZShell.S < prev    next >
Encoding:
Text File  |  1994-07-02  |  178.5 KB  |  8,959 lines

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