diff --git a/src/buttons_effects.c b/src/buttons_effects.c index dcb336e9..be444522 100644 --- a/src/buttons_effects.c +++ b/src/buttons_effects.c @@ -368,6 +368,8 @@ void Button_Constraint_menu(void) {IMAGE_MODE_C64HIRES,"C64 HiRes", "2 colors per 8x8 block", 1}, // 320x200 {IMAGE_MODE_C64MULTI,"C64 Multicolor","4 colors per 4x1 block", 1}, // 160x200 //{IMAGE_MODE_C64FLI, "C64 FLI", "improved multicolor ", 1}, // 160x200 + {IMAGE_MODE_HGR, "Apple II HGR", "6 colors ", 1}, // 280x192 + //{IMAGE_MODE_DHGR, "Apple II DHGR", "16 colors ", 1}, // 560x192 }; Open_window(194,95+36,"8-bit constraints"); @@ -483,6 +485,15 @@ void Button_Constraint_menu(void) End_of_modification(); /// @todo enable WIDE pixels when switching to 160x200 break; + case IMAGE_MODE_HGR: + Resize_image(280, 192); + End_of_modification(); + break; + case IMAGE_MODE_DHGR: + Resize_image(560, 192); + End_of_modification(); + /// @todo enable TALL pixels when switching to 560x192 + break; default: break; } @@ -510,6 +521,11 @@ void Button_Constraint_menu(void) Snap_width = 8; Snap_height = 999; // maximum value (3 digits) break; + case IMAGE_MODE_HGR: + case IMAGE_MODE_DHGR: + Snap_width = 7; + Snap_height = 999; // maximum value (3 digits) + break; default: set_grid = 0; } @@ -613,6 +629,20 @@ void Button_Constraint_menu(void) Fore_color = 1; Back_color = 0; break; + case IMAGE_MODE_HGR: + memset(Main.palette, 0, sizeof(T_Palette)); + HGR_set_palette(Main.palette); + First_color_in_palette = 0; + Fore_color = 3; + Back_color = 0; + break; + case IMAGE_MODE_DHGR: + memset(Main.palette, 0, sizeof(T_Palette)); + DHGR_set_palette(Main.palette); + First_color_in_palette = 0; + Fore_color = 15; + Back_color = 0; + break; default: break; } diff --git a/src/const.h b/src/const.h index 6c7903ae..4bc2a066 100644 --- a/src/const.h +++ b/src/const.h @@ -622,6 +622,8 @@ enum IMAGE_MODES IMAGE_MODE_C64HIRES, ///< C64 HiRes IMAGE_MODE_C64MULTI, ///< C64 Multicolor IMAGE_MODE_C64FLI, ///< C64 Flexible Line Interpretation + IMAGE_MODE_HGR, ///< Apple 2 HGR + IMAGE_MODE_DHGR, ///< Apple 2 DHGR }; /// Circle / Ellipse Modes diff --git a/src/graph.c b/src/graph.c index 55599c43..9ec75fe5 100644 --- a/src/graph.c +++ b/src/graph.c @@ -3256,6 +3256,25 @@ static void Pixel_in_screen_layered_with_opt_preview(word x,word y,byte color, i } } +/// Paint in a specific layer and update optionnaly the screen +static void Pixel_in_layer_with_opt_preview(int layer, word x,word y,byte color, int preview) +{ + byte depth = *(Main_visible_image_depth_buffer.Image+x+y*Main.image_width); + + Pixel_in_layer(layer, x, y, color); + // if (depth > layer) => another layer hides this one + if (depth <= layer && ((1 << layer) & Main.layers_visible)) + { + if (color == Main.backups->Pages->Transparent_color) // transparent color + // fetch pixel color from the topmost visible layer + color = Read_pixel_from_layer(depth, x, y); + + Main_screen[x+y*Main.image_width]=color; + + if (preview) + Pixel_preview(x,y,color); + } +} /// @defgroup constraints Special constaints drawing modes /// For 8bits machines modes (ZX Spectrum, C64, etc.) @@ -3657,6 +3676,7 @@ void Update_pixel_renderer(void) // direct Pixel_in_current_screen_with_opt_preview = Pixel_in_screen_direct_with_opt_preview; break; + case IMAGE_MODE_DHGR: // TODO case IMAGE_MODE_LAYERED: // layered Pixel_in_current_screen_with_opt_preview = Pixel_in_screen_layered_with_opt_preview; @@ -3688,5 +3708,13 @@ void Update_pixel_renderer(void) else // layered (again, for layers > 4 in MODE5 and RASTER) Pixel_in_current_screen_with_opt_preview = Pixel_in_screen_layered_with_opt_preview; break; + case IMAGE_MODE_HGR: + if (Main.current_layer == 0) // monochrome layer + Pixel_in_current_screen_with_opt_preview = Pixel_in_screen_hgr_mono_with_opt_preview; + else if (Main.current_layer == 1) // color layer + Pixel_in_current_screen_with_opt_preview = Pixel_in_screen_hgr_color_with_opt_preview; + else + Pixel_in_current_screen_with_opt_preview = Pixel_in_screen_layered_with_opt_preview; + break; } }