News: 11 March 2016 - Forum Rules

Author Topic: Dragon Warrior 1 - ultimate patch and project  (Read 6320 times)

joe73ffdq

  • Full Member
  • ***
  • Posts: 207
    • View Profile
Dragon Warrior 1 - ultimate patch and project
« on: December 19, 2016, 03:37:26 am »
Fairy Water
dd74/77 : A9 FE 85 DB > 4C xx xx EA

MP restore and Repel
A5 C6 18 69 xx 18 85 C6 A9 FE 85 DB 4C 68 DD

---

Dragons Scale
f10e/1b : A5 CF 29 10 F0 07 A5 CD 18 69 xx 85 CD 60

Fighters Ring, Dragon's Scale, Cursed Belt, Death Necklace
A5 CF 29 20 F0 07 A5 CC 18 69 xx 85 CC-------------------- Fighters Ring - Attack
A5 CF 29 10 F0 07 A5 CD 18 69 xx 85 CD-------------------- Dragon's Scale - Defense
A5 CF 29 40 F0 07 A5 CA 18 69 xx 85 CA-------------------- Cursed Belt - Max HP
A5 CF 29 80 F0 07 A5 CB 18 69 xx 85 CB 60----------------- Death Necklace - Max MP

---

Hurt resistance
ec46/64 :
A5 BE 29 1C C9 1C F0 04 C9 18 D0 10 A5 00 85 3C A9 xx 85 3E 20 F0 C1 A5 3C 0A 85 00 4C 20 ED >
A5 BE 29 1C C9 1C 4C xx xx A5 00 85 3C A9 xx 85 3E 20 F0 C1 A5 3C 0A 0A 0A EA 85 00 4C 20 ED ------------------- Erdricks Armor

A9 xx is your dividing #

This patch changes the multiplying # from 2 to 8. This gives more range for the dividing number.
EC5C/5F : 0A 0A 0A 0A - use EA on any of those to change the multiplier to 2, 4, or 8.

With this we have resistance options for
F0 2A C9 18 F0 1A C9 14 F0 0D C9 10 D0 1B
A5 00 85 3C A9 xx 4C 45 EC----------------------------- Half Plate
A5 00 85 3C A9 xx 4C 45 EC ---------------------------- Full Plate
A5 00 85 3C A9 xx 4C 45 EC ---------------------------- Magic Armor
4C 52 EC 4C 3F EC
 
---

Fire resistance
ed0c/23 :
A5 BE 29 1C C9 1C D0 10 A5 00 85 3C A9 xx 85 3E 20 F0 C1 A5 3C 0A 85 00 >
A5 BE 4C 54 FF A5 00 85 3C A9 xx 85 3E 20 F0 C1 A5 3C 0A 0A 0A EA 85 00 -------------------- Erdricks Armor

ED1E/21 : 0A 0A 0A 0A

29 1C C9 1C F0 27 C9 18 F0 1A C9 14 F0 0D C9 10 D0 1E
A5 00 85 3C A9 xx 4C 07 ED ---------------------------------------- Half Plate
A5 00 85 3C A9 xx 4C 07 ED ---------------------------------------- Full Plate
A5 00 85 3C A9 xx 4C 07 ED ---------------------------------------- Magic Armor
4C 01 ED 4C 14 ED

---

Stopspell resist added to Magic Armor

ec80/95 :
A5 BE 29 1C C9 1C F0 16 20 5B C5 A5 95 4A 90 0E A5 DF 09 10 85 DF
A5 BE 29 1C 4C xx xx EA 20 5B C5 A5 95 4A 90 0E A5 DF 09 10 85 DF

C9 1C F0 04 C9 18 D0 03 4C 8E EC 4C 78 EC

---

Sleep resist for both Erdricks and Magic Armor

eca6/b5 :
20 EE EB A5 DF 09 80 85 DF 20 C5 C7 06 4C DE E5
4c xx xx A5 DF 09 80 85 DF 20 C5 C7 06 4C DE E5

20 EE EB A5 BE 29 1C C9 1C F0 04 C9 18 D0 03 4C 8E EC 4C 99 EC



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


Where does all this space come from?


Remove name generator for stats

F095/97 : 4C CD F0  -  make this jump and then nop the following

F098/dc - 69
F11C/42 - 40

There is more space at

FF64/83 - 32
FF8d/9d - 17


There are 4 variables for running from enemies. Lower this to 3 with

EEB1/B2 : 90 07 > 90 1D

EEBA/CF - 22 - nop this for more space


And this one is proving tricky.

