annotate code_part1/OSTC_code_asm_part1/printf.asm @ 120:5c7f98fad01a

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