EGX mode for CPC
In this custom mode, odd lines use MODE 0 (wide pixels, 16 colors), and even lines use MODE 1 (square pixels, 4 colors). - Add a settings window to the 8-bit effect where you can chose what you want to draw - Add the customizations required to make it work in graph.c - Tweak some other places so it is easier to add other modes later on. - Groundwork for some more modes: EGX2, ZX spectrum, Game Boy color.
This commit is contained in:
parent
f04691145b
commit
aef77744e1
@ -506,9 +506,8 @@ void Button_Toggle_toolbar(void)
|
|||||||
|
|
||||||
Window_dropdown_add_item(&dropdown, 0, menu_name_tools);
|
Window_dropdown_add_item(&dropdown, 0, menu_name_tools);
|
||||||
|
|
||||||
if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED ||
|
if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION ||
|
||||||
Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5 ||
|
Main_backups->Pages->Nb_layers==1)
|
||||||
(Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION && Main_backups->Pages->Nb_layers==1))
|
|
||||||
Window_dropdown_add_item(&dropdown, 1, menu_name_layers);
|
Window_dropdown_add_item(&dropdown, 1, menu_name_layers);
|
||||||
|
|
||||||
if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION ||
|
if (Main_backups->Pages->Image_mode == IMAGE_MODE_ANIMATION ||
|
||||||
@ -544,7 +543,7 @@ void Button_Toggle_toolbar(void)
|
|||||||
}
|
}
|
||||||
Set_bar_visibility(MENUBAR_ANIMATION, !Menu_bars[MENUBAR_ANIMATION].Visible, 0);
|
Set_bar_visibility(MENUBAR_ANIMATION, !Menu_bars[MENUBAR_ANIMATION].Visible, 0);
|
||||||
|
|
||||||
if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED)
|
if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION)
|
||||||
Switch_layer_mode(IMAGE_MODE_ANIMATION);
|
Switch_layer_mode(IMAGE_MODE_ANIMATION);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -4860,10 +4859,10 @@ void Button_Effects(void)
|
|||||||
Display_effect_state(C2,L4, "8 bit" ,Main_backups->Pages->Image_mode > IMAGE_MODE_ANIMATION);
|
Display_effect_state(C2,L4, "8 bit" ,Main_backups->Pages->Image_mode > IMAGE_MODE_ANIMATION);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
} else {
|
} else {
|
||||||
//Close_window();
|
Close_window();
|
||||||
//Display_cursor();
|
Display_cursor();
|
||||||
// Contraint checker/enforcer menu
|
Button_Constraint_menu();
|
||||||
//clicked_button = 11;
|
clicked_button = 11;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 15: // Tilemap
|
case 15: // Tilemap
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||||
|
|
||||||
Copyright 2008 Yves Rizoud
|
Copyright 2008 Yves Rizoud
|
||||||
Copyright 2007 Adrien Destugues
|
Copyright 2007-2017 Adrien Destugues
|
||||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||||
|
|
||||||
Grafx2 is free software; you can redistribute it and/or
|
Grafx2 is free software; you can redistribute it and/or
|
||||||
@ -163,41 +163,84 @@ void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_ca
|
|||||||
Display_cursor();
|
Display_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte Selected_Constraint_Mode = 0;
|
||||||
|
|
||||||
// Constaint enforcer/checker ------------------------------------------------
|
// Constaint enforcer/checker ------------------------------------------------
|
||||||
void Button_Constraint_mode(void)
|
void Button_Constraint_mode()
|
||||||
{
|
{
|
||||||
int pixel;
|
int pixel;
|
||||||
|
|
||||||
if (Main_backups->Pages->Image_mode == IMAGE_MODE_MODE5)
|
if (Main_backups->Pages->Image_mode >= IMAGE_MODE_MODE5)
|
||||||
{
|
{
|
||||||
// Disable
|
// Disable
|
||||||
Switch_layer_mode(IMAGE_MODE_LAYERED);
|
Switch_layer_mode(IMAGE_MODE_LAYERED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Main_backups->Pages->Image_mode != IMAGE_MODE_LAYERED ||
|
|
||||||
Main_backups->Pages->Nb_layers!=5 || (Main_image_width%48))
|
if (Selected_Constraint_Mode < IMAGE_MODE_MODE5)
|
||||||
|
Selected_Constraint_Mode = IMAGE_MODE_EGX;
|
||||||
|
|
||||||
|
if (Selected_Constraint_Mode == IMAGE_MODE_MODE5)
|
||||||
{
|
{
|
||||||
Verbose_message("Error!", "This emulation of Amstrad CPC's Mode5 can only be used on a 5-layer image whose width is a multiple of 48.");
|
if (Main_backups->Pages->Image_mode != IMAGE_MODE_LAYERED ||
|
||||||
return;
|
Main_backups->Pages->Nb_layers!=5 || (Main_image_width%48))
|
||||||
}
|
|
||||||
for (pixel=0; pixel < Main_image_width*Main_image_height; pixel++)
|
|
||||||
{
|
|
||||||
if (Main_backups->Pages->Image[4].Pixels[pixel]>3)
|
|
||||||
{
|
{
|
||||||
Verbose_message("Error!", "This emulation of Amstrad CPC's Mode5 needs all pixels of layer 5 to use colors 0-3.");
|
Verbose_message("Error!", "This emulation of Amstrad CPC's Mode5 can only be used on a 5-layer image whose width is a multiple of 48.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
for (pixel=0; pixel < Main_image_width*Main_image_height; pixel++)
|
||||||
|
{
|
||||||
|
if (Main_backups->Pages->Image[4].Pixels[pixel]>3)
|
||||||
|
{
|
||||||
|
Verbose_message("Error!", "This emulation of Amstrad CPC's Mode5 needs all pixels of layer 5 to use colors 0-3.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO set the palette to a CPC one ?
|
||||||
}
|
}
|
||||||
// TODO backup
|
|
||||||
Switch_layer_mode(IMAGE_MODE_MODE5);
|
// TODO backup
|
||||||
// TODO set the palette to a CPC one ?
|
Switch_layer_mode(Selected_Constraint_Mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Button_Constraint_menu(void)
|
void Button_Constraint_menu(void)
|
||||||
{
|
{
|
||||||
|
short clicked_button;
|
||||||
|
T_Dropdown_button* dropdown;
|
||||||
|
|
||||||
|
Open_window(154,79,"8-bit constraints");
|
||||||
|
|
||||||
|
Window_set_normal_button(21,55,51,14,"Cancel",0,1,KEY_ESC); // 1
|
||||||
|
Window_set_normal_button(82,55,51,14,"OK" ,0,1,SDLK_RETURN); // 2
|
||||||
|
|
||||||
|
dropdown = Window_set_dropdown_button(17, 21, 120, 14, 120, "Constraints", 1, 0, 1, RIGHT_SIDE|LEFT_SIDE, 0); // 3
|
||||||
|
//Window_dropdown_add_item(dropdown, IMAGE_MODE_ZX, "ZX Spectrum");
|
||||||
|
//Window_dropdown_add_item(dropdown, IMAGE_MODE_GBC, "Game Boy Color");
|
||||||
|
Window_dropdown_add_item(dropdown, IMAGE_MODE_EGX, "EGX (CPC)");
|
||||||
|
//Window_dropdown_add_item(dropdown, IMAGE_MODE_EGX2, "EGX2 (CPC)");
|
||||||
|
Window_dropdown_add_item(dropdown, IMAGE_MODE_MODE5, "Mode 5 (CPC)");
|
||||||
|
|
||||||
|
Update_window_area(0,0,Window_width, Window_height);
|
||||||
|
Display_cursor();
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
clicked_button=Window_clicked_button();
|
||||||
|
|
||||||
|
if (clicked_button == 3)
|
||||||
|
Selected_Constraint_Mode = Window_attribute2;
|
||||||
|
}
|
||||||
|
while ( (clicked_button!=1) && (clicked_button!=2) );
|
||||||
|
|
||||||
|
Close_window();
|
||||||
|
|
||||||
|
if (clicked_button==2) // OK
|
||||||
|
{
|
||||||
|
Button_Constraint_mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
Display_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tilemap mode
|
// Tilemap mode
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
Copyright 2014 Sergii Pylypenko
|
Copyright 2014 Sergii Pylypenko
|
||||||
Copyright 2008 Yves Rizoud
|
Copyright 2008 Yves Rizoud
|
||||||
Copyright 2007 Adrien Destugues
|
Copyright 2007-2017 Adrien Destugues
|
||||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||||
|
|
||||||
Grafx2 is free software; you can redistribute it and/or
|
Grafx2 is free software; you can redistribute it and/or
|
||||||
@ -589,6 +589,10 @@ enum IMAGE_MODES
|
|||||||
{
|
{
|
||||||
IMAGE_MODE_LAYERED=0, ///< Layered image
|
IMAGE_MODE_LAYERED=0, ///< Layered image
|
||||||
IMAGE_MODE_ANIMATION, ///< Animation
|
IMAGE_MODE_ANIMATION, ///< Animation
|
||||||
|
IMAGE_MODE_ZX, ///< ZX Spectrum (note "SPECTRUM" is kept for later... Spectrum 512 anyone?)
|
||||||
|
IMAGE_MODE_GBC, ///< Game Boy Color
|
||||||
|
IMAGE_MODE_EGX, ///< CPC EGX
|
||||||
|
IMAGE_MODE_EGX2, ///< CPC EGX2
|
||||||
IMAGE_MODE_MODE5, ///< CPC mode 5
|
IMAGE_MODE_MODE5, ///< CPC mode 5
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
31
src/graph.c
31
src/graph.c
@ -3003,6 +3003,28 @@ void Pixel_in_screen_layered_with_preview(word x,word y,byte color)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Pixel_in_screen_egx(word x,word y,byte color)
|
||||||
|
{
|
||||||
|
if (y & 1)
|
||||||
|
{
|
||||||
|
Pixel_in_screen_layered(x & ~1,y,color);
|
||||||
|
Pixel_in_screen_layered(x | 1,y,color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Pixel_in_screen_layered(x,y,color & 0xF3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pixel_in_screen_egx_with_preview(word x,word y,byte color)
|
||||||
|
{
|
||||||
|
if (y & 1)
|
||||||
|
{
|
||||||
|
Pixel_in_screen_layered_with_preview(x & ~1,y,color);
|
||||||
|
Pixel_in_screen_layered_with_preview(x | 1,y,color);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Pixel_in_screen_layered_with_preview(x,y,color & 0xF3);
|
||||||
|
}
|
||||||
|
|
||||||
/// Paint a a single pixel in image only : in a layer under one that acts as a layer-selector (mode 5).
|
/// Paint a a single pixel in image only : in a layer under one that acts as a layer-selector (mode 5).
|
||||||
void Pixel_in_screen_underlay(word x,word y,byte color)
|
void Pixel_in_screen_underlay(word x,word y,byte color)
|
||||||
{
|
{
|
||||||
@ -3108,6 +3130,13 @@ void Update_pixel_renderer(void)
|
|||||||
Pixel_in_current_screen = Pixel_in_screen_layered;
|
Pixel_in_current_screen = Pixel_in_screen_layered;
|
||||||
Pixel_in_current_screen_with_preview = Pixel_in_screen_layered_with_preview;
|
Pixel_in_current_screen_with_preview = Pixel_in_screen_layered_with_preview;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
if (Main_backups->Pages->Image_mode == IMAGE_MODE_EGX)
|
||||||
|
{
|
||||||
|
// layered
|
||||||
|
Pixel_in_current_screen = Pixel_in_screen_egx;
|
||||||
|
Pixel_in_current_screen_with_preview = Pixel_in_screen_egx_with_preview;
|
||||||
|
}
|
||||||
// Implicit else : Image_mode must be IMAGE_MODE_MODE5
|
// Implicit else : Image_mode must be IMAGE_MODE_MODE5
|
||||||
else if ( Main_current_layer == 4)
|
else if ( Main_current_layer == 4)
|
||||||
{
|
{
|
||||||
@ -3123,7 +3152,7 @@ void Update_pixel_renderer(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// layered (again)
|
// layered (again, for layers > 4 in MODE5)
|
||||||
Pixel_in_current_screen = Pixel_in_screen_layered;
|
Pixel_in_current_screen = Pixel_in_screen_layered;
|
||||||
Pixel_in_current_screen_with_preview = Pixel_in_screen_layered_with_preview;
|
Pixel_in_current_screen_with_preview = Pixel_in_screen_layered_with_preview;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||||
|
|
||||||
Copyright 2008 Franck Charlet
|
Copyright 2008 Franck Charlet
|
||||||
Copyright 2007 Adrien Destugues
|
Copyright 2007-2017 Adrien Destugues
|
||||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||||
|
|
||||||
Grafx2 is free software; you can redistribute it and/or
|
Grafx2 is free software; you can redistribute it and/or
|
||||||
@ -1531,6 +1531,7 @@ void Switch_layer_mode(enum IMAGE_MODES new_mode)
|
|||||||
{
|
{
|
||||||
case IMAGE_MODE_MODE5:
|
case IMAGE_MODE_MODE5:
|
||||||
case IMAGE_MODE_LAYERED:
|
case IMAGE_MODE_LAYERED:
|
||||||
|
default:
|
||||||
Update_buffers(Main_image_width, Main_image_height);
|
Update_buffers(Main_image_width, Main_image_height);
|
||||||
Redraw_layered_image();
|
Redraw_layered_image();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
*/
|
*/
|
||||||
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
/* Grafx2 - The Ultimate 256-color bitmap paint program
|
||||||
|
|
||||||
Copyright 2007 Adrien Destugues
|
Copyright 2007-2017 Adrien Destugues
|
||||||
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
|
||||||
|
|
||||||
Grafx2 is free software; you can redistribute it and/or
|
Grafx2 is free software; you can redistribute it and/or
|
||||||
@ -344,7 +344,8 @@ void Remap_image_highlevel(byte * conversion_table)
|
|||||||
int layer;
|
int layer;
|
||||||
|
|
||||||
// Remap the flatenned image view
|
// Remap the flatenned image view
|
||||||
if (Main_backups->Pages->Image_mode == IMAGE_MODE_LAYERED)
|
if (Main_backups->Pages->Image_mode != IMAGE_MODE_ANIMATION
|
||||||
|
&& Main_backups->Pages->Image_mode != IMAGE_MODE_MODE5)
|
||||||
{
|
{
|
||||||
Remap_general_lowlevel(conversion_table,Main_visible_image.Image,Main_visible_image.Image,
|
Remap_general_lowlevel(conversion_table,Main_visible_image.Image,Main_visible_image.Image,
|
||||||
Main_image_width,Main_image_height,Main_image_width);
|
Main_image_width,Main_image_height,Main_image_width);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user