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 given in decimal notation (as already shown in the examples above), or in hexadecimal notation (prefixed by $):
#UDG$98E8,$06
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 byte at address 32768 is #CALL:peek(32768).
This instance of the #CALL macro expands to the return value of the peek 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 |
---|---|
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
or:
#CHR(num)
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 |
---|---|
3.1 | New |
The #D (Description) 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.
The #EREFS (Entry point REFerenceS) 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.
Version | Changes |
---|---|
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>.)
If text contains a closing bracket - ) - then the macro will not expand as required. In that case, square brackets, braces or any character that does not appear in text (except for an upper case letter) may be used as delimiters:
#HTML[text]
#HTML{text}
#HTML@text@
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 also #UDGTABLE.
Version | Changes |
---|---|
3.1.2 | 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’.
Version | Changes |
---|---|
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 |
In HTML mode, the #R (Reference) 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).
Version | Changes |
---|---|
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 (REFerenceS) 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.
Version | Changes |
---|---|
3.1 | Added support for ASM mode |
1.0.6 | Added the prefix parameter |
In HTML mode, the #REG (REGister) 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 contain 1, 2 or 3 of the following characters:
abcdefhlirspxy'
For example:
24623 LD C,31 ; #REGbc'=31
The #SPACE macro expands to one or more   expressions (in HTML mode) or spaces (in ASM mode).
#SPACE[num]
or:
#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 |
---|---|
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 text contains a closing bracket - ) - then the macro will not expand as required. In that case, square brackets, braces or any character that does not appear in text may be used as delimiters; for example:
#FONT:[(0) OK]$3D00
#FONT:{(0) OK}$3D00
#FONT:/(0) OK/$3D00
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 8*8 font whose graphic data starts at 49152.
Version | Changes |
---|---|
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 (SCReenshot) 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#
Version | Changes |
---|---|
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]
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 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 |
---|---|
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.
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 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 |
---|---|
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 (POKE Snapshot) 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.
Version | Changes |
---|---|
3.1 | Added support for ASM mode |
2.3.1 | Added support for multiple addresses |
The #POPS (POP Snapshot) 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 (PUSH Snapshot) 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.
Version | Changes |
---|---|
3.1 | Added support for ASM mode |