annotate src/color_processor.asm @ 518:72f6cb65ca4a

BUGFIX: Do not check ppO2 for disabled gases
author heinrichsweikamp
date Thu, 03 Aug 2017 17:17:25 +0200
parents 95ee78f4a974
children b455b31ce022
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File File color_processor.asm
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.
heinrichsweikamp
parents:
diff changeset
18 ; Ouputs: None.
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 ; Temporary overlay (in bank 1).
heinrichsweikamp
parents:
diff changeset
47
heinrichsweikamp
parents:
diff changeset
48 CBLOCK tmp ; Data overlay in reserved tmp area.
heinrichsweikamp
parents:
diff changeset
49 img_colors:1
heinrichsweikamp
parents:
diff changeset
50 img_pixels:3
heinrichsweikamp
parents:
diff changeset
51 img_count:2
heinrichsweikamp
parents:
diff changeset
52 ; Reserved to tmp+0x07...
heinrichsweikamp
parents:
diff changeset
53 ENDC
heinrichsweikamp
parents:
diff changeset
54
heinrichsweikamp
parents:
diff changeset
55 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
56 ;
heinrichsweikamp
parents:
diff changeset
57 ; Note: Some variables (win_width, win_height) are in BANK0 !
heinrichsweikamp
parents:
diff changeset
58 basic CODE
heinrichsweikamp
parents:
diff changeset
59 global color_image
heinrichsweikamp
parents:
diff changeset
60 color_image:
heinrichsweikamp
parents:
diff changeset
61 banksel win_width ; Bank1, just to be sure...
heinrichsweikamp
parents:
diff changeset
62
heinrichsweikamp
parents:
diff changeset
63 ;---- Get image parameters -------------------------------------------
heinrichsweikamp
parents:
diff changeset
64 tblrd*+
heinrichsweikamp
parents:
diff changeset
65 movff TABLAT,win_width
heinrichsweikamp
parents:
diff changeset
66 tblrd*+
heinrichsweikamp
parents:
diff changeset
67 movff TABLAT,win_height
heinrichsweikamp
parents:
diff changeset
68 tblrd*+
heinrichsweikamp
parents:
diff changeset
69 movff TABLAT,img_colors
heinrichsweikamp
parents:
diff changeset
70 tblrd*+ ; Skip one byte (future flags ?)
heinrichsweikamp
parents:
diff changeset
71 ;---- Copy color table -----------------------------------------------
heinrichsweikamp
parents:
diff changeset
72 movf img_colors,W
heinrichsweikamp
parents:
diff changeset
73 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
74 get_colors_loop:
heinrichsweikamp
parents:
diff changeset
75 tblrd*+
heinrichsweikamp
parents:
diff changeset
76 movff TABLAT,POSTINC2
heinrichsweikamp
parents:
diff changeset
77 tblrd*+
heinrichsweikamp
parents:
diff changeset
78 movff TABLAT,POSTINC2
heinrichsweikamp
parents:
diff changeset
79 decfsz WREG
heinrichsweikamp
parents:
diff changeset
80 bra get_colors_loop
heinrichsweikamp
parents:
diff changeset
81
heinrichsweikamp
parents:
diff changeset
82 ; Compute width * height * 2 : the number of pixels to write.
heinrichsweikamp
parents:
diff changeset
83 clrf img_pixels+2
heinrichsweikamp
parents:
diff changeset
84 movf win_width,W ; Compute number of pixels to draw
heinrichsweikamp
parents:
diff changeset
85 mulwf win_height ; 0 .. 160x240
heinrichsweikamp
parents:
diff changeset
86 bcf STATUS,C ; BEWARE: mulwf does not reset carry flag !
heinrichsweikamp
parents:
diff changeset
87 rlcf PRODL ; x2 --> 0 .. 320x240, might be > 0xFFFF
heinrichsweikamp
parents:
diff changeset
88 rlcf PRODH
heinrichsweikamp
parents:
diff changeset
89 movff PRODL, img_pixels+0
heinrichsweikamp
parents:
diff changeset
90 movff PRODH, img_pixels+1
heinrichsweikamp
parents:
diff changeset
91 rlcf img_pixels+2 ; Get the upper bit in place.
heinrichsweikamp
parents:
diff changeset
92
heinrichsweikamp
parents:
diff changeset
93 clrf WREG ; Decrement count to ease end detection.
heinrichsweikamp
parents:
diff changeset
94 decf img_pixels+0,F
heinrichsweikamp
parents:
diff changeset
95 subwfb img_pixels+1,F
heinrichsweikamp
parents:
diff changeset
96 subwfb img_pixels+2,F
heinrichsweikamp
parents:
diff changeset
97
heinrichsweikamp
parents:
diff changeset
98 ;---- Send window command --------------------------------------------
heinrichsweikamp
parents:
diff changeset
99 clrf win_width+1 ; x2 on width, for the true box size.
heinrichsweikamp
parents:
diff changeset
100 rlcf win_width+0
heinrichsweikamp
parents:
diff changeset
101 rlcf win_width+1
heinrichsweikamp
parents:
diff changeset
102 call TFT_box_write
heinrichsweikamp
parents:
diff changeset
103 Index_out 0x22
heinrichsweikamp
parents:
diff changeset
104
heinrichsweikamp
parents:
diff changeset
105 ;---- Decode pixels --------------------------------------------------
heinrichsweikamp
parents:
diff changeset
106 color_image_loop_xy:
heinrichsweikamp
parents:
diff changeset
107 ; Get pixel count
heinrichsweikamp
parents:
diff changeset
108 clrf img_count+0
heinrichsweikamp
parents:
diff changeset
109 clrf img_count+1
heinrichsweikamp
parents:
diff changeset
110
heinrichsweikamp
parents:
diff changeset
111 ;---- Decode repetition count
heinrichsweikamp
parents:
diff changeset
112 color_image_decode_1:
heinrichsweikamp
parents:
diff changeset
113 tblrd*+ ; Get one byte
heinrichsweikamp
parents:
diff changeset
114
heinrichsweikamp
parents:
diff changeset
115 btfss TABLAT,7 ; High bit cleared ?
heinrichsweikamp
parents:
diff changeset
116 bra color_image_decode_2 ; YES: this is a color byte.
heinrichsweikamp
parents:
diff changeset
117
heinrichsweikamp
parents:
diff changeset
118 rlcf TABLAT,F ; Drop high bit.
heinrichsweikamp
parents:
diff changeset
119 movlw .7 ; Move 7 bits
heinrichsweikamp
parents:
diff changeset
120 color_image_decode_3:
heinrichsweikamp
parents:
diff changeset
121 rlcf TABLAT,F ; Get bit into carry
heinrichsweikamp
parents:
diff changeset
122 rlcf img_count+0,F ; Push into pixel count
heinrichsweikamp
parents:
diff changeset
123 rlcf img_count+1,F
heinrichsweikamp
parents:
diff changeset
124 decfsz WREG
heinrichsweikamp
parents:
diff changeset
125 bra color_image_decode_3 ; and loop foreach 7 bits.
heinrichsweikamp
parents:
diff changeset
126
heinrichsweikamp
parents:
diff changeset
127 bra color_image_decode_1 ; Decode next byte.
heinrichsweikamp
parents:
diff changeset
128
heinrichsweikamp
parents:
diff changeset
129 color_image_decode_2:
heinrichsweikamp
parents:
diff changeset
130 ;---- Get pixel color into PROD
heinrichsweikamp
parents:
diff changeset
131 movf TABLAT,W ; Get color index.
heinrichsweikamp
parents:
diff changeset
132 addwf WREG ; *2
heinrichsweikamp
parents:
diff changeset
133 lfsr FSR2,buffer ; Reinitialize color table.
heinrichsweikamp
parents:
diff changeset
134 movff WREG,FSR2L ; LOW(buffer) == 0
heinrichsweikamp
parents:
diff changeset
135 movff POSTINC2,PRODL
heinrichsweikamp
parents:
diff changeset
136 movff POSTINC2,PRODH
heinrichsweikamp
parents:
diff changeset
137
heinrichsweikamp
parents:
diff changeset
138 ; Substract count-1 from the number of pixel we should do.
heinrichsweikamp
parents:
diff changeset
139 movf img_count+0,W ; Make a 24bit substraction.
heinrichsweikamp
parents:
diff changeset
140 subwf img_pixels+0,F
heinrichsweikamp
parents:
diff changeset
141 movf img_count+1,W
heinrichsweikamp
parents:
diff changeset
142 subwfb img_pixels+1,F
heinrichsweikamp
parents:
diff changeset
143 movlw 0
heinrichsweikamp
parents:
diff changeset
144 subwfb img_pixels+2,F
heinrichsweikamp
parents:
diff changeset
145
heinrichsweikamp
parents:
diff changeset
146 color_image_not_over:
heinrichsweikamp
parents:
diff changeset
147 infsnz img_count+0 ; Increment count.
heinrichsweikamp
parents:
diff changeset
148 incf img_count+1
heinrichsweikamp
parents:
diff changeset
149
heinrichsweikamp
parents:
diff changeset
150 ; Loop sending pixel color
heinrichsweikamp
parents:
diff changeset
151 incf img_count+1 ; Because we decrement first, should add one here !
heinrichsweikamp
parents:
diff changeset
152 bsf tft_rs,0 ; RS_H ; Data
heinrichsweikamp
parents:
diff changeset
153 movff PRODH,PORTA ; Move high byte to PORTA
heinrichsweikamp
parents:
diff changeset
154 movff PRODL,PORTH ; Move low byte to PORTH
436
95ee78f4a974 no screen reboot after logbook exit
heinrichsweikamp
parents: 275
diff changeset
155 bcf INTCON,GIE
0
heinrichsweikamp
parents:
diff changeset
156 color_image_loop_pixel:
heinrichsweikamp
parents:
diff changeset
157 bcf tft_nwr,0 ; WR_L
heinrichsweikamp
parents:
diff changeset
158 bsf tft_nwr,0 ; WR_H ; Tick
heinrichsweikamp
parents:
diff changeset
159 decfsz img_count+0
heinrichsweikamp
parents:
diff changeset
160 bra color_image_loop_pixel
heinrichsweikamp
parents:
diff changeset
161 decfsz img_count+1
heinrichsweikamp
parents:
diff changeset
162 bra color_image_loop_pixel
436
95ee78f4a974 no screen reboot after logbook exit
heinrichsweikamp
parents: 275
diff changeset
163 bsf INTCON,GIE
0
heinrichsweikamp
parents:
diff changeset
164
heinrichsweikamp
parents:
diff changeset
165 ; And count (on a 24bit counter)
heinrichsweikamp
parents:
diff changeset
166 clrf WREG ; Make a 24bit decrement.
heinrichsweikamp
parents:
diff changeset
167 decf img_pixels+0
heinrichsweikamp
parents:
diff changeset
168 subwfb img_pixels+1,F
heinrichsweikamp
parents:
diff changeset
169 subwfb img_pixels+2,F
heinrichsweikamp
parents:
diff changeset
170
heinrichsweikamp
parents:
diff changeset
171 bnn color_image_loop_xy ; Not finished ? loop...
heinrichsweikamp
parents:
diff changeset
172
heinrichsweikamp
parents:
diff changeset
173 ;---- Closeup --------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
174 Index_out 0x00
heinrichsweikamp
parents:
diff changeset
175 return
heinrichsweikamp
parents:
diff changeset
176
heinrichsweikamp
parents:
diff changeset
177 end