Home » Archimedes archive » Acorn Computing » 1993 06 Mega Disk.adf » 93_06 » Miscellany/SolidDrag/!SolidDrag/Source/drag_src2

Miscellany/SolidDrag/!SolidDrag/Source/drag_src2

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Acorn Computing » 1993 06 Mega Disk.adf » 93_06
Filename: Miscellany/SolidDrag/!SolidDrag/Source/drag_src2
Read OK:
File size: 1623 bytes
Load address: 0000
Exec address: 0000
File contents
; > drag_src
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
sp RN 13
lr RN 14
pc RN 15

Wimp_DragBox            EQU &400D0
XWimp_GetPointerInfo    EQU &600CF
XWimp_GetIconState      EQU &600CE
XDragASprite_Start      EQU &62400
XDragASprite_Stop       EQU &62401
XOS_AddCallBack         EQU &20054
V_FLAG                  EQU 1:SHL:28

module_base
        DCD     0
        DCD     initialise - module_base
        DCD     finalise - module_base
        DCD     0
        DCD     title_string - module_base
        DCD     help_string - module_base
        DCD     0


; ---------------------------------------------------------------------------------------------------------

initialise
        STMFD   sp!, {lr}
        BL      claim_swi_vector
        LDMFD   sp!, {pc}

; ---------------------------------------------------------------------------------------------------------

finalise
        STMFD   sp!, {lr}
        BL      release_swi_vector
        LDMFD   sp!, {pc}^

; ---------------------------------------------------------------------------------------------------------

title_string
        DCB     "AutoDrag",0

help_string
        DCB     "AutoDrag ",9,"0.10 (09 Sep 1992)",0
        ALIGN

; ---------------------------------------------------------------------------------------------------------

release_swi_vector
        MOV     r0, #8
        LDR     r1, [r0]
        LDR     r2, new_branch                  ; check that our SWI decoder hasn't been replaced
        CMP     r1, r2
        LDREQ   r1, old_branch                  ; replace original decoder if it hasn't
        STREQ   r1, [r0]
        MOVEQ   r0, #0
        STREQ   r1, old_branch
        MOVEQS  pc, lr

        ADR   r0, error_block                 ; otherwise return an error
        ORRS  pc, lr, #V_FLAG

error_block     DCD     &103
                DCB     "Can't detach SWI handler", 0
                ALIGN

; ---------------------------------------------------------------------------------------------------------

claim_swi_vector
        MOV     r0, #8
        LDR     r0, [r0]                        ; get branch to SWI handler
        STR     r0, old_branch

        ADR     r1, second_branch-8             ; insert in our own code
        SUB     r0, r0, r1, LSR #2
        STR     r0, second_branch

        ADD     r0, r0, #(second_branch-first_branch) / 4
        SUB     r0, r0, #&D0000000
        STR     r0, first_branch                ; convert to a BNE

        MOV     r1, #8
        ADR     r0, swi_patch-8-8
        MOV     r0, r0, LSR #2
        ADD     r0, r0, #&EA000000
        STR     r0, [r1]
        STR     r0, new_branch                  ; put in a branch to our code

        MOV     pc, lr

; ---------------------------------------------------------------------------------------------------------

