~ubuntu-branches/ubuntu/karmic/xmame/karmic

« back to all changes in this revision

Viewing changes to src/drivers/nitedrvr.c

  • Committer: Bazaar Package Importer
  • Author(s): Bruno Barrera C.
  • Date: 2007-02-16 10:06:54 UTC
  • mfrom: (2.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20070216100654-iztas2cl47k5j039
Tags: 0.106-2
* Added Italian debconf templates translation. (closes: #382672)
* Added German debconf templates translation. (closes: #396610)
* Added Japanese debconf templates translation. (closes: #400011)
* Added Portuguese debconf templates translation. (closes: #409960)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
2
 
3
 
        Atari Night Driver hardware
4
 
 
5
 
        driver by Mike Balfour
6
 
 
7
 
        Games supported:
8
 
                * Night Driver
9
 
 
10
 
        Known issues:
11
 
                * none at this time
 
3
    Atari Night Driver hardware
 
4
 
 
5
    driver by Mike Balfour
 
6
 
 
7
    Games supported:
 
8
        * Night Driver
 
9
 
 
10
    Known issues:
 
11
        * The road boxes in service mode are flipped horizontally and there
 
12
          is an extraneous box according to the service manual.
12
13
 
13
14
****************************************************************************
14
15
 
15
 
        Memory Map:
16
 
                0000-01FF       R/W     SCRAM (Scratchpad RAM)
17
 
                0200-03FF        W              PFW (Playfield Write)
18
 
                0400-05FF        W              HVC (Horiz/Vert/Char for Roadway)
19
 
                0600-07FF        R              IN0
20
 
                0800-09FF        R              IN1
21
 
                0A00-0BFF        W              OUT0
22
 
                0C00-0DFF        W              OUT1
23
 
                0E00-0FFF        -              OUT2 (Not used)
24
 
                8000-83FF        R              PFR (Playfield Read)
25
 
                8400-87FF                       Steering Reset
26
 
                8800-8FFF        -              Spare (Not used)
27
 
                9000-97FF        R              Program ROM1
28
 
                9800-9FFF        R              Program ROM2
29
 
                (F800-FFFF)      R              Program ROM2 - only needed for the 6502 vectors
 
16
    Memory Map:
 
17
        0000-01FF   R/W     SCRAM (Scratchpad RAM)
 
18
        0200-03FF    W      PFW (Playfield Write)
 
19
        0400-05FF    W      HVC (Horiz/Vert/Char for Roadway)
 
20
        0600-07FF    R      IN0
 
21
        0800-09FF    R      IN1
 
22
        0A00-0BFF    W      OUT0
 
23
        0C00-0DFF    W      OUT1
 
24
        0E00-0FFF    -      OUT2 (Not used)
 
25
        8000-83FF    R      PFR (Playfield Read)
 
26
        8400-87FF           Steering Reset
 
27
        8800-8FFF    -      Spare (Not used)
 
28
        9000-97FF    R      Program ROM1
 
29
        9800-9FFF    R      Program ROM2
 
30
        (F800-FFFF)  R      Program ROM2 - only needed for the 6502 vectors
30
31
 
31
 
        If you have any questions about how this driver works, don't hesitate to
32
 
        ask.  - Mike Balfour (mab22@po.cwru.edu)
 
32
    If you have any questions about how this driver works, don't hesitate to
 
33
    ask.  - Mike Balfour (mab22@po.cwru.edu)
33
34
 
34
35
***************************************************************************/
35
36
 
36
37
#include "driver.h"
37
 
#include "vidhrdw/generic.h"
38
 
 
39
 
extern UINT8 *nitedrvr_ram;
40
 
 
41
 
extern int nitedrvr_gear;
42
 
extern int nitedrvr_track;
 
38
#include "sound/discrete.h"
 
39
#include "nitedrvr.h"
43
40
 
44
41
extern READ8_HANDLER( nitedrvr_in0_r );
45
42
extern READ8_HANDLER( nitedrvr_in1_r );
46
 
extern READ8_HANDLER( nitedrvr_ram_r );
47
43
extern READ8_HANDLER( nitedrvr_steering_reset_r );
48
44
extern WRITE8_HANDLER( nitedrvr_steering_reset_w );
49
45
extern WRITE8_HANDLER( nitedrvr_out0_w );
50
46
extern WRITE8_HANDLER( nitedrvr_out1_w );
51
 
extern WRITE8_HANDLER( nitedrvr_ram_w );
52
47
extern void nitedrvr_crash_toggle(int dummy);
 
48
extern void nitedrvr_register_machine_vars(void);
53
49
 
54
50
extern UINT8 *nitedrvr_hvc;
55
51
 
59
55
extern VIDEO_START( nitedrvr );
60
56
extern VIDEO_UPDATE( nitedrvr );
61
57
 
62
 
 
63
 
/*************************************
64
 
 *
65
 
 *      Palette generation
66
 
 *
67
 
 *************************************/
68
 
 
69
 
static unsigned short colortable_source[] =
70
 
{
71
 
        0x00, 0x01,
72
 
        0x01, 0x00,
73
 
};
74
 
 
75
 
static PALETTE_INIT( nitedrvr )
76
 
{
77
 
        palette_set_color(0,0x00,0x00,0x00); /* BLACK */
78
 
        palette_set_color(1,0xff,0xff,0xff); /* WHITE */
79
 
        palette_set_color(2,0x55,0x55,0x55); /* DK GREY - for MAME text only */
80
 
        palette_set_color(3,0x80,0x80,0x80); /* LT GREY - for MAME text only */
81
 
        memcpy(colortable,colortable_source,sizeof(colortable_source));
82
 
}
83
 
 
84
 
 
85
 
static MACHINE_INIT( nitedrvr )
86
 
{
87
 
        timer_pulse(TIME_IN_SEC(0.693 * (180000 + (2 * 330)) * 1e-6), 0, nitedrvr_crash_toggle);
88
 
}
89
 
 
90
 
 
91
 
 
92
 
/*************************************
93
 
 *
94
 
 *      Main CPU memory handlers
95
 
 *
96
 
 *************************************/
97
 
 
98
 
static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
99
 
        AM_RANGE(0x0000, 0x00ff) AM_READ(nitedrvr_ram_r) /* SCRAM */
100
 
        AM_RANGE(0x0100, 0x01ff) AM_READ(nitedrvr_ram_r) /* SCRAM */
 
58
/* Memory Map */
 
59
 
 
60
static ADDRESS_MAP_START( nitedrvr_map, ADDRESS_SPACE_PROGRAM, 8 )
 
61
        AM_RANGE(0x0000, 0x00ff) AM_RAM AM_MIRROR(0x100) /* SCRAM */
 
62
        AM_RANGE(0x0200, 0x027f) AM_RAM AM_MIRROR(0x180) AM_WRITE(nitedrvr_videoram_w) AM_BASE(&videoram) /* PFW */
 
63
        AM_RANGE(0x0400, 0x05ff) AM_WRITE(nitedrvr_hvc_w) AM_BASE(&nitedrvr_hvc) /* POSH, POSV, CHAR, Watchdog */
101
64
        AM_RANGE(0x0600, 0x07ff) AM_READ(nitedrvr_in0_r)
102
65
        AM_RANGE(0x0800, 0x09ff) AM_READ(nitedrvr_in1_r)
103
 
        AM_RANGE(0x8000, 0x807f) AM_READ(videoram_r) /* PFR */
104
 
        AM_RANGE(0x8080, 0x80ff) AM_READ(videoram_r) /* PFR */
105
 
        AM_RANGE(0x8100, 0x817f) AM_READ(videoram_r) /* PFR */
106
 
        AM_RANGE(0x8180, 0x81ff) AM_READ(videoram_r) /* PFR */
107
 
        AM_RANGE(0x8200, 0x827f) AM_READ(videoram_r) /* PFR */
108
 
        AM_RANGE(0x8280, 0x82ff) AM_READ(videoram_r) /* PFR */
109
 
        AM_RANGE(0x8300, 0x837f) AM_READ(videoram_r) /* PFR */
110
 
        AM_RANGE(0x8380, 0x83ff) AM_READ(videoram_r) /* PFR */
111
 
        AM_RANGE(0x8400, 0x87ff) AM_READ(nitedrvr_steering_reset_r)
112
 
        AM_RANGE(0x9000, 0x9fff) AM_READ(MRA8_ROM) /* ROM1-ROM2 */
113
 
        AM_RANGE(0xfff0, 0xffff) AM_READ(MRA8_ROM) /* ROM2 for 6502 vectors */
114
 
ADDRESS_MAP_END
115
 
 
116
 
 
117
 
static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 )
118
 
        AM_RANGE(0x0000, 0x00ff) AM_WRITE(nitedrvr_ram_w) AM_BASE(&nitedrvr_ram) /* SCRAM */
119
 
        AM_RANGE(0x0100, 0x01ff) AM_WRITE(nitedrvr_ram_w) /* SCRAM */
120
 
        AM_RANGE(0x0200, 0x027f) AM_WRITE(nitedrvr_videoram_w) AM_BASE(&videoram) /* PFW */
121
 
        AM_RANGE(0x0280, 0x02ff) AM_WRITE(nitedrvr_videoram_w) /* PFW */
122
 
        AM_RANGE(0x0300, 0x037f) AM_WRITE(nitedrvr_videoram_w) /* PFW */
123
 
        AM_RANGE(0x0380, 0x03ff) AM_WRITE(nitedrvr_videoram_w) /* PFW */
124
 
        AM_RANGE(0x0400, 0x05ff) AM_WRITE(nitedrvr_hvc_w) AM_BASE(&nitedrvr_hvc) /* POSH, POSV, CHAR, Watchdog */
125
66
        AM_RANGE(0x0a00, 0x0bff) AM_WRITE(nitedrvr_out0_w)
126
67
        AM_RANGE(0x0c00, 0x0dff) AM_WRITE(nitedrvr_out1_w)
127
 
        AM_RANGE(0x8400, 0x87ff) AM_WRITE(nitedrvr_steering_reset_w)
128
 
        AM_RANGE(0x9000, 0x9fff) AM_WRITE(MWA8_ROM) /* ROM1-ROM2 */
 
68
        AM_RANGE(0x8000, 0x807f) AM_RAM AM_MIRROR(0x380) AM_BASE(&videoram) /* PFR */
 
69
        AM_RANGE(0x8400, 0x87ff) AM_READWRITE(nitedrvr_steering_reset_r, nitedrvr_steering_reset_w)
 
70
        AM_RANGE(0x9000, 0x9fff) AM_ROM /* ROM1-ROM2 */
 
71
        AM_RANGE(0xfff0, 0xffff) AM_ROM /* ROM2 for 6502 vectors */
129
72
ADDRESS_MAP_END
130
73
 
131
 
 
132
 
 
133
 
/*************************************
134
 
 *
135
 
 *      Port definitions
136
 
 *
137
 
 *************************************/
 
74
/* Input Ports */
138
75
 
139
76
INPUT_PORTS_START( nitedrvr )
140
 
        PORT_START              /* fake port, gets mapped to Night Driver ports */
 
77
        PORT_START      /* fake */
141
78
        PORT_DIPNAME( 0x30, 0x10, DEF_STR( Coinage ) )
142
79
        PORT_DIPSETTING(        0x30, DEF_STR( 2C_1C ) )
143
 
        /*PORT_DIPSETTING(      0x20, DEF_STR( 1C_1C ) )    not a typo    */
 
80
        /*PORT_DIPSETTING(  0x20, DEF_STR( 1C_1C ) ) // not a typo */
144
81
        PORT_DIPSETTING(        0x10, DEF_STR( 1C_1C ) )
145
82
        PORT_DIPSETTING(        0x00, DEF_STR( 1C_2C ) )
146
 
        PORT_DIPNAME( 0xC0, 0x80, "Playing Time" )
 
83
        PORT_DIPNAME( 0xc0, 0x80, "Playing Time" )
147
84
        PORT_DIPSETTING(        0x00, "50" )
148
85
        PORT_DIPSETTING(        0x40, "75" )
149
86
        PORT_DIPSETTING(        0x80, "100" )
150
87
        PORT_DIPSETTING(        0xC0, "125" )
151
88
 
152
 
        PORT_START              /* fake port, gets mapped to Night Driver ports */
 
89
        PORT_START      /* fake */
153
90
        PORT_DIPNAME( 0x10, 0x00, "Track Set" )
154
91
        PORT_DIPSETTING(        0x00, DEF_STR( Normal ) )
155
92
        PORT_DIPSETTING(        0x10, DEF_STR( Reverse ) )
156
93
        PORT_DIPNAME( 0x20, 0x20, "Bonus Time" )
157
94
        PORT_DIPSETTING(        0x00, DEF_STR ( No ) )
158
95
        PORT_DIPSETTING(        0x20, "Score = 350" )
159
 
        PORT_BIT (0x40, IP_ACTIVE_HIGH, IPT_VBLANK )
160
 
        PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Self Test") PORT_CODE(KEYCODE_F2) PORT_TOGGLE
161
 
 
162
 
        PORT_START              /* fake port, gets mapped to Night Driver ports */
163
 
        PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_NAME("1st gear") PORT_PLAYER(2)
164
 
        PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_NAME("2nd gear") PORT_PLAYER(2)
165
 
        PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_NAME("3rd gear") PORT_PLAYER(2)
166
 
        PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_NAME("4th gear") PORT_PLAYER(2)
167
 
 
168
 
        PORT_START              /* fake port, gets mapped to Night Driver ports */
169
 
        PORT_BIT (0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )   /* Spare */
 
96
        PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_VBLANK )
 
97
        PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
 
98
 
 
99
        PORT_START      /* fake */
 
100
        PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("1st Gear")
 
101
        PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("2nd Gear")
 
102
        PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("3rd Gear")
 
103
        PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("4th Gear")
 
104
 
 
105
        PORT_START      /* fake */
 
106
        PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )   /* Spare */
170
107
        PORT_DIPNAME( 0x20, 0x00, "Difficult Bonus" )
171
108
        PORT_DIPSETTING(        0x00, DEF_STR( Normal ) )
172
109
        PORT_DIPSETTING(        0x20, "Difficult" )
173
 
        PORT_BIT (0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
174
 
        PORT_BIT (0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
175
 
 
176
 
        PORT_START              /* fake port, gets mapped to Night Driver ports */
177
 
        PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_COIN1 )
178
 
        PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_COIN2 )
179
 
        PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_START1 )
180
 
        PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gas")
181
 
        PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Novice Track")
182
 
        PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Expert Track")
183
 
        PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Pro Track")
184
 
        PORT_BIT (0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )   /* Alternating signal? */
185
 
 
186
 
        PORT_START              /* fake port used for steering */
 
110
        PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
 
111
 
 
112
        PORT_START      /* fake */
 
113
        PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
 
114
        PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
 
115
        PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START1 )
 
