~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/mame/drivers/clayshoo.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
 
    Atari Clay Shoot hardware
4
 
 
5
 
    driver by Zsolt Vasvari
6
 
 
7
 
    Games supported:
8
 
        * Clay Shoot
9
 
 
10
 
    Known issues:
11
 
        * none at this time
12
 
 
13
 
****************************************************************************/
14
 
 
15
 
#include "emu.h"
16
 
#include "cpu/z80/z80.h"
17
 
#include "machine/8255ppi.h"
18
 
 
19
 
 
20
 
class clayshoo_state : public driver_device
21
 
{
22
 
public:
23
 
        clayshoo_state(const machine_config &mconfig, device_type type, const char *tag)
24
 
                : driver_device(mconfig, type, tag) { }
25
 
 
26
 
        /* memory pointers */
27
 
        UINT8 *   m_videoram;
28
 
        size_t    m_videoram_size;
29
 
 
30
 
        /* misc */
31
 
        emu_timer *m_analog_timer_1, *m_analog_timer_2;
32
 
        UINT8 m_input_port_select;
33
 
        UINT8 m_analog_port_val;
34
 
};
35
 
 
36
 
 
37
 
/*************************************
38
 
 *
39
 
 *  Digital control handling functions
40
 
 *
41
 
 *************************************/
42
 
 
43
 
static WRITE8_DEVICE_HANDLER( input_port_select_w )
44
 
{
45
 
        clayshoo_state *state = device->machine().driver_data<clayshoo_state>();
46
 
        state->m_input_port_select = data;
47
 
}
48
 
 
49
 
 
50
 
static UINT8 difficulty_input_port_r( running_machine &machine, int bit )
51
 
{
52
 
        UINT8 ret = 0;
53
 
 
54
 
        /* read fake port and remap the buttons to 2 bits */
55
 
        UINT8   raw = input_port_read(machine, "FAKE");
56
 
 
57
 
        if (raw & (1 << (bit + 1)))
58
 
                ret = 0x03;             /* expert */
59
 
        else if (raw & (1 << (bit + 2)))
60
 
                ret = 0x01;             /* pro */
61
 
        else
62
 
                ret = 0x00;             /* amateur otherwise */
63
 
 
64
 
        return ret;
65
 
}
66
 
 
67
 
 
68
 
static READ8_DEVICE_HANDLER( input_port_r )
69
 
{
70
 
        clayshoo_state *state = device->machine().driver_data<clayshoo_state>();
71
 
        UINT8 ret = 0;
72
 
 
73
 
        switch (state->m_input_port_select)
74
 
        {
75
 
        case 0x01:      ret = input_port_read(device->machine(), "IN0"); break;
76
 
        case 0x02:      ret = input_port_read(device->machine(), "IN1"); break;
77
 
        case 0x04:      ret = (input_port_read(device->machine(), "IN2") & 0xf0) | difficulty_input_port_r(device->machine(), 0) |
78
 
                                          (difficulty_input_port_r(device->machine(), 3) << 2); break;
79
 
        case 0x08:      ret = input_port_read(device->machine(), "IN3"); break;
80
 
        case 0x10:
81
 
        case 0x20:      break;  /* these two are not really used */
82
 
        default: logerror("Unexpected port read: %02X\n", state->m_input_port_select);
83
 
        }
84
 
        return ret;
85
 
}
86
 
 
87
 
 
88
 
 
89
 
/*************************************
90
 
 *
91
 
 *  Analog control handling functions
92
 
 *
93
 
 *************************************/
94
 
 
95
 
static TIMER_CALLBACK( reset_analog_bit )
96
 
{
97
 
        clayshoo_state *state = machine.driver_data<clayshoo_state>();
98
 
        state->m_analog_port_val &= ~param;
99
 
}
100
 
 
101
 
 
102
 
static attotime compute_duration( device_t *device, int analog_pos )
103
 
{
104
 
        /* the 58 comes from the length of the loop used to
105
 
       read the analog position */
106
 
        return downcast<cpu_device *>(device)->cycles_to_attotime(58 * analog_pos);
107
 
}
108
 
 
109
 
 
110
 
static WRITE8_HANDLER( analog_reset_w )
111
 