swi_patch
        STMFD   sp!,{lr}
        BIC     lr, lr, #&FC000003
        LDR     lr, [lr,#-4]                    ; get SWI instruction

        BIC     lr, lr, #&FF000000
        BIC     lr, lr, #&20000
        SUB     lr, lr, #&40000
        CMP     lr, #&D0                        ; is it Wimp_DragBox ?

        LDMNEFD sp!, {lr}                       ; otherwise drop through to SWI handler
first_branch
        DCD     0

        LDR     lr, [r1,#4]                     ; get drag type
        CMP     lr, #5
        BNE     continue                        ; check it's the right sort of drag

        STMFD   sp!,{r0,r1}
        ADR     r0, callback_code               ; value in r1 appears in r12 in CallBack routine
        SWI     XOS_AddCallBack
        LDMFD   sp!,{r0,r1,pc}^
        
        MOVS    pc, lr

continue
        LDMFD sp!, {lr}                         ; call Wimp_DragBox as usual
second_branch
        DCD     0

sprite_name
        DCB     "!edit",0
        ALIGN

workspace
        %       256


callback_code
        STMFD   sp!,{r0-r4,lr}
        ADR     r1, workspace
        SWI     XWimp_GetPointerInfo
        ADD     r1, r1, #12
        SWI     XWimp_GetIconState              ; get data block for icon under the pointer

        LDR     r3, [r1, #24]
        TST     r3, #2                          ; if it's not a sprite then do nothing
        BEQ     not_sprite

        TST     r3, #256                        ; is it indirected ?
        BNE     indirected

        ADD     r2, r1, #28                     ; sprite name directly specified
        MOV     r1, #1
        B       do_drag

indirected
        TST     r3, #1
        BNE     text_and_sprite
        LDR     r3, [r1, #36]                   ; get indirected sprite name length
        LDR     r2, [r1, #28]
        LDR     r1, [r1, #32]

        CMP     r3, #0                          ; if length = 0 then r2 points to start of sprite
        ADDEQ   r2, r2, #4
        B       do_drag

text_and_sprite
        LDR     r2, [r1, #32]
        
find_start
        LDRB    r3, [r2], #1
        CMP     r3, #'S'
        CMPNE   r3, #'s'
        BNE     find_start
        MOV     r1, #1

do_drag
        MOV     r0, #128+64+32+4+1
        ADD     r3, r12, #8
        ADD     r4, r12, #24        
        SWI     XDragASprite_Start
not_sprite
        LDMFD   sp!,{r0-r4,pc}^

; ---------------------------------------------------------------------------------------------------------

lr_store        DCD     0                       ; register storage for SWI decoder
old_branch      DCD     0                       ; branch to original SWI decoder
new_branch      DCD     0                       ; branch to our new SWI decoder                               

   END
00000000  3b 20 3e 20 64 72 61 67  5f 73 72 63 0a 72 30 20  |; > drag_src.r0 |
00000010  52 4e 20 30 0a 72 31 20  52 4e 20 31 0a 72 32 20  |RN 0.r1 RN 1.r2 |
00000020  52 4e 20 32 0a 72 33 20  52 4e 20 33 0a 72 34 20  |RN 2.r3 RN 3.r4 |
00000030  52 4e 20 34 0a 72 35 20  52 4e 20 35 0a 72 36 20  |RN 4.r5 RN 5.r6 |
00000040  52 4e 20 36 0a 72 37 20  52 4e 20 37 0a 72 38 20  |RN 6.r7 RN 7.r8 |
00000050  52 4e 20 38 0a 72 39 20  52 4e 20 39 0a 72 31 30  |RN 8.r9 RN 9.r10|
00000060  20 52 4e 20 31 30 0a 72  31 31 20 52 4e 20 31 31  | RN 10.r11 RN 11|
00000070  0a 72 31 32 20 52 4e 20  31 32 0a 73 70 20 52 4e  |.r12 RN 12.sp RN|
00000080  20 31 33 0a 6c 72 20 52  4e 20 31 34 0a 70 63 20  | 13.lr RN 14.pc |
00000090  52 4e 20 31 35 0a 0a 57  69 6d 70 5f 44 72 61 67  |RN 15..Wimp_Drag|
000000a0  42 6f 78 20 20 20 20 20  20 20 20 20 20 20 20 45  |Box            E|
000000b0  51 55 20 26 34 30 30 44  30 0a 58 57 69 6d 70 5f  |QU &400D0.XWimp_|
000000c0  47 65 74 50 6f 69 6e 74  65 72 49 6e 66 6f 20 20  |GetPointerInfo  |
000000d0  20 20 45 51 55 20 26 36  30 30 43 46 0a 58 57 69  |  EQU &600CF.XWi|
000000e0  6d 70 5f 47 65 74 49 63  6f 6e 53 74 61 74 65 20  |mp_GetIconState |
000000f0  20 20 20 20 20 45 51 55  20 26 36 30 30 43 45 0a  |     EQU &600CE.|
00000100  58 44 72 61 67 41 53 70  72 69 74 65 5f 53 74 61  |XDragASprite_Sta|
00000110  72 74 20 20 20 20 20 20  45 51 55 20 26 36 32 34  |rt      EQU &624|
00000120  30 30 0a 58 44 72 61 67  41 53 70 72 69 74 65 5f  |00.XDragASprite_|
00000130  53 74 6f 70 20 20 20 20  20 20 20 45 51 55 20 26  |Stop       EQU &|
00000140  36 32 34 30 31 0a 58 4f  53 5f 41 64 64 43 61 6c  |62401.XOS_AddCal|
00000150  6c 42 61 63 6b 20 20 20  20 20 20 20 20 20 45 51  |lBack         EQ|
00000160  55 20 26 32 30 30 35 34  0a 56 5f 46 4c 41 47 20  |U &20054.V_FLAG |
00000170  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000180  20 45 51 55 20 31 3a 53  48 4c 3a 32 38 0a 0a 6d  | EQU 1:SHL:28..m|
00000190  6f 64 75 6c 65 5f 62 61  73 65 0a 20 20 20 20 20  |odule_base.     |
000001a0  20 20 20 44 43 44 20 20  20 20 20 30 0a 20 20 20  |   DCD     0.   |
000001b0  20 20 20 20 20 44 43 44  20 20 20 20 20 69 6e 69  |     DCD     ini|
000001c0  74 69 61 6c 69 73 65 20  2d 20 6d 6f 64 75 6c 65  |tialise - module|
000001d0  5f 62 61 73 65 0a 20 20  20 20 20 20 20 20 44 43  |_base.        DC|
000001e0  44 20 20 20 20 20 66 69  6e 61 6c 69 73 65 20 2d  |D     finalise -|
000001f0  20 6d 6f 64 75 6c 65 5f  62 61 73 65 0a 20 20 20  | module_base.   |
00000200  20 20 20 20 20 44 43 44  20 20 20 20 20 30 0a 20  |     DCD     0. |
00000210  20 20 20 20 20 20 20 44  43 44 20 20 20 20 20 74  |       DCD     t|
00000220  69 74 6c 65 5f 73 74 72  69 6e 67 20 2d 20 6d 6f  |itle_string - mo|
00000230  64 75 6c 65 5f 62 61 73  65 0a 20 20 20 20 20 20  |dule_base.      |
00000240  20 20 44 43 44 20 20 20  20 20 68 65 6c 70 5f 73  |  DCD     help_s|
00000250  74 72 69 6e 67 20 2d 20  6d 6f 64 75 6c 65 5f 62  |tring - module_b|
00000260  61 73 65 0a 20 20 20 20  20 20 20 20 44 43 44 20  |ase.        DCD |
00000270  20 20 20 20 30 0a 0a 0a  3b 20 2d 2d 2d 2d 2d 2d  |    0...; ------|
00000280  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000002e0  2d 2d 2d 0a 0a 69 6e 69  74 69 61 6c 69 73 65 0a  |---..initialise.|
000002f0  20 20 20 20 20 20 20 20  53 54 4d 46 44 20 20 20  |        STMFD   |
00000300  73 70 21 2c 20 7b 6c 72  7d 0a 20 20 20 20 20 20  |sp!, {lr}.      |
00000310  20 20 42 4c 20 20 20 20  20 20 63 6c 61 69 6d 5f  |  BL      claim_|
00000320  73 77 69 5f 76 65 63 74  6f 72 0a 20 20 20 20 20  |swi_vector.     |
00000330  20 20 20 4c 44 4d 46 44  20 20 20 73 70 21 2c 20  |   LDMFD   sp!, |
00000340  7b 70 63 7d 0a 0a 3b 20  2d 2d 2d 2d 2d 2d 2d 2d  |{pc}..; --------|
00000350  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
000003b0  2d 0a 0a 66 69 6e 61 6c  69 73 65 0a 20 20 20 20  |-..finalise.    |
000003c0  20 20 20 20 53 54 4d 46  44 20 20 20 73 70 21 2c  |    STMFD   sp!,|
000003d0  20 7b 6c 72 7d 0a 20 20  20 20 20 20 20 20 42 4c  | {lr}.        BL|
000003e0  20 20 20 20 20 20 72 65  6c 65 61 73 65 5f 73 77  |      release_sw|
000003f0  69 5f 76 65 63 74 6f 72  0a 20 20 20 20 20 20 20  |i_vector.       |
00000400  20 4c 44 4d 46 44 20 20  20 73 70 21 2c 20 7b 70  | LDMFD   sp!, {p|
00000410  63 7d 5e 0a 0a 3b 20 2d  2d 2d 2d 2d 2d 2d 2d 2d  |c}^..; ---------|
00000420  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000480  0a 0a 74 69 74 6c 65 5f  73 74 72 69 6e 67 0a 20  |..title_string. |
00000490  20 20 20 20 20 20 20 44  43 42 20 20 20 20 20 22  |       DCB     "|
000004a0  41 75 74 6f 44 72 61 67  22 2c 30 0a 0a 68 65 6c  |AutoDrag",0..hel|
000004b0  70 5f 73 74 72 69 6e 67  0a 20 20 20 20 20 20 20  |p_string.       |
000004c0  20 44 43 42 20 20 20 20  20 22 41 75 74 6f 44 72  | DCB     "AutoDr|
000004d0  61 67 20 22 2c 39 2c 22  30 2e 31 30 20 28 30 39  |ag ",9,"0.10 (09|
000004e0  20 53 65 70 20 31 39 39  32 29 22 2c 30 0a 20 20  | Sep 1992)",0.  |
000004f0  20 20 20 20 20 20 41 4c  49 47 4e 0a 0a 3b 20 2d  |      ALIGN..; -|
00000500  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000560  2d 2d 2d 2d 2d 2d 2d 2d  0a 0a 72 65 6c 65 61 73  |--------..releas|
00000570  65 5f 73 77 69 5f 76 65  63 74 6f 72 0a 20 20 20  |e_swi_vector.   |
00000580  20 20 20 20 20 4d 4f 56  20 20 20 20 20 72 30 2c  |     MOV     r0,|
00000590  20 23 38 0a 20 20 20 20  20 20 20 20 4c 44 52 20  | #8.        LDR |
000005a0  20 20 20 20 72 31 2c 20  5b 72 30 5d 0a 20 20 20  |    r1, [r0].   |
000005b0  20 20 20 20 20 4c 44 52  20 20 20 20 20 72 32 2c  |     LDR     r2,|
000005c0  20 6e 65 77 5f 62 72 61  6e 63 68 20 20 20 20 20  | new_branch     |
000005d0  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 63  |             ; c|
000005e0  68 65 63 6b 20 74 68 61  74 20 6f 75 72 20 53 57  |heck that our SW|
000005f0  49 20 64 65 63 6f 64 65  72 20 68 61 73 6e 27 74  |I decoder hasn't|
00000600  20 62 65 65 6e 20 72 65  70 6c 61 63 65 64 0a 20  | been replaced. |
00000610  20 20 20 20 20 20 20 43  4d 50 20 20 20 20 20 72  |       CMP     r|
00000620  31 2c 20 72 32 0a 20 20  20 20 20 20 20 20 4c 44  |1, r2.        LD|
00000630  52 45 51 20 20 20 72 31  2c 20 6f 6c 64 5f 62 72  |REQ   r1, old_br|
00000640  61 6e 63 68 20 20 20 20  20 20 20 20 20 20 20 20  |anch            |
00000650  20 20 20 20 20 20 3b 20  72 65 70 6c 61 63 65 20  |      ; replace |
00000660  6f 72 69 67 69 6e 61 6c  20 64 65 63 6f 64 65 72  |original decoder|
00000670  20 69 66 20 69 74 20 68  61 73 6e 27 74 0a 20 20  | if it hasn't.  |
00000680  20 20 20 20 20 20 53 54  52 45 51 20 20 20 72 31  |      STREQ   r1|
00000690  2c 20 5b 72 30 5d 0a 20  20 20 20 20 20 20 20 4d  |, [r0].        M|
000006a0  4f 56 45 51 20 20 20 72  30 2c 20 23 30 0a 20 20  |OVEQ   r0, #0.  |
000006b0  20 20 20 20 20 20 53 54  52 45 51 20 20 20 72 31  |      STREQ   r1|
000006c0  2c 20 6f 6c 64 5f 62 72  61 6e 63 68 0a 20 20 20  |, old_branch.   |
000006d0  20 20 20 20 20 4d 4f 56  45 51 53 20 20 70 63 2c  |     MOVEQS  pc,|
000006e0  20 6c 72 0a 0a 20 20 20  20 20 20 20 20 41 44 52  | lr..        ADR|
000006f0  20 20 20 72 30 2c 20 65  72 72 6f 72 5f 62 6c 6f  |   r0, error_blo|
00000700  63 6b 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |ck              |
00000710  20 20 20 3b 20 6f 74 68  65 72 77 69 73 65 20 72  |   ; otherwise r|
00000720  65 74 75 72 6e 20 61 6e  20 65 72 72 6f 72 0a 20  |eturn an error. |
00000730  20 20 20 20 20 20 20 4f  52 52 53 20 20 70 63 2c  |       ORRS  pc,|
00000740  20 6c 72 2c 20 23 56 5f  46 4c 41 47 0a 0a 65 72  | lr, #V_FLAG..er|
00000750  72 6f 72 5f 62 6c 6f 63  6b 20 20 20 20 20 44 43  |ror_block     DC|
00000760  44 20 20 20 20 20 26 31  30 33 0a 20 20 20 20 20  |D     &103.     |
00000770  20 20 20 20 20 20 20 20  20 20 20 44 43 42 20 20  |           DCB  |
00000780  20 20 20 22 43 61 6e 27  74 20 64 65 74 61 63 68  |   "Can't detach|
00000790  20 53 57 49 20 68 61 6e  64 6c 65 72 22 2c 20 30  | SWI handler", 0|
000007a0  0a 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |.               |
000007b0  20 41 4c 49 47 4e 0a 0a  3b 20 2d 2d 2d 2d 2d 2d  | ALIGN..; ------|
000007c0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000820  2d 2d 2d 0a 0a 63 6c 61  69 6d 5f 73 77 69 5f 76  |---..claim_swi_v|
00000830  65 63 74 6f 72 0a 20 20  20 20 20 20 20 20 4d 4f  |ector.        MO|
00000840  56 20 20 20 20 20 72 30  2c 20 23 38 0a 20 20 20  |V     r0, #8.   |
00000850  20 20 20 20 20 4c 44 52  20 20 20 20 20 72 30 2c  |     LDR     r0,|
00000860  20 5b 72 30 5d 20 20 20  20 20 20 20 20 20 20 20  | [r0]           |
00000870  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 67  |             ; g|
00000880  65 74 20 62 72 61 6e 63  68 20 74 6f 20 53 57 49  |et branch to SWI|
00000890  20 68 61 6e 64 6c 65 72  0a 20 20 20 20 20 20 20  | handler.       |
000008a0  20 53 54 52 20 20 20 20  20 72 30 2c 20 6f 6c 64  | STR     r0, old|
000008b0  5f 62 72 61 6e 63 68 0a  0a 20 20 20 20 20 20 20  |_branch..       |
000008c0  20 41 44 52 20 20 20 20  20 72 31 2c 20 73 65 63  | ADR     r1, sec|
000008d0  6f 6e 64 5f 62 72 61 6e  63 68 2d 38 20 20 20 20  |ond_branch-8    |
000008e0  20 20 20 20 20 20 20 20  20 3b 20 69 6e 73 65 72  |         ; inser|
000008f0  74 20 69 6e 20 6f 75 72  20 6f 77 6e 20 63 6f 64  |t in our own cod|
00000900  65 0a 20 20 20 20 20 20  20 20 53 55 42 20 20 20  |e.        SUB   |
00000910  20 20 72 30 2c 20 72 30  2c 20 72 31 2c 20 4c 53  |  r0, r0, r1, LS|
00000920  52 20 23 32 0a 20 20 20  20 20 20 20 20 53 54 52  |R #2.        STR|
00000930  20 20 20 20 20 72 30 2c  20 73 65 63 6f 6e 64 5f  |     r0, second_|
00000940  62 72 61 6e 63 68 0a 0a  20 20 20 20 20 20 20 20  |branch..        |
00000950  41 44 44 20 20 20 20 20  72 30 2c 20 72 30 2c 20  |ADD     r0, r0, |
00000960  23 28 73 65 63 6f 6e 64  5f 62 72 61 6e 63 68 2d  |#(second_branch-|
00000970  66 69 72 73 74 5f 62 72  61 6e 63 68 29 20 2f 20  |first_branch) / |
00000980  34 0a 20 20 20 20 20 20  20 20 53 55 42 20 20 20  |4.        SUB   |
00000990  20 20 72 30 2c 20 72 30  2c 20 23 26 44 30 30 30  |  r0, r0, #&D000|
000009a0  30 30 30 30 0a 20 20 20  20 20 20 20 20 53 54 52  |0000.        STR|
000009b0  20 20 20 20 20 72 30 2c  20 66 69 72 73 74 5f 62  |     r0, first_b|
000009c0  72 61 6e 63 68 20 20 20  20 20 20 20 20 20 20 20  |ranch           |
000009d0  20 20 20 20 20 3b 20 63  6f 6e 76 65 72 74 20 74  |     ; convert t|
000009e0  6f 20 61 20 42 4e 45 0a  0a 20 20 20 20 20 20 20  |o a BNE..       |
000009f0  20 4d 4f 56 20 20 20 20  20 72 31 2c 20 23 38 0a  | MOV     r1, #8.|
00000a00  20 20 20 20 20 20 20 20  41 44 52 20 20 20 20 20  |        ADR     |
00000a10  72 30 2c 20 73 77 69 5f  70 61 74 63 68 2d 38 2d  |r0, swi_patch-8-|
00000a20  38 0a 20 20 20 20 20 20  20 20 4d 4f 56 20 20 20  |8.        MOV   |
00000a30  20 20 72 30 2c 20 72 30  2c 20 4c 53 52 20 23 32  |  r0, r0, LSR #2|
00000a40  0a 20 20 20 20 20 20 20  20 41 44 44 20 20 20 20  |.        ADD    |
00000a50  20 72 30 2c 20 72 30 2c  20 23 26 45 41 30 30 30  | r0, r0, #&EA000|
00000a60  30 30 30 0a 20 20 20 20  20 20 20 20 53 54 52 20  |000.        STR |
00000a70  20 20 20 20 72 30 2c 20  5b 72 31 5d 0a 20 20 20  |    r0, [r1].   |
00000a80  20 20 20 20 20 53 54 52  20 20 20 20 20 72 30 2c  |     STR     r0,|
00000a90  20 6e 65 77 5f 62 72 61  6e 63 68 20 20 20 20 20  | new_branch     |
00000aa0  20 20 20 20 20 20 20 20  20 20 20 20 20 3b 20 70  |             ; p|
00000ab0  75 74 20 69 6e 20 61 20  62 72 61 6e 63 68 20 74  |ut in a branch t|
00000ac0  6f 20 6f 75 72 20 63 6f  64 65 0a 0a 20 20 20 20  |o our code..    |
00000ad0  20 20 20 20 4d 4f 56 20  20 20 20 20 70 63 2c 20  |    MOV     pc, |
00000ae0  6c 72 0a 0a 3b 20 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |lr..; ----------|
00000af0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000b40  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 0a  |---------------.|
00000b50  0a 73 77 69 5f 70 61 74  63 68 0a 20 20 20 20 20  |.swi_patch.     |
00000b60  20 20 20 53 54 4d 46 44  20 20 20 73 70 21 2c 7b  |   STMFD   sp!,{|
00000b70  6c 72 7d 0a 20 20 20 20  20 20 20 20 42 49 43 20  |lr}.        BIC |
00000b80  20 20 20 20 6c 72 2c 20  6c 72 2c 20 23 26 46 43  |    lr, lr, #&FC|
00000b90  30 30 30 30 30 33 0a 20  20 20 20 20 20 20 20 4c  |000003.        L|
00000ba0  44 52 20 20 20 20 20 6c  72 2c 20 5b 6c 72 2c 23  |DR     lr, [lr,#|
00000bb0  2d 34 5d 20 20 20 20 20  20 20 20 20 20 20 20 20  |-4]             |
00000bc0  20 20 20 20 20 20 20 3b  20 67 65 74 20 53 57 49  |       ; get SWI|
00000bd0  20 69 6e 73 74 72 75 63  74 69 6f 6e 0a 0a 20 20  | instruction..  |
00000be0  20 20 20 20 20 20 42 49  43 20 20 20 20 20 6c 72  |      BIC     lr|
00000bf0  2c 20 6c 72 2c 20 23 26  46 46 30 30 30 30 30 30  |, lr, #&FF000000|
00000c00  0a 20 20 20 20 20 20 20  20 42 49 43 20 20 20 20  |.        BIC    |
00000c10  20 6c 72 2c 20 6c 72 2c  20 23 26 32 30 30 30 30  | lr, lr, #&20000|
00000c20  0a 20 20 20 20 20 20 20  20 53 55 42 20 20 20 20  |.        SUB    |
00000c30  20 6c 72 2c 20 6c 72 2c  20 23 26 34 30 30 30 30  | lr, lr, #&40000|
00000c40  0a 20 20 20 20 20 20 20  20 43 4d 50 20 20 20 20  |.        CMP    |
00000c50  20 6c 72 2c 20 23 26 44  30 20 20 20 20 20 20 20  | lr, #&D0       |
00000c60  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000c70  20 3b 20 69 73 20 69 74  20 57 69 6d 70 5f 44 72  | ; is it Wimp_Dr|
00000c80  61 67 42 6f 78 20 3f 0a  0a 20 20 20 20 20 20 20  |agBox ?..       |
00000c90  20 4c 44 4d 4e 45 46 44  20 73 70 21 2c 20 7b 6c  | LDMNEFD sp!, {l|
00000ca0  72 7d 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |r}              |
00000cb0  20 20 20 20 20 20 20 20  20 3b 20 6f 74 68 65 72  |         ; other|
00000cc0  77 69 73 65 20 64 72 6f  70 20 74 68 72 6f 75 67  |wise drop throug|
00000cd0  68 20 74 6f 20 53 57 49  20 68 61 6e 64 6c 65 72  |h to SWI handler|
00000ce0  0a 66 69 72 73 74 5f 62  72 61 6e 63 68 0a 20 20  |.first_branch.  |
00000cf0  20 20 20 20 20 20 44 43  44 20 20 20 20 20 30 0a  |      DCD     0.|
00000d00  0a 20 20 20 20 20 20 20  20 4c 44 52 20 20 20 20  |.        LDR    |
00000d10  20 6c 72 2c 20 5b 72 31  2c 23 34 5d 20 20 20 20  | lr, [r1,#4]    |
00000d20  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000d30  20 3b 20 67 65 74 20 64  72 61 67 20 74 79 70 65  | ; get drag type|
00000d40  0a 20 20 20 20 20 20 20  20 43 4d 50 20 20 20 20  |.        CMP    |
00000d50  20 6c 72 2c 20 23 35 0a  20 20 20 20 20 20 20 20  | lr, #5.        |
00000d60  42 4e 45 20 20 20 20 20  63 6f 6e 74 69 6e 75 65  |BNE     continue|
00000d70  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000d80  20 20 20 20 20 20 20 20  3b 20 63 68 65 63 6b 20  |        ; check |
00000d90  69 74 27 73 20 74 68 65  20 72 69 67 68 74 20 73  |it's the right s|
00000da0  6f 72 74 20 6f 66 20 64  72 61 67 0a 0a 20 20 20  |ort of drag..   |
00000db0  20 20 20 20 20 53 54 4d  46 44 20 20 20 73 70 21  |     STMFD   sp!|
00000dc0  2c 7b 72 30 2c 72 31 7d  0a 20 20 20 20 20 20 20  |,{r0,r1}.       |
00000dd0  20 41 44 52 20 20 20 20  20 72 30 2c 20 63 61 6c  | ADR     r0, cal|
00000de0  6c 62 61 63 6b 5f 63 6f  64 65 20 20 20 20 20 20  |lback_code      |
00000df0  20 20 20 20 20 20 20 20  20 3b 20 76 61 6c 75 65  |         ; value|
00000e00  20 69 6e 20 72 31 20 61  70 70 65 61 72 73 20 69  | in r1 appears i|
00000e10  6e 20 72 31 32 20 69 6e  20 43 61 6c 6c 42 61 63  |n r12 in CallBac|
00000e20  6b 20 72 6f 75 74 69 6e  65 0a 20 20 20 20 20 20  |k routine.      |
00000e30  20 20 53 57 49 20 20 20  20 20 58 4f 53 5f 41 64  |  SWI     XOS_Ad|
00000e40  64 43 61 6c 6c 42 61 63  6b 0a 20 20 20 20 20 20  |dCallBack.      |
00000e50  20 20 4c 44 4d 46 44 20  20 20 73 70 21 2c 7b 72  |  LDMFD   sp!,{r|
00000e60  30 2c 72 31 2c 70 63 7d  5e 0a 20 20 20 20 20 20  |0,r1,pc}^.      |
00000e70  20 20 0a 20 20 20 20 20  20 20 20 4d 4f 56 53 20  |  .        MOVS |
00000e80  20 20 20 70 63 2c 20 6c  72 0a 0a 63 6f 6e 74 69  |   pc, lr..conti|
00000e90  6e 75 65 0a 20 20 20 20  20 20 20 20 4c 44 4d 46  |nue.        LDMF|
00000ea0  44 20 73 70 21 2c 20 7b  6c 72 7d 20 20 20 20 20  |D sp!, {lr}     |
00000eb0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00000ec0  20 20 20 20 3b 20 63 61  6c 6c 20 57 69 6d 70 5f  |    ; call Wimp_|
00000ed0  44 72 61 67 42 6f 78 20  61 73 20 75 73 75 61 6c  |DragBox as usual|
00000ee0  0a 73 65 63 6f 6e 64 5f  62 72 61 6e 63 68 0a 20  |.second_branch. |
00000ef0  20 20 20 20 20 20 20 44  43 44 20 20 20 20 20 30  |       DCD     0|
00000f00  0a 0a 73 70 72 69 74 65  5f 6e 61 6d 65 0a 20 20  |..sprite_name.  |
00000f10  20 20 20 20 20 20 44 43  42 20 20 20 20 20 22 21  |      DCB     "!|
00000f20  65 64 69 74 22 2c 30 0a  20 20 20 20 20 20 20 20  |edit",0.        |
00000f30  41 4c 49 47 4e 0a 0a 77  6f 72 6b 73 70 61 63 65  |ALIGN..workspace|
00000f40  0a 20 20 20 20 20 20 20  20 25 20 20 20 20 20 20  |.        %      |
00000f50  20 32 35 36 0a 0a 0a 63  61 6c 6c 62 61 63 6b 5f  | 256...callback_|
00000f60  63 6f 64 65 0a 20 20 20  20 20 20 20 20 53 54 4d  |code.        STM|
00000f70  46 44 20 20 20 73 70 21  2c 7b 72 30 2d 72 34 2c  |FD   sp!,{r0-r4,|
00000f80  6c 72 7d 0a 20 20 20 20  20 20 20 20 41 44 52 20  |lr}.        ADR |
00000f90  20 20 20 20 72 31 2c 20  77 6f 72 6b 73 70 61 63  |    r1, workspac|
00000fa0  65 0a 20 20 20 20 20 20  20 20 53 57 49 20 20 20  |e.        SWI   |
00000fb0  20 20 58 57 69 6d 70 5f  47 65 74 50 6f 69 6e 74  |  XWimp_GetPoint|
00000fc0  65 72 49 6e 66 6f 0a 20  20 20 20 20 20 20 20 41  |erInfo.        A|
00000fd0  44 44 20 20 20 20 20 72  31 2c 20 72 31 2c 20 23  |DD     r1, r1, #|
00000fe0  31 32 0a 20 20 20 20 20  20 20 20 53 57 49 20 20  |12.        SWI  |
00000ff0  20 20 20 58 57 69 6d 70  5f 47 65 74 49 63 6f 6e  |   XWimp_GetIcon|
00001000  53 74 61 74 65 20 20 20  20 20 20 20 20 20 20 20  |State           |
00001010  20 20 20 3b 20 67 65 74  20 64 61 74 61 20 62 6c  |   ; get data bl|
00001020  6f 63 6b 20 66 6f 72 20  69 63 6f 6e 20 75 6e 64  |ock for icon und|
00001030  65 72 20 74 68 65 20 70  6f 69 6e 74 65 72 0a 0a  |er the pointer..|
00001040  20 20 20 20 20 20 20 20  4c 44 52 20 20 20 20 20  |        LDR     |
00001050  72 33 2c 20 5b 72 31 2c  20 23 32 34 5d 0a 20 20  |r3, [r1, #24].  |
00001060  20 20 20 20 20 20 54 53  54 20 20 20 20 20 72 33  |      TST     r3|
00001070  2c 20 23 32 20 20 20 20  20 20 20 20 20 20 20 20  |, #2            |
00001080  20 20 20 20 20 20 20 20  20 20 20 20 20 20 3b 20  |              ; |
00001090  69 66 20 69 74 27 73 20  6e 6f 74 20 61 20 73 70  |if it's not a sp|
000010a0  72 69 74 65 20 74 68 65  6e 20 64 6f 20 6e 6f 74  |rite then do not|
000010b0  68 69 6e 67 0a 20 20 20  20 20 20 20 20 42 45 51  |hing.        BEQ|
000010c0  20 20 20 20 20 6e 6f 74  5f 73 70 72 69 74 65 0a  |     not_sprite.|
000010d0  0a 20 20 20 20 20 20 20  20 54 53 54 20 20 20 20  |.        TST    |
000010e0  20 72 33 2c 20 23 32 35  36 20 20 20 20 20 20 20  | r3, #256       |
000010f0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001100  20 3b 20 69 73 20 69 74  20 69 6e 64 69 72 65 63  | ; is it indirec|
00001110  74 65 64 20 3f 0a 20 20  20 20 20 20 20 20 42 4e  |ted ?.        BN|
00001120  45 20 20 20 20 20 69 6e  64 69 72 65 63 74 65 64  |E     indirected|
00001130  0a 0a 20 20 20 20 20 20  20 20 41 44 44 20 20 20  |..        ADD   |
00001140  20 20 72 32 2c 20 72 31  2c 20 23 32 38 20 20 20  |  r2, r1, #28   |
00001150  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001160  20 20 3b 20 73 70 72 69  74 65 20 6e 61 6d 65 20  |  ; sprite name |
00001170  64 69 72 65 63 74 6c 79  20 73 70 65 63 69 66 69  |directly specifi|
00001180  65 64 0a 20 20 20 20 20  20 20 20 4d 4f 56 20 20  |ed.        MOV  |
00001190  20 20 20 72 31 2c 20 23  31 0a 20 20 20 20 20 20  |   r1, #1.      |
000011a0  20 20 42 20 20 20 20 20  20 20 64 6f 5f 64 72 61  |  B       do_dra|
000011b0  67 0a 0a 69 6e 64 69 72  65 63 74 65 64 0a 20 20  |g..indirected.  |
000011c0  20 20 20 20 20 20 54 53  54 20 20 20 20 20 72 33  |      TST     r3|
000011d0  2c 20 23 31 0a 20 20 20  20 20 20 20 20 42 4e 45  |, #1.        BNE|
000011e0  20 20 20 20 20 74 65 78  74 5f 61 6e 64 5f 73 70  |     text_and_sp|
000011f0  72 69 74 65 0a 20 20 20  20 20 20 20 20 4c 44 52  |rite.        LDR|
00001200  20 20 20 20 20 72 33 2c  20 5b 72 31 2c 20 23 33  |     r3, [r1, #3|
00001210  36 5d 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |6]              |
00001220  20 20 20 20 20 3b 20 67  65 74 20 69 6e 64 69 72  |     ; get indir|
00001230  65 63 74 65 64 20 73 70  72 69 74 65 20 6e 61 6d  |ected sprite nam|
00001240  65 20 6c 65 6e 67 74 68  0a 20 20 20 20 20 20 20  |e length.       |
00001250  20 4c 44 52 20 20 20 20  20 72 32 2c 20 5b 72 31  | LDR     r2, [r1|
00001260  2c 20 23 32 38 5d 0a 20  20 20 20 20 20 20 20 4c  |, #28].        L|
00001270  44 52 20 20 20 20 20 72  31 2c 20 5b 72 31 2c 20  |DR     r1, [r1, |
00001280  23 33 32 5d 0a 0a 20 20  20 20 20 20 20 20 43 4d  |#32]..        CM|
00001290  50 20 20 20 20 20 72 33  2c 20 23 30 20 20 20 20  |P     r3, #0    |
000012a0  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
000012b0  20 20 20 20 20 20 3b 20  69 66 20 6c 65 6e 67 74  |      ; if lengt|
000012c0  68 20 3d 20 30 20 74 68  65 6e 20 72 32 20 70 6f  |h = 0 then r2 po|
000012d0  69 6e 74 73 20 74 6f 20  73 74 61 72 74 20 6f 66  |ints to start of|
000012e0  20 73 70 72 69 74 65 0a  20 20 20 20 20 20 20 20  | sprite.        |
000012f0  41 44 44 45 51 20 20 20  72 32 2c 20 72 32 2c 20  |ADDEQ   r2, r2, |
00001300  23 34 0a 20 20 20 20 20  20 20 20 42 20 20 20 20  |#4.        B    |
00001310  20 20 20 64 6f 5f 64 72  61 67 0a 0a 74 65 78 74  |   do_drag..text|
00001320  5f 61 6e 64 5f 73 70 72  69 74 65 0a 20 20 20 20  |_and_sprite.    |
00001330  20 20 20 20 4c 44 52 20  20 20 20 20 72 32 2c 20  |    LDR     r2, |
00001340  5b 72 31 2c 20 23 33 32  5d 0a 20 20 20 20 20 20  |[r1, #32].      |
00001350  20 20 0a 66 69 6e 64 5f  73 74 61 72 74 0a 20 20  |  .find_start.  |
00001360  20 20 20 20 20 20 4c 44  52 42 20 20 20 20 72 33  |      LDRB    r3|
00001370  2c 20 5b 72 32 5d 2c 20  23 31 0a 20 20 20 20 20  |, [r2], #1.     |
00001380  20 20 20 43 4d 50 20 20  20 20 20 72 33 2c 20 23  |   CMP     r3, #|
00001390  27 53 27 0a 20 20 20 20  20 20 20 20 43 4d 50 4e  |'S'.        CMPN|
000013a0  45 20 20 20 72 33 2c 20  23 27 73 27 0a 20 20 20  |E   r3, #'s'.   |
000013b0  20 20 20 20 20 42 4e 45  20 20 20 20 20 66 69 6e  |     BNE     fin|
000013c0  64 5f 73 74 61 72 74 0a  20 20 20 20 20 20 20 20  |d_start.        |
000013d0  4d 4f 56 20 20 20 20 20  72 31 2c 20 23 31 0a 0a  |MOV     r1, #1..|
000013e0  64 6f 5f 64 72 61 67 0a  20 20 20 20 20 20 20 20  |do_drag.        |
000013f0  4d 4f 56 20 20 20 20 20  72 30 2c 20 23 31 32 38  |MOV     r0, #128|
00001400  2b 36 34 2b 33 32 2b 34  2b 31 0a 20 20 20 20 20  |+64+32+4+1.     |
00001410  20 20 20 41 44 44 20 20  20 20 20 72 33 2c 20 72  |   ADD     r3, r|
00001420  31 32 2c 20 23 38 0a 20  20 20 20 20 20 20 20 41  |12, #8.        A|
00001430  44 44 20 20 20 20 20 72  34 2c 20 72 31 32 2c 20  |DD     r4, r12, |
00001440  23 32 34 20 20 20 20 20  20 20 20 0a 20 20 20 20  |#24        .    |
00001450  20 20 20 20 53 57 49 20  20 20 20 20 58 44 72 61  |    SWI     XDra|
00001460  67 41 53 70 72 69 74 65  5f 53 74 61 72 74 0a 6e  |gASprite_Start.n|
00001470  6f 74 5f 73 70 72 69 74  65 0a 20 20 20 20 20 20  |ot_sprite.      |
00001480  20 20 4c 44 4d 46 44 20  20 20 73 70 21 2c 7b 72  |  LDMFD   sp!,{r|
00001490  30 2d 72 34 2c 70 63 7d  5e 0a 0a 3b 20 2d 2d 2d  |0-r4,pc}^..; ---|
000014a0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00001500  2d 2d 2d 2d 2d 2d 0a 0a  6c 72 5f 73 74 6f 72 65  |------..lr_store|
00001510  20 20 20 20 20 20 20 20  44 43 44 20 20 20 20 20  |        DCD     |
00001520  30 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |0               |
00001530  20 20 20 20 20 20 20 20  3b 20 72 65 67 69 73 74  |        ; regist|
00001540  65 72 20 73 74 6f 72 61  67 65 20 66 6f 72 20 53  |er storage for S|
00001550  57 49 20 64 65 63 6f 64  65 72 0a 6f 6c 64 5f 62  |WI decoder.old_b|
00001560  72 61 6e 63 68 20 20 20  20 20 20 44 43 44 20 20  |ranch      DCD  |
00001570  20 20 20 30 20 20 20 20  20 20 20 20 20 20 20 20  |   0            |
00001580  20 20 20 20 20 20 20 20  20 20 20 3b 20 62 72 61  |           ; bra|
00001590  6e 63 68 20 74 6f 20 6f  72 69 67 69 6e 61 6c 20  |nch to original |
000015a0  53 57 49 20 64 65 63 6f  64 65 72 0a 6e 65 77 5f  |SWI decoder.new_|
000015b0  62 72 61 6e 63 68 20 20  20 20 20 20 44 43 44 20  |branch      DCD |
000015c0  20 20 20 20 30 20 20 20  20 20 20 20 20 20 20 20  |    0           |
000015d0  20 20 20 20 20 20 20 20  20 20 20 20 3b 20 62 72  |            ; br|
000015e0  61 6e 63 68 20 74 6f 20  6f 75 72 20 6e 65 77 20  |anch to our new |
000015f0  53 57 49 20 64 65 63 6f  64 65 72 20 20 20 20 20  |SWI decoder     |
00001600  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
00001610  20 20 20 20 20 20 20 20  20 20 0a 0a 20 20 20 45  |          ..   E|
00001620  4e 44 0a                                          |ND.|
00001623