Digger Icon Digger for .NET

Brian Long (www.blong.com)

A Digger game written in Delphi for .NET

Introduction

This demo is an implementation of the classic Digger game (sometimes known as Boulderdash or Dig Dug).
It was translated to Delphi for .NET by Brian Long (www.blong.com) from the C# implementation by Lutz Roeder (www.aisto.com/roeder/dotnet).
The graphics and levels are taken from the original version by Alexander Lang and Jan Fricke.

Delphi For .NET Details

Changes in the Delphi implementation include:

Concepts Demonstrated

Digger spans several units and demonstrates a number of useful concepts, including:

Points To Note

The Digger source uses conditional compilation through various conditional defines to cater for some features that are currently not working in the preview version of Delphi for .NET and also to show alternative ways of doing things:

Building Digger

You can build Digger in two different ways, depending on whether you want a simple, straightforward compilation, or something slightly more involved and interesting:

  1. The preview version of Delphi for .NET does not currently support linking in managed resources into the executable.
    So the first approach to compiling Digger generates an executable that reads data files from disk (they are expected to be in the current directory).
    Use the BUILD.BAT batch file at the command line to generate this version of Digger.exe.
    BUILD.BAT performs the following steps:

    1. delete any existing copy of Digger.exe
    2. compile a resource script that refers to the application icon (to display in Windows Explorer and on the Task Bar), generating a Win32 resource file
    3. delete command-line configuration file if present (it will be generated if you save the project in the Delphi 7 IDE)
    4. compile the project source files and link in the Win32 icon resource to an executable (Digger.exe)
    5. verify Digger.exe
    6. show a DIR listing of the Digger.exe
    7. launch Digger.exe

    
    *** Deleting old executable (if present) ***
    
    *** Compiling the icon into a resource file ***
    
    Borland Resource Compiler  Version 5.40
    Copyright (c) 1990, 1999 Inprise Corporation.  All rights reserved.
    
    *** Deleting command-line compiler config file (if present) ***
    
    *** Compiling Digger to use external resource files ***
    
    Borland Delphi Version 16.0
    Copyright (c) 1983,2002 Borland Software Corporation
    Confidential pre-release version built Aug  6 2002 14:22:28
    Oblong.Vcl.Controls.pas(42)
    Oblong.Types.pas(27)
    DiggerFont.pas(77)
    DiggerLevel.pas(1157)
    DiggerMainForm.pas(291)
    Digger.dpr(60)
    1660 lines, 0.49 seconds, 23803 bytes code, 0 bytes data.
    
    *** Verifying generated executable ***
    
    Microsoft (R) .NET Framework PE Verifier  Version 1.0.3705.0
    Copyright (C) Microsoft Corporation 1998-2001. All rights reserved.
    
    All Classes and Methods in Digger.exe Verified
    
    *** Showing generated executable details ***
    
     Volume in drive D is DATA
     Volume Serial Number is A43F-3989
    
     Directory of D:\Dev\Delphi.NET\Digger
    
    09/08/2002  11:18               28,672 Digger.exe
                   1 File(s)         28,672 bytes
                   0 Dir(s)     706,592,768 bytes free
    
    *** Launching Digger ***
    
    D:\Dev\Delphi.NET\Digger>
    

  2. The second approach to compiling Digger involves the use of creative round tripping to link the data files into the executable as managed resources.
    This is an interesting process that involves:

    1. Disassembling the executable compiled by Delphi for .NET with the .NET disassembler (ildasm.exe), which produces a CIL (Common Intermediate Language) file with a .IL extension
    2. Modifying the generated IL code, or adding new IL files into the pot
    3. Reassembling the (possibly) modified IL file(s) with the .NET assembler (ilasm.exe) to recreate a new version of the executable

    In this particular case, once Digger.exe has been disassembled to the corresponding Digger.il file, it is reassembled with one additional IL file, DiggerResources.il.
    This is a trivial file that refers to each data file in an appropriate manner to have the assembler link them all as managed resources and looks like this:

    
      .mresource public Level.bin {}  
      .mresource public Font.png {}  
      .mresource public Digger.ico {}  
      .mresource public Sprite.png {}  
    

    Use the BUILD2.BAT batch file at the command line to generate this version of Digger.exe.
    BUILD2.BAT performs the following operations:

    1. delete any existing copy of Digger.exe
    2. compile a resource script that refers to the application icon (to display in Windows Explorer and on the Task Bar), generating a Win32 resource file
    3. delete command-line configuration file if present (it will be generated if you save the project in the Delphi 7 IDE)
    4. compile the project source files and link in the Win32 icon resource to an executable (Digger.exe) with LINK_RESOURCES defined
    5. disassemble Digger.exe to Digger.il
    6. assemble Digger.il and DiggerResources.il to create a new Digger.exe
    7. verify Digger.exe
    8. show a DIR listing of the Digger.exe
    9. launch Digger.exe

    
    *** Deleting old executable (if present) ***
    
    *** Compiling the icon into a resource file ***
    
    Borland Resource Compiler  Version 5.40
    Copyright (c) 1990, 1999 Inprise Corporation.  All rights reserved.
    
    *** Deleting command-line compiler config file (if present) ***
    
    *** Compiling Digger to use linked managed resources ***
    
    Borland Delphi Version 16.0
    Copyright (c) 1983,2002 Borland Software Corporation
    Confidential pre-release version built Aug  6 2002 14:22:28
    Oblong.Vcl.Controls.pas(42)
    Oblong.Types.pas(27)
    DiggerFont.pas(77)
    DiggerLevel.pas(1157)
    DiggerMainForm.pas(291)
    Digger.dpr(60)
    1660 lines, 0.54 seconds, 23891 bytes code, 0 bytes data.
    
    *** Disassembling Digger ***
    
    // WARNING: Created Win32 resource file Digger.res
    
    *** Reassembling Digger with linked resources ***
    
    Assembling 'Digger.IL' , no listing file, to EXE --> 'Digger.EXE'
    Source file is ANSI
    
    
    Assembling 'DiggerResources.IL' , no listing file, to EXE --> 'Digger.EXE'
    Source file is ANSI
    
    Operation completed successfully
    
    *** Verifying generated executable ***
    
    Microsoft (R) .NET Framework PE Verifier  Version 1.0.3705.0
    Copyright (C) Microsoft Corporation 1998-2001. All rights reserved.
    
    All Classes and Methods in Digger.exe Verified
    
    *** Showing generated executable details ***
    
     Volume in drive D is DATA
     Volume Serial Number is A43F-3989
    
     Directory of D:\Dev\Delphi.NET\Digger
    
    09/08/2002  11:19               38,912 Digger.exe
                   1 File(s)         38,912 bytes
                   0 Dir(s)     706,580,480 bytes free
    
    *** Launching Digger ***
    
    D:\Dev\Delphi.NET\Digger>
    


Back to the top of this page