annotate code_part1/OSTC_code_asm_part1/displaytext.asm @ 34:5dbdc08e5460

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