News:

11 March 2016 - Forum Rules

Main Menu

Zelda 1 Redux / The Legend of Zelda Redux

Started by ShadowOne333, October 10, 2019, 12:04:03 PM

Previous topic - Next topic

51mmz0rz

So I was talking about the inventory screen, but I didn't know what to call it.  It looks like you mostly fixed it, but I'm still getting a little bit off gibberish on the bottom of the screen:

 

This is playable though, so thank you!


ShadowOne333

Quote from: 51mmz0rz on February 18, 2020, 01:44:18 AM
So I was talking about the inventory screen, but I didn't know what to call it.  It looks like you mostly fixed it, but I'm still getting a little bit off gibberish on the bottom of the screen:

 

This is playable though, so thank you!

Ah I see.
I noticed that the code for that part still has some issues.

I just sent a commit that should fix that now.
I tried it out on my end and it now works properly.

Please, try compiling again and let me know if it's fixed on your end.

51mmz0rz

Working great!  Thanks again for all the work you put into this!

ShadowOne333

Pushed a commit today which should be the fully working Optional bosses patch coutersy of lexluthermeister.
It's inside the Optional.asm file, so don't forget to uncomment the optional section from the main.asm if you want the game to be build with those patches!

The3Dude

I know this might be impossible, but what if you made diagnal d-pad movement, like ALTTP or Links awakening for example. So you wouldn't have to move only 4 directions. You could move 8, and the enemies could too.
~The3Dude~

aml435

With the new stage colors/bosses patched, the enemies show up glitched in Level-3.

lexluthermiester

#146
Quote from: aml435 on February 22, 2020, 12:25:52 AM
With the new stage colors/bosses patched, the enemies show up glitched in Level-3.

This might be a problem with changes I made, let me check and be sure..

Edit: This glitch is not related to the changes I made. I tested both quests L3. What do those glitched enemies behave like?

aml435

They are darknuts with glitched wizrobe graphics.

lexluthermiester


ShadowOne333

#149
Yeah I'm not sure where that Level 3 stuff is coming from, might have been a bad base rom or something.

Out of that, I will go back to this:

Quote from: Trax on December 18, 2019, 09:50:08 PM
See you next year, ShadowOne, and hopefully in good shape.

As for the secrets, whether they appear in Quest 1 or 2 or both, yes, there is a separate flag for each quest. The bits are in Screen Attributes Table 5. The byte structure is as follows:

.... .xxx   Vertical Position Out of Caves (0 = second row from top)
.... x...   Enemies appear from the sides of the screen
..xx ....   Stairs Position Code (when something is pushed)
.x.. ....   Secret in 1st Quest
x... ....   Secret in 2nd Quest


All pointers for Attributes Tables (both quests) are right at the beginning of Bank 6, starting at 0x18000. See my docs for Bank 6.

I think I have an idea about how to make the game not load the secret tiles for both quests.
By splitting the Overworld Screen attributes (found at 0x18410 in PC or $18400 in NES).

It seems that the routine found at 0x18057 checks whether Link is in the Overworld, and if Quest 1 or 2 are loaded in. Once that check is done, it loads a two byte pointer from 0x18010/$18000 for 1st Quest, or 0x1803A/$1802A for 2nd Quest.
The problem is... Both pointers point to the exact same location, which means the Overworld Screen Attributes are shared between the two Quests, and the only defining factor which tells the game what Cave to uncover is the one that Trax posted in his reply above.

The precise attribute table which I need to split in two for either Quest is located exactly at 0x18690/$18680.
However, from what I can see, it seems like there is no exact pointer to this address, the closest one is only the 0x18410/$18400 one, which from what I see, seems to take the entire data from 0x18410$18400 up to 0x186FF/$1870F (300 bytes). Anyone feel free to let me know if I'm right or not on this.

So with this data, there's one of two things that can be done here:

  • Copying the entire 300 bytes of the original Overworld Attribute Table into free space, and then make the 2nd Quest pointer point to this one, while the 1st Quest one should still point to the original one, but modified to only load 1st Quest stuff, instead of both. I would only be modifying the Screen attributes from Table 5 between the two Quests though, the rest would remain the same.
  • Do a more sophisticated hack which checks what quest is loaded in, and modify the loaded tiles only based on that. But to be honest, I have no clue as to how to do this properly, nor if it is possible.
