News: 11 March 2016 - Forum Rules, Mobile Version
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia

Author Topic: zelda 2 ASM hacking and improvements  (Read 9597 times)

Trax

  • Sr. Member
  • ****
  • Posts: 423
    • View Profile
    • Trax ROM Hacking
Re: zelda 2 ASM hacking and improvements
« Reply #100 on: May 06, 2018, 11:53:08 pm »
What was said about Hidden Kasuto is correct. The Y position is set to 0 initially, and when you chop the correct Forest unit, the game sets a Town unit at the correct location, draws the Town tiles, plays a sound and modifies the Key Area byte to have the correct Y location, which enables you to enter the Area by stepping on it.

Palace 6 is similar. When you play the Flute, the game checks if you are in the right location, then sets the Palace tile in place of the corresponding Desert tile. If I remember correctly, the drawing, though, is set explicitly 2 tile units down from Link's location. I think that's what makes changing the Palace location a bit harder. Unless you completely change the ASM, you are forced to have the Palace 2 tiles down from the Flute spot.

Ultima. Yes, I got your email. I'll take a look at it when I have time.

Nsjoro. Usually, a disassembler should be able to do the assembly as well, assuming it uses the same formatting rules.

njosro

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #101 on: May 07, 2018, 10:04:59 am »
@itemdrop no problem :)

@Ultimaweapon You can assemble the code you wrote with whatever tool you used, and paste it at the correct rom offset using a hex editor. I use FCEUX's hex editor. Also, if you want to make just a small code change, the easiest thing to do is use the debugger tool in FCEUX. You first freeze the game, then seek to the address, then click the left margin beside the instruction, and then you can just type the asm line by line. It will assemble your code and modify the rom right away.

ultimaweapon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #102 on: May 09, 2018, 08:02:52 am »
@njosro - This link here is what I'm trying to accomplish. https://github.com/cfrantz/z2doc/wiki/bigger-overworlds
So I downloaded a disassembly program, changed the code that I needed, and of course I can't assemble the game back. So I'm trying your method aith the hex editor and debugger from FCEUX, and I can't figure out how to modify the code. I'm not getting any options to do that, so it looks like I'm stuck at the moment. I wish there was a way I could just copy and paste all the work I did.  :banghead:
Trust in the Heart of the Cards

njosro

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #103 on: May 09, 2018, 08:44:15 am »
Oh! I've seen those github pages before. A very intelligent programmer, CFrantz, did a bunch of advanced zelda 2 tinkering and posted his stuff there.

To convert your asm into byte code just use this online tool. No download required:
http://www.e-tradition.net/bytes/6502/assembler.html

Copy the object code that it generates.

For example,

LDA #$05
STA $768

becomes:

A9 05 8D 68 07

And paste it at the right location in the hex editor.

Don't use the FCEUX's debugger tool for large modifications. I was talking about small changes for that, like maybe 3 instructions here and there.

ultimaweapon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #104 on: May 09, 2018, 11:04:47 am »
Oh! I've seen those github pages before. A very intelligent programmer, CFrantz, did a bunch of advanced zelda 2 tinkering and posted his stuff there.

To convert your asm into byte code just use this online tool. No download required:
http://www.e-tradition.net/bytes/6502/assembler.html

Copy the object code that it generates.

For example,

LDA #$05
STA $768

becomes:

A9 05 8D 68 07

And paste it at the right location in the hex editor.

Don't use the FCEUX's debugger tool for large modifications. I was talking about small changes for that, like maybe 3 instructions here and there.

Thank you for that heads up. I was probably making changes I don't need to and others I needed. I will definitely try this tonight. BTW, what I'm attempting to do is increase the size of the overworld. Have you thought about updating your overworld editor to do this automatically? I think it's cool to have a bigger overworld and not have to change any code to handle this.

Also have you done any updates to your sideview editor? I know you said because of requests you would consider including a "delete all terrain" "add enemy" "delete enemy" and "delete all enemy"? I still think those would be great additions to your editor njosro.
Trust in the Heart of the Cards

Trax

  • Sr. Member
  • ****
  • Posts: 423
    • View Profile
    • Trax ROM Hacking
