Author Topic: preview - possible an 1k intro for TUM2008 (exclusiv captured video)  (Read 14009 times)

0 Members and 1 Guest are viewing this topic.

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
hi guys..
as some of you know this month is the german demoparty TUM... since some time i am working on a "very simple" 1k intro for this event and most things are done and working more or less good... (using VC2005 and DX9 for the 1k intro)

With some help and tips i managed to shrink the actually version to 1061 bytes (unenjoyable slow version) and to 1069 bytes (faster version)... I am out of ideas how and where are possibilities to save more bytes to get it fit in just 1024 bytes!

Here you DBF members can exclusive see my 1k intro as captured video version which runs a lot smoother as the original 1061 bytes exe version :
(Klick here to watch the video! Please do not copy nor spread the video nor idea around before the 1k has been released, thx) 


And here is my actually problem list:
- Optimize size to fit into 1024 bytes (still using /UNSAFEIMPORT by crinkler)
- Speed up the particle system drawing ( using DX9->DrawText() which is extreme slow, using no sprite yet *damn* )
- Add GetTickCount (Kernel32.dll) for timing things to run in same speed on all PCs instead using things like   x = x + 1   on good old amiga ^^
- Maybe some design reworking (like background colors but this is easy and not so important yet... i like it myself colorfull)
- Sometimes (not often but still happens from time to time), the intro resets my computer while running O.O  (possible a HW prob with my PC?)

So if someone of you having good 1k coding/size-optimizing skills and is interested to help me it would be really nice...  feedback if you like or dislike the intro and its idea would be nice too... Btw, due fact i need help from other ppl to realise this 1k, the intro will be released with complete C/CPP source (with the party release!) - so any other ppl can try to see how it was done and can hopefully learn a bit from!!!

Due fact this prod is planed to be released in the "4k intro competition", i think its would be a problem with the compo-rulez to show here the source, before the intro has been released!? Thanks a lot for any feedback!
« Last Edit: December 09, 2008 by va!n »
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
- How did you store the moving scenery ? In which format ?
Maybe there is space to optimize?

- How you print the text out ?
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
@benny:
Quote
How did you store the moving scenery ? In which format ?
Mhhh.. sorry, i am not really sure what you mean... the scenery graphic is just drawn by using the webdings font. So the full scenery is stored in stringdatas (sky + airplane + sun == only 7 bytes of data without the shown text messages)

Quote
- How you print the text out ?
Due fact the intro is DX9 based, i use   DX->DrawText()   to draw the text and a bit tricky, the particles too :P
Thats the reason, the particles are so extreme slow in the 1061 bytes version... DX->DrawText is very very slow for my need!
Afaik it could be speed up by using sprites... but this would cost more bytes/space in the exe...



Btw, here is the part where and how i draw things:
Code: [Select]
// ---- Draw our Scene with Text ----

rect.left = 680+(ScrollX<<1);
rect.top  = -50;
g_pFont[0]->DrawText(NULL, "j", -1, &rect, DT_LEFT , 0x88000000); // D3DCOLOR_XRGB(85,49,23) Airplane
// g_pFont[0]->DrawText(NULL, "j", -1, &rect, DT_LEFT , 0xff523317); // D3DCOLOR_XRGB(85,49,23) Airplane

rect.left  = 910+(ScrollX>>1);
rect.top = -30;
g_pFont[0]->DrawText(NULL, "Ö", -1, &rect, DT_LEFT , 0xff000000); // D3DCOLOR_XRGB(0,0,0) ) Sun 

rect.left  = ScrollX;
rect.top = 150;
g_pFont[0]->DrawText(NULL, "CKMSQ", -1, &rect, DT_LEFT , 0xff000000); // D3DCOLOR_XRGB(0,0,0) Landschaft

rect.left  = 20;
rect.top = 20;
g_pFont[2]->DrawText(NULL, TextParts[TextObj], -1, &rect, DT_LEFT , 0xffFFFFFF); // D3DCOLOR_XRGB(255,255,255) MessageText

// -----------------------------------------------

if (ScrollX > -1212) // Check how to get it work using GetTickCount() to run in same speed on all PCs
{
--ScrollX;
}

if ((change > 310) && (TextObj < 3))
{
++TextObj;
change = 0;
}
else
{
++change;
}

// ---- End the scene ----
« Last Edit: December 09, 2008 by va!n »
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Instead of calling DrawText multiple times with different parameters, you can try something like this:
Code: [Select]
static int posx[3]={680, 910, 0};
static int posy[3]={-50, -30, 150};
static int speed[3]={4, 1, 2};
static char *text[3]={"j", "Ö", "CKMSQ" };
static unsigned int color[3]={0x88000000, 0xff000000, 0xff000000};

