User Tools

Site Tools


8-bit-print

8-bit text print routine


syntax is for sjasmplus

;8-bit text print (32 columns) by Universum (c)1992, taken from ASM&ZXS book
;sjasmplus formatting by z00m/SinDiKAT (c)2016
;input: hl=text address, (printpos)=print position, font=font position
 
;		device	zxspectrum48
 
;		org	32768
 
font		equ	15616
 
;demo:
;		ld	hl,text
;		ld	de,16384
;		ld	(printpos),de
;		call	print
;endless:
;		di
;		halt
;		jr	endless
 
print:
		ld	a,(hl)
		cp	0
		ret	z
		call	char1
		inc	hl
		jr	print
 
char1:
		push	af
		exx
		ld	l,a
		ld	h,0
		add	hl,hl
		add	hl,hl
		add	hl,hl
		ld	bc,font-256
		add	hl,bc
		ld	de,(printpos)
		push	de
		ld	b,8
char1a:
		ld	a,(hl)
		ld	(de),a
		inc	hl
		inc	d
		djnz	char1a
		pop	de
		inc	e
		jr	nz,char1b
		ld	a,d
		add	a,8
		ld	d,a
		cp	88
		jr	c,char1b
		ld	d,64
char1b:
		ld	(printpos),de
		exx
		pop	af
		ret
 
printpos:	dw	0
 
text:		db	"This is sample text."
		db	0				;text ends with 0 (zero)
 
;		savesna "8bitprint.sna",demo

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

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