paavohtl Claude Opus 4.6 (1M context) commited on
Commit
45fd8ba
·
1 Parent(s): 8a0cd0d

fix: correct color entries — pass (x=idx, y=0) for colours.img

Browse files

The colours.img is a horizontal strip. The original constructor reads
pixels at (0,0), (1,0), (2,0)... not (0,0), (0,1), (0,2)...

Color entries at DDGame+0x730C..0x732C now match the original exactly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

crates/openwa-core/src/engine/ddgame.rs CHANGED
@@ -1186,15 +1186,25 @@ unsafe fn init_graphics_and_resources(
1186
  );
1187
  if !res.is_null() {
1188
  let rvt = *(res as *const *const u32);
1189
- // vtable[4] = CTaskOilDrum__ProcessFrame_stub: XOR EAX,EAX; RET 0x8
1190
- // RET 0x8 = 2 stack params consumed. Always returns 0 (stub).
1191
- // Must pass 2 dummy u32s so the callee's RET 0x8 balances the stack.
 
 
1192
  let get_color: unsafe extern "thiscall" fn(*mut u8, u32, u32) -> u32 =
1193
  core::mem::transmute(*rvt.add(4));
1194
  let mut off = 0x730Cu32;
 
1195
  while off < 0x732Du32 {
1196
- *((ddgame as *mut u8).add(off as usize) as *mut u32) = get_color(res, 0, 0);
 
 
 
 
 
 
1197
  off += 4;
 
1198
  }
1199
  // DisplayGfx__vmethod_3: thiscall(this, byte param_2), RET 4.
1200
  // param_2 & 1 = free the object itself.
 
1186
  );
1187
  if !res.is_null() {
1188
  let rvt = *(res as *const *const u32);
1189
+ let _ = crate::log::log_line(&format!(
1190
+ "[DDGame] color entries: res=0x{:08X} vt=0x{:08X} vt[4]=0x{:08X}",
1191
+ res as u32, rvt as u32, *rvt.add(4),
1192
+ ));
1193
+ // vtable[4] = get_pixel: thiscall(this, x, y) -> color, RET 0x8.
1194
  let get_color: unsafe extern "thiscall" fn(*mut u8, u32, u32) -> u32 =
1195
  core::mem::transmute(*rvt.add(4));
1196
  let mut off = 0x730Cu32;
1197
+ let mut idx = 0u32;
1198
  while off < 0x732Du32 {
1199
+ let c = get_color(res, idx, 0);
1200
+ *((ddgame as *mut u8).add(off as usize) as *mut u32) = c;
1201
+ if idx == 0 {
1202
+ let _ = crate::log::log_line(&format!(
1203
+ "[DDGame] color[0] = 0x{:08X}", c,
1204
+ ));
1205
+ }
1206
  off += 4;
1207
+ idx += 1;
1208
  }
1209
  // DisplayGfx__vmethod_3: thiscall(this, byte param_2), RET 4.
1210
  // param_2 & 1 = free the object itself.