Hey all - got a nifty little simple LR scrolling routine 99% working with the existing structure. It's ugly, being that it has to work around some things that are already there, but it works well enough for the most part.
Using two nametables and a 32 value column tracker, I've got it updating tiles, attributes, and collisions just as expected, when expected.
One of the challenges has been in making the room for two collision tables. I can't exactly put them adjacent for right now, but I have collisionTable1 and collisionTable2 in RAM. The thing that keeps tripping is doing a test to determine which collision table to read from upon collision detection. I've had to do some crazy tapdancing to get it to work, and I'm left with the very occasional read from the wrong table.
Effectively, I have a oScroll value assigned for each object, which is set at first to the table, but sort of acts as a high byte for the position as well. My method has been something like this:
- Clear the carry
- Load x + speed, store it in temp.
- Load oScroll+0 (if there was a carry, this would increase, if not, would stay the same as oScroll). Store it in temp2.
- do collision detection. If all was clean, load temp2 into oScroll, load temp into x.
Same thing with left movement, but doing a 16 byte evaluation to check if the carry is still set.
Then in the collision detection, I'm reading, and based on what is in temp2, it determines if I should read from the *same page* (if my nt is the first nt, it reads from collisionTable, if it was looking at second, it reads from collisionTable2), or the *opposite page*.
All of this works perfectly, exactly as expected, EXCEPT every once in a while when moving back left, it reads from the wrong table. And I mean about 5% of the time, without any clear pattern as to why.
Knowing I can't easily put the col data consecutively and for now at least need to work off of this two separate table scenario, anyone have any better suggestions for handling this? I had originally thought it was a rather clever way around the issue. But keep having this anomaly, and every time I THINK it's fixed and move on, it pops up again.
Curious what you guys might advise!
Using two nametables and a 32 value column tracker, I've got it updating tiles, attributes, and collisions just as expected, when expected.
One of the challenges has been in making the room for two collision tables. I can't exactly put them adjacent for right now, but I have collisionTable1 and collisionTable2 in RAM. The thing that keeps tripping is doing a test to determine which collision table to read from upon collision detection. I've had to do some crazy tapdancing to get it to work, and I'm left with the very occasional read from the wrong table.
Effectively, I have a oScroll value assigned for each object, which is set at first to the table, but sort of acts as a high byte for the position as well. My method has been something like this:
- Clear the carry
- Load x + speed, store it in temp.
- Load oScroll+0 (if there was a carry, this would increase, if not, would stay the same as oScroll). Store it in temp2.
- do collision detection. If all was clean, load temp2 into oScroll, load temp into x.
Same thing with left movement, but doing a 16 byte evaluation to check if the carry is still set.
Then in the collision detection, I'm reading, and based on what is in temp2, it determines if I should read from the *same page* (if my nt is the first nt, it reads from collisionTable, if it was looking at second, it reads from collisionTable2), or the *opposite page*.
All of this works perfectly, exactly as expected, EXCEPT every once in a while when moving back left, it reads from the wrong table. And I mean about 5% of the time, without any clear pattern as to why.
Knowing I can't easily put the col data consecutively and for now at least need to work off of this two separate table scenario, anyone have any better suggestions for handling this? I had originally thought it was a rather clever way around the issue. But keep having this anomaly, and every time I THINK it's fixed and move on, it pops up again.
Curious what you guys might advise!