Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/display_lowlevel.asm @ 687:a8a36c85e031
ignore screenshots with display1 (for now)
author | heinrichsweikamp |
---|---|
date | Sat, 26 Jan 2013 16:25:19 +0100 |
parents | 99b3fb0ab4c7 |
children | c04e5c18acf9 |
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 | |
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: | |
687
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
767 movff win_flags,WREG ; Display1? win_flags is in bank0... |
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
768 btfsc WREG,1 ; Display1? |
a8a36c85e031
ignore screenshots with display1 (for now)
heinrichsweikamp
parents:
684
diff
changeset
|
769 return ; Yes, done. |
681 | 770 bsf DISPLAY_rs ; Data register. |
771 bcf DISPLAY_e_nwr ; Read enable. | |
772 nop | |
773 nop | |
774 nop | |
775 nop | |
776 movf PORTD,W ; Read byte. | |
777 bsf DISPLAY_e_nwr ; release bus. | |
778 return | |
779 | |
780 ; ----------------------------- | |
781 ; DISP boot | |
782 ; ----------------------------- | |
783 DISPLAY_boot: | |
784 movlw LOW 0x17FDC | |
785 movwf TBLPTRL | |
786 movlw HIGH 0x17FDC | |
787 movwf TBLPTRH | |
788 movlw UPPER 0x17FDC | |
789 movwf TBLPTRU | |
790 TBLRD* | |
791 movlw 0x01 | |
792 cpfseq TABLAT ; Display1? | |
793 bra display0_init ; No, Display0 | |
794 | |
795 banksel win_flags | |
796 bsf win_flags,0 | |
797 bsf win_flags,1 | |
798 banksel flag1 | |
799 bcf DISPLAY_hv ; Backlight off | |
800 nop | |
801 bcf DISPLAY_vdd | |
802 WAITMS d'10' | |
803 bsf DISPLAY_vdd | |
804 WAITMS d'100' | |
805 bsf DISPLAY_rw | |
806 nop | |
807 bcf DISPLAY_cs | |
808 nop | |
809 bsf DISPLAY_nreset | |
810 WAITMS d'1' | |
811 bcf DISPLAY_nreset | |
812 WAIT10US d'2' | |
813 bsf DISPLAY_nreset | |
814 WAITMS d'120' | |
815 bsf DISPLAY_e_nwr ; release bus. | |
816 rcall display1_init ; Init sequence | |
817 rcall DISP_ClearScreen | |
818 WAITMS d'60' | |
819 bsf DISPLAY_hv ; Backlight on | |
820 return | |
821 | |
822 display1_init: | |
823 movlw LOW display1_config_table | |
824 movwf TBLPTRL | |
825 movlw HIGH display1_config_table | |
826 movwf TBLPTRH | |
827 movlw UPPER display1_config_table | |
828 movwf TBLPTRU | |
829 display_init_loop: | |
830 TBLRD*+ | |
831 movlw 0xFF | |
832 cpfseq TABLAT | |
833 bra display_config_write ; Write Config pair to Display | |
834 ; Delay ms or quit (return) | |
835 TBLRD*+ | |
836 tstfsz TABLAT ; End of config? | |
837 bra $+4 ; No | |
838 return ; Done. | |
839 movf TABLAT,W | |
840 call WAITMSX ; Wait WREG milliseconds | |
841 bra display_init_loop ; Loop | |
842 | |
843 display_config_write: ; With command in WREG | |
844 movf TABLAT,W | |
845 rcall DISP_CmdWrite ; Write command | |
846 TBLRD*+ ; Get config | |
847 movf TABLAT,W | |
848 rcall DISP_DataWrite ; Write config | |
849 bra display_init_loop ; Loop | |
850 | |
851 | |
852 display1_config_table: | |
853 ; Reg, Dat or 0xFF, Delay or 0xFF, 0x00 (End) | |
854 db 0x96,0x01 | |
855 db 0x19,0x87 | |
856 db 0xFF,.10 | |
857 db 0x26,0x80 | |
858 db 0x1B,0x0C | |
859 db 0x43,0x00 | |
860 db 0x20,0x00 | |
861 db 0x1F,0x07 | |
862 db 0x44,0x7F | |
863 db 0x45,0x14 | |
864 db 0x1D,0x05 | |
865 db 0x1E,0x00 | |
866 db 0x1C,0x04 | |
867 db 0x1B,0x14 | |
868 db 0xFF,.40 | |
869 db 0x43,0x80 | |
870 db 0x42,0x08 | |
871 db 0x23,0x95 | |
872 db 0x24,0x95 | |
873 db 0x25,0xFF | |
874 db 0x21,0x10 | |
875 db 0x2B,0x00 | |
876 db 0x95,0x01 | |
877 db 0x1A,0x00 | |
878 db 0x93,0x0F | |
879 db 0x70,0x66 | |
880 db 0x18,0x01 | |
881 db 0x46,0x86 | |
882 db 0x47,0x60 | |
883 db 0x48,0x01 | |
884 db 0x49,0x67 | |
885 db 0x4A,0x46 | |
886 db 0x4B,0x13 | |
887 db 0x4C,0x01 | |
888 db 0x4D,0x67 | |
889 db 0x4E,0x00 | |
890 db 0x4F,0x13 | |
891 db 0x50,0x02 | |
892 db 0x51,0x00 | |
893 db 0x38,0x00 | |
894 db 0x39,0x00 | |
895 db 0x27,0x02 | |
896 db 0x28,0x03 | |
897 db 0x29,0x08 | |
898 db 0x2A,0x08 | |
899 db 0x2C,0x08 | |
900 db 0x2D,0x08 | |
901 db 0x35,0x09 | |
902 db 0x36,0x09 | |
903 db 0x91,0x14 | |
904 db 0x37,0x00 | |
905 db 0x01,0x06 | |
906 db 0x3A,0xA1 | |
907 db 0x3B,0xA1 | |
908 db 0x3C,0xA1 | |
909 db 0x3D,0x00 | |
910 db 0x3E,0x2D | |
911 db 0x40,0x03 | |
912 db 0x41,0xCC | |
913 db 0x0A,0x00 | |
914 db 0x0B,0x00 | |
915 db 0x0C,0x01 | |
916 db 0x0D,0x3F | |
917 db 0x0E,0x00 | |
918 db 0x0F,0x00 | |
919 db 0x10,0x01 | |
920 db 0x11,0x40 | |
921 db 0x12,0x00 | |
922 db 0x13,0x00 | |
923 db 0x14,0x00 | |
924 db 0x15,0x00 | |
925 db 0x02,0x00 | |
926 db 0x03,0x00 | |
927 db 0x04,0x00 | |
928 db 0x05,0xEF | |
929 db 0x06,0x00 | |
930 db 0x07,0x00 | |
931 db 0x08,0x01 | |
932 db 0x09,0x3F | |
933 db 0x16,0x88 | |
934 db 0x72,0x00 | |
935 db 0x22,0x60 | |
936 db 0x94,0x0A | |
937 db 0x90,0x7F | |
938 db 0x26,0x84 | |
939 db 0xFF,.40 | |
940 db 0x26,0xA4 | |
941 db 0x26,0xAC | |
942 db 0xFF,.40 | |
943 db 0x26,0xBC | |
944 db 0x96,0x00 | |
945 db 0xFF,0x00 ; End of table pair | |
946 | |
947 | |
948 display0_init: ; Display0 | |
949 banksel win_flags | |
950 bcf win_flags,1 | |
951 banksel flag1 | |
952 bcf DISPLAY_hv | |
953 WAITMS d'32' | |
954 bsf DISPLAY_vdd | |
955 nop | |
956 bcf DISPLAY_cs | |
957 nop | |
958 bsf DISPLAY_nreset | |
959 WAITMS d'250' ; Standard wake-up | |
960 bsf DISPLAY_e_nwr | |
961 nop | |
962 bcf DISPLAY_nreset | |
963 WAIT10US d'2' | |
964 bsf DISPLAY_nreset | |
965 WAITMS d'10' | |
966 | |
967 movlw 0x24 ; 80-System 8-Bit Mode | |
968 rcall DISP_CmdWrite | |
969 | |
970 movlw 0x02 ; RGB Interface Control (S6E63D6 Datasheet page 42) | |
971 rcall DISP_CmdWrite | |
972 movlw 0x00 ; X X X X X X X RM | |
973 rcall DISP_DataWrite | |
974 movlw 0x00 ; DM X RIM1 RIM0 VSPL HSPL EPL DPL | |
975 rcall DISP_DataWrite ; System Interface: RIM is ignored, Internal Clock | |
976 | |
977 movlw 0x03 ; Entry Mode (S6E63D6 Datasheet page 46) | |
978 rcall DISP_CmdWrite | |
979 movlw 0x00 ; CLS MDT1 MDT0 BGR X X X SS 65k Color | |
980 rcall DISP_DataWrite | |
981 | |
982 ; Change direction for block-writes of pixels | |
983 lfsr FSR0,win_flags | |
684 | 984 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM |
681 | 985 btfss INDF0,0 ; BANK-SAFE bit test. |
986 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM | |
987 rcall DISP_DataWrite | |
988 | |
989 movlw 0x18 | |
990 rcall DISP_CmdWrite | |
991 movlw 0x00 | |
992 rcall DISP_DataWrite | |
993 movlw 0x28 | |
994 rcall DISP_DataWrite | |
995 | |
996 movlw 0xF8 | |
997 rcall DISP_CmdWrite | |
998 movlw 0x00 | |
999 rcall DISP_DataWrite | |
1000 movlw 0x0F | |
1001 rcall DISP_DataWrite | |
1002 | |
1003 movlw 0xF9 | |
1004 rcall DISP_CmdWrite | |
1005 movlw 0x00 | |
1006 rcall DISP_DataWrite | |
1007 movlw 0x0F | |
1008 rcall DISP_DataWrite | |
1009 | |
1010 movlw 0x10 | |
1011 rcall DISP_CmdWrite | |
1012 movlw 0x00 | |
1013 rcall DISP_DataWrite | |
1014 movlw 0x00 | |
1015 rcall DISP_DataWrite | |
1016 | |
1017 ; Now Gamma settings... | |
1018 rcall DISP_brightness_full | |
1019 ;rcall DISP_brightness_low | |
1020 ; End Gamma Settings | |
1021 | |
1022 rcall DISP_ClearScreen | |
1023 | |
1024 bsf DISPLAY_hv | |
1025 WAITMS d'32' | |
1026 bsf DISPLAY_hv | |
1027 WAITMS d'32' | |
1028 bsf DISPLAY_hv | |
1029 | |
1030 movlw 0x05 | |
1031 rcall DISP_CmdWrite | |
1032 movlw 0x00 | |
1033 rcall DISP_DataWrite | |
1034 movlw 0x01 | |
1035 rcall DISP_DataWrite ; Display ON | |
1036 return | |
1037 | |
1038 | |
1039 DISP_brightness_full: ; Choose between Eco and High... | |
1040 btfsc DISPLAY_brightness_high ; DISPLAY brightness (=0: Eco, =1: High) | |
1041 bra DISP_brightness_full_high | |
1042 ; Mid | |
1043 bsf PORTB,7 | |
1044 bcf PORTB,6 | |
1045 | |
1046 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1047 btfsc WREG,1 ; Display1? | |
1048 return ; Yes, done. | |
1049 | |
1050 movlw 0x70 | |
1051 rcall DISP_CmdWrite | |
1052 movlw 0x1B | |
1053 rcall DISP_DataWrite | |
1054 movlw 0x80 | |
1055 rcall DISP_DataWrite | |
1056 movlw 0x71 | |
1057 rcall DISP_CmdWrite | |
1058 movlw 0x1F | |
1059 rcall DISP_DataWrite | |
1060 movlw 0x00 | |
1061 rcall DISP_DataWrite | |
1062 movlw 0x72 | |
1063 rcall DISP_CmdWrite | |
1064 movlw 0x22 | |
1065 rcall DISP_DataWrite | |
1066 movlw 0x00 | |
1067 rcall DISP_DataWrite | |
1068 | |
1069 movlw 0x73 | |
1070 rcall DISP_CmdWrite | |
1071 movlw 0x17 | |
1072 rcall DISP_DataWrite | |
1073 movlw 0x11 | |
1074 rcall DISP_DataWrite | |
1075 movlw 0x74 | |
1076 rcall DISP_CmdWrite | |
1077 movlw 0x1A | |
1078 rcall DISP_DataWrite | |
1079 movlw 0x0E | |
1080 rcall DISP_DataWrite | |
1081 | |
1082 movlw 0x75 | |
1083 rcall DISP_CmdWrite | |
1084 movlw 0x1D | |
1085 rcall DISP_DataWrite | |
1086 movlw 0x15 | |
1087 rcall DISP_DataWrite | |
1088 movlw 0x76 | |
1089 rcall DISP_CmdWrite | |
1090 movlw 0x18 | |
1091 rcall DISP_DataWrite | |
1092 movlw 0x11 | |
1093 rcall DISP_DataWrite | |
1094 | |
1095 movlw 0x77 | |
1096 rcall DISP_CmdWrite | |
1097 movlw 0x1E | |
1098 rcall DISP_DataWrite | |
1099 movlw 0x18 | |
1100 rcall DISP_DataWrite | |
1101 movlw 0x78 | |
1102 rcall DISP_CmdWrite | |
1103 movlw 0x1D | |
1104 rcall DISP_DataWrite | |
1105 movlw 0x11 | |
1106 rcall DISP_DataWrite | |
1107 return | |
1108 | |
1109 DISP_brightness_full_high: | |
1110 ; Full | |
1111 bsf PORTB,7 | |
1112 bsf PORTB,6 | |
1113 | |
1114 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1115 btfsc WREG,1 ; Display1? | |
1116 return ; Yes, done. | |
1117 | |
1118 movlw 0x70 | |
1119 rcall DISP_CmdWrite | |
1120 movlw 0x1F | |
1121 rcall DISP_DataWrite | |
1122 movlw 0x00 | |
1123 rcall DISP_DataWrite | |
1124 movlw 0x71 | |
1125 rcall DISP_CmdWrite | |
1126 movlw 0x23 | |
1127 rcall DISP_DataWrite | |
1128 movlw 0x80 | |
1129 rcall DISP_DataWrite | |
1130 movlw 0x72 | |
1131 rcall DISP_CmdWrite | |
1132 movlw 0x2A | |
1133 rcall DISP_DataWrite | |
1134 movlw 0x80 | |
1135 rcall DISP_DataWrite | |
1136 | |
1137 movlw 0x73 | |
1138 rcall DISP_CmdWrite | |
1139 movlw 0x15 | |
1140 rcall DISP_DataWrite | |
1141 movlw 0x11 | |
1142 rcall DISP_DataWrite | |
1143 movlw 0x74 | |
1144 rcall DISP_CmdWrite | |
1145 movlw 0x1C | |
1146 rcall DISP_DataWrite | |
1147 movlw 0x11 | |
1148 rcall DISP_DataWrite | |
1149 | |
1150 movlw 0x75 | |
1151 rcall DISP_CmdWrite | |
1152 movlw 0x1B | |
1153 rcall DISP_DataWrite | |
1154 movlw 0x15 | |
1155 rcall DISP_DataWrite | |
1156 movlw 0x76 | |
1157 rcall DISP_CmdWrite | |
1158 movlw 0x1A | |
1159 rcall DISP_DataWrite | |
1160 movlw 0x15 | |
1161 rcall DISP_DataWrite | |
1162 | |
1163 movlw 0x77 | |
1164 rcall DISP_CmdWrite | |
1165 movlw 0x1C | |
1166 rcall DISP_DataWrite | |
1167 movlw 0x18 | |
1168 rcall DISP_DataWrite | |
1169 movlw 0x78 | |
1170 rcall DISP_CmdWrite | |
1171 movlw 0x21 | |
1172 rcall DISP_DataWrite | |
1173 movlw 0x15 | |
1174 rcall DISP_DataWrite | |
1175 return | |
1176 | |
1177 | |
1178 DISP_brightness_low: | |
1179 ;Low | |
1180 bcf PORTB,7 | |
1181 bcf PORTB,6 | |
1182 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1183 btfsc WREG,1 ; Display1? | |
1184 return ; Yes, done. | |
1185 | |
1186 movlw 0x70 | |
1187 rcall DISP_CmdWrite | |
1188 movlw 0x14 | |
1189 rcall DISP_DataWrite | |
1190 movlw 0x00 | |
1191 rcall DISP_DataWrite | |
1192 movlw 0x71 | |
1193 rcall DISP_CmdWrite | |
1194 movlw 0x17 | |
1195 rcall DISP_DataWrite | |
1196 movlw 0x00 | |
1197 rcall DISP_DataWrite | |
1198 movlw 0x72 | |
1199 rcall DISP_CmdWrite | |
1200 movlw 0x15 | |
1201 rcall DISP_DataWrite | |
1202 movlw 0x80 | |
1203 rcall DISP_DataWrite | |
1204 | |
1205 movlw 0x73 | |
1206 rcall DISP_CmdWrite | |
1207 movlw 0x15 | |
1208 rcall DISP_DataWrite | |
1209 movlw 0x11 | |
1210 rcall DISP_DataWrite | |
1211 movlw 0x74 | |
1212 rcall DISP_CmdWrite | |
1213 movlw 0x14 | |
1214 rcall DISP_DataWrite | |
1215 movlw 0x0B | |
1216 rcall DISP_DataWrite | |
1217 | |
1218 movlw 0x75 | |
1219 rcall DISP_CmdWrite | |
1220 movlw 0x1B | |
1221 rcall DISP_DataWrite | |
1222 movlw 0x15 | |
1223 rcall DISP_DataWrite | |
1224 movlw 0x76 | |
1225 rcall DISP_CmdWrite | |
1226 movlw 0x13 | |
1227 rcall DISP_DataWrite | |
1228 movlw 0x0E | |
1229 rcall DISP_DataWrite | |
1230 | |
1231 movlw 0x77 | |
1232 rcall DISP_CmdWrite | |
1233 movlw 0x1C | |
1234 rcall DISP_DataWrite | |
1235 movlw 0x18 | |
1236 rcall DISP_DataWrite | |
1237 movlw 0x78 | |
1238 rcall DISP_CmdWrite | |
1239 movlw 0x15 | |
1240 rcall DISP_DataWrite | |
1241 movlw 0x0E | |
1242 rcall DISP_DataWrite | |
1243 | |
1244 return | |
1245 | |
1246 DISP_set_color:;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGG GGGBBBBB' | |
1247 movwf DISPLAY1_temp ; Get 8Bit RGB b'RRRGGGBB' | |
1248 movwf DISPLAY2_temp ; Copy | |
1249 | |
1250 movff win_flags,WREG ; Display1? win_flags is in bank0... | |
1251 btfsc WREG,1 ; Display1? | |
1252 bra DISP_set_color_display1 ; Yes | |
1253 | |
1254 ; Display0 | |
1255 ; Mask Bit 7,6,5,4,3,2 | |
1256 movlw b'00000011' | |
1257 andwf DISPLAY2_temp,F | |
1258 | |
1259 movlw b'00000000' | |
1260 dcfsnz DISPLAY2_temp,F | |
1261 movlw b'01010000' | |
1262 dcfsnz DISPLAY2_temp,F | |
1263 movlw b'10100000' | |
1264 dcfsnz DISPLAY2_temp,F | |
1265 movlw b'11111000' | |
1266 movwf DISPLAY3_temp ; Blue done. | |
1267 | |
1268 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1269 ; Mask Bit 7,6,5,1,0 | |
1270 movlw b'00011100' | |
1271 andwf DISPLAY2_temp,F | |
1272 rrncf DISPLAY2_temp,F | |
1273 rrncf DISPLAY2_temp,F | |
1274 | |
1275 movlw b'00000000' | |
1276 dcfsnz DISPLAY2_temp,F | |
1277 movlw b'00000100' | |
1278 dcfsnz DISPLAY2_temp,F | |
1279 movlw b'00001000' | |
1280 dcfsnz DISPLAY2_temp,F | |
1281 movlw b'00001100' | |
1282 dcfsnz DISPLAY2_temp,F | |
1283 movlw b'00010000' | |
1284 dcfsnz DISPLAY2_temp,F | |
1285 movlw b'00010100' | |
1286 dcfsnz DISPLAY2_temp,F | |
1287 movlw b'00100000' | |
1288 dcfsnz DISPLAY2_temp,F | |
1289 movlw b'00111111' | |
1290 movwf DISPLAY4_temp | |
1291 | |
1292 rrcf DISPLAY4_temp,F | |
1293 rrcf DISPLAY3_temp,F | |
1294 | |
1295 rrcf DISPLAY4_temp,F | |
1296 rrcf DISPLAY3_temp,F | |
1297 | |
1298 rrcf DISPLAY4_temp,F | |
1299 rrcf DISPLAY3_temp,F ; DISPLAY3_temp (b'GGGBBBBB') done. | |
1300 | |
1301 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1302 clrf DISPLAY1_temp | |
1303 | |
1304 rrcf DISPLAY4_temp,F | |
1305 rrcf DISPLAY1_temp,F | |
1306 | |
1307 rrcf DISPLAY4_temp,F | |
1308 rrcf DISPLAY1_temp,F | |
1309 | |
1310 rrcf DISPLAY4_temp,F | |
1311 rrcf DISPLAY1_temp,F ; Green done. | |
1312 | |
1313 ; Mask Bit 4,3,2,1,0 | |
1314 movlw b'11100000' | |
1315 andwf DISPLAY2_temp,F | |
1316 | |
1317 rrncf DISPLAY2_temp,F | |
1318 rrncf DISPLAY2_temp,F | |
1319 rrncf DISPLAY2_temp,F | |
1320 rrncf DISPLAY2_temp,F | |
1321 rrncf DISPLAY2_temp,F | |
1322 | |
1323 movlw b'00000000' | |
1324 dcfsnz DISPLAY2_temp,F | |
1325 movlw b'00000100' | |
1326 dcfsnz DISPLAY2_temp,F | |
1327 movlw b'00001000' | |
1328 dcfsnz DISPLAY2_temp,F | |
1329 movlw b'00001100' | |
1330 dcfsnz DISPLAY2_temp,F | |
1331 movlw b'00010000' | |
1332 dcfsnz DISPLAY2_temp,F | |
1333 movlw b'00010100' | |
1334 dcfsnz DISPLAY2_temp,F | |
1335 movlw b'00100000' | |
1336 dcfsnz DISPLAY2_temp,F | |
1337 movlw b'00111111' | |
1338 movwf DISPLAY4_temp | |
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 | |
1351 | |
1352 rrcf DISPLAY4_temp,F | |
1353 rrcf DISPLAY1_temp,F ; Red done. | |
1354 | |
1355 movff DISPLAY1_temp,win_color1 | |
1356 movff DISPLAY3_temp,win_color2 ; Set Bank0 Color registers... | |
1357 return | |
1358 | |
684 | 1359 DISP_set_color_display1:;Converts 8Bit RGB b'RRRGGGBB' into 24Bit RGB b'00RRRRRR 00GGGGGG 00BBBBBB' |
681 | 1360 ; Mask Bit 7,6,5,4,3,2 |
1361 movlw b'00000011' | |
1362 andwf DISPLAY2_temp,F | |
1363 | |
1364 movlw b'00000000' | |
1365 dcfsnz DISPLAY2_temp,F | |
1366 movlw b'01010000' | |
1367 dcfsnz DISPLAY2_temp,F | |
1368 movlw b'10100000' | |
1369 dcfsnz DISPLAY2_temp,F | |
1370 movlw b'11111000' | |
1371 movff WREG,win_color3 ; B | |
1372 | |
1373 movff DISPLAY1_temp, DISPLAY2_temp ; Copy | |
1374 ; Mask Bit 7,6,5,1,0 | |
1375 movlw b'00011100' | |
1376 andwf DISPLAY2_temp,F | |
1377 rrncf DISPLAY2_temp,F | |
1378 rrncf DISPLAY2_temp,F | |
1379 | |
1380 movlw b'00000000' | |
1381 dcfsnz DISPLAY2_temp,F | |
1382 movlw b'00010000' | |
1383 dcfsnz DISPLAY2_temp,F | |
1384 movlw b'00100000' | |
1385 dcfsnz DISPLAY2_temp,F | |
1386 movlw b'00110000' | |
1387 dcfsnz DISPLAY2_temp,F | |
1388 movlw b'01000000' | |
1389 dcfsnz DISPLAY2_temp,F | |
1390 movlw b'01010000' | |
1391 dcfsnz DISPLAY2_temp,F | |
1392 movlw b'10000000' | |
1393 dcfsnz DISPLAY2_temp,F | |
1394 movlw b'11111100' | |
1395 movff WREG,win_color2 ; G | |
1396 | |
1397 ; Mask Bit 4,3,2,1,0 | |
1398 movlw b'11100000' | |
684 | 1399 andwf DISPLAY1_temp,F |
681 | 1400 |
684 | 1401 rrncf DISPLAY1_temp,F |
1402 rrncf DISPLAY1_temp,F | |
1403 rrncf DISPLAY1_temp,F | |
1404 rrncf DISPLAY1_temp,F | |
1405 rrncf DISPLAY1_temp,F | |
681 | 1406 |
1407 movlw b'00000000' | |
684 | 1408 dcfsnz DISPLAY1_temp,F |
681 | 1409 movlw b'00010000' |
684 | 1410 dcfsnz DISPLAY1_temp,F |
681 | 1411 movlw b'00100000' |
684 | 1412 dcfsnz DISPLAY1_temp,F |
681 | 1413 movlw b'00110000' |
684 | 1414 dcfsnz DISPLAY1_temp,F |
681 | 1415 movlw b'01000000' |
684 | 1416 dcfsnz DISPLAY1_temp,F |
681 | 1417 movlw b'01010000' |
684 | 1418 dcfsnz DISPLAY1_temp,F |
681 | 1419 movlw b'10000000' |
684 | 1420 dcfsnz DISPLAY1_temp,F |
681 | 1421 movlw b'11111100' |
1422 movff WREG,win_color1 ; R | |
1423 return |