1 Commits
Author SHA1 Message Date
stefankoelle 73c793e3f7 release v0.9.4
This release updates the Marcer GameDVD Launcher with the following changes:

Bug Fixes:
- Fix Hatari.ConfigFile placeholder handling when empty (use bundled config from current directory)
- Add Hatari.ArgsTemplate validation in constructor
- Fix MenuRenderer.RedrawEntry() bounds checking on console resize
- Fix RightArrow key binding documentation

Features:
- Add bundled Hatari configuration file (MarcerGameDvd-Hatari.cfg)
- Make Hatari.ConfigFile optional with automatic fallback (uses current directory)
- Add RightArrow key support (alias for Enter)

Documentation:
- Update AGENTS.md with new RightArrow key binding
- Update README.md to clarify optional Hatari.ConfigFile
- Create BUGS.md with known issues and fixes

Code Improvements:
- Centralize magic strings and constants
- Add AvailableLines helper for console height
- Make color scheme fully configurable
- Improve Win32 constants documentation

The launcher now provides a more robust and configurable experience with proper error handling.
2026-08-11 14:47:19 +02:00
13 changed files with 231 additions and 216 deletions
+6 -11
View File
@@ -14,27 +14,22 @@ Create a release tag and push it to origin. The GitHub Action will automatically
- Run `git status --porcelain`
- If any output, warn the user and stop (commit first)
3. Find the previous tag dynamically:
- Run `git describe --tags --abbrev=0 HEAD` to find the most recent tag before HEAD
- If no previous tag exists (first release), note this and skip to step 5
- Report the previous tag to the user (e.g. "Previous tag found: v0.9.5")
4. Analyze changes since the previous tag:
- Run `git log --oneline <PREV_TAG>..HEAD` to list all commits between the previous tag and HEAD
3. Analyze changes since last release:
- Run `git log --oneline $(git describe --tags --abbrev=0 HEAD)..HEAD` to list all commits
- Read the changed files to understand context
- Write a concise, well-structured release summary in English with:
- A one-line overview
- Bullet points for each notable change (features, fixes, breaking changes)
- Keep it developer-friendly, no fluff
5. Create release commit with the summary as message:
4. Create release commit with the summary as message:
- Run `git commit --allow-empty -m "release v$ARGUMENTS\n\n<summary>"`
- The commit message IS the release notes — the GitHub Action picks it up automatically
6. Create annotated tag on that commit:
5. Create annotated tag on that commit:
- Run `git tag -a v$ARGUMENTS -m "Release v$ARGUMENTS"`
7. Push commit and tag:
6. Push commit and tag:
- Run `git push origin main --tags` (or current branch)
8. Confirm success with the version number
7. Confirm success with the version number
-26
View File
@@ -47,32 +47,6 @@ Download the ZIP for your platform from the [Releases](https://github.com/anomal
- **.NET Runtime 10** or later ([download](https://dotnet.microsoft.com/download/dotnet/10.0))
- **Hatari Emulator** (Windows native, or Linux/macOS via Wine or native build) — a Hatari configuration file (`MarcerGameDvd-Hatari.cfg`) is bundled with the launcher and used automatically when `Hatari.ConfigFile` is empty.
- **TOS 1.04** ROM image (`TOS.IMG`) — required by Hatari to boot the Atari ST system.
### 🕹️ Setting Up Hatari
Before using the launcher, you need to install Hatari and provide a TOS ROM:
1. **Download Hatari** from the official site: [https://hatari.tuxfamily.org/download.html](https://hatari.tuxfamily.org/download.html)
- **Windows:** Download and extract the latest Windows binary.
- **Linux:** Install via your package manager (e.g. `sudo apt install hatari`) or build from source.
- **macOS:** Download the macOS build or install via Homebrew: `brew install hatari`.
2. **Get TOS 1.04** (also known as TOS UK or TOS 1.04):
- TOS is copyrighted Atari ROM software — you must own a legal copy.
- Place the ROM file as `TOS.IMG` in the same directory as the launcher executable (or the Hatari working directory).
- The bundled `MarcerGameDvd-Hatari.cfg` is preconfigured to look for `TOS.IMG` in the current directory.
3. **Configure the path** in `launcher.config.json`:
```json
"Hatari": {
"Executable": "C:\\Tools\\hatari\\hatari.exe",
"ConfigFile": "",
"ArgsTemplate": "-c \"{cfg}\" --disk-a \"{zip}\""
}
```
- Set `Hatari.Executable` to the full path of your `hatari` (or `hatari.exe`) binary.
- Leave `Hatari.ConfigFile` empty to use the bundled configuration automatically.
### ⚡ Quick Start
+3 -8
View File
@@ -13,7 +13,7 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
DEMO_DIR="$SCRIPT_DIR/.demo"
ROOT_DIR="$DEMO_DIR/root"
PATCH_DIR="$DEMO_DIR/patch"
CONFIG_FILE="$DEMO_DIR/launcher.config.json"
CONFIG_FILE="$SCRIPT_DIR/launcher.config.json"
# --- Step 1: Build ---
echo "=== Building MarcerGameDvdLauncher ==="
@@ -83,11 +83,6 @@ fake_zip "$ROOT_DIR/E/Racing/Pole Position.zip"
fake_zip "$ROOT_DIR/E/Racing/Out Run.zip"
fake_zip "$ROOT_DIR/E/Racing/Daytona USA.zip"
# === Folders G-Z: empty placeholder folders ===
for letter in {G..Z}; do
mkdir -p "$ROOT_DIR/$letter"
done
# --- PATCH layer (overlay/additions) ---
echo "Creating patch layer..."
@@ -165,7 +160,7 @@ echo "=== Writing launcher.config.json ==="
HATARI_FAKE="$DEMO_DIR/hatari.exe"
cat > "$HATARI_FAKE" <<'HATEXEC'
#!/bin/bash
echo "[DEMO] Hatari would launch with: $0 $@"
echo "[DEMO] Hatari would launch with: $@"
HATEXEC
chmod +x "$HATARI_FAKE"
@@ -176,7 +171,7 @@ cat > "$CONFIG_FILE" <<EOF
"Hatari": {
"Executable": "$HATARI_FAKE",
"ConfigFile": "",
"ArgsTemplate": "-c \"{cfg}\" --disk-a \"{zip}\""
"ArgsTemplate": "{zip}"
}
}
EOF
+10 -4
View File
@@ -4,7 +4,7 @@
namespace MarcerGameDvdLauncher
{
// Manages loading, saving and querying favorite ZIP paths.
public class FavoritesService(string filePath)
public class FavoritesService
{
// Virtual folder name displayed at the root when favorites exist.
// Not configurable — fixed UI element.
@@ -14,10 +14,15 @@ namespace MarcerGameDvdLauncher
// Not configurable — fixed persistence file.
public const string DefaultFileName = "favorites.txt";
private readonly string _filePath = filePath ?? throw new ArgumentNullException(nameof(filePath));
private readonly string _filePath;
// Use a SortedSet so favorites are kept in sorted order in memory.
private SortedSet<string> _favorites = new(StringComparer.OrdinalIgnoreCase);
public FavoritesService(string filePath)
{
_filePath = filePath ?? throw new ArgumentNullException(nameof(filePath));
}
// Load favorites from disk (no-op if file missing)
public void Load()
{
@@ -26,7 +31,7 @@ namespace MarcerGameDvdLauncher
var lines = File.ReadAllLines(_filePath, System.Text.Encoding.UTF8);
foreach (var l in lines)
{
var t = l.Trim();
var t = l?.Trim();
if (string.IsNullOrEmpty(t)) continue;
try
{
@@ -66,13 +71,14 @@ namespace MarcerGameDvdLauncher
if (string.IsNullOrWhiteSpace(path)) throw new ArgumentNullException(nameof(path));
var full = Path.GetFullPath(path);
bool added;
if (!_favorites.Add(full))
if (_favorites.Contains(full))
{
_favorites.Remove(full);
added = false;
}
else
{
_favorites.Add(full);
added = true;
}
Save();
+17 -9
View File
@@ -8,7 +8,7 @@ namespace MarcerGameDvdLauncher
// The Hatari configuration file that is shipped with the launcher.
// When Hatari.ConfigFile is not set in launcher.config.json, this file
// (resolved relative to the executable directory) is used automatically.
private const string DEFAULT_CONFIG_FILE = "MarcerGameDvd-Hatari.cfg";
public const string DefaultConfigFile = "MarcerGameDvd-Hatari.cfg";
private readonly string _exePath;
private readonly string _cfgPath;
@@ -26,8 +26,6 @@ namespace MarcerGameDvdLauncher
// Validate argsTemplate
if (string.IsNullOrWhiteSpace(argsTemplate) || !argsTemplate.Contains("{zip}"))
throw new ArgumentException("Hatari.ArgsTemplate must contain the {zip} placeholder.", nameof(argsTemplate));
if (string.IsNullOrWhiteSpace(argsTemplate) || !argsTemplate.Contains("{cfg}"))
throw new ArgumentException("Hatari.ArgsTemplate must contain the {cfg} placeholder.", nameof(argsTemplate));
_exePath = exePath;
_cfgPath = cfgPath;
@@ -44,8 +42,17 @@ namespace MarcerGameDvdLauncher
throw new ArgumentException("ZIP archive path must not be empty.", nameof(zipFilePath));
try
{
var args = _argsTemplate;
args = args.Replace("{cfg}", !string.IsNullOrWhiteSpace(_cfgPath) ? _cfgPath : Path.Combine(Directory.GetCurrentDirectory(),DEFAULT_CONFIG_FILE));
// Build arguments: only include config section if cfgPath is not empty
string args = _argsTemplate;
if (!string.IsNullOrWhiteSpace(_cfgPath))
{
args = args.Replace("{cfg}", _cfgPath);
}
else
{
// Remove {cfg} placeholder entirely if config file is empty
args = args.Replace("{cfg}", string.Empty);
}
args = args.Replace("{zip}", zipFilePath);
var psi = new System.Diagnostics.ProcessStartInfo
@@ -55,10 +62,11 @@ namespace MarcerGameDvdLauncher
UseShellExecute = false,
WorkingDirectory = Directory.GetCurrentDirectory()
};
var process = System.Diagnostics.Process.Start(psi);
// Show a modal indicating the emulator is running and wait until
// the process has exited before clearing the modal.
ProgramHelpers.ShowModalUntilProcessExited(process, "Hatari is running...");
System.Diagnostics.Process.Start(psi);
// Show a modal indicating the emulator was started and wait until
// the user releases the Return key before clearing the modal. This
// prevents accidental key repeats from triggering other actions.
ProgramHelpers.ShowModalUntilReturnReleased("Hatari started. Release Return to continue...");
}
catch (Exception ex)
{
+68 -48
View File
@@ -1,6 +1,11 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
namespace MarcerGameDvdLauncher
{
/// <summary>
@@ -8,25 +13,42 @@ namespace MarcerGameDvdLauncher
/// Extracted from AppHost so that LauncherApp stays focused on lifecycle management.
/// No functional change - all key-handling behaviour is preserved exactly.
/// </summary>
internal class InputController(
OverlayDirectoryBrowser directoryBrowser,
MenuRenderer menuRenderer,
NavigationController navigationController,
HatariLauncher hatariLauncher,
FavoritesService favoritesService,
UIErrorService errorService)
internal class InputController
{
private readonly OverlayDirectoryBrowser _directoryBrowser;
private readonly MenuRenderer _menuRenderer;
private readonly NavigationController _navigationController;
private readonly HatariLauncher _hatariLauncher;
private readonly FavoritesService _favoritesService;
private readonly UIErrorService _errorService;
private List<GameEntry> _gameEntries = new();
public IReadOnlyList<GameEntry> GameEntries => _gameEntries;
public InputController(OverlayDirectoryBrowser directoryBrowser, MenuRenderer menuRenderer,
NavigationController navigationController, HatariLauncher hatariLauncher,
FavoritesService favoritesService, UIErrorService errorService)
{
_directoryBrowser = directoryBrowser;
_menuRenderer = menuRenderer;
_navigationController = navigationController;
_hatariLauncher = hatariLauncher;
_favoritesService = favoritesService;
_errorService = errorService;
}
private bool IsFavorite(GameEntry e)
{
return e.Kind == EntryKind.Zip && favoritesService.IsFavorite(e.InPatch ? e.PatchPath : e.RootPath);
return e.Kind == EntryKind.Zip
? _favoritesService.IsFavorite(e.InPatch ? e.PatchPath : e.RootPath)
: false;
}
private void DrawMenu(int availableLines)
{
menuRenderer.DrawMenu(_gameEntries, navigationController.ScrollOffset,
navigationController.SelectedIndex, availableLines, IsFavorite);
_menuRenderer.DrawMenu(_gameEntries, _navigationController.ScrollOffset,
_navigationController.SelectedIndex, availableLines, IsFavorite);
}
/// <summary>
@@ -34,7 +56,7 @@ namespace MarcerGameDvdLauncher
/// </summary>
public void RefreshView(int availableLines)
{
navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
_navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
DrawMenu(availableLines);
}
@@ -46,9 +68,9 @@ namespace MarcerGameDvdLauncher
try
{
// If we are at the virtual Favorites folder, produce the flat list from the favorites service
if (string.Equals(navigationController.CurrentRelativePath, FavoritesService.FavoritesRootName, StringComparison.OrdinalIgnoreCase))
if (string.Equals(_navigationController.CurrentRelativePath, FavoritesService.FavoritesRootName, StringComparison.OrdinalIgnoreCase))
{
var favs = favoritesService.GetAll();
var favs = _favoritesService.GetAll();
_gameEntries = new List<GameEntry>();
foreach (var p in favs)
{
@@ -63,15 +85,15 @@ namespace MarcerGameDvdLauncher
IsVirtual = false
});
}
navigationController.SetEntriesCount(_gameEntries.Count);
_navigationController.SetEntriesCount(_gameEntries.Count);
return;
}
// Otherwise use the overlay directory browser for normal folders
_gameEntries = directoryBrowser.GetEntries(navigationController.CurrentRelativePath);
_gameEntries = _directoryBrowser.GetEntries(_navigationController.CurrentRelativePath);
// If we are at the root and there are favorites, prepend a virtual Favorites folder
if (string.IsNullOrEmpty(navigationController.CurrentRelativePath) && favoritesService.HasFavorites())
if (string.IsNullOrEmpty(_navigationController.CurrentRelativePath) && _favoritesService.HasFavorites())
{
var virtualEntry = new GameEntry
{
@@ -86,14 +108,14 @@ namespace MarcerGameDvdLauncher
_gameEntries.Insert(0, virtualEntry);
}
navigationController.SetEntriesCount(_gameEntries.Count);
_navigationController.SetEntriesCount(_gameEntries.Count);
}
catch (Exception ex)
{
// Show the error to the user and continue with an empty list
errorService.ShowError(ex.Message);
_errorService.ShowError(ex.Message);
_gameEntries = new List<GameEntry>();
navigationController.SetEntriesCount(0);
_navigationController.SetEntriesCount(0);
}
}
@@ -104,9 +126,9 @@ namespace MarcerGameDvdLauncher
{
if (key.KeyChar == '?')
{
menuRenderer.ShowHelpBox(availableLines);
_menuRenderer.ShowHelpBox(availableLines);
Console.ReadKey(intercept: true);
menuRenderer.InvalidateCache();
_menuRenderer.InvalidateCache();
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
return false;
@@ -116,16 +138,16 @@ namespace MarcerGameDvdLauncher
{
case ConsoleKey.UpArrow:
{
int previousSelectedIndex = navigationController.SelectedIndex;
bool didScroll = navigationController.MoveUp(_gameEntries, availableLines);
int previousSelectedIndex = _navigationController.SelectedIndex;
bool didScroll = _navigationController.MoveUp(_gameEntries, availableLines);
if (didScroll)
{
DrawMenu(availableLines);
}
else
{
menuRenderer.RedrawEntry(_gameEntries, previousSelectedIndex, previousSelectedIndex - navigationController.ScrollOffset, false, availableLines, IsFavorite);
menuRenderer.RedrawEntry(_gameEntries, navigationController.SelectedIndex, navigationController.SelectedIndex - navigationController.ScrollOffset, true, availableLines, IsFavorite);
_menuRenderer.RedrawEntry(_gameEntries, previousSelectedIndex, previousSelectedIndex - _navigationController.ScrollOffset, false, availableLines, IsFavorite);
_menuRenderer.RedrawEntry(_gameEntries, _navigationController.SelectedIndex, _navigationController.SelectedIndex - _navigationController.ScrollOffset, true, availableLines, IsFavorite);
}
// flush input to avoid key repeat
ProgramHelpers.FlushInputBuffer();
@@ -133,16 +155,16 @@ namespace MarcerGameDvdLauncher
break;
case ConsoleKey.DownArrow:
{
int previousSelectedIndex = navigationController.SelectedIndex;
bool didScroll = navigationController.MoveDown(_gameEntries, availableLines);
int previousSelectedIndex = _navigationController.SelectedIndex;
bool didScroll = _navigationController.MoveDown(_gameEntries, availableLines);
if (didScroll)
{
DrawMenu(availableLines);
}
else
{
menuRenderer.RedrawEntry(_gameEntries, previousSelectedIndex, previousSelectedIndex - navigationController.ScrollOffset, false, availableLines, IsFavorite);
menuRenderer.RedrawEntry(_gameEntries, navigationController.SelectedIndex, navigationController.SelectedIndex - navigationController.ScrollOffset, true, availableLines, IsFavorite);
_menuRenderer.RedrawEntry(_gameEntries, previousSelectedIndex, previousSelectedIndex - _navigationController.ScrollOffset, false, availableLines, IsFavorite);
_menuRenderer.RedrawEntry(_gameEntries, _navigationController.SelectedIndex, _navigationController.SelectedIndex - _navigationController.ScrollOffset, true, availableLines, IsFavorite);
}
ProgramHelpers.FlushInputBuffer();
}
@@ -150,29 +172,27 @@ namespace MarcerGameDvdLauncher
case ConsoleKey.Enter:
case ConsoleKey.RightArrow:
{
var oldRelativePath = navigationController.CurrentRelativePath;
var isDirectory = _gameEntries.Count > 0 && _gameEntries[navigationController.SelectedIndex].Kind == EntryKind.Directory;
navigationController.HandleEnter(_gameEntries);
if (isDirectory && oldRelativePath != navigationController.CurrentRelativePath)
var oldRelativePath = _navigationController.CurrentRelativePath;
var isDirectory = _gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Directory;
_navigationController.HandleEnter(_gameEntries);
if (isDirectory && oldRelativePath != _navigationController.CurrentRelativePath)
{
ReloadGameEntries();
navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
_navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
}
DrawMenu(availableLines);
// Only start a ZIP if NOT switching to a directory
if (!isDirectory && _gameEntries.Count > 0 && _gameEntries[navigationController.SelectedIndex].Kind == EntryKind.Zip)
if (!isDirectory && _gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Zip)
{
string zipToLaunch = _gameEntries[navigationController.SelectedIndex].InPatch ? _gameEntries[navigationController.SelectedIndex].PatchPath : _gameEntries[navigationController.SelectedIndex].RootPath;
string zipToLaunch = _gameEntries[_navigationController.SelectedIndex].InPatch ? _gameEntries[_navigationController.SelectedIndex].PatchPath : _gameEntries[_navigationController.SelectedIndex].RootPath;
try
{
hatariLauncher.Launch(zipToLaunch);
_hatariLauncher.Launch(zipToLaunch);
}
catch (Exception ex)
{
errorService.ShowError(ex.Message);
_errorService.ShowError(ex.Message);
}
// Redraw menu after Hatari has exited
DrawMenu(availableLines);
}
// flush input to avoid leftover key events after an enter/navigation
ProgramHelpers.FlushInputBuffer();
@@ -181,23 +201,23 @@ namespace MarcerGameDvdLauncher
case ConsoleKey.Backspace:
case ConsoleKey.LeftArrow:
{
navigationController.GoUpDirectory();
_navigationController.GoUpDirectory();
ReloadGameEntries();
navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
_navigationController.UpdateScrollOffset(_gameEntries.Count, availableLines);
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.PageDown:
{
navigationController.PageDown(_gameEntries, availableLines);
_navigationController.PageDown(_gameEntries, availableLines);
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
}
break;
case ConsoleKey.PageUp:
{
navigationController.PageUp(_gameEntries, availableLines);
_navigationController.PageUp(_gameEntries, availableLines);
DrawMenu(availableLines);
ProgramHelpers.FlushInputBuffer();
}
@@ -206,17 +226,17 @@ namespace MarcerGameDvdLauncher
case ConsoleKey.Oem8:
{
// Toggle favorite for selected ZIP (handles numpad * and some layouts)
if (_gameEntries.Count > 0 && _gameEntries[navigationController.SelectedIndex].Kind == EntryKind.Zip)
if (_gameEntries.Count > 0 && _gameEntries[_navigationController.SelectedIndex].Kind == EntryKind.Zip)
{
var ge = _gameEntries[navigationController.SelectedIndex];
var ge = _gameEntries[_navigationController.SelectedIndex];
string path = ge.InPatch ? ge.PatchPath : ge.RootPath;
try
{
favoritesService.Toggle(path);
_favoritesService.Toggle(path);
}
catch (Exception ex)
{
errorService.ShowError("Failed to toggle favorite: " + ex.Message);
_errorService.ShowError("Failed to toggle favorite: " + ex.Message);
}
// Redraw the whole menu so the '*' marker updates immediately
DrawMenu(availableLines);
+9 -3
View File
@@ -63,11 +63,17 @@ namespace MarcerGameDvdLauncher
if (!File.Exists(cfg.Hatari.Executable))
throw new InvalidOperationException($"Hatari executable not found: {cfg.Hatari.Executable}");
// If no Hatari config file was specified, fall back to the bundled
// MarcerGameDvd-Hatari.cfg that ships with the launcher.
// Use current working directory to allow running from different locations
if (string.IsNullOrWhiteSpace(cfg.Hatari.ConfigFile))
{
cfg.Hatari.ConfigFile = Path.Combine(Directory.GetCurrentDirectory(), HatariLauncher.DefaultConfigFile);
}
// Validate the Hatari config file (either user-specified or bundled fallback)
if (!string.IsNullOrEmpty(cfg.Hatari.ConfigFile) && !File.Exists(cfg.Hatari.ConfigFile))
if (!File.Exists(cfg.Hatari.ConfigFile))
throw new InvalidOperationException($"Hatari configuration file not found: {cfg.Hatari.ConfigFile}");
if (string.IsNullOrWhiteSpace(cfg.Hatari.ArgsTemplate) || !cfg.Hatari.ArgsTemplate.Contains("{cfg}"))
throw new InvalidOperationException("Hatari.ArgsTemplate must contain the {cfg} placeholder.");
if (string.IsNullOrWhiteSpace(cfg.Hatari.ArgsTemplate) || !cfg.Hatari.ArgsTemplate.Contains("{zip}"))
throw new InvalidOperationException("Hatari.ArgsTemplate must contain the {zip} placeholder.");
@@ -11,14 +11,12 @@ bConsoleWindow = FALSE
nNumberBase = 10
nSymbolLines = -1
nMemdumpLines = -1
nFindLines = -1
nDisasmLines = -1
nBacktraceLines = 0
nExceptionDebugMask = 1073741830
nDisasmOptions = 7
nMemConvLocale = FALSE
bDisasmUAE = TRUE
nSymbolsAutoLoad = 1
bSymbolsAutoLoad = TRUE
bMatchAllSymbols = FALSE
[Screen]
@@ -44,14 +42,13 @@ nMaxHeight = 1024
nZoomFactor = 3
bUseSdlRenderer = FALSE
ScreenShotFormat = 2
szScreenShotDir =
bUseVsync = FALSE
[Joystick0]
nJoystickMode = 0
bEnableAutoFire = FALSE
bEnableJumpOnFire2 = TRUE
nJoyId = 0
nJoyId = -1
nJoyBut1Index = 0
nJoyBut2Index = 1
nJoyBut3Index = 2
@@ -79,7 +76,7 @@ kFire = Right Ctrl
nJoystickMode = 0
bEnableAutoFire = FALSE
bEnableJumpOnFire2 = TRUE
nJoyId = 0
nJoyId = -1
nJoyBut1Index = 0
nJoyBut2Index = 1
nJoyBut3Index = 2
@@ -109,7 +106,7 @@ kButton9 = 9
nJoystickMode = 0
bEnableAutoFire = FALSE
bEnableJumpOnFire2 = TRUE
nJoyId = 0
nJoyId = -1
nJoyBut1Index = 0
nJoyBut2Index = 1
nJoyBut3Index = 2
@@ -139,7 +136,7 @@ kButton9 =
nJoystickMode = 0
bEnableAutoFire = FALSE
bEnableJumpOnFire2 = TRUE
nJoyId = 0
nJoyId = -1
nJoyBut1Index = 0
nJoyBut2Index = 1
nJoyBut3Index = 2
@@ -153,7 +150,7 @@ kFire = Right Ctrl
nJoystickMode = 0
bEnableAutoFire = FALSE
bEnableJumpOnFire2 = TRUE
nJoyId = 0
nJoyId = -1
nJoyBut1Index = 0
nJoyBut2Index = 1
nJoyBut3Index = 2
@@ -164,7 +161,7 @@ kRight = Right
kFire = Right Ctrl
[Keyboard]
bFastForwardKeyRepeat = TRUE
bDisableKeyRepeat = FALSE
nKeymapType = 0
nCountryCode = -1
nKbdLayout = -1
@@ -255,17 +252,13 @@ szDiskImageDirectory =
nGemdosDrive = 0
bBootFromHardDisk = FALSE
bUseHardDiskDirectory = FALSE
szHardDiskDirectory = R:
szHardDiskDirectory = R:\
nGemdosCase = 0
nWriteProtection = 0
bFilenameConversion = FALSE
bGemdosHostTime = FALSE
[ACSI]
bUseDevice0 = FALSE
sDeviceFile0 =
nBlockSize0 = 512
nAcsiVersion0 = 1
[SCSI]
@@ -273,7 +266,6 @@ nAcsiVersion0 = 1
[IDE]
[ROM]
szTosImageFileName = TOS.IMG
bPatchTos = TRUE
@@ -320,13 +312,13 @@ bCompatibleCpu = TRUE
nModelType = 0
bBlitter = FALSE
nDSPType = 0
nVMEType = 1
nRtcYear = 0
bPatchTimerD = FALSE
bFastBoot = FALSE
bFastForward = FALSE
bAddressSpace24 = TRUE
bCycleExactCpu = TRUE
bCpuDataCache = TRUE
n_FPUType = 0
bSoftFloatFPU = FALSE
bMMU = TRUE
@@ -336,4 +328,3 @@ VideoTiming = 3
AviRecordVcodec = 2
AviRecordFps = 0
AviRecordFile =
+44 -26
View File
@@ -3,7 +3,7 @@
namespace MarcerGameDvdLauncher
{
public class MenuRenderer(AppColorConfig? colors = null)
public class MenuRenderer
{
// Simple line-based double buffer to avoid full Clear() flicker.
// cachedBuffer holds the last rendered text and colors for each visible row.
@@ -12,7 +12,12 @@ namespace MarcerGameDvdLauncher
private int _cachedWidth = -1;
// Color configuration (injected; defaults to built-in scheme if null)
private readonly AppColorConfig _colors = colors ?? new AppColorConfig();
private readonly AppColorConfig _colors;
public MenuRenderer(AppColorConfig? colors = null)
{
_colors = colors ?? new AppColorConfig();
}
// availableLines is provided per-draw so the renderer adapts to console resizes
public void DrawMenu(List<GameEntry> entries, int scrollOffset, int selectedIndex, int availableLines, Func<GameEntry, bool>? isFavorite = null)
@@ -135,41 +140,54 @@ namespace MarcerGameDvdLauncher
// Renders a centered, bordered help box with key bindings inside the
// available console area. The caller is responsible for waiting on a
// key and redrawing the menu afterward.
// key and redrawing the menu afterwards.
public void ShowHelpBox(int availableLines)
{
var width = Console.WindowWidth;
var helpLines = GetHelpLines();
var boxHeight = Math.Min(helpLines.Length + 2, Math.Max(3, availableLines));
var boxWidth = Math.Max(1, width);
var topRow = Math.Max(0, (availableLines - boxHeight) / 2);
try
{
int width = Console.WindowWidth;
string[] helpLines = GetHelpLines();
int boxHeight = Math.Min(helpLines.Length + 2, Math.Max(3, availableLines));
int boxWidth = Math.Max(1, width);
int topRow = Math.Max(0, (availableLines - boxHeight) / 2);
Console.BackgroundColor = ConsoleColor.DarkGray;
Console.ForegroundColor = ConsoleColor.White;
var topBorder = "+" + new string('-', Math.Max(0, boxWidth - 2)) + "+";
string topBorder = "+" + new string('-', Math.Max(0, boxWidth - 2)) + "+";
Console.SetCursorPosition(0, topRow);
Console.Write(topBorder);
for (var i = 0; i < boxHeight - 2; i++)
for (int i = 0; i < boxHeight - 2; i++)
{
var row = topRow + 1 + i;
var content = i < helpLines.Length
? PadToWidth(helpLines[i], boxWidth - 2)
: new string(' ', Math.Max(0, boxWidth - 2));
int row = topRow + 1 + i;
string content;
if (i < helpLines.Length)
{
content = PadToWidth(helpLines[i], boxWidth - 2);
}
else
{
content = new string(' ', Math.Max(0, boxWidth - 2));
}
Console.SetCursorPosition(0, row);
Console.Write("|" + content + "|");
}
var bottomRow = topRow + boxHeight - 1;
int bottomRow = topRow + boxHeight - 1;
if (bottomRow < Console.WindowHeight)
{
var bottomBorder = "+" + new string('-', Math.Max(0, boxWidth - 2)) + "+";
string bottomBorder = "+" + new string('-', Math.Max(0, boxWidth - 2)) + "+";
Console.SetCursorPosition(0, bottomRow);
Console.Write(bottomBorder);
}
Console.ResetColor();
}
catch
{
}
}
private static string[] GetHelpLines()
{
@@ -217,7 +235,7 @@ namespace MarcerGameDvdLauncher
{
if (width <= 0) return string.Empty;
var label = GetLabel(e, isFavorite);
string label = GetLabel(e, isFavorite);
// If the console width is smaller than the label, truncate the label
if (width <= label.Length)
@@ -225,7 +243,7 @@ namespace MarcerGameDvdLauncher
return label.Substring(0, width);
}
var maxNameLen = width - label.Length; // space left for name
int maxNameLen = width - label.Length; // space left for name
string displayName;
if (e.Name.Length <= maxNameLen)
{
@@ -239,7 +257,7 @@ namespace MarcerGameDvdLauncher
displayName = e.Name.Substring(0, Math.Max(0, maxNameLen));
}
var padding = Math.Max(0, width - label.Length - displayName.Length);
int padding = Math.Max(0, width - label.Length - displayName.Length);
var result = label + displayName + new string(' ', padding);
// Ensure exact width (defensive): truncate or pad if needed
if (result.Length > width) return result.Substring(0, width);
@@ -255,7 +273,7 @@ namespace MarcerGameDvdLauncher
{
// Layer label (7 chars)
string layer;
if (e is {InRoot: true, InPatch: true}) layer = "[BOTH] ";
if (e.InRoot && e.InPatch) layer = "[BOTH] ";
else if (e.InPatch) layer = "[PTCH] ";
else if (e.InRoot) layer = "[ROOT] ";
else layer = " ";
@@ -281,15 +299,15 @@ namespace MarcerGameDvdLauncher
if (e.Kind == EntryKind.Directory)
{
if (e is {InRoot: true, InPatch: true}) return _colors.FolderBoth; // Both layers
if (e is {InPatch: true, InRoot: false}) return _colors.FolderPatchOnly; // Only patch
if (e is {InRoot: true, InPatch: false}) return _colors.FolderRootOnly; // Only root
if (e.InRoot && e.InPatch) return _colors.FolderBoth; // Both layers
if (e.InPatch && !e.InRoot) return _colors.FolderPatchOnly; // Only patch
if (e.InRoot && !e.InPatch) return _colors.FolderRootOnly; // Only root
}
else if (e.Kind == EntryKind.Zip)
{
if (e is {InRoot: true, InPatch: true}) return _colors.ZipBoth; // Both layers
if (e is { InRoot: true, InPatch: false }) return _colors.ZipRootOnly; // Only root
if (e is {InPatch: true, InRoot: false}) return _colors.ZipPatchOnly; // Only patch
if (e.InRoot && e.InPatch) return _colors.ZipBoth; // Both layers
if (e.InRoot && !e.InPatch) return _colors.ZipRootOnly; // Only root
if (e.InPatch && !e.InRoot) return _colors.ZipPatchOnly; // Only patch
}
return ConsoleColor.DarkGray;
}
@@ -8,11 +8,11 @@ namespace MarcerGameDvdLauncher
// Scroll fractions: when the selection cursor reaches 2/3 of the visible window
// height from the top, the list scrolls down; when it reaches 1/3, it scrolls up.
// Not configurable — these ratios are the established navigation behaviour.
private const double BOTTOM_SCROLL_FRACTION = 2.0 / 3.0;
private const double TOP_SCROLL_FRACTION = 1.0 / 3.0;
private const double BottomScrollFraction = 2.0 / 3.0;
private const double TopScrollFraction = 1.0 / 3.0;
public int SelectedIndex { get; private set; }
public int ScrollOffset { get; private set; }
public int SelectedIndex { get; private set; } = 0;
public int ScrollOffset { get; private set; } = 0;
public string CurrentRelativePath { get; private set; } = "";
// Stores the last selection & scroll position for each directory
private readonly Dictionary<string, (int sel, int scroll)> _lastSelections = new();
@@ -105,12 +105,12 @@ namespace MarcerGameDvdLauncher
if (availableLines < 1) availableLines = 1;
if (entryCount <= availableLines) { ScrollOffset = 0; return; }
if (SelectedIndex == 0) { ScrollOffset = 0; return; }
int bottomScrollTrigger = ScrollOffset + (int)(availableLines * BOTTOM_SCROLL_FRACTION);
int topScrollTrigger = ScrollOffset + (int)(availableLines * TOP_SCROLL_FRACTION);
int bottomScrollTrigger = ScrollOffset + (int)(availableLines * BottomScrollFraction);
int topScrollTrigger = ScrollOffset + (int)(availableLines * TopScrollFraction);
if (SelectedIndex >= bottomScrollTrigger && (ScrollOffset + availableLines) < entryCount)
ScrollOffset = SelectedIndex - (int)(availableLines * BOTTOM_SCROLL_FRACTION);
ScrollOffset = SelectedIndex - (int)(availableLines * BottomScrollFraction);
else if (SelectedIndex < topScrollTrigger && ScrollOffset > 0)
ScrollOffset = SelectedIndex - (int)(availableLines * TOP_SCROLL_FRACTION);
ScrollOffset = SelectedIndex - (int)(availableLines * TopScrollFraction);
if (ScrollOffset < 0) ScrollOffset = 0;
if (ScrollOffset > entryCount - availableLines)
ScrollOffset = entryCount - availableLines;
@@ -19,16 +19,16 @@ namespace MarcerGameDvdLauncher
public class OverlayDirectoryBrowser(string root, string patch)
{
public List<GameEntry> GetEntries(string? currentRelativePath)
public List<GameEntry> GetEntries(string currentRelativePath)
{
try
{
// Normalize and protect against path traversal or absolute paths in the relative path
var rel = currentRelativePath ?? string.Empty;
string rel = currentRelativePath ?? string.Empty;
// Remove any leading directory separators
rel = rel.TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
// If the relative path is rooted or contains parent directory segments, reset to root
if (Path.IsPathRooted(rel) || rel.Split([Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar], StringSplitOptions.RemoveEmptyEntries).Any(p => p == ".."))
if (Path.IsPathRooted(rel) || rel.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries).Any(p => p == ".."))
{
rel = string.Empty;
}
+2 -2
View File
@@ -6,11 +6,11 @@ namespace MarcerGameDvdLauncher
class Program
{
// Console window title. Not configurable — fixed application display name.
private const string DEFAULT_TITLE = "Marcer GameDVD Launcher";
private const string DefaultTitle = "Marcer GameDVD Launcher";
static void Main(string[] args)
{
Console.Title = DEFAULT_TITLE;
Console.Title = DefaultTitle;
var app = new LauncherApp();
app.Run();
}
+22 -20
View File
@@ -1,6 +1,7 @@
// Copyright (c) 2026 Stefan Koelle (https://stefankoelle.de)
// Licensed under the MIT License. See LICENSE file in project root for details.
using System;
using System.Runtime.InteropServices;
namespace MarcerGameDvdLauncher
@@ -39,11 +40,11 @@ namespace MarcerGameDvdLauncher
// These are defined by the Windows API and do not change.
private const int STD_INPUT_HANDLE = -10;
[DllImport("kernel32.dll")]
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
[System.Runtime.InteropServices.DllImport("kernel32.dll", SetLastError = true)]
[return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
private static extern bool FlushConsoleInputBuffer(IntPtr hConsoleInput);
// P/Invoke to query key state (used to detect physical key release)
@@ -53,36 +54,37 @@ namespace MarcerGameDvdLauncher
[DllImport("user32.dll")]
private static extern short GetAsyncKeyState(int vKey);
// Shows a simple modal message in the center of the console and
// blocks until the given process has exited. The message is then
// removed and the method returns.
public static void ShowModalUntilProcessExited(System.Diagnostics.Process? process, string? message)
// Shows a simple modal message on the reserved last console line and
// blocks until the Return key is physically released. The message is
// then removed and the method returns. This is designed to be a
// lightweight modal for the console UI and uses the last console line
// which the application reserves for transient messages.
public static void ShowModalUntilReturnReleased(string message)
{
try
{
int lastRow = AvailableLines;
int width = Console.WindowWidth;
int height = Console.WindowHeight;
int centerRow = height / 2;
var text = message ?? string.Empty;
if (text.Length > width - 4) text = text.Substring(0, Math.Max(0, width - 7)) + "...";
int leftPad = Math.Max(0, (width - text.Length) / 2);
var line = new string(' ', leftPad) + text;
string text = message ?? string.Empty;
if (text.Length > width) text = text.Substring(0, Math.Max(0, width - 3)) + "...";
int padding = Math.Max(0, width - text.Length);
string line = text + new string(' ', padding);
Console.BackgroundColor = ConsoleColor.DarkGray;
Console.ForegroundColor = ConsoleColor.White;
try { Console.SetCursorPosition(0, centerRow); } catch { }
try { Console.Write(line.PadRight(width)); } catch { }
try { Console.SetCursorPosition(0, lastRow); } catch { }
try { Console.Write(line); } catch { }
Console.ResetColor();
// Wait until the external process has exited
while (process != null && !process.HasExited)
// Wait until Return key is not pressed
// GetAsyncKeyState returns a short where the high-order bit is set when key is down
while ((GetAsyncKeyState(VK_RETURN) & 0x8000) != 0)
{
Thread.Sleep(100);
Thread.Sleep(10);
}
// Clear the line
try { Console.SetCursorPosition(0, centerRow); } catch { }
try { Console.SetCursorPosition(0, lastRow); } catch { }
try { Console.Write(new string(' ', width)); } catch { }
}
catch