<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<language name="ACME Assembler (C64)" version="1.0" kateversion="5.0" section="Assembler" extensions="*.asm;*.inc;*.s;*.a;*.lib" mimetype="text/x-acme-asm" author="Converted from Sublime" license="MIT">
  <highlighting>
    <list name="opcodes">
      <item>adc</item>
      <item>and</item>
      <item>asl</item>
      <item>bit</item>
      <item>clc</item>
      <item>cld</item>
      <item>cli</item>
      <item>clv</item>
      <item>cmp</item>
      <item>cpx</item>
      <item>cpy</item>
      <item>dec</item>
      <item>dex</item>
      <item>dey</item>
      <item>eor</item>
      <item>inc</item>
      <item>inx</item>
      <item>iny</item>
      <item>lda</item>
      <item>ldx</item>
      <item>ldy</item>
      <item>lsr</item>
      <item>nop</item>
      <item>ora</item>
      <item>pha</item>
      <item>php</item>
      <item>pla</item>
      <item>plp</item>
      <item>phx</item>
      <item>phy</item>
      <item>plx</item>
      <item>ply</item>
      <item>rol</item>
      <item>ror</item>
      <item>sbc</item>
      <item>sec</item>
      <item>sed</item>
      <item>sei</item>
      <item>sta</item>
      <item>stx</item>
      <item>stz</item>
      <item>sty</item>
      <item>tax</item>
      <item>txa</item>
      <item>tay</item>
      <item>tya</item>
      <item>tsx</item>
      <item>txs</item>
      <item>trb</item>
      <item>tsb</item>
      <item>bbr</item>
      <item>bbs</item>
      <item>rmb</item>
      <item>smb</item>
      <item>stp</item>
      <item>wat</item>
    </list>

    <list name="illegal_opcodes">
      <item>aac</item>
      <item>aax</item>
      <item>alr</item>
      <item>anc</item>
      <item>ane</item>
      <item>arr</item>
      <item>aso</item>
      <item>asr</item>
      <item>atx</item>
      <item>axa</item>
      <item>axs</item>
      <item>dcm</item>
      <item>dcp</item>
      <item>dop</item>
      <item>hlt</item>
      <item>ins</item>
      <item>isb</item>
      <item>isc</item>
      <item>jam</item>
      <item>kil</item>
      <item>lae</item>
      <item>lar</item>
      <item>las</item>
      <item>lax</item>
      <item>lse</item>
      <item>lxa</item>
      <item>oal</item>
      <item>rla</item>
      <item>rra</item>
      <item>sax</item>
      <item>sbx</item>
      <item>skb</item>
      <item>sha</item>
      <item>shs</item>
      <item>say</item>
      <item>shx</item>
      <item>shy</item>
      <item>slo</item>
      <item>skw</item>
      <item>sre</item>
      <item>sxa</item>
      <item>sya</item>
      <item>tas</item>
      <item>top</item>
      <item>xaa</item>
      <item>xas</item>
    </list>

    <list name="control_flow">
      <item>bcc</item>
      <item>bcs</item>
      <item>beq</item>
      <item>bmi</item>
      <item>bne</item>
      <item>bra</item>
      <item>bpl</item>
      <item>brk</item>
      <item>bvc</item>
      <item>bvs</item>
      <item>jmp</item>
      <item>jsr</item>
      <item>rti</item>
      <item>rts</item>
    </list>

    <list name="colors">
      <item>BLACK</item>
      <item>WHITE</item>
      <item>RED</item>
      <item>CYAN</item>
      <item>PURPLE</item>
      <item>GREEN</item>
      <item>BLUE</item>
      <item>YELLOW</item>
      <item>ORANGE</item>
      <item>BROWN</item>
      <item>LIGHT_RED</item>
      <item>DARK_GRAY</item>
      <item>GRAY</item>
      <item>DARK_GREY</item>
      <item>GREY</item>
      <item>LIGHT_GREEN</item>
      <item>LIGHT_BLUE</item>
      <item>LIGHT_GRAY</item>
      <item>LIGHT_GREY</item>
    </list>

    <contexts>
      <context name="Normal" attribute="Normal Text" lineEndContext="#stay">
        <!-- Block comments -->
        <Detect2Chars attribute="Comment" context="BlockComment" char="/" char1="*" beginRegion="Comment"/>
        
        <!-- Line comments -->
        <Detect2Chars attribute="Comment" context="LineComment" char="/" char1="/"/>
        
        <!-- Strings -->
        <DetectChar attribute="String" context="String" char="&quot;"/>
        
        <!-- Preprocessor directives at start of line or after semicolon -->
        <RegExpr attribute="Preprocessor" context="#stay" String="(?:^\s*|;\s*)\#(define|elif|if|undef)\s+[A-Za-z_][A-Za-z0-9_]*"/>
        <RegExpr attribute="Preprocessor" context="#stay" String="(?:^\s*|;\s*)\#(else|endif|importonce)\b"/>
        <RegExpr attribute="Preprocessor" context="#stay" String="(?:^\s*|;\s*)\#(import)(?=\s+&quot;)"/>
        <RegExpr attribute="Preprocessor" context="#stay" String="(?:^\s*|;\s*)\#(importif)\s+!*([A-Za-z_][A-Za-z0-9_]*)(?=\s+&quot;)"/>
        
        <!-- Directives -->
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.(word|byte|text|dword)\b"/>
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.(var|label|const)\b"/>
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.(struct|enum)\b"/>
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.(eval|fill|print|printnow|import|align|assert|asserterror|error)\b"/>
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.(pc|importonce|pseudopc|return|eval)\b"/>
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.(encoding)\b"/>
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.(for)\s*\(var\b"/>
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.if\b|(?:^|\s)else\b"/>
        <RegExpr attribute="Directive" context="#stay" String="(?:^|\s)\.(while)(?=\s*\()"/>
        
        <!-- Special constructs -->
        <RegExpr attribute="Function" context="#stay" String="(?:^\s*|;\s*)\.(filenamespace)\s*[A-Za-z_][A-Za-z0-9_]*"/>
        <RegExpr attribute="Function" context="#stay" String="(?:^\s*|;\s*)\.(namespace)\s*[A-Za-z_][A-Za-z0-9_]*"/>
        <RegExpr attribute="Function" context="#stay" String="(?:^\s*|;\s*)\.(pseudocommand)\s*\@*[A-Za-z_][A-Za-z0-9_]*"/>
        <RegExpr attribute="Function" context="#stay" String="(?:^\s*|;\s*)\.(function)\s*\@*[A-Za-z0-9_]*"/>
        <RegExpr attribute="Function" context="#stay" String="(?:^\s*|;\s*)\.(macro)\s*\@*[A-Za-z_][A-Za-z0-9_]*"/>
        
        <!-- Labels -->
        <RegExpr attribute="Label" context="#stay" String="(?:^\s*|;\s*)(!|!?(\@*[A-Za-z_][A-Za-z0-9_]*)+):"/>
        
        <!-- PC assignment -->
        <RegExpr attribute="Keyword" context="#stay" String="(?:^\s*|;\s*)\*(?=\s*=)"/>
        
        <!-- Built-in functions -->
        <RegExpr attribute="Function" context="#stay" String="\b(getNamespace)\b"/>
        <RegExpr attribute="Function" context="#stay" String="\b(toIntString|toBinaryString|toOctalString|toHexString)\b"/>
        <RegExpr attribute="Function" context="#stay" String="\b(abs|acos|asin|atan|atan2|cbrt|ceil|cos|cosh|exp|expm1|floor|hypot|IEEEremainder|log|log10|log1p|max|min|pow|mod|random|round|signum|sin|sinh|sqrt|tan|tanh|toDegrees|toRadians)\b"/>
        <RegExpr attribute="Function" context="#stay" String="\b(LoadBinary|LoadPicture|LoadSid|createFile)\b"/>
        <RegExpr attribute="Function" context="#stay" String="\b(Matrix|RotationMatrix|ScaleMatrix|MoveMatrix|PerspectiveMatrix|Vector)\b"/>
        
        <!-- Constants -->
        <RegExpr attribute="Constant" context="#stay" String="\b(true|false)\b"/>
        <RegExpr attribute="Constant" context="#stay" String="\b(PI|E)\b"/>
        <keyword attribute="Constant" context="#stay" String="colors"/>
        <RegExpr attribute="Constant" context="#stay" String="\b(LDA_IMM|LDA_ZP|LDA_ZPX|LDX_ZPY|LDA_IZPX|LDA_IZPY|LDA_ABS|LDA_ABSX|LDA_ABSY|JMP_IND|BNE_REL|RTS)\b"/>
        <RegExpr attribute="Constant" context="#stay" String="\b(BF_C64FILE|BF_BITMAP_SINGLECOLOR|BF_KOALA|BF_FLI)\b"/>
        <RegExpr attribute="Constant" context="#stay" String="\b(AT_ABSOLUTE|AT_ABSOLUTEX|AT_ABSOLUTEY|AT_IMMEDIATE|AT_INDIRECT|AT_IZEROPAGEX|AT_IZEROPAGEY|AT_NONE)\b"/>
        
        <!-- Types -->
        <RegExpr attribute="Type" context="#stay" String="\b(CmdArgument|Hashtable)\b"/>
        <RegExpr attribute="Type" context="#stay" String="\b(list|List)\(\s*\$?\d*\s*\)"/>
        
        <!-- Control flow opcodes -->
        <keyword attribute="ControlFlow" context="#stay" String="control_flow"/>
        
        <!-- Illegal opcodes -->
        <keyword attribute="IllegalOpcode" context="#stay" String="illegal_opcodes"/>
        
        <!-- Regular opcodes -->
        <keyword attribute="Opcode" context="#stay" String="opcodes"/>
        
        <!-- Numbers -->
        <RegExpr attribute="Hex" context="#stay" String="#?\$[0-9a-fA-F]+"/>
        <RegExpr attribute="Binary" context="#stay" String="#?%[01]+"/>
        <RegExpr attribute="Number" context="#stay" String="\b\d+"/>
      </context>

      <context name="BlockComment" attribute="Comment" lineEndContext="#stay">
        <Detect2Chars attribute="Comment" context="#pop" char="*" char1="/" endRegion="Comment"/>
      </context>

      <context name="LineComment" attribute="Comment" lineEndContext="#pop"/>

      <context name="String" attribute="String" lineEndContext="#stay">
        <RegExpr attribute="Escape" context="#stay" String="\\."/>
        <DetectChar attribute="String" context="#pop" char="&quot;"/>
      </context>
    </contexts>

    <itemDatas>
      <itemData name="Normal Text" defStyleNum="dsNormal"/>
      <itemData name="Opcode" defStyleNum="dsKeyword"/>
      <itemData name="IllegalOpcode" defStyleNum="dsWarning" italic="1"/>
      <itemData name="ControlFlow" defStyleNum="dsControlFlow" bold="1"/>
      <itemData name="Directive" defStyleNum="dsAttribute" bold="1"/>
      <itemData name="Preprocessor" defStyleNum="dsPreprocessor"/>
      <itemData name="Comment" defStyleNum="dsComment"/>
      <itemData name="String" defStyleNum="dsString"/>
      <itemData name="Escape" defStyleNum="dsSpecialChar"/>
      <itemData name="Number" defStyleNum="dsDecVal"/>
      <itemData name="Hex" defStyleNum="dsBaseN"/>
      <itemData name="Binary" defStyleNum="dsBaseN"/>
      <itemData name="Constant" defStyleNum="dsConstant"/>
      <itemData name="Function" defStyleNum="dsFunction"/>
      <itemData name="Label" defStyleNum="dsVariable" bold="1"/>
      <itemData name="Keyword" defStyleNum="dsKeyword"/>
      <itemData name="Type" defStyleNum="dsDataType"/>
    </itemDatas>
  </highlighting>

  <general>
    <comments>
      <comment name="singleLine" start="//"/>
    </comments>
    <keywords casesensitive="0"/>
  </general>
</language>
