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

« back to all changes in this revision

Viewing changes to src/mame/machine/stfight.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
*/
37
37
 
38
 
static UINT8 *decrypt;
39
 
static int adpcm_data_offs;
40
 
static int adpcm_data_end;
41
 
static int toggle;
42
 
static UINT8 fm_data;
43
 
 
44
 
static int coin_mech_latch[2];
45
 
static int stfight_coin_mech_query_active = 0;
46
 
static int stfight_coin_mech_query;
47
 
 
48
 
 
49
38
 
50
39
DRIVER_INIT( empcity )
51
40
{
52
 
        address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
53
 
        UINT8 *rom = machine->region("maincpu")->base();
 
41
        stfight_state *state = machine.driver_data<stfight_state>();
 
42
        address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
 
43
        UINT8 *rom = machine.region("maincpu")->base();
54
44
        int A;
55
45
 
56
 
        decrypt = auto_alloc_array(machine, UINT8, 0x8000);
57
 
        space->set_decrypted_region(0x0000, 0x7fff, decrypt);
 
46
        state->m_decrypt = auto_alloc_array(machine, UINT8, 0x8000);
 
47
        space->set_decrypted_region(0x0000, 0x7fff, state->m_decrypt);
58
48
 
59
49
        for (A = 0;A < 0x8000;A++)
60
50
        {
61
51
                UINT8 src = rom[A];
62
52
 
63
53
                // decode opcode
64
 
                decrypt[A] =
 
54
                state->m_decrypt[A] =
65
55
                                ( src & 0xA6 ) |
66
56
                                ( ( ( ( src << 2 ) ^ src ) << 3 ) & 0x40 ) |
67
57
                                ( ~( ( src ^ ( A >> 1 ) ) >> 2 ) & 0x10 ) |
80
70
 
81
71
DRIVER_INIT( stfight )
82
72
{
 
73
        stfight_state *state = machine.driver_data<stfight_state>();
83
74
        DRIVER_INIT_CALL(empcity);
84
75
 
85
76
        /* patch out a tight loop during startup - is the code waiting */
86
77
        /* for NMI to wake it up? */
87
 
        decrypt[0xb1] = 0x00;
88
 
        decrypt[0xb2] = 0x00;
89
 
        decrypt[0xb3] = 0x00;
90
 
        decrypt[0xb4] = 0x00;
91
 
        decrypt[0xb5] = 0x00;
 
78
        state->m_decrypt[0xb1] = 0x00;
 
79
        state->m_decrypt[0xb2] = 0x00;
 
80
        state->m_decrypt[0xb3] = 0x00;
 
81
        state->m_decrypt[0xb4] = 0x00;
 
82
        state->m_decrypt[0xb5] = 0x00;
92
83
}
93
84
 
94
85
MACHINE_RESET( stfight )
95
86
{
96
 
        address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
97
 
        adpcm_data_offs = adpcm_data_end = 0;
98
 
        toggle = 0;
99
 
        fm_data = 0;
100
 
        coin_mech_latch[0] = 0x02;
101
 
        coin_mech_latch[1] = 0x01;
 
87
        stfight_state *state = machine.driver_data<stfight_state>();
 
88
        address_space *space = machine.device("maincpu")->memory().space(AS_PROGRAM);
 
89
        state->m_adpcm_data_offs = state->m_adpcm_data_end = 0;
 
90
        state->m_toggle = 0;
 
91
        state->m_fm_data = 0;
 
92
        state->m_coin_mech_latch[0] = 0x02;
 
93
        state->m_coin_mech_latch[1] = 0x01;
102
94
 
103
 
        stfight_coin_mech_query_active = 0;
104
 
        stfight_coin_mech_query = 0;
 
95
        state->m_coin_mech_query_active = 0;
 
96
        state->m_coin_mech_query = 0;
105
97
 
106
98
    // initialise rom bank
107
99
    stfight_bank_w( space, 0, 0 );
111
103
// - in fact I don't even know how/where it's switched in!
112
104
static WRITE8_HANDLER( stfight_bank_w )
113
105
{
114
 
        UINT8   *ROM2 = space->machine->region("maincpu")->base() + 0x10000;
 
106
        UINT8   *ROM2 = space->machine().region("maincpu")->base() + 0x10000;
115
107
 
116
 
        memory_set_bankptr(space->machine,  "bank1", &ROM2[data<<14] );
 
108
        memory_set_bankptr(space->machine(),  "bank1", &ROM2[data<<14] );
117
109
}
118
110
 
119
111
/*
129
121
INTERRUPT_GEN( stfight_vb_interrupt )
130
122
{
131
123
    // Do a RST10
132
 
    cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xd7);
133
 
    timer_set(device->machine, ATTOTIME_IN_HZ(120), NULL, 0, stfight_interrupt_1);
 
124
    device_set_input_line_and_vector(device, 0, HOLD_LINE, 0xd7);
 
125
    device->machine().scheduler().timer_set(attotime::from_hz(120), FUNC(stfight_interrupt_1));
134
126
}
135
127
 
136
128
/*
140
132
// Perhaps define dipswitches as active low?
141
133
READ8_HANDLER( stfight_dsw_r )
142
134
{
143
 
    return( ~input_port_read(space->machine, offset ? "DSW1" : "DSW0") );
 
135
    return( ~input_port_read(space->machine(), offset ? "DSW1" : "DSW0") );
144
136
}
145
137
 
146
138
READ8_HANDLER( stfight_coin_r )
147
139
{
 
140
        stfight_state *state = space->machine().driver_data<stfight_state>();
148
141
    int coin_mech_data;
149
142
    int i;
150
143
 
151
144
    // Was the coin mech queried by software?
152
 
    if( stfight_coin_mech_query_active )
 
145
    if( state->m_coin_mech_query_active )
153
146
    {
154
 
        stfight_coin_mech_query_active = 0;
155
 
        return( (~stfight_coin_mech_query) & 0x03 );
 
147
        state->m_coin_mech_query_active = 0;
 
148
        return( (~state->m_coin_mech_query) & 0x03 );
156
149
    }
157
150
 
158
151
    /*
162
155
     *        since it's read by the 30Hz interrupt ISR
163
156
     */
164
157
 
165
 
    coin_mech_data = input_port_read(space->machine, "COIN");
 
158
    coin_mech_data = input_port_read(space->machine(), "COIN");
166
159
 
167
160
    for( i=0; i<2; i++ )
168
161
    {
169
162
        /* Only valid on signal edge */
170
 
        if( ( coin_mech_data & (1<<i) ) != coin_mech_latch[i] )
171
 
            coin_mech_latch[i] = coin_mech_data & (1<<i);
 
163
        if( ( coin_mech_data & (1<<i) ) != state->m_coin_mech_latch[i] )
 
164
            state->m_coin_mech_latch[i] = coin_mech_data & (1<<i);
172
165
        else
173
166
            coin_mech_data |= coin_mech_data & (1<<i);
174
167
    }
178
171
 
179
172
WRITE8_HANDLER( stfight_coin_w )
180
173
{
 
174
        stfight_state *state = space->machine().driver_data<stfight_state>();
181
175
    // interrogate coin mech
182
 
    stfight_coin_mech_query_active = 1;
183
 
    stfight_coin_mech_query = data;
 
176
    state->m_coin_mech_query_active = 1;
 
177
    state->m_coin_mech_query = data;
184
178
}
185
179
 
186
180
/*
199
193
 
200
194
void stfight_adpcm_int(device_t *device)
201
195
{
202
 
        UINT8 *SAMPLES = device->machine->region("adpcm")->base();
203
 
        int adpcm_data = SAMPLES[adpcm_data_offs & 0x7fff];
 
196
        stfight_state *state = device->machine().driver_data<stfight_state>();
 
197
        UINT8 *SAMPLES = device->machine().region("adpcm")->base();
 
198
        int adpcm_data = SAMPLES[state->m_adpcm_data_offs & 0x7fff];
204
199
 
205
200
    // finished playing sample?
206
 
    if( adpcm_data_offs == adpcm_data_end )
 
201
    if( state->m_adpcm_data_offs == state->m_adpcm_data_end )
207
202
    {
208
203
        msm5205_reset_w( device, 1 );
209
204
        return;
210
205
    }
211
206
 
212
 
        if( toggle == 0 )
 
207
        if( state->m_toggle == 0 )
213
208
                msm5205_data_w( device, ( adpcm_data >> 4 ) & 0x0f );
214
209
        else
215
210
        {
216
211
                msm5205_data_w( device, adpcm_data & 0x0f );
217
 
                adpcm_data_offs++;
 
212
                state->m_adpcm_data_offs++;
218
213
        }
219
214
 
220
 
        toggle ^= 1;
 
215
        state->m_toggle ^= 1;
221
216
}
222
217
 
223
218
WRITE8_DEVICE_HANDLER( stfight_adpcm_control_w )
224
219
{
 
220
        stfight_state *state = device->machine().driver_data<stfight_state>();
225
221
    if( data < 0x08 )
226
222
    {
227
 
        adpcm_data_offs = sampleLimits[data];
228
 
        adpcm_data_end = sampleLimits[data+1];
 
223
        state->m_adpcm_data_offs = sampleLimits[data];
 
224
        state->m_adpcm_data_end = sampleLimits[data+1];
229
225
    }
230
226
 
231
227
    msm5205_reset_w( device, data & 0x08 ? 1 : 0 );
241
237
 
242
238
WRITE8_HANDLER( stfight_fm_w )
243
239
{
 
240
        stfight_state *state = space->machine().driver_data<stfight_state>();
244
241
    // the sound cpu ignores any fm data without bit 7 set
245
 
    fm_data = 0x80 | data;
 
242
    state->m_fm_data = 0x80 | data;
246
243
}
247
244
 
248
245
READ8_HANDLER( stfight_fm_r )
249
246
{
250
 
    int data = fm_data;
 
247
        stfight_state *state = space->machine().driver_data<stfight_state>();
 
248
    int data = state->m_fm_data;
251
249
 
252
250
    // clear the latch?!?
253
 
    fm_data &= 0x7f;
 
251
    state->m_fm_data &= 0x7f;
254
252
 
255
253
    return( data );
256
254
}