03416: bradley: Exits with DISCRETE_ADJUSTMENT_TAG - NODE_88 has invalid tag.

- removed old bzone sound code as well.
This commit is contained in:
Couriersud 2009-09-03 19:19:29 +00:00
parent a0dc0e0196
commit 73b9245008
3 changed files with 8 additions and 317 deletions

View File

@ -22,282 +22,6 @@ D0 explosion enable gates a noise generator
#include "streams.h"
#include "bzone.h"
#if !BZONE_DISCRETE
#define OUTPUT_RATE (6000*4)
/* Statics */
static INT16 *discharge = NULL;
#define EXP(charge,n) (charge ? 0x7fff - discharge[0x7fff-n] : discharge[n])
static sound_stream *channel;
static int latch;
static int poly_counter;
static int poly_shift;
static int explosion_clock;
static int explosion_out;
static int explosion_amp;
static int explosion_amp_counter;
static int shell_clock;
static int shell_out;
static int shell_amp;
static int shell_amp_counter;
static int motor_counter;
static int motor_counter_a;
static int motor_counter_b;
static int motor_rate;
static int motor_rate_new;
static int motor_rate_counter;
static int motor_amp;
static int motor_amp_new;
static int motor_amp_step;
static int motor_amp_counter;
WRITE8_HANDLER( bzone_sounds_w )
{
if( data == latch )
return;
stream_update(channel);
latch = data;
sound_global_enable(space->machine, latch & 0x20);
}
static STREAM_UPDATE( bzone_sound_update )
{
stream_sample_t *buffer = outputs[0];
while( samples-- )
{
static int last_val = 0;
int sum = 0;
/* polynome shifter H5 and H4 (LS164) clocked with 6kHz */
poly_counter -= 6000;
while( poly_counter <= 0 )
{
int clock;
poly_counter += OUTPUT_RATE;
if( ((poly_shift & 0x0008) == 0) == ((poly_shift & 0x4000) == 0) )
poly_shift = (poly_shift << 1) | 1;
else
poly_shift <<= 1;
/* NAND gate J4 */
clock = ((poly_shift & 0x7000) == 0x7000) ? 0 : 1;
/* raising edge on pin 3 of J5 (LS74)? */
if( clock && !explosion_clock )
explosion_out ^= 1;
/* save explo clock level */
explosion_clock = clock;
/* input 11 of J5 (LS74) */
clock = (poly_shift >> 15) & 1;
/* raising edge on pin 11 of J5 (LS74)? */
if( clock && !shell_clock )
shell_out ^= 1;
/* save shell clock level */
shell_clock = clock;
}
/* explosion enable: charge C14 */
if( latch & 0x01 )
explosion_amp = 32767;
/* explosion output? */
if( explosion_out )
{
if( explosion_amp > 0 )
{
/*
* discharge C14 through R17 + R16
* time constant is 10e-6 * 23000 = 0.23 seconds
* (samples were decaying much slower: 1/4th rate? )
*/
explosion_amp_counter -= (int)(32767 / (0.23*4));
if( explosion_amp_counter < 0 )
{
int n = (-explosion_amp_counter / OUTPUT_RATE) + 1;
explosion_amp_counter += n * OUTPUT_RATE;
if( (explosion_amp -= n) < 0 )
explosion_amp = 0;
}
}
/*
* I don't know the amplification of the op-amp
* and feedback, so the loud/soft values are arbitrary
*/
if( latch & 0x02 ) /* explosion loud ? */
sum += EXP(0,explosion_amp)/3;
else
sum += EXP(0,explosion_amp)/4;
}
/* shell enable: charge C9 */
if( latch & 0x04 )
shell_amp = 32767;
/* shell output? */
if( shell_out )
{
if( shell_amp > 0 )
{
/*
* discharge C9 through R14 + R15
* time constant is 4.7e-6 * 23000 = 0.1081 seconds
* (samples were decaying much slower: 1/4th rate? )
*/
shell_amp_counter -= (int)(32767 / (0.1081*4));
if( shell_amp_counter < 0 )
{
int n = (-shell_amp_counter / OUTPUT_RATE) + 1;
shell_amp_counter += n * OUTPUT_RATE;
if( (shell_amp -= n) < 0 )
shell_amp = 0;
}
}
/*
* I don't know the amplification of the op-amp
* and feedback, so the loud/soft values are arbitrary
*/
if( latch & 0x08 ) /* shell loud ? */
sum += EXP(0,shell_amp)/3;
else
sum += EXP(0,shell_amp)/4;
}
if( latch & 0x80 )
{
/* NE5555 timer
* C = 0.018u, Ra = 100k, Rb = 125k
* charge time = 0.693 * (Ra + Rb) * C = 3870us
* discharge time = 0.693 * Rb * C = 1559.25us
* freq approx. 184 Hz
* I have no idea what frequencies are coming from the NE555
* with "MOTOR REV EN" being high or low. I took 240Hz as
* higher rate and sweep up or down to the new rate in 0.25s
*/
motor_rate_new = (latch & 0x10) ? 240 : 184;
if( motor_rate != motor_rate_new )
{
/* sweep rate to new rate */
motor_rate_counter -= (int)((240 - 184) / 0.25);
while( motor_rate_counter <= 0 )
{
motor_rate_counter += OUTPUT_RATE;
motor_rate += (motor_rate < motor_rate_new) ? +1 : -1;
}
}
motor_counter -= motor_rate;
while( motor_counter <= 0 )
{
double r0, r1;
motor_counter += OUTPUT_RATE;
r0 = 1.0/1e12;
r1 = 1.0/1e12;
if( ++motor_counter_a == 16 )
motor_counter_a = 6;
if( ++motor_counter_b == 16 )
motor_counter_b = 4;
if( motor_counter_a & 8 ) /* bit 3 */
r1 += 1.0/33000;
else
r0 += 1.0/33000;
if( motor_counter_a == 15 ) /* ripple carry */
r1 += 1.0/33000;
else
r0 += 1.0/33000;
if( motor_counter_b & 8 ) /* bit 3 */
r1 += 1.0/33000;
else
r0 += 1.0/33000;
if( motor_counter_b == 15 ) /* ripple carry */
r1 += 1.0/33000;
else
r0 += 1.0/33000;
/* new voltage at C29 */
r0 = 1.0/r0;
r1 = 1.0/r1;
motor_amp_new = (int)(32767 * r0 / (r0 + r1));
/* charge/discharge C29 (0.47uF) */
if( motor_amp_new > motor_amp )
motor_amp_step = (int)((motor_amp_new - motor_amp) / (r1*0.47e-6));
else
motor_amp_step = (int)((motor_amp - motor_amp_new) / (r0*0.47e-6));
}
if( motor_amp != motor_amp_new )
{
motor_amp_counter -= motor_amp_step;
if( motor_amp_counter < 0 )
{
int n = (-motor_amp_counter / OUTPUT_RATE) + 1;
motor_amp_counter += n * OUTPUT_RATE;
if( motor_amp > motor_amp_new )
{
motor_amp -= n;
if( motor_amp < motor_amp_new )
motor_amp = motor_amp_new;
}
else
{
motor_amp += n;
if( motor_amp > motor_amp_new )
motor_amp = motor_amp_new;
}
}
}
sum += EXP((motor_amp<motor_amp_new),motor_amp)/3;
}
*buffer++ = (sum + last_val) / 2;
/* crude 75% low pass filter */
last_val = (sum + last_val * 3) / 4;
}
}
static DEVICE_START( bzone_sound )
{
int i;
discharge = auto_alloc_array(device->machine, INT16, 32768);
for( i = 0; i < 0x8000; i++ )
discharge[0x7fff-i] = (INT16) (0x7fff/exp(1.0*i/4096));
channel = stream_create(device, 0, 1, OUTPUT_RATE, 0, bzone_sound_update);
}
DEVICE_GET_INFO( bzone_sound )
{
switch (state)
{
/* --- the following bits of info are returned as pointers to data or functions --- */
case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(bzone_sound); break;
/* --- the following bits of info are returned as NULL-terminated strings --- */
case DEVINFO_STR_NAME: strcpy(info->s, "Battlezone Engine"); break;
case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break;
}
}
#else
#include "sound/discrete.h"
#include "sound/pokey.h"
@ -584,5 +308,3 @@ MACHINE_DRIVER_START( bzone_audio )
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_DRIVER_END
#endif

