diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2016-01-10 11:39:38 +0100 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2016-01-10 11:39:38 +0100 |
commit | 283fbf13a4c8c07e3e45fdae316842d7a8608f2f (patch) | |
tree | dedeae6c0a959ed1c24db3d86ab279b837bae8cb /src/emu/machine | |
parent | 726f7958ca25af6e4a3edb5663e30278c419cdbd (diff) |
generic machine is now bookkeeping (nw)
Diffstat (limited to 'src/emu/machine')
-rw-r--r-- | src/emu/machine/generic.cpp | 255 | ||||
-rw-r--r-- | src/emu/machine/generic.h | 64 |
2 files changed, 0 insertions, 319 deletions
diff --git a/src/emu/machine/generic.cpp b/src/emu/machine/generic.cpp deleted file mode 100644 index 2de58502c7c..00000000000 --- a/src/emu/machine/generic.cpp +++ /dev/null @@ -1,255 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -/********************************************************************* - - generic.c - - Generic simple machine functions. - -*********************************************************************/ - -#include "emu.h" -#include "config.h" - - - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - -static void counters_load(running_machine &machine, int config_type, xml_data_node *parentnode); -static void counters_save(running_machine &machine, int config_type, xml_data_node *parentnode); - - - -/*************************************************************************** - TYPE DEFINITIONS -***************************************************************************/ - -struct generic_machine_private -{ - /* tickets and coin counters */ - UINT32 dispensed_tickets; - UINT32 coin_count[COIN_COUNTERS]; - UINT32 coinlockedout[COIN_COUNTERS]; - UINT32 lastcoin[COIN_COUNTERS]; -}; - - - -/*************************************************************************** - INITIALIZATION -***************************************************************************/ - -/*------------------------------------------------- - generic_machine_init - initialize globals and - register for save states --------------------------------------------------*/ - -void generic_machine_init(running_machine &machine) -{ - generic_machine_private *state; - int counternum; - - /* allocate our state */ - machine.generic_machine_data = auto_alloc_clear(machine, <generic_machine_private>()); - state = machine.generic_machine_data; - - /* reset coin counters */ - for (counternum = 0; counternum < COIN_COUNTERS; counternum++) - { - state->lastcoin[counternum] = 0; - state->coinlockedout[counternum] = 0; - } - - /* register coin save state */ - machine.save().save_item(NAME(state->coin_count)); - machine.save().save_item(NAME(state->coinlockedout)); - machine.save().save_item(NAME(state->lastcoin)); - - /* register for configuration */ - config_register(machine, "counters", config_saveload_delegate(FUNC(counters_load), &machine), config_saveload_delegate(FUNC(counters_save), &machine)); -} - - - -/*************************************************************************** - TICKETS -***************************************************************************/ - -/*------------------------------------------------- - get_dispensed_tickets - return the number of - tickets dispensed --------------------------------------------------*/ - -int get_dispensed_tickets(running_machine &machine) -{ - generic_machine_private *state = machine.generic_machine_data; - return state->dispensed_tickets; -} - - -/*------------------------------------------------- - increment_dispensed_tickets - increment the - number of dispensed tickets --------------------------------------------------*/ - -void increment_dispensed_tickets(running_machine &machine, int delta) -{ - generic_machine_private *state = machine.generic_machine_data; - state->dispensed_tickets += delta; -} - - - -/*************************************************************************** - COIN COUNTERS -***************************************************************************/ - -/*------------------------------------------------- - counters_load - load the state of the counters - and tickets --------------------------------------------------*/ - -static void counters_load(running_machine &machine, int config_type, xml_data_node *parentnode) -{ - generic_machine_private *state = machine.generic_machine_data; - xml_data_node *coinnode, *ticketnode; - - /* on init, reset the counters */ - if (config_type == CONFIG_TYPE_INIT) - { - memset(state->coin_count, 0, sizeof(state->coin_count)); - state->dispensed_tickets = 0; - } - - /* only care about game-specific data */ - if (config_type != CONFIG_TYPE_GAME) - return; - - /* might not have any data */ - if (parentnode == nullptr) - return; - - /* iterate over coins nodes */ - for (coinnode = xml_get_sibling(parentnode->child, "coins"); coinnode; coinnode = xml_get_sibling(coinnode->next, "coins")) - { - int index = xml_get_attribute_int(coinnode, "index", -1); - if (index >= 0 && index < COIN_COUNTERS) - state->coin_count[index] = xml_get_attribute_int(coinnode, "number", 0); - } - - /* get the single tickets node */ - ticketnode = xml_get_sibling(parentnode->child, "tickets"); - if (ticketnode != nullptr) - state->dispensed_tickets = xml_get_attribute_int(ticketnode, "number", 0); -} - - -/*------------------------------------------------- - counters_save - save the state of the counters - and tickets --------------------------------------------------*/ - -static void counters_save(running_machine &machine, int config_type, xml_data_node *parentnode) -{ - generic_machine_private *state = machine.generic_machine_data; - int i; - - /* only care about game-specific data */ - if (config_type != CONFIG_TYPE_GAME) - return; - - /* iterate over coin counters */ - for (i = 0; i < COIN_COUNTERS; i++) - if (state->coin_count[i] != 0) - { - xml_data_node *coinnode = xml_add_child(parentnode, "coins", nullptr); - if (coinnode != nullptr) - { - xml_set_attribute_int(coinnode, "index", i); - xml_set_attribute_int(coinnode, "number", state->coin_count[i]); - } - } - - /* output tickets */ - if (state->dispensed_tickets != 0) - { - xml_data_node *tickets = xml_add_child(parentnode, "tickets", nullptr); - if (tickets != nullptr) - xml_set_attribute_int(tickets, "number", state->dispensed_tickets); - } -} - - -/*------------------------------------------------- - coin_counter_w - sets input for coin counter --------------------------------------------------*/ - -void coin_counter_w(running_machine &machine, int num, int on) -{ - generic_machine_private *state = machine.generic_machine_data; - if (num >= ARRAY_LENGTH(state->coin_count)) - return; - - /* Count it only if the data has changed from 0 to non-zero */ - if (on && (state->lastcoin[num] == 0)) - state->coin_count[num]++; - state->lastcoin[num] = on; -} - - -/*------------------------------------------------- - coin_counter_get_count - return the coin count - for a given coin --------------------------------------------------*/ - -int coin_counter_get_count(running_machine &machine, int num) -{ - generic_machine_private *state = machine.generic_machine_data; - if (num >= ARRAY_LENGTH(state->coin_count)) - return 0; - return state->coin_count[num]; -} - - -/*------------------------------------------------- - coin_lockout_w - locks out one coin input --------------------------------------------------*/ - -void coin_lockout_w(running_machine &machine, int num,int on) -{ - generic_machine_private *state = machine.generic_machine_data; - if (num >= ARRAY_LENGTH(state->coinlockedout)) - return; - state->coinlockedout[num] = on; -} - - -/*------------------------------------------------- - coin_lockout_get_state - return current lockout - state for a particular coin --------------------------------------------------*/ - -int coin_lockout_get_state(running_machine &machine, int num) -{ - generic_machine_private *state = machine.generic_machine_data; - if (num >= ARRAY_LENGTH(state->coinlockedout)) - return FALSE; - return state->coinlockedout[num]; -} - - -/*------------------------------------------------- - coin_lockout_global_w - locks out all the coin - inputs --------------------------------------------------*/ - -void coin_lockout_global_w(running_machine &machine, int on) -{ - generic_machine_private *state = machine.generic_machine_data; - int i; - - for (i = 0; i < ARRAY_LENGTH(state->coinlockedout); i++) - coin_lockout_w(machine, i, on); -} diff --git a/src/emu/machine/generic.h b/src/emu/machine/generic.h deleted file mode 100644 index 38660d9a386..00000000000 --- a/src/emu/machine/generic.h +++ /dev/null @@ -1,64 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Nicola Salmoria -/********************************************************************* - - generic.h - - Generic simple machine functions. - -*********************************************************************/ - -#pragma once - -#ifndef __MACHINE_GENERIC_H__ -#define __MACHINE_GENERIC_H__ - - - -/*************************************************************************** - CONSTANTS -***************************************************************************/ - -/* total # of coin counters */ -#define COIN_COUNTERS 8 - -/*************************************************************************** - FUNCTION PROTOTYPES -***************************************************************************/ - - -/* ----- initialization ----- */ - -/* set up all the common systems */ -void generic_machine_init(running_machine &machine); - - - -/* ----- tickets ----- */ - -/* return the number of tickets dispensed */ -int get_dispensed_tickets(running_machine &machine); - -/* increment the number of dispensed tickets */ -void increment_dispensed_tickets(running_machine &machine, int delta); - - - -/* ----- coin counters ----- */ - -/* write to a particular coin counter (clocks on active high edge) */ -void coin_counter_w(running_machine &machine, int num, int on); - -/* return the coin count for a given coin */ -int coin_counter_get_count(running_machine &machine, int num); - -/* enable/disable coin lockout for a particular coin */ -void coin_lockout_w(running_machine &machine, int num, int on); - -/* return current lockout state for a particular coin */ -int coin_lockout_get_state(running_machine &machine, int num); - -/* enable/disable global coin lockout */ -void coin_lockout_global_w(running_machine &machine, int on); - -#endif /* __MACHINE_GENERIC_H__ */ |