annotate src/tft.asm @ 151:5cb177f0948a

work on flip screen...
author heinrichsweikamp
date Mon, 18 Aug 2014 17:37:00 +0200
parents 53409476a05f
children 19ad15f04f60
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File tft.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Managing the TFT screen
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code.
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 #include "ostc3.inc"
heinrichsweikamp
parents:
diff changeset
13 #include "wait.inc"
heinrichsweikamp
parents:
diff changeset
14 #include "varargs.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "external_flash.inc"
heinrichsweikamp
parents:
diff changeset
16 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "eeprom_rs232.inc"
heinrichsweikamp
parents:
diff changeset
18
heinrichsweikamp
parents:
diff changeset
19 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
20 ; TFT_frame needs to backup coordinates.
heinrichsweikamp
parents:
diff changeset
21 CBLOCK tmp
heinrichsweikamp
parents:
diff changeset
22 save_top
heinrichsweikamp
parents:
diff changeset
23 save_height
heinrichsweikamp
parents:
diff changeset
24 save_left
heinrichsweikamp
parents:
diff changeset
25 save_width
heinrichsweikamp
parents:
diff changeset
26 ds_line ; Current line (0..239).
heinrichsweikamp
parents:
diff changeset
27 ds_column ; Current columnx2 (0..159)
heinrichsweikamp
parents:
diff changeset
28 ds_pixel:2 ; Current pixel color.
heinrichsweikamp
parents:
diff changeset
29 ds_count ; Repetition count.
heinrichsweikamp
parents:
diff changeset
30 ENDC
heinrichsweikamp
parents:
diff changeset
31
heinrichsweikamp
parents:
diff changeset
32 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
33 ; Basic bit-level macros
heinrichsweikamp
parents:
diff changeset
34
heinrichsweikamp
parents:
diff changeset
35 RD_H macro
heinrichsweikamp
parents:
diff changeset
36 bsf tft_rd,0
heinrichsweikamp
parents:
diff changeset
37 endm
heinrichsweikamp
parents:
diff changeset
38
heinrichsweikamp
parents:
diff changeset
39 RD_L macro
heinrichsweikamp
parents:
diff changeset
40 bcf tft_rd,0
heinrichsweikamp
parents:
diff changeset
41 endm
heinrichsweikamp
parents:
diff changeset
42
heinrichsweikamp
parents:
diff changeset
43 RS_H macro
heinrichsweikamp
parents:
diff changeset
44 bsf tft_rs,0
heinrichsweikamp
parents:
diff changeset
45 endm
heinrichsweikamp
parents:
diff changeset
46
heinrichsweikamp
parents:
diff changeset
47 RS_L macro
heinrichsweikamp
parents:
diff changeset
48 bcf tft_rs,0
heinrichsweikamp
parents:
diff changeset
49 endm
heinrichsweikamp
parents:
diff changeset
50
heinrichsweikamp
parents:
diff changeset
51 NCS_H macro
heinrichsweikamp
parents:
diff changeset
52 bsf tft_cs,0
heinrichsweikamp
parents:
diff changeset
53 endm
heinrichsweikamp
parents:
diff changeset
54
heinrichsweikamp
parents:
diff changeset
55 NCS_L macro
heinrichsweikamp
parents:
diff changeset
56 bcf tft_cs,0
heinrichsweikamp
parents:
diff changeset
57 endm
heinrichsweikamp
parents:
diff changeset
58
heinrichsweikamp
parents:
diff changeset
59 WR_H macro
heinrichsweikamp
parents:
diff changeset
60 bsf tft_nwr,0
heinrichsweikamp
parents:
diff changeset
61 endm
heinrichsweikamp
parents:
diff changeset
62
heinrichsweikamp
parents:
diff changeset
63 WR_L macro
heinrichsweikamp
parents:
diff changeset
64 bcf tft_nwr,0
heinrichsweikamp
parents:
diff changeset
65 endm
heinrichsweikamp
parents:
diff changeset
66
heinrichsweikamp
parents:
diff changeset
67 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
68 ; Byte-leve macros
heinrichsweikamp
parents:
diff changeset
69 ;
heinrichsweikamp
parents:
diff changeset
70 Index_out macro low_b
heinrichsweikamp
parents:
diff changeset
71 movlw low_b
heinrichsweikamp
parents:
diff changeset
72 rcall TFT_CmdWrite
heinrichsweikamp
parents:
diff changeset
73 endm
heinrichsweikamp
parents:
diff changeset
74
heinrichsweikamp
parents:
diff changeset
75 Parameter_out macro high_b, low_b
heinrichsweikamp
parents:
diff changeset
76 movlw high_b
heinrichsweikamp
parents:
diff changeset
77 movwf PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
78 movlw low_b
heinrichsweikamp
parents:
diff changeset
79 rcall TFT_DataWrite
heinrichsweikamp
parents:
diff changeset
80 endm
heinrichsweikamp
parents:
diff changeset
81
heinrichsweikamp
parents:
diff changeset
82
heinrichsweikamp
parents:
diff changeset
83 basic CODE
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
84 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
85 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
86 ;;=============================================================================
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
87 ;; TFT_write_flash_image
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
88 ;;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
89 ;; Inputs: FSR2 = EEPROM address / 256
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
90 ;; win_left, win_top : imagte CENTER position
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
91 ;; Outputs: win_height, win_width.
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
92 ;; image copyed on screen.
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
93 ;; Trashed: PROD, hi, lo
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
94 ;;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
95 ; global TFT_write_flash_image
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
96 ;TFT_write_flash_image:
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
97 ; ; Get back the full 24bit EEPROM address
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
98 ; clrf ext_flash_address+0
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
99 ; movff FSR2L,ext_flash_address+1
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
100 ; movf FSR2H,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
101 ; iorlw 0x30
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
102 ; movwf ext_flash_address+2
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
103 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
104 ; ; Read header: width and height
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
105 ; global TFT_write_flash_image_addr
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
106 ;TFT_write_flash_image_addr:
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
107 ; call ext_flash_read_block_start
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
108 ; movff SSP2BUF,win_width+0
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
109 ; movwf SSP2BUF ; Write to buffer to initiate new read
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
110 ; btfss SSP2STAT, BF ; Next byte ready ?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
111 ; bra $-2 ; NO: wait...
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
112 ; movff SSP2BUF,win_width+1
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
113 ; movwf SSP2BUF ; Write to buffer to initiate new read
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
114 ; btfss SSP2STAT, BF ; Next byte ready ?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
115 ; bra $-2 ; NO: wait...
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
116 ; movff SSP2BUF,win_height
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
117 ; movwf SSP2BUF ; Write to buffer to initiate new read
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
118 ; btfss SSP2STAT, BF ; Next byte ready ?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
119 ; bra $-2 ; NO: wait...
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
120 ; movff SSP2BUF,WREG ; drop 4th byte.
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
121 ; movwf SSP2BUF ; Write to buffer to initiate new read
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
122 ; btfss SSP2STAT, BF ; Next byte ready ?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
123 ; bra $-2 ; NO: wait...
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
124 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
125 ; ; Sanity check on header to avoid badly uploaded images.
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
126 ; iorwf WREG ; Check height < 256
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
127 ; bnz TFT_write_flash_image_failed
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
128 ; movf win_width+1,W ; Check width < 512
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
129 ; andlw 0xFE
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
130 ; bnz TFT_write_flash_image_failed
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
131 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
132 ; ; Center image on win_top, win_left values
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
133 ; bcf STATUS,C ; Clear carry
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
134 ; rrcf win_height,W ; And get height/2
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
135 ; subwf win_top,F ; top -= height/2
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
136 ; rrcf win_width+1,W ; Get 9th bit into carry
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
137 ; rrcf win_width+0,W ; Get width/2 (in 0..320 range)
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
138 ; bcf STATUS,C
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
139 ; rrcf WREG,W ; Get width/2 in 0..160 range
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
140 ; subwf win_leftx2,F ; left -= width/2
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
141 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
142 ; rcall TFT_box_write ; Inputs : win_top, win_leftx2, win_height, win_width(in 1..320 range)
0
heinrichsweikamp
parents:
diff changeset
143 ;
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
144 ; ; Compute number of pixels to move (result on 17 bits !)
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
145 ; clrf TBLPTRU
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
146 ; movf win_width+0,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
147 ; mulwf win_height ; Result in PRODL:H
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
148 ; movf win_width+1,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
149 ; bz TFT_write_flash_image_1 ; width > 8bits ?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
150 ; movf win_height,W ; YES: add extra
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
151 ; addwf PRODH,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
152 ; rlcf TBLPTRU ; And carry into upper register.
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
153 ;TFT_write_flash_image_1:
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
154 ; incf PRODH,F ; Pre-condition nested loops
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
155 ; incf TBLPTRU,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
156 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
157 ; ; Write pixels
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
158 ; Index_out 0x22 ; Frame Memory Data Write start
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
159 ; RS_H ; Data
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
160 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
161 ;TFT_write_flash_image_loop:
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
162 ; btfss SSP2STAT, BF ; Buffer full?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
163 ; bra $-2 ; NO: wait...
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
164 ; movff SSP2BUF,PORTH ; Read lo
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
165 ; movwf SSP2BUF ; Write to buffer to initiate new read
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
166 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
167 ; btfss SSP2STAT, BF ; Buffer full?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
168 ; bra $-2 ; NO: wait...
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
169 ; movff SSP2BUF,PORTA ; And read hi
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
170 ; movwf SSP2BUF ; Write to buffer to initiate new read
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
171 ; WR_L
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
172 ; WR_H ; Write 1 Pixel
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
173 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
174 ; decfsz PRODL,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
175 ; bra TFT_write_flash_image_loop
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
176 ; decfsz PRODH,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
177 ; bra TFT_write_flash_image_loop
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
178 ; decfsz TBLPTRU,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
179 ; bra TFT_write_flash_image_loop
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
180 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
181 ; btfss SSP2STAT, BF ; Buffer full?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
182 ; bra $-2 ; No, wait
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
183 ; movf SSP2BUF,W ; Read dummy byte
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
184 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
185 ; bsf flash_ncs ; CS=1
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
186 ; movlw 0x00 ; NOP, to stop window mode
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
187 ; bra TFT_CmdWrite ; This routine "returns"
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
188 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
189 ; ;---- Draw a 4x4 red square in place of missing images...
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
190 ;TFT_write_flash_image_failed:
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
191 ; movlw -1
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
192 ; addwf win_leftx2,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
193 ; movlw -2
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
194 ; addwf win_top,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
195 ; movlw 2
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
196 ; movwf win_width+0
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
197 ; clrf win_width+1
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
198 ; movlw 4
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
199 ; movwf win_height
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
200 ; movlw color_red
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
201 ; rcall TFT_set_color
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
202 ; goto TFT_box
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
203 ;
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
204 ;;=============================================================================
0
heinrichsweikamp
parents:
diff changeset
205 ;
heinrichsweikamp
parents:
diff changeset
206
heinrichsweikamp
parents:
diff changeset
207 global TFT_CmdWrite
heinrichsweikamp
parents:
diff changeset
208 TFT_CmdWrite:
heinrichsweikamp
parents:
diff changeset
209 RS_L ; Command
heinrichsweikamp
parents:
diff changeset
210 clrf PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
211 movwf PORTH ; Lower
heinrichsweikamp
parents:
diff changeset
212 WR_L
heinrichsweikamp
parents:
diff changeset
213 WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
214 return;
heinrichsweikamp
parents:
diff changeset
215
heinrichsweikamp
parents:
diff changeset
216 global TFT_DataWrite
heinrichsweikamp
parents:
diff changeset
217 TFT_DataWrite:
heinrichsweikamp
parents:
diff changeset
218 RS_H ; Data
heinrichsweikamp
parents:
diff changeset
219 movwf PORTH ; Lower
heinrichsweikamp
parents:
diff changeset
220 WR_L
heinrichsweikamp
parents:
diff changeset
221 WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
222 return
heinrichsweikamp
parents:
diff changeset
223
heinrichsweikamp
parents:
diff changeset
224 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
225 ;
heinrichsweikamp
parents:
diff changeset
226 global TFT_ClearScreen
heinrichsweikamp
parents:
diff changeset
227 TFT_ClearScreen:
heinrichsweikamp
parents:
diff changeset
228 Index_out 0x50 ; Window Horizontal Start Address
heinrichsweikamp
parents:
diff changeset
229 Parameter_out 0x00, 0x00 ; 0-239
heinrichsweikamp
parents:
diff changeset
230 Index_out 0x51 ; Window Horizontal End Address
heinrichsweikamp
parents:
diff changeset
231 Parameter_out 0x00, 0xEF ; 0-239
heinrichsweikamp
parents:
diff changeset
232 Index_out 0x52 ; Window Vertical Start Address
heinrichsweikamp
parents:
diff changeset
233 Parameter_out 0x00, 0x00 ; 0-319
heinrichsweikamp
parents:
diff changeset
234 Index_out 0x53 ; Window Vertical End Address
heinrichsweikamp
parents:
diff changeset
235 Parameter_out 0x01, 0x3F ; 0-319
heinrichsweikamp
parents:
diff changeset
236 Index_out 0x20 ; Frame Memory Horizontal Address
heinrichsweikamp
parents:
diff changeset
237 Parameter_out 0x00, 0x00 ; 0-239
heinrichsweikamp
parents:
diff changeset
238 Index_out 0x21 ; Frame Memory Vertical Address
heinrichsweikamp
parents:
diff changeset
239 Parameter_out 0x01, 0x3F ; 0-319
heinrichsweikamp
parents:
diff changeset
240
heinrichsweikamp
parents:
diff changeset
241 Index_out 0x22 ; Frame Memory Data Write start
heinrichsweikamp
parents:
diff changeset
242
heinrichsweikamp
parents:
diff changeset
243 RD_H ; Not Read
heinrichsweikamp
parents:
diff changeset
244 RS_H ; Data
heinrichsweikamp
parents:
diff changeset
245 NCS_L ; Not CS
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
246 ; clrf PORTA ; Data Upper
0
heinrichsweikamp
parents:
diff changeset
247 clrf PORTH ; Data Lower
heinrichsweikamp
parents:
diff changeset
248
heinrichsweikamp
parents:
diff changeset
249 movlw d'10'
heinrichsweikamp
parents:
diff changeset
250 movwf tft_temp3
heinrichsweikamp
parents:
diff changeset
251 TFT_ClearScreen2:
heinrichsweikamp
parents:
diff changeset
252 movlw d'30'
heinrichsweikamp
parents:
diff changeset
253 movwf tft_temp2
heinrichsweikamp
parents:
diff changeset
254 TFT_ClearScreen3:
heinrichsweikamp
parents:
diff changeset
255 clrf tft_temp1 ; 30*10*256=76800 Pixels -> Clear complete 240*320
heinrichsweikamp
parents:
diff changeset
256 TFT_ClearScreen4:
heinrichsweikamp
parents:
diff changeset
257 WR_L
heinrichsweikamp
parents:
diff changeset
258 WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
259 decfsz tft_temp1,F
heinrichsweikamp
parents:
diff changeset
260 bra TFT_ClearScreen4
heinrichsweikamp
parents:
diff changeset
261 decfsz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
262 bra TFT_ClearScreen3
heinrichsweikamp
parents:
diff changeset
263 decfsz tft_temp3,F
heinrichsweikamp
parents:
diff changeset
264 bra TFT_ClearScreen2
heinrichsweikamp
parents:
diff changeset
265 return
heinrichsweikamp
parents:
diff changeset
266
heinrichsweikamp
parents:
diff changeset
267 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
268 ;
heinrichsweikamp
parents:
diff changeset
269 global TFT_DisplayOff
heinrichsweikamp
parents:
diff changeset
270 TFT_DisplayOff:
heinrichsweikamp
parents:
diff changeset
271 clrf CCPR1L ; PWM OFF
heinrichsweikamp
parents:
diff changeset
272 clrf PORTA
heinrichsweikamp
parents:
diff changeset
273 clrf PORTH
heinrichsweikamp
parents:
diff changeset
274 RD_L ; LOW
heinrichsweikamp
parents:
diff changeset
275 nop
heinrichsweikamp
parents:
diff changeset
276 RS_L ; LOW
heinrichsweikamp
parents:
diff changeset
277 bcf tft_nwr
heinrichsweikamp
parents:
diff changeset
278 nop
heinrichsweikamp
parents:
diff changeset
279 bcf tft_cs
heinrichsweikamp
parents:
diff changeset
280 nop
heinrichsweikamp
parents:
diff changeset
281 bcf tft_nreset
heinrichsweikamp
parents:
diff changeset
282 WAITMS d'1'
heinrichsweikamp
parents:
diff changeset
283 bsf tft_power ; inverted...
heinrichsweikamp
parents:
diff changeset
284 bcf lightsen_power ; power-down light sensor
heinrichsweikamp
parents:
diff changeset
285 return
heinrichsweikamp
parents:
diff changeset
286
heinrichsweikamp
parents:
diff changeset
287 ; -----------------------------
heinrichsweikamp
parents:
diff changeset
288 ; TFT boot
heinrichsweikamp
parents:
diff changeset
289 ; -----------------------------
heinrichsweikamp
parents:
diff changeset
290 global TFT_boot
heinrichsweikamp
parents:
diff changeset
291 TFT_boot:
heinrichsweikamp
parents:
diff changeset
292 clrf PORTA
heinrichsweikamp
parents:
diff changeset
293 clrf PORTH
heinrichsweikamp
parents:
diff changeset
294 RD_L ; LOW
heinrichsweikamp
parents:
diff changeset
295 bcf tft_nwr
heinrichsweikamp
parents:
diff changeset
296 nop
heinrichsweikamp
parents:
diff changeset
297 bcf tft_cs
heinrichsweikamp
parents:
diff changeset
298 nop
heinrichsweikamp
parents:
diff changeset
299 bcf tft_nreset
heinrichsweikamp
parents:
diff changeset
300 WAITMS d'1'
heinrichsweikamp
parents:
diff changeset
301 bcf tft_power ; inverted...
heinrichsweikamp
parents:
diff changeset
302 WAITMS d'1'
heinrichsweikamp
parents:
diff changeset
303
heinrichsweikamp
parents:
diff changeset
304 RD_H ; Keep high
heinrichsweikamp
parents:
diff changeset
305 WR_H ;
heinrichsweikamp
parents:
diff changeset
306 NCS_L ; Not CS
heinrichsweikamp
parents:
diff changeset
307
heinrichsweikamp
parents:
diff changeset
308 WAITMS d'2'
heinrichsweikamp
parents:
diff changeset
309 bsf tft_nreset
heinrichsweikamp
parents:
diff changeset
310 WAITMS d'150'
heinrichsweikamp
parents:
diff changeset
311 bsf lightsen_power ; Supply power to light sensor
heinrichsweikamp
parents:
diff changeset
312
heinrichsweikamp
parents:
diff changeset
313 ; Data Transfer Synchronization
heinrichsweikamp
parents:
diff changeset
314 Parameter_out 0x00, 0x00
heinrichsweikamp
parents:
diff changeset
315 Parameter_out 0x00, 0x00
heinrichsweikamp
parents:
diff changeset
316
heinrichsweikamp
parents:
diff changeset
317 ; Init through config table...
heinrichsweikamp
parents:
diff changeset
318 movlw LOW display0_config_table
heinrichsweikamp
parents:
diff changeset
319 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
320 movlw HIGH display0_config_table
heinrichsweikamp
parents:
diff changeset
321 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
322 movlw UPPER display0_config_table
heinrichsweikamp
parents:
diff changeset
323 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
324 rcall display0_init_loop
heinrichsweikamp
parents:
diff changeset
325
heinrichsweikamp
parents:
diff changeset
326 Index_out 0x22
heinrichsweikamp
parents:
diff changeset
327 ; WAITMS d'81' ; 46
heinrichsweikamp
parents:
diff changeset
328 call TFT_ClearScreen
heinrichsweikamp
parents:
diff changeset
329 Index_out 0x07
heinrichsweikamp
parents:
diff changeset
330 Parameter_out 0x01, 0x00
heinrichsweikamp
parents:
diff changeset
331 return
heinrichsweikamp
parents:
diff changeset
332
heinrichsweikamp
parents:
diff changeset
333
heinrichsweikamp
parents:
diff changeset
334 display0_config_table:
heinrichsweikamp
parents:
diff changeset
335 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end
heinrichsweikamp
parents:
diff changeset
336 db 0xA4,0x00,0x01,0xFF,.002,0x00
heinrichsweikamp
parents:
diff changeset
337 db 0x09,0x00,0x01,0x92,0x04,0x00
heinrichsweikamp
parents:
diff changeset
338 db 0x93,0x04,0x02,0x94,0x00,0x02
heinrichsweikamp
parents:
diff changeset
339 db 0x07,0x00,0x00,0x10,0x04,0x30
heinrichsweikamp
parents:
diff changeset
340 db 0x11,0x02,0x37,0x12,0x11,0x8D
heinrichsweikamp
parents:
diff changeset
341 db 0x13,0x11,0x00,0x01,0x01,0x00
heinrichsweikamp
parents:
diff changeset
342 db 0x02,0x02,0x00,0x03,0x50,0x20
heinrichsweikamp
parents:
diff changeset
343 db 0x0A,0x00,0x08,0x0D,0x00,0x00
heinrichsweikamp
parents:
diff changeset
344 db 0x0E,0x00,0x30,0xFF,.151,0x00
heinrichsweikamp
parents:
diff changeset
345 db 0x12,0x11,0xBD,0x20,0x00,0x00
heinrichsweikamp
parents:
diff changeset
346 db 0x21,0x00,0x00,0x30,0x06,0x02
heinrichsweikamp
parents:
diff changeset
347 db 0x31,0x56,0x0D,0x32,0x05,0x07
heinrichsweikamp
parents:
diff changeset
348 db 0x33,0x06,0x09,0x34,0x00,0x00
heinrichsweikamp
parents:
diff changeset
349 db 0x35,0x09,0x06,0x36,0x57,0x05
heinrichsweikamp
parents:
diff changeset
350 db 0x37,0x0D,0x06,0x38,0x02,0x06
heinrichsweikamp
parents:
diff changeset
351 db 0x39,0x00,0x00,0xFF,0x00,0x00
heinrichsweikamp
parents:
diff changeset
352
heinrichsweikamp
parents:
diff changeset
353 display0_init_loop:
heinrichsweikamp
parents:
diff changeset
354 TBLRD*+
heinrichsweikamp
parents:
diff changeset
355 movlw 0xFF
heinrichsweikamp
parents:
diff changeset
356 cpfseq TABLAT
heinrichsweikamp
parents:
diff changeset
357 bra display0_config_write ; Write Config pair to Display
heinrichsweikamp
parents:
diff changeset
358 ; Delay ms or quit (return)
heinrichsweikamp
parents:
diff changeset
359 TBLRD*+
heinrichsweikamp
parents:
diff changeset
360 tstfsz TABLAT ; End of config?
heinrichsweikamp
parents:
diff changeset
361 bra $+4 ; No
heinrichsweikamp
parents:
diff changeset
362 return ; Done.
heinrichsweikamp
parents:
diff changeset
363 movf TABLAT,W
heinrichsweikamp
parents:
diff changeset
364 call WAITMSX ; Wait WREG milliseconds
heinrichsweikamp
parents:
diff changeset
365 TBLRD*+ ; Dummy read (Third byte of delay command)
heinrichsweikamp
parents:
diff changeset
366 bra display0_init_loop ; Loop
heinrichsweikamp
parents:
diff changeset
367
heinrichsweikamp
parents:
diff changeset
368 display0_config_write: ; With command in WREG
heinrichsweikamp
parents:
diff changeset
369 movf TABLAT,W
heinrichsweikamp
parents:
diff changeset
370 rcall TFT_CmdWrite ; Write command
heinrichsweikamp
parents:
diff changeset
371 TBLRD*+ ; Get config0
heinrichsweikamp
parents:
diff changeset
372 movff TABLAT,PORTA
heinrichsweikamp
parents:
diff changeset
373 TBLRD*+ ; Get config1
heinrichsweikamp
parents:
diff changeset
374 movf TABLAT,W
heinrichsweikamp
parents:
diff changeset
375 rcall TFT_DataWrite ; Write config
heinrichsweikamp
parents:
diff changeset
376 bra display0_init_loop ; Loop
heinrichsweikamp
parents:
diff changeset
377
heinrichsweikamp
parents:
diff changeset
378
heinrichsweikamp
parents:
diff changeset
379 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
380 ; Smooth lighting-up of the display:
heinrichsweikamp
parents:
diff changeset
381 ;
heinrichsweikamp
parents:
diff changeset
382 ; Trashes: WREG, PRODL
heinrichsweikamp
parents:
diff changeset
383 ; Typical usage:
heinrichsweikamp
parents:
diff changeset
384 ; clrf CCPR1L ; Backlight off
heinrichsweikamp
parents:
diff changeset
385 ; [draw splash screen]
heinrichsweikamp
parents:
diff changeset
386 ; call TFT_DisplayFadeIn
heinrichsweikamp
parents:
diff changeset
387 ;
heinrichsweikamp
parents:
diff changeset
388 global TFT_Display_FadeIn
heinrichsweikamp
parents:
diff changeset
389 TFT_Display_FadeIn:
heinrichsweikamp
parents:
diff changeset
390 movlw CCP1CON_VALUE ; See ostc3.inc
heinrichsweikamp
parents:
diff changeset
391 movwf CCP1CON
heinrichsweikamp
parents:
diff changeset
392 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor!
heinrichsweikamp
parents:
diff changeset
393 clrf CCPR1L ; Backlight off - to be sure
heinrichsweikamp
parents:
diff changeset
394 movff max_CCPR1L,PRODL
heinrichsweikamp
parents:
diff changeset
395 TFT_Display_FadeIn_0:
heinrichsweikamp
parents:
diff changeset
396 incf CCPR1L,F ; Duty cycle
heinrichsweikamp
parents:
diff changeset
397 WAITMS d'2'
heinrichsweikamp
parents:
diff changeset
398 decfsz PRODL,F
heinrichsweikamp
parents:
diff changeset
399 bra TFT_Display_FadeIn_0
heinrichsweikamp
parents:
diff changeset
400 bcf tft_is_dimming ; dimming done.
heinrichsweikamp
parents:
diff changeset
401 return
heinrichsweikamp
parents:
diff changeset
402
heinrichsweikamp
parents:
diff changeset
403 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
404 ; Smooth lighting-off of the display:
heinrichsweikamp
parents:
diff changeset
405 ; Trashes: WREG, PRODL
heinrichsweikamp
parents:
diff changeset
406 global TFT_Display_FadeOut
heinrichsweikamp
parents:
diff changeset
407 TFT_Display_FadeOut:
heinrichsweikamp
parents:
diff changeset
408 movff max_CCPR1L,PRODL
heinrichsweikamp
parents:
diff changeset
409 bsf tft_is_dimming ; TFT is dimming, ignore ambient sensor!
heinrichsweikamp
parents:
diff changeset
410 TFT_Display_FadeOut_0:
heinrichsweikamp
parents:
diff changeset
411 movff PRODL,CCPR1L ; Duty cycle
heinrichsweikamp
parents:
diff changeset
412 WAITMS d'1'
heinrichsweikamp
parents:
diff changeset
413 decfsz PRODL,F
heinrichsweikamp
parents:
diff changeset
414 bra TFT_Display_FadeOut_0
heinrichsweikamp
parents:
diff changeset
415 clrf CCPR1L
heinrichsweikamp
parents:
diff changeset
416 return
heinrichsweikamp
parents:
diff changeset
417
heinrichsweikamp
parents:
diff changeset
418 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
419
heinrichsweikamp
parents:
diff changeset
420 global box_std_block, box_black_block, box_color_block
heinrichsweikamp
parents:
diff changeset
421
heinrichsweikamp
parents:
diff changeset
422 box_std_block: ; Use white color
heinrichsweikamp
parents:
diff changeset
423 setf WREG
heinrichsweikamp
parents:
diff changeset
424 bra box_common
heinrichsweikamp
parents:
diff changeset
425 box_black_block: ; Use black color
heinrichsweikamp
parents:
diff changeset
426 clrf WREG
heinrichsweikamp
parents:
diff changeset
427 box_common:
heinrichsweikamp
parents:
diff changeset
428 box_color_block:
heinrichsweikamp
parents:
diff changeset
429 rcall TFT_set_color
heinrichsweikamp
parents:
diff changeset
430 VARARGS_BEGIN
heinrichsweikamp
parents:
diff changeset
431 VARARGS_GET8 win_top
heinrichsweikamp
parents:
diff changeset
432 VARARGS_GET8 win_height
heinrichsweikamp
parents:
diff changeset
433 VARARGS_GET8 win_leftx2
heinrichsweikamp
parents:
diff changeset
434 VARARGS_GET8 win_width
heinrichsweikamp
parents:
diff changeset
435 VARARGS_END
heinrichsweikamp
parents:
diff changeset
436 bra TFT_box
heinrichsweikamp
parents:
diff changeset
437
heinrichsweikamp
parents:
diff changeset
438 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
439
heinrichsweikamp
parents:
diff changeset
440 global box_frame_std, box_frame_common, box_frame_color, box_frame_color16
heinrichsweikamp
parents:
diff changeset
441
heinrichsweikamp
parents:
diff changeset
442 box_frame_std:
heinrichsweikamp
parents:
diff changeset
443 setf WREG
heinrichsweikamp
parents:
diff changeset
444 rcall TFT_set_color
heinrichsweikamp
parents:
diff changeset
445
heinrichsweikamp
parents:
diff changeset
446 box_frame_common:
heinrichsweikamp
parents:
diff changeset
447 VARARGS_BEGIN
heinrichsweikamp
parents:
diff changeset
448 VARARGS_GET8 win_top
heinrichsweikamp
parents:
diff changeset
449 VARARGS_GET8 win_height
heinrichsweikamp
parents:
diff changeset
450 VARARGS_GET8 win_leftx2
heinrichsweikamp
parents:
diff changeset
451 VARARGS_GET8 win_width
heinrichsweikamp
parents:
diff changeset
452 VARARGS_END
heinrichsweikamp
parents:
diff changeset
453 bra TFT_frame
heinrichsweikamp
parents:
diff changeset
454
heinrichsweikamp
parents:
diff changeset
455 box_frame_color:
heinrichsweikamp
parents:
diff changeset
456 rcall TFT_set_color
heinrichsweikamp
parents:
diff changeset
457 box_frame_color16:
heinrichsweikamp
parents:
diff changeset
458 bra box_frame_common
heinrichsweikamp
parents:
diff changeset
459
heinrichsweikamp
parents:
diff changeset
460 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
461 ; Init for half_pixel_write
heinrichsweikamp
parents:
diff changeset
462 ; Set column register on TFT device, and current color.
heinrichsweikamp
parents:
diff changeset
463 ; Inputs: win_leftx2
heinrichsweikamp
parents:
diff changeset
464 ; Outputs: win_color:2
heinrichsweikamp
parents:
diff changeset
465 ; Trashed: WREG, PROD
heinrichsweikamp
parents:
diff changeset
466 global init_pixel_write
heinrichsweikamp
parents:
diff changeset
467 init_pixel_write:
heinrichsweikamp
parents:
diff changeset
468 movff win_leftx2,WREG
heinrichsweikamp
parents:
diff changeset
469 mullw 2
heinrichsweikamp
parents:
diff changeset
470 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
heinrichsweikamp
parents:
diff changeset
471 setf WREG
heinrichsweikamp
parents:
diff changeset
472 bra TFT_set_color
heinrichsweikamp
parents:
diff changeset
473
heinrichsweikamp
parents:
diff changeset
474 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
475 ; Writes two half-pixels at position (win_top,win_leftx2)
heinrichsweikamp
parents:
diff changeset
476 ; Inputs: win_leftx2, win_top, win_color:2
heinrichsweikamp
parents:
diff changeset
477 ; Trashed: WREG, PROD
heinrichsweikamp
parents:
diff changeset
478 global pixel_write
heinrichsweikamp
parents:
diff changeset
479 pixel_write:
heinrichsweikamp
parents:
diff changeset
480 movff win_leftx2,WREG
heinrichsweikamp
parents:
diff changeset
481 mullw 2 ; win_leftx2 x 2 -> PRODH:PRODL
heinrichsweikamp
parents:
diff changeset
482 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
heinrichsweikamp
parents:
diff changeset
483 rcall half_pixel_write ; Write this half-one.
heinrichsweikamp
parents:
diff changeset
484
heinrichsweikamp
parents:
diff changeset
485 movff win_leftx2,WREG ; Address of next one
heinrichsweikamp
parents:
diff changeset
486 mullw 2
heinrichsweikamp
parents:
diff changeset
487 infsnz PRODL ; +1
heinrichsweikamp
parents:
diff changeset
488 incf PRODH
heinrichsweikamp
parents:
diff changeset
489 rcall pixel_write_col320
heinrichsweikamp
parents:
diff changeset
490 bra half_pixel_write ; Note: Cmd 0x20 is mandatory, because
heinrichsweikamp
parents:
diff changeset
491 ; of the autoincrement going vertical
heinrichsweikamp
parents:
diff changeset
492
heinrichsweikamp
parents:
diff changeset
493 global pixel_write_col320
heinrichsweikamp
parents:
diff changeset
494 pixel_write_col320:
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
495 btfss flip_screen ; 180° rotation?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
496 bra pixel_write_noflip_H ; No
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
497
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
498 movf PRODL,W ; 16bits 319 - PROD --> PROD
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
499 sublw LOW(.319) ; 319-W --> W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
500 movwf PRODL
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
501 movf PRODH,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
502 btfss STATUS,C ; Borrow = /CARRY
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
503 incf WREG
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
504 sublw HIGH(.319)
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
505 movwf PRODH
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
506
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
507 pixel_write_noflip_H:
0
heinrichsweikamp
parents:
diff changeset
508 Index_out 0x21 ; Frame Memory Vertical Address
heinrichsweikamp
parents:
diff changeset
509 bra TFT_DataWrite_PROD
heinrichsweikamp
parents:
diff changeset
510
heinrichsweikamp
parents:
diff changeset
511 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
512 ; Writes one half-pixel at position (win_top,win_leftx2).
heinrichsweikamp
parents:
diff changeset
513 ; Inputs: win_leftx2, win_top, win_color:2
heinrichsweikamp
parents:
diff changeset
514 ; Trashed: WREG, PROD
heinrichsweikamp
parents:
diff changeset
515 global half_pixel_write
heinrichsweikamp
parents:
diff changeset
516 half_pixel_write:
heinrichsweikamp
parents:
diff changeset
517 movff win_top,WREG ; d'0' ... d'239'
heinrichsweikamp
parents:
diff changeset
518 ; Variant with Y position in WREG.
heinrichsweikamp
parents:
diff changeset
519 half_pixel_write_1:
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
520 btfss flip_screen ; 180° rotation?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
521 sublw .239 ; 239-Y --> Y
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
522 mullw 1 ; Copy row to PRODL (PRODH=0)
0
heinrichsweikamp
parents:
diff changeset
523
heinrichsweikamp
parents:
diff changeset
524 Index_out 0x20 ; Frame Memory Horizontal Address
heinrichsweikamp
parents:
diff changeset
525 rcall TFT_DataWrite_PROD
heinrichsweikamp
parents:
diff changeset
526
heinrichsweikamp
parents:
diff changeset
527 Index_out 0x22 ; Frame Memory Data Write start
heinrichsweikamp
parents:
diff changeset
528 RS_H ; Data
heinrichsweikamp
parents:
diff changeset
529 movff win_color1,PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
530 movff win_color2,PORTH ; Lower
heinrichsweikamp
parents:
diff changeset
531 WR_L
heinrichsweikamp
parents:
diff changeset
532 WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
533 return
heinrichsweikamp
parents:
diff changeset
534
heinrichsweikamp
parents:
diff changeset
535 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
536 ; Writes a vertical line of half-pixel at position (win_top,win_leftx2,win_height).
heinrichsweikamp
parents:
diff changeset
537 ; Inputs: win_leftx2, win_top, win_height, win_color:2
heinrichsweikamp
parents:
diff changeset
538 ; Trashed: WREG, PROD, TABLAT, TBLPTRL
heinrichsweikamp
parents:
diff changeset
539 global half_vertical_line
heinrichsweikamp
parents:
diff changeset
540 half_vertical_line:
heinrichsweikamp
parents:
diff changeset
541 clrf TABLAT ; Loop index.
heinrichsweikamp
parents:
diff changeset
542
heinrichsweikamp
parents:
diff changeset
543 half_vertical_line_loop:
heinrichsweikamp
parents:
diff changeset
544 movff win_leftx2,WREG ; Init X position.
heinrichsweikamp
parents:
diff changeset
545 mullw 2
heinrichsweikamp
parents:
diff changeset
546 movf TABLAT,W ; Get loop index
heinrichsweikamp
parents:
diff changeset
547 andlw 1 ; Just low bit
heinrichsweikamp
parents:
diff changeset
548 xorwf PRODL,F ; And use it to jitter current X position
heinrichsweikamp
parents:
diff changeset
549 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
heinrichsweikamp
parents:
diff changeset
550
heinrichsweikamp
parents:
diff changeset
551 movff win_height,WREG ; Index reached height (Bank0 read) ?
heinrichsweikamp
parents:
diff changeset
552 xorwf TABLAT,W
heinrichsweikamp
parents:
diff changeset
553 btfsc STATUS,Z ; Equals ?
heinrichsweikamp
parents:
diff changeset
554 return ; Yes: done.
heinrichsweikamp
parents:
diff changeset
555 movff win_top,WREG ; Y = top + index (Bank0 read)
heinrichsweikamp
parents:
diff changeset
556 addwf TABLAT,W
heinrichsweikamp
parents:
diff changeset
557 rcall half_pixel_write_1
heinrichsweikamp
parents:
diff changeset
558 incf TABLAT,F ; index++
heinrichsweikamp
parents:
diff changeset
559 bra half_vertical_line_loop
heinrichsweikamp
parents:
diff changeset
560
heinrichsweikamp
parents:
diff changeset
561 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
562 ; Writes a horizontal line of half-pixel at position (win_top,win_leftx2,win_width).
heinrichsweikamp
parents:
diff changeset
563 ; Inputs: win_leftx2, win_top, win_width, win_color:2
heinrichsweikamp
parents:
diff changeset
564 ; Trashed: WREG, PROD, TABLAT, TBLPTRL
heinrichsweikamp
parents:
diff changeset
565 global half_horizontal_line
heinrichsweikamp
parents:
diff changeset
566 half_horizontal_line:
heinrichsweikamp
parents:
diff changeset
567 clrf TABLAT ; Loop index.
heinrichsweikamp
parents:
diff changeset
568
heinrichsweikamp
parents:
diff changeset
569 half_horizontal_line_loop:
heinrichsweikamp
parents:
diff changeset
570 movff win_leftx2,WREG ; Init X position.
heinrichsweikamp
parents:
diff changeset
571 mullw 2
heinrichsweikamp
parents:
diff changeset
572 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
heinrichsweikamp
parents:
diff changeset
573 movff win_width,WREG ; Index reached height (Bank0 read) ?
heinrichsweikamp
parents:
diff changeset
574 xorwf TABLAT,W
heinrichsweikamp
parents:
diff changeset
575 btfsc STATUS,Z ; Equals ?
heinrichsweikamp
parents:
diff changeset
576 return ; Yes: done.
heinrichsweikamp
parents:
diff changeset
577 movff win_top,WREG ; Y = top + index (Bank0 read)
heinrichsweikamp
parents:
diff changeset
578 addwf TABLAT,W
heinrichsweikamp
parents:
diff changeset
579 rcall half_pixel_write_1
heinrichsweikamp
parents:
diff changeset
580 incf TABLAT,F ; index++
heinrichsweikamp
parents:
diff changeset
581 bra half_horizontal_line_loop
heinrichsweikamp
parents:
diff changeset
582
heinrichsweikamp
parents:
diff changeset
583
heinrichsweikamp
parents:
diff changeset
584 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
585 ; TFT Data Cmd via W
heinrichsweikamp
parents:
diff changeset
586 ;
heinrichsweikamp
parents:
diff changeset
587 global TFT_DataWrite_PROD
heinrichsweikamp
parents:
diff changeset
588 TFT_DataWrite_PROD:
heinrichsweikamp
parents:
diff changeset
589 ; RD_H ; Keep high
heinrichsweikamp
parents:
diff changeset
590 RS_H ; Data
heinrichsweikamp
parents:
diff changeset
591 movff PRODH,PORTA ; Move high byte to PORTA
heinrichsweikamp
parents:
diff changeset
592 movff PRODL,PORTH ; Move low byte to PORTH
heinrichsweikamp
parents:
diff changeset
593 WR_L
heinrichsweikamp
parents:
diff changeset
594 WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
595 return
heinrichsweikamp
parents:
diff changeset
596
heinrichsweikamp
parents:
diff changeset
597 TFT_DataRead_PROD:
heinrichsweikamp
parents:
diff changeset
598 Index_out 0x22 ; Frame Memory Data Read start
heinrichsweikamp
parents:
diff changeset
599 setf TRISA ; PortA as input.
heinrichsweikamp
parents:
diff changeset
600 setf TRISH ; PortH as input.
heinrichsweikamp
parents:
diff changeset
601 RS_H ; Data
heinrichsweikamp
parents:
diff changeset
602 WR_H ; Not write
heinrichsweikamp
parents:
diff changeset
603 RD_L ; Read!
heinrichsweikamp
parents:
diff changeset
604 nop
heinrichsweikamp
parents:
diff changeset
605 nop
heinrichsweikamp
parents:
diff changeset
606 nop
heinrichsweikamp
parents:
diff changeset
607 RD_H ; Tick
heinrichsweikamp
parents:
diff changeset
608 nop
heinrichsweikamp
parents:
diff changeset
609 RD_L ; Read!
heinrichsweikamp
parents:
diff changeset
610 nop
heinrichsweikamp
parents:
diff changeset
611 nop
heinrichsweikamp
parents:
diff changeset
612 nop
heinrichsweikamp
parents:
diff changeset
613 movff PORTA,PRODH
heinrichsweikamp
parents:
diff changeset
614 movff PORTH,PRODL
heinrichsweikamp
parents:
diff changeset
615 RD_H ; Tick
heinrichsweikamp
parents:
diff changeset
616 nop
heinrichsweikamp
parents:
diff changeset
617 clrf TRISA ; PortA as output
heinrichsweikamp
parents:
diff changeset
618 clrf TRISH ; PortH as output
heinrichsweikamp
parents:
diff changeset
619 return
heinrichsweikamp
parents:
diff changeset
620
heinrichsweikamp
parents:
diff changeset
621
heinrichsweikamp
parents:
diff changeset
622
heinrichsweikamp
parents:
diff changeset
623 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
624 ; Output TFT Window Address commands.
heinrichsweikamp
parents:
diff changeset
625 ; Inputs : win_top, win_leftx2, win_height, win_width.
heinrichsweikamp
parents:
diff changeset
626 ; Output : PortA/PortH commands.
heinrichsweikamp
parents:
diff changeset
627 ; Trashed: PROD
heinrichsweikamp
parents:
diff changeset
628 ;
heinrichsweikamp
parents:
diff changeset
629 global TFT_box_write
heinrichsweikamp
parents:
diff changeset
630 TFT_box_write:
heinrichsweikamp
parents:
diff changeset
631 movff win_leftx2,WREG ; Compute left = 2*leftx2 --> PROD
heinrichsweikamp
parents:
diff changeset
632 mullw 2
heinrichsweikamp
parents:
diff changeset
633
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
634 btfsc flip_screen ; 180° rotation ?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
635 bra DISP_box_flip_H ; Yes
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
636
83
eb72c8865f47 Test with graphic compass
heinrichsweikamp
parents: 0
diff changeset
637 global TFT_box_write_16bit_win_left
eb72c8865f47 Test with graphic compass
heinrichsweikamp
parents: 0
diff changeset
638 TFT_box_write_16bit_win_left: ; With column in PRODL:PRODH
0
heinrichsweikamp
parents:
diff changeset
639 ;---- Normal horizontal window ---------------------------------------
heinrichsweikamp
parents:
diff changeset
640 ; Output 0x35 left,
heinrichsweikamp
parents:
diff changeset
641 ; 0x36 right == left + width - 1.
heinrichsweikamp
parents:
diff changeset
642
heinrichsweikamp
parents:
diff changeset
643 Index_out 0x52 ; Window Vertical Start Address
heinrichsweikamp
parents:
diff changeset
644 rcall TFT_DataWrite_PROD ; Output left
heinrichsweikamp
parents:
diff changeset
645 Index_out 0x21 ; Frame Memory Vertical Address
heinrichsweikamp
parents:
diff changeset
646 rcall TFT_DataWrite_PROD ; Output left
heinrichsweikamp
parents:
diff changeset
647
heinrichsweikamp
parents:
diff changeset
648 movff win_width+0,WREG ; right = left + width - 1
heinrichsweikamp
parents:
diff changeset
649 addwf PRODL,F
heinrichsweikamp
parents:
diff changeset
650 movff win_width+1,WREG
heinrichsweikamp
parents:
diff changeset
651 addwfc PRODH,F
heinrichsweikamp
parents:
diff changeset
652 decf PRODL,F ; decrement result
heinrichsweikamp
parents:
diff changeset
653 btfss STATUS,C
heinrichsweikamp
parents:
diff changeset
654 decf PRODH,F
heinrichsweikamp
parents:
diff changeset
655
heinrichsweikamp
parents:
diff changeset
656 Index_out 0x53 ; Window Vertical End Address
heinrichsweikamp
parents:
diff changeset
657 rcall TFT_DataWrite_PROD
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
658 bra DISP_box_noflip_H
0
heinrichsweikamp
parents:
diff changeset
659
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
660 ;---- Flipped horizontal window --------------------------------------
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
661 DISP_box_flip_H:
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
662 ; Output 0x36 flipped(left) = 319-left
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
663 ; 0x35 flipped(right) = 319-right = 320 - left - width
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
664 movf PRODL,W ; 16bits 319 - PROD --> PROD
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
665 sublw LOW(.319) ; 319-W --> W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
666 movwf PRODL
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
667 movf PRODH,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
668 btfss STATUS,C ; Borrow = /CARRY
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
669 incf WREG
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
670 sublw HIGH(.319)
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
671 movwf PRODH
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
672 Index_out 0x52 ; Window Vertical Start Address
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
673 rcall TFT_DataWrite_PROD ; Output left
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
674 Index_out 0x21 ; Frame Memory Vertical Address
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
675 rcall TFT_DataWrite_PROD ; Output left
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
676
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
677 movff win_width+0,WREG ; right = left + width - 1
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
678 addwf PRODL,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
679 movff win_width+1,WREG
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
680 addwfc PRODH,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
681 decf PRODL,F ; decrement result
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
682 btfss STATUS,C
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
683 decf PRODH,F
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
684
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
685 Index_out 0x53 ; Window Vertical End Address
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
686 rcall TFT_DataWrite_PROD
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
687
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
688 DISP_box_noflip_H:
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
689 btfss flip_screen ; 180° rotation ?
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
690 bra TFT_box_flip_V ; Yes.
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
691
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
692 ;---- Normal vertical window -----------------------------------------
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
693 movff win_top,PRODL ; Second byte
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
694 movff win_height,WREG
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
695 addwf PRODL,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
696 movwf PRODH ; First byte
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
697
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
698
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
699 Index_out 0x50 ; Window Horizontal Start Address
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
700 clrf PORTA ; Upper
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
701 movf PRODH,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
702 rcall TFT_DataWrite ; Lower (and tick)
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
703
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
704 Index_out 0x51 ; Window Horizontal End Address
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
705 clrf PORTA ; Upper
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
706 movf PRODL,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
707 rcall TFT_DataWrite ; Lower (and tick)
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
708
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
709 Index_out 0x20 ; Frame Memory Horizontal Address
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
710 clrf PORTA ; Upper
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
711 movf PRODL,W
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
712 rcall TFT_DataWrite ; Lower (and tick)
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
713 return
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
714
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
715
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
716 TFT_box_flip_V:
0
heinrichsweikamp
parents:
diff changeset
717 ;---- Flipped vertical window ----------------------------------------
heinrichsweikamp
parents:
diff changeset
718 ; Output 0x37 flipped(bottom) = 239-bottom = 240 - top - height
heinrichsweikamp
parents:
diff changeset
719 ; flipped(top) = 239-top
heinrichsweikamp
parents:
diff changeset
720 movff win_top,PRODL
heinrichsweikamp
parents:
diff changeset
721 movff win_height,WREG
heinrichsweikamp
parents:
diff changeset
722 addwf PRODL,W
heinrichsweikamp
parents:
diff changeset
723 sublw .240 ; 240 - top - height
heinrichsweikamp
parents:
diff changeset
724 movwf PRODH ; First byte
heinrichsweikamp
parents:
diff changeset
725
heinrichsweikamp
parents:
diff changeset
726 movf PRODL,W
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 125
diff changeset
727 sublw .239 ; 239-top
0
heinrichsweikamp
parents:
diff changeset
728 movwf PRODL ; --> second byte.
heinrichsweikamp
parents:
diff changeset
729
heinrichsweikamp
parents:
diff changeset
730 Index_out 0x50 ; Window Horizontal Start Address
heinrichsweikamp
parents:
diff changeset
731 clrf PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
732 movf PRODH,W
heinrichsweikamp
parents:
diff changeset
733 rcall TFT_DataWrite ; Lower (and tick)
heinrichsweikamp
parents:
diff changeset
734
heinrichsweikamp
parents:
diff changeset
735 Index_out 0x51 ; Window Horizontal End Address
heinrichsweikamp
parents:
diff changeset
736 clrf PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
737 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
738 rcall TFT_DataWrite ; Lower (and tick)
heinrichsweikamp
parents:
diff changeset
739
heinrichsweikamp
parents:
diff changeset
740 Index_out 0x20 ; Frame Memory Horizontal Address
heinrichsweikamp
parents:
diff changeset
741 clrf PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
742 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
743 rcall TFT_DataWrite ; Lower (and tick)
heinrichsweikamp
parents:
diff changeset
744 return
heinrichsweikamp
parents:
diff changeset
745
heinrichsweikamp
parents:
diff changeset
746
heinrichsweikamp
parents:
diff changeset
747 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
748 ; TFT_frame : draw a frame around current box with current color.
heinrichsweikamp
parents:
diff changeset
749 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
heinrichsweikamp
parents:
diff changeset
750 ; Outputs: (none)
heinrichsweikamp
parents:
diff changeset
751 ; Trashed: WREG, PROD, aa_start:2, aa_end:2
heinrichsweikamp
parents:
diff changeset
752 global TFT_frame
heinrichsweikamp
parents:
diff changeset
753 TFT_frame:
heinrichsweikamp
parents:
diff changeset
754 movff win_top,save_top ; Backup everything.
heinrichsweikamp
parents:
diff changeset
755 movff win_height,save_height
heinrichsweikamp
parents:
diff changeset
756 movff win_leftx2,save_left
heinrichsweikamp
parents:
diff changeset
757 movff win_width,save_width
heinrichsweikamp
parents:
diff changeset
758
heinrichsweikamp
parents:
diff changeset
759 ;---- TOP line -----------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
760 movlw 1 ; row ~ height=1
heinrichsweikamp
parents:
diff changeset
761 movff WREG,win_height
heinrichsweikamp
parents:
diff changeset
762 rcall TFT_box
heinrichsweikamp
parents:
diff changeset
763
heinrichsweikamp
parents:
diff changeset
764 ;---- BOTTOM line --------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
765 movff save_top,PRODL ; Get back top,
heinrichsweikamp
parents:
diff changeset
766 movff save_height,WREG ; and height
heinrichsweikamp
parents:
diff changeset
767 addwf PRODL,W ; top+height
heinrichsweikamp
parents:
diff changeset
768 decf WREG ; top+height-1
heinrichsweikamp
parents:
diff changeset
769 movff WREG,win_top ; top+height-1 --> top
heinrichsweikamp
parents:
diff changeset
770 rcall TFT_box
heinrichsweikamp
parents:
diff changeset
771
heinrichsweikamp
parents:
diff changeset
772 ;---- LEFT column --------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
773 movff save_top,win_top ; Restore top/height.
heinrichsweikamp
parents:
diff changeset
774 movff save_height,win_height
heinrichsweikamp
parents:
diff changeset
775 movlw 1 ; column ~ width=1
heinrichsweikamp
parents:
diff changeset
776 movff WREG,win_width
heinrichsweikamp
parents:
diff changeset
777 rcall TFT_box
heinrichsweikamp
parents:
diff changeset
778
heinrichsweikamp
parents:
diff changeset
779 ;---- RIGHT column -------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
780 movff save_left,WREG
heinrichsweikamp
parents:
diff changeset
781 movff save_width,PRODL
heinrichsweikamp
parents:
diff changeset
782 addwf PRODL,W
heinrichsweikamp
parents:
diff changeset
783 decf WREG
heinrichsweikamp
parents:
diff changeset
784 movff WREG,win_leftx2
heinrichsweikamp
parents:
diff changeset
785 rcall TFT_box
heinrichsweikamp
parents:
diff changeset
786
heinrichsweikamp
parents:
diff changeset
787 ;---- Restore everything -------------------------------------------------
heinrichsweikamp
parents:
diff changeset
788 movff save_left,win_leftx2
heinrichsweikamp
parents:
diff changeset
789 movff save_width,win_width
heinrichsweikamp
parents:
diff changeset
790 return
heinrichsweikamp
parents:
diff changeset
791
heinrichsweikamp
parents:
diff changeset
792 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
793 ; TFT_box : fills current box with current color.
heinrichsweikamp
parents:
diff changeset
794 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
heinrichsweikamp
parents:
diff changeset
795 ; Outputs: (none)
heinrichsweikamp
parents:
diff changeset
796 ; Trashed: WREG, PROD
heinrichsweikamp
parents:
diff changeset
797 global TFT_box
heinrichsweikamp
parents:
diff changeset
798
heinrichsweikamp
parents:
diff changeset
799 TFT_box:
heinrichsweikamp
parents:
diff changeset
800 ;---- Define Window ------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
801 movf win_width,W
heinrichsweikamp
parents:
diff changeset
802 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
803 rlcf WREG
heinrichsweikamp
parents:
diff changeset
804 movwf win_width+0
heinrichsweikamp
parents:
diff changeset
805 movlw 0
heinrichsweikamp
parents:
diff changeset
806 rlcf WREG
heinrichsweikamp
parents:
diff changeset
807 movwf win_width+1
83
eb72c8865f47 Test with graphic compass
heinrichsweikamp
parents: 0
diff changeset
808 rcall TFT_box_write ; Setup box
0
heinrichsweikamp
parents:
diff changeset
809
83
eb72c8865f47 Test with graphic compass
heinrichsweikamp
parents: 0
diff changeset
810 global TFT_box_16bit_win_left
eb72c8865f47 Test with graphic compass
heinrichsweikamp
parents: 0
diff changeset
811 TFT_box_16bit_win_left:
0
heinrichsweikamp
parents:
diff changeset
812 rrcf win_width+1,W ; width /= 2
heinrichsweikamp
parents:
diff changeset
813 rrcf win_width+0,W
heinrichsweikamp
parents:
diff changeset
814 movwf win_width
heinrichsweikamp
parents:
diff changeset
815
heinrichsweikamp
parents:
diff changeset
816 ;---- Fill Window --------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
817 Index_out 0x22 ; Frame Memory Data Write start
heinrichsweikamp
parents:
diff changeset
818
heinrichsweikamp
parents:
diff changeset
819 clrf PRODH ; Column counter.
heinrichsweikamp
parents:
diff changeset
820 RS_H ; Data
heinrichsweikamp
parents:
diff changeset
821
heinrichsweikamp
parents:
diff changeset
822 TFT_box2: ; Loop height times
heinrichsweikamp
parents:
diff changeset
823 movff win_height,PRODL
heinrichsweikamp
parents:
diff changeset
824
heinrichsweikamp
parents:
diff changeset
825 TFT_box3: ; loop width times
heinrichsweikamp
parents:
diff changeset
826 movff win_color1,PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
827 movff win_color2,PORTH ; Lower
heinrichsweikamp
parents:
diff changeset
828 WR_L
heinrichsweikamp
parents:
diff changeset
829 WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
830
heinrichsweikamp
parents:
diff changeset
831 movff win_color1,PORTA ; Upper
heinrichsweikamp
parents:
diff changeset
832 movff win_color2,PORTH ; Lower
heinrichsweikamp
parents:
diff changeset
833 WR_L
heinrichsweikamp
parents:
diff changeset
834 WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
835
heinrichsweikamp
parents:
diff changeset
836 decfsz PRODL,F ; row loop finished ?
heinrichsweikamp
parents:
diff changeset
837 bra TFT_box3 ; No: continue.
heinrichsweikamp
parents:
diff changeset
838
heinrichsweikamp
parents:
diff changeset
839 incf PRODH,F ; column count ++
heinrichsweikamp
parents:
diff changeset
840
heinrichsweikamp
parents:
diff changeset
841 movff win_bargraph,WREG ; current column == bargraph ?
heinrichsweikamp
parents:
diff changeset
842 cpfseq PRODH
heinrichsweikamp
parents:
diff changeset
843 bra TFT_box4 ; No: just loop.
heinrichsweikamp
parents:
diff changeset
844
heinrichsweikamp
parents:
diff changeset
845 clrf WREG ; Yes: switch to black
heinrichsweikamp
parents:
diff changeset
846 movff WREG,win_color1
heinrichsweikamp
parents:
diff changeset
847 movff WREG,win_color2
heinrichsweikamp
parents:
diff changeset
848 TFT_box4:
heinrichsweikamp
parents:
diff changeset
849
heinrichsweikamp
parents:
diff changeset
850 movff win_width+0,WREG ; compare ?
heinrichsweikamp
parents:
diff changeset
851 xorwf PRODH,W
heinrichsweikamp
parents:
diff changeset
852 bnz TFT_box2 ; Loop not finished.
heinrichsweikamp
parents:
diff changeset
853
heinrichsweikamp
parents:
diff changeset
854 movlw 0x00 ; NOP, to stop window mode
heinrichsweikamp
parents:
diff changeset
855 rcall TFT_CmdWrite
heinrichsweikamp
parents:
diff changeset
856
heinrichsweikamp
parents:
diff changeset
857 setf WREG ; Reset bargraph mode...
heinrichsweikamp
parents:
diff changeset
858 movff WREG,win_bargraph
heinrichsweikamp
parents:
diff changeset
859
heinrichsweikamp
parents:
diff changeset
860 return
heinrichsweikamp
parents:
diff changeset
861
heinrichsweikamp
parents:
diff changeset
862 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
863 ;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGGGGGBBBBB'
heinrichsweikamp
parents:
diff changeset
864 global TFT_set_color
heinrichsweikamp
parents:
diff changeset
865
heinrichsweikamp
parents:
diff changeset
866 TFT_set_color:
heinrichsweikamp
parents:
diff changeset
867 movwf tft_temp1 ; Get 8Bit RGB b'RRRGGGBB'
heinrichsweikamp
parents:
diff changeset
868 movwf tft_temp2 ; Copy
heinrichsweikamp
parents:
diff changeset
869
heinrichsweikamp
parents:
diff changeset
870 ; Mask Bit 7,6,5,4,3,2
heinrichsweikamp
parents:
diff changeset
871 movlw b'00000011'
heinrichsweikamp
parents:
diff changeset
872 andwf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
873
heinrichsweikamp
parents:
diff changeset
874 movlw b'00000000'
heinrichsweikamp
parents:
diff changeset
875 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
876 movlw b'01010000'
heinrichsweikamp
parents:
diff changeset
877 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
878 movlw b'10100000'
heinrichsweikamp
parents:
diff changeset
879 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
880 movlw b'11111000'
heinrichsweikamp
parents:
diff changeset
881 movwf tft_temp3 ; Blue done.
heinrichsweikamp
parents:
diff changeset
882
heinrichsweikamp
parents:
diff changeset
883 movff tft_temp1, tft_temp2 ; Copy
heinrichsweikamp
parents:
diff changeset
884 ; Mask Bit 7,6,5,1,0
heinrichsweikamp
parents:
diff changeset
885 movlw b'00011100'
heinrichsweikamp
parents:
diff changeset
886 andwf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
887 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
888 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
889
heinrichsweikamp
parents:
diff changeset
890 movlw b'00000000'
heinrichsweikamp
parents:
diff changeset
891 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
892 movlw b'00000100'
heinrichsweikamp
parents:
diff changeset
893 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
894 movlw b'00001000'
heinrichsweikamp
parents:
diff changeset
895 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
896 movlw b'00001100'
heinrichsweikamp
parents:
diff changeset
897 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
898 movlw b'00010000'
heinrichsweikamp
parents:
diff changeset
899 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
900 movlw b'00010100'
heinrichsweikamp
parents:
diff changeset
901 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
902 movlw b'00100000'
heinrichsweikamp
parents:
diff changeset
903 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
904 movlw b'00111111'
heinrichsweikamp
parents:
diff changeset
905 movwf tft_temp4
heinrichsweikamp
parents:
diff changeset
906
heinrichsweikamp
parents:
diff changeset
907 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
908 rrcf tft_temp3,F
heinrichsweikamp
parents:
diff changeset
909
heinrichsweikamp
parents:
diff changeset
910 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
911 rrcf tft_temp3,F
heinrichsweikamp
parents:
diff changeset
912
heinrichsweikamp
parents:
diff changeset
913 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
914 rrcf tft_temp3,F ; tft_temp3 (b'GGGBBBBB') done.
heinrichsweikamp
parents:
diff changeset
915
heinrichsweikamp
parents:
diff changeset
916 movff tft_temp1, tft_temp2 ; Copy
heinrichsweikamp
parents:
diff changeset
917 clrf tft_temp1
heinrichsweikamp
parents:
diff changeset
918
heinrichsweikamp
parents:
diff changeset
919 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
920 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
921
heinrichsweikamp
parents:
diff changeset
922 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
923 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
924
heinrichsweikamp
parents:
diff changeset
925 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
926 rrcf tft_temp1,F ; Green done.
heinrichsweikamp
parents:
diff changeset
927
heinrichsweikamp
parents:
diff changeset
928 ; Mask Bit 4,3,2,1,0
heinrichsweikamp
parents:
diff changeset
929 movlw b'11100000'
heinrichsweikamp
parents:
diff changeset
930 andwf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
931
heinrichsweikamp
parents:
diff changeset
932 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
933 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
934 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
935 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
936 rrncf tft_temp2,F
heinrichsweikamp
parents:
diff changeset
937
heinrichsweikamp
parents:
diff changeset
938 movlw b'00000000'
heinrichsweikamp
parents:
diff changeset
939 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
940 movlw b'00000100'
heinrichsweikamp
parents:
diff changeset
941 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
942 movlw b'00001000'
heinrichsweikamp
parents:
diff changeset
943 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
944 movlw b'00001100'
heinrichsweikamp
parents:
diff changeset
945 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
946 movlw b'00010000'
heinrichsweikamp
parents:
diff changeset
947 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
948 movlw b'00010100'
heinrichsweikamp
parents:
diff changeset
949 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
950 movlw b'00100000'
heinrichsweikamp
parents:
diff changeset
951 dcfsnz tft_temp2,F
heinrichsweikamp
parents:
diff changeset
952 movlw b'00111111'
heinrichsweikamp
parents:
diff changeset
953 movwf tft_temp4
heinrichsweikamp
parents:
diff changeset
954
heinrichsweikamp
parents:
diff changeset
955 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
956 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
957
heinrichsweikamp
parents:
diff changeset
958 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
959 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
960
heinrichsweikamp
parents:
diff changeset
961 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
962 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
963
heinrichsweikamp
parents:
diff changeset
964 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
965 rrcf tft_temp1,F
heinrichsweikamp
parents:
diff changeset
966
heinrichsweikamp
parents:
diff changeset
967 rrcf tft_temp4,F
heinrichsweikamp
parents:
diff changeset
968 rrcf tft_temp1,F ; Red done.
heinrichsweikamp
parents:
diff changeset
969
heinrichsweikamp
parents:
diff changeset
970 movff tft_temp1,win_color1
heinrichsweikamp
parents:
diff changeset
971 movff tft_temp3,win_color2 ; Set Bank0 Color registers...
heinrichsweikamp
parents:
diff changeset
972 return
heinrichsweikamp
parents:
diff changeset
973
heinrichsweikamp
parents:
diff changeset
974 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
975 ; Dump screen contents to the UART
heinrichsweikamp
parents:
diff changeset
976
heinrichsweikamp
parents:
diff changeset
977 global TFT_dump_screen
heinrichsweikamp
parents:
diff changeset
978 TFT_dump_screen:
heinrichsweikamp
parents:
diff changeset
979 bsf no_sensor_int
heinrichsweikamp
parents:
diff changeset
980 movlw 'l'
heinrichsweikamp
parents:
diff changeset
981 movwf TXREG ; Send command echo.
heinrichsweikamp
parents:
diff changeset
982 call rs232_wait_tx ; wait for UART
heinrichsweikamp
parents:
diff changeset
983 ;---- Send DISPLAY box command for the full screen window -------------------
heinrichsweikamp
parents:
diff changeset
984 Index_out 0x50 ; Window Horizontal Start Address
heinrichsweikamp
parents:
diff changeset
985 Parameter_out 0x00, 0x00 ; 0-239
heinrichsweikamp
parents:
diff changeset
986 Index_out 0x51 ; Window Horizontal End Address
heinrichsweikamp
parents:
diff changeset
987 Parameter_out 0x00, 0xEF ; 0-239
heinrichsweikamp
parents:
diff changeset
988 Index_out 0x52 ; Window Vertical Start Address
heinrichsweikamp
parents:
diff changeset
989 Parameter_out 0x00, 0x00 ; 0-319
heinrichsweikamp
parents:
diff changeset
990 Index_out 0x53 ; Window Vertical End Address
heinrichsweikamp
parents:
diff changeset
991 Parameter_out 0x01, 0x3F ; 0-319
heinrichsweikamp
parents:
diff changeset
992
heinrichsweikamp
parents:
diff changeset
993 clrf ds_column
heinrichsweikamp
parents:
diff changeset
994 rcall dump_screen_pixel_reset
heinrichsweikamp
parents:
diff changeset
995 dump_screen_1:
heinrichsweikamp
parents:
diff changeset
996 btg LEDr ; LED activity toggle
heinrichsweikamp
parents:
diff changeset
997 ; Dump even column
heinrichsweikamp
parents:
diff changeset
998 movlw .240 ; 240 lines, once.
heinrichsweikamp
parents:
diff changeset
999 movwf ds_line
heinrichsweikamp
parents:
diff changeset
1000 dump_screen_2:
heinrichsweikamp
parents:
diff changeset
1001 Index_out 0x20 ; Frame Memory Horizontal Address
heinrichsweikamp
parents:
diff changeset
1002 movff ds_line,WREG ; d'0' ... d'239'
heinrichsweikamp
parents:
diff changeset
1003 mullw 1 ; Copy row to PRODH:L
heinrichsweikamp
parents:
diff changeset
1004 rcall TFT_DataWrite_PROD
heinrichsweikamp
parents:
diff changeset
1005
heinrichsweikamp
parents:
diff changeset
1006 movff ds_column,WREG ; Init X position.
heinrichsweikamp
parents:
diff changeset
1007 mullw 2
heinrichsweikamp
parents:
diff changeset
1008 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
heinrichsweikamp
parents:
diff changeset
1009
heinrichsweikamp
parents:
diff changeset
1010 rcall TFT_DataRead_PROD ; read pixel
heinrichsweikamp
parents:
diff changeset
1011 rcall dump_screen_pixel
heinrichsweikamp
parents:
diff changeset
1012
heinrichsweikamp
parents:
diff changeset
1013 decfsz ds_line,F
heinrichsweikamp
parents:
diff changeset
1014 bra dump_screen_2
heinrichsweikamp
parents:
diff changeset
1015 rcall dump_screen_pixel_flush
heinrichsweikamp
parents:
diff changeset
1016
heinrichsweikamp
parents:
diff changeset
1017 ; Dump odd column
heinrichsweikamp
parents:
diff changeset
1018 movlw .240 ; 240 lines, twice.
heinrichsweikamp
parents:
diff changeset
1019 movwf ds_line
heinrichsweikamp
parents:
diff changeset
1020 dump_screen_3:
heinrichsweikamp
parents:
diff changeset
1021 Index_out 0x20 ; Frame Memory Horizontal Address
heinrichsweikamp
parents:
diff changeset
1022 movff ds_line,WREG ; d'0' ... d'239'
heinrichsweikamp
parents:
diff changeset
1023 mullw 1 ; Copy row to PRODH:L
heinrichsweikamp
parents:
diff changeset
1024 rcall TFT_DataWrite_PROD
heinrichsweikamp
parents:
diff changeset
1025
heinrichsweikamp
parents:
diff changeset
1026 movff ds_column,WREG ; Init X position.
heinrichsweikamp
parents:
diff changeset
1027 mullw 2
heinrichsweikamp
parents:
diff changeset
1028 movlw .1
heinrichsweikamp
parents:
diff changeset
1029 addwf PRODL,F
heinrichsweikamp
parents:
diff changeset
1030 movlw 0
heinrichsweikamp
parents:
diff changeset
1031 addwfc PRODH,F ; +1
heinrichsweikamp
parents:
diff changeset
1032 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
heinrichsweikamp
parents:
diff changeset
1033
heinrichsweikamp
parents:
diff changeset
1034 rcall TFT_DataRead_PROD ; read pixel
heinrichsweikamp
parents:
diff changeset
1035 rcall dump_screen_pixel
heinrichsweikamp
parents:
diff changeset
1036
heinrichsweikamp
parents:
diff changeset
1037 decfsz ds_line,F
heinrichsweikamp
parents:
diff changeset
1038 bra dump_screen_3
heinrichsweikamp
parents:
diff changeset
1039 rcall dump_screen_pixel_flush
heinrichsweikamp
parents:
diff changeset
1040
heinrichsweikamp
parents:
diff changeset
1041 incf ds_column,F
heinrichsweikamp
parents:
diff changeset
1042 movlw .160
heinrichsweikamp
parents:
diff changeset
1043 cpfseq ds_column
heinrichsweikamp
parents:
diff changeset
1044 bra dump_screen_1
heinrichsweikamp
parents:
diff changeset
1045
heinrichsweikamp
parents:
diff changeset
1046 bcf no_sensor_int
heinrichsweikamp
parents:
diff changeset
1047 clrf RCREG1 ; Clear receive buffer
heinrichsweikamp
parents:
diff changeset
1048 bcf RCSTA1,CREN ; Clear receiver status
heinrichsweikamp
parents:
diff changeset
1049 bsf RCSTA1,CREN
heinrichsweikamp
parents:
diff changeset
1050 bsf enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
heinrichsweikamp
parents:
diff changeset
1051 return
heinrichsweikamp
parents:
diff changeset
1052
heinrichsweikamp
parents:
diff changeset
1053
heinrichsweikamp
parents:
diff changeset
1054 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1055 ; Pixel compression
heinrichsweikamp
parents:
diff changeset
1056 ;
heinrichsweikamp
parents:
diff changeset
1057 ; Input: PRODH:L = pixel.
heinrichsweikamp
parents:
diff changeset
1058 ; Output: Compressed stream on output.
heinrichsweikamp
parents:
diff changeset
1059 ; Compressed format:
heinrichsweikamp
parents:
diff changeset
1060 ; 0ccccccc : BLACK pixel, repeated ccccccc+1 times (1..128).
heinrichsweikamp
parents:
diff changeset
1061 ; 11cccccc : WHITE pixel, repeated cccccc+1 times (1..64).
heinrichsweikamp
parents:
diff changeset
1062 ; 10cccccc HIGH LOW : color pixel (H:L) repeated ccccc+1 times (1..64).
heinrichsweikamp
parents:
diff changeset
1063 ;
heinrichsweikamp
parents:
diff changeset
1064 dump_screen_pixel:
heinrichsweikamp
parents:
diff changeset
1065 movf PRODH,W ; Compare pixel-high
heinrichsweikamp
parents:
diff changeset
1066 xorwf ds_pixel+1,W
heinrichsweikamp
parents:
diff changeset
1067 bnz dump_screen_pixel_1 ; Different -> dump.
heinrichsweikamp
parents:
diff changeset
1068
heinrichsweikamp
parents:
diff changeset
1069 movf PRODL,W ; Compare pixel-low
heinrichsweikamp
parents:
diff changeset
1070 xorwf ds_pixel+0,W
heinrichsweikamp
parents:
diff changeset
1071 bnz dump_screen_pixel_1 ; Different -> dump.
heinrichsweikamp
parents:
diff changeset
1072
heinrichsweikamp
parents:
diff changeset
1073 incf ds_count,F ; Same color: just increment.
heinrichsweikamp
parents:
diff changeset
1074 return
heinrichsweikamp
parents:
diff changeset
1075
heinrichsweikamp
parents:
diff changeset
1076 dump_screen_pixel_1: ; Send (pixel,count) tuple
heinrichsweikamp
parents:
diff changeset
1077 movf ds_count,W ; Is count zero ?
heinrichsweikamp
parents:
diff changeset
1078 bz dump_screen_pixel_2 ; Yes: skip sending.
heinrichsweikamp
parents:
diff changeset
1079
heinrichsweikamp
parents:
diff changeset
1080 movf ds_pixel+1,W ; This is a BLACK pixel ?
heinrichsweikamp
parents:
diff changeset
1081 iorwf ds_pixel+0,W
heinrichsweikamp
parents:
diff changeset
1082 bz dump_screen_pix_black ; YES.
heinrichsweikamp
parents:
diff changeset
1083
heinrichsweikamp
parents:
diff changeset
1084 movf ds_pixel+1,W ; This is a white pixel ?
heinrichsweikamp
parents:
diff changeset
1085 andwf ds_pixel+0,W
heinrichsweikamp
parents:
diff changeset
1086 incf WREG
heinrichsweikamp
parents:
diff changeset
1087 bz dump_screen_pix_white ; YES.
heinrichsweikamp
parents:
diff changeset
1088
heinrichsweikamp
parents:
diff changeset
1089 ; No: write the pixel itself...
heinrichsweikamp
parents:
diff changeset
1090 movlw .64 ; Max color pixel on a single byte.
heinrichsweikamp
parents:
diff changeset
1091 cpfsgt ds_count ; Skip if count > 64
heinrichsweikamp
parents:
diff changeset
1092 movf ds_count,W ; W <- min(64,count)
heinrichsweikamp
parents:
diff changeset
1093 subwf ds_count,F ; ds_count <- ds_count-W
heinrichsweikamp
parents:
diff changeset
1094 decf WREG ; Save as 0..63
heinrichsweikamp
parents:
diff changeset
1095 iorlw b'10000000' ; MARK as a color pixel.
heinrichsweikamp
parents:
diff changeset
1096
heinrichsweikamp
parents:
diff changeset
1097 movwf TXREG
heinrichsweikamp
parents:
diff changeset
1098 call rs232_wait_tx ; wait for UART
heinrichsweikamp
parents:
diff changeset
1099 movff ds_pixel+1,TXREG
heinrichsweikamp
parents:
diff changeset
1100 call rs232_wait_tx ; wait for UART
heinrichsweikamp
parents:
diff changeset
1101 movff ds_pixel+0,TXREG
heinrichsweikamp
parents:
diff changeset
1102 call rs232_wait_tx ; wait for UART
heinrichsweikamp
parents:
diff changeset
1103 bra dump_screen_pixel_1
heinrichsweikamp
parents:
diff changeset
1104
heinrichsweikamp
parents:
diff changeset
1105 dump_screen_pixel_2:
heinrichsweikamp
parents:
diff changeset
1106 movff PRODH,ds_pixel+1 ; Save new pixel color
heinrichsweikamp
parents:
diff changeset
1107 movff PRODL,ds_pixel+0
heinrichsweikamp
parents:
diff changeset
1108 movlw 1
heinrichsweikamp
parents:
diff changeset
1109 movwf ds_count ; And set count=1.
heinrichsweikamp
parents:
diff changeset
1110 return
heinrichsweikamp
parents:
diff changeset
1111
heinrichsweikamp
parents:
diff changeset
1112 dump_screen_pix_black:
heinrichsweikamp
parents:
diff changeset
1113 movlw .128 ; Max black pixel on a single byte.
heinrichsweikamp
parents:
diff changeset
1114 cpfsgt ds_count ; Skip if count > 128
heinrichsweikamp
parents:
diff changeset
1115 movf ds_count,W ; W <- min(128,count)
heinrichsweikamp
parents:
diff changeset
1116 subwf ds_count,F ; ds_count <- ds_count-W
heinrichsweikamp
parents:
diff changeset
1117 decf WREG ; Save as 0..127
heinrichsweikamp
parents:
diff changeset
1118 dump_screen_pix_3:
heinrichsweikamp
parents:
diff changeset
1119 movwf TXREG
heinrichsweikamp
parents:
diff changeset
1120 call rs232_wait_tx
heinrichsweikamp
parents:
diff changeset
1121 bra dump_screen_pixel_1 ; More to dump ?
heinrichsweikamp
parents:
diff changeset
1122
heinrichsweikamp
parents:
diff changeset
1123 dump_screen_pix_white:
heinrichsweikamp
parents:
diff changeset
1124 movlw .64 ; Max white pixel on a single byte.
heinrichsweikamp
parents:
diff changeset
1125 cpfsgt ds_count ; Skip if count > 64
heinrichsweikamp
parents:
diff changeset
1126 movf ds_count,W ; W <- min(64,count)
heinrichsweikamp
parents:
diff changeset
1127 subwf ds_count,F ; ds_count <- ds_count-W
heinrichsweikamp
parents:
diff changeset
1128 decf WREG ; Save as 0..63
heinrichsweikamp
parents:
diff changeset
1129 iorlw b'11000000' ; MARK as a compressed white.
heinrichsweikamp
parents:
diff changeset
1130 bra dump_screen_pix_3
heinrichsweikamp
parents:
diff changeset
1131
heinrichsweikamp
parents:
diff changeset
1132 dump_screen_pixel_flush:
heinrichsweikamp
parents:
diff changeset
1133 clrf PRODH
heinrichsweikamp
parents:
diff changeset
1134 clrf PRODL
heinrichsweikamp
parents:
diff changeset
1135 rcall dump_screen_pixel_1 ; Send it
heinrichsweikamp
parents:
diff changeset
1136 dump_screen_pixel_reset:
heinrichsweikamp
parents:
diff changeset
1137 clrf ds_count ; But clear count.
heinrichsweikamp
parents:
diff changeset
1138 return
heinrichsweikamp
parents:
diff changeset
1139
heinrichsweikamp
parents:
diff changeset
1140 end