Dark Bit Factory & Gravity

PROGRAMMING => C / C++ /C# => Topic started by: taj on November 13, 2006

Title: Visual C++ 4k settings?
Post by: taj on November 13, 2006
Does anyone (Rbraz?) have a set of instriuctions/settings/steps/tutorial/link on how to reduce code size to the minimum using Visual C++. I prefer to put as little into the C code as possible. I usually use GCC but I'm having a lot of issues combining that with DX and these days DX offers a lot more than Opengl for size coders.

Title: Re: Visual C++ 4k settings?
Post by: benny! on November 13, 2006
Sorry ... I am in a hurry ... but maybe this link is of some help for you :

http://keyj.s2000.ws/?p=29

cu l8er.
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 13, 2006
I'm installing Visual C++ 2005 Express right now, when I got something I'll post here...
Title: Re: Visual C++ 4k settings?
Post by: taj on November 13, 2006
Sorry ... I am in a hurry ... but maybe this link is of some help for you :

http://keyj.s2000.ws/?p=29

cu l8er.

That link has one or two gems including the /QIfist hint! Thanks Benny
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 14, 2006
With VC2005 Express, the best what I can get is 563 bytes packed...
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 14, 2006
Ok, now it's 427 bytes only  :o , damn it's too close to my ASM version (421 bytes packed)   :||


 :cheers:



[Edited - file updated again...]
Title: Re: Visual C++ 4k settings?
Post by: taj on November 14, 2006
Now thats worth Karma :-) thanks rbraz!
Title: Re: Visual C++ 4k settings?
Post by: benny! on November 14, 2006
Indeed .. very cool Rbraz. Thx for sharing !
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 15, 2006
No problems dudes :)

I have updated the attached file, just removed unused #pragma commands, removed msvcrt.lib and added msvcrtd.lib instead.
Title: Re: Visual C++ 4k settings?
Post by: benny! on November 15, 2006
@rbraz:

cool ...


@taj:

uhh ... the new banner looks scary cool  ;)
Title: Re: Visual C++ 4k settings?
Post by: taj on November 15, 2006
Ok, now it's 427 bytes only  :o , damn it's too close to my ASM version (421 bytes packed)   :||
 :cheers:

[Edited - file updated...]

Rbraz,

I did some texting with this with some results for you.
Aulds 1k framework under GCC, your exact version of code: 494 bytes
Aulds 1k framework under GCC, his code: 474 bytes

Neither is close to your result but 50 bytes is damn suspicious. Thats something not working (as if aulds framework pulls in another library under GCC), not simple optimisation. Nontheless it seems VC++ plus your tuned version of aulds framework is 50 bytes smaller!! Damn, guess I'll be working in VC++ from now on.

One thing how do you compress? Is it convert to com and then use apack?
Are you using the same settings as in aulds framework or something else?
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 15, 2006
Cool, I hope that Auld can find this and post it at In4k  ;)

To compress it, I just used the same settings as Auld have used for his framework, tried others settings but without any better results...

Cheers,
Title: Re: Visual C++ 4k settings?
Post by: taj on November 15, 2006
In4k is a wiki Rbraz, you can always add this information yourself...
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 15, 2006
I've already registered at In4k (sometime ago), I'll check how to add that info there... thx
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 15, 2006
In4k is a wiki Rbraz, you can always add this information yourself...

Done  ;)
Title: Re: Visual C++ 4k settings?
Post by: taj on November 15, 2006
In4k is a wiki Rbraz, you can always add this information yourself...

Done  ;)

Yeah checked it out, mega cool!
Title: Re: Visual C++ 4k settings?
Post by: taj on November 18, 2006
Im really struggling to get this working Rbraz.

Installed VC++ 2005 Express
Installed platform SDK

trying to manually find all the paths for stuff that it needs..getting this error
Project : error PRJ0002 : Error result -1073741515 returned from 'C:\Program Files\Microsoft Visual Studio 8\VC\bin\link.exe'.

Any ideas?


...

Ok found the answer. Despite the install instructions I found I had to add:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
under Tools->Options->Projects and Solutions->VC++ Files on the tab executable Files

As you can imagine, it took a while to find so if anyone else tries this and has issues, I wanted to write it down to save you hassle.
Title: Re: Visual C++ 4k settings?
Post by: taj on November 18, 2006
Rbraz,

