; Armalyser analysis of IDEFS::HardDisc.$.Utils.Mouse.!Scaler.MouseScale

; Generated by Armalyser 0.43c (27-Jan-2003)
; From IDEFS::HardDisc.$.Utils.Mouse.!Scaler.MouseScale
; Assemble with ObjAsm -ABSolute and link with Link -bin
; Set file type of output file to &FFA

; 2.05 27-Jan-2003 First 32bit rev
; 2.06 21-Apr-2007 Added service call table

OS_Module                        EQU &00001E
OS_Byte                          EQU &000006
OS_AddToVector                   EQU &000047
OS_GenerateError                 EQU &00002B
OS_Release                       EQU &000020
OS_ExitAndDie                    EQU &000050

        ORG      &0

        ENTRY

|L00000000.Module_Header.Offset|
        DCD     &00000000                        ; Start offset
        DCD     |L0000007C.Initialisation_code|  ; Initialisation offset
        DCD     |L00000194.Finalisation_code|    ; Finalisation offset
        DCD     |L00000344.Service_call_handler_code| ; Service call handler offset
        DCD     |L0000002C.String|               ; Title string offset -> "MouseScaler"
        DCD     |L00000038.String|               ; Help string offset  -> "Mouse Scaler	2.04 (19 Aug 1994) by Nick Jarman and Roger Spooner"
        DCD     &00000000                        ; Help and command keyword table offset
        DCD     &00000000                        ; SWI chunk base number
        DCD     &00000000                        ; SWI handler code offset
        DCD     &00000000                        ; SWI decoding table offset
        DCD     &00000000                        ; SWI decoding code offset
        DCD     &00000000                        ; MessageTrans filename
        DCD     |ModuleFlags.Word|               ; Module flags word

|ModuleFlags.Word|
        DCD     &00000001

|L0000002C.String|
        DCB     "MouseScaler",0                  ; String -/- (referenced)
|L00000038.String|
        DCB     "Mouse Scaler\t2.06 (21-Apr-2007) [32bit] by Nick Jarman and Roger Spooner" ; String -/- (referenced)
        DCB     0,0,0,0                          ; String -/-