116
        PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Gas")
 
117
        PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Novice Track")
 
118
        PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("Expert Track")
 
119
        PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("Pro Track")
 
120
        PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL )   /* Alternating signal? */
 
121
 
 
122
        PORT_START      /* fake */
187
123
        PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(100) PORT_KEYDELTA(10)
188
124
 
189
125
        PORT_START
190
126
        PORT_ADJUSTER( 60, "Motor RPM" )
191
127
INPUT_PORTS_END
192
128
 
193
 
 
194
 
 
195
 
/*************************************
196
 
 *
197
 
 *      Graphics definitions
198
 
 *
199
 
 *************************************/
200
 
 
201
 
static struct GfxLayout charlayout =
 
129
/* Graphics Layouts */
 
130
 
 
131
static const gfx_layout charlayout =
202
132
{
203
 
        8,8,
 
133
        8, 8,
204
134
        64,
205
135
        1,
206
136
        { 0 },
209
139
        8*8
210
140
};
211
141
 
212
 
 
213
 
static struct GfxDecodeInfo gfxdecodeinfo[] =
214
 
{
215
 
        { REGION_GFX1, 0, &charlayout, 0x00, 0x02 }, /* offset into colors, # of colors */
216
 
        { -1 } /* end of array */
217
 
};
218
 
 
219
 
 
220
 
