Mercurial > touhou
comparison src/th06/ecl_vm.rs @ 686:aefe5b5f481e
ecl_vm: implement the SetBulletAttributes opcodes.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 17 Aug 2019 04:28:24 +0200 |
parents | 11d7e4d6947a |
children | 1adecaddf442 |
comparison
equal
deleted
inserted
replaced
685:11d7e4d6947a | 686:aefe5b5f481e |
---|---|
1 //! ECL runner. | 1 //! ECL runner. |
2 | 2 |
3 use crate::th06::ecl::{Ecl, SubInstruction}; | 3 use crate::th06::ecl::{Ecl, SubInstruction}; |
4 use crate::th06::enemy::Enemy; | 4 use crate::th06::enemy::{Enemy, BulletAttributes}; |
5 use crate::util::prng::Prng; | 5 use crate::util::prng::Prng; |
6 use std::cell::RefCell; | 6 use std::cell::RefCell; |
7 use std::rc::Rc; | 7 use std::rc::Rc; |
8 | |
9 macro_rules! gen_SetBulletAttributes { | |
10 ($self:ident, $opcode:tt, $anim:ident, $sprite_index_offset:ident, $bullets_per_shot:ident, | |
11 $number_of_shots:ident, $speed:ident, $speed2:ident, $launch_angle:ident, $angle:ident, | |
12 $flags:ident) => {{ | |
13 let sprite_index_offset = $self.get_i32($sprite_index_offset as i32) as i16; | |
14 let bullets_per_shot = $self.get_i32($bullets_per_shot) as i16; | |
15 let number_of_shots = $self.get_i32($number_of_shots) as i16; | |
16 let speed = $self.get_f32($speed); | |
17 let speed2 = $self.get_f32($speed2); | |
18 let launch_angle = $self.get_f32($launch_angle); | |
19 let angle = $self.get_f32($angle); | |
20 | |
21 let mut enemy = $self.enemy.borrow_mut(); | |
22 enemy.set_bullet_attributes($opcode, $anim, sprite_index_offset, bullets_per_shot, | |
23 number_of_shots, speed, speed2, launch_angle, angle, $flags); | |
24 }}; | |
25 } | |
8 | 26 |
9 type Variables = ([i32; 4], [f32; 4], [i32; 4]); | 27 type Variables = ([i32; 4], [f32; 4], [i32; 4]); |
10 | 28 |
11 /// Interpreter for enemy scripts. | 29 /// Interpreter for enemy scripts. |
12 #[derive(Default)] | 30 #[derive(Default)] |
535 // 66 | 553 // 66 |
536 SubInstruction::ClearScreenBox() => { | 554 SubInstruction::ClearScreenBox() => { |
537 let mut enemy = self.enemy.borrow_mut(); | 555 let mut enemy = self.enemy.borrow_mut(); |
538 enemy.screen_box = None; | 556 enemy.screen_box = None; |
539 } | 557 } |
558 | |
540 // 67 to 75 are set bullet attributes and it seems a pain to reverse rn | 559 // 67 to 75 are set bullet attributes and it seems a pain to reverse rn |
560 SubInstruction::SetBulletAttributes1(anim, sprite_index_offset, bullets_per_shot, | |
561 number_of_shots, speed, speed2, launch_angle, | |
562 angle, flags) => { | |
563 gen_SetBulletAttributes!(self, 67, anim, sprite_index_offset, bullets_per_shot, | |
564 number_of_shots, speed, speed2, launch_angle, angle, | |
565 flags); | |
566 } | |
567 SubInstruction::SetBulletAttributes2(anim, sprite_index_offset, bullets_per_shot, | |
568 number_of_shots, speed, speed2, launch_angle, | |
569 angle, flags) => { | |
570 gen_SetBulletAttributes!(self, 68, anim, sprite_index_offset, bullets_per_shot, | |
571 number_of_shots, speed, speed2, launch_angle, angle, | |
572 flags); | |
573 } | |
574 SubInstruction::SetBulletAttributes3(anim, sprite_index_offset, bullets_per_shot, | |
575 number_of_shots, speed, speed2, launch_angle, | |
576 angle, flags) => { | |
577 gen_SetBulletAttributes!(self, 69, anim, sprite_index_offset, bullets_per_shot, | |
578 number_of_shots, speed, speed2, launch_angle, angle, | |
579 flags); | |
580 } | |
581 SubInstruction::SetBulletAttributes4(anim, sprite_index_offset, bullets_per_shot, | |
582 number_of_shots, speed, speed2, launch_angle, | |
583 angle, flags) => { | |
584 gen_SetBulletAttributes!(self, 70, anim, sprite_index_offset, bullets_per_shot, | |
585 number_of_shots, speed, speed2, launch_angle, angle, | |
586 flags); | |
587 } | |
588 SubInstruction::SetBulletAttributes5(anim, sprite_index_offset, bullets_per_shot, | |
589 number_of_shots, speed, speed2, launch_angle, | |
590 angle, flags) => { | |
591 gen_SetBulletAttributes!(self, 71, anim, sprite_index_offset, bullets_per_shot, | |
592 number_of_shots, speed, speed2, launch_angle, angle, | |
593 flags); | |
594 } | |
595 SubInstruction::SetBulletAttributes6(anim, sprite_index_offset, bullets_per_shot, | |
596 number_of_shots, speed, speed2, launch_angle, | |
597 angle, flags) => { | |
598 gen_SetBulletAttributes!(self, 74, anim, sprite_index_offset, bullets_per_shot, | |
599 number_of_shots, speed, speed2, launch_angle, angle, | |
600 flags); | |
601 } | |
602 SubInstruction::SetBulletAttributes7(anim, sprite_index_offset, bullets_per_shot, | |
603 number_of_shots, speed, speed2, launch_angle, | |
604 angle, flags) => { | |
605 gen_SetBulletAttributes!(self, 75, anim, sprite_index_offset, bullets_per_shot, | |
606 number_of_shots, speed, speed2, launch_angle, angle, | |
607 flags); | |
608 } | |
541 | 609 |
542 | 610 |
543 | 611 |
544 // 78-79 are more interpolation flags | 612 // 78-79 are more interpolation flags |
545 // 78 | 613 // 78 |