DOAEditor and Romhacking for Destiny of an Emperor

Use this forum to discuss hex-editing or otherwise altering any Three Kingdoms game, and to promote modded titles and patches.

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby MiDKnighT » Thu Dec 28, 2017 1:52 pm

I haven't moved cave warps around much but in Meteorstrike's original thread he mentioned that cave warps are different from other warps:

The entrance and exit locations in maps was coded in a special way. Programmatically speaking, there are what I call entrance points and warp points. Each was programmed differently. Going into a town is an entrance point and will add your last location ( the world map ) into a stack data format. Going into a house will push the town location into the stack. As you exit these homes / rooms / towns / etc. the stack pops and the game can figure out where to put you.

Warp points were used in other cases such as caves. When you enter a cave, the game does NOT push your current location into the stack. Instead, it REPLACES the last stack location with the location you are entering. Upon exit, depending on the tile you stepped on, it knows to change the location back to something appropriate. The reason this was needed for caves was because some caves have more than one exit point. Some caves lead from one entrance in the world map to another one. If the stack approach was used here, it would be impossible for the game to put you on the other side of the cave when you exited the cave through the other entrance.

When you are on the world map, you are at stack depth 0. If you enter into a town, you are at stack depth 1, and entering a house will put you at stack depth 2. Exiting these simply pops the stack accordingly, making it easy to remember where you came from, and where to return you. Entering a cave from the world map will keep you in stack depth 0 instead of pushing you into stack depth 1. You are essentially "warped" to a new location. If you step on certain tiles on the world map that are out-of-bounds, these tiles are marked as boundaries to the current map you are on. ( Much in the same way a town map has tiles around it marked as boundaries, so the game knows to "exit" you back to the world map when you step on them. )

Well, when you step on these on the world map ( stack depth 0 ) the algorithm is supposed to pop the stack and return you to the previous location you were on. The game is essentially popping the stack that has a current depth of 0. This is a bug and the result is that the memory location right before the call stack memory is used as the return point. This will usually lead to returning to the same coordinates, depending on the memory that shows up before the stack memory. Since you're not supposed to walk thru walls, this is not REALLY a bug. There is no other way to trigger this bug so it does not need fixing.


https://www.gamefaqs.com/boards/563402- ... 42?page=13
User avatar
MiDKnighT
Sage
 
Posts: 302
Joined: Mon Oct 16, 2006 4:16 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby Boneduke » Thu Dec 28, 2017 10:13 pm

Ah makes sense - I remember reading this info now, probably explains the difference in behavior I'm seeing.

Encountered a relatively game breaking bug recently, wondered if anyone had seen it before or if its a new one.

1. After a battle, sometimes one of my generals will lose an equipped item (weapon or armor).
2. The item no longer appears in the generals inventory or is displayed on the general's status screen.
3. However the AP or AC on the status screen will still reflect as if the item was equipped (and in battle, seems to still function as equipped in terms of offensive or defensive capability)
4. If a new item of any type (weapon, armor, helm), all AP and AC of the officer revert to the currently expected totals.

Behavior doesnt seem to happen consistently. I have a save state after the issue has occurred. Hopefully we can investigate it at some point, but was curious for now if it was ever encountered before in other mods. I wonder if the Spoils of War feature is related.
Boneduke
Initiate
 
Posts: 67
Joined: Sun Aug 13, 2017 5:09 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby MiDKnighT » Sat Dec 30, 2017 3:04 pm

Hmm, a save state right before it happens would be ideal. But that might be hard to get?
User avatar
MiDKnighT
Sage
 
Posts: 302
Joined: Mon Oct 16, 2006 4:16 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby Boneduke » Sat Dec 30, 2017 5:11 pm

I did some further investigating and it seems like the behavior actually happens mid-battle - I checked inventory in one round and my general still had his weapon, next round it was gone. I was saving during each round and was able to test it several times and it was happening consistently. Will PM you a savestate now. Much appreciated if you have a chance to take a look!
Boneduke
Initiate
 
