Go to Gplex Database Home
 Gplex iPhone Software
  Gplex The Legned
  Gplex InfoStore
  About Us
  Gplex Database

 

 

Want a free promo code to play the game?
Just email us and we'll send you one.
admin@gplexdb.com
(while supplies last)

Step 2: Try to get 500 points and collect the key to proceed to the next level 2


Step 3: TTry to get 500 points and collect the key to proceed to the next level 3


When the person hold the phone against their ear a funny sound is played. Loads of fun at home or at the office

 

The Legend is a Wolfenstein-3D dervied game.  The code base that was distributed by id software.

I changed the buffer for the sound and maybe commented a thing here or there... but mostly changed all the assets to give it more modern look.

Added floor and ceilig textures in the new update v2.0 - The latest code is posted below.

Here is the code has required by GPL. wolf3d2.zip
The code will be posted here under the GPL license as released by id software (thanks to id for contibuting so much).

Convert .5551 to PNG

So the first step in figuring out was converting the data that .5551 format to something I could see. So I found a sample on www.codeproject.com a sample that was using a RAW file to convert it to a BMP. The orignal code with my modifications is posted here. I looked at how the code was reading the .5551 file and that is what I duplicated here and ignored portions that were fluff in the header (probably needed but not for my purpose). Here is the entire project using Visual Studio 2008ImageDraw.zip
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; // Program to display a 16-bit raw image file. // Written by Amarnath S, Bangalore, India, December 2008. namespace ImageDraw { /// /// Summary description for Form1. /// /// It is assumed that the pixels comprising the image are stored /// from left to right, and top to bottom, as unsigned short values. /// It is also assumed that the width and height of the image are /// identical, so that the image dimensions can be computed by just /// using the square root function. /// The algorithm is briefly as follows: /// 1. Read the raw image file and store the pixel values into an /// ArrayList called pixel16. /// 2. Create a bitmap of the required dimensions. Create the bitmap /// with the pixel format of Format24bppRgb, and set the red, green /// and blue colors to be identical, since the images are grayscale. /// Scale the 16-bit grayscale interval of 0 - 65535 to an 8-bit /// interval of 0 - 255, since each color is represented by 8 bits. /// Use the BitmapData class to populate the bitmap pixel values /// from the abovementioned pixel16 array list. Use LockBits and /// UnlockBits appropriately. Display the image. It is also /// possible to use SetPixel to set the values, but this method /// is painfully slow compared to what is used here. /// 3. Override Paint to draw the image. /// /// Compile with the unsafe flag on. /// public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Panel panelImage; private System.Windows.Forms.Button bnOpenImage; private ArrayList pixels16; // To hold the pixel data Graphics g; // Graphics of the panel object int width, height; // Dimensions of the bitmap Bitmap bmp; private Button button1; // Bitmap object /// /// Required designer variable. /// private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // pixels16 = new ArrayList(); g = panelImage.CreateGraphics(); } /// /// Clean up any resources being used. /// protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.bnOpenImage = new System.Windows.Forms.Button(); this.panelImage = new System.Windows.Forms.Panel(); this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // bnOpenImage // this.bnOpenImage.Location = new System.Drawing.Point(8, 8); this.bnOpenImage.Name = "bnOpenImage"; this.bnOpenImage.Size = new System.Drawing.Size(88, 56); this.bnOpenImage.TabIndex = 0; this.bnOpenImage.Text = "Open Raw Image"; this.bnOpenImage.Click += new System.EventHandler(this.bnOpenImage_Click); // // panelImage // this.panelImage.Location = new System.Drawing.Point(104, 8); this.panelImage.Name = "panelImage"; this.panelImage.Size = new System.Drawing.Size(512, 512); this.panelImage.TabIndex = 2; // // button1 // this.button1.Location = new System.Drawing.Point(12, 173); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 3; this.button1.Text = "button1"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(624, 530); this.Controls.Add(this.button1); this.Controls.Add(this.panelImage); this.Controls.Add(this.bnOpenImage); this.Name = "Form1"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Display 16-bit Raw Image Files"; this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint); this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing); this.ResumeLayout(false); } #endregion /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new Form1()); } // Open the Raw image file for reading. private void bnOpenImage_Click(object sender, System.EventArgs e) { pixels16.Clear(); OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "All Files(*.*)|*.*"; ofd.Multiselect = true; ofd.ShowDialog(); if (ofd.FileName.Length > 0) { ReadImageFile(ofd.FileName); CreateBitmap(); //CreateBitmapOnFly(); Invalidate(); } ofd.Dispose(); } private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if (pixels16.Count > 0) g.DrawImage(bmp, 0, 0); } private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e) { bmp.Dispose(); pixels16.Clear(); } private void ReadImageFile(string fileName) { BinaryReader br = new BinaryReader(File.Open(fileName, FileMode.Open)); ushort s; int i = 0; long iTotalSize = br.BaseStream.Length; int hasAlpha = br.ReadInt32(); i += 4; int srcWidth = br.ReadInt32(); i += 4; int srcHeight = br.ReadInt32(); i += 4; int w = br.ReadInt32(); i += 4; width = w; int h = br.ReadInt32(); i += 4; height = h; int numBounds = br.ReadInt32(); i += 4; int l = 0; int[, ,] bounds = new int[2, 2, 2]; bounds[0, 0, 0] = br.ReadInt32(); i += 4; bounds[0, 0, 1] = br.ReadInt32(); i += 4; bounds[0, 1, 0] = br.ReadInt32(); i += 4; bounds[0, 1, 1] = br.ReadInt32(); i += 4; bounds[1, 0, 0] = br.ReadInt32(); i += 4; bounds[1, 0, 1] = br.ReadInt32(); i += 4; bounds[1, 1, 0] = br.ReadInt32(); i += 4; bounds[1, 1, 1] = br.ReadInt32(); i += 4; for (; i < iTotalSize; i += 2) { s = (ushort)br.ReadInt16(); pixels16.Add(s); } br.Close(); width = srcWidth; // (int)(Math.Sqrt(pixels16.Count)); height = srcHeight; // width; } // Create the Bitmap object and populate its pixel data with the stored pixel values. private void CreateBitmap() { bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData bmd = bmp.LockBits(new Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat); // This 'unsafe' part of the code populates the bitmap bmp with data stored in pixel16. // It does so using pointers, and therefore the need for 'unsafe'. unsafe { int pixelSize = 4; int i, j, j1, i1; byte b; ushort sVal; double lPixval; for (i = 0; i < bmd.Height; ++i) { byte* row = (byte*)bmd.Scan0 + (i * bmd.Stride); i1 = i * bmd.Height; for (j = 0; j < bmd.Width; ++j) { sVal = (ushort)(pixels16[i1 + j]); lPixval = (sVal / 255.0); // Convert to a 255 value range if (lPixval > 255) lPixval = 255; if (lPixval < 0) lPixval = 0; b = (byte)(lPixval); j1 = j * pixelSize; uint iVal = (uint)sVal; uint red = (uint)(iVal & 0xF800); // high 5 bits of RGB uint green = (uint)(iVal & 0x07C0); uint blue = (uint)(iVal & 0x003E); uint alpha = (uint)(iVal & 0x0001); // high 1 bit of A red = (ushort)(red >> 11); green = (ushort)(green >> 6); blue = (ushort)(blue >> 1); red *= 8; green *= 8; blue *= 8; alpha *= 255; row[j1] = (byte)(blue); // Red row[j1 + 1] = (byte)(green); // Green row[j1 + 2] = (byte)(red); // Blue //if (blue == 0 && green == 0 && red == 0) alpha = 0; else alpha = 255; row[j1 + 3] = (byte)(alpha); } } } bmp.UnlockBits(bmd); bmp.Save("c:\\face.png"); } private void CreateBitmap(string newfilename) { bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); BitmapData bmd = bmp.LockBits(new Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadOnly, bmp.PixelFormat); // This 'unsafe' part of the code populates the bitmap bmp with data stored in pixel16. // It does so using pointers, and therefore the need for 'unsafe'. unsafe { int pixelSize = 4; int i, j, j1, i1; byte b; ushort sVal; double lPixval; for (i = 0; i < bmd.Height; ++i) { byte* row = (byte*)bmd.Scan0 + (i * bmd.Stride); i1 = i * bmd.Height; for (j = 0; j < bmd.Width; ++j) { sVal = (ushort)(pixels16[i1 + j]); lPixval = (sVal / 255.0); // Convert to a 255 value range if (lPixval > 255) lPixval = 255; if (lPixval < 0) lPixval = 0; b = (byte)(lPixval); j1 = j * pixelSize; uint iVal = (uint)sVal; uint red = (uint)(iVal & 0xF800); // high 5 bits of RGB uint green = (uint)(iVal & 0x07C0); uint blue = (uint)(iVal & 0x003E); uint alpha = (uint)(iVal & 0x0001); // high 1 bit of A red = (ushort)(red >> 11); green = (ushort)(green >> 6); blue = (ushort)(blue >> 1); red *= 8; green *= 8; blue *= 8; alpha *= 255; row[j1] = (byte)(blue); // Red row[j1 + 1] = (byte)(green); // Green row[j1 + 2] = (byte)(red); // Blue //row[j1 + 3] = c2.A; //if (blue == 0 && green == 0 && red == 0) alpha = 0; else alpha = 255; row[j1 + 3] = (byte)(alpha); //row[j1] = (byte)(0); // Red //row[j1 + 1] = (byte)(0); // Green //row[j1 + 2] = (byte)(0); // Blue ////row[j1 + 3] = c2.A; ////if (blue == 0 && green == 0 && red == 0) alpha = 0; else alpha = 255; //row[j1 + 3] = (byte)(0); } } } bmp.UnlockBits(bmd); bmp.Save(newfilename); } private void button1_Click(object sender, EventArgs e) { foreach (string file in Directory.GetFiles(@".", "*.5551")) { pixels16.Clear(); ReadImageFile(file); // figure out the new file name char[] charperiod = { '.' }; int fLen = file.Length; int indexOfPeriod = file.LastIndexOf('.'); string newfile = file.Substring(0, indexOfPeriod); newfile += ".png"; CreateBitmap(newfile); bmp.Dispose(); } } } }

