Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Winksplorer authored and Winksplorer committed May 6, 2023
1 parent 7ba8ecc commit b8e7a0e
Show file tree
Hide file tree
Showing 17 changed files with 1,436 additions and 0 deletions.
70 changes: 70 additions & 0 deletions Apps/Screensaver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Cosmos.Core.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;

namespace ziOS.Apps
{
internal class Screensaver
{
public static void Entry(string[] args)
{
DVDstyle(args);
}

public static void DVDstyle(string[] args)
{
const int LogoWidth = 188;
const int LogoHeight = 65;
int ScreenWidth = Kernel.Scrwidth;
int ScreenHeight = Kernel.Scrheight;

Random random = new Random();

int logoX = random.Next(ScreenWidth - LogoWidth);
int logoY = random.Next(ScreenHeight - LogoHeight);

int velocityX = random.Next(-5, 5);
int velocityY = random.Next(-5, 5);

long beat = 0;

bool enableVerbose = (args.Length == 2);
while (!Cosmos.System.KeyboardManager.ShiftPressed)
{
beat++;
if ((beat % 750) == 0)
{
velocityX = random.Next(-5, 5);
velocityY = random.Next(-5, 5);
}
logoX += velocityX;
logoY += velocityY;

if (logoX < 0 || logoX + LogoWidth > ScreenWidth)
{
velocityX = -velocityX;
}

if (logoY < 0 || logoY + LogoHeight > ScreenHeight)
{
velocityY = -velocityY;
}

Kernel.canvas.DrawImage(logoX, logoY, Kernel.Logo, false);
if (enableVerbose)
{
Kernel.canvas.DrawFilledRectangle(0, 0, (ushort)Kernel.Scrwidth, 15, 0, PrismGraphics.Color.Black);
Kernel.canvas.DrawString(0, 0, "FPS: " + Kernel.canvas.GetFPS() + " - RAM used: " + Cosmos.Core.GCImplementation.GetUsedRAM() / 1000 + " KB - Currently on beat " + beat, Libs.LibTerm.Termfont, PrismGraphics.Color.GoogleRed);
}
Kernel.canvas.Update();
Heap.Collect();
//System.Threading.Thread.Sleep(1);
}
}

}
}
60 changes: 60 additions & 0 deletions Apps/ziv/Editor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.IO;
using ziOS;
using ziOS.Libs;

namespace ziOS.Apps.ziv
{
public class Editor
{
public static PrismGraphics.Color[] colors = { PrismGraphics.Color.GoogleBlue, PrismGraphics.Color.GoogleRed, PrismGraphics.Color.GoogleGreen, PrismGraphics.Color.GoogleYellow };
public static void Entry(string file)
{
Kernel.canvas.Clear(PrismGraphics.Color.Black);
LibTerm.CursorX = 0; LibTerm.CursorY = 0;
PrismGraphics.Color fore = colors[Program.rng.Next(0, colors.Length - 1)];
LibTerm.ForegroundC = fore;
LibTerm.Write("ziv - " + file + " - Type $-wq on 1 line to save and quit.");
Kernel.canvas.DrawFilledRectangle(LibTerm.CursorX, LibTerm.CursorY, (ushort)(Kernel.Scrwidth - LibTerm.CursorX), 16, 0, fore);
LibTerm.WriteLine("\n");
LibTerm.ForegroundC = PrismGraphics.Color.White;
MainLoop(file);
}

public static void MainLoop(string file)
{
LibTerm.Write(Program.buffer);
while (true)
{
string Buffer2 = libinput.ReadstdLine();
if (Buffer2 == "$-wq") // Write, then quit
{
LibTerm.Clear();
LibTerm.WriteLine("Saving file to disk...");
File.WriteAllText(file, Program.buffer);
LibTerm.WriteLine("I finished! Have a good day/night!");
break;
}
else if (Buffer2 == "$-q") // quit
{
LibTerm.Clear();
break;
}
else if (Buffer2 == "$-waq") // Write as, then quit
{
LibTerm.Clear();
LibTerm.Write("Where do you want to save this text? (Don't do a full path) ");
string dest = libinput.ReadstdLine();
LibTerm.WriteLine("Saving file to disk...");
File.WriteAllText(tuldrv.Syspath + dest, Program.buffer);
LibTerm.WriteLine("I finished! Have a good day/night!");
break;
}
else
{
Program.buffer += Buffer2 + "\n";
}
}
}
}
}
60 changes: 60 additions & 0 deletions Apps/ziv/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.IO;
using ziOS;
using ziOS.Libs;

namespace ziOS.Apps.ziv
{
public class Program
{
public static Random rng = new Random(); // Global random object
public static string version = "Milestone 1 (ziOS port)"; // Version string
public static string buffer = ""; // Text buffer
public static void Main(string[] args) // Runner, sets up the buffer
{
if (tuldrv.DisableFS)
{
tuldrv.Error("The file system is disabled.", "ziv");
}
else
{
try
{
buffer = "";
bool ActuallyGoIntoEditor = true;
if (args.Length == 2) // If one argument is passed
{
if (File.Exists(tuldrv.Syspath + args[1])) // If the first argument exists as a file
{
buffer = File.ReadAllText(tuldrv.Syspath + args[1]); // Setup the buffer
}
else
{
if (args[1] == "--version" || args[1] == "-v")
{
LibTerm.WriteLine($"ziv " + version);
ActuallyGoIntoEditor = false;
}
else
{
LibTerm.WriteLine("ziv says: No files? I'll make one then!");
}
}
if (ActuallyGoIntoEditor)
Editor.Entry(tuldrv.Syspath + args[1]); // Call the actual ziv editor
}
else
{
LibTerm.WriteLine("ziv says: It would be really nice if actually gave me a file to edit.");
}
}
catch (Exception e)
{
LibTerm.WriteLine("Oops! ziv has crashed! Sorry for the inconvenience!\n");
LibTerm.WriteLine("Error: " + e.Message);
LibTerm.WriteLine($"Error type: " + e.GetType().Name);
}
}
}
}
}
146 changes: 146 additions & 0 deletions Kernel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
using PrismGraphics;
using System.Threading;
using ziOS.Libs;
using IL2CPU.API.Attribs;
using ziOS.ziSH;
using System.IO;
using Cosmos.Core.Memory;

