isolate dependencies to SDL

Do not access directly the SDL_Surface Screen_pixels
use new functions Get_Screen_pixel_ptr() Set_Screen_pixel(),
Get_Screen_pixel()
And SetPalette()

Signed-off-by: Thomas Bernard <miniupnp@free.fr>
This commit is contained in:
Thomas Bernard 2018-05-26 23:49:19 +02:00
parent c6975afe94
commit 72fea0290f
21 changed files with 1006 additions and 440 deletions

View File

@ -49,7 +49,6 @@
#endif #endif
#include <ctype.h> #include <ctype.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <SDL.h>
#include "const.h" #include "const.h"
#include "struct.h" #include "struct.h"

View File

@ -25,7 +25,6 @@
/// Handles all the effects buttons and setup windows in the effects menu. /// Handles all the effects buttons and setup windows in the effects menu.
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
#include <SDL.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>

View File

@ -30,7 +30,6 @@
#ifndef _GLOBAL_H_ #ifndef _GLOBAL_H_
#define _GLOBAL_H_ #define _GLOBAL_H_
#include <SDL.h>
#include "struct.h" #include "struct.h"
// MAIN declares the variables, // MAIN declares the variables,
@ -775,10 +774,8 @@ GFX2_GLOBAL iconv_t cd_utf16_inv; // UTF16 => FROMCODE
// -- Specific to SDL // -- Specific to SDL
/// Pointer to the program's screen.
GFX2_GLOBAL SDL_Surface * Screen_SDL;
/// Pointer to the current joystick controller. /// Pointer to the current joystick controller.
GFX2_GLOBAL SDL_Joystick* Joystick; //GFX2_GLOBAL SDL_Joystick* Joystick;
/// Indicates "no keyboard shortcut". /// Indicates "no keyboard shortcut".
#define KEY_NONE 0 #define KEY_NONE 0

View File

@ -3169,7 +3169,8 @@ void Horizontal_grid_line(word x_pos,word y_pos,word width)
int x; int x;
for (x=!(x_pos&1);x<width;x+=2) for (x=!(x_pos&1);x<width;x+=2)
Pixel(x_pos+x, y_pos, xor_lut[*((y_pos-1)*Pixel_height*VIDEO_LINE_WIDTH+x_pos*Pixel_width+Screen_pixels+x*Pixel_width)]); Pixel(x_pos+x, y_pos, xor_lut[Get_Screen_pixel((x_pos+x)*Pixel_width, (y_pos-1)*Pixel_height)]);
//Pixel(x_pos+x, y_pos, xor_lut[*((y_pos-1)*Pixel_height*VIDEO_LINE_WIDTH+x_pos*Pixel_width+Screen_pixels+x*Pixel_width)]);
} }
void Vertical_grid_line(word x_pos,word y_pos,word height) void Vertical_grid_line(word x_pos,word y_pos,word height)
@ -3177,7 +3178,8 @@ void Vertical_grid_line(word x_pos,word y_pos,word height)
int y; int y;
for (y=!(y_pos&1);y<height;y+=2) for (y=!(y_pos&1);y<height;y+=2)
Pixel(x_pos, y_pos+y, xor_lut[*(Screen_pixels+(x_pos*Pixel_width-1)+(y_pos*Pixel_height+y*Pixel_height)*VIDEO_LINE_WIDTH)]); Pixel(x_pos, y_pos+y, xor_lut[Get_Screen_pixel(x_pos*Pixel_width-1, (y_pos+y)*Pixel_height)]);
//Pixel(x_pos, y_pos+y, xor_lut[*(Screen_pixels+(x_pos*Pixel_width-1)+(y_pos*Pixel_height+y*Pixel_height)*VIDEO_LINE_WIDTH)]);
} }
// Tile Grid // Tile Grid

View File

@ -1071,7 +1071,6 @@ static int Color_cycling(void)
{ {
static byte offset[16]; static byte offset[16];
int i, color; int i, color;
static SDL_Color PaletteSDL[256];
int changed; // boolean : true if the palette needs a change in this tick. int changed; // boolean : true if the palette needs a change in this tick.
const T_Gradient_range * range; const T_Gradient_range * range;
int len; int len;
@ -1112,13 +1111,9 @@ static int Color_cycling(void)
} }
if (changed) if (changed)
{ {
T_Palette palette;
// Initialize the palette // Initialize the palette
for(color=0;color<256;color++) memcpy(palette, Main.palette, sizeof(T_Palette));
{
PaletteSDL[color].r=Main.palette[color].R;
PaletteSDL[color].g=Main.palette[color].G;
PaletteSDL[color].b=Main.palette[color].B;
}
for (i=0; i<16; i++) for (i=0; i<16; i++)
{ {
range = &Main.backups->Pages->Gradients->Range[i]; range = &Main.backups->Pages->Gradients->Range[i];
@ -1128,13 +1123,11 @@ static int Color_cycling(void)
for(color=range->Start;color<=range->End;color++) for(color=range->Start;color<=range->End;color++)
{ {
int new_color = range->Start+((color-range->Start+offset[i])%len); int new_color = range->Start+((color-range->Start+offset[i])%len);
PaletteSDL[color].r=Main.palette[new_color].R; palette[color] = Main.palette[new_color];
PaletteSDL[color].g=Main.palette[new_color].G;
PaletteSDL[color].b=Main.palette[new_color].B;
} }
} }
} }
SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256); SetPalette(palette, 0, 256);
} }
return 0; return 0;
} }

View File

@ -25,7 +25,7 @@
// Fonctions de lecture/ecriture file, gèrent les systèmes big-endian et // Fonctions de lecture/ecriture file, gèrent les systèmes big-endian et
// little-endian. // little-endian.
#include <SDL_endian.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
@ -53,6 +53,7 @@
#else #else
#include <dirent.h> #include <dirent.h>
#endif #endif
#include <SDL_endian.h>
#include "struct.h" #include "struct.h"
#include "io.h" #include "io.h"

View File

@ -22,6 +22,7 @@
*/ */
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "keyboard.h" #include "keyboard.h"

View File

@ -631,7 +631,7 @@ int Init_program(int argc,char * argv[])
return(0); return(0);
} }
Joystick = SDL_JoystickOpen(0); //Joystick = SDL_JoystickOpen(0);
SDL_EnableKeyRepeat(250, 32); SDL_EnableKeyRepeat(250, 32);
SDL_EnableUNICODE(SDL_ENABLE); SDL_EnableUNICODE(SDL_ENABLE);
SDL_WM_SetCaption("GrafX2","GrafX2"); SDL_WM_SetCaption("GrafX2","GrafX2");

View File

@ -24,7 +24,6 @@
#if defined(WIN32) #if defined(WIN32)
#define _WIN32_WINNT 0x0500 #define _WIN32_WINNT 0x0500
#endif #endif
#include <SDL.h>
#include <string.h> #include <string.h>
#ifndef _MSC_VER #ifndef _MSC_VER
#include <strings.h> #include <strings.h>
@ -108,8 +107,9 @@ word Count_used_colors_screen_area(dword* usage, word start_x, word start_y,
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
{ {
// Get color in screen memory // Get color in screen memory
color=*(Screen_pixels+((start_x + x)+(start_y + y) * Screen_width //color=*(Screen_pixels+((start_x + x)+(start_y + y) * Screen_width
* Pixel_height) * Pixel_width); // * Pixel_height) * Pixel_width);
color = Get_Screen_pixel(start_x + x, start_y + y);
usage[color]++; //Un point de plus pour cette couleur usage[color]++; //Un point de plus pour cette couleur
} }
} }
@ -172,27 +172,24 @@ const T_Components * Get_current_palette(void)
void Set_palette(T_Palette palette) void Set_palette(T_Palette palette)
{ {
register int i; int i;
SDL_Color PaletteSDL[256];
memcpy(Current_palette, palette, sizeof(T_Palette)); memcpy(Current_palette, palette, sizeof(T_Palette));
for(i=0;i<256;i++) for(i=0;i<256;i++)
{ {
PaletteSDL[i].r=(palette[i].R=Round_palette_component(palette[i].R)); palette[i].R = Round_palette_component(palette[i].R);
PaletteSDL[i].g=(palette[i].G=Round_palette_component(palette[i].G)); palette[i].G = Round_palette_component(palette[i].G);
PaletteSDL[i].b=(palette[i].B=Round_palette_component(palette[i].B)); palette[i].B = Round_palette_component(palette[i].B);
} }
SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL,0,256); SetPalette(palette,0,256);
} }
void Set_color(byte color, byte red, byte green, byte blue) void Set_color(byte color, byte red, byte green, byte blue)
{ {
SDL_Color comp; Current_palette[color].R = red;
Current_palette[color].G = green;
Current_palette[color].R = comp.r = red; Current_palette[color].B = blue;
Current_palette[color].G = comp.g = green; SetPalette(Current_palette + color, color, 1);
Current_palette[color].B = comp.b = blue;
SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, &comp, color, 1);
} }
void Wait_end_of_click(void) void Wait_end_of_click(void)

View File

