User | Post |
MingShun
Since: 05-10-02 Rating: 10 (400 pts)
Since last post: 7615 days Last activity: 7615 days
|
|
Wow, amazing what you can understand after a cup of coffee at 2 in the morning. I get where you're coming from Sasami.
After looking over your code, I've concluded that I need a way to toss out frames if I'm taking too long to draw one. In other words, draw every other frame if I have a lot of action going on. Note, I don't check for heavy action, instead heavy action requires a lot of processing.
Gaah, this solution requires a limit on the number of frames I can toss out. If I toss out too many, the gamer will notice.
Neat Optimization Trick that Sasami demonstrated...
Integer Bit Shifting used to be widely used because of it's speed over multiplication and division operations. Nowadays, I don't think it's as noticable, but as games take advantage of technology of today, I'm sure a little bit can go a long way. Err, well, you need a lot...so stuff it into a loop then ^^"
3 * 4 <=> 3<<2 I think.
10 / 2 <=> 10>>1 then.
2 * 68 <=> note...68 can be broken up into 4 + 64. 2<<2 + 2<<8
I'm not sure if that's faster...I guess only if multiplication takes 4 cycles.
It's better for division though (last I heard, 12 cycles ^^")
If you notice, I can shift because I'm multiplying or dividing by a power of 2. There are limits, like integers can only represent so much...and this doesn't work for floats (integer bit shifting, why else?).
It's still pretty neat seeing it in action though.
Please note: I read from a book that it's better to get you code working first. Then you can optimize, because a good rule of thumb is that 90% of the execution time is in 10% of the code. Optimizing tends to make your code messy and unreadable, and it's a waste of time if the code doesn't work.
-------------------- I wonder....Gundam vs. Angry Anime Girl...
The real question is, would there be any surviving viewers? |
Sasami
Goddess in Training
Since: 02-18-02 From: Back in texas! YAY! college sucked! Rating: 10 (1030 pts)
Since last post: 7567 days Last activity: 7567 days
|
|
http://www.singlix.com/trdos/pentium.txt
i use this reference a lot to know whats going on and know how to best optomize my code, microsoft visual c++ lets you see how it compiles down the code to assembly. Bit shifting is a lot faster than multiplying, a single integer multiplication takes 10 cycles, while a single bitshift takes 1 cycle. Division still takes 22-46 depending on the bit size of the integers, and most of the time 32 bit integers are used today b/c of the p3+ architecture of 32 bit pipelines and such.
2<<2+2<<6 (not 8) is still faster than 2*68 b/c
mov eax,2 = 1
mov ecx,2 = 1
shl eax,2 = 1
shl ecx,6 = 1
add eax,exc=1
that takes 5 clock cycles as opposed to
mov eax,2=1
imul eax,68=10
11 clock cycles
and besides, if you are multiplying 5*16 in your code, MVC++ already optomizes that in the assembly to 5<<4 (but it wont do it if it isnt a direct power of 2) although... i have a real awsome intel compiler that totally blows my mind and i dont even know the optimizations it does
(edited by Sasami on 02-13-03 01:55 PM) |
Kasatka
Since: 09-25-02 From: Palana, Koryak, Russia
Since last post: 7823 days Last activity: 8081 days
|
|
well consider my mind blown.
Where do you learn all this? |
MingShun
Since: 05-10-02 Rating: 10 (400 pts)
Since last post: 7615 days Last activity: 7615 days
|
|
1. Where there's a will, there's a way.
2. Start small. I used to program BASIC on a graphing calculator.
3. Rome wasn't built in one day.
4. Books aren't just collections of words, they actually have something important in them.
5. School is good. Forces you to learn.
With those points in mind, I suggest you go out and learn a programming language.
After you're done, come back and see if you understand it better. The secret is to change your way of thinking. This isn't english, and it doesn't look like english, but exposure will make things easier to comprehend.
Don't worry though, I don't understand Miss Sasami's assembly example ^^;; Basically, that's because I don't understand the structure of assembly.
To me, I see:
3 letter word...number...number.
What do they mean? That's where I have to adapt my way of thinking. Once I understand the philosophy of how a line is put together, I can try and figure what many lines put together mean.
I'm lazy and stubborn...hence the inability to learn Assembly.
-------------------- I wonder....Gundam vs. Angry Anime Girl...
The real question is, would there be any surviving viewers? |
Sasami
Goddess in Training
Since: 02-18-02 From: Back in texas! YAY! college sucked! Rating: 10 (1030 pts)
Since last post: 7567 days Last activity: 7567 days
|
|
miss sasami... **
and i can agree with you on all those but school... i hate formal education.. |
sakura
Since: 06-18-02 From: Canada
Since last post: 7651 days Last activity: 7651 days
|
|
School does forces you to learn the language, but it can be very tough. I like learning at my own paste, and not have someone telling me how to do things all the time. What I don't like about computer classes at school is that they are very repetitive, long and boring lectures and that you must include lots and lots of documentations in your work...yuck! Also, I don't like the samples they teach, I find that I can learn most of the stuff I like from books especially game programming which they don't teach you. |
Kasatka
Since: 09-25-02 From: Palana, Koryak, Russia
Since last post: 7823 days Last activity: 8081 days
|
|
I like school for the perks. I like work experience, but I hate school CLASSES since they're all so nausiatingly dull. Yeah, calculus is vaguely interesting, and physics is neat, but really, English? It isnt really that much about english either. Shakespeare was a good writer - one of the best - but the ENGLISH is five centuries old - and wasnt even that good for it's age. The writing is good, the words are not.
That and I already know some of a few programming languages -
QUICK BASIC! OOH TOP OF THE LINE STUFF! (yeeccchhhhhh I can make DOS add, look at me)
Visual Basic and C++, but now there's this new J# stuff and, heh... It's like they told you to do Visual in the usual lanuguage, but TOLD YOUTO SPEAK IT IN A TOTALLY UNRELATED WAY. That's how I feel anyhoo.
Director 6.0. That was a fun course... on Macs...
HYPERCARD! I MISS HYPERCARD! THE 1-bit, two "color" glory of Macintosh UI "programming"! Those were the days...
Anyway, the thing is I never learned the nitty-gritty of anything - I like nitty gritty, but a semester is not enough time. 20 weeks wont hold me, and I dont have the software at home to keep up.
The more disabling problem is that I havent the cash to support a good book-buying regime. I usually jsut real manuals or white papers I print out on the crapper, and that really wont do a whole lot of good since I dont always follow all of it .
-----
Anyway, now that that tirade is over, on with the thread! |
MingShun
Since: 05-10-02 Rating: 10 (400 pts)
Since last post: 7615 days Last activity: 7615 days
|
|
Oh, I guess you lack the experience then. I suggest you listen to the world around you...listen for neat tricks. At least, that's what I do these days. I read tutorials on websites like this game developing site. Of course, I do it whenever I feel like. But if you listen enough, your way of thinking will change, or your knowledge...maybe both.
School...well, I'm proud of learning pointers in a week. Haha, that's what introduced me to a very scary subject. I mean, the topic was sitting in my (non-school) programming book under linked lists, but it looked so complicated.
[edit] oops. fixed the link, sorry.
--------------------
I wonder....Gundam vs. Angry Anime Girl...
The real question is, would there be any surviving viewers?
(edited by MingShun on 02-18-03 10:58 PM) |
|