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

« back to all changes in this revision

Viewing changes to src/mame/drivers/statriv2.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
#include "emu.h"
72
72
#include "cpu/i8085/i8085.h"
73
73
#include "sound/ay8910.h"
74
 
#include "machine/8255ppi.h"
 
74
#include "machine/i8255.h"
75
75
#include "video/tms9927.h"
76
76
#include "machine/nvram.h"
77
77
 
80
80
{
81
81
public:
82
82
        statriv2_state(const machine_config &mconfig, device_type type, const char *tag)
83
 
                : driver_device(mconfig, type, tag) { }
 
83
                : driver_device(mconfig, type, tag) ,
 
84
                m_videoram(*this, "videoram"),
 
85
                m_question_offset(*this, "question_offset"){ }
84
86
 
85
 
        UINT8 *m_videoram;
 
87
        required_shared_ptr<UINT8> m_videoram;
86
88
        tilemap_t *m_tilemap;
87
 
        UINT8 *m_question_offset;
 
89
        required_shared_ptr<UINT8> m_question_offset;
88
90
        UINT8 m_question_offset_low;
89
91
        UINT8 m_question_offset_mid;
90
92
        UINT8 m_question_offset_high;
91
93
        UINT8 m_latched_coin;
92
94
        UINT8 m_last_coin;
 
95
        DECLARE_WRITE8_MEMBER(statriv2_videoram_w);
 
96
        DECLARE_READ8_MEMBER(question_data_r);
 
97
        DECLARE_READ8_MEMBER(laserdisc_io_r);
 
98
        DECLARE_WRITE8_MEMBER(laserdisc_io_w);
 
99
        DECLARE_CUSTOM_INPUT_MEMBER(latched_coin_r);
93
100
};
94
101
 
95
102
 
161
168
 *
162
169
 *************************************/
163
170
 
164
 
static WRITE8_HANDLER( statriv2_videoram_w )
 
171
WRITE8_MEMBER(statriv2_state::statriv2_videoram_w)
165
172
{
166
 
        statriv2_state *state = space->machine().driver_data<statriv2_state>();
167
 
        UINT8 *videoram = state->m_videoram;
 
173
        UINT8 *videoram = m_videoram;
168
174
        videoram[offset] = data;
169
 
        state->m_tilemap->mark_tile_dirty(offset & 0x3ff);
 
175
        m_tilemap->mark_tile_dirty(offset & 0x3ff);
170
176
}
171
177
 
172
178
 
