- Fixed master brightness
This commit is contained in:
parent
53b3034e8b
commit
857bfacf1c
|
@ -229,7 +229,13 @@ void GPU_resortBGs(GPU *gpu)
|
|||
#endif
|
||||
}
|
||||
|
||||
void GPU_setMasterBrightness (GPU *gpu, u16 val)
|
||||
{
|
||||
u8 temp = (val&31);
|
||||
|
||||
gpu->MasterBrightFactor = (temp > 16 ? 16 : temp);
|
||||
gpu->MasterBrightMode = (val>>14);
|
||||
}
|
||||
|
||||
|
||||
/* Sets up LCD control variables for Display Engines A and B for quick reading */
|
||||
|
@ -1962,8 +1968,8 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
|||
// Reference: http://nocash.emubase.de/gbatek.htm#dsvideo (Under MASTER_BRIGHTNESS)
|
||||
/* Mightymax> it should be more effective if the windowmanager applies brightness when drawing */
|
||||
/* it will most likly take acceleration, while we are stuck here with CPU power */
|
||||
mBright = &(gpu->dispx_st)->dispx_MASTERBRIGHT.bits;
|
||||
switch (mBright->Mode)
|
||||
|
||||
switch (gpu->MasterBrightMode)
|
||||
{
|
||||
// Disabled
|
||||
case 0:
|
||||
|
@ -1973,15 +1979,9 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
|||
case 1:
|
||||
{
|
||||
COLOR dstColor;
|
||||
unsigned int masterBrightFactor = mBright->Factor;
|
||||
unsigned int masterBrightFactor = gpu->MasterBrightFactor;
|
||||
u16 * colors = bright_more_colors[masterBrightFactor];
|
||||
|
||||
if (mBright->FactorEx)
|
||||
{
|
||||
/* the formular would create only white, as (r + (31-r)) = 31 */
|
||||
/* white = enable all bits */
|
||||
memset(dst,0xFF, 256*2 /* sizeof(COLOR) */) ;
|
||||
} else {
|
||||
/* when we wont do anything, we dont need to loop */
|
||||
if (!masterBrightFactor) break ;
|
||||
|
||||
|
@ -2005,7 +2005,6 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
|||
#endif
|
||||
T2WriteWord (dst, i16 << 1, dstColor.val);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2030,16 +2029,9 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
|||
|
||||
*/
|
||||
COLOR dstColor;
|
||||
unsigned int masterBrightFactor = mBright->Factor ;
|
||||
unsigned int masterBrightFactor = gpu->MasterBrightFactor;
|
||||
u16 * colors = bright_less_colors[masterBrightFactor];
|
||||
|
||||
if (mBright->FactorEx)
|
||||
{
|
||||
/* the formular would create only black, as (r - r) = 0 */
|
||||
/* black = disable all bits */
|
||||
memset(dst,0, 256*2 /* sizeof(COLOR) */) ;
|
||||
} else
|
||||
{
|
||||
/* when we wont do anything, we dont need to loop */
|
||||
if (!masterBrightFactor) break;
|
||||
|
||||
|
@ -2061,7 +2053,6 @@ void GPU_ligne(NDS_Screen * screen, u16 l)
|
|||
#endif
|
||||
T2WriteWord (dst, i16 << 1, dstColor.val);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -276,30 +276,6 @@ typedef union
|
|||
} DISPCAPCNT;
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
this structure is to represent global FX
|
||||
applied to each pixel (each color of x555 is expanded to 6 bits)
|
||||
|
||||
Lighten : New = Old + (63-Old) * Factor/16
|
||||
Darken : New = Old - Old * Factor/16
|
||||
*******************************************************************************/
|
||||
|
||||
struct _MASTER_BRIGHT
|
||||
{
|
||||
/* 0*/ u8 Factor:4; // combine with (Factor / 16) of white/black
|
||||
/* 4*/ u8 FactorEx:1; // if true use white or black
|
||||
/* 5*/ u8 :3;
|
||||
/* 8*/ u8 :5;
|
||||
/*14*/ u8 Mode:2; // 0=off, 1=Lighten, 2=Darken, 3=?
|
||||
};
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct _MASTER_BRIGHT bits;
|
||||
u16 val;
|
||||
} MASTER_BRIGHT;
|
||||
|
||||
/*******************************************************************************
|
||||
this structure holds everything and should be mapped to
|
||||
* core A : 0x04000000
|
||||
|
@ -319,7 +295,6 @@ typedef struct _reg_dispx {
|
|||
DISP3DCNT dispA_DISP3DCNT; // 0x04000060
|
||||
DISPCAPCNT dispA_DISPCAPCNT; // 0x04000064
|
||||
u32 dispA_DISPMMEMFIFO; // 0x04000068
|
||||
MASTER_BRIGHT dispx_MASTERBRIGHT; // 0x0400x06C
|
||||
} REG_DISPx ;
|
||||
|
||||
|
||||
|
@ -540,6 +515,9 @@ struct _GPU
|
|||
u8 sprBMPMode;
|
||||
u32 sprEnable;
|
||||
|
||||
u8 MasterBrightMode;
|
||||
u32 MasterBrightFactor;
|
||||
|
||||
void (*spriteRender)(GPU * gpu, u16 l, u8 * dst, u8 * prioTab);
|
||||
};
|
||||
|
||||
|
@ -559,8 +537,6 @@ static void REG_DISPx_pack_test(GPU * gpu)
|
|||
printf ("\t%02x\n", (long)(&r->dispA_DISP3DCNT) - (long)r);
|
||||
printf ("\t%02x\n", (long)(&r->dispA_DISPCAPCNT) - (long)r);
|
||||
printf ("\t%02x\n", (long)(&r->dispA_DISPMMEMFIFO) - (long)r);
|
||||
printf ("\t%02x\n", (long)(&r->dispx_MASTERBRIGHT) - (long)r);
|
||||
printf ("\t%04x\n", r->dispx_MASTERBRIGHT);
|
||||
}
|
||||
|
||||
|
||||
|
@ -632,6 +608,7 @@ int GPU_ChangeGraphicsCore(int coreid);
|
|||
|
||||
void GPU_set_DISPCAPCNT(GPU * gpu, u32 val) ;
|
||||
void GPU_ligne(NDS_Screen * screen, u16 l) ;
|
||||
void GPU_setMasterBrightness (GPU *gpu, u16 val);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1188,6 +1188,17 @@ void FASTCALL MMU_write16(u32 proc, u32 adr, u16 val)
|
|||
return;
|
||||
}
|
||||
|
||||
case REG_DISPA_MASTERBRIGHT:
|
||||
{
|
||||
GPU_setMasterBrightness (MainScreen.gpu, val);
|
||||
break;
|
||||
}
|
||||
case REG_DISPB_MASTERBRIGHT:
|
||||
{
|
||||
GPU_setMasterBrightness (SubScreen.gpu, val);
|
||||
break;
|
||||
}
|
||||
|
||||
case REG_POWCNT1 :
|
||||
if(proc == ARMCPU_ARM9)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue