Fix the bug where the tiles on the RHS may be marked dirty and accumulate garbage if the player dies on the RHS. Add some more debug for the crashing bug I am chasing. It looks like more than 12 segments have been added so I am adding debug to detect when the number of segments exceeds 12.

This commit is contained in:
Jeremy Rand 2020-12-25 23:59:09 -05:00
parent a5296ee1b8
commit dbbdd156e3
3 changed files with 20 additions and 2 deletions

View File

@ -10,8 +10,8 @@ This is a list of the software bugs (as opposed to the bugs in the game that you
* I reproduced it and ended up at brk $4 with y set to $2270 which is much larger than the max of 156. Also odd is that X is 1 but I think it needs to be an even number.
* In order to get the wrong value in Y, I noticed that the segmentSpriteOffset was overwritten with the pattern 70 02 70 02, etc.
* Something is trashing memory.
* 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.
* I have just seen it again. I think the problem happens when the player dies on the extreme RHS of the screen (perhaps the LHS also but I have seen it on the RHS). I think the non game tile just beyond the bounds gets marked as dirty but is not put on the dirty non-game tiles list. So, it remains "dirty" forever and is never cleaned up. Once that happens, then if a spider traverses the tile, it leaves behind junk.
* Just got the same crash on real HW with the same register values and everything.
* Based on the investigation, it looks like 24 segments have been added which means the segment data structures have all overflowed. I am adding validation to check that the number of segments added never exceeds 12.
* I have seen some mushrooms appear suddenly. Sometimes, if I am shooting, the shot "hits" an invisible mushroom which then becomes visible. My guess is that there is something wrong with the code which turns a centipede segment into a mushroom when shot and the tile isn't correctly marked dirty all the time.
* In theory, there shouldn't be a collision with an invisible mushroom but what happens is that when the shot overlaps with the tile, it becomes dirty. At that point, the mushroom will appear on the next frame and a collision can then occur.
* It is possible to shoot between two segments of a centipede. The problem is that there are black pixels between the segments and if things are timed just right (or just wrong), the shot can slot in at those black pixels and end up missing both segments.
@ -22,6 +22,9 @@ This is a list of the software bugs (as opposed to the bugs in the game that you
FIXED
=======
* 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.
* I have just seen it again. I think the problem happens when the player dies on the extreme RHS of the screen (perhaps the LHS also but I have seen it on the RHS). I think the non game tile just beyond the bounds gets marked as dirty but is not put on the dirty non-game tiles list. So, it remains "dirty" forever and is never cleaned up. Once that happens, then if a spider traverses the tile, it leaves behind junk.
* Confirmed. The code which exploded the player on the RHS would mark the non game tile as dirty because it always marked three tiles in a row as dirty. But the 3rd when right on the edge is a non-game tile. It just needed to skip marking it as dirty.
* I am still seeing shots go through almost gone mushrooms sometimes. I checked more rows of pixels for collisions even though the shot doesn't draw there but it still seems to be possible. If the height of the shot is equal to the amount it moves in one frame, it shouldn't be possible so that is worth checking.
* I said I already fixed this below but I only did half the job. What I tried to implement was a collision detection for the full 8 pixel height of the shot even though the shot is only 6 pixels tall. In the end, I just implemented that for the "shifted" shot sprite and not the unshifted version. I have corrected that oversight and that should address this.
* Sometimes at the end of the flea sound, there is a short high pitched tone.

View File

@ -151,6 +151,8 @@ updatePlayer_drawExplosionSkipBelow1 anop
sta tileDirty,x
updatePlayer_drawExplosionSkipBelow2 anop
ldx tileRight,y
cpx #RHS_FIRST_TILE_OFFSET
bge updatePlayer_drawExplosionSkipBelow3
sta tileDirty,x
ldy tileBelow,x
cpy #INVALID_TILE_NUM

View File

@ -1482,6 +1482,13 @@ addBodySegment entry
tax
inc numSegments
; DEBUG - Validate the number of segments
lda numSegments
cmp #SEGMENT_MAX_NUM+1
blt addBodySegment_isOK
brk $11
addBodySegment_isOK anop
; DEBUG - End of validation
lda #SEGMENT_STATE_BODY
sta segmentStates,x
@ -1676,6 +1683,12 @@ addBodySegment_slow anop
; preserve the X register.
addCentipede entry
lda numSegments
; DEBUG - Validate the number of segments
cmp #SEGMENT_MAX_NUM
blt addCentipede_isOK
brk $10
addCentipede_isOK anop
; DEBUG - End of validation
asl a
tay