Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Ben Lankamp
2020-06-20 11:14:55 +02:00
62 changed files with 4157 additions and 1225 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
View File
+5 -4
View File
@@ -1,4 +1,4 @@
# CMakeList.txt : CMake project for Red Alert
# CMakeList.txt : CMake project for Red Alert
cmake_minimum_required (VERSION 3.8)
project(RedAlert ASM CXX C)
@@ -547,6 +547,7 @@ set(src_redalert
./RedAlert/TEXTBTN.H
./RedAlert/THEME.CPP
./RedAlert/THEME.H
./RedAlert/TILESET.CPP
./RedAlert/TOGGLE.CPP
./RedAlert/TOGGLE.H
./RedAlert/TOOLTIP.CPP
@@ -708,10 +709,10 @@ 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})
set_target_properties(RedAlert PROPERTIES OUTPUT_NAME "RedAlert" LINK_FLAGS "/PDB:\"RedAlert.pdb\" /SUBSYSTEM:WINDOWS" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../../bin" )
set_target_properties(RedAlert PROPERTIES OUTPUT_NAME "RedAlert" LINK_FLAGS "/PDB:\"RedAlert.pdb\" /SUBSYSTEM:WINDOWS" RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../" )
target_include_directories(RedAlert PRIVATE ./external/devil/;./external/;./redalert/win32lib;./external/lua/;./external/imgui;./external/dxsdk/Include;./external/ffmpeg-win32/include;./external/sdl2/include;./win32lib;./external/openal/include)
target_link_libraries(RedAlert "opengl32.lib" "winmm.lib" "Ws2_32.lib" "${CMAKE_SOURCE_DIR}/external/devil/DevIL.lib" "${CMAKE_SOURCE_DIR}/external/sdl2/lib/x86/SDL2.lib" "${CMAKE_SOURCE_DIR}/external/openal/out/build/x86-Release/OpenAL32.lib")
target_link_libraries(RedAlert "opengl32.lib" "winmm.lib" "Ws2_32.lib" "${CMAKE_SOURCE_DIR}/external/devil/ilu.lib" "${CMAKE_SOURCE_DIR}/external/devil/DevIL.lib" "${CMAKE_SOURCE_DIR}/external/sdl2/lib/x86/SDL2.lib" "${CMAKE_SOURCE_DIR}/external/openal/out/build/x86-Release/OpenAL32.lib")
+59 -8
View File
@@ -58,7 +58,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include "Image.h"
#define FATSHIP
@@ -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
}
@@ -3134,6 +3140,19 @@ void BuildingTypeClass::One_Time(void)
*/
_makepath(fullname, NULL, NULL, building.Graphic_Name(), ".SHP");
((void const *&)building.ImageData) = MFCD::Retrieve(fullname);
{
char imageFileName[512];
sprintf(imageFileName, "DATA/ART/TEXTURES/SRGB/RED_ALERT/STRUCTURES/%s/%s-0000.TGA", building.Graphic_Name(), building.Graphic_Name());
((void const*&)building.HDImageData) = Image_LoadImage(imageFileName, true, true);
if (building.ImageData != NULL && building.HDImageData != NULL) {
int width = Get_Build_Frame_Width(building.ImageData);
int height = Get_Build_Frame_Height(building.ImageData);
building.HDImageData->renderwidth = width;
building.HDImageData->renderheight = height;
}
}
}
// Try to load weap2.shp and tesla coil's lightning shapes
@@ -3206,13 +3225,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->renderwidth, hdimage->renderheight);
}
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 +3265,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));
}
}
@@ -3356,7 +3386,28 @@ void BuildingTypeClass::Init(TheaterType theater)
if (classptr->IsTheater) {
_makepath(fullname, NULL, NULL, classptr->Graphic_Name(), Theaters[theater].Suffix);
((void const *&)classptr->ImageData) = MFCD::Retrieve(fullname);
// jmarshall
{
char imageFileName[512];
// Try load the theatre specific asset first
sprintf(imageFileName, "DATA/ART/TEXTURES/SRGB/RED_ALERT/TERRAIN/%s/%s.%s/%s.%s-0000.DDS", Theaters[theater].Name, classptr->Graphic_Name(), Theaters[theater].Suffix, classptr->Graphic_Name(), Theaters[theater].Suffix);
((BuildingTypeClass*)classptr)->HDImageData = Image_LoadImage(imageFileName);
if (!((BuildingTypeClass*)classptr)->HDImageData) {
sprintf(imageFileName, "DATA/ART/TEXTURES/SRGB/RED_ALERT/STRUCTURES/%s/%s-0000.TGA", classptr->Graphic_Name(), classptr->Graphic_Name());
((BuildingTypeClass*)classptr)->HDImageData = Image_LoadImage(imageFileName);
}
if (classptr->ImageData != NULL && classptr->HDImageData != NULL) {
int width = Get_Build_Frame_Width(classptr->ImageData);
int height = Get_Build_Frame_Height(classptr->ImageData);
classptr->HDImageData->renderwidth = width;
classptr->HDImageData->renderheight = height;
}
}
// jmarshall end
/*
** Buildup data is probably theater specific as well. Fetch a pointer to the
** data at this time as well.
+34
View File
@@ -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.
);
+15
View File
@@ -451,6 +451,14 @@ void BuildingClass::Draw_It(int x, int y, WindowNumberType window) const
{
assert(Buildings.ID(this) == ID);
assert(IsActive);
// jmarshall
Image_t* hdimage = Get_HDImage_Data();
if (hdimage != NULL) {
Techno_Draw_Object_HD(hdimage, Shape_Number(), x, y, window);
TechnoClass::Draw_It(x, y, window);
return;
}
// jmarshall end
/*
** The shape file to use for rendering depends on whether the building
@@ -5919,6 +5927,13 @@ void const * BuildingClass::Get_Image_Data(void) const
return(TechnoClass::Get_Image_Data());
}
struct Image_t *BuildingClass::Get_HDImage_Data(void) const
{
if (BState == BSTATE_CONSTRUCTION) {
return NULL;
}
return(TechnoClass::Get_HDImage_Data());
}
/***********************************************************************************************
* BuildingClass::Value -- Determine the value of this building. *
+3
View File
@@ -236,6 +236,9 @@ class BuildingClass : public TechnoClass
*/
virtual int Value(void) const;
virtual void const * Get_Image_Data(void) const;
// jmarshall
struct Image_t* BuildingClass::Get_HDImage_Data(void) const;
// jmarshall end
virtual int How_Many_Survivors(void) const;
virtual DirType Turret_Facing(void) const;
virtual CELL Find_Exit_Cell(TechnoClass const * techno) const;
+2 -1
View File
@@ -3184,8 +3184,8 @@ void TemplateTypeClass::Display(int x, int y, WindowNumberType window, HousesTyp
for (index = 0; index < w*h; index++) {
if (map[index] != 0xFF) {
HidPage.Draw_Stamp(iconset, index, 0, 0, NULL, WINDOW_MAIN);
Buffer_Enable_HD_Texture(true); // At this point, Draw_Stamp creates a 32bit image.
if (scale) {
HidPage.Scale((*LogicPage), 0, 0,
x + ((index % w)*(ICON_PIXEL_W/2)),
y + ((index / w)*(ICON_PIXEL_H/2)),
@@ -3196,6 +3196,7 @@ void TemplateTypeClass::Display(int x, int y, WindowNumberType window, HousesTyp
HidPage.Blit((*LogicPage), 0, 0, x + ((index % w)*(ICON_PIXEL_W)),
y + ((index / w)*(ICON_PIXEL_H)), ICON_PIXEL_W, ICON_PIXEL_H);
}
Buffer_Enable_HD_Texture(false);
}
}
}
+13 -4
View File
@@ -84,6 +84,11 @@
*/
#include "SidebarGlyphx.h"
std::vector<const ObjectClass*> renderedFrameObjects;
bool HasRenderedObject(const ObjectClass* technoClass) {
return std::find(renderedFrameObjects.begin(), renderedFrameObjects.end(), technoClass) != renderedFrameObjects.end();
}
/***********************************************************************************************
* CellClass::CellClass -- Constructor for cell objects. *
@@ -993,8 +998,6 @@ bool CellClass::Get_Template_Info(char *template_name, int &icon, void *&image_d
return false;
}
/***********************************************************************************************
* CellClass::Draw_It -- Draws the cell imagery at the location specified. *
* *
@@ -1088,7 +1091,7 @@ void CellClass::Draw_It(int x, int y, bool objects) const
** This is the underlying terrain icon.
*/
if (ttype->Get_Image_Data()) {
LogicPage->Draw_Stamp(ttype->Get_Image_Data(), icon, x, y, NULL, WINDOW_TACTICAL);
LogicPage->Draw_Stamp(ttype, icon, x, y, NULL, WINDOW_TACTICAL);
if (remap) {
LogicPage->Remap(x+Map.TacPixelX, y+Map.TacPixelY, ICON_PIXEL_W, ICON_PIXEL_H, remap);
}
@@ -1210,7 +1213,9 @@ void CellClass::Draw_It(int x, int y, bool objects) const
icon = (Cell_X(cell) - Cell_X(Map.ZoneCell + Map.ZoneOffset)) +
(Cell_Y(cell) - Cell_Y(Map.ZoneCell + Map.ZoneOffset)) *
tptr->Width;
LogicPage->Draw_Stamp(tptr->Get_Image_Data(), icon, x, y, NULL, WINDOW_TACTICAL);
// jmarshall - pass in raw tptr
LogicPage->Draw_Stamp(tptr, icon, x, y, NULL, WINDOW_TACTICAL);
// jmarshall end
}
break;
@@ -1334,6 +1339,10 @@ void CellClass::Draw_It(int x, int y, bool objects) const
*/
for (int index = 0; index < count; index++) {
object = optr[index];
if (HasRenderedObject(object)) {
continue;
}
renderedFrameObjects.push_back(object);
int xx,yy;
if (object->IsToDisplay && (!object->Is_Techno() || ((TechnoClass *)object)->Visual_Character() == VISUAL_NORMAL) && Map.Coord_To_Pixel(object->Render_Coord(), xx, yy)) {
if (_Calc_Partial_Window(x, y, xx, yy)) {
+175 -23
View File
@@ -105,6 +105,7 @@ TcpipManagerClass Winsock;
#include "vortex.h"
#include "VQAMOVIE.H"
#include "AUDIOMIX.H"
#include "image.h"
#ifdef WOLAPI_INTEGRATION
//#include "WolDebug.h"
@@ -142,6 +143,9 @@ extern void Do_Draw(void);
bool bNoMovies = false;
#endif
KeyNumType g_globalKeyNumType = KN_NONE;
int g_globalKeyFlags = 0;
/****************************************
** Function prototypes for this module **
*****************************************/
@@ -1634,6 +1638,8 @@ void Color_Cycle(void)
*=============================================================================================*/
void Call_Back(void)
{
WWSDL_ProcessEvents(g_globalKeyNumType, g_globalKeyFlags);
/*
** Music and speech maintenance
*/
@@ -2115,8 +2121,8 @@ static void Sync_Delay(void)
** Delay until the frame timer expires. This forces the game loop to be regulated to a
** speed controlled by the game options slider.
*/
while (FrameTimer) {
Color_Cycle();
while (FrameTimer) {
Color_Cycle();
Call_Back();
if (SpecialDialog == SDLG_NONE) {
@@ -2130,10 +2136,12 @@ static void Sync_Delay(void)
Keyboard_Process(input);
}
Map.Render();
}
}
}
if (!FrameTimer) {
Color_Cycle();
Call_Back();
}
Color_Cycle();
Call_Back();
}
@@ -2315,8 +2323,7 @@ Mono_Set_Cursor(0,0);
** Keep track of elapsed time in the game.
*/
Score.ElapsedTime += TIMER_SECOND / TICKS_PER_SECOND;
Call_Back();
//Call_Back();
/*
** Check for player wins or loses according to global event flag.
@@ -2541,7 +2548,7 @@ void Go_Editor(bool flag)
if (flag) {
AudMix_SetMusicState(false); // jmarshall: disable music if we are in editor mode
Hide_Mouse();
ShowCursor(TRUE);
//ShowCursor(TRUE);
Debug_Map = true;
Debug_Unshroud = true;
@@ -2574,7 +2581,7 @@ void Go_Editor(bool flag)
} else {
AudMix_SetMusicState(true); // jmarshall: enable music if we are going back into editor mode.
Show_Mouse();
ShowCursor(FALSE);
//ShowCursor(FALSE);
/*
** Go into normal game mode
@@ -3469,6 +3476,137 @@ void CC_Draw_Pip(const ObjectClass *object, void const * shapefile, int shapenum
CC_Draw_Shape(shapefile, shapenum, x, y, window, flags, fadingdata, ghostdata, rotation);
}
// jmarshall - this is for hd textures
void CC_Draw_Shape(Image_t* image, int shapenum, int x, int y, WindowNumberType window, ShapeFlags_Type flags, void const* fadingdata, void const* ghostdata, DirType rotation) {
int predoffset;
/*
** Special kludge for E3 to prevent crashes
*/
if ((flags & SHAPE_GHOST) && (!ghostdata)) {
ghostdata = DisplayClass::SpecialGhost;
}
//if ((flags & SHAPE_FADING) && (!fadingdata)) {
// fadingdata = DisplayClass::FadingShade;
//}
static unsigned char* _xbuffer = 0;
if (!_xbuffer) {
_xbuffer = new unsigned char[SHAPE_BUFFER_SIZE];
}
if (image != NULL && shapenum != -1) {
int width = image->renderwidth;
int height = image->renderheight;
#ifdef NEVER
/*
** Perform a quick clip check against the destination rectangle.
*/
if (flags & SHAPE_CENTER) {
if (x - width / 2 >= WindowList[window][WINDOWWIDTH]) return;
if (y - width / 2 >= WindowList[window][WINDOWHEIGHT]) return;
if (x + width / 2 < 0) return;
if (y + height / 2 < 0) return;
}
else {
if (x >= WindowList[window][WINDOWWIDTH]) return;
if (y >= WindowList[window][WINDOWHEIGHT]) return;
if (x + width < 0) return;
if (y + height < 0) return;
}
#endif
{
//GraphicViewPortClass draw_window(LogicPage->Get_Graphic_Buffer(),
// WindowList[window][WINDOWX] + LogicPage->Get_XPos(),
// WindowList[window][WINDOWY] + LogicPage->Get_YPos(),
// WindowList[window][WINDOWWIDTH],
// WindowList[window][WINDOWHEIGHT]);
UseOldShapeDraw = false;
/*
** Rotation handler.
*/
// jmarshall: todo HD rotation code!
// if (rotation != DIR_N) {
//
// /*
// ** Get the raw shape data without the new header and flag to use the old shape drawing
// */
// UseOldShapeDraw = true;
//
// if (Debug_Rotate) {
//#if (0)//PG
// GraphicBufferClass src(width, height, buffer);
// width *= 2;
// height *= 2;
// memset(_xbuffer, '\0', SHAPE_BUFFER_SIZE);
// GraphicBufferClass dst(width, height, _xbuffer);
// Rotate_Bitmap(&src, &dst, rotation);
// buffer = _xbuffer;
//#endif
// }
// else {
//
// BitmapClass bm(width, height, buffer);
// width *= 2;
// height *= 2;
// memset(_xbuffer, '\0', SHAPE_BUFFER_SIZE);
// GraphicBufferClass gb(width, height, _xbuffer);
// TPoint2D pt(width / 2, height / 2);
//
// gb.Scale_Rotate(bm, pt, 0x0100, (256 - (rotation - 64)));
// buffer = _xbuffer;
// }
// }
// jmarshall end
/*
** Special shadow drawing code (used for aircraft and bullets).
*/
if ((flags & (SHAPE_FADING | SHAPE_PREDATOR)) == (SHAPE_FADING | SHAPE_PREDATOR)) {
flags = flags & ~(SHAPE_FADING | SHAPE_PREDATOR);
flags = flags | SHAPE_GHOST;
ghostdata = DisplayClass::SpecialGhost;
}
predoffset = Frame;
//if (x > ( WindowList[window][WINDOWWIDTH] << 2)) {
// predoffset = -predoffset;
//}
Buffer_Enable_HD_Texture(true);
//if (draw_window.Lock()) {
if ((flags & (SHAPE_GHOST | SHAPE_FADING)) == (SHAPE_GHOST | SHAPE_FADING)) {
Buffer_Frame_To_Page(x, y, width, height, image, window, flags | SHAPE_TRANS, ghostdata, fadingdata, 1, predoffset);
}
else {
if (flags & SHAPE_FADING) {
Buffer_Frame_To_Page(x, y, width, height, image, window, flags | SHAPE_TRANS, fadingdata, 1, predoffset);
}
else {
if (flags & SHAPE_PREDATOR) {
Buffer_Frame_To_Page(x, y, width, height, image, window, flags | SHAPE_TRANS, predoffset);
}
else {
Buffer_Frame_To_Page(x, y, width, height, image, window, flags | SHAPE_TRANS, ghostdata, predoffset);
}
}
}
// draw_window.Unlock();
//}
Buffer_Enable_HD_Texture(false);
}
}
}
// jmarshall end
/***********************************************************************************************
* CC_Draw_Shape -- Custom draw shape handler. *
@@ -3558,13 +3696,16 @@ void CC_Draw_Shape(void const * shapefile, int shapenum, int x, int y, WindowNum
/*
** In WIn95, build shape returns a pointer to the shape not its size
*/
Image_t* shape_image = NULL;
shape_pointer = Build_Frame(shapefile, shapenum, _ShapeBuffer);
if (shape_pointer) {
GraphicViewPortClass draw_window(LogicPage->Get_Graphic_Buffer(),
WindowList[window][WINDOWX] + LogicPage->Get_XPos(),
WindowList[window][WINDOWY] + LogicPage->Get_YPos(),
WindowList[window][WINDOWWIDTH],
WindowList[window][WINDOWHEIGHT]);
//GraphicViewPortClass draw_window(LogicPage->Get_Graphic_Buffer(),
// WindowList[window][WINDOWX] + LogicPage->Get_XPos(),
// WindowList[window][WINDOWY] + LogicPage->Get_YPos(),
// WindowList[window][WINDOWWIDTH],
// WindowList[window][WINDOWHEIGHT]);
unsigned char * buffer = (unsigned char *) shape_pointer; //Get_Shape_Header_Data((void*)shape_pointer);
#else //WIN32
@@ -3615,6 +3756,18 @@ void CC_Draw_Shape(void const * shapefile, int shapenum, int x, int y, WindowNum
}
}
{
char tmp[512];
sprintf(tmp, "s_%d_%d_%d_%d_%d", shapefile, shapenum, rotation, fadingdata, flags);
if (flags & SHAPE_FADING) {
shape_image = Image_CreateImageFrom8Bit(tmp, width, height, (unsigned char*)buffer, (unsigned char*)fadingdata);
}
else {
shape_image = Image_CreateImageFrom8Bit(tmp, width, height, (unsigned char*)buffer, NULL);
}
}
/*
** Special shadow drawing code (used for aircraft and bullets).
*/
@@ -3626,25 +3779,24 @@ void CC_Draw_Shape(void const * shapefile, int shapenum, int x, int y, WindowNum
predoffset = Frame;
if (x > ( WindowList[window][WINDOWWIDTH] << 2)) {
predoffset = -predoffset;
}
//if (x > ( WindowList[window][WINDOWWIDTH] << 2)) {
// predoffset = -predoffset;
//}
if (draw_window.Lock()) {
{
if ((flags & (SHAPE_GHOST|SHAPE_FADING)) == (SHAPE_GHOST|SHAPE_FADING)) {
Buffer_Frame_To_Page(x, y, width, height, buffer, draw_window, flags | SHAPE_TRANS, ghostdata, fadingdata, 1, predoffset);
Buffer_Frame_To_Page(x, y, width, height, shape_image, window, flags | SHAPE_TRANS, ghostdata, fadingdata, 1, predoffset);
} else {
if (flags & SHAPE_FADING) {
Buffer_Frame_To_Page(x, y, width, height, buffer, draw_window, flags | SHAPE_TRANS, fadingdata, 1, predoffset);
Buffer_Frame_To_Page(x, y, width, height, shape_image, window, flags | SHAPE_TRANS, fadingdata, 1, predoffset);
} else {
if (flags & SHAPE_PREDATOR) {
Buffer_Frame_To_Page(x, y, width, height, buffer, draw_window, flags | SHAPE_TRANS, predoffset);
Buffer_Frame_To_Page(x, y, width, height, shape_image, window, flags | SHAPE_TRANS, predoffset);
} else {
Buffer_Frame_To_Page(x, y, width, height, buffer, draw_window, flags | SHAPE_TRANS, ghostdata, predoffset);
Buffer_Frame_To_Page(x, y, width, height, shape_image, window, flags | SHAPE_TRANS, ghostdata, predoffset);
}
}
}
draw_window.Unlock();
}
}
}
+3
View File
@@ -1472,6 +1472,9 @@ typedef enum StructType : char {
STRUCT_LARVA2,
#endif
#ifdef RA_AF
STRUCT_AFV01,
#endif
STRUCT_COUNT,
STRUCT_FIRST=0
} StructType;
+12 -12
View File
@@ -99,7 +99,7 @@ void Dialog_Box(int x, int y, int w, int h)
int cx = w/2;
int cy = h/2;
// jmarshall
void const * shapedata = MFCD::Retrieve("DD-BKGND.SHP");
//void const * shapedata = MFCD::Retrieve("DD-BKGND.SHP");
//#ifdef WIN32
// CC_Draw_Shape(shapedata, 0, cx-312, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL);
// CC_Draw_Shape(shapedata, 1, cx, cy-192, WINDOW_PARTIAL, SHAPE_WIN_REL);
@@ -197,17 +197,17 @@ void Dialog_Box(int x, int y, int w, int h)
//CC_Draw_Shape(shapedata, 2, 0, h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL);
//CC_Draw_Shape(shapedata, 3, w-(12*RESFACTOR-1), h-(12*RESFACTOR), WINDOW_PARTIAL, SHAPE_WIN_REL);
#ifdef WIN32
WWMouse->Draw_Mouse(&HidPage);
HidPage.Blit(SeenBuff, x, y, x, y, w, h, false);
WWMouse->Erase_Mouse(&HidPage, FALSE);
#else
// Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, Map.ShadowPage->Get_Buffer());
Hide_Mouse();
HidPage.Blit(SeenBuff);
Show_Mouse();
// Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, ((GraphicBufferClass*)Map.Shadow_Address())->Get_Buffer());
#endif
//#ifdef WIN32
// WWMouse->Draw_Mouse(&HidPage);
// HidPage.Blit(SeenBuff, x, y, x, y, w, h, false);
// WWMouse->Erase_Mouse(&HidPage, FALSE);
//#else
//// Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, Map.ShadowPage->Get_Buffer());
// Hide_Mouse();
// HidPage.Blit(SeenBuff);
// Show_Mouse();
//// Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, ((GraphicBufferClass*)Map.Shadow_Address())->Get_Buffer());
//#endif
Set_Logic_Page(oldpage);
GL_ResetClipRect();
+3 -2
View File
@@ -189,8 +189,9 @@ class DisplayClass: public MapClass
void Repair_Mode_Control(int control);
virtual void Flag_Cell(CELL cell);
bool Is_Cell_Flagged(CELL cell) const {return CellRedraw.Is_True(cell);};
// jmarshall
bool Is_Cell_Flagged(CELL cell) const { return true; }
// jmarshall end
/*
** Computes starting position based on player's units' Coords.
*/
+29 -27
View File
@@ -1474,33 +1474,35 @@ bool Debug_Write_Shape(const char *file_name, void const * shapefile, int shapen
/*
** Build frame returns a pointer now instead of the shapes length
*/
char *shape_pointer = (char*) Build_Frame(shapefile , shapenum , _ShapeBuffer);
if (shape_pointer == NULL) {
return false;;
}
if (Get_Last_Frame_Length() > _ShapeBufferSize) {
return false;;
}
int width = Get_Build_Frame_Width(shapefile);
int height = Get_Build_Frame_Height(shapefile);
GraphicBufferClass temp_gbuffer(width, height);
GraphicViewPortClass temp_viewport(&temp_gbuffer, 0, 0, width, height);
WindowList[WINDOW_CUSTOM][WINDOWX] = 0;
WindowList[WINDOW_CUSTOM][WINDOWY] = 0;
WindowList[WINDOW_CUSTOM][WINDOWWIDTH] = width;
WindowList[WINDOW_CUSTOM][WINDOWHEIGHT] = height;
static const char _shape_trans = 0x40;
if (flags == 0) {
Buffer_Frame_To_Page(0, 0, width, height, shape_pointer, temp_viewport, SHAPE_NORMAL|SHAPE_WIN_REL|_shape_trans); //, ghostdata, predoffset);
} else {
Buffer_Frame_To_Page(0, 0, width, height, shape_pointer, temp_viewport, flags, ghostdata);
}
Write_PCX_File((char*)file_name, temp_viewport, (unsigned char*)GamePalette.Get_Data());
// jmarshall - do we need this?
//char *shape_pointer = (char*) Build_Frame(shapefile , shapenum , _ShapeBuffer);
//if (shape_pointer == NULL) {
// return false;;
//}
//if (Get_Last_Frame_Length() > _ShapeBufferSize) {
// return false;;
//}
//
//int width = Get_Build_Frame_Width(shapefile);
//int height = Get_Build_Frame_Height(shapefile);
//
//GraphicBufferClass temp_gbuffer(width, height);
//GraphicViewPortClass temp_viewport(&temp_gbuffer, 0, 0, width, height);
//
//WindowList[WINDOW_CUSTOM][WINDOWX] = 0;
//WindowList[WINDOW_CUSTOM][WINDOWY] = 0;
//WindowList[WINDOW_CUSTOM][WINDOWWIDTH] = width;
//WindowList[WINDOW_CUSTOM][WINDOWHEIGHT] = height;
//
//static const char _shape_trans = 0x40;
//
//if (flags == 0) {
// Buffer_Frame_To_Page(0, 0, width, height, shape_pointer, temp_viewport, SHAPE_NORMAL|SHAPE_WIN_REL|_shape_trans); //, ghostdata, predoffset);
//} else {
// Buffer_Frame_To_Page(0, 0, width, height, shape_pointer, temp_viewport, flags, ghostdata);
//}
//Write_PCX_File((char*)file_name, temp_viewport, (unsigned char*)GamePalette.Get_Data());
// jmarshall end
return true;
}
+6 -4
View File
@@ -549,6 +549,7 @@ void CC_Draw_Shape(void const * shapefile, int shapenum, int x, int y, WindowNum
// Added for draw intercept. ST - 1/17/2019 12:31PM
void CC_Draw_Shape(const ObjectClass *object, void const * shapefile, int shapenum, int x, int y, WindowNumberType window, ShapeFlags_Type flags, void const * fadingdata = 0, void const * ghostdata = 0, DirType rotation = DIR_N, long virtualscale = 0x0100);
void CC_Draw_Shape(Image_t *image, int shapenum, int x, int y, WindowNumberType window, ShapeFlags_Type flags, void const* fadingdata, void const* ghostdata, DirType rotation);
void CC_Draw_Shape(const ObjectClass *object, const char *shape_file_name, void const * shapefile, int shapenum, int x, int y, WindowNumberType window, ShapeFlags_Type flags, void const * fadingdata = 0, void const * ghostdata = 0, DirType rotation = DIR_N, long virtualscale = 0x0100, char override_owner = HOUSE_NONE);
// Added for pip draw intercept - SKY
@@ -704,12 +705,12 @@ void *Build_Translucent_Table(PaletteClass const & palette, TLucentType const *c
void *Conquer_Build_Translucent_Table(PaletteClass const & palette, TLucentType const *control, int count, void *buffer);
void * Make_Fading_Table(PaletteClass const & palette, void * dest, int color, int frac);
void Buffer_Enable_HD_Texture(bool hdTextureEnabled);
/*
** KEYFBUFF.ASM
*/
extern "C" {
long __cdecl Buffer_Frame_To_Page(int x, int y, int w, int h, void *Buffer, GraphicViewPortClass &view, int flags, ...);
}
long __cdecl Buffer_Frame_To_Page(int x, int y, int w, int h, Image_t* image, unsigned int Window, int flags, ...);
/*
** KEYFRAME.CPP
@@ -1180,5 +1181,6 @@ __forceinline void COM_SetExtension(char* path, int maxSize, const char* extensi
}
extern bool g_inMainMenu;
extern KeyNumType g_globalKeyNumType;
extern int g_globalKeyFlags;
#endif
+1 -4
View File
@@ -533,10 +533,7 @@ KeyNumType GadgetClass::Input(void)
** rather the the mouse position at the time we get around to this function.
*/
// jmarshall
int flags = 0;
WWSDL_ProcessEvents(key, flags);
Show_Mouse(); // jmarshall: thsi shouldn't be here!
int flags = g_globalKeyFlags;
// jmarshall end
/*
+15 -9
View File
@@ -397,7 +397,7 @@ void GScreenClass::Render(void)
//if (Buttons && Buttons->Is_List_To_Redraw()) {
// IsToRedraw = true;
//}
IsToRedraw = true;
if (IsToUpdate || IsToRedraw) {
BStart(BENCH_GSCREEN_RENDER);
@@ -468,14 +468,20 @@ extern "C" {
}
void GScreenClass::Blit_Display(void)
{
BStart(BENCH_BLIT_DISPLAY);
WWMouse->Draw_Mouse(&HidPage);
HidPage.Blit(SeenBuff , 0 , 0 , 0 , 0 , HidPage.Get_Width() , HidPage.Get_Height() , (BOOL) FALSE );
WWMouse->Erase_Mouse(&HidPage, FALSE);
BEnd(BENCH_BLIT_DISPLAY);
{
BEnd(BENCH_BLIT_DISPLAY);
#ifdef WIN32
if (SeenBuff.Get_Width()!=320) {
WWMouse->Draw_Mouse(&HidPage);
//HidPage.Blit(SeenBuff , 0 , 0 , 0 , 0 , HidPage.Get_Width() , HidPage.Get_Height() , (BOOL) FALSE );
memcpy(SeenBuff.Get_Graphic_Buffer()->GetMemoryBuffer(), HidPage.Get_Graphic_Buffer()->GetMemoryBuffer(), HidPage.Get_Width() * HidPage.Get_Height() * 4);
WWMouse->Erase_Mouse(&HidPage, FALSE);
} else {
//PG ModeX_Blit(&HiddenPage);
}
#else
Shadow_Blit(0, 0, 320, 200, HidPage, SeenPage, ShadowPage->Get_Buffer());
#endif
}
+58
View File
@@ -0,0 +1,58 @@
// HOUSECOLOR.H
//
#include "vectormath.h"
struct HouseColorHD {
HouseColorHD(float3 lowerbounds,
float3 upperbounds,
float fudge,
float3 hsvshift,
float3 inputlevels,
float2 outputlevels,
float3 overallinputlevels,
float2 overalloutputlevels,
float3 radarmapcolor)
{
this->LowerBounds = lowerbounds;
this->UpperBounds = upperbounds;
this->Fudge = fudge;
this->HSVShift = hsvshift;
this->InputLevels = inputlevels;
this->OutputLevels = outputlevels;
this->OverallInputLevels = overallinputlevels;
this->OverallOutputLevels = overalloutputlevels;
this->RadarMapColor = radarmapcolor;
}
float3 LowerBounds;
float3 UpperBounds;
float Fudge;
float3 HSVShift;
float3 InputLevels;
float2 OutputLevels;
float3 OverallInputLevels;
float2 OverallOutputLevels;
float3 RadarMapColor;
};
// This data has been sourced from the TD Original Skirmish Color mod by Pokey
//
static HouseColorHD *houseColors[8] = {
// Spain
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.713,-0.621, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.6421568, 0.4784698, 0.4784698)),
// Greece
new HouseColorHD(float3(0.264706f, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.310000f,-0.211000, 0.005000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0980f, 0.3922, 0.9216)),
// USSR
new HouseColorHD(float3(0.264706f, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.689000f,0.382000, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.756863f, 0.0, 0.015686)),
// England
new HouseColorHD(float3(0.26f, 1.0f, 1.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.777f,-0.196, -0.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.737255, 0.627451, 0.239216)),
// Ukraine
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.726,0.119, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.772549, 0.380392, 0.07451)),
// Germany
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.911f,-0.381, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.184314, 0.67451, 0.141176)),
// France
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.119,-0.233, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.1151961, 0.6911765, 0.4031861)),
// Turkey
new HouseColorHD(float3(0.26, 1.0f, 0.0f), float3(0.0f, 1.0f, 0.22f), 0, float3(0.685,-0.151, 0.000000), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.0f, 1.0f, 1.0f), float2(0.0f, 1.0f), float3(0.5784314, 0.1155861, 0.05387352)),
};
+206
View File
@@ -0,0 +1,206 @@
// IMGUTIL.H
//
#ifdef _DEBUG
#pragma optimize( "", on )
#endif
// SRGB -> Linear color space conversion.
inline float ByteToLinear(byte p) {
float v;
v = ((float)p) / 255.0f;
v = (double)v >= 0.0404499992728233 ? (float)pow((200.0 * (double)v + 11.0) / 211.0, 2.40000009536743) : (float)((double)v * 25.0 / 323.0);
return v;
}
inline float ToSRGB(float v)
{
return (double)v >= 0.0031308 ? (float)((pow((double)v, 0.416666656732559) * 211.0 - 11.0) / 200.0) : (float)((double)v * 323.0 / 25.0);
}
inline float PixelToHue(float R, float G, float B) {
if (R == G && G == B)
return 0; // 0 makes as good an UNDEFINED value as any
float r = (float)R / 255.0f;
float g = (float)G / 255.0f;
float b = (float)B / 255.0f;
float max, min;
float delta;
float hue = 0.0f;
max = r; min = r;
if (g > max) max = g;
if (b > max) max = b;
if (g < min) min = g;
if (b < min) min = b;
delta = max - min;
if (r == max) {
hue = (g - b) / delta;
}
else if (g == max) {
hue = 2 + (b - r) / delta;
}
else if (b == max) {
hue = 4 + (r - g) / delta;
}
hue *= 60;
if (hue < 0.0f) {
hue += 360.0f;
}
return hue;
}
struct Turple {
Turple() {
memset(this, 0, sizeof(Turple));
}
Turple(float Item1, float Item2, float Item3) {
this->Item1 = Item1;
this->Item2 = Item2;
this->Item3 = Item3;
this->Item4 = -1;
}
Turple(float Item1, float Item2, float Item3, float Item4) {
this->Item1 = Item1;
this->Item2 = Item2;
this->Item3 = Item3;
this->Item4 = Item4;
}
float Item1;
float Item2;
float Item3;
float Item4;
};
float step(float a, float x)
{
return x >= a;
}
inline float4 lerp(float4 a, float4 b, float w)
{
float4 l;
l.x = a.x + w * (b.x - a.x);
l.y = a.y + w * (b.y - a.y);
l.z = a.z + w * (b.z - a.z);
l.w = a.w + w * (b.w - a.w);
return l;
}
inline float3 lerp(float3 a, float3 b, float w)
{
float3 l;
l.x = a.x + w * (b.x - a.x);
l.y = a.y + w * (b.y - a.y);
l.z = a.z + w * (b.z - a.z);
return l;
}
inline float3 frac(float3 v)
{
float3 f;
f.x = v.x - floor(v.x);
f.y = v.y - floor(v.y);
f.z = v.z - floor(v.z);
return f;
}
inline float frac(float v)
{
return v - floor(v);
}
inline float lerp(float a, float b, float w)
{
return a + w * (b - a);
}
inline float3 clamp(float3 x, float a, float b)
{
float3 r;
r.x = max(a, min(b, x.x));
r.y = max(a, min(b, x.y));
r.z = max(a, min(b, x.z));
return r;
}
inline float saturate(float x)
{
return max(0, min(1, x));
}
inline void RenderTeamPalette(byte* pixel, HouseColorHD &teamColor) {
float linear1 = ByteToLinear(pixel[2]);
float linear2 = ByteToLinear(pixel[1]);
float linear3 = ByteToLinear(pixel[0]);
float num1 = linear1;
float num2 = linear2;
float num3 = (float)linear3;
Turple valueTuple1 = Turple(0.0f, -0.3333333, 0.6666667, -1 );
Turple valueTuple2;
if ((double)num2 >= (double)num3)
valueTuple2 = Turple( num2, num3, valueTuple1.Item1, valueTuple1.Item2 );
else
valueTuple2 = Turple( num3, num2, valueTuple1.Item4, valueTuple1.Item3 );
Turple valueTuple3;
if ((double)num1 >= (double)valueTuple2.Item1)
valueTuple3 = Turple(num1, valueTuple2.Item2, valueTuple2.Item3, valueTuple2.Item1);
else
valueTuple3 = Turple(valueTuple2.Item1, valueTuple2.Item2, valueTuple2.Item4, num1);
double num4 = (double)valueTuple3.Item1 - (double)min(valueTuple3.Item4, valueTuple3.Item2);
float num5 = 1E-10f;
float num6 = (float)num4;
float num7 = num5;
float num8 = abs(valueTuple3.Item3 + (float)(((double)valueTuple3.Item4 - (double)valueTuple3.Item2) / (6.0 * (double)num6 + (double)num7)));
float num9 = num6 / (valueTuple3.Item1 + num7);
double num10 = (double)valueTuple3.Item1;
float num11 = num8;
float num12 = num9;
float num13 = (float)num10;
float num14 = PixelToHue(teamColor.LowerBounds.x, teamColor.LowerBounds.y, teamColor.LowerBounds.z) / 360;
float num15 = PixelToHue(teamColor.UpperBounds.x, teamColor.UpperBounds.y, teamColor.UpperBounds.z) / 360;
if ((double)num11 >= (double)num14 && (double)num15 >= (double)num11)
{
float num16 = (float)((double)num11 / ((double)num15 - (double)num14) * ((double)num15 + (double)teamColor.Fudge - ((double)num14 - (double)teamColor.Fudge))) + teamColor.HSVShift.x;
float t = num12 + teamColor.HSVShift.y;
float num17 = num13 + teamColor.HSVShift.z;
Turple valueTuple4 = Turple(1.0f, 0.6666667, 0.3333333, 3);
Turple valueTuple5 = Turple(abs(frac(num16 + valueTuple4.Item1) * 6 - valueTuple4.Item4), abs(frac(num16 + valueTuple4.Item2) * 6 - valueTuple4.Item4), abs(frac(num16 + valueTuple4.Item3) * 6 - valueTuple4.Item4));
float num18 = num17 * lerp(valueTuple4.Item1, saturate(valueTuple5.Item1 - valueTuple4.Item1), t);
float num19 = num17 * lerp(valueTuple4.Item1, saturate(valueTuple5.Item2 - valueTuple4.Item1), t);
float num20 = num17 * lerp(valueTuple4.Item1, saturate(valueTuple5.Item3 - valueTuple4.Item1), t);
Turple valueTuple6 = Turple(min(1, max(0.0f, num18 - teamColor.InputLevels.x) / (teamColor.InputLevels.z - teamColor.InputLevels.x)), min(1, max(0.0f, num19 - teamColor.InputLevels.x) / (teamColor.InputLevels.z - teamColor.InputLevels.x)), min(1, max(0.0f, num20 - teamColor.InputLevels.x) / (teamColor.InputLevels.z - teamColor.InputLevels.x)));
valueTuple6.Item1 = (float)pow((double)valueTuple6.Item1, (double)teamColor.InputLevels.y);
valueTuple6.Item2 = (float)pow((double)valueTuple6.Item2, (double)teamColor.InputLevels.y);
valueTuple6.Item3 = (float)pow((double)valueTuple6.Item3, (double)teamColor.InputLevels.y);
num1 = lerp(teamColor.OutputLevels.x, teamColor.OutputLevels.y, valueTuple6.Item1);
num2 = lerp(teamColor.OutputLevels.x, teamColor.OutputLevels.y, valueTuple6.Item2);
num3 = lerp(teamColor.OutputLevels.x, teamColor.OutputLevels.y, valueTuple6.Item3);
}
Turple valueTuple7 = Turple(min(1, max(0.0f, num1 - teamColor.OverallInputLevels.x) / (teamColor.OverallInputLevels.z - teamColor.OverallInputLevels.x)), min(1, max(0.0f, num2 - teamColor.OverallInputLevels.x) / (teamColor.OverallInputLevels.z - teamColor.OverallInputLevels.x)), min(1, max(0.0f, num3 - teamColor.OverallInputLevels.x) / (teamColor.OverallInputLevels.z - teamColor.OverallInputLevels.x)));
valueTuple7.Item1 = (float)pow((double)valueTuple7.Item1, (double)teamColor.OverallInputLevels.y);
valueTuple7.Item2 = (float)pow((double)valueTuple7.Item2, (double)teamColor.OverallInputLevels.y);
valueTuple7.Item3 = (float)pow((double)valueTuple7.Item3, (double)teamColor.OverallInputLevels.y);
float v1 = lerp(teamColor.OverallOutputLevels.x, teamColor.OverallOutputLevels.y, valueTuple7.Item1);
float v2 = lerp(teamColor.OverallOutputLevels.x, teamColor.OverallOutputLevels.y, valueTuple7.Item2);
float v3 = lerp(teamColor.OverallOutputLevels.x, teamColor.OverallOutputLevels.y, valueTuple7.Item3);
pixel[2] = (byte)((double)ToSRGB(v1) * (double)255.0f);
pixel[1] = (byte)((double)ToSRGB(v2) * (double)255.0f);
pixel[0] = (byte)((double)ToSRGB(v3) * (double)255.0f);
}
#ifdef _DEBUG
#pragma optimize( "", off )
#endif
+3 -1
View File
@@ -2532,7 +2532,9 @@ static void Init_Color_Remaps(void)
GraphicBufferClass temp_page(320, 200, (void*)NULL);
temp_page.Clear();
Load_Picture("PALETTE.CPS", temp_page, temp_page, NULL, BM_DEFAULT);
temp_page.Blit(HidPage);
// jmarshall
temp_page.BlitLegacy(HidPage, (BOOL)false);
// jmarshall end
#else
Load_Picture("PALETTE.CPS", HidPage, HidPage, NULL, BM_DEFAULT);
#endif
+25 -2
View File
@@ -1,11 +1,34 @@
// Image.h
//
#define MAX_IMAGE_FRAMES 256
#define MAX_HOUSE_COLORS 8
struct Image_t {
Image_t();
~Image_t();
char name[512];
unsigned int image;
int64_t namehash;
unsigned int image[MAX_HOUSE_COLORS][MAX_IMAGE_FRAMES];
unsigned int numAnimFrames;
int width;
int height;
int renderwidth;
int renderheight;
//unsigned char* buffer[MAX_HOUSE_COLORS][MAX_IMAGE_FRAMES];
};
Image_t* Image_LoadImage(const char* name);
__forceinline Image_t::Image_t() {
// buffer = NULL;
numAnimFrames = 0;
}
__forceinline Image_t::~Image_t() {
//if (buffer) {
// delete buffer;
// buffer = NULL;
//}
}
Image_t* Image_LoadImage(const char* name, bool loadAnims = false, bool loadHouseColor = false);
Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsigned char* data, unsigned char *remap = NULL);
+4 -14
View File
@@ -62,6 +62,8 @@
#define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0]))
int WWKeyboardClass::Head = 0;
int WWKeyboardClass::Tail = 0;
/***********************************************************************************************
* WWKeyboardClass::WWKeyBoardClass -- Construction for Westwood Keyboard Class *
@@ -75,9 +77,7 @@
*=============================================================================================*/
WWKeyboardClass::WWKeyboardClass(void) :
MouseQX(0),
MouseQY(0),
Head(0),
Tail(0)
MouseQY(0)
{
// _Kbd = this;
@@ -517,17 +517,7 @@ bool WWKeyboardClass::Is_Buffer_Empty(void) const
*=============================================================================================*/
void WWKeyboardClass::Fill_Buffer_From_System(void)
{
if (!Is_Buffer_Full())
{
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (!GetMessage( &msg, NULL, 0, 0 )) {
return;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
+2 -2
View File
@@ -117,8 +117,8 @@ class WWKeyboardClass
** These are the tracking pointers to maintain the
** circular keyboard list.
*/
int Head;
int Tail;
static int Head;
static int Tail;
};
#define RA_SCANCODE_MASK (1<<30)
+6 -6
View File
@@ -428,14 +428,17 @@ int MapEditClass::Placement_Dialog(void)
/*
** Refresh display if needed
*/
if (display) {
//if (display) {
/*
** Display the dialog box
*/
Hide_Mouse();
Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
// Dialog_Box(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W, D_DIALOG_H);
// Draw_Caption(TXT_PLACE_OBJECT, D_DIALOG_X, D_DIALOG_Y, D_DIALOG_W);
// jmarshall - temp render a black background here so the tool works.
LogicPage->Fill_Rect(D_DIALOG_X, D_DIALOG_Y, D_DIALOG_X + D_DIALOG_W, D_DIALOG_Y + D_DIALOG_H, 0);
// jamrshall end
/*
** Display the current object:
@@ -560,7 +563,7 @@ int MapEditClass::Placement_Dialog(void)
Show_Mouse();
display = false;
}
// }
display = true;
@@ -756,9 +759,6 @@ int MapEditClass::Placement_Dialog(void)
// default:
// break;
//}
KeyNumType _key;
int _type;
WWSDL_ProcessEvents(_key, _type);
}
/*
+5 -2
View File
@@ -160,7 +160,7 @@ GameType Select_MPlayer_Game (void)
// Initialize
//------------------------------------------------------------------------
Set_Logic_Page(SeenBuff);
VisiblePage.Blit(seen_buff_save);
//VisiblePage.Blit(seen_buff_save);
//------------------------------------------------------------------------
// Fill array of button ptrs
@@ -694,7 +694,7 @@ int Surrender_Dialog(int text)
//.....................................................................
// Refresh display if needed
//.....................................................................
if (display) {
{
display = false;
//..................................................................
@@ -730,6 +730,9 @@ int Surrender_Dialog(int text)
// Get user input
//.....................................................................
KeyNumType input = commands->Input();
// jmarshall
Call_Back();
// jmarshall end
//.....................................................................
// Process input
+3 -1
View File
@@ -166,7 +166,9 @@ int WWMessageBox::Process(const char * msg, const char * b1txt, const char * b2t
*/
Set_Logic_Page(SeenBuff);
#ifdef WIN32
VisiblePage.Blit(seen_buff_save);
// jmarshall - not needed
//VisiblePage.Blit(seen_buff_save);
// jmarshall end
#endif
/*
+341 -19
View File
@@ -5,10 +5,12 @@
#include "MapScript.h"
/***********************************************************************************************
* Script_GiveCreditsToPlayer - Gives a given player a given amount of credits *
* Script_GiveCredits - Gives a given player a given amount of credits *
* *
* SCRIPT INPUT: houseType (int) - The player (house) index to give credits to *
* cashToGive (int) - The amount of cold hard credits to give the player *
* SCRIPT INPUT: cashToGive (int) - The amount of cold hard credits to give the player *
* *
* houseType (int) - The player (house) index to give credits to *
* or -1 to give to all players *
* *
* SCRIPT OUTPUT: void *
* *
@@ -22,16 +24,28 @@
* 6/11/2020 - JM Created *
* 6/12/2020 - JJ Added player (house) index input *
*=============================================================================================*/
static int Script_GiveCreditsToPlayer(lua_State* L) {
int houseType = lua_tointeger(L, 1);
int cashToGive = lua_tointeger(L, 2);
static int Script_GiveCredits(lua_State* L) {
int cashToGive = lua_tointeger(L, 1);
int houseType = -1;
// Optional houseType parameter
if (lua_gettop(L) == 2) {
houseType = lua_tointeger(L, 2);
}
for (int h_index = 0; h_index < Houses.Count(); h_index++) {
HouseClass* house = Houses.Ptr(h_index);
if (house->ID == houseType) {
if (house->ID == houseType || houseType == -1) {
house->Refund_Money(cashToGive);
// Discontinue giving out free cash if a specific house was specified
if (houseType >= 0) {
break;
}
}
}
@@ -42,8 +56,11 @@ static int Script_GiveCreditsToPlayer(lua_State* L) {
/***********************************************************************************************
* Script_NumBuildingTypeForPlayer - Returns the amount of specific buildings for a player *
* *
* SCRIPT INPUT: houseType (int) - The player (house) index to count buildings for *
* structType (int) - The structure index to count buildings for *
* SCRIPT INPUT: structType (int) - The structure index to count buildings for *
* or -1 for all structures *
* *
* houseType (int) - The player (house) index to count buildings for *
* or -1 to for all players *
* *
* SCRIPT OUTPUT: result (number) - The amount of matching buildings for that player *
* *
@@ -54,15 +71,22 @@ static int Script_GiveCreditsToPlayer(lua_State* L) {
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_NumBuildingTypeForPlayer(lua_State* L) {
int houseType = lua_tointeger(L, 1);
int structType = lua_tointeger(L, 2);
static int Script_CountBuildings(lua_State* L) {
int structType = lua_tointeger(L, 1);
int houseType = -1;
// Optional houseType parameter
if (lua_gettop(L) == 2) {
houseType = lua_tointeger(L, 2);
}
int result = 0;
for (int b_index = 0; b_index < Buildings.Count(); b_index++) {
BuildingClass* building = Buildings.Ptr(b_index);
if (building->Owner() == houseType) {
if (building->Class->Type == structType) {
if (building->Owner() == houseType || houseType == -1) {
if (building->Class->Type == structType || structType == -1) {
result++;
}
}
@@ -73,6 +97,243 @@ static int Script_NumBuildingTypeForPlayer(lua_State* L) {
}
/***********************************************************************************************
* Script_CountAircraft - Returns the amount of specific aircraft for a player *
* *
* SCRIPT INPUT: aircraftType (int) - The aircraft index to count aircraft for *
* or -1 for all aircraft *
* *
* houseType (int) - The player (house) index to count aircraft for *
* or -1 for all players *
* *
* SCRIPT OUTPUT: result (number) - The amount of matching aircraft for that player *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_CountAircraft(lua_State* L) {
int aircraftType = lua_tointeger(L, 1);
int houseType = -1;
// Optional houseType parameter
if (lua_gettop(L) == 2) {
houseType = lua_tointeger(L, 2);
}
int result = 0;
for (int a_index = 0; a_index < Aircraft.Count(); a_index++) {
AircraftClass* aircraft = Aircraft.Ptr(a_index);
if (aircraft->Owner() == houseType || houseType == -1) {
if (aircraft->Class->Type == aircraftType || aircraftType == -1) {
result++;
}
}
}
lua_pushnumber(L, result);
return 1;
}
/***********************************************************************************************
* Script_CountUnits - Returns the amount of specific units for a player *
* *
* SCRIPT INPUT: unitType (int) - The unit index to count units for *
* or -1 for all units *
* *
* houseType (int) - The player (house) index to count units for *
* or -1 for all players *
* *
* NOTE: -1 for either index input acts as ALL *
* *
* SCRIPT OUTPUT: result (number) - The amount of matching units for that player *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_CountUnits(lua_State* L) {
int unitType = lua_tointeger(L, 1);
int houseType = -1;
// Optional houseType parameter
if (lua_gettop(L) == 2) {
houseType = lua_tointeger(L, 2);
}
int result = 0;
for (int u_index = 0; u_index < Units.Count(); u_index++) {
UnitClass* unit = Units.Ptr(u_index);
if (unit->Owner() == houseType || houseType == -1) {
if (unit->Class->Type == unitType || unitType == -1) {
result++;
}
}
}
lua_pushnumber(L, result);
return 1;
}
/***********************************************************************************************
* Script_CountInfantry - Returns the amount of specific infantry for a player *
* *
* SCRIPT INPUT: infantryType (int) - The infantry index to count infantry for *
* or -1 for all infantry *
* *
* houseType (int) - The player (house) index to count infantry for *
* or -1 for all players *
* *
* NOTE: -1 for either index input acts as ALL *
* *
* SCRIPT OUTPUT: result (number) - The amount of matching infantry for that player *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_CountInfantry(lua_State* L) {
int infantryType = lua_tointeger(L, 1);
int houseType = -1;
// Optional houseType parameter
if (lua_gettop(L) == 2) {
houseType = lua_tointeger(L, 2);
}
int result = 0;
for (int u_index = 0; u_index < Infantry.Count(); u_index++) {
InfantryClass* infantry = Infantry.Ptr(u_index);
if (infantry->Owner() == houseType || houseType == -1) {
if (infantry->Class->Type == infantryType || infantryType == -1) {
result++;
}
}
}
lua_pushnumber(L, result);
return 1;
}
/***********************************************************************************************
* Script_CountVessels - Returns the amount of specific vessels for a player *
* *
* SCRIPT INPUT: vesselType (int) - The vessel index to count vessels for *
* or -1 for all vessels *
* *
* houseType (int) - The player (house) index to count vessels for *
* or -1 for all players *
* *
* NOTE: -1 for either index input acts as ALL *
* *
* SCRIPT OUTPUT: result (number) - The amount of matching vessels for that player *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_CountVessels(lua_State* L) {
int vesselType = lua_tointeger(L, 1);
int houseType = -1;
// Optional houseType parameter
if (lua_gettop(L) == 2) {
houseType = lua_tointeger(L, 2);
}
int result = 0;
for (int u_index = 0; u_index < Vessels.Count(); u_index++) {
VesselClass* vessel = Vessels.Ptr(u_index);
if (vessel->Owner() == houseType || houseType == -1) {
if (vessel->Class->Type == vesselType || vesselType == -1) {
result++;
}
}
}
lua_pushnumber(L, result);
return 1;
}
/***********************************************************************************************
* Script_SetTriggerCallback - Adds a lua callback to an existing trigger *
* *
* SCRIPT INPUT: triggerName (string) - The ININame of the trigger via its class *
* *
* callbackName (string) - The function name to be called when the *
* actions have been met *
* *
* actionIndex (int) (opt.) - 0: always callback on any of the given paths *
* of the trigger *
* 1: only callback on first action *
* 2: only callback on second action *
* *
* SCRIPT OUTPUT: result (number) - The amount of matching buildings for that player *
* *
* INPUT: lua_State - The current Lua state *
* *
* OUTPUT: int; Did the function run successfully? Return 1 *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
static int Script_SetTriggerCallback(lua_State* L) {
const char* triggerName = lua_tostring(L, 1);
const char* callbackName = lua_tostring(L, 2);
char actionIndex = 0;
// Optional actionIndex parameter
if (lua_gettop(L) == 3) {
actionIndex = lua_tointeger(L, 2);
}
// Find the trigger and set up callback
for (int t_index = 0; t_index < Triggers.Count(); t_index++) {
TriggerClass* trigger = Triggers.Ptr(t_index);
if (trigger != NULL) {
if (strcmp(trigger->Name(), triggerName) == 0) {
strncpy(trigger->MapScriptCallback,callbackName,sizeof(trigger->MapScriptCallback ) - 1);
trigger->MapScriptActionIndex = actionIndex;
break;
}
}
}
return 1;
}
/***********************************************************************************************
* Script_Win - The specified player wins *
* *
@@ -88,7 +349,7 @@ static int Script_NumBuildingTypeForPlayer(lua_State* L) {
* *
*=============================================================================================*/
static int Script_Win(lua_State* L) {
int houseType = lua_tointeger(L, -1);
if (houseType != HOUSE_NONE) {
@@ -779,11 +1040,47 @@ static int Script_SetBriefingText(lua_State* L) {
* *
*=============================================================================================*/
void MapScript::CallFunction(const char* functionName) {
lua_getglobal(L, functionName);
lua_pcall(L, 0, 0, 0);
} //BriefingText
/***********************************************************************************************
* MapScript::setLuaPath - Sets Lua's path / extensions to search for scripts *
* *
* This helps Lua know where/how to look for files when using require(), otherwise we could *
* hard code path/extension as we did previously *
* *
* INPUT: pathvalue - See lua documentation RE: LUA_PATH to know how to deal with this *
* *
* OUTPUT: void *
* *
* WARNINGS: ? *
* *
*=============================================================================================*/
void MapScript::SetLuaPath( const char* input_path)
{
// Needs space to keep the initial paths
char new_path[1024];
// Set new GLOBALS.package.path
lua_getglobal(L, "package");
lua_getfield(L, -1, "path"); // get field "path" from table at top of stack (-1)
const char* cur_path = lua_tostring(L, -1); // grab path string from top of stack
sprintf(new_path, "%s;%s", cur_path, input_path);
lua_pop(L, 1);
lua_pushstring(L, new_path);
lua_setfield(L, -2, "path");
lua_pop(L, 1);
}
/***********************************************************************************************
* MapScript::Init -- Loads and initializes script for a given map *
* *
@@ -798,10 +1095,28 @@ void MapScript::CallFunction(const char* functionName) {
*=============================================================================================*/
bool MapScript::Init(const char* mapName) {
char scriptName[256];
// Build map path
sprintf(scriptName, "scripts/%s.script", mapName);
L = luaL_newstate();
if (luaL_loadfile(L, scriptName) || lua_pcall(L, 0, 0, 0)) {
luaL_openlibs(L);
// Load file
if (luaL_loadfile(L, scriptName)){
L = NULL;
return false;
}
// TODO: I've tried several combinations of paths (including "scripts/?"),
// but I can only get "require 'basefilename'" to work within a
// script, not "require 'basefilename.script'". This may be completely
// normal within lua, but it seems odd.
// This allows require() to work
SetLuaPath(";scripts/?.script;");
if (lua_pcall(L, 0, 0, 0)) {
L = NULL;
return false;
}
@@ -880,15 +1195,22 @@ bool MapScript::Init(const char* mapName) {
*=============================================================================================*/
lua_register(L, "SetBriefingText", Script_SetBriefingText); // Sets the [text] on the mission briefing screen
lua_register(L, "GiveCreditsToPlayer", Script_GiveCreditsToPlayer); // Give [player] [credits]
lua_register(L, "NumBuildingTypeForPlayer", Script_NumBuildingTypeForPlayer); // Number of buildings of [type] for given [player]
lua_register(L, "GiveCredits", Script_GiveCredits); // Give [credits] to [player]
lua_register(L, "CountBuildings", Script_CountBuildings); // Number of buildings of [type] for given [player]
lua_register(L, "CountAircraft", Script_CountAircraft); // Number of units of [type] for given [player]
lua_register(L, "CountUnits", Script_CountUnits); // Number of units of [type] for given [player]
lua_register(L, "CountInfantry", Script_CountInfantry); // Number of infantry of [type] for given [player]
lua_register(L, "CountVessels", Script_CountVessels); // Number of vessels of [type] for given [player]
lua_register(L, "SetTriggerCallback", Script_SetTriggerCallback); // Initiates a given [callback] on an existing [trigger]
/**********************************************************************************************
* Script Globals *
*=============================================================================================*/
lua_pushnumber(L, PlayerPtr->ID); // Local (human) player
lua_pushnumber(L, PlayerPtr->ID); // Local player (house) index
lua_setglobal(L, "_localPlayer");
+5
View File
@@ -1,6 +1,9 @@
// MapScript.h
//
#ifndef MAPSCRIPT_H
#define MAPSCRIPT_H
// Lua is written in C, so compiler needs to know how to link its libraries
extern "C" {
# include "lua.h"
@@ -15,6 +18,8 @@ class MapScript {
public:
bool Init(const char* mapName);
void CallFunction(const char* functionName);
void SetLuaPath(const char* input_path);
private:
lua_State* L;
};
#endif
+2 -2
View File
@@ -18,10 +18,10 @@ void GL_ResetClipRect(void) {
ImGui::GetForegroundDrawList()->PopClipRect();
}
void GL_RenderImage(Image_t* image, int x, int y, int width, int height) {
void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap) {
ImVec2 mi(x, y);
ImVec2 ma(x + width, y + height);
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->image, mi, ma);
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)image->image[colorRemap][0], mi, ma);
}
void GL_FillRect(int color, int x, int y, int width, int height) {
+1 -1
View File
@@ -2,7 +2,7 @@
//
struct Image_t;
void GL_RenderImage(Image_t* image, int x, int y, int width, int height);
void GL_RenderImage(Image_t* image, int x, int y, int width, int height, int colorRemap = 0);
void GL_DrawText(int color, int x, int y, char* text);
void GL_FillRect(int color, int x, int y, int width, int height);
void GL_DrawLine(int color, int x, int y, int dx, int dy);
+5 -5
View File
@@ -651,11 +651,6 @@ oh_dear_its_a_label:
}
}
/*
........................ Invoke game callback .........................
*/
Call_Back();
#ifdef WIN32
/*
** If we have just received input focus again after running in the background then
@@ -795,6 +790,11 @@ oh_dear_its_a_label:
bool droplist_is_dropped = housebtn.IsDropped;
input = commands->Input();
/*
........................ Invoke game callback .........................
*/
Call_Back();
Load_Title_Page(true);
/*
+7 -1
View File
@@ -164,6 +164,11 @@ void const * ObjectClass::Get_Image_Data(void) const
return(Class_Of().Get_Image_Data());
}
struct Image_t *ObjectClass::Get_HDImage_Data(void) const
{
return(Class_Of().Get_HDImage_Data());
}
/***********************************************************************************************
* ObjectClass::Name -- Fetches the identification name of this object. *
@@ -2177,7 +2182,8 @@ ObjectTypeClass::ObjectTypeClass(
Armor(ARMOR_NONE),
MaxStrength(0),
ImageData(0),
RadarIcon(0)
RadarIcon(0),
HDImageData(0)
{
/*
** Init the DimensionData rect. Not sure how this was ever working before without being allocated. It was just trashing
+1
View File
@@ -152,6 +152,7 @@ class ObjectClass : public AbstractClass
*/
virtual bool Is_Players_Army(void) const {return(false);}
virtual void const * Get_Image_Data(void) const;
virtual struct Image_t *Get_HDImage_Data(void) const;
virtual ActionType What_Action(ObjectClass const *) const;
virtual ActionType What_Action(CELL) const;
virtual LayerType In_Which_Layer(void) const;
+5 -2
View File
@@ -166,6 +166,10 @@ void PowerClass::Draw_It(bool complete)
0, -1, 0, 1, 0, -1, -2, -1, 0, 1, 2, 1 ,0
};
// jmarshall - render the world before the power bar.
RadarClass::Draw_It(complete);
// jmarshall end
{
BStart(BENCH_POWER);
@@ -244,8 +248,7 @@ void PowerClass::Draw_It(bool complete)
LogicPage->Unlock();
}
BEnd(BENCH_POWER);
}
RadarClass::Draw_It(complete);
}
}
+16 -8
View File
@@ -67,7 +67,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include "Image.h"
//void const * RadarClass::CoverShape;
RadarClass::RTacticalClass RadarClass::RadarButton;
@@ -1073,7 +1073,7 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
*/
if (color == TBLACK) {
if (ZoomFactor > 1) {
void const * ptr = NULL;
const TemplateTypeClass* ptr = NULL;
int icon;
/*
@@ -1081,7 +1081,7 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
** specified cell.
*/
if (cellptr->TType != TEMPLATE_NONE && cellptr->TType != 255) {
ptr = TemplateTypeClass::As_Reference(cellptr->TType).Get_Image_Data();
ptr = &TemplateTypeClass::As_Reference(cellptr->TType);
icon = cellptr->TIcon;
}
@@ -1090,11 +1090,11 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
** template or an illegal one. Setup for a clear template.
*/
if (ptr == NULL) {
ptr = TemplateTypeClass::As_Reference(TEMPLATE_CLEAR1).Get_Image_Data();
ptr = &TemplateTypeClass::As_Reference(TEMPLATE_CLEAR1);
icon = cellptr->Clear_Icon();
}
IconsetClass const * iconset = (IconsetClass const *)ptr;
IconsetClass const * iconset = (IconsetClass const *)ptr->Get_Image_Data();
unsigned char const * icondata = iconset->Icon_Data();
@@ -1103,10 +1103,18 @@ void RadarClass::Plot_Radar_Pixel(CELL cell)
*/
icon &= 0x00FF;
icon = *(iconset->Map_Data() + icon);
// jmarshall
unsigned char * data = (unsigned char *)icondata + icon*(24*24);
Buffer_To_Page(0, 0, 24, 24, data, _TileStage);
_TileStage.Scale(*LogicPage, 0, 0, x, y, 24, 24, ZoomFactor, ZoomFactor, TRUE);
Image_t* image;
{
char tmp[512];
sprintf(tmp, "radar_%d_%d", ptr->Type, icon);
image = Image_CreateImageFrom8Bit(tmp, 24, 24, (unsigned char*)data);
}
GL_RenderImage(image, x, y, ZoomFactor, ZoomFactor);
// jmarshall end
//Buffer_To_Page(0, 0, 24, 24, data, _TileStage);
//_TileStage.Scale(*LogicPage, 0, 0, x, y, 24, 24, ZoomFactor, ZoomFactor, TRUE);
} else {
// LogicPage->Fill_Rect(x, y, x+ZoomFactor-1, y+ZoomFactor-1, cellptr->Cell_Color(false));
/*BG*/ LogicPage->Put_Pixel(x, y, cellptr->Cell_Color(false));
+12 -14
View File
@@ -60,7 +60,6 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include "MapScript.h"
#ifdef WIN32
#include "tcpip.h"
#include "ccdde.h"
@@ -111,7 +110,6 @@ bool Is_Mission_Counterstrike (char *file_name);
bool Is_Mission_Aftermath (char *file_name);
#endif
MapScript* mapScript = nullptr;
bool mapScriptPlayStart = false;
void Cmd_Map(void);
@@ -332,13 +330,13 @@ bool Start_Scenario(char * name, bool briefing)
}
// jmarshall: map scripts
if (mapScript) {
delete mapScript;
if (Scen.mapScript) {
delete Scen.mapScript;
}
mapScript = new MapScript();
if (!mapScript->Init(name)) {
delete mapScript;
mapScript = nullptr;
Scen.mapScript = new MapScript();
if (!Scen.mapScript->Init(name)) {
delete Scen.mapScript;
Scen.mapScript = nullptr;
}
else {
mapScriptPlayStart = true;
@@ -379,11 +377,11 @@ bool Start_Scenario(char * name, bool briefing)
// }
Theme.Stop();
// jmarshall - map scripts
if (mapScript) {
if (Scen.mapScript) {
Hide_Mouse();
VisiblePage.Clear();
Show_Mouse();
mapScript->CallFunction("map_briefing");
Scen.mapScript->CallFunction("map_briefing");
}
else if (briefing) {
Hide_Mouse();
@@ -430,16 +428,16 @@ bool Start_Scenario(char * name, bool briefing)
}
void Scenario_MapScriptFrame(void) {
if (!mapScript)
if (!Scen.mapScript)
return;
if (mapScriptPlayStart) {
mapScript->CallFunction("map_start");
Scen.mapScript->CallFunction("map_start");
mapScriptPlayStart = false;
return;
}
mapScript->CallFunction("map_frame");
Scen.mapScript->CallFunction("map_frame");
}
@@ -1628,7 +1626,7 @@ int BGMessageBox(char const * msg, int btn1, int btn2)
HidPage.Blit(SeenPage);
#ifdef WIN32
VisiblePage.Blit(seen_buff_save);
//VisiblePage.Blit(seen_buff_save);
#endif
static unsigned char _scorepal[]={0,1,12,13,4,5,6,7,8,9,10,255,252,253,14,248};
+8
View File
@@ -36,6 +36,8 @@
#ifndef SCENARIO_H
#define SCENARIO_H
#include "MapScript.h"
/*
** This class holds the information about the current game being played. This information is
@@ -328,6 +330,12 @@ class ScenarioClass {
#endif
bool warpIntoMap;
/*
** MapScript storage, to be accessed by triggers etc.
*/
MapScript* mapScript = nullptr;
};
+2 -2
View File
@@ -924,8 +924,8 @@ void Read_Setup_Options( RawFileClass *config_file )
VideoBackBufferAllowed = ini.Get_Bool("Options", "VideoBackBuffer", true);
AllowHardwareBlitFills = ini.Get_Bool("Options", "HardwareFills", true);
ScreenWidth = 1024;
ScreenHeight = 768;
ScreenWidth = 1280;
ScreenHeight = 720;
/*
** See if an alternative socket number has been specified
+145 -100
View File
@@ -28,10 +28,20 @@
* A full copy of the GNU General Public License can be found in
* LICENSE
*/
/*
============================
This file has been heavily modified by IceColdDuke(Justin Marshall) to render with OpenGL.
============================
*/
#include "FUNCTION.H"
#include <cstdarg>
#include <cstring>
#include "Image.h"
#define le16toh(x) x
#define le32toh(x) x
@@ -99,6 +109,13 @@ static uint8_t* g_PredatorLimit = nullptr;
typedef void (*BF_Function)(int, int, uint8_t*, uint8_t*, int, int, uint8_t*, uint8_t*, uint8_t*, int);
typedef void (*Single_Line_Function)(int, uint8_t*, uint8_t*, uint8_t*, uint8_t*, uint8_t*, int);
bool renderHDTexture = false;
void Buffer_Enable_HD_Texture(bool hdTextureEnabled) {
renderHDTexture = hdTextureEnabled;
}
#define ChannelBlend_Alpha(A,B,O) ((uint8_t)((O / 255.0f) * A + (1 - (O / 255.0f)) * B))
// Just copy source to dest as is.
void BF_Copy(int width, int height, uint8_t* dst, uint8_t* src, int dst_pitch, int src_pitch, uint8_t* ghost_lookup,
uint8_t* ghost_tab, uint8_t* fade_tab, int count)
@@ -114,20 +131,23 @@ void BF_Copy(int width, int height, uint8_t* dst, uint8_t* src, int dst_pitch, i
void BF_Trans(int width, int height, uint8_t* dst, uint8_t* src, int dst_pitch, int src_pitch, uint8_t* ghost_lookup,
uint8_t* ghost_tab, uint8_t* fade_tab, int count)
{
while (height--) {
for (int i = width; i > 0; --i) {
uint8_t sbyte = *src++;
while (height--) {
for (int i = width; i > 0; --i) {
uint8_t sbyte = *src++;
if (sbyte) {
*dst = sbyte;
}
if (sbyte) {
dst[0] = backbuffer_palette[(sbyte * 3) + 0];
dst[1] = backbuffer_palette[(sbyte * 3) + 1];
dst[2] = backbuffer_palette[(sbyte * 3) + 2];
dst[3] = 255;
}
++dst;
}
dst += 4;
}
src += src_pitch;
dst += dst_pitch;
}
src += src_pitch;
dst += dst_pitch * 4;
}
}
// Fading table based shadow and transparency
@@ -166,14 +186,17 @@ void BF_Ghost_Trans(int width, int height, uint8_t* dst, uint8_t* src, int dst_p
sbyte = ghost_tab[*dst + fbyte * 256];
}
*dst = sbyte;
dst[0] = backbuffer_palette[(sbyte * 3) + 0];
dst[1] = backbuffer_palette[(sbyte * 3) + 1];
dst[2] = backbuffer_palette[(sbyte * 3) + 2];
dst[3] = 255;
}
++dst;
dst += 4;
}
src += src_pitch;
dst += dst_pitch;
dst += dst_pitch * 4;
}
}
@@ -258,14 +281,17 @@ void BF_Ghost_Fading_Trans(int width, int height, uint8_t* dst, uint8_t* src, in
sbyte = fade_tab[sbyte];
}
*dst = sbyte;
dst[0] = backbuffer_palette[(sbyte * 3) + 0];
dst[1] = backbuffer_palette[(sbyte * 3) + 1];
dst[2] = backbuffer_palette[(sbyte * 3) + 2];
dst[3] = 255;
}
++dst;
dst += 4;
}
src += src_pitch;
dst += dst_pitch;
dst += dst_pitch * 4;
}
}
@@ -1370,7 +1396,7 @@ static void Single_Line_Flagger(
}
}
long Buffer_Frame_To_Page(int x, int y, int width, int height, void* shape, GraphicViewPortClass& viewport, int flags, ...)
long Buffer_Frame_To_Page(int x, int y, int width, int height, struct Image_t * shape_image, unsigned int Window, int flags, ...)
{
BOOL use_old_drawer = false;
int fade_count = 0;
@@ -1379,27 +1405,10 @@ long Buffer_Frame_To_Page(int x, int y, int width, int height, void* shape, Grap
uint8_t* ghost_table = nullptr;
uint8_t* ghost_lookup = nullptr;
if (!shape) {
if (!shape_image) {
return 0;
}
uint8_t* frame_data = static_cast<uint8_t*>(shape);
if (UseOldShapeDraw) {
use_old_drawer = true;
}
else if (UseBigShapeBuffer) {
draw_header = static_cast<ShapeBufferHeader*>(shape);
uint8_t* shape_buff = reinterpret_cast<uint8_t*>(BigShapeBufferStart);
if (draw_header->m_IsTheaterShape) {
shape_buff = reinterpret_cast<uint8_t*>(TheaterShapeBufferStart);
}
frame_data = shape_buff + draw_header->m_FrameOffset;
use_old_drawer = false;
}
va_list ap;
va_start(ap, flags);
@@ -1426,10 +1435,6 @@ long Buffer_Frame_To_Page(int x, int y, int width, int height, void* shape, Grap
use_old_drawer = true;
}
if (use_old_drawer != true && (draw_header->m_DrawFlags == 0xFFFFFFFF || draw_header->m_DrawFlags != (flags & 0x1340))) {
Single_Line_Flagger(width, height, frame_data, draw_header, flags, ghost_table, ghost_lookup);
}
// Sets for BF_Fading functions
if (flags & SHAPE_FADING) {
fade_table = va_arg(ap, uint8_t*);
@@ -1451,18 +1456,18 @@ long Buffer_Frame_To_Page(int x, int y, int width, int height, void* shape, Grap
}
// Sets for BF_Predator functions
if (flags & SHAPE_PREDATOR) {
int current_frame = va_arg(ap, uint32_t);
blit_style |= 8;
g_PredFrame = ((unsigned)current_frame) % 8;
g_PartialCount = 0;
g_PartialPred = 256;
// Calculates the end of the visible display buffer, hopefully prevent crashes from predator effect.
// Unused by default in RA, but would be nice on the phase tank in Aftermath.
g_PredatorLimit = (uint8_t*)(viewport.Get_Offset()) + viewport.Get_Full_Pitch() * viewport.Get_Height();
}
//if (flags & SHAPE_PREDATOR) {
// int current_frame = va_arg(ap, uint32_t);
// blit_style |= 8;
//
// g_PredFrame = ((unsigned)current_frame) % 8;
// g_PartialCount = 0;
// g_PartialPred = 256;
//
// // Calculates the end of the visible display buffer, hopefully prevent crashes from predator effect.
// // Unused by default in RA, but would be nice on the phase tank in Aftermath.
// g_PredatorLimit = (uint8_t*)(viewport.Get_Offset()) + viewport.Get_Full_Pitch() * viewport.Get_Height();
//}
if (flags & SHAPE_PARTIAL) {
g_PartialPred = va_arg(ap, int) & 0xFF;
@@ -1477,67 +1482,107 @@ long Buffer_Frame_To_Page(int x, int y, int width, int height, void* shape, Grap
int ms_img_offset = 0;
// If we aren't drawing within the viewport, return.
if (xstart >= viewport.Get_Width() || ystart >= viewport.Get_Height() || xend <= 0 || yend <= 0) {
return 0;
}
//if (xstart >= viewport.Get_Width() || ystart >= viewport.Get_Height() || xend <= 0 || yend <= 0) {
// return 0;
//}
// Do any needed clipping.
if (xstart < 0) {
ms_img_offset = -xstart;
xstart = 0;
use_old_drawer = true;
}
//if (xstart < 0) {
// ms_img_offset = -xstart;
// xstart = 0;
// use_old_drawer = true;
//}
//
//if (ystart < 0) {
// //frame_data += width * (-ystart);
// ystart = 0;
// use_old_drawer = true;
//}
if (ystart < 0) {
frame_data += width * (-ystart);
ystart = 0;
use_old_drawer = true;
}
if (xstart + width < 0 || ystart + height < 0)
return 0;
if (xend >= viewport.Get_Width() - 1) {
xend = viewport.Get_Width() - 1;
use_old_drawer = true;
}
if (yend >= viewport.Get_Height() - 1) {
yend = viewport.Get_Height() - 1;
use_old_drawer = true;
}
// if (xend >= viewport.Get_Width() - 1) {
// xend = viewport.Get_Width() - 1;
// use_old_drawer = true;
// }
//
// if (yend >= viewport.Get_Height() - 1) {
// yend = viewport.Get_Height() - 1;
// use_old_drawer = true;
// }
int blit_width = xend - xstart + 1;
int blit_height = yend - ystart + 1;
int pitch = viewport.Get_Full_Pitch();
uint8_t* dst = ystart * pitch + xstart + (uint8_t*)(viewport.Get_Offset());
uint8_t* src = frame_data + ms_img_offset;
int dst_pitch = pitch - blit_width;
int src_pitch = width - blit_width;
//int pitch = viewport.Get_Full_Pitch();
//uint8_t* dst = (ystart * pitch * 4) + (xstart * 4) + (uint8_t*)(viewport.Get_Offset());
//uint8_t* src = frame_data + ms_img_offset;
//if (renderHDTexture) {
// Image_t* image = (Image_t*)shape;
// src = image->buffer + (ms_img_offset * 4);
//}
//int dst_pitch = pitch - blit_width;
//int src_pitch = width - blit_width;
// Use "new" line drawing routines that appear to have been added during the windows port.
if (use_old_drawer != true) {
// DEBUG_SAY("Drawing with Single_Line draw functions\n");
// Here we can use the individual line drawing routines
// Means we can skip drawing some lines all together or avoid using
// more expensive routines on some lines.
uint8_t* line_flags = reinterpret_cast<uint8_t*>(draw_header + 1);
for (int i = 0; i < blit_height; ++i) {
NewShapeJumpTable[line_flags[i] & 0x1F](blit_width, dst, src, ghost_lookup, ghost_table, fade_table, fade_count);
src += width;
dst += pitch;
}
return 0;
}
//if (use_old_drawer != true && !renderHDTexture) {
// // DEBUG_SAY("Drawing with Single_Line draw functions\n");
//
// // Here we can use the individual line drawing routines
// // Means we can skip drawing some lines all together or avoid using
// // more expensive routines on some lines.
// uint8_t* line_flags = reinterpret_cast<uint8_t*>(draw_header + 1);
//
// for (int i = 0; i < blit_height; ++i) {
// NewShapeJumpTable[line_flags[i] & 0x1F](blit_width, dst, src, ghost_lookup, ghost_table, fade_table, fade_count);
// src += width;
// dst += pitch * 4;
// }
//
// return 0;
//}
xstart = xstart + WindowList[Window][WINDOWX];// + LogicPage->Get_XPos();
ystart = ystart + WindowList[Window][WINDOWY];// + LogicPage->Get_YPos();
//GL_SetClipRect(WindowList[Window][WINDOWX], WindowList[Window][WINDOWY], WindowList[Window][WINDOWWIDTH], WindowList[Window][WINDOWWIDTH]);
if(renderHDTexture)
GL_RenderImage(shape_image, xstart, ystart, width, height, (int)fade_table);
else
GL_RenderImage(shape_image, xstart, ystart, width, height, 0);
// Here we just use the function that will blit the entire frame
// using the appropriate effects.
if (blit_height > 0 && blit_width > 0) {
// DEBUG_SAY("Drawing with BF draw functions\n");
OldShapeJumpTable[blit_style & 0xF](
blit_width, blit_height, dst, src, dst_pitch, src_pitch, ghost_lookup, ghost_table, fade_table, fade_count);
}
//if (blit_height > 0 && blit_width > 0) {
// // DEBUG_SAY("Drawing with BF draw functions\n");
// if (!renderHDTexture)
// {
// OldShapeJumpTable[blit_style & 0xF](blit_width, blit_height, dst, src, dst_pitch, src_pitch, ghost_lookup, ghost_table, fade_table, fade_count);
// }
// else
// {
// int src_index = 0;
// for (int f = 0; f < height; f++)
// {
// for (int i = width; i > 0; --i) {
// //if (src_index >= ((f + 1) * blit_height * 4))
// // break;
//
// if (src[src_index + 3] > 0) {
// dst[0] = ChannelBlend_Alpha(src[(src_index) + 0], dst[0], src[(src_index) + 3]);
// dst[1] = ChannelBlend_Alpha(src[(src_index) + 1], dst[1], src[(src_index) + 3]);
// dst[2] = ChannelBlend_Alpha(src[(src_index) + 2], dst[2], src[(src_index) + 3]);
// dst[3] = 255;
// }
// src_index += 4;
// dst += 4;
// }
//
// src_index += src_pitch * 4;
// dst += dst_pitch * 4;
// }
// }
//}
return 0;
}
+13
View File
@@ -4450,6 +4450,19 @@ VisualType TechnoClass::Visual_Character(bool raw) const
return(VISUAL_HIDDEN);
}
void TechnoClass::Techno_Draw_Object_HD(struct Image_t* image, int shapenum, int x, int y, WindowNumberType window, DirType rotation, int scale) const {
//void const* remap = Remap_Table();
void const* shadow = Map.UnitShadow;
PlayerColorType remapColor = PCOLOR_GOLD;
if (Techno_Type_Class()->IsRemappable) {
remapColor = House->RemapColor;
}
y -= Lepton_To_Pixel(Height);
CC_Draw_Shape(image, shapenum, x, y, window, SHAPE_CENTER | SHAPE_WIN_REL | SHAPE_FADING | SHAPE_GHOST, (const void *)remapColor, shadow, rotation);
}
/***********************************************************************************************
* TechnoClass::Techno_Draw_Object -- General purpose draw object routine. *
+3
View File
@@ -369,6 +369,9 @@ class TechnoClass : public RadioClass,
virtual void const * Remap_Table(void) const;
VisualType Visual_Character(bool raw = false) const;
void Techno_Draw_Object(void const * shapefile, int shapenum, int x, int y, WindowNumberType window, DirType rotation=DIR_N, int scale=0x0100) const;
// jmarshall
void Techno_Draw_Object_HD(struct Image_t* image, int shapenum, int x, int y, WindowNumberType window, DirType rotation = DIR_N, int scale = 0x0100) const;
// jmarshall end
// Added. ST - 8/1/2019 5:37PM
void Techno_Draw_Object_Virtual(void const * shapefile, int shapenum, int x, int y, WindowNumberType window, DirType rotation=DIR_N, int scale=0x0100, const char *shape_name = NULL) const;
+341
View File
@@ -0,0 +1,341 @@
/**
* @file
*
* @author CCHyper
* @author OmniBlade
*
* @brief Low level functions for loading and rendering C&C terrain tilesets.
*
* @copyright Chronoshift is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version
* 2 of the License, or (at your option) any later version.
* A full copy of the GNU General Public License can be found in
* LICENSE
*/
/*
============================
This file has been heavily modified by IceColdDuke(Justin Marshall) to render with OpenGL.
============================
*/
#include "FUNCTION.H"
#include "gbuffer.h"
#include "Image.h"
#include <cstring>
using std::memcpy;
class GraphicViewPortClass;
#define TD_TILESET_CHECK 0x20
Image_t* tileset_icon_cache[4096];
/**
* @brief union is to handle the parts of the header which vary between TD and RA format tiles.
*/
struct IconControlType
{
uint8_t* Get_Icon_Data()
{
if (td.icons == TD_TILESET_CHECK) {
return reinterpret_cast<uint8_t*>(this) + td.icons;
}
else {
return reinterpret_cast<uint8_t*>(this) + ra.icons;
}
}
uint8_t* Get_Icon_Map()
{
if (td.icons == TD_TILESET_CHECK) {
return reinterpret_cast<uint8_t*>(this) + td.map;
}
else {
return reinterpret_cast<uint8_t*>(this) + ra.map;
}
}
int16_t width; // always 24 (ICON_WIDTH)
int16_t height; // always 24 (ICON_HEIGHT)
int16_t count; // count of cells in set, not same as images
int16_t allocated; // is treated like a bool, always 0 in the file?
union
{
struct
{
int32_t size; // filesize
int32_t icons; // always 0x00000020
int32_t palettes; // seems to always be 0x00000000
int32_t remaps; // unknown, bitfield?
int32_t trans_flag; // array of images length, unknown
int32_t map; // image index for each cell
} td;
struct
{
int16_t map_width; // tile width in cells
int16_t map_height; // tile height in cells
int32_t size; // filesize
int32_t icons; // always 0x00000028
int32_t palettes; // seems to always be 0x00000000
int32_t remaps; // unknown, bitfield?
int32_t trans_flag; // array of images length, unknown
int32_t color_map; // terrain type index, ra only
int32_t map; // image index for each cell
} ra;
};
};
static int IconEntry;
static void* IconData;
static IconControlType* LastIconset;
static uint8_t* StampPtr;
static uint8_t* TransFlagPtr;
static uint8_t* MapPtr;
static int IconWidth;
static int IconHeight;
static int IconSize;
static int IconCount;
void __cdecl Init_Stamps(IconControlType* iconset)
{
memset(&tileset_icon_cache, 0, sizeof(tileset_icon_cache));
if (iconset && LastIconset != iconset) {
IconCount = (iconset->count);
IconWidth = (iconset->width);
IconHeight = (iconset->height);
LastIconset = iconset;
IconSize = IconWidth * IconHeight;
// TD and RA tileset headers are slightly different, so check a constant that only exists in one type.
if ((iconset->td.icons) == TD_TILESET_CHECK) {
MapPtr = reinterpret_cast<uint8_t*>(iconset) + (iconset->td.map);
StampPtr = reinterpret_cast<uint8_t*>(iconset) + (iconset->td.icons);
TransFlagPtr = reinterpret_cast<uint8_t*>(iconset) + (iconset->td.trans_flag);
}
else {
MapPtr = reinterpret_cast<uint8_t*>(iconset) + (iconset->ra.map);
StampPtr = reinterpret_cast<uint8_t*>(iconset) + (iconset->ra.icons);
TransFlagPtr = reinterpret_cast<uint8_t*>(iconset) + (iconset->ra.trans_flag);
}
}
}
void __cdecl Buffer_Draw_Stamp2(GraphicViewPortClass& viewport, IconControlType* tileset, int icon, int x, int y, const void* remapper)
{
if (!tileset) {
return;
}
if (LastIconset != tileset) {
Init_Stamps(tileset);
}
int32_t icon_index = MapPtr != nullptr ? MapPtr[icon] : icon;
if (icon_index < IconCount) {
int32_t fullpitch = viewport.Get_Full_Pitch(); //(viewport.Get_Pitch() + viewport.Get_XAdd() + viewport.Get_Width());
uint8_t* dst = (x * 4) + (y * 4) * fullpitch + (uint8_t*)(viewport.Get_Offset());
int32_t blitpitch = fullpitch - IconWidth;
uint8_t* src = &StampPtr[IconSize * icon_index];
if (remapper) {
const uint8_t* remap = static_cast<const uint8_t*>(remapper);
for (int i = 0; i < IconHeight; ++i) {
for (int j = 0; j < IconWidth; ++j) {
uint8_t cur_byte = remap[*src++];
if (cur_byte) {
dst[0] = backbuffer_data_raw[(cur_byte * 3) + 0];
dst[1] = backbuffer_data_raw[(cur_byte * 3) + 1];
dst[2] = backbuffer_data_raw[(cur_byte * 3) + 2];
dst[3] = 255;
}
dst+=4;
}
dst += blitpitch;
}
}
else if (TransFlagPtr[icon_index]) {
for (int i = 0; i < IconHeight; ++i) {
for (int j = 0; j < IconWidth; ++j) {
uint8_t cur_byte = *src++;
if (cur_byte) {
dst[0] = backbuffer_data_raw[(cur_byte * 3) + 0];
dst[1] = backbuffer_data_raw[(cur_byte * 3) + 1];
dst[2] = backbuffer_data_raw[(cur_byte * 3) + 2];
dst[3] = 255;
}
dst += 4;
}
dst += blitpitch;
}
}
else {
for (int32_t i = 0; i < IconHeight; ++i) {
FastScanlinePaletteBlit(dst, src, IconWidth);
dst += fullpitch;
src += IconWidth * 4;
}
}
}
}
void __cdecl Buffer_Draw_Stamp_Clip2(GraphicViewPortClass& viewport, const void *icondata, int icon, int x, int y, const void* remapper, int left, int top, int right, int bottom)
{
const TemplateTypeClass* ttype = (TemplateTypeClass const*)icondata;
IconControlType* tileset = (IconControlType * )ttype->Get_Image_Data();
// This is a awful hack, but need type info to generate unique id's for tileset generation.
if (icondata == DisplayClass::TransIconset) {
tileset = (IconControlType*)DisplayClass::TransIconset;
ttype = NULL;
}
if (!tileset) {
return;
}
if (LastIconset != tileset) {
Init_Stamps(tileset);
}
int icon_index = MapPtr != nullptr ? MapPtr[icon] : icon;
if (icon_index < IconCount) {
int blit_height = IconHeight;
int blit_width = IconWidth;
uint8_t* src = &StampPtr[IconSize * icon_index];
int width = left + right;
int xstart = left + x;
int height = top + bottom;
int ystart = top + y;
//
if (!tileset_icon_cache[icon_index]) {
char tmp[512];
if (ttype != NULL) {
sprintf(tmp, "icon_%d_%d", ttype->Type, icon_index);
}
else {
sprintf(tmp, "icon_%d_%d", icondata, icon_index);
}
tileset_icon_cache[icon_index] = Image_CreateImageFrom8Bit(tmp, IconWidth, IconHeight, (unsigned char *)src);
}
if (xstart < width && ystart < height && IconHeight + ystart > top && IconWidth + xstart > left) {
if (xstart < left) {
src += left - xstart;
blit_width -= left - xstart;
xstart = left;
}
int src_pitch = IconWidth - blit_width;
if (blit_width + xstart > width) {
src_pitch += blit_width - (width - xstart);
blit_width = width - xstart;
}
if (top > ystart) {
blit_height = IconHeight - (top - ystart);
src += IconWidth * (top - ystart);
ystart = top;
}
if (blit_height + ystart > height) {
blit_height = height - ystart;
}
int full_pitch = viewport.Get_Full_Pitch(); //(viewport.Get_Pitch() + viewport.Get_XAdd() + viewport.Get_Width());
uint8_t* dst = (xstart * 4) + (ystart * 4) * full_pitch + (uint8_t*)(viewport.Get_Offset());
int dst_pitch = full_pitch - blit_width;
//if (remapper) {
// const uint8_t* remap = static_cast<const uint8_t*>(remapper);
// for (int i = 0; i < blit_height; ++i) {
// for (int j = 0; j < blit_width; ++j) {
// uint8_t cur_byte = remap[*src++];
// if (cur_byte) {
// dst[0] = backbuffer_data_raw[(cur_byte * 3) + 0];
// dst[1] = backbuffer_data_raw[(cur_byte * 3) + 1];
// dst[2] = backbuffer_data_raw[(cur_byte * 3) + 2];
// dst[3] = 255;
// }
//
// dst += 4;
// }
// dst += dst_pitch * 4;
// }
//
//}
//else if (TransFlagPtr[icon_index]) {
// for (int i = 0; i < blit_height; ++i) {
// for (int j = 0; j < blit_width; ++j) {
// uint8_t cur_byte = *src++;
// if (cur_byte) {
// dst[0] = backbuffer_data_raw[(cur_byte * 3) + 0];
// dst[1] = backbuffer_data_raw[(cur_byte * 3) + 1];
// dst[2] = backbuffer_data_raw[(cur_byte * 3) + 2];
// dst[3] = 255;
// }
//
// dst += 4;
// }
// src += src_pitch;
// dst += dst_pitch * 4;
// }
//
//}
//else {
{
//for (int i = 0; i < blit_height; ++i) {
// FastScanlinePaletteBlit(dst, src, blit_width);
// dst += full_pitch * 4;
// src += IconWidth;
//}
GL_SetClipRect(xstart, ystart, blit_width, blit_height);
GL_RenderImage(tileset_icon_cache[icon_index], xstart, ystart, blit_width, blit_height);
GL_ResetClipRect();
}
}
}
}
extern "C" void __cdecl Buffer_Draw_Stamp_Clip(void const* this_object, void const* icondata, int icon, int x_pixel, int y_pixel, void const* remap, int min_x, int min_y, int max_x, int max_y) {
if (icondata == NULL)
return;
Buffer_Draw_Stamp_Clip2(*((GraphicViewPortClass*)this_object), icondata, icon, x_pixel, y_pixel, remap, min_x, min_y, max_x, max_y);
}
extern "C" void __cdecl Buffer_Draw_Stamp(void const* thisptr, void const* icondata, int icon, int x_pixel, int y_pixel, void const* remap) {
Buffer_Draw_Stamp2(*((GraphicViewPortClass*)thisptr), (IconControlType*)icondata, icon, x_pixel, y_pixel, remap);
}
uint8_t* Get_Icon_Set_Map(void* temp)
{
if (temp != nullptr) {
if ((static_cast<IconControlType*>(temp)->td.icons) == TD_TILESET_CHECK) {
return static_cast<uint8_t*>(temp) + (static_cast<IconControlType*>(temp)->td.icons);
}
else {
return static_cast<uint8_t*>(temp) + (static_cast<IconControlType*>(temp)->ra.icons);
}
}
return nullptr;
}
+37 -2
View File
@@ -45,6 +45,7 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#include "MapScript.h"
#if defined(CHEAT_KEYS) || defined(SCENARIO_EDITOR)
@@ -228,6 +229,7 @@ bool TriggerClass::Spring(TEventType event, ObjectClass * obj, CELL cell, bool f
bool e1 = Class->Event1(Event1, event, Class->House, obj, forced);
bool e2 = false;
bool execute = false;
bool execute_mapScript = false;
/*
** Forced triggers must presume that the cell parameter is invalid. It then
@@ -295,6 +297,13 @@ bool TriggerClass::Spring(TEventType event, ObjectClass * obj, CELL cell, bool f
}
}
/*
** We need to execute this trigger, so is there an attached MapScript callback?
*/
if (Scen.mapScript != NULL && strlen(MapScriptCallback) > 0) {
execute_mapScript = true;
}
/*
** For linked trigger events, perform the action associated with the matching
** trigger event. Otherwise perform the action for both events.
@@ -302,19 +311,45 @@ bool TriggerClass::Spring(TEventType event, ObjectClass * obj, CELL cell, bool f
bool ok = false;
HousesType hh = Class->House;
if (Class->EventControl == MULTI_LINKED) {
if (e1 || forced) ok |= Class->Action1(hh, obj, ID, cell);
if (e2 && !forced) ok |= Class->Action2(hh, obj, ID, cell);
if (e1 || forced) {
ok |= Class->Action1(hh, obj, ID, cell);
// Execute MapScript Callback for action 1?
if (ok && execute_mapScript && MapScriptActionIndex <= 1) {
Scen.mapScript->CallFunction(MapScriptCallback);
}
}
if (e2 && !forced) {
ok |= Class->Action2(hh, obj, ID, cell);
// Execute MapScript Callback for action 2?
if (ok && execute_mapScript && MapScriptActionIndex != 1) {
Scen.mapScript->CallFunction(MapScriptCallback);
}
}
} else {
switch (Class->ActionControl) {
case MULTI_ONLY:
ok |= Class->Action1(hh, obj, ID, cell);
// Execute MapScript Callback for action 1?
if (ok && execute_mapScript && MapScriptActionIndex <= 1) {
Scen.mapScript->CallFunction(MapScriptCallback);
}
break;
default:
case MULTI_AND:
ok |= Class->Action1(hh, obj, ID, cell);
ok |= Class->Action2(hh, obj, ID, cell);
// Execute MapScript Callback for action?
if (ok && execute_mapScript) {
Scen.mapScript->CallFunction(MapScriptCallback);
}
break;
}
}
+6
View File
@@ -115,6 +115,12 @@ class TriggerClass {
** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
*/
unsigned char SaveLoadPadding[32];
/*
** Store MapScript callback function and optional action index (because there can be multiple outcomes) -- JJ 6/14/2020
*/
char MapScriptCallback[32];
char MapScriptActionIndex;
};
+6 -1
View File
@@ -257,7 +257,9 @@ class ObjectTypeClass : public AbstractTypeClass
** The "mutable" keyword allows easy modification to this otherwise const object.
*/
void const * ImageData;
// jmarshall
struct Image_t *HDImageData;
// jmarshall end
/*
** Points to the dimension data for each shape in the image list. By using this
** data, the minimum number of cells will be redrawn when the object changes shape.
@@ -298,6 +300,9 @@ class ObjectTypeClass : public AbstractTypeClass
virtual short const * Overlap_List(void) const;
virtual BuildingClass * Who_Can_Build_Me(bool intheory, bool legal, HousesType house) const;
virtual void const * Get_Cameo_Data(void) const;
// jmarshall
struct Image_t* Get_HDImage_Data(void) const { return HDImageData; }
// jmarshall end
void const * Get_Image_Data(void) const {return ImageData;};
void const * Get_Radar_Data(void) const {return RadarIcon;};
+1 -2
View File
@@ -49,7 +49,7 @@
#include "function.h"
#include "Image.h"
// Submarine
static VesselTypeClass const VesselSubmarine(
@@ -578,7 +578,6 @@ void VesselTypeClass::One_Time(void)
*/
_makepath(fullname, NULL, NULL, uclass.Graphic_Name(), ".SHP");
((void const *&)uclass.ImageData) = MFCD::Retrieve(fullname);
((int &)uclass.MaxSize) = 26;
}
}
+3 -1
View File
@@ -935,7 +935,9 @@ void ChronalVortexClass::Render (void)
** Draw the template
*/
if (ttype->Get_Image_Data()) {
RenderBuffer->Draw_Stamp(ttype->Get_Image_Data(), icon, x*CELL_PIXEL_W, y*CELL_PIXEL_H, NULL, WINDOW_MAIN);
// jmarshall - send down the raw ttype
RenderBuffer->Draw_Stamp(ttype, icon, x*CELL_PIXEL_W, y*CELL_PIXEL_H, NULL, WINDOW_MAIN);
// jmarshall end
}
/*
+1
View File
@@ -43,6 +43,7 @@ extern "C" {
long __cdecl Buffer_To_Page(int x, int y, int w, int h, void *Buffer, void *view);
BOOL __cdecl Linear_Blit_To_Linear( void *thisptr, void * dest, int x_pixel, int y_pixel, int dx_pixel,
int dy_pixel, int pixel_width, int pixel_height, BOOL trans);
BOOL __cdecl Linear_Blit_To_Linear_Pal(void* this_object, void* dest, int src_x, int src_y, int dst_x, int dst_y, int w, int h, BOOL use_key);
BOOL __cdecl Linear_Scale_To_Linear( void *, void *, int, int, int, int, int, int, int, int, BOOL, char *);
LONG __cdecl Buffer_Print(void *thisptr, const char *str, int x, int y, int fcolor, int bcolor);
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -172,7 +172,7 @@ void GraphicViewPortClass::Attach(GraphicBufferClass *gbuffer, int x, int y, int
/*======================================================================*/
/* Get a pointer to the top left edge of the buffer. */
/*======================================================================*/
Offset = gbuffer->Get_Offset() + ((gbuffer->Get_Width()+gbuffer->Get_Pitch()) * y) + x;
Offset = gbuffer->Get_Offset() + ((gbuffer->Get_Width()+gbuffer->Get_Pitch()) * y * 4) + (x * 4);
/*======================================================================*/
/* Copy over all of the variables that we need to store. */
@@ -237,7 +237,7 @@ BOOL GraphicViewPortClass::Change(int x, int y, int w, int h)
*=========================================================================*/
void GraphicBufferClass::DD_Init(GBC_Enum flags)
{
rawCpuBuffer = new unsigned char[Width * Height];
rawCpuBuffer = new unsigned char[Width * Height * 4];
Allocated = FALSE; // even if system alloced, dont flag it cuz
// we dont want it freed.
@@ -280,7 +280,7 @@ void GraphicBufferClass::Init(int w, int h, void *buffer, long size, GBC_Enum fl
Buffer= (BYTE *)buffer; // point to it and mark
Allocated = FALSE; // it as user allocated
} else {
if (!Size) Size = w*h;
if (!Size) Size = w*h*4;
Buffer = new BYTE[Size]; // otherwise allocate it and
Allocated = TRUE; // mark it system alloced
}
+89 -30
View File
@@ -138,7 +138,31 @@
#include "iconcach.h"
#include "../NEWBLIT.H"
#include <stdint.h>
extern unsigned char* backbuffer_data_raw;
extern unsigned char backbuffer_palette[768];
__forceinline void FastScanlinePaletteBlit(uint8_t* dst, uint8_t* src, int length) {
for (int i = 0; i < length; i++) {
uint8_t color = src[i];
if (color == 0)
continue;
dst[(i * 4) + 0] = backbuffer_palette[(color * 3) + 0];
dst[(i * 4) + 1] = backbuffer_palette[(color * 3) + 1];
dst[(i * 4) + 2] = backbuffer_palette[(color * 3) + 2];
dst[(i * 4) + 3] = 255;
}
}
__forceinline void FastScanlinePaletteBlit(uint8_t* dst, uint8_t color, int length) {
for (int i = 0; i < length; i++) {
dst[(i * 4) + 0] = backbuffer_palette[(color * 3) + 0];
dst[(i * 4) + 1] = backbuffer_palette[(color * 3) + 1];
dst[(i * 4) + 2] = backbuffer_palette[(color * 3) + 2];
dst[(i * 4) + 3] = 255;
}
}
#ifndef FUNCTION_H
//#pragma off (unreferenced)
@@ -268,6 +292,7 @@ class GraphicViewPortClass {
int dy_pixel, int pixel_width, int pixel_height, BOOL trans = FALSE);
HRESULT Blit( GraphicViewPortClass& dest, int dx, int dy, BOOL trans = FALSE);
HRESULT Blit( GraphicViewPortClass& dest, BOOL trans = FALSE);
HRESULT BlitLegacy(GraphicViewPortClass& dest, BOOL trans = FALSE);
HRESULT Blit( VideoViewPortClass& dest, int x_pixel, int y_pixel, int dx_pixel,
int dy_pixel, int pixel_width, int pixel_height, BOOL trans = FALSE);
HRESULT Blit( VideoViewPortClass& dest, int dx, int dy, BOOL trans = FALSE);
@@ -796,6 +821,40 @@ inline HRESULT GraphicViewPortClass::Blit( GraphicViewPortClass& dest, int dx, i
}
/***************************************************************************
* GVPC::BLIT -- stub 3 to call curr graphic mode Blit to GVPC *
* *
* INPUT: *
* *
* OUTPUT: *
* *
* WARNINGS: *
* *
* HISTORY: *
* 01/06/1995 PWG : Created. *
*=========================================================================*/
inline HRESULT GraphicViewPortClass::BlitLegacy(GraphicViewPortClass& dest, BOOL trans)
{
HRESULT return_code = 0;
if (Lock()) {
if (dest.Lock()) {
return_code = (Linear_Blit_To_Linear_Pal(this, &dest, 0, 0
, 0, 0
, Width, Height, trans));
}
dest.Unlock();
}
Unlock();
return (return_code);
}
/***************************************************************************
* GVPC::BLIT -- stub 3 to call curr graphic mode Blit to GVPC *
* *
@@ -810,7 +869,7 @@ inline HRESULT GraphicViewPortClass::Blit( GraphicViewPortClass& dest, int dx, i
*=========================================================================*/
inline HRESULT GraphicViewPortClass::Blit( GraphicViewPortClass& dest, BOOL trans)
{
HRESULT return_code=0;
HRESULT return_code = 0;
if (Lock()) {
@@ -1063,28 +1122,28 @@ inline void GraphicViewPortClass::Draw_Stamp(void const * icondata, int icon, in
int cache_index=-1;
int drewit = 0;
if (IconCacheAllowed){
if (IsDirectDraw){
if (!remap){
cache_index = Is_Icon_Cached(icondata,icon);
}
if (cache_index != -1){
if (CachedIcons[cache_index].Get_Is_Cached() ){
CachedIcons[cache_index].Draw_It (GraphicBuff->Get_DD_Surface() , x_pixel, y_pixel,
WindowList[clip_window][WINDOWX] + XPos,
WindowList[clip_window][WINDOWY] +YPos,
WindowList[clip_window][WINDOWWIDTH],
WindowList[clip_window][WINDOWHEIGHT]);
CachedIconsDrawn++;
drewit = 1;
}
}
}
}
//if (IconCacheAllowed){
// if (IsDirectDraw){
// if (!remap){
// cache_index = Is_Icon_Cached(icondata,icon);
// }
//
// if (cache_index != -1){
// if (CachedIcons[cache_index].Get_Is_Cached() ){
// CachedIcons[cache_index].Draw_It (GraphicBuff->Get_DD_Surface() , x_pixel, y_pixel,
// WindowList[clip_window][WINDOWX] + XPos,
// WindowList[clip_window][WINDOWY] +YPos,
// WindowList[clip_window][WINDOWWIDTH],
// WindowList[clip_window][WINDOWHEIGHT]);
// CachedIconsDrawn++;
// drewit = 1;
// }
// }
// }
//}
if (drewit == 0) {
{
if (Lock()){
UnCachedIconsDrawn++;
extern int ScreenHeight, ScreenWidth;
@@ -1114,7 +1173,10 @@ inline VOID GraphicViewPortClass::Draw_Line(int sx, int sy, int dx, int dy, unsi
// Buffer_Draw_Line(this, sx, sy, dx, dy, color);
//}
//Unlock();
sx += XPos;
sy += YPos;
dx += XPos;
dy += YPos;
GL_DrawLine(color, sx, sy, dx, dy);
}
@@ -1132,14 +1194,11 @@ inline VOID GraphicViewPortClass::Draw_Line(int sx, int sy, int dx, int dy, unsi
*=========================================================================*/
inline VOID GraphicViewPortClass::Fill_Rect(int sx, int sy, int dx, int dy, unsigned char color)
{
// jmarshall
// Still needed for gameplay.
if (Lock()) {
Buffer_Fill_Rect(this, sx, sy, dx, dy, color);
Unlock();
}
//GL_FillRect(color, sx, sy, dx - sx, dy - sy);
// jmarshall end
sx += XPos;
sy += YPos;
dx += XPos;
dy += YPos;
GL_FillRect(color, sx - 1, sy - 1, (dx - sx) + 1, ((dy - sy) + 1));
}
+1 -1
View File
@@ -252,7 +252,7 @@ void WWMouseClass::RenderMouse(void) {
ImGui::SetMouseCursor(ImGuiMouseCursor_None);
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)current_cursor->image, mi, ma);
ImGui::GetForegroundDrawList()->AddImage((ImTextureID)current_cursor->image[0][0], mi, ma);
}
void WWMouseClass::Low_Show_Mouse(int x, int y)
+261 -36
View File
@@ -45,6 +45,7 @@
#include "examples/imgui_impl_sdl.h"
#include "function.h"
#include "il/il.h"
#include "il/ilu.h"
#include "image.h"
#ifdef WINSOCK_IPX
@@ -62,9 +63,11 @@
#include <examples/imgui_impl_opengl3.h>
#include <vector>
#include "HOUSECOLOR.H"
#include "IMGUTIL.H"
GLuint backbuffer_texture = -1;
byte* backbuffer_data;
//byte* backbuffer_data;
unsigned char* backbuffer_data_raw;
byte backbuffer_palette[768];
HWND MainWindow;
@@ -73,6 +76,8 @@ SDL_Window* game_window;
SDL_GLContext game_context;
int OverlappedVideoBlits = 0;
extern std::vector<const ObjectClass*> renderedFrameObjects;
bool renderConsole = false;
void (*Misc_Focus_Loss_Function)(void) = nullptr;
@@ -83,16 +88,86 @@ void (*Imgui_Dialog_Function)(void) = nullptr;
bool show_oldframebuffer = true;
void Show_OldFrameBuffer(bool show) {
show_oldframebuffer = show;
memset(backbuffer_data, 0, ScreenWidth * ScreenHeight * 4);
memset(backbuffer_data_raw, 0, ScreenWidth * ScreenHeight * 4);
}
std::vector<Image_t *> loaded_images;
Image_t* Image_LoadImage(const char* name) {
// 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];
unsigned char* Draw_Dropsample(const unsigned char* in, int inwidth, int inheight, int outwidth, int outheight);
/*
================
return a hash value for the filename
================
*/
static int64_t generateHashValue(const char* fname, const int size) {
uint32_t hash = 0x811c9dc5;
uint32_t prime = 0x1000193;
for (int i = 0; i < size; ++i) {
uint8_t value = fname[i];
hash = hash ^ value;
hash *= prime;
}
return hash;
}
/*
================
Image_WriteTGA
================
*/
void Image_WriteTGA(const char* filename, const byte* data, int width, int height, bool flipVertical) {
byte* buffer;
int i;
int bufferSize = width * height * 4 + 18;
int imgStart = 18;
buffer = (byte*)malloc(bufferSize);
memset(buffer, 0, 18);
buffer[2] = 2; // uncompressed type
buffer[12] = width & 255;
buffer[13] = width >> 8;
buffer[14] = height & 255;
buffer[15] = height >> 8;
buffer[16] = 32; // pixel size
if (!flipVertical) {
buffer[17] = (1 << 5); // flip bit, for normal top to bottom raster order
}
// swap rgba to bgra
for (i = imgStart; i < bufferSize; i += 4) {
buffer[i] = data[i - imgStart + 2]; // blue
buffer[i + 1] = data[i - imgStart + 1]; // green
buffer[i + 2] = data[i - imgStart + 0]; // red
buffer[i + 3] = data[i - imgStart + 3]; // alpha
}
char temp[512];
strcpy(temp, filename);
COM_SetExtension(temp, strlen(temp), ".tga");
FILE* f = fopen(temp, "wb");
fwrite(buffer, 1, bufferSize, f);
fclose(f);
free(buffer);
}
static char* Image_GetGeneratedName(Image_t* image, const char* name, int houseid, int animid, int64_t hash) {
static char generatedFileName[1024];
sprintf(generatedFileName, "cache/%d.%d.%d.tga", hash, houseid, animid);
return &generatedFileName[0];
}
static bool Image_loadHDImage(Image_t *image, const char* name, int houseid, int animid, int64_t hash, bool writeGenerated) {
// Check to see if we can load a generated image first.
// We only generate images that need a houseid
if (!writeGenerated && houseid >= 0) {
char* generatedImageName = Image_GetGeneratedName(image, name, houseid, animid, hash);
if (Image_loadHDImage(image, generatedImageName, houseid, animid, hash, true)) {
return true;
}
}
@@ -100,7 +175,14 @@ Image_t* Image_LoadImage(const char* name) {
ilGenImages(1, &ImageName);
ilBindImage(ImageName);
if (!ilLoadImage(name)) {
return NULL;
ilDeleteImages(1, &ImageName);
return false;
}
bool swapBGR = false;
if (strstr(name, ".TGA")) {
iluFlipImage();
swapBGR = true;
}
ILuint Width, Height, Bpp;
@@ -109,12 +191,28 @@ Image_t* Image_LoadImage(const char* name) {
Bpp = ilGetInteger(IL_IMAGE_BPP);
ILubyte* Data = ilGetData();
if (Bpp == 4 && houseid != -1 && !writeGenerated) {
//Buffer_Enable_HD_Texture(true);
//Data = Draw_Dropsample(Data, Width, Height, Width / 2, Height / 2);
//Buffer_Enable_HD_Texture(false);
//Width = Width / 2;
//Height = Height / 2;
for (int i = 0; i < Width * Height; i++) {
RenderTeamPalette(&Data[i * 4], *houseColors[houseid]);
}
}
GLuint texture;
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
if (Bpp == 4) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data);
if (swapBGR) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_BGRA, GL_UNSIGNED_BYTE, Data);
}
else {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, Data);
}
}
else if (Bpp == 3) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Width, Height, 0, GL_RGB, GL_UNSIGNED_BYTE, Data);
@@ -126,20 +224,141 @@ Image_t* Image_LoadImage(const char* name) {
assert(!"Unknown BPP in image!");
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
ilDeleteImages(1, &ImageName);
Image_t* image = new Image_t();
strcpy(image->name, name);
image->image = texture;
image->width = Width;
image->height = Height;
if(houseid == -1)
image->image[0][animid] = texture;
else
image->image[houseid][animid] = texture;
image->namehash = hash;
image->renderwidth = image->width = Width;
image->renderheight = image->height = Height;
//image->buffer[houseid][animid] = new unsigned char[Width * Height * Bpp];
//memcpy(image->buffer[houseid][animid], Data, Width * Height * Bpp);
if (!writeGenerated && Bpp == 4 && houseid >= 0) {
char* generatedImageName = Image_GetGeneratedName(image, name, houseid, animid, hash);
Image_WriteTGA(generatedImageName, Data, Width, Height, false);
}
ilDeleteImages(1, &ImageName);
return true;
}
Image_t* Image_LoadImage(const char* name, bool loadAnims, bool loadHouseColor) {
int64_t hash = generateHashValue(name, strlen(name));
int image_table_size = loaded_images.size();
if (image_table_size > 0)
{
Image_t** image_table = &loaded_images[0];
// Check to see if the image is already loaded.
for (int i = 0; i < image_table_size; i++) {
if (image_table[i]->namehash == hash) {
return image_table[i];
}
}
}
Image_t* image = new Image_t();
if (!loadAnims) {
unsigned char remap[3] = { 0, 0, 0 };
if (!Image_loadHDImage(image, name, -1, 0, hash, false)) {
delete image;
return NULL;
}
}
else {
byte* palette = (byte *)CCPalette.Get_Data();
for (int i = 0; i < MAX_MPLAYER_COLORS; i++) {
if (!Image_loadHDImage(image, name, i, 0, hash, false)) {
delete image;
return NULL;
}
}
}
loaded_images.push_back(image);
return image;
}
Image_t* Image_CreateImageFrom8Bit(const char* name, int Width, int Height, unsigned char *data, unsigned char* remap) {
int64_t hash = generateHashValue(name, strlen(name));
int image_table_size = loaded_images.size();
if (image_table_size > 0)
{
Image_t** image_table = &loaded_images[0];
// Check to see if the image is already loaded.
for (int i = 0; i < image_table_size; i++) {
if (image_table[i]->namehash == hash) {
return image_table[i];
}
}
}
unsigned char* ccpalete = (unsigned char*)CCPalette.Get_Data();
Image_t* image = new Image_t();
unsigned char *buffer = new unsigned char[Width * Height * 4];
for (int i = 0; i < Width * Height; i++) {
unsigned char c = data[i];
if (remap) {
c = remap[c];
}
unsigned char r = ccpalete[(c * 3) + 0] << 2;
unsigned char g = ccpalete[(c * 3) + 1] << 2;
unsigned char b = ccpalete[(c * 3) + 2] << 2;
unsigned char a = 0;
if ((r == 84 && g == 252 && b == 84) || (r == 0 && g == 168 && b == 0)) {
r = 0;
g = 0;
b = 0;
a = 128;
}
else if (c != 0) {
a = 255;
}
buffer[(i * 4) + 0] = r;
buffer[(i * 4) + 1] = g;
buffer[(i * 4) + 2] = b;
buffer[(i * 4) + 3] = a;
}
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, buffer);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
strcpy(image->name, name);
image->image[0][0] = texture;
image->numAnimFrames = -1;
image->namehash = hash;
image->renderwidth = image->width = Width;
image->renderheight = image->height = Height;
loaded_images.push_back(image);
delete buffer;
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;
@@ -180,19 +399,21 @@ void ImGui_NewFrame(void) {
ImGui::NewFrame(show_oldframebuffer);
ImGui_ImplSDL2_NewFrame(game_window);
renderedFrameObjects.clear();
}
void Device_Present(void) {
// Rasterize the palette.
for (int i = 0; i < ScreenWidth * ScreenHeight; i++) {
backbuffer_data[(i * 4) + 0] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 0];
backbuffer_data[(i * 4) + 1] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 1];
backbuffer_data[(i * 4) + 2] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 2];
backbuffer_data[(i * 4) + 3] = 255;
}
//for (int i = 0; i < ScreenWidth * ScreenHeight; i++) {
// backbuffer_data[(i * 4) + 0] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 0];
// backbuffer_data[(i * 4) + 1] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 1];
// backbuffer_data[(i * 4) + 2] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 2];
// backbuffer_data[(i * 4) + 3] = 255;
//}
glBindTexture(GL_TEXTURE_2D, backbuffer_texture);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ScreenWidth, ScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, backbuffer_data);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ScreenWidth, ScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, backbuffer_data_raw);
bool ScreenActive;
ImGuiStyle& style = ImGui::GetStyle();
@@ -422,15 +643,13 @@ void Create_Main_Window ( HANDLE instance , int command_show , int width , int h
glGenTextures(1, &backbuffer_texture);
glBindTexture(GL_TEXTURE_2D, backbuffer_texture);
// Give the image to OpenGL
backbuffer_data_raw = new byte[width * height * 4];
memset(backbuffer_data_raw, 0, width * height * 4);
// Give the image to OpenGL
backbuffer_data = new byte[width * height * 4];
memset(backbuffer_data, 0, width * height * 4);
backbuffer_data_raw = new byte[width * height];
memset(backbuffer_data_raw, 0, width * height);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, backbuffer_data);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, backbuffer_data_raw);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glewInit();
@@ -669,6 +888,9 @@ void WWSDL_ProcessEvents(KeyNumType& key, int& flags, bool presentBuffer) {
extern int mousex, mousey;
bool leftMouseProcessed = false;
key = KN_NONE;
flags = 0;
SDL_GetMouseState(&mousex, &mousey);
Keyboard->MouseQX = mousex;
@@ -677,7 +899,8 @@ void WWSDL_ProcessEvents(KeyNumType& key, int& flags, bool presentBuffer) {
// if (flags == LEFTRELEASE || flags == RIGHTRELEASE)
// flags = 0;
SDL_Event event;
static SDL_Event event;
memset(&event, 0, sizeof(SDL_Event));
while (SDL_PollEvent(&event)) {
switch (event.type)
{
@@ -720,10 +943,12 @@ void WWSDL_ProcessEvents(KeyNumType& key, int& flags, bool presentBuffer) {
leftMouseProcessed = true;
numFramesLMouse++;
key = KN_LMOUSE;
Keyboard->Put_Element(KN_LMOUSE);
}
else if (event.button.button == SDL_BUTTON_RIGHT) {
numFramesLMouse = 0;
flags = GadgetClass::RIGHTPRESS;
Keyboard->Put_Element(KN_RMOUSE);
key = KN_RMOUSE;
}
break;
@@ -744,12 +969,12 @@ void WWSDL_ProcessEvents(KeyNumType& key, int& flags, bool presentBuffer) {
renderConsole = !renderConsole;
if (renderConsole) {
ShowCursor(TRUE);
Hide_Mouse();
// ShowCursor(TRUE);
// Hide_Mouse();
}
else {
ShowCursor(FALSE);
Show_Mouse();
// ShowCursor(FALSE);
// Show_Mouse();
}
break;
}
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -492,6 +492,7 @@ extern bool CanVblankSync;
*=============================================================================================*/
void GScreenClass::Blit_Display(void)
{
#if 0 // jmarshall - no longer used and saves on performance to disable it(3.6%).
if (SeenBuff.Get_Width()!=320){
#if (0)
if (HidPage.Get_IsDirectDraw() && (Options.GameSpeed >1 || Options.ScrollRate==6 && CanVblankSync) ){
@@ -520,7 +521,7 @@ void GScreenClass::Blit_Display(void)
// ST - 1/2/2019 5:26PM
//ModeX_Blit (&HiddenPage);
}
#endif
}
BIN
View File
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB