From d9228e03204ea8444a7ae5bd6dfea10ef52a3904 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Fri, 21 Jan 2022 17:01:42 +0100 Subject: [PATCH] [Decompilation] [th01] Shootout lasers: Broken reset function Whoops, 4406c3d did not actually decompile it yet. Part of P0181, funded by Ember2528. --- th01/main/bullet/laser_s.hpp | 33 +++++++++++++++++++++++++++++++++ th01/main/bullet/laser_s.inc | 17 ----------------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/th01/main/bullet/laser_s.hpp b/th01/main/bullet/laser_s.hpp index 0bfd09b5..5d8565a9 100644 --- a/th01/main/bullet/laser_s.hpp +++ b/th01/main/bullet/laser_s.hpp @@ -88,6 +88,33 @@ public: // Directly sets [done] if the laser collides with the player. void update_hittest_and_render(void); + + // Tries to unblit the entire laser, but fails hilariously. + void unput_and_reset(void) { + if(alive) { + // Two ZUN bugs here: + // + // 1) Surely this should have unblitted from the start to the end + // of the ray instead? Except that this class doesn't explicitly + // store that end point… so the best alternative would be the + // target point. But given that we use our own blitting routine, + // who knows how accurate that actually is? + // + // 2) graph_r_line_unput() takes screen_x_t and vram_y_t, not + // LaserPixels truncated to 16-bits :zunpet: As a result, this + // call effectively unblit random 32-bit pixel chunks. + // + // Not that it matters a lot. This function is only called at the + // end of a boss battle, immediately before transitioning to the + // tally screen. Still, not doing anything would have been the + // better choice. + graph_r_line_unput( + ray_start_left.v, ray_start_y.v, origin_left.v, origin_y.v + ); + + alive = false; + } + } }; extern CShootoutLaser shootout_lasers[SHOOTOUT_LASER_COUNT]; @@ -98,3 +125,9 @@ extern CShootoutLaser shootout_lasers[SHOOTOUT_LASER_COUNT]; shootout_lasers[i].id = id; \ } \ } + +#define shootout_lasers_unput_and_reset_broken(i) { \ + for(i = 0; i < SHOOTOUT_LASER_COUNT; i++) { \ + shootout_lasers[i].unput_and_reset(); \ + } \ +} diff --git a/th01/main/bullet/laser_s.inc b/th01/main/bullet/laser_s.inc index 32474e82..208d6e21 100644 --- a/th01/main/bullet/laser_s.inc +++ b/th01/main/bullet/laser_s.inc @@ -6,23 +6,6 @@ shootout_laser_unput_and_reset_broken macro @@slot:req imul bx, size CShootoutLaser cmp _shootout_lasers[bx].SL_alive, 0 jz short @@skip - - ; Two ZUN bugs here: - ; - ; 1) Surely this should have unblitted from the start to the end of the - ; ray instead? Except that CShootoutLaser doesn't explicitly store that - ; end point... so the best alternative would be the target point. But - ; given that CShootoutLaser has its own blitting routine, who knows how - ; accurate that actually is? - ; - ; 2) graph_r_line_unput() takes screen_x_t and vram_y_t, not LaserPixels - ; truncated to 16-bits :zunpet: As a result, these calls effectively - ; unblit random 32-bit pixel chunks. - ; - ; Not that it matters a lot. This function is only called at the end of a - ; boss battle, immediately before transitioning to the tally screen. - ; Still, not doing anything would have been the better choice. - mov bx, @@slot imul bx, size CShootoutLaser push word ptr _shootout_lasers[bx].SL_origin_y