Home › Forums › Destiny of an Emperor › Destiny of an Editor (permanent beta test mode active)
Tagged: Destiny of an Editor, Destiny of an Emperor, Huo Hu, Niahak, ROM Hacking, Xian Zhu Xuande, Zhuge Liang
- This topic has 1,129 replies, 26 voices, and was last updated 10 years, 12 months ago by
MiDKnighT.
-
AuthorPosts
-
February 2, 2014 at 10:29 am #53406
MiDKnighT
ModeratorJust added Colors2.tbl.
February 2, 2014 at 11:10 am #53408Niahak
ModeratorThanks!
I have the editor loading in the small tiles (the 8×8 ones). Do you know where the information of what each tile type is, is stored?
In the “Build the map tiles” section, you have an example of loading a tile, but I don’t see any information about where tile 2_192 is actually defined in the ROM.
If I can understand that format, I think I can load the world map graphics 100% dynamically and then loading cave / town / etc graphics should be comparably a piece of cake.
February 2, 2014 at 11:51 am #53410MiDKnighT
ModeratorI have the editor loading in the small tiles (the 8×8 ones). Do you know where the information of what each tile type is, is stored?
The actual small tiles are stored in the PPU graphics from step 6 “Load the Graphics Into PPU Memory” –> http://doaerhguide.wikidot.com/#toc15
World map graphics: 0x10010-0x1080f
Inside an Inn/House: 0x10810-0x1100f
Cave graphics: 0x11010-0x1180f
Inside castle graphics: 0x11810-0x1200f
Fortress graphics: 0x12010-0x1280f
Town graphics: 0x12810-0x1300f
Burnt Luo Yang: 0x13010-0x1380fWhen it loads the actual tile ID, it’s giving the location in PPU memory starting with tile $80. That means for the world map, tile $80 is at 0x10010 and so on.
The tile “type” comes from the table at (0x3bf95-0x3bfd5) from step 2 using the location ID.
In the “Build the map tiles” section, you have an example of loading a tile, but I don’t see any information about where tile 2_192 is actually defined in the ROM.
The “2” comes from that control code that you talked about here:
As for how to load the large tiles, that is discussed in the “Find the Map Region” section –> http://doaerhguide.wikidot.com/#toc15
I think that’s what you’re asking here…
February 2, 2014 at 12:02 pm #53411MiDKnighT
ModeratorAll that said, it probably takes reading through this a few times to put it all together: http://doaerhguide.wikidot.com/#toc15
The map loading in the game is pretty complicated.
February 2, 2014 at 12:31 pm #53413Niahak
ModeratorI understand where the graphics are, and I have them loading in…
The issue is how to stitch the 8×8 tiles together to make 2_192, for example. Where does the game store what 8×8 tiles make up 2_192?
For example, this image:

