Okay
These are stupid questions. But I'm reading up on Amiga programming and ANSI C, and I'm reading this tutorial:
http://www.liquido2.com/tutorial/Now question 1:
In part 4 (
http://www.liquido2.com/tutorial/draw.html)
Line 132 states:
window_signal = 1L << MyWindow->UserPort->mp_SigBit;
I understand this that he is copying the signal address of the window he's created into a varialbe called "window_signal".
What I don't understand is why he has to bitshift it to the left.
Tutorial says:
MyWindow->UserPort->mp_SigBit holds the number of the particular bit used to represent the message signal for MyWindow. So, if MyWindow->UserPort->mp_SigBit happens to be 26, then we will shift the 1 to the left 26 places:
00000010 00000000 00000000 00000000
thus, the decimal value of window_signal would be 33,554,432. That really doesn't matter here, because we're interested in the bit number much more than the value, but it may be useful to understand what's really going on. Just remember that the signal bit for your window may be any number.
Why could he not just use:
Arnjots question:
window_signal = MyWindow->UserPort->mp_SigBit;
Isn't the bitshifting redundant? Or is it so that the name mp_SigBit is to be read literally, that its not the value it would be wih the bit set, but the digit position of the bit?
Next question:
Reading the code in the tutorial:
Line 139 to 142:
signals = Wait( window_signal );
/* Check the signal bit for our message port. Will be true if these is a message. */
if ( signals & window_signal )
Why is he using the AND bit operator here? What can Wait return? can the result of Wait be more than what you've "asked for" in the argument to Wait?
And if so, why would you ignore a return signal where the signal you are listening for is part of the bitmask?
I understand that my questions are a mix of lack of understanding of ANSI C, the Amiga Signaling system and the spesific application domain in this tutorial example.
I'm a bit embarresed to ask, but I wanna learn and understand the smallest details. And I'm starting on zero.
Please be gentle...