Eliminating the lower encounter rate for zone 00. This whole routine runs from CDD6/CF83. I have had close results on a few tries, but still trying to figure what can be eliminated. CED1/CEE7 is part of it, but the JMP is inconclusive. 20 to 30 free space here is likely.


---


Code space required - 188 (dec), and a few jumps as well

Not including zone 00 encounters, there is 180 free space


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


If there is a way to bank switch from C010/1000F to 8010/C00F, then there is about 240 available space at BEFB/BFE6 . If someone can help me figure this out, then I can create more new code as well. If it is possible, then I would like to add a holding amount for Fairy Water. Adding more spiked square battles besides the two, is another thought.


Once I get all this code stuff done and finalize the document for it, then I will likely start a mod. I already have the idea for mountain cave to go south of Kol, and swamp cave to go east of Cantlin. Garins Grave will go north of Cantlin. Everything else is yet to be concluded. It will be similar to DQ3's Alafgard, and with some of DQ2's difficulty.


Im back into the hacking mood, and with 90%+ of the code I am looking for, hopefully I keep with it this time  :beer:


« Last Edit: December 19, 2016, 04:04:15 am by joe73ffdq »

mrrichard999

  • Hero Member
  • *****
  • Posts: 686
  • So Goooood! :D
    • View Profile
    • GameFAQS Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #1 on: December 19, 2016, 11:13:11 am »
Can you add CHR mapping to give the sea water movement and for possible additional active sprites? That would look cool. Some people have done similiar stuff with newer metroid hacks.

tomaitheous

  • Hero Member
  • *****
  • Posts: 543
    • View Profile
    • PC Engine Dev
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #2 on: December 19, 2016, 12:35:12 pm »
Since you're dealing with code instead of data, it'd be more clear if you posted the code as mnemonics instead of hex values (or at least long with it).

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2939
  • 2 + 2 = 5
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #3 on: December 19, 2016, 04:16:05 pm »
Since you're dealing with code instead of data, it'd be more clear if you posted the code as mnemonics instead of hex values (or at least long with it).

Good idea, but don't get rid of the hex. 9 times out of 10 when someone is working with one of these games on this level they are doing so in a hex editor.
Cigarettes, ice-cream, figurines of the Virgin Mary...

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #4 on: December 19, 2016, 08:16:40 pm »
Good idea, but don't get rid of the hex.

Absolutely get rid of the hex and use a freaking assembler.  Memorizing and manually inserting opcodes is slow, tedious, and error-prone.

Quote
9 times out of 10 when someone is working with one of these games on this level they are doing so in a hex editor.

That's a problem that needs correcting!

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2939
  • 2 + 2 = 5
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #5 on: December 19, 2016, 08:31:22 pm »
Absolutely get rid of the hex and use a freaking assembler.

Cigarettes, ice-cream, figurines of the Virgin Mary...

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #6 on: December 19, 2016, 08:49:51 pm »
Because they'll overwrite each other?

I mean FFS how do you branch?  Do you manually count the number of bytes you have to skip?

And what if you want to insert 1 more instruction in your code and all your branches go to shit... how do you remember to update all of them?
« Last Edit: December 19, 2016, 08:59:04 pm by Disch »

SunGodPortal

  • Hero Member
  • *****
  • Posts: 2939
  • 2 + 2 = 5
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #7 on: December 19, 2016, 09:15:23 pm »
Because they'll overwrite each other?

I mean FFS how do you branch?  Do you manually count the number of bytes you have to skip?

And what if you want to insert 1 more instruction in your code and all your branches go to shit... how do you remember to update all of them?

You're the expert here Disch, but from a beginners perspective it would be nice to only have to learn how to do the same thing once. If I were going to be coding a ton of stuff or building a game from the ground up the assembler would be the way to go. For a lot of stuff, an assembler is just adding an extra step to the chain. Hex editor is 100% direct.

But really, IDK, maybe I've just got a hex fetish. I know at least one person feels the same about this as me (Dr. Floppy) and he does more with this stuff than most of the people in the community.
Cigarettes, ice-cream, figurines of the Virgin Mary...

mz

  • Sr. Member
  • ****
  • Posts: 447
  • Whore
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #8 on: December 19, 2016, 09:28:18 pm »
He does more because he seems to be awfully inefficient at this (if he really does type bytecode by hand and never writes ASM... He's most likely lying, though.)

In any case, don't waste your time doing things in a retarded way and learn how to use an assembler in 15 seconds. Use a hex fetish for the other 5 million things that need a hex editor.
There has to be a better life.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #9 on: December 19, 2016, 09:59:58 pm »
In all fairness:

There's a tipping point.  If you found the code you're looking for and you just need to inject some NOPs or something, then yeah a hex editor is fine and will be faster and easier.

But if you are writing more than ~20 lines of code or are doing anything that involves any level of complexity, it really saves you a big headache to use an assembler.


Assemblers let you comment code and/in include notes on what you're doing.  Having your changes in separate file(s) lets you see everything you've changed.  You can organize your changes however you like.  If you're clever with your setup, you can temporarily remove sections you've changed to test stuff.  The list of benefits goes on and on and on.


The *one* advantage to using a hex editor directly is being able to edit in real-time without reloading the file.  And that's only with certain emulators (FCEUX) -- and even then you're stuck using their hex editors.  FCEUX's hex editor is pretty mediocre.

The big downside to assemblers is getting them set up on your system in a way that makes them easy to use.  By which I mean, putting them in PATH, and putting a keybinding in <insert text editor here> to automatically launch the assembler.  But neither of those are particularly difficult, and you only have to do them once.

joe73ffdq

  • Full Member
  • ***
  • Posts: 207
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #10 on: December 20, 2016, 01:43:50 am »
Wow, this thread got a lot of responses.

Disch has tried to help many times, and sometimes I get confused with the technical language. I use a hex editor for everything, but finally started using FCEUX, so now I have a feel for looking for RAM ops. This will help for games that dont already have a ram map on data crystal.

I do tend to do things slowly. This code took 5-6 weeks to work out, and my method is very tedious. Scrolling and scrolling and scrolling through a hex editor. If there is an assembler that is recommended, then I can check it out.

You are right about branching, and trying to remember all of them if I add something. This burns a lot of time, and my concentration isnt always there, so I tend to double check numerous times. Glad I am almost done here, because I am dying to just build a damn game. DW2 didnt have enough info available, so I bogged out. FF1 is a different story, and I hope to revisit it some day. Speaking of FF1, I had a concept recently. I has last wanted to change base damage from base 1/2 to base 8/16, but couldnt figure it out. Every 32 hit% gives an additional hit. Can something be written to give magic damage an extra hit per 2, 4, 8, 16, or 32 INT, just like how hit% works. I wanted FF4 battle dynamics, but couldnt achieve it.

Adding animated water movement would be beyond my current ability. Grond did this for GFF, and it would be a nice addition.

The last thing here, is wanting to use that free space at at BEFB/BFE6 . This is in the bank just before the one I am in. I havent tried yet, but Im wondering if LDA absolute would work AD xx xx. There has to be a way to have code communicate between banks, but I dont know how it works yet. If I can use that space, then I would only eliminate the name generator stat reducer, which is just flat out annoying and unnecessary to begin with. I would add a random for MP restore on Fairy water. See if adding a quantity for it also, by running it through A5 BF # of keys held. Adding more then just the 2 spiked squares would be nice also.

I got townnedit to work finally, so I can do almost anything for a mod now when ready. I have 4 days in a row off this weekend, so Im hoping to get this code stuff done, and maybe start a mod before 2017 starts  :beer:

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #11 on: December 20, 2016, 02:16:54 pm »
I had a concept recently. I has last wanted to change base damage from base 1/2 to base 8/16, but couldnt figure it out.

Might be as simple as multiplying the base by 8 (left shifting 3 times) before running it through the RNG.  Though you might run into overflow problems.

Quote
Every 32 hit% gives an additional hit. Can something be written to give magic damage an extra hit per 2, 4, 8, 16, or 32 INT, just like how hit% works. I wanted FF4 battle dynamics, but couldnt achieve it.

Of course something like that can be written.  In general if the question is "is it possible" the answer is "yes" unless you're doing something that exceeds the system's capabilities.

Hardest part about INT changes is that there is NO code in the battle calculations that factors it in, which means you'd have to inject all new code.  Finding space for that might be challenging.

Quote
Adding animated water movement would be beyond my current ability. Grond did this for GFF, and it would be a nice addition.

It's not as hard as you might be thinking.  You just have to understand the basics of how the NES pulls pixels from 2bpp data.

Quote
The last thing here, is wanting to use that free space at at BEFB/BFE6 . This is in the bank just before the one I am in. I havent tried yet, but Im wondering if LDA absolute would work AD xx xx.  There has to be a way to have code communicate between banks, but I dont know how it works yet.

If the bank is not swapped in, you can't access it.  Period.

Assuming this is MMC1 (which FF uses, and I'm pretty sure the DW series uses it as well):

You have two "slots":

$8000-BFFF:  swappable slot... a different bank of PRG can be swapped into this slot at any time
$C000-FFFF:  fixed slot ... the last bank of PRG is always here.  It can't be swapped out*.


So if bank 3 is swapped in, and you're running some code in that bank... and you want to access data in bank 4 -- you can't.  Because swapping in bank 4 means swapping out bank 3, which means the code you want to run would no longer be visible and you'd be running code/garbage from bank 4 instead.

Doing cross-bank communication stuff pretty much has to be done from the fixed bank.  Which is usually tough, because the fixed bank is typically low on free space (for this exact reason).

Alternatively you can copy some code to RAM, jump to it, swap banks, read data, then swap back, and jump out of RAM.  But that's MUCH harder, and then you need to find free space in RAM which might be harder than finding free space in the fixed bank.



* Technically you can swap out everything on MMC1... but it involves changing swap modes... which.... if you're not comfortable getting normal bank swapping to work, I wouldn't recommend it.  However it WOULD let you access stuff 1-bank earlier.  But you'd probably still need some space in the fixed bank to make it work anyway.  If you really want to know how to do it I can explain -- but like I said I don't recommend it.

joe73ffdq

  • Full Member
  • ***
  • Posts: 207
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #12 on: December 20, 2016, 03:09:16 pm »
$8000-BFFF:  swappable slot... a different bank of PRG can be swapped into this slot at any time
$C000-FFFF:  fixed slot ... the last bank of PRG is always here.  It can't be swapped out*.

Bank swapping sounds very complicated (DW1 is MMC1). It looks like I can transfer from C000-FFFF into 8000-FFFF if it ends with RTS. Is this correct?

Can I take a whole routine from bank 03 (C000-FFFF) and transfer it to bank 02 (8000-BFFF) with a JMP?

If not, then I just need to trim the current routines, for the 30 or so more bytes of space I need.


Thank you Disch  :beer:

I did take some time to look into MMC1 and bank swapping, and it was all very hard to understand. Im in grade 3 trying to understand high school math (for a lack of better words)


Funny story here, and I wish I had taken a screen shot of it. In one of the attempts to remove some of the encounter rates, I saw one of the coolest glitches I have ever seen. I went into battle with a star wyvern, and after the battle, I was walking around the over world as a star wyvern. I thought I had seen the weirdest glitches with all my FF1 attempts, but this one was the best one.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #13 on: December 20, 2016, 04:28:50 pm »
Quote
It looks like I can transfer from C000-FFFF into 8000-FFFF if it ends with RTS. Is this correct?

RTS has nothing to do with it.  The actual code/data that exists in the bank doesn't matter.  Bankswapping is just about visibility.

Quote
Bank swapping sounds very complicated

It's actually extremely simple once you get it.  You're probably just intimidated by what appears to be black magic -- or you're just overthinking it.  ;)

Here's an analogy:

Imagine you have two identical copies of the same book.  The book to your right is stapled so that it only opens to page 15.  The book on your left, however, can be turned to any page.

Now let's say you want to look at information on different pages of that book.  Since the book on the right is always open to page 15, you can look at that page at any time.  On the other hand, you can make the left book to be open to whatever page you want at any time -- however it's impossible for it to be open to 2 pages at once.  So you can only ever "see" one page at a time in the left book.


That's really all it is.
Each book is a 'slot' ... the left book would be the $8000-BFFF slot, and the right book would be the $C000-FFFF slot.
Each page in the book is a bank.  The right book is always open to page 15, so $C000-FFFF is always showing bank $F.  The left book can be turned to any page, so any bank can be swapped into the $8000-BFFF slot.
"Bankswapping" is just turning the page.  When you turn the left book to page 3, page 3 becomes visible, but whatever page it was on before is no longer visible.


To be a bit more technical... if you have 16 banks of PRG (where each bank is $4000 bytes), that means you have $40000 bytes of PRG total.  However the NES only has 16-bit addresses ($FFFF is the max address), and only half of those (8000-FFFF) are used to address PRG.

So how do you fit 0x40000 bytes of data into only $8000 addresses?

MMC1 does it like this:

address $C000-FFFF always shows PRG data $3C000-3FFFF (bank F)
address $8000-BFFF is swappable so that it can show any one of the below:
  - $00000-03FFF (bank 0)
  - $04000-07FFF (bank 1)
  - $08000-0BFFF (bank 2)
  ... etc
... But it can never show two different banks at the same time.

You tell it which bank you want to be visible at any given time by bankswapping.  If you want to see data at offset 0x07654, you'd swap to bank 1.  It's that simple.

Quote
Can I take a whole routine from bank 03 (C000-FFFF) and transfer it to bank 02 (8000-BFFF) with a JMP?

If you're asking about whether you can be in a routine in bank 3 and JMP to a routine in bank 2 -- no you cannot, because bank 2 and 3 are never visible at the same time.

If you're asking if you can move a routine from one bank to another -- sure.  You can put anything anywhere you want.  But when you put something in a different bank, you have to make sure all the code that uses it has the proper bank swapped in when it tries to access it, otherwise it will access something else.



EDIT:  To elaborate a bit more
-------------

When you do an 'LDA $8000', you are obviously reading from address $8000.  But the byte that appears that that address depends on what bank is swapped into the $8000-BFFF slot.

If bank 0 is swapped in, you'll get the byte at prg:00000
If bank 1 is swapped in, you'll get the byte at prg:04000
etc

This is what I mean by visibility.  That specific address can refer to any one of 16 bytes.  Exactly which byte depends on the current bank.


It's the same with JMP/JSR/RTS.  If you do 'JMP $8000', that tells the NES "start executing code from address $8000".  But when the NES starts reading bytes from that address, it's going to get different bytes (different code) depending on which bank is swapped in.
« Last Edit: December 20, 2016, 04:36:32 pm by Disch »

joe73ffdq

  • Full Member
  • ***
  • Posts: 207
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #14 on: December 23, 2016, 04:43:42 pm »
Thank you very much Disch  :)

I dont understand all the language, but you always point me in the right direction. I have a text file marked "notes from Disch", and once I take the time to learn this stuff better, then I have just about all the info I need. If you live near the 5 college area of western Mass, then let me buy you a few beers sometime. Easthampton Mass to be exact, and this area is hopping with good micro brews  :beer:

Was it Spooniest that mentioned altruism here at RHDN, I cant remember off hand. I wish I could contribute more, instead of always asking for help.

Im not fully sure yet, but with the code I am looking at, it appears that the data I want to transfer will not work. C010/D010 determines a lot of all the functions of D010/10010. Moving any of it to 8010/C010 doesnt appear to work with only 240 bytes free space. There are too many JSR's to redirect. Trimming and eliminating certain code will eventually work once I get back to this.

Merry Christmas everyone  :) Enjoy time with the kids and family  :)