Where is the knowledge that the tile 02_192 is made up of
B0 A1 A2 A3
B0 B1 B2 B3
C0 C1 C2 C3
D0 D1 D2 D3?/edit: Ah, I think I see where it happens now. The order of entries was throwing me off.
-
This reply was modified 12 years, 2 months ago by
Niahak.
February 2, 2014 at 12:42 pm #53416MiDKnighT
ModeratorThe small tile IDs are physically located on page 09. So let’s take the first set for example:
A:10 X:10 Y:0E S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $880E = #$C0
A:11 X:11 Y:0E S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $890E = #$C1
A:34 X:34 Y:0E S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8A0E = #$D0
A:35 X:35 Y:0E S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8B0E = #$D1These are locations are coming from:
$880E = 0x2481E
$890E = 0x2491E
$8A0E = 0x24A1E
$8B0E = 0x24B1EOf course getting to the point of finding these locations is pretty complicated and I’ve documented it as best I can. It starts with…Tile ID 192 is “C0” in hex. To get the tile makeup, take C0 (the tile #) and multiply it by 4 which gives us 0x300, etc… in the “Build the Map Tiles” section.
February 2, 2014 at 12:55 pm #53419MiDKnighT
ModeratorNiahak, I also just e-mailed your gmail account with my phone number so you can call or text me if you get stuck.
February 2, 2014 at 2:43 pm #53424Niahak
ModeratorI think the biggest barrier for me is that I don’t understand assembly language.
I understand the transformation from 0xc0 to 0x00 and 0x07.
I think I understand the lookup table (it starts at 0x3d9c6, so the world map category is 0x80, inn/house is 0x8D, etc).
What confuses me is the Y, X and Y1,X1 values and how $1C and $1E are derived from them.
Where do Y1 and X1 come from?
Can you describe (mathematically) how $1C and $1E are set and how Y is set from them?What is happening in the final step (where the lookup value goes from 0x8700 to 0x8800)? I tried looking up the assembly command descriptions, but none of them seem to use Y. X is being used, but what matters seems to be what’s in $F6BA.
Thanks!February 2, 2014 at 3:10 pm #53425MiDKnighT
ModeratorI think I understand the lookup table (it starts at 0x3d9c6, so the world map category is 0×80, inn/house is 0x8D, etc).
What confuses me is the Y, X and Y1,X1 values and how $1C and $1E are derived from them.
That’s the right location for a normal ROM but in an expanded ROM it would be 0x7d9c6 and 0xfd9c6.
What confuses me is the Y, X and Y1,X1 values and how $1C and $1E are derived from them.
Where do Y1 and X1 come from?
X1 and Y1 come from the coordinates in the “region”. Ie…the coordinates for X1 can be 00 up to 0F and Y1 can be anywhere from 00 to 0F. So the values are the coordinates of the tile we are working on within the region:
Everytime it loads small tile “C0” I see $1C is 0B and $1E is 06.
Can you describe (mathematically) how $1C and $1E are set and how Y is set from them?
What is happening in the final step (where the lookup value goes from 0×8700 to 0×8800)? I tried looking up the assembly command descriptions, but none of them seem to use Y. X is being used, but what matters seems to be what’s in $F6BA.
I think we should be good to use Y1 for $1C and X1 for $1E. How is Y set from them? It right shifts each one and the original bit 0 is shifted into the Carry.
Y starts as 0, then:
If X1 LSR (right shift) forces a binary “1” into carry, then increase Y by 2
If Y1 LSR (right shift) forces a binary “1” into carry, then increase Y by 1.So any number that has a “1” in the right most binary value will set the carry flag:
0000 = 0
0001 = 1
0010 = 2
0011 = 3
0100 = 4
0101 = 5
0110 = 6
0111 = 7
1000 = 8
1001 = 9
1010 = 10
1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15So for example if X1 is 6 then it will not cause Y to increase. If X1 is 7 then Y will increase by 2. Same with Y1. If the carry flag is set for X1 it will increase Y by 2, if it’s set for Y1 then Y will increase by 1.
As for the table at $F6BA, I think it follows the same rules for the X value as before:
0 = World Map
1 = Inn/House, Caves, & Inside Castles
2 = Fortress, Town, & Burnt Luo YangThis table lives at:
Normal Rom:
0x3f6ca: 88 95 A2
Expanded ROM:
0x7f6ca: 88 95 A2
0xff6ca: 88 95 A2Any questions on the above?
-
This reply was modified 12 years, 2 months ago by
MiDKnighT.
February 2, 2014 at 4:55 pm #53429MiDKnighT
ModeratorUpdated my post above with some corrections. My apologies for the confusion. The main point being that $1C = Y1 coordinate inside the region we are working on. $1E = X1 coordinate inside the region we are working on. I also updated the guide: http://doaerhguide.wikidot.com/start#toc15
February 2, 2014 at 5:40 pm #53430Niahak
ModeratorWhew! I figured it out after a while. Thanks for bearing with me.
I figured out that the X1, Y1 stuff wouldn’t be relevant except *within* a tile. Once I got past that, I got most of it.
So, the next question: I’ve successfully loaded bank 2 by mistake. How is the processing different for bank 1 (e.g. if the control code is different)? I didn’t see that detail included in the explanation.
February 2, 2014 at 6:00 pm #53431MiDKnighT
ModeratorIt looks like for bank 1 you do not add this:
A:03 X:FF Y:45 S:22 P:nvUbdIzC $D93B:69 03 ADC #$03
So going back to your previous post:
I understand the transformation from 0xc0 to 0×00 and 0×07.
If you’re loading tile ID “C0” if it’s bank 1 it would be 0x00 and 0x03. If it’s bank 2 it would be 0x00 and 0x07. Making this clearer in the guide:
“To load the actual (small) tiles first it takes the tile ID. In this case “C0” and multiplies it by 4 (0x300) and stores it in $14 (00) and $15 (03). Then if the control code was “1” it adds 4 to $15 which gives us #07 (if control code was 0 it would stay at 03) then it loads the value from the table at D9B6.”
February 2, 2014 at 7:02 pm #53432Niahak
Moderator
Still need to colorize things… but I think the interface for that is TBD anyway!
All of this stuff (aside from categories) is loaded from the ROM now. I can get rid of the images in the maptiles subfolder.
The other tilesets are loading in in the background, but aren’t selectable yet.
I might not have time to work on this tomorrow, so I’ll check-in what I have. MiDKnighT, if you’d like to work on it any more or look over what I’ve done, feel free.
-
This reply was modified 12 years, 2 months ago by
Niahak.
February 2, 2014 at 7:08 pm #53433MiDKnighT
ModeratorNice! Great job Niahak. And sorry if the guide wasn’t as clear as it should have been. This is pretty complicated stuff! I’ll look at what you have tomorrow and if I can add to it then I will.
February 2, 2014 at 11:39 pm #53438MiDKnighT
ModeratorWe’ve got glorious, beautiful color!
I found out the palette number is stored here:
int palette = entireRom[fullIndex + 0x400];
So I had to change mapSubImages into a byte[] list instead of an image list. So I have to add the colors in LoadMapGraphics with:
using (var g = Graphics.FromImage(subImg))
{
g.DrawImage(ConvertToBitmap(mapSubImages[category][topLeft – 0x80],8,8,”map”,paletteinfo), 0, 0);
g.DrawImage(ConvertToBitmap(mapSubImages[category][topRight – 0x80],8,8,”map”,paletteinfo), 8, 0);
g.DrawImage(ConvertToBitmap(mapSubImages[category][bottomLeft – 0x80],8,8,”map”,paletteinfo), 0, 8);
g.DrawImage(ConvertToBitmap(mapSubImages[category][bottomRight – 0x80],8,8,”map”,paletteinfo), 8, 8);
}Only problem is the ROM loading time is a lot higher now loading all these bitmaps… But to be able to edit map in the game should be well worth it.
Checked in my changes.
-
This reply was modified 12 years, 2 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.



