summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/bookkeeping.h
blob: 760789fd5369e8b165dcf6d38bcee7dddb0bc59b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// license:BSD-3-Clause
// copyright-holders:Nicola Salmoria
/*********************************************************************

    bookkeeping.h

    Bookkeeping simple machine functions.

*********************************************************************/

#ifndef MAME_EMU_BOOKKEEPING_H
#define MAME_EMU_BOOKKEEPING_H

#pragma once



//**************************************************************************
//  TYPE DEFINITIONS
//**************************************************************************


// ======================> bookkeeping_manager

class bookkeeping_manager
{
public:
	// total # of coin counters
	static constexpr size_t COIN_COUNTERS = 8;

	// construction/destruction
	bookkeeping_manager(running_machine &machine);

	// ----- tickets -----
	// return the number of tickets dispensed
	int get_dispensed_tickets() const;

	// increment the number of dispensed tickets
	void increment_dispensed_tickets(int delta);

	// ----- coin counters -----
	// write to a particular coin counter (clocks on active high edge)
	void coin_counter_w(int num, int on);

	// return the coin count for a given coin
	int coin_counter_get_count(int num);

	// enable/disable coin lockout for a particular coin
	void coin_lockout_w(int num, int on);

	// return current lockout state for a particular coin
	int coin_lockout_get_state(int num);

	// enable/disable global coin lockout
	void coin_lockout_global_w(int on);

	// getters
	running_machine &machine() const { return m_machine; }
private:
	void config_load(config_type cfg_type, util::xml::data_node const *parentnode);
	void config_save(config_type cfg_type, util::xml::data_node *parentnode);

	// internal state
	running_machine &   m_machine;                  // reference to our machine

	u32                 m_dispensed_tickets;
	u32                 m_coin_count[COIN_COUNTERS];
	u32                 m_coinlockedout[COIN_COUNTERS];
	u32                 m_lastcoin[COIN_COUNTERS];
};

#endif  /* MAME_EMU_BOOKKEEPING_H */