Hi all,
I've been having problems with the GrDisplayCursor function. In my case, sometimes the cursor is drawn partially. I think I've found the error in GrDisplayCursor.
If the cursor is 8 pixels wide, the work area is 16 pixels wide. Let's supose a call to GrDisplayCursor with C->xcord = 323:
C->xcord = 323; C->xoffs = 0; C->xsize = 8; C->xwork = 16; ----------------------- call GrDisplayCursor xpos = 323; xsiz = 16; xwrk = 312; ... (save bitmap from 312 to 327) [our cursor goes from 323 to 330] ... xpos = 11; xsiz = 8; if(xsiz > (C->xwork - xpos)) xsiz = C->xwork - xpos; ====> xsiz = 5; (draw a cursor 5 pixels wide)
IMHO this is a bug. I think GrDisplayCursor tries to place the cursor in the middle of the work area, but in a coordinate multiple of 8:
xwrk = (xpos - (C->xsize >> 1)) & ~7;
but sometimes the result lets the cursor partially outside the work area. I think after this line is necesary a correction: if((xpos + C->size) > (xwrk + xsiz)) xwrk += 8;
The same applies to vertical coordinates. What do you think about it?
Josu Onandia
Dpto. I+D Software. e-mail: jonandia@fagorautomation.es
---------------------------------------------------- Fagor Automation, S.Coop. Barrio San Andres, s/n - P.O. Box. 144 Mondragon 20500 - SPAIN
Reviewing the GRX mailing list for bug reports and supplied patches I found this one:
On Thu, 23 Dec 1999, you wrote:
Hi all,
I've been having problems with the GrDisplayCursor function. In my case, sometimes the cursor is drawn partially. I think I've found the error in GrDisplayCursor.
If the cursor is 8 pixels wide, the work area is 16 pixels wide. Let's supose a call to GrDisplayCursor with C->xcord = 323:
C->xcord = 323; C->xoffs = 0; C->xsize = 8; C->xwork = 16; ----------------------- call GrDisplayCursor xpos = 323; xsiz = 16; xwrk = 312; ... (save bitmap from 312 to 327) [our cursor goes from 323 to 330] ... xpos = 11; xsiz = 8; if(xsiz > (C->xwork - xpos)) xsiz = C->xwork - xpos; ====> xsiz = 5; (draw a cursor 5 pixels wide)
IMHO this is a bug. I think GrDisplayCursor tries to place the cursor in the middle of the work area, but in a coordinate multiple of 8:
xwrk = (xpos - (C->xsize >> 1)) & ~7;
but sometimes the result lets the cursor partially outside the work area. I think after this line is necesary a correction: if((xpos + C->size) > (xwrk + xsiz)) xwrk += 8;
The same applies to vertical coordinates. What do you think about it?
Josu Onandia
Josu,
I donŽt know if you got a reply on this question.
I think you are right. Following should hold
xwrk <= xpos <= xpos+xsiz <= xwrk+C->xsize ywrk <= ypos <= ypos+ysiz <= ywrk+C->ysize
After short analysis I think, the two lines xwrk = (xpos - (C->xsize >> 1)) & ~7; ywrk = (ypos - (C->ysize >> 1)) & ~7; should be changed to xwrk = xpos & ~7; ywrk = ypos & ~7; to give the correct result.
Does it work ? Hartmut