Previous 15994 Revisions Next

r2152 Saturday 29th March, 2008 at 23:37:54 UTC by R. Belmont
[SDLMESS] Removing obsolete files
[src/osd/sdl]dirty.h effect.h effect_func.h osdefs.h sdlmisc.h ticker.h yuv_blit.c

src/osd/sdl/effect.h
r2151r2152
1#ifndef __SDL_EFFECT__
2#define __SDL_EFFECT__
3
4void scale2x_argb32(texture_info *texture, const render_texinfo *texsource);
5void scale2x_rgb32(texture_info *texture, const render_texinfo *texsource);
6void scale2x_rgb32_paletted(texture_info *texture, const render_texinfo *texsource);
7void scale2x_palette16(texture_info *texture, const render_texinfo *texsource);
8void scale2x_palette16a(texture_info *texture, const render_texinfo *texsource);
9void scale2x_rgb15(texture_info *texture, const render_texinfo *texsource);
10void scale2x_rgb15_paletted(texture_info *texture, const render_texinfo *texsource);
11void scale2x_yuv16(texture_info *texture, const render_texinfo *texsource);
12void scale2x_yuv16_paletted(texture_info *texture, const render_texinfo *texsource);
13void scale2x_palette16_argb1555(texture_info *texture, const render_texinfo *texsource);
14void scale2x_rgb15_argb1555(texture_info *texture, const render_texinfo *texsource);
15void scale2x_rgb15_paletted_argb1555(texture_info *texture, const render_texinfo *texsource);
16
17#endif
src/osd/sdl/effect_func.h
r2151r2152
1#include "texsrc.h"
2
3// texcopy function prototype
4void FUNC_NAME(texcopy)(texture_info *texture, const render_texinfo *texsource);
5
6void EFFECT_FUNC_NAME(texture_info *texture, const render_texinfo *texsource)
7{
8   int y;
9   DEST_TYPE *dst = (DEST_TYPE *)texture->data + texture->borderpix * texture->rawwidth;
10   TEXSRC_TYPE *src = (TEXSRC_TYPE *)texsource->base;
11#ifndef SRC_EQUALS_DEST
12   int x;
13   DEST_TYPE *tmp, *effectbuf0, *effectbuf1, *effectbuf2;
14#endif
15
16   switch ((texture->xprescale << 8) | texture->yprescale)
17   {
18      case 0x0101:
19      case 0x0102:
20      case 0x0103:
21      case 0x0201:
22      case 0x0301:
23         FUNC_NAME(texcopy)(texture, texsource);
24         return;
25   }
26
27#ifndef SRC_EQUALS_DEST
28   // First convert to a temporary buffer so that we do not convert each
29   // pixel 4 times
30   effectbuf1 = (DEST_TYPE *)texture->effectbuf;
31   effectbuf2 = (DEST_TYPE *)texture->effectbuf + texsource->width;
32   effectbuf0 = (DEST_TYPE *)texture->effectbuf + 2 * texsource->width;
33   
34   tmp = effectbuf1;
35   for (x = 0; x < texsource->width; x++)
36   {
37      *tmp++ = TEXSRC_TO_DEST(*src);
38      src++;
39   }
40
41   src = (TEXSRC_TYPE *)texsource->base + texsource->rowpixels;
42   tmp = effectbuf2;
43   for (x = 0; x < texsource->width; x++)
44   {
45      *tmp++ = TEXSRC_TO_DEST(*src);
46      src++;
47   }
48   EFFECT_DEST_NAME(&dst, effectbuf1, effectbuf1, effectbuf2, texture,
49      texsource);
50#else
51   EFFECT_DEST_NAME(&dst, src, src, src + texsource->rowpixels,
52      texture, texsource);
53#endif   
54
55   // loop over Y
56   for (y = 1; y < (texsource->height-1); y++)
57   {
58      dst += texture->rawwidth;
59#ifndef SRC_EQUALS_DEST
60      // First convert to a temporary buffer so that we do not
61      // convert each pixel 4 times
62      src = (TEXSRC_TYPE *)texsource->base +
63         (y + 1) * texsource->rowpixels;
64      tmp = effectbuf0;
65      effectbuf0 = effectbuf1;
66      effectbuf1 = effectbuf2;
67      effectbuf2 = tmp;
68      for (x = 0; x < texsource->width; x++)
69      {
70         *tmp++ = TEXSRC_TO_DEST(*src);
71         src++;
72      }
73      EFFECT_DEST_NAME(&dst, effectbuf0, effectbuf1, effectbuf2, texture, texsource);
74#else
75      src += texsource->rowpixels;
76      EFFECT_DEST_NAME(&dst, src - texsource->rowpixels, src,
77         src + texsource->rowpixels, texture, texsource);
78#endif
79   }
80
81   // last line
82   dst += texture->rawwidth;
83#ifndef SRC_EQUALS_DEST
84   EFFECT_DEST_NAME(&dst, effectbuf1, effectbuf2, effectbuf2, texture, texsource);
85#else
86   EFFECT_DEST_NAME(&dst, src, src + texsource->rowpixels, src + texsource->rowpixels, texture, texsource);
87#endif
88}
89
90#undef SDL_TEXFORMAT
src/osd/sdl/osdefs.h
r2151r2152
1//============================================================
2//
3//  osdefs.h - System-specific defines
4//
5//  Copyright (c) 2007 Albert Lee.
6//  Visit http://mamedev.org for licensing and usage restrictions.
7//
8//============================================================
9
10#ifndef _OSDEFS_H_
11#define _OSDEFS_H_
12
13
14#ifdef __APPLE__
15#define SDLMAME_DARWIN 1
16#endif /* __APPLE__ */
17
18#ifdef SDLMAME_UNIX
19
20#if defined(__sun__) && defined(__svr4__)
21#define SDLMAME_SOLARIS 1
22
23#elif defined(__irix__) || defined(__sgi)
24#define SDLMAME_IRIX 1
25/* Large file support on IRIX needs _SGI_SOURCE */
26#undef _POSIX_SOURCE
27
28#elif defined(__linux__)
29#define SDLMAME_LINUX 1
30
31#elif defined(__FreeBSD__) || defined(__DragonFly__)
32#define SDLMAME_FREEBSD 1
33#endif
34
35#endif /* SDLMAME_UNIX */
36
37#endif /* _OSDEFS_H_ */
src/osd/sdl/sdlmisc.h
r2151r2152
1/* Miscelancelous utility functions
2
3   Copyright 2000 Hans de Goede
4   
5   This file and the acompanying files in this directory are free software;
6   you can redistribute them and/or modify them under the terms of the GNU
7   Library General Public License as published by the Free Software Foundation;
8   either version 2 of the License, or (at your option) any later version.
9
10   These files are distributed in the hope that they will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   Library General Public License for more details.
14
15   You should have received a copy of the GNU Library General Public
16   License along with these files; see the file COPYING.LIB.  If not,
17   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18   Boston, MA 02111-1307, USA.
19*/
20
21#ifndef __SDLMISC_H
22#define __SDLMISC_H
23
24/* clock stuff */
25typedef long uclock_t;
26uclock_t uclock(void);
27#define UCLOCKS_PER_SEC 1000000
28
29#if !(defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98)
30int snprintf(char *s, size_t maxlen, const char *fmt, ...);
31#endif
32
33#endif /* ifndef __SDLMISC_H */
src/osd/sdl/ticker.h
r2151r2152
1//============================================================
2//
3//   ticker.h - Win32 timing code
4//
5//============================================================
6
7#ifndef __SDL_TICKER__
8#define __SDL_TICKER__
9
10#include "osd_cpu.h"
11
12//============================================================
13//   TYPE DEFINITIONS
14//============================================================
15
16typedef INT64 TICKER;
17
18
19
20//============================================================
21//   MACROS
22//============================================================
23
24#define TICKS_PER_SEC ticks_per_sec
25
26
27
28//============================================================
29//   GLOBAL VARIABLES
30//============================================================
31
32extern TICKER      ticks_per_sec;
33extern TICKER      (*ticker)(void);
34
35#endif
src/osd/sdl/dirty.h
src/osd/sdl/yuv_blit.c
r2151r2152
1
2// YUV Blitters
3//
4// This should be included at the end of drawsdl.c
5
6
7#define CU_CLAMP(v, a, b)   ((v < a)? a: ((v > b)? b: v))
8#define RGB2YUV_F(r,g,b,y,u,v) \
9    (y) = (0.299*(r) + 0.587*(g) + 0.114*(b) ); \
10    (u) = (-0.169*(r) - 0.331*(g) + 0.5*(b) + 128); \
11    (v) = (0.5*(r) - 0.419*(g) - 0.081*(b) + 128); \
12   (y) = CU_CLAMP(y,0,255); \
13   (u) = CU_CLAMP(u,0,255); \
14   (v) = CU_CLAMP(v,0,255)
15
16#define RGB2YUV(r,g,b,y,u,v) \
17    (y) = ((  8453*(r) + 16594*(g) +  3223*(b) +  524288) >> 15); \
18    (u) = (( -4878*(r) -  9578*(g) + 14456*(b) + 4210688) >> 15); \
19    (v) = (( 14456*(r) - 12105*(g) -  2351*(b) + 4210688) >> 15)
20
21#ifdef LSB_FIRST   
22#define Y1MASK  0x000000FF
23#define  UMASK  0x0000FF00
24#define Y2MASK  0x00FF0000
25#define  VMASK  0xFF000000
26#define Y1SHIFT  0
27#define  USHIFT  8
28#define Y2SHIFT 16
29#define  VSHIFT 24
30#else
31#define Y1MASK  0xFF000000
32#define  UMASK  0x00FF0000
33#define Y2MASK  0x0000FF00
34#define  VMASK  0x000000FF
35#define Y1SHIFT 24
36#define  USHIFT 16
37#define Y2SHIFT  8
38#define  VSHIFT  0
39#endif
40
41#define YMASK  (Y1MASK|Y2MASK)
42#define UVMASK (UMASK|VMASK)
43
44
45static void yuv_lookup_set(sdl_window_info *window, unsigned int pen, unsigned char red,
46         unsigned char green, unsigned char blue)
47{
48   UINT32 y,u,v;
49
50   RGB2YUV(red,green,blue,y,u,v);
51
52   /* Storing this data in YUYV order simplifies using the data for
53      YUY2, both with and without smoothing... */
54   window->yuv_lookup[pen]=(y<<Y1SHIFT)|(u<<USHIFT)|(y<<Y2SHIFT)|(v<<VSHIFT);
55}
56
57void drawsdl_yuv_init(sdl_window_info *window)
58{
59   unsigned char r,g,b;
60   if (window->yuv_lookup == NULL)
61      window->yuv_lookup = malloc_or_die(65536*sizeof(UINT32));
62   for (r = 0; r < 32; r++)
63      for (g = 0; g < 32; g++)
64         for (b = 0; b < 32; b++)
65         {
66            int idx = (r << 10) | (g << 5) | b;
67            yuv_lookup_set(window, idx,
68               (r << 3) | (r >> 2),
69               (g << 3) | (g >> 2),
70               (b << 3) | (b >> 2));
71         }
72}
73
74static void yuv_RGB_to_YV12(UINT16 *bitmap, int bw, sdl_window_info *window)
75{
76   int x, y;
77   UINT8 *dest_y;
78   UINT8 *dest_u;
79   UINT8 *dest_v;
80   UINT16 *src;
81   UINT16 *src2;
82   UINT32 *lookup = window->yuv_lookup;
83   int yuv_pitch = window->yuvsurf->pitches[0];
84   int u1,v1,y1,u2,v2,y2,u3,v3,y3,u4,v4,y4;     /* 12 */
85     
86   for(y=0;y<window->yuv_ovl_height;y+=2)
87   {
88      src=bitmap + (y * bw) ;
89      src2=src + bw;
90
91      dest_y = window->yuvsurf->pixels[0] + y * window->yuvsurf->pitches[0];
92      dest_v = window->yuvsurf->pixels[1] + (y>>1) * window->yuvsurf->pitches[1];
93      dest_u = window->yuvsurf->pixels[2] + (y>>1) * window->yuvsurf->pitches[2];
94
95      for(x=0;x<window->yuv_ovl_width;x+=2)
96      {
97         v1 = lookup[src[x]];
98         y1 = (v1>>Y1SHIFT) & 0xff;
99         u1 = (v1>>USHIFT)  & 0xff;
100         v1 = (v1>>VSHIFT)  & 0xff;
101
102         v2 = lookup[src[x+1]];
103         y2 = (v2>>Y1SHIFT) & 0xff;
104         u2 = (v2>>USHIFT)  & 0xff;
105         v2 = (v2>>VSHIFT)  & 0xff;
106
107         v3 = lookup[src2[x]];
108         y3 = (v3>>Y1SHIFT) & 0xff;
109         u3 = (v3>>USHIFT)  & 0xff;
110         v3 = (v3>>VSHIFT)  & 0xff;
111
112         v4 = lookup[src2[x+1]];
113         y4 = (v4>>Y1SHIFT) & 0xff;
114         u4 = (v4>>USHIFT)  & 0xff;
115         v4 = (v4>>VSHIFT)  & 0xff;
116
117         dest_y[x] = y1;
118         dest_y[x+yuv_pitch] = y3;
119         dest_y[x+1] = y2;
120         dest_y[x+yuv_pitch+1] = y4;
121
122         dest_u[x>>1] = (u1+u2+u3+u4)/4;
123         dest_v[x>>1] = (v1+v2+v3+v4)/4;
124         
125      }
126   }
127}
128
129static void yuv_RGB_to_YV12X2(UINT16 *bitmap, int bw, sdl_window_info *window)
130{      /* this one is used when scale==2 */
131   unsigned int x,y;
132   UINT16 *dest_y;
133   UINT8 *dest_u;
134   UINT8 *dest_v;
135   UINT16 *src;
136   int yuv_pitch = window->yuvsurf->pitches[0];
137   int u1,v1,y1;
138
139   for(y=0;y<window->yuv_ovl_height;y++)
140   {
141      src=bitmap + (y * bw) ;
142
143      dest_y = (UINT16 *)(window->yuvsurf->pixels[0] + 2*y * window->yuvsurf->pitches[0]);
144      dest_v = window->yuvsurf->pixels[1] + y * window->yuvsurf->pitches[1];
145      dest_u = window->yuvsurf->pixels[2] + y * window->yuvsurf->pitches[2];
146      for(x=0;x<window->yuv_ovl_width;x++)
147      {
148         v1 = window->yuv_lookup[src[x]];
149         y1 = (v1>>Y1SHIFT) & 0xff;
150         u1 = (v1>>USHIFT)  & 0xff;
151         v1 = (v1>>VSHIFT)  & 0xff;
152
153         dest_y[x+yuv_pitch/2]=y1<<8|y1;
154         dest_y[x]=y1<<8|y1;
155         dest_u[x] = u1;
156         dest_v[x] = v1;
157      }
158   }
159}
160
161static void yuv_RGB_to_YUY2(UINT16 *bitmap, int bw, sdl_window_info *window)
162{      /* this one is used when scale==2 */
163   unsigned int y;
164   UINT32 *dest;
165   UINT16 *src;
166   UINT16 *end;
167   UINT32 p1,p2,uv;
168   UINT32 *lookup = window->yuv_lookup;
169   int yuv_pitch = window->yuvsurf->pitches[0]/4;
170
171   for(y=0;y<window->yuv_ovl_height;y++)
172   {
173      src=bitmap + (y * bw) ;
174      end=src+window->yuv_ovl_width;
175
176      dest = (UINT32 *) window->yuvsurf->pixels[0];
177      dest += y * yuv_pitch;
178      for(; src<end; src+=2)
179      {
180         p1  = lookup[src[0]];
181         p2  = lookup[src[1]];
182         uv = (p1&UVMASK)>>1;
183         uv += (p2&UVMASK)>>1;
184         *dest++ = (p1&Y1MASK)|(p2&Y2MASK)|(uv&UVMASK);
185      }
186   }
187}
188
189static void yuv_RGB_to_YUY2X2(UINT16 *bitmap, int bw, sdl_window_info *window)
190{      /* this one is used when scale==2 */
191   unsigned int y;
192   UINT32 *dest;
193   UINT16 *src;
194   UINT16 *end;
195   UINT32 *lookup = window->yuv_lookup;
196   int yuv_pitch = window->yuvsurf->pitches[0]/4;
197
198   for(y=0;y<window->yuv_ovl_height;y++)
199   {
200      src=bitmap + (y * bw) ;
201      end=src+window->yuv_ovl_width;
202
203      dest = (UINT32 *) window->yuvsurf->pixels[0];
204      dest += (y * yuv_pitch);
205      for(; src<end; src++)
206      {
207         dest[0] = lookup[src[0]];
208         dest++;
209      }
210   }
211}
212

Previous 15994 Revisions Next


© 1998-2018 The MESS Team