diff --git a/Android/jni/Glide64/Glide64.mk b/Android/jni/Glide64/Glide64.mk index 2426d81b8..b99467c58 100644 --- a/Android/jni/Glide64/Glide64.mk +++ b/Android/jni/Glide64/Glide64.mk @@ -22,15 +22,16 @@ LOCAL_SRC_FILES := \ $(SRCDIR)/Glitch64/OGLEStextures.cpp \ $(SRCDIR)/Glitch64/OGLESwrappers.cpp \ $(SRCDIR)/Glide64/3dmath.cpp \ + $(SRCDIR)/Glide64/Android.cpp \ $(SRCDIR)/Glide64/Combine.cpp \ $(SRCDIR)/Glide64/Config.cpp \ $(SRCDIR)/Glide64/CRC.cpp \ $(SRCDIR)/Glide64/Debugger.cpp \ $(SRCDIR)/Glide64/DepthBufferRender.cpp \ $(SRCDIR)/Glide64/FBtoScreen.cpp \ - $(SRCDIR)/Glide64/Keys.cpp \ $(SRCDIR)/Glide64/Main.cpp \ $(SRCDIR)/Glide64/rdp.cpp \ + $(SRCDIR)/Glide64/ScreenResolution.cpp \ $(SRCDIR)/Glide64/Settings.cpp \ $(SRCDIR)/Glide64/TexBuffer.cpp \ $(SRCDIR)/Glide64/TexCache.cpp \ diff --git a/Android/res/values/strings.xml b/Android/res/values/strings.xml index 024a939dd..3d3c5fa18 100644 --- a/Android/res/values/strings.xml +++ b/Android/res/values/strings.xml @@ -100,9 +100,11 @@ Advanced CPU Usage Show the cpu used by different components - Display Speed Limit the max speed executed Limit FPS + Rendered Resolution + should show value??? + Display Speed Show the speed of the emulation Display Speed Display Display lists per second diff --git a/Android/res/xml/setting_video.xml b/Android/res/xml/setting_video.xml index 0c7ab6470..f8cf1cbba 100644 --- a/Android/res/xml/setting_video.xml +++ b/Android/res/xml/setting_video.xml @@ -1,6 +1,12 @@ + = Build.VERSION_CODES.GINGERBREAD; - + /** True if device is running Honeycomb or later (11 - Android 3.0.x) */ public static final boolean IS_HONEYCOMB = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; - + /** True if device is running Honeycomb MR1 or later (12 - Android 3.1.x) */ public static final boolean IS_HONEYCOMB_MR1 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1; - + /** True if device is running Ice Cream Sandwich or later (14 - Android 4.0.x) */ public static final boolean IS_ICE_CREAM_SANDWICH = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH; - + /** True if device is running Jellybean or later (16 - Android 4.1.x) */ public static final boolean IS_JELLY_BEAN = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN; - + /** True if device is running KitKat or later (19 - Android 4.4.x) */ public static final boolean IS_KITKAT = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; - + /** True if device is running Lollipop or later (21 - Android 5.0.x) */ public static final boolean IS_LOLLIPOP = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; /** True if device is an OUYA. */ public static final boolean IS_OUYA_HARDWARE = OuyaFacade.getInstance().isRunningOnOUYAHardware(); - + public final static String EXTERNAL_PUBLIC_DIRECTORY = Environment.getExternalStorageDirectory().getPath(); public final static String PACKAGE_DIRECTORY = EXTERNAL_PUBLIC_DIRECTORY + "/Android/data/" + AndroidDevice.class.getPackage().getName(); public static final boolean IS_ACTION_BAR_AVAILABLE = AndroidDevice.IS_HONEYCOMB && !AndroidDevice.IS_OUYA_HARDWARE; final static boolean isTv; - + public final static int nativeWidth, nativeWidthOriginal; + public final static int nativeHeight, nativeHeightOriginal; + public static boolean MapVolumeKeys = false; - - static + + static { isTv = Project64Application.getAppContext().getPackageManager().hasSystemFeature("android.software.leanback"); + DisplayMetrics metrics = Project64Application.getAppContext().getResources().getDisplayMetrics(); + int _nativeWidth = metrics.widthPixels < metrics.heightPixels ? metrics.heightPixels : metrics.widthPixels; + int _nativeHeight = metrics.widthPixels < metrics.heightPixels ? metrics.widthPixels: metrics.heightPixels; + + if (IS_KITKAT) + { + Point size = new Point(); + try + { + ((WindowManager) Project64Application.getAppContext().getSystemService(Project64Application.getAppContext().WINDOW_SERVICE)).getDefaultDisplay().getRealSize(size); + _nativeWidth = size.x < size.y ? size.y : size.x; + _nativeHeight = size.x < size.y ? size.x: size.y; + } + catch (NoSuchMethodError e) + { + } + } + nativeWidth = _nativeWidth; + nativeHeight = _nativeHeight; + + final float aspect = 0.75f; + final boolean isLetterboxed = ( (float) nativeHeight / (float) nativeWidth ) > aspect; + nativeWidthOriginal = isLetterboxed ? nativeWidth : Math.round( nativeHeight / aspect ); + nativeHeightOriginal = isLetterboxed ? Math.round( nativeWidth * aspect ) : nativeHeight; } - - public static boolean isAndroidTv() + + public static boolean isAndroidTv() { return isTv; } - + public static List getUnmappableKeyCodes () { List unmappables = new ArrayList(); @@ -89,8 +120,8 @@ public class AndroidDevice } return unmappables; } - - public static ArrayList getStorageDirectories() + + public static ArrayList getStorageDirectories() { BufferedReader bufReader = null; ArrayList list = new ArrayList(); @@ -99,7 +130,7 @@ public class AndroidDevice List typeWL = Arrays.asList("vfat", "exfat", "sdcardfs", "fuse", "ntfs", "fat32", "ext3", "ext4", "esdfs"); List typeBL = Arrays.asList("tmpfs"); String[] mountWL = {"/mnt", "/Removable", "/storage"}; - String[] mountBL = + String[] mountBL = { "/mnt/secure", "/mnt/shell", @@ -109,18 +140,18 @@ public class AndroidDevice "/mnt/media_rw/sdcard", "/storage/emulated" }; - String[] deviceWL = + String[] deviceWL = { "/dev/block/vold", "/dev/fuse", "/mnt/media_rw" }; - try + try { bufReader = new BufferedReader(new FileReader("/proc/mounts")); String line; - while ((line = bufReader.readLine()) != null) + while ((line = bufReader.readLine()) != null) { StringTokenizer tokens = new StringTokenizer(line, " "); String device = tokens.nextToken(); @@ -134,7 +165,7 @@ public class AndroidDevice } // check that device is in whitelist, and either type or mountpoint is in a whitelist - if (Strings.startsWith(deviceWL, device) && (typeWL.contains(type) || Strings.startsWith(mountWL, mountpoint))) + if (Strings.startsWith(deviceWL, device) && (typeWL.contains(type) || Strings.startsWith(mountWL, mountpoint))) { int position = Strings.containsName(list, FileUtil.getFileNameFromPath(mountpoint)); if (position > -1) @@ -145,13 +176,13 @@ public class AndroidDevice } } } - catch (FileNotFoundException e) + catch (FileNotFoundException e) { } - catch (IOException e) + catch (IOException e) { } - finally + finally { Utility.close(bufReader); } diff --git a/Android/src/emu/project64/GalleryActivity.java b/Android/src/emu/project64/GalleryActivity.java index 25e4dece2..5c5c73bde 100644 --- a/Android/src/emu/project64/GalleryActivity.java +++ b/Android/src/emu/project64/GalleryActivity.java @@ -843,7 +843,7 @@ public class GalleryActivity extends AppCompatActivity implements IabBroadcastLi { return false; } - + int RunCount = NativeExports.UISettingsLoadDword(UISettingID.SupportWindow_RunCount.getValue()); Log.d("GalleryActivity", "ShowSupportWindow RunCount = " + RunCount); if (RunCount == -1) diff --git a/Android/src/emu/project64/game/GameLifecycleHandler.java b/Android/src/emu/project64/game/GameLifecycleHandler.java index 21e755ba8..9a3a228b5 100644 --- a/Android/src/emu/project64/game/GameLifecycleHandler.java +++ b/Android/src/emu/project64/game/GameLifecycleHandler.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Set; import emu.project64.AndroidDevice; +import emu.project64.Project64Application; import emu.project64.R; import emu.project64.hack.MogaHack; import emu.project64.input.AbstractController; @@ -34,10 +35,12 @@ import emu.project64.input.provider.KeyProvider; import emu.project64.input.provider.KeyProvider.ImeFormula; import emu.project64.input.provider.MogaProvider; import emu.project64.jni.NativeExports; +import emu.project64.jni.NativeVideo; import emu.project64.jni.NativeXperiaTouchpad; import emu.project64.jni.SettingsID; import emu.project64.jni.SystemEvent; import emu.project64.jni.UISettingID; +import emu.project64.jni.VideoSettingID; import emu.project64.persistent.ConfigFile; import emu.project64.persistent.ConfigFile.ConfigSection; import emu.project64.profile.Profile; @@ -52,11 +55,15 @@ import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.os.Vibrator; import android.util.Log; +import android.view.Display; +import android.view.Gravity; import android.view.KeyEvent; import android.view.SurfaceHolder; import android.view.View; import android.view.Window; +import android.view.WindowManager; import android.view.WindowManager.LayoutParams; +import android.widget.FrameLayout; public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.Callback, GameSurface.SurfaceInfo { @@ -92,7 +99,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C mActivity = activity; mControllers = new ArrayList(); mIsXperiaPlay = !(activity instanceof GameActivity); - mMogaController = Controller.getInstance( mActivity ); + mMogaController = Controller.getInstance(mActivity); } @TargetApi(11) @@ -105,8 +112,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C // Initialize MOGA controller API // TODO: Remove hack after MOGA SDK is fixed // mMogaController.init(); - MogaHack.init( mMogaController, mActivity ); - + MogaHack.init(mMogaController, mActivity); // For Honeycomb, let the action bar overlay the rendered view (rather // than squeezing it) @@ -140,19 +146,34 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C // Lay out content and get the views mActivity.setContentView(R.layout.game_activity); - mSurface = (GameSurface) mActivity.findViewById( R.id.gameSurface ); + mSurface = (GameSurface) mActivity.findViewById(R.id.gameSurface); mOverlay = (GameOverlay) mActivity.findViewById(R.id.gameOverlay); + float widthRatio = (float)AndroidDevice.nativeWidth/(float)AndroidDevice.nativeWidthOriginal; + float heightRatio = (float)AndroidDevice.nativeHeight/(float)AndroidDevice.nativeHeightOriginal; + int ScreenRes = NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue()); + + int videoRenderWidth = Math.round(NativeVideo.GetScreenResWidth(ScreenRes) * (ScreenRes == 0 ? 1 : widthRatio)); + int videoRenderHeight = Math.round(NativeVideo.GetScreenResHeight(ScreenRes) * (ScreenRes == 0 ? 1 : heightRatio)); + + // Update screen res + mSurface.getHolder().setFixedSize(videoRenderWidth, videoRenderHeight); + final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mSurface.getLayoutParams(); + params.width = AndroidDevice.nativeWidth; + params.height = AndroidDevice.nativeHeight; + params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL; + mSurface.setLayoutParams(params); + // Listen to game surface events (created, changed, destroyed) - mSurface.getHolder().addCallback( this ); - mSurface.createGLContext((ActivityManager)mActivity.getSystemService(Context.ACTIVITY_SERVICE)); + mSurface.getHolder().addCallback(this); + mSurface.createGLContext((ActivityManager) mActivity.getSystemService(Context.ACTIVITY_SERVICE)); // Configure the action bar introduced in higher Android versions if (AndroidDevice.IS_ACTION_BAR_AVAILABLE) { mActivity.getActionBar().hide(); ColorDrawable color = new ColorDrawable(Color.parseColor("#303030")); - color.setAlpha(50 /*mGlobalPrefs.displayActionBarTransparency*/); + color.setAlpha(50 /* mGlobalPrefs.displayActionBarTransparency */); mActivity.getActionBar().setBackgroundDrawable(color); } @@ -162,8 +183,9 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C View inputSource = mIsXperiaPlay ? new NativeXperiaTouchpad(mActivity) : mOverlay; initControllers(inputSource); - // Override the peripheral controllers' key provider, to add some extra functionality - inputSource.setOnKeyListener( this ); + // Override the peripheral controllers' key provider, to add some extra + // functionality + inputSource.setOnKeyListener(this); } public void onStart() @@ -235,7 +257,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C { pause = true; PauseType = NativeExports.SettingsLoadDword(SettingsID.GameRunning_CPU_PausedType.getValue()); - NativeExports.ExternalEvent( SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue()); + NativeExports.ExternalEvent(SystemEvent.SysEvent_ResumeCPU_FromMenu.getValue()); } int CurrentSaveState = NativeExports.SettingsLoadDword(SettingsID.Game_CurrentSaveState.getValue()); int OriginalSaveTime = NativeExports.SettingsLoadDword(SettingsID.Game_LastSaveTime.getValue()); @@ -256,7 +278,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C { Thread.sleep(100); } - catch(InterruptedException ex) + catch (InterruptedException ex) { Thread.currentThread().interrupt(); } @@ -264,7 +286,7 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C NativeExports.SettingsSaveDword(SettingsID.Game_CurrentSaveState.getValue(), CurrentSaveState); if (pause) { - NativeExports.ExternalEvent( SystemEvent.SysEvent_PauseCPU_FromMenu.getValue()); + NativeExports.ExternalEvent(SystemEvent.SysEvent_PauseCPU_FromMenu.getValue()); NativeExports.SettingsSaveDword(SettingsID.GameRunning_CPU_PausedType.getValue(), PauseType); } } @@ -324,9 +346,9 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C mMogaController.exit(); } - public void onSettingDone () + public void onSettingDone() { - mtouchscreenScale = ((float)NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) / 100.0f; + mtouchscreenScale = ((float) NativeExports.UISettingsLoadDword(UISettingID.TouchScreen_ButtonScale.getValue())) / 100.0f; mlayout = NativeExports.UISettingsLoadString(UISettingID.TouchScreen_Layout.getValue()); mControllers = new ArrayList(); CreateTouchScreenControls(); @@ -339,37 +361,40 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C private void CreateTouchScreenControls() { - boolean isTouchscreenAnimated = false; //mGlobalPrefs.isTouchscreenAnimated - boolean isTouchscreenHidden = false; //!isTouchscreenEnabled || globalPrefs.touchscreenTransparency == 0; + boolean isTouchscreenAnimated = false; // mGlobalPrefs.isTouchscreenAnimated + boolean isTouchscreenHidden = false; // !isTouchscreenEnabled || + // globalPrefs.touchscreenTransparency + // == 0; String profilesDir = AndroidDevice.PACKAGE_DIRECTORY + "/profiles"; String touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg"; - ConfigFile touchscreenConfigFile = new ConfigFile( touchscreenProfiles_cfg ); + ConfigFile touchscreenConfigFile = new ConfigFile(touchscreenProfiles_cfg); ConfigSection section = touchscreenConfigFile.get(mlayout); if (section == null) { mlayout = "Analog"; section = touchscreenConfigFile.get(mlayout); } - Profile touchscreenProfile = new Profile( true, section); + Profile touchscreenProfile = new Profile(true, section); int touchscreenTransparency = 100; String touchscreenSkinsDir = AndroidDevice.PACKAGE_DIRECTORY + "/skins/touchscreen"; String touchscreenSkin = touchscreenSkinsDir + "/Outline"; - // The touch map and overlay are needed to display frame rate and/or controls - mTouchscreenMap = new VisibleTouchMap( mActivity.getResources() ); - mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency ); - mOverlay.initialize( mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated ); - } + // The touch map and overlay are needed to display frame rate and/or + // controls + mTouchscreenMap = new VisibleTouchMap(mActivity.getResources()); + mTouchscreenMap.load(touchscreenSkin, touchscreenProfile, isTouchscreenAnimated, mtouchscreenScale, touchscreenTransparency); + mOverlay.initialize(mTouchscreenMap, !isTouchscreenHidden, isTouchscreenAnimated); + } @Override - public boolean onKey( View view, int keyCode, KeyEvent event ) + public boolean onKey(View view, int keyCode, KeyEvent event) { // If PeripheralControllers exist and handle the event, // they return true. Else they return false, signaling // Android to handle the event (menu button, vol keys). - if( mKeyProvider != null ) + if (mKeyProvider != null) { - return mKeyProvider.onKey( view, keyCode, event ); + return mKeyProvider.onKey(view, keyCode, event); } return false; } @@ -378,32 +403,32 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C private void initControllers(View inputSource) { // By default, send Player 1 rumbles through phone vibrator - Vibrator vibrator = (Vibrator) mActivity.getSystemService( Context.VIBRATOR_SERVICE ); + Vibrator vibrator = (Vibrator) mActivity.getSystemService(Context.VIBRATOR_SERVICE); int touchscreenAutoHold = 0; boolean isTouchscreenFeedbackEnabled = false; Set autoHoldableButtons = null; // Create the touchscreen controller - TouchController touchscreenController = new TouchController( mTouchscreenMap, - inputSource, mOverlay, vibrator, touchscreenAutoHold, - isTouchscreenFeedbackEnabled, autoHoldableButtons ); - mControllers.add( touchscreenController ); + TouchController touchscreenController = new TouchController(mTouchscreenMap, inputSource, mOverlay, vibrator, + touchscreenAutoHold, isTouchscreenFeedbackEnabled, autoHoldableButtons); + mControllers.add(touchscreenController); // Create the input providers shared among all peripheral controllers String profile_name = NativeExports.UISettingsLoadString(UISettingID.Controller_CurrentProfile.getValue()); - ConfigFile ControllerConfigFile = new ConfigFile(NativeExports.UISettingsLoadString(UISettingID.Controller_ConfigFile.getValue())); - ConfigSection section = ControllerConfigFile.get( profile_name ); + ConfigFile ControllerConfigFile = new ConfigFile( + NativeExports.UISettingsLoadString(UISettingID.Controller_ConfigFile.getValue())); + ConfigSection section = ControllerConfigFile.get(profile_name); if (section != null) { - Profile ControllerProfile = new Profile( false, section ); - InputMap map = new InputMap( ControllerProfile.get( "map" ) ); + Profile ControllerProfile = new Profile(false, section); + InputMap map = new InputMap(ControllerProfile.get("map")); - mKeyProvider = new KeyProvider( inputSource, ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes() ); - MogaProvider mogaProvider = new MogaProvider( mMogaController ); - AbstractProvider axisProvider = AndroidDevice.IS_HONEYCOMB_MR1 ? new AxisProvider( inputSource ) : null; + mKeyProvider = new KeyProvider(inputSource, ImeFormula.DEFAULT, AndroidDevice.getUnmappableKeyCodes()); + MogaProvider mogaProvider = new MogaProvider(mMogaController); + AbstractProvider axisProvider = AndroidDevice.IS_HONEYCOMB_MR1 ? new AxisProvider(inputSource) : null; int Deadzone = NativeExports.UISettingsLoadDword(UISettingID.Controller_Deadzone.getValue()); int Sensitivity = NativeExports.UISettingsLoadDword(UISettingID.Controller_Sensitivity.getValue()); - mControllers.add( new PeripheralController( 1, map, Deadzone, Sensitivity, mKeyProvider, axisProvider, mogaProvider ) ); + mControllers.add(new PeripheralController(1, map, Deadzone, Sensitivity, mKeyProvider, axisProvider, mogaProvider)); } } @@ -442,4 +467,4 @@ public class GameLifecycleHandler implements View.OnKeyListener, SurfaceHolder.C } NativeExports.onSurfaceChanged(width, height); } -} +} \ No newline at end of file diff --git a/Android/src/emu/project64/jni/LanguageStringID.java b/Android/src/emu/project64/jni/LanguageStringID.java index e3be953eb..40354211b 100644 --- a/Android/src/emu/project64/jni/LanguageStringID.java +++ b/Android/src/emu/project64/jni/LanguageStringID.java @@ -589,6 +589,9 @@ public enum LanguageStringID ANDROID_MENU_DEBUGGINGOPTIONS(3111), ANDROID_MENU_RESETFUNCTIONTIMES(3112), ANDROID_MENU_DUMPFUNCTIONTIMES(3113), + + //Video plugin + ANDROID_VIDEO_NATIVE_RES(3200), ; private int value; diff --git a/Android/src/emu/project64/jni/NativeVideo.java b/Android/src/emu/project64/jni/NativeVideo.java new file mode 100644 index 000000000..39432d44a --- /dev/null +++ b/Android/src/emu/project64/jni/NativeVideo.java @@ -0,0 +1,31 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +package emu.project64.jni; + +/** + * Calls made between the native input-android library and Java. Any function names changed here + * should also be changed in the corresponding C code, and vice versa. + * + * @see /Source/Android/PluginInput/Main.cpp + * @see CoreInterface + */ +public class NativeVideo +{ + static + { + System.loadLibrary( "Project64-gfx-glide64" ); + } + + public static native int getResolutionCount(); + public static native String getResolutionName(int Index); + public static native int GetScreenResWidth(int Index); + public static native int GetScreenResHeight(int Index); +} diff --git a/Android/src/emu/project64/jni/VideoSettingID.java b/Android/src/emu/project64/jni/VideoSettingID.java new file mode 100644 index 000000000..71d505ea6 --- /dev/null +++ b/Android/src/emu/project64/jni/VideoSettingID.java @@ -0,0 +1,63 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +package emu.project64.jni; + +public enum VideoSettingID +{ + // General Settings + Set_vsync, Set_Rotate, Set_texenh_options, Set_wrpVRAM, + Set_wrpFBO, Set_wrpAnisotropic, Set_autodetect_ucode, Set_ucode, Set_wireframe, + Set_wfmode, Set_unk_as_red, Set_unk_clear, Set_ghq_fltr, + Set_ghq_cmpr, Set_ghq_enht, Set_ghq_hirs, Set_ghq_enht_cmpr, Set_ghq_enht_tile, + Set_ghq_enht_f16bpp, Set_ghq_enht_gz, Set_ghq_enht_nobg, Set_ghq_hirs_cmpr, + Set_ghq_hirs_tile, Set_ghq_hirs_f16bpp, Set_ghq_hirs_gz, Set_ghq_hirs_altcrc, + Set_ghq_cache_save, Set_ghq_cache_size, Set_ghq_hirs_let_texartists_fly, + Set_ghq_hirs_dump, Set_Resolution, + + // Default Game Settings + Set_optimize_texrect_default, Set_filtering_default, Set_lodmode_default, + Set_fog_default, Set_buff_clear_default, Set_swapmode_default, + Set_aspect_default, Set_fb_smart_default, Set_fb_hires_default, + Set_fb_read_always_default, Set_read_back_to_screen_default, Set_detect_cpu_write_default, + Set_fb_get_info_default, Set_fb_render_default, + + //Game Settings + Set_alt_tex_size, Set_use_sts1_only, Set_force_calc_sphere, Set_correct_viewport, + Set_increase_texrect_edge, Set_decrease_fillrect_edge, Set_texture_correction, + Set_pal230, Set_stipple_mode, Set_stipple_pattern, Set_force_microcheck, Set_force_quad3d, + Set_clip_zmin, Set_clip_zmax, Set_fast_crc, Set_adjust_aspect, Set_zmode_compare_less, + Set_old_style_adither, Set_n64_z_scale, Set_optimize_texrect, Set_ignore_aux_copy, + Set_hires_buf_clear, Set_fb_read_alpha, Set_useless_is_useless, Set_fb_crc_mode, + Set_filtering, Set_fog, Set_buff_clear, Set_swapmode, Set_aspect, Set_lodmode, + Set_fb_smart, Set_fb_hires, Set_fb_read_always, Set_read_back_to_screen, + Set_detect_cpu_write, Set_fb_get_info, Set_fb_render, + + //RDB Setting + Set_ucodeLookup, + ; + + private int value; + + public int getValue() + { + return this.value; + } + private static final class StaticFields + { + public static int Counter = 0; + } + + private VideoSettingID() + { + this.value = StaticFields.Counter; + StaticFields.Counter += 1; + } +} diff --git a/Android/src/emu/project64/settings/GamepadScreenFragment.java b/Android/src/emu/project64/settings/GamepadScreenFragment.java index d134bfec8..c1b8fb8f2 100644 --- a/Android/src/emu/project64/settings/GamepadScreenFragment.java +++ b/Android/src/emu/project64/settings/GamepadScreenFragment.java @@ -31,27 +31,5 @@ public class GamepadScreenFragment extends BaseSettingsFragment public void onCreatePreferences(Bundle bundle, String s) { super.onCreatePreferences(bundle, s); - - /*String profilesDir = AndroidDevice.PACKAGE_DIRECTORY + "/profiles"; - String touchscreenProfiles_cfg = profilesDir + "/touchscreen.cfg"; - ConfigFile touchscreenProfiles = new ConfigFile( touchscreenProfiles_cfg ); - Set layoutsKeySet = touchscreenProfiles.keySet(); - String[] layouts = layoutsKeySet.toArray(new String[layoutsKeySet.size()]); - - CharSequence[] entries = new CharSequence[layouts.length]; - String[] entryValues = new String[layouts.length]; - String[] entrySubtitles = new String[layouts.length]; - - for( int i = 0; i < layouts.length; i++ ) - { - entries[i] = layouts[i]; - entryValues[i] = layouts[i]; - entrySubtitles[i] = touchscreenProfiles.get(layouts[i]).get("comment"); - } - - final TwoLinesListPreference listPreference = (TwoLinesListPreference) findPreference("touchscreenLayout"); - listPreference.setEntries(entries); - listPreference.setEntryValues(entryValues); - listPreference.setEntriesSubtitles(entrySubtitles);*/ } } diff --git a/Android/src/emu/project64/settings/SettingsActivity.java b/Android/src/emu/project64/settings/SettingsActivity.java index 554d9787e..41378c9c7 100644 --- a/Android/src/emu/project64/settings/SettingsActivity.java +++ b/Android/src/emu/project64/settings/SettingsActivity.java @@ -18,6 +18,7 @@ import emu.project64.jni.NativeExports; import emu.project64.jni.SettingsID; import emu.project64.jni.SystemEvent; import emu.project64.jni.UISettingID; +import emu.project64.jni.VideoSettingID; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -92,6 +93,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere .putString("Debugger_TraceExceptionHandler",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.Debugger_TraceExceptionHandler.getValue()))) .putString("Debugger_TraceAudioInitShutdown",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInitShutdown.getValue()))) .putString("Debugger_TraceAudioAudioInterface",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInterface.getValue()))) + .putString("video_screenResolution",String.valueOf(NativeExports.SettingsLoadDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue()))) .putInt("MaxRomsRemembered",NativeExports.UISettingsLoadDword(UISettingID.File_RecentGameFileCount.getValue())) .apply(); @@ -175,6 +177,7 @@ public class SettingsActivity extends AppCompatActivity implements SharedPrefere else if (key.equals("Debugger_TraceExceptionHandler")) { NativeExports.SettingsSaveDword(SettingsID.Debugger_TraceExceptionHandler.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceAudioInitShutdown")) { NativeExports.SettingsSaveDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInitShutdown.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("Debugger_TraceAudioAudioInterface")) { NativeExports.SettingsSaveDword(SettingsID.FirstAudioSettings.getValue() + AudioSettingID.Logging_LogAudioInterface.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } + else if (key.equals("video_screenResolution")) { NativeExports.SettingsSaveDword(SettingsID.FirstGfxSettings.getValue() + VideoSettingID.Set_Resolution.getValue(), Integer.valueOf(sharedPreferences.getString(key, "1"))); } else if (key.equals("MaxRomsRemembered")) { NativeExports.UISettingsSaveDword(UISettingID.File_RecentGameFileCount.getValue(), sharedPreferences.getInt(key, 10)); } } } diff --git a/Android/src/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java b/Android/src/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java index f69d47c3a..a23cf0f01 100644 --- a/Android/src/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java +++ b/Android/src/emu/project64/settings/TwoLinesListPreferenceDialogFragmentCompat.java @@ -32,18 +32,15 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog return (TwoLinesListPreference)this.getPreference(); } - class YourAdapter extends ArrayAdapter + class TwoLinesListPreferenceAdapter extends ArrayAdapter { - public YourAdapter(Context context, String[] values) + public TwoLinesListPreferenceAdapter(Context context, String[] values) { super(context, R.layout.two_lines_list_preference_row, values); } class ViewHolder { - TextView title; - TextView subTitle; - RadioButton radioBtn; } ViewHolder holder; @@ -52,33 +49,32 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog @Override public View getView(int position, View convertView, ViewGroup parent) { - final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - if (convertView == null) - { - convertView = inflater.inflate(R.layout.two_lines_list_preference_row, null); - holder = new ViewHolder(); - holder.title = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_text); - holder.subTitle = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_subtext); - holder.radioBtn = (RadioButton) convertView.findViewById(R.id.two_lines_list_view_row_radiobtn); - convertView.setTag(holder); + final TwoLinesListPreference preference = getTwoLinesListPreference(); - holder.title.setOnClickListener(listener); - holder.subTitle.setOnClickListener(listener); - holder.radioBtn.setOnClickListener(listener); + final LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); + convertView = inflater.inflate(R.layout.two_lines_list_preference_row, null); + + TextView title = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_text); + title.setOnClickListener(listener); + title.setText(preference.getEntries()[position]); + title.setTag(position); + + TextView subTitle = (TextView) convertView.findViewById(R.id.two_lines_list_view_row_subtext); + if (preference.getEntriesSubtitles()[position].length() == 0) + { + subTitle.setVisibility(View.GONE); } else { - holder = (ViewHolder) convertView.getTag(); + subTitle.setOnClickListener(listener); + subTitle.setText(preference.getEntriesSubtitles()[position]); + subTitle.setTag(position); } - final TwoLinesListPreference preference = getTwoLinesListPreference(); - holder.title.setText(preference.getEntries()[position]); - holder.title.setTag(position); - holder.subTitle.setText(preference.getEntriesSubtitles()[position]); - holder.subTitle.setTag(position); - - holder.radioBtn.setChecked(preference.getValueIndex() == position); - holder.radioBtn.setTag(position); + RadioButton radioBtn = (RadioButton) convertView.findViewById(R.id.two_lines_list_view_row_radiobtn); + radioBtn.setOnClickListener(listener); + radioBtn.setChecked(preference.getValueIndex() == position); + radioBtn.setTag(position); return convertView; } @@ -96,7 +92,7 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog values[i] = entries[i].toString(); } - ListAdapter adapter = new YourAdapter(builder.getContext(), values); + ListAdapter adapter = new TwoLinesListPreferenceAdapter(builder.getContext(), values); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @Override @@ -126,7 +122,7 @@ public class TwoLinesListPreferenceDialogFragmentCompat extends PreferenceDialog { final TwoLinesListPreference preference = getTwoLinesListPreference(); int EntryIndex = (Integer) v.getTag(); - preference.setValue(preference.getEntries()[EntryIndex].toString()); + preference.setValue(preference.getEntryValues()[EntryIndex].toString()); TwoLinesListPreferenceDialogFragmentCompat.this.getDialog().dismiss(); } } diff --git a/Android/src/emu/project64/settings/VideoFragment.java b/Android/src/emu/project64/settings/VideoFragment.java index 4db06a5f4..c1e5426cb 100644 --- a/Android/src/emu/project64/settings/VideoFragment.java +++ b/Android/src/emu/project64/settings/VideoFragment.java @@ -10,19 +10,58 @@ ****************************************************************************/ package emu.project64.settings; +import android.content.Context; +import android.graphics.Point; +import android.os.Build; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.WindowManager; +import emu.project64.AndroidDevice; import emu.project64.R; +import emu.project64.jni.LanguageStringID; +import emu.project64.jni.NativeVideo; +import emu.project64.util.Strings; public class VideoFragment extends BaseSettingsFragment { @Override - protected int getXml() + protected int getXml() { return R.xml.setting_video; } @Override - protected int getTitleId() + protected int getTitleId() { return R.string.video_screen_title; } + + @Override + public void onCreatePreferences(Bundle bundle, String s) + { + super.onCreatePreferences(bundle, s); + + int ResCount = NativeVideo.getResolutionCount(); + CharSequence[] ResEntries = new CharSequence[ResCount]; + String[] ResEntryValues = new String[ResCount]; + String[] ResEntrySubtitles = new String[ResCount]; + + for( int i = 0; i < ResCount; i++ ) + { + ResEntries[i] = NativeVideo.getResolutionName(i); + ResEntryValues[i] = Integer.toString(i); + ResEntrySubtitles[i] = ""; + if (ResEntries[i].equals("#3200#")) + { + ResEntries[i] = Strings.GetString(LanguageStringID.ANDROID_VIDEO_NATIVE_RES); + ResEntrySubtitles[i] = AndroidDevice.nativeWidth+"x"+AndroidDevice.nativeHeight; + } + } + + final TwoLinesListPreference listPreference = (TwoLinesListPreference) findPreference("video_screenResolution"); + listPreference.setEntries(ResEntries); + listPreference.setEntryValues(ResEntryValues); + listPreference.setEntriesSubtitles(ResEntrySubtitles); + } } diff --git a/Source/Glide64/3dmath.cpp b/Source/Glide64/3dmath.cpp index 6100d4f42..9d0b1f329 100644 --- a/Source/Glide64/3dmath.cpp +++ b/Source/Glide64/3dmath.cpp @@ -76,7 +76,7 @@ void calc_light(VERTEX *v) //* void calc_linear(VERTEX *v) { - if (g_settings->force_calc_sphere) + if (g_settings->force_calc_sphere()) { calc_sphere(v); return; @@ -122,7 +122,7 @@ void calc_sphere(VERTEX *v) WriteTrace(TraceRDP, TraceDebug, "calc_sphere"); DECLAREALIGN16VAR(vec[3]); int s_scale, t_scale; - if (g_settings->hacks&hack_Chopper) + if (g_settings->hacks(CSettings::hack_Chopper)) { s_scale = minval(rdp.tiles[rdp.cur_tile].org_s_scale >> 6, rdp.tiles[rdp.cur_tile].lr_s); t_scale = minval(rdp.tiles[rdp.cur_tile].org_t_scale >> 6, rdp.tiles[rdp.cur_tile].lr_t); diff --git a/Source/Glide64/Android.cpp b/Source/Glide64/Android.cpp new file mode 100644 index 000000000..d73ed3000 --- /dev/null +++ b/Source/Glide64/Android.cpp @@ -0,0 +1,37 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#ifdef ANDROID +#include +#include "ScreenResolution.h" + +#define EXPORT extern "C" __attribute__((visibility("default"))) +#define CALL + +EXPORT jint CALL Java_emu_project64_jni_NativeVideo_getResolutionCount(JNIEnv* env, jclass cls) +{ + return GetScreenResolutionCount(); +} + +EXPORT jstring CALL Java_emu_project64_jni_NativeVideo_getResolutionName(JNIEnv* env, jclass cls, int index) +{ + return env->NewStringUTF(GetScreenResolutionName(index)); +} + +EXPORT jint CALL Java_emu_project64_jni_NativeVideo_GetScreenResWidth(JNIEnv* env, jclass cls, int index) +{ + return GetScreenResWidth(index); +} + +EXPORT jint CALL Java_emu_project64_jni_NativeVideo_GetScreenResHeight(JNIEnv* env, jclass cls, int index) +{ + return GetScreenResHeight(index); +} +#endif \ No newline at end of file diff --git a/Source/Glide64/Combine.cpp b/Source/Glide64/Combine.cpp index e0ac9c9d1..4746edc2f 100644 --- a/Source/Glide64/Combine.cpp +++ b/Source/Glide64/Combine.cpp @@ -619,25 +619,7 @@ COMBINE cmb; cmb.tmu0_a_fac = GR_COMBINE_FACTOR_DETAIL_FACTOR, \ percent = (float)(rdp.env_color&0xFF) / 255.0f, \ cmb.dc0_detailmax = cmb.dc1_detailmax = percent - -// Bright red, sets up a bright red combine -#ifdef BRIGHT_RED -// Bright red, sets up a bright red combine during the alpha stage -#define BrightRed() { \ - CCMB (GR_COMBINE_FUNCTION_LOCAL, \ - GR_COMBINE_FACTOR_NONE, \ - GR_COMBINE_LOCAL_CONSTANT, \ - GR_COMBINE_OTHER_NONE); \ - ACMB (GR_COMBINE_FUNCTION_LOCAL, \ - GR_COMBINE_FACTOR_NONE, \ - GR_COMBINE_LOCAL_CONSTANT, \ - GR_COMBINE_OTHER_NONE); \ - cmb.ccolor = 0xFF0000FF; \ -} -#else -#define BrightRed() -#endif - + #define CC(color) cmb.ccolor=(color)&0xFFFFFF00 #define CC_BYTE(byte) { cmb.ccolor=(byte<<8)|(byte<<16)|(byte<<24); } #define CC_C1MULC2(color1, color2) { \ @@ -997,7 +979,7 @@ static void cc_shade() static void cc_one_mul_shade() { - if ((g_settings->hacks&hack_Knockout) && (rdp.aTBuffTex[0] || rdp.aTBuffTex[1] || rdp.cur_image)) //hack for boxer shadow + if (g_settings->hacks(CSettings::hack_Knockout) && (rdp.aTBuffTex[0] || rdp.aTBuffTex[1] || rdp.cur_image)) //hack for boxer shadow { CCMB(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, @@ -5976,7 +5958,7 @@ static void cc_prim_sub_env_mul_t1_add_env() GR_COMBINE_OTHER_CONSTANT); CC_PRIM(); SETSHADE_ENV(); - if (rdp.cycle_mode == 0 || ((g_settings->hacks&hack_KI) && (rdp.cycle2 & 0x0FFFFFFF) == 0x01FF1FFF)) + if (rdp.cycle_mode == 0 || (g_settings->hacks(CSettings::hack_KI) && (rdp.cycle2 & 0x0FFFFFFF) == 0x01FF1FFF)) { USE_T0(); } @@ -8130,13 +8112,12 @@ static void cc__t1_inter_t0_using_prim__mul_shade() static void cc__t0_inter_t1_using_primlod__mul_shade() { //* - if (rdp.LOD_en && (rdp.mipmap_level == 0) && !(g_settings->hacks&hack_Fifa98)) + if (rdp.LOD_en && (rdp.mipmap_level == 0) && !g_settings->hacks(CSettings::hack_Fifa98)) { cc_t0_mul_shade(); return; } - //*/ - if (g_settings->ucode == 7) + if (g_settings->ucode() == CSettings::ucode_PerfectDark) lod_frac = rdp.prim_lodfrac; CCMB(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, @@ -8412,7 +8393,7 @@ static void cc__one_inter_prim_using_t1__mul_shade() { if (cmb.combine_ext) { - if ((g_settings->hacks&hack_BAR) && rdp.cur_tile == 1) + if (g_settings->hacks(CSettings::hack_BAR) && rdp.cur_tile == 1) { T0CCMBEXT(GR_CMBX_TMU_CCOLOR, GR_FUNC_MODE_X, GR_CMBX_TMU_CALPHA, GR_FUNC_MODE_NEGATIVE_X, @@ -8444,7 +8425,7 @@ static void cc__one_inter_prim_using_t1__mul_shade() GR_COMBINE_FACTOR_LOCAL, GR_COMBINE_LOCAL_ITERATED, GR_COMBINE_OTHER_TEXTURE); - if ((g_settings->hacks&hack_BAR) && rdp.cur_tile == 1) + if (g_settings->hacks(CSettings::hack_BAR) && rdp.cur_tile == 1) { MOD_0(TMOD_COL_INTER_COL1_USING_TEX); MOD_0_COL(0xFFFFFF00); @@ -8813,7 +8794,7 @@ static void ac_t1() GR_COMBINE_FACTOR_ONE, GR_COMBINE_LOCAL_NONE, GR_COMBINE_OTHER_TEXTURE); - if ((g_settings->hacks&hack_BAR) && rdp.tiles[rdp.cur_tile].format == 3) + if (g_settings->hacks(CSettings::hack_BAR) && rdp.tiles[rdp.cur_tile].format == 3) A_USE_T0(); else A_USE_T1(); @@ -11202,7 +11183,7 @@ static void ac__t1_mul_primlod_add_t0__mul_env() static void ac__t0_inter_t1_using_primlod__mul_shade() { - if (g_settings->hacks & hack_Makers) + if (g_settings->hacks(CSettings::hack_Makers)) { //rolling rock issue - it has zero shade alpha and thus rejected by alpha compare ac_t0_inter_t1_using_primlod(); @@ -15521,12 +15502,18 @@ void Combine() Alpha0[(rdp.cycle1 >> 16) & 7], Alpha1[(rdp.cycle1 >> 19) & 7], Alpha2[(rdp.cycle1 >> 22) & 7], Alpha3[(rdp.cycle1 >> 25) & 7], Alpha0[(rdp.cycle2 >> 16) & 7], Alpha1[(rdp.cycle2 >> 19) & 7], Alpha2[(rdp.cycle2 >> 22) & 7], Alpha3[(rdp.cycle2 >> 25) & 7]); if (!rdp.LOD_en || rdp.cur_tile == rdp.mipmap_level) + { lod_frac = rdp.prim_lodfrac; - else if (g_settings->lodmode == 0) + } + else if (g_settings->lodmode() == CSettings::LOD_Off) + { lod_frac = 0; + } else + { lod_frac = 10; - + } + rdp.noise = RDP::noise_none; uint32_t found = TRUE; @@ -15602,12 +15589,9 @@ void Combine() if (actual_combine != current_combine) { rdp.uncombined |= 1; - if (g_settings->log_unk) - { - WriteTrace(TraceUnknown, TraceDebug, "COLOR combine not found: %08x, #1: (%s-%s)*%s+%s, #2: (%s-%s)*%s+%s", actual_combine, - Mode0[rdp.cycle1 & 0xF], Mode1[(rdp.cycle1 >> 4) & 0xF], Mode2[(rdp.cycle1 >> 8) & 0x1F], Mode3[(rdp.cycle1 >> 13) & 7], - Mode0[rdp.cycle2 & 0xF], Mode1[(rdp.cycle2 >> 4) & 0xF], Mode2[(rdp.cycle2 >> 8) & 0x1F], Mode3[(rdp.cycle2 >> 13) & 7]); - } + WriteTrace(TraceUnknown, TraceDebug, "COLOR combine not found: %08x, #1: (%s-%s)*%s+%s, #2: (%s-%s)*%s+%s", actual_combine, + Mode0[rdp.cycle1 & 0xF], Mode1[(rdp.cycle1 >> 4) & 0xF], Mode2[(rdp.cycle1 >> 8) & 0x1F], Mode3[(rdp.cycle1 >> 13) & 7], + Mode0[rdp.cycle2 & 0xF], Mode1[(rdp.cycle2 >> 4) & 0xF], Mode2[(rdp.cycle2 >> 8) & 0x1F], Mode3[(rdp.cycle2 >> 13) & 7]); found = FALSE; //tex |= 3; @@ -15653,23 +15637,12 @@ void Combine() if (actual_combine != current_combine) { rdp.uncombined |= 2; - if (g_settings->log_unk) - { - WriteTrace(TraceUnknown, TraceDebug, "ALPHA combine not found: %08x, #1: (%s-%s)*%s+%s, #2: (%s-%s)*%s+%s", actual_combine, - Alpha0[(rdp.cycle1 >> 16) & 7], Alpha1[(rdp.cycle1 >> 19) & 7], Alpha2[(rdp.cycle1 >> 22) & 7], Alpha3[(rdp.cycle1 >> 25) & 7], - Alpha0[(rdp.cycle2 >> 16) & 7], Alpha1[(rdp.cycle2 >> 19) & 7], Alpha2[(rdp.cycle2 >> 22) & 7], Alpha3[(rdp.cycle2 >> 25) & 7]); - } + WriteTrace(TraceUnknown, TraceDebug, "ALPHA combine not found: %08x, #1: (%s-%s)*%s+%s, #2: (%s-%s)*%s+%s", actual_combine, + Alpha0[(rdp.cycle1 >> 16) & 7], Alpha1[(rdp.cycle1 >> 19) & 7], Alpha2[(rdp.cycle1 >> 22) & 7], Alpha3[(rdp.cycle1 >> 25) & 7], + Alpha0[(rdp.cycle2 >> 16) & 7], Alpha1[(rdp.cycle2 >> 19) & 7], Alpha2[(rdp.cycle2 >> 22) & 7], Alpha3[(rdp.cycle2 >> 25) & 7]); } - if (g_settings->unk_as_red) - { - BrightRed(); - } - else - { - // use full alpha as default - ac_t0(); - } - //tex |= 3; + // use full alpha as default + ac_t0(); } else { @@ -15685,7 +15658,7 @@ void Combine() cc_t0(); ac_t1(); } - else if (color_combine == 0x613522f0 && (g_settings->hacks&hack_PMario)) //Paper Mario fortune teller spheres + else if (color_combine == 0x613522f0 && g_settings->hacks(CSettings::hack_PMario)) //Paper Mario fortune teller spheres { ac_t0(); } @@ -15713,9 +15686,9 @@ void Combine() aTBuff[rdp.aTBuffTex[1]->tile] = rdp.aTBuffTex[1]; if (cmb.tex && (aTBuff[0] || aTBuff[1])) { - if (aTBuff[0] && (g_settings->frame_buffer&fb_read_alpha)) + if (aTBuff[0] && g_settings->fb_read_alpha_enabled()) { - if ((g_settings->hacks&hack_PMario) && aTBuff[0]->width == rdp.ci_width) + if (g_settings->hacks(CSettings::hack_PMario) && aTBuff[0]->width == rdp.ci_width) ; else { @@ -15909,7 +15882,7 @@ void CombineBlender() */ else if (blendmode == 0x0040) // Mia Soccer Lights A_BLEND(GR_BLEND_SRC_ALPHA, GR_BLEND_ONE_MINUS_SRC_ALPHA); - else if ((g_settings->hacks&hack_Pilotwings) && (rdp.othermode_l & 0x80)) //CLR_ON_CVG without FORCE_BL + else if (g_settings->hacks(CSettings::hack_Pilotwings) && (rdp.othermode_l & 0x80)) //CLR_ON_CVG without FORCE_BL A_BLEND(GR_BLEND_ZERO, GR_BLEND_ONE); else A_BLEND(GR_BLEND_ONE, GR_BLEND_ZERO); @@ -15919,7 +15892,7 @@ void CombineBlender() // if (rdp.othermode_l & 0x2000) if ((rdp.othermode_l & 0x2000) && ((rdp.othermode_l & 0x7000) != 0x7000)) { - if ((g_settings->hacks&hack_PMario) && (blendmode == 0x5055)) + if (g_settings->hacks(CSettings::hack_PMario) && (blendmode == 0x5055)) { A_BLEND(GR_BLEND_ZERO, GR_BLEND_ONE); } @@ -15935,7 +15908,7 @@ void CombineBlender() //hack //* - if (g_settings->hacks&hack_ISS64) + if (g_settings->hacks(CSettings::hack_ISS64)) { if (rdp.othermode_l == 0xff5a6379) { @@ -15946,7 +15919,7 @@ void CombineBlender() A_BLEND(GR_BLEND_ZERO, GR_BLEND_ONE); } } - else if (g_settings->hacks&hack_TGR) + else if (g_settings->hacks(CSettings::hack_TGR)) { if (rdp.othermode_l == 0x0f0a0235) { diff --git a/Source/Glide64/Config.cpp b/Source/Glide64/Config.cpp index 93d0414a9..991fcdc2c 100644 --- a/Source/Glide64/Config.cpp +++ b/Source/Glide64/Config.cpp @@ -48,10 +48,9 @@ #include "DepthBufferRender.h" #include "Config.h" #include "trace.h" +#include "ScreenResolution.h" #include -short Set_basic_mode = 0, Set_texture_dir = 0, Set_log_dir = 0, Set_log_flush = 0; - #ifdef _WIN32 #include #include "resource.h" @@ -69,6 +68,7 @@ short Set_basic_mode = 0, Set_texture_dir = 0, Set_log_dir = 0, Set_log_flush = #include extern HINSTANCE hinstDLL; +extern bool g_ghq_use; extern CriticalSection * g_ProcessDListCS; @@ -107,48 +107,6 @@ void ConfigCleanup(void) void CloseConfig(); -#ifdef TEXTURE_FILTER -uint32_t texfltr[] = -{ - NO_FILTER, //"None" - SMOOTH_FILTER_1, //"Smooth filtering 1" - SMOOTH_FILTER_2, //"Smooth filtering 2" - SMOOTH_FILTER_3, //"Smooth filtering 3" - SMOOTH_FILTER_4, //"Smooth filtering 4" - SHARP_FILTER_1, //"Sharp filtering 1" - SHARP_FILTER_2, //"Sharp filtering 2" -}; - -uint32_t texenht[] = -{ - NO_ENHANCEMENT, //"None" - NO_ENHANCEMENT, //"Store" - X2_ENHANCEMENT, //"X2" - X2SAI_ENHANCEMENT, //"X2SAI" - HQ2X_ENHANCEMENT, //"HQ2X" - HQ2XS_ENHANCEMENT, //"HQ2XS" - LQ2X_ENHANCEMENT, //"LQ2X" - LQ2XS_ENHANCEMENT, //"LQ2XS" - HQ4X_ENHANCEMENT, //"HQ4X" -}; - -uint32_t texcmpr[] = -{ - //NO_COMPRESSION, //"None" - // NCC_COMPRESSION, //"NCC" - S3TC_COMPRESSION, //"S3TC" - FXT1_COMPRESSION, //"FXT1" -}; - -uint32_t texhirs[] = -{ - NO_HIRESTEXTURES, //"Do not use" - RICE_HIRESTEXTURES, //"Rice format" - // GHQ_HIRESTEXTURES, //"GlideHQ format" - // JABO_HIRESTEXTURES, //"Jabo format" -}; -#endif - #ifdef _WIN32 template < class T, class TT = CToolTipCtrl > @@ -312,8 +270,6 @@ public: COMMAND_HANDLER_EX(IDC_CMB_WINDOW_RES, CBN_SELCHANGE, ItemChanged) COMMAND_HANDLER_EX(IDC_CMB_FS_RESOLUTION, CBN_SELCHANGE, ItemChanged) COMMAND_HANDLER_EX(IDC_CHK_VERTICAL_SYNC, BN_CLICKED, ItemChanged) - COMMAND_HANDLER_EX(IDC_CHK_CLOCK_ENABLED, BN_CLICKED, ItemChanged) - COMMAND_HANDLER_EX(IDC_CHK_CLOCK_24, BN_CLICKED, ItemChanged) COMMAND_HANDLER_EX(IDC_CBXANISOTROPIC, BN_CLICKED, ItemChanged) COMMAND_HANDLER_EX(IDC_CHK_SHOW_TEXTURE_ENHANCEMENT, BN_CLICKED, ItemChanged) COMMAND_HANDLER_EX(IDC_CHK_AUTODETECT_VRAM, BN_CLICKED, ItemChanged) @@ -327,55 +283,19 @@ public: TTInit(); TTSize(400); m_WindowRes.Attach(GetDlgItem(IDC_CMB_WINDOW_RES)); - m_WindowRes.SetItemData(m_WindowRes.AddString("320x200"), 0); - m_WindowRes.SetItemData(m_WindowRes.AddString("320x240"), 1); - m_WindowRes.SetItemData(m_WindowRes.AddString("400x256"), 2); - m_WindowRes.SetItemData(m_WindowRes.AddString("512x384"), 3); - m_WindowRes.SetItemData(m_WindowRes.AddString("640x200"), 4); - m_WindowRes.SetItemData(m_WindowRes.AddString("640x350"), 5); - m_WindowRes.SetItemData(m_WindowRes.AddString("640x400"), 6); - m_WindowRes.SetItemData(m_WindowRes.AddString("640x480"), 7); - m_WindowRes.SetItemData(m_WindowRes.AddString("800x600"), 8); - m_WindowRes.SetItemData(m_WindowRes.AddString("960x720"), 9); - m_WindowRes.SetItemData(m_WindowRes.AddString("856x480"), 10); - m_WindowRes.SetItemData(m_WindowRes.AddString("512x256"), 11); - m_WindowRes.SetItemData(m_WindowRes.AddString("1024x768"), 12); - m_WindowRes.SetItemData(m_WindowRes.AddString("1280x1024"), 13); - m_WindowRes.SetItemData(m_WindowRes.AddString("1600x1200"), 14); - m_WindowRes.SetItemData(m_WindowRes.AddString("400x300"), 15); - m_WindowRes.SetItemData(m_WindowRes.AddString("1152x864"), 16); - m_WindowRes.SetItemData(m_WindowRes.AddString("1280x960"), 17); - m_WindowRes.SetItemData(m_WindowRes.AddString("1600x1024"), 18); - m_WindowRes.SetItemData(m_WindowRes.AddString("1792x1344"), 19); - m_WindowRes.SetItemData(m_WindowRes.AddString("1856x1392"), 20); - m_WindowRes.SetItemData(m_WindowRes.AddString("1920x1440"), 21); - m_WindowRes.SetItemData(m_WindowRes.AddString("2048x1536"), 22); - m_WindowRes.SetItemData(m_WindowRes.AddString("2048x2048"), 23); - SetComboBoxIndex(m_WindowRes, g_settings->res_data); + for (uint32_t i = 0, n = GetScreenResolutionCount(); i < n; i++) + { + m_WindowRes.SetItemData(m_WindowRes.AddString(GetScreenResolutionName(i)), i); + } + SetComboBoxIndex(m_WindowRes, g_settings->ScreenRes()); TTSetTxt(IDC_CMB_WINDOW_RES, "Resolution:\n\nThis option selects the windowed resolution.\n\n[Recommended: 640x480, 800x600, 1024x768]"); m_cbxVSync.Attach(GetDlgItem(IDC_CHK_VERTICAL_SYNC)); - m_cbxVSync.SetCheck(g_settings->vsync ? BST_CHECKED : BST_UNCHECKED); + m_cbxVSync.SetCheck(g_settings->vsync() ? BST_CHECKED : BST_UNCHECKED); TTSetTxt(IDC_CHK_VERTICAL_SYNC, "Vertical sync:\n\nThis option will enable the vertical sync, which will prevent tearing.\nNote: this option will ONLY have effect if vsync is set to \"Software Controlled\"."); - m_cmbScreenShotFormat.Attach(GetDlgItem(IDC_CMB_SCREEN_SHOT_FORMAT)); - for (int f = 0; f < NumOfFormats; f++) - { - m_cmbScreenShotFormat.SetItemData(m_cmbScreenShotFormat.AddString(ScreenShotFormats[f].format), ScreenShotFormats[f].type); - } - SetComboBoxIndex(m_cmbScreenShotFormat, g_settings->ssformat); - TTSetTxt(IDC_CMB_SCREEN_SHOT_FORMAT, "Select a format, in which screen shots will be saved"); - m_cbxTextureSettings.Attach(GetDlgItem(IDC_CHK_SHOW_TEXTURE_ENHANCEMENT)); - m_cbxTextureSettings.SetCheck(g_settings->texenh_options ? BST_CHECKED : BST_UNCHECKED); - - m_cbxClockEnabled.Attach(GetDlgItem(IDC_CHK_CLOCK_ENABLED)); - m_cbxClockEnabled.SetCheck(g_settings->clock > 0 ? BST_CHECKED : BST_UNCHECKED); - TTSetTxt(IDC_CHK_CLOCK_ENABLED, "Clock enabled:\n\nThis option will put a clock in the lower right corner of the screen, showing the current time.\n\n[Recommended: your preference]"); - - m_cbxClock24.Attach(GetDlgItem(IDC_CHK_CLOCK_24)); - m_cbxClock24.SetCheck(g_settings->clock_24_hr > 0 ? BST_CHECKED : BST_UNCHECKED); - TTSetTxt(IDC_CHK_CLOCK_24, "Display hours as 24-hour clock.\n\n[Recommended: your preference]"); + m_cbxTextureSettings.SetCheck(g_settings->texenh_options() ? BST_CHECKED : BST_UNCHECKED); m_cmbFSResolution.Attach(GetDlgItem(IDC_CMB_FS_RESOLUTION)); int32_t size = 0; @@ -386,24 +306,24 @@ public: { m_cmbFSResolution.AddString(aRes[r]); } - m_cmbFSResolution.SetCurSel(g_settings->wrpResolution < size ? g_settings->wrpResolution : 0); + m_cmbFSResolution.SetCurSel(g_settings->FullScreenRes() < size ? g_settings->FullScreenRes() : 0); } TTSetTxt(IDC_CMB_FS_RESOLUTION, "Full screen resolution:\n\nThis sets the full screen resolution.\nAll the resolutions that your video card / monitor support should be displayed.\n\n[Recommended:native(max) resolution of your monitor - unless performance becomes an issue]"); m_cbxAnisotropic.Attach(GetDlgItem(IDC_CBXANISOTROPIC)); - m_cbxAnisotropic.SetCheck(g_settings->wrpAnisotropic > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxAnisotropic.SetCheck(g_settings->wrpAnisotropic() ? BST_CHECKED : BST_UNCHECKED); TTSetTxt(IDC_CBXANISOTROPIC, "Anisotropic filtering:\n\nThis filter sharpens and brings out the details of textures that recede into the distance.\nWhen activated, it will use the max anisotropy your video card supports.\nHowever, this will override native way of texture filtering and may cause visual artifacts in some games.\n\n[Recommended: your preference, game dependant]"); m_cbxFBO.Attach(GetDlgItem(IDC_CHK_USE_FRAME_BUFFER_OBJECT)); TTSetTxt(IDC_CHK_USE_FRAME_BUFFER_OBJECT, "Use frame buffer objects:\n\nChanges the way FB effects are rendered - with or without usage of the OpenGL Frame Buffer Objects (FBO) extension.\nThe choice depends on game and your video card. FBO off is good for NVIDIA cards, while for ATI cards, it's usually best that FBOs are turned on.\nAlso, some FB effects works only with one of the methods, no matter, which card you have.\nOn the whole, with FBO off, compatibility/ accuracy is a bit better (which is the case for Resident Evil 2).\nHowever, with FBO on with some systems, it can actually be a bit faster in cases.\n\n[Recommended: video card and game dependant]"); - m_cbxFBO.SetCheck(g_settings->wrpFBO > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFBO.SetCheck(g_settings->wrpFBO() > 0 ? BST_CHECKED : BST_UNCHECKED); m_cbxVRAM.Attach(GetDlgItem(IDC_CHK_AUTODETECT_VRAM)); TTSetTxt(IDC_CHK_AUTODETECT_VRAM, "Autodetect VRAM Size:\n\nSince OpenGL cannot do this reliably at the moment, the option to set this manually is available.\nIf checked, plugin will try to autodetect VRAM size.\nBut if this appears wrong, please uncheck and set it to correct value.\n\n[Recommended: on]"); m_VramSize.Attach(GetDlgItem(IDC_SPIN_VRAM_SIZE)); m_VramSize.SetBuddy(GetDlgItem(IDC_TXT_VRAM_SIZE)); m_spinVRAM.Attach(GetDlgItem(IDC_TXT_VRAM_SIZE)); - m_cbxVRAM.SetCheck(g_settings->wrpVRAM == 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxVRAM.SetCheck(g_settings->wrpVRAM() == 0 ? BST_CHECKED : BST_UNCHECKED); m_lblMb.Attach(GetDlgItem(IDC_LBL_MB)); AutoDetectChanged(); return TRUE; @@ -414,23 +334,17 @@ public: char spinVRAM[100]; m_spinVRAM.GetWindowText(spinVRAM, sizeof(spinVRAM)); CSettings oldsettings = *g_settings; - g_settings->res_data = m_WindowRes.GetCurSel(); - g_settings->res_data_org = g_settings->res_data; - g_settings->scr_res_x = g_settings->res_x = resolutions[g_settings->res_data][0]; - g_settings->scr_res_y = g_settings->res_y = resolutions[g_settings->res_data][1]; - g_settings->vsync = m_cbxVSync.GetCheck() == BST_CHECKED; - g_settings->ssformat = m_cmbScreenShotFormat.GetCurSel(); - g_settings->texenh_options = m_cbxTextureSettings.GetCheck() == BST_CHECKED; - g_settings->clock = m_cbxClockEnabled.GetCheck() == BST_CHECKED; - g_settings->clock_24_hr = m_cbxClock24.GetCheck() == BST_CHECKED; - g_settings->wrpResolution = m_cmbFSResolution.GetCurSel(); - g_settings->wrpAnisotropic = m_cbxAnisotropic.GetCheck() == BST_CHECKED; - g_settings->wrpVRAM = m_cbxVRAM.GetCheck() == BST_CHECKED ? 0 : atoi(spinVRAM); - g_settings->wrpFBO = m_cbxFBO.GetCheck() == BST_CHECKED; + g_settings->SetScreenRes(m_WindowRes.GetCurSel()); + g_settings->SetVsync(m_cbxVSync.GetCheck() == BST_CHECKED); + g_settings->SetTexenhOptions(m_cbxTextureSettings.GetCheck() == BST_CHECKED); + g_settings->SetFullScreenRes(m_cmbFSResolution.GetCurSel()); + g_settings->SetWrpAnisotropic(m_cbxAnisotropic.GetCheck() == BST_CHECKED); + g_settings->SetWrpVRAM(m_cbxVRAM.GetCheck() == BST_CHECKED ? 0 : atoi(spinVRAM)); + g_settings->SetWrpFBO(m_cbxFBO.GetCheck() == BST_CHECKED); if (memcmp(&oldsettings, g_settings, sizeof(oldsettings))) //check that settings were changed { - WriteSettings(); + g_settings->WriteSettings(); } m_options_page->UpdateTextureSettings(); return true; @@ -447,7 +361,7 @@ private: void AutoDetectChanged(void) { - m_spinVRAM.SetWindowText(m_cbxVRAM.GetCheck() == BST_CHECKED ? " auto" : stdstr_f("%d",g_settings->wrpVRAM ? g_settings->wrpVRAM : 32).c_str()); + m_spinVRAM.SetWindowText(m_cbxVRAM.GetCheck() == BST_CHECKED ? " auto" : stdstr_f("%d",g_settings->wrpVRAM() != 0 ? g_settings->wrpVRAM() : 32).c_str()); m_spinVRAM.EnableWindow(m_cbxVRAM.GetCheck() != BST_CHECKED); m_VramSize.EnableWindow(m_cbxVRAM.GetCheck() != BST_CHECKED); m_lblMb.EnableWindow(m_cbxVRAM.GetCheck() != BST_CHECKED); @@ -455,10 +369,8 @@ private: COptionsSheet * m_options_page; CComboBox m_WindowRes, m_cmbFSResolution; - CComboBox m_cmbScreenShotFormat; CButton m_cbxVSync; CButton m_cbxTextureSettings; - CButton m_cbxClockEnabled, m_cbxClock24; CButton m_cbxAnisotropic; CButton m_cbxFBO; CButton m_cbxVRAM; @@ -512,77 +424,77 @@ public: TTSetTxt(IDC_CMB_FILTERING_MODE, tooltip.c_str()); m_cmbFiltering.Attach(GetDlgItem(IDC_CMB_FILTERING_MODE)); - m_cmbFiltering.SetItemData(m_cmbFiltering.AddString("Automatic"), 0); - m_cmbFiltering.SetItemData(m_cmbFiltering.AddString("Force Bilinear"), 1); - m_cmbFiltering.SetItemData(m_cmbFiltering.AddString("Force Point-sampled"), 2); - SetComboBoxIndex(m_cmbFiltering, g_settings->filtering); + m_cmbFiltering.SetItemData(m_cmbFiltering.AddString("Automatic"), CSettings::Filter_Automatic); + m_cmbFiltering.SetItemData(m_cmbFiltering.AddString("Force Bilinear"), CSettings::Filter_ForceBilinear); + m_cmbFiltering.SetItemData(m_cmbFiltering.AddString("Force Point-sampled"), CSettings::Filter_ForcePointSampled); + SetComboBoxIndex(m_cmbFiltering, (uint32_t)g_settings->filtering()); tooltip = "Buffer swapping method:\n\nThere are 3 buffer swapping methods:\n\n* old - swap buffers when vertical interrupt has occurred.\n* new - swap buffers when set of conditions is satisfied. Prevents flicker on some games.\n* hybrid - mix of first two methods. Can prevent even more flickering then previous method, but also can cause artefacts.\nIf you have flickering problems in a game (or graphics that don't show), try to change swapping method.\n\n[Recommended: new (hybrid for Paper Mario)]"; TTSetTxt(IDC_TXT_BUFFER_SWAPPING, tooltip.c_str()); TTSetTxt(IDC_CMB_BUFFER_SWAPPING, tooltip.c_str()); m_cmbBufferSwap.Attach(GetDlgItem(IDC_CMB_BUFFER_SWAPPING)); - m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("Old"), 0); - m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("New"), 1); - m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("Hybrid"), 2); - SetComboBoxIndex(m_cmbBufferSwap, g_settings->swapmode); + m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("Old"), CSettings::SwapMode_Old); + m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("New"), CSettings::SwapMode_New); + m_cmbBufferSwap.SetItemData(m_cmbBufferSwap.AddString("Hybrid"), CSettings::SwapMode_Hybrid); + SetComboBoxIndex(m_cmbBufferSwap, g_settings->swapmode()); tooltip = "Per-pixel level-of-detail calculation:\n\nN64 uses special mechanism for mip-mapping, which nearly impossible to reproduce correctly on PC hardware.\nThis option enables approximate emulation of this feature.\nFor example, it is required for the Peach/Bowser portrait's transition in Super Mario 64.\nThere are 3 modes:\n\n* off - LOD is not calculated\n* fast - fast imprecise LOD calculation.\n* precise - most precise LOD calculation possible, but more slow.\n\n[Recommended: your preference]"; TTSetTxt(IDC_TXT_LOD_CALC, tooltip.c_str()); TTSetTxt(IDC_CMB_LOD_CALC, tooltip.c_str()); m_cmbLOD.Attach(GetDlgItem(IDC_CMB_LOD_CALC)); - m_cmbLOD.SetItemData(m_cmbLOD.AddString("off"), 0); - m_cmbLOD.SetItemData(m_cmbLOD.AddString("fast"), 1); - m_cmbLOD.SetItemData(m_cmbLOD.AddString("precise"), 2); - SetComboBoxIndex(m_cmbLOD, g_settings->lodmode); + m_cmbLOD.SetItemData(m_cmbLOD.AddString("off"), CSettings::LOD_Off); + m_cmbLOD.SetItemData(m_cmbLOD.AddString("fast"), CSettings::LOD_Fast); + m_cmbLOD.SetItemData(m_cmbLOD.AddString("precise"), CSettings::LOD_Precise); + SetComboBoxIndex(m_cmbLOD, g_settings->lodmode()); tooltip = "Aspect ratio of the output:\n\nMost N64 games use 4:3 aspect ratio, but some support widescreen too.\nYou may select appropriate aspect here and set widescreen mode in game settings->\nIn \"Stretch\" mode the output will be stretched to the entire screen, other modes may add black borders if necessary"; TTSetTxt(IDC_TXT_ASPECT_RATIO, tooltip.c_str()); TTSetTxt(IDC_CMB_ASPECT_RATIO, tooltip.c_str()); m_cmbAspect.Attach(GetDlgItem(IDC_CMB_ASPECT_RATIO)); - m_cmbAspect.SetItemData(m_cmbAspect.AddString("4:3 (default)"), 0); - m_cmbAspect.SetItemData(m_cmbAspect.AddString("Force 16:9"), 1); - m_cmbAspect.SetItemData(m_cmbAspect.AddString("Stretch"), 2); - m_cmbAspect.SetItemData(m_cmbAspect.AddString("Original"), 3); - SetComboBoxIndex(m_cmbAspect, g_settings->aspectmode); + m_cmbAspect.SetItemData(m_cmbAspect.AddString("4:3 (default)"), CSettings::Aspect_4x3); + m_cmbAspect.SetItemData(m_cmbAspect.AddString("Force 16:9"), CSettings::Aspect_16x9); + m_cmbAspect.SetItemData(m_cmbAspect.AddString("Stretch"), CSettings::Aspect_Stretch); + m_cmbAspect.SetItemData(m_cmbAspect.AddString("Original"), CSettings::Aspect_Original); + SetComboBoxIndex(m_cmbAspect, (uint32_t)g_settings->aspectmode()); tooltip = "Fog enabled:\n\nSets fog emulation on//off.\n\n[Recommended: on]"; TTSetTxt(IDC_CHK_FOG, tooltip.c_str()); m_cbxFog.Attach(GetDlgItem(IDC_CHK_FOG)); - m_cbxFog.SetCheck(g_settings->fog > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFog.SetCheck(g_settings->fog() > 0 ? BST_CHECKED : BST_UNCHECKED); tooltip = "Buffer clear on every frame:\n\nForces the frame buffer to be cleared every frame drawn.\nUsually frame buffer clear is controlled by the game.\nHowever, in some cases it is not well emulated, and some garbage may be left on the screen.\nIn such cases, this option must be set on.\n\n[Recommended: on]"; TTSetTxt(IDC_CHK_BUFFER_CLEAR, tooltip.c_str()); m_cbxBuffer.Attach(GetDlgItem(IDC_CHK_BUFFER_CLEAR)); - m_cbxBuffer.SetCheck(g_settings->buff_clear > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxBuffer.SetCheck(g_settings->buff_clear() ? BST_CHECKED : BST_UNCHECKED); m_cbxFBEnable.Attach(GetDlgItem(IDC_CHK_FRAME_BUFFER_EMULATION)); TTSetTxt(IDC_CHK_FRAME_BUFFER_EMULATION, "Enable frame buffer emulation:\n\nIf on, plugin will try to detect frame buffer usage and apply appropriate frame buffer emulation.\n\n[Recommended: on for games which use frame buffer effects]"); - m_cbxFBEnable.SetCheck((g_settings->frame_buffer&fb_emulation) > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFBEnable.SetCheck(g_settings->fb_emulation_enabled() ? BST_CHECKED : BST_UNCHECKED); m_cbxFBHWFBE.Attach(GetDlgItem(IDC_CHK_HARDWARE_FRAMEBUFFER)); TTSetTxt(IDC_CHK_HARDWARE_FRAMEBUFFER, "Enable hardware frame buffer emulation:\n\nIf this option is on, plugin will create auxiliary frame buffers in video memory instead of copying frame buffer content into main memory.\nThis allows plugin to run frame buffer effects without slowdown and without scaling image down to N64's native resolution.\nThis feature is fully supported by Voodoo 4/5 cards and partially by Voodoo3 and Banshee. Modern cards also fully support it.\n\n[Recommended: on, if supported by your hardware]"); - m_cbxFBHWFBE.SetCheck((g_settings->frame_buffer&fb_hwfbe) > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFBHWFBE.SetCheck(g_settings->fb_hwfbe_set() ? BST_CHECKED : BST_UNCHECKED); m_cbxFBGetFBI.Attach(GetDlgItem(IDC_CHK_GET_FRAMEBUFFER)); TTSetTxt(IDC_CHK_GET_FRAMEBUFFER, "Get information about frame buffers:\n\nThis is compatibility option. It must be set on for Mupen64 and off for 1964"); - m_cbxFBGetFBI.SetCheck((g_settings->frame_buffer&fb_get_info) > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFBGetFBI.SetCheck(g_settings->fb_get_info_enabled() ? BST_CHECKED : BST_UNCHECKED); m_cbxFBReadEveryFrame.Attach(GetDlgItem(IDC_CHK_READ_EVERY_FRAME)); TTSetTxt(IDC_CHK_READ_EVERY_FRAME, "Read every frame:\n\nIn some games plugin can't detect frame buffer usage.\nIn such cases you need to enable this option to see frame buffer effects.\nEvery drawn frame will be read from video card -> it works very slow.\n\n[Recommended: mostly off (needed only for a few games)]"); - m_cbxFBReadEveryFrame.SetCheck((g_settings->frame_buffer&fb_ref) > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFBReadEveryFrame.SetCheck(g_settings->fb_ref_enabled() ? BST_CHECKED : BST_UNCHECKED); m_cbxFBasTex.Attach(GetDlgItem(IDC_RENDER_FRAME_AS_TEXTURE)); TTSetTxt(IDC_RENDER_FRAME_AS_TEXTURE, "Render N64 frame buffer as texture:\n\nWhen this option is enabled, content of each N64 frame buffer is rendered as texture over the frame, rendered by the plugin.\nThis prevents graphics lost, but may cause slowdowns and various glitches in some games.\n\n[Recommended: mostly off]"); - m_cbxFBasTex.SetCheck((g_settings->frame_buffer&fb_read_back_to_screen) > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFBasTex.SetCheck(g_settings->fb_read_back_to_screen_enabled() ? BST_CHECKED : BST_UNCHECKED); m_cbxDetect.Attach(GetDlgItem(IDC_CHK_DETECT_CPU_WRITE)); TTSetTxt(IDC_CHK_DETECT_CPU_WRITE, "Detect CPU write to the N64 frame buffer:\n\nThis option works as the previous options, but the plugin is trying to detect, when game uses CPU writes to N64 frame buffer.\nThe N64 frame buffer is rendered only when CPU writes is detected.\nUse this option for those games, in which you see still image or no image at all for some time with no reason.\n\n[Recommended: mostly off]"); - m_cbxDetect.SetCheck((g_settings->frame_buffer&fb_cpu_write_hack) > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxDetect.SetCheck(g_settings->fb_cpu_write_hack_enabled() ? BST_CHECKED : BST_UNCHECKED); m_cbxFBDepthBuffer.Attach(GetDlgItem(IDC_SOFTWARE_DEPTH_BUFFER)); TTSetTxt(IDC_SOFTWARE_DEPTH_BUFFER, "Enable depth buffer rendering:\n\nThis option is used to fully emulate N64 depth buffer.\nIt is required for correct emulation of depth buffer based effects.\nHowever, it requires fast (>1GHz) CPU to work full speed.\n\n[Recommended: on for fast PC]"); - m_cbxFBDepthBuffer.SetCheck((g_settings->frame_buffer&fb_depth_render) > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxFBDepthBuffer.SetCheck(g_settings->fb_depth_render_enabled() ? BST_CHECKED : BST_UNCHECKED); return TRUE; } @@ -590,30 +502,44 @@ public: { CSettings oldsettings = *g_settings; - g_settings->filtering = m_cmbFiltering.GetItemData(m_cmbFiltering.GetCurSel()); - g_settings->aspectmode = m_cmbAspect.GetItemData(m_cmbAspect.GetCurSel()); - g_settings->swapmode = m_cmbBufferSwap.GetItemData(m_cmbBufferSwap.GetCurSel()); - g_settings->fog = m_cbxFog.GetCheck() == BST_CHECKED; - g_settings->buff_clear = m_cbxBuffer.GetCheck() == BST_CHECKED; - g_settings->lodmode = m_cmbLOD.GetItemData(m_cmbLOD.GetCurSel()); + g_settings->SetFiltering((CSettings::Filtering_t)m_cmbFiltering.GetItemData(m_cmbFiltering.GetCurSel())); + g_settings->SetAspectmode((CSettings::AspectMode_t)m_cmbAspect.GetItemData(m_cmbAspect.GetCurSel())); + g_settings->SetSwapMode((CSettings::SwapMode_t)m_cmbBufferSwap.GetItemData(m_cmbBufferSwap.GetCurSel())); + g_settings->SetFog(m_cbxFog.GetCheck() == BST_CHECKED); + g_settings->SetBuffClear(m_cbxBuffer.GetCheck() == BST_CHECKED); + g_settings->SetLODmode((CSettings::PixelLevelOfDetail_t)m_cmbLOD.GetItemData(m_cmbLOD.GetCurSel())); - if (m_cbxFBEnable.GetCheck() == BST_CHECKED) g_settings->frame_buffer |= fb_emulation; - else g_settings->frame_buffer &= ~fb_emulation; - if (m_cbxFBHWFBE.GetCheck() == BST_CHECKED) g_settings->frame_buffer |= fb_hwfbe; - else g_settings->frame_buffer &= ~fb_hwfbe; - if (m_cbxFBReadEveryFrame.GetCheck() == BST_CHECKED) g_settings->frame_buffer |= fb_ref; - else g_settings->frame_buffer &= ~fb_ref; - if (m_cbxFBasTex.GetCheck() == BST_CHECKED) g_settings->frame_buffer |= fb_read_back_to_screen; - else g_settings->frame_buffer &= ~fb_read_back_to_screen; - if (m_cbxDetect.GetCheck() == BST_CHECKED) g_settings->frame_buffer |= fb_cpu_write_hack; - else g_settings->frame_buffer &= ~fb_cpu_write_hack; - if (m_cbxFBGetFBI.GetCheck() == BST_CHECKED) g_settings->frame_buffer |= fb_get_info; - else g_settings->frame_buffer &= ~fb_get_info; - if (m_cbxFBDepthBuffer.GetCheck() == BST_CHECKED) g_settings->frame_buffer |= fb_depth_render; - else g_settings->frame_buffer &= ~fb_depth_render; + CButton * fb_buttons[] = + { + &m_cbxFBEnable, &m_cbxFBHWFBE, &m_cbxFBReadEveryFrame, + &m_cbxFBasTex, &m_cbxDetect, + &m_cbxFBGetFBI, &m_cbxFBDepthBuffer + }; + + CSettings::fb_bits_t bits[] = + { + CSettings::fb_emulation, CSettings::fb_hwfbe, CSettings::fb_ref, + CSettings::fb_read_back_to_screen, CSettings::fb_cpu_write_hack, + CSettings::fb_get_info, CSettings::fb_depth_render + }; + + uint32_t fb_add_bits = 0, fb_remove_bits = 0; + for (int i = 0; i < (sizeof(fb_buttons) / sizeof(fb_buttons[0])); i++) + { + if (fb_buttons[i]->GetCheck() == BST_CHECKED) + { + fb_add_bits |= bits[i]; + } + else + { + fb_remove_bits |= bits[i]; + } + } + + g_settings->UpdateFrameBufferBits(fb_add_bits, fb_remove_bits); if (memcmp(&oldsettings, g_settings, sizeof(oldsettings))) //check that settings were changed { - WriteSettings(); + g_settings->WriteSettings(); } return true; } @@ -660,100 +586,99 @@ public: TTSetTxt(IDC_TXT_ENH_FILTER, tooltip.c_str()); TTSetTxt(IDC_CMB_ENH_FILTER, tooltip.c_str()); m_cmbEnhFilter.Attach(GetDlgItem(IDC_CMB_ENH_FILTER)); - m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("None"), 0); - m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Smooth filtering 1"), 1); - m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Smooth filtering 2"), 2); - m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Smooth filtering 3"), 3); - m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Smooth filtering 4"), 4); - m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Sharp filtering 1"), 5); - m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Sharp filtering 2"), 6); - SetComboBoxIndex(m_cmbEnhFilter, g_settings->ghq_fltr); + m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("None"), CSettings::TextureFilter_None); + m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Smooth filtering 1"), CSettings::TextureFilter_SmoothFiltering); + m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Smooth filtering 2"), CSettings::TextureFilter_SmoothFiltering2); + m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Smooth filtering 3"), CSettings::TextureFilter_SmoothFiltering3); + m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Smooth filtering 4"), CSettings::TextureFilter_SmoothFiltering4); + m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Sharp filtering 1"), CSettings::TextureFilter_SharpFiltering1); + m_cmbEnhFilter.SetItemData(m_cmbEnhFilter.AddString("Sharp filtering 2"), CSettings::TextureFilter_SharpFiltering2); + SetComboBoxIndex(m_cmbEnhFilter, g_settings->ghq_fltr()); tooltip = "Texture enhancement:\n\n7 different filters are selectable here, each one with a distinctive look.\nBe aware of possible performance impacts.\n\nIMPORTANT: 'Store' mode - saves textures in cache 'as is'.\nIt can improve performance in games, which load many textures.\nDisable 'Ignore backgrounds' option for better result.\n\n[Recommended: your preference]"; TTSetTxt(IDC_TXT_ENHANCEMENT, tooltip.c_str()); TTSetTxt(IDC_CMB_ENHANCEMENT, tooltip.c_str()); m_cmbEnhEnhancement.Attach(GetDlgItem(IDC_CMB_ENHANCEMENT)); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("None"), 0); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("Store"), 1); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("X2"), 2); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("X2SAI"), 3); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("HQ2X"), 4); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("HQ2XS"), 5); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("LQ2X"), 6); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("LQ2XS"), 7); - m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("HQ4X"), 8); - SetComboBoxIndex(m_cmbEnhEnhancement, g_settings->ghq_enht); + m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("None"), CSettings::TextureEnht_None); + m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("X2"), CSettings::TextureEnht_X2); + m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("X2SAI"), CSettings::TextureEnht_X2SAI); + m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("HQ2X"), CSettings::TextureEnht_HQ2X); + m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("HQ2XS"), CSettings::TextureEnht_HQ2XS); + m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("LQ2X"), CSettings::TextureEnht_LQ2X); + m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("LQ2XS"), CSettings::TextureEnht_LQ2XS); + m_cmbEnhEnhancement.SetItemData(m_cmbEnhEnhancement.AddString("HQ4X"), CSettings::TextureEnht_HQ4X); + SetComboBoxIndex(m_cmbEnhEnhancement, g_settings->ghq_enht()); tooltip = "Hi-res pack format:\n\nChoose which method is to be used for loading Hi-res texture packs.\nOnly Rice's format is available currently.\nLeave on \"None\" if you will not be needing to load hi-res packs.\n\n[Recommended: Rice's format. Default: \"None\"]"; TTSetTxt(IDC_TXT_FORMAT_CHOICES, tooltip.c_str()); TTSetTxt(IDC_CMB_FORMAT_CHOICES, tooltip.c_str()); m_cmbHrsFormat.Attach(GetDlgItem(IDC_CMB_FORMAT_CHOICES)); - m_cmbHrsFormat.SetItemData(m_cmbHrsFormat.AddString("None"), 0); - m_cmbHrsFormat.SetItemData(m_cmbHrsFormat.AddString("Rice format"), 1); - SetComboBoxIndex(m_cmbHrsFormat, g_settings->ghq_hirs); + m_cmbHrsFormat.SetItemData(m_cmbHrsFormat.AddString("None"), CSettings::HiResPackFormat_None); + m_cmbHrsFormat.SetItemData(m_cmbHrsFormat.AddString("Rice format"), CSettings::HiResPackFormat_Riceformat); + SetComboBoxIndex(m_cmbHrsFormat, g_settings->ghq_hirs()); m_cmbTextureCompression.Attach(GetDlgItem(IDC_CMB_TEX_COMPRESS_MEHTOD)); - m_cmbTextureCompression.SetItemData(m_cmbTextureCompression.AddString("S3TC"), 0); - m_cmbTextureCompression.SetItemData(m_cmbTextureCompression.AddString("FXT1"), 1); - SetComboBoxIndex(m_cmbTextureCompression, g_settings->ghq_cmpr); + m_cmbTextureCompression.SetItemData(m_cmbTextureCompression.AddString("S3TC"), CSettings::TextureCompression_S3TC); + m_cmbTextureCompression.SetItemData(m_cmbTextureCompression.AddString("FXT1"), CSettings::TextureCompression_FXT1); + SetComboBoxIndex(m_cmbTextureCompression, g_settings->ghq_cmpr()); tooltip = "Texture cache size:\n\nEnhanced and filtered textures can be cached to aid performance.\nThis setting will adjust how much PC memory will be dedicated for texture cache.\nThis helps boost performance if there are subsequent requests for the same texture (usually the case).\nNormally, 128MB should be more than enough but there is a sweet spot for each game.\nSuper Mario may not need more than 32megs, but Conker streams a lot of textures, so setting 256+ megs can boost performance.\nAdjust accordingly if you are encountering speed issues.\n'0' disables cache.\n\n[Recommended: PC and game dependant]"; TTSetTxt(IDC_TXT_TEXTURE_CACHE, tooltip.c_str()); TTSetTxt(IDC_SPIN_TEXTURE_CACHE, tooltip.c_str()); TTSetTxt(IDC_TEXT_MB, tooltip.c_str()); m_textTexCache.Attach(GetDlgItem(IDC_TXT_TEXTURE_CACHE)); - m_textTexCache.SetWindowTextA(stdstr_f("%d", g_settings->ghq_cache_size).c_str()); + m_textTexCache.SetWindowTextA(stdstr_f("%d", g_settings->ghq_cache_size()).c_str()); m_spinEnhCacheSize.Attach(GetDlgItem(IDC_SPIN_TEXTURE_CACHE)); m_spinEnhCacheSize.SetBuddy(m_textTexCache); TTSetTxt(IDC_CHK_IGNORE_BACKGROUND, "Ignore Backgrounds:\n\nIt is used to skip enhancement for long narrow textures, usually used for backgrounds.\nThis may save texture memory greatly and increase performance.\n\n[Recommended: on (off for 'Store' mode)]"); m_cbxEnhIgnoreBG.Attach(GetDlgItem(IDC_CHK_IGNORE_BACKGROUND)); - m_cbxEnhIgnoreBG.SetCheck(g_settings->ghq_enht_nobg > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxEnhIgnoreBG.SetCheck(g_settings->ghq_enht_nobg() > 0 ? BST_CHECKED : BST_UNCHECKED); tooltip = "Texture compression:\n\nTextures will be compressed using selected texture compression method.\nThe overall compression ratio is about 1/6 for FXT1 and 1/4 for S3TC.\nIn addition to saving space on the texture cache, the space occupied on the GFX hardware's texture RAM, by the enhanced textures, will be greatly reduced.\nThis minimizes texture RAM usage, decreasing the number of texture swaps to the GFX hardware leading to performance gains.\nHowever, due to the nature of lossy compression of FXT1 and S3TC, using this option can sometimes lead to quality degradation of small size textures and color banding of gradient colored textures.\n\n[Recommended: off]"; TTSetTxt(IDC_CHK_TEX_COMPRESSION, tooltip.c_str()); TTSetTxt(IDC_CHK_HIRES_TEX_COMPRESSION, tooltip.c_str()); m_cbxEnhTexCompression.Attach(GetDlgItem(IDC_CHK_TEX_COMPRESSION)); - m_cbxEnhTexCompression.SetCheck(g_settings->ghq_enht_cmpr > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxEnhTexCompression.SetCheck(g_settings->ghq_enht_cmpr() > 0 ? BST_CHECKED : BST_UNCHECKED); m_cbxHrsTexCompression.Attach(GetDlgItem(IDC_CHK_HIRES_TEX_COMPRESSION)); - m_cbxHrsTexCompression.SetCheck(g_settings->ghq_hirs_cmpr > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxHrsTexCompression.SetCheck(g_settings->ghq_hirs_cmpr() ? BST_CHECKED : BST_UNCHECKED); TTSetTxt(IDC_CHK_COMPRESS_CACHE, "Compress texture cache:\n\nMemory will be compressed so that more textures can be held in the texture cache.\nThe compression ratio varies with each texture, but 1/5 of the original size would be a modest approximation.\nThey will be decompressed on-the-fly, before being downloaded to the gfx hardware.\nThis option will still help save memory space even when using texture compression.\n\n[Recommended: on]"); m_cbxEnhCompressCache.Attach(GetDlgItem(IDC_CHK_COMPRESS_CACHE)); - m_cbxEnhCompressCache.SetCheck(g_settings->ghq_enht_gz > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxEnhCompressCache.SetCheck(g_settings->ghq_enht_gz() > 0 ? BST_CHECKED : BST_UNCHECKED); m_cbxHrsTile.Attach(GetDlgItem(IDC_CHK_TILE_TEX)); TTSetTxt(IDC_CHK_TILE_TEX, "Tile textures:\n\nWhen on, wide texture will be split on several tiles to fit in one 256-width texture.\nThis tiled texture takes much less video memory space and thus overall performance will increase.\nHowever, corresponding polygons must be split too, and this is not polished yet - various issues are possible, including black lines and polygons distortions.\n\n[Recommended: off]"); - m_cbxHrsTile.SetCheck(g_settings->ghq_hirs_tile > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxHrsTile.SetCheck(g_settings->ghq_hirs_tile() ? BST_CHECKED : BST_UNCHECKED); m_cbxHrsForce16.Attach(GetDlgItem(IDC_CHK_FORCE_16BPP_TEXT)); TTSetTxt(IDC_CHK_FORCE_16BPP_TEXT, "Force 16bpp textures:\n\nThe color of the textures will be reduced to 16bpp.\nThis is another space saver and performance enhancer.\nThis halves the space used on the texture cache and the GFX hardware's texture RAM.\nColor reduction is done so that the original quality is preserved as much as possible.\nDepending on the texture, this usually is hardly noticeable.\nSometimes though, it can be: skies are a good example.\n\n[Recommended: off]"); - m_cbxHrsForce16.SetCheck(g_settings->ghq_hirs_tile > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxHrsForce16.SetCheck(g_settings->ghq_hirs_f16bpp() > 0 ? BST_CHECKED : BST_UNCHECKED); m_cbxHrsTexEdit.Attach(GetDlgItem(IDC_CHK_TEX_DUMP_EDIT)); TTSetTxt(IDC_CHK_TEX_DUMP_EDIT, "Texture dumping mode:\n\nIn this mode, you have that ability to dump textures on screen to the appropriate folder.\nYou can also reload textures while the game is running to see how they look instantly - big time saver!\n\nHotkeys:\n\"R\" reloads hires textures from the texture pack\n\"D\" toggles texture dumps on/off."); - m_cbxHrsTexEdit.SetCheck(g_settings->ghq_hirs_dump > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxHrsTexEdit.SetCheck(g_settings->ghq_hirs_dump() > 0 ? BST_CHECKED : BST_UNCHECKED); m_cbxHrsAltCRC.Attach(GetDlgItem(IDC_CHK_ALT_CRC)); TTSetTxt(IDC_CHK_ALT_CRC, "Alternative CRC calculation:\n\nThis option enables emulation of a palette CRC calculation bug in RiceVideo.\nIf some textures are not loaded, try to set this option on/off.\n\n[Recommended: texture pack dependant, mostly on]"); - m_cbxHrsAltCRC.SetCheck(g_settings->ghq_hirs_altcrc > 0 ? BST_CHECKED : BST_UNCHECKED); - if (g_settings->ghq_hirs_dump) + m_cbxHrsAltCRC.SetCheck(g_settings->ghq_hirs_altcrc() > 0 ? BST_CHECKED : BST_UNCHECKED); + if (g_settings->ghq_hirs_dump()) { m_cbxHrsAltCRC.EnableWindow(false); } m_cbxHrsCompressCache.Attach(GetDlgItem(IDC_CHK_HRS_COMPRESS_CACHE)); TTSetTxt(IDC_CHK_HRS_COMPRESS_CACHE, "Compress texture cache:\n\nWhen game started, plugin loads all its hi-resolution textures into PC memory.\nSince hi-resolution textures are usually large, the whole pack can take hundreds megabytes of memory.\nCache compression allows save memory space greatly.\nTextures will be decompressed on-the-fly, before being downloaded to the gfx hardware.\nThis option will still help save memory space even when using texture compression.\n\n[Recommended: on]"); - m_cbxHrsCompressCache.SetCheck(g_settings->ghq_hirs_gz > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxHrsCompressCache.SetCheck(g_settings->ghq_hirs_gz() > 0 ? BST_CHECKED : BST_UNCHECKED); m_cbxHrsLetFly.Attach(GetDlgItem(IDC_CHK_USE_ALPHA_FULLY)); TTSetTxt(IDC_CHK_USE_ALPHA_FULLY, "Use Alpha channel fully:\n\nWhen this option is off, 16bit rgba textures will be loaded using RiceVideo style, with 1bit for alpha channel.\nWhen it is on, GlideHQ will check, how alpha channel is used by the hires texture, and select most appropriate format for it.\nThis gives texture designers freedom to play with alpha, as they need, regardless of format of original N64 texture.\nFor older and badly designed texture packs it can cause unwanted black borders.\n\n[Recommended: texture pack dependant]"); - m_cbxHrsLetFly.SetCheck(g_settings->ghq_hirs_let_texartists_fly > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxHrsLetFly.SetCheck(g_settings->ghq_hirs_let_texartists_fly() > 0 ? BST_CHECKED : BST_UNCHECKED); m_cbxSaveTexCache.Attach(GetDlgItem(IDC_CHK_TEX_CACHE_HD)); TTSetTxt(IDC_CHK_TEX_CACHE_HD, "Save texture cache to HD:\n\nFor enhanced textures cache:\nThis will save all previously loaded and enhanced textures to HD.\nSo upon next game launch, all the textures will be instantly loaded, resulting in smoother performance.\n\nFor high-resolution textures cache:\nAfter creation, loading hi-res texture will take only a few seconds upon game launch, as opposed to the 5 to 60 seconds a pack can take to load without this cache file.\nThe only downside here is upon any changes to the pack, the cache file will need to be manually deleted.\n\nSaved cache files go into a folder called \"Cache\" within the Textures folder.\n\n[Highly Recommended: on]"); - m_cbxSaveTexCache.SetCheck(g_settings->ghq_cache_save > 0 ? BST_CHECKED : BST_UNCHECKED); + m_cbxSaveTexCache.SetCheck(g_settings->ghq_cache_save() > 0 ? BST_CHECKED : BST_UNCHECKED); return TRUE; } @@ -763,25 +688,25 @@ public: m_textTexCache.GetWindowText(texcache, sizeof(texcache)); CSettings oldsettings = *g_settings; - g_settings->ghq_fltr = m_cmbEnhFilter.GetItemData(m_cmbEnhFilter.GetCurSel()); - g_settings->ghq_enht = m_cmbEnhEnhancement.GetItemData(m_cmbEnhEnhancement.GetCurSel()); - g_settings->ghq_cache_size = atoi(texcache); - g_settings->ghq_enht_nobg = (int)m_cbxEnhIgnoreBG.GetCheck() == BST_CHECKED; - g_settings->ghq_enht_cmpr = (int)m_cbxEnhTexCompression.GetCheck() == BST_CHECKED; - g_settings->ghq_enht_gz = (int)m_cbxEnhCompressCache.GetCheck() == BST_CHECKED; - g_settings->ghq_hirs = m_cmbHrsFormat.GetItemData(m_cmbHrsFormat.GetCurSel()); - g_settings->ghq_hirs_tile = (int)m_cbxHrsTile.GetCheck() == BST_CHECKED; - g_settings->ghq_hirs_f16bpp = (int)m_cbxHrsForce16.GetCheck() == BST_CHECKED; - g_settings->ghq_hirs_dump = (int)m_cbxHrsTexEdit.GetCheck() == BST_CHECKED; - g_settings->ghq_hirs_altcrc = (int)m_cbxHrsAltCRC.GetCheck() == BST_CHECKED; - g_settings->ghq_hirs_cmpr = (int)m_cbxHrsTexCompression.GetCheck() == BST_CHECKED; - g_settings->ghq_hirs_gz = (int)m_cbxHrsCompressCache.GetCheck() == BST_CHECKED; - g_settings->ghq_hirs_let_texartists_fly = (int)m_cbxHrsLetFly.GetCheck() == BST_CHECKED; - g_settings->ghq_cmpr = (int)m_cmbTextureCompression.GetItemData(m_cmbTextureCompression.GetCurSel()); - g_settings->ghq_cache_save = (int)m_cbxSaveTexCache.GetCheck() == BST_CHECKED; + g_settings->SetGhqFltr((CSettings::TextureFilter_t)m_cmbEnhFilter.GetItemData(m_cmbEnhFilter.GetCurSel())); + g_settings->SetGhqEnht((CSettings::TextureEnhancement_t)m_cmbEnhEnhancement.GetItemData(m_cmbEnhEnhancement.GetCurSel())); + g_settings->SetGhqCacheSize(atoi(texcache)); + g_settings->SetGhqEnhtNobg(m_cbxEnhIgnoreBG.GetCheck() == BST_CHECKED); + g_settings->SetGhqEnhtCmpr(m_cbxEnhTexCompression.GetCheck() == BST_CHECKED); + g_settings->SetGhqEnhtGz(m_cbxEnhCompressCache.GetCheck() == BST_CHECKED); + g_settings->SetGhqHirs((CSettings::HiResPackFormat_t)m_cmbHrsFormat.GetItemData(m_cmbHrsFormat.GetCurSel())); + g_settings->SetGhqHirsTile(m_cbxHrsTile.GetCheck() == BST_CHECKED); + g_settings->SetGhqHirsF16bpp(m_cbxHrsForce16.GetCheck() == BST_CHECKED); + g_settings->SetGhqHirsDump(m_cbxHrsTexEdit.GetCheck() == BST_CHECKED); + g_settings->SetGhqHirsAltcrc(m_cbxHrsAltCRC.GetCheck() == BST_CHECKED); + g_settings->SetGhqHirsCmpr(m_cbxHrsTexCompression.GetCheck() == BST_CHECKED); + g_settings->SetGhqHirsGz(m_cbxHrsCompressCache.GetCheck() == BST_CHECKED); + g_settings->SetGhqHirsLetTexartistsFly(m_cbxHrsLetFly.GetCheck() == BST_CHECKED); + g_settings->SetGhqCmpr((CSettings::TextureCompression_t)m_cmbTextureCompression.GetItemData(m_cmbTextureCompression.GetCurSel())); + g_settings->SetGhqCacheSave(m_cbxSaveTexCache.GetCheck() == BST_CHECKED); if (memcmp(&oldsettings, g_settings, sizeof(oldsettings))) //check that settings were changed { - WriteSettings(); + g_settings->WriteSettings(); } return true; } @@ -817,7 +742,7 @@ COptionsSheet::COptionsSheet(_U_STRINGorID /*title*/, UINT /*uStartPage*/, HWND m_hTextureEnhancement(0) { AddPage(&m_pgBasicPage->m_psp); - if (g_settings->advanced_options) + if (g_settings->advanced_options()) { AddPage(&m_pgEmuSettings->m_psp); } @@ -833,7 +758,7 @@ COptionsSheet::~COptionsSheet() void COptionsSheet::UpdateTextureSettings(void) { - if (g_settings->texenh_options) + if (g_settings->texenh_options()) { if (m_hTextureEnhancement == NULL) { @@ -864,7 +789,6 @@ void CALL DllConfig(HWND hParent) WriteTrace(TraceGlide64, TraceDebug, "-"); #ifdef _WIN32 CGuard guard(*g_ProcessDListCS); - ReadSettings(); if (g_romopen) { @@ -873,18 +797,17 @@ void CALL DllConfig(HWND hParent) ReleaseGfx(); rdp_reset(); } -#ifdef TEXTURE_FILTER // Hiroshi Morii - if (g_settings->ghq_use) + if (g_ghq_use) { ext_ghq_shutdown(); - g_settings->ghq_use = 0; + g_ghq_use = false; } -#endif } else { char name[21] = "DEFAULT"; - ReadSpecialSettings(name); + g_settings->ReadGameSettings(name); + ZLUT_init(); } COptionsSheet("Glide64 settings").DoModal(hParent); @@ -896,8 +819,10 @@ void CloseConfig() { if (g_romopen) { - if (fb_depth_render_enabled) + if (g_settings->fb_depth_render_enabled()) + { ZLUT_init(); + } // re-init evoodoo graphics to resize window if (evoodoo)// && !ev_fullscreen) InitGfx(); @@ -947,18 +872,3 @@ void CALL DllAbout(HWND /*hParent*/) dlg.DoModal(); #endif } - -void general_setting(short setting_ID, const char * name, unsigned int value) -{ - RegisterSetting(setting_ID, Data_DWORD_General, name, NULL, value, NULL); -} - -void game_setting(short setting_ID, const char * name, unsigned int value) -{ - RegisterSetting(setting_ID, Data_DWORD_Game, name, NULL, value, NULL); -} - -void game_setting_default(short setting_ID, const char * name, short default_setting) -{ - RegisterSetting2(setting_ID, Data_DWORD_Game, name, NULL, default_setting); -} diff --git a/Source/Glide64/Config.h b/Source/Glide64/Config.h index c48d16a23..5a32f87a4 100644 --- a/Source/Glide64/Config.h +++ b/Source/Glide64/Config.h @@ -47,49 +47,3 @@ void ConfigInit(HINSTANCE hinst); void ConfigCleanup(void); #endif - -enum -{ - // General Settings - Set_CardId, Set_vsync, Set_ssformat, Set_clock, - Set_clock_24_hr, Set_Rotate, Set_texenh_options, Set_hotkeys, Set_wrpVRAM, - Set_wrpFBO, Set_wrpAnisotropic, Set_autodetect_ucode, Set_ucode, Set_wireframe, - Set_wfmode, Set_logging, Set_log_clear, Set_elogging, Set_run_in_window, - Set_filter_cache, Set_unk_as_red, Set_log_unk, Set_unk_clear, Set_ghq_fltr, - Set_ghq_cmpr, Set_ghq_enht, Set_ghq_hirs, Set_ghq_enht_cmpr, Set_ghq_enht_tile, - Set_ghq_enht_f16bpp, Set_ghq_enht_gz, Set_ghq_enht_nobg, Set_ghq_hirs_cmpr, - Set_ghq_hirs_tile, Set_ghq_hirs_f16bpp, Set_ghq_hirs_gz, Set_ghq_hirs_altcrc, - Set_ghq_cache_save, Set_ghq_cache_size, Set_ghq_hirs_let_texartists_fly, - Set_ghq_hirs_dump, - -#ifndef ANDROID - Set_Resolution, Set_wrpResolution, -#endif - - // Default Game Settings - Set_optimize_texrect_default, Set_filtering_default, Set_lodmode_default, - Set_fog_default, Set_buff_clear_default, Set_swapmode_default, - Set_aspect_default, Set_fb_smart_default, Set_fb_hires_default, - Set_fb_read_always_default, Set_read_back_to_screen_default, Set_detect_cpu_write_default, - Set_fb_get_info_default, Set_fb_render_default, - - //Game Settings - Set_alt_tex_size, Set_use_sts1_only, Set_force_calc_sphere, Set_correct_viewport, - Set_increase_texrect_edge, Set_decrease_fillrect_edge, Set_texture_correction, - Set_pal230, Set_stipple_mode, Set_stipple_pattern, Set_force_microcheck, Set_force_quad3d, - Set_clip_zmin, Set_clip_zmax, Set_fast_crc, Set_adjust_aspect, Set_zmode_compare_less, - Set_old_style_adither, Set_n64_z_scale, Set_optimize_texrect, Set_ignore_aux_copy, - Set_hires_buf_clear, Set_fb_read_alpha, Set_useless_is_useless, Set_fb_crc_mode, - Set_filtering, Set_fog, Set_buff_clear, Set_swapmode, Set_aspect, Set_lodmode, - Set_fb_smart, Set_fb_hires, Set_fb_read_always, Set_read_back_to_screen, - Set_detect_cpu_write, Set_fb_get_info, Set_fb_render, - - //RDB Setting - Set_ucodeLookup, -}; - -extern short Set_basic_mode, Set_texture_dir, Set_log_dir, Set_log_flush; - -extern void general_setting(short setting_ID, const char * name, unsigned int value); -extern void game_setting(short setting_ID, const char * name, unsigned int value); -extern void game_setting_default(short setting_ID, const char * name, short default_setting); diff --git a/Source/Glide64/Debugger.cpp b/Source/Glide64/Debugger.cpp index 7e24ed8a7..354630451 100644 --- a/Source/Glide64/Debugger.cpp +++ b/Source/Glide64/Debugger.cpp @@ -44,938 +44,9 @@ #include "Util.h" #include "Debugger.h" -GLIDE64_DEBUGGER _debugger; - #define SX(x) ((x)*rdp.scale_1024) #define SY(x) ((x)*rdp.scale_768) -#ifdef COLORED_DEBUGGER -#define COL_CATEGORY() grConstantColorValue(0xD288F400) -#define COL_UCC() grConstantColorValue(0xFF000000) -#define COL_CC() grConstantColorValue(0x88C3F400) -#define COL_UAC() grConstantColorValue(0xFF808000) -#define COL_AC() grConstantColorValue(0x3CEE5E00) -#define COL_TEXT() grConstantColorValue(0xFFFFFF00) -#define COL_SEL(x) grConstantColorValue((x)?0x00FF00FF:0x800000FF) -#else -#define COL_CATEGORY() -#define COL_UCC() -#define COL_CC() -#define COL_UAC() -#define COL_AC() -#define COL_TEXT() -#define COL_SEL(x) -#endif - -#define COL_GRID 0xFFFFFF80 - -int grid = 0; -static const char *tri_type[4] = { "TRIANGLE", "TEXRECT", "FILLRECT", "BACKGROUND" }; - -//Platform-specific stuff -#ifndef _WIN32 -typedef struct dbgPOINT { - int x; - int y; -} POINT; -#endif -void DbgCursorPos(POINT * pt) -{ - pt->x = pt->y = 0; -} - -// -// debug_init - initialize the debugger -// - -void debug_init () -{ - _debugger.capture = 0; - _debugger.selected = SELECTED_TRI; - _debugger.screen = NULL; - _debugger.tri_list = NULL; - _debugger.tri_last = NULL; - _debugger.tri_sel = NULL; - _debugger.tmu = 0; - - _debugger.tex_scroll = 0; - _debugger.tex_sel = 0; - - _debugger.draw_mode = 0; -} - -// -// debug_cacheviewer - views the debugger's cache -// - -void debug_cacheviewer () -{ - grCullMode (GR_CULL_DISABLE); - - int i; - for (i=0; i<2; i++) - { - grTexFilterMode (i, - (g_settings->filter_cache)?GR_TEXTUREFILTER_BILINEAR:GR_TEXTUREFILTER_POINT_SAMPLED, - (g_settings->filter_cache)?GR_TEXTUREFILTER_BILINEAR:GR_TEXTUREFILTER_POINT_SAMPLED); - grTexClampMode (i, - GR_TEXTURECLAMP_CLAMP, - GR_TEXTURECLAMP_CLAMP); - } - - switch (_debugger.draw_mode) - { - case 0: - grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_NONE, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_NONE, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - break; - case 1: - grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_NONE, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - grAlphaCombine (GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_LOCAL_CONSTANT, - GR_COMBINE_OTHER_NONE, - FXFALSE); - grConstantColorValue (0xFFFFFFFF); - break; - case 2: - grColorCombine (GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_LOCAL_CONSTANT, - GR_COMBINE_OTHER_NONE, - FXFALSE); - grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_NONE, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - grConstantColorValue (0xFFFFFFFF); - } - - if (_debugger.tmu == 1) - { - grTexCombine (GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE, - FXFALSE); - - grTexCombine (GR_TMU0, - GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - FXFALSE, - FXFALSE); - } - else - { - grTexCombine (GR_TMU0, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE, - FXFALSE); - } - - grAlphaBlendFunction (GR_BLEND_SRC_ALPHA, - GR_BLEND_ONE_MINUS_SRC_ALPHA, - GR_BLEND_ONE, - GR_BLEND_ZERO); - - // Draw texture memory - for (i=0; i<4; i++) - { - for (uint32_t x=0; x<16; x++) - { - uint32_t y = i+_debugger.tex_scroll; - if (x+y*16 >= (uint32_t)rdp.n_cached[_debugger.tmu]) break; - CACHE_LUT * cache = voodoo.tex_UMA?rdp.cache[0]:rdp.cache[_debugger.tmu]; - - VERTEX v[4] = { - { SX(x*64.0f), SY(512+64.0f*i), 1, 1, 0, 0, 0, 0, {0, 0, 0, 0} }, - { SX(x*64.0f+64.0f*cache[x+y*16].scale_x), SY(512+64.0f*i), 1, 1, 255*cache[x+y*16].scale_x, 0, 0, 0, {0, 0, 0, 0} }, - { SX(x*64.0f), SY(512+64.0f*i+64.0f*cache[x+y*16].scale_y), 1, 1, 0, 255*cache[x+y*16].scale_y, 0, 0, {0, 0, 0, 0} }, - { SX(x*64.0f+64.0f*cache[x+y*16].scale_x), SY(512+64.0f*i+64.0f*cache[x+y*16].scale_y), 1, 1, 255*cache[x+y*16].scale_x, 255*cache[x+y*16].scale_y, 0, 0, {0, 0, 0, 0} } - }; - for - (int i=0; i<4; i++) - { - v[i].u1 = v[i].u0; - v[i].v1 = v[i].v0; - } - - ConvertCoordsConvert (v, 4); - - grTexSource(_debugger.tmu, - voodoo.tex_min_addr[_debugger.tmu] + cache[x+y*16].tmem_addr, - GR_MIPMAPLEVELMASK_BOTH, - &cache[x+y*16].t_info); - - grDrawTriangle (&v[2], &v[1], &v[0]); - grDrawTriangle (&v[2], &v[3], &v[1]); - } - } - -} - -// -// debug_capture - does a frame capture event (for debugging) -// - -void debug_capture () -{ - uint32_t i,j; - - if (_debugger.tri_list == NULL) goto END; - _debugger.tri_sel = _debugger.tri_list; - _debugger.selected = SELECTED_TRI; - - // Connect the list - _debugger.tri_last->pNext = _debugger.tri_list; - - while (!CheckKeyPressed(G64_VK_INSERT, 0x0001)) //INSERT - { - // Check for clicks - if (CheckKeyPressed(G64_VK_LBUTTON, 0x0001)) //LBUTTON - { - POINT pt; - DbgCursorPos(&pt); - - //int diff = g_settings->scr_res_y-g_settings->res_y; - - if (pt.y <= (int)g_settings->res_y) - { - int x = pt.x; - int y = pt.y;//g_settings->res_y - (pt.y - diff); - - TRI_INFO *start; - TRI_INFO *tri; - if (_debugger.tri_sel == NULL) tri = _debugger.tri_list, start = _debugger.tri_list; - else tri = _debugger.tri_sel->pNext, start = _debugger.tri_sel; - - // Select a triangle (start from the currently selected one) - do { - if (tri->v[0].x == tri->v[1].x && - tri->v[0].y == tri->v[1].y) - { - tri = tri->pNext; - continue; - } - - for (i=0; inv; i++) - { - j=i+1; - if (j==tri->nv) j=0; - - if ((y-tri->v[i].y)*(tri->v[j].x-tri->v[i].x) - - (x-tri->v[i].x)*(tri->v[j].y-tri->v[i].y) < 0) - break; // It's outside - } - - if (i==tri->nv) // all lines passed - { - _debugger.tri_sel = tri; - break; - } - - for (i=0; inv; i++) - { - j=i+1; - if (j==tri->nv) j=0; - - if ((y-tri->v[i].y)*(tri->v[j].x-tri->v[i].x) - - (x-tri->v[i].x)*(tri->v[j].y-tri->v[i].y) > 0) - break; // It's outside - } - - if (i==tri->nv) // all lines passed - { - _debugger.tri_sel = tri; - break; - } - - tri = tri->pNext; - } while (tri != start); - } - else - { - // on a texture - _debugger.tex_sel = (((uint32_t)((pt.y-SY(512))/SY(64))+_debugger.tex_scroll)*16) + - (uint32_t)(pt.x/SX(64)); - } - } - - debug_keys (); - - grBufferClear (0, 0, 0xFFFF); - - // Copy the screen capture back to the screen: - grLfbWriteRegion(GR_BUFFER_BACKBUFFER, - (uint32_t)rdp.offset_x, - (uint32_t)rdp.offset_y, - GR_LFB_SRC_FMT_565, - g_settings->res_x, - g_settings->res_y, - FXFALSE, - g_settings->res_x<<1, - _debugger.screen); - - // Do the cacheviewer - debug_cacheviewer (); - - // ** - // 3/16/02: Moved texture viewer out of loop, remade it. Now it's simpler, and - // supports TMU1. [Dave2001] - // Original by Gugaman - - CACHE_LUT * cache = voodoo.tex_UMA?rdp.cache[0]:rdp.cache[_debugger.tmu]; - if (_debugger.page == PAGE_TEX_INFO) - { - grTexSource(_debugger.tmu, - voodoo.tex_min_addr[_debugger.tmu] + cache[_debugger.tex_sel].tmem_addr, - GR_MIPMAPLEVELMASK_BOTH, - &cache[_debugger.tex_sel].t_info); - -#ifdef SHOW_FULL_TEXVIEWER - float scx = 1.0f; - float scy = 1.0f; -#else - float scx = cache[_debugger.tex_sel].scale_x; - float scy = cache[_debugger.tex_sel].scale_y; -#endif - VERTEX v[4] = { - { SX(704.0f), SY(221.0f), 1, 1, 0, 0, 0, 0, {0, 0, 0, 0} }, - { SX(704.0f+256.0f*scx), SY(221.0f), 1, 1, 255*scx, 0, 255*scx, 0, {0, 0, 0, 0} }, - { SX(704.0f), SY(221.0f+256.0f*scy), 1, 1, 0, 255*scy, 0, 255*scy, {0, 0, 0, 0} }, - { SX(704.0f+256.0f*scx), SY(221.0f+256.0f*scy), 1, 1, 255*scx, 255*scy, 255*scx, 255*scy, {0, 0, 0, 0} } - }; - ConvertCoordsConvert (v, 4); - VERTEX *varr[4] = { &v[0], &v[1], &v[2], &v[3] }; - grDrawVertexArray (GR_TRIANGLE_STRIP, 4, varr); - } - - // ** - - grTexFilterMode (GR_TMU0, - GR_TEXTUREFILTER_BILINEAR, - GR_TEXTUREFILTER_BILINEAR); - - grColorCombine (GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_LOCAL_CONSTANT, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - grAlphaCombine (GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_LOCAL_CONSTANT, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - grConstantColorValue (0x0000FFFF); - - VERTEX *v[8]; - if (_debugger.tri_sel) - { - // Draw the outline around the selected triangle - for (i=0; i<_debugger.tri_sel->nv; i++) - { - j=i+1; - if (j>=_debugger.tri_sel->nv) j=0; - - grDrawLine (&_debugger.tri_sel->v[i], &_debugger.tri_sel->v[j]); - - v[i] = &_debugger.tri_sel->v[i]; - } - } - - // and the selected texture - uint32_t t_y = ((_debugger.tex_sel & 0xFFFFFFF0) >> 4) - _debugger.tex_scroll; - uint32_t t_x = _debugger.tex_sel & 0xF; - VERTEX vt[4] = { - { SX(t_x*64.0f), SY(512+64.0f*t_y), 1, 1 }, - { SX(t_x*64.0f+64.0f), SY(512+64.0f*t_y), 1, 1 }, - { SX(t_x*64.0f), SY(512+64.0f*t_y+64.0f), 1, 1 }, - { SX(t_x*64.0f+64.0f), SY(512+64.0f*t_y+64.0f), 1, 1 } }; - if (t_y < 4) - { - grDrawLine (&vt[0], &vt[1]); - grDrawLine (&vt[1], &vt[3]); - grDrawLine (&vt[3], &vt[2]); - grDrawLine (&vt[2], &vt[0]); - } - - grConstantColorValue (0xFF000020); - - if (t_y < 4) - { - grDrawTriangle (&vt[2], &vt[1], &vt[0]); - grDrawTriangle (&vt[2], &vt[3], &vt[1]); - } - - if (_debugger.tri_sel) - grDrawVertexArray (GR_TRIANGLE_FAN, _debugger.tri_sel->nv, &v); - - // Draw the outline of the cacheviewer - if (_debugger.page == PAGE_TEX_INFO) - { - float scx = cache[_debugger.tex_sel].scale_x; - float scy = cache[_debugger.tex_sel].scale_y; - - // And the grid - if (grid) - { - grConstantColorValue (COL_GRID); - - float scale_y = (256.0f * scy) / (float)cache[_debugger.tex_sel].height; - for (int y=0; y<=(int)cache[_debugger.tex_sel].height; y++) - { - float y_val = SY(221.0f+y*scale_y); - VERTEX vh[2] = { - { SX(704.0f), y_val, 1, 1 }, - { SX(704.0f+255.0f*scx), y_val, 1, 1 } }; - grDrawLine (&vh[0], &vh[1]); - } - - float scale_x = (256.0f * scx) / (float)cache[_debugger.tex_sel].width; - for (int x=0; x<=(int)cache[_debugger.tex_sel].width; x++) - { - float x_val = SX(704.0f+x*scale_x); - VERTEX vv[2] = { - { x_val, SX(221.0f), 1, 1 }, - { x_val, SX(221.0f+256.0f*scy), 1, 1 } }; - grDrawLine (&vv[0], &vv[1]); - } - } - } - - grTexCombine (GR_TMU0, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE, - FXFALSE); - - grColorCombine (GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_LOCAL_CONSTANT, - GR_COMBINE_OTHER_NONE, - FXFALSE); - - grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_NONE, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - - grConstantColorValue (0xFFFFFF00); - - // Output the information about the selected triangle - grTexSource(GR_TMU0, // Text - voodoo.tex_min_addr[_debugger.tmu]+ offset_font, - GR_MIPMAPLEVELMASK_BOTH, - &fontTex); - - static const char *cycle_mode_s[4] = { "1 cycle (0)", "2 cycle (1)", "copy (2)", "fill (3)" }; - -#define OUTPUT(fmt,other) output(642,(float)i,1,fmt,other); i-=16; -#define OUTPUT1(fmt,other,other1) output(642,(float)i,1,fmt,other,other1); i-=16; -#define OUTPUT_(fmt,cc) COL_SEL(cc); x=642; output(x,(float)i,1,fmt,0); x+=8*(strlen(fmt)+1) -#define _OUTPUT(fmt,cc) COL_SEL(cc); output(x,(float)i,1,fmt,0); x+=8*(strlen(fmt)+1) - i = 740; - float x; - if (_debugger.page == PAGE_GENERAL && _debugger.tri_sel) - { - COL_CATEGORY(); - OUTPUT ("GENERAL (page 1):",0); - COL_TEXT(); - OUTPUT ("tri #%d", _debugger.tri_sel->tri_n); - OUTPUT ("type: %s", tri_type[_debugger.tri_sel->type]); - OUTPUT ("geom: 0x%08lx", _debugger.tri_sel->geom_mode); - OUTPUT ("othermode_h: 0x%08lx", _debugger.tri_sel->othermode_h); - OUTPUT ("othermode_l: 0x%08lx", _debugger.tri_sel->othermode_l); - OUTPUT ("flags: 0x%08lx", _debugger.tri_sel->flags); - OUTPUT ("",0); - COL_CATEGORY(); - OUTPUT ("COMBINE:",0); - COL_TEXT(); - OUTPUT ("cycle_mode: %s", cycle_mode_s[_debugger.tri_sel->cycle_mode]); - OUTPUT ("cycle1: 0x%08lx", _debugger.tri_sel->cycle1); - OUTPUT ("cycle2: 0x%08lx", _debugger.tri_sel->cycle2); - if (_debugger.tri_sel->uncombined & 1) - COL_UCC(); - else - COL_CC(); - OUTPUT ("a0: %s", Mode0[(_debugger.tri_sel->cycle1)&0x0000000F]); - OUTPUT ("b0: %s", Mode1[(_debugger.tri_sel->cycle1>>4)&0x0000000F]); - OUTPUT ("c0: %s", Mode2[(_debugger.tri_sel->cycle1>>8)&0x0000001F]); - OUTPUT ("d0: %s", Mode3[(_debugger.tri_sel->cycle1>>13)&0x00000007]); - if (_debugger.tri_sel->uncombined & 2) - COL_UAC(); - else - COL_AC(); - OUTPUT ("Aa0: %s", Alpha0[(_debugger.tri_sel->cycle1>>16)&0x00000007]); - OUTPUT ("Ab0: %s", Alpha1[(_debugger.tri_sel->cycle1>>19)&0x00000007]); - OUTPUT ("Ac0: %s", Alpha2[(_debugger.tri_sel->cycle1>>22)&0x00000007]); - OUTPUT ("Ad0: %s", Alpha3[(_debugger.tri_sel->cycle1>>25)&0x00000007]); - if (_debugger.tri_sel->uncombined & 1) - COL_UCC(); - else - COL_CC(); - OUTPUT ("a1: %s", Mode0[(_debugger.tri_sel->cycle2)&0x0000000F]); - OUTPUT ("b1: %s", Mode1[(_debugger.tri_sel->cycle2>>4)&0x0000000F]); - OUTPUT ("c1: %s", Mode2[(_debugger.tri_sel->cycle2>>8)&0x0000001F]); - OUTPUT ("d1: %s", Mode3[(_debugger.tri_sel->cycle2>>13)&0x00000007]); - if (_debugger.tri_sel->uncombined & 2) - COL_UAC(); - else - COL_AC(); - OUTPUT ("Aa1: %s", Alpha0[(_debugger.tri_sel->cycle2>>16)&0x00000007]); - OUTPUT ("Ab1: %s", Alpha1[(_debugger.tri_sel->cycle2>>19)&0x00000007]); - OUTPUT ("Ac1: %s", Alpha2[(_debugger.tri_sel->cycle2>>22)&0x00000007]); - OUTPUT ("Ad1: %s", Alpha3[(_debugger.tri_sel->cycle2>>25)&0x00000007]); - } - if ((_debugger.page == PAGE_TEX1 || _debugger.page == PAGE_TEX2) && _debugger.tri_sel) - { - COL_CATEGORY (); - OUTPUT1 ("TEXTURE %d (page %d):", _debugger.page-PAGE_TEX1, 2+_debugger.page-PAGE_TEX1); - COL_TEXT(); - int tmu = _debugger.page - PAGE_TEX1; - OUTPUT1 ("cur cache: %d,%d", _debugger.tri_sel->t[tmu].cur_cache[tmu]&0x0F, _debugger.tri_sel->t[tmu].cur_cache[tmu]>>4); - OUTPUT ("tex_size: %d", _debugger.tri_sel->t[tmu].size); - OUTPUT ("tex_format: %d", _debugger.tri_sel->t[tmu].format); - OUTPUT ("width: %d", _debugger.tri_sel->t[tmu].width); - OUTPUT ("height: %d", _debugger.tri_sel->t[tmu].height); - OUTPUT ("palette: %d", _debugger.tri_sel->t[tmu].palette); - OUTPUT ("clamp_s: %d", _debugger.tri_sel->t[tmu].clamp_s); - OUTPUT ("clamp_t: %d", _debugger.tri_sel->t[tmu].clamp_t); - OUTPUT ("mirror_s: %d", _debugger.tri_sel->t[tmu].mirror_s); - OUTPUT ("mirror_t: %d", _debugger.tri_sel->t[tmu].mirror_t); - OUTPUT ("mask_s: %d", _debugger.tri_sel->t[tmu].mask_s); - OUTPUT ("mask_t: %d", _debugger.tri_sel->t[tmu].mask_t); - OUTPUT ("shift_s: %d", _debugger.tri_sel->t[tmu].shift_s); - OUTPUT ("shift_t: %d", _debugger.tri_sel->t[tmu].shift_t); - OUTPUT ("ul_s: %d", _debugger.tri_sel->t[tmu].ul_s); - OUTPUT ("ul_t: %d", _debugger.tri_sel->t[tmu].ul_t); - OUTPUT ("lr_s: %d", _debugger.tri_sel->t[tmu].lr_s); - OUTPUT ("lr_t: %d", _debugger.tri_sel->t[tmu].lr_t); - OUTPUT ("t_ul_s: %d", _debugger.tri_sel->t[tmu].t_ul_s); - OUTPUT ("t_ul_t: %d", _debugger.tri_sel->t[tmu].t_ul_t); - OUTPUT ("t_lr_s: %d", _debugger.tri_sel->t[tmu].t_lr_s); - OUTPUT ("t_lr_t: %d", _debugger.tri_sel->t[tmu].t_lr_t); - OUTPUT ("scale_s: %f", _debugger.tri_sel->t[tmu].scale_s); - OUTPUT ("scale_t: %f", _debugger.tri_sel->t[tmu].scale_t); - OUTPUT ("s_mode: %s", str_cm[((_debugger.tri_sel->t[tmu].clamp_s << 1) | _debugger.tri_sel->t[tmu].mirror_s)&3]); - OUTPUT ("t_mode: %s", str_cm[((_debugger.tri_sel->t[tmu].clamp_t << 1) | _debugger.tri_sel->t[tmu].mirror_t)&3]); - } - if (_debugger.page == PAGE_COLORS && _debugger.tri_sel) - { - COL_CATEGORY(); - OUTPUT ("COLORS (page 4)", 0); - COL_TEXT(); - OUTPUT ("fill: %08lx", _debugger.tri_sel->fill_color); - OUTPUT ("prim: %08lx", _debugger.tri_sel->prim_color); - OUTPUT ("blend: %08lx", _debugger.tri_sel->blend_color); - OUTPUT ("env: %08lx", _debugger.tri_sel->env_color); - OUTPUT ("fog: %08lx", _debugger.tri_sel->fog_color); - OUTPUT ("prim_lodmin: %d", _debugger.tri_sel->prim_lodmin); - OUTPUT ("prim_lodfrac: %d", _debugger.tri_sel->prim_lodfrac); - } - if (_debugger.page == PAGE_FBL && _debugger.tri_sel) - { - COL_CATEGORY(); - OUTPUT ("BLENDER", 0); - COL_TEXT(); - OUTPUT ("fbl_a0: %s", FBLa[(_debugger.tri_sel->othermode_l>>30)&0x3]); - OUTPUT ("fbl_b0: %s", FBLb[(_debugger.tri_sel->othermode_l>>26)&0x3]); - OUTPUT ("fbl_c0: %s", FBLc[(_debugger.tri_sel->othermode_l>>22)&0x3]); - OUTPUT ("fbl_d0: %s", FBLd[(_debugger.tri_sel->othermode_l>>18)&0x3]); - OUTPUT ("fbl_a1: %s", FBLa[(_debugger.tri_sel->othermode_l>>28)&0x3]); - OUTPUT ("fbl_b1: %s", FBLb[(_debugger.tri_sel->othermode_l>>24)&0x3]); - OUTPUT ("fbl_c1: %s", FBLc[(_debugger.tri_sel->othermode_l>>20)&0x3]); - OUTPUT ("fbl_d1: %s", FBLd[(_debugger.tri_sel->othermode_l>>16)&0x3]); - OUTPUT ("", 0); - OUTPUT ("fbl: %08lx", _debugger.tri_sel->othermode_l&0xFFFF0000); - OUTPUT ("fbl #1: %08lx", _debugger.tri_sel->othermode_l&0xCCCC0000); - OUTPUT ("fbl #2: %08lx", _debugger.tri_sel->othermode_l&0x33330000); - } - if (_debugger.page == PAGE_OTHERMODE_L && _debugger.tri_sel) - { - uint32_t othermode_l = _debugger.tri_sel->othermode_l; - COL_CATEGORY (); - OUTPUT ("OTHERMODE_L: %08lx", othermode_l); - OUTPUT_ ("AC_NONE", (othermode_l & 3) == 0); - _OUTPUT ("AC_THRESHOLD", (othermode_l & 3) == 1); - _OUTPUT ("AC_DITHER", (othermode_l & 3) == 3); - i -= 16; - OUTPUT_ ("ZS_PIXEL", !(othermode_l & 4)); - _OUTPUT ("ZS_PRIM", (othermode_l & 4)); - i -= 32; - COL_CATEGORY (); - OUTPUT ("RENDERMODE: %08lx", othermode_l); - OUTPUT_ ("AA_EN", othermode_l & 0x08); - i -= 16; - OUTPUT_ ("Z_CMP", othermode_l & 0x10); - i -= 16; - OUTPUT_ ("Z_UPD", othermode_l & 0x20); - i -= 16; - OUTPUT_ ("IM_RD", othermode_l & 0x40); - i -= 16; - OUTPUT_ ("CLR_ON_CVG", othermode_l & 0x80); - i -= 16; - OUTPUT_ ("CVG_DST_CLAMP", (othermode_l & 0x300) == 0x000); - _OUTPUT ("CVG_DST_WRAP", (othermode_l & 0x300) == 0x100); - _OUTPUT (".._FULL", (othermode_l & 0x300) == 0x200); - _OUTPUT (".._SAVE", (othermode_l & 0x300) == 0x300); - i -= 16; - OUTPUT_ ("ZM_OPA", (othermode_l & 0xC00) == 0x000); - _OUTPUT ("ZM_INTER", (othermode_l & 0xC00) == 0x400); - _OUTPUT ("ZM_XLU", (othermode_l & 0xC00) == 0x800); - _OUTPUT ("ZM_DEC", (othermode_l & 0xC00) == 0xC00); - i -= 16; - OUTPUT_ ("CVG_X_ALPHA", othermode_l & 0x1000); - i -= 16; - OUTPUT_ ("ALPHA_CVG_SEL", othermode_l & 0x2000); - i -= 16; - OUTPUT_ ("FORCE_BL", othermode_l & 0x4000); - } - if (_debugger.page == PAGE_OTHERMODE_H && _debugger.tri_sel) - { - uint32_t othermode_h = _debugger.tri_sel->othermode_h; - COL_CATEGORY (); - OUTPUT ("OTHERMODE_H: %08lx", othermode_h); - OUTPUT_ ("CK_NONE", (othermode_h & 0x100) == 0); - _OUTPUT ("CK_KEY", (othermode_h & 0x100) == 1); - i -= 16; - OUTPUT_ ("TC_CONV", (othermode_h & 0xE00) == 0x200); - _OUTPUT ("TC_FILTCONV", (othermode_h & 0xE00) == 0xA00); - _OUTPUT ("TC_FILT", (othermode_h & 0xE00) == 0xC00); - i -= 16; - OUTPUT_ ("TF_POINT", (othermode_h & 0x3000) == 0x0000); - _OUTPUT ("TF_AVERAGE", (othermode_h & 0x3000) == 0x3000); - _OUTPUT ("TF_BILERP", (othermode_h & 0x3000) == 0x2000); - i -= 16; - OUTPUT_ ("TT_NONE", (othermode_h & 0xC000) == 0x0000); - _OUTPUT ("TT_RGBA16", (othermode_h & 0xC000) == 0x8000); - _OUTPUT ("TT_IA16", (othermode_h & 0xC000) == 0xC000); - i -= 16; - OUTPUT_ ("TL_TILE", (othermode_h & 0x10000) == 0x00000); - _OUTPUT ("TL_LOD", (othermode_h & 0x10000) == 0x10000); - i -= 16; - OUTPUT_ ("TD_CLAMP", (othermode_h & 0x60000) == 0x00000); - _OUTPUT ("TD_SHARPEN", (othermode_h & 0x60000) == 0x20000); - _OUTPUT ("TD_DETAIL", (othermode_h & 0x60000) == 0x40000); - i -= 16; - OUTPUT_ ("TP_NONE", (othermode_h & 0x80000) == 0x00000); - _OUTPUT ("TP_PERSP", (othermode_h & 0x80000) == 0x80000); - i -= 16; - OUTPUT_ ("1CYCLE", (othermode_h & 0x300000) == 0x000000); - _OUTPUT ("2CYCLE", (othermode_h & 0x300000) == 0x100000); - _OUTPUT ("COPY", (othermode_h & 0x300000) == 0x200000); - _OUTPUT ("FILL", (othermode_h & 0x300000) == 0x300000); - i -= 16; - OUTPUT_ ("PM_1PRIM", (othermode_h & 0x400000) == 0x000000); - _OUTPUT ("PM_NPRIM", (othermode_h & 0x400000) == 0x400000); - } - if (_debugger.page == PAGE_TEXELS && _debugger.tri_sel) - { - // change these to output whatever you need, ou for triangles, or u0 for texrects - COL_TEXT(); - OUTPUT ("n: %d", _debugger.tri_sel->nv); - OUTPUT ("",0); - for (j=0; j<_debugger.tri_sel->nv; j++) - { - OUTPUT1 ("v[%d].s0: %f", j, _debugger.tri_sel->v[j].ou); - OUTPUT1 ("v[%d].t0: %f", j, _debugger.tri_sel->v[j].ov); - } - OUTPUT ("",0); - for (j=0; j<_debugger.tri_sel->nv; j++) - { - OUTPUT1 ("v[%d].s1: %f", j, _debugger.tri_sel->v[j].u0); - OUTPUT1 ("v[%d].t1: %f", j, _debugger.tri_sel->v[j].v0); - } - } - if (_debugger.page == PAGE_COORDS && _debugger.tri_sel) - { - COL_TEXT(); - OUTPUT ("n: %d", _debugger.tri_sel->nv); - for (j=0; j<_debugger.tri_sel->nv; j++) - { - OUTPUT1 ("v[%d].x: %f", j, _debugger.tri_sel->v[j].x); - OUTPUT1 ("v[%d].y: %f", j, _debugger.tri_sel->v[j].y); - OUTPUT1 ("v[%d].z: %f", j, _debugger.tri_sel->v[j].z); - OUTPUT1 ("v[%d].w: %f", j, _debugger.tri_sel->v[j].w); - OUTPUT1 ("v[%d].f: %f", j, 1.0f/_debugger.tri_sel->v[j].f); - OUTPUT1 ("v[%d].r: %d", j, _debugger.tri_sel->v[j].r); - OUTPUT1 ("v[%d].g: %d", j, _debugger.tri_sel->v[j].g); - OUTPUT1 ("v[%d].b: %d", j, _debugger.tri_sel->v[j].b); - OUTPUT1 ("v[%d].a: %d", j, _debugger.tri_sel->v[j].a); - } - } - if (_debugger.page == PAGE_TEX_INFO && _debugger.tex_sel < (uint32_t)rdp.n_cached[_debugger.tmu]) - { - COL_CATEGORY(); - OUTPUT ("CACHE (page 0)", 0); - COL_TEXT(); - //OUTPUT ("t_mem: %08lx", rdp.cache[0][_debugger.tex_sel].t_mem); - //OUTPUT ("crc: %08lx", rdp.cache[0][_debugger.tex_sel].crc); - OUTPUT ("addr: %08lx", cache[_debugger.tex_sel].addr); - OUTPUT ("scale_x: %f", cache[_debugger.tex_sel].scale_x); - OUTPUT ("scale_y: %f", cache[_debugger.tex_sel].scale_y); - OUTPUT ("tmem_addr: %08lx", cache[_debugger.tex_sel].tmem_addr); - OUTPUT ("palette: %08lx", cache[_debugger.tex_sel].palette); - OUTPUT ("set_by: %08lx", cache[_debugger.tex_sel].set_by); - OUTPUT ("texrecting: %d", cache[_debugger.tex_sel].texrecting); - - OUTPUT ("mod: %08lx", cache[_debugger.tex_sel].mod); - OUTPUT ("mod_col: %08lx", cache[_debugger.tex_sel].mod_color); - OUTPUT ("mod_col1: %08lx", cache[_debugger.tex_sel].mod_color1); - i=740; - output(800,(float)i,1,"width: %d", cache[_debugger.tex_sel].width); - i-=16; - output(800,(float)i,1,"height: %d", cache[_debugger.tex_sel].height); - i-=16; - output(800,(float)i,1,"format: %d", cache[_debugger.tex_sel].format); - i-=16; - output(800,(float)i,1,"size: %d", cache[_debugger.tex_sel].size); - i-=16; - output(800,(float)i,1,"crc: %08lx", cache[_debugger.tex_sel].crc); - i-=16; -#ifdef TEXTURE_FILTER - output(800,(float)i,1,"RiceCrc: %08lx", (uint32_t)(rdp.cache[_debugger.tmu][_debugger.tex_sel].ricecrc&0xFFFFFFFF)); - i-=16; - output(800,(float)i,1,"RicePalCrc: %08lx", (uint32_t)(rdp.cache[_debugger.tmu][_debugger.tex_sel].ricecrc>>32)); - i-=16; -#endif - output(800,(float)i,1,"flags: %08lx", cache[_debugger.tex_sel].flags); - i-=16; - output(800,(float)i,1,"line: %d", cache[_debugger.tex_sel].line); - i-=16; - output(800,(float)i,1,"mod_factor: %08lx", cache[_debugger.tex_sel].mod_factor); - i-=32; - - output(800,(float)i,1,"lod: %s", str_lod[cache[_debugger.tex_sel].lod]); - i-=16; - output(800,(float)i,1,"aspect: %s", str_aspect[cache[_debugger.tex_sel].aspect + 3]); - -// debug_texture(_debugger.tmu, cache[_debugger.tex_sel].addr, _debugger.tex_sel); - } - - // Draw the vertex numbers - if (_debugger.tri_sel) - { - for (i=0; i<_debugger.tri_sel->nv; i++) - { - grConstantColorValue (0x000000FF); - output (_debugger.tri_sel->v[i].x+1, g_settings->scr_res_y-_debugger.tri_sel->v[i].y+1, 1, - "%d", i); - grConstantColorValue (0xFFFFFFFF); - output (_debugger.tri_sel->v[i].x, g_settings->scr_res_y-_debugger.tri_sel->v[i].y, 1, - "%d", i); - } - } - - // Draw the cursor - debug_mouse (); - - grBufferSwap (1); - } - -END: - // Release all data - delete [] _debugger.screen; - TRI_INFO *tri; - for (tri=_debugger.tri_list; tri != _debugger.tri_last;) - { - TRI_INFO *tmp = tri; - tri = tri->pNext; - delete [] tmp->v; - delete tmp; - } - delete [] tri->v; - delete tri; - - // Reset all values - _debugger.capture = 0; - _debugger.selected = SELECTED_TRI; - _debugger.screen = NULL; - _debugger.tri_list = NULL; - _debugger.tri_last = NULL; - _debugger.tri_sel = NULL; - _debugger.tex_sel = 0; -} - -// -// debug_mouse - draws the debugger mouse -// - -void debug_mouse () -{ - grColorCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_NONE, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - - grAlphaCombine (GR_COMBINE_FUNCTION_SCALE_OTHER, - GR_COMBINE_FACTOR_ONE, - GR_COMBINE_LOCAL_NONE, - GR_COMBINE_OTHER_TEXTURE, - FXFALSE); - - // Draw the cursor - POINT pt; - DbgCursorPos(&pt); - float cx = (float)pt.x; - float cy = (float)pt.y; - - VERTEX v[4] = { - { cx, cy, 1, 1, 0, 0, 0, 0, {0, 0, 0, 0} }, - { cx+32, cy, 1, 1, 255, 0, 0, 0, {0, 0, 0, 0} }, - { cx, cy+32, 1, 1, 0, 255, 0, 0, {0, 0, 0, 0} }, - { cx+32, cy+32, 1, 1, 255, 255, 0, 0, {0, 0, 0, 0} } - }; - - ConvertCoordsKeep (v, 4); - - grTexSource(GR_TMU0, - voodoo.tex_min_addr[GR_TMU0] + offset_cursor, - GR_MIPMAPLEVELMASK_BOTH, - &cursorTex); - - if (voodoo.num_tmu >= 3) - grTexCombine (GR_TMU2, - GR_COMBINE_FUNCTION_NONE, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_NONE, - GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - if (voodoo.num_tmu >= 2) - grTexCombine (GR_TMU1, - GR_COMBINE_FUNCTION_NONE, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_NONE, - GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - grTexCombine (GR_TMU0, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); - - grDrawTriangle (&v[0], &v[1], &v[2]); - grDrawTriangle (&v[1], &v[3], &v[2]); -} - -// -// debug_keys - receives debugger key input -// - -void debug_keys () -{ - if (CheckKeyPressed(G64_VK_RIGHT, 0x0001) && _debugger.tri_sel) - { - TRI_INFO *start = _debugger.tri_sel; - - while (_debugger.tri_sel->pNext != start) - _debugger.tri_sel = _debugger.tri_sel->pNext; - } - - if (CheckKeyPressed(G64_VK_LEFT, 0x0001) && _debugger.tri_sel) - _debugger.tri_sel = _debugger.tri_sel->pNext; - - // Check for page changes - if (CheckKeyPressed(G64_VK_1, 0x0001)) - _debugger.page = PAGE_GENERAL; - if (CheckKeyPressed(G64_VK_2, 0x0001)) - _debugger.page = PAGE_TEX1; - if (CheckKeyPressed(G64_VK_3, 0x0001)) - _debugger.page = PAGE_TEX2; - if (CheckKeyPressed(G64_VK_4, 0x0001)) - _debugger.page = PAGE_COLORS; - if (CheckKeyPressed(G64_VK_5, 0x0001)) - _debugger.page = PAGE_FBL; - if (CheckKeyPressed(G64_VK_6, 0x0001)) - _debugger.page = PAGE_OTHERMODE_L; - if (CheckKeyPressed(G64_VK_7, 0x0001)) - _debugger.page = PAGE_OTHERMODE_H; - if (CheckKeyPressed(G64_VK_8, 0x0001)) - _debugger.page = PAGE_TEXELS; - if (CheckKeyPressed(G64_VK_9, 0x0001)) - _debugger.page = PAGE_COORDS; - if (CheckKeyPressed(G64_VK_0, 0x0001)) - _debugger.page = PAGE_TEX_INFO; - if (CheckKeyPressed(G64_VK_Q, 0x0001)) - _debugger.tmu = 0; - if (CheckKeyPressed(G64_VK_W, 0x0001)) - _debugger.tmu = 1; - - if (CheckKeyPressed(G64_VK_G, 0x0001)) - grid = !grid; - - // Go to texture - if (CheckKeyPressed(G64_VK_SPACE, 0x0001)) - { - int tile = -1; - if (_debugger.page == PAGE_TEX2) - tile = 1; - else - tile = 0; - if (tile != -1) - { - _debugger.tmu = _debugger.tri_sel->t[tile].tmu; - _debugger.tex_sel = _debugger.tri_sel->t[tile].cur_cache[_debugger.tmu]; - _debugger.tex_scroll = (_debugger.tri_sel->t[tile].cur_cache[_debugger.tmu] >> 4) - 1; - } - } - - // Go to triangle - CACHE_LUT * cache = voodoo.tex_UMA?rdp.cache[0]:rdp.cache[_debugger.tmu]; - if (CheckKeyPressed(G64_VK_CONTROL, 0x0001)) - { - int count = rdp.debug_n - cache[_debugger.tex_sel].uses - 1; - if (cache[_debugger.tex_sel].last_used == frame_count) - { - TRI_INFO *t = _debugger.tri_list; - while (count && t) { - t = t->pNext; - count --; - } - _debugger.tri_sel = t; - } - else - _debugger.tri_sel = NULL; - } - - if (CheckKeyPressed(G64_VK_A, 0x0001)) - _debugger.draw_mode = 0; // texture & texture alpha - if (CheckKeyPressed(G64_VK_S, 0x0001)) - _debugger.draw_mode = 1; // texture - if (CheckKeyPressed(G64_VK_D, 0x0001)) - _debugger.draw_mode = 2; // texture alpha - - // Check for texture scrolling - if (CheckKeyPressed(G64_VK_DOWN, 0x0001)) - _debugger.tex_scroll ++; - if (CheckKeyPressed(G64_VK_UP, 0x0001)) - _debugger.tex_scroll --; -} - // // output - output debugger text // diff --git a/Source/Glide64/Debugger.h b/Source/Glide64/Debugger.h index 290982c13..b19906bbf 100644 --- a/Source/Glide64/Debugger.h +++ b/Source/Glide64/Debugger.h @@ -37,101 +37,4 @@ // //**************************************************************** -#define SELECTED_NONE 0x00000000 -#define SELECTED_TRI 0x00000001 -#define SELECTED_TEX 0x00000002 - -typedef struct TEX_INFO_t -{ - uint32_t cur_cache[2]; // Current cache # - uint8_t format; - uint8_t size; - uint32_t width, height; - uint16_t line, wid; - uint8_t palette; - uint8_t clamp_s, clamp_t; - uint8_t mirror_s, mirror_t; - uint8_t mask_s, mask_t; - uint8_t shift_s, shift_t; - uint16_t ul_s, ul_t, lr_s, lr_t; - uint16_t t_ul_s, t_ul_t, t_lr_s, t_lr_t; - float scale_s, scale_t; - int tmu; -} TEX_INFO; - -typedef struct TRI_INFO_t -{ - uint32_t nv; // Number of vertices - VERTEX *v; // Vertices (2d screen coords) of the triangle, used to outline - uint32_t cycle1, cycle2, cycle_mode; // Combine mode at the time of rendering - uint8_t uncombined; // which is uncombined: 0x01=color 0x02=alpha 0x03=both - uint32_t geom_mode; // geometry mode flags - uint32_t othermode_h; // setothermode_h flags - uint32_t othermode_l; // setothermode_l flags - uint32_t tri_n; // Triangle number - uint32_t flags; - - int type; // 0-normal, 1-texrect, 2-fillrect - - // texture info - TEX_INFO t[2]; - - // colors - uint32_t fog_color; - uint32_t fill_color; - uint32_t prim_color; - uint32_t blend_color; - uint32_t env_color; - uint32_t prim_lodmin, prim_lodfrac; - - TRI_INFO_t *pNext; -} TRI_INFO; - -typedef struct DEBUGGER_t -{ - int capture; // Capture moment for debugging? - - uint32_t selected; // Selected object (see flags above) - TRI_INFO *tri_sel; - - uint32_t tex_scroll; // texture scrolling - uint32_t tex_sel; - - // CAPTURE INFORMATION - uint8_t *screen; // Screen capture - TRI_INFO *tri_list; // Triangle information list - TRI_INFO *tri_last; // Last in the list (first in) - - uint32_t tmu; // tmu # - - uint32_t draw_mode; - - // Page number - int page; - -} GLIDE64_DEBUGGER; - -#define PAGE_GENERAL 0 -#define PAGE_TEX1 1 -#define PAGE_TEX2 2 -#define PAGE_COLORS 3 -#define PAGE_FBL 4 -#define PAGE_OTHERMODE_L 5 -#define PAGE_OTHERMODE_H 6 -#define PAGE_TEXELS 7 -#define PAGE_COORDS 8 -#define PAGE_TEX_INFO 9 - -#define TRI_TRIANGLE 0 -#define TRI_TEXRECT 1 -#define TRI_FILLRECT 2 -#define TRI_BACKGROUND 3 - -extern GLIDE64_DEBUGGER _debugger; - -void debug_init (); -void debug_capture (); -void debug_cacheviewer (); -void debug_mouse (); -void debug_keys (); void output (float x, float y, int scale, const char *fmt, ...); diff --git a/Source/Glide64/FBtoScreen.cpp b/Source/Glide64/FBtoScreen.cpp index 265420316..fdea2311b 100644 --- a/Source/Glide64/FBtoScreen.cpp +++ b/Source/Glide64/FBtoScreen.cpp @@ -130,11 +130,11 @@ static int SetupFBtoScreenCombiner(uint32_t texture_size, uint32_t opaque) static void DrawRE2Video(FB_TO_SCREEN_INFO & fb_info, float scale) { float scale_y = (float)fb_info.width / rdp.vi_height; - float height = g_settings->scr_res_x / scale_y; + float height = g_settings->scr_res_x() / scale_y; float ul_x = 0.5f; - float ul_y = (g_settings->scr_res_y - height) / 2.0f; - float lr_y = g_settings->scr_res_y - ul_y - 1.0f; - float lr_x = g_settings->scr_res_x - 1.0f; + float ul_y = (g_settings->scr_res_y() - height) / 2.0f; + float lr_y = g_settings->scr_res_y() - ul_y - 1.0f; + float lr_x = g_settings->scr_res_x() - 1.0f; float lr_u = (fb_info.width - 1)*scale; float lr_v = (fb_info.height - 1)*scale; VERTEX v[4] = { @@ -191,7 +191,7 @@ static void DrawRE2Video256(FB_TO_SCREEN_INFO & fb_info) static void DrawFrameBufferToScreen256(FB_TO_SCREEN_INFO & fb_info) { - if (g_settings->hacks&hack_RE2) + if (g_settings->hacks(CSettings::hack_RE2)) { DrawRE2Video256(fb_info); return; @@ -403,7 +403,7 @@ bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info) voodoo.tex_min_addr[tmu] + voodoo.tmem_ptr[tmu], GR_MIPMAPLEVELMASK_BOTH, &t_info); - if (g_settings->hacks&hack_RE2) + if (g_settings->hacks(CSettings::hack_RE2)) { DrawRE2Video(fb_info, scale); } @@ -506,7 +506,7 @@ static void DrawHiresDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info) GrTexInfo t_info; float scale = 0.25f; GrLOD_t LOD = GR_LOD_LOG2_1024; - if (g_settings->scr_res_x > 1024) + if (g_settings->scr_res_x() > 1024) { scale = 0.125f; LOD = GR_LOD_LOG2_2048; @@ -578,7 +578,7 @@ void DrawDepthBufferToScreen(FB_TO_SCREEN_INFO & fb_info) DrawDepthBufferToScreen256(fb_info); return; } - if (fb_hwfbe_enabled && !evoodoo) + if (g_settings->fb_hwfbe_enabled() && !evoodoo) { DrawHiresDepthBufferToScreen(fb_info); return; diff --git a/Source/Glide64/Gfx_1.3.h b/Source/Glide64/Gfx_1.3.h index ce061aa16..7688020a2 100644 --- a/Source/Glide64/Gfx_1.3.h +++ b/Source/Glide64/Gfx_1.3.h @@ -70,10 +70,8 @@ the plugin #include // offsetof #include #include -#include #include "GlideExtensions.h" #include "rdp.h" -#include "Keys.h" #include "Config.h" #include "Settings.h" @@ -99,24 +97,14 @@ extern "C" { // ** TAKE OUT BEFORE RELEASE!!! ** //#define LOG_UCODE - //#define ALTTAB_FIX - // note that some of these things are inserted/removed // from within the code & may not be changed by this define. // ******************************** -#define LOGNOTKEY // Log if not pressing: -#define LOGKEY 0x11 // this key (CONTROL) - -#define LOG_COMMANDS // log the whole 64-bit command as (0x........, 0x........) - //#define CATCH_EXCEPTIONS // catch exceptions so it doesn't freeze and will report // "The gfx plugin has caused an exception" instead. -#define FLUSH // flush the file buffer. slower logging, but makes sure - // the command is logged before continuing (in case of - // crash or exception, the log will not be cut short) #ifndef _ENDUSER_RELEASE_ #endif @@ -127,33 +115,16 @@ extern "C" { // Usually enabled #define LARGE_TEXTURE_HANDLING // allow large-textured objects to be split? -#ifdef ALTTAB_FIX - extern HHOOK hhkLowLevelKybd; - extern LRESULT CALLBACK LowLevelKeyboardProc(int nCode, - WPARAM wParam, LPARAM lParam); -#endif - // Simulations //#define SIMULATE_VOODOO1 //#define SIMULATE_BANSHEE //******** -#ifndef _ENDUSER_RELEASE_ -#define BRIGHT_RED // Keep enabled, option in dialog -#endif - -#define COLORED_DEBUGGER // ;) pretty colors - - // rdram mask at 0x400000 bytes (bah, not right for majora's mask) - //#define BMASK 0x7FFFFF extern unsigned int BMASK; #define WMASK 0x3FFFFF #define DMASK 0x1FFFFF extern uint32_t update_screen_count; - extern uint32_t resolutions[0x18][2]; - - int CheckKeyPressed(int key, int mask); //#define PERFORMANCE #ifdef PERFORMANCE @@ -164,7 +135,6 @@ extern "C" { extern int GfxInitDone; extern bool g_romopen; extern int to_fullscreen; - extern int debugging; extern int evoodoo; extern int ev_fullscreen; @@ -288,8 +258,6 @@ extern "C" { typedef int(*GETTEXADDR)(int tmu, int texsize); - extern GRSTIPPLE grStippleModeExt; - extern GRSTIPPLE grStipplePatternExt; extern GETTEXADDR GetTexAddr; #ifndef GR_STIPPLE_DISABLE @@ -298,10 +266,6 @@ extern "C" { #define GR_STIPPLE_ROTATE 0x2 #endif - void ReadSettings(); - void ReadSpecialSettings(const char * name); - void WriteSettings(void); - /****************************************************************** Function: CaptureScreen Purpose: This function dumps the current frame to a file diff --git a/Source/Glide64/Glide64.rc b/Source/Glide64/Glide64.rc index 73da448c3..49ea61797 100644 --- a/Source/Glide64/Glide64.rc +++ b/Source/Glide64/Glide64.rc @@ -84,7 +84,7 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_CAPTION CAPTION "Basic Settings" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - GROUPBOX "Rendering",IDC_STATIC,6,2,161,128 + GROUPBOX "Rendering",IDC_STATIC,7,2,303,128 LTEXT "Windowed Resolution",IDC_STATIC,11,17,75,8 COMBOBOX IDC_CMB_WINDOW_RES,86,15,77,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Vertical sync",IDC_CHK_VERTICAL_SYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,30,120,10 @@ -99,15 +99,9 @@ BEGIN GROUPBOX "Frame buffer emulation",IDC_STATIC,14,103,146,23 CONTROL "Use frame buffer objects",IDC_CHK_USE_FRAME_BUFFER_OBJECT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,20,113,133,10 - GROUPBOX "On screen display",IDC_STATIC,174,2,135,128 - GROUPBOX "Time",IDC_STATIC,179,13,124,36 - CONTROL "Clock enabled",IDC_CHK_CLOCK_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,186,24,59,10 - CONTROL "Clock is 24-hour",IDC_CHK_CLOCK_24,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,186,37,52,8 GROUPBOX "Other",IDC_STATIC,7,132,303,36 CONTROL "Show texture enhancement options",IDC_CHK_SHOW_TEXTURE_ENHANCEMENT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,140,123,11 - LTEXT "Screenshot format:",IDC_STATIC,14,153,65,11 - COMBOBOX IDC_CMB_SCREEN_SHOT_FORMAT,79,151,42,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END IDD_EMULATION_SETTINGS DIALOGEX 0, 0, 311, 177 diff --git a/Source/Glide64/Glide64.vcxproj b/Source/Glide64/Glide64.vcxproj index bce65c1a7..f2c287f73 100644 --- a/Source/Glide64/Glide64.vcxproj +++ b/Source/Glide64/Glide64.vcxproj @@ -48,7 +48,9 @@ + + @@ -88,14 +90,15 @@ - + + @@ -105,7 +108,6 @@ - diff --git a/Source/Glide64/Glide64.vcxproj.filters b/Source/Glide64/Glide64.vcxproj.filters index 0020b4e24..451d50bfa 100644 --- a/Source/Glide64/Glide64.vcxproj.filters +++ b/Source/Glide64/Glide64.vcxproj.filters @@ -122,7 +122,6 @@ - @@ -130,6 +129,8 @@ + + @@ -147,13 +148,14 @@ - + + diff --git a/Source/Glide64/GlideExtensions.h b/Source/Glide64/GlideExtensions.h index a0630a1ea..899853c29 100644 --- a/Source/Glide64/GlideExtensions.h +++ b/Source/Glide64/GlideExtensions.h @@ -44,31 +44,16 @@ typedef FxU32 GrCombineMode_t; #define GR_TEXTURE_UMA_EXT 0x06 //wrapper specific -FX_ENTRY void FX_CALL grConfigWrapperExt( -#ifndef ANDROID - FxI32, /* resolution parameter not supported on Android */ -#endif +void grConfigWrapperExt( FxI32, FxBool, FxBool ); -FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32*, FxU32*); -FX_ENTRY char ** FX_CALL grQueryResolutionsExt(int32_t*); -FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key); +uint32_t grWrapperFullScreenResolutionExt(uint32_t *, uint32_t *); +char ** grQueryResolutionsExt(int32_t*); FX_ENTRY void FX_CALL grGetGammaTableExt(FxU32, FxU32*, FxU32*, FxU32*); -FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt( -#ifndef ANDROID - HWND hWnd, - GrScreenResolution_t screen_resolution, -#endif - GrScreenRefresh_t refresh_rate, - GrColorFormat_t color_format, - GrOriginLocation_t origin_location, - GrPixelFormat_t pixelformat, - int nColBuffers, - int nAuxBuffers -); +FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt(GrColorFormat_t color_format, GrOriginLocation_t origin_location, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers ); //color combiner FX_ENTRY void FX_CALL diff --git a/Source/Glide64/Keys.cpp b/Source/Glide64/Keys.cpp deleted file mode 100644 index c604e1d97..000000000 --- a/Source/Glide64/Keys.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Keys, used by Glide64. -// Since key codes are different for WinAPI and SDL, this difference is managed here -// Created by Sergey 'Gonetz' Lipski, July 2009 -// -//**************************************************************** - -#include "Gfx_1.3.h" - -Glide64Keys::Glide64Keys() -{ -_keys[G64_VK_CONTROL] = 306; -_keys[G64_VK_ALT] = 308; -_keys[G64_VK_INSERT] = 277; -_keys[G64_VK_LBUTTON] = 1; -_keys[G64_VK_UP] = 273; -_keys[G64_VK_DOWN] = 274; -_keys[G64_VK_LEFT] = 276; -_keys[G64_VK_RIGHT] = 275; -_keys[G64_VK_SPACE] = 32; -_keys[G64_VK_BACK] = 8; -_keys[G64_VK_SCROLL] = 302; -_keys[G64_VK_1] = 49; -_keys[G64_VK_2] = 50; -_keys[G64_VK_3] = 51; -_keys[G64_VK_4] = 52; -_keys[G64_VK_5] = 53; -_keys[G64_VK_6] = 54; -_keys[G64_VK_7] = 55; -_keys[G64_VK_8] = 56; -_keys[G64_VK_9] = 57; -_keys[G64_VK_0] = 48; -_keys[G64_VK_A] = 97; -_keys[G64_VK_B] = 98; -_keys[G64_VK_D] = 100; -_keys[G64_VK_G] = 103; -_keys[G64_VK_Q] = 113; -_keys[G64_VK_R] = 114; -_keys[G64_VK_S] = 115; -_keys[G64_VK_V] = 118; -_keys[G64_VK_W] = 119; -} diff --git a/Source/Glide64/Keys.h b/Source/Glide64/Keys.h deleted file mode 100644 index fe5da6e96..000000000 --- a/Source/Glide64/Keys.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Keys, used by Glide64. -// Since key codes are different for WinAPI and SDL, this difference is managed here -// Created by Sergey 'Gonetz' Lipski, July 2009 -// -//**************************************************************** - -#ifndef Keys_H -#define Keys_H - -#define G64_VK_CONTROL 0 -#define G64_VK_ALT 1 -#define G64_VK_INSERT 2 -#define G64_VK_LBUTTON 3 -#define G64_VK_UP 4 -#define G64_VK_DOWN 5 -#define G64_VK_LEFT 6 -#define G64_VK_RIGHT 7 -#define G64_VK_SPACE 8 -#define G64_VK_BACK 9 -#define G64_VK_SCROLL 10 -#define G64_VK_1 11 -#define G64_VK_2 12 -#define G64_VK_3 13 -#define G64_VK_4 14 -#define G64_VK_5 15 -#define G64_VK_6 16 -#define G64_VK_7 17 -#define G64_VK_8 18 -#define G64_VK_9 19 -#define G64_VK_0 20 -#define G64_VK_A 21 -#define G64_VK_B 22 -#define G64_VK_D 23 -#define G64_VK_G 24 -#define G64_VK_Q 25 -#define G64_VK_R 26 -#define G64_VK_S 27 -#define G64_VK_V 28 -#define G64_VK_W 29 - -#define G64_NUM_KEYS 30 - -class Glide64Keys -{ - public: - Glide64Keys(); - ~Glide64Keys(){} - int operator[](unsigned int index){return _keys[index];} - - private: - int _keys[G64_NUM_KEYS]; -}; - -#endif //Keys_H diff --git a/Source/Glide64/Main.cpp b/Source/Glide64/Main.cpp index 59d29c92d..18332c0d5 100644 --- a/Source/Glide64/Main.cpp +++ b/Source/Glide64/Main.cpp @@ -41,7 +41,6 @@ #include #include "Gfx_1.3.h" #include "Version.h" -#include #include #include #include @@ -59,10 +58,16 @@ #include "FBtoScreen.h" #include "DepthBufferRender.h" #include "trace.h" +#include "ScreenResolution.h" + +#ifdef _WIN32 +#include +#endif -#ifdef TEXTURE_FILTER // Hiroshi Morii #include -int ghq_dmptex_toggle_key = 0; + +#ifdef ANDROID +uint32_t g_NativeWidth, g_NativeHeight; #endif GFX_INFO gfx; @@ -71,22 +76,19 @@ int to_fullscreen = FALSE; int GfxInitDone = FALSE; bool g_romopen = false; GrContext_t gfx_context = 0; -int debugging = FALSE; int exception = FALSE; int evoodoo = 0; int ev_fullscreen = 0; +extern int g_viewport_offset; +extern int g_width, g_height; + + #ifdef _WIN32 HINSTANCE hinstDLL = NULL; #endif -#ifdef ALTTAB_FIX -HHOOK hhkLowLevelKybd = NULL; -LRESULT CALLBACK LowLevelKeyboardProc(int nCode, - WPARAM wParam, LPARAM lParam); -#endif - #ifdef PERFORMANCE int64 perf_cur; int64 perf_next; @@ -94,46 +96,11 @@ int64 perf_next; uint32_t region = 0; -// Resolutions, MUST be in the correct order (SST1VID.H) -uint32_t resolutions[0x18][2] = { - { 320, 200 }, - { 320, 240 }, - { 400, 256 }, - { 512, 384 }, - { 640, 200 }, - { 640, 350 }, - { 640, 400 }, - { 640, 480 }, - { 800, 600 }, - { 960, 720 }, - { 856, 480 }, - { 512, 256 }, - { 1024, 768 }, - { 1280, 1024 }, - { 1600, 1200 }, - { 400, 300 }, - - // 0x10 - { 1152, 864 }, - { 1280, 960 }, - { 1600, 1024 }, - { 1792, 1344 }, - { 1856, 1392 }, - { 1920, 1440 }, - { 2048, 1536 }, - { 2048, 2048 } -}; - -// ref rate -// 60=0x0, 70=0x1, 72=0x2, 75=0x3, 80=0x4, 90=0x5, 100=0x6, 85=0x7, 120=0x8, none=0xff - unsigned int BMASK = 0x7FFFFF; // Reality display processor structure RDP rdp; -CSettings * g_settings; - -HOTKEY_INFO hotkey_info; +CSettings * g_settings = NULL; VOODOO voodoo = { 0, 0, 0, 0, 0, 0, 0, 0, @@ -147,16 +114,25 @@ uint32_t offset_cursor = 0; uint32_t offset_textures = 0; uint32_t offset_texbuf1 = 0; -int capture_screen = 0; -std::string capture_path; +bool g_ghq_use = false; +bool g_capture_screen = false; +std::string g_capture_path; + +#ifdef _WIN32 +HWND g_hwnd_win = NULL; +static RECT g_windowedRect = { 0 }; +static HMENU g_windowedMenu = 0; +static unsigned long g_windowedExStyle, g_windowedStyle; +bool g_fullscreen; +#endif // _WIN32 void _ChangeSize() { - rdp.scale_1024 = g_settings->scr_res_x / 1024.0f; - rdp.scale_768 = g_settings->scr_res_y / 768.0f; + rdp.scale_1024 = g_settings->scr_res_x() / 1024.0f; + rdp.scale_768 = g_settings->scr_res_y() / 768.0f; // float res_scl_x = (float)g_settings->res_x / 320.0f; - float res_scl_y = (float)g_settings->res_y / 240.0f; + float res_scl_y = (float)g_settings->res_y() / 240.0f; uint32_t scale_x = *gfx.VI_X_SCALE_REG & 0xFFF; if (!scale_x) return; @@ -180,26 +156,26 @@ void _ChangeSize() rdp.vi_width = (hend - hstart) * fscale_x; rdp.vi_height = (vend - vstart) * fscale_y * 1.0126582f; - float aspect = (g_settings->adjust_aspect && (fscale_y > fscale_x) && (rdp.vi_width > rdp.vi_height)) ? fscale_x / fscale_y : 1.0f; + float aspect = (g_settings->adjust_aspect() && (fscale_y > fscale_x) && (rdp.vi_width > rdp.vi_height)) ? fscale_x / fscale_y : 1.0f; WriteTrace(TraceResolution, TraceDebug, "hstart: %d, hend: %d, vstart: %d, vend: %d", hstart, hend, vstart, vend); WriteTrace(TraceResolution, TraceDebug, "size: %d x %d", (int)rdp.vi_width, (int)rdp.vi_height); - rdp.scale_x = (float)g_settings->res_x / rdp.vi_width; - if (region > 0 && g_settings->pal230) + rdp.scale_x = (float)g_settings->res_x() / rdp.vi_width; + if (region > 0 && g_settings->pal230()) { // odd... but pal games seem to want 230 as height... rdp.scale_y = res_scl_y * (230.0f / rdp.vi_height) * aspect; } else { - rdp.scale_y = (float)g_settings->res_y / rdp.vi_height * aspect; + rdp.scale_y = (float)g_settings->res_y() / rdp.vi_height * aspect; } // rdp.offset_x = g_settings->offset_x * res_scl_x; // rdp.offset_y = g_settings->offset_y * res_scl_y; //rdp.offset_x = 0; // rdp.offset_y = 0; - rdp.offset_y = ((float)g_settings->res_y - rdp.vi_height * rdp.scale_y) * 0.5f; + rdp.offset_y = ((float)g_settings->res_y() - rdp.vi_height * rdp.scale_y) * 0.5f; if (((uint32_t)rdp.vi_width <= (*gfx.VI_WIDTH_REG) / 2) && (rdp.vi_width > rdp.vi_height)) rdp.scale_y *= 0.5f; @@ -213,395 +189,26 @@ void _ChangeSize() void ChangeSize() { - if (debugging) - { - _ChangeSize(); - return; - } - switch (g_settings->aspectmode) - { - case 0: //4:3 - if (g_settings->scr_res_x >= g_settings->scr_res_y * 4.0f / 3.0f) { - g_settings->res_y = g_settings->scr_res_y; - g_settings->res_x = (uint32_t)(g_settings->res_y * 4.0f / 3.0f); - } - else { - g_settings->res_x = g_settings->scr_res_x; - g_settings->res_y = (uint32_t)(g_settings->res_x / 4.0f * 3.0f); - } - break; - case 1: //16:9 - if (g_settings->scr_res_x >= g_settings->scr_res_y * 16.0f / 9.0f) { - g_settings->res_y = g_settings->scr_res_y; - g_settings->res_x = (uint32_t)(g_settings->res_y * 16.0f / 9.0f); - } - else { - g_settings->res_x = g_settings->scr_res_x; - g_settings->res_y = (uint32_t)(g_settings->res_x / 16.0f * 9.0f); - } - break; - default: //stretch or original - g_settings->res_x = g_settings->scr_res_x; - g_settings->res_y = g_settings->scr_res_y; - } + g_settings->UpdateScreenSize(ev_fullscreen); _ChangeSize(); - rdp.offset_x = (g_settings->scr_res_x - g_settings->res_x) / 2.0f; - float offset_y = (g_settings->scr_res_y - g_settings->res_y) / 2.0f; - g_settings->res_x += (uint32_t)rdp.offset_x; - g_settings->res_y += (uint32_t)offset_y; + rdp.offset_x = (g_settings->scr_res_x() - g_settings->res_x()) / 2.0f; + float offset_y = (g_settings->scr_res_y() - g_settings->res_y()) / 2.0f; rdp.offset_y += offset_y; - if (g_settings->aspectmode == 3) // original + if (g_settings->aspectmode() == CSettings::Aspect_Original) { rdp.scale_x = rdp.scale_y = 1.0f; - rdp.offset_x = (g_settings->scr_res_x - rdp.vi_width) / 2.0f; - rdp.offset_y = (g_settings->scr_res_y - rdp.vi_height) / 2.0f; + rdp.offset_x = (g_settings->scr_res_x() - rdp.vi_width) / 2.0f; + rdp.offset_y = (g_settings->scr_res_y() - rdp.vi_height) / 2.0f; } - // g_settings->res_x = g_settings->scr_res_x; - // g_settings->res_y = g_settings->scr_res_y; } void ConfigWrapper() { - grConfigWrapperExt( -#ifdef ANDROID - g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic -#else - g_settings->wrpResolution, g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic -#endif - ); + grConfigWrapperExt(g_settings->wrpVRAM() * 1024 * 1024, g_settings->wrpFBO(), g_settings->wrpAnisotropic()); } -void UseUnregisteredSetting(int /*SettingID*/) -{ -#ifdef _WIN32 - DebugBreak(); -#endif -} extern int g_width, g_height; -void ReadSettings() -{ - g_settings->card_id = GetSetting(Set_CardId); -#ifdef ANDROID - g_settings->scr_res_x = g_settings->res_x = g_width; - g_settings->scr_res_y = g_settings->res_y = g_height; -#else - g_settings->res_data = (uint32_t)GetSetting(Set_Resolution); - if (g_settings->res_data >= 24) g_settings->res_data = 12; - g_settings->scr_res_x = g_settings->res_x = resolutions[g_settings->res_data][0]; - g_settings->scr_res_y = g_settings->res_y = resolutions[g_settings->res_data][1]; - g_settings->wrpResolution = GetSetting(Set_wrpResolution); -#endif - g_settings->vsync = GetSetting(Set_vsync); - g_settings->ssformat = (uint8_t)GetSetting(Set_ssformat); - g_settings->clock = GetSetting(Set_clock); - g_settings->clock_24_hr = GetSetting(Set_clock_24_hr); - g_settings->rotate = GetSetting(Set_Rotate); - g_settings->advanced_options = Set_basic_mode ? !GetSystemSetting(Set_basic_mode) : 0; - g_settings->texenh_options = GetSetting(Set_texenh_options); - g_settings->use_hotkeys = GetSetting(Set_hotkeys); - - g_settings->wrpVRAM = GetSetting(Set_wrpVRAM); - g_settings->wrpFBO = GetSetting(Set_wrpFBO); - g_settings->wrpAnisotropic = GetSetting(Set_wrpAnisotropic); - -#ifndef _ENDUSER_RELEASE_ - g_settings->autodetect_ucode = GetSetting(Set_autodetect_ucode); - g_settings->ucode = GetSetting(Set_ucode); - g_settings->wireframe = GetSetting(Set_wireframe); - g_settings->wfmode = GetSetting(Set_wfmode); - g_settings->logging = GetSetting(Set_logging); - g_settings->log_clear = GetSetting(Set_log_clear); - g_settings->run_in_window = GetSetting(Set_run_in_window); - g_settings->elogging = GetSetting(Set_elogging); - g_settings->filter_cache = GetSetting(Set_filter_cache); - g_settings->unk_as_red = GetSetting(Set_unk_as_red); - g_settings->log_unk = GetSetting(Set_log_unk); - g_settings->unk_clear = GetSetting(Set_unk_clear); -#else - g_settings->autodetect_ucode = TRUE; - g_settings->ucode = 2; - g_settings->wireframe = FALSE; - g_settings->wfmode = 0; - g_settings->logging = FALSE; - g_settings->log_clear = FALSE; - g_settings->run_in_window = FALSE; - g_settings->elogging = FALSE; - g_settings->filter_cache = FALSE; - g_settings->unk_as_red = FALSE; - g_settings->log_unk = FALSE; - g_settings->unk_clear = FALSE; -#endif - -#ifdef TEXTURE_FILTER - char texture_dir[260]; - memset(texture_dir, 0, sizeof(texture_dir)); - GetSystemSettingSz(Set_texture_dir, texture_dir, sizeof(texture_dir)); - g_settings->texture_dir = texture_dir; - g_settings->ghq_fltr = (uint8_t)GetSetting(Set_ghq_fltr); - g_settings->ghq_cmpr = (uint8_t)GetSetting(Set_ghq_cmpr); - g_settings->ghq_enht = (uint8_t)GetSetting(Set_ghq_enht); - g_settings->ghq_hirs = (uint8_t)GetSetting(Set_ghq_hirs); - g_settings->ghq_enht_cmpr = GetSetting(Set_ghq_enht_cmpr); - g_settings->ghq_enht_tile = GetSetting(Set_ghq_enht_tile); - g_settings->ghq_enht_f16bpp = GetSetting(Set_ghq_enht_f16bpp); - g_settings->ghq_enht_gz = GetSetting(Set_ghq_enht_gz); - g_settings->ghq_enht_nobg = GetSetting(Set_ghq_enht_nobg); - g_settings->ghq_hirs_cmpr = GetSetting(Set_ghq_hirs_cmpr); - g_settings->ghq_hirs_tile = GetSetting(Set_ghq_hirs_tile); - g_settings->ghq_hirs_f16bpp = GetSetting(Set_ghq_hirs_f16bpp); - g_settings->ghq_hirs_gz = GetSetting(Set_ghq_hirs_gz); - g_settings->ghq_hirs_altcrc = GetSetting(Set_ghq_hirs_altcrc); - g_settings->ghq_cache_save = GetSetting(Set_ghq_cache_save); - g_settings->ghq_cache_size = GetSetting(Set_ghq_cache_size); - g_settings->ghq_hirs_let_texartists_fly = GetSetting(Set_ghq_hirs_let_texartists_fly); - g_settings->ghq_hirs_dump = GetSetting(Set_ghq_hirs_dump); -#endif - - ConfigWrapper(); -} - -void ReadSpecialSettings(const char * name) -{ - g_settings->hacks = 0; - - //detect games which require special hacks - if (strstr(name, (const char *)"ZELDA")) - g_settings->hacks |= (hack_Zelda | hack_OoT); - else if (strstr(name, (const char *)"MASK")) - g_settings->hacks |= hack_Zelda; - else if (strstr(name, (const char *)"ROADSTERS TROPHY")) - g_settings->hacks |= hack_Zelda; - else if (strstr(name, (const char *)"Diddy Kong Racing")) - g_settings->hacks |= hack_Diddy; - else if (strstr(name, (const char *)"Tonic Trouble")) - g_settings->hacks |= hack_Tonic; - else if (strstr(name, (const char *)"All") && strstr(name, (const char *)"Star") && strstr(name, (const char *)"Baseball")) - g_settings->hacks |= hack_ASB; - else if (strstr(name, (const char *)"Beetle") || strstr(name, (const char *)"BEETLE") || strstr(name, (const char *)"HSV")) - g_settings->hacks |= hack_BAR; - else if (strstr(name, (const char *)"I S S 64") || strstr(name, (const char *)"J WORLD SOCCER3") || strstr(name, (const char *)"PERFECT STRIKER") || strstr(name, (const char *)"RONALDINHO SOCCER")) - g_settings->hacks |= hack_ISS64; - else if (strstr(name, (const char *)"MARIOKART64")) - g_settings->hacks |= hack_MK64; - else if (strstr(name, (const char *)"NITRO64")) - g_settings->hacks |= hack_WCWnitro; - else if (strstr(name, (const char *)"CHOPPER_ATTACK") || strstr(name, (const char *)"WILD CHOPPERS")) - g_settings->hacks |= hack_Chopper; - else if (strstr(name, (const char *)"Resident Evil II") || strstr(name, (const char *)"BioHazard II")) - g_settings->hacks |= hack_RE2; - else if (strstr(name, (const char *)"YOSHI STORY")) - g_settings->hacks |= hack_Yoshi; - else if (strstr(name, (const char *)"F-Zero X") || strstr(name, (const char *)"F-ZERO X")) - g_settings->hacks |= hack_Fzero; - else if (strstr(name, (const char *)"PAPER MARIO") || strstr(name, (const char *)"MARIO STORY")) - g_settings->hacks |= hack_PMario; - else if (strstr(name, (const char *)"TOP GEAR RALLY 2")) - g_settings->hacks |= hack_TGR2; - else if (strstr(name, (const char *)"TOP GEAR RALLY")) - g_settings->hacks |= hack_TGR; - else if (strstr(name, (const char *)"Top Gear Hyper Bike")) - g_settings->hacks |= hack_Hyperbike; - else if (strstr(name, (const char *)"Killer Instinct Gold") || strstr(name, (const char *)"KILLER INSTINCT GOLD")) - g_settings->hacks |= hack_KI; - else if (strstr(name, (const char *)"Knockout Kings 2000")) - g_settings->hacks |= hack_Knockout; - else if (strstr(name, (const char *)"LEGORacers")) - g_settings->hacks |= hack_Lego; - else if (strstr(name, (const char *)"OgreBattle64")) - g_settings->hacks |= hack_Ogre64; - else if (strstr(name, (const char *)"Pilot Wings64")) - g_settings->hacks |= hack_Pilotwings; - else if (strstr(name, (const char *)"Supercross")) - g_settings->hacks |= hack_Supercross; - else if (strstr(name, (const char *)"STARCRAFT 64")) - g_settings->hacks |= hack_Starcraft; - else if (strstr(name, (const char *)"BANJO KAZOOIE 2") || strstr(name, (const char *)"BANJO TOOIE")) - g_settings->hacks |= hack_Banjo2; - else if (strstr(name, (const char *)"FIFA: RTWC 98") || strstr(name, (const char *)"RoadToWorldCup98")) - g_settings->hacks |= hack_Fifa98; - else if (strstr(name, (const char *)"Mega Man 64") || strstr(name, (const char *)"RockMan Dash")) - g_settings->hacks |= hack_Megaman; - else if (strstr(name, (const char *)"MISCHIEF MAKERS") || strstr(name, (const char *)"TROUBLE MAKERS")) - g_settings->hacks |= hack_Makers; - else if (strstr(name, (const char *)"GOLDENEYE")) - g_settings->hacks |= hack_GoldenEye; - else if (strstr(name, (const char *)"PUZZLE LEAGUE")) - g_settings->hacks |= hack_PPL; - else if (strstr(name, (const char *)"WIN BACK") || strstr(name, (const char *)"OPERATION WINBACK")) - g_settings->hacks |= hack_Winback; - - g_settings->alt_tex_size = GetSetting(Set_alt_tex_size); - g_settings->use_sts1_only = GetSetting(Set_use_sts1_only); - g_settings->force_calc_sphere = GetSetting(Set_force_calc_sphere); - g_settings->correct_viewport = GetSetting(Set_correct_viewport); - g_settings->increase_texrect_edge = GetSetting(Set_increase_texrect_edge); - g_settings->decrease_fillrect_edge = GetSetting(Set_decrease_fillrect_edge); - g_settings->texture_correction = GetSetting(Set_texture_correction) == 0 ? 0 : 1; - g_settings->pal230 = GetSetting(Set_pal230) == 1 ? 1 : 0; - g_settings->stipple_mode = GetSetting(Set_stipple_mode); - int stipple_pattern = GetSetting(Set_stipple_pattern); - g_settings->stipple_pattern = stipple_pattern > 0 ? (uint32_t)stipple_pattern : 0x3E0F83E0; - g_settings->force_microcheck = GetSetting(Set_force_microcheck); - g_settings->force_quad3d = GetSetting(Set_force_quad3d); - g_settings->clip_zmin = GetSetting(Set_clip_zmin); - g_settings->clip_zmax = GetSetting(Set_clip_zmax); - g_settings->fast_crc = GetSetting(Set_fast_crc); - g_settings->adjust_aspect = GetSetting(Set_adjust_aspect); - g_settings->zmode_compare_less = GetSetting(Set_zmode_compare_less); - g_settings->old_style_adither = GetSetting(Set_old_style_adither); - g_settings->n64_z_scale = GetSetting(Set_n64_z_scale); - ZLUT_init(); - - //frame buffer - int optimize_texrect = GetSetting(g_romopen ? Set_optimize_texrect : Set_optimize_texrect_default); - int ignore_aux_copy = GetSetting(Set_ignore_aux_copy); - int hires_buf_clear = GetSetting(Set_hires_buf_clear); - int read_alpha = GetSetting(Set_fb_read_alpha); - int useless_is_useless = GetSetting(Set_useless_is_useless); - int fb_crc_mode = GetSetting(Set_fb_crc_mode); - - if (optimize_texrect > 0) g_settings->frame_buffer |= fb_optimize_texrect; - else if (optimize_texrect == 0) g_settings->frame_buffer &= ~fb_optimize_texrect; - if (ignore_aux_copy > 0) g_settings->frame_buffer |= fb_ignore_aux_copy; - else if (ignore_aux_copy == 0) g_settings->frame_buffer &= ~fb_ignore_aux_copy; - if (hires_buf_clear > 0) g_settings->frame_buffer |= fb_hwfbe_buf_clear; - else if (hires_buf_clear == 0) g_settings->frame_buffer &= ~fb_hwfbe_buf_clear; - if (read_alpha > 0) g_settings->frame_buffer |= fb_read_alpha; - else if (read_alpha == 0) g_settings->frame_buffer &= ~fb_read_alpha; - if (useless_is_useless > 0) g_settings->frame_buffer |= fb_useless_is_useless; - else g_settings->frame_buffer &= ~fb_useless_is_useless; - if (fb_crc_mode >= 0) g_settings->fb_crc_mode = (CSettings::FBCRCMODE)fb_crc_mode; - - g_settings->filtering = GetSetting(g_romopen ? Set_filtering : Set_filtering_default); - g_settings->fog = GetSetting(g_romopen ? Set_fog : Set_fog_default); - g_settings->buff_clear = GetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default); - g_settings->swapmode = GetSetting(g_romopen ? Set_swapmode : Set_swapmode_default); - g_settings->aspectmode = GetSetting(g_romopen ? Set_aspect : Set_aspect_default); - g_settings->lodmode = GetSetting(g_romopen ? Set_lodmode : Set_lodmode_default); -#ifdef _WIN32 - g_settings->res_data = GetSetting(Set_Resolution); - if (g_settings->res_data < 0 || g_settings->res_data >= 0x18) g_settings->res_data = 12; - g_settings->scr_res_x = g_settings->res_x = resolutions[g_settings->res_data][0]; - g_settings->scr_res_y = g_settings->res_y = resolutions[g_settings->res_data][1]; -#endif - - //frame buffer - int smart_read = GetSetting(g_romopen ? Set_fb_smart : Set_fb_smart_default); - int hires = GetSetting(g_romopen ? Set_fb_hires : Set_fb_hires_default); - int read_always = GetSetting(g_romopen ? Set_fb_read_always : Set_fb_read_always_default); - int read_back_to_screen = GetSetting(g_romopen ? Set_read_back_to_screen : Set_read_back_to_screen_default); - int cpu_write_hack = GetSetting(g_romopen ? Set_detect_cpu_write : Set_detect_cpu_write_default); - int get_fbinfo = GetSetting(g_romopen ? Set_fb_get_info : Set_fb_get_info_default); - int depth_render = GetSetting(g_romopen ? Set_fb_render : Set_fb_render_default); - - if (smart_read > 0) g_settings->frame_buffer |= fb_emulation; - else if (smart_read == 0) g_settings->frame_buffer &= ~fb_emulation; - if (hires > 0) g_settings->frame_buffer |= fb_hwfbe; - else if (hires == 0) g_settings->frame_buffer &= ~fb_hwfbe; - if (read_always > 0) g_settings->frame_buffer |= fb_ref; - else if (read_always == 0) g_settings->frame_buffer &= ~fb_ref; - if (read_back_to_screen == 1) g_settings->frame_buffer |= fb_read_back_to_screen; - else if (read_back_to_screen == 2) g_settings->frame_buffer |= fb_read_back_to_screen2; - else if (read_back_to_screen == 0) g_settings->frame_buffer &= ~(fb_read_back_to_screen | fb_read_back_to_screen2); - if (cpu_write_hack > 0) g_settings->frame_buffer |= fb_cpu_write_hack; - else if (cpu_write_hack == 0) g_settings->frame_buffer &= ~fb_cpu_write_hack; - if (get_fbinfo > 0) g_settings->frame_buffer |= fb_get_info; - else if (get_fbinfo == 0) g_settings->frame_buffer &= ~fb_get_info; - if (depth_render > 0) g_settings->frame_buffer |= fb_depth_render; - else if (depth_render == 0) g_settings->frame_buffer &= ~fb_depth_render; - g_settings->frame_buffer |= fb_motionblur; - g_settings->flame_corona = (g_settings->hacks & hack_Zelda) && !fb_depth_render_enabled; -} - -void WriteSettings(void) -{ - SetSetting(Set_CardId, g_settings->card_id); -#ifdef _WIN32 - SetSetting(Set_Resolution, (int)g_settings->res_data); - SetSetting(Set_wrpResolution, g_settings->wrpResolution); -#endif - SetSetting(Set_ssformat, g_settings->ssformat); - SetSetting(Set_vsync, g_settings->vsync); - SetSetting(Set_clock, g_settings->clock); - SetSetting(Set_clock_24_hr, g_settings->clock_24_hr); - SetSetting(Set_Rotate, g_settings->rotate); - //SetSetting(Set_advanced_options,g_settings->advanced_options); - SetSetting(Set_texenh_options, g_settings->texenh_options); - - SetSetting(Set_wrpVRAM, g_settings->wrpVRAM); - SetSetting(Set_wrpFBO, g_settings->wrpFBO); - SetSetting(Set_wrpAnisotropic, g_settings->wrpAnisotropic); - -#ifndef _ENDUSER_RELEASE_ - SetSetting(Set_autodetect_ucode, g_settings->autodetect_ucode); - SetSetting(Set_ucode, (int)g_settings->ucode); - SetSetting(Set_wireframe, g_settings->wireframe); - SetSetting(Set_wfmode, g_settings->wfmode); - SetSetting(Set_logging, g_settings->logging); - SetSetting(Set_log_clear, g_settings->log_clear); - SetSetting(Set_run_in_window,g_settings->run_in_window); - SetSetting(Set_elogging,g_settings->elogging); - SetSetting(Set_filter_cache,g_settings->filter_cache); - SetSetting(Set_unk_as_red,g_settings->unk_as_red); - SetSetting(Set_log_unk,g_settings->log_unk); - SetSetting(Set_unk_clear, g_settings->unk_clear); -#endif //_ENDUSER_RELEASE_ - -#ifdef TEXTURE_FILTER - SetSetting(Set_ghq_fltr, g_settings->ghq_fltr); - SetSetting(Set_ghq_cmpr, g_settings->ghq_cmpr); - SetSetting(Set_ghq_enht, g_settings->ghq_enht); - SetSetting(Set_ghq_hirs, g_settings->ghq_hirs); - SetSetting(Set_ghq_enht_cmpr, g_settings->ghq_enht_cmpr); - SetSetting(Set_ghq_enht_tile, g_settings->ghq_enht_tile); - SetSetting(Set_ghq_enht_f16bpp, g_settings->ghq_enht_f16bpp); - SetSetting(Set_ghq_enht_gz, g_settings->ghq_enht_gz); - SetSetting(Set_ghq_enht_nobg, g_settings->ghq_enht_nobg); - SetSetting(Set_ghq_hirs_cmpr, g_settings->ghq_hirs_cmpr); - SetSetting(Set_ghq_hirs_tile, g_settings->ghq_hirs_tile); - SetSetting(Set_ghq_hirs_f16bpp, g_settings->ghq_hirs_f16bpp); - SetSetting(Set_ghq_hirs_gz, g_settings->ghq_hirs_gz); - SetSetting(Set_ghq_hirs_altcrc, g_settings->ghq_hirs_altcrc); - SetSetting(Set_ghq_cache_save, g_settings->ghq_cache_save); - SetSetting(Set_ghq_cache_size, g_settings->ghq_cache_size); - SetSetting(Set_ghq_hirs_let_texartists_fly, g_settings->ghq_hirs_let_texartists_fly); - SetSetting(Set_ghq_hirs_dump, g_settings->ghq_hirs_dump); -#endif - - SetSetting(g_romopen ? Set_filtering : Set_filtering_default, g_settings->filtering); - SetSetting(g_romopen ? Set_fog : Set_fog_default, g_settings->fog); - SetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default, g_settings->buff_clear); - SetSetting(g_romopen ? Set_swapmode : Set_swapmode_default, g_settings->swapmode); - SetSetting(g_romopen ? Set_lodmode : Set_lodmode_default, g_settings->lodmode); - SetSetting(g_romopen ? Set_aspect : Set_aspect_default, g_settings->aspectmode); - - SetSetting(g_romopen ? Set_fb_read_always : Set_fb_read_always_default, g_settings->frame_buffer&fb_ref ? 1 : 0); - SetSetting(g_romopen ? Set_fb_smart : Set_fb_smart_default, g_settings->frame_buffer & fb_emulation ? 1 : 0); - SetSetting(g_romopen ? Set_fb_hires : Set_fb_hires_default, g_settings->frame_buffer & fb_hwfbe ? 1 : 0); - SetSetting(g_romopen ? Set_fb_get_info : Set_fb_get_info_default, g_settings->frame_buffer & fb_get_info ? 1 : 0); - SetSetting(g_romopen ? Set_fb_render : Set_fb_render_default, g_settings->frame_buffer & fb_depth_render ? 1 : 0); - SetSetting(g_romopen ? Set_detect_cpu_write : Set_detect_cpu_write_default, g_settings->frame_buffer & fb_cpu_write_hack ? 1 : 0); - if (g_settings->frame_buffer & fb_read_back_to_screen) - { - SetSetting(g_romopen ? Set_read_back_to_screen : Set_read_back_to_screen_default, 1); - } - else if (g_settings->frame_buffer & fb_read_back_to_screen2) - { - SetSetting(g_romopen ? Set_read_back_to_screen : Set_read_back_to_screen_default, 2); - } - else - { - SetSetting(g_romopen ? Set_read_back_to_screen : Set_read_back_to_screen_default, 0); - } - - FlushSettings(); -} - -GRSTIPPLE grStippleModeExt = NULL; -GRSTIPPLE grStipplePatternExt = NULL; -FxBool(FX_CALL *grKeyPressed)(FxU32) = NULL; - int GetTexAddrUMA(int /*tmu*/, int texsize) { int addr = voodoo.tex_min_addr[0] + voodoo.tmem_ptr[0]; @@ -628,7 +235,7 @@ void guLoadTextures() tbuf_size = 8 * grTexCalcMemRequired(GR_LOD_LOG2_256, GR_LOD_LOG2_256, GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565); } - else if (g_settings->scr_res_x <= 1024) + else if (g_settings->scr_res_x() <= 1024) { grTextureBufferExt(GR_TMU0, voodoo.tex_min_addr[GR_TMU0], GR_LOD_LOG2_1024, GR_LOD_LOG2_1024, GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH); @@ -739,7 +346,6 @@ void guLoadTextures() free(cursorTex.data); } -#ifdef TEXTURE_FILTER void DisplayLoadProgress(const wchar_t *format, ...) { va_list args; @@ -764,8 +370,88 @@ void DisplayLoadProgress(const wchar_t *format, ...) grColorMask(FXTRUE, FXTRUE); grBufferClear(0, 0, 0xFFFF); } + +#ifdef _WIN32 +void SetWindowDisplaySize(HWND hWnd) +{ + if (hWnd == NULL) + { + hWnd = GetActiveWindow(); + } + g_hwnd_win = (HWND)hWnd; + + if (ev_fullscreen) + { + ZeroMemory(&g_windowedRect, sizeof(RECT)); + GetWindowRect(hWnd, &g_windowedRect); + + g_windowedExStyle = GetWindowLong(hWnd, GWL_EXSTYLE); + g_windowedStyle = GetWindowLong(hWnd, GWL_STYLE); + + // primary monitor only + if (!EnterFullScreen(g_settings->FullScreenRes())) + { + WriteTrace(TraceGlitch, TraceWarning, "can't change to fullscreen mode"); + } + + g_windowedMenu = GetMenu(hWnd); + if (g_windowedMenu) SetMenu(hWnd, NULL); + + HWND hStatusBar = FindWindowEx(hWnd, NULL, "msctls_statusbar32", NULL); // 1964 + if (hStatusBar) ShowWindow(hStatusBar, SW_HIDE); + + SetWindowLong(hWnd, GWL_STYLE, 0); + SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); + SetWindowPos(hWnd, NULL, 0, 0, g_width, g_height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW); + + g_viewport_offset = 0; + g_fullscreen = true; + } + else + { + RECT clientRect = { 0 }, toolbarRect = { 0 }, statusbarRect = { 0 }, windowedRect = { 0 }; + HWND hToolBar = FindWindowEx(hWnd, NULL, REBARCLASSNAME, NULL); + HWND hStatusBar = FindWindowEx(hWnd, NULL, STATUSCLASSNAME, NULL); + if (hStatusBar == NULL) + { + hStatusBar = FindWindowEx(hWnd, NULL, "msctls_statusbar32", NULL); + } + if (hToolBar != NULL) + { + GetWindowRect(hToolBar, &toolbarRect); + } + if (hStatusBar != NULL) + { + GetWindowRect(hStatusBar, &statusbarRect); + } + g_viewport_offset = statusbarRect.bottom - statusbarRect.top; + GetWindowRect(hWnd, &g_windowedRect); + GetClientRect(hWnd, &clientRect); + g_windowedRect.right += (g_width - (clientRect.right - clientRect.left)); + g_windowedRect.bottom += (g_height + (toolbarRect.bottom - toolbarRect.top) + (statusbarRect.bottom - statusbarRect.top) - (clientRect.bottom - clientRect.top)); + SetWindowPos(hWnd, NULL, 0, 0, g_windowedRect.right - g_windowedRect.left, g_windowedRect.bottom - g_windowedRect.top, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); + + g_fullscreen = false; + } +} + +void ExitFullScreen(void) +{ + if (g_fullscreen) + { + ChangeDisplaySettings(NULL, 0); + SetWindowPos(g_hwnd_win, NULL, g_windowedRect.left, g_windowedRect.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + SetWindowLong(g_hwnd_win, GWL_STYLE, g_windowedStyle); + SetWindowLong(g_hwnd_win, GWL_EXSTYLE, g_windowedExStyle); + if (g_windowedMenu) SetMenu(g_hwnd_win, g_windowedMenu); + g_fullscreen = false; + } +} + #endif +void setPattern(); + int InitGfx() { if (GfxInitDone) @@ -775,15 +461,11 @@ int InitGfx() WriteTrace(TraceGlide64, TraceDebug, "-"); - debugging = FALSE; rdp_reset(); // Initialize Glide grGlideInit(); - // Select the Glide device - grSstSelect(g_settings->card_id); - // Is mirroring allowed? const char *extensions = grGetString(GR_EXTENSION); @@ -823,34 +505,19 @@ int InitGfx() voodoo.has_2mb_tex_boundary = (SST_type < GR_SSTTYPE_Banshee) && !evoodoo; // use UMA if available voodoo.tex_UMA = FALSE; - //* - if (strstr(extensions, " TEXUMA ")) { + if (strstr(extensions, " TEXUMA ")) + { // we get better texture cache hits with UMA on grEnable(GR_TEXTURE_UMA_EXT); voodoo.tex_UMA = TRUE; WriteTrace(TraceGlide64, TraceDebug, "Using TEXUMA extension"); } - //*/ + g_settings->UpdateScreenSize(ev_fullscreen); #ifndef ANDROID - uint32_t res_data = g_settings->res_data; - if (ev_fullscreen) - { - uint32_t _width, _height = 0; - g_settings->res_data = grWrapperFullScreenResolutionExt((FxU32*)&_width, (FxU32*)&_height); - g_settings->scr_res_x = g_settings->res_x = _width; - g_settings->scr_res_y = g_settings->res_y = _height; - res_data = g_settings->res_data; - } - else if (evoodoo) - { - g_settings->res_data = g_settings->res_data_org; - g_settings->scr_res_x = g_settings->res_x = resolutions[g_settings->res_data][0]; - g_settings->scr_res_y = g_settings->res_y = resolutions[g_settings->res_data][1]; - res_data = g_settings->res_data | 0x80000000; - } - - gfx_context = grSstWinOpen(gfx.hWnd, res_data, GR_REFRESH_60Hz, GR_COLORFORMAT_RGBA, GR_ORIGIN_UPPER_LEFT, 2, 1); + SetWindowDisplaySize(gfx.hWnd); +#endif + gfx_context = grSstWinOpen(GR_COLORFORMAT_RGBA, GR_ORIGIN_UPPER_LEFT, 2, 1); if (!gfx_context) { #ifdef _WIN32 @@ -861,29 +528,15 @@ int InitGfx() grGlideShutdown(); return FALSE; } -#else - gfx_context = grSstWinOpen(GR_REFRESH_60Hz, GR_COLORFORMAT_RGBA, GR_ORIGIN_UPPER_LEFT, 2, 1); - g_settings->scr_res_x = g_settings->res_x = g_width; - g_settings->scr_res_y = g_settings->res_y = g_height; -#endif GfxInitDone = TRUE; to_fullscreen = FALSE; -#ifdef __WINDOWS__ - if (ev_fullscreen) - { - if (gfx.hStatusBar) - ShowWindow(gfx.hStatusBar, SW_HIDE); - ShowCursor(FALSE); - } -#endif - // get the # of TMUs available grGet(GR_NUM_TMU, 4, (FxI32*)&voodoo.num_tmu); // get maximal texture size grGet(GR_MAX_TEXTURE_SIZE, 4, (FxI32*)&voodoo.max_tex_size); - voodoo.sup_large_tex = (voodoo.max_tex_size > 256 && !(g_settings->hacks & hack_PPL)); + voodoo.sup_large_tex = (voodoo.max_tex_size > 256 && !g_settings->hacks(CSettings::hack_PPL)); //num_tmu = 1; if (voodoo.tex_UMA) @@ -901,7 +554,7 @@ int InitGfx() voodoo.tex_max_addr[1] = grTexMaxAddress(GR_TMU1); } - if (strstr(extensions, "TEXMIRROR") && !(g_settings->hacks&hack_Zelda)) //zelda's trees suffer from hardware mirroring + if (strstr(extensions, "TEXMIRROR") && !g_settings->hacks(CSettings::hack_Zelda)) //zelda's trees suffer from hardware mirroring voodoo.sup_mirroring = 1; else voodoo.sup_mirroring = 0; @@ -915,14 +568,8 @@ int InitGfx() if (strstr(extensions, "GETGAMMA")) grGet(GR_GAMMA_TABLE_ENTRIES, sizeof(voodoo.gamma_table_size), &voodoo.gamma_table_size); - grStippleModeExt = (GRSTIPPLE)grStippleMode; - grStipplePatternExt = (GRSTIPPLE)grStipplePattern; - - if (grStipplePatternExt) - grStipplePatternExt(g_settings->stipple_pattern); - - char strKeyPressedExt[] = "grKeyPressedExt"; - grKeyPressed = (FxBool(FX_CALL *)(FxU32))grGetProcAddress(strKeyPressedExt); + srand(g_settings->stipple_pattern()); + setPattern(); InitCombine(); @@ -946,7 +593,7 @@ int InitGfx() grCullMode(GR_CULL_NEGATIVE); - if (g_settings->fog) //"FOGCOORD" extension + if (g_settings->fog()) //"FOGCOORD" extension { if (strstr(extensions, "FOGCOORD")) { @@ -969,15 +616,15 @@ int InitGfx() grVertexLayout(GR_PARAM_FOG_EXT, offsetof(VERTEX, f), GR_PARAM_ENABLE); } else //not supported - g_settings->fog = FALSE; + { + g_settings->SetFog(FALSE); + } } grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); grDepthBufferFunction(GR_CMP_LESS); grDepthMask(FXTRUE); - g_settings->res_x = g_settings->scr_res_x; - g_settings->res_y = g_settings->scr_res_y; ChangeSize(); guLoadTextures(); @@ -997,56 +644,71 @@ int InitGfx() grTexFilterMode(1, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); grTexClampMode(0, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP); grTexClampMode(1, GR_TEXTURECLAMP_CLAMP, GR_TEXTURECLAMP_CLAMP); - grClipWindow(0, 0, g_settings->scr_res_x, g_settings->scr_res_y); + grClipWindow(0, 0, g_settings->scr_res_x(), g_settings->scr_res_y()); rdp.update |= UPDATE_SCISSOR | UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE; -#ifdef TEXTURE_FILTER // Hiroshi Morii - if (!g_settings->ghq_use) + if (!g_ghq_use) { - g_settings->ghq_use = g_settings->ghq_fltr || g_settings->ghq_enht /*|| g_settings->ghq_cmpr*/ || g_settings->ghq_hirs; - if (g_settings->ghq_use) + g_ghq_use = g_settings->ghq_fltr() != CSettings::TextureFilter_None || g_settings->ghq_enht() != CSettings::TextureEnht_None || g_settings->ghq_hirs() != CSettings::HiResPackFormat_None; + if (g_ghq_use) { /* Plugin path */ - int options = texfltr[g_settings->ghq_fltr] | texenht[g_settings->ghq_enht] | texcmpr[g_settings->ghq_cmpr] | texhirs[g_settings->ghq_hirs]; - if (g_settings->ghq_enht_cmpr) + int options = g_settings->ghq_fltr() | g_settings->ghq_enht() | g_settings->ghq_cmpr() | g_settings->ghq_hirs(); + if (g_settings->ghq_enht_cmpr()) + { options |= COMPRESS_TEX; - if (g_settings->ghq_hirs_cmpr) + } + if (g_settings->ghq_hirs_cmpr()) + { options |= COMPRESS_HIRESTEX; - // if (g_settings->ghq_enht_tile) - // options |= TILE_TEX; - if (g_settings->ghq_hirs_tile) + } + if (g_settings->ghq_hirs_tile()) + { options |= TILE_HIRESTEX; - if (g_settings->ghq_enht_f16bpp) + } + if (g_settings->ghq_enht_f16bpp()) + { options |= FORCE16BPP_TEX; - if (g_settings->ghq_hirs_f16bpp) + } + if (g_settings->ghq_hirs_f16bpp()) + { options |= FORCE16BPP_HIRESTEX; - if (g_settings->ghq_enht_gz) + } + if (g_settings->ghq_enht_gz()) + { options |= GZ_TEXCACHE; - if (g_settings->ghq_hirs_gz) + } + if (g_settings->ghq_hirs_gz()) + { options |= GZ_HIRESTEXCACHE; - if (g_settings->ghq_cache_save) + } + if (g_settings->ghq_cache_save()) + { options |= (DUMP_TEXCACHE | DUMP_HIRESTEXCACHE); - if (g_settings->ghq_hirs_let_texartists_fly) + } + if (g_settings->ghq_hirs_let_texartists_fly()) + { options |= LET_TEXARTISTS_FLY; - if (g_settings->ghq_hirs_dump) + } + if (g_settings->ghq_hirs_dump()) + { options |= DUMP_TEX; + } - ghq_dmptex_toggle_key = 0; - - g_settings->ghq_use = (int)ext_ghq_init(voodoo.max_tex_size, // max texture width supported by hardware + g_ghq_use = (int)ext_ghq_init(voodoo.max_tex_size, // max texture width supported by hardware voodoo.max_tex_size, // max texture height supported by hardware voodoo.sup_32bit_tex ? 32 : 16, // max texture bpp supported by hardware options, - g_settings->ghq_cache_size * 1024 * 1024, // cache texture to system memory - g_settings->texture_dir.c_str(), + g_settings->ghq_cache_size() * 1024 * 1024, // cache texture to system memory + g_settings->texture_dir(), rdp.RomName, // name of ROM. must be no longer than 256 characters DisplayLoadProgress); } } - if (g_settings->ghq_use && strstr(extensions, "TEXMIRROR")) + if (g_ghq_use && strstr(extensions, "TEXMIRROR")) + { voodoo.sup_mirroring = 1; -#endif - + } return TRUE; } @@ -1082,7 +744,6 @@ extern "C" int WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID /*lpReser if (fdwReason == DLL_PROCESS_ATTACH) { hinstDLL = hinst; - SetupTrace(); if (g_ProcessDListCS == NULL) { g_ProcessDListCS = new CriticalSection(); @@ -1103,9 +764,9 @@ extern "C" int WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID /*lpReser void CALL ReadScreen(void **dest, int *width, int *height) { - *width = g_settings->res_x; - *height = g_settings->res_y; - uint8_t * buff = (uint8_t*)malloc(g_settings->res_x * g_settings->res_y * 3); + *width = g_settings->res_x(); + *height = g_settings->res_y(); + uint8_t * buff = (uint8_t*)malloc(g_settings->res_x() * g_settings->res_y() * 3); uint8_t * line = buff; *dest = (void*)buff; @@ -1118,17 +779,17 @@ void CALL ReadScreen(void **dest, int *width, int *height) FXFALSE, &info)) { - uint32_t offset_src = info.strideInBytes*(g_settings->scr_res_y - 1); + uint32_t offset_src = info.strideInBytes*(g_settings->scr_res_y() - 1); // Copy the screen uint8_t r, g, b; if (info.writeMode == GR_LFBWRITEMODE_8888) { uint32_t col; - for (uint32_t y = 0; y < g_settings->res_y; y++) + for (uint32_t y = 0; y < g_settings->res_y(); y++) { uint32_t *ptr = (uint32_t*)((uint8_t*)info.lfbPtr + offset_src); - for (uint32_t x = 0; x < g_settings->res_x; x++) + for (uint32_t x = 0; x < g_settings->res_x(); x++) { col = *(ptr++); r = (uint8_t)((col >> 16) & 0xFF); @@ -1138,17 +799,17 @@ void CALL ReadScreen(void **dest, int *width, int *height) line[x * 3 + 1] = g; line[x * 3 + 2] = r; } - line += g_settings->res_x * 3; + line += g_settings->res_x() * 3; offset_src -= info.strideInBytes; } } else { uint16_t col; - for (uint32_t y = 0; y < g_settings->res_y; y++) + for (uint32_t y = 0; y < g_settings->res_y(); y++) { uint16_t *ptr = (uint16_t*)((uint8_t*)info.lfbPtr + offset_src); - for (uint32_t x = 0; x < g_settings->res_x; x++) + for (uint32_t x = 0; x < g_settings->res_x(); x++) { col = *(ptr++); r = (uint8_t)((float)(col >> 11) / 31.0f * 255.0f); @@ -1158,7 +819,7 @@ void CALL ReadScreen(void **dest, int *width, int *height) line[x * 3 + 1] = g; line[x * 3 + 2] = r; } - line += g_settings->res_x * 3; + line += g_settings->res_x() * 3; offset_src -= info.strideInBytes; } } @@ -1176,8 +837,8 @@ output: none *******************************************************************/ EXPORT void CALL CaptureScreen(char * Directory) { - capture_screen = 1; - capture_path = Directory; + g_capture_screen = true; + g_capture_path = Directory; } /****************************************************************** @@ -1198,24 +859,11 @@ EXPORT void CALL ChangeWindow(void) { to_fullscreen = TRUE; ev_fullscreen = TRUE; -#ifdef __WINDOWS__ - if (gfx.hStatusBar) - ShowWindow(gfx.hStatusBar, SW_HIDE); - ShowCursor(FALSE); -#endif } else { ev_fullscreen = FALSE; InitGfx(); -#ifdef __WINDOWS__ - ShowCursor(TRUE); - if (gfx.hStatusBar) - { - ShowWindow(gfx.hStatusBar, SW_SHOW); - } - SetWindowLongPtr(gfx.hWnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc); -#endif } } else @@ -1226,24 +874,10 @@ EXPORT void CALL ChangeWindow(void) if (!GfxInitDone) { to_fullscreen = TRUE; -#ifdef __WINDOWS__ - if (gfx.hStatusBar) - ShowWindow(gfx.hStatusBar, SW_HIDE); - ShowCursor(FALSE); -#endif } else { ReleaseGfx(); -#ifdef __WINDOWS__ - ShowCursor(TRUE); - if (gfx.hStatusBar) - ShowWindow(gfx.hStatusBar, SW_SHOW); - // SetWindowLong fixes the following Windows XP Banshee issues: - // 1964 crash error when loading another rom. - // All N64 emu's minimize, restore crashes. - SetWindowLongPtr(gfx.hWnd, GWLP_WNDPROC, (LONG_PTR)oldWndProc); -#endif } } } @@ -1259,23 +893,11 @@ void CALL CloseDLL(void) { WriteTrace(TraceGlide64, TraceDebug, "-"); -#ifdef ALTTAB_FIX - if (hhkLowLevelKybd) - { - UnhookWindowsHookEx(hhkLowLevelKybd); - hhkLowLevelKybd = 0; - } -#endif - - //CLOSELOG (); - -#ifdef TEXTURE_FILTER // Hiroshi Morii - if (g_settings->ghq_use) + if (g_ghq_use) { ext_ghq_shutdown(); - g_settings->ghq_use = 0; + g_ghq_use = false; } -#endif if (g_settings) { @@ -1368,15 +990,10 @@ int CALL InitiateGFX(GFX_INFO Gfx_Info) rdp.scale_x = 1.0f; rdp.scale_y = 1.0f; - g_settings = new CSettings; - ReadSettings(); char name[21] = "DEFAULT"; - ReadSpecialSettings(name); -#ifndef ANDROID - g_settings->res_data_org = g_settings->res_data; -#endif - - debug_init(); // Initialize debugger + g_settings->ReadGameSettings(name); + ZLUT_init(); + ConfigWrapper(); gfx = Gfx_Info; @@ -1387,16 +1004,8 @@ int CALL InitiateGFX(GFX_INFO Gfx_Info) CountCombine(); ZLUT_init(); - grConfigWrapperExt( -#ifdef ANDROID - g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic -#else - g_settings->wrpResolution, g_settings->wrpVRAM * 1024 * 1024, g_settings->wrpFBO, g_settings->wrpAnisotropic -#endif - ); - + grConfigWrapperExt(g_settings->wrpVRAM() * 1024 * 1024, g_settings->wrpFBO(), g_settings->wrpAnisotropic()); grGlideInit(); - grSstSelect(0); const char *extensions = grGetString(GR_EXTENSION); grGlideShutdown(); if (strstr(extensions, "EVOODOO")) @@ -1431,129 +1040,15 @@ void CALL MoveScreen(int xpos, int ypos) rdp.window_changed = TRUE; } -#ifdef _WIN32 -int GetCurrentResIndex(void); -#endif - void CALL PluginLoaded(void) { - SetModuleName("default"); - Set_basic_mode = FindSystemSettingId("Basic Mode"); - Set_texture_dir = FindSystemSettingId("Dir:Texture"); - Set_log_flush = FindSystemSettingId("Log Auto Flush"); - Set_log_dir = FindSystemSettingId("Dir:Log"); + if (g_settings == NULL) + { + g_settings = new CSettings; + } SetupTrace(); WriteTrace(TraceInterface, TraceDebug, "Start"); - - SetModuleName("Glide64"); - general_setting(Set_CardId, "card_id", 0); -#ifdef _WIN32 - general_setting(Set_Resolution, "resolution", 7); - general_setting(Set_wrpResolution, "wrpResolution", GetCurrentResIndex()); -#endif - general_setting(Set_vsync, "vsync", 1); - general_setting(Set_ssformat, "ssformat", 1); - general_setting(Set_clock, "clock", 0); - general_setting(Set_clock_24_hr, "clock_24_hr", 0); - general_setting(Set_texenh_options, "texenh_options", 0); - general_setting(Set_hotkeys, "hotkeys", 1); - general_setting(Set_wrpVRAM, "wrpVRAM", 0); -#ifndef ANDROID - general_setting(Set_wrpFBO, "wrpFBO", 0); -#else - general_setting(Set_wrpFBO, "wrpFBO", 1); -#endif - general_setting(Set_Rotate, "rotate", 0); - general_setting(Set_wrpAnisotropic, "wrpAnisotropic", 0); - general_setting(Set_autodetect_ucode, "autodetect_ucode", 1); - general_setting(Set_ucode, "ucode", 2); - general_setting(Set_wireframe, "wireframe", 0); - general_setting(Set_wfmode, "wfmode", 1); - general_setting(Set_logging, "logging", 0); - general_setting(Set_log_clear, "log_clear", 0); - general_setting(Set_run_in_window, "run_in_window", 0); - general_setting(Set_elogging, "elogging", 0); - general_setting(Set_filter_cache, "filter_cache", 0); - general_setting(Set_unk_as_red, "unk_as_red", 0); - general_setting(Set_log_unk, "log_unk", 0); - general_setting(Set_unk_clear, "unk_clear", 0); - general_setting(Set_ghq_fltr, "ghq_fltr", 0); - general_setting(Set_ghq_cmpr, "ghq_cmpr", 0); - general_setting(Set_ghq_enht, "ghq_enht", 0); - general_setting(Set_ghq_hirs, "ghq_hirs", 0); - general_setting(Set_ghq_enht_cmpr, "ghq_enht_cmpr", 0); - general_setting(Set_ghq_enht_tile, "ghq_enht_tile", 0); - general_setting(Set_ghq_enht_f16bpp, "ghq_enht_f16bpp", 0); - general_setting(Set_ghq_enht_gz, "ghq_enht_gz", 1); - general_setting(Set_ghq_enht_nobg, "ghq_enht_nobg", 0); - general_setting(Set_ghq_hirs_cmpr, "ghq_hirs_cmpr", 0); - general_setting(Set_ghq_hirs_tile, "ghq_hirs_tile", 0); - general_setting(Set_ghq_hirs_f16bpp, "ghq_hirs_f16bpp", 0); - general_setting(Set_ghq_hirs_gz, "ghq_hirs_gz", 1); - general_setting(Set_ghq_hirs_altcrc, "ghq_hirs_altcrc", 1); - general_setting(Set_ghq_cache_save, "ghq_cache_save", 1); - general_setting(Set_ghq_cache_size, "ghq_cache_size", 0); - general_setting(Set_ghq_hirs_let_texartists_fly, "ghq_hirs_let_texartists_fly", 0); - general_setting(Set_ghq_hirs_dump, "ghq_hirs_dump", 0); - - general_setting(Set_optimize_texrect_default, "optimize_texrect", 1); - general_setting(Set_filtering_default, "filtering", 0); - general_setting(Set_lodmode_default, "lodmode", 0); - general_setting(Set_fog_default, "fog", 1); - general_setting(Set_buff_clear_default, "buff_clear", 1); - general_setting(Set_swapmode_default, "swapmode", 1); - general_setting(Set_aspect_default, "aspect", 0); - - general_setting(Set_fb_smart_default, "fb_smart", 1); - general_setting(Set_fb_hires_default, "fb_hires", 1); - general_setting(Set_fb_read_always_default, "fb_read_always", 0); - general_setting(Set_read_back_to_screen_default, "read_back_to_screen", 0); - general_setting(Set_detect_cpu_write_default, "detect_cpu_write", 0); - general_setting(Set_fb_get_info_default, "fb_get_info", 0); - general_setting(Set_fb_render_default, "fb_render", 0); - - game_setting(Set_alt_tex_size, "alt_tex_size", 0); - game_setting(Set_use_sts1_only, "use_sts1_only", 0); - game_setting(Set_force_calc_sphere, "force_calc_sphere", 0); - game_setting(Set_correct_viewport, "correct_viewport", 0); - game_setting(Set_increase_texrect_edge, "increase_texrect_edge", 0); - game_setting(Set_decrease_fillrect_edge, "decrease_fillrect_edge", 0); - game_setting(Set_texture_correction, "texture_correction", 1); - game_setting(Set_pal230, "pal230", 0); - game_setting(Set_stipple_mode, "stipple_mode", 2); - - game_setting(Set_stipple_pattern, "stipple_pattern", 0x3E0F83E0); - game_setting(Set_force_microcheck, "force_microcheck", 0); - game_setting(Set_force_quad3d, "force_quad3d", 0); - game_setting(Set_clip_zmin, "clip_zmin", 0); - game_setting(Set_clip_zmax, "clip_zmax", 1); - game_setting(Set_fast_crc, "fast_crc", 1); - game_setting(Set_adjust_aspect, "adjust_aspect", 1); - game_setting(Set_zmode_compare_less, "zmode_compare_less", 0); - game_setting(Set_old_style_adither, "old_style_adither", 0); - game_setting(Set_n64_z_scale, "n64_z_scale", 0); - game_setting_default(Set_optimize_texrect, "optimize_texrect", Set_optimize_texrect_default); - game_setting(Set_ignore_aux_copy, "ignore_aux_copy", (unsigned int)-1); - game_setting(Set_hires_buf_clear, "hires_buf_clear", 1); - game_setting(Set_fb_read_alpha, "fb_read_alpha", 0); - game_setting(Set_useless_is_useless, "useless_is_useless", (unsigned int)-1); - game_setting(Set_fb_crc_mode, "fb_crc_mode", 1); - game_setting_default(Set_filtering, "filtering", Set_filtering_default); - game_setting_default(Set_fog, "fog", Set_fog_default); - game_setting_default(Set_buff_clear, "buff_clear", Set_buff_clear_default); - game_setting_default(Set_swapmode, "swapmode", Set_swapmode_default); - game_setting_default(Set_aspect, "aspect", Set_aspect_default); - game_setting_default(Set_lodmode, "lodmode", Set_lodmode_default); - - game_setting_default(Set_fb_smart, "fb_smart", Set_fb_smart_default); - game_setting_default(Set_fb_hires, "fb_hires", Set_fb_hires_default); - game_setting_default(Set_fb_read_always, "fb_read_always", Set_fb_read_always_default); - game_setting_default(Set_read_back_to_screen, "read_back_to_screen", Set_read_back_to_screen_default); - game_setting_default(Set_detect_cpu_write, "detect_cpu_write", Set_detect_cpu_write_default); - game_setting_default(Set_fb_get_info, "fb_get_info", Set_fb_get_info_default); - game_setting_default(Set_fb_render, "fb_render", Set_fb_render_default); - WriteTrace(TraceInterface, TraceDebug, "Done"); } @@ -1615,7 +1110,7 @@ void CALL RomOpen(void) WriteTrace(TraceGlide64, TraceDebug, "-"); no_dlist = true; g_romopen = TRUE; - ucode_error_report = TRUE; // allowed to report ucode errors + g_ucode_error_report = TRUE; // allowed to report ucode errors rdp_reset(); // Get the country code & translate to NTSC(0) or PAL(1) @@ -1651,13 +1146,13 @@ void CALL RomOpen(void) name[strlen(name) - 1] = 0; } - if (g_settings->ghq_use && strcmp(rdp.RomName, name) != 0) + if (g_ghq_use && strcmp(rdp.RomName, name) != 0) { ext_ghq_shutdown(); - g_settings->ghq_use = 0; + g_ghq_use = false; } strcpy(rdp.RomName, name); - ReadSpecialSettings(name); + g_settings->ReadGameSettings(name); ClearCache(); CheckDRAMSize(); @@ -1666,7 +1161,6 @@ void CALL RomOpen(void) if (!GfxInitDone) { grGlideInit(); - grSstSelect(0); } const char *extensions = grGetString(GR_EXTENSION); grGlideShutdown(); @@ -1678,15 +1172,6 @@ void CALL RomOpen(void) if (evoodoo) InitGfx(); - - if (strstr(extensions, "ROMNAME")) - { - char strSetRomName[] = "grSetRomName"; - void (FX_CALL *grSetRomName)(char*); - grSetRomName = (void (FX_CALL *)(char*))grGetProcAddress(strSetRomName); - grSetRomName(name); - } - // ** } /****************************************************************** @@ -1707,9 +1192,8 @@ void CALL ShowCFB(void) void drawViRegBG() { WriteTrace(TraceGlide64, TraceDebug, "start"); - const uint32_t VIwidth = *gfx.VI_WIDTH_REG; FB_TO_SCREEN_INFO fb_info; - fb_info.width = VIwidth; + fb_info.width = *gfx.VI_WIDTH_REG; fb_info.height = (uint32_t)rdp.vi_height; if (fb_info.height == 0) { @@ -1718,7 +1202,7 @@ void drawViRegBG() } fb_info.ul_x = 0; - fb_info.lr_x = VIwidth - 1; + fb_info.lr_x = fb_info.width - 1; // fb_info.lr_x = (uint32_t)rdp.vi_width - 1; fb_info.ul_y = 0; fb_info.lr_y = fb_info.height - 1; @@ -1728,7 +1212,7 @@ void drawViRegBG() rdp.last_bg = fb_info.addr; bool drawn = DrawFrameBufferToScreen(fb_info); - if (g_settings->hacks&hack_Lego && drawn) + if (g_settings->hacks(CSettings::hack_Lego) && drawn) { rdp.updatescreen = 1; newSwapBuffers(); @@ -1766,8 +1250,8 @@ void CALL UpdateScreen(void) { update_screen_count++; } - uint32_t limit = (g_settings->hacks&hack_Lego) ? 15 : 30; - if ((g_settings->frame_buffer&fb_cpu_write_hack) && (update_screen_count > limit) && (rdp.last_bg == 0)) + uint32_t limit = g_settings->hacks(CSettings::hack_Lego) ? 15 : 30; + if (g_settings->fb_cpu_write_hack_enabled() && (update_screen_count > limit) && (rdp.last_bg == 0)) { WriteTrace(TraceRDP, TraceDebug, "DirectCPUWrite hack!"); update_screen_count = 0; @@ -1789,17 +1273,23 @@ void CALL UpdateScreen(void) } return; } - if (g_settings->swapmode == 0) + if (g_settings->swapmode() == CSettings::SwapMode_Old) + { newSwapBuffers(); + } } static void DrawWholeFrameBufferToScreen() { static uint32_t toScreenCI = 0; if (rdp.ci_width < 200) + { return; + } if (rdp.cimg == toScreenCI) + { return; + } toScreenCI = rdp.cimg; FB_TO_SCREEN_INFO fb_info; fb_info.addr = rdp.cimg; @@ -1807,15 +1297,19 @@ static void DrawWholeFrameBufferToScreen() fb_info.width = rdp.ci_width; fb_info.height = rdp.ci_height; if (fb_info.height == 0) + { return; + } fb_info.ul_x = 0; fb_info.lr_x = rdp.ci_width - 1; fb_info.ul_y = 0; fb_info.lr_y = rdp.ci_height - 1; fb_info.opaque = 0; DrawFrameBufferToScreen(fb_info); - if (!(g_settings->frame_buffer & fb_ref)) + if (!g_settings->fb_ref_enabled()) + { memset(gfx.RDRAM + rdp.cimg, 0, (rdp.ci_width*rdp.ci_height) << rdp.ci_size >> 1); + } } static void GetGammaTable() @@ -1939,85 +1433,14 @@ void newSwapBuffers() WriteTrace(TraceRDP, TraceDebug, "swapped"); rdp.update |= UPDATE_SCISSOR | UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE; - grClipWindow(0, 0, g_settings->scr_res_x, g_settings->scr_res_y); + grClipWindow(0, 0, g_settings->scr_res_x(), g_settings->scr_res_y()); grDepthBufferFunction(GR_CMP_ALWAYS); grDepthMask(FXFALSE); grCullMode(GR_CULL_DISABLE); - if (g_settings->clock) + if (g_capture_screen) { - set_message_combiner(); - if (g_settings->clock_24_hr) - { - output(956.0f, 0, 1, CDateTime().SetToNow().Format("%H:%M:%S").c_str(), 0); - } - else - { - output(930.0f, 0, 1, CDateTime().SetToNow().Format("%I:%M:%S %p").c_str(), 0); - } - } - //hotkeys - if ((abs((int)(frame_count - curframe)) > 3) && CheckKeyPressed(G64_VK_ALT, 0x8000)) //alt + - { - if (CheckKeyPressed(G64_VK_B, 0x8000)) //b - { - hotkey_info.hk_motionblur = 100; - hotkey_info.hk_ref = 0; - curframe = frame_count; - g_settings->frame_buffer ^= fb_motionblur; - } - else if (CheckKeyPressed(G64_VK_V, 0x8000)) //v - { - hotkey_info.hk_ref = 100; - hotkey_info.hk_motionblur = 0; - curframe = frame_count; - g_settings->frame_buffer ^= fb_ref; - } - } - if (hotkey_info.hk_ref || hotkey_info.hk_motionblur || hotkey_info.hk_filtering) - { - set_message_combiner(); - char buf[256]; - buf[0] = 0; - char * message = 0; - if (hotkey_info.hk_ref) - { - if (g_settings->frame_buffer & fb_ref) - message = strcat(buf, "FB READ ALWAYS: ON"); - else - message = strcat(buf, "FB READ ALWAYS: OFF"); - hotkey_info.hk_ref--; - } - if (hotkey_info.hk_motionblur) - { - if (g_settings->frame_buffer & fb_motionblur) - message = strcat(buf, " MOTION BLUR: ON"); - else - message = strcat(buf, " MOTION BLUR: OFF"); - hotkey_info.hk_motionblur--; - } - if (hotkey_info.hk_filtering) - { - switch (g_settings->filtering) - { - case 0: - message = strcat(buf, " FILTERING MODE: AUTOMATIC"); - break; - case 1: - message = strcat(buf, " FILTERING MODE: FORCE BILINEAR"); - break; - case 2: - message = strcat(buf, " FILTERING MODE: FORCE POINT-SAMPLED"); - break; - } - hotkey_info.hk_filtering--; - } - output(120.0f, 0.0f, 1, message, 0); - } - - if (capture_screen) - { - CPath path(capture_path); + CPath path(g_capture_path); if (!path.DirectoryExists()) { path.DirectoryCreate(); @@ -2026,13 +1449,9 @@ void newSwapBuffers() romName.Replace(" ", "_"); romName.Replace(":", ";"); - if (g_settings->ssformat >= NumOfFormats) - { - g_settings->ssformat = 0; - } for (int i = 1;; i++) { - stdstr_f filename("Glide64_%s_%s%d.%s", romName.c_str(), i < 10 ? "0" : "", i, ScreenShotFormats[g_settings->ssformat].extension); + stdstr_f filename("Glide64_%s_%s%d.png", romName.c_str(), i < 10 ? "0" : "", i); path.SetNameExtension(filename.c_str()); if (!path.Exists()) { @@ -2042,8 +1461,8 @@ void newSwapBuffers() const uint32_t offset_x = (uint32_t)rdp.offset_x; const uint32_t offset_y = (uint32_t)rdp.offset_y; - const uint32_t image_width = g_settings->scr_res_x - offset_x * 2; - const uint32_t image_height = g_settings->scr_res_y - offset_y * 2; + const uint32_t image_width = g_settings->scr_res_x() - offset_x * 2; + const uint32_t image_height = g_settings->scr_res_y() - offset_y * 2; GrLfbInfo_t info; info.size = sizeof(GrLfbInfo_t); @@ -2091,76 +1510,22 @@ void newSwapBuffers() } // Unlock the backbuffer grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER); - if (ScreenShotFormats[g_settings->ssformat].type == rdpBITMAP_TYPE_PNG) - { - write_png_file(path, image_width, image_height, ssimg); - } - capture_screen = 0; + write_png_file(path, image_width, image_height, ssimg); + g_capture_screen = false; } } - // Capture the screen if debug capture is set - if (_debugger.capture) + if (g_settings->fb_read_back_to_screen_enabled()) { - // Allocate the screen - _debugger.screen = new uint8_t[(g_settings->res_x*g_settings->res_y) << 1]; - - // Lock the backbuffer (already rendered) - GrLfbInfo_t info; - info.size = sizeof(GrLfbInfo_t); - while (!grLfbLock(GR_LFB_READ_ONLY, - GR_BUFFER_BACKBUFFER, - GR_LFBWRITEMODE_565, - GR_ORIGIN_UPPER_LEFT, - FXFALSE, - &info)); - - uint32_t offset_src = 0, offset_dst = 0; - - // Copy the screen - for (uint32_t y = 0; y < g_settings->res_y; y++) - { - if (info.writeMode == GR_LFBWRITEMODE_8888) - { - uint32_t *src = (uint32_t*)((uint8_t*)info.lfbPtr + offset_src); - uint16_t *dst = (uint16_t*)(_debugger.screen + offset_dst); - uint8_t r, g, b; - uint32_t col; - for (unsigned int x = 0; x < g_settings->res_x; x++) - { - col = src[x]; - r = (uint8_t)((col >> 19) & 0x1F); - g = (uint8_t)((col >> 10) & 0x3F); - b = (uint8_t)((col >> 3) & 0x1F); - dst[x] = (r << 11) | (g << 5) | b; - } - } - else - { - memcpy(_debugger.screen + offset_dst, (uint8_t*)info.lfbPtr + offset_src, g_settings->res_x << 1); - } - offset_dst += g_settings->res_x << 1; - offset_src += info.strideInBytes; - } - - // Unlock the backbuffer - grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_BACKBUFFER); - } - - if (debugging) - { - debug_keys(); - debug_cacheviewer(); - debug_mouse(); - } - - if (g_settings->frame_buffer & fb_read_back_to_screen) DrawWholeFrameBufferToScreen(); + } - if (fb_hwfbe_enabled && !(g_settings->hacks&hack_RE2) && !evoodoo) + if (g_settings->fb_hwfbe_enabled() && !g_settings->hacks(CSettings::hack_RE2) && !evoodoo) + { grAuxBufferExt(GR_BUFFER_AUXBUFFER); + } WriteTrace(TraceGlide64, TraceDebug, "BUFFER SWAPPED"); - grBufferSwap(g_settings->vsync); + grBufferSwap(g_settings->vsync()); if (*gfx.VI_STATUS_REG & 0x08) //gamma correction is used { if (!voodoo.gamma_correction) @@ -2183,65 +1548,17 @@ void newSwapBuffers() } } - if (_debugger.capture) - debug_capture(); - - if (debugging || g_settings->wireframe || g_settings->buff_clear || (g_settings->hacks&hack_PPL && g_settings->ucode == 6)) + if (g_settings->wireframe() || g_settings->buff_clear() || (g_settings->hacks(CSettings::hack_PPL) && g_settings->ucode() == CSettings::ucode_S2DEX)) { - if (g_settings->hacks&hack_RE2 && fb_depth_render_enabled) - grDepthMask(FXFALSE); - else - grDepthMask(FXTRUE); + grDepthMask((g_settings->hacks(CSettings::hack_RE2) && g_settings->fb_depth_render_enabled()) ? FXFALSE : FXTRUE); grBufferClear(0, 0, 0xFFFF); } - /* //let the game to clear the buffers - else - { - grDepthMask (FXTRUE); - grColorMask (FXFALSE, FXFALSE); - grBufferClear (0, 0, 0xFFFF); - grColorMask (FXTRUE, FXTRUE); - } - */ - if (g_settings->frame_buffer & fb_read_back_to_screen2) + if (g_settings->fb_read_back_to_screen2_enabled()) { DrawWholeFrameBufferToScreen(); } frame_count++; - - // Open/close debugger? - if (CheckKeyPressed(G64_VK_SCROLL, 0x0001)) - { - if (!debugging) - { - //if (g_settings->scr_res_x == 1024 && g_settings->scr_res_y == 768) - { - debugging = 1; - - // Recalculate screen size, don't resize screen - g_settings->res_x = (uint32_t)(g_settings->scr_res_x * 0.625f); - g_settings->res_y = (uint32_t)(g_settings->scr_res_y * 0.625f); - - ChangeSize(); - } - } - else - { - debugging = 0; - - g_settings->res_x = g_settings->scr_res_x; - g_settings->res_y = g_settings->scr_res_y; - - ChangeSize(); - } - } - - // Debug capture? - if (/*fullscreen && */debugging && CheckKeyPressed(G64_VK_INSERT, 0x0001)) - { - _debugger.capture = 1; - } } /****************************************************************** @@ -2283,82 +1600,12 @@ Purpose: this function is called when the surface is has changed. input: none output: none *******************************************************************/ -void init_combiner(); - void CALL SurfaceChanged(int width, int height) { - g_width = width; - g_height = height; -} -#endif - -int CheckKeyPressed(int key, int mask) -{ - static Glide64Keys g64Keys; - if (g_settings->use_hotkeys == 0) - return 0; -#ifdef __WINDOWS__ - return (GetAsyncKeyState(g64Keys[key]) & mask); -#else - if (grKeyPressed) - return grKeyPressed(g64Keys[key]); - return 0; -#endif + g_NativeWidth = width; + g_NativeHeight = height; } -#ifdef ALTTAB_FIX -int k_ctl = 0, k_alt = 0, k_del = 0; - -LRESULT CALLBACK LowLevelKeyboardProc(int nCode, - WPARAM wParam, LPARAM lParam) -{ - if (!fullscreen) return CallNextHookEx(NULL, nCode, wParam, lParam); - - int TabKey = FALSE; - - PKBDLLHOOKSTRUCT p; - - if (nCode == HC_ACTION) - { - switch (wParam) { - case WM_KEYUP: case WM_SYSKEYUP: - p = (PKBDLLHOOKSTRUCT) lParam; - if (p->vkCode == 162) k_ctl = 0; - if (p->vkCode == 164) k_alt = 0; - if (p->vkCode == 46) k_del = 0; - goto do_it; - - case WM_KEYDOWN: case WM_SYSKEYDOWN: - p = (PKBDLLHOOKSTRUCT) lParam; - if (p->vkCode == 162) k_ctl = 1; - if (p->vkCode == 164) k_alt = 1; - if (p->vkCode == 46) k_del = 1; - goto do_it; - - do_it: - TabKey = - ((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) || - ((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0)) || - ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000) != 0)) || - (k_ctl && k_alt && k_del); - - break; - } - } - - if (TabKey) - { - k_ctl = 0; - k_alt = 0; - k_del = 0; - ReleaseGfx (); - } - - return CallNextHookEx(NULL, nCode, wParam, lParam); -} -#endif - -#ifdef ANDROID void Android_JNI_SwapWindow() { gfx.SwapBuffers(); diff --git a/Source/Glide64/ScreenResolution.cpp b/Source/Glide64/ScreenResolution.cpp new file mode 100644 index 000000000..962819ec5 --- /dev/null +++ b/Source/Glide64/ScreenResolution.cpp @@ -0,0 +1,337 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#include "ScreenResolution.h" +#include "settings.h" +#include "trace.h" + +#ifdef ANDROID +extern uint32_t g_NativeWidth, g_NativeHeight; +#endif + +struct ResolutionInfo +{ + ResolutionInfo(const char * name = NULL, uint32_t width = 0, uint32_t height = 0, uint32_t frequency = 0, bool default_res = false) : + m_name(name), + m_width(width), + m_height(height), + m_frequency(frequency), + m_default_res(default_res) + { + } + + const char * Name(void) const { return m_name; } + uint32_t width(void) const { return m_width; } + uint32_t height(void) const { return m_height; } + uint32_t frequency(void) const { return m_frequency; } + bool DefaultRes(void) const { return m_default_res; } + + bool operator == (const ResolutionInfo& rRes) const + { + return m_width == rRes.m_width && m_height == rRes.m_height && m_frequency == rRes.m_frequency; + } + bool operator != (const ResolutionInfo& rRes) const + { + return !(*this == rRes); + } +private: + uint32_t m_width, m_height, m_frequency; + const char * m_name; + bool m_default_res; +}; + +#ifdef ANDROID +static ResolutionInfo g_resolutions[] = +{ + ResolutionInfo("#3200#", 0, 0, 0, true), + ResolutionInfo("960x720", 960, 720, 0, false), + ResolutionInfo("800x600", 800, 600, 0, false), + ResolutionInfo("640x480", 640, 480, 0, false), + ResolutionInfo("480x360", 480, 360, 0, false), + ResolutionInfo("320x240", 320, 240, 0, false), +}; + +#else +static ResolutionInfo g_resolutions[] = +{ + { "320x200", 320, 200, 0, false }, + { "320x240", 320, 240, 0, false }, + { "400x256", 400, 256, 0, false }, + { "512x384", 512, 384, 0, false }, + { "640x200", 640, 200, 0, false }, + { "640x350", 640, 350, 0, false }, + { "640x400", 640, 400, 0, false }, + { "640x480", 640, 480, 0, true }, + { "800x600", 800, 600, 0, false }, + { "960x720", 960, 720, 0, false }, + { "856x480", 856, 480, 0, false }, + { "512x256", 512, 256, 0, false }, + { "1024x768", 1024, 768, 0, false }, + { "1280x1024", 1280, 1024, 0, false }, + { "1600x1200", 1600, 1200, 0, false }, + { "400x300", 400, 300, 0, false }, + { "1152x864", 1152, 864, 0, false }, + { "1280x960", 1280, 960, 0, false }, + { "1600x1024", 1600, 1024, 0, false }, + { "1792x1344", 1792, 1344, 0, false }, + { "1856x1392", 1856, 1392, 0, false }, + { "1920x1440", 1920, 1440, 0, false }, + { "2048x1536", 2048, 1536, 0, false }, + { "2048x2048", 2048, 2048, 0, false }, +}; +#endif + +uint32_t GetScreenResolutionCount() +{ + return sizeof(g_resolutions) / sizeof(g_resolutions[0]); +} + +const char * GetScreenResolutionName(uint32_t index) +{ + if (index < GetScreenResolutionCount()) + { + return g_resolutions[index].Name(); + } + return "unknown"; +} + +uint32_t GetDefaultScreenRes() +{ + for (uint32_t i = 0, n = GetScreenResolutionCount(); i < n; i++) + { + if (g_resolutions[i].DefaultRes()) + { + return i; + } + } + return 0; +} + +uint32_t GetScreenResWidth(uint32_t index) +{ + if (index < GetScreenResolutionCount()) + { +#ifdef ANDROID + if (g_resolutions[index].width() == 0) + { + return g_NativeWidth; + } +#endif + return g_resolutions[index].width(); + } + return 0; +} + +uint32_t GetScreenResHeight(uint32_t index) +{ + if (index < GetScreenResolutionCount()) + { +#ifdef ANDROID + if (g_resolutions[index].height() == 0) + { + return g_NativeHeight; + } +#endif + return g_resolutions[index].height(); + } + return 0; +} + +class FullScreenResolutions +{ +public: + FullScreenResolutions() : + m_dwNumResolutions(0), + m_aResolutions(0), + m_aResolutionsStr(0) + { + } + ~FullScreenResolutions(); + + void getResolution(uint32_t _idx, uint32_t * _width, uint32_t * _height, uint32_t * _frequency = 0) + { + WriteTrace(TraceResolution, TraceDebug, "_idx: %d", _idx); + if (m_dwNumResolutions == 0) + { + init(); + } + if (_idx >= m_dwNumResolutions) + { + WriteTrace(TraceGlitch, TraceError, "NumResolutions = %d", m_dwNumResolutions); + _idx = 0; + } + *_width = (uint32_t)m_aResolutions[_idx].width(); + *_height = (uint32_t)m_aResolutions[_idx].height(); + if (_frequency != 0) + { + *_frequency = (uint32_t)m_aResolutions[_idx].frequency(); + } + } + + int getCurrentResolutions(void) + { + if (m_dwNumResolutions == 0) + { + init(); + } + return m_currentResolutions; + } + + char ** getResolutionsList(int32_t * Size) + { + if (m_dwNumResolutions == 0) + { + init(); + } + *Size = (int32_t)m_dwNumResolutions; + return m_aResolutionsStr; + } + + bool changeDisplaySettings(uint32_t _resolution); + +private: + void init(); + unsigned int m_dwNumResolutions; + ResolutionInfo * m_aResolutions; + char ** m_aResolutionsStr; + int m_currentResolutions; +}; + +FullScreenResolutions::~FullScreenResolutions() +{ + for (unsigned int i = 0; i < m_dwNumResolutions; i++) + { + delete[] m_aResolutionsStr[i]; + m_aResolutionsStr[i] = NULL; + } + if (m_aResolutionsStr) + { + delete[] m_aResolutionsStr; + m_aResolutionsStr = NULL; + } + if (m_aResolutions) + { + delete[] m_aResolutions; + m_aResolutions = NULL; + } +} + +void FullScreenResolutions::init() +{ +#ifdef _WIN32 + m_currentResolutions = -1; + DEVMODE enumMode, currentMode; + int iModeNum = 0; + memset(&enumMode, 0, sizeof(DEVMODE)); + + EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, ¤tMode); + + ResolutionInfo prevInfo; + while (EnumDisplaySettings(NULL, iModeNum++, &enumMode) != 0) + { + ResolutionInfo curInfo("", enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency); + if (enumMode.dmBitsPerPel == 32 && curInfo != prevInfo) + { + m_dwNumResolutions++; + prevInfo = curInfo; + } + } + + m_aResolutions = new ResolutionInfo[m_dwNumResolutions]; + m_aResolutionsStr = new char*[m_dwNumResolutions]; + iModeNum = 0; + int current = 0; + char smode[256]; + memset(&enumMode, 0, sizeof(DEVMODE)); + memset(&prevInfo, 0, sizeof(ResolutionInfo)); + while (EnumDisplaySettings(NULL, iModeNum++, &enumMode) != 0) + { + ResolutionInfo curInfo(NULL, enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency); + if (enumMode.dmBitsPerPel == 32 && curInfo != prevInfo) + { + if (enumMode.dmPelsHeight == currentMode.dmPelsHeight && enumMode.dmPelsWidth == currentMode.dmPelsWidth) + { + m_currentResolutions = current; + } + m_aResolutions[current] = curInfo; + sprintf(smode, curInfo.frequency() > 0 ? "%ix%i 32bpp %iHz" : "%ix%i 32bpp", curInfo.width(), curInfo.height(), curInfo.frequency()); + m_aResolutionsStr[current] = new char[strlen(smode) + 1]; + strcpy(m_aResolutionsStr[current], smode); + prevInfo = curInfo; + current++; + } + } +#endif +} + +bool FullScreenResolutions::changeDisplaySettings(uint32_t _resolution) +{ +#ifdef _WIN32 + uint32_t width, height, frequency; + getResolution(_resolution, &width, &height, &frequency); + ResolutionInfo info(NULL, width, height, frequency); + DEVMODE enumMode; + int iModeNum = 0; + memset(&enumMode, 0, sizeof(DEVMODE)); + while (EnumDisplaySettings(NULL, iModeNum++, &enumMode) != 0) + { + ResolutionInfo curInfo(NULL, enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency); + if (enumMode.dmBitsPerPel == 32 && curInfo == info) { + bool bRes = ChangeDisplaySettings(&enumMode, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL; + WriteTrace(TraceGlitch, TraceDebug, "width=%d, height=%d, freq=%d %s\r\n", enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency, bRes ? "Success" : "Failed"); + return bRes; + } + } + return false; +#else // _WIN32 + return false; +#endif // _WIN32 +} + +FullScreenResolutions g_FullScreenResolutions; + +uint32_t GetFullScreenResWidth(uint32_t index) +{ + uint32_t _width, _height; + g_FullScreenResolutions.getResolution(index, &_width, &_height); + return _width; +} + +uint32_t GetFullScreenResHeight(uint32_t index) +{ + uint32_t _width, _height; + g_FullScreenResolutions.getResolution(index, &_width, &_height); + return _height; +} + +bool EnterFullScreen(uint32_t index) +{ + return g_FullScreenResolutions.changeDisplaySettings(index); +} + +int GetCurrentResIndex(void) +{ + return g_FullScreenResolutions.getCurrentResolutions(); +} + +#ifndef ANDROID +char ** grQueryResolutionsExt(int32_t * Size) +{ + WriteTrace(TraceGlitch, TraceDebug, "-"); + return g_FullScreenResolutions.getResolutionsList(Size); +} + +uint32_t grWrapperFullScreenResolutionExt(uint32_t * width, uint32_t * height) +{ + WriteTrace(TraceGlitch, TraceDebug, "-"); + g_FullScreenResolutions.getResolution(g_settings->FullScreenRes(), width, height); + return g_settings->FullScreenRes(); +} +#endif \ No newline at end of file diff --git a/Source/Glide64/ScreenResolution.h b/Source/Glide64/ScreenResolution.h new file mode 100644 index 000000000..81d0cab67 --- /dev/null +++ b/Source/Glide64/ScreenResolution.h @@ -0,0 +1,23 @@ +/**************************************************************************** +* * +* Project64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#pragma once +#include + +uint32_t GetScreenResolutionCount(); +uint32_t GetDefaultScreenRes(); +uint32_t GetScreenResWidth(uint32_t index); +uint32_t GetScreenResHeight(uint32_t index); +const char * GetScreenResolutionName(uint32_t index); + +int GetCurrentResIndex(void); +uint32_t GetFullScreenResWidth(uint32_t index); +uint32_t GetFullScreenResHeight(uint32_t index); +bool EnterFullScreen(uint32_t index); diff --git a/Source/Glide64/Settings.cpp b/Source/Glide64/Settings.cpp index b08114e87..8e216bc4f 100644 --- a/Source/Glide64/Settings.cpp +++ b/Source/Glide64/Settings.cpp @@ -1,101 +1,921 @@ +#include +#include #include "Gfx_1.3.h" +#include "ScreenResolution.h" +#include "SettingsID.h" + +extern int g_width, g_height; CSettings::CSettings() : -card_id(0), -res_x(640), -scr_res_x(640), -res_y(480), -scr_res_y(480), -#ifndef ANDROID -res_data(GR_RESOLUTION_640x480), -res_data_org(GR_RESOLUTION_640x480), -#endif -advanced_options(0), -texenh_options(0), -ssformat(0), -vsync(0), + m_Set_basic_mode(0), + m_Set_texture_dir(0), + m_Set_log_dir(0), + m_Set_log_flush(0), + m_dirty(false), + m_res_x(GetScreenResWidth(GetDefaultScreenRes())), + m_scr_res_x(GetScreenResWidth(GetDefaultScreenRes())), + m_res_y(GetScreenResHeight(GetDefaultScreenRes())), + m_scr_res_y(GetScreenResHeight(GetDefaultScreenRes())), + m_ScreenRes(GetDefaultScreenRes()), + m_advanced_options(false), + m_texenh_options(false), + m_vsync(false), + m_rotate(Rotate_None), + m_filtering(Filter_Automatic), + m_fog(false), + m_buff_clear(false), + m_swapmode(SwapMode_Old), + m_lodmode(LOD_Off), + m_aspectmode(Aspect_4x3), + m_frame_buffer(0), + m_fb_crc_mode(fbcrcFast), + //Texture filtering options + m_texture_dir(""), + m_ghq_fltr(TextureFilter_None), + m_ghq_enht(TextureEnht_None), + m_ghq_cmpr(TextureCompression_S3TC), + m_ghq_hirs(HiResPackFormat_None), + m_ghq_enht_cmpr(false), + m_ghq_enht_f16bpp(false), + m_ghq_enht_gz(false), + m_ghq_enht_nobg(false), + m_ghq_hirs_cmpr(false), + m_ghq_hirs_tile(false), + m_ghq_hirs_f16bpp(false), + m_ghq_hirs_gz(false), + m_ghq_hirs_altcrc(false), + m_ghq_cache_save(false), + m_ghq_cache_size(0), + m_ghq_hirs_let_texartists_fly(false), + m_ghq_hirs_dump(false), + m_autodetect_ucode(true), + m_ucode(ucode_Fast3D), + m_unk_as_red(false), + m_wireframe(false), + m_wfmode(wfmode_VertexColors), -clock(0), -clock_24_hr(0), -rotate(0), + // Special fixes + m_fast_crc(false), + m_alt_tex_size(false), + m_use_sts1_only(false), + m_flame_corona(false), //hack for zeldas flame's corona + m_increase_texrect_edge(false), // add 1 to lower right corner coordinates of texrect + m_decrease_fillrect_edge(false), // sub 1 from lower right corner coordinates of fillrect + m_texture_correction(false), // enable perspective texture correction emulation. is on by default + m_stipple_mode(STIPPLE_Disable), //used for dithered alpha emulation + m_stipple_pattern(0), //used for dithered alpha emulation + m_force_microcheck(false), //check microcode each frame, for mixed F3DEX-S2DEX games + m_force_quad3d(false), //force 0xb5 command to be quad, not line 3d + m_clip_zmin(false), //enable near z clipping + m_clip_zmax(false), //enable far plane clipping; + m_adjust_aspect(false), //adjust screen aspect for wide screen mode + m_force_calc_sphere(false), //use spheric mapping only, Ridge Racer 64 + m_pal230(false), //set special scale for PAL games + m_correct_viewport(false), //correct viewport values + m_zmode_compare_less(false), //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) + m_old_style_adither(false), //apply alpha dither regardless of alpha_dither_mode + m_n64_z_scale(false), //scale vertex z value before writing to depth buffer, as N64 does. -filtering(0), -fog(0), -buff_clear(0), -swapmode(0), -lodmode(0), -aspectmode(0), -use_hotkeys(0), -#ifdef TEXTURE_FILTER -//Texture filtering options -texture_dir(""), -ghq_fltr(0), -ghq_enht(0), -ghq_cmpr(0), -ghq_hirs(0), -ghq_use(0), -ghq_enht_cmpr(0), -ghq_enht_tile(0), -ghq_enht_f16bpp(0), -ghq_enht_gz(0), -ghq_enht_nobg(0), -ghq_hirs_cmpr(0), -ghq_hirs_tile(0), -ghq_hirs_f16bpp(0), -ghq_hirs_gz(0), -ghq_hirs_altcrc(0), -ghq_cache_save(0), -ghq_cache_size(0), -ghq_hirs_let_texartists_fly(0), -ghq_hirs_dump(0), -#endif -autodetect_ucode(0), -ucode(0), -logging(0), -elogging(0), -log_clear(0), -run_in_window(0), -filter_cache(0), -unk_as_red(0), -log_unk(0), -unk_clear(0), -wireframe(0), -wfmode(0), - -// Special fixes -offset_x(0), -offset_y(0), -scale_x(0), -scale_y(0), -fast_crc(0), -alt_tex_size(0), -use_sts1_only(0), -flame_corona(0), //hack for zeldas flame's corona -increase_texrect_edge(0), // add 1 to lower right corner coordinates of texrect -decrease_fillrect_edge(0), // sub 1 from lower right corner coordinates of fillrect -texture_correction(0), // enable perspective texture correction emulation. is on by default -stipple_mode(0), //used for dithered alpha emulation -stipple_pattern(0), //used for dithered alpha emulation -force_microcheck(0), //check microcode each frame, for mixed F3DEX-S2DEX games -force_quad3d(0), //force 0xb5 command to be quad, not line 3d -clip_zmin(0), //enable near z clipping -clip_zmax(0), //enable far plane clipping; -adjust_aspect(0), //adjust screen aspect for wide screen mode -force_calc_sphere(0), //use spheric mapping only, Ridge Racer 64 -pal230(0), //set special scale for PAL games -correct_viewport(0), //correct viewport values -zmode_compare_less(0), //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) -old_style_adither(0), //apply alpha dither regardless of alpha_dither_mode -n64_z_scale(0), //scale vertex z value before writing to depth buffer, as N64 does. - -hacks(0), + m_hacks((hacks_t)0), //wrapper settings #ifndef ANDROID -wrpResolution(0), + m_FullScreenRes(0), #endif -wrpVRAM(0), -wrpFBO(0), -wrpAnisotropic(0) + m_wrpVRAM(0), + m_wrpFBO(false), + m_wrpAnisotropic(false), + m_FlushLogs(false) { + memset(m_log_dir, 0, sizeof(m_log_dir)); + RegisterSettings(); + ReadSettings(); +} + +void CSettings::RegisterSettings(void) +{ + SetModuleName("default"); + m_Set_basic_mode = FindSystemSettingId("Basic Mode"); + m_Set_texture_dir = FindSystemSettingId("Dir:Texture"); + m_Set_log_flush = FindSystemSettingId("Log Auto Flush"); + m_Set_log_dir = FindSystemSettingId("Dir:Log"); + + SetModuleName("Glide64"); + general_setting(Set_Resolution, "resolution", GetDefaultScreenRes()); + general_setting(Set_vsync, "vsync", true); + general_setting(Set_texenh_options, "texenh_options", false); + general_setting(Set_wrpVRAM, "wrpVRAM", 0); +#ifndef ANDROID + general_setting(Set_wrpFBO, "wrpFBO", false); +#else + general_setting(Set_wrpFBO, "wrpFBO", true); +#endif + general_setting(Set_Rotate, "rotate", Rotate_None); + general_setting(Set_wrpAnisotropic, "wrpAnisotropic", false); + general_setting(Set_autodetect_ucode, "autodetect_ucode", true); + general_setting(Set_ucode, "ucode", ucode_F3DEX2); + general_setting(Set_wireframe, "wireframe", false); + general_setting(Set_wfmode, "wfmode", wfmode_VertexColors); + general_setting(Set_ghq_fltr, "ghq_fltr", TextureFilter_None); + general_setting(Set_ghq_cmpr, "ghq_cmpr", TextureCompression_S3TC); + general_setting(Set_ghq_enht, "ghq_enht", TextureEnht_None); + general_setting(Set_ghq_hirs, "ghq_hirs", HiResPackFormat_None); + general_setting(Set_ghq_enht_cmpr, "ghq_enht_cmpr", false); + general_setting(Set_ghq_enht_f16bpp, "ghq_enht_f16bpp", false); + general_setting(Set_ghq_enht_gz, "ghq_enht_gz", true); + general_setting(Set_ghq_enht_nobg, "ghq_enht_nobg", false); + general_setting(Set_ghq_hirs_cmpr, "ghq_hirs_cmpr", false); + general_setting(Set_ghq_hirs_tile, "ghq_hirs_tile", false); + general_setting(Set_ghq_hirs_f16bpp, "ghq_hirs_f16bpp", false); + general_setting(Set_ghq_hirs_gz, "ghq_hirs_gz", true); + general_setting(Set_ghq_hirs_altcrc, "ghq_hirs_altcrc", true); + general_setting(Set_ghq_cache_save, "ghq_cache_save", true); + general_setting(Set_ghq_cache_size, "ghq_cache_size", 0); + general_setting(Set_ghq_hirs_let_texartists_fly, "ghq_hirs_let_texartists_fly", false); + general_setting(Set_ghq_hirs_dump, "ghq_hirs_dump", false); + + general_setting(Set_optimize_texrect_default, "optimize_texrect", true); + general_setting(Set_filtering_default, "filtering", CSettings::Filter_Automatic); + general_setting(Set_lodmode_default, "lodmode", CSettings::LOD_Off); + general_setting(Set_fog_default, "fog", true); + general_setting(Set_buff_clear_default, "buff_clear", true); + general_setting(Set_swapmode_default, "swapmode", SwapMode_New); + general_setting(Set_aspect_default, "aspect", Aspect_4x3); + + general_setting(Set_fb_smart_default, "fb_smart", true); + general_setting(Set_fb_hires_default, "fb_hires", true); + general_setting(Set_fb_read_always_default, "fb_read_always", false); + general_setting(Set_read_back_to_screen_default, "read_back_to_screen", false); + general_setting(Set_detect_cpu_write_default, "detect_cpu_write", false); + general_setting(Set_fb_get_info_default, "fb_get_info", false); + general_setting(Set_fb_render_default, "fb_render", false); + +#ifndef ANDROID + general_setting(Set_FullScreenRes, "FullScreenRes", GetCurrentResIndex()); +#endif + + game_setting(Set_alt_tex_size, "alt_tex_size", false); + game_setting(Set_use_sts1_only, "use_sts1_only", false); + game_setting(Set_force_calc_sphere, "force_calc_sphere", false); + game_setting(Set_correct_viewport, "correct_viewport", false); + game_setting(Set_increase_texrect_edge, "increase_texrect_edge", false); + game_setting(Set_decrease_fillrect_edge, "decrease_fillrect_edge", false); + game_setting(Set_texture_correction, "texture_correction", true); + game_setting(Set_pal230, "pal230", false); + game_setting(Set_stipple_mode, "stipple_mode", STIPPLE_Rotate); + + game_setting(Set_stipple_pattern, "stipple_pattern", 0x3E0F83E0); + game_setting(Set_force_microcheck, "force_microcheck", false); + game_setting(Set_force_quad3d, "force_quad3d", false); + game_setting(Set_clip_zmin, "clip_zmin", false); + game_setting(Set_clip_zmax, "clip_zmax", true); + game_setting(Set_fast_crc, "fast_crc", true); + game_setting(Set_adjust_aspect, "adjust_aspect", true); + game_setting(Set_zmode_compare_less, "zmode_compare_less", false); + game_setting(Set_old_style_adither, "old_style_adither", false); + game_setting(Set_n64_z_scale, "n64_z_scale", false); + game_setting_default(Set_optimize_texrect, "optimize_texrect", Set_optimize_texrect_default); + game_setting(Set_ignore_aux_copy, "ignore_aux_copy", false); + game_setting(Set_hires_buf_clear, "hires_buf_clear", true); + game_setting(Set_fb_read_alpha, "fb_read_alpha", false); + game_setting(Set_useless_is_useless, "useless_is_useless", false); + game_setting(Set_fb_crc_mode, "fb_crc_mode", fbcrcFast); + game_setting_default(Set_filtering, "filtering", Set_filtering_default); + game_setting_default(Set_fog, "fog", Set_fog_default); + game_setting_default(Set_buff_clear, "buff_clear", Set_buff_clear_default); + game_setting_default(Set_swapmode, "swapmode", Set_swapmode_default); + game_setting_default(Set_aspect, "aspect", Set_aspect_default); + game_setting_default(Set_lodmode, "lodmode", Set_lodmode_default); + + game_setting_default(Set_fb_smart, "fb_smart", Set_fb_smart_default); + game_setting_default(Set_fb_hires, "fb_hires", Set_fb_hires_default); + game_setting_default(Set_fb_read_always, "fb_read_always", Set_fb_read_always_default); + game_setting_default(Set_read_back_to_screen, "read_back_to_screen", Set_read_back_to_screen_default); + game_setting_default(Set_detect_cpu_write, "detect_cpu_write", Set_detect_cpu_write_default); + game_setting_default(Set_fb_get_info, "fb_get_info", Set_fb_get_info_default); + game_setting_default(Set_fb_render, "fb_render", Set_fb_render_default); + + SettingsRegisterChange(false, Set_Resolution, this, stSettingsChanged); + +} + +void CSettings::SetTexenhOptions(bool value) +{ + if (value != m_texenh_options) + { + m_texenh_options = value; + m_dirty = true; + } +} + +void CSettings::SetScreenRes(uint32_t value) +{ + if (value >= GetScreenResolutionCount()) + { + value = GetDefaultScreenRes(); + } + + if (value != m_ScreenRes) + { + m_ScreenRes = value; + m_dirty = true; + } +} + +void CSettings::UpdateScreenSize(bool fullscreen) +{ +#ifndef ANDROID + if (fullscreen) + { + g_width = GetFullScreenResWidth(m_FullScreenRes); + g_height = GetFullScreenResHeight(m_FullScreenRes); + } + else + { +#endif + g_width = GetScreenResWidth(m_ScreenRes); + g_height = GetScreenResHeight(m_ScreenRes); +#ifndef ANDROID + } +#endif + m_scr_res_x = m_res_x = g_width; + m_scr_res_y = m_res_y = g_height; + UpdateAspectRatio(); +} + +void CSettings::SetAspectmode(AspectMode_t value) +{ + if (value != m_aspectmode) + { + m_aspectmode = value; + UpdateAspectRatio(); + m_dirty = true; + } +} + +void CSettings::SetLODmode(PixelLevelOfDetail_t value) +{ + if (value != m_lodmode) + { + m_lodmode = value; + m_dirty = true; + } +} + +void CSettings::SetVsync(bool value) +{ + if (value != m_vsync) + { + m_vsync = value; + m_dirty = true; + } +} + +void CSettings::SetFiltering(Filtering_t value) +{ + if (value != m_filtering) + { + m_filtering = value; + m_dirty = true; + } +} + +void CSettings::SetSwapMode(SwapMode_t value) +{ + if (value != m_swapmode) + { + m_swapmode = value; + m_dirty = true; + } +} + +void CSettings::SetFog(bool value) +{ + if (value != m_fog) + { + m_fog = value; + m_dirty = true; + } +} + +void CSettings::SetBuffClear(bool value) +{ + if (value != m_buff_clear) + { + m_buff_clear = value; + m_dirty = true; + } +} + +void CSettings::SetWrpAnisotropic(bool value) +{ + if (value != m_wrpAnisotropic) + { + m_wrpAnisotropic = value; + m_dirty = true; + } +} + +void CSettings::SetWrpVRAM(int value) +{ + if (value != m_wrpVRAM) + { + m_wrpVRAM = value; + m_dirty = true; + } +} + +void CSettings::SetWrpFBO(bool value) +{ + if (value != m_wrpFBO) + { + m_wrpFBO = value; + m_dirty = true; + } +} + +void CSettings::SetGhqFltr(TextureFilter_t value) +{ + if (value != m_ghq_fltr) + { + m_ghq_fltr = value; + m_dirty = true; + } +} + +void CSettings::SetGhqEnht(TextureEnhancement_t value) +{ + if (value != m_ghq_enht) + { + m_ghq_enht = value; + m_dirty = true; + } +} + +void CSettings::SetGhqCmpr(TextureCompression_t value) +{ + if (value != m_ghq_cmpr) + { + m_ghq_cmpr = value; + m_dirty = true; + } +} + +void CSettings::SetGhqHirs(HiResPackFormat_t value) +{ + if (value != m_ghq_hirs) + { + m_ghq_hirs = value; + m_dirty = true; + } +} + +void CSettings::SetGhqEnhtGz(bool value) +{ + if (value != m_ghq_enht_gz) + { + m_ghq_enht_gz = value; + m_dirty = true; + } +} + +void CSettings::SetGhqHirsTile(bool value) +{ + if (value != m_ghq_hirs_tile) + { + m_ghq_hirs_tile = value; + m_dirty = true; + } +} + +void CSettings::SetGhqHirsF16bpp(bool value) +{ + if (value != m_ghq_hirs_f16bpp) + { + m_ghq_hirs_f16bpp = value; + m_dirty = true; + } +} + +void CSettings::SetGhqHirsDump(bool value) +{ + if (value != m_ghq_hirs_dump) + { + m_ghq_hirs_dump = value; + m_dirty = true; + } +} + +void CSettings::SetGhqEnhtNobg(bool value) +{ + if (value != m_ghq_enht_nobg) + { + m_ghq_enht_nobg = value; + m_dirty = true; + } +} + +void CSettings::SetGhqEnhtCmpr(bool value) +{ + if (value != m_ghq_enht_cmpr) + { + m_ghq_enht_cmpr = value; + m_dirty = true; + } +} + +void CSettings::SetGhqHirsAltcrc(bool value) +{ + if (value != m_ghq_hirs_altcrc) + { + m_ghq_hirs_altcrc = value; + m_dirty = true; + } +} + +void CSettings::SetGhqHirsCmpr(bool value) +{ + if (value != m_ghq_hirs_cmpr) + { + m_ghq_hirs_cmpr = value; + m_dirty = true; + } +} + +void CSettings::SetGhqHirsGz(bool value) +{ + if (value != m_ghq_hirs_gz) + { + m_ghq_hirs_gz = value; + m_dirty = true; + } +} + +void CSettings::SetGhqHirsLetTexartistsFly(bool value) +{ + if (value != m_ghq_hirs_let_texartists_fly) + { + m_ghq_hirs_let_texartists_fly = value; + m_dirty = true; + } +} + +void CSettings::SetGhqCacheSave(bool value) +{ + if (value != m_ghq_cache_save) + { + m_ghq_cache_save = value; + m_dirty = true; + } +} + +void CSettings::SetGhqCacheSize(int value) +{ + if (value != m_ghq_cache_size) + { + m_ghq_cache_size = value; + m_dirty = true; + } +} + +void CSettings::UpdateFrameBufferBits(uint32_t BitsToAdd, uint32_t BitsToRemove) +{ + uint32_t frame_buffer_original = m_frame_buffer; + m_frame_buffer |= BitsToAdd; + m_frame_buffer &= ~BitsToRemove; + if (frame_buffer_original != m_frame_buffer) + { + m_dirty = true; + } +} + +CSettings::ucode_t CSettings::DetectUCode(uint32_t uc_crc) +{ + RegisterSetting(Set_ucodeLookup, Data_DWORD_RDB_Setting, stdstr_f("%08lx", uc_crc).c_str(), "ucode", (unsigned int)-2, NULL); + CSettings::ucode_t uc = (CSettings::ucode_t)GetSetting(Set_ucodeLookup); + if (uc == CSettings::uCode_NotFound || uc == CSettings::uCode_Unsupported) + { + m_ucode = (CSettings::ucode_t)GetSetting(Set_ucode); + } + else + { + m_ucode = uc; + } + return uc; +} + +void CSettings::SetUcode(ucode_t value) +{ + m_ucode = value; +} + +#ifndef ANDROID +void CSettings::SetFullScreenRes(uint32_t value) +{ + if (value != m_FullScreenRes) + { + m_FullScreenRes = value; + m_dirty = true; + } +} +#endif + +void CSettings::UpdateAspectRatio(void) +{ + switch (m_aspectmode) + { + case Aspect_4x3: + if (m_scr_res_x >= m_scr_res_y * 4.0f / 3.0f) { + m_res_y = m_scr_res_y; + m_res_x = (uint32_t)(m_res_y * 4.0f / 3.0f); + } + else + { + m_res_x = m_scr_res_x; + m_res_y = (uint32_t)(m_res_x / 4.0f * 3.0f); + } + break; + case Aspect_16x9: + if (m_scr_res_x >= m_scr_res_y * 16.0f / 9.0f) + { + m_res_y = m_scr_res_y; + m_res_x = (uint32_t)(m_res_y * 16.0f / 9.0f); + } + else + { + m_res_x = m_scr_res_x; + m_res_y = (uint32_t)(m_res_x / 16.0f * 9.0f); + } + break; + default: //stretch or original + m_res_x = m_scr_res_x; + m_res_y = m_scr_res_y; + } + + m_res_x += (uint32_t)(m_scr_res_x - m_res_x) / 2.0f; + m_res_y += (uint32_t)(m_scr_res_y - m_res_y) / 2.0f; + +} + +void CSettings::ReadSettings() +{ + SetScreenRes(GetSetting(Set_Resolution)); +#ifndef ANDROID + SetFullScreenRes(GetSetting(Set_FullScreenRes)); +#endif + m_vsync = GetSetting(Set_vsync) != 0; + m_rotate = (ScreenRotate_t)GetSetting(Set_Rotate); + m_advanced_options = m_Set_basic_mode ? GetSystemSetting(m_Set_basic_mode) == 0 : false; + m_texenh_options = GetSetting(Set_texenh_options) != 0; + + m_wrpVRAM = GetSetting(Set_wrpVRAM); + m_wrpFBO = GetSetting(Set_wrpFBO) != 0; + m_wrpAnisotropic = GetSetting(Set_wrpAnisotropic) != 0; + + m_autodetect_ucode = GetSetting(Set_autodetect_ucode) != 0; + m_wireframe = GetSetting(Set_wireframe) != 0; + m_wfmode = (wfmode_t)GetSetting(Set_wfmode); + m_ucode = ucode_F3DEX2; + + char texture_dir[260]; + memset(texture_dir, 0, sizeof(texture_dir)); + GetSystemSettingSz(m_Set_texture_dir, texture_dir, sizeof(texture_dir)); + m_texture_dir = texture_dir; + m_ghq_fltr = (TextureFilter_t)GetSetting(Set_ghq_fltr); + m_ghq_cmpr = (TextureCompression_t)GetSetting(Set_ghq_cmpr); + m_ghq_enht = (TextureEnhancement_t)GetSetting(Set_ghq_enht); + m_ghq_hirs = (HiResPackFormat_t)GetSetting(Set_ghq_hirs); + m_ghq_enht_cmpr = GetSetting(Set_ghq_enht_cmpr) != 0; + m_ghq_enht_f16bpp = GetSetting(Set_ghq_enht_f16bpp) !=0; + m_ghq_enht_gz = GetSetting(Set_ghq_enht_gz) != 0; + m_ghq_enht_nobg = GetSetting(Set_ghq_enht_nobg) != 0; + m_ghq_hirs_cmpr = GetSetting(Set_ghq_hirs_cmpr) != 0; + m_ghq_hirs_tile = GetSetting(Set_ghq_hirs_tile) != 0; + m_ghq_hirs_f16bpp = GetSetting(Set_ghq_hirs_f16bpp) != 0; + m_ghq_hirs_gz = GetSetting(Set_ghq_hirs_gz) != 0; + m_ghq_hirs_altcrc = GetSetting(Set_ghq_hirs_altcrc) != 0; + m_ghq_cache_save = GetSetting(Set_ghq_cache_save) != 0; + m_ghq_cache_size = GetSetting(Set_ghq_cache_size); + m_ghq_hirs_let_texartists_fly = GetSetting(Set_ghq_hirs_let_texartists_fly) != 0; + m_ghq_hirs_dump = GetSetting(Set_ghq_hirs_dump) != 0; + + if (m_Set_log_dir != 0) + { + GetSystemSettingSz(m_Set_log_dir, m_log_dir, sizeof(m_log_dir)); + } + m_FlushLogs = m_Set_log_flush != 0 ? GetSystemSetting(m_Set_log_flush) != 0 : false; + m_dirty = false; +} + +void CSettings::ReadGameSettings(const char * name) +{ + m_hacks = (hacks_t)0; + + //detect games which require special hacks + if (strstr(name, (const char *)"ZELDA")) + { + m_hacks = (hacks_t)(m_hacks | (CSettings::hack_Zelda | CSettings::hack_OoT)); + } + else if (strstr(name, (const char *)"MASK")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Zelda); + } + else if (strstr(name, (const char *)"ROADSTERS TROPHY")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Zelda); + } + else if (strstr(name, (const char *)"Diddy Kong Racing")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Diddy); + } + else if (strstr(name, (const char *)"Tonic Trouble")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Tonic); + } + else if (strstr(name, (const char *)"All") && strstr(name, (const char *)"Star") && strstr(name, (const char *)"Baseball")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_ASB); + } + else if (strstr(name, (const char *)"Beetle") || strstr(name, (const char *)"BEETLE") || strstr(name, (const char *)"HSV")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_BAR); + } + else if (strstr(name, (const char *)"I S S 64") || strstr(name, (const char *)"J WORLD SOCCER3") || strstr(name, (const char *)"PERFECT STRIKER") || strstr(name, (const char *)"RONALDINHO SOCCER")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_ISS64); + } + else if (strstr(name, (const char *)"MARIOKART64")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_MK64); + } + else if (strstr(name, (const char *)"NITRO64")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_WCWnitro); + } + else if (strstr(name, (const char *)"CHOPPER_ATTACK") || strstr(name, (const char *)"WILD CHOPPERS")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Chopper); + } + else if (strstr(name, (const char *)"Resident Evil II") || strstr(name, (const char *)"BioHazard II")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_RE2); + } + else if (strstr(name, (const char *)"YOSHI STORY")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Yoshi); + } + else if (strstr(name, (const char *)"F-Zero X") || strstr(name, (const char *)"F-ZERO X")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Fzero); + } + else if (strstr(name, (const char *)"PAPER MARIO") || strstr(name, (const char *)"MARIO STORY")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_PMario); + } + else if (strstr(name, (const char *)"TOP GEAR RALLY 2")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_TGR2); + } + else if (strstr(name, (const char *)"TOP GEAR RALLY")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_TGR); + } + else if (strstr(name, (const char *)"Top Gear Hyper Bike")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Hyperbike); + } + else if (strstr(name, (const char *)"Killer Instinct Gold") || strstr(name, (const char *)"KILLER INSTINCT GOLD")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_KI); + } + else if (strstr(name, (const char *)"Knockout Kings 2000")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Knockout); + } + else if (strstr(name, (const char *)"LEGORacers")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Lego); + } + else if (strstr(name, (const char *)"OgreBattle64")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Ogre64); + } + else if (strstr(name, (const char *)"Pilot Wings64")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Pilotwings); + } + else if (strstr(name, (const char *)"Supercross")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Supercross); + } + else if (strstr(name, (const char *)"STARCRAFT 64")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Starcraft); + } + else if (strstr(name, (const char *)"BANJO KAZOOIE 2") || strstr(name, (const char *)"BANJO TOOIE")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Banjo2); + } + else if (strstr(name, (const char *)"FIFA: RTWC 98") || strstr(name, (const char *)"RoadToWorldCup98")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Fifa98); + } + else if (strstr(name, (const char *)"Mega Man 64") || strstr(name, (const char *)"RockMan Dash")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Megaman); + } + else if (strstr(name, (const char *)"MISCHIEF MAKERS") || strstr(name, (const char *)"TROUBLE MAKERS")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Makers); + } + else if (strstr(name, (const char *)"GOLDENEYE")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_GoldenEye); + } + else if (strstr(name, (const char *)"PUZZLE LEAGUE")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_PPL); + } + else if (strstr(name, (const char *)"WIN BACK") || strstr(name, (const char *)"OPERATION WINBACK")) + { + m_hacks = (hacks_t)(m_hacks | CSettings::hack_Winback); + } + + m_alt_tex_size = GetSetting(Set_alt_tex_size) != 0; + m_use_sts1_only = GetSetting(Set_use_sts1_only) != 0; + m_force_calc_sphere = GetSetting(Set_force_calc_sphere) != 0; + m_correct_viewport = GetSetting(Set_correct_viewport); + m_increase_texrect_edge = GetSetting(Set_increase_texrect_edge) != 0; + m_decrease_fillrect_edge = GetSetting(Set_decrease_fillrect_edge) != 0; + m_texture_correction = GetSetting(Set_texture_correction) != 0; + m_pal230 = GetSetting(Set_pal230) != 0; + m_stipple_mode = (StippleMode_t)GetSetting(Set_stipple_mode); + int stipple_pattern = GetSetting(Set_stipple_pattern); + m_stipple_pattern = stipple_pattern > 0 ? (uint32_t)stipple_pattern : 0x3E0F83E0; + m_force_microcheck = GetSetting(Set_force_microcheck) != 0; + m_force_quad3d = GetSetting(Set_force_quad3d) != 0; + m_clip_zmin = GetSetting(Set_clip_zmin) != 0; + m_clip_zmax = GetSetting(Set_clip_zmax) != 0; + m_fast_crc = GetSetting(Set_fast_crc) != 0; + m_adjust_aspect = GetSetting(Set_adjust_aspect); + m_zmode_compare_less = GetSetting(Set_zmode_compare_less); + m_old_style_adither = GetSetting(Set_old_style_adither); + m_n64_z_scale = GetSetting(Set_n64_z_scale) != 0; + + m_ScreenRes = GetSetting(Set_Resolution); + if (m_ScreenRes >= GetScreenResolutionCount()) { m_ScreenRes = GetDefaultScreenRes(); } + + //frame buffer + short fb_Settings[] = + { + g_romopen ? Set_optimize_texrect : Set_optimize_texrect_default, + Set_ignore_aux_copy, + Set_hires_buf_clear, + Set_fb_read_alpha, + Set_useless_is_useless, + g_romopen ? Set_fb_smart : Set_fb_smart_default, + g_romopen ? Set_fb_hires : Set_fb_hires_default, + g_romopen ? Set_fb_read_always : Set_fb_read_always_default, + g_romopen ? Set_detect_cpu_write : Set_detect_cpu_write_default, + g_romopen ? Set_fb_get_info : Set_fb_get_info_default, + g_romopen ? Set_fb_render : Set_fb_render_default + }; + + fb_bits_t bits[] = + { + fb_optimize_texrect, + fb_ignore_aux_copy, + fb_hwfbe_buf_clear, + fb_read_alpha, + fb_useless_is_useless, + fb_emulation, + fb_hwfbe, + fb_ref, + fb_cpu_write_hack, + fb_get_info, + fb_depth_render + }; + + uint32_t fb_add_bits = 0, fb_remove_bits = 0; + for (int i = 0; i < (sizeof(fb_Settings) / sizeof(fb_Settings[0])); i++) + { + if (GetSetting(fb_Settings[i]) != 0) + { + fb_add_bits |= bits[i]; + } + else + { + fb_remove_bits |= bits[i]; + } + } + fb_add_bits |= fb_motionblur; + + int read_back_to_screen = GetSetting(g_romopen ? Set_read_back_to_screen : Set_read_back_to_screen_default); + if (read_back_to_screen == 1) { fb_add_bits |= fb_read_back_to_screen; } + else if (read_back_to_screen == 2) { fb_add_bits |= fb_read_back_to_screen2; } + else if (read_back_to_screen == 0) { fb_remove_bits |= fb_read_back_to_screen | fb_read_back_to_screen2; } + + UpdateFrameBufferBits(fb_add_bits, fb_remove_bits); + m_fb_crc_mode = (FBCRCMODE_t)GetSetting(Set_fb_crc_mode); + + SetFiltering((Filtering_t)GetSetting(g_romopen ? Set_filtering : Set_filtering_default)); + SetFog(GetSetting(g_romopen ? Set_fog : Set_fog_default) != 0); + SetBuffClear(GetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default) != 0); + SetSwapMode((SwapMode_t)GetSetting(g_romopen ? Set_swapmode : Set_swapmode_default)); + SetAspectmode((AspectMode_t)GetSetting(g_romopen ? Set_aspect : Set_aspect_default)); + SetLODmode((PixelLevelOfDetail_t)GetSetting(g_romopen ? Set_lodmode : Set_lodmode_default)); + m_flame_corona = hacks(hack_Zelda) && !fb_depth_render_enabled(); +} + +void CSettings::WriteSettings(void) +{ + SetSetting(Set_Resolution, m_ScreenRes); +#ifndef ANDROID + SetSetting(Set_FullScreenRes, m_FullScreenRes); +#endif + SetSetting(Set_vsync, m_vsync ? 1 : 0); + SetSetting(Set_Rotate, m_rotate); + SetSetting(Set_texenh_options, m_texenh_options); + + SetSetting(Set_wrpVRAM, m_wrpVRAM); + SetSetting(Set_wrpFBO, m_wrpFBO); + SetSetting(Set_wrpAnisotropic, m_wrpAnisotropic); + SetSetting(Set_autodetect_ucode, m_autodetect_ucode); + + SetSetting(Set_wireframe, m_wireframe); + SetSetting(Set_wfmode, m_wfmode); + SetSetting(Set_ucode, (int)m_ucode); + + SetSetting(Set_ghq_fltr, m_ghq_fltr); + SetSetting(Set_ghq_cmpr, m_ghq_cmpr); + SetSetting(Set_ghq_enht, m_ghq_enht); + SetSetting(Set_ghq_hirs, m_ghq_hirs); + SetSetting(Set_ghq_enht_cmpr, m_ghq_enht_cmpr); + SetSetting(Set_ghq_enht_f16bpp, m_ghq_enht_f16bpp); + SetSetting(Set_ghq_enht_gz, m_ghq_enht_gz); + SetSetting(Set_ghq_enht_nobg, m_ghq_enht_nobg); + SetSetting(Set_ghq_hirs_cmpr, m_ghq_hirs_cmpr); + SetSetting(Set_ghq_hirs_tile, m_ghq_hirs_tile); + SetSetting(Set_ghq_hirs_f16bpp, m_ghq_hirs_f16bpp); + SetSetting(Set_ghq_hirs_gz, m_ghq_hirs_gz); + SetSetting(Set_ghq_hirs_altcrc, m_ghq_hirs_altcrc); + SetSetting(Set_ghq_cache_save, m_ghq_cache_save); + SetSetting(Set_ghq_cache_size, m_ghq_cache_size); + SetSetting(Set_ghq_hirs_let_texartists_fly, m_ghq_hirs_let_texartists_fly); + SetSetting(Set_ghq_hirs_dump, m_ghq_hirs_dump); + + SetSetting(g_romopen ? Set_filtering : Set_filtering_default, m_filtering); + SetSetting(g_romopen ? Set_fog : Set_fog_default, m_fog); + SetSetting(g_romopen ? Set_buff_clear : Set_buff_clear_default, m_buff_clear); + SetSetting(g_romopen ? Set_swapmode : Set_swapmode_default, m_swapmode); + SetSetting(g_romopen ? Set_lodmode : Set_lodmode_default, m_lodmode); + SetSetting(g_romopen ? Set_aspect : Set_aspect_default, m_aspectmode); + + SetSetting(g_romopen ? Set_fb_read_always : Set_fb_read_always_default, fb_ref_enabled() ? true : false); + SetSetting(g_romopen ? Set_fb_smart : Set_fb_smart_default, fb_emulation_enabled() ? true : false); + SetSetting(g_romopen ? Set_fb_hires : Set_fb_hires_default, fb_hwfbe_set() ? true : false); + SetSetting(g_romopen ? Set_fb_get_info : Set_fb_get_info_default, fb_get_info_enabled() ? true : false); + SetSetting(g_romopen ? Set_fb_render : Set_fb_render_default, fb_depth_render_enabled() ? true : false); + SetSetting(g_romopen ? Set_detect_cpu_write : Set_detect_cpu_write_default, fb_cpu_write_hack_enabled() ? true : false); + if (fb_read_back_to_screen_enabled()) + { + SetSetting(g_romopen ? Set_read_back_to_screen : Set_read_back_to_screen_default, 1); + } + else if (fb_read_back_to_screen2_enabled()) + { + SetSetting(g_romopen ? Set_read_back_to_screen : Set_read_back_to_screen_default, 2); + } + else + { + SetSetting(g_romopen ? Set_read_back_to_screen : Set_read_back_to_screen_default, 0); + } + + FlushSettings(); +} + +void CSettings::general_setting(short setting_ID, const char * name, unsigned int value) +{ + RegisterSetting(setting_ID, Data_DWORD_General, name, NULL, value, NULL); +} + +void CSettings::game_setting(short setting_ID, const char * name, unsigned int value) +{ + RegisterSetting(setting_ID, Data_DWORD_Game, name, NULL, value, NULL); +} + +void CSettings::game_setting_default(short setting_ID, const char * name, short default_setting) +{ + RegisterSetting2(setting_ID, Data_DWORD_Game, name, NULL, default_setting); +} + +void CSettings::SettingsChanged(void) +{ + m_ScreenRes = GetSetting(Set_Resolution); +} + +void UseUnregisteredSetting(int /*SettingID*/) +{ +#ifdef _WIN32 + DebugBreak(); +#endif } diff --git a/Source/Glide64/Settings.h b/Source/Glide64/Settings.h index 6db262eb2..857dbd293 100644 --- a/Source/Glide64/Settings.h +++ b/Source/Glide64/Settings.h @@ -1,166 +1,397 @@ #pragma once +#include class CSettings { public: CSettings(); - int card_id; - - uint32_t res_x, scr_res_x; - uint32_t res_y, scr_res_y; -#ifndef ANDROID - uint32_t res_data, res_data_org; -#endif - - int advanced_options; - int texenh_options; - int ssformat; - int vsync; - - int clock; - int clock_24_hr; - int rotate; - - int filtering; - int fog; - int buff_clear; - int swapmode; - int lodmode; - int aspectmode; - int use_hotkeys; - //Frame buffer emulation options -#define fb_emulation (1<<0) //frame buffer emulation -#define fb_hwfbe (1<<1) //hardware frame buffer emualtion -#define fb_motionblur (1<<2) //emulate motion blur -#define fb_ref (1<<3) //read every frame -#define fb_read_alpha (1<<4) //read alpha -#define fb_hwfbe_buf_clear (1<<5) //clear auxiliary texture frame buffers -#define fb_depth_render (1<<6) //enable software depth render -#define fb_optimize_texrect (1<<7) //fast texrect rendering with hwfbe -#define fb_ignore_aux_copy (1<<8) //do not copy auxiliary frame buffers -#define fb_useless_is_useless (1<<10) // -#define fb_get_info (1<<11) //get frame buffer info -#define fb_read_back_to_screen (1<<12) //render N64 frame buffer to screen -#define fb_read_back_to_screen2 (1<<13) //render N64 frame buffer to screen -#define fb_cpu_write_hack (1<<14) //show images writed directly by CPU + enum fb_bits_t + { + fb_emulation = (1 << 0), //frame buffer emulation + fb_hwfbe = (1 << 1), //hardware frame buffer emualtion + fb_motionblur = (1 << 2), //emulate motion blur + fb_ref = (1 << 3), //read every frame + fb_read_alpha = (1 << 4), //read alpha + fb_hwfbe_buf_clear = (1 << 5), //clear auxiliary texture frame buffers + fb_depth_render = (1 << 6), //enable software depth render + fb_optimize_texrect = (1 << 7), //fast texrect rendering with hwfbe + fb_ignore_aux_copy = (1 << 8), //do not copy auxiliary frame buffers + fb_useless_is_useless = (1 << 10), // + fb_get_info = (1 << 11), //get frame buffer info + fb_read_back_to_screen = (1 << 12), //render N64 frame buffer to screen + fb_read_back_to_screen2 = (1 << 13), //render N64 frame buffer to screen + fb_cpu_write_hack = (1 << 14), //show images writed directly by CPU + }; -#define fb_emulation_enabled ((g_settings->frame_buffer&fb_emulation)>0) -#define fb_hwfbe_enabled ((g_settings->frame_buffer&(fb_emulation|fb_hwfbe))==(fb_emulation|fb_hwfbe)) -#define fb_depth_render_enabled ((g_settings->frame_buffer&fb_depth_render)>0) + enum hacks_t + { + hack_ASB = (1<<0), //All-Star Baseball games + hack_Banjo2 = (1<<1), //Banjo Tooie + hack_BAR = (1<<2), //Beetle Adventure Racing + hack_Chopper = (1<<3), //Chopper Attack + hack_Diddy = (1<<4), //diddy kong racing + hack_Fifa98 = (1<<5), //FIFA - Road to World Cup 98 + hack_Fzero = (1<<6), //F-Zero + hack_GoldenEye = (1<<7), //Golden Eye + hack_Hyperbike = (1<<8), //Top Gear Hyper Bike + hack_ISS64 = (1<<9), //International Superstar Soccer 64 + hack_KI = (1<<10), //Killer Instinct + hack_Knockout = (1<<11), //Knockout Kings 2000 + hack_Lego = (1<<12), //LEGO Racers + hack_MK64 = (1<<13), //Mario Kart + hack_Megaman = (1<<14), //Megaman64 + hack_Makers = (1<<15), //Mischief-makers + hack_WCWnitro = (1<<16), //WCW Nitro + hack_Ogre64 = (1<<17), //Ogre Battle 64 + hack_Pilotwings = (1<<18), //Pilotwings + hack_PMario = (1<<19), //Paper Mario + hack_PPL = (1<<20), //pokemon puzzle league requires many special fixes + hack_RE2 = (1<<21), //Resident Evil 2 + hack_Starcraft = (1<<22), //StarCraft64 + hack_Supercross = (1<<23), //Supercross 2000 + hack_TGR = (1<<24), //Top Gear Rally + hack_TGR2 = (1<<25), //Top Gear Rally 2 + hack_Tonic = (1<<26), //tonic trouble + hack_Winback = (1<<27), //WinBack - Covert Operations + hack_Yoshi = (1<<28), //Yoshi Story + hack_Zelda = (1<<29), //zeldas hacks + hack_OoT = (1<<30), //zelda OoT hacks + }; - uint32_t frame_buffer; - enum FBCRCMODE - { + enum AspectMode_t + { + Aspect_4x3 = 0, + Aspect_16x9 = 1, + Aspect_Stretch = 2, + Aspect_Original = 3, + }; + + enum ScreenRotate_t + { + Rotate_None = 0, + Rotate_90 = 1, + Rotate_180 = 2, + Rotate_270 = 3, + }; + + enum Filtering_t + { + Filter_Automatic = 0, + Filter_ForceBilinear = 1, + Filter_ForcePointSampled = 2, + }; + + enum TextureFilter_t + { + TextureFilter_None = 0x00, + TextureFilter_SmoothFiltering = 0x01, + TextureFilter_SmoothFiltering2 = 0x02, + TextureFilter_SmoothFiltering3 = 0x03, + TextureFilter_SmoothFiltering4 = 0x04, + TextureFilter_SharpFiltering1 = 0x10, + TextureFilter_SharpFiltering2 = 0x20, + }; + + enum TextureEnhancement_t + { + TextureEnht_None = 0x00, + TextureEnht_X2 = 0x100, + TextureEnht_X2SAI = 0x200, + TextureEnht_HQ2X = 0x300, + TextureEnht_HQ2XS = 0x600, + TextureEnht_LQ2X = 0x400, + TextureEnht_LQ2XS = 0x700, + TextureEnht_HQ4X = 0x500, + }; + + enum TextureCompression_t + { + TextureCompression_S3TC = 0x3000, + TextureCompression_FXT1 = 0x1000, + }; + + enum HiResPackFormat_t + { + HiResPackFormat_None = 0, + HiResPackFormat_Riceformat = 0x00020000, + }; + + enum SwapMode_t + { + SwapMode_Old = 0, + SwapMode_New = 1, + SwapMode_Hybrid = 2, + }; + + enum PixelLevelOfDetail_t + { + LOD_Off = 0, + LOD_Fast = 1, + LOD_Precise = 2, + }; + + enum StippleMode_t + { + STIPPLE_Disable = 0x0, + STIPPLE_Pattern = 0x1, + STIPPLE_Rotate = 0x2, + }; + + enum ucode_t + { + uCode_NotFound = -2, + uCode_Unsupported = -1, + ucode_Fast3D = 0, + ucode_F3DEX = 1, + ucode_F3DEX2 = 2, + ucode_WaveRace = 3, + ucode_StarWars = 4, + ucode_DiddyKong = 5, + ucode_S2DEX = 6, + ucode_PerfectDark = 7, + ucode_CBFD = 8, + ucode_zSort = 9, + ucode_Turbo3d = 21, + }; + + enum wfmode_t + { + wfmode_NormalColors = 0, + wfmode_VertexColors = 1, + wfmode_RedOnly = 2, + }; + + enum FBCRCMODE_t + { fbcrcNone = 0, fbcrcFast = 1, fbcrcSafe = 2 - } fb_crc_mode; + }; + + inline bool fb_emulation_enabled(void) const { return ((m_frame_buffer&fb_emulation) != 0); } + inline bool fb_ref_enabled(void) const { return ((m_frame_buffer&fb_ref) != 0); } + inline bool fb_hwfbe_enabled(void) const { return ((m_frame_buffer&(fb_emulation |fb_hwfbe)) == (fb_emulation | fb_hwfbe)); } + inline bool fb_hwfbe_set(void) const { return ((m_frame_buffer&fb_hwfbe) != 0); } + inline bool fb_depth_render_enabled(void) const { return ((m_frame_buffer&fb_depth_render) != 0); } + inline bool fb_get_info_enabled(void) const { return ((m_frame_buffer&fb_get_info) != 0); } + inline bool fb_read_back_to_screen_enabled(void) const { return ((m_frame_buffer&fb_read_back_to_screen) != 0); } + inline bool fb_read_back_to_screen2_enabled(void) const { return ((m_frame_buffer&fb_read_back_to_screen2) != 0); } + inline bool fb_cpu_write_hack_enabled(void) const { return ((m_frame_buffer&fb_cpu_write_hack) != 0); } + inline bool fb_ignore_aux_copy_enabled(void) const { return ((m_frame_buffer&fb_ignore_aux_copy) != 0); } + inline bool fb_hwfbe_buf_clear_enabled(void) const { return ((m_frame_buffer&fb_hwfbe_buf_clear) != 0); } + inline bool fb_useless_is_useless_enabled(void) const { return ((m_frame_buffer&fb_useless_is_useless) != 0); } + inline bool fb_motionblur_enabled(void) const { return ((m_frame_buffer&fb_motionblur) != 0); } + inline bool fb_read_alpha_enabled(void) const { return ((m_frame_buffer&fb_read_alpha) != 0); } + inline bool fb_optimize_texrect_enabled(void) const { return ((m_frame_buffer&fb_optimize_texrect) != 0); } + + inline const char * log_dir(void) const { return m_log_dir; } + inline uint32_t res_x(void) const { return m_res_x; } + inline uint32_t res_y(void) const { return m_res_y; } + inline uint32_t scr_res_x(void) const { return m_scr_res_x; } + inline uint32_t scr_res_y(void) const { return m_scr_res_y; } + inline uint32_t ScreenRes(void) const { return m_ScreenRes; } + inline bool advanced_options(void) const { return m_advanced_options; } + inline bool texenh_options(void) const { return m_texenh_options; } + inline bool vsync(void) const { return m_vsync; } + inline ScreenRotate_t rotate(void) const { return m_rotate; } + inline Filtering_t filtering(void) const { return m_filtering; } + + inline bool fog (void) const { return m_fog; } + inline bool buff_clear(void) const { return m_buff_clear; } + inline SwapMode_t swapmode(void) const { return m_swapmode; } + inline PixelLevelOfDetail_t lodmode(void) const { return m_lodmode; } + inline AspectMode_t aspectmode(void) const { return m_aspectmode; } + + inline FBCRCMODE_t fb_crc_mode(void) const { return m_fb_crc_mode; } -#ifdef TEXTURE_FILTER //Texture filtering options - std::string texture_dir; - int ghq_fltr; - int ghq_enht; - int ghq_cmpr; - int ghq_hirs; - int ghq_use; - int ghq_enht_cmpr; - int ghq_enht_tile; - int ghq_enht_f16bpp; - int ghq_enht_gz; - int ghq_enht_nobg; - int ghq_hirs_cmpr; - int ghq_hirs_tile; - int ghq_hirs_f16bpp; - int ghq_hirs_gz; - int ghq_hirs_altcrc; - int ghq_cache_save; - int ghq_cache_size; - int ghq_hirs_let_texartists_fly; - int ghq_hirs_dump; -#endif + inline const char * texture_dir(void) const { return m_texture_dir.c_str(); } + inline TextureFilter_t ghq_fltr(void) const { return m_ghq_fltr; } + inline TextureEnhancement_t ghq_enht(void) const { return m_ghq_enht; } + inline TextureCompression_t ghq_cmpr(void) const { return m_ghq_cmpr; } + inline HiResPackFormat_t ghq_hirs(void) const { return m_ghq_hirs; } + inline bool ghq_enht_cmpr(void) const { return m_ghq_enht_cmpr; } + inline bool ghq_enht_f16bpp(void) const { return m_ghq_enht_f16bpp; } + inline bool ghq_enht_gz(void) const { return m_ghq_enht_gz; } + inline bool ghq_enht_nobg(void) const { return m_ghq_enht_nobg; } + inline bool ghq_hirs_cmpr(void) const { return m_ghq_hirs_cmpr; } + inline bool ghq_hirs_tile(void) const { return m_ghq_hirs_tile; } + inline bool ghq_hirs_f16bpp(void) const { return m_ghq_hirs_f16bpp; } + inline bool ghq_hirs_gz(void) const { return m_ghq_hirs_gz; } + inline bool ghq_hirs_altcrc(void) const { return m_ghq_hirs_altcrc; } + inline bool ghq_cache_save(void) const { return m_ghq_cache_save; } + inline int ghq_cache_size(void) const { return m_ghq_cache_size; } + inline bool ghq_hirs_let_texartists_fly(void) const { return m_ghq_hirs_let_texartists_fly; } + inline bool ghq_hirs_dump(void) const { return m_ghq_hirs_dump; } //Debug - int autodetect_ucode; - int ucode; - int logging; - int elogging; - int log_clear; - int run_in_window; - int filter_cache; - int unk_as_red; - int log_unk; - int unk_clear; - int wireframe; - int wfmode; + inline bool autodetect_ucode(void) const { return m_autodetect_ucode; } + inline ucode_t ucode(void) const { return m_ucode; } + inline bool unk_as_red(void) const { return m_unk_as_red; } + inline bool wireframe(void) const { return m_wireframe; } + inline wfmode_t wfmode(void) const { return m_wfmode; } // Special fixes - int offset_x, offset_y; - int scale_x, scale_y; - int fast_crc; - int alt_tex_size; - int use_sts1_only; - int flame_corona; //hack for zeldas flame's corona - int increase_texrect_edge; // add 1 to lower right corner coordinates of texrect - int decrease_fillrect_edge; // sub 1 from lower right corner coordinates of fillrect - int texture_correction; // enable perspective texture correction emulation. is on by default - int stipple_mode; //used for dithered alpha emulation - uint32_t stipple_pattern; //used for dithered alpha emulation - int force_microcheck; //check microcode each frame, for mixed F3DEX-S2DEX games - int force_quad3d; //force 0xb5 command to be quad, not line 3d - int clip_zmin; //enable near z clipping - int clip_zmax; //enable far plane clipping; - int adjust_aspect; //adjust screen aspect for wide screen mode - int force_calc_sphere; //use spheric mapping only, Ridge Racer 64 - int pal230; //set special scale for PAL games - int correct_viewport; //correct viewport values - int zmode_compare_less; //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) - int old_style_adither; //apply alpha dither regardless of alpha_dither_mode - int n64_z_scale; //scale vertex z value before writing to depth buffer, as N64 does. - - //Special game hacks -#define hack_ASB (1<<0) //All-Star Baseball games -#define hack_Banjo2 (1<<1) //Banjo Tooie -#define hack_BAR (1<<2) //Beetle Adventure Racing -#define hack_Chopper (1<<3) //Chopper Attack -#define hack_Diddy (1<<4) //diddy kong racing -#define hack_Fifa98 (1<<5) //FIFA - Road to World Cup 98 -#define hack_Fzero (1<<6) //F-Zero -#define hack_GoldenEye (1<<7) //Golden Eye -#define hack_Hyperbike (1<<8) //Top Gear Hyper Bike -#define hack_ISS64 (1<<9) //International Superstar Soccer 64 -#define hack_KI (1<<10) //Killer Instinct -#define hack_Knockout (1<<11) //Knockout Kings 2000 -#define hack_Lego (1<<12) //LEGO Racers -#define hack_MK64 (1<<13) //Mario Kart -#define hack_Megaman (1<<14) //Megaman64 -#define hack_Makers (1<<15) //Mischief-makers -#define hack_WCWnitro (1<<16) //WCW Nitro -#define hack_Ogre64 (1<<17) //Ogre Battle 64 -#define hack_Pilotwings (1<<18) //Pilotwings -#define hack_PMario (1<<19) //Paper Mario -#define hack_PPL (1<<20) //pokemon puzzle league requires many special fixes -#define hack_RE2 (1<<21) //Resident Evil 2 -#define hack_Starcraft (1<<22) //StarCraft64 -#define hack_Supercross (1<<23) //Supercross 2000 -#define hack_TGR (1<<24) //Top Gear Rally -#define hack_TGR2 (1<<25) //Top Gear Rally 2 -#define hack_Tonic (1<<26) //tonic trouble -#define hack_Winback (1<<27) //WinBack - Covert Operations -#define hack_Yoshi (1<<28) //Yoshi Story -#define hack_Zelda (1<<29) //zeldas hacks -#define hack_OoT (1<<30) //zelda OoT hacks - uint32_t hacks; - + inline bool fast_crc(void) const { return m_fast_crc; } + inline bool alt_tex_size(void) const { return m_alt_tex_size; } + inline bool use_sts1_only(void) const { return m_use_sts1_only; } + inline bool flame_corona(void) const { return m_flame_corona; } //hack for zeldas flame's corona + inline bool increase_texrect_edge(void) const { return m_increase_texrect_edge; } // add 1 to lower right corner coordinates of texrect + inline bool decrease_fillrect_edge(void) const { return m_decrease_fillrect_edge; }; // sub 1 from lower right corner coordinates of fillrect + inline bool texture_correction(void) const { return m_texture_correction; } // enable perspective texture correction emulation. is on by default + inline StippleMode_t stipple_mode(void) const { return m_stipple_mode; } //used for dithered alpha emulation + inline uint32_t stipple_pattern(void) const { return m_stipple_pattern; } //used for dithered alpha emulation + inline bool force_microcheck(void) const { return m_force_microcheck; } //check microcode each frame, for mixed F3DEX-S2DEX games + inline bool force_quad3d(void) const { return m_force_quad3d; } //force 0xb5 command to be quad, not line 3d + inline bool clip_zmin(void) const { return m_clip_zmin; } //enable near z clipping + inline bool clip_zmax(void) const { return m_clip_zmax; } //enable far plane clipping + inline bool adjust_aspect(void) const { return m_adjust_aspect; } //adjust screen aspect for wide screen mode + inline bool force_calc_sphere(void) const { return m_force_calc_sphere; } //use spheric mapping only, Ridge Racer 64 + inline bool pal230(void) const { return m_pal230; } //use spheric mapping only, Ridge Racer 64 + inline bool correct_viewport(void) const { return m_correct_viewport; } //correct viewport values + inline bool zmode_compare_less(void) const { return m_zmode_compare_less; } //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) + inline bool old_style_adither(void) const { return m_old_style_adither; } //apply alpha dither regardless of alpha_dither_mode + inline bool n64_z_scale(void) const { return m_n64_z_scale; } //scale vertex z value before writing to depth buffer, as N64 does. + + inline bool hacks(hacks_t hack) const { return (m_hacks & hack) == hack; } //Special game hacks + //wrapper settings #ifndef ANDROID - int wrpResolution; + inline uint32_t FullScreenRes(void) const { return m_FullScreenRes; } #endif - int wrpVRAM; - int wrpFBO; - int wrpAnisotropic; + inline int wrpVRAM(void) const { return m_wrpVRAM; } + inline bool wrpFBO(void) const { return m_wrpFBO; } + inline bool wrpAnisotropic(void) const { return m_wrpAnisotropic; } + inline bool FlushLogs(void) const { return m_FlushLogs; } + + void SetTexenhOptions(bool value); + void SetScreenRes(uint32_t value); + void SetAspectmode(AspectMode_t value); + void SetLODmode(PixelLevelOfDetail_t value); + void SetVsync(bool value); + void SetFiltering(Filtering_t value); + void SetSwapMode(SwapMode_t value); + void SetFog(bool value); + void SetBuffClear(bool value); + void SetWrpAnisotropic(bool value); + void SetWrpVRAM(int value); + void SetWrpFBO(bool value); + void SetGhqFltr(TextureFilter_t value); + void SetGhqEnht(TextureEnhancement_t value); + void SetGhqCmpr(TextureCompression_t value); + void SetGhqHirs(HiResPackFormat_t value); + void SetGhqEnhtGz(bool value); + void SetGhqHirsTile(bool value); + void SetGhqHirsF16bpp(bool value); + void SetGhqHirsDump(bool value); + void SetGhqEnhtNobg(bool value); + void SetGhqEnhtCmpr(bool value); + void SetGhqHirsAltcrc(bool value); + void SetGhqHirsCmpr(bool value); + void SetGhqHirsGz(bool value); + void SetGhqCacheSave(bool value); + void SetGhqHirsLetTexartistsFly(bool value); + void SetGhqCacheSize(int value); + void UpdateFrameBufferBits(uint32_t BitsToAdd, uint32_t BitsToRemove); + ucode_t DetectUCode(uint32_t uc_crc); + void SetUcode(ucode_t value); +#ifndef ANDROID + void SetFullScreenRes(uint32_t value); +#endif + void ReadSettings(); + void ReadGameSettings(const char * name); + void WriteSettings(void); + void UpdateScreenSize(bool fullscreen); + +private: + static void general_setting(short setting_ID, const char * name, unsigned int value); + static void game_setting(short setting_ID, const char * name, unsigned int value); + static void game_setting_default(short setting_ID, const char * name, short default_setting); + + void RegisterSettings(void); + void UpdateAspectRatio(void); + void SettingsChanged(void); + + static void stSettingsChanged(void * _this) + { + ((CSettings *)_this)->SettingsChanged(); + } + + short m_Set_basic_mode; + short m_Set_texture_dir; + short m_Set_log_dir; + short m_Set_log_flush; + + bool m_dirty; +#ifndef ANDROID + uint32_t m_FullScreenRes; +#endif + int m_wrpVRAM; + bool m_wrpFBO; + bool m_wrpAnisotropic; + bool m_FlushLogs; + char m_log_dir[260]; + uint32_t m_ScreenRes; + uint32_t m_res_x, m_scr_res_x; + uint32_t m_res_y, m_scr_res_y; + AspectMode_t m_aspectmode; + uint32_t m_frame_buffer; + FBCRCMODE_t m_fb_crc_mode; + ScreenRotate_t m_rotate; + Filtering_t m_filtering; + bool m_fog; + bool m_buff_clear; + SwapMode_t m_swapmode; + PixelLevelOfDetail_t m_lodmode; + bool m_advanced_options; + bool m_texenh_options; + bool m_vsync; + std::string m_texture_dir; + TextureFilter_t m_ghq_fltr; + TextureEnhancement_t m_ghq_enht; + TextureCompression_t m_ghq_cmpr; + HiResPackFormat_t m_ghq_hirs; + bool m_ghq_enht_cmpr; + bool m_ghq_enht_f16bpp; + bool m_ghq_enht_gz; + bool m_ghq_enht_nobg; + bool m_ghq_hirs_cmpr; + bool m_ghq_hirs_tile; + bool m_ghq_hirs_f16bpp; + bool m_ghq_hirs_gz; + bool m_ghq_hirs_altcrc; + bool m_ghq_cache_save; + int m_ghq_cache_size; + bool m_ghq_hirs_let_texartists_fly; + bool m_ghq_hirs_dump; + bool m_autodetect_ucode; + bool m_unk_as_red; + bool m_wireframe; + wfmode_t m_wfmode; + ucode_t m_ucode; + bool m_fast_crc; + bool m_alt_tex_size; + bool m_use_sts1_only; + bool m_flame_corona; + bool m_increase_texrect_edge; + bool m_decrease_fillrect_edge; + bool m_texture_correction; + StippleMode_t m_stipple_mode; + uint32_t m_stipple_pattern; + bool m_force_microcheck; + bool m_force_quad3d; + bool m_clip_zmin; + bool m_clip_zmax; + bool m_adjust_aspect; + bool m_force_calc_sphere; + bool m_pal230; + bool m_correct_viewport; + bool m_zmode_compare_less; + bool m_old_style_adither; + bool m_n64_z_scale; + hacks_t m_hacks; }; extern CSettings * g_settings; diff --git a/Source/Glide64/SettingsID.h b/Source/Glide64/SettingsID.h new file mode 100644 index 000000000..bf601eafa --- /dev/null +++ b/Source/Glide64/SettingsID.h @@ -0,0 +1,48 @@ +/**************************************************************************** +* * +* Project 64 - A Nintendo 64 emulator. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2012 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ +#pragma once + +enum +{ + // General Settings + Set_vsync, Set_Rotate, Set_texenh_options, Set_wrpVRAM, + Set_wrpFBO, Set_wrpAnisotropic, Set_autodetect_ucode, Set_ucode, Set_wireframe, + Set_wfmode, Set_ghq_fltr, Set_ghq_cmpr, Set_ghq_enht, Set_ghq_hirs, Set_ghq_enht_cmpr, + Set_ghq_enht_f16bpp, Set_ghq_enht_gz, Set_ghq_enht_nobg, Set_ghq_hirs_cmpr, + Set_ghq_hirs_tile, Set_ghq_hirs_f16bpp, Set_ghq_hirs_gz, Set_ghq_hirs_altcrc, + Set_ghq_cache_save, Set_ghq_cache_size, Set_ghq_hirs_let_texartists_fly, + Set_ghq_hirs_dump, Set_Resolution, + + // Default Game Settings + Set_optimize_texrect_default, Set_filtering_default, Set_lodmode_default, + Set_fog_default, Set_buff_clear_default, Set_swapmode_default, + Set_aspect_default, Set_fb_smart_default, Set_fb_hires_default, + Set_fb_read_always_default, Set_read_back_to_screen_default, Set_detect_cpu_write_default, + Set_fb_get_info_default, Set_fb_render_default, + + //Game Settings + Set_alt_tex_size, Set_use_sts1_only, Set_force_calc_sphere, Set_correct_viewport, + Set_increase_texrect_edge, Set_decrease_fillrect_edge, Set_texture_correction, + Set_pal230, Set_stipple_mode, Set_stipple_pattern, Set_force_microcheck, Set_force_quad3d, + Set_clip_zmin, Set_clip_zmax, Set_fast_crc, Set_adjust_aspect, Set_zmode_compare_less, + Set_old_style_adither, Set_n64_z_scale, Set_optimize_texrect, Set_ignore_aux_copy, + Set_hires_buf_clear, Set_fb_read_alpha, Set_useless_is_useless, Set_fb_crc_mode, + Set_filtering, Set_fog, Set_buff_clear, Set_swapmode, Set_aspect, Set_lodmode, + Set_fb_smart, Set_fb_hires, Set_fb_read_always, Set_read_back_to_screen, + Set_detect_cpu_write, Set_fb_get_info, Set_fb_render, + + //RDB Setting + Set_ucodeLookup, + +#ifdef _WIN32 + Set_FullScreenRes, +#endif +}; diff --git a/Source/Glide64/TexBuffer.cpp b/Source/Glide64/TexBuffer.cpp index 2759d9640..af44e9bb3 100644 --- a/Source/Glide64/TexBuffer.cpp +++ b/Source/Glide64/TexBuffer.cpp @@ -57,7 +57,7 @@ static TBUFF_COLOR_IMAGE * AllocateTextureBuffer(COLOR_IMAGE & cimage) texbuf.height = cimage.height; texbuf.format = cimage.format; texbuf.size = cimage.size; - texbuf.scr_width = minval(cimage.width * rdp.scale_x, g_settings->scr_res_x); + texbuf.scr_width = minval(cimage.width * rdp.scale_x, g_settings->scr_res_x()); float height = minval(rdp.vi_height, cimage.height); if (cimage.status == ci_copy_self || (cimage.status == ci_copy && cimage.width == rdp.frame_buffers[rdp.main_ci_index].width)) height = rdp.vi_height; @@ -216,7 +216,7 @@ int OpenTextureBuffer(COLOR_IMAGE & cimage) int found = FALSE, search = TRUE; TBUFF_COLOR_IMAGE *texbuf = 0; uint32_t addr = cimage.addr; - if ((g_settings->hacks&hack_Banjo2) && cimage.status == ci_copy_self) + if (g_settings->hacks(CSettings::hack_Banjo2) && cimage.status == ci_copy_self) addr = rdp.frame_buffers[rdp.copy_ci_index].addr; uint32_t end_addr = addr + ((cimage.width*cimage.height) << cimage.size >> 1); if (rdp.motionblur) @@ -227,7 +227,7 @@ int OpenTextureBuffer(COLOR_IMAGE & cimage) } if (rdp.read_whole_frame) { - if (g_settings->hacks&hack_PMario) //motion blur effects in Paper Mario + if (g_settings->hacks(CSettings::hack_PMario)) //motion blur effects in Paper Mario { rdp.cur_tex_buf = rdp.acc_tex_buf; WriteTrace(TraceRDP, TraceDebug, "\nread_whole_frame. last allocated bank: %d", rdp.acc_tex_buf); @@ -326,8 +326,8 @@ int OpenTextureBuffer(COLOR_IMAGE & cimage) grRenderBuffer(GR_BUFFER_TEXTUREBUFFER_EXT); grTextureBufferExt(rdp.cur_image->tmu, rdp.cur_image->tex_addr, rdp.cur_image->info.smallLodLog2, rdp.cur_image->info.largeLodLog2, rdp.cur_image->info.aspectRatioLog2, rdp.cur_image->info.format, GR_MIPMAPLEVELMASK_BOTH); - ///* - if (rdp.cur_image->clear && (g_settings->frame_buffer&fb_hwfbe_buf_clear) && cimage.changed) + + if (rdp.cur_image->clear && g_settings->fb_hwfbe_buf_clear_enabled() && cimage.changed) { rdp.cur_image->clear = FALSE; grDepthMask(FXFALSE); @@ -369,7 +369,7 @@ static GrTextureFormat_t TexBufSetupCombiner(int force_rgb = FALSE) GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO); - grClipWindow(0, 0, g_settings->scr_res_x, g_settings->scr_res_y); + grClipWindow(0, 0, g_settings->scr_res_x(), g_settings->scr_res_y()); grDepthBufferFunction(GR_CMP_ALWAYS); grDepthMask(FXFALSE); grCullMode(GR_CULL_DISABLE); @@ -457,11 +457,11 @@ int CloseTextureBuffer(int draw) }; grTexSource(rdp.tbuff_tex->tmu, rdp.tbuff_tex->tex_addr, GR_MIPMAPLEVELMASK_BOTH, &(rdp.tbuff_tex->info)); - grClipWindow(0, 0, g_settings->res_x, g_settings->res_y); + grClipWindow(0, 0, g_settings->res_x(), g_settings->res_y()); grDrawTriangle(&v[0], &v[2], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]); rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) { grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); } @@ -519,14 +519,14 @@ int CopyTextureBuffer(COLOR_IMAGE & fb_from, COLOR_IMAGE & fb_to) rdp.offset_y = rdp.offset_y_bak; rdp.offset_x_bak = rdp.offset_y_bak = 0; AddOffset(v, 4); - grClipWindow(0, 0, g_settings->res_x, g_settings->res_y); + grClipWindow(0, 0, g_settings->res_x(), g_settings->res_y()); grDrawTriangle(&v[0], &v[2], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]); rdp.tbuff_tex->info.format = buf_format; rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE; rdp.update |= UPDATE_VIEWPORT | UPDATE_SCISSOR; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); WriteTrace(TraceRDP, TraceDebug, "CopyTextureBuffer draw, OK"); rdp.tbuff_tex = 0; @@ -539,7 +539,7 @@ int CopyDepthBuffer() WriteTrace(TraceRDP, TraceDebug, "CopyDepthBuffer. "); float bound = 1024.0f; GrLOD_t LOD = GR_LOD_LOG2_1024; - if (g_settings->scr_res_x > 1024) + if (g_settings->scr_res_x() > 1024) { bound = 2048.0f; LOD = GR_LOD_LOG2_2048; @@ -580,7 +580,7 @@ int CopyDepthBuffer() grAuxBufferExt(GR_BUFFER_TEXTUREAUXBUFFER_EXT); rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); WriteTrace(TraceRDP, TraceDebug, "CopyDepthBuffer draw, OK"); rdp.tbuff_tex = 0; @@ -654,7 +654,7 @@ int SwapTextureBuffer() rdp.update |= UPDATE_VIEWPORT | UPDATE_SCISSOR; } rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) { grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); } @@ -665,11 +665,15 @@ int SwapTextureBuffer() static uint32_t CalcCRC(TBUFF_COLOR_IMAGE * pTCI) { uint32_t result = 0; - if ((g_settings->frame_buffer&fb_ref) > 0) + if (g_settings->fb_ref_enabled()) + { pTCI->crc = 0; //Since fb content changes each frame, crc check is meaningless. - else if (g_settings->fb_crc_mode == CSettings::fbcrcFast) + } + else if (g_settings->fb_crc_mode() == CSettings::fbcrcFast) + { result = *((uint32_t*)(gfx.RDRAM + pTCI->addr + (pTCI->end_addr - pTCI->addr) / 2)); - else if (g_settings->fb_crc_mode == CSettings::fbcrcSafe) + } + else if (g_settings->fb_crc_mode() == CSettings::fbcrcSafe) { uint8_t * pSrc = gfx.RDRAM + pTCI->addr; const uint32_t nSize = pTCI->end_addr - pTCI->addr; diff --git a/Source/Glide64/TexCache.cpp b/Source/Glide64/TexCache.cpp index f0ccc5eb5..a6c0dcee8 100644 --- a/Source/Glide64/TexCache.cpp +++ b/Source/Glide64/TexCache.cpp @@ -59,11 +59,11 @@ uint8_t *texture_buffer = tex1; #include "TexMod.h" #include "TexModCI.h" #include "CRC.h" -#ifdef TEXTURE_FILTER // Hiroshi Morii -extern int ghq_dmptex_toggle_key; -#endif -typedef struct TEXINFO_t { +extern bool g_ghq_use; + +typedef struct TEXINFO_t +{ int real_image_width, real_image_height; // FOR ALIGNMENT PURPOSES ONLY!!! int tile_width, tile_height; int mask_width, mask_height; @@ -72,21 +72,18 @@ typedef struct TEXINFO_t { uint32_t crc; uint32_t flags; int splits, splitheight; -#ifdef TEXTURE_FILTER uint64 ricecrc; -#endif } TEXINFO; TEXINFO texinfo[2]; int tex_found[2][MAX_TMU]; -#ifdef TEXTURE_FILTER -typedef struct HIRESTEX_t { +typedef struct HIRESTEX_t +{ int width, height; uint16_t format; uint8_t *data; } HIRESTEX; -#endif //**************************************************************** // List functions @@ -203,7 +200,7 @@ void GetTexInfo(int id, int tile) mask_width = (rdp.tiles[tile].mask_s == 0) ? (tile_width) : (1 << rdp.tiles[tile].mask_s); mask_height = (rdp.tiles[tile].mask_t == 0) ? (tile_height) : (1 << rdp.tiles[tile].mask_t); - if (g_settings->alt_tex_size) + if (g_settings->alt_tex_size()) { // ** ALTERNATE TEXTURE SIZE METHOD ** // Helps speed in some games that loaded weird-sized textures, but could break other @@ -356,7 +353,7 @@ void GetTexInfo(int id, int tile) if (rdp.tiles[tile].size == 3) line <<= 1; uint32_t crc = 0; - if (g_settings->fast_crc) + if (g_settings->fast_crc()) { line = (line - wid_64) << 3; if (wid_64 < 1) wid_64 = 1; @@ -527,28 +524,6 @@ void TexCache() { WriteTrace(TraceRDP, TraceDebug, " |-+ TexCache called"); -#ifdef TEXTURE_FILTER /* Hiroshi Morii */ // POSTNAPALM - if (g_settings->ghq_use && g_settings->ghq_hirs_dump) { - /* Force reload hi-res textures. Useful for texture artists */ - if (CheckKeyPressed(G64_VK_R, 0x0001)) { - if (ext_ghq_reloadhirestex()) ClearCache(); - } - /* Turn on texture dump */ - else if (CheckKeyPressed(G64_VK_D, 0x0001)) { - extern void DisplayLoadProgress(const wchar_t *format, ...); - ghq_dmptex_toggle_key = !ghq_dmptex_toggle_key; - if (ghq_dmptex_toggle_key) { - DisplayLoadProgress(L"Texture dump - ON"); - ClearCache(); - } - else { - DisplayLoadProgress(L"Texture dump - OFF"); - } - pjutil::Sleep(1000); - } - } -#endif - if (rdp.tex & 1) GetTexInfo(0, rdp.cur_tile); if (rdp.tex & 2) @@ -894,14 +869,14 @@ void TexCache() int tile = rdp.cur_tile + i; - if (g_settings->filtering == 0) + if (g_settings->filtering() == CSettings::Filter_Automatic) { int filter = (rdp.filter_mode != 2) ? GR_TEXTUREFILTER_POINT_SAMPLED : GR_TEXTUREFILTER_BILINEAR; grTexFilterMode(tmu, filter, filter); } else { - int filter = (g_settings->filtering == 1) ? GR_TEXTUREFILTER_BILINEAR : GR_TEXTUREFILTER_POINT_SAMPLED; + int filter = (g_settings->filtering() == CSettings::Filter_ForceBilinear) ? GR_TEXTUREFILTER_BILINEAR : GR_TEXTUREFILTER_POINT_SAMPLED; grTexFilterMode(tmu, filter, filter); } @@ -962,7 +937,6 @@ void TexCache() WriteTrace(TraceRDP, TraceDebug, " | +- TexCache End"); } -#ifdef TEXTURE_FILTER /** cite from RiceVideo */ inline uint32_t CalculateDXT(uint32_t txl2words) { @@ -996,7 +970,6 @@ inline uint32_t ReverseDXT(uint32_t val, uint32_t /*lrs*/, uint32_t width, uint3 return (low + high) / 2; } /** end RiceVideo cite */ -#endif //**************************************************************** // LoadTex - does the actual texture loading after everything is prepared @@ -1029,7 +1002,7 @@ void LoadTex(int id, int tmu) //!Hackalert //GoldenEye water texture. It has CI format in fact, but the game set it to RGBA - if ((g_settings->hacks&hack_GoldenEye) && rdp.tiles[td].format == 0 && rdp.tlut_mode == 2 && rdp.tiles[td].size == 2) + if (g_settings->hacks(CSettings::hack_GoldenEye) && rdp.tiles[td].format == 0 && rdp.tlut_mode == 2 && rdp.tiles[td].size == 2) { rdp.tiles[td].format = 2; rdp.tiles[td].size = 1; @@ -1054,10 +1027,8 @@ void LoadTex(int id, int tmu) cache->f_mirror_t = FALSE; cache->f_wrap_s = FALSE; cache->f_wrap_t = FALSE; -#ifdef TEXTURE_FILTER cache->is_hires_tex = FALSE; cache->ricecrc = texinfo[id].ricecrc; -#endif // Add this cache to the list AddToList(&cachelut[cache->crc >> 16], cache->crc, uintptr_t(cache), tmu, rdp.n_cached[tmu]); @@ -1283,11 +1254,10 @@ void LoadTex(int id, int tmu) // when we get passed the texture ram cache and texture buffers for // minimal calculation overhead. // -#ifdef TEXTURE_FILTER // Hiroshi Morii GHQTexInfo ghqTexInfo; memset(&ghqTexInfo, 0, sizeof(GHQTexInfo)); uint32_t g64_crc = cache->crc; - if (g_settings->ghq_use) + if (g_ghq_use) { int bpl; uint8_t* addr = (uint8_t*)(gfx.RDRAM + rdp.addr[rdp.tiles[td].t_mem]); @@ -1329,7 +1299,7 @@ void LoadTex(int id, int tmu) { if (rdp.tiles[td].size == 1) paladdr = (uint8_t*)(rdp.pal_8_rice); - else if (g_settings->ghq_hirs_altcrc) + else if (g_settings->ghq_hirs_altcrc()) paladdr = (uint8_t*)(rdp.pal_8_rice + (rdp.tiles[td].palette << 5)); else paladdr = (uint8_t*)(rdp.pal_8_rice + (rdp.tiles[td].palette << 4)); @@ -1359,7 +1329,6 @@ void LoadTex(int id, int tmu) if (ghqTexInfo.data) ;//do nothing else -#endif if (splits > 1) { cache->scale_y = 0.125f; @@ -1491,11 +1460,7 @@ void LoadTex(int id, int tmu) memcpy(rdp.pal_8, tmp_pal, 512); } -#ifdef TEXTURE_FILTER if (mod && !modifyPalette && !ghqTexInfo.data) -#else - if (mod && !modifyPalette) -#endif { // Convert the texture to ARGB 4444 if (LOWORD(result) == GR_TEXFMT_ARGB_1555) @@ -1616,46 +1581,10 @@ void LoadTex(int id, int tmu) if (GfxInitDone) { -#ifdef TEXTURE_FILTER // Hiroshi Morii - if (g_settings->ghq_use) + if (g_ghq_use) { - if (!ghqTexInfo.data && ghq_dmptex_toggle_key) { - unsigned char *tmpbuf = (unsigned char*)texture; - int tmpwidth = real_x; - if (texinfo[id].splits > 1) { - int dstpixoffset, srcpixoffset; - int shift; - switch (LOWORD(result) & 0x7fff) { // XXX is there a better way of determining the pixel color depth? - case GR_TEXFMT_ARGB_8888: - shift = 3; - break; - case GR_TEXFMT_ALPHA_INTENSITY_44: - case GR_TEXFMT_ALPHA_8: - shift = 0; - break; - default: - shift = 1; - } - tmpwidth = texinfo[id].real_image_width; - tmpbuf = (unsigned char*)malloc((256 * 256) << 3); // XXX performance overhead - for (int i = 0; i < cache->splitheight; i++) { - dstpixoffset = texinfo[id].real_image_width * i; - srcpixoffset = 256 * i; - for (int k = 0; k < texinfo[id].splits; k++) { - memcpy(tmpbuf + (dstpixoffset << shift), texture + (srcpixoffset << shift), (256 << shift)); - dstpixoffset += 256; - srcpixoffset += (256 * cache->splitheight); - } - } - } - ext_ghq_dmptx(tmpbuf, (int)texinfo[id].real_image_width, (int)texinfo[id].real_image_height, (int)tmpwidth, (unsigned short)LOWORD(result), (unsigned short)((cache->format << 8) | (cache->size)), cache->ricecrc); - if (tmpbuf != texture && tmpbuf) { - free(tmpbuf); - } - } - if (!ghqTexInfo.data) - if (!g_settings->ghq_enht_nobg || !rdp.texrecting || (texinfo[id].splits == 1 && texinfo[id].width <= 256)) + if (!g_settings->ghq_enht_nobg() || !rdp.texrecting || (texinfo[id].splits == 1 && texinfo[id].width <= 256)) ext_ghq_txfilter((unsigned char*)texture, (int)real_x, (int)real_y, LOWORD(result), (uint64)g64_crc, &ghqTexInfo); if (ghqTexInfo.data) @@ -1713,17 +1642,6 @@ void LoadTex(int id, int tmu) cache->c_scl_y *= mscale; cache->c_scl_x *= mscale; } - /* - else - { - if (rdp.tiles[td].mirror_s && sup_mirroring) - cache->f_mirror_s = TRUE; - if (rdp.tiles[td].mirror_t && sup_mirroring) - cache->f_mirror_t = TRUE; - //cache->c_scl_y /= mscale; - //cache->c_scl_x /= mscale; - } - */ if (ghqTexInfo.aspectRatioLog2 >= 0) { cache->scale_x = 1.0f; @@ -1763,7 +1681,6 @@ void LoadTex(int id, int tmu) } else { - //cache->scale = 256.0f / float(1<c_off = 128.0f / float(1 << lod); } real_x = ghqTexInfo.width; @@ -1775,7 +1692,6 @@ void LoadTex(int id, int tmu) } } } -#endif // Load the texture into texture memory GrTexInfo *t_info = &cache->t_info; diff --git a/Source/Glide64/Util.cpp b/Source/Glide64/Util.cpp index 5b817950e..de4a0f979 100644 --- a/Source/Glide64/Util.cpp +++ b/Source/Glide64/Util.cpp @@ -289,7 +289,7 @@ VERTEX **org_vtx; void draw_tri(VERTEX **vtx, uint16_t linew) { deltaZ = dzdx = 0; - if (linew == 0 && (fb_depth_render_enabled || (rdp.rm & 0xC00) == 0xC00)) + if (linew == 0 && (g_settings->fb_depth_render_enabled() || (rdp.rm & 0xC00) == 0xC00)) { double X0 = vtx[0]->sx / rdp.scale_x; double Y0 = vtx[0]->sy / rdp.scale_y; @@ -308,12 +308,15 @@ void draw_tri(VERTEX **vtx, uint16_t linew) double diffz_02 = vtx[0]->sz - vtx[2]->sz; double diffz_12 = vtx[1]->sz - vtx[2]->sz; double fdzdx = (diffz_02 * diffy_12 - diffz_12 * diffy_02) / denom; - if ((rdp.rm & 0xC00) == 0xC00) { + if ((rdp.rm & 0xC00) == 0xC00) + { // Calculate deltaZ per polygon for Decal z-mode double fdzdy = (diffz_02 * diffx_12 - diffz_12 * diffx_02) / denom; double fdz = fabs(fdzdx) + fabs(fdzdy); - if ((g_settings->hacks & hack_Zelda) && (rdp.rm & 0x800)) + if (g_settings->hacks(CSettings::hack_Zelda) && (rdp.rm & 0x800)) + { fdz *= 4.0; // Decal mode in Zelda sometimes needs mutiplied deltaZ to work correct, e.g. roads + } deltaZ = maxval(8, (int)fdz); } dzdx = (int)(fdzdx * 65536.0); @@ -398,7 +401,7 @@ void draw_tri(VERTEX **vtx, uint16_t linew) { if (rdp.aTBuffTex[0]->tile_uls != (int)rdp.tiles[rdp.cur_tile].f_ul_s) v->u0 -= rdp.tiles[rdp.cur_tile].f_ul_s; - if (rdp.aTBuffTex[0]->tile_ult != (int)rdp.tiles[rdp.cur_tile].f_ul_t || (g_settings->hacks&hack_Megaman)) + if (rdp.aTBuffTex[0]->tile_ult != (int)rdp.tiles[rdp.cur_tile].f_ul_t || g_settings->hacks(CSettings::hack_Megaman)) v->v0 -= rdp.tiles[rdp.cur_tile].f_ul_t; //required for megaman (boss special attack) v->u0 *= rdp.aTBuffTex[0]->u_scale; v->v0 *= rdp.aTBuffTex[0]->v_scale; @@ -799,10 +802,14 @@ void do_triangle_stuff(uint16_t linew, int old_interpolate) // what else?? do th rdp.clip = 0; else { - if (!g_settings->clip_zmin) + if (!g_settings->clip_zmin()) + { rdp.clip &= ~CLIP_ZMIN; - if (!g_settings->clip_zmax) + } + if (!g_settings->clip_zmax()) + { rdp.clip &= ~CLIP_ZMAX; + } } render_tri(linew, old_interpolate); } @@ -964,7 +971,7 @@ static void CalculateLOD(VERTEX *v, int n) double intptr; float s_scale = rdp.tiles[rdp.cur_tile].width / 255.0f; float t_scale = rdp.tiles[rdp.cur_tile].height / 255.0f; - if (g_settings->lodmode == 1) + if (g_settings->lodmode() == CSettings::LOD_Fast) { deltaS = (v[1].u0 / v[1].q - v[0].u0 / v[0].q) * s_scale; deltaT = (v[1].v0 / v[1].q - v[0].v0 / v[0].q) * t_scale; @@ -1018,7 +1025,7 @@ static void CalculateLOD(VERTEX *v, int n) float ScaleZ(float z) { - if (g_settings->n64_z_scale) + if (g_settings->n64_z_scale()) { int iz = (int)(z*8.0f + 0.5f); if (iz < 0) iz = 0; @@ -1033,7 +1040,7 @@ float ScaleZ(float z) static void DepthBuffer(VERTEX * vtx, int n) { - if (fb_depth_render_enabled && !(g_settings->hacks&hack_RE2) && dzdx && (rdp.flags & ZBUF_UPDATE)) + if (g_settings->fb_depth_render_enabled() && !g_settings->hacks(CSettings::hack_RE2) && dzdx && (rdp.flags & ZBUF_UPDATE)) { vertexi v[12]; if (u_cull_mode == 1) //cull front @@ -1562,21 +1569,14 @@ static void render_tri(uint16_t linew, int old_interpolate) } } - if (g_settings->lodmode > 0 && rdp.cur_tile < rdp.mipmap_level) + if (g_settings->lodmode() != CSettings::LOD_Off && rdp.cur_tile < rdp.mipmap_level) + { CalculateLOD(rdp.vtxbuf, n); + } cmb.cmb_ext_use = cmb.tex_cmb_ext_use = 0; - /* - if (rdp.tbuff_tex) - { - for (int k = 0; k < 3; k++) - { - WriteTrace(TraceRDP, TraceDebug, "v%d %f->%f, width: %d. height: %d, tex_width: %d, tex_height: %d, lr_u: %f, lr_v: %f", k, vv0[k], pv[k]->v1, rdp.tbuff_tex->width, rdp.tbuff_tex->height, rdp.tbuff_tex->tex_width, rdp.tbuff_tex->tex_height, rdp.tbuff_tex->lr_u, rdp.tbuff_tex->lr_v); - } - } - */ - if (g_settings->wireframe) + if (g_settings->wireframe()) { SetWireframeCol(); for (i = 0; i < n; i++) @@ -1588,11 +1588,6 @@ static void render_tri(uint16_t linew, int old_interpolate) } else { - // VERTEX ** pv = rdp.vtx_buffer?(vtx_list2):(vtx_list1); - // for (int k = 0; k < n; k ++) - // WriteTrace(TraceRDP, TraceDebug, "DRAW[%d]: v.x = %f, v.y = %f, v.z = %f, v.u = %f, v.v = %f", k, pv[k]->x, pv[k]->y, pv[k]->z, pv[k]->coord[rdp.t0<<1], pv[k]->coord[(rdp.t0<<1)+1]); - // pv[k]->y = g_settings->res_y - pv[k]->y; - if (linew > 0) { VERTEX *V0 = &rdp.vtxbuf[0]; @@ -1652,83 +1647,6 @@ static void render_tri(uint16_t linew, int old_interpolate) grDrawVertexArray(GR_TRIANGLE_FAN, n, rdp.vtx_buffer ? (&vtx_list2) : (&vtx_list1)); } } - - if (_debugger.capture) add_tri(rdp.vtxbuf, n, TRI_TRIANGLE); -} - -void add_tri(VERTEX *v, int n, int type) -{ - //WriteTrace(TraceRDP, TraceDebug, "ENTER (%f, %f, %f), (%f, %f, %f), (%f, %f, %f)", v[0].x, v[0].y, v[0].w, - // v[1].x, v[1].y, v[1].w, v[2].x, v[2].y, v[2].w); - - // Debug capture - if (_debugger.capture) - { - rdp.debug_n++; - - TRI_INFO *info = new TRI_INFO; - info->nv = n; - info->v = new VERTEX[n]; - memcpy(info->v, v, sizeof(VERTEX)*n); - info->cycle_mode = rdp.cycle_mode; - info->cycle1 = rdp.cycle1; - info->cycle2 = rdp.cycle2; - info->uncombined = rdp.uncombined; - info->geom_mode = rdp.geom_mode; - info->othermode_h = rdp.othermode_h; - info->othermode_l = rdp.othermode_l; - info->tri_n = rdp.tri_n; - info->type = type; - - for (int i = 0; i < 2; i++) - { - int j = rdp.cur_tile + i; - if (i == 0) - info->t[i].tmu = rdp.t0; - else - info->t[i].tmu = rdp.t1; - info->t[i].cur_cache[0] = rdp.cur_cache_n[rdp.t0]; - info->t[i].cur_cache[1] = rdp.cur_cache_n[rdp.t1]; - info->t[i].format = rdp.tiles[j].format; - info->t[i].size = rdp.tiles[j].size; - info->t[i].width = rdp.tiles[j].width; - info->t[i].height = rdp.tiles[j].height; - info->t[i].line = rdp.tiles[j].line; - info->t[i].palette = rdp.tiles[j].palette; - info->t[i].clamp_s = rdp.tiles[j].clamp_s; - info->t[i].clamp_t = rdp.tiles[j].clamp_t; - info->t[i].mirror_s = rdp.tiles[j].mirror_s; - info->t[i].mirror_t = rdp.tiles[j].mirror_t; - info->t[i].shift_s = rdp.tiles[j].shift_s; - info->t[i].shift_t = rdp.tiles[j].shift_t; - info->t[i].mask_s = rdp.tiles[j].mask_s; - info->t[i].mask_t = rdp.tiles[j].mask_t; - info->t[i].ul_s = rdp.tiles[j].ul_s; - info->t[i].ul_t = rdp.tiles[j].ul_t; - info->t[i].lr_s = rdp.tiles[j].lr_s; - info->t[i].lr_t = rdp.tiles[j].lr_t; - info->t[i].t_ul_s = rdp.tiles[7].t_ul_s; - info->t[i].t_ul_t = rdp.tiles[7].t_ul_t; - info->t[i].t_lr_s = rdp.tiles[7].t_lr_s; - info->t[i].t_lr_t = rdp.tiles[7].t_lr_t; - info->t[i].scale_s = rdp.tiles[j].s_scale; - info->t[i].scale_t = rdp.tiles[j].t_scale; - } - - info->fog_color = rdp.fog_color; - info->fill_color = rdp.fill_color; - info->prim_color = rdp.prim_color; - info->blend_color = rdp.blend_color; - info->env_color = rdp.env_color; - info->prim_lodmin = rdp.prim_lodmin; - info->prim_lodfrac = rdp.prim_lodfrac; - - info->pNext = _debugger.tri_list; - _debugger.tri_list = info; - - if (_debugger.tri_last == NULL) - _debugger.tri_last = _debugger.tri_list; - } } void update_scissor() @@ -1738,10 +1656,10 @@ void update_scissor() rdp.update ^= UPDATE_SCISSOR; // KILL the floating point error with 0.01f - rdp.scissor.ul_x = (uint32_t)maxval(minval((rdp.scissor_o.ul_x * rdp.scale_x + rdp.offset_x + 0.01f), g_settings->res_x), 0); - rdp.scissor.lr_x = (uint32_t)maxval(minval((rdp.scissor_o.lr_x * rdp.scale_x + rdp.offset_x + 0.01f), g_settings->res_x), 0); - rdp.scissor.ul_y = (uint32_t)maxval(minval((rdp.scissor_o.ul_y * rdp.scale_y + rdp.offset_y + 0.01f), g_settings->res_y), 0); - rdp.scissor.lr_y = (uint32_t)maxval(minval((rdp.scissor_o.lr_y * rdp.scale_y + rdp.offset_y + 0.01f), g_settings->res_y), 0); + rdp.scissor.ul_x = (uint32_t)maxval(minval((rdp.scissor_o.ul_x * rdp.scale_x + rdp.offset_x + 0.01f), g_settings->res_x()), 0); + rdp.scissor.lr_x = (uint32_t)maxval(minval((rdp.scissor_o.lr_x * rdp.scale_x + rdp.offset_x + 0.01f), g_settings->res_x()), 0); + rdp.scissor.ul_y = (uint32_t)maxval(minval((rdp.scissor_o.ul_y * rdp.scale_y + rdp.offset_y + 0.01f), g_settings->res_y()), 0); + rdp.scissor.lr_y = (uint32_t)maxval(minval((rdp.scissor_o.lr_y * rdp.scale_y + rdp.offset_y + 0.01f), g_settings->res_y()), 0); //grClipWindow specifies the hardware clipping window. Any pixels outside the clipping window are rejected. //Values are inclusive for minimum x and y values and exclusive for maximum x and y values. // grClipWindow (rdp.scissor.ul_x?rdp.scissor.ul_x+1:0, rdp.scissor.ul_y?rdp.scissor.ul_y+1:0, rdp.scissor.lr_x, rdp.scissor.lr_y); @@ -1874,14 +1792,14 @@ void update() switch ((rdp.rm & 0xC00) >> 10) { case 0: grDepthBiasLevel(0); - grDepthBufferFunction(g_settings->zmode_compare_less ? GR_CMP_LESS : GR_CMP_LEQUAL); + grDepthBufferFunction(g_settings->zmode_compare_less() ? GR_CMP_LESS : GR_CMP_LEQUAL); break; case 1: grDepthBiasLevel(-4); - grDepthBufferFunction(g_settings->zmode_compare_less ? GR_CMP_LESS : GR_CMP_LEQUAL); + grDepthBufferFunction(g_settings->zmode_compare_less() ? GR_CMP_LESS : GR_CMP_LEQUAL); break; case 2: - grDepthBiasLevel(g_settings->ucode == 7 ? -4 : 0); + grDepthBiasLevel(g_settings->ucode() == CSettings::ucode_PerfectDark ? -4 : 0); grDepthBufferFunction(GR_CMP_LESS); break; case 3: @@ -1958,23 +1876,20 @@ void update() } if (rdp.acmp == 3 && rdp.cycle_mode < 2) { - if (grStippleModeExt != 0) + if (g_settings->old_style_adither() || rdp.alpha_dither_mode != 3) { - if (g_settings->old_style_adither || rdp.alpha_dither_mode != 3) { - WriteTrace(TraceRDP, TraceDebug, " |- alpha compare: dither"); - grStippleModeExt(g_settings->stipple_mode); - } - else - grStippleModeExt(GR_STIPPLE_DISABLE); + WriteTrace(TraceRDP, TraceDebug, " |- alpha compare: dither"); + grStippleMode(g_settings->stipple_mode()); + } + else + { + grStippleMode(GR_STIPPLE_DISABLE); } } else { - if (grStippleModeExt) - { - //WriteTrace(TraceRDP, TraceDebug, " |- alpha compare: dither disabled"); - grStippleModeExt(GR_STIPPLE_DISABLE); - } + //WriteTrace(TraceRDP, TraceDebug, " |- alpha compare: dither disabled"); + grStippleMode(GR_STIPPLE_DISABLE); } } // Cull mode (leave this in for z-clipped triangles) @@ -2001,7 +1916,7 @@ void update() } //Added by Gonetz. - if (g_settings->fog && (rdp.update & UPDATE_FOG_ENABLED)) + if (g_settings->fog() && (rdp.update & UPDATE_FOG_ENABLED)) { rdp.update ^= UPDATE_FOG_ENABLED; @@ -2053,8 +1968,8 @@ void update() rdp.clip_min_x = maxval((rdp.view_trans[0] - scale_x + rdp.offset_x) / rdp.clip_ratio, 0.0f); rdp.clip_min_y = maxval((rdp.view_trans[1] - scale_y + rdp.offset_y) / rdp.clip_ratio, 0.0f); - rdp.clip_max_x = minval((rdp.view_trans[0] + scale_x + rdp.offset_x) * rdp.clip_ratio, g_settings->res_x); - rdp.clip_max_y = minval((rdp.view_trans[1] + scale_y + rdp.offset_y) * rdp.clip_ratio, g_settings->res_y); + rdp.clip_max_x = minval((rdp.view_trans[0] + scale_x + rdp.offset_x) * rdp.clip_ratio, g_settings->res_x()); + rdp.clip_max_y = minval((rdp.view_trans[1] + scale_y + rdp.offset_y) * rdp.clip_ratio, g_settings->res_y()); WriteTrace(TraceRDP, TraceDebug, " |- viewport - (%d, %d, %d, %d)", (uint32_t)rdp.clip_min_x, (uint32_t)rdp.clip_min_y, (uint32_t)rdp.clip_max_x, (uint32_t)rdp.clip_max_y); if (!rdp.scissor_set) @@ -2092,10 +2007,7 @@ void set_message_combiner() GR_BLEND_ZERO, GR_BLEND_ZERO); grAlphaTestFunction(GR_CMP_ALWAYS); - if (grStippleModeExt) - { - grStippleModeExt(GR_STIPPLE_DISABLE); - } + grStippleMode(GR_STIPPLE_DISABLE); grTexFilterMode(0, GR_TEXTUREFILTER_BILINEAR, GR_TEXTUREFILTER_BILINEAR); grTexCombine(GR_TMU1, GR_COMBINE_FUNCTION_NONE, diff --git a/Source/Glide64/Util.h b/Source/Glide64/Util.h index 22bbabd1e..4b0dc5b68 100644 --- a/Source/Glide64/Util.h +++ b/Source/Glide64/Util.h @@ -45,13 +45,11 @@ #define NOT_TMU2 0x02 void util_init(); -void render_tri(uint16_t linew = 0); int cull_tri(VERTEX **v); void draw_tri(VERTEX **v, uint16_t linew = 0); void do_triangle_stuff(uint16_t linew = 0, int old_interpolate = TRUE); void do_triangle_stuff_2(uint16_t linew = 0); -void add_tri(VERTEX *v, int n, int type); void apply_shade_mods(VERTEX *v); void update(); diff --git a/Source/Glide64/rdp.cpp b/Source/Glide64/rdp.cpp index ea70a343c..b4457d2d3 100644 --- a/Source/Glide64/rdp.cpp +++ b/Source/Glide64/rdp.cpp @@ -51,6 +51,7 @@ #include "CRC.h" #include #include "trace.h" +#include "SettingsID.h" #ifdef _WIN32 #include @@ -58,12 +59,6 @@ extern CriticalSection * g_ProcessDListCS; #endif -const int NumOfFormats = 1; -SCREEN_SHOT_FORMAT ScreenShotFormats[NumOfFormats] = -{ - { "PNG", "png", rdpBITMAP_TYPE_PNG }, -}; - const char *ACmp[] = { "NONE", "THRESHOLD", "UNKNOWN", "DITHER" }; const char *Mode0[] = { "COMBINED", "TEXEL0", @@ -153,7 +148,7 @@ char out_buf[2048]; uint32_t frame_count; // frame counter -int ucode_error_report = TRUE; +bool g_ucode_error_report = TRUE; int wrong_tile = -1; // ** RDP graphics functions ** @@ -227,7 +222,7 @@ void microcheck(); #include "turbo3D.h" static int reset = 0; -static int old_ucode = -1; +static CSettings::ucode_t g_old_ucode = CSettings::uCode_Unsupported; void RDP::Reset() { @@ -253,14 +248,6 @@ void RDP::Reset() rdp.update = UPDATE_SCISSOR | UPDATE_COMBINE | UPDATE_ZBUF_ENABLED | UPDATE_CULL_MODE; fog_mode = RDP::fog_enabled; maincimg[0].addr = maincimg[1].addr = last_drawn_ci_addr = 0x7FFFFFFF; - - hotkey_info.hk_ref = 90; - hotkey_info.hk_motionblur = (g_settings->buff_clear == 0) ? 0 : 90; - hotkey_info.hk_filtering = hotkey_info.hk_motionblur; - - CheckKeyPressed(G64_VK_BACK, 1); //BACK - CheckKeyPressed(G64_VK_B, 1); - CheckKeyPressed(G64_VK_V, 1); } RDP::RDP() @@ -328,47 +315,42 @@ void microcheck() ucf.close(); #endif + g_old_ucode = g_settings->ucode(); WriteTrace(TraceRDP, TraceDebug, "ucode = %08lx", uc_crc); - - RegisterSetting(Set_ucodeLookup, Data_DWORD_RDB_Setting, stdstr_f("%08lx", uc_crc).c_str(), "ucode", (unsigned int)-2, NULL); - int uc = GetSetting(Set_ucodeLookup); - - if (uc == -2 && ucode_error_report) + CSettings::ucode_t uc = g_settings->DetectUCode(uc_crc); + if (uc == CSettings::uCode_NotFound) { - g_settings->ucode = GetSetting(Set_ucode); - - ReleaseGfx(); - WriteTrace(TraceGlide64, TraceError, "uCode crc not found in INI, using currently selected uCode %08lx", (unsigned long)uc_crc); + if (g_ucode_error_report) + { + ReleaseGfx(); + WriteTrace(TraceGlide64, TraceError, "uCode crc not found in INI, using currently selected uCode %08lx", (unsigned long)uc_crc); #ifdef _WIN32 - MessageBox(gfx.hWnd, stdstr_f("Error: uCode crc not found in INI, using currently selected uCode\n\n%08lx", uc_crc).c_str(), "Error", MB_OK | MB_ICONEXCLAMATION); + MessageBox(gfx.hWnd, stdstr_f("Error: uCode crc not found in INI, using currently selected uCode\n\n%08lx", uc_crc).c_str(), "Error", MB_OK | MB_ICONEXCLAMATION); #endif - - ucode_error_report = FALSE; // don't report any more ucode errors from this game + g_ucode_error_report = false; // don't report any more ucode errors from this game + } } - else if (uc == -1 && ucode_error_report) + else if (uc == CSettings::uCode_Unsupported) { - g_settings->ucode = GetSetting(Set_ucode); - - ReleaseGfx(); - WriteTrace(TraceGlide64, TraceError, "Unsupported uCode! crc: %08lx", (unsigned long)uc_crc); - + if (g_ucode_error_report) + { + ReleaseGfx(); + WriteTrace(TraceGlide64, TraceError, "Unsupported uCode! crc: %08lx", (unsigned long)uc_crc); #ifdef _WIN32 - MessageBox(gfx.hWnd, stdstr_f("Error: Unsupported uCode!\n\ncrc: %08lx", uc_crc).c_str(), "Error", MB_OK | MB_ICONEXCLAMATION); + MessageBox(gfx.hWnd, stdstr_f("Error: Unsupported uCode!\n\ncrc: %08lx", uc_crc).c_str(), "Error", MB_OK | MB_ICONEXCLAMATION); #endif - - ucode_error_report = FALSE; // don't report any more ucode errors from this game + g_ucode_error_report = FALSE; // don't report any more ucode errors from this game + } } else { - old_ucode = g_settings->ucode; - g_settings->ucode = uc; - WriteTrace(TraceRDP, TraceDebug, "microcheck: old ucode: %d, new ucode: %d", old_ucode, uc); + WriteTrace(TraceRDP, TraceDebug, "microcheck: old ucode: %d, new ucode: %d", g_old_ucode, uc); if (uc_crc == 0x8d5735b2 || uc_crc == 0xb1821ed3 || uc_crc == 0x1118b3e0) //F3DLP.Rej ucode. perspective texture correction is not implemented { rdp.Persp_en = 1; rdp.persp_supported = FALSE; } - else if (g_settings->texture_correction) + else if (g_settings->texture_correction()) { rdp.persp_supported = TRUE; } @@ -428,7 +410,7 @@ static void CopyFrameBuffer(GrBuffer_t buffer = GR_BUFFER_BACKBUFFER) uint32_t width = rdp.ci_width;//*gfx.VI_WIDTH_REG; uint32_t height; - if (fb_emulation_enabled && !(g_settings->hacks&hack_PPL)) + if (g_settings->fb_emulation_enabled() && !g_settings->hacks(CSettings::hack_PPL)) { int ind = (rdp.ci_count > 0) ? rdp.ci_count - 1 : 0; height = rdp.frame_buffers[ind].height; @@ -436,8 +418,10 @@ static void CopyFrameBuffer(GrBuffer_t buffer = GR_BUFFER_BACKBUFFER) else { height = rdp.ci_lower_bound; - if (g_settings->hacks&hack_PPL) + if (g_settings->hacks(CSettings::hack_PPL)) + { height -= rdp.ci_upper_bound; + } } WriteTrace(TraceRDP, TraceDebug, "width: %d, height: %d... ", width, height); @@ -461,7 +445,7 @@ static void CopyFrameBuffer(GrBuffer_t buffer = GR_BUFFER_BACKBUFFER) for (uint32_t x = 0; x < width; x++) { c = ptr_src[x + y * width]; - if (g_settings->frame_buffer&fb_read_alpha) + if (g_settings->fb_read_alpha_enabled()) { if (c > 0) c = (c & 0xFFC0) | ((c & 0x001F) << 1) | 1; @@ -486,14 +470,14 @@ static void CopyFrameBuffer(GrBuffer_t buffer = GR_BUFFER_BACKBUFFER) } else { - if (rdp.motionblur && fb_hwfbe_enabled) + if (rdp.motionblur && g_settings->fb_hwfbe_enabled()) { return; } else { - float scale_x = (g_settings->scr_res_x - rdp.offset_x*2.0f) / maxval(width, rdp.vi_width); - float scale_y = (g_settings->scr_res_y - rdp.offset_y*2.0f) / maxval(height, rdp.vi_height); + float scale_x = (g_settings->scr_res_x() - rdp.offset_x*2.0f) / maxval(width, rdp.vi_width); + float scale_y = (g_settings->scr_res_y() - rdp.offset_y*2.0f) / maxval(height, rdp.vi_height); WriteTrace(TraceRDP, TraceDebug, "width: %d, height: %d, ul_y: %d, lr_y: %d, scale_x: %f, scale_y: %f, ci_width: %d, ci_height: %d", width, height, rdp.ci_upper_bound, rdp.ci_lower_bound, scale_x, scale_y, rdp.ci_width, rdp.ci_height); GrLfbInfo_t info; @@ -512,11 +496,13 @@ static void CopyFrameBuffer(GrBuffer_t buffer = GR_BUFFER_BACKBUFFER) uint16_t c; uint32_t stride = info.strideInBytes >> 1; - int read_alpha = g_settings->frame_buffer & fb_read_alpha; - if ((g_settings->hacks&hack_PMario) && rdp.frame_buffers[rdp.ci_count - 1].status != ci_aux) + int read_alpha = g_settings->fb_read_alpha_enabled(); + if (g_settings->hacks(CSettings::hack_PMario) && rdp.frame_buffers[rdp.ci_count - 1].status != ci_aux) + { read_alpha = FALSE; + } int x_start = 0, y_start = 0, x_end = width, y_end = height; - if (g_settings->hacks&hack_BAR) + if (g_settings->hacks(CSettings::hack_BAR)) { x_start = 80, y_start = 24, x_end = 240, y_end = 86; } @@ -554,11 +540,6 @@ void GoToFullScreen() WriteTrace(TraceGlide64, TraceError, "tInitGfx failed"); return; } -#ifdef __WINDOWS__ - if (gfx.hStatusBar) - ShowWindow(gfx.hStatusBar, SW_HIDE); - ShowCursor(FALSE); -#endif } /****************************************************************** @@ -590,20 +571,12 @@ EXPORT void CALL ProcessDList(void) update_screen_count = 0; ChangeSize(); -#ifdef ALTTAB_FIX - if (!hhkLowLevelKybd) - { - hhkLowLevelKybd = SetWindowsHookEx(WH_KEYBOARD_LL, - LowLevelKeyboardProc, hInstance, 0); - } -#endif - WriteTrace(TraceGlide64, TraceDebug, "ProcessDList"); if (reset) { reset = 0; - if (g_settings->autodetect_ucode) + if (g_settings->autodetect_ucode()) { // Thanks to ZeZu for ucode autodetection!!! uint32_t startUcode = *(uint32_t*)(gfx.DMEM + 0xFD0); @@ -613,7 +586,7 @@ EXPORT void CALL ProcessDList(void) else memset(microcode, 0, 4096); } - else if (((old_ucode == ucode_S2DEX) && (g_settings->ucode == ucode_F3DEX)) || g_settings->force_microcheck) + else if ((g_old_ucode == CSettings::ucode_S2DEX && g_settings->ucode() == CSettings::ucode_F3DEX) || g_settings->force_microcheck()) { uint32_t startUcode = *(uint32_t*)(gfx.DMEM + 0xFD0); memcpy(microcode, gfx.RDRAM + startUcode, 4096); @@ -621,15 +594,21 @@ EXPORT void CALL ProcessDList(void) } if (exception) + { return; + } // Switch to fullscreen? if (to_fullscreen) + { GoToFullScreen(); + } //* Set states *// - if (g_settings->swapmode > 0) + if (g_settings->swapmode() != CSettings::SwapMode_Old) + { SwapOK = TRUE; + } rdp.updatescreen = 1; rdp.tri_n = 0; // 0 triangles so far this frame @@ -667,16 +646,16 @@ EXPORT void CALL ProcessDList(void) depth_buffer_fog = TRUE; //analize possible frame buffer usage - if (fb_emulation_enabled) + if (g_settings->fb_emulation_enabled()) DetectFrameBufferUsage(); - if (!(g_settings->hacks&hack_Lego) || rdp.num_of_ci > 1) + if (!g_settings->hacks(CSettings::hack_Lego) || rdp.num_of_ci > 1) rdp.last_bg = 0; //* End of set states *// // Get the start of the display list and the length of it uint32_t dlist_start = *(uint32_t*)(gfx.DMEM + 0xFF0); uint32_t dlist_length = *(uint32_t*)(gfx.DMEM + 0xFF4); - WriteTrace(TraceRDP, TraceDebug, "--- NEW DLIST --- crc: %08lx, ucode: %d, fbuf: %08lx, fbuf_width: %d, dlist start: %08lx, dlist_length: %d, x_scale: %f, y_scale: %f", uc_crc, g_settings->ucode, *gfx.VI_ORIGIN_REG, *gfx.VI_WIDTH_REG, dlist_start, dlist_length, (*gfx.VI_X_SCALE_REG & 0xFFF) / 1024.0f, (*gfx.VI_Y_SCALE_REG & 0xFFF) / 1024.0f); + WriteTrace(TraceRDP, TraceDebug, "--- NEW DLIST --- crc: %08lx, ucode: %d, fbuf: %08lx, fbuf_width: %d, dlist start: %08lx, dlist_length: %d, x_scale: %f, y_scale: %f", uc_crc, g_settings->ucode(), *gfx.VI_ORIGIN_REG, *gfx.VI_WIDTH_REG, dlist_start, dlist_length, (*gfx.VI_X_SCALE_REG & 0xFFF) / 1024.0f, (*gfx.VI_Y_SCALE_REG & 0xFFF) / 1024.0f); // Do nothing if dlist is empty if (dlist_start == 0) @@ -684,7 +663,7 @@ EXPORT void CALL ProcessDList(void) if (cpu_fb_write == TRUE) DrawPartFrameBufferToScreen(); - if ((g_settings->hacks&hack_Tonic) && dlist_length < 16) + if (g_settings->hacks(CSettings::hack_Tonic) && dlist_length < 16) { rdp_fullsync(); WriteTrace(TraceRDP, TraceWarning, "DLIST is too short!"); @@ -702,14 +681,15 @@ EXPORT void CALL ProcessDList(void) #ifdef CATCH_EXCEPTIONS try { #endif - if (g_settings->ucode == ucode_Turbo3d) + if (g_settings->ucode() == CSettings::ucode_Turbo3d) { Turbo3D(); } else { // MAIN PROCESSING LOOP - do { + do + { // Get the address of the next command a = rdp.pc[rdp.pc_i] & BMASK; @@ -719,11 +699,7 @@ EXPORT void CALL ProcessDList(void) // cmd2 and cmd3 are filled only when needed, by the function that needs them // Output the address before the command -#ifdef LOG_COMMANDS WriteTrace(TraceRDP, TraceDebug, "%08lx (c0:%08lx, c1:%08lx): ", a, rdp.cmd0, rdp.cmd1); -#else - WriteTrace(TraceRDP, TraceDebug, "%08lx: ", a); -#endif // Go to the next instruction rdp.pc[rdp.pc_i] = (a + 8) & BMASK; @@ -732,7 +708,7 @@ EXPORT void CALL ProcessDList(void) perf_cur = CDateTime().SetToNow().Value(); #endif // Process this instruction - gfx_instruction[g_settings->ucode][rdp.cmd0 >> 24](); + gfx_instruction[g_settings->ucode()][rdp.cmd0 >> 24](); // check DL counter if (rdp.dl_count != -1) @@ -757,17 +733,15 @@ EXPORT void CALL ProcessDList(void) #ifdef CATCH_EXCEPTIONS } catch (...) { - if (fullscreen) + if (g_fullscreen) { ReleaseGfx (); rdp_reset(); -#ifdef TEXTURE_FILTER - if (g_settings->ghq_use) + if (g_ghq_use) { ext_ghq_shutdown(); - g_settings->ghq_use = 0; + g_ghq_use = false; } -#endif } if (MessageBox(gfx.hWnd, "The GFX plugin caused an exception and has been disabled.\nWould you like to turn it back on and attempt to continue?","Glide64 Exception", MB_YESNO|MB_ICONEXCLAMATION) == MB_NO) { @@ -781,21 +755,27 @@ EXPORT void CALL ProcessDList(void) } #endif - if (fb_emulation_enabled) + if (g_settings->fb_emulation_enabled()) { rdp.scale_x = rdp.scale_x_bak; rdp.scale_y = rdp.scale_y_bak; } - if (g_settings->hacks & hack_OoT) + if (g_settings->hacks(CSettings::hack_OoT)) + { copyWhiteToRDRAM(); //Subscreen delay fix - else if (g_settings->frame_buffer & fb_ref) + } + else if (g_settings->fb_ref_enabled()) + { CopyFrameBuffer(); + } if (rdp.cur_image) - CloseTextureBuffer(rdp.read_whole_frame && ((g_settings->hacks&hack_PMario) || rdp.swap_ci_index >= 0)); + { + CloseTextureBuffer(rdp.read_whole_frame && (g_settings->hacks(CSettings::hack_PMario) || rdp.swap_ci_index >= 0)); + } - if ((g_settings->hacks&hack_TGR2) && rdp.vi_org_reg != *gfx.VI_ORIGIN_REG && CI_SET) + if (g_settings->hacks(CSettings::hack_TGR2) && rdp.vi_org_reg != *gfx.VI_ORIGIN_REG && CI_SET) { newSwapBuffers(); CI_SET = FALSE; @@ -929,29 +909,34 @@ static void rdp_texrect() else { //gDPTextureRectangle - if (g_settings->hacks&hack_Winback) { + if (g_settings->hacks(CSettings::hack_Winback)) + { rdp.pc[rdp.pc_i] += 8; return; } - if (g_settings->hacks&hack_ASB) + if (g_settings->hacks(CSettings::hack_ASB)) + { rdp.cmd2 = 0; + } else + { rdp.cmd2 = ((uint32_t*)gfx.RDRAM)[a + 0]; + } rdp.cmd3 = ((uint32_t*)gfx.RDRAM)[a + 1]; rdp.pc[rdp.pc_i] += 8; } } - if ((g_settings->hacks&hack_Yoshi) && g_settings->ucode == ucode_S2DEX) + if (g_settings->hacks(CSettings::hack_Yoshi) && g_settings->ucode() == CSettings::ucode_S2DEX) { ys_memrect(); return; } - if (rdp.skip_drawing || (!fb_emulation_enabled && (rdp.cimg == rdp.zimg))) + if (rdp.skip_drawing || (!g_settings->fb_emulation_enabled() && (rdp.cimg == rdp.zimg))) { - if ((g_settings->hacks&hack_PMario) && rdp.ci_status == ci_useless) + if (g_settings->hacks(CSettings::hack_PMario) && rdp.ci_status == ci_useless) { pm_palette_mod(); } @@ -962,7 +947,7 @@ static void rdp_texrect() return; } - if ((g_settings->ucode == ucode_CBFD) && rdp.cur_image && rdp.cur_image->format) + if ((g_settings->ucode() == CSettings::ucode_CBFD) && rdp.cur_image && rdp.cur_image->format) { //WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect. texaddr: %08lx, cimg: %08lx, cimg_end: %08lx", rdp.timg.addr, rdp.maincimg[1].addr, rdp.maincimg[1].addr+rdp.ci_width*rdp.ci_height*rdp.ci_size); WriteTrace(TraceRDP, TraceDebug, "Shadow texrect is skipped."); @@ -970,7 +955,7 @@ static void rdp_texrect() return; } - if ((g_settings->ucode == ucode_PerfectDark) && rdp.ci_count > 0 && (rdp.frame_buffers[rdp.ci_count - 1].status == ci_zcopy)) + if ((g_settings->ucode() == CSettings::ucode_PerfectDark) && rdp.ci_count > 0 && (rdp.frame_buffers[rdp.ci_count - 1].status == ci_zcopy)) { pd_zcopy(); WriteTrace(TraceRDP, TraceDebug, "Depth buffer copied."); @@ -980,11 +965,14 @@ static void rdp_texrect() if ((rdp.othermode_l >> 16) == 0x3c18 && rdp.cycle1 == 0x03ffffff && rdp.cycle2 == 0x01ff1fff) //depth image based fog { - if (!depth_buffer_fog) - return; - if (g_settings->fog) - DrawDepthBufferFog(); - depth_buffer_fog = FALSE; + if (depth_buffer_fog) + { + if (g_settings->fog()) + { + DrawDepthBufferFog(); + } + depth_buffer_fog = false; + } return; } @@ -1020,7 +1008,7 @@ static void rdp_texrect() else if (lr_y - ul_y < 1.0f) lr_y = ceil(lr_y); - if (g_settings->increase_texrect_edge) + if (g_settings->increase_texrect_edge()) { if (floor(lr_x) != lr_x) lr_x = ceil(lr_x); @@ -1028,8 +1016,7 @@ static void rdp_texrect() lr_y = ceil(lr_y); } - //* - if (rdp.tbuff_tex && (g_settings->frame_buffer & fb_optimize_texrect)) + if (rdp.tbuff_tex && g_settings->fb_optimize_texrect_enabled()) { WriteTrace(TraceRDP, TraceDebug, "Attempt to optimize texrect"); if (!rdp.tbuff_tex->drawn) @@ -1059,7 +1046,7 @@ static void rdp_texrect() /*Gonetz*/ //hack for Zelda MM. it removes black texrects which cover all geometry in "Link meets Zelda" cut scene - if ((g_settings->hacks&hack_Zelda) && rdp.timg.addr >= rdp.cimg && rdp.timg.addr < rdp.ci_end) + if (g_settings->hacks(CSettings::hack_Zelda) && rdp.timg.addr >= rdp.cimg && rdp.timg.addr < rdp.ci_end) { WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect. texaddr: %08lx, cimg: %08lx, cimg_end: %08lx", rdp.cur_cache[0]->addr, rdp.cimg, rdp.cimg + rdp.ci_width*rdp.ci_height * 2); rdp.tri_n += 2; @@ -1067,7 +1054,7 @@ static void rdp_texrect() } //* //hack for Banjo2. it removes black texrects under Banjo - if (!fb_hwfbe_enabled && ((rdp.cycle1 << 16) | (rdp.cycle2 & 0xFFFF)) == 0xFFFFFFFF && (rdp.othermode_l & 0xFFFF0000) == 0x00500000) + if (!g_settings->fb_hwfbe_enabled() && ((rdp.cycle1 << 16) | (rdp.cycle2 & 0xFFFF)) == 0xFFFFFFFF && (rdp.othermode_l & 0xFFFF0000) == 0x00500000) { rdp.tri_n += 2; return; @@ -1075,27 +1062,25 @@ static void rdp_texrect() //*/ //* //remove motion blur in night vision - if ((g_settings->ucode == ucode_PerfectDark) && (rdp.maincimg[1].addr != rdp.maincimg[0].addr) && (rdp.timg.addr >= rdp.maincimg[1].addr) && (rdp.timg.addr < (rdp.maincimg[1].addr + rdp.ci_width*rdp.ci_height*rdp.ci_size))) + if (g_settings->ucode() == CSettings::ucode_PerfectDark && (rdp.maincimg[1].addr != rdp.maincimg[0].addr) && (rdp.timg.addr >= rdp.maincimg[1].addr) && (rdp.timg.addr < (rdp.maincimg[1].addr + rdp.ci_width*rdp.ci_height*rdp.ci_size))) { - if (fb_emulation_enabled) - if (rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_copy_self) - { - //WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect. texaddr: %08lx, cimg: %08lx, cimg_end: %08lx", rdp.timg.addr, rdp.maincimg[1], rdp.maincimg[1]+rdp.ci_width*rdp.ci_height*rdp.ci_size); - WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect."); - rdp.tri_n += 2; - return; - } + if (g_settings->fb_emulation_enabled() && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_copy_self) + { + //WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect. texaddr: %08lx, cimg: %08lx, cimg_end: %08lx", rdp.timg.addr, rdp.maincimg[1], rdp.maincimg[1]+rdp.ci_width*rdp.ci_height*rdp.ci_size); + WriteTrace(TraceRDP, TraceDebug, "Wrong Texrect."); + rdp.tri_n += 2; + return; + } } - //*/ int i; - uint32_t tile = (uint16_t)((rdp.cmd1 & 0x07000000) >> 24); + uint32_t tile_no = (uint16_t)((rdp.cmd1 & 0x07000000) >> 24); rdp.texrecting = 1; uint32_t prev_tile = rdp.cur_tile; - rdp.cur_tile = tile; + rdp.cur_tile = tile_no; const float Z = set_sprite_combine_mode(); @@ -1130,7 +1115,7 @@ static void rdp_texrect() float s_ul_y = ul_y * rdp.scale_y + rdp.offset_y; float s_lr_y = lr_y * rdp.scale_y + rdp.offset_y; - WriteTrace(TraceRDP, TraceDebug, "texrect (%.2f, %.2f, %.2f, %.2f), tile: %d, #%d, #%d", ul_x, ul_y, lr_x, lr_y, tile, rdp.tri_n, rdp.tri_n + 1); + WriteTrace(TraceRDP, TraceDebug, "texrect (%.2f, %.2f, %.2f, %.2f), tile: %d, #%d, #%d", ul_x, ul_y, lr_x, lr_y, tile_no, rdp.tri_n, rdp.tri_n + 1); WriteTrace(TraceRDP, TraceDebug, "(%f, %f) -> (%f, %f), s: (%d, %d) -> (%d, %d)", s_ul_x, s_ul_y, s_lr_x, s_lr_y, rdp.scissor.ul_x, rdp.scissor.ul_y, rdp.scissor.lr_x, rdp.scissor.lr_y); WriteTrace(TraceRDP, TraceDebug, "\toff_x: %f, off_y: %f, dsdx: %f, dtdy: %f", off_x_i / 32.0f, off_y_i / 32.0f, dsdx, dtdy); @@ -1139,14 +1124,12 @@ static void rdp_texrect() if (((rdp.cmd0 >> 24) & 0xFF) == 0xE5) //texrectflip { -#ifdef TEXTURE_FILTER if (rdp.cur_cache[0]->is_hires_tex) { off_size_x = (float)((lr_y - ul_y) * dsdx); off_size_y = (float)((lr_x - ul_x) * dtdy); } else -#endif { off_size_x = (lr_y - ul_y - 1) * dsdx; off_size_y = (lr_x - ul_x - 1) * dtdy; @@ -1154,14 +1137,12 @@ static void rdp_texrect() } else { -#ifdef TEXTURE_FILTER if (rdp.cur_cache[0]->is_hires_tex) { off_size_x = (float)((lr_x - ul_x) * dsdx); off_size_y = (float)((lr_y - ul_y) * dtdy); } else -#endif { off_size_x = (lr_x - ul_x - 1) * dsdx; off_size_y = (lr_y - ul_y - 1) * dtdy; @@ -1430,7 +1411,7 @@ static void rdp_texrect() ConvertCoordsConvert(vptr, n_vertices); - if (g_settings->wireframe) + if (g_settings->wireframe()) { SetWireframeCol(); grDrawLine(&vstd[0], &vstd[2]); @@ -1444,22 +1425,7 @@ static void rdp_texrect() grDrawVertexArrayContiguous(GR_TRIANGLE_STRIP, n_vertices, vptr, sizeof(VERTEX)); } - if (_debugger.capture) - { - VERTEX vl[3]; - vl[0] = vstd[0]; - vl[1] = vstd[2]; - vl[2] = vstd[1]; - add_tri(vl, 3, TRI_TEXRECT); - rdp.tri_n++; - vl[0] = vstd[2]; - vl[1] = vstd[3]; - vl[2] = vstd[1]; - add_tri(vl, 3, TRI_TEXRECT); - rdp.tri_n++; - } - else - rdp.tri_n += 2; + rdp.tri_n += 2; delete[] vnew; } @@ -1565,17 +1531,17 @@ static void rdp_setothermode() #define F3DEX2_SETOTHERMODE(cmd,sft,len,data) { \ rdp.cmd0 = (uint32_t)((cmd<<24) | ((32-(sft)-(len))<<8) | (((len)-1))); \ rdp.cmd1 = (uint32_t)(data); \ - gfx_instruction[g_settings->ucode][cmd] (); \ + gfx_instruction[g_settings->ucode()][cmd] (); \ } #define SETOTHERMODE(cmd,sft,len,data) { \ rdp.cmd0 = (uint32_t)((cmd<<24) | ((sft)<<8) | (len)); \ rdp.cmd1 = (uint32_t)data; \ - gfx_instruction[g_settings->ucode][cmd] (); \ + gfx_instruction[g_settings->ucode()][cmd] (); \ } WriteTrace(TraceRDP, TraceDebug, "rdp_setothermode"); - if ((g_settings->ucode == ucode_F3DEX2) || (g_settings->ucode == ucode_CBFD)) + if (g_settings->ucode() == CSettings::ucode_F3DEX2 || g_settings->ucode() == CSettings::ucode_CBFD) { int cmd0 = rdp.cmd0; F3DEX2_SETOTHERMODE(0xE2, 0, 32, rdp.cmd1); // SETOTHERMODE_L @@ -1594,9 +1560,7 @@ void load_palette(uint32_t addr, uint16_t start, uint16_t count) WriteTrace(TraceRDP, TraceDebug, "Loading palette... "); uint16_t *dpal = rdp.pal_8 + start; uint16_t end = start + count; -#ifdef TEXTURE_FILTER uint16_t *spal = (uint16_t*)(gfx.RDRAM + (addr & BMASK)); -#endif for (uint16_t i = start; i < end; i++) { @@ -1605,12 +1569,10 @@ void load_palette(uint32_t addr, uint16_t start, uint16_t count) WriteTrace(TraceTLUT, TraceDebug, "%d: %08lx", i, *(uint16_t *)(gfx.RDRAM + (addr ^ 2))); } -#ifdef TEXTURE_FILTER - if (g_settings->ghq_hirs) + if (g_settings->ghq_hirs() != CSettings::HiResPackFormat_None) { memcpy((uint8_t*)(rdp.pal_8_rice + start), spal, count << 1); } -#endif start >>= 4; end = start + (count >> 4); if (end == start) // it can be if count < 16 @@ -1681,7 +1643,7 @@ static void rdp_settilesize() else if (wrong_tile == (int)tile) wrong_tile = -1; - if (g_settings->use_sts1_only) + if (g_settings->use_sts1_only()) { // ** USE FIRST SETTILESIZE ONLY ** // This option helps certain textures while using the 'Alternate texture size method', @@ -1915,11 +1877,9 @@ static void rdp_loadblock() rdp.timg.set_by = 0; // load block -#ifdef TEXTURE_FILTER LOAD_TILE_INFO &info = rdp.load_info[rdp.tiles[tile].t_mem]; info.tile_width = lr_s; info.dxt = dxt; -#endif // do a quick boundary check before copying to eliminate the possibility for exception if (ul_s >= 512) { @@ -1958,8 +1918,10 @@ static void rdp_loadblock() tile, ul_s, ul_t, lr_s, dxt, _dxt); - if (fb_hwfbe_enabled) + if (g_settings->fb_hwfbe_enabled()) + { setTBufTex(rdp.tiles[tile].t_mem, cnt); + } } static inline void loadTile(uint32_t *src, uint32_t *dst, int width, int height, int line, int off, uint32_t *end) @@ -2127,7 +2089,7 @@ static void rdp_loadtile() rdp.tbuff_tex->tile_ult = ul_t; } - if ((g_settings->hacks&hack_Tonic) && tile == 7) + if (g_settings->hacks(CSettings::hack_Tonic) && tile == 7) { rdp.tiles[0].ul_s = ul_s; rdp.tiles[0].ul_t = ul_t; @@ -2138,21 +2100,24 @@ static void rdp_loadtile() uint32_t height = lr_t - ul_t + 1; // get height uint32_t width = lr_s - ul_s + 1; -#ifdef TEXTURE_FILTER LOAD_TILE_INFO &info = rdp.load_info[rdp.tiles[tile].t_mem]; info.tile_ul_s = ul_s; info.tile_ul_t = ul_t; info.tile_width = (rdp.tiles[tile].mask_s ? minval((uint16_t)width, 1 << rdp.tiles[tile].mask_s) : (uint16_t)width); info.tile_height = (rdp.tiles[tile].mask_t ? minval((uint16_t)height, 1 << rdp.tiles[tile].mask_t) : (uint16_t)height); - if (g_settings->hacks&hack_MK64) { + if (g_settings->hacks(CSettings::hack_MK64)) + { if (info.tile_width % 2) + { info.tile_width--; + } if (info.tile_height % 2) + { info.tile_height--; + } } info.tex_width = rdp.timg.width; info.tex_size = rdp.timg.size; -#endif int line_n = rdp.timg.width << rdp.tiles[tile].size >> 1; uint32_t offs = ul_t * line_n; @@ -2181,8 +2146,10 @@ static void rdp_loadtile() WriteTrace(TraceRDP, TraceDebug, "loadtile: tile: %d, ul_s: %d, ul_t: %d, lr_s: %d, lr_t: %d", tile, ul_s, ul_t, lr_s, lr_t); - if (fb_hwfbe_enabled) + if (g_settings->fb_hwfbe_enabled()) + { setTBufTex(rdp.tiles[tile].t_mem, rdp.tiles[tile].line*height); + } } static void rdp_settile() @@ -2217,7 +2184,7 @@ static void rdp_settile() tile->t_mem, tile->palette, str_cm[(tile->clamp_t << 1) | tile->mirror_t], tile->mask_t, tile->shift_t, str_cm[(tile->clamp_s << 1) | tile->mirror_s], tile->mask_s, tile->shift_s); - if (fb_hwfbe_enabled && rdp.last_tile < rdp.cur_tile + 2) + if (g_settings->fb_hwfbe_enabled() && rdp.last_tile < rdp.cur_tile + 2) { for (int i = 0; i < 2; i++) { @@ -2257,11 +2224,11 @@ static void rdp_fillrect() WriteTrace(TraceRDP, TraceDebug, "Fillrect. Wrong coordinates. Skipped"); return; } - int pd_multiplayer = (g_settings->ucode == ucode_PerfectDark) && (rdp.cycle_mode == 3) && (rdp.fill_color == 0xFFFCFFFC); - if ((rdp.cimg == rdp.zimg) || (fb_emulation_enabled && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_zimg) || pd_multiplayer) + bool pd_multiplayer = g_settings->ucode() == CSettings::ucode_PerfectDark && rdp.cycle_mode == 3 && rdp.fill_color == 0xFFFCFFFC; + if ((rdp.cimg == rdp.zimg) || (g_settings->fb_emulation_enabled() && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_zimg) || pd_multiplayer) { WriteTrace(TraceRDP, TraceDebug, "Fillrect - cleared the depth buffer"); - if (!(g_settings->hacks&hack_Hyperbike) || rdp.ci_width > 64) //do not clear main depth buffer for aux depth buffers + if (!g_settings->hacks(CSettings::hack_Hyperbike) || rdp.ci_width > 64) //do not clear main depth buffer for aux depth buffers { update_scissor(); grDepthMask(FXTRUE); @@ -2270,25 +2237,22 @@ static void rdp_fillrect() grColorMask(FXTRUE, FXTRUE); rdp.update |= UPDATE_ZBUF_ENABLED; } - //if (g_settings->frame_buffer&fb_depth_clear) + ul_x = minval(maxval(ul_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x); + lr_x = minval(maxval(lr_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x); + ul_y = minval(maxval(ul_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y); + lr_y = minval(maxval(lr_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y); + uint32_t zi_width_in_dwords = rdp.ci_width >> 1; + ul_x >>= 1; + lr_x >>= 1; + uint32_t * dst = (uint32_t*)(gfx.RDRAM + rdp.cimg); + dst += ul_y * zi_width_in_dwords; + for (uint32_t y = ul_y; y < lr_y; y++) { - ul_x = minval(maxval(ul_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x); - lr_x = minval(maxval(lr_x, rdp.scissor_o.ul_x), rdp.scissor_o.lr_x); - ul_y = minval(maxval(ul_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y); - lr_y = minval(maxval(lr_y, rdp.scissor_o.ul_y), rdp.scissor_o.lr_y); - uint32_t zi_width_in_dwords = rdp.ci_width >> 1; - ul_x >>= 1; - lr_x >>= 1; - uint32_t * dst = (uint32_t*)(gfx.RDRAM + rdp.cimg); - dst += ul_y * zi_width_in_dwords; - for (uint32_t y = ul_y; y < lr_y; y++) + for (uint32_t x = ul_x; x < lr_x; x++) { - for (uint32_t x = ul_x; x < lr_x; x++) - { - dst[x] = rdp.fill_color; - } - dst += zi_width_in_dwords; + dst[x] = rdp.fill_color; } + dst += zi_width_in_dwords; } return; } @@ -2320,7 +2284,7 @@ static void rdp_fillrect() // Update scissor update_scissor(); - if (g_settings->decrease_fillrect_edge && rdp.cycle_mode == 0) + if (g_settings->decrease_fillrect_edge() && rdp.cycle_mode == 0) { lr_x--; lr_y--; } @@ -2338,8 +2302,8 @@ static void rdp_fillrect() if (s_lr_x < 0) s_lr_x = 0; if (s_lr_y < 0) s_lr_y = 0; - if ((uint32_t)s_ul_x > g_settings->res_x) s_ul_x = g_settings->res_x; - if ((uint32_t)s_ul_y > g_settings->res_y) s_ul_y = g_settings->res_y; + if ((uint32_t)s_ul_x > g_settings->res_x()) { s_ul_x = g_settings->res_x(); } + if ((uint32_t)s_ul_y > g_settings->res_y()) { s_ul_y = g_settings->res_y(); } WriteTrace(TraceRDP, TraceDebug, " - %d, %d, %d, %d", s_ul_x, s_ul_y, s_lr_x, s_lr_y); @@ -2358,7 +2322,7 @@ static void rdp_fillrect() { uint32_t color = rdp.fill_color; - if ((g_settings->hacks&hack_PMario) && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_aux) + if (g_settings->hacks(CSettings::hack_PMario) && rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_aux) { //background of auxiliary frame buffers must have zero alpha. //make it black, set 0 alpha to plack pixels on frame buffer read @@ -2389,10 +2353,7 @@ static void rdp_fillrect() grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO); grAlphaTestFunction(GR_CMP_ALWAYS); - if (grStippleModeExt) - { - grStippleModeExt(GR_STIPPLE_DISABLE); - } + grStippleMode(GR_STIPPLE_DISABLE); grCullMode(GR_CULL_DISABLE); grFogMode(GR_FOG_DISABLE); @@ -2425,7 +2386,7 @@ static void rdp_fillrect() } } - if (g_settings->wireframe) + if (g_settings->wireframe()) { SetWireframeCol(); grDrawLine(&v[0], &v[2]); @@ -2441,23 +2402,7 @@ static void rdp_fillrect() grDrawTriangle(&v[2], &v[3], &v[1]); } - if (_debugger.capture) - { - VERTEX v1[3]; - v1[0] = v[0]; - v1[1] = v[2]; - v1[2] = v[1]; - add_tri(v1, 3, TRI_FILLRECT); - rdp.tri_n++; - v1[0] = v[2]; - v1[1] = v[3]; - add_tri(v1, 3, TRI_FILLRECT); - rdp.tri_n++; - } - else - { - rdp.tri_n += 2; - } + rdp.tri_n += 2; } // @@ -2584,7 +2529,7 @@ static void rdp_settextureimage() } } - if (fb_hwfbe_enabled) //search this texture among drawn texture buffers + if (g_settings->fb_hwfbe_enabled()) //search this texture among drawn texture buffers FindTextureBuffer(rdp.timg.addr, rdp.timg.width); WriteTrace(TraceRDP, TraceDebug, "settextureimage: format: %s, size: %s, width: %d, addr: %08lx", @@ -2622,7 +2567,7 @@ static uint32_t swapped_addr = 0; static void rdp_setcolorimage() { - if (fb_emulation_enabled && (rdp.num_of_ci < NUMTEXBUF)) + if (g_settings->fb_emulation_enabled() && (rdp.num_of_ci < NUMTEXBUF)) { COLOR_IMAGE & cur_fb = rdp.frame_buffers[rdp.ci_count]; COLOR_IMAGE & prev_fb = rdp.frame_buffers[rdp.ci_count ? rdp.ci_count - 1 : 0]; @@ -2643,7 +2588,7 @@ static void rdp_setcolorimage() rdp.scale_x = sx; rdp.scale_y = sy; } - if (!fb_hwfbe_enabled) + if (!g_settings->fb_hwfbe_enabled()) { if ((rdp.num_of_ci > 1) && (next_fb.status == ci_aux) && @@ -2653,17 +2598,17 @@ static void rdp_setcolorimage() rdp.scale_y = 1.0f; } } - else if (rdp.copy_ci_index && (g_settings->hacks&hack_PMario)) //tidal wave + else if (rdp.copy_ci_index && g_settings->hacks(CSettings::hack_PMario)) //tidal wave OpenTextureBuffer(rdp.frame_buffers[rdp.main_ci_index]); } - else if (!rdp.motionblur && fb_hwfbe_enabled && !SwapOK && (rdp.ci_count <= rdp.copy_ci_index)) + else if (!rdp.motionblur && g_settings->fb_hwfbe_enabled() && !SwapOK && (rdp.ci_count <= rdp.copy_ci_index)) { if (next_fb.status == ci_aux_copy) OpenTextureBuffer(rdp.frame_buffers[rdp.main_ci_index]); else OpenTextureBuffer(rdp.frame_buffers[rdp.copy_ci_index]); } - else if (fb_hwfbe_enabled && prev_fb.status == ci_aux) + else if (g_settings->fb_hwfbe_enabled() && prev_fb.status == ci_aux) { if (rdp.motionblur) { @@ -2685,7 +2630,7 @@ static void rdp_setcolorimage() break; case ci_copy: { - if (!rdp.motionblur || (g_settings->frame_buffer&fb_motionblur)) + if (!rdp.motionblur || g_settings->fb_motionblur_enabled()) { if (cur_fb.width == rdp.ci_width) { @@ -2693,7 +2638,7 @@ static void rdp_setcolorimage() { // if (CloseTextureBuffer(TRUE)) //* - if ((g_settings->hacks&hack_Zelda) && (rdp.frame_buffers[rdp.ci_count + 2].status == ci_aux) && !rdp.fb_drawn) //hack for photo camera in Zelda MM + if (g_settings->hacks(CSettings::hack_Zelda) && (rdp.frame_buffers[rdp.ci_count + 2].status == ci_aux) && !rdp.fb_drawn) //hack for photo camera in Zelda MM { CopyFrameBuffer(GR_BUFFER_TEXTUREBUFFER_EXT); rdp.fb_drawn = TRUE; @@ -2733,13 +2678,13 @@ static void rdp_setcolorimage() CopyFrameBuffer(); rdp.fb_drawn = TRUE; } - if (fb_hwfbe_enabled) + if (g_settings->fb_hwfbe_enabled()) OpenTextureBuffer(cur_fb); } break; case ci_old_copy: { - if (!rdp.motionblur || (g_settings->frame_buffer&fb_motionblur)) + if (!rdp.motionblur || g_settings->fb_motionblur_enabled()) { if (cur_fb.width == rdp.ci_width) { @@ -2764,12 +2709,12 @@ static void rdp_setcolorimage() */ case ci_aux: { - if (!fb_hwfbe_enabled && cur_fb.format != 0) + if (!g_settings->fb_hwfbe_enabled() && cur_fb.format != 0) rdp.skip_drawing = TRUE; else { rdp.skip_drawing = FALSE; - if (fb_hwfbe_enabled && OpenTextureBuffer(cur_fb)) + if (g_settings->fb_hwfbe_enabled() && OpenTextureBuffer(cur_fb)) ; else { @@ -2783,7 +2728,7 @@ static void rdp_setcolorimage() rdp.scale_y = 1.0f; // } } - else if (!fb_hwfbe_enabled && (prev_fb.status == ci_main) && + else if (!g_settings->fb_hwfbe_enabled() && (prev_fb.status == ci_main) && (prev_fb.width == cur_fb.width)) // for Pokemon Stadium CopyFrameBuffer(); } @@ -2792,13 +2737,11 @@ static void rdp_setcolorimage() } break; case ci_zimg: - if (g_settings->ucode != ucode_PerfectDark) + if (g_settings->ucode() != CSettings::ucode_PerfectDark) { - if (fb_hwfbe_enabled && !rdp.copy_ci_index && (rdp.copy_zi_index || (g_settings->hacks&hack_BAR))) + if (g_settings->fb_hwfbe_enabled() && !rdp.copy_ci_index && (rdp.copy_zi_index || g_settings->hacks(CSettings::hack_BAR))) { - GrLOD_t LOD = GR_LOD_LOG2_1024; - if (g_settings->scr_res_x > 1024) - LOD = GR_LOD_LOG2_2048; + GrLOD_t LOD = g_settings->scr_res_x() > 1024 ? GR_LOD_LOG2_1024 : GR_LOD_LOG2_2048; grTextureAuxBufferExt(rdp.texbufs[0].tmu, rdp.texbufs[0].begin, LOD, LOD, GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH); grAuxBufferExt(GR_BUFFER_TEXTUREAUXBUFFER_EXT); @@ -2808,9 +2751,9 @@ static void rdp_setcolorimage() rdp.skip_drawing = TRUE; break; case ci_zcopy: - if (g_settings->ucode != ucode_PerfectDark) + if (g_settings->ucode() != CSettings::ucode_PerfectDark) { - if (fb_hwfbe_enabled && !rdp.copy_ci_index && rdp.copy_zi_index == rdp.ci_count) + if (g_settings->fb_hwfbe_enabled() && !rdp.copy_ci_index && rdp.copy_zi_index == rdp.ci_count) { CopyDepthBuffer(); } @@ -2821,8 +2764,10 @@ static void rdp_setcolorimage() rdp.skip_drawing = TRUE; break; case ci_copy_self: - if (fb_hwfbe_enabled && (rdp.ci_count <= rdp.copy_ci_index) && (!SwapOK || g_settings->swapmode == 2)) + if (g_settings->fb_hwfbe_enabled() && (rdp.ci_count <= rdp.copy_ci_index) && (!SwapOK || g_settings->swapmode() == CSettings::SwapMode_Hybrid)) + { OpenTextureBuffer(cur_fb); + } rdp.skip_drawing = FALSE; break; default: @@ -2831,23 +2776,23 @@ static void rdp_setcolorimage() if ((rdp.ci_count > 0) && (prev_fb.status >= ci_aux)) //for Pokemon Stadium { - if (!fb_hwfbe_enabled && prev_fb.format == 0) + if (!g_settings->fb_hwfbe_enabled() && prev_fb.format == 0) CopyFrameBuffer(); - else if ((g_settings->hacks&hack_Knockout) && prev_fb.width < 100) + else if (g_settings->hacks(CSettings::hack_Knockout) && prev_fb.width < 100) CopyFrameBuffer(GR_BUFFER_TEXTUREBUFFER_EXT); } - if (!fb_hwfbe_enabled && cur_fb.status == ci_copy) + if (!g_settings->fb_hwfbe_enabled() && cur_fb.status == ci_copy) { if (!rdp.motionblur && (rdp.num_of_ci > rdp.ci_count + 1) && (next_fb.status != ci_aux)) { RestoreScale(); } } - if (!fb_hwfbe_enabled && cur_fb.status == ci_aux) + if (!g_settings->fb_hwfbe_enabled() && cur_fb.status == ci_aux) { if (cur_fb.format == 0) { - if ((g_settings->hacks&hack_PPL) && (rdp.scale_x < 1.1f)) //need to put current image back to frame buffer + if (g_settings->hacks(CSettings::hack_PPL) && (rdp.scale_x < 1.1f)) //need to put current image back to frame buffer { int width = cur_fb.width; int height = cur_fb.height; @@ -2900,10 +2845,10 @@ static void rdp_setcolorimage() WriteTrace(TraceRDP, TraceDebug, "return to original scale"); rdp.scale_x = rdp.scale_x_bak; rdp.scale_y = rdp.scale_y_bak; - if (fb_hwfbe_enabled && !rdp.read_whole_frame) + if (g_settings->fb_hwfbe_enabled() && !rdp.read_whole_frame) CloseTextureBuffer(); } - if (fb_hwfbe_enabled && !rdp.read_whole_frame && (prev_fb.status >= ci_aux) && (rdp.ci_count > rdp.copy_ci_index)) + if (g_settings->fb_hwfbe_enabled() && !rdp.read_whole_frame && (prev_fb.status >= ci_aux) && (rdp.ci_count > rdp.copy_ci_index)) CloseTextureBuffer(); } rdp.ci_status = cur_fb.status; @@ -2913,7 +2858,7 @@ static void rdp_setcolorimage() rdp.ocimg = rdp.cimg; rdp.cimg = segoffset(rdp.cmd1) & BMASK; rdp.ci_width = (rdp.cmd0 & 0xFFF) + 1; - if (fb_emulation_enabled && rdp.ci_count > 0) + if (g_settings->fb_emulation_enabled() && rdp.ci_count > 0) rdp.ci_height = rdp.frame_buffers[rdp.ci_count - 1].height; else if (rdp.ci_width == 32) rdp.ci_height = 32; @@ -2935,7 +2880,7 @@ static void rdp_setcolorimage() { if (!rdp.cur_image) { - if (fb_hwfbe_enabled && rdp.ci_width <= 64 && rdp.ci_count > 0) + if (g_settings->fb_hwfbe_enabled() && rdp.ci_width <= 64 && rdp.ci_count > 0) OpenTextureBuffer(rdp.frame_buffers[rdp.ci_count - 1]); else if (format > 2) rdp.skip_drawing = TRUE; @@ -2944,29 +2889,35 @@ static void rdp_setcolorimage() } else { - if (!fb_emulation_enabled) + if (!g_settings->fb_emulation_enabled()) rdp.skip_drawing = FALSE; } CI_SET = TRUE; - if (g_settings->swapmode > 0) + if (g_settings->swapmode() != CSettings::SwapMode_Old) { if (rdp.zimg == rdp.cimg) + { rdp.updatescreen = 1; + } - int viSwapOK = ((g_settings->swapmode == 2) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE; + int viSwapOK = ((g_settings->swapmode() == CSettings::SwapMode_Hybrid) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE; if ((rdp.zimg != rdp.cimg) && (rdp.ocimg != rdp.cimg) && SwapOK && viSwapOK && !rdp.cur_image) { - if (fb_emulation_enabled) + if (g_settings->fb_emulation_enabled()) + { rdp.maincimg[0] = rdp.frame_buffers[rdp.main_ci_index]; + } else + { rdp.maincimg[0].addr = rdp.cimg; - rdp.last_drawn_ci_addr = (g_settings->swapmode == 2) ? swapped_addr : rdp.maincimg[0].addr; + } + rdp.last_drawn_ci_addr = (g_settings->swapmode() == CSettings::SwapMode_Hybrid) ? swapped_addr : rdp.maincimg[0].addr; swapped_addr = rdp.cimg; newSwapBuffers(); rdp.vi_org_reg = *gfx.VI_ORIGIN_REG; SwapOK = FALSE; - if (fb_hwfbe_enabled) + if (g_settings->fb_hwfbe_enabled()) { if (rdp.copy_ci_index && (rdp.frame_buffers[rdp.ci_count - 1].status != ci_zimg)) { @@ -2987,7 +2938,7 @@ static void rdp_setcolorimage() static void rsp_reserved0() { - if (g_settings->ucode == ucode_DiddyKong) + if (g_settings->ucode() == CSettings::ucode_DiddyKong) { ucode5_texshiftaddr = segoffset(rdp.cmd1); ucode5_texshiftcount = 0; @@ -3016,10 +2967,10 @@ static void rsp_reserved3() void SetWireframeCol() { - switch (g_settings->wfmode) + switch (g_settings->wfmode()) { - //case 0: // normal colors, don't do anything - case 1: // vertex colors + //case CSettings::wfmode_NormalColors: // normal colors, don't do anything + case CSettings::wfmode_VertexColors: grColorCombine(GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_LOCAL_ITERATED, @@ -3047,7 +2998,7 @@ void SetWireframeCol() GR_COMBINE_FACTOR_NONE, FXFALSE, FXFALSE); break; - case 2: // red only + case CSettings::wfmode_RedOnly: grColorCombine(GR_COMBINE_FUNCTION_LOCAL, GR_COMBINE_FACTOR_NONE, GR_COMBINE_LOCAL_CONSTANT, @@ -3130,7 +3081,7 @@ EXPORT void CALL FBRead(uint32_t addr) { uint32_t cimg = rdp.cimg; rdp.cimg = rdp.maincimg[1].addr; - if (fb_emulation_enabled) + if (g_settings->fb_emulation_enabled()) { rdp.ci_width = rdp.maincimg[1].width; rdp.ci_count = 0; @@ -3231,11 +3182,13 @@ EXPORT void CALL FBGetFrameBufferInfo(void *p) WriteTrace(TraceGlide64, TraceDebug, "-"); FrameBufferInfo * pinfo = (FrameBufferInfo *)p; memset(pinfo, 0, sizeof(FrameBufferInfo) * 6); - if (!(g_settings->frame_buffer&fb_get_info)) + if (!g_settings->fb_get_info_enabled()) + { return; + } WriteTrace(TraceRDP, TraceDebug, "FBGetFrameBufferInfo ()"); - //* - if (fb_emulation_enabled) + + if (g_settings->fb_emulation_enabled()) { pinfo[0].addr = rdp.maincimg[1].addr; pinfo[0].size = rdp.maincimg[1].size; @@ -3280,7 +3233,7 @@ void DetectFrameBufferUsage() uint32_t a; int tidal = FALSE; - if ((g_settings->hacks&hack_PMario) && (rdp.copy_ci_index || rdp.frame_buffers[rdp.copy_ci_index].status == ci_copy_self)) + if (g_settings->hacks(CSettings::hack_PMario) && (rdp.copy_ci_index || rdp.frame_buffers[rdp.copy_ci_index].status == ci_copy_self)) tidal = TRUE; uint32_t ci = rdp.cimg, zi = rdp.zimg; uint32_t ci_height = rdp.frame_buffers[(rdp.ci_count > 0) ? rdp.ci_count - 1 : 0].height; @@ -3318,8 +3271,8 @@ void DetectFrameBufferUsage() // Go to the next instruction rdp.pc[rdp.pc_i] = (a + 8) & BMASK; - if (uintptr_t(reinterpret_cast(gfx_instruction_lite[g_settings->ucode][rdp.cmd0 >> 24]))) - gfx_instruction_lite[g_settings->ucode][rdp.cmd0 >> 24](); + if (uintptr_t(reinterpret_cast(gfx_instruction_lite[g_settings->ucode()][rdp.cmd0 >> 24]))) + gfx_instruction_lite[g_settings->ucode()][rdp.cmd0 >> 24](); // check DL counter if (rdp.dl_count != -1) @@ -3398,10 +3351,10 @@ void DetectFrameBufferUsage() rdp.num_of_ci = rdp.ci_count; if (rdp.read_previous_ci && previous_ci_was_read) { - if (!fb_hwfbe_enabled || !rdp.copy_ci_index) + if (!g_settings->fb_hwfbe_enabled() || !rdp.copy_ci_index) rdp.motionblur = TRUE; } - if (rdp.motionblur || fb_hwfbe_enabled || (rdp.frame_buffers[rdp.copy_ci_index].status == ci_aux_copy)) + if (rdp.motionblur || g_settings->fb_hwfbe_enabled() || (rdp.frame_buffers[rdp.copy_ci_index].status == ci_aux_copy)) { rdp.scale_x = rdp.scale_x_bak; rdp.scale_y = rdp.scale_y_bak; @@ -3411,9 +3364,9 @@ void DetectFrameBufferUsage() rdp.read_whole_frame = TRUE; if (rdp.read_whole_frame) { - if (fb_hwfbe_enabled) + if (g_settings->fb_hwfbe_enabled()) { - if (rdp.read_previous_ci && !previous_ci_was_read && (g_settings->swapmode != 2) && (g_settings->ucode != ucode_PerfectDark)) + if (rdp.read_previous_ci && !previous_ci_was_read && (g_settings->swapmode() != CSettings::SwapMode_Hybrid) && (g_settings->ucode() != CSettings::ucode_PerfectDark)) { int ind = (rdp.ci_count > 0) ? rdp.ci_count - 1 : 0; uint32_t height = rdp.frame_buffers[ind].height; @@ -3431,10 +3384,14 @@ void DetectFrameBufferUsage() { if (rdp.motionblur) { - if (g_settings->frame_buffer&fb_motionblur) + if (g_settings->fb_motionblur_enabled()) + { CopyFrameBuffer(); + } else + { memset(gfx.RDRAM + rdp.cimg, 0, rdp.ci_width*rdp.ci_height*rdp.ci_size); + } } else //if (ci_width == rdp.frame_buffers[rdp.main_ci_index].width) { @@ -3456,7 +3413,7 @@ void DetectFrameBufferUsage() } } - if (fb_hwfbe_enabled) + if (g_settings->fb_hwfbe_enabled()) { for (i = 0; i < voodoo.num_tmu; i++) { @@ -3474,8 +3431,10 @@ void DetectFrameBufferUsage() } } rdp.ci_count = 0; - if (g_settings->hacks&hack_Banjo2) + if (g_settings->hacks(CSettings::hack_Banjo2)) + { rdp.cur_tex_buf = 0; + } rdp.maincimg[0] = rdp.frame_buffers[rdp.main_ci_index]; // rdp.scale_x = rdp.scale_x_bak; // rdp.scale_y = rdp.scale_y_bak; @@ -3844,23 +3803,6 @@ void lle_triangle(uint32_t w1, uint32_t w2, int shade, int texture, int zbuffer, ConvertCoordsConvert(vtxbuf, nbVtxs); grCullMode(GR_CULL_DISABLE); grDrawVertexArrayContiguous(GR_TRIANGLE_STRIP, nbVtxs - 1, vtxbuf, sizeof(VERTEX)); - if (_debugger.capture) - { - VERTEX vl[3]; - vl[0] = vtxbuf[0]; - vl[1] = vtxbuf[2]; - vl[2] = vtxbuf[1]; - add_tri(vl, 3, TRI_TRIANGLE); - rdp.tri_n++; - if (nbVtxs > 4) - { - vl[0] = vtxbuf[2]; - vl[1] = vtxbuf[3]; - vl[2] = vtxbuf[1]; - add_tri(vl, 3, TRI_TRIANGLE); - rdp.tri_n++; - } - } } static void rdp_triangle(int shade, int texture, int zbuffer) @@ -4112,8 +4054,10 @@ void CALL ProcessRDPList(void) GoToFullScreen(); //* Set states *// - if (g_settings->swapmode > 0) + if (g_settings->swapmode() != CSettings::SwapMode_Old) + { SwapOK = TRUE; + } rdp.updatescreen = 1; rdp.tri_n = 0; // 0 triangles so far this frame @@ -4167,7 +4111,8 @@ void CALL ProcessRDPList(void) bool setZero = true; - while (rdp_cmd_cur != rdp_cmd_ptr) { + while (rdp_cmd_cur != rdp_cmd_ptr) + { uint32_t cmd = (rdp_cmd_data[rdp_cmd_cur] >> 24) & 0x3f; if ((((rdp_cmd_ptr - rdp_cmd_cur)&maxCMDMask) * 4) < rdp_command_length[cmd]) { @@ -4189,7 +4134,8 @@ void CALL ProcessRDPList(void) rdp_cmd_cur = (rdp_cmd_cur + rdp_command_length[cmd] / 4) & maxCMDMask; } - if (setZero) { + if (setZero) + { rdp_cmd_ptr = 0; rdp_cmd_cur = 0; } diff --git a/Source/Glide64/rdp.h b/Source/Glide64/rdp.h index f22022903..e7f46f766 100644 --- a/Source/Glide64/rdp.h +++ b/Source/Glide64/rdp.h @@ -47,10 +47,7 @@ extern char out_buf[2048]; extern uint32_t frame_count; // frame counter //GlideHQ support -#define TEXTURE_FILTER -#ifdef TEXTURE_FILTER #include "Ext_TxFilter.h" -#endif #define MAX_CACHE 1024*4 #define MAX_TRI_CACHE 768 // this is actually # of vertices, not triangles @@ -167,12 +164,6 @@ typedef struct { uint32_t lr_y; } SCISSOR; -#ifdef TEXTURE_FILTER -extern uint32_t texfltr[]; -extern uint32_t texenht[]; -extern uint32_t texcmpr[]; -extern uint32_t texhirs[]; - typedef struct { uint16_t tile_ul_s; uint16_t tile_ul_t; @@ -182,30 +173,6 @@ typedef struct { uint16_t tex_size; uint32_t dxt; } LOAD_TILE_INFO; -#endif - -enum rdpBitmapType -{ - rdpBITMAP_TYPE_INVALID, // should be == 0 for compatibility! - rdpBITMAP_TYPE_PNG, -}; - -typedef struct -{ - const char * format; - const char * extension; - rdpBitmapType type; -} SCREEN_SHOT_FORMAT; - -extern const int NumOfFormats; -extern SCREEN_SHOT_FORMAT ScreenShotFormats[]; - -typedef struct -{ - uint8_t hk_ref; - uint8_t hk_motionblur; - uint8_t hk_filtering; -} HOTKEY_INFO; typedef struct { @@ -325,10 +292,8 @@ typedef struct { float c_scl_y; // scale to lower-right center-texel y uint32_t mod, mod_color, mod_color1, mod_color2, mod_factor; -#ifdef TEXTURE_FILTER uint64 ricecrc; int is_hires_tex; -#endif } CACHE_LUT; // Lights @@ -503,9 +468,7 @@ struct RDP_Base{ TILE tiles[8]; // 8 tile descriptors uint8_t tmem[4096]; // 4k tmem uint32_t addr[512]; // 512 addresses (used to determine address loaded from) -#ifdef TEXTURE_FILTER LOAD_TILE_INFO load_info[512]; // 512 addresses. inforamation about tile loading. -#endif int cur_tile; // current tile int mipmap_level; @@ -526,9 +489,7 @@ struct RDP_Base{ int Persp_en; int persp_supported; int force_wrap; -#ifdef TEXTURE_FILTER uint16_t pal_8_rice[512]; -#endif // Lighting uint32_t num_lights; @@ -639,7 +600,6 @@ void ChangeSize(); void GoToFullScreen(); extern RDP rdp; -extern HOTKEY_INFO hotkey_info; extern VOODOO voodoo; extern GrTexInfo fontTex; @@ -649,7 +609,7 @@ extern uint32_t offset_cursor; extern uint32_t offset_textures; extern uint32_t offset_texbuf1; -extern int ucode_error_report; +extern bool g_ucode_error_report; // RDP functions void rdp_reset(); diff --git a/Source/Glide64/resource.h b/Source/Glide64/resource.h index f44379181..c2ef6cd8a 100644 --- a/Source/Glide64/resource.h +++ b/Source/Glide64/resource.h @@ -17,9 +17,6 @@ #define IDC_SPIN_TEXTURE_CACHE 1006 #define IDC_EDIT1 1007 #define IDC_CHK_USE_FRAME_BUFFER_OBJECT 1008 -#define IDC_CHK_CLOCK_ENABLED 1012 -#define IDC_CHK_CLOCK_24 1013 -#define IDC_CMB_SCREEN_SHOT_FORMAT 1015 #define IDC_CHK_SHOW_TEXTURE_ENHANCEMENT 1016 #define IDC_INFO 1017 #define IDC_CMB_FILTERING_MODE 1018 diff --git a/Source/Glide64/trace.cpp b/Source/Glide64/trace.cpp index 78fc73a7f..409f7f68b 100644 --- a/Source/Glide64/trace.cpp +++ b/Source/Glide64/trace.cpp @@ -1,11 +1,11 @@ #include "trace.h" #include "Config.h" +#include "settings.h" #include #include #include #include -#include #ifdef ANDROID #include @@ -55,7 +55,6 @@ void SetupTrace(void) TraceSetMaxModule(MaxTraceModuleGlide64, TraceError); #endif - TraceSetModuleName(TraceMD5, "MD5"); TraceSetModuleName(TraceThread, "Thread"); TraceSetModuleName(TracePath, "Path"); @@ -70,14 +69,8 @@ void SetupTrace(void) TraceSetModuleName(TracePNG, "PNG"); TraceSetModuleName(TraceOGLWrapper, "OGL Wrapper"); - char log_dir[260]; - memset(log_dir, 0, sizeof(log_dir)); - if (Set_log_dir != 0) - { - GetSystemSettingSz(Set_log_dir, log_dir, sizeof(log_dir)); - } - - if (strlen(log_dir) == 0) + const char * log_dir = g_settings ? g_settings->log_dir() : NULL; + if (log_dir == NULL || log_dir[0] == '\0') { return; } @@ -87,6 +80,6 @@ void SetupTrace(void) { LogFilePath.DirectoryCreate(); } - g_LogFile = new CTraceFileLog(LogFilePath, GetSystemSetting(Set_log_flush) != 0, CLog::Log_New, 500); + g_LogFile = new CTraceFileLog(LogFilePath, g_settings->FlushLogs(), CLog::Log_New, 500); TraceAddModule(g_LogFile); } \ No newline at end of file diff --git a/Source/Glide64/turbo3D.h b/Source/Glide64/turbo3D.h index c1d254a9d..5fb7cc053 100644 --- a/Source/Glide64/turbo3D.h +++ b/Source/Glide64/turbo3D.h @@ -243,9 +243,10 @@ static void t3dLoadObject(uint32_t pstate, uint32_t pvtx, uint32_t ptri) static void Turbo3D() { WriteTrace(TraceRDP, TraceDebug, "Start Turbo3D microcode"); - g_settings->ucode = ucode_Fast3D; + g_settings->SetUcode(CSettings::ucode_Fast3D); uint32_t a = 0, pgstate = 0, pstate = 0, pvtx = 0, ptri = 0; - do { + do + { a = rdp.pc[rdp.pc_i] & BMASK; pgstate = ((uint32_t*)gfx.RDRAM)[a >> 2]; pstate = ((uint32_t*)gfx.RDRAM)[(a >> 2) + 1]; @@ -258,11 +259,12 @@ static void Turbo3D() break; } if (pgstate) + { t3dLoadGlobState(pgstate); + } t3dLoadObject(pstate, pvtx, ptri); // Go to the next instruction rdp.pc[rdp.pc_i] += 16; } while (pstate); - // rdp_fullsync(); - g_settings->ucode = ucode_Turbo3d; + g_settings->SetUcode(CSettings::ucode_Turbo3d); } diff --git a/Source/Glide64/ucode00.h b/Source/Glide64/ucode00.h index 780e51660..47d3d6e80 100644 --- a/Source/Glide64/ucode00.h +++ b/Source/Glide64/ucode00.h @@ -37,18 +37,6 @@ // //**************************************************************** -#define ucode_Fast3D 0 -#define ucode_F3DEX 1 -#define ucode_F3DEX2 2 -#define ucode_WaveRace 3 -#define ucode_StarWars 4 -#define ucode_DiddyKong 5 -#define ucode_S2DEX 6 -#define ucode_PerfectDark 7 -#define ucode_CBFD 8 -#define ucode_zSort 9 -#define ucode_Turbo3d 21 - static void rsp_vertex(int v0, int n) { uint32_t addr = segoffset(rdp.cmd1) & 0x00FFFFFF; @@ -369,10 +357,10 @@ static void uc0_movemem() short trans_x = ((short*)gfx.RDRAM)[(a + 4) ^ 1] / 4; short trans_y = ((short*)gfx.RDRAM)[(a + 5) ^ 1] / 4; short trans_z = ((short*)gfx.RDRAM)[(a + 6) ^ 1]; - if (g_settings->correct_viewport) + if (g_settings->correct_viewport()) { - scale_x = abs(scale_x); - scale_y = abs(scale_y); + scale_x = (short)abs(scale_x); + scale_y = (short)abs(scale_y); } rdp.view_scale[0] = scale_x * rdp.scale_x; rdp.view_scale[1] = -scale_y * rdp.scale_y; @@ -535,7 +523,7 @@ static void uc0_tri1() &rdp.vtx[((rdp.cmd1 >> 8) & 0xFF) / 10], &rdp.vtx[(rdp.cmd1 & 0xFF) / 10] }; - if (g_settings->hacks & hack_Makers) + if (g_settings->hacks(CSettings::hack_Makers)) { rdp.force_wrap = FALSE; for (int i = 0; i < 3; i++) @@ -775,7 +763,10 @@ static void uc0_moveword() static void uc0_texture() { int tile = (rdp.cmd0 >> 8) & 0x07; - if (tile == 7 && (g_settings->hacks&hack_Supercross)) tile = 0; //fix for supercross 2000 + if (tile == 7 && g_settings->hacks(CSettings::hack_Supercross)) + { + tile = 0; //fix for supercross 2000 + } rdp.mipmap_level = (rdp.cmd0 >> 11) & 0x07; uint32_t on = (rdp.cmd0 & 0xFF); rdp.cur_tile = tile; @@ -811,7 +802,7 @@ static void uc0_setothermode_h() WriteTrace(TraceRDP, TraceDebug, "uc0:setothermode_h: "); int shift, len; - if ((g_settings->ucode == ucode_F3DEX2) || (g_settings->ucode == ucode_CBFD)) + if (g_settings->ucode() == CSettings::ucode_F3DEX2 || g_settings->ucode() == CSettings::ucode_CBFD) { len = (rdp.cmd0 & 0xFF) + 1; shift = 32 - ((rdp.cmd0 >> 8) & 0xFF) - len; @@ -889,7 +880,7 @@ static void uc0_setothermode_l() WriteTrace(TraceRDP, TraceDebug, "uc0:setothermode_l "); int shift, len; - if ((g_settings->ucode == ucode_F3DEX2) || (g_settings->ucode == ucode_CBFD)) + if (g_settings->ucode() == CSettings::ucode_F3DEX2 || g_settings->ucode() == CSettings::ucode_CBFD) { len = (rdp.cmd0 & 0xFF) + 1; shift = 32 - ((rdp.cmd0 >> 8) & 0xFF) - len; @@ -931,8 +922,10 @@ static void uc0_setothermode_l() rdp.update |= UPDATE_FOG_ENABLED; //if blender has no fog bits, fog must be set off rdp.render_mode_changed |= rdp.rm ^ rdp.othermode_l; rdp.rm = rdp.othermode_l; - if (g_settings->flame_corona && (rdp.rm == 0x00504341)) //hack for flame's corona - rdp.othermode_l |= /*0x00000020 |*/ 0x00000010; + if (g_settings->flame_corona() && (rdp.rm == 0x00504341)) //hack for flame's corona + { + rdp.othermode_l |= 0x00000010; + } WriteTrace(TraceRDP, TraceDebug, "rendermode: %08lx", rdp.othermode_l); // just output whole othermode_l } diff --git a/Source/Glide64/ucode01.h b/Source/Glide64/ucode01.h index 80d72eeeb..875756431 100644 --- a/Source/Glide64/ucode01.h +++ b/Source/Glide64/ucode01.h @@ -104,7 +104,7 @@ static void uc1_tri2() static void uc1_line3d() { - if (!g_settings->force_quad3d && ((rdp.cmd1 & 0xFF000000) == 0) && ((rdp.cmd0 & 0x00FFFFFF) == 0)) + if (!g_settings->force_quad3d() && ((rdp.cmd1 & 0xFF000000) == 0) && ((rdp.cmd0 & 0x00FFFFFF) == 0)) { uint16_t width = (uint16_t)(rdp.cmd1 & 0xFF) + 3; diff --git a/Source/Glide64/ucode02.h b/Source/Glide64/ucode02.h index bf099dba8..3f4ba0328 100644 --- a/Source/Glide64/ucode02.h +++ b/Source/Glide64/ucode02.h @@ -123,7 +123,7 @@ static void uc2_vertex() } uint32_t geom_mode = rdp.geom_mode; - if ((g_settings->hacks&hack_Fzero) && (rdp.geom_mode & 0x40000)) + if (g_settings->hacks(CSettings::hack_Fzero) && (rdp.geom_mode & 0x40000)) { if (((short*)gfx.RDRAM)[(((addr) >> 1) + 4) ^ 1] || ((short*)gfx.RDRAM)[(((addr) >> 1) + 5) ^ 1]) rdp.geom_mode ^= 0x40000; @@ -413,8 +413,10 @@ static void uc2_geom_mode() { if ((rdp.flags & ZBUF_ENABLED)) { - if (!g_settings->flame_corona || (rdp.rm != 0x00504341)) //hack for flame's corona + if (!g_settings->flame_corona() || (rdp.rm != 0x00504341)) //hack for flame's corona + { rdp.flags ^= ZBUF_ENABLED; + } rdp.update |= UPDATE_ZBUF_ENABLED; } } diff --git a/Source/Glide64/ucode05.h b/Source/Glide64/ucode05.h index f9852c8d9..f7c6903d2 100644 --- a/Source/Glide64/ucode05.h +++ b/Source/Glide64/ucode05.h @@ -114,7 +114,7 @@ static void uc5_vertex() // 0 = unused int n = ((rdp.cmd0 >> 19) & 0x1F);// + 1; - if (g_settings->hacks&hack_Diddy) + if (g_settings->hacks(CSettings::hack_Diddy)) n++; if (rdp.cmd0 & 0x00010000) diff --git a/Source/Glide64/ucode06.h b/Source/Glide64/ucode06.h index c9fe96a13..a421f9c57 100644 --- a/Source/Glide64/ucode06.h +++ b/Source/Glide64/ucode06.h @@ -209,9 +209,7 @@ void DrawHiresDepthImage(const DRAWIMAGE & d) grDepthBufferFunction(GR_CMP_ALWAYS); grDepthMask(FXFALSE); - GrLOD_t LOD = GR_LOD_LOG2_1024; - if (g_settings->scr_res_x > 1024) - LOD = GR_LOD_LOG2_2048; + GrLOD_t LOD = g_settings->scr_res_x() > 1024 ? GR_LOD_LOG2_2048 : GR_LOD_LOG2_1024; float lr_x = (float)d.imageW * rdp.scale_x; float lr_y = (float)d.imageH * rdp.scale_y; @@ -233,7 +231,6 @@ void DrawHiresDepthImage(const DRAWIMAGE & d) GR_ASPECT_LOG2_1x1, GR_TEXFMT_RGB_565, GR_MIPMAPLEVELMASK_BOTH); grRenderBuffer(GR_BUFFER_TEXTUREBUFFER_EXT); grAuxBufferExt(GR_BUFFER_AUXBUFFER); - grSstOrigin(GR_ORIGIN_UPPER_LEFT); grBufferClear(0, 0, 0xFFFF); grDrawTriangle(&v[0], &v[2], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]); @@ -246,12 +243,12 @@ void DrawHiresDepthImage(const DRAWIMAGE & d) void DrawDepthImage(const DRAWIMAGE & d) { - if (!fb_depth_render_enabled) + if (!g_settings->fb_depth_render_enabled()) return; if (d.imageH > d.imageW) return; WriteTrace(TraceRDP, TraceDebug, "Depth image write"); - if (fb_hwfbe_enabled) + if (g_settings->fb_hwfbe_enabled()) { DrawHiresDepthImage(d); return; @@ -262,8 +259,8 @@ void DrawDepthImage(const DRAWIMAGE & d) float scale_y_src = 1.0f / rdp.scale_y; int src_width = d.imageW; int src_height = d.imageH; - int dst_width = minval(int(src_width*scale_x_dst), (int)g_settings->scr_res_x); - int dst_height = minval(int(src_height*scale_y_dst), (int)g_settings->scr_res_y); + int dst_width = minval(int(src_width*scale_x_dst), (int)g_settings->scr_res_x()); + int dst_height = minval(int(src_height*scale_y_dst), (int)g_settings->scr_res_y()); uint16_t * src = (uint16_t*)(gfx.RDRAM + d.imagePtr); uint16_t * dst = new uint16_t[dst_width*dst_height]; for (int y = 0; y < dst_height; y++) @@ -289,7 +286,9 @@ void DrawImage(DRAWIMAGE & d) { if (d.imageW == 0 || d.imageH == 0 || d.frameH == 0) return; - int x_size, y_size, x_shift, y_shift, line; + int x_shift, y_shift; + uint16_t x_size, y_size, line; + // choose optimum size for the format/size switch (d.imageSiz) { @@ -356,15 +355,19 @@ void DrawImage(DRAWIMAGE & d) } } - if ((g_settings->hacks&hack_PPL) > 0) + if (g_settings->hacks(CSettings::hack_PPL)) { if (d.imageY > d.imageH) + { d.imageY = (d.imageY%d.imageH); + } } - else if ((g_settings->hacks&hack_Starcraft) > 0) + else if (g_settings->hacks(CSettings::hack_Starcraft)) { if (d.imageH % 2 == 1) + { d.imageH -= 1; + } } else { @@ -443,7 +446,7 @@ void DrawImage(DRAWIMAGE & d) rdp.allow_combine = 0; if (rdp.ci_width == 512 && !no_dlist) - grClipWindow(0, 0, g_settings->scr_res_x, g_settings->scr_res_y); + grClipWindow(0, 0, g_settings->scr_res_x(), g_settings->scr_res_y()); else if (d.scaleX == 1.0f && d.scaleY == 1.0f) grClipWindow(rdp.scissor.ul_x, rdp.scissor.ul_y, rdp.scissor.lr_x, rdp.scissor.lr_y); else @@ -546,23 +549,7 @@ void DrawImage(DRAWIMAGE & d) ConvertCoordsConvert(v, 4); grDrawVertexArrayContiguous(GR_TRIANGLE_STRIP, 4, v, sizeof(VERTEX)); - - if (_debugger.capture) - { - VERTEX vl[3]; - vl[0] = v[0]; - vl[1] = v[2]; - vl[2] = v[1]; - add_tri(vl, 3, TRI_BACKGROUND); - rdp.tri_n++; - vl[0] = v[2]; - vl[1] = v[3]; - vl[2] = v[1]; - add_tri(vl, 3, TRI_BACKGROUND); - rdp.tri_n++; - } - else - rdp.tri_n += 2; + rdp.tri_n += 2; } else { @@ -611,13 +598,13 @@ void DrawHiresImage(DRAWIMAGE & d, int screensize = FALSE) setTBufTex(rdp.tbuff_tex->t_mem, rdp.tbuff_tex->width << rdp.tbuff_tex->size >> 1); const float Z = set_sprite_combine_mode(); - grClipWindow(0, 0, g_settings->res_x, g_settings->res_y); + grClipWindow(0, 0, g_settings->res_x(), g_settings->res_y()); if (d.imageW % 2 == 1) d.imageW -= 1; if (d.imageH % 2 == 1) d.imageH -= 1; if (d.imageY > d.imageH) d.imageY = (d.imageY%d.imageH); - if (!(g_settings->hacks&hack_PPL)) + if (!g_settings->hacks(CSettings::hack_PPL)) { if ((d.frameX > 0) && (d.frameW == rdp.ci_width)) d.frameW -= (uint16_t)(2.0f*d.frameX); @@ -676,22 +663,7 @@ void DrawHiresImage(DRAWIMAGE & d, int screensize = FALSE) grDrawTriangle(&v[0], &v[2], &v[1]); grDrawTriangle(&v[2], &v[3], &v[1]); rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_COMBINE | UPDATE_TEXTURE | UPDATE_ALPHA_COMPARE | UPDATE_SCISSOR; - if (_debugger.capture) - { - VERTEX vl[3]; - vl[0] = v[0]; - vl[1] = v[2]; - vl[2] = v[1]; - add_tri(vl, 3, TRI_BACKGROUND); - rdp.tri_n++; - vl[0] = v[2]; - vl[1] = v[3]; - vl[2] = v[1]; - add_tri(vl, 3, TRI_BACKGROUND); - rdp.tri_n++; - } - else - rdp.tri_n += 2; + rdp.tri_n += 2; rdp.tbuff_tex = tbuff_tex; } @@ -758,13 +730,13 @@ static void uc6_bg(bool bg_1cyc) DRAWIMAGE d; uc6_read_background_data(d, bg_1cyc); - if (fb_hwfbe_enabled && FindTextureBuffer(d.imagePtr, d.imageW)) + if (g_settings->fb_hwfbe_enabled() && FindTextureBuffer(d.imagePtr, d.imageW)) { DrawHiresImage(d); return; } - if (g_settings->ucode == ucode_F3DEX2 || (g_settings->hacks&hack_PPL)) + if (g_settings->ucode() == CSettings::ucode_F3DEX2 || g_settings->hacks(CSettings::hack_PPL)) { if ((d.imagePtr != rdp.cimg) && (d.imagePtr != rdp.ocimg) && d.imagePtr) //can't draw from framebuffer DrawImage(d); @@ -979,7 +951,7 @@ static void uc6_draw_polygons(VERTEX v[4]) } rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_VIEWPORT; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) { grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); } @@ -1276,7 +1248,7 @@ static void uc6_obj_rectangle_r() DRAWOBJECT d; uc6_read_object_data(d); - if (d.imageFmt == 1 && (g_settings->hacks&hack_Ogre64)) //Ogre Battle needs to copy YUV texture to frame buffer + if (d.imageFmt == 1 && g_settings->hacks(CSettings::hack_Ogre64)) //Ogre Battle needs to copy YUV texture to frame buffer { float ul_x = d.objX / mat_2d.BaseScaleX + mat_2d.X; float lr_x = (d.objX + d.imageW / d.scaleW) / mat_2d.BaseScaleX + mat_2d.X; @@ -1384,7 +1356,7 @@ static void uc6_obj_loadtxtr() WriteTrace(TraceRDP, TraceDebug, "tile addr: %08lx, tmem: %08lx, twidth: %d, theight: %d", image, tmem, twidth, theight); - int line = (twidth + 1) >> 2; + uint16_t line = (twidth + 1) >> 2; rdp.timg.addr = image; rdp.timg.width = line << 3; @@ -1519,7 +1491,7 @@ void uc6_sprite2d() d.frameY = ((short)(cmd1 & 0xFFFF)) / 4.0f; d.frameW = (uint16_t)(d.imageW / d.scaleX); d.frameH = (uint16_t)(d.imageH / d.scaleY); - if (g_settings->hacks&hack_WCWnitro) + if (g_settings->hacks(CSettings::hack_WCWnitro)) { int scaleY = (int)d.scaleY; d.imageH /= scaleY; @@ -1688,7 +1660,7 @@ void uc6_sprite2d() } rdp.update |= UPDATE_ZBUF_ENABLED | UPDATE_VIEWPORT; - if (g_settings->fog && (rdp.flags & FOG_ENABLED)) + if (g_settings->fog() && (rdp.flags & FOG_ENABLED)) { grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT); } diff --git a/Source/Glide64/ucode09rdp.h b/Source/Glide64/ucode09rdp.h index 587b55ad5..805593dd5 100644 --- a/Source/Glide64/ucode09rdp.h +++ b/Source/Glide64/ucode09rdp.h @@ -63,7 +63,7 @@ void uc9_rpdcmd() a++; rdp.cmd3 = ((uint32_t*)gfx.RDRAM)[a++]; } - gfx_instruction[ucode_zSort][cmd](); + gfx_instruction[CSettings::ucode_zSort][cmd](); }; rdp.LLE = 0; } diff --git a/Source/Glide64/ucodeFB.h b/Source/Glide64/ucodeFB.h index bfb2571e2..83c770299 100644 --- a/Source/Glide64/ucodeFB.h +++ b/Source/Glide64/ucodeFB.h @@ -62,7 +62,7 @@ static void fb_bg_copy() if (rdp.main_ci == 0) return; CI_STATUS status = rdp.frame_buffers[rdp.ci_count - 1].status; - if ((status == ci_copy)) + if (status == ci_copy) return; uint32_t addr = segoffset(rdp.cmd1) >> 1; @@ -222,7 +222,7 @@ static void fb_settextureimage() rdp.scale_y = 1.0f; } } - else if (!(g_settings->frame_buffer & fb_ignore_aux_copy) && cur_fb.width < rdp.frame_buffers[rdp.main_ci_index].width) + else if (!g_settings->fb_ignore_aux_copy_enabled() && cur_fb.width < rdp.frame_buffers[rdp.main_ci_index].width) { rdp.copy_ci_index = rdp.ci_count - 1; cur_fb.status = ci_aux_copy; @@ -238,7 +238,6 @@ static void fb_settextureimage() } WriteTrace(TraceRDP, TraceDebug, "Detect FB usage. texture addr is inside framebuffer: %08lx - %08lx ", addr, rdp.main_ci); } - ///* else if ((cur_fb.status != ci_main) && (addr >= rdp.zimg && addr < rdp.zimg_end)) { cur_fb.status = ci_zcopy; @@ -246,7 +245,6 @@ static void fb_settextureimage() rdp.copy_zi_index = rdp.ci_count - 1; WriteTrace(TraceRDP, TraceDebug, "fb_settextureimage. rdp.frame_buffers[%d].status = ci_zcopy", rdp.ci_count - 1); } - //*/ else if ((rdp.maincimg[0].width > 64) && (addr >= rdp.maincimg[0].addr) && (addr < (rdp.maincimg[0].addr + rdp.maincimg[0].width*rdp.maincimg[0].height * 2))) { if (cur_fb.status != ci_main) @@ -268,7 +266,7 @@ static void fb_settextureimage() WriteTrace(TraceRDP, TraceDebug, "read_previous_ci = TRUE"); } } - else if (fb_hwfbe_enabled && (cur_fb.status == ci_main)) + else if (g_settings->fb_hwfbe_enabled() && (cur_fb.status == ci_main)) { if ((addr >= rdp.main_ci) && (addr < rdp.main_ci_end)) //addr within main frame buffer { @@ -407,7 +405,7 @@ static void fb_setcolorimage() } if (rdp.ci_count > 0 && rdp.frame_buffers[rdp.ci_count - 1].status == ci_unknown) //status of previous fb was not changed - it is useless { - if (fb_hwfbe_enabled && !(g_settings->frame_buffer & fb_useless_is_useless)) + if (g_settings->fb_hwfbe_enabled() && !g_settings->fb_useless_is_useless_enabled()) { rdp.frame_buffers[rdp.ci_count - 1].status = ci_aux; rdp.frame_buffers[rdp.ci_count - 1].changed = 0; @@ -432,7 +430,7 @@ static void fb_setcolorimage() } if (cur_fb.status == ci_main) { - int viSwapOK = ((g_settings->swapmode == 2) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE; + int viSwapOK = ((g_settings->swapmode() == CSettings::SwapMode_Hybrid) && (rdp.vi_org_reg == *gfx.VI_ORIGIN_REG)) ? FALSE : TRUE; if ((rdp.maincimg[0].addr != cur_fb.addr) && SwapOK && viSwapOK) { SwapOK = FALSE; diff --git a/Source/GlideHQ/TxDbg.cpp b/Source/GlideHQ/TxDbg.cpp index 0ee1817f0..d48b43ced 100644 --- a/Source/GlideHQ/TxDbg.cpp +++ b/Source/GlideHQ/TxDbg.cpp @@ -29,31 +29,28 @@ #include #include #include -#include +#include TxDbg::TxDbg() { - - char log_dir[260]; - memset(log_dir, 0, sizeof(log_dir)); - if (Set_log_dir != 0) + const char * log_dir = g_settings->log_dir(); + if (log_dir != NULL && log_dir[0] != '\0') { - GetSystemSettingSz(Set_log_dir, log_dir, sizeof(log_dir)); - } + _level = DBG_LEVEL; - _level = DBG_LEVEL; - - if (!_dbgfile) + if (!_dbgfile) #ifdef GHQCHK - _dbgfile = fopen(CPath(log_dir, "ghqchk.txt"), "w"); + _dbgfile = fopen(CPath(log_dir, "ghqchk.txt"), "w"); #else - _dbgfile = fopen(CPath(log_dir, "glidehq.dbg"), "w"); + _dbgfile = fopen(CPath(log_dir, "glidehq.dbg"), "w"); #endif + } } TxDbg::~TxDbg() { - if (_dbgfile) { + if (_dbgfile) + { fclose(_dbgfile); _dbgfile = 0; } diff --git a/Source/GlideHQ/TxHiResCache.cpp b/Source/GlideHQ/TxHiResCache.cpp index 30cbaf72d..4b390b18b 100644 --- a/Source/GlideHQ/TxHiResCache.cpp +++ b/Source/GlideHQ/TxHiResCache.cpp @@ -146,8 +146,6 @@ TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */ switch (_options & HIRESTEXTURES_MASK) { - case GHQ_HIRESTEXTURES: - break; case RICE_HIRESTEXTURES: INFO(80, "-----\n"); INFO(80, "using Rice hires texture format...\n"); @@ -163,8 +161,6 @@ TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */ dir_path.AppendDirectory(_ident.c_str()); loadHiResTextures(dir_path, replace); break; - case JABO_HIRESTEXTURES: - ; } return 1; diff --git a/Source/Glitch64/OGLEScombiner.cpp b/Source/Glitch64/OGLEScombiner.cpp index 9df06fb01..821063033 100644 --- a/Source/Glitch64/OGLEScombiner.cpp +++ b/Source/Glitch64/OGLEScombiner.cpp @@ -241,7 +241,7 @@ void check_link(GLuint program) } } -void set_rotation_matrix(GLuint loc, int rotate) +void set_rotation_matrix(GLuint loc, CSettings::ScreenRotate_t rotate) { GLfloat mat[16]; @@ -252,13 +252,13 @@ void set_rotation_matrix(GLuint loc, int rotate) * (0, 0, 0, 1) */ - //mat[0] = cos(angle); - //mat[1] = sin(angle); + mat[0] = 1; + mat[1] = 0; mat[2] = 0; mat[3] = 0; - //mat[4] = -sin(angle); - //mat[5] = cos(angle); + mat[4] = 0; + mat[5] = 1; mat[6] = 0; mat[7] = 0; @@ -273,35 +273,27 @@ void set_rotation_matrix(GLuint loc, int rotate) mat[15] = 1; /* now set the actual rotation */ - if (1 == rotate) // 90 degree + if (rotate == CSettings::Rotate_90) { mat[0] = 0; mat[1] = 1; mat[4] = -1; mat[5] = 0; } - else if (2 == rotate) // 180 degree + else if (rotate == CSettings::Rotate_180) { mat[0] = -1; mat[1] = 0; mat[4] = 0; mat[5] = -1; } - else if (3 == rotate) // 270 degree + else if (rotate == CSettings::Rotate_270) { mat[0] = 0; mat[1] = -1; mat[4] = 1; mat[5] = 0; } - else /* 0 degree, also fallback if input is wrong) */ - { - mat[0] = 1; - mat[1] = 0; - mat[4] = 0; - mat[5] = 1; - } - glUniformMatrix4fv(loc, 1, GL_FALSE, mat); } @@ -349,7 +341,7 @@ void init_combiner() check_link(g_program_object_default); glUseProgram(g_program_object_default); int rotation_matrix_location = glGetUniformLocation(g_program_object_default, "rotation_matrix"); - set_rotation_matrix(rotation_matrix_location, g_settings->rotate); + set_rotation_matrix(rotation_matrix_location, g_settings->rotate()); texture0_location = glGetUniformLocation(g_program_object_default, "texture0"); texture1_location = glGetUniformLocation(g_program_object_default, "texture1"); @@ -484,7 +476,7 @@ void update_uniforms(GLuint program_object, const shader_program_key & prog) } GLuint rotation_matrix_location = glGetUniformLocation(program_object, "rotation_matrix"); - set_rotation_matrix(rotation_matrix_location, g_settings->rotate); + set_rotation_matrix(rotation_matrix_location, g_settings->rotate()); set_lambda(); } @@ -1697,7 +1689,7 @@ grChromakeyValue(GrColor_t value) g_chroma_color[2], g_chroma_color[3]); } -static void setPattern() +void setPattern() { int i; GLubyte stip[32 * 4]; @@ -1732,15 +1724,6 @@ static void setPattern() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } -FX_ENTRY void FX_CALL -grStipplePattern( -GrStipplePattern_t stipple) -{ - WriteTrace(TraceResolution, TraceDebug, "value: %x", stipple); - srand(stipple); - setPattern(); -} - FX_ENTRY void FX_CALL grStippleMode(GrStippleMode_t mode) { diff --git a/Source/Glitch64/OGLESgeometry.cpp b/Source/Glitch64/OGLESgeometry.cpp index 6133ee593..ad6eb3220 100644 --- a/Source/Glitch64/OGLESgeometry.cpp +++ b/Source/Glitch64/OGLESgeometry.cpp @@ -350,7 +350,7 @@ void FindBestDepthBias() glVertex3f(float(x + 4 - widtho) / (width / 2), float(4 - heighto) / (height / 2), 0.5); glVertex3f(float(x - widtho) / (width / 2), float(4 - heighto) / (height / 2), 0.5); glEnd(); - glReadPixels(x + 2, 2 + viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); + glReadPixels(x + 2, 2 + g_viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); z -= 0.75f + 8e-6f; if (z < 0.0f) z = -z; if (z > 0.01f) continue; @@ -397,7 +397,7 @@ grDrawTriangle(const void *a, const void *b, const void *c) vbo_enable(); if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -436,7 +436,7 @@ grDrawPoint(const void *pt) if(nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -506,7 +506,7 @@ grDrawLine(const void *a, const void *b) if(nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -579,7 +579,7 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -603,7 +603,7 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } diff --git a/Source/Glitch64/OGLESglitchmain.cpp b/Source/Glitch64/OGLESglitchmain.cpp index 3b690477f..15c1e7a3f 100644 --- a/Source/Glitch64/OGLESglitchmain.cpp +++ b/Source/Glitch64/OGLESglitchmain.cpp @@ -22,7 +22,6 @@ #ifdef _WIN32 #include -#include #else #include #include @@ -72,8 +71,8 @@ if (x+width >= screen_width) { width = screen_width - x; //printf("resizing w --> %d\n", width); } -if (y+height >= screen_height+viewport_offset) { -height = screen_height+viewport_offset - y; +if (y+height >= screen_height+g_viewport_offset) { +height = screen_height+g_viewport_offset - y; //printf("resizing h --> %d\n", height); } glCopyTexSubImage2D(target, level, 0, 0, x, y, width, height); @@ -162,7 +161,7 @@ int default_texture; // the infamous "32*1024*1024" is now configurable int current_texture; int depth_texture, color_texture; int glsl_support = 1; -int viewport_width, viewport_height, viewport_offset = 0, nvidia_viewport_hack = 0; +int viewport_width, viewport_height, g_viewport_offset = 0, nvidia_viewport_hack = 0; int save_w, save_h; int lfb_color_fmt; float invtex[2]; @@ -173,14 +172,8 @@ int UMAmode = 0; //support for VSA-100 UMA mode; static HDC hDC = NULL; static HGLRC hGLRC = NULL; static HWND hToolBar = NULL; -static HWND hwnd_win = NULL; -static unsigned long windowedExStyle, windowedStyle; #endif // _WIN32 static unsigned long fullscreen; -#ifdef _WIN32 -static RECT windowedRect; -static HMENU windowedMenu; -#endif // _WIN32 static int savedWidtho, savedHeighto; static int savedWidth, savedHeight; @@ -287,11 +280,11 @@ grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy) if (int(miny) < 0) miny = 0; if (maxx < minx) maxx = minx; if (maxy < miny) maxy = miny; - glScissor(minx, miny + viewport_offset, maxx - minx, maxy - miny); + glScissor(minx, miny + g_viewport_offset, maxx - minx, maxy - miny); //printf("gl scissor %d %d %d %d\n", minx, miny, maxx, maxy); } else { - glScissor(minx, (viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); + glScissor(minx, (g_viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); } glEnable(GL_SCISSOR_TEST); } @@ -309,12 +302,6 @@ grGlideInit(void) WriteTrace(TraceGlitch, TraceDebug, "-"); } -FX_ENTRY void FX_CALL -grSstSelect(int which_sst) -{ - WriteTrace(TraceGlitch, TraceDebug, "which_sst = %d", which_sst); -} - int isExtensionSupported(const char *extension) { return 0; @@ -380,10 +367,10 @@ int isWglExtensionSupported(const char *extension) #define GrPixelFormat_t int -FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt(GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers) +FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt(GrColorFormat_t color_format, GrOriginLocation_t origin_location, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers) { - WriteTrace(TraceGlitch, TraceDebug, "refresh_rate: %d, color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers); - return grSstWinOpen(refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers); + WriteTrace(TraceGlitch, TraceDebug, "color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", color_format, origin_location, nColBuffers, nAuxBuffers); + return grSstWinOpen(color_format, origin_location, nColBuffers, nAuxBuffers); } #ifdef _WIN32 @@ -393,7 +380,7 @@ FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt(GrScreenRefresh_t refresh_rate, GrC # endif #endif -FX_ENTRY GrContext_t FX_CALL grSstWinOpen( GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers) +FX_ENTRY GrContext_t FX_CALL grSstWinOpen( GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers) { static int show_warning = 1; @@ -405,16 +392,16 @@ FX_ENTRY GrContext_t FX_CALL grSstWinOpen( GrScreenRefresh_t refresh_rate, GrCol color_texture = free_texture++; depth_texture = free_texture++; - WriteTrace(TraceGlitch, TraceDebug, "refresh_rate: %d, color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers); + WriteTrace(TraceGlitch, TraceDebug, "color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", color_format, origin_location, nColBuffers, nAuxBuffers); WriteTrace(TraceGlitch, TraceDebug, "g_width: %d, g_height: %d fullscreen: %d", g_width, g_height, fullscreen); - //viewport_offset = ((screen_resolution>>2) > 20) ? screen_resolution >> 2 : 20; - // ZIGGY viewport_offset is WIN32 specific, with SDL just set it to zero - viewport_offset = 0; //-10 //-20; + //g_viewport_offset = ((screen_resolution>>2) > 20) ? screen_resolution >> 2 : 20; + // ZIGGY g_viewport_offset is WIN32 specific, with SDL just set it to zero + g_viewport_offset = 0; //-10 //-20; printf("(II) Setting video mode %dx%d...\n", g_width, g_height); - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); lfb_color_fmt = color_format; if (origin_location != GR_ORIGIN_UPPER_LEFT) WriteTrace(TraceGlitch, TraceWarning, "origin must be in upper left corner"); if (nColBuffers != 2) WriteTrace(TraceGlitch, TraceWarning, "number of color buffer is not 2"); @@ -542,12 +529,12 @@ FX_ENTRY GrContext_t FX_CALL grSstWinOpen( GrScreenRefresh_t refresh_rate, GrCol #endif #ifdef _WIN32 - glViewport(0, viewport_offset, width, height); + glViewport(0, g_viewport_offset, width, height); viewport_width = width; viewport_height = height; nvidia_viewport_hack = 1; #else - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); viewport_width = g_width; viewport_height = g_height; #endif // _WIN32 @@ -676,18 +663,7 @@ grSstWinClose(GrContext_t context) wglDeleteContext(hGLRC); hGLRC = NULL; } - if (fullscreen) - { - ChangeDisplaySettings(NULL, 0); - SetWindowPos(hwnd_win, NULL, - windowedRect.left, windowedRect.top, - 0, 0, - SWP_NOZORDER | SWP_NOSIZE); - SetWindowLong(hwnd_win, GWL_STYLE, windowedStyle); - SetWindowLong(hwnd_win, GWL_EXSTYLE, windowedExStyle); - if (windowedMenu) SetMenu(hwnd_win, windowedMenu); - fullscreen = 0; - } + ExitFullScreen(); #endif return FXTRUE; } @@ -749,26 +725,26 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu, if (save_w) { if (tw > save_w && th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, - 0, viewport_offset + save_h, tw, th - save_h); + 0, g_viewport_offset + save_h, tw, th - save_h); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, save_w, 0, - save_w, viewport_offset, tw - save_w, save_h); + save_w, g_viewport_offset, tw - save_w, save_h); save_w = tw; save_h = th; } else if (tw > save_w) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, save_w, 0, - save_w, viewport_offset, tw - save_w, save_h); + save_w, g_viewport_offset, tw - save_w, save_h); save_w = tw; } else if (th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, - 0, viewport_offset + save_h, save_w, th - save_h); + 0, g_viewport_offset + save_h, save_w, th - save_h); save_h = th; } } else { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, - 0, viewport_offset, tw, th); + 0, g_viewport_offset, tw, th); save_w = tw; save_h = th; } @@ -817,12 +793,12 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu, //printf("viewport %dx%d\n", width, height); if (g_height > screen_height) { - glViewport(0, viewport_offset + screen_height - g_height, g_width, g_height); + glViewport(0, g_viewport_offset + screen_height - g_height, g_width, g_height); } else - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); - glScissor(0, viewport_offset, g_width, g_height); + glScissor(0, g_viewport_offset, g_width, g_height); } else { if (!render_to_texture) //initialization @@ -1058,8 +1034,6 @@ grGetProcAddress(char *procName) return (GrProc)grTextureAuxBufferExt; if (!strcmp(procName, "grAuxBufferExt")) return (GrProc)grAuxBufferExt; - if (!strcmp(procName, "grWrapperFullScreenResolutionExt")) - return (GrProc)grWrapperFullScreenResolutionExt; if (!strcmp(procName, "grConfigWrapperExt")) return (GrProc)grConfigWrapperExt; if (!strcmp(procName, "grKeyPressedExt")) @@ -1087,7 +1061,7 @@ grGet(FxU32 pname, FxU32 plength, FxI32 *params) if (plength < 4 || params == NULL) return 0; if (!nbTextureUnits) { - grSstWinOpen(0, GR_COLORFORMAT_ARGB, GR_ORIGIN_UPPER_LEFT, 2, 1); + grSstWinOpen(GR_COLORFORMAT_ARGB, GR_ORIGIN_UPPER_LEFT, 2, 1); grSstWinClose(0); } #ifdef VOODOO1 @@ -1359,7 +1333,7 @@ void updateTexture() //glDeleteTextures( 1, &pBufferAddress ); glBindTexture(GL_TEXTURE_2D, pBufferAddress); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, - 0, viewport_offset, g_width, g_height, 0); + 0, g_viewport_offset, g_width, g_height, 0); glBindTexture(GL_TEXTURE_2D, default_texture); //glPopAttrib(); @@ -1385,7 +1359,7 @@ FX_ENTRY void FX_CALL grFramebufferCopyExt(int x, int y, int w, int h, //glReadBuffer(current_buffer); glBindTexture(GL_TEXTURE_2D, depth_texture); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, - 0, viewport_offset, tw, th, 0); + 0, g_viewport_offset, tw, th, 0); glBindTexture(GL_TEXTURE_2D, default_texture); return; } @@ -1448,8 +1422,8 @@ grRenderBuffer(GrBuffer_t buffer) } curBufferAddr = 0; - glViewport(0, viewport_offset, g_width, viewport_height); - glScissor(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, viewport_height); + glScissor(0, g_viewport_offset, g_width, g_height); #ifdef SAVE_CBUFFER if (!use_fbo && render_to_texture == 2) { @@ -1688,7 +1662,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 4; info->writeMode = GR_LFBWRITEMODE_888; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, frameBuffer); } else { buf = (unsigned char*)malloc(g_width*g_height * 4); @@ -1697,7 +1671,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 2; info->writeMode = GR_LFBWRITEMODE_565; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); for (j = 0; j < g_height; j++) { @@ -1718,7 +1692,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 2; info->writeMode = GR_LFBWRITEMODE_ZA16; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); } } @@ -1767,7 +1741,7 @@ FxU32 dst_stride, void *dst_data) { buf = (unsigned char*)malloc(src_width*src_height * 4); - glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glReadPixels(src_x, (g_viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); for (j = 0; j < src_height; j++) { @@ -1785,7 +1759,7 @@ FxU32 dst_stride, void *dst_data) { buf = (unsigned char*)malloc(src_width*src_height * 2); - glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); + glReadPixels(src_x, (g_viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); for (j = 0; j < src_height; j++) { @@ -1912,7 +1886,7 @@ FxI32 src_stride, void *src_data) } else { - float *buf = (float*)malloc(src_width*(src_height + (viewport_offset))*sizeof(float)); + float *buf = (float*)malloc(src_width*(src_height + (g_viewport_offset))*sizeof(float)); if (src_format != GR_LFBWRITEMODE_ZA16) WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer write format:%x", src_format); @@ -1924,14 +1898,14 @@ FxI32 src_stride, void *src_data) { for (i = 0; i < src_width; i++) { - buf[(j + (viewport_offset))*src_width + i] = + buf[(j + (g_viewport_offset))*src_width + i] = (frameBuffer[(src_height - j - 1)*(src_stride / 2) + i] / (65536.0f*(2.0f / zscale))) + 1 - zscale / 2.0f; } } #ifdef VPDEBUG if (dumping) { - unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (viewport_offset))); + unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (g_viewport_offset))); for (i = 0; i < src_width*src_height; i++) buf2[i] = buf[i] * 255.0f; ilTexImage(src_width, src_height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, buf2); @@ -1950,7 +1924,7 @@ FxI32 src_stride, void *src_data) //glDrawBuffer(GL_BACK); glClear(GL_DEPTH_BUFFER_BIT); glDepthMask(1); - //glDrawPixels(src_width, src_height+(viewport_offset), GL_DEPTH_COMPONENT, GL_FLOAT, buf); + //glDrawPixels(src_width, src_height+(g_viewport_offset), GL_DEPTH_COMPONENT, GL_FLOAT, buf); free(buf); } @@ -1966,16 +1940,6 @@ grQueryResolutionsExt(int32_t * Size) { WriteTrace(TraceGlitch, TraceDebug, "-"); return 0; - } - -FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32* width, FxU32* height) -{ - WriteTrace(TraceGlitch, TraceDebug, "-"); - return 0; - /* - g_FullScreenResolutions.getResolution(config.res, width, height); - return config.res; - */ } FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key) @@ -1983,7 +1947,7 @@ FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key) return 0; } -FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32 vram, FxBool fbo, FxBool aniso) +void grConfigWrapperExt(FxI32 vram, FxBool fbo, FxBool aniso) { WriteTrace(TraceGlitch, TraceDebug, "-"); config.vram_size = vram; @@ -2236,18 +2200,6 @@ GrTexInfo *info) FX_ENTRY void FX_CALL grLoadGammaTable(FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue) { - //TODO? - /*LOG("grLoadGammaTable\r\n"); - if (!fullscreen) - return; - FxU16 aGammaRamp[3][256]; - for (int i = 0; i < 256; i++) - { - aGammaRamp[0][i] = (FxU16)((red[i] << 8) & 0xFFFF); - aGammaRamp[1][i] = (FxU16)((green[i] << 8) & 0xFFFF); - aGammaRamp[2][i] = (FxU16)((blue[i] << 8) & 0xFFFF); - } - CorrectGamma(aGammaRamp);*/ } FX_ENTRY void FX_CALL diff --git a/Source/Glitch64/OGLcombiner.cpp b/Source/Glitch64/OGLcombiner.cpp index 59e8cb175..d8e0b49fb 100644 --- a/Source/Glitch64/OGLcombiner.cpp +++ b/Source/Glitch64/OGLcombiner.cpp @@ -1651,7 +1651,7 @@ grChromakeyValue(GrColor_t value) grDisplayGLError("grChromakeyValue"); } -static void setPattern() +void setPattern() { int i; GLubyte stip[32 * 4]; @@ -1690,15 +1690,6 @@ static void setPattern() grDisplayGLError("setPattern"); } -FX_ENTRY void FX_CALL -grStipplePattern( -GrStipplePattern_t stipple) -{ - WriteTrace(TraceResolution, TraceDebug, "value: %x", stipple); - srand(stipple); - setPattern(); -} - FX_ENTRY void FX_CALL grStippleMode(GrStippleMode_t mode) { diff --git a/Source/Glitch64/OGLgeometry.cpp b/Source/Glitch64/OGLgeometry.cpp index 75bfc35e3..dc7b8c8a8 100644 --- a/Source/Glitch64/OGLgeometry.cpp +++ b/Source/Glitch64/OGLgeometry.cpp @@ -276,7 +276,7 @@ void FindBestDepthBias() glVertex3fv(vertices[3]); glEnd(); - glReadPixels(x + 2, 2 + viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); + glReadPixels(x + 2, 2 + g_viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); z -= 0.75f + 8e-6f; if (z < 0.0f) z = -z; if (z > 0.01f) continue; @@ -354,7 +354,7 @@ grDrawTriangle(const void *a, const void *b, const void *c) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -467,7 +467,7 @@ grDrawPoint(const void *pt) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -536,7 +536,7 @@ grDrawLine(const void *a, const void *b) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -612,7 +612,7 @@ grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2) if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } @@ -684,7 +684,7 @@ grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 strid if (nvidia_viewport_hack && !render_to_texture) { - glViewport(0, viewport_offset, viewport_width, viewport_height); + glViewport(0, g_viewport_offset, viewport_width, viewport_height); nvidia_viewport_hack = 0; } diff --git a/Source/Glitch64/OGLglitchmain.cpp b/Source/Glitch64/OGLglitchmain.cpp index 239b8be8a..283de0c84 100644 --- a/Source/Glitch64/OGLglitchmain.cpp +++ b/Source/Glitch64/OGLglitchmain.cpp @@ -2,7 +2,6 @@ #ifdef _WIN32 #include -#include #else #include #include @@ -29,188 +28,7 @@ */ #include -struct ResolutionInfo -{ - unsigned int dwW, dwH, dwF; - - ResolutionInfo() : dwW(0), dwH(0), dwF(0) {} - - ResolutionInfo(unsigned int _w, unsigned int _h, unsigned int _f) : dwW(_w), dwH(_h), dwF(_f) {} - - bool operator == (const ResolutionInfo & _other) const - { - if (dwW != _other.dwW) - return false; - if (dwH != _other.dwH) - return false; - if (dwF != _other.dwF) - return false; - return true; - } - - bool operator != (const ResolutionInfo & _other) const - { - return !(operator==(_other)); - } - - void toString(char * _str) const - { - if (dwF > 0) - sprintf(_str, "%ix%i 32bpp %iHz", dwW, dwH, dwF); - else - sprintf(_str, "%ix%i 32bpp", dwW, dwH); - } -}; - -class FullScreenResolutions -{ -public: - FullScreenResolutions() : dwNumResolutions(0), aResolutions(0), aResolutionsStr(0) {} - ~FullScreenResolutions(); - - void getResolution(FxU32 _idx, FxU32 * _width, FxU32 * _height, FxU32 * _frequency = 0) - { - WriteTrace(TraceResolution, TraceDebug, "_idx: %d", _idx); - if (dwNumResolutions == 0) - { - init(); - } - if (_idx >= dwNumResolutions) - { - WriteTrace(TraceGlitch, TraceError, "NumResolutions = %d", dwNumResolutions); - _idx = 0; - } - *_width = (FxU32)aResolutions[_idx].dwW; - *_height = (FxU32)aResolutions[_idx].dwH; - if (_frequency != 0) - { - *_frequency = (FxU32)aResolutions[_idx].dwF; - } - } - - int getCurrentResolutions(void) - { - if (dwNumResolutions == 0) - { - init(); - } - return currentResolutions; - } - - char ** getResolutionsList(int32_t * Size) - { - if (dwNumResolutions == 0) - { - init(); - } - *Size = (int32_t)dwNumResolutions; - return aResolutionsStr; - } - - bool changeDisplaySettings(FxU32 _resolution); - -private: - void init(); - unsigned int dwNumResolutions; - ResolutionInfo * aResolutions; - char ** aResolutionsStr; - int currentResolutions; -}; - -FullScreenResolutions::~FullScreenResolutions() -{ - for (unsigned int i = 0; i < dwNumResolutions; i++) - { - delete[] aResolutionsStr[i]; - aResolutionsStr[i] = NULL; - } - if (aResolutionsStr) - { - delete[] aResolutionsStr; - aResolutionsStr = NULL; - } - if (aResolutions) - { - delete[] aResolutions; - aResolutions = NULL; - } -} - -void FullScreenResolutions::init() -{ - WriteTrace(TraceGlitch, TraceDebug, "executing"); -#ifdef _WIN32 - currentResolutions = -1; - DEVMODE enumMode , currentMode; - int iModeNum = 0; - memset(&enumMode, 0, sizeof(DEVMODE)); - - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, ¤tMode); - - ResolutionInfo prevInfo; - while (EnumDisplaySettings(NULL, iModeNum++, &enumMode) != 0) - { - ResolutionInfo curInfo(enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency); - if (enumMode.dmBitsPerPel == 32 && curInfo != prevInfo) - { - dwNumResolutions++; - prevInfo = curInfo; - } - } - - aResolutions = new ResolutionInfo[dwNumResolutions]; - aResolutionsStr = new char*[dwNumResolutions]; - iModeNum = 0; - int current = 0; - char smode[256]; - memset(&enumMode, 0, sizeof(DEVMODE)); - memset(&prevInfo, 0, sizeof(ResolutionInfo)); - while (EnumDisplaySettings(NULL, iModeNum++, &enumMode) != 0) - { - ResolutionInfo curInfo(enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency); - if (enumMode.dmBitsPerPel == 32 && curInfo != prevInfo) - { - if (enumMode.dmPelsHeight == currentMode.dmPelsHeight && enumMode.dmPelsWidth == currentMode.dmPelsWidth) - { - currentResolutions = current; - } - aResolutions[current] = curInfo; - curInfo.toString(smode); - aResolutionsStr[current] = new char[strlen(smode) + 1]; - strcpy(aResolutionsStr[current], smode); - prevInfo = curInfo; - current++; - } - } -#endif -} - -bool FullScreenResolutions::changeDisplaySettings(FxU32 _resolution) -{ -#ifdef _WIN32 - FxU32 width, height, frequency; - getResolution(_resolution, &width, &height, &frequency); - ResolutionInfo info(width, height, frequency); - DEVMODE enumMode; - int iModeNum = 0; - memset(&enumMode, 0, sizeof(DEVMODE)); - while (EnumDisplaySettings(NULL, iModeNum++, &enumMode) != 0) - { - ResolutionInfo curInfo(enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency); - if (enumMode.dmBitsPerPel == 32 && curInfo == info) { - bool bRes = ChangeDisplaySettings(&enumMode, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL; - WriteTrace(TraceGlitch, TraceDebug, "width=%d, height=%d, freq=%d %s\r\n", enumMode.dmPelsWidth, enumMode.dmPelsHeight, enumMode.dmDisplayFrequency, bRes ? "Success" : "Failed"); - return bRes; - } - } - return false; -#else // _WIN32 - return false; -#endif // _WIN32 -} - -FullScreenResolutions g_FullScreenResolutions; -wrapper_config config = { 0, 0, 0, 0 }; +wrapper_config config = { 0, 0, 0 }; int screen_width, screen_height; static inline void opt_glCopyTexImage2D(GLenum target, @@ -233,8 +51,8 @@ static inline void opt_glCopyTexImage2D(GLenum target, width = screen_width - x; //printf("resizing w --> %d\n", width); } - if (y + height >= screen_height + viewport_offset) { - height = screen_height + viewport_offset - y; + if (y + height >= screen_height + g_viewport_offset) { + height = screen_height + g_viewport_offset - y; //printf("resizing h --> %d\n", height); } glCopyTexSubImage2D(target, level, 0, 0, x, y, width, height); @@ -474,7 +292,7 @@ int default_texture; // the infamous "32*1024*1024" is now configurable int current_texture; int depth_texture, color_texture; int glsl_support = 1; -int viewport_width, viewport_height, viewport_offset = 0, nvidia_viewport_hack = 0; +int viewport_width, viewport_height, g_viewport_offset = 0, nvidia_viewport_hack = 0; int save_w, save_h; int lfb_color_fmt; float invtex[2]; @@ -485,13 +303,6 @@ int UMAmode = 0; //support for VSA-100 UMA mode; static HDC hDC = NULL; static HGLRC hGLRC = NULL; static HWND hToolBar = NULL; -static HWND hwnd_win = NULL; -static unsigned long windowedExStyle, windowedStyle; -#endif // _WIN32 -static unsigned long fullscreen; -#ifdef _WIN32 -static RECT windowedRect; -static HMENU windowedMenu; #endif // _WIN32 static int savedWidtho, savedHeighto; @@ -571,11 +382,11 @@ grClipWindow(FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy) if (int(miny) < 0) miny = 0; if (maxx < minx) maxx = minx; if (maxy < miny) maxy = miny; - glScissor(minx, miny + viewport_offset, maxx - minx, maxy - miny); + glScissor(minx, miny + g_viewport_offset, maxx - minx, maxy - miny); //printf("gl scissor %d %d %d %d\n", minx, miny, maxx, maxy); } else { - glScissor(minx, (viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); + glScissor(minx, (g_viewport_offset)+g_height - maxy, maxx - minx, maxy - miny); } glEnable(GL_SCISSOR_TEST); grDisplayGLError("grClipWindow"); @@ -595,12 +406,6 @@ grGlideInit(void) WriteTrace(TraceGlitch, TraceDebug, "-"); } -FX_ENTRY void FX_CALL -grSstSelect(int which_sst) -{ - WriteTrace(TraceGlitch, TraceDebug, "which_sst = %d", which_sst); -} - int isExtensionSupported(const char *extension) { const GLubyte *extensions = NULL; @@ -667,17 +472,14 @@ int isWglExtensionSupported(const char *extension) FX_ENTRY GrContext_t FX_CALL grSstWinOpenExt( -HWND hWnd, -GrScreenResolution_t screen_resolution, -GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, GrPixelFormat_t /*pixelformat*/, int nColBuffers, int nAuxBuffers) { - WriteTrace(TraceGlitch, TraceDebug, "hWnd: %d, screen_resolution: %d, refresh_rate: %d, color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers); - return grSstWinOpen(hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers); + WriteTrace(TraceGlitch, TraceDebug, "color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", color_format, origin_location, nColBuffers, nAuxBuffers); + return grSstWinOpen(color_format, origin_location, nColBuffers, nAuxBuffers); } #ifdef _WIN32 @@ -685,13 +487,11 @@ int nAuxBuffers) # ifndef ATTACH_PARENT_PROCESS # define ATTACH_PARENT_PROCESS ((FxU32)-1) # endif +extern HWND g_hwnd_win; #endif FX_ENTRY GrContext_t FX_CALL grSstWinOpen( -HWND hWnd, -GrScreenResolution_t screen_resolution, -GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, @@ -724,184 +524,16 @@ int nAuxBuffers) fputs("ERROR: No GLX yet to start GL on [Free]BSD, Linux etc.\n", stderr); #endif // _WIN32 - WriteTrace(TraceGlitch, TraceDebug, "hWnd: %d, screen_resolution: %d, refresh_rate: %d, color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", hWnd, screen_resolution&~0x80000000, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers); + WriteTrace(TraceGlitch, TraceDebug, "color_format: %d, origin_location: %d, nColBuffers: %d, nAuxBuffers: %d", color_format, origin_location, nColBuffers, nAuxBuffers); #ifdef _WIN32 - if ((HWND)hWnd == NULL) hWnd = GetActiveWindow(); - hwnd_win = (HWND)hWnd; -#endif // _WIN32 - g_width = g_height = 0; - if (screen_resolution & 0x80000000) - { - switch (screen_resolution & ~0x80000000) - { - case GR_RESOLUTION_320x200: - g_width = 320; - g_height = 200; - break; - case GR_RESOLUTION_320x240: - g_width = 320; - g_height = 240; - break; - case GR_RESOLUTION_400x256: - g_width = 400; - g_height = 256; - break; - case GR_RESOLUTION_512x384: - g_width = 512; - g_height = 384; - break; - case GR_RESOLUTION_640x200: - g_width = 640; - g_height = 200; - break; - case GR_RESOLUTION_640x350: - g_width = 640; - g_height = 350; - break; - case GR_RESOLUTION_640x400: - g_width = 640; - g_height = 400; - break; - case GR_RESOLUTION_640x480: - g_width = 640; - g_height = 480; - break; - case GR_RESOLUTION_800x600: - g_width = 800; - g_height = 600; - break; - case GR_RESOLUTION_960x720: - g_width = 960; - g_height = 720; - break; - case GR_RESOLUTION_856x480: - g_width = 856; - g_height = 480; - break; - case GR_RESOLUTION_512x256: - g_width = 512; - g_height = 256; - break; - case GR_RESOLUTION_1024x768: - g_width = 1024; - g_height = 768; - break; - case GR_RESOLUTION_1280x1024: - g_width = 1280; - g_height = 1024; - break; - case GR_RESOLUTION_1600x1200: - g_width = 1600; - g_height = 1200; - break; - case GR_RESOLUTION_400x300: - g_width = 400; - g_height = 300; - break; - case GR_RESOLUTION_1152x864: - g_width = 1152; - g_height = 864; - break; - case GR_RESOLUTION_1280x960: - g_width = 1280; - g_height = 960; - break; - case GR_RESOLUTION_1600x1024: - g_width = 1600; - g_height = 1024; - break; - case GR_RESOLUTION_1792x1344: - g_width = 1792; - g_height = 1344; - break; - case GR_RESOLUTION_1856x1392: - g_width = 1856; - g_height = 1392; - break; - case GR_RESOLUTION_1920x1440: - g_width = 1920; - g_height = 1440; - break; - case GR_RESOLUTION_2048x1536: - g_width = 2048; - g_height = 1536; - break; - case GR_RESOLUTION_2048x2048: - g_width = 2048; - g_height = 2048; - break; - default: - WriteTrace(TraceGlitch, TraceWarning, "unknown SstWinOpen resolution : %x", screen_resolution); - } - } - -#ifdef _WIN32 - if (screen_resolution & 0x80000000) - { - RECT clientRect, toolbarRect, statusbarRect; - ZeroMemory(&windowedRect, sizeof(RECT)); - ZeroMemory(&clientRect, sizeof(RECT)); - ZeroMemory(&toolbarRect, sizeof(RECT)); - ZeroMemory(&statusbarRect, sizeof(RECT)); - HWND hToolBar = FindWindowEx(hwnd_win, NULL, REBARCLASSNAME, NULL); - HWND hStatusBar = FindWindowEx(hwnd_win, NULL, STATUSCLASSNAME, NULL); - if (hStatusBar == NULL) hStatusBar = FindWindowEx(hwnd_win, NULL, "msctls_statusbar32", NULL); // 1964 - if (hToolBar != NULL) GetWindowRect(hToolBar, &toolbarRect); - if (hStatusBar != NULL) GetWindowRect(hStatusBar, &statusbarRect); - viewport_offset = statusbarRect.bottom - statusbarRect.top; - GetWindowRect(hwnd_win, &windowedRect); - GetClientRect(hwnd_win, &clientRect); - windowedRect.right += (g_width - (clientRect.right - clientRect.left)); - windowedRect.bottom += (g_height + (toolbarRect.bottom - toolbarRect.top) + (statusbarRect.bottom - statusbarRect.top) - (clientRect.bottom - clientRect.top)); - SetWindowPos(hwnd_win, NULL, 0, 0, windowedRect.right - windowedRect.left, - windowedRect.bottom - windowedRect.top, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOMOVE); - - TMU_SIZE = (config.vram_size - g_width * g_height * 4 * 3) / 2; // XXX - what about windows desktop usage? - - fullscreen = 0; - } - else - { - { - FxU32 _width, _height; - g_FullScreenResolutions.getResolution(screen_resolution, &_width, &_height); - g_width = _width; - g_height = _height; - } - ZeroMemory(&windowedRect, sizeof(RECT)); - GetWindowRect(hwnd_win, &windowedRect); - - windowedExStyle = GetWindowLong(hwnd_win, GWL_EXSTYLE); - windowedStyle = GetWindowLong(hwnd_win, GWL_STYLE); - - // primary monitor only - if (!g_FullScreenResolutions.changeDisplaySettings(screen_resolution)) - { - WriteTrace(TraceGlitch, TraceWarning, "can't change to fullscreen mode"); - } - - windowedMenu = GetMenu(hwnd_win); - if (windowedMenu) SetMenu(hwnd_win, NULL); - - HWND hStatusBar = FindWindowEx(hwnd_win, NULL, "msctls_statusbar32", NULL); // 1964 - if (hStatusBar) ShowWindow(hStatusBar, SW_HIDE); - - SetWindowLong(hwnd_win, GWL_STYLE, 0); - SetWindowLong(hwnd_win, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_TOPMOST); - SetWindowPos(hwnd_win, NULL, 0, 0, g_width, g_height, SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW); - - viewport_offset = 0; - fullscreen = 1; - } - TMU_SIZE = (config.vram_size - g_width * g_height * 4 * 3) / 2; // save screen resolution for hwfbe, after resolution enumeration screen_width = g_width; screen_height = g_height; - if ((hDC = GetDC(hwnd_win)) == NULL) + if ((hDC = GetDC(g_hwnd_win)) == NULL) { WriteTrace(TraceGlitch, TraceWarning, "GetDC on main window failed"); return FXFALSE; @@ -1134,12 +766,12 @@ int nAuxBuffers) #endif #ifndef ANDROID - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); viewport_width = g_width; viewport_height = g_height; nvidia_viewport_hack = 1; #else - glViewport(0, viewport_offset, width, height); + glViewport(0, g_viewport_offset, width, height); viewport_width = width; viewport_height = height; #endif // _WIN32 @@ -1271,18 +903,7 @@ grSstWinClose(GrContext_t context) wglDeleteContext(hGLRC); hGLRC = NULL; } - if (fullscreen) - { - ChangeDisplaySettings(NULL, 0); - SetWindowPos(hwnd_win, NULL, - windowedRect.left, windowedRect.top, - 0, 0, - SWP_NOZORDER | SWP_NOSIZE); - SetWindowLong(hwnd_win, GWL_STYLE, windowedStyle); - SetWindowLong(hwnd_win, GWL_EXSTYLE, windowedExStyle); - if (windowedMenu) SetMenu(hwnd_win, windowedMenu); - fullscreen = 0; - } + ExitFullScreen(); #else //SDL_QuitSubSystem(SDL_INIT_VIDEO); //sleep(2); @@ -1348,26 +969,26 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu, if (save_w) { if (tw > save_w && th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, - 0, viewport_offset + save_h, tw, th - save_h); + 0, g_viewport_offset + save_h, tw, th - save_h); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, save_w, 0, - save_w, viewport_offset, tw - save_w, save_h); + save_w, g_viewport_offset, tw - save_w, save_h); save_w = tw; save_h = th; } else if (tw > save_w) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, save_w, 0, - save_w, viewport_offset, tw - save_w, save_h); + save_w, g_viewport_offset, tw - save_w, save_h); save_w = tw; } else if (th > save_h) { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, save_h, - 0, viewport_offset + save_h, save_w, th - save_h); + 0, g_viewport_offset + save_h, save_w, th - save_h); save_h = th; } } else { glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, - 0, viewport_offset, tw, th); + 0, g_viewport_offset, tw, th); save_w = tw; save_h = th; } @@ -1416,12 +1037,12 @@ FX_ENTRY void FX_CALL grTextureBufferExt(GrChipID_t tmu, //printf("viewport %dx%d\n", width, height); if (g_height > screen_height) { - glViewport(0, viewport_offset + screen_height - g_height, g_width, g_height); + glViewport(0, g_viewport_offset + screen_height - g_height, g_width, g_height); } else - glViewport(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, g_height); - glScissor(0, viewport_offset, g_width, g_height); + glScissor(0, g_viewport_offset, g_width, g_height); grDisplayGLError("grTextureBufferExt :: A"); } @@ -1689,7 +1310,7 @@ grGet(FxU32 pname, FxU32 plength, FxI32 *params) if (plength < 4 || params == NULL) return 0; if (!nbTextureUnits) { - grSstWinOpen((unsigned long)NULL, GR_RESOLUTION_640x480 | 0x80000000, 0, GR_COLORFORMAT_ARGB, GR_ORIGIN_UPPER_LEFT, 2, 1); + grSstWinOpen(GR_COLORFORMAT_ARGB, GR_ORIGIN_UPPER_LEFT, 2, 1); grSstWinClose(0); } #ifdef VOODOO1 @@ -1935,7 +1556,7 @@ void updateTexture() //glDeleteTextures( 1, &pBufferAddress ); glBindTexture(GL_TEXTURE_2D, pBufferAddress); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, - 0, viewport_offset, g_width, g_height, 0); + 0, g_viewport_offset, g_width, g_height, 0); glBindTexture(GL_TEXTURE_2D, default_texture); glPopAttrib(); @@ -1962,7 +1583,7 @@ FX_ENTRY void FX_CALL grFramebufferCopyExt(int /*x*/, int /*y*/, int /*w*/, int glReadBuffer(current_buffer); glBindTexture(GL_TEXTURE_2D, depth_texture); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, - 0, viewport_offset, tw, th, 0); + 0, g_viewport_offset, tw, th, 0); glBindTexture(GL_TEXTURE_2D, default_texture); grDisplayGLError("grFramebufferCopyExt :: A"); return; @@ -2027,8 +1648,8 @@ grRenderBuffer(GrBuffer_t buffer) } curBufferAddr = 0; - glViewport(0, viewport_offset, g_width, viewport_height); - glScissor(0, viewport_offset, g_width, g_height); + glViewport(0, g_viewport_offset, g_width, viewport_height); + glScissor(0, g_viewport_offset, g_width, g_height); #ifdef SAVE_CBUFFER if (!use_fbo && render_to_texture == 2) { @@ -2235,7 +1856,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 4; info->writeMode = GR_LFBWRITEMODE_888; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_BGRA, GL_UNSIGNED_BYTE, frameBuffer); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_BGRA, GL_UNSIGNED_BYTE, frameBuffer); } else { buf = (unsigned char*)malloc(g_width*g_height * 4); @@ -2244,7 +1865,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 2; info->writeMode = GR_LFBWRITEMODE_565; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); for (j = 0; j < g_height; j++) { @@ -2265,7 +1886,7 @@ GrLfbInfo_t *info) info->strideInBytes = g_width * 2; info->writeMode = GR_LFBWRITEMODE_ZA16; info->origin = origin; - glReadPixels(0, viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); + glReadPixels(0, g_viewport_offset, g_width, g_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); } } @@ -2315,7 +1936,7 @@ FxU32 dst_stride, void *dst_data) { buf = (unsigned char*)malloc(src_width*src_height * 4); - glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); + glReadPixels(src_x, (g_viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, buf); for (j = 0; j < src_height; j++) { @@ -2333,7 +1954,7 @@ FxU32 dst_stride, void *dst_data) { buf = (unsigned char*)malloc(src_width*src_height * 2); - glReadPixels(src_x, (viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); + glReadPixels(src_x, (g_viewport_offset)+g_height - src_y - src_height, src_width, src_height, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, depthBuffer); for (j = 0; j < src_height; j++) { @@ -2461,7 +2082,7 @@ FxI32 src_stride, void *src_data) } else { - float *buf = (float*)malloc(src_width*(src_height + (viewport_offset))*sizeof(float)); + float *buf = (float*)malloc(src_width*(src_height + (g_viewport_offset))*sizeof(float)); if (src_format != GR_LFBWRITEMODE_ZA16) WriteTrace(TraceGlitch, TraceWarning, "unknown depth buffer write format:%x", src_format); @@ -2473,14 +2094,14 @@ FxI32 src_stride, void *src_data) { for (i = 0; i < src_width; i++) { - buf[(j + (viewport_offset))*src_width + i] = + buf[(j + (g_viewport_offset))*src_width + i] = (frameBuffer[(src_height - j - 1)*(src_stride / 2) + i] / (65536.0f*(2.0f / zscale))) + 1 - zscale / 2.0f; } } #ifdef VPDEBUG if (dumping) { - unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (viewport_offset))); + unsigned char * buf2 = (unsigned char *)malloc(src_width*(src_height + (g_viewport_offset))); for (i = 0; i < src_width*src_height; i++) buf2[i] = buf[i] * 255.0f; ilTexImage(src_width, src_height, 1, 1, IL_LUMINANCE, IL_UNSIGNED_BYTE, buf2); @@ -2499,7 +2120,7 @@ FxI32 src_stride, void *src_data) glDrawBuffer(GL_BACK); glClear(GL_DEPTH_BUFFER_BIT); glDepthMask(1); - glDrawPixels(src_width, src_height + (viewport_offset), GL_DEPTH_COMPONENT, GL_FLOAT, buf); + glDrawPixels(src_width, src_height + (g_viewport_offset), GL_DEPTH_COMPONENT, GL_FLOAT, buf); free(buf); } @@ -2510,27 +2131,9 @@ FxI32 src_stride, void *src_data) return FXTRUE; } -int GetCurrentResIndex(void) -{ - return g_FullScreenResolutions.getCurrentResolutions(); -} /* wrapper-specific glide extensions */ -FX_ENTRY char ** FX_CALL -grQueryResolutionsExt(int32_t * Size) -{ - WriteTrace(TraceGlitch, TraceDebug, "-"); - return g_FullScreenResolutions.getResolutionsList(Size); -} - -FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32* width, FxU32* height) -{ - WriteTrace(TraceGlitch, TraceDebug, "-"); - g_FullScreenResolutions.getResolution(config.res, width, height); - return config.res; -} - FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key) { #ifdef _WIN32 @@ -2540,10 +2143,9 @@ FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key) #endif } -FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32 resolution, FxI32 vram, FxBool fbo, FxBool aniso) +void grConfigWrapperExt(FxI32 vram, FxBool fbo, FxBool aniso) { WriteTrace(TraceGlitch, TraceDebug, "-"); - config.res = resolution; config.vram_size = vram; config.fbo = fbo; config.anisofilter = aniso; @@ -2819,8 +2421,6 @@ FX_ENTRY void FX_CALL grLoadGammaTable(FxU32 /*nentries*/, FxU32 *red, FxU32 *green, FxU32 *blue) { WriteTrace(TraceGlitch, TraceDebug, "-"); - if (!fullscreen) - return; FxU16 aGammaRamp[3][256]; for (int i = 0; i < 256; i++) { @@ -2829,7 +2429,6 @@ grLoadGammaTable(FxU32 /*nentries*/, FxU32 *red, FxU32 *green, FxU32 *blue) aGammaRamp[2][i] = (FxU16)((blue[i] << 8) & 0xFFFF); } CorrectGamma(aGammaRamp); - pjutil::Sleep(1000); } FX_ENTRY void FX_CALL @@ -2862,8 +2461,7 @@ FX_ENTRY void FX_CALL guGammaCorrectionRGB(FxFloat gammaR, FxFloat gammaG, FxFloat gammaB) { WriteTrace(TraceGlitch, TraceDebug, "-"); - if (!fullscreen) - return; + FxU16 aGammaRamp[3][256]; for (int i = 0; i < 256; i++) { diff --git a/Source/Glitch64/glitchmain.h b/Source/Glitch64/glitchmain.h index d4aa20977..b95d993ed 100644 --- a/Source/Glitch64/glitchmain.h +++ b/Source/Glitch64/glitchmain.h @@ -17,9 +17,6 @@ extern int dumping; typedef struct _wrapper_config { -#ifndef ANDROID - int res; -#endif int fbo; int anisofilter; int vram_size; @@ -158,7 +155,7 @@ extern int fog_coord_support; //extern int pbuffer_support; extern int glsl_support; extern unsigned int pBufferAddress; -extern int viewport_width, viewport_height, viewport_offset, nvidia_viewport_hack; +extern int viewport_width, viewport_height, g_viewport_offset, nvidia_viewport_hack; extern int UMAmode; void grChromaRangeExt(GrColor_t color0, GrColor_t color1, FxU32 mode); @@ -172,19 +169,13 @@ void compile_shader(); void set_lambda(); void set_copy_shader(); void disable_textureSizes(); +void ExitFullScreen(); // config functions -FX_ENTRY void FX_CALL grConfigWrapperExt( -#ifndef ANDROID - FxI32, /* resolution parameter not supported on Android build */ -#endif - FxI32, - FxBool, - FxBool -); -FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32*, FxU32*); -FX_ENTRY char ** FX_CALL grQueryResolutionsExt(int32_t*); +void grConfigWrapperExt(FxI32,FxBool,FxBool); +uint32_t grWrapperFullScreenResolutionExt(uint32_t * width, uint32_t * height); +char ** grQueryResolutionsExt(int32_t*); FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key); FX_ENTRY void FX_CALL grGetGammaTableExt(FxU32, FxU32*, FxU32*, FxU32*); diff --git a/Source/Glitch64/inc/glide.h b/Source/Glitch64/inc/glide.h index 138d79e80..5ec56a671 100644 --- a/Source/Glitch64/inc/glide.h +++ b/Source/Glitch64/inc/glide.h @@ -623,13 +623,7 @@ grFinish(void); FX_ENTRY void FX_CALL grFlush(void); -FX_ENTRY GrContext_t FX_CALL grSstWinOpen( -#ifdef ANDROID - GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers -#else - HWND hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers -#endif -); +FX_ENTRY GrContext_t FX_CALL grSstWinOpen(GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers); FX_ENTRY FxBool FX_CALL grSstWinClose( GrContext_t context ); diff --git a/Source/Project64-core/Multilanguage.h b/Source/Project64-core/Multilanguage.h index b178e20ec..5d7066c2c 100644 --- a/Source/Project64-core/Multilanguage.h +++ b/Source/Project64-core/Multilanguage.h @@ -589,6 +589,9 @@ enum LanguageStringID ANDROID_MENU_DEBUGGINGOPTIONS = 3111, ANDROID_MENU_RESETFUNCTIONTIMES = 3112, ANDROID_MENU_DUMPFUNCTIONTIMES = 3113, + + //Video plugin + ANDROID_VIDEO_NATIVE_RES = 3200, }; #include "Multilanguage/LanguageClass.h" diff --git a/Source/Project64-core/Multilanguage/LanguageClass.cpp b/Source/Project64-core/Multilanguage/LanguageClass.cpp index b2a4a2d91..57f42f880 100644 --- a/Source/Project64-core/Multilanguage/LanguageClass.cpp +++ b/Source/Project64-core/Multilanguage/LanguageClass.cpp @@ -557,6 +557,9 @@ void CLanguage::LoadDefaultStrings(void) DEF_STR(ANDROID_MENU_DEBUGGINGOPTIONS, "Debugging Options"); DEF_STR(ANDROID_MENU_RESETFUNCTIONTIMES, "Reset Function Times"); DEF_STR(ANDROID_MENU_DUMPFUNCTIONTIMES, "Dump Function Times"); + + //Video plugin + DEF_STR(ANDROID_VIDEO_NATIVE_RES, "Native"); } CLanguage::CLanguage() : diff --git a/changes.txt b/changes.txt new file mode 100644 index 000000000..9bb048312 --- /dev/null +++ b/changes.txt @@ -0,0 +1,2 @@ +Android Release 9: +- Add ability to change screen res \ No newline at end of file