4 ; Handle buttons definitions
6 ; © 1995-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sapphire library.
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Standard header ------------------------------------------------------
34 ;----- External dependencies ------------------------------------------------
39 ;----- Main code ------------------------------------------------------------
41 AREA |Sapphire$$Code|,CODE,READONLY
43 ; --- buttons_setup ---
45 ; On entry: R0 == dialogue box handle
46 ; R1 == pointer to buttons block
47 ; R2 == buttons base icon
48 ; R3 == number of buttons to allow
50 ; On exit: R2 == buttons flag mask
51 ; R3 == cancel button icon, or -1
53 ; Use: Sets up a dialogue box's buttons according to a buttons
59 STMFD R13!,{R0,R1,R4-R9,R14} ;Save some registers
60 MOV R9,R1 ;Look after the button table
61 ADD R8,R2,R3 ;Get the icon limit value
62 MOV R7,R2 ;Start an icon counter
63 MOV R6,#0 ;Keep track of the bits
64 MOV R5,R0 ;And get the dialogue handle
65 MOV R4,#-1 ;No cancel as yet
66 BL dbox_window ;And turn it into a window
67 STR R0,[R13,#-16]! ;Save it on the stack
68 MOV R14,#&00800000 ;Put deleted flag in BIC word
69 STR R14,[R13,#12] ;Store that away too
71 05buttons_setup LDR R3,[R9],#4 ;Load the flags word
72 MOV R0,#0 ;No text for this icon
74 TST R3,#bFlag_cancel ;Is this a cancel button?
75 MOVNE R4,R7 ;Yes -- we have cancel
76 ADRNE R0,but__cancelTag ;Point to the message
77 BNE %07buttons_setup ;And skip onwards
78 TST R3,#bFlag_ok ;Is this an OK button?
79 ADRNE R0,but__okTag ;Point to the message
80 BNE %10buttons_setup ;And skip onwards
81 TST R3,#bFlag_help ;Is this a help button?
82 ADRNE R0,but__helpTag ;Point to the message
83 BNE %07buttons_setup ;And skip onwards
85 07buttons_setup TST R3,#bFlag_text ;Does this icon contain text?
86 BEQ %10buttons_setup ;Skip forwards to that bit
87 MOV R0,R9 ;Point to button message
89 00 LDRB R14,[R9],#1 ;Load a byte from the block
90 CMP R14,#&20 ;Reached the end yet?
91 BCS %b00 ;No -- keep looping
92 ADD R9,R9,#3 ;Word-align pointer
95 ; --- Fill an icon with text ---
97 10buttons_setup CMP R0,#0 ;Is there text defined?
98 MOVEQ R14,#&00800000 ;No -- delete the icon then
99 BEQ %20buttons_setup ;So go and do that
100 BL msgs_lookup ;Get the actual message
101 MOV R2,R0 ;Get the string in R2
102 MOV R1,R7 ;Get the icon handle
103 MOV R0,R5 ;And the dialogue handle
104 BL dbox_setField ;Write that in nicely
105 MOV R14,#1 ;Set this icon's bit
106 ORR R6,R6,R14,LSL R7 ;Remember this icon exists
108 ; --- Delete or undelete an icon ---
110 MOV R14,#0 ;We want to undelete here
111 20buttons_setup STMIB R13,{R7,R14} ;Save icon and EOR mask
112 MOV R1,R13 ;Point to the block
113 SWI Wimp_SetIconState ;And make sure of that
115 ; --- See what to do next ---
117 ADD R7,R7,#1 ;Move on to next icon
118 CMP R7,R8 ;Have we finished yet?
119 BCS %30buttons_setup ;Finished them all -- skip
120 TST R3,#bFlag_last ;Was that the last of them?
121 BEQ %05buttons_setup ;No -- go round again then
123 ; --- Delete the rest of the icons ---
125 MOV R14,#&00800000 ;Get the deleted flag
126 STR R14,[R13,#8] ;Save it in the block
127 MOV R1,R13 ;Point at the block
128 00 STR R7,[R13,#4] ;Save the icon number
129 SWI Wimp_SetIconState ;Delete the icon
130 ADD R7,R7,#1 ;Move on to next icon
131 CMP R7,R8 ;Finished yet?
132 BCC %b00 ;More to go -- loop
134 ; --- That's it -- return ---
136 30buttons_setup MOV R2,R6 ;Get the button bits
137 MOV R3,R4 ;And get the cancel button
138 ADD R13,R13,#16 ;Restore the stack pointer
139 LDMFD R13!,{R0,R1,R4-R9,PC}^ ;And return to caller
141 but__okTag DCB "ok",0
142 but__cancelTag DCB "can",0
143 but__helpTag DCB "help",0
147 bFlag_cancel EQU (1<<0) ;This is the cancel button
148 bFlag_ok EQU (1<<1) ;This is the OK button
149 bFlag_help EQU (1<<2) ;This is the help button
150 bFlag_text EQU (1<<3) ;This button contains text
151 bFlag_last EQU (1<<31) ;This is the last item
153 ;----- That's all, folks ----------------------------------------------------