Option 1 seems like the most feasible one for sure, and I can make it work (I think), given I have the proper free space to work with, which should be no issue.

What do you guys think?


I still haven't found a way to make the collision work again for the cracked walls, but at least with this a possible fix to the cracked walls always appearing regardless of the Quest should be fixed.

-------------------------------------------------------------

EDIT:
Forget what I said
I just tried it out, doesn't work :/
The cave entrances still appear in there, regardless of whether secret is defined on the table or not.
Even if I remove the definition for both Quests in the table, the caves STILL show up there.
So that table at $18680 only determines if the cave can be bombed on either Quest or both, but doesn't change the cracked wall tile appearing there.

Trax

I'd think the first solution would be too much overkill to be practical. The 6 tables in Bank 6 are ubiquitous, they are used everywhere in the code. Also, most of the time, the tables are referred to directly, not through pointers.

The relevant code is around $16ABF, bank 5. I'll have to revise my docs because it's been some since I worked with Zelda 1, but I have a fairly good idea on how to proceed. From the original Tile Codes in Column Definitions, Codes E5 to EA represent a secret tile (wall, tree, Armos, etc.), which should either be replaced by its "found" equivalent (staircase for tree, cave for wall, etc.) if the secret has been found already, or to the same tile visually, but with a different Tile Code, to finally be processed and mached to its Tile Mappings. The table at $16976 does that. What we need to do is to check whether we are currently in Quest 1 or 2, compare it to the relevant bits in Screen Attributes Table 5, and if it matches, select an alternate Tile Code (wall with crack, for example) from a custom table. If it doesn't match, use the regular Tile Code.

I will conjure some code and let you know if I can find a solution. Do we have unused Tile Codes for the 6 new Secret Tiles? Because if we don't, we have a problem.

ShadowOne333

Quote from: Trax on March 03, 2020, 11:02:36 PM
I'd think the first solution would be too much overkill to be practical. The 6 tables in Bank 6 are ubiquitous, they are used everywhere in the code. Also, most of the time, the tables are referred to directly, not through pointers.

The relevant code is around $16ABF, bank 5. I'll have to revise my docs because it's been some since I worked with Zelda 1, but I have a fairly good idea on how to proceed. From the original Tile Codes in Column Definitions, Codes E5 to EA represent a secret tile (wall, tree, Armos, etc.), which should either be replaced by its "found" equivalent (staircase for tree, cave for wall, etc.) if the secret has been found already, or to the same tile visually, but with a different Tile Code, to finally be processed and mached to its Tile Mappings. The table at $16976 does that. What we need to do is to check whether we are currently in Quest 1 or 2, compare it to the relevant bits in Screen Attributes Table 5, and if it matches, select an alternate Tile Code (wall with crack, for example) from a custom table. If it doesn't match, use the regular Tile Code.

I will conjure some code and let you know if I can find a solution. Do we have unused Tile Codes for the 6 new Secret Tiles? Because if we don't, we have a problem.

Oh interesting.
I was trying to fiddle around with the other Attribute tables, but was going slowly through each one.

As for your question, you mean unused tile space, as in unused tiles and their IDs?
If that so, then I have already added the tiles. I think I am currently using tiles 54 (or was it 56?) and onwards for the secret caves cracked walls.
They can be seen by patching a ROM with the Redux.ips from the GitHub page on the OP, inside the /output/ folder, then opening the PPU Viewer while on the Overworld.

lexluthermiester

If it were me, I'd just leave the cracked walls the way they are. People might grumble a bit when a cracked wall doesn't open up but the same thing happens in LTTP and that isn't a big deal. The cracked walls are cool.

Trax

Quote from: ShadowOne333As for your question, you mean unused tile space, as in unused tiles and their IDs?
If that so, then I have already added the tiles. I think I am currently using tiles 54 (or was it 56?) and onwards for the secret caves cracked walls.
They can be seen by patching a ROM with the Redux.ips from the GitHub page on the OP, inside the /output/ folder, then opening the PPU Viewer while on the Overworld.