|L0000007C.Initialisation_code|
        CMP     R12,#0                           ; Entry Point, (alters flags), Initialisation code, (Referenced)
        MOVEQ   PC,R14                           ; Function exit if EQ
        STMFD   R13!,{R0-R4,R14}
        MOV     R0,#6
        MOV     R3,#&20                          ; =" " (32)
        SWI     OS_Module
        STR     R2,[R12,#0]
        MOV     R12,R2
        MOV     R0,#&81                          ; ="" (129)
        MOV     R1,#0
        MOV     R2,#&FF                          ; ="" (255)
        SWI     OS_Byte
        MOV     R0,#0
        CMP     R1,#&A1                          ; ="" (161)
        CMPNE   R1,#&AA
        MOVEQ   R0,#&5A0                         ; =&5A0
        ADDEQ   R0,R0,#4
        CMP     R1,#&A4                          ; ="" (164)
        MOVEQ   R0,#&5B0                         ; =&5B0
        ADDEQ   R0,R0,#4
        CMP     R1,#&A5                          ; ="" (165)
        CMPNE   R1,#&A6                          ; ="" (165)
        CMPNE   R1,#&A7                          ; ="" (165)
        CMPNE   R1,#&A8                          ; ="" (165)
        CMPNE   R1,#&A9                          ; ="" (165)
        MOVEQ   R0,#&5A0                         ; =&5A0
        CMP     R0,#0
        BEQ     |L0000017C|
        STR     R0,[R12,#&01C]                   ; =28
        LDR     R1,[R0,#0]
        STR     R1,[R12,#0]
        LDR     R1,[R0,#4]
        STR     R1,[R12,#4]
        MOV     R0,#&10                          ; =16
        ADR     R1,|L000001FC.EventV|            ; -> Func: EventV (alters flags)
        MOV     R2,R12
        SWI     OS_AddToVector
        MOV     R0,#7
        ADR     R1,|L000001D8.WordV|             ; -> Func: WordV (alters flags)
        SWI     OS_AddToVector
        MOV     R0,#&0E                          ; =14
        MOV     R1,#4
        SWI     OS_Byte
        BL      |L00000300|
        MOV     R0,#1
        STR     R0,[R12,#&018]                   ; =24
        LDMFD   R13!,{R0-R4,PC}                  ; Function exit, Ends

|L00000124.Error_Block|
        DCD     &00004242                        ; Error Block Word r/- (referenced)
        DCB     "Mouse Scaler cannot initialise - it is not compatible with this " ; Error Block String -/-
        DCB     "version of RISC OS",0,0

|L0000017C|
        ADR     R0,|L00000124.Error_Block|       ; -> Error Block Word: &00004242
        SWI     OS_GenerateError                 ; Ends

|L00000184|
        MOV     R1,#0
        MOV     R2,#0
        ADR     R3,|L0000002C.String|
        SWI     OS_ExitAndDie

|L00000194.Finalisation_code|
        STMFD   R13!,{R14}                       ; Entry Point, (alters flags), Finalisation code, (Referenced)
        MOV     R0,#&0D                          ; =13
        MOV     R1,#4
        SWI     OS_Byte
        MOV     R2,R12
        LDR     R12,[R12,#0]
        MOV     R2,R12
        MOV     R0,#&10                          ; =16
        ADR     R1,|L000001FC.EventV|            ; -> Func: EventV (alters flags)
        SWI     OS_Release
        MOV     R0,#7
        ADR     R1,|L000001D8.WordV|             ; -> Func: WordV (alters flags)
        SWI     OS_Release
        MOV     R0,#7
        MOV     R2,R12
        SWI     OS_Module
        LDMFD   R13!,{PC}                        ; Function exit, Ends

|L000001D8.WordV|
        STMFD   R13!,{R0-R11,R14}                ; Entry Point, (alters flags), WordV, (Referenced)
        CMP     R0,#&15                          ; =21
        LDMNEFD R13!,{R0-R11,PC}                 ; CAUTION: conditional LDM/STM maybe slow. Function exit if NE
        LDRB    R0,[R1,#0]
        CMP     R0,#3
        LDMNEFD R13!,{R0-R11,PC}                 ; CAUTION: conditional LDM/STM maybe slow. Function exit if NE
        MOV     R0,#4
        STR     R0,[R12,#&018]                   ; =24
        LDMFD   R13!,{R0-R11,PC}                 ; Function exit, Ends

|L000001FC.EventV|
        STMFD   R13!,{R0-R11,R14}                ; Entry Point, (alters flags), EventV, (Referenced)
        LDR     R11,[R12,#&01C]                  ; =28
        LDR     R0,[R12,#&018]                   ; =24
        CMP     R0,#0
        SUBNE   R0,R0,#1
        STRNE   R0,[R12,#&018]                   ; =24
        BNE     |L00000228|
        BL      |L00000300|
        LDR     R0,[R12,#&018]                   ; =24
        CMP     R0,#0
        BEQ     |L0000023C|
|L00000228|
        LDR     R0,[R11,#0]
        STR     R0,[R12,#0]
        LDR     R0,[R11,#4]
        STR     R0,[R12,#4]
        LDMFD   R13!,{R0-R11,PC}                 ; Function exit, Ends
|L0000023C|
        LDR     R0,[R11,#0]
        LDR     R1,[R12,#0]
        STR     R0,[R12,#0]
        CMP     R0,R1
        BEQ     |L0000029C|
        SUBGT   R2,R0,R1
        MOVGT   R3,#0
        SUBLT   R2,R1,R0
        MOVLT   R3,#1
        MOV     R1,R0
        MOV     R5,R2,LSR #2
        MUL     R4,R2,R5
        MOV     R2,R4
        CMP     R3,#0
        ADDEQ   R1,R1,R2
        SUBNE   R1,R1,R2
        LDR     R5,[R12,#8]
        CMP     R1,R5
        MOVLT   R1,R5
        LDR     R5,[R12,#&010]                   ; =16
        CMP     R1,R5
        MOVGT   R1,R5
        STR     R1,[R11,#0]
        STR     R1,[R12,#0]
|L0000029C|
        LDR     R0,[R11,#4]
        LDR     R1,[R12,#4]
        STR     R0,[R12,#4]
        CMP     R0,R1
        BEQ     |L000002FC|
        SUBGT   R2,R0,R1
        MOVGT   R3,#0
        SUBLT   R2,R1,R0
        MOVLT   R3,#1
        MOV     R1,R0
        MOV     R5,R2,LSR #2
        MUL     R4,R2,R5
        MOV     R2,R4
        CMP     R3,#0
        ADDEQ   R1,R1,R2
        SUBNE   R1,R1,R2
        LDR     R5,[R12,#&00C]                   ; =12
        CMP     R1,R5
        MOVLT   R1,R5
        LDR     R5,[R12,#&014]                   ; =20
        CMP     R1,R5
        MOVGT   R1,R5
        STR     R1,[R11,#4]
        STR     R1,[R12,#4]
|L000002FC|
        LDMFD   R13!,{R0-R11,PC}                 ; Function exit, Ends

|Service_Table|
        DCD     0                                ; flags word
        DCD     |Service2|
        DCD     &46                              ; reasons of interest
        DCD     0                                ; table end
        DCD     |Service_Table|                  ; offset to service table for ursula

|L00000344.Service_call_handler_code|
        MOV     R0,R0                            ; magic word for new Ursula table
        TEQ     R1,#&46                          ; pre-rejection code
        MOVNE   PC,R14                           ; Function exit if NE
|Service2|
        LDR     R12,[R12,#0]
|L00000300|
        STMFD   R13!,{R0-R9,R14}                 ; Function entry, (alters flags)
        LDR     R0,[R12,#&01C]                   ; =28
        ADD     R0,R0,#&18                       ; =24
        ADD     R1,R12,#8
        LDMIA   R0,{R2-R5}
        LDMIA   R1,{R6-R9}
        CMP     R2,R6
        CMPEQ   R3,R7
        CMPEQ   R4,R8
        CMPEQ   R5,R9
        STMNEIA R1,{R2-R5}                       ; CAUTION: conditional LDM/STM maybe slow.
        MOVNE   R0,#1
        MOVEQ   R0,#0
        LDR     R1,[R12,#&018]                   ; =24
        CMP     R1,#0
        STREQ   R0,[R12,#&018]                   ; =24
        LDMFD   R13!,{R0-R9,PC}                  ; Function exit, Ends

        END

