
	
Cls:
	lda #0
	stx CursorX 
	sty CursorY
	rts
Locate:
		stx CursorX 
		sty CursorY
	rts
	
NewLine:
	stz CursorX	
	inc CursorY
	rts
  
PrintChar:
	sta z_As
	PushAll
	lda z_H
	pha
	lda z_L
	pha



	
		lda CursorY 	
		ifdef ScrWid256	;256x192
			clc
			adc #2
		endif
		sta z_H
		lda #0
		sta z_L
		clc
		ror z_H
		ror z_L
		ror z_H
		ror z_L
		;ror z_H
		;ror z_L
		
		
		
		
		;jsr WaitVblank
		lda CursorX 	
		adc CursorX
		adc z_L
		sta z_L
		
		
		lda z_L
		adc #<SnesScreenBuffer
		sta z_L
		;lda #$00
		;sta $2116		;MemL -Video port address [VMADDL/VMADDH]                            
		lda z_H
		adc #>SnesScreenBuffer
		sta z_H
		
		ldy #0
		lda z_As
		clc
		sbc #31
		sta (z_HL),y
		iny
		lda #0
		sta (z_HL),y
		
		
		;sta $2116		;MemL -Video port address [VMADDL/VMADDH]                            
		;lda z_H
		;sta $2117		;MemH
	

		;lda #$00
		;sta $2119	;h -Video port data [VMDATAL/VMDATAH]                             
		;lda z_As
		;sbc #31
		;lda #'L'-32
		;sta $2118	;l
	
	inc CursorX
	lda CursorX
	cmp #32
	bne PrintChar_NotNextLine
	jsr NewLine
	
PrintChar_NotNextLine:
	
		
	pla
	sta z_L
	pla
	sta z_H	
	PullAll
	
	rts
	
			
load_font:
	
	lda #$00
	sta $2116		;MemL
	lda #$10
	sta $2117		;MemH

	lda #BitmapFont&255
	sta z_L
	lda #BitmapFont/256
	sta z_H
	ldx #3
	ldy #0
fontchar_loop:
	jsr WaitVblank
	lda (z_HL),y
	sta $2119
	sta $2118			;Write data to data-port
	iny
	lda (z_HL),y
	sta $2119
	sta $2118
	iny
	lda (z_HL),y
	sta $2119
	sta $2118
	iny
	lda (z_HL),y
	sta $2119
	sta $2118
	iny
	lda (z_HL),y
	sta $2119
	sta $2118
	iny
	lda (z_HL),y
	sta $2119
	sta $2118
	iny
	lda (z_HL),y
	sta $2119
	sta $2118
	iny
	lda (z_HL),y
	sta $2119
	sta $2118
	
	
	lda #0	
	jsr blankblock
	iny
	bne fontchar_loop
	inc z_HL+1
	dex
	bne fontchar_loop
	rts
blankblock:
	sta $2119
	sta $2118
	sta $2119
	sta $2118
	sta $2119
	sta $2118
	sta $2119
	sta $2118
	sta $2119
	sta $2118
	sta $2119
	sta $2118
	sta $2119
	sta $2118
	sta $2119
	sta $2118
	rts