Skip to content

Commit

Permalink
Merge pull request #1796 from ZehMatt/screeninfo-rt
Browse files Browse the repository at this point in the history
Separate screen info from render target
  • Loading branch information
ZehMatt committed Feb 2, 2023
2 parents 923fb6c + f7b5168 commit 85e9a61
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/OpenLoco/src/Drawing/SoftwareDrawingEngine.cpp
Expand Up @@ -13,7 +13,10 @@ namespace OpenLoco::Drawing
{
using SetPaletteFunc = void (*)(const PaletteEntry* palette, int32_t index, int32_t count);

static loco_global<Ui::ScreenInfo, 0x0050B884> _screenInfo;
// TODO: Move both into the renderer.
static loco_global<RenderTarget, 0x0050B884> _screenRT;
static loco_global<Ui::ScreenInfo, 0x0050B894> _screenInfo;

static loco_global<uint8_t[1], 0x00E025C4> _E025C4;
loco_global<SetPaletteFunc, 0x0052524C> _setPaletteCallback;

Expand Down Expand Up @@ -204,8 +207,8 @@ namespace OpenLoco::Drawing
rt.height = rect.height();
rt.x = rect.left();
rt.y = rect.top();
rt.bits = _screenInfo->renderTarget.bits + rect.left() + ((_screenInfo->renderTarget.width + _screenInfo->renderTarget.pitch) * rect.top());
rt.pitch = _screenInfo->renderTarget.width + _screenInfo->renderTarget.pitch - rect.width();
rt.bits = _screenRT->bits + rect.left() + ((_screenRT->width + _screenRT->pitch) * rect.top());
rt.pitch = _screenRT->width + _screenRT->pitch - rect.width();
rt.zoomLevel = 0;

// TODO: Remove main window and draw that independent from UI.
Expand Down
6 changes: 3 additions & 3 deletions src/OpenLoco/src/Ui.cpp
Expand Up @@ -67,7 +67,8 @@ namespace OpenLoco::Ui
#ifdef _WIN32
loco_global<void*, 0x00525320> _hwnd;
#endif // _WIN32
loco_global<ScreenInfo, 0x0050B884> _screenInfo;
// TODO: Move this into renderer.
static loco_global<ScreenInfo, 0x0050B894> _screenInfo;
static loco_global<uint16_t, 0x00523390> _toolWindowNumber;
static loco_global<Ui::WindowType, 0x00523392> _toolWindowType;
static loco_global<Ui::CursorId, 0x00523393> _currentToolCursor;
Expand Down Expand Up @@ -373,13 +374,12 @@ namespace OpenLoco::Ui

int32_t pitch = surface->pitch;

Gfx::RenderTarget rt{};
auto& rt = Gfx::getScreenRT();
rt.bits = new uint8_t[surface->pitch * height];
rt.width = width;
rt.height = height;
rt.pitch = pitch - width;

_screenInfo->renderTarget = rt;
_screenInfo->width = width;
_screenInfo->height = height;
_screenInfo->width_2 = width;
Expand Down
2 changes: 1 addition & 1 deletion src/OpenLoco/src/Ui.h
Expand Up @@ -27,7 +27,6 @@ namespace OpenLoco::Ui
#pragma pack(push, 1)
struct ScreenInfo
{
Gfx::RenderTarget renderTarget;
int16_t width;
int16_t height;
int16_t width_2;
Expand All @@ -42,6 +41,7 @@ namespace OpenLoco::Ui
int8_t dirtyBlockRowShift;
int8_t dirtyBlocksInitialised;
};
static_assert(sizeof(ScreenInfo) == 0x1B);
#pragma pack(pop)

enum class CursorId : uint8_t
Expand Down

0 comments on commit 85e9a61

Please sign in to comment.