示例#1
0
        public bool Identify(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);

            if (stream.Length < 512)
            {
                return(false);
            }

            byte[] test = new byte[512];
            stream.Read(test, 0, 512);

            return(Apple2.IsApple2GCR(test));
        }
 void Start()
 {
     Timer = SpawnTimer;
     //disables all menus needed not needed at start
     ExitMenu.enabled       = false;
     MainGUI.enabled        = false;
     InGameExitMenu.enabled = false;
     GameOverGUI.enabled    = false;
     DirectionsGUI.enabled  = false;
     //disables all objects not needed at start
     Player.SetActive(false);
     Apple1.SetActive(false);
     Apple2.SetActive(false);
     Apple3.SetActive(false);
     QuitYes.SetActive(false);
     //sets game score to 0
     GameScore = 0;
     // recalls high score info for display at start screen
     HighScore1.text = "HighScore: " + PlayerPrefs.GetString("HighScoreName").ToString() + " - " + ((int)PlayerPrefs.GetFloat("HighScore")).ToString();
 }
 public void StartGame()
 {
     // resets till death count just in case
     TillDeath = 3;
     // calls player high score from previous game to be displayed on player gui
     HighScore.text = "HighScore: " + PlayerPrefs.GetString("HighScoreName").ToString() + " - " + ((int)PlayerPrefs.GetFloat("HighScore")).ToString();
     // start game bool toggle
     GameStart = !GameStart;
     //Makes the start menu go away
     StartGUI.enabled = false;
     MainGUI.enabled  = true;
     //locks the cursor to the game window...or supposed to...havent tested this as i have not tried a build yet.
     Cursor.lockState = CursorLockMode.Confined;
     //hides the cursor so we dont have to look at its ugly self :-)
     Cursor.visible = false;
     // enables the player and his/her/it's lives
     Player.SetActive(true);
     Apple1.SetActive(true);
     Apple2.SetActive(true);
     Apple3.SetActive(true);
 }
示例#4
0
    void Start()
    {
        //Notice here how the variable "myFruit" is of type
        //Fruit but is being assigned a reference to an Apple. This
        //works because of Polymorphism. Since an Apple is a Fruit,
        //this works just fine. While the Apple reference is stored
        //in a Fruit variable, it can only be used like a Fruit
        Fruit2 myFruit = new Apple2();

        myFruit.SayHello();
        myFruit.Chop();

        //This is called downcasting. The variable "myFruit" which is
        //of type Fruit, actually contains a reference to an Apple. Therefore,
        //it can safely be turned back into an Apple variable. This allows
        //it to be used like an Apple, where before it could only be used
        //like a Fruit.
        Apple2 myApple = (Apple2)myFruit;

        myApple.SayHello();
        myApple.Chop();
    }
