Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port Doom to Aura #264

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion SRC/Aura_Boot/Aura_Boot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<DebugMode>Source</DebugMode>
<IgnoreDebugStubAttribute>False</IgnoreDebugStubAttribute>
<ISOFile>bin\Debug\net6.0\Aura_Boot.iso</ISOFile>
<CompileVBEMultiboot>True</CompileVBEMultiboot>
<CompileVBEMultiboot>False</CompileVBEMultiboot>
<ExtractMapFile>False</ExtractMapFile>
<Launch>VMware</Launch>
<VisualStudioDebugPort>Pipe: Cosmos\Serial</VisualStudioDebugPort>
Expand Down
2 changes: 2 additions & 0 deletions SRC/Aura_OS/Aura_OS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\doom1.wad" />
<None Remove="Resources\wallpaper-1.bmp" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\doom1.wad" />
<EmbeddedResource Include="Resources\error.bmp" />
<EmbeddedResource Include="Resources\Tetris.gb" />
<EmbeddedResource Include="Resources\wallpaper1920.bmp" />
Expand Down
3 changes: 3 additions & 0 deletions SRC/Aura_OS/Files.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public class Files
[ManifestResourceStream(ResourceName = "Aura_OS.Resources.wallpaper1920.bmp")]
public static byte[] Wallpaper;

[ManifestResourceStream(ResourceName = "Aura_OS.Resources.doom1.wad")]
public static byte[] DoomWad;

public static void LoadFiles()
{
CustomConsole.WriteLineInfo("Checking for ISO9660 volume...");
Expand Down
12 changes: 2 additions & 10 deletions SRC/Aura_OS/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ public static void BeforeRun()
Running = true;
}

private static int lastHeapCollectTime = -1;

public static void Run()
{
try
Expand All @@ -192,18 +190,12 @@ public static void Run()
_fps = _frames;
_frames = 0;
_deltaT = RTC.Second;

lastHeapCollectTime++;

if (lastHeapCollectTime >= 3)
{
FreeCount = Heap.Collect();
lastHeapCollectTime = 0;
}
}

_frames++;

FreeCount = Heap.Collect();

UpdateUI();

canvas.Display();
Expand Down
2 changes: 1 addition & 1 deletion SRC/Aura_OS/Properties/VersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace Aura_OS
{
public class VersionInfo
{
public static string revision = "090120241014";
public static string revision = "150120241337";
}
}
Binary file added SRC/Aura_OS/Resources/doom1.wad
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Runtime.CompilerServices;
using Cosmos.System.Graphics;

