681
|
1 ; OSTC - diving computer code
|
|
2 ; Copyright (C) 2009 HeinrichsWeikamp GbR
|
|
3
|
|
4 ; This program is free software: you can redistribute it and/or modify
|
|
5 ; it under the terms of the GNU General Public License as published by
|
|
6 ; the Free Software Foundation, either version 3 of the License, or
|
|
7 ; (at your option) any later version.
|
|
8
|
|
9 ; This program is distributed in the hope that it will be useful,
|
|
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 ; GNU General Public License for more details.
|
|
13
|
|
14 ; You should have received a copy of the GNU General Public License
|
|
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
|
17
|
|
18 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
|
|
19 ; written: 090801
|
|
20 ; History:
|
|
21 ; 2009-08-30: [MH] last updated.
|
|
22 ; 2011-01-07: [jDG] Added flip_screen option
|
|
23 ; known bugs: pixel-write (loogbok curves) not done yet...
|
|
24 ; ToDo:
|
|
25
|
|
26 WIN_FONT macro win_font_input
|
|
27 movlw win_font_input
|
|
28 movff WREG,win_font
|
|
29 endm
|
|
30
|
|
31 WIN_TOP macro win_top_input
|
|
32 movlw win_top_input
|
|
33 movff WREG,win_top
|
|
34 endm
|
|
35
|
|
36 WIN_LEFT macro win_left_input
|
|
37 movlw win_left_input
|
|
38 movff WREG,win_leftx2
|
|
39 endm
|
|
40
|
|
41 WIN_INVERT macro win_invert_input
|
|
42 movlw win_invert_input
|
|
43 movff WREG,win_invert
|
|
44 endm
|
|
45
|
|
46 WIN_COLOR macro win_color_input
|
|
47 movlw win_color_input
|
|
48 call DISP_set_color
|
|
49 endm
|
|
50
|
|
51 ;=============================================================================
|
|
52
|
|
53 word_processor: ; word_processor:
|
|
54 clrf POSTINC2 ; Required, to mark end of string.
|
|
55 call aa_wordprocessor
|
|
56 movlb b'00000001' ; Back to Rambank1
|
|
57 return
|
|
58
|
|
59 ;=============================================================================
|
|
60 ; Macro to provides our own interface code.
|
|
61 ;
|
|
62 PIXEL_WRITE macro colRegister, rowRegister
|
|
63 movff colRegister,win_leftx2
|
|
64 movff rowRegister,win_top
|
|
65 call pixel_write
|
|
66 endm
|
|
67
|
|
68 INIT_PIXEL_WROTE macro colRegister
|
|
69 movff colRegister,win_leftx2
|
|
70 call init_pixel_write
|
|
71 endm
|
|
72
|
|
73 HALF_PIXEL_WRITE macro rowRegister
|
|
74 movff rowRegister,win_top
|
|
75 call half_pixel_write
|
|
76 endm
|
|
77
|
|
78 ;-----------------------------------------------------------------------------
|
|
79 ; Init for half_pixel_write
|
|
80 ; Set column register on DISPLAY device, and current color.
|
|
81 ; Inputs: win_leftx2
|
|
82 ; Outputs: win_color:2
|
|
83 ; Trashed: WREG, PROD
|
|
84 init_pixel_write:
|
|
85 movff win_leftx2,WREG
|
|
86 mullw 2
|
|
87 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
|
|
88 goto DISP_standard_color
|
|
89
|
|
90 ;-----------------------------------------------------------------------------
|
|
91 ; Writes two half-pixels at position (win_top,win_leftx2)
|
|
92 ; Inputs: win_leftx2, win_top, win_color:2
|
|
93 ; Trashed: WREG, PROD
|
|
94 pixel_write:
|
|
95 movff win_leftx2,WREG
|
|
96 mullw 2
|
|
97 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
|
|
98 rcall half_pixel_write ; Write this half-one.
|
|
99
|
|
100 movff win_leftx2,WREG ; Address of next one
|
|
101 mullw 2
|
|
102 infsnz PRODL ; +1
|
|
103 incf PRODH
|
|
104 rcall pixel_write_col320
|
|
105 bra half_pixel_write ; Note: Cmd 0x20 is mandatory, because
|
|
106 ; of the autoincrement going vertical
|
|
107
|
|
108 ;---- Do the 16bit 319-X-->X, if needed, and send to DISPLAY ------------
|
|
109 pixel_write_col320:
|
|
110 movff win_flags,WREG ; BEWARE: bank0 bit-test
|
684
|
111 btfsc WREG,1 ; Display1
|
|
112 bra pixel_write_noflip_H_display1 ; Yes.
|
681
|
113 btfss WREG,0 ; 180° rotation ?
|
|
114 bra pixel_write_noflip_H
|
|
115
|
|
116 movf PRODL,W ; 16bits 319 - PROD --> PROD
|
|
117 sublw LOW(.319) ; 319-W --> W
|
|
118 movwf PRODL
|
|
119 movf PRODH,W
|
|
120 btfss STATUS,C ; Borrow = /CARRY
|
|
121 incf WREG
|
|
122 sublw HIGH(.319)
|
|
123 movwf PRODH
|
|
124
|
|
125 pixel_write_noflip_H:
|
|
126 movlw 0x21 ; Start Address Vertical (.0 - .319)
|
|
127 rcall DISP_CmdWrite
|
684
|
128 bra DISP_DataWrite_PROD ; And return...
|
|
129
|
|
130 pixel_write_noflip_H_display1:
|
|
131 movlw 0x06
|
|
132 rcall DISP_CmdWrite
|
|
133 movf PRODH,W
|
|
134 rcall DISP_DataWrite
|
|
135 movlw 0x07
|
|
136 rcall DISP_CmdWrite
|
|
137 movf PRODL,W
|
|
138 rcall DISP_DataWrite
|
681
|
139
|
684
|
140 incf PRODL,F
|
|
141 movlw .0
|
|
142 addwfc PRODH,F ;+1
|
|
143
|
|
144 movlw 0x08
|
|
145 rcall DISP_CmdWrite
|
|
146 movf PRODH,W
|
|
147 rcall DISP_DataWrite
|
|
148 movlw 0x09
|
|
149 rcall DISP_CmdWrite
|
|
150 movf PRODL,W
|
|
151 bra DISP_DataWrite ; And return...
|
|
152
|
|
153
|
681
|
154 ;-----------------------------------------------------------------------------
|
|
155 ; Writes a vertical line of half-pixel at position (win_top,win_leftx2,win_height).
|
|
156 ; Inputs: win_leftx2, win_top, win_height, win_color:2
|
|
157 ; Trashed: WREG, PROD, TABLAT, TBLPTRL
|
|
158 half_vertical_line:
|
|
159 clrf TABLAT ; Loop index.
|
|
160
|
|
161 half_vertical_line_loop:
|
|
162 movff win_leftx2,WREG ; Init X position.
|
|
163 mullw 2
|
|
164 movf TABLAT,W ; Get loop index
|
|
165 andlw 1 ; Just low bit
|
|
166 xorwf PRODL,F ; And use it to jitter current X position
|
|
167 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
|
|
168
|
|
169 movff win_height,WREG ; Index reached height (Bank0 read) ?
|
|
170 xorwf TABLAT,W
|
|
171 btfsc STATUS,Z ; Equals ?
|
|
172 return ; Yes: done.
|
|
173 movff win_top,WREG ; Y = top + index (Bank0 read)
|
|
174 addwf TABLAT,W
|
|
175 rcall half_pixel_write_1
|
|
176 incf TABLAT,F ; index++
|
|
177 bra half_vertical_line_loop
|
|
178
|
|
179 ;-----------------------------------------------------------------------------
|
|
180 ; Writes one half-pixel at position (win_top,win_leftx2).
|
|
181 ; Inputs: win_leftx2, win_top, win_color:2
|
|
182 ; Trashed: WREG, PROD
|
|
183 half_pixel_write:
|
|
184 movff win_top,WREG ; d'0' ... d'239'
|
|
185 ; Variant with Y position in WREG.
|
|
186 half_pixel_write_1:
|
684
|
187 movff win_flags,PRODL ; Display1? win_flags is in bank0...
|
|
188 btfsc PRODL,1
|
|
189 bra half_pixel_write_1_display1 ; Yes.
|
|
190
|
681
|
191 btfsc PRODL,0 ; 180° rotation ?
|
|
192 sublw .239 ; 239-Y --> Y
|
684
|
193 mullw 1 ; Copy row to PRODL (PRODH=0)
|
681
|
194
|
|
195 movlw 0x20 ; Horizontal Address START:END
|
|
196 rcall DISP_CmdWrite
|
|
197 rcall DISP_DataWrite_PROD
|
|
198
|
|
199 movlw 0x22 ; Start Writing Data to GRAM
|
|
200 rcall DISP_CmdWrite
|
684
|
201 bsf DISPLAY_rs ; Data!
|
681
|
202 movff win_color1, PORTD
|
|
203 bcf DISPLAY_rw
|
684
|
204 bsf DISPLAY_rw ; Upper
|
681
|
205 movff win_color2, PORTD
|
|
206 bcf DISPLAY_rw
|
684
|
207 bsf DISPLAY_rw ; Lower
|
|
208 return ; Done.
|
|
209
|
|
210 half_pixel_write_1_display1:
|
|
211 mullw 1 ; Copy row to PRODL (PRODH=0)
|
|
212 ; Row address start
|
|
213 movlw 0x02
|
|
214 rcall DISP_CmdWrite
|
|
215 movlw .0
|
|
216 rcall DISP_DataWrite
|
|
217 movlw 0x03
|
|
218 rcall DISP_CmdWrite
|
|
219 movf PRODL,W
|
|
220 rcall DISP_DataWrite
|
|
221
|
|
222 incf PRODL,F
|
|
223
|
|
224 movlw 0x04
|
|
225 rcall DISP_CmdWrite
|
|
226 movlw .0
|
|
227 rcall DISP_DataWrite
|
|
228 movlw 0x05
|
|
229 rcall DISP_CmdWrite
|
|
230 movf PRODL,W
|
|
231 rcall DISP_DataWrite
|
|
232
|
|
233 movlw 0x22 ; Start Writing Data to GRAM
|
|
234 rcall DISP_CmdWrite
|
|
235 bsf DISPLAY_rs ; Data!
|
|
236 movff win_color1, PORTD
|
|
237 bcf DISPLAY_rw
|
|
238 bsf DISPLAY_rw ; Upper
|
|
239 movff win_color2, PORTD
|
|
240 bcf DISPLAY_rw
|
|
241 bsf DISPLAY_rw ; High
|
681
|
242 movff win_color3, PORTD
|
|
243 bcf DISPLAY_rw
|
684
|
244 bsf DISPLAY_rw ; Lower
|
681
|
245 return
|
|
246
|
684
|
247
|
681
|
248 ; -----------------------------
|
|
249 ; DISP Display Off
|
|
250 ; -----------------------------
|
|
251 DISP_DisplayOff:
|
|
252 clrf PORTD
|
|
253 bcf DISPLAY_hv
|
|
254 bcf DISPLAY_vdd
|
|
255 bcf DISPLAY_cs
|
|
256 bcf DISPLAY_e_nwr
|
|
257 bcf DISPLAY_rw
|
|
258 bcf DISPLAY_nreset
|
|
259 return
|
|
260
|
|
261 ;=============================================================================
|
|
262 ; Fast macros to write to DISPLAY display.
|
|
263 ; Adding a call/return adds 3 words and a pipeline flush, hence make it
|
|
264 ; nearly twice slower...
|
|
265 ;
|
|
266 ; Input : commande as macro parameter.
|
|
267 ; Output : NONE
|
|
268 ; Trash : WREG
|
|
269 ;
|
|
270 AA_CMD_WRITE macro cmd
|
|
271 movlw cmd
|
|
272 rcall DISP_CmdWrite ; slow but saves a lot of bytes in flash
|
|
273 endm
|
|
274 ;
|
|
275 ; Input : data as macro parameter.
|
|
276 ; Output : NONE
|
|
277 ; Trash : WREG
|
|
278 ;
|
|
279 AA_DATA_WRITE macro data
|
|
280 movlw data
|
|
281 rcall DISP_DataWrite
|
|
282 endm
|
|
283 ;
|
|
284 ; Input : PRODH:L as 16bits data.
|
|
285 ; Output : NONE
|
|
286 ; Trash : NONE
|
|
287 ;
|
|
288 AA_DATA_WRITE_PROD macro
|
|
289 rcall DISP_DataWrite_PROD ; slow but saves a lot of bytes in flash
|
|
290 endm
|
|
291
|
|
292 ;=============================================================================
|
|
293 ; Output DISPLAY Window Address commands.
|
|
294 ; Inputs : win_top, win_leftx2, win_height, aa_width.
|
|
295 ; Output : PortD commands.
|
|
296 ; Trashed: PROD
|
|
297 ;
|
|
298 DISP_box_write:
|
|
299 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
300 btfsc WREG,1 ; Display1?
|
|
301 bra DISP_box_write_display1 ; Yes
|
|
302
|
|
303 movff win_leftx2,WREG ; Compute left = 2*leftx2 --> PROD
|
|
304 mullw 2
|
|
305
|
|
306 movff win_flags,WREG ; BEWARE: bank0 bit-test
|
|
307 btfsc WREG,0 ; 180° rotation ?
|
|
308 bra DISP_box_flip_H ; YES:
|
|
309
|
|
310 ;---- Normal horizontal window ---------------------------------------
|
|
311 ; Output 0x35 left,
|
|
312 ; 0x36 right == left + width - 1.
|
|
313 AA_CMD_WRITE 0x35 ; this is the left border
|
|
314 AA_DATA_WRITE_PROD ; Output left
|
|
315 AA_CMD_WRITE 0x21 ; Also the horizontal first pix coord.
|
|
316 AA_DATA_WRITE_PROD
|
|
317
|
|
318 movf aa_width+0,W,ACCESS ; right = left + width - 1
|
|
319 addwf PRODL,F
|
|
320 movf aa_width+1,W,ACCESS
|
|
321 addwfc PRODH,F
|
|
322 decf PRODL,F,A ; decrement result
|
|
323 btfss STATUS,C
|
|
324 decf PRODH,F,A
|
|
325
|
|
326 AA_CMD_WRITE 0x36 ; Write and the right border
|
|
327 AA_DATA_WRITE_PROD
|
|
328
|
|
329 bra DISP_box_noflip_H
|
|
330
|
|
331 ;---- Flipped horizontal window --------------------------------------
|
|
332 DISP_box_flip_H:
|
|
333 ; Output 0x36 flipped(left) = 319-left
|
|
334 ; 0x35 flipped(right) = 319-right = 320 - left - width
|
|
335 movf PRODL,W ; 16bits 319 - PROD --> PROD
|
|
336 sublw LOW(.319) ; 319-W --> W
|
|
337 movwf PRODL
|
|
338 movf PRODH,W
|
|
339 btfss STATUS,C ; Borrow = /CARRY
|
|
340 incf WREG
|
|
341 sublw HIGH(.319)
|
|
342 movwf PRODH
|
|
343 AA_CMD_WRITE 0x36 ; this is the left border
|
|
344 AA_DATA_WRITE_PROD ; Output left
|
|
345 AA_CMD_WRITE 0x21
|
|
346 AA_DATA_WRITE_PROD
|
|
347
|
|
348 movf aa_width+0,W ; 16bits PROD - width --> PROD
|
|
349 subwf PRODL,F ; PRODL - WREG --> PRODL
|
|
350 movf aa_width+1,W
|
|
351 subwfb PRODH,F
|
|
352 infsnz PRODL ; PROD+1 --> PROD
|
|
353 incf PRODH
|
|
354 AA_CMD_WRITE 0x35 ; this is the left border
|
|
355 AA_DATA_WRITE_PROD ; Output left
|
|
356
|
|
357 DISP_box_noflip_H:
|
|
358 movff win_flags,WREG ; BEWARE: bank0 bit-test
|
|
359 btfsc WREG,0 ; 180° rotation ?
|
|
360 bra DISP_box_flip_V
|
|
361
|
|
362 ;---- Normal vertical window -----------------------------------------
|
|
363 ; Output 0x37 (top) (bottom)
|
|
364 movff win_top,PRODH ; top --> PRODH (first byte)
|
|
365 movff win_height,WREG
|
|
366 addwf PRODH,W
|
|
367 decf WREG
|
|
368 movwf PRODL ; top+height-1 --> PRODL (second byte)
|
|
369
|
|
370 AA_CMD_WRITE 0x37
|
|
371 AA_DATA_WRITE_PROD
|
|
372
|
|
373 movff PRODH,PRODL
|
|
374 clrf PRODH ; Start pixel V coord == top.
|
|
375 AA_CMD_WRITE 0x20
|
|
376 AA_DATA_WRITE_PROD
|
|
377
|
|
378 return
|
|
379
|
|
380 ;---- Flipped vertical window ----------------------------------------
|
|
381 ; Output 0x37 flipped(bottom) = 239-bottom = 240 - top - height
|
|
382 ; flipped(top) = 239-top
|
|
383 DISP_box_flip_V:
|
|
384 movff win_top,PRODL
|
|
385 movff win_height,WREG
|
|
386 addwf PRODL,W
|
|
387 sublw .240 ; 240 - top - height
|
|
388 movwf PRODH ; First byte
|
|
389
|
|
390 movf PRODL,W
|
|
391 sublw .239 ; 249-top
|
|
392 movwf PRODL ; --> second byte.
|
|
393
|
|
394 AA_CMD_WRITE 0x37
|
|
395 AA_DATA_WRITE_PROD
|
|
396
|
|
397 clrf PRODH ; Start pixel V coord.
|
|
398 AA_CMD_WRITE 0x20
|
|
399 AA_DATA_WRITE_PROD
|
|
400
|
|
401 return
|
|
402
|
|
403 DISP_box_write_display1:
|
|
404 movff win_leftx2,WREG ; Compute left = 2*leftx2 --> PROD
|
|
405 mullw 2
|
|
406
|
|
407 movlw 0x06
|
|
408 rcall DISP_CmdWrite
|
|
409 movf PRODH,W
|
|
410 rcall DISP_DataWrite
|
|
411 movlw 0x07
|
|
412 rcall DISP_CmdWrite
|
|
413 movf PRODL,W
|
|
414 rcall DISP_DataWrite
|
|
415
|
|
416 movf aa_width+0,W,ACCESS ; right = left + width - 1
|
|
417 addwf PRODL,F
|
|
418 movf aa_width+1,W,ACCESS
|
|
419 addwfc PRODH,F
|
|
420 decf PRODL,F,A ; decrement result
|
|
421 btfss STATUS,C
|
|
422 decf PRODH,F,A
|
|
423
|
|
424 movlw 0x08
|
|
425 rcall DISP_CmdWrite
|
|
426 movf PRODH,W
|
|
427 rcall DISP_DataWrite
|
|
428 movlw 0x09
|
|
429 rcall DISP_CmdWrite
|
|
430 movf PRODL,W
|
|
431 rcall DISP_DataWrite
|
|
432
|
|
433 ;---- Normal vertical window -----------------------------------------
|
684
|
434 ; Output (top) (bottom)
|
681
|
435 movff win_top,PRODH ; top --> PRODH (first byte)
|
|
436 movff win_height,WREG
|
|
437 addwf PRODH,W
|
|
438 decf WREG
|
|
439 movwf PRODL ; top+height-1 --> PRODL (second byte)
|
|
440
|
|
441 movlw 0x02
|
|
442 rcall DISP_CmdWrite
|
|
443 movlw 0x00
|
|
444 rcall DISP_DataWrite
|
|
445 movlw 0x03
|
|
446 rcall DISP_CmdWrite
|
|
447 movf PRODH,W
|
|
448 rcall DISP_DataWrite
|
|
449
|
|
450 movlw 0x04
|
|
451 rcall DISP_CmdWrite
|
|
452 movlw 0x00
|
|
453 rcall DISP_DataWrite
|
|
454 movlw 0x05
|
|
455 rcall DISP_CmdWrite
|
|
456 movf PRODL,W
|
|
457 rcall DISP_DataWrite
|
|
458 return
|
|
459
|
|
460 ;=============================================================================
|
|
461 ; DISP_frame : draw a frame around current box with current color.
|
|
462 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
|
|
463 ; Outputs: (none)
|
|
464 ; Trashed: WREG, PROD, aa_start:2, aa_end:2, win_leftx2, win_width:1
|
|
465 global DISP_frame
|
|
466 DISP_frame:
|
|
467 movff win_top,aa_start+0 ; Backup everything.
|
|
468 movff win_height,aa_start+1
|
|
469 movff win_leftx2,aa_end+0
|
|
470 movff win_width,aa_end+1
|
|
471
|
|
472 ;---- TOP line -----------------------------------------------------------
|
|
473 movlw 1 ; row ~ height=1
|
|
474 movff WREG,win_height
|
|
475 rcall DISP_box
|
|
476
|
|
477 ;---- BOTTOM line --------------------------------------------------------
|
|
478 movff aa_start+0,PRODL ; Get back top,
|
|
479 movff aa_start+1,WREG ; and height
|
|
480 addwf PRODL,W ; top+height
|
|
481 decf WREG ; top+height-1
|
|
482 movff WREG,win_top ; top+height-1 --> top
|
|
483 rcall DISP_box
|
|
484
|
|
485 ;---- LEFT column --------------------------------------------------------
|
|
486 movff aa_start+0,win_top ; Restore top/height.
|
|
487 movff aa_start+1,win_height
|
|
488 movlw 1 ; column ~ width=1
|
|
489 movff WREG,win_width
|
|
490 rcall DISP_box
|
|
491
|
|
492 ;---- RIGHT column -------------------------------------------------------
|
|
493 movff aa_end+0,WREG
|
|
494 movff aa_end+1,PRODL
|
|
495 addwf PRODL,W
|
|
496 decf WREG
|
|
497 movff WREG,win_leftx2
|
|
498 bra DISP_box
|
|
499
|
|
500 ;=============================================================================
|
|
501 ; DISP_box : fills current box with current color.
|
|
502 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
|
|
503 ; Outputs: (none)
|
|
504 ; Trashed: WREG, PROD
|
|
505
|
|
506 global DISP_box
|
|
507 DISP_box:
|
|
508 ;---- Define Window ------------------------------------------------------
|
|
509 movff win_width,WREG
|
|
510 bcf STATUS,C
|
|
511 rlcf WREG
|
|
512 movwf aa_width+0
|
|
513 movlw 0
|
|
514 rlcf WREG
|
|
515 movwf aa_width+1
|
|
516 rcall DISP_box_write
|
|
517
|
|
518 ;---- Fill Window --------------------------------------------------------
|
|
519 movlw 0x22 ; Start Writing Data to GRAM
|
|
520 rcall DISP_CmdWrite
|
|
521
|
|
522 clrf PRODH ; Column counter.
|
|
523 bsf DISPLAY_rs ; Data!
|
|
524
|
|
525 DISP_box2: ; Loop height times
|
|
526 movff win_height,PRODL
|
|
527
|
|
528 DISP_box3: ; loop width times
|
|
529 movff win_color1,PORTD
|
|
530 bcf DISPLAY_rw
|
684
|
531 bsf DISPLAY_rw ; Upper
|
681
|
532 movff win_color2,PORTD
|
|
533 bcf DISPLAY_rw
|
684
|
534 bsf DISPLAY_rw ; Lower/High
|
681
|
535 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
536 btfss WREG,1 ; Display1?
|
|
537 bra DISP_box3a ; No
|
|
538 movff win_color3,PORTD
|
|
539 bcf DISPLAY_rw
|
684
|
540 bsf DISPLAY_rw ; Lower
|
681
|
541
|
|
542 DISP_box3a:
|
|
543 movff win_color1,PORTD
|
|
544 bcf DISPLAY_rw
|
684
|
545 bsf DISPLAY_rw ; Upper
|
681
|
546 movff win_color2,PORTD
|
|
547 bcf DISPLAY_rw
|
684
|
548 bsf DISPLAY_rw ; Lower/High
|
681
|
549 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
550 btfss WREG,1 ; Display1?
|
|
551 bra DISP_box3b ; No
|
|
552 movff win_color3,PORTD
|
|
553 bcf DISPLAY_rw
|
684
|
554 bsf DISPLAY_rw ; Lower
|
681
|
555
|
|
556 DISP_box3b:
|
|
557 decfsz PRODL,F ; row loop finished ?
|
|
558 bra DISP_box3 ; No: continue.
|
|
559
|
|
560 incf PRODH,F ; column count ++
|
|
561
|
|
562 movff win_bargraph,WREG ; current column == bargraph ?
|
|
563 cpfseq PRODH
|
|
564 bra DISP_box4 ; No: just loop.
|
|
565
|
|
566 clrf WREG ; Yes: switch to black
|
|
567 movff WREG,win_color1
|
|
568 movff WREG,win_color2
|
|
569 movff WREG,win_color3 ; Yes.
|
|
570 DISP_box4:
|
|
571 movff win_width,WREG
|
|
572 cpfseq PRODH
|
|
573 bra DISP_box2
|
|
574
|
|
575 setf WREG ; Reset bargraph mode...
|
|
576 movff WREG,win_bargraph
|
|
577
|
|
578 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
579 btfsc WREG,1 ; Display1?
|
|
580 return ; Yes, done.
|
|
581
|
|
582 movlw 0x00 ; NOP, to stop window mode
|
|
583 bra DISP_CmdWrite ; Returns....
|
|
584
|
|
585 ;=============================================================================
|
|
586 ; DISP_ClearScreen: An optimized version of PLEX_box, for full screen black.
|
|
587 ; Trashed: WREG, PROD
|
|
588
|
|
589 global DISP_ClearScreen
|
|
590 DISP_ClearScreen:
|
|
591 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
592 btfsc WREG,1 ; Display1?
|
|
593 bra DISP_ClearScreen_display1; Yes
|
|
594
|
|
595 movlw 0x35 ; VerticalStartAddress HIGH:LOW
|
|
596 rcall DISP_CmdWrite
|
|
597 mullw 0
|
|
598 rcall DISP_DataWrite_PROD
|
|
599
|
|
600 movlw 0x36 ; VerticalEndAddress HIGH:LOW
|
|
601 rcall DISP_CmdWrite
|
|
602 movlw 0x01
|
|
603 rcall DISP_DataWrite
|
|
604 movlw 0x3F
|
|
605 rcall DISP_DataWrite
|
|
606
|
|
607 movlw 0x37 ; HorizontalAddress START:END
|
|
608 rcall DISP_CmdWrite
|
|
609 movlw 0x00
|
|
610 rcall DISP_DataWrite
|
|
611 movlw 0xEF
|
|
612 rcall DISP_DataWrite
|
|
613
|
|
614 movlw 0x20 ; Start Address Horizontal (.0 - .239)
|
|
615 rcall DISP_CmdWrite
|
|
616 rcall DISP_DataWrite_PROD
|
|
617
|
|
618 movlw 0x21 ; Start Address Vertical (.0 - .319)
|
|
619 rcall DISP_CmdWrite
|
|
620 rcall DISP_DataWrite_PROD
|
|
621
|
|
622 movlw 0x22 ; Start Writing Data to GRAM
|
|
623 rcall DISP_CmdWrite
|
|
624
|
|
625 ; See Page 101 of DISPLAY Driver IC Datasheet how to handle rs/rw clocks
|
|
626 bsf DISPLAY_rs ; Data!
|
684
|
627 clrf PORTD
|
681
|
628 movlw .160
|
|
629 movwf PRODH
|
|
630 DISP_ClearScreen2:
|
|
631 movlw .240
|
|
632 movwf PRODL
|
|
633 DISP_ClearScreen3:
|
|
634 bcf DISPLAY_rw
|
|
635 bsf DISPLAY_rw ; Upper
|
|
636 bcf DISPLAY_rw
|
|
637 bsf DISPLAY_rw ; Lower
|
|
638 bcf DISPLAY_rw
|
|
639 bsf DISPLAY_rw ; Upper
|
|
640 bcf DISPLAY_rw
|
|
641 bsf DISPLAY_rw ; Lower
|
|
642 decfsz PRODL,F
|
|
643 bra DISP_ClearScreen3
|
|
644 decfsz PRODH,F
|
|
645 bra DISP_ClearScreen2
|
|
646 movlw 0x00 ; NOP, to stop Address Update Counter
|
684
|
647 bra DISP_CmdWrite ; And return...
|
681
|
648
|
|
649 DISP_ClearScreen_display1:
|
|
650 ; Column Address start
|
|
651 movlw 0x02
|
|
652 rcall DISP_CmdWrite
|
|
653 movlw 0x00
|
|
654 rcall DISP_DataWrite
|
|
655 movlw 0x03
|
|
656 rcall DISP_CmdWrite
|
|
657 movlw 0x00
|
|
658 rcall DISP_DataWrite
|
|
659
|
|
660 ; Column Address end
|
|
661 movlw 0x04
|
|
662 rcall DISP_CmdWrite
|
|
663 movlw 0x00
|
|
664 rcall DISP_DataWrite
|
|
665 movlw 0x05
|
|
666 rcall DISP_CmdWrite
|
|
667 movlw 0xEF
|
|
668 rcall DISP_DataWrite
|
|
669
|
|
670 ; Row address start
|
|
671 movlw 0x06
|
|
672 rcall DISP_CmdWrite
|
|
673 movlw 0x00
|
|
674 rcall DISP_DataWrite
|
|
675 movlw 0x07
|
|
676 rcall DISP_CmdWrite
|
|
677 movlw 0x00
|
|
678 rcall DISP_DataWrite
|
|
679
|
|
680 ; Row address end
|
|
681 movlw 0x08
|
|
682 rcall DISP_CmdWrite
|
|
683 movlw 0x01
|
|
684 rcall DISP_DataWrite
|
|
685 movlw 0x09
|
|
686 rcall DISP_CmdWrite
|
|
687 movlw 0x3F
|
|
688 rcall DISP_DataWrite
|
|
689
|
|
690 movlw 0x22 ; Start Writing Data to GRAM
|
|
691 rcall DISP_CmdWrite
|
|
692
|
|
693 bsf DISPLAY_rs ; Data!
|
|
694
|
|
695 movlw .160
|
|
696 movwf PRODH
|
|
697 DISP_ClearScreen2_display1:
|
|
698 movlw .240
|
|
699 movwf PRODL
|
684
|
700 clrf PORTD
|
681
|
701 DISP_ClearScreen3_display1:
|
|
702 bcf DISPLAY_rw
|
|
703 bsf DISPLAY_rw ; Upper
|
|
704 bcf DISPLAY_rw
|
|
705 bsf DISPLAY_rw ; High
|
|
706 bcf DISPLAY_rw
|
|
707 bsf DISPLAY_rw ; Lower
|
|
708 bcf DISPLAY_rw
|
|
709 bsf DISPLAY_rw ; Upper
|
|
710 bcf DISPLAY_rw
|
|
711 bsf DISPLAY_rw ; High
|
|
712 bcf DISPLAY_rw
|
|
713 bsf DISPLAY_rw ; Lower
|
|
714 decfsz PRODL,F
|
|
715 bra DISP_ClearScreen3_display1
|
|
716 decfsz PRODH,F
|
|
717 bra DISP_ClearScreen2_display1
|
|
718 return
|
|
719
|
|
720
|
|
721 ; -----------------------------
|
|
722 ; DISP Write Cmd via W
|
|
723 ; -----------------------------
|
|
724 DISP_CmdWrite:
|
|
725 bcf DISPLAY_rs ; Command!
|
|
726 movwf PORTD ; Move Data to PORTD
|
|
727 bcf DISPLAY_rw
|
|
728 bsf DISPLAY_rw
|
|
729 return
|
|
730
|
|
731 ; -----------------------------
|
|
732 ; DISP Write Display Data via W
|
|
733 ; -----------------------------
|
|
734 DISP_DataWrite:
|
|
735 bsf DISPLAY_rs ; Data!
|
|
736 movwf PORTD ; Move Data to PORTD
|
|
737 bcf DISPLAY_rw
|
|
738 bsf DISPLAY_rw
|
|
739 return
|
|
740
|
|
741 ; -----------------------------
|
|
742 ; DISP Data Cmd via W
|
|
743 ; -----------------------------
|
|
744 DISP_DataWrite_PROD:
|
|
745 bsf DISPLAY_rs ; Data!
|
|
746 movff PRODH,PORTD ; Move high byte to PORTD (DISPLAY is bigendian)
|
|
747 bcf DISPLAY_rw
|
|
748 bsf DISPLAY_rw
|
|
749 movff PRODL,PORTD ; Move low byte to PORTD
|
|
750 bcf DISPLAY_rw
|
|
751 bsf DISPLAY_rw
|
|
752 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
753 btfss WREG,1 ; Display1?
|
|
754 return ; No, done.
|
|
755 movff win_color3,PORTD ; Move low byte to PORTD
|
|
756 bcf DISPLAY_rw
|
|
757 bsf DISPLAY_rw
|
|
758 return
|
|
759
|
|
760
|
|
761 ; -----------------------------
|
|
762 ; DISP Read data into WREG
|
|
763 ; -----------------------------
|
|
764 ; NOTE: you should "setf TRISD" before calling this function,
|
|
765 ; to make PortD an input port...
|
|
766 DISP_DataRead:
|
|
767 bsf DISPLAY_rs ; Data register.
|
|
768 bcf DISPLAY_e_nwr ; Read enable.
|
|
769 nop
|
|
770 nop
|
|
771 nop
|
|
772 nop
|
|
773 movf PORTD,W ; Read byte.
|
|
774 bsf DISPLAY_e_nwr ; release bus.
|
|
775 return
|
|
776
|
|
777 ; -----------------------------
|
|
778 ; DISP boot
|
|
779 ; -----------------------------
|
|
780 DISPLAY_boot:
|
|
781 movlw LOW 0x17FDC
|
|
782 movwf TBLPTRL
|
|
783 movlw HIGH 0x17FDC
|
|
784 movwf TBLPTRH
|
|
785 movlw UPPER 0x17FDC
|
|
786 movwf TBLPTRU
|
|
787 TBLRD*
|
|
788 movlw 0x01
|
|
789 cpfseq TABLAT ; Display1?
|
|
790 bra display0_init ; No, Display0
|
|
791
|
|
792 banksel win_flags
|
|
793 bsf win_flags,0
|
|
794 bsf win_flags,1
|
|
795 banksel flag1
|
|
796 bcf DISPLAY_hv ; Backlight off
|
|
797 nop
|
|
798 bcf DISPLAY_vdd
|
|
799 WAITMS d'10'
|
|
800 bsf DISPLAY_vdd
|
|
801 WAITMS d'100'
|
|
802 bsf DISPLAY_rw
|
|
803 nop
|
|
804 bcf DISPLAY_cs
|
|
805 nop
|
|
806 bsf DISPLAY_nreset
|
|
807 WAITMS d'1'
|
|
808 bcf DISPLAY_nreset
|
|
809 WAIT10US d'2'
|
|
810 bsf DISPLAY_nreset
|
|
811 WAITMS d'120'
|
|
812 bsf DISPLAY_e_nwr ; release bus.
|
|
813 rcall display1_init ; Init sequence
|
|
814 rcall DISP_ClearScreen
|
|
815 WAITMS d'60'
|
|
816 bsf DISPLAY_hv ; Backlight on
|
|
817 return
|
|
818
|
|
819 display1_init:
|
|
820 movlw LOW display1_config_table
|
|
821 movwf TBLPTRL
|
|
822 movlw HIGH display1_config_table
|
|
823 movwf TBLPTRH
|
|
824 movlw UPPER display1_config_table
|
|
825 movwf TBLPTRU
|
|
826 display_init_loop:
|
|
827 TBLRD*+
|
|
828 movlw 0xFF
|
|
829 cpfseq TABLAT
|
|
830 bra display_config_write ; Write Config pair to Display
|
|
831 ; Delay ms or quit (return)
|
|
832 TBLRD*+
|
|
833 tstfsz TABLAT ; End of config?
|
|
834 bra $+4 ; No
|
|
835 return ; Done.
|
|
836 movf TABLAT,W
|
|
837 call WAITMSX ; Wait WREG milliseconds
|
|
838 bra display_init_loop ; Loop
|
|
839
|
|
840 display_config_write: ; With command in WREG
|
|
841 movf TABLAT,W
|
|
842 rcall DISP_CmdWrite ; Write command
|
|
843 TBLRD*+ ; Get config
|
|
844 movf TABLAT,W
|
|
845 rcall DISP_DataWrite ; Write config
|
|
846 bra display_init_loop ; Loop
|
|
847
|
|
848
|
|
849 display1_config_table:
|
|
850 ; Reg, Dat or 0xFF, Delay or 0xFF, 0x00 (End)
|
|
851 db 0x96,0x01
|
|
852 db 0x19,0x87
|
|
853 db 0xFF,.10
|
|
854 db 0x26,0x80
|
|
855 db 0x1B,0x0C
|
|
856 db 0x43,0x00
|
|
857 db 0x20,0x00
|
|
858 db 0x1F,0x07
|
|
859 db 0x44,0x7F
|
|
860 db 0x45,0x14
|
|
861 db 0x1D,0x05
|
|
862 db 0x1E,0x00
|
|
863 db 0x1C,0x04
|
|
864 db 0x1B,0x14
|
|
865 db 0xFF,.40
|
|
866 db 0x43,0x80
|
|
867 db 0x42,0x08
|
|
868 db 0x23,0x95
|
|
869 db 0x24,0x95
|
|
870 db 0x25,0xFF
|
|
871 db 0x21,0x10
|
|
872 db 0x2B,0x00
|
|
873 db 0x95,0x01
|
|
874 db 0x1A,0x00
|
|
875 db 0x93,0x0F
|
|
876 db 0x70,0x66
|
|
877 db 0x18,0x01
|
|
878 db 0x46,0x86
|
|
879 db 0x47,0x60
|
|
880 db 0x48,0x01
|
|
881 db 0x49,0x67
|
|
882 db 0x4A,0x46
|
|
883 db 0x4B,0x13
|
|
884 db 0x4C,0x01
|
|
885 db 0x4D,0x67
|
|
886 db 0x4E,0x00
|
|
887 db 0x4F,0x13
|
|
888 db 0x50,0x02
|
|
889 db 0x51,0x00
|
|
890 db 0x38,0x00
|
|
891 db 0x39,0x00
|
|
892 db 0x27,0x02
|
|
893 db 0x28,0x03
|
|
894 db 0x29,0x08
|
|
895 db 0x2A,0x08
|
|
896 db 0x2C,0x08
|
|
897 db 0x2D,0x08
|
|
898 db 0x35,0x09
|
|
899 db 0x36,0x09
|
|
900 db 0x91,0x14
|
|
901 db 0x37,0x00
|
|
902 db 0x01,0x06
|
|
903 db 0x3A,0xA1
|
|
904 db 0x3B,0xA1
|
|
905 db 0x3C,0xA1
|
|
906 db 0x3D,0x00
|
|
907 db 0x3E,0x2D
|
|
908 db 0x40,0x03
|
|
909 db 0x41,0xCC
|
|
910 db 0x0A,0x00
|
|
911 db 0x0B,0x00
|
|
912 db 0x0C,0x01
|
|
913 db 0x0D,0x3F
|
|
914 db 0x0E,0x00
|
|
915 db 0x0F,0x00
|
|
916 db 0x10,0x01
|
|
917 db 0x11,0x40
|
|
918 db 0x12,0x00
|
|
919 db 0x13,0x00
|
|
920 db 0x14,0x00
|
|
921 db 0x15,0x00
|
|
922 db 0x02,0x00
|
|
923 db 0x03,0x00
|
|
924 db 0x04,0x00
|
|
925 db 0x05,0xEF
|
|
926 db 0x06,0x00
|
|
927 db 0x07,0x00
|
|
928 db 0x08,0x01
|
|
929 db 0x09,0x3F
|
|
930 db 0x16,0x88
|
|
931 db 0x72,0x00
|
|
932 db 0x22,0x60
|
|
933 db 0x94,0x0A
|
|
934 db 0x90,0x7F
|
|
935 db 0x26,0x84
|
|
936 db 0xFF,.40
|
|
937 db 0x26,0xA4
|
|
938 db 0x26,0xAC
|
|
939 db 0xFF,.40
|
|
940 db 0x26,0xBC
|
|
941 db 0x96,0x00
|
|
942 db 0xFF,0x00 ; End of table pair
|
|
943
|
|
944
|
|
945 display0_init: ; Display0
|
|
946 banksel win_flags
|
|
947 bcf win_flags,1
|
|
948 banksel flag1
|
|
949 bcf DISPLAY_hv
|
|
950 WAITMS d'32'
|
|
951 bsf DISPLAY_vdd
|
|
952 nop
|
|
953 bcf DISPLAY_cs
|
|
954 nop
|
|
955 bsf DISPLAY_nreset
|
|
956 WAITMS d'250' ; Standard wake-up
|
|
957 bsf DISPLAY_e_nwr
|
|
958 nop
|
|
959 bcf DISPLAY_nreset
|
|
960 WAIT10US d'2'
|
|
961 bsf DISPLAY_nreset
|
|
962 WAITMS d'10'
|
|
963
|
|
964 movlw 0x24 ; 80-System 8-Bit Mode
|
|
965 rcall DISP_CmdWrite
|
|
966
|
|
967 movlw 0x02 ; RGB Interface Control (S6E63D6 Datasheet page 42)
|
|
968 rcall DISP_CmdWrite
|
|
969 movlw 0x00 ; X X X X X X X RM
|
|
970 rcall DISP_DataWrite
|
|
971 movlw 0x00 ; DM X RIM1 RIM0 VSPL HSPL EPL DPL
|
|
972 rcall DISP_DataWrite ; System Interface: RIM is ignored, Internal Clock
|
|
973
|
|
974 movlw 0x03 ; Entry Mode (S6E63D6 Datasheet page 46)
|
|
975 rcall DISP_CmdWrite
|
|
976 movlw 0x00 ; CLS MDT1 MDT0 BGR X X X SS 65k Color
|
|
977 rcall DISP_DataWrite
|
|
978
|
|
979 ; Change direction for block-writes of pixels
|
|
980 lfsr FSR0,win_flags
|
684
|
981 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM
|
681
|
982 btfss INDF0,0 ; BANK-SAFE bit test.
|
|
983 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM
|
|
984 rcall DISP_DataWrite
|
|
985
|
|
986 movlw 0x18
|
|
987 rcall DISP_CmdWrite
|
|
988 movlw 0x00
|
|
989 rcall DISP_DataWrite
|
|
990 movlw 0x28
|
|
991 rcall DISP_DataWrite
|
|
992
|
|
993 movlw 0xF8
|
|
994 rcall DISP_CmdWrite
|
|
995 movlw 0x00
|
|
996 rcall DISP_DataWrite
|
|
997 movlw 0x0F
|
|
998 rcall DISP_DataWrite
|
|
999
|
|
1000 movlw 0xF9
|
|
1001 rcall DISP_CmdWrite
|
|
1002 movlw 0x00
|
|
1003 rcall DISP_DataWrite
|
|
1004 movlw 0x0F
|
|
1005 rcall DISP_DataWrite
|
|
1006
|
|
1007 movlw 0x10
|
|
1008 rcall DISP_CmdWrite
|
|
1009 movlw 0x00
|
|
1010 rcall DISP_DataWrite
|
|
1011 movlw 0x00
|
|
1012 rcall DISP_DataWrite
|
|
1013
|
|
1014 ; Now Gamma settings...
|
|
1015 rcall DISP_brightness_full
|
|
1016 ;rcall DISP_brightness_low
|
|
1017 ; End Gamma Settings
|
|
1018
|
|
1019 rcall DISP_ClearScreen
|
|
1020
|
|
1021 bsf DISPLAY_hv
|
|
1022 WAITMS d'32'
|
|
1023 bsf DISPLAY_hv
|
|
1024 WAITMS d'32'
|
|
1025 bsf DISPLAY_hv
|
|
1026
|
|
1027 movlw 0x05
|
|
1028 rcall DISP_CmdWrite
|
|
1029 movlw 0x00
|
|
1030 rcall DISP_DataWrite
|
|
1031 movlw 0x01
|
|
1032 rcall DISP_DataWrite ; Display ON
|
|
1033 return
|
|
1034
|
|
1035
|
|
1036 DISP_brightness_full: ; Choose between Eco and High...
|
|
1037 btfsc DISPLAY_brightness_high ; DISPLAY brightness (=0: Eco, =1: High)
|
|
1038 bra DISP_brightness_full_high
|
|
1039 ; Mid
|
|
1040 bsf PORTB,7
|
|
1041 bcf PORTB,6
|
|
1042
|
|
1043 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
1044 btfsc WREG,1 ; Display1?
|
|
1045 return ; Yes, done.
|
|
1046
|
|
1047 movlw 0x70
|
|
1048 rcall DISP_CmdWrite
|
|
1049 movlw 0x1B
|
|
1050 rcall DISP_DataWrite
|
|
1051 movlw 0x80
|
|
1052 rcall DISP_DataWrite
|
|
1053 movlw 0x71
|
|
1054 rcall DISP_CmdWrite
|
|
1055 movlw 0x1F
|
|
1056 rcall DISP_DataWrite
|
|
1057 movlw 0x00
|
|
1058 rcall DISP_DataWrite
|
|
1059 movlw 0x72
|
|
1060 rcall DISP_CmdWrite
|
|
1061 movlw 0x22
|
|
1062 rcall DISP_DataWrite
|
|
1063 movlw 0x00
|
|
1064 rcall DISP_DataWrite
|
|
1065
|
|
1066 movlw 0x73
|
|
1067 rcall DISP_CmdWrite
|
|
1068 movlw 0x17
|
|
1069 rcall DISP_DataWrite
|
|
1070 movlw 0x11
|
|
1071 rcall DISP_DataWrite
|
|
1072 movlw 0x74
|
|
1073 rcall DISP_CmdWrite
|
|
1074 movlw 0x1A
|
|
1075 rcall DISP_DataWrite
|
|
1076 movlw 0x0E
|
|
1077 rcall DISP_DataWrite
|
|
1078
|
|
1079 movlw 0x75
|
|
1080 rcall DISP_CmdWrite
|
|
1081 movlw 0x1D
|
|
1082 rcall DISP_DataWrite
|
|
1083 movlw 0x15
|
|
1084 rcall DISP_DataWrite
|
|
1085 movlw 0x76
|
|
1086 rcall DISP_CmdWrite
|
|
1087 movlw 0x18
|
|
1088 rcall DISP_DataWrite
|
|
1089 movlw 0x11
|
|
1090 rcall DISP_DataWrite
|
|
1091
|
|
1092 movlw 0x77
|
|
1093 rcall DISP_CmdWrite
|
|
1094 movlw 0x1E
|
|
1095 rcall DISP_DataWrite
|
|
1096 movlw 0x18
|
|
1097 rcall DISP_DataWrite
|
|
1098 movlw 0x78
|
|
1099 rcall DISP_CmdWrite
|
|
1100 movlw 0x1D
|
|
1101 rcall DISP_DataWrite
|
|
1102 movlw 0x11
|
|
1103 rcall DISP_DataWrite
|
|
1104 return
|
|
1105
|
|
1106 DISP_brightness_full_high:
|
|
1107 ; Full
|
|
1108 bsf PORTB,7
|
|
1109 bsf PORTB,6
|
|
1110
|
|
1111 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
1112 btfsc WREG,1 ; Display1?
|
|
1113 return ; Yes, done.
|
|
1114
|
|
1115 movlw 0x70
|
|
1116 rcall DISP_CmdWrite
|
|
1117 movlw 0x1F
|
|
1118 rcall DISP_DataWrite
|
|
1119 movlw 0x00
|
|
1120 rcall DISP_DataWrite
|
|
1121 movlw 0x71
|
|
1122 rcall DISP_CmdWrite
|
|
1123 movlw 0x23
|
|
1124 rcall DISP_DataWrite
|
|
1125 movlw 0x80
|
|
1126 rcall DISP_DataWrite
|
|
1127 movlw 0x72
|
|
1128 rcall DISP_CmdWrite
|
|
1129 movlw 0x2A
|
|
1130 rcall DISP_DataWrite
|
|
1131 movlw 0x80
|
|
1132 rcall DISP_DataWrite
|
|
1133
|
|
1134 movlw 0x73
|
|
1135 rcall DISP_CmdWrite
|
|
1136 movlw 0x15
|
|
1137 rcall DISP_DataWrite
|
|
1138 movlw 0x11
|
|
1139 rcall DISP_DataWrite
|
|
1140 movlw 0x74
|
|
1141 rcall DISP_CmdWrite
|
|
1142 movlw 0x1C
|
|
1143 rcall DISP_DataWrite
|
|
1144 movlw 0x11
|
|
1145 rcall DISP_DataWrite
|
|
1146
|
|
1147 movlw 0x75
|
|
1148 rcall DISP_CmdWrite
|
|
1149 movlw 0x1B
|
|
1150 rcall DISP_DataWrite
|
|
1151 movlw 0x15
|
|
1152 rcall DISP_DataWrite
|
|
1153 movlw 0x76
|
|
1154 rcall DISP_CmdWrite
|
|
1155 movlw 0x1A
|
|
1156 rcall DISP_DataWrite
|
|
1157 movlw 0x15
|
|
1158 rcall DISP_DataWrite
|
|
1159
|
|
1160 movlw 0x77
|
|
1161 rcall DISP_CmdWrite
|
|
1162 movlw 0x1C
|
|
1163 rcall DISP_DataWrite
|
|
1164 movlw 0x18
|
|
1165 rcall DISP_DataWrite
|
|
1166 movlw 0x78
|
|
1167 rcall DISP_CmdWrite
|
|
1168 movlw 0x21
|
|
1169 rcall DISP_DataWrite
|
|
1170 movlw 0x15
|
|
1171 rcall DISP_DataWrite
|
|
1172 return
|
|
1173
|
|
1174
|
|
1175 DISP_brightness_low:
|
|
1176 ;Low
|
|
1177 bcf PORTB,7
|
|
1178 bcf PORTB,6
|
|
1179 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
1180 btfsc WREG,1 ; Display1?
|
|
1181 return ; Yes, done.
|
|
1182
|
|
1183 movlw 0x70
|
|
1184 rcall DISP_CmdWrite
|
|
1185 movlw 0x14
|
|
1186 rcall DISP_DataWrite
|
|
1187 movlw 0x00
|
|
1188 rcall DISP_DataWrite
|
|
1189 movlw 0x71
|
|
1190 rcall DISP_CmdWrite
|
|
1191 movlw 0x17
|
|
1192 rcall DISP_DataWrite
|
|
1193 movlw 0x00
|
|
1194 rcall DISP_DataWrite
|
|
1195 movlw 0x72
|
|
1196 rcall DISP_CmdWrite
|
|
1197 movlw 0x15
|
|
1198 rcall DISP_DataWrite
|
|
1199 movlw 0x80
|
|
1200 rcall DISP_DataWrite
|
|
1201
|
|
1202 movlw 0x73
|
|
1203 rcall DISP_CmdWrite
|
|
1204 movlw 0x15
|
|
1205 rcall DISP_DataWrite
|
|
1206 movlw 0x11
|
|
1207 rcall DISP_DataWrite
|
|
1208 movlw 0x74
|
|
1209 rcall DISP_CmdWrite
|
|
1210 movlw 0x14
|
|
1211 rcall DISP_DataWrite
|
|
1212 movlw 0x0B
|
|
1213 rcall DISP_DataWrite
|
|
1214
|
|
1215 movlw 0x75
|
|
1216 rcall DISP_CmdWrite
|
|
1217 movlw 0x1B
|
|
1218 rcall DISP_DataWrite
|
|
1219 movlw 0x15
|
|
1220 rcall DISP_DataWrite
|
|
1221 movlw 0x76
|
|
1222 rcall DISP_CmdWrite
|
|
1223 movlw 0x13
|
|
1224 rcall DISP_DataWrite
|
|
1225 movlw 0x0E
|
|
1226 rcall DISP_DataWrite
|
|
1227
|
|
1228 movlw 0x77
|
|
1229 rcall DISP_CmdWrite
|
|
1230 movlw 0x1C
|
|
1231 rcall DISP_DataWrite
|
|
1232 movlw 0x18
|
|
1233 rcall DISP_DataWrite
|
|
1234 movlw 0x78
|
|
1235 rcall DISP_CmdWrite
|
|
1236 movlw 0x15
|
|
1237 rcall DISP_DataWrite
|
|
1238 movlw 0x0E
|
|
1239 rcall DISP_DataWrite
|
|
1240
|
|
1241 return
|
|
1242
|
|
1243 DISP_set_color:;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGG GGGBBBBB'
|
|
1244 movwf DISPLAY1_temp ; Get 8Bit RGB b'RRRGGGBB'
|
|
1245 movwf DISPLAY2_temp ; Copy
|
|
1246
|
|
1247 movff win_flags,WREG ; Display1? win_flags is in bank0...
|
|
1248 btfsc WREG,1 ; Display1?
|
|
1249 bra DISP_set_color_display1 ; Yes
|
|
1250
|
|
1251 ; Display0
|
|
1252 ; Mask Bit 7,6,5,4,3,2
|
|
1253 movlw b'00000011'
|
|
1254 andwf DISPLAY2_temp,F
|
|
1255
|
|
1256 movlw b'00000000'
|
|
1257 dcfsnz DISPLAY2_temp,F
|
|
1258 movlw b'01010000'
|
|
1259 dcfsnz DISPLAY2_temp,F
|
|
1260 movlw b'10100000'
|
|
1261 dcfsnz DISPLAY2_temp,F
|
|
1262 movlw b'11111000'
|
|
1263 movwf DISPLAY3_temp ; Blue done.
|
|
1264
|
|
1265 movff DISPLAY1_temp, DISPLAY2_temp ; Copy
|
|
1266 ; Mask Bit 7,6,5,1,0
|
|
1267 movlw b'00011100'
|
|
1268 andwf DISPLAY2_temp,F
|
|
1269 rrncf DISPLAY2_temp,F
|
|
1270 rrncf DISPLAY2_temp,F
|
|
1271
|
|
1272 movlw b'00000000'
|
|
1273 dcfsnz DISPLAY2_temp,F
|
|
1274 movlw b'00000100'
|
|
1275 dcfsnz DISPLAY2_temp,F
|
|
1276 movlw b'00001000'
|
|
1277 dcfsnz DISPLAY2_temp,F
|
|
1278 movlw b'00001100'
|
|
1279 dcfsnz DISPLAY2_temp,F
|
|
1280 movlw b'00010000'
|
|
1281 dcfsnz DISPLAY2_temp,F
|
|
1282 movlw b'00010100'
|
|
1283 dcfsnz DISPLAY2_temp,F
|
|
1284 movlw b'00100000'
|
|
1285 dcfsnz DISPLAY2_temp,F
|
|
1286 movlw b'00111111'
|
|
1287 movwf DISPLAY4_temp
|
|
1288
|
|
1289 rrcf DISPLAY4_temp,F
|
|
1290 rrcf DISPLAY3_temp,F
|
|
1291
|
|
1292 rrcf DISPLAY4_temp,F
|
|
1293 rrcf DISPLAY3_temp,F
|
|
1294
|
|
1295 rrcf DISPLAY4_temp,F
|
|
1296 rrcf DISPLAY3_temp,F ; DISPLAY3_temp (b'GGGBBBBB') done.
|
|
1297
|
|
1298 movff DISPLAY1_temp, DISPLAY2_temp ; Copy
|
|
1299 clrf DISPLAY1_temp
|
|
1300
|
|
1301 rrcf DISPLAY4_temp,F
|
|
1302 rrcf DISPLAY1_temp,F
|
|
1303
|
|
1304 rrcf DISPLAY4_temp,F
|
|
1305 rrcf DISPLAY1_temp,F
|
|
1306
|
|
1307 rrcf DISPLAY4_temp,F
|
|
1308 rrcf DISPLAY1_temp,F ; Green done.
|
|
1309
|
|
1310 ; Mask Bit 4,3,2,1,0
|
|
1311 movlw b'11100000'
|
|
1312 andwf DISPLAY2_temp,F
|
|
1313
|
|
1314 rrncf DISPLAY2_temp,F
|
|
1315 rrncf DISPLAY2_temp,F
|
|
1316 rrncf DISPLAY2_temp,F
|
|
1317 rrncf DISPLAY2_temp,F
|
|
1318 rrncf DISPLAY2_temp,F
|
|
1319
|
|
1320 movlw b'00000000'
|
|
1321 dcfsnz DISPLAY2_temp,F
|
|
1322 movlw b'00000100'
|
|
1323 dcfsnz DISPLAY2_temp,F
|
|
1324 movlw b'00001000'
|
|
1325 dcfsnz DISPLAY2_temp,F
|
|
1326 movlw b'00001100'
|
|
1327 dcfsnz DISPLAY2_temp,F
|
|
1328 movlw b'00010000'
|
|
1329 dcfsnz DISPLAY2_temp,F
|
|
1330 movlw b'00010100'
|
|
1331 dcfsnz DISPLAY2_temp,F
|
|
1332 movlw b'00100000'
|
|
1333 dcfsnz DISPLAY2_temp,F
|
|
1334 movlw b'00111111'
|
|
1335 movwf DISPLAY4_temp
|
|
1336
|
|
1337 rrcf DISPLAY4_temp,F
|
|
1338 rrcf DISPLAY1_temp,F
|
|
1339
|
|
1340 rrcf DISPLAY4_temp,F
|
|
1341 rrcf DISPLAY1_temp,F
|
|
1342
|
|
1343 rrcf DISPLAY4_temp,F
|
|
1344 rrcf DISPLAY1_temp,F
|
|
1345
|
|
1346 rrcf DISPLAY4_temp,F
|
|
1347 rrcf DISPLAY1_temp,F
|
|
1348
|
|
1349 rrcf DISPLAY4_temp,F
|
|
1350 rrcf DISPLAY1_temp,F ; Red done.
|
|
1351
|
|
1352 movff DISPLAY1_temp,win_color1
|
|
1353 movff DISPLAY3_temp,win_color2 ; Set Bank0 Color registers...
|
|
1354 return
|
|
1355
|
684
|
1356 DISP_set_color_display1:;Converts 8Bit RGB b'RRRGGGBB' into 24Bit RGB b'00RRRRRR 00GGGGGG 00BBBBBB'
|
681
|
1357 ; Mask Bit 7,6,5,4,3,2
|
|
1358 movlw b'00000011'
|
|
1359 andwf DISPLAY2_temp,F
|
|
1360
|
|
1361 movlw b'00000000'
|
|
1362 dcfsnz DISPLAY2_temp,F
|
|
1363 movlw b'01010000'
|
|
1364 dcfsnz DISPLAY2_temp,F
|
|
1365 movlw b'10100000'
|
|
1366 dcfsnz DISPLAY2_temp,F
|
|
1367 movlw b'11111000'
|
|
1368 movff WREG,win_color3 ; B
|
|
1369
|
|
1370 movff DISPLAY1_temp, DISPLAY2_temp ; Copy
|
|
1371 ; Mask Bit 7,6,5,1,0
|
|
1372 movlw b'00011100'
|
|
1373 andwf DISPLAY2_temp,F
|
|
1374 rrncf DISPLAY2_temp,F
|
|
1375 rrncf DISPLAY2_temp,F
|
|
1376
|
|
1377 movlw b'00000000'
|
|
1378 dcfsnz DISPLAY2_temp,F
|
|
1379 movlw b'00010000'
|
|
1380 dcfsnz DISPLAY2_temp,F
|
|
1381 movlw b'00100000'
|
|
1382 dcfsnz DISPLAY2_temp,F
|
|
1383 movlw b'00110000'
|
|
1384 dcfsnz DISPLAY2_temp,F
|
|
1385 movlw b'01000000'
|
|
1386 dcfsnz DISPLAY2_temp,F
|
|
1387 movlw b'01010000'
|
|
1388 dcfsnz DISPLAY2_temp,F
|
|
1389 movlw b'10000000'
|
|
1390 dcfsnz DISPLAY2_temp,F
|
|
1391 movlw b'11111100'
|
|
1392 movff WREG,win_color2 ; G
|
|
1393
|
|
1394 ; Mask Bit 4,3,2,1,0
|
|
1395 movlw b'11100000'
|
684
|
1396 andwf DISPLAY1_temp,F
|
681
|
1397
|
684
|
1398 rrncf DISPLAY1_temp,F
|
|
1399 rrncf DISPLAY1_temp,F
|
|
1400 rrncf DISPLAY1_temp,F
|
|
1401 rrncf DISPLAY1_temp,F
|
|
1402 rrncf DISPLAY1_temp,F
|
681
|
1403
|
|
1404 movlw b'00000000'
|
684
|
1405 dcfsnz DISPLAY1_temp,F
|
681
|
1406 movlw b'00010000'
|
684
|
1407 dcfsnz DISPLAY1_temp,F
|
681
|
1408 movlw b'00100000'
|
684
|
1409 dcfsnz DISPLAY1_temp,F
|
681
|
1410 movlw b'00110000'
|
684
|
1411 dcfsnz DISPLAY1_temp,F
|
681
|
1412 movlw b'01000000'
|
684
|
1413 dcfsnz DISPLAY1_temp,F
|
681
|
1414 movlw b'01010000'
|
684
|
1415 dcfsnz DISPLAY1_temp,F
|
681
|
1416 movlw b'10000000'
|
684
|
1417 dcfsnz DISPLAY1_temp,F
|
681
|
1418 movlw b'11111100'
|
|
1419 movff WREG,win_color1 ; R
|
|
1420 return
|