Пример #1
0
 private void OpenScriptResourceLittleEndian(uint id)
 {
     bool needByteSwap = false;
     if (_isBigEndian)
     {
         // Cluster files are in big endian fomat.
         // If the resource are not in memory anymore, and therefore will be read
         // from disk, they will need to be byte swaped.
         MemHandle memHandle = ResHandle(id);
         if (memHandle != null)
             needByteSwap = (memHandle.cond == MemMan.MEM_FREED);
     }
     ResOpen(id);
     if (needByteSwap)
     {
         MemHandle handle = ResHandle(id);
         if (handle == null)
             return;
         // uint32 totSize = handle.size;
         Header head = new Header(handle.data);
         head.comp_length = ScummHelper.SwapBytes(head.comp_length);
         head.decomp_length = ScummHelper.SwapBytes(head.decomp_length);
         head.version = ScummHelper.SwapBytes(head.version);
         UIntAccess data = new UIntAccess(handle.data, Header.Size);
         uint size = handle.size - Header.Size;
         if ((size & 3) != 0)
             throw new InvalidOperationException($"Odd size during script endian conversion. Resource ID ={id}, size = {size}");
         size >>= 2;
         for (uint cnt = 0; cnt < size; cnt++)
         {
             data[0] = ScummHelper.SwapBytes(data[0]);
             data.Offset += 4;
         }
     }
 }
Пример #2
0
 public void AddToGraphicList(byte listId, uint objId)
 {
     if (listId == 0)
     {
         Debug.Assert(_foreLength < MAX_FORE);
         _foreList[_foreLength++] = objId;
     }
     if (listId == 1)
     {
         Debug.Assert(_sortLength < MAX_SORT);
         var cpt = _objMan.FetchObject(objId);
         _sortList[_sortLength].id = (int)objId;
         _sortList[_sortLength].y = cpt.anim_y; // gives feet coords if boxed mega, otherwise top of sprite box
         if ((cpt.status & STAT_SHRINK) == 0)
         {     // not a boxed mega using shrinking
             Header frameRaw = new Header(_resMan.OpenFetchRes((uint)cpt.resource));
             FrameHeader frameHead = new FrameHeader(_resMan.FetchFrame(frameRaw.Data, (uint)cpt.frame));
             _sortList[_sortLength].y += _resMan.ReadUInt16(frameHead.height) - 1; // now pointing to base of sprite
             _resMan.ResClose((uint)cpt.resource);
         }
         _sortLength++;
     }
     if (listId == 2)
     {
         Debug.Assert(_backLength < MAX_BACK);
         _backList[_backLength++] = objId;
     }
 }