Home › Forums › Destiny of an Emperor › Making DoaE1 Portraits Using Feidian.
- This topic has 75 replies, 8 voices, and was last updated 12 years, 5 months ago by MiDKnighT.
-
AuthorPosts
-
October 12, 2011 at 2:00 am #38109MiDKnighTModerator
OK I thought I had uploaded bmp's. Too bad you couldn't get Feidian to work. A couple other people had that problem and I have no clue why it didn't work for them. Your other option is Tile Layer Pro but that's a bit more tedious.
October 12, 2011 at 4:17 am #38110MiDKnighTModeratorVICTORY!
I now have a 512k (double size) Destiny of an Emperor ROM that can support um let's see…
255*16=4080 slices
Or in other words…
680 unique portraits lol… I really don't think anybody will need that many but we may be able to use that space in the future for other things like text, maps, sprites, etc…
I'll share the details with Niahak when he gets back from vacation. It should actually be pretty simple to incorporate this into Destiny of an Editor. All it would need is:
1. To support saving a 512k ROM.
and
2. One drop down box on the generals page that has the bit to load the new pages. This is the bit after the officer's background color which was previously found to be unused.
Wow…that was a tough one. I had to actually write 18 lines of assembly to do this. My God that is a terrible frigging language to work with. What a friggin nightmare!
Anyway, I've tested it and it works great! I have Liu Bei using his original portrait, Xu Zhu with his portrait coming from the original bank 1 and bank 2, and Guan Yu using the brand new bank and it's all finally working together.
NO MORE GENERIC PORTRAITS! Time to celebrate?
October 12, 2011 at 4:28 am #38111Lord Yuan ShuKeymasterDoaE hacking at it's finest. Never ceases to amaze me around here. huohu :hook:
Welcome to Lord Yuan Shu Walkthrough Guides ·
Huo Hu's Adventure started Destiny of an Emperor hackingOctober 12, 2011 at 5:38 am #38112Zhuge LiangParticipantAmazing discovery MiDKnight. You undoubtedly were born to do this :huohu:
DoaE gave birth to Huo Hu.
October 12, 2011 at 7:02 am #38113MiDKnighTModeratorHere are the gory details. I figure I'd better post it before I lose it.
NOTE: I do not recommend that anybody does this yet… Because if you do then you will no longer be able to use "Destiny of an Editor" as it will chop your ROM back down to 256k when you save (until it supports a 512k ROM).
TO EXPAND YOUR ROM:
1. Back up the ROM.
2. Open your hex editor and expand the ROM to 80010 bytes. (ie…add 0's to the end until the last byte is 80010).
3. Copy all the data that currently exists at $3C010-$40010… and paste it to $7C010-$80010 (this is the "master" code of the game, for lack of a better term. It must stay at the end of the ROM).
4. Change offset $00004 from $10 to $20 (to show that you've doubled the size).
Now you have a 512k ROM. This allows us to add more portraits and other stuff!
Now…a little about how the portrait system works. A portrait is made up of 6 horizontal slices. Each slice is indexed from 00 to FF and they are stored in 2 banks in the ROM at 0x8810 and 0xC810. The reason we could never have more than 255 slices before was because of this two character index system. In order to have MORE portraits we need a 2nd pointer, a place to put our new slices, and new code in the game to allow it to use our new banks.
USING NEW PORTRAIT BANKS:
1. The 2nd pointer. Each general has a little "profile" if you will in the ROM. I'm going to borrow an old post from Niahak to show this:
Quote:Officer structure notes (from various sources, as well as DoaEd code)STR
INT
Region
Sprite
Sprite color (AP as enemy)
DP as enemy
Soldiers (Enemy)
Soldiers (Ally)
Tactics
AGI
portrait 1
portrait 2
portrait 3
portrait 4
portrait 5
portrait 6
portrait BG (single-color BG only)
unknown <
unknown
Name spacing
Officer name
See the 2 "unknown" slots? We have never found any use for these 2 slots and it is likely that these were used for Japanese characters. I am using the 1st "unknown" slot for the 2nd portrait slice pointer.
With that said I will be using the following values for that byte:
00 = Use the original DOAE portrait banks.
F1 = This officer's portrait lives in new ROM page 16 or 17 (hex: 10 or 11)
F3 = This officer's portrait lives in new ROM page 18 or 19 (hex: 12 or 13)
F5 = This officer's portrait lives in new ROM page 20 or 21 (hex: 14 or 15)
F7 = This officer's portrait lives in new ROM page 22 or 23 (hex: 16 or 17)
F9 = This officer's portrait lives in new ROM page 24 or 25 (hex: 18 or 19)
FB = This officer's portrait lives in new ROM page 26 or 27 (hex: 1A or 1B)
FD = This officer's portrait lives in new ROM page 28 or 29 (hex: 1C or 1D)
2. The assembly part (nasty). OK for the short version, just open your hex editor and paste this into 0x3CFE4 and 0x7CFE4: "4C3083000000". You'd be pasting this over "10044980E6F1".
Then copy this into 0x30340: "85158425A011B1F31004E9E085F1A51510064980E6F18515A4254CDACF"
That's all the magic right there.
The first copy is changing the code that adjusts the ROM lookup for any slice at index 80 or greater to just jump to $8330 where I put my new code. Here's what the new code is doing and *this* is what took the most time to do:
00:8330:85 15 STA $0015 = #$DA
00:8332:84 25 STY $0025 = #$00
00:8334:A0 11 LDY #$11
00:8336:B1 F3 LDA ($F3),Y @ $AE29 = #$F1
00:8338:10 04 BPL $833E
00:833A:E9 E0 SBC #$E0
00:833C:85 F1 STA $00F1 = #$02
00:833E:A5 15 LDA $0015 = #$DA
00:8340:10 06 BPL $8348
00:8342:49 80 EOR #$80
00:8344:E6 F1 INC $00F1 = #$02
00:8346:85 15 STA $0015 = #$DA
00:8348:A4 25 LDY $0025 = #$00
00:834A:4C DA CF JMP $CFDA
Essentially it has to figure out where to look in the ROM for the slice based on what the index number is and if that new bit is set.
3. Loading your portraits! Of course my preferred method is feidian. The two existing banks you'd load at 0x8810 and 0xC810. Note that any slice at hex:80 or above will go to page 2.
The new banks you can load into will be at:
0x40810 (F1)
0x44810 (F1 – 2nd page)
0x48810 (F3)
0x4C810 (F3 – 2nd page)
0x50810 (F5)
0x54810 (F5 – 2nd page)
0x58810 (F7)
0x5C810 (F7 – 2nd page)
0x60810 (F9)
0x64810 (F9 – 2nd page)
0x68810 (FB)
0x6C810 (FB – 2nd page)
0x70810 (FD)
0x74810 (FD – 2nd page)
And with these new banks you can load 128 rows for each page (the first page has slices 00-7F, the 2nd page has slices 80-FF). Example commands which would load up banks F1 and F3:
php feidian.php -ci nes8,6,128,0×040810 F1_1.bmp doae.nes
php feidian.php -ci nes8,6,128,0×044810 F1_2.bmp doae.nes
php feidian.php -ci nes8,6,128,0×048810 F3_1.bmp doae.nes
php feidian.php -ci nes8,6,128,0x04C810 F3_2.bmp doae.nes
If you were to go nuts with it you could load 340 unique portraits in a couple minutes if your bitmaps were ready.
4. Assigning a portrait to a general. Just like in "Destiny of an Editor" you assign your six slices, however, if you're going to use a new portrait bank you have to set that bit to F# to tell it which portrait bank to use. For example, slice 00 of F1 will be at 0x040810, slice 80 of F1 will be at 0x044810.
October 12, 2011 at 12:32 pm #38114sonic.penguinModeratorVery awesome! Maybe more music can be added to the game too? Now if only an easier method of importing portraits into the game were made, it would make your discovery even better! (shameless plug)
October 12, 2011 at 12:34 pm #38115MiDKnighTModeratorQuote:Very awesome! Maybe more music can be added to the game too?Now I'm starting to feel like Niahak with a big to do list lol…
I did think about the music stuff. Replacing music would probably be pretty straight forward. Adding new music using the new banks? Ya that would require a ton of debugging and more assembly code…yuck…
EDIT: Maybe my next project should be working on understanding Niahak's Destiny of an Editor code. I think the tool needs to catch up with all the latest discoveries. The problem is, there's only 1 Niahak.
October 12, 2011 at 12:45 pm #38116sonic.penguinModeratorHere is what the portrait will look "similiar to" in game, just a little smaller
also… here's to reviving dead threads that were years old! Now get to work!
http://i390.photobucket.com/albums/oo350/zero_Cool_02/bossage.jpg
October 12, 2011 at 12:46 pm #38117sonic.penguinModeratorHere is what the portrait will look "similiar to" in game, just a little smaller
also… here's to reviving dead threads that were years old! Now get to work!
http://i390.photobucket.com/albums/oo350/zero_Cool_02/bossage.jpg
October 12, 2011 at 12:49 pm #38118sonic.penguinModeratorHere is what the portrait will look "similiar to" in game, just a little smaller
also… here's to reviving dead threads that were years old! Now get to work!
http://i390.photobucket.com/albums/oo350/zero_Cool_02/bossage.jpg
October 13, 2011 at 1:28 am #38119NiahakModeratorThis is pretty cool stuff! Being able to deal with an expanded ROM is actually easy to do (… in fact, expanding it in the program sounds easy enough from your description).
With this, should I bump dynamic portrait loading up a bit in priority? I wouldn't be able to do it until I get back, most likely… but I don't think it'd actually be that hard to do. Just have to buckle down and do it :)
October 13, 2011 at 1:45 am #38120MiDKnighTModeratorQuote:With this, should I bump dynamic portrait loading up a bit in priority? I wouldn't be able to do it until I get back, most likely… but I don't think it'd actually be that hard to do. Just have to buckle down and do itBy portrait loading do you mean loading it from the ROM? Ya that'd be cool after adding the new bit to the general editing page and having it load from the new banks too. If you think it's "low hanging fruit" then by all means. Battles page would probably be easy too. Seems like the warp stuff might be harder (displaying it on a map, editing it, etc…).
I was thinking that maybe I should take another look at the "Destiny of an Editor" code stuff some more. I figure if I could make sense of assembly enough to do the new portrait banks I should be able to make sense of your code with enough time and motivation. Just let me know if you'd like me to pursue that. If so, perhaps we can have a phone call where you can walk me through the code or something.
October 13, 2011 at 12:54 pm #38121MiDKnighTModeratorHey guys, I ran into one snafu. Apparently I miscalculated and you cannot put all slices (00-FF) on one ROM page. I'll have to split it into 2 pages per bank. That means we'll only be able to support up to 340 portraits with a 512k ROM. I know…so sad… :(
It should be pretty easy to fix, just have to tweak my assembly code and change the instructions a little bit. I can get it done today.
October 13, 2011 at 1:24 pm #38122DragonAtmaModeratorBut… but RoTK2 has 352 officers! How can anyone take us seriously if we import all 352 yet use the same portrait for Cai He and Cai Zhong!? :Þ
October 13, 2011 at 2:48 pm #38123MiDKnighTModeratorOK I fixed it and updated the instructions accordingly.
-
AuthorPosts
- You must be logged in to reply to this topic.