{
int ret = vout_init();
gpu.status.reg = 0x14802000;
+ gpu.status.blanking = 1;
+ gpu.regs[3] = 1;
+ gpu.screen.hres = gpu.screen.w = 320;
+ gpu.screen.vres = gpu.screen.h = 240;
gpu.lcf_hc = &gpu.zero;
return ret;
}
gpu.screen.h = sh;
}
+static noinline void decide_frameskip(void)
+{
+ gpu.frameskip.frame_ready = !gpu.frameskip.active;
+
+ if (!gpu.frameskip.active && *gpu.frameskip.advice)
+ gpu.frameskip.active = 1;
+ else
+ gpu.frameskip.active = 0;
+}
+
void GPUwriteStatus(uint32_t data)
{
static const short hres[8] = { 256, 368, 320, 384, 512, 512, 640, 640 };
static const short vres[4] = { 240, 480, 256, 480 };
uint32_t cmd = data >> 24;
- if (cmd < ARRAY_SIZE(gpu.regs))
+ if (cmd < ARRAY_SIZE(gpu.regs)) {
+ if (cmd != 0 && gpu.regs[cmd] == data)
+ return;
gpu.regs[cmd] = data;
+ }
+
+ gpu.state.fb_dirty = 1;
switch (cmd) {
case 0x00:
case 0x05:
gpu.screen.x = data & 0x3ff;
gpu.screen.y = (data >> 10) & 0x3ff;
+ if (gpu.frameskip.enabled)
+ decide_frameskip();
break;
case 0x06:
gpu.screen.x1 = data & 0xfff;
static int check_cmd(uint32_t *data, int count)
{
int len, cmd, start, pos;
+ int vram_dirty = 0;
// process buffer
for (start = pos = 0; pos < count; )
gpu.status.reg |= (list[0] & 3) << 11;
break;
}
+ if (2 <= cmd && cmd < 0xc0)
+ vram_dirty = 1;
if (pos + len > count) {
cmd = -1;
}
if (pos - start > 0) {
- do_cmd_list(data + start, pos - start);
+ if (!gpu.frameskip.active)
+ do_cmd_list(data + start, pos - start);
start = pos;
}
break;
}
+ gpu.state.fb_dirty |= vram_dirty;
+
return count - pos;
}
long GPUfreeze(uint32_t type, GPUFreeze_t *freeze)
{
+ int i;
+
switch (type) {
case 1: // save
if (gpu.cmd_len > 0)
memcpy(gpu.vram, freeze->psxVRam, sizeof(gpu.vram));
memcpy(gpu.regs, freeze->ulControl, sizeof(gpu.regs));
gpu.status.reg = freeze->ulStatus;
- GPUwriteStatus((5 << 24) | gpu.regs[5]);
- GPUwriteStatus((7 << 24) | gpu.regs[7]);
- GPUwriteStatus((8 << 24) | gpu.regs[8]);
+ for (i = 8; i > 0; i--) {
+ gpu.regs[i] ^= 1; // avoid reg change detection
+ GPUwriteStatus((i << 24) | (gpu.regs[i] ^ 1));
+ }
break;
}
void GPUupdateLace(void)
{
- if (!gpu.status.blanking)
+ if (gpu.frameskip.enabled && !gpu.frameskip.frame_ready)
+ return;
+
+ if (!gpu.status.blanking && gpu.state.fb_dirty) {
blit();
+ gpu.state.fb_dirty = 0;
+ }
}
long GPUopen(void)
{
+ gpu.frameskip.enabled = cbs->frameskip;
+ gpu.frameskip.advice = &cbs->fskip_advice;
+
cbs->pl_fbdev_open();
screen_buf = cbs->pl_fbdev_flip();
return 0;
void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_)
{
cbs = cbs_;
+ gpu.frameskip.enabled = cbs->frameskip;
+ gpu.frameskip.advice = &cbs->fskip_advice;
+ gpu.frameskip.active = gpu.frameskip.frame_ready = 0;
}
// vim:shiftwidth=2:expandtab