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