src/mame/includes/nam_cust.h
| r4879 | r4880 | |
| 1 | | /* Namco Custom Chip ROM loading Macros */ |
| 2 | | |
| 3 | | |
| 4 | | /* the 50XX is a player score controller, used for protection */ |
| 5 | | #define ROM_REGION_NAMCO_50XX( region ) \ |
| 6 | | ROM_REGION( 0x800, region, 0 ) /* 2k for the 50xx */ \ |
| 7 | | ROM_LOAD( "50xx.bin", 0x0000, 0x0800, CRC(a0acbaf7) SHA1(f03c79451e73b3a93c1591cdb27fedc9f130508d) ) \ |
| 8 | | |
| 9 | | /* the 51XX is an I/O controller */ |
| 10 | | #define ROM_REGION_NAMCO_51XX( region ) \ |
| 11 | | ROM_REGION( 0x400, region, 0 ) /* 1k for the 51xx */ \ |
| 12 | | ROM_LOAD( "51xx.bin", 0x0000, 0x0400, CRC(c2f57ef8) SHA1(50de79e0d6a76bda95ffb02fcce369a79e6abfec) ) \ |
| 13 | | |
| 14 | | /* the 52XX is a sample player */ |
| 15 | | #define ROM_REGION_NAMCO_52XX( region ) \ |
| 16 | | ROM_REGION( 0x400, region, 0 ) /* 1k for the 52xx */ \ |
| 17 | | ROM_LOAD( "52xx.bin", 0x0000, 0x0400, CRC(3257d11e) SHA1(4883b2fdbc99eb7b9906357fcc53915842c2c186) ) \ |
| 18 | | |
| 19 | | /* the 53XX is an I/O controller */ |
| 20 | | #define ROM_REGION_NAMCO_53XX( region ) \ |
| 21 | | ROM_REGION( 0x400, region, 0 ) /* 1k for the 53xx */ \ |
| 22 | | ROM_LOAD( "53xx.bin", 0x0000, 0x0400, CRC(b326fecb) SHA1(758d8583d658e4f1df93184009d86c3eb8713899) ) \ |
| 23 | | |
| 24 | | /* the 54XX is an explosion sound generator */ |
| 25 | | #define ROM_REGION_NAMCO_54XX( region ) \ |
| 26 | | ROM_REGION( 0x400, region, 0 ) /* 1k for the 54xx */ \ |
| 27 | | ROM_LOAD( "54xx.bin", 0x0000, 0x0400, CRC(ee7357e0) SHA1(01bdf984a49e8d0cc8761b2cc162fd6434d5afbe) ) \ |
| 28 | | |
src/emu/sound/namco52.c
| r4879 | r4880 | |
| 1 | | /*************************************************************************** |
| 2 | | |
| 3 | | Namco 52XX |
| 4 | | |
| 5 | | This instance of the Fujitsu MB8852 MCU is programmed to act as a sample player. |
| 6 | | It is used by just two games: Bosconian and Pole Position. |
| 7 | | |
| 8 | | A0-A15 = address to read from sample ROMs |
| 9 | | D0-D7 = data freom sample ROMs |
| 10 | | CMD = command from CPU (sample to play, 0 = none) |
| 11 | | OUT = sound output |
| 12 | | |
| 13 | | +------+ |
| 14 | | EXTAL|1 42|Vcc |
| 15 | | XTAL|2 41|CMD3 |
| 16 | | /RESET|3 40|CMD2 |
| 17 | | /IRQ|4 39|CMD1 |
| 18 | | n.c.|5 38|CMD0 |
| 19 | | [2] |6 37|A7 |
| 20 | | n.c.|7 36|A6 |
| 21 | | [1] |8 35|A5 |
| 22 | | OUT0|9 34|A4 |
| 23 | | OUT1|10 33|A3 |
| 24 | | OUT2|11 32|A2 |
| 25 | | OUT3|12 31|A1 |
| 26 | | A8|13 30|A0 |
| 27 | | A9|14 29|D7 |
| 28 | | A10|15 28|D6 |
| 29 | | A11|16 27|D5 |
| 30 | | [3]A12|17 26|D4 |
| 31 | | [3]A13|18 25|D3 |
| 32 | | [3]A14|19 24|D2 |
| 33 | | [3]A15|20 23|D1 |
| 34 | | GND|21 22|D0 |
| 35 | | +------+ |
| 36 | | |
| 37 | | [1] in polepos, GND; in bosco, 4kHz output from a 555 timer |
| 38 | | [2] in polepos, +5V; in bosco, GND |
| 39 | | [3] in polepos, these are true address lines, in bosco they are chip select lines |
| 40 | | (each one select one of the four ROM chips). Behaviour related to [2]? |
| 41 | | |
| 42 | | TODO: |
| 43 | | - the purpose of the 555 timer in bosco is unknown; maybe modulate the output? |
| 44 | | Jan 12, 2005. The 555 is probably an external playback frequency. |
| 45 | | |
| 46 | | ***************************************************************************/ |
| 47 | | |
| 48 | | #include "sndintrf.h" |
| 49 | | #include "streams.h" |
| 50 | | #include "filter.h" |
| 51 | | #include "namco52.h" |
| 52 | | |
| 53 | | |
| 54 | | typedef struct _namco_52xx namco_52xx; |
| 55 | | struct _namco_52xx |
| 56 | | { |
| 57 | | const namco_52xx_interface *intf; /* pointer to our config data */ |
| 58 | | UINT8 *rom; /* pointer to sample ROM */ |
| 59 | | UINT32 rom_len; |
| 60 | | sound_stream * stream; /* the output stream */ |
| 61 | | double n52_pb_cycle; /* playback clock time based on machine sample rate */ |
| 62 | | double n52_step; /* playback clock step based on machine sample rate */ |
| 63 | | /* n52_pb_cycle is incremented by n52_step every machine-sample. |
| 64 | | * At every integer value of n52_pb_cycle the next 4bit value is used. */ |
| 65 | | INT32 n52_start; /* current effect start position in the ROM */ |
| 66 | | INT32 n52_end; /* current effect end position in the ROM */ |
| 67 | | INT32 n52_length; /* # of 4bit samples in current effect */ |
| 68 | | INT32 n52_pos; /* current 4bit sample of effect */ |
| 69 | | filter2_context n52_hp_filter; |
| 70 | | filter2_context n52_lp_filter; |
| 71 | | }; |
| 72 | | |
| 73 | | |
| 74 | | INLINE namco_52xx *get_safe_token(const device_config *device) |
| 75 | | { |
| 76 | | assert(device != NULL); |
| 77 | | assert(device->token != NULL); |
| 78 | | assert(device->type == SOUND); |
| 79 | | assert(sound_get_type(device) == SOUND_NAMCO_52XX); |
| 80 | | return (namco_52xx *)device->token; |
| 81 | | } |
| 82 | | |
| 83 | | |
| 84 | | static void namco_52xx_reset(namco_52xx *chip); |
| 85 | | |
| 86 | | |
| 87 | | static STREAM_UPDATE( namco_52xx_stream_update_one ) |
| 88 | | { |
| 89 | | namco_52xx *chip = (namco_52xx *)param; |
| 90 | | int i, rom_pos, whole_pb_cycles, buf; |
| 91 | | stream_sample_t *buffer = outputs[0]; |
| 92 | | |
| 93 | | if (chip->n52_start >= chip->n52_end) |
| 94 | | { |
| 95 | | memset(buffer, 0, samples * sizeof(*buffer)); |
| 96 | | return; |
| 97 | | } |
| 98 | | |
| 99 | | for (i = 0; i < samples; i++) |
| 100 | | { |
| 101 | | chip->n52_pb_cycle += chip->n52_step; |
| 102 | | if (chip->n52_pb_cycle >= 1) |
| 103 | | { |
| 104 | | whole_pb_cycles = (int)chip->n52_pb_cycle; |
| 105 | | chip->n52_pos += whole_pb_cycles; |
| 106 | | chip->n52_pb_cycle -= whole_pb_cycles; |
| 107 | | } |
| 108 | | |
| 109 | | if (chip->n52_pos > chip->n52_length) |
| 110 | | { |
| 111 | | /* sample done */ |
| 112 | | memset(&buffer[i], 0, (samples - i) * sizeof(INT16)); |
| 113 | | i = samples; |
| 114 | | namco_52xx_reset(chip); |
| 115 | | } |
| 116 | | else |
| 117 | | { |
| 118 | | /* filter and fill the buffer */ |
| 119 | | rom_pos = chip->n52_start + (chip->n52_pos >> 1); |
| 120 | | /* get the 4bit sample from rom and shift to +7/-8 value */ |
| 121 | | chip->n52_hp_filter.x0 = (((chip->n52_pos & 1) ? chip->rom[rom_pos] >> 4 : chip->rom[rom_pos]) & 0x0f) - 0x08; |
| 122 | | filter2_step(&chip->n52_hp_filter); |
| 123 | | chip->n52_lp_filter.x0 = chip->n52_hp_filter.y0; |
| 124 | | filter2_step(&chip->n52_lp_filter); |
| 125 | | /* convert 4bit filtered to 16bit allowing room for filter gain */ |
| 126 | | buf = (int)(chip->n52_lp_filter.y0 * 0x0fff); |
| 127 | | if (buf > 32767) buf = 32767; |
| 128 | | if (buf < -32768) buf = -32768; |
| 129 | | buffer[i] = buf; |
| 130 | | } |
| 131 | | } |
| 132 | | } |
| 133 | | |
| 134 | | static void namco_52xx_reset(namco_52xx *chip) |
| 135 | | { |
| 136 | | chip->n52_pb_cycle = chip->n52_start = chip->n52_end = chip->n52_length = chip->n52_pos = 0; |
| 137 | | |
| 138 | | filter2_reset(&chip->n52_hp_filter); |
| 139 | | filter2_reset(&chip->n52_lp_filter); |
| 140 | | } |
| 141 | | |
| 142 | | static DEVICE_RESET( namco_52xx ) |
| 143 | | { |
| 144 | | namco_52xx_reset(get_safe_token(device)); |
| 145 | | } |
| 146 | | |
| 147 | | static DEVICE_START( namco_52xx ) |
| 148 | | { |
| 149 | | namco_52xx *chip = get_safe_token(device); |
| 150 | | int rate = device->clock/32; |
| 151 | | |
| 152 | | chip->intf = (const namco_52xx_interface *)device->static_config; |
| 153 | | chip->rom = device->region; |
| 154 | | chip->rom_len = device->regionbytes; |
| 155 | | |
| 156 | | if (chip->intf->play_rate == 0) |
| 157 | | { |
| 158 | | /* If play clock is 0 (grounded) then default to internal clock */ |
| 159 | | chip->n52_step = (double)device->clock / 384 / rate; |
| 160 | | } |
| 161 | | else |
| 162 | | { |
| 163 | | chip->n52_step = chip->intf->play_rate / rate; |
| 164 | | } |
| 165 | | filter2_setup(device, FILTER_HIGHPASS, chip->intf->hp_filt_fc, Q_TO_DAMP(chip->intf->hp_filt_q), 1, &chip->n52_hp_filter); |
| 166 | | filter2_setup(device, FILTER_LOWPASS, chip->intf->lp_filt_fc, Q_TO_DAMP(chip->intf->lp_filt_q), chip->intf->filt_gain, &chip->n52_lp_filter); |
| 167 | | |
| 168 | | |
| 169 | | chip->stream = stream_create(device, 0, 1, rate, chip, namco_52xx_stream_update_one); |
| 170 | | |
| 171 | | namco_52xx_reset(chip); |
| 172 | | |
| 173 | | state_save_register_device_item(device, 0, chip->n52_pb_cycle); |
| 174 | | state_save_register_device_item(device, 0, chip->n52_step); |
| 175 | | state_save_register_device_item(device, 0, chip->n52_start); |
| 176 | | state_save_register_device_item(device, 0, chip->n52_end); |
| 177 | | state_save_register_device_item(device, 0, chip->n52_length); |
| 178 | | state_save_register_device_item(device, 0, chip->n52_pos); |
| 179 | | } |
| 180 | | |
| 181 | | |
| 182 | | void namcoio_52xx_write(const device_config *device, int data) |
| 183 | | { |
| 184 | | namco_52xx *chip = get_safe_token(device); |
| 185 | | data &= 0x0f; |
| 186 | | |
| 187 | | if (data != 0) |
| 188 | | { |
| 189 | | stream_update(chip->stream); |
| 190 | | |
| 191 | | chip->n52_start = chip->rom[data-1] + (chip->rom[data-1+0x10] << 8); |
| 192 | | chip->n52_end = chip->rom[data] + (chip->rom[data+0x10] << 8); |
| 193 | | |
| 194 | | if (chip->n52_end >= chip->rom_len) |
| 195 | | chip->n52_end = chip->rom_len; |
| 196 | | |
| 197 | | chip->n52_length = (chip->n52_end - chip->n52_start) * 2; |
| 198 | | chip->n52_pos = 0; |
| 199 | | chip->n52_pb_cycle= 0; |
| 200 | | } |
| 201 | | } |
| 202 | | |
| 203 | | |
| 204 | | |
| 205 | | /************************************************************************** |
| 206 | | * Generic get_info |
| 207 | | **************************************************************************/ |
| 208 | | |
| 209 | | DEVICE_GET_INFO( namco_52xx ) |
| 210 | | { |
| 211 | | switch (state) |
| 212 | | { |
| 213 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 214 | | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(namco_52xx); break; |
| 215 | | |
| 216 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 217 | | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME( namco_52xx ); break; |
| 218 | | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 219 | | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME( namco_52xx ); break; |
| 220 | | |
| 221 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 222 | | case DEVINFO_STR_NAME: strcpy(info->s, "Namco 52XX"); break; |
| 223 | | case DEVINFO_STR_FAMILY: strcpy(info->s, "Namco custom"); break; |
| 224 | | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 225 | | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 226 | | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; |
| 227 | | } |
| 228 | | } |
| 229 | | |