~ubuntu-branches/debian/wheezy/mame/wheezy

« back to all changes in this revision

Viewing changes to src/mame/drivers/sprint4.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:
17
17
#define PIXEL_CLOCK    (MASTER_CLOCK / 2)
18
18
 
19
19
 
20
 
 
21
 
static int da_latch;
22
 
 
23
 
static int steer_FF1[4];
24
 
static int steer_FF2[4];
25
 
 
26
 
static int gear[4];
27
 
 
28
 
 
29
20
static CUSTOM_INPUT( get_lever )
30
21
{
 
22
        sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
31
23
        int n = (FPTR) param;
32
24
 
33
 
        return 4 * gear[n] > da_latch;
 
25
        return 4 * state->m_gear[n] > state->m_da_latch;
34
26
}
35
27
 
36
28
 
37
29
static CUSTOM_INPUT( get_wheel )
38
30
{
 
31
        sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
39
32
        int n = (FPTR) param;
40
33
 
41
 
        return 8 * steer_FF1[n] + 8 * steer_FF2[n] > da_latch;
 
34
        return 8 * state->m_steer_FF1[n] + 8 * state->m_steer_FF2[n] > state->m_da_latch;
42
35
}
43
36
 
44
37
 
45
38
static CUSTOM_INPUT( get_collision )
46
39
{
 
40
        sprint4_state *state = field->port->machine().driver_data<sprint4_state>();
47
41
        int n = (FPTR) param;
48
42
 
49
 
        return sprint4_collision[n];
 
43
        return state->m_collision[n];
50
44
}
51
45
 
52
46
 
53
47
static TIMER_CALLBACK( nmi_callback     )
54
48
{
 
49
        sprint4_state *state = machine.driver_data<sprint4_state>();
55
50
        int scanline = param;
56
 
        static UINT8 last_wheel[4];
57
51
 
58
52
        /* MAME updates controls only once per frame but the game checks them on every NMI */
59
53
 
78
72
 
79
73
        for (i = 0; i < 4; i++)
80
74
        {
81
 
                signed char delta = wheel[i] - last_wheel[i];
 
75
                signed char delta = wheel[i] - state->m_last_wheel[i];
82
76
 
83
77
                if (delta < 0)
84
78
                {
85
 
                        steer_FF2[i] = 0;
 
79
                        state->m_steer_FF2[i] = 0;
86
80
                }
87
81
                if (delta > 0)
88
82
                {
89
 
                        steer_FF2[i] = 1;
 
83
                        state->m_steer_FF2[i] = 1;
90
84
                }
91
85
 
92
 
                steer_FF1[i] = (wheel[i] >> 4) & 1;
93
 
 
94
 
                if (lever[i] & 1) { gear[i] = 1; }
95
 
                if (lever[i] & 2) { gear[i] = 2; }
96
 
                if (lever[i] & 4) { gear[i] = 3; }
97
 
                if (lever[i] & 8) { gear[i] = 4; }
98
 
 
99
 
                last_wheel[i] = wheel[i];
 
86
                state->m_steer_FF1[i] = (wheel[i] >> 4) & 1;
 
87
 
 
88
                if (lever[i] & 1) { state->m_gear[i] = 1; }
 
89
                if (lever[i] & 2) { state->m_gear[i] = 2; }
 
90
                if (lever[i] & 4) { state->m_gear[i] = 3; }
 
91
                if (lever[i] & 8) { state->m_gear[i] = 4; }
 
92
 
 
93
                state->m_last_wheel[i] = wheel[i];
100
94
        }
101
95
 
102
96
        scanline += 64;
113
107
        if (input_port_read(machine, "IN0") & 0x40)
114
108
                cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
115
109
 
116
 
        timer_set(machine, machine->primary_screen->time_until_pos(scanline), NULL, scanline, nmi_callback);
 
110
        machine.scheduler().timer_set(machine.primary_screen->time_until_pos(scanline), FUNC(nmi_callback), scanline);
117
111
}
118
112
 
119
113
 
120
114
static MACHINE_RESET( sprint4 )
121
115
{
122
 
        timer_set(machine, machine->primary_screen->time_until_pos(32), NULL, 32, nmi_callback);
123
 
 
124
 
        memset(steer_FF1, 0, sizeof steer_FF1);
125
 
        memset(steer_FF2, 0, sizeof steer_FF2);
126
 
 
127
 
        gear[0] = 1;
128
 
        gear[1] = 1;
129
 
        gear[2] = 1;
130
 
        gear[3] = 1;
131
 
 
132
 
        da_latch = 0;
 
116
        sprint4_state *state = machine.driver_data<sprint4_state>();
 
117
        machine.scheduler().timer_set(machine.primary_screen->time_until_pos(32), FUNC(nmi_callback), 32);
 
118
 
 
119
        memset(state->m_steer_FF1, 0, sizeof state->m_steer_FF1);
 
120
        memset(state->m_steer_FF2, 0, sizeof state->m_steer_FF2);
 
121
 
 
122
        state->m_gear[0] = 1;
 
123
        state->m_gear[1] = 1;
 
124
        state->m_gear[2] = 1;
 
125
        state->m_gear[3] = 1;
 
126
 
 
127
        state->m_da_latch = 0;
133
128
}
134
129
 
135
130
 
