Пример #1
0
        // Generates static relocation unit from or to static
        public RelocationUnit(Region region, ROM rom, bool isFromStatic)
        {
            int segmentedAddress = rom.GetSegmentedAddress(region.romStart);

            if (segmentedAddress == -1)
            {
                throw new ArgumentException("Failed to get segmented address");
            }

            int segment = SegmentedAddressHelper.GetSegment(segmentedAddress);
            int staticSegmentedAddress = SegmentedAddressHelper.GetStaticSegmentedAddress(segment);

            length = region.length;

            if (!isFromStatic)
            {
                start    = segmentedAddress;
                newStart = staticSegmentedAddress;
            }
            else
            {
                start    = staticSegmentedAddress;
                newStart = segmentedAddress;
            }
        }
Пример #2
0
        public int GetROMAddress(int segmentedAddress)
        {
            int segment = SegmentedAddressHelper.GetSegment(segmentedAddress);
            int offset  = SegmentedAddressHelper.GetOffset(segmentedAddress);

            if (segment > 0x20)
            {
                return(-1);
            }

            if (segments[segment] == null)
            {
                return(-1);
            }

            return(segments[segment].start + offset);
        }
Пример #3
0
        public int GetSegmentedAddress(int romAddress)
        {
            for (int currentSegment = 0; currentSegment < 0x20; currentSegment++)
            {
                SegmentDescriptor descriptor = segments[currentSegment];
                if (descriptor == null)
                {
                    continue;
                }

                if (descriptor.start <= romAddress && romAddress <= descriptor.start + descriptor.length)
                {
                    return(SegmentedAddressHelper.GetSegmentedAddress(currentSegment, romAddress - descriptor.start));
                }
            }

            return(-1);
        }
Пример #4
0
        private static void RegionParse_cmd06(ROM rom, List <Region> regions, RegionParseState state)
        {
            int segmentedAddress = rom.Read32(4);
            int segment          = SegmentedAddressHelper.GetSegment(segmentedAddress);

            // 06 command will return one way or another, so just wait for it
            if (segment != 0x19)
            {
                return;
            }

            CutRegion(rom, regions, state, rom.offset, state.regionState);

            state.retAddressStack.Push(rom.offset + rom.Read8(1));
            int offset = (int)rom.GetROMAddress(segmentedAddress);

            rom.offset  = offset - 8; // kostul for next cmd switching
            state.start = offset;
        }