Exemplo n.º 1
0
        //----------------------------------------------------------------
        //Method that does a series of removes
        //----------------------------------------------------------------
        public static void RunRemove()
        {
            int i;

            for (i = 0; i < MaxRemove; i++)
            {
                if (RemList[i].Active == true)
                {
                    switch (RemList[i].NewImage)
                    {
                    case 0:
                        BackGr.DrawBackGrBlock(RemList[i].RemX, RemList[i].RemY, RemList[i].RemW, RemList[i].RemH);
                        break;

                    case 1:
                        FormMarioPort.formRef.DrawImage(RemList[i].RemX, RemList[i].RemY, RemList[i].RemW, RemList[i].RemH, Resources.QUEST_001);
                        break;

                    case 2:
                        FormMarioPort.formRef.DrawImage(RemList[i].RemX, RemList[i].RemY, RemList[i].RemW, RemList[i].RemH, Resources.QUEST_000);
                        break;

                    case 5:
                        FormMarioPort.formRef.DrawImage(RemList[i].RemX, RemList[i].RemY, RemList[i].RemW, RemList[i].RemH, Resources.NOTE_000);
                        break;
                    }
                    RemList[i].RemCount--;
                    if (RemList[i].RemCount < 1)
                    {
                        RemList[i].Active = false;
                    }
                }
            }
        }
Exemplo n.º 2
0
        //-----------------------------------------------------
        // Draw the current scene to the form, then cycle
        // through all game elements to update image
        //-----------------------------------------------------
        public void PaintForm()
        {
            graphics.DrawImage(screenBmp, 0, 0, screenBmp.Width * 2, screenBmp.Height * 2);

            Graphics g = Graphics.FromImage(screenBmp);

            g.Clear(Color.LightBlue);

            Figures.DrawSky(Buffers.XView, 0, Buffers.NH * Buffers.W, Buffers.NV * Buffers.H);

            //BackGr.StartClouds();

            for (int x = Buffers.XView / Buffers.W; x < Buffers.XView / Buffers.W + Buffers.NH; x++)
            {
                for (int y = 0; y < 24; y++)
                {
                    Figures.Redraw(x, y);
                }
            }

            BackGr.DrawBackGr(true);
            //ReadColorMap();

            if (Buffers.Options.Stars != 0)
            {
                Stars.ShowStars();
            }

            Enemies.ShowEnemies();

            if (!Play.OnlyDraw)
            {
                Players.DrawPlayer();
            }

            // ShowPage
        }
Exemplo n.º 3
0
        //-------------------------------------------------------------------
        // Builds the level from the using the already initialized buffers
        //-------------------------------------------------------------------
        static void BuildLevel()
        {
            Figures.InitSky(Buffers.Options.SkyType);
            Figures.InitWalls(Buffers.Options.WallType1, Buffers.Options.WallType2, Buffers.Options.WallType3);
            //This loop draws the ground on the Menu screen only
            for (int i = 0; i < Buffers.NH; i++)
            {
                for (int j = 0; j < Buffers.NV; j++)
                {
                    if (j == (Buffers.NV - 1))
                    {
                        FormMarioPort.formRef.DrawImage(i * Buffers.W, j * Buffers.H, Buffers.W, Buffers.H, Resources.GREEN_001);
                    }
                }
            }
            Figures.InitPipes(Buffers.Options.PipeColor);
            BackGr.InitBackGr(Buffers.Options.BackGrType, Buffers.Options.Clouds);
            if (Buffers.Options.Stars != 0)
            {
                Stars.InitStars();
            }

            Figures.BuildWorld();
        }
