From f517f32902b8c454ea355141444807198f9b678e Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sat, 10 Oct 2009 14:26:53 +0000 Subject: RGB support. svn-id: r44874 --- backends/platform/dc/display.cpp | 137 ++++++++++++++++++++++++++++++++------- 1 file changed, 114 insertions(+), 23 deletions(-) (limited to 'backends/platform/dc/display.cpp') diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index c6be514e36..75bf31f4f6 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -41,6 +41,22 @@ #define TOP_OFFSET (_top_offset+_yscale*_current_shake_pos) +static const struct { + Graphics::PixelFormat pixelFormat; + unsigned int textureFormat; + operator const Graphics::PixelFormat&() const { return pixelFormat; } +} screenFormats[] = { + /* Note: These are ordered by _increasing_ preference, so that + CLUT8 appears at index 0. getSupportedFormats() will return + them in reversed order. */ + { Graphics::PixelFormat::createFormatCLUT8(), TA_TEXTUREMODE_ARGB1555 }, + { Graphics::PixelFormat(2,4,4,4,4,8,4,0,12), TA_TEXTUREMODE_ARGB4444 }, + { Graphics::PixelFormat(2,5,5,5,1,10,5,0,15), TA_TEXTUREMODE_ARGB1555 }, + { Graphics::PixelFormat(2,5,6,5,0,11,5,0,0), TA_TEXTUREMODE_RGB565 }, +}; +#define NUM_FORMATS (sizeof(screenFormats)/sizeof(screenFormats[0])) + + #define QACR0 (*(volatile unsigned int *)(void *)0xff000038) #define QACR1 (*(volatile unsigned int *)(void *)0xff00003c) @@ -178,6 +194,20 @@ void OSystem_Dreamcast::grabPalette(byte *colors, uint start, uint num) } } +Graphics::PixelFormat OSystem_Dreamcast::getScreenFormat() const +{ + return screenFormats[_screenFormat]; +} + +Common::List OSystem_Dreamcast::getSupportedFormats() +{ + Common::List list; + int i; + for (i=0; i 400) { @@ -197,6 +227,13 @@ void OSystem_Dreamcast::initSize(uint w, uint h, const Graphics::PixelFormat *fo { assert(w <= SCREEN_W && h <= SCREEN_H); + int i = 0; + if (format != NULL) + for (i=NUM_FORMATS-1; i>0; --i) + if (*format == screenFormats[i]) + break; + _screenFormat = i; + _overlay_visible = false; _overlay_fade = 0.0; _screen_w = w; @@ -208,7 +245,7 @@ void OSystem_Dreamcast::initSize(uint w, uint h, const Graphics::PixelFormat *fo setScaling(); ta_sync(); if (!screen) - screen = new unsigned char[SCREEN_W*SCREEN_H]; + screen = new unsigned char[SCREEN_W*SCREEN_H*2]; if (!overlay) overlay = new unsigned short[OVL_W*OVL_H]; for (int i=0; i0; --i) + if (*format == screenFormats[i]) + break; + _mouseFormat = i; if (_ms_buf) free(_ms_buf); + if (_mouseFormat != 0) + w <<= 1; + _ms_buf = (byte *)malloc(w * h); memcpy(_ms_buf, buf, w * h); } @@ -298,12 +348,20 @@ void OSystem_Dreamcast::updateScreenTextures(void) // while ((*((volatile unsigned int *)(void*)0xa05f810c) & 0x3ff) != 200); // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff0000; - for ( int y = 0; y<_screen_h; y++ ) - { - texture_memcpy64_pal( dst, src, _screen_w>>5, palette ); - src += SCREEN_W; - dst += SCREEN_W; - } + if (_screenFormat == 0) + for ( int y = 0; y<_screen_h; y++ ) + { + texture_memcpy64_pal( dst, src, _screen_w>>5, palette ); + src += SCREEN_W*2; + dst += SCREEN_W; + } + else + for ( int y = 0; y<_screen_h; y++ ) + { + texture_memcpy64( dst, src, _screen_w>>5 ); + src += SCREEN_W*2; + dst += SCREEN_W; + } _screen_dirty = false; } @@ -341,8 +399,9 @@ void OSystem_Dreamcast::updateScreenPolygons(void) mypoly.mode2 = TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_REPLACE| TA_POLYMODE2_U_SIZE_1024|TA_POLYMODE2_V_SIZE_1024; - mypoly.texture = TA_TEXTUREMODE_ARGB1555|TA_TEXTUREMODE_NON_TWIDDLED| - TA_TEXTUREMODE_STRIDE|TA_TEXTUREMODE_ADDRESS(screen_tx[_screen_buffer]); + mypoly.texture = screenFormats[_screenFormat].textureFormat| + TA_TEXTUREMODE_NON_TWIDDLED|TA_TEXTUREMODE_STRIDE| + TA_TEXTUREMODE_ADDRESS(screen_tx[_screen_buffer]); mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; @@ -471,17 +530,22 @@ void OSystem_Dreamcast::maybeRefreshScreen(void) void OSystem_Dreamcast::drawMouse(int xdraw, int ydraw, int w, int h, unsigned char *buf, bool visible) { + if (!visible || buf == NULL || !w || !h || w>MOUSE_W || h>MOUSE_H) { + commit_dummy_transpoly(); + return; + } + struct polygon_list mypoly; struct packed_colour_vertex_list myvertex; - unsigned short *pal = _enable_cursor_palette? cursor_palette : palette; - _mouse_buffer++; _mouse_buffer &= NUM_BUFFERS-1; unsigned short *dst = (unsigned short *)mouse_tx[_mouse_buffer]; + unsigned int texturemode = screenFormats[_mouseFormat].textureFormat; - if (visible && w && h && w<=MOUSE_W && h<=MOUSE_H) + if (_mouseFormat == 0) { + unsigned short *pal = _enable_cursor_palette? cursor_palette : palette; for (int y=0; y>1)|0x8000; + } + dst += MOUSE_W-x; + } + } else { + unsigned short *bufs = (unsigned short *)buf; + for (int y=0; y