home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 2 / DATAFILE_PDCD2.iso / utilities2 / desklib / Libraries / DragASpr / s / DragIcon next >
Encoding:
Text File  |  1993-07-09  |  4.0 KB  |  112 lines

  1. ; Copyright 1993 Shaun Blackmore and Jason Williams
  2. ; (Shaun wrote the C version, plus the basis of this assembler, which I then
  3. ;  got working correctly and added the CMOS check into)
  4. ; version 1.00
  5. ;
  6. ; Interestingly, this code is only about 4 instructions shorter than its
  7. ; C code equivalent.
  8.  
  9.         GET     h.regdefs
  10.         GET     h.swinos
  11.         GET     h.macros
  12.  
  13. ; void DragASprite_DragIcon(window_handle window, icon_handle icon);
  14.  
  15.         PREAMBLE
  16.         STARTCODE DragASprite_DragIcon
  17. ;                        
  18.         STMFD   sp!, {r4,r5,r6,r7,lr}                  
  19.         MOV     ip,sp
  20.         
  21.         SUB     sp, sp, #40        ; Set up block for GetWindowState
  22.         STR     r0, [sp, #0]       ; icon.window=r0
  23.  
  24.         MOV     r7, r1             ; remember icon number for later...
  25.           MOV     r1, sp           ; r1 = pointer to windowstate block
  26.  
  27.           SWI     SWI_Wimp_GetWindowState + XOS_Bit
  28.           BVS     Exit
  29.  
  30.           LDR     r2, [sp, #4]     
  31.           LDR     r3, [sp, #20]
  32.           SUB     r2, r2, r3       ; r2 = window_origin_x
  33.  
  34.           LDR     r3, [sp, #16]
  35.           LDR     r4, [sp, #24]
  36.           SUB     r3, r3, r4       ; r3 = window_origin_y
  37.  
  38.                                    ; Set up a DragBox structure
  39.           SUB     sp, sp, #40      ; Drag Structure
  40.  
  41.           STR     r0, [sp, #0]     ; drag.window=r0
  42.           MOV     r0, #5
  43.           STR     r0, [sp, #4]     ; drag.type=5;
  44.  
  45.                                    ; Now get the icon state
  46.         STR     r7, [r1, #4]       ; store icon- Block already has windowhandle
  47.         SWI     SWI_Wimp_GetIconState + XOS_Bit
  48.         BVS     Exit                                           
  49.  
  50.         ADD     r1, r1, #8         ; r1 = icon block
  51.                                    ; sp = drag structure
  52.         LDMIA   r1,{r4,r5,r6,r7}   ; Read icon bounding rectangle
  53.  
  54.           ADD     r4, r4, r2       ; Convert offsets from window origin (TL)
  55.           ADD     r5, r5, r3       ; into absolute screen coordinates, using
  56.           ADD     r6, r6, r2       ; the window origin calculated above (r2,r3)
  57.           ADD     r7, r7, r3
  58.  
  59.         ADD     r2, sp, #8         ; r1 = bounding box
  60.         STMIA   r2,{r4,r5,r6,r7}
  61.         
  62.         MOV     r0,#0
  63.         STR     r0,[sp,#24]        ; parent.x0 = 0
  64.         STR     r0,[sp,#28]        ; parent.y0 = 0
  65.         MVN     r0,#0
  66.         STR     r0,[sp,#32]        ; parent.x1 = &FFFFFFFF
  67.         STR     r0,[sp,#36]        ; parent.y1 = &FFFFFFFF
  68.  
  69.         MOV     r7, r1             ; r7 = pointer to icon state data
  70.  
  71.                                    ; Check if DragASprite is available
  72.         ADD     r1, pc, #DragString-.-8
  73.         SWI     SWI_OS_SWINumberFromString + XOS_Bit
  74.         BVS     NoDrag             ; It isn't, so do Wimp_DragBox
  75.  
  76.         MOV     r0, #161           ; Check the DragASpr configuration bit
  77.         MOV     r1, #28
  78.         SWI     SWI_OS_Byte + XOS_Bit
  79.         TST     r2, #2             ; Is DragASprite enabled?
  80.         BEQ     NoDrag             ; No - do a Wimp_DragBox
  81.  
  82.         LDR     r0, [r7, #16]      ; check for icon type - is it indirected?
  83.         TST     r0, #256
  84.                                    ; Not Indirected
  85.         MOVEQ   r1, #1             ;   System area
  86.         ADDEQ   r2, r7, #20        ;   Point to data
  87.  
  88.         LDRNE   r1, [r7, #24]      ; Is Indirected
  89.         LDRNE   r2, [r7, #20]      ;
  90.  
  91.         ADD     r3, sp, #8         ; r3 => Bounding box
  92.         ADD     r4, sp, #24        ; r4 => Parent box (not actually needed)
  93.  
  94.         MOV     r0, #197           ; Flags- centered, bbox = screen bounds,
  95.                                    ; bbox limits mouse pointer, has drop shadow
  96.  
  97.         SWI     SWI_DragASprite_Start + XOS_Bit
  98.         B       Exit
  99.  
  100. NoDrag
  101.         MOV     r1, sp             ; Can't DragASprite, so Wimp_DragBox instead
  102.         SWI     SWI_Wimp_DragBox + XOS_Bit
  103.  
  104. Exit
  105.         MOV     sp, ip             ; restore old stack pointer
  106.         MOVVC   r0, #0
  107.         LDMFD   sp!, {r4,r5,r6,r7,pc}^
  108. ;
  109. DragString
  110.         DCB     "DragASprite_Start",0
  111.         END
  112.