Skip to content

Commit

Permalink
Merge pull request #94 from bayaraa/dev
Browse files Browse the repository at this point in the history
Dev to master
  • Loading branch information
bayaraa authored Jul 22, 2023
2 parents c19ced3 + 59f5e9c commit 11f1b84
Show file tree
Hide file tree
Showing 61 changed files with 1,589 additions and 2,449 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLoopsOnASingleLine: true
BasedOnStyle: LLVM
BraceWrapping:
AfterClass: false
Expand Down
3 changes: 2 additions & 1 deletion d2gl/d2gl.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)src\graphic\pipeline.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\graphic\texture.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\graphic\uniform_buffer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\graphic\upscaler.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\helpers.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\log.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\modules\hd_cursor.cpp" />
Expand Down Expand Up @@ -93,6 +94,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)src\d2\common.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\d2\funcs.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\graphic\command_buffer.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\graphic\upscaler.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\graphic\vertex.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\modules\hd_text\glyph_set.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\modules\hd_text\variables.h" />
Expand Down Expand Up @@ -122,6 +124,5 @@
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)src\graphic\shaders\ddraw.glsl" />
<None Include="$(MSBuildThisFileDirectory)src\graphic\shaders\mod.glsl" />
<None Include="$(MSBuildThisFileDirectory)src\graphic\shaders\upscale\catmull-rom.glsl" />
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion d2gl/d2gl.vcxitems.filters
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<ClCompile Include="$(MSBuildThisFileDirectory)src\patch.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\graphic\command_buffer.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\modules\hd_text\glyph_set.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)src\graphic\upscaler.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)src\app.h" />
Expand Down Expand Up @@ -63,10 +64,10 @@
<ClInclude Include="$(MSBuildThisFileDirectory)src\graphic\vertex.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\modules\hd_text\variables.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\modules\hd_text\glyph_set.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)src\graphic\upscaler.h" />
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)src\graphic\shaders\mod.glsl" />
<None Include="$(MSBuildThisFileDirectory)src\graphic\shaders\upscale\catmull-rom.glsl" />
<None Include="$(MSBuildThisFileDirectory)src\graphic\shaders\ddraw.glsl" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions d2gl/src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ void dllAttach(HMODULE hmodule)
return;
}

if (command_line.find("-log") != std::string::npos)
App.log = true;
App.log = command_line.find("-log") != std::string::npos;
App.direct = command_line.find("-direct") != std::string::npos;

logInit();
trace_log("Renderer Api: %s", App.api == Api::Glide ? "Glide" : "DDraw");
Expand Down
35 changes: 27 additions & 8 deletions d2gl/src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,22 @@ struct D2GLApp {
bool log = false;
bool video_test = false;
bool ready = false;
bool direct = false;

std::string menu_title = "D2GL";
std::string version_str = "D2GL v1.2.2 by Bayaraa.";
std::string version_str = "1.3.0";
std::string ini_file = "d2gl.ini";
std::string mpq_file = "d2gl.mpq";
std::string log_file = "d2gl.log";

Api api = Api::Glide;
std::unique_ptr<Context> context;
std::string gl_version = "";
std::string gl_ver_str = "";
bool vsync = true;
uint32_t frame_latency = 1;

GLCaps gl_caps;
uint8_t gl_ver_major = 4;
uint8_t gl_ver_minor = 6;
glm::vec<2, uint8_t> gl_ver = { 4, 6 };
bool use_compute_shader = false;

HMODULE hmodule = 0;
Expand Down Expand Up @@ -86,7 +86,7 @@ struct D2GLApp {
glm::uvec2 custom_size = { 0, 0 };
GameScreen screen = GameScreen::Movie;
DrawStage draw_stage = DrawStage::World;
glm::uvec2 tex_size = { 0, 0 };
glm::uvec2 tex_size = { 1024, 512 };
glm::vec2 tex_scale = { 1.0f, 1.0f };
} game;

Expand All @@ -110,9 +110,18 @@ struct D2GLApp {
Range<int> range = { 25, 25, 60 };
} background_fps;

Select<int> shader = {};
struct {
Select<std::string> presets = {};
std::string preset = "bilinear.slangp";
int selected = 0;
} shader;

Select<int> lut = {};
bool fxaa = false;

struct {
bool active = false;
Select<int> presets = { 1, { { "Low", 0 }, { "Medium", 1 }, { "High", 2 } } };
} fxaa;

struct {
bool active = false;
Expand All @@ -129,14 +138,15 @@ struct D2GLApp {

struct {
bool active = false;
Range<float> scale = { 1.0f, 0.5f, 1.2f };
Range<float> scale = { 1.0f, 0.8f, 1.2f };
} hd_text;

bool hd_cursor = false;
bool motion_prediction = false;
bool skip_intro = false;
bool no_pickup = false;
bool show_item_quantity = false;
bool show_monster_res = false;
bool show_fps = false;

struct {
Expand Down Expand Up @@ -195,4 +205,13 @@ constexpr inline float FLOATVAL(float glide3x, float ddraw)
#endif
}

constexpr inline bool ISHDTEXT()
{
#ifdef _HDTEXT
return true;
#else
return false;
#endif
}

}
4 changes: 2 additions & 2 deletions d2gl/src/d2/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ void initHooks()
unit_hover_patch.toggle(true);

Patch show_item_quantity_patch = Patch();
show_item_quantity_patch.add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x57566AFF), (0xB807D, 0x55536AFF), (0xBA42D, 0x55536AFF), (0x6B96B), (0x4689B), (0x9347B), (0x6B69B), (0x5F57B), (0x6EF78, 0x52536AFF)), 5, (uintptr_t)((isVerMax(V_110) || isVer(V_114d)) ? drawItemImageBeginPatchESI : drawItemImageBeginPatch));
show_item_quantity_patch.add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0xD1E803C5), (0xB80B8, 0xBAFF0000), (0xBA468, 0xBAFF0000), (0x6B993), (0x468C3), (0x934A3), (0x6B6C3), (0x5F5A3), (0x6EF9D, 0xD1E803C7)), 5, (uintptr_t)drawItemImageEndPatch);
show_item_quantity_patch.add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x8A442416), (0x3AD84, 0x558BD38B), (0x410ED, 0x8B6C241C), (0xAF14E), (0x7A1BE), (0xAF88E), (0x95A2E), (0x99DFE), (0x841A1, 0x8A4DFF8A)), isVer(V_109d) ? 5 : 6, (uintptr_t)(isVerMax(V_110) ? drawInvItemPatchESI : (isVer(V_114d) ? drawInvItemPatchEDI : drawInvItemPatch)));
show_item_quantity_patch.add(PatchType::Auto, getOffset((DLL_D2CLIENT, 0x8A442416), (0x3AF2D, 0x558BD38B), (0x4128F, 0x8B6C241C), (0xAF26D), (0x7A2DD), (0xAF9AD), (0x95B4D), (0x99F1D), (0x842BF, 0x8A4DFF8A)), isVer(V_109d) ? 5 : 6, (uintptr_t)(isVerMax(V_110) ? drawInvItemPatchESI : (isVer(V_114d) ? drawInvItemPatchEDI : drawInvItemPatch)));
show_item_quantity_patch.toggle(true);

