site 1.10.0: flash bar in the builder, Browse info and Divide hold, phase meter V2
- builder: a bar under the mods shows the player's flash: Pioneer's firmware, the ticked mods and what stays free; every mod shows its packed share (measured by tools/make_builder_data.py, cached in tools/flash_sizes.json) - new mods: browseinfo 0.1.0, divhold 0.1.0 (cards, docs, builder) - phasemeter V2, quicksearch 0.6.0, usbautoload 0.2.0, cuenames 0.1.2, beatjump 1.0.2; boot screen 1.10.0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9eedbe5e5f
commit
04f123fbfe
19 files changed
+319
-50
No files matched your search
@@ -140,7 +140,95 @@ def apply_ops(app, stock, ops, hk, size):
|
||||
|
||||
|
||||
MODS_ALL = ('extended_bpm', 'phasemeter', 'advanced_waveforms', 'beatjump', 'cuecolours', 'hotcuekeys',
|
||||
'ledsaver', 'keynotation', 'usbautoload', 'quicksearch', 'cuenames', 'played', 'endwarn', 'wide_waveform', 'credit')
|
||||
'ledsaver', 'keynotation', 'usbautoload', 'quicksearch', 'cuenames', 'played', 'endwarn', 'wide_waveform',
|
||||
'browseinfo', 'divhold', 'credit')
|
||||
FLASH_NEEDS = {'beatjump': ('cuecolours', 'hotcuekeys'), 'hotcuekeys': ('cuecolours',), 'cuenames': ('cuecolours',)}
|
||||
FLASH_CACHE = os.path.join(HERE, 'flash_sizes.json')
|
||||
|
||||
|
||||
def _packed_len(job):
|
||||
"""(repo, names) -> the LZSS stream's length of the application with those mods (one process each)."""
|
||||
repo, names = job
|
||||
sys.path[:0] = [os.path.join(repo, 'mods'), os.path.join(repo, 'mods', 'cdj900nxs'),
|
||||
os.path.join(repo, 'scripts', 'firmware')]
|
||||
import patch_cdj900nxs as p
|
||||
import lzss_encode
|
||||
with open(os.path.join(repo, 'extract', 'cdj900nxs', 'main_unpacked.bin'), 'rb') as f:
|
||||
stock = f.read()[:p.APP_SIZE]
|
||||
app = p.patch(stock, list(names)) if names else stock
|
||||
return names, sha(app), len(lzss_encode.pack(app))
|
||||
|
||||
|
||||
def flash_sizes(repo, p):
|
||||
"""What each mod takes of the player's flash: the application is stored LZSS-packed in
|
||||
0x40000-0x7E0000 (upd.APP_END - APP_START bytes). A mod's share is the packed size with it
|
||||
(and what it needs) minus without it; the sum over a choice is an estimate (the packer finds
|
||||
a little more or less to share), the exact number the build tells. Packing takes a minute a
|
||||
run, so results are cached by the application's SHA-256 (tools/flash_sizes.json)."""
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(WEB), 'CDJ900NXSPatcher'))
|
||||
import upd
|
||||
from multiprocessing import Pool
|
||||
try:
|
||||
with open(FLASH_CACHE, encoding='utf-8') as f:
|
||||
cache = json.load(f)
|
||||
except (OSError, ValueError):
|
||||
cache = {}
|
||||
with open(os.path.join(repo, 'extract', 'cdj900nxs', 'main_unpacked.bin'), 'rb') as f:
|
||||
stock = f.read()[:p.APP_SIZE]
|
||||
def removed(m): # m and every mod that needs it, directly or not
|
||||
out, grow = {m}, True
|
||||
while grow:
|
||||
grow = False
|
||||
for n, d in FLASH_NEEDS.items():
|
||||
if n not in out and out & set(d):
|
||||
out.add(n)
|
||||
grow = True
|
||||
return out
|
||||
jobs = {(): None, MODS_ALL: None}
|
||||
for m in MODS_ALL:
|
||||
jobs[tuple(n for n in MODS_ALL if n not in removed(m))] = None
|
||||
d = tuple(n for n in MODS_ALL if n in FLASH_NEEDS.get(m, ()))
|
||||
jobs[d] = None
|
||||
jobs[tuple(n for n in MODS_ALL if n in d + (m,))] = None
|
||||
todo, known = [], {}
|
||||
for names in jobs:
|
||||
app_sha = sha(p.patch(stock, list(names)) if names else stock)
|
||||
if app_sha in cache:
|
||||
known[names] = cache[app_sha]
|
||||
else:
|
||||
todo.append((repo, names))
|
||||
if todo:
|
||||
print('packing %d applications for the flash sizes (about a minute each, in parallel)' % len(todo))
|
||||
with Pool(min(len(todo), max(1, (os.cpu_count() or 2) - 1))) as pool:
|
||||
for names, app_sha, n in pool.imap_unordered(_packed_len, todo):
|
||||
cache[app_sha] = n
|
||||
known[names] = n
|
||||
print(' %-60s %d' % (','.join(names) or 'stock', n))
|
||||
with open(FLASH_CACHE, 'w', encoding='utf-8', newline=chr(10)) as f:
|
||||
json.dump(cache, f, indent=1, sort_keys=True)
|
||||
region = lambda n: len(upd.pack_region(bytes(n)))
|
||||
# The packer shares a lot between the mods (alone each costs 7-30 KB, all together 50 KB), so a
|
||||
# sum of single sizes is far off. What every mod brings anyway (the frame: the smallest mod alone,
|
||||
# the boot text, costs it) is counted once; the rest is split by each mod's marginal size in the
|
||||
# full build (all mods packed minus all but it, and what needs it). Exact with none and with all.
|
||||
alone = {}
|
||||
for m in MODS_ALL:
|
||||
d = tuple(n for n in MODS_ALL if n in FLASH_NEEDS.get(m, ()))
|
||||
alone[m] = known[tuple(n for n in MODS_ALL if n in d + (m,))] - known[d]
|
||||
frame = min(v for m, v in alone.items() if m not in FLASH_NEEDS) # (one that needs others adds to them)
|
||||
marg = {}
|
||||
for m in sorted(MODS_ALL, key=lambda m: len(removed(m))):
|
||||
rest = tuple(n for n in MODS_ALL if n not in removed(m))
|
||||
marg[m] = max(0, known[MODS_ALL] - known[rest] - sum(marg[n] for n in removed(m) - {m}))
|
||||
total = region(known[MODS_ALL]) - region(known[()]) - frame
|
||||
k = total / float(sum(marg.values()) or 1)
|
||||
mods = {m: max(1, int(round(marg[m] * k))) for m in MODS_ALL}
|
||||
out = {'size': upd.APP_END - upd.APP_START, 'stock': region(known[()]),
|
||||
'all': region(known[MODS_ALL]), 'common': frame, 'mods': mods}
|
||||
print('flash: %d of %d with no mods, %d with all; shares %d + frame %d'
|
||||
% (out['stock'], out['size'], out['all'], sum(mods.values()), out['common']))
|
||||
print(' ' + ', '.join('%s %d' % kv for kv in sorted(mods.items(), key=lambda kv: -kv[1])))
|
||||
return out
|
||||
|
||||
|
||||
def python_bundle(repo):
|
||||
@@ -264,6 +352,7 @@ def main():
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(WEB), 'CDJ900NXSPatcher'))
|
||||
import upd
|
||||
data['stockUpdSha256'] = upd.STOCK_UPD_SHA256
|
||||
data['flash'] = flash_sizes(args.repo, p)
|
||||
for key, b64 in chunks.items(): # no firmware in what we ship
|
||||
blob = base64.b64decode(b64)
|
||||
for i in range(0, max(0, len(blob) - 47), 8):
|
||||
|
||||
Reference in new issue
Block a user