Re: zelda 2 ASM hacking and improvements
« Reply #105 on: May 09, 2018, 10:44:32 pm »
Be careful about the Overworld changes, because of the Item Presence data. Unless you want an overly complex sharing of Item Presence bits between multiple Overworld regions, you have to consider this bottleneck. All Item Presence bits are stored in RAM, in the 6xx range.

ultimaweapon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #106 on: May 10, 2018, 07:06:28 am »
I followed every detail and still can't get it to work, so I will just abandon it for now. 'll go back to my other plans for my next Zelda 2 hacks.
Trust in the Heart of the Cards

Trax

  • Sr. Member
  • ****
  • Posts: 423
    • View Profile
    • Trax ROM Hacking
Re: zelda 2 ASM hacking and improvements
« Reply #107 on: May 14, 2018, 10:37:16 pm »
It's quite a demanding task to have a larger Overworld, as it involves so much new data and many variables that have to work flawlessly. I will let you know when I find a safe way to do it.

ultimaweapon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #108 on: May 15, 2018, 01:31:27 pm »
May the Triforce be with you Trax!  :laugh:

I'm going back and work on my next 2 Zelda II hacks (yes I said 2). 1 of my ideas of course I have to wait on you Trax... no worries. I'd gladly wait.

My other idea on the other hand, I'm working on. I'm still trying to figure out this midair jump.
Trust in the Heart of the Cards

ultimaweapon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #109 on: May 23, 2018, 07:44:14 am »
@Trax & Njosro - Is it possible to make one of the other palaces such as the Great Palace hidden to where it would require the flute to reveal just like palace 6?
Trust in the Heart of the Cards

Trax

  • Sr. Member
  • ****
  • Posts: 423
    • View Profile
    • Trax ROM Hacking
Re: zelda 2 ASM hacking and improvements
« Reply #110 on: May 29, 2018, 02:18:02 am »
With new ASM, you could have as many hidden things as you want. The hard part is that the original programming is hard-coded to have the 6th palace's Area appear specifically 2 tiles under Link's current position. The simplest way would be to recycle the 6th palace Area to make it point to the Great Palace. Very straightforward.

ultimaweapon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #111 on: May 29, 2018, 06:12:42 pm »
With new ASM, you could have as many hidden things as you want. The hard part is that the original programming is hard-coded to have the 6th palace's Area appear specifically 2 tiles under Link's current position. The simplest way would be to recycle the 6th palace Area to make it point to the Great Palace. Very straightforward.

I relocated palace 6 and the Great Palace to where palace 6 was and hidden it. When I test it, a palace tile appears, but I cannot enter. It grants no entry into the Great Palace. How do I get the area to point to The Great Palace? I'm going through the disassembly, and I see at bank 0 at 04E9, bank 1 at 4368 and bank 2 at 8368 are all indications about the Hidden Palace, but I'm a bit confused. 
Trust in the Heart of the Cards

Trax

  • Sr. Member
  • ****
  • Posts: 423
    • View Profile
    • Trax ROM Hacking
Re: zelda 2 ASM hacking and improvements
« Reply #112 on: May 30, 2018, 08:15:49 pm »
You don't have to change the code. Just find the Key Area attributes of the 6th palace, and replace the Region and World bitfields with the same values as the Great Palace. You should have to change the Map Number as well. The original 6th palace Key Area index is 35 (hex). Here's the structure of the Key Area bitfields:

Code: [Select]
Byte 0

.xxx xxxx - Y position
x... .... - External to this world (immediately return to Overworld upon entrance)

Byte 1 (offset 3F bytes from Byte 0)

..xx xxxx - X position
xx.. .... - On exit, appear at the location of area index minus this value (0-3)

Rauru, Ruto, North Saria and Mido have bit 6 set
If Area Index minus Exit Offset = 0, music stops when entering area
If Area Index minus Exit Offset < 0, Link ends up in the lower-left corner of the OW

Byte 2 (offset 7E bytes from Byte 0)

