Пример #1
0
void osd_init(running_machine *machine)
{
	int watchdog = options_get_int(mame_options(), WINOPTION_WATCHDOG);
	const char *stemp;

	// thread priority
	if (!(machine->debug_flags & DEBUG_FLAG_OSD_ENABLED))
		SetThreadPriority(GetCurrentThread(), options_get_int(mame_options(), WINOPTION_PRIORITY));

	// ensure we get called on the way out
	add_exit_callback(machine, osd_exit);

	// get number of processors
	stemp = options_get_string(mame_options(), WINOPTION_NUMPROCESSORS);

	osd_num_processors = 0;

	if (strcmp(stemp, "auto") != 0)
	{
		osd_num_processors = atoi(stemp);
		if (osd_num_processors < 1)
		{
			mame_printf_warning("Warning: numprocessors < 1 doesn't make much sense. Assuming auto ...\n");
			osd_num_processors = 0;
		}
	}

	// initialize the subsystems
	winvideo_init(machine);
	winsound_init(machine);
	wininput_init(machine);
	winoutput_init(machine);

	// hook up the debugger log
	if (options_get_bool(mame_options(), WINOPTION_OSLOG))
		add_logerror_callback(machine, output_oslog);

	// crank up the multimedia timer resolution to its max
	// this gives the system much finer timeslices
	timeresult = timeGetDevCaps(&caps, sizeof(caps));
	if (timeresult == TIMERR_NOERROR)
		timeBeginPeriod(caps.wPeriodMin);

	// set our multimedia tasks if we can
//      if (av_set_mm_thread_characteristics != NULL)
//          mm_task = (*av_set_mm_thread_characteristics)(TEXT("Playback"), &task_index);

	start_profiler();

	// if a watchdog thread is requested, create one
	if (watchdog != 0)
	{
		watchdog_reset_event = CreateEvent(NULL, FALSE, FALSE, NULL);
		assert_always(watchdog_reset_event != NULL, "Failed to create watchdog reset event");
		watchdog_exit_event = CreateEvent(NULL, TRUE, FALSE, NULL);
		assert_always(watchdog_exit_event != NULL, "Failed to create watchdog exit event");
		watchdog_thread = CreateThread(NULL, 0, watchdog_thread_entry, (LPVOID)(FPTR)watchdog, 0, NULL);
		assert_always(watchdog_thread != NULL, "Failed to create watchdog thread");
	}
}
Пример #2
0
void osd_init(running_machine *machine)
{
	// thread priority
	if (!options_get_bool(mame_options(), OPTION_DEBUG))
		SetThreadPriority(GetCurrentThread(), options_get_int(mame_options(), WINOPTION_PRIORITY));

	// ensure we get called on the way out
	add_exit_callback(machine, osd_exit);

	// initialize the subsystems
	winvideo_init(machine);
	winsound_init(machine);
	wininput_init(machine);
	winoutput_init(machine);

	// hook up the debugger log
	if (options_get_bool(mame_options(), WINOPTION_OSLOG))
		add_logerror_callback(machine, output_oslog);

	// crank up the multimedia timer resolution to its max
	// this gives the system much finer timeslices
	timeresult = timeGetDevCaps(&caps, sizeof(caps));
	if (timeresult == TIMERR_NOERROR)
		timeBeginPeriod(caps.wPeriodMin);

	// set our multimedia tasks if we can
//      if (av_set_mm_thread_characteristics != NULL)
//          mm_task = (*av_set_mm_thread_characteristics)(TEXT("Playback"), &task_index);

	start_profiler();
}
Пример #3
0
void sound_init(running_machine *machine)
{
	attotime update_frequency = SOUND_UPDATE_FREQUENCY;
	const char *filename;

	/* handle -nosound */
	nosound_mode = !options_get_bool(mame_options(), OPTION_SOUND);
	if (nosound_mode)
		Machine->sample_rate = 11025;

	/* count the speakers */
	for (totalspeakers = 0; Machine->drv->speaker[totalspeakers].tag; totalspeakers++) ;
	VPRINTF(("total speakers = %d\n", totalspeakers));

	/* allocate memory for mix buffers */
	leftmix = auto_malloc(Machine->sample_rate * sizeof(*leftmix));
	rightmix = auto_malloc(Machine->sample_rate * sizeof(*rightmix));
	finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix));

	/* allocate a global timer for sound timing */
	sound_update_timer = timer_alloc(sound_update, NULL);
	timer_adjust(sound_update_timer, update_frequency, 0, update_frequency);

	/* initialize the streams engine */
	VPRINTF(("streams_init\n"));
	streams_init(machine, update_frequency.attoseconds);

	/* now start up the sound chips and tag their streams */
	VPRINTF(("start_sound_chips\n"));
	start_sound_chips();

	/* then create all the speakers */
	VPRINTF(("start_speakers\n"));
	start_speakers();

	/* finally, do all the routing */
	VPRINTF(("route_sound\n"));
	route_sound();

	/* open the output WAV file if specified */
	filename = options_get_string(mame_options(), OPTION_WAVWRITE);
	if (filename[0] != 0)
		wavfile = wav_open(filename, machine->sample_rate, 2);

	/* enable sound by default */
	global_sound_enabled = TRUE;
	sound_muted = FALSE;
	sound_set_attenuation(options_get_int(mame_options(), OPTION_VOLUME));

	/* register callbacks */
	config_register("mixer", sound_load, sound_save);
	add_pause_callback(machine, sound_pause);
	add_reset_callback(machine, sound_reset);
	add_exit_callback(machine, sound_exit);
}
Пример #4
0
static void sdlwindow_update_cursor_state(running_machine *machine, sdl_window_info *window)
{
#if (SDL_VERSION_ATLEAST(1,3,0))
	// do not do mouse capture if the debugger's enabled to avoid
	// the possibility of losing control
	if (!options_get_bool(mame_options(), OPTION_DEBUG))
	{
		//FIXME: SDL1.3: really broken: the whole SDL code
		//       will only work correct with relative mouse movements ...
		//SDL_SetRelativeMouseMode
		if (!window->fullscreen && !sdlinput_should_hide_mouse(machine))
		{
			SDL_ShowCursor(SDL_ENABLE);
			if (SDL_GetWindowGrab(window->window_id ))
				SDL_SetWindowGrab(window->window_id, 0);
		}
		else
		{
			SDL_ShowCursor(SDL_DISABLE);
			if (!SDL_GetWindowGrab(window->window_id))
				SDL_SetWindowGrab(window->window_id, 1);
		}
		SDL_SetCursor(NULL); // Force an update in case the underlying driver has changed visibility
	}

#else
	// do not do mouse capture if the debugger's enabled to avoid
	// the possibility of losing control
	if (!options_get_bool(mame_options(), OPTION_DEBUG))
	{
		if ( window->fullscreen || sdlinput_should_hide_mouse(machine) )
		{
			SDL_ShowCursor(SDL_DISABLE);
			if (!SDL_WM_GrabInput(SDL_GRAB_QUERY))
			{
				SDL_WM_GrabInput(SDL_GRAB_ON);
			}
		}
		else
		{
			SDL_ShowCursor(SDL_ENABLE);
			if (SDL_WM_GrabInput(SDL_GRAB_QUERY))
			{
				SDL_WM_GrabInput(SDL_GRAB_OFF);
			}
		}
	}
#endif
}
Пример #5
0
static int write_config(const char *filename, const game_driver *gamedrv)
{
	file_error filerr;
	mame_file *f;
	char buffer[128];
	int retval = 1;

	if (gamedrv != NULL)
	{
		sprintf(buffer, "%s.ini", gamedrv->name);
		filename = buffer;
	}

	filerr = mame_fopen(SEARCHPATH_INI, buffer, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &f);
	if (filerr != FILERR_NONE)
		goto done;

	options_output_ini_file(mame_options(), mame_core_file(f));
	retval = 0;

done:
	if (f != NULL)
		mame_fclose(f);
	return retval;
}
Пример #6
0
static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt )
{
	worker_param *wp = (worker_param *) param;
	sdl_window_info *window = wp->window;

	ASSERT_WINDOW_THREAD();

	// if we are in debug mode, never go full screen
	if (options_get_bool(mame_options(), OPTION_DEBUG))
		return NULL;

	// If we are going fullscreen (leaving windowed) remember our windowed size
	if (!window->fullscreen)
	{
		window->windowed_width = window->width;
		window->windowed_height = window->height;
	}

	window->destroy(window);
	sdlinput_release_keys(wp->machine);

	// toggle the window mode
	window->fullscreen = !window->fullscreen;	

	complete_create_wt(param, 0);

	return NULL;
}
Пример #7
0
void osd_init(running_machine *machine)
{

	//add_exit_callback(machine, osd_exit);
	machine->add_notifier(MACHINE_NOTIFY_EXIT, osd_exit);

	our_target = render_target_alloc(machine, NULL, 0);
	if (our_target == NULL)
		fatalerror("Error creating render target");

	myosd_inGame = !(machine->gamedrv == &GAME_NAME(empty));
    
	options_set_bool(mame_options(), OPTION_CHEAT,myosd_cheat,OPTION_PRIORITY_CMDLINE);
    options_set_bool(mame_options(), OPTION_AUTOSAVE,myosd_autosave,OPTION_PRIORITY_CMDLINE);
    options_set_bool(mame_options(), OPTION_SOUND,myosd_sound_value != -1,OPTION_PRIORITY_CMDLINE);
    if(myosd_sound_value!=-1)
       options_set_int(mame_options(), OPTION_SAMPLERATE,myosd_sound_value,OPTION_PRIORITY_CMDLINE);
    
    options_set_float(mame_options(), OPTION_BEAM,myosd_vector_bean2x ? 2.5 : 1.0, OPTION_PRIORITY_CMDLINE);
    options_set_float(mame_options(), OPTION_FLICKER,myosd_vector_flicker ? 0.4 : 0.0, OPTION_PRIORITY_CMDLINE);
    options_set_bool(mame_options(), OPTION_ANTIALIAS,myosd_vector_antialias,OPTION_PRIORITY_CMDLINE);
    
	droid_ios_init_input(machine);
	droid_ios_init_sound(machine);
	droid_ios_init_video(machine);
    
    netplay_t *handle = netplay_get_handle();
        
    if(handle->has_connection)
    {
        handle->has_begun_game = 1;
    }
}
Пример #8
0
int config_load_settings(running_machine *machine)
{
	const char *controller = options_get_string(mame_options(), OPTION_CTRLR);
	file_error filerr;
	config_type *type;
	mame_file *file;
	int loaded = 0;
	astring *fname;

	/* loop over all registrants and call their init function */
	for (type = typelist; type; type = type->next)
		(*type->load)(CONFIG_TYPE_INIT, NULL);

	/* now load the controller file */
	if (controller[0] != 0)
	{
		/* open the config file */
		fname = astring_assemble_2(astring_alloc(), controller, ".cfg");
		filerr = mame_fopen(SEARCHPATH_CTRLR, astring_c(fname), OPEN_FLAG_READ, &file);
		astring_free(fname);

		if (filerr != FILERR_NONE)
			fatalerror("Could not load controller file %s.cfg", controller);

		/* load the XML */
		if (!config_load_xml(machine, file, CONFIG_TYPE_CONTROLLER))
			fatalerror("Could not load controller file %s.cfg", controller);
		mame_fclose(file);
	}

	/* next load the defaults file */
	filerr = mame_fopen(SEARCHPATH_CONFIG, "default.cfg", OPEN_FLAG_READ, &file);
	if (filerr == FILERR_NONE)
	{
		config_load_xml(machine, file, CONFIG_TYPE_DEFAULT);
		mame_fclose(file);
	}

	/* finally, load the game-specific file */
	fname = astring_assemble_2(astring_alloc(), machine->basename, ".cfg");
	filerr = mame_fopen(SEARCHPATH_CONFIG, astring_c(fname), OPEN_FLAG_READ, &file);
	astring_free(fname);

	if (filerr == FILERR_NONE)
	{
		loaded = config_load_xml(machine, file, CONFIG_TYPE_GAME);
		mame_fclose(file);
	}

	/* loop over all registrants and call their final function */
	for (type = typelist; type; type = type->next)
		(*type->load)(CONFIG_TYPE_FINAL, NULL);

	/* if we didn't find a saved config, return 0 so the main core knows that it */
	/* is the first time the game is run and it should diplay the disclaimer. */
	return loaded;
}
Пример #9
0
int sdlwindow_init(running_machine *machine)
{
	// determine if we are using multithreading or not
	multithreading_enabled = options_get_bool(mame_options(), SDLOPTION_MULTITHREADING);

	// get the main thread ID before anything else
	main_threadid = SDL_ThreadID();

	// ensure we get called on the way out
	add_exit_callback(machine, sdlwindow_exit);

	// if multithreading, create a thread to run the windows
	if (multithreading_enabled)
	{
		// create a thread to run the windows from
#ifndef SDLMAME_OS2
		work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO);
#else
		work_queue = osd_work_queue_alloc(WORK_QUEUE_FLAG_IO);
#endif
		if (work_queue == NULL)
			return 1;
		osd_work_item_queue(work_queue, &sdlwindow_thread_id, NULL, WORK_ITEM_FLAG_AUTO_RELEASE);
	}
	else
	{
		// otherwise, treat the window thread as the main thread
		//window_threadid = main_threadid;
		sdlwindow_thread_id(NULL, 0);
	}

	// initialize the drawers
