fix: correct stale comment on PALETTE_X4 orientation mapping
Browse filesThe code already implements the full palette×4 + orientation quadrant
logic from the original ASM at 0x56B145. The "for now, handle the
simple case" comment was left over from an earlier draft. Updated
comments to accurately describe the quadrant→orientation mapping and
annotated each match arm with the corresponding orientation name.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-dll/src/replacements/render.rs
CHANGED
|
@@ -872,23 +872,22 @@ unsafe extern "thiscall" fn blit_sprite(
|
|
| 872 |
}
|
| 873 |
|
| 874 |
// ---------------------------------------------------------------
|
| 875 |
-
// Bit 24: palette
|
| 876 |
// ---------------------------------------------------------------
|
| 877 |
-
// The original ASM at 0x56B145
|
| 878 |
-
//
|
| 879 |
-
//
|
|
|
|
| 880 |
let mut orient_local: u32 = 0x0000_0001; // blend=1 (ColorTable/transparency), orientation=0 (Normal)
|
| 881 |
if flags.contains(SpriteFlags::PALETTE_X4) {
|
| 882 |
-
// The ASM computes: pal = pal * 4 + 0x8000, then maps (pal >> 16) & 3
|
| 883 |
-
// to set specific orient values (0x80001, 0xC0001, 0x40001)
|
| 884 |
let scaled = pal.wrapping_mul(4).wrapping_add(0x8000);
|
| 885 |
pal = scaled & 0xFFFF;
|
| 886 |
let quad = ((scaled as i32) >> 16) & 3;
|
| 887 |
orient_local = match quad {
|
| 888 |
-
0 => 0x0008_0001,
|
| 889 |
-
1 => 0x000C_0001,
|
| 890 |
-
2 => 0x0004_0001,
|
| 891 |
-
_ => 0x0000_0001, //
|
| 892 |
};
|
| 893 |
}
|
| 894 |
|
|
|
|
| 872 |
}
|
| 873 |
|
| 874 |
// ---------------------------------------------------------------
|
| 875 |
+
// Bit 24: palette ×4 adjust with orientation-dependent high bits
|
| 876 |
// ---------------------------------------------------------------
|
| 877 |
+
// The original ASM at 0x56B145 scales pal by 4, adds 0x8000, then
|
| 878 |
+
// uses the overflow quadrant (bits 16-17 of the scaled value) to
|
| 879 |
+
// select an orientation+blend combo. The low 16 bits become the
|
| 880 |
+
// new palette value.
|
| 881 |
let mut orient_local: u32 = 0x0000_0001; // blend=1 (ColorTable/transparency), orientation=0 (Normal)
|
| 882 |
if flags.contains(SpriteFlags::PALETTE_X4) {
|
|
|
|
|
|
|
| 883 |
let scaled = pal.wrapping_mul(4).wrapping_add(0x8000);
|
| 884 |
pal = scaled & 0xFFFF;
|
| 885 |
let quad = ((scaled as i32) >> 16) & 3;
|
| 886 |
orient_local = match quad {
|
| 887 |
+
0 => 0x0008_0001, // MirrorXY + ColorTable
|
| 888 |
+
1 => 0x000C_0001, // Rotate90MirrorXY + ColorTable
|
| 889 |
+
2 => 0x0004_0001, // Rotate90 + ColorTable
|
| 890 |
+
_ => 0x0000_0001, // Normal + ColorTable
|
| 891 |
};
|
| 892 |
}
|
| 893 |
|