comparison code_part1/OSTC_code_asm_part1/printf.asm @ 83:3e351e25f5d1

adding anti-aliased fonts frame and merging some patches from Jeando
author heinrichsweikamp
date Tue, 07 Dec 2010 22:36:19 +0100
parents
children
comparison
equal deleted inserted replaced
82:bc3092c41335 83:3e351e25f5d1
1 ;=============================================================================
2 ;
3 ; file printf.asm
4 ; brief Implementation code for the PRINTF macros.
5 ; author JD Gascuel.
6 ;
7 ; copyright (c) 2010, JD Gascuel. All rights reserved.
8 ; $Id: printf.asm 60 2010-11-27 18:40:53Z gascuel $
9 ;=============================================================================
10 ; HISTORY
11 ; 2010-11-17 : [jDG] Creation...
12 ;
13 ; BUGS : repetitive calls to the same CF# color do strange things...
14
15 #include printf.inc
16
17 ; We need to keep the flags. To avoid trouble of memory alloc, put it in
18 ; some register untouched by any called function...
19 #define flags FSR0L
20
21 printf_subroutine:
22 movff TBLPTRL, printf_len ; Save bloc start before parsing
23
24 tblrd*+ ; Read flags...
25 movf TABLAT,W ; Get flags
26 movwf flags ; and save for later use.
27
28 andlw 3 ; Select font bits
29 bz printf_keep_font ; Keep font ? skip setting
30 decf WREG ; Minus one make it font size.
31 movff WREG, win_font
32
33 printf_keep_font:
34 clrf WREG ; Normal or invert video ?
35 btfsc flags,2
36 movlw 1
37 movff WREG, win_invert
38
39 btfss flags,3 ; Optional Top/Left position ?
40 bra printf_no_position
41
42 tblrd*+ ; Copy it...
43 movff TABLAT, win_top
44 tblrd*+
45 movff TABLAT, win_leftx2
46
47 printf_no_position:
48 btfss flags,4 ; Optional RRRGGGBB packed color ?
49 bra printf_no_color8
50 tblrd*+
51 movff TABLAT, WREG
52 call PLED_set_color
53
54 printf_no_color8:
55 btfss flags,5 ; Optional CF color ?
56 bra printf_no_color_cf
57 tblrd*+
58 movff TABLAT, WREG
59 call getcustom8_1 ; Read CF into WREG
60 call PLED_set_color ; convert it to 16bits into win_color1:2
61
62 printf_no_color_cf:
63 movf flags,W ; Should we completely skip string copy/append ?
64 andlw .192
65 xorlw .192 ; Is command 192 (no string op) ?
66 bz printf_exec
67
68 btfsc flags,7 ; Don't reset FRS2 index ?
69 bra printf_strcat
70 lfsr FSR2, letter
71 bra printf_loop
72
73 printf_strcat:
74 movlw 0x60
75 cpfslt FSR2L
76 decf FSR2L
77
78 printf_loop: ; Loop over string append byte by byte.
79 tblrd*+
80 movff TABLAT, POSTINC2
81 tstfsz TABLAT
82 bra printf_loop
83
84 printf_exec:
85 movf printf_len,W ; Get back block start
86 subwf TBLPTRL,W ; Compute block len
87 movwf printf_len ; And backup for inline variante
88
89 movf flags,W ; Was is a NO-PRINT command ?
90 addlw .64 ; DEF/CPY/CAT/PRT ->64/128/192/0
91 btfsc WREG,7 ; Test if 128 or 192 ?
92 return
93
94 ifdef AAFFONTS
95 goto aa_wordprocessor ; TESTING NEW STRINGWIDTH ROUTINE
96 else
97 goto word_processor
98 endif
99
100 ;=============================================================================
101
102 printf_inline:
103 movff TOSU, TBLPTRU ; Transfer return addr to Table ptr
104 movff TOSH, TBLPTRH
105 movff TOSL, TBLPTRL
106
107 rcall printf_subroutine ; Execute command bloc
108
109 movlb 1 ; Restore BANK1 after C-code
110
111 ; Round-up block length, so to branch to even addr.
112 movf printf_len,W ; Get back block len
113 incf WREG ; Add +1
114 andlw 0xFE ; Then clean odd bit
115
116 ; Then add len to return address
117 addwf TOSL,F
118 movlw 0 ; Clear WREG, but keep carry
119 addwfc TOSH,F
120 addwfc TOSU,F
121 return