コード例 #1
0
ファイル: video-resources.c プロジェクト: markjreed/vice-emu
int video_resources_chip_init(const char *chipname,
                              struct video_canvas_s **canvas,
                              video_chip_cap_t *video_chip_cap)
{
    unsigned int i;
    
    DBG(("video_resources_chip_init (%s) (canvas:%p) (cap:%p)", chipname, *canvas, video_chip_cap));

    video_render_initconfig((*canvas)->videoconfig);
    (*canvas)->videoconfig->cap = video_chip_cap;

    (*canvas)->videoconfig->chip_name = lib_stralloc(chipname);

    /* Set single size render as default.  */
    (*canvas)->videoconfig->rendermode = video_chip_cap->single_mode.rmode;
    (*canvas)->videoconfig->scalex
        = video_chip_cap->single_mode.sizex > 1 ? 2 : 1;
    (*canvas)->videoconfig->scaley
        = video_chip_cap->single_mode.sizey > 1 ? 2 : 1;

    /* CHIPDoubleScan */
    if (video_chip_cap->dscan_allowed != 0) {
        if (machine_class != VICE_MACHINE_VSID) {
            resources_chip_scan[0].name
                = util_concat(chipname, vname_chip_scan[0], NULL);
            resources_chip_scan[0].value_ptr
                = &((*canvas)->videoconfig->doublescan);
            resources_chip_scan[0].param = (void *)*canvas;
            if (resources_register_int(resources_chip_scan) < 0) {
                return -1;
            }

            lib_free((char *)(resources_chip_scan[0].name));
        } else {
            set_double_scan_enabled(0, (void *)*canvas);
        }
    }

    if (video_chip_cap->hwscale_allowed != 0) {
        if (machine_class != VICE_MACHINE_VSID) {
            resources_chip_hwscale[0].name
                = util_concat(chipname, vname_chip_hwscale[0], NULL);
            resources_chip_hwscale[0].value_ptr
                = &((*canvas)->videoconfig->hwscale);
            resources_chip_hwscale[0].param = (void *)*canvas;
            if (resources_register_int(resources_chip_hwscale) < 0) {
                return -1;
            }

            lib_free((char *)(resources_chip_hwscale[0].name));
        } else {
            set_hwscale_enabled(0, (void *)*canvas);
        }
    }

    /* CHIPDoubleSize */
    if (video_chip_cap->dsize_allowed != 0) {
        if (machine_class != VICE_MACHINE_VSID) {
            resources_chip_size[0].name
                = util_concat(chipname, vname_chip_size[0], NULL);
            resources_chip_size[0].factory_value
                = video_chip_cap->dsize_default;
            resources_chip_size[0].value_ptr
                = &((*canvas)->videoconfig->double_size_enabled);
            resources_chip_size[0].param = (void *)*canvas;
            if (resources_register_int(resources_chip_size) < 0) {
                return -1;
            }

            lib_free((char *)(resources_chip_size[0].name));
        } else {
            set_double_size_enabled(0, (void *)*canvas);
        }
    }

    if (video_chip_cap->fullscreen.device_num > 0) {
        video_resource_chip_mode_t *resource_chip_mode;

        if (machine_class != VICE_MACHINE_VSID) {
            resources_chip_fullscreen_int[0].name
                = util_concat(chipname, vname_chip_fullscreen[0], NULL);
            resources_chip_fullscreen_int[0].value_ptr
                = &((*canvas)->videoconfig->fullscreen_enabled);
            resources_chip_fullscreen_int[0].param = (void *)*canvas;

            resources_chip_fullscreen_int[1].name
                = util_concat(chipname, vname_chip_fullscreen[1], NULL);
            resources_chip_fullscreen_int[1].value_ptr
                = &((*canvas)->videoconfig->fullscreen_statusbar_enabled);
            resources_chip_fullscreen_int[1].param = (void *)*canvas;

            resources_chip_fullscreen_string[0].name
                = util_concat(chipname, vname_chip_fullscreen[2], NULL);
            resources_chip_fullscreen_string[0].factory_value
                = video_chip_cap->fullscreen.device_name[0];
            resources_chip_fullscreen_string[0].value_ptr
                = &((*canvas)->videoconfig->fullscreen_device);
            resources_chip_fullscreen_string[0].param = (void *)*canvas;

            if (resources_register_string(resources_chip_fullscreen_string) < 0) {
                return -1;
            }

            if (resources_register_int(resources_chip_fullscreen_int) < 0) {
                return -1;
            }

            lib_free((char *)(resources_chip_fullscreen_int[0].name));
            lib_free((char *)(resources_chip_fullscreen_int[1].name));
            lib_free((char *)(resources_chip_fullscreen_string[0].name));
        } else {
            set_fullscreen_enabled(0, (void *)*canvas);
            set_fullscreen_statusbar(0, (void *)*canvas);
            set_fullscreen_device(video_chip_cap->fullscreen.device_name[0], (void *)*canvas);
        }

        for (i = 0; i < video_chip_cap->fullscreen.device_num; i++) {
            resource_chip_mode = get_resource_chip_mode();
            resource_chip_mode->resource_chip = *canvas;
            resource_chip_mode->device = i;

            if (machine_class != VICE_MACHINE_VSID) {
                resources_chip_fullscreen_mode[0].name
                    = util_concat(chipname,
                                  video_chip_cap->fullscreen.device_name[i],
                                  vname_chip_fullscreen_mode[0], NULL);
                resources_chip_fullscreen_mode[0].value_ptr
                    = &((*canvas)->videoconfig->fullscreen_mode[i]);
                resources_chip_fullscreen_mode[0].param
                    = (void *)resource_chip_mode;

                if (resources_register_int(resources_chip_fullscreen_mode) < 0) {
                    return -1;
                }

                lib_free((char *)(resources_chip_fullscreen_mode[0].name));
            } else {
                set_fullscreen_mode(0, (void *)resource_chip_mode);
            }
        }
    }

    /* Palette related */
    if (machine_class != VICE_MACHINE_VSID) {
        resources_chip_palette_string[0].name
            = util_concat(chipname, vname_chip_palette[0], NULL);
        resources_chip_palette_string[0].factory_value
            = video_chip_cap->external_palette_name;
        resources_chip_palette_string[0].value_ptr
            = &((*canvas)->videoconfig->external_palette_name);
        resources_chip_palette_string[0].param = (void *)*canvas;

        resources_chip_palette_int[0].name
            = util_concat(chipname, vname_chip_palette[1], NULL);
        resources_chip_palette_int[0].value_ptr
            = &((*canvas)->videoconfig->external_palette);
        resources_chip_palette_int[0].param = (void *)*canvas;

        if (resources_register_string(resources_chip_palette_string) < 0) {
            return -1;
        }

        if (resources_register_int(resources_chip_palette_int) < 0) {
            return -1;
        }

        lib_free((char *)(resources_chip_palette_string[0].name));
        lib_free((char *)(resources_chip_palette_int[0].name));
    } else {
        set_palette_file_name(video_chip_cap->external_palette_name, (void *)*canvas);
        set_ext_palette(0, (void *)*canvas);
    }

    /* double buffering */
    if (video_chip_cap->double_buffering_allowed != 0) {
        if (machine_class != VICE_MACHINE_VSID) {
            resources_chip_double_buffer[0].name
                = util_concat(chipname, vname_chip_double_buffer[0], NULL);
            resources_chip_double_buffer[0].value_ptr
                = &((*canvas)->videoconfig->double_buffer);
            resources_chip_double_buffer[0].param = (void *)*canvas;
            if (resources_register_int(resources_chip_double_buffer) < 0) {
                return -1;
            }

            lib_free((char *)(resources_chip_double_buffer[0].name));
        } else {
            set_double_buffer_enabled(0, (void *)*canvas);
        }
    }

    /* palette generator */
    if (machine_class != VICE_MACHINE_VSID) {
        i = 0;
        while (vname_chip_colors[i]) {
            resources_chip_colors[i].name = util_concat(chipname, vname_chip_colors[i], NULL);
            resources_chip_colors[i].param = (void *)*canvas;
            ++i;
        }
        resources_chip_colors[0].value_ptr = &((*canvas)->videoconfig->video_resources.color_saturation);
        resources_chip_colors[1].value_ptr = &((*canvas)->videoconfig->video_resources.color_contrast);
        resources_chip_colors[2].value_ptr = &((*canvas)->videoconfig->video_resources.color_brightness);
        resources_chip_colors[3].value_ptr = &((*canvas)->videoconfig->video_resources.color_gamma);
        resources_chip_colors[4].value_ptr = &((*canvas)->videoconfig->video_resources.color_tint);

        if (resources_register_int(resources_chip_colors) < 0) {
            return -1;
        }

        i = 0;
        while (vname_chip_colors[i]) {
            lib_free((char *)(resources_chip_colors[i].name));
            ++i;
        }
    } else {
        set_color_saturation(1250, (void *)*canvas);
        set_color_contrast(1250, (void *)*canvas);
        set_color_brightness(1000, (void *)*canvas);
        set_color_gamma(2200, (void *)*canvas);
        set_color_tint(1000, (void *)*canvas);
    }

    /* crt emulation */
    if (machine_class != VICE_MACHINE_VSID) {
        i = 0;
        while (vname_chip_crtemu[i]) {
            resources_chip_crtemu[i].name = util_concat(chipname, vname_chip_crtemu[i], NULL);
            resources_chip_crtemu[i].param = (void *)*canvas;
            ++i;
        }
        resources_chip_crtemu[0].value_ptr = &((*canvas)->videoconfig->video_resources.pal_scanlineshade);
        resources_chip_crtemu[1].value_ptr = &((*canvas)->videoconfig->video_resources.pal_blur);
        resources_chip_crtemu[2].value_ptr = &((*canvas)->videoconfig->video_resources.pal_oddlines_phase);
        resources_chip_crtemu[3].value_ptr = &((*canvas)->videoconfig->video_resources.pal_oddlines_offset);
        resources_chip_crtemu[4].value_ptr = &((*canvas)->videoconfig->video_resources.audioleak);

        if (resources_register_int(resources_chip_crtemu) < 0) {
            return -1;
        }

        i = 0;
        while (vname_chip_crtemu[i]) {
            lib_free((char *)(resources_chip_crtemu[i].name));
            ++i;
        }
    } else {
        set_pal_scanlineshade(750, (void *)*canvas);
        set_pal_blur(500, (void *)*canvas);
        set_pal_oddlinesphase(1125, (void *)*canvas);
        set_pal_oddlinesoffset(875, (void *)*canvas);
        set_audioleak(0, (void *)*canvas);
    }

    /* CHIPFilter */
    if (machine_class != VICE_MACHINE_VSID) {
        resources_chip_rendermode[0].name
            = util_concat(chipname, vname_chip_rendermode[0], NULL);
        resources_chip_rendermode[0].value_ptr
            = &((*canvas)->videoconfig->filter);
        resources_chip_rendermode[0].param = (void *)*canvas;
        if (resources_register_int(resources_chip_rendermode) < 0) {
            return -1;
        }

        lib_free((char *)(resources_chip_rendermode[0].name));
    } else {
        set_chip_rendermode(VIDEO_FILTER_NONE, (void *)*canvas);
    }

    return 0;
}
コード例 #2
0
i4_bool r1_dx9_class::init(i4_display_class * display)
{
	HRESULT hResult = DD_OK;

	// JJ FOR TEST
	if (display!=i4_dx9_display)
	{
		// || !i4_dx9_display->using_accelerated_driver())
		return i4_F;
	}
	d3d_device=dx9_common.device;
	set_color_tint(0);
	init_d3d_vert_buffer();
	D3DDeviceInfo * info;
	info=dx9_common.get_driver_hardware_info(dx9_common.pD3D9,i4_dx9_display->cur_mode.adaptor_id);
	if (!info)
	{
		return i4_F;
	}



	if (info->Caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY)
	{
		needs_square_textures = i4_T;
	}
	else
	{
		needs_square_textures = i4_F;
	}


	//turn zbuffering on
	i4_dx9_check(d3d_device->SetRenderState(D3DRS_ZENABLE,TRUE));

	//turn gouraud shading on the entire time
	i4_dx9_check(d3d_device->SetRenderState(D3DRS_SHADEMODE,D3DSHADE_GOURAUD));

	//dithering.. eh..
	i4_dx9_check(d3d_device->SetRenderState(D3DRS_DITHERENABLE,TRUE));

	//no monochomatic shading?
	//d3d_device->SetRenderState(D3DRS_MONOENABLE,FALSE);

	//texturemapping mode setup
	//d3d_device->SetRenderState(D3DRS_TEXTUREMAPBLEND,D3DTBLEND_MODULATE);
	//d3d_device->SetRenderState(D3DRS_TEXTUREHANDLE,0);

	i4_dx9_check(d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSU,D3DTADDRESS_CLAMP));
	i4_dx9_check(d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSV,D3DTADDRESS_CLAMP));
	i4_dx9_check(d3d_device->SetSamplerState(0, D3DSAMP_ADDRESSW,D3DTADDRESS_CLAMP));

	//d3d_device->SetRenderState(D3DRS_TEXTUREPERSPECTIVE,1);

	//no automatic face culling
	i4_dx9_check(d3d_device->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE));

	i4_dx9_check(d3d_device->SetFVF(FVF_CUSTOMVERTEX));
	//setup other basic modes
	set_write_mode(R1_WRITE_W | R1_COMPARE_W | R1_WRITE_COLOR);

	//Duh, I would need this, but it's not supported on my hw...
	//What else can we do?
	//Hm... the hw supports it, but the driver says it doesn't, so
	//we have a lot of false errors.
	i4_dx9_check(d3d_device->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE));
	//d3d_device->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_DISABLE);
	//i4_dx9_check(d3d_device->SetTextureStageState(0,D3DTSS_TEXCOORDINDEX,0);
	i4_dx9_check(d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ));
	i4_dx9_check(d3d_device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ));
	i4_dx9_check(d3d_device->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_DISABLE ));
	i4_dx9_check(d3d_device->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX,
												  D3DTSS_TCI_CAMERASPACEPOSITION ));
	i4_dx9_check(d3d_device->SetRenderState(D3DRS_LIGHTING,FALSE));
	i4_dx9_check(d3d_device->SetRenderState(D3DRS_SPECULARENABLE,FALSE));
	//d3d_device->SetRenderState(D3DRS_WRAP0,
	//	  D3DWRAPCOORD_0 | D3DWRAPCOORD_1);


	set_shading_mode(R1_COLORED_SHADING);

	set_alpha_mode(R1_ALPHA_DISABLED);

	set_filter_mode(R1_BILINEAR_FILTERING);

	set_z_range(0.01f,1.0f);

	m_dwFogColor           = 0x00b5b5ff;
	m_dwFogMode            = D3DFOG_LINEAR;
	m_fFogStartValue       = 0.2f;
	m_fFogEndValue         = 1.0f;
	m_fFogDensity          = 0.5f;
	m_bRangeBasedFog       = FALSE;


	//clear the viewport, initialize type thing
	//clear_area(0,0,639,479,0x00000000,1.0);
	int w=i4_dx9_display->cur_mode.xres;
	int h=i4_dx9_display->cur_mode.yres;
	clear_area(0,0,w-1,h-1,0x0,RENDER_DEFAULT_FAR_DISTANCE);

	//if we're page flipping, flip so we can clear the other page initially as well
	i4_dx9_display->flush();

	//clear_area(0,0,639,479,0x00000000,1.0);
	clear_area(0,0,w-1,h-1,0x0,RENDER_DEFAULT_FAR_DISTANCE);

	tmanager = new r1_dx9_texture_class(display->get_palette());
	tmanagers.reallocate(10,10);
	r1_name_cache_file("dx9");
	default_state();
	return i4_T;
}