#if USE_OPENGL
	if (video_config.mode == VIDEO_MODE_OPENGL)
	{
		if (drawogl_init(&draw))
			video_config.mode = VIDEO_MODE_SOFT;
	}
#endif
#if	SDL_VERSION_ATLEAST(1,3,0)
	if (video_config.mode == VIDEO_MODE_SDL13)
	{
		if (draw13_init(&draw))
			video_config.mode = VIDEO_MODE_SOFT;
	}
#endif
	if (video_config.mode == VIDEO_MODE_SOFT)
	{
		if (drawsdl_init(&draw))
			return 1;
	}

	// set up the window list
	last_window_ptr = &sdl_window_list;
	return 0;
}
Пример #10
0
static chd_file *get_disc(const device_config *device)
{
	mame_file *image_file = NULL;
	chd_file *image_chd = NULL;
	mame_path *path;

	/* open a path to the ROMs and find the first CHD file */
	path = mame_openpath(mame_options(), OPTION_ROMPATH);
	if (path != NULL)
	{
		const osd_directory_entry *dir;

		/* iterate while we get new objects */
		while ((dir = mame_readpath(path)) != NULL)
		{
			int length = strlen(dir->name);

			/* look for files ending in .chd */
			if (length > 4 &&
				dir->name[length - 4] == '.' &&
				tolower(dir->name[length - 3]) == 'c' &&
				tolower(dir->name[length - 2]) == 'h' &&
				tolower(dir->name[length - 1]) == 'd')
			{
				file_error filerr;
				chd_error chderr;

				/* open the file itself via our search path */
				filerr = mame_fopen(SEARCHPATH_IMAGE, dir->name, OPEN_FLAG_READ, &image_file);
				if (filerr == FILERR_NONE)
				{
					/* try to open the CHD */
					chderr = chd_open_file(mame_core_file(image_file), CHD_OPEN_READ, NULL, &image_chd);
					if (chderr == CHDERR_NONE)
					{
						set_disk_handle(device->machine, "laserdisc", image_file, image_chd);
						filename = astring_dupc(dir->name);
						add_exit_callback(device->machine, free_string);
						break;
					}

					/* close the file on failure */
					mame_fclose(image_file);
					image_file = NULL;
				}
			}
		}
		mame_closepath(path);
	}

	/* if we failed, pop a message and exit */
	if (image_file == NULL)
		fatalerror("No valid image file found!\n");

	return get_disk_handle(device->machine, "laserdisc");
}
Пример #11
0
struct loaded_samples *readsamples(const char *const *samplenames, const char *basename)
{
	struct loaded_samples *samples;
	int skipfirst = 0;
	int i;

