줄바꿈을 LF로 통일
서버에서 바로 빌드하고 고칠 수 있게 저장소 줄바꿈을 LF로 맞췄습니다. CRLF로 들어가 있던 sh 빌드 스크립트도 이제 리눅스에서 그대로 돌아갑니다. 내용은 바뀌지 않았습니다.
This commit is contained in:
1 parent
40615838ac
commit
2d48091205
623 files changed
+501372
-501365
No files matched your search
+23
-23
@@ -1,23 +1,23 @@
|
||||
# The ten V3Emu icons (20 x 20 PNG, mameise) -> src/app/icons_v3.h. A missing icon is taken from T7Emu (t7/src/app/icons.h).
|
||||
# python3 gen/icons.py <folder with icon_0.png .. icon_9.png (icon_06.png also works)>
|
||||
import sys, os, re
|
||||
from PIL import Image
|
||||
d = sys.argv[1]
|
||||
t7 = re.findall(r'\{([^{}]+)\}', open(os.path.join(os.path.dirname(__file__), '../../t7/src/app/icons.h')).read())
|
||||
rows = []
|
||||
for i in range(10):
|
||||
f = next((os.path.join(d, n) for n in ('icon_%d.png' % i, 'icon_%02d.png' % i) if os.path.exists(os.path.join(d, n))), None)
|
||||
if not f:
|
||||
rows.append(t7[i].strip()); print('icon %d: from T7Emu' % i); continue
|
||||
im = Image.open(f).convert('RGBA').resize((20, 20))
|
||||
v = []
|
||||
for y in range(20):
|
||||
b = 0
|
||||
for x in range(20):
|
||||
p = im.getpixel((x, y))
|
||||
if p[3] > 128 and sum(p[:3]) < 384: b |= 0x80000 >> x
|
||||
v.append('0x%08X' % b)
|
||||
rows.append(','.join(v)); print('icon %d: %s' % (i, os.path.basename(f)))
|
||||
with open(os.path.join(os.path.dirname(__file__), '../src/app/icons_v3.h'), 'w') as o:
|
||||
o.write('/* 20x20 icons of V3Emu (bit 0x80000 = left), drawn by mameise; made by gen/icons.py */\n')
|
||||
o.write('static const unsigned int g_icons[10][20]={\n' + ''.join(' {%s},\n' % r for r in rows) + '};\n')
|
||||
# The ten V3Emu icons (20 x 20 PNG, mameise) -> src/app/icons_v3.h. A missing icon is taken from T7Emu (t7/src/app/icons.h).
|
||||
# python3 gen/icons.py <folder with icon_0.png .. icon_9.png (icon_06.png also works)>
|
||||
import sys, os, re
|
||||
from PIL import Image
|
||||
d = sys.argv[1]
|
||||
t7 = re.findall(r'\{([^{}]+)\}', open(os.path.join(os.path.dirname(__file__), '../../t7/src/app/icons.h')).read())
|
||||
rows = []
|
||||
for i in range(10):
|
||||
f = next((os.path.join(d, n) for n in ('icon_%d.png' % i, 'icon_%02d.png' % i) if os.path.exists(os.path.join(d, n))), None)
|
||||
if not f:
|
||||
rows.append(t7[i].strip()); print('icon %d: from T7Emu' % i); continue
|
||||
im = Image.open(f).convert('RGBA').resize((20, 20))
|
||||
v = []
|
||||
for y in range(20):
|
||||
b = 0
|
||||
for x in range(20):
|
||||
p = im.getpixel((x, y))
|
||||
if p[3] > 128 and sum(p[:3]) < 384: b |= 0x80000 >> x
|
||||
v.append('0x%08X' % b)
|
||||
rows.append(','.join(v)); print('icon %d: %s' % (i, os.path.basename(f)))
|
||||
with open(os.path.join(os.path.dirname(__file__), '../src/app/icons_v3.h'), 'w') as o:
|
||||
o.write('/* 20x20 icons of V3Emu (bit 0x80000 = left), drawn by mameise; made by gen/icons.py */\n')
|
||||
o.write('static const unsigned int g_icons[10][20]={\n' + ''.join(' {%s},\n' % r for r in rows) + '};\n')
|
||||
+65
-65
@@ -1,65 +1,65 @@
|
||||
# py2c.py - translates the instruction methods of BrickEmuPy's SPLB32 core (cores/SPLB32.py, CC0) into C.
|
||||
# python3 py2c.py <BrickEmuPy dir> > ../src/core/v3ops.inc
|
||||
# Each method becomes "static int op_XX(void)" on the state macros of v3cpu.c (A, X, Y, SP, PC, NF ... RD, WR).
|
||||
import re, sys, inspect
|
||||
sys.path.insert(0, sys.argv[1])
|
||||
from cores.SPLB32 import SPLB32
|
||||
src = open(sys.argv[1] + '/cores/SPLB32.py').read()
|
||||
t = src[src.index('self._execute = ('):src.index('def _get_rom_addr')]
|
||||
ops = []
|
||||
for a, n, b in re.findall(r'\*\(\[SPLB32\.(_\w+)\] \* (\d+)\)|SPLB32\.(_\w+)', t):
|
||||
ops += [a] * int(n) if a else [b]
|
||||
assert len(ops) == 256
|
||||
def expr(e):
|
||||
e = e.strip()
|
||||
e = re.sub(r'(?<![_\w])SP\b', '0x100', e)
|
||||
e = re.sub(r'self\._read_mem\(', 'RD(', e)
|
||||
e = re.sub(r'self\._write_mem\(', 'WR(', e)
|
||||
e = re.sub(r'self\._get_ps\(\)', 'get_ps()', e)
|
||||
e = re.sub(r'self\._set_ps\(', 'set_ps(', e)
|
||||
e = re.sub(r'self\._adc\(', 'do_adc(', e)
|
||||
e = re.sub(r'self\._sbc\(', 'do_sbc(', e)
|
||||
e = re.sub(r'self\._IRQ\(\)', 'irq_enter()', e)
|
||||
e = re.sub(r'self\._([A-Z][A-Z_0-9]*)', r'\1', e)
|
||||
e = re.sub(r'(\w+) & (0x[0-9A-Fa-f]+) > 0', r'(((\1) & \2) > 0)', e)
|
||||
e = re.sub(r'\bnot\s*\(', '!(', e)
|
||||
e = re.sub(r'\bnot\s+([\w.]+)', r'!(\1)', e)
|
||||
e = e.replace(' and ', ' && ').replace(' or ', ' || ')
|
||||
return e
|
||||
out = []
|
||||
done = {}
|
||||
for i, name in enumerate(ops):
|
||||
if name == '_dummy' or name in done: continue
|
||||
lines = inspect.getsource(getattr(SPLB32, name)).split('\n')[1:]
|
||||
body = []; stack = [8]
|
||||
for l in lines:
|
||||
if not l.strip(): continue
|
||||
ind = len(l) - len(l.lstrip()); s = l.strip()
|
||||
while ind < stack[-1]: stack.pop(); body.append(' ' * (len(stack)) + '}')
|
||||
pre = ' ' * len(stack)
|
||||
m = re.match(r'(if|elif|while) \((.*)\):$', s) or re.match(r'(if|elif|while) (.*):$', s)
|
||||
if m:
|
||||
kw = {'if': 'if', 'elif': 'else if', 'while': 'while'}[m.group(1)]
|
||||
body.append(pre + '%s (%s) {' % (kw, expr(m.group(2)))); stack.append(ind + 4); continue
|
||||
if s == 'else:':
|
||||
body.append(pre + 'else {'); stack.append(ind + 4); continue
|
||||
m = re.match(r'return (.*)$', s)
|
||||
if m: body.append(pre + 'return (int)(%s);' % expr(m.group(1))); continue
|
||||
m = re.match(r'([\w.]+) *(\|=|\^=|&=|\+=|-=|=) *(.*)$', s)
|
||||
if m:
|
||||
lhs = expr(m.group(1)); rhs = expr(m.group(3))
|
||||
if lhs in ('zp', 'addr', 'base', 'new_value', 'prev_value', 'test_value', 'm', 'rel', 'prev_PC', 'pc', 'opcode', 'value') and m.group(2) == '=' and lhs not in done.get('_vars_' + name, set()):
|
||||
done.setdefault('_vars_' + name, set()).add(lhs)
|
||||
body.append(pre + 'int %s = %s;' % (lhs, rhs))
|
||||
else:
|
||||
body.append(pre + '%s %s %s;' % (lhs, m.group(2), rhs))
|
||||
continue
|
||||
body.append(pre + expr(s) + ';')
|
||||
while len(stack) > 1: stack.pop(); body.append(' ' * len(stack) + '}')
|
||||
done[name] = 1
|
||||
out.append('static int op%s(void)\n{\n%s\n}' % (name, '\n'.join(body)))
|
||||
print('/* generated by v3/gen/py2c.py from BrickEmuPy cores/SPLB32.py (azya52, CC0) */')
|
||||
print('\n'.join(out))
|
||||
print('static int (*const v3_op[256])(void) = {')
|
||||
print(',\n'.join(' ' + ('op_dummy' if n == '_dummy' else 'op' + n) for n in ops))
|
||||
print('};')
|
||||
# py2c.py - translates the instruction methods of BrickEmuPy's SPLB32 core (cores/SPLB32.py, CC0) into C.
|
||||
# python3 py2c.py <BrickEmuPy dir> > ../src/core/v3ops.inc
|
||||
# Each method becomes "static int op_XX(void)" on the state macros of v3cpu.c (A, X, Y, SP, PC, NF ... RD, WR).
|
||||
import re, sys, inspect
|
||||
sys.path.insert(0, sys.argv[1])
|
||||
from cores.SPLB32 import SPLB32
|
||||
src = open(sys.argv[1] + '/cores/SPLB32.py').read()
|
||||
t = src[src.index('self._execute = ('):src.index('def _get_rom_addr')]
|
||||
ops = []
|
||||
for a, n, b in re.findall(r'\*\(\[SPLB32\.(_\w+)\] \* (\d+)\)|SPLB32\.(_\w+)', t):
|
||||
ops += [a] * int(n) if a else [b]
|
||||
assert len(ops) == 256
|
||||
def expr(e):
|
||||
e = e.strip()
|
||||
e = re.sub(r'(?<![_\w])SP\b', '0x100', e)
|
||||
e = re.sub(r'self\._read_mem\(', 'RD(', e)
|
||||
e = re.sub(r'self\._write_mem\(', 'WR(', e)
|
||||
e = re.sub(r'self\._get_ps\(\)', 'get_ps()', e)
|
||||
e = re.sub(r'self\._set_ps\(', 'set_ps(', e)
|
||||
e = re.sub(r'self\._adc\(', 'do_adc(', e)
|
||||
e = re.sub(r'self\._sbc\(', 'do_sbc(', e)
|
||||
e = re.sub(r'self\._IRQ\(\)', 'irq_enter()', e)
|
||||
e = re.sub(r'self\._([A-Z][A-Z_0-9]*)', r'\1', e)
|
||||
e = re.sub(r'(\w+) & (0x[0-9A-Fa-f]+) > 0', r'(((\1) & \2) > 0)', e)
|
||||
e = re.sub(r'\bnot\s*\(', '!(', e)
|
||||
e = re.sub(r'\bnot\s+([\w.]+)', r'!(\1)', e)
|
||||
e = e.replace(' and ', ' && ').replace(' or ', ' || ')
|
||||
return e
|
||||
out = []
|
||||
done = {}
|
||||
for i, name in enumerate(ops):
|
||||
if name == '_dummy' or name in done: continue
|
||||
lines = inspect.getsource(getattr(SPLB32, name)).split('\n')[1:]
|
||||
body = []; stack = [8]
|
||||
for l in lines:
|
||||
if not l.strip(): continue
|
||||
ind = len(l) - len(l.lstrip()); s = l.strip()
|
||||
while ind < stack[-1]: stack.pop(); body.append(' ' * (len(stack)) + '}')
|
||||
pre = ' ' * len(stack)
|
||||
m = re.match(r'(if|elif|while) \((.*)\):$', s) or re.match(r'(if|elif|while) (.*):$', s)
|
||||
if m:
|
||||
kw = {'if': 'if', 'elif': 'else if', 'while': 'while'}[m.group(1)]
|
||||
body.append(pre + '%s (%s) {' % (kw, expr(m.group(2)))); stack.append(ind + 4); continue
|
||||
if s == 'else:':
|
||||
body.append(pre + 'else {'); stack.append(ind + 4); continue
|
||||
m = re.match(r'return (.*)$', s)
|
||||
if m: body.append(pre + 'return (int)(%s);' % expr(m.group(1))); continue
|
||||
m = re.match(r'([\w.]+) *(\|=|\^=|&=|\+=|-=|=) *(.*)$', s)
|
||||
if m:
|
||||
lhs = expr(m.group(1)); rhs = expr(m.group(3))
|
||||
if lhs in ('zp', 'addr', 'base', 'new_value', 'prev_value', 'test_value', 'm', 'rel', 'prev_PC', 'pc', 'opcode', 'value') and m.group(2) == '=' and lhs not in done.get('_vars_' + name, set()):
|
||||
done.setdefault('_vars_' + name, set()).add(lhs)
|
||||
body.append(pre + 'int %s = %s;' % (lhs, rhs))
|
||||
else:
|
||||
body.append(pre + '%s %s %s;' % (lhs, m.group(2), rhs))
|
||||
continue
|
||||
body.append(pre + expr(s) + ';')
|
||||
while len(stack) > 1: stack.pop(); body.append(' ' * len(stack) + '}')
|
||||
done[name] = 1
|
||||
out.append('static int op%s(void)\n{\n%s\n}' % (name, '\n'.join(body)))
|
||||
print('/* generated by v3/gen/py2c.py from BrickEmuPy cores/SPLB32.py (azya52, CC0) */')
|
||||
print('\n'.join(out))
|
||||
print('static int (*const v3_op[256])(void) = {')
|
||||
print(',\n'.join(' ' + ('op_dummy' if n == '_dummy' else 'op' + n) for n in ops))
|
||||
print('};')
|
||||
Reference in new issue
Block a user