Posts: 67
Joined: Sun Aug 13, 2017 5:09 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby MiDKnighT » Sat Dec 30, 2017 6:40 pm

I found a problem with the "Mend All" tactic which is overwriting one of the inventory items of Yue Jin with "0".

Traced it and see:

A:23 X:23 Y:0B S:2C P:nvUbdIzc $8D1F:A5 4D LDA $004D = #$3D
A:3D X:23 Y:0B S:2C P:nvUbdIzc $8D21:C9 30 CMP #$30
A:3D X:23 Y:0B S:2C P:nvUbdIzC $8D23:90 06 BCC $8D2B
A:3D X:23 Y:0B S:2C P:nvUbdIzC $8D25:4C 48 8D JMP $8D48
A:3D X:23 Y:0B S:2C P:nvUbdIzC $8D48:A5 4A LDA $004A = #$01
A:01 X:23 Y:0B S:2C P:nvUbdIzC $8D4A:0A ASL
A:02 X:23 Y:0B S:2C P:nvUbdIzc $8D4B:0A ASL
A:04 X:23 Y:0B S:2C P:nvUbdIzc $8D4C:0A ASL
A:08 X:23 Y:0B S:2C P:nvUbdIzc $8D4D:65 70 ADC $0070 = #$08
A:10 X:23 Y:0B S:2C P:nvUbdIzc $8D4F:AA TAX
A:10 X:10 Y:0B S:2C P:nvUbdIzc $8D50:A9 00 LDA #$00
A:00 X:10 Y:0B S:2C P:nvUbdIZc $8D52:9D 00 61 STA $6100,X @ $6110 = #$C6

So it's overwriting $6110 which is Yue Jin's Bow. I'm thinking heal tactics might be broken if the tactic id is > 30. Mend All is 3D.

0x38D32: "30" --> "60" seems to fix it but this might break something else. Checking...

EDIT: I don't see this code being used for anything else so try this change and see how things go...
User avatar
MiDKnighT
Sage
 
Posts: 302
Joined: Mon Oct 16, 2006 4:16 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby Boneduke » Sat Dec 30, 2017 10:00 pm

Nice! Thanks a lot!! Will keep an eye on it, and do some other testing with the higher numbered tactics.
Boneduke
Initiate
 
Posts: 67
Joined: Sun Aug 13, 2017 5:09 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby Boneduke » Sun Dec 31, 2017 4:30 pm

Image
Zhang Xiu is not pleased with the arrival of our armies.

Image
The last remnants of the Yellow Scarves at Runan.

Image
Yuan Shao...always has a lot to say.

Image
"Sima Yi is frightened when he hears of battle fronts, Cao Zhen is alarmed at mere rumors."

Image
Jia Xu

Image
Zhang Liao, likely in need of a stat reduction

Image
Xu Huang

Image
Guan Yu
Boneduke
Initiate
 
Posts: 67
Joined: Sun Aug 13, 2017 5:09 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby wk123 » Sun Dec 31, 2017 9:37 pm

Boneduke wrote:Image
Zhang Xiu is not pleased with the arrival of our armies.

Image
The last remnants of the Yellow Scarves at Runan.

Image
Yuan Shao...always has a lot to say.

Image
"Sima Yi is frightened when he hears of battle fronts, Cao Zhen is alarmed at mere rumors."

Image
Jia Xu

Image
Zhang Liao, likely in need of a stat reduction

Image
Xu Huang

Image
Guan Yu
What does POL represent? If it's Politics, then I think Sima Yi should be higher, Zhang Liao lower

Regardless, amazing job!!!!!!


Sent from my P027 using Tapatalk
wk123
Apprentice
 
Posts: 31
Joined: Sat May 02, 2015 7:47 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby Boneduke » Mon Jan 01, 2018 3:24 pm

What does POL represent?


