24 lines
1022 B
Python
24 lines
1022 B
Python
from pathlib import Path
|
|
from PIL import Image,ImageDraw,ImageFont
|
|
import struct
|
|
p=Path(__file__).parent
|
|
u16=lambda n:struct.pack('>H',n)
|
|
u32=lambda n:struct.pack('>I',n&0xffffffff)
|
|
h=bytearray(78);h[0:4]=u16(0xe310)+u16(1)
|
|
h[12:16]=u16(48)+u16(40);h[16:18]=u16(6);h[48]=3
|
|
for off in (22,26):h[off:off+4]=u32(1)
|
|
h[58:66]=u32(-1)+u32(-1);h[74:78]=u32(131072)
|
|
data=bytearray(h)
|
|
for selected in (False,True):
|
|
im=Image.new('P',(48,40),0);d=ImageDraw.Draw(im)
|
|
d.rounded_rectangle((2,1,45,34),radius=3,fill=2,outline=1 if selected else 3,width=2)
|
|
d.rectangle((6,5,41,29),fill=0,outline=3)
|
|
d.text((9,7),'BBS',font=ImageFont.load_default(),fill=1)
|
|
d.line((10,23,15,23),fill=3,width=2);d.line((18,23,34,23),fill=3)
|
|
d.rectangle((18,35,30,37),fill=3)
|
|
data+=u16(0)+u16(0)+u16(48)+u16(40)+u16(2)+u32(1)+bytes([3,0])+u32(0)
|
|
for plane in range(2):
|
|
for y in range(40):
|
|
for x in range(0,48,8):data.append(sum((128>>i) if im.getpixel((x+i,y))&(1<<plane) else 0 for i in range(8)))
|
|
(p/'assets/RetroTerm.info').write_bytes(data)
|