{
112
 
        clayshoo_state *state = space->machine().driver_data<clayshoo_state>();
113
 
 
114
 
        /* reset the analog value, and start the two times that will fire
115
 
       off in a short period proportional to the position of the
116
 
       analog control and set the appropriate bit. */
117
 
 
118
 
        state->m_analog_port_val = 0xff;
119
 
 
120
 
        state->m_analog_timer_1->adjust(compute_duration(&space->device(), input_port_read(space->machine(), "AN1")), 0x02);
121
 
        state->m_analog_timer_2->adjust(compute_duration(&space->device(), input_port_read(space->machine(), "AN2")), 0x01);
122
 
}
123
 
 
124
 
 
125
 
static READ8_HANDLER( analog_r )
126
 
{
127
 
        clayshoo_state *state = space->machine().driver_data<clayshoo_state>();
128
 
        return state->m_analog_port_val;
129
 
}
130
 
 
131
 
 
132
 
static void create_analog_timers( running_machine &machine )
133
 
{
134
 
        clayshoo_state *state = machine.driver_data<clayshoo_state>();
135
 
        state->m_analog_timer_1 = machine.scheduler().timer_alloc(FUNC(reset_analog_bit));
136
 
        state->m_analog_timer_2 = machine.scheduler().timer_alloc(FUNC(reset_analog_bit));
137
 
}
138
 
 
139
 
 
140
 
 
141
 
/*************************************
142
 
 *
143
 
 *  Machine setup
144
 
 *
145
 
 *************************************/
146
 
 
147
 
static const ppi8255_interface ppi8255_intf[2] =
148
 
{
149
 
        {
150
 
                DEVCB_NULL,                                     /* Port A read */
151
 
                DEVCB_NULL,                                     /* Port B read */
152
 
                DEVCB_NULL,                                     /* Port C read */
153
 
                DEVCB_NULL,                                     /* Port A write */
154
 
                DEVCB_NULL,                                     /* Port B write */
155
 
                DEVCB_NULL                                      /* Port C write */
156
 
        },
157
 
        {
158
 
                DEVCB_NULL,                                     /* Port A read */
159
 
                DEVCB_HANDLER(input_port_r),/* Port B read */
160
 
                DEVCB_NULL,                                     /* Port C read */
161
 
                DEVCB_HANDLER(input_port_select_w),     /* Port A write */
162
 
                DEVCB_NULL,                                     /* Port B write */
163
 
                DEVCB_NULL                                      /* sound effects, Port C write */
164
 
        }
165
 
};
166
 
 
167
 
 
168
 
static MACHINE_START( clayshoo )
169
 
{
170
 
        clayshoo_state *state = machine.driver_data<clayshoo_state>();
171
 
        create_analog_timers(machine);
172
 
 
173
 
        /* register for state saving */
174
 
        state->save_item(NAME(state->m_input_port_select));
175
 
        state->save_item(NAME(state->m_analog_port_val));
176
 
}
177
 
 
178
 
 
179
 
 
180
 
/*************************************
181
 
 *
182
 
 *  Video hardware
183
 
 *
184
 
 *************************************/
185
 
 
186
 
static SCREEN_UPDATE( clayshoo )
187
 
{
188
 
        clayshoo_state *state = screen->machine().driver_data<clayshoo_state>();
189
 
        offs_t offs;
190
 
 
191
 
        for (offs = 0; offs < state->m_videoram_size; offs++)
192
 
        {
193
 
                int i;
194
 
                UINT8 x = offs << 3;
195
 
                UINT8 y = ~(offs >> 5);
196
 
                UINT8 data = state->m_videoram[offs];
197
 
 
198
 
                for (i = 0; i < 8; i++)
199
 
                {
200
 
                        pen_t pen = (data & 0x80) ? RGB_WHITE : RGB_BLACK;
201
 
                        *BITMAP_ADDR32(bitmap, y, x) = pen;
202
 
 
203
 
                        data = data << 1;
204
 
                        x = x + 1;
205
 
                }
206
 
        }
207
 
 
208
 
        return 0;
209
 
}
210
 
 
211
 
 
212
 
 
213
 
/*************************************
214
 
 *
215
 
 *  Memory handlers
216
 
 *
217
 
 *************************************/
218
 
 
219
 
static ADDRESS_MAP_START( main_map, AS_PROGRAM, 8 )
220
 
        AM_RANGE(0x0000, 0x1fff) AM_ROM
221
 
        AM_RANGE(0x2000, 0x23ff) AM_RAM
222
 
        AM_RANGE(0x4000, 0x47ff) AM_ROM
