mirror of
https://github.com/holub/mame
synced 2025-07-01 16:19:38 +03:00
Added a validity check against reading input ports at init time.
This commit is contained in:
parent
6a1d0b762c
commit
a93fb6b1bf
@ -1275,6 +1275,7 @@ input_port_value input_port_read_direct(const input_port_config *port)
|
|||||||
input_port_value input_port_read(running_machine *machine, const char *tag)
|
input_port_value input_port_read(running_machine *machine, const char *tag)
|
||||||
{
|
{
|
||||||
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
|
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
|
||||||
|
assert_always(mame_get_phase(machine) != MAME_PHASE_INIT, "Input ports cannot be read at init time!");
|
||||||
if (port == NULL)
|
if (port == NULL)
|
||||||
fatalerror("Unable to locate input port '%s'", tag);
|
fatalerror("Unable to locate input port '%s'", tag);
|
||||||
return input_port_read_direct(port);
|
return input_port_read_direct(port);
|
||||||
@ -1290,6 +1291,7 @@ input_port_value input_port_read(running_machine *machine, const char *tag)
|
|||||||
input_port_value input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue)
|
input_port_value input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue)
|
||||||
{
|
{
|
||||||
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
|
const input_port_config *port = input_port_by_tag(machine->portconfig, tag);
|
||||||
|
assert_always(mame_get_phase(machine) != MAME_PHASE_INIT, "Input ports cannot be read at init time!");
|
||||||
return (port == NULL) ? defvalue : input_port_read_direct(port);
|
return (port == NULL) ? defvalue : input_port_read_direct(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,6 +1304,7 @@ input_port_value input_port_read_safe(running_machine *machine, const char *tag,
|
|||||||
input_port_value input_port_read_indexed(running_machine *machine, int portnum)
|
input_port_value input_port_read_indexed(running_machine *machine, int portnum)
|
||||||
{
|
{
|
||||||
const input_port_config *port = input_port_by_index(machine->portconfig, portnum);
|
const input_port_config *port = input_port_by_index(machine->portconfig, portnum);
|
||||||
|
assert_always(mame_get_phase(machine) != MAME_PHASE_INIT, "Input ports cannot be read at init time!");
|
||||||
return (port == NULL) ? 0 : input_port_read_direct(port);
|
return (port == NULL) ? 0 : input_port_read_direct(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user