 |
|
|
Scene.org is hosted and supported by:
|
|
|
Scene.org is sponsored by:
|
|
|
|
|
 |
forum - #coders |
|
 | | Topic: | 64k intro framework and _ftol | | | Hi, i´m a newbie project of argentinian demoscener and i´m experimenting a problem in a 64 intro framework
The thing is
1) i´m using VC++6
2) when compiling with /NODEFAULTLIB and use floats i get this error
external symbol not found _fltused
which can be overcomed typing:
extern unsigned int _fltused=1;
(i know this is too obvious for most of you, but please, patience.... )
and everything works ok until a conversion from float to int appears
then:
xternal symbol not found _ftol
so i provide:
inline long _ftol(float x)
{
float y;
_asm
{
fld x
fistp y
}
return y;
}
but still keep getting
external symbol not found _ftol
from compiler
I think I cant use /Qltsp becouse of the softsynth module which requires rounding (i suppose, but not sure)
Any help?
BTW, here´s my page where some sort of diskmag/newbie demo/mods/virtual midi keyboard can be downloaded:
http://personales.ciudad.com.ar/anarkimedes/index.html
there´s the old version of the editor's softsynth included | | |
| Try removing the underscore from your C function declaration: inline long ftol(float x)
The c compiler usually prefixes every function with an underscore..
Cheers,
TRC. | | |
| Hi. You can totally avoid calls to _ftol adding /QIfist to the compiler option list (VC or Intel Compiler), it workd great for us (rgba). Sometimes you will maybe need to do a better conversion writting your ouwn floorf(), but normally /QIfist workd just fine.
Regarding _fltused, you have to add
int _fltused = 0;
somewhere in your code, WITHOUT "extern". If you are using C++, make like this instead:
extern "C"
{
int _fltused = 0;
}
and you will get rid of it. Something else, add /Oi to your code, and you will have memset(), memcpy() and strlen() for free, you will not need to recode them (cause they are added inline to your code directly in assemblre). Similarly, remember to use sinf(), cosf(), sqrtf() and so on instead of sin(), cos() and sqrt() because these go also directly in ASM, so you will not have to code these funcions (exp, fmod and others remain, however).
Hope all this helps :)
iq | | |
| iq, note, you need vs.net to use /qifist i think, if i remember it's not in vc6. (that goes for the intrinsics settings too.)
and also that reminds me of a very amusing bug that happened to us very close to the assembly 64k deadline this year to do with it - the floating point rounding mode has to be set to round down if you use /qifist and expect it to work for float to int. and guess what, directx changes that mode. so various routines of ours were fucked, and we had to go back to an ftol routine. so be careful and know where it'll cause problems. | | |
| Hi Smash. Both /Qifist and /Oi perfectly work with VC 6.0, that's the only compiler we use for our intros. It works even without any service or processor packs. 100% sure about it.
We always use OpenGL for rendering, and that does not mess up the rounding mode for us. But indeed, you must be very carefull with /Qifist. We had to use in fact some floorf() like functions in some parts of the code to have expected roundings, and it was not easy to find the problem. YOu are right on that "so be careful and know where it'll cause problems".
Some other trick we use that saves around 1 kb of code, is using __fastcall calling convention (lot of push/pops are just omited and registers are used instead).
Regards,
iq | | |
| strange, i remember it not working when i tried it before on 6, oh well.
yes, we use __fastcall too. good trick.
although i am linking with msvcrt for a couple of routines (like qsort). does anyone know whether it's really worth it sizewise to rewrite the crt for a 64k? it never seemed that worthwhile when i did tests before. | | |
| my experience is that linking to msvcrt.dll is really usefull for 64k anyway. just watch your mapfile so you don't screw up something that should have been done as an intrinsic.
one thing i wonder about is weither dynamic memory allocation _should_ (not if it actually does) work properly when you omit (WinM/m)ainCRTStartup. afaik, (WinM/m)ainCRTStartup is responsible for setting up the heap (atleast according to catch22.net), and allocating memory without a heap... well, shouldn't really work ;)
however, from the crt sources, i can't really find any heap initialization, so i guess it should be safe. i just wonder if anyone has any further knowledge on this ;) | | |
|
|
|