User Tools

Site Tools


6-bit-print

6-bit text print routine


syntax is for sjasmplus

;6-bit text print (42 columns) by MTB (c)1994 @ ZXM 5/1994
;simplification, bugfix and sjasmplus formatting by z00m/SinDiKAT (c)2016
;input: hl=text address, de=print position
 
 
 
;		device	zxspectrum48
 
;		org	32768
 
;printpos	equ	16384
 
;demo:
;		ld	hl,text
;		call	print
;endless:	
;		di
;		halt
;		jr	endless
 
print:		
;		ld	de,printpos
		ld	(pos),de
		xor	a
		ld	(roll),a	
 
print1:		
		push	hl
		ld	a,(hl)
		and	127
		call	ascii
		ld	a,(roll)
		inc	a
		cp	1
		call	z,print2
		cp	2
		call	z,print2
		cp	4
		jr	nz,print3
		ld	a,0
		call	print2
print3:
		ld	(roll),a
		pop	hl
		bit	7,(hl)
		inc	hl
		ret	nz
		jr	print1
 
print2:
		ld	hl,(pos)
		inc	hl
		ld	(pos),hl
		ret
 
ascii:
		ld	bc,font
		push	bc
		sub	32
		ld	e,a
		ld	d,0
		ld	b,8
		ld	hl,0
x8:
		add	hl,de
		djnz	x8
		pop	bc
		add	hl,bc
		ld	de,(pos)
		ex	de,hl
asci0:
		ld	a,(roll)
		cp	3
		jr	z,roll3
		cp	2
		jr	z,roll2
		cp	1
		jr	z,roll1
roll0:
		call	asci1
		ret
 
roll1:
		ld	b,8
rol1_1:
		ld	a,(de)
		sla	a
		ld	c,0
		rl	c
		sla	a
		rl	c
		push	bc
		call	asci2
		pop	bc
		inc	de
		djnz	rol1_1
		ret
 
roll2:
		ld	b,8
rol2_1:
		ld	a,(de)
		sla	a
		ld	c,0
		rl	c
		sla	a
		rl	c
		sla	a
		rl	c
		sla	a
		rl	c
		push	bc
		call	asci2
		pop	bc
		inc	de
		djnz	rol2_1
		ret
 
roll3:
		ld	b,8
rol3_1:
		ld	a,(de)
		srl	a
		srl	a
		push	bc
		call	asci3
		pop	bc
		inc	de
		djnz	rol3_1
		ret
 
asci1:
		ld	b,8
asc1:
		ld	a,(de)
		ld	(hl),a
		inc	de
		call	downhl
		djnz	asc1
		ret
 
asci2:
		ld	(hl),a
		ld	a,c
		dec	hl
		or	(hl)
		ld	(hl),a
		inc	hl
		call	downhl
		ret
 
asci3:
		or	(hl)
		ld	(hl),a
 
downhl:
		inc	h
		ld	a,h
		and	7
		ret	nz
		ld	a,l
		add	a,32
		ld	l,a
		ld	a,h
		jr	c,down2
		sub	8
		ld	h,a
down2:
		cp	88
		ret	c
		ld	hl,64
		ret
 