/************************************************************************/
221
 
/* nitedrvr Sound System Analog emulation                                  */
222
 
/************************************************************************/
223
 
 
224
 
const struct discrete_lfsr_desc nitedrvr_lfsr = {
225
 
        16,                     /* Bit Length */
226
 
        0,                      /* Reset Value */
227
 
        0,                      /* Use Bit 0 as XOR input 0 */
228
 
        14,                     /* Use Bit 14 as XOR input 1 */
229
 
        DISC_LFSR_XNOR,         /* Feedback stage1 is XNOR */
230
 
        DISC_LFSR_OR,           /* Feedback stage2 is just stage 1 output OR with external feed */
231
 
        DISC_LFSR_REPLACE,      /* Feedback stage3 replaces the shifted register contents */
232
 
        0x000001,               /* Everything is shifted into the first bit only */
233
 
        0,                      /* Output is already inverted by XNOR */
234
 
        15                      /* Output bit */
235
 
};
236
 
 
237
 
/* Nodes - Inputs */
238
 
#define NITEDRVR_BANG_DATA      NODE_01
239
 
#define NITEDRVR_SKID1_EN       NODE_02
240
 
#define NITEDRVR_SKID2_EN       NODE_03
241
 
#define NITEDRVR_MOTOR_DATA     NODE_04
242
 
