4.5.9 -- Get More Monsters In Your Game By Storing In Two Banks

3DPLABox

Member
Okay. I have a weird question. So I'm using a lot of unique/bespoke code to manually draw monters to help with slowdown. When I use this method to bankswitch to 1D, I get all kinds of errors if I don't take out a lot of my unique sprite draw code from the default script.

As an example, this is what I'm doing at the top of the script to check for monsters and manually draw them if possible. How do I go about incorporating this system into this method without massive errors? This works fine and I even have several more monsters in the full version of the script below before I hit the "limit" and get an error. Again, for the record, this is just the default drawSprites_Platformer script with a bunch of CMP checks upfront to manually draw monsters (and it has the 1D bankswitch stuff noted in this thread).

Is there a way to use Bank 1D to do these unique draw commands so I can avoid the error? Every time I try to change the place of the bank switch command, I get errors or the game freezes.

Code:
    LDA gameHandler
    AND #%01000000
    BEQ doDrawThisSprite
    JMP doneDrawingThisSprite
doDrawThisSprite:
  
;; This routine will work together with the luts created by the old object animation tool.
;; Due to that, it must be included in the same bank with luts.

    ;; We will use tempA to track the x value of a tile.
    ;; We will use tempB to track the y value of a tile.
    ;; X is the index of the object.
    ;; Y is the index of the object type.
  
    ;; ObjectSize,y is the size in tiles for this version of drawing.
    ;; 00xxxyyy
    ;; where x = the width in tiles (1-7)
    ;; where y = the height in tiles (1-7)
    ;; for both, zero is an impossible value.
  
    ;; Object_frame,x keeps track of actions and animations.
    ;; 00xxxyyy
    ;; where x = animation frame
    ;; where y = action frame

    ;LDY Object_type,x ;; for lut lookups.
  
    LDA Object_x_hi,x
    SEC
    SBC camX ;; is using scrolling
    STA tempA
    LDA Object_y_hi,x
    ;sec
    ;SBC camY
    STA tempB
  
    LDY Object_type,x
  
    LDA Object_type,x
    CMP #$01
    BEQ +isPlayerProjectile   ;;;;START OF NEW STUFF
        JMP +isNotNormalProjectile
  
    +isPlayerProjectile
        ;;; DRAW PLAYER PROJECTILE
        GetActionStep temp
        CMP #$01
        BEQ +drawBuzzSaw
            JMP +BuzzSawReverseCheck
          
        +drawBuzzSaw 
        DrawSprite tempA, tempB, #$49, #%00000000
        JMP doneDrawingThisSprite
  
        +BuzzSawReverseCheck
        CMP #$02
        BEQ +drawBuzzSawReverse
            JMP +PlasmaCheck
          
        +drawBuzzSawReverse
        DrawSprite tempA, tempB, #$49, #%00000000
        JMP doneDrawingThisSprite
      
        +PlasmaCheck
        CMP #$03
        BEQ +drawPlasma
        BCS +drawPlasma
            JMP +drawNormalProjectile
          
        +drawPlasma
        DrawSprite tempA, tempB, #$56, #%00000011
        JMP doneDrawingThisSprite
  
        +drawNormalProjectile
        DrawSprite tempA, tempB, #$56, #%00000000
        JMP doneDrawingThisSprite
      
    +isNotNormalProjectile
  
    ;;;and then it has the default stuff below this. In my actual script, I have WAY more
    unique monster draw code. But I get errors if I have this material here after this bankswitching
    method. Any idea how to resolve or where to appropriately move this stuff?

@vanderblade Did you ever find a resolution to this? I really want to move the sprite draw code to 1D but I keep running into the game freezing any time I try to bank switch. I've been at it for hours and have found no solution
 

Vasyan

New member
@vanderblade Did you ever find a resolution to this? I really want to move the sprite draw code to 1D but I keep running into the game freezing any time I try to bank switch. I've been at it for hours and have found no solution
Hello! if it’s still relevant, the freezing is caused by this "ReturnBank.", but this is necessary ReturnBank
 

laurentpb

New member
I got this to work in 4.1.5! It required removing a table, Object_total_sprites from ObjectInfo and placing back in bank 1C, and creating a different dat file. Great work!
Hi,
I am still working on the 4.1.5 version too, thanks for your help, it is now working on my side too.
The Object_total_sprites keep writting itselft in ObjectInfo (now in my #$1A bank) when I compile the code, so i've created the vector Object_total_sprites2 separately from Object_total_sprites and it works. But know if I create a new monster, I have to manually copy and paste Object_total_sprites to Object_total_sprites2 each time.
Do you know if there's a way to change the location of creation Object_total_sprites during compilation, or should I juste create a function during the initialization of the code that create Object_total_sprites2 from Object_total_sprites?

Thanks
 

dale_coop

Moderator
Staff member
Hi,
I am still working on the 4.1.5 version too, thanks for your help, it is now working on my side too.
The Object_total_sprites keep writting itselft in ObjectInfo (now in my #$1A bank) when I compile the code, so i've created the vector Object_total_sprites2 separately from Object_total_sprites and it works. But know if I create a new monster, I have to manually copy and paste Object_total_sprites to Object_total_sprites2 each time.
Do you know if there's a way to change the location of creation Object_total_sprites during compilation, or should I juste create a function during the initialization of the code that create Object_total_sprites2 from Object_total_sprites?

Thanks
You can't change that, sadly. The ObjectInfo scripts are generated by the NESmaker tool itself.
 

laurentpb

New member
Thank you,
And I think I've celebrated a little bit to early. If I'm creating a 65th monster, the game is running, but there's gonna be a graphic lag only for the monster above 63 (if we start counting from 0). Would you have any tip where to look first? At least I have more space for sprites for the first 64 monsters for now.
 

dale_coop

Moderator
Staff member
NESmaker is limited to 64 monsters.
After that the animation data are not exported. And there is nothing we can do, sadly.
I suggest to try to optimze your monster objects, to have less but maybe using differnt subpals to fee different.
 

GlassFrog

Member
I've just done this and it has freed up a load of space, cheers for that as I was running into a load of out of range issues regarding band 1C.
 
Last edited:
Top Bottom