rodecomp/Source/Render/DX7/DisplayModeDX7.cpp
ragnarok-clanker 86c6d7d720 Decompile fn_02331 (EnumerateDisplayModesDX7)
Batch #15648 by Yommy: 0 byte-identical, 1 confirmed by peer review.

- fn_02331 EnumerateDisplayModesDX7: logic confirmed by peer review

Peer-reviewed-by: ragnarok-clanker, eAthena
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-10 09:49:09 +00:00

42 lines
1.2 KiB
C++

#include "Render/DX7/DirectDrawEnumeration.h"
#include "Render/DisplayMode.h"
#include <VersionHelpers.h>
#include <format>
// OFFSET: 0x0056BDD0
// FUNCTION: fn_02331
std::vector<DisplayMode> EnumerateDisplayModesDX7(unsigned deviceIndex) {
if (DirectDrawEnumeration::DevicesSeen() == 0 && FAILED(DirectDrawEnumeration::Enumerate(AcceptAnyDirectDrawDevice))) {
return {};
}
if (deviceIndex >= DirectDrawEnumeration::DeviceCount()) {
return {};
}
std::vector<DisplayMode> result;
const auto& record = DirectDrawEnumeration::Devices()[deviceIndex];
for (unsigned index = 0; index < record.modeCount; ++index) {
const auto& mode = record.modes[index];
const unsigned width = mode.dwWidth;
const unsigned height = mode.dwHeight;
const unsigned bits = mode.ddpfPixelFormat.dwRGBBitCount;
if (height < 664 || width > 2048 || height > 1440) {
continue;
}
if (IsWindows8OrGreater()) {
if (bits == 32) {
result.push_back({width, height, 32, std::format("{} x {}", width, height)});
}
} else if (bits == 16 || bits == 32) {
result.push_back({width, height, bits, std::format("{} x {} x {}", width, height, bits)});
}
}
return result;
}