nurpax / c64jasm

C64 6502 assembler in TypeScript
51 stars 14 forks source link

Support !text or similar #82

Closed micheldebree closed 3 years ago

micheldebree commented 3 years ago

To me, it is very useful to have a !text:

!text 'This is very handy for scrolltexts'

It should support different encodings (screen codes, petscii) and escaping of quotes.

nurpax commented 3 years ago

This has been asked before, I just never finished a good spec for it. I'm not happy with the stateful thing KickAssembler has (that encoding is a state).

The way I've been doing text strings in demo code has been with writing minimal extension and using that. The basic idea is that you make a .js extension that can encode to your desired format. Then call that on a string to return an array of bytes (yes, normal UTF-8 strings are supported just fine in c64jasm.). Use in assembler looks like this:

!use "./text" as text

!byte text("testing 123")

Here's a complete buildable gist: https://gist.github.com/nurpax/a55779dfaf9265b4470f74a3ea9896d8

Or play with the same online: https://nurpax.github.io/c64jasm-browser/?gist_id=a55779dfaf9265b4470f74a3ea9896d8

I realize that this is something that at least should be covered in documentation. I thought I had written this down but looks like I did not!

I'm open to adding some sort of !text support too.. but I don't want a design with an encoding state. :)

The extension approach was always "good enough" for me, so I never ended up extending the assembler core for this.

micheldebree commented 3 years ago

Thanks for the detailed response! I myself would be happy to use the plugin solution. Thanks for the ready made one, you could put that up on the site, or include it in the packaged as a ready made plugin. I think I actually prefer this minimal approach and not have too much 'sugar' in the compiler syntax.