示例#5
0
文件: Read.cs 项目: morefun0302/Aaru
        public bool Open(IFilter imageFilter)
        {
            Stream stream = imageFilter.GetDataForkStream();

            stream.Seek(0, SeekOrigin.Begin);

            if (stream.Length < 512)
            {
                return(false);
            }

            byte[] buffer = new byte[stream.Length];
            stream.Read(buffer, 0, buffer.Length);

            AaruConsole.DebugWriteLine("Apple NIB Plugin", "Decoding whole image");
            List <Apple2.RawTrack> tracks = Apple2.MarshalDisk(buffer);

            AaruConsole.DebugWriteLine("Apple NIB Plugin", "Got {0} tracks", tracks.Count);

            Dictionary <ulong, Apple2.RawSector> rawSectors = new Dictionary <ulong, Apple2.RawSector>();

            int  spt            = 0;
            bool allTracksEqual = true;

            for (int i = 1; i < tracks.Count; i++)
            {
                allTracksEqual &= tracks[i - 1].sectors.Length == tracks[i].sectors.Length;
            }

            if (allTracksEqual)
            {
                spt = tracks[0].sectors.Length;
            }

            bool skewed = spt == 16;

            ulong[] skewing = _proDosSkewing;

            // Detect ProDOS skewed disks
            if (skewed)
            {
                foreach (Apple2.RawSector sector in tracks[17].sectors)
                {
                    if (!sector.addressField.sector.SequenceEqual(new byte[]
                    {
                        170, 170
                    }))
                    {
                        continue;
                    }

                    byte[] sector0 = Apple2.DecodeSector(sector);

                    if (sector0 == null)
                    {
                        continue;
                    }

                    bool isDos = sector0[0x01] == 17 && sector0[0x02] < 16 && sector0[0x27] <= 122 &&
                                 sector0[0x34] == 35 && sector0[0x35] == 16 && sector0[0x36] == 0 && sector0[0x37] == 1;

                    if (isDos)
                    {
                        skewing = _dosSkewing;
                    }

                    AaruConsole.DebugWriteLine("Apple NIB Plugin", "Using {0}DOS skewing",
                                               skewing.SequenceEqual(_dosSkewing) ? "" : "Pro");
                }
            }

            for (int i = 0; i < tracks.Count; i++)
            {
                foreach (Apple2.RawSector sector in tracks[i].sectors)
                {
                    if (skewed && spt != 0)
                    {
                        ulong sectorNo = (ulong)((((sector.addressField.sector[0] & 0x55) << 1) |
                                                  (sector.addressField.sector[1] & 0x55)) & 0xFF);

                        AaruConsole.DebugWriteLine("Apple NIB Plugin",
                                                   "Hardware sector {0} of track {1} goes to logical sector {2}",
                                                   sectorNo, i, skewing[sectorNo] + (ulong)(i * spt));

                        rawSectors.Add(skewing[sectorNo] + (ulong)(i * spt), sector);
                        _imageInfo.Sectors++;
                    }
                    else
                    {
                        rawSectors.Add(_imageInfo.Sectors, sector);
                        _imageInfo.Sectors++;
                    }
                }
            }

            AaruConsole.DebugWriteLine("Apple NIB Plugin", "Got {0} sectors", _imageInfo.Sectors);

            AaruConsole.DebugWriteLine("Apple NIB Plugin", "Cooking sectors");

            _longSectors   = new Dictionary <ulong, byte[]>();
            _cookedSectors = new Dictionary <ulong, byte[]>();
            _addressFields = new Dictionary <ulong, byte[]>();

            foreach (KeyValuePair <ulong, Apple2.RawSector> kvp in rawSectors)
            {
                byte[] cooked = Apple2.DecodeSector(kvp.Value);
                byte[] raw    = Apple2.MarshalSector(kvp.Value);
                byte[] addr   = Apple2.MarshalAddressField(kvp.Value.addressField);
                _longSectors.Add(kvp.Key, raw);
                _cookedSectors.Add(kvp.Key, cooked);
                _addressFields.Add(kvp.Key, addr);
            }

            _imageInfo.ImageSize            = (ulong)imageFilter.GetDataForkLength();
            _imageInfo.CreationTime         = imageFilter.GetCreationTime();
            _imageInfo.LastModificationTime = imageFilter.GetLastWriteTime();
            _imageInfo.MediaTitle           = Path.GetFileNameWithoutExtension(imageFilter.GetFilename());

            if (_imageInfo.Sectors == 455)
            {
                _imageInfo.MediaType = MediaType.Apple32SS;
            }
            else if (_imageInfo.Sectors == 560)
            {
                _imageInfo.MediaType = MediaType.Apple33SS;
            }
            else
            {
                _imageInfo.MediaType = MediaType.Unknown;
            }

            _imageInfo.SectorSize   = 256;
            _imageInfo.XmlMediaType = XmlMediaType.BlockMedia;
            _imageInfo.ReadableSectorTags.Add(SectorTagType.FloppyAddressMark);

            switch (_imageInfo.MediaType)
            {
            case MediaType.Apple32SS:
                _imageInfo.Cylinders       = 35;
                _imageInfo.Heads           = 1;
                _imageInfo.SectorsPerTrack = 13;

                break;

            case MediaType.Apple33SS:
                _imageInfo.Cylinders       = 35;
                _imageInfo.Heads           = 1;
                _imageInfo.SectorsPerTrack = 16;

                break;
            }

            return(true);
        }