136
131
static READ8_HANDLER( sprint4_wram_r )
137
132
{
138
 
        sprint4_state *state = space->machine->driver_data<sprint4_state>();
139
 
        UINT8 *videoram = state->videoram;
 
133
        sprint4_state *state = space->machine().driver_data<sprint4_state>();
 
134
        UINT8 *videoram = state->m_videoram;
140
135
        return videoram[0x380 + offset];
141
136
}
142
137
 
143
138
 
144
139
static READ8_HANDLER( sprint4_analog_r )
145
140
{
146
 
        return (input_port_read(space->machine, "ANALOG") << (~offset & 7)) & 0x80;
 
141
        return (input_port_read(space->machine(), "ANALOG") << (~offset & 7)) & 0x80;
147
142
}
148
143
static READ8_HANDLER( sprint4_coin_r )
149
144
{
150
 
        return (input_port_read(space->machine, "COIN") << (~offset & 7)) & 0x80;
 
145
        return (input_port_read(space->machine(), "COIN") << (~offset & 7)) & 0x80;
151
146
}
152
147
static READ8_HANDLER( sprint4_collision_r )
153
148
{
154
 
        return (input_port_read(space->machine, "COLLISION") << (~offset & 7)) & 0x80;
 
149
        return (input_port_read(space->machine(), "COLLISION") << (~offset & 7)) & 0x80;
155
150
}
156
151
 
157
152
 
158
153
static READ8_HANDLER( sprint4_options_r )
159
154
{
160
 
        return (input_port_read(space->machine, "DIP") >> (2 * (offset & 3))) & 3;
 
155
        return (input_port_read(space->machine(), "DIP") >> (2 * (offset & 3))) & 3;
161
156
}
162
157
 
163
158
 
164
159
static WRITE8_HANDLER( sprint4_wram_w )
165
160
{
166
 
        sprint4_state *state = space->machine->driver_data<sprint4_state>();
167
 
        UINT8 *videoram = state->videoram;
 
161
        sprint4_state *state = space->machine().driver_data<sprint4_state>();
 
162
        UINT8 *videoram = state->m_videoram;
168
163
        videoram[0x380 + offset] = data;
169
164
}
170
165
 
171
166
 
172
167
static WRITE8_HANDLER( sprint4_collision_reset_w )
173
168
{
174
 
        sprint4_collision[(offset >> 1) & 3] = 0;
 
169
        sprint4_state *state = space->machine().driver_data<sprint4_state>();
 
170
        state->m_collision[(offset >> 1) & 3] = 0;
175
171
}
176
172
 
177
173
 
178
174
static WRITE8_HANDLER( sprint4_da_latch_w )
179
175
{
180
 
        da_latch = data & 15;
 
176
        sprint4_state *state = space->machine().driver_data<sprint4_state>();
 
177
        state->m_da_latch = data & 15;
181
178
}
182
179
 
183
180
 
184
181
static WRITE8_HANDLER( sprint4_lamp_w )
185
182
{
186
 
        set_led_status(space->machine, (offset >> 1) & 3, offset & 1);
 
183
        set_led_status(space->machine(), (offset >> 1) & 3, offset & 1);
187
184
}
188
185
 
189
186
 
190
187
#ifdef UNUSED_FUNCTION
191
188
static WRITE8_HANDLER( sprint4_lockout_w )
192
189
{
193
 
        coin_lockout_global_w(space->machine, ~offset & 1);
 
190
        coin_lockout_global_w(space->machine(), ~offset & 1);
194
191
}
195
192
#endif
196
193
 
233
230
}
234
231
 
235
232
 
236
 
static ADDRESS_MAP_START( sprint4_cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
 
233
static ADDRESS_MAP_START( sprint4_cpu_map, AS_PROGRAM, 8 )
237
234
 
238
235
        ADDRESS_MAP_GLOBAL_MASK(0x3fff)
239
236
 
240
237
        AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x700) AM_READWRITE(sprint4_wram_r, sprint4_wram_w)
241
 
        AM_RANGE(0x0800, 0x0bff) AM_MIRROR(0x400) AM_RAM_WRITE(sprint4_video_ram_w) AM_BASE_MEMBER(sprint4_state, videoram)
 
238
        AM_RANGE(0x0800, 0x0bff) AM_MIRROR(0x400) AM_RAM_WRITE(sprint4_video_ram_w) AM_BASE_MEMBER(sprint4_state, m_videoram)
242
239
 
243
240
        AM_RANGE(0x0000, 0x0007) AM_MIRROR(0x718) AM_READ(sprint4_analog_r)
244
241
        AM_RANGE(0x0020, 0x0027) AM_MIRROR(0x718) AM_READ(sprint4_coin_r)
411
408
        MCFG_SCREEN_ADD("screen", RASTER)
412
409
        MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
413
410
        MCFG_SCREEN_RAW_PARAMS(PIXEL_CLOCK, HTOTAL, 0, 256, VTOTAL, 0, 224)
 
411
        MCFG_SCREEN_UPDATE(sprint4)
 
412
        MCFG_SCREEN_EOF(sprint4)
 
413
 
414
414
        MCFG_GFXDECODE(sprint4)
415
415
        MCFG_PALETTE_LENGTH(10)
416
416
 
417
417
        MCFG_PALETTE_INIT(sprint4)
418
418
        MCFG_VIDEO_START(sprint4)
419
 
        MCFG_VIDEO_UPDATE(sprint4)
420
 
        MCFG_VIDEO_EOF(sprint4)
421
419
 
422
420
        /* sound hardware */
423
421
        MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")