..xx xxxx - Map number
xx.. .... - Horizontal position to enter within map
    0 = enter from the left
    1 = enter at x=256 or from the right for 2 screens maps
    2 = enter at x=512 or from the right for 3 screens maps
    3 = enter from the right for 4 screens maps

Byte 3 (offset BD bytes from Byte 0)

.... ..xx - Region number
...x xx.. - World number
..x. .... - Forced enter from the right edge of screen
.x.. .... - Pass through
x... .... - Fall in hole

njosro

  • Jr. Member
  • **
  • Posts: 56
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #113 on: June 01, 2018, 04:57:47 pm »
Hi ultimaweapon, maybe I can help since this seems doable through the editor :)

Quote
I relocated palace 6 and the Great Palace to where palace 6 was and hidden it.

This is what I understood from that:
1. You moved the area warp of palace 6
2. You moved the area warp of the great palace to where palace 6 used to be
3. You set the Y coordinate of the great palace's area warp to 0

If that's what you did, then here's what's wrong:
As trax said, the game just "draws" a palace tile when you play the flue and it moves the area warp of palace 6, NOT the great palace. So you probably saw the drawn image of a palace but it's just that: an image tile.

Here's what I suggest:
1. Undo everything you did with the moves and such.
2. In the editor, in area editing mode, click any area to select it, then right-click it. (Yeah, it's a bug that you gotta left click first)
3. From the drop down menu, click "Seek Index..."
4. Type 53 (that's the index of palace 6's area warp), then click OK. (in hex it's 35 like trax said, but 53 in decimal)
5. You'll see the view go all the way up north since palace 6 has a Y value of 0. You can't click it since it's out of bounds, but you can change its properties.
   Change the scene and world to the appropriate values that you want. (Probably scene 0 in Great Palace)
6. SAVE!

It will work. (I've done this before.) BUT you will need to fix the graphics of the great palace when you enter. Maybe trax can help you with that...?

I hope this information is what you're looking for!

ultimaweapon

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #114 on: June 02, 2018, 04:27:57 pm »
Hi ultimaweapon, maybe I can help since this seems doable through the editor :)

This is what I understood from that:
1. You moved the area warp of palace 6
2. You moved the area warp of the great palace to where palace 6 used to be
3. You set the Y coordinate of the great palace's area warp to 0

If that's what you did, then here's what's wrong:
As trax said, the game just "draws" a palace tile when you play the flue and it moves the area warp of palace 6, NOT the great palace. So you probably saw the drawn image of a palace but it's just that: an image tile.

Here's what I suggest:
1. Undo everything you did with the moves and such.
2. In the editor, in area editing mode, click any area to select it, then right-click it. (Yeah, it's a bug that you gotta left click first)
3. From the drop down menu, click "Seek Index..."
4. Type 53 (that's the index of palace 6's area warp), then click OK. (in hex it's 35 like trax said, but 53 in decimal)
5. You'll see the view go all the way up north since palace 6 has a Y value of 0. You can't click it since it's out of bounds, but you can change its properties.
   Change the scene and world to the appropriate values that you want. (Probably scene 0 in Great Palace)
6. SAVE!

It will work. (I've done this before.) BUT you will need to fix the graphics of the great palace when you enter. Maybe trax can help you with that...?

I hope this information is what you're looking for!

You were spot on Njosro. I tried what you said, and that did work. Like you said, the graphics were totally distorted. I even tried swapping the CHR bank and palette offset, but that didn't work. I'll probably just switch it back to normal.

Here's what I would like to do. Keep Palace 6 hidden where it belongs, but I would also like to hide Palace & (Great Palace) so that it would appear 2 spaces above Link. I figured I needed ASM, but what I can't figure out is how Palace 6 is hidden with ASM, so I can try to replicate the process for Palace 7. Any info that can help is greatly appreciated.
« Last Edit: June 02, 2018, 04:45:49 pm by ultimaweapon »
Trust in the Heart of the Cards

itemdrop

  • Jr. Member
  • **
  • Posts: 37
    • View Profile
Re: zelda 2 ASM hacking and improvements
« Reply #115 on: June 12, 2018, 10:17:39 pm »
is it possible to have different music for different palaces ?
 instead of the same track for all but Great Palace