comparison code_part1/OSTC_code_asm_part1/displaytext.asm @ 0:96a35aeda5f2

Initial setup
author heinrichsweikamp
date Tue, 12 Jan 2010 15:05:59 +0100
parents
children ceeeb5e49348
comparison
equal deleted inserted replaced
-1:000000000000 0:96a35aeda5f2
1
2 ; OSTC - diving computer code
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR
4
5 ; This program is free software: you can redistribute it and/or modify
6 ; it under the terms of the GNU General Public License as published by
7 ; the Free Software Foundation, either version 3 of the License, or
8 ; (at your option) any later version.
9
10 ; This program is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU General Public License for more details.
14
15 ; You should have received a copy of the GNU General Public License
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19 ; Displays from text_table_vx.asm
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
21 ; written: 10/30/05
22 ; last updated: 081215
23 ; known bugs:
24 ; ToDo:
25
26
27 ; These macros output to POSTINC only
28 OUTPUTTEXT macro textnumber ; For Texts 1-254
29 movlw textnumber
30 call displaytext0
31 endm
32
33 OUTPUTTEXTH macro textnumber ; For Texts 255-511
34 movlw LOW textnumber ; Use only Lower 8 Bit
35 call displaytext0_h
36 endm
37
38 displaytext0_h:
39 bsf displaytext_high ; Highbit set
40 rcall displaytext0
41 return
42
43 displaytext0:
44 bsf output_to_postinc_only
45 rcall displaytext1
46 bcf output_to_postinc_only
47 return
48
49 ; These macros output to POSTINC and call the wordprocessor
50 DISPLAYTEXT macro textnumber
51 movlw textnumber
52 call displaytext1
53 endm
54
55 DISPLAYTEXTH macro textnumber
56 movlw LOW textnumber ; Use only Lower 8 Bit
57 call displaytext1h
58 endm
59
60 displaytext1h:
61 bsf displaytext_high ; Highbit set
62 rcall displaytext1
63 return
64
65 displaytext1:
66 movwf textnumber
67 movlw b'10000000'
68 movwf EECON1
69
70 clrf TBLPTRU
71 movlw textpos_pointer_high
72 movwf TBLPTRH
73 movlw textpos_pointer_low ; base address -4 for position table
74 movwf TBLPTRL
75
76 movff textnumber,xA+0
77 movlw d'0'
78 btfsc displaytext_high ; Highbit set?
79 movlw d'1' ; Yes!
80 movwf xA+1 ; Set High Bit
81 movlw d'4' ; times 4 for adress
82 movwf xB+0
83 clrf xB+1
84 call mult16x16 ;xA*xB=xC
85 movf xC+0,W
86 addwf TBLPTRL,F ; set adress, data can be read
87 movf xC+1,W
88 addwfc TBLPTRH,F ; High byte, if required
89
90 TBLRD*+
91 movf TABLAT,W
92 btfsc output_to_postinc_only ; output to postinc only?
93 bra displaytext1_1 ; Yes
94 movff WREG,win_leftx2
95
96 displaytext1_1:
97 TBLRD*+
98 movf TABLAT,W
99 btfsc output_to_postinc_only ; output to postinc only?
100 bra displaytext1_2 ; Yes
101 movff WREG,win_top
102
103 displaytext1_2:
104 TBLRD*+
105 movf TABLAT,W ; ScaleY
106 sublw d'1' ; -1
107 movff WREG,win_font
108
109 TBLRD*+
110 movff TABLAT,grayvalue ; grayvalue
111
112 clrf textaddress+0
113 clrf textaddress+1
114 clrf TBLPTRL ; Set Pointer for textlength table 0x0100
115 clrf TBLPTRU
116 movlw 0x01
117 movwf TBLPTRH
118 bra displaytext1b
119
120 displaytext1a:
121 bcf displaytext_high ; Clear flag
122 ; Get textadress from textlength table
123 displaytext1b:
124 TBLRD*+
125 movf TABLAT,W
126 addwf textaddress+0,F
127 movlw d'0'
128 addwfc textaddress+1,F
129 decfsz textnumber,F
130 bra displaytext1b
131
132 btfsc displaytext_high ; Highbit set?
133 bra displaytext1a ; Yes, add 256 loops
134
135 displaytext2: ; copies text to wordprocessor
136 clrf TBLPTRU
137
138 movlw text_pointer_low
139 addwf textaddress+0,W
140 movwf TBLPTRL
141 movlw text_pointer_high ; Base address Texts
142 addwfc textaddress+1,W
143 movwf TBLPTRH
144
145 btfss output_to_postinc_only ; output to postinc only?
146 lfsr FSR2,letter ; no!
147
148 displaytext2a:
149 TBLRD*+
150 movlw '}' ; Text finished?
151 cpfseq TABLAT
152 bra displaytext3
153 bra display_text_exit
154
155 displaytext3:
156 movf TABLAT,W
157 movwf POSTINC2
158
159 TBLRD*+
160 movlw '}' ; Text finished?
161 cpfseq TABLAT
162 bra displaytext4
163 bra display_text_exit
164 displaytext4:
165 movf TABLAT,W
166 movwf POSTINC2
167
168 bra displaytext2a
169
170 display_text_exit:
171 btfss output_to_postinc_only ; output to postinc only?
172 call word_processor
173 return