Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/display_lowlevel.asm @ 707:2129862bbfe6
correct a typo
author | heinrichsweikamp |
---|---|
date | Wed, 17 Apr 2013 19:52:08 +0200 |
parents | d68c6a6b1f38 |
children | 71bb907d0ce5 |
rev | line source |
---|---|
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 | |
707 | 68 INIT_PIXEL_WRITE macro colRegister |
681 | 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! | |
706 | 236 movff win_color4, PORTD |
684 | 237 bcf DISPLAY_rw |
238 bsf DISPLAY_rw ; Upper | |
706 | 239 movff win_color5, PORTD |
684 | 240 bcf DISPLAY_rw |
241 bsf DISPLAY_rw ; High | |
706 | 242 movff win_color6, PORTD |
681 | 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 | |
693 | 258 bcf DISPLAY_rs |
681 | 259 bcf DISPLAY_nreset |
260 return | |
261 | |
262 ;============================================================================= | |
263 ; Fast macros to write to DISPLAY display. | |
264 ; Adding a call/return adds 3 words and a pipeline flush, hence make it | |
265 ; nearly twice slower... | |
266 ; | |
267 ; Input : commande as macro parameter. | |
268 ; Output : NONE | |
269 ; Trash : WREG | |
270 ; | |
271 AA_CMD_WRITE macro cmd | |
272 movlw cmd | |
273 rcall DISP_CmdWrite ; slow but saves a lot of bytes in flash | |
274 endm | |
275 ; | |
276 ; Input : data as macro parameter. | |
277 ; Output : NONE | |
278 ; Trash : WREG | |
279 ; | |
280 AA_DATA_WRITE macro data | |
281 movlw data | |
282 rcall DISP_DataWrite | |
283 endm | |
284 ; | |
285 ; Input : PRODH:L as 16bits data. | |
286 ; Output : NONE | |
287 ; Trash : NONE | |
288 ; | |
289 AA_DATA_WRITE_PROD macro | |
290 rcall DISP_DataWrite_PROD ; slow but saves a lot of bytes in flash | |
291 endm | |
292 | |
293 ;============================================================================= | |
294 ; Output DISPLAY Window Address commands. | |
295 ; Inputs : win_top, win_leftx2, win_height, aa_width. | |
296 ; Output : PortD commands. | |
297 ; Trashed: PROD | |
298 ; | |
299 DISP_box_write: | |
300 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
301 btfsc WREG,1 ; Display1? | |
302 bra DISP_box_write_display1 ; Yes | |
303 | |
304 movff win_leftx2,WREG ; Compute left = 2*leftx2 --> PROD | |
305 mullw 2 | |
306 | |
307 movff win_flags,WREG ; BEWARE: bank0 bit-test | |
308 btfsc WREG,0 ; 180° rotation ? | |
309 bra DISP_box_flip_H ; YES: | |
310 | |
311 ;---- Normal horizontal window --------------------------------------- | |
312 ; Output 0x35 left, | |
313 ; 0x36 right == left + width - 1. | |
314 AA_CMD_WRITE 0x35 ; this is the left border | |
315 AA_DATA_WRITE_PROD ; Output left | |
316 AA_CMD_WRITE 0x21 ; Also the horizontal first pix coord. | |
317 AA_DATA_WRITE_PROD | |
318 | |
319 movf aa_width+0,W,ACCESS ; right = left + width - 1 | |
320 addwf PRODL,F | |
321 movf aa_width+1,W,ACCESS | |
322 addwfc PRODH,F | |
323 decf PRODL,F,A ; decrement result | |
324 btfss STATUS,C | |
325 decf PRODH,F,A | |
326 | |
327 AA_CMD_WRITE 0x36 ; Write and the right border | |
328 AA_DATA_WRITE_PROD | |
329 | |
330 bra DISP_box_noflip_H | |
331 | |
332 ;---- Flipped horizontal window -------------------------------------- | |
333 DISP_box_flip_H: | |
334 ; Output 0x36 flipped(left) = 319-left | |
335 ; 0x35 flipped(right) = 319-right = 320 - left - width | |
336 movf PRODL,W ; 16bits 319 - PROD --> PROD | |
337 sublw LOW(.319) ; 319-W --> W | |
338 movwf PRODL | |
339 movf PRODH,W | |
340 btfss STATUS,C ; Borrow = /CARRY | |
341 incf WREG | |
342 sublw HIGH(.319) | |
343 movwf PRODH | |
344 AA_CMD_WRITE 0x36 ; this is the left border | |
345 AA_DATA_WRITE_PROD ; Output left | |
346 AA_CMD_WRITE 0x21 | |
347 AA_DATA_WRITE_PROD | |
348 | |
349 movf aa_width+0,W ; 16bits PROD - width --> PROD | |
350 subwf PRODL,F ; PRODL - WREG --> PRODL | |
351 movf aa_width+1,W | |
352 subwfb PRODH,F | |
353 infsnz PRODL ; PROD+1 --> PROD | |
354 incf PRODH | |
355 AA_CMD_WRITE 0x35 ; this is the left border | |
356 AA_DATA_WRITE_PROD ; Output left | |
357 | |
358 DISP_box_noflip_H: | |
359 movff win_flags,WREG ; BEWARE: bank0 bit-test | |
360 btfsc WREG,0 ; 180° rotation ? | |
361 bra DISP_box_flip_V | |
362 | |
363 ;---- Normal vertical window ----------------------------------------- | |
364 ; Output 0x37 (top) (bottom) | |
365 movff win_top,PRODH ; top --> PRODH (first byte) | |
366 movff win_height,WREG | |
367 addwf PRODH,W | |
368 decf WREG | |
369 movwf PRODL ; top+height-1 --> PRODL (second byte) | |
370 | |
371 AA_CMD_WRITE 0x37 | |
372 AA_DATA_WRITE_PROD | |
373 | |
374 movff PRODH,PRODL | |
375 clrf PRODH ; Start pixel V coord == top. | |
376 AA_CMD_WRITE 0x20 | |
377 AA_DATA_WRITE_PROD | |
378 | |
379 return | |
380 | |
381 ;---- Flipped vertical window ---------------------------------------- | |
382 ; Output 0x37 flipped(bottom) = 239-bottom = 240 - top - height | |
383 ; flipped(top) = 239-top | |
384 DISP_box_flip_V: | |
385 movff win_top,PRODL | |
386 movff win_height,WREG | |
387 addwf PRODL,W | |
388 sublw .240 ; 240 - top - height | |
389 movwf PRODH ; First byte | |
390 | |
391 movf PRODL,W | |
392 sublw .239 ; 249-top | |
393 movwf PRODL ; --> second byte. | |
394 | |
395 AA_CMD_WRITE 0x37 | |
396 AA_DATA_WRITE_PROD | |
397 | |
398 clrf PRODH ; Start pixel V coord. | |
399 AA_CMD_WRITE 0x20 | |
400 AA_DATA_WRITE_PROD | |
401 | |
402 return | |
403 | |
404 DISP_box_write_display1: | |
405 movff win_leftx2,WREG ; Compute left = 2*leftx2 --> PROD | |
406 mullw 2 | |
407 | |
408 movlw 0x06 | |
409 rcall DISP_CmdWrite | |
410 movf PRODH,W | |
411 rcall DISP_DataWrite | |
412 movlw 0x07 | |
413 rcall DISP_CmdWrite | |
414 movf PRODL,W | |
415 rcall DISP_DataWrite | |
416 | |
417 movf aa_width+0,W,ACCESS ; right = left + width - 1 | |
418 addwf PRODL,F | |
419 movf aa_width+1,W,ACCESS | |
420 addwfc PRODH,F | |
421 decf PRODL,F,A ; decrement result | |
422 btfss STATUS,C | |
423 decf PRODH,F,A | |
424 | |
425 movlw 0x08 | |
426 rcall DISP_CmdWrite | |
427 movf PRODH,W | |
428 rcall DISP_DataWrite | |
429 movlw 0x09 | |
430 rcall DISP_CmdWrite | |
431 movf PRODL,W | |
432 rcall DISP_DataWrite | |
433 | |
434 ;---- Normal vertical window ----------------------------------------- | |
684 | 435 ; Output (top) (bottom) |
681 | 436 movff win_top,PRODH ; top --> PRODH (first byte) |
437 movff win_height,WREG | |
438 addwf PRODH,W | |
439 decf WREG | |
440 movwf PRODL ; top+height-1 --> PRODL (second byte) | |
441 | |
442 movlw 0x02 | |
443 rcall DISP_CmdWrite | |
444 movlw 0x00 | |
445 rcall DISP_DataWrite | |
446 movlw 0x03 | |
447 rcall DISP_CmdWrite | |
448 movf PRODH,W | |
449 rcall DISP_DataWrite | |
450 | |
451 movlw 0x04 | |
452 rcall DISP_CmdWrite | |
453 movlw 0x00 | |
454 rcall DISP_DataWrite | |
455 movlw 0x05 | |
456 rcall DISP_CmdWrite | |
457 movf PRODL,W | |
458 rcall DISP_DataWrite | |
459 return | |
460 | |
461 ;============================================================================= | |
462 ; DISP_frame : draw a frame around current box with current color. | |
463 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
464 ; Outputs: (none) | |
465 ; Trashed: WREG, PROD, aa_start:2, aa_end:2, win_leftx2, win_width:1 | |
466 global DISP_frame | |
467 DISP_frame: | |
468 movff win_top,aa_start+0 ; Backup everything. | |
469 movff win_height,aa_start+1 | |
470 movff win_leftx2,aa_end+0 | |
471 movff win_width,aa_end+1 | |
472 | |
473 ;---- TOP line ----------------------------------------------------------- | |
474 movlw 1 ; row ~ height=1 | |
475 movff WREG,win_height | |
476 rcall DISP_box | |
477 | |
478 ;---- BOTTOM line -------------------------------------------------------- | |
479 movff aa_start+0,PRODL ; Get back top, | |
480 movff aa_start+1,WREG ; and height | |
481 addwf PRODL,W ; top+height | |
482 decf WREG ; top+height-1 | |
483 movff WREG,win_top ; top+height-1 --> top | |
484 rcall DISP_box | |
485 | |
486 ;---- LEFT column -------------------------------------------------------- | |
487 movff aa_start+0,win_top ; Restore top/height. | |
488 movff aa_start+1,win_height | |
489 movlw 1 ; column ~ width=1 | |
490 movff WREG,win_width | |
491 rcall DISP_box | |
492 | |
493 ;---- RIGHT column ------------------------------------------------------- | |
494 movff aa_end+0,WREG | |
495 movff aa_end+1,PRODL | |
496 addwf PRODL,W | |
497 decf WREG | |
498 movff WREG,win_leftx2 | |
499 bra DISP_box | |
500 | |
501 ;============================================================================= | |
502 ; DISP_box : fills current box with current color. | |
503 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
504 ; Outputs: (none) | |
505 ; Trashed: WREG, PROD | |
506 | |
507 global DISP_box | |
508 DISP_box: | |
509 ;---- Define Window ------------------------------------------------------ | |
510 movff win_width,WREG | |
511 bcf STATUS,C | |
512 rlcf WREG | |
513 movwf aa_width+0 | |
514 movlw 0 | |
515 rlcf WREG | |
516 movwf aa_width+1 | |
517 rcall DISP_box_write | |
518 | |
519 ;---- Fill Window -------------------------------------------------------- | |
520 movlw 0x22 ; Start Writing Data to GRAM | |
521 rcall DISP_CmdWrite | |
522 | |
523 clrf PRODH ; Column counter. | |
524 bsf DISPLAY_rs ; Data! | |
525 | |
526 DISP_box2: ; Loop height times | |
527 movff win_height,PRODL | |
528 | |
529 DISP_box3: ; loop width times | |
706 | 530 movff win_flags,WREG ; Display1? win_flags is in bank0... |
531 btfsc WREG,1 ; Display1? | |
532 bra DISP_box3aa ; Yes | |
533 | |
681 | 534 movff win_color1,PORTD |
535 bcf DISPLAY_rw | |
684 | 536 bsf DISPLAY_rw ; Upper |
681 | 537 movff win_color2,PORTD |
706 | 538 bra DISP_box3a ; Done. |
539 DISP_box3aa: | |
540 movff win_color4,PORTD | |
541 bcf DISPLAY_rw | |
542 bsf DISPLAY_rw ; Upper | |
543 movff win_color5,PORTD | |
681 | 544 bcf DISPLAY_rw |
684 | 545 bsf DISPLAY_rw ; Lower/High |
706 | 546 movff win_color6,PORTD |
681 | 547 |
548 DISP_box3a: | |
706 | 549 bcf DISPLAY_rw |
550 bsf DISPLAY_rw ; Lower/High | |
551 | |
552 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
553 btfsc WREG,1 ; Display1? | |
554 bra DISP_box3ab ; Yes | |
555 | |
681 | 556 movff win_color1,PORTD |
557 bcf DISPLAY_rw | |
684 | 558 bsf DISPLAY_rw ; Upper |
681 | 559 movff win_color2,PORTD |
706 | 560 bra DISP_box3b |
561 | |
562 DISP_box3ab: | |
563 movff win_color4,PORTD | |
681 | 564 bcf DISPLAY_rw |
706 | 565 bsf DISPLAY_rw ; Upper |
566 movff win_color5,PORTD | |
567 bcf DISPLAY_rw | |
568 bsf DISPLAY_rw ; High | |
569 movff win_color6,PORTD | |
570 | |
571 DISP_box3b: | |
681 | 572 bcf DISPLAY_rw |
684 | 573 bsf DISPLAY_rw ; Lower |
681 | 574 decfsz PRODL,F ; row loop finished ? |
575 bra DISP_box3 ; No: continue. | |
576 | |
577 incf PRODH,F ; column count ++ | |
578 | |
579 movff win_bargraph,WREG ; current column == bargraph ? | |
580 cpfseq PRODH | |
581 bra DISP_box4 ; No: just loop. | |
582 | |
583 clrf WREG ; Yes: switch to black | |
584 movff WREG,win_color1 | |
585 movff WREG,win_color2 | |
706 | 586 movff WREG,win_color3 |
587 movff WREG,win_color4 | |
588 movff WREG,win_color5 | |
589 movff WREG,win_color6 | |
681 | 590 DISP_box4: |
591 movff win_width,WREG | |
592 cpfseq PRODH | |
593 bra DISP_box2 | |
594 | |
595 setf WREG ; Reset bargraph mode... | |
596 movff WREG,win_bargraph | |
597 | |
598 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
599 btfsc WREG,1 ; Display1? | |
600 return ; Yes, done. | |
601 | |
602 movlw 0x00 ; NOP, to stop window mode | |
603 bra DISP_CmdWrite ; Returns.... | |
604 | |
605 ;============================================================================= | |
606 ; DISP_ClearScreen: An optimized version of PLEX_box, for full screen black. | |
607 ; Trashed: WREG, PROD | |
608 | |
609 global DISP_ClearScreen | |
610 DISP_ClearScreen: | |
611 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
612 btfsc WREG,1 ; Display1? | |
613 bra DISP_ClearScreen_display1; Yes | |
614 | |
615 movlw 0x35 ; VerticalStartAddress HIGH:LOW | |
616 rcall DISP_CmdWrite | |
617 mullw 0 | |
618 rcall DISP_DataWrite_PROD | |
619 | |
620 movlw 0x36 ; VerticalEndAddress HIGH:LOW | |
621 rcall DISP_CmdWrite | |
622 movlw 0x01 | |
623 rcall DISP_DataWrite | |
624 movlw 0x3F | |
625 rcall DISP_DataWrite | |
626 | |
627 movlw 0x37 ; HorizontalAddress START:END | |
628 rcall DISP_CmdWrite | |
629 movlw 0x00 | |
630 rcall DISP_DataWrite | |
631 movlw 0xEF | |
632 rcall DISP_DataWrite | |
633 | |
634 movlw 0x20 ; Start Address Horizontal (.0 - .239) | |
635 rcall DISP_CmdWrite | |
636 rcall DISP_DataWrite_PROD | |
637 | |
638 movlw 0x21 ; Start Address Vertical (.0 - .319) | |
639 rcall DISP_CmdWrite | |
640 rcall DISP_DataWrite_PROD | |
641 | |
642 movlw 0x22 ; Start Writing Data to GRAM | |
643 rcall DISP_CmdWrite | |
644 | |
645 ; See Page 101 of DISPLAY Driver IC Datasheet how to handle rs/rw clocks | |
646 bsf DISPLAY_rs ; Data! | |
684 | 647 clrf PORTD |
681 | 648 movlw .160 |
649 movwf PRODH | |
650 DISP_ClearScreen2: | |
651 movlw .240 | |
652 movwf PRODL | |
653 DISP_ClearScreen3: | |
654 bcf DISPLAY_rw | |
655 bsf DISPLAY_rw ; Upper | |
656 bcf DISPLAY_rw | |
657 bsf DISPLAY_rw ; Lower | |
658 bcf DISPLAY_rw | |
659 bsf DISPLAY_rw ; Upper | |
660 bcf DISPLAY_rw | |
661 bsf DISPLAY_rw ; Lower | |
662 decfsz PRODL,F | |
663 bra DISP_ClearScreen3 | |
664 decfsz PRODH,F | |
665 bra DISP_ClearScreen2 | |
666 movlw 0x00 ; NOP, to stop Address Update Counter | |
684 | 667 bra DISP_CmdWrite ; And return... |
681 | 668 |
669 DISP_ClearScreen_display1: | |
670 ; Column Address start | |
671 movlw 0x02 | |
672 rcall DISP_CmdWrite | |
673 movlw 0x00 | |
674 rcall DISP_DataWrite | |
675 movlw 0x03 | |
676 rcall DISP_CmdWrite | |
677 movlw 0x00 | |
678 rcall DISP_DataWrite | |
679 | |
680 ; Column Address end | |
681 movlw 0x04 | |
682 rcall DISP_CmdWrite | |
683 movlw 0x00 | |
684 rcall DISP_DataWrite | |
685 movlw 0x05 | |
686 rcall DISP_CmdWrite | |
687 movlw 0xEF | |
688 rcall DISP_DataWrite | |
689 | |
690 ; Row address start | |
691 movlw 0x06 | |
692 rcall DISP_CmdWrite | |
693 movlw 0x00 | |
694 rcall DISP_DataWrite | |
695 movlw 0x07 | |
696 rcall DISP_CmdWrite | |
697 movlw 0x00 | |
698 rcall DISP_DataWrite | |
699 | |
700 ; Row address end | |
701 movlw 0x08 | |
702 rcall DISP_CmdWrite | |
703 movlw 0x01 | |
704 rcall DISP_DataWrite | |
705 movlw 0x09 | |
706 rcall DISP_CmdWrite | |
707 movlw 0x3F | |
708 rcall DISP_DataWrite | |
709 | |
710 movlw 0x22 ; Start Writing Data to GRAM | |
711 rcall DISP_CmdWrite | |
712 | |
713 bsf DISPLAY_rs ; Data! | |
714 | |
715 movlw .160 | |
716 movwf PRODH | |
717 DISP_ClearScreen2_display1: | |
718 movlw .240 | |
719 movwf PRODL | |
684 | 720 clrf PORTD |
681 | 721 DISP_ClearScreen3_display1: |
722 bcf DISPLAY_rw | |
723 bsf DISPLAY_rw ; Upper | |
724 bcf DISPLAY_rw | |
725 bsf DISPLAY_rw ; High | |
726 bcf DISPLAY_rw | |
727 bsf DISPLAY_rw ; Lower | |
728 bcf DISPLAY_rw | |
729 bsf DISPLAY_rw ; Upper | |
730 bcf DISPLAY_rw | |
731 bsf DISPLAY_rw ; High | |
732 bcf DISPLAY_rw | |
733 bsf DISPLAY_rw ; Lower | |
734 decfsz PRODL,F | |
735 bra DISP_ClearScreen3_display1 | |
736 decfsz PRODH,F | |
737 bra DISP_ClearScreen2_display1 | |
738 return | |
739 | |
740 | |
741 ; ----------------------------- | |
742 ; DISP Write Cmd via W | |
743 ; ----------------------------- | |
744 DISP_CmdWrite: | |
745 bcf DISPLAY_rs ; Command! | |
746 movwf PORTD ; Move Data to PORTD | |
747 bcf DISPLAY_rw | |
748 bsf DISPLAY_rw | |
749 return | |
750 | |
751 ; ----------------------------- | |
752 ; DISP Write Display Data via W | |
753 ; ----------------------------- | |
754 DISP_DataWrite: | |
755 bsf DISPLAY_rs ; Data! | |
756 movwf PORTD ; Move Data to PORTD | |
757 bcf DISPLAY_rw | |
758 bsf DISPLAY_rw | |
759 return | |
760 | |
761 ; ----------------------------- | |
762 ; DISP Data Cmd via W | |
763 ; ----------------------------- | |
764 DISP_DataWrite_PROD: | |
765 bsf DISPLAY_rs ; Data! | |
766 movff PRODH,PORTD ; Move high byte to PORTD (DISPLAY is bigendian) | |
767 bcf DISPLAY_rw | |
768 bsf DISPLAY_rw | |
769 movff PRODL,PORTD ; Move low byte to PORTD | |
770 bcf DISPLAY_rw | |
771 bsf DISPLAY_rw | |
772 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
773 btfss WREG,1 ; Display1? | |
774 return ; No, done. | |
705 | 775 movff win_color3,PORTD ; Move low(est) byte to PORTD |
681 | 776 bcf DISPLAY_rw |
777 bsf DISPLAY_rw | |
778 return | |
779 | |
780 | |
781 ; ----------------------------- | |
782 ; DISP Read data into WREG | |
783 ; ----------------------------- | |
784 ; NOTE: you should "setf TRISD" before calling this function, | |
785 ; to make PortD an input port... | |
786 DISP_DataRead: | |
687
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
787 movff win_flags,WREG ; Display1? win_flags is in bank0... |
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
788 btfsc WREG,1 ; Display1? |
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
789 return ; Yes, done. |
681 | 790 bsf DISPLAY_rs ; Data register. |
791 bcf DISPLAY_e_nwr ; Read enable. | |
792 nop | |
793 nop | |
794 nop | |
795 nop | |
796 movf PORTD,W ; Read byte. | |
797 bsf DISPLAY_e_nwr ; release bus. | |
798 return | |
799 | |
800 ; ----------------------------- | |
801 ; DISP boot | |
802 ; ----------------------------- | |
803 DISPLAY_boot: | |
804 movlw LOW 0x17FDC | |
805 movwf TBLPTRL | |
806 movlw HIGH 0x17FDC | |
807 movwf TBLPTRH | |
808 movlw UPPER 0x17FDC | |
809 movwf TBLPTRU | |
810 TBLRD* | |
811 movlw 0x01 | |
812 cpfseq TABLAT ; Display1? | |
813 bra display0_init ; No, Display0 | |
814 | |
815 banksel win_flags | |
816 bsf win_flags,0 | |
817 bsf win_flags,1 | |
818 banksel flag1 | |
819 bcf DISPLAY_hv ; Backlight off | |
820 nop | |
821 bcf DISPLAY_vdd | |
822 WAITMS d'10' | |
823 bsf DISPLAY_vdd | |
824 WAITMS d'100' | |
825 bsf DISPLAY_rw | |
826 nop | |
827 bcf DISPLAY_cs | |
828 nop | |
829 bsf DISPLAY_nreset | |
830 WAITMS d'1' | |
831 bcf DISPLAY_nreset | |
832 WAIT10US d'2' | |
833 bsf DISPLAY_nreset | |
834 WAITMS d'120' | |
835 bsf DISPLAY_e_nwr ; release bus. | |
836 rcall display1_init ; Init sequence | |
837 rcall DISP_ClearScreen | |
838 WAITMS d'60' | |
839 bsf DISPLAY_hv ; Backlight on | |
840 return | |
841 | |
842 display1_init: | |
843 movlw LOW display1_config_table | |
844 movwf TBLPTRL | |
845 movlw HIGH display1_config_table | |
846 movwf TBLPTRH | |
847 movlw UPPER display1_config_table | |
848 movwf TBLPTRU | |
688 | 849 display1_init_loop: |
681 | 850 TBLRD*+ |
851 movlw 0xFF | |
852 cpfseq TABLAT | |
688 | 853 bra display1_config_write ; Write Config pair to Display |
681 | 854 ; Delay ms or quit (return) |
855 TBLRD*+ | |
856 tstfsz TABLAT ; End of config? | |
857 bra $+4 ; No | |
858 return ; Done. | |
859 movf TABLAT,W | |
860 call WAITMSX ; Wait WREG milliseconds | |
688 | 861 bra display1_init_loop ; Loop |
681 | 862 |
688 | 863 display1_config_write: ; With command in WREG |
681 | 864 movf TABLAT,W |
865 rcall DISP_CmdWrite ; Write command | |
866 TBLRD*+ ; Get config | |
867 movf TABLAT,W | |
868 rcall DISP_DataWrite ; Write config | |
688 | 869 bra display1_init_loop ; Loop |
681 | 870 |
871 | |
872 display1_config_table: | |
873 ; Reg, Dat or 0xFF, Delay or 0xFF, 0x00 (End) | |
874 db 0x96,0x01 | |
875 db 0x19,0x87 | |
876 db 0xFF,.10 | |
877 db 0x26,0x80 | |
878 db 0x1B,0x0C | |
879 db 0x43,0x00 | |
880 db 0x20,0x00 | |
881 db 0x1F,0x07 | |
882 db 0x44,0x7F | |
883 db 0x45,0x14 | |
884 db 0x1D,0x05 | |
885 db 0x1E,0x00 | |
886 db 0x1C,0x04 | |
887 db 0x1B,0x14 | |
888 db 0xFF,.40 | |
889 db 0x43,0x80 | |
890 db 0x42,0x08 | |
891 db 0x23,0x95 | |
892 db 0x24,0x95 | |
893 db 0x25,0xFF | |
894 db 0x21,0x10 | |
895 db 0x2B,0x00 | |
896 db 0x95,0x01 | |
897 db 0x1A,0x00 | |
898 db 0x93,0x0F | |
899 db 0x70,0x66 | |
900 db 0x18,0x01 | |
901 db 0x46,0x86 | |
902 db 0x47,0x60 | |
903 db 0x48,0x01 | |
904 db 0x49,0x67 | |
905 db 0x4A,0x46 | |
906 db 0x4B,0x13 | |
907 db 0x4C,0x01 | |
908 db 0x4D,0x67 | |
909 db 0x4E,0x00 | |
910 db 0x4F,0x13 | |
911 db 0x50,0x02 | |
912 db 0x51,0x00 | |
913 db 0x38,0x00 | |
914 db 0x39,0x00 | |
915 db 0x27,0x02 | |
916 db 0x28,0x03 | |
917 db 0x29,0x08 | |
918 db 0x2A,0x08 | |
919 db 0x2C,0x08 | |
920 db 0x2D,0x08 | |
921 db 0x35,0x09 | |
922 db 0x36,0x09 | |
923 db 0x91,0x14 | |
924 db 0x37,0x00 | |
925 db 0x01,0x06 | |
926 db 0x3A,0xA1 | |
927 db 0x3B,0xA1 | |
928 db 0x3C,0xA1 | |
929 db 0x3D,0x00 | |
930 db 0x3E,0x2D | |
931 db 0x40,0x03 | |
932 db 0x41,0xCC | |
933 db 0x0A,0x00 | |
934 db 0x0B,0x00 | |
935 db 0x0C,0x01 | |
936 db 0x0D,0x3F | |
937 db 0x0E,0x00 | |
938 db 0x0F,0x00 | |
939 db 0x10,0x01 | |
940 db 0x11,0x40 | |
941 db 0x12,0x00 | |
942 db 0x13,0x00 | |
943 db 0x14,0x00 | |
944 db 0x15,0x00 | |
945 db 0x02,0x00 | |
946 db 0x03,0x00 | |
947 db 0x04,0x00 | |
948 db 0x05,0xEF | |
949 db 0x06,0x00 | |
950 db 0x07,0x00 | |
951 db 0x08,0x01 | |
952 db 0x09,0x3F | |
953 db 0x16,0x88 | |
954 db 0x72,0x00 | |
955 db 0x22,0x60 | |
956 db 0x94,0x0A | |
957 db 0x90,0x7F | |
958 db 0x26,0x84 | |
959 db 0xFF,.40 | |
960 db 0x26,0xA4 | |
961 db 0x26,0xAC | |
962 db 0xFF,.40 | |
963 db 0x26,0xBC | |
964 db 0x96,0x00 | |
965 db 0xFF,0x00 ; End of table pair | |
966 | |
967 | |
968 display0_init: ; Display0 | |
969 banksel win_flags | |
970 bcf win_flags,1 | |
971 banksel flag1 | |
972 bcf DISPLAY_hv | |
973 WAITMS d'32' | |
974 bsf DISPLAY_vdd | |
975 nop | |
976 bcf DISPLAY_cs | |
977 nop | |
978 bsf DISPLAY_nreset | |
979 WAITMS d'250' ; Standard wake-up | |
980 bsf DISPLAY_e_nwr | |
981 nop | |
982 bcf DISPLAY_nreset | |
983 WAIT10US d'2' | |
984 bsf DISPLAY_nreset | |
985 WAITMS d'10' | |
986 | |
987 movlw 0x24 ; 80-System 8-Bit Mode | |
988 rcall DISP_CmdWrite | |
989 | |
990 movlw 0x02 ; RGB Interface Control (S6E63D6 Datasheet page 42) | |
991 rcall DISP_CmdWrite | |
992 movlw 0x00 ; X X X X X X X RM | |
993 rcall DISP_DataWrite | |
994 movlw 0x00 ; DM X RIM1 RIM0 VSPL HSPL EPL DPL | |
995 rcall DISP_DataWrite ; System Interface: RIM is ignored, Internal Clock | |
996 | |
997 movlw 0x03 ; Entry Mode (S6E63D6 Datasheet page 46) | |
998 rcall DISP_CmdWrite | |
999 movlw 0x00 ; CLS MDT1 MDT0 BGR X X X SS 65k Color | |
1000 rcall DISP_DataWrite | |
1001 | |
1002 ; Change direction for block-writes of pixels | |
1003 lfsr FSR0,win_flags | |
684 | 1004 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM |
681 | 1005 btfss INDF0,0 ; BANK-SAFE bit test. |
1006 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM | |
1007 rcall DISP_DataWrite | |
1008 | |
688 | 1009 movlw LOW display0_config_table |
1010 movwf TBLPTRL | |
1011 movlw HIGH display0_config_table | |
1012 movwf TBLPTRH | |
1013 movlw UPPER display0_config_table | |
1014 movwf TBLPTRU | |
1015 rcall display0_init_loop | |
1016 rcall DISP_brightness_full ; Gamma settings... | |
1017 rcall DISP_ClearScreen | |
1018 bsf DISPLAY_hv ; OLED volatages on | |
1019 return | |
681 | 1020 |
1021 | |
688 | 1022 display0_config_table: |
1023 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
1024 db 0x18,0x00,0x28,0xF8,0x00,0x0F | |
1025 db 0xF9,0x00,0x0F,0x10,0x00,0x00 | |
1026 db 0x05,0x00,0x01,0xFF,0x00,0x00 | |
681 | 1027 |
1028 | |
1029 DISP_brightness_full: ; Choose between Eco and High... | |
1030 btfsc DISPLAY_brightness_high ; DISPLAY brightness (=0: Eco, =1: High) | |
1031 bra DISP_brightness_full_high | |
1032 ; Mid | |
1033 bsf PORTB,7 | |
1034 bcf PORTB,6 | |
1035 | |
1036 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1037 btfsc WREG,1 ; Display1? | |
1038 return ; Yes, done. | |
1039 | |
688 | 1040 movlw LOW display0_gamma_high_table |
1041 movwf TBLPTRL | |
1042 movlw HIGH display0_gamma_high_table | |
1043 movwf TBLPTRH | |
1044 movlw UPPER display0_gamma_high_table | |
1045 movwf TBLPTRU | |
1046 bra display0_init_loop ; And return... | |
681 | 1047 |
1048 | |
1049 DISP_brightness_full_high: | |
1050 ; Full | |
1051 bsf PORTB,7 | |
1052 bsf PORTB,6 | |
1053 | |
1054 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1055 btfsc WREG,1 ; Display1? | |
1056 return ; Yes, done. | |
1057 | |
688 | 1058 movlw LOW display0_gamma_full_table |
1059 movwf TBLPTRL | |
1060 movlw HIGH display0_gamma_full_table | |
1061 movwf TBLPTRH | |
1062 movlw UPPER display0_gamma_full_table | |
1063 movwf TBLPTRU | |
1064 bra display0_init_loop ; And return... | |
681 | 1065 |
1066 | |
1067 DISP_brightness_low: | |
1068 ;Low | |
1069 bcf PORTB,7 | |
1070 bcf PORTB,6 | |
1071 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1072 btfsc WREG,1 ; Display1? | |
1073 return ; Yes, done. | |
688 | 1074 movlw LOW display0_gamma_low_table |
1075 movwf TBLPTRL | |
1076 movlw HIGH display0_gamma_low_table | |
1077 movwf TBLPTRH | |
1078 movlw UPPER display0_gamma_low_table | |
1079 movwf TBLPTRU | |
1080 bra display0_init_loop ; And return... | |
681 | 1081 |
688 | 1082 display0_init_loop: |
1083 TBLRD*+ | |
1084 movlw 0xFF | |
1085 cpfseq TABLAT | |
1086 bra display0_config_write ; Write Config pair to Display | |
1087 ; Delay ms or quit (return) | |
1088 TBLRD*+ | |
1089 tstfsz TABLAT ; End of config? | |
1090 bra $+4 ; No | |
1091 return ; Done. | |
1092 movf TABLAT,W | |
1093 call WAITMSX ; Wait WREG milliseconds | |
1094 bra display0_init_loop ; Loop | |
681 | 1095 |
688 | 1096 display0_config_write: ; With command in WREG |
1097 movf TABLAT,W | |
1098 rcall DISP_CmdWrite ; Write command | |
1099 TBLRD*+ ; Get config | |
1100 movf TABLAT,W | |
1101 rcall DISP_DataWrite ; Write config | |
1102 TBLRD*+ ; Get config | |
1103 movf TABLAT,W | |
1104 rcall DISP_DataWrite ; Write config | |
1105 bra display0_init_loop ; Loop | |
1106 | |
681 | 1107 |
688 | 1108 display0_gamma_high_table: |
1109 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
1110 db 0x70,0x1B,0x80,0x71,0x1F,0x00 | |
1111 db 0x72,0x22,0x00,0x73,0x17,0x11 | |
1112 db 0x74,0x1A,0x0E,0x75,0x1D,0x15 | |
1113 db 0x76,0x18,0x11,0x77,0x1E,0x18 | |
1114 db 0x78,0x1D,0x11,0xFF,0x00,0x00 | |
681 | 1115 |
688 | 1116 display0_gamma_full_table: |
1117 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
1118 db 0x70,0x1F,0x00,0x71,0x23,0x80 | |
1119 db 0x72,0x2A,0x80,0x73,0x15,0x11 | |
1120 db 0x74,0x1C,0x11,0x75,0x1B,0x15 | |
1121 db 0x76,0x1A,0x15,0x77,0x1C,0x18 | |
1122 db 0x78,0x21,0x15,0xFF,0x00,0x00 | |
1123 | |
1124 display0_gamma_low_table: | |
1125 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
1126 db 0x70,0x14,0x00,0x71,0x17,0x00 | |
1127 db 0x72,0x15,0x80,0x73,0x15,0x11 | |
1128 db 0x74,0x14,0x0B,0x75,0x1B,0x15 | |
1129 db 0x76,0x13,0x0E,0x77,0x1C,0x18 | |
1130 db 0x78,0x15,0x0E,0xFF,0x00,0x00 | |
1131 | |
681 | 1132 |
1133 DISP_set_color:;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGG GGGBBBBB' | |
1134 movwf DISPLAY1_temp ; Get 8Bit RGB b'RRRGGGBB' | |
1135 movwf DISPLAY2_temp ; Copy | |
706 | 1136 movff WREG,win_color6 ; Another (bank-safe) copy |
681 | 1137 |
1138 ; Display0 | |
1139 ; Mask Bit 7,6,5,4,3,2 | |
1140 movlw b'00000011' | |
1141 andwf DISPLAY2_temp,F | |
1142 | |
1143 movlw b'00000000' | |
1144 dcfsnz DISPLAY2_temp,F | |
1145 movlw b'01010000' | |
1146 dcfsnz DISPLAY2_temp,F | |
1147 movlw b'10100000' | |
1148 dcfsnz DISPLAY2_temp,F | |
1149 movlw b'11111000' | |
1150 movwf DISPLAY3_temp ; Blue done. | |
1151 | |
1152 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1153 ; Mask Bit 7,6,5,1,0 | |
1154 movlw b'00011100' | |
1155 andwf DISPLAY2_temp,F | |
1156 rrncf DISPLAY2_temp,F | |
1157 rrncf DISPLAY2_temp,F | |
1158 | |
1159 movlw b'00000000' | |
1160 dcfsnz DISPLAY2_temp,F | |
1161 movlw b'00000100' | |
1162 dcfsnz DISPLAY2_temp,F | |
1163 movlw b'00001000' | |
1164 dcfsnz DISPLAY2_temp,F | |
1165 movlw b'00001100' | |
1166 dcfsnz DISPLAY2_temp,F | |
1167 movlw b'00010000' | |
1168 dcfsnz DISPLAY2_temp,F | |
1169 movlw b'00010100' | |
1170 dcfsnz DISPLAY2_temp,F | |
1171 movlw b'00100000' | |
1172 dcfsnz DISPLAY2_temp,F | |
1173 movlw b'00111111' | |
1174 movwf DISPLAY4_temp | |
1175 | |
1176 rrcf DISPLAY4_temp,F | |
1177 rrcf DISPLAY3_temp,F | |
1178 | |
1179 rrcf DISPLAY4_temp,F | |
1180 rrcf DISPLAY3_temp,F | |
1181 | |
1182 rrcf DISPLAY4_temp,F | |
1183 rrcf DISPLAY3_temp,F ; DISPLAY3_temp (b'GGGBBBBB') done. | |
1184 | |
1185 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1186 clrf DISPLAY1_temp | |
1187 | |
1188 rrcf DISPLAY4_temp,F | |
1189 rrcf DISPLAY1_temp,F | |
1190 | |
1191 rrcf DISPLAY4_temp,F | |
1192 rrcf DISPLAY1_temp,F | |
1193 | |
1194 rrcf DISPLAY4_temp,F | |
1195 rrcf DISPLAY1_temp,F ; Green done. | |
1196 | |
1197 ; Mask Bit 4,3,2,1,0 | |
1198 movlw b'11100000' | |
1199 andwf DISPLAY2_temp,F | |
1200 | |
1201 rrncf DISPLAY2_temp,F | |
1202 rrncf DISPLAY2_temp,F | |
1203 rrncf DISPLAY2_temp,F | |
1204 rrncf DISPLAY2_temp,F | |
1205 rrncf DISPLAY2_temp,F | |
1206 | |
1207 movlw b'00000000' | |
1208 dcfsnz DISPLAY2_temp,F | |
1209 movlw b'00000100' | |
1210 dcfsnz DISPLAY2_temp,F | |
1211 movlw b'00001000' | |
1212 dcfsnz DISPLAY2_temp,F | |
1213 movlw b'00001100' | |
1214 dcfsnz DISPLAY2_temp,F | |
1215 movlw b'00010000' | |
1216 dcfsnz DISPLAY2_temp,F | |
1217 movlw b'00010100' | |
1218 dcfsnz DISPLAY2_temp,F | |
1219 movlw b'00100000' | |
1220 dcfsnz DISPLAY2_temp,F | |
1221 movlw b'00111111' | |
1222 movwf DISPLAY4_temp | |
1223 | |
1224 rrcf DISPLAY4_temp,F | |
1225 rrcf DISPLAY1_temp,F | |
1226 | |
1227 rrcf DISPLAY4_temp,F | |
1228 rrcf DISPLAY1_temp,F | |
1229 | |
1230 rrcf DISPLAY4_temp,F | |
1231 rrcf DISPLAY1_temp,F | |
1232 | |
1233 rrcf DISPLAY4_temp,F | |
1234 rrcf DISPLAY1_temp,F | |
1235 | |
1236 rrcf DISPLAY4_temp,F | |
1237 rrcf DISPLAY1_temp,F ; Red done. | |
1238 | |
1239 movff DISPLAY1_temp,win_color1 | |
1240 movff DISPLAY3_temp,win_color2 ; Set Bank0 Color registers... | |
706 | 1241 |
1242 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1243 btfss WREG,1 ; Display1? | |
1244 return ; No | |
681 | 1245 |
684 | 1246 DISP_set_color_display1:;Converts 8Bit RGB b'RRRGGGBB' into 24Bit RGB b'00RRRRRR 00GGGGGG 00BBBBBB' |
706 | 1247 movff win_color6,DISPLAY1_temp |
1248 movff win_color6,DISPLAY2_temp | |
1249 | |
681 | 1250 ; Mask Bit 7,6,5,4,3,2 |
1251 movlw b'00000011' | |
1252 andwf DISPLAY2_temp,F | |
1253 | |
1254 movlw b'00000000' | |
1255 dcfsnz DISPLAY2_temp,F | |
1256 movlw b'01010000' | |
1257 dcfsnz DISPLAY2_temp,F | |
1258 movlw b'10100000' | |
1259 dcfsnz DISPLAY2_temp,F | |
1260 movlw b'11111000' | |
706 | 1261 movff WREG,win_color6 ; B |
681 | 1262 |
1263 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1264 ; Mask Bit 7,6,5,1,0 | |
1265 movlw b'00011100' | |
1266 andwf DISPLAY2_temp,F | |
1267 rrncf DISPLAY2_temp,F | |
1268 rrncf DISPLAY2_temp,F | |
1269 | |
1270 movlw b'00000000' | |
1271 dcfsnz DISPLAY2_temp,F | |
1272 movlw b'00010000' | |
1273 dcfsnz DISPLAY2_temp,F | |
1274 movlw b'00100000' | |
1275 dcfsnz DISPLAY2_temp,F | |
1276 movlw b'00110000' | |
1277 dcfsnz DISPLAY2_temp,F | |
1278 movlw b'01000000' | |
1279 dcfsnz DISPLAY2_temp,F | |
1280 movlw b'01010000' | |
1281 dcfsnz DISPLAY2_temp,F | |
1282 movlw b'10000000' | |
1283 dcfsnz DISPLAY2_temp,F | |
1284 movlw b'11111100' | |
706 | 1285 movff WREG,win_color5 ; G |
681 | 1286 |
1287 ; Mask Bit 4,3,2,1,0 | |
1288 movlw b'11100000' | |
684 | 1289 andwf DISPLAY1_temp,F |
681 | 1290 |
684 | 1291 rrncf DISPLAY1_temp,F |
1292 rrncf DISPLAY1_temp,F | |
1293 rrncf DISPLAY1_temp,F | |
1294 rrncf DISPLAY1_temp,F | |
1295 rrncf DISPLAY1_temp,F | |
681 | 1296 |
1297 movlw b'00000000' | |
684 | 1298 dcfsnz DISPLAY1_temp,F |
681 | 1299 movlw b'00010000' |
684 | 1300 dcfsnz DISPLAY1_temp,F |
681 | 1301 movlw b'00100000' |
684 | 1302 dcfsnz DISPLAY1_temp,F |
681 | 1303 movlw b'00110000' |
684 | 1304 dcfsnz DISPLAY1_temp,F |
681 | 1305 movlw b'01000000' |
684 | 1306 dcfsnz DISPLAY1_temp,F |
681 | 1307 movlw b'01010000' |
684 | 1308 dcfsnz DISPLAY1_temp,F |
681 | 1309 movlw b'10000000' |
684 | 1310 dcfsnz DISPLAY1_temp,F |
681 | 1311 movlw b'11111100' |
706 | 1312 movff WREG,win_color4 ; R |
681 | 1313 return |