paavohtl Claude Opus 4.6 (1M context) commited on
Commit
2e91cbf
·
1 Parent(s): ac31270

feat: wire create_ddgame() into game_session, trap original

Browse files

Switch construct_ddgame_wrapper to call our Rust create_ddgame()
instead of the original DDGame__Constructor bridge. Original is now
trapped.

This is a test commit — remaining constructor sections (sprite
loading, gradient images, fill image, HUD, display finalization)
are still TODO and may cause crashes or missing visuals.

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

crates/openwa-wormkit/src/replacements/game_session.rs CHANGED
@@ -17,8 +17,9 @@
17
  use openwa_core::address::va;
18
  use openwa_core::audio::DSSound;
19
  use openwa_core::display::{DDDisplay, Palette};
20
- use openwa_core::engine::ddgame::init_constructor_addrs;
21
  use openwa_core::engine::{DDGameWrapper, GameInfo, GameSession};
 
22
  use openwa_core::rebase::rb;
23
  use crate::hook;
24
  use crate::log_line;
@@ -106,12 +107,18 @@ pub(crate) unsafe fn construct_ddgame_wrapper(
106
  let timer_obj = (*session).timer_obj;
107
  let net_game = (*session).net_game;
108
 
109
- // Call original DDGame__Constructor via bridge.
110
- // TODO: Replace with create_ddgame() once fully ported.
111
- DDGAME_CTOR_ECX = input_ctrl as u32;
112
- ddgame_constructor_call(
113
- this, display, sound, keyboard, palette, streaming_audio,
114
- timer_obj, net_game, game_info,
 
 
 
 
 
 
115
  );
116
 
117
  // Initialize DDGame's game-state fields.
@@ -136,8 +143,8 @@ pub fn install() -> Result<(), String> {
136
  init_constructor_addrs();
137
  // DDGameWrapper__Constructor is fully converted — trap the original.
138
  hook::install_trap!("DDGameWrapper__Constructor", va::CONSTRUCT_DD_GAME_WRAPPER);
139
- // DDGame__Constructor still uses the original via bridge.
140
- // Will be trapped once create_ddgame() is complete.
141
  }
142
  Ok(())
143
  }
 
17
  use openwa_core::address::va;
18
  use openwa_core::audio::DSSound;
19
  use openwa_core::display::{DDDisplay, Palette};
20
+ use openwa_core::engine::ddgame::{create_ddgame, init_constructor_addrs};
21
  use openwa_core::engine::{DDGameWrapper, GameInfo, GameSession};
22
+ use openwa_core::input::DDKeyboard;
23
  use openwa_core::rebase::rb;
24
  use crate::hook;
25
  use crate::log_line;
 
107
  let timer_obj = (*session).timer_obj;
108
  let net_game = (*session).net_game;
109
 
110
+ // Call our Rust DDGame constructor (incremental port).
111
+ create_ddgame(
112
+ this,
113
+ keyboard as *mut DDKeyboard,
114
+ display,
115
+ sound,
116
+ palette,
117
+ streaming_audio as *mut openwa_core::audio::Music,
118
+ timer_obj,
119
+ net_game,
120
+ game_info,
121
+ input_ctrl as u32,
122
  );
123
 
124
  // Initialize DDGame's game-state fields.
 
143
  init_constructor_addrs();
144
  // DDGameWrapper__Constructor is fully converted — trap the original.
145
  hook::install_trap!("DDGameWrapper__Constructor", va::CONSTRUCT_DD_GAME_WRAPPER);
146
+ // DDGame__Constructor replaced by create_ddgame() — trap original.
147
+ hook::install_trap!("DDGame__Constructor", va::CONSTRUCT_DD_GAME);
148
  }
149
  Ok(())
150
  }