why have you added exitprocess and return 0 to the code? It seems to compile and run fine without them and the result is only 414 bytes.
Title: Re: Visual C++ 4k settings?
Post by: benny! on November 18, 2006
...
Ok found the answer. Despite the install instructions I found I had to add:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
under Tools->Options->Projects and Solutions->VC++ Files on the tab executable Files

As you can imagine, it took a while to find so if anyone else tries this and has issues, I wanted to write it down to save you hassle.

Always nice to see when people add the solution to their own question when no one else
answerrs ! I like this attitude - keep it up. (Karma up!)
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 19, 2006
Im really struggling to get this working Rbraz.

Installed VC++ 2005 Express
Installed platform SDK

trying to manually find all the paths for stuff that it needs..getting this error
Project : error PRJ0002 : Error result -1073741515 returned from 'C:\Program Files\Microsoft Visual Studio 8\VC\bin\link.exe'.

Any ideas?


...

Ok found the answer. Despite the install instructions I found I had to add:
C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
under Tools->Options->Projects and Solutions->VC++ Files on the tab executable Files

As you can imagine, it took a while to find so if anyone else tries this and has issues, I wanted to write it down to save you hassle.

I really recommend for people who want install VC++2005 to follow this link, step by step, to avoid such problems:
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/


Rbraz,

why have you added exitprocess and return 0 to the code? It seems to compile and run fine without them and the result is only 414 bytes.

Because I like to waste bytes  ::)
No, just kidding, because I'm not able to make WinMain return void, and since that function return int,  return 0 doesn't make your file bigger.

About Exitprocess(0), you know better than me that is more safe to exit all process created by our prog, if removed from my ASM version, the final file is 399 bytes, but it crash when exit was pressed...



Well, I found one issue about VC++2005 framework, msvcrt.lib and msvcrtd.lib they call respectively those dlls - msvcrt80.dll and msvcrt80d.dll
to get rid about that I've included an old msvcrt.lib (from VC++6.0) and renamed it to msvcrts.lib ( s=standard), this library call the standard msvcrt.dll present in all windows platform (I guess), anyway I've tested it with Windows98 and WinXP and it works fine.

Download the updated framework here --> http://www.rbraz.com/source/1K_FrameWork_VC2005.zip
There's a little readme.txt file included to help you install the file msvcrts.lib

Have fun!

Title: Re: Visual C++ 4k settings?
Post by: taj on November 19, 2006
Quote
I really recommend for people who want install VC++2005 to follow this link, step by step, to avoid such problems:
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

Yeah I did that, it didnt work...I had to do what I said as well..
Title: Re: Visual C++ 4k settings?
Post by: taj on November 19, 2006
Quote
Well, I found one issue about VC++2005 framework, msvcrt.lib and msvcrtd.lib they call respectively those dlls - msvcrt80.dll and msvcrt80d.dll
to get rid about that I've included an old msvcrt.lib (from VC++6.0) and renamed it to msvcrts.lib ( s=standard), this library call the standard msvcrt.dll present in all windows platform (I guess), anyway I've tested it with Windows98 and WinXP and it works fine.

Download the updated framework here --> http://www.rbraz.com/source/1K_FrameWork_VC2005.zip
There's a little readme.txt file included to help you install the file msvcrts.lib

I dont understand - are you saying that people have to install a dll to run the file at 4k? If so, it doubt it will be accepted as 4k at any compo. I had a similar problem yesterday wjhen I tried to add a call to ZeroMemory which began looking for msvcrt80d.dll. In the end I just avoided the call - so I'm sure this will bite me in the future but not yet. Incidentally Im using your settings to try and get D3D and OGL up and running and talking to each other so I can use functions from either set of libraries. I managed yesterday to have d3d and opengl up and running in 490 bytes. Though only ogl was drawing, d3d was just intialised. Nontheless, its an exciting idea because d3dx offers lots of useful routines (say like finding the normals on a mesh). From GCC this is a real pain in the arse and not worth trying to do IMO.

Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 19, 2006
Quote
I dont understand - are you saying that people have to install a dll to run the file at 4k?

Yes, but you will be able to get rid about that, just use the standard msvcrts.lib that I've included in the new package, any problems, let me know...
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 19, 2006
Quote
Nontheless, its an exciting idea because d3dx offers lots of useful routines (say like finding the normals on a mesh)

