Sunday, March 24, 2013

Zelda Starring Zelda: The Python Code

Update! I've made the .py file available on my google drive. IMPORTANT NOTE! You'll need to have a copy of Legend of Zelda named "original.nes" in the same folder as the .py file. Run the .py file and it'll spit out a file called "hack.nes". Have at it, my fellow script kiddies! :)

Here's the full code to edit the opening and closing screens, the colors of Zelda's tunic, and a few other things. Simon says it was no trouble at all to create, but I don't believe that for a minute. :P

You'll need Python installed and a Legend of Zelda ROM labeled "original.nes" to run it. It'll spit out a new file called "hack.nes" but remember that it won't alter the shape of the sprites. That's all Tile Layer Pro. If you have any questions about editing, like editing the colors, please post them here and I'll be happy to help. If you have a question about Python, you can ask in the comments, or ask it at my boyfriend's blog.

NOTE: The indentations didn't survive the copy/paste. :( I'll replace them later.   (Edit: Fixed-ish. The indents aren't as dramatic here as they are in my txt editor, but I hope it's easier for people to read)

Code after the jump


Zelda Starring Zelda: Frequently Asked Questions

Why is Zelda wearing red and not green?
I like her in red and I didn't want her to look like Link in a dress. :) I have a purple and blue dress that I'd really like her to switch to during the course of the game, but alas, the code for the dress-changing power-up rings is hard to control.


Can you publish the python code that your boyfriend created?
Sure! I'll share the full text in the next post.

Did you call the patch "Legend of Link"?
No. I think the Legend of Zelda should star Zelda. But you can call it whatever you want. :P


Did you do this for your kid?
No, I think you're thinking of the Donkey Kong Dad, and the dad who search-replaced the pronouns in Wind Waker to make Link into a girl. This is just a personal project to right a wrong from my own childhood. I wanted to play as the princess that saves the day and now I can. 
  
Can you do the same thing to Link to the Past?
Yep. I think I'll do it too. It's a personal favorite of a few of my friends. It'll make a nice birthday present for them. I'll post it on my blog when I get it done.


Can you do the same thing to Ocarina of Time?
 Technically, yes. I could do a swap of Link for Zelda or Sheik (or even Ganondorf, for that matter.)  It wouldn't be a short 4-day project. It would probably be more of a 10-month project and trust me, this is not a gig that pays. lol
 The bigger issue is that I don't think I have enough control over the rest of the code to force the story to make any sense. So yeah, you could play as Shiek, but then who is in the Palace? Zelda? Is Zelda still Shiek in this game? Or how about Link? Why is Link in the palace? Is he Prince Link now? Did he marry the old Zelda? ...actually that might work. Let me get back to you.


Can you do the same thing to ---
No, but you can. Seriously. You can totally do it for yourself. It's really not that hard and there's tons of programs out there that can help you create the game that you want to play. No programming experience required.


You should do a gender-swapped Metroid!!
People keep asking for a gender-swapped Metroid as a joke, and I think it's because they actually can't think of another game that stars a girl. lol It's actually kinda depressing if you think about it.


Are you a part of a multi-national feminist cult that is plotting to ruin all fun, destroy the American way of gaming, and turn all men into women?
Yes. We meet on Tuesdays at the "New World Order Bar" in the Freemason lodge next to Bohemian Grove. Bring a dessert to share.

Wait, was that a joke?
Yes.

How can I get in touch with you?
Leave me a comment here on my blog or message me through Linkedin. I'm not a big e-mail person, so this is really the best way to get in contact with me. :)


Friday, March 15, 2013

Zelda Starring Zelda: The Story


Earlier this week, I read about that awesome dad who edited Donkey Kong to let his daughter play as the Princess. I wished I had someone who could have done that for me. Then I remembered. I'm an adult now. If he could work it out, I could too.


I'm hobbyist animator and my boyfriend is a professional video game programmer. I sent him the article and I asked, "How do I do this?"

"I think he's just using an existing rom editor, so he just went in and changed the sprites."

"I want to switch around Link and Zelda."

That got his attention. We'd been talking about a Zelda-centric game ever since the first Tropes vs Women in Games video was released. He's a huge fan of the series and really wants to see a game completely based around Zelda. The series could use a shake-up like that.

For me, I played my first Zelda game when I was pretty young, and at the time, I thought the game did star Princess Zelda. I figured I'd get to play as a magical battle princess that saved her kingdom. The game was fun, but I was bummed out that I never got to play as Zelda. But like I said, I'm an adult now. There's no one to stop me from eating candy before bed and there's nothing standing in the way of me creating the games I want to play.

