changeset 674:3e4cc64a254d

ecl_vm: more instructions.
author Gauvain "GovanifY" Roussel-Tarbouriech <gauvain@govanify.com>
date Mon, 12 Aug 2019 20:50:22 +0200
parents 81ad01910f4b
children 6be3320a1cb3
files src/th06/ecl.rs src/th06/ecl_vm.rs
diffstat 2 files changed, 30 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/th06/ecl.rs	Mon Aug 12 20:32:08 2019 +0200
+++ b/src/th06/ecl.rs	Mon Aug 12 20:50:22 2019 +0200
@@ -265,7 +265,7 @@
     104 => fn SetCollidable(collidable: i32),
     105 => fn SetDamageable(damageable: i32),
     106 => fn PlaySound(index: i32),
-    107 => fn SetDeathFlags(death_flags: i32),
+    107 => fn SetDeathFlags(death_flags: u32),
     108 => fn SetDeathCallback(sub: i32),
     109 => fn MemoryWriteInt(value: i32, index: i32),
     111 => fn SetLife(life: i32),
--- a/src/th06/ecl_vm.rs	Mon Aug 12 20:32:08 2019 +0200
+++ b/src/th06/ecl_vm.rs	Mon Aug 12 20:50:22 2019 +0200
@@ -552,11 +552,39 @@
 
             // 103
             SubInstruction::SetHitbox(width, height, depth) => {
-                assert_eq!(depth, 32.);
                 let mut enemy = self.enemy.borrow_mut();
                 enemy.set_hitbox(width, height);
             }
 
+            // 104
+            SubInstruction::SetCollidable(collidable) => {
+                // TODO: me and my siblings(105, 107) are implemented as a single variable in the touhou 6
+                // original engine. While our behaviour seems correct we might want to implement
+                // that as a single variable
+                let mut enemy = self.enemy.borrow_mut();
+                enemy.collidable = (collidable&1) != 0;
+            }
+
+            // 105
+            SubInstruction::SetDamageable(damageable) => {
+                let mut enemy = self.enemy.borrow_mut();
+                enemy.damageable = (damageable&1) != 0;
+            }
+
+            // 106
+            /*
+            SubInstruction::PlaySound(index) => {
+                let mut enemy = self.enemy.borrow_mut();
+                enemy.play_sound(index);
+            }
+            */
+
+            // 107
+            SubInstruction::SetDeathFlags(death_flags) => {
+                let mut enemy = self.enemy.borrow_mut();
+                enemy.death_flags = death_flags;
+            }
+
             _ => unimplemented!()
         }
     }