@taj: Where I can found more info about that, I would like to know what I can do with directx 9...
Title: Re: Visual C++ 4k settings?
Post by: taj on November 19, 2006
Quote
Nontheless, its an exciting idea because d3dx offers lots of useful routines (say like finding the normals on a mesh)

@taj: Where I can found more info about that, I would like to know what I can do with directx 9...

Honestly I started last week, but the thing that got me excited was d3dx so go to www.msdn.com and search for d3dx...look at the mesh stuff for a start. Its how loonies/fairlight are doing their 4ks right now, a few calls into d3dx (meshes and precomputed radiance transfer (ie ambient occlusion for free) and a kicking synth (diectsound :-). Basically they have huge advantages over us OGL guys so I'm trying to even the odds a little.

For the last few years the winning 4ks at breakpoint are basically calls to d3d and not a lot else...

You could also start here:
http://msdn2.microsoft.com/en-us/library/ms810495.aspx
Title: Re: Visual C++ 4k settings?
Post by: Jim on November 19, 2006
If you can use d3d9.dll and opengl32.dll, what would be the problem with using msvcrt.dll?  As long as it's part of a modern XP SP2 install it would be OK, right?

Jim
Title: Re: Visual C++ 4k settings?
Post by: taj on November 19, 2006
If you can use d3d9.dll and opengl32.dll, what would be the problem with using msvcrt.dll?  As long as it's part of a modern XP SP2 install it would be OK, right?
Jim

Nothing at all, but it seemed Rbraz was delivering a dll with his stuff for it to work...whcih you cant do...Rbraz can you be a bit clearer? Why are you renaming a file and shipping it?
Title: Re: Visual C++ 4k settings?
Post by: Rbz on November 20, 2006
If you can use d3d9.dll and opengl32.dll, what would be the problem with using msvcrt.dll?  As long as it's part of a modern XP SP2 install it would be OK, right?

Jim


That's what I'm trying to do, how can I access msvcrt.dll using VC++ 2005 ? If I compile with msvcrt.lib it still calling msvcrt80.dll, so, my fix for this was to compile with an old msvcrt.lib file from Visual C++ 6.0, just renamed it to msvcrts.lib and using with that framework.
I did this because most of people don't have msvcrt80.dll installed on their PC.


Quote
Nothing at all, but it seemed Rbraz was delivering a dll with his stuff for it to work...whcih you cant do...Rbraz can you be a bit clearer? Why are you renaming a file and shipping it?

I just renamed that old library file to avoid conflicts with the new msvcrt.lib installed (I don't want to delete it!)  with your VC++2005, in the end this is just my way to call the standard msvcrt.dll found in every Windows incarnation.


If someone have another way to do that let me know...


Title: Re: Visual C++ 4k settings?
Post by: Jim on November 20, 2006
I guess in the Project Linker options,
Linker, Input, Ignore Specific Library,
you need to add msvcrt??.lib
otherwise it will always use it.
Then put the old .lib of your choice in your project folder and add it to
Additional Dependencies
and in to your library path.

There's a huge gotcha doing that though - if the standard C headers have changed in any way (for instance, say someone changed FILE or time_t or something, which does happen) then the old runtime library may not work with code generated by the new compiler.  You might get linker errors (missing symbols) or you might get runtime errors or crashes.

Another possibility is to LoadLibrary your desired runtime yourself and GetProcAddress the C runtime library functions you want.  That's subject to the same gotcha...

Jim
Title: Re: Visual C++ 4k settings?
Post by: taj on December 28, 2006
BTW Rbraz, in the end I got the framework working without the extra lib. I've forgotten what I did though, so I'll package a copy and you can have a look.

Also I got it working with D3D and Opengl both initialised in less than 500 bytes. Meaning the Dx maths stuff can be used with opengl in 1k or 4k. I'm not willing to release this in a public forum but anyone from this forum who wants a copy of the code can have it.
Title: Re: Visual C++ 4k settings?
Post by: Rbz on December 29, 2006
Quote
BTW Rbraz, in the end I got the framework working without the extra lib. I've forgotten what I did though, so I'll package a copy and you can have a look.

Cool, if you don't mind, send it to me (or attach it) and I'll update it on my site.