1
0
Fork 0
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:
Tom Ross 2007-02-06 21:41:08 +00:00
parent 1026c0f5b2
commit 2882b26a99
48 changed files with 4891 additions and 5419 deletions

View file

@ -30,9 +30,9 @@
struct svar
{
int len;
char key[4];
void *ptr;
int len;
char key[4];
void *ptr;
};
static int ver;
@ -41,247 +41,243 @@ static int hramofs, hiofs, palofs, oamofs, wavofs;
struct svar svars[] =
{
I4("GbSs", &ver),
I2("PC ", &PC),
I2("SP ", &SP),
I2("HL ", &HL),
I4("GbSs", &ver),
I2("PC ", &PC),
I2("SP ", &SP),
I2("HL ", &HL),
#ifdef DYNAREC
I1("A ", &A),
I1("B ", &A),
I1("C ", &A),
I1("D ", &A),
I1("E ", &A),
I1("F ", &A),
I1("A ", &A),
I1("B ", &A),
I1("C ", &A),
I1("D ", &A),
I1("E ", &A),
I1("F ", &A),
#else
I2("BC ", &BC),
I2("DE ", &DE),
I2("AF ", &AF),
#endif
I4("IME ", &cpu.ime),
I4("ima ", &cpu.ima),
I4("spd ", &cpu.speed),
I4("halt", &cpu.halt),
I4("div ", &cpu.div),
I4("tim ", &cpu.tim),
I4("lcdc", &cpu.lcdc),
I4("snd ", &cpu.snd),
I1("ints", &hw.ilines),
I1("pad ", &hw.pad),
I4("cgb ", &hw.cgb),
I4("gba ", &hw.gba),
I4("mbcm", &mbc.model),
I4("romb", &mbc.rombank),
I4("ramb", &mbc.rambank),
I4("enab", &mbc.enableram),
I4("batt", &mbc.batt),
I4("rtcR", &rtc.sel),
I4("rtcL", &rtc.latch),
I4("rtcC", &rtc.carry),
I4("rtcS", &rtc.stop),
I4("rtcd", &rtc.d),
I4("rtch", &rtc.h),
I4("rtcm", &rtc.m),
I4("rtcs", &rtc.s),
I4("rtct", &rtc.t),
I1("rtR8", &rtc.regs[0]),
I1("rtR9", &rtc.regs[1]),
I1("rtRA", &rtc.regs[2]),
I1("rtRB", &rtc.regs[3]),
I1("rtRC", &rtc.regs[4]),
I2("BC ", &BC),
I2("DE ", &DE),
I2("AF ", &AF),
#endif
I4("IME ", &cpu.ime),
I4("ima ", &cpu.ima),
I4("spd ", &cpu.speed),
I4("halt", &cpu.halt),
I4("div ", &cpu.div),
I4("tim ", &cpu.tim),
I4("lcdc", &cpu.lcdc),
I4("snd ", &cpu.snd),
I1("ints", &hw.ilines),
I1("pad ", &hw.pad),
I4("cgb ", &hw.cgb),
I4("mbcm", &mbc.model),
I4("romb", &mbc.rombank),
I4("ramb", &mbc.rambank),
I4("enab", &mbc.enableram),
I4("batt", &mbc.batt),
I4("rtcR", &rtc.sel),
I4("rtcL", &rtc.latch),
I4("rtcC", &rtc.carry),
I4("rtcS", &rtc.stop),
I4("rtcd", &rtc.d),
I4("rtch", &rtc.h),
I4("rtcm", &rtc.m),
I4("rtcs", &rtc.s),
I4("rtct", &rtc.t),
I1("rtR8", &rtc.regs[0]),
I1("rtR9", &rtc.regs[1]),
I1("rtRA", &rtc.regs[2]),
I1("rtRB", &rtc.regs[3]),
I1("rtRC", &rtc.regs[4]),
I4("S1on", &snd.ch[0].on),
I4("S1p ", &snd.ch[0].pos),
I4("S1c ", &snd.ch[0].cnt),
I4("S1ec", &snd.ch[0].encnt),
I4("S1sc", &snd.ch[0].swcnt),
I4("S1sf", &snd.ch[0].swfreq),
I4("S1on", &snd.ch[0].on),
I4("S1p ", &snd.ch[0].pos),
I4("S1c ", &snd.ch[0].cnt),
I4("S1ec", &snd.ch[0].encnt),
I4("S1sc", &snd.ch[0].swcnt),
I4("S2on", &snd.ch[1].on),
I4("S2p ", &snd.ch[1].pos),
I4("S2c ", &snd.ch[1].cnt),
I4("S2ec", &snd.ch[1].encnt),
I4("S3on", &snd.ch[2].on),
I4("S3p ", &snd.ch[2].pos),
I4("S3c ", &snd.ch[2].cnt),
I4("S4on", &snd.ch[3].on),
I4("S4p ", &snd.ch[3].pos),
I4("S4c ", &snd.ch[3].cnt),
I4("S4ec", &snd.ch[3].encnt),
I4("hdma", &hw.hdma),
I4("sram", &sramblock),
I4("iram", &iramblock),
I4("vram", &vramblock),
I4("hi ", &hiofs),
I4("pal ", &palofs),
I4("oam ", &oamofs),
I4("wav ", &wavofs),
/* NOSAVE is a special code to prevent the rest of the table
* from being saved, used to support old stuff for backwards
* compatibility... */
NOSAVE,
I4("S2on", &snd.ch[1].on),
I4("S2p ", &snd.ch[1].pos),
I4("S2c ", &snd.ch[1].cnt),
I4("S2ec", &snd.ch[1].encnt),
I4("S3on", &snd.ch[2].on),
I4("S3p ", &snd.ch[2].pos),
I4("S3c ", &snd.ch[2].cnt),
I4("S4on", &snd.ch[3].on),
I4("S4p ", &snd.ch[3].pos),
I4("S4c ", &snd.ch[3].cnt),
I4("S4ec", &snd.ch[3].encnt),
I4("hdma", &hw.hdma),
I4("sram", &sramblock),
I4("iram", &iramblock),
I4("vram", &vramblock),
I4("hi ", &hiofs),
I4("pal ", &palofs),
I4("oam ", &oamofs),
/* NOSAVE is a special code to prevent the rest of the table
* from being saved, used to support old stuff for backwards
* compatibility... */
NOSAVE,
/* the following are obsolete as of 0x104 */
I4("hram", &hramofs),
R(P1), R(SB), R(SC),
R(DIV), R(TIMA), R(TMA), R(TAC),
R(IE), R(IF),
R(LCDC), R(STAT), R(LY), R(LYC),
R(SCX), R(SCY), R(WX), R(WY),
R(BGP), R(OBP0), R(OBP1),
R(DMA),
/* the following are obsolete as of 0x104 */
I4("hram", &hramofs),
/* I4("gba ", &hw.gba), */
/* I4("S1sf", &snd.ch[0].swfreq), */
I4("wav ", &wavofs),
R(P1), R(SB), R(SC),
R(DIV), R(TIMA), R(TMA), R(TAC),
R(IE), R(IF),
R(LCDC), R(STAT), R(LY), R(LYC),
R(SCX), R(SCY), R(WX), R(WY),
R(BGP), R(OBP0), R(OBP1),
R(DMA),
R(VBK), R(SVBK), R(KEY1),
R(BCPS), R(BCPD), R(OCPS), R(OCPD),
R(VBK), R(SVBK), R(KEY1),
R(BCPS), R(BCPD), R(OCPS), R(OCPD),
R(NR10), R(NR11), R(NR12), R(NR13), R(NR14),
R(NR21), R(NR22), R(NR23), R(NR24),
R(NR30), R(NR31), R(NR32), R(NR33), R(NR34),
R(NR41), R(NR42), R(NR43), R(NR44),
R(NR50), R(NR51), R(NR52),
R(NR10), R(NR11), R(NR12), R(NR13), R(NR14),
R(NR21), R(NR22), R(NR23), R(NR24),
R(NR30), R(NR31), R(NR32), R(NR33), R(NR34),
R(NR41), R(NR42), R(NR43), R(NR44),
R(NR50), R(NR51), R(NR52),
I1("DMA1", &R_HDMA1),
I1("DMA2", &R_HDMA2),
I1("DMA3", &R_HDMA3),
I1("DMA4", &R_HDMA4),
I1("DMA5", &R_HDMA5),
END
I1("DMA1", &R_HDMA1),
I1("DMA2", &R_HDMA2),
I1("DMA3", &R_HDMA3),
I1("DMA4", &R_HDMA4),
I1("DMA5", &R_HDMA5),
END
};
void loadstate(int fd)
{
int i, j;
byte buf[4096];
un32 (*header)[2] = (un32 (*)[2])buf;
un32 d;
int irl = hw.cgb ? 8 : 2;
int vrl = hw.cgb ? 4 : 2;
int srl = mbc.ramsize << 1;
size_t base_offset;
int i, j;
byte buf[4096];
un32 (*header)[2] = (un32 (*)[2])buf;
un32 d;
int irl = hw.cgb ? 8 : 2;
int vrl = hw.cgb ? 4 : 2;
int srl = mbc.ramsize << 1;
size_t base_offset;
ver = hramofs = hiofs = palofs = oamofs = wavofs = 0;
ver = hramofs = hiofs = palofs = oamofs = wavofs = 0;
base_offset = lseek(fd, 0, SEEK_CUR);
base_offset = lseek(fd, 0, SEEK_CUR);
read(fd,buf, 4096);
for (j = 0; header[j][0]; j++)
{
for (i = 0; svars[i].ptr; i++)
{
if (header[j][0] != *(un32 *)svars[i].key)
continue;
d = LIL(header[j][1]);
switch (svars[i].len)
{
case 1:
*(byte *)svars[i].ptr = d;
break;
case 2:
*(un16 *)svars[i].ptr = d;
break;
case 4:
*(un32 *)svars[i].ptr = d;
break;
}
break;
}
}
read(fd,buf, 4096);
for (j = 0; header[j][0]; j++)
{
for (i = 0; svars[i].ptr; i++)
{
if (header[j][0] != *(un32 *)svars[i].key)
continue;
d = LIL(header[j][1]);
switch (svars[i].len)
{
case 1:
*(byte *)svars[i].ptr = d;
break;
case 2:
*(un16 *)svars[i].ptr = d;
break;
case 4:
*(un32 *)svars[i].ptr = d;
break;
}
break;
}
}
/* obsolete as of version 0x104 */
if (hramofs) memcpy(ram.hi+128, buf+hramofs, 127);
if (hiofs) memcpy(ram.hi, buf+hiofs, sizeof ram.hi);
if (palofs) memcpy(lcd.pal, buf+palofs, sizeof lcd.pal);
if (oamofs) memcpy(lcd.oam.mem, buf+oamofs, sizeof lcd.oam);
/* obsolete as of version 0x104 */
if (hramofs) memcpy(ram.hi+128, buf+hramofs, 127);
if (wavofs) memcpy(ram.hi+48, buf+wavofs, 16);
if (hiofs) memcpy(ram.hi, buf+hiofs, sizeof ram.hi);
if (palofs) memcpy(lcd.pal, buf+palofs, sizeof lcd.pal);
if (oamofs) memcpy(lcd.oam.mem, buf+oamofs, sizeof lcd.oam);
if (wavofs) memcpy(snd.wave, buf+wavofs, sizeof snd.wave);
else memcpy(snd.wave, ram.hi+0x30, 16); /* patch data from older files */
lseek(fd, base_offset + (iramblock << 12), SEEK_SET);
read(fd,ram.ibank, 4096*irl);
lseek(fd, base_offset + (vramblock << 12), SEEK_SET);
read(fd,lcd.vbank, 4096*vrl);
lseek(fd, base_offset + (sramblock << 12), SEEK_SET);
read(fd,ram.sbank, 4096*srl);
vram_dirty();
pal_dirty();
sound_dirty();
mem_updatemap();
lseek(fd, base_offset + (iramblock << 12), SEEK_SET);
read(fd,ram.ibank, 4096*irl);
lseek(fd, base_offset + (vramblock << 12), SEEK_SET);
read(fd,lcd.vbank, 4096*vrl);
lseek(fd, base_offset + (sramblock << 12), SEEK_SET);
read(fd,ram.sbank, 4096*srl);
vram_dirty();
pal_dirty();
sound_dirty();
mem_updatemap();
}
void savestate(int fd)
{
int i;
byte buf[4096];
un32 (*header)[2] = (un32 (*)[2])buf;
un32 d = 0;
int irl = hw.cgb ? 8 : 2;
int vrl = hw.cgb ? 4 : 2;
int srl = mbc.ramsize << 1;
size_t base_offset;
int i;
byte buf[4096];
un32 (*header)[2] = (un32 (*)[2])buf;
un32 d = 0;
int irl = hw.cgb ? 8 : 2;
int vrl = hw.cgb ? 4 : 2;
int srl = mbc.ramsize << 1;
size_t base_offset;
ver = 0x105;
iramblock = 1;
vramblock = 1+irl;
sramblock = 1+irl+vrl;
wavofs = 4096 - 784;
hiofs = 4096 - 768;
palofs = 4096 - 512;
oamofs = 4096 - 256;
memset(buf, 0, sizeof buf);
ver = 0x104;
iramblock = 1;
vramblock = 1+irl;
sramblock = 1+irl+vrl;
hiofs = 4096 - 768;
palofs = 4096 - 512;
oamofs = 4096 - 256;
memset(buf, 0, sizeof buf);
for (i = 0; svars[i].len > 0; i++)
{
header[i][0] = *(un32 *)svars[i].key;
switch (svars[i].len)
{
case 1:
d = *(byte *)svars[i].ptr;
break;
case 2:
d = *(un16 *)svars[i].ptr;
break;
case 4:
d = *(un32 *)svars[i].ptr;
break;
}
header[i][1] = LIL(d);
}
header[i][0] = header[i][1] = 0;
for (i = 0; svars[i].len > 0; i++)
{
header[i][0] = *(un32 *)svars[i].key;
switch (svars[i].len)
{
case 1:
d = *(byte *)svars[i].ptr;
break;
case 2:
d = *(un16 *)svars[i].ptr;
break;
case 4:
d = *(un32 *)svars[i].ptr;
break;
}
header[i][1] = LIL(d);
}
header[i][0] = header[i][1] = 0;
memcpy(buf+hiofs, ram.hi, sizeof ram.hi);
memcpy(buf+palofs, lcd.pal, sizeof lcd.pal);
memcpy(buf+oamofs, lcd.oam.mem, sizeof lcd.oam);
memcpy(buf+wavofs, snd.wave, sizeof snd.wave);
memcpy(buf+hiofs, ram.hi, sizeof ram.hi);
memcpy(buf+palofs, lcd.pal, sizeof lcd.pal);
memcpy(buf+oamofs, lcd.oam.mem, sizeof lcd.oam);
/* calculate base offset for output file */
/* (we'll seek relative to that from now on) */
base_offset = lseek(fd, 0, SEEK_CUR);
write(fd,buf, 4096);
lseek(fd, base_offset + (iramblock << 12), SEEK_SET);
write(fd,ram.ibank, 4096*irl);
lseek(fd, base_offset + (vramblock << 12), SEEK_SET);
write(fd,lcd.vbank, 4096*vrl);
lseek(fd, base_offset + (sramblock << 12), SEEK_SET);
write(fd,ram.sbank, 4096*srl);
/* calculate base offset for output file */
/* (we'll seek relative to that from now on) */
base_offset = lseek(fd, 0, SEEK_CUR);
write(fd,buf, 4096);
lseek(fd, base_offset + (iramblock << 12), SEEK_SET);
write(fd,ram.ibank, 4096*irl);
lseek(fd, base_offset + (vramblock << 12), SEEK_SET);
write(fd,lcd.vbank, 4096*vrl);
lseek(fd, base_offset + (sramblock << 12), SEEK_SET);
write(fd,ram.sbank, 4096*srl);
}