Copying BAM frames in WeiDU - Is it possible?
Adul
Member Posts: 2,002
In another forum thread we've been discussing the possibility of restoring vanilla behavior to inventory item icons in the EEs and reintroduce the possibility for items to feature individual inventory icon images for their unselected and selected states, similarly to how they worked in the original games. As Balquo has explained, it is possible to do this, and all it requires is to open up the BAM file for each inventory icon, and copy (or move) the first frame of the second animation cycle to the second frame of the first animation cycle.
I've been trying to check out the WeiDU documentation as well as the BAM file format(s) on IESDP in order to figure out whether it would be possible to automate this process with WeiDU, but unfortunately, I'm very inexperienced in both of those areas, and all I've managed to do so far is make my head spin.
So I thought I'd ask to check if anyone else has any more experience in this field and could maybe give some pointers or example code to help me tackle this problem, if it is indeed possible to do what I want to do.
Here's a really rough (hopefully) human-interpretable mock code of roughly what I'm looking for:
I've been trying to check out the WeiDU documentation as well as the BAM file format(s) on IESDP in order to figure out whether it would be possible to automate this process with WeiDU, but unfortunately, I'm very inexperienced in both of those areas, and all I've managed to do so far is make my head spin.
So I thought I'd ask to check if anyone else has any more experience in this field and could maybe give some pointers or example code to help me tackle this problem, if it is indeed possible to do what I want to do.
Here's a really rough (hopefully) human-interpretable mock code of roughly what I'm looking for:
FOR EACH (ITEM in game) SET VAR BAM = ITEM.icon IF (BAM.numcycles >= 2) IF (BAM[cycle 1].numframes >= 1) COPY_FRAME BAM[cycle 1][frame 0] to BAM[cycle 0][frame 1] ENDIF ENDIF ENDFOR
1
Comments
Just now I've had some success changing the structure of an uncompressed BAM to the desired format with a hex editor by changing the first byte of the first cycle entry from 1 to 2. I've checked with NearInfinity afterwards, and that did just what I wanted, simple as that. It works in-game, too!
Now, if I wasn't so terrible with WeiDU, it'd be as simple as doing that with all the item icon BAMs in the game, and we'd have a great little nostalgic mod at our hands.
Bam V1 have two cycles : the first one (#0) displays the large frame when you move the item. The second one (#1) displays the small icon in the inventory slots.
This behavior was changed in the EEs, probably because the inventory slots were made larger. Now the game displays the first cycle (large icon) for both item states: selected and unselected. The second cycle is no longer in use.
However, due to @Balquo's insight into this matter, it is now known that it's possible to subvert the new EE behavior and return to the original way the game used to display item icons by adding the small icon frame (from the second cycle) to the first cycle, like so:
Original item icon BAM:
cycle 0: frame 0
cycle 1: frame 1
Restructured item icon BAM:
cycle 0: frame 0; frame 1
cycle 1: frame 1
Doing this will restore the original small icon to appear when the item is unselected. The large icon will continue to appear when the item is selected, as usual.
Sorry if you knew all this already. This can be an awkward topic to discuss, because the details are so small and easy to miss. Yet, the overall effects of this issue on one's experience in the game can be very large indeed.
Much more difficult than my function. I will have a look at it this weekend.
I've tested it, and it works, both in NI and in-game. Very very simple to do.
That is, very simple in theory. I still have to quite a bit of brushing up on my WeiDU-fu to do to be able to do anything with this on a mass scale.
Can you post two bam files that you modified, so I can compare them with the originals and reproduce it with WeiDU?
It made sense to me, because the IESDP definition of the BAM v1 states that the first two bytes of a cycle entry dictates the count of frame indices in the animation cycle (essentially its length), so adding +1 to it means that the cycle will extend to encompass the next frame.
I wrote a function that seems to work in BG2:EE. But I have discovered that many bam files don't have the same structures in BG:EE and BG2:EE.
I must add another check to handle them.
You will notice that ISPER01.bam cannot be modified because it contains 1 single frame (the large one). Fortunately, its BG:EE version can be modified.
I handled the following cases:
- two cycles and two frames ==> DONE
- one cycle and two frames ==> DONE (I added a second cycle, so that the bam file is now compatible with classic games).
- it works whatever the large frame is (#0 or #1): if necessary, I modify the lookup table.
This should scope both BG:EE and BG2:EE matching icons.
Next to do :
- write a process to identify which bam files must be fixed manually (one single large frame) in BG:EE and BG2:EE games ==> EASY
- run my own function to extract those bam files from classic games and convert them to be used in EE games ==> SUPER EASY
As you can see, most bam files might be modified with WeiDU. I say 'might' because many are not the same: for example, ILEAT10 (BGEE) and ILEAT10 (BG2EE) are different. The first one can be automatically modified, the second one needs another process.
It's also worth noting that a lot of item icons have minor differences in art style between BG1 and BG2, and I believe the EEs unfortunately use the wrong icon in the wrong game in some cases. For example, BG:EE includes the BG2-style icon for IHALB01.
So, you could check which ones REALLY need a manual conversion.
You can add a column to notify the BAM which need a manual conversion.