View File

@ -306,11 +306,7 @@ static ADDRESS_MAP_START( bzone_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1810, 0x1810) AM_DEVREAD("mathbox", mathbox_lo_r)
AM_RANGE(0x1818, 0x1818) AM_DEVREAD("mathbox", mathbox_hi_r)
AM_RANGE(0x1820, 0x182f) AM_DEVREADWRITE("pokey", pokey_r, pokey_w)
#if BZONE_DISCRETE
AM_RANGE(0x1840, 0x1840) AM_DEVWRITE("discrete", bzone_sounds_w)
#else
AM_RANGE(0x1840, 0x1840) AM_WRITE(bzone_sounds_w)
#endif
AM_RANGE(0x1860, 0x187f) AM_DEVWRITE("mathbox", mathbox_go_w)
AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE(&vectorram) AM_SIZE(&vectorram_size) AM_REGION("maincpu", 0x2000)
AM_RANGE(0x3000, 0x7fff) AM_ROM
@ -407,6 +403,10 @@ ADDRESS_MAP_END
PORT_DIPSETTING( 0x60, "6 credits/4 coins" )\
PORT_DIPSETTING( 0x80, "6 credits/5 coins" )
#define BZONEADJ \
PORT_START("R11") \
PORT_ADJUSTER( 50, "Engine Frequency" )
static INPUT_PORTS_START( bzone )
BZONEIN0
BZONEDSW0
@ -422,10 +422,7 @@ static INPUT_PORTS_START( bzone )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
#if BZONE_DISCRETE
PORT_START("R11")
PORT_ADJUSTER( 50, "Engine Frequency" )
#endif
BZONEADJ
INPUT_PORTS_END
@ -519,6 +516,8 @@ static INPUT_PORTS_START( bradley )
PORT_START("AN2") /* analog 2 = shell firing range hack removed, now uses Z */
PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Z ) PORT_MINMAX(0x10,0xf0) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_CENTERDELTA(0) PORT_REVERSE
BZONEADJ
INPUT_PORTS_END
@ -578,32 +577,11 @@ static MACHINE_DRIVER_START( bzone )
MDRV_IMPORT_FROM(bzone_base)
/* sound hardware */
#if BZONE_DISCRETE
MDRV_IMPORT_FROM(bzone_audio)
#else
MDRV_SPEAKER_STANDARD_MONO("mono")
MDRV_SOUND_ADD("pokey", POKEY, MASTER_CLOCK / 8)
MDRV_SOUND_CONFIG(bzone_pokey_interface)
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MDRV_SOUND_ADD("custom", BZONE, 0)
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
#endif
MACHINE_DRIVER_END
static MACHINE_DRIVER_START( bradley )
/* basic machine hardware */
MDRV_IMPORT_FROM(bzone)
/* sound hardware */
MDRV_SOUND_REPLACE("pokey", POKEY, BZONE_MASTER_CLOCK / 8)
MDRV_SOUND_CONFIG(bzone_pokey_interface)
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_DRIVER_END
static MACHINE_DRIVER_START( redbaron )
@ -842,5 +820,5 @@ static DRIVER_INIT( bradley )
GAMEL(1980, bzone, 0, bzone, bzone, 0, ROT0, "Atari", "Battle Zone (set 1)", GAME_SUPPORTS_SAVE, layout_bzone )
GAMEL(1980, bzone2, bzone, bzone, bzone, 0, ROT0, "Atari", "Battle Zone (set 2)", GAME_SUPPORTS_SAVE, layout_bzone )
GAMEL(1980, bzonec, bzone, bzone, bzone, 0, ROT0, "Atari", "Battle Zone (cocktail)", GAME_SUPPORTS_SAVE|GAME_NO_COCKTAIL, layout_bzone )
GAME( 1980, bradley, 0, bradley, bradley, bradley, ROT0, "Atari", "Bradley Trainer", GAME_SUPPORTS_SAVE )
GAME( 1980, bradley, 0, bzone, bradley, bradley, ROT0, "Atari", "Bradley Trainer", GAME_SUPPORTS_SAVE )
GAMEL(1980, redbaron, 0, redbaron, redbaron, 0, ROT0, "Atari", "Red Baron", GAME_SUPPORTS_SAVE, layout_ho88ffff )

View File

@ -4,8 +4,6 @@
*************************************************************************/
#define BZONE_DISCRETE (1)
#define BZONE_MASTER_CLOCK (XTAL_12_096MHz)
#define BZONE_CLOCK_3KHZ (MASTER_CLOCK / 4096)
@ -16,17 +14,10 @@ extern UINT8 rb_input_select;
/*----------- defined in audio/bzone.c -----------*/
#if BZONE_DISCRETE
WRITE8_DEVICE_HANDLER( bzone_sounds_w );
MACHINE_DRIVER_EXTERN( bzone_audio );
#else
WRITE8_HANDLER( bzone_sounds_w );
DEVICE_GET_INFO( bzone_sound );
#define SOUND_BZONE DEVICE_GET_INFO_NAME(bzone_sound)
#endif
/*----------- defined in audio/redbaron.c -----------*/