@ -20,7 +20,6 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Grafx2; if not, see <http://www.gnu.org/licenses/> along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/ */
#include <SDL.h>
#include <string.h> #include <string.h>
#ifndef _MSC_VER #ifndef _MSC_VER
#include <strings.h> #include <strings.h>

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -38,40 +37,49 @@
void Pixel_double (word x,word y,byte color) void Pixel_double (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color; //*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color; //*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH)=color; //*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH + 1)=color; //*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1)* VIDEO_LINE_WIDTH + 1)=color;
Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 1, color);
} }
byte Read_pixel_double (word x,word y) byte Read_pixel_double (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX); //return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
} }
void Block_double (word start_x,word start_y,word width,word height,byte color) void Block_double (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x*ZOOMX; rectangle.x=start_x*ZOOMX;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width*ZOOMX; rectangle.w=width*ZOOMX;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
} }
void Display_part_of_screen_double (word width,word height,word image_width) void Display_part_of_screen_double (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
for(y=height;y!=0;y--) for(y = 0; y < height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte *dest = Get_Screen_pixel_ptr(0, y * ZOOMY);
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
@ -80,11 +88,11 @@ void Display_part_of_screen_double (word width,word height,word image_width)
dest+=ZOOMX; dest+=ZOOMX;
} }
// On double la ligne qu'on vient de copier // On double la ligne qu'on vient de copier
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 1), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -129,53 +137,68 @@ void Pixel_preview_magnifier_double (word x,word y,byte color)
void Horizontal_XOR_line_double(word x_pos,word y_pos,word width) void Horizontal_XOR_line_double(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
int x; int x;
byte color;
for (x=0;x<width*ZOOMX;x+=ZOOMX) for (x=0;x<width*ZOOMX;x+=ZOOMX) {
*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)]; //*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)];
color = xor_lut[Get_Screen_pixel(x_pos*ZOOMX + x, y_pos * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 1, color);
}
} }
void Vertical_XOR_line_double(word x_pos,word y_pos,word height) void Vertical_XOR_line_double(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; byte color;
for (i=height;i>0;i--) //byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
for (i = 0; i < height; i++)
{ {
*dest=*(dest+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=xor_lut[*dest]; color = xor_lut[Get_Screen_pixel(x_pos*ZOOMX, (y_pos + i) * ZOOMY)];
dest+=VIDEO_LINE_WIDTH*ZOOMY; Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 1, color);
//*dest=*(dest+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=xor_lut[*dest];
//dest+=VIDEO_LINE_WIDTH*ZOOMY;
} }
} }
void Display_brush_color_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+1) = *dest = *src; //*(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+1) = *dest = *src;
*(dest2+1) = *(dest2) = *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest2+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -186,36 +209,38 @@ void Display_brush_mono_double(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à // dest = adr destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) // Pour chaque ligne
//Pour chaque ligne for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=color; *(dest2+1)=*(dest2)=*(dest+1)=*dest=color;
//*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=color;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest2+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) void Clear_brush_double(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -223,22 +248,25 @@ void Clear_brush_double(word x_pos,word y_pos,word x_offset,word y_offset,word w
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src; //*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src;
*(dest2+1)=*(dest2)=*(dest+1)=*dest=*src;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest2+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -247,30 +275,32 @@ void Clear_brush_double(word x_pos,word y_pos,word x_offset,word y_offset,word w
void Display_brush_double(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_double(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src; //*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*src;
*(dest2+1)=*(dest2)=*(dest+1)=*dest=*src;
} }
// Pixel suivant // Pixel suivant
src++; dest+=ZOOMX; src++; dest+=ZOOMX;
dest2+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -278,21 +308,24 @@ void Display_brush_double(byte * brush, word x_pos,word y_pos,word x_offset,word
void Remap_screen_double(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_double(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest= //*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=
*(dest2+1)=*(dest2)=*(dest+1)=*dest=
conversion_table[*dest]; conversion_table[*dest];
dest +=ZOOMX; dest +=ZOOMX;
dest2+=ZOOMX;
} }
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -302,20 +335,26 @@ void Display_line_on_screen_fast_double(word x_pos,word y_pos,word width,byte *
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX); memcpy(Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), line, width*ZOOMX);
//memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1), line, width*ZOOMX);
} }
void Display_line_on_screen_double(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_double(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *dest; //byte *dest;
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
for(x=width;x>0;x--) for(x=0; x<width; x++)
{ {
*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*line; //*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*dest=*line;
dest+=ZOOMX; //dest+=ZOOMX;
Set_Screen_pixel((x_pos + x) * ZOOMX, y_pos * ZOOMY, *line);
Set_Screen_pixel((x_pos + x) * ZOOMX + 1, y_pos * ZOOMY, *line);
Set_Screen_pixel((x_pos + x) * ZOOMX, y_pos * ZOOMY + 1, *line);
Set_Screen_pixel((x_pos + x) * ZOOMX + 1, y_pos * ZOOMY + 1, *line);
line++; line++;
} }
} }
@ -325,7 +364,8 @@ void Display_transparent_mono_line_on_screen_double(
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos);
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
@ -341,7 +381,8 @@ void Display_transparent_mono_line_on_screen_double(
void Read_line_screen_double(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_double(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX); //memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), width*ZOOMX);
} }
void Display_part_of_screen_scaled_double( void Display_part_of_screen_scaled_double(
@ -406,7 +447,8 @@ void Display_brush_color_zoom_double(word x_pos,word y_pos,
for(bx=Main.magnifier_factor;bx>0;bx--) for(bx=Main.magnifier_factor;bx>0;bx--)
{ {
Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main.magnifier_factor,buffer,transp_color); Display_transparent_line_on_screen_wide(x_pos,y*ZOOMY,width*Main.magnifier_factor,buffer,transp_color);
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -37,6 +36,7 @@
void Pixel_quad (word x,word y,byte color) void Pixel_quad (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
#if 0
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
@ -53,36 +53,59 @@ void Pixel_quad (word x,word y,byte color)
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 2)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 2)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 3)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 3)=color;
#endif
Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 3, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 3, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 3, color);
Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY + 3, color);
} }
byte Read_pixel_quad (word x,word y) byte Read_pixel_quad (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX); //return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
} }
void Block_quad (word start_x,word start_y,word width,word height,byte color) void Block_quad (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x*ZOOMX; rectangle.x=start_x*ZOOMX;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width*ZOOMX; rectangle.w=width*ZOOMX;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
} }
void Display_part_of_screen_quad (word width,word height,word image_width) void Display_part_of_screen_quad (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
for(y=height;y!=0;y--) for(y = 0; y < height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte* dest = Get_Screen_pixel_ptr(0, y * ZOOMY);
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
@ -91,15 +114,18 @@ void Display_part_of_screen_quad (word width,word height,word image_width)
dest+=ZOOMX; dest+=ZOOMX;
} }
// On double la ligne qu'on vient de copier // On double la ligne qu'on vient de copier
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 1), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On la triple // On la triple
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 2), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On la quadruple // On la quadruple
memcpy(dest-width*ZOOMX+3*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+3*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 3), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -144,53 +170,95 @@ void Pixel_preview_magnifier_quad (word x,word y,byte color)
void Horizontal_XOR_line_quad(word x_pos,word y_pos,word width) void Horizontal_XOR_line_quad(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
int x; int x;
for (x=0;x<width*ZOOMX;x+=ZOOMX) for (x=0;x<width*ZOOMX;x+=ZOOMX)
*(dest+x+3*VIDEO_LINE_WIDTH+3)=*(dest+x+3*VIDEO_LINE_WIDTH+2)=*(dest+x+3*VIDEO_LINE_WIDTH+1)=*(dest+x+3*VIDEO_LINE_WIDTH)=*(dest+x+2*VIDEO_LINE_WIDTH+3)=*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+3)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+3)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)]; {
//*(dest+x+3*VIDEO_LINE_WIDTH+3)=*(dest+x+3*VIDEO_LINE_WIDTH+2)=*(dest+x+3*VIDEO_LINE_WIDTH+1)=*(dest+x+3*VIDEO_LINE_WIDTH)=*(dest+x+2*VIDEO_LINE_WIDTH+3)=*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+3)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+3)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)];
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY + 3, color);
}
} }
void Vertical_XOR_line_quad(word x_pos,word y_pos,word height) void Vertical_XOR_line_quad(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; //byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
for (i=height;i>0;i--) for (i = 0; i < height; i++)
{ {
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*(dest)=xor_lut[*(dest)]; //*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*(dest)=xor_lut[*(dest)];
dest+=VIDEO_LINE_WIDTH*ZOOMY; //dest+=VIDEO_LINE_WIDTH*ZOOMY;
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY + 3, color);
} }
} }
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) 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)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
// Pour chaque pixel byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+3*VIDEO_LINE_WIDTH+3) = *(dest+3*VIDEO_LINE_WIDTH+2) = *(dest+3*VIDEO_LINE_WIDTH+1) = *(dest+3*VIDEO_LINE_WIDTH) = *(dest+2*VIDEO_LINE_WIDTH+3) = *(dest+2*VIDEO_LINE_WIDTH+2) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+3) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src; //*(dest+3*VIDEO_LINE_WIDTH+3) = *(dest+3*VIDEO_LINE_WIDTH+2) = *(dest+3*VIDEO_LINE_WIDTH+1) = *(dest+3*VIDEO_LINE_WIDTH) = *(dest+2*VIDEO_LINE_WIDTH+3) = *(dest+2*VIDEO_LINE_WIDTH+2) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+3) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
*(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;
} }
// Pixel suivant // Pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -201,36 +269,43 @@ void Display_brush_mono_quad(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à // dest = adr destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) // Pour chaque ligne
//Pour chaque ligne for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=color; //*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=color;
*(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;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
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) 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)
{ {
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -238,22 +313,30 @@ void Clear_brush_quad(word x_pos,word y_pos,word x_offset,word y_offset,word wid
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src; //*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
*(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;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -262,30 +345,36 @@ void Clear_brush_quad(word x_pos,word y_pos,word x_offset,word y_offset,word wid
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) 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)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src; //*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
*(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;
} }
// Pixel suivant // Pixel suivant
src++; dest+=ZOOMX; src++; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -293,21 +382,28 @@ void Display_brush_quad(byte * brush, word x_pos,word y_pos,word x_offset,word y
void Remap_screen_quad(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_quad(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest= //*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=
*(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 =
conversion_table[*dest]; conversion_table[*dest];
dest +=ZOOMX; dest +=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -317,22 +413,34 @@ void Display_line_on_screen_fast_quad(word x_pos,word y_pos,word width,byte * li
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+3)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+3)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+1), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+2), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+3), line, width*ZOOMX);
} }
void Display_line_on_screen_quad(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_quad(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *dest; //byte *dest;
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 3);
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*line; //*(dest+3*VIDEO_LINE_WIDTH+3)=*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+3)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*line;
*(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;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
line++; line++;
} }
} }
@ -342,7 +450,8 @@ void Display_transparent_mono_line_on_screen_quad(
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos);
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
@ -358,7 +467,8 @@ void Display_transparent_mono_line_on_screen_quad(
void Read_line_screen_quad(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_quad(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX); //memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), width*ZOOMX);
} }
void Display_part_of_screen_scaled_quad( void Display_part_of_screen_scaled_quad(
@ -423,7 +533,8 @@ void Display_brush_color_zoom_quad(word x_pos,word y_pos,
for(bx=Main.magnifier_factor;bx>0;bx--) for(bx=Main.magnifier_factor;bx>0;bx--)
{ {
byte* line_src = buffer; byte* line_src = buffer;
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; //byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY);
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne
for(x = width*Main.magnifier_factor;x > 0;x--) for(x = width*Main.magnifier_factor;x > 0;x--)
@ -436,11 +547,14 @@ void Display_brush_color_zoom_quad(word x_pos,word y_pos,
dest+=ZOOMX; dest+=ZOOMX;
} }
// Double the line // Double the line
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
// Triple the line // Triple the line
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
// Quadruple it // Quadruple it
memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {
@ -542,5 +656,3 @@ void Clear_brush_scaled_quad(word x_pos,word y_pos,word x_offset,word y_offset,w
src+= image_width; src+= image_width;
} }
} }

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -34,42 +33,47 @@
void Pixel_simple (word x,word y,byte color) void Pixel_simple (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Screen_pixels + x + y * VIDEO_LINE_WIDTH)=color; //*(Screen_pixels + x + y * VIDEO_LINE_WIDTH)=color;
Set_Screen_pixel(x, y, color);
} }
byte Read_pixel_simple (word x,word y) byte Read_pixel_simple (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * VIDEO_LINE_WIDTH + x ); //return *( Screen_pixels + y * VIDEO_LINE_WIDTH + x );
return Get_Screen_pixel(x, y);
} }
void Block_simple (word start_x,word start_y,word width,word height,byte color) void Block_simple (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x; rectangle.x=start_x;
rectangle.y=start_y; rectangle.y=start_y;
rectangle.w=width; rectangle.w=width;
rectangle.h=height; rectangle.h=height;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x, start_y, width, height, color);
} }
void Display_part_of_screen_simple (word width,word height,word image_width) void Display_part_of_screen_simple (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; word y;
for(y=height;y!=0;y--) for(y=0;y<height;y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte *dest = Get_Screen_pixel_ptr(0, y);
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(dest,src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width; src+=image_width;
dest+=VIDEO_LINE_WIDTH;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -114,7 +118,8 @@ void Pixel_preview_magnifier_simple (word x,word y,byte color)
void Horizontal_XOR_line_simple(word x_pos,word y_pos,word width) void Horizontal_XOR_line_simple(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; //byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
byte* dest=Get_Screen_pixel_ptr(x_pos, y_pos);
int x; int x;
@ -128,23 +133,25 @@ void Vertical_XOR_line_simple(word x_pos,word y_pos,word height)
byte color; byte color;
for (i=y_pos;i<y_pos+height;i++) for (i=y_pos;i<y_pos+height;i++)
{ {
color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH); //color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH);
*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=xor_lut[color]; color = Get_Screen_pixel(x_pos, i);
//*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=xor_lut[color];
Set_Screen_pixel(x_pos, i, xor_lut[color]);
} }
} }
void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos, y_pos + y);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
@ -159,7 +166,6 @@ void Display_brush_color_simple(word x_pos,word y_pos,word x_offset,word y_offse
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH - width;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -170,15 +176,16 @@ void Display_brush_mono_simple(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à // dest = adr Destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) for(y=0; y<height; y++)
//Pour chaque ligne //Pour chaque ligne
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos, y_pos + y);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
@ -192,29 +199,30 @@ void Display_brush_mono_simple(word x_pos, word y_pos,
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH-width; //dest+=VIDEO_LINE_WIDTH-width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) void Clear_brush_simple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
(void)x_offset; // unused (void)x_offset; // unused
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--) for(y=0; y<height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos, y_pos + y);
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(dest,src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width; src+=image_width;
dest+=VIDEO_LINE_WIDTH; //dest+=VIDEO_LINE_WIDTH;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -223,15 +231,15 @@ void Clear_brush_simple(word x_pos,word y_pos,word x_offset,word y_offset,word w
void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos, y_pos + y);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
@ -246,7 +254,6 @@ void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH - width;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -254,12 +261,12 @@ void Display_brush_simple(byte * brush, word x_pos,word y_pos,word x_offset,word
void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y=0; y<height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos, y_pos + y);
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
@ -267,7 +274,7 @@ void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * con
dest ++; dest ++;
} }
dest = dest + VIDEO_LINE_WIDTH - width; //dest = dest + VIDEO_LINE_WIDTH - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -276,7 +283,9 @@ void Remap_screen_simple(word x_pos,word y_pos,word width,word height,byte * con
void Display_line_on_screen_simple(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_simple(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */ /* On affiche toute une ligne de pixels. Utilisé pour les textes. */
{ {
memcpy(Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH,line,width); byte* dest = Get_Screen_pixel_ptr(x_pos, y_pos);
memcpy(dest, line, width);
//memcpy(Screen_pixels+x_pos+y_pos*VIDEO_LINE_WIDTH,line,width);
} }
void Display_transparent_mono_line_on_screen_simple( void Display_transparent_mono_line_on_screen_simple(
@ -285,7 +294,8 @@ void Display_transparent_mono_line_on_screen_simple(
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos * VIDEO_LINE_WIDTH + x_pos; //byte* dest = Screen_pixels+ y_pos * VIDEO_LINE_WIDTH + x_pos;
byte* dest = Get_Screen_pixel_ptr(x_pos, y_pos);
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
@ -299,7 +309,8 @@ void Display_transparent_mono_line_on_screen_simple(
void Read_line_screen_simple(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_simple(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH * y_pos + x_pos + Screen_pixels,width); //memcpy(line,VIDEO_LINE_WIDTH * y_pos + x_pos + Screen_pixels,width);
memcpy(line, Get_Screen_pixel_ptr(x_pos, y_pos), width);
} }
void Display_part_of_screen_scaled_simple( void Display_part_of_screen_scaled_simple(
@ -347,7 +358,8 @@ void Display_part_of_screen_scaled_simple(
void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color) void Display_transparent_line_on_screen_simple(word x_pos,word y_pos,word width,byte* line,byte transp_color)
{ {
byte* src = line; byte* src = line;
byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos; //byte* dest = Screen_pixels + y_pos * VIDEO_LINE_WIDTH + x_pos;
byte* dest = Get_Screen_pixel_ptr(x_pos, y_pos);
word x; word x;

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -38,45 +37,53 @@
void Pixel_tall (word x,word y,byte color) void Pixel_tall (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Screen_pixels + x + y*ZOOMY*VIDEO_LINE_WIDTH)=color; //*(Screen_pixels + x + y*ZOOMY*VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x + (y*ZOOMY+1)*VIDEO_LINE_WIDTH)=color; //*(Screen_pixels + x + (y*ZOOMY+1)*VIDEO_LINE_WIDTH)=color;
Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 1, color);
} }
byte Read_pixel_tall (word x,word y) byte Read_pixel_tall (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x ); //return *( Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x );
return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
} }
void Block_tall (word start_x,word start_y,word width,word height,byte color) void Block_tall (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x; rectangle.x=start_x;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width; rectangle.w=width;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
} }
void Display_part_of_screen_tall (word width,word height,word image_width) void Display_part_of_screen_tall (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
for(y=height;y!=0;y--) for(y = 0; y < height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(dest,src,width); //memcpy(dest,src,width);
dest+=VIDEO_LINE_WIDTH; memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY), src, width);
memcpy(dest,src,width); //dest+=VIDEO_LINE_WIDTH;
//memcpy(dest,src,width);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 1), src, width);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width; src+=image_width;
dest+=VIDEO_LINE_WIDTH; //dest+=VIDEO_LINE_WIDTH;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -121,14 +128,16 @@ void Pixel_preview_magnifier_tall (word x,word y,byte color)
void Horizontal_XOR_line_tall(word x_pos,word y_pos,word width) void Horizontal_XOR_line_tall(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
int x; int x;
for (x=0;x<width;x++) for (x=0;x<width;x++)
*(dest+x)=xor_lut[*(dest+x)]; *(dest+x)=xor_lut[*(dest+x)];
dest=(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; //dest=(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH+x_pos+Screen_pixels;
dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1);
for (x=0;x<width;x++) for (x=0;x<width;x++)
*(dest+x)=xor_lut[*(dest+x)]; *(dest+x)=xor_lut[*(dest+x)];
} }
@ -139,23 +148,26 @@ void Vertical_XOR_line_tall(word x_pos,word y_pos,word height)
byte color; byte color;
for (i=y_pos*ZOOMY;i<(y_pos+height)*ZOOMY;i++) for (i=y_pos*ZOOMY;i<(y_pos+height)*ZOOMY;i++)
{ {
color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH); //color=*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH);
*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=xor_lut[color]; color = Get_Screen_pixel(x_pos, i);
//*(Screen_pixels+x_pos+i*VIDEO_LINE_WIDTH)=xor_lut[color];
Set_Screen_pixel(x_pos, i, xor_lut[color]);
} }
} }
void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY + 1);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
@ -163,15 +175,15 @@ void Display_brush_color_tall(word x_pos,word y_pos,word x_offset,word y_offset,
if(*src != transp_color) if(*src != transp_color)
{ {
*dest = *src; *dest = *src;
*(dest+VIDEO_LINE_WIDTH) = *src; //*(dest+VIDEO_LINE_WIDTH) = *src;
*dest2 = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest++; src++; dest++; dest2++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + ZOOMY*VIDEO_LINE_WIDTH - width;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -182,56 +194,61 @@ void Display_brush_mono_tall(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos+Screen_pixels; // dest = adr Destination à // dest = adr Destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--)
//Pour chaque ligne //Pour chaque ligne
for(y = 0; y < height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY + 1);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
{ {
*dest=color; *dest=color;
*(dest+VIDEO_LINE_WIDTH)=color; //*(dest+VIDEO_LINE_WIDTH)=color;
*dest2 = color;
} }
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest++; dest++;
dest2++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=ZOOMY*VIDEO_LINE_WIDTH-width; //dest+=ZOOMY*VIDEO_LINE_WIDTH-width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) void Clear_brush_tall(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
(void)x_offset; // unused (void)x_offset; // unused
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--) for(y=0; y<height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY);
// On fait une copie de la ligne // On fait une copie de la ligne
memcpy(dest,src,width); memcpy(dest,src,width);
dest+=VIDEO_LINE_WIDTH; dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY + 1);
memcpy(dest,src,width); memcpy(dest,src,width);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width; src+=image_width;
dest+=VIDEO_LINE_WIDTH; //dest+=VIDEO_LINE_WIDTH;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -240,15 +257,16 @@ void Clear_brush_tall(word x_pos,word y_pos,word x_offset,word y_offset,word wid
void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y=0; y<height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY + 1);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
@ -256,15 +274,14 @@ void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y
if(*src != transp_color) if(*src != transp_color)
{ {
*dest = *src; *dest = *src;
*(dest+VIDEO_LINE_WIDTH) = *src; *dest2 = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest++; src++; dest++; dest2++;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -272,12 +289,12 @@ void Display_brush_tall(byte * brush, word x_pos,word y_pos,word x_offset,word y
void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos*ZOOMY*VIDEO_LINE_WIDTH + x_pos;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height*ZOOMY;y>0;y--) for(y=0; y<height*ZOOMY; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + y);
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
@ -285,7 +302,7 @@ void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conve
dest ++; dest ++;
} }
dest = dest + VIDEO_LINE_WIDTH - width; //dest = dest + VIDEO_LINE_WIDTH - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -294,13 +311,16 @@ void Remap_screen_tall(word x_pos,word y_pos,word width,word height,byte * conve
void Display_line_on_screen_tall(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_tall(word x_pos,word y_pos,word width,byte * line)
/* On affiche toute une ligne de pixels. Utilisé pour les textes. */ /* On affiche toute une ligne de pixels. Utilisé pour les textes. */
{ {
memcpy(Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width); //memcpy(Screen_pixels+x_pos+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width);
memcpy(Screen_pixels+x_pos+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width); //memcpy(Screen_pixels+x_pos+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width);
memcpy(Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), line, width);
memcpy(Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1), line, width);
} }
void Read_line_screen_tall(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_tall(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY*y_pos + x_pos + Screen_pixels,width); //memcpy(line,VIDEO_LINE_WIDTH*ZOOMY*y_pos + x_pos + Screen_pixels,width);
memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), width);
} }
void Display_part_of_screen_scaled_tall( void Display_part_of_screen_scaled_tall(
@ -365,7 +385,8 @@ void Display_brush_color_zoom_tall(word x_pos,word y_pos,
for(bx=Main.magnifier_factor;bx>0;bx--) for(bx=Main.magnifier_factor;bx>0;bx--)
{ {
Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main.magnifier_factor,buffer,transp_color); Display_transparent_line_on_screen_simple(x_pos,y*ZOOMY,width*Main.magnifier_factor,buffer,transp_color);
memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY +1) * VIDEO_LINE_WIDTH + x_pos, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos, width*Main.magnifier_factor);
memcpy(Get_Screen_pixel_ptr(x_pos, y * ZOOMY + 1), Get_Screen_pixel_ptr(x_pos, y * ZOOMY), width*Main.magnifier_factor);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -37,6 +36,7 @@
void Pixel_tall2 (word x,word y,byte color) void Pixel_tall2 (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
#if 0
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH)=color;
@ -45,36 +45,50 @@ void Pixel_tall2 (word x,word y,byte color)
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 1)=color;
#endif
Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 3, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 3, color);
} }
byte Read_pixel_tall2 (word x,word y) byte Read_pixel_tall2 (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX); //return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
} }
void Block_tall2 (word start_x,word start_y,word width,word height,byte color) void Block_tall2 (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x*ZOOMX; rectangle.x=start_x*ZOOMX;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width*ZOOMX; rectangle.w=width*ZOOMX;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
} }
void Display_part_of_screen_tall2 (word width,word height,word image_width) void Display_part_of_screen_tall2 (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; word y;
int dy; int dy;
for(y=height;y!=0;y--) for(y = 0; y < height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte* dest = Get_Screen_pixel_ptr(0, y * ZOOMY);
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
@ -83,15 +97,18 @@ void Display_part_of_screen_tall2 (word width,word height,word image_width)
dest+=ZOOMX; dest+=ZOOMX;
} }
// On double la ligne qu'on vient de copier // On double la ligne qu'on vient de copier
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 1), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On la triple // On la triple
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 2), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On la quadruple // On la quadruple
memcpy(dest-width*ZOOMX+3*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+3*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 3), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -136,53 +153,79 @@ void Pixel_preview_magnifier_tall2 (word x,word y,byte color)
void Horizontal_XOR_line_tall2(word x_pos,word y_pos,word width) void Horizontal_XOR_line_tall2(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
int x; int x;
for (x=0;x<width*ZOOMX;x+=ZOOMX) for (x=0;x<width*ZOOMX;x+=ZOOMX)
*(dest+x+3*VIDEO_LINE_WIDTH+1)=*(dest+x+3*VIDEO_LINE_WIDTH)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)]; {
//*(dest+x+3*VIDEO_LINE_WIDTH+1)=*(dest+x+3*VIDEO_LINE_WIDTH)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)];
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 3, color);
}
} }
void Vertical_XOR_line_tall2(word x_pos,word y_pos,word height) void Vertical_XOR_line_tall2(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; //byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
for (i=height;i>0;i--) for (i=0; i<height; i++)
{ {
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=xor_lut[*(dest)]; //*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=xor_lut[*(dest)];
dest+=VIDEO_LINE_WIDTH*ZOOMY; //dest+=VIDEO_LINE_WIDTH*ZOOMY;
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 3, color);
} }
} }
void Display_brush_color_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte *dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte *dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+3*VIDEO_LINE_WIDTH+1) = *(dest+3*VIDEO_LINE_WIDTH) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+1) = *dest = *src; //*(dest+3*VIDEO_LINE_WIDTH+1) = *(dest+3*VIDEO_LINE_WIDTH) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+1) = *dest = *src;
*(dest3+1)=*(dest3)=*(dest2+1)=*(dest2)=*(dest1+1)=*(dest1)=*(dest+1)=*(dest)=*src;
} }
// Pixel suivant // Pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -193,36 +236,43 @@ void Display_brush_mono_tall2(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à // dest = adr destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) // Pour chaque ligne
//Pour chaque ligne for(y = 0; y < height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte *dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte *dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=color; //*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=color;
*(dest3+1)=*(dest3)=*(dest2+1)=*(dest2)=*(dest1+1)=*(dest1)=*(dest+1)=*(dest)=color;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) void Clear_brush_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -230,22 +280,30 @@ void Clear_brush_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word wi
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
for(y = 0; y < height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte *dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte *dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*src; //*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*src;
*(dest3+1)=*(dest3)=*(dest2+1)=*(dest2)=*(dest1+1)=*(dest1)=*(dest+1)=*(dest)=*src;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -254,30 +312,36 @@ void Clear_brush_tall2(word x_pos,word y_pos,word x_offset,word y_offset,word wi
void Display_brush_tall2(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_tall2(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte *dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte *dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*src; //*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*src;
*(dest3+1)=*(dest3)=*(dest2+1)=*(dest2)=*(dest1+1)=*(dest1)=*(dest+1)=*(dest)=*src;
} }
// Pixel suivant // Pixel suivant
src++; dest+=ZOOMX; src++; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -285,21 +349,28 @@ void Display_brush_tall2(byte * brush, word x_pos,word y_pos,word x_offset,word
void Remap_screen_tall2(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_tall2(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y = 0; y < height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte *dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte *dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)= //*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=
*(dest3+1)=*(dest3)=*(dest2+1)=*(dest2)=*(dest1+1)=*(dest1)=*(dest+1)=*(dest)=
conversion_table[*dest]; conversion_table[*dest];
dest +=ZOOMX; dest +=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -309,22 +380,34 @@ void Display_line_on_screen_fast_tall2(word x_pos,word y_pos,word width,byte * l
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+3)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+3)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+1), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+2), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+3), line, width*ZOOMX);
} }
void Display_line_on_screen_tall2(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_tall2(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *dest; //byte *dest;
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
byte *dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1);
byte *dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 2);
byte *dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 3);
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*line; //*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=*line;
*(dest3+1)=*(dest3)=*(dest2+1)=*(dest2)=*(dest1+1)=*(dest1)=*(dest+1)=*(dest)=*line;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
line++; line++;
} }
} }
@ -334,7 +417,8 @@ void Display_transparent_mono_line_on_screen_tall2(
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos*ZOOMX, y_pos);
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
@ -350,7 +434,8 @@ void Display_transparent_mono_line_on_screen_tall2(
void Read_line_screen_tall2(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_tall2(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX); //memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), width*ZOOMX);
} }
void Display_part_of_screen_scaled_tall2( void Display_part_of_screen_scaled_tall2(
@ -415,7 +500,8 @@ void Display_brush_color_zoom_tall2(word x_pos,word y_pos,
for(bx=Main.magnifier_factor;bx>0;bx--) for(bx=Main.magnifier_factor;bx>0;bx--)
{ {
byte* line_src = buffer; byte* line_src = buffer;
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; //byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY);
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne
for(x = width*Main.magnifier_factor;x > 0;x--) for(x = width*Main.magnifier_factor;x > 0;x--)
@ -428,11 +514,14 @@ void Display_brush_color_zoom_tall2(word x_pos,word y_pos,
dest+=ZOOMX; dest+=ZOOMX;
} }
// Double the line // Double the line
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
// Triple the line // Triple the line
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
// Quadruple it // Quadruple it
memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -37,6 +36,7 @@
void Pixel_tall3 (word x,word y,byte color) void Pixel_tall3 (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
#if 0
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
@ -49,36 +49,54 @@ void Pixel_tall3 (word x,word y,byte color)
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 2)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+3) * VIDEO_LINE_WIDTH + 2)=color;
#endif
Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 3, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 3, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 3, color);
} }
byte Read_pixel_tall3 (word x,word y) byte Read_pixel_tall3 (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX); //return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
} }
void Block_tall3 (word start_x,word start_y,word width,word height,byte color) void Block_tall3 (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x*ZOOMX; rectangle.x=start_x*ZOOMX;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width*ZOOMX; rectangle.w=width*ZOOMX;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
} }
void Display_part_of_screen_tall3 (word width,word height,word image_width) void Display_part_of_screen_tall3 (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
for(y=height;y!=0;y--) for(y = 0; y < height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte* dest = Get_Screen_pixel_ptr(0, y * ZOOMY);
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
@ -87,15 +105,18 @@ void Display_part_of_screen_tall3 (word width,word height,word image_width)
dest+=ZOOMX; dest+=ZOOMX;
} }
// On double la ligne qu'on vient de copier // On double la ligne qu'on vient de copier
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 1), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On la triple // On la triple
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 2), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On la quadruple // On la quadruple
memcpy(dest-width*ZOOMX+3*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+3*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 3), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -140,53 +161,84 @@ void Pixel_preview_magnifier_tall3 (word x,word y,byte color)
void Horizontal_XOR_line_tall3(word x_pos,word y_pos,word width) void Horizontal_XOR_line_tall3(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
int x; int x;
for (x=0;x<width*ZOOMX;x+=ZOOMX) for (x=0;x<width*ZOOMX;x+=ZOOMX)
*(dest+x+3*VIDEO_LINE_WIDTH+2)=*(dest+x+3*VIDEO_LINE_WIDTH+1)=*(dest+x+3*VIDEO_LINE_WIDTH)=*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)]; {
//*(dest+x+3*VIDEO_LINE_WIDTH+2)=*(dest+x+3*VIDEO_LINE_WIDTH+1)=*(dest+x+3*VIDEO_LINE_WIDTH)=*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)];
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 3, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 3, color);
}
} }
void Vertical_XOR_line_tall3(word x_pos,word y_pos,word height) void Vertical_XOR_line_tall3(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; //byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
for (i=height;i>0;i--) for (i=0; i<height; i++)
{ {
*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=xor_lut[*(dest)]; //*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=xor_lut[*(dest)];
dest+=VIDEO_LINE_WIDTH*ZOOMY; //dest+=VIDEO_LINE_WIDTH*ZOOMY;
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 2, color);
} }
} }
void Display_brush_color_tall3(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_tall3(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+3*VIDEO_LINE_WIDTH+2) =*(dest+3*VIDEO_LINE_WIDTH+1) = *(dest+3*VIDEO_LINE_WIDTH) = *(dest+2*VIDEO_LINE_WIDTH+2) =*(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+2) =*(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+2) =*(dest+1) = *dest = *src; //*(dest+3*VIDEO_LINE_WIDTH+2) =*(dest+3*VIDEO_LINE_WIDTH+1) = *(dest+3*VIDEO_LINE_WIDTH) = *(dest+2*VIDEO_LINE_WIDTH+2) =*(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+2) =*(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+2) =*(dest+1) = *dest = *src;
*(dest3+2) =*(dest3+1) = *(dest3) = *(dest2+2) =*(dest2+1) = *(dest2) = *(dest1+2) =*(dest1+1) = *(dest1) = *(dest+2) =*(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -197,36 +249,43 @@ void Display_brush_mono_tall3(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à // dest = adr destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) // Pour chaque ligne
//Pour chaque ligne for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=color; //*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=color;
*(dest3+2) =*(dest3+1) = *(dest3) = *(dest2+2) =*(dest2+1) = *(dest2) = *(dest1+2) =*(dest1+1) = *(dest1) = *(dest+2) =*(dest+1) = *dest = color;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_tall3(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) void Clear_brush_tall3(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -234,22 +293,30 @@ void Clear_brush_tall3(word x_pos,word y_pos,word x_offset,word y_offset,word wi
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=*src; //*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=*src;
*(dest3+2) =*(dest3+1) = *(dest3) = *(dest2+2) =*(dest2+1) = *(dest2) = *(dest1+2) =*(dest1+1) = *(dest1) = *(dest+2) =*(dest+1) = *dest = *src;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -258,30 +325,36 @@ void Clear_brush_tall3(word x_pos,word y_pos,word x_offset,word y_offset,word wi
void Display_brush_tall3(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_tall3(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=*src; //*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=*src;
*(dest3+2) =*(dest3+1) = *(dest3) = *(dest2+2) =*(dest2+1) = *(dest2) = *(dest1+2) =*(dest1+1) = *(dest1) = *(dest+2) =*(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest+=ZOOMX; src++; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -289,21 +362,28 @@ void Display_brush_tall3(byte * brush, word x_pos,word y_pos,word x_offset,word
void Remap_screen_tall3(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_tall3(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 3);
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)= //*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=
*(dest3+2) =*(dest3+1) = *(dest3) = *(dest2+2) =*(dest2+1) = *(dest2) = *(dest1+2) =*(dest1+1) = *(dest1) = *(dest+2) =*(dest+1) = *dest =
conversion_table[*dest]; conversion_table[*dest];
dest +=ZOOMX; dest +=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
dest3+=ZOOMX;
} }
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -313,21 +393,30 @@ void Display_line_on_screen_fast_tall3(word x_pos,word y_pos,word width,byte * l
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+3)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+3)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+1), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+2), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+3), line, width*ZOOMX);
} }
void Display_line_on_screen_tall3(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_tall3(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *dest; //byte *dest;
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 2);
byte* dest3 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 3);
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=*line; //*(dest+3*VIDEO_LINE_WIDTH+2)=*(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*(dest)=*line;
*(dest3+2) =*(dest3+1) = *(dest3) = *(dest2+2) =*(dest2+1) = *(dest2) = *(dest1+2) =*(dest1+1) = *(dest1) = *(dest+2) =*(dest+1) = *dest = *line;
dest+=ZOOMX; dest+=ZOOMX;
line++; line++;
} }
@ -338,7 +427,8 @@ void Display_transparent_mono_line_on_screen_tall3(
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos);
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
@ -354,7 +444,8 @@ void Display_transparent_mono_line_on_screen_tall3(
void Read_line_screen_tall3(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_tall3(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX); //memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), width*ZOOMX);
} }
void Display_part_of_screen_scaled_tall3( void Display_part_of_screen_scaled_tall3(
@ -419,7 +510,8 @@ void Display_brush_color_zoom_tall3(word x_pos,word y_pos,
for(bx=Main.magnifier_factor;bx>0;bx--) for(bx=Main.magnifier_factor;bx>0;bx--)
{ {
byte* line_src = buffer; byte* line_src = buffer;
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; //byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y*ZOOMY);
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne
for(x = width*Main.magnifier_factor;x > 0;x--) for(x = width*Main.magnifier_factor;x > 0;x--)
@ -432,11 +524,14 @@ void Display_brush_color_zoom_tall3(word x_pos,word y_pos,
dest+=ZOOMX; dest+=ZOOMX;
} }
// Double the line // Double the line
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
// Triple the line // Triple the line
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
// Quadruple it // Quadruple it
memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+3)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -37,6 +36,7 @@
void Pixel_triple (word x,word y,byte color) void Pixel_triple (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
#if 0
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
@ -46,36 +46,51 @@ void Pixel_triple (word x,word y,byte color)
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 2)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+2) * VIDEO_LINE_WIDTH + 2)=color;
#endif
Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 2, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 2, color);
} }
byte Read_pixel_triple (word x,word y) byte Read_pixel_triple (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX); //return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
} }
void Block_triple (word start_x,word start_y,word width,word height,byte color) void Block_triple (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x*ZOOMX; rectangle.x=start_x*ZOOMX;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width*ZOOMX; rectangle.w=width*ZOOMX;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
} }
void Display_part_of_screen_triple (word width,word height,word image_width) void Display_part_of_screen_triple (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
for(y=height;y!=0;y--) for(y = 0; y < height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte *dest = Get_Screen_pixel_ptr(0, y * ZOOMY);
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
@ -84,13 +99,15 @@ void Display_part_of_screen_triple (word width,word height,word image_width)
dest+=ZOOMX; dest+=ZOOMX;
} }
// On double la ligne qu'on vient de copier // On double la ligne qu'on vient de copier
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 1), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On la triple // On la triple
memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); //memcpy(dest-width*ZOOMX+2*VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 2), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -135,53 +152,79 @@ void Pixel_preview_magnifier_triple (word x,word y,byte color)
void Horizontal_XOR_line_triple(word x_pos,word y_pos,word width) void Horizontal_XOR_line_triple(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
int x; int x;
for (x=0;x<width*ZOOMX;x+=ZOOMX) for (x=0;x<width*ZOOMX;x+=ZOOMX)
*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)]; {
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY)];
//*(dest+x+2*VIDEO_LINE_WIDTH+2)=*(dest+x+2*VIDEO_LINE_WIDTH+1)=*(dest+x+2*VIDEO_LINE_WIDTH)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)];
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 2, color);
}
} }
void Vertical_XOR_line_triple(word x_pos,word y_pos,word height) void Vertical_XOR_line_triple(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; //byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
for (i=height;i>0;i--) for (i=0; i<height; i++)
{ {
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=xor_lut[*dest]; //*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=xor_lut[*dest];
dest+=VIDEO_LINE_WIDTH*ZOOMY; //dest+=VIDEO_LINE_WIDTH*ZOOMY;
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 2, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 2, color);
} }
} }
void Display_brush_color_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+2*VIDEO_LINE_WIDTH+2) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+2) = *(dest+1) = *dest = *src; //*(dest+2*VIDEO_LINE_WIDTH+2) = *(dest+2*VIDEO_LINE_WIDTH+1) = *(dest+2*VIDEO_LINE_WIDTH) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+2) = *(dest+1) = *dest = *src;
*(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+2) = *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -192,36 +235,41 @@ void Display_brush_mono_triple(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à // dest = adr destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) // Pour chaque ligne
//Pour chaque ligne for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=color; //*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=color;
*(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+2) = *(dest+1) = *dest = color;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) void Clear_brush_triple(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -229,22 +277,28 @@ void Clear_brush_triple(word x_pos,word y_pos,word x_offset,word y_offset,word w
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src; //*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src;
*(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+2) = *(dest+1) = *dest = *src;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -253,30 +307,33 @@ void Clear_brush_triple(word x_pos,word y_pos,word x_offset,word y_offset,word w
void Display_brush_triple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_triple(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src; //*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*src;
*(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+2) = *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest+=ZOOMX; src++; dest+=ZOOMX;
dest1+=ZOOMX; dest2+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -284,21 +341,25 @@ void Display_brush_triple(byte * brush, word x_pos,word y_pos,word x_offset,word
void Remap_screen_triple(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_triple(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 2);
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest= //*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=
*(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+2) = *(dest+1) = *dest =
conversion_table[*dest]; conversion_table[*dest];
dest +=ZOOMX; dest +=ZOOMX;
dest1+=ZOOMX; dest2+=ZOOMX;
} }
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -308,21 +369,30 @@ void Display_line_on_screen_fast_triple(word x_pos,word y_pos,word width,byte *
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+2)*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+1), line, width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY+2), line, width*ZOOMX);
} }
void Display_line_on_screen_triple(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_triple(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *dest; //byte *dest;
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1);
byte* dest2 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 2);
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*line; //*(dest+2*VIDEO_LINE_WIDTH+2)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+2)=*(dest+1)=*dest=*line;
*(dest2+2) = *(dest2+1) = *(dest2) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+2) = *(dest+1) = *dest = *line;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
dest2+=ZOOMX;
line++; line++;
} }
} }
@ -332,7 +402,8 @@ void Display_transparent_mono_line_on_screen_triple(
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos*ZOOMX, y_pos);
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
@ -348,7 +419,8 @@ void Display_transparent_mono_line_on_screen_triple(
void Read_line_screen_triple(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_triple(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX); //memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY), width*ZOOMX);
} }
void Display_part_of_screen_scaled_triple( void Display_part_of_screen_scaled_triple(
@ -413,7 +485,8 @@ void Display_brush_color_zoom_triple(word x_pos,word y_pos,
for(bx=Main.magnifier_factor;bx>0;bx--) for(bx=Main.magnifier_factor;bx>0;bx--)
{ {
byte* line_src = buffer; byte* line_src = buffer;
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; //byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y * ZOOMY);
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne
for(x = width*Main.magnifier_factor;x > 0;x--) for(x = width*Main.magnifier_factor;x > 0;x--)
@ -426,9 +499,11 @@ void Display_brush_color_zoom_triple(word x_pos,word y_pos,
dest+=ZOOMX; dest+=ZOOMX;
} }
// Double the line // Double the line
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
// Triple the line // Triple the line
memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+2)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -37,38 +36,45 @@
void Pixel_wide (word x,word y,byte color) void Pixel_wide (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color; //*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color; //*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY, color);
} }
byte Read_pixel_wide (word x,word y) byte Read_pixel_wide (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX); //return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
} }
void Block_wide (word start_x,word start_y,word width,word height,byte color) void Block_wide (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x*ZOOMX; rectangle.x=start_x*ZOOMX;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width*ZOOMX; rectangle.w=width*ZOOMX;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
} }
void Display_part_of_screen_wide (word width,word height,word image_width) void Display_part_of_screen_wide (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
for(y=height;y!=0;y--) for(y = 0; y < height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte *dest = Get_Screen_pixel_ptr(0, y * ZOOMY);
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
@ -79,7 +85,7 @@ void Display_part_of_screen_wide (word width,word height,word image_width)
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -124,7 +130,8 @@ void Pixel_preview_magnifier_wide (word x,word y,byte color)
void Horizontal_XOR_line_wide(word x_pos,word y_pos,word width) void Horizontal_XOR_line_wide(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
int x; int x;
@ -135,26 +142,30 @@ void Horizontal_XOR_line_wide(word x_pos,word y_pos,word width)
void Vertical_XOR_line_wide(word x_pos,word y_pos,word height) void Vertical_XOR_line_wide(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; byte color;
for (i=height;i>0;i--) //byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
for (i = 0; i < height; i++)
{ {
*dest=*(dest+1)=xor_lut[*dest]; color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY)];
dest+=VIDEO_LINE_WIDTH*ZOOMY; Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY, color);
//*dest=*(dest+1)=xor_lut[*dest];
//dest+=VIDEO_LINE_WIDTH*ZOOMY;
} }
} }
void Display_brush_color_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
@ -170,7 +181,6 @@ void Display_brush_color_wide(word x_pos,word y_pos,word x_offset,word y_offset,
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -181,15 +191,15 @@ void Display_brush_mono_wide(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à // dest = adr destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) // Pour chaque ligne
//Pour chaque ligne for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
@ -203,14 +213,14 @@ void Display_brush_mono_wide(word x_pos, word y_pos,
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) void Clear_brush_wide(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -218,9 +228,10 @@ void Clear_brush_wide(word x_pos,word y_pos,word x_offset,word y_offset,word wid
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
@ -233,7 +244,7 @@ void Clear_brush_wide(word x_pos,word y_pos,word x_offset,word y_offset,word wid
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -242,15 +253,15 @@ void Clear_brush_wide(word x_pos,word y_pos,word x_offset,word y_offset,word wid
void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY);
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
@ -265,7 +276,6 @@ void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -273,12 +283,12 @@ void Display_brush_wide(byte * brush, word x_pos,word y_pos,word x_offset,word y
void Remap_screen_wide(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_wide(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y=0; y<height; y++)
{ {
byte *dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos+y) * ZOOMY);
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
@ -286,7 +296,7 @@ void Remap_screen_wide(word x_pos,word y_pos,word width,word height,byte * conve
dest +=ZOOMX; dest +=ZOOMX;
} }
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -296,7 +306,8 @@ void Display_line_on_screen_fast_wide(word x_pos,word y_pos,word width,byte * li
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX); //memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX);
memcpy(Get_Screen_pixel_ptr(+x_pos*ZOOMX, y_pos*ZOOMY), line, width*ZOOMX);
} }
void Display_line_on_screen_wide(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_wide(word x_pos,word y_pos,word width,byte * line)
@ -304,7 +315,8 @@ void Display_line_on_screen_wide(word x_pos,word y_pos,word width,byte * line)
{ {
int x; int x;
byte *dest; byte *dest;
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+1)=*dest=*line; *(dest+1)=*dest=*line;
@ -318,7 +330,8 @@ void Display_transparent_mono_line_on_screen_wide(
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos);
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
@ -334,7 +347,8 @@ void Display_transparent_mono_line_on_screen_wide(
void Read_line_screen_wide(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_wide(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX); //memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, ZOOMY * y_pos), width*ZOOMX);
} }
void Display_part_of_screen_scaled_wide( void Display_part_of_screen_scaled_wide(
@ -382,7 +396,8 @@ void Display_part_of_screen_scaled_wide(
void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color) void Display_transparent_line_on_screen_wide(word x_pos,word y_pos,word width,byte* line,byte transp_color)
{ {
byte* src = line; byte* src = line;
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos);
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne

View File

@ -23,7 +23,6 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <SDL.h>
#include "global.h" #include "global.h"
#include "sdlscreen.h" #include "sdlscreen.h"
#include "misc.h" #include "misc.h"
@ -37,6 +36,7 @@
void Pixel_wide2 (word x,word y,byte color) void Pixel_wide2 (word x,word y,byte color)
/* Affiche un pixel de la color aux coords x;y à l'écran */ /* Affiche un pixel de la color aux coords x;y à l'écran */
{ {
#if 0
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color; *(Screen_pixels + x * ZOOMX + y*ZOOMY * VIDEO_LINE_WIDTH + 2)=color;
@ -45,36 +45,50 @@ void Pixel_wide2 (word x,word y,byte color)
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 1)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 1)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 2)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 2)=color;
*(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 3)=color; *(Screen_pixels + x * ZOOMX + (y*ZOOMY+1) * VIDEO_LINE_WIDTH + 3)=color;
#endif
Set_Screen_pixel(x * ZOOMX, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY, color);
Set_Screen_pixel(x * ZOOMX, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 1, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 2, y * ZOOMY + 1, color);
Set_Screen_pixel(x * ZOOMX + 3, y * ZOOMY + 1, color);
} }
byte Read_pixel_wide2 (word x,word y) byte Read_pixel_wide2 (word x,word y)
/* On retourne la couleur du pixel aux coords données */ /* On retourne la couleur du pixel aux coords données */
{ {
return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX); //return *( Screen_pixels + y * ZOOMY * VIDEO_LINE_WIDTH + x * ZOOMX);
return Get_Screen_pixel(x * ZOOMX, y * ZOOMY);
} }
void Block_wide2 (word start_x,word start_y,word width,word height,byte color) void Block_wide2 (word start_x,word start_y,word width,word height,byte color)
/* On affiche un rectangle de la couleur donnée */ /* On affiche un rectangle de la couleur donnée */
{ {
#if 0
SDL_Rect rectangle; SDL_Rect rectangle;
rectangle.x=start_x*ZOOMX; rectangle.x=start_x*ZOOMX;
rectangle.y=start_y*ZOOMY; rectangle.y=start_y*ZOOMY;
rectangle.w=width*ZOOMX; rectangle.w=width*ZOOMX;
rectangle.h=height*ZOOMY; rectangle.h=height*ZOOMY;
SDL_FillRect(Screen_SDL,&rectangle,color); SDL_FillRect(Screen_SDL,&rectangle,color);
#endif
Screen_FillRect(start_x * ZOOMX, start_y * ZOOMY, width * ZOOMX, height * ZOOMY, color);
} }
void Display_part_of_screen_wide2 (word width,word height,word image_width) void Display_part_of_screen_wide2 (word width,word height,word image_width)
/* Afficher une partie de l'image telle quelle sur l'écran */ /* Afficher une partie de l'image telle quelle sur l'écran */
{ {
byte* dest=Screen_pixels; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src) byte* src=Main.offset_Y*image_width+Main.offset_X+Main_screen; //Coords de départ ds la source (src)
int y; int y;
int dy; int dy;
for(y=height;y!=0;y--) for(y = 0; y < height; y++)
// Pour chaque ligne // Pour chaque ligne
{ {
byte* dest = Get_Screen_pixel_ptr(0, y * ZOOMY);
// On fait une copie de la ligne // On fait une copie de la ligne
for (dy=width;dy>0;dy--) for (dy=width;dy>0;dy--)
{ {
@ -83,11 +97,10 @@ void Display_part_of_screen_wide2 (word width,word height,word image_width)
dest+=ZOOMX; dest+=ZOOMX;
} }
// On double la ligne qu'on vient de copier // On double la ligne qu'on vient de copier
memcpy(dest-width*ZOOMX+VIDEO_LINE_WIDTH,dest-width*ZOOMX,width*ZOOMX); memcpy(Get_Screen_pixel_ptr(0, y * ZOOMY + 1), Get_Screen_pixel_ptr(0, y * ZOOMY), width * ZOOMX);
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
//Update_rect(0,0,width,height); //Update_rect(0,0,width,height);
} }
@ -132,53 +145,74 @@ void Pixel_preview_magnifier_wide2 (word x,word y,byte color)
void Horizontal_XOR_line_wide2(word x_pos,word y_pos,word width) void Horizontal_XOR_line_wide2(word x_pos,word y_pos,word width)
{ {
//On calcule la valeur initiale de dest: //On calcule la valeur initiale de dest:
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; //byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels;
int x; int x;
for (x=0;x<width*ZOOMX;x+=ZOOMX) for (x=0;x<width*ZOOMX;x+=ZOOMX) {
*(dest+x+VIDEO_LINE_WIDTH+3)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+3)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)]; byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY)];
//*(dest+x+VIDEO_LINE_WIDTH+3)=*(dest+x+VIDEO_LINE_WIDTH+2)=*(dest+x+VIDEO_LINE_WIDTH+1)=*(dest+x+VIDEO_LINE_WIDTH)=*(dest+x+3)=*(dest+x+2)=*(dest+x+1)=*(dest+x)=xor_lut[*(dest+x)];
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + x, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 1, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 2, y_pos * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + x + 3, y_pos * ZOOMY + 1, color);
}
} }
void Vertical_XOR_line_wide2(word x_pos,word y_pos,word height) void Vertical_XOR_line_wide2(word x_pos,word y_pos,word height)
{ {
int i; int i;
byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; //byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY;
for (i=height;i>0;i--) for (i = 0; i < height; i++)
{ {
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*(dest)=xor_lut[*(dest)]; //*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*(dest)=xor_lut[*(dest)];
dest+=VIDEO_LINE_WIDTH*ZOOMY; //dest+=VIDEO_LINE_WIDTH*ZOOMY;
byte color = xor_lut[Get_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY)];
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY, color);
Set_Screen_pixel(x_pos * ZOOMX, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 1, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 2, (y_pos + i) * ZOOMY + 1, color);
Set_Screen_pixel(x_pos * ZOOMX + 3, (y_pos + i) * ZOOMY + 1, color);
} }
} }
void Display_brush_color_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_color_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = Brush + y_offset * brush_width + x_offset; byte* src = Brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
// Pour chaque pixel byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
// Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+VIDEO_LINE_WIDTH+3) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src; //*(dest+VIDEO_LINE_WIDTH+3) = *(dest+VIDEO_LINE_WIDTH+2) = *(dest+VIDEO_LINE_WIDTH+1) = *(dest+VIDEO_LINE_WIDTH) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
*(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -189,36 +223,40 @@ void Display_brush_mono_wide2(word x_pos, word y_pos,
byte transp_color, byte color, word brush_width) byte transp_color, byte color, word brush_width)
/* On affiche la brosse en monochrome */ /* On affiche la brosse en monochrome */
{ {
byte* dest=y_pos*ZOOMY*VIDEO_LINE_WIDTH+x_pos*ZOOMX+Screen_pixels; // dest = adr destination à // dest = adr destination à l'écran
// l'écran
byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds byte* src=brush_width*y_offset+x_offset+Brush; // src = adr ds
// la brosse // la brosse
int x,y; int x,y;
for(y=height;y!=0;y--) // Pour chaque ligne
//Pour chaque ligne for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
// Pour chaque pixel
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
if (*src!=transp_color) if (*src!=transp_color)
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=color; //*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=color;
*(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = color;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=brush_width-width; src+=brush_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
void Clear_brush_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width) void Clear_brush_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word image_width)
{ {
byte* dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //On va se mettre en 0,0 dans l'écran (dest) //On va se mettre en 0,0 dans l'écran (dest)
byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src) byte* src = ( y_pos + Main.offset_Y ) * image_width + x_pos + Main.offset_X + Main_screen; //Coords de départ ds la source (src)
int y; int y;
int x; int x;
@ -226,22 +264,27 @@ void Clear_brush_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word wi
(void)y_offset; // unused (void)y_offset; // unused
(void)transp_color; // unused (void)transp_color; // unused
for(y=height;y!=0;y--)
// Pour chaque ligne // Pour chaque ligne
for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
// Pour chaque pixel
for(x=width;x!=0;x--) for(x=width;x!=0;x--)
//Pour chaque pixel //Pour chaque pixel
{ {
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src; //*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
*(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
// On passe au pixel suivant // On passe au pixel suivant
src++; src++;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
src+=image_width-width; src+=image_width-width;
dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX; //dest+=VIDEO_LINE_WIDTH*ZOOMY-width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
} }
@ -250,30 +293,33 @@ void Clear_brush_wide2(word x_pos,word y_pos,word x_offset,word y_offset,word wi
void Display_brush_wide2(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width) void Display_brush_wide2(byte * brush, word x_pos,word y_pos,word x_offset,word y_offset,word width,word height,byte transp_color,word brush_width)
{ {
// dest = Position à l'écran // dest = Position à l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
// src = Position dans la brosse // src = Position dans la brosse
byte* src = brush + y_offset * brush_width + x_offset; byte* src = brush + y_offset * brush_width + x_offset;
word x,y; word x,y;
// Pour chaque ligne // Pour chaque ligne
for(y = height;y > 0; y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
// Pour chaque pixel
// Pour chaque pixel // Pour chaque pixel
for(x = width;x > 0; x--) for(x = width;x > 0; x--)
{ {
// On vérifie que ce n'est pas la transparence // On vérifie que ce n'est pas la transparence
if(*src != transp_color) if(*src != transp_color)
{ {
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src; //*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*src;
*(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *src;
} }
// Pixel suivant // Pixel suivant
src++; dest+=ZOOMX; src++; dest+=ZOOMX;
dest1+=ZOOMX;
} }
// On passe à la ligne suivante // On passe à la ligne suivante
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
src = src + brush_width - width; src = src + brush_width - width;
} }
} }
@ -281,21 +327,25 @@ void Display_brush_wide2(byte * brush, word x_pos,word y_pos,word x_offset,word
void Remap_screen_wide2(word x_pos,word y_pos,word width,word height,byte * conversion_table) void Remap_screen_wide2(word x_pos,word y_pos,word width,word height,byte * conversion_table)
{ {
// dest = coords a l'écran // dest = coords a l'écran
byte* dest = Screen_pixels + y_pos * ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
int x,y; int x,y;
// Pour chaque ligne // Pour chaque ligne
for(y=height;y>0;y--) for(y = 0; y < height; y++)
{ {
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, (y_pos + y) * ZOOMY + 1);
// Pour chaque pixel
// Pour chaque pixel // Pour chaque pixel
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest= //*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=
*(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest =
conversion_table[*dest]; conversion_table[*dest];
dest +=ZOOMX; dest +=ZOOMX;
dest1+=ZOOMX;
} }
dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX; //dest = dest + VIDEO_LINE_WIDTH*ZOOMY - width*ZOOMX;
} }
Update_rect(x_pos,y_pos,width,height); Update_rect(x_pos,y_pos,width,height);
@ -305,20 +355,24 @@ void Display_line_on_screen_fast_wide2(word x_pos,word y_pos,word width,byte * l
/* On affiche toute une ligne de pixels telle quelle. */ /* On affiche toute une ligne de pixels telle quelle. */
/* Utilisée si le buffer contient déja des pixel doublés. */ /* Utilisée si le buffer contient déja des pixel doublés. */
{ {
memcpy(Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH,line,width*ZOOMX); memcpy(Get_Screen_pixel_ptr(x_pos*ZOOMX, y_pos*ZOOMY), line, width*ZOOMX);
memcpy(Screen_pixels+x_pos*ZOOMX+(y_pos*ZOOMY+1)*VIDEO_LINE_WIDTH,line,width*ZOOMX); memcpy(Get_Screen_pixel_ptr(x_pos*ZOOMX, y_pos*ZOOMY+1), line, width*ZOOMX);
} }
void Display_line_on_screen_wide2(word x_pos,word y_pos,word width,byte * line) void Display_line_on_screen_wide2(word x_pos,word y_pos,word width,byte * line)
/* On affiche une ligne de pixels en les doublant. */ /* On affiche une ligne de pixels en les doublant. */
{ {
int x; int x;
byte *dest; //byte *dest;
dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH; //dest=Screen_pixels+x_pos*ZOOMX+y_pos*ZOOMY*VIDEO_LINE_WIDTH;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY);
byte* dest1 = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos * ZOOMY + 1);
for(x=width;x>0;x--) for(x=width;x>0;x--)
{ {
*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*line; //*(dest+VIDEO_LINE_WIDTH+3)=*(dest+VIDEO_LINE_WIDTH+2)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+3)=*(dest+2)=*(dest+1)=*dest=*line;
*(dest1+3) = *(dest1+2) = *(dest1+1) = *(dest1) = *(dest+3) = *(dest+2) = *(dest+1) = *dest = *line;
dest+=ZOOMX; dest+=ZOOMX;
dest1+=ZOOMX;
line++; line++;
} }
} }
@ -328,7 +382,8 @@ void Display_transparent_mono_line_on_screen_wide2(
// Affiche une ligne à l'écran avec une couleur + transparence. // Affiche une ligne à l'écran avec une couleur + transparence.
// Utilisé par les brosses en mode zoom // Utilisé par les brosses en mode zoom
{ {
byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX; //byte* dest = Screen_pixels+ y_pos*VIDEO_LINE_WIDTH + x_pos*ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y_pos);
int x; int x;
// Pour chaque pixel // Pour chaque pixel
for(x=0;x<width;x++) for(x=0;x<width;x++)
@ -344,7 +399,8 @@ void Display_transparent_mono_line_on_screen_wide2(
void Read_line_screen_wide2(word x_pos,word y_pos,word width,byte * line) void Read_line_screen_wide2(word x_pos,word y_pos,word width,byte * line)
{ {
memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX); //memcpy(line,VIDEO_LINE_WIDTH*ZOOMY * y_pos + x_pos * ZOOMX + Screen_pixels,width*ZOOMX);
memcpy(line, Get_Screen_pixel_ptr(x_pos * ZOOMX, ZOOMY * y_pos), width*ZOOMX);
} }
void Display_part_of_screen_scaled_wide2( void Display_part_of_screen_scaled_wide2(
@ -409,7 +465,8 @@ void Display_brush_color_zoom_wide2(word x_pos,word y_pos,
for(bx=Main.magnifier_factor;bx>0;bx--) for(bx=Main.magnifier_factor;bx>0;bx--)
{ {
byte* line_src = buffer; byte* line_src = buffer;
byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX; //byte* dest = Screen_pixels + y*ZOOMY * VIDEO_LINE_WIDTH + x_pos * ZOOMX;
byte* dest = Get_Screen_pixel_ptr(x_pos * ZOOMX, y*ZOOMY);
word x; word x;
// Pour chaque pixel de la ligne // Pour chaque pixel de la ligne
for(x = width*Main.magnifier_factor;x > 0;x--) for(x = width*Main.magnifier_factor;x > 0;x--)
@ -422,7 +479,8 @@ void Display_brush_color_zoom_wide2(word x_pos,word y_pos,
dest+=ZOOMX; dest+=ZOOMX;
} }
// Double the line // Double the line
memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor); //memcpy(Screen_pixels + (y*ZOOMY+1)*VIDEO_LINE_WIDTH + x_pos*ZOOMX, Screen_pixels + y*ZOOMY*VIDEO_LINE_WIDTH + x_pos*ZOOMX, width*ZOOMX*Main.magnifier_factor);
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);
y++; y++;
if(y==end_y_pos) if(y==end_y_pos)
{ {

View File

@ -64,8 +64,50 @@
#endif #endif
#endif #endif
static SDL_Surface * Screen_SDL = NULL;
volatile int Allow_colorcycling=1; volatile int Allow_colorcycling=1;
byte Get_Screen_pixel(int x, int y)
{
if (y < 0 || x < 0 || y >= Screen_SDL->h || x >= Screen_SDL->w)
{
Warning("Get_Screen_pixel() coordinates out of bound");
return 0;
}
return ((byte *)Screen_SDL->pixels)[x + y*(Screen_SDL->pitch)];
}
void Set_Screen_pixel(int x, int y, byte value)
{
if (y < 0 || x < 0 || y >= Screen_SDL->h || x >= Screen_SDL->w)
{
Warning("Set_Screen_pixel() coordinates out of bound");
return;
}
((byte *)Screen_SDL->pixels)[x + y*(Screen_SDL->pitch)] = value;
}
byte* Get_Screen_pixel_ptr(int x, int y)
{
if (y < 0 || x < 0 || y >= Screen_SDL->h || x >= Screen_SDL->w)
{
Warning("Get_Screen_pixel_ptr() coordinates out of bound");
return NULL;
}
return (byte *)Screen_SDL->pixels + x + y*(Screen_SDL->pitch);
}
void Screen_FillRect(int x, int y, int w, int h, byte color)
{
SDL_Rect rectangle;
rectangle.x = x;
rectangle.y = y;
rectangle.w = w;
rectangle.h = h;
SDL_FillRect(Screen_SDL,&rectangle,color);
}
/// Sets the new screen/window dimensions. /// Sets the new screen/window dimensions.
void Set_mode_SDL(int *width, int *height, int fullscreen) void Set_mode_SDL(int *width, int *height, int fullscreen)
{ {
@ -86,7 +128,7 @@ void Set_mode_SDL(int *width, int *height, int fullscreen)
*width = Screen_SDL->w; *width = Screen_SDL->w;
*height = Screen_SDL->h; *height = Screen_SDL->h;
} }
Screen_pixels=Screen_SDL->pixels; //Screen_pixels=Screen_SDL->pixels;
} }
else else
{ {
@ -321,6 +363,19 @@ void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette)
} }
int SetPalette(const T_Components * colors, int firstcolor, int ncolors)
{
int i;
SDL_Color PaletteSDL[256];
for (i = 0; i < ncolors; i++) {
PaletteSDL[i].r = colors[i].R;
PaletteSDL[i].g = colors[i].G;
PaletteSDL[i].b = colors[i].B;
}
return SDL_SetPalette(Screen_SDL, SDL_PHYSPAL | SDL_LOGPAL, PaletteSDL, firstcolor, ncolors);
}
void Clear_border(byte color) void Clear_border(byte color)
{ {
int width; int width;

View File

@ -2,6 +2,7 @@
*/ */
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2018 Thomas Bernard
Copyright 2008 Yves Rizoud Copyright 2008 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
@ -32,16 +33,17 @@
#include "struct.h" #include "struct.h"
#include "global.h" #include "global.h"
///
/// This is the number of bytes in a video line for the current mode.
/// On many platforms it will be the video mode's width (in pixels), rounded up
/// to be a multiple of 4.
#define VIDEO_LINE_WIDTH (Screen_SDL->pitch)
void Set_mode_SDL(int *,int *,int); void Set_mode_SDL(int *,int *,int);
GFX2_GLOBAL SDL_Rect ** List_SDL_video_modes; GFX2_GLOBAL SDL_Rect ** List_SDL_video_modes;
GFX2_GLOBAL byte* Screen_pixels;
byte Get_Screen_pixel(int x, int y);
void Set_Screen_pixel(int x, int y, byte value);
byte* Get_Screen_pixel_ptr(int x, int y);
void Screen_FillRect(int x, int y, int w, int h, byte color);
void Update_rect(short x, short y, unsigned short width, unsigned short height); void Update_rect(short x, short y, unsigned short width, unsigned short height);
void Flush_update(void); void Flush_update(void);
@ -64,6 +66,8 @@ void Set_SDL_pixel_8(SDL_Surface *bmp, int x, int y, byte color);
/// Convert a SDL Palette to a grafx2 palette /// Convert a SDL Palette to a grafx2 palette
void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette); void Get_SDL_Palette(const SDL_Palette * sdl_palette, T_Palette palette);
int SetPalette(const T_Components * colors, int firstcolor, int ncolors);
/// ///
/// Clears the parts of screen that are outside of the editing area. /// Clears the parts of screen that are outside of the editing area.
/// There is such area only if the screen mode is not a multiple of the pixel /// There is such area only if the screen mode is not a multiple of the pixel