home *** CD-ROM | disk | FTP | other *** search
- TTL BootAutil - send message to BootA
-
- ;*===================================================================*
- ;* *
- ;* BootAutil - send message to BootA *
- ;* --------- *
- ;* *
- ;* Version 1.00 *
- ;* Paul Witheridge - 15 December 1991 *
- ;* *
- ;* *
- ;* This application sends a message to BootA to request one of the *
- ;* following actions: *
- ;* *
- ;* *
- ;* (1) A client application's icon be replaced by a different *
- ;* sprite: *
- ;* *
- ;* e.g. *BootAutil -sprite newname *
- ;* *
- ;* (2) A client application's icon be removed (equivalent to 'quit' *
- ;* on the BootA client menu: *
- ;* *
- ;* e.g. *BootAutil -quit *
- ;* *
- ;* The client application is identified by is icon handle which *
- ;* BootA stores in the system variable 'BootA$Handle' before it *
- ;* runs the client application. Alternatively, the client's icon *
- ;* handle can be specified on the command line: *
- ;* *
- ;* e.g. *BootAutil -sprite newname -handle <myvar> *
- ;* *BootAutil -quit -handle <myvar> *
- ;* *
- ;* but since the icon handle is an internal code, this would only *
- ;* be useful where the client application had copied BootA$Handle *
- ;* into its own system variable in order to preserve it. *
- ;* *
- ;* Note that any sprite replacing the original sprite installed on *
- ;* the icon bar for a client application should be no larger than *
- ;* that original sprite. *
- ;* *
- ;* The command to run BootAutil should be incorporated in the *
- ;* !RunA obey file for the client application. Since BootAutil is *
- ;* technically an application and uses the application work area, *
- ;* issuing directly from the client application will result in the *
- ;* client application being overlaid. *
- ;* *
- ;*-------------------------------------------------------------------*
- ;* *
- ;* COPYRIGHT NOTICE *
- ;* *
- ;* BootAutil is subject to Copyright. *
- ;* *
- ;* Permission is granted by the author to any recipient of this *
- ;* material to use and make/disseminate copies of the application *
- ;* provided that no charges are made for doing so (other than to *
- ;* cover any cost of media or postage) and that this notice is *
- ;* included with all copies. *
- ;* *
- ;*===================================================================*
-
- ;*-------------------------------------------------------------------*
- ;* Define symbolic registers *
- ;*-------------------------------------------------------------------*
-
- r0 RN 0
- r1 RN 1
- r2 RN 2
- r3 RN 3
- r4 RN 4
- r5 RN 5
- r6 RN 6
- r7 RN 7
- r8 RN 8
- r9 RN 9
- r10 RN 10
- r11 RN 11
- r12 RN 12
- r13 RN 13
- r14 RN 14
- r15 RN 15
- pc RN 15
-
- ;*-------------------------------------------------------------------*
- ;* Define symbolic SWI numbers *
- ;*-------------------------------------------------------------------*
-
- bit_17 EQU 1 << 17
-
- OS_WriteC EQU &00
- XOS_WriteC EQU bit_17 + OS_WriteC
-
- OS_WriteI EQU &100
- XOS_WriteI EQU bit_17 + OS_WriteI
-
- OS_WriteS EQU &01
- XOS_WriteS EQU bit_17 + OS_WriteS
-
- OS_Write0 EQU &02
- XOS_Write0 EQU bit_17 + OS_Write0
-
- OS_NewLine EQU &03
- XOS_NewLine EQU bit_17 + OS_NewLine
-
- OS_Byte EQU &06
- XOS_Byte EQU bit_17 + OS_Byte
-
- OS_GetEnv EQU &10
- XOS_GetEnv EQU bit_17 + OS_GetEnv
-
- OS_Exit EQU &11
-
- OS_EvaluateExpression EQU &2D
- XOS_EvaluateExpression EQU bit_17 + OS_EvaluateExpression
-
- OS_ReadArgs EQU &49
- XOS_ReadArgs EQU bit_17 + OS_ReadArgs
-
- Wimp_Initialise EQU &400C0
- XWimp_Initialise EQU bit_17 + Wimp_Initialise
-
- Wimp_Poll EQU &400C7
- XWimp_Poll EQU bit_17 + Wimp_Poll
-
- Wimp_CloseDown EQU &400DD
- XWimp_CloseDown EQU bit_17 + Wimp_CloseDown
-
- Wimp_ReportError EQU &400DF
- XWimp_ReportError EQU bit_17 + Wimp_ReportError
-
- Wimp_SendMessage EQU &400E7
- XWimp_SendMessage EQU bit_17 + Wimp_SendMessage
-
- ;*-------------------------------------------------------------------*
- ;* Define Wimp_Poll reason codes *
- ;*-------------------------------------------------------------------*
-
- Null_Reason_Code EQU 0
- ReDraw_Window_Request EQU 1
- Open_Window_Request EQU 2
- Close_Window_Request EQU 3
- Pointer_Leaving_Window EQU 4
- Pointer_Entering_Window EQU 5
- Mouse_Click EQU 6
- User_Drag_Box EQU 7
- Key_Pressed EQU 8
- Menu_Selection EQU 9
- Scroll_Request EQU 10
- Lose_Caret EQU 11
- Gain_Caret EQU 12
- User_Message EQU 17
- User_Message_Recorded EQU 18
- User_Message_Acknowledge EQU 19
-
- ;*-------------------------------------------------------------------*
- ;* Define layout of work area (follows end of assembled program) *
- ;*-------------------------------------------------------------------*
-
- ^ 0,r12
- wrkthndl # 4 ; Wimp task handle
- wrkbforg # 0 ; Start of buffer for ReadArgs
- wrkbfrun # 4 ; Pointer to *RUN
- wrkbffil # 4 ; Pointer to file name
- wrkbfqut # 4 ; Switch for -quit argument
- wrkbfspr # 4 ; Pointer to -sprite argument
- wrkbfhdl # 4 ; Pointer to -handle argument
- wrkbftxt # 80 ; Argument output area
- wrkbfend # 0 ; End of ReadArgs buffer
- wrkbfsiz EQU wrkbfend - wrkbforg ; Length of ReadArgs buffer
- wrkmsorg # 0 ; Start of wimp message block.
- wrkmslen # 4 ; Block length
- wrkmstsk # 4 ; Task handle (not used)
- wrkmsyrf # 4 ; Your ref (not used)
- wrkmsmrf # 4 ; My ref (set to zero)
- wrkmsact # 4 ; Message action code
- wrkmshdl # 4 ; Icon handle stored here
- wrkmsspr # 16 ; Sprite name stored here
- wrkmsend # 0 ; End of message block.
- wrkmssiz EQU wrkmsend - wrkmsorg ; Length of message block.
-
- ;*-------------------------------------------------------------------*
- ;* Entry from caller. Establish addressability to data areas *
- ;*-------------------------------------------------------------------*
-
- util BL database ; Go set up reg.11 --> data
- ; reg.12 --> work
-
- ;*-------------------------------------------------------------------*
- ;* Get address of command string and set up stack pointer. *
- ;*-------------------------------------------------------------------*
-
- SWI XOS_GetEnv ; Get address of command string
- BVS errexit ; Go exit if error occurred.
-
- MOV r13,r1 ; Set up stack.
-
- ;*-------------------------------------------------------------------*
- ;* Use ReadArgs to analyse command line *
- ;*-------------------------------------------------------------------*
-
- ADR r2,wrkbforg ; Invoke OS_ReadArgs to parse
- MOV r1,r0 ; command line (pointed to by
- ADD r0,r11,#keydefn ; reg.0 on return from GetEnv).
- MOV r3,#wrkbfsiz
- SWI XOS_ReadArgs
- BVS errexit ; Go exit if error.
-
- ;*-------------------------------------------------------------------*
- ;* Check either "-quit" or "-sprite" but not both specified *
- ;*-------------------------------------------------------------------*
-
- LDR r2,wrkbfqut ; Set reg.2 to zero if '-quit'
- MOVS r2,r2 ; not specified, or to one if
- MOVNE r2,#1 ; it is specified. Do likewise
- LDR r3,wrkbfspr ; for reg.3 and '-sprite'. Use
- MOVS r3,r3 ; exclusive OR to test if both
- MOVNE r3,#1 ; or neither specified.
- EORS r0,r2,r3
-
- ADDEQ r0,r11,#badparm ; If so exit with error
- BEQ errexit ; message.
-
- ;*-------------------------------------------------------------------*
- ;* Obtain BootA handle from parameters or system variable *
- ;*-------------------------------------------------------------------*
-
- LDR r0,wrkbfhdl ; Check if '-handle' argument
- MOVS r0,r0 ; specified. If not, use default
- ADDEQ r0,r11,#varname ; value of <BootA$Handle>.
-
- ADR r1,wrkmsorg ; Handle should be integer.
- MOV r2,#16
- SWI XOS_EvaluateExpression
- BVS errexit
- MOVS r1,r1 ; Evaluate. Take error exit
- ADDNE r0,r11,#badhndl ; if not integer.
- BNE errexit
-
- STR r2,wrkmshdl ; Else save handle value.
-
- ;*-------------------------------------------------------------------*
- ;* Sign on to Wimp manager so we can send a message to BootA. *
- ;*-------------------------------------------------------------------*
-
- MOV r0,#200 ; Register as task so that
- LDR r1,task ; we can send message to
- ADD r2,r11,#taskid ; BootA and then check that
- SWI XWimp_Initialise ; it was actually received.
- BVS errexit
- STR r1,wrkthndl
-
- ;*-------------------------------------------------------------------*
- ;* Initialise message block *
- ;*-------------------------------------------------------------------*
-
- MOV r0,#wrkmssiz ; Block length
- STR r0,wrkmslen
- MOV r0,#0 ; Your ref (0 for original msg)
- STR r0,wrkmsyrf
- LDR r9,msgactn ; Action code &211172 for
- LDR r1,wrkbfspr ; sprite name change or &211173
- MOVS r1,r1 ; for quit request.
- ADDEQ r9,r9,#1
- STR r9,wrkmsact ; Reg.9 = action code
- BEQ util0020
- LDRB r3,[r1],#2 ; New sprite name if request
- ADR r2,wrkmsspr ; to change sprite.
- MOVS r3,r3
- util0010 LDRPLB r0,[r1],#1
- STRPLB r0,[r2],#1
- SUBPLS r3,r3,#1
- BPL util0010
- STRB r3,[r2],#1
-
- ;*-------------------------------------------------------------------*
- ;* Send message to creator of sprite (i.e. BootA) *
- ;*-------------------------------------------------------------------*
-
- util0020 MOV r0,#User_Message ; Use reason code 17.
- ADR r1,wrkmsorg
- MOV r2,#-2 ; Addressee is creator of
- LDR r3,wrkmshdl ; sprite on icon bar.
- SWI XWimp_SendMessage
- BVC util0030
-
- ADD r2,r11,#taskid ; If send failed report
- MOV r1,#0 ; error message.
- SWI XWimp_ReportError
-
- ;*-------------------------------------------------------------------*
- ;* Perform Wimp Poll to let BootA do its stuff *
- ;*-------------------------------------------------------------------*
-
- util0030 LDR r0,pollmask ; Perform Wimp Poll loop until
- ADR r1,wrkmsorg ; reason code 0 is returned.
- SWI XWimp_Poll
- BVS util0040
- TEQ r0,#0
- BNE util0030
-
- ;*-------------------------------------------------------------------*
- ;* Sign off from Wimp manager and exit. *
- ;*-------------------------------------------------------------------*
-
- util0040 LDR r0,wrkthndl ; Use our task handle
- LDR r1,task ; specifically just in case.
- SWI XWimp_CloseDown
- BVS errexit
-
- MOV r2,#0 ; Exit and set zero
- util0050 LDR r1,abex ; return code.
- MOV r0,#0
- SWI OS_Exit
-
- ;*-------------------------------------------------------------------*
- ;* Issue error message and exit (reg.0 points to error block) *
- ;*-------------------------------------------------------------------*
-
- errexit ADD r2,r11,#taskid ; Use Wimp_ReportError to
- MOV r1,#0 ; issue error message.
- SWI XWimp_ReportError
- MOV r2,#4
- B util0050
-
- ;*-------------------------------------------------------------------*
- ;* Data areas *
- ;*-------------------------------------------------------------------*
-
- task DCB "TASK"
- abex DCB "ABEX"
- msgactn DCD &211172 ; Message action code.
- pollmask DCD 2_11100001100101110010
-
- database ADR r11,dataorg ; Establish reg.11 as base
- ADR r12,wrkarea ; register for data and
- MOV pc,r14 ; reg.12 for work area.
- dataorg
-
- ALIGN
- badparm * . - dataorg
- DCD 0
- DCB "either '-quit' or '-sprite' parameter "
- DCB "required (but not both)",0
-
- ALIGN
- badhndl * . - dataorg
- DCD 0
- DCB "bad handle"
-
- taskid * . - dataorg
- DCB "BootAutil",0
-
- keydefn * . - dataorg
- DCB ",,quit/S,sprite/K/G,handle/K",0
-
- varname * . - dataorg
- DCB "<BootA$Handle>",0
-
- ALIGN
- wrkarea
-
- END
-