We started to dig around the internet for the tools to edit the files. Let me tell you, there are dozens of tools out there to help you, no matter what game you're trying to mess around with. The nice thing about the programs is that you don't have to be a programmer to use them. (Yay!)  Some of the tools were even specific to "The Legend of Zelda", but almost all of the Zelda-specific tools were just level editors, so I didn't end up using any of those. The sprite editor was easiest to find. I talked a little about "Tile Layer Pro" already, but it's worth mentioning again, because it's really the coolest little program.

Tiles are the blocks of pixels that make up each sprite. Animation happens when the tiles are swapped for other tiles. So, to create new animation, you just have to edit the appropriate tile.

Some tips! Make sure that tile goes back in the same place where you found it, or you might end up with random legs and arms sticking out of scenery. When you open up your ROM in Tile Layer Pro, you'll see a grid with all of the ROM information displayed as pixels. It shows *all* of the rom information, so you're going to see a flaming hot mess -- at first. Keep scrolling down until you find something vaguely sprite-shaped and use the "+" and "-" keys on the keyboard to align them. But beware -- the tiles will go back to their starting alignment when you scroll and not all parts of the code use the same alignment. We spent hours hunting down the princess tiles because we didn't realize that the alignment changed from section to section.

Everything else, I learned in this fabulous (and delightfully short!) tutorial

Take care to REALLY make sure you've really hunted down every instance of the tiles you want to edit. Link's "Large-Shield walk cycle" appears in two completely different parts of the code and Zelda's "Standing" and "arms raised" animations are on two different lines.

The best part? When you're done editing your sprites, just click save! That's it. You've edited your file.



Unfortunately, that program can't edit colors so Zelda was still in a green dress. But I was happy with my Zelda and I was busily hacking away at monsters when suddenly Simon sends me a file.

It was the code for the opening and closing scrolls, as well as the code for the colors of the "Tunic", nestled in a bit of Python script that would do a search and replace on my newly edited rom. I could rewrite the scrolls and change her dress to anything I liked. Best. Boyfriend. Ever. :D

While I had been animating, Simon had done some code googling and found a Legend of Zelda ROM Map, which was the hard work of some brilliant Zelda enthusiasts. Line by line, the map explains what each piece of code does. Without that wiki or the Computer Archeology website, we would still be hunting down code and play testing until our brains had melted. Play testing is exciting at first, but as soon as you stop seeing results, it becomes the worst thing in the world.

(Side note: I did ask Simon if I could publish the code here, but he's a perfectionist and the code isn't as slick as he'd like. I have a screen shot on my other post though. Update! We published the code! Thanks Simon!)

Now I had complete control of all of the elements of the game that I needed to make this Zelda's story. I just needed to come up with new opening text. But after playing as Zelda: Warrior Princess, I honestly couldn't figure out how to put Link back into the story. In cannon, Link is the one with the sword. When you take away the sword, who is he? Just some guy that can't get out of a room? Do I make him Prince Link? Is he a knight to Zelda? (Simon's idea :)) In the end, I decided he's still Link. Even though he's seemingly powerless to leave a simple room.

When I got to the end of the game, I took a screen capture and sent it to Simon. He was strangely quiet. "My first thought" he told me later, "was 'Link, why are you standing there? Just jump over the flames.' But I guess that's the point isn't it? The gender in games thing."



My friends have all had very strong emotions to the switch of Zelda and Link -- all positive so far. A male friend of mine said he teared up when he saw Zelda holding the sword over her head. (he's a sweetie) A friend posted a link to my blog with a "Because if Miyamoto won't, we will." Another friend told me she couldn't wait for her baby daughter to be old enough to play as Zelda. Many friends told me that it made them excited and happy. Not in the cute-ironic way, but really happy.



It makes me happy too. It feels really good to play as Zelda. I feel like I connect with her character better and it makes me feel like a big damn hero. It's so nice to be swinging around a sword as Zelda. I can't describe it. You really should try it for yourself. :D

I'm sure people will think I'm trying to make some kind of anti-Link statement, but I like this franchise a lot. And if it really bothers you, just think of it as overly complicated fan fiction. :P

All said and done, the project took only about 3 days to complete, including the play-through. Not too shabby. Basic sprite editing is very simple and requires no programming skill, but if you do happen to have a programmer handy you'll be able to gain almost complete control over these old classics.

I've put together a video of some of my play testing, including video from a complete play-through with all of the cheats on (which are REALLY hard to turn off, btw) and I added some of the Orchestrated Zelda theme music because I really love that theme. Zelda defeats Gannon at 2:02

 



Yes, just a patch. Unfortunately, I can't just hand you my edited ROM. It's a copyright thing. So instead you'll need to:

1) Find your own unedited Legend of Zelda NES ROM
2) Download my patch
3) Download an NES emulator (I like Nestopia)
4) Place the patch and the ROM in the same folder
5) "Open" the PATCH in Nestopia
6) Follow the Nestopia prompts and select the unedited ROM

