Compare commits

...

5 commits

Author SHA1 Message Date
Jeff Epler
c35cf2827f img/: use generated font images 2017-07-13 14:41:37 -05:00
Jeff Epler
60934cf830 Makefile: generate font image programmatically 2017-07-13 14:41:26 -05:00
Jeff Epler
1d379db86b Makefile: build with all 4 character sets 2017-07-13 13:53:50 -05:00
Jeff Epler
a8b6b59b62 Makefile: declare targets that don't create files .PHONY
.. see GNU make for more information about this extension, which
prevents unwanted behavior if a file with a name like 'clean' or 'all'
is created accidentally
2017-07-13 13:34:59 -05:00
Jeff Epler
1bc4391921 Makefile: don't error if you 'make clean' twice 2017-07-13 13:34:07 -05:00
11 changed files with 100 additions and 8 deletions

View file

@ -1,10 +1,40 @@
all:
ca65 80columns.s
ca65 -o charset.o charset.s
ld65 -C 80columns.cfg 80columns.o charset.o -o 80columns.bin
printf "\0\310" > 80columns.prg
cat 80columns.bin >> 80columns.prg
exomizer sfx 51200 -q -n -o 80columns-compressed.prg 80columns.prg
.PHONY: all
all: 80columns-compressed.prg 80c2-compressed.prg 80c3-compressed.prg 80c4-compressed.prg
.INTERMEDIATE: charset.bin
charset.bin: charset.o charset.cfg
ld65 -C charset.cfg $< -o $@
charset%.bin: charset%.o charset.cfg
ld65 -C charset.cfg $< -o $@
%-compressed.prg: %-uncompressed.prg
exomizer sfx 51200 -q -n -o $@ $<
%-uncompressed.prg: %.bin
(printf '\0\310'; cat $<) > $@
.PHONY: update-font-images
update-font-images: charset.bin charset2.bin charset3.bin charset4.bin mkfontimg.py
python mkfontimg.py -l charset.bin img/t1.png
python mkfontimg.py charset.bin img/g1.png
python mkfontimg.py -l charset2.bin img/t2.png
python mkfontimg.py charset2.bin img/g2.png
python mkfontimg.py -l charset3.bin img/t3.png
python mkfontimg.py charset3.bin img/g3.png
python mkfontimg.py -l charset4.bin img/t4.png
python mkfontimg.py charset4.bin img/g4.png
.INTERMEDIATE: 80columns.bin
80columns.bin: 80columns.o charset.o 80columns.cfg
ld65 -C 80columns.cfg $(filter %.o,$^) -o $@
80c%.bin: 80columns.o charset%.o 80columns.cfg
ld65 -C 80columns.cfg $(filter %.o,$^) -o $@
%.o: %.s
ca65 -o $@ $<
.PHONY: clean
clean:
rm *.prg *.bin *.o
rm -f *.prg *.bin *.o

7
charset.cfg Normal file
View file

@ -0,0 +1,7 @@
MEMORY {
CHARSET: start = $D000, size = $0800, fill=no;
}
SEGMENTS {
CHARSET: load = CHARSET, type = ro;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 855 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3 KiB

After

Width:  |  Height:  |  Size: 932 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 904 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 970 B

55
mkfontimg.py Normal file
View file

@ -0,0 +1,55 @@
#!/usr/bin/python
import sys
import PIL.Image as Image
text = """\
10 poke53280,0:poke53281,1
20 print"\xd0\xd3";
30 fory=0to7
40 forx=0to15
50 poke49152+111+x+80*y,x+16*y
60 next
70 next
80 list"""
lowercase = False
if sys.argv[1] == '-l':
lowercase = True
del sys.argv[1]
def toscreencode(ch):
cc = ord(ch)
if '`' <= ch <= '~': return cc - 96
return cc
charset = map(ord, open(sys.argv[1]).read())
def putcat(img, r, c, code, lowercase):
inverse = code & 128
code = code % 128
idx = code*8
for y in range(8):
data = charset[idx+y+lowercase*1024]
if not inverse: data = ~data
for x in range(4):
img.putpixel((4*c+x,8*r+y), data & (1<<(3-x)))
img = Image.frombytes('1', (188,64), '\xff' * 188*64)
r=c=0
for ch in text:
if ch == '\n':
r = r + 1
c = 0
continue
putcat(img, r, c, toscreencode(ch), lowercase)
c = c + 1
if c == 80:
r = r + 1
c = 0
for r in range(8):
for c in range(16):
putcat(img, r, c+31, r*16+c, lowercase)
img.save(sys.argv[2])