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

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
NEVERMIND! FIXED THE TILE GLITCH! Now it's time to fix the animation glitch!... (after I finish the demo ;))
 

Jonny

Well-known member
So, I though I wasn't going to bother going upto 4 banks but the temptation was too great.

Got it all set up, working but with a glitched 4th CHR bank.

After pulling my hair out for a couple of hours I finally found out it would only work as inteded if I did this...

Code:
AnimTiles3_Lo:
    .db #$00, #$00, #<AnimTiles07, #<AnimTiles08, #<AnimTiles09
AnimTiles3_Hi:
    .db #$00, #$00, #>AnimTiles07, #>AnimTiles08, #>AnimTiles09

I know this is wrong but for some reason I am having to put two #$00 values at the start of the table to get normal tiles (as it would be with no anim) then the other three. I mean, it works so I guess it doesn't need fixing, I'm just curious now whether anyone knows - have I set the bank back to 0 too many times? Not done it enough? I've been though the code a few times and I can't see where I've messed up (it's a very long and convoluted doLoadScreen so maybe I'm just not seeing or realising something).

I noticed in an earlier post @5kids2feed mentions doing this...

Code:
AnimTiles_Lo:
.db #$00, #<AnimTiles01, #<AnimTiles02, #<AnimTiles03, #<AnimTiles04
AnimTiles_Hi:
.db #$00, #>AnimTiles01, #>AnimTiles02, #<AnimTiles03, #<AnimTiles04

...but doesn't that mean to use the 4 bank switching in this way you're not using the original/normal tile load i.e the main tileset as it would normal be loaded but instead using 4 loads so having to have 1 more set of CHR in memory to achive the same thing? Confused yet? I definately am lol
 

JamesNES

Well-known member
So, I though I wasn't going to bother going upto 4 banks but the temptation was too great.

Got it all set up, working but with a glitched 4th CHR bank.

After pulling my hair out for a couple of hours I finally found out it would only work as inteded if I did this...

Code:
AnimTiles3_Lo:
    .db #$00, #$00, #<AnimTiles07, #<AnimTiles08, #<AnimTiles09
AnimTiles3_Hi:
    .db #$00, #$00, #>AnimTiles07, #>AnimTiles08, #>AnimTiles09

I know this is wrong but for some reason I am having to put two #$00 values at the start of the table to get normal tiles (as it would be with no anim) then the other three. I mean, it works so I guess it doesn't need fixing, I'm just curious now whether anyone knows - have I set the bank back to 0 too many times? Not done it enough? I've been though the code a few times and I can't see where I've messed up (it's a very long and convoluted doLoadScreen so maybe I'm just not seeing or realising something).

I noticed in an earlier post @5kids2feed mentions doing this...

Code:
AnimTiles_Lo:
.db #$00, #<AnimTiles01, #<AnimTiles02, #<AnimTiles03, #<AnimTiles04
AnimTiles_Hi:
.db #$00, #>AnimTiles01, #>AnimTiles02, #<AnimTiles03, #<AnimTiles04

...but doesn't that mean to use the 4 bank switching in this way you're not using the original/normal tile load i.e the main tileset as it would normal be loaded but instead using 4 loads so having to have 1 more set of CHR in memory to achive the same thing? Confused yet? I definately am lol
How are you doing it? Easiest would be to have a screen flag that tells it whether to load and cycle 3 or 4 banks. Then you can put it in the same AnimTiles_Lo/Hi tables and it'll work like normal.

There'd be only three spots to change, the three "CMP #$03"s would just change to a variable that's either 3 or 4 depending on that screen flag. So two CMPs in load screen and one in your timer script.

Could loop the part at the bottom of load screen as well really. I was pretty green when I wrote this originally and also probably pretty lazy.
 

Jonny

Well-known member
I basically did all that adding another INC userScreenByte2 then the load for 4th one in doLoadScreen16. The switching worked just with glitched tiles for the 4th bank. The only way I could get it to work was by having the table set up with two #$00 at the start. Mostly curious what that table *should* look like when everything else is correct... for switching 4 banks, I presume is should just be the original bank #$00, then the other 3, not 5 as some people have done?

I mean, it works properly as I've got it set up now but just seems odd and that I'm doing something wrong.
 

Jonny

Well-known member
I'm not explaining what I mean very well sorry about that! What I'm trying to ask is, should the tables being used look like this...

Code:
AnimTiles3_Lo:
    .db #$00, #<AnimTiles07, #<AnimTiles08, #<AnimTiles09
AnimTiles3_Hi:
    .db #$00, #>AnimTiles07, #>AnimTiles08, #>AnimTiles09

i.e the four different banks, starting with #$00, then the other three? Seems to start at the second place of that table in my example and what @5kidstofeed is doing above, only for mine I'm not using another set of CHR.
 

Jonny

Well-known member
I'd post the code but it's very very very long and it doesn't matter a great deal as it's working as it should. I don't want to waste your time, I was just super confused about that table becuase that's ultimately the thing that stopped the glitching by adding the extra #$00 at the start.
 

JamesNES

Well-known member
It's no trouble, I like thinking about this stuff.

The user screenbyte argument of the LoadCHR macro just tells it what offset to use in your AnimTiles table, ie the lo and hi addresses in the earlier part of the macro. So if it's loading garbage that means the screenbyte argument must be wrong, maybe too high and loading random data as graphics.

You should be able to have all your CHR files in the same address tables, as it'd only be trying to load four in a row if you've told it it's a screen with four graphics sets.

Having separate tables might just complicate things.

But hey, if it's working and you can add stuff to it without issues then... it only costs two bytes haha
 

Jonny

Well-known member
I'll give that a go (putting them in the same table) when I'm giving my game it's 'final flurish'. Just lack of proper understanding why I seperated them I expect. For now I wont rock the boat but it's something to jot down for later. I'm pretty certain you're exactly right. I do have a lot of these seperate tables.

That's really helpful thanks old bean.
 

Vasyan

New member
Hello, tell me where DoLoadScreen16 should be, I don’t have it in the project, and I don’t know where to connect it?
 

Vasyan

New member
And why are the jars filled with black tiles to the end?
 

Attachments

  • Безымянный.jpg
    Безымянный.jpg
    118.8 KB · Views: 9
  • Безымянный1.jpg
    Безымянный1.jpg
    81.1 KB · Views: 9
  • Безымянный2.jpg
    Безымянный2.jpg
    68.4 KB · Views: 10

dale_coop

Moderator
Staff member
I'd suggest to follow all the tutorial videos ;)
Animation speed ... is "Animation Speed" in the object details, to be set for the action step you are using.
 

Vasyan

New member
I'd suggest to follow all the tutorial videos ;)
Animation speed ... is "Animation Speed" in the object details, to be set for the action step you are using.
Hello Dale! Thank you I review all possible videos and hour-long tutorials for 10-15 minutes of useful information. Now my main question is to adapt Button Lock to version 4.5.6, so far nothing has come of it, can you help me with this? It should be easier than Monster Lock, just after the button tile is pressed to make the spikes tiles disappear
 

dale_coop

Moderator
Staff member
A tile would be kinda tricky... because the collision type is executed every frames... until you're not colliding with it anymore. So it would always execute again and again the code to replace all the lock tiles. In that case, I'd suggest to change the collision of the button to 0 as soon as the player colliding it, to only execute the code once.

An example of changing the tile collision to 0 can be find in the collectable tiles.
And the replace all tiles at collision is done here: https://www.nesmakers.com/index.php...to-bring-back-changealltiles.6727/#post-38543
 
Top Bottom