REM >LineUpSrc REM REM One way to pass the small hours... : DIM module 2048 FOR pass=12 TO 14 STEP 2 P%=0:O%=module:L%=O%+2048 [OPT pass : EQUD 0 ; start EQUD init EQUD final EQUD 0 ; service EQUD title EQUD help EQUD 0 ; commands : .title EQUS "LineUp":EQUB 0 ALIGN .help EQUS "LineUp":EQUB 9:EQUB 9:EQUS "1.00 (27 Jul 1997)":EQUB 13:EQUB 13 EQUS "This module arranges the icons on your icon bar according to " EQUS "the priorities file specified by ." EQUB 0 ALIGN .error_wimpswive_not_loaded EQUD 0:EQUS "WimpSWIVe module is not loaded (is this module separate" EQUS "from the !LineUp application?)":EQUB 0 ALIGN .error_no_settings_file EQUD 0:EQUS "Couldn't find settings file , or " EQUS "variable hasn't been set (is this module separate from the " EQUS "!LineUp application?)":EQUB 0 .settings_filename EQUS "":EQUB 0 ALIGN .wswi_word EQUS "WSWI" : .init STMFD R13!,{R7-R8,R14} : LDR R0,wswi_word MOV R1,#2 ; SWI &400C0 + 2 -- Wimp_Createicon ORR R1,R1,#1<<31 ; bit 31 set -- claim MOV R2,R12 ADR R3,wimp_createicon_pretrap MOV R4,#0 SWI "XWimp_RegisterFilter" ADRVS R0,error_wimpswive_not_loaded LDMVSFD R13!,{R7-R8,PC} : LDR R0,wswi_word MOV R1,#0 ; SWI &400C0 + 0 -- Wimp_Initialise ORR R1,R1,#1<<31 MOV R2,R12 MOV R3,#0 ADR R4,wimp_initialise_posttrap SWI "XWimp_RegisterFilter" : LDR R0,wswi_word MOV R1,#&1D ; SWI &400C0 + &1D -- Wimp_CloseDown ORR R1,R1,#1<<31 MOV R2,R12 ADR R3,wimp_closedown_pretrap MOV R4,#0 SWI "XWimp_RegisterFilter" : MOV R0,#&43 ; Open file with read access ADR R1,settings_filename SWI "XOS_Find" MOVVS R0,#0 CMP R0,#0 ADREQ R0,error_no_settings_file LDMEQFD R13!,{R7-R8,R14} ORREQS PC,R14,#1<<28 ; Return, setting V flag MOV R6,R0 ; Keep file handle in R6 for now : MOV R0,#6 MOV R3,#2048 ; 2k should be enough for around 160 apps SWI "XOS_Module" LDMVSFD R13!,{PC} STR R2,[R12] ; Store workspace pointer in our private word LDR R12,[R12] ; R12 now points to our real workspace MOV R0,#0 MOV R1,#0 MOV R2,#0 MOV R3,#0 MOV R4,R12 MOV R5,#2048 .zero_workspace_loop ; Quickly blank workspace (for debugging, mainly) STMIA R4!,{R0-R3} SUBS R5,R5,#16 BNE zero_workspace_loop : ADD R7,R12,#2048 SUB R7,R7,#80 ; Use 80 bytes at end for scratch space ; (80, then, is the maximum line length in the ; settings file) : .read_line MOV R2,R7 ; R2 > scratch space .read_line_loop MOV R0,#4 ; R0 = 4 (read from file) MOV R1,R6 ; R1 = file handle MOV R3,#1 ; 1 byte at a time... SWI "XOS_GBPB"; R2 is updated accordingly after this call BCS finished_reading ; Carry set on end-of-file LDRB R5,[R2,#-1] ; Check last byte read CMP R5,#9 MOVEQ R5,#0 STREQB R5,[R2,#-1] ; Convert tabs to zero-bytes CMP R5,#10 ; Newline character transferred? BNE read_line_loop ; Loop round if not : MOV R4,R7 ; R4 > start of line we've read in LDRB R0,[R4] CMP R0,#ASC"#" CMPNE R0,#10 ; Slip comments / blank lines BEQ read_line .read_name_crc_loop LDRB R0,[R4],#1 CMP R0,#0 BNE read_name_crc_loop MOV R0,#0 MOV R1,R7 MOV R2,R4 MOV R3,#1 SWI "OS_CRC" ; Find CRC of task name STR R0,[R12],#4 ; and store it in the workspace : .skip_padding_loop LDRB R0,[R4],#1 CMP R0,#0 BEQ skip_padding_loop SUB R4,R4,#1 : MOV R0,#16 MOV R1,R4 SWI "OS_ReadUnsigned" ; Read position STR R2,[R12],#4 ; (store) ADD R1,R1,#1 SWI "OS_ReadUnsigned" ; Read priority STR R2,[R12],#4 ; (store) : B read_line ; Read next line of settings file : .finished_reading MOV R0,#0 MOV R1,R6 SWI "XOS_Find" ; Close settings file MVN R0,#0 STR R0,[R12] ; Use -1 to mark end of list : LDMFD R13!,{R7-R8,PC} : .final STMFD R13!,{R14} ; As initialisation, but in reverse... : LDR R0,wswi_word MOV R1,#2 MOV R2,R12 ADR R3,wimp_createicon_pretrap MOV R4,#0 SWI "XWimp_RegisterFilter" : LDR R0,wswi_word MOV R1,#0 ; SWI &400C0 + 0 -- Wimp_Initialise MOV R2,R12 MOV R3,#0 ADR R4,wimp_initialise_posttrap SWI "XWimp_RegisterFilter" : LDR R0,wswi_word MOV R1,#&1D ; SWI &400C0 + &1D -- Wimp_CloseDown MOV R2,R12 ADR R3,wimp_closedown_pretrap MOV R4,#0 SWI "XWimp_RegisterFilter" : MOV R0,#7 LDR R2,[R12] SWI "XOS_Module" : LDMFD R13!,{PC} : .wimp_createicon_pretrap STMFD R13!,{R0-R3,R14} LDR R2,[R1] CMP R2,#0 ; Don't bother unless we're on the icon bar LDMGEFD R13!,{R0-R3,PC}^ : LDR R12,[R12] ADD R1,R12,#2048 SUB R1,R1,#20 ; Use 20 bytes at end of workspace for message : MOV R0,#0 STR R0,[R1,#12] ; yourref = 0 (original message) MOV R0,#20 STR R0,[R1,#0] ; message block size = 20 MOV R0,#19 ; UserMessageAcknowledge MOV R2,#0 ; broadcast message (doesn't matter actually) SWI "Wimp_SendMessage" LDR R0,[R1,#4] ; fills in current task's handle in R1+4 ; so R0 now = current task handle : ADD R1,R12,#1024 ADD R1,R1,#4 .find_crc_from_handle_loop LDR R2,[R1],#8 CMP R2,#0 BEQ no_match CMP R0,R2 BNE find_crc_from_handle_loop LDR R0,[R1,#-12] : .compare_tasks_loop LDR R1,[R12],#12 CMN R1,#0 ; End of list? BEQ no_match CMP R0,R1 BNE compare_tasks_loop LDMFD R13!,{R0-R3,R14} : LDR R0,[R12,#-4] ; Patch icon position and priority LDR R12,[R12,#-8] RSB R12,R12,#0 STR R12,[R1] MOVS PC,R14 : .no_match LDMFD R13!,{R0-R3,PC} : .wimp_initialise_posttrap STMFD R13!,{R0-R4,R14} MOV R4,R1 ; R4 = task handle MOV R1,R2 .count_task_name_loop LDRB R0,[R2],#1 CMP R0,#32 BGE count_task_name_loop MOV R0,#0 MOV R3,#1 SWI "OS_CRC" ; R0 = CRC value of task name : LDR R12,[R12] ADD R12,R12,#1024 .find_space_loop ; Find space to store new task name & handle LDR R1,[R12],#8 CMP R1,#0 BNE find_space_loop STR R0,[R12,#-8] STR R4,[R12,#-4] LDMFD R13!,{R0-R4,PC} : .wimp_closedown_pretrap STMFD R13!,{R0-R4,R14} LDR R12,[R12] ADD R12,R12,#1024 ADD R12,R12,#4 .find_dying_task_loop ; Look for currently closing down task in list LDR R1,[R12],#8 CMP R1,#0 BEQ dying_task_not_found CMP R1,R0 BNE find_dying_task_loop MOV R0,#0 STR R0,[R12,#-12] STR R0,[R12,#-8] .dying_task_not_found LDMFD R13!,{R0-R4,PC} ]:NEXT SYS "OS_File",10,".LineUp",&FFA,0,module,O%