;===========================================================================
;File - Char Generator
;Author - Gayan Soyza
;Date - 08-11-2009
;===========================================================================
;Notes
;
;Character Tables must arrange like this starting from MSB
;Char_A Retlw b'0[COLOR="Red"]111[/COLOR]0000' ; Letter A
; Retlw b'[COLOR="Red"]1[/COLOR]000[COLOR="Red"]1[/COLOR]000'
; Retlw b'[COLOR="Red"]1[/COLOR]000[COLOR="Red"]1[/COLOR]000'
; Retlw b'[COLOR="Red"]11111[/COLOR]000'
; Retlw b'[COLOR="Red"]1[/COLOR]000[COLOR="Red"]1[/COLOR]000'
; Retlw b'[COLOR="Red"]1[/COLOR]000[COLOR="Red"]1[/COLOR]000'
; Retlw b'[COLOR="Red"]1[/COLOR]000[COLOR="Red"]1[/COLOR]000'
;GP registers used
;Htab ; Horizontal Tab (Starting Column of a char)
;Byte_H ; division byteH - Integer
;Byte_L ; division byteL - fraction
;Rotate_Count ; Rotate couns for make masks
;Mask_1 ; mask bits of a char,0 bits will affected by new data
;Mask_2 ; mask bits of a char,0 bits will affected by new data
;Temp_H ; Temperory byteH for char placing from table
;Temp_L ; Temperory byteL for char placing from table
;Pointer ; offset values to table patterns
;----------------------------------------------------------------------------
Char_Generator movwf Htab ; ex: 11th column
movwf Byte_H ;
movlw b'00000011' ; Make default masks first
movwf Mask_1 ; 00000011 11111111
movlw b'11111111' ;
movwf Mask_2
bcf STATUS,C
rrf Byte_H,F ; divide by 8
rrf Byte_L,F
bcf STATUS,C
rrf Byte_H,F
rrf Byte_L,F
bcf STATUS,C
rrf Byte_H,F ; 00000001
rrf Byte_L,F ; 01100000
swapf Byte_L,F
bcf STATUS,C
rrf Byte_L,F ; 00000011
;
movf Byte_L,W ; remainder = 3
btfsc STATUS,Z
goto Char_Place_Loop
movwf Rotate_Count ; 3
;
Make_Masks bsf STATUS,C
rrf Mask_1,F ; 11100000
rrf Mask_2,F ; 01111111
decfsz Rotate_Count,F
goto Make_Masks
;
;-----------------------------------------------------------------------------
;
Char_Place_Loop movf Byte_L,W ;
movwf Rotate_Count
movf Byte_H,W ; position register
addlw 20h
movwf FSR ; add the position from 20h
movf Pointer,W
call Table ; get the character pattern
movwf Temp_H ; store in temp
movf Htab,W ; get column
btfsc STATUS,Z ; is it zero column ?
goto Place_Set_1 ; yes,then no need adjust pattern
Adjust_Pattern bcf STATUS,C ; no,
rrf Temp_H,F
rrf Temp_L,F
decfsz Rotate_Count,F
goto Adjust_Pattern
;
Place_Set_1 movf INDF,W
andwf Mask_1,W
iorwf Temp_H,W
movwf INDF
;
incf FSR,F
Place_Set_2 movf INDF,W
andwf Mask_2,W
iorwf Temp_L,W
movwf INDF
decf FSR,F
;
decfsz Row_Counter,F
goto $+4
movlw .7
movwf Row_Counter
retlw 0x00 ; end of placing a char
movlw .6
addwf FSR,F
incf Pointer,F
goto Char_Place_Loop