From e261761d5ae23ee99158eebcd7dcb54f9669f850 Mon Sep 17 00:00:00 2001 From: Scorr Date: Wed, 13 Feb 2019 03:52:25 +0100 Subject: [PATCH 1/2] limit update to rom framerate --- .../RetroUnity/Examples/Scenes/Main.unity | 250 ++++++++++-------- .../Plugins/RetroUnity/Scripts/GameManager.cs | 27 +- ProjectSettings/ProjectSettings.asset | 247 +++++++++-------- ProjectSettings/QualitySettings.asset | 11 +- ProjectSettings/TimeManager.asset | 1 + 5 files changed, 282 insertions(+), 254 deletions(-) diff --git a/Assets/Plugins/RetroUnity/Examples/Scenes/Main.unity b/Assets/Plugins/RetroUnity/Examples/Scenes/Main.unity index 5731ea4..4cd0c83 100644 --- a/Assets/Plugins/RetroUnity/Examples/Scenes/Main.unity +++ b/Assets/Plugins/RetroUnity/Examples/Scenes/Main.unity @@ -13,7 +13,7 @@ OcclusionCullingSettings: --- !u!104 &2 RenderSettings: m_ObjectHideFlags: 0 - serializedVersion: 8 + serializedVersion: 9 m_Fog: 0 m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} m_FogMode: 3 @@ -39,6 +39,7 @@ RenderSettings: m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: m_ObjectHideFlags: 0 @@ -49,16 +50,14 @@ LightmapSettings: m_BounceScale: 1 m_IndirectOutputScale: 1 m_AlbedoBoost: 1 - m_TemporalCoherenceThreshold: 1 m_EnvironmentLightingMode: 0 m_EnableBakedLightmaps: 1 m_EnableRealtimeLightmaps: 1 m_LightmapEditorSettings: - serializedVersion: 9 + serializedVersion: 10 m_Resolution: 2 m_BakeResolution: 40 - m_TextureWidth: 1024 - m_TextureHeight: 1024 + m_AtlasSize: 1024 m_AO: 0 m_AOMaxDistance: 1 m_CompAOExponent: 0 @@ -77,15 +76,18 @@ LightmapSettings: m_PVRDirectSampleCount: 32 m_PVRSampleCount: 500 m_PVRBounces: 2 - m_PVRFiltering: 0 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 m_PVRFilteringMode: 1 m_PVRCulling: 1 m_PVRFilteringGaussRadiusDirect: 1 m_PVRFilteringGaussRadiusIndirect: 5 m_PVRFilteringGaussRadiusAO: 2 - m_PVRFilteringAtrousColorSigma: 1 - m_PVRFilteringAtrousNormalSigma: 1 - m_PVRFilteringAtrousPositionSigma: 1 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 m_LightingDataAsset: {fileID: 0} m_UseShadowmask: 0 --- !u!196 &4 @@ -107,13 +109,16 @@ NavMeshSettings: manualTileSize: 0 tileSize: 256 accuratePlacement: 0 + debug: + m_Flags: 0 m_NavMeshData: {fileID: 0} --- !u!1 &536390079 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 536390081} - component: {fileID: 536390080} @@ -127,8 +132,9 @@ GameObject: --- !u!108 &536390080 Light: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 536390079} m_Enabled: 1 serializedVersion: 8 @@ -154,22 +160,9 @@ Light: serializedVersion: 2 m_Bits: 4294967295 m_Lightmapping: 4 + m_LightShadowCasterMode: 0 m_AreaSize: {x: 1, y: 1} m_BounceIntensity: 1 - m_FalloffTable: - m_Table[0]: 0 - m_Table[1]: 0 - m_Table[2]: 0 - m_Table[3]: 0 - m_Table[4]: 0 - m_Table[5]: 0 - m_Table[6]: 0 - m_Table[7]: 0 - m_Table[8]: 0 - m_Table[9]: 0 - m_Table[10]: 0 - m_Table[11]: 0 - m_Table[12]: 0 m_ColorTemperature: 6570 m_UseColorTemperature: 0 m_ShadowRadius: 0 @@ -177,8 +170,9 @@ Light: --- !u!4 &536390081 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 536390079} m_LocalRotation: {x: 0.40821794, y: -0.23456973, z: 0.109381676, w: 0.87542605} m_LocalPosition: {x: 0, y: 3, z: 0} @@ -189,14 +183,17 @@ Transform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &589599783 stripped Transform: - m_PrefabParentObject: {fileID: 400000, guid: ad6611d95a9ac7d45bc4da137220780c, type: 3} - m_PrefabInternal: {fileID: 793110061} + m_CorrespondingSourceObject: {fileID: 400000, guid: ad6611d95a9ac7d45bc4da137220780c, + type: 3} + m_PrefabInstance: {fileID: 793110061} + m_PrefabAsset: {fileID: 0} --- !u!1 &635089073 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 635089077} - component: {fileID: 635089076} @@ -212,15 +209,19 @@ GameObject: --- !u!23 &635089074 MeshRenderer: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 635089073} m_Enabled: 1 m_CastShadows: 1 m_ReceiveShadows: 1 + m_DynamicOccludee: 1 m_MotionVectors: 1 m_LightProbeUsage: 1 m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 m_Materials: - {fileID: 2100000, guid: ea16435dffa3e34408933b59f313504c, type: 2} m_StaticBatchInfo: @@ -233,6 +234,7 @@ MeshRenderer: m_PreserveUVs: 1 m_IgnoreNormalsForChartDetection: 0 m_ImportantGI: 0 + m_StitchLightmapSeams: 0 m_SelectedEditorRenderState: 3 m_MinimumChartSize: 4 m_AutoUVMaxDistance: 0.5 @@ -244,29 +246,31 @@ MeshRenderer: --- !u!64 &635089075 MeshCollider: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 635089073} m_Material: {fileID: 0} m_IsTrigger: 0 m_Enabled: 1 - serializedVersion: 2 + serializedVersion: 3 m_Convex: 0 - m_InflateMesh: 0 - m_SkinWidth: 0.01 + m_CookingOptions: 14 m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!33 &635089076 MeshFilter: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 635089073} m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!4 &635089077 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 635089073} m_LocalRotation: {x: 0, y: 0, z: 1, w: -0.00000016292068} m_LocalPosition: {x: 0, y: 6.2, z: -0.16} @@ -276,7 +280,7 @@ Transform: m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &793110061 -Prefab: +PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: @@ -315,14 +319,14 @@ Prefab: value: 4 objectReference: {fileID: 0} m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: ad6611d95a9ac7d45bc4da137220780c, type: 3} - m_IsPrefabParent: 0 + m_SourcePrefab: {fileID: 100100000, guid: ad6611d95a9ac7d45bc4da137220780c, type: 3} --- !u!1 &794582236 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 794582239} - component: {fileID: 794582237} @@ -337,8 +341,9 @@ GameObject: --- !u!114 &794582237 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 794582236} m_Enabled: 1 m_EditorHideFlags: 0 @@ -348,8 +353,9 @@ MonoBehaviour: --- !u!82 &794582238 AudioSource: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 794582236} m_Enabled: 1 serializedVersion: 4 @@ -375,62 +381,78 @@ AudioSource: rolloffCustomCurve: serializedVersion: 2 m_Curve: - - serializedVersion: 2 + - serializedVersion: 3 time: 0 value: 1 inSlope: 0 outSlope: 0 tangentMode: 0 - - serializedVersion: 2 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 time: 1 value: 0 inSlope: 0 outSlope: 0 tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 panLevelCustomCurve: serializedVersion: 2 m_Curve: - - serializedVersion: 2 + - serializedVersion: 3 time: 0 value: 0 inSlope: 0 outSlope: 0 tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 0 spreadCustomCurve: serializedVersion: 2 m_Curve: - - serializedVersion: 2 + - serializedVersion: 3 time: 0 value: 0 inSlope: 0 outSlope: 0 tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 0 reverbZoneMixCustomCurve: serializedVersion: 2 m_Curve: - - serializedVersion: 2 + - serializedVersion: 3 time: 0 value: 1 inSlope: 0 outSlope: 0 tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 0 --- !u!4 &794582239 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 794582236} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -442,9 +464,10 @@ Transform: --- !u!1 &1042651432 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 1042651434} - component: {fileID: 1042651433} @@ -459,8 +482,9 @@ GameObject: --- !u!114 &1042651433 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1042651432} m_Enabled: 1 m_EditorHideFlags: 0 @@ -470,8 +494,9 @@ MonoBehaviour: --- !u!4 &1042651434 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1042651432} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} @@ -483,81 +508,81 @@ Transform: --- !u!114 &1042651435 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1042651432} m_Enabled: 1 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: 52ea678dff3796c4c92ab162cb5764bd, type: 3} m_Name: m_EditorClassIdentifier: - CoreName: vbam_libretro.dll - RomName: 1695 - Pokemon Fire Red (U)(Independent).gba + CoreName: snes9x_libretro.dll + RomName: Chrono Trigger (USA).sfc Display: {fileID: 635089074} --- !u!1001 &1178825821 -Prefab: +PrefabInstance: m_ObjectHideFlags: 0 serializedVersion: 2 m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalPosition.x value: 0 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalPosition.y value: -12.5 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalPosition.z value: 4 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalRotation.x value: 0.000000115202326 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalRotation.y value: 0.7071068 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalRotation.z value: 0.7071067 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalRotation.w value: -0.00000011520231 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalScale.x value: 10 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalScale.y value: 10 objectReference: {fileID: 0} - - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} + - target: {fileID: 400002, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} propertyPath: m_LocalScale.z value: 10 objectReference: {fileID: 0} m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 2} - m_IsPrefabParent: 0 + m_SourcePrefab: {fileID: 100100000, guid: 29e497487ae706f4a90f81cac1f10ccf, type: 3} --- !u!1 &1702816979 GameObject: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - serializedVersion: 5 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 m_Component: - component: {fileID: 1702816984} - component: {fileID: 1702816983} - - component: {fileID: 1702816982} - component: {fileID: 1702816981} - component: {fileID: 1702816980} - component: {fileID: 1702816985} @@ -571,34 +596,35 @@ GameObject: --- !u!81 &1702816980 AudioListener: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} m_Enabled: 1 --- !u!124 &1702816981 Behaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1702816979} - m_Enabled: 1 ---- !u!92 &1702816982 -Behaviour: - m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} m_Enabled: 1 --- !u!20 &1702816983 Camera: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} m_Enabled: 1 serializedVersion: 2 m_ClearFlags: 2 m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_GateFitMode: 2 + m_FocalLength: 50 m_NormalizedViewPortRect: serializedVersion: 2 x: 0 @@ -620,16 +646,17 @@ Camera: m_TargetEye: 3 m_HDR: 0 m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 m_ForceIntoRT: 0 m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: 0.022 - m_StereoMirrorMode: 0 --- !u!4 &1702816984 Transform: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: -10} @@ -641,10 +668,11 @@ Transform: --- !u!114 &1702816985 MonoBehaviour: m_ObjectHideFlags: 0 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1702816979} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: aaf7309e7e423004696df04cdf3b7a8b, type: 3} m_Name: diff --git a/Assets/Plugins/RetroUnity/Scripts/GameManager.cs b/Assets/Plugins/RetroUnity/Scripts/GameManager.cs index c77058a..0b9b810 100644 --- a/Assets/Plugins/RetroUnity/Scripts/GameManager.cs +++ b/Assets/Plugins/RetroUnity/Scripts/GameManager.cs @@ -9,35 +9,28 @@ public class GameManager : MonoBehaviour { [SerializeField] private string RomName = "Chrono Trigger (USA).sfc"; private LibretroWrapper.Wrapper wrapper; + private float _frameTimer; + public Renderer Display; private void Awake() { - Application.targetFrameRate = 60; LoadRom(Application.streamingAssetsPath + "/" + RomName); } private void Update() { if (wrapper != null) { - wrapper.Update(); + _frameTimer += Time.deltaTime; + float timePerFrame = 1f / (float)wrapper.GetAVInfo().timing.fps; + + while (_frameTimer >= timePerFrame) + { + wrapper.Update(); + _frameTimer -= timePerFrame; + } } if (LibretroWrapper.tex != null) { Display.material.mainTexture = LibretroWrapper.tex; } - - // debug input - //if (Input.GetButton("B")) Debug.Log("B"); - //if (Input.GetButton("Y")) Debug.Log("Y"); - //if (Input.GetButton("SELECT")) Debug.Log("SELECT"); - //if (Input.GetButton("START")) Debug.Log("START"); - //if (Input.GetAxisRaw("DpadX") >= 1.0f) Debug.Log("UP"); - //if (Input.GetAxisRaw("DpadX") <= -1.0f) Debug.Log("DOWN"); - //if (Input.GetAxisRaw("DpadY") >= 1.0f) Debug.Log("RIGHT"); - //if (Input.GetAxisRaw("DpadY") <= -1.0f) Debug.Log("LEFT"); - //if (Input.GetButton("A")) Debug.Log("A"); - //if (Input.GetButton("X")) Debug.Log("X"); - //if (Input.GetButton("L")) Debug.Log("L"); - //if (Input.GetButton("R")) Debug.Log("R"); - } public void LoadRom(string path) { diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index d2af132..615c103 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -3,9 +3,11 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 12 + serializedVersion: 15 productGUID: 0600f466d2bb79d45aa373ee29d3a2aa AndroidProfiler: 0 + AndroidFilterTouchesWhenObscured: 0 + AndroidEnableSustainedPerformanceMode: 0 defaultScreenOrientation: 4 targetDevice: 2 useOnDemandResources: 0 @@ -38,8 +40,6 @@ PlayerSettings: width: 1 height: 1 m_SplashScreenLogos: [] - m_SplashScreenBackgroundLandscape: {fileID: 0} - m_SplashScreenBackgroundPortrait: {fileID: 0} m_VirtualRealitySplashScreen: {fileID: 0} m_HolographicTrackingLossScreen: {fileID: 0} defaultScreenWidth: 1024 @@ -49,11 +49,9 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 - m_MobileMTRendering: 0 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 - tizenShowActivityIndicatorOnLoading: -1 iosAppInBackgroundBehavior: 0 displayResolutionDialog: 0 iosAllowHTTPDownload: 1 @@ -63,14 +61,20 @@ PlayerSettings: allowedAutorotateToLandscapeLeft: 1 useOSAutorotation: 1 use32BitDisplayBuffer: 1 + preserveFramebufferAlpha: 0 disableDepthAndStencilBuffers: 0 - defaultIsFullScreen: 0 + androidStartInFullscreen: 1 + androidRenderOutsideSafeArea: 0 + androidBlitType: 0 defaultIsNativeResolution: 1 + macRetinaSupport: 1 runInBackground: 1 captureSingleScreen: 0 muteOtherAudioSources: 0 Prepare IOS For Recording: 0 Force IOS Speakers When Recording: 0 + deferSystemGesturesMode: 0 + hideHomeButton: 0 submitAnalytics: 1 usePlayerLog: 1 bakeCollisionMeshes: 0 @@ -88,33 +92,21 @@ PlayerSettings: visibleInBackground: 0 allowFullscreenSwitch: 1 graphicsJobMode: 0 - macFullscreenMode: 2 - d3d9FullscreenMode: 1 - d3d11FullscreenMode: 1 + fullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 xboxEnablePIXSampling: 0 - n3dsDisableStereoscopicView: 0 - n3dsEnableSharedListOpt: 1 - n3dsEnableVSync: 0 - ignoreAlphaClear: 0 + metalFramebufferOnly: 0 xboxOneResolution: 0 + xboxOneSResolution: 0 + xboxOneXResolution: 3 xboxOneMonoLoggingLevel: 0 xboxOneLoggingLevel: 1 xboxOneDisableEsram: 0 - videoMemoryForVertexBuffers: 0 - psp2PowerMode: 0 - psp2AcquireBGM: 1 - wiiUTVResolution: 0 - wiiUGamePadMSAA: 1 - wiiUSupportsNunchuk: 0 - wiiUSupportsClassicController: 0 - wiiUSupportsBalanceBoard: 0 - wiiUSupportsMotionPlus: 0 - wiiUSupportsProController: 0 - wiiUAllowScreenCapture: 1 - wiiUControllerCount: 0 + xboxOnePresentImmediateThreshold: 0 + switchQueueCommandMemory: 0 + vulkanEnableSetSRGBWrite: 0 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -124,9 +116,11 @@ PlayerSettings: bundleVersion: 1.0 preloadedAssets: [] metroInputSource: 0 + wsaTransparentSwapchain: 0 m_HolographicPauseOnTrackingLoss: 1 xboxOneDisableKinectGpuReservation: 0 xboxOneEnable7thCore: 0 + isWsaHolographicRemotingEnabled: 0 vrSettings: cardboard: depthFormat: 0 @@ -134,12 +128,25 @@ PlayerSettings: daydream: depthFormat: 0 useSustainedPerformanceMode: 0 + enableVideoLayer: 0 + useProtectedVideoMemory: 0 + minimumSupportedHeadTracking: 0 + maximumSupportedHeadTracking: 1 hololens: depthFormat: 1 + depthBufferSharingEnabled: 0 + oculus: + sharedDepthBuffer: 1 + dashSupport: 1 + enable360StereoCapture: 0 protectGraphicsMemory: 0 + enableFrameTimingStats: 0 useHDRDisplay: 0 - targetPixelDensity: 0 + m_ColorGamuts: 00000000 + targetPixelDensity: 30 resolutionScalingMode: 0 + androidSupportedAspectRatio: 1 + androidMaxAspectRatio: 2.1 applicationIdentifier: Android: com.scorr.retrounity Standalone: unity.DefaultCompany.RetroUnity @@ -162,11 +169,9 @@ PlayerSettings: APKExpansionFiles: 0 keepLoadedShadersAlive: 0 StripUnusedMeshComponents: 0 - VertexChannelCompressionMask: - serializedVersion: 2 - m_Bits: 238 + VertexChannelCompressionMask: 214 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 6.0 + iOSTargetOSVersionString: 9.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 tvOSTargetOSVersionString: 9.0 @@ -182,15 +187,22 @@ PlayerSettings: iPhone47inSplashScreen: {fileID: 0} iPhone55inPortraitSplashScreen: {fileID: 0} iPhone55inLandscapeSplashScreen: {fileID: 0} + iPhone58inPortraitSplashScreen: {fileID: 0} + iPhone58inLandscapeSplashScreen: {fileID: 0} iPadPortraitSplashScreen: {fileID: 0} iPadHighResPortraitSplashScreen: {fileID: 0} iPadLandscapeSplashScreen: {fileID: 0} iPadHighResLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} + appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] + tvOSSmallIconLayers2x: [] tvOSLargeIconLayers: [] + tvOSLargeIconLayers2x: [] tvOSTopShelfImageLayers: [] + tvOSTopShelfImageLayers2x: [] tvOSTopShelfImageWideLayers: [] + tvOSTopShelfImageWideLayers2x: [] iOSLaunchScreenType: 0 iOSLaunchScreenPortrait: {fileID: 0} iOSLaunchScreenLandscape: {fileID: 0} @@ -208,6 +220,8 @@ PlayerSettings: iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 iOSLaunchScreeniPadCustomXibPath: + iOSUseLaunchScreenStoryboard: 0 + iOSLaunchScreenCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] iOSBackgroundModes: 0 @@ -218,15 +232,25 @@ PlayerSettings: appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: + iOSManualSigningProvisioningProfileType: 0 + tvOSManualSigningProvisioningProfileType: 0 appleEnableAutomaticSigning: 0 - AndroidTargetDevice: 0 + iOSRequireARKit: 0 + appleEnableProMotion: 0 + clonedFromGUID: 00000000000000000000000000000000 + templatePackageId: + templateDefaultScene: + AndroidTargetArchitectures: 5 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: AndroidKeyaliasName: + AndroidBuildApkPerCpuArchitecture: 0 AndroidTVCompatibility: 1 AndroidIsGame: 1 + AndroidEnableTango: 0 androidEnableBanner: 1 + androidUseLowAccuracyLocation: 0 m_AndroidBanners: - width: 320 height: 180 @@ -240,6 +264,8 @@ PlayerSettings: m_Icon: {fileID: 0} m_Width: 128 m_Height: 128 + m_Kind: 0 + m_BuildTargetPlatformIcons: [] m_BuildTargetBatching: [] m_BuildTargetGraphicsAPIs: [] m_BuildTargetVRSettings: @@ -297,29 +323,23 @@ PlayerSettings: - m_BuildTarget: tvOS m_Enabled: 0 m_Devices: [] + m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 - webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} - wiiUTitleID: 0005000011000000 - wiiUGroupID: 00010000 - wiiUCommonSaveSize: 4096 - wiiUAccountSaveSize: 2048 - wiiUOlvAccessKey: 0 - wiiUTinCode: 0 - wiiUJoinGameId: 0 - wiiUJoinGameModeMask: 0000000000000000 - wiiUCommonBossSize: 0 - wiiUAccountBossSize: 0 - wiiUAddOnUniqueIDs: [] - wiiUMainThreadStackSize: 3072 - wiiULoaderThreadStackSize: 1024 - wiiUSystemHeapSize: 128 - wiiUTVStartupScreen: {fileID: 0} - wiiUGamePadStartupScreen: {fileID: 0} - wiiUDrcBufferDisabled: 0 - wiiUProfilerLibPath: + mobileMTRendering: + iPhone: 1 + tvOS: 1 + m_BuildTargetGroupLightmapEncodingQuality: + - m_BuildTarget: Standalone + m_EncodingQuality: 1 + - m_BuildTarget: XboxOne + m_EncodingQuality: 1 + - m_BuildTarget: PS4 + m_EncodingQuality: 1 + m_BuildTargetGroupLightmapSettings: [] playModeTestRunnerEnabled: 0 + runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 @@ -347,6 +367,9 @@ PlayerSettings: switchTitleNames_9: switchTitleNames_10: switchTitleNames_11: + switchTitleNames_12: + switchTitleNames_13: + switchTitleNames_14: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -359,6 +382,9 @@ PlayerSettings: switchPublisherNames_9: switchPublisherNames_10: switchPublisherNames_11: + switchPublisherNames_12: + switchPublisherNames_13: + switchPublisherNames_14: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -371,6 +397,9 @@ PlayerSettings: switchIcons_9: {fileID: 0} switchIcons_10: {fileID: 0} switchIcons_11: {fileID: 0} + switchIcons_12: {fileID: 0} + switchIcons_13: {fileID: 0} + switchIcons_14: {fileID: 0} switchSmallIcons_0: {fileID: 0} switchSmallIcons_1: {fileID: 0} switchSmallIcons_2: {fileID: 0} @@ -383,6 +412,9 @@ PlayerSettings: switchSmallIcons_9: {fileID: 0} switchSmallIcons_10: {fileID: 0} switchSmallIcons_11: {fileID: 0} + switchSmallIcons_12: {fileID: 0} + switchSmallIcons_13: {fileID: 0} + switchSmallIcons_14: {fileID: 0} switchManualHTML: switchAccessibleURLs: switchLegalInformation: @@ -424,8 +456,14 @@ PlayerSettings: switchLocalCommunicationIds_7: switchParentalControl: 0 switchAllowsScreenshot: 1 + switchAllowsVideoCapturing: 1 + switchAllowsRuntimeAddOnContentInstall: 0 switchDataLossConfirmation: 0 + switchUserAccountLockEnabled: 0 switchSupportedNpadStyles: 3 + switchNativeFsCacheSize: 32 + switchIsHoldTypeHorizontal: 0 + switchSupportedNpadCount: 8 switchSocketConfigEnabled: 0 switchTcpInitialSendBufferSize: 32 switchTcpInitialReceiveBufferSize: 64 @@ -455,6 +493,8 @@ PlayerSettings: ps4PronunciationSIGPath: ps4BackgroundImagePath: ps4StartupImagePath: + ps4StartupImagesFolder: + ps4IconImagesFolder: ps4SaveDataImagePath: ps4SdkOverride: ps4BGMPath: @@ -479,6 +519,8 @@ PlayerSettings: ps4pnFriends: 1 ps4pnGameCustomData: 1 playerPrefsSupport: 0 + enableApplicationExit: 0 + resetTempFolder: 1 restrictedAudioUsageRights: 0 ps4UseResolutionFallback: 0 ps4ReprojectionSupport: 0 @@ -502,54 +544,6 @@ PlayerSettings: ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] monoEnv: - psp2Splashimage: {fileID: 0} - psp2NPTrophyPackPath: - psp2NPSupportGBMorGJP: 0 - psp2NPAgeRating: 12 - psp2NPTitleDatPath: - psp2NPCommsID: - psp2NPCommunicationsID: - psp2NPCommsPassphrase: - psp2NPCommsSig: - psp2ParamSfxPath: - psp2ManualPath: - psp2LiveAreaGatePath: - psp2LiveAreaBackroundPath: - psp2LiveAreaPath: - psp2LiveAreaTrialPath: - psp2PatchChangeInfoPath: - psp2PatchOriginalPackage: - psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui - psp2KeystoneFile: - psp2MemoryExpansionMode: 0 - psp2DRMType: 0 - psp2StorageType: 0 - psp2MediaCapacity: 0 - psp2DLCConfigPath: - psp2ThumbnailPath: - psp2BackgroundPath: - psp2SoundPath: - psp2TrophyCommId: - psp2TrophyPackagePath: - psp2PackagedResourcesPath: - psp2SaveDataQuota: 10240 - psp2ParentalLevel: 1 - psp2ShortTitle: Not Set - psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF - psp2Category: 0 - psp2MasterVersion: 01.00 - psp2AppVersion: 01.00 - psp2TVBootMode: 0 - psp2EnterButtonAssignment: 2 - psp2TVDisableEmu: 0 - psp2AllowTwitterDialog: 1 - psp2Upgradable: 0 - psp2HealthWarning: 0 - psp2UseLibLocation: 0 - psp2InfoBarOnStartup: 0 - psp2InfoBarColor: 0 - psp2ScriptOptimizationLevel: 0 - psmSplashimage: {fileID: 0} splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} spritePackerPolicy: @@ -563,8 +557,9 @@ PlayerSettings: webGLTemplate: APPLICATION:Default webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 - webGLUseWasm: 0 webGLCompressionFormat: 1 + webGLLinkerTarget: 1 + webGLThreadsSupport: 0 scriptingDefineSymbols: 1: 2: @@ -581,7 +576,10 @@ PlayerSettings: Standalone: 0 WebGL: 1 WebPlayer: 0 + il2cppCompilerConfiguration: {} + managedStrippingLevel: {} incrementalIl2cppBuild: {} + allowUnsafeCode: 0 additionalIl2CppArgs: scriptingRuntimeVersion: 0 apiCompatibilityLevelPerPlatform: {} @@ -597,11 +595,12 @@ PlayerSettings: metroApplicationDescription: RetroUnity wsaImages: {} metroTileShortName: - metroCommandLineArgsFile: metroTileShowName: 0 metroMediumTileShowName: 0 metroLargeTileShowName: 0 metroWideTileShowName: 0 + metroSupportStreamingInstall: 0 + metroLastRequiredScene: 0 metroDefaultTileSize: 1 metroTileForegroundText: 1 metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} @@ -609,35 +608,11 @@ PlayerSettings: a: 1} metroSplashScreenUseBackgroundColor: 1 platformCapabilities: {} + metroTargetDeviceFamilies: {} metroFTAName: metroFTAFileTypes: [] metroProtocolName: metroCompilationOverrides: 1 - tizenProductDescription: - tizenProductURL: - tizenSigningProfileName: - tizenGPSPermissions: 0 - tizenMicrophonePermissions: 0 - tizenDeploymentTarget: - tizenDeploymentTargetType: 0 - tizenMinOSVersion: 1 - n3dsUseExtSaveData: 0 - n3dsCompressStaticMem: 1 - n3dsExtSaveDataNumber: 0x12345 - n3dsStackSize: 131072 - n3dsTargetPlatform: 2 - n3dsRegion: 7 - n3dsMediaSize: 0 - n3dsLogoStyle: 3 - n3dsTitle: GameName - n3dsProductCode: - n3dsApplicationId: 0xFF3FF - stvDeviceAddress: - stvProductDescription: - stvProductAuthor: - stvProductAuthorEmail: - stvProductLink: - stvProductCategory: 0 XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -647,6 +622,7 @@ PlayerSettings: XboxOneGameOsOverridePath: XboxOnePackagingOverridePath: XboxOneAppManifestOverridePath: + XboxOneVersion: 1.0.0.0 XboxOnePackageEncryption: 0 XboxOnePackageUpdateGranularity: 2 XboxOneDescription: @@ -660,7 +636,9 @@ PlayerSettings: XboxOneSplashScreen: {fileID: 0} XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 + XboxOneXTitleMemory: 8 xboxOneScriptCompiler: 0 + XboxOneOverrideIdentityName: vrEditorSettings: daydream: daydreamIconForeground: {fileID: 0} @@ -675,11 +653,30 @@ PlayerSettings: Purchasing: 0 UNet: 0 Unity_Ads: 0 + luminIcon: + m_Name: + m_ModelFolderPath: + m_PortalFolderPath: + luminCert: + m_CertPath: + m_PrivateKeyPath: + luminIsChannelApp: 0 + luminVersion: + m_VersionCode: 1 + m_VersionName: facebookSdkVersion: 7.9.4 + facebookAppId: + facebookCookies: 1 + facebookLogging: 1 + facebookStatus: 1 + facebookXfbml: 0 + facebookFrictionlessRequests: 1 apiCompatibilityLevel: 2 cloudProjectId: + framebufferDepthMemorylessMode: 0 projectName: organizationId: cloudEnabled: 0 enableNativePlatformBackendsForNewInputSystem: 0 disableOldInputManagerSupport: 0 + legacyClampBlendShapeWeights: 1 diff --git a/ProjectSettings/QualitySettings.asset b/ProjectSettings/QualitySettings.asset index 48a883e..5a48d90 100644 --- a/ProjectSettings/QualitySettings.asset +++ b/ProjectSettings/QualitySettings.asset @@ -17,6 +17,7 @@ QualitySettings: shadowNearPlaneOffset: 2 shadowCascade2Split: 0.33333334 shadowCascade4Split: {x: 0.06666667, y: 0.19999999, z: 0.46666664} + shadowmaskMode: 0 blendWeights: 4 textureQuality: 0 anisotropicTextures: 2 @@ -25,12 +26,20 @@ QualitySettings: softVegetation: 1 realtimeReflectionProbes: 1 billboardsFaceCameraPosition: 1 - vSyncCount: 1 + vSyncCount: 0 lodBias: 2 maximumLODLevel: 0 + streamingMipmapsActive: 0 + streamingMipmapsAddAllCameras: 1 + streamingMipmapsMemoryBudget: 512 + streamingMipmapsRenderersPerFrame: 512 + streamingMipmapsMaxLevelReduction: 2 + streamingMipmapsMaxFileIORequests: 1024 particleRaycastBudget: 4096 asyncUploadTimeSlice: 2 asyncUploadBufferSize: 4 + asyncUploadPersistentBuffer: 1 + resolutionScalingFixedDPIFactor: 1 excludedTargetPlatforms: [] m_PerPlatformDefaultQuality: Android: 0 diff --git a/ProjectSettings/TimeManager.asset b/ProjectSettings/TimeManager.asset index a2dc235..558a017 100644 --- a/ProjectSettings/TimeManager.asset +++ b/ProjectSettings/TimeManager.asset @@ -6,3 +6,4 @@ TimeManager: Fixed Timestep: 0.02 Maximum Allowed Timestep: 0.33333334 m_TimeScale: 1 + Maximum Particle Timestep: 0.03 From a8b270a88552d1554c0f47a362b3714062203ede Mon Sep 17 00:00:00 2001 From: Humberto Dias Date: Sat, 12 Sep 2020 14:42:47 +0200 Subject: [PATCH 2/2] Android with arm7 cpu supporting read rom from sd card --- .../RetroUnity/Scripts/CoreDownloader.cs | 55 +++++++++++++------ .../Plugins/RetroUnity/Scripts/GameManager.cs | 49 ++++++++++++++--- ProjectSettings/ProjectSettings.asset | 2 +- 3 files changed, 80 insertions(+), 26 deletions(-) diff --git a/Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs b/Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs index b3a4fdf..712b4e1 100644 --- a/Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs +++ b/Assets/Plugins/RetroUnity/Scripts/CoreDownloader.cs @@ -31,7 +31,7 @@ static void DownloadCores() { var coreNames = new List() { - "snes9x","blastem", "nestopia" + "snes9x","blastem", "nestopia", "mgba" }; foreach (var coreName in coreNames) { @@ -51,8 +51,9 @@ string extractDirectory(BuildTarget buildTarget) } } - void unzipCore(BuildTarget buildTarget, string zipPath, string extractDirectory) + List unzipCore(string zipPath, string extractDirectory) { + List assets = new List(); try { using (var archive = ZipFile.OpenRead(zipPath)) @@ -67,17 +68,7 @@ void unzipCore(BuildTarget buildTarget, string zipPath, string extractDirectory) } entry.ExtractToFile(destinationPath); - - var relativePath = destinationPath.Substring(destinationPath.IndexOf("Assets")); - AssetDatabase.ImportAsset(relativePath); - - - // Only for plugins - if (relativePath.Contains("Plugins")) - { - setNativePluginLibrary(buildTarget, relativePath); - } - + assets.Add(destinationPath); } } } @@ -86,7 +77,9 @@ void unzipCore(BuildTarget buildTarget, string zipPath, string extractDirectory) File.Delete(zipPath); } + return assets; } + static void DownloadCores(string romName) { @@ -113,9 +106,9 @@ static void DownloadCores(string romName) { var zipPath = coreDownloader.DownloadFile(url, extractDirectory); Debug.Log($"File successfully downloaded and saved to {zipPath}"); - coreDownloader.unzipCore(buildTarget, zipPath, extractDirectory); + var unzippedAssets = coreDownloader.unzipCore( zipPath, extractDirectory); Debug.Log($"Unzipping successfully downloaded and saved to {item.Value}"); - + ImportAssets(buildTarget, unzippedAssets); } catch (Exception e) { @@ -126,14 +119,40 @@ static void DownloadCores(string romName) } - static void setNativePluginLibrary(BuildTarget buildTarget, string pluginRelativePath) + + static void ImportAssets(BuildTarget buildTarget, List assetPaths) + { + foreach (var assetPath in assetPaths) + { + var relativePath = assetPath.Substring(assetPath.IndexOf("Assets")); + AssetDatabase.ImportAsset(relativePath); + + // Only for plugins + if (assetPath.Contains("Plugins")) + { + SetNativePluginLibrary(buildTarget, "ARMv7", relativePath); + } + + } + + } + + static void SetNativePluginLibrary(BuildTarget buildTarget, string cpu, string relativePath) { // native library, avaiable only for mobile - var nativePlugin = AssetImporter.GetAtPath(pluginRelativePath) as PluginImporter; + var nativePlugin = AssetImporter.GetAtPath(relativePath) as PluginImporter; + // Exclude + nativePlugin.SetExcludeEditorFromAnyPlatform(true); + nativePlugin.SetExcludeFromAnyPlatform(buildTarget, false); + // Include nativePlugin.SetCompatibleWithEditor(false); nativePlugin.SetCompatibleWithAnyPlatform(false); nativePlugin.SetCompatibleWithPlatform(buildTarget, true); - nativePlugin.SetPlatformData(buildTarget, "CompileFlags", "-fno-objc-arc"); + // Specific + nativePlugin.SetPlatformData(buildTarget, "CPU", cpu); + // Forcing flush + EditorUtility.SetDirty(nativePlugin); + AssetDatabase.WriteImportSettingsIfDirty(relativePath); } } diff --git a/Assets/Plugins/RetroUnity/Scripts/GameManager.cs b/Assets/Plugins/RetroUnity/Scripts/GameManager.cs index 5687e01..d681bf0 100644 --- a/Assets/Plugins/RetroUnity/Scripts/GameManager.cs +++ b/Assets/Plugins/RetroUnity/Scripts/GameManager.cs @@ -1,6 +1,9 @@ -using System.IO; -using RetroUnity.Utility; +using System; +using System.Collections; +using System.IO; +using System.Net; using UnityEngine; +using UnityEngine.Networking; namespace RetroUnity { public class GameManager : MonoBehaviour { @@ -33,21 +36,53 @@ private void Update() { } } - public void LoadRom(string path) { + private IEnumerator RequestRoutine(string url, Action callback = null) + { + // Using the static constructor + var request = UnityWebRequest.Get(url); + + // Wait for the response and then get our data + yield return request.SendWebRequest(); + var data = request.downloadHandler.data; + + // This isn't required, but I prefer to pass in a callback so that I can + // act on the response data outside of this function + if (callback != null) + callback(data); + } + + public void LoadRom(string romPath) { #if UNITY_EDITOR || UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX // If the file doesn't exist the application gets stuck in a loop. - if (!File.Exists(path)) + if (!File.Exists(romPath)) { - Debug.LogError(path + " not found."); + Debug.LogError(romPath + " not found."); return; } #endif + Display.material.color = Color.white; wrapper = new LibretroWrapper.Wrapper(CoreName); - wrapper.Init(); - wrapper.LoadGame(path); + +#if UNITY_ANDROID + Action AfterReadingRomFromAPK = bytes => + { + // Using persistentDataPath + romPath = Path.Combine(Application.persistentDataPath, RomName); + // Write + File.WriteAllBytes(romPath, bytes); + Debug.Log($"Copied to {romPath}"); + // Load Rom + wrapper.LoadGame(romPath); + }; + // Async + StartCoroutine(RequestRoutine(romPath, AfterReadingRomFromAPK)); +#else + wrapper.LoadGame(romPath); +#endif + } private void OnDestroy() { diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 615c103..bc96571 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -164,7 +164,7 @@ PlayerSettings: iPhoneStrippingLevel: 0 iPhoneScriptCallOptimization: 0 ForceInternetPermission: 0 - ForceSDCardPermission: 0 + ForceSDCardPermission: 1 CreateWallpaper: 0 APKExpansionFiles: 0 keepLoadedShadersAlive: 0