From 147a71b97633f788014710799b430d92166e9f80 Mon Sep 17 00:00:00 2001 From: Daniel Santos <47725160+DanielSant0s@users.noreply.github.com> Date: Thu, 30 Jun 2022 12:57:37 -0300 Subject: [PATCH] Finish dummy driver --- CMakeLists.txt | 2 +- include/SDL_config.h.cmake | 1 + src/render/SDL_render.c | 2 +- src/render/ps2/SDL_blendfillrect.c | 2 +- src/render/ps2/SDL_blendline.c | 2 +- src/render/ps2/SDL_blendpoint.c | 2 +- src/render/ps2/SDL_drawline.c | 2 +- src/render/ps2/SDL_drawpoint.c | 2 +- .../ps2/{SDL_render_sw.c => SDL_render_ps2.c} | 7 ++----- .../{SDL_render_sw_c.h => SDL_render_ps2.h} | 8 ++++---- src/render/ps2/SDL_rotate.c | 2 +- src/render/ps2/SDL_triangle.c | 20 +++++++++---------- src/render/ps2/SDL_triangle.h | 6 +++--- 13 files changed, 28 insertions(+), 30 deletions(-) rename src/render/ps2/{SDL_render_sw.c => SDL_render_ps2.c} (99%) rename src/render/ps2/{SDL_render_sw_c.h => SDL_render_ps2.h} (87%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fe57578e..8be55cc0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2575,7 +2575,7 @@ elseif(PS2) file(GLOB PS2_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/ps2/*.c ${SDL2_SOURCE_DIR}/src/render/ps2/*.c) - set(SOURCE_FILES ${SOURCE_FILES} ${PS2_VIDEO_SOURCES}) + list(APPEND SOURCE_FILES ${PS2_VIDEO_SOURCES}) set(SDL_VIDEO_OPENGL 0) set(HAVE_SDL_VIDEO TRUE) endif() diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index 61b320f4f..2d21b37dd 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -456,6 +456,7 @@ #cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@ #cmakedefine SDL_VIDEO_RENDER_METAL @SDL_VIDEO_RENDER_METAL@ #cmakedefine SDL_VIDEO_RENDER_VITA_GXM @SDL_VIDEO_RENDER_VITA_GXM@ +#cmakedefine SDL_VIDEO_RENDER_PS2 @SDL_VIDEO_RENDER_PS2@ #cmakedefine SDL_VIDEO_RENDER_PSP @SDL_VIDEO_RENDER_PSP@ /* Enable OpenGL support */ diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 702cde7ef..0220387bd 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -114,7 +114,7 @@ static const SDL_RenderDriver *render_drivers[] = { #if SDL_VIDEO_RENDER_DIRECTFB &DirectFB_RenderDriver, #endif -#if SDL_VIDEO_RENDER_PS2 +#if SDL_VIDEO_RENDER_PS2 && !SDL_RENDER_DISABLED &PS2_RenderDriver, #endif #if SDL_VIDEO_RENDER_PSP diff --git a/src/render/ps2/SDL_blendfillrect.c b/src/render/ps2/SDL_blendfillrect.c index d0e2f836d..41a0b83c1 100644 --- a/src/render/ps2/SDL_blendfillrect.c +++ b/src/render/ps2/SDL_blendfillrect.c @@ -352,6 +352,6 @@ SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, return status; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/ps2/SDL_blendline.c b/src/render/ps2/SDL_blendline.c index 363b7a887..d85eeb504 100644 --- a/src/render/ps2/SDL_blendline.c +++ b/src/render/ps2/SDL_blendline.c @@ -870,6 +870,6 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_PS2 && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/ps2/SDL_blendpoint.c b/src/render/ps2/SDL_blendpoint.c index ebdb685d1..aae201b7f 100644 --- a/src/render/ps2/SDL_blendpoint.c +++ b/src/render/ps2/SDL_blendpoint.c @@ -357,6 +357,6 @@ SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, return status; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_PS2 && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/ps2/SDL_drawline.c b/src/render/ps2/SDL_drawline.c index 15798b462..e97312fa8 100644 --- a/src/render/ps2/SDL_drawline.c +++ b/src/render/ps2/SDL_drawline.c @@ -208,6 +208,6 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_PS2 */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/ps2/SDL_drawpoint.c b/src/render/ps2/SDL_drawpoint.c index 9e1407499..27a43e81c 100644 --- a/src/render/ps2/SDL_drawpoint.c +++ b/src/render/ps2/SDL_drawpoint.c @@ -109,6 +109,6 @@ SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_PS2 && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/ps2/SDL_render_sw.c b/src/render/ps2/SDL_render_ps2.c similarity index 99% rename from src/render/ps2/SDL_render_sw.c rename to src/render/ps2/SDL_render_ps2.c index 70b699498..fd2c91a67 100644 --- a/src/render/ps2/SDL_render_sw.c +++ b/src/render/ps2/SDL_render_ps2.c @@ -23,7 +23,7 @@ #if SDL_VIDEO_RENDER_PS2 && !SDL_RENDER_DISABLED #include "../SDL_sysrender.h" -#include "SDL_render_sw_c.h" +#include "SDL_render_ps2.h" #include "SDL_hints.h" #include "SDL_draw.h" @@ -1168,9 +1168,6 @@ PS2_CreateRenderer(SDL_Window * window, Uint32 flags) dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF); dmaKit_chan_init(DMA_CHANNEL_GIF); - printf("\nGraphics: created %ix%i video surface\n", - gsGlobal->Width, gsGlobal->Height); - gsKit_set_clamp(gsGlobal, GS_CMODE_REPEAT); gsKit_vram_clear(gsGlobal); @@ -1224,6 +1221,6 @@ SDL_RenderDriver PS2_RenderDriver = { .max_texture_height = 512,} }; -#endif /* SDL_VIDEO_RENDER_PS2 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_PS2 */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/ps2/SDL_render_sw_c.h b/src/render/ps2/SDL_render_ps2.h similarity index 87% rename from src/render/ps2/SDL_render_sw_c.h rename to src/render/ps2/SDL_render_ps2.h index e4812d3df..a9eecd6f5 100644 --- a/src/render/ps2/SDL_render_sw_c.h +++ b/src/render/ps2/SDL_render_ps2.h @@ -19,8 +19,8 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifndef SDL_render_sw_c_h_ -#define SDL_render_sw_c_h_ +#ifndef SDL_render_ps2_h_ +#define SDL_render_ps2_h_ #include @@ -30,8 +30,8 @@ #include #include -extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface); +extern SDL_Renderer * PS2_CreateRendererForSurface(SDL_Surface * surface); -#endif /* SDL_render_sw_c_h_ */ +#endif /* SDL_render_ps2_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/ps2/SDL_rotate.c b/src/render/ps2/SDL_rotate.c index e35a5ebea..4676887e8 100644 --- a/src/render/ps2/SDL_rotate.c +++ b/src/render/ps2/SDL_rotate.c @@ -574,4 +574,4 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int smooth, int flipx, int return rz_dst; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_PS2 && !SDL_RENDER_DISABLED */ diff --git a/src/render/ps2/SDL_triangle.c b/src/render/ps2/SDL_triangle.c index a7bc2058d..2e1b7dfcd 100644 --- a/src/render/ps2/SDL_triangle.c +++ b/src/render/ps2/SDL_triangle.c @@ -67,9 +67,9 @@ int SDL_BlitTriangle(SDL_Surface *src, const SDL_Point srcpoints[3], SDL_Surface points[4] = srcpoints[2]; points[5] = dstpoints[2]; for (i = 0; i < 3; i++) { - trianglepoint_2_fixedpoint(&points[2 * i + 1]); + PS2_trianglepoint_2_fixedpoint(&points[2 * i + 1]); } - return SDL_SW_BlitTriangle(src, dst, points); + return SDL_PS2_BlitTriangle(src, dst, points); } int SDL_FillTriangle(SDL_Surface *dst, const SDL_Point points[3], Uint32 color) @@ -81,9 +81,9 @@ int SDL_FillTriangle(SDL_Surface *dst, const SDL_Point points[3], Uint32 color) } for (i = 0; i < 3; i++) { points_tmp[i] = points[i]; - trianglepoint_2_fixedpoint(&points_tmp[i]); + PS2_trianglepoint_2_fixedpoint(&points_tmp[i]); } - return SDL_SW_FillTriangle(dst, points_tmp, SDL_BLENDMODE_NONE, color); + return SDL_PS2_FillTriangle(dst, points_tmp, SDL_BLENDMODE_NONE, color); } #endif @@ -114,7 +114,7 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise) return 0; } -void trianglepoint_2_fixedpoint(SDL_Point *a) { +void PS2_trianglepoint_2_fixedpoint(SDL_Point *a) { a->x <<= FP_BITS; a->y <<= FP_BITS; } @@ -202,7 +202,7 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin } \ } \ -int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2) +int SDL_PS2_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2) { int ret = 0; int dst_locked = 0; @@ -314,7 +314,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin SDL_Point p; p.x = dstrect.x; p.y = dstrect.y; - trianglepoint_2_fixedpoint(&p); + PS2_trianglepoint_2_fixedpoint(&p); p.x += (1 << FP_BITS) / 2; p.y += (1 << FP_BITS) / 2; w0_row = cross_product(d1, d2, p.x, p.y); @@ -439,7 +439,7 @@ end: -int SDL_SW_BlitTriangle( +int SDL_PS2_BlitTriangle( SDL_Surface *src, SDL_Point *s0, SDL_Point *s1, SDL_Point *s2, SDL_Surface *dst, @@ -587,7 +587,7 @@ int SDL_SW_BlitTriangle( SDL_Point p; p.x = dstrect.x; p.y = dstrect.y; - trianglepoint_2_fixedpoint(&p); + PS2_trianglepoint_2_fixedpoint(&p); p.x += (1 << FP_BITS) / 2; p.y += (1 << FP_BITS) / 2; w0_row = cross_product(d1, d2, p.x, p.y); @@ -883,6 +883,6 @@ SDL_BlitTriangle_Slow(SDL_BlitInfo *info, TRIANGLE_END_LOOP } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_PS2 && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/render/ps2/SDL_triangle.h b/src/render/ps2/SDL_triangle.h index c120b39cf..39f4b5abc 100644 --- a/src/render/ps2/SDL_triangle.h +++ b/src/render/ps2/SDL_triangle.h @@ -24,18 +24,18 @@ #include "../../SDL_internal.h" -extern int SDL_SW_FillTriangle(SDL_Surface *dst, +extern int SDL_PS2_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_BlendMode blend, SDL_Color c0, SDL_Color c1, SDL_Color c2); -extern int SDL_SW_BlitTriangle( +extern int SDL_PS2_BlitTriangle( SDL_Surface *src, SDL_Point *s0, SDL_Point *s1, SDL_Point *s2, SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Point *d2, SDL_Color c0, SDL_Color c1, SDL_Color c2); -extern void trianglepoint_2_fixedpoint(SDL_Point *a); +extern void PS2_trianglepoint_2_fixedpoint(SDL_Point *a); #endif /* SDL_triangle_h_ */