4 * A Sapphire application in C!
6 * © 1995-1998 Straylight
9 /*----- Licensing note ----------------------------------------------------*
11 * CApp is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2, or (at your option)
16 * CApp is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with CApp. If not, write to the Free Software Foundation,
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 /*----- External dependencies ---------------------------------------------*/
28 /* --- Header files --- */
33 /* --- Sapphire routines --- *
35 * Currently we have to declare these by hand. Maybe things will get better
39 #include "defHandler.h"
46 #include "resources.h"
50 __swi(OS_Exit) void os_exit(void);
52 /* --- Version strings --- */
55 extern char version[];
57 /*----- Main code ---------------------------------------------------------*/
59 /* --- The application name --- *
61 * This is picked up by start.s and passed to sapphire_init.
64 char appname[]="CApp";
66 /* --- capp__menuHandler --- *
68 * The menu handling routine. This is fairly straightforward. Equipped
69 * with os_exit, we can quit the program on a `Quit' event, and progInfo
70 * displays a dialogue if you choose `Info...'.
73 static _sapph(capp__menuHandler)(regset *r)
82 _call(progInfo,_inr(0,2),
83 msgs_lookup("caPUR"),cright,version);
93 /* --- capp__ibHandler --- *
95 * Handles events on the icon bar. Select displays a `Hello, world!'
96 * message. Menu displays a menu. The menu is contained within the
100 static _sapph(capp__ibHandler)(regset *r)
102 static const unsigned menu[]={ /* Yuk! */
104 0x00000000, /* Default title style */
105 0x70704143, /* `CApp' */
108 0x00000200, /* Send subwarn events */
109 0x4E496163, /* `caINF' */
112 0x00000000, /* Normal item style */
113 0x55516163, /* `caQUIT' */
116 0x80000000, /* End of the block */
123 _call(errorBox,_inr(0,1),
124 strerror(1,"Hello, world! %i0",(int)scratchpad/24),
128 _call(menu_create,_inr(0,3),menu,capp__menuHandler,0,0);
131 _swi(Wimp_ReportError,_inr(0,2),
132 strerror(1,"%0 seems to be working",appname),1,appname);
140 /* --- sapph_main --- *
142 * This is the main program. Well, almost. I couldn't use `main' because
143 * the compiler messes up the output. The code initialises the library
144 * units (yes! we can start executing C code before most of Sapphire is
145 * awake!), creates an icon on the icon bar, and handles events until
146 * something kills the application.
149 _sapph(sapph_main)(void)
154 _call(resources_init,0);
155 _call(sapphire_libInit,0);
156 _call(ibicon_create,_inr(0,6),
159 capp__ibHandler,0,0);
163 /* --- Use _call here -- it needs testing --- */
165 if (!(_call(event_poll,_inr(0,1)|_out(0)|_return(_flags),
166 1,pollblock, &e) & _c))
167 _call(defHandler,_inr(0,1),e,pollblock);
173 /*----- That's all, folks -------------------------------------------------*/