Equation of the Day

Started by
7 comments, last by Buster 23 years, 9 months ago
Just thought I'd share something... this proves I need to take a break and get some sunlight!

*(WORD*)(bDes+(dw*(p->y+y))+(2*(p->x+x)))=
   (aK[a-1][(s&x.maskR)>>x.sR][(d&x.maskR)>>x.sR]<_<_x.sR) +
   (aK[a-1][(s&x.maskG)>>x.sR][(d&x.maskG)>>x.sG]<_<_x.sG) +
   (aK[a-1][(s&x.maskB)>>x.sR][(d&x.maskB)>>x.sB]<_<_x.sB);

// the <_<_ is actually a bitshift, but this message board won't display 2 "<" in a row

  
Hint: this eq alpha-blends two 16-bit pixels into one. It's from a function that they're having me convert from C to assembler. I'd rather be playing Diablo! Edited by - Buster on 7/13/00 1:28:30 PM Edited by - Buster on 7/13/00 1:28:58 PM
Advertisement

You might need one of these after too much code like that
~S''Greth

Got Code?
"The difference between insanity and genius is measured only by success."~Bruce Feirstein
I do not know what the arousement is all about...

First of all code like this might seem good but the compiler sucks at it... since processors are RISC based (they love simple instructions).

Finally... if you think that this is complex... what have you been coding?? Just simple text adventures or something like that... If you want really complex stuff... just get into 4D (width, height, depth, and time) that will make this look like childs play.

Greetings Dark

Mail me at mitolah@hotmail.com

ICQ: 130925152Email: e.j.folkertsma@student.utwente.nl
Woah!! Excuse me...didn''t mean to offend you by saying that looked complex, chill out a bit Dark...sheesh! BTW, the top of my last message was supposed to say
*passes Buster a frosty beverage*

~S''Greth

Got Code?
"The difference between insanity and genius is measured only by success."~Bruce Feirstein
It wasn''t meant to be a dick measuring contest, so zip it back up, big boy. (and BTW, text adventures don''t do alpha-blending).

I was just saying that when the code you''re looking at contains almost no readable english, it''s time for a lunch break!

Sorry guys... I didn''t mean to upset you.

Dark

ICQ: 130925152Email: e.j.folkertsma@student.utwente.nl
You don''t upset us, you''ve just killed yourself

heheheheheh
I dunno. Buster''s post sounds kind of condescending to me.
Maybe he thinks we''re all a bunch of morons.
I usually make my code as simple as possible, i usually look at other people''s programs and think they are a better coder than me, but usually mine is a lot simpler and easier to understand and usually is more efficient, flexible, or supports more features. I think that code looks like crap, I see 1 cast, a few array indexes, some pointer access and structure access and your variables look like shit. I think you should get Code Complete, even though I have never read it, I understand it shows how to employ understandable code. I see what you are doing there though, you take 2 pixels that will be overlayed on top of each other, average out each aspect(RGB) (you can use different percentages if you wish to make different effects) and you get a resulting pixel.

A few hints, don''t use structures to hold the RGB masks, don''t use structures to figure out how much to shift by, copy the pointer or array value into a separate variable if you will be using it repeatedly. Just say there are three people, and I wanted to poke person 3, but if i poked person 2, person 2 would poke person 3, well, if i want to keep on poking person 3, why don''t i just push person 2 out of the way and poke person 3 personally. hehe... i like that analogy =)

I don''t mean to sound harsh or anything, just giving you some hints on some fundamental optimization. Like I said, you can define a mask like this
#define RedMask 0x000000ff
considering flag,green,blue,red format
and you should know how much you are shifting by. Anyways, alpha-blending is a time consuming procedure, and you shouldn''t be using a whole bunch of crap to slow it down
Rock on,- Tom

This topic is closed to new replies.

Advertisement