#define NITEDRVR_CRASH_EN       NODE_05
243
 
#define NITEDRVR_ATTRACT_EN     NODE_06
244
 
/* Nodes - Sounds */
245
 
#define NITEDRVR_NOISE          NODE_10
246
 
#define NITEDRVR_BANG_SND       NODE_11
247
 
#define NITEDRVR_MOTOR_SND      NODE_12
248
 
#define NITEDRVR_SCREECH1_SND   NODE_13
249
 
#define NITEDRVR_SCREECH2_SND   NODE_14
250
 
 
251
 
static DISCRETE_SOUND_START(nitedrvr_sound_interface)
252
 
        /************************************************/
253
 
        /* nitedrvr  Effects Relataive Gain Table       */
254
 
        /*                                              */
255
 
        /* Effect    V-ampIn  Gain ratio      Relative  */
256
 
        /* Bang       3.8     5/(5+6.8)        1000.0   */
257
 
        /* Motor      3.8     5/(5+10)          786.7   */
258
 
        /* Screech1   3.8     5/(5+47)          226.9   */
259
 
        /* Screech2   3.8     5/(5+47)          226.9   */
260
 
        /************************************************/
261
 
 
262
 
        /************************************************/
263
 
        /* Input register mapping for nitedrvr          */
264
 
        /************************************************/
