From 0b02eb7712f1272fa7f38b0af41968b53af3b5a8 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 13 Aug 2012 00:02:23 +0300 Subject: add support for software-enhanced rendering --- plugins/gpulib/gpu.c | 15 +++++++++++++++ plugins/gpulib/gpu.h | 4 ++++ plugins/gpulib/vout_pl.c | 43 +++++++++++++++++++++++++++++++++---------- 3 files changed, 52 insertions(+), 10 deletions(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index 46e92d1..462e301 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -9,6 +9,7 @@ */ #include +#include #include #include "gpu.h" @@ -137,8 +138,21 @@ long GPUinit(void) { int ret; ret = vout_init(); + + gpu.state.enhancement_available = 0; ret |= renderer_init(); + if (gpu.state.enhancement_available) { + if (gpu.enhancement_bufer == NULL) + gpu.enhancement_bufer = malloc(2048 * 1024 * 2 + 1024 * 512 * 2); + if (gpu.enhancement_bufer == NULL) + gpu_log("OOM for enhancement buffer\n"); + } + else if (gpu.enhancement_bufer != NULL) { + free(gpu.enhancement_bufer); + gpu.enhancement_bufer = NULL; + } + gpu.state.frame_count = &gpu.zero; gpu.state.hcnt = &gpu.zero; gpu.frameskip.active = 0; @@ -669,6 +683,7 @@ void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) gpu.state.hcnt = cbs->gpu_hcnt; gpu.state.frame_count = cbs->gpu_frame_count; gpu.state.allow_interlace = cbs->gpu_neon.allow_interlace; + gpu.state.enhancement_enable = cbs->gpu_neon.enhancement_enable; if (cbs->pl_vout_set_raw_vram) cbs->pl_vout_set_raw_vram(gpu.vram); diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index 1cbe38c..f514395 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -67,6 +67,9 @@ struct psx_gpu { uint32_t old_interlace:1; uint32_t allow_interlace:2; uint32_t blanked:1; + uint32_t enhancement_available:1; + uint32_t enhancement_enable:1; + uint32_t enhancement_active:1; uint32_t *frame_count; uint32_t *hcnt; /* hsync count */ struct { @@ -87,6 +90,7 @@ struct psx_gpu { uint32_t last_flip_frame; uint32_t pending_fill[3]; } frameskip; + void *enhancement_bufer; }; extern struct psx_gpu gpu; diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 0bd1ecf..47c28f3 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -31,13 +31,25 @@ static void check_mode_change(void) { static uint32_t old_status; static int old_h; + int w = gpu.screen.hres; + int h = gpu.screen.h; + + gpu.state.enhancement_active = + gpu.enhancement_bufer != NULL && gpu.state.enhancement_enable + && w <= 512 && h <= 256 && !gpu.status.rgb24; + + if (gpu.state.enhancement_active) { + w *= 2; + h *= 2; + } // width|rgb24 change? - if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || gpu.screen.h != old_h) + if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) { old_status = gpu.status.reg; - old_h = gpu.screen.h; - screen_buf = cbs->pl_vout_set_mode(gpu.screen.hres, gpu.screen.h, + old_h = h; + + screen_buf = cbs->pl_vout_set_mode(w, h, (gpu.status.rgb24 && !cbs->only_16bpp) ? 24 : 16); } } @@ -50,6 +62,8 @@ static void blit(void) int h = gpu.screen.h; uint16_t *vram = gpu.vram; int stride = gpu.screen.hres; + int vram_stride = 1024; + int vram_mask = 1024 * 512 - 1; int fb_offs, doffs; uint8_t *dest; @@ -57,7 +71,16 @@ static void blit(void) if (dest == NULL) return; - fb_offs = y * 1024 + x; + if (gpu.state.enhancement_active) { + vram = gpu.enhancement_bufer; + x *= 2; + y *= 2; + w *= 2; + h *= 2; + stride *= 2; + vram_mask = 1024 * 1024 - 1; + } + fb_offs = y * vram_stride + x; // only do centering, at least for now doffs = (stride - w) / 2 & ~1; @@ -66,17 +89,17 @@ static void blit(void) { if (cbs->only_16bpp) { dest += doffs * 2; - for (; h-- > 0; dest += stride * 2, fb_offs += 1024) + for (; h-- > 0; dest += stride * 2, fb_offs += vram_stride) { - fb_offs &= 1024*512-1; + fb_offs &= vram_mask; bgr888_to_rgb565(dest, vram + fb_offs, w * 3); } } else { dest += (doffs / 8) * 24; - for (; h-- > 0; dest += stride * 3, fb_offs += 1024) + for (; h-- > 0; dest += stride * 3, fb_offs += vram_stride) { - fb_offs &= 1024*512-1; + fb_offs &= vram_mask; bgr888_to_rgb888(dest, vram + fb_offs, w * 3); } } @@ -84,9 +107,9 @@ static void blit(void) else { dest += doffs * 2; - for (; h-- > 0; dest += stride * 2, fb_offs += 1024) + for (; h-- > 0; dest += stride * 2, fb_offs += vram_stride) { - fb_offs &= 1024*512-1; + fb_offs &= vram_mask; bgr555_to_rgb565(dest, vram + fb_offs, w * 2); } } -- cgit v1.2.3 From f1359c5758c2e745b1cbec63e21445fa65f7cafe Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 13 Aug 2012 02:53:21 +0300 Subject: psx_gpu: switch enhancement to 2048 width otherwise games that position framebuffers horizontally corrupt the display. --- plugins/gpulib/vout_pl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 47c28f3..5131034 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -78,7 +78,8 @@ static void blit(void) w *= 2; h *= 2; stride *= 2; - vram_mask = 1024 * 1024 - 1; + vram_stride = 2048; + vram_mask = 2048 * 1024 - 1; } fb_offs = y * vram_stride + x; -- cgit v1.2.3 From e929dec505f8d3692248fe0d42c84a37c994ad39 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 18 Aug 2012 02:37:49 +0300 Subject: psx_gpu: switch to 1024 width again. --- plugins/gpulib/gpu.c | 16 ++-------------- plugins/gpulib/gpu.h | 5 +++-- plugins/gpulib/vout_pl.c | 9 +++++---- 3 files changed, 10 insertions(+), 20 deletions(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index 462e301..e133f07 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -9,7 +9,6 @@ */ #include -#include #include #include "gpu.h" @@ -138,21 +137,8 @@ long GPUinit(void) { int ret; ret = vout_init(); - - gpu.state.enhancement_available = 0; ret |= renderer_init(); - if (gpu.state.enhancement_available) { - if (gpu.enhancement_bufer == NULL) - gpu.enhancement_bufer = malloc(2048 * 1024 * 2 + 1024 * 512 * 2); - if (gpu.enhancement_bufer == NULL) - gpu_log("OOM for enhancement buffer\n"); - } - else if (gpu.enhancement_bufer != NULL) { - free(gpu.enhancement_bufer); - gpu.enhancement_bufer = NULL; - } - gpu.state.frame_count = &gpu.zero; gpu.state.hcnt = &gpu.zero; gpu.frameskip.active = 0; @@ -164,6 +150,7 @@ long GPUinit(void) long GPUshutdown(void) { + renderer_finish(); return vout_finish(); } @@ -221,6 +208,7 @@ void GPUwriteStatus(uint32_t data) gpu.screen.vres = vres[(gpu.status.reg >> 19) & 3]; update_width(); update_height(); + renderer_notify_res_change(); break; default: if ((cmd & 0xf0) == 0x10) diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index f514395..5ad2a46 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -67,7 +67,6 @@ struct psx_gpu { uint32_t old_interlace:1; uint32_t allow_interlace:2; uint32_t blanked:1; - uint32_t enhancement_available:1; uint32_t enhancement_enable:1; uint32_t enhancement_active:1; uint32_t *frame_count; @@ -90,7 +89,7 @@ struct psx_gpu { uint32_t last_flip_frame; uint32_t pending_fill[3]; } frameskip; - void *enhancement_bufer; + uint16_t *enhancement_bufer; }; extern struct psx_gpu gpu; @@ -102,11 +101,13 @@ int do_cmd_list(uint32_t *list, int count, int *last_cmd); struct rearmed_cbs; int renderer_init(void); +void renderer_finish(void); void renderer_sync_ecmds(uint32_t * ecmds); void renderer_update_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); +void renderer_notify_res_change(void); int vout_init(void); int vout_finish(void); diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 5131034..cbd8034 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -68,18 +68,19 @@ static void blit(void) uint8_t *dest; dest = (uint8_t *)screen_buf; - if (dest == NULL) + if (dest == NULL || w == 0 || stride == 0) return; if (gpu.state.enhancement_active) { - vram = gpu.enhancement_bufer; + // this layout is gpu_neon specific.. + vram = gpu.enhancement_bufer + + (x + 8) / stride * 1024 * 1024; x *= 2; y *= 2; w *= 2; h *= 2; stride *= 2; - vram_stride = 2048; - vram_mask = 2048 * 1024 - 1; + vram_mask = 1024 * 1024 - 1; } fb_offs = y * vram_stride + x; -- cgit v1.2.3 From 50f9355a2338111d940ed408f52fe1defe4df23e Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 19 Aug 2012 00:37:50 +0300 Subject: psx_gpu: start handling vram loads/moves for enhancement --- plugins/gpulib/vout_pl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index cbd8034..5c74914 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -77,8 +77,8 @@ static void blit(void) (x + 8) / stride * 1024 * 1024; x *= 2; y *= 2; - w *= 2; - h *= 2; + w = (w - 2) * 2; + h = (h * 2) - 1; stride *= 2; vram_mask = 1024 * 1024 - 1; } -- cgit v1.2.3 From 9ee0fd5b333039b1140d90f935aa9299825f1e42 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 19 Aug 2012 22:39:49 +0300 Subject: start mmap'ing vram, with hugetlb if possible --- plugins/gpulib/gpu.c | 44 ++++++++++++++++++++++++++++++++++++++++---- plugins/gpulib/gpu.h | 5 +++-- 2 files changed, 43 insertions(+), 6 deletions(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index e133f07..b61bff6 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -24,7 +24,7 @@ //#define log_anomaly gpu_log #define log_anomaly(...) -struct psx_gpu gpu __attribute__((aligned(2048))); +struct psx_gpu gpu; static noinline int do_cmd_buffer(uint32_t *data, int count); static void finish_vram_transfer(int is_read); @@ -133,6 +133,22 @@ static noinline void get_gpu_info(uint32_t data) } } +// double, for overdraw guard +#define VRAM_SIZE (1024 * 512 * 2 * 2) + +static int map_vram(void) +{ + gpu.vram = gpu.mmap(VRAM_SIZE); + if (gpu.vram != NULL) { + gpu.vram += 4096 / 2; + return 0; + } + else { + fprintf(stderr, "could not map vram, expect crashes\n"); + return -1; + } +} + long GPUinit(void) { int ret; @@ -145,13 +161,26 @@ long GPUinit(void) gpu.cmd_len = 0; do_reset(); + if (gpu.mmap != NULL) { + if (map_vram() != 0) + ret = -1; + } return ret; } long GPUshutdown(void) { + long ret; + renderer_finish(); - return vout_finish(); + ret = vout_finish(); + if (gpu.vram != NULL) { + gpu.vram -= 4096 / 2; + gpu.munmap(gpu.vram, VRAM_SIZE); + } + gpu.vram = NULL; + + return ret; } void GPUwriteStatus(uint32_t data) @@ -584,13 +613,13 @@ long GPUfreeze(uint32_t type, struct GPUFreeze *freeze) case 1: // save if (gpu.cmd_len > 0) flush_cmd_buffer(); - memcpy(freeze->psxVRam, gpu.vram, sizeof(gpu.vram)); + memcpy(freeze->psxVRam, gpu.vram, 1024 * 512 * 2); memcpy(freeze->ulControl, gpu.regs, sizeof(gpu.regs)); memcpy(freeze->ulControl + 0xe0, gpu.ex_regs, sizeof(gpu.ex_regs)); freeze->ulStatus = gpu.status.reg; break; case 0: // load - memcpy(gpu.vram, freeze->psxVRam, sizeof(gpu.vram)); + memcpy(gpu.vram, freeze->psxVRam, 1024 * 512 * 2); memcpy(gpu.regs, freeze->ulControl, sizeof(gpu.regs)); memcpy(gpu.ex_regs, freeze->ulControl + 0xe0, sizeof(gpu.ex_regs)); gpu.status.reg = freeze->ulStatus; @@ -673,6 +702,13 @@ void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) gpu.state.allow_interlace = cbs->gpu_neon.allow_interlace; gpu.state.enhancement_enable = cbs->gpu_neon.enhancement_enable; + gpu.mmap = cbs->mmap; + gpu.munmap = cbs->munmap; + + // delayed vram mmap + if (gpu.vram == NULL) + map_vram(); + if (cbs->pl_vout_set_raw_vram) cbs->pl_vout_set_raw_vram(gpu.vram); renderer_set_config(cbs); diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index 5ad2a46..78a8990 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -17,10 +17,9 @@ extern "C" { #define CMD_BUFFER_LEN 1024 struct psx_gpu { - uint16_t vram[1024 * 512]; - uint16_t guard[1024 * 512]; // overdraw guard uint32_t cmd_buffer[CMD_BUFFER_LEN]; uint32_t regs[16]; + uint16_t *vram; union { uint32_t reg; struct { @@ -90,6 +89,8 @@ struct psx_gpu { uint32_t pending_fill[3]; } frameskip; uint16_t *enhancement_bufer; + void *(*mmap)(unsigned int size); + void (*munmap)(void *ptr, unsigned int size); }; extern struct psx_gpu gpu; -- cgit v1.2.3 From 06bc35c833797ce9f6f3287abf954f037bb12319 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 27 Aug 2012 02:04:01 +0300 Subject: various enhancement tweaks --- plugins/gpulib/vout_pl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 5c74914..2116422 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -77,8 +77,8 @@ static void blit(void) (x + 8) / stride * 1024 * 1024; x *= 2; y *= 2; - w = (w - 2) * 2; - h = (h * 2) - 1; + w = w * 2; + h = h * 2; stride *= 2; vram_mask = 1024 * 1024 - 1; } @@ -130,6 +130,7 @@ void vout_update(void) void vout_blank(void) { + gpu.state.enhancement_active = 0; check_mode_change(); if (cbs->pl_vout_raw_flip == NULL) { int bytespp = gpu.status.rgb24 ? 3 : 2; -- cgit v1.2.3 From 7956599fa5f666016f71870d9889748c97839041 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 22 Oct 2012 01:42:56 +0300 Subject: psx_gpu: select buffers differently this handles weird drawing areas better --- plugins/gpulib/vout_pl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 2116422..6e2764c 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -130,11 +130,15 @@ void vout_update(void) void vout_blank(void) { - gpu.state.enhancement_active = 0; - check_mode_change(); if (cbs->pl_vout_raw_flip == NULL) { + int w = gpu.screen.hres; + int h = gpu.screen.h; int bytespp = gpu.status.rgb24 ? 3 : 2; - memset(screen_buf, 0, gpu.screen.hres * gpu.screen.h * bytespp); + if (gpu.state.enhancement_active) { + w *= 2; + h *= 2; + } + memset(screen_buf, 0, w * h * bytespp); screen_buf = cbs->pl_vout_flip(); } } -- cgit v1.2.3 From a8be0debff95f9b56af7c4c19eaacee782a09e28 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 23 Oct 2012 00:34:30 +0300 Subject: gpu: move enhacement logic out of vout_pl --- plugins/gpulib/gpu.h | 3 ++- plugins/gpulib/vout_pl.c | 16 ++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index 78a8990..ea5051e 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -88,7 +88,8 @@ struct psx_gpu { uint32_t last_flip_frame; uint32_t pending_fill[3]; } frameskip; - uint16_t *enhancement_bufer; + uint16_t *(*get_enhancement_bufer) + (int *x, int *y, int *w, int *h, int *stride, int *mask); void *(*mmap)(unsigned int size); void (*munmap)(void *ptr, unsigned int size); }; diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 6e2764c..9a84432 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -35,7 +35,7 @@ static void check_mode_change(void) int h = gpu.screen.h; gpu.state.enhancement_active = - gpu.enhancement_bufer != NULL && gpu.state.enhancement_enable + gpu.get_enhancement_bufer != NULL && gpu.state.enhancement_enable && w <= 512 && h <= 256 && !gpu.status.rgb24; if (gpu.state.enhancement_active) { @@ -71,17 +71,9 @@ static void blit(void) if (dest == NULL || w == 0 || stride == 0) return; - if (gpu.state.enhancement_active) { - // this layout is gpu_neon specific.. - vram = gpu.enhancement_bufer + - (x + 8) / stride * 1024 * 1024; - x *= 2; - y *= 2; - w = w * 2; - h = h * 2; - stride *= 2; - vram_mask = 1024 * 1024 - 1; - } + if (gpu.state.enhancement_active) + vram = gpu.get_enhancement_bufer(&x, &y, &w, &h, &stride, &vram_mask); + fb_offs = y * vram_stride + x; // only do centering, at least for now -- cgit v1.2.3 From fa56d36096cd4ab2b227ce2aa61c8404b8874689 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 29 Oct 2012 01:08:35 +0200 Subject: move blit to core, allow filtering while blitting also adds libpicofe to pull filters from, and filter related UI stuff --- plugins/gpulib/gpu.h | 2 +- plugins/gpulib/vout_pl.c | 91 ++++++++++++++---------------------------------- 2 files changed, 27 insertions(+), 66 deletions(-) (limited to 'plugins/gpulib') diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index ea5051e..d11f991 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -89,7 +89,7 @@ struct psx_gpu { uint32_t pending_fill[3]; } frameskip; uint16_t *(*get_enhancement_bufer) - (int *x, int *y, int *w, int *h, int *stride, int *mask); + (int *x, int *y, int *w, int *h, int *vram_h); void *(*mmap)(unsigned int size); void (*munmap)(void *ptr, unsigned int size); }; diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 9a84432..11307e2 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -15,7 +15,6 @@ #include "../../frontend/plugin_lib.h" static const struct rearmed_cbs *cbs; -static void *screen_buf; int vout_init(void) { @@ -27,7 +26,7 @@ int vout_finish(void) return 0; } -static void check_mode_change(void) +static void check_mode_change(int force) { static uint32_t old_status; static int old_h; @@ -44,95 +43,57 @@ static void check_mode_change(void) } // width|rgb24 change? - if ((gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) + if (force || (gpu.status.reg ^ old_status) & ((7<<16)|(1<<21)) || h != old_h) { old_status = gpu.status.reg; old_h = h; - screen_buf = cbs->pl_vout_set_mode(w, h, + cbs->pl_vout_set_mode(w, h, (gpu.status.rgb24 && !cbs->only_16bpp) ? 24 : 16); } } -static void blit(void) +void vout_update(void) { int x = gpu.screen.x & ~1; // alignment needed by blitter int y = gpu.screen.y; int w = gpu.screen.w; int h = gpu.screen.h; uint16_t *vram = gpu.vram; - int stride = gpu.screen.hres; - int vram_stride = 1024; - int vram_mask = 1024 * 512 - 1; - int fb_offs, doffs; - uint8_t *dest; - - dest = (uint8_t *)screen_buf; - if (dest == NULL || w == 0 || stride == 0) + int vram_h = 512; + + if (w == 0 || h == 0) return; + check_mode_change(0); if (gpu.state.enhancement_active) - vram = gpu.get_enhancement_bufer(&x, &y, &w, &h, &stride, &vram_mask); - - fb_offs = y * vram_stride + x; + vram = gpu.get_enhancement_bufer(&x, &y, &w, &h, &vram_h); - // only do centering, at least for now - doffs = (stride - w) / 2 & ~1; - - if (gpu.status.rgb24) - { - if (cbs->only_16bpp) { - dest += doffs * 2; - for (; h-- > 0; dest += stride * 2, fb_offs += vram_stride) - { - fb_offs &= vram_mask; - bgr888_to_rgb565(dest, vram + fb_offs, w * 3); - } - } - else { - dest += (doffs / 8) * 24; - for (; h-- > 0; dest += stride * 3, fb_offs += vram_stride) - { - fb_offs &= vram_mask; - bgr888_to_rgb888(dest, vram + fb_offs, w * 3); - } - } - } - else - { - dest += doffs * 2; - for (; h-- > 0; dest += stride * 2, fb_offs += vram_stride) - { - fb_offs &= vram_mask; - bgr555_to_rgb565(dest, vram + fb_offs, w * 2); + if (y + h > vram_h) { + if (y + h - vram_h > h / 2) { + // wrap + y = 0; + h -= vram_h - y; } + else + // clip + h = vram_h - y; } - screen_buf = cbs->pl_vout_flip(); -} + vram += y * 1024 + x; -void vout_update(void) -{ - check_mode_change(); - if (cbs->pl_vout_raw_flip) - cbs->pl_vout_raw_flip(gpu.screen.x, gpu.screen.y); - else - blit(); + cbs->pl_vout_flip(vram, 1024, gpu.status.rgb24, w, h); } void vout_blank(void) { - if (cbs->pl_vout_raw_flip == NULL) { - int w = gpu.screen.hres; - int h = gpu.screen.h; - int bytespp = gpu.status.rgb24 ? 3 : 2; - if (gpu.state.enhancement_active) { - w *= 2; - h *= 2; - } - memset(screen_buf, 0, w * h * bytespp); - screen_buf = cbs->pl_vout_flip(); + int w = gpu.screen.hres; + int h = gpu.screen.h; + if (gpu.state.enhancement_active) { + w *= 2; + h *= 2; } + cbs->pl_vout_flip(NULL, 1024, gpu.status.rgb24, w, h); } long GPUopen(void **unused) @@ -141,7 +102,7 @@ long GPUopen(void **unused) gpu.frameskip.frame_ready = 1; cbs->pl_vout_open(); - screen_buf = cbs->pl_vout_flip(); + check_mode_change(1); return 0; } -- cgit v1.2.3