# HG changeset patch # User Emmanuel Gil Peyrot # Date 1572449263 -3600 # Node ID 414f8611f3446f31ad4f1a20ce05f4eb7f964778 # Parent eea03c9ca60428063c05305b76c5d99baa19dab6 ecl: Add support for bullet sounds, instruction 84. diff --git a/src/th06/ecl.rs b/src/th06/ecl.rs --- a/src/th06/ecl.rs +++ b/src/th06/ecl.rs @@ -271,7 +271,7 @@ declare_sub_instructions!{ 82 => fn SetExtendedBulletAttributes(a: i32, b: i32, c: i32, d: i32, e: f32, f: f32, g: f32, h: f32), 83 => fn ChangeBulletsInStarBonus(), // TODO: Found in stage 4 onward. - 84 => fn UNK_ins84(param: i32), + 84 => fn SetBulletSound(sound: i32), 85 => fn NewLaser(laser_type: i16, sprite_idx_offset: i16, angle: f32, speed: f32, start_offset: f32, end_offset: f32, max_length: f32, width: f32, start_duration: i32, duration: i32, end_duration: i32, grazing_delay: i32, grazing_extra_duration: i32, UNK1: i32), 86 => fn NewLaserTowardsPlayer(laser_type: i16, sprite_idx_offset: i16, angle: f32, speed: f32, start_offset: f32, end_offset: f32, max_length: f32, width: f32, start_duration: i32, duration: i32, end_duration: i32, grazing_delay: i32, grazing_extra_duration: i32, UNK1: i32), 87 => fn SetUpcomingLaserId(id: u32), diff --git a/src/th06/ecl_vm.rs b/src/th06/ecl_vm.rs --- a/src/th06/ecl_vm.rs +++ b/src/th06/ecl_vm.rs @@ -679,15 +679,19 @@ impl EclRunner { game.change_bullets_into_star_items(); } */ + // 84 - // WARNING: dead code. If the parameter is < 0 it unsets a bullet_flag, otherwise it - // sets it, never using the parameter ever - /* - SubInstruction::UNK_ins84() => { + SubInstruction::SetBulletSound(sound) => { let mut enemy = self.enemy.borrow_mut(); - enemy.bullet_flag_something + if sound < 0 { + enemy.bullet_attributes.sound = None; + } else { + // This assert isn’t part of the original engine, but it would crash on high + // values anyway. + assert!(sound <= 255); + enemy.bullet_attributes.sound = Some(sound as u8); + } } - */ // 85-86 ire newlaser functions diff --git a/src/th06/enemy.rs b/src/th06/enemy.rs --- a/src/th06/enemy.rs +++ b/src/th06/enemy.rs @@ -209,7 +209,9 @@ pub(crate) struct BulletAttributes { pub(crate) bullet_type: i16, // zero: x32, pub(crate) flags: u32, - pub(crate) ins84_param: i32, + + /// Which sound to play when the bullet gets fired. + pub sound: Option, } impl BulletAttributes {