;5-bit font
font:
		db	$00, $00, $00, $00, $00, $00, $00, $00
		db	$00, $20, $20, $20, $20, $00, $20, $00
		db	$00, $50, $50, $00, $00, $00, $00, $00
		db	$00, $50, $F8, $50, $50, $F8, $50, $00
		db	$00, $20, $F8, $A0, $F8, $28, $F8, $20
		db	$00, $40, $A8, $50, $20, $50, $A8, $10
		db	$00, $20, $50, $20, $68, $90, $68, $00
		db	$00, $10, $20, $00, $00, $00, $00, $00
		db	$00, $08, $10, $10, $10, $10, $08, $00
		db	$00, $40, $20, $20, $20, $20, $40, $00
		db	$00, $00, $50, $20, $F8, $20, $50, $00
		db	$00, $00, $20, $20, $F8, $20, $20, $00
		db	$00, $00, $00, $00, $00, $10, $10, $20
		db	$00, $00, $00, $00, $78, $00, $00, $00
		db	$00, $00, $00, $00, $00, $30, $30, $00
		db	$00, $00, $08, $10, $20, $40, $80, $00
		db	$00, $70, $98, $A8, $A8, $C8, $70, $00
		db	$00, $60, $A0, $20, $20, $20, $F8, $00
		db	$00, $70, $88, $08, $70, $80, $F8, $00
		db	$00, $70, $88, $30, $08, $88, $70, $00
		db	$00, $10, $30, $50, $90, $F8, $10, $00
		db	$00, $F8, $80, $F0, $08, $88, $70, $00
		db	$00, $70, $80, $F0, $88, $88, $70, $00
		db	$00, $F8, $08, $10, $20, $40, $40, $00
		db	$00, $70, $88, $70, $88, $88, $70, $00
		db	$00, $70, $88, $88, $78, $08, $70, $00
		db	$00, $00, $00, $20, $00, $00, $20, $00
		db	$00, $00, $20, $00, $00, $20, $20, $40
		db	$00, $00, $08, $10, $20, $10, $08, $00
		db	$00, $00, $00, $78, $00, $78, $00, $00
		db	$00, $00, $20, $10, $08, $10, $20, $00
		db	$00, $70, $88, $10, $20, $00, $20, $00
		db	$00, $70, $08, $68, $A8, $A8, $70, $00
		db	$00, $70, $88, $88, $F8, $88, $88, $00
		db	$00, $F0, $88, $F0, $88, $88, $F0, $00
		db	$00, $70, $88, $80, $80, $88, $70, $00
		db	$00, $E0, $90, $88, $88, $90, $E0, $00
		db	$00, $F8, $80, $F0, $80, $80, $F8, $00
		db	$00, $F8, $80, $F0, $80, $80, $80, $00
		db	$00, $70, $88, $80, $B8, $88, $70, $00
		db	$00, $88, $88, $F8, $88, $88, $88, $00
		db	$00, $F8, $20, $20, $20, $20, $F8, $00
		db	$00, $08, $08, $08, $88, $88, $70, $00
		db	$00, $90, $A0, $C0, $A0, $90, $88, $00
		db	$00, $80, $80, $80, $80, $80, $F8, $00
		db	$00, $88, $D8, $A8, $88, $88, $88, $00
		db	$00, $88, $C8, $A8, $98, $88, $88, $00
		db	$00, $70, $88, $88, $88, $88, $70, $00
		db	$00, $F0, $88, $88, $F0, $80, $80, $00
		db	$00, $70, $88, $88, $A8, $98, $70, $00
		db	$00, $F0, $88, $88, $F0, $90, $88, $00
		db	$00, $70, $80, $70, $08, $88, $70, $00
		db	$00, $F8, $20, $20, $20, $20, $20, $00
		db	$00, $88, $88, $88, $88, $88, $70, $00
		db	$00, $88, $88, $88, $88, $50, $20, $00
		db	$00, $88, $88, $88, $88, $A8, $50, $00
		db	$00, $88, $50, $20, $20, $50, $88, $00
		db	$00, $88, $50, $20, $20, $20, $20, $00
		db	$00, $F8, $08, $30, $40, $80, $F8, $00
		db	$00, $38, $20, $20, $20, $20, $38, $00
		db	$00, $00, $80, $40, $20, $10, $08, $00
		db	$00, $70, $10, $10, $10, $10, $70, $00
		db	$00, $20, $70, $A8, $20, $20, $20, $00
		db	$00, $00, $00, $00, $00, $00, $00, $FC
		db	$00, $30, $48, $E0, $40, $40, $F8, $00
		db	$00, $00, $70, $08, $78, $88, $78, $00
		db	$00, $80, $80, $F0, $88, $88, $F0, $00
		db	$00, $00, $38, $40, $40, $40, $38, $00
		db	$00, $08, $08, $78, $88, $88, $78, $00
		db	$00, $00, $70, $88, $F0, $80, $78, $00
		db	$00, $30, $40, $60, $40, $40, $40, $00
		db	$00, $00, $78, $88, $88, $78, $08, $70
		db	$00, $80, $80, $F0, $88, $88, $88, $00
		db	$00, $20, $00, $60, $20, $20, $70, $00
		db	$00, $08, $00, $08, $08, $08, $48, $30
		db	$00, $40, $50, $60, $60, $50, $48, $00
		db	$00, $40, $40, $40, $40, $40, $30, $00
		db	$00, $00, $D0, $A8, $A8, $A8, $A8, $00
		db	$00, $00, $F0, $88, $88, $88, $88, $00
		db	$00, $00, $70, $88, $88, $88, $70, $00
		db	$00, $00, $F0, $88, $88, $F0, $80, $80
		db	$00, $00, $78, $88, $88, $78, $08, $08
		db	$00, $00, $38, $40, $40, $40, $40, $00
		db	$00, $00, $70, $80, $70, $08, $F0, $00
		db	$00, $20, $70, $20, $20, $20, $18, $00
		db	$00, $00, $88, $88, $88, $88, $70, $00
		db	$00, $00, $88, $88, $50, $50, $20, $00
		db	$00, $00, $88, $A8, $A8, $A8, $50, $00
		db	$00, $00, $88, $50, $20, $50, $88, $00
		db	$00, $00, $88, $88, $88, $78, $08, $70
		db	$00, $00, $F8, $10, $20, $40, $F8, $00
		db	$00, $38, $20, $C0, $20, $20, $38, $00
		db	$00, $10, $10, $10, $10, $10, $10, $00
		db	$00, $E0, $20, $18, $20, $20, $E0, $00
		db	$00, $28, $50, $00, $00, $00, $00, $00
		db	$00, $78, $84, $B4, $B4, $84, $78, $00
 
pos:		dw	0
roll:		db	0
txtbuf:		ds	44
 
;text:
;		db	"This is sample text"
;		db	46+128			;last char is inverted, "." here.
 
;		savesna	"6bitprint.sna",demo

Navigation: general . math . graphic . sound . system . other . back to start

6-bit-print.txt · Last modified: 2017/02/16 13:21 by darkbyte