~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to mess/src/mame/audio/cyberbal.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 
3
 
    Cyberball 68000 sound simulator
4
 
 
5
 
****************************************************************************/
6
 
 
7
 
#include "emu.h"
8
 
#include "sound/dac.h"
9
 
#include "sound/2151intf.h"
10
 
#include "machine/atarigen.h"
11
 
#include "includes/cyberbal.h"
12
 
 
13
 
 
14
 
static void update_sound_68k_interrupts(running_machine &machine);
15
 
 
16
 
 
17
 
 
18
 
void cyberbal_sound_reset(running_machine &machine)
19
 
{
20
 
        cyberbal_state *state = machine.driver_data<cyberbal_state>();
21
 
 
22
 
        /* reset the sound system */
23
 
        state->m_bank_base = &machine.region("audiocpu")->base()[0x10000];
24
 
        memory_set_bankptr(machine, "soundbank", &state->m_bank_base[0x0000]);
25
 
        state->m_fast_68k_int = state->m_io_68k_int = 0;
26
 
        state->m_sound_data_from_68k = state->m_sound_data_from_6502 = 0;
27
 
        state->m_sound_data_from_68k_ready = state->m_sound_data_from_6502_ready = 0;
28
 
}
29
 
 
30
 
 
31
 
 
32
 
/*************************************
33
 
 *
34
 
 *  6502 Sound Interface
35
 
 *
36
 
 *************************************/
37
 
 
38
 
READ8_HANDLER( cyberbal_special_port3_r )
39
 
{
40
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
41
 
        int temp = input_port_read(space->machine(), "JSAII");
42
 
        if (!(input_port_read(space->machine(), "IN0") & 0x8000)) temp ^= 0x80;
43
 
        if (state->m_cpu_to_sound_ready) temp ^= 0x40;
44
 
        if (state->m_sound_to_cpu_ready) temp ^= 0x20;
45
 
        return temp;
46
 
}
47
 
 
48
 
 
49
 
READ8_HANDLER( cyberbal_sound_6502_stat_r )
50
 
{
51
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
52
 
        int temp = 0xff;
53
 
        if (state->m_sound_data_from_6502_ready) temp ^= 0x80;
54
 
        if (state->m_sound_data_from_68k_ready) temp ^= 0x40;
55
 
        return temp;
56
 
}
57
 
 
58
 
 
59
 
WRITE8_HANDLER( cyberbal_sound_bank_select_w )
60
 
{
61
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
62
 
        memory_set_bankptr(space->machine(), "soundbank", &state->m_bank_base[0x1000 * ((data >> 6) & 3)]);
63
 
        coin_counter_w(space->machine(), 1, (data >> 5) & 1);
64
 
        coin_counter_w(space->machine(), 0, (data >> 4) & 1);
65
 
        cputag_set_input_line(space->machine(), "dac", INPUT_LINE_RESET, (data & 0x08) ? CLEAR_LINE : ASSERT_LINE);
66
 
        if (!(data & 0x01)) devtag_reset(space->machine(), "ymsnd");
67
 
}
68
 
 
69
 
 
70
 
READ8_HANDLER( cyberbal_sound_68k_6502_r )
71
 
{
72
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
73
 
        state->m_sound_data_from_68k_ready = 0;
74
 
        return state->m_sound_data_from_68k;
75
 
}
76
 
 
77
 
 
78
 
WRITE8_HANDLER( cyberbal_sound_68k_6502_w )
79
 
{
80
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
81
 
 
82
 
        state->m_sound_data_from_6502 = data;
83
 
        state->m_sound_data_from_6502_ready = 1;
84
 
 
85
 
        if (!state->m_io_68k_int)
86
 
        {
87
 
                state->m_io_68k_int = 1;
88
 
                update_sound_68k_interrupts(space->machine());
89
 
        }
90
 
}
91
 
 
92
 
 
93
 
 
94
 
/*************************************
95
 
 *
96
 
 *  68000 Sound Interface
97
 
 *
98
 
 *************************************/
99
 
 
100
 
static void update_sound_68k_interrupts(running_machine &machine)
101
 
{
102
 
        cyberbal_state *state = machine.driver_data<cyberbal_state>();
103
 
        cputag_set_input_line(machine, "dac", 6, state->m_fast_68k_int ? ASSERT_LINE : CLEAR_LINE);
104
 
        cputag_set_input_line(machine, "dac", 2, state->m_io_68k_int   ? ASSERT_LINE : CLEAR_LINE);
105
 
}
106
 
 
107
 
 
108
 
INTERRUPT_GEN( cyberbal_sound_68k_irq_gen )
109
 
{
110
 
        cyberbal_state *state = device->machine().driver_data<cyberbal_state>();
111
 
        if (!state->m_fast_68k_int)
112
 
        {
113
 
                state->m_fast_68k_int = 1;
114
 
                update_sound_68k_interrupts(device->machine());
115
 
        }
116
 
}
117
 
 
118
 
 
119
 
WRITE16_HANDLER( cyberbal_io_68k_irq_ack_w )
120
 
{
121
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
122
 
        if (state->m_io_68k_int)
123
 
        {
124
 
                state->m_io_68k_int = 0;
125
 
                update_sound_68k_interrupts(space->machine());
126
 
        }
127
 
}
128
 
 
129
 
 
130
 
READ16_HANDLER( cyberbal_sound_68k_r )
131
 
{
132
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
133
 
        int temp = (state->m_sound_data_from_6502 << 8) | 0xff;
134
 
 
135
 
        state->m_sound_data_from_6502_ready = 0;
136
 
 
137
 
        if (state->m_sound_data_from_6502_ready) temp ^= 0x08;
138
 
        if (state->m_sound_data_from_68k_ready) temp ^= 0x04;
139
 
        return temp;
140
 
}
141
 
 
142
 
 
143
 
WRITE16_HANDLER( cyberbal_sound_68k_w )
144
 
{
145
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
146
 
        if (ACCESSING_BITS_8_15)
147
 
        {
148
 
                state->m_sound_data_from_68k = (data >> 8) & 0xff;
149
 
                state->m_sound_data_from_68k_ready = 1;
150
 
        }
151
 
}
152
 
 
153
 
 
154
 
WRITE16_HANDLER( cyberbal_sound_68k_dac_w )
155
 
{
156
 
        cyberbal_state *state = space->machine().driver_data<cyberbal_state>();
157
 
        device_t *dac = space->machine().device((offset & 8) ? "dac2" : "dac1");
158
 
        dac_data_16_w(dac, (((data >> 3) & 0x800) | ((data >> 2) & 0x7ff)) << 4);
159
 
 
160
 
        if (state->m_fast_68k_int)
161
 
        {
162
 
                state->m_fast_68k_int = 0;
163
 
                update_sound_68k_interrupts(space->machine());
164
 
        }
165
 
}