Well, obviously, we'll need the tiles, as in 8x8 pixels tiles. But we need "tile definitions" as in 2x2 tiles TSAs. One for each secret you want to be different. I figure it would be walls, but maybe also trees that are a bit different? The table at $16976 reads like this:

16976: C8 D8 C4 BC C0 C0   Table for Secret Tiles Codes (6 bytes)

Codes E5 to EA

C8   Pushable Rock   (C8 C9 CA CB)
D8   Bombable Wall   (D8 D9 DA DB)
C4   Burnable Tree   (C4 C5 C6 C7)
BC   Pushable Tomb   (BC BD BE BF)
C0   Armos Statue   (C0 C1 C2 C3)
C0   Armos Statue   (C0 C1 C2 C3)


I guess there's 2 Armos entries because one type reveals a stairway and another reveals an item (Bracelet). We need as many Tile Codes as we have different tiles for these secrets. It really depends on how many secret tiles we want to have slight differences for a more reasonable secret hunt.

ShadowOne333

Quote from: Trax on March 04, 2020, 09:04:35 PM
Well, obviously, we'll need the tiles, as in 8x8 pixels tiles. But we need "tile definitions" as in 2x2 tiles TSAs. One for each secret you want to be different. I figure it would be walls, but maybe also trees that are a bit different? The table at $16976 reads like this:

16976: C8 D8 C4 BC C0 C0   Table for Secret Tiles Codes (6 bytes)

Codes E5 to EA

C8   Pushable Rock   (C8 C9 CA CB)
D8   Bombable Wall   (D8 D9 DA DB)
C4   Burnable Tree   (C4 C5 C6 C7)
BC   Pushable Tomb   (BC BD BE BF)
C0   Armos Statue   (C0 C1 C2 C3)
C0   Armos Statue   (C0 C1 C2 C3)


I guess there's 2 Armos entries because one type reveals a stairway and another reveals an item (Bracelet). We need as many Tile Codes as we have different tiles for these secrets. It really depends on how many secret tiles we want to have slight differences for a more reasonable secret hunt.
Ah I see.
Then yeah the one I used is 54-55-56-57 for the cracked/bombable walls.
I modified the D8 there to 54 for the new cracked wall tiles.

Although I think that's the only one that might be visible, as even with the modified Automap hack for 1/4 hearts, I already ran out of tile space in the PPU for anything outside the cracked walls, so right now I'm only focusing on that one.

One more thing, changing the tile definitions in that table to anything below 70-80 breaks their collision as well, since right now using 54-57 for the cracked wall makes them have no collision at all.

Here's what I posted some pages ago:
Quote from: ShadowOne333 on November 04, 2019, 11:31:48 AMI still haven't found the collision data for the cracked walls on the overworld.
However, I did do some tests and found some interesting stuff:

By changing the value at 0x16987 (D8):

  • Values below $70 are walk-through
  • $70-$73 (ladder tiles) makes it so that you enter the cave immediately without even needing to blow the tile up
  • $86-$89 (cascade tiles) do make the wall solid
  • $8A (and onwards) seem to be mostly solid
So it seems like the game does have what tile values do what in a hardcoded manner, since putting the ladder tiles automatically makes Link enter the cave without even bombing it.
Now the thing is trying to find exacty what routine is in charge of defining what tiles are solid, which can be walked through, and which can be entered, and modify said routine (or add an exception) for tiles $54-$57.

Trax

I tamed the beast. Here's the code:


Zelda 1
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

q1

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

q2

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

normalTile

16CAC: BD 76A9   LDA $A976,X
16CAF: 60   RTS

----

altTile

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.

ShadowOne333

#156
Quote from: Trax on March 06, 2020, 12:24:11 AM
I tamed the beast. Here's the code:


Zelda 1
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

q1

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

q2

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

normalTile

16CAC: BD 76A9   LDA $A976,X
16CAF: 60   RTS

----

altTile

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.

Oh damn!
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

------------------------------------------------------------------------------------