Convert PNG to TGA

The 2nd part of the puzzle was converting the PNG to a TGA format that the game engine could acutally read. For that I just got lucky when I googled png to tga. The code was very cool and it worked... The code was compiled using Microsoft Visual Studio 2005.
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.IO; using System.Diagnostics; // Credits: // Creating TGA Image files Written by Paul Bourke // http://local.wasp.uwa.edu.au/~pbourke/dataformats/tga/ // CxImage By Davide Pizzolato. // http://www.codeproject.com/bitmap/cximage.asp namespace png32totga { class Program { static void Main(string[] args) { //if (args.Length != 2) //{ // Console.Error.WriteLine("png32totga "); // Environment.Exit(1); //} foreach (string file in Directory.GetFiles(@".", "*.png")) { //File.Delete(file); using (Bitmap picin = (Bitmap)Bitmap.FromFile(file)) { // figure out the new file name char[] charsToTrim = { '.', 'p', 'n', 'g' }; string newfile = file.TrimEnd(charsToTrim); newfile += ".tga"; using (FileStream fs = File.Create(newfile)) { BinaryWriter wr = new BinaryWriter(fs); wr.Write((byte)0); // IdLength wr.Write((byte)0); // CmapType wr.Write((byte)10); // ImageType ... TGA_RLERGB 10 wr.Write((UInt16)0); // CmapIndex wr.Write((UInt16)0); // CmapLength wr.Write((byte)0); // CmapEntrySize wr.Write((UInt16)0); // X_Origin wr.Write((UInt16)0); // Y_Origin wr.Write(Convert.ToUInt16(picin.Width)); // ImageWidth wr.Write(Convert.ToUInt16(picin.Height)); // ImageHeight wr.Write((byte)32); // PixelDepth wr.Write((byte)0); // ImagDesc int cx = picin.Width; int cy = picin.Height; int maxpos = picin.Width * picin.Height; PacketRaw pktraw = new PacketRaw(); for (int pos = 0; pos < maxpos; ) { Color clr = picin.GetPixel(pos % cx, cy - 1 - pos / cx); int t = 1; for (; t < 128 && t + pos < maxpos && clr == picin.GetPixel((pos + t) % cx, cy - 1 - (pos + t) / cx); t++) ; if (1 < t) { // RLE Ut.WritePacket(wr, pktraw); pktraw = new PacketRaw(); Ut.WritePacket(wr, new PacketRLE(clr, (byte)t)); pos += t; } else { // Raw if (pktraw.pixels.Count == 128) { Ut.WritePacket(wr, pktraw); pktraw = new PacketRaw(); } pktraw.pixels.Add(clr); pos += t; } } Ut.WritePacket(wr, pktraw); } } } } } class Ut { public static void Write32(BinaryWriter fs, Color clr) { fs.Write((byte)clr.B); fs.Write((byte)clr.G); fs.Write((byte)clr.R); fs.Write((byte)clr.A); } public static void WritePacket(BinaryWriter wr, PacketRaw o) { if (o.pixels.Count != 0) { if (o.pixels.Count > 128) throw new ArgumentOutOfRangeException("o"); wr.Write((byte)(o.pixels.Count - 1)); foreach (Color clr in o.pixels) Ut.Write32(wr, clr); } } public static void WritePacket(BinaryWriter wr, PacketRLE o) { if (o.cnt != 0) { if (o.cnt > 128) throw new ArgumentOutOfRangeException("o"); wr.Write((byte)(128 | (o.cnt - 1))); Ut.Write32(wr, o.clr); } } } class PacketRaw { public List pixels = new List(); } class PacketRLE { public Color clr; public byte cnt; public PacketRLE(Color clr, byte cnt) { this.clr = clr; this.cnt = cnt; } } }

Getting new art work

The final part is that art work is not easy to create on your own so again I googled and I recommend these sites. So after you have the art work you have to use a tool like 3D Studio Max and create png images for the frames in the different angles that you will need and want. There are some good tutorials to generate png's from the 3D models.

New maps

When wolfenstein was on the PC there were a lof fan who created some very cool program. One such program is called NMAP -- this allows you to create new maps that the game uses. NMAP run on Windows XP just great, but if you have Windows Vista then you'll need DOSBOX (and they do have a Mac version of DOSBOX as well).
NMAP - Wolfenstein Map Editor Dosbox

 

Call or email for help!
Email | help@gplexdb.com


 

2007 Gplex Database -  About Gplex Database