chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Steel / s / wimp_main
1 ;
2 ; wimp_main.s
3 ;
4 ; APCS interface to WIMP SWIs
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Steel library.
12 ;
13 ; Steel 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 ; Steel 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 Steel.  If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Initialising the WIMP ------------------------------------------------
28
29 ; --- wimp_initialise ---
30 ;
31 ; On entry:     a1 == pointer to where to put the version number
32
33                 EXPORT  wimp_initialise
34 wimp_initialise STMFD   sp!,{lr}                ;Save the link register
35                 MOV     ip,a1                   ;Save this away for a bit
36                 MOV     a1,#120                 ;Make sure it's Arthur :-)
37                 MOV     a2,#0                   ;Don't start a WIMP task
38                 SWI     XWimp_Initialise        ;Start up the WIMP
39                 STRVC   a1,[ip]                 ;Store the version number
40                 MOVVC   a1,#0                   ;If no error, return no error
41                 LDMFD   sp!,{pc}^               ;Return to caller
42
43 ; --- wimp_taskinit ---
44 ;
45 ; On entry:     a1 == pointer to name of task
46 ;               a2 == pointer to version number (to be updated)
47 ;               a3 == pointer to task handle to set
48 ;               a4 == optional pointer to messages block
49
50                 EXPORT  wimp_taskinit
51 wimp_taskinit   STMFD   sp!,{a2,a3,lr}          ;Stash lots of registers
52                 MOV     a3,a1                   ;Point to the task name
53                 LDR     a1,[a2]                 ;Get the version number
54                 LDR     a2,wimp__magic          ;Load the strange magic value
55                 SWI     XWimp_Initialise        ;Initialise the WIMP
56                 LDMIA   sp!,{a3,a4,lr}          ;Get the pointers back
57                 STRVC   a1,[a3]                 ;Store the version number
58                 STRVC   a2,[a4]                 ;Store the task handle too
59                 MOVVC   a1,#0                   ;If no error, clear return
60                 MOVS    pc,lr                   ;Return to caller
61
62 wimp__magic     DCB     "TASK"                  ;The magic value for initing
63
64 ;----- Closing the WIMP down again ------------------------------------------
65
66 ; --- wimp_closedown ---
67 ;
68 ; On entry:     --
69
70                 EXPORT  wimp_closedown
71 wimp_closedown  SWI     XWimp_CloseDown         ;Close down the WIMP
72                 MOVVC   a1,#0                   ;If no error, return clear
73                 MOVS    pc,lr                   ;Return to caller
74
75 ; --- wimp_taskclose ---
76 ;
77 ; On entry:     a1 == my task handle to use
78
79                 EXPORT  wimp_taskclose
80 wimp_taskclose  LDR     a2,wimp__magic          ;Get the magic number again
81                 SWI     XWimp_CloseDown         ;Close down my task only
82                 MOVVC   a1,#0                   ;Clear error if it worked
83                 MOVS    pc,lr                   ;Return to caller
84
85 ;----- Everything else :-) --------------------------------------------------
86
87 ; --- wimp_create_wind ---
88 ;
89 ; On entry:     a1 == pointer to window definition
90 ;               a2 == pointer to window handle to fill in
91
92                 EXPORT  wimp_create_wind
93 wimp_create_wind
94                 MOV     a4,a2                   ;Keep pointer to handle too
95                 MOV     a2,a1                   ;Point to window definition
96                 SWI     XWimp_CreateWindow      ;Create the new window
97                 STRVC   a1,[a4]                 ;Store the handle away
98                 MOVVC   a1,#0                   ;And clear the error code
99                 MOVS    pc,lr                   ;Return to caller
100
101 ; --- wimp_create_icon ---
102 ;
103 ; On entry:     a1 == pointer to icon creation block
104 ;               a2 == pointer to icon handle to fill in
105
106                 EXPORT  wimp_create_icon
107 wimp_create_icon
108                 MOV     a4,a2                   ;Keep pointer to icon handle
109                 MOV     a2,a1                   ;Point to the icon block
110                 SWI     XWimp_CreateIcon        ;Create the icon now
111                 STRVC   a1,[a4]                 ;Store the icon handle away
112                 MOVVC   a1,#0                   ;Clear any error code
113                 MOVS    pc,lr                   ;Return to caller
114
115 ; --- wimp_delete_wind ---
116 ;
117 ; On entry:     a1 == window handle
118
119                 EXPORT  wimp_delete_wind
120 wimp_delete_wind
121                 STMFD   sp!,{a1}                ;Store window handle on stack
122                 MOV     a2,sp                   ;Point to saved handle
123                 SWI     XWimp_DeleteWindow      ;Delete the window
124                 MOVVC   a1,#0                   ;Return no error if success
125                 ADD     sp,sp,#4                ;Restore stack pointer
126                 MOVS    pc,lr                   ;Return to caller
127
128 ; --- wimp_delete_icon ---
129 ;
130 ; On entry:     a1 == window handle
131 ;               a2 == icon handle
132
133                 EXPORT  wimp_delete_icon
134 wimp_delete_icon
135                 STMFD   sp!,{a1,a2}             ;Stack registers for block
136                 MOV     a2,sp                   ;Point to the block
137                 SWI     XWimp_DeleteIcon        ;Do the SWI
138                 MOVVC   a1,#0                   ;Clear the error indicator
139                 ADD     sp,sp,#8                ;Restore stack pointer
140                 MOVS    pc,lr                   ;Return to caller
141
142 ; --- wimp_open_wind ---
143 ;
144 ; On entry:     a1 == pointer to window block
145
146                 EXPORT  wimp_open_wind
147 wimp_open_wind  MOV     a2,a1                   ;Point to window block
148                 SWI     XWimp_OpenWindow        ;Do the SWI
149                 MOVVC   a1,#0
150                 MOVS    pc,lr
151
152 ; --- wimp_close_wind ---
153 ;
154 ; On entry:     a1 == window handle
155
156                 EXPORT  wimp_close_wind
157 wimp_close_wind STMFD   sp!,{a1}                ;Store window handle away
158                 MOV     a2,sp                   ;Point to the `block'
159                 SWI     XWimp_CloseWindow       ;Close the window
160                 MOVVC   a1,#0
161                 ADD     sp,sp,#4                ;Restore the stack
162                 MOVS    pc,lr
163
164 ; --- wimp_redraw_wind ---
165 ;
166 ; On entry:     a1 == pointer to a redraw structure to fill in
167 ;               a2 == pointer to a `more' variable to fill in
168
169                 EXPORT  wimp_redraw_wind
170 wimp_redraw_wind
171                 MOV     a3,a2                   ;Keep this pointer safe
172                 MOV     a2,a1                   ;Point to redraw structure
173                 SWI     XWimp_RedrawWindow      ;Do the redraw window call
174                 STRVC   a1,[a3]                 ;Store the `more' variable
175                 MOVVC   a1,#0
176                 MOVS    pc,lr                   ;Return to caller
177
178 ; --- wimp_update_wind ---
179 ;
180 ; On entry:     a1 == pointer to a redraw structure to fill in
181 ;               a2 == pointer to a `more' variable to fill in
182
183                 EXPORT  wimp_update_wind
184 wimp_update_wind
185                 MOV     a3,a2                   ;Keep this pointer safe
186                 MOV     a2,a1                   ;Point to redraw structure
187                 SWI     XWimp_UpdateWindow      ;Do the update window call
188                 STRVC   a1,[a3]                 ;Store the `more' variable
189                 MOVVC   a1,#0
190                 MOVS    pc,lr                   ;Return to caller
191
192 ; --- wimp_get_rectangle ---
193 ;
194 ; On entry:     a1 == pointer to a redraw structure to fill in
195 ;               a2 == pointer to a `more' variable to fill in
196
197                 EXPORT  wimp_get_rectangle
198 wimp_get_rectangle
199                 MOV     a3,a2                   ;Keep this pointer safe
200                 MOV     a2,a1                   ;Point to redraw structure
201                 SWI     XWimp_GetRectangle      ;Get the next rectangle
202                 STRVC   a1,[a3]                 ;Store the `more' variable
203                 MOVVC   a1,#0
204                 MOVS    pc,lr                   ;Return to caller
205
206 ; --- wimp_get_wind_state ---
207 ;
208 ; On entry:     a1 == window handle
209 ;               a2 == pointer to block to fill in
210
211                 EXPORT  wimp_get_wind_state
212 wimp_get_wind_state
213                 STR     a1,[a2,#0]              ;Fill in the window handle
214                 SWI     XWimp_GetWindowState
215                 MOVVC   a1,#0
216                 MOVS    pc,lr
217
218 ; --- wimp_get_wind_info ---
219 ;
220 ; On entry:     a1 == pointer to block to fill in
221
222                 EXPORT  wimp_get_wind_info
223 wimp_get_wind_info
224                 MOV     a2,a1
225                 SWI     XWimp_GetWindowInfo
226                 MOVVC   a1,#0
227                 MOVS    pc,lr
228
229 ; --- wimp_set_icon_state ---
230 ;
231 ; On entry:     a1 == window handle
232 ;               a2 == icon handle
233 ;               a3 == EOR mask
234 ;               a4 == BIC mask
235
236                 EXPORT  wimp_set_icon_state
237 wimp_set_icon_state
238                 STMFD   sp!,{a1-a4}
239                 MOV     a2,sp
240                 SWI     XWimp_SetIconState
241                 ADD     sp,sp,#16
242                 MOVVC   a1,#0
243                 MOVS    pc,lr
244
245 ; --- wimp_get_icon_info ---
246 ;
247 ; On entry:     a1 == window handle
248 ;               a2 == icon handle
249 ;               a3 == pointer to structure to fill in
250
251                 EXPORT  wimp_get_icon_info
252 wimp_get_icon_info
253                 SUB     sp,sp,#40               ;Make space for icon block
254                 STMIA   sp,{a1,a2}              ;Fill in the handles nicely
255                 MOV     a2,sp                   ;Point to the block
256                 SWI     XWimp_GetIconState      ;Get information about icon
257                 ADDVS   sp,sp,#40               ;If it failed, restore stack
258                 MOVVSS  pc,lr                   ;And return to caller
259                 ADD     sp,sp,#8                ;Point to icon info
260                 LDMIA   sp!,{a1,a2,a4,ip}       ;Get some of the data
261                 STMIA   a3!,{a1,a2,a4,ip}       ;Store in the caller's buffer
262                 LDMIA   sp!,{a1,a2,a4,ip}       ;Get the rest of the icon
263                 STMIA   a3!,{a1,a2,a4,ip}       ;And store that away too
264                 MOV     a1,#0                   ;Nothing went wrong
265                 MOVS    pc,lr                   ;Return to caller
266
267 ; --- wimp_get_point_info ---
268 ;
269 ; On entry:     a1 == pointer to block to fill in
270
271                 EXPORT  wimp_get_point_info
272 wimp_get_point_info
273                 MOV     a2,a1                   ;Point to the block
274                 SWI     XWimp_GetPointerInfo    ;Get the mouse information
275                 MOVVC   a1,#0
276                 MOVS    pc,lr
277
278 ; --- wimp_drag_box ---
279 ;
280 ; On entry:     a1 == pointer to a drag structure
281
282                 EXPORT  wimp_drag_box
283 wimp_drag_box   MOV     a2,a1                   ;Point to the block
284                 SWI     XWimp_DragBox           ;Perform the drag
285                 MOVVC   a1,#0
286                 MOVS    pc,lr
287
288 ; --- wimp_force_redraw ---
289 ;
290 ; On entry:     a1 == pointer to a redraw block
291
292                 EXPORT  wimp_force_redraw
293 wimp_force_redraw
294                 STMFD   sp!,{v1,lr}             ;Store v1 away nicely
295                 LDMIA   a1,{a1-a4,v1}           ;Get registers from the block
296                 SWI     XWimp_ForceRedraw
297                 MOVVC   a1,#0
298                 LDMFD   sp!,{v1,pc}^
299
300 ; --- wimp_set_caret_pos ---
301 ;
302 ; On entry:     a1 == pointer to a caret structure to set
303
304                 EXPORT  wimp_set_caret_pos
305 wimp_set_caret_pos
306                 STMFD   sp!,{v1,v2,lr}          ;Store v1 and v2 away nicely
307                 LDMIA   a1,{a1-a4,v1,v2}
308                 SWI     XWimp_SetCaretPosition
309                 MOVVC   a1,#0
310                 LDMFD   sp!,{v1,v2,pc}^
311
312 ; --- wimp_get_caret_pos ---
313 ;
314 ; On entry:     a1 == pointer to caret structure to fill in
315
316                 EXPORT  wimp_get_caret_pos
317 wimp_get_caret_pos
318                 MOV     a2,a1
319                 SWI     XWimp_GetCaretPosition
320                 MOVVC   a1,#0
321                 MOVS    pc,lr
322
323 ; --- wimp_create_menu ---
324 ;
325 ; On entry:     a1 == pointer to menu
326 ;               a2 == x coordinate to open menu
327 ;               a3 == y coordinate to open menu
328
329                 EXPORT  wimp_create_menu
330 wimp_create_menu
331                 MOV     a4,a3
332                 MOV     a3,a2
333                 MOV     a2,a1
334                 SWI     XWimp_CreateMenu
335                 MOVVC   a1,#0
336                 MOVS    pc,lr
337
338 ; --- wimp_decode_menu ---
339 ;
340 ; On entry:     a1 == pointer to menu
341 ;               a2 == pointer to menu hit array
342 ;               a3 == pointer to buffer for string
343
344                 EXPORT  wimp_decode_menu
345 wimp_decode_menu
346                 MOV     a4,a3
347                 MOV     a3,a2
348                 MOV     a2,a1
349                 SWI     XWimp_DecodeMenu
350                 MOVVC   a1,#0
351                 MOVS    pc,lr
352
353 ; --- wimp_which_icon ---
354 ;
355 ; On entry:     a1 == pointer to strange which block thing
356 ;               a2 == pointer to where to store the results
357
358                 EXPORT  wimp_which_icon
359 wimp_which_icon LDMIA   a1,{a1,a3,a4}           ;Get arguments from block
360                 SWI     XWimp_WhichIcon
361                 MOVVC   a1,#0
362                 MOVS    pc,lr
363
364 ; --- wimp_set_extent ---
365 ;
366 ; On entry:     a1 == pointer to strange block with window handle
367
368                 EXPORT  wimp_set_extent
369 wimp_set_extent ADD     a2,a1,#4                ;Point to extent block
370                 LDR     a1,[a1]                 ;Get the window handle
371                 SWI     XWimp_SetExtent
372                 MOVVC   a1,#0
373                 MOVS    pc,lr
374
375 ; --- wimp_set_point_shape ---
376 ;
377 ; On entry:     a1 == pointer to a freaky pointer shape structure
378
379                 EXPORT  wimp_set_point_shape
380 wimp_set_point_shape
381                 STMFD   sp!,{v1,v2,lr}
382                 LDMIA   a1,{a1-a4,v1,v2}
383                 SWI     XWimp_SetPointerShape
384                 MOVVC   a1,#0
385                 LDMFD   sp!,{v1,v2,pc}^
386
387 ; --- wimp_open_template ---
388 ;
389 ; On entry:     a1 == pointer to name of template file
390
391                 EXPORT  wimp_open_template
392 wimp_open_template
393                 MOV     a2,a1
394                 SWI     XWimp_OpenTemplate
395                 MOVVC   a1,#0
396                 MOVS    pc,lr
397
398 ; --- wimp_close_template ---
399 ;
400 ; On entry:     --
401
402                 EXPORT  wimp_close_template
403 wimp_close_template
404                 SWI     XWimp_CloseTemplate
405                 MOVVC   a1,#0
406                 MOVS    pc,lr
407
408 ; --- wimp_load_template ---
409 ;
410 ; On entry:     a1 == pointer to a template structure
411
412                 EXPORT  wimp_load_template
413 wimp_load_template
414                 MOV     ip,a1                   ;Keep the pointer safe
415                 STMFD   sp!,{v1-v3,lr}          ;Save lots of registers
416                 LDMIA   ip,{a1-a4,v1-v3}        ;Get all the arguments
417                 CMP     v1,#0                   ;If no font array specified
418                 MOVEQ   v1,#-1                  ;Pass the *correct* value
419                 SWI     XWimp_LoadTemplate      ;Load the template
420                 STMVCIA ip,{a1-a4,v1-v3}        ;Store the information back
421                 MOVVC   a1,#0                   ;Clear error indicator
422                 LDMFD   sp!,{v1-v3,pc}^         ;Return to caller
423
424 ; --- wimp_processkey ---
425 ;
426 ; On entry:     a1 == key to process
427
428                 EXPORT  wimp_processkey
429 wimp_processkey SWI     XWimp_ProcessKey
430                 MOVVC   a1,#0
431                 MOVS    pc,lr
432
433 ; --- wimp_starttask ---
434 ;
435 ; On entry:     a1 == pointer to command to execute
436
437                 EXPORT  wimp_starttask
438 wimp_starttask  SWI     XWimp_StartTask
439                 MOVVC   a1,#0
440                 MOVS    pc,lr
441
442 ; --- wimp_reporterror ---
443 ;
444 ; On entry:     a1 == pointer to error block
445 ;               a2 == Wimp_ReportError flags word
446 ;               a3 == pointer to application name
447
448                 EXPORT  wimp_reporterror
449 wimp_reporterror
450                 SWI     XWimp_ReportError
451                 MOVVC   a1,#0
452                 MOVS    pc,lr
453
454 ; --- wimp_getwindowoutline ---
455 ;
456 ; On entry:     a1 == pointer to a block to fill in
457
458                 EXPORT  wimp_getwindowoutline
459 wimp_getwindowoutline
460                 MOV     a2,a1
461                 SWI     XWimp_GetWindowOutline
462                 MOVVC   a1,#0
463                 MOVS    pc,lr
464
465 ; --- wimp_ploticon ---
466 ;
467 ; On entry:     a1 == pointer to icon to plot
468
469                 EXPORT  wimp_ploticon
470 wimp_ploticon   MOV     a2,a1
471                 SWI     XWimp_PlotIcon
472                 MOVVC   a1,#0
473                 MOVS    pc,lr
474
475 ; --- wimp_setmode ---
476 ;
477 ; On entry:     a1 == new mode to set
478
479                 EXPORT  wimp_setmode
480 wimp_setmode    SWI     XWimp_SetMode
481                 MOVVC   a1,#0
482                 MOVS    pc,lr
483
484 ; --- wimp_setpalette ---
485 ;
486 ; On entry:     a1 == pointer to palette to set
487
488                 EXPORT  wimp_setpalette
489 wimp_setpalette MOV     a2,a1
490                 SWI     XWimp_SetPalette
491                 MOVVC   a1,#0
492                 MOVS    pc,lr
493
494 ; --- wimp_readpalette ---
495 ;
496 ; On entry:     a1 == pointer to palette block to fill in
497
498                 EXPORT  wimp_readpalette
499 wimp_readpalette
500                 MOV     a2,a1
501                 SWI     XWimp_ReadPalette
502                 MOVVSS  pc,lr
503
504                 ; --- It seems we must mangle the colours now ---
505                 ;
506                 ; Since Wimp_ReadPalette leaves the bottom nibbles clear for
507                 ; no sensible reason, and RISC_OSLib's wimp.c bodges the
508                 ; palette to try and make it sensible, we must do the same
509                 ; here, being careful to preserve the GCOL numbers at the
510                 ; bottom of the palette words.
511
512                 MOV     a1,#20                  ;Do this once for each entry
513                 LDR     a4,=&F0F0F000           ;Mask for copying nibbles
514 00              LDR     a3,[a2]                 ;Get the next palette word
515                 AND     ip,a3,a4                ;Get the top nibbles
516                 BIC     a3,a3,a4,LSR #4         ;Clear the bottom nibbles
517                 ORR     a3,a3,ip,LSR #4         ;Shift down to copy nibbles
518                 STR     a3,[a2],#4              ;Store and bump a2 along
519                 SUBS    a1,a1,#1                ;Done another one
520                 BNE     %b00                    ;If there's any more, loop
521
522                 MOVVC   a1,#0
523                 MOVS    pc,lr
524
525 ; --- wimp_setcolour ---
526 ;
527 ; On entry:     a1 == colour to set
528
529                 EXPORT  wimp_setcolour
530 wimp_setcolour  SWI     XWimp_SetColour
531                 MOVVC   a1,#0
532                 MOVS    pc,lr
533
534 ; --- wimp_sendmessage ---
535 ;
536 ; On entry:     a1 == the event type of the message
537 ;               a2 == pointer to the message to send
538 ;               a3 == the task handle of the recipient
539
540 ; --- wimp_sendwmessage ---
541 ;
542 ; On entry:     a1 == the event type again
543 ;               a2 == pointer to the message to send
544 ;               a3 == the window handle of the recipient
545 ;               a4 == the icon handle of the recipient
546
547 ; --- Note ---
548 ;
549 ; Since the registers are set up perfectly in both cases, we can use the
550 ; same routine!
551
552                 EXPORT  wimp_sendmessage
553                 EXPORT  wimp_sendwmessage
554 wimp_sendmessage
555 wimp_sendwmessage
556                 SWI     XWimp_SendMessage
557                 MOVVC   a1,#0
558                 MOVS    pc,lr
559
560 ; --- wimp_create_submenu ---
561 ;
562 ; On entry:     a1 == pointer to menu to open
563 ;               a2 == x coordinate to open it at
564 ;               a3 == y coordinate to open it at
565
566                 EXPORT  wimp_create_submenu
567 wimp_create_submenu
568                 MOV     a4,a3
569                 MOV     a3,a2
570                 MOV     a2,a1
571                 SWI     XWimp_CreateSubMenu
572                 MOVVC   a1,#0
573                 MOVS    pc,lr
574
575 ; --- wimp_spriteop ---
576 ;
577 ; On entry:     a1 == the reason code to pass
578 ;               a2 == the name of the sprite to do it on
579
580                 EXPORT  wimp_spriteop
581 wimp_spriteop   STMFD   sp!,{v1-v6,lr}
582                 MOV     a3,a2
583                 SWI     XWimp_SpriteOp
584                 MOVVC   a1,#0
585                 LDMFD   sp!,{v1-v6,pc}^
586
587 ; --- wimp_spriteop_full ---
588 ;
589 ; On entry:     a1 == pointer to registers to use
590
591                 EXPORT  wimp_spriteop_full
592 wimp_spriteop_full
593                 STMFD   sp!,{v1-v6,lr}
594                 MOV     ip,a1
595                 LDMIA   ip,{a1-a4,v1-v6}
596                 SWI     XWimp_SpriteOp
597                 STMVCIA ip,{a1-a4,v1-v6}
598                 MOVVC   a1,#0
599                 LDMFD   sp!,{v1-v6,pc}^
600
601 ; --- wimp_baseofsprites ---
602 ;
603 ; On entry:     --
604 ; On exit:      a1 == pointer to WIMP sprite pool in RMA
605
606                 EXPORT  wimp_baseofsprites
607 wimp_baseofsprites
608                 SWI     XWimp_SpriteOp
609                 MOV     a1,a2
610                 MOVS    pc,lr
611
612 ; --- wimp_blockcopy ---
613 ;
614 ; On entry:     a1 == window handle
615 ;               a2 == pointer to source rectangle
616 ;               a3 == destination x coordinate
617 ;               a4 == destination y coordinate
618
619                 EXPORT  wimp_blockcopy
620 wimp_blockcopy  STMFD   sp!,{v1-v3,lr}
621                 MOV     v3,a4
622                 MOV     v2,a3
623                 LDMIA   a2,{a2,a3,a4,v1}
624                 SWI     XWimp_BlockCopy
625                 MOVVC   a1,#0
626                 LDMFD   sp!,{v1-v3,pc}^
627
628 ; --- wimp_slotsize ---
629 ;
630 ; On entry:     a1 == pointer to current slot size
631 ;               a2 == pointer to next slot size
632 ;               a3 == pointer to free pool size
633
634                 EXPORT  wimp_slotsize
635 wimp_slotsize   STMFD   sp!,{v1-v3,lr}          ;Stack registers
636                 MOV     a4,a1                   ;Keep pointer to current
637                 MOV     v2,a2                   ;Keep pointer to next
638                 MOV     v3,a3                   ;Keep pointer to free
639                 LDR     a1,[a1]                 ;Get the actual current slot
640                 LDR     a2,[a2]                 ;Get the actual next slot
641                 SWI     XWimp_SlotSize          ;Set or read the slot size
642                 STRVC   a1,[a4]                 ;Store current slot size
643                 STRVC   a2,[v2]                 ;Store next slot size
644                 STRVC   a3,[v3]                 ;Store free area size
645                 MOVVC   a1,#0                   ;Clear error marker
646                 LDMFD   sp!,{v1-v3,pc}^         ;Return to caller
647
648 ; --- wimp_readpixtrans ---
649 ;
650 ; On entry:     a1 == pointer to sprite area
651 ;               a2 == pointer to sprite id (yuk)
652 ;               a3 == pointer to scale factors to fill in
653 ;               a4 == pointer to translation table to fill in
654
655                 EXPORT  wimp_readpixtrans
656 wimp_readpixtrans
657                 STMFD   sp!,{v3,v4,lr}
658
659                 ; --- Put the registers in the right places ---
660
661                 MOV     v4,a4
662                 MOV     v3,a3
663                 MOV     a3,a2
664                 MOV     a2,a1
665
666                 ; --- Set up the reason code properly ---
667
668                 CMP     a2,#0                   ;Is it the WIMP or system
669                 CMPNE   a2,#1                   ;sprite area?
670                 MOVEQ   a1,#&000                ;Then say it's system area
671                 BEQ     %f00                    ;And branch ahead
672
673                 ; --- Munge the sprite ID to get the right reason code ---
674
675                 LDR     lr,[a3,#4]              ;Get the sprite ID tag
676                 CMP     lr,#0                   ;Is it a name
677                 MOVEQ   a1,#&100                ;Yes -- user area, named
678                 MOVNE   a1,#&200                ;No -- user area, pointer
679
680                 ; --- Now get the pixel translation ---
681
682 00              LDR     a3,[a3,#0]              ;Get sprite name or pointer
683                 SWI     XWimp_ReadPixTrans      ;Do the actual operation
684
685                 MOVVC   a1,#0                   ;If it succeeded, no error
686                 LDMFD   sp!,{v3,v4,pc}^         ;Return to caller
687
688 ; --- Missing call ---
689 ;
690 ; We omit a veneer for Wimp_ClaimFreeMemory, since it's not much use unless
691 ; you're in SVC mode, in which case you'd better be writing in assembler
692 ; anyway.
693
694 ; --- wimp_commandwindow ---
695 ;
696 ; On entry:     a1 == pointer to a funny structure
697
698                 EXPORT  wimp_commandwindow
699 wimp_commandwindow
700                 MOV     a2,a1                   ;Keep pointer to structure
701                 LDR     a3,[a2,#0]              ;Get the operation code
702
703                 ; --- Work out what the operation is meant to be ---
704                 ;
705                 ; If we don't recognise the `tag' then all hell breaks loose.
706
707                 CMP     a3,#0                   ;Create window with title
708                 LDREQ   a1,[a2,#4]              ;Then find the title
709                 CMP     a3,#1                   ;Just make window `active'
710                 MOVEQ   a1,#1                   ;Horrors -- that's right
711                 CMP     a3,#2                   ;Close the window, prompting
712                 MOVEQ   a1,#0                   ;Then set up the code
713                 CMP     a3,#3                   ;Close the window, no prompt
714                 MOVEQ   a1,#-1                  ;Do that right too
715
716                 ; --- Now just do it ---
717
718                 SWI     XWimp_CommandWindow
719                 MOVVC   a1,#0
720                 MOVS    pc,lr
721
722 ; --- wimp_textcolour ---
723 ;
724 ; On entry:     a1 == colour to set
725
726                 EXPORT  wimp_textcolour
727 wimp_textcolour SWI     XWimp_TextColour
728                 MOVVC   a1,#0
729                 MOVS    pc,lr
730
731 ; --- wimp_transferblock ---
732 ;
733 ; On entry:     a1 == source task's handle
734 ;               a2 == address of buffer in source task
735 ;               a3 == destination task's handle
736 ;               a4 == address of buffer in destination task
737 ;               [sp] == amount of data to transfer
738
739                 EXPORT  wimp_transferblock
740 wimp_transferblock
741                 STMFD   sp!,{v1,lr}             ;Save v1 on the stack
742                 LDR     v1,[sp,#8]              ;Get the buffer length
743                 SWI     XWimp_TransferBlock     ;Do the operation
744                 MOVVC   a1,#0
745                 LDMFD   sp!,{v1,pc}^
746
747 ; --- wimp_readsysinfo ---
748 ;
749 ; On entry:     a1 == information to read
750 ;               a2 == where to put R0 on exit
751 ;               a3 == where to put R1 on exit
752
753                 EXPORT  wimp_readsysinfo
754 wimp_readsysinfo
755                 CMP     a1,#5
756                 MOVNE   a3,#0
757                 MOV     a4,a2
758                 SWI     XWimp_ReadSysInfo
759                 MOVVSS  pc,lr
760                 CMP     a4,#0
761                 STRNE   a1,[a4]
762                 CMP     a3,#0
763                 STRNE   a2,[a3]
764                 MOV     a1,#0
765                 MOVS    pc,lr
766
767 ; --- wimp_setfontcolours ---
768 ;
769 ; On entry:     a1 == background colour
770 ;               a2 == foreground colour
771
772                 EXPORT  wimp_setfontcolours
773 wimp_setfontcolours
774                 SWI     XWimp_SetFontColours
775                 MOVVC   a1,#0
776                 MOVS    pc,lr
777
778 ; --- wimp_getmenustate ---
779 ;
780 ; On entry:     a1 == what to do
781 ;               a2 == pointer to buffer to fill in
782 ;               a3 == window handle (optional)
783 ;               a4 == icon handle (optional too)
784
785                 EXPORT  wimp_getmenustate
786 wimp_getmenustate
787                 SWI     XWimp_GetMenuState
788                 MOVVC   a1,#0
789                 MOVS    pc,lr
790
791 ; --- wimp_addmessages ---
792 ;
793 ; On entry:     a1 == pointer to messages array
794
795                 EXPORT  wimp_addmessages
796 wimp_addmessages
797                 SWI     XWimp_AddMessages
798                 MOVVC   a1,#0
799                 MOVS    pc,lr
800
801 ; --- wimp_removemessages ---
802 ;
803 ; On entry:     a1 == pointer to messages array
804
805                 EXPORT  wimp_removemessages
806 wimp_removemessages
807                 SWI     XWimp_RemoveMessages
808                 MOVVC   a1,#0
809                 MOVS    pc,lr
810
811 ; --- Missing call ---
812 ;
813 ; We omit a veneer for Wimp_SetColourMapping, since it's for specialised use
814 ; only probably, and not of use to an average application.
815
816 ;----- That's all, folks ----------------------------------------------------
817
818                 END