	/* if the user doesn't want to use samples, bail */
	if (!options_get_bool(mame_options(), OPTION_SAMPLES))
		return NULL;
	if (samplenames == 0 || samplenames[0] == 0)
		return NULL;

	/* if a name begins with '*', we will also look under that as an alternate basename */
	if (samplenames[0][0] == '*')
		skipfirst = 1;

	/* count the samples */
	for (i = 0; samplenames[i+skipfirst] != 0; i++) ;
	if (i == 0)
		return NULL;

	/* allocate the array */
	samples = auto_malloc(sizeof(struct loaded_samples) + (i-1) * sizeof(struct loaded_sample));
	memset(samples, 0, sizeof(struct loaded_samples) + (i-1) * sizeof(struct loaded_sample));
	samples->total = i;

	/* load the samples */
	for (i = 0; i < samples->total; i++)
		if (samplenames[i+skipfirst][0])
		{
			file_error filerr;
			mame_file *f;
			astring *fname;

			fname = astring_assemble_3(astring_alloc(), basename, PATH_SEPARATOR, samplenames[i+skipfirst]);
			filerr = mame_fopen(SEARCHPATH_SAMPLE, astring_c(fname), OPEN_FLAG_READ, &f);

			if (filerr != FILERR_NONE && skipfirst)
			{
				astring_assemble_3(fname, samplenames[0] + 1, PATH_SEPARATOR, samplenames[i+skipfirst]);
				filerr = mame_fopen(SEARCHPATH_SAMPLE, astring_c(fname), OPEN_FLAG_READ, &f);
			}
			if (filerr == FILERR_NONE)
			{
				read_wav_sample(f, &samples->sample[i]);
				mame_fclose(f);
			}

			astring_free(fname);
		}

