Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/display_lowlevel.asm @ 734:65822fa08333
use "first Gas" as first bailout
author | heinrichsweikamp |
---|---|
date | Sun, 23 Jun 2013 20:20:31 +0200 |
parents | ad5ab9910820 |
children | 4f3c91ef3bfe |
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. | |
719 | 524 bsf DISPLAY_rs ; Data! |
681 | 525 DISP_box2: ; Loop height times |
526 movff win_height,PRODL | |
527 | |
528 DISP_box3: ; loop width times | |
706 | 529 movff win_flags,WREG ; Display1? win_flags is in bank0... |
530 btfsc WREG,1 ; Display1? | |
531 bra DISP_box3aa ; Yes | |
532 | |
681 | 533 movff win_color1,PORTD |
534 bcf DISPLAY_rw | |
684 | 535 bsf DISPLAY_rw ; Upper |
681 | 536 movff win_color2,PORTD |
706 | 537 bra DISP_box3a ; Done. |
538 DISP_box3aa: | |
539 movff win_color4,PORTD | |
540 bcf DISPLAY_rw | |
541 bsf DISPLAY_rw ; Upper | |
542 movff win_color5,PORTD | |
681 | 543 bcf DISPLAY_rw |
684 | 544 bsf DISPLAY_rw ; Lower/High |
706 | 545 movff win_color6,PORTD |
681 | 546 |
547 DISP_box3a: | |
706 | 548 bcf DISPLAY_rw |
549 bsf DISPLAY_rw ; Lower/High | |
550 | |
551 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
552 btfsc WREG,1 ; Display1? | |
553 bra DISP_box3ab ; Yes | |
554 | |
681 | 555 movff win_color1,PORTD |
556 bcf DISPLAY_rw | |
684 | 557 bsf DISPLAY_rw ; Upper |
681 | 558 movff win_color2,PORTD |
706 | 559 bra DISP_box3b |
560 | |
561 DISP_box3ab: | |
562 movff win_color4,PORTD | |
681 | 563 bcf DISPLAY_rw |
706 | 564 bsf DISPLAY_rw ; Upper |
565 movff win_color5,PORTD | |
566 bcf DISPLAY_rw | |
567 bsf DISPLAY_rw ; High | |
568 movff win_color6,PORTD | |
569 | |
570 DISP_box3b: | |
681 | 571 bcf DISPLAY_rw |
684 | 572 bsf DISPLAY_rw ; Lower |
681 | 573 decfsz PRODL,F ; row loop finished ? |
574 bra DISP_box3 ; No: continue. | |
575 | |
576 incf PRODH,F ; column count ++ | |
577 | |
578 movff win_bargraph,WREG ; current column == bargraph ? | |
579 cpfseq PRODH | |
580 bra DISP_box4 ; No: just loop. | |
581 | |
582 clrf WREG ; Yes: switch to black | |
583 movff WREG,win_color1 | |
584 movff WREG,win_color2 | |
706 | 585 movff WREG,win_color3 |
586 movff WREG,win_color4 | |
587 movff WREG,win_color5 | |
588 movff WREG,win_color6 | |
681 | 589 DISP_box4: |
590 movff win_width,WREG | |
591 cpfseq PRODH | |
592 bra DISP_box2 | |
593 | |
594 setf WREG ; Reset bargraph mode... | |
595 movff WREG,win_bargraph | |
596 | |
597 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
598 btfsc WREG,1 ; Display1? | |
599 return ; Yes, done. | |
600 | |
601 movlw 0x00 ; NOP, to stop window mode | |
602 bra DISP_CmdWrite ; Returns.... | |
603 | |
604 ;============================================================================= | |
605 ; DISP_ClearScreen: An optimized version of PLEX_box, for full screen black. | |
606 ; Trashed: WREG, PROD | |
607 | |
608 global DISP_ClearScreen | |
609 DISP_ClearScreen: | |
610 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
611 btfsc WREG,1 ; Display1? | |
612 bra DISP_ClearScreen_display1; Yes | |
613 | |
614 movlw 0x35 ; VerticalStartAddress HIGH:LOW | |
615 rcall DISP_CmdWrite | |
616 mullw 0 | |
617 rcall DISP_DataWrite_PROD | |
618 | |
619 movlw 0x36 ; VerticalEndAddress HIGH:LOW | |
620 rcall DISP_CmdWrite | |
621 movlw 0x01 | |
622 rcall DISP_DataWrite | |
623 movlw 0x3F | |
624 rcall DISP_DataWrite | |
625 | |
626 movlw 0x37 ; HorizontalAddress START:END | |
627 rcall DISP_CmdWrite | |
628 movlw 0x00 | |
629 rcall DISP_DataWrite | |
630 movlw 0xEF | |
631 rcall DISP_DataWrite | |
632 | |
633 movlw 0x20 ; Start Address Horizontal (.0 - .239) | |
634 rcall DISP_CmdWrite | |
635 rcall DISP_DataWrite_PROD | |
636 | |
637 movlw 0x21 ; Start Address Vertical (.0 - .319) | |
638 rcall DISP_CmdWrite | |
639 rcall DISP_DataWrite_PROD | |
640 | |
641 movlw 0x22 ; Start Writing Data to GRAM | |
642 rcall DISP_CmdWrite | |
643 | |
644 ; See Page 101 of DISPLAY Driver IC Datasheet how to handle rs/rw clocks | |
645 bsf DISPLAY_rs ; Data! | |
684 | 646 clrf PORTD |
681 | 647 movlw .160 |
648 movwf PRODH | |
649 DISP_ClearScreen2: | |
650 movlw .240 | |
651 movwf PRODL | |
652 DISP_ClearScreen3: | |
653 bcf DISPLAY_rw | |
654 bsf DISPLAY_rw ; Upper | |
655 bcf DISPLAY_rw | |
656 bsf DISPLAY_rw ; Lower | |
657 bcf DISPLAY_rw | |
658 bsf DISPLAY_rw ; Upper | |
659 bcf DISPLAY_rw | |
660 bsf DISPLAY_rw ; Lower | |
661 decfsz PRODL,F | |
662 bra DISP_ClearScreen3 | |
663 decfsz PRODH,F | |
664 bra DISP_ClearScreen2 | |
665 movlw 0x00 ; NOP, to stop Address Update Counter | |
684 | 666 bra DISP_CmdWrite ; And return... |
681 | 667 |
668 DISP_ClearScreen_display1: | |
669 ; Column Address start | |
670 movlw 0x02 | |
671 rcall DISP_CmdWrite | |
672 movlw 0x00 | |
673 rcall DISP_DataWrite | |
674 movlw 0x03 | |
675 rcall DISP_CmdWrite | |
676 movlw 0x00 | |
677 rcall DISP_DataWrite | |
678 | |
679 ; Column Address end | |
680 movlw 0x04 | |
681 rcall DISP_CmdWrite | |
682 movlw 0x00 | |
683 rcall DISP_DataWrite | |
684 movlw 0x05 | |
685 rcall DISP_CmdWrite | |
686 movlw 0xEF | |
687 rcall DISP_DataWrite | |
688 | |
689 ; Row address start | |
690 movlw 0x06 | |
691 rcall DISP_CmdWrite | |
692 movlw 0x00 | |
693 rcall DISP_DataWrite | |
694 movlw 0x07 | |
695 rcall DISP_CmdWrite | |
696 movlw 0x00 | |
697 rcall DISP_DataWrite | |
698 | |
699 ; Row address end | |
700 movlw 0x08 | |
701 rcall DISP_CmdWrite | |
702 movlw 0x01 | |
703 rcall DISP_DataWrite | |
704 movlw 0x09 | |
705 rcall DISP_CmdWrite | |
706 movlw 0x3F | |
707 rcall DISP_DataWrite | |
708 | |
709 movlw 0x22 ; Start Writing Data to GRAM | |
710 rcall DISP_CmdWrite | |
711 | |
712 bsf DISPLAY_rs ; Data! | |
713 | |
714 movlw .160 | |
715 movwf PRODH | |
716 DISP_ClearScreen2_display1: | |
717 movlw .240 | |
718 movwf PRODL | |
684 | 719 clrf PORTD |
681 | 720 DISP_ClearScreen3_display1: |
721 bcf DISPLAY_rw | |
722 bsf DISPLAY_rw ; Upper | |
723 bcf DISPLAY_rw | |
724 bsf DISPLAY_rw ; High | |
725 bcf DISPLAY_rw | |
726 bsf DISPLAY_rw ; Lower | |
727 bcf DISPLAY_rw | |
728 bsf DISPLAY_rw ; Upper | |
729 bcf DISPLAY_rw | |
730 bsf DISPLAY_rw ; High | |
731 bcf DISPLAY_rw | |
732 bsf DISPLAY_rw ; Lower | |
733 decfsz PRODL,F | |
734 bra DISP_ClearScreen3_display1 | |
735 decfsz PRODH,F | |
736 bra DISP_ClearScreen2_display1 | |
737 return | |
738 | |
739 | |
740 ; ----------------------------- | |
741 ; DISP Write Cmd via W | |
742 ; ----------------------------- | |
743 DISP_CmdWrite: | |
744 bcf DISPLAY_rs ; Command! | |
745 movwf PORTD ; Move Data to PORTD | |
746 bcf DISPLAY_rw | |
747 bsf DISPLAY_rw | |
748 return | |
749 | |
750 ; ----------------------------- | |
751 ; DISP Write Display Data via W | |
752 ; ----------------------------- | |
753 DISP_DataWrite: | |
754 bsf DISPLAY_rs ; Data! | |
755 movwf PORTD ; Move Data to PORTD | |
756 bcf DISPLAY_rw | |
757 bsf DISPLAY_rw | |
758 return | |
759 | |
760 ; ----------------------------- | |
761 ; DISP Data Cmd via W | |
762 ; ----------------------------- | |
763 DISP_DataWrite_PROD: | |
764 bsf DISPLAY_rs ; Data! | |
765 movff PRODH,PORTD ; Move high byte to PORTD (DISPLAY is bigendian) | |
766 bcf DISPLAY_rw | |
767 bsf DISPLAY_rw | |
768 movff PRODL,PORTD ; Move low byte to PORTD | |
769 bcf DISPLAY_rw | |
770 bsf DISPLAY_rw | |
771 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
772 btfss WREG,1 ; Display1? | |
773 return ; No, done. | |
705 | 774 movff win_color3,PORTD ; Move low(est) byte to PORTD |
681 | 775 bcf DISPLAY_rw |
776 bsf DISPLAY_rw | |
777 return | |
778 | |
779 | |
780 ; ----------------------------- | |
781 ; DISP Read data into WREG | |
782 ; ----------------------------- | |
783 ; NOTE: you should "setf TRISD" before calling this function, | |
784 ; to make PortD an input port... | |
785 DISP_DataRead: | |
687
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
786 movff win_flags,WREG ; Display1? win_flags is in bank0... |
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
787 btfsc WREG,1 ; Display1? |
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
788 return ; Yes, done. |
681 | 789 bsf DISPLAY_rs ; Data register. |
790 bcf DISPLAY_e_nwr ; Read enable. | |
791 nop | |
792 nop | |
793 nop | |
794 nop | |
795 movf PORTD,W ; Read byte. | |
796 bsf DISPLAY_e_nwr ; release bus. | |
797 return | |
798 | |
799 ; ----------------------------- | |
800 ; DISP boot | |
801 ; ----------------------------- | |
802 DISPLAY_boot: | |
803 movlw LOW 0x17FDC | |
804 movwf TBLPTRL | |
805 movlw HIGH 0x17FDC | |
806 movwf TBLPTRH | |
807 movlw UPPER 0x17FDC | |
808 movwf TBLPTRU | |
809 TBLRD* | |
810 movlw 0x01 | |
811 cpfseq TABLAT ; Display1? | |
812 bra display0_init ; No, Display0 | |
813 | |
814 banksel win_flags | |
815 bsf win_flags,0 | |
816 bsf win_flags,1 | |
817 banksel flag1 | |
818 bcf DISPLAY_hv ; Backlight off | |
819 nop | |
820 bcf DISPLAY_vdd | |
821 WAITMS d'10' | |
822 bsf DISPLAY_vdd | |
823 WAITMS d'100' | |
824 bsf DISPLAY_rw | |
825 nop | |
826 bcf DISPLAY_cs | |
827 nop | |
828 bsf DISPLAY_nreset | |
829 WAITMS d'1' | |
830 bcf DISPLAY_nreset | |
831 WAIT10US d'2' | |
832 bsf DISPLAY_nreset | |
833 WAITMS d'120' | |
834 bsf DISPLAY_e_nwr ; release bus. | |
835 rcall display1_init ; Init sequence | |
836 rcall DISP_ClearScreen | |
837 WAITMS d'60' | |
838 bsf DISPLAY_hv ; Backlight on | |
839 return | |
840 | |
841 display1_init: | |
842 movlw LOW display1_config_table | |
843 movwf TBLPTRL | |
844 movlw HIGH display1_config_table | |
845 movwf TBLPTRH | |
846 movlw UPPER display1_config_table | |
847 movwf TBLPTRU | |
688 | 848 display1_init_loop: |
681 | 849 TBLRD*+ |
850 movlw 0xFF | |
851 cpfseq TABLAT | |
688 | 852 bra display1_config_write ; Write Config pair to Display |
681 | 853 ; Delay ms or quit (return) |
854 TBLRD*+ | |
855 tstfsz TABLAT ; End of config? | |
856 bra $+4 ; No | |
857 return ; Done. | |
858 movf TABLAT,W | |
859 call WAITMSX ; Wait WREG milliseconds | |
688 | 860 bra display1_init_loop ; Loop |
681 | 861 |
688 | 862 display1_config_write: ; With command in WREG |
681 | 863 movf TABLAT,W |
864 rcall DISP_CmdWrite ; Write command | |
865 TBLRD*+ ; Get config | |
866 movf TABLAT,W | |
867 rcall DISP_DataWrite ; Write config | |
688 | 868 bra display1_init_loop ; Loop |
681 | 869 |
870 | |
871 display1_config_table: | |
872 ; Reg, Dat or 0xFF, Delay or 0xFF, 0x00 (End) | |
873 db 0x96,0x01 | |
874 db 0x19,0x87 | |
875 db 0xFF,.10 | |
876 db 0x26,0x80 | |
877 db 0x1B,0x0C | |
878 db 0x43,0x00 | |
879 db 0x20,0x00 | |
880 db 0x1F,0x07 | |
881 db 0x44,0x7F | |
882 db 0x45,0x14 | |
883 db 0x1D,0x05 | |
884 db 0x1E,0x00 | |
885 db 0x1C,0x04 | |
886 db 0x1B,0x14 | |
887 db 0xFF,.40 | |
888 db 0x43,0x80 | |
889 db 0x42,0x08 | |
890 db 0x23,0x95 | |
891 db 0x24,0x95 | |
892 db 0x25,0xFF | |
893 db 0x21,0x10 | |
894 db 0x2B,0x00 | |
895 db 0x95,0x01 | |
896 db 0x1A,0x00 | |
897 db 0x93,0x0F | |
898 db 0x70,0x66 | |
899 db 0x18,0x01 | |
900 db 0x46,0x86 | |
901 db 0x47,0x60 | |
902 db 0x48,0x01 | |
903 db 0x49,0x67 | |
904 db 0x4A,0x46 | |
905 db 0x4B,0x13 | |
906 db 0x4C,0x01 | |
907 db 0x4D,0x67 | |
908 db 0x4E,0x00 | |
909 db 0x4F,0x13 | |
910 db 0x50,0x02 | |
911 db 0x51,0x00 | |
912 db 0x38,0x00 | |
913 db 0x39,0x00 | |
914 db 0x27,0x02 | |
915 db 0x28,0x03 | |
916 db 0x29,0x08 | |
917 db 0x2A,0x08 | |
918 db 0x2C,0x08 | |
919 db 0x2D,0x08 | |
920 db 0x35,0x09 | |
921 db 0x36,0x09 | |
922 db 0x91,0x14 | |
923 db 0x37,0x00 | |
924 db 0x01,0x06 | |
925 db 0x3A,0xA1 | |
926 db 0x3B,0xA1 | |
927 db 0x3C,0xA1 | |
928 db 0x3D,0x00 | |
929 db 0x3E,0x2D | |
930 db 0x40,0x03 | |
931 db 0x41,0xCC | |
932 db 0x0A,0x00 | |
933 db 0x0B,0x00 | |
934 db 0x0C,0x01 | |
935 db 0x0D,0x3F | |
936 db 0x0E,0x00 | |
937 db 0x0F,0x00 | |
938 db 0x10,0x01 | |
939 db 0x11,0x40 | |
940 db 0x12,0x00 | |
941 db 0x13,0x00 | |
942 db 0x14,0x00 | |
943 db 0x15,0x00 | |
944 db 0x02,0x00 | |
945 db 0x03,0x00 | |
946 db 0x04,0x00 | |
947 db 0x05,0xEF | |
948 db 0x06,0x00 | |
949 db 0x07,0x00 | |
950 db 0x08,0x01 | |
951 db 0x09,0x3F | |
952 db 0x16,0x88 | |
953 db 0x72,0x00 | |
954 db 0x22,0x60 | |
955 db 0x94,0x0A | |
956 db 0x90,0x7F | |
957 db 0x26,0x84 | |
958 db 0xFF,.40 | |
959 db 0x26,0xA4 | |
960 db 0x26,0xAC | |
961 db 0xFF,.40 | |
962 db 0x26,0xBC | |
963 db 0x96,0x00 | |
964 db 0xFF,0x00 ; End of table pair | |
965 | |
966 | |
967 display0_init: ; Display0 | |
968 banksel win_flags | |
969 bcf win_flags,1 | |
970 banksel flag1 | |
971 bcf DISPLAY_hv | |
713 | 972 btfsc DISPLAY_hv |
973 bra $-4 | |
681 | 974 WAITMS d'32' |
975 bsf DISPLAY_vdd | |
976 nop | |
977 bcf DISPLAY_cs | |
978 nop | |
979 bsf DISPLAY_nreset | |
980 WAITMS d'250' ; Standard wake-up | |
981 bsf DISPLAY_e_nwr | |
982 nop | |
983 bcf DISPLAY_nreset | |
984 WAIT10US d'2' | |
985 bsf DISPLAY_nreset | |
986 WAITMS d'10' | |
987 | |
988 movlw 0x24 ; 80-System 8-Bit Mode | |
989 rcall DISP_CmdWrite | |
990 | |
991 movlw 0x02 ; RGB Interface Control (S6E63D6 Datasheet page 42) | |
992 rcall DISP_CmdWrite | |
993 movlw 0x00 ; X X X X X X X RM | |
994 rcall DISP_DataWrite | |
995 movlw 0x00 ; DM X RIM1 RIM0 VSPL HSPL EPL DPL | |
996 rcall DISP_DataWrite ; System Interface: RIM is ignored, Internal Clock | |
997 | |
998 movlw 0x03 ; Entry Mode (S6E63D6 Datasheet page 46) | |
999 rcall DISP_CmdWrite | |
1000 movlw 0x00 ; CLS MDT1 MDT0 BGR X X X SS 65k Color | |
1001 rcall DISP_DataWrite | |
1002 | |
1003 ; Change direction for block-writes of pixels | |
1004 lfsr FSR0,win_flags | |
684 | 1005 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM |
681 | 1006 btfss INDF0,0 ; BANK-SAFE bit test. |
1007 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM | |
1008 rcall DISP_DataWrite | |
1009 | |
688 | 1010 movlw LOW display0_config_table |
1011 movwf TBLPTRL | |
1012 movlw HIGH display0_config_table | |
1013 movwf TBLPTRH | |
1014 movlw UPPER display0_config_table | |
1015 movwf TBLPTRU | |
1016 rcall display0_init_loop | |
1017 rcall DISP_brightness_full ; Gamma settings... | |
1018 rcall DISP_ClearScreen | |
1019 bsf DISPLAY_hv ; OLED volatages on | |
1020 return | |
681 | 1021 |
1022 | |
688 | 1023 display0_config_table: |
1024 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
1025 db 0x18,0x00,0x28,0xF8,0x00,0x0F | |
1026 db 0xF9,0x00,0x0F,0x10,0x00,0x00 | |
1027 db 0x05,0x00,0x01,0xFF,0x00,0x00 | |
681 | 1028 |
1029 | |
1030 DISP_brightness_full: ; Choose between Eco and High... | |
1031 btfsc DISPLAY_brightness_high ; DISPLAY brightness (=0: Eco, =1: High) | |
1032 bra DISP_brightness_full_high | |
1033 ; Mid | |
1034 bsf PORTB,7 | |
708 | 1035 nop |
681 | 1036 bcf PORTB,6 |
1037 | |
1038 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1039 btfsc WREG,1 ; Display1? | |
1040 return ; Yes, done. | |
1041 | |
688 | 1042 movlw LOW display0_gamma_high_table |
1043 movwf TBLPTRL | |
1044 movlw HIGH display0_gamma_high_table | |
1045 movwf TBLPTRH | |
1046 movlw UPPER display0_gamma_high_table | |
1047 movwf TBLPTRU | |
1048 bra display0_init_loop ; And return... | |
681 | 1049 |
1050 | |
1051 DISP_brightness_full_high: | |
1052 ; Full | |
1053 bsf PORTB,7 | |
708 | 1054 nop |
681 | 1055 bsf PORTB,6 |
1056 | |
1057 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1058 btfsc WREG,1 ; Display1? | |
1059 return ; Yes, done. | |
1060 | |
688 | 1061 movlw LOW display0_gamma_full_table |
1062 movwf TBLPTRL | |
1063 movlw HIGH display0_gamma_full_table | |
1064 movwf TBLPTRH | |
1065 movlw UPPER display0_gamma_full_table | |
1066 movwf TBLPTRU | |
1067 bra display0_init_loop ; And return... | |
681 | 1068 |
1069 | |
1070 DISP_brightness_low: | |
1071 ;Low | |
1072 bcf PORTB,7 | |
708 | 1073 nop |
681 | 1074 bcf PORTB,6 |
1075 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1076 btfsc WREG,1 ; Display1? | |
1077 return ; Yes, done. | |
688 | 1078 movlw LOW display0_gamma_low_table |
1079 movwf TBLPTRL | |
1080 movlw HIGH display0_gamma_low_table | |
1081 movwf TBLPTRH | |
1082 movlw UPPER display0_gamma_low_table | |
1083 movwf TBLPTRU | |
1084 bra display0_init_loop ; And return... | |
681 | 1085 |
688 | 1086 display0_init_loop: |
1087 TBLRD*+ | |
1088 movlw 0xFF | |
1089 cpfseq TABLAT | |
1090 bra display0_config_write ; Write Config pair to Display | |
1091 ; Delay ms or quit (return) | |
1092 TBLRD*+ | |
1093 tstfsz TABLAT ; End of config? | |
1094 bra $+4 ; No | |
1095 return ; Done. | |
1096 movf TABLAT,W | |
1097 call WAITMSX ; Wait WREG milliseconds | |
1098 bra display0_init_loop ; Loop | |
681 | 1099 |
688 | 1100 display0_config_write: ; With command in WREG |
1101 movf TABLAT,W | |
1102 rcall DISP_CmdWrite ; Write command | |
1103 TBLRD*+ ; Get config | |
1104 movf TABLAT,W | |
1105 rcall DISP_DataWrite ; Write config | |
1106 TBLRD*+ ; Get config | |
1107 movf TABLAT,W | |
1108 rcall DISP_DataWrite ; Write config | |
1109 bra display0_init_loop ; Loop | |
1110 | |
681 | 1111 |
688 | 1112 display0_gamma_high_table: |
1113 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
1114 db 0x70,0x1B,0x80,0x71,0x1F,0x00 | |
1115 db 0x72,0x22,0x00,0x73,0x17,0x11 | |
1116 db 0x74,0x1A,0x0E,0x75,0x1D,0x15 | |
1117 db 0x76,0x18,0x11,0x77,0x1E,0x18 | |
1118 db 0x78,0x1D,0x11,0xFF,0x00,0x00 | |
681 | 1119 |
688 | 1120 display0_gamma_full_table: |
1121 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
1122 db 0x70,0x1F,0x00,0x71,0x23,0x80 | |
1123 db 0x72,0x2A,0x80,0x73,0x15,0x11 | |
1124 db 0x74,0x1C,0x11,0x75,0x1B,0x15 | |
1125 db 0x76,0x1A,0x15,0x77,0x1C,0x18 | |
1126 db 0x78,0x21,0x15,0xFF,0x00,0x00 | |
1127 | |
1128 display0_gamma_low_table: | |
1129 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end | |
1130 db 0x70,0x14,0x00,0x71,0x17,0x00 | |
1131 db 0x72,0x15,0x80,0x73,0x15,0x11 | |
1132 db 0x74,0x14,0x0B,0x75,0x1B,0x15 | |
1133 db 0x76,0x13,0x0E,0x77,0x1C,0x18 | |
1134 db 0x78,0x15,0x0E,0xFF,0x00,0x00 | |
1135 | |
681 | 1136 |
1137 DISP_set_color:;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGG GGGBBBBB' | |
1138 movwf DISPLAY1_temp ; Get 8Bit RGB b'RRRGGGBB' | |
1139 movwf DISPLAY2_temp ; Copy | |
706 | 1140 movff WREG,win_color6 ; Another (bank-safe) copy |
681 | 1141 |
1142 ; Display0 | |
1143 ; Mask Bit 7,6,5,4,3,2 | |
1144 movlw b'00000011' | |
1145 andwf DISPLAY2_temp,F | |
1146 | |
1147 movlw b'00000000' | |
1148 dcfsnz DISPLAY2_temp,F | |
1149 movlw b'01010000' | |
1150 dcfsnz DISPLAY2_temp,F | |
1151 movlw b'10100000' | |
1152 dcfsnz DISPLAY2_temp,F | |
1153 movlw b'11111000' | |
1154 movwf DISPLAY3_temp ; Blue done. | |
1155 | |
1156 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1157 ; Mask Bit 7,6,5,1,0 | |
1158 movlw b'00011100' | |
1159 andwf DISPLAY2_temp,F | |
1160 rrncf DISPLAY2_temp,F | |
1161 rrncf DISPLAY2_temp,F | |
1162 | |
1163 movlw b'00000000' | |
1164 dcfsnz DISPLAY2_temp,F | |
1165 movlw b'00000100' | |
1166 dcfsnz DISPLAY2_temp,F | |
1167 movlw b'00001000' | |
1168 dcfsnz DISPLAY2_temp,F | |
1169 movlw b'00001100' | |
1170 dcfsnz DISPLAY2_temp,F | |
1171 movlw b'00010000' | |
1172 dcfsnz DISPLAY2_temp,F | |
1173 movlw b'00010100' | |
1174 dcfsnz DISPLAY2_temp,F | |
1175 movlw b'00100000' | |
1176 dcfsnz DISPLAY2_temp,F | |
1177 movlw b'00111111' | |
1178 movwf DISPLAY4_temp | |
1179 | |
1180 rrcf DISPLAY4_temp,F | |
1181 rrcf DISPLAY3_temp,F | |
1182 | |
1183 rrcf DISPLAY4_temp,F | |
1184 rrcf DISPLAY3_temp,F | |
1185 | |
1186 rrcf DISPLAY4_temp,F | |
1187 rrcf DISPLAY3_temp,F ; DISPLAY3_temp (b'GGGBBBBB') done. | |
1188 | |
1189 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1190 clrf DISPLAY1_temp | |
1191 | |
1192 rrcf DISPLAY4_temp,F | |
1193 rrcf DISPLAY1_temp,F | |
1194 | |
1195 rrcf DISPLAY4_temp,F | |
1196 rrcf DISPLAY1_temp,F | |
1197 | |
1198 rrcf DISPLAY4_temp,F | |
1199 rrcf DISPLAY1_temp,F ; Green done. | |
1200 | |
1201 ; Mask Bit 4,3,2,1,0 | |
1202 movlw b'11100000' | |
1203 andwf DISPLAY2_temp,F | |
1204 | |
1205 rrncf DISPLAY2_temp,F | |
1206 rrncf DISPLAY2_temp,F | |
1207 rrncf DISPLAY2_temp,F | |
1208 rrncf DISPLAY2_temp,F | |
1209 rrncf DISPLAY2_temp,F | |
1210 | |
1211 movlw b'00000000' | |
1212 dcfsnz DISPLAY2_temp,F | |
1213 movlw b'00000100' | |
1214 dcfsnz DISPLAY2_temp,F | |
1215 movlw b'00001000' | |
1216 dcfsnz DISPLAY2_temp,F | |
1217 movlw b'00001100' | |
1218 dcfsnz DISPLAY2_temp,F | |
1219 movlw b'00010000' | |
1220 dcfsnz DISPLAY2_temp,F | |
1221 movlw b'00010100' | |
1222 dcfsnz DISPLAY2_temp,F | |
1223 movlw b'00100000' | |
1224 dcfsnz DISPLAY2_temp,F | |
1225 movlw b'00111111' | |
1226 movwf DISPLAY4_temp | |
1227 | |
1228 rrcf DISPLAY4_temp,F | |
1229 rrcf DISPLAY1_temp,F | |
1230 | |
1231 rrcf DISPLAY4_temp,F | |
1232 rrcf DISPLAY1_temp,F | |
1233 | |
1234 rrcf DISPLAY4_temp,F | |
1235 rrcf DISPLAY1_temp,F | |
1236 | |
1237 rrcf DISPLAY4_temp,F | |
1238 rrcf DISPLAY1_temp,F | |
1239 | |
1240 rrcf DISPLAY4_temp,F | |
1241 rrcf DISPLAY1_temp,F ; Red done. | |
1242 | |
1243 movff DISPLAY1_temp,win_color1 | |
1244 movff DISPLAY3_temp,win_color2 ; Set Bank0 Color registers... | |
706 | 1245 |
1246 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1247 btfss WREG,1 ; Display1? | |
1248 return ; No | |
681 | 1249 |
684 | 1250 DISP_set_color_display1:;Converts 8Bit RGB b'RRRGGGBB' into 24Bit RGB b'00RRRRRR 00GGGGGG 00BBBBBB' |
706 | 1251 movff win_color6,DISPLAY1_temp |
1252 movff win_color6,DISPLAY2_temp | |
1253 | |
681 | 1254 ; Mask Bit 7,6,5,4,3,2 |
1255 movlw b'00000011' | |
1256 andwf DISPLAY2_temp,F | |
1257 | |
1258 movlw b'00000000' | |
1259 dcfsnz DISPLAY2_temp,F | |
1260 movlw b'01010000' | |
1261 dcfsnz DISPLAY2_temp,F | |
1262 movlw b'10100000' | |
1263 dcfsnz DISPLAY2_temp,F | |
1264 movlw b'11111000' | |
706 | 1265 movff WREG,win_color6 ; B |
681 | 1266 |
1267 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1268 ; Mask Bit 7,6,5,1,0 | |
1269 movlw b'00011100' | |
1270 andwf DISPLAY2_temp,F | |
1271 rrncf DISPLAY2_temp,F | |
1272 rrncf DISPLAY2_temp,F | |
1273 | |
1274 movlw b'00000000' | |
1275 dcfsnz DISPLAY2_temp,F | |
1276 movlw b'00010000' | |
1277 dcfsnz DISPLAY2_temp,F | |
1278 movlw b'00100000' | |
1279 dcfsnz DISPLAY2_temp,F | |
1280 movlw b'00110000' | |
1281 dcfsnz DISPLAY2_temp,F | |
1282 movlw b'01000000' | |
1283 dcfsnz DISPLAY2_temp,F | |
1284 movlw b'01010000' | |
1285 dcfsnz DISPLAY2_temp,F | |
1286 movlw b'10000000' | |
1287 dcfsnz DISPLAY2_temp,F | |
1288 movlw b'11111100' | |
706 | 1289 movff WREG,win_color5 ; G |
681 | 1290 |
1291 ; Mask Bit 4,3,2,1,0 | |
1292 movlw b'11100000' | |
684 | 1293 andwf DISPLAY1_temp,F |
681 | 1294 |
684 | 1295 rrncf DISPLAY1_temp,F |
1296 rrncf DISPLAY1_temp,F | |
1297 rrncf DISPLAY1_temp,F | |
1298 rrncf DISPLAY1_temp,F | |
1299 rrncf DISPLAY1_temp,F | |
681 | 1300 |
1301 movlw b'00000000' | |
684 | 1302 dcfsnz DISPLAY1_temp,F |
681 | 1303 movlw b'00010000' |
684 | 1304 dcfsnz DISPLAY1_temp,F |
681 | 1305 movlw b'00100000' |
684 | 1306 dcfsnz DISPLAY1_temp,F |
681 | 1307 movlw b'00110000' |
684 | 1308 dcfsnz DISPLAY1_temp,F |
681 | 1309 movlw b'01000000' |
684 | 1310 dcfsnz DISPLAY1_temp,F |
681 | 1311 movlw b'01010000' |
684 | 1312 dcfsnz DISPLAY1_temp,F |
681 | 1313 movlw b'10000000' |
684 | 1314 dcfsnz DISPLAY1_temp,F |
681 | 1315 movlw b'11111100' |
706 | 1316 movff WREG,win_color4 ; R |
681 | 1317 return |