home *** CD-ROM | disk | FTP | other *** search
- * Documentation for User-defined symbols April 1994
- * ======================================
- * Starting vith version 4.00, ReSource will accept user-defined symbols.
- * This document will show you how to construct your own symbol bases for use
- * in ReSource.
- *
- * A symbol base starts with a longword pointer to the name for this symbol
- * base. Only the first 23 characters of this name will be used in the
- * menus.
- *
- * There are 2 basic types of user-defined symbol bases. The most used type
- * will be one in which any particular value can only equate to one symbol.
- *
- * In the other type the target number is considered to be one or more groups
- * of bit fields, and each field may or may not equate to a symbol. The
- * resulting symbols are OR'd together, to create the final string. For
- * example, "MEMF_CLEAR!MEMF_CHIP" is comprised of two symbols, the first
- * equates to $10000; the second equates to 2. Therefore, the number that
- * created this string must have been $10002.
- *
- * ReSource looks at the byte following the name pointer to know which type of
- * symbol base is being defined.
- *
- * If bit 7 is clear, this is the first type, a simple symbol base. ReSource
- * will also need to know whether the values in this symbol base are signed,
- * and also their size (byte/word/longword). Bit 4 is set for signed values,
- * cleared for unsigned. The lower nibble of this byte is 1 for bytes, 2 for
- * words, and 3 for longwords.
- *
- * If bit 7 is set, the second symbol base, or compound type using OR'd
- * symbols, is being defined.
- *
- * Simple Symbol Base
- * ------------------
- * Following the symbol base type byte are zero or more entries, each
- * consisting of a null-terminated string, followed immediately by the value
- * assigned to that string. Word and longword values are NOT expected to be
- * word-aligned, although the entire structure IS; make sure you enter a CNOP
- * after the name. The order of these entries must be such that the values
- * are in ascending (unsigned) order.
- *
- * Compound Symbol Base
- * --------------------
- * Following the symbol base type byte are zero or more entries, each
- * consisting of a null-terminated string, followed immediately by 2
- * longwords. ReSource AND's the target value with the first longword value,
- * and compares the result to the second longword value. If the comparison
- * succeeds, the string defined in this entry becomes part of the produced
- * string. If there is more than one symbol produced, it is OR'ed with the
- * others, and the entire string is surrounded by parentheses.
- *
- * In either case the last entry must be followed by a -1 byte, which
- * terminates the symbol base. Following are a few macros and equates which
- * may be handy when creating symbol bases. Remember, except for the
- * structure itself, no word alignment of word or longword fields is expected
- * or desired; if you do use any pad bytes, incorrect symbols may be produced.
- * Once you have written a compete symbol base, assemble it, link it, and the
- * resulting executable can be loaded into ReSource.
- *
- * Loading User Symbol Bases
- * -------------------------
- * Use the SYMBOLS gadget to bring up the Symbols ListView and select
- * "UserSymbols" from the directory gadget, "User Symbols" from the file
- * gadget, and any base from the "Symbol Base" gadget. Then click on
- * "Load user symbols" to actually load your previously defined symbol base
- * into ReSource. When the requester pops up, select the pathname of your
- * symbol base.
- *
- * Now that your symbol base has been loaded, whenever you wish to assign a
- * symbol, select your base from the "Individual SymbolBases" gadget to create
- * a symbol using that particular base.
- *
- * To unload a symbol base, select it from the "Individual SymbolBases" gadget
- * and then select CANCEL on the requester.
-
- ByteSymbol macro
- dc.b '\1'
- dc.b 0
- dc.b (\2)
- endm
-
- WordSymbol macro
- dc.b '\1'
- dc.b 0
- dc.b ((\2>>8)&$FF)
- dc.b (\2&$FF)
- endm
-
- LongSymbol macro
- dc.b '\1'
- dc.b 0
- dc.b ((\2>>24)&$FF)
- dc.b ((\2>>16)&$FF)
- dc.b ((\2>>8)&$FF)
- dc.b (\2&$FF)
- endm
-
- ORedSymbol macro
- dc.b '\1'
- dc.b 0
- dc.b ((\2>>24)&$FF)
- dc.b ((\2>>16)&$FF)
- dc.b ((\2>>8)&$FF)
- dc.b (\2&$FF)
- dc.b ((\3>>24)&$FF)
- dc.b ((\3>>16)&$FF)
- dc.b ((\3>>8)&$FF)
- dc.b (\3&$FF)
- endm
-
- OREDSYM equ 1<<7 ;Symbol base using OR'd symbols
- SIGNEDSYM equ 1<<4 ;Symbol base using signed symbols
- BYTESYM equ 1<<0 ;Symbol base using byte symbols
- WORDSYM equ 1<<1 ;Symbol base using word symbols
- LONGSYM equ BYTESYM!WORDSYM ;Symbol base using long symbols
- ENDBASE equ $FF ;Token to end symbol base
-
-
- In this example, we will create a symbol base for a standard list node
- structure. This has only 6 symbols in it, and the largest of these has a
- value of only $0E (LN_SIZE). Because of this, we shall define the values as
- bytes. None of the values are considered to be signed, so our first byte
- of symbol base will be BYTESYM:
-
- dc.l listnodename
- dc.b BYTESYM
- ByteSymbol <LN_SUCC>,$00
- ByteSymbol <LN_PRED>,$04
- ByteSymbol <LN_TYPE>,$08
- ByteSymbol <LN_PRI>,$09
- ByteSymbol <LN_NAME>,$0A
- ByteSymbol <LN_SIZE>,$0E
- dc.b ENDBASE ;Required to terminate symbol base
- listnodename dc.b 'List Node',0 ;This will appear in the menu in ReSource
- cnop 0,2
-
-
- * This example demonstrates the use of signed word values. The actual
- * symbols and values are similar to those in the "console library" symbol
- * base in ReSource:
-
- dc.l consolename
- dc.b SIGNEDSYM!WORDSYM ;Signed word
- WordSymbol <LIB+LN_SUCC>,$00
- WordSymbol <LIB+LN_PRED>,$04
- WordSymbol <LIB+LN_TYPE>,$08
- WordSymbol <LIB+LN_PRI>,$09
- WordSymbol <LIB+LN_NAME>,$0A
- WordSymbol <LIB_FLAGS>,$0E
- WordSymbol <LIB_pad>,$0F
- WordSymbol <LIB_NEGSIZE>,$10
- WordSymbol <LIB_POSSIZE>,$12
- WordSymbol <LIB_VERSION>,$14
- WordSymbol <LIB_REVISION>,$16
- WordSymbol <LIB_IDSTRING>,$18
- WordSymbol <LIB_SUM>,$1C
- WordSymbol <LIB_OPENCNT>,$20
- WordSymbol <LIB_SIZE>,$22
- WordSymbol <_LVOSetDefaultKeyMap>,-$3C
- WordSymbol <_LVOAskDefaultKeyMap>,-$36
- WordSymbol <_LVORawKeyConvert>,-$30
- WordSymbol <_LVOCDInputHandler>,-$2A
- WordSymbol <LIB_EXTFUNC>,-$24
- WordSymbol <LIB_EXPUNGE>,-$18
- WordSymbol <LIB_CLOSE>,-$12
- WordSymbol <LIB_OPEN>,-$6
- dc.b ENDBASE ;Terminate symbol base
- consolename dc.b 'Console library',0
- cnop 0,2
-
-
- * This example introduces a compound symbol base. Use this type when
- * several symbols may have to be OR'ed together to get the required value.
- * To create a compound symbol base, the first byte after the symbol base
- * name pointer must have bit 7 set. The actual symbol base used here is
- * similar to the one for memory attributes in ReSource:
-
- dc.l memattrname
- dc.b OREDSYM ;OR'ed symbols
- OredSymbol <MEMF_ANY>,-1,0 ;Must match exactly
- OredSymbol <MEMF_PUBLIC>,1<<0,1<<0
- OredSymbol <MEMF_CHIP>,1<<1,1<<1
- OredSymbol <MEMF_FAST>,1<<2,1<<2
- OredSymbol <MEMF_CLEAR>,1<<16,1<<16
- OredSymbol <MEMF_LARGEST>,1<<17,1<<17
- dc.b ENDBASE ;Terminate symbol base
- memattrname dc.b 'Memory attributes',0
- cnop 0,2
-
- * Notice that each entry has TWO values, where previous symbol bases had only
- * one. ReSource AND's the target value with the first number, and compares
- * it with the second. If the comparison succeeds, the symbol gets OR'ed with
- * the rest of the entries which succeed.
- *
- * Thus, if the target value was "$00010001", the actual symbol produced would
- * be "MEMF_CLEAR!MEMF_PUBLIC". This type of symbol base is already used in
- * ReSource for Memory Attributes, Alert Codes, Font Flags, MenuItem Flags and
- * many more.
-
-
- * The next example is similar to the "Alert codes" symbol base, but has been
- * much reduced in size:
-
- dc.l alertcodename
- dc.b OREDSYM!LONGSYM ;OR'ed symbols, unsigned, longword
- LongSymbol <AT_DeadEnd>,$80000000,$80000000
- LongSymbol <AT_Recovery>,$80000000,$00000000
- LongSymbol <AG_NoSignal>,$000F0000,$00070000
- LongSymbol <AG_IOError>,$000F0000,$00060000
- LongSymbol <AG_OpenRes>,$000F0000,$00050000
- LongSymbol <AG_OpenDev>,$000F0000,$00040000
- LongSymbol <AG_OpenLib>,$000F0000,$00030000
- LongSymbol <AG_MakeLib>,$000F0000,$00020000
- LongSymbol <AG_NoMemory>,$000F0000,$00010000
- LongSymbol <AO_GraphicsLib>,$0000FFFF,$00008002
- LongSymbol <AO_ExecLib>,$0000FFFF,$00008001
- LongSymbol <AO_DiskRsrc>,$0000FFFF,$00008021
- LongSymbol <AO_MiscRsrc>,$0000FFFF,$00008022
- LongSymbol <AO_BootStrap>,$0000FFFF,$00008030
- LongSymbol <AO_Workbench>,$0000FFFF,$00008031
- dc.b ENDBASE ;Terminate symbol base
- alertcodename dc.b 'Alert codes',0
-
- * The above example is much smaller than the actual "Alert codes" symbol
- * base in ReSource. However, it does demonstate that individual bit fields
- * can be masked out, and the remainder compared, to produce the required
- * symbols.
- *
- * It is interesting to note that because of the first 2 entries, ALL symbols
- * produced will start with either "AT_DeadEnd" or "AT_Recovery". Every bit
- * other than bit 31 is masked out, and then compared. If bit 31 is set, the
- * symbol will start with "AT_DeadEnd", otherwise "AT_Recovery". If you wish
- * to compare the entire longword, the first value should be -1. In this
- * case, only if the target number is EXACTLY equal to the second longword,
- * will the symbol for that entry be used.
-
- end
-