From 6cd3909339d3a59e663d91dc8c00eb1f3e908869 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Sun, 22 Nov 2026 04:54:08 +0100 Subject: [PATCH 1/2] reimplement: SHC_3BB0A8C1_0x004B58D0 100.0% Reimplemented MinimapViewState::renderMinimapTileColors, the minimap's terrain picture: for a strip of the screen tile rows it takes each tile's colour from its terrain flags and MiniMapDefinedData's tables, scales it by the tile's luminescence (RGB555 or RGB565) and writes it into the minimap pixel buffer, at full or at half size. Written from the original's listing. gynt's draft is 4a1f8dd396 (2026-11-02, a style pass over the UI folders; status line "20.4% | Style pass, asm differs") on his fork's reimpl/UI-MenuItems-development; his 0b3142f51e, 1de07cb9e7 and 0d4e470ce9 are earlier steps of it at 20.36%. 10280b1610 on reimpl/UI-Core-development has 20.2%, and a0e86e1129 (20.4%) and ab8f1e3a65 (20.2%) are the same draft on his reimpl/UI-Core (#256). The draft has the tables' names and the whole colour chain as the original has it. Behaviour fixes against 4a1f8dd396: - the map-size test is `mapSize < 200` where the original has `<= 200` (0x004B597E: `cmp ..., 200; jg`), so a 200-tile map took the larger maps' path, where the column count is halved: rows 0 to 399 and columns 0 to 99 of the screen tile table, where the original draws the table's centre, rows 100 to 299 and columns 50 to 149 (every 200 by 200 map); - past the strip's end the original returns (0x004B5A6B); the draft has an empty `if` there and draws on (no caller passes a partial strip today). gynt has that return himself in 8ca78619cd on reimpl/Wilps-2026-10-18. Two places where the code differs from the draft without a change on today's callers: - the pixels are written through `this->minimapPixelBuffer`, as in the original, not through the fixed address 0x01A58754, the same address while `this` is DAT_MinimapViewState; - the screen tile table is indexed from its base on today's main (the draft's `- 8` was right for the header of its day and reads 8 entries too low now). What the match needed: - The pixel stores are handwritten assembly in the original: `add eax, eax` and a `mul edx` by the row pitch, the same address computation as in renderMinimapPreview and drawCurrentPixel (whose pitch is `horizontalByteSize`, not the constant 400). Here they are two `__asm` blocks, one per size. The function keeps no frame pointer with them, as in the original. - The colour is a 16-bit local. As a uint, the two colour modes' ends are merged into one block and the (ushort) of the mix is split over its operands; the original has both ends written out. - The channels: each mask as a statement right after its cap, and green set before red (the mix takes the two in the order they are first set, so the three are initialised blue, green, red). - The five simple initialisations before the two strip-row divisions: a local set while a parameter is still to be read cannot take its stack slot. With them first, every stack slot is the original's (the row counter, the colour and x's stepping value sit in the dead parameters' slots). - The viewport height read from the global a second time for the other parity; y declared inside the tile loop and a copy of x at the top of the full-size branch, so that the stores of the assembly's operands stand where the original has them; the tile read before x; rowBase stepped in the row loop's header; the column loop started at `firstRow / 2` (started at firstColumn, the compiler folds x's first value, which the original computes as `(firstColumn - firstColumn) * widthFactor + rowX`); rowBase holding the orientation's offset first, with north writing the 8 again. The channel masks have names in a small file-local enum (the style lint asks for names or decimals); the listing is the same with the hex numbers. Measured in a narrow build on main 3458fea34 of this file alone (main is now 812d14969: #399 and #398 add only the optional function-visibility units, off by default), struct resolvers and its resolver on: 100.0% raw and normalised, no diff entry. Not run in game. Co-authored-by: Gynt Co-Authored-By: Claude Fable 5.2 --- .../renderMinimapTileColors.cpp | 249 ++++++++++++++++++ status/addresses-SHC-3BB0A8C1.txt | 2 +- 2 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 src/OpenSHC/UI/MinimapViewState/renderMinimapTileColors.cpp diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileColors.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileColors.cpp new file mode 100644 index 0000000000..8148d49508 --- /dev/null +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileColors.cpp @@ -0,0 +1,249 @@ +#include "../MinimapViewState.func.hpp" + +#include "OpenSHC/Map/Enums/MapOrientation.hpp" +#include "OpenSHC/Map/LogicHelpers/Logic1.hpp" +#include "OpenSHC/Map/LogicHelpers/Logic2.hpp" +#include "OpenSHC/Rendering/ColorMode.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_MiniMapDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + + using namespace Map::LogicHelpers; + + // The channels' bits in an RGB555 and in an RGB565 colour. + enum { + RGB555_RED = 31744, // 0x7c00 + RGB555_GREEN = 992, // 0x03e0 + RGB565_RED = 63488, // 0xf800 + RGB565_GREEN = 2016, // 0x07e0 + RGB_BLUE = 31 // 0x001f + }; + + // Draws a strip of the screen tile rows into the minimap pixel buffer, each tile in its terrain's colour and light. + // FUNCTION: STRONGHOLDCRUSADER 0x004B58D0 + void MinimapViewState::renderMinimapTileColors( + uint flags, int widthFactor, int heightFactor, int stripStart, uint stripLength) + { + // The assembly below takes the buffer's address from this local. + ushort* const buffer = this->minimapPixelBuffer; + // These five in this order before the strip rows (after them, isRGB565 takes stripLength's stack slot). + int firstRow = 0; + BOOLEnum isRGB565 = FALSE; + int rowBase = 8; + int scale = 1; + int columnDivisor = 2; + // the strip covers rows stripStart% .. stripStart + stripLength% of the 400 screen tile rows + int const firstStripRow = stripStart * 400 / 100; + // (int) for a signed division (divided unsigned, the match is lost). + int const endStripRow = (int)(stripStart + stripLength) * 400 / 100; + if (flags & 4) { + // zoomed out: half the size + scale = 2; + } + int const columns = 400 / widthFactor * scale; + int const rowCount = scale * 200; + if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_565) { + isRGB565 = TRUE; + } + if (DAT_TileMapState::instance.mapSize <= 200) { + firstRow = 100; + columnDivisor = 1; + } + int const viewportHeight = DAT_ViewportRenderState::instance.viewportState.viewportHeight; + // The global again (viewportHeight + 1 is added up anew in every row). + int const otherParity = DAT_ViewportRenderState::instance.viewportState.viewportHeight + 1; + int rowParity = otherParity; + // rowBase first holds the orientation's offset into the screen tile table (a variable of its own for the + // offset takes another stack slot); north writes the 8 again (left out, the match is lost). + if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_NORTH) { + rowBase = 8; + } else if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_WEST) { + rowBase = 80408; + } else if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_SOUTH) { + rowBase = 160808; + } else if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_EAST) { + rowBase = 241208; + } + int const firstColumn = firstRow / 2; + rowBase = firstColumn * 401 + rowBase + 1; + int rowLength; + // rowBase steps in the header (as the body's last statement it is stepped before the row's own values). + for (int row = firstRow; row < rowCount - firstRow; ++row, rowBase += rowLength) { + // the screen tile rows are staggered: every other row starts half a tile in and has one entry less in + // the screen tile table (200 against 201) + int rowX; + if (rowParity == otherParity) { + rowParity = viewportHeight; + rowX = widthFactor / 2; + rowLength = 200; + } else { + rowParity = otherParity; + rowX = 0; + rowLength = 201; + } + if (row < firstStripRow) { + continue; + } + if (row >= endStripRow) { + return; + } + if (scale == 2 && (row * heightFactor & 1)) { + continue; + } + int const lastColumn = columns / columnDivisor - firstColumn; + // firstRow / 2 written out (starting at firstColumn, x's first value is folded to rowX). + for (int column = firstRow / 2; column < lastColumn; ++column) { + // The tile before x (after x, the two stepping values are set up and advanced in the other + // order); y in here (declared per row, the match is lost). + int const tile = DAT_ViewportRenderState::instance.screenPointToTileNumber[column + rowBase]; + int const x = (column - firstColumn) * widthFactor + rowX; + int const y = (row - firstRow) * heightFactor; + int const logic = DAT_TileMapState::instance.LogicLayer[tile]; + int const logic2 = DAT_TileMapState::instance.Logic2Layer[tile]; + int const random = DAT_TileMapState::instance.RandomLayer[tile]; + int const groundHeight = DAT_TileMapState::instance.HeightLayer[tile]; + int const luminescence = DAT_TileMapState::instance.LuminesenceLayer[tile]; + // 16 bits wide (as a uint, the two colour modes below end in one shared block). + ushort color; + if (logic & (L_BORDER | L_BORDER_EDGE)) { + color = 0; + } else if (logic & L_SEA) { + color = DAT_MiniMapDefinedData::instance.SeaMinimapColors[isRGB565 + (random & 7) * 2]; + } else if (logic & L_FORD) { + // & 7 on an 8-entry table, as in the original (its entries run on into field_0x64). + color = DAT_MiniMapDefinedData::instance.FordMinimapColors[isRGB565 + (random & 7) * 2]; + } else if (logic & L_RIVER) { + color = DAT_MiniMapDefinedData::instance.RiverMinimapColors[isRGB565 + (random & 3) * 2]; + } else if (logic & L_BOULDERS) { + color = DAT_MiniMapDefinedData::instance.BouldersMinimapColors[isRGB565 + (random & 7) * 2]; + } else if (logic & L_ROCKY) { + color = DAT_MiniMapDefinedData::instance.MinimapColorArray[isRGB565 + (random & 3) * 2]; + } else if (logic & L_PEBBLES) { + color = DAT_MiniMapDefinedData::instance.PebblesMinimapColors[isRGB565 + (random & 3) * 2]; + } else if (logic2 & L2_STONES_OR_DRIVEN_SANDUnk) { + color + = DAT_MiniMapDefinedData::instance.StonesOrDrivenSandMinimapColors[isRGB565 + (random & 3) * 2]; + } else if (logic2 & L2_BEACH) { + color = DAT_MiniMapDefinedData::instance.BeachMinimapColors[isRGB565 + (random & 3) * 2]; + } else if ((logic2 & L2_OASIS_GRASS) && (logic & L_DEFAULT_EARTH_OR_TEXTURE)) { + color = DAT_MiniMapDefinedData::instance.OasisGrassMinimapColors[isRGB565 + (random & 3) * 2]; + } else if ((logic2 & L2_THICK_SCRUB) && (logic & L_DEFAULT_EARTH_OR_TEXTURE)) { + color = DAT_MiniMapDefinedData::instance.ThickScrubMinimapColors[isRGB565 + (random & 3) * 2]; + } else if ((logic2 & L2_SCRUB) && (logic & L_DEFAULT_EARTH_OR_TEXTURE)) { + color = DAT_MiniMapDefinedData::instance.ScrubMinimapColors[isRGB565 + (random & 3) * 2]; + } else if (logic & L_IRON) { + color = DAT_MiniMapDefinedData::instance.IronMinimapColors[isRGB565 + (random & 3) * 2]; + } else if (logic & (L_MARSH | L_OIL)) { + color = DAT_MiniMapDefinedData::instance.MarshOrOilMinimapColors[isRGB565 + (random & 3) * 2]; + } else if (groundHeight > 16) { + color + = DAT_MiniMapDefinedData::instance.StonesOrDrivenSandMinimapColors[isRGB565 + (random & 3) * 2]; + } else if (!(logic2 & L2_EARTH_AND_STONES) && !(logic & L_PLAIN2_AND_PITCH)) { + color = DAT_MiniMapDefinedData::instance.EarthMinimapColors[isRGB565 + (random & 7) * 2]; + } else { + color = DAT_MiniMapDefinedData::instance.EarthAndStonesMinimapColors[isRGB565 + (random & 7) * 2]; + } + // entry 2 is 100%: the colour as it is + if (luminescence != 2) { + int const brightness = DAT_MiniMapDefinedData::instance.LuminescenceBrightnessPercent[luminescence]; + // Set in this order (the mix takes green and red in the order they are first set). + int blue = 0; + int green = 0; + int red = 0; + // Red's and green's masks right after their caps (inside the mix, they move to the end). Blue's + // stays in the mix, where the original masks it last. + if (!isRGB565) { + red = (color & RGB555_RED) * brightness / 100; + if (red > RGB555_RED) { + red = RGB555_RED; + } + red &= RGB555_RED; + green = (color & RGB555_GREEN) * brightness / 100; + if (green > RGB555_GREEN) { + green = RGB555_GREEN; + } + green &= RGB555_GREEN; + blue = (color & RGB_BLUE) * brightness / 100; + if (blue > RGB_BLUE) { + blue = RGB_BLUE; + } + color = (ushort)(blue & RGB_BLUE | green | red); + } else { + red = (color & RGB565_RED) * brightness / 100; + if (red > RGB565_RED) { + red = RGB565_RED; + } + red &= RGB565_RED; + green = (color & RGB565_GREEN) * brightness / 100; + if (green > RGB565_GREEN) { + green = RGB565_GREEN; + } + green &= RGB565_GREEN; + blue = (color & RGB_BLUE) * brightness / 100; + if (blue > RGB_BLUE) { + blue = RGB_BLUE; + } + color = (ushort)(blue & RGB_BLUE | green | red); + } + } + // The pixel stores are handwritten assembly in the original, transcribed from the binary. + if (scale == 1) { + // A copy for the assembly (x named there is stored at the top of the tile loop). + int const pixelX = x; + for (int offsetX = 0; offsetX < widthFactor; ++offsetX) { + if (x + offsetX < 0 || x + offsetX >= columns * widthFactor) { + continue; + } + for (int offsetY = 0; offsetY < heightFactor; ++offsetY) { + __asm { + mov edi, buffer + mov eax, pixelX + add eax, offsetX + add eax, eax + add edi, eax + mov eax, y + add eax, offsetY + mov edx, 400 + mul edx + add edi, eax + mov ax, color + mov word ptr [edi], ax + } + } + } + } else { + // Every other pixel at half the position (a plain loop skipping odd ones loses the match). + for (int offsetX = x & 1; offsetX < widthFactor; offsetX += 2) { + if (x + offsetX < 0 || x + offsetX >= columns * widthFactor) { + continue; + } + int const halfX = (x + offsetX) / scale; + for (int offsetY = 0; offsetY < heightFactor; ++offsetY) { + int const halfY = (y + offsetY) / scale; + __asm { + mov edi, buffer + mov eax, halfX + add eax, eax + add edi, eax + mov eax, halfY + mov edx, 400 + mul edx + add edi, eax + mov ax, color + mov word ptr [edi], ax + } + } + } + } + } + } + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index b62540e14f..08bd06d13b 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -26887,7 +26887,7 @@ SHC_3BB0A8C1_0x004B5330 | 0.0% | Pending SHC_3BB0A8C1_0x004B5480 | 0.0% | Pending -SHC_3BB0A8C1_0x004B58D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004B58D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004B5A20 | 0.0% | Pending From af881e2acfbade56a92592d6bb253d60c8d5bd25 Mon Sep 17 00:00:00 2001 From: kotijekriv Date: Mon, 23 Nov 2026 07:25:44 +0100 Subject: [PATCH 2/2] style: renderMinimapTileColors names its map, buffer and screen tile table sizes The three 400s in the C++ (the strip's first and end rows, and the number of columns) are the map's 400 screen tile rows and columns, Map::MC_MAP_XY_LIMIT. The assembly's two `mov edx, 400` are a row of the minimap buffer in bytes (200 pixels of 2 bytes): a file-local BUFFER_ROW_BYTES, defined as MC_MAP_XY_LIMIT / 2 * sizeof(ushort), as renderMinimapTileStripWithLuminescence in #465 does, because inline assembly cannot name a qualified constant. The screen tile table's numbers use main's ViewportConstants, as #465 writes them: the table's start (8) is VC_SCREEN_POINT_TABLE_START, the other orientations' tables (80408, 160808, 241208) are VC_SCREEN_POINT_TABLE_START plus one, two and three VC_SCREEN_POINT_TABLE_SIZE, a short and a long row together (401) are VC_SCREEN_POINT_SHORT_ROW + VC_SCREEN_POINT_LONG_ROW, and the row lengths (200, 201) are those two. The 200 of the row count and of the map size test is Map::MC_MAP_SIZE_200, and such a map's first row (100) is (MC_MAP_XY_LIMIT - MC_MAP_SIZE_200) / 2. The comment above the orientation test names the table's start instead of the 8. The file includes MapConstants.hpp and ViewportConstants.hpp. No other change. The colour masks stay a file-local enum for now: Rendering::ColorChannelMask, which names them, comes with #465, and this file switches to it once #465 is on main. Measured: with the precompiled header, quick_diff gives the same listing for the pushed head's text and this one after MSVC's `$T` temp labels are normalised. A narrow real build (main's /GL list and this round's files of two of our PRs, with the struct resolvers and those files' function resolvers on, sourcehold's reccmp with --resolve-wrapped-calls --ignore-security-cookie) reads 100.0% raw and normalised with no differing line for each function this commit touches, and every other function reads as in the same build without them. Co-authored-by: Gynt Co-Authored-By: Claude Opus 5.5 --- .../renderMinimapTileColors.cpp | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileColors.cpp b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileColors.cpp index 8148d49508..54d5ae94e2 100644 --- a/src/OpenSHC/UI/MinimapViewState/renderMinimapTileColors.cpp +++ b/src/OpenSHC/UI/MinimapViewState/renderMinimapTileColors.cpp @@ -3,7 +3,9 @@ #include "OpenSHC/Map/Enums/MapOrientation.hpp" #include "OpenSHC/Map/LogicHelpers/Logic1.hpp" #include "OpenSHC/Map/LogicHelpers/Logic2.hpp" +#include "OpenSHC/Map/MapConstants.hpp" #include "OpenSHC/Rendering/ColorMode.hpp" +#include "OpenSHC/Rendering/Enums/ViewportConstants.hpp" #include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" #include "OpenSHC/Globals/DAT_MiniMapDefinedData.hpp" @@ -16,6 +18,11 @@ namespace UI { using namespace Map::LogicHelpers; + using OpenSHC::Rendering::Enums::VC_SCREEN_POINT_LONG_ROW; + using OpenSHC::Rendering::Enums::VC_SCREEN_POINT_SHORT_ROW; + using OpenSHC::Rendering::Enums::VC_SCREEN_POINT_TABLE_SIZE; + using OpenSHC::Rendering::Enums::VC_SCREEN_POINT_TABLE_START; + // The channels' bits in an RGB555 and in an RGB565 colour. enum { RGB555_RED = 31744, // 0x7c00 @@ -25,6 +32,9 @@ namespace UI { RGB_BLUE = 31 // 0x001f }; + // A row of the minimap buffer (200 pixels) in bytes, for the assembly (it cannot name a qualified constant). + enum { BUFFER_ROW_BYTES = Map::MC_MAP_XY_LIMIT / 2 * sizeof(ushort) }; + // Draws a strip of the screen tile rows into the minimap pixel buffer, each tile in its terrain's colour and light. // FUNCTION: STRONGHOLDCRUSADER 0x004B58D0 void MinimapViewState::renderMinimapTileColors( @@ -35,24 +45,24 @@ namespace UI { // These five in this order before the strip rows (after them, isRGB565 takes stripLength's stack slot). int firstRow = 0; BOOLEnum isRGB565 = FALSE; - int rowBase = 8; + int rowBase = VC_SCREEN_POINT_TABLE_START; int scale = 1; int columnDivisor = 2; // the strip covers rows stripStart% .. stripStart + stripLength% of the 400 screen tile rows - int const firstStripRow = stripStart * 400 / 100; + int const firstStripRow = stripStart * Map::MC_MAP_XY_LIMIT / 100; // (int) for a signed division (divided unsigned, the match is lost). - int const endStripRow = (int)(stripStart + stripLength) * 400 / 100; + int const endStripRow = (int)(stripStart + stripLength) * Map::MC_MAP_XY_LIMIT / 100; if (flags & 4) { // zoomed out: half the size scale = 2; } - int const columns = 400 / widthFactor * scale; - int const rowCount = scale * 200; + int const columns = Map::MC_MAP_XY_LIMIT / widthFactor * scale; + int const rowCount = scale * Map::MC_MAP_SIZE_200; if (DAT_WindowAndDirectDraw::instance.colorBitMode == OpenSHC::Rendering::RGB_565) { isRGB565 = TRUE; } - if (DAT_TileMapState::instance.mapSize <= 200) { - firstRow = 100; + if (DAT_TileMapState::instance.mapSize <= Map::MC_MAP_SIZE_200) { + firstRow = (Map::MC_MAP_XY_LIMIT - Map::MC_MAP_SIZE_200) / 2; columnDivisor = 1; } int const viewportHeight = DAT_ViewportRenderState::instance.viewportState.viewportHeight; @@ -60,18 +70,18 @@ namespace UI { int const otherParity = DAT_ViewportRenderState::instance.viewportState.viewportHeight + 1; int rowParity = otherParity; // rowBase first holds the orientation's offset into the screen tile table (a variable of its own for the - // offset takes another stack slot); north writes the 8 again (left out, the match is lost). + // offset takes another stack slot); north sets the table's start again (left out, the match is lost). if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_NORTH) { - rowBase = 8; + rowBase = VC_SCREEN_POINT_TABLE_START; } else if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_WEST) { - rowBase = 80408; + rowBase = VC_SCREEN_POINT_TABLE_START + VC_SCREEN_POINT_TABLE_SIZE; } else if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_SOUTH) { - rowBase = 160808; + rowBase = VC_SCREEN_POINT_TABLE_START + 2 * VC_SCREEN_POINT_TABLE_SIZE; } else if (DAT_TileMapState::instance.mapOrientation == Map::Enums::MO_EAST) { - rowBase = 241208; + rowBase = VC_SCREEN_POINT_TABLE_START + 3 * VC_SCREEN_POINT_TABLE_SIZE; } int const firstColumn = firstRow / 2; - rowBase = firstColumn * 401 + rowBase + 1; + rowBase = firstColumn * (VC_SCREEN_POINT_SHORT_ROW + VC_SCREEN_POINT_LONG_ROW) + rowBase + 1; int rowLength; // rowBase steps in the header (as the body's last statement it is stepped before the row's own values). for (int row = firstRow; row < rowCount - firstRow; ++row, rowBase += rowLength) { @@ -81,11 +91,11 @@ namespace UI { if (rowParity == otherParity) { rowParity = viewportHeight; rowX = widthFactor / 2; - rowLength = 200; + rowLength = VC_SCREEN_POINT_SHORT_ROW; } else { rowParity = otherParity; rowX = 0; - rowLength = 201; + rowLength = VC_SCREEN_POINT_LONG_ROW; } if (row < firstStripRow) { continue; @@ -209,7 +219,7 @@ namespace UI { add edi, eax mov eax, y add eax, offsetY - mov edx, 400 + mov edx, BUFFER_ROW_BYTES mul edx add edi, eax mov ax, color @@ -232,7 +242,7 @@ namespace UI { add eax, eax add edi, eax mov eax, halfY - mov edx, 400 + mov edx, BUFFER_ROW_BYTES mul edx add edi, eax mov ax, color