refactor: simplify GfxHandler threshold to plain 33 / -2
Browse filesThe original asm uses NEG+SBB+AND+ADD to branchlessly compute
(gfx_mode ? 33 : -2). Our code had wrapping_sub which obscured
the simple constant values.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-core/src/engine/ddgame.rs
CHANGED
|
@@ -568,11 +568,8 @@ unsafe fn init_graphics_and_resources(
|
|
| 568 |
|
| 569 |
// ── GfxHandler #2 (conditional) ──
|
| 570 |
let d778 = (*game_info).game_version;
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
} else {
|
| 574 |
-
-2i32
|
| 575 |
-
};
|
| 576 |
if d778 < threshold {
|
| 577 |
let c_digit = if d778 > -3 { b'2' } else { b'1' };
|
| 578 |
let mut gfx_c_path = *b"data\\Gfx\\GfxC_3_0.dir\0";
|
|
|
|
| 568 |
|
| 569 |
// ── GfxHandler #2 (conditional) ──
|
| 570 |
let d778 = (*game_info).game_version;
|
| 571 |
+
// Original: (-(gfx_mode != 0) & 0x23) - 2 → gfx_mode ? 33 : -2
|
| 572 |
+
let threshold = if (*wrapper).gfx_mode != 0 { 33 } else { -2i32 };
|
|
|
|
|
|
|
|
|
|
| 573 |
if d778 < threshold {
|
| 574 |
let c_digit = if d778 > -3 { b'2' } else { b'1' };
|
| 575 |
let mut gfx_c_path = *b"data\\Gfx\\GfxC_3_0.dir\0";
|