Skip to content

Fix allows slots with default values to be set to None#2

Closed
xotmatrix wants to merge 1 commit into
anomixer:masterfrom
xotmatrix:patch-slot-defaults
Closed

Fix allows slots with default values to be set to None#2
xotmatrix wants to merge 1 commit into
anomixer:masterfrom
xotmatrix:patch-slot-defaults

Conversation

@xotmatrix
Copy link
Copy Markdown

This patch addresses a problem with setting certain slots to be empty.

Background:
Attempting to select "—None—" for a slot with a default device will immediately select the default device. I do not have a Mac to compare to, but according to my discussion with Kelvin Sherlock, the correct behavior is to explicitly set the slot to empty in the command line. For example, slot 6 defaults to diskiing when no command line argument is given. To disable it, the empty string -sl6 '' is required. Ample does this, but AmpleWin does not.

Cause:
This problem is caused by initialize_default_slots() being called each time the UI selections change. That function will automatically set a slot to its default value because an empty slot is indistinguishable from an unset slot.

Fix:
According to Kelvin, Ample does not initialize the system when the UI is changed. It simply updates the command line. The first part of this patch removes the reinitialization when the UI is refreshed. The second part sets the slot to a quoted, empty string whenever it has a default=False value in its XML, which I believe means the slot must be explicitly disabled in the command line.

Linux:
It looks like the same fix could be applied to the Linux port. I cannot build for Linux, so I left this alone. I think these are the equivalent lines.

# 0. Re-initialize defaults for any newly appeared slots/devices

item.setData(opt['value'], Qt.UserRole)

anomixer added a commit that referenced this pull request May 11, 2026
@anomixer
Copy link
Copy Markdown
Owner

Hi, xotmatrix

Thank you for the PR! This is a great catch—you correctly identified the issue where slots with defaults were overriding user "None" selections.

After reviewing the implementation, we realized that removing the call to initialize_default_slots entirely might break the automatic initialization of nested slots (e.g., automatically mounting a hard disk when a SCSI card is inserted).

To address your discovery while preserving this automation, we implemented a more robust "None-aware" check: changing if not val: to if slot_name not in self.current_slots:. This respects a deliberate "None" choice while still ensuring newly added cards get their defaults.

We've synced this fix across the Windows, Linux ports and credited your discovery in our project logs. Thanks again for your contribution!

@anomixer anomixer added the bug Something isn't working label May 11, 2026
@anomixer anomixer added this to the 🏆 Awarded: Bug Hunter milestone May 11, 2026
@anomixer anomixer closed this May 11, 2026
@xotmatrix
Copy link
Copy Markdown
Author

xotmatrix commented May 18, 2026

I think your patch only addresses half of the problem. While this patch allows one to set slot 6 to "None", when you start MAME, the Disk II interface will be present because it hasn't been explicitly dissabled.

For slots that have a defined default device, they must be explicitly disabled on the command line. For instance, to empty slot 6, the command line must include -sl6 '' otherwise MAME will use the default value (diskiing Disk II interface).

I think your PR needs more work.
ksherlock#52

@anomixer
Copy link
Copy Markdown
Owner

Hi @xotmatrix

Thank you so much! You are 100% correct, and that's an extremely sharp observation.

What was happening:

The issue was that in mame_launcher.py (and also in the WASM loader for AmpleWeb), the argument builder was filtering out empty string values using a truthiness check (if option: / if (value)). Since "" (representing "None") is Falsy, the builder completely omitted the slot from MAME's command line, causing MAME to fall back to its internal hardware defaults (e.g. loading the Disk II interface in slot 6 anyway).

The Fix:

I have updated the codebase to address the second half of the problem:

  1. Argument Builder Update: Changed the checks to explicitly allow empty strings. In the Python ports, it now checks if option is not None:, and in the Web port, it checks if (value !== undefined && value !== null).
  2. Explicit Disabling: This ensures that -[slot_name] "" is explicitly generated and passed to MAME on launch. MAME receives the empty string and correctly disables the slot device.

I have pushed the updated commits to master. Now, slots set to "None" will actually be disabled in the running emulator. Thanks again for your excellent catch!

I think your patch only addresses half of the problem. While this patch allows one to set slot 6 to "None", when you start MAME, the Disk II interface will be present because it hasn't been explicitly dissabled.

For slots that have a defined default device, they must be explicitly disabled on the command line. For instance, to empty slot 6, the command line must include -sl6 '' otherwise MAME will use the default value (diskiing Disk II interface).

I think your PR needs more work. ksherlock#52

@xotmatrix
Copy link
Copy Markdown
Author

This patch is simple and resolves the main issue. An ideal solution would explicitly disable only the slots that require it (4, 6, Auxiliary), but I don't see a simple way to do it. These slots can be identified in the XML plist, but that data is not present when the arguments are built.

if slot['options'][0]['default'] == False:
    # This is a slot that must be explicitly disabled on the command line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants