Skip to content

6502: Generate USTY chunk with parsed style information - #114

Open
sehugg wants to merge 1 commit into
Dialog-IF:mainfrom
sehugg:gen-usty
Open

sehugg wants to merge 1 commit into
Dialog-IF:mainfrom
sehugg:gen-usty

Conversation

@sehugg

@sehugg sehugg commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Been sitting on this awhile, so time to PR! Apologies for the huge commit.

This patch parses the LANG chunk and replaces it with a binary USTY chunk which is now mandatory for apple2, c64, aambox.

The parsing is more complex than frontend.c, it supports RGB colors and gives warnings on lots of things.
You can also override styles with -iftf-sys--* syntax.
For example: "-iftf-sys-c64-color: red"

It also adds a foreground text color feature to C64, activated by the above syntax or just "color: red".

There is also a generic warning subsystem sort of based on the Dialog compiler, which might be overkill (--help-all shows all warning options)

Aamshow will decode the currently-versioned USTY chunk for debugging purposes.

The USTY format is documented a few times in the comments, but I don't know if a small internal spec might be better (since it'll change with new features)

- parse LANG and issue warnings on improper styles
- rewrite LANG -> USTY for apple2, c64, aambox
- -iftf-sys-* platform overrides
- foreground text color (c64)
- warning options (see usage for flags)
@sehugg

sehugg commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

But first I have to figure out why the gosling test fails with blank lines but not on my Mac :^P

@dstelzer

Copy link
Copy Markdown
Contributor

This generally looks good to me! Just a few things:

  • I think it would be best to have USTY documented in a centralized place. The obvious place is the main Å-machine spec in docs/, even if it's not something compilers are expected to emit, but we could also make an "8-bit addendum" in docs/; Antora makes that fairly easy.
  • Since we're making a significant change to the spec, I think it's worth bumping the minor version here. "1.0.* 8-bit interpreters expect a LOOK chunk and 1.1.* 8-bit interpreters expect a USTY chunk" is easy to remember, and people who want to get the old CSS-processing code can look at the last 1.0.* release for it.
  • Conveniently, I'm about to bump the minor version anyway, to change the behavior of MUL_NUM. Might as well do this at the same time!
  • It looks like currently, a defined color property overrides the other bits on Commodore 64? That makes sense to me, but I want to make sure I'm documenting it correctly in the Dialog manual.
  • Does the C64 implementation distinguish between "inherit" and "initial" colors? That is, if I put an "inherit" span inside a "red" span, it should be red, but if I put an "initial" span inside a "red" span, it should be black. (Or blue if the whole thing was inside an italic div, etc.)
  • If we're allowing direct color specification on C64, it makes sense to allow background color specification too, via the SET_BODY opcode. Not essential, but would be nice.
  • What does the aambox option in aambundle output, exactly? Just a modified .aastory file to run through aambox?

@dstelzer

Copy link
Copy Markdown
Contributor

Oh, and one more thing: I think it's a bad idea to try to match hex color codes to the closest available fixed color. Better to make users explicitly acknowledge which color they want by name, which ensures they know about the limited palette available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants