2014
10-05

how to create 1KB exe for demoscene (start for 1KB or 4KB intro)

Here is instruction how to make very small *.exe file with simple animation.
1. Create empty win32 project in visual studio 2012.
2. Place crinkler in solution directory. Rename it to link.exe.
3. Go to Project options, VC++ Directories, Executable Directories, and add $(SolutionDir) at top of tle list.
4. Change Properites, General, Character Set to Not set.
5. Turn off whole code optimalization.
6. Go to Properities, Linker, Advenced, Entry Point and set it to string "winmain".
7. Go to Properites / Linker / Command line and add /CRINKLER to command line.
8. Add empty cpp file. Put ther that code:
  1.  
  2. #define WIN32_LEAN_AND_MEAN
  3. #define WIN32_EXTRA_LEAN
  4. #include <windows.h>
  5. #define XRES 1920
  6. #define YRES 1080
  7. static const BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER),XRES,-YRES,1,32,BI_RGB,0,0,0,0,0},{0,0,0,0}};
  8. static unsigned int buffer[XRES*YRES] = { 0 };
  9. __declspec(naked) void winmain()
  10. {
  11. // Prolog
  12. __asm enter 0x10, 0;
  13. __asm pushad;
  14. {
  15. HWND hwnd = CreateWindow("i", 0, WS_POPUP | WS_VISIBLE | WS_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0, 0);
  16. HDC hdc = GetDC(hwnd);
  17. while(true)
  18. {
  19. for( int a=0; a<XRES*YRES; a++)
  20. buffer[a]= 0xFF0000 + ((a*12345+345)%0x1000000);
  21. StretchDIBits(hdc,0,0,XRES,YRES,0,0,XRES,YRES,buffer,&bmi,DIB_RGB_COLORS,SRCCOPY);
  22. if(GetAsyncKeyState(VK_ESCAPE))break;
  23. }
  24. ExitProcess(0);
  25. }
  26. }
  27.  
Comments are closed.