Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Pull Request for issues #18, #19, #7, #8 #21

Merged
merged 6 commits into from
Feb 28, 2016
Merged

Conversation

MetLob
Copy link
Contributor

@MetLob MetLob commented Oct 8, 2015

Also fixed "Tile Index" maximum value in OAM Editor...
This is commit to close Issue #18 and #19

For all oldest plugins, where using SpriteBase and OAM Editor, nothing affected and their works has't been changed.

@MetLob
Copy link
Contributor Author

MetLob commented Dec 25, 2015

Added implementation for Issues #7 and #8

@MetLob MetLob changed the title Partitions data has been added to the OBJ base structure and supported NCER format Pull Request for issues #18, #19, #7, #8 Dec 25, 2015
@pleonex
Copy link
Owner

pleonex commented Dec 26, 2015

Thanks a lot! and sorry for forgetting about this. I will review all the changes today

// Update partition data info
ncer.cebk.partition_data_offset = ncer.cebk.section_size - 8;
ncer.cebk.max_partition_size = max_partition_size;
ncer.cebk.first_partition_data_offset = (ncer.cebk.first_partition_data_offset > 0) ? ncer.cebk.first_partition_data_offset : 8;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this means that the first_partition_data_offset can't be smaller than 8? In that case, should be check if it's smaller than 8 instad of 0?

@pleonex
Copy link
Owner

pleonex commented Jan 20, 2016

Everything look good for me. I am waiting for a reply to my comment before merging.
Thank you so much! This will make a new release. I am adding you to the credits.

@pleonex pleonex self-assigned this Jan 20, 2016
@MetLob
Copy link
Contributor Author

MetLob commented Jan 22, 2016

In this code I always added one part of data as default.
And if partition data exist then ncer.cebk.partition_data_offset = ncer.cebk.section_size - 8;
this > 0 because ncer.cebk.section_size > 8
-8 because:

br.BaseStream.Position = ncer.header.header_size + ncer.cebk.partition_data_offset + 8; // 8 is a    CEBK general header size (magic and size))

If you do not want to add partition data if original file does not contain this, you can change this code to

       // Update partition data info
        if (ncer.cebk.partition_data_offset != 0)
        {
            ncer.cebk.partition_data_offset = ncer.cebk.section_size - 8;
            ncer.cebk.max_partition_size = max_partition_size;
            ncer.cebk.first_partition_data_offset = 8;
            ncer.cebk.section_size += (uint)(8 * (Banks.Length + 1));
        }

@MetLob
Copy link
Contributor Author

MetLob commented Jan 22, 2016

about ncer.cebk.first_partition_data_offset
This value has min value = 8, because for all partitions data section fisrt 8 bytes is first_partition_data_offset and max_partition_size and value of first_partition_data_offset relative to this section.

value of first_partition_data_offset is offset to position where start reading to partitions data
value of first_partition_data_offset = 0 if partition_data_offset == 0 in source file and i add one part.

In row with update first_partition_data_offset value i keep original value if partition data exist.
But in correct files this value = 8 only (in NITRO-SDK) and (my bug) i don't use this value in reading and writing.
For full compatible (if this value > 8) we can fix this:

        #region Read partitions data

        if (ncer.cebk.partition_data_offset != 0)
        {
            br.BaseStream.Position = ncer.header.header_size + ncer.cebk.partition_data_offset + 8; // 8 is a CEBK general header size (magic and size)
            ncer.cebk.max_partition_size = br.ReadUInt32();
            ncer.cebk.first_partition_data_offset = br.ReadUInt32();
            br.BaseStream.Position += ncer.cebk.first_partition_data_offset - 8;
            for (int i = 0; i < ncer.cebk.nBanks; i++)
            {
                ncer.cebk.banks[i].partition_offset = br.ReadUInt32();
                ncer.cebk.banks[i].partition_size = br.ReadUInt32();
            }
        }

        #endregion

... and in updates:

         ncer.cebk.first_partition_data_offset = 8;

I can commit this fix?

@MetLob
Copy link
Contributor Author

MetLob commented Feb 12, 2016

I fixed this

@pleonex
Copy link
Owner

pleonex commented Feb 28, 2016

Perfect! Thanks! I am merging and closing the issues.
Regarding the credits (in the About window) do you want to appear as MetLob or with another nick?

@MetLob
Copy link
Contributor Author

MetLob commented Mar 1, 2016

Yea, MetLob is OK

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants