Mercurial > public > hwos_code
comparison src/color_processor.asm @ 604:ca4556fb60b9
bump to 2.99beta, work on 3.00 stable
author | heinrichsweikamp |
---|---|
date | Thu, 22 Nov 2018 19:47:26 +0100 |
parents | b455b31ce022 |
children | d866684249bd |
comparison
equal
deleted
inserted
replaced
603:00b24fb4324d | 604:ca4556fb60b9 |
---|---|
1 ;============================================================================= | 1 ;============================================================================= |
2 ; | 2 ; |
3 ; File File color_processor.asm ## V2.98 | 3 ; File File color_processor.asm ## V2.98c |
4 ; | 4 ; |
5 ; Decompress and draw an image. | 5 ; Decompress and draw an image. |
6 ; | 6 ; |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. |
8 ;============================================================================= | 8 ;============================================================================= |
17 ; win_top, win_leftx2 the Top/Leftx2 corner here to put the image. | 17 ; win_top, win_leftx2 the Top/Leftx2 corner here to put the image. |
18 ; Outputs: None. | 18 ; Outputs: None. |
19 ; Trashed: TBLPTR, TABLAT, FSR2, PROD, win_width, win_height | 19 ; Trashed: TBLPTR, TABLAT, FSR2, PROD, win_width, win_height |
20 ; | 20 ; |
21 ; ImageBloc: | 21 ; ImageBloc: |
22 ; db widthx2, height | 22 ; db widthx2, height |
23 ; db nbColors, 0 ; Unused yet... Should be 0 to keep packing happy. | 23 ; db nbColors, 0 ; 0 = unused yet, should remain 0 to keep packing happy |
24 ; dw color0, color1, color2, color3, ... | 24 ; dw color0, color1, color2, color3, ... |
25 ; db ...packed pixels... | 25 ; db packed pixels... |
26 ; | 26 ; |
27 ; Limitations: | 27 ; Limitations: |
28 ; * nbColors should be <= 15. | 28 ; * nbColors <= 127 |
29 ; * image width should be even. | 29 ; * image width should be even |
30 ; * image left border should be on even position too. | 30 ; * image left border should be on even position, too |
31 ; | |
31 ; Compressed format: | 32 ; Compressed format: |
32 ; - Upper nibble = color, lower nibble = count-1. | 33 ; - 1-3 bytes pixel count, followed by 1 byte pixel color |
33 ; - All bytes F* accumulates to make count larger than 16. | 34 ; - bit 7 = 1: byte holds pixel count in bits 6-0 |
34 ; Eg. 00 is 1 pixel color 0 | 35 ; - bit 7 = 0: byte holds pixel color in bits 6-0 |
35 ; 07 is 8 pixels color 0 | 36 ; - all pixel count bytes accumulate: |
36 ; 70 is 1 pixel color 7 | 37 ; - 1 byte pixel count: 1xxxxxxx -> 7 bit pixel count |
37 ; bf is 16 pixels of color .11 | 38 ; - 2 bytes pixel count: 1yyyyyyy 1xxxxxxx -> 14 bit pixel count |
38 ; F1 F2 F3 04 is 0x1235 pixels of color 0. | 39 ; - 3 bytes pixel count: 1zzzzzzz 1yyyyyyy 1xxxxxxx -> 21 bit pixel count |
40 ; | |
41 ; Pixels are written column by column from left to right, with columns down first. | |
39 ; | 42 ; |
40 ;----------------------------------------------------------------------------- | 43 ;----------------------------------------------------------------------------- |
41 | 44 |
42 #include "hwos.inc" | 45 #include "hwos.inc" |
43 #include "tft.inc" | 46 #include "tft.inc" |
47 | |
48 color_proc CODE | |
44 | 49 |
45 ;----------------------------------------------------------------------------- | 50 ;----------------------------------------------------------------------------- |
46 ; | 51 ; Note: some variables (win_width, win_height) are in BANK 0 ! |
47 ; Note: Some variables (win_width, win_height) are in BANK0 ! | 52 |
48 basic CODE | |
49 global color_image | 53 global color_image |
50 color_image: | 54 color_image: |
51 banksel common ; Bank1, just to be sure... | 55 banksel common ; Bank 1, just to be sure... |
52 | 56 |
53 ;---- Get image parameters ------------------------------------------- | 57 ;---- Get image size ----------------------------------------------- |
54 tblrd*+ | 58 tblrd*+ |
55 movff TABLAT,win_width | 59 movff TABLAT,win_width |
56 tblrd*+ | 60 tblrd*+ |
57 movff TABLAT,win_height | 61 movff TABLAT,win_height |
58 tblrd*+ | |
59 movff TABLAT,lo ; image colors | |
60 tblrd*+ ; Skip one byte (future flags ?) | |
61 ;---- Copy color table ----------------------------------------------- | |
62 movf lo,W | |
63 lfsr FSR2,buffer | |
64 get_colors_loop: | |
65 tblrd*+ | |
66 movff TABLAT,POSTINC2 | |
67 tblrd*+ | |
68 movff TABLAT,POSTINC2 | |
69 decfsz WREG | |
70 bra get_colors_loop | |
71 | 62 |
72 ; Compute width * height * 2 : the number of pixels to write. | 63 ; Compute width * height * 2 : the number of pixels to write. |
73 clrf img_pixels+2 | 64 clrf img_pixels+2 |
74 movf win_width,W ; Compute number of pixels to draw | 65 movf win_width,W ; Compute number of pixels to draw |
75 mulwf win_height ; 0 .. 160x240 | 66 mulwf win_height ; 0 .. 160x240 |
76 bcf STATUS,C ; BEWARE: mulwf does not reset carry flag ! | 67 bcf STATUS,C ; BEWARE: mulwf does not reset carry flag! |
77 rlcf PRODL ; x2 --> 0 .. 320x240, might be > 0xFFFF | 68 rlcf PRODL ; x2 --> 0 .. 320x240, might be > 0xFFFF |
78 rlcf PRODH | 69 rlcf PRODH |
79 movff PRODL, img_pixels+0 | 70 movff PRODL, img_pixels+0 |
80 movff PRODH, img_pixels+1 | 71 movff PRODH, img_pixels+1 |
81 rlcf img_pixels+2 ; Get the upper bit in place | 72 rlcf img_pixels+2 ; Get the upper bit in place |
89 clrf win_width+1 ; x2 on width, for the true box size | 80 clrf win_width+1 ; x2 on width, for the true box size |
90 rlcf win_width+0 | 81 rlcf win_width+0 |
91 rlcf win_width+1 | 82 rlcf win_width+1 |
92 call TFT_box_write | 83 call TFT_box_write |
93 Index_out 0x22 | 84 Index_out 0x22 |
85 | |
86 ;---- Read the colors ------------------------------------------------ | |
87 rcall get_colors | |
94 | 88 |
95 ;---- Decode pixels -------------------------------------------------- | 89 ;---- Decode pixels -------------------------------------------------- |
96 color_image_loop_xy: | 90 color_image_loop_xy: |
97 ; Get pixel count | 91 ; Get pixel count |
98 clrf img_count+0 | 92 clrf img_count+0 |
130 movf img_count+1,W | 124 movf img_count+1,W |
131 subwfb img_pixels+1,F | 125 subwfb img_pixels+1,F |
132 movlw 0 | 126 movlw 0 |
133 subwfb img_pixels+2,F | 127 subwfb img_pixels+2,F |
134 | 128 |
135 color_image_not_over: | |
136 infsnz img_count+0 ; Increment count | 129 infsnz img_count+0 ; Increment count |
137 incf img_count+1 | 130 incf img_count+1 |
138 | 131 |
139 ; Loop sending pixel color | 132 ; Loop sending pixel color |
140 incf img_count+1 ; Because we decrement first, should add one here ! | 133 incf img_count+1 ; Because we decrement first, should add one here ! |
148 decfsz img_count+0 | 141 decfsz img_count+0 |
149 bra color_image_loop_pixel | 142 bra color_image_loop_pixel |
150 decfsz img_count+1 | 143 decfsz img_count+1 |
151 bra color_image_loop_pixel | 144 bra color_image_loop_pixel |
152 bsf INTCON,GIE | 145 bsf INTCON,GIE |
153 | 146 |
154 ; And count (on a 24bit counter) | 147 ; And count (on a 24bit counter) |
155 clrf WREG ; Make a 24bit decrement | 148 clrf WREG ; Make a 24bit decrement |
156 decf img_pixels+0 | 149 decf img_pixels+0 |
157 subwfb img_pixels+1,F | 150 subwfb img_pixels+1,F |
158 subwfb img_pixels+2,F | 151 subwfb img_pixels+2,F |
161 | 154 |
162 ;---- Closeup -------------------------------------------------------- | 155 ;---- Closeup -------------------------------------------------------- |
163 Index_out 0x00 | 156 Index_out 0x00 |
164 return | 157 return |
165 | 158 |
159 | |
160 global get_colors | |
161 get_colors: | |
162 tblrd*+ ; read number of image colors | |
163 movff TABLAT,lo ; store in lo | |
164 tblrd*+ ; skip one spare byte (future flags ?) | |
165 movf lo,W | |
166 lfsr FSR2,buffer ; set up buffer as storage for the colors | |
167 get_colors_loop: | |
168 tblrd*+ | |
169 btfss use_custom_colors ; shall custom colors be used? | |
170 movff TABLAT,POSTINC2 ; NO | |
171 tblrd*+ | |
172 btfss use_custom_colors ; shall custom colors be used? | |
173 movff TABLAT,POSTINC2 ; NO | |
174 decfsz WREG | |
175 bra get_colors_loop | |
176 | |
177 bcf use_custom_colors ; clear custom colors request | |
178 return | |
179 | |
166 END | 180 END |