paavohtl Claude Opus 4.6 (1M context) commited on
Commit
3e3755a
Β·
1 Parent(s): e257d42

feat: port 6 of 7 InitGameState usercall functions to Rust (Group C)

Browse files

Ported and hooked:
- CGameTask__InitTurnState (0x528690): 96-line field init, camera
center, per-team flags. Bridges to DDGame__InitFeatureFlags (0x524700).
- DDGame__IsSuperWeapon (0x565960): pure switch on weapon index.
ECX preservation fix: callers rely on ECX being preserved.
- CGameTask__InitLandscapeFlags (0x528480): scheme flag + vtable dispatch.

NOT yet hooked (porting bug, disabled):
- DDGame__CheckWeaponAvail (0x53FFC0): weapon availability check.
Implementation has logic errors β€” needs careful re-port.

Named 5 functions in Ghidra. Headful + headless replay tests PASS
with 3 Group C hooks active (6 of 7 usercalls total ported).

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

crates/openwa-core/src/address.rs CHANGED
@@ -358,6 +358,16 @@ pub mod va {
358
  pub const INIT_TEAM_SCORING: u32 = 0x0052_8510;
359
  /// CGameTask__InitAllianceData (0x5262D0): usercall(EAX=wrapper), plain RET.
360
  pub const INIT_ALLIANCE_DATA: u32 = 0x0052_62D0;
 
 
 
 
 
 
 
 
 
 
361
  /// DDGame__InitDisplayFinal_Maybe (0x56A830): display finalization for non-headless.
362
  pub const DDGAME_INIT_DISPLAY_FINAL: u32 = 0x0056_A830;
363
  /// PCLandscape__Constructor (0x57ACB0): constructs 0xB44-byte landscape object.
 
358
  pub const INIT_TEAM_SCORING: u32 = 0x0052_8510;
359
  /// CGameTask__InitAllianceData (0x5262D0): usercall(EAX=wrapper), plain RET.
360
  pub const INIT_ALLIANCE_DATA: u32 = 0x0052_62D0;
361
+ /// DDGame__IsSuperWeapon (0x565960): usercall(EAX=weapon_index) + 1 stack param, plain RET.
362
+ pub const IS_SUPER_WEAPON: u32 = 0x0056_5960;
363
+ /// DDGame__CheckWeaponAvail (0x53FFC0): fastcall(ECX=ddgame) + unaff_ESI, plain RET.
364
+ pub const CHECK_WEAPON_AVAIL: u32 = 0x0053_FFC0;
365
+ /// CGameTask__InitTurnState (0x528690): usercall(EAX=wrapper), plain RET.
366
+ pub const INIT_TURN_STATE: u32 = 0x0052_8690;
367
+ /// CGameTask__InitLandscapeFlags (0x528480): usercall(EAX=wrapper), plain RET.
368
+ pub const INIT_LANDSCAPE_FLAGS: u32 = 0x0052_8480;
369
+ /// DDGame__InitFeatureFlags (0x524700): stdcall(wrapper), RET 0x4.
370
+ pub const DDGAME_INIT_FEATURE_FLAGS: u32 = 0x0052_4700;
371
  /// DDGame__InitDisplayFinal_Maybe (0x56A830): display finalization for non-headless.
372
  pub const DDGAME_INIT_DISPLAY_FINAL: u32 = 0x0056_A830;
373
  /// PCLandscape__Constructor (0x57ACB0): constructs 0xB44-byte landscape object.
crates/openwa-core/src/engine/game_state_init.rs CHANGED
@@ -323,3 +323,275 @@ pub unsafe fn init_alliance_data(wrapper: *mut u8) {
323
  }
324
  }
325
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
323
  }
324
  }
325
  }