198
204
static INTERRUPT_GEN( statriv2_interrupt )
199
205
{
200
206
        statriv2_state *state = device->machine().driver_data<statriv2_state>();
201
 
        UINT8 new_coin = input_port_read(device->machine(), "COIN");
 
207
        UINT8 new_coin = state->ioport("COIN")->read();
202
208
 
203
209
        /* check the coin inputs once per frame */
204
210
        state->m_latched_coin |= new_coin & (new_coin ^ state->m_last_coin);
216
222
 *
217
223
 *************************************/
218
224
 
219
 
static READ8_HANDLER( question_data_r )
 
225
READ8_MEMBER(statriv2_state::question_data_r)
220
226
{
221
 
        statriv2_state *state = space->machine().driver_data<statriv2_state>();
222
 
        const UINT8 *qrom = space->machine().region("questions")->base();
223
 
        UINT32 qromsize = space->machine().region("questions")->bytes();
 
227
        const UINT8 *qrom = memregion("questions")->base();
 
228
        UINT32 qromsize = memregion("questions")->bytes();
224
229
        UINT32 address;
225
230
 
226
 
        if (state->m_question_offset_high == 0xff)
227
 
                state->m_question_offset[state->m_question_offset_low]++;
 
231
        if (m_question_offset_high == 0xff)
 
232
                m_question_offset[m_question_offset_low]++;
228
233
 
229
 
        address = state->m_question_offset[state->m_question_offset_low];
230
 
        address |= state->m_question_offset[state->m_question_offset_mid] << 8;
231
 
        if (state->m_question_offset_high != 0xff)
232
 
                address |= state->m_question_offset[state->m_question_offset_high] << 16;
 
234
        address = m_question_offset[m_question_offset_low];
 
235
        address |= m_question_offset[m_question_offset_mid] << 8;
 
236
        if (m_question_offset_high != 0xff)
 
237
                address |= m_question_offset[m_question_offset_high] << 16;
233
238
 
234
239
        return (address < qromsize) ? qrom[address] : 0xff;
235
240
}
242
247
 *
243
248
 *************************************/
244
249
 
245
 
static CUSTOM_INPUT( latched_coin_r )
 
250
CUSTOM_INPUT_MEMBER(statriv2_state::latched_coin_r)
246
251
{
247
 
        statriv2_state *state = field.machine().driver_data<statriv2_state>();
248
 
        return state->m_latched_coin;
 
252
        return m_latched_coin;
249
253
}
250
254
 
251
255
 
266
270
 *
267
271
 *************************************/
268
272
 
269
 
static const ppi8255_interface ppi8255_intf =
 
273
static I8255A_INTERFACE( ppi8255_intf )
270
274
{
271
 
/* PPI 8255 group A & B set to Mode 0.
272
 
   Port A, B and lower 4 bits of C set as Input.
273
 
   High 4 bits of C set as Output
274
 
*/
275
 
        DEVCB_INPUT_PORT("IN0"),                /* Port A read */
276
 
        DEVCB_INPUT_PORT("IN1"),                /* Port B read */
277
 
        DEVCB_INPUT_PORT("IN2"),                /* Port C read (Lower Nibble as Input) */
278
 
        DEVCB_NULL,                                     /* Port A write */
279
 
        DEVCB_NULL,                                     /* Port B write */
280
 
        DEVCB_HANDLER(ppi_portc_hi_w)   /* Port C write (High nibble as Output) */
 
275
        /* PPI 8255 group A & B set to Mode 0.
 
276
     Port A, B and lower 4 bits of C set as Input.
 
277
     High 4 bits of C set as Output */
 
278
        DEVCB_INPUT_PORT("IN0"),                        /* Port A read */
 
279
        DEVCB_NULL,                                                     /* Port A write */
 
280
        DEVCB_INPUT_PORT("IN1"),                        /* Port B read */
 
281
        DEVCB_NULL,                                                     /* Port B write */
 
282
        DEVCB_INPUT_PORT("IN2"),                        /* Port C read */
 
283
        DEVCB_HANDLER(ppi_portc_hi_w)           /* Port C write */
281
284
};
282
285
 
283
286
 
284
 
 
285
287
/*************************************
286
288
 *
287
289
 *  Address maps
288
290
 *
289
291
 *************************************/
290
292
 
291
 
static ADDRESS_MAP_START( statriv2_map, AS_PROGRAM, 8 )
 
293
static ADDRESS_MAP_START( statriv2_map, AS_PROGRAM, 8, statriv2_state )
292
294
        AM_RANGE(0x0000, 0x3fff) AM_ROM
293
295
        AM_RANGE(0x4000, 0x43ff) AM_RAM
294
296
        AM_RANGE(0x4800, 0x48ff) AM_RAM AM_SHARE("nvram")
295
 
        AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(statriv2_videoram_w) AM_BASE_MEMBER(statriv2_state, m_videoram)
 
297
        AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(statriv2_videoram_w) AM_SHARE("videoram")
296
298
ADDRESS_MAP_END
297
299
 
298
 
static ADDRESS_MAP_START( statriv2_io_map, AS_IO, 8 )
299
 
        AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi", ppi8255_r, ppi8255_w)
300
 
        AM_RANGE(0x28, 0x2b) AM_READ(question_data_r) AM_WRITEONLY AM_BASE_MEMBER(statriv2_state, m_question_offset)
301
 
        AM_RANGE(0xb0, 0xb1) AM_DEVWRITE("aysnd", ay8910_address_data_w)
302
 
        AM_RANGE(0xb1, 0xb1) AM_DEVREAD("aysnd", ay8910_r)
303
 
        AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE("tms", tms9927_r, tms9927_w)
 
300
static ADDRESS_MAP_START( statriv2_io_map, AS_IO, 8, statriv2_state )
 
301
        AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi8255", i8255_device, read, write)
 
302
        AM_RANGE(0x28, 0x2b) AM_READ(question_data_r) AM_WRITEONLY AM_SHARE("question_offset")
 
303
        AM_RANGE(0xb0, 0xb1) AM_DEVWRITE_LEGACY("aysnd", ay8910_address_data_w)
 
304
        AM_RANGE(0xb1, 0xb1) AM_DEVREAD_LEGACY("aysnd", ay8910_r)
 
305
        AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE_LEGACY("tms", tms9927_r, tms9927_w)
304
306
ADDRESS_MAP_END
305
307
 
306
308
#ifdef UNUSED_CODE
307
 
static ADDRESS_MAP_START( statusbj_io, AS_IO, 8 )
 
309
static ADDRESS_MAP_START( statusbj_io, AS_IO, 8, statriv2_state )
308
310
        ADDRESS_MAP_GLOBAL_MASK(0xff)
309
 
        AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi", ppi8255_r, ppi8255_w)
310
 
        AM_RANGE(0xb0, 0xb1) AM_DEVWRITE("aysnd", ay8910_address_data_w)
311
 
        AM_RANGE(0xb1, 0xb1) AM_DEVREAD("aysnd", ay8910_r)
312
 
        AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE("tms", tms9927_r, tms9927_w)
 
311
        AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi8255", i8255_device, read, write)
 
312
        AM_RANGE(0xb0, 0xb1) AM_DEVWRITE_LEGACY("aysnd", ay8910_address_data_w)
 
313
        AM_RANGE(0xb1, 0xb1) AM_DEVREAD_LEGACY("aysnd", ay8910_r)
 
314
        AM_RANGE(0xc0, 0xcf) AM_DEVREADWRITE_LEGACY("tms", tms9927_r, tms9927_w)
313
315
ADDRESS_MAP_END
314
316
#endif
315
317
 
335
337
        PORT_START("IN1")
336
338
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
337
339
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
338
 
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(latched_coin_r, "COIN")
 
340
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, statriv2_state,latched_coin_r, "COIN")
339
341
        PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
