home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / diskmanager / overfiler_1 / !OverFiler / 0_07 (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1994-12-03  |  86KB  |  1,639 lines

  1.  >OverFiler:0_07
  2.  Allow objects to be dragged to FileCore icon filer
  3.  David G Jones, 1994
  4.  This software is PD, do what you will with it.
  5. $; " (Error code "; 
  6. ); ")": 
  7. prog$ = "OverFiler"
  8. vers$ = "0.07"
  9. date$ = "30 Nov 1994"
  10. command$="Desktop_" + prog$
  11. cUpdate% = 100                                         :
  12.  Number of centiseconds between testing
  13. 0bl$ = 
  14. (0): cr$ = 
  15. (13): nl$ = 
  16. (10) + 
  17. "Service_Reset            = &27
  18. XService_StartWimp        = &49 :
  19.  Use *Wimp versions so we start up after all Filers
  20. %Service_StartedWimp      = &4A :
  21. "Service_WimpSaveDesktop  = &5C
  22.  Layout of OverDrive for one drive
  23. "                       A%  = 0
  24. LOD_Icon%         = A%: A% += 4: 
  25.  Current icon number in icon bar window
  26. :OD_Drive%        = A%: A% += 4: 
  27.  Drive number [0 - 7]
  28. KOD_Task%         = A%: A% += 4: 
  29.  Task handle of original owner of icon
  30. AOD_Flags%        = A%: A% += 4: 
  31.  Word. Details of bits below
  32. YOD_Sequence%     = A%: A% += 4: 
  33.  Sequence number of accessing Poll changed for drive
  34. 6OD_IWidth%       = A%: A% += 4: 
  35.  Icon width in EC
  36. 8OD_SWidth%       = A%: A% += 4: 
  37.  Sprite width in EC
  38. :OD_FSNumber%     = A%: A% += 4: 
  39.  Filing system number
  40.  TOD_DescribeDisc% = A%: A% += 4: 
  41.  SWI "Xfs_DescriveDisc" instruction for this FS
  42. !TOD_MiscOp%       = A%: A% += 4: 
  43.  SWI "Xfs_MiscOp"       instruction for this FS
  44. "8OD_FSName%       = A%: A% +=12: 
  45.  Filing system name
  46. #HOD_IName%        = A%: A% +=12: 
  47.  Icon name, either :0, or disc name
  48. $7OD_ISprite%      = A%: A% +=12: 
  49.  "S" + sprite name
  50. %?OD_IPriority%    = A%: A% += 4: 
  51.  Icon priority on icon bar
  52. &MOD_OldIcon%      = A%: A% += 4: 
  53.  Original icon number from original task
  54. 'cOD_OldIconData%  = A%: A% +=36: 
  55.  Actual data to recreate original icon (+4 for fiddling space)
  56.  OD_PollChanged%  = A%: A% += 4: REM Store actual word returned by FileCore_MiscOp
  57. )DOD_Next%         = A%: A% += 4: 
  58.  Pointer to next drive. 0 = end
  59. OD_Size%         = A%
  60.  Details of OD_Flags% word
  61. -PFlags_Directory%   = 1<<  0  :
  62.  Display drive directory if new disc inserted
  63. .PFlags_Poll%        = 1<<  1  :
  64.  Whether drive should be tested every Update%
  65. /8Flags_Hard%        = 1<<  2  :
  66.  Drive is a Hard disc
  67. 0ZFlags_SprCorrupt%  = 1<<  3  :
  68.  Can't find a sprite for the drive so just use standard
  69. 1TFlags_Added%       = 1<<  4  :
  70.  Drive added,   but details not yet known by WIMP
  71. 2TFlags_Removed%     = 1<<  5  :
  72.  Drive removed, but details not yet known by WIMP
  73. 3cFlags_FullProcess% = 1<<  6  :
  74.  Ensure that a suitable name, etc is written into icon this poll
  75. 4DFlags_DiscCorrupt% = 1<<  7  :
  76.  Current disc in drive is corrupt
  77. 52Flags_Empty%       = 1<<  8  :
  78.  Drive is empty
  79. 6GFlags_ModeSame%    = 1<<  9  :
  80.  If there has NOT been a mode change
  81. 7dFlags_FinalRemove% = 1<< 10  :
  82.  Drive removed, and original icon reinserted within original task
  83. 8DFlags_Priority%    = 1<< 11  :
  84.  Priority value explicitly stated
  85. 9DFlags_SprOverload% = 1<< 12  :
  86.  A sprite was explicitly supplied
  87. :bFlags_Click%       = 1<< 13  :
  88.  Update icon display when icon is clicked (ie reverse of -Poll)
  89. ;XFlags_NoIcon%      = 1<< 14  :
  90.  There actually was not such an original icon defined
  91.  Set out of Data. If changed see .ProtoDT
  92. >(                            A%  =  0
  93. ?ADT_TaskHandle%         = A%:A% +=  4: 
  94.  OverFiler task handle
  95. @_DT_DrivesPending%      = A%:A% +=  4: 
  96.  != 0 means Add/Remove waiting for WIMP to come back
  97. AHDT_Drives%             = A%:A% +=  4: 
  98.  Pointer to first Drive entry
  99. BZDT_HelpTask%           = A%:A% +=  4: 
  100.  Task handle from sender of Message_HelpRequest
  101. C_DT_FilerSelect_Column% = A%:A% +=  4: 
  102.  End column of selection from Message_FilerSelection
  103. D_DT_FilerSelect_Row%    = A%:A% +=  4: 
  104.  End row    of selection from Nessage_FilerSelection
  105. EfDT_DataLoad%           = A%:A% +=  4: 
  106.  -2 DataSave; -1 No select; 0 First in select; +ve select X
  107. FaDT_UpdateIcon%         = A%:A% += 16: 
  108.  Suitale blank Wimp_UpdateIcon block to redraw an icon
  109. GJDT_InlineSWI%          = A%:A% +=  8: 
  110.  Area for a SWI X & mov pc, r14
  111. HMDT_WimpPollRoutine%    = A%:A% +=  4: 
  112.  Address of current Wimp_Poll loop
  113. IiDT_CloseDownRoutine%   = A%:A% +=  4: 
  114.  Address of routine we should execute application in emergency
  115. JcDT_FilerAction_Reason% = A%:A% +=  4: 
  116.  Reason code we are going to send to our FileAction task
  117. KJDT_FilerAction_Task%   = A%:A% +=  4: 
  118.  Task handle for our FileAction
  119. L;DT_XEigfactor%         = A%:A% +=  4: 
  120.  Current modes X
  121. M[DT_Trapfscv%           = A%:A% += 12: 
  122.  Used for generating changed discs filing system
  123. NaDT_Space%              = A%:A% +=256: 
  124.  For Wimp_Poll and general sandpit area for playing in
  125. OW                            A% +=128: 
  126.  Space for a few register saves in the stack
  127. DT_Stack%              = A%
  128. DT_Size%               = A%
  129.  OS_WriteI = &100
  130. T!XOS_WriteI = &100 
  131.  (1 << 17)
  132. assembly
  133.  "OS_File", 10, prog$, &FFA,, code, O%
  134. assembly
  135. rDrive = 10
  136.  code 16383
  137.  pass% = 4 
  138. O% = code: P% = 0
  139. [ OPT pass%
  140. `!                equd    start
  141. a&                equd    initialize
  142. b$                equd    finalize
  143. c'                equd    serviceCall
  144. d'                equd    titleString
  145. e&                equd    helpString
  146. f$                equd    keyWords
  147.                 equd    0
  148.                 equd    0
  149.                 equd    0
  150.                 equd    0
  151. l-.titleString    equs    prog$ +bl$: align
  152. md.helpString     equs    prog$+
  153. (9)+vers$+" ("+date$+") David G Jones (Public Domain)"+bl$: align
  154. .keyWords
  155. p/.startUpName    equs    command$+bl$: align
  156. q'                equd    startUpComm
  157.                 equd    0
  158. s'                equd    startUpHelp
  159. t'                equd    startUpHelp
  160. u4.addName        equs    prog$+"_Add" +bl$: align
  161. v#                equd    addComm
  162. w'                equd    &0000080003
  163. x#                equd    addHelp
  164. y#                equd    addHelp
  165. z7.drivesName     equs    prog$+"_Drives" +bl$: align
  166. {&                equd    drivesComm
  167.                 equd    0
  168. }&                equd    drivesHelp
  169. ~&                equd    drivesHelp
  170. 7.removeName     equs    prog$+"_Remove" +bl$: align
  171. &                equd    removeComm
  172. '                equd    &0000020002
  173. &                equd    removeHelp
  174. &                equd    removeHelp
  175. .keyWords_end   equd    0
  176. g                equd 0                                ; So we can use startUpHelp as an error block
  177. .startUpHelp    equs "The "+prog$+" allows files to be dragged over FileCore drive icons. Drive icons also reflect discs in drive."+nl$
  178. N                equs "Do not use *"+command$+", use *Desktop instead."+nl$
  179. 6                equs "Syntax: *Desktop_"+prog$+bl$
  180.                 align
  181. /.startUpComm   stmfd   r13!, {r0 - r2, r14}
  182. !               mov     r2, r0
  183. O               mov     r0, #3                         ; Command mode or not
  184. .               swi     "XWimp_ReadSysInfo"
  185. .               ldmVSfd r13!, {r0 - r2, pc}
  186. P               teq     r0, #0                         ; Is the wimp running?
  187. H               adrEQ   r0, startUpHelp                ; >No  So barf
  188. -               swiEQ   "OS_GenerateError"
  189. *               adr     r1, titleString
  190. H               mov     r0, #2                         ; Enter module
  191. '               swi     "XOS_Module"
  192. .               ldmfd   r13!, {r0 - r2, pc}
  193. n.addHelp       equs "OverFiler_Add will replace a FileCore filer icon bar icon with a super version." +nl$
  194.                equs "Syntax: *OverFiler_Add <drive> <FSname> <iconnumber> [-Directory] [-Poll] [-Priority <priority>] [-Sprite <name>] [-Click]" +bl$
  195.                align
  196. n.addReadArgs   equs "drive/E/A,fs/A,icon/E/A,directory/S,poll/S,priority/E/K,sprite/K,click/S" +bl$: align
  197. 2.addComm       stmfd   r13!, {r9, rDrive, r14}
  198. %               ldr     r12, [r12]
  199. Y               ldr     rDrive, [r12, #DT_Drives%]     ;*rDrive => Head of drive chain
  200. ; process command arguments
  201. !               mov     r1, r0
  202. *               adr     r0, addReadArgs
  203. .               add     r2, r12, #DT_Space%
  204. #               mov     r3, #256
  205. )               swi     "XOS_ReadArgs"
  206. *; Create new block of memory for drive
  207. G               movVC   r0, #6                         ; Claim block
  208. (               movVC   r3, #OD_Size%
  209. '               swiVC   "XOS_Module"
  210. '               bVS     addComm_exit
  211. %               mov     rDrive, r2
  212. q               mov     r0, #0                         ; Ensure drive is terminated correctly (even though not
  213. W               str     r0, [rDrive, #OD_Next%]        ; connect in drive chain yet)
  214. ; Read in arguments
  215. `               mov     r9, #Flags_Added% + Flags_FullProcess% + Flags_ModeSame%;*r9 == Flags
  216. H               ldr     r0, [r12, #0 +DT_Space%]       ; Drive number
  217. %               add     r0, r0, #1
  218. #               bL      loadWord
  219. d               cmp     r1, #7                         ; FileCore drives are in the range [0 - 7]
  220. X               adrHI   r0, addComm_err0               ; Illegal drive number so barf
  221. '               bHI     addComm_fail
  222. 3               str     r1, [rDrive, #OD_Drive%]
  223. V               cmp     r1, #4                         ; Is it a floppy/hard drive?
  224. %               rsb     r0, r1, #7
  225. I               movLT   r1, #&60000000                 ; >Floppy drive
  226. G               movGE   r1, #&70000000                 ; >Hard drive
  227. \               orrGE   r9, r9, #Flags_Hard%           ;               Remember it aswell
  228. h               add     r1, r1, r0                     ; Order icons with Priority group on their dri
  229. 7               str     r1, [rDrive, #OD_IPriority%]
  230. B               ldr     r0, [r12, #4 +DT_Space%]       ; FSname
  231. 2               add     r1, rDrive, #OD_FSName%
  232. !               bl      strcpy
  233. G               ldr     r0, [r12, #8 +DT_Space%]       ; Icon number
  234. %               add     r0, r0, #1
  235. #               bl      loadWord
  236. 2               str     r1, [rDrive, #OD_Icon%]
  237. 5               str     r1, [rDrive, #OD_OldIcon%]
  238. E               ldr     r0, [r12, #12 +DT_Space%]      ; Directory
  239. !               teq     r0, #0
  240. 4               orrNE   r9, r9, #Flags_Directory%
  241. @               ldr     r0, [r12, #16 +DT_Space%]      ; Poll
  242. !               teq     r0, #0
  243. /               orrNE   r9, r9, #Flags_Poll%
  244. I               ldr     r0, [r12, #20 +DT_Space%]      ; Icon priority
  245. !               teq     r0, #0
  246. 3               orrNE   r9, r9, #Flags_Priority%
  247. %               addNE   r0, r0, #1
  248. #               blNE    loadWord
  249. 7               strNE   r1, [rDrive, #OD_IPriority%]
  250. G               ldr     r0, [r12, #24 +DT_Space%]      ; Sprite name
  251. !               teq     r0, #0
  252. 5               orrNE   r9, r9, #Flags_SprCorrupt%
  253. 6               orrNE   r9, r9, #Flags_SprOverload%
  254. 6               addNE   r1, rDrive, #OD_ISprite% +1
  255. !               blNE    strcpy
  256. A               ldr     r0, [r12, #28 +DT_Space%]      ; Click
  257. !               teq     r0, #0
  258. 0               orrNE   r9, r9, #Flags_Click%
  259. 8; Now initialize rest of structure to default values
  260. !               mov     r0, #0
  261. 2               str     r0, [rDrive, #OD_Task%]
  262. 6               str     r0, [rDrive, #OD_Sequence%]
  263. 4               str     r0, [rDrive, #OD_IWidth%]
  264. 4               str     r0, [rDrive, #OD_SWidth%]
  265. T               str     r0, [rDrive, #OD_FSNumber%]    ; No FS number (presently)
  266. E               str     r0, [rDrive, #OD_DescribeDisc%]; Excessive
  267. E               str     r0, [rDrive, #OD_MiscOp%]      ; Excessive
  268. 3               str     r0, [rDrive, #OD_IName%]
  269. 3               add     r1, rDrive, #OD_ISprite%
  270. f               mov r0, #
  271. ("S"): strB r0, [r1], #1   ; Set first char to 'S' for Spite name command
  272. ]               tst     r9, #Flags_SprCorrupt%         ; Has the user set the sprite name?
  273. f               addEQ   r0, rDrive, #OD_FSName%        ; >No  So generate ours from FS and tail 'i'
  274. !               blEQ    strcpy
  275. 3               ldrEQ   r0, [rDrive, #OD_Drive%]
  276. *               addEQ   r0, r0, #
  277. ("0")
  278. )               strEQB    r0, [r1], #1
  279. d               movEQ r0, #
  280. ("i"):strEQB r0, [r1], #1; Set initially disc to be inserted in drive
  281. 6               movEQ r0, #     0  :strEQB r0, [r1]
  282. 3               str     r9, [rDrive, #OD_Flags%]
  283. 9; Setup to tell WIMP about all our devilish going ons
  284. 8               ldr     r0, [r12, #DT_DrivesPending%]
  285. %               add     r0, r0, #1
  286. 8               str     r0, [r12, #DT_DrivesPending%]
  287. 1;Now connect this drive up in the drive chain
  288. 1               ldr     r0, [r12, #DT_Drives%]
  289. !               teq     r0, #0
  290. 5               strEQ   rDrive, [r12, #DT_Drives%]
  291. '               bEQ     addComm_exit
  292. /               add     r1, r12, #DT_Drives%
  293. 5               ldr     r2, [rDrive, #OD_OldIcon%]
  294. 1.loop          ldr     r3, [r0, #OD_OldIcon%]
  295. !               cmp     r2, r3
  296. '               bLE     addComm_addB
  297. ,               add     r1, r0, #OD_Next%
  298. .               ldr     r0, [r0, #OD_Next%]
  299. !               teq     r0, #0
  300.                bNE     loop
  301. '               str     rDrive, [r1]
  302. 1.addComm_exit  ldmfd   r13!, {r9, rDrive, pc}
  303. '.addComm_addB  str     rDrive, [r1]
  304. 2               str     r0, [rDrive, #OD_Next%]
  305.     1               ldmfd   r13!, {r9, rDrive, pc}
  306. P.addComm_err0  equd 0: equs "Drive must be within range [0 - 7]" +bl$: align
  307. Y; Any errors encountered which lead to the new proto drive entry having to be deleted
  308. !.addComm_fail  mov     r1, r0
  309. @               mov     r0, #7                         ; Free
  310. %               mov     r2, rDrive
  311. '               swi     "XOS_Module"
  312. !               movVC   r0, r1
  313. K               swiVC   "XOS_GenerateError"            ; Ensure Vbit set
  314. 1               ldmfd   r13!, {r9, rDrive, pc}
  315. c.drivesHelp    equs "OverFiler_Drives displays all the drives which have been taken over." +nl$
  316. 8               equs "Syntax: *OverFiler_Drives" +bl$
  317.                align
  318. F.drivesHeader  equs " D FS   Icon    .NCOPRMECFRASHPD" +bl$: align
  319. ..drivesComm    stmfd   r13!, {rDrive, r14}
  320. %               ldr     r12, [r12]
  321. O               mov     r3, #9                         ;*r3 == Tab character
  322. V               add     r4, r12, #DT_Space%            ;*r4 => Output string buffer
  323. O               mov     r5, #
  324. (" ")                  ;*r5 == Space character
  325. 5               ldr     rDrive, [r12, #DT_Drives%]
  326. %               teq     rDrive, #0
  327. -               ldmEQfd r13!, {rDrive, pc}
  328.  >; Write a hopefully helpful header string outlining fields
  329. !+               adr     r0, drivesHeader
  330. "'               swi     "XOS_Write0"
  331. #(               swiVC   "XOS_NewLine"
  332. $J               mov     r0, #32                        ;.Draw separator
  333. %..loop          swiVC   XOS_WriteI + 
  334. ("-")
  335. &%               subS    r0, r0, #1
  336.                bGT     loop
  337. ((               swiVC   "XOS_NewLine"
  338. )-               ldmVSfd r13!, {rDrive, pc}
  339. * ; Now print each drive entry
  340. +%.loop          teq     rDrive, #0
  341. ,F               ldmEQfd r13!, {rDrive, pc}             ; ***Exit***
  342. -!               mov     r1, r4
  343. .3               ldr     r2, [rDrive, #OD_Flags%]
  344. /,               tst     r2, #Flags_Added%
  345. 0S               movNE r0, #
  346. ("+"):strNEB r0, [r1], #1; Drive waiting to be added
  347. 1V               tst     r2, #Flags_Removed%            ; /\Not mutually exlcusive\/
  348. 2U               movNE r0, #
  349. ("-"):strNEB r0, [r1], #1; Drive waiting to be removed
  350. 3=               tst     r2, #Flags_Removed% + Flags_Added%
  351. 4^               movEQ r0, #     31 :strEQB r0, [r1], #1; No executive action wainting drive
  352. 5H               ldr     r0, [rDrive, #OD_Drive%]       ; Drive number
  353. 6#               mov     r2, #128
  354. 71               swi     "XOS_ConvertCardinal1"
  355. 8'               strVCB  r5, [r1], #1
  356. 9C               addVC   r0, rDrive, #OD_FSName%        ; FS name
  357. :!               blVC    strcpy
  358. ;'               strVCB  r3, [r1], #1
  359. <d               ldrVC   r0, [rDrive, #OD_OldIcon%]     ; Old icon number (for original Filer app)
  360. =1               swiVC   "XOS_ConvertCardinal1"
  361. >'               strVCB  r5, [r1], #1
  362. ?O               ldrVC   r0, [rDrive, #OD_Icon%]        ; Current icon number
  363. @1               swiVC   "XOS_ConvertCardinal1"
  364. A'               strVCB  r3, [r1], #1
  365. BO               ldrVC   r0, [rDrive, #OD_Flags%]       ; Current drive flags
  366. C/               swiVC   "XOS_ConvertBinary2"
  367. D!               movVC   r0, r4
  368. EZ               movVC   r1, #0                         ; Use internal RiscOS dictionary
  369. FM               movVC   r2, #0                         ; No special string
  370. G,               swiVC   "XOS_PrettyPrint"
  371. H(               swiVC   "XOS_NewLine"
  372. I6               ldrVC   rDrive, [rDrive, #OD_Next%]
  373.                bVC     loop
  374. K,               ldmfd  r13!, {rDrive, pc}
  375. .removeHelp    equs "OverFiler_Remove allows single drive entries to be forgotten. Icon will be replaced by the original version." +nl$
  376. NI               equs "Syntax: *Overfiler_Remove <drive> <FSname>" +bl$
  377.                align
  378. Q5.removeReadArgs equs "drive/E/A,fs/A" +bl$: align
  379. S&.removeComm    stmfd   r13!, {r14}
  380. TG               ldr     r12, [r12]                     ; r12 => Data
  381. U!               mov     r1, r0
  382. V-               adr     r0, removeReadArgs
  383. W.               add     r2, r12, #DT_Space%
  384. X#               mov     r3, #256
  385. Y)               swi     "XOS_ReadArgs"
  386. Z%               ldmVSfd r13!, {pc}
  387. [:               ldr     r0, [r2, #0]                   
  388. \%               add     r0, r0, #1
  389. ]#               bL      loadWord
  390. ^V               mov     r4, r1                         ;*r4 == desired Drive number
  391. _Q               ldr     r1, [r2, #4]                   ;*r1 => desired FS name
  392. `M               ldr     r2, [r12, #DT_Drives%]         ;*r2 => Drive entry
  393. aX.loop          teq     r2, #0                         ; Is this a valid drive entry?
  394. b[               bEQ     removeComm_fail                ; >No ***Exit*** @Drive not found
  395. cR               ldr     r3, [r2, #OD_Next%]            ;*r3 => Next Drive entry
  396. d/               ldr     r0, [r2, #OD_Drive%]
  397. eQ               teq     r0, r4                         ; Correct drive number?
  398. f.               addEQ   r0, r2, #OD_FSName%
  399. g!               blEQ    strcmp
  400. h!               movNE   r2, r3
  401.                bNE     loop
  402. ; now delete the drive
  403. k/               ldr     r0, [r2, #OD_Flags%]
  404. l2               orr     r0, r0, #Flags_Removed%
  405. m/               str     r0, [r2, #OD_Flags%]
  406. n8               ldr     r0, [r12, #DT_DrivesPending%]
  407. o%               add     r0, r0, #1
  408. p8               str     r0, [r12, #DT_DrivesPending%]
  409. q%               ldmfd   r13!, {pc}
  410. .removeComm_fail
  411. s.               adr     r0, removeComm_err0
  412. tK               swi     "XOS_GenerateError"            ; Ensure Vbit set
  413. u%               ldmfd   r13!, {pc}
  414. vW.removeComm_err0 equd 0: equs "Could not find suitable drive to remove" +bl$: align
  415. x1.serviceCall   teq     r1, #Service_StartWimp
  416. y3               teqNE   r1, #Service_StartedWimp
  417. z-               teqNE   r1, #Service_Reset
  418. {7               teqNE   r1, #Service_WimpSaveDesktop
  419. |"               movNES  pc, r14
  420. ~1               teq     r1, #Service_StartWimp
  421. $               bEQ     startWimp
  422. 3               teq     r1, #Service_StartedWimp
  423. &               bEQ     startedWimp
  424. -               teq     r1, #Service_Reset
  425. '               bEQ     serviceReset
  426. 7               teq     r1, #Service_WimpSaveDesktop
  427. *               bEQ     wimpSaveDesktop
  428. "               movS    pc, r14
  429. *.startWimp     stmfd   r13!, {r2, r14}
  430. %               ldr     r12, [r12]
  431. 5               ldr     r2, [r12, #DT_TaskHandle%]
  432. !               teq     r2, #0
  433. !               mvnEQ   r2, #0
  434. 5               strEQ   r2, [r12, #DT_TaskHandle%]
  435. .               
  436. adrl("EQ", 0, startUpName)
  437. !               movEQ   r1, #0
  438. *               ldmfd   r13!, {r2, pc}^
  439. *.startedWimp   stmfd   r13!, {r2, r14}
  440. %               ldr     r12, [r12]
  441. 5               ldr     r2, [r12, #DT_TaskHandle%]
  442. !               cmn     r2, #1
  443. !               movEQ   r2, #0
  444. 5               strEQ   r2, [r12, #DT_TaskHandle%]
  445. *               ldmfd   r13!, {r2, pc}^
  446. *.serviceReset  stmfd   r13!, {r2, r14}
  447. %               ldr     r12, [r12]
  448. !               mov     r2, #0
  449. 5               str     r2, [r12, #DT_TaskHandle%]
  450. *               ldmfd   r13!, {r2, pc}^
  451. .wimpSaveDesktop
  452. 7               stmfd   r13!, {r0 - r6, rDrive, r14}
  453. %               ldr     r12, [r12]
  454. M               mov     r5, r2                         ;*r5 == File handle
  455. (               adr     r0, SD_OFPath
  456. .               add     r1, r12, #DT_Space%
  457. C               mov     r2, #
  458. ("/")                  ; / == *Run
  459. '               strB    r2, [r1], #1
  460. #               mov     r2, #255
  461. !               mov     r3, #0
  462. Z               mov     r4, #3                         ; Want expanded string on return
  463. +               swi     "XOS_ReadVarVal"
  464. %               addVC   r1, r1, r2
  465. %               adrVC   r0, SD_Run
  466. !               blVC    strcpy
  467. N               movVC   r0, #10                        ; Linefeed character
  468. (               strVCB   r0, [r1], #1
  469. K               addVC   r3, r2, #1 + 4 + 1             ; Number of chars
  470. .               addVC   r2, r12, #DT_Space%
  471. !               movVC   r1, r5
  472. ]               movVC   r0, #2                         ; Write bytes from current position
  473. %               swiVC   "XOS_GBPB"
  474. /               bVS     wimpSaveDesktop_fail
  475. 3; Set up command to regenerate each drive entry
  476. Y               ldr     rDrive, [r12, #DT_Drives%]     ;*rDrive => Current drive entry
  477. O               mov     r6, #
  478. (" ")                  ;*r6 == Space character
  479. %.loop          teq     rDrive, #0
  480. 7               ldmEQfd r13!, {r0 - r6, rDrive, pc}^
  481. :               add     r1, r12, #DT_Space%            
  482. _               ldr     r4, [rDrive, #OD_Flags%]       ;*r4 == Flags for current drive entry
  483. '               adr     r0, SD_OFAdd
  484. !               bl      strcpy
  485. H               ldrB    r0, [rDrive, #OD_Drive%]       ; Drive number
  486. *               add     r0, r0, #
  487. ("0")
  488. '               strB    r0, [r1], #1
  489. '               strB    r6, [r1], #1
  490. N               add     r0, rDrive, #OD_FSName%        ; Filing system name
  491. !               bl      strcpy
  492. '               strB    r6, [r1], #1
  493. K               ldr     r0, [rDrive, #OD_OldIcon%]     ; Old icon number
  494. "               mov     r2, #16
  495. 0               swi     "XOS_ConvertInteger2"
  496. /               bVS     wimpSaveDesktop_fail
  497. K               tst     r4, #Flags_Poll%               ; Poll the drive?
  498. &               adrNE   r0, SD_Poll
  499. !               blNE    strcpy
  500. L               tst     r4, #Flags_Click%               ; Poll the drive?
  501. '               adrNE   r0, SD_Click
  502. !               blNE    strcpy
  503. M               tst     r4, #Flags_Directory%          ; Open directories?
  504. +               adrNE   r0, SD_Directory
  505. !               blNE    strcpy
  506. L               tst     r4, #Flags_SprOverload%        ; Explicit Sprite?
  507. (               adrNE   r0, SD_Sprite
  508. !               blNE    strcpy
  509. 6               add     r0, rDrive, #OD_ISprite% +1
  510. !               blNE    strcpy
  511. N               tst     r4, #Flags_Priority%           ; Explicit Priority?
  512. *               adrNE   r0, SD_Priority
  513. !               blNE    strcpy
  514. ]               movNE   r0, #
  515. ("&")                  ; Tell system that it is a Hex number
  516. '               strNEB  r0, [r1], #1
  517. 7               ldrNE   r0, [rDrive, #OD_IPriority%]
  518. ,               swiNE   "XOS_ConvertHex8"
  519. N               movVC   r0, #10                        ; Linefeed character
  520. '               strVCB  r0, [r1], #1
  521. .               addVC   r2, r12, #DT_Space%
  522. W               subVC   r3, r1, r2                     ; Length of generated command
  523. ]               movVC   r0, #2                         ; Write bytes from current position
  524. !               movVC   r1, r5
  525. %               swiVC   "XOS_GBPB"
  526. 6               ldrVC   rDrive, [rDrive, #OD_Next%]
  527.                bVC     loop
  528. .wimpSaveDesktop_fail
  529. O               add     r13, r13, #8                   ; Ignore saved r0, r1
  530. L               mov     r1, #0                         ; We have an error
  531. 7               ldmfd   r13!, {r2 - r6, rDrive, pc}^
  532.                
  533. 0.SD_OFPath     equs    "OverFiler$Path" +bl$
  534. 0.SD_Run        equs    "!Run"           +bl$
  535. 0.SD_OFAdd      equs    "OverFiler_Add " +bl$
  536. 0.SD_Poll       equs    " -Poll"         +bl$
  537. 0.SD_Directory  equs    " -Directory"    +bl$
  538. 0.SD_Sprite     equs    " -Sprite "      +bl$
  539. 0.SD_Priority   equs    " -Priority "    +bl$
  540. 0.SD_Click      equs    " -Click"        +bl$
  541.                ALIGN
  542. ,; Last ditch attempt to find task handle
  543. ; Entry rDrive
  544. -.searchFT_filer equs " Filer" +bl$: align
  545. 8.searchForTask stmfd   r13!, {r0 - r1, r3 - r5, r14}
  546. .               add     r1, r12, #DT_Space%
  547. 2               add     r0, rDrive, #OD_FSName%
  548. !               bl      strcpy
  549. -               adr     r0, searchFT_filer
  550. !               bl      strcpy
  551. !               mov     r0, #0
  552.     2.searchFT0     add     r1, r12, #32 +DT_Space%
  553. "               mov     r2, #16
  554. 8               swi     "XTaskManager_EnumerateTasks"
  555. !               movVS   r2, #0
  556. '               bVS     searchFT_end
  557. !               cmp     r0, #0
  558. !               movLT   r2, #0
  559. '               bLT     searchFT_end
  560. 7               ldr     r2, [r12, #4 +32 +DT_Space%]
  561. .               add     r3, r12, #DT_Space%
  562. '.loop          ldrB    r4, [r2], #1
  563. '               ldrB    r5, [r3], #1
  564. !               teq     r4, r5
  565. $               bNE     searchFT0
  566. "               cmp     r4, #32
  567.                bGE     loop
  568. 7               ldr     r2, [r12, #0 +32 +DT_Space%]
  569. 8.searchFT_end  ldmfd   r13!, {r0 - r1, r3 - r5, pc}^
  570. Z.drive0_err    equd 0: equs "Could not find Filer in charge of this drive" +bl$: align
  571. C.drive1_err    equd 0: equs "No such filing system" +bl$: align
  572.  V; This startup a new drive within the WIMP             *rDrive => drive entry , r9
  573. !(; Exit r0 *Corrupted*  Vset if error
  574. "/.driveStart    stmfd   r13!, {r1 - r8, r14}
  575. #.;Get full details of icon we are replacing
  576. $.               add     r1, r12, #DT_Space%
  577. %K               mvn     r0, #1                         ; Icon bar window
  578. &'               str     r0, [r1, #0]
  579. '5               ldr     r0, [rDrive, #OD_OldIcon%]
  580. ('               str     r0, [r1, #4]
  581. )/               swi     "XWimp_GetIconState"
  582. *Q               add     r0, r1, #8                     ; => Start of Icon data
  583. +V               ldmia   r0, {r1 - r8}                  ; Load 32 bytes of icon data
  584. ,7               add     r0, rDrive, #OD_OldIconData%
  585. -f               stmia   r0, {r1 - r8}                  ; Store them so we can recreate icon in full
  586. .I; Find task handle of the drive filer we are replacing               
  587. /.               add     r1, r12, #DT_Space%
  588. 0D               mov     r0, #0 : str r0, [r1, #12]     ; your_ref
  589. 1Z               mov     r0, #19                        ;*r0 == User_Message_Acknowledge
  590. 2X               mvn     r2, #1                         ;*r2 == icon bar window handle
  591. 35               ldr     r3, [rDrive, #OD_OldIcon%]
  592. 4.               swi     "XWimp_SendMessage"
  593. 5*               bVS     driveStart_exit
  594. 65               ldr     r3, [r12, #DT_TaskHandle%]
  595. 7!               teq     r3, r2
  596. 8e               teqNE   r2, #0                         ; Did a task actually have control of icon?
  597. 92               strNE   r2, [rDrive, #OD_Task%]
  598. :1               orrEQ   r9, r9, #Flags_NoIcon%
  599. ;U               mvnNE   r0, #1                         ; == icon bar window handle
  600. <5               ldrNE   r2, [rDrive, #OD_OldIcon%]
  601. ='               stmNEia r1, {r0, r2}
  602. >-               swiNE   "XWimp_DeleteIcon"
  603. ?*               blVS    driveStart_exit
  604. @(               blEQ    searchForTask
  605. A@               strEQ   r2, [rDrive, #OD_Task%]        ; >Yes
  606. BZ               teqEQ   r2, #0                         ; Has owner task been found yet?
  607. Cd               adrEQ   r0, drive0_err                 ; >No Aarggh just warn user of the problem
  608. D#               blEQ    retError
  609. E\; Gets FS number (almost possibly manipulating FSname into correct form, ie add tail FS)
  610. F_.driveStart1   mov     r0, #13                        ; Check for presence of filing system
  611. G2               add     r1, rDrive, #OD_FSName%
  612. HX               mov     r2, #0                         ; String termination condition
  613. I*               swi     "XOS_FSControl"
  614. J*               bVS     driveStart_exit
  615. KT               teq     r2, #0                         ; Was filing system found?
  616. LX               adrEQ   r0, drive1_err                 ; >No  So prime for error barf
  617. M.               swiEQ   "XOS_GenerateError"
  618. NK               bEQ     driveStart_exit                ;      ***Exit***
  619. O6               strNE   r1, [rDrive, #OD_FSNumber%]
  620. P7; get swi numbers for Xfs_MiscOp & Xfs_DescribeDisc
  621. Q0.driveStart2   add     r1, r12, #DT_Space%  
  622. Rd               ldr     r2, drive1_swi                 ;*r2 == swiAL proto section of instruction
  623. SR               mov     r0, #
  624. ("X")                  ; Want error returning swi
  625. T'               strB    r0, [r1], #1
  626. U2               add     r0, rDrive, #OD_FSName%
  627. V!               bl      strcpy
  628. Wf               ldrB    r0, [r1, #-2]                  ; Append 'FS' if not already included at end
  629. XD               teq     r0, #
  630. ("F")                  ; of FS name
  631. Y(               ldrNEB  r0, [r1, #-1]
  632. Z&               teqNE   r0, #
  633. ("S")
  634. [9               movNE r0, #
  635. ("F"): strNEB r0, [r1], #1
  636. \9               movNE r0, #
  637. ("S"): strNEB r0, [r1], #1
  638. ]d               mov     r3, r1                         ;*r3 => start of swi specific name section
  639. ; swi Xfs_DescribeDisc
  640. _(               adr     r0, drive1_DD
  641. `!               bL      strcpy
  642. a.               add     r1, r12, #DT_Space%
  643. b4               swi     "XOS_SWINumberFromString"
  644. c,               ldrVS   r0, drive1_DDfail
  645. d%               orrVC   r0, r0, r2
  646. e:               str     r0, [rDrive, #OD_DescribeDisc%]
  647. ; swi Xfs_MiscOp
  648. g(               adr     r0, drive1_MO
  649. h!               mov     r1, r3
  650. i!               bL      strcpy
  651. j.               add     r1, r12, #DT_Space%
  652. k4               swi     "XOS_SWINumberFromString"
  653. l,               ldrVS   r0, drive1_MOfail
  654. m%               orrVC   r0, r0, r2
  655. n4               str     r0, [rDrive, #OD_MiscOp%]
  656. pcmov r0, pc: bic r0, r0, #1 << 28: teqP pc, r0         ; Clear Vbit from all our above fiddlings
  657. r&; Calculate width of drives sprite
  658. s%               bL      spriteSize
  659. u.; Replace original drive icon with our own
  660. vb               movS    r0, #0                         ; Set EQ - relevant icon deleted already
  661. wQ               bL      iconRebirth                    ; Replace with our icon
  662. xF.driveStart_exit ldmfd  r13!, {r1 - r8, pc}           ; ***Exit***
  663. .drive1_swi    swi 0
  664. {,.drive1_DD     equs "_DescribeDisc" +bl$
  665. |-.drive1_MO     equs "_MiscOp" +bl$: align
  666. }*.drive1_DDfail swi "XOS_GenerateError"
  667. .drive1_MOfail mov r3, #0
  668. /.wimpError     add     r13, r12, #DT_Stack%
  669. $               mov     r1, #%011
  670. '               adr     r2, TaskName
  671. -               swi     "Wimp_ReportError"
  672. K               teq     r1, #1                         ; Ok to continue?
  673. ?               bNE     error_cd                       ; >No
  674. ;               ldr     r14, [r12, #DT_WimpPollRoutine%]
  675. ]               teq     r14, #0                        ; Has a wimp_Poll loop been set up?
  676. P               movNE   pc, r14                        ; >Yes So return to it
  677. C; Attempt to exist application in the safest way               
  678. <.error_cd      ldr     r14, [r12, #DT_CloseDownRoutine%]
  679. p               teq     r14, #0                        ; Has a suitable application exit routine been set up?
  680. Z               swiEQ   "OS_Exit"                      ; >No  Default system ***Exit***
  681. N               mov     pc, r14                        ; >Yes Go on to that
  682. /.retError      stmfd   r13!, {r0 - r2, r14}
  683. $               mov     r1, #%011
  684. '               adr     r2, TaskName
  685. -               swi     "Wimp_ReportError"
  686. K               teq     r1, #1                         ; Ok to continue?
  687. Q               ldmEQfd r13!, {r0 - r2, pc}^           ; Ensure Vbit still set
  688. #               b       error_cd
  689. $.initialize    ldr     r0, [r12]
  690. ]               teq     r0, #0                         ; Is this the result of a RMA tidy?
  691. N               movNE   pc, r14                        ; >Yes So ***Exit***
  692. &               stmfd   r13!, {r14}
  693. H               mov     r0, #6                         ; Claim memory
  694. (               mov     r3, #DT_Size%
  695. '               swi     "XOS_Module"
  696. f               strVC   r2, [r12]                      ; Store the reference to our block of memory
  697. `               adrVC   r1, ProtoDT                    ; Initialize critical sections of DaTa
  698. \               ldmVCia r1!, {r0, r3 - r6, r12, r14}   ; Copy DT_TaskHandle - DT_DataLoad
  699. 7               stmVCia r2!, {r0, r3 - r6, r12, r14}
  700. N               ldmVCia r1!,     {r3 - r6}             ; Copy DT_UpdateIcon
  701. -               stmVCia r2!,     {r3 - r6}
  702. h               ldmVCia r1!,     {r3 - r6}             ; DT_InlineSWI% , WimpPollRoutine, ExitRoutine
  703. -               stmVCia r2!,     {r3 - r6}
  704. F               ldmfd   r13!, {pc}                     ; ***Exit***
  705. &; This destroys our nice DT_% defs
  706. E.ProtoDT equd  0: equd 0: equd 0: equd 0: equd 0: equd 0: equd -1
  707. ,         equd -2: equd 0: equd 0: equd 0
  708. 1         equd  0: mov pc, r14: equd 0: equd 0
  709. '.finalize       stmfd   r13!, {r14}
  710. G                ldr     r12, [r12]                    ;*r12 => DaTa
  711. 6                ldr     r0, [r12, #DT_TaskHandle%]
  712. W                teq     r0, #0                        ; Was Wimp_Initialize called?
  713. $                ldrGT   r1, TASK
  714. -                swiGT   "XWimp_CloseDown"
  715. C                movGT   r0, #&1D                      ; UpCallV
  716. .                
  717. adrl("GT", 1, trapupcall)
  718. #                movGT   r2, r12
  719. )                swiGT   "XOS_Release"
  720. H                movGT   r0, #&0F                      ; OS_FSControl
  721. ,                
  722. adrl("GT", 1, trapfscv)
  723. #                movGT   r2, r12
  724. .                swiGT   "XOS_Release"     
  725. 0; reset task handle in case we are restarted
  726. e                mov     r1, #0                        ; Initialize task handle in case we restart
  727. 6                str     r1, [r12, #DT_TaskHandle%]
  728. +; free all our drive entries (if fatal)
  729. ]               teq     r10, #0                        ; Is this a non-fatal finalization?
  730. h               ldmEQfd r13!, {pc}^                    ; >Yes So leave drive entries intact***Exit***
  731. G               mov     r0, #7                         ; Free memory
  732. M               ldr     r2, [r12, #DT_Drives%]         ;*r2 => Drive entry
  733. Y               teq     r2, #0                         ; Are there any drives entries?
  734. h               ldmEQfd  r13!, {pc}^                   ; >No  So ignore                    ***Exit***
  735. G               mov     r4, #0                         ; Reset value
  736. 1               str     r4, [r12, #DT_Drives%]
  737. [.loop          ldr     r3, [r2, #OD_Next%]            ;*r3 => next Drive entry in chain
  738. c               str     r4, [r2, #OD_Next%]            ; Just a precaution incase gone cyclic...
  739. '               swi     "XOS_Module"
  740. !               movS    r2, r3
  741.                bNE     loop
  742. &               ldmfd   r13!, {pc}^
  743. \; Simply removes the icon from the icon bar and sets up Filter to recreate original icon
  744. /.driveRemove   stmfd   r13!, {r1 - r4, r14}
  745. 3               add     r1, r12, #DT_UpdateIcon%
  746. 2               ldr     r0, [rDrive, #OD_Icon%]
  747. '               str     r0, [r1, #4]
  748. -               swi     "XWimp_DeleteIcon"
  749. +               bVS     driveRemove_fail
  750. 2               ldr     r3, [rDrive, #OD_Task%]
  751. R               teq     r3, #0                         ; Does task still exist?
  752. ?               bEQ     driveRemove_fail               ; >No
  753. a               tst     r9, #Flags_NoIcon%             ; Was there originally an icon present?
  754. ?               bNE     driveRemove_fail               ; >No
  755. '; Setup PostFilter to recreate icon
  756. '               adr     r0, TaskName
  757. 1               adr     r1, filterRecreateIcon
  758. %               mov     r2, rDrive
  759. /               ldr     r4, Filter_EventMask
  760. 7               swi     "XFilter_RegisterPostFilter"
  761. +               bVS     driveRemove_fail
  762. Z; Signal PostFilter to do its job (through Message_Quit which Task will never receive)
  763. .               add     r1, r12, #DT_Space%
  764. "               mov     r0, #20
  765. '               str     r0, [r1, #0]
  766. !               mov     r0, #0
  767. (               str     r0, [r1, #12]
  768. (               str     r0, [r1, #16]
  769. !               mov     r2, r3
  770. H               mov     r0, #17                        ; User_Message
  771. .               swi     "XWimp_SendMessage"
  772. e               strVC   r12, [rDrive, #OD_OldIconData% + 32]; Slight fiddle - corrupted on RM_Tidy
  773. b               ldmVCfd r13!, {r1 - r4, pc}            ; Houston we are ready to go! ***Exit***
  774. 1; Signal has failed so ignore icon recreation
  775. '               adr     r0, TaskName
  776. 1               adr     r1, filterRecreateIcon
  777. %               mov     r2, rDrive
  778. 2               ldr     r3, [rDrive, #OD_Task%]
  779. /               ldr     r4, Filter_EventMask
  780. 9               swi     "XFilter_DeRegisterPostFilter"
  781. .driveRemove_fail
  782. ^               orr     r9, r9, #Flags_FinalRemove%    ; Pretend we have recreated old icon
  783. g               mov     r1, #0                         ; Blank out task handle so we dont attempt to
  784. Z               str     r1, [rDrive, #OD_Task%]        ; delete non-existant PostFilter
  785. F               ldmfd   r13!, {r1 - r4, pc}            ; ***Exit***
  786. 0.Filter_EventMask equd %10011111111111111111
  787. ; Entry r12 => Drive entry
  788. .filterRecreateIcon
  789. /               stmfd   r13!, {r2 - r9, r14}
  790. O               ldr     r2, [r1, #16]                  ; Load message action
  791. Q               teq     r2, #0                         ; Is this Message_Quit?
  792. b               ldmNEfd r13!, {r2 - r9, pc}^           ; >No ***Exit*** @Waiting for our signal
  793. 4               add     r0, r12, #OD_OldIconData%
  794. (               ldmia   r0, {r2 - r9}
  795. K               mvn     r0, #4                         ; Icon bar window
  796. ,               stmia   r1, {r0, r2 - r9}
  797. 4               ldr     r0, [r12, #OD_IPriority%]
  798.     -               swi     "XWimp_CreateIcon"
  799. 0               ldr     r0, [r12, #OD_Flags%]
  800. [               orr     r0, r0, #Flags_FinalRemove%    ; Mark we have recreated old icon
  801. 0               str     r0, [r12, #OD_Flags%]
  802. ;               ldr     r0, [r12, #OD_OldIconData% + 32]
  803. h               ldr     r2, [r0, #DT_DrivesPending%]   ; Mark that we are waiting to operate on drive
  804. %               add     r2, r2, #1
  805. 7               str     r2, [r0, #DT_DrivesPending%]
  806. G               mvn     r0, #0                         ; Claim event
  807. /               ldmfd   r13!, {r2 - r9, pc}^
  808. D; Remove drive from chain, and remove its icon from the icon bar
  809. Y; Entry r2 => Last drive entry ;r3 => Next drive entry ;rDrive => Current drive entry
  810. .driveFinalRemove
  811. /               stmfd   r13!, {r1 - r4, r14}
  812. Y               teq     r2, #0                         ; Is this the first drive entry
  813. d               strNE   r3, [r2, #OD_Next%]            ; >No  Last drive points to Next drive now
  814. c               strEQ   r3, [r12, #DT_Drives%]         ; >Yes Store next at head of drives chain
  815. I; Deregister PostFilter to recreate original icon (if actually setup)
  816. 2               ldr     r3, [rDrive, #OD_Task%]
  817. !               teq     r3, #0
  818. '               adrNE   r0, TaskName
  819. 1               adrNE   r1, filterRecreateIcon
  820.  %               movNE   r2, rDrive
  821. !/               ldrNE   r4, Filter_EventMask
  822. "9               swiNE   "XFilter_DeRegisterPostFilter"
  823. #&; Free the Drive entry memory used
  824. $@               mov     r0, #7                         ; Free
  825. %%               mov     r2, rDrive
  826. &'               swi     "XOS_Module"
  827. 'R               mov     rDrive, #0                     ; Register loss of drive
  828. (-               ldmfd   r13!, {r1 - 4, pc}
  829. *8; Start up any drives that just happen to be waiting
  830. .processDrivesPending
  831. ,7               stmfd   r13!, {r0 - r3, rDrive, r14}
  832. -R               ldr     rDrive, [r12, #DT_Drives%]     ;*rDrive =>  Drive entry
  833. .R               mov     r2, #0                         ;*r2 => Last Drive entry
  834. /Y.loop          teq     rDrive, #0                     ; Do we have a valid drive here
  835. 0M               bEQ     processDP1                     ; >No  Jump to Exit
  836. 1R               ldr     r3, [rDrive, #OD_Next%]        ;*r3 => Next Drive entry
  837. 23               ldr     r9, [rDrive, #OD_Flags%]
  838. 3,               tst     r9, #Flags_Added%
  839. 4%               blNE    driveStart
  840. 5#               blVS    retError
  841. 6h               orrVS   r9, r9, #Flags_Removed%        ; If error while starting then Remove Now!!!!!
  842. 7.               tst     r9, #Flags_Removed%
  843. 8&               blNE    driveRemove
  844. 9#               blVS    retError
  845. :2               tst     r9, #Flags_FinalRemove%
  846. ;+               blNE    driveFinalRemove
  847. <#               blVS    retError
  848. =A               bic     r9, r9, #Flags_Added% + Flags_Removed%
  849. >Y               teq     rDrive, #0                     ; Does drive entry still exist?
  850. ?Y               strNE   r9, [rDrive, #OD_Flags%]       ; >Yes Store new state of Flags
  851. @%               mov     r2, rDrive
  852. A%               mov     rDrive, r3
  853. BF               b       loop                           ; Process it
  854. C!.processDP1    mov     r0, #0
  855. D8               str     r0, [r12, #DT_DrivesPending%]
  856. E7               ldmfd   r13!, {r0 - r3, rDrive, pc}^
  857. G3.TaskName      equs    "Over Filer" +bl$: align
  858. H4.PollMask      equd    %110010000001100100110010
  859. I!.TASK          equs    "TASK"
  860. Jd.Messages      equd 1: equd 3: equd &407: equd &502: equd &503: equd &400C1: equd &400c3: equd 0
  861. LG.start         ldr     r12, [r12]                     ; r12 => DaTa
  862. MH               add     r13, r12, #DT_Stack%           ; Set up stack
  863. O$; Tell the WIMP manager about us
  864. P].start0        mov     r0, #256                       ; == 310  Minimum WIMP version 3.10
  865. Q-               add     r0, r0, #310 - 256
  866. R#               ldr     r1, TASK
  867. S'               adr     r2, TaskName
  868. T'               adr     r3, Messages
  869. U,               swi     "Wimp_Initialise"
  870. V5               str     r1, [r12, #DT_TaskHandle%]
  871. WW; Want to trap if a filing medium is not present/known or we might miss a disc swap
  872. XC.start1        mov     r0, #&1D                       ; UpCallV
  873. Y)               adr     r1, trapupcall
  874. Z"               mov     r2, r12
  875. [&               swi     "XOS_Claim"
  876. \H               mov     r0, #&0F                       ; OS_FSControl
  877. ]'               adr     r1, trapfscv
  878. ^"               mov     r2, r12
  879. _&               swi     "XOS_Claim"
  880. `N; We can now set up a suitable place to retreat to in the case of an error
  881. a*               
  882. adrl("", 0, closeDown)
  883. b;               str     r0, [r12, #DT_CloseDownRoutine%]
  884. ; Initialize XEigfactor
  885. dH               mvn     r0, #0                         ; Current mode
  886. eF               mov     r1, #4                         ; XEigfactor
  887. f1               swi     "XOS_ReadModeVariable"
  888. g5               str     r2, [r12, #DT_XEigfactor%]
  889. h7; Initialize any drive entries that have been setup
  890. i/               bl      processDrivesPending
  891. jC; Can now set suitable place to continue processing after error
  892. k'               adr     r0, wimpPoll
  893. l:               str     r0, [r12, #DT_WimpPollRoutine%]
  894. m@; Set initial values for any pre-loaded icons               
  895. na               b       testAllDrives                  ; Insert drive names, etc straight away
  896. p^.wimpPoll      adr     r14, wimpPoll                  ; Set up return address just in case
  897. q2               swi     "XOS_ReadMonotonicTime"
  898. r+               addVC   r2, r0, #Update%
  899. s'               ldrVC   r0, PollMask
  900. t.               addVC   r1, r12, #DT_Space%
  901. u6               addVC   r3, r12, #DT_DrivesPending%
  902. v+               swiVC   "XWimp_PollIdle"
  903. w$               bVS     wimpError
  904. yL               teq     r0, #0                         ; Null_Reason_Code
  905. z(               bEQ     testAllDrives
  906. |L               teq     r0, #13                        ; PollWord_NonZero
  907. }/               bEQ     processDrivesPending
  908. H               teq     r0, #17                        ; User_Message
  909. Q               teqNE   r0, #18                        ; User_Message_Recorded
  910. )               bEQ     receiveMessage
  911. G               teq     r0, #6                         ; Mouse_Click
  912. %               bEQ     mouseclick
  913. Y               b       wimpPoll                       ; Nothing that interested us...
  914. H; See's if any of the drives under our control have changed in state
  915. Z.testAllDrives ldr     rDrive, [r12, #DT_Drives%]     ;*rDrive => First drive in chain
  916. b.loop          teq     rDrive, #0                     ; Have we reached the end of the drives?
  917. g               bEQ     wimpPoll                       ; >Yes ***Exit*** @Reached end of drive chain
  918. H               ldr     r9, [rDrive, #OD_Flags%]       ;*r9  == Flags
  919. _               tst     r9, #Flags_Poll% + Flags_FullProcess%; Should this drive be checked?
  920. L               blNE    testDrive                      ; >Yes So check it
  921. W               strNE   r9, [rDrive, #OD_Flags%]       ;      Store new set of flags
  922. Q               ldr     rDrive, [rDrive, #OD_Next%]    ; Advance to next drive
  923. K               b       loop                           ;      Process it
  924. /.testDrive     stmfd   r13!, {r0 - r8, r14}
  925. ; Has drive poll changed?
  926. H.testDrive1    mov     r0, #1                         ; Poll changed
  927. 4               ldr     r1, [rDrive, #OD_MiscOp%]
  928. 4               str     r1, [r12, #DT_InlineSWI%]
  929. 3               ldr     r1, [rDrive, #OD_Drive%]
  930. 6               ldr     r2, [rDrive, #OD_Sequence%]
  931. -               adr     r14, testDrive1swi
  932. R               add     pc, r12, #DT_InlineSWI%        ; bl to SWI "Xfs_MiscOp"
  933. S.testDrive1swi movVS   r3, #0                         ; Pretend to get a result
  934. 6               orrVS   r9, r9, #Flags_DiscCorrupt%
  935. 6               bicVC   r9, r9, #Flags_DiscCorrupt%
  936. a               str     r2, [rDrive, #OD_Sequence%]    ; Store for next MiscOp with this drive
  937. :;               ldr     r4, [rDrive, #OD_PollChanged%]
  938. ";               cmp     r3, r4
  939. :;               strNE   r3, [rDrive, #OD_PollChanged%]
  940. ';               bEQ     testDrive1b
  941. h               mov     r3, r3, LSL #5 ;WARN WARN WARN uses absolute positions of bit@@@@@@@@@@@@@@@@
  942. 0               and     r3, r3, #Flags_Empty%
  943. %               eor     r0, r9, r3
  944. 0               bic     r9, r9, #Flags_Empty%
  945. %               orr     r9, r9, r3
  946. R.testDrive1b   tst     r9, #Flags_FullProcess%        ; Completly update icon?
  947. 6               bic     r9, r9, #Flags_FullProcess%
  948. @               bNE     testDrive2                     ; >Yes
  949. T               tst     r0, #Flags_Empty%              ; Has drive state changed?
  950. K               ldmEQfd r13!, {r0 - r8, pc}^           ; >Yes ***Exit***
  951. 5; Make icon name/sprite details reflect new state
  952. G.testDrive2    add     r0, rDrive, #OD_IName%         ;*r0 => IName
  953. &               mov     r1, #
  954. (":")
  955. 3               ldr     r2, [rDrive, #OD_Drive%]
  956. X               add     r2, r2, #
  957. ("0")              ; FileCore limits to < 10 drives
  958. B               orr     r1, r1, r2, LSL #8             ; ";n00"
  959. #               str     r1, [r0]
  960. ,               tst     r9, #Flags_Empty%
  961. b               movNE   r2, #
  962. ("o")                  ; >Yes Disk out of drive - sprite end char
  963. U               bNE     testDrive2_0                   ;      Jump to next section
  964. ;; There is a disc in the drive so try and find its name
  965. :               ldr     r1, [rDrive, #OD_DescribeDisc%]
  966. 4               str     r1, [r12, #DT_InlineSWI%]
  967. c               swi     "XHourglass_On"                ; DescribeDisc can take a noticeable time
  968. f               sub     r1, r13, #64 +4                ; Assume temp space on stack for disk record
  969. -               adr     r14, testDrive2swi
  970. T               add     pc, r12, #DT_InlineSWI%        ; bl to "Xfs_DescribeDisc"
  971. a.testDrive2swi movVS   r8, #1                         ;*r8 Indicate if there was a disc error
  972. !               movVC   r8, #0
  973. f               addVC   r1, r1, #22                    ;*r1 => Discname (with space & poss. no end)
  974. (               adrVS   r1, DiskError
  975. [               addVS   r0, rDrive, #OD_IName%         ; r0 was overwritten by swi error
  976. ]               mov     r2, #10                        ; Discname up to 10 characters long
  977. '.loop          ldrB    r3, [r1], #1
  978. f               cmp     r3, #
  979. (" ")                  ; Check for character terminater (incld SPACE)
  980. !               movLE   r3, #0
  981. '               strB    r3, [r0], #1
  982. %               subS    r2, r2, #1
  983.                bGT     loop
  984. ^               mov     r3, #0                         ; Properly terminate it if it wasn't
  985. #               strB    r3, [r0]
  986. T               tst     r9, #Flags_ModeSame%           ; Was there a mode change?
  987. Q               teqNE   r8, #1                         ; >No  Was the disc ok?
  988. f               tstNE   r9, #Flags_Directory%          ;      >Yes Does user want us to open filer?
  989. ]               blNE    filerOpen                      ;           >Yes Open filer on disc
  990. +               swi     "XHourglass_Off"
  991. a               mov     r2, #
  992. ("i")                  ; Disc in drive - end of sprite character
  993. O; Set sprite name                                      *r2 == end character
  994. T.testDrive2_0  tst     r9, #Flags_ModeSame%           ; Was there a mode change?
  995. O               orrEQ   r9, r9, #Flags_ModeSame%       ; >Yes So reset flags
  996. 1               tst     r9, #Flags_SprCorrupt%
  997. %               bNE     testDrive3
  998. 3               add     r0, rDrive, #OD_ISprite%
  999. \.loop          ldrB    r1, [r0], #1                   ;.Find end of current Sprite name 
  1000. &               cmp     r1, #
  1001. (" ")
  1002.                bGE     loop
  1003. (               strB    r2, [r0, #-2]
  1004. 3; Change icon in WIMPs eye to reflect new state
  1005. 1.testDrive3    add     r0, rDrive, #OD_IName%
  1006. O               mov     r2, #0                         ;*r2 == width of text
  1007. U.loop          ldrB    r1, [r0], #1                   ;.Count length of disc name
  1008. "               cmp     r1, #32
  1009. %               addGE   r2, r2, #1
  1010.                bGE     loop
  1011. Y               mov     r2, r2, ASL #4                 ; width in external coordinates
  1012. 4               ldr     r3, [rDrive, #OD_SWidth%]
  1013. d               cmp     r2, r3                         ; Must be at least width enough for sprite
  1014. !               movLE   r2, r3
  1015. 4               ldr     r0, [rDrive, #OD_IWidth%]
  1016. N               teq     r0, r2                         ; Has width changed?
  1017. U               strNE   r2, [rDrive, #OD_IWidth%]      ; >Yes Store new width then
  1018. \               blNE    iconRebirth                    ;      Delete & then reCreate icon
  1019. /               ldmNEfd r13!, {r0 - r8, pc}^
  1020. 9; Icon has same dimensions so just redraw screen form
  1021. S               add     r1, r12, #DT_UpdateIcon%       ; No change to icon flags
  1022. 2               ldr     r3, [rDrive, #OD_Icon%]
  1023. '               str     r3, [r1, #4]
  1024. /               swi     "XWimp_SetIconState"
  1025. #               blVS    retError
  1026. /               ldmfd   r13!, {r0 - r8, pc}^
  1027. U; Deletes a drives icon then recreates                *rDrive => this drive entry
  1028. !; Entry  NE delete icon first
  1029. /.iconRebirth   stmfd   r13!, {r0 - r7, r14}
  1030. Z               sub     r1, r13, #36 +4                ; Assume a bit of space on stack
  1031. U               mvnNE   r0, #1                         ; == icon bar window handle
  1032. 2               ldrNE   r2, [rDrive, #OD_Icon%]
  1033. '               stmNEia r1, {r0, r2}
  1034. -               swiNE   "XWimp_DeleteIcon"
  1035. .               adr     r2, ProtoCreateIcon
  1036. g               ldmia   r2, {r2 - r7}                  ; r2 == window; r3..r6 == coords; r7 == flags
  1037. 4               ldr     r5, [rDrive, #OD_IWidth%]
  1038. (               stmia   r1, {r2 - r7}
  1039. )               add     r0, r1, #20 +4
  1040. O               add     r2, rDrive, #OD_IName%         ; => Icon text buffer
  1041. U               add     r3, rDrive, #OD_ISprite%       ; => Icon validation buffer
  1042.     L               mov     r4, #12                        ; == buffer length
  1043. +               stmia   r0, {r2, r3, r4}
  1044. 7               ldr     r0, [rDrive, #OD_IPriority%]
  1045. -               swi     "XWimp_CreateIcon"
  1046. #               blVS    retError
  1047. 2               strVC   r0, [rDrive, #OD_Icon%]
  1048. /               ldmfd   r13!, {r0 - r7, pc}^
  1049. ).trapfscv_adfs equs "ADFS" +
  1050. 0: align
  1051. C; Trap a disc changing name and us updating our display of this
  1052. I.trapfscv      teq     r0, #50                        ; Name the disc
  1053. "               movNES  pc, r14
  1054. /               stmfd   r13!, {r0 - r5, r14}
  1055. 1; Check to see filing system was not included
  1056. #               ldrB    r2, [r1]
  1057. _               teq     r2, #
  1058. (":")                  ; No filing system given so assume ADFS
  1059. _               adrEQ   r0, trapfscv_adfs              ; should be able to calculate real FS
  1060. $               bEQ     trapfscv0
  1061. ; Find filing system name
  1062. 1               add     r0, r12, #DT_Trapfscv%
  1063. m               mov     r3, #12                        ; Remember max size so don't write all over storage
  1064.  '.loop          ldrB    r2, [r1], #1
  1065. !%               subS    r3, r3, #1
  1066. "!               movLE   r2, #0
  1067. #&               teq     r2, #
  1068. (":")
  1069. $!               movEQ   r2, #0
  1070. %&               cmp     r2, #
  1071. (" ")
  1072. &!               movLT   r2, #0
  1073. ''               strB    r2, [r0], #1
  1074.                bGE     loop
  1075. )1               add     r0, r12, #DT_Trapfscv%
  1076. ; Get drive number
  1077. +\.trapfscv0     ldrB    r2, [r1, #1]                   ; Should be drive number character
  1078. ,L               sub     r2, r2, #
  1079. ("0")              ;*r2 == drive number
  1080. -f               cmp     r2, #7                         ; Should only be up to 7 devices on FileCore
  1081. .F               ldmHIfd r13!, {r0 - r5, pc}^           ; ***Exit***
  1082. /$; Now search for matching drives
  1083. 01               ldr     r5, [r12, #DT_Drives%]
  1084. 1!.loop          teq     r5, #0
  1085. 2F               ldmEQfd r13!, {r0 - r5, pc}^           ; ***Exit***
  1086. 3/               ldr     r3, [r5, #OD_Flags%]
  1087. 4A               tst     r3, #Flags_Empty% + Flags_DiscCorrupt%
  1088. 5/               ldrEQ   r4, [r5, #OD_Drive%]
  1089. 6!               teqEQ   r4, r2
  1090. 7$               bNE     trapfscv1
  1091. 8.               add     r1, r5, #OD_FSName%
  1092. 9!               bl      strcmp
  1093. :6               orrEQ   r3, r3, #Flags_FullProcess%
  1094. ;/               strEQ   r3, [r5, #OD_Flags%]
  1095. <..trapfscv1     ldr     r5, [r5, #OD_Next%]
  1096.                b       loop
  1097. Ah; Trap if there is a request for a media change. If there is a change then we won't catch the change
  1098. BM.trapupcall    teq     r0, #1                         ; Media not present
  1099. CK               teqNE   r0, #2                         ; Media not known
  1100. D"               movNES  pc, r14
  1101. E/               stmfd   r13!, {r5 - r6, r14}
  1102. FU               ldr     r5, [r12, #DT_Drives%]         ;*r5 => Current drive entry
  1103. GX.loop          teq     r5, #0                         ; Is this a valid drive entry?
  1104. Hc               ldmEQfd r13!, {r5 - r6, pc}^           ; >No ***Exit*** @Dont control this drive
  1105. IK               ldr     r6, [r5, #OD_FSNumber%]        ; Same FS number?
  1106. J!               teq     r6, r1
  1107. K&               bNE     trapupcall0
  1108. L!               cmn     r3, #1
  1109. MK               ldrNE   r6, [r5, #OD_Drive%]           ; And same drive?
  1110. N!               teqNE   r6, r3
  1111. OV.trapupcall0   ldrNE   r5, [r5, #OD_Next%]            ; >No  Load next drive entry
  1112. PK               bNE     loop                           ;      Process it
  1113. Q/               ldr     r6, [r5, #OD_Flags%]
  1114. Re               orr     r6, r6, #Flags_FullProcess%    ; Reprocess this drive as disc might change
  1115. S/               str     r6, [r5, #OD_Flags%]
  1116. TF               ldmfd   r13!, {r5 - r6, pc}^           ; ***Exit***
  1117. WY.helpRequest   ldr     rDrive, [r12, #DT_Drives%]     ;*rDrive => Current Drive entry
  1118. XM               ldr     r3, [r1, #36]                  ;*r3 == icon handle
  1119. YX.loop          teq     rDrive, #0                     ; Is this still a drive entry?
  1120. Zc               bEQ     wimpPoll                       ; >No  ***Exit*** @Shouldnt have happened
  1121. [2               ldr     r0, [rDrive, #OD_Icon%]
  1122. \Z               teq     r0, r3                         ; Help requested from this icon?
  1123. ]\               ldrNE   rDrive, [rDrive, #OD_Next%]    ; >No  Advance to next drive entry
  1124. ^K               bNE     loop                           ;      Process it
  1125. _W               ldr     r3, [rDrive, #OD_Task%]        ;*r3 == real icon task handle
  1126. `g               teq     r3, #0                         ; Does the real owner has a valid task handle
  1127. aK               bEQ     wimpPoll                       ; >No  ***Exit***
  1128. b%; Acknowledge Message_HelpRequest
  1129. c'               ldr     r0, [r1, #8]
  1130. dM               str     r0, [r1, #12]                  ; your_ref = my_ref
  1131. eT               mov     r0, #19                        ; User_Message_Acknowledge
  1132. fP               ldr     r2, [r1, #4]                   ; Reply to task handle
  1133. ge               str     r2, [r12, #DT_HelpTask%]       ; Remember task for later helpReply message
  1134. h.               swi     "XWimp_SendMessage"
  1135. i8; Now send Message_HelpRequest to real owner of icon
  1136. j5               ldrVC   r0, [rDrive, #OD_OldIcon%]
  1137. k(               strVC   r0, [r1, #36]
  1138. lH               movVC   r0, #17                        ; User_Message
  1139. m!               movVC   r2, r3
  1140. nh               swiVC   "XWimp_SendMessage"            ; >Yes So pass on HelpRequest to real receiver
  1141. o#               bVC     wimpPoll
  1142. p$               bVS     wimpError
  1143. rH.helpReply     mov     r0, #17                        ; User_Message
  1144. s3               ldr     r2, [r12, #DT_HelpTask%]
  1145. tZ               teq     r2, #0                         ; Is HelpTask a real task handle
  1146. uZ               swiNE   "XWimp_SendMessage"            ; >Yes So send Message_HelpReply
  1147. v#               bVC     wimpPoll
  1148. w$               bVS     wimpError
  1149. .receiveMessage
  1150. zJ               ldr     r2, [r1, #16]                  ; Message number
  1151. {Q               mov r3, #&500  : add r4, r3, #2  : teq r2, r4: bEQ helpRequest
  1152. |O                                add r4, r3, #3  : teq r2, r4: bEQ helpReply
  1153. ~T               mov r3, #&400  : add r4, r3, #7  : teq r2, r4: bEQ filerSelection
  1154. N                                                  teq r2, #3: bEQ dataLoad
  1155. N                                                  teq r2, #1: bEQ dataSave
  1156. P               mov r3, #&40000: add r4, r3, #&C1: teq r2, r4: bEQ modeChange
  1157. T                                add r4, r3, #&C3: teq r2, r4: bEQ checkCloseDown
  1158. @               teq     r2, #0                         ; Quit
  1159. #               bNE     wimpPoll
  1160. :                                                      
  1161. C.closeDown     mov     r0, #&1D                       ; UpCallV
  1162. )               adr     r1, trapupcall
  1163. "               mov     r2, r12
  1164. (               swi     "XOS_Release"
  1165. H               mov     r0, #&0F                       ; OS_FSControl
  1166. '               adr     r1, trapfscv
  1167. "               mov     r2, r12
  1168. (               swi     "XOS_Release"
  1169. )               adr     r1, closeDown3
  1170. ;               str     r1, [r12, #DT_CloseDownRoutine%]
  1171. )               adr     r1, closeDown1
  1172. :               str     r1, [r12, #DT_WimpPollRoutine%]
  1173. #               blVS    retError
  1174. ?; Set Flags_Remove% for each drive to get them to shut down
  1175. 5               ldr     rDrive, [r12, #DT_Drives%]
  1176. %.loop          teq     rDrive, #0
  1177. %               bEQ     closeDown0
  1178. 3               ldr     r9, [rDrive, #OD_Flags%]
  1179. 2               tst     r9, #Flags_FinalRemove%
  1180. 2               orrEQ   r9, r9, #Flags_Removed%
  1181. 3               strEQ   r9, [rDrive, #OD_Flags%]
  1182. 6               ldr     rDrive, [rDrive, #OD_Next%]
  1183.                b       loop
  1184. /.closeDown0    bl      processDrivesPending
  1185. ,; Give chance to recreate original icons
  1186. 5.closeDown1    ldr     rDrive, [r12, #DT_Drives%]
  1187. %               teq     rDrive, #0
  1188. %               bEQ     closeDown3
  1189. `               adr     r14, closeDown1                  ; Set up return address just in case
  1190. '               ldr     r0, PollMask
  1191. I               orr     r0, r0, #1                     ; Mask out Null
  1192. .               add     r1, r12, #DT_Space%
  1193. 6               add     r3, r12, #DT_DrivesPending%
  1194. '               swi     "XWimp_Poll"
  1195. $               bVS     wimpError
  1196. L               teq     r0, #13                        ; PollWord_NonZero
  1197. /               bEQ     processDrivesPending
  1198. H               teq     r0, #17                        ; User_Message
  1199. Q               teqNE   r0, #18                        ; User_Message_Recorded
  1200. (               ldrEQ   r2, [r1, #16]
  1201. H               teqEQ   r2, #0                         ; Message_Quit
  1202. %               bNE     closeDown1
  1203. ; Now finally Exit
  1204. 5.closeDown3    ldr     r0, [r12, #DT_TaskHandle%]
  1205. #               ldr     r1, TASK
  1206. ,               swi     "XWimp_CloseDown"
  1207. !               mov     r0, #0
  1208. 5               str     r0, [r12, #DT_TaskHandle%]
  1209. ,; Delete our module for testing purposes
  1210. -               
  1211. adrl(" ", 3, titleString)
  1212. *               swi     "OS_ExitAndDie"
  1213. P.ProtoCreateIcon equd -5: equd 0: equd -16: equd -1: equd 60: equd &1700212B
  1214. h; Used if Vset on swi DescribeDisc, assume disc itself is corrupted. '*' is illegal disc name char!!
  1215. 0.DiskError      equs "*Corrupt*" +bl$: align
  1216. *; Redirect mouseclick to original task
  1217. &.mouseclick    add     r0, r1, #12
  1218. U               ldmia   r0, {r0, r2}                   ;*r0 == window ;*r2 == icon
  1219. X               cmn     r0, #2                         ; Is this the icon bar window?
  1220. d               bNE     wimpPoll                       ; >No  ***Exit*** Should not have received
  1221. Q               ldr     rDrive, [r12, #DT_Drives%]     ;*rDrive => Drive entry
  1222. S.loop          teq     rDrive, #0                      ; Is this a valid entry?
  1223. _               bEQ     wimpPoll                       ; >No  ***Exit*** Failed to find icon
  1224. 2               ldr     r0, [rDrive, #OD_Icon%]
  1225. Y               teq     r0, r2                         ; Is this for the correct icon?
  1226. [               ldrNE   rDrive, [rDrive, #OD_Next%]    ; >No  Advance to next drive enty
  1227. K               bNE     loop                           ;      Process it
  1228. L; If MENU pressed then ignore -Click test (by Kade Hansson, many thanks)
  1229. O               ldr     r0, [r1, #8]                   ; Load button pressed
  1230. S               teq     r0, #2                         ; Was it the menu button?
  1231. &               bEQ     mouseclick0
  1232. <; If drive has -Click on then set to update icon display
  1233. 3               ldr     r9, [rDrive, #OD_Flags%]
  1234. P               tst     r9, #Flags_Click%              ; Is -Click switch on?
  1235. R               orrNE   r9, r9, #Flags_FullProcess%    ; >Yes Update drive icon
  1236. 3               strNE   r9, [rDrive, #OD_Flags%]
  1237. (; Send message to original task/icon
  1238. 5.mouseclick0   ldr     r0, [rDrive, #OD_OldIcon%]
  1239. (               str     r0, [r1, #16]
  1240. G               mov     r0, #6                         ; Mouse_Click
  1241. 2               ldr     r2, [rDrive, #OD_Task%]
  1242. Y               teq     r2, #0                         ; Is there a valid task handle?
  1243. d               swiNE   "XWimp_SendMessage"            ; >Yes So inform real owners of mouseclick
  1244. #               bVC     wimpPoll
  1245. $               bVS     wimpError
  1246. V.dataSave      ldr     r3, [r1, #24]                  ;*r3 == icon bar icon handle
  1247. 5               ldr     rDrive, [r12, #DT_Drives%]
  1248. %.loop          teq     rDrive, #0
  1249. #               bEQ     wimpPoll
  1250. 2               ldr     r0, [rDrive, #OD_Icon%]
  1251. !               teq     r0, r3
  1252. 6               ldrNE   rDrive, [rDrive, #OD_Next%]
  1253.                bNE     loop
  1254. 3               ldr     r9, [rDrive, #OD_Flags%]
  1255. ,               tst     r9, #Flags_Click%
  1256. 5               orrNE   r9, r9,#Flags_FullProcess%
  1257. $               blNE    testDrive
  1258. 3               strNE   r9, [rDrive, #OD_Flags%]
  1259. A               tst     r9, #Flags_DiscCorrupt% + Flags_Empty%
  1260. W               swiNE   XOS_WriteI + 7                ; >Yes Little feedback to user
  1261. $               bVS     wimpError
  1262. e               bNE     wimpPoll                      ;      ***Exit*** @Can't save to empty drive
  1263. 3               add     r0, r12, #44  +DT_Space%
  1264. 3               add     r1, r12, #192 +DT_Space%
  1265. !               bL      strcpy
  1266. 3               add     r1, r12, #44  +DT_Space%
  1267. (               bL      drivePathname
  1268. &               mov     r0, #
  1269. (".")
  1270. (               strB    r0, [r1, #-1]
  1271. 3               add     r0, r12, #192 +DT_Space%
  1272. !               bL      strcpy
  1273. .               add     r0, r12, #DT_Space%
  1274. J               sub     r1, r1, r0                     ; Message length
  1275. n               add     r1, r1, #3 + 1                 ; Align message length to word (also add terminator)
  1276. %               bic     r1, r1, #3
  1277.     R               str     r1, [r12, #0 +DT_Space%]       ; Store new message size
  1278. !               mov     r1, r0
  1279. '               ldr     r0, [r1, #8]
  1280. M               str     r0, [r1, #12]                  ; your_ref = my_ref
  1281. O               mov     r0, #2                         ; Message_DataSaveAck
  1282. (               str     r0, [r1, #16]
  1283. H               mov     r0, #17                        ; User_Message
  1284. X               ldr     r2, [r1, #4]                   ; Return it to original sender
  1285. .               swi     "XWimp_SendMessage"
  1286. f               mvnVC   r0, #1                         ; Mark a DataSave for future DataLoad mesage
  1287. 3               strVC   r0, [r12, #DT_DataLoad%]
  1288. #               bVC     wimpPoll
  1289. $               bVS     wimpError
  1290. Q; Used by filer to inform us of the number of files it is going to give to us
  1291. (.filerSelection ldr    r0, [r1, #56]
  1292. (               ldr     r2, [r1, #60]
  1293. S               teq     r0, #0                         ; -ve value means trouble
  1294. S               teqPL   r2, #0                         ; -ve value means trouble
  1295. !               movMI   r0, #0
  1296. !               movMI   r2, #0
  1297. =               str     r0, [r12, #DT_FilerSelect_Column%]
  1298.  :               str     r2, [r12, #DT_FilerSelect_Row%]
  1299. !W               mov     r0, #0                         ; Start of selection DataLoad
  1300. "/               str r0, [r12, #DT_DataLoad%]
  1301. ##               b       wimpPoll
  1302. %:.FilerAction_Start equs    "Filer_Action" + bl$: align
  1303. 'O.dataLoad      ldr     r6, [r12, #DT_DataLoad%]       ;*r6 == present state
  1304. (R               cmn     r6, #2                         ; Did DataSave preceeded
  1305. )V               bEQ     dataload_ack                   ; >Yes Simply acknowledge it
  1306. *(; find drive which received dataLoad
  1307. +S               ldr     r2, [r1, #24]                  ; Destination icon handle
  1308. ,Y               ldr     rDrive, [r12, #DT_Drives%]     ;*rDrive => Current drive entry
  1309. -b.loop          teq     rDrive, #0                     ; Have we reached the end of our drives?
  1310. .h               bEQ     wimpPoll                       ; >Yes ***Exit*** @Should not have been inform
  1311. /2               ldr     r0, [rDrive, #OD_Icon%]
  1312. 0Y               teq     r0, r2                         ; DataLoad for this drive icon?
  1313. 1_               ldrNE   rDrive, [rDrive, #OD_Next%]    ; >No  So advance to next drive entry
  1314. 2K               bNE     loop                           ;      Process it
  1315. ; Test state of drive
  1316. 43               ldr     r9, [rDrive, #OD_Flags%]
  1317. 5,               tst     r9, #Flags_Click%
  1318. 66               orrNE   r9, r9, #Flags_FullProcess%
  1319. 7$               blNE    testDrive
  1320. 83               strNE   r9, [rDrive, #OD_Flags%]
  1321. 9A               tst     r9, #Flags_DiscCorrupt% + Flags_Empty%
  1322. :\               swiNE   XOS_WriteI + 7                 ; >Yes Give a little user feedback
  1323. ;$               bVS     wimpError
  1324. <f               bNE     wimpPoll                       ;      ***Exit*** @Can't save to empty drive
  1325. >R               cmp     r6, #0                         ; Test state of transfer
  1326. ?d               adrLE   r0, FilerAction_Start          ; >First Have to load up a new FilerAction
  1327. @,               swiLE   "XWimp_StartTask"
  1328. A$               bVS     wimpError
  1329. BW               strLE   r0, [r12, #DT_FilerAction_Task%];       Remember task handle
  1330. Ce               addGE   r2, r6, #1                     ; >Filer Record that the next file has been
  1331. DL               strGE   r2, [r12, #DT_DataLoad%]       ;        processed
  1332. EE               ldrGT   r0, [r12, #DT_FilerAction_Task%];>NotFirst
  1333. F$               bGT     dataLoad1
  1334. HR; Check to see if Shift key is pressed, if so then move rather than copy files
  1335. I)               mov r3, r0: mov r4, r1
  1336. JW               mov r0, #202: mov r1, #0:mov r2, #255: swi "XOS_Byte": blVS retError
  1337. Kd               tst r1, #%1000:movEQ r1, #0: movNE r1, #6: str r1, [r12, #DT_FilerAction_Reason%]
  1338. L)               mov r0, r3: mov r1, r4
  1339. M:                                                      
  1340. NR.dataLoad1     add     r1, r1, #44                    ;*r1 => pathname of file
  1341. O!               mov     r2, r1
  1342. PQ.loop          ldrB    r3, [r2], #1                   ;.Go to end of pathname
  1343. Q&               cmp     r3, #
  1344. (" ")
  1345.                bGE     loop
  1346. SM               mov     r8, r2                         ;*r8 => message end
  1347. Th.loop          ldrB    r3, [r2, #-1]!                 ;.RSearch for first directory separator marker
  1348. U&               teq     r3, #
  1349. (".")
  1350.                bNE     loop
  1351. W!               mov     r3, #0
  1352. X[               strB    r3, [r2], #1                   ; Terminate path just before leaf
  1353. Z^               cmp     r6, #0                         ; Is this the first file to process?
  1354. [_               swiLE   "XFilerAction_SendSelectedDirectory"; >Yes So have to send directory
  1355. \I               movVC   r1, r2                         ; Send the leaf
  1356. ]:               swiVC   "XFilerAction_SendSelectedFile"
  1357. ^$               bVS     wimpError
  1358. _.; Read the current filer options from CMOS
  1359. `!               mov     r3, r0
  1360. aX               mov     r0, #161                       ; read battery-backed CMOS RAM
  1361. bI               mov     r1, #198                       ; Desktop state
  1362. c%               swi     "XOS_Byte"
  1363. d#               blVS    retError
  1364. e!               mov     r0, #0
  1365. fC               tst     r2, #1 << 6                    ; Verbose
  1366. g*               orrNE   r0, r0, #%00001
  1367. hC               tst     r2, #1 << 5                    ; Conform
  1368. i*               orrNE   r0, r0, #%00010
  1369. jA               tst     r2, #1 << 4                    ; Force
  1370. k*               orrNE   r0, r0, #%00100
  1371. lA               tst     r2, #1 << 7                    ; Newer
  1372. m*               orrNE   r0, r0, #%01000
  1373. nC               mov     r2, r0                         ; Options
  1374. o!               mov     r0, r3
  1375. q3               add     r1, r12, #192 +DT_Space%
  1376. r(               bL      drivePathname
  1377. s3               add     r3, r12, #192 +DT_Space%
  1378. t[               sub     r4, r1, r3                     ; Length of destination directory
  1379. uT               ldr     r1, [r12, #DT_FilerAction_Reason%]; Operation reason code
  1380. wR               cmp     r6, #0                         ; Is this a one off file
  1381. x]               bMI     dataLoad2                      ; >Yes So ignore test for moe files
  1382. yO; Check column/row range to see if Filer will send us more files to process
  1383. z_               add     r8, r8, #3                     ; Set message length to multiple of 4
  1384. {%               bic     r8, r8, #3
  1385. |a               ldr     r5, [r12, #DT_FilerSelect_Column%]; Maximum column of files to process
  1386. }V               ldr     r7, [r8], #4                   ; Load current column number
  1387. ~T               cmp     r7, r5                         ; At the limit of columns?
  1388. \               ldrHS   r5, [r12, #DT_FilerSelect_Row%]; >Yes Max row of files to process
  1389. #               ldrHS   r7, [r8]
  1390. !               cmpHS   r7, r5
  1391. b               bLO     wimpPoll                       ; Still more files to come so ***Exit***
  1392. <.dataLoad2     swi     "XFilerAction_SendStartOperation"
  1393. $               bVS     wimpError
  1394. ,; Acknowledge that we have loaded a file
  1395. Q.dataload_ack  mov     r5, #0                         ; Re-initialize markers
  1396. =               str     r5, [r12, #DT_FilerSelect_Column%]
  1397. :               str     r5, [r12, #DT_FilerSelect_Row%]
  1398. I               mvn     r5, #0                          ; No selection
  1399. ;               str     r5, [r12, #DT_DataLoad%]        
  1400. H               mov     r0, #17                        ; User_Message
  1401. .               add     r1, r12, #DT_Space%
  1402. '               ldr     r2, [r1, #8]
  1403. L               str     r2, [r1, #12]                  ; you_ref = my_ref
  1404. O               mov     r2, #4                         ; Message_DataLoadAck
  1405. (               str     r2, [r1, #16]
  1406. '               ldr     r2, [r1, #4]
  1407. .               swi     "XWimp_SendMessage"
  1408. #               bVC     wimpPoll
  1409. $               bVS     wimpError
  1410. O; Attempts to open a drives directory display          *rDrive => OverBlock
  1411. /.filerOpen     stmfd   r13!, {r0 - r2, r14}
  1412. .               add     r1, r12, #DT_Space%
  1413. !               mov     r0, #0
  1414. G               str     r0, [r1, #12]                  ; == your_ref
  1415. @               str     r0, [r1, #24]                  ; bits
  1416. P               mov     r0, #&400                      ; Message_FilerOpenDir
  1417. (               str     r0, [r1, #16]
  1418. 6               ldr     r0, [rDrive, #OD_FSNumber%]
  1419. (               str     r0, [r1, #20]
  1420. O               add     r1, r1, #28                    ;*r1 => direcory name
  1421. (               bL      drivePathname
  1422. .               add     r0, r12, #DT_Space%
  1423. %               sub     r1, r1, r0
  1424. %               add     r1, r1, #3
  1425. %               bic     r1, r1, #3
  1426. '               str     r1, [r0, #0]
  1427. !               mov     r1, r0
  1428. "               mov     r0, #17
  1429. R               mov     r2, #0                         ; Broadcast to all tasks
  1430. .               swi     "XWimp_SendMessage"
  1431. #               blVS    retError
  1432. /               ldmfd   r13!, {r0 - r2, pc}^
  1433. H.modeChange    mvn     r0, #0                         ; Current mode
  1434. F               mov     r1, #4                         ; XEigfactor
  1435. 1               swi     "XOS_ReadModeVariable"
  1436. $               bVS     wimpError
  1437. 5               ldr     r0, [r12, #DT_XEigfactor%]
  1438. h               teq     r0, r2                         ; Has the XEigfactor changed over mode change?
  1439. ^               bEQ     wimpPoll                       ; >No ***Exit*** No action necessary
  1440. 5               str     r2, [r12, #DT_XEigfactor%]
  1441. 5               ldr     rDrive, [r12, #DT_Drives%]
  1442. %.loop          teq     rDrive, #0
  1443. #               bEQ     wimpPoll
  1444. 3               ldr     r9, [rDrive, #OD_Flags%]
  1445. 6               orr     r9, r9, #Flags_FullProcess%
  1446. _               bic     r9, r9, #Flags_ModeSame%       ; Mark that we have just changed mode
  1447. [               bl      spriteSize                     ; New size of sprite in this mode
  1448. X               str     r9, [rDrive, #OD_Flags%]       ; Store new set of drive flags
  1449. [               ldr     rDrive, [rDrive, #OD_Next%]    ; Advance to the next drive entry
  1450. F               b       loop                           ; Process it
  1451. L; Checks to see if one of the tasks we are interested in has closed down
  1452. \.checkCloseDown ldr    r0, [r1, #4]                   ;*r0 == task which has closed down
  1453. Y                ldr    rDrive, [r12, #DT_Drives%]     ;*rDrive => Current drive entry
  1454. R                mov    r2, #0                         ;*r2 == null task handle
  1455. V.loop           teq    rDrive, #0                     ; Are there any drives left?
  1456. K                bEQ    wimpPoll                       ; >No  ***Exit***
  1457. 2                ldr    r1, [rDrive, #OD_Task%]
  1458. V                teq    r0, r1                         ; Is this task closing down?
  1459. Q                strEQ  r2, [rDrive, #OD_Task%]        ; >Yes So mark it as so
  1460. 6                ldr    rDrive, [rDrive, #OD_Next%]
  1461.                 b      loop
  1462. /; Creates full pathname for root on a drive
  1463. O; Entry r1 => start ; Exit r1 => end                  ;*rDrive => OverBlock
  1464. +.drivePathname  stmfd   r13!, {r0, r14}
  1465. 3                add     r0, rDrive, #OD_FSName%
  1466. "                bl      strcpy
  1467. I                mov r0, #
  1468. (":"): strB r0, [r1], #1: strB r0, [r1], #1
  1469. 2                add     r0, rDrive, #OD_IName%
  1470. "                bl      strcpy
  1471. 6                mov r0, #
  1472. ("."): strB r0, [r1], #1
  1473. 6                mov r0, #
  1474. ("$"): strB r0, [r1], #1
  1475. C                mov r0, #     0  : strB r0, [r1], #1  ; BIZARRE
  1476. +                ldmfd   r13!, {r0, pc}^
  1477. '.SFloppydisc equs "floppydisc" +bl$
  1478. ..SHarddisc   equs "harddisc"   +bl$: align
  1479. F; Calculate width of the current drive entry sprite (current mode)
  1480. ; Entry rDrive, r9
  1481. /.spriteSize    stmfd   r13!, {r0 - r7, r14}
  1482. S               mov     r0, #40                        ; Read sprite information
  1483. e               add     r2, rDrive, #OD_ISprite% +1    ; Sprite name, after inital 'S' in indirect
  1484. +               swi     "XWimp_SpriteOp"
  1485. e               bVC     spriteSize1                    ; Was the sprite found? >Yes Jump past this
  1486. 1               tst     r9, #Flags_SprCorrupt%
  1487. :               blNE    retError                       
  1488. b               orrEQ   r9, r9, #Flags_SprCorrupt%     ; Mark that we have bodged a sprite name
  1489. a               tst     r9, #Flags_Hard%               ; What type of drive do we think it is?
  1490. Y               adrEQ   r0, SFloppydisc                ;} both of these sprites should
  1491. e               adrNE   r0, SHarddisc                  ;} exist as they are put of the ROM sprites
  1492. O               add     r1, rDrive, #OD_ISprite% +1    ; Set new sprite name
  1493. !               bl      strcpy
  1494. 6               add     r2, rDrive, #OD_ISprite% +1
  1495. S               mov     r0, #40                        ; Read sprite information
  1496. +               swi     "XWimp_SpriteOp"
  1497. R.spriteSize1   movVC   r0, #&100                      ; Pointer to sprite name
  1498. L               movVC   r1, #1                         ; Wimp sprite area
  1499. O               addVC   r6, r12, #DT_Space%            ; Scale factors block
  1500. W               movVC   r7, #0                         ; No colour translation table
  1501. /               swiVC   "XWimp_ReadPixTrans"
  1502. /               ldmVSfd r13!, {r0 - r7, pc}^
  1503. 5               ldr     r2, [r12, #DT_XEigfactor%]
  1504. )               mov     r3, r3, LSL r2
  1505. '               ldr     r0, [r6, #0]
  1506. %               mul     r0, r3, r0
  1507. '               ldr     r1, [r6, #8]
  1508.                bL      udiv
  1509. 4               str     r0, [rDrive, #OD_SWidth%]
  1510. 4               ldr     r1, [rDrive, #OD_IWidth%]
  1511. !               cmp     r0, r1
  1512. 4               strGT   r0, [rDrive, #OD_IWidth%]
  1513. .               ldmfd  r13!, {r0 - r7, pc}^
  1514.     &; Load word from unknown alignment
  1515. ; Entry r0 => from
  1516. (; Exit  r0 => from  r1 == word value
  1517. *.loadWord      stmfd   r13!, {r2 - r3}
  1518. %               bic     r2, r0, #3
  1519. '               ldmia   r2, {r1, r3}
  1520. %               and     r2, r0, #3
  1521. )               movS    r2, r2, LSL #3
  1522. )               movNE   r1, r1, LSR r2
  1523. &               rsbNE   r2, r2, #32
  1524. -               orrNE   r1, r1, r3, LSL r2
  1525. *               ldmFD   r13!, {r2 - r3}
  1526. "               movS    pc, r14
  1527. !; Simple string copy function
  1528.  ; Entry r0 => from; r1 => to
  1529. /; Exit  r0 => from; r1 => 0 terminate of to
  1530. -.strcpy        stmfd  r13!, {r0, r2, r14}
  1531. &.loop          ldrB   r2, [r0], #1
  1532. %               cmp    r2, #
  1533. (" ")
  1534. &               strB   r2, [r1], #1
  1535.                bGE    loop
  1536.  $               sub    r1, r1, #1
  1537. !-               ldmfd  r13!, {r0, r2, pc}^
  1538. ; Simple string compare
  1539. $!; Entry r0 =>one    r1 => two
  1540. ; Exit LT/EQ/GT set
  1541. &/.strcmp        stmfd   r13!, {r0 - r3, r14}
  1542. ''.loop          ldrB    r2, [r0], #1
  1543. ('               ldrB    r3, [r1], #1
  1544. )!               cmp     r2, r3
  1545. *.               ldmNEfd r13!, {r0 - r3, pc}
  1546. +R               cmp     r2, #32                        ; String terminated yet?
  1547. ,U               bGE     loop                           ; >No  So process next char
  1548. -I               cmp     r2, r2                         ; Ensure EQ set
  1549. ..               ldmfd   r13!, {r0 - r3, pc}
  1550. 1!; r0 
  1551.  r1 = r0 ; r0 
  1552.  r1 = r1
  1553. 2/.udiv          stmfd   r13!, {r2 - r3, r14}
  1554. 3!               mov     r3, r1
  1555. 4)               cmp     r3, r0, LSR #1
  1556. 5).loop          movLS   r3, r3, LSL #1
  1557. 6)               cmp     r3, r0, LSR #1
  1558.                bLS     loop
  1559. 8!               mov     r2, #0
  1560. 9!.loop          cmp     r0, r3
  1561. :%               subCS   r0, r0, r3
  1562. ;%               adc     r2, r2, r2
  1563. <)               mov     r3, r3, lsr #1
  1564. =!               cmp     r3, r1
  1565.                bHS     loop
  1566. ?!               mov     r1, r0
  1567. @!               mov     r0, r2
  1568. A/               ldmfd   r13!, {r2 - r3, pc}^
  1569. defineMemory(A%)
  1570. fill(0, A%)
  1571. equsPadWithTo(string$, pad%, length%)
  1572.  This stores the string$. Ensuring it is pad% terminated, and altogether
  1573.  takes length% bytes. (Pads all with pad%)
  1574.  short$, temp$
  1575. O#short$ = 
  1576. string$, length% - 1)
  1577. [OPT pass%: equs short$:]
  1578. Q,temp$ = 
  1579. fill(pad%, length% - 
  1580. (short$))
  1581. fill(byte, count)
  1582.  This fills in count bytes with the value in byte
  1583.  loop
  1584.  count = 0 
  1585. Z%   
  1586.  "Assigning zero space here!"
  1587.    =""
  1588.  loop = 1 
  1589.  count
  1590.    [ OPT pass%
  1591.          equb byte
  1592.  loop
  1593. [ OPT pass%
  1594.       ALIGN
  1595. copy(from%, to%, using%)
  1596. [ OPT pass%
  1597. k..copy          ldrB    using%, [from%], #1
  1598. l,               strB    using%, [to%], #1
  1599. m&               cmp     using%, #32
  1600.                bGE     copy
  1601. ]: =""
  1602. adrl(c$,r%,addr%)
  1603.  c%,df%,byte_lo%,byte_hi%,opcode1%,opcode2%
  1604.  addr%=P% 
  1605.  (pass% 
  1606.  12)=0 
  1607.  P%+=8:O%+=8:=0
  1608. (addr%-P%)<256 
  1609. error("ADRL failed: Address within range when setting R"+
  1610.  r%+" to "+
  1611.  addr%,-1)
  1612. (addr%-P%)>65535 
  1613. error("ADRL failed: Address outside range when setting R"+
  1614.  r%+" to "+
  1615.  addr%,-1)
  1616.  c$=" " 
  1617.  c$="" c$="AL"
  1618. w.c%=
  1619. "EQNECSCCMIPLVSVCHILSGELTGTLEALNV",c$)
  1620.  c%=0 
  1621. error("ADRL failed: ARM condition code not recognized when setting R"+
  1622.  r%+" to "+
  1623.  addr%,-1) 
  1624.  c%=(c%-1) 
  1625. df%=addr%-P%-8
  1626. byte_lo%=
  1627. (df%) 
  1628. byte_hi%=
  1629. (df%) 
  1630.  &FF00
  1631.  df%>=0 
  1632. }3  opcode1%=(c%<<28)+&028F0000+(r%<<12)+byte_lo%
  1633. ~A  opcode2%=(c%<<28)+&02800C00+(r%<<16)+(r%<<12)+(byte_hi%>>8)
  1634. 3  opcode1%=(c%<<28)+&024F0000+(r%<<12)+byte_lo%
  1635. A  opcode2%=(c%<<28)+&02400C00+(r%<<16)+(r%<<12)+(byte_hi%>>8)
  1636. ,[OPT pass%:EQUD opcode1%:EQUD opcode2%:]
  1637. stmfd r13!, {r0 - r3}: swi &104: mov r0, r4: sub r1, r13, #20: mov r2, #16: swi "OS_ConvertInteger4":swi "OS_Write0":swi &100 + 
  1638. ("*"): swi &105: ldmfd r13!, {r0 - r3}
  1639.