I tamed the beast. Here's the code:
Alternate Secret Tiles
16AD0: BD 76A9 LDA $A976,X
Replace with :
16AD0: 20 90AC JSR $AC90
Alternate Secret Tile Codes Table
16C80: C8 D8 C4 BC C0 C0
Replace with any Tile Code needed
16C90: A4 EB LDY $EB ; Current Location
16C92: B9 FE6A LDA $6AFE,Y ; Screen Attributes - Table 5 (VRAM)
16C95: 30 0E BMI $q2 ; Bit 7 - 2nd Quest
16C97: 0A ASL
16C98: 30 02 BMI $q1 ; Bit 6 - 1st Quest
16C9A: 10 10 BPL $normalTile
16C9C: A4 16 LDY $16 ; Selected Save Slot (0-2)
16C9E: B9 2D06 LDA $062D,Y ; 2nd Quest Flag (0 = 1st Quest, 1 = 2nd Quest)
16CA1: F0 0D BEQ $altTile
16CA3: D0 07 BNE $normalTile
16CA5: A4 16 LDY $16 ; Selected Save Slot (0-2)
16CA7: B9 2D06 LDA $062D,Y ; 2nd Quest Flag (0 = 1st Quest, 1 = 2nd Quest)
16CAA: D0 04 BNE $altTile
16CAC: BD 76A9 LDA $A976,X
16CAF: 60 RTS
16CB0: BD 80AC LDA $AC80,X ; Alternate Secret Tile Codes Table
16CB3: 60 RTS
Feel free to move the code around if necessary. It doesn't solve the problem of tile collision, obviously.
This is fantastic. Thank you for going the extra effort with it.
Converted it to the source code format I am using for xkas, compiled it and indeed, the cracked tiles appear only for the caves specific to each Quest. I moved the new code to 16C30 instead, since there is some Automap code at that same free space, but I even moved it around as well, just to be sure it doesn't collide with any extra code that might be done in the future.
However, there is one issue with the code.
The cracked tiles don't appear for caves that are shared between the two quests.
One quick way to test this:
- Create a blank "LINK" file for 1st Quest, and a blank "ZELDA" file for 2nd Quest
- From the starting area, visit the screen just above it, that one should not appear at all in 1st Quest, but it appears in 2nd Quest. So far so good
- Now from the starting area, go one screen to the left. The secret cave here should always be there, for both 1st and 2nd Quest, but now with the new code, it simply doesn't show the cracked walls for neither 1st nor 2nd Quest
I tried looking in the rest and the map, and this seems to be the same case for every other cave in the game using your new code.
Here are the maps I am using as reference for testing:
1st Quest Map:https://i.pinimg.com/originals/aa/b7/c9/aab7c94432db6b240b19b369505a79e8.png
2nd Quest Map:https://www.nesmaps.com/maps/Zelda/ZeldaOverworldMapQ2.png
I screwed a little bit with your code, Trax, and I think I understand how it works.
I came up with this slight change:
org $AC40 // $16C50 - Free space
ldy.b $EB // Current Location
lda.w $6AFE,y // Screen Attributes - Table 5 (VRAM)
bmi quest2 // Bit 7 - 2nd Quest
bmi quest1 // Bit 6 - 1st Quest
The BPL normalTile
you had there, I modified it to BPL altTile
, so the cracked walls will be loaded up for all the caves that are shared between both Quests, and the rest of the code stays as you wrote it to ensure that only those that are NOT shared are loaded up according to what Quest requires it.
Also, one other thing...
I can make space for other two secret tiles for the overworld, if I can find a way to make the cracked tiles for the Dungeons ONLY appear when inside the Dungeons, and the cracked walls for the OW ONLY appear when in the Overworld.
Here, let me explain a little:
That's the tiles I am currently using for both the cracked walls in the overworld (bottom-left, next to the heart sprites) and the 4 cracked wall positions for the Dungeons.
If I can make those be loaded dynamically when in the Overworld/Dungeons accordingly, I can make other two 2x2 tile TSAs for possibly the burnable trees and another one (possibly the Armos Statues with secret entrances).
I am still not sure as to what the second one could be, but I know for sure I'd like to have burnable trees be identified on the overworld.
Please let me know what do you think