I think I found out what the problem is. At lines 142-151 of nm_zapper.asm, the script loads the object's width and height to calculate the number of white sprites to draw. These dimensions are retrieved from bank $1C, but the script never switches to that bank. This causes the zap script to sometimes load the wrong dimensions, thereby drawing way too many sprites for way too many frames. The fix is to wrap lines 142-151 within a bank switch and return:
Code:
SwitchBank #$1C
LDA ObjectSize,y ; Get the object's height in tiles
AND #%00000111 ;
STA tempC ; and store it in a temp variable
STA tempy ; store it twice; we need to reuse this later
LDA ObjectSize,y ; Get the object's width in tiles
LSR ;
LSR ;
LSR ;
AND #%00000111 ;
STA tempD ; and store it in a temp variable
ReturnBank
I think the
Illegal Instruction, not a number error may be due to different assembler versions, but I'm not sure -- replacing those with $4017 is indeed the correct fix and should not be causing any issues.