/** procedure CalibrateJoystick; begin Delay (100); WriteLn ('Rotate joystick and press button'); WriteLn ('or press any key to use keyboard...'); Delay (100); Key := #0; repeat Calibrate; Write (#13, 'X = ', Byte (jsRight) - Byte (jsLeft): 2, ' Y = ', Byte (jsDown) - Byte (jsUp): 2); until jsButton1 or jsButton2 or (Key <> #0); WriteLn; if (Key <> #0) then begin jsEnabled := FALSE; ReadJoystick; end; Config.UseJS := jsEnabled; Config.JSDat := jr; Key := #0; end; **/ //------------------------------------------------------------------- // Read the commands given at the command line // args: string[], array of command line arguments //------------------------------------------------------------------- public static void ReadCmdLine(string[] args) { string S; for(int i = 0; i < args.Length; i++) { S = args[i]; while(!string.IsNullOrEmpty(S)) { if(S.Length >= 2 && (S[1] == '/' || S[1] == '-')) { switch(S[2]) { case 'S': Play.Stat = true; break; case 'Q': Buffers.BeeperOff(); break; case 'J': CalibrateJoystick(); break; default: break; } S = S.Remove(1, 2); } else S = S.Remove(1, 1); } } }
//---------------------------------------------------------------- //Method to handle when a coin object is hit //---------------------------------------------------------------- public static void HitCoin(int X, int Y, bool ThrowUp) { int MapX, MapY; MapX = X / Buffers.W; MapY = Y / Buffers.H; if (Buffers.WorldMap[MapX, MapY] == ' ') { return; } if (ThrowUp) { NewTempObj(tpCoin, X, Y - Buffers.H, 0, CoinSpeed, Buffers.W, Buffers.H); } else { Buffers.WorldMap[MapX, MapY] = ' '; Remove(X, Y, Buffers.W, Buffers.H, 0); Glitter.CoinGlitter(X, Y); } Buffers.data.coins[Buffers.Player]++; Buffers.AddScore(50); if (Buffers.data.coins[Buffers.Player] % 100 == 0) { AddLife(); Buffers.data.coins[Buffers.Player] = 0; } }
//------------------------------------------------------------------- // displays the background //------------------------------------------------------------------- public static void ShowTotalBack() { if (Buffers.Passed && CountingScore) { Buffers.Beep(4 * 880); } TotalBackGrAddr[FormMarioPort.formRef.CurrentPage()] = FormMarioPort.formRef.PushBackGr(Buffers.XView + 160, 120, 120, 8); if (Buffers.Passed && CountingScore) { Buffers.Beep(2 * 880); } WriteTotalScore(); if (Buffers.Passed && CountingScore) { Buffers.Beep(0); } }
//------------------------------------------------------------------- // Sets up and reads in a new world to the buffer. After the world // has been read, it will build and then finally start running the // world. // N1: char, the first part (before the hyphen) of the world name. // N2: char, the second part (before the hyphen) of the world name. // Map1: char[,], the map to play // Opt1: WorldOptions, options for the aboveground world of Map1 // Opt1b, WorldOptions, options for the underground world of Map1 // Map2, char[,] the underground of the map to play // Opt2, WorldOptions, options for the abovegound world of Map2 // Opt2b, WorldOptions, options for the underground world of Map2 // Player, byte, the player to put in the world. //------------------------------------------------------------------- public static bool PlayWorld(char N1, char N2, char[,] Map1, Buffers.WorldOptions Opt1, Buffers.WorldOptions Opt1b, char[,] Map2, Buffers.WorldOptions Opt2, Buffers.WorldOptions Opt2b, byte Player) { int j, k, x, y; int[] TotalBackGrAddr = new int[FormMarioPort.MAX_PAGE]; //PlayWorld = false; //Keyboard.Key = 0; //Palettes.ClearPalette(); //Palettes.LockPal(); Buffers.TextCounter = 0; Buffers.WorldNumber = new string[] { N1.ToString(), "-", N2.ToString() }; OnlyDraw = ((N1 == '0') && (N2 == '0')); ShowObjects = true; Players.InPipe = false; Players.PipeCode = new char[] { ' ', ' ' }; Buffers.Demo = Buffers.dmNoDemo; Buffers.InitLevelScore(); //FillChar (TotalBackGrAddr, TotalBackGrAddr.Size(), 0); for (int i = 0; i < TotalBackGrAddr.Length; i++) { TotalBackGrAddr[i] = 0; } ShowScore = false; if (!Enemies.Turbo) { Buffers.ReadWorld(Map2, ref Buffers.WorldMap, Opt2); Buffers.Swap(); Buffers.ReadWorld(Map1, ref Buffers.WorldMap, Opt1); } else { Buffers.ReadWorld(Map2, ref Buffers.WorldMap, Opt2b); Buffers.Swap(); Buffers.ReadWorld(Map1, ref Buffers.WorldMap, Opt1b); } //Console.WriteLine("Done Reading World"); Players.InitPlayer(Buffers.Options.InitX, Buffers.Options.InitY, Buffers.Player); Players.MapX = Buffers.Options.InitX; Players.MapY = Buffers.Options.InitY; Buffers.XView = 0; Buffers.YView = 0; //FillChar (LastXView, LastXView.Size(), 0); for (int i = 0; i < Buffers.LastXView.Length; i++) { Buffers.LastXView[i] = 0; } FormMarioPort.formRef.SetView(Buffers.XView, Buffers.YView); BuildLevel(); try { if (Restart()) { return(true); } } catch (Exception e) { Console.WriteLine("Exception: ", e); } Enemies.ClearEnemies(); //ClearGlitter(); //Palettes.FadeDown(64); //Palettes.ClearPalette(); //Music.StopMusic(); return(false); //http://en.wikipedia.org/wiki/Return_statement#Syntax //"In Pascal there is no return statement." ...wat!? }
//---------------------------------------------------- // Redraw the image described by WorldMap[X, Y] //---------------------------------------------------- public static void Redraw(int X, int Y) { char Ch; Bitmap Fig = null; bool L, R, LS, RS; int XPos, YPos; XPos = X * Buffers.W; YPos = Y * Buffers.H; if (X < 0) { return; } Ch = (char)Buffers.WorldMap[X, Y]; if (X >= 0 && Y >= 0 && Y < Buffers.NV * 2) { if (Ch != (char)0) { if (Ch == '%' && Buffers.Options.Design == 4) { DrawSky(XPos, YPos, Buffers.W, Buffers.H / 2); } else { DrawSky(XPos, YPos, Buffers.W, Buffers.H); } } if (Ch == ' ') { return; } if (Buffers.WorldMap[X, Y] == (char)18) { Fig = FigList[1, 5]; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } switch (Ch) { case (char)1: case (char)2: case (char)3: case (char)4: case (char)5: case (char)6: case (char)7: case (char)8: case (char)9: case (char)10: case (char)11: case (char)12: case (char)13: case (char)14: case (char)15: case (char)16: case (char)17: case (char)18: case (char)19: case (char)20: case (char)21: case (char)22: case (char)23: case (char)24: case (char)25: case (char)26: { if (Ch > (char)13) { Ch -= (char)13; } else { if (Buffers.WorldMap[X, Y + 8] >= 65 && Buffers.WorldMap[X, Y + 8] <= 77) { if (Ch == (char)1 || Ch == (char)4 || Ch == (char)7) { Fig = FigList[1, (int)(Buffers.WorldMap[X, Y + 8]) - 64]; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } else { if (Buffers.WorldMap[X + 2, Y + 8] >= 65 && Buffers.WorldMap[X + 2, Y + 8] <= 77) { if (Ch == (char)3 || Ch == (char)6 || Ch == (char)9) { Fig = FigList[1, (int)(Buffers.WorldMap[X + 2, Y + 8]) - 64]; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } } } Fig = FigList [1, (int)Ch]; if (!(Ch == (char)1 || Ch == (char)3 || Ch == (char)4 || Ch == (char)6 || Ch == (char)7 || Ch == (char)9)) { FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); Fig = null; } break; } case '?': Fig = Resources.QUEST_000; break; case '@': Fig = Resources.QUEST_001; break; case 'A': { L = true; Buffers.WorldMap[X, Y] = 'A'; R = true; Buffers.WorldMap[X + 1, Y] = 'A'; if ((X + Y) % 2 == 1) { RS = true; LS = false; } else { LS = true; RS = false; } if (LS && R) { Fig = Bricks[1]; } else { if (RS && L) { Fig = Bricks[2]; } else { Fig = Bricks[0]; } } break; } case 'I': Fig = Resources.BLOCK_000; break; case 'J': Fig = Resources.BLOCK_001; break; case 'K': Fig = Resources.NOTE_000; break; case 'X': Fig = Resources.XBLOCK_000; break; case 'W': Fig = Resources.WOOD_000; break; case '=': { Fig = Resources.PIN_000; if (Buffers.CanHoldYou((char)Buffers.WorldMap[X, Y + 1])) { FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } else { FormMarioPort.formRef.UpSideDown(XPos, YPos, Buffers.W, Buffers.H, Fig); } // Fig = null; break; } case '0': Fig = Resources.PIPE_000; break; case '1': Fig = Resources.PIPE_001; break; case '2': Fig = Resources.PIPE_002; break; case '3': Fig = Resources.PIPE_003; break; case '*': Fig = Resources.COIN_000; break; case 'þ': { if (Buffers.WorldMap[X, Y - 1] == 'þ') { Fig = Resources.EXIT_001; } else { Fig = Resources.EXIT_000; } break; } case '÷': { if ((Buffers.WorldMap[X, Y - 1] == 'ð') && (Buffers.Options.Design == 2)) { Fig = Resources.SMTREE_001; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } if (Buffers.WorldMap[X, Y - 1] == 'ö') { if (Buffers.Options.Design == 1) { Fig = Resources.WPALM_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } if ((X == 0) || (Buffers.WorldMap[X - 1, Y] == Ch)) { if (Buffers.WorldMap[X + 1, Y] == (byte)Ch) { Fig = Resources.GRASS2_000; } else { Fig = Resources.GRASS3_000; } } else { if (Buffers.WorldMap[X + 1, Y] == Ch) { Fig = Resources.GRASS1_000; } else { Fig = Resources.GRASS3_000; } } break; } case 'ð': { switch (Buffers.Options.Design) { case 1: { if (Buffers.WorldMap[X, Y - 1] != Ch) { Fig = Resources.FENCE_001; } else { Fig = Resources.FENCE_000; } break; } case 2: { if (Buffers.WorldMap[X, Y - 1] != Ch) { Fig = Resources.SMTREE_000; } else { Fig = Resources.SMTREE_001; } break; } } break; } case 'ö': { switch (Buffers.Options.Design) { case 1: Fig = Resources.WPALM_000; break; } break; } case 'ú': { switch (Buffers.Options.Design) { case 1: { if (Buffers.WorldMap[X - 1, Y] == 'ù') { Fig = Resources.PALM3_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } else { if (Buffers.WorldMap[X + 1, Y] == 'ù') { Fig = Resources.PALM1_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } Fig = Resources.PALM0_000; break; } } break; } case 'ô': { switch (Buffers.Options.Design) { case 1: { if (Buffers.WorldMap[X, Y + 1] == 'ö') { Fig = Resources.WPALM_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } Fig = Resources.PALM1_000; break; } } break; } case 'ù': { switch (Buffers.Options.Design) { case 1: Fig = Resources.PALM2_000; break; } break; } case 'õ': { switch (Buffers.Options.Design) { case 1: { if (Buffers.WorldMap[X, Y + 1] == 'ö') { Fig = Resources.WPALM_000; FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } Fig = Resources.PALM3_000; break; } } break; } case '#': { switch (Buffers.Options.Design) { case 1: Fig = Resources.FALL_000; break; case 2: { switch ((char)Buffers.WorldMap[X, Y - 1]) { case '#': FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Resources.TREE_001); break; case '%': { Fig = Resources.TREE_000; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); Fig = Resources.TREE_003; break; } default: Fig = Resources.TREE_003; break; } break; } case 3: Fig = Resources.WINDOW_001; break; case 4: Fig = Resources.LAVA_000; break; case 5: FormMarioPort.formRef.Fill(XPos, YPos, Buffers.W, Buffers.H, 5); break; } break; } case '%': { switch (Buffers.Options.Design) { case 1: Fig = Resources.FALL_001; break; case 2: { switch ((char)Buffers.WorldMap[X, Y - 1]) { case '%': FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Resources.TREE_000); break; case '#': { Fig = Resources.TREE_001; FormMarioPort.formRef.PutImage(XPos, YPos, Buffers.W, Buffers.H, Fig); Fig = Resources.TREE_002; break; } default: Fig = Resources.TREE_002; break; } break; } case 3: Fig = Resources.WINDOW_000; break; case 4: Fig = Resources.LAVA_001; break; case 5: { switch ((X + Buffers.LavaCounter / 8) % 5) { case 0: Fig = Resources.LAVA2_001; break; case 1: Fig = Resources.LAVA2_002; break; case 2: Fig = Resources.LAVA2_003; break; case 3: Fig = Resources.LAVA2_004; break; case 4: Fig = Resources.LAVA2_005; break; } break; } break; } break; } } if (Fig != null) { FormMarioPort.formRef.DrawImage(XPos, YPos, Buffers.W, Buffers.H, Fig); } } }
//------------------------------------------------------------------- // 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; }
//------------------------------------------------------------------- // Sets up and reads in a new world to the buffer. After the world // has been read, it will build and then finally start running the // world. // N1: char, the first part (before the hyphen) of the world name. // N2: char, the second part (before the hyphen) of the world name. // Map1: char[,], the map to play // Opt1: WorldOptions, options for the aboveground world of Map1 // Opt1b, WorldOptions, options for the underground world of Map1 // Map2, char[,] the underground of the map to play // Opt2, WorldOptions, options for the abovegound world of Map2 // Opt2b, WorldOptions, options for the underground world of Map2 // Player, byte, the player to put in the world. //------------------------------------------------------------------- public static bool PlayWorld(char N1, char N2, char[,] Map1, Buffers.WorldOptions Opt1, Buffers.WorldOptions Opt1b, char[,] Map2, Buffers.WorldOptions Opt2, Buffers.WorldOptions Opt2b, byte Player) { int j, k, x, y; int[] TotalBackGrAddr = new int[FormMarioPort.MAX_PAGE]; //PlayWorld = false; //Keyboard.Key = 0; FormMarioPort.formRef.SetYOffset(YBase);//FormMarioPort.formRef.Y); FormMarioPort.formRef.SetYStart (18); FormMarioPort.formRef.SetYEnd (125); //Palettes.ClearPalette(); //Palettes.LockPal(); FormMarioPort.formRef.ClearVGAMem(); Buffers.TextCounter = 0; Buffers.WorldNumber = new string[] {N1.ToString(), "-", N2.ToString()}; OnlyDraw = ((N1 == '0') && (N2 == '0')); ShowObjects = true; Players.InPipe = false; Players.PipeCode = new char[] { ' ', ' '}; Buffers.Demo = Buffers.dmNoDemo; Buffers.InitLevelScore(); //FillChar (TotalBackGrAddr, TotalBackGrAddr.Size(), 0); for (int i = 0; i < TotalBackGrAddr.Length; i++) TotalBackGrAddr[i] = 0; ShowScore = false; if (! Enemies.Turbo) { Buffers.ReadWorld (Map2, ref Buffers.WorldMap, Opt2); Buffers.Swap(); Buffers.ReadWorld (Map1, ref Buffers.WorldMap, Opt1); } else { Buffers.ReadWorld (Map2, ref Buffers.WorldMap, Opt2b); Buffers.Swap(); Buffers.ReadWorld (Map1, ref Buffers.WorldMap, Opt1b); } //Console.WriteLine("Done Reading World"); Players.InitPlayer (Buffers.Options.InitX, Buffers.Options.InitY, Buffers.Player); Players.MapX = Buffers.Options.InitX; Players.MapY = Buffers.Options.InitY; Buffers.XView = 0; Buffers.YView = 0; //FillChar (LastXView, LastXView.Size(), 0); for (int i = 0; i < Buffers.LastXView.Length; i++) Buffers.LastXView[i] = 0; FormMarioPort.formRef.SetView (Buffers.XView, Buffers.YView); BuildLevel(); Restart(); FormMarioPort.formRef.SetYOffset(YBase); Enemies.ClearEnemies(); //ClearGlitter(); //Palettes.FadeDown(64); //Palettes.ClearPalette(); FormMarioPort.formRef.ClearVGAMem(); //Music.StopMusic(); return false; //http://en.wikipedia.org/wiki/Return_statement#Syntax //"In Pascal there is no return statement." ...wat!? }
//------------------------------------------------- // Check the player for actions //------------------------------------------------- private static void Check() { bool Small; NewCh1 = ' '; NewCh2 = ' '; NewCh3 = ' '; Side = System.Convert.ToByte(XVel > 0) * (Buffers.W - 1); NewX1 = (X + Side) / Buffers.W; NewX2 = (X + Side + XVel) / Buffers.W; Small = Buffers.data.mode[Buffers.Player] == Buffers.mdSmall; if (NewX1 != NewX2) { Y1 = (Y + HSafe + (4)) / Buffers.H - Safe; Y2 = (Y + HSafe + Buffers.H) / Buffers.H - Safe; Y3 = (Y + HSafe + 2 * Buffers.H - 1) / Buffers.H - Safe; // Hack to fix negative Y Y1 = Y1 < 0 ? 1 : Y1; Y2 = Y2 < 0 ? 1 : Y2; Y3 = Y3 < 0 ? 1 : Y3; NewCh1 = (char)Buffers.WorldMap[NewX2, Y1]; NewCh2 = (char)Buffers.WorldMap[NewX2, Y2]; NewCh3 = (char)Buffers.WorldMap[NewX2, Y3]; if (NewCh3 == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, Y3 * Buffers.H, false); } if (NewCh2 == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, Y2 * Buffers.H, false); } else if (NewCh2 == 'z') { Enemies.Turbo = true; } if (!Small && NewCh1 == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, Y1 * Buffers.H, false); } Hold1 = (Buffers.CanHoldYou(NewCh1)) && (!Small); Hold2 = (Buffers.CanHoldYou(NewCh2)); Hold3 = (Buffers.CanHoldYou(NewCh3)); if (Hold1 || Hold2 || Hold3) { XVel = 0; Walkingmode = 0; } } NewX1 = (X + XVel) / Buffers.W; NewX2 = (X + XVel + Buffers.W - 1) / Buffers.W; if (Enemies.cdEnemy != 0) { CheckJump(); } if ((Status == stJumping)) { NewY = (Y + 1 + (4) + (Buffers.H - 1 - (4)) * Convert.ToByte(Small) + YVel + HSafe) / Buffers.H - Safe; } else { NewY = (Y + 1 + 2 * Buffers.H + YVel + HSafe) / Buffers.H - Safe; } if (NewY < 0) { NewY = 12; Y = 12; } NewCh1 = (char)Buffers.WorldMap[NewX1, NewY]; NewCh2 = (char)Buffers.WorldMap[NewX2, NewY]; NewCh3 = (char)Buffers.WorldMap[(X + XVel + Buffers.W / 2) / Buffers.W, NewY]; Hold1 = (Buffers.CanHoldYou(NewCh1) || Buffers.CanStandOn(NewCh1)); Hold2 = (Buffers.CanHoldYou(NewCh2) || Buffers.CanStandOn(NewCh2)); Hold3 = (Buffers.CanHoldYou(NewCh3) || Buffers.CanStandOn(NewCh3)); switch (Status) { case stFalling: { CheckFall(); break; } case stOnTheGround: { if ((Enemies.cdLift == 0)) { if (!(Hold1 || Hold2)) { Status = stFalling; if (Math.Abs(XVel) < 2) { Y++; } } else { if ((NewCh1 == 'K') || (NewCh2 == 'K')) { CheckFall(); } else { if (XVel == 0) { Below1 = NewCh1; Below2 = NewCh2; MapX = NewX1; //Codes for pipes MapY = NewY - 1; AtCh1 = (char)Buffers.WorldMap[MapX, MapY]; AtCh2 = (char)Buffers.WorldMap[MapX + 1, MapY]; Mo = (X + XVel) % Buffers.W; if (!Hold1 && (Mo >= 1 && Mo <= 5)) { XVel--; } if (!Hold2 && (Mo >= Buffers.W - 5 && Mo <= Buffers.W - 1)) { XVel++; } } } CheckJump(); } } else { YVel = Enemies.PlayerYVel; CheckJump(); } break; } case stJumping: { Hold1 = (Buffers.CanHoldYou(NewCh1) || Buffers.CanStandOn(NewCh1)); Hold2 = (Buffers.CanHoldYou(NewCh2) || Buffers.CanStandOn(NewCh2)); Hold3 = (Buffers.CanHoldYou(NewCh3) || Buffers.CanStandOn(NewCh3)); Hit = (Hold1 || Hold2); if (Hit) { Mo = (X + XVel) % Buffers.W; if ((Mo >= 1 && Mo <= 4 && Mo >= Buffers.W - 4 && Mo <= Buffers.W - 1) && (!Hold3)) { if (!((NewCh1 == Buffers.Hidden) && (NewCh2 == Buffers.Hidden))) { Hit = false; } if ((Mo < Buffers.W / 2) && (!(NewCh2 == Buffers.Hidden))) { X -= Mo; } else if ((Mo >= Buffers.W / 2) && (!(NewCh1 == Buffers.Hidden))) { X += Buffers.W - Mo; } } } if (!Hit) { if (NewCh1 == '*') { TmpObj.HitCoin(NewX1 * Buffers.W, NewY * Buffers.H, false); } if (NewCh1 == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, NewY * Buffers.H, false); } if ((Counter % (JumpDelay + Convert.ToByte(HighJump)) == 0) || ((!keyAlt) && (!HitEnemy))) { YVel++; } if (YVel >= 0) { YVel = 0; Status = stFalling; } } else { char Ch = (char)0; if (Mo >= 0 && Mo <= (Buffers.W / 2 - 1)) { if (Buffers.CanHoldYou(NewCh1) || Buffers.CanStandOn(NewCh1)) { Ch = NewCh1; NewX2 = NewX1; } else { Ch = NewCh2; } } else if (Mo >= (Buffers.W / 2) && Mo <= Buffers.W - 1) { Ch = NewCh2; if (!(Buffers.CanHoldYou(Ch) || Ch == Buffers.Hidden)) { Ch = NewCh1; NewX2 = NewX1; } } switch (Ch) { case '=': Enemies.cdHit = 1; break; case '0': case '1': if (keyUp) { CheckPipeAbove(NewCh1, NewCh2); } break; case '?': case '$': case 'J': case 'K': { Mo = 0; if (Buffers.WorldMap[NewX2, NewY - 1] >= 'à' && Buffers.WorldMap[NewX2, NewY - 1] <= 'â') { Buffers.WorldMap[NewX2, NewY] = '?'; Ch = '?'; } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'ï') { Buffers.WorldMap[NewX2, NewY] = 'K'; Ch = 'K'; } else { if (!Small && (Ch == 'J')) { TmpObj.BreakBlock(NewX2, NewY); Buffers.AddScore(10); Mo = 1; } } if (Mo == 0) { Blocks.BumpBlock(NewX2 * Buffers.W, NewY * Buffers.H); //Beep (110 ); } if (Buffers.WorldMap[NewX2, NewY - 1] >= 'ã' && Buffers.WorldMap[NewX2, NewY - 1] <= 'ì') { if (!(Ch == 'J' || Ch == 'K')) { TmpObj.HitCoin(NewX2 * Buffers.W, NewY * Buffers.H, true); if (Buffers.WorldMap[NewX2, NewY - 1] != ' ') { Buffers.WorldMap[NewX2, NewY - 1] = (char)(Buffers.WorldMap[NewX2, NewY - 1] + 1); if (Buffers.WorldMap[NewX2, NewY] == '$') { TmpObj.Remove(NewX2 * Buffers.W, NewY * Buffers.H, Buffers.W, Buffers.H, 2); Buffers.WorldMap[NewX2, NewY] = '?'; } } } } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'à') { if (Buffers.data.mode[Buffers.Player] == Buffers.mdSmall) { Enemies.NewEnemy(EnemyType.tpRisingChamp, 0, NewX2, NewY, 0, -1, 2); } else { Enemies.NewEnemy(EnemyType.tpRisingFlower, 0, NewX2, NewY, 0, -1, 2); } } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'á') { Enemies.NewEnemy(EnemyType.tpRisingLife, 0, NewX2, NewY, 0, -1, 2); } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'â') { Enemies.NewEnemy(EnemyType.tpRisingStar, 0, NewX2, NewY, 0, -1, 1); } else if (Buffers.WorldMap[NewX2, NewY - 1] == '*') { TmpObj.HitCoin(NewX2 * Buffers.W, (NewY - 1) * Buffers.H, false); } else if (Buffers.WorldMap[NewX2, NewY - 1] == 'í') { Enemies.NewEnemy(EnemyType.tpRisingChamp, 1, NewX2, NewY, 0, -1, 2); } Enemies.HitAbove(NewX2, NewY - 1); if (Ch == 'K') { TmpObj.Remove(NewX2 * Buffers.W, NewY * Buffers.H, Buffers.W, Buffers.H, TmpObj.tpNote); Buffers.WorldMap[NewX2, NewY] = 'K'; } else { if (Ch != 'J') { if (!(Buffers.WorldMap[NewX2, NewY - 1] >= 'ã' && Buffers.WorldMap[NewX2, NewY - 1] <= 'ì')) { TmpObj.Remove(NewX2 * Buffers.W, NewY * Buffers.H, Buffers.W, Buffers.H, 1); Buffers.WorldMap[NewX2, NewY] = '@'; } } } break; } default: //Beep (30); break; } if ((Ch != 'J') || (Buffers.data.mode[Buffers.Player] == Buffers.mdSmall)) { YVel = 0; Status = stFalling; } if (Ch == 'K') { YVel = 3; } } break; } } }