patch_motion_prediction = std::make_unique<Patch>();
Expand Down
4 changes: 3 additions & 1 deletion d2gl/src/d2/funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ void __stdcall drawImageHooked(CellContext* cell, int x, int y, uint32_t gamma,
drawImage(cell, pos.x, pos.y, gamma, draw_mode, palette);
}

modules::HDText::drawItemQuantity(x, y);
modules::HDText::drawItemQuantity(true);
}

void __stdcall drawPerspectiveImageHooked(CellContext* cell, int x, int y, uint32_t gamma, int draw_mode, int screen_mode, uint8_t* palette)
Expand Down Expand Up @@ -279,6 +279,8 @@ void __stdcall drawSolidRectExHooked(int left, int top, int right, int bottom, u
auto offset = modules::MotionPrediction::Instance().drawSolidRect();
if (!modules::HDText::Instance().drawSolidRect(left - offset.x, top - offset.y, right - offset.x, bottom - offset.y, color, draw_mode))
drawSolidRectEx(left - offset.x, top - offset.y, right - offset.x, bottom - offset.y, color, draw_mode);

modules::HDText::drawItemQuantity(false, left, bottom);
}

void __stdcall drawLineHooked(int x_start, int y_start, int x_end, int y_end, uint8_t color, uint8_t alpha)
Expand Down
10 changes: 10 additions & 0 deletions d2gl/src/d2/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ namespace d2gl::d2 {
#define SCREENPANEL_LEFT 2
#define SCREENPANEL_BOTH 3

#define STAT_HP 6
#define STAT_MAXHP 7
#define STAT_DMGREDUCTIONPCT 36
#define STAT_MAGICDMGREDUCTIONPCT 37
#define STAT_FIRERESIST 39
#define STAT_LIGHTNINGRESIST 41
#define STAT_COLDRESIST 43
#define STAT_POISONRESIST 45
#define STAT_ITEMQUANTITY 70

enum class UnitType {
Player,
Monster,
Expand Down
10 changes: 5 additions & 5 deletions d2gl/src/d2/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ __declspec(naked) void unitHoverEndPatch()
}
}

__declspec(naked) void drawItemImageBeginPatch()
__declspec(naked) void drawInvItemPatch()
{
__asm
{
Expand All @@ -480,20 +480,20 @@ __declspec(naked) void drawItemImageBeginPatch()
}
}

__declspec(naked) void drawItemImageBeginPatchESI()
__declspec(naked) void drawInvItemPatchEDI()
{
__asm
{
mov currently_drawing_item, esi
mov currently_drawing_item, edi
ret
}
}

__declspec(naked) void drawItemImageEndPatch()
__declspec(naked) void drawInvItemPatchESI()
{
__asm
{
mov currently_drawing_item, 0x0
mov currently_drawing_item, esi
ret
}
}
Expand Down
6 changes: 3 additions & 3 deletions d2gl/src/d2/stubs.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ void unitHoverBeginPatch();
void unitHoverMidPatch();
void unitHoverEndPatch();

void drawItemImageBeginPatch();
void drawItemImageBeginPatchESI();
void drawItemImageEndPatch();
void drawInvItemPatch();
void drawInvItemPatchEDI();
void drawInvItemPatchESI();

void loadUIImageStub();
void loadUIImageStubECX();
Expand Down
1 change: 1 addition & 0 deletions d2gl/src/graphic/command_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ void CommandBuffer::resize()
m_resized = true;
m_game_size = App.game.size;
m_game_tex_bpp = App.game.bpp;
m_window_size = App.window.size;
}

void CommandBuffer::colorUpdate(UBOType type, const void* data)
Expand Down
Loading

0 comments on commit 11f1b84

Please sign in to comment.