1:1 source port of the engine and game code; Windows build and system layer; docs. No game files or SDK headers.
This commit is contained in:
parent
c3b032a45a
commit
0ecb47e9cb
3871 changed files with 91080 additions and 1640063 deletions
26
tools/port/gen_defaultfont.py
Normal file
26
tools/port/gen_defaultfont.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"""Generate port/src/core/defaultfont.h: the built-in vector font kDefaultFont (pflib/src/core/defaultfont.h,
|
||||
decl line 3: an anonymous-namespace "const unsigned char[76844]"), copied byte for byte from the shipped game binary
|
||||
(__const @0x001932a0, 0x12c2c bytes; identical to the SDK debug object textgraphic.o __const @0x3bc00).
|
||||
usage: python3 tools/port/gen_defaultfont.py"""
|
||||
import os, re, struct, subprocess
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
B = os.path.expanduser("~/Library/Application Support/Steam/steamapps/common/Chocolatier Decadence by Design/chocolatier-decadence-design.app/Contents/MacOS/chocolatier-decadence-design")
|
||||
ADDR, SIZE = 0x1932a0, 0x12c2c
|
||||
out = subprocess.run(['otool', '-arch', 'i386', '-l', B], capture_output=True, text=True).stdout
|
||||
data = open(B, 'rb').read()
|
||||
for m in re.finditer(r'sectname (\S+)\n\s+segname (\S+)\n\s+addr (0x[0-9a-f]+)\n\s+size (0x[0-9a-f]+)\n\s+offset (\d+)', out):
|
||||
s, sz, off = int(m.group(3), 16), int(m.group(4), 16), int(m.group(5))
|
||||
if s <= ADDR < s + sz:
|
||||
blob = data[off + ADDR - s: off + ADDR - s + SIZE]
|
||||
break
|
||||
assert len(blob) == SIZE and blob[:4] == b'MVC4'
|
||||
lines = ['// Generated by tools/port/gen_defaultfont.py from the game binary (__const @0x001932a0, 0x12c2c bytes). Do not edit.',
|
||||
'// Port of pflib/src/core/defaultfont.h (Playground SDK 4.0): the built-in "MVC4" vector font used when a font',
|
||||
'// file cannot be opened (TFontData::GetMvec). Included by textgraphic.cpp only.',
|
||||
'#ifndef DEFAULTFONT_H_INCLUDED', '#define DEFAULTFONT_H_INCLUDED', '', 'namespace', '{',
|
||||
'const unsigned char kDefaultFont[%d] = {' % SIZE]
|
||||
for i in range(0, SIZE, 24):
|
||||
lines.append(' ' + ','.join('0x%02x' % b for b in blob[i:i + 24]) + ',')
|
||||
lines += ['};', '}', '', '#endif // DEFAULTFONT_H_INCLUDED', '']
|
||||
open(os.path.join(ROOT, 'port/src/core/defaultfont.h'), 'w').write('\n'.join(lines))
|
||||
print('wrote port/src/core/defaultfont.h', SIZE, 'bytes')
|
||||
Loading…
Add table
Add a link
Reference in a new issue