-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
113 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,7 @@ __pycache__ | |
*.o | ||
*.chr | ||
|
||
# Don't get your hopes up | ||
/hopesup/*.sms | ||
/hopesup/*.sym | ||
/hopesup/obj/something/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.include "src/sms.inc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.include "src/sms.inc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env python3 | ||
from __future__ import with_statement | ||
from PIL import Image | ||
import sys | ||
|
||
def rgbasm_bytearray(s): | ||
s = [' .db ' + ','.join("%3d" % ch for ch in s[i:i + 16]) | ||
for i in range(0, len(s), 16)] | ||
return '\n'.join(s) | ||
|
||
def vwfcvt(filename, tileHt=8): | ||
im = Image.open(filename) | ||
pixels = im.load() | ||
(w, h) = im.size | ||
(xparentColor, sepColor) = im.getextrema() | ||
widths = bytearray() | ||
tiledata = bytearray() | ||
for yt in range(0, h, tileHt): | ||
for xt in range(0, w, 8): | ||
# step 1: find the glyph width | ||
tilew = 8 | ||
for x in range(8): | ||
if pixels[x + xt, yt] == sepColor: | ||
tilew = x | ||
break | ||
# step 2: encode the pixels | ||
widths.append(tilew) | ||
for y in range(tileHt): | ||
rowdata = 0 | ||
for x in range(8): | ||
pxhere = pixels[x + xt, y + yt] | ||
pxhere = 0 if pxhere in (xparentColor, sepColor) else 1 | ||
rowdata = (rowdata << 1) | pxhere | ||
tiledata.append(rowdata) | ||
return (widths, tiledata) | ||
|
||
def main(argv=None): | ||
import sys | ||
if argv is None: | ||
argv = sys.argv | ||
if len(argv) > 1 and argv[1] == '--help': | ||
print("usage: %s font.png font.asm" % argv[0]) | ||
return | ||
if len(argv) != 3: | ||
print("wrong number of options; try %s --help" % argv[0], file=sys.stderr) | ||
sys.exit(1) | ||
|
||
(widths, tiledata) = vwfcvt(argv[1]) | ||
out = ["; Generated by vwfbuild", | ||
'.include "src/sms.inc"', | ||
'.section "vwfChrData" align 8 ; glyph height = 8', | ||
'vwfChrData:', | ||
rgbasm_bytearray(tiledata), | ||
"vwfChrWidths:", | ||
rgbasm_bytearray(widths), | ||
'.ends', | ||
''] | ||
with open(argv[2], 'w') as outfp: | ||
outfp.write('\n'.join(out)) | ||
|
||
if __name__ == '__main__': | ||
if 'idlelib' in sys.modules: | ||
main(['vwfbuild', '../../tilesets/vwf7_cp144p.png', '../obj/something/vwf7.asm']) | ||
else: | ||
main() |