Mercurial > public > mk2
changeset 773:9e82de8dc12d
update color processor to latest format
author | heinrichsweikamp |
---|---|
date | Sat, 08 Mar 2014 14:06:09 +0100 |
parents | 5d6da9ddde27 |
children | fac7710ab84e |
files | code_part1/OSTC_code_asm_part1/color_processor.asm |
diffstat | 1 files changed, 37 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/color_processor.asm Sun Mar 02 20:11:10 2014 +0100 +++ b/code_part1/OSTC_code_asm_part1/color_processor.asm Sat Mar 08 14:06:09 2014 +0100 @@ -67,7 +67,7 @@ movlb HIGH(win_height) ; Switch to bank 0. ;---- Get image parameters ------------------------------------------- - tblrd*+ + tblrd*+ movff TABLAT,img_width tblrd*+ movff TABLAT,win_height @@ -77,7 +77,7 @@ ;---- Copy color table ----------------------------------------------- movf img_colors,W lfsr FSR2,colorTable -get_colors_loop: +get_colors_loop: tblrd*+ movff TABLAT,POSTINC2 tblrd*+ @@ -96,6 +96,11 @@ movff PRODH, img_pixelsH rlcf img_pixelsU ; Get the upper bit in place. + clrf WREG ; Decrement count to ease end detection. + decf img_pixelsL,F + subwfb img_pixelsH,F + subwfb img_pixelsU,F + ;---- Send window command -------------------------------------------- clrf img_width+1 ; x2 on width, for the true box size. rlcf img_width+0 @@ -109,69 +114,61 @@ clrf img_countL clrf img_countH -color_image_loop_count: + ;---- Decode repetition count +color_image_decode_1: tblrd*+ ; Get one byte - movlw 0x0F ; Get count bits - andwf TABLAT,W - swapf WREG ; On top-4 bits of W - rlcf WREG ; Push topmost bit into img_count:2 - rlcf img_countL - rlcf img_countH - rlcf WREG ; Push topmost bit into img_count:2 - rlcf img_countL - rlcf img_countH - rlcf WREG ; Push topmost bit into img_count:2 - rlcf img_countL - rlcf img_countH - rlcf WREG ; Push topmost bit into img_count:2 - rlcf img_countL - rlcf img_countH + btfss TABLAT,7 ; High bit cleared ? + bra color_image_decode_2 ; YES: this is a color byte. - movf TABLAT,W ; Does the color-bits mark a big-count ? - andlw 0xF0 - xorlw 0xF0 - bz color_image_loop_count ; YES: loop for more count bits. + rlcf TABLAT,F ; Drop high bit. + movlw .7 ; Move 7 bits +color_image_decode_3: + rlcf TABLAT,F ; Get bit into carry + rlcf img_countL,F ; Push into pixel count + rlcf img_countH,F + decfsz WREG + bra color_image_decode_3 ; and loop foreach 7 bits. - ; Get pixel color into PROD - xorlw 0xF0 ; Get back index. - swapf WREG ; Get color index to lower bits. - addwf WREG ; x2 - addlw LOW(colorTable) ; 0x60 + 2 * .15 < 0x80. - movff WREG,FSR2L + bra color_image_decode_1 ; Decode next byte. + +color_image_decode_2: + ;---- Get pixel color into PROD + movf TABLAT,W ; Get color index. + addwf WREG ; *2 + lfsr FSR2,colorTable ; Reinitialize color table. + movff WREG,FSR2L ; LOW(buffer) == 0 movff POSTINC2,PRODL movff POSTINC2,PRODH - + ; Substract count-1 from the number of pixel we should do. - movf img_countL,W ; Make a 24bit substraction. + movf img_countL,W ; Make a 24bit substraction. subwf img_pixelsL,F movf img_countH,W subwfb img_pixelsH,F movlw 0 subwfb img_pixelsU,F - incf img_countL ; Get back the true count. - addwfc img_countH +color_image_not_over: + infsnz img_countL ; Increment count. + incf img_countH ; Loop sending pixel color - incf img_countH ; Because we decrement first, should add one here ! + incf img_countH ; Because we decrement first, should add one here ! color_image_loop_pixel: AA_DATA_WRITE_PROD decfsz img_countL bra color_image_loop_pixel decfsz img_countH bra color_image_loop_pixel - - ; And count (on a 17bit counter) + + ; And count (on a 24bit counter) clrf WREG ; Make a 24bit decrement. decf img_pixelsL subwfb img_pixelsH,F subwfb img_pixelsU,F - - movf img_pixelsL,W ; Test if img_pixels == 0 - iorwf img_pixelsH,W - iorwf img_pixelsU,W - bnz color_image_loop_xy ; NO: loop... + + bnn color_image_loop_xy ; Not finished ? loop... ;---- Closeup -------------------------------------------------------- AA_CMD_WRITE 0x00