chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Sapphire / s / defHandler
1 ;
2 ; defHandler.s
3 ;
4 ; Default event handler (TMA)
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sapphire library.
12 ;
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)
16 ; any later version.
17 ;
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.
22 ;
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.
26
27 ;----- Standard header ------------------------------------------------------
28
29                 GET     libs:header
30                 GET     libs:swis
31
32 ;----- External dependencies ------------------------------------------------
33
34                 GET     sapphire:resspr
35
36 ;----- Main code ------------------------------------------------------------
37
38                 AREA    |Sapphire$$Code|,CODE,READONLY
39
40 ; --- defHandler ---
41 ;
42 ; On entry:     R0 == Wimp_Poll reason code
43 ;               R1 == pointer to Wimp_Poll event block
44 ;
45 ; On exit:      CS if we handled the event, CC otherwise.
46 ;
47 ; Use:          Handles events no-one else is interested in.  It's basically
48 ;               a catch-all for things that probably should have been
49 ;               handled elsewhere, and does some useful tidying up
50 ;               operations (like calling Wimp_ProcessKey on key events).
51
52                 EXPORT  defHandler
53 defHandler      ROUT
54
55                 ORR     R14,R14,#C_flag         ;Set carry flag on return
56                 CMP     R0,#9                   ;Is it a low-numbered event?
57                 ADDLO   PC,PC,R0,LSL #2         ;Yes -- dispatch
58                 B       %10defHandler           ;No -- handle specially
59
60                 ; --- The event dispatch table ---
61
62                 BICS    PC,R14,#C_flag          ;Null events are ignored
63                 B       def__redraw             ;Do a dummy redraw op
64                 B       def__open               ;Open unopened windows
65                 B       def__close              ;Close unclosed windows
66                 BICS    PC,R14,#C_flag          ;So pointer's left a window
67                 BICS    PC,R14,#C_flag          ;Gone back inside again
68                 BICS    PC,R14,#C_flag          ;Mouse click -- yawn
69                 B       def__drag               ;Turn off DragASprite
70                 B       def__key                ;Pass keypresses onwards
71
72                 ; --- Handle high-numbered events ---
73
74 10defHandler    CMP     R0,#17                  ;Is it a message?
75                 CMPNE   R0,#18                  ;Or another message?
76                 BICNES  PC,R14,#C_flag          ;No -- nothing we can do
77
78                 ; --- Handle Message_Quit properly ---
79
80                 STMFD   R13!,{R14}              ;Save the link register
81                 LDR     R14,[R1,#16]            ;Get the message action
82                 CMP     R14,#0                  ;Is it a quit message?
83                 LDMFD   R13!,{R14}              ;Restore link register
84                 SWIEQ   OS_Exit                 ;Yes -- kill everything off
85                 BICS    PC,R14,#C_flag          ;Couldn't understand message
86
87 ; --- def__<event> ---
88 ;
89 ; Entry/exit:   As for defHandler above
90 ;
91 ; Use:          Handles default behaviour for an individual event type
92
93 def__redraw     ROUT
94
95                 STMFD   R13!,{R0,R1,R14}        ;Save some registers
96                 BL      resspr_area             ;Find the sprite area
97                 SWI     XSculptrix_SetSpriteArea ;Register it with Sculptrix
98                 SWI     Wimp_RedrawWindow       ;Start the redraw operation
99 00def__redraw   CMP     R0,#0                   ;Is this the end of the line?
100                 SWINE   XSculptrix_RedrawWindow ;Use Sculptrix if it's there
101                 SWINE   Wimp_GetRectangle       ;No -- get another rectangle
102                 BNE     %00def__redraw          ;And go back again
103                 LDMFD   R13!,{R0,R1,PC}^        ;Yes -- return
104
105 def__open       SWI     Wimp_OpenWindow         ;Open the window then
106                 MOVS    PC,R14
107
108 def__close      SWI     Wimp_CloseWindow        ;Close the window
109                 MOVS    PC,R14
110
111 def__drag       SWI     XDragASprite_Stop       ;Stop any spritely drags
112                 MOVS    PC,R14
113
114 def__key        STMFD   R13!,{R0,R14}           ;Save some registers
115                 LDR     R0,[R1,#24]             ;Get the key number out
116                 SWI     Wimp_ProcessKey         ;Pass it to other apps
117                 LDMFD   R13!,{R0,PC}^           ;Return to the caller
118
119 ;----- That's all, folks ----------------------------------------------------
120
121                 END