From 7368281d58526dc1bdc882cefff12bd068bbb77f Mon Sep 17 00:00:00 2001 From: Jeremy Rand Date: Wed, 2 Dec 2020 23:51:06 -0500 Subject: [PATCH] Fix a long standing bug I have ignored for too long. When adding centipede segments on the left or right, if there was a mushroom right where the segment was arriving, it would try to change direction even though it was still mostly off-screen. This lead to some very strange segment tracks that should never happen. I have added code to ignore blocking mushrooms and not change direction when the segment is partially off-screen. --- BUGS.md | 4 +++- BuGS/gameSegments.s | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/BUGS.md b/BUGS.md index e81c21d..0ee665c 100644 --- a/BUGS.md +++ b/BUGS.md @@ -3,17 +3,19 @@ BUGS This is a list of the software bugs (as opposed to the bugs in the game that you shoot) that still need attention: -* When a centipede segment is added on the right, if there is a mushroom either right at the edge or maybe on tile from the edge (not sure which), the segment seems to turn around and travel up along the edge of the screen. Not sure if this can happen on the left side also. This is likely a problem with the mushroom collision detection and a segment which is mostly off-screen should probably ignore blocking mushrooms until on-screen. * Sometimes centipede segments seem to be stacked one on top of another. You think there is just one left but you shoot it and there is one underneath it. This should not happen. * A spider moving left to right went off screen and left garbage on the RHS as it exited. I have only seen this once. I think it coincided with the player dying. * Sometimes when the player dies, the "you can shoot" indicator is left behind as garbage on-screen. * If you die holding the mouse button down, your next game will start shooting without pressing the mouse button. + * I was reproducing this reliably on real HW but I don't see it from either emulator. Need to try to reproduce it again on real HW. + * I also don't see how this happens given how the code is structured. FIXED ======= +* When a centipede segment is added on the right, if there is a mushroom either right at the edge or maybe on tile from the edge (not sure which), the segment seems to turn around and travel up along the edge of the screen. Not sure if this can happen on the left side also. This is likely a problem with the mushroom collision detection and a segment which is mostly off-screen should probably ignore blocking mushrooms until on-screen. * A shot is able to pass through an almost gone mushroom if lined up just right. Best to change the sprite code for the shot to scan the two pixels below for a collision. * I have seen a couple of crashes. I think an off-screen centipede segment is getting "shot" at the beginning of a level leading to a crash. Almost definitely related to collision and shot handling. * I am seeing other crashes where the PC ends up in bank 22 or so. Need to dig into the stack to figure out where it is coming from. diff --git a/BuGS/gameSegments.s b/BuGS/gameSegments.s index 0c6cc6d..1ce34a6 100644 --- a/BuGS/gameSegments.s +++ b/BuGS/gameSegments.s @@ -560,6 +560,13 @@ updateSegmentLeftFast_checkDir anop lda segmentStates,x cmp #SEGMENT_STATE_POISONED_HEAD beq updateSegmentLeftFast_changeDir +; This is a important special case. When we add segments on the side, we don't want a mushroom +; right on the edge or near the edge to cause a turn and make the segment head off-screen. This +; special case is there only for fast head segments because we only add fast head segments on the +; right and left. + ldx segmentTileOffsetsUR,y + cpx #RHS_FIRST_TILE_OFFSET + bge updateSegmentLeftFast_noChangeDir ldx segmentTileOffsetsUL,y cpx #LHS_FIRST_TILE_OFFSET bge updateSegmentLeftFast_changeDir @@ -587,6 +594,7 @@ updateSegmentLeftFast_checkDir anop ply and segmentTileMask,x bne updateSegmentLeftFast_changeDir +updateSegmentLeftFast_noChangeDir anop rts updateSegmentLeftFast_checkPoison anop @@ -1147,6 +1155,13 @@ updateSegmentRightFast_checkDir anop lda segmentStates,x cmp #SEGMENT_STATE_POISONED_HEAD beq updateSegmentRightFast_changeDir +; This is a important special case. When we add segments on the side, we don't want a mushroom +; right on the edge or near the edge to cause a turn and make the segment head off-screen. This +; special case is there only for fast head segments because we only add fast head segments on the +; right and left. + ldx segmentTileOffsetsUL,y + cpx #LHS_FIRST_TILE_OFFSET + bge updateSegmentRightFast_noChangeDir ldx segmentTileOffsetsUR,y cpx #RHS_FIRST_TILE_OFFSET bge updateSegmentRightFast_changeDir @@ -1174,6 +1189,7 @@ updateSegmentRightFast_checkDir anop ply and segmentTileMask,x bne updateSegmentRightFast_changeDir +updateSegmentRightFast_noChangeDir anop rts updateSegmentRightFast_checkPoison anop cmp #TILE_POISON_MUSHROOM1