diff options
-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 |