• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Gavin Williams

Small application / exe

10 posts in this topic

This is a follow-on from a question i posted on [url="http://stackoverflow.com/questions/8790923"]stackoverflow.[/url] I'm looking at how demo coders prepare small applications, with the intention to make the smallest SlimDX application that I can. I managed to make a window application using C++ with a size of 4096 bytes. But there doesn't seem to be a way to include a static library into C# code, and my goal is to create a single file package. Using Assembly I have created a window application with a size of 2,560 bytes, but I haven't yet looked at making a library using assembly. And I would have the same problem there being unable to incorporate it into a C# Assembly.

When I create the smallest C# application that I can (code following) I get an exe size of 6,144 bytes. Is this the smallest C# application that one can build ? I don't really know anything about CLR under the hood, except that it creates like a CLR-machine language version of the app that is compiled into machine code (first run or every run). Does anyone have any ready hints at the issues I'm facing, even just some reading material on solving this problem would be good. I have seen SlimDX demos but they are large (>100k), seemingly the only small demos are written using C++. but certainly small SlimDX apps can be build, I'm just not sure how small ?

[CODE]
namespace CreateWindowUsingMiniWindowLib
{
static class Program
{
static int Main()
{
return 42;
}
}
}
[/CODE]
0

Share this post


Link to post
Share on other sites
If you need C#, couldn't you cheat with a small C/C++/assembler application (with appropriate linking tricks) that writes out C# sources (with compression and code generation) to temporary files, compiles them and runs them?
0

Share this post


Link to post
Share on other sites
I don't think there's any chance of using SlimDX for a 4k intro, assuming you want to get it past the rules for say [url="http://www.assembly.org/summer11/compos/realtime/demo#4k"]Assembly[/url]. The problem is that SlimDX needs a DLL as well as the exe.

If you want to get your C++ exe smaller, try http://crinkler.net/
0

Share this post


Link to post
Share on other sites
Thanks for that, I didn't know about Assembly.org, that's great. I have my C++ exe down to 3,584 bytes now, and haven't tried anything like Crinkler yet. So I'm getting there. Reading about the PE/COFF file formats at the moment (exciting stuff ;P) Im thinking I'll work out how to put together some direct x, coz I want to use this little file. I don't know if referencing SlimDX dlls would be a problem as the same has to be done with directX (doesn't it ?). And presumably SlimDX could be considered system software as much as DX. But until I learn more on how the .NET file format works, and code-generation options, it's not an option for 4k.
0

Share this post


Link to post
Share on other sites
[quote name='Gavin Williams' timestamp='1326199966' post='4901279']
Thanks for that, I didn't know about Assembly.org, that's great. I have my C++ exe down to 3,584 bytes now, and haven't tried anything like Crinkler yet. So I'm getting there. Reading about the PE/COFF file formats at the moment (exciting stuff ;P) Im thinking I'll work out how to put together some direct x, coz I want to use this little file. I don't know if referencing SlimDX dlls would be a problem as the same has to be done with directX (doesn't it ?). And presumably SlimDX could be considered system software as much as DX. But until I learn more on how the .NET file format works, and code-generation options, it's not an option for 4k.
[/quote]
Well the wikipedia page on sharpdx tells you he wanted to create a slimdx version that didnt need C++/CLI for API calls to direct3d apis.
0

Share this post


Link to post
Share on other sites
Smallest possible valid PE executable is between [url="http://www.phreedom.org/solar/code/tinype/"]97 and 133 bytes[/url]. So even in C++ you have long way to go from 2.5k.

C# cannot be used for this purpose since it uses CLR. If one used Java, then there could be one single .class file, no dlls or anything. While small, it relies on the 100MB+ VM just to start. If anything, it might be acceptable if one were to strip out everything possible, but that would still leave tens of megabytes.

DX features used are part of HAL, so they are essentially drivers. They are also standardized and typically used for shaders only.

Using C# for demo-like projects also doesn't bring any benefits. There is no C# or even C++ code in such projects. They are just a loader for shaders. So there's a stub which does the minimum a runnable app needs to do, initializes the DX, then passes the big shader text file to it and that's it.


If doing CPU code, then assembly is where it's at. While no longer useful for general programming, compilers today can be beaten hard by someone with adequate knowledge. Especially when optimizing for size (the extreme type), there are plenty of tools compilers simply do not make use of, especially on newer CPUs with abundance of registers.
1

Share this post


Link to post
Share on other sites
[quote name='Gavin Williams' timestamp='1326173578' post='4901196']But there doesn't seem to be a way to include a static library into C# code, and my goal is to create a single file package.[/quote]
You can merge multiple assemblies into one using one of these tools:
[url="http://code.google.com/p/il-repack/"]http://code.google.com/p/il-repack/[/url]
[url="http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx"]http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx[/url]

Not sure if they work C++/CLI. If not, then another option would be swap SlimDX with SharpDX. The latter is pure C# library.
0

Share this post


Link to post
Share on other sites
@[b]NightCreature83 @Martins Mozeiko - I don't understand how C# can be independant of CLI (CLR specifically), isn't it a CLR language. So isn't all C# code compiled to CLI/CLR.[/b]

[b]Let me describe how i currently 'think' of the difference between SlimDX and SharpDX : SlimDX uses System.Runtime.InteropServices to Import the C++ dll's from DirectX, in the normal way that I might access a C++ native function. While SharpDX uses a special magic source concocted at 4am by some crazed demo coder who knew there was a faster way to do this !! This might not be exactly correct, but I'm sure it's close to the mark.[/b]
0

Share this post


Link to post
Share on other sites
C# is compiled to IL, not CLI/CLR (that's different concept).
C++/CLI is compiled to IL, or native code, or both of them (in mixed assemblies)

And that's not entirely correct regarding SlimDX vs SharpDX.
They both call com methods directly - only difference is that SlimDX is calling them through C++/CLI using calli, but SharpDX using calli IL instruction in pure C# - in generated IL asm instructions look very alike for both of them. SlimDX2 will be very similar in SharpDX in this matter.
0

Share this post


Link to post
Share on other sites
@Martins Mozeiko - thanks for those links, which led me to finding this article on [url="http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx"]imbedding dlls into the assembly as a resource[/url] !
0

Share this post


Link to post
Share on other sites
Well compared to C/C++/native world, that is more like embedding dll file in your exe file, and then loading this dll file from memory, instead of disk. Of course that also works, not really efficient, but works.
Using Mono.Linker/il-repack/ilmerge is much better, imho.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0