diff --git a/src/global.h b/src/global.h index 8d3e8794..3e36627a 100644 --- a/src/global.h +++ b/src/global.h @@ -291,8 +291,7 @@ GFX2_GLOBAL int Pixel_width; GFX2_GLOBAL int Pixel_height; -// -- Current image data - +/// Current image data GFX2_GLOBAL T_Document Main; /// Pointer to the pixel data of the main image @@ -300,8 +299,7 @@ GFX2_GLOBAL byte * Main_screen; /// Lookup table for XOR effects, pointing each color to the most different one GFX2_GLOBAL byte xor_lut[256]; -// -- Spare page data - +/// Spare page data GFX2_GLOBAL T_Document Spare; // -- Image backups diff --git a/src/graph.c b/src/graph.c index 075e7e64..6f13f93f 100644 --- a/src/graph.c +++ b/src/graph.c @@ -3502,18 +3502,32 @@ static void Pixel_in_screen_overlay_with_opt_preview(word x,word y,byte color,in Func_pixel_opt_preview Pixel_in_current_screen_with_opt_preview=Pixel_in_screen_direct_with_opt_preview; +/** + * Put a pixel in the current layer of a "Document" + * + * @param doc pointer to either @ref Main or @ref Spare + * @param x x coordinate of the pixel to put + * @param y y coordinate of the pixel to put + * @param color the new color for the pixel + */ +void Pixel_in_document_current_layer(T_Document * doc, word x, word y, byte color) +{ + doc->backups->Pages->Image[doc->current_layer].Pixels[x + y*doc->image_width] = color; +} + void Pixel_in_spare(word x,word y, byte color) { - *((y)*Spare.image_width+(x)+Spare.backups->Pages->Image[Spare.current_layer].Pixels)=color; + Pixel_in_document_current_layer(&Spare, x, y, color); } void Pixel_in_current_layer(word x,word y, byte color) { - *((y)*Main.image_width+(x)+Main.backups->Pages->Image[Main.current_layer].Pixels)=color; + Pixel_in_document_current_layer(&Main, x, y, color); } byte Read_pixel_from_current_layer(word x,word y) { + // return Main.backups->Pages->Image[Main.current_layer].Pixels[x + y*Main.image_width]; return *((y)*Main.image_width+(x)+Main.backups->Pages->Image[Main.current_layer].Pixels); }