	return samples;
}
Пример #12
0
void osd_init(running_machine *machine)
{

	//add_exit_callback(machine, osd_exit);
	machine->add_notifier(MACHINE_NOTIFY_EXIT, osd_exit);

	our_target = render_target_alloc(machine, NULL, 0);
	if (our_target == NULL)
		fatalerror("Error creating render target");

	myosd_inGame = !(machine->gamedrv == &GAME_NAME(empty));


	options_set_bool(mame_options(), OPTION_CHEAT,myosd_cheat,OPTION_PRIORITY_CMDLINE);
    options_set_bool(mame_options(), OPTION_AUTOSAVE,myosd_autosave,OPTION_PRIORITY_CMDLINE);
    options_set_bool(mame_options(), OPTION_SOUND,myosd_sound_value != -1,OPTION_PRIORITY_CMDLINE);
    if(myosd_sound_value!=-1)
       options_set_int(mame_options(), OPTION_SAMPLERATE,myosd_sound_value,OPTION_PRIORITY_CMDLINE);

	droid_ios_init_input(machine);
	droid_ios_init_sound(machine);
	droid_ios_init_video(machine);
}
Пример #13
0
static void set_starting_view(running_machine *machine, int index, sdl_window_info *window, const char *view)
{
	const char *defview = options_get_string(mame_options(), SDLOPTION_VIEW( ));
	int viewindex;

	ASSERT_MAIN_THREAD();

	// choose non-auto over auto
	if (strcmp(view, "auto") == 0 && strcmp(defview, "auto") != 0)
		view = defview;

	// query the video system to help us pick a view
	viewindex = video_get_view_for_target(machine, window->target, view, index, video_config.numscreens);

	// set the view
	render_target_set_view(window->target, viewindex);
	window->start_viewscreen=viewindex;
}
Пример #14
0
static int drawgx_window_create(sdl_window_info *window, int width, int height)
{
    sdl_info *sdl = window->dxdata;
    u32 xfbHeight;
    f32 yscale;
    Mtx44 perspective;
    Mtx GXmodelView2D;
    GXColor background = {0, 0, 0, 0xff};
    currfb = 0;
    // allocate memory for our structures
    sdl = malloc(sizeof(*sdl));
    memset(sdl, 0, sizeof(*sdl));

    window->dxdata = sdl;

    sdl->scale_mode = &scale_modes[window->scale_mode];

    sdl->extra_flags = (window->fullscreen ?  SDL_FULLSCREEN : SDL_RESIZABLE);

    sdl->extra_flags |= sdl->scale_mode->extra_flags;

    /*sdl->sdlsurf = SDL_SetVideoMode(width, height,
    			   0, SDL_SWSURFACE | SDL_ANYFORMAT | sdl->extra_flags);*/
    //sdl->sdlsurf = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF);

    //if (!sdl->sdlsurf)
    //	return 1;

    window->width = gx_screenWidth();//sdl->sdlsurf->w;
    window->height = 480;//sdl->sdlsurf->h;

    sdl->safe_hofs = (window->width - window->width * options_get_float(mame_options(), SDLOPTVAL_SAFEAREA)) / 2;
    sdl->safe_vofs = (window->height - window->height * options_get_float(mame_options(), SDLOPTVAL_SAFEAREA)) / 2;

    /*if (sdl->scale_mode->is_yuv)
    	yuv_overlay_init(window);*/

    sdl->yuv_lookup = NULL;
    sdl->blittimer = 0;

    //if (is_inited) return 0;
    //is_inited = 1;
    //drawgx_yuv_init(sdl);
    //SDL_QuitSubSystem(SDL_INIT_VIDEO);
    if (is_inited) return 0;

    is_inited = 1;

    VIDEO_Init();
    VIDEO_SetBlack(true);
    vmode = VIDEO_GetPreferredMode(NULL);

    switch (vmode->viTVMode >> 2)
    {
    case VI_PAL:
        vmode = &TVPal574IntDfScale;
        vmode->xfbHeight = 480;
        vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2;
        vmode->viHeight = 480;
        break;

    case VI_NTSC:
        break;

    default:
        break;
    }

    VIDEO_Configure(vmode);

    xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));
    xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(vmode));

    VIDEO_ClearFrameBuffer(vmode, xfb[0], COLOR_BLACK);
    VIDEO_ClearFrameBuffer(vmode, xfb[1], COLOR_BLACK);

    VIDEO_SetNextFramebuffer(xfb[currfb]);

    VIDEO_Flush();
    VIDEO_WaitVSync();
    if (vmode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
    else while (VIDEO_GetNextField()) VIDEO_WaitVSync();

    gp_fifo = memalign(32, DEFAULT_FIFO_SIZE);
    memset(gp_fifo, 0, DEFAULT_FIFO_SIZE);
    GX_Init(gp_fifo, DEFAULT_FIFO_SIZE);
    atexit(drawgx_shutdown);

    GX_SetCopyClear(background, 0x00ffffff);

    // other gx setup
    GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1);
    yscale = GX_GetYScaleFactor(vmode->efbHeight,vmode->xfbHeight);
    xfbHeight = GX_SetDispCopyYScale(yscale);
    GX_SetScissor(0,0,vmode->fbWidth,vmode->efbHeight);
    GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight);
    GX_SetDispCopyDst(vmode->fbWidth,xfbHeight);
    GX_SetCopyFilter(vmode->aa,vmode->sample_pattern,GX_TRUE,vmode->vfilter);
    GX_SetFieldMode(vmode->field_rendering,((vmode->viHeight==2*vmode->xfbHeight)?GX_ENABLE:GX_DISABLE));

    if (vmode->aa)
        GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
    else
        GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);

    GX_SetCullMode(GX_CULL_NONE);
    GX_CopyDisp(xfb[currfb],GX_TRUE);
    GX_SetDispCopyGamma(GX_GM_1_0);

    GX_SetNumChans(1);
    GX_SetNumTexGens(1);
    GX_SetTevOp(GX_TEVSTAGE0, GX_MODULATE);
    GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);

    GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
    GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
    GX_SetAlphaUpdate(GX_TRUE);
    GX_SetColorUpdate(GX_TRUE);

    guOrtho(perspective,0,479,0,gx_screenWidth()-1,0,300);
    GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC);

    guMtxIdentity(GXmodelView2D);
    guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -5.0F);
    GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);

    GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1);
    GX_InvVtxCache();
    GX_ClearVtxDesc();
    GX_InvalidateTexAll();

    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XY, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
    GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);

    GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_CLR0, GX_DIRECT);
    GX_SetVtxDesc(GX_VA_TEX0, GX_DIRECT);

    GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);

    VIDEO_SetBlack(false);

    GX_InitTexObj(&blankTex, blanktex, 1, 1, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);

    return 0;
}
Пример #15
0
int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config)
{
	sdl_window_info *window;
	worker_param *wp = malloc(sizeof(worker_param));
	char option[20];
	int result;

	ASSERT_MAIN_THREAD();

	clear_worker_param(wp);

	// allocate a new window object
	window = alloc_or_die(sdl_window_info);
	memset(window, 0, sizeof(*window));
	window->maxwidth = config->width;
	window->maxheight = config->height;
	window->depth = config->depth;
	window->refresh = config->refresh;
	window->monitor = monitor;
	window->machine = machine;
	window->index = index;
	
	//FIXME: these should be per_window in config-> or even better a bit set
	window->fullscreen = !video_config.windowed;
	window->prescale = video_config.prescale;
	window->prescale_effect = video_config.prescale_effect;
	window->scale_mode = video_config.scale_mode;

	// set the initial maximized state
	// FIXME: Does not belong here
	window->startmaximized = options_get_bool(mame_options(), SDLOPTION_MAXIMIZE);

	if (!window->fullscreen)
	{
		window->windowed_width = config->width;
		window->windowed_height = config->height;
	}
  	window->totalColors = config->totalColors;

	// add us to the list
	*last_window_ptr = window;
	last_window_ptr = &window->next;

	draw.attach(&draw, window);
	
	// create an event that we can use to skip blitting
	window->rendered_event = osd_event_alloc(FALSE, TRUE);

	// load the layout
	window->target = render_target_alloc(machine, NULL, FALSE);
	if (window->target == NULL)
		goto error;

	// set the specific view				    
	sprintf(option, SDLOPTION_VIEW("%d"), index);
	set_starting_view(machine, index, window, options_get_string(mame_options(), option));

	// make the window title
	if (video_config.numscreens == 1)
		sprintf(window->title, APPNAME ": %s [%s]", machine->gamedrv->description, machine->gamedrv->name);
	else
		sprintf(window->title, APPNAME ": %s [%s] - Screen %d", machine->gamedrv->description, machine->gamedrv->name, index);

	wp->window = window;

	if (multithreading_enabled)
	{
		osd_work_item *wi;		
		
		wi = osd_work_item_queue(work_queue, &complete_create_wt, (void *) wp, 0);
		sdlwindow_sync();
		result = *((int *) (osd_work_item_result)(wi));
		osd_work_item_release(wi);
	} 
	else
		result = *((int *) complete_create_wt((void *) wp, 0));

	// handle error conditions
	if (result == 1)
		goto error;

	return 0;

error:
	sdlwindow_video_window_destroy(machine, window);
	return 1;
}
Пример #16
0
static int ddraw_create_surfaces(win_window_info *window)
{
	dd_info *dd = window->drawdata;
	HRESULT result;

	// make a description of the primary surface
	memset(&dd->primarydesc, 0, sizeof(dd->primarydesc));
	dd->primarydesc.dwSize = sizeof(dd->primarydesc);
	dd->primarydesc.dwFlags = DDSD_CAPS;
	dd->primarydesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;

	// for triple-buffered full screen mode, allocate flipping surfaces
	if (window->fullscreen && video_config.triplebuf)
	{
		dd->primarydesc.dwFlags |= DDSD_BACKBUFFERCOUNT;
		dd->primarydesc.ddsCaps.dwCaps |= DDSCAPS_FLIP | DDSCAPS_COMPLEX;
		dd->primarydesc.dwBackBufferCount = 2;
	}

	// create the primary surface and report errors
	result = create_surface(dd, &dd->primarydesc, &dd->primary, "primary");
	if (result != DD_OK) goto error;

	// full screen mode: get the back surface
	dd->back = NULL;
	if (window->fullscreen && video_config.triplebuf)
	{
		DDSCAPS2 caps = { DDSCAPS_BACKBUFFER };
		result = IDirectDrawSurface7_GetAttachedSurface(dd->primary, &caps, &dd->back);
		if (result != DD_OK)
		{
			mame_printf_verbose("DirectDraw: Error %08X getting attached back surface\n", (int)result);
			goto error;
		}
	}

	// now make a description of our blit surface, based on the primary surface
	if (dd->blitwidth == 0 || dd->blitheight == 0)
		compute_blit_surface_size(window);
	dd->blitdesc = dd->primarydesc;
	dd->blitdesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_CAPS;
	dd->blitdesc.dwWidth = dd->blitwidth;
	dd->blitdesc.dwHeight = dd->blitheight;
	dd->blitdesc.ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;

	// then create the blit surface, fall back to system memory if video mem doesn't work
	result = create_surface(dd, &dd->blitdesc, &dd->blit, "blit");
	if (result != DD_OK)
	{
		dd->blitdesc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
		result = create_surface(dd, &dd->blitdesc, &dd->blit, "blit");
	}
	if (result != DD_OK) goto error;

	// create a memory buffer for offscreen drawing
	if (dd->membuffersize < dd->blitwidth * dd->blitheight * 4)
	{
		dd->membuffersize = dd->blitwidth * dd->blitheight * 4;
		dd->membuffer = realloc(dd->membuffer, dd->membuffersize);
	}
	if (dd->membuffer == NULL)
		goto error;

#ifdef MESS
	// create a clipper for all modes, since MESS has dialogs
	if (create_clipper(window))
		goto error;
#else
	// create a clipper for windowed mode
	if (!window->fullscreen && create_clipper(window))
		goto error;
#endif

	// full screen mode: set the gamma
	if (window->fullscreen)
	{
		// only set the gamma if it's not 1.0f
		float brightness = options_get_float(mame_options(), WINOPTION_FULLSCREENBRIGHTNESS);
		float contrast = options_get_float(mame_options(), WINOPTION_FULLLSCREENCONTRAST);
		float gamma = options_get_float(mame_options(), WINOPTION_FULLSCREENGAMMA);
		if (brightness != 1.0f || contrast != 1.0f || gamma != 1.0f)
		{
			// see if we can get a GammaControl object
			result = IDirectDrawSurface_QueryInterface(dd->primary, &IID_IDirectDrawGammaControl, (void **)&dd->gamma);
			if (result != DD_OK)
			{
				mame_printf_warning("DirectDraw: Warning - device does not support full screen gamma correction.\n");
				dd->gamma = NULL;
			}

			// proceed if we can
			if (dd->gamma != NULL)
			{
				DDGAMMARAMP ramp;
				int i;

				// create a standard ramp and set it
				for (i = 0; i < 256; i++)
					ramp.red[i] = ramp.green[i] = ramp.blue[i] = apply_brightness_contrast_gamma(i, brightness, contrast, gamma) << 8;

				// attempt to set it
				result = IDirectDrawGammaControl_SetGammaRamp(dd->gamma, 0, &ramp);
				if (result != DD_OK)
					mame_printf_verbose("DirectDraw: Error %08X attempting to set gamma correction.\n", (int)result);
			}
		}
	}

	// force some updates
	update_outer_rects(dd);
	return 0;

error:
	ddraw_delete_surfaces(window);
	return 1;
}
Пример #17
0
//============================================================
//	sdl_init
//============================================================
static int sdl_init(running_machine *machine)
{
    int			n_channels = 2;
    int			audio_latency;
    SDL_AudioSpec 	aspec, obtained;
    char audio_driver[16];

    if (initialized_audio)
    {
        sdl_cleanup_audio(machine);
    }

    initialized_audio = 0;

    sdl_xfer_samples = SDL_XFER_SAMPLES;
    stream_in_initialized = 0;
    stream_loop = 0;

    // set up the audio specs
    aspec.freq = machine->sample_rate;
    aspec.format = AUDIO_S16SYS;	// keep endian independant
    aspec.channels = n_channels;
    aspec.samples = sdl_xfer_samples;
    aspec.callback = sdl_callback;
    aspec.userdata = 0;

    if (SDL_OpenAudio(&aspec, &obtained) < 0)
        goto cant_start_audio;

    initialized_audio = 1;
    snd_enabled = 1;

#if (SDL_VERSION_ATLEAST(1,3,0))
    strncpy(audio_driver, SDL_GetCurrentAudioDriver(), sizeof(audio_driver));
#else
    SDL_AudioDriverName(audio_driver, sizeof(audio_driver));
#endif
    mame_printf_verbose("Audio initialized - driver: %s, frequency: %d, "
                        "channels: %d, samples: %d\n", audio_driver,
                        obtained.freq, obtained.channels, obtained.samples);

    sdl_xfer_samples = obtained.samples;

    audio_latency = options_get_int(mame_options(), SDLOPTION_AUDIO_LATENCY);

    // pin audio latency
    if (audio_latency > MAX_AUDIO_LATENCY)
    {
        audio_latency = MAX_AUDIO_LATENCY;
    }
    else if (audio_latency < 1)
    {
        audio_latency = 1;
    }

    // compute the buffer sizes
    stream_buffer_size = machine->sample_rate * 2 * sizeof(INT16) * audio_latency / MAX_AUDIO_LATENCY;
    stream_buffer_size = (stream_buffer_size / 1024) * 1024;
    if (stream_buffer_size < 1024)
        stream_buffer_size = 1024;

    // create the buffers
    if (sdl_create_buffers())
        goto cant_create_buffers;

    return 0;

    // error handling
cant_create_buffers:
cant_start_audio:
    return 0;
}