Points of Required Attention™
Smaghetti, a new Super Mario Advance 4 editor, is currently in development! Check out the thread HERE!

Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,275,799
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 03-19-24 10:17 AM
Guest: Register | Login

Main - Posts by njosro

Pages: 1 2

njosro
Posted on 05-15-14 06:16 PM, in Zelda 2 restart from current palace after game over (rev. 8 of 05-20-14 01:39 AM) Link | Quote | ID: 156541


Goomba
Level: 13

Posts: 1/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
This is my first post(!), my first time doing real ASM hacking, and the first time I really come to appreciate the tools FCEUX provides.

I heard about someone making it so that you start where you died if you were in a palace in zelda 2, instead of being sent allll the way back to zelda's castle. I never saw anything come of it though, so I decided to try for myself. I figured I could exploit the fact that the game has a real continue option for the great palace.

This is when I discovered how magical fceux is.

I used the code/data logger in conjunction with the trace logger to narrow my search for the relevant code. It took a few tries, but eventually I found it! The debugger was incredibly helpful in making the code understandable with the symbolic names and all that. ...sorry if I'm rambling about stuff you already know about!

So this is what I found:

Let's start with relevant RAM addresses. Naming these and finding their functions were the preliminary steps.
$0700 - lives left
$0701 - how Link enters the screen
$0706 - overworld index (0=west hyrule, 1=death mtn/maze island, 2=east hyrule)
$0707 - "world" (0=caves, enemy encounters...; 1=west hyrule towns; 2=east hyrule towns; 3=palace 1,2,5 ; 4=palace 3,4,6 ; 5=great palace)
$0736 - screen intro type
$0748 - area location index (the index of the spot on the overworld that pulled you into the sideview)
$075C - start this many 'pages' into the scene
$075F - something to do with music
$0760 - I don't know... freezing it doesn't affect anything anywhere but it's in the code so... yeah
$0561 - scene layout index (doesn't affect location)
$076C - begin a special routine. Changing this value has the most 'automation' (00=restart from zelda's castle with 3 lives, 01=no routine, 02=die, 03=wake up zelda, 04=roll credits, 06=show the lives then restart the scene)

Okay now for the the ASM code. It starts at CF30, but of course in the file it's really at 1CF40.

LDA $0706
ASL
ASL
ADC $0706
ADC $0707
RTS

;returns to CAD3:

CMP #$0F
BEQ $CADE
LDA #$00
LDY #$01
JMP $CAF0
JSR $C358 -------------> LDA #$03
LDA #$00 STA $0700
STA $0561 INC $0760
STA $0701 INC $076C
STA $075C RTS
LDA #$01
LDY #$02
STA $076C
STY $075F
RTS

So it calculates with a formula whether to send you back to the beginning or keep you in the same "world". Here's my little pseudocode describing the situation.
if (overworld_index*4+overworld_index+world = $F)
{
lives=3
???++
special_routine++
scene_index=0 //return to the palace entrance
Link_entrance_type=0 //walk in from the left
pages_into_scene=0
special_routine=1 //don't do any special routine
change_music=2
}
else
{
special_routine=0 //go back to zelda's castle. This sets a bunch of ram addresses automatically.
change_music=1
}

My first step was to make it so that you stay in the current world no matter which palace you're in. So I changed the condition for branching.

LDA $0706
RTS

;returns to CAD3

CMP #$03
BCS $CADE

(if you're in any world >= 3, you're in a palace so don't start over)
And it worked!! ... except it always sets scene_index (ram $561) to 0, so if you're in the ocean palace, for example, you'll be sent to scene 0 of that world which is the entrance to parapa palace! But the palette stays green, and your location on the overworld is fine.

At this point I thought I was in over my head, beyond my capabilities. I was really nervous about injecting my own routine instead of just manipulating what's already there!
First I had to figure out how to get a unique number identifier for each palace, since I couldn't find one already in the game. I took the area location index ($748), world ($707), and overworld index ($706) of each palace and tried to see what I could do with that. After playing around a bit, I got a unique number for each one. It could probably be better, but this one works:

overworld_index*4 + world + area_location_index = the palace id (sure why not)

4 is the smallest multiplier that prevents non-unique numbers for each palace.

Now I needed a place to store the corresponding scene indices in RAM. I found a spot with a bunch of zeros and I'm hoping that it isn't used for anything important It's around $6500. I think that's near the SRAM?
I also needed a place in ROM to put my code that would load the scene index from the correct RAM address. I found a bunch of FF's (undefined opcodes) in the debugger and stupid me thought it would be plenty of room for everything! (thinking 1 byte = room for a whole opcode and operand(s)) The FF's start at $D39A in rom. I just barely made it, in terms of available bytes. (2 bytes to spare!)

At $CADE in rom I changed the JSR location from $C358 (the subroutine in bold from above) to $D39A (the FF's). At $D39A:

JSR $C358 ;We still need to execute the subroutine that was there before
;now storing each scene_index value in appropriate RAM as (I the human) computed by the math formula using $64D0 as base address.
LDA #$00
STA $6507 ;lookup location for parapa palace
STA $650A ;lookup location for 'red' palace
LDA #$0E
STA $6508 ;lookup location for swamp palace
LDA #$0F
STA $650C ;lookup location for 'purple' palace
LDA #$23
STA $650F ;lookup location for ocean palace
LDA #$24
STA $6511 ;lookup location for hidden palace
;retrieving the correct scene_index value from RAM. The game computes the lookup address using the math formula this time.
LDA $0706
ASL
ASL
ADC $0707
ADC $0748
TAY
LDA $4060, Y
RTS

(the code then returns to that LDA #$00 statement, but I don't want A to be overwritten so I just changed it to LDY)

I don't have an assembler and I don't know how to access fceux's inline assembler if it has one, so doing this by hand in the hex editor took a little while. (Good old pen and paper planning!)
I gulped, started the game, went into the 'purple' palace and continued from a gameover. Annnnd.... (play 'item found' sound) it works!!!! For every single palace without a glitch!

And then I realized I didn't code any scene_index lookup location for the great palace
But lucky me, the spot in RAM that gets looked up for the great palace is unused (I hope) and always = 00 which is correct!

So... wow, I actually did it. Hopefully without inadvertently causing problems somewhere else. I don't really know how to make an ips patch, but if anyone's interested I could try making one I posted it below.

video!
https://www.youtube.com/watch?v=4PWFpUTDwK4

patch!
http://acmlm.kafuka.org/uploader/get.php?id=4629

EDIT: a glitch was fixed. The link now takes you to the new patch.
EDIT2: the glitch was fixed properly this time and works without causing problems elsewhere in the game (finally!)

njosro
Posted on 05-16-14 12:29 AM, in Zelda 2 restart from current palace after game over Link | Quote | ID: 156544


Goomba
Level: 13

Posts: 2/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Oh cool I didn't think it would be that simple.
Ok, I'll edit my post above to include the patch.

If anyone can think of a way to improve my code or to expand on it, let me know!

njosro
Posted on 05-17-14 07:19 AM, in Zelda 2 restart from current palace after game over Link | Quote | ID: 156554


Goomba
Level: 13

Posts: 3/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Ok so I did a whole playthrough of the game with my patch applied and everything worked completely fine until the very end... the game froze just as Thunderbird was about to die! > Also the continue feature might mess up in the great palace. Luckily I was able to find the opcodes causing the problems. I messed around with a few values because I was getting desperate and luckily got it to work. Thunderbird dies and if you die in the great palace you can continue glitch-free. That is, unless this new patch causes something else to go wrong. If anyone finds a new glitch, let me know.

Updated my first post with the new patch.

njosro
Posted on 05-20-14 01:45 AM, in Zelda 2 restart from current palace after game over Link | Quote | ID: 156570


Goomba
Level: 13

Posts: 4/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
New update. version 3 patch caused glitches with some other bosses in the game. I got the will power to look through why this was happening and it turns out that the code at $CF30 is shared! If you're in the great palace then I guess it does a different defeat explosion? But that's how it is. It was checking for the great palace with CMP #$0F but with my modified code it should actually be #$05. This seems to work properly for everything, and I'm fairly confident that it won't cause any unwanted effects elsewhere (nothing noticeable anyway)

If you downloaded one of the older patches, just repatch the rom with this new one and it should work.

njosro
Posted on 05-21-14 08:35 PM, in Zelda 2 restart from current palace after game over (rev. 2 of 05-21-14 10:24 PM) Link | Quote | ID: 156578


Goomba
Level: 13

Posts: 5/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Hey Trax thanks a lot for getting back to me!

If you download the patch you'll see it already does work as I want it to! At this point I just need to make sure I'm not interfering with something else by accident.

In case you didn't see in my first post (which I wouldnt blame you because it's a mess of paragraphs ), I do use $706 and $707 to compute where the game should make you restart.

The trick is that there is no single variable that can be used to identify which palace your're at, so I use a combination of the two. Just like in your chart, except I do *4 instead of *5. (two ASL instructions) The code is in my first post.

Since we only want the game to care about where you are if you're in a palace, I took advantage of the fact that whenever $707 ('world') >= 3, you're in a palace. The original code does region*4 + region + world. If it equals $F, (which it only does if you're in the great palace), then it hard codes in the proper values of where to begin. I modified it so that if world >= 3, JSR to my own subroutine, which computes where to start off based on lookup values I manually store in RAM.


The problem was that when the bosses die, they share the code that tests if region*4+region+world=$F so that Thunderbird can have a distinguished explosion from the other bosses. I don't remember the specifics but in my newest patch I fixed where the branching and jumping goes so it goes to the correct routines.

Download the patch! Try it out

njosro
Posted on 05-22-14 02:46 AM, in Zelda 2 restart from current palace after game over (rev. 4 of 05-22-14 04:28 AM) Link | Quote | ID: 156580


Goomba
Level: 13

Posts: 6/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Yes this is exactly the kind of feedback I was looking for. I knew the way I did it is not a very good way.

For the R*5+W routine, I thought about the problems it might cause if changed, but I did three play throughs of the entire game and noticed no change, except for the original Thunderbird glitch. But the latest patch fixes that. The problem was that for Thunderbird's explosion, it would use my new thing of just taking 'world', then exit that subroutine and compare it to $F. I changed it to compare it to $5, which is of course the great palace. So now every boss works. Even Dark Link (because he doesn't explode of course). Nothing else has been affected by this change as far as I could tell when I played through it again.

For me writing to RAM, I really didn't want to do that. It was just my on-the-spot thinking to get the job done. I was thinking about what you mentioned: moving the Palaces in the overworld, and how flexible my modification would be. Because what if, for example, ice penguin got a soft spot in his heart and decided to use the patch to make one of his future hacks easier ? There's no guarantee that the palace entrances would be the same.

I actually do know about the area data table thanks to people like you and dwedit updating data crystal, although I thought it was only in ROM. I used that data to make an overworld editor that can modify areas (because hex editing for that is soooo archaic! And I don't have a mac to use yours). I haven't released it. Anyway, I'm no expert, but are you saying that I should use $748 to lookup the correct index, then extract the corresponding map number from byte 2, and use THAT as the scene to return the player to after a gameover?

Something like this maybe:

LDY $0748
LDA $6A7E , Y
AND #%00111111
RTS
...
STA $0561

is that kind of what you're saying? I'll try it out. Thanks

EDIT: Ok maybe that's not what you meant... I tested it out. The problem is that the area tables completely change as soon as you enter a palace (or change to any other world I'm guessing), so the lookup index doesn't work for me inside a palace which is when I need it. Aw man

EDIT 2: It doesn't fix anything, but I thought you were going from left to right talking about bits 0-5. Now I know you meant to go right-to-left. Fixed the code anyway.

njosro
Posted on 05-22-14 10:41 PM, in Zelda 2 restart from current palace after game over Link | Quote | ID: 156583


Goomba
Level: 13

Posts: 7/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
The R*5+W routine seems like it is very important in theory, but honestly I've played the patched rom, going back to areas after saving and restarting, and it remembers correctly that, for example, the candle was taken or a P-bag was taken. But if you're telling me I should change it back, I'll change it back.

Using Y as an index for my own custom table is what I had in the first place, except I make the game write it to RAM, which I know is not good. I don't know how to load data from a table of values in ROM. But like you said, doing it this way makes palace entrance manipulation an extra chore. I guess it isn't too much work for the user, but ideally I think we'd like this patch to work automatically even if the palace entrances get moved.

If switching banks is what it takes to accomplish this, I'm willing to try. But I don't know how to switch banks...

njosro
Posted on 05-24-14 01:34 AM, in Zelda - The Legend of Link (v3-12-20) Released Link | Quote | ID: 156598


Goomba
Level: 13

Posts: 8/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
This is really amazing... I can't wait!

njosro
Posted on 07-31-14 03:34 PM, in Zelda - The Legend of Link (v3-12-20) Released Link | Quote | ID: 157584


Goomba
Level: 13

Posts: 9/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Finally the day has come!! So exciting!

...

Ok I started the title screen and let the intro play... MIND BLOWN! It's awesome already!! Like, whaaat? It's just so amazing already and I haven't even pressed start yet. I can tell this is going to be one of the best hacks I'll ever play.

Maybe I'm just overly excited.

...

Ok now I've played it a bit, and it's just so awesome.

Thank you Infidelity and all who helped. This was definitely worth the wait.

njosro
Posted on 03-29-15 08:03 PM, in My Zelda 2 Editors (rev. 10 of 12-05-16 05:26 AM) Link | Quote | ID: 159761


Goomba
Level: 13

Posts: 10/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
I've been working on multiple zelda 2 tools for the past few months on and off because of school and such, but I'd like to get people's opinions.

I'm working on 3 editors: dialogue/stats editor, overworld editor, and sideview editor. Tell me what you think I don't want to release them until they're 100% to my liking.

dialogue editor: (80% complete)


stats editor: (100% complete)


overworld editor: (100% complete)


sideview editor: (70% complete)

My thread at rhdn is more up to date with the progress I've made.

Download Link!
overworld editor at rhdn

njosro
Posted on 04-01-15 05:10 PM, in My Zelda 2 Editors (rev. 2 of 04-01-15 05:11 PM) Link | Quote | ID: 159773


Goomba
Level: 13

Posts: 11/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
That's good to hear! It's one of my favourites as well. I was frustrated by the very limited selection of tools available. I figure that more people would be willing to try their hand at hacking this game if it were made easier. The sideview editor by dwedit is very good at what it does, but the DOS environment isn't all that great. Trax's editor is only for mac, so I made one for windows hehe. Their documents and entries in datacrystal are what made this possible. I'm feeding off the work of the masters

njosro
Posted on 04-02-15 12:56 AM, in My Zelda 2 Editors Link | Quote | ID: 159776


Goomba
Level: 13

Posts: 12/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Haha you're welcome It only works with the american version.

njosro
Posted on 04-08-15 07:02 PM, in My Zelda 2 Editors Link | Quote | ID: 159823


Goomba
Level: 13

Posts: 13/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Hey, glad to see people taking an interest!

I'll go through your list point by point.

1. I'm not too interested in graphics editing, so I never looked into editing palettes.
2. I'm not sure what you mean by modification of tile properties
3. same as above
4. I will definitely be implementing enemy manipulation in the sideview scenes. I've looked into adding and deleting. It's possible to 'delete', but adding doesn't look promising.
5. The sideview editor is where you would edit collectible items to be found, and for example there could be 5 angel trophies to find (remember ice penguin's Shadow of Night with the 5 golden leaves?) So it wouldn't make sense to have an item-location hash map.
6. I do plan on having a magic editor along with attack and life level editor, and enemy properties editor too.
7. same as above


8. I think that a ROM expansion should be a separate thing entirely, and I don't plan on making one. I know that dwedit has made one with instructions here for anyone interested.
9. I thought each dungeon already had unique graphics. As for unique music... I wouldn't know how to do it.
10. Due to the way the overworld tiles are compressed and decompressed, it is not feasible to try and have more than sixteen different tiles. The whole compression system would have to be rewritten, and too many things rely on the current system. 1 byte specifies the number of repetitions (4 bits) and the type of tile (4 bits). With 4 bits of course the highest number is fifteen, so including zero gives sixteen tile possibilities.
11. This actually might be possible to some extent, because there are some 'slots' that currently go unused.
12. I was actually thinking about this. But it's on the back burner and I don't have the motivation atm to go ahead and make one.

njosro
Posted on 05-18-16 01:04 AM, in My Zelda 2 Editors Link | Quote | ID: 163094


Goomba
Level: 13

Posts: 14/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Hey guys I'm still at it! I love the enthusiasm about hacking Z2
And actually I should post my tools since by now they're pretty much done, except the sideview editor. Expect download links soon

The sideview editor is coming along though! Slowly but surely...

njosro
Posted on 05-22-16 05:50 AM, in My Zelda 2 Editors Link | Quote | ID: 163109


Goomba
Level: 13

Posts: 15/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
The overworld editor is available now. There's a link in the first post. Have fun with it, and please tell me if you find bugs!

njosro
Posted on 05-31-16 03:47 PM, in My Zelda 2 Editors Link | Quote | ID: 163192


Goomba
Level: 13

Posts: 16/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Update on the sideview editor! Progress is slow but steady.



njosro
Posted on 06-03-16 03:12 PM, in My Zelda 2 Editors Link | Quote | ID: 163218


Goomba
Level: 13

Posts: 17/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Thanks grimlock, actually we've been PM'ing each other for a while now. He's working on the hidden palace and hidden town of kasuto.

Don't worry Termingamer2-JD I'm aware of the other project! Thanks for the support


My map editor isn't going to be updated yet since I've moved on to the sideview editor. I've given Matal3ao some of my notes for the hidden areas, but I'll post it here too for anyone else interested.


0x01df78: the y value to place hidden palace when it appears
0x0083ed: some weird max value

(0x01df79: the y value to place new kasuto when it appears)

0x01df74: the tile type to write to the compressed byte (not visual; just behavioural component)

(RAM) $7F03: the original compressed byte to be replaced




0x8382: y value you need to be at
0x8388: x value you need to be at

$73: current y
$74: current x


(RAM) $516: badguy countdown

njosro
Posted on 06-03-16 06:16 PM, in SUPER MARIO ADVANCE 4 - Hacking & Editor Efforts Link | Quote | ID: 163220


Goomba
Level: 13

Posts: 18/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Wow that sounds really cool! I've always wondered if anything special would happen with all the e-Coins.

The sma4 hacking scene is really exciting. I think I'll tinker around myself and see if I can contribute...

njosro
Posted on 06-07-16 04:58 AM, in My Zelda 2 Editors (rev. 2 of 06-07-16 05:09 AM) Link | Quote | ID: 163259


Goomba
Level: 13

Posts: 19/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Thanks for the heads up! I've re-uploaded it. Check back tomorrow at RHDN.

Just in case, I've uploaded it here too.

Download the overworld editor!

njosro
Posted on 06-14-16 02:34 AM, in My Zelda 2 Editors Link | Quote | ID: 163315


Goomba
Level: 13

Posts: 20/27
EXP: 8412
Next: 1855

Since: 05-15-14

Last post: 2501 days
Last view: 2239 days
Update: You can edit the spawn bits now and the object properties too. Things are coming together. The next challenge is to tackle the stupid towns. They're so confusing

Also there is the issue of the automatic templates.
Some scenes in the game read from a special "template" that automatically places clouds, ceiling, or other objects in certain places. The templates are different depending on the currently loaded bank. (aka wilderness vs. towns vs. palace...) There's a chance that I'll just release it without being able to edit this because it's so annoying.

By the way, for you mac users out there, trax has just recently continued work on his sideview editor at rhdn.
Pages: 1 2


Main - Posts by njosro

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.240 seconds. (338KB of memory used)
MySQL - queries: 129, rows: 161/161, time: 0.222 seconds.