From 8a60c291c5282e6c92b2e71eb7feebce5a0ad58d Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Fri, 16 Nov 2018 23:00:17 +0800 Subject: remove r2 and make it another project, add .gitignore --- r2/print_card_strings.py | 75 ------------------------------------------------ 1 file changed, 75 deletions(-) delete mode 100644 r2/print_card_strings.py (limited to 'r2/print_card_strings.py') diff --git a/r2/print_card_strings.py b/r2/print_card_strings.py deleted file mode 100644 index 3df59cd..0000000 --- a/r2/print_card_strings.py +++ /dev/null @@ -1,75 +0,0 @@ -# Copyright (C) 2018 Iru Cai -# SPDX-License-Identifier: GPL-3.0-or-later - -import r2pipe -import opencc - - -def isprint(c): - if c >= 0x20 and c <= 0x7e and c != ord('"') and c != ord('\\'): - return True - else: - return False - - -def asc2str(c): - if isprint(c): - return chr(c) - else: - return f'\\x{i:02c}' - - -def ishexchr(c): - if c >= ord('0') and c <= ord('9'): - return True - if c >= ord('a') and c <= ord('z'): - return True - if c >= ord('A') and c <= ord('Z'): - return True - return False - - -cc = opencc.OpenCC('t2s') -r = r2pipe.open() -data = r.cmdj("xj 360*12 @ 0x48123a") - -print('const char *card_strings[12][3][30] = {') - -for rich4_player in range(0, 12): - print('{') - for str_type in range(0, 3): - print('{') - for card_idx in range(0, 30): - idx = rich4_player * 90 + str_type * 30 + card_idx - offset = idx * 4 - addr = data[offset] + (data[offset+1] << 8) + \ - (data[offset+2] << 16) + (data[offset+3] << 24) - if addr == 0: - print('NULL,') - else: - prev_ascii = False - hexs = r.cmdj("xj 100 @ {}".format(addr)) - hexstr = "" - cbytes = bytearray([]) - for i in hexs: - if i == 0: - break - if isprint(i) and prev_ascii: - hexstr += asc2str(i) - elif isprint(i) and not ishexchr(i): - hexstr += asc2str(i) - prev_ascii = True - else: - hexstr += f'\\x{i:02x}' - prev_ascii = False - cbytes.append(i) - try: - big5str = cc.convert(cbytes.decode( - encoding='big5')).replace('\n', '') - except UnicodeDecodeError: - big5str = "" - print(f'"{hexstr}", /* {big5str} */') - print('},') - print('},') - -print('};') -- cgit v1.2.3