]> git.sur5r.net Git - cc65/blob - doc/grc.txt
Added grc doc file from Maciek
[cc65] / doc / grc.txt
1
2
3
4     grc - GEOS resource compiler
5     
6     Maciej 'YTM/Alliance' Witkowiak
7     <ytm@friko.onet.pl>
8
9     VII 2000
10
11
12
13
14
15 1. Overview
16 -----------
17
18 grc is a part of cc65's GEOS support. This tool is necessary to generate
19 required and optional resources. A required resource for every GEOS app is the
20 header, that is: icon, some strings and addresses. Optional resources might be
21 menu definitions, other headers (e.g. for data files of an app), dialogs
22 definitions etc. Without application header GEOS is unable to load and start
23 it.
24
25 Currently, grc supports only menus and required header definition.
26
27 grc generates output in two formats - as C header and ca65 source (.s). This
28 is because application header data must be in assembler fromat while menu
29 definitions can be easily translated into C. The purpose of C file is to include
30 it as header in only one project file. Assembler source should be processed with
31 ca65 and linked as first object (read Building process below).
32
33 2. Usage
34 --------
35
36 grc accepts following options:
37     -f          force writting output files
38     -o name     name C output file
39     -s name     name S output file
40     -h          help
41
42 Default output names are made from input name with extension replaced by '.h'
43 and '.s'. grc will not overwrite existing files unless forced to do so.
44 This is to avoid situation where you have test.c and test.grc files. Both would
45 make output into test.s. For this reason you should name your resources files
46 differently than sources, e.g. as resource.grc or apphead.grc
47
48
49 3. Resource file format
50 -----------------------
51
52 A resource file has name extension '.grc'. This is not required, but it will
53 make easier recognition of file purpose. Also cl65 recognizes these files.
54 Parser is very weak at the moment so read the comments carefully and write
55 resources exactly as it is written here. Look out for CAPS and small letters.
56 Everything after a ';' till the end of line is considered as comment and 
57 ignored.
58 See included commented example .grc file for better view of the problem.
59
60 Currently grc supports only two types of resources - menu and header.
61
62 a) menu definition
63
64 MENU menuName leftx,topy ORIENTATION
65 {
66     "item name 1" MENU_TYPE pointer
67     ...
68     "item name x" MENU_TYPE pointer
69 }
70
71 The definition starts with keyword MENU, then goes menu name, which will be 
72 represented in C as const void. Then are coordinates of top left corner
73 of menu box. The position of bottom right corner is estimated basing on length
74 of item names and menu orientation. It means that menu box will be always
75 as large as it should be. Then there's orientation keyword, it can be either
76 HORIZONTAL or VERTICAL.
77 Between { and } there's menu content. It consists of item definitions.
78 First is item name - it has to be in quotes. Next is menu type bit. It can 
79 be MENU_ACTION or SUB_MENU, both can be combined with DYN_SUB_MENU bit
80 (see GEOSLib documentation for description of these). You can use C logical
81 operators in expressions but you have to do it without spaces, so dynamically
82 created submenu will be something like:
83
84     "dynamic" SUB_MENU|DYN_SUB_MENU create_dynamic
85
86 The last part of the item definition is a pointer which can be any name which
87 is present in source that includes generated header. It can point to a function
88 or to another menu definition.
89
90 If you are doing sub(sub)menus definitions remember to place the lowest level 
91 definition first. This way C compiler won't complain about unknown names.
92
93 b) header definition
94
95 HEADER GEOS_TYPE "dosname" "classname" "version"
96 {
97     author "Joe Schmoe"
98     info   "This is my killer-app!"
99     date   yy mm dd hh ss
100     dostype SEQ
101     mode    any
102 }
103
104 Header definition describes GEOS header sector which is unique to each file. 
105 Currently there's no way to change default grc icon (an empty frame). It will 
106 be possible in next versions.
107 The definition starts with keyword HEADER, then goes GEOS file type. You can 
108 only use APPLICATION here at the moment. Then there are (all in quotes) DOS 
109 filename (up to 16 characters), GEOS Class name (up to 12 characters) and 
110 version info (up to 4 characters). Version should be written as "Vx.y" where 
111 x is the major and y the minor version number. These fields along with both 
112 brackets are required. Data between brackets is optional and will be replaced 
113 by default and current values.
114 Keyword 'author' and value in quotes describes Author field and can be up to
115 63 bytes long.
116 Info (in the same format) can have up to 95 characters.
117 If 'date' field will be ommited then the time of compilation will be placed. 
118 Note that if you do specify the date you have to write all 5 numbers.
119 Dostype can by SEQ, PRG or USR. USR is by default, GEOS doesn't care.
120 Mode can be 'any', '40only', '80only', 'c64only' and describes system 
121 requirements. 'any' will work both on GEOS64 and GEOS128 in 40 and 80 column 
122 modes. '40only' will work on GEOS128 in 40 column mode only. '80only' will 
123 work only on GEOS128 and 'c64only' will work only on GEOS64.
124
125
126 4. Building GEOS application
127 ----------------------------
128
129 Before proceeding please read cc65, ca65 and ld65 documentation and find
130 appropriate sections about compiling programs in general.
131
132 GEOS support in cc65 is based on well-known in GEOS world Convert v2.5 format.
133 It means that each file built with cc65 package has to unconverted before
134 running.
135
136 Each project consists of four parts, two are provided by cc65. These parts are:
137
138 a) application header
139 b) main object
140 c) application objects
141 d) system library
142
143 b) and d) are with cc65, you have to write application yourself ;)
144
145 Application header is defined in HEADER section of .grc file and processed
146 into assembler .s file. You have to compile it with ca65 to object .o format.
147
148
149 4a. Building GEOS application without cl65
150 -----------------------------------------
151
152 Assume that there are three input files: test.c (a C source), test.h (a header
153 file) and resource.grc (with menu and header definition). Note the fact that I
154 DON'T RECOMMEND naming this file test.grc, because you will have to be very
155 careful with names (grc will make test.s and test.h out of test.grc by default
156 and you don't want that, because test.s is compiled test.c and test.h is
157 something completely different).
158
159 Important thing - the top of test.c looks like:
160
161 --- cut here ---
162
163 #include <geos.h>
164 #include "resource.h"
165
166 --- cut here ---
167
168 There are no other includes.
169
170 1. First step - compiling resources:
171
172 $ grc resource.grc
173
174 will produce two output files: resource.h and resource.s
175
176 Note that resource.h is included at the top of test.c so resource compiling
177 must be the first step.
178
179 2. Second step - compiling the code:
180
181 $ cc65 -t geos -O test.c
182 $ ca65 -t geos test.s
183
184 This way you have test.o object file which contains all the executable code.
185
186 3. Third step - compiling the application header
187
188 $ ca65 -t geos resource.s
189
190 And voilá - resource.o is ready
191
192 4. Fourth and the last step - linking it together
193
194 $ ld -t geos -o test.cvt resource.o geos.o test.o geos.lib
195
196 resource.o comes first because it contains the header. Next one is geos.o, a
197 required starter code, then actual application code in test.o and the last is
198 GEOS system library.
199 The resulting file test.cvt is executable in well-known GEOS Convert format.
200 Note that it's name (test) isn't important, the real name after unconverting 
201 is the DOS name given in header definition.
202
203 On each step a '-t geos' was present at the command line. This switch is required
204 for correct process of app building.
205
206
207 5. Bugs and feedback
208 --------------------
209
210 This is the first release of grc and it contains bugs for sure. I am aware of 
211 them, I know that parser is weak and if you don't strictly follow grammar
212 rules then everything will crash. However if you find an interesting bug mail
213 me :-) Mail me also for help writting your .grc correctly if you have problems
214 with it.
215 I would also appreciate comments and help on this file because I am sure that
216 it can be written better.
217
218
219 6. Legal stuff
220 --------------
221
222 grc is covered by the same license as whole cc65 package, so see its 
223 documentation for more info. Anyway, if you like it and want to ecourage me 
224 to work more on it send me a postcard with sight of your neighbourhood, city, 
225 region etc or just e-mail with info that you actually used it. See GEOSLib
226 documentation for addresses.
227
228
229 Appendix A: example.grc
230
231 ---- cut here ----
232
233 ;Note that MENU is either MENU and SUBMENU
234 ;If you want to use any C operators (like '|', '&' etc.) do it WITHOUT spaces
235 ;between arguments (parser is simple and weak)
236
237 MENU subMenu1 15,0 VERTICAL
238 ; this is a vertical menu placed at (15,0)
239 {
240 ; there are three items, all are calling functions
241 ; first and third are normal functions, see GEOSLib documentation for
242 ; information what should second function return (it's a dynamic one)
243     "subitem1" MENU_ACTION smenu1
244     "mubitem2" MENU_ACTION|DYN_SUB_MENU smenu2
245     "subitem3" MENU_ACTION smenu3
246 }
247
248 ; format: MENU "name" left,top ALIGN { "itemname" TYPE pointer ... }
249 MENU mainMenu 0,0 HORIZONTAL
250 ; here we have our main menu placed at (0,0) and it is a horizontal menu
251 ; since it is a top level menu you would register it in C source using
252 ; DoMenu(&mainMenu);
253 {
254 ; there are two items - a submenu and an action menu
255 ; this calls submenu named subMenu1 (see previous definition)
256     "sub menu1" SUB_MENU subMenu1
257 ; this will work the same as EnterDeskTop() call from C source
258     "quit"     MENU_ACTION EnterDeskTop
259 }
260
261 ; format: HEADER GEOS_TYPE "dosname" "classname" "version"
262 HEADER APPLICATION "MyFirstApp" "Class Name" "V1.0"
263 ; this is a header for APPLICATION which wille be seen in directory as
264 ; file named MyFirstApp with Class "Class Name V1.0"
265 {
266 ; not all fields are required, default and current values will be used
267     author "Maciej Witkowiak"                   ; always in quotes!
268     info "Information text"                     ; always in quotes!
269 ;    date yy mm dd hh ss                        ; always 5 fields!
270 ;    dostype seq                                ; can be PRG, SEQ, USR (only UPPER or lower case)
271     mode c64only                                ; can be any, 40only, 80only, c64only
272 }
273
274 --- cut here ---