Is there an escape character in ca65 to add such commands to a text string?
In general: No.
The whole ASCII(Z) mechanic is meant to write device independent code, so adding device specific sequences is rather outside of the scope. To get arbitrary inserts, you may want to use the good old .BYTE
:
msg .BYTE "Hello ",$05,"World",0
Then again, there is a way to do it, it just comes with a big caveat.
Starting with version 2.18 (*1,2) escape code processing can be enabled via a feature (*3)
.FEATURE STRING_ESCAPES
This will enable C-style escape codes for special characters. Now it's possible to write
msg .ASCIIZ "Hello \x05World"
So far a great thing, except, this is only painless on the source/module side, as character mapping according to the target will kick in when linking (*4). When linking, strings get translated into target codes, which can be vastly different depending on each machine.
Now, since we already left the path of compatibility, there is a way to add (somewhat) machine independent support by using defined character codes and have their mapping fixed using the .CHARMAP
directive. And with a bit of Macro-Fu logical names could be used as well ... but all of that is a complete different story :)
*1 - More correct, it wasn't there in 2.15, but is available in 2.18.
*2 - It also seems to be a backport by Oliver Schmidt from 2.5 into the free version.
*3 - When using the command line option, feature needs to be specified all lower case as
--feature string_escapes
*4 -Unless no target is specified (-t none
).
.text "{clr}Text in PETSCII\n"
.