mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 18:46:43 +00:00
Cleanup
This commit is contained in:
parent
40295112fe
commit
e606dfee95
27 changed files with 35 additions and 91 deletions
|
@ -17,8 +17,9 @@ using Capy64.API;
|
|||
using Capy64.Core;
|
||||
using Capy64.Eventing;
|
||||
using Capy64.Extensions;
|
||||
using Capy64.Runtime;
|
||||
using Capy64.Integrations;
|
||||
using Capy64.PluginManager;
|
||||
using Capy64.Runtime;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
@ -27,7 +28,6 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using static Capy64.Utils;
|
||||
using Capy64.Integrations;
|
||||
|
||||
namespace Capy64;
|
||||
|
||||
|
@ -121,8 +121,8 @@ public class Capy64 : Game, IGame
|
|||
|
||||
if (Window.IsMaximized())
|
||||
{
|
||||
var vertical = bounds.Height - Height * Scale;
|
||||
var horizontal = bounds.Width - Width * Scale;
|
||||
var vertical = bounds.Height - (Height * Scale);
|
||||
var horizontal = bounds.Width - (Width * Scale);
|
||||
|
||||
Borders.Top = (int)Math.Floor(vertical / 2d);
|
||||
Borders.Bottom = (int)Math.Ceiling(vertical / 2d);
|
||||
|
|
|
@ -146,7 +146,7 @@ public class Audio : IDisposable
|
|||
Waveform.Square => GetSquarePoint(frequency, x),
|
||||
Waveform.Triangle => GetTrianglePoint(frequency, x),
|
||||
Waveform.Sawtooth => GetSawtoothPoint(frequency, x),
|
||||
Waveform.Noise => rng.NextDouble() * 2 - 1,
|
||||
Waveform.Noise => (rng.NextDouble() * 2) - 1,
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
|
||||
|
@ -184,8 +184,8 @@ public class Audio : IDisposable
|
|||
double v = 0;
|
||||
for (int k = 1; k <= 25; k++)
|
||||
{
|
||||
v += (Math.Pow(-1, k) / Math.Pow(2 * k - 1, 2))
|
||||
* Math.Sin(frequency * 2 * Math.PI * (2 * k - 1) * x);
|
||||
v += Math.Pow(-1, k) / Math.Pow((2 * k) - 1, 2)
|
||||
* Math.Sin(frequency * 2 * Math.PI * ((2 * k) - 1) * x);
|
||||
}
|
||||
return -(8 / Math.Pow(Math.PI, 2)) * v;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class Audio : IDisposable
|
|||
double v = 0;
|
||||
for (int k = 1; k <= 50; k++)
|
||||
{
|
||||
v += (Math.Pow(-1, k) / k) * Math.Sin(frequency * 2 * Math.PI * k * x);
|
||||
v += Math.Pow(-1, k) / k * Math.Sin(frequency * 2 * Math.PI * k * x);
|
||||
}
|
||||
return -(2 / Math.PI) * v;
|
||||
}
|
||||
|
|
|
@ -14,11 +14,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
using Capy64.Extensions.Bindings;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Core;
|
||||
|
||||
|
|
|
@ -163,7 +163,8 @@ public class EventEmitter
|
|||
|
||||
public void RaiseOverlay(OverlayEvent ev)
|
||||
{
|
||||
if(OnOverlay is not null) {
|
||||
if (OnOverlay is not null)
|
||||
{
|
||||
OnOverlay(this, ev);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
|
||||
namespace Capy64.Eventing.Events;
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
|
||||
namespace Capy64.Eventing.Events;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
// limitations under the License.
|
||||
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
|
||||
namespace Capy64.Eventing.Events;
|
||||
|
|
|
@ -14,11 +14,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Extensions.Bindings;
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
using Capy64.API;
|
||||
using Capy64.Core;
|
||||
using Capy64.Eventing;
|
||||
using Capy64.Integrations;
|
||||
using Capy64.Runtime;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
|
|
@ -18,12 +18,7 @@ using DiscordRPC;
|
|||
using DiscordRPC.Logging;
|
||||
using DiscordRPC.Message;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Integrations;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ using IHost host = Host.CreateDefaultBuilder(args)
|
|||
.ConfigureAppConfiguration((context, c) =>
|
||||
{
|
||||
var settingsPath = Path.Combine(Capy64.Capy64.AppDataPath, "settings.json");
|
||||
if(!Directory.Exists(Capy64.Capy64.AppDataPath))
|
||||
if (!Directory.Exists(Capy64.Capy64.AppDataPath))
|
||||
{
|
||||
Directory.CreateDirectory(Capy64.Capy64.AppDataPath);
|
||||
}
|
||||
|
|
|
@ -15,12 +15,10 @@
|
|||
|
||||
using Capy64.Core;
|
||||
using Capy64.Eventing.Events;
|
||||
using Capy64.Eventing;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using static Capy64.Eventing.InputManager;
|
||||
using Capy64.Runtime.Extensions;
|
||||
|
||||
namespace Capy64.Runtime;
|
||||
|
||||
|
@ -187,7 +185,8 @@ internal class EventEmitter
|
|||
if (SDL.HasClipboardText())
|
||||
{
|
||||
var text = SDL.GetClipboardText();
|
||||
_runtime.QueueEvent("paste", LK => {
|
||||
_runtime.QueueEvent("paste", LK =>
|
||||
{
|
||||
LK.PushString(text);
|
||||
|
||||
return 1;
|
||||
|
@ -199,7 +198,8 @@ internal class EventEmitter
|
|||
|
||||
private void OnChar(object sender, CharEvent e)
|
||||
{
|
||||
_runtime.QueueEvent("char", LK => {
|
||||
_runtime.QueueEvent("char", LK =>
|
||||
{
|
||||
LK.PushString(e.Character.ToString());
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -17,7 +17,6 @@ using Capy64.API;
|
|||
using KeraLua;
|
||||
using Microsoft.Xna.Framework.Audio;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using static Capy64.Core.Audio;
|
||||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
using Capy64.API;
|
||||
using KeraLua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
|
|
|
@ -15,13 +15,12 @@
|
|||
|
||||
using Capy64.API;
|
||||
using Capy64.Runtime.Extensions;
|
||||
using Capy64.Runtime.Objects;
|
||||
using KeraLua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Capy64.Runtime.Objects;
|
||||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
|
@ -430,7 +429,7 @@ public class FileSystem : IComponent
|
|||
var attr = File.GetAttributes(path);
|
||||
if (attr.HasFlag(FileAttributes.Directory))
|
||||
{
|
||||
if(!recursive && Directory.GetFileSystemEntries(path).Any())
|
||||
if (!recursive && Directory.GetFileSystemEntries(path).Any())
|
||||
{
|
||||
L.Error("directory not empty");
|
||||
return 0;
|
||||
|
|
|
@ -456,7 +456,7 @@ public class GPU : IComponent
|
|||
var w = (int)L.CheckInteger(4);
|
||||
var h = (int)L.CheckInteger(5);
|
||||
|
||||
if(w * h != buffer.Length)
|
||||
if (w * h != buffer.Length)
|
||||
{
|
||||
L.Error("width and height do not match buffer size");
|
||||
}
|
||||
|
|
|
@ -18,10 +18,6 @@ using KeraLua;
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
|
|
|
@ -18,11 +18,8 @@ using Capy64.Eventing.Events;
|
|||
using KeraLua;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using MonoGame.Extended;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using static Capy64.Utils;
|
||||
using static System.Formats.Asn1.AsnWriter;
|
||||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
|
@ -292,7 +289,7 @@ internal class Term : IComponent
|
|||
if (cursorState)
|
||||
{
|
||||
var realpos = ToRealPos(CursorPosition - Vector2.One);
|
||||
var charpos = realpos * _game.Scale + CharOffset;
|
||||
var charpos = (realpos * _game.Scale) + CharOffset;
|
||||
_game.Game.SpriteBatch.Draw(cursorTexture, charpos, null, ForegroundColor, 0f, Vector2.Zero, _game.Scale, SpriteEffects.None, 0);
|
||||
}
|
||||
}
|
||||
|
@ -623,15 +620,15 @@ internal class Term : IComponent
|
|||
|
||||
// RGB to ABGR
|
||||
fgv =
|
||||
(fgv & 0x00_FF_00_00U) >> 16 | // move R
|
||||
((fgv & 0x00_FF_00_00U) >> 16) | // move R
|
||||
(fgv & 0x00_00_FF_00U) | // move G
|
||||
(fgv & 0x00_00_00_FFU) << 16 | // move B
|
||||
((fgv & 0x00_00_00_FFU) << 16) | // move B
|
||||
0xFF_00_00_00U;
|
||||
|
||||
bgv =
|
||||
(bgv & 0x00_FF_00_00U) >> 16 | // move R
|
||||
((bgv & 0x00_FF_00_00U) >> 16) | // move R
|
||||
(bgv & 0x00_00_FF_00U) | // move G
|
||||
(bgv & 0x00_00_00_FFU) << 16 | // move B
|
||||
((bgv & 0x00_00_00_FFU) << 16) | // move B
|
||||
0xFF_00_00_00U;
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ using Capy64.API;
|
|||
using KeraLua;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Capy64.Runtime.Libraries;
|
||||
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
|
||||
using KeraLua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Runtime;
|
||||
|
||||
|
|
|
@ -18,11 +18,6 @@ using KeraLua;
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Runtime;
|
||||
|
||||
|
|
|
@ -16,11 +16,7 @@
|
|||
using Capy64.API;
|
||||
using KeraLua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Runtime.Objects;
|
||||
|
||||
|
@ -107,12 +103,13 @@ public class FileHandle : IComponent
|
|||
{
|
||||
var modes = "nlLa";
|
||||
mode = mode.TrimStart('*');
|
||||
if(string.IsNullOrEmpty(mode)) {
|
||||
if (string.IsNullOrEmpty(mode))
|
||||
{
|
||||
return '\0';
|
||||
}
|
||||
|
||||
var i = modes.IndexOf(mode[0]);
|
||||
if(i == -1)
|
||||
if (i == -1)
|
||||
return '\0';
|
||||
|
||||
return modes[i];
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
using Capy64.API;
|
||||
using KeraLua;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Capy64.Runtime.Objects;
|
||||
|
||||
|
@ -111,9 +110,9 @@ public class GPUBuffer : IComponent
|
|||
|
||||
// ABGR to RGB
|
||||
value =
|
||||
(value & 0x00_00_00_FFU) << 16 | // move R
|
||||
((value & 0x00_00_00_FFU) << 16) | // move R
|
||||
(value & 0x00_00_FF_00U) | // move G
|
||||
(value & 0x00_FF_00_00U) >> 16; // move B
|
||||
((value & 0x00_FF_00_00U) >> 16); // move B
|
||||
|
||||
L.PushInteger(value);
|
||||
|
||||
|
@ -146,9 +145,9 @@ public class GPUBuffer : IComponent
|
|||
|
||||
// RGB to ABGR
|
||||
value =
|
||||
(value & 0x00_FF_00_00U) >> 16 | // move R
|
||||
((value & 0x00_FF_00_00U) >> 16) | // move R
|
||||
(value & 0x00_00_FF_00U) | // move G
|
||||
(value & 0x00_00_00_FFU) << 16 | // move B
|
||||
((value & 0x00_00_00_FFU) << 16) | // move B
|
||||
0xFF_00_00_00U;
|
||||
|
||||
|
||||
|
|
|
@ -13,14 +13,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using Capy64.Core;
|
||||
using Capy64.Runtime.Libraries;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Runtime;
|
||||
|
||||
|
|
|
@ -19,14 +19,8 @@ using Capy64.Extensions;
|
|||
using Capy64.Runtime.Libraries;
|
||||
using KeraLua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Capy64.Runtime;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public static class Utils
|
|||
return
|
||||
(color.R << 16) +
|
||||
(color.G << 8) +
|
||||
(color.B);
|
||||
color.B;
|
||||
}
|
||||
|
||||
public static void UnpackRGB(uint packed, out byte r, out byte g, out byte b)
|
||||
|
|
Loading…
Reference in a new issue