aboutsummaryrefslogtreecommitdiffstats
path: root/atk16_asm/asm_pass0.py
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-04-12 22:28:40 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-04-12 22:28:40 +0300
commitb6ac63225524f1b34ffc4f780726ed981ba7e6a2 (patch)
tree400a8f46e3ace22f31cf7e893686cfaf53445227 /atk16_asm/asm_pass0.py
parent77bbd007004a0c0174dd9ce3df840db04fe9ec98 (diff)
Add "@include %bootstrap" directive format for including builtin bootstrap file
Diffstat (limited to 'atk16_asm/asm_pass0.py')
-rw-r--r--atk16_asm/asm_pass0.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/atk16_asm/asm_pass0.py b/atk16_asm/asm_pass0.py
index f6586cd..b30ddc0 100644
--- a/atk16_asm/asm_pass0.py
+++ b/atk16_asm/asm_pass0.py
@@ -29,7 +29,14 @@ def pass_0(lines: list[str], file_name: str) -> Result0:
match keyword:
case "@include":
asm_file_name = args[0] if args[0].endswith(".atk16") else args[0] + ".atk16"
- path = os.path.join(os.path.dirname(file_name), asm_file_name)
+ # if starts with %, use the path relative to this source file, not the current working directory
+ if asm_file_name.startswith("%"):
+ path = os.path.join(os.path.dirname(__file__), "builtin_asm", asm_file_name[1:])
+ # if absolute, use the absolute path
+ elif os.path.isabs(asm_file_name):
+ path = asm_file_name
+ else:
+ path = os.path.join(os.path.dirname(file_name), asm_file_name)
with open(path, "r") as f:
incl_lines = f.readlines()