cleaned up windowdecision, fixed wrong x coordinate useed for sprites in windows
This commit is contained in:
parent
d4c83d21f4
commit
11b680df05
|
@ -493,91 +493,174 @@ void GPU_setMASTER_BRIGHT (GPU *gpu, u16 v)
|
||||||
gpu->masterBright.val = v;
|
gpu->masterBright.val = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check whether (x,y) is within the rectangle (including wraparounds) */
|
||||||
|
INLINE BOOL withinRect (u8 x,u8 y, u16 startX, u16 startY, u16 endX, u16 endY)
|
||||||
|
{
|
||||||
|
if (startX > endX) {
|
||||||
|
/* if start > end, the window gets wrapped around */
|
||||||
|
/* check if the current pixel is in that x-wrapped area */
|
||||||
|
if ((x < endX) || (x >= startX))
|
||||||
|
{
|
||||||
|
/* x coord for this window is matched */
|
||||||
|
/* now check for y coord */
|
||||||
|
if (startY > endY)
|
||||||
|
{
|
||||||
|
/* rectangle is wrapped around y */
|
||||||
|
if ((y < endY) || (y >= startY))
|
||||||
|
{
|
||||||
|
/* y coord was mathched too, the point is within! */
|
||||||
|
return TRUE ;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* y coord is outside */
|
||||||
|
return FALSE ;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* y coord is not wraped, simple rectangle check */
|
||||||
|
if ((y < endY) && (y >= startY))
|
||||||
|
{
|
||||||
|
/* y coord was mathched too, the point is within! */
|
||||||
|
return TRUE ;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* y coord is outside */
|
||||||
|
return FALSE ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* x coord is not matched, so we dont need to check further */
|
||||||
|
return FALSE ;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* if start >= end, it just describes an rectangle */
|
||||||
|
/* check we are within the limits */
|
||||||
|
if ((x >= startX) && (x < endX))
|
||||||
|
{
|
||||||
|
/* within the x range */
|
||||||
|
/* now check for y coord */
|
||||||
|
if (startY > endY)
|
||||||
|
{
|
||||||
|
/* rectangle is wrapped around y */
|
||||||
|
if ((y < endY) || (y >= startY))
|
||||||
|
{
|
||||||
|
/* y coord was mathched too, the point is within! */
|
||||||
|
return TRUE ;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* y coord is outside */
|
||||||
|
return FALSE ;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* y coord is not wraped, simple rectangle check */
|
||||||
|
if ((y < endY) && (y >= startY))
|
||||||
|
{
|
||||||
|
/* y coord was mathched too, the point is within! */
|
||||||
|
return TRUE ;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* y coord is outside */
|
||||||
|
return FALSE ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
/* not within this rectangle */
|
||||||
|
return FALSE ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
INLINE BOOL renderline_checkWindowInside(GPU *gpu, u8 bgnum, u16 x, u16 y, BOOL *draw, BOOL *effect)
|
INLINE BOOL renderline_checkWindowInside(GPU *gpu, u8 bgnum, u16 x, u16 y, BOOL *draw, BOOL *effect)
|
||||||
{
|
{
|
||||||
/* priority to check the window regions: win0,win1,winobj */
|
/* priority to check the window regions: win0,win1,winobj */
|
||||||
if (gpu->dispCnt.bits.Win0_Enable) /* highest priority */
|
if (gpu->dispCnt.bits.Win0_Enable) /* highest priority */
|
||||||
{
|
{
|
||||||
if (((gpu->WINDOW_XDIM[0].val) && (gpu->WINDOW_YDIM[0].val)) &&
|
if (withinRect( x,y,
|
||||||
((((x >= gpu->WINDOW_XDIM[0].bits.start) && (x < gpu->WINDOW_XDIM[0].bits.end)) /* || (gpu->WINDOW_XDIM[1].bits.end==0)*/)
|
gpu->WINDOW_XDIM[0].bits.start,gpu->WINDOW_YDIM[0].bits.start,
|
||||||
&&(y >= gpu->WINDOW_YDIM[0].bits.start) && (y < gpu->WINDOW_YDIM[0].bits.end)))
|
gpu->WINDOW_XDIM[0].bits.end,gpu->WINDOW_YDIM[0].bits.end
|
||||||
{
|
))
|
||||||
switch (bgnum) {
|
{
|
||||||
case 0:
|
switch (bgnum) {
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN0_BG0_Enable)
|
case 0:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN0_BG0_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
case 1:
|
break ;
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN0_BG1_Enable)
|
case 1:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN0_BG1_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
case 2:
|
break ;
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN0_BG2_Enable)
|
case 2:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN0_BG2_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
case 3:
|
break ;
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN0_BG3_Enable)
|
case 3:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN0_BG3_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
case 4:
|
break ;
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN0_OBJ_Enable)
|
case 4:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN0_OBJ_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
}
|
break ;
|
||||||
*effect = gpu->WINDOW_INCNT.bits.WIN0_Effect_Enable ;
|
}
|
||||||
return TRUE ;
|
*effect = gpu->WINDOW_INCNT.bits.WIN0_Effect_Enable ;
|
||||||
|
return TRUE ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gpu->dispCnt.bits.Win1_Enable) /* mid priority */
|
if (gpu->dispCnt.bits.Win1_Enable) /* mid priority */
|
||||||
{
|
{
|
||||||
if (((gpu->WINDOW_XDIM[1].val) && (gpu->WINDOW_YDIM[1].val)) &&
|
if (withinRect( x,y,
|
||||||
((((x >= gpu->WINDOW_XDIM[1].bits.start) && (x < gpu->WINDOW_XDIM[1].bits.end)) /* || (gpu->WINDOW_XDIM[1].bits.end==0)*/)
|
gpu->WINDOW_XDIM[1].bits.start,gpu->WINDOW_YDIM[1].bits.start,
|
||||||
&&(y >= gpu->WINDOW_YDIM[1].bits.start) && (y < gpu->WINDOW_YDIM[1].bits.end)))
|
gpu->WINDOW_XDIM[1].bits.end,gpu->WINDOW_YDIM[1].bits.end
|
||||||
{
|
))
|
||||||
switch (bgnum) {
|
{
|
||||||
case 0:
|
switch (bgnum) {
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN0_BG0_Enable)
|
case 0:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN1_BG0_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
case 1:
|
break ;
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN1_BG1_Enable)
|
case 1:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN1_BG1_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
case 2:
|
break ;
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN1_BG2_Enable)
|
case 2:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN1_BG2_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
case 3:
|
break ;
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN1_BG3_Enable)
|
case 3:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN1_BG3_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
case 4:
|
break ;
|
||||||
if (!gpu->WINDOW_INCNT.bits.WIN1_OBJ_Enable)
|
case 4:
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
if (!gpu->WINDOW_INCNT.bits.WIN1_OBJ_Enable)
|
||||||
else
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = TRUE ;
|
else
|
||||||
break ;
|
*draw = TRUE ;
|
||||||
}
|
break ;
|
||||||
*effect = gpu->WINDOW_INCNT.bits.WIN1_Effect_Enable ;
|
}
|
||||||
return TRUE ;
|
*effect = gpu->WINDOW_INCNT.bits.WIN1_Effect_Enable ;
|
||||||
|
return TRUE ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((gpu->dispCnt.bits.WinOBJ_Enable) && (bgnum==4)) /* low priority, but only applies to OBJ */
|
if ((gpu->dispCnt.bits.WinOBJ_Enable) && (bgnum==4)) /* low priority, but only applies to OBJ */
|
||||||
|
@ -594,90 +677,88 @@ INLINE BOOL renderline_checkWindowOutside(GPU *gpu, u8 bgnum, u16 x, u16 y, BOOL
|
||||||
/* priority to check the window regions: win0,win1,winobj */
|
/* priority to check the window regions: win0,win1,winobj */
|
||||||
if (gpu->dispCnt.bits.Win0_Enable) /* highest priority */
|
if (gpu->dispCnt.bits.Win0_Enable) /* highest priority */
|
||||||
{
|
{
|
||||||
if (((gpu->WINDOW_XDIM[0].val) && (gpu->WINDOW_YDIM[0].val)) &&
|
if (!withinRect( x,y,
|
||||||
((((x >= gpu->WINDOW_XDIM[0].bits.start) && (x < gpu->WINDOW_XDIM[0].bits.end)) /* || (gpu->WINDOW_XDIM[1].bits.end==0)*/)
|
gpu->WINDOW_XDIM[0].bits.start,gpu->WINDOW_YDIM[0].bits.start,
|
||||||
&&(y >= gpu->WINDOW_YDIM[0].bits.start) && (y < gpu->WINDOW_YDIM[0].bits.end)))
|
gpu->WINDOW_XDIM[0].bits.end,gpu->WINDOW_YDIM[0].bits.end
|
||||||
{
|
))
|
||||||
} else
|
{
|
||||||
{
|
switch (bgnum) {
|
||||||
switch (bgnum) {
|
case 0:
|
||||||
case 0:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG0_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG0_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
case 1:
|
||||||
case 1:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG1_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG1_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
case 2:
|
||||||
case 2:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG2_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG2_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
case 3:
|
||||||
case 3:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG3_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG3_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
case 4:
|
||||||
case 4:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN0_OBJ_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN0_OBJ_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
}
|
||||||
}
|
*effect = gpu->WINDOW_OUTCNT.bits.WIN0_Effect_Enable ;
|
||||||
*effect = gpu->WINDOW_OUTCNT.bits.WIN0_Effect_Enable ;
|
return TRUE ;
|
||||||
return TRUE ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gpu->dispCnt.bits.Win1_Enable) /* mid priority */
|
if (gpu->dispCnt.bits.Win1_Enable) /* mid priority */
|
||||||
{
|
{
|
||||||
if (((gpu->WINDOW_XDIM[1].val) && (gpu->WINDOW_YDIM[1].val)) &&
|
if (!withinRect( x,y,
|
||||||
((((x >= gpu->WINDOW_XDIM[1].bits.start) && (x < gpu->WINDOW_XDIM[1].bits.end)) /* || (gpu->WINDOW_XDIM[1].bits.end==0)*/)
|
gpu->WINDOW_XDIM[1].bits.start,gpu->WINDOW_YDIM[1].bits.start,
|
||||||
&&(y >= gpu->WINDOW_YDIM[1].bits.start) && (y < gpu->WINDOW_YDIM[1].bits.end)))
|
gpu->WINDOW_XDIM[1].bits.end,gpu->WINDOW_YDIM[1].bits.end
|
||||||
{
|
))
|
||||||
} else
|
{
|
||||||
{
|
switch (bgnum) {
|
||||||
switch (bgnum) {
|
case 0:
|
||||||
case 0:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN1_BG0_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN0_BG0_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
case 1:
|
||||||
case 1:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN1_BG1_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN1_BG1_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
case 2:
|
||||||
case 2:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN1_BG2_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN1_BG2_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
case 3:
|
||||||
case 3:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN1_BG3_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN1_BG3_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
case 4:
|
||||||
case 4:
|
if (!gpu->WINDOW_OUTCNT.bits.WIN1_OBJ_Enable)
|
||||||
if (!gpu->WINDOW_OUTCNT.bits.WIN1_OBJ_Enable)
|
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
||||||
*draw = FALSE ; /* drawing explicit disabled for thios bg in this rectangle */
|
else
|
||||||
else
|
*draw = TRUE ;
|
||||||
*draw = TRUE ;
|
break ;
|
||||||
break ;
|
}
|
||||||
}
|
*effect = gpu->WINDOW_OUTCNT.bits.WIN1_Effect_Enable ;
|
||||||
*effect = gpu->WINDOW_OUTCNT.bits.WIN1_Effect_Enable ;
|
return TRUE ;
|
||||||
return TRUE ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((gpu->dispCnt.bits.WinOBJ_Enable) && (bgnum==4)) /* low priority, but only applies to OBJ */
|
if ((gpu->dispCnt.bits.WinOBJ_Enable) && (bgnum==4)) /* low priority, but only applies to OBJ */
|
||||||
|
@ -1216,19 +1297,19 @@ void extRotBG(GPU * gpu, u8 num, u8 * DST)
|
||||||
#define RENDERS_A(a) \
|
#define RENDERS_A(a) \
|
||||||
if((a)&&(prioTab[sprX]>=prio)) \
|
if((a)&&(prioTab[sprX]>=prio)) \
|
||||||
{ \
|
{ \
|
||||||
renderline_setFinalColor(gpu, sprX << 1,4,dst, c,x,l); \
|
renderline_setFinalColor(gpu, sprX << 1,4,dst, c,sprX,l); \
|
||||||
prioTab[sprX] = prio; \
|
prioTab[sprX] = prio; \
|
||||||
}
|
}
|
||||||
#define RENDERS_B(c) \
|
#define RENDERS_B(c) \
|
||||||
if((c)&&(prioTab[sprX]>=prio)) \
|
if((c)&&(prioTab[sprX]>=prio)) \
|
||||||
{ \
|
{ \
|
||||||
renderline_setFinalColor(gpu, sprX << 1,4,dst, T1ReadWord(pal, (c) << 1),x,l); \
|
renderline_setFinalColor(gpu, sprX << 1,4,dst, T1ReadWord(pal, (c) << 1),sprX,l); \
|
||||||
prioTab[sprX] = prio; \
|
prioTab[sprX] = prio; \
|
||||||
}
|
}
|
||||||
#define RENDERS_C(c,d) \
|
#define RENDERS_C(c,d) \
|
||||||
if((c)&&(prioTab[sprX]>=prio)) \
|
if((c)&&(prioTab[sprX]>=prio)) \
|
||||||
{ \
|
{ \
|
||||||
renderline_setFinalColor(gpu, (sprX d) << 1,4,dst, T1ReadWord(pal, ((c)+(spriteInfo->PaletteIndex<<4)) << 1),x,l); \
|
renderline_setFinalColor(gpu, (sprX d) << 1,4,dst, T1ReadWord(pal, ((c)+(spriteInfo->PaletteIndex<<4)) << 1),(sprX d),l); \
|
||||||
prioTab[sprX d] = prio; \
|
prioTab[sprX d] = prio; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue