riq
Fri, 15 Dec 2000 10:36:16 -0800
Patch that adds video_update for 16bpp_to_16bpp to the SDL video driver. (src/unix/video-driver/SDL.c) Tested only with one rom (mk2r91). Also, the SDL_HWPALETTE was added to the flags of SDL_SetVideoMode. (I hope that wont break anything) riq. -- Ricardo Quesada
--- SDL.c Fri Dec 8 01:03:30 2000
+++ SDL-orig.c Fri Dec 15 00:00:51 2000
@@ -3,16 +3,17 @@
SDL XMAME display driver, based on
Linux SVGALib adaptation by Phillip Ezolt.
- updated and patched by Ricardo Calixto Quesada ([EMAIL PROTECTED])
+ updated and patched by Ricardo Calixto Quesada ([EMAIL PROTECTED])
TODO: Test the HERMES code.
- Make other update routines. The only one is 8bpp -> 16bpp
+ Add more updates routines (available only 8->16bpp & 16->16bpp)
+ Test the 16bpp->16bpp update routine (tested only in mk2r91)
Improve performace.
***************************************************************************/
#define __SDL_C
-/* #define SDL_DEBUG */
+#undef SDL_DEBUG
/* #define DIRECT_HERMES */
#include <signal.h>
@@ -35,7 +36,7 @@
static int hardware=1;
static int mode_number=-1;
static int list_modes=0;
-SDL_Color *Colors;
+SDL_Color *Colors=NULL;
#ifdef DIRECT_HERMES
HermesHandle H_PaletteHandle;
@@ -65,7 +66,8 @@
};
void list_sdl_modes(void);
-void sdl_update_8bpp_16bpp(struct osd_bitmap *bitmap);
+void sdl_update_8_to_16bpp(struct osd_bitmap *bitmap);
+void sdl_update_16_to_16bpp(struct osd_bitmap *bitmap);
int sysdep_init(void)
{
@@ -104,7 +106,7 @@
video_info = SDL_GetVideoInfo();
#ifdef SDL_DEBUG
- fprintf (stderr,"SDL: Info: Best matching mode: \n");
+ fprintf (stderr,"SDL: create_display(%d): \n",depth);
fprintf (stderr,"SDL: Info: HW blits %d\n"
"SDL: Info: SW blits %d\n"
"SDL: Info: Vid mem %d\n"
@@ -128,13 +130,29 @@
hardware=0;
Vid_height = visual_height*heightscale;
Vid_width = visual_width*widthscale;
- update_function = &sdl_update_8bpp_16bpp;
+ if( depth == 8 )
+ update_function = &sdl_update_8_to_16bpp;
+ else if( depth == 16 )
+ update_function = &sdl_update_16_to_16bpp;
+ else {
+ fprintf (stderr, "SDL: Unsupported depth=%d\n", depth);
+ SDL_Quit();
+ exit (OSD_NOT_OK);
+ }
} else {
#ifdef SDL_DEBUG
fprintf (stderr, "SDL: visual w:%d visual h:%d\n", visual_width, visual_height);
#endif
hardware=1;
- update_function = &sdl_update_8bpp_16bpp;
+ if( depth == 8 )
+ update_function = &sdl_update_8_to_16bpp;
+ else if( depth == 16 )
+ update_function = &sdl_update_16_to_16bpp;
+ else {
+ fprintf (stderr, "SDL: Unsupported depth=%d\n", Vid_depth);
+ SDL_Quit();
+ exit (OSD_NOT_OK);
+ }
while( *(vid_modes+vid_modes_i) ) {
#ifdef SDL_DEBUG
@@ -171,7 +189,7 @@
}
}
- if(! (Surface = SDL_SetVideoMode(Vid_width, Vid_height,Vid_depth, SDL_HWSURFACE)))
{
+ if(! (Surface = SDL_SetVideoMode(Vid_width, Vid_height,Vid_depth,
+SDL_HWSURFACE|SDL_HWPALETTE))) {
fprintf (stderr, "SDL: Error: Setting video mode failed\n");
SDL_Quit();
exit (OSD_NOT_OK);
@@ -221,7 +239,7 @@
/* Update the display. */
-void sdl_update_8bpp_16bpp(struct osd_bitmap *bitmap)
+void sdl_update_8_to_16bpp(struct osd_bitmap *bitmap)
{
#define BLIT_16BPP_HACK
#define INDIRECT current_palette->lookup
@@ -240,6 +258,28 @@
#undef BLIT_16BPP_HACK
}
+void sdl_update_16_to_16bpp (struct osd_bitmap *bitmap)
+{
+#define SRC_PIXEL unsigned short
+#define DEST_PIXEL unsigned short
+#define DEST Offscreen_surface->pixels
+#define DEST_WIDTH Vid_width
+ if(current_palette->lookup)
+ {
+#define INDIRECT current_palette->lookup
+#include "blit.h"
+#undef INDIRECT
+ }
+ else
+ {
+#include "blit.h"
+ }
+#undef DEST
+#undef DEST_WIDTH
+#undef SRC_PIXEL
+#undef DEST_PIXEL
+}
+
#ifndef DIRECT_HERMES
void sysdep_update_display(struct osd_bitmap *bitmap)
{
@@ -434,10 +474,14 @@
int i;
ncolors = totalcolors;
- fprintf (stderr, "SDL: sysdep_display_alloc_palette();\n");
+ fprintf (stderr, "SDL: sysdep_display_alloc_palette(%d);\n",totalcolors);
+ if (Vid_depth != 8)
+ return 0;
#ifndef DIRECT_HERMES
Colors = (SDL_Color*) malloc (totalcolors * sizeof(SDL_Color));
+ if( !Colors )
+ return 1;
for (i=0;i<totalcolors;i++) {
(Colors + i)->r = 0xFF;
(Colors + i)->g = 0x00;
@@ -459,14 +503,17 @@
int sysdep_display_set_pen(int pen,unsigned char red, unsigned char green, unsigned
char blue)
{
static int warned = 0;
+ fprintf(stderr,"sysdep_display_set_pen(%d,%d,%d,%d)\n",pen,red,green,blue);
#ifndef DIRECT_HERMES
- (Colors + pen)->r = red;
- (Colors + pen)->g = green;
- (Colors + pen)->b = blue;
- if ( (! SDL_SetColors(Offscreen_surface, Colors + pen, pen,1)) && (! warned)) {
- printf ("Color allocation failed, or > 8 bit display\n");
- warned = 0;
+ if( Colors ) {
+ (Colors + pen)->r = red;
+ (Colors + pen)->g = green;
+ (Colors + pen)->b = blue;
+ if ( (! SDL_SetColors(Offscreen_surface, Colors + pen, pen,1)) && (! warned)) {
+ printf ("Color allocation failed, or > 8 bit display\n");
+ warned = 0;
+ }
}
#else /* DIRECT_HERMES */
*(H_Palette + pen) = (red<<16) | ((green) <<8) | (blue );
@@ -532,10 +579,12 @@
}
}
-/* funciones agregadas */
+/* added funcions */
int sysdep_display_16bpp_capable(void)
{
- return (Vid_depth >=16);
+ const SDL_VideoInfo* video_info;
+ video_info = SDL_GetVideoInfo();
+ return ( video_info->vfmt->BitsPerPixel >=16);
}
void list_sdl_modes(void)