Skool files and ref files may contain skool macros that are ‘expanded’ to an appropriate piece of HTML markup (when rendering in HTML mode), or to an appropriate piece of plain text (when rendering in ASM mode).
Skool macros have the following general form:
#MACROrparam1,rparam2,...[,oparam1,oparam2,...]
where:
If an optional parameter is left blank or omitted entirely, it assumes its default value. So, for example:
#UDG39144
is equivalent to:
#UDG39144,56,4,1,0,0,0,1
and:
#UDG30115,,2
is equivalent to:
#UDG30115,56,2
Numeric parameters may be written in decimal notation:
#UDG51673,17
or in hexadecimal notation (prefixed by $):
#UDG$C9D9,$11
Wherever a sequence of numeric parameters appears in a macro, that sequence may optionally be enclosed in parentheses: ( and ). Parentheses are required if any numeric parameter is written as an expression containing arithmetic operations or skool macros:
#UDG(51672+1,#PEEK51672)
The following operators are permitted in an arithmetic expression:
Parentheses and spaces are also permitted in an arithmetic expression:
#IF(1 == 2 || (1 <= 2 && 2 < 3))(Yes,No)
Where a macro requires a single string parameter consisting of arbitrary text, it must be enclosed in parentheses, square brackets or braces:
(text)
[text]
{text}
If text contains unbalanced brackets, any non-whitespace character that is not present in text may be used as an alternative delimiter. For example:
/text/
|text|
Where a macro requires multiple string parameters consisting of arbitrary text, they must be enclosed in parentheses, square brackets or braces and be separated by commas:
(string1,string2)
[string1,string2]
{string1,string2}
Alternatively, an arbitrary delimiter - d, which cannot be whitespace - and separator - s, which can be whitespace - may be used. (They can be the same character.) The string parameters must open with ds, be separated by s, and close with sd. For example:
//same/delimiter/and/separator//
| different delimiter and separator |
This form is required if any of the strings contain a comma.
The macros described in this section constitute the Skool Macro Programming Language (SMPL). They can be used to programmatically specify values in the parameter string of any macro.
The #() macro expands the skool macros in its sole string parameter.
#(text)
It takes effect only when it immediately follows the opening token of another skool macro, and is expanded before that macro. For example:
#UDGARRAY#(2#FOR37159,37168,9||n|;(n+1),#PEEKn||)(item)
This instance of the #() macro expands the #FOR macro first, giving:
2;(37159+1),#PEEK37159;(37168+1),#PEEK37168
It then expands the #PEEK macros, ultimately forming the parameters of the #UDGARRAY macro.
See String parameters for details on alternative ways to supply the text parameter. Note that if an alternative delimiter is used, it must not be an alphanumeric character (A-Z, a-z, 0-9).
The #EVAL macro expands to the value of an arithmetic expression.
#EVALexpr[,base,width]
For example:
; The following mask byte is #EVAL(#PEEK29435,2,8).
29435 DEFB 62
This instance of the #EVAL macro expands to ‘00111110’ (62 in binary).
Version | Changes |
---|---|
5.1 | New |
The #FOR macro expands to a sequence of strings based on a range of integers.
#FORstart,stop[,step](var,string[,sep,fsep])
For example:
; The next three bytes (#FOR31734,31736||n|#PEEKn|, | and ||) define the
; item locations.
31734 DEFB 24,17,156
This instance of the #FOR macro expands to ‘24, 17 and 156’.
See String parameters for details on alternative ways to supply the var, string, sep and fsep parameters.
Version | Changes |
---|---|
5.1 | New |
The #FOREACH macro expands to a sequence of output strings based on a sequence of input strings.
#FOREACH([s1,s2,...])(var,string[,sep,fsep])
or:
#FOREACH(svar)(var,string[,sep,fsep])
For example:
; The next three bytes (#FOREACH(31734,31735,31736)||n|#PEEKn|, | and ||)
; define the item locations.
31734 DEFB 24,17,156
This instance of the #FOREACH macro expands to ‘24, 17 and 156’.
The #FOREACH macro recognises certain special variables, each one of which expands to a specific sequence of strings. The special variables are:
For example:
; The messages can be found at #FOREACH(ENTRYt)||n|n|, | and ||.
This instance of the #FOREACH macro expands to a list of the addresses of the entries of type t (text).
See String parameters for details on alternative ways to supply the var, string, sep and fsep parameters.
Version | Changes |
---|---|
5.1 | New |
The #IF macro expands to an arbitrary string based on the truth value of an arithmetic expression.
#IFexpr(true[,false])
For example:
; #FOR0,7||n|#IF(#PEEK47134 & 2**(7-n))(X,O)||
47134 DEFB 170
This instance of the #IF macro is used (in combination with a #FOR macro and a #PEEK macro) to display the contents of the address 47134 in the memory snapshot in binary format with ‘X’ for one and ‘O’ for zero: XOXOXOXO.
See String parameters for details on alternative ways to supply the true and false output strings.
Version | Changes |
---|---|
5.1 | New |
The #MAP macro expands to a value from a map of key-value pairs whose keys are integers.
#MAPkey(default[,k1:v1,k2:v2...])
For example:
; The next three bytes specify the directions that are available from here:
; #FOR56112,56114||q|#MAP(#PEEKq)(?,0:left,1:right,2:up,3:down)|, | and ||.
56112 DEFB 0,1,3
This instance of the #MAP macro is used (in combination with a #FOR macro and a #PEEK macro) to display a list of directions available based on the contents of addresses 56112-56114: ‘left, right and down’.
Note that the keys (k1, k2 etc.) may be expressed using arithmetic operations. They may also be expressed using skool macros, but in that case the entire parameter string of the #MAP macro must be enclosed by a #() macro.
See String parameters for details on alternative ways to supply the default output string and the key-value pairs.
Version | Changes |
---|---|
5.1 | New |
The #PEEK macro expands to the contents of an address in the memory snapshot.
#PEEKaddr
For example:
; At the start of the game, the number of lives remaining is #PEEK33879.
This instance of the #PEEK macro expands to the contents of the address 33879 in the memory snapshot.
See also #POKES.
Version | Changes |
---|---|
5.1 | New |
In HTML mode, the #BUG macro expands to a hyperlink (<a> element) to the ‘Bugs’ page, or to a specific entry on that page.
#BUG[#name][(link text)]
The anchor name must be limited to the characters ‘$’, ‘#’, 0-9, A-Z and a-z.
In HTML mode, if the link text is blank, the title of the bug entry (if linking to a specific one) is substituted; if the link text is omitted entirely, ‘bug’ is substituted.
In ASM mode, the #BUG macro expands to the link text, or ‘bug’ if the link text is blank or omitted.
For example:
42726 DEFB 130 ; This is a #BUG#bug1; it should be 188
In HTML mode, this instance of the #BUG macro expands to a hyperlink to an entry on the ‘Bugs’ page.
In ASM mode, this instance of the #BUG macro expands to ‘bug’.
Version | Changes |
---|---|
2.3.1 | If left blank, the link text defaults to the bug entry title in HTML mode |
In HTML mode, the #CALL macro expands to the return value of a method on the HtmlWriter class or subclass that is being used to create the HTML disassembly (as defined by the HtmlWriterClass parameter in the [Config] section of the ref file).
In ASM mode, the #CALL macro expands to the return value of a method on the AsmWriter class or subclass that is being used to generate the ASM output (as defined by the @writer ASM directive in the skool file).
#CALL:methodName(args)
For example:
; The word at address 32768 is #CALL:word(32768).
This instance of the #CALL macro expands to the return value of the word method (on the HtmlWriter or AsmWriter subclass being used) when called with the argument 32768.
For information on writing methods that may be called by a #CALL macro, see the documentation on extending SkoolKit.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in numeric method arguments |
3.1 | Added support for ASM mode |
2.1 | New |
In HTML mode, the #CHR macro expands to a numeric character reference (&#num;). In ASM mode, it expands to a unicode character in the UTF-8 encoding.
#CHRnum
For example:
26751 DEFB 127 ; This is the copyright symbol: #CHR169
In HTML mode, this instance of the #CHR macro expands to ©. In ASM mode, it expands to the copyright symbol.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the num parameter |
3.1 | New |
The #D macro expands to the title of an entry (a routine or data block) in the memory map.
#Daddr
For example:
; Now we make an indirect jump to one of the following routines:
; .
; #TABLE(default,centre)
; { =h Address | =h Description }
; { #R27126 | #D27126 }
This instance of the #D macro expands to the title of the routine at 27126.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the addr parameter |
The #EREFS macro expands to a comma-separated sequence of hyperlinks to (in HTML mode) or addresses of (in ASM mode) the routines that jump to or call a given address.
#EREFSaddr
See also #REFS.
Note
The #EREFS macro is deprecated since version 5.1. Consider using the special variable EREFaddr with the #FOREACH macro instead.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the addr parameter |
3.1 | Added support for ASM mode |
In HTML mode, the #FACT macro expands to a hyperlink (<a> element) to the ‘Trivia’ page, or to a specific entry on that page.
#FACT[#name][(link text)]
The anchor name must be limited to the characters ‘$’, ‘#’, 0-9, A-Z and a-z.
In HTML mode, if the link text is blank, the title of the trivia entry (if linking to a specific one) is substituted; if the link text is omitted entirely, ‘fact’ is substituted.
In ASM mode, the #FACT macro expands to the link text, or ‘fact’ if the link text is blank or omitted.
For example:
See the trivia entry #FACT#interestingFact() for details.
In HTML mode, this instance of the #FACT macro expands to a hyperlink to an entry on the ‘Trivia’ page, with link text equal to the title of the entry.
Version | Changes |
---|---|
2.3.1 | If left blank, the link text defaults to the trivia entry title in HTML mode; added support for ASM mode |
The #HTML macro expands to arbitrary text (in HTML mode) or to an empty string (in ASM mode).
#HTML(text)
The #HTML macro may be used to render HTML (which would otherwise be escaped) from a skool file. For example:
; #HTML(For more information, go <a href="http://example.com/">here</a>.)
text may contain other skool macros, which will be expanded before rendering. For example:
; #HTML[The UDG defined here (32768) looks like this: #UDG32768,4,1]
See String parameters for details on alternative ways to supply the text parameter. Note that if an alternative delimiter is used, it must not be an upper case letter.
See also #UDGTABLE.
Version | Changes |
---|---|
3.1.2 | New |
In HTML mode, the #INCLUDE macro expands to the contents of a ref file section; in ASM mode, it expands to an empty string.
#INCLUDE[paragraphs](section)
The #INCLUDE macro can be used to insert the contents of one ref file section into another. For example:
[MemoryMap:RoutinesMap]
Intro=#INCLUDE(RoutinesMapIntro)
[RoutinesMapIntro]
This is the intro to the 'Routines' map page.
See String parameters for details on alternative ways to supply the section parameter.
Version | Changes |
---|---|
5.3 | New |
In HTML mode, the #LINK macro expands to a hyperlink (<a> element) to another page.
#LINK:PageId[#name](link text)
In HTML mode, if the link text is blank, the page’s link text (as defined in the [Links] section or the relevant [Page:*] section of the ref file) is substituted.
In ASM mode, the #LINK macro expands to the link text.
The page IDs that may be used are the same as the file IDs that may be used in the [Paths] section of a ref file, or the page IDs defined by [Page:*] sections.
For example:
; See the #LINK:Glossary(glossary) for a definition of 'chuntey'.
In HTML mode, this instance of the #LINK macro expands to a hyperlink to the ‘Glossary’ page, with link text ‘glossary’.
In ASM mode, this instance of the #LINK macro expands to ‘glossary’.
To create a hyperlink to an entry on a memory map page, use the address of the entry as the anchor. For example:
; Now we update the #LINK:GameStatusBuffer#40000(number of lives).
In HTML mode, the anchor of this #LINK macro (40000) is converted to the format specified by the AddressAnchor parameter in the [Game] section.
Version | Changes |
---|---|
5.2 | An entry address anchor in a link to a memory map page is converted to the format specified by the AddressAnchor parameter |
3.1.3 | If left blank, the link text defaults to the page’s link text in HTML mode |
2.1 | New |
The #LIST macro marks the beginning of a list of bulleted items; LIST# is used to mark the end. Between these markers, the list items are defined.
#LIST[(class)]<items>LIST#
Each item in a list must start with { followed by a whitespace character, and end with } preceded by a whitespace character.
For example:
; #LIST(data)
; { Item 1 }
; { Item 2 }
; LIST#
This list has two items, and will have the CSS class ‘data’.
In ASM mode, lists are rendered as plain text, with each item on its own line, and an asterisk as the bullet character. The bullet character can be changed by using a @set directive to set the bullet property on the ASM writer.
Version | Changes |
---|---|
3.2 | New |
In HTML mode, the #POKE macro expands to a hyperlink (<a> element) to the ‘Pokes’ page, or to a specific entry on that page.
#POKE[#name][(link text)]
The anchor name must be limited to the characters ‘$’, ‘#’, 0-9, A-Z and a-z.
In HTML mode, if the link text is blank, the title of the poke entry (if linking to a specific one) is substituted; if the link text is omitted entirely, ‘poke’ is substituted.
In ASM mode, the #POKE macro expands to the link text, or ‘poke’ if the link text is blank or omitted.
For example:
; Of course, if you feel like cheating, you can always give yourself
; #POKE#infiniteLives(infinite lives).
In HTML mode, this instance of the #POKE macro expands to a hyperlink to an entry on the ‘Pokes’ page, with link text ‘infinite lives’.
In ASM mode, this instance of the #POKE macro expands to ‘infinite lives’.
Version | Changes |
---|---|
2.3.1 | If left blank, the link text defaults to the poke entry title in HTML mode; added support for ASM mode |
The #N macro renders a numeric value in hexadecimal format when the --hex option is used with skool2asm.py or skool2html.py, or in decimal format otherwise. A hexadecimal number is rendered in lower case when the --lower option is used, or in upper case otherwise.
#Nvalue[,hwidth,dwidth,affix][(prefix[,suffix])]
For example:
#N15,4,5,1(0x)
This instance of the #N macro expands to one of the following:
See String parameters for details on alternative ways to supply the prefix and suffix parameters.
Version | Changes |
---|---|
5.2 | New |
In HTML mode, the #R macro expands to a hyperlink (<a> element) to the disassembly page for a routine or data block, or to a line at a given address within that page.
#Raddr[@code][#name][(link text)]
The disassembly ID (code) and anchor name (name) must be limited to the characters ‘$’, ‘#’, 0-9, A-Z and a-z.
In ASM mode, the #R macro expands to the link text if it is specified, or to the label for addr, or to addr if no label is found.
For example:
; Prepare for a new game
;
; Used by the routine at #R25820.
In HTML mode, this instance of the #R macro expands to a hyperlink to the disassembly page for the routine at 25820.
In ASM mode, this instance of the #R macro expands to the label for the routine at 25820 (or simply 25820 if that routine has no label).
To create a hyperlink to the first instruction in a routine or data block, use an anchor that evaluates to the address of that instruction. For example:
; See the #R40000#40000(first item) in the data table at 40000.
In HTML mode, the anchor of this #R macro (40000) is converted to the format specified by the AddressAnchor parameter in the [Game] section.
Version | Changes |
---|---|
5.1 | An anchor that matches the entry address is converted to the format specified by the AddressAnchor parameter; added support for arithmetic expressions and skool macros in the addr parameter |
3.5 | Added the ability to resolve (in HTML mode) the address of an entry point in another disassembly when an appropriate remote entry is defined |
2.0 | Added support for the @code notation |
The #REFS macro expands to a comma-separated sequence of hyperlinks to (in HTML mode) or addresses of (in ASM mode) the routines that jump to or call a given routine, or jump to or call any entry point within that routine.
#REFSaddr[(prefix)]
If there are no references, the macro expands to the following text:
Not used directly by any other routines
See also #EREFS.
Note
The #REFS macro is deprecated since version 5.1. Consider using the special variable REFaddr with the #FOREACH macro instead.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the addr parameter |
3.1 | Added support for ASM mode |
1.0.6 | Added the prefix parameter |
In HTML mode, the #REG macro expands to a styled <span> element containing a register name.
#REGreg
In ASM mode, the #REG macro expands to the name of the register.
The register name must be one of the following:
a b c d e f h l
a' b' c' d' e' f' h' l'
af bc de hl
af' bc' de' hl'
ix iy ixh iyh ixl iyl
i r sp pc
For example:
24623 LD C,31 ; #REGbc'=31
Version | Changes |
---|---|
5.3 | Added support for the F and F’ registers |
5.1 | The reg parameter must be a valid register name |
The #SPACE macro expands to one or more   expressions (in HTML mode) or spaces (in ASM mode).
#SPACE[num]
For example:
; '#SPACE8' (8 spaces)
t56832 DEFM " "
In HTML mode, this instance of the #SPACE macro expands to:
        
In ASM mode, this instance of the #SPACE macro expands to a string containing 8 spaces.
The form SPACE([num]) may be used to distinguish the macro from adjacent text where necessary. For example:
; 'Score:#SPACE(5)0'
t49152 DEFM "Score: 0"
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the num parameter |
2.4.1 | Added support for the #SPACE([num]) syntax |
The #TABLE macro marks the beginning of a table; TABLE# is used to mark the end. Between these markers, the rows of the table are defined.
#TABLE[([class[,class1[:w][,class2[:w]...]]])]<rows>TABLE#
Each row in a table must start with { followed by a whitespace character, and end with } preceded by a whitespace character. The cells in a row must be separated by | with a whitespace character on each side.
For example:
; #TABLE(default,centre)
; { 0 | Off }
; { 1 | On }
; TABLE#
This table has two rows and two columns, and will have the CSS class ‘default’. The cells in the first column will have the CSS class ‘centre’.
By default, cells will be rendered as <td> elements. To render a cell as a <th> element, use the =h indicator before the cell contents:
; #TABLE
; { =h Header 1 | =h Header 2 }
; { Regular cell | Another one }
; TABLE#
It is also possible to specify colspan and rowspan attributes using the =c and =r indicators:
; #TABLE
; { =r2 2 rows | X | Y }
; { =c2 2 columns }
; TABLE#
Finally, the =t indicator makes a cell transparent (i.e. gives it the same background colour as the page body).
If a cell requires more than one indicator, separate the indicators by commas:
; #TABLE
; { =h,c2 Wide header }
; { Column 1 | Column 2 }
; TABLE#
The CSS files included in SkoolKit provide two classes that may be used when defining tables:
In ASM mode, tables are rendered as plain text, using dashes (-) and pipes (|) for the borders, and plus signs (+) where a horizontal border meets a vertical border.
ASM mode also supports the :w indicator in the #TABLE macro’s parameters. The :w indicator marks a column as a candidate for having its width reduced (by wrapping the text it contains) so that the table will be no more than 79 characters wide when rendered. For example:
; #TABLE(default,centre,:w)
; { =h X | =h Description }
; { 0 | Text in this column will be wrapped in ASM mode to make the table less than 80 characters wide }
; TABLE#
See also #UDGTABLE.
The #FONT, #SCR, #UDG and #UDGARRAY macros (described in the following sections) may be used to create images based on graphic data in the memory snapshot. They are not supported in ASM mode.
These macros have several numeric parameters, most of which are optional. This can give rise to a long sequence of commas in a macro parameter string, making it hard to read (and write); for example:
#UDG32768,,,,,,1
To alleviate this problem, the image macros accept keyword arguments at any position in the parameter string; the #UDG macro above could be rewritten as follows:
#UDG32768,rotate=1
In HTML mode, the #FONT macro expands to an <img> element for an image of text rendered in the game font.
#FONT[:(text)]addr[,chars,attr,scale][{CROP}][(fname)]
If an image with the given filename doesn’t already exist, it will be created. If fname starts with a ‘/’, the filename is taken to be relative to the root of the HTML disassembly; otherwise the filename is taken to be relative to the directory defined by the FontImagePath parameter in the [Paths] section of the ref file.
For example:
; Font graphic data
;
; #HTML[#FONT:(0123456789)49152]
In HTML mode, this instance of the #FONT macro expands to an <img> element for the image of the digits 0-9 in the 8x8 font whose graphic data starts at 49152.
See String parameters for details on alternative ways to supply the text parameter.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the numeric parameters |
4.3 | Added the ability to create frames |
4.2 | Added the ability to specify alt text for the <img> element |
4.0 | Added support for keyword arguments |
3.6 | Added the text parameter, and made the chars parameter optional |
3.0 | Added image-cropping capabilities |
2.0.5 | Added the fname parameter and support for regular 8x8 fonts |
In HTML mode, the #SCR macro expands to an <img> element for an image constructed from the display file and attribute file (or suitably arranged graphic data and attribute bytes elsewhere in memory) of the current memory snapshot (in turn constructed from the contents of the skool file).
#SCR[scale,x,y,w,h,df,af][{CROP}][(fname)]
If an image with the given filename doesn’t already exist, it will be created. If fname starts with a ‘/’, the filename is taken to be relative to the root of the HTML disassembly; otherwise the filename is taken to be relative to the directory defined by the ScreenshotImagePath parameter in the [Paths] section of the ref file.
For example:
; #UDGTABLE
; { #SCR(loading) | This is the loading screen. }
; TABLE#
Note
In SkoolKit 5.0 and earlier versions, #SCR(2) would create an image file named 2.png using the default parameter values. However, since the introduction in version 5.1 of support for arithmetic expressions in numeric parameters, #SCR(2) creates an image file with the default name and scale 2; to create an image file named 2.png with the default parameter values in SkoolKit 5.1+, write #SCR()(2) instead.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the numeric parameters |
4.3 | Added the ability to create frames |
4.2 | Added the ability to specify alt text for the <img> element |
4.0 | Added support for keyword arguments |
3.0 | Added image-cropping capabilities and the df and af parameters |
2.0.5 | Added the scale, x, y, w, h and fname parameters |
In HTML mode, the #UDG macro expands to an <img> element for the image of a UDG (an 8x8 block of pixels).
#UDGaddr[,attr,scale,step,inc,flip,rotate,mask][:MASK][{CROP}][(fname)]
The mask specification (MASK) takes the form:
addr[,step]
Note that if any of the parameters in the mask specification is expressed using arithmetic operations or skool macros, then the entire specification must be enclosed in parentheses.
If an image with the given filename (fname) doesn’t already exist, it will be created. If fname starts with a ‘/’, the filename is taken to be relative to the root of the HTML disassembly; otherwise the filename is taken to be relative to the directory defined by the UDGImagePath parameter in the [Paths] section of the ref file.
For example:
; Safe key UDG
;
; #HTML[#UDG39144,6(safe_key)]
In HTML mode, this instance of the #UDG macro expands to an <img> element for the image of the UDG at 39144 (which will be named safe_key.png or safe_key.gif), with attribute byte 6 (INK 6: PAPER 0).
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the numeric parameters |
4.3 | Added the ability to create frames |
4.2 | Added the ability to specify alt text for the <img> element |
4.0 | Added the mask parameter and support for AND-OR masking; added support for keyword arguments |
3.1.2 | Made the attr parameter optional |
3.0 | Added image-cropping capabilities |
2.4 | Added the rotate parameter |
2.3.1 | Added the flip parameter |
2.1 | Added support for masks |
2.0.5 | Added the fname parameter |
In HTML mode, the #UDGARRAY macro expands to an <img> element for the image of an array of UDGs (8x8 blocks of pixels).
#UDGARRAYwidth[,attr,scale,step,inc,flip,rotate,mask];SPEC1[;SPEC2;...][{CROP}](fname)
SPEC1, SPEC2 etc. are UDG specifications for the sets of UDGs that make up the array. Each UDG specification has the form:
addr[,attr,step,inc][:MASK]
The mask specification (MASK) takes the form:
addr[,step]
Address range specifications (addr) may be given in one of the following forms:
Any of these forms of address ranges can be repeated by appending xN, where N is the desired number of repetitions. For example:
As many UDG specifications as required may be supplied, separated by semicolons; the UDGs will be arranged in a rectangular array with the given width.
Note that, like the main parameters of a #UDGARRAY macro (up to but not including the first semicolon), if any of the following parts of the parameter string is expressed using arithmetic operations or skool macros, then that part must be enclosed in parentheses:
If an image with the given filename (fname) doesn’t already exist, it will be created. If fname starts with a ‘/’, the filename is taken to be relative to the root of the HTML disassembly; otherwise the filename is taken to be relative to the directory defined by the UDGImagePath parameter in the [Paths] section of the ref file.
For example:
; Base sprite
;
; #HTML[#UDGARRAY4;32768-32888-8(base_sprite.png)]
In HTML mode, this instance of the #UDGARRAY macro expands to an <img> element for the image of the 4x4 sprite formed by the 16 UDGs with base addresses 32768, 32776, 32784 and so on up to 32888; the image file will be named base_sprite.png.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the numeric parameters |
4.2 | Added the ability to specify alt text for the <img> element |
4.0 | Added the mask parameter and support for AND-OR masking; added support for keyword arguments |
3.6 | Added support for creating an animated image from an arbitrary sequence of frames |
3.1.1 | Added support for UDG address ranges with horizontal and vertical steps |
3.0 | Added image-cropping capabilities |
2.4 | Added the rotate parameter |
2.3.1 | Added the flip parameter |
2.2.5 | Added support for masks |
2.0.5 | New |
The value of the alt attribute in the <img> element created by an image macro can be specified by appending a | character and the required text to the filename. For example:
#SCR(screenshot1|Screenshot 1)
This #SCR macro creates an image named screenshot1.png with alt text ‘Screenshot 1’.
The image macros may be used to create the frames of an animated image. To create a frame, the fname parameter must have one of the following forms:
Then a special form of the #UDGARRAY macro creates the animated image from a set of frames:
#UDGARRAY*FRAME1[;FRAME2;...](fname)
FRAME1, FRAME2 etc. are frame specifications; each one has the form:
name[,delay]
For example:
; #UDGTABLE {
; #FONT:(hello)$3D00(hello*) |
; #FONT:(there)$3D00(there*) |
; #FONT:(peeps)$3D00(peeps*) |
; #UDGARRAY*hello,50;there;peeps(hello_there_peeps.gif)
; } TABLE#
The #FONT macros create the required frames (and write images of them); the #UDGARRAY macro combines the three frames into a single animated image, with a delay of 0.5s between each frame.
Each image macro accepts a cropping specification (CROP) which takes the form:
x,y,width,height
For example:
#UDG40000,scale=2{2,2,12,12}
This #UDG macro creates an image of the UDG at 40000, at scale 2, with the top two rows and bottom two rows of pixels removed, and the leftmost two columns and rightmost two columns of pixels removed.
The #UDG and #UDGARRAY macros accept a mask parameter that determines what kind of mask to apply to each UDG. The supported values are:
Given a ‘background’ bit (B), a UDG bit (U), and a mask bit (M), the OR-AND mask works as follows:
U | M | Result |
---|---|---|
0 | 0 | 0 (paper) |
0 | 1 | B (transparent) |
1 | 0 | 0 (paper) |
1 | 1 | 1 (ink) |
The AND-OR mask works as follows:
U | M | Result |
---|---|---|
0 | 0 | 0 (paper) |
0 | 1 | B (transparent) |
1 | 0 | 1 (ink) |
1 | 1 | 1 (ink) |
By default, transparent bits in masked images are rendered in bright green (#00fe00); this colour can be changed by modifying the TRANSPARENT parameter in the [Colours] section. To make the transparent bits in masked images actually transparent, set GIFTransparency=1 or PNGAlpha=0 in the [ImageWriter] section.
The #POKES, #POPS and #PUSHS macros (described in the following sections) may be used to manipulate the memory snapshot that is built from the DEFB, DEFM, DEFS and DEFW statements in the skool file. Each macro expands to an empty string.
The #POKES macro POKEs values into the current memory snapshot.
#POKESaddr,byte[,length,step][;addr,byte[,length,step];...]
For example:
The UDG looks like this:
#UDG32768(udg_orig)
But it's supposed to look like this:
#PUSHS
#POKES32772,254;32775,136
#UDG32768(udg_fixed)
#POPS
This instance of the #POKES macro does POKE 32772,254 and POKE 32775,136, which fixes a graphic glitch in the UDG at 32768.
See also #PEEK.
Version | Changes |
---|---|
5.1 | Added support for arithmetic expressions and skool macros in the numeric parameters |
3.1 | Added support for ASM mode |
2.3.1 | Added support for multiple addresses |
The #POPS macro removes the current memory snapshot and replaces it with the one that was previously saved by a #PUSHS macro.
#POPS
Version | Changes |
---|---|
3.1 | Added support for ASM mode |
The #PUSHS macro saves the current memory snapshot, and replaces it with an identical copy with a given name.
#PUSHS[name]
The snapshot name must be limited to the characters ‘$’, ‘#’, 0-9, A-Z and a-z; it must not start with a capital letter. The name can be retrieved by using the get_snapshot_name() method on HtmlWriter.
Version | Changes |
---|---|
3.1 | Added support for ASM mode |
By using the @replace directive, it is possible to define new macros based on existing ones without writing any Python code. Some examples are given below.
There is the #HTML macro for inserting content in HTML mode only, but there is no corresponding macro for inserting content in ASM mode only. The following @replace directive defines an #asm macro to fill that gap:
@replace=/#asm(\(.*\))/#IF(#HTML(1)0<1)\1
For example:
#asm(This text appears only in ASM mode.)
Suppose the game you’re disassembling arranges tiles in groups of nine bytes: the attribute byte first, followed by the eight graphic bytes. If there is a tile at 32768, then:
#UDG(32769,#PEEK32768)
will create an image of it. If you want to create several tile images, this syntax can get cumbersome; it would be easier if you could supply just the address of the attribute byte. The following @replace directive defines a #tile macro that creates a tile image given an attribute byte address:
@replace=/#tile\i/#UDG(\1+1,#PEEK\1)
Now you can create an image of the tile at 32768 like this:
#tile32768
If you have several nine-byte tiles arranged one after the other, you might want to create images of all of them in a single row of a #UDGTABLE. The following @replace directive defines a #tiles macro for this purpose:
@replace=/#tiles\i,\i/#FOR(\1,\1+9*(\2-1),9);;n;#UDG(n+1,#PEEKn); | ;;
Now you can create a #UDGTABLE of images of a series of 10 tiles starting at 32768 like this:
#UDGTABLE { #tiles32768,10 } TABLE#