340
342
        PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coinage ) )
341
343
        PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
368
370
        PORT_START("IN1")
369
371
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stand")         PORT_CODE(KEYCODE_4)
370
372
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Select Game")   PORT_CODE(KEYCODE_S)
371
 
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(latched_coin_r, "COIN")
 
373
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, statriv2_state,latched_coin_r, "COIN")
372
374
        PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED )
373
375
        PORT_DIPNAME( 0x10, 0x10, "DIP switch? 10" )
374
376
        PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
443
445
        PORT_START("IN1")
444
446
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Play 1000")
445
447
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
446
 
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM(latched_coin_r, "COIN")
 
448
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, statriv2_state,latched_coin_r, "COIN")
447
449
        PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
448
450
        PORT_SERVICE( 0x10, IP_ACTIVE_HIGH )
449
451
        PORT_DIPNAME( 0x20, 0x20, "Show Correct Answer" )
598
600
        MCFG_NVRAM_ADD_0FILL("nvram")
599
601
 
600
602
        /* 1x 8255 */
601
 
        MCFG_PPI8255_ADD("ppi", ppi8255_intf)
 
603
        MCFG_I8255A_ADD( "ppi8255", ppi8255_intf )
602
604
 
603
605
        /* video hardware */
604
606
        MCFG_SCREEN_ADD("screen", RASTER)
1098
1100
    *                                                   *
1099
1101
    \***************************************************/
1100
1102
 
1101
 
        UINT8 *qrom = machine.region("questions")->base();
1102
 
        UINT32 length = machine.region("questions")->bytes();
 
1103
        UINT8 *qrom = machine.root_device().memregion("questions")->base();
 
1104
        UINT32 length = machine.root_device().memregion("questions")->bytes();
1103
1105
        UINT32 address;
1104
1106
 
1105
1107
        for (address = 0; address < length; address++)
1109
1111
}
1110
1112
 
1111
1113
 
1112
 
static READ8_HANDLER( laserdisc_io_r )
 
1114
READ8_MEMBER(statriv2_state::laserdisc_io_r)
1113
1115
{
1114
1116
        UINT8 result = 0x00;
1115
1117
        if (offset == 1)
1116
1118
                result = 0x18;
1117
 
        mame_printf_debug("%s:ld read ($%02X) = %02X\n", space->machine().describe_context(), 0x28 + offset, result);
 
1119
        mame_printf_debug("%s:ld read ($%02X) = %02X\n", machine().describe_context(), 0x28 + offset, result);
1118
1120
        return result;
1119
1121
}
1120
1122
 
1121
 
static WRITE8_HANDLER( laserdisc_io_w )
 
1123
WRITE8_MEMBER(statriv2_state::laserdisc_io_w)
1122
1124
{
1123
 
        mame_printf_debug("%s:ld write ($%02X) = %02X\n", space->machine().describe_context(), 0x28 + offset, data);
 
1125
        mame_printf_debug("%s:ld write ($%02X) = %02X\n", machine().describe_context(), 0x28 + offset, data);
1124
1126
}
1125
1127
 
1126
1128
static DRIVER_INIT( laserdisc )
1127
1129
{
1128
1130
        address_space *iospace = machine.device("maincpu")->memory().space(AS_IO);
1129
 
        iospace->install_legacy_readwrite_handler(0x28, 0x2b, FUNC(laserdisc_io_r), FUNC(laserdisc_io_w));
 
1131
        statriv2_state *state = machine.driver_data<statriv2_state>();
 
1132
        iospace->install_readwrite_handler(0x28, 0x2b, read8_delegate(FUNC(statriv2_state::laserdisc_io_r), state), write8_delegate(FUNC(statriv2_state::laserdisc_io_w), state));
1130
1133
}
1131
1134
 
1132
1135