diff options
author | B. Watson <urchlay@slackware.uk> | 2025-03-10 03:32:55 -0400 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2025-03-10 03:32:55 -0400 |
commit | 9727ec419720c93884939bd077d41a989b7ff51e (patch) | |
tree | 357848fc1d2382b51a903f1237d9be5774c331b0 | |
parent | 38d8bbec8a6bccb29392336790cc7a6433aa81b9 (diff) | |
download | bw-atari8-tools-9727ec419720c93884939bd077d41a989b7ff51e.tar.gz |
listamsb: support functions for int tokens.
-rw-r--r-- | listamsb.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -558,8 +558,7 @@ int crunch_line(void) { return codelen; } -/* only called during decrunching. - only handles one-byte tokens (only has to). */ +/* only called during decrunching. */ void expand_token(int ext, unsigned char t, unsigned char *buf) { const char *result; @@ -582,6 +581,33 @@ void expand_token(int ext, unsigned char t, unsigned char *buf) { strcpy((char *)buf, result); } +int read_token(void) { + int tok = read_prog_byte(); + if(tok == 0xff) { + tok <<= 8; + tok |= read_prog_byte(); + } + return tok; +} + +int token_is_extended(int tok) { + return tok > 0xff; +} + +int append_token(int tok, char *buf, int len) { + if(token_is_extended(tok)) { + buf[len++] = 0xff; + buf[len++] = tok; + } else { + buf[len++] = tok; + } + return len; +} + +void token2text(int tok, unsigned char *buf) { + return expand_token(token_is_extended(tok), tok & 0xff, buf); +} + /* only called during decrunching. the tokenizer in AMSB requires spaces to separate keywords and variables/numbers. "IF A THEN 100" really needs the spaces |