1 /* vim:expandtab:ts=2 sw=2:
2 */
3 /* Grafx2 - The Ultimate 256-color bitmap paint program
4
5 Copyright owned by various GrafX2 authors, see COPYRIGHT.txt for details.
6
7 Grafx2 is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; version 2
10 of the License.
11
12 Grafx2 is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Grafx2; if not, see <http://www.gnu.org/licenses/>
19 */
20
21 #include <string.h>
22 #include <stdlib.h>
23 #include "global.h"
24 #include "screen.h"
25 #include "misc.h"
26 #include "graph.h"
27 #include "pxquad.h"
28
29 #define ZOOMX 4
30 #define ZOOMY 4
31
32
Pixel_quad(word x,word y,byte color)33 void Pixel_quad (word x,word y,byte color)
34 /* Affiche un pixel de la color aux coords x;y à l'écran */
35 {
36 Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
37 Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY, color);
38 Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY, color);
39 Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY, color);
40 Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 1, color);
41 Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 1, color);
42 Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 1, color);
43 Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY + 1, color);
44 Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 2, color);
45 Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 2, color);
46 Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 2, color);
47 Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY + 2, color);
48 Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 3, color);
49 Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 3, color);
50 Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 3, color);
51 Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY + 3, color);
52
53 }
54
Read_pixel_quad(word x,word y)55 byte Read_pixel_quad (word x,word y)
56 /* On retourne la couleur du pixel aux coords données */
57 {
58 return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
59 }
60
Block_quad(word start_x,word start_y,word width,word height,byte color)61 void Block_quad (word start_x,word start_y,word width,word height,byte color)
62 /* On affiche un rectangle de la couleur donnée */
63 {
64 Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
65 }
66
Display_part_of_screen_quad(word width,word height,word image_width)67 void Display_part_of_screen_quad (word width,word height,word image_width)
68 /* Afficher une partie de l'image telle quelle sur l'écran */
69 {
70 byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
71 int y;
72 int dy;
73
74 for(y = 0; y < height; y++)
75 // Pour chaque ligne
76 {
77 byte* dest = Get_Screen_pixel_ptr(0, y * ZOOMY);
78 // On fait une copie de la ligne
79 for (dy=width;dy>0;dy--)
80 {
81 *(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
82 src++;
83 dest+=ZOOMX;
84 }
85 // On double la ligne qu'on vient de copier
86 memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 1), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
87 // On la triple
88 memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 2), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
89 // On la quadruple
90 memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 3), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
91
92 // On passe à la ligne suivante
93 src+=image_width-width;
94 }
95 //Update_rect(0,0,width,height);
96 }
97
Pixel_preview_normal_quad(word x,word y,byte color)98 void Pixel_preview_normal_quad (word x,word y,byte color)
99 /* Affichage d'un pixel dans l'écran, par rapport au décalage de l'image
100 * dans l'écran, en mode normal (pas en mode loupe)
101 * Note: si on modifie cette procédure, il faudra penser à faire également
102 * la modif dans la procédure Pixel_Preview_Loupe_SDL. */
103 {
104 // if(x-Main.offset_X >= 0 && y - Main.offset_Y >= 0)
105 Pixel_quad(x-Main.offset_X,y-Main.offset_Y,color);
106 }
107
Pixel_preview_magnifier_quad(word x,word y,byte color)108 void Pixel_preview_magnifier_quad (word x,word y,byte color)
109 {
110 // Affiche le pixel dans la partie non zoomée
111 Pixel_quad(x-Main.offset_X,y-Main.offset_Y,color);
112
113 // Regarde si on doit aussi l'afficher dans la partie zoomée
114 if (y >= Limit_top_zoom && y <= Limit_visible_bottom_zoom
115 && x >= Limit_left_zoom && x <= Limit_visible_right_zoom)
116 {
117 // On est dedans
118 int height;
119 int y_zoom = Main.magnifier_factor * (y-Main.magnifier_offset_Y);
120
121 if (Menu_Y - y_zoom < Main.magnifier_factor)
122 // On ne doit dessiner qu'un morceau du pixel
123 // sinon on dépasse sur le menu
124 height = Menu_Y - y_zoom;
125 else
126 height = Main.magnifier_factor;
127
128 Block_quad(
129 Main.magnifier_factor * (x-Main.magnifier_offset_X) + Main.X_zoom,
130 y_zoom, Main.magnifier_factor, height, color
131 );
132 }
133 }
134
Horizontal_XOR_line_quad(word x_pos,word y_pos,word width)135 void Horizontal_XOR_line_quad(word x_pos,word y_pos,word width)
136 {
137 //On calcule la valeur initiale de dest:
138 //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
139
140 int x;
141
142 for (x=0;x<width*ZOOMX;x+=ZOOMX)
143 {
144 byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY)];
145 Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY, color);
146 Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY, color);
147 Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY, color);
148 Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY, color);
149 Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 1, color);
150 Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 1, color);
151 Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 1, color);
152 Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY + 1, color);
153 Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 2, color);
154 Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 2, color);
155 Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 2, color);
156 Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY + 2, color);
157 Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 3, color);
158 Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 3, color);
159 Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 3, color);
160 Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY + 3, color);
161 }
162 }
163
Vertical_XOR_line_quad(word x_pos,word y_pos,word height)164 void Vertical_XOR_line_quad(word x_pos,word y_pos,word height)
165 {
166 int i;
167 for (i = 0; i < height; i++)
168 {
169 byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY)];
170 Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY, color);
171 Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY, color);
172 Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY, color);
173 Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY, color);
174 Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 1, color);
175 Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 1, color);
176 Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 1, color);
177 Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY + 1, color);
178 Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 2, color);
179 Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 2, color);
180 Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 2, color);
181 Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY + 2, color);
182 Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 3, color);
183 Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 3, color);
184 Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 3, color);
185 Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY + 3, color);
186 }
187 }
188
Display_brush_color_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)189 void Display_brush_color_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
190 {
191 // dest = Position à l'écran
192 // src = Position dans la brosse
193 byte* src = Brush + y_offset * brush_width + x_offset;
194
195 word x,y;
196
197 // Pour chaque ligne
198 for(y = 0; y < height; y++)
199 {
200 byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
201 byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
202 byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
203 byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
204 // Pour chaque pixel
205 for(x = width;x > 0; x--)
206 {
207 // On vérifie que ce n'est pas la transparence
208 if(*src != transp_color)
209 {
210 *(dest3+3) = *(dest3+2) = *(dest3+1) = *(dest3) = *(dest2+3) = *(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
211 }
212
213 // Pixel suivant
214 src++;
215 dest+=ZOOMX;
216 dest1+=ZOOMX;
217 dest2+=ZOOMX;
218 dest3+=ZOOMX;
219 }
220
221 // On passe à la ligne suivante
222 src = src + brush_width - width;
223 }
224 Update_rect(x_pos,y_pos,width,height);
225 }
226
Display_brush_mono_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,byte color,word brush_width)227 void Display_brush_mono_quad(word x_pos, word y_pos,
228 word x_offset, word y_offset, word width, word height,
229 byte transp_color, byte color, word brush_width)
230 /* On affiche la brosse en monochrome */
231 {
232 // dest = adr destination à l'écran
233 byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
234 // la brosse
235 int x,y;
236
237 // Pour chaque ligne
238 for(y = 0; y < height; y++)
239 {
240 byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
241 byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
242 byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
243 byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
244 for(x=width;x!=0;x--)
245 //Pour chaque pixel
246 {
247 if (*src!=transp_color)
248 *(dest3+3) = *(dest3+2) = *(dest3+1) = *(dest3) = *(dest2+3) = *(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = color;
249
250 // On passe au pixel suivant
251 src++;
252 dest+=ZOOMX;
253 dest1+=ZOOMX;
254 dest2+=ZOOMX;
255 dest3+=ZOOMX;
256 }
257
258 // On passe à la ligne suivante
259 src+=brush_width-width;
260 }
261 Update_rect(x_pos,y_pos,width,height);
262 }
263
Clear_brush_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)264 void Clear_brush_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
265 {
266 byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
267 int y;
268 int x;
269 (void)x_offset; // unused
270 (void)y_offset; // unused
271 (void)transp_color; // unused
272
273 // Pour chaque ligne
274 for(y = 0; y < height; y++)
275 {
276 byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
277 byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
278 byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
279 byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
280 for(x=width;x!=0;x--)
281 //Pour chaque pixel
282 {
283 *(dest3+3) = *(dest3+2) = *(dest3+1) = *(dest3) = *(dest2+3) = *(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
284
285 // On passe au pixel suivant
286 src++;
287 dest+=ZOOMX;
288 dest1+=ZOOMX;
289 dest2+=ZOOMX;
290 dest3+=ZOOMX;
291 }
292
293 // On passe à la ligne suivante
294 src+=image_width-width;
295 }
296 Update_rect(x_pos,y_pos,width,height);
297 }
298
299 // Affiche une brosse (arbitraire) à l'écran
Display_brush_quad(byte * brush,word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)300 void Display_brush_quad(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
301 {
302 // dest = Position à l'écran
303 // src = Position dans la brosse
304 byte* src = brush + y_offset * brush_width + x_offset;
305
306 word x,y;
307
308 // Pour chaque ligne
309 for(y = 0; y < height; y++)
310 {
311 byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
312 byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
313 byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
314 byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
315 // Pour chaque pixel
316 for(x = width;x > 0; x--)
317 {
318 // On vérifie que ce n'est pas la transparence
319 if(*src != transp_color)
320 {
321 *(dest3+3) = *(dest3+2) = *(dest3+1) = *(dest3) = *(dest2+3) = *(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
322 }
323
324 // Pixel suivant
325 src++; dest+=ZOOMX;
326 dest1+=ZOOMX;
327 dest2+=ZOOMX;
328 dest3+=ZOOMX;
329 }
330
331 // On passe à la ligne suivante
332 src = src + brush_width - width;
333 }
334 }
335
Remap_screen_quad(word x_pos,word y_pos,word width,word height,byte * conversion_table)336 void Remap_screen_quad(word x_pos,word y_pos,word width,word height,byte * conversion_table)
337 {
338 // dest = coords a l'écran
339 int x,y;
340
341 // Pour chaque ligne
342 for(y = 0; y < height; y++)
343 {
344 byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
345 byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
346 byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
347 byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
348 // Pour chaque pixel
349 for(x=width;x>0;x--)
350 {
351 *(dest3+3) = *(dest3+2) = *(dest3+1) = *(dest3) = *(dest2+3) = *(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest =
352 conversion_table[*dest];
353 dest +=ZOOMX;
354 dest1+=ZOOMX;
355 dest2+=ZOOMX;
356 dest3+=ZOOMX;
357 }
358 }
359
360 Update_rect(x_pos,y_pos,width,height);
361 }
362
Display_line_on_screen_fast_quad(word x_pos,word y_pos,word width,byte * line)363 void Display_line_on_screen_fast_quad(word x_pos,word y_pos,word width,byte * line)
364 /* On affiche toute une ligne de pixels telle quelle. */
365 /* Utilisée si le buffer contient déja des pixel doublés. */
366 {
367 memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY), line, width*ZOOMX);
368 memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+1), line, width*ZOOMX);
369 memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+2), line, width*ZOOMX);
370 memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+3), line, width*ZOOMX);
371 }
372
Display_line_on_screen_quad(word x_pos,word y_pos,word width,byte * line)373 void Display_line_on_screen_quad(word x_pos,word y_pos,word width,byte * line)
374 /* On affiche une ligne de pixels en les doublant. */
375 {
376 int x;
377 byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
378 byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1);
379 byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 2);
380 byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 3);
381 for(x=width;x>0;x--)
382 {
383 *(dest3+3) = *(dest3+2) = *(dest3+1) = *(dest3) = *(dest2+3) = *(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *line;
384 dest+=ZOOMX;
385 dest1+=ZOOMX;
386 dest2+=ZOOMX;
387 dest3+=ZOOMX;
388 line++;
389 }
390 }
Display_transparent_mono_line_on_screen_quad(word x_pos,word y_pos,word width,byte * line,byte transp_color,byte color)391 void Display_transparent_mono_line_on_screen_quad(
392 word x_pos, word y_pos, word width, byte* line,
393 byte transp_color, byte color)
394 // Affiche une ligne à l'écran avec une couleur + transparence.
395 // Utilisé par les brosses en mode zoom
396 {
397 //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
398 byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos);
399 int x;
400 // Pour chaque pixel
401 for(x=0;x<width;x++)
402 {
403 if (transp_color!=*line)
404 {
405 *(dest+3)=*(dest+2)=*(dest+1)=*dest=color;
406 }
407 line ++; // Pixel suivant
408 dest+=ZOOMX;
409 }
410 }
411
Read_line_screen_quad(word x_pos,word y_pos,word width,byte * line)412 void Read_line_screen_quad(word x_pos,word y_pos,word width,byte * line)
413 {
414 memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), width*ZOOMX);
415 }
416
Display_part_of_screen_scaled_quad(word width,word height,word image_width,byte * buffer)417 void Display_part_of_screen_scaled_quad(
418 word width, // width non zoomée
419 word height, // height zoomée
420 word image_width,byte * buffer)
421 {
422 byte* src = Main_screen + Main.magnifier_offset_Y * image_width
423 + Main.magnifier_offset_X;
424 int y = 0; // Ligne en cours de traitement
425
426 // Pour chaque ligne à zoomer
427 while(1)
428 {
429 int x;
430
431 // On éclate la ligne
432 Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width);
433 // On l'affiche Facteur fois, sur des lignes consécutives
434 x = Main.magnifier_factor/**ZOOMY*/;
435 // Pour chaque ligne
436 do{
437 // On affiche la ligne zoomée
438 Display_line_on_screen_fast_quad(
439 Main.X_zoom, y, width*Main.magnifier_factor,
440 buffer
441 );
442 // On passe à la suivante
443 y++;
444 if(y==height/**ZOOMY*/)
445 {
446 Redraw_grid(Main.X_zoom,0,
447 width*Main.magnifier_factor,height);
448 Update_rect(Main.X_zoom,0,
449 width*Main.magnifier_factor,height);
450 return;
451 }
452 x--;
453 }while (x > 0);
454 src += image_width;
455 }
456 // ATTENTION on n'arrive jamais ici !
457 }
458
459 // Affiche une partie de la brosse couleur zoomée
Display_brush_color_zoom_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word brush_width,byte * buffer)460 void Display_brush_color_zoom_quad(word x_pos,word y_pos,
461 word x_offset,word y_offset,
462 word width, // width non zoomée
463 word end_y_pos,byte transp_color,
464 word brush_width, // width réelle de la brosse
465 byte * buffer)
466 {
467 byte* src = Brush+y_offset*brush_width + x_offset;
468 word y = y_pos;
469 byte bx;
470
471 // Pour chaque ligne
472 while(1)
473 {
474 Zoom_a_line(src,buffer,Main.magnifier_factor,width);
475 // On affiche facteur fois la ligne zoomée
476 for(bx=Main.magnifier_factor;bx>0;bx--)
477 {
478 byte* line_src = buffer;
479 //byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
480 byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY);
481 word x;
482 // Pour chaque pixel de la ligne
483 for(x = width*Main.magnifier_factor;x > 0;x--)
484 {
485 if(*line_src!=transp_color)
486 {
487 *(dest+3)=*(dest+2)=*(dest+1)=*dest = *line_src;
488 }
489 line_src++;
490 dest+=ZOOMX;
491 }
492 // Double the line
493 memcpy(Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY + 1), Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY), width*ZOOMX*Main.magnifier_factor);
494 // Triple the line
495 memcpy(Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY + 2), Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY), width*ZOOMX*Main.magnifier_factor);
496 // Quadruple it
497 memcpy(Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY + 3), Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY), width*ZOOMX*Main.magnifier_factor);
498 y++;
499 if(y==end_y_pos)
500 {
501 return;
502 }
503 }
504 src += brush_width;
505 }
506 // ATTENTION zone jamais atteinte
507 }
508
Display_brush_mono_zoom_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,byte color,word brush_width,byte * buffer)509 void Display_brush_mono_zoom_quad(word x_pos, word y_pos,
510 word x_offset, word y_offset,
511 word width, // width non zoomée
512 word end_y_pos,
513 byte transp_color, byte color,
514 word brush_width, // width réelle de la brosse
515 byte * buffer
516 )
517
518 {
519 byte* src = Brush + y_offset * brush_width + x_offset;
520 int y=y_pos*ZOOMY;
521
522 //Pour chaque ligne à zoomer :
523 while(1)
524 {
525 int bx;
526 // src = Ligne originale
527 // On éclate la ligne
528 Zoom_a_line(src,buffer,Main.magnifier_factor,width);
529
530 // On affiche la ligne Facteur fois à l'écran (sur des
531 // lignes consécutives)
532 bx = Main.magnifier_factor*ZOOMY;
533
534 // Pour chaque ligne écran
535 do
536 {
537 // On affiche la ligne zoomée
538 Display_transparent_mono_line_on_screen_quad(
539 x_pos, y, width * Main.magnifier_factor,
540 buffer, transp_color, color
541 );
542 // On passe à la ligne suivante
543 y++;
544 // On vérifie qu'on est pas à la ligne finale
545 if(y == end_y_pos*ZOOMY)
546 {
547 Redraw_grid( x_pos, y_pos,
548 width * Main.magnifier_factor, end_y_pos - y_pos );
549 Update_rect( x_pos, y_pos,
550 width * Main.magnifier_factor, end_y_pos - y_pos );
551 return;
552 }
553 bx --;
554 }
555 while (bx > 0);
556
557 // Passage à la ligne suivante dans la brosse aussi
558 src+=brush_width;
559 }
560 }
561
Clear_brush_scaled_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer)562 void Clear_brush_scaled_quad(word x_pos,word y_pos,word x_offset,word y_offset,word width,word end_y_pos,byte transp_color,word image_width,byte * buffer)
563 {
564
565 // En fait on va recopier l'image non zoomée dans la partie zoomée !
566 byte* src = Main_screen + y_offset * image_width + x_offset;
567 int y = y_pos;
568 int bx;
569 (void)transp_color; // unused
570
571 // Pour chaque ligne à zoomer
572 while(1){
573 Zoom_a_line(src,buffer,Main.magnifier_factor*ZOOMX,width);
574
575 bx=Main.magnifier_factor;
576
577 // Pour chaque ligne
578 do{
579 // TODO a verifier
580 Display_line_on_screen_fast_quad(x_pos,y,
581 width * Main.magnifier_factor,buffer);
582
583 // Ligne suivante
584 y++;
585 if(y==end_y_pos)
586 {
587 Redraw_grid(x_pos,y_pos,
588 width*Main.magnifier_factor,end_y_pos-y_pos);
589 Update_rect(x_pos,y_pos,
590 width*Main.magnifier_factor,end_y_pos-y_pos);
591 return;
592 }
593 bx--;
594 }while(bx!=0);
595
596 src+= image_width;
597 }
598 }
599