223
 
        AM_RANGE(0x8000, 0x97ff) AM_RAM AM_BASE_SIZE_MEMBER(clayshoo_state, m_videoram, m_videoram_size)        /* 6k of video ram according to readme */
224
 
        AM_RANGE(0x9800, 0xa800) AM_WRITENOP      /* not really mapped, but cleared */
225
 
        AM_RANGE(0xc800, 0xc800) AM_READWRITE(analog_r, analog_reset_w)
226
 
ADDRESS_MAP_END
227
 
 
228
 
 
229
 
 
230
 
/*************************************
231
 
 *
232
 
 *  Port handlers
233
 
 *
234
 
 *************************************/
235
 
 
236
 
static ADDRESS_MAP_START( main_io_map, AS_IO, 8 )
237
 
        ADDRESS_MAP_GLOBAL_MASK(0xff)
238
 
        AM_RANGE(0x00, 0x00) AM_WRITE(watchdog_reset_w)
239
 
        AM_RANGE(0x20, 0x23) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)
240
 
        AM_RANGE(0x30, 0x33) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)
241
 
ADDRESS_MAP_END
242
 
 
243
 
 
244
 
 
245
 
/*************************************
246
 
 *
247
 
 *  Port definitions
248
 
 *
249
 
 *************************************/
250
 
 
251
 
static INPUT_PORTS_START( clayshoo )
252
 
        PORT_START("IN0")
253
 
        PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) )
254
 
        PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
255
 
        PORT_DIPSETTING(    0x02, DEF_STR( 2C_3C ) )
256
 
        PORT_DIPSETTING(    0x01, DEF_STR( 1C_2C ) )
257
 
        PORT_DIPSETTING(    0x03, DEF_STR( Free_Play ) )
258
 
        PORT_BIT( 0x3c, IP_ACTIVE_LOW, IPT_UNKNOWN )            /* doesn't appear to be used */
259
 
        PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )      /* not 100% positive */
260
 
        PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
261
 
        PORT_DIPSETTING(    0x40, DEF_STR( On ) )
262
 
        PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )          /* used */
263
 
        PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
264
 
        PORT_DIPSETTING(    0x80, DEF_STR( On ) )
265
 
 
266
 
        PORT_START("IN1")
267
 
        PORT_DIPNAME( 0x07, 0x01, "Time/Bonus 1P-2P" )
268
 
        PORT_DIPSETTING(    0x00, "60/6k-90/6k" )
269
 
        PORT_DIPSETTING(    0x01, "60/6k-120/8k" )
270
 
        PORT_DIPSETTING(    0x02, "90/9.5k-150/9.5k" )
271
 
        PORT_DIPSETTING(    0x03, "90/9.5k-190/11k" )
272
 
        PORT_DIPSETTING(    0x04, "60/8k-90/8k" )
273
 
        PORT_DIPSETTING(    0x05, "60/8k-120/10k" )
274
 
        PORT_DIPSETTING(    0x06, "90/11.5k-150/11.5k" )
275
 
        PORT_DIPSETTING(    0x07, "90/11.5k-190/13k" )
276
 
        PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )    /* doesn't appear to be used */
277
 
 
278
 
        PORT_START("IN2")
279
 
        PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_SPECIAL )    /* amateur/expert/pro Player 2 */
280
 
        PORT_BIT( 0x0c, IP_ACTIVE_LOW, IPT_SPECIAL )    /* amateur/expert/pro Player 1 */
281
 
        PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
282
 
        PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
283
 
        PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
284
 
        PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
285
 
 
286
 
        PORT_START("IN3")
287
 
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
288
 
        PORT_BIT( 0xfe, IP_ACTIVE_LOW, IPT_UNKNOWN )
289
 
 
290
 
        PORT_START("AN1")  /* IN4 - Fake analog control.  Visible in $c800 bit 1 */
291
 
        PORT_BIT( 0x0f, 0x08, IPT_AD_STICK_Y ) PORT_MINMAX(0,0x0f) PORT_SENSITIVITY(10) PORT_KEYDELTA(10) PORT_REVERSE PORT_PLAYER(1)
292
 
        PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
293
 
 
294
 
        PORT_START("AN2")  /* IN5 - Fake analog control.  Visible in $c800 bit 0 */
295
 
        PORT_BIT( 0x0f, 0x08, IPT_AD_STICK_Y ) PORT_MINMAX(0,0x0f) PORT_SENSITIVITY(10) PORT_KEYDELTA(10) PORT_REVERSE PORT_PLAYER(2)
