.. _skoolMacros: Skool macros ============ `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: * ``MACRO`` is the macro name * ``rparam1``, ``rparam2`` etc. are required parameters * ``oparam1``, ``oparam2`` etc. are optional parameters 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 General macros ^^^^^^^^^^^^^^ .. _BUG: #BUG ---- In HTML mode, the ``#BUG`` macro expands to a hyperlink (```` element) to the 'Bugs' page, or to a specific entry on that page. :: #BUG[#name][(link text)] * ``#name`` is the named anchor of a bug (if linking to a specific one) * ``link text`` is the link text to use 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: .. parsed-literal:: :class: nonexistent 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'. See also :ref:`FACT` and :ref:`POKE`. +---------+-----------------------------------------------------------------+ | Version | Changes | +=========+=================================================================+ | 2.3.1 | If left blank, the link text defaults to the bug entry title in | | | HTML mode | +---------+-----------------------------------------------------------------+ .. _CALL: #CALL ----- 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 :ref:`ref-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 :ref:`writer` ASM directive in the `skool` file). :: #CALL:methodName(args) * ``methodName`` is the name of the method to call * ``args`` is a comma-separated list of arguments to pass to the method 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 :ref:`extending SkoolKit `. +---------+----------------------------+ | Version | Changes | +=========+============================+ | 3.1 | Added support for ASM mode | +---------+----------------------------+ | 2.1 | New | +---------+----------------------------+ .. _CHR: #CHR ---- 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: .. parsed-literal:: :class: nonexistent 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 | +---------+---------+ .. _D: #D -- The ``#D`` (Description) macro expands to the title of an entry (a routine or data block) in the memory map. :: #Daddr * ``addr`` is the address of the entry. 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. .. _EREFS: #EREFS ------ 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 * ``addr`` is the address to search for references to See also :ref:`m-REFS`. +---------+----------------------------+ | Version | Changes | +=========+============================+ | 3.1 | Added support for ASM mode | +---------+----------------------------+ .. _FACT: #FACT ----- In HTML mode, the ``#FACT`` macro expands to a hyperlink (```` element) to the 'Trivia' page, or to a specific entry on that page. :: #FACT[#name][(link text)] * ``#name`` is the named anchor of a trivia entry (if linking to a specific one) * ``link text`` is the link text to use 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. See also :ref:`BUG` and :ref:`POKE`. +---------+-----------------------------------------------------------------+ | 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 | +---------+-----------------------------------------------------------------+ .. _HTML: #HTML ----- 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 here.) 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 :ref:`UDGTABLE`. +---------+---------+ | Version | Changes | +=========+=========+ | 3.1.2 | New | +---------+---------+ .. _LINK: #LINK ----- In HTML mode, the ``#LINK`` macro expands to a hyperlink (```` element) to another page. :: #LINK:PageId[#name](link text) * ``PageId`` is the ID of the page to link to * ``name`` is the name of an anchor on the page to link to * ``link text`` is the link text to use In HTML mode, if the link text is blank, the page's link text (as defined in the :ref:`links` section or the relevant :ref:`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 :ref:`paths` section of a `ref` file, or the page IDs defined by :ref:`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 | +---------+------------------------------------------------------------------+ .. _LIST: #LIST ----- 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)]LIST# * ``class`` is the CSS class to use for the ``