forked from len0rd/rockbox
Major Rockboy update.
1) Adapt Rockboy to smaller screens (H10, X5, and iPod Nano). 2) Add the ability to use a preset palette on color targets. Choose 'Set Palette' from the main menu. 3) Clean up the code to remove any unused code and variables. 4) Changed tabs to spaces. 5) Disable reading and writing sound when sound is disabled. 6) Disbable writing to the RTC since it is not implemented yet. 7) Minor optimizations from WAC gnuboy CE and iBoy. 8) Massive clean up of code to make it appear consistent. 9) Change all C++ style comments to C style. 10) Completely reorganize dynarec. Add fixmes to all unimplemented opcodes. Add debug writes for all opcodes. Attempt to implement a few opcodes myself. 11) Silence some warnings when built using dynarec. 12) Minor reshuffling of IRAM, may or not offer a speed increase. 13) Include fixes found in the short-lived gnuboy CVS. All in all, there's about a 10% improvement on my test roms when sound is disabled and slight improvement with sound. Especially noticable when there are few sprites on screen and less action is occurring. See FS #6567. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12216 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
1026c0f5b2
commit
2882b26a99
48 changed files with 4891 additions and 5419 deletions
|
@ -23,32 +23,23 @@
|
|||
|
||||
void stat_trigger(void)
|
||||
{
|
||||
static const int condbits[4] = { 0x08, 0x30, 0x20, 0x00 };
|
||||
int flag = 0;
|
||||
static const int condbits[4] = { 0x08, 0x10, 0x20, 0x00 };
|
||||
int flag = 0;
|
||||
|
||||
if ((R_LY < 0x91) && (R_LY == R_LYC))
|
||||
{
|
||||
R_STAT |= 0x04;
|
||||
if (R_STAT & 0x40) flag = IF_STAT;
|
||||
}
|
||||
else R_STAT &= ~0x04;
|
||||
if (R_LY == R_LYC)
|
||||
{
|
||||
R_STAT |= 0x04;
|
||||
if (R_STAT & 0x40) flag = IF_STAT;
|
||||
}
|
||||
else R_STAT &= ~0x04;
|
||||
|
||||
if (R_STAT & condbits[R_STAT&3]) flag = IF_STAT;
|
||||
if (R_STAT & condbits[R_STAT&3]) flag = IF_STAT;
|
||||
|
||||
if (!(R_LCDC & 0x80)) flag = 0;
|
||||
|
||||
hw_interrupt(flag, IF_STAT);
|
||||
if (!(R_LCDC & 0x80)) flag = 0;
|
||||
|
||||
hw_interrupt(flag, IF_STAT);
|
||||
}
|
||||
|
||||
void stat_write(byte b)
|
||||
{
|
||||
R_STAT = (R_STAT & 0x07) | (b & 0x78);
|
||||
if (!hw.cgb &&!(R_STAT & 2)) /* DMG STAT write bug => interrupt */
|
||||
hw_interrupt(IF_STAT, IF_STAT);
|
||||
stat_trigger();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* stat_change is called when a transition results in a change to the
|
||||
* LCD STAT condition (the low 2 bits of R_STAT). It raises or lowers
|
||||
|
@ -58,118 +49,118 @@ void stat_write(byte b)
|
|||
|
||||
static void stat_change(int stat)
|
||||
{
|
||||
stat &= 3;
|
||||
R_STAT = (R_STAT & 0x7C) | stat;
|
||||
stat &= 3;
|
||||
R_STAT = (R_STAT & 0x7C) | stat;
|
||||
|
||||
if (stat != 1) hw_interrupt(0, IF_VBLANK);
|
||||
/* hw_interrupt((stat == 1) ? IF_VBLANK : 0, IF_VBLANK); */
|
||||
stat_trigger();
|
||||
if (stat != 1) hw_interrupt(0, IF_VBLANK);
|
||||
/* hw_interrupt((stat == 1) ? IF_VBLANK : 0, IF_VBLANK); */
|
||||
stat_trigger();
|
||||
}
|
||||
|
||||
|
||||
void lcdc_change(byte b)
|
||||
{
|
||||
byte old = R_LCDC;
|
||||
R_LCDC = b;
|
||||
if ((R_LCDC ^ old) & 0x80) /* lcd on/off change */
|
||||
{
|
||||
R_LY = 0;
|
||||
stat_change(2);
|
||||
C = 40;
|
||||
lcd_begin();
|
||||
}
|
||||
byte old = R_LCDC;
|
||||
R_LCDC = b;
|
||||
if ((R_LCDC ^ old) & 0x80) /* lcd on/off change */
|
||||
{
|
||||
R_LY = 0;
|
||||
stat_change(2);
|
||||
C = 40;
|
||||
lcd_begin();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void lcdc_trans(void)
|
||||
{
|
||||
if (!(R_LCDC & 0x80))
|
||||
{
|
||||
while (C <= 0)
|
||||
{
|
||||
switch ((byte)(R_STAT & 3))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
stat_change(2);
|
||||
C += 40;
|
||||
break;
|
||||
case 2:
|
||||
stat_change(3);
|
||||
C += 86;
|
||||
break;
|
||||
case 3:
|
||||
stat_change(0);
|
||||
if (hw.hdma & 0x80)
|
||||
hw_hdma();
|
||||
else
|
||||
C += 102;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (C <= 0)
|
||||
{
|
||||
switch ((byte)(R_STAT & 3))
|
||||
{
|
||||
case 1:
|
||||
if (!(hw.ilines & IF_VBLANK))
|
||||
{
|
||||
C += 218;
|
||||
hw_interrupt(IF_VBLANK, IF_VBLANK);
|
||||
break;
|
||||
}
|
||||
if (R_LY == 0)
|
||||
{
|
||||
lcd_begin();
|
||||
stat_change(2);
|
||||
C += 40;
|
||||
break;
|
||||
}
|
||||
else if (R_LY < 152)
|
||||
C += 228;
|
||||
else if (R_LY == 152)
|
||||
C += 28;
|
||||
else
|
||||
{
|
||||
R_LY = -1;
|
||||
C += 200;
|
||||
}
|
||||
R_LY++;
|
||||
stat_trigger();
|
||||
break;
|
||||
case 2:
|
||||
if (!(R_LCDC & 0x80))
|
||||
{
|
||||
while (C <= 0)
|
||||
{
|
||||
switch ((byte)(R_STAT & 3))
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
stat_change(2);
|
||||
C += 40;
|
||||
break;
|
||||
case 2:
|
||||
stat_change(3);
|
||||
C += 86;
|
||||
break;
|
||||
case 3:
|
||||
stat_change(0);
|
||||
if (hw.hdma & 0x80)
|
||||
hw_hdma();
|
||||
else
|
||||
C += 102;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (C <= 0)
|
||||
{
|
||||
switch ((byte)(R_STAT & 3))
|
||||
{
|
||||
case 1:
|
||||
if (!(hw.ilines & IF_VBLANK))
|
||||
{
|
||||
C += 218;
|
||||
hw_interrupt(IF_VBLANK, IF_VBLANK);
|
||||
break;
|
||||
}
|
||||
if (R_LY == 0)
|
||||
{
|
||||
lcd_begin();
|
||||
stat_change(2);
|
||||
C += 40;
|
||||
break;
|
||||
}
|
||||
else if (R_LY < 152)
|
||||
C += 228;
|
||||
else if (R_LY == 152)
|
||||
C += 28;
|
||||
else
|
||||
{
|
||||
R_LY = -1;
|
||||
C += 200;
|
||||
}
|
||||
R_LY++;
|
||||
stat_trigger();
|
||||
break;
|
||||
case 2:
|
||||
if (fb.enabled)
|
||||
lcd_refreshline();
|
||||
stat_change(3);
|
||||
C += 86;
|
||||
break;
|
||||
case 3:
|
||||
stat_change(0);
|
||||
if (hw.hdma & 0x80)
|
||||
hw_hdma();
|
||||
/* FIXME -- how much of the hblank does hdma use?? */
|
||||
/* else */
|
||||
C += 102;
|
||||
break;
|
||||
case 0:
|
||||
if (++R_LY >= 144)
|
||||
{
|
||||
if (cpu.halt)
|
||||
{
|
||||
hw_interrupt(IF_VBLANK, IF_VBLANK);
|
||||
C += 228;
|
||||
}
|
||||
else C += 10;
|
||||
stat_change(1);
|
||||
break;
|
||||
}
|
||||
stat_change(2);
|
||||
C += 40;
|
||||
break;
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
stat_change(0);
|
||||
if (hw.hdma & 0x80)
|
||||
hw_hdma();
|
||||
/* FIXME -- how much of the hblank does hdma use?? */
|
||||
/* else */
|
||||
C += 102;
|
||||
break;
|
||||
case 0:
|
||||
if (++R_LY >= 144)
|
||||
{
|
||||
if (cpu.halt)
|
||||
{
|
||||
hw_interrupt(IF_VBLANK, IF_VBLANK);
|
||||
C += 228;
|
||||
}
|
||||
else C += 10;
|
||||
stat_change(1);
|
||||
break;
|
||||
}
|
||||
stat_change(2);
|
||||
C += 40;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue