Skip to content

Commit 12f29c6

Browse files
committed
[Anniversary] [th01] Shootout lasers: Remove unblitting on reset
Freezing the lasers in place during the defeat animation is arguably nicer than trying to unblit them, *and* we don't need to work around the graph_r_line() General Protection Fault! Completes P0234, funded by Ember2528.
1 parent 80ee9b2 commit 12f29c6

6 files changed

Lines changed: 14 additions & 44 deletions

File tree

th01/main/boss/b10j.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1341,7 +1341,7 @@ void mima_main(void)
13411341
mdrv2_bgm_fade_out_nonblock();
13421342
Pellets.unput_and_reset();
13431343
Missiles.reset();
1344-
shootout_lasers_unput_and_reset_broken(i, 5); // 5? Doubly broken...
1344+
shootout_lasers_reset();
13451345
boss_defeat_animate();
13461346
}
13471347
}

th01/main/boss/b15j.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ void kikuri_main(void)
11381138
if(boss_hp <= 0) {
11391139
mdrv2_bgm_fade_out_nonblock();
11401140
Pellets.unput_and_reset();
1141-
shootout_lasers_unput_and_reset_broken(i, 4); // 4? Doubly broken...
1141+
shootout_lasers_reset();
11421142
boss_defeat_animate();
11431143
}
11441144
}

th01/main/boss/b15m.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2111,7 +2111,7 @@ void elis_main(void)
21112111
Pellets.unput_and_reset();
21122112
girl_bg_put(1);
21132113
Missiles.reset();
2114-
shootout_lasers_unput_and_reset_broken(i, SHOOTOUT_LASER_COUNT);
2114+
shootout_lasers_reset();
21152115
boss_defeat_animate();
21162116
}
21172117
}

th01/main/boss/b20m.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2707,7 +2707,7 @@ void sariel_main(void)
27072707

27082708
Shots.unput_and_reset();
27092709
Pellets.unput_and_reset();
2710-
shootout_lasers_unput_and_reset_broken(i, SHOOTOUT_LASER_COUNT);
2710+
shootout_lasers_reset();
27112711

27122712
// MODDERS: Move this to a common player reset function.
27132713
orb_cur_left = ORB_LEFT_START;

th01/main/bullet/laser_s.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,10 @@ void CShootoutLaser::update_hittest_and_render(void)
150150
hittest_and_render(SL_RAY_PUT);
151151
grcg_off_func();
152152
}
153+
154+
void shootout_lasers_reset(void)
155+
{
156+
for(int i = 0; i < SHOOTOUT_LASER_COUNT; i++) {
157+
shootout_lasers[i].alive = false;
158+
}
159+
}

th01/main/bullet/laser_s.hpp

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -82,41 +82,6 @@ class CShootoutLaser {
8282

8383
// Directly sets [done] if the laser collides with the player.
8484
void update_hittest_and_render(void);
85-
86-
// Tries to unblit the entire laser, but fails hilariously and potentially
87-
// even crashes the game.
88-
void unput_and_reset(void) {
89-
if(alive) {
90-
// ZUN bug: And even two of them:
91-
//
92-
// 1) Surely this should have unblitted from the start to the end
93-
// of the ray instead? Except that this class doesn't explicitly
94-
// store that end point… so the best alternative would be the
95-
// target point. But given that we use our own blitting routine,
96-
// who knows how accurate that actually is?
97-
//
98-
// 2) graph_r_line_unput() takes screen_x_t and vram_y_t, not
99-
// LaserPixels truncated to 16-bits. :zunpet: The function then
100-
// interpolates and clips these values in a rather clumsy
101-
// attempt to find a line segment between those garbage
102-
// coordinates that actually falls within the boundaries of
103-
// VRAM. At best, this search fails, and the function simply
104-
// does nothing. At worst, the resulting line triggers the ZUN
105-
// bugs in graph_r_line_unput(), raising a General Protection
106-
// Fault.
107-
// The latter is exactly the cause behind potential crashes when
108-
// defeating bosses while there are diagonally moving lasers on
109-
// screen, which are most commonly reported for Elis and Mima.
110-
//
111-
// So yeah, not doing anything would have been the much better
112-
// choice.
113-
graph_r_line_unput(
114-
ray_start_left.v, ray_start_y.v, origin_left.v, origin_y.v
115-
);
116-
117-
alive = false;
118-
}
119-
}
12085
};
12186

12287
extern CShootoutLaser shootout_lasers[SHOOTOUT_LASER_COUNT];
@@ -125,8 +90,6 @@ extern CShootoutLaser shootout_lasers[SHOOTOUT_LASER_COUNT];
12590
#define shootout_laser_safe(i) \
12691
shootout_lasers[(i) % SHOOTOUT_LASER_COUNT]
12792

128-
#define shootout_lasers_unput_and_reset_broken(i, count) { \
129-
for(i = 0; i < count; i++) { \
130-
shootout_lasers[i].unput_and_reset(); \
131-
} \
132-
}
93+
// Resets all lasers, but leaves them in VRAM. The boss defeat animation is
94+
// supposed to get rid of them.
95+
void shootout_lasers_reset(void);

0 commit comments

Comments
 (0)