265
 
        /*              NODE                 ADDR  MASK    GAIN      OFFSET  INIT */
266
 
        DISCRETE_INPUTX(NITEDRVR_BANG_DATA,  0x00, 0x000f, 1000.0/15, 0.0,   0.0)
267
 
        DISCRETE_INPUT (NITEDRVR_SKID1_EN,   0x01, 0x000f,                   0.0)
268
 
        DISCRETE_INPUT (NITEDRVR_SKID2_EN,   0x02, 0x000f,                   0.0)
269
 
        DISCRETE_INPUT (NITEDRVR_MOTOR_DATA, 0x03, 0x000f,                   0.0)
270
 
        DISCRETE_INPUT (NITEDRVR_CRASH_EN,   0x04, 0x000f,                   0.0)
271
 
        DISCRETE_INPUT (NITEDRVR_ATTRACT_EN, 0x05, 0x000f,                   0.0)
272
 
 
273
 
        /************************************************/
274
 
        /* NOTE: Motor circuit is a rip from Sprint for */
275
 
        /* now. This will have to be converted to 566.  */
276
 
        /*                                              */
277
 
        /* Motor sound circuit is based on a 556 VCO    */
278
 
        /* with the input frequency set by the MotorSND */
279
 
        /* latch (4 bit). This freqency is then used to */
280
 
        /* driver a modulo 12 counter, with div6, 4 & 3 */
281
 
        /* summed as the output of the circuit.         */
282
 
        /* VCO Output is Sq wave = 27-382Hz             */
283
 
        /*  F1 freq - (Div6)                            */
284
 
        /*  F2 freq = (Div4)                            */
285
 
        /*  F3 freq = (Div3) 33.3% duty, 33.3 deg phase */
286
 
        /* To generate the frequency we take the freq.  */
287
 
        /* diff. and /15 to get all the steps between   */
288
 
        /* 0 - 15.  Then add the low frequency and send */
289
 
        /* that value to a squarewave generator.        */
290
 
        /* Also as the frequency changes, it ramps due  */
291
 
        /* to a 2.2uf capacitor on the R-ladder.        */
292
 
        /* Note the VCO freq. is controlled by a 250k   */
293
 
        /* pot.  The freq. used here is for the pot set */
294
 
        /* to 125k.  The low freq is allways the same.  */
295
 
        /* This adjusts the high end.                   */
296
 
        /* 0k = 214Hz.   250k = 4416Hz                  */
297
 
        /************************************************/
298
 
        DISCRETE_RCFILTER(NODE_20, 1, NITEDRVR_MOTOR_DATA, 123037, 2.2e-6)
299
 
        DISCRETE_ADJUSTMENT(NODE_21, 1, (214.0-27.0)/12/31, (4416.0-27.0)/12/31, DISC_LOGADJ, 6)
300
 
        DISCRETE_MULTIPLY(NODE_22, 1, NODE_20, NODE_21)
