Previous 15994 Revisions Next

r1897 Tuesday 11th March, 2008 at 00:12:02 UTC by R. Belmont
[SDLMESS] Sync with SDLMAME 0.123u4 + patches for OS/2, general cleanup, and OSX debugger compiling.
[src/osd/sdl]debugosx.c drawogl.c drawsdl.c input.c osdsdl.h scale2x.c scale2x_core.c sdl.mak sdlfile.c sdlmain.c sdlmisc.c sdlsync.c sdlsync.h sdltime.c sound.c testkeys.c texcopy.c texsrc.h video.c window.c

src/osd/sdl/sdl.mak
r1896r1897
164164
165165
166166ifndef NO_OPENGL
167OSDOBJS += $(SDLOBJ)/drawogl.o $(SDLOBJ)/scale2x.o
167OSDOBJS += $(SDLOBJ)/drawogl.o
168168endif
169169
170170# add the debugger includes
r1896r1897
286286# drawSDL depends on the core software renderer, so make sure it exists
287287$(SDLOBJ)/drawsdl.o : $(SRC)/emu/rendersw.c
288288
289$(SDLOBJ)/drawogl.o : $(SDLSRC)/drawogl.c $(SDLSRC)/texcopy.c $(SDLSRC)/scale2x.c $(SDLSRC)/scale2x_core.c
290
289291# due to quirks of using /bin/sh, we need to explicitly specify the current path
290292CURPATH = ./
291293
292294$(LIBOCORE): $(OSDCOREOBJS)
293295$(LIBOSD): $(OSDOBJS)
294296
295$(SDLOBJ)/scale2x.o: $(SDLSRC)/scale2x.c $(SDLSRC)/effect_func.h $(SDLSRC)/scale2x_core.c $(SDLSRC)/texsrc.h
296
297297#-------------------------------------------------
298298# testkeys
299299#-------------------------------------------------
src/osd/sdl/scale2x_core.c
r1896r1897
6161 *
6262 * J.W.R. de Goede, Rotterdam the Netherlands, 17 december 2004.
6363 */
64#include "window.h"
6564
6665INLINE void FUNC_NAME(scale2x_border)(DEST_TYPE *dst, DEST_TYPE *src0,
6766   DEST_TYPE *src1, DEST_TYPE *src2, int count,
src/osd/sdl/drawsdl.c
r1896r1897
5454static void drawsdl_destroy_all_textures(sdl_window_info *window);
5555
5656// soft rendering
57void drawsdl_rgb888_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
58void drawsdl_bgr888_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
59void drawsdl_rgb565_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
60void drawsdl_rgb555_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
57static void drawsdl_rgb888_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
58static void drawsdl_bgr888_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
59static void drawsdl_rgb565_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
60static void drawsdl_rgb555_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
6161
6262// YUV overlays
6363
src/osd/sdl/scale2x.c
r1896r1897
1#include "osdcomm.h"
2#include "mamecore.h"
3#include "window.h"
4#include "effect.h"
51
2#ifndef SDL_TEXFORMAT
3
64// 16 and 32 bpp versions of the core scale2x functions
75// NOTE, advancemame has mmx asm versions of these, these could be easily
86// integrated by someone interested, except for borderpix support.
7
8#ifdef FUNC_NAME
9#undef FUNC_NAME
10#endif
11
912#define DEST_TYPE UINT16
1013#define FUNC_NAME(name) name ## _16bpp
1114#include "scale2x_core.c"
r1896r1897
2023#define EFFECT_DEST_NAME DEST_NAME(scaleXxX)
2124
2225#define SDL_TEXFORMAT SDL_TEXFORMAT_ARGB32
23#include "effect_func.h"
26#include "scale2x.c"
2427#undef SDL_TEXFORMAT
2528
2629#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32
27#include "effect_func.h"
30#include "scale2x.c"
2831#undef SDL_TEXFORMAT
2932
3033#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32_PALETTED
31#include "effect_func.h"
34#include "scale2x.c"
3235#undef SDL_TEXFORMAT
3336
3437#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16
35#include "effect_func.h"
38#include "scale2x.c"
3639#undef SDL_TEXFORMAT
3740
3841#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16A
39#include "effect_func.h"
42#include "scale2x.c"
4043#undef SDL_TEXFORMAT
4144
4245#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15
43#include "effect_func.h"
46#include "scale2x.c"
4447#undef SDL_TEXFORMAT
4548
4649#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED
47#include "effect_func.h"
50#include "scale2x.c"
4851#undef SDL_TEXFORMAT
4952
5053#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16_ARGB1555
51#include "effect_func.h"
54#include "scale2x.c"
5255#undef SDL_TEXFORMAT
5356
5457#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_ARGB1555
55#include "effect_func.h"
58#include "scale2x.c"
5659#undef SDL_TEXFORMAT
5760
5861#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555
59#include "effect_func.h"
62#include "scale2x.c"
6063#undef SDL_TEXFORMAT
6164
6265#undef EFFECT_FUNC_NAME
r1896r1897
6972//     
7073//============================================================
7174
72void scale2x_yuv16(texture_info *texture, const render_texinfo *texsource)
75static void scale2x_yuv16(texture_info *texture, const render_texinfo *texsource)
7376{
7477   fatalerror("ERROR: Scale2X not supported for YUV textures\n");
7578}
7679
77void scale2x_yuv16_paletted(texture_info *texture, const render_texinfo *texsource)
80static void scale2x_yuv16_paletted(texture_info *texture, const render_texinfo *texsource)
7881{
7982   fatalerror("ERROR: Scale2X not supported for YUV textures\n");
8083}
84
85#else // recursive include
86
87#include "texsrc.h"
88
89// texcopy function prototype
90//void FUNC_NAME(texcopy)(texture_info *texture, const render_texinfo *texsource);
91
92static void EFFECT_FUNC_NAME(texture_info *texture, const render_texinfo *texsource)
93{
94   int y;
95   DEST_TYPE *dst = (DEST_TYPE *)texture->data + texture->borderpix * texture->rawwidth;
96   TEXSRC_TYPE *src = (TEXSRC_TYPE *)texsource->base;
97#ifndef SRC_EQUALS_DEST
98   int x;
99   DEST_TYPE *tmp, *effectbuf0, *effectbuf1, *effectbuf2;
100#endif
101
102   switch ((texture->xprescale << 8) | texture->yprescale)
103   {
104      case 0x0101:
105      case 0x0102:
106      case 0x0103:
107      case 0x0201:
108      case 0x0301:
109         FUNC_NAME(texcopy)(texture, texsource);
110         return;
111   }
112
113#ifndef SRC_EQUALS_DEST
114   // First convert to a temporary buffer so that we do not convert each
115   // pixel 4 times
116   effectbuf1 = (DEST_TYPE *)texture->effectbuf;
117   effectbuf2 = (DEST_TYPE *)texture->effectbuf + texsource->width;
118   effectbuf0 = (DEST_TYPE *)texture->effectbuf + 2 * texsource->width;
119   
120   tmp = effectbuf1;
121   for (x = 0; x < texsource->width; x++)
122   {
123      *tmp++ = TEXSRC_TO_DEST(*src);
124      src++;
125   }
126
127   src = (TEXSRC_TYPE *)texsource->base + texsource->rowpixels;
128   tmp = effectbuf2;
129   for (x = 0; x < texsource->width; x++)
130   {
131      *tmp++ = TEXSRC_TO_DEST(*src);
132      src++;
133   }
134   EFFECT_DEST_NAME(&dst, effectbuf1, effectbuf1, effectbuf2, texture,
135      texsource);
136#else
137   EFFECT_DEST_NAME(&dst, src, src, src + texsource->rowpixels,
138      texture, texsource);
139#endif   
140
141   // loop over Y
142   for (y = 1; y < (texsource->height-1); y++)
143   {
144      dst += texture->rawwidth;
145#ifndef SRC_EQUALS_DEST
146      // First convert to a temporary buffer so that we do not
147      // convert each pixel 4 times
148      src = (TEXSRC_TYPE *)texsource->base +
149         (y + 1) * texsource->rowpixels;
150      tmp = effectbuf0;
151      effectbuf0 = effectbuf1;
152      effectbuf1 = effectbuf2;
153      effectbuf2 = tmp;
154      for (x = 0; x < texsource->width; x++)
155      {
156         *tmp++ = TEXSRC_TO_DEST(*src);
157         src++;
158      }
159      EFFECT_DEST_NAME(&dst, effectbuf0, effectbuf1, effectbuf2, texture, texsource);
160#else
161      src += texsource->rowpixels;
162      EFFECT_DEST_NAME(&dst, src - texsource->rowpixels, src,
163         src + texsource->rowpixels, texture, texsource);
164#endif
165   }
166
167   // last line
168   dst += texture->rawwidth;
169#ifndef SRC_EQUALS_DEST
170   EFFECT_DEST_NAME(&dst, effectbuf1, effectbuf2, effectbuf2, texture, texsource);
171#else
172   EFFECT_DEST_NAME(&dst, src, src + texsource->rowpixels, src + texsource->rowpixels, texture, texsource);
173#endif
174}
175
176#undef SDL_TEXFORMAT
177
178
179#endif
src/osd/sdl/video.c
r1896r1897
8585static sdl_monitor_info *primary_monitor;
8686static sdl_monitor_info *sdl_monitor_list;
8787
88static mame_bitmap *effect_bitmap;
88static bitmap_t *effect_bitmap;
8989
9090//============================================================
9191//  PROTOTYPES
src/osd/sdl/texsrc.h
r1896r1897
1#include "palette.h"
21
32#ifdef DEST_TYPE
43#undef DEST_TYPE
src/osd/sdl/sdlsync.c
r1896r1897
2727// MAME headers
2828#include "osdcore.h"
2929#include "osinline.h"
30#include "mame.h"
3130#include "sdlsync.h"
3231
3332#include "eminline.h"
r1896r1897
295294//  osd_event_set
296295//============================================================
297296
297#if 1
298298void osd_event_set(osd_event *event)
299299{
300#if 0
301   if (osd_compare_exchange32(&event->signalled, FALSE, TRUE) == FALSE)
302   {
303      pthread_mutex_lock(&event->mutex);
304      if (event->autoreset)
305         pthread_cond_signal(&event->cond);
306      else
307         pthread_cond_broadcast(&event->cond);
308      pthread_mutex_unlock(&event->mutex);
309   }
310#endif
311300   pthread_mutex_lock(&event->mutex);
312301   if (event->signalled == FALSE)
313302   {
r1896r1897
348337   }
349338   else
350339   {
351      struct timespec   ts;
352      struct timeval    tp;
353      UINT64 t;
354      UINT64 msec = timeout * 1000 / osd_ticks_per_second();
355      UINT64 nsec;
356     
357      gettimeofday(&tp, NULL);
358
359      ts.tv_sec  = tp.tv_sec;
360      nsec = (UINT64) tp.tv_usec * (UINT64) 1000 + (msec * (UINT64) 1000000);
361      t = nsec / (UINT64) 1000000000;
362      ts.tv_nsec = t % (UINT64) 1000000000;
363      ts.tv_sec += t;
364
365340      if (!event->signalled)
366341      {
342         struct timespec   ts;
343         struct timeval    tp;
344         UINT64 msec = timeout * 1000 / osd_ticks_per_second();
345         UINT64 nsec;
346         
347         gettimeofday(&tp, NULL);
348   
349         ts.tv_sec  = tp.tv_sec;
350         nsec = (UINT64) tp.tv_usec * (UINT64) 1000 + (msec * (UINT64) 1000000);
351         ts.tv_nsec = nsec % (UINT64) 1000000000;
352         ts.tv_sec += nsec / (UINT64) 1000000000;
353
367354         do {
368355            int ret = pthread_cond_timedwait(&event->cond, &event->mutex, &ts);
369356            if ( ret == ETIMEDOUT )
r1896r1897
380367               break;
381368            if ( ret != EINTR)
382369            {
383               printf("Error %d while waiting for pthread_cond_timedwait: %d - %s\n", ret, (int) t, strerror(ret));
370               printf("Error %d while waiting for pthread_cond_timedwait: %s\n", ret, strerror(ret));
384371            }
385372               
386373         } while (TRUE);
r1896r1897
394381
395382   return TRUE;
396383}
397 
384#else
385
386/*
387 * The following code has been added
388 * for demonstration purposes only.
389 * It implements a events without the need
390 * for pthreads. However, it horribly fails, if
391 * threads > num processors as is the case if you
392 * enable "-mt"
393 */
394
395void osd_event_set(osd_event *event)
396{
397//   while (compare_exchange32(&event->signalled, 0, 1) == 1)
398//      osd_yield_processor();
399   atomic_exchange32(&event->signalled, 1);
400}
401
402void osd_event_reset(osd_event *event)
403{
404   compare_exchange32(&event->signalled, 1, 0);
405}
406
407int osd_event_wait(osd_event *event, osd_ticks_t timeout)
408{
409   osd_ticks_t stopspin;
410   osd_ticks_t gotosleep;
411   //struct timespec sleep = { 0, 100000 }, remaining;
412   
413   if (!timeout && !event->signalled)
414      return FALSE;
415
416   stopspin = osd_ticks() + timeout;
417   gotosleep = osd_ticks() + osd_ticks_per_second()/1000;
418
419   if (event->autoreset)
420   {
421      while (compare_exchange32(&event->signalled, 1, 0) == 1)
422      {
423         if (osd_ticks()>=stopspin)
424            return FALSE;
425         osd_yield_processor();
426         //if (osd_ticks()>=gotosleep)
427            //usleep(100);
428            //nanosleep(&sleep, &remaining); // sleep for 100us
429      }
430   }
431   else
432   {
433      while (!event->signalled)
434      {
435         if (osd_ticks()>=stopspin)
436            return FALSE;
437         osd_yield_processor();
438         //if (osd_ticks()>=gotosleep)
439            //usleep(100);
440            //nanosleep(&sleep, &remaining); // sleep for 100us
441      }
442   }
443   return TRUE;
444}
445#endif
446
398447//============================================================
399448//  osd_thread_create
400449//============================================================
src/osd/sdl/debugosx.c
r1896r1897
31193119   info->minwidth = 0;
31203120   info->maxwidth = 0;
31213121   for (cpunum = MAX_CPU - 1; (INT32)cpunum >= 0; cpunum--)
3122      if (Machine->drv->cpu[cpunum].type != CPU_DUMMY)
3122      if (Machine->config->cpu[cpunum].type != CPU_DUMMY)
31233123      {
31243124         UINT32 regchars, dischars, conchars;
31253125         UINT32 minwidth, maxwidth;
src/osd/sdl/sdlfile.c
r1896r1897
438438#endif
439439
440440// these are MESS specific - DO NOT TOUCH!!@!
441#ifdef MESS
441442
442443//============================================================
443444//   osd_copyfile
r1896r1897
483484   
484485   return result;
485486}
486
487#endif
src/osd/sdl/sdlsync.h
r1896r1897
5757-----------------------------------------------------------------------------*/
5858int osd_event_wait(osd_event *event, osd_ticks_t timeout);
5959
60//FIXME: description
6160/*-----------------------------------------------------------------------------
62    osd_event_wait_multiple: wait for multiple events
63
64    Parameters:
65
66        event - The event to set to non-signalled state
67
68    Return value:
69
70       None
71-----------------------------------------------------------------------------*/
72
73int osd_event_wait_multiple(int num, osd_event **events, osd_ticks_t timeout);
74
75/*-----------------------------------------------------------------------------
7661    osd_event_reset: reset an event to non-signalled state
7762
7863    Parameters:
r1896r1897
8671void osd_event_reset(osd_event *event);
8772
8873/*-----------------------------------------------------------------------------
89    osd_event_reset: reset an event to non-signalled state
90
91    Parameters:
92
93        event - The event to set to non-signalled state
94
95    Return value:
96
97       None
98-----------------------------------------------------------------------------*/
99
100int osd_event_wait_multiple(int num, osd_event *events[], osd_ticks_t timeout);
101
102/*-----------------------------------------------------------------------------
10374    osd_event_set: set an event to signalled state
10475
10576    Parameters:
src/osd/sdl/sdlmain.c
r1896r1897
1414#include <stdlib.h>
1515
1616// MAME headers
17#include "driver.h"
18#include "window.h"
19#include "options.h"
17#include "osdepend.h"
18#include "mame.h"
2019#include "clifront.h"
20
21// OSD headers
22#include "video.h"
2123#include "input.h"
22
2324#include "osdsdl.h"
2425
2526// we override SDL's normal startup on Win32
src/osd/sdl/osdsdl.h
r1896r1897
33
44/* Notes
55
6   - removed  osd_event_wait_multiple from sdlsync.h
7   - removed some includes not needed
8   - reorganized texcopy/scale2x
9   - removed effect.h
10   - removed effect_func.h
11   - indenting
12   - put osd_copyfile, osd_stat into #ifdef MESS
13   - added code which implements events without the need
14      for pthreads. This is commented out, since
15      owever, it horribly fails, if
16      threads > num processors as is the case if you
17      enable "-mt"
18    - rename mame_bitmap to bitmap_t
19    - introduced define OSDWORK_CALLBACK to prototype and
20      define functions to be passed to sdlwork.c
21
622   - fixes from judge for warnings / may reappear (glade)
723   - more warnings fixed / may reappear (glade)
824   - moved osdefs.h into sdlprefix.h
src/osd/sdl/sdlmisc.c
r1896r1897
2626-UCLOCKS_PER_SECOND is now always 1000000, instead of making it depent on
2727 the system headers. (Hans de Goede)
2828*/
29/* Todo ?
30-rename uclock to sysdep_clock (Hans de Goede)
31*/
3229#include <stdio.h>
3330#include <stdlib.h>
3431#include <string.h>
3532#include <unistd.h>
3633#include <ctype.h>
3734#include <stdlib.h>
35
36#include "osdcore.h"
37
3838#if defined(SDLMAME_UNIX) && !defined(SDLMAME_DARWIN)
3939#include <sys/mman.h>
4040#endif
src/osd/sdl/drawogl.c
r1896r1897
121121// OSD headers
122122#include "osdsdl.h"
123123#include "window.h"
124#include "effect.h"
125124
126125//============================================================
127126//  DEBUGGING
r1896r1897
159158   return (HashT)texture->base ^ (flags & (PRIMFLAG_BLENDMODE_MASK | PRIMFLAG_TEXFORMAT_MASK));
160159}
161160
162INLINE void set_blendmode(sdl_info *sdl, int blendmode, texture_info *texture)
161INLINE void set_blendmode(sdl_info *sdl, int blendmode)
163162{
164163   // try to minimize texture state changes
165164   if (blendmode != sdl->last_blendmode)
r1896r1897
187186   }
188187}
189188
189#if 0
190190INLINE int better_mode(int width0, int height0, int width1, int height1, float desired_aspect)
191191{
192192   float aspect0 = (float)width0 / (float)height0;
193193   float aspect1 = (float)width1 / (float)height1;
194194   return (fabs(desired_aspect - aspect0) < fabs(desired_aspect - aspect1)) ? 0 : 1;
195195}
196#endif
196197
197198INLINE UINT32 ycc_to_rgb(UINT8 y, UINT8 cb, UINT8 cr)
198199{
r1896r1897
273274
274275static int glsl_shader_feature = GLSL_SHADER_FEAT_PLAIN;
275276
276// texcopy functions
277void texcopy_argb32(texture_info *texture, const render_texinfo *texsource);
278void texcopy_rgb32(texture_info *texture, const render_texinfo *texsource);
279void texcopy_rgb32_paletted(texture_info *texture, const render_texinfo *texsource);
280void texcopy_palette16(texture_info *texture, const render_texinfo *texsource);
281void texcopy_palette16a(texture_info *texture, const render_texinfo *texsource);
282void texcopy_rgb15(texture_info *texture, const render_texinfo *texsource);
283void texcopy_rgb15_paletted(texture_info *texture, const render_texinfo *texsource);
284void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource);
285void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo *texsource);
277//============================================================
278//  TEXCOPY FUNCS
279//============================================================
280
281static void texcopy_argb32(texture_info *texture, const render_texinfo *texsource);
282static void texcopy_rgb32(texture_info *texture, const render_texinfo *texsource);
283static void texcopy_rgb32_paletted(texture_info *texture, const render_texinfo *texsource);
284static void texcopy_palette16(texture_info *texture, const render_texinfo *texsource);
285static void texcopy_palette16a(texture_info *texture, const render_texinfo *texsource);
286static void texcopy_rgb15(texture_info *texture, const render_texinfo *texsource);
287static void texcopy_rgb15_paletted(texture_info *texture, const render_texinfo *texsource);
288static void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource);
289static void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo *texsource);
286290#ifdef SDLMAME_MACOSX
287void texcopy_yuv16_apple(texture_info *texture, const render_texinfo *texsource);
288void texcopy_yuv16_paletted_apple(texture_info *texture, const render_texinfo *texsource);
291static void texcopy_yuv16_apple(texture_info *texture, const render_texinfo *texsource);
292static void texcopy_yuv16_paletted_apple(texture_info *texture, const render_texinfo *texsource);
289293#endif
290294// 16 bpp destination texture texcopy functions
291void texcopy_palette16_argb1555(texture_info *texture, const render_texinfo *texsource);
292void texcopy_rgb15_argb1555(texture_info *texture, const render_texinfo *texsource);
293void texcopy_rgb15_paletted_argb1555(texture_info *texture, const render_texinfo *texsource);
295static void texcopy_palette16_argb1555(texture_info *texture, const render_texinfo *texsource);
296static void texcopy_rgb15_argb1555(texture_info *texture, const render_texinfo *texsource);
297static void texcopy_rgb15_paletted_argb1555(texture_info *texture, const render_texinfo *texsource);
294298
295// textures
299//============================================================
300//  SCALE2x FUNCS
301//============================================================
302
303static void scale2x_argb32(texture_info *texture, const render_texinfo *texsource);
304static void scale2x_rgb32(texture_info *texture, const render_texinfo *texsource);
305static void scale2x_rgb32_paletted(texture_info *texture, const render_texinfo *texsource);
306static void scale2x_palette16(texture_info *texture, const render_texinfo *texsource);
307static void scale2x_palette16a(texture_info *texture, const render_texinfo *texsource);
308static void scale2x_rgb15(texture_info *texture, const render_texinfo *texsource);
309static void scale2x_rgb15_paletted(texture_info *texture, const render_texinfo *texsource);
310static void scale2x_yuv16(texture_info *texture, const render_texinfo *texsource);
311static void scale2x_yuv16_paletted(texture_info *texture, const render_texinfo *texsource);
312static void scale2x_palette16_argb1555(texture_info *texture, const render_texinfo *texsource);
313static void scale2x_rgb15_argb1555(texture_info *texture, const render_texinfo *texsource);
314static void scale2x_rgb15_paletted_argb1555(texture_info *texture, const render_texinfo *texsource);
315
316//============================================================
317//  Textures
318//============================================================
319
320static void texture_set_data(texture_info *texture, const render_texinfo *texsource);
296321static texture_info *texture_create(sdl_info *sdl, sdl_window_info *window, const render_texinfo *texsource, UINT32 flags);
297static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_texinfo *texsource, UINT32 flags);
298322static texture_info *texture_find(sdl_info *sdl, const render_primitive *prim);
299323static texture_info * texture_update(sdl_info *sdl, sdl_window_info *window, const render_primitive *prim, int shaderIdx);
300324static void texture_all_disable(sdl_info *sdl);
301325static void texture_disable(sdl_info *sdl, texture_info * texture);
302326
303327//============================================================
304//  STATIC Variables
328//  STAgTIC Variables
305329//============================================================
306330
307331static int shown_video_info = 0;
r1896r1897
343367    */
344368
345369   #define OSD_GL(ret,func,params) \
346   if (!(func = SDL_GL_GetProcAddress( #func ) )) \
370   if (!( func = (void *) SDL_GL_GetProcAddress( #func ) )) \
347371      { err++; mame_printf_error("GL function %s not found!\n", #func ); }
348372
349373   #define OSD_GL_UNUSED(ret,func,params)
r1896r1897
928952      blittimer = 2;
929953   }
930954
931        if ( !window->initialized ||
932             window->sdlsurf->w!= surf_w || window->sdlsurf->h!= surf_h
933           )
934        {
955   if ( !window->initialized ||
956         window->sdlsurf->w!= surf_w || window->sdlsurf->h!= surf_h )
957   {
935958      if ( !window->initialized )
936959      {
937960         loadGLExtensions(sdl);
938961      }
962     
963      surf_w=window->sdlsurf->w;
964      surf_h=window->sdlsurf->h;
939965
940                surf_w=window->sdlsurf->w;
941                surf_h=window->sdlsurf->h;
966      // we're doing nothing 3d, so the Z-buffer is currently not interesting
967      glDisable(GL_DEPTH_TEST);
942968
943                // we're doing nothing 3d, so the Z-buffer is currently not interesting
944                glDisable(GL_DEPTH_TEST);
969      if (options_get_bool(mame_options(), OPTION_ANTIALIAS))
970      {
971         // enable antialiasing for lines
972         glEnable(GL_LINE_SMOOTH);
973         // enable antialiasing for points
974         glEnable(GL_POINT_SMOOTH);
945975
946                if (options_get_bool(mame_options(), OPTION_ANTIALIAS))
947                {
948                    // enable antialiasing for lines
949                    glEnable(GL_LINE_SMOOTH);
950                    // enable antialiasing for points
951                    glEnable(GL_POINT_SMOOTH);
952
953                    // prefer quality to speed
954                    glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
955                    glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
956                }
957                else
958                {
959                    glDisable(GL_LINE_SMOOTH);
960                    glDisable(GL_POINT_SMOOTH);
961                }
962
963                // enable blending
964                glEnable(GL_BLEND);
965                glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
966                sdl->last_blendmode = BLENDMODE_ALPHA;
967
968                // set lines and points just barely above normal size to get proper results
969                glLineWidth(video_config.beamwidth);
970                glPointSize(video_config.beamwidth);
971
972                // set up a nice simple 2D coordinate system, so GL behaves exactly how we'd like.
973                //
974                // (0,0)     (w,0)
975                //   |~~~~~~~~~|
976                //   |          |
977                //   |          |
978                //   |          |
979                //   |_________|
980                // (0,h)     (w,h)
981
982                glViewport(0.0, 0.0, (GLsizei)window->sdlsurf->w, (GLsizei)window->sdlsurf->h);
983                glMatrixMode(GL_PROJECTION);
984                glLoadIdentity();
985                glOrtho(0.0, (GLdouble)window->sdlsurf->w, (GLdouble)window->sdlsurf->h, 0.0, 0.0, -1.0);
976         // prefer quality to speed
977         glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
978         glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
979      }
980      else
981      {
982         glDisable(GL_LINE_SMOOTH);
983         glDisable(GL_POINT_SMOOTH);
984      }
985     
986      // enable blending
987      glEnable(GL_BLEND);
988      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
989      sdl->last_blendmode = BLENDMODE_ALPHA;
990     
991      // set lines and points just barely above normal size to get proper results
992      glLineWidth(video_config.beamwidth);
993      glPointSize(video_config.beamwidth);
994     
995      // set up a nice simple 2D coordinate system, so GL behaves exactly how we'd like.
996      //
997      // (0,0)     (w,0)
998      //   |~~~~~~~~~|
999      //   |          |
1000      //   |          |
1001      //   |          |
1002      //   |_________|
1003      // (0,h)     (w,h)
1004     
1005      glViewport(0.0, 0.0, (GLsizei)window->sdlsurf->w, (GLsizei)window->sdlsurf->h);
1006      glMatrixMode(GL_PROJECTION);
1007      glLoadIdentity();
1008      glOrtho(0.0, (GLdouble)window->sdlsurf->w, (GLdouble)window->sdlsurf->h, 0.0, 0.0, -1.0);
9861009      glMatrixMode(GL_MODELVIEW);
987                glLoadIdentity();
988
989                if ( ! window->initialized )
1010      glLoadIdentity();
1011           
1012      if ( ! window->initialized )
9901013      {
991                        glEnableClientState(GL_VERTEX_ARRAY);
992                        glVertexPointer(2, GL_FLOAT, 0, texVerticex); // no VBO, since it's too volatile
993
1014         glEnableClientState(GL_VERTEX_ARRAY);
1015         glVertexPointer(2, GL_FLOAT, 0, texVerticex); // no VBO, since it's too volatile
1016         
9941017         window->initialized = 1;
995                }
996        }
1018      }
1019   }
9971020
9981021   // compute centering parameters
9991022   vofs = hofs = 0.0f;
r1896r1897
10511074                pendingPrimitive=GL_NO_PRIMITIVE;
10521075            }
10531076
1054                                if ( pendingPrimitive==GL_NO_PRIMITIVE )
1055                                    set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags), 0);
1077                if ( pendingPrimitive==GL_NO_PRIMITIVE )
1078                   set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags));
10561079
10571080            glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a);
10581081
1059                                if(pendingPrimitive!=curPrimitive)
1060                                {
1061                                    glBegin(curPrimitive);
1062                                    pendingPrimitive=curPrimitive;
1063                                }
1082            if(pendingPrimitive!=curPrimitive)
1083            {
1084               glBegin(curPrimitive);
1085               pendingPrimitive=curPrimitive;
1086            }
10641087
10651088            // check if it's really a point
10661089            if (curPrimitive==GL_POINTS)
10671090            {
1068                                    glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs);
1091               glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs);
10691092            }
10701093            else
10711094            {
1072                                    glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs);
1073                                    glVertex2f(prim->bounds.x1+hofs, prim->bounds.y1+vofs);
1095               glVertex2f(prim->bounds.x0+hofs, prim->bounds.y0+vofs);
1096               glVertex2f(prim->bounds.x1+hofs, prim->bounds.y1+vofs);
10741097            }
10751098            break;
10761099
10771100         case RENDER_PRIMITIVE_QUAD:
10781101
1079                                if(pendingPrimitive!=GL_NO_PRIMITIVE)
1102            if(pendingPrimitive!=GL_NO_PRIMITIVE)
10801103            {
10811104                glEnd();
10821105                pendingPrimitive=GL_NO_PRIMITIVE;
10831106            }
10841107
1085                                glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a);
1108            glColor4f(prim->color.r, prim->color.g, prim->color.b, prim->color.a);
10861109
1087            set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags), texture);
1110            set_blendmode(sdl, PRIMFLAG_GET_BLENDMODE(prim->flags));
10881111
10891112            texture = texture_update(sdl, window, prim, 0);
10901113
r1896r1897
11341157               glDrawArrays(GL_QUADS, 0, 4);
11351158            }
11361159
1137                                if ( texture )
1138                                {
1139                                        texture_disable(sdl, texture);
1140                                        texture=NULL;
1141                                }
1142                                break;
1160            if ( texture )
1161            {
1162               texture_disable(sdl, texture);
1163               texture=NULL;
1164            }
1165            break;
11431166      }
11441167   }
11451168
1146        if(pendingPrimitive!=GL_NO_PRIMITIVE)
1147        {
1148                glEnd();
1149                pendingPrimitive=GL_NO_PRIMITIVE;
1150        }
1169   if(pendingPrimitive!=GL_NO_PRIMITIVE)
1170   {
1171      glEnd();
1172      pendingPrimitive=GL_NO_PRIMITIVE;
1173   }
11511174
1152
11531175   osd_lock_release(window->primlist->lock);
11541176
11551177   SDL_GL_SwapBuffers();
r1896r1897
16031625            return -1;
16041626        default:
16051627            mame_printf_error("GL FBO: incomplete, implementation ERROR\n");
1606            return -1;
1628            /* fall through */
16071629    }
16081630    return -1;
16091631}
r1896r1897
21962218//  texture_set_data
21972219//============================================================
21982220
2199static void texture_set_data(sdl_info *sdl, texture_info *texture, const render_texinfo *texsource, UINT32 flags)
2221static void texture_set_data(texture_info *texture, const render_texinfo *texsource)
22002222{
22012223   if ( texture->type == TEXTURE_TYPE_DYNAMIC )
22022224   {
r1896r1897
22042226      assert(!texture->nocopy);
22052227
22062228      texture->data = pfn_glMapBuffer(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY);
2207        }
2229   }
22082230
22092231   // note that nocopy and borderpix are mutually exclusive, IOW
22102232   // they cannot be both true, thus this cannot lead to the
2211        // borderpix code below writing to texsource->base .
2212        if (texture->nocopy)
2213                texture->data = texsource->base;
2233   // borderpix code below writing to texsource->base .
2234   if (texture->nocopy)
2235      texture->data = texsource->base;
22142236
22152237   // always fill non-wrapping textures with an extra pixel on the top
22162238   if (texture->borderpix)
2217        {
2239   {
22182240      memset(texture->data, 0,
2219                       (texsource->width * texture->xprescale + 2) * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]);
2220        }
2241            (texsource->width * texture->xprescale + 2) * texture->texProperties[SDL_TEXFORMAT_PIXEL_SIZE]);
2242   }   
22212243
22222244   // when nescesarry copy (and convert) the data
22232245   if (!texture->nocopy)
2224        {
2225                assert(texture->texCopyFn);
2226                texture->texCopyFn(texture, texsource);
2227        }
2246   {
2247      assert(texture->texCopyFn);
2248      texture->texCopyFn(texture, texsource);
2249   }
22282250
22292251   // always fill non-wrapping textures with an extra pixel on the bottom
22302252   if (texture->borderpix)
r1896r1897
23742396   {
23752397      // 1:1 tex coord CCW (0/0) (1/0) (1/1) (0/1)
23762398      // we must go CW here due to the mame bitmap order
2377      texture->texCoord[0]=ustart + du * 0.0;
2378      texture->texCoord[1]=vstart + dv * 1.0;
2379      texture->texCoord[2]=ustart + du * 1.0;
2380      texture->texCoord[3]=vstart + dv * 1.0;
2381      texture->texCoord[4]=ustart + du * 1.0;
2382      texture->texCoord[5]=vstart + dv * 0.0;
2383      texture->texCoord[6]=ustart + du * 0.0;
2384      texture->texCoord[7]=vstart + dv * 0.0;
2399      texture->texCoord[0]=ustart + du * 0.0f;
2400      texture->texCoord[1]=vstart + dv * 1.0f;
2401      texture->texCoord[2]=ustart + du * 1.0f;
2402      texture->texCoord[3]=vstart + dv * 1.0f;
2403      texture->texCoord[4]=ustart + du * 1.0f;
2404      texture->texCoord[5]=vstart + dv * 0.0f;
2405      texture->texCoord[6]=ustart + du * 0.0f;
2406      texture->texCoord[7]=vstart + dv * 0.0f;
23852407   } else {
23862408      // transformation: mamebm -> scrn
23872409      texture->texCoord[0]=ustart + du * prim->texcoords.tl.u;
r1896r1897
23952417   }
23962418}
23972419
2398static void texture_mpass_flip(sdl_info *sdl, sdl_window_info *window, texture_info *texture, int shaderIdx)
2420static void texture_mpass_flip(sdl_info *sdl, texture_info *texture, int shaderIdx)
23992421{
24002422   UINT32 mpass_src_idx = texture->mpass_dest_idx;
24012423
r1896r1897
25182540         texture_shader_update(sdl, window, texture, shaderIdx);
25192541         if ( sdl->glsl_program_num>1 )
25202542         {
2521            texture_mpass_flip(sdl, window, texture, shaderIdx);
2543            texture_mpass_flip(sdl, texture, shaderIdx);
25222544         }
25232545      }
25242546
r1896r1897
25292551            texture->texinfo.seqid = prim->texture.seqid;
25302552
25312553            // if we found it, but with a different seqid, copy the data
2532            texture_set_data(sdl, texture, &prim->texture, prim->flags);
2554            texture_set_data(texture, &prim->texture);
25332555            texBound=1;
25342556         }
25352557      }
r1896r1897
25562578
25572579static void texture_disable(sdl_info *sdl, texture_info * texture)
25582580{
2559        if ( texture->type == TEXTURE_TYPE_SHADER )
2560        {
2561                assert ( sdl->useglsl );
2581   if ( texture->type == TEXTURE_TYPE_SHADER )
2582   {
2583      assert ( sdl->useglsl );
25622584      pfn_glUseProgramObjectARB(0); // back to fixed function pipeline
2563        } else if ( texture->type == TEXTURE_TYPE_DYNAMIC )
2564        {
2565                pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0);
2566                glDisable(texture->texTarget);
2567        } else {
2568                glDisable(texture->texTarget);
2569        }
2585   } else if ( texture->type == TEXTURE_TYPE_DYNAMIC )
2586   {
2587      pfn_glBindBuffer( GL_PIXEL_UNPACK_BUFFER_ARB, 0);
2588      glDisable(texture->texTarget);
2589   } else {
2590      glDisable(texture->texTarget);
2591   }
25702592}
25712593
25722594static void texture_all_disable(sdl_info *sdl)
r1896r1897
26982720//  TEXCOPY FUNCS
26992721//============================================================
27002722
2701#define SDL_TEXFORMAT SDL_TEXFORMAT_ARGB32
27022723#include "texcopy.c"
27032724
2704#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32
2705#include "texcopy.c"
2706
2707#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32_PALETTED
2708#include "texcopy.c"
2709
2710#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16
2711#include "texcopy.c"
2712
2713#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16A
2714#include "texcopy.c"
2715
2716#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15
2717#include "texcopy.c"
2718
2719#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED
2720#include "texcopy.c"
2721
2722#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16_ARGB1555
2723#include "texcopy.c"
2724
2725#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_ARGB1555
2726#include "texcopy.c"
2727
2728#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555
2729#include "texcopy.c"
2730
2731#ifdef SDLMAME_MACOSX /* native MacOS X composite texture format */
2732
2733#define SDL_TEXFORMAT SDL_TEXFORMAT_YUY16
2734#include "texcopy.c"
2735
2736#define SDL_TEXFORMAT SDL_TEXFORMAT_YUY16_PALETTED
2737#include "texcopy.c"
2738
2739#endif
2740
27412725//============================================================
2742//  MANUAL TEXCOPY FUNCS
2743//  (YUY format is weird and doesn't fit the assumptions of the
2744//   standard macros so we handle it here
2726//  SCALE2x FUNCS
27452727//============================================================
27462728
2747void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource)
2748{
2749   int x, y;
2750   UINT32 *dst;
2751   UINT16 *src;
2752
2753   // loop over Y
2754   for (y = 0; y < texsource->height; y++)
2755   {
2756      src = (UINT16 *)texsource->base + y * texsource->rowpixels;
2757      dst = (UINT32 *)texture->data + (y * texture->yprescale + texture->borderpix) * texture->rawwidth;
2758
2759      // always fill non-wrapping textures with an extra pixel on the left
2760      if (texture->borderpix)
2761         *dst++ = 0;
2762
2763      // we don't support prescale for YUV textures
2764      for (x = 0; x < texsource->width/2; x++)
2765      {
2766         UINT16 srcpix0 = *src++;
2767         UINT16 srcpix1 = *src++;
2768         UINT8 cb = srcpix0 & 0xff;
2769         UINT8 cr = srcpix1 & 0xff;
2770   
2771         *dst++ = ycc_to_rgb(srcpix0 >> 8, cb, cr);
2772         *dst++ = ycc_to_rgb(srcpix1 >> 8, cb, cr);
2773      }
2774      break;
2775     
2776      // always fill non-wrapping textures with an extra pixel on the right
2777      #if 0
2778      if (texture->borderpix)
2779         *dst++ = 0;
2780      #endif
2781   }
2782}
2783
2784void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo *texsource)
2785{
2786   int x, y;
2787   UINT32 *dst;
2788   UINT16 *src;
2789
2790   // loop over Y
2791   for (y = 0; y < texsource->height; y++)
2792   {
2793      src = (UINT16 *)texsource->base + y * texsource->rowpixels;
2794      dst = (UINT32 *)texture->data + (y * texture->yprescale + texture->borderpix) * texture->rawwidth;
2795
2796      // always fill non-wrapping textures with an extra pixel on the left
2797      if (texture->borderpix)
2798         *dst++ = 0;
2799
2800      // we don't support prescale for YUV textures
2801      for (x = 0; x < texsource->width/2; x++)
2802      {
2803         UINT16 srcpix0 = *src++;
2804         UINT16 srcpix1 = *src++;
2805         UINT8 cb = srcpix0 & 0xff;
2806         UINT8 cr = srcpix1 & 0xff;
2807   
2808         *dst++ = ycc_to_rgb(texsource->palette[0x000 + (srcpix0 >> 8)], cb, cr);
2809         *dst++ = ycc_to_rgb(texsource->palette[0x000 + (srcpix1 >> 8)], cb, cr);
2810      }
2811      break;
2812     
2813      // always fill non-wrapping textures with an extra pixel on the right
2814      #if 0
2815      if (texture->borderpix)
2816         *dst++ = 0;
2817      #endif
2818   }
2819}
2820
2729#include "scale2x.c"
src/osd/sdl/sound.c
r1896r1897
2020#endif
2121
2222// MAME headers
23#include "driver.h"
23#include "mame.h"
2424#include "osdepend.h"
25#include "window.h"
26#include "video.h"
2725#include "osdsdl.h"
2826
2927//============================================================
r1896r1897
220218   int count = bytes_to_copy/2;
221219   while (count>0)
222220   {   
223      *d++ = *data++ * level/128;
221      *d++ = (*data++ * level) >> 7; /* / 128 */
224222      count--;
225223   }
226224}
r1896r1897
283281   if (machine->sample_rate != 0 && stream_buffer)
284282   {
285283      int bytes_this_frame = samples_this_frame * sizeof(INT16) * 2;
286      int play_position, write_position, orig_write, stream_in;
287
284      int play_position, write_position, stream_in;
285#if LOG_SOUND
286      int orig_write;
287#endif
288288      play_position = stream_playpos;
289289
290290      write_position = stream_playpos + ((machine->sample_rate / 50) * sizeof(INT16) * 2);
291#if LOG_SOUND
291292      orig_write = write_position;
293#endif
292294
293295      if (!stream_in_initialized)
294296      {
r1896r1897
527529
528530static int sdl_create_buffers(void)
529531{
530   mame_printf_verbose("sdl_create_buffers: creating stream buffer of %d bytes\n", stream_buffer_size);
532   mame_printf_verbose("sdl_create_buffers: creating stream buffer of %u bytes\n", stream_buffer_size);
531533
532534   stream_buffer = (INT8 *)malloc(stream_buffer_size);
533535   memset(stream_buffer, 0, stream_buffer_size);
src/osd/sdl/texcopy.c
r1896r1897
1#include "window.h"
1
2#ifndef SDL_TEXFORMAT
3
4#define SDL_TEXFORMAT SDL_TEXFORMAT_ARGB32
5#include "texcopy.c"
6
7#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32
8#include "texcopy.c"
9
10#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB32_PALETTED
11#include "texcopy.c"
12
13#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16
14#include "texcopy.c"
15
16#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16A
17#include "texcopy.c"
18
19#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15
20#include "texcopy.c"
21
22#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED
23#include "texcopy.c"
24
25#define SDL_TEXFORMAT SDL_TEXFORMAT_PALETTE16_ARGB1555
26#include "texcopy.c"
27
28#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_ARGB1555
29#include "texcopy.c"
30
31#define SDL_TEXFORMAT SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555
32#include "texcopy.c"
33
34#ifdef SDLMAME_MACOSX /* native MacOS X composite texture format */
35
36#define SDL_TEXFORMAT SDL_TEXFORMAT_YUY16
37#include "texcopy.c"
38
39#define SDL_TEXFORMAT SDL_TEXFORMAT_YUY16_PALETTED
40#include "texcopy.c"
41
42#endif
43
44//============================================================
45//  MANUAL TEXCOPY FUNCS
46//  (YUY format is weird and doesn't fit the assumptions of the
47//   standard macros so we handle it here
48//============================================================
49
50static void texcopy_yuv16(texture_info *texture, const render_texinfo *texsource)
51{
52   int x, y;
53   UINT32 *dst;
54   UINT16 *src;
55
56   // loop over Y
57   for (y = 0; y < texsource->height; y++)
58   {
59      src = (UINT16 *)texsource->base + y * texsource->rowpixels;
60      dst = (UINT32 *)texture->data + (y * texture->yprescale + texture->borderpix) * texture->rawwidth;
61
62      // always fill non-wrapping textures with an extra pixel on the left
63      if (texture->borderpix)
64         *dst++ = 0;
65
66      // we don't support prescale for YUV textures
67      for (x = 0; x < texsource->width/2; x++)
68      {
69         UINT16 srcpix0 = *src++;
70         UINT16 srcpix1 = *src++;
71         UINT8 cb = srcpix0 & 0xff;
72         UINT8 cr = srcpix1 & 0xff;
73   
74         *dst++ = ycc_to_rgb(srcpix0 >> 8, cb, cr);
75         *dst++ = ycc_to_rgb(srcpix1 >> 8, cb, cr);
76      }
77      break;
78     
79      // always fill non-wrapping textures with an extra pixel on the right
80      #if 0
81      if (texture->borderpix)
82         *dst++ = 0;
83      #endif
84   }
85}
86
87static void texcopy_yuv16_paletted(texture_info *texture, const render_texinfo *texsource)
88{
89   int x, y;
90   UINT32 *dst;
91   UINT16 *src;
92
93   // loop over Y
94   for (y = 0; y < texsource->height; y++)
95   {
96      src = (UINT16 *)texsource->base + y * texsource->rowpixels;
97      dst = (UINT32 *)texture->data + (y * texture->yprescale + texture->borderpix) * texture->rawwidth;
98
99      // always fill non-wrapping textures with an extra pixel on the left
100      if (texture->borderpix)
101         *dst++ = 0;
102
103      // we don't support prescale for YUV textures
104      for (x = 0; x < texsource->width/2; x++)
105      {
106         UINT16 srcpix0 = *src++;
107         UINT16 srcpix1 = *src++;
108         UINT8 cb = srcpix0 & 0xff;
109         UINT8 cr = srcpix1 & 0xff;
110   
111         *dst++ = ycc_to_rgb(texsource->palette[0x000 + (srcpix0 >> 8)], cb, cr);
112         *dst++ = ycc_to_rgb(texsource->palette[0x000 + (srcpix1 >> 8)], cb, cr);
113      }
114      break;
115     
116      // always fill non-wrapping textures with an extra pixel on the right
117      #if 0
118      if (texture->borderpix)
119         *dst++ = 0;
120      #endif
121   }
122}
123
124#else // recursive include
125
2126#include "texsrc.h"
3127
4void FUNC_NAME(texcopy)(texture_info *texture, const render_texinfo *texsource)
128static void FUNC_NAME(texcopy)(texture_info *texture, const render_texinfo *texsource)
5129{
6130   int x, y;
7131   DEST_TYPE *dst;
r1896r1897
62186}
63187
64188#undef SDL_TEXFORMAT
189#endif
src/osd/sdl/input.c
r1896r1897
1414
1515// standard sdl header
1616#include <SDL/SDL.h>
17#include <SDL/SDL_thread.h>
1817#include <ctype.h>
1918#include <stddef.h>
2019
2120// MAME headers
2221#include "osdepend.h"
23#include "driver.h"
24#include "ui.h"
2522
2623// MAMEOS headers
2724#include "window.h"
2825#include "input.h"
29#include "debugwin.h"
30#include "video.h"
31#include "config.h"
3226#include "osdsdl.h"
3327
3428#ifdef MESS
r1896r1897
160154
161155static int sixaxis_mode;
162156
163static int joy_logical[MAX_JOYSTICKS];
157//static int joy_logical[MAX_JOYSTICKS];
164158
165159//============================================================
166160//  PROTOTYPES
r1896r1897
343337   KE8(k,         l,         m,            n,         o,         p,         q,         r         )
344338   KE8(s,         t,         u,            v,         w,         x,         y,         z         )
345339   { SDLK_DELETE, "SDLK_DELETE" },
346   //FIXME:Proper check for version
347340#if (!SDL_VERSION_ATLEAST(1,3,0))
348341   KE8(WORLD_0,   WORLD_1,   WORLD_2,   WORLD_3,   WORLD_4,   WORLD_5,   WORLD_6,   WORLD_7      )
349342   KE8(WORLD_8,   WORLD_9,   WORLD_10,   WORLD_11,   WORLD_12,   WORLD_13,   WORLD_14,   WORLD_15   )
r1896r1897
605598         joy_map[first_free].ismapped = 1;
606599      }
607600     
608      joy_logical[physical_stick] = stick;
601      //joy_logical[physical_stick] = stick;
609602
610603      mame_printf_verbose("Joystick: %s\n", joy_name);
611604      mame_printf_verbose("Joystick:   ...  %d axes, %d buttons %d hats\n", SDL_JoystickNumAxes(joy), SDL_JoystickNumButtons(joy), SDL_JoystickNumHats(joy));
src/osd/sdl/sdltime.c
r1896r1897
332332      gettimeofday(&tp, NULL);
333333      if (start_sec==0)
334334         start_sec = tp.tv_sec;
335      return (tp.tv_sec - start_sec) * 1000000 + tp.tv_usec;
335      return (tp.tv_sec - start_sec) * (osd_ticks_t) 1000000 + tp.tv_usec;
336336}
337337
338338
src/osd/sdl/window.c
r1896r1897
2222#include <sys/time.h>
2323#endif
2424
25#include "osd_opengl.h"
26
2725// standard C headers
2826#include <math.h>
2927#include <unistd.h>
r1896r1897
3230
3331#include "osdcomm.h"
3432#include "osdepend.h"
35//#include "driver.h"
33#include "options.h"
34#include "ui.h"
3635
3736// OSD headers
3837
3938#include "window.h"
40#include "video.h"
4139#include "input.h"
42#include "options.h"
43#include "ui.h"
4440#include "osdsdl.h"
4541
4642#ifdef MESS
r1896r1897
5854#define ASSERT_USE(x)   assert(SDL_ThreadID() == x)
5955#endif
6056
61#define ASSERT_REDRAW_THREAD() ASSERT_USE(window_threadid)
62#define ASSERT_WINDOW_THREAD() ASSERT_USE(window_threadid)
63#define ASSERT_MAIN_THREAD() ASSERT_USE(main_threadid)
57#define ASSERT_REDRAW_THREAD()    ASSERT_USE(window_threadid)
58#define ASSERT_WINDOW_THREAD()    ASSERT_USE(window_threadid)
59#define ASSERT_MAIN_THREAD()    ASSERT_USE(main_threadid)
6460
61#define OSDWORK_CALLBACK(name)   void *name(void *param, ATTR_UNUSED int threadid)
62
6563// minimum window dimension
6664#define MIN_WINDOW_DIM               200
6765
r1896r1897
9795static int window_threadid;
9896static int dll_loaded;
9997
100
101static UINT32 last_update_time;
102
10398static const char *yuv_mode_names[] = { "none", "yv12", "yv12x2", "yuy2", "yuy2x2" };
10499
105100// debugger
106101//static int in_background;
107102
108//static int ui_temp_pause;
109//static int ui_temp_was_paused;
110
111//static UINT32 last_update_time;
112
113103static sdl_draw_callbacks draw;
114104
115105typedef struct _worker_param worker_param;
r1896r1897
128118
129119static void sdlwindow_exit(running_machine *machine);
130120static void sdlwindow_video_window_destroy(sdl_window_info *window);
131static void *draw_video_contents_wt(void *param, int threadid);
132static void *sdlwindow_video_window_destroy_wt(void *param, int threadid);
133static void *sdlwindow_resize_wt(void *param, int threadid);
134static void *sdlwindow_toggle_full_screen_wt(void *param, int threadid);
121static OSDWORK_CALLBACK( draw_video_contents_wt );
122static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt );
123static OSDWORK_CALLBACK( sdlwindow_resize_wt );
124static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt );
135125static void sdlwindow_clear_surface(sdl_window_info *window, int times);
136126static void sdlwindow_update_cursor_state(void);
137127static void sdlwindow_sync(void);
r1896r1897
190180//  (window thread)
191181//============================================================
192182
193static void *sdlwindow_thread_id(void *param, int threadid)
183static OSDWORK_CALLBACK(sdlwindow_thread_id)
194184{
195185   window_threadid = SDL_ThreadID();
196186
r1896r1897
279269//============================================================
280270
281271#ifdef SDLMAME_WIN32
282static void *sdlwindow_exit_wt(void *param, int threadid)
272static OSDWORK_CALLBACK( sdlwindow_exit_wt )
283273{
284274   SDL_Quit();
285275   return NULL;
r1896r1897
473463//  (main thread)
474464//============================================================
475465
476static void *sdlwindow_resize_wt(void *param, int threadid)
466static OSDWORK_CALLBACK( sdlwindow_resize_wt )
477467{
478468   sdl_window_info *window = sdl_window_list;
479469   worker_param *wp = (worker_param *) param;
r1896r1897
525515//  (window thread)
526516//============================================================
527517
528static void *sdlwindow_clear_surface_wt(void *param, int threadid)
518static OSDWORK_CALLBACK( sdlwindow_clear_surface_wt )
529519{
530520   worker_param *wp = (worker_param *) param;
531521   //sdl_window_info *window = sdl_window_list;
r1896r1897
570560//  (main thread)
571561//============================================================
572562
573static void *sdlwindow_toggle_full_screen_wt(void *param, int threadid)
563static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt )
574564{
575565   worker_param *wp = (worker_param *) param;
576566   sdl_window_info *window = wp->window;
r1896r1897
642632   }
643633}
644634
645static void *destroy_all_textures_wt(void *param, int threadid)
635static OSDWORK_CALLBACK( destroy_all_textures_wt )
646636{
647637   worker_param *wp = (worker_param *) param;
648638
r1896r1897
710700      if (new_prescale_effect != video_config.prescale_effect)
711701      {
712702         worker_param wp;
713         sdl_window_info *window = sdl_window_list;
714703
715704         clear_worker_param(&wp);
716705         wp.window = window;
r1896r1897
874863//  (main thread)
875864//============================================================
876865
877static void *sdlwindow_video_window_destroy_wt(void *param, int threadid)
866static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt )
878867{
879868   worker_param *wp = (worker_param *) param;
880869   sdl_window_info *window = wp->window;
r1896r1897
975964      for (i = 0; modes[i]; ++i)
976965      {
977966         // compute initial score based on difference between target and current
978         size_score = 1.0f / (1.0f + fabs((INT32)modes[i]->w - target_width) + fabs((INT32)modes[i]->h - target_height));
967         size_score = 1.0f / (1.0f + fabsf((INT32)modes[i]->w - target_width) + fabsf((INT32)modes[i]->h - target_height));
979968
980969         // if the mode is too small, give a big penalty
981970         if (modes[i]->w < minimum_width || modes[i]->h < minimum_height)
r1896r1897
10551044// while rendering is still in progress is all fine ..
10561045#if 0
10571046      // only block if we're throttled
1058      if (video_config.throttle) // || timeGetTime() - last_update_time > 250)
1047      if (video_config.throttle)
10591048         osd_lock_acquire(window->render_lock);
10601049      else
10611050#endif
r1896r1897
10761065         primlist = (*draw.window_get_primitives)(window);
10771066
10781067         // and redraw now
1079         last_update_time = SDL_GetTicks();
1068
10801069         wp.list = primlist;
10811070         wp.window = window;
10821071
r1896r1897
11751164//  (window thread)
11761165//============================================================
11771166
1178static void *complete_create_wt(void *param, int threadid)
1167static OSDWORK_CALLBACK( complete_create_wt )
11791168{
11801169   
11811170   worker_param *wp = (worker_param *) param;
r1896r1897
13231312}
13241313#endif
13251314
1326static void *draw_video_contents_wt(void * param, int threadid)
1315static OSDWORK_CALLBACK( draw_video_contents_wt )
13271316{
13281317   #ifndef SDLMAME_WIN32
13291318   const unsigned long frames_skip4fps = 100;
src/osd/sdl/testkeys.c
r1896r1897
4545//FIXME: SDL 1.3 Definitions are gone
4646#if (SDL_VERSION_ATLEAST(1,3,0))
4747   KE8(DELETE,      KP0,      KP1,         KP2,      KP3,      KP4,      KP5,      KP6         )
48
4948#else
5049   KE8(DELETE,      WORLD_0,   WORLD_1,      WORLD_2,   WORLD_3,   WORLD_4,   WORLD_5,   WORLD_6      )
5150   KE8(WORLD_7,   WORLD_8,   WORLD_9,      WORLD_10,   WORLD_11,   WORLD_12,   WORLD_13,   WORLD_14   )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team