annotate src/color_processor.asm @ 596:2b4e02a9c1e4

italian update
author heinrichsweikamp
date Tue, 03 Jul 2018 09:49:34 +0200
parents b455b31ce022
children ca4556fb60b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
3 ; File File color_processor.asm ## V2.98
0
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Decompress and draw an image.
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2010-12-13 : [jDG] Creation.
heinrichsweikamp
parents:
diff changeset
11 ; 2010-12-30 : [jDG] Revised to put temp into ACCESSRAM0
heinrichsweikamp
parents:
diff changeset
12 ;
heinrichsweikamp
parents:
diff changeset
13 ; RATIONALS: The OSTC have a nice color screen, and a std geek attitude impose
heinrichsweikamp
parents:
diff changeset
14 ; to show off ... ;-)
heinrichsweikamp
parents:
diff changeset
15 ;
heinrichsweikamp
parents:
diff changeset
16 ; Inputs: TBLPTR points to the image description block.
heinrichsweikamp
parents:
diff changeset
17 ; win_top, win_leftx2 the Top/Leftx2 corner here to put the image.
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
18 ; Outputs: None.
0
heinrichsweikamp
parents:
diff changeset
19 ; Trashed: TBLPTR, TABLAT, FSR2, PROD, win_width, win_height
heinrichsweikamp
parents:
diff changeset
20 ;
heinrichsweikamp
parents:
diff changeset
21 ; ImageBloc:
heinrichsweikamp
parents:
diff changeset
22 ; db widthx2, height
heinrichsweikamp
parents:
diff changeset
23 ; db nbColors, 0 ; Unused yet... Should be 0 to keep packing happy.
heinrichsweikamp
parents:
diff changeset
24 ; dw color0, color1, color2, color3, ...
heinrichsweikamp
parents:
diff changeset
25 ; db ...packed pixels...
heinrichsweikamp
parents:
diff changeset
26 ;
heinrichsweikamp
parents:
diff changeset
27 ; Limitations:
heinrichsweikamp
parents:
diff changeset
28 ; * nbColors should be <= 15.
heinrichsweikamp
parents:
diff changeset
29 ; * image width should be even.
heinrichsweikamp
parents:
diff changeset
30 ; * image left border should be on even position too.
heinrichsweikamp
parents:
diff changeset
31 ; Compressed format:
heinrichsweikamp
parents:
diff changeset
32 ; - Upper nibble = color, lower nibble = count-1.
heinrichsweikamp
parents:
diff changeset
33 ; - All bytes F* accumulates to make count larger than 16.
heinrichsweikamp
parents:
diff changeset
34 ; Eg. 00 is 1 pixel color 0
heinrichsweikamp
parents:
diff changeset
35 ; 07 is 8 pixels color 0
heinrichsweikamp
parents:
diff changeset
36 ; 70 is 1 pixel color 7
heinrichsweikamp
parents:
diff changeset
37 ; bf is 16 pixels of color .11
heinrichsweikamp
parents:
diff changeset
38 ; F1 F2 F3 04 is 0x1235 pixels of color 0.
heinrichsweikamp
parents:
diff changeset
39 ;
heinrichsweikamp
parents:
diff changeset
40 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
41
275
653a3ab08062 rename into hwOS
heinrichsweikamp
parents: 0
diff changeset
42 #include "hwos.inc"
0
heinrichsweikamp
parents:
diff changeset
43 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
44
heinrichsweikamp
parents:
diff changeset
45 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
46 ;
heinrichsweikamp
parents:
diff changeset
47 ; Note: Some variables (win_width, win_height) are in BANK0 !
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
48 basic CODE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
49 global color_image
0
heinrichsweikamp
parents:
diff changeset
50 color_image:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
51 banksel common ; Bank1, just to be sure...
0
heinrichsweikamp
parents:
diff changeset
52
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
53 ;---- Get image parameters -------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
54 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
55 movff TABLAT,win_width
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
56 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
57 movff TABLAT,win_height
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
58 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
59 movff TABLAT,lo ; image colors
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
60 tblrd*+ ; Skip one byte (future flags ?)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
61 ;---- Copy color table -----------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
62 movf lo,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
63 lfsr FSR2,buffer
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
64 get_colors_loop:
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
65 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
66 movff TABLAT,POSTINC2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
67 tblrd*+
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
68 movff TABLAT,POSTINC2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
69 decfsz WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
70 bra get_colors_loop
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
71
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
72 ; Compute width * height * 2 : the number of pixels to write.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
73 clrf img_pixels+2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
74 movf win_width,W ; Compute number of pixels to draw
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
75 mulwf win_height ; 0 .. 160x240
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
76 bcf STATUS,C ; BEWARE: mulwf does not reset carry flag !
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
77 rlcf PRODL ; x2 --> 0 .. 320x240, might be > 0xFFFF
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
78 rlcf PRODH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
79 movff PRODL, img_pixels+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
80 movff PRODH, img_pixels+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
81 rlcf img_pixels+2 ; Get the upper bit in place
0
heinrichsweikamp
parents:
diff changeset
82
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
83 clrf WREG ; Decrement count to ease end detection
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
84 decf img_pixels+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
85 subwfb img_pixels+1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
86 subwfb img_pixels+2,F
0
heinrichsweikamp
parents:
diff changeset
87
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
88 ;---- Send window command --------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
89 clrf win_width+1 ; x2 on width, for the true box size
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
90 rlcf win_width+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
91 rlcf win_width+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
92 call TFT_box_write
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
93 Index_out 0x22
0
heinrichsweikamp
parents:
diff changeset
94
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
95 ;---- Decode pixels --------------------------------------------------
0
heinrichsweikamp
parents:
diff changeset
96 color_image_loop_xy:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
97 ; Get pixel count
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
98 clrf img_count+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
99 clrf img_count+1
0
heinrichsweikamp
parents:
diff changeset
100
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
101 ;---- Decode repetition count
0
heinrichsweikamp
parents:
diff changeset
102 color_image_decode_1:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
103 tblrd*+ ; Get one byte
0
heinrichsweikamp
parents:
diff changeset
104
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
105 btfss TABLAT,7 ; High bit cleared ?
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
106 bra color_image_decode_2 ; YES: this is a color byte
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
107
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
108 rlcf TABLAT,F ; Drop high bit.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
109 movlw .7 ; Move 7 bits
0
heinrichsweikamp
parents:
diff changeset
110 color_image_decode_3:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
111 rlcf TABLAT,F ; Get bit into carry
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
112 rlcf img_count+0,F ; Push into pixel count
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
113 rlcf img_count+1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
114 decfsz WREG
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
115 bra color_image_decode_3 ; and loop for each 7 bits
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
116 bra color_image_decode_1 ; Decode next byte
0
heinrichsweikamp
parents:
diff changeset
117
heinrichsweikamp
parents:
diff changeset
118 color_image_decode_2:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
119 ;---- Get pixel color into PROD
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
120 movf TABLAT,W ; Get color index
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
121 addwf WREG ; *2
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
122 lfsr FSR2,buffer ; Reinitialize color table
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
123 movff WREG,FSR2L ; LOW(buffer) == 0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
124 movff POSTINC2,PRODL
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
125 movff POSTINC2,PRODH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
126
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
127 ; Subtract count-1 from the number of pixel we should do.
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
128 movf img_count+0,W ; Make a 24bit subtraction
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
129 subwf img_pixels+0,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
130 movf img_count+1,W
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
131 subwfb img_pixels+1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
132 movlw 0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
133 subwfb img_pixels+2,F
0
heinrichsweikamp
parents:
diff changeset
134
heinrichsweikamp
parents:
diff changeset
135 color_image_not_over:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
136 infsnz img_count+0 ; Increment count
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
137 incf img_count+1
0
heinrichsweikamp
parents:
diff changeset
138
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
139 ; Loop sending pixel color
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
140 incf img_count+1 ; Because we decrement first, should add one here !
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
141 bsf tft_rs,0 ; RS_H Data
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
142 movff PRODH,PORTA ; Move high byte to PORTA
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
143 movff PRODL,PORTH ; Move low byte to PORTH
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
144 bcf INTCON,GIE
0
heinrichsweikamp
parents:
diff changeset
145 color_image_loop_pixel:
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
146 bcf tft_nwr,0 ; WR_L
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
147 bsf tft_nwr,0 ; WR_H Tick
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
148 decfsz img_count+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
149 bra color_image_loop_pixel
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
150 decfsz img_count+1
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
151 bra color_image_loop_pixel
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
152 bsf INTCON,GIE
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
153
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
154 ; And count (on a 24bit counter)
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
155 clrf WREG ; Make a 24bit decrement
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
156 decf img_pixels+0
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
157 subwfb img_pixels+1,F
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
158 subwfb img_pixels+2,F
0
heinrichsweikamp
parents:
diff changeset
159
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
160 bnn color_image_loop_xy ; Not finished ? loop...
0
heinrichsweikamp
parents:
diff changeset
161
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
162 ;---- Closeup --------------------------------------------------------
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
163 Index_out 0x00
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
164 return
0
heinrichsweikamp
parents:
diff changeset
165
582
b455b31ce022 work on 2.97 stable
heinrichsweikamp
parents: 436
diff changeset
166 END