aboutsummaryrefslogtreecommitdiff
path: root/plugins/gpu_neon
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/gpu_neon')
-rw-r--r--plugins/gpu_neon/gpu.c69
-rw-r--r--plugins/gpu_neon/gpu.h11
-rw-r--r--plugins/gpu_neon/peops_if.c4
-rw-r--r--plugins/gpu_neon/psx_gpu_if.c9
-rw-r--r--plugins/gpu_neon/test.c2
-rw-r--r--plugins/gpu_neon/unai_if.cpp4
-rw-r--r--plugins/gpu_neon/vout_fb.c29
-rw-r--r--plugins/gpu_neon/vout_sdl.c23
8 files changed, 95 insertions, 56 deletions
diff --git a/plugins/gpu_neon/gpu.c b/plugins/gpu_neon/gpu.c
index 02dd372..339cdfd 100644
--- a/plugins/gpu_neon/gpu.c
+++ b/plugins/gpu_neon/gpu.c
@@ -29,6 +29,7 @@ struct psx_gpu gpu __attribute__((aligned(2048)));
static noinline void do_reset(void)
{
memset(gpu.regs, 0, sizeof(gpu.regs));
+ memset(gpu.ex_regs, 0, sizeof(gpu.ex_regs));
gpu.status.reg = 0x14802000;
gpu.gp0 = 0;
gpu.regs[3] = 1;
@@ -264,10 +265,10 @@ static void start_vram_transfer(uint32_t pos_word, uint32_t size_word, int is_re
if (gpu.dma.h)
log_anomaly("start_vram_transfer while old unfinished\n");
- gpu.dma.x = pos_word & 1023;
- gpu.dma.y = (pos_word >> 16) & 511;
- gpu.dma.w = size_word & 0xffff; // ?
- gpu.dma.h = size_word >> 16;
+ gpu.dma.x = pos_word & 0x3ff;
+ gpu.dma.y = (pos_word >> 16) & 0x1ff;
+ gpu.dma.w = size_word & 0x3ff;
+ gpu.dma.h = (size_word >> 16) & 0x1ff;
gpu.dma.offset = 0;
renderer_flush_queues();
@@ -275,6 +276,7 @@ static void start_vram_transfer(uint32_t pos_word, uint32_t size_word, int is_re
gpu.status.img = 1;
// XXX: wrong for width 1
memcpy(&gpu.gp0, VRAM_MEM_XY(gpu.dma.x, gpu.dma.y), 4);
+ gpu.state.last_vram_read_frame = *gpu.state.frame_count;
}
else {
renderer_invalidate_caches(gpu.dma.x, gpu.dma.y, gpu.dma.w, gpu.dma.h);
@@ -362,7 +364,7 @@ static int check_cmd(uint32_t *data, int count)
return count - pos;
}
-void flush_cmd_buffer(void)
+static void flush_cmd_buffer(void)
{
int left = check_cmd(gpu.cmd_buffer, gpu.cmd_len);
if (left > 0)
@@ -533,8 +535,65 @@ long GPUfreeze(uint32_t type, struct GPUFreeze *freeze)
return 1;
}
+void GPUupdateLace(void)
+{
+ if (gpu.cmd_len > 0)
+ flush_cmd_buffer();
+ renderer_flush_queues();
+
+ if (gpu.status.blanking || !gpu.state.fb_dirty)
+ return;
+
+ if (gpu.frameskip.set) {
+ if (!gpu.frameskip.frame_ready) {
+ if (*gpu.state.frame_count - gpu.frameskip.last_flip_frame < 9)
+ return;
+ gpu.frameskip.active = 0;
+ }
+ gpu.frameskip.frame_ready = 0;
+ }
+
+ vout_update();
+ gpu.state.fb_dirty = 0;
+}
+
void GPUvBlank(int is_vblank, int lcf)
{
+ int interlace = gpu.state.allow_interlace
+ && gpu.status.interlace && gpu.status.dheight;
+ // interlace doesn't look nice on progressive displays,
+ // so we have this "auto" mode here for games that don't read vram
+ if (gpu.state.allow_interlace == 2
+ && *gpu.state.frame_count - gpu.state.last_vram_read_frame > 1)
+ {
+ interlace = 0;
+ }
+ if (interlace || interlace != gpu.state.old_interlace) {
+ gpu.state.old_interlace = interlace;
+
+ if (gpu.cmd_len > 0)
+ flush_cmd_buffer();
+ renderer_flush_queues();
+ renderer_set_interlace(interlace, !lcf);
+ }
+}
+
+#include "../../frontend/plugin_lib.h"
+
+void GPUrearmedCallbacks(const struct rearmed_cbs *cbs)
+{
+ gpu.frameskip.set = cbs->frameskip;
+ gpu.frameskip.advice = &cbs->fskip_advice;
+ gpu.frameskip.active = 0;
+ gpu.frameskip.frame_ready = 1;
+ gpu.state.hcnt = cbs->gpu_hcnt;
+ gpu.state.frame_count = cbs->gpu_frame_count;
+ gpu.state.allow_interlace = cbs->gpu_neon.allow_interlace;
+
+ if (cbs->pl_vout_set_raw_vram)
+ cbs->pl_vout_set_raw_vram(gpu.vram);
+ renderer_set_config(cbs);
+ vout_set_config(cbs);
}
// vim:shiftwidth=2:expandtab
diff --git a/plugins/gpu_neon/gpu.h b/plugins/gpu_neon/gpu.h
index 6aa933e..36fdef8 100644
--- a/plugins/gpu_neon/gpu.h
+++ b/plugins/gpu_neon/gpu.h
@@ -64,6 +64,8 @@ struct psx_gpu {
uint32_t zero;
struct {
uint32_t fb_dirty:1;
+ uint32_t old_interlace:1;
+ uint32_t allow_interlace:2;
uint32_t *frame_count;
uint32_t *hcnt; /* hsync count */
struct {
@@ -72,6 +74,7 @@ struct psx_gpu {
uint32_t frame;
uint32_t hcnt;
} last_list;
+ uint32_t last_vram_read_frame;
} state;
struct {
int32_t set:3; /* -1 auto, 0 off, 1-3 fixed */
@@ -87,7 +90,6 @@ struct psx_gpu {
extern struct psx_gpu gpu;
extern const unsigned char cmd_lengths[256];
-void flush_cmd_buffer(void);
void do_cmd_list(uint32_t *list, int count);
@@ -97,10 +99,13 @@ int renderer_init(void);
void renderer_sync_ecmds(uint32_t * ecmds);
void renderer_invalidate_caches(int x, int y, int w, int h);
void renderer_flush_queues(void);
+void renderer_set_interlace(int enable, int is_odd);
void renderer_set_config(const struct rearmed_cbs *config);
-int vout_init(void);
-int vout_finish(void);
+int vout_init(void);
+int vout_finish(void);
+void vout_update(void);
+void vout_set_config(const struct rearmed_cbs *config);
/* listing these here for correct linkage if rasterizer uses c++ */
struct GPUFreeze;
diff --git a/plugins/gpu_neon/peops_if.c b/plugins/gpu_neon/peops_if.c
index 48fd431..2e967f2 100644
--- a/plugins/gpu_neon/peops_if.c
+++ b/plugins/gpu_neon/peops_if.c
@@ -385,6 +385,10 @@ void renderer_flush_queues(void)
{
}
+void renderer_set_interlace(int enable, int is_odd)
+{
+}
+
#include "../../frontend/plugin_lib.h"
void renderer_set_config(const struct rearmed_cbs *cbs)
diff --git a/plugins/gpu_neon/psx_gpu_if.c b/plugins/gpu_neon/psx_gpu_if.c
index 8907ac0..470f68e 100644
--- a/plugins/gpu_neon/psx_gpu_if.c
+++ b/plugins/gpu_neon/psx_gpu_if.c
@@ -48,6 +48,15 @@ void renderer_flush_queues(void)
flush_render_block_buffer(&egpu);
}
+void renderer_set_interlace(int enable, int is_odd)
+{
+ egpu.interlace_mode &= ~(RENDER_INTERLACE_ENABLED|RENDER_INTERLACE_ODD);
+ if (enable)
+ egpu.interlace_mode |= RENDER_INTERLACE_ENABLED;
+ if (is_odd)
+ egpu.interlace_mode |= RENDER_INTERLACE_ODD;
+}
+
void renderer_set_config(const struct rearmed_cbs *cbs)
{
}
diff --git a/plugins/gpu_neon/test.c b/plugins/gpu_neon/test.c
index be271b6..e523e20 100644
--- a/plugins/gpu_neon/test.c
+++ b/plugins/gpu_neon/test.c
@@ -89,6 +89,8 @@ int main(int argc, char *argv[])
pcnt_init();
renderer_init();
memcpy(gpu.vram, state.vram, sizeof(gpu.vram));
+ if ((state.gpu_register[8] & 0x24) == 0x24)
+ renderer_set_interlace(1, !(state.status >> 31));
start_cycles = pcnt_get();
diff --git a/plugins/gpu_neon/unai_if.cpp b/plugins/gpu_neon/unai_if.cpp
index 4e3e7f9..072993a 100644
--- a/plugins/gpu_neon/unai_if.cpp
+++ b/plugins/gpu_neon/unai_if.cpp
@@ -272,6 +272,10 @@ void renderer_flush_queues(void)
{
}
+void renderer_set_interlace(int enable, int is_odd)
+{
+}
+
#ifndef TEST
#include "../../frontend/plugin_lib.h"
diff --git a/plugins/gpu_neon/vout_fb.c b/plugins/gpu_neon/vout_fb.c
index a45b5f1..20c8ff3 100644
--- a/plugins/gpu_neon/vout_fb.c
+++ b/plugins/gpu_neon/vout_fb.c
@@ -88,28 +88,13 @@ static void blit(void)
screen_buf = cbs->pl_vout_flip();
}
-void GPUupdateLace(void)
+void vout_update(void)
{
- if (gpu.status.blanking || !gpu.state.fb_dirty)
- return;
-
- if (gpu.frameskip.set) {
- if (!gpu.frameskip.frame_ready) {
- if (*gpu.state.frame_count - gpu.frameskip.last_flip_frame < 9)
- return;
- }
- gpu.frameskip.frame_ready = 0;
- }
-
- if (gpu.cmd_len > 0)
- flush_cmd_buffer();
- renderer_flush_queues();
check_mode_change();
if (cbs->pl_vout_raw_flip)
cbs->pl_vout_raw_flip(gpu.screen.x, gpu.screen.y);
else
blit();
- gpu.state.fb_dirty = 0;
}
long GPUopen(void **unused)
@@ -128,19 +113,9 @@ long GPUclose(void)
return 0;
}
-void GPUrearmedCallbacks(const struct rearmed_cbs *cbs_)
+void vout_set_config(const struct rearmed_cbs *cbs_)
{
cbs = cbs_;
- gpu.frameskip.set = cbs->frameskip;
- gpu.frameskip.advice = &cbs->fskip_advice;
- gpu.frameskip.active = 0;
- gpu.frameskip.frame_ready = 1;
- gpu.state.hcnt = cbs->gpu_hcnt;
- gpu.state.frame_count = cbs->gpu_frame_count;
-
- if (cbs->pl_vout_set_raw_vram)
- cbs->pl_vout_set_raw_vram(gpu.vram);
- renderer_set_config(cbs_);
}
// vim:shiftwidth=2:expandtab
diff --git a/plugins/gpu_neon/vout_sdl.c b/plugins/gpu_neon/vout_sdl.c
index 0830c56..db1ae96 100644
--- a/plugins/gpu_neon/vout_sdl.c
+++ b/plugins/gpu_neon/vout_sdl.c
@@ -48,7 +48,7 @@ int vout_finish(void)
return 0;
}
-static void blit(void)
+void vout_update(void)
{
uint32_t *d;
int i;
@@ -77,17 +77,6 @@ static void blit(void)
SDL_UpdateRect(screen, 0, 0, 1024, 512);
}
-void GPUupdateLace(void)
-{
- if (!gpu.status.blanking && gpu.state.fb_dirty) {
- if (gpu.cmd_len > 0)
- flush_cmd_buffer();
- renderer_flush_queues();
- blit();
- gpu.state.fb_dirty = 0;
- }
-}
-
long GPUopen(void **dpy)
{
*dpy = x11_display;
@@ -99,16 +88,8 @@ long GPUclose(void)
return 0;
}
-#include "../../frontend/plugin_lib.h"
-
-void GPUrearmedCallbacks(const struct rearmed_cbs *cbs)
+void vout_set_config(const struct rearmed_cbs *cbs)
{
- gpu.state.hcnt = cbs->gpu_hcnt;
- gpu.state.frame_count = cbs->gpu_frame_count;
-
- if (cbs->pl_vout_set_raw_vram)
- cbs->pl_vout_set_raw_vram(gpu.vram);
- renderer_set_config(cbs);
}
// vim:shiftwidth=2:expandtab