326
+
327
+ /// Pure Rust implementation of DDGame__IsSuperWeapon (0x565960).
328
+ ///
329
+ /// Convention: usercall(EAX=weapon_index) + 1 stack param (param_1: u8), plain RET.
330
+ /// Returns 1 for super weapons, param_1 for 0x3B, 0 otherwise.
331
+ pub unsafe fn is_super_weapon(weapon_index: u32, param_1: u8) -> u8 {
332
+ match weapon_index {
333
+ 10 | 0x13 | 0x1D | 0x1E | 0x1F | 0x24 | 0x29 | 0x2A | 0x2D | 0x2E | 0x31 | 0x32 | 0x33
334
+ | 0x36 | 0x37 | 0x38 | 0x3C | 0x3D => 1,
335
+ 0x3B => param_1,
336
+ _ => 0,
337
+ }
338
+ }
339
+
340
+ /// Pure Rust implementation of DDGame__CheckWeaponAvail (0x53FFC0).
341
+ ///
342
+ /// Convention: fastcall(ECX=ddgame) + unaff_ESI=weapon_index, plain RET. Returns i32.
343
+ ///
344
+ /// Checks whether a weapon (1..0x46) is available given current game state.
345
+ /// `ddgame` is the DDGame pointer directly (not wrapper).
346
+ pub unsafe fn check_weapon_avail(ddgame: *mut u8, weapon_index: u32) -> i32 {
347
+ let game_info = *(ddgame.add(0x24) as *const *mut u8);
348
+ let game_version = *(game_info.add(0xD778) as *const i32);
349
+ let num_teams = *game_info as u8;
350
+
351
+ // Step 1: Special per-weapon disabling rules
352
+ match weapon_index {
353
+ 10 | 0x37 | 0x38 => {
354
+ if *(game_info.add(0xD946) as *const u8) != 0
355
+ && *(game_info.add(0xD9A2) as *const u8) == 0
356
+ {
357
+ return 0;
358
+ }
359
+ }
360
+ 0x36 => {
361
+ if *(game_info.add(0xD94C) as *const u8) != 0 {
362
+ return 0;
363
+ }
364
+ }
365
+ 0x42 => {
366
+ let db08 = *(game_info.add(0xDB08) as *const u32);
367
+ if db08 == 0 {
368
+ if *(ddgame.add(0x1C) as *const u32) == 0 {
369
+ return 0;
370
+ }
371
+ } else if (num_teams as u32) < 2 {
372
+ return 0;
373
+ }
374
+ }
375
+ 0x45 => {
376
+ if game_version > 0xD1 {
377
+ let val = *(game_info.add(0xD932) as *const u16);
378
+ if val > 0x7FFF {
379
+ return 0;
380
+ }
381
+ }
382
+ }
383
+ _ => {}
384
+ }
385
+
386
+ // Step 2: Check weapon table entry
387
+ // weapon_table_entry is at ddgame+0x510 + 0x10 + weapon_index*0x1D0
388
+ let weapon_table_entry =
389
+ *(ddgame.add(0x510 + 0x10 + (weapon_index as usize) * 0x1D0) as *const u8);
390
+
391
+ if *(ddgame.add(0x777C) as *const u32) == 0 && weapon_table_entry == 0 {
392
+ if game_version > 0x29 && *(game_info.add(0xD959) as *const u8) != 0 {
393
+ return -2;
394
+ }
395
+ return 0;
396
+ }
397
+
398
+ // Step 3: Super weapon check
399
+ let super_result = is_super_weapon(weapon_index, *(ddgame.add(0x7E3F) as *const u8));
400
+ if super_result != 0 && *(game_info.add(0xD93C) as *const u8) == 0 {
401
+ // (game_version < 0x2A) - 1: if version < 0x2A β†’ 0, else β†’ -1
402
+ return if game_version < 0x2A { 0 } else { -1 };
403
+ }
404
+
405
+ // Step 4: Check DDGame+0x7E25 and weapon_index condition
406
+ if *(ddgame.add(0x7E25) as *const u8) == 0 {
407
+ return 1;
408
+ }
409
+
410
+ // weapon_index != (0x19 - (game_info+0xD956 != 0))
411
+ let d956_nonzero = *(game_info.add(0xD956) as *const u8) != 0;
412
+ let threshold = 0x19u32 - d956_nonzero as u32;
413
+ if weapon_index != threshold {
414
+ return 1;
415
+ }
416
+
417
+ 0
418
+ }
419
+
420
+ /// Bridge to DDGame__InitFeatureFlags (0x524700): stdcall(wrapper), RET 0x4.
421
+ unsafe fn wa_init_feature_flags(wrapper: *mut u8) {
422
+ let f: unsafe extern "stdcall" fn(*mut u8) = core::mem::transmute(crate::rebase::rb(
423
+ crate::address::va::DDGAME_INIT_FEATURE_FLAGS,
424
+ ) as usize);
425
+ f(wrapper);
426
+ }
427
+
428
+ /// Pure Rust implementation of CGameTask__InitTurnState (0x528690).
429
+ ///
430
+ /// Convention: usercall(EAX=wrapper), plain RET.
431
+ ///
432
+ /// Initializes turn-related state fields in both the DDGameWrapper and DDGame
433
+ /// structs. Zeroes camera state, timing fields, per-team flags, and calls
434
+ /// DDGame__InitFeatureFlags. Also dispatches a vtable call on the landscape
435
+ /// object.
436
+ pub unsafe fn init_turn_state(wrapper: *mut u8) {
437
+ let ddgame = ddgame_from_wrapper(wrapper);
438
+ let game_info = *(ddgame.add(0x24) as *const *mut u8);
439
+
440
+ // wrapper+0x458 = -1, wrapper+0x450 = 0, wrapper+0x454 = 0
441
+ *(wrapper.add(0x458) as *mut u32) = 0xFFFF_FFFF;
442
+ *(wrapper.add(0x450) as *mut u32) = 0;
443
+ *(wrapper.add(0x454) as *mut u32) = 0;
444
+
445
+ // DDGame+0x72E0/E4 = -1, DDGame+0x72E8 = 0
446
+ *(ddgame.add(0x72E0) as *mut u32) = 0xFFFF_FFFF;
447
+ *(ddgame.add(0x72E4) as *mut u32) = 0xFFFF_FFFF;
448
+ *(ddgame.add(0x72E8) as *mut u32) = 0;
449
+
450
+ // Zero array at DDGame+0x73B0, stride 0x14, while offset < 0x118
451
+ {
452
+ let mut off = 0u32;
453
+ while off < 0x118 {
454
+ *(ddgame.add(0x73B0 + off as usize) as *mut u32) = 0;
455
+ off += 0x14;
456
+ }
457
+ }
458
+
459
+ // More DDGame field zeroing
460
+ *(ddgame.add(0x739C) as *mut u32) = 0;
461
+ *(ddgame.add(0x72F4) as *mut u32) = 0;
462
+ *(ddgame.add(0x72F8) as *mut u32) = 0;
463
+ *(ddgame.add(0x72FC) as *mut u32) = 0;
464
+ *(ddgame.add(0x7300) as *mut u32) = 0;
465
+ *(ddgame.add(0x7304) as *mut u32) = 0;
466
+
467
+ // DDGame+0x72EC = game_info+0xD774 (RNG seed from scheme)
468
+ let rng_seed = *(game_info.add(0xD774) as *const u32);
469
+ *(ddgame.add(0x72EC) as *mut u32) = rng_seed;
470
+ *(ddgame.add(0x72F0) as *mut u32) = rng_seed; // duplicate
471
+
472
+ *(ddgame.add(0x7378) as *mut u32) = 0;
473
+ *(ddgame.add(0x7374) as *mut u32) = 0;
474
+ *(ddgame.add(0x737C) as *mut u32) = 0;
475
+ *(ddgame.add(0x77DC) as *mut u32) = 0;
476
+ *(ddgame.add(0x77E0) as *mut u32) = 0;
477
+ *(ddgame.add(0x7784) as *mut u32) = 0;
478
+
479
+ // DDGame+0x7788 = game_info+0xF362 (byte β†’ u32)
480
+ *(ddgame.add(0x7788) as *mut u32) = *(game_info.add(0xF362) as *const u8) as u32;
481
+ *(ddgame.add(0x778C) as *mut u32) = 0x10000; // Fixed-point 1.0
482
+ *(ddgame.add(0x7790) as *mut u32) = 0;
483
+
484
+ // Camera center: (level_width << 16) / 2, (level_height << 16) / 2
485
+ let level_width = *(ddgame.add(0x77C0) as *const i32);
486
+ let level_height = *(ddgame.add(0x77C4) as *const i32);
487
+ let cx = (level_width << 16) / 2;
488
+ let cy = (level_height << 16) / 2;
489
+ *(ddgame.add(0x7380) as *mut i32) = cx;
490
+ *(ddgame.add(0x7388) as *mut i32) = cx; // duplicate
491
+ *(ddgame.add(0x7384) as *mut i32) = cy;
492
+ *(ddgame.add(0x738C) as *mut i32) = cy; // duplicate
493
+
494
+ *(ddgame.add(0x7D84) as *mut u32) = 0;
495
+ *(ddgame.add(0x7E4C) as *mut u32) = 0;
496
+ *(ddgame.add(0x77D4) as *mut u32) = 0;
497
+ *(ddgame.add(0x77D8) as *mut u32) = 0;
498
+
499
+ // Per-team loop
500
+ let num_teams = *game_info as u8 as i32;
501
+ if num_teams > 0 {
502
+ let mut off = 0x7D88u32;
503
+ for i in 0..num_teams {
504
+ *(ddgame.add(off as usize) as *mut u32) = 0;
505
+ *(ddgame.add(0x7DBC + i as usize) as *mut u8) = 1;
506
+ *(ddgame.add(0x7DC9 + i as usize) as *mut u8) = 1;
507
+ *(ddgame.add(0x7DD6 + i as usize) as *mut u8) = 0;
508
+ *(ddgame.add(0x7DE3 + i as usize) as *mut u8) = 0;
509
+ *(ddgame.add(0x7DF0 + i as usize) as *mut u8) = 0;
510
+ off += 4;
511
+ }
512
+ }
513
+
514
+ *(ddgame.add(0x7E03) as *mut u8) = 0;
515
+ *(ddgame.add(0x7E04) as *mut u8) = 0;
516
+
517
+ // Call DDGame__InitFeatureFlags (600-line feature flag init, bridged)
518
+ wa_init_feature_flags(wrapper);
519
+
520
+ // Post-feature-flag field writes
521
+ *(ddgame.add(0x7E41) as *mut u8) = 0;
522
+ *(ddgame.add(0x7E50) as *mut u32) = 0;
523
+ *(ddgame.add(0x7E54) as *mut u32) = 0;
524
+ *(ddgame.add(0x7E58) as *mut u32) = 0;
525
+ *(ddgame.add(0x7E5C) as *mut u32) = 0;
526
+ *(ddgame.add(0x7E60) as *mut u32) = 0;
527
+ *(ddgame.add(0x7E64) as *mut u32) = 0;
528
+ *(ddgame.add(0x7E68) as *mut u32) = 0;
529
+ *(ddgame.add(0x7E6C) as *mut u32) = 0;
530
+ *(ddgame.add(0x7E88) as *mut u32) = 0;
531
+ *(ddgame.add(0x7E8C) as *mut u32) = 0;
532
+ *(ddgame.add(0x7E90) as *mut u32) = 0;
533
+ *(ddgame.add(0x7E94) as *mut u32) = 0;
534
+ *(ddgame.add(0x7E98) as *mut u32) = 0;
535
+ *(ddgame.add(0x7EA0) as *mut u32) = 0;
536
+ *(ddgame.add(0x7EA4) as *mut u32) = 0;
537
+
538
+ *(ddgame.add(0x8148) as *mut u32) = 1;
539
+
540
+ let ddgame2 = ddgame_from_wrapper(wrapper);
541
+ *(ddgame2.add(0x8158) as *mut u32) = 0;
542
+ *(ddgame2.add(0x815C) as *mut u32) = 0;
543
+ let ddgame3 = ddgame_from_wrapper(wrapper);
544
+ *(ddgame3.add(0x8160) as *mut u32) = 0;
545
+ *(ddgame3.add(0x8164) as *mut u32) = 0;
546
+
547
+ // Vtable dispatch: DDGame+0x20 β†’ landscape object, vtable slot 1,
548
+ // param = game_info+0xD94C (byte)
549
+ let ddgame4 = ddgame_from_wrapper(wrapper);
550
+ let landscape = *(ddgame4.add(0x20) as *const *mut u8);
551
+ if !landscape.is_null() {
552
+ let vtable = *(landscape as *const *const usize);
553
+ let slot1: unsafe extern "thiscall" fn(*mut u8, u32) = core::mem::transmute(*vtable.add(1));
554
+ let game_info2 = *(ddgame4.add(0x24) as *const *const u8);
555
+ let param = *game_info2.add(0xD94C) as u32;
556
+ slot1(landscape, param);
557
+ }
558
+ }
559
+
560
+ /// Pure Rust implementation of CGameTask__InitLandscapeFlags (0x528480).
561
+ ///
562
+ /// Convention: usercall(EAX=wrapper), plain RET.
563
+ ///
564
+ /// Checks game_info+0xD94B and dispatches landscape vtable slot 6 with
565
+ /// appropriate parameters, then updates DDGame+0x777C.
566
+ pub unsafe fn init_landscape_flags(wrapper: *mut u8) {
567
+ let ddgame = ddgame_from_wrapper(wrapper);
568
+ let game_info = *(ddgame.add(0x24) as *const *mut u8);
569
+
570
+ let scheme_flag = *(game_info.add(0xD94B) as *const u8);
571
+
572
+ // Read the 4 DDGame fields used as params
573
+ let field_7318 = *(ddgame.add(0x7318) as *const u32);
574
+ let field_730c = *(ddgame.add(0x730C) as *const u32);
575
+ let field_734c = *(ddgame.add(0x734C) as *const u32);
576
+ let field_7340 = *(ddgame.add(0x7340) as *const u32);
577
+
578
+ // DDGame+0x20 = landscape object
579
+ let landscape = *(ddgame.add(0x20) as *const *mut u8);
580
+ let vtable = *(landscape as *const *const usize);
581
+ // Vtable slot 6 = offset +0x18
582
+ let slot6: unsafe extern "thiscall" fn(*mut u8, u32, u32, u32, u32, u32, u32, u32, u32) =
583
+ core::mem::transmute(*vtable.add(6));
584
+
585
+ if scheme_flag != 0 {
586
+ // Call with (1, 1, 1, 1, field_7318, field_730c, field_734c, field_7340)
587
+ slot6(
588
+ landscape, 1, 1, 1, 1, field_7318, field_730c, field_734c, field_7340,
589
+ );
590
+ *(ddgame.add(0x777C) as *mut u32) = 1;
591
+ } else if *(ddgame.add(0x777C) as *const u32) != 0 {
592
+ // Call with (0, 0, 1, 0, field_7318, field_730c, field_734c, field_7340)
593
+ slot6(
594
+ landscape, 0, 0, 1, 0, field_7318, field_730c, field_734c, field_7340,
595
+ );
596
+ }
597
+ }
crates/openwa-wormkit/src/replacements/ddgame_init.rs CHANGED
@@ -19,7 +19,8 @@ use openwa_core::engine::ddgame::{
19
  gfx_dir_find_entry, gfx_dir_load_dir, gfx_resource_create, DDGame,
20
  };