301
 
 
302
 
        DISCRETE_MULTADD(NODE_23, 1, NODE_22, 2, 27.0/6)        /* F1 = /12*2 = /6 */
303
 
        DISCRETE_SQUAREWAVE(NODE_24, 1, NODE_23, (786.7/3), 50.0, 0, 0)
304
 
        DISCRETE_RCFILTER(NODE_25, 1, NODE_24, 10000, 1e-7)
305
 
 
306
 
        DISCRETE_MULTADD(NODE_26, 1, NODE_22, 3, 27.0/4)        /* F2 = /12*3 = /4 */
307
 
        DISCRETE_SQUAREWAVE(NODE_27, 1, NODE_26, (786.7/3), 50.0, 0, 0)
308
 
        DISCRETE_RCFILTER(NODE_28, 1, NODE_27, 10000, 1e-7)
309
 
 
310
 
        DISCRETE_MULTADD(NODE_29, 1, NODE_22, 4, 27.0/3)        /* F3 = /12*4 = /3 */
311
 
        DISCRETE_SQUAREWAVE(NODE_30, 1, NODE_29, (786.7/3), 100.0/3, 0, 360.0/3)
312
 
        DISCRETE_RCFILTER(NODE_31, 1, NODE_30, 10000, 1e-7)
313
 
 
314
 
        DISCRETE_ADDER3(NITEDRVR_MOTOR_SND, NITEDRVR_ATTRACT_EN, NODE_25, NODE_28, NODE_31)
315
 
 
316
 
        /************************************************/
317
 
        /* Bang circuit is built around a noise         */
318
 
        /* generator built from 2 shift registers that  */
319
 
        /* are clocked by the 4V signal.                */
320
 
        /* 4V = HSYNC/2/4                               */
321
 
        /*    = 15750/2/4                               */
322
 
        /* Output is integrated to apply decay.         */
323
 
        /************************************************/
324
 
        DISCRETE_LFSR_NOISE(NITEDRVR_NOISE, NITEDRVR_CRASH_EN, NITEDRVR_CRASH_EN, 15750.0/2/4, 1.0, 0, 0, &nitedrvr_lfsr)
325
 
 
326
 
        DISCRETE_MULTIPLY(NODE_62, 1, NITEDRVR_NOISE, NITEDRVR_BANG_DATA)
327
 
        DISCRETE_RCFILTER(NITEDRVR_BANG_SND, 1, NODE_62, 545.6, 3.3e-7)
328
 
 
329
 
        /************************************************/
330
 
        /* Skid circuits ripped from other drivers      */
331
 
        /* for now.                                     */
332
 
        /*                                              */
333
 
        /* Skid circuits takes the noise output from    */
334
 
        /* the crash circuit and applies +ve feedback   */
335
 
        /* to cause oscillation. There is also an RC    */
336
 
        /* filter on the input to the feedback cct.     */
337
 
        /* RC is 1K & 10uF                              */
338
 
        /* Feedback cct is modelled by using the RC out */
339
 
        /* as the frequency input on a VCO,             */
340
 
        /* breadboarded freq range as:                  */
341
 
        /*  0 = 940Hz, 34% duty                         */
342
 
        /*  1 = 630Hz, 29% duty                         */
343
 
        /*  the duty variance is so small we ignore it  */
344
 
        /************************************************/
345
 
        DISCRETE_INVERT(NODE_70, NITEDRVR_NOISE)
346
 
        DISCRETE_RCFILTER(NODE_71, 1, NODE_70, 1000, 1e-5)
347
 
        DISCRETE_MULTADD(NODE_72, 1, NODE_71, 940.0-630.0, ((940.0-630.0)/2)+630.0)
348
 
        DISCRETE_SQUAREWAVE(NITEDRVR_SCREECH1_SND, NITEDRVR_SKID1_EN, NODE_72, 226.9, 31.5, 0, 0.0)
349
 
 
350
 
        DISCRETE_MULTADD(NODE_75, 1, NODE_71, 1380.0-626.0, 626.0+((1380.0-626.0)/2))   /* Frequency */
351
 
        DISCRETE_MULTADD(NODE_76, 1, NODE_71, 32.0-13.0, 13.0+((32.0-13.0)/2))          /* Duty */
352
 
        DISCRETE_SQUAREWAVE(NITEDRVR_SCREECH2_SND, NITEDRVR_SKID2_EN, NODE_75, 226.9, NODE_76, 0, 0.0)