Dr. Floppy

  • Restricted Access
  • Hero Member
  • *
  • Posts: 970
  • Make America GREAT Again!
    • View Profile
    • BaddestHacks.net
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #15 on: January 08, 2017, 09:29:35 pm »
Quote from: joe73ffdq
Im not fully sure yet, but with the code I am looking at, it appears that the data I want to transfer will not work. C010/D010 determines a lot of all the functions of D010/10010. Moving any of it to 8010/C010 doesnt appear to work with only 240 bytes free space. There are too many JSR's to redirect. Trimming and eliminating certain code will eventually work once I get back to this.

Welcome to the 4-dimensional Gordian Knot that is the DW1 ROM. I've been chipping away at that thing on and off for the past few years in preparation for my own hack. You're probably better off leaving the fixed bank stuff in the fixed bank ($$C010-1000F), and relocating routines from the swappable banks to create new free space. Have you expanded the ROM yet?

I mean FFS how do you branch?  Do you manually count the number of bytes you have to skip?

Yes.

Quote
And what if you want to insert 1 more instruction in your code and all your branches go to shit... how do you remember to update all of them?

You just do.

Quote from: mz
He does more because he seems to be awfully inefficient at this

"Seems"...  ::)

Quote
(if he really does type bytecode by hand and never writes ASM... He's most likely lying, though.)

 :laugh:

Protip: "Bytecodes" are quicker to type.
« Last Edit: January 08, 2017, 09:41:46 pm by Dr. Floppy »

tomaitheous

  • Hero Member
  • *****
  • Posts: 543
    • View Profile
    • PC Engine Dev
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #16 on: January 09, 2017, 01:14:46 am »
Protip: "Bytecodes" are quicker to type.
For those of us that don't struggle with ADHD, the extra time it takes to type out mnemonics, and label names (!), is worth the trade off for clarity.
« Last Edit: January 09, 2017, 03:53:27 am by tomaitheous »

joe73ffdq

  • Full Member
  • ***
  • Posts: 207
    • View Profile
Re: Dragon Warrior 1 - ultimate patch and project
« Reply #17 on: January 18, 2017, 07:02:26 am »
Finally got the patch done. All the detail is in the text file. I cant thank Disch enough for direct help  :beer: Many others have helped also  :beer: Thank you  :)

I have to fine tune some things, and then officially upload it soon.


https://dl.dropboxusercontent.com/u/228695840/DW1%20magic%20and%20item%20expansion%20patch.zip