예제 #1
0
 protected override Resource[] ReadResTypeList(BinaryReader br)
 {
     var numEntries = br.ReadUInt16();
     var res = new Resource[numEntries];
     var roomNumbers = br.ReadBytes(numEntries);
     for (int i = 0; i < numEntries; i++)
     {
         res[i] = new Resource { RoomNum = roomNumbers[i], Offset = br.ReadUInt32() };
     }
     return res;
 }
예제 #2
0
 static Resource[] ReadRoomResTypeList(BinaryReader br)
 {
     var num = br.ReadByte();
     var rooms = new Resource[num];
     br.ReadBytes(num); // disk file numbers
     for (int i = 0; i < num; i++)
     {
         var offset = ToOffset(br.ReadUInt16());
         rooms[i] = new Resource{ RoomNum = (byte)i, Offset = offset };
     }
     return rooms;
 }
예제 #3
0
 protected virtual Resource[] ReadResTypeList(BinaryReader br)
 {
     var num = br.ReadByte();
     var res = new Resource[num];
     var rooms = br.ReadBytes(num);
     for (int i = 0; i < num; i++)
     {
         var offset = ToOffset(br.ReadUInt16());
         res[i] = new Resource{ RoomNum = rooms[i], Offset = offset };
     }
     return res;
 }
예제 #4
0
        void ReadMap()
        {
            var br = new BinaryReader(_stream);
            _stream.Seek(_mapOffset + 22, SeekOrigin.Begin);

            _resMap.resAttr = br.ReadUInt16BigEndian();
            _resMap.typeOffset = br.ReadUInt16BigEndian();
            _resMap.nameOffset = br.ReadUInt16BigEndian();
            _resMap.numTypes = br.ReadUInt16BigEndian();
            _resMap.numTypes++;

            _stream.Seek(_mapOffset + _resMap.typeOffset + 2, SeekOrigin.Begin);
            _resTypes = new ResType[_resMap.numTypes];

            for (int i = 0; i < _resMap.numTypes; i++)
            {
                _resTypes[i].id = br.ReadUInt32BigEndian();
                _resTypes[i].items = br.ReadUInt16BigEndian();
                _resTypes[i].offset = br.ReadUInt16BigEndian();
                _resTypes[i].items++;

                Debug.WriteLine("resType: <{0}> items: {1} offset: {2} (0x{3:X2})", _resTypes[i].id, _resTypes[i].items, _resTypes[i].offset, _resTypes[i].offset);
            }

            _resLists = new Resource[_resMap.numTypes][];

            for (int i = 0; i < _resMap.numTypes; i++)
            {
                _resLists[i] = new Resource[_resTypes[i].items];
                _stream.Seek(_resTypes[i].offset + _mapOffset + _resMap.typeOffset, SeekOrigin.Begin);

                for (int j = 0; j < _resTypes[i].items; j++)
                {
                    var resPtr = _resLists[i][j] = new Resource();

                    resPtr.id = br.ReadUInt16BigEndian();
                    resPtr.nameOffset = (short)br.ReadUInt16BigEndian();
                    resPtr.dataOffset = br.ReadUInt32BigEndian();
                    br.ReadUInt32BigEndian();

                    resPtr.attr = (byte)(resPtr.dataOffset >> 24);
                    resPtr.dataOffset &= 0xFFFFFF;
                }

                for (int j = 0; j < _resTypes[i].items; j++)
                {
                    if (_resLists[i][j].nameOffset != -1)
                    {
                        _stream.Seek(_resLists[i][j].nameOffset + _mapOffset + _resMap.nameOffset, SeekOrigin.Begin);

                        byte len = br.ReadByte();
						_resLists[i][j].name = br.ReadBytes(len).GetText();
                    }
                }
            }
        }