[4.5.x] Animated Tiles with CHR-RAM Switching

JamesNES

Well-known member
Last time someone had problems I said I'd say this next time, did you make sure your hi and lo addresses have the right symbols? #< for lo and #> for hi
 
Last time someone had problems I said I'd say this next time, did you make sure your hi and lo addresses have the right symbols? #< for lo and #> for hi
Hey just woke up from last night. unfortunately, I checked bank 16 (where you said in the tutorial to put them) and the symbols are correct from what you said...
#< for low as well as #> for high. if you want to help me I can send you each edited script from the tutorial! if you can solve this either I'll even ask to Venmo you five bucks!
I'm serious!
 
Hey just woke up from last night. unfortunately, I checked bank 16 (where you said in the tutorial to put them) and the symbols are correct from what you said...
#< for low as well as #> for high. if you want to help me I can send you each edited script from the tutorial! if you can solve this either I'll even ask to Venmo you five bucks!
I'm serious!
oh! and in order to send you the edited scripts, I'll DM you a few links from google drive.
 

JamesNES

Well-known member
This might not be the cause, but in doLoadScreen16.asm your first SwitchCHRBank macro comes before the label at the top so it's not getting done when you jump to that.

Also I can't see where you've included doLoadScreen16.asm in bank 16. Apart from those everything seemed identical.

I've attached the original files I wrote for this tutorial way back, I recompiled it this morning and it's all working.
 

Attachments

  • chr switch.zip
    12.6 KB · Views: 7
This might not be the cause, but in doLoadScreen16.asm your first SwitchCHRBank macro comes before the label at the top so it's not getting done when you jump to that.

Also I can't see where you've included doLoadScreen16.asm in bank 16. Apart from those everything seemed identical.

I've attached the original files I wrote for this tutorial way back, I recompiled it this morning and it's all working.
sorry to ask... but now this pops up:

IDontHaveLoadCHRHowDoYouInstallThat.PNG
I Know LoadCHRData should (probably) be a Macro... but I don't have it. so I guess we figured out where I forgot the tutorial
haha... but can you send me it... along with the instructions on how to put it in the macros section of code along with (probably) SwitchCHRBank.asm?

EDIT: Also do you mind giving me your actual first and last name for the credits when the game is finished?
 

JamesNES

Well-known member
LoadCHRData is already in as a macro by default. Macros go in the System\Macros folder which is where SwitchCHRBank.asm should've been put to be able to use it.

It might be complaining if you haven't set up the user screen bytes part properly using that other tutorial.

Don't need to worry about credit or anything, just doing it for the exercise.
 
LoadCHRData is already in as a macro by default. Macros go in the System\Macros folder which is where SwitchCHRBank.asm should've been put to be able to use it.

It might be complaining if you haven't set up the user screen bytes part properly using that other tutorial.

Don't need to worry about credit or anything, just doing it for the exercise.
off the computer with nesmaker right now so I'll check tommorow thank you for the advice and patience!
other than that again I love representing people in credits! if you don't want to at all that's fine too... but can I have your full name for the credits?
again no pressure I won't do it if you don't want to share it.

EDIT: OH I JUST REMEMBERED as I posted!
the reason the userscreenbytes is messed up is because I tried using the your asm files in a different alpha of the game I have as a backup duh!
this alpha was a backup while making the animated tiles!
 
Okay Just fixed EVERYTHING, I think...
did you program every on-screen tile regardless of look to flash? if so how can I fix it?
secondly, ignore the pallet & cactus I can easily fix those through DoLoadScreen16 I'm pretty sure
(the cactus is the first thing I'm animating oooooh)
also how many of these animated tiles can I put into the game MAX
I need at least 14 four frame (or if I have two frames) animated Tiles and at best: around thirty-four (other than the first fourteen these vary in length from 2, 3,& 4)

and finally, here is a video to show you what I mean about if it is fixed?:
View: https://youtu.be/uf8R6Pamn9s
 

SciNEStist

Well-known member
It looks like your tile layout might be different. set it to " no path (main, screen*3) "

I'm not sure how to make it work with other tile layouts, or get more animated than the top 8. if it is possible, I'd like to know as well.
 

JamesNES

Well-known member
It looks like your tile layout might be different. set it to " no path (main, screen*3) "

I'm not sure how to make it work with other tile layouts, or get more animated than the top 8. if it is possible, I'd like to know as well.

You can do anything you want with it, what's going on might look more complicated than it actually is, if I explain it you should be able to modify it.

The only things to change would be in doLoadScreen16. The first important bit is what I put at the end of LOAD_MSSS:

Code:
    LDA userScreenByte7
    BEQ +noAnimatedTiles
        INC tempj
        LDA tempj
        CMP #$03
        BEQ +noAnimatedTiles
            SwitchCHRBank tempj
            JMP MSSS_CHR_LOAD_LOOP
    +noAnimatedTiles
  
    JMP doneLoadingChrs

This just loops through it 3 times (I should've just made the guide for all 4 banks) to fill all the CHR banks with the default main/screen/screen/screen graphics you have set up in NES Maker. If you put something like this in the sections other than MSSS it'll work just the same.

The second part is at the end, that loads a single strip into the second and third banks:

Code:
       ;;userScreenByte7 is used as the offset for getting tile data addresses from AnimTiles_Lo/Hi
        SwitchCHRBank #$01
        LoadChrData #$17, #$10, #$00, #$20, AnimTiles_Lo, AnimTiles_Hi, userScreenByte7
        jsr doWaitFrame
      
        INC userScreenByte7
      
        SwitchCHRBank #$02
        LoadChrData #$17, #$10, #$00, #$20, AnimTiles_Lo, AnimTiles_Hi, userScreenByte7
        jsr doWaitFrame

       SwitchCHRBank #$00  ;;switch back to the first bank

If you get rid of that part, and modify the first part to load in a DIFFERENT full size CHR each time, and the screen-specific tiles, you can animate absolutely everything. It's basically just telling it to load different graphics into each CHR bank. Have a look at the arguments LoadCHRData takes, like number of columns/rows to load, it should make sense. And because it's already loading all the banks up anyway, there won't be a difference in loading time between screens.

There's also the other loop at the end but that's just for filling the banks with the sprite data. It'd be interesting to see what would be possible animating those as well, but I can't think of anything.
 

SciNEStist

Well-known member
in response to your video:

The best way to specify which objects are allowed to trigger a tile is not in the changetileatcollision macro, but the tile scripts themselves (scripts> defined scripts, then on the next panel, Game>tile types>pick the tile you want. )

make sure you arent editing blank.asm

at the beginning of the tile type script for the tile you want only certain things to trigger, add something like this:

Code:
    LDA Object_flags,x
    AND #%00000010 ; is it a player?
    BNE +
        RTS
    +

that will only allow player types
or

Code:
    LDA Object_type,x
    CMP #$06 ; is it object 6?
    BEQ +
        RTS
    +

in that example, object #6 will trigger the tile at collision

if you want to be able to have more than 1 object that can trigger the tile, then you ould do it like this:

Code:
    LDA Object_type,x
    CMP #$01 ; is it object 1?
    BEQ +
    CMP #$06;  is it object 6?
    BEQ +
        RTS ; if neither, then stop
    +
    ;rest of the code goes under here
 

SciNEStist

Well-known member
There's also the other loop at the end but that's just for filling the banks with the sprite data. It'd be interesting to see what would be possible animating those as well, but I can't think of anything.
Thanks for the info James!

as for swapping out animation tiles, that could be an interesting way to add secondary animations. for example, have all the character sprites flip over momentarily to another sprite sheet that has the character eyes closed, then switch back. then randomize the interval, and you have a randomly blinking character
 

Shaoran

New member
Is this possible in 4.1.5? Since there is no loadScreen16.asm I wouldn't know where to put it.
 
Last edited:

JamesNES

Well-known member
Thanks for the info James!

as for swapping out animation tiles, that could be an interesting way to add secondary animations. for example, have all the character sprites flip over momentarily to another sprite sheet that has the character eyes closed, then switch back. then randomize the interval, and you have a randomly blinking character

That'd be a lot of effort for blinking haha when you swap banks it swaps the background tiles too though so it'd be one or the other, unless your dude blinked in time with the tiles animating.

Is this possible in 4.1.5? Since there is no loadScreen16 I wouldn't know where to put it.

I looked into that for someone a while back but couldn't figure it out, I'm not familiar with that version at all.
 
in response to your video:

The best way to specify which objects are allowed to trigger a tile is not in the changetileatcollision macro, but the tile scripts themselves (scripts> defined scripts, then on the next panel, Game>tile types>pick the tile you want. )

make sure you arent editing blank.asm

at the beginning of the tile type script for the tile you want only certain things to trigger, add something like this:

Code:
    LDA Object_flags,x
    AND #%00000010 ; is it a player?
    BNE +
        RTS
    +

that will only allow player types
or

Code:
    LDA Object_type,x
    CMP #$06 ; is it object 6?
    BEQ +
        RTS
    +

in that example, object #6 will trigger the tile at collision

if you want to be able to have more than 1 object that can trigger the tile, then you ould do it like this:

Code:
    LDA Object_type,x
    CMP #$01 ; is it object 1?
    BEQ +
    CMP #$06;  is it object 6?
    BEQ +
        RTS ; if neither, then stop
    +
    ;rest of the code goes under here
I added the this code to the interactive tile and it still only half-works:
;Grass THIS IS THE TILE FOR FIXXINNNNNNNNGG!
GetActionStep player1_object
CMP #$02
BEQ mytileupdate
JMP +notPlayer
mytileupdate:
LDA Object_type,x
CMP #$00
BEQ mytileupdateparttwo
JMP notErasor
mytileupdateparttwo:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; BELOW WILL CHANGE TILE AT COLLISION.
ChangeTileAtCollision #$08, #$01
CreateObject tempA, tempB, #$0F, #$00
JMP notErasor

+notPlayer
LDA Object_type,x
CMP #$0F ; is it object 15?
BEQ isErasor
JMP notErasor
isErasor:
ChangeTileAtCollision #$00, #$0C
notErasor:
RTS
The player cursor turns the next tile into the last. but the non-player cleanup object doesn't "erase" the next tile
(changes it into a blank tile) :|
 
You can do anything you want with it, what's going on might look more complicated than it actually is, if I explain it you should be able to modify it.

The only things to change would be in doLoadScreen16. The first important bit is what I put at the end of LOAD_MSSS:

Code:
    LDA userScreenByte7
    BEQ +noAnimatedTiles
        INC tempj
        LDA tempj
        CMP #$03
        BEQ +noAnimatedTiles
            SwitchCHRBank tempj
            JMP MSSS_CHR_LOAD_LOOP
    +noAnimatedTiles
 
    JMP doneLoadingChrs

This just loops through it 3 times (I should've just made the guide for all 4 banks) to fill all the CHR banks with the default main/screen/screen/screen graphics you have set up in NES Maker. If you put something like this in the sections other than MSSS it'll work just the same.

The second part is at the end, that loads a single strip into the second and third banks:

Code:
       ;;userScreenByte7 is used as the offset for getting tile data addresses from AnimTiles_Lo/Hi
        SwitchCHRBank #$01
        LoadChrData #$17, #$10, #$00, #$20, AnimTiles_Lo, AnimTiles_Hi, userScreenByte7
        jsr doWaitFrame
     
        INC userScreenByte7
     
        SwitchCHRBank #$02
        LoadChrData #$17, #$10, #$00, #$20, AnimTiles_Lo, AnimTiles_Hi, userScreenByte7
        jsr doWaitFrame

       SwitchCHRBank #$00  ;;switch back to the first bank

If you get rid of that part, and modify the first part to load in a DIFFERENT full size CHR each time, and the screen-specific tiles, you can animate absolutely everything. It's basically just telling it to load different graphics into each CHR bank. Have a look at the arguments LoadCHRData takes, like number of columns/rows to load, it should make sense. And because it's already loading all the banks up anyway, there won't be a difference in loading time between screens.

There's also the other loop at the end but that's just for filling the banks with the sprite data. It'd be interesting to see what would be possible animating those as well, but I can't think of anything.
thanks for the help I will definitely read this later I need to fix the first major bug (halfway there?) then I'll look into this further
 
Got the Moving Half-Working (sorry I know this movement of tiles is unrelated to the main post)
here is the newest issue:
View: https://youtu.be/3qHVTKS3_JM


I've tried multiple ways to stop the quick switch back and forth during tile collision and this was the best I got:
HTML clipboard GetActionStep player1_object
CMP #$02
BEQ MovingDown
JMP stillMovingDown
MovingDown:
PlaySound #sfx_cursor
LDA #$01
STA switchTiles
LDA Object_y_hi,x
CLC
ADC #$10 ;how far is it moving? (15px in this case, as there seems to be an offset)
STA Object_y_hi,x ;; store it into the new x
RTS
the switch tiles variable was supposed to trigger the blank tile to spawn where the current tile is
then the cursor moves
followed by it still being blank. so yeah... :|
 
Top Bottom