diff options
author | XANTRONIX Development | 2023-09-13 14:40:48 -0400 |
---|---|---|
committer | XANTRONIX Development | 2023-09-13 14:40:48 -0400 |
commit | b89c79b5a8b2084574f2645d7034ba595b9d5cd0 (patch) | |
tree | 3d792b341ccf98567725e8b12d6e81801b95351e /include | |
parent | 4451e2f2ef709ad4ad0e519a0310cc1e31c0d25a (diff) | |
download | zxdump-b89c79b5a8b2084574f2645d7034ba595b9d5cd0.tar.gz zxdump-b89c79b5a8b2084574f2645d7034ba595b9d5cd0.tar.bz2 zxdump-b89c79b5a8b2084574f2645d7034ba595b9d5cd0.zip |
Refactor stuff into separate files, finally
Diffstat (limited to 'include')
-rw-r--r-- | include/zx/basic.h | 35 | ||||
-rw-r--r-- | include/zx/charset.h | 40 | ||||
-rw-r--r-- | include/zx/hexdump.h | 12 |
3 files changed, 87 insertions, 0 deletions
diff --git a/include/zx/basic.h b/include/zx/basic.h new file mode 100644 index 0000000..1989954 --- /dev/null +++ b/include/zx/basic.h @@ -0,0 +1,35 @@ +#ifndef _ZX_BASIC_H +#define _ZX_BASIC_H + +#include <stdio.h> +#include <stdlib.h> +#include <inttypes.h> + +#define ZX81_CHAR_TOKEN_LOW_START 0x40 +#define ZX81_CHAR_TOKEN_LOW_END 0x42 + +#define ZX81_CHAR_TOKEN_HIGH_START 0xc0 +#define ZX81_CHAR_TOKEN_HIGH_END 0xff + +#define ZX_BASIC_STATE_SIZE 116 +#define ZX_BASIC_LINE_LAST 0x7676 + +extern char *zx81_basic_tokens_low[3]; + +extern char *zx81_basic_tokens[64]; + +typedef struct _zx_basic_line { + uint16_t num, len; +} zx_basic_line; + +enum zx_basic_token_type { + ZX_BASIC_TOKEN_UNKNOWN, + ZX_BASIC_TOKEN_ALNUM, + ZX_BASIC_TOKEN_QUOTE, + ZX_BASIC_TOKEN_SYMBOL, + ZX_BASIC_TOKEN_WORD, +}; + +ssize_t zx81_basic_dump(int fd, FILE *stream); + +#endif /* _ZX_BASIC_H */ diff --git a/include/zx/charset.h b/include/zx/charset.h new file mode 100644 index 0000000..34f6eb8 --- /dev/null +++ b/include/zx/charset.h @@ -0,0 +1,40 @@ +#ifndef _ZX_CHARSET_H +#define _ZX_CHARSET_H + +#include <stdio.h> +#include <inttypes.h> + +#define ZX81_CHARSET_LEN 64 + +#define ZX81_CHAR_LOW(c) \ + (c <= ZX81_CHARSET_LEN) + +#define ZX81_CHAR_INVERSE_START 0x80 +#define ZX81_CHAR_INVERSE_END 0xbf + +#define ZX81_CHAR_INVERSE(c) \ + (c >= ZX81_CHAR_INVERSE_START && c <= ZX81_CHAR_INVERSE_END) + +#define ZX81_CHAR_TOKEN_LOW(c) \ + (c >= ZX81_CHAR_TOKEN_LOW_START && c <= ZX81_CHAR_TOKEN_LOW_END) + +#define ZX81_CHAR_NEWLINE(c) \ + (c == 0x76) + +#define ZX81_CHAR_TOKEN_HIGH(c) \ + (c >= 0xc0) + +#define ZX81_CHAR_TOKEN(c) \ + (ZX81_CHAR_TOKEN_LOW(c) || ZX81_CHAR_TOKEN_HIGH(c)) + +#define ZX81_CHAR_TOKEN_INTEGRAL(c) \ + (c == 0x0e) + +#define ZX81_CHAR_TOKEN_FLOAT(c) \ + (c == 0x7e) + +extern uint32_t zx81_charset[ZX81_CHARSET_LEN]; + +int zx81_fputc(uint8_t c, int inverse, FILE *stream); + +#endif /* _ZX_CHARSET_H */ diff --git a/include/zx/hexdump.h b/include/zx/hexdump.h new file mode 100644 index 0000000..5b38796 --- /dev/null +++ b/include/zx/hexdump.h @@ -0,0 +1,12 @@ +#ifndef _ZX81_HEXDUMP_H +#define _ZX81_HEXDUMP_H + +#include <stdio.h> +#include <sys/types.h> + +#define ZX81_HEXDUMP_STRIDE_LINE 16 +#define ZX81_HEXDUMP_STRIDE_GROUP 2 + +ssize_t zx81_hexdump(int source_fd, FILE *stream); + +#endif /* _ZX81_HEXDUMP_H */ |