296
 
        PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
297
 
 
298
 
        PORT_START("FAKE")      /* IN6 - Fake.  Visible in IN2 bits 0-1 and 2-3 */
299
 
        PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_TOGGLE PORT_PLAYER(2) PORT_NAME("P2 Amateur Difficulty")
300
 
        PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_TOGGLE PORT_PLAYER(2) PORT_NAME("P2 Expert Difficulty")
301
 
        PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_TOGGLE PORT_PLAYER(2) PORT_NAME("P2 Pro Difficulty")
302
 
        PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_TOGGLE PORT_PLAYER(1) PORT_NAME("P1 Amateur Difficulty")
303
 
        PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_TOGGLE PORT_PLAYER(1) PORT_NAME("P1 Expert Difficulty")
304
 
        PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_TOGGLE PORT_PLAYER(1) PORT_NAME("P2 Pro Difficulty")
305
 
        PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
306
 
INPUT_PORTS_END
307
 
 
308
 
 
309
 
 
310
 
/*************************************
311
 
 *
312
 
 *  Machine driver
313
 
 *
314
 
 *************************************/
315
 
 
316
 
static MACHINE_RESET( clayshoo )
317
 
{
318
 
        clayshoo_state *state = machine.driver_data<clayshoo_state>();
319
 
 
320
 
        state->m_input_port_select = 0;
321
 
        state->m_analog_port_val = 0;
322
 
}
323
 
 
324
 
static MACHINE_CONFIG_START( clayshoo, clayshoo_state )
325
 
 
326
 
        /* basic machine hardware */
327
 
        MCFG_CPU_ADD("maincpu", Z80,5068000/4)          /* 5.068/4 Mhz (divider is a guess) */
328
 
        MCFG_CPU_PROGRAM_MAP(main_map)
329
 
        MCFG_CPU_IO_MAP(main_io_map)
330
 
        MCFG_CPU_VBLANK_INT("screen", irq0_line_hold)
331
 
 
332
 
        MCFG_MACHINE_START(clayshoo)
333
 
        MCFG_MACHINE_RESET(clayshoo)
334
 
 
335
 
        /* video hardware */
336
 
        MCFG_SCREEN_ADD("screen", RASTER)
337
 
        MCFG_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
338
 
        MCFG_SCREEN_SIZE(256, 256)
339
 
        MCFG_SCREEN_VISIBLE_AREA(0, 255, 64, 255)
340
 
        MCFG_SCREEN_REFRESH_RATE(60)
341
 
        MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
342
 
        MCFG_SCREEN_UPDATE(clayshoo)
343
 
 
344
 
        MCFG_PPI8255_ADD( "ppi8255_0", ppi8255_intf[0] )
345
 
        MCFG_PPI8255_ADD( "ppi8255_1", ppi8255_intf[1] )
346
 
MACHINE_CONFIG_END
347
 
 
348
 
 
349
 
 
350
 
/*************************************
351
 
 *
352
 
 *  ROM definitions
353
 
 *
354
 
 *************************************/
355
 
 
356
 
ROM_START( clayshoo )
357
 
        ROM_REGION( 0x10000, "maincpu", 0 )
358
 
        ROM_LOAD( "0",      0x0000, 0x0800, CRC(9df9d9e3) SHA1(8ce71a6faf5df9c8c3dbb92a443b62c0f376491c) )
359
 
        ROM_LOAD( "1",      0x0800, 0x0800, CRC(5134a631) SHA1(f0764a5161934564fd0416be26087cf812e0c422) )
360
 
        ROM_LOAD( "2",      0x1000, 0x0800, CRC(5b5a67f6) SHA1(c97b4d44e6dc5dd0c42e04ffceed8934975fe769) )
361
 
        ROM_LOAD( "3",      0x1800, 0x0800, CRC(7eda8e44) SHA1(2974f8b06653aee2ffd96ff402707acfc059bc91) )
362
 
        ROM_LOAD( "4",      0x4000, 0x0800, CRC(3da16196) SHA1(eb0c0cf0c8fc3db05ac0c469fb20fe92ae6f27ce) )
363
 
ROM_END
364
 
 
365
 
 
366
 
 
367
 
/*************************************
368
 
 *
369
 
 *  Game drivers
370
 
 *
371
 
 *************************************/
372
 
 
373
 
GAME( 1979, clayshoo, 0, clayshoo, clayshoo, 0, ROT0, "Allied Leisure", "Clay Shoot", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )