Skip to content

Commit fdd02b9

Browse files
anomixerUser
andauthored
Pull Request: Add native Windows (AmpleWin) and Linux (AmpleLinux) ports (#46)
* Initialize and finalize AmpleWin: Full-featured Windows Port with Adaptive UI, optimized engine, and internationalized documentation * Update media args * AmpleWin: Finalized Windows Port with Adaptive UI, Optimized Engine, VGM Recording, and Shared Directory Support * Fix NameError: subprocess not defined in main.py * UI: Remove redundant MAME path label from Paths tab * UI: Implement smart slot validation for disabled options and click-to-browse Shared Directory * feat(win): editable console, launch logic fixes & doc updates * Fix path quoting issues, add file selectors for A/V, and normalize shared dir path * feat: sync with Ample v0.285 resources, update to MAME 0.285, and add ROM search filter * v0.285: Expand ROM library, implement download failover, and advanced SCSI sub-slot emulation * Adjust ROM download priority: prefer callapple.org for stability, mdk.cab as fallback * Sync roms.plist with upstream/master * docs(agent): record upstream synchronization session * refactor: rename mame_bin to mame directory * chore: update .gitignore for mame directory rename * fix(main): update download and detection paths to 'mame' * fix(main): robust path resolution for pyinstaller builds * docs(readme): add build_exe.bat to project structure * fix(build): remove creation of empty mame directory to avoid confusion * feat(build): auto-generate application icon from Assets.xcassets * Add AmpleLinux - Linux Port of Ample (Apple II/Mac emulator frontend) - Ported from AmpleWin with ~20 Linux-specific adaptations - Replaced winreg with gsettings/KDE dark mode detection - Replaced os.startfile with xdg-open - Removed MAME auto-download (users install via package manager) - Added system-wide MAME detection (PATH, /usr/bin, /usr/games) - Removed all .exe suffixes from binary references - Created AmpleLinux.sh launcher script - Dual-language READMEs (English + Traditional Chinese) * Fix: use python3 -m pip instead of pip3/pip for modern Linux compatibility * feat(linux): Finalize AmpleLinux port documentation and build scripts * Fix formatting for Windows and Linux user notes Updated user guidance for Windows and Linux users. * feat(linux): interactive .desktop install, runtime icon loading, updated docs * docs(linux): clarify mame_downloader.py usage status * docs: add PR draft template * fix(linux): add binutils dependency check for pyinstaller * Update: mame 0.286 --------- Co-authored-by: User <user@example.com>
1 parent 4a44e22 commit fdd02b9

31 files changed

Lines changed: 7633 additions & 1 deletion

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,27 @@ embedded/SDL3-*
99
build
1010
embedded/mame-data.tgz
1111
__pycache__
12+
13+
# Windows Port
14+
AmpleWin/mame/
15+
AmpleWin/dist/
16+
AmpleWin/build/
17+
AmpleWin/*.spec
18+
19+
nvram/
20+
cfg/
21+
diff/
22+
inp/
23+
comments/
24+
sta/
25+
*.ini
26+
*.ico
27+
28+
# Linux Port
29+
AmpleLinux/.venv
30+
AmpleLinux/.build_venv
31+
AmpleLinux/icons/
32+
AmpleLinux/Ample.spec
33+
AmpleLinux/mame/
34+
!AmpleLinux/mame/.gitkeep
35+

AmpleLinux/Agent.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Agent Task Audit Log - Ample Linux Port
2+
3+
4+
## 📅 Session: 2026-03-02 (Session 3)
5+
6+
### 🎯 Objective: Upstream Version Tracking & Documentation Maintenance
7+
Focused on updating the Linux port documentation to track MAME 0.286 and simplifying maintainability.
8+
9+
### ✅ Key Achievements:
10+
1. **Documentation Refactoring**:
11+
* Renamed version-specific screenshot files (e.g. `screenshot-v0.28x.png` to `screenshot.png`).
12+
* Updated `README.md` and `README_tw.md` to use generic "latest version" terminology to prevent the need for manual text updates upon future Ample/MAME releases.
13+
14+
### 🚀 Current Project Status
15+
The Linux Port documentation is updated for MAME 0.286 and future-proofed against minor version increments.
16+
17+
---
18+
19+
## 📅 Session: 2026-02-17 (Session 2)
20+
21+
### 🎯 Objective: Real-World Testing & Deployment Fix
22+
Deployed the Linux Port to an actual Linux machine for testing. Identified and fixed a critical dependency installation issue.
23+
24+
### ✅ Key Achievements:
25+
26+
1. **Launcher Script Fix (`AmpleLinux.sh`)**:
27+
* **Bug**: Original script used `pip3` / `pip` commands directly, which don't exist on many modern Linux distros (Debian 12+, Ubuntu 23+, Fedora 38+ enforce PEP 668).
28+
* **Fix v1**: Changed to `python3 -m pip` (the universally reliable pip invocation).
29+
* **Fix v2**: Added automatic `--break-system-packages` fallback for PEP 668-compliant systems.
30+
* **Error Messages**: Added distro-specific guidance (apt/dnf/pacman) and venv instructions in error output.
31+
32+
2. **Git Workflow**:
33+
* Created `linux` branch from `master`.
34+
* Pushed to `origin/linux` for cross-machine testing.
35+
36+
### 🔍 Testing Observations (Real Linux Machine):
37+
* `pip3` command was not in PATH → first fallback triggered.
38+
* `python3 -m pip` also failed (PEP 668 system Python restriction) → second fallback triggered with `--break-system-packages`.
39+
* **Conclusion**: Many modern Linux distros require either system packages (`sudo apt install python3-pyside6 python3-requests`) or a venv approach. The launcher script now documents both paths clearly.
40+
41+
### ⚠️ Known Issue - Pending Resolution:
42+
* Systems without any pip module need manual package installation first. The script provides clear guidance but cannot auto-resolve this without `sudo`.
43+
* **Recommended solutions** (in priority order):
44+
1. System packages: `sudo apt install python3-pyside6 python3-requests`
45+
2. Install pip: `sudo apt install python3-pip`, then re-run script
46+
3. Use venv: `python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt && python3 main.py`
47+
48+
### 🚀 Current Project Status
49+
Codebase is ported and pushed to `linux` branch. Launcher script has been hardened for modern Linux distros. Awaiting successful end-to-end test with dependencies installed.
50+
51+
---
52+
53+
## 📅 Session: 2026-02-16 (Session 1)
54+
55+
### 🎯 Objective: Linux Port Creation
56+
Ported AmpleWin (Windows) to Linux, following the original author's suggestion (ksherlock/ample#45) that Linux support would be easy to add.
57+
58+
### ✅ Key Achievements:
59+
60+
1. **Codebase Porting (from AmpleWin)**:
61+
* **Zero-Modification Files**: `data_manager.py`, `rom_manager.py`, `mame_launcher.py`, `requirements.txt` — copied directly, no changes needed.
62+
* **Simplified `mame_downloader.py`**: Removed `MameDownloadWorker` entirely (Linux users install MAME via their package manager). Kept `VgmModDownloadWorker` with Linux adaptations (7z via PATH, no `.exe` suffix, helpful `p7zip` install instructions).
63+
* **`main.py` (~20 changes)**: Comprehensive platform adaptation:
64+
- Replaced `winreg` theme detection with `gsettings` (GNOME 42+ `color-scheme`) and KDE (`kdeglobals`) dark mode detection.
65+
- Replaced all `os.startfile()` calls with `xdg-open` via a helper function `_xdg_open()`.
66+
- Removed all `.exe` suffixes from MAME binary references (`mame.exe``mame`, `mame-vgm.exe``mame-vgm`).
67+
- Enhanced `check_for_mame()` to search system paths (`/usr/bin/mame`, `/usr/games/mame`, `/usr/local/bin/mame`) and use `which mame`.
68+
- Replaced `Download MAME` button with package manager guidance text.
69+
- Updated `shlex.split()` from `posix=False` (Windows) to `posix=True` (Linux).
70+
- Updated file browser filter from `*.exe` to `All Files (*)`.
71+
- Changed window title and help URL.
72+
73+
2. **Launcher Script**:
74+
* Created `AmpleLinux.sh` as equivalent of `AmpleWin.bat`.
75+
* Includes Python 3 detection, pip dependency installation, and helpful error messages with distro-specific commands.
76+
77+
3. **Documentation**:
78+
* Created dual-language READMEs (`README.md` English, `README_tw.md` Traditional Chinese).
79+
* Includes installation guide for all major distros (Ubuntu, Fedora, Arch, Flatpak).
80+
* Troubleshooting section for PySide6, MAME detection, and theme issues.
81+
82+
### 🔍 Design Decisions:
83+
84+
1. **Separate Directory (not shared codebase)**: Chose to create `AmpleLinux/` as a separate directory rather than refactoring `AmpleWin/` into a shared codebase. This maintains the project convention where each platform gets its own additive subdirectory, minimizing risk to the stable Windows port.
85+
86+
2. **No MAME Auto-Download**: Following the original author's guidance ("let the user download it themselves"), Linux users install MAME via their system package manager. This is the Linux cultural norm and avoids complex binary distribution issues.
87+
88+
3. **GNOME + KDE Theme Detection**: Implemented multi-strategy dark mode detection covering GNOME 42+ `color-scheme`, older GNOME `gtk-theme`, and KDE `kdeglobals`, with Qt palette as ultimate fallback.
89+
90+
### 🚀 Current Project Status
91+
The Linux Port is functionally complete. All Windows-specific code has been adapted, and the application should work on major Linux distributions with GNOME or KDE desktops.
92+
93+
---
94+
95+
## Handover Notes for Future Agents
96+
97+
### 1. Platform Differences from AmpleWin
98+
* **No `winreg`**: Theme detection uses `gsettings` and KDE config file parsing.
99+
* **No `os.startfile()`**: Uses `xdg-open` via the `_xdg_open()` helper function.
100+
* **No `.exe` suffixes**: All binary references use bare names (`mame`, `mame-vgm`).
101+
* **No MAME auto-download**: Users install via package manager. Settings dialog shows guidance.
102+
* **`shlex.split(posix=True)`**: Linux uses POSIX-mode shell parsing (no special Windows path handling).
103+
* **MAME detection**: Checks `PATH` via `which`, plus standard Linux paths (`/usr/bin`, `/usr/games`, `/usr/local/bin`).
104+
105+
### 2. Deployment (CRITICAL)
106+
* **PEP 668 Era**: Modern Linux distros (Debian 12+, Ubuntu 23.04+, Fedora 38+) block global pip installs. The launcher script handles this with `--break-system-packages` fallback.
107+
* **Recommended Install Methods** (in priority order):
108+
1. System packages: `sudo apt install python3-pyside6 python3-requests mame`
109+
2. venv: `python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt`
110+
3. pip with override: `python3 -m pip install -r requirements.txt --break-system-packages`
111+
* **Never use `pip3` or `pip` directly** in scripts — always use `python3 -m pip` for reliability.
112+
113+
### 3. Known Mantras (inherited from AmpleWin)
114+
* **Visual Parity is King**: Every margin, font size, and color was cross-referenced with macOS.
115+
* **Authorship**: This Linux Port is based on the AmpleWin collaboration between **anomixer** and **Antigravity**.
116+
117+
---
118+
119+
## 📅 Session: 2026-02-17 (Session 2)
120+
121+
### 🎯 Objective: First-Run Experience, Build System & Polish
122+
123+
### ✅ Key Changes:
124+
125+
1. **Launcher Architecture (`AmpleLinux.sh`)**:
126+
* **Refactored to venv**: Switched from system-level `apt` dependencies to a strictly isolated `python3 -m venv` approach.
127+
* **Automated Setup**: Script now auto-creates `.venv`, installs `python3-venv` (if missing), and pip installs `requirements.txt`.
128+
* **Distro Agnostic**: Only depends on `python3-full` and `libxcb-cursor*` (apt) for the base interpreter; all libraries (PySide6) are pulled via pip.
129+
* **ALSA Fix**: Added auto-detection of `/proc/asound` and `usermod -a -G audio` fix for permission issues.
130+
131+
2. **User Experience Enhancements (`main.py`)**:
132+
* **Ubuntu Snap Integration**: If MAME is missing on Ubuntu, offers `sudo snap install mame` with a non-blocking `QProgressDialog`.
133+
* **Configuration Fix**: `ensure_mame_ini` now runs `mame -cc` inside `AmpleLinux/mame` to keep config portable.
134+
* **Path Precision**: `update_command_line` now resolves absolute paths for `-inipath` and `-rompath` (e.g., `/home/user/...`).
135+
* **BGFX Cleanup**: Removed Windows-only Direct3D options.
136+
* **UI Polish**: "Generate VGM" now shows a "Feature not implemented" popup.
137+
138+
3. **Build System (New)**:
139+
* **`make_icon.py`**: Created Linux-specific icon generator (produces standard PNG sizes: 16x16 to 512x512).
140+
* **`build_elf.sh`**: Created PyInstaller build script that uses a temporary venv to bypass PEP 668 restrictions and produce a standalone ELF binary in `dist/`.
141+
142+
### 🔍 Technical Decisions:
143+
* **PySide6 via pip**: Moved away from `python3-pyside2` (apt) because the codebase is written for PySide6. Using venv + pip ensures version consistency and avoids the "externally-managed-environment" error on modern distros.
144+
* **MAME Snap**: For Ubuntu users, Snap is the most reliable way to get a recent MAME version without PPA complexity.

AmpleLinux/AmpleLinux.sh

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/bin/bash
2+
echo "========================================"
3+
echo " Ample - Linux Port Auto Launcher"
4+
echo "========================================"
5+
6+
# --- First-Time Setup: Install system-level dependencies ---
7+
if command -v apt &> /dev/null; then
8+
# libxcb-cursor0 is required by Qt/PySide6 on X11
9+
NEED_INSTALL=0
10+
for pkg in python3-full libxcb-cursor0; do
11+
if ! dpkg -s "$pkg" &> /dev/null 2>&1; then
12+
NEED_INSTALL=1
13+
break
14+
fi
15+
done
16+
17+
if [ $NEED_INSTALL -eq 1 ]; then
18+
echo "[SETUP] Installing required system packages..."
19+
echo " sudo apt install python3-full libxcb-cursor*"
20+
sudo apt install -y python3-full libxcb-cursor*
21+
if [ $? -ne 0 ]; then
22+
echo "[WARN] Some packages may have failed to install. Continuing anyway..."
23+
else
24+
echo "[SETUP] System packages installed successfully."
25+
fi
26+
fi
27+
fi
28+
29+
# --- ALSA Audio Permission Fix ---
30+
if [ -d /proc/asound ]; then
31+
if ! id -nG "$(whoami)" | grep -qw "audio"; then
32+
echo "[SETUP] ALSA audio system detected. Adding user to 'audio' group..."
33+
sudo usermod -a -G audio "$(whoami)"
34+
if [ $? -eq 0 ]; then
35+
echo "[SETUP] Added $(whoami) to 'audio' group. Please log out and back in for this to take effect."
36+
else
37+
echo "[WARN] Failed to add user to 'audio' group. Sound may not work properly."
38+
fi
39+
fi
40+
fi
41+
42+
# Check for Python 3
43+
if ! command -v python3 &> /dev/null; then
44+
echo "[ERROR] Python 3 not found! Please install Python 3.9 or newer."
45+
echo " Ubuntu/Debian: sudo apt install python3 python3-full"
46+
echo " Fedora: sudo dnf install python3 python3-pip"
47+
echo " Arch: sudo pacman -S python python-pip"
48+
exit 1
49+
fi
50+
51+
# Navigate to script directory
52+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
53+
cd "$SCRIPT_DIR"
54+
55+
# --- Virtual Environment Setup ---
56+
VENV_DIR=".venv"
57+
58+
# Ensure python3-venv is available
59+
if ! python3 -m venv --help &> /dev/null; then
60+
echo "[INFO] python3-venv is required but not installed."
61+
if command -v apt &> /dev/null; then
62+
PY_VER=$(python3 -c "import sys; print(f'{sys.version_info.major}.{sys.version_info.minor}')")
63+
echo "[INFO] Installing python3.${PY_VER}-venv ..."
64+
sudo apt install -y "python3.${PY_VER}-venv" python3-full
65+
else
66+
echo "[ERROR] Please install python3-venv for your distro and try again."
67+
exit 1
68+
fi
69+
fi
70+
71+
# Recreate if venv is broken
72+
if [ -d "$VENV_DIR" ] && [ ! -f "$VENV_DIR/bin/activate" ]; then
73+
echo "[WARN] Virtual environment is broken, recreating..."
74+
rm -rf "$VENV_DIR"
75+
fi
76+
77+
# Create venv if it doesn't exist
78+
if [ ! -d "$VENV_DIR" ]; then
79+
echo "[1/3] Creating virtual environment..."
80+
python3 -m venv "$VENV_DIR"
81+
else
82+
echo "[1/3] Virtual environment found."
83+
fi
84+
85+
# Activate venv
86+
source "$VENV_DIR/bin/activate"
87+
88+
# Install/Update dependencies
89+
echo "[2/3] Checking dependencies..."
90+
pip install -r requirements.txt --quiet 2>/dev/null
91+
92+
if [ $? -ne 0 ]; then
93+
echo "[WARN] pip install failed, retrying with upgrade..."
94+
pip install --upgrade pip --quiet 2>/dev/null
95+
pip install -r requirements.txt --quiet
96+
if [ $? -ne 0 ]; then
97+
echo "[ERROR] Failed to install requirements."
98+
deactivate
99+
exit 1
100+
fi
101+
fi
102+
103+
# Run the application
104+
echo "[3/3] Launching Ample..."
105+
python3 main.py
106+
107+
if [ $? -ne 0 ]; then
108+
echo ""
109+
echo "[INFO] Application exited with error."
110+
read -p "Press Enter to continue..."
111+
fi
112+
113+
deactivate

0 commit comments

Comments
 (0)