Skip to content

Commit

Permalink
Nothing to see; move along
Browse files Browse the repository at this point in the history
  • Loading branch information
pinobatch committed May 3, 2020
1 parent f125b96 commit 2fb8098
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ __pycache__
*.o
*.chr

# Don't get your hopes up
/hopesup/*.sms
/hopesup/*.sym
/hopesup/obj/something/
4 changes: 3 additions & 1 deletion hopesup/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
title:=hopesup
version:=wip
objlist:= \
init main ppuclear pads vwfdraw
init main ppuclear pads vwfdraw vwf7_cp144p

objdir:=obj/something
srcdir:=src
Expand Down Expand Up @@ -59,6 +59,8 @@ $(objdir)/%.pb16: tools/pb16.py $(objdir)/%
$(PY) $^ $@
$(objdir)/%.iu: tools/incruniq.py $(objdir)/%.2b
$(PY) $^ $@
$(objdir)/vwf7_cp144p.asm: tools/vwfbuild.py ../tilesets/vwf7_cp144p.png
$(PY) $^ $@

# LUT generation

Expand Down
6 changes: 0 additions & 6 deletions hopesup/obj/something/objlist

This file was deleted.

1 change: 1 addition & 0 deletions hopesup/src/floormodel.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.include "src/sms.inc"
1 change: 1 addition & 0 deletions hopesup/src/floorvram.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.include "src/sms.inc"
52 changes: 26 additions & 26 deletions hopesup/src/main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -124,39 +124,39 @@ draw_bg:
; Clear the pattern table
vdp_seek_tile 0
ld a, $55
ld d, 32/32
ld d, 40/8
call vmemset_256d

; Clear nametable and SAT
call vdp_clear_nt
vdp_seek_xy 15, 11
ld a, 16
out [VDPDATA], a
ld a, 0
out [VDPDATA], a
ld a, 17
out [VDPDATA], a
ld a, 0
out [VDPDATA], a

; load vwfcanvas
vdp_seek_xy 8, 11
ld c, 16
ld b, c
@loop:
ld a, c
inc c
out [VDPDATA], a
xor a
out [VDPDATA], a
djnz @loop

call vwfClearBuf
ld hl, hello_msg
ld b, 4
call vwfPuts

vdp_seek_tile 16
ld a, $20
out [VDPDATA], a
xor a
out [VDPDATA], a
out [VDPDATA], a
out [VDPDATA], a
ld a, $10
out [VDPDATA], a
xor a
out [VDPDATA], a
out [VDPDATA], a
out [VDPDATA], a
ld hl, lineImgBuf
ld d, 1
call load_1bpp_font

ret

PaletteData:
drgb $FF0000, $555555, $AAAAAA, $FFFFFF
drgb $AAAAAA, $000000
PaletteDataEnd:

hello_msg:
.db "Nothing to see; move along", 0
.ends
18 changes: 15 additions & 3 deletions hopesup/src/vwfdraw.asm
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ vwfPutTile_rowloop:

;;
; Draws the tile for glyph A at horizontal position B
vwfPutTile::
vwfPutTile:

; Calculate address of glyph
ld h,0
Expand Down Expand Up @@ -123,11 +123,11 @@ vwfPutTile::
; Write glyphs for the 8-bit-encoded characters string at (hl) to
; X position B in the VWF buffer
; @return HL pointer to the first character not drawn
vwfPuts::
vwfPuts:
@chloop:
; Load character, stopping at control character
ld a,[hl]
inc a
inc hl
cp 32
jr c,@decret

Expand Down Expand Up @@ -162,5 +162,17 @@ vwfPuts::
dec hl
ret

;;
; Clears the line image.
; @return B = 0; HL = lineImgBuf + lineImgBufLen
vwfClearBuf:
ld hl,lineImgBuf
ld b,lineImgBufLen
xor a
.loop:
ld [hl],a
inc l
djnz .loop
ret

.ends
65 changes: 65 additions & 0 deletions hopesup/tools/vwfbuild.py
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()

0 comments on commit 2fb8098

Please sign in to comment.