diff options
Diffstat (limited to 'atk16_ast_walking_compiler/sample_py')
| -rw-r--r-- | atk16_ast_walking_compiler/sample_py/aoc23_1a.py | 48 | ||||
| -rw-r--r-- | atk16_ast_walking_compiler/sample_py/atk16.py | 39 | ||||
| -rw-r--r-- | atk16_ast_walking_compiler/sample_py/sample_py_src.py | 36 |
3 files changed, 0 insertions, 123 deletions
diff --git a/atk16_ast_walking_compiler/sample_py/aoc23_1a.py b/atk16_ast_walking_compiler/sample_py/aoc23_1a.py deleted file mode 100644 index 12e3953..0000000 --- a/atk16_ast_walking_compiler/sample_py/aoc23_1a.py +++ /dev/null @@ -1,48 +0,0 @@ -import atk16 - -GRAPHICS_NO_MODE: atk16.ConstWord16 = 0 -GRAPHICS_TEXT_MODE: atk16.ConstWord16 = 1 -GRAPHICS_SPRITE_MODE: atk16.ConstWord16 = 2 - -GRAPHICS_MODE_PP: atk16.ConstWord16 = 0x17 -TEXT_MEM_PP: atk16.ConstWord16 = 0x19 - -graphics_mode_p = atk16.load(GRAPHICS_MODE_PP) -text_mem_p = atk16.load(TEXT_MEM_PP) - -atk16.store(graphics_mode_p, GRAPHICS_TEXT_MODE) - -INPUT_P: atk16.ConstWord16 = 0x9000 -INPUT_ELEM_SIZE: atk16.ConstWord16 = 256 - -# 1a example - -atk16.store(INPUT_P + 0, "1") -atk16.store(INPUT_P + 1, "a") -atk16.store(INPUT_P + 2, "b") -atk16.store(INPUT_P + 3, "c") -atk16.store(INPUT_P + 4, "2") -atk16.store(INPUT_P + 5, "\0") -# atk16.store_const_vec(INPUT_P + 0, "1abc2\0") -# atk16.store_const_vec(INPUT_P + 256, "pqr3stu8vwx\0") -# atk16.store_const_vec(INPUT_P + 512, "a1b2c3d4e5f\0") -# atk16.store_const_vec(INPUT_P + 768, "treb7uchet\0") - -row_p = INPUT_P -i = 0 - -first = atk16.load(row_p) -last = 0 - -while True: - char_p = INPUT_P + i - char = atk16.load(char_p) - - if char == "\0": - break - - last = char - i += 1 - -atk16.store(text_mem_p + 0, first) -atk16.store(text_mem_p + 1, last)
\ No newline at end of file diff --git a/atk16_ast_walking_compiler/sample_py/atk16.py b/atk16_ast_walking_compiler/sample_py/atk16.py deleted file mode 100644 index 9aa3c55..0000000 --- a/atk16_ast_walking_compiler/sample_py/atk16.py +++ /dev/null @@ -1,39 +0,0 @@ -from typing import Literal, Any, TypeVar, NewType, Never, Callable, Generic, overload, cast -Char = Literal['\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\t', '\n', '\x0b', '\x0c', '\r', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '\x7f', '\x80', '\x81', '\x82', '\x83', '\x84', '\x85', '\x86', '\x87', '\x88', '\x89', '\x8a', '\x8b', '\x8c', '\x8d', '\x8e', '\x8f', '\x90', '\x91', '\x92', '\x93', '\x94', '\x95', '\x96', '\x97', '\x98', '\x99', '\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f', '\xa0', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '\xad', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ'] -Void = Literal[0] -Word16 = int -ConstWord16 = int - -def store(p: Word16, value: Word16 | Char) -> Void: - raise NotImplementedError - -@overload -def store_const_vec(p: Word16, value: list[Word16]) -> Void: ... -@overload -def store_const_vec(p: Word16, value: list[Char]) -> Void: ... -@overload -def store_const_vec(p: Word16, value: str) -> Void: ... - -def store_const_vec(p, value) -> Void: - raise NotImplementedError - -def load(p: Word16) -> Word16: - raise NotImplementedError - -T = TypeVar("T") -def call_inline(expr: T) -> T: - """Inline the function call `expr` at the callsite. - This can lead to a larger output size but avoids having to do a subroutine call.""" - raise NotImplementedError - -def asm(asm: str): - """Inject ATK16 assembly `asm` into the compiled output.""" - raise NotImplementedError - -def ord(char: Char) -> int: - """Convert char to int""" - raise NotImplementedError - -def const(word: Word16) -> ConstWord16: - """When used in an assignment such as `A = const(0xFF)`, stores the value as a globally accessible constant.""" - raise NotImplementedError
\ No newline at end of file diff --git a/atk16_ast_walking_compiler/sample_py/sample_py_src.py b/atk16_ast_walking_compiler/sample_py/sample_py_src.py deleted file mode 100644 index 619d22e..0000000 --- a/atk16_ast_walking_compiler/sample_py/sample_py_src.py +++ /dev/null @@ -1,36 +0,0 @@ -# TODO: actual imports, not just `import atk16` -from atk16 import * - -GRAPHICS_NO_MODE: ConstWord16 = 0 -GRAPHICS_TEXT_MODE: ConstWord16 = 1 -GRAPHICS_SPRITE_MODE: ConstWord16 = 2 - -GRAPHICS_MODE_PP: ConstWord16 = 0x17 -TEXT_MEM_PP: ConstWord16 = 0x19 - -TEXT_MEM_PP: ConstWord16 = 0x19 - -# asm( -# "@label keyboard_isr" -# " spu RA" - -# " spo RA" -# ) - -# set_isr(0, "keyboard_isr") - -graphics_mode_p = load(GRAPHICS_MODE_PP) -text_mem_p = load(TEXT_MEM_PP) - -store(graphics_mode_p, GRAPHICS_TEXT_MODE) - -def nth_letter(n: int) -> int: - return ord('A') + n - -i = 0 -while i < 26: - store(text_mem_p + i, nth_letter(i)) - i += 1 - -while True: - pass |
