diff --git a/src_rebuild/PsyX/include/PsyX/PsyX_render.h b/src_rebuild/PsyX/include/PsyX/PsyX_render.h index f5ce8aa9..b78d8b91 100644 --- a/src_rebuild/PsyX/include/PsyX/PsyX_render.h +++ b/src_rebuild/PsyX/include/PsyX/PsyX_render.h @@ -191,6 +191,7 @@ extern void GR_SetWireframe(int enable); extern void GR_DestroyTexture(TextureID texture); extern void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b); +extern void GR_ClearVRAM(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b); extern void GR_UpdateVertexBuffer(const GrVertex* vertices, int count); extern void GR_DrawTriangles(int start_vertex, int triangles); diff --git a/src_rebuild/PsyX/src/psx/LIBGPU.C b/src_rebuild/PsyX/src/psx/LIBGPU.C index 909dbad9..8975e7d9 100644 --- a/src_rebuild/PsyX/src/psx/LIBGPU.C +++ b/src_rebuild/PsyX/src/psx/LIBGPU.C @@ -27,12 +27,18 @@ void(*drawsync_callback)(void) = NULL; int ClearImage(RECT16* rect, u_char r, u_char g, u_char b) { + GR_ClearVRAM(rect->x, rect->y, rect->w, rect->h, r, g, b); + + // TODO: clear all affected backbuffers GR_Clear(rect->x, rect->y, rect->w, rect->h, r, g, b); return 0; } int ClearImage2(RECT16* rect, u_char r, u_char g, u_char b) { + GR_ClearVRAM(rect->x, rect->y, rect->w, rect->h, r, g, b); + + // TODO: clear all affected backbuffers GR_Clear(rect->x, rect->y, rect->w, rect->h, r, g, b); return 0; } diff --git a/src_rebuild/PsyX/src/render/PsyX_render.cpp b/src_rebuild/PsyX/src/render/PsyX_render.cpp index a2693990..c0589b4e 100644 --- a/src_rebuild/PsyX/src/render/PsyX_render.cpp +++ b/src_rebuild/PsyX/src/render/PsyX_render.cpp @@ -1326,30 +1326,34 @@ void GR_DestroyTexture(TextureID texture) #endif } -void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b) +void GR_ClearVRAM(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b) { vram_need_update = 1; - framebuffer_need_update = 1; u_short* dst = vram + x + y * VRAM_WIDTH; - if (x+w > VRAM_WIDTH) + if (x + w > VRAM_WIDTH) w = VRAM_WIDTH - x; - if (y+h > VRAM_HEIGHT) - h = VRAM_HEIGHT-y; + if (y + h > VRAM_HEIGHT) + h = VRAM_HEIGHT - y; // clear VRAM region with given color - for (int i = 0; i < h; i++) + for (int i = 0; i < h; i++) { u_short* tmp = dst; - + for (int j = 0; j < w; j++) *tmp++ = r | (g << 5) | (b << 11); dst += VRAM_WIDTH; } - +} + +void GR_Clear(int x, int y, int w, int h, unsigned char r, unsigned char g, unsigned char b) +{ + framebuffer_need_update = 1; + #if defined(USE_OPENGL) glClearColor(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);