[4.5.9] Adding zapper support

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.
Will this fix an issue I encountered? I'm trying to make a scrolling game where you shoot stuff.. (again just toying with NESmaker getting distracted from my main project đź« )
 

kevin81

Well-known member
While it does fix one (pretty serious) issue, it does not yet correct the x-position for scrolling modules.
That's fairly easy to do though: in the zapper handler file, find the line that says LDA Object_x_hi,x and add these lines underneath:

Code:
    SEC
    SBC camX

That will make the handler draw the white tiles in the correct spot on screen.
 
Top Bottom