Fix bug leading to crash when trying to add centipede body segments. I needed to have a nop instruction after the self-modifying long jump. I am writing 4 bytes of the address into the long jump which only uses a 3 byte address and I was corrupting the next instruction. Inserting a nop ensures no corruption happens.

This commit is contained in:
Jeremy Rand 2020-09-06 13:39:00 -04:00
parent f5d1aa9ee6
commit 3b541f8482
3 changed files with 26 additions and 29 deletions

View File

@ -296,18 +296,17 @@ checkKey_slow anop
checkKey_centipede anop checkKey_centipede anop
jsl addHeadSegment jsl addHeadSegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jsl addHeadSegment jsl addBodySegment
jmp addHeadSegment jmp addBodySegment
; jmp addBodySegment
waitForKey entry waitForKey entry

View File

@ -52,16 +52,23 @@ drawSegments_head anop
jsl segmentHeadJump jsl segmentHeadJump
drawSegments_handleTiles anop drawSegments_handleTiles anop
_dirtyGameTileWithX segmentTileOffsetsUL lda #TILE_STATE_DIRTY
_dirtyGameTileWithX segmentTileOffsetsUR ldy segmentTileOffsetsUL,x
_dirtyGameTileWithX segmentTileOffsetsLL sta tileDirty,y
_dirtyGameTileWithX segmentTileOffsetsLR
ldy segmentTileOffsetsUR,x
sta tileDirty,y
ldy segmentTileOffsetsLL,x
sta tileDirty,y
ldy segmentTileOffsetsLR,x
sta tileDirty,y
drawSegments_skipSegment anop drawSegments_skipSegment anop
dex dex
dex dex
bmi drawSegments_done bpl drawSegments_nextSegment
bra drawSegments_nextSegment
drawSegments_done anop drawSegments_done anop
rtl rtl
@ -89,8 +96,8 @@ segmentHeadJump_noShift anop
segmentHeadJump_jumpInst anop segmentHeadJump_jumpInst anop
jmp >leftHead1 jmp >leftHead1
nop
segmentBodyJump entry segmentBodyJump entry
lda segmentScreenShifts,x lda segmentScreenShifts,x
beq segmentBodyJump_noShift beq segmentBodyJump_noShift
@ -113,7 +120,7 @@ segmentBodyJump_noShift anop
segmentBodyJump_jumpInst anop segmentBodyJump_jumpInst anop
jmp >leftHead1 jmp >leftHead1
nop
updateSegments entry updateSegments entry
lda segmentSpriteShift lda segmentSpriteShift

View File

@ -65,15 +65,6 @@ _drawDirtyGameRow_skip&tileOffset anop
aif &tileOffset<&lastTileOffset,.drawDirtyGameRowLoop aif &tileOffset<&lastTileOffset,.drawDirtyGameRowLoop
mend mend
; This macro uses the X register as an index into the tile offsets. This is
; needed for segments because each segment has their own dirty tile offsets.
macro
_dirtyGameTileWithX &tileOffset
ldy &tileOffset,x
lda #TILE_STATE_DIRTY
sta tileDirty,y
mend
macro macro