From 07f6df5f5bed8056e71d0a4316476c992846fbda Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 17 Jun 2020 13:36:18 -0700 Subject: [PATCH 1/3] New Church is now a new building type, placement editor can now render 32bit images. --- code/CMakeLists.txt | 2 +- code/REDALERT/BDATA.CPP | 31 ++++++++++++---- code/REDALERT/BDATA_AF.H | 34 ++++++++++++++++++ code/REDALERT/DEFINES.H | 3 ++ .../v01.sno.png => textures/afv01.sno.png | Bin 5 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 code/REDALERT/BDATA_AF.H rename examples/textures/v01.sno.png => textures/afv01.sno.png (100%) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index a8fa477..4bfc44d 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -709,7 +709,7 @@ set(src_external ) -add_definitions(-DCHEAT_KEYS -DIMGUI_IMPL_OPENGL_LOADER_GLEW -DSCENARIO_EDITOR -DWINDOWS_IGNORE_PACKING_MISMATCH -DTRUE_FALSE_DEFINED -DWIN32 -DWINDOWS -DENGLISH -D_USRDLL -DREDALERT_EXPORTS) +add_definitions(-D RA_AF -DCHEAT_KEYS -DIMGUI_IMPL_OPENGL_LOADER_GLEW -DSCENARIO_EDITOR -DWINDOWS_IGNORE_PACKING_MISMATCH -DTRUE_FALSE_DEFINED -DWIN32 -DWINDOWS -DENGLISH -D_USRDLL -DREDALERT_EXPORTS) add_compile_options(/permissive+ /Zc:forScope- /Zp1) add_executable(RedAlert ${src_win32lib} ${src_redalert} ${src_external}) diff --git a/code/REDALERT/BDATA.CPP b/code/REDALERT/BDATA.CPP index 9edc7f4..2aa0319 100644 --- a/code/REDALERT/BDATA.CPP +++ b/code/REDALERT/BDATA.CPP @@ -142,6 +142,9 @@ static short const OComList[] = {1, REFRESH_EOL}; static short const OList12[] = {0, REFRESH_EOL}; static short const OListTmpl[] = {0, 1, 2, REFRESH_EOL}; +#ifdef RA_AF +#include "BDATA_AF.H" +#endif /*************************************************************************** */ @@ -3026,6 +3029,9 @@ void BuildingTypeClass::Init_Heap(void) new BuildingTypeClass(ClassLarva2); // STRUCT_LARVA2 #endif +#ifdef RA_AF + new BuildingTypeClass(ClassAFV01); // STRUCT_AFV01 +#endif } @@ -3206,13 +3212,24 @@ StructType BuildingTypeClass::From_Name(char const * name) *=============================================================================================*/ void BuildingTypeClass::Display(int x, int y, WindowNumberType window, HousesType ) const { - void const * ptr = Get_Cameo_Data(); - if (ptr == NULL) { - IsTheaterShape = IsTheater; - ptr = Get_Image_Data(); +// jmarshall - hd buildings. + Image_t* hdimage = Get_HDImage_Data(); + if (hdimage != NULL) { + //CC_Draw_Shape((Image_t *)Get_HDImage_Data(), 0, x, y, window, SHAPE_CENTER | SHAPE_WIN_REL, NULL, NULL, DIR_N); + x += WindowList[window][WINDOWX]; + y += WindowList[window][WINDOWY]; + GL_RenderImage(hdimage, x, y, hdimage->width, hdimage->height); } - CC_Draw_Shape(ptr, 0, x, y, window, SHAPE_CENTER|SHAPE_WIN_REL); - IsTheaterShape = false; + else { + void const* ptr = Get_Cameo_Data(); + if (ptr == NULL) { + IsTheaterShape = IsTheater; + ptr = Get_Image_Data(); + } + CC_Draw_Shape(ptr, 0, x, y, window, SHAPE_CENTER | SHAPE_WIN_REL); + IsTheaterShape = false; + } +// jmarshall end } @@ -3235,7 +3252,7 @@ void BuildingTypeClass::Display(int x, int y, WindowNumberType window, HousesTyp void BuildingTypeClass::Prep_For_Add(void) { for (StructType index = STRUCT_FIRST; index < STRUCT_COUNT; index++) { - if (As_Reference(index).Get_Image_Data()) { + if (As_Reference(index).Get_Image_Data() || As_Reference(index).Get_HDImage_Data()) { Map.Add_To_List(&As_Reference(index)); } } diff --git a/code/REDALERT/BDATA_AF.H b/code/REDALERT/BDATA_AF.H new file mode 100644 index 0000000..e99510e --- /dev/null +++ b/code/REDALERT/BDATA_AF.H @@ -0,0 +1,34 @@ +// BDAD_AF.H +// + +// Building Data for Red Alert Allied Force. + +static BuildingTypeClass const ClassAFV01( + STRUCT_AFV01, + TXT_CIV1, // NAME: Short name of the structure. + "afV01", // NAME: Short name of the structure. + FACING_S, // Foundation direction from center of building. + XYP_COORD(0, 0), // Exit point for produced units. + REMAP_ALTERNATE, // Sidebar remap logic. + 0x0000, // Vertical offset. + 0x0000, // Primary weapon offset along turret centerline. + 0x0000, // Primary weapon lateral offset along turret centerline. + false, // Is this building a fake (decoy?) + true, // Animation rate is regulated for constant speed? + true, // Always use the given name for the building? + false, // Is this a wall type structure? + true, // Simple (one frame) damage imagery? + true, // Is it invisible to radar? + true, // Can the player select this? + true, // Is this a legal target for attack or move? + true, // Is this an insignificant building? + true, // Theater specific graphic image? + false, // Does it have a rotating turret? + false, // Can the building be color remapped to indicate owner? + RTTI_NONE, // The object type produced at this factory. + DIR_N, // Starting idle frame to match construction. + BSIZE_22, // SIZE: Building size. + NULL, // Preferred exit cell list. + (short const*)List0011, // OCCUPYLIST: List of active foundation squares. + (short const*)List1100 // OVERLAPLIST:List of overlap cell offset. +); \ No newline at end of file diff --git a/code/REDALERT/DEFINES.H b/code/REDALERT/DEFINES.H index d70a67e..cb64fe5 100644 --- a/code/REDALERT/DEFINES.H +++ b/code/REDALERT/DEFINES.H @@ -1472,6 +1472,9 @@ typedef enum StructType : char { STRUCT_LARVA2, #endif +#ifdef RA_AF + STRUCT_AFV01, +#endif STRUCT_COUNT, STRUCT_FIRST=0 } StructType; diff --git a/examples/textures/v01.sno.png b/textures/afv01.sno.png similarity index 100% rename from examples/textures/v01.sno.png rename to textures/afv01.sno.png From ad91794bb2a8b58ff90571b3014fe8eb15cb7676 Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 17 Jun 2020 13:37:07 -0700 Subject: [PATCH 2/3] Removed examples folder. --- examples/readme.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 examples/readme.txt diff --git a/examples/readme.txt b/examples/readme.txt deleted file mode 100644 index 26f164e..0000000 --- a/examples/readme.txt +++ /dev/null @@ -1 +0,0 @@ -To see HD textures in action, move the textures folder out of the examples folder. \ No newline at end of file From df88871b1354c001ec7b6d707ca91d0f3a76f74e Mon Sep 17 00:00:00 2001 From: Justin Marshall Date: Wed, 17 Jun 2020 17:08:45 -0700 Subject: [PATCH 3/3] Added 8bit image upload code. --- code/REDALERT/Image.h | 3 ++- code/REDALERT/WINSTUB.CPP | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/code/REDALERT/Image.h b/code/REDALERT/Image.h index 6028300..57b88bf 100644 --- a/code/REDALERT/Image.h +++ b/code/REDALERT/Image.h @@ -23,4 +23,5 @@ __forceinline Image_t::~Image_t() { } } -Image_t* Image_LoadImage(const char* name); \ No newline at end of file +Image_t* Image_LoadImage(const char* name); +Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, char* data); \ No newline at end of file diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index 6e4fbf7..e9dbb29 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -144,6 +144,50 @@ Image_t* Image_LoadImage(const char* name) { return image; } +Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, char *data) { + // Check to see if the image is already loaded. + for (int i = 0; i < loaded_images.size(); i++) { + if (!strcmp(loaded_images[i]->name, name)) { + return loaded_images[i]; + } + } + + Image_t* image = new Image_t(); + image->buffer = new unsigned char[Width * Height * 4]; + + for (int i = 0; i < Width * Height; i++) { + char c = data[i]; + + image->buffer[(i * 4) + 0] = backbuffer_palette[(c * 3) + 0]; + image->buffer[(i * 4) + 1] = backbuffer_palette[(c * 3) + 1]; + image->buffer[(i * 4) + 2] = backbuffer_palette[(c * 3) + 2]; + if (c == 0) { + image->buffer[(i * 4) + 3] = 0; + } + else { + image->buffer[(i * 4) + 3] = 255; + } + } + + + GLuint texture; + glGenTextures(1, &texture); + glBindTexture(GL_TEXTURE_2D, texture); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->buffer); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + + + strcpy(image->name, name); + image->image = texture; + image->width = Width; + image->height = Height; + loaded_images.push_back(image); + return image; +} + + BOOL Set_Video_Mode(HWND hwnd, int w, int h, int bits_per_pixel) { // Todo implement resoluton scaling. return true; // Always return true;