Yes it is a kind of political/loyalty kind of stat. To be honest I havent paid much attention to that one or the Vitality stat. I dont think they have as important a bearing on gameplay as STR, INT, AGI. But will give them an overhaul before too long
Boneduke
Initiate
 
Posts: 67
Joined: Sun Aug 13, 2017 5:09 pm

Re: DOAEditor and Romhacking for Destiny of an Emperor

Unread postby MiDKnighT » Wed Jan 03, 2018 1:20 pm

What does POL represent?


This was from the enhanced attributes enhancement to make generals more interesting and give them more unique skills. The 3 attributes added were LDR (Leadership), POL (Political although I almost named it CHR for charisma or charm), and VIT (Vitality). The idea is that officers with high LDR are natural leaders and best suited to lead a party. I coded retreat to make use of LDR and AGI. Of course tactics can be made to use LDR as well. I always thought Bei Ji (Zeal) would be a great tactic for someone with high LDR. POL would be ideal for something like Yi Xin or Li Jian. Ie...convincing an officer to either not attack or attack his own army. I may have also added POL into the recruiting odds. VIT is used for defense. Pretty sure ludmeister and I incorporated this into officer defence. Ie... officers with high VIT can take a hit better and have more built in AC. I'll give examples of officers who should excel at each:

LDR = I'd say Cao Cao is the prime example of an officer with high LDR. He's going to be a natural leader who should be leading your party.

POL = Liu Bei for sure, very high charm and political. His royal lineage also adds to this. I'd imagine that the hereditary seal would increase POL automatically. Maybe an idea for a future enhancement.

VIT = Maybe Zhang Fei? I imagine him holding the bridge with 20 men in the novel. Super high defense.

Of course Lu Bu is the example for STR, Zhuge Liang for INT, and whoever has Red Hare for AGI.

This was from a PM but adding it here for future reference:

I tried to make use of the original "Sima Hui hut" guy, where the intro letter is required in order to talk to him. I noticed in my ROM that, no matter where in the storyline I put this warp, the game always behaves as tho you have the intro letter, on the second time you talk to the person at the door.


This was an interesting one. Through tracing I found that it all depends on the value stored in $670E. Here is the code where you get the intro letter.

0D:A6CC:A9 18 LDA #$18
0D:A6CE:20 6F E9 JSR $E96F
0D:A6D1:A5 6F LDA $006F = #$02
0D:A6D3:F0 08 BEQ $A6DD
0D:A6D5:A9 00 LDA #$00
0D:A6D7:8D 6B 67 STA $676B = #$00
0D:A6DA:4C A6 C4 JMP $C4A6
0D:A6DD:A9 03 LDA #$03
0D:A6DF:8D 0E 67 STA $670E = #$02
0D:A6E2:4C A6 C4 JMP $C4A6
0D:A6E5:20 9F C9 JSR $C99F

If $670E has the 0x10 bit, it thinks you have the letter. The problem is after he says "He is very busy..." he's flipping the 0x10 bit and essentially giving you the letter event wise. Trying to figure out why this is happening...

I compared it to the original game and it seems to be firing an event / sequence in your ROM that is not being fired in the original. Will have to trace and figure out why.

EDIT: This is a crazy bug. Walking up to talk to the lady is adding 0x40 to $05D4 and causing the extra event (giving the intro letter) to fire. It's actually the type of room that seems to be the problem. The original room doesn't allow you to take any steps. If you take steps in the room it's adding to $05D4 which is essentially giving you the intro letter. Note that the save state you gave me already has the problem. I know you can fix it if you basically put the statement back in the old room. Ie... this one...

Image
User avatar
MiDKnighT
Sage
 
Posts: 302
Joined: Mon Oct 16, 2006 4:16 pm

PreviousNext

Return to Three Kingdoms Game Editing & Mods

Who is online

Users browsing this forum: No registered users and 1 guest

Copyright © 2002–2008 Kongming’s Archives. All Rights Reserved