namespace Aura_OS.System.Processing.Application.Emulators.GameBoyEmu.Utils
namespace Aura_OS.System.Graphics.UI.GUI.Components
{
public class DirectBitmap
{
Expand All @@ -17,6 +17,18 @@ public DirectBitmap()
Bitmap = new Bitmap((uint)Width, (uint)Height, ColorDepth.ColorDepth32);
}

public DirectBitmap(byte[] data)
{
Bitmap = new Bitmap(data);
}

public DirectBitmap(int width, int height)
{
Width = width;
Height = height;
Bitmap = new Bitmap((uint)Width, (uint)Height, ColorDepth.ColorDepth32);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetPixel(int x, int y, int colour)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void LoadApplications()
RegisterApplication(typeof(SystemInfo), 40, 40, 402, 360);
RegisterApplication(typeof(Cube), 40, 40, 200, 200);
RegisterApplication(typeof(GameBoyEmu), 40, 40, 160 + 4, 144 + 22);
RegisterApplication(typeof(DoomApp), 40, 40, 320 + 4, 200 + 22 + 200);
}

public void RegisterApplication(ApplicationConfig config)
Expand Down Expand Up @@ -92,6 +93,10 @@ public Graphics.UI.GUI.Application Instantiate(ApplicationConfig config)
{
app = new Explorer(Kernel.CurrentVolume, config.Weight, config.Height, config.X, config.Y);
}
else if (config.Template == typeof(DoomApp))
{
app = new DoomApp(config.Weight, config.Height, config.X, config.Y);
}
else
{
throw new InvalidOperationException("Type d'application non reconnu.");
Expand Down
26 changes: 26 additions & 0 deletions SRC/Aura_OS/System/Processing/Application/Doom/Debugger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Aura_OS.System.Graphics.UI.GUI.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aura_OS.System.Processing.Application.Doom
{
public class Debugger
{
public string Text = "";

public Debugger() { }

public void Write(string message)
{
Text += message;
}

public void WriteLine(string message)
{
Text += message += "\n";
}
}
}
100 changes: 100 additions & 0 deletions SRC/Aura_OS/System/Processing/Application/Doom/Doom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* PROJECT: Aura Operating System Development
* CONTENT: Doom
* PROGRAMMERS: Valentin Charbonnier <valentinbreiz@gmail.com>
*/

using Aura_OS.System.Graphics;
using Aura_OS.System.Graphics.UI.GUI.Components;
using Aura_OS.System.Processing.Application.Doom;
using Cosmos.System;
using Cosmos.System.FileSystem;
using System;
using System.IO;

namespace Aura_OS.System.Processing.Application
{
public class DoomApp : Graphics.UI.GUI.Application
{
public static string ApplicationName = "Doom";

public Panel TopPanel;
public Button Screenshot;

static ManagedDoom.DoomApplication app = null;

public static Debugger debugger = new Debugger();

bool calledAfterRender = false;

static float framesPerSecond;

private string[] args = { };
private string[] configLines = { };

public DoomApp(int width, int height, int x = 0, int y = 0) : base(ApplicationName, width, height, x, y)
{
TopPanel = new Panel(Kernel.Gray, x + 1, y + 1, width - 6, 22);
TopPanel.Borders = true;

string text = "Screenshot";
int textWidth = text.Length * (Kernel.font.Width + 1);
Screenshot = new Button(text, x + 3, y + 3, textWidth, 18);
Screenshot.Action = new Action(() =>
{
File.Create(Kernel.CurrentDirectory + "screenshot.bmp");
app.renderer.bitmap.Bitmap.Save(Kernel.CurrentDirectory + "screenshot.bmp");
});

app = null;
var commandLineArgs = new ManagedDoom.CommandLineArgs(args);
app = new ManagedDoom.DoomApplication(commandLineArgs, configLines);
}

public override void UpdateApp()
{
app.renderer.X = x;
app.renderer.Y = y + 23;

if (app == null)
{
return;
}

uint[] upKeys = { };
uint[] downKeys = { };

app.Run(upKeys, downKeys);

string[] lines = debugger.Text.Split('\n');
int maxLinesToShow = 17;
int startIndex = Math.Max(0, lines.Length - maxLinesToShow); // Ensure you don't go below 0
int dy = 0;

for (int i = startIndex; i < lines.Length; i++)
{
string line = lines[i];
Kernel.canvas.DrawString(line, Kernel.font, Kernel.BlackColor, x + 2, y + 23 + 200 + 4 + dy);
dy += 12;
}

TopPanel.X = x + 1;
TopPanel.Y = y + 1;
TopPanel.Update();
Screenshot.X = x + 3;
Screenshot.Y = y + 3;
Screenshot.Update();
}

public override void HandleLeftClick()
{
base.HandleLeftClick();

if (Screenshot.IsInside((int)MouseManager.X, (int)MouseManager.Y))
{
Screenshot.Action();
return;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright (C) 1993-1996 Id Software, Inc.
// Copyright (C) 2019-2020 Nobuaki Tanaka
//
// 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
// (at your option) 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.
//



using System;

namespace ManagedDoom
{
public static class ApplicationInfo
{
public static readonly string Title = "Managed Doom v1.1b";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright (C) 1993-1996 Id Software, Inc.
// Copyright (C) 2019-2020 Nobuaki Tanaka
//
// 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
// (at your option) 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.
//



using System;

namespace ManagedDoom
{
public enum ApplicationState
{
None,
Opening,
DemoPlayback,
Game
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
//
// Copyright (C) 1993-1996 Id Software, Inc.
// Copyright (C) 2019-2020 Nobuaki Tanaka
//
// 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
// (at your option) 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.
//



using System;

namespace ManagedDoom
{
public enum Bgm
{
NONE,
E1M1,
E1M2,
E1M3,
E1M4,
E1M5,
E1M6,
E1M7,
E1M8,
E1M9,
E2M1,
E2M2,
E2M3,
E2M4,
E2M5,
E2M6,
E2M7,
E2M8,
E2M9,
E3M1,
E3M2,
E3M3,
E3M4,
E3M5,
E3M6,
E3M7,
E3M8,
E3M9,
INTER,
INTRO,
BUNNY,
VICTOR,
INTROA,
RUNNIN,
STALKS,
COUNTD,
BETWEE,
DOOM,
THE_DA,
SHAWN,
DDTBLU,
IN_CIT,
DEAD,
STLKS2,
THEDA2,
DOOM2,
DDTBL2,
RUNNI2,
DEAD2,
STLKS3,
ROMERO,
SHAWN2,
MESSAG,
COUNT2,
DDTBL3,
AMPIE,
THEDA3,
ADRIAN,
MESSG2,
ROMER2,
TENSE,
SHAWN3,
OPENIN,
EVIL,
ULTIMA,
READ_M,
DM2TTL,
DM2INT
}
}
Loading
Loading