21
  use openwa_core::engine::game_state_init::{
22
- init_alliance_data, init_team_scoring, ring_buffer_init, sprite_gfx_table_init,
 
23
  };
24
  use openwa_core::engine::DDGameWrapper;
25
 
@@ -227,6 +228,27 @@ pub fn install() -> Result<(), String> {
227
  va::INIT_ALLIANCE_DATA,
228
  init_alliance_data_trampoline as *const (),
229
  )?;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
230
  }
231
 
232
  Ok(())
@@ -286,3 +308,89 @@ unsafe extern "C" fn init_alliance_data_trampoline() {
286
  impl_fn = sym impl_init_alliance_data,
287
  );
288
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  gfx_dir_find_entry, gfx_dir_load_dir, gfx_resource_create, DDGame,
20
  };
21
  use openwa_core::engine::game_state_init::{
22
+ check_weapon_avail, init_alliance_data, init_landscape_flags, init_team_scoring,
23
+ init_turn_state, is_super_weapon, ring_buffer_init, sprite_gfx_table_init,
24
  };
25
  use openwa_core::engine::DDGameWrapper;
26
 
 
228
  va::INIT_ALLIANCE_DATA,
229
  init_alliance_data_trampoline as *const (),
230
  )?;
231
+
232
+ hook::install(
233
+ "CGameTask__InitTurnState",
234
+ va::INIT_TURN_STATE,
235
+ init_turn_state_trampoline as *const (),
236
+ )?;
237
+
238
+ // TODO: CheckWeaponAvail has a porting bug β€” disabled until fixed
239
+ // hook::install("DDGame__CheckWeaponAvail", va::CHECK_WEAPON_AVAIL, check_weapon_avail_trampoline as *const ())?;
240
+
241
+ hook::install(
242
+ "CGameTask__InitLandscapeFlags",
243
+ va::INIT_LANDSCAPE_FLAGS,
244
+ init_landscape_flags_trampoline as *const (),
245
+ )?;
246
+
247
+ hook::install(
248
+ "DDGame__IsSuperWeapon",
249
+ va::IS_SUPER_WEAPON,
250
+ is_super_weapon_trampoline as *const (),
251
+ )?;
252
  }