for (int i=0;i<3;i++)
{
  rect.left = posx[i] + (ScrollX*speed[i]>>1);
  rect.top  = pos[y];
  g_pFont[0]->DrawText(NULL, text[i], -1, &rect, DT_LEFT , color[i]);
}
(untested)

timing should be something like this:
Code: [Select]
int startTime= GetTickCount();

while (...)
{
  int scrollX= (startTime - GetTickCount)>>4; // scrollX is negative
  ...
};
this assumes that you're now running at ~60 frames per 1000 miliseconds => 1000/60=~16
« Last Edit: December 09, 2008 by hellfire »
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Looking pretty cool so far dude; one thing I noticed that you might want to address is with the plane, and that it could do with being made more rounded on the nose of it.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline AnimalMother

  • btst #6,$bfe001
  • Atari ST
  • ***
  • Posts: 113
  • Karma: 7
    • View Profile
Looks really cool. I like it!

But one funny thing: Airplane, Sun, Landschaft  ;D

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
thanks for your feedback and comments!

@hellfire:
thanks for your help... i have tried to add your code which works fine with fixing a small typemistake ^^ The packed file was a lot bigger using this way as the original. But no problem, it was a try worth. However i tried something similar myself before and had no luck with...

@all:
I know that its not really possible to help/optimize things when not having the full source/project to play a bit around with it... So i finally determined myself to attache the complete source/project here "for DBF forum members only"... but please do not copy nor spread the source/project/exe nor idea of this unfinished version! (The final 1k version will be released as exe with the complete and final source/project files for everybody!) For more infos, please read the info in the source. Thanks a lot!



« Last Edit: December 11, 2008 by va!n »
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
CPP source/project added...
btw... is it true, when writing a intro in pure C that the generated output (exe) may be some bytes smaller as writing in CPP? O.O

Here i will list some things i have tried myself to optimize the size (possible some older source versions here)

Code: [Select]
struct MyTextData
{
int x;
int y;
int font;
char* string;
int color;
};

static MyTextData td[4] = {
910+(ScrollX>>1),  -30, 0,     "Ö", 0xff000000,
580+(ScrollX<<1),  -50, 0,     "j", 0xff523317,
ScrollX ,  150, 0, "CKMSQ", 0xff000000,
20 ,   20, 1, TextParts[TextObj], 0xffFFFFFF,
};

for (int i=0; i<=3; i++)
{
SetRect( &rect, td[i].x, td[i].y, 1024, 1024);
g_pFont[ td[i].font ]->DrawText(NULL, td[i].string, -1, &rect, DT_LEFT , td[i].color); // D3DCOLOR_XRGB(0,0,0) ) Sun 
};

// ************************************************************
//   i n s t e a d   o f   t h i s :
// ************************************************************

rect.left = 680+(ScrollX<<1);
rect.top  = -50;
g_pFont[0]->DrawText(NULL, "j", -1, &rect, DT_LEFT , 0x88000000); // D3DCOLOR_XRGB(85,49,23) airplane (saves some bytes!)
// g_pFont[0]->DrawText(NULL, "j", -1, &rect, DT_LEFT , 0xff523317); // D3DCOLOR_XRGB(85,49,23) airplane

rect.left  = 910+(ScrollX>>1);
rect.top = -30;
g_pFont[0]->DrawText(NULL, "Ö", -1, &rect, DT_LEFT , 0xff000000); // D3DCOLOR_XRGB(0,0,0) sun 

rect.left  = ScrollX;
rect.top = 150;
g_pFont[0]->DrawText(NULL, "CKMSQ", -1, &rect, DT_LEFT , 0xff000000); // D3DCOLOR_XRGB(0,0,0) landscape


Code: [Select]
static void MyDrawText(int x, int y, int font, char* string, int color)
{
SetRect( &rect, x, y, 1024, 1024);
g_pFont[font]->DrawText(NULL, string, -1, &rect, DT_LEFT , color);
};

MyDrawText( 0, 910+(ScrollX>>1), -30, "Ö", 0xff000000);
MyDrawText( 0, 680+(ScrollX<<1), -50, "j", 0xff523317);
MyDrawText( 0, ScrollX, 150, "CKMSQ", 0xff000000);
MyDrawText( 1,               20,  20, TextParts[TextObj], 0xffFFFFFF);



« Last Edit: December 11, 2008 by va!n »
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
from yesterday until now (03:10am here) i have spend over 4 hours in trying a lot of things to optimize the filesize without any success yet :diablo:
does someone of the tiny size coders here have any idea/tip for me?

