Initial revision
[ssr] / StraySrc / Libraries / Sapphire / dbx / s / arrow
1 ;
2 ; dbx.arrow.s
3 ;
4 ; Implementation of arrow icons as dbx controls (MDW)
5 ;
6 ; © 1994 Straylight
7 ;
8
9 ;----- Standard header ------------------------------------------------------
10
11 GET libs:header
12 GET libs:swis
13
14 ;----- External dependencies ------------------------------------------------
15
16 GET sapphire:dbox
17 GET sapphire:repeater
18
19 GET sapphire:dbx.dbx
20 GET sapphire:dbx._dbxMacs
21
22 ;----- Main code ------------------------------------------------------------
23
24 AREA |Sapphire$$Code|,CODE,READONLY
25
26 arrow_event EQU &80000002 ;Click on an arrow button
27 ;R1 == icon handle
28 ;R2 == increment value or 0
29
30 ; --- arrow ---
31 ;
32 ; Control data: +0 == increment when clicked with Select
33 ; +4
34 ;
35 ; Workspace: --
36 ;
37 ; Flags: --
38 ;
39 ; Use: Control type for an arrow button.
40
41 EXPORT arrow
42 arrow ROUT
43
44 DBXWS arrow__wSpace
45 DCD dbxMask_click
46
47 TST R2,#5 ;Is this a bona fido click?
48 MOVEQS PC,R14 ;No -- then ignore it
49 STMFD R13!,{R0-R3,R14} ;Save some registers away
50 STR R1,arrow__icon ;Save the icon handle
51
52 ; --- First, select the arrow button ---
53
54 MOV R0,R10 ;Get the dialogue handle
55 MOV R2,#1 ;Set icon's select state
56 BL dbox_select ;Show the button popped in
57
58 ; --- Calculate the increment to return ---
59
60 SUB R13,R13,#20 ;Make some space for a block
61 MOV R1,R13 ;Point to the block
62 SWI Wimp_GetPointerInfo ;Get the current mouse state
63 LDR R14,[R1,#8] ;Load the button status
64 LDR R2,[R9,#0] ;Get the arrow increment
65 CMP R14,#1 ;Is Adjust being clicked?
66 RSBEQ R2,R2,#0 ;Yes -- negate the increment
67 STR R2,arrow__inc ;Save the increment
68 ADD R13,R13,#20 ;Reclaim the stack space
69
70 ; --- Now set up the repeater ---
71
72 ADR R0,arrow__repeat ;Point to repeater routine
73 MOV R1,R10 ;Pass dialogue in R10
74 MOV R2,R12 ;And workspace in R12
75 BL repeater ;Set up the repeater
76
77 LDMFD R13!,{R0-R3,PC}^ ;Return to caller if all OK
78
79 arrow__wSpace DCD 0
80
81 LTORG
82
83 ; --- arrow__repeat ---
84 ;
85 ; On entry: R0 == number of repeats, or 0 for end of job
86 ;
87 ; On exit: --
88 ;
89 ; Use: Handles autorepeating for the arrow button.
90
91 arrow__repeat ROUT
92
93 STMFD R13!,{R0-R3,R14} ;Save some registers
94 CMP R0,#0 ;Is this the end?
95 BEQ %50arrow__repeat ;Yes -- do different things
96
97 ; --- Send a normal continuation event ---
98 ;
99 ; To avoid `buffering' effect, remove the MUL R2,R0,R2
100 ; instruction.
101
102 LDMIA R12,{R1,R2} ;Load increment and icon
103 MUL R2,R0,R2 ;Accumulate lots of ops
104 MOV R0,#arrow_event ;Get the event code
105 BL dbx_sendEvent ;Send the event along nicely
106 LDMFD R13!,{R0-R3,PC}^ ;And return to caller
107
108 ; --- Send end-of-the-job event ---
109
110 50arrow__repeat MOV R0,R10 ;Yes -- get the dialogue
111 LDR R1,arrow__icon ;Load the icon handle
112 MOV R2,#0 ;Deselect the button
113 BL dbox_select ;And do the deselect op
114
115 MOV R0,#arrow_event ;Get the event code
116 BL dbx_sendEvent ;Send the event along nicely
117 LDMFD R13!,{R0-R3,PC}^ ;And return to caller
118
119 LTORG
120
121 ;----- Workspace ------------------------------------------------------------
122
123 ^ 0,R12
124 arrow__wStart # 0
125
126 arrow__icon # 4 ;Icon handle of button
127 arrow__inc # 4 ;Increment to return
128
129 arrow__wSize EQU {VAR}-arrow__wStart
130
131 AREA |Sapphire$$LibData|,CODE,READONLY
132
133 DCD arrow__wSize
134 DCD arrow__wSpace
135 DCD 0
136 DCD 0
137
138 ;----- That's all, folks ----------------------------------------------------
139
140 END