353
 
 
354
 
        /************************************************/
355
 
        /* Combine all sound sources.                   */
356
 
        /* Add some final gain to get to a good sound   */
357
 
        /* level.                                       */
358
 
        /************************************************/
359
 
        DISCRETE_ADDER4(NODE_90, 1, NITEDRVR_MOTOR_SND, NITEDRVR_BANG_SND, NITEDRVR_SCREECH1_SND, NITEDRVR_SCREECH2_SND)
360
 
        DISCRETE_GAIN(NODE_91, NODE_90, 65534.0/(786.7+1000.0+226.9))
361
 
 
362
 
        DISCRETE_OUTPUT(NODE_91, 100)
363
 
DISCRETE_SOUND_END
364
 
 
365
 
 
366
 
 
367
 
/*************************************
368
 
 *
369
 
 *      Machine driver
370
 
 *
371
 
 *************************************/
 
142
/* Graphics Decode Information */
 
143
 
 
144
static const gfx_decode gfxdecodeinfo[] =
 
145
{
 
146
        { REGION_GFX1, 0, &charlayout, 0, 1 },
 
147
        { -1 }
 
148
};
 
149
 
 
150
/* Machine Initialization */
 
151
 
 
152
static MACHINE_RESET( nitedrvr )
 
153
{
 
154
        timer_pulse(TIME_IN_SEC(0.693 * (180000 + (2 * 330)) * 1e-6), 0, nitedrvr_crash_toggle);
 
155
        nitedrvr_register_machine_vars();
 
156
}
 
157
 
 
158
/* Machine Driver */
372
159
 
373
160
static MACHINE_DRIVER_START( nitedrvr )
374
 
 
375
161
        /* basic machine hardware */
376
 
        MDRV_CPU_ADD(M6502,1000000)        /* 1 MHz ???? */
377
 
        MDRV_CPU_PROGRAM_MAP(readmem,writemem)
378
 
        MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
 
162
        MDRV_CPU_ADD(M6502, 12096000/12) /* 1 MHz */
 
163
        MDRV_CPU_PROGRAM_MAP(nitedrvr_map, 0)
 
164
        MDRV_CPU_VBLANK_INT(irq0_line_hold, 1)
 
165
        MDRV_WATCHDOG_VBLANK_INIT(3)
379
166
 
380
 
        MDRV_FRAMES_PER_SECOND(57)
 
167
        MDRV_FRAMES_PER_SECOND(57) /* how is this derived? */
381
168
        MDRV_VBLANK_DURATION(DEFAULT_REAL_60HZ_VBLANK_DURATION)
382
169
 
383
 
        MDRV_MACHINE_INIT(nitedrvr)
 
170
        MDRV_MACHINE_RESET(nitedrvr)
384
171
 
385
172
        /* video hardware */
386
173
        MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
387
174
        MDRV_SCREEN_SIZE(32*8, 32*8)
388
175
        MDRV_VISIBLE_AREA(0*8, 32*8-1, 0*8, 32*8-1)
389
176
        MDRV_GFXDECODE(gfxdecodeinfo)
390
 
        MDRV_PALETTE_LENGTH(4)
391
 
        MDRV_COLORTABLE_LENGTH(sizeof(colortable_source) / sizeof(colortable_source[0]))
392
 
        
393
 
        MDRV_PALETTE_INIT(nitedrvr)
 
177
        MDRV_PALETTE_LENGTH(2)
 
178
 
 
179
        MDRV_PALETTE_INIT(black_and_white)
394
180
        MDRV_VIDEO_START(nitedrvr)
395
181
        MDRV_VIDEO_UPDATE(nitedrvr)
396
182
 
397
183
        /* sound hardware */
398
 
        MDRV_SOUND_ADD_TAG("discrete", DISCRETE, nitedrvr_sound_interface)
 
184
        MDRV_SPEAKER_STANDARD_MONO("mono")
 
185
 
 
186
        MDRV_SOUND_ADD_TAG("discrete", DISCRETE, 0)
 
187
        MDRV_SOUND_CONFIG(nitedrvr_discrete_interface)
 
188
        MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
399
189
MACHINE_DRIVER_END
400
190
 
401
 
 
402
 
 
403
 
/*************************************
404
 
 *
405
 
 *      ROM definitions
406
 
 *
407
 
 *************************************/
 
191
/* ROMs */
 
