CLS:
	ld de,%0000000000011000
	ld bc,320*240/2
	ld hl,$D40000
CLSB:
	
	ld (hl),e
	inc hl
	ld (hl),d
	inc hl
	
	ld (hl),e
	inc hl
	ld (hl),d
	inc hl
	
	dec bc
	ld a,b 
	or c
	jr nz,CLSB
	ret

Printchar:
	push af
	push bc
	push de
	push hl
	push ix 
		
		push af
			call GetScreenPos
		pop af
		sub ' '				;We don't have any chars below 32 (Space)

		ld h,0
		
		sla a
		rl h
		sla a
		rl h
		sla a
		rl h
		ld l,a
		push de
			ld de,Font		;Add Location of Bitmap font
			add hl,de
		pop de
		
		ld ixl,8
FontNextLine:	
		
#ifndef fourcolor
		ld c,(hl)
		inc hl
		ld b,8
		push de
FontNextPixel:
			rl c
			jr c,Pixel1
Pixel0
			ld a,%00011000
			ld (de),a
			inc de
			ld a,%00000000
			ld (de),a
			inc de
			jr PixelNext
Pixel1
			ld a,%00000011
			ld (de),a
			inc de
			ld a,%11111111
			ld (de),a
			inc de
PixelNext:
		djnz FontNextPixel
#else
		ld c,(hl)
		inc hl
		ld b,4
		push de
FontNextPixel:
			xor a
			rl c
			rr a
			rrca
			rrca
			rrca
			rl c
			rr a
			rrca
			rrca
			rrca
			ld (de),a
			inc de
		djnz FontNextPixel
#endif
		pop de
		call GetNextLine
		dec ixl
		jr nz,FontNextLine
		ld bc,(xpos)
		inc bc
		ld (xpos),bc
		
	pop ix
	pop hl
	pop de
	pop bc
	pop af
	ret 
 
#ifndef fourcolor
 
GetNextLine:
	push hl
		ld hl,320*2
		add hl,de
		ex de,hl
	pop hl
	ret
GetScreenPos:
	ld hl,$D40000
	
	ld de,16
	ld bc,(Xpos)
	call BCMult
	
	ld de,320*2*8
	ld bc,(Ypos)
	call BCMult
	ex de,hl
	ret
#else

GetNextLine:
	push hl
		ld hl,320/2
		add hl,de
		ex de,hl
	pop hl
	ret
GetScreenPos:
	ld hl,$D40000
	
	ld de,4
	ld bc,(Xpos)
	call BCMult
	
	ld de,320*8/2
	ld bc,(Ypos)
	call BCMult
	ex de,hl
	ret
#endif	

NewLine:
	push bc
		ld bc,(ypos)
		inc bc
		ld (ypos),bc
		ld bc,0
		ld (xpos),bc
	pop bc
	ret
	
NewLine8Bit:
	push bc
		ld bc,(ypos)
		inc bc
		ld (ypos),bc
		ld bc,0
		ld (xpos),bc
	pop bc
	ret.l
	
 
BCMult:
	ld a,b
	or c
	ret z
	add hl,de
	dec bc
	jr BCMult
	

PrintString:
	ld a,(hl)	;Char 255 terminated string
	cp 255
	ret z
	inc hl
	call PrintChar
	jr PrintString

;PrintCharOld:
	;call $0207B8
;	ret 
	
;NewLineOld:
	;call $0207F0
	;ret 
	

Xpos: .db 0,0,0
Ypos: .db 0,0,0
