comparison code_part1/OSTC_code_asm_part1/display_lowlevel.asm @ 684:99b3fb0ab4c7

pixel_write fix
author heinrichsweikamp
date Sat, 26 Jan 2013 10:41:35 +0100
parents 6e456a6398e0
children a8a36c85e031
comparison
equal deleted inserted replaced
683:f998411851b7 684:99b3fb0ab4c7
106 ; of the autoincrement going vertical 106 ; of the autoincrement going vertical
107 107
108 ;---- Do the 16bit 319-X-->X, if needed, and send to DISPLAY ------------ 108 ;---- Do the 16bit 319-X-->X, if needed, and send to DISPLAY ------------
109 pixel_write_col320: 109 pixel_write_col320:
110 movff win_flags,WREG ; BEWARE: bank0 bit-test 110 movff win_flags,WREG ; BEWARE: bank0 bit-test
111 btfsc WREG,1 ; Display1
112 bra pixel_write_noflip_H_display1 ; Yes.
111 btfss WREG,0 ; 180° rotation ? 113 btfss WREG,0 ; 180° rotation ?
112 bra pixel_write_noflip_H 114 bra pixel_write_noflip_H
113 115
114 movf PRODL,W ; 16bits 319 - PROD --> PROD 116 movf PRODL,W ; 16bits 319 - PROD --> PROD
115 sublw LOW(.319) ; 319-W --> W 117 sublw LOW(.319) ; 319-W --> W
121 movwf PRODH 123 movwf PRODH
122 124
123 pixel_write_noflip_H: 125 pixel_write_noflip_H:
124 movlw 0x21 ; Start Address Vertical (.0 - .319) 126 movlw 0x21 ; Start Address Vertical (.0 - .319)
125 rcall DISP_CmdWrite 127 rcall DISP_CmdWrite
126 bra DISP_DataWrite_PROD 128 bra DISP_DataWrite_PROD ; And return...
127 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
139
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
128 ;----------------------------------------------------------------------------- 154 ;-----------------------------------------------------------------------------
129 ; Writes a vertical line of half-pixel at position (win_top,win_leftx2,win_height). 155 ; 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 156 ; Inputs: win_leftx2, win_top, win_height, win_color:2
131 ; Trashed: WREG, PROD, TABLAT, TBLPTRL 157 ; Trashed: WREG, PROD, TABLAT, TBLPTRL
132 half_vertical_line: 158 half_vertical_line:
154 ; Writes one half-pixel at position (win_top,win_leftx2). 180 ; Writes one half-pixel at position (win_top,win_leftx2).
155 ; Inputs: win_leftx2, win_top, win_color:2 181 ; Inputs: win_leftx2, win_top, win_color:2
156 ; Trashed: WREG, PROD 182 ; Trashed: WREG, PROD
157 half_pixel_write: 183 half_pixel_write:
158 movff win_top,WREG ; d'0' ... d'239' 184 movff win_top,WREG ; d'0' ... d'239'
159
160 ; Variant with Y position in WREG. 185 ; Variant with Y position in WREG.
161 half_pixel_write_1: 186 half_pixel_write_1:
162 movff win_flags,PRODL ; BEWARE: bank0 bit-test 187 movff win_flags,PRODL ; Display1? win_flags is in bank0...
188 btfsc PRODL,1
189 bra half_pixel_write_1_display1 ; Yes.
190
163 btfsc PRODL,0 ; 180° rotation ? 191 btfsc PRODL,0 ; 180° rotation ?
164 sublw .239 ; 239-Y --> Y 192 sublw .239 ; 239-Y --> Y
165 193 mullw 1 ; Copy row to PRODL (PRODH=0)
166 mullw 1 ; Copy row to PRODH:L 194
167 movlw 0x20 ; Horizontal Address START:END 195 movlw 0x20 ; Horizontal Address START:END
168 rcall DISP_CmdWrite 196 rcall DISP_CmdWrite
169 rcall DISP_DataWrite_PROD 197 rcall DISP_DataWrite_PROD
170 198
171 movlw 0x22 ; Start Writing Data to GRAM 199 movlw 0x22 ; Start Writing Data to GRAM
172 rcall DISP_CmdWrite 200 rcall DISP_CmdWrite
173 bsf DISPLAY_rs ; Data! 201 bsf DISPLAY_rs ; Data!
174 movff win_color1, PORTD 202 movff win_color1, PORTD
175 bcf DISPLAY_rw 203 bcf DISPLAY_rw
176 bsf DISPLAY_rw ; Upper 204 bsf DISPLAY_rw ; Upper
177 movff win_color2, PORTD 205 movff win_color2, PORTD
178 bcf DISPLAY_rw 206 bcf DISPLAY_rw
179 bsf DISPLAY_rw ; Lower 207 bsf DISPLAY_rw ; Lower
180 movff win_flags,WREG ; Display1? win_flags is in bank0... 208 return ; Done.
181 btfss WREG,1 209
182 return ; No, Done. 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
183 movff win_color3, PORTD 242 movff win_color3, PORTD
184 bcf DISPLAY_rw 243 bcf DISPLAY_rw
185 bsf DISPLAY_rw ; Lower 244 bsf DISPLAY_rw ; Lower
186 return 245 return
246
187 247
188 ; ----------------------------- 248 ; -----------------------------
189 ; DISP Display Off 249 ; DISP Display Off
190 ; ----------------------------- 250 ; -----------------------------
191 DISP_DisplayOff: 251 DISP_DisplayOff:
369 rcall DISP_CmdWrite 429 rcall DISP_CmdWrite
370 movf PRODL,W 430 movf PRODL,W
371 rcall DISP_DataWrite 431 rcall DISP_DataWrite
372 432
373 ;---- Normal vertical window ----------------------------------------- 433 ;---- Normal vertical window -----------------------------------------
374 ; Output 0x37 (top) (bottom) 434 ; Output (top) (bottom)
375 movff win_top,PRODH ; top --> PRODH (first byte) 435 movff win_top,PRODH ; top --> PRODH (first byte)
376 movff win_height,WREG 436 movff win_height,WREG
377 addwf PRODH,W 437 addwf PRODH,W
378 decf WREG 438 decf WREG
379 movwf PRODL ; top+height-1 --> PRODL (second byte) 439 movwf PRODL ; top+height-1 --> PRODL (second byte)
384 rcall DISP_DataWrite 444 rcall DISP_DataWrite
385 movlw 0x03 445 movlw 0x03
386 rcall DISP_CmdWrite 446 rcall DISP_CmdWrite
387 movf PRODH,W 447 movf PRODH,W
388 rcall DISP_DataWrite 448 rcall DISP_DataWrite
389
390 449
391 movlw 0x04 450 movlw 0x04
392 rcall DISP_CmdWrite 451 rcall DISP_CmdWrite
393 movlw 0x00 452 movlw 0x00
394 rcall DISP_DataWrite 453 rcall DISP_DataWrite
467 movff win_height,PRODL 526 movff win_height,PRODL
468 527
469 DISP_box3: ; loop width times 528 DISP_box3: ; loop width times
470 movff win_color1,PORTD 529 movff win_color1,PORTD
471 bcf DISPLAY_rw 530 bcf DISPLAY_rw
472 bsf DISPLAY_rw ; Upper 531 bsf DISPLAY_rw ; Upper
473 movff win_color2,PORTD 532 movff win_color2,PORTD
474 bcf DISPLAY_rw 533 bcf DISPLAY_rw
475 bsf DISPLAY_rw ; Lower 534 bsf DISPLAY_rw ; Lower/High
476 movff win_flags,WREG ; Display1? win_flags is in bank0... 535 movff win_flags,WREG ; Display1? win_flags is in bank0...
477 btfss WREG,1 ; Display1? 536 btfss WREG,1 ; Display1?
478 bra DISP_box3a ; No 537 bra DISP_box3a ; No
479 movff win_color3,PORTD 538 movff win_color3,PORTD
480 bcf DISPLAY_rw 539 bcf DISPLAY_rw
481 bsf DISPLAY_rw ; Lower 540 bsf DISPLAY_rw ; Lower
482 541
483 DISP_box3a: 542 DISP_box3a:
484 movff win_color1,PORTD 543 movff win_color1,PORTD
485 bcf DISPLAY_rw 544 bcf DISPLAY_rw
486 bsf DISPLAY_rw ; Upper 545 bsf DISPLAY_rw ; Upper
487 movff win_color2,PORTD 546 movff win_color2,PORTD
488 bcf DISPLAY_rw 547 bcf DISPLAY_rw
489 bsf DISPLAY_rw ; Lower 548 bsf DISPLAY_rw ; Lower/High
490 movff win_flags,WREG ; Display1? win_flags is in bank0... 549 movff win_flags,WREG ; Display1? win_flags is in bank0...
491 btfss WREG,1 ; Display1? 550 btfss WREG,1 ; Display1?
492 bra DISP_box3b ; No 551 bra DISP_box3b ; No
493 movff win_color3,PORTD 552 movff win_color3,PORTD
494 bcf DISPLAY_rw 553 bcf DISPLAY_rw
495 bsf DISPLAY_rw ; Lower 554 bsf DISPLAY_rw ; Lower
496 555
497 DISP_box3b: 556 DISP_box3b:
498 decfsz PRODL,F ; row loop finished ? 557 decfsz PRODL,F ; row loop finished ?
499 bra DISP_box3 ; No: continue. 558 bra DISP_box3 ; No: continue.
500 559
563 movlw 0x22 ; Start Writing Data to GRAM 622 movlw 0x22 ; Start Writing Data to GRAM
564 rcall DISP_CmdWrite 623 rcall DISP_CmdWrite
565 624
566 ; See Page 101 of DISPLAY Driver IC Datasheet how to handle rs/rw clocks 625 ; See Page 101 of DISPLAY Driver IC Datasheet how to handle rs/rw clocks
567 bsf DISPLAY_rs ; Data! 626 bsf DISPLAY_rs ; Data!
568 627 clrf PORTD
569 movlw .160 628 movlw .160
570 movwf PRODH 629 movwf PRODH
571 DISP_ClearScreen2: 630 DISP_ClearScreen2:
572 movlw .240 631 movlw .240
573 movwf PRODL 632 movwf PRODL
574 DISP_ClearScreen3: 633 DISP_ClearScreen3:
575
576 clrf PORTD ; Need to generate trace here too.
577 bcf DISPLAY_rw 634 bcf DISPLAY_rw
578 bsf DISPLAY_rw ; Upper 635 bsf DISPLAY_rw ; Upper
579
580 clrf PORTD ; Need to generate trace here too.
581 bcf DISPLAY_rw 636 bcf DISPLAY_rw
582 bsf DISPLAY_rw ; Lower 637 bsf DISPLAY_rw ; Lower
583
584 clrf PORTD ; Need to generate trace here too.
585 bcf DISPLAY_rw 638 bcf DISPLAY_rw
586 bsf DISPLAY_rw ; Upper 639 bsf DISPLAY_rw ; Upper
587
588 clrf PORTD ; Need to generate trace here too.
589 bcf DISPLAY_rw 640 bcf DISPLAY_rw
590 bsf DISPLAY_rw ; Lower 641 bsf DISPLAY_rw ; Lower
591
592 decfsz PRODL,F 642 decfsz PRODL,F
593 bra DISP_ClearScreen3 643 bra DISP_ClearScreen3
594 decfsz PRODH,F 644 decfsz PRODH,F
595 bra DISP_ClearScreen2 645 bra DISP_ClearScreen2
596
597 movlw 0x00 ; NOP, to stop Address Update Counter 646 movlw 0x00 ; NOP, to stop Address Update Counter
598 bra DISP_CmdWrite 647 bra DISP_CmdWrite ; And return...
599 648
600 DISP_ClearScreen_display1: 649 DISP_ClearScreen_display1:
601 ; Column Address start 650 ; Column Address start
602 movlw 0x02 651 movlw 0x02
603 rcall DISP_CmdWrite 652 rcall DISP_CmdWrite
646 movlw .160 695 movlw .160
647 movwf PRODH 696 movwf PRODH
648 DISP_ClearScreen2_display1: 697 DISP_ClearScreen2_display1:
649 movlw .240 698 movlw .240
650 movwf PRODL 699 movwf PRODL
651 clrf PORTD ; Need to generate trace here too. 700 clrf PORTD
652 DISP_ClearScreen3_display1: 701 DISP_ClearScreen3_display1:
653 bcf DISPLAY_rw 702 bcf DISPLAY_rw
654 bsf DISPLAY_rw ; Upper 703 bsf DISPLAY_rw ; Upper
655 bcf DISPLAY_rw 704 bcf DISPLAY_rw
656 bsf DISPLAY_rw ; High 705 bsf DISPLAY_rw ; High
902 bsf DISPLAY_vdd 951 bsf DISPLAY_vdd
903 nop 952 nop
904 bcf DISPLAY_cs 953 bcf DISPLAY_cs
905 nop 954 nop
906 bsf DISPLAY_nreset 955 bsf DISPLAY_nreset
907 ; WAITMS d'10' ; Quick wake-up
908 WAITMS d'250' ; Standard wake-up 956 WAITMS d'250' ; Standard wake-up
909 bsf DISPLAY_e_nwr 957 bsf DISPLAY_e_nwr
910 nop 958 nop
911 bcf DISPLAY_nreset 959 bcf DISPLAY_nreset
912 WAIT10US d'2' 960 WAIT10US d'2'
928 movlw 0x00 ; CLS MDT1 MDT0 BGR X X X SS 65k Color 976 movlw 0x00 ; CLS MDT1 MDT0 BGR X X X SS 65k Color
929 rcall DISP_DataWrite 977 rcall DISP_DataWrite
930 978
931 ; Change direction for block-writes of pixels 979 ; Change direction for block-writes of pixels
932 lfsr FSR0,win_flags 980 lfsr FSR0,win_flags
981 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM
933 btfss INDF0,0 ; BANK-SAFE bit test. 982 btfss INDF0,0 ; BANK-SAFE bit test.
934 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM 983 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 984 rcall DISP_DataWrite
938 985
939 movlw 0x18 986 movlw 0x18
940 rcall DISP_CmdWrite 987 rcall DISP_CmdWrite
941 movlw 0x00 988 movlw 0x00
1304 1351
1305 movff DISPLAY1_temp,win_color1 1352 movff DISPLAY1_temp,win_color1
1306 movff DISPLAY3_temp,win_color2 ; Set Bank0 Color registers... 1353 movff DISPLAY3_temp,win_color2 ; Set Bank0 Color registers...
1307 return 1354 return
1308 1355
1309 DISP_set_color_display1: 1356 DISP_set_color_display1:;Converts 8Bit RGB b'RRRGGGBB' into 24Bit RGB b'00RRRRRR 00GGGGGG 00BBBBBB'
1310 ; Mask Bit 7,6,5,4,3,2 1357 ; Mask Bit 7,6,5,4,3,2
1311 movlw b'00000011' 1358 movlw b'00000011'
1312 andwf DISPLAY2_temp,F 1359 andwf DISPLAY2_temp,F
1313 1360
1314 movlw b'00000000' 1361 movlw b'00000000'
1316 movlw b'01010000' 1363 movlw b'01010000'
1317 dcfsnz DISPLAY2_temp,F 1364 dcfsnz DISPLAY2_temp,F
1318 movlw b'10100000' 1365 movlw b'10100000'
1319 dcfsnz DISPLAY2_temp,F 1366 dcfsnz DISPLAY2_temp,F
1320 movlw b'11111000' 1367 movlw b'11111000'
1321 ; movwf DISPLAY3_temp ; Blue done.
1322 movff WREG,win_color3 ; B 1368 movff WREG,win_color3 ; B
1323 1369
1324 movff DISPLAY1_temp, DISPLAY2_temp ; Copy 1370 movff DISPLAY1_temp, DISPLAY2_temp ; Copy
1325 ; Mask Bit 7,6,5,1,0 1371 ; Mask Bit 7,6,5,1,0
1326 movlw b'00011100' 1372 movlw b'00011100'
1341 movlw b'01010000' 1387 movlw b'01010000'
1342 dcfsnz DISPLAY2_temp,F 1388 dcfsnz DISPLAY2_temp,F
1343 movlw b'10000000' 1389 movlw b'10000000'
1344 dcfsnz DISPLAY2_temp,F 1390 dcfsnz DISPLAY2_temp,F
1345 movlw b'11111100' 1391 movlw b'11111100'
1346 ; movwf DISPLAY4_temp
1347 movff WREG,win_color2 ; G 1392 movff WREG,win_color2 ; G
1348 1393
1349 movff DISPLAY1_temp, DISPLAY2_temp ; Copy
1350 ; Mask Bit 4,3,2,1,0 1394 ; Mask Bit 4,3,2,1,0
1351 movlw b'11100000' 1395 movlw b'11100000'
1352 andwf DISPLAY2_temp,F 1396 andwf DISPLAY1_temp,F
1353 1397
1354 rrncf DISPLAY2_temp,F 1398 rrncf DISPLAY1_temp,F
1355 rrncf DISPLAY2_temp,F 1399 rrncf DISPLAY1_temp,F
1356 rrncf DISPLAY2_temp,F 1400 rrncf DISPLAY1_temp,F
1357 rrncf DISPLAY2_temp,F 1401 rrncf DISPLAY1_temp,F
1358 rrncf DISPLAY2_temp,F 1402 rrncf DISPLAY1_temp,F
1359 1403
1360 movlw b'00000000' 1404 movlw b'00000000'
1361 dcfsnz DISPLAY2_temp,F 1405 dcfsnz DISPLAY1_temp,F
1362 movlw b'00010000' 1406 movlw b'00010000'
1363 dcfsnz DISPLAY2_temp,F 1407 dcfsnz DISPLAY1_temp,F
1364 movlw b'00100000' 1408 movlw b'00100000'
1365 dcfsnz DISPLAY2_temp,F 1409 dcfsnz DISPLAY1_temp,F
1366 movlw b'00110000' 1410 movlw b'00110000'
1367 dcfsnz DISPLAY2_temp,F 1411 dcfsnz DISPLAY1_temp,F
1368 movlw b'01000000' 1412 movlw b'01000000'
1369 dcfsnz DISPLAY2_temp,F 1413 dcfsnz DISPLAY1_temp,F
1370 movlw b'01010000' 1414 movlw b'01010000'
1371 dcfsnz DISPLAY2_temp,F 1415 dcfsnz DISPLAY1_temp,F
1372 movlw b'10000000' 1416 movlw b'10000000'
1373 dcfsnz DISPLAY2_temp,F 1417 dcfsnz DISPLAY1_temp,F
1374 movlw b'11111100' 1418 movlw b'11111100'
1375 ; movwf DISPLAY4_temp
1376 movff WREG,win_color1 ; R 1419 movff WREG,win_color1 ; R
1377 return 1420 return