Skip to content

Copying BAM frames in WeiDU - Is it possible?

AdulAdul 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:
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
lolien

Comments

  • GwendolyneGwendolyne Member Posts: 461
    edited May 2018
    It is possible. One year ago, I wrote a WeiDU function to Convert classic inventory BAMs to EE. I might try to modify it to convert EE inventory BAMs to classic structure, but only if EE BAMs are v1 (like IAMUL01.bam).
    Adullolien
  • AdulAdul Member Posts: 2,002
    edited May 2018
    @Gwendolyne Ah, cool! If you could provide the code for v1 BAMs, I could take a crack at extending its functionality to work with v2 BAMs.

    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.
    lolien
  • GwendolyneGwendolyne Member Posts: 461
    edited May 2018
    In fact, you only want to display the small icon ? Correct ?

    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.

  • AdulAdul Member Posts: 2,002
    edited May 2018
    @Gwendolyne The original game (vanilla BG1 and BG2) displayed the first cycle (large icon) when the player selected/moved the item in the inventory, and the second cycle (small icon) when the item was placed into an inventory slot (e.g. unselected).



    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.
    Post edited by Adul on
    lolien
  • GwendolyneGwendolyne Member Posts: 461
    That's what I understood at first glance : the goal is to insert a second cycle displaying the small icon, and to update the next offsets. ;)

    Much more difficult than my function. I will have a look at it this weekend.
    Adul
  • AdulAdul Member Posts: 2,002
    In my testing I've found that I didn't need to update any offsets. All I've done is open up the uncompressed BAM in a hex editor, and change the value of the first byte of the first cycle entry from 01 to 02, essentially extending the length of the first cycle by one, which now includes the second frame, just how we need it to be.

    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.
    lolien
  • GwendolyneGwendolyne Member Posts: 461
    Very weird. But if it works!

    Can you post two bam files that you modified, so I can compare them with the originals and reproduce it with WeiDU?
    lolienAdul
  • AdulAdul Member Posts: 2,002
    Sure thing, I'm attaching two of the BAMs I edited.

    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.
  • GwendolyneGwendolyne Member Posts: 461
    Argh...

    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.
    Adul
  • GwendolyneGwendolyne Member Posts: 461
    edited May 2018
    Here is a small set of BG2:EE new icons altered with WeiDU (Sorry, but I can't upload my file : "the file has failed to upload"). Test them and tell me if they are OK for you.
    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. ;)
    Post edited by Gwendolyne on
    Adul
  • AdulAdul Member Posts: 2,002
    edited May 2018
    Awesome, that's great news! Thank you! They seem to work fine for me in-game, except ISPER01, which predictably only shows one frame. I figured each game would have some aberrations like that, we might have to handle those icons manually for each game. Hopefully there isn't a large quantity of those.
  • AdulAdul Member Posts: 2,002
    I'll tag @Kilivitz and @AndreaColombo here, as they might be interested in our findings and progress. :)
  • GwendolyneGwendolyne Member Posts: 461
    edited May 2018
    As I will be very busy the next 4 days, a couple of news:

    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
    Post edited by Gwendolyne on
    Adullolien
  • AdulAdul Member Posts: 2,002
    edited May 2018
    Thank you for your hard work, it sounds like you've already done a lot to make it work.
    lolien
  • GwendolyneGwendolyne Member Posts: 461
    Here is the summary of the BAM to convert:



    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.



    Adullolien
  • AdulAdul Member Posts: 2,002
    That's incredible, well done! I've been doing some work on the icons recently, so I can try to resolve the cases where manual conversion is required.

    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.
    lolien
  • GwendolyneGwendolyne Member Posts: 461
    I can post the ods file that explains each bam status (USED, UNUSED, NOT PROVIDED IN THE GAME) and their possibility of being automatically modified.
    So, you could check which ones REALLY need a manual conversion.

  • AdulAdul Member Posts: 2,002
    OK, thanks! Please do so, and I'll go ahead and take a look.
  • GwendolyneGwendolyne Member Posts: 461
    edited May 2018
    Here it is!

    You can add a column to notify the BAM which need a manual conversion.
    Adullolien
Sign In or Register to comment.