grc.txt
来自「cc65 的编译器文档」· 文本 代码 · 共 232 行
TXT
232 行
grc - GEOS resource compiler Maciej 'YTM/Elysium' Witkowiak <ytm@elysium.pl> VII 2000 VI,VII 20021. Overview-----------grc is a part of cc65's GEOS support. This tool is necessary to generaterequired and optional resources. A required resource for every GEOS app is theheader, that is: icon, some strings and addresses. Optional resources might bemenu definitions, other headers (e.g. for data files of an app), dialogsdefinitions etc. Without application header GEOS is unable to load and startit.Currently, grc supports only menus and required header definition as long withsupport for building VLIR structured files.grc generates output in three formats - as C header, ca65 source (.s) and forlinking VLIR - ld65 configuration file. This is because application header datamust be in assembler format while menu definitions can be easily translatedinto C. The purpose of C file is to include it as header in only one projectfile. Assembler source should be processed with ca65 and linked as first object(read Building process below). VLIR structure is currently supported only forproject written entirely in assembler.grc can be also used as a handy VLIR linker used to build VLIR-structured .cvtfile out of prepared binary chains.2. Usage--------grc accepts following options: -f force writting output files -o name name C output file -s name name S output file -l name name ld65 output file -h helpwhen used as VLIR linker the correct syntax is: grc -vlir output.cvt header.bin vlir0.bin vlir1.bin...Default output names are made from input name with extension replaced by '.h'and '.s'. grc will not overwrite existing files unless forced to do so.This is to avoid situation where you have test.c and test.grc files. Both wouldmake output into test.s. For this reason you should name your resources filesdifferently than sources, e.g. as resource.grc or apphead.grc.3. Resource file format-----------------------A resource file has name extension '.grc'. This is not required, but it willmake easier recognition of file purpose. Also cl65 recognizes these files.Parser is very weak at the moment so read the comments carefully and writeresources exactly as it is written here. Look out for CAPS and small letters.Everything after a ';' till the end of line is considered as comment andignored.See included commented example .grc file for better view of the problem.a) menu definitionMENU menuName leftx,topy ORIENTATION{ "item name 1" MENU_TYPE pointer ... "item name x" MENU_TYPE pointer}The definition starts with keyword MENU, then goes menu name, which will berepresented in C as const void. Then are coordinates of top left cornerof menu box. The position of bottom right corner is estimated basing on lengthof item names and menu orientation. It means that menu box will be alwaysas large as it should be. Then there's orientation keyword, it can be eitherHORIZONTAL or VERTICAL.Between { and } there's menu content. It consists of item definitions.First is item name - it has to be in quotes. Next is menu type bit. It canbe MENU_ACTION or SUB_MENU, both can be combined with DYN_SUB_MENU bit(see GEOSLib documentation for description of these). You can use C logicaloperators in expressions but you have to do it without spaces, so dynamicallycreated submenu will be something like: "dynamic" SUB_MENU|DYN_SUB_MENU create_dynamicThe last part of the item definition is a pointer which can be any name whichis present in source that includes generated header. It can point to a functionor to another menu definition.If you are doing sub(sub)menus definitions remember to place the lowest leveldefinition first and top lever menu as the last one. This way C compiler won'tcomplain about unknown names.b) header definitionHEADER GEOS_TYPE "dosname" "classname" "version"{ author "Joe Schmoe" info "This is my killer-app!" date yy mm dd hh ss dostype SEQ mode any structure SEQ}Header definition describes GEOS header sector which is unique to each file.Currently there's no way to change default grc icon (an empty frame). It willbe possible in next versions.The definition starts with keyword HEADER, then goes GEOS file type. You canonly use APPLICATION here at the moment. Then there are (all in quotes) DOSfilename (up to 16 characters), GEOS Class name (up to 12 characters) andversion info (up to 4 characters). Version should be written as "Vx.y" wherex is the major and y the minor version number. These fields along with bothbrackets are required. Data between brackets is optional and will be replacedby default and current values.Keyword 'author' and value in quotes describes Author field and can be up to63 bytes long.Info (in the same format) can have up to 95 characters.If 'date' field will be ommited then the time of compilation will be placed.Note that if you do specify the date you have to write all 5 numbers.Dostype can by SEQ, PRG or USR. USR is by default, GEOS doesn't care.Mode can be 'any', '40only', '80only', 'c64only' and describes systemrequirements. 'any' will work both on GEOS64 and GEOS128 in 40 and 80 columnmodes. '40only' will work on GEOS128 in 40 column mode only. '80only' willwork only on GEOS128 and 'c64only' will work only on GEOS64.The default value for 'structure' is SEQ (sequential). You can also put 'VLIR'there but then you have also to place third type of resources - VLIR tabledescription.c) VLIR table descriptionVLIR headname address { vlir0 blank vlir2 blank vlir4}The first element is keyword 'VLIR', then goes the name for header binary name(read below) and base address for all VLIR chains diffrent than 0. It can beeither decimal (e.g. '4096') or hexadecimal with '0x' prefix (e.g. '0x1000').Then between brackets are names of vlir chain binaries or keyword 'blank' whichdenotes empty chains. In this example chains #1 and #3 are missing.The names between brackets are names of binaries containing code for each VLIRpart. They matter only for generated ld65 configuration file and will be thenames of resulting binary files after linking. Each one will contain one VLIRchain and they will have to be put together into VLIR .cvt by grc in VLIR linkermodey in correct order.The 'headname' will be the name for binary which will contain only GEOS .cvtheader made out of compiling .s header file generated also by grc.At the end of resulting ld65 config file (.cfg) in comments there will beinformation what commands are required for putting the stuff together. Readinfo below and see example somewhere around.4. Building GEOS application (SEQUENTIAL)----------------------------Before proceeding please read cc65, ca65 and ld65 documentation and findappropriate sections about compiling programs in general.GEOS support in cc65 is based on well-known in GEOS world Convert v2.5 format.It means that each file built with cc65 package has to unconverted beforerunning.Each project consists of four parts, two are provided by cc65. These parts are:a) application headerb) main objectc) application objectsd) system libraryb) and d) are with cc65, you have to write application yourself ;)Application header is defined in HEADER section of .grc file and processedinto assembler .s file. You have to compile it with ca65 to object .o format.4a. Building GEOS application without cl65-----------------------------------------Assume that there are three input files: test.c (a C source), test.h (a headerfile) and resource.grc (with menu and header definition). Note the fact that IDON'T RECOMMEND naming this file test.grc, because you will have to be verycareful with names (grc will make test.s and test.h out of test.grc by defaultand you don't want that, because test.s is compiled test.c and test.h issomething completely different).Important thing - the top of test.c looks like:--- cut here ---#include <geos.h>#include "resource.h"--- cut here ---There are no other includes.1. First step - compiling resources:$ grc resource.grcwill produce two output files: resource.h and resource.sNote that resource.h is included at the top of test.c so resource compilingmust be the first step.2. Second step - compiling the code:$ cc65 -t geos -O test.c$ ca65 -t geos test.sThis way you have test.o object file which contains all the executable code.3. Third step - compiling the application header$ ca65 -t geos resource.sAnd voil
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?