trunk/src/osd/windows/d3dhlsl.c
| r20245 | r20246 | |
| 203 | 203 | lastidx = -1; |
| 204 | 204 | targethead = NULL; |
| 205 | 205 | cachehead = NULL; |
| 206 | initialized = false; |
| 206 | 207 | } |
| 207 | 208 | |
| 208 | 209 | |
| r20245 | r20246 | |
| 498 | 499 | |
| 499 | 500 | |
| 500 | 501 | //============================================================ |
| 502 | // hlsl_info::set_texture |
| 503 | //============================================================ |
| 504 | |
| 505 | void hlsl_info::toggle() |
| 506 | { |
| 507 | if (master_enable) |
| 508 | { |
| 509 | if (initialized) |
| 510 | { |
| 511 | delete_resources(false); |
| 512 | } |
| 513 | } |
| 514 | else |
| 515 | { |
| 516 | if (!initialized) |
| 517 | { |
| 518 | create_resources(false); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | master_enable = !master_enable; |
| 523 | } |
| 524 | |
| 525 | //============================================================ |
| 501 | 526 | // hlsl_info::begin_avi_recording |
| 502 | 527 | //============================================================ |
| 503 | 528 | |
| r20245 | r20246 | |
| 655 | 680 | } |
| 656 | 681 | } |
| 657 | 682 | |
| 683 | |
| 658 | 684 | //============================================================ |
| 659 | 685 | // hlsl_info::set_texture |
| 660 | 686 | //============================================================ |
| r20245 | r20246 | |
| 698 | 724 | if (!d3dintf->post_fx_available) |
| 699 | 725 | return; |
| 700 | 726 | |
| 727 | g_slider_list = init_slider_list(); |
| 728 | |
| 701 | 729 | this->d3dintf = d3dintf; |
| 702 | 730 | this->window = window; |
| 703 | 731 | |
| r20245 | r20246 | |
| 712 | 740 | |
| 713 | 741 | snap_width = downcast<windows_options &>(window->machine().options()).d3d_snap_width(); |
| 714 | 742 | snap_height = downcast<windows_options &>(window->machine().options()).d3d_snap_height(); |
| 715 | | } |
| 716 | 743 | |
| 744 | prescale_force_x = 0; |
| 745 | prescale_force_y = 0; |
| 717 | 746 | |
| 718 | | //============================================================ |
| 719 | | // hlsl_info::init_fsfx_quad |
| 720 | | //============================================================ |
| 747 | windows_options &winoptions = downcast<windows_options &>(window->machine().options()); |
| 721 | 748 | |
| 722 | | void hlsl_info::init_fsfx_quad(void *vertbuf) |
| 723 | | { |
| 724 | | if (!master_enable || !d3dintf->post_fx_available) |
| 725 | | return; |
| 749 | options = (hlsl_options*)global_alloc_clear(hlsl_options); |
| 726 | 750 | |
| 727 | | d3d_info *d3d = (d3d_info *)window->drawdata; |
| 751 | options->params_dirty = true; |
| 752 | strcpy(options->shadow_mask_texture, downcast<windows_options &>(window->machine().options()).screen_shadow_mask_texture()); // unsafe |
| 728 | 753 | |
| 729 | | // get a pointer to the vertex buffer |
| 730 | | fsfx_vertices = (d3d_vertex *)vertbuf; |
| 731 | | if (fsfx_vertices == NULL) |
| 732 | | return; |
| 754 | write_ini = downcast<windows_options &>(window->machine().options()).hlsl_write_ini(); |
| 755 | read_ini = downcast<windows_options &>(window->machine().options()).hlsl_read_ini(); |
| 733 | 756 | |
| 734 | | // fill in the vertexes clockwise |
| 735 | | fsfx_vertices[0].x = 0.0f; |
| 736 | | fsfx_vertices[0].y = 0.0f; |
| 737 | | fsfx_vertices[1].x = d3d->width; |
| 738 | | fsfx_vertices[1].y = 0.0f; |
| 739 | | fsfx_vertices[2].x = 0.0f; |
| 740 | | fsfx_vertices[2].y = d3d->height; |
| 741 | | fsfx_vertices[3].x = d3d->width; |
| 742 | | fsfx_vertices[3].y = 0.0f; |
| 743 | | fsfx_vertices[4].x = 0.0f; |
| 744 | | fsfx_vertices[4].y = d3d->height; |
| 745 | | fsfx_vertices[5].x = d3d->width; |
| 746 | | fsfx_vertices[5].y = d3d->height; |
| 747 | | |
| 748 | | fsfx_vertices[0].u0 = 0.0f; |
| 749 | | fsfx_vertices[0].v0 = 0.0f; |
| 750 | | |
| 751 | | fsfx_vertices[1].u0 = 1.0f; |
| 752 | | fsfx_vertices[1].v0 = 0.0f; |
| 753 | | |
| 754 | | fsfx_vertices[2].u0 = 0.0f; |
| 755 | | fsfx_vertices[2].v0 = 1.0f; |
| 756 | | |
| 757 | | fsfx_vertices[3].u0 = 1.0f; |
| 758 | | fsfx_vertices[3].v0 = 0.0f; |
| 759 | | |
| 760 | | fsfx_vertices[4].u0 = 0.0f; |
| 761 | | fsfx_vertices[4].v0 = 1.0f; |
| 762 | | |
| 763 | | fsfx_vertices[5].u0 = 1.0f; |
| 764 | | fsfx_vertices[5].v0 = 1.0f; |
| 765 | | |
| 766 | | // set the color, Z parameters to standard values |
| 767 | | for (int i = 0; i < 6; i++) |
| 757 | if(read_ini) |
| 768 | 758 | { |
| 769 | | fsfx_vertices[i].z = 0.0f; |
| 770 | | fsfx_vertices[i].rhw = 1.0f; |
| 771 | | fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255); |
| 772 | | } |
| 773 | | } |
| 759 | emu_file ini_file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_READ | OPEN_FLAG_CREATE_PATHS); |
| 760 | file_error filerr = open_next((d3d_info*)window->drawdata, ini_file, downcast<windows_options &>(window->machine().options()).hlsl_ini_name(), "ini", 0); |
| 774 | 761 | |
| 775 | | |
| 776 | | //============================================================ |
| 777 | | // hlsl_info::create_resources |
| 778 | | //============================================================ |
| 779 | | |
| 780 | | int hlsl_info::create_resources(bool reset) |
| 781 | | { |
| 782 | | if (!master_enable || !d3dintf->post_fx_available) |
| 783 | | return 0; |
| 784 | | |
| 785 | | d3d_info *d3d = (d3d_info *)window->drawdata; |
| 786 | | |
| 787 | | HRESULT result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture); |
| 788 | | if (result != D3D_OK) |
| 789 | | { |
| 790 | | mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result); |
| 791 | | return 1; |
| 792 | | } |
| 793 | | (*d3dintf->texture.get_surface_level)(avi_copy_texture, 0, &avi_copy_surface); |
| 794 | | |
| 795 | | result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &avi_final_texture); |
| 796 | | if (result != D3D_OK) |
| 797 | | { |
| 798 | | mame_printf_verbose("Direct3D: Unable to init video-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result); |
| 799 | | return 1; |
| 800 | | } |
| 801 | | (*d3dintf->texture.get_surface_level)(avi_final_texture, 0, &avi_final_target); |
| 802 | | |
| 803 | | windows_options &winoptions = downcast<windows_options &>(window->machine().options()); |
| 804 | | |
| 805 | | if (!reset) |
| 806 | | { |
| 807 | | options = (hlsl_options*)global_alloc_clear(hlsl_options); |
| 808 | | |
| 809 | | options->params_dirty = true; |
| 810 | | strcpy(options->shadow_mask_texture, downcast<windows_options &>(window->machine().options()).screen_shadow_mask_texture()); // unsafe |
| 811 | | |
| 812 | | write_ini = downcast<windows_options &>(window->machine().options()).hlsl_write_ini(); |
| 813 | | read_ini = downcast<windows_options &>(window->machine().options()).hlsl_read_ini(); |
| 814 | | |
| 815 | | if(read_ini) |
| 762 | read_ini = false; |
| 763 | if (filerr == FILERR_NONE) |
| 816 | 764 | { |
| 817 | | emu_file ini_file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_READ | OPEN_FLAG_CREATE_PATHS); |
| 818 | | file_error filerr = open_next((d3d_info*)window->drawdata, ini_file, downcast<windows_options &>(window->machine().options()).hlsl_ini_name(), "ini", 0); |
| 819 | | |
| 820 | | read_ini = false; |
| 821 | | if (filerr == FILERR_NONE) |
| 765 | ini_file.seek(0, SEEK_END); |
| 766 | if (ini_file.tell() >= 1000) |
| 822 | 767 | { |
| 823 | | ini_file.seek(0, SEEK_END); |
| 824 | | if (ini_file.tell() >= 1000) |
| 825 | | { |
| 826 | | read_ini = true; |
| 827 | | ini_file.seek(0, SEEK_SET); |
| 768 | read_ini = true; |
| 769 | ini_file.seek(0, SEEK_SET); |
| 828 | 770 | |
| 829 | | int en = 0; |
| 830 | | char buf[1024]; |
| 831 | | ini_file.gets(buf, 1024); |
| 832 | | sscanf(buf, "hlsl_enable %d\n", &en); |
| 833 | | master_enable = en == 1; |
| 771 | int en = 0; |
| 772 | char buf[1024]; |
| 773 | ini_file.gets(buf, 1024); |
| 774 | sscanf(buf, "hlsl_enable %d\n", &en); |
| 775 | master_enable = en == 1; |
| 834 | 776 | |
| 835 | | ini_file.gets(buf, 1024); |
| 836 | | sscanf(buf, "hlsl_prescale_x %d\n", &prescale_force_x); |
| 777 | ini_file.gets(buf, 1024); |
| 778 | sscanf(buf, "hlsl_prescale_x %d\n", &prescale_force_x); |
| 837 | 779 | |
| 838 | | ini_file.gets(buf, 1024); |
| 839 | | sscanf(buf, "hlsl_prescale_y %d\n", &prescale_force_y); |
| 780 | ini_file.gets(buf, 1024); |
| 781 | sscanf(buf, "hlsl_prescale_y %d\n", &prescale_force_y); |
| 840 | 782 | |
| 841 | | ini_file.gets(buf, 1024); |
| 842 | | sscanf(buf, "hlsl_preset %d\n", &preset); |
| 783 | ini_file.gets(buf, 1024); |
| 784 | sscanf(buf, "hlsl_preset %d\n", &preset); |
| 843 | 785 | |
| 844 | | ini_file.gets(buf, 1024); |
| 845 | | sscanf(buf, "hlsl_snap_width %d\n", &snap_width); |
| 786 | ini_file.gets(buf, 1024); |
| 787 | sscanf(buf, "hlsl_snap_width %d\n", &snap_width); |
| 846 | 788 | |
| 847 | | ini_file.gets(buf, 1024); |
| 848 | | sscanf(buf, "hlsl_snap_height %d\n", &snap_height); |
| 789 | ini_file.gets(buf, 1024); |
| 790 | sscanf(buf, "hlsl_snap_height %d\n", &snap_height); |
| 849 | 791 | |
| 850 | | ini_file.gets(buf, 1024); |
| 851 | | sscanf(buf, "shadow_mask_alpha %f\n", &options->shadow_mask_alpha); |
| 792 | ini_file.gets(buf, 1024); |
| 793 | sscanf(buf, "shadow_mask_alpha %f\n", &options->shadow_mask_alpha); |
| 852 | 794 | |
| 853 | | ini_file.gets(buf, 1024); |
| 854 | | sscanf(buf, "shadow_mask_texture %s\n", options->shadow_mask_texture); |
| 795 | ini_file.gets(buf, 1024); |
| 796 | sscanf(buf, "shadow_mask_texture %s\n", options->shadow_mask_texture); |
| 855 | 797 | |
| 856 | | ini_file.gets(buf, 1024); |
| 857 | | sscanf(buf, "shadow_mask_x_count %d\n", &options->shadow_mask_count_x); |
| 798 | ini_file.gets(buf, 1024); |
| 799 | sscanf(buf, "shadow_mask_x_count %d\n", &options->shadow_mask_count_x); |
| 858 | 800 | |
| 859 | | ini_file.gets(buf, 1024); |
| 860 | | sscanf(buf, "shadow_mask_y_count %d\n", &options->shadow_mask_count_y); |
| 801 | ini_file.gets(buf, 1024); |
| 802 | sscanf(buf, "shadow_mask_y_count %d\n", &options->shadow_mask_count_y); |
| 861 | 803 | |
| 862 | | ini_file.gets(buf, 1024); |
| 863 | | sscanf(buf, "shadow_mask_usize %f\n", &options->shadow_mask_u_size); |
| 804 | ini_file.gets(buf, 1024); |
| 805 | sscanf(buf, "shadow_mask_usize %f\n", &options->shadow_mask_u_size); |
| 864 | 806 | |
| 865 | | ini_file.gets(buf, 1024); |
| 866 | | sscanf(buf, "shadow_mask_vsize %f\n", &options->shadow_mask_v_size); |
| 807 | ini_file.gets(buf, 1024); |
| 808 | sscanf(buf, "shadow_mask_vsize %f\n", &options->shadow_mask_v_size); |
| 867 | 809 | |
| 868 | | ini_file.gets(buf, 1024); |
| 869 | | sscanf(buf, "curvature %f\n", &options->curvature); |
| 810 | ini_file.gets(buf, 1024); |
| 811 | sscanf(buf, "curvature %f\n", &options->curvature); |
| 870 | 812 | |
| 871 | | ini_file.gets(buf, 1024); |
| 872 | | sscanf(buf, "pincushion %f\n", &options->pincushion); |
| 813 | ini_file.gets(buf, 1024); |
| 814 | sscanf(buf, "pincushion %f\n", &options->pincushion); |
| 873 | 815 | |
| 874 | | ini_file.gets(buf, 1024); |
| 875 | | sscanf(buf, "scanline_alpha %f\n", &options->scanline_alpha); |
| 816 | ini_file.gets(buf, 1024); |
| 817 | sscanf(buf, "scanline_alpha %f\n", &options->scanline_alpha); |
| 876 | 818 | |
| 877 | | ini_file.gets(buf, 1024); |
| 878 | | sscanf(buf, "scanline_size %f\n", &options->scanline_scale); |
| 819 | ini_file.gets(buf, 1024); |
| 820 | sscanf(buf, "scanline_size %f\n", &options->scanline_scale); |
| 879 | 821 | |
| 880 | | ini_file.gets(buf, 1024); |
| 881 | | sscanf(buf, "scanline_height %f\n", &options->scanline_height); |
| 822 | ini_file.gets(buf, 1024); |
| 823 | sscanf(buf, "scanline_height %f\n", &options->scanline_height); |
| 882 | 824 | |
| 883 | | ini_file.gets(buf, 1024); |
| 884 | | sscanf(buf, "scanline_bright_scale %f\n", &options->scanline_bright_scale); |
| 825 | ini_file.gets(buf, 1024); |
| 826 | sscanf(buf, "scanline_bright_scale %f\n", &options->scanline_bright_scale); |
| 885 | 827 | |
| 886 | | ini_file.gets(buf, 1024); |
| 887 | | sscanf(buf, "scanline_bright_offset %f\n", &options->scanline_bright_offset); |
| 828 | ini_file.gets(buf, 1024); |
| 829 | sscanf(buf, "scanline_bright_offset %f\n", &options->scanline_bright_offset); |
| 888 | 830 | |
| 889 | | ini_file.gets(buf, 1024); |
| 890 | | sscanf(buf, "scanline_jitter %f\n", &options->scanline_offset); |
| 831 | ini_file.gets(buf, 1024); |
| 832 | sscanf(buf, "scanline_jitter %f\n", &options->scanline_offset); |
| 891 | 833 | |
| 892 | | ini_file.gets(buf, 1024); |
| 893 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 894 | | sscanf(buf, "defocus %f %f\n", &options->defocus[0], &options->defocus[1]); |
| 834 | ini_file.gets(buf, 1024); |
| 835 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 836 | sscanf(buf, "defocus %f %f\n", &options->defocus[0], &options->defocus[1]); |
| 895 | 837 | |
| 896 | | ini_file.gets(buf, 1024); |
| 897 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 898 | | sscanf(buf, "converge_x %f %f %f\n", &options->converge_x[0], &options->converge_x[1], &options->converge_x[2]); |
| 838 | ini_file.gets(buf, 1024); |
| 839 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 840 | sscanf(buf, "converge_x %f %f %f\n", &options->converge_x[0], &options->converge_x[1], &options->converge_x[2]); |
| 899 | 841 | |
| 900 | | ini_file.gets(buf, 1024); |
| 901 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 902 | | sscanf(buf, "converge_y %f %f %f\n", &options->converge_y[0], &options->converge_y[1], &options->converge_y[2]); |
| 842 | ini_file.gets(buf, 1024); |
| 843 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 844 | sscanf(buf, "converge_y %f %f %f\n", &options->converge_y[0], &options->converge_y[1], &options->converge_y[2]); |
| 903 | 845 | |
| 904 | | ini_file.gets(buf, 1024); |
| 905 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 906 | | sscanf(buf, "radial_converge_x %f %f %f\n", &options->radial_converge_x[0], &options->radial_converge_x[1], &options->radial_converge_x[2]); |
| 846 | ini_file.gets(buf, 1024); |
| 847 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 848 | sscanf(buf, "radial_converge_x %f %f %f\n", &options->radial_converge_x[0], &options->radial_converge_x[1], &options->radial_converge_x[2]); |
| 907 | 849 | |
| 908 | | ini_file.gets(buf, 1024); |
| 909 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 910 | | sscanf(buf, "radial_converge_y %f %f %f\n", &options->radial_converge_y[0], &options->radial_converge_y[1], &options->radial_converge_y[2]); |
| 850 | ini_file.gets(buf, 1024); |
| 851 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 852 | sscanf(buf, "radial_converge_y %f %f %f\n", &options->radial_converge_y[0], &options->radial_converge_y[1], &options->radial_converge_y[2]); |
| 911 | 853 | |
| 912 | | ini_file.gets(buf, 1024); |
| 913 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 914 | | sscanf(buf, "red_ratio %f %f %f\n", &options->red_ratio[0], &options->red_ratio[1], &options->red_ratio[2]); |
| 854 | ini_file.gets(buf, 1024); |
| 855 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 856 | sscanf(buf, "red_ratio %f %f %f\n", &options->red_ratio[0], &options->red_ratio[1], &options->red_ratio[2]); |
| 915 | 857 | |
| 916 | | ini_file.gets(buf, 1024); |
| 917 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 918 | | sscanf(buf, "grn_ratio %f %f %f\n", &options->grn_ratio[0], &options->grn_ratio[1], &options->grn_ratio[2]); |
| 858 | ini_file.gets(buf, 1024); |
| 859 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 860 | sscanf(buf, "grn_ratio %f %f %f\n", &options->grn_ratio[0], &options->grn_ratio[1], &options->grn_ratio[2]); |
| 919 | 861 | |
| 920 | | ini_file.gets(buf, 1024); |
| 921 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 922 | | sscanf(buf, "blu_ratio %f %f %f\n", &options->blu_ratio[0], &options->blu_ratio[1], &options->blu_ratio[2]); |
| 862 | ini_file.gets(buf, 1024); |
| 863 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 864 | sscanf(buf, "blu_ratio %f %f %f\n", &options->blu_ratio[0], &options->blu_ratio[1], &options->blu_ratio[2]); |
| 923 | 865 | |
| 924 | | ini_file.gets(buf, 1024); |
| 925 | | sscanf(buf, "saturation %f\n", &options->saturation); |
| 866 | ini_file.gets(buf, 1024); |
| 867 | sscanf(buf, "saturation %f\n", &options->saturation); |
| 926 | 868 | |
| 927 | | ini_file.gets(buf, 1024); |
| 928 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 929 | | sscanf(buf, "offset %f %f %f\n", &options->offset[0], &options->offset[1], &options->offset[2]); |
| 869 | ini_file.gets(buf, 1024); |
| 870 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 871 | sscanf(buf, "offset %f %f %f\n", &options->offset[0], &options->offset[1], &options->offset[2]); |
| 930 | 872 | |
| 931 | | ini_file.gets(buf, 1024); |
| 932 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 933 | | sscanf(buf, "scale %f %f %f\n", &options->scale[0], &options->scale[1], &options->scale[2]); |
| 873 | ini_file.gets(buf, 1024); |
| 874 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 875 | sscanf(buf, "scale %f %f %f\n", &options->scale[0], &options->scale[1], &options->scale[2]); |
| 934 | 876 | |
| 935 | | ini_file.gets(buf, 1024); |
| 936 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 937 | | sscanf(buf, "power %f %f %f\n", &options->power[0], &options->power[1], &options->power[2]); |
| 877 | ini_file.gets(buf, 1024); |
| 878 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 879 | sscanf(buf, "power %f %f %f\n", &options->power[0], &options->power[1], &options->power[2]); |
| 938 | 880 | |
| 939 | | ini_file.gets(buf, 1024); |
| 940 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 941 | | sscanf(buf, "floor %f %f %f\n", &options->floor[0], &options->floor[1], &options->floor[2]); |
| 881 | ini_file.gets(buf, 1024); |
| 882 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 883 | sscanf(buf, "floor %f %f %f\n", &options->floor[0], &options->floor[1], &options->floor[2]); |
| 942 | 884 | |
| 943 | | ini_file.gets(buf, 1024); |
| 944 | | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 945 | | sscanf(buf, "phosphor_life %f %f %f\n", &options->phosphor[0], &options->phosphor[1], &options->phosphor[2]); |
| 885 | ini_file.gets(buf, 1024); |
| 886 | for(int idx = 0; idx < strlen(buf); idx++) if(buf[idx] == ',') buf[idx] = ' '; |
| 887 | sscanf(buf, "phosphor_life %f %f %f\n", &options->phosphor[0], &options->phosphor[1], &options->phosphor[2]); |
| 946 | 888 | |
| 947 | | ini_file.gets(buf, 1024); |
| 948 | | sscanf(buf, "yiq_enable %d\n", &en); |
| 949 | | options->yiq_enable = en == 1; |
| 889 | ini_file.gets(buf, 1024); |
| 890 | sscanf(buf, "yiq_enable %d\n", &en); |
| 891 | options->yiq_enable = en == 1; |
| 950 | 892 | |
| 951 | | ini_file.gets(buf, 1024); |
| 952 | | sscanf(buf, "yiq_cc %f\n", &options->yiq_cc); |
| 893 | ini_file.gets(buf, 1024); |
| 894 | sscanf(buf, "yiq_cc %f\n", &options->yiq_cc); |
| 953 | 895 | |
| 954 | | ini_file.gets(buf, 1024); |
| 955 | | sscanf(buf, "yiq_a %f\n", &options->yiq_a); |
| 896 | ini_file.gets(buf, 1024); |
| 897 | sscanf(buf, "yiq_a %f\n", &options->yiq_a); |
| 956 | 898 | |
| 957 | | ini_file.gets(buf, 1024); |
| 958 | | sscanf(buf, "yiq_b %f\n", &options->yiq_b); |
| 899 | ini_file.gets(buf, 1024); |
| 900 | sscanf(buf, "yiq_b %f\n", &options->yiq_b); |
| 959 | 901 | |
| 960 | | ini_file.gets(buf, 1024); |
| 961 | | sscanf(buf, "yiq_o %f\n", &options->yiq_o); |
| 902 | ini_file.gets(buf, 1024); |
| 903 | sscanf(buf, "yiq_o %f\n", &options->yiq_o); |
| 962 | 904 | |
| 963 | | ini_file.gets(buf, 1024); |
| 964 | | sscanf(buf, "yiq_p %f\n", &options->yiq_p); |
| 905 | ini_file.gets(buf, 1024); |
| 906 | sscanf(buf, "yiq_p %f\n", &options->yiq_p); |
| 965 | 907 | |
| 966 | | ini_file.gets(buf, 1024); |
| 967 | | sscanf(buf, "yiq_n %f\n", &options->yiq_n); |
| 908 | ini_file.gets(buf, 1024); |
| 909 | sscanf(buf, "yiq_n %f\n", &options->yiq_n); |
| 968 | 910 | |
| 969 | | ini_file.gets(buf, 1024); |
| 970 | | sscanf(buf, "yiq_y %f\n", &options->yiq_y); |
| 911 | ini_file.gets(buf, 1024); |
| 912 | sscanf(buf, "yiq_y %f\n", &options->yiq_y); |
| 971 | 913 | |
| 972 | | ini_file.gets(buf, 1024); |
| 973 | | sscanf(buf, "yiq_i %f\n", &options->yiq_i); |
| 914 | ini_file.gets(buf, 1024); |
| 915 | sscanf(buf, "yiq_i %f\n", &options->yiq_i); |
| 974 | 916 | |
| 975 | | ini_file.gets(buf, 1024); |
| 976 | | sscanf(buf, "yiq_q %f\n", &options->yiq_q); |
| 917 | ini_file.gets(buf, 1024); |
| 918 | sscanf(buf, "yiq_q %f\n", &options->yiq_q); |
| 977 | 919 | |
| 978 | | ini_file.gets(buf, 1024); |
| 979 | | sscanf(buf, "yiq_scan_time %f\n", &options->yiq_scan_time); |
| 920 | ini_file.gets(buf, 1024); |
| 921 | sscanf(buf, "yiq_scan_time %f\n", &options->yiq_scan_time); |
| 980 | 922 | |
| 981 | | ini_file.gets(buf, 1024); |
| 982 | | sscanf(buf, "yiq_phase_count %d\n", &options->yiq_phase_count); |
| 983 | | } |
| 923 | ini_file.gets(buf, 1024); |
| 924 | sscanf(buf, "yiq_phase_count %d\n", &options->yiq_phase_count); |
| 984 | 925 | } |
| 985 | 926 | } |
| 986 | 927 | } |
| 987 | | |
| 988 | | // experimental: load a PNG to use for vector rendering; it is treated |
| 989 | | // as a brightness map |
| 990 | | emu_file file(window->machine().options().art_path(), OPEN_FLAG_READ); |
| 991 | | |
| 992 | | // experimental: if we have a shadow bitmap, create a texture for it |
| 993 | | render_load_png(shadow_bitmap, file, NULL, options->shadow_mask_texture); |
| 994 | | if (shadow_bitmap.valid()) |
| 928 | else |
| 995 | 929 | { |
| 996 | | render_texinfo texture; |
| 997 | | |
| 998 | | // fake in the basic data so it looks like it came from render.c |
| 999 | | texture.base = shadow_bitmap.raw_pixptr(0); |
| 1000 | | texture.rowpixels = shadow_bitmap.rowpixels(); |
| 1001 | | texture.width = shadow_bitmap.width(); |
| 1002 | | texture.height = shadow_bitmap.height(); |
| 1003 | | texture.palette = NULL; |
| 1004 | | texture.seqid = 0; |
| 1005 | | |
| 1006 | | // now create it |
| 1007 | | shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)); |
| 1008 | | } |
| 1009 | | |
| 1010 | | prescale_force_x = 0; |
| 1011 | | prescale_force_y = 0; |
| 1012 | | |
| 1013 | | if(!read_ini) |
| 1014 | | { |
| 1015 | 930 | prescale_force_x = winoptions.d3d_hlsl_prescale_x(); |
| 1016 | 931 | prescale_force_y = winoptions.d3d_hlsl_prescale_y(); |
| 1017 | 932 | if(preset == -1) |
| r20245 | r20246 | |
| 1063 | 978 | options->yiq_phase_count = winoptions.screen_yiq_phase_count(); |
| 1064 | 979 | } |
| 1065 | 980 | |
| 1066 | | g_slider_list = init_slider_list(); |
| 981 | options->params_dirty = true; |
| 982 | // experimental: load a PNG to use for vector rendering; it is treated |
| 983 | // as a brightness map |
| 984 | emu_file file(window->machine().options().art_path(), OPEN_FLAG_READ); |
| 1067 | 985 | |
| 986 | render_load_png(shadow_bitmap, file, NULL, options->shadow_mask_texture); |
| 987 | } |
| 988 | |
| 989 | |
| 990 | //============================================================ |
| 991 | // hlsl_info::init_fsfx_quad |
| 992 | //============================================================ |
| 993 | |
| 994 | void hlsl_info::init_fsfx_quad(void *vertbuf) |
| 995 | { |
| 996 | if (!master_enable || !d3dintf->post_fx_available) |
| 997 | return; |
| 998 | |
| 999 | d3d_info *d3d = (d3d_info *)window->drawdata; |
| 1000 | |
| 1001 | // get a pointer to the vertex buffer |
| 1002 | fsfx_vertices = (d3d_vertex *)vertbuf; |
| 1003 | if (fsfx_vertices == NULL) |
| 1004 | return; |
| 1005 | |
| 1006 | // fill in the vertexes clockwise |
| 1007 | fsfx_vertices[0].x = 0.0f; |
| 1008 | fsfx_vertices[0].y = 0.0f; |
| 1009 | fsfx_vertices[1].x = d3d->width; |
| 1010 | fsfx_vertices[1].y = 0.0f; |
| 1011 | fsfx_vertices[2].x = 0.0f; |
| 1012 | fsfx_vertices[2].y = d3d->height; |
| 1013 | fsfx_vertices[3].x = d3d->width; |
| 1014 | fsfx_vertices[3].y = 0.0f; |
| 1015 | fsfx_vertices[4].x = 0.0f; |
| 1016 | fsfx_vertices[4].y = d3d->height; |
| 1017 | fsfx_vertices[5].x = d3d->width; |
| 1018 | fsfx_vertices[5].y = d3d->height; |
| 1019 | |
| 1020 | fsfx_vertices[0].u0 = 0.0f; |
| 1021 | fsfx_vertices[0].v0 = 0.0f; |
| 1022 | |
| 1023 | fsfx_vertices[1].u0 = 1.0f; |
| 1024 | fsfx_vertices[1].v0 = 0.0f; |
| 1025 | |
| 1026 | fsfx_vertices[2].u0 = 0.0f; |
| 1027 | fsfx_vertices[2].v0 = 1.0f; |
| 1028 | |
| 1029 | fsfx_vertices[3].u0 = 1.0f; |
| 1030 | fsfx_vertices[3].v0 = 0.0f; |
| 1031 | |
| 1032 | fsfx_vertices[4].u0 = 0.0f; |
| 1033 | fsfx_vertices[4].v0 = 1.0f; |
| 1034 | |
| 1035 | fsfx_vertices[5].u0 = 1.0f; |
| 1036 | fsfx_vertices[5].v0 = 1.0f; |
| 1037 | |
| 1038 | // set the color, Z parameters to standard values |
| 1039 | for (int i = 0; i < 6; i++) |
| 1040 | { |
| 1041 | fsfx_vertices[i].z = 0.0f; |
| 1042 | fsfx_vertices[i].rhw = 1.0f; |
| 1043 | fsfx_vertices[i].color = D3DCOLOR_ARGB(255, 255, 255, 255); |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | |
| 1048 | //============================================================ |
| 1049 | // hlsl_info::create_resources |
| 1050 | //============================================================ |
| 1051 | |
| 1052 | int hlsl_info::create_resources(bool reset) |
| 1053 | { |
| 1054 | initialized = true; |
| 1055 | |
| 1056 | d3d_info *d3d = (d3d_info *)window->drawdata; |
| 1057 | |
| 1058 | HRESULT result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &avi_copy_texture); |
| 1059 | if (result != D3D_OK) |
| 1060 | { |
| 1061 | mame_printf_verbose("Direct3D: Unable to init system-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result); |
| 1062 | return 1; |
| 1063 | } |
| 1064 | (*d3dintf->texture.get_surface_level)(avi_copy_texture, 0, &avi_copy_surface); |
| 1065 | |
| 1066 | result = (*d3dintf->device.create_texture)(d3d->device, (int)snap_width, (int)snap_height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &avi_final_texture); |
| 1067 | if (result != D3D_OK) |
| 1068 | { |
| 1069 | mame_printf_verbose("Direct3D: Unable to init video-memory target for HLSL AVI dumping (%08x)\n", (UINT32)result); |
| 1070 | return 1; |
| 1071 | } |
| 1072 | (*d3dintf->texture.get_surface_level)(avi_final_texture, 0, &avi_final_target); |
| 1073 | |
| 1074 | // experimental: if we have a shadow bitmap, create a texture for it |
| 1075 | if (shadow_bitmap.valid()) |
| 1076 | { |
| 1077 | render_texinfo texture; |
| 1078 | |
| 1079 | // fake in the basic data so it looks like it came from render.c |
| 1080 | texture.base = shadow_bitmap.raw_pixptr(0); |
| 1081 | texture.rowpixels = shadow_bitmap.rowpixels(); |
| 1082 | texture.width = shadow_bitmap.width(); |
| 1083 | texture.height = shadow_bitmap.height(); |
| 1084 | texture.palette = NULL; |
| 1085 | texture.seqid = 0; |
| 1086 | |
| 1087 | // now create it |
| 1088 | shadow_texture = texture_create(d3d, &texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXFORMAT(TEXFORMAT_ARGB32)); |
| 1089 | } |
| 1090 | |
| 1068 | 1091 | const char *fx_dir = downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(); |
| 1069 | 1092 | |
| 1070 | 1093 | // Replace all this garbage with a proper data-driven system |
| r20245 | r20246 | |
| 2063 | 2086 | if (!master_enable || !d3dintf->post_fx_available) |
| 2064 | 2087 | return; |
| 2065 | 2088 | |
| 2089 | initialized = false; |
| 2090 | |
| 2066 | 2091 | if(write_ini && !reset) |
| 2067 | 2092 | { |
| 2068 | 2093 | emu_file file(downcast<windows_options &>(window->machine().options()).screen_post_fx_dir(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); |
| r20245 | r20246 | |
| 2199 | 2224 | avi_final_target = NULL; |
| 2200 | 2225 | } |
| 2201 | 2226 | |
| 2202 | | global_free(options); |
| 2203 | | |
| 2204 | 2227 | shadow_bitmap.reset(); |
| 2205 | 2228 | } |
| 2206 | 2229 | |