MAC USERS!
Nestopia is pretty bare bones for Mac, so the Mac version can't patch for you. You'll have to use a patching program instead. MultiPatch seems to work pretty well.

Important note: Some ROMs have a hard time with the patch. If you're experiencing any glitches, try a different ROM. Happy gaming! :)


Thursday, March 14, 2013

Zelda Starring Zelda Patch

Kids, we are GO!

I just finished a quick play-through on god mode to make sure that all of the sprites look right. Earlier, I had discovered that Link's head "tile" had been copied over a mountain "tile". Yikes. Everything looks good now and I was able to get some footage and screen shots. Even in god-mode, this game was HARD. It took me around 8 hours to finish. @.@
But it felt really good to play as Zelda. Not just "accomplishment" good, but "there was a rock in my shoe and it's gone now" good. I remember when I was a kid, I felt really cheated when I found out that I couldn't play as Zelda in her own game. I was a little surprised how much of that old emotion I'd held onto. But it's fixed now. :)

Here's the patch.

Yes, just a patch. Unfortunately, I can't just hand you my edited ROM. It's a copyright thing. So instead you'll need to:
1) Find your own unedited Legend of Zelda NES ROM
2) Download my patch
3) Download an NES emulator (I like Nestopia)
4) Place the patch and the ROM in the same folder
5) "Open" the PATCH in Nestopia
6) Follow the Nestopia prompts and select the unedited ROM

Nestopia will combine the two. Have fun storming the castle!

Click the image for a comparison from the original. In the original, Zelda is in the black square, not Link and it's the only time in the entire game that we see her.

Here's some more screen shots. I'll update later with my in-game footage. I'm also considering doing a few releases of the patch for different dress colors. I have several purples, a pink, a blue, and even some greens picked out. Also, if you're code-inclined, I could use some help tracking down the bit of code that regulates the in-game dress changes.





Special thanks to the people at The Legend of Zelda page of the Data Crystal wiki
and to the people behind The Legend of Zelda page at Computer Archeology. Without those resources, this project would have taken weeks, not 3 days. You guys are amazing.

Wednesday, March 13, 2013

Zelda Starring Zelda 3





Zelda Starring Zelda


She's playable. :D :D




Zelda Starring Zelda 2

Part two of the Zelda Starring Zelda project.

I was going to finish the animation and call it a day, but my boyfriend dug up the code for the opening scroll and the code for the colors, so I spent this morning making a new story and color correcting. He also wrote me a neat little Python program that searches the .nes file for the old code, then replaces it with the new code.

The Python file is on the left, the emulated file is on the right.


This isn't the grid. It's just a list of all of the possible color combinations.

The colors for this game are a bit weird, at first. Basically, the the scroll is in a big grid. The grid is separated out into blocks of 4 letters x 4 letters (for example, MANY and DARK are in the same block). The color of each block can be changed with a two-digit "hexadecimal" code. The wonderful people at "Data Crystal" (a rom-hacking wiki) have made a handy chart for working out which code to use. (so the code for MANY and DARK is 00, because both top and bottom are white.)

The 4x4 blocks are further divided into sets of 2 letters (MA   NY on top, DA   RK on bottom)




It's weird. There's such a huge rom-hacking community out there, but I think I might be the first to switch Zelda and Link.

Also, I can't tell you how much trouble it was to settle on a new opening scroll. Link was even "Prince Link" for a few hours. When Zelda and Link are reversed, Link is a really hard character to write for. Maybe that's why we haven't seen a proper Zelda game yet. Writers just assume she's boring.

Well, eff that.







Zelda Starring Zelda

This was the first stage of my Zelda Starring Zelda project. With a LOT of help (thanks Computer Archeology!) and some luck, I isolated Link's animations in the .nes file and carefully edited them down to look like Zelda. The grid is helpful, to a point. Not all of the tiles line up nicely in the grid and each set had to be individually adjusted. Simon did a brilliant search trick to track down the rogue tiles. It took us hours to work it all out. lol Also, in the original game, Zelda only has 2 sets of "tiles" so I had to completely make up her back and her profiles, but I'm happy with her design.

Just fyi, this program won't edit the color information. That's harder to get to. The "palette" that you see is just for your own sanity. BUT this program edits the actual game file, so any changes you make will show up in the actual game. So poke around. Creating Zelda only took me a few hours.

Edited with Tile Layer Pro


New Gimp Brushes

Test, test, test...