aboutsummaryrefslogtreecommitdiffstats
path: root/tools/consts.py
diff options
context:
space:
mode:
authorRangi42 <remy.oukaour+rangi42@gmail.com>2024-10-07 16:48:18 -0400
committerRangi42 <remy.oukaour+rangi42@gmail.com>2024-10-07 16:48:18 -0400
commitb52b44f8834fd64d7f279804585e0a554cf61d5b (patch)
tree7081a0f36d4bcb82786cb97361da03f48bb1e0e6 /tools/consts.py
parentComment wave5 garbage data (#474) (diff)
downloadpokeyellow-b52b44f8834fd64d7f279804585e0a554cf61d5b.tar.gz
pokeyellow-b52b44f8834fd64d7f279804585e0a554cf61d5b.tar.xz
pokeyellow-b52b44f8834fd64d7f279804585e0a554cf61d5b.zip
Remove independent tools and link to pokemon-asm-tools
Diffstat (limited to 'tools/consts.py')
-rwxr-xr-xtools/consts.py56
1 files changed, 0 insertions, 56 deletions
diff --git a/tools/consts.py b/tools/consts.py
deleted file mode 100755
index 37c85951..00000000
--- a/tools/consts.py
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-
-"""
-Usage: python consts.py constants/some_constants.asm
-
-View numeric values of `const`ants.
-"""
-
-import sys
-import re
-
-const_value = 0
-const_inc = 1
-
-def asm_int(s):
- base = {'$': 16, '&': 8, '%': 2}.get(s[0], 10)
- return int(s if base == 10 else s[1:], base)
-
-def print_const(s, v):
- print(f'{s} == {v} == ${v:x}')
-
-def parse_for_constants(line):
- global const_value, const_inc
- if not (m := re.match(r'^\s+([A-Za-z_][A-Za-z0-9_@#]*)(?:\s+([^;\\n]+))?', line)):
- return
- macro, rest = m.groups()
- args = [arg.strip() for arg in rest.split(',')] if rest else []
- if args and not args[-1]:
- args = args[:-1]
- if macro == 'const_def':
- const_value = asm_int(args[0]) if len(args) >= 1 else 0
- const_inc = asm_int(args[1]) if len(args) >= 2 else 1
- elif macro == 'const':
- print_const(args[0], const_value)
- const_value += const_inc
- elif macro == 'shift_const':
- print_const(args[0], 1 << const_value)
- print_const(args[0] + '_F', const_value)
- const_value += const_inc
- elif macro == 'const_skip':
- const_value += const_inc * (asm_int(args[0]) if len(args) >= 1 else 1)
- elif macro == 'const_next':
- const_value = asm_int(args[0])
-
-def main():
- if len(sys.argv) < 2:
- print(f'Usage: {sys.argv[0]} constants/some_constants.asm', file=sys.stderr)
- sys.exit(1)
- for filename in sys.argv[1:]:
- with open(filename, 'r', encoding='utf-8') as file:
- for line in file:
- parse_for_constants(line)
-
-if __name__ == '__main__':
- main()