192
 
 
193
/*
 
194
ROM_START( nitedrvo )       // early revision has the program code stored in 8 chips
 
195
    ROM_REGION( 0x10000, REGION_CPU1, 0 )
 
196
    ROM_LOAD( "006560-01.h1", 0x9000, 0x0200, NO_DUMP ) // PROM 1
 
197
    ROM_LOAD( "006561-01.c1", 0x9200, 0x0200, NO_DUMP ) // PROM 2
 
198
    ROM_LOAD( "006562-01.j1", 0x9400, 0x0200, NO_DUMP ) // PROM 3
 
199
    ROM_LOAD( "006563-01.d1", 0x9600, 0x0200, NO_DUMP ) // PROM 4
 
200
    ROM_LOAD( "006564-01.k1", 0x9800, 0x0200, NO_DUMP ) // PROM 5
 
201
    ROM_LOAD( "006565-01.e1", 0x9a00, 0x0200, NO_DUMP ) // PROM 6
 
202
    ROM_LOAD( "006566-01.l1", 0x9c00, 0x0200, NO_DUMP ) // PROM 7
 
203
    ROM_LOAD( "006567-01.f1", 0x9e00, 0x0200, NO_DUMP ) // PROM 8
 
204
ROM_END
 
205
*/
408
206
 
409
207
ROM_START( nitedrvr )
410
 
        ROM_REGION( 0x10000, REGION_CPU1, 0 ) /* 64k for code */
411
 
        ROM_LOAD( "6569-01.d2",   0x9000, 0x0800, CRC(7afa7542) SHA1(81018e25ebdeae1daf1308676661063b6fd7fd22) )
412
 
        ROM_LOAD( "6570-01.f2",   0x9800, 0x0800, CRC(bf5d77b1) SHA1(6f603f8b0973bd89e0e721b66944aac8e9f904d9) )
413
 
        ROM_RELOAD(                       0xf800, 0x0800 )
414
 
 
415
 
        ROM_REGION( 0x0200, REGION_GFX1, ROMREGION_DISPOSE )
416
 
        ROM_LOAD( "6568-01.p2",   0x0000, 0x0200, CRC(f80d8889) SHA1(ca573543dcce1221459d5693c476cef14bfac4f4) )
417
 
 
418
 
        ROM_REGION( 0x0100, REGION_PROMS, 0 )
419
 
        ROM_LOAD( "6559-01.h7",   0x0000, 0x0100, CRC(5a8d0e42) SHA1(772220c4c24f18769696ddba26db2bc2e5b0909d) )        /* unknown */
 
208
        ROM_REGION( 0x10000, REGION_CPU1, 0 )
 
209
        ROM_LOAD( "006569-01.d2", 0x9000, 0x0800, CRC(7afa7542) SHA1(81018e25ebdeae1daf1308676661063b6fd7fd22) ) /* MASK ROM 1 */
 
210
        ROM_LOAD( "006570-01.f2", 0x9800, 0x0800, CRC(bf5d77b1) SHA1(6f603f8b0973bd89e0e721b66944aac8e9f904d9) ) /* MASK ROM 2 */
 
211
        ROM_RELOAD(                       0xf800, 0x0800 ) /* vectors */
 
212
 
 
213
        ROM_REGION( 0x200, REGION_GFX1, ROMREGION_DISPOSE )
 
214
        ROM_LOAD( "006568-01.p2", 0x0000, 0x0200, CRC(f80d8889) SHA1(ca573543dcce1221459d5693c476cef14bfac4f4) ) /* PROM, Alpha-Numeric */
 
215
 
 
216
        ROM_REGION( 0x100, REGION_PROMS, 0 )
 
217
        ROM_LOAD( "006559-01.h7", 0x0000, 0x0100, CRC(5a8d0e42) SHA1(772220c4c24f18769696ddba26db2bc2e5b0909d) ) /* PROM, Sync */
420
218
ROM_END
421
219
 
422
 
 
423
 
 
424
 
/*************************************
425
 
 *
426
 
 *      Game drivers
427
 
 *
428
 
 *************************************/
429
 
 
430
 
GAMEX( 1976, nitedrvr, 0, nitedrvr, nitedrvr, 0, ROT0, "Atari", "Night Driver", GAME_IMPERFECT_SOUND )
 
220
/* Game Drivers */
 
221
 
 
222
GAME( 1976, nitedrvr, 0, nitedrvr, nitedrvr, 0, ROT0, "Atari", "Night Driver", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE)