FetchCpt() public method

public FetchCpt ( ushort cptId ) : Compact
cptId ushort
return Compact
Ejemplo n.º 1
0
        public void Engine()
        {
            do
            {
                var    raw       = _skyCompact.FetchCptRaw((ushort)_scriptVariables[LOGIC_LIST_NO]);
                var    logicList = new UShortAccess(raw, 0);
                ushort id;
                while ((id = logicList[0]) != 0)
                {
                    logicList.Offset += 2;
                    // 0 means end of list
                    if (id == 0xffff)
                    {
                        // Change logic data address
                        raw       = _skyCompact.FetchCptRaw(logicList[0]);
                        logicList = new UShortAccess(raw, 0);
                        continue;
                    }

                    _scriptVariables[CUR_ID] = id;
                    _compact = _skyCompact.FetchCpt(id);

                    // check the id actually wishes to be processed
                    if ((_compact.Core.status & (1 << 6)) == 0)
                    {
                        continue;
                    }

                    // ok, here we process the logic bit system

                    if ((_compact.Core.status & (1 << 7)) != 0)
                    {
                        _skyGrid.RemoveObjectFromWalk(_compact);
                    }

                    Debug.Instance.Logic(_compact.Core.logic);
                    _logicTable[_compact.Core.logic]();

                    if ((_compact.Core.status & (1 << 7)) != 0)
                    {
                        _skyGrid.ObjectToWalk(_compact);
                    }

                    // a sync sent to the compact is available for one cycle
                    // only. that cycle has just ended so remove the sync.
                    // presumably the mega has just reacted to it.
                    _compact.Core.sync = 0;
                }
                // usually this loop is run only once, it'll only be run a second time if the game
                // script just asked the user to enter a copy protection code.
                // this is done to prevent the copy protection screen from flashing up.
                // (otherwise it would be visible for 1/50 second)
            } while (CheckProtection());
        }
Ejemplo n.º 2
0
        private void ButtonEngine1()
        {
            //checks for clicking on special item
            //"compare the size of this routine to S1 mouse_button"

            if (_mouseB != 0)
            {
                //anything pressed?
                Logic.ScriptVariables[Logic.BUTTON] = _mouseB;
                if (Logic.ScriptVariables[Logic.SPECIAL_ITEM] != 0)
                {
                    //over anything?
                    var item = _skyCompact.FetchCpt((ushort)Logic.ScriptVariables[Logic.SPECIAL_ITEM]);
                    if (item.Core.mouseClick != 0)
                    {
                        Logic.MouseScript(item.Core.mouseClick, item);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void LoadGrids()
 {
     // no endian conversion necessary as I'm using uint8* instead of uint32*
     for (byte cnt = 0; cnt < TotNoGrids; cnt++)
     {
         _gameGrids[cnt] = _skyDisk.LoadFile(GridFileStart + cnt);
     }
     if (!SkyEngine.IsDemo)
     {
         // single disk demos never get that far
         // Reloading the grids can sometimes cause problems eg when reichs door is
         // open the door grid bit gets replaced so you can't get back in (or out)
         if (_skyLogic.ScriptVariables[Logic.REICH_DOOR_FLAG] != 0)
         {
             RemoveGrid(256, 280, 1, _skyCompact.FetchCpt((ushort)CptIds.ReichDoor20));
         }
         //removeGrid(256, 280, 1, &SkyCompact::reich_door_20);
     }
 }