From 879f94454221dcc68c810a2463ec46c2b0b6f77d Mon Sep 17 00:00:00 2001 From: cbrgray Date: Thu, 20 Jun 2024 17:53:33 +0100 Subject: [PATCH] support asar 1.91 --- README.md | 4 +- asarsyntaxhighlighter/changelog.md | 3 + asarsyntaxhighlighter/package.json | 2 +- asarsyntaxhighlighter/readme.md | 4 +- .../syntaxes/asar.tmLanguage | 76 ++++++++++++++++--- samples/highlight_test.asm | 61 ++++++++++++--- user-settings/default.json | 16 ++++ 7 files changed, 142 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index d28ef2f..7163361 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The best syntax highlighter for [Asar](https://github.com/RPGHacker/asar) projects in VS Code. ## Features -- Support for every function and directives in Asar 1.81 +- Support for every function and directives in Asar 1.91 - Support for 65c816, SPC700 and GSU/Super FX mnemonics - Custom scopes for literally everything supported - (Hopefully) smarter than the current options at the extensions marketplace @@ -13,7 +13,7 @@ Check the `samples` folder contents for some live previews of the highlighter. Some color settings have their own previews in `user-settings` folder's README.md file, you can check them out there. ## Extra info -You can check which scopes are affecting the text in the file by using `Developer: Inspect Editior Tokens and Scopes` in the command palette in VS Code. +You can check which scopes are affecting the text in the file by using `Developer: Inspect Editor Tokens and Scopes` in the command palette in VS Code. ## Bugs See the [current issues](https://github.com/TheLX5/AsarSyntaxHighlight-VSCode/issues) in order to check what's missing or doesn't work. diff --git a/asarsyntaxhighlighter/changelog.md b/asarsyntaxhighlighter/changelog.md index 7ab1fb3..006e810 100644 --- a/asarsyntaxhighlighter/changelog.md +++ b/asarsyntaxhighlighter/changelog.md @@ -1,3 +1,6 @@ +# Version 1.0.3 +- Now supports asar 1.91 + # Version 1.0.2 - Fixed macro labels not being captured in a scope if they're missing : at the end diff --git a/asarsyntaxhighlighter/package.json b/asarsyntaxhighlighter/package.json index cc9c2ab..cc5dbc5 100644 --- a/asarsyntaxhighlighter/package.json +++ b/asarsyntaxhighlighter/package.json @@ -5,7 +5,7 @@ "publisher": "lx5", "icon": "asar.ico", "description": "Syntax highlighter for Asar, a SNES assembler with support for 65c816, SPC700 and GSU mnemonics.", - "version": "1.0.2", + "version": "1.0.3", "repository": { "url": "https://github.com/TheLX5/AsarSyntaxHighlight-VSCode" }, diff --git a/asarsyntaxhighlighter/readme.md b/asarsyntaxhighlighter/readme.md index c30520a..9955603 100644 --- a/asarsyntaxhighlighter/readme.md +++ b/asarsyntaxhighlighter/readme.md @@ -5,13 +5,13 @@ Official GitHub Repo: https://github.com/TheLX5/AsarSyntaxHighlight-VSCode The best syntax highlighter for [Asar](https://github.com/RPGHacker/asar) projects. ## Features -- Support for every function and directive in Asar 1.81 +- Support for every function and directive in Asar 1.91 - Support for 65c816, SPC700 and GSU mnemonics - Custom scopes for literally everything supported - (Hopefully) smarter than the current options at the extensions marketplace ## Extra info -You can check which scopes are affecting the text in the file by using `Developer: Inspect Editior Tokens and Scopes` in the command palette in VS Code. +You can check which scopes are affecting the text in the file by using `Developer: Inspect Editor Tokens and Scopes` in the command palette in VS Code. ## Previews Check the [samples folder](https://github.com/TheLX5/AsarSyntaxHighlight-VSCode/tree/master/samples) contents for some live previews of the highlighter. diff --git a/asarsyntaxhighlighter/syntaxes/asar.tmLanguage b/asarsyntaxhighlighter/syntaxes/asar.tmLanguage index 4492109..5958a5a 100644 --- a/asarsyntaxhighlighter/syntaxes/asar.tmLanguage +++ b/asarsyntaxhighlighter/syntaxes/asar.tmLanguage @@ -128,8 +128,21 @@ Asar macro arguments name keyword.asar.macro.args.usage - match - <[a-zA-Z_0-9]+> + patterns + + + name + keyword.asar.macro.args.usage + match + <[a-zA-Z_0-9]+> + + + name + keyword.asar.macro.args.usage.variadic + match + <\.{3}(\[\S+\])?> + + @@ -550,6 +563,14 @@ name keyword.asar.functions.struct + + comment + Asar macro functions + match + (?i)\s*(sizeof)(?=\(\.{3}\)) + name + keyword.asar.functions.macro + comment Asar string functions @@ -558,6 +579,14 @@ name keyword.asar.functions.string + + comment + Asar address functions + match + (?i)\s*_?(pc|realbase)(?=\() + name + keyword.asar.functions.address + comment Asar convert functions @@ -603,7 +632,7 @@ comment Asar architecture directives match - (?i)\s*\b(arch)\b[\s]+\b(65816|spc700\-inline|spc700|superfx) + (?i)\s*\b(arch)\b[\s]+\b(65816|spc700|superfx)$ name keyword.asar.arch @@ -626,7 +655,7 @@ comment Asar warning directives match - (?i)\s*\b(warnings\s+(push|pull|((enable|disable)\b\s+[W|w][0-9]+)))\b\s* + \s*\b(warnings\s+(push|pull|((enable|disable)\b\s+W\w+)))\b\s* name keyword.asar.warnings @@ -638,7 +667,7 @@ comment Asar compatibility directives match - (?i)\s*\b(warn\s+xkas\s+(on|off)|math\s+pri\s+(on|off)|math\s+round\s+(on|off)|namespace\s+nested\s+(on|off))\b\s* + (?i)\s*\b(warn\s+xkas\s+(on|off)|math\s+pri\s+(on|off)|math\s+round\s+(on|off)|namespace\s+nested\s+(on|off)|asar\s([\d\.]+))\b\s* name keyword.asar.compatibility @@ -687,7 +716,7 @@ comment Asar freespace directives match - (?i)\s*\b(freecode|freedata|freespace\b\s+(ram|noram)?)\b\s*((\,*\s*(align|cleaned|static)\s*)+)? + (?i)\s*\b(freespacebyte|freecode|freedata|freespace\b\s+(ram|noram)?)\b\s*((\,*\s*(align|cleaned|static)\s*)+)? name keyword.asar.freespace @@ -708,7 +737,7 @@ comment Asar check directives match - (?i)\s*\b(check\s+(title|bankcross\s+(on|off)))\b\s* + (?i)\s*\b(check\s+(title|bankcross\s+(full|half|off)))\b\s* name keyword.asar.checks @@ -749,6 +778,14 @@ + + comment + Asar extra namespace directives + match + (?i)\s*\b(pushns|pullns)\b\s* + name + keyword.asar.namespace + @@ -757,7 +794,7 @@ comment Asar conditional function match - (?i)\s*\b(if|while|else|elseif)\b\s* + (?i)\s*\b(if|while|for|else|elseif)\b\s* name keyword.asar.conditionals @@ -765,9 +802,9 @@ comment Asar end conditional function match - (?i)\s*\b(endif)\b\s* + (?i)\s*\b(endif|endwhile|endfor)\b\s* name - keyword.asar.conditionals.endif + keyword.asar.conditionals.end @@ -783,6 +820,25 @@ + + comment + Asar inline SPC block + name + keyword.asar.spcblock + match + (?i)(\s*\b(spcblock)\b\s+) + + + comment + Asar inline SPC block ending + name + keyword.asar.spcblock.end + match + (?i)^\s*(endspcblock)\b\s* + + + + comment Label Reference diff --git a/samples/highlight_test.asm b/samples/highlight_test.asm index 5f073ec..c706933 100644 --- a/samples/highlight_test.asm +++ b/samples/highlight_test.asm @@ -387,7 +387,7 @@ BRK : COP : WDM : STP ;################################################ ;# CONDITIONALS -; IF/WHILE/ELSE/ELSEIF conditionals +; IF/WHILE/FOR/ELSE/ELSEIF conditionals ; Scope: keyword.asar.conditionals ; if, elseif, else and endif tests @@ -406,7 +406,16 @@ endif while !i < 10 lda.b #!i sta $00,x -endif +endwhile + +; for test + +for i = 1..5 + lda.b #!i + sta $00+!i +endfor + +for i = 0..10 : NOP : endfor ;################################################ ;# BINARY DATA @@ -439,6 +448,8 @@ fillword $DEAD filllong $0D9040 filldword $DEADBEEF fill 4 +fill align 8 offset 2 +fill align $08 offset $02 ; Pad area with bytes ; Scope: keyword.asar.binary.pad @@ -456,6 +467,7 @@ pad $01A005 incbin "file.bin" incbin "file.bin":9-12 +incbin "file.bin":$9..$F ; Incbin operator ; Scope: keyword.asar.operator.incbin @@ -526,6 +538,8 @@ endmacro %macro($0000, label, !define) ; Calling a macro with arguments will use their respective scopes macro macro(a, ...) ; Variadic macros are also supported + db sizeof(...), <...>, <...[0]>, <...[!i]> +endmacro ; Some other valid macros @@ -583,6 +597,18 @@ rep 10 rep $10 rep %10 +;################################################ +;# SPCBLOCK + +; spcblock command +; Scope: keyword.asar.spcblock + +spcblock $6000 nspc + db $00,$01,$02 + exec_start: + mov $33,#$44 +endspcblock execute exec_start + ;################################################ ;# NAMESPACES @@ -596,6 +622,9 @@ namespace prefix namespace off namespace ; Requires a prefix or the "off" directive! +pushns +pullns + ; Global labels ; Scope: keyword.asar.namespace.global @@ -716,6 +745,12 @@ objectsize(identifier) stringsequal("yes", "no") stringsequalnocase("yes", "perhaps") +; Address related functions +; Scope: keyword.asar.functions.address + +pc() +realbase() + ; Address conversion functions ; Scope: keyword.asar.functions.convert @@ -780,6 +815,7 @@ error "string" assert assert !define == $23, "string" +assert pc() <= $008123 ;################################################ ;# FREESPACE @@ -795,8 +831,9 @@ freespace ram freespace noram, ram ; Only one of these are supported at the same time freecode cleaned, static freedata align -freedata $00 ; Values are supported +freedata $00 ; Values are supported, but deprecated in favour of freespacebyte freedata cleaned, $00 +freespacebyte $00 ; autoclean/prot directives ; Scope: keyword.asar.freespace.misc @@ -831,6 +868,9 @@ base off base !ram_define skip skip 12 +skip align 16 +skip align 16 offset 5 +skip align $20 offset $17 warnpc warnpc 1 warnpc $008000 @@ -878,10 +918,10 @@ norom arch 65816 arch spc700 -arch spc700-inline +arch spc700-inline ; Invalid arch superfx -arch spc700-inli ; Incomplete, doesn't work +arch spc70 ; Incomplete, doesn't work arch ; Must specify an architecture in order to work ;################################################ @@ -901,6 +941,7 @@ namespace nested off ;@xkas ; No special highlight @asar ; Highlight doesn't work +asar 1.91 ;################################################ ;# CHECKS @@ -909,8 +950,10 @@ namespace nested off ; Scope: keyword.asar.checks check title "string" -check bankcross on +check bankcross on ; Invalid check bankcross off +check bankcross half +check bankcross full ;################################################ ;# WARNINGS @@ -922,6 +965,6 @@ warnings push warnings pull warnings ; Invalid -warnings enable W1012 -warnings disable W1012 -warnings enable 1012 ; Invalid \ No newline at end of file +warnings enable Wfreespace_leaked +warnings disable Wfreespace_leaked +warnings enable freespace_leaked ; Invalid diff --git a/user-settings/default.json b/user-settings/default.json index d8d0cf5..ae60854 100644 --- a/user-settings/default.json +++ b/user-settings/default.json @@ -392,6 +392,14 @@ "fontStyle": "italic" } }, + { + "name": "Asar macro variadic argument usage", + "scope": "keyword.asar.macro.args.usage.variadic", + "settings": { + "foreground": "#45b397", + "fontStyle": "italic" + } + }, @@ -406,6 +414,14 @@ } }, + { + "name": "Asar SPC blocks", + "scope": "keyword.asar.spcblock", + "settings": { + "foreground": "#dd726b" + } + }, +