EDIT:
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
asl
bmi quest1 // Bit 6 - 1st Quest
bpl altTile


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 think 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

Trax

Oh, good catch. For some reason, I thought that in order to have a secret available in both quests, you had to have both bits set to 1, and I coded with that in mind. But no such screen exists. So, the bits 6-7 should be labeled "1st/2nd Quest Only" in the docs. Having both bits set to 0 simply means the secret is always there. I wonder what quest takes precedence if someone decided to set both bits to 1...

As for the tile collision, I'm still in the dark on that one. I have at least two theories, but we'll have to take a look at the routines that control Link's movements and comb the code to find out how a tile is set to "blocked", "staircase" or "walk-through". One theory is that it's done arbitrarily in the code, and check for specific tile ranges, and assign collision accordingly. My second hunch is that there's a small table somewhere in the ROM that represents the tile codes where the type changes. Like in Contra. If we assume Zelda 1 has only three types of collision, then this table could be as small as 2 bytes. For example, first byte defines the limit between walk-through and staircase, and the second byte defines the limit between staircase and blocked. Are there any other tile type?

I'll let you know if I find something. In the meantime, something that could help is to document precisely the type of each tile, especially the places where the type changes.

ShadowOne333

Quote from: Trax on March 06, 2020, 08:09:45 PM
Oh, good catch. For some reason, I thought that in order to have a secret available in both quests, you had to have both bits set to 1, and I coded with that in mind. But no such screen exists. So, the bits 6-7 should be labeled "1st/2nd Quest Only" in the docs. Having both bits set to 0 simply means the secret is always there. I wonder what quest takes precedence if someone decided to set both bits to 1...

As for the tile collision, I'm still in the dark on that one. I have at least two theories, but we'll have to take a look at the routines that control Link's movements and comb the code to find out how a tile is set to "blocked", "staircase" or "walk-through". One theory is that it's done arbitrarily in the code, and check for specific tile ranges, and assign collision accordingly. My second hunch is that there's a small table somewhere in the ROM that represents the tile codes where the type changes. Like in Contra. If we assume Zelda 1 has only three types of collision, then this table could be as small as 2 bytes. For example, first byte defines the limit between walk-through and staircase, and the second byte defines the limit between staircase and blocked. Are there any other tile type?

I'll let you know if I find something. In the meantime, something that could help is to document precisely the type of each tile, especially the places where the type changes.

I went ahead and redid my previous test with the tiles, so far this is what I found changing the tile value.
I ended up going up by 4 bytes each time, beginning in $00 all the way up to $FC.
If I go up byte by byte, then I'll get combinations of like half-solid/half-passable tiles for some, but if just one of the 4 tiles is walked-through but the other 3 solid, then it will all be counted as solid due to Link being too wide to fit in one 8x8 pixels tile, so I wanted to make it consistent by going up 4 bytes by 4 bytes on each test.

Quote from: Tiles test
$00-$6F = Walk-through tiles
$70-$73 = Ladder tiles, behaves as normal ladder, makes you enter the cave directly without bombing the entrance
$74-$87 = Walk-through tiles
$88-$DB = Solid tiles
$DC-$DF = Lower half walk-through, upper half solid
$E0-$FF = Solid tiles

If there's any other thing you need me to test, I'll gladly do so, even if I still have to go byte by byte to test the tile collisions.

Pleiades7

Quote from: ShadowOne333 on March 09, 2020, 12:17:04 PM
I went ahead and redid my previous test with the tiles, so far this is what I found changing the tile value.
I ended up going up by 4 bytes each time, beginning in $00 all the way up to $FC.
If I go up byte by byte, then I'll get combinations of like half-solid/half-passable tiles for some, but if just one of the 4 tiles is walked-through but the other 3 solid, then it will all be counted as solid due to Link being too wide to fit in one 8x8 pixels tile, so I wanted to make it consistent by going up 4 bytes by 4 bytes on each test.

If there's any other thing you need me to test, I'll gladly do so, even if I still have to go byte by byte to test the tile collisions.

Can we please get another beta release, with the optional boss hack included. Would love to try this out, and give you feedback.  :)