253
 
254
  Ok(())
 
308
  impl_fn = sym impl_init_alliance_data,
309
  );
310
  }
311
+
312
+ // ─── CGameTask__InitTurnState (0x528690) ────────────────────────────────────
313
+ // Convention: usercall(EAX=wrapper), plain RET.
314
+
315
+ extern "cdecl" fn impl_init_turn_state(wrapper: u32) {
316
+ unsafe { init_turn_state(wrapper as *mut u8) }
317
+ }
318
+
319
+ #[unsafe(naked)]
320
+ unsafe extern "C" fn init_turn_state_trampoline() {
321
+ core::arch::naked_asm!(
322
+ "push edx",
323
+ "push eax", // wrapper (EAX)
324
+ "call {impl_fn}",
325
+ "add esp, 4",
326
+ "pop edx",
327
+ "ret",
328
+ impl_fn = sym impl_init_turn_state,
329
+ );
330
+ }
331
+
332
+ // ─── DDGame__CheckWeaponAvail (0x53FFC0) ────────────────────────────────────
333
+ // Convention: fastcall(ECX=ddgame) + unaff_ESI=weapon_index, plain RET.
334
+ // Returns i32 in EAX.
335
+
336
+ extern "cdecl" fn impl_check_weapon_avail(ddgame: u32, weapon_index: u32) -> i32 {
337
+ unsafe { check_weapon_avail(ddgame as *mut u8, weapon_index) }
338
+ }
339
+
340
+ #[unsafe(naked)]
341
+ unsafe extern "C" fn check_weapon_avail_trampoline() {
342
+ core::arch::naked_asm!(
343
+ "push edx",
344
+ "push esi", // weapon_index (ESI)
345
+ "push ecx", // ddgame (ECX)
346
+ "call {impl_fn}",
347
+ "add esp, 8",
348
+ "pop edx",
349
+ "ret",
350
+ impl_fn = sym impl_check_weapon_avail,
351
+ );
352
+ }
353
+
354
+ // ─── CGameTask__InitLandscapeFlags (0x528480) ───────────────────────────────
355
+ // Convention: usercall(EAX=wrapper), plain RET.
356
+
357
+ extern "cdecl" fn impl_init_landscape_flags(wrapper: u32) {
358
+ unsafe { init_landscape_flags(wrapper as *mut u8) }
359
+ }
360
+
361
+ #[unsafe(naked)]
362
+ unsafe extern "C" fn init_landscape_flags_trampoline() {
363
+ core::arch::naked_asm!(
364
+ "push edx",
365
+ "push eax", // wrapper (EAX)
366
+ "call {impl_fn}",
367
+ "add esp, 4",
368
+ "pop edx",
369
+ "ret",
370
+ impl_fn = sym impl_init_landscape_flags,
371
+ );
372
+ }
373
+
374
+ // ─── DDGame__IsSuperWeapon (0x565960) ───────────────────────────────────────
375
+ // Convention: usercall(EAX=weapon_index) + 1 stack param (param_1: u8), plain RET.
376
+ // Returns u8 in AL.
377
+
378
+ extern "cdecl" fn impl_is_super_weapon(weapon_index: u32, param_1: u32) -> u32 {
379
+ unsafe { is_super_weapon(weapon_index, param_1 as u8) as u32 }
380
+ }
381
+
382
+ #[unsafe(naked)]
383
+ unsafe extern "C" fn is_super_weapon_trampoline() {
384
+ core::arch::naked_asm!(
385
+ "push ecx",
386
+ "push edx",
387
+ "push [esp+12]", // stack param_1 (shifted by push ecx + push edx)
388
+ "push eax", // weapon_index (EAX)
389
+ "call {impl_fn}",
390
+ "add esp, 8",
391
+ "pop edx",
392
+ "pop ecx",
393
+ "ret 0x4", // callee cleans 1 stack param
394
+ impl_fn = sym impl_is_super_weapon,
395
+ );
396
+ }