Would be nice to see in what filesize the exe ends up when it would be packed with a custom "no public" 1k packer like by mentor or hitchicker...  8)
Okay.. now i have to go to bed..  4,5 hours to sleep before going to work :P
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
I believe you don't require 3 individual timers.
this:
Code: [Select]
if ((change > 310) && (TextObj < 3))
{
++TextObj;
change = 0;
}
else
{
++change;
}
is essentially the same as this:
Code: [Select]
TextObj= time / 311You just have to handle the case "TextObj==4" properly.
For example you could declare "mirand" (which is 0 at the time of calling DrawText) right behind "TextParts", making TextParts[4] a null-pointer (which is valid input to DrawText).

Just a thought...
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Cant wait to see your progress dude, btw, Karma for supplying a video capture, as on my system I can't run the smaller Special K intros.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
@hellfire:
thanks for the help... i have tried something simular but i had to add a if condition to check if TextObj>3 so no crap will be displayed... your way saves me about 5 bytes but after last msg has been shown, memory-trash (some random bytes) will be shown :P i will take a closer look to this methode next minutes...

btw i have tried wihout success (get it working and more tiny), to combine "time" and "SpeedX" into just one variable... should be possible.. i will play with this again... hopefully it saves some bytes too ^^



@all:
wanna just tell you great news...  actually i have a running version == 1022 bytes!!! :updance:  :mince:
i will tell you more about this very soon... so please be patienced...
btw if you have still any ideas, dont hestitate and let me know :)

« Last Edit: December 12, 2008 by va!n »
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
If the effect produced by removing mirand = 0; is acceptable for you I got it down to 1022 bytes too with proper timer added.

Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
@rbz:
Wow, 1022 bytes with an added timer to run in same speed on all PCs?  8) (this would be really cool!) The effect produced without using mirand = 0; does not looks so great but i could life with it if necessary ;) Btw, is there any way to get your reworked and optimized source version, so i can compare your version with my latest version and probaly shrink some more bytes?

Attached: my actually source version (1022 bytes). Many many thanks to Auld for his great help !!! :cheers:



- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
1020 now, I forgot to add data_seg and code_seg like Auld did :)

The trick here was to remove your sfrand function and use rand() function from msvcrt.dll instead.

In the .zip file you will find a library called "msvcrts.lib" which msvc and crinkler will use, just keep it in the same intro folder, any problems let me know.

Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
@rbz:
thanks for the source. i am just wondering whats going wrong here... i can compile your source without problems... but the crinkled exe is always 1312 bytes for me, using VC++2005, Crinkler v1.1, DX SDK Nov2008... Any idea why i cant compile your version to 1020/1022 bytes too? O.O Thanks!
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
You need to add this command line for crinkler ->   /ENTRY:WinMain
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
@rbz:
thanks for the source and the info with the settings! Yes, now it compiles to 1020 bytes...*thumbs up*

i have spend the full last night to compare the code differences between your and aulds source and tried to create a new version which uses tricks/optimiations from both sources... until now without real success... so i have still a queston i dont really check atm.

you changed following which i dont really understand why you canged nor where/whats the diffent between both versions:

Code: [Select]
void WinMainCRTStartup()
{

Code: [Select]
int WINAPI WinMain(HINSTANCE hThisInstance,
                    HINSTANCE hPrevInstance,
                         LPSTR lpszArgument,
                           int nFunsterStil)

{

Ok, both are the Entrypoint, i have to change in the linker settings... but when adding your WinMain version to aulds version, the compiled exe is over 1300 bytes! So i am not sure about this point/changes and would be nice to know some more about it. thanks!

i will try to make a new tiny version (  <=1024 bytes including optimisations from you both with real timer and possible faster particle drawings).
Many thanks for your help, rbz!

 
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
This happens because msvcrt lib already have this symbol -> WinMainCRTStartup() / header
What we do is only use it's function, bypassing crt header using our own entry point.
« Last Edit: December 15, 2008 by rbz »
Challenge Trophies Won:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
ok guys.. just only a few days and the TUM begins... so i have really try to hurry up and come up with something that works hopefully faster (i mean the extreme slow particle drawing system) and to put all in just max 1024 bytes!

Since having two jobs and beeing very busy i will continue this project in a few minutes and try to compare both optimized version you guys posted/helped me... maybe it may be possible to save some more bytes and optimize the extrem slow DrawText()-Particle system, i.e. its possible to use the particles as texture/sprites, which should be faster!? So if someone of you great size-coders here have tips or may help, it would be really cool!

Would be very interested to see the packed exe size when it would be packed with a custom packer like the one by mentor or hitchhiker ;)
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won: