changeset 728:414f8611f344

ecl: Add support for bullet sounds, instruction 84.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 30 Oct 2019 16:27:43 +0100
parents eea03c9ca604
children f953ae5b3732
files src/th06/ecl.rs src/th06/ecl_vm.rs src/th06/enemy.rs
diffstat 3 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/th06/ecl.rs	Wed Oct 30 16:27:20 2019 +0100
+++ b/src/th06/ecl.rs	Wed Oct 30 16:27:43 2019 +0100
@@ -271,7 +271,7 @@
     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),
--- a/src/th06/ecl_vm.rs	Wed Oct 30 16:27:20 2019 +0100
+++ b/src/th06/ecl_vm.rs	Wed Oct 30 16:27:43 2019 +0100
@@ -679,15 +679,19 @@
                 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
 
--- a/src/th06/enemy.rs	Wed Oct 30 16:27:20 2019 +0100
+++ b/src/th06/enemy.rs	Wed Oct 30 16:27:43 2019 +0100
@@ -209,7 +209,9 @@
     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<u8>,
 }
 
 impl BulletAttributes {