Home › Forums › Destiny of an Emperor › Town and Cave Editing
- This topic has 48 replies, 4 voices, and was last updated 12 years, 2 months ago by
sonic.penguin.
-
AuthorPosts
-
January 25, 2014 at 11:23 am #53243
MiDKnighT
ModeratorSo was trying to figure this out. Looks like the “address” for each region it pulls is stored in $12 and $13 and is loaded by $D902 and $D90A:
$D902:85 12 STA $0012 = #$88 A:B8 X:01
…
$D90A:85 13 STA $0013 = #$0F A:91 X:01 Y:01 S:2C P:NvUbdIzcThen it load the actual tile at $D91E:
$D91E:B1 12 LDA ($12),Y @ $91CA = #$60 A:12 X:01 Y
Using this, I tracked down one of Xu Zhou’s regions stored at $BDE0 on page 07 which is 0x1FDF0. If I zero out that line look what happens:
Now I’ll try the same thing for a cave. So I walked into Guan Ping’s cave and watched $D902, $D90A, and $D91E and the region it was using is $B018 on page 06 which is 0x1B028. If I zero out that line look what happens:
So I know how it finds the town and cave regions. What I don’t know yet is how it builds the tiles and what each tile is. That’s the key to pulling regions directly from the ROM. Or in total, what has to be known is:
1. How the regions are laid out (not known yet)
2. Where the region is located (known)
3. How it builds the tiles for each region type ie…map, town, or cave (not known yet)January 25, 2014 at 11:25 am #53244sonic.penguin
ModeratorLike the difference between a wall and a non-wall?
January 25, 2014 at 11:33 am #53247MiDKnighT
ModeratorLike the difference between a wall and a non-wall?
Go to the area near 0x1B028 and play around with different values. If you’re lucky or diligent enough you can manually build a wall 8)
January 28, 2014 at 3:13 am #53311DragonAtma
ModeratorYou know, there are a lot of gaps around the edges of china where nothing exists, neither plains nor mountains nor water nor (etc.)
…is it possible those tiles are at least some of the cities/caves/etc.?
January 28, 2014 at 6:57 am #53312MiDKnighT
ModeratorI don’t think so because they use different region numbers. Since you’re so interested in this I’ll see if I can make progress on this today.
January 28, 2014 at 9:11 am #53313MiDKnighT
ModeratorMore on the formula to find the map region:
First, the address in the warp when you walk into Xu Zhou is “0E 08 0F 01” which is in the format Y1 Y2 X1 X2. With the Y2/X2 values being the region and the Y1/X1 values being the location on the region.
Find the lookup table location for the region:
Load $1F which is the X2 value for the region (01), ASL it, then store in $F3 (02).
Load $1D (Y2 value) which is 09 then multiply it by 40 which gives us 240. It then takes the “40” and adds $F3 to it giving us 42. It then loads the “2” from 240 and adds A7 to it giving us A9. This gives us the addres to look up our region info which is $A942 which is used in the next section:
Find the region location:
Page 09 contains a table which includes a page number and a modifier. For example when I walk into Xu Zhou it loads the modifier at $A942 and $A943 which is 07 D5:
$D8D2:B1 10 LDA ($10),Y @ $A942 = #$D5 A:00 X:24 Y:00 S:22 P:nvUbdIZc
$D8D4:AA TAX A:D5 X:24 Y:00 S:22 P:NvUbdIzc
$D8D5:C8 INY A:D5 X:D5 Y:00 S:22 P:NvUbdIzc
$D8D6:B1 10 LDA ($10),Y @ $A943 = #$07 A:D5 X:D5 Y:01 S:22 P:nvUbdIzcSo once it goes to page 07, it load D5 into memory then multiplies it by 8 which gives 0x06a8 and stores these values in $F4 (06) and $F3 (A8). Then it takes our 06a8 number and multiplies it by 8 again giving us 0x3540. Then it takes the “40” and adds $F3 to it giving us E8 and it takes the “35” number and adds $F4 to it giving us 0x3b then it takes that number and adds 0x80 to it giving us our region location which is $BBE8 on page 07 in this case. It uses BBE8, applies a Y value, and looks up the tile here:
$D91E:B1 12 LDA ($12),Y @ $BC03 = #$8A A:1B X:06 Y:1B S:22 P:nvUbdIzc
Testing this… Let’s mess with the modifier and see what happens. I’ll replace D5 with DB and look what happens, it replaces an entire region in Xu Zhou:
Next to find how it constructs the tile. Using Tile Layer Pro, I can see that most of the map, cave, and town graphics are physically stored on page 04. Some of the map graphics are at the bottom of the system page.
January 28, 2014 at 9:13 am #53314sonic.penguin
ModeratorActually, some areas are used to duplicate other areas. For example, if you edit the water north of Qing Zhou, that will affect other large areas of water because that ‘zone’ is essentially copied to cover other large areas of water so any land you add on that one zone will affect all other zones. It was probably done to save space on the game is my guess.
January 28, 2014 at 9:16 am #53315sonic.penguin
ModeratorTesting this… Let’s mess with the modifier and see what happens. I’ll replace D5 with DB and look what happens, it replaces an entire region in Xu Zhou:
Awesome! The town edits cometh…. I can feel it!
Actually, a cool feature would be to add the Gullwing locations to DOAEditor as well.
Something I found out through editing is that Gullwing are unusable until you enter Xu Zhou. So if I make Chang An the first castle, I won’t gain access to Chang An’s gullwing location until I enter Xu Zhou in which case I will gain access to the gullwing abilities for Xu Zhou and Chang An simultaneously. Weird.
January 28, 2014 at 9:17 am #53316MiDKnighT
ModeratorActually, some areas are used to duplicate other areas. For example, if you edit the water north of Qing Zhou, that will affect other large areas of water because that ‘zone’ is essentially copied to cover other large areas of water so any land you add on that one zone will affect all other zones. It was probably done to save space on the game is my guess.
This is true, several regions are “reused”. For example the region I traced “D5 07” is used in several places because it is a grassy plain. It is used for any grass area (like the ones outside town entrances).
January 28, 2014 at 9:25 am #53319MiDKnighT
ModeratorSomething I found out through editing is that Gullwing are unusable until you enter Xu Zhou. So if I make Chang An the first castle, I won’t gain access to Chang An’s gullwing location until I enter Xu Zhou in which case I will gain access to the gullwing abilities for Xu Zhou and Chang An simultaneously. Weird.
Yes I actually just saw this when I was tracing how it finds the region. It actually stores whether you’ve entered a town or not here:
$06D2:B1 1A LDA ($1A),Y @ $8383 = #$7E A:00 X:01 Y:08 S:2E P:nvUbdIzc
$06D4:9D 12 60 STA $6012,X @ $6013 = #$7E A:7E X:01 Y:08 S:2E P:nvUbdIzc
$06D7:85 47 STA $0047 = #$00 A:7E X:01 Y:08 S:2E P:nvUbdIzc
$06D9:AA TAX A:7E X:01 Y:08 S:2E P:nvUbdIzc
$06DA:BD 00 67 LDA $6700,X @ $677E = #$06 A:7E X:7E Y:08 S:2E P:nvUbdIzc
$06DD:09 02 ORA #$02 A:06 X:7E Y:08 S:2E P:nvUbdIzc
$06DF:9D 00 67 STA $6700,X @ $677E = #$06 A:06 X:7E Y:08 S:2E P:nvUbdIzcIt stores a value in $67## where ## is the location ID. I think that means it will only let you gullwing somewhere if you’ve entered the town – because it checks $67##:
>0E:876E:AD 7E 67 LDA $677E = #$06
0E:8771:29 02 AND #$02
0E:8773:D0 26 BNE $879BJanuary 28, 2014 at 11:33 am #53320sonic.penguin
ModeratorEssentially, you could enter every town in the entire game and not be able to gullwing until you enter Xu Zhou, granted, the way DOAE is set up in the original it forces you to enter Xu Zhou at some point to open up access through Si Shui gate. Actually, I’ve used this method in the Flames of Wu Mod and probably the HOC mod to impede progress to specific areas via players not being able to access the death of tao qian event.
January 28, 2014 at 11:44 am #53321MiDKnighT
ModeratorMore findings:
Town graphic tiles are loaded into PPU memory at $1800-$1FFF. The first one loading into a town being here:
$C3BD:B1 00 LDA ($00),Y @ $A800 = #$FF A:00 X:08 Y:00 S:24 P:nvUbdIzc
$C3BF:8D 07 20 STA $2007 = #$95 A:FF X:08 Y:00 S:24 P:NvUbdIzcThe town graphics range is physically stored in 0xa800-0xafff (page 04). I also checked on the world map graphics, cave graphics, and more and we have these physical locations for the tiles:
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-0x1380fThese ranges get loaded into PPU memory (visible in PPU viewer)
How does it know which set of graphics to load?
A:00 X:0F Y:02 S:2A P:nvUbdIZC $BF38:A5 47 LDA $0047 = #$7E
A:7E X:0F Y:02 S:2A P:nvUbdIzC $BF3A:4A LSR
A:3F X:0F Y:02 S:2A P:nvUbdIzc $BF3B:A8 TAY
A:3F X:0F Y:3F S:2A P:nvUbdIzc $BF3C:B9 86 BF LDA $BF86,Y @ $BFC5 = #$55
A:55 X:0F Y:3F S:2A P:nvUbdIzc $BF3F:B0 04 BCS $BF45
A:55 X:0F Y:3F S:2A P:nvUbdIzc $BF41:4A LSR
A:2A X:0F Y:3F S:2A P:nvUbdIzC $BF42:4A LSR
A:15 X:0F Y:3F S:2A P:nvUbdIzc $BF43:4A LSR
A:0A X:0F Y:3F S:2A P:nvUbdIzC $BF44:4A LSR
A:05 X:0F Y:3F S:2A P:nvUbdIzc $BF45:29 0F AND #$0F
A:05 X:0F Y:3F S:2A P:nvUbdIzc $BF47:85 49 STA $0049 = #$00What this is doing, loading the location ID (Xu Zhou / 7E), then LSR’ing it, transferring it to Y, and looking up from a table at $BF86-$BFC5 on page 0E (0x3bf95-0x3bfd5). Then it stores the value in $49 and uses it here to find where to look up tiles:
A:00 X:BA Y:00 S:28 P:nvUbdIZc $DEF5:A5 49 LDA $0049 = #$05
A:05 X:BA Y:00 S:28 P:nvUbdIzc $DEF7:0A ASL
A:0A X:BA Y:00 S:28 P:nvUbdIzc $DEF8:0A ASL
A:14 X:BA Y:00 S:28 P:nvUbdIzc $DEF9:0A ASL
A:28 X:BA Y:00 S:28 P:nvUbdIzc $DEFA:69 80 ADC #$80
A:A8 X:BA Y:00 S:28 P:NvUbdIzc $DEFC:85 01 STA $0001 = #$60
A:A8 X:BA Y:00 S:28 P:NvUbdIzc $DEFE:A9 00 LDA #$00
A:00 X:BA Y:00 S:28 P:nvUbdIZc $DF00:85 00 STA $0000 = #$78Other notable location IDs:
World Map: 00
Yellow Scarves Cave: 04
Guan Ping Cave: 2A
Cave leading to Chang An: 29
Yuan Shu Cave: 2B
Xu Zhe Cave: 17
Mt Gong Tai: 29
First Wu Cave (Saltpeter): 30
Second Wu Cave: 29
Ru Nan Cave: 2F
Second Wei Cave: 2DNow to put this info to use, let’s change Xu Zhou’s PPU tiles…
Xu Zhou with Guan Ping cave PPU settings:
Last piece to find – how it uses these PPU tiles to construct and identify “map” tiles.
January 28, 2014 at 1:52 pm #53322MiDKnighT
ModeratorTracing how this tile is built:
First it loads “C0” (the tile ID) into memory via $D91E. Remember that in the world map there are 2 versions of “C0”. We have to figure out which one by loading the control code. More about that in Niahak’s old post here:
So here it is loading the control code:
A:45 X:03 Y:45 S:22 P:nvUbdIzc $D931:B1 12 LDA ($12),Y @ $91FD = #$7F
7F = 01111111
This tile is in the middle of that row so it gets the high value “1”. Which means it’s tile # 2_192.
Blowing up the picture and looking at the PPU viewer you can see exactly how the small tiles make it up (4×4):
It loads it in groups 4 at a time and it actually looks like it looks up the tile IDs on page 9.
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 = #$D1A:12 X:12 Y:0F S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $880F = #$C2
A:13 X:13 Y:0F S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $890F = #$C3
A:36 X:36 Y:0F S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8A0F = #$D2
A:37 X:37 Y:0F S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8B0F = #$D3A:10 X:10 Y:0C S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $880C = #$B0
A:11 X:11 Y:0C S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $890C = #$A1
A:34 X:34 Y:0C S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8A0C = #$B0
A:35 X:35 Y:0C S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8B0C = #$B1A:12 X:12 Y:0D S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $880D = #$A2
A:13 X:13 Y:0D S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $890D = #$A3
A:36 X:36 Y:0D S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8A0D = #$B2
A:37 X:37 Y:0D S:24 P:nvUbdIzc $F59E:B1 14 LDA ($14),Y @ $8B0D = #$B3Next to get how it populates the values for $14 and $15, how the Y value changes.
Man this map stuff is complicated.
January 28, 2014 at 2:25 pm #53323sonic.penguin
ModeratorMan this map stuff is complicated.
Heh, seems that way but at least some progress has been made on the locations of where town and cave information is stored. I figured that the “pictures” had a lot more code behind them than we originally thought. I’ve noticed alot of tiles from going into warps that send you into “neverland” that there are all kinds of graphic tiles that seem unused in the normal game?
January 28, 2014 at 2:39 pm #53324MiDKnighT
Moderator“neverland” that there are all kinds of graphic tiles that seem unused in the normal game?
Neverland is an area where the wrong graphics are loaded into PPU memory for the place you are at. Similar to my “Change the PPU graphics for Xu Zhou” example:
The game uses every bit of graphics it has stored over and over (besides Japanese characters). There’s really not that many graphics in the original game.
Note that my posts in this thread are mostly out of order as far as how the mapping system works. I put it in order and put it in the guide here: http://doaerhguide.wikidot.com/start#toc15
Just a few last touches to have the whole thing figured out.
-
AuthorPosts
- You must be logged in to reply to this topic.







