Abandoned FE7 Hard Mode Feature?
Awhile back I was looking through the ROM for a good place to increase enemy stats because I was trying to find a way to tune the game's difficulty.
I found the function that gives enemies their hard mode bonuses so I felt like I found what I was looking for. However there was something a little odd about this function. This is the function here with my comments.
08079990
B500
push {lr}
//Get Character Hard Mode Bonus Levels, @r0 = char ID, returns -> r0 = bonus levels
08079992
0600
lsl r0 ,r0 ,#0x18
//trim
08079994
0E00
lsr r0 ,r0 ,#0x18
//trim
08079996
4A01
ldr r2, [pc, #0x4]
# pointer:0807999C -> 08C9F9EC (Character Hard Mode Bonus Levels Data Table)
08079998
E007
b 0x80799aa
//skip ahead
0807999C
F9EC 08C9
//LDRDATA
080799A0
4281
cmp r1 ,r0
//compare r1 to r0 (char ID)
080799A2
D101
bne #0x80799a8
//branch if not equal
080799A4
6850
ldr r0, [r2, #0x4]
//read data table +0x4 (bonus levels)
080799A6
E00A
b 0x80799be
//done
080799A8
3208
add r2, #0x8
//next entry
080799AA
7811
ldrb r1, [r2, #0x0]
//read data table +0x0 (char ID)
080799AC
2900
cmp r1, #0x0
//compare to zero
080799AE
D1F7
bne #0x80799a0
//branch if not zero
080799B0
4804
ldr r0, [pc, #0x10]
# pointer:080799C4 -> 0202BBF8 (Chapter Data)
080799B2
7B80
ldrb r0, [r0, #0xe]
//read Chapter Data +0xE (Chapter ID)
080799B4
0600
lsl r0 ,r0 ,#0x18
//trim
080799B6
1600
asr r0 ,r0 ,#0x18
//trim
080799B8
F7B7 FDDC
bl 0x08031574
//A function that returns the address of the map setting from the map number r0: Address of map setting r0: Map ID you want to check: MAPCHAPTER
080799BC
7D00
ldrb r0, [r0, #0x14]
//read Chapter Setting +0x14 (Difficulty)
080799BE
BC02
pop {r1}
//pop return adds
080799C0
4708
bx r1
//return
This might be a little confusing to look at if you aren't familiar with assembly, but let me walk you through it and it will make sense.
We start with the enemies' character ID number. If you've used FE Builder then this is the ID number for the character in the Character Editor. We trim the ID by shifting the register left then shifting it right by the same amount. A visual example should explain this pretty well.
Let's say the input is 000010C8. Let's shift it left by 0x18 we get
C8000000
Now let's shift it back right by 0x18 we get
000000C8
See what happened? The 10 in the original input was removed. A character ID number needs to be two digits so when we shift back and forth this way we trim the input to make sure it's the right size.
This is just a best practice thing. Ideally the input is just two digits already. This is a just in case we are getting some messy input it will still work because we trimmed it down to be the size we need it to be kind of deal. If you look through the FE7 ROM you'll see this happen all the time. So nothing too surprising so far.
Then we can see that we are loading a data table located at 08C9F9EC. Then we are going to skip ahead, I'll highlight the jump here.
08079990
B500
push {lr}
//Get Character Hard Mode Bonus Levels, @r0 = char ID, returns -> r0 = bonus levels
08079992
0600
lsl r0 ,r0 ,#0x18
//trim
08079994
0E00
lsr r0 ,r0 ,#0x18
//trim
08079996
4A01
ldr r2, [pc, #0x4]
# pointer:0807999C -> 08C9F9EC (Character Hard Mode Bonus Levels Data Table)
08079998
E007
b 0x80799aa
//skip ahead
0807999C
F9EC 08C9
//LDRDATA
080799A0
4281
cmp r1 ,r0
//compare r1 to r0 (char ID)
080799A2
D101
bne #0x80799a8
//branch if not equal
080799A4
6850
ldr r0, [r2, #0x4]
//read data table +0x4 (bonus levels)
080799A6
E00A
b 0x80799be
//done
080799A8
3208
add r2, #0x8
//next entry
080799AA
7811
ldrb r1, [r2, #0x0]
//read data table +0x0 (char ID)
080799AC
2900
cmp r1, #0x0
//compare to zero
080799AE
D1F7
bne #0x80799a0
//branch if not zero
080799B0
4804
ldr r0, [pc, #0x10]
# pointer:080799C4 -> 0202BBF8 (Chapter Data)
080799B2
7B80
ldrb r0, [r0, #0xe]
//read Chapter Data +0xE (Chapter ID)
080799B4
0600
lsl r0 ,r0 ,#0x18
//trim
080799B6
1600
asr r0 ,r0 ,#0x18
//trim
080799B8
F7B7 FDDC
bl 0x08031574
//A function that returns the address of the map setting from the map number r0: Address of map setting r0: Map ID you want to check: MAPCHAPTER
080799BC
7D00
ldrb r0, [r0, #0x14]
//read Chapter Setting +0x14 (Difficulty)
080799BE
BC02
pop {r1}
//pop return adds
080799C0
4708
bx r1
//return
Now we are going to read the first thing in that data table, or as I would call it offset +0x0. In the notes you can see that offset labeled as (char ID) but we don't actually know that yet. I figured that out from context that we are going to see very soon.
After reading the table offset +0x0 we are going to compare the value at that offset to zero. We are going to branch if it is not zero. Meaning we branch if we found something in the table. So let me highlight that jump.
08079990
B500
push {lr}
//Get Character Hard Mode Bonus Levels, @r0 = char ID, returns -> r0 = bonus levels
08079992
0600
lsl r0 ,r0 ,#0x18
//trim
08079994
0E00
lsr r0 ,r0 ,#0x18
//trim
08079996
4A01
ldr r2, [pc, #0x4]
# pointer:0807999C -> 08C9F9EC (Character Hard Mode Bonus Levels Data Table)
08079998
E007
b 0x80799aa
//skip ahead
0807999C
F9EC 08C9
//LDRDATA
080799A0
4281
cmp r1 ,r0
//compare r1 to r0 (char ID)
080799A2
D101
bne #0x80799a8
//branch if not equal
080799A4
6850
ldr r0, [r2, #0x4]
//read data table +0x4 (bonus levels)
080799A6
E00A
b 0x80799be
//done
080799A8
3208
add r2, #0x8
//next entry
080799AA
7811
ldrb r1, [r2, #0x0]
//read data table +0x0 (char ID)
080799AC
2900
cmp r1, #0x0
//compare to zero
080799AE
D1F7
bne #0x80799a0
//branch if not zero
080799B0
4804
ldr r0, [pc, #0x10]
# pointer:080799C4 -> 0202BBF8 (Chapter Data)
080799B2
7B80
ldrb r0, [r0, #0xe]
//read Chapter Data +0xE (Chapter ID)
080799B4
0600
lsl r0 ,r0 ,#0x18
//trim
080799B6
1600
asr r0 ,r0 ,#0x18
//trim
080799B8
F7B7 FDDC
bl 0x08031574
//A function that returns the address of the map setting from the map number r0: Address of map setting r0: Map ID you want to check: MAPCHAPTER
080799BC
7D00
ldrb r0, [r0, #0x14]
//read Chapter Setting +0x14 (Difficulty)
080799BE
BC02
pop {r1}
//pop return adds
080799C0
4708
bx r1
//return
Now we can see that we are comparing the table value to our original input which was the enemies' character ID number. So that's the context. Since we are comparing the table value to the character ID number I know that the table value is expected to be a character ID number. So let's see what happens next.
We are going to branch if the character ID in the data table is not equal to the enemy character ID that we started the function with. So basically we don't have a match. So let's look at the jump if that's the case.
08079990
B500
push {lr}
//Get Character Hard Mode Bonus Levels, @r0 = char ID, returns -> r0 = bonus levels
08079992
0600
lsl r0 ,r0 ,#0x18
//trim
08079994
0E00
lsr r0 ,r0 ,#0x18
//trim
08079996
4A01
ldr r2, [pc, #0x4]
# pointer:0807999C -> 08C9F9EC (Character Hard Mode Bonus Levels Data Table)
08079998
E007
b 0x80799aa
//skip ahead
0807999C
F9EC 08C9
//LDRDATA
080799A0
4281
cmp r1 ,r0
//compare r1 to r0 (char ID)
080799A2
D101
bne #0x80799a8
//branch if not equal
080799A4
6850
ldr r0, [r2, #0x4]
//read data table +0x4 (bonus levels)
080799A6
E00A
b 0x80799be
//done
080799A8
3208
add r2, #0x8
//next entry
080799AA
7811
ldrb r1, [r2, #0x0]
//read data table +0x0 (char ID)
080799AC
2900
cmp r1, #0x0
//compare to zero
080799AE
D1F7
bne #0x80799a0
//branch if not zero
080799B0
4804
ldr r0, [pc, #0x10]
# pointer:080799C4 -> 0202BBF8 (Chapter Data)
080799B2
7B80
ldrb r0, [r0, #0xe]
//read Chapter Data +0xE (Chapter ID)
080799B4
0600
lsl r0 ,r0 ,#0x18
//trim
080799B6
1600
asr r0 ,r0 ,#0x18
//trim
080799B8
F7B7 FDDC
bl 0x08031574
//A function that returns the address of the map setting from the map number r0: Address of map setting r0: Map ID you want to check: MAPCHAPTER
080799BC
7D00
ldrb r0, [r0, #0x14]
//read Chapter Setting +0x14 (Difficulty)
080799BE
BC02
pop {r1}
//pop return adds
080799C0
4708
bx r1
//return
You can see we add 0x8 to the data table, this just means we are going to the next entry in the data table, we are going to read offset +0x0 again and that brings us back to where we started. So we are in a loop. We will compare the table value to the character ID again and the loop will continue until one of two things happen.
Either we will match the character ID in the data table, or we will read zero in the data table. Let's look at the case in which we match the character ID. That will be this line here.
08079990
B500
push {lr}
//Get Character Hard Mode Bonus Levels, @r0 = char ID, returns -> r0 = bonus levels
08079992
0600
lsl r0 ,r0 ,#0x18
//trim
08079994
0E00
lsr r0 ,r0 ,#0x18
//trim
08079996
4A01
ldr r2, [pc, #0x4]
# pointer:0807999C -> 08C9F9EC (Character Hard Mode Bonus Levels Data Table)
08079998
E007
b 0x80799aa
//skip ahead
0807999C
F9EC 08C9
//LDRDATA
080799A0
4281
cmp r1 ,r0
//compare r1 to r0 (char ID)
080799A2
D101
bne #0x80799a8
//branch if not equal
080799A4
6850
ldr r0, [r2, #0x4]
//read data table +0x4 (bonus levels)
080799A6
E00A
b 0x80799be
//done
080799A8
3208
add r2, #0x8
//next entry
080799AA
7811
ldrb r1, [r2, #0x0]
//read data table +0x0 (char ID)
080799AC
2900
cmp r1, #0x0
//compare to zero
080799AE
D1F7
bne #0x80799a0
//branch if not zero
080799B0
4804
ldr r0, [pc, #0x10]
# pointer:080799C4 -> 0202BBF8 (Chapter Data)
080799B2
7B80
ldrb r0, [r0, #0xe]
//read Chapter Data +0xE (Chapter ID)
080799B4
0600
lsl r0 ,r0 ,#0x18
//trim
080799B6
1600
asr r0 ,r0 ,#0x18
//trim
080799B8
F7B7 FDDC
bl 0x08031574
//A function that returns the address of the map setting from the map number r0: Address of map setting r0: Map ID you want to check: MAPCHAPTER
080799BC
7D00
ldrb r0, [r0, #0x14]
//read Chapter Setting +0x14 (Difficulty)
080799BE
BC02
pop {r1}
//pop return adds
080799C0
4708
bx r1
//return
We read the data table at offset +0x4 which I have labeled as (bonus levels). How do I know these are bonus levels? Well that's because the next instruction just brings us to the end of the function. As we can see here.
08079990
B500
push {lr}
//Get Character Hard Mode Bonus Levels, @r0 = char ID, returns -> r0 = bonus levels
08079992
0600
lsl r0 ,r0 ,#0x18
//trim
08079994
0E00
lsr r0 ,r0 ,#0x18
//trim
08079996
4A01
ldr r2, [pc, #0x4]
# pointer:0807999C -> 08C9F9EC (Character Hard Mode Bonus Levels Data Table)
08079998
E007
b 0x80799aa
//skip ahead
0807999C
F9EC 08C9
//LDRDATA
080799A0
4281
cmp r1 ,r0
//compare r1 to r0 (char ID)
080799A2
D101
bne #0x80799a8
//branch if not equal
080799A4
6850
ldr r0, [r2, #0x4]
//read data table +0x4 (bonus levels)
080799A6
E00A
b 0x80799be
//done
080799A8
3208
add r2, #0x8
//next entry
080799AA
7811
ldrb r1, [r2, #0x0]
//read data table +0x0 (char ID)
080799AC
2900
cmp r1, #0x0
//compare to zero
080799AE
D1F7
bne #0x80799a0
//branch if not zero
080799B0
4804
ldr r0, [pc, #0x10]
# pointer:080799C4 -> 0202BBF8 (Chapter Data)
080799B2
7B80
ldrb r0, [r0, #0xe]
//read Chapter Data +0xE (Chapter ID)
080799B4
0600
lsl r0 ,r0 ,#0x18
//trim
080799B6
1600
asr r0 ,r0 ,#0x18
//trim
080799B8
F7B7 FDDC
bl 0x08031574
//A function that returns the address of the map setting from the map number r0: Address of map setting r0: Map ID you want to check: MAPCHAPTER
080799BC
7D00
ldrb r0, [r0, #0x14]
//read Chapter Setting +0x14 (Difficulty)
080799BE
BC02
pop {r1}
//pop return adds
080799C0
4708
bx r1
//return
Which means the table value at +0x4 is the value this function will return, and since I looked at the parent function that called this function, I know that the parent function was expecting to get the number of bonus levels for the enemy character. If that's our return value then that's what that table value must be.
For more confirmation that the table value is bonus levels we can look at what happens if we read a zero in the table. Reading a zero in the table will break the search loop. Typically zero is used to denote the end of a data table. If we read zero then we have reached the end of the table so there aren't any more character IDs to test against. If we reach the end of the table without a match we will end up here.
08079990
B500
push {lr}
//Get Character Hard Mode Bonus Levels, @r0 = char ID, returns -> r0 = bonus levels
08079992
0600
lsl r0 ,r0 ,#0x18
//trim
08079994
0E00
lsr r0 ,r0 ,#0x18
//trim
08079996
4A01
ldr r2, [pc, #0x4]
# pointer:0807999C -> 08C9F9EC (Character Hard Mode Bonus Levels Data Table)
08079998
E007
b 0x80799aa
//skip ahead
0807999C
F9EC 08C9
//LDRDATA
080799A0
4281
cmp r1 ,r0
//compare r1 to r0 (char ID)
080799A2
D101
bne #0x80799a8
//branch if not equal
080799A4
6850
ldr r0, [r2, #0x4]
//read data table +0x4 (bonus levels)
080799A6
E00A
b 0x80799be
//done
080799A8
3208
add r2, #0x8
//next entry
080799AA
7811
ldrb r1, [r2, #0x0]
//read data table +0x0 (char ID)
080799AC
2900
cmp r1, #0x0
//compare to zero
080799AE
D1F7
bne #0x80799a0
//branch if not zero
080799B0
4804
ldr r0, [pc, #0x10]
# pointer:080799C4 -> 0202BBF8 (Chapter Data)
080799B2
7B80
ldrb r0, [r0, #0xe]
//read Chapter Data +0xE (Chapter ID)
080799B4
0600
lsl r0 ,r0 ,#0x18
//trim
080799B6
1600
asr r0 ,r0 ,#0x18
//trim
080799B8
F7B7 FDDC
bl 0x08031574
//A function that returns the address of the map setting from the map number r0: Address of map setting r0: Map ID you want to check: MAPCHAPTER
080799BC
7D00
ldrb r0, [r0, #0x14]
//read Chapter Setting +0x14 (Difficulty)
080799BE
BC02
pop {r1}
//pop return adds
080799C0
4708
bx r1
//return
We are going to load Chapter Data and get the current Chapter ID. We trim the ID, even though there's really no reason to do that here, but we do that anyway and then we pass the chapter ID to a function called:
A function that returns the address of the map setting from the map number r0: Address of map setting r0: Map ID you want to check: MAPCHAPTER
Yeah so that's what FE Builder calls that function. It's not a very catchy name. It's not what I would have called it. A better name could be Get Chapter Settings, because this function gets us the settings for that chapter. You can see a chapter's settings in FE Builder by clicking the Chapter Editor button.
The setting we are going to read is the Difficulty setting, and this setting is the number of bonus levels to give enemies in hard mode. So basically if we find the enemy in the data table we will give them the number of bonus levels that's defined in the table. Otherwise we are going to give them the default number of bonus levels by using the Chapter Difficulty setting.
So it would appear that certain enemies, I would assume bosses, can have bonus levels that are different from the default bonus levels that are given to generics. I didn't know that the game did anything like that, but this is still not really odd per say. There's no reason the game wouldn't do something like that. But then I looked to see what's actually in the data table and I found this.
08C9F9EC = 00 00 00 00 00 00 00 00
Oh. So remember when I said that reading a zero in the data table would break the search loop and we will have reached the end of the table? Well, zero is the first entry in the table. Which means the loop breaks immediately and this one blank entry is the entire table.
What's interesting about this is that if this table was populated this feature would actually work just fine. All the programming is there, it's just the table that's missing. So the question then becomes, why is the table missing?
Was this a feature that was scrapped during the game's development? And if it was then what would it have been used for? Potentially you could use this data table to keep bosses from getting too strong when adding hard mode bonuses to a chapter. Bosses get the same bonuses as generics in the finished game. Since bosses are already stronger than generics adding hard mode bonuses to them could make them too strong if the hard mode bonus for the chapter is too high.
I think this could make sense, especially if the developers played around with the Chapter Difficulty setting. However if you use the Chapter Editor in FE Builder to look at the Difficulty setting for each chapter you can see there's a flat bonus of 5 bonus levels for every chapter in Eliwood and Hector modes. If the hard mode bonus doesn't ever change then there's probably not much of a risk of tuning it too high. Which could explain why the feature was scrapped.
However, there could be another reason for the empty data table. It's possible it was never part of an intended feature at all. Remember when we read the Chapter ID, and I said we trimmed the chapter ID number even though we didn't need to? Well, FE7 does things it doesn't need to do all the time, just to be confusing.
And I don't mean that in like a, it's confusing for me sometimes kind of way, I mean that they are literally trying to confuse people like me who might be reading the code and trying to reverse engineer their game. It turns out Nintendo doesn't really want people turning their game into awesome randomizers and ROM hacks.
Since debuggers are a thing they can't really stop people from reading the code. All they can do is try to make the code harder to read. Mainly by doing things that are pointless, or doing things that do accomplish something but in a very convoluted way. Keep in mind the game still needs to work. They just want to try to make it harder for you to see which parts of the code are actually important.
Which brings us to this empty data table. It is possible this wasn't a planned feature, but rather it's just a way to make the function "look busy." It looks like it's doing something. At least at a glance. If you look at the data table then you'll know that it's not doing anything, but maybe you won't look at it. Not looking at the code is what they want you to do so I guess if they're doing it right you won't look that far.
Considering how close this code is to being functional I think I would lean towards it being a scrapped feature rather than being an attempt to obfuscate. But what do you think? Is Nintendo just trying to confuse me or do you think it's a scrapped feature? If it's a scrapped feature what do you think they would have planned to use it for? Find me on my socials and tell me your theory. Thanks for reading!