Exemplo n.º 4
0
        //-------------------------------------------------------------------
        // main loop of the world to handle drawing, hiding, and showing of the
        // resources. When mario runs out of lives the thread is killed and cleaned
        // up. read: GAME OVER!
        //-------------------------------------------------------------------
        static bool Restart()
        {
            bool PlayWorld = false;

            TextStatus = false;
            //InitStatus();

            Blocks.InitBlocks();
            TmpObj.InitTempObj();
            Glitter.ClearGlitter();
            Enemies.ClearEnemies();

            // ShowPage

            Buffers.GameDone = false;
            Buffers.Passed   = false;

            for (int i = Enemies.StartEnemiesAt * -1; i < Buffers.NH + Enemies.StartEnemiesAt; i++)
            {
                int j = (Buffers.XView / Buffers.W) + i;
                Enemies.StartEnemies(j, (short)(1 - 2 * System.Convert.ToByte(j > Players.MapX)));
            }

            //   SetYOffset (YBase);

            /*for (int i = 0; i < FormMarioPort.MAX_PAGE; i++)
             * {
             * //      DrawSky (XView, 0, NH * W, NV * H);
             *
             * //      StartClouds();
             *
             * for (int x = Buffers.XView / Buffers.W; x < Buffers.XView / Buffers.W + Buffers.NH; x++)
             *    for (int y = 0; y < Buffers.NV - 1; y++)
             *       Figures.Redraw(x, y);
             *
             * BackGr.DrawBackGr(true);
             * //ReadColorMap();
             *
             * if (Buffers.Options.Stars != 0)
             *    Stars.ShowStars();
             *
             * Enemies.ShowEnemies();
             * if (!OnlyDraw)
             *    Players.DrawPlayer();
             *
             * FormMarioPort.formRef.ShowPage();
             * }
             */

            Buffers.Demo = Buffers.dmNoDemo;
            Waiting      = false;

            //Palettes.NewPalette (P256*);
            //for (int i = 1; i < 100; i++)
            //{
            //Waterfalls()?
            //Palettes.BlinkPalette();
            //}

            Figures.SetSkyPalette();
            BackGr.DrawPalBackGr();
            //Palettes.InitGrass();

            if (OnlyDraw)
            {
                return(false);
            }

            //   Palettes.UnLockPal();
            //   FadeUp (64);
            //   Palettes.ReadPalette (Palette);

            TextStatus = Stat;// && !KeyBoard.PlayingMacro());

            //uint counter = 0;
            do //until gamedone
            {
                try
                {
                    //Console.WriteLine("Restart Loop");

                    //if (!Keyboard.PlayingMacro)
                    //{
                    //   if (Key = 31) //'S'
                    //   {
                    //      Stat = !Stat;
                    //      TextStatus = Stat;
                    //      Keyboard.Key = 255;
                    //   }
                    //   if (Keyboard.Key = 16) //'Q'
                    //   {
                    //      if (Buffers.BeeperSound)
                    //         Buffers.BeeperOff();
                    //      else
                    //      {
                    //         Buffers.BeeperOn();
                    //         Buffers.Beep (80);
                    //      }
                    //      Key = 255;
                    //   }

                    //   if (Key == 197 || Key == 198) //Pause/Break
                    //   {
                    //      Music.PauseMusic();
                    //      //do
                    //      //{
                    //      //   while (Keyboard.Key = 197) {} //busy wait of some sort?
                    //      //} while //(Keyboard.kbHit);
                    //   }
                    //   else
                    //   {
                    //      if (Keyboard.Key != 0)
                    //      {
                    //         Buffers.GameDone = true;
                    //         Buffers.Passed = true;
                    //      }
                    //   }

                    //   if (Buffers.TextCounter) //in 40..40+MAX_PAGE
                    //      ShowObjects = false;

                    //   HideGlitter();
                    //   if (Options.Stars != 0)
                    //      HideStars();
                    //   if (ShowObjects)
                    //      HideTempObj();
                    //   if (ShowScore)
                    //      HideTotalBack();
                    //   ErasePlayer();
                    //   if (ShowObjects)
                    //   {
                    //      HideEnemies();
                    //      EraseBlocks();
                    //   }
                    //}

                    // { Fade };
                    Buffers.LavaCounter++;

                    if (!Waiting)
                    {
                        if (Buffers.Demo == Buffers.dmNoDemo)
                        {
                            Enemies.MoveEnemies();
                            Players.MovePlayer();
                        }
                        else
                        {
                            Players.DoDemo();
                        }
                    }



                    if (!Waiting)
                    {
                        if (Buffers.Passed)
                        {
                            if (Buffers.Demo == Buffers.dmNoDemo || Players.InPipe)
                            {
                                Waiting             = true;
                                Buffers.TextCounter = 0;
                            }
                            Buffers.TextCounter++;
                            if (!ShowScore && (Buffers.TextCounter >= 50 && Buffers.TextCounter < 50 + FormMarioPort.MAX_PAGE)) //in 50..50 + MAX_PAGE
                            {
                                //SetFont (0, Bold + Shadow);
                                //TXT.CenterText (20, Buffers.PlayerName [Buffers.Player], 30.ToString("X"));
                                //SetFont(1, Bold + Shadow);
                                //TXT.CenterText (40, "STAGE CLEAR!", 31);
                                if (Buffers.TextCounter == (50 + FormMarioPort.MAX_PAGE))
                                {
                                    ShowScore = true;
                                }
                            }
                        }
                        else
                        if (Buffers.GameDone)
                        {
                            Buffers.data.lives[Buffers.Player]--;
                            Buffers.data.mode[Buffers.Player] = Buffers.mdSmall;
                            Buffers.TextCounter = 0;
                            Buffers.data.score[Buffers.Player] += Buffers.LevelScore;
                            Waiting          = true;
                            Buffers.GameDone = false;
                        }
                    }



                    //if (Keyboard.Key = 25) //P
                    //   Pause();

                    if (ShowScore && (Buffers.TextCounter == 120) && (Buffers.LevelScore > 0))
                    {
                        int i = (int)(Buffers.LevelScore - 50);
                        if (i < 0)
                        {
                            i = 0;
                        }
                        Buffers.data.score[Buffers.Player] += Buffers.LevelScore - 1;
                        Buffers.LevelScore  = i;
                        Buffers.TextCounter = 119;
                        CountingScore       = true;
                    }
                    else
                    {
                        CountingScore = false;
                    }

                    if (Waiting)
                    {
                        Buffers.TextCounter++;
                        if (Buffers.data.lives[Buffers.Player] == 0)
                        {
                            if (Buffers.TextCounter >= 100 && Buffers.TextCounter < 100 + FormMarioPort.MAX_PAGE) //in 100..100 + MAX_PAGE
                            {
                                //SetFont (0, Bold + Shadow);
                                //CenterText (20, Buffers.PlayerName[Buffers.Player], 30.ToString("X"));
                                //SetFont (1, Bold + Shadow);
                                //CenterText (40, "GAME OVER", 31);
                                ShowScore = true;
                            }
                            if (Buffers.TextCounter > 350)
                            {
                                Buffers.GameDone = true;
                            }
                        }
                        else
                        if (Buffers.Passed)
                        {
                            if (Buffers.TextCounter > 250)
                            {
                                Waiting = false;
                            }
                        }
                        else
                        if (Buffers.TextCounter > 100)
                        {
                            Buffers.GameDone = true;
                        }
                    }

                    TmpObj.MoveTempObj();
                    Blocks.MoveBlocks();

                    if (Keyboard.kbEsc)
                    {
                        Buffers.QuitGame = true;
                    }

                    MoveScreen();
                    TmpObj.RunRemove();

                    if (Buffers.Options.Horizon < Buffers.NV)
                    {
                        int j = Buffers.Options.Horizon;
                        for (int i = 0 / Buffers.W; i < Buffers.NH; i++)
                        {
                            int k = Buffers.XView / Buffers.W + (i + Buffers.LavaCounter / 8) % (Buffers.NH + 1);
                            if (Buffers.WorldMap[k, j] == '%')
                            {
                                Figures.Redraw(k, j);
                            }
                        }
                    }


                    //FormMarioPort.formRef.ResetStack();

                    if (ShowObjects)
                    {
                        Blocks.DrawBlocks();
                        Enemies.ShowEnemies();
                    }
                    Players.DrawPlayer();

                    if (ShowScore)
                    {
                        ShowTotalBack();
                    }
                    //if (TextStatus)
                    //   Status.ShowStatus();
                    if (ShowObjects)
                    {
                        TmpObj.ShowTempObj();
                    }
                    if (Buffers.Options.Stars != 0)
                    {
                        Stars.ShowStars();
                    }
                    Glitter.ShowGlitter();

                    Buffers.LastXView[FormMarioPort.formRef.CurrentPage()] = Buffers.XView;

                    //if (ShowRetrace)
                    //   SetPalette(0, 0, 0, 0);

                    // ShowPage

                    //if (ShowRetrace)
                    //   SetPalette( 0, 63, 63, 63);

                    BackGr.DrawPalBackGr();

                    //Palette.BlinkPalette();

                    Music.PlayMusic();

                    if (Players.InPipe && Keyboard.PlayingMacro)
                    {
                        Buffers.GameDone = true;
                    }


                    if (Players.InPipe && !Buffers.GameDone && !Waiting)
                    {
                        Enemies.StopEnemies();
                        Glitter.ClearGlitter();
                        //FadeDown(64);
                        //FormMarioPort.formRef.LockPal();
                        //FormMarioPort.formRef.ClearVGAMem();

                        switch (Players.PipeCode[1])
                        {
                        case 'à':
                            FindPipeExit();
                            //Delay(100);
                            break;

                        case 'á':
                            //Swap();
                            FindPipeExit();
                            break;

                        case 'ç':
                            Buffers.GameDone = true;
                            PlayWorld        = true;
                            break;
                        }

                        Players.InitPlayer(Players.MapX * Buffers.W + Buffers.W / 2, (Players.MapY - 1) * Buffers.H, Buffers.Player);

                        FormMarioPort.formRef.SetView(Buffers.XView, Buffers.YView);

                        for (int i = 0; i < FormMarioPort.MAX_PAGE; i++)
                        {
                            Buffers.LastXView[i] = Buffers.XView;
                        }

                        if (Players.PipeCode[1] == 'à')
                        {
                            Restart();
                        }
                        else
                        if (Players.PipeCode[1] == 'á')
                        {
                            BuildLevel();
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("error" + e);
                }

                FormMarioPort.formRef.PaintForm();
                System.Threading.Thread.Sleep(1 / 60 * 1000);
            } while (!Buffers.GameDone && !Buffers.QuitGame);
            return(PlayWorld);
        }
Exemplo n.º 5
0
        //-------------------------------------------------------------------
        // Scrolls the screen to move along with mario as he moves.
        //-------------------------------------------------------------------
        public static void MoveScreen()
        {
            int    Scroll;
            int    N1, N2;
            int    OldX, NewX, Page;
            Random rand = new Random();

            Page   = FormMarioPort.formRef.CurrentPage();
            Scroll = Buffers.XView - Buffers.LastXView[Page];
            if (!Players.EarthQuake)
            {
                FormMarioPort.formRef.SetView(Buffers.XView, Buffers.YView);
            }
            else
            {
                Players.EarthQuakeCounter++;
                if (Players.EarthQuakeCounter > 0)
                {
                    Players.EarthQuake = false;
                }
                int Rand1 = rand.Next(0, 2);
                int Rand2 = rand.Next(0, 2);
                FormMarioPort.formRef.SetView(Buffers.XView, Buffers.YView + Rand1 - Rand2);
            }
            if (Scroll < 0)
            {
                Enemies.StartEnemies((Buffers.XView / Buffers.W) - Enemies.StartEnemiesAt, 1);
            }
            else if (Scroll > 0)
            {
                Enemies.StartEnemies((Buffers.XView / Buffers.W) + Buffers.NH + Enemies.StartEnemiesAt, -1);
            }

            int i = Buffers.Options.Horizon;

            BackGr.DrawBackGr(false);
            Buffers.Options.Horizon = (byte)i;

            if (Scroll > 0)
            {
                for (int j = Buffers.LastXView[Page]; j < Buffers.XView; j++)
                {
                    i = j - Buffers.W - Buffers.W;
                    if (i >= 0)
                    {
                        FormMarioPort.formRef.PutPixel(i, 0, 0);
                    }
                    i = Buffers.W - j % Buffers.W - 1;
                    Figures.Redraw(j / Buffers.W + Buffers.NH + 1, i);
                }
            }

            if (Scroll < 0)
            {
                for (int j = Buffers.LastXView[Page]; j > Buffers.XView; j--)
                {
                    i = Buffers.W - j % Buffers.W - 1;
                    Figures.Redraw(j / Buffers.W - 1, i);
                }
            }
        }
Exemplo n.º 6
0
        //----------------------------------------------------
        // Draw the sky
        //----------------------------------------------------
        public static void DrawSky(int X, int Y, int W, int H)
        {
            int Y1    = 0;
            int Y2    = Y1 + 96;
            int YStep = (Y2 - Y1) / 16; // { = 6 }

            int    i, j, k;             // Integer;
            ushort Mix;                 //: Word;

            if (Buffers.Options.BackGrType == 0)
            {
                FormMarioPort.formRef.Fill(X, Y, Buffers.W, Buffers.H, 0xE0);
            }
            else
            {
                switch (Sky)
                {
                case 0:
                case 1:
                case 3:
                case 4:
                {
                    i = Buffers.Options.Horizon;
                    j = i - Y;
                    if (i < Y)
                    {
                        FormMarioPort.formRef.Fill(X, Y, Buffers.W, Buffers.H, 0xF0);
                    }
                    else
                    if (i > Y + Buffers.H - 1)
                    {
                        FormMarioPort.formRef.Fill(X, Y, Buffers.W, Buffers.H, 0xE0);
                    }
                    else
                    {
                        FormMarioPort.formRef.Fill(X, Y, Buffers.W, j, 0xE0);
                        FormMarioPort.formRef.Fill(X, i, Buffers.W, Buffers.H - j, 0xF0);
                    }
                    break;
                }

                case 2:
                case 5:
                case 9:
                case 10:
                case 11:
                case 12:
                    BackGr.SmoothFill(X, Y, Buffers.W, Buffers.H);
                    break;

                case 6:
                case 7:
                case 8:
                {
                    switch (Buffers.Options.BackGrType)
                    {
                    case 4: BackGr.DrawBricks(X, Y, Buffers.W, Buffers.H); break;

                    case 5: BackGr.LargeBricks(X, Y, Buffers.W, Buffers.H); break;

                    case 6: BackGr.Pillar(X, Y, Buffers.W, Buffers.H); break;

                    case 7: BackGr.Windows(X, Y, Buffers.W, Buffers.H); break;
                    }
                    break;
                }
                }
            }
        }
Exemplo n.º 7
0
      //-------------------------------------------------------------------
      // starts up mario with the menu, if a specific amount of time passes
      // the demo will play until the user presses any key and stops the demo
      //-------------------------------------------------------------------
      public static void Intro()
      {
         int i = 0, j = 0;
         Status = Statuses.ST_NONE;
         Statuses OldStatus = Statuses.ST_NONE;
         Statuses LastStatus = Statuses.ST_NONE;
         string[] Menu = new String[5];
         uint[,] BG = new uint[FormMarioPort.MAX_PAGE + 1, 5];

         //nested procedures
         Page = (byte)FormMarioPort.formRef.CurrentPage();
         Status = Statuses.ST_NONE;
         TestVGAMode = false;
         GameNumber = -1;
         NextNumPlayers = Buffers.data.numPlayers;

         do //until IntroDone and (not TestVGAMode);
         {
            //if(FormMarioPort.formRef.TestVGAMode)
            //   FormMarioPort.InitVGA();
            TestVGAMode = false;
            IntroDone = false;
            NewData();

            Play.PlayWorld('0', '0', Worlds.Intro_0(), Worlds.Options_0(), Worlds.Options_0(),
                    Worlds.Intro_0(), Worlds.Options_0(), Worlds.Options_0(), Buffers.plMario);
            BackGr.InitBackGr(3, 0);

            //Palettes.OutPalette(0xA0, 35, 45, 50);
            //Palettes.OutPalette(0xA1, 45, 55, 60);

            //Palettes.OutPalette(0xEF, 30, 40, 30);
            //Palettes.OutPalette(0x18, 10, 15, 25);

            //Palettes.OutPalette(0x8D, 28, 38, 50);
            //Palettes.OutPalette(0x8F, 40, 50, 63);

            //for(int i = 1; i < 50; i++)
            //   Palettes.BlinkPalette();

            for(int p = 0; p < FormMarioPort.MAX_PAGE; p++)
            {
               for( i = 1; i >= 0; i--)
                  for( j = 1; j >= 0; j--)
                     for(int k = 1; k >= 0; k--)
                     {
                        FormMarioPort.formRef.DrawImage(38 + i + j, 29 + i + k, 108, 28, Resources.INTRO_000);
                        FormMarioPort.formRef.DrawImage(159 + i + j, 29 + i + k, 24, 28, Resources.INTRO_001);
                        FormMarioPort.formRef.DrawImage(198 + i + j, 29 + i + k, 84, 28, Resources.INTRO_002);
                     }
               BackGr.DrawBackGrMap(10 * Buffers.H + 6, 11 * Buffers.H - 1, 54, 0xA0);
               BackGr.DrawBackGrMap(10 * Buffers.H + 6, 11 * Buffers.H - 1, 55, 0xA1);
               BackGr.DrawBackGrMap(10 * Buffers.H + 6, 11 * Buffers.H - 1, 53, 0xA1);
               for( i = 0; i < Buffers.NH + 1; i++)
                  for( j = 0; j < Buffers.NV + 1; j++)
                     if((i == 0 || i == Buffers.NH - 1) || (j == 0 || j == Buffers.NV))
                        FormMarioPort.formRef.DrawImage(i * Buffers.W, j * Buffers.H, Buffers.W, Buffers.H, Resources.BLOCK_000);
               Players.DrawPlayer();

               FormMarioPort.formRef.PaintForm();
            }
            //UnlockPal();
            //Keyboard.Key = 0;
            //FadeUp(64);
            //ResetStack();

            //FillChar(BG, BG.Size(), 0);
            //FillChar(Menu, Menu.Size(), 0);
            //SetFont(0, Bold + Shadow);

            if(Status != Statuses.ST_OPTIONS)
            {
               OldStatus = Statuses.ST_NONE;
               LastStatus = Statuses.ST_NONE;
               Status = Statuses.ST_MENU;
               Selected = 1;
            }
            UpDate = true;
            Counter = 1;

            do //until IntroDone or (Counter = WAIT_BEFORE_DEMO);
            {
               if (UpDate || Status != OldStatus)
               {
                  if (Status != OldStatus)
                     Selected = 1;
                  switch (Status)
                  {
                     case Statuses.ST_MENU:
                        Menu[0] = "START";
                        Menu[1] = "OPTIONS";
                        Menu[2] = "END";
                        Menu[3] = "";
                        Menu[4] = "";
                        NumOptions = 3;
                        LastStatus = Statuses.ST_MENU;
                        break;
                     case Statuses.ST_OPTIONS:
                        if (Buffers.BeeperSound)
                           Menu[0] = "SOUND ON ";
                        else
                           Menu[0] = "SOUND OFF";
                        if (Play.Stat)
                           Menu[1] = "STATUSLINE OFF";
                        else
                           Menu[1] = "STATUSLINE OFF";
                        Menu[2] = "";
                        Menu[3] = "";
                        Menu[4] = "";
                        NumOptions = 2;
                        LastStatus = Statuses.ST_MENU;
                        break;
                     case Statuses.ST_START:
                        Menu[0] = "NO SAVE";
                        Menu[1] = "GAME SELECT";
                        Menu[2] = "ERASE";
                        Menu[3] = "";
                        Menu[4] = "";
                        NumOptions = 3;
                        LastStatus = Statuses.ST_MENU;
                        break;
                     case Statuses.ST_NUMPLAYERS:
                        Menu[0] = "ONE PLAYER";
                        Menu[1] = "TWO PLAYERS";
                        Menu[2] = "";
                        Menu[3] = "";
                        Menu[4] = "";
                        NumOptions = 3;
                        LastStatus = Statuses.ST_MENU;
                        break;
                     case Statuses.ST_LOAD:
                     case Statuses.ST_ERASE:
                        Menu[0] = "GAME #1 " + 7 + " ";
                        Menu[1] = "Game #2 " + 7 + " ";
                        Menu[2] = "Game #3 " + 7 + " ";
                        Menu[3] = "";
                        Menu[4] = "";

                        for ( i = 0; i < 3; i++)
                           if (Config.Games[i].progress[Buffers.plMario] == 0 &&
                              Config.Games[i].progress[Buffers.plLuigi] == 0)
                              Menu[i] = Menu[i] + "EMPTY";
                           else
                           {
                              m = Config.Games[i].progress[Buffers.plMario];
                              n = Convert.ToInt32((Config.Games[i].progress[CurPlayer] >= NUM_LEV));
                              if (n > 0)
                                 m -= NUM_LEV;
                              if (Config.Games[i].progress[Buffers.plLuigi] > m)
                              {
                                 m = Config.Games[i].progress[Buffers.plLuigi];
                                 Config.Games[i].progress[Buffers.plMario] = m;
                              }
                              Menu[i] = Menu[i] + "LEVEL " + (char)(m +
                                      Convert.ToInt32(Encoding.ASCII.GetBytes("0")) + 1) + " ";
                              if (n == 0)
                                 Menu[i] = Menu[i] + 7 + " ";
                              else
                                 Menu[i] = Menu[i] + "* ";
                              Menu[i] = Menu[i] + (char)(Config.Games[i].numPlayers +
                                      Convert.ToInt32(Encoding.ASCII.GetBytes("0"))) + 'P';
                           }
                        NumOptions = 3;
                        LastStatus = Statuses.ST_START;
                        break;
                     default:
                        break;
                  }
                  wd = 0;
                  xp = 0;

                  for ( i = 0; i < 5; i++)
                  {
                      j = TXT.TextWidth(Menu[i]);
                     if (j > wd)
                     {
                        wd = j;
                        //xp = CenterX(Menu[i]) / 4 * 4;
                     }
                     ht = 8;
                  }
                  OldStatus = Status;
                  UpDate = false;
               }
               MacroKey = '0';
               
                  if ( Keyboard.kbEsc)
                     if (Status == Statuses.ST_MENU)
                     {
                        IntroDone = true;
                        Buffers.QuitGame = true;
                     }
                     else
                        Status = LastStatus;

                  if ( Keyboard.kbUpArrow )
                     Up();

                  if ( Keyboard.kbDownArrow )
                     Down();

                  if ( Keyboard.kbSP || Keyboard.kbEnter )
                     switch (Status)
                     {
                        case Statuses.ST_MENU:
                           switch (Selected)
                           {
                              case 1:
                                 Status = Statuses.ST_START;
                                 break;
                              case 2:
                                 Status = Statuses.ST_OPTIONS;
                                 break;
                              case 3:
                                 IntroDone = true;
                                 Buffers.QuitGame = true;
                                 break;
                           }
                           break;
                        case Statuses.ST_START:
                           switch (Selected)
                           {
                              case 1:
                                 Status = Statuses.ST_NUMPLAYERS;
                                 break;
                              case 2:
                                 Status = Statuses.ST_LOAD;
                                 break;
                              case 3:
                                 Status = Statuses.ST_ERASE;
                                 break;
                           }
                           break;
                        case Statuses.ST_OPTIONS:
                           switch (Selected)
                           {
                              case 1:
                                 if (Buffers.BeeperSound)
                                    Buffers.BeeperOff();
                                 else
                                    Buffers.BeeperOn();
                                 break;
                              case 2:
                                 Play.Stat = !Play.Stat;
                                 break;
                           }
                           break;
                        case Statuses.ST_NUMPLAYERS:
                           switch (Selected)
                           {
                              case 1:
                                 NextNumPlayers = 1;
                                 IntroDone = true;
                                 break;
                              case 2:
                                 NextNumPlayers = 2;
                                 IntroDone = true;
                                 break;
                           }
                           break;
                        case Statuses.ST_LOAD:
                           GameNumber = Selected - 1;
                           Config.Games[GameNumber].numPlayers = 1;
                           if (Config.Games[GameNumber].progress[Buffers.plMario] == 0 &&
                                    Config.Games[GameNumber].progress[Buffers.plLuigi] == 0)
                              Status = Statuses.ST_NUMPLAYERS;
                           else
                           {
                              IntroDone = true;
                              NextNumPlayers = Config.Games[GameNumber].numPlayers;
                           }
                           break;
                        case Statuses.ST_ERASE:
                           NewData();
                           Config.Games[Selected - 1] = Buffers.data;
                           Config.Games[Selected - 1].numPlayers = 1;
                           GameNumber = -1;
                           break;
                     }

               //if(Keyboard.Key != 0)
               //{
               //   Counter = 0;
               //   Keyboard.Key = MacroKey;
               //   UpDate = true;
               //}

               for(int k = 0; k < 5; k++)
               {
                  if(BG[Page, k] != 0)
                     FormMarioPort.formRef.PopBackGr((ushort)BG[Page, k]);
               }

               for(int k = 0; k < 5; k++)
               {
                  if(Menu[k] != "")
                  {
                     m = xp;
                     n = 56 + 14 * k;
                     BG[Page, k] = FormMarioPort.formRef.PushBackGr(50, j, 220, ht);
                     if (k == Selected)
                        ;//TXT.WriteText(i - 12, j, 16, 5);
                     l = 15;
                     if(Menu[k].Length > 19 && Menu[k][10] == '*')
                        //l := 14 + (Counter and 1);
                        l = 14 + (Counter & l);
                     //SetPalette(14, 63, 61, 31);
                     //TXT.WriteText(i + 8, j, Menu[k], l);
                  }
               }
               // ShowPage
               //Palettes.BlinkPalette();

               System.Threading.Thread.Sleep(10);
               Counter++;
            } while(!IntroDone && Counter != WAIT_BEFORE_DEMO);

            //FadeDown(64);

            if(!IntroDone)
               Demo();
         } while(!IntroDone || TestVGAMode);

         if(GameNumber != -1)
            Buffers.data = Config.Games[GameNumber];

         Config.Games[Config.Games.Length - 1].numPlayers = NextNumPlayers;
      }