namespace ziOS
{
public class Kernel : Sys.Kernel
{
// VERSION INFORMATION
public static readonly int BuildNum = 230506;
public static readonly string BuildString = "ziOS 2.2.0.4 [Build " + BuildNum + "]";
// version scheme is REWRITE.MAJOR.MINOR.PATCH: ADD TO PATCH WHEN YOU PATCH, MINOR WHEN YOU ADD NEW FEATURE. MAJOR WHEN MINOR REACHES 16. REWRITE WHEN YOU REWRITE OR WHEN MAJOR REACHES 30.

// CRITICAL VARIABLES
public static PrismGraphics.Extentions.VMWare.SVGAIICanvas canvas;
public static short Scrwidth = 1024, Scrheight = 768;
Sys.FileSystem.CosmosVFS fs = new Sys.FileSystem.CosmosVFS();

// RESOURCES INIT
[ManifestResourceStream(ResourceName = "ziOS.Resources.zios_logo.bmp")]
static byte[] LogoBytes;
public static Image Logo;

[ManifestResourceStream(ResourceName = "ziOS.Resources.wateringcan.bmp")]
static byte[] WateringCanBytes;
public static Image Wateringcan;

// CONFIGURABLE INFO
public static string Hostname = "omniverse";

protected override void BeforeRun()
{
try
{
Console.Clear();
Console.Write("Welcome to ");
tuldrv.ColorTextMode(BuildString + "\n", ConsoleColor.Cyan);

Console.Write("Hold shift NOW to get advanced startup options");
Thread.Sleep(666);
Console.Write(".");
Thread.Sleep(666);
Console.Write(".");
Thread.Sleep(666);
Console.WriteLine(".");
if (Sys.KeyboardManager.ShiftPressed)
{
StartupOptions.Entry();
}

if (!Sys.VMTools.IsVMWare)
{
// | |
Console.WriteLine("That's an X in my book!\n");
Console.WriteLine("You are running ziOS on REAL HARDWARE! Or you aren't using VMWare, why though?");
Console.WriteLine("There is about a 110% chance that ziOS will burn into flames on this computer.");
Console.WriteLine("That can include performance or stability issues, and/or even data loss.");
Console.WriteLine("Do you want to continue? (Y/N)");
if (!tuldrv.YNmenu()) { Sys.Power.Shutdown(); }
}

// START OF "CANVAS LAYER"
canvas = new((ushort)Scrwidth,(ushort)Scrheight);
if (canvas == null || canvas.Width <= 0 || canvas.Height <= 0) { throw new Exception("Canvas init didn't really do anything."); }
Logo = Image.FromBitmap(LogoBytes);
canvas.Clear(Color.Black);
canvas.DrawImage(0,15,Logo);
canvas.Update();
LibTerm.SetCursorPos(0, 90);
// | |
LibTerm.Write("Initializing canvas... ");
LibTerm.ColorWrite("[OK]\n", Color.GoogleGreen);
if (!tuldrv.DisableFS)
{
// | |
LibTerm.Write("Initializing FS... ");
try
{
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
LibTerm.ColorWrite("[OK]\n", Color.GoogleGreen);
}
catch (Exception e)
{
LibTerm.ColorWrite("[FAIL: " + e.Message + "]\n", Color.GoogleRed);
}

// | |
LibTerm.Write("Parsing autoexec.zis... ");
try
{
tuldrv.ParseShellScript("0:\\autoexec.zis");
LibTerm.ColorWrite("[OK]\n", Color.GoogleGreen);
canvas.Clear(Color.Black);
canvas.DrawImage(0, 15, Logo);
canvas.Update();
LibTerm.SetCursorPos(0, 90);
}
catch (Exception e)
{
LibTerm.ColorWrite("[FAIL: " + e.Message + "]\n", Color.GoogleRed);
}
}

// | |
LibTerm.Write("Initializing Bitmaps... ");
try
{
Wateringcan = Image.FromBitmap(WateringCanBytes);
LibTerm.ColorWrite("[OK]\n", Color.GoogleGreen);
}
catch (Exception e)
{
LibTerm.ColorWrite("[FAIL: " + e.Message + "]\n", Color.GoogleRed);
}

LibTerm.WriteLine();
LibTerm.WriteLine(BuildString + " " + Hostname + " svga\n"); // ADD HOST/USERNAMES!!!
}
catch (Exception e)
{
tuldrv.KernelPanic(e);
}
}

protected override void Run()
{
try
{
string Command = Prompt.ShowPrompt();
CmdHandler.Handle(Command);
Heap.Collect();
} catch (Exception e)
{
tuldrv.KernelPanic(e);
}
}
}
}
Loading

0 comments on commit b8e7a0e

Please sign in to comment.