feat: wire create_ddgame() into game_session, trap original
Browse filesSwitch 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
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 140 |
-
|
| 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 |
}
|