Previous 15994 Revisions Next

r4940 Friday 5th June, 2009 at 01:55:27 UTC by Nathan Woods
Updated to MAME 0.131u4 core; disabled snk.a temporarily
[docs]messnew.txt
[src/emu]devintrf.h devtempl.h* info.c memory.h
[src/emu/cpu]cpu.mak
[src/emu/cpu/ssem]ssem.h
[src/emu/machine]6821pia.c 6840ptm.c 6840ptm.h adc083x.c adc083x.h adc1213x.c adc1213x.h ds1302.c ds1302.h mb3773.c mb3773.h pd4990a.c pd4990a.h rp5h01.c rp5h01.h upd4701.c upd4701.h
[src/emu/sound]digitalk.c
[src/emu/video]voodoo.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]amiga.c namco52.c namco54.c
[src/mame/drivers]8080bw.c 86lions.c badlands.c bigfghtr.c boogwing.c cchasm.c cps1.c crystal.c cvs.c ddragon3.c dmndrby.c eprom.c esripsys.c galaga.c galdrvr.c goal92.c guab.c hnayayoi.c hvyunit.c jpmsys5.c konamigx.c ksys573.c megadriv.c midtunit.c midvunit.c mirax.c moo.c mpu4.c mpu4drvr.c mystwarr.c namcos12.c neogeo.c nwk-tr.c olibochu.c parodius.c pipedrm.c playch10.c polepos.c scobra.c seta2.c srumbler.c superqix.c suprgolf.c taito_z.c thedeep.c tmaster.c tmnt.c toaplan2.c trackfld.c twin16.c twinkle.c ultrsprt.c zn.c zr107.c
[src/mame/machine]fddebug.c midtunit.c midyunit.c namco06.c namco06.h namco50.c namco51.c namco53.c playch10.c s16fd.c s24fd.c slapstic.c toaplan1.c
[src/mame/video]antic.c cischeat.c cps1.c moo.c taitoic.c
[src/mess]mess.mak messdriv.c

src/mame/audio/amiga.c
r4939r4940
290290      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(amiga_sound);   break;
291291
292292      /* --- the following bits of info are returned as NULL-terminated strings --- */
293      case DEVINFO_STR_NAME:                     strcpy(info->s, "Amiga Custom");            break;
293      case DEVINFO_STR_NAME:                     strcpy(info->s, "Amiga Paula");            break;
294294      case DEVINFO_STR_SOURCE_FILE:                  strcpy(info->s, __FILE__);                  break;
295295   }
296296}
src/mame/audio/namco52.c
r4939r4940
11/***************************************************************************
22
3Namco 52XX
3    Namco 52XX
44
5This instance of the Fujitsu MB8843 MCU is programmed to act as a sample player.
6It is used by just two games: Bosconian and Pole Position.
5    This instance of the Fujitsu MB8843 MCU is programmed to act as a
6    sample player. It is used by just two games: Bosconian and Pole
7    Position.
78
8A0-A15 = address to read from sample ROMs
9D0-D7 = data freom sample ROMs
10CMD = command from CPU (sample to play, 0 = none)
11OUT = sound output
9    A0-A15 = address to read from sample ROMs
10    D0-D7 = data from sample ROMs
11    CMD0-CMD3 = command from CPU (sample to play, 0 = none)
12    OUT0-OUT3 = sound output
1213
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      +------+
14                  +------+
15                EX|1   42|Vcc
16                 X|2   41|K3 (CMD3)
17            /RESET|3   40|K2 (CMD2)
18              /IRQ|4   39|K1 (CMD1)
19         (n.c.) SO|5   38|K0 (CMD0)
20            [1] SI|6   37|R15 (A7)
21     (n.c.) /SC/TO|7   36|R14 (A6)
22           [2] /TC|8   35|R13 (A5)
23         (OUT0) P0|9   34|R12 (A4)
24         (OUT1) P1|10  33|R11 (A3)
25         (OUT2) P2|11  32|R10 (A2)
26         (OUT3) P3|12  31|R9 (A1)
27           (A8) O0|13  30|R8 (A0)
28           (A9) O1|14  29|R7 (D7)
29          (A10) O2|15  28|R6 (D6)
30          (A11) O3|16  27|R5 (D5)
31          (A12) O4|17  26|R4 (D4)
32          (A13) O5|18  25|R3 (D3)
33          (A14) O6|19  24|R2 (D2)
34          (A15) O7|20  23|R1 (D1)
35               GND|21  22|R0 (D0)
36                  +------+
3637
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]
38    [1] in polepos, +5V; in bosco, GND
39        this value controls the ROM addressing mode:
40           if 0 (GND), A12-A15 are direct active-low chip enables
41           if 1 (Vcc), A12-A15 are address lines
4142
43    [2] in polepos, GND; in bosco, output from a 555 timer
44        this value is an external timer, which is used for some samples
4245
43CMD0-CMD3 -> K0-K3
44D0-D3     -> R0-R3
45D4-D7     -> R4-R7
46A0-A3     -> R8-R11
47A4-A7     -> R12-R15
48A8-A11    -> O0-O3
49A12-A15   -> O4-O7
50OUT0-OUT3 -> P0-P3
51/TC       -> [1]
52SI        -> [2]
53
5446***************************************************************************/
5547
5648#include "driver.h"
r4939r4940
235227
236228
237229/*-------------------------------------------------
238    device reset callback
230    device definition
239231-------------------------------------------------*/
240232
241static DEVICE_RESET( namco_52xx )
242{
243//  namco_52xx_state *state = get_safe_token(device);
244}
233static const char *DEVTEMPLATE_SOURCE = __FILE__;
245234
246
247/*-------------------------------------------------
248    device get info callback
249-------------------------------------------------*/
250
251DEVICE_GET_INFO( namco_52xx )
252{
253   switch (state)
254   {
255      /* --- the following bits of info are returned as 64-bit signed integers --- */
256      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(namco_52xx_state);            break;
257      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;            break;
258
259      /* --- the following bits of info are returned as pointers --- */
260      case DEVINFO_PTR_ROM_REGION:         info->romregion = ROM_NAME(namco_52xx);         break;
261      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = MACHINE_DRIVER_NAME(namco_52xx); break;
262
263      /* --- the following bits of info are returned as pointers to data or functions --- */
264      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(namco_52xx);    break;
265      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(namco_52xx);    break;
266
267      /* --- the following bits of info are returned as NULL-terminated strings --- */
268      case DEVINFO_STR_NAME:               strcpy(info->s, "Namco 52xx");               break;
269      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Namco I/O");               break;
270      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
271      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
272      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
273   }
274}
235#define DEVTEMPLATE_ID(p,s)      p##namco_52xx##s
236#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_ROM_REGION | DT_HAS_MACHINE_CONFIG
237#define DEVTEMPLATE_NAME      "Namco 52xx"
238#define DEVTEMPLATE_FAMILY      "Namco I/O"
239#include "devtempl.h"
src/mame/audio/namco54.c
r4939r4940
11/***************************************************************************
22
3Namco 54XX
3    Namco 54XX
44
5This custom chip is a Fujitsu MB8844 MCU programmed to act as a noise
6generator. It is used for explosions, the shoot sound in Bosconian, and the
7tire screech sound in Pole Position.
5    This custom chip is a Fujitsu MB8844 MCU programmed to act as a noise
6    generator. It is used for explosions, the shoot sound in Bosconian,
7    and the tire screech sound in Pole Position.
88
9CMD = command from main CPU
10OUTn = sound outputs (3 channels)
9    CMD = command from main CPU
10    OUTn = sound outputs (3 channels)
1111
12The chip reads the command when the /IRQ is pulled down.
12    The chip reads the command when the /IRQ is pulled down.
1313
14      +------+
15 EXTAL|1   28|Vcc
16  XTAL|2   27|CMD7
17/RESET|3   26|CMD6
18OUT0.0|4   25|CMD5
19OUT0.1|5   24|CMD4
20OUT0.2|6   23|/IRQ
21OUT0.3|7   22|n.c. [1]
22OUT1.0|8   21|n.c. [1]
23OUT1.1|9   20|OUT2.3
24OUT1.2|10  19|OUT2.2
25OUT1.3|11  18|OUT2.1
26  CMD0|12  17|OUT2.0
27  CMD1|13  16|CMD3
28   GND|14  15|CMD2
29      +------+
14                       +------+
15                     EX|1   28|Vcc
16                      X|2   27|K3 (CMD7)
17                 /RESET|3   26|K2 (CMD6)
18            (OUT0.0) O0|4   25|K1 (CMD5)
19            (OUT0.1) O1|5   24|K0 (CMD4)
20            (OUT0.2) O2|6   23|R10/IRQ
21            (OUT0.3) O3|7   22|R9/TC
22            (OUT1.0) O4|8   21|R8
23            (OUT1.1) O5|9   20|R7 (OUT2.3)
24            (OUT1.2) O6|10  19|R6 (OUT2.2)
25            (OUT1.3) O7|11  18|R5 (OUT2.1)
26              (CMD0) R0|12  17|R4 (OUT2.0)
27              (CMD1) R1|13  16|R3 (CMD3)
28                    GND|14  15|R2 (CMD2)
29                       +------+
3030
31    [1] The RNG that drives the type A output is output on pin 21, and
32    the one that drives the type B output is output on pin 22, but those
33    pins are not connected on the board.
3134
32[1] The RNG that drives the type A output is output on pin 21, and the one that
33drives the type B output is output on pin 22, but those pins are not connected
34on the board.
3535
36    The command format is very simple:
3637
37The command format is very simple:
38    0x: nop
39    1x: play sound type A
40    2x: play sound type B
41    3x: set parameters (type A) (followed by 4 bytes)
42    4x: set parameters (type B) (followed by 4 bytes)
43    5x: play sound type C
44    6x: set parameters (type C) (followed by 5 bytes)
45    7x: set volume for sound type C to x
46    8x-Fx: nop
3847
390x: nop
401x: play sound type A
412x: play sound type B
423x: set parameters (type A) (followed by 4 bytes)
434x: set parameters (type B) (followed by 4 bytes)
445x: play sound type C
456x: set parameters (type C) (followed by 5 bytes)
467x: set volume for sound type C to x
478x-Fx: nop
48
4948***************************************************************************/
5049
5150#include "driver.h"
r4939r4940
184183
185184
186185/*-------------------------------------------------
187    device reset callback
186    device definition
188187-------------------------------------------------*/
189188
190static DEVICE_RESET( namco_54xx )
191{
192//  namco_54xx_state *state = get_safe_token(device);
193}
189static const char *DEVTEMPLATE_SOURCE = __FILE__;
194190
195
196/*-------------------------------------------------
197    device get info callback
198-------------------------------------------------*/
199
200DEVICE_GET_INFO( namco_54xx )
201{
202   switch (state)
203   {
204      /* --- the following bits of info are returned as 64-bit signed integers --- */
205      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(namco_54xx_state);            break;
206      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = sizeof(namco_54xx_config);         break;
207      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;            break;
208
209      /* --- the following bits of info are returned as pointers --- */
210      case DEVINFO_PTR_ROM_REGION:         info->romregion = ROM_NAME(namco_54xx);         break;
211      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = MACHINE_DRIVER_NAME(namco_54xx); break;
212
213      /* --- the following bits of info are returned as pointers to data or functions --- */
214      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(namco_54xx);    break;
215      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(namco_54xx);    break;
216
217      /* --- the following bits of info are returned as NULL-terminated strings --- */
218      case DEVINFO_STR_NAME:               strcpy(info->s, "Namco 54xx");               break;
219      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Namco I/O");               break;
220      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
221      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
222      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
223   }
224}
191#define DEVTEMPLATE_ID(p,s)      p##namco_54xx##s
192#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_ROM_REGION | DT_HAS_MACHINE_CONFIG | DT_HAS_INLINE_CONFIG
193#define DEVTEMPLATE_NAME      "Namco 54xx"
194#define DEVTEMPLATE_FAMILY      "Namco I/O"
195#include "devtempl.h"
src/mame/machine/playch10.c
r4939r4940
2828 *************************************/
2929MACHINE_RESET( pc10 )
3030{
31   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
3231   const device_config *ppu = devtag_get_device(machine, "ppu");
32   const device_config *rp5h01 = devtag_get_device(machine, "rp5h01");
3333
3434   /* initialize latches and flip-flops */
3535   pc10_nmi_enable = pc10_dog_di = pc10_dispmask = pc10_sdcs = pc10_int_detect = 0;
r4939r4940
4646   MMC2_bank_latch[0] = MMC2_bank_latch[1] = 0xfe;
4747
4848   /* reset the security chip */
49   RP5H01_enable_w( 0, 0 );
50   RP5H01_0_reset_w( space, 0, 0 );
51   RP5H01_0_reset_w( space, 0, 1 );
52   RP5H01_enable_w( 0, 1 );
49   rp5h01_enable_w(rp5h01, 0, 0);
50   rp5h01_reset_w(rp5h01, 0, 0);
51   rp5h01_reset_w(rp5h01, 0, 1);
52   rp5h01_enable_w(rp5h01, 0, 1);
5353
5454   ppu2c0x_set_mirroring( ppu, mirroring );
5555}
r4939r4940
138138 *************************************/
139139READ8_HANDLER( pc10_prot_r )
140140{
141   const device_config *rp5h01 = devtag_get_device(space->machine, "rp5h01");
141142   int data = 0xe7;
142143
143144   /* we only support a single cart connected at slot 0 */
144   if ( cart_sel == 0 )
145   if (cart_sel == 0)
145146   {
146      RP5H01_0_enable_w( space, 0, 0 );
147      data |= ( ( ~RP5H01_counter_r( 0 ) ) << 4 ) & 0x10;   /* D4 */
148      data |= ( ( RP5H01_data_r( 0 ) ) << 3 ) & 0x08;      /* D3 */
149      RP5H01_0_enable_w( space, 0, 1 );
147      rp5h01_enable_w(rp5h01, 0, 0);
148      data |= ((~rp5h01_counter_r(rp5h01, 0)) << 4) & 0x10;   /* D4 */
149      data |= ((rp5h01_data_r(rp5h01, 0)) << 3) & 0x08;      /* D3 */
150      rp5h01_enable_w(rp5h01, 0, 1);
150151   }
151152   return data;
152153}
153154
154155WRITE8_HANDLER( pc10_prot_w )
155156{
157   const device_config *rp5h01 = devtag_get_device(space->machine, "rp5h01");
156158   /* we only support a single cart connected at slot 0 */
157   if ( cart_sel == 0 )
159   if (cart_sel == 0)
158160   {
159      RP5H01_0_enable_w( space, 0, 0 );
160      RP5H01_0_test_w( space, 0, data & 0x10 );      /* D4 */
161      RP5H01_0_clock_w( space, 0, data & 0x08 );      /* D3 */
162      RP5H01_0_reset_w( space, 0, ~data & 0x01 );   /* D0 */
163      RP5H01_0_enable_w( space, 0, 1 );
161      rp5h01_enable_w(rp5h01, 0, 0);
162      rp5h01_test_w(rp5h01, 0, data & 0x10);      /* D4 */
163      rp5h01_clock_w(rp5h01, 0, data & 0x08);      /* D3 */
164      rp5h01_reset_w(rp5h01, 0, ~data & 0x01);   /* D0 */
165      rp5h01_enable_w(rp5h01, 0, 1);
164166
165167      /* this thing gets dense at some point                      */
166168      /* it wants to jump and execute an opcode at $ffff, wich    */
167169      /* is the actual protection memory area                     */
168170      /* setting the whole 0x2000 region every time is a waste    */
169171      /* so we just set $ffff with the current value              */
170      memory_region( space->machine, "maincpu" )[0xffff] = pc10_prot_r(space,0);
172      memory_region(space->machine, "maincpu")[0xffff] = pc10_prot_r(space, 0);
171173   }
172174}
173175
r4939r4940
255257   return ret;
256258}
257259
258/* RP5H01 interface */
259static const struct RP5H01_interface rp5h01_interface =
260{
261   1,
262   { "user1" },
263   { 0 }
264};
265260
266261/*************************************
267262 *
r4939r4940
270265 *************************************/
271266DRIVER_INIT( playch10 )
272267{
273   /* initialize the security chip */
274   if ( RP5H01_init( machine, &rp5h01_interface ) )
275   {
276      fatalerror("rp5h01_interface initualization failed");
277   }
278
279268   /* set the controller to default */
280269   pc10_gun_controller = 0;
281270
src/mame/machine/s16fd.c
r4939r4940
4343   if (fd1094_set_decrypted != NULL)
4444      (*fd1094_set_decrypted)(machine, (UINT8 *)fd1094_userregion);
4545   else
46      memory_set_decrypted_region(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0, fd1094_cpuregionsize - 1, fd1094_userregion);
46      memory_set_decrypted_region(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, fd1094_cpuregionsize - 1, fd1094_userregion);
4747}
4848
4949/* this function checks the cache to see if the current state is cached,
r4939r4940
6565
6666   fd1094_state = state;
6767
68   cpu_set_reg(machine->cpu[0], M68K_PREF_ADDR, 0x0010);   // force a flush of the prefetch cache
68   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), M68K_PREF_ADDR, 0x0010);   // force a flush of the prefetch cache
6969
7070   /* set the FD1094 state ready to decrypt.. */
71   state = fd1094_set_state(fd1094_key,state) & 0xff;
71   state = fd1094_set_state(fd1094_key, state) & 0xff;
7272
7373   /* first check the cache, if its cached we don't need to decrypt it, just copy */
74   for (i=0;i<CACHE_ENTRIES;i++)
74   for (i = 0; i < CACHE_ENTRIES; i++)
7575   {
7676      if (fd1094_cached_states[i] == state)
7777      {
7878         /* copy cached state */
79         fd1094_userregion=fd1094_cacheregion[i];
79         fd1094_userregion = fd1094_cacheregion[i];
8080         set_decrypted_region(machine);
81         m68k_set_encrypted_opcode_range(machine->cpu[0],0,fd1094_cpuregionsize);
81         m68k_set_encrypted_opcode_range(cputag_get_cpu(machine, "maincpu"), 0, fd1094_cpuregionsize);
8282
8383         return;
8484      }
8585   }
8686
8787   /* mark it as cached (because it will be once we decrypt it) */
88   fd1094_cached_states[fd1094_current_cacheposition]=state;
88   fd1094_cached_states[fd1094_current_cacheposition] = state;
8989
90   for (addr=0;addr<fd1094_cpuregionsize/2;addr++)
90   for (addr = 0; addr < fd1094_cpuregionsize / 2; addr++)
9191   {
9292      UINT16 dat;
9393      dat = fd1094_decode(addr,fd1094_cpuregion[addr],fd1094_key,0);
r4939r4940
9595   }
9696
9797   /* copy newly decrypted data to user region */
98   fd1094_userregion=fd1094_cacheregion[fd1094_current_cacheposition];
98   fd1094_userregion = fd1094_cacheregion[fd1094_current_cacheposition];
9999   set_decrypted_region(machine);
100   m68k_set_encrypted_opcode_range(machine->cpu[0],0,fd1094_cpuregionsize);
100   m68k_set_encrypted_opcode_range(cputag_get_cpu(machine, "maincpu"), 0, fd1094_cpuregionsize);
101101
102102   fd1094_current_cacheposition++;
103103
104   if (fd1094_current_cacheposition>=CACHE_ENTRIES)
104   if (fd1094_current_cacheposition >= CACHE_ENTRIES)
105105   {
106106      mame_printf_debug("out of cache, performance may suffer, incrase CACHE_ENTRIES!\n");
107      fd1094_current_cacheposition=0;
107      fd1094_current_cacheposition = 0;
108108   }
109109}
110110
r4939r4940
164164      int selected_state = fd1094_selected_state;
165165      int state = fd1094_state;
166166
167      fd1094_machine_init(machine->cpu[0]);
167      fd1094_machine_init(cputag_get_cpu(machine, "maincpu"));
168168
169169      fd1094_setstate_and_decrypt(machine, selected_state);
170170      fd1094_setstate_and_decrypt(machine, state);
r4939r4940
177177   int addr;
178178
179179   /* re-decode the against the current parameter into cache entry 0 */
180   for (addr = 0; addr < fd1094_cpuregionsize/2; addr++)
180   for (addr = 0; addr < fd1094_cpuregionsize / 2; addr++)
181181   {
182182      UINT16 dat;
183      dat = fd1094_decode(addr,fd1094_cpuregion[addr],fd1094_key,0);
183      dat = fd1094_decode(addr, fd1094_cpuregion[addr], fd1094_key, 0);
184184      fd1094_cacheregion[0][addr]=dat;
185185   }
186186
r4939r4940
190190   fd1094_current_cacheposition = 1;
191191
192192   /* flush the prefetch queue */
193   cpu_set_reg(machine->cpu[0], M68K_PREF_ADDR, 0x0010);
193   cpu_set_reg(cputag_get_cpu(machine, "maincpu"), M68K_PREF_ADDR, 0x0010);
194194}
195195
196196
r4939r4940
210210
211211   for (i = 0; i < CACHE_ENTRIES; i++)
212212   {
213      fd1094_cacheregion[i] = auto_alloc_array(machine, UINT16, fd1094_cpuregionsize/2);
213      fd1094_cacheregion[i] = auto_alloc_array(machine, UINT16, fd1094_cpuregionsize / 2);
214214      fd1094_cached_states[i] = -1;
215215   }
216216     fd1094_current_cacheposition = 0;
src/mame/machine/midyunit.c
r4939r4940
292292   {
293293      case SOUND_CVSD_SMALL:
294294         williams_cvsd_init(machine);
295         memory_install_write8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), prot_start, prot_end, 0, 0, cvsd_protection_w);
295         memory_install_write8_handler(cputag_get_address_space(machine, "cvsdcpu", ADDRESS_SPACE_PROGRAM), prot_start, prot_end, 0, 0, cvsd_protection_w);
296296         cvsd_protection_base = memory_region(machine, "cvsdcpu") + 0x10000 + (prot_start - 0x8000);
297297         break;
298298
299299      case SOUND_CVSD:
300300         williams_cvsd_init(machine);
301         memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), prot_start, prot_end, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
301         memory_install_readwrite8_handler(cputag_get_address_space(machine, "cvsdcpu", ADDRESS_SPACE_PROGRAM), prot_start, prot_end, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
302302         memory_set_bankptr(machine, 9, auto_alloc_array(machine, UINT8, 0x80));
303303         break;
304304
305305      case SOUND_ADPCM:
306306         williams_adpcm_init(machine);
307         memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), prot_start, prot_end, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
307         memory_install_readwrite8_handler(cputag_get_address_space(machine, "adpcm", ADDRESS_SPACE_PROGRAM), prot_start, prot_end, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
308308         memory_set_bankptr(machine, 9, auto_alloc_array(machine, UINT8, 0x80));
309309         break;
310310
311311      case SOUND_NARC:
312312         williams_narc_init(machine);
313         memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), prot_start, prot_end, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
313         memory_install_readwrite8_handler(cputag_get_address_space(machine, "narc1cpu", ADDRESS_SPACE_PROGRAM), prot_start, prot_end, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
314314         memory_set_bankptr(machine, 9, auto_alloc_array(machine, UINT8, 0x80));
315315         break;
316316
r4939r4940
582582
583583         case SOUND_YAWDIM:
584584            soundlatch_w(space, 0, data);
585            cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_NMI, PULSE_LINE);
585            cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
586586            break;
587587      }
588588}
src/mame/machine/namco06.c
r4939r4940
11/***************************************************************************
22
3The following Namco custom chips are all instances of the same 4-bit MCU,
4the Fujitsu MB8843 (42-pin DIP package) and MB8842/MB8844 (28-pin DIP),
5differently programmed.
3    Namco 06XX
64
7chip  MCU   pins function
8---- ------ ---- --------
950XX MB8842  28  player score handling (protection)
1051XX MB8843  42  I/O (coin management built-in)
1152XX MB8843  42  sample playback
1253XX MB8843  42  I/O (steering wheel support)
1354XX MB8844  28  explosion (noise) generator
5    This chip is used as an interface to up to 4 other custom chips.
6    It signals IRQs to the custom MCUs when writes happen, and generates
7    NMIs to the controlling CPU to drive reads based on a clock.
148
1506XX interface:
16---------------
17Galaga                  51XX  ----  ----  54XX
18Bosconian (CPU board)   51XX  ----  50XX  54XX
19Bosconian (Video board) 50XX  52XX  ----  ----
20Xevious                 51XX  ----  50XX  54XX
21Dig Dug                 51XX  53XX  ----  ----
22Pole Position / PP II   51XX  53XX  52XX  54XX
9    SD0-SD7 are data I/O lines connecting to the controlling CPU
10    SEL selects either control (1) or data (0), usually connected to
11        an address line of the controlling CPU
12    /NMI is an NMI signal line for the controlling CPU
2313
14    ID0-ID7 are data I/O lines connecting to the other custom chips
15    /IO1-/IO4 are IRQ signal lines for each custom chip
2416
25Pinouts:
17                   +------+
18                [1]|1   28|Vcc
19                ID7|2   27|SD7
20                ID6|3   26|SD6
21                ID5|4   25|SD5
22                ID4|5   24|SD4
23                ID3|6   23|SD3
24                ID2|7   22|SD2
25                ID1|8   21|SD1
26                ID0|9   20|SD0
27               /IO1|10  19|/NMI
28               /IO2|11  18|/CS
29               /IO3|12  17|CLOCK
30               /IO4|13  16|R/W
31                GND|14  15|SEL
32                   +------+
2633
27        MB8843                   MB8842/MB8844
28       +------+                    +------+
29  EXTAL|1   42|Vcc            EXTAL|1   28|Vcc
30   XTAL|2   41|K3              XTAL|2   27|K3
31 /RESET|3   40|K2            /RESET|3   26|K2
32   /IRQ|4   39|K1                O0|4   25|K1
33     SO|5   38|K0                O1|5   24|K0
34     SI|6   37|R15               O2|6   23|R10 /IRQ
35/SC /TO|7   36|R14               O3|7   22|R9 /TC
36    /TC|8   35|R13               O4|8   21|R8
37     P0|9   34|R12               O5|9   20|R7
38     P1|10  33|R11               O6|10  19|R6
39     P2|11  32|R10               O7|11  18|R5
40     P3|12  31|R9                R0|12  17|R4
41     O0|13  30|R8                R1|13  16|R3
42     O1|14  29|R7               GND|14  15|R2
43     O2|15  28|R6                  +------+
44     O3|16  27|R5
45     O4|17  26|R4
46     O5|18  25|R3
47     O6|19  24|R2
48     O7|20  23|R1
49    GND|21  22|R0
50       +------+
34    [1] on polepos, galaga, xevious, and bosco: connected to K3 of the 51xx
35        on bosco and xevious, connected to R8 of the 50xx
5136
5237
53      O  O  R  R  R  K
5450XX  O  O  I     I  I
5554XX  O  O  I  O     I
38    06XX interface:
39    ---------------
40    Galaga                  51XX  ----  ----  54XX
41    Bosconian (CPU board)   51XX  ----  50XX  54XX
42    Bosconian (Video board) 50XX  52XX  ----  ----
43    Xevious                 51XX  ----  50XX  54XX
44    Dig Dug                 51XX  53XX  ----  ----
45    Pole Position / PP II   51XX  53XX  52XX  54XX
5646
57      P  O  O  R  R  R  R  K
5851XX  O  O  O  I  I  I  I  I
5952XX  O  O  O  I  I  O  O  I
6053XX  O? O  O  I  I  I  I  I
6147
48    Galaga writes:
49        control = 10(000), data = FF at startup
50        control = 71(011), read 3, control = 10
51        control = A1(101), write 4, control = 10
52        control = A8(101), write 12, control = 10
6253
63For the 52XX, see sound/namco52.c
54    Xevious writes:
55        control = 10 at startup
56        control = A1(101), write 6, control = 10
57        control = 71(011), read 3, control = 10
58        control = 64(011), write 1, control = 10
59        control = 74(011), read 4, control = 10
60        control = 68(011), write 7, control = 10
6461
65For the 54XX, see audio/namco54.c
62    Dig Dug writes:
63        control = 10(000), data = 10 at startup
64        control = A1(101), write 3, control = 10
65        control = 71(011), read 3, control = 10
66        control = D2(110), read 2, control = 10
6667
68    Bosco writes:
69        control = 10(000), data = FF at startup
70        control = C8(110), write 17, control = 10
71        control = 61(011), write 1, control = 10
72        control = 71(011), read 3, control = 10
73        control = 94(100), read 4, control = 10
74        control = 64(011), write 1, control = 10
75        control = 84(100), write 5, control = 10
76
77
78        control = 34(001), write 1, control = 10
79
6780***************************************************************************/
6881
6982#include "driver.h"
r4939r4940
8396typedef struct _namco_06xx_state namco_06xx_state;
8497struct _namco_06xx_state
8598{
86   UINT8 command;
99   UINT8 control;
87100   emu_timer *nmi_timer;
88101   const device_config *nmicpu;
89102   const device_config *device[4];
r4939r4940
121134READ8_DEVICE_HANDLER( namco_06xx_data_r )
122135{
123136   namco_06xx_state *state = get_safe_token(device);
137   UINT8 result = 0xff;
138   int devnum;
124139
125140   LOG(("%s: 06XX '%s' read offset %d\n",cpuexec_describe_context(device->machine),device->tag,offset));
126141
127   if (!(state->command & 0x10))
142   if (!(state->control & 0x10))
128143   {
129      logerror("%s: 06XX '%s' read in write mode %02x\n",cpuexec_describe_context(device->machine),device->tag,state->command);
144      logerror("%s: 06XX '%s' read in write mode %02x\n",cpuexec_describe_context(device->machine),device->tag,state->control);
130145      return 0;
131146   }
132147
133   switch (state->command & 0xf)
134   {
135      case 0x1: return (state->read[0] != NULL) ? (*state->read[0])(state->device[0],0) : 0xff;
136      case 0x2: return (state->read[1] != NULL) ? (*state->read[1])(state->device[1],0) : 0xff;
137      case 0x4: return (state->read[2] != NULL) ? (*state->read[2])(state->device[2],0) : 0xff;
138      case 0x8: return (state->read[3] != NULL) ? (*state->read[3])(state->device[3],0) : 0xff;
139      default:
140         logerror("%s: 06XX '%s' read in unsupported mode %02x\n",cpuexec_describe_context(device->machine),device->tag,state->command);
141         return 0xff;
142   }
148   for (devnum = 0; devnum < 4; devnum++)
149      if ((state->control & (1 << devnum)) && state->read[devnum] != NULL)
150         result &= (*state->read[devnum])(state->device[devnum], 0);
151
152   return result;
143153}
144154
145155
146156WRITE8_DEVICE_HANDLER( namco_06xx_data_w )
147157{
148158   namco_06xx_state *state = get_safe_token(device);
159   int devnum;
149160
150161   LOG(("%s: 06XX '%s' write offset %d = %02x\n",cpuexec_describe_context(device->machine),device->tag,offset,data));
151162
152   if (state->command & 0x10)
163   if (state->control & 0x10)
153164   {
154      logerror("%s: 06XX '%s' write in read mode %02x\n",cpuexec_describe_context(device->machine),device->tag,state->command);
165      logerror("%s: 06XX '%s' write in read mode %02x\n",cpuexec_describe_context(device->machine),device->tag,state->control);
155166      return;
156167   }
157168
158   switch (state->command & 0xf)
159   {
160      case 0x1: if (state->write[0] != NULL) (*state->write[0])(state->device[0],0,data); break;
161      case 0x2: if (state->write[1] != NULL) (*state->write[1])(state->device[1],0,data); break;
162      case 0x4: if (state->write[2] != NULL) (*state->write[2])(state->device[2],0,data); break;
163      case 0x8: if (state->write[3] != NULL) (*state->write[3])(state->device[3],0,data); break;
164      default:
165         logerror("%s: 06XX '%s' write in unsupported mode %02x\n",cpuexec_describe_context(device->machine),device->tag,state->command);
166         break;
167   }
169   for (devnum = 0; devnum < 4; devnum++)
170      if ((state->control & (1 << devnum)) && state->write[devnum] != NULL)
171         (*state->write[devnum])(state->device[devnum], 0, data);
168172}
169173
170174
r4939r4940
172176{
173177   namco_06xx_state *state = get_safe_token(device);
174178   LOG(("%s: 06XX '%s' ctrl_r\n",cpuexec_describe_context(device->machine),device->tag));
175   return state->command;
179   return state->control;
176180}
177181
178182WRITE8_DEVICE_HANDLER( namco_06xx_ctrl_w )
179183{
180184   namco_06xx_state *state = get_safe_token(device);
185   int devnum;
181186
182   LOG(("%s: 06XX '%s' command %02x\n",cpuexec_describe_context(device->machine),device->tag,data));
187   LOG(("%s: 06XX '%s' control %02x\n",cpuexec_describe_context(device->machine),device->tag,data));
183188
184   state->command = data;
189   state->control = data;
185190
186   if ((state->command & 0x0f) == 0)
191   if ((state->control & 0x0f) == 0)
187192   {
188193      LOG(("disabling nmi generate timer\n"));
189194      timer_adjust_oneshot(state->nmi_timer, attotime_never, 0);
r4939r4940
195200      // this timing is critical. Due to a bug, Bosconian will stop responding to
196201      // inputs if a transfer terminates at the wrong time.
197202      // On the other hand, the time cannot be too short otherwise the 54XX will
198      // not have enough time to process the incoming commands.
203      // not have enough time to process the incoming controls.
199204      timer_adjust_periodic(state->nmi_timer, ATTOTIME_IN_USEC(200), 0, ATTOTIME_IN_USEC(200));
200205
201      if (state->command & 0x10)
202      {
203         switch (state->command & 0xf)
204         {
205            case 0x1: if (state->readreq[0] != NULL) (*state->readreq[0])(state->device[0]); break;
206            case 0x2: if (state->readreq[1] != NULL) (*state->readreq[1])(state->device[1]); break;
207            case 0x4: if (state->readreq[2] != NULL) (*state->readreq[2])(state->device[2]); break;
208            case 0x8: if (state->readreq[3] != NULL) (*state->readreq[3])(state->device[3]); break;
209            default:
210               logerror("%s: 06XX '%s' read in unsupported mode %02x\n",cpuexec_describe_context(device->machine),device->tag,state->command);
211         }
212      }
206      if (state->control & 0x10)
207         for (devnum = 0; devnum < 4; devnum++)
208            if ((state->control & (1 << devnum)) && state->readreq[devnum] != NULL)
209               (*state->readreq[devnum])(state->device[devnum]);
213210   }
214211}
215212
r4939r4940
224221
225222static DEVICE_START( namco_06xx )
226223{
227   const namco_06xx_interface *config = (const namco_06xx_interface *)device->inline_config;
224   const namco_06xx_config *config = (const namco_06xx_config *)device->inline_config;
228225   namco_06xx_state *state = get_safe_token(device);
229226   int devnum;
230227
r4939r4940
277274   /* allocate a timer */
278275   state->nmi_timer = timer_alloc(device->machine, nmi_generate, (void *)device);
279276
280   state_save_register_device_item(device, 0, state->command);
277   state_save_register_device_item(device, 0, state->control);
281278}
282279
283280
r4939r4940
288285static DEVICE_RESET( namco_06xx )
289286{
290287   namco_06xx_state *state = get_safe_token(device);
291   state->command = 0;
288   state->control = 0;
292289}
293290
294291
295292/*-------------------------------------------------
296    device get info callback
293    device definition
297294-------------------------------------------------*/
298295
299DEVICE_GET_INFO( namco_06xx )
300{
301   switch (state)
302   {
303      /* --- the following bits of info are returned as 64-bit signed integers --- */
304      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(namco_06xx_state);            break;
305      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = sizeof(namco_06xx_interface);         break;
306      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;            break;
296static const char *DEVTEMPLATE_SOURCE = __FILE__;
307297
308      /* --- the following bits of info are returned as pointers to data or functions --- */
309      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(namco_06xx);    break;
310      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(namco_06xx);    break;
311
312      /* --- the following bits of info are returned as NULL-terminated strings --- */
313      case DEVINFO_STR_NAME:               strcpy(info->s, "Namco 06xx");               break;
314      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Namco I/O");               break;
315      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
316      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
317      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
318   }
319}
298#define DEVTEMPLATE_ID(p,s)      p##namco_06xx##s
299#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG
300#define DEVTEMPLATE_NAME      "Namco 06xx"
301#define DEVTEMPLATE_FAMILY      "Namco I/O"
302#include "devtempl.h"
src/mame/machine/namco06.h
r4939r4940
44#include "devintrf.h"
55
66
7typedef struct _namco_06xx_interface namco_06xx_interface;
8struct _namco_06xx_interface
7typedef struct _namco_06xx_config namco_06xx_config;
8struct _namco_06xx_config
99{
1010   const char *nmicpu;
1111   const char *chip0;
r4939r4940
1515};
1616
1717
18#define MDRV_NAMCO_06XX_ADD(_tag, _nmicpu, _chip0, _chip1, _chip2, _chip3) \
19   MDRV_DEVICE_ADD(_tag, NAMCO_06XX, 0) \
20   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_interface, nmicpu, _nmicpu) \
21   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_interface, chip0, _chip0) \
22   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_interface, chip1, _chip1) \
23   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_interface, chip2, _chip2) \
24   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_interface, chip3, _chip3)
18#define MDRV_NAMCO_06XX_ADD(_tag, _clock, _nmicpu, _chip0, _chip1, _chip2, _chip3) \
19   MDRV_DEVICE_ADD(_tag, NAMCO_06XX, _clock) \
20   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_config, nmicpu, _nmicpu) \
21   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_config, chip0, _chip0) \
22   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_config, chip1, _chip1) \
23   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_config, chip2, _chip2) \
24   MDRV_DEVICE_CONFIG_DATAPTR(namco_06xx_config, chip3, _chip3)
2525
2626#define MDRV_NAMCO_06XX_REMOVE(_tag) \
2727   MDRV_DEVICE_REMOVE(_tag)
src/mame/machine/toaplan1.c
r4939r4940
126126      logerror("Turning DSP on and 68000 off\n");
127127      cputag_set_input_line(machine, "dsp", INPUT_LINE_HALT, CLEAR_LINE);
128128      cputag_set_input_line(machine, "dsp", 0, ASSERT_LINE); /* TMS32010 INT */
129      cputag_set_input_line(machine, "audiocpu", INPUT_LINE_HALT, ASSERT_LINE);
129      cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, ASSERT_LINE);
130130   }
131131   else
132132   {
src/mame/machine/midtunit.c
r4939r4940
450450   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x1b00000, 0x1b6ffff, 0, 0, mk_prot_r, mk_prot_w);
451451
452452   /* sound chip protection (hidden RAM) */
453   memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0xfb9c, 0xfbc6, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
453   memory_install_readwrite8_handler(cputag_get_address_space(machine, "adpcm", ADDRESS_SPACE_PROGRAM), 0xfb9c, 0xfbc6, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
454454   memory_set_bankptr(machine, 9, auto_alloc_array(machine, UINT8, 0x80));
455455}
456456
r4939r4940
474474
475475   /* sound chip protection (hidden RAM) */
476476   if (!te_protection)
477      memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0xfbaa, 0xfbd4, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
477      memory_install_readwrite8_handler(cputag_get_address_space(machine, "adpcm", ADDRESS_SPACE_PROGRAM), 0xfbaa, 0xfbd4, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
478478   else
479      memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0xfbec, 0xfc16, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
479      memory_install_readwrite8_handler(cputag_get_address_space(machine, "adpcm", ADDRESS_SPACE_PROGRAM), 0xfbec, 0xfc16, 0, 0, (read8_space_func)SMH_BANK(9), (write8_space_func)SMH_BANK(9));
480480   memory_set_bankptr(machine, 9, auto_alloc_array(machine, UINT8, 0x80));
481481}
482482
r4939r4940
502502   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x1b00000, 0x1bfffff, 0, 0, jdredd_prot_r, jdredd_prot_w);
503503
504504   /* sound chip protection (hidden RAM) */
505   memory_install_readwrite8_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0xfbcf, 0xfbf9, 0, 0, (read8_space_func)SMH_BANK(7), (write8_space_func)SMH_BANK(9));
505   memory_install_readwrite8_handler(cputag_get_address_space(machine, "adpcm", ADDRESS_SPACE_PROGRAM), 0xfbcf, 0xfbf9, 0, 0, (read8_space_func)SMH_BANK(7), (write8_space_func)SMH_BANK(9));
506506   memory_set_bankptr(machine, 9, auto_alloc_array(machine, UINT8, 0x80));
507507
508508#if ENABLE_ALL_JDREDD_LEVELS
src/mame/machine/fddebug.c
r4939r4940
535535   debug_console_register_command(machine, "fdcsearch", CMDFLAG_NONE, 0, 0, 0, execute_fdcsearch);
536536
537537   /* set up the instruction hook */
538   debug_cpu_set_instruction_hook(machine->cpu[0], instruction_hook);
538   debug_cpu_set_instruction_hook(cputag_get_cpu(machine, "maincpu"), instruction_hook);
539539
540540   /* regenerate the key */
541541   if (keydirty)
src/mame/machine/namco53.c
r4939r4940
11/***************************************************************************
22
3Namco 53XX
3    Namco 53XX
44
5This custom chip is a Fujitsu MB8843 MCU programmed to act as an I/O device.
5    This instance of the Fujitsu MB8843 MCU is programmed to act as an I/O
6    device. It is used by just two games: Dig Dug and Pole Position.
67
7        MB8843
8       +------+
9  EXTAL|1   42|Vcc
10   XTAL|2   41|K3
11 /RESET|3   40|K2
12   /IRQ|4   39|K1
13     SO|5   38|K0
14     SI|6   37|R15
15/SC /TO|7   36|R14
16    /TC|8   35|R13
17     P0|9   34|R12
18     P1|10  33|R11
19     P2|11  32|R10
20     P3|12  31|R9
21     O0|13  30|R8
22     O1|14  29|R7
23     O2|15  28|R6
24     O3|16  27|R5
25     O4|17  26|R4
26     O5|18  25|R3
27     O6|19  24|R2
28     O7|20  23|R1
29    GND|21  22|R0
30       +------+
8    MOD0-MOD2 = input mode
9    CS0-CS3 = chip select lines used to select 1 of 4 input sources
10    OUT0-OUT7 = 8-bit final output data
11    P0.0-P0.3 = input port 0 data
12    P1.0-P1.3 = input port 1 data
13    P2.0-P2.3 = input port 2 data
14    P3.0-P3.3 = input port 3 data
3115
32Bits K1-K3 select one of 8 modes in which the input data is interpreted.
16                   +------+
17                 EX|1   42|Vcc
18                  X|2   41|K3 (MOD2)
19             /RESET|3   40|K2 (MOD1)
20               /IRQ|4   39|K1 (MOD0)
21                 SO|5   38|K0
22                 SI|6   37|R15 (P3.3)
23            /SC /TO|7   36|R14 (P3.2)
24                /TC|8   35|R13 (P3.1)
25           (CS0) P0|9   34|R12 (P3.0)
26           (CS1) P1|10  33|R11 (P2.3)
27           (CS2) P2|11  32|R10 (P2.2)
28           (CS3) P3|12  31|R9 (P2.1)
29          (OUT0) O0|13  30|R8 (P2.0)
30          (OUT1) O1|14  29|R7 (P1.3)
31          (OUT2) O2|15  28|R6 (P1.2)
32          (OUT3) O3|16  27|R5 (P1.1)
33          (OUT4) O4|17  26|R4 (P1.0)
34          (OUT5) O5|18  25|R3 (P0.3)
35          (OUT6) O6|19  24|R2 (P0.2)
36          (OUT7) O7|20  23|R1 (P0.1)
37                GND|21  22|R0 (P0.0)
38                   +------+
3339
34Pole Position is hard-wired to use mode 0, which reads 4 steering inputs
35and 4 DIP switches (only 1 of each is used).
40    MOD selects one of 8 modes in which the input data is interpreted.
3641
37Dig Dug can control which mode to use via the MOD bit latches. It sets
38these values to mode 7 when running.
42    Pole Position is hard-wired to use mode 0, which reads 4 steering
43    inputs and 4 DIP switches (only 1 of each is used). The steering
44    inputs are clocked on P0 and direction on P1, 1 bit per analog input.
45    The DIP switches are connected to P2 and P3.
3946
47    Dig Dug can control which mode to use via the MOD bit latches. It sets
48    these values to mode 7 when running.
49
50    Unknowns:
51        SO is connected to IOSEL on Pole Position
52
4053***************************************************************************/
4154
4255#include "driver.h"
r4939r4940
180193
181194
182195/*-------------------------------------------------
183    device reset callback
196    device definition
184197-------------------------------------------------*/
185198
186static DEVICE_RESET( namco_53xx )
187{
188//  namco_53xx_state *state = get_safe_token(device);
189}
199static const char *DEVTEMPLATE_SOURCE = __FILE__;
190200
191
192/*-------------------------------------------------
193    device get info callback
194-------------------------------------------------*/
195
196DEVICE_GET_INFO( namco_53xx )
197{
198   switch (state)
199   {
200      /* --- the following bits of info are returned as 64-bit signed integers --- */
201      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(namco_53xx_state);            break;
202      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;            break;
203
204      /* --- the following bits of info are returned as pointers --- */
205      case DEVINFO_PTR_ROM_REGION:         info->romregion = ROM_NAME(namco_53xx);         break;
206      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = MACHINE_DRIVER_NAME(namco_53xx); break;
207
208      /* --- the following bits of info are returned as pointers to data or functions --- */
209      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(namco_53xx);    break;
210      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(namco_53xx);    break;
211
212      /* --- the following bits of info are returned as NULL-terminated strings --- */
213      case DEVINFO_STR_NAME:               strcpy(info->s, "Namco 53xx");               break;
214      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Namco I/O");               break;
215      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
216      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
217      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
218   }
219}
201#define DEVTEMPLATE_ID(p,s)      p##namco_53xx##s
202#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_ROM_REGION | DT_HAS_MACHINE_CONFIG
203#define DEVTEMPLATE_NAME      "Namco 53xx"
204#define DEVTEMPLATE_FAMILY      "Namco I/O"
205#include "devtempl.h"
src/mame/machine/namco50.c
r4939r4940
11/***************************************************************************
22
3Namco 50XX
3    Namco 50XX
44
5This custom chip is a Fujitsu MB8842 MCU programmed to act as a protection
6device. It keeps track of the players scores, and checks if a high score has
7been obtained or bonus lives should be awarded. The main CPU has a range of
8commands to increment/decrement the score by various fixed amounts.
5    This custom chip is a Fujitsu MB8842 MCU programmed to act as a
6    protection device. It keeps track of the players scores, and checks if
7    a high score has been obtained or bonus lives should be awarded. The
8    main CPU has a range of commands to increment/decrement the score by
9    various fixed amounts.
910
10The device is used to its full potential only by Bosconian; Xevious uses it
11too, but only to do a protection check on startup.
11    The device is used to its full potential only by Bosconian; Xevious
12    uses it too, but only to do a protection check on startup.
1213
13CMD = command from main CPU
14ANS = answer to main CPU
14    CMD = command from main CPU
15    ANS = answer to main CPU
1516
16The chip reads/writes the I/O ports when the /IRQ is pulled down. Pin 21
17determines whether a read or write should happen (1=R, 0=W).
17    The chip reads/writes the I/O ports when the /IRQ is pulled down. Pin 21
18    determines whether a read or write should happen (1=R, 0=W).
1819
19      +------+
20 EXTAL|1   28|Vcc
21  XTAL|2   27|CMD7
22/RESET|3   26|CMD6
23  ANS0|4   25|CMD5
24  ANS1|5   24|CMD4
25  ANS2|6   23|/IRQ
26  ANS3|7   22|n.c.
27  ANS4|8   21|R/W
28  ANS5|9   20|n.c.
29  ANS6|10  19|n.c.
30  ANS7|11  18|n.c.
31  CMD0|12  17|n.c.
32  CMD1|13  16|CMD3
33   GND|14  15|CMD2
34      +------+
20                  +------+
21                EX|1   28|Vcc
22                 X|2   27|K3 (CMD7)
23            /RESET|3   26|K2 (CMD6)
24         (ANS0) O0|4   25|K1 (CMD5)
25         (ANS1) O1|5   24|K0 (CMD4)
26         (ANS2) O2|6   23|R10/IRQ
27         (ANS3) O3|7   22|R9/TC (n.c.)
28         (ANS4) O4|8   21|R8 (R/W)
29         (ANS5) O5|9   20|R7 (n.c.)
30         (ANS6) O6|10  19|R6 (n.c.)
31         (ANS7) O7|11  18|R5 (n.c.)
32         (CMD0) R7|12  17|R4 (n.c.)
33         (CMD1) R0|13  16|R3 (CMD3)
34               GND|14  15|R2 (CMD2)
35                  +------+
3536
3637
3738
r4939r4940
290291
291292
292293/*-------------------------------------------------
293    device reset callback
294    device definition
294295-------------------------------------------------*/
295296
296static DEVICE_RESET( namco_50xx )
297{
298//  namco_50xx_state *state = get_safe_token(device);
299}
297static const char *DEVTEMPLATE_SOURCE = __FILE__;
300298
301
302/*-------------------------------------------------
303    device get info callback
304-------------------------------------------------*/
305
306DEVICE_GET_INFO( namco_50xx )
307{
308   switch (state)
309   {
310      /* --- the following bits of info are returned as 64-bit signed integers --- */
311      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(namco_50xx_state);            break;
312      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;            break;
313
314      /* --- the following bits of info are returned as pointers --- */
315      case DEVINFO_PTR_ROM_REGION:         info->romregion = ROM_NAME(namco_50xx);         break;
316      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = MACHINE_DRIVER_NAME(namco_50xx); break;
317
318      /* --- the following bits of info are returned as pointers to data or functions --- */
319      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(namco_50xx);    break;
320      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(namco_50xx);    break;
321
322      /* --- the following bits of info are returned as NULL-terminated strings --- */
323      case DEVINFO_STR_NAME:               strcpy(info->s, "Namco 50xx");               break;
324      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Namco I/O");               break;
325      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
326      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
327      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
328   }
329}
299#define DEVTEMPLATE_ID(p,s)      p##namco_50xx##s
300#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_ROM_REGION | DT_HAS_MACHINE_CONFIG
301#define DEVTEMPLATE_NAME      "Namco 50xx"
302#define DEVTEMPLATE_FAMILY      "Namco I/O"
303#include "devtempl.h"
src/mame/machine/s24fd.c
r4939r4940
4444
4545   fd1094_state = state;
4646
47   cpu_set_reg(machine->cpu[1], M68K_PREF_ADDR, 0x0010);   // force a flush of the prefetch cache
47   cpu_set_reg(cputag_get_cpu(machine, "sub"), M68K_PREF_ADDR, 0x0010);   // force a flush of the prefetch cache
4848
4949   /* set the s24_fd1094 state ready to decrypt.. */
5050   state = fd1094_set_state(s24_fd1094_key,state) & 0xff;
5151
5252   /* first check the cache, if its cached we don't need to decrypt it, just copy */
53   for (i=0;i<S16_NUMCACHE;i++)
53   for (i = 0; i < S16_NUMCACHE; i++)
5454   {
5555      if (fd1094_cached_states[i] == state)
5656      {
5757         /* copy cached state */
58         s24_fd1094_userregion=s24_fd1094_cacheregion[i];
59         memory_set_decrypted_region(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0, s24_fd1094_cpuregionsize - 1, s24_fd1094_userregion);
60         m68k_set_encrypted_opcode_range(machine->cpu[1],0,s24_fd1094_cpuregionsize);
58         s24_fd1094_userregion = s24_fd1094_cacheregion[i];
59         memory_set_decrypted_region(cputag_get_address_space(machine, "sub", ADDRESS_SPACE_PROGRAM), 0, s24_fd1094_cpuregionsize - 1, s24_fd1094_userregion);
60         m68k_set_encrypted_opcode_range(cputag_get_cpu(machine, "sub"), 0, s24_fd1094_cpuregionsize);
6161
6262         return;
6363      }
r4939r4940
6666// mame_printf_debug("new state %04x\n",state);
6767
6868   /* mark it as cached (because it will be once we decrypt it) */
69   fd1094_cached_states[fd1094_current_cacheposition]=state;
69   fd1094_cached_states[fd1094_current_cacheposition] = state;
7070
71   for (addr=0;addr<s24_fd1094_cpuregionsize/2;addr++)
71   for (addr = 0; addr < s24_fd1094_cpuregionsize / 2; addr++)
7272   {
7373      UINT16 dat;
74      dat = fd1094_decode(addr,s24_fd1094_cpuregion[addr],s24_fd1094_key,0);
75      s24_fd1094_cacheregion[fd1094_current_cacheposition][addr]=dat;
74      dat = fd1094_decode(addr, s24_fd1094_cpuregion[addr], s24_fd1094_key, 0);
75      s24_fd1094_cacheregion[fd1094_current_cacheposition][addr] = dat;
7676   }
7777
7878   /* copy newly decrypted data to user region */
79   s24_fd1094_userregion=s24_fd1094_cacheregion[fd1094_current_cacheposition];
80   memory_set_decrypted_region(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0, s24_fd1094_cpuregionsize - 1, s24_fd1094_userregion);
81   m68k_set_encrypted_opcode_range(machine->cpu[1],0,s24_fd1094_cpuregionsize);
79   s24_fd1094_userregion = s24_fd1094_cacheregion[fd1094_current_cacheposition];
80   memory_set_decrypted_region(cputag_get_address_space(machine, "sub", ADDRESS_SPACE_PROGRAM), 0, s24_fd1094_cpuregionsize - 1, s24_fd1094_userregion);
81   m68k_set_encrypted_opcode_range(cputag_get_cpu(machine, "sub"), 0, s24_fd1094_cpuregionsize);
8282
8383   fd1094_current_cacheposition++;
8484
85   if (fd1094_current_cacheposition>=S16_NUMCACHE)
85   if (fd1094_current_cacheposition >= S16_NUMCACHE)
8686   {
8787      mame_printf_debug("out of cache, performance may suffer, incrase S16_NUMCACHE!\n");
88      fd1094_current_cacheposition=0;
88      fd1094_current_cacheposition = 0;
8989   }
9090}
9191
r4939r4940
116116{
117117   int i;
118118
119   for (i = 0;i < 4;i++)
120      s24_fd1094_userregion[i] = fd1094_decode(i,s24_fd1094_cpuregion[i],s24_fd1094_key,1);
119   for (i = 0; i < 4; i++)
120      s24_fd1094_userregion[i] = fd1094_decode(i, s24_fd1094_cpuregion[i], s24_fd1094_key, 1);
121121}
122122
123123
r4939r4940
131131   s24_fd1094_setstate_and_decrypt(machine, FD1094_STATE_RESET);
132132   s24_fd1094_kludge_reset_values();
133133
134   m68k_set_cmpild_callback(machine->cpu[1], s24_fd1094_cmp_callback);
135   m68k_set_rte_callback(machine->cpu[1], s24_fd1094_rte_callback);
136   cpu_set_irq_callback(machine->cpu[1], s24_fd1094_int_callback);
134   m68k_set_cmpild_callback(cputag_get_cpu(machine, "sub"), s24_fd1094_cmp_callback);
135   m68k_set_rte_callback(cputag_get_cpu(machine, "sub"), s24_fd1094_rte_callback);
136   cpu_set_irq_callback(cputag_get_cpu(machine, "sub"), s24_fd1094_int_callback);
137137
138   device_reset(machine->cpu[1]);
138   device_reset(cputag_get_cpu(machine, "sub"));
139139}
140140
141141static STATE_POSTLOAD( s24_fd1094_postload )
src/mame/machine/namco51.c
r4939r4940
11/***************************************************************************
22
3Namco 51XX
3    Namco 51XX
44
5This custom chip is a Fujitsu MB8843 MCU programmed to act as an I/O device
6with built-in coin management.
7 protection
8device. It keeps track of the players scores, and checks if a high score has
9been obtained or bonus lives should be awarded. The main CPU has a range of
10commands to increment/decrement the score by various fixed amounts.
5    This custom chip is a Fujitsu MB8843 MCU programmed to act as an I/O
6    device with built-in coin management. It is also apparently used as a
7    protection device. It keeps track of the players scores, and checks
8    if a high score has been obtained or bonus lives should be awarded.
9    The main CPU has a range of commands to increment/decrement the score
10    by various fixed amounts.
1111
12The device is used to its full potential only by Bosconian; Xevious uses it
13too, but only to do a protection check on startup.
12    The device is used to its full potential only by Bosconian; Xevious
13    uses it too, but only to do a protection check on startup.
1414
15CMD = command from main CPU
16ANS = answer to main CPU
15    CMD = command from main CPU
16    ANS = answer to main CPU
1717
18The chip reads/writes the I/O ports when the /IRQ is pulled down. Pin 21
19determines whether a read or write should happen (1=R, 0=W).
18    The chip reads/writes the I/O ports when the /IRQ is pulled down.
19    Pin 21 determines whether a read or write should happen (1=R, 0=W).
2020
21        MB8843
22       +------+
23  EXTAL|1   42|Vcc
24   XTAL|2   41|K3
25 /RESET|3   40|K2
26   /IRQ|4   39|K1
27     SO|5   38|K0
28     SI|6   37|R15
29/SC /TO|7   36|R14
30    /TC|8   35|R13
31     P0|9   34|R12
32     P1|10  33|R11
33     P2|11  32|R10
34     P3|12  31|R9
35     O0|13  30|R8
36     O1|14  29|R7
37     O2|15  28|R6
38     O3|16  27|R5
39     O4|17  26|R4
40     O5|18  25|R3
41     O6|19  24|R2
42     O7|20  23|R1
43    GND|21  22|R0
44       +------+
21               +------+
22             EX|1   42|Vcc
23              X|2   41|K3
24         /RESET|3   40|K2
25           /IRQ|4   39|K1
26             SO|5   38|K0
27             SI|6   37|R15
28        /SC /TO|7   36|R14
29            /TC|8   35|R13
30             P0|9   34|R12
31             P1|10  33|R11
32             P2|11  32|R10
33             P3|12  31|R9
34             O0|13  30|R8
35             O1|14  29|R7
36             O2|15  28|R6
37             O3|16  27|R5
38             O4|17  26|R4
39             O5|18  25|R3
40             O6|19  24|R2
41             O7|20  23|R1
42            GND|21  22|R0
43               +------+
4544
45    commands:
46    00: nop
47    01 + 4 arguments: set coinage (xevious, possibly because of a bug, is different)
48    02: go in "credit" mode and enable start buttons
49    03: disable joystick remapping
50    04: enable joystick remapping
51    05: go in "switch" mode
52    06: nop
53    07: nop
4654
47commands:
4800: nop
4901 + 4 arguments: set coinage (xevious, possibly because of a bug, is different)
5002: go in "credit" mode and enable start buttons
5103: disable joystick remapping
5204: enable joystick remapping
5305: go in "switch" mode
5406: nop
5507: nop
56
5755***************************************************************************/
5856
5957#include "driver.h"
r4939r4940
431429
432430
433431/*-------------------------------------------------
434    device get info callback
432    device definition
435433-------------------------------------------------*/
436434
437DEVICE_GET_INFO( namco_51xx )
438{
439   switch (state)
440   {
441      /* --- the following bits of info are returned as 64-bit signed integers --- */
442      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(namco_51xx_state);            break;
443      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_PERIPHERAL;            break;
435static const char *DEVTEMPLATE_SOURCE = __FILE__;
444436
445      /* --- the following bits of info are returned as pointers --- */
446      case DEVINFO_PTR_ROM_REGION:         info->romregion = ROM_NAME(namco_51xx);         break;
447      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = MACHINE_DRIVER_NAME(namco_51xx); break;
448
449      /* --- the following bits of info are returned as pointers to data or functions --- */
450      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(namco_51xx);    break;
451      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(namco_51xx);    break;
452
453      /* --- the following bits of info are returned as NULL-terminated strings --- */
454      case DEVINFO_STR_NAME:               strcpy(info->s, "Namco 51xx");               break;
455      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Namco I/O");               break;
456      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
457      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
458      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
459   }
460}
437#define DEVTEMPLATE_ID(p,s)      p##namco_51xx##s
438#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_ROM_REGION | DT_HAS_MACHINE_CONFIG
439#define DEVTEMPLATE_NAME      "Namco 51xx"
440#define DEVTEMPLATE_FAMILY      "Namco I/O"
441#include "devtempl.h"
src/mame/machine/slapstic.c
r4939r4940
807807
808808void slapstic_init(running_machine *machine, int chip)
809809{
810   cpu_type cputype = cpu_get_type(machine->cpu[0]);
810   cpu_type cputype = cpu_get_type(cputag_get_cpu(machine, "maincpu"));
811811
812812   /* only a small number of chips are known to exist */
813813   if (chip < 101 || chip > 118)
src/mame/mamedriv.c
r4939r4940
25192519   DRIVER( nemoj )      /* 20/11/1990 (c) 1990 (Japan) */
25202520   DRIVER( sf2 )      /* 22/05/1991 (c) 1991 (World) */
25212521   DRIVER( sf2eb )      /* 14/02/1991 (c) 1991 (World) */
2522   DRIVER( sf2ebbl )   /* 14/02/1991 (c) 1991 (World, bootleg) */
25222523   DRIVER( sf2ua )      /* 06/02/1991 (c) 1991 (US)    */
25232524   DRIVER( sf2ub )      /* 14/02/1991 (c) 1991 (US)    */
25242525   DRIVER( sf2ud )      /* 18/03/1991 (c) 1991 (US)    */
r4939r4940
53415342   DRIVER( moobl )      /* bootleg */
53425343   DRIVER( bucky )      /* GX173 (c) 1992 (World) */
53435344   DRIVER( buckyua )   /* GX173 (c) 1992 (US) */
5345   DRIVER( buckyaa )   /* GX173 (c) 1992 (Asia) */
53445346   DRIVER( gaiapols )   /* GX123 (c) 1993 (Europe) */
53455347   DRIVER( gaiapolu )   /* GX123 (c) 1993 (US) */
53465348   DRIVER( gaiapolj )   /* GX123 (c) 1993 (Japan) */
r4939r4940
67246726   DRIVER( crusnw20 )   /* (c) 1996 Midway */
67256727   DRIVER( crusnw17 )   /* (c) 1996 Midway */
67266728   DRIVER( crusnw13 )   /* (c) 1996 Midway */
6727   DRIVER( offroadc )   /* (c) 1997 Midway (v1.40) */
6729   DRIVER( offroadc )   /* (c) 1997 Midway (v1.63) */
6730   DRIVER( offrodc4 )   /* (c) 1997 Midway (v1.40) */
67286731   DRIVER( offrodc3 )   /* (c) 1997 Midway (v1.30) */
67296732   DRIVER( offrodc1 )   /* (c) 1997 Midway (v1.10) */
67306733   DRIVER( wargods )   /* (c) 1996 Midway */
r4939r4940
67786781   DRIVER( tm3ka )      /* (c) 1997 Midway Games */
67796782   DRIVER( tm4k )      /* (c) 1998 Midway Games */
67806783   DRIVER( tm5k )      /* (c) 1998 Midway Games */
6784   DRIVER( tm5kca )   /* (c) 1998 Midway Games */
67816785   DRIVER( tm7k )      /* (c) 1999 Midway Games */
67826786   DRIVER( tm7ka )      /* (c) 1999 Midway Games */
6787   DRIVER( tm7keval )   /* (c) 1999 Midway Games */
67836788   DRIVER( tm8k )      /* (c) 2000 Midway Games */
67846789   DRIVER( galgbios )  /* (c) 1998 Creative Electonics & Software (CES) */
67856790
src/mame/mame.mak
r4939r4940
3030
3131#-------------------------------------------------
3232# specify available CPU cores; some of these are
33# only for MESS and so aren't included
33# only for MESS, but are included so that they get
34# updated with any MAME core changes
3435#-------------------------------------------------
3536
3637CPUS += Z80
r4939r4940
109110CPUS += TMS7000
110111CPUS += SM8500
111112CPUS += MINX
113CPUS += SSEM
112114
113115
114
115116#-------------------------------------------------
116117# specify available sound cores; some of these are
117118# only for MESS and so aren't included
src/mame/video/antic.c
r4939r4940
9090      data = antic.r.antic09;
9191      break;
9292   case 10: /* WSYNC read */
93      cpu_spinuntil_trigger(space->machine->cpu[0], TRIGGER_HSYNC);
93      cpu_spinuntil_trigger(cputag_get_cpu(space->machine, "maincpu"), TRIGGER_HSYNC);
9494      antic.w.wsync = 1;
9595      data = antic.r.antic0a;
9696      break;
r4939r4940
200200      break;
201201   case 10: /* WSYNC write */
202202      LOG(("ANTIC 0A write WSYNC  $%02X\n", data));
203      cpu_spinuntil_trigger(space->machine->cpu[0], TRIGGER_HSYNC);
203      cpu_spinuntil_trigger(cputag_get_cpu(space->machine, "maincpu"), TRIGGER_HSYNC);
204204      antic.w.wsync = 1;
205205      break;
206206   case 11:
src/mame/video/taitoic.c
r4939r4940
612612
613613int TC0100SCN_count(running_machine *machine)
614614{
615   int mask = (has_write_handler(machine->cpu[0], TC0100SCN_word_0_w) ||
616      has_write_handler(machine->cpu[0], TC0100SCN_dual_screen_w) ||
617      has_write_handler(machine->cpu[0], TC0100SCN_triple_screen_w)) ? 1 : 0;
618   mask |= has_write_handler(machine->cpu[0], TC0100SCN_word_1_w) << 1;
619   mask |= has_write_handler(machine->cpu[0], TC0100SCN_word_2_w) << 2;
615   int mask = (has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0100SCN_word_0_w) ||
616      has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0100SCN_dual_screen_w) ||
617      has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0100SCN_triple_screen_w)) ? 1 : 0;
618   mask |= has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0100SCN_word_1_w) << 1;
619   mask |= has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0100SCN_word_2_w) << 2;
620620
621621   /* Catch illegal configurations */
622622   /* TODO: we should give an appropriate warning */
623623   assert_always(mask == 0 || mask == 1 || mask == 3 || mask == 7, "Invalid TC0110PCR configuration");
624   return BIT(mask,0) + BIT(mask,1) + BIT(mask,2);
624   return BIT(mask, 0) + BIT(mask, 1) + BIT(mask, 2);
625625}
626626
627627
628628int TC0110PCR_mask(running_machine *machine)
629629{
630   int mask = (has_write_handler(machine->cpu[0], TC0110PCR_word_w) ||
631         has_write_handler(machine->cpu[0], TC0110PCR_step1_word_w) ||
632         has_write_handler(machine->cpu[0], TC0110PCR_step1_rbswap_word_w) ||
633         has_write_handler(machine->cpu[0], TC0110PCR_step1_4bpg_word_w)) ? 1 : 0;
634   mask |= has_write_handler(machine->cpu[0], TC0110PCR_step1_word_1_w) << 1;
635   mask |= has_write_handler(machine->cpu[0], TC0110PCR_step1_word_2_w) << 2;
630   int mask = (has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0110PCR_word_w) ||
631         has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0110PCR_step1_word_w) ||
632         has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0110PCR_step1_rbswap_word_w) ||
633         has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0110PCR_step1_4bpg_word_w)) ? 1 : 0;
634   mask |= has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0110PCR_step1_word_1_w) << 1;
635   mask |= has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0110PCR_step1_word_2_w) << 2;
636636   return mask;
637637}
638638
639639int has_TC0150ROD(running_machine *machine)
640640{
641   return   has_write_handler(machine->cpu[0], TC0150ROD_word_w) ||
642         has_write_handler(machine->cpu[1], TC0150ROD_word_w) ||
643         has_write_handler(machine->cpu[2], TC0150ROD_word_w);
641   return   has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0150ROD_word_w) ||
642         has_write_handler(cputag_get_cpu(machine, "audiocpu"), TC0150ROD_word_w) ||
643         has_write_handler(cputag_get_cpu(machine, "sub"), TC0150ROD_word_w);
644644}
645645
646646
647647int has_TC0280GRD(running_machine *machine)
648648{
649   return   has_write_handler(machine->cpu[0], TC0280GRD_word_w);
649   return   has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0280GRD_word_w);
650650}
651651
652652
653653int has_TC0360PRI(running_machine *machine)
654654{
655   return   has_write_handler8(machine->cpu[0], TC0360PRI_w);
655   return   has_write_handler8(cputag_get_cpu(machine, "maincpu"), TC0360PRI_w);
656656}
657657
658658
659659int has_TC0430GRW(running_machine *machine)
660660{
661   return   has_write_handler(machine->cpu[0], TC0430GRW_word_w);
661   return   has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0430GRW_word_w);
662662}
663663
664664
665665int has_TC0480SCP(running_machine *machine)
666666{
667   return   has_write_handler(machine->cpu[0], TC0480SCP_word_w);
667   return   has_write_handler(cputag_get_cpu(machine, "maincpu"), TC0480SCP_word_w);
668668}
669669
670670
src/mame/video/cps1.c
r4939r4940
12791279   {"cawingj",  CPS_B_16,     mapper_CA22B },   // equivalent to CA24B
12801280   {"sf2",      CPS_B_11,     mapper_STF29,  0x36 },
12811281   {"sf2eb",    CPS_B_17,     mapper_STF29,  0x36 },
1282   {"sf2ebbl",  CPS_B_17,     mapper_STF29,  0x36, 0, 0, 1  },
12821283   {"sf2ua",    CPS_B_17,     mapper_STF29,  0x36 },
12831284   {"sf2ub",    CPS_B_17,     mapper_STF29,  0x36 },
12841285   {"sf2ud",    CPS_B_05,     mapper_STF29,  0x36 },
src/mame/video/cischeat.c
r4939r4940
297297      case 0x2208/2   : break;   // watchdog reset
298298
299299      /* Not sure about this one.. */
300      case 0x2308/2   :   cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
301                     cpu_set_input_line(space->machine->cpu[2], INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
302                     cpu_set_input_line(space->machine->cpu[3], INPUT_LINE_RESET, (new_data & 1) ? ASSERT_LINE : CLEAR_LINE );
300      case 0x2308/2   :   cputag_set_input_line(space->machine, "cpu2", INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
301                     cputag_set_input_line(space->machine, "cpu3", INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
302                     cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, (new_data & 1) ? ASSERT_LINE : CLEAR_LINE );
303303                     break;
304304
305305      default: SHOW_WRITE_ERROR("vreg %04X <- %04X",offset*2,data);
r4939r4940
384384      case 0x2208/2   : break;   // watchdog reset
385385
386386      case 0x2300/2   :   /* Sound CPU: reads latch during int 4, and stores command */
387                     soundlatch_word_w(space,0,new_data,0xffff);
388                     cpu_set_input_line(space->machine->cpu[3],4,HOLD_LINE);
387                     soundlatch_word_w(space, 0, new_data, 0xffff);
388                     cputag_set_input_line(space->machine, "soundcpu", 4, HOLD_LINE);
389389                     break;
390390
391391      /* Not sure about this one.. */
392      case 0x2308/2   :   cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
393                     cpu_set_input_line(space->machine->cpu[2], INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
394                     cpu_set_input_line(space->machine->cpu[3], INPUT_LINE_RESET, (new_data & 1) ? ASSERT_LINE : CLEAR_LINE );
392      case 0x2308/2   :   cputag_set_input_line(space->machine, "cpu2", INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
393                     cputag_set_input_line(space->machine, "cpu3", INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
394                     cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, (new_data & 1) ? ASSERT_LINE : CLEAR_LINE );
395395                     break;
396396
397397      default: SHOW_WRITE_ERROR("vreg %04X <- %04X",offset*2,data);
r4939r4940
499499      case 0x0014/2   :   break;
500500
501501      /* Usually written in sequence, but not always */
502      case 0x0008/2   :   soundlatch_word_w(space,0,new_data,0xffff);   break;
503      case 0x0018/2   :   cpu_set_input_line(space->machine->cpu[3],4,HOLD_LINE);   break;
502      case 0x0008/2   :   soundlatch_word_w(space, 0, new_data, 0xffff);   break;
503      case 0x0018/2   :   cputag_set_input_line(space->machine, "soundcpu", 4, HOLD_LINE);   break;
504504
505505      case 0x0010/2   :   break;
506506
r4939r4940
520520      case 0x2208/2   : break;   // watchdog reset
521521
522522      /* Not sure about this one. Values: $10 then 0, $7 then 0 */
523      case 0x2308/2   :   cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, (new_data & 1) ? ASSERT_LINE : CLEAR_LINE );
524                     cpu_set_input_line(space->machine->cpu[2], INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
525                     cpu_set_input_line(space->machine->cpu[3], INPUT_LINE_RESET, (new_data & 4) ? ASSERT_LINE : CLEAR_LINE );
523      case 0x2308/2   :   cputag_set_input_line(space->machine, "cpu2", INPUT_LINE_RESET, (new_data & 1) ? ASSERT_LINE : CLEAR_LINE );
524                     cputag_set_input_line(space->machine, "cpu3", INPUT_LINE_RESET, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE );
525                     cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, (new_data & 4) ? ASSERT_LINE : CLEAR_LINE );
526526                     break;
527527
528528      default:      SHOW_WRITE_ERROR("vreg %04X <- %04X",offset*2,data);
r4939r4940
542542      case 0x0000/2   :
543543         if (ACCESSING_BITS_0_7)
544544         {
545            cpu_set_input_line(space->machine->cpu[4],4,(new_data & 4)?ASSERT_LINE:CLEAR_LINE);
546            cpu_set_input_line(space->machine->cpu[4],2,(new_data & 2)?ASSERT_LINE:CLEAR_LINE);
545            cputag_set_input_line(space->machine, "cpu5", 4, (new_data & 4) ? ASSERT_LINE : CLEAR_LINE);
546            cputag_set_input_line(space->machine, "cpu5", 2, (new_data & 2) ? ASSERT_LINE : CLEAR_LINE);
547547         }
548548         break;
549549
550550      default:
551         f1gpstar_vregs_w(space,offset,data,mem_mask);
551         f1gpstar_vregs_w(space, offset, data, mem_mask);
552552         break;
553553   }
554554}
r4939r4940
13431343   if (msk != 0) megasys1_active_layers &= msk;
13441344#if 1
13451345   {
1346      const address_space *space = cpu_get_address_space(screen->machine->cpu[0], ADDRESS_SPACE_PROGRAM);
1346      const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
13471347
13481348      popmessage("Cmd: %04X Pos:%04X Lim:%04X Inp:%04X",
13491349                     scudhamm_motor_command,
src/mame/video/moo.c
r4939r4940
5252
5353   K056832_vh_start(machine, "gfx1", K056832_BPP_4, 1, NULL, moo_tile_callback, 0);
5454
55   if (!strcmp(machine->gamedrv->name, "bucky") || !strcmp(machine->gamedrv->name, "buckyua"))
55   if (!strcmp(machine->gamedrv->name, "bucky") || !strcmp(machine->gamedrv->name, "buckyua") || !strcmp(machine->gamedrv->name, "buckyaa"))
5656   {
5757      // Bucky doesn't chain tilemaps
5858      K056832_set_LayerAssociation(0);
src/mame/drivers/crystal.c
r4939r4940
337337
338338static WRITE32_HANDLER(PIO_w)
339339{
340   UINT32 RST=data&0x01000000;
341   UINT32 CLK=data&0x02000000;
342   UINT32 DAT=data&0x10000000;
340   const device_config *ds1302 = devtag_get_device(space->machine, "rtc");
341   UINT32 RST = data & 0x01000000;
342   UINT32 CLK = data & 0x02000000;
343   UINT32 DAT = data & 0x10000000;
343344
344   DS1302_RST(RST?1:0);
345   DS1302_DAT(DAT?1:0);
346   DS1302_CLK(space->machine, CLK?1:0);
345   if (!RST)
346      device_reset(ds1302);
347347
348   if(DS1302_RD())
349      memory_write_dword(space,0x01802008,memory_read_dword(space,0x01802008)|0x10000000);
348   ds1302_dat_w(ds1302, 0, DAT ? 1 : 0);
349   ds1302_clk_w(ds1302, 0, CLK ? 1 : 0);
350
351   if (ds1302_read(ds1302, 0))
352      memory_write_dword(space, 0x01802008, memory_read_dword(space, 0x01802008) | 0x10000000);
350353   else
351      memory_write_dword(space,0x01802008,memory_read_dword(space,0x01802008)&(~0x10000000));
354      memory_write_dword(space, 0x01802008, memory_read_dword(space, 0x01802008) & (~0x10000000));
352355
353356   COMBINE_DATA(&PIO);
354357}
r4939r4940
757760   MDRV_PALETTE_INIT(RRRRR_GGGGGG_BBBBB)
758761   MDRV_PALETTE_LENGTH(65536)
759762
763   MDRV_DS1302_ADD("rtc")
764
760765   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
761766
762767   MDRV_SOUND_ADD("vrender", VRENDER0, 0)
src/mame/drivers/eprom.c
r4939r4940
4949
5050static void update_interrupts(running_machine *machine)
5151{
52   cpu_set_input_line(machine->cpu[0], 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE);
53   cpu_set_input_line(machine->cpu[1], 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE);
54   cpu_set_input_line(machine->cpu[0], 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE);
52   cputag_set_input_line(machine, "maincpu", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE);
53
54   if (cputag_get_cpu(machine, "extra") != NULL)
55      cputag_set_input_line(machine, "extra", 4, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE);
56
57   cputag_set_input_line(machine, "maincpu", 6, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE);
5558}
5659
5760
r4939r4940
111114
112115static WRITE16_HANDLER( eprom_latch_w )
113116{
114   if (ACCESSING_BITS_0_7)
117   if (ACCESSING_BITS_0_7 && (cputag_get_cpu(space->machine, "extra") != NULL))
115118   {
116119      /* bit 0: reset extra CPU */
117120      if (data & 1)
118         cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, CLEAR_LINE);
121         cputag_set_input_line(space->machine, "extra", INPUT_LINE_RESET, CLEAR_LINE);
119122      else
120         cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, ASSERT_LINE);
123         cputag_set_input_line(space->machine, "extra", INPUT_LINE_RESET, ASSERT_LINE);
121124
122125      /* bits 1-4: screen intensity */
123126      eprom_screen_intensity = (data & 0x1e) >> 1;
r4939r4940
726729   atarijsa_init(machine, "260010", 0x0002);
727730
728731   /* install CPU synchronization handlers */
729   sync_data = memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x16cc00, 0x16cc01, 0, 0, sync_r, sync_w);
730   sync_data = memory_install_readwrite16_handler(cpu_get_address_space(machine->cpu[1], ADDRESS_SPACE_PROGRAM), 0x16cc00, 0x16cc01, 0, 0, sync_r, sync_w);
732   sync_data = memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x16cc00, 0x16cc01, 0, 0, sync_r, sync_w);
733   sync_data = memory_install_readwrite16_handler(cputag_get_address_space(machine, "extra", ADDRESS_SPACE_PROGRAM), 0x16cc00, 0x16cc01, 0, 0, sync_r, sync_w);
731734}
732735
733736
src/mame/drivers/ultrsprt.c
r4939r4940
22
33    Driver by Ville Linde
44
5TODO:
6- sound cpu irqs generation is unknown and very prone to get broken (i.e. if 4G and 2G returns as bad in POST screen).
7- sound is lagged, reason is probably the same as above.
8
59*/
610
711#include "driver.h"
r4939r4940
234238   if (irq == 0)
235239      /*generic_pulse_irq_line(cputag_get_cpu(machine, "audiocpu"), INPUT_LINE_IRQ5)*/;
236240   else
237      cputag_set_input_line(machine, "maincpu", INPUT_LINE_IRQ6, HOLD_LINE);
241      cputag_set_input_line(machine, "audiocpu", INPUT_LINE_IRQ6, HOLD_LINE);
238242}
239243
240244static DRIVER_INIT( ultrsprt )
src/mame/drivers/twinkle.c
r4939r4940
943943   ROM_LOAD( "a03j.pd",      0x000000, 0x000100, BAD_DUMP CRC(1faf8d1b) SHA1(e8d9d216a8f5459598ff68692f9197e226a231e6) )
944944
945945   DISK_REGION( "cdrom0" )
946   DISK_IMAGE_READONLY( "a03jaa01", 0, BAD_DUMP MD5(dccbe0158236453c27a9768d185ee275) SHA1(ee0f5989ed2bec3d174150a072e188bc10c15dcb) )
946   DISK_IMAGE_READONLY( "a03jaa01", 0, BAD_DUMP SHA1(2a587b5524bac6f03d26b55247a0acd22aad6c3a) )
947947//  DISK_IMAGE_READONLY( "a03jaahd", 1, NO_DUMP )
948948//  DISK_IMAGE_READONLY( "a03jaa02", 2, NO_DUMP )
949949ROM_END
r4939r4940
955955   ROM_LOAD( "b4uj.pd",      0x000000, 0x000100, BAD_DUMP CRC(0ab15633) SHA1(df004ff41f35b16089f69808ccf53a5e5cc13ac3) )
956956
957957   DISK_REGION( "cdrom0" )
958   DISK_IMAGE_READONLY( "b4ujaa01", 0, BAD_DUMP MD5(c9397ff1399b268ceac98732e4d7b16d) SHA1(1e723c74fd93140881c00c5af402249e0a8b3f2f) )
958   DISK_IMAGE_READONLY( "b4ujaa01", 0, BAD_DUMP SHA1(d8f5d56b8728bea761dc4cdbc04851094d276bd6) )
959959//  DISK_IMAGE_READONLY( "b4ujaahd", 1, NO_DUMP )
960960//  DISK_IMAGE_READONLY( "b4ujaa02", 2, NO_DUMP )
961961ROM_END
r4939r4940
967967   ROM_LOAD( "b44j.pd",      0x000000, 0x000100, BAD_DUMP CRC(5baf4761) SHA1(aa7e07eb2cada03b85bdf11ac6a3de65f4253eef) )
968968
969969   DISK_REGION( "cdrom0" )
970   DISK_IMAGE_READONLY( "b44jaa01", 0, BAD_DUMP MD5(3078c73d050bb6a513b329f3844e1208) SHA1(5910e557816ced2c5162c5458b5ccf6f8e6839f0) )
970   DISK_IMAGE_READONLY( "b44jaa01", 0, BAD_DUMP SHA1(a21610f3dc090e39e125d063442ed877fa056146) )
971971//  DISK_IMAGE_READONLY( "b44jaahd", 1, NO_DUMP )
972972//  DISK_IMAGE_READONLY( "b44jaa02", 2, NO_DUMP )
973973ROM_END
r4939r4940
979979   ROM_LOAD( "c44j.pd",      0x000000, 0x000100, BAD_DUMP CRC(04c22349) SHA1(d1cb78911cb1ca660d393a81ed3ed07b24c51525) )
980980
981981   DISK_REGION( "cdrom0" )
982   DISK_IMAGE_READONLY( "c44jaa01", 0, BAD_DUMP MD5(43ae8f40ba8974d7d135e83c8e09112a) SHA1(b116775e47c7d5e2578b92811dccdc84f1cafe43) )
982   DISK_IMAGE_READONLY( "c44jaa01", 0, BAD_DUMP SHA1(8b544c81bc56b19e4aa1649e68824811d6d51ce5) )
983983//  DISK_IMAGE_READONLY( "c44jaahd", 1, NO_DUMP )
984984//  DISK_IMAGE_READONLY( "c44jaa02", 2, NO_DUMP )
985985ROM_END
r4939r4940
991991   ROM_LOAD( "896j.pd",      0x000000, 0x000100, BAD_DUMP CRC(1e5caf37) SHA1(75b378662b651cb322e41564d3bae68cc9edadc5) )
992992
993993   DISK_REGION( "cdrom0" )
994   DISK_IMAGE_READONLY( "896jaabm", 0, MD5(f842277762e330d500fa3eb6755c1547) SHA1(965772160177df43ce7a94f0e12d8cf676e57228) )
994   DISK_IMAGE_READONLY( "896jaabm", 0, SHA1(af008e5bcf18da4e9aea752a712c843e37a74be5) )
995995//  DISK_IMAGE_READONLY( "abmjaahd", 1, NO_DUMP )
996996//  DISK_IMAGE_READONLY( "abmjaa02", 2, NO_DUMP )
997997ROM_END
r4939r4940
10031003   ROM_LOAD( "984j.pd",      0x000000, 0x000100, BAD_DUMP CRC(213843e5) SHA1(5571db155a60fa4087dd996af48e8e27fc1c518c) )
10041004
10051005   DISK_REGION( "cdrom0" )
1006   DISK_IMAGE_READONLY( "984a01bm", 0, MD5(61ada5db9fcbfa01971c5f06253ab5e1) SHA1(98d5e120d0cd08e8598bfde75b16ba62bf67a15b) )
1006   DISK_IMAGE_READONLY( "984a01bm", 0, SHA1(d9b7d74a72a76e4e9cf7725e0fb8dafcc1c87187) )
10071007//  DISK_IMAGE_READONLY( "abmjaahd", 1, NO_DUMP )
10081008//  DISK_IMAGE_READONLY( "abmjaa02", 2, NO_DUMP )
10091009ROM_END
r4939r4940
10151015   ROM_LOAD( "896j.pd",      0x000000, 0x000100, BAD_DUMP CRC(1e5caf37) SHA1(75b378662b651cb322e41564d3bae68cc9edadc5) )
10161016
10171017   DISK_REGION( "cdrom0" )
1018   DISK_IMAGE_READONLY( "896jabbm", 0, MD5(46f8bd83e8fbe527f6e4512804b2ce1e) SHA1(b7fcf3e6b9c1cebedacbc65c77aa3509c66984a9) )
1018   DISK_IMAGE_READONLY( "896jabbm", 0, SHA1(117ae4c876207bbaf9e8fe0fdf5bb161155c1bdb) )
10191019//  DISK_IMAGE_READONLY( "abmjaahd", 1, NO_DUMP )
10201020//  DISK_IMAGE_READONLY( "abmjaa02", 2, NO_DUMP )
10211021ROM_END
src/mame/drivers/pipedrm.c
r4939r4940
44
55    driver by Bryan McPhail & Aaron Giles
66
7Pipe Dreams
8  PCB# OP-11A-05
9  OSC:
10   12.000MHz   (next to Z80B Main CPU)
11   14.31818MHz (next to Z80B Sub CPU)
12    8.000MHz   (near YM2610 audio chip)
13
14Hatris coinage:
15  MAME uses the values listed in Test Mode.
16  This does NOT match what's listed in Hatris Manual:
17
18DIPSW-1 (from Hatris manual)
19------------------------------------------------------------------
20    DipSwitch Title   | Function | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
21------------------------------------------------------------------
22                      | 1cn/1pl  |off|off|off|off|               |*
23                      | 1cn/2pl  |on |off|off|off|               |
24                      | 1cn/3pl  |off|on |off|off|               |
25                      | 1cn/4pl  |on |on |off|off|               |
26                      | 1cn/5pl  |off|off|on |off|               |
27                      | 1cn/6pl  |on |off|on |off|               |
28     Coin Chute 1     | 2cn/1pl  |off|on |on |off|               |
29                      | 3cn/1pl  |on |on |on |off|               |
30                      | 4cn/1pl  |off|off|off|on |               |
31                      | 5cn/1pl  |on |off|off|on |               |
32                      | 2cn/3pl  |off|on |off|on |               |
33                      | Multi A  |on |on |off|on |               |
34                      | Multi B  |off|off|on |on |               |
35                      | Multi C  |on |off|on |on |               |
36                      | Multi D  |off|on |on |on |               |
37                      | Multi E  |on |on |on |on |               |
38------------------------------------------------------------------
39                      | 1cn/1pl  |               |off|off|off|off|*
40                      | 1cn/2pl  |               |on |off|off|off|
41                      | 1cn/3pl  |               |off|on |off|off|
42                      | 1cn/4pl  |               |on |on |off|off|
43                      | 1cn/5pl  |               |off|off|on |off|
44                      | 1cn/6pl  |               |on |off|on |off|
45     Coin Chute 2     | 2cn/1pl  |               |off|on |on |off|
46                      | 3cn/1pl  |               |on |on |on |off|
47                      | 4cn/1pl  |               |off|off|off|on |
48                      | 5cn/1pl  |               |on |off|off|on |
49                      | 2cn/3pl  |               |off|on |off|on |
50                      | Multi A  |               |on |on |off|on |
51                      | Multi B  |               |off|off|on |on |
52                      | Multi C  |               |on |off|on |on |
53                      | Multi D  |               |off|on |on |on |
54                      | Multi E  |               |on |on |on |on |
55------------------------------------------------------------------
56
57Added Multiple Coin Feature:
58  Multi A = 2cn/1pl  4cn/2pl  5cn/3pl  6cn/4pl
59  Multi B = 2cn/1pl  4cn/3pl
60  Multi C = 1cn/1pl  2cn/2pl  3cn/3pl  4cn/4pl  5cn/6pl
61  Multi D = 1cn/1pl  2cn/2pl  3cn/3pl  4cn/5pl
62  Multi E = 1cn/1pl  2cn/3pl
63
764****************************************************************************
865
966    Memory map
r4939r4940
316373   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
317374
318375   PORT_START("DSW1")   /* $22 */
319   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
376   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )   PORT_DIPLOCATION("SW1:1,2,3,4")
320377   PORT_DIPSETTING(    0x06, DEF_STR( 5C_1C ) )
321378   PORT_DIPSETTING(    0x07, DEF_STR( 4C_1C ) )
322379   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )
r4939r4940
333390   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
334391   PORT_DIPSETTING(    0x0b, DEF_STR( 1C_5C ) )
335392   PORT_DIPSETTING(    0x0a, DEF_STR( 1C_6C ) )
336   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
393   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )   PORT_DIPLOCATION("SW1:5,6,7,8")
337394   PORT_DIPSETTING(    0x60, DEF_STR( 5C_1C ) )
338395   PORT_DIPSETTING(    0x70, DEF_STR( 4C_1C ) )
339396   PORT_DIPSETTING(    0x80, DEF_STR( 3C_1C ) )
r4939r4940
352409   PORT_DIPSETTING(    0xa0, DEF_STR( 1C_6C ) )
353410
354411   PORT_START("DSW2")   /* $23 */
355   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
412   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW2:1,2")
356413   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
357414   PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
358415   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
359416   PORT_DIPSETTING(    0x00, "Super" )
360   PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Lives ) )
417   PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Lives ) )   PORT_DIPLOCATION("SW2:3,4")
361418   PORT_DIPSETTING(    0x0c, "1" )
362419   PORT_DIPSETTING(    0x08, "2" )
363420   PORT_DIPSETTING(    0x04, "3" )
364421   PORT_DIPSETTING(    0x00, "4" )
365   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) )
422   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW2:5")
366423   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
367424   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
368   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )
425   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Flip_Screen ) )   PORT_DIPLOCATION("SW2:6")
369426   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
370427   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
371   PORT_DIPNAME( 0x40, 0x40, "Training Mode" )
428   PORT_DIPNAME( 0x40, 0x40, "Training Mode" )   PORT_DIPLOCATION("SW2:7")
372429   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
373430   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
374   PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
431   PORT_SERVICE_DIPLOC( 0x0080, IP_ACTIVE_LOW, "SW2:8" )
375432INPUT_PORTS_END
376433
377434
r4939r4940
407464   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
408465
409466   PORT_START("DSW1")   /* $22 */
410   PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_A ) )
467   PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_A ) )   PORT_DIPLOCATION("SW1:1,2,3,4")
411468   PORT_DIPSETTING(    0x09, DEF_STR( 5C_1C ) )
412469   PORT_DIPSETTING(    0x08, DEF_STR( 4C_1C ) )
413470   PORT_DIPSETTING(    0x07, DEF_STR( 3C_1C ) )
r4939r4940
424481   PORT_DIPSETTING(    0x03, DEF_STR( 1C_4C ) )
425482   PORT_DIPSETTING(    0x04, DEF_STR( 1C_5C ) )
426483   PORT_DIPSETTING(    0x05, DEF_STR( 1C_6C ) )
427   PORT_DIPNAME( 0xf0, 0x00, DEF_STR( Coin_B ) )
484   PORT_DIPNAME( 0xf0, 0x00, DEF_STR( Coin_B ) )   PORT_DIPLOCATION("SW1:5,6,7,8")
428485   PORT_DIPSETTING(    0x90, DEF_STR( 5C_1C ) )
429486   PORT_DIPSETTING(    0x80, DEF_STR( 4C_1C ) )
430487   PORT_DIPSETTING(    0x70, DEF_STR( 3C_1C ) )
r4939r4940
443500   PORT_DIPSETTING(    0x50, DEF_STR( 1C_6C ) )
444501
445502   PORT_START("DSW2")   /* $23 */
446   PORT_DIPNAME( 0x03, 0x00, "Hat Fall Velocity" )
503   PORT_DIPNAME( 0x03, 0x00, "Hat Fall Velocity" )   PORT_DIPLOCATION("SW2:1,2")
447504   PORT_DIPSETTING(    0x01, DEF_STR( Easy ) )
448505   PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )
449506   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
450507   PORT_DIPSETTING(    0x03, "Super" )
451   PORT_DIPNAME( 0x0c, 0x00, "End Line Position" )
508   PORT_DIPNAME( 0x0c, 0x00, "End Line Position" )   PORT_DIPLOCATION("SW2:3,4")
452509   PORT_DIPSETTING(    0x04, DEF_STR( Easy ) )
453510   PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )
454511   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )
455512   PORT_DIPSETTING(    0x0c, "Super" )
456   PORT_SERVICE( 0x10, IP_ACTIVE_HIGH )
457   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Flip_Screen ) )
513   PORT_SERVICE_DIPLOC(  0x0010, IP_ACTIVE_HIGH, "SW2:5" )
514   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Flip_Screen ) )   PORT_DIPLOCATION("SW2:6")
458515   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
459516   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
460   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Demo_Sounds ) )
517   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW2:7")
461518   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
462519   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
463   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
520   PORT_DIPUNUSED_DIPLOC( 0x0080, 0x0080, "SW2:8" ) /* Listed as "N.C." */
464521INPUT_PORTS_END
465522
466523
r4939r4940
633690
634691ROM_START( pipedrm )
635692   ROM_REGION( 0x20000, "maincpu", 0 )
636   ROM_LOAD( "y1.u129",   0x00000, 0x08000, CRC(9b4d84a2) SHA1(82c26cf52b37ca3bcc10a534759e7bb52b1daa2d) )
637   ROM_LOAD( "yb.u110",   0x10000, 0x10000, CRC(7416554a) SHA1(612aff94da3ec282e200c07eae9af26a28e071bd) )
693   ROM_LOAD( "ya.u129", 0x00000, 0x08000, CRC(9b4d84a2) SHA1(82c26cf52b37ca3bcc10a534759e7bb52b1daa2d) )
694   ROM_LOAD( "yb.u110", 0x10000, 0x10000, CRC(7416554a) SHA1(612aff94da3ec282e200c07eae9af26a28e071bd) )
638695
639696   ROM_REGION( 0x20000, "sub", 0 )
640   ROM_LOAD( "4",   0x00000, 0x08000, CRC(497fad4c) SHA1(f151543a0c4a1d6d5d2de5e1dc12fd59dabcf1a8) )
641   ROM_LOAD( "3",   0x10000, 0x10000, CRC(4800322a) SHA1(a616c497ac18351b68b8307050a2a62c717a7873) )
697   ROM_LOAD( "u4,u86", 0x00000, 0x08000, CRC(497fad4c) SHA1(f151543a0c4a1d6d5d2de5e1dc12fd59dabcf1a8) )
698   ROM_LOAD( "u3.u99", 0x10000, 0x10000, CRC(4800322a) SHA1(a616c497ac18351b68b8307050a2a62c717a7873) )
642699
643700   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
644   ROM_LOAD( "s73",    0x000000, 0x80000, CRC(63f4e10c) SHA1(ba935490578887080d8b16508fa6191236a8fea6) )
645   ROM_LOAD( "s72",    0x080000, 0x80000, CRC(4e669e97) SHA1(1de8a8cd8f8f69fa86b8fe2c73c6997e7a89c706) )
701   ROM_LOAD( "s73", 0x000000, 0x80000, CRC(63f4e10c) SHA1(ba935490578887080d8b16508fa6191236a8fea6) )
702   ROM_LOAD( "s72", 0x080000, 0x80000, CRC(4e669e97) SHA1(1de8a8cd8f8f69fa86b8fe2c73c6997e7a89c706) )
646703
647704   ROM_REGION( 0x100000, "gfx2", ROMREGION_DISPOSE )
648   ROM_LOAD( "s71",    0x000000, 0x80000, CRC(431485ee) SHA1(70a2ba5338598db9fcd9ef2be46e5cc2fd9510ee) )
705   ROM_LOAD( "s71",  0x000000, 0x80000, CRC(431485ee) SHA1(70a2ba5338598db9fcd9ef2be46e5cc2fd9510ee) )
649706   ROM_COPY( "gfx1", 0x080000, 0x080000, 0x80000 )
650707
651708   ROM_REGION( 0x080000, "gfx3", ROMREGION_DISPOSE )
652   ROM_LOAD16_BYTE( "a30", 0x00000, 0x40000, CRC(50bc5e98) SHA1(b351af780d04e67a560935a9eeaedf597ac5bb1f) )
653   ROM_LOAD16_BYTE( "a29", 0x00001, 0x40000, CRC(a240a448) SHA1(d64169258e91eb09e8685bcdd96b16bf56e82ef1) )
709   ROM_LOAD16_BYTE( "a30.u12", 0x00000, 0x40000, CRC(50bc5e98) SHA1(b351af780d04e67a560935a9eeaedf597ac5bb1f) )
710   ROM_LOAD16_BYTE( "a29.u2",  0x00001, 0x40000, CRC(a240a448) SHA1(d64169258e91eb09e8685bcdd96b16bf56e82ef1) )
654711
655712   ROM_REGION( 0x80000, "ym", 0 )
656   ROM_LOAD( "g71",    0x00000, 0x80000, CRC(488e2fd1) SHA1(8ef8ceb2bd36a245138802f51babf62f17c30942) )
713   ROM_LOAD( "g71.u118", 0x00000, 0x80000, CRC(488e2fd1) SHA1(8ef8ceb2bd36a245138802f51babf62f17c30942) )
657714
658715   ROM_REGION( 0x80000, "ym.deltat", 0 )
659   ROM_LOAD( "g72",    0x00000, 0x80000, CRC(dc3d14be) SHA1(4220f3fd13487dd861ac84b1b0d3e92125b3cc19) )
716   ROM_LOAD( "g72.u83", 0x00000, 0x80000, CRC(dc3d14be) SHA1(4220f3fd13487dd861ac84b1b0d3e92125b3cc19) )
660717
661718   ROM_REGION( 0x0800, "plds", ROMREGION_DISPOSE )
662   ROM_LOAD( "palce16v8h.114", 0x0000, 0x0117, CRC(1f3a3816) SHA1(2b4d84ab98036b8861961f610b1b1ec23a653ef7) )
663   ROM_LOAD( "gal16v8a.115",   0x0200, 0x0117, CRC(2b32e239) SHA1(a3b9e45a1ce15ea4cc5754b2bf89cbaa416e814a) )
664   ROM_LOAD( "gal16v8a.116",   0x0400, 0x0117, CRC(3674f043) SHA1(06c88f65877a6575149bdd4f7cea64cd310227bd) )
665   ROM_LOAD( "gal16v8a.127",   0x0600, 0x0117, CRC(7115d95c) SHA1(23044039373b5a2face63d72c3fc6bf7f0c8a475) )
719   ROM_LOAD( "palce16v8h.114", 0x0000, 0x0117, CRC(1f3a3816) SHA1(2b4d84ab98036b8861961f610b1b1ec23a653ef7) ) /* Stamped 1023 */
720   ROM_LOAD( "gal16v8a.115",   0x0200, 0x0117, CRC(2b32e239) SHA1(a3b9e45a1ce15ea4cc5754b2bf89cbaa416e814a) ) /* Stamped 1015 */
721   ROM_LOAD( "gal16v8a.116",   0x0400, 0x0117, CRC(3674f043) SHA1(06c88f65877a6575149bdd4f7cea64cd310227bd) ) /* Stamped 1014 */
722   ROM_LOAD( "gal16v8a.127",   0x0600, 0x0117, CRC(7115d95c) SHA1(23044039373b5a2face63d72c3fc6bf7f0c8a475) ) /* Stamped 1016 */
666723ROM_END
667724
668725ROM_START( pipedrmu )
669726   ROM_REGION( 0x20000, "maincpu", 0 )
670   ROM_LOAD( "01.u12",   0x00000, 0x08000, CRC(9fe261fb) SHA1(57beeeade8809be0a71086f55b14b1676c0b3759) )
671   ROM_LOAD( "02.u11",   0x10000, 0x10000, CRC(c8209b67) SHA1(cca7356d75e8091b07e3328aef523ff452abbcd8) )
727   ROM_LOAD( "01.u129", 0x00000, 0x08000, CRC(9fe261fb) SHA1(57beeeade8809be0a71086f55b14b1676c0b3759) )
728   ROM_LOAD( "02.u110", 0x10000, 0x10000, CRC(c8209b67) SHA1(cca7356d75e8091b07e3328aef523ff452abbcd8) )
672729
673730   ROM_REGION( 0x20000, "sub", 0 )
674   ROM_LOAD( "4",   0x00000, 0x08000, CRC(497fad4c) SHA1(f151543a0c4a1d6d5d2de5e1dc12fd59dabcf1a8) )
675   ROM_LOAD( "3",   0x10000, 0x10000, CRC(4800322a) SHA1(a616c497ac18351b68b8307050a2a62c717a7873) )
731   ROM_LOAD( "u4,u86", 0x00000, 0x08000, CRC(497fad4c) SHA1(f151543a0c4a1d6d5d2de5e1dc12fd59dabcf1a8) )
732   ROM_LOAD( "u3.u99", 0x10000, 0x10000, CRC(4800322a) SHA1(a616c497ac18351b68b8307050a2a62c717a7873) )
676733
677734   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
678   ROM_LOAD( "s73",    0x000000, 0x80000, CRC(63f4e10c) SHA1(ba935490578887080d8b16508fa6191236a8fea6) )
679   ROM_LOAD( "s72",    0x080000, 0x80000, CRC(4e669e97) SHA1(1de8a8cd8f8f69fa86b8fe2c73c6997e7a89c706) )
735   ROM_LOAD( "s73", 0x000000, 0x80000, CRC(63f4e10c) SHA1(ba935490578887080d8b16508fa6191236a8fea6) )
736   ROM_LOAD( "s72", 0x080000, 0x80000, CRC(4e669e97) SHA1(1de8a8cd8f8f69fa86b8fe2c73c6997e7a89c706) )
680737
681738   ROM_REGION( 0x100000, "gfx2", ROMREGION_DISPOSE )
682   ROM_LOAD( "s71",    0x000000, 0x80000, CRC(431485ee) SHA1(70a2ba5338598db9fcd9ef2be46e5cc2fd9510ee) )
739   ROM_LOAD( "s71",  0x000000, 0x80000, CRC(431485ee) SHA1(70a2ba5338598db9fcd9ef2be46e5cc2fd9510ee) )
683740   ROM_COPY( "gfx1", 0x080000, 0x080000, 0x80000 )
684741
685742   ROM_REGION( 0x080000, "gfx3", ROMREGION_DISPOSE )
686   ROM_LOAD16_BYTE( "a30", 0x00000, 0x40000, CRC(50bc5e98) SHA1(b351af780d04e67a560935a9eeaedf597ac5bb1f) )
687   ROM_LOAD16_BYTE( "a29", 0x00001, 0x40000, CRC(a240a448) SHA1(d64169258e91eb09e8685bcdd96b16bf56e82ef1) )
743   ROM_LOAD16_BYTE( "a30.u12", 0x00000, 0x40000, CRC(50bc5e98) SHA1(b351af780d04e67a560935a9eeaedf597ac5bb1f) )
744   ROM_LOAD16_BYTE( "a29.u2",  0x00001, 0x40000, CRC(a240a448) SHA1(d64169258e91eb09e8685bcdd96b16bf56e82ef1) )
688745
689746   ROM_REGION( 0x80000, "ym", 0 )
690   ROM_LOAD( "g71",    0x00000, 0x80000, CRC(488e2fd1) SHA1(8ef8ceb2bd36a245138802f51babf62f17c30942) )
747   ROM_LOAD( "g71.u118", 0x00000, 0x80000, CRC(488e2fd1) SHA1(8ef8ceb2bd36a245138802f51babf62f17c30942) )
691748
692749   ROM_REGION( 0x80000, "ym.deltat", 0 )
693   ROM_LOAD( "g72",    0x00000, 0x80000, CRC(dc3d14be) SHA1(4220f3fd13487dd861ac84b1b0d3e92125b3cc19) )
750   ROM_LOAD( "g72.u83", 0x00000, 0x80000, CRC(dc3d14be) SHA1(4220f3fd13487dd861ac84b1b0d3e92125b3cc19) )
694751
695752   ROM_REGION( 0x0800, "plds", ROMREGION_DISPOSE )
696   ROM_LOAD( "palce16v8h.114", 0x0000, 0x0117, CRC(1f3a3816) SHA1(2b4d84ab98036b8861961f610b1b1ec23a653ef7) )
697   ROM_LOAD( "gal16v8a.115",   0x0200, 0x0117, CRC(2b32e239) SHA1(a3b9e45a1ce15ea4cc5754b2bf89cbaa416e814a) )
698   ROM_LOAD( "gal16v8a.116",   0x0400, 0x0117, CRC(3674f043) SHA1(06c88f65877a6575149bdd4f7cea64cd310227bd) )
699   ROM_LOAD( "gal16v8a.127",   0x0600, 0x0117, CRC(7115d95c) SHA1(23044039373b5a2face63d72c3fc6bf7f0c8a475) )
753   ROM_LOAD( "palce16v8h.114", 0x0000, 0x0117, CRC(1f3a3816) SHA1(2b4d84ab98036b8861961f610b1b1ec23a653ef7) ) /* Stamped 1023 */
754   ROM_LOAD( "gal16v8a.115",   0x0200, 0x0117, CRC(2b32e239) SHA1(a3b9e45a1ce15ea4cc5754b2bf89cbaa416e814a) ) /* Stamped 1015 */
755   ROM_LOAD( "gal16v8a.116",   0x0400, 0x0117, CRC(3674f043) SHA1(06c88f65877a6575149bdd4f7cea64cd310227bd) ) /* Stamped 1014 */
756   ROM_LOAD( "gal16v8a.127",   0x0600, 0x0117, CRC(7115d95c) SHA1(23044039373b5a2face63d72c3fc6bf7f0c8a475) ) /* Stamped 1016 */
700757ROM_END
701758
702759
703760ROM_START( pipedrmj )
704761   ROM_REGION( 0x20000, "maincpu", 0 )
705   ROM_LOAD( "1",   0x00000, 0x08000, CRC(dbfac46b) SHA1(98ddfaed61de28b238964445572eb398b9dd03c7) )
706   ROM_LOAD( "2",   0x10000, 0x10000, CRC(b7adb99a) SHA1(fdab2b99e86aa0b6b17ec95556222e5211ba55e9) )
762   ROM_LOAD( "1.u129", 0x00000, 0x08000, CRC(dbfac46b) SHA1(98ddfaed61de28b238964445572eb398b9dd03c7) )
763   ROM_LOAD( "2.u110", 0x10000, 0x10000, CRC(b7adb99a) SHA1(fdab2b99e86aa0b6b17ec95556222e5211ba55e9) )
707764
708765   ROM_REGION( 0x20000, "sub", 0 )
709   ROM_LOAD( "4",   0x00000, 0x08000, CRC(497fad4c) SHA1(f151543a0c4a1d6d5d2de5e1dc12fd59dabcf1a8) )
710   ROM_LOAD( "3",   0x10000, 0x10000, CRC(4800322a) SHA1(a616c497ac18351b68b8307050a2a62c717a7873) )
766   ROM_LOAD( "u4,u86", 0x00000, 0x08000, CRC(497fad4c) SHA1(f151543a0c4a1d6d5d2de5e1dc12fd59dabcf1a8) )
767   ROM_LOAD( "u3.u99", 0x10000, 0x10000, CRC(4800322a) SHA1(a616c497ac18351b68b8307050a2a62c717a7873) )
711768
712769   ROM_REGION( 0x100000, "gfx1", ROMREGION_DISPOSE )
713   ROM_LOAD( "s73",    0x000000, 0x80000, CRC(63f4e10c) SHA1(ba935490578887080d8b16508fa6191236a8fea6) )
714   ROM_LOAD( "s72",    0x080000, 0x80000, CRC(4e669e97) SHA1(1de8a8cd8f8f69fa86b8fe2c73c6997e7a89c706) )
770   ROM_LOAD( "s73", 0x000000, 0x80000, CRC(63f4e10c) SHA1(ba935490578887080d8b16508fa6191236a8fea6) )
771   ROM_LOAD( "s72", 0x080000, 0x80000, CRC(4e669e97) SHA1(1de8a8cd8f8f69fa86b8fe2c73c6997e7a89c706) )
715772
716773   ROM_REGION( 0x100000, "gfx2", ROMREGION_DISPOSE )
717   ROM_LOAD( "s71",    0x000000, 0x80000, CRC(431485ee) SHA1(70a2ba5338598db9fcd9ef2be46e5cc2fd9510ee) )
774   ROM_LOAD( "s71",  0x000000, 0x80000, CRC(431485ee) SHA1(70a2ba5338598db9fcd9ef2be46e5cc2fd9510ee) )
718775   ROM_COPY( "gfx1", 0x080000, 0x080000, 0x80000 )
719776
720777   ROM_REGION( 0x080000, "gfx3", ROMREGION_DISPOSE )
721   ROM_LOAD16_BYTE( "a30", 0x00000, 0x40000, CRC(50bc5e98) SHA1(b351af780d04e67a560935a9eeaedf597ac5bb1f) )
722   ROM_LOAD16_BYTE( "a29", 0x00001, 0x40000, CRC(a240a448) SHA1(d64169258e91eb09e8685bcdd96b16bf56e82ef1) )
778   ROM_LOAD16_BYTE( "a30.u12", 0x00000, 0x40000, CRC(50bc5e98) SHA1(b351af780d04e67a560935a9eeaedf597ac5bb1f) )
779   ROM_LOAD16_BYTE( "a29.u2",  0x00001, 0x40000, CRC(a240a448) SHA1(d64169258e91eb09e8685bcdd96b16bf56e82ef1) )
723780
724781   ROM_REGION( 0x80000, "ym", 0 )
725   ROM_LOAD( "g71",    0x00000, 0x80000, CRC(488e2fd1) SHA1(8ef8ceb2bd36a245138802f51babf62f17c30942) )
782   ROM_LOAD( "g71.u118", 0x00000, 0x80000, CRC(488e2fd1) SHA1(8ef8ceb2bd36a245138802f51babf62f17c30942) )
726783
727784   ROM_REGION( 0x80000, "ym.deltat", 0 )
728   ROM_LOAD( "g72",    0x00000, 0x80000, CRC(dc3d14be) SHA1(4220f3fd13487dd861ac84b1b0d3e92125b3cc19) )
785   ROM_LOAD( "g72.u83", 0x00000, 0x80000, CRC(dc3d14be) SHA1(4220f3fd13487dd861ac84b1b0d3e92125b3cc19) )
729786
730787   ROM_REGION( 0x0800, "plds", ROMREGION_DISPOSE )
731   ROM_LOAD( "palce16v8h.114", 0x0000, 0x0117, CRC(1f3a3816) SHA1(2b4d84ab98036b8861961f610b1b1ec23a653ef7) )
732   ROM_LOAD( "gal16v8a.115",   0x0200, 0x0117, CRC(2b32e239) SHA1(a3b9e45a1ce15ea4cc5754b2bf89cbaa416e814a) )
733   ROM_LOAD( "gal16v8a.116",   0x0400, 0x0117, CRC(3674f043) SHA1(06c88f65877a6575149bdd4f7cea64cd310227bd) )
734   ROM_LOAD( "gal16v8a.127",   0x0600, 0x0117, CRC(7115d95c) SHA1(23044039373b5a2face63d72c3fc6bf7f0c8a475) )
788   ROM_LOAD( "palce16v8h.114", 0x0000, 0x0117, CRC(1f3a3816) SHA1(2b4d84ab98036b8861961f610b1b1ec23a653ef7) ) /* Stamped 1023 */
789   ROM_LOAD( "gal16v8a.115",   0x0200, 0x0117, CRC(2b32e239) SHA1(a3b9e45a1ce15ea4cc5754b2bf89cbaa416e814a) ) /* Stamped 1015 */
790   ROM_LOAD( "gal16v8a.116",   0x0400, 0x0117, CRC(3674f043) SHA1(06c88f65877a6575149bdd4f7cea64cd310227bd) ) /* Stamped 1014 */
791   ROM_LOAD( "gal16v8a.127",   0x0600, 0x0117, CRC(7115d95c) SHA1(23044039373b5a2face63d72c3fc6bf7f0c8a475) ) /* Stamped 1016 */
735792ROM_END
736793
737794
src/mame/drivers/ddragon3.c
r4939r4940
275275static ADDRESS_MAP_START( ctribe_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
276276   AM_RANGE(0x0000, 0x7fff) AM_ROM
277277   AM_RANGE(0x8000, 0x87ff) AM_RAM
278   AM_RANGE(0x8801, 0x8801) AM_DEVREADWRITE("ym2151", ym2151_status_port_r, ym2151_w)
278   AM_RANGE(0x8800, 0x8801) AM_DEVREADWRITE("ym2151", ym2151_status_port_r, ym2151_w)
279279   AM_RANGE(0x9800, 0x9800) AM_DEVREADWRITE("oki", okim6295_r, okim6295_w)
280280   AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r)
281281ADDRESS_MAP_END
src/mame/drivers/86lions.c
r4939r4940
1717    - Understand inputs / via mapping properly;
1818    - Finish the mc6845 conversion;
1919
20Changes 02/06/2009 - Palindrome
21- Fixed VIA address map to 5000 - 0x501f ( now generates required FIRQ_LINE timer interrupt,
22  call attendant msg no longer displayed)
23
24
2025*******************************************************************************************/
2126
2227#define MAIN_CLOCK   XTAL_12MHz   /* guess */
r4939r4940
8691   AM_RANGE(0x0800, 0x0fff) AM_RAM
8792   AM_RANGE(0x1800, 0x1800) AM_DEVWRITE("crtc", mc6845_address_w)
8893   AM_RANGE(0x1801, 0x1801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
89   AM_RANGE(0x5000, 0x500f) AM_READWRITE(lions_via_r, lions_via_w)
94   AM_RANGE(0x5000, 0x500f) AM_MIRROR(0x0010) AM_READWRITE(lions_via_r, lions_via_w)
9095   AM_RANGE(0x5300, 0x5300) AM_READ(test_r)//AM_READ_PORT("IN0")
9196   AM_RANGE(0x5382, 0x5383) AM_DEVWRITE("ay", ay8910_data_address_w)
9297   AM_RANGE(0xe000, 0xffff) AM_ROM
src/mame/drivers/midtunit.c
r4939r4940
12921292GAME( 1993, nbajam,   0,       tunit_adpcm, nbajam,   nbajam,   ROT0, "Midway",   "NBA Jam (rev 3.01 04/07/93)", GAME_SUPPORTS_SAVE )
12931293GAME( 1993, nbajamr2, nbajam,  tunit_adpcm, nbajam,   nbajam,   ROT0, "Midway",   "NBA Jam (rev 2.00 02/10/93)", GAME_SUPPORTS_SAVE )
12941294
1295GAME( 1994, nbajamte, 0,  tunit_adpcm, nbajamte, nbajamte, ROT0, "Midway",   "NBA Jam TE (rev 4.0 03/23/94)", GAME_SUPPORTS_SAVE )
1295GAME( 1994, nbajamte, 0,         tunit_adpcm, nbajamte, nbajamte, ROT0, "Midway",   "NBA Jam TE (rev 4.0 03/23/94)", GAME_SUPPORTS_SAVE )
12961296GAME( 1994, nbajamt1, nbajamte,  tunit_adpcm, nbajamte, nbajamte, ROT0, "Midway",   "NBA Jam TE (rev 1.0 01/17/94)", GAME_SUPPORTS_SAVE )
12971297GAME( 1994, nbajamt2, nbajamte,  tunit_adpcm, nbajamte, nbajamte, ROT0, "Midway",   "NBA Jam TE (rev 2.0 01/28/94)", GAME_SUPPORTS_SAVE )
12981298GAME( 1994, nbajamt3, nbajamte,  tunit_adpcm, nbajamte, nbajamte, ROT0, "Midway",   "NBA Jam TE (rev 3.0 03/04/94)", GAME_SUPPORTS_SAVE )
src/mame/drivers/seta2.c
r4939r4940
412412
413413U38 - U40 Mask roms (Graphics 23c64020 64Mbit) - 23C64020 read as 27C322 with pin11 +5v & 27C322 with pin11 GND
414414
415--------------------------------------------------------------------------
416
417From the WSC upgrade instruction sheet:
418
419 Wing Shooting Championship
420      Game Echancement
421          1/23/02
422
423New Program chip Ver. 2.00 For Wing Shooting Championship
424We are announcing NEW GAME FEATURES to enhance game play. Please refer below.
425
426NEW FEATURES
427------------
428
429 * Easier play for the first 3 hunting spots in every state with the addition of more birds.
430 * The "BEGINNER" weapon has been changed to the 5-shot PUMP SHOTGUN plus the "hit area"
431    for each shot has been increased. Same as the 3-shot SEMI-AUTO SHOTGUN.
432 * Player can now advance through all result screens faster by pulling gun trigger.
433 * The Auto Select bird is now GOOSE (easiest target) if player fails to choose bird at start of game.
434
415435***************************************************************************/
416436
417437/***************************************************************************
r4939r4940
27252745
27262746ROM_START( wschamp ) /* Wing Shootiong Championship V2.00 (01/23/2002) */
27272747   ROM_REGION( 0x200000, "maincpu", 0 )      /* TMP68301 Code */
2728   ROM_LOAD16_BYTE( "as1006e02.u06", 0x000000, 0x100000, CRC(0ad01677) SHA1(63e09b9f7cc8b781af1756f86caa0cc0962ae584) ) /* checksum 421E printed on label */
2729   ROM_LOAD16_BYTE( "as1007e02.u07", 0x000001, 0x100000, CRC(572624f0) SHA1(0c2f67daa22f4edd66a2be990dc6cd999faff0fa) ) /* checksum A48F printed on label */
2748   ROM_LOAD16_BYTE( "as1006e03.u06", 0x000000, 0x100000, CRC(0ad01677) SHA1(63e09b9f7cc8b781af1756f86caa0cc0962ae584) ) /* checksum 421E printed on label */
2749   ROM_LOAD16_BYTE( "as1007e03.u07", 0x000001, 0x100000, CRC(572624f0) SHA1(0c2f67daa22f4edd66a2be990dc6cd999faff0fa) ) /* checksum A48F printed on label */
27302750
27312751   ROM_REGION( 0x2000000, "gfx1", ROMREGION_DISPOSE )   /* Sprites */
27322752   ROM_LOAD( "as1001m01.u38", 0x0000000, 0x800000, CRC(92595579) SHA1(75a7131aedb18b7103677340c3cca7c91aaca2bf) )
r4939r4940
27412761
27422762ROM_START( wschampa ) /* Wing Shootiong Championship V1.01 */
27432763   ROM_REGION( 0x200000, "maincpu", 0 )      /* TMP68301 Code */
2744   ROM_LOAD16_BYTE( "as1006e01.u06", 0x000000, 0x100000, CRC(d3d3b2b5) SHA1(2d036d795b40a4ed78bb9f7751f875cfc76276a9) )
2745   ROM_LOAD16_BYTE( "as1007e01.u07", 0x000001, 0x100000, CRC(78ede6d9) SHA1(e6d10f52cd4c6bf97288df44911f23bb64fc012c) )
2764   ROM_LOAD16_BYTE( "as1006e02.u06", 0x000000, 0x100000, CRC(d3d3b2b5) SHA1(2d036d795b40a4ed78bb9f7751f875cfc76276a9) ) /* checksum 31EF printed on label */
2765   ROM_LOAD16_BYTE( "as1007e02.u07", 0x000001, 0x100000, CRC(78ede6d9) SHA1(e6d10f52cd4c6bf97288df44911f23bb64fc012c) ) /* checksum 615E printed on label */
27462766
27472767   ROM_REGION( 0x2000000, "gfx1", ROMREGION_DISPOSE )   /* Sprites */
27482768   ROM_LOAD( "as1001m01.u38", 0x0000000, 0x800000, CRC(92595579) SHA1(75a7131aedb18b7103677340c3cca7c91aaca2bf) )
r4939r4940
28582878GAME( 2000, deerhunb, deerhunt, samshoot, deerhunt, 0,        ROT0, "Sammy USA Corporation", "Deer Hunting USA V4.0",                        GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS )
28592879GAME( 2000, deerhunc, deerhunt, samshoot, deerhunt, 0,        ROT0, "Sammy USA Corporation", "Deer Hunting USA V2",                          GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS )
28602880GAME( 2001, turkhunt, 0,        samshoot, turkhunt, 0,        ROT0, "Sammy USA Corporation", "Turkey Hunting USA V1.0",                      GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS )
2861GAME( 2001, wschamp,  0,        samshoot, wschamp,  0,        ROT0, "Sammy USA Corporation", "Wing Shooting Championship V2.0",              GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS )
2881GAME( 2001, wschamp,  0,        samshoot, wschamp,  0,        ROT0, "Sammy USA Corporation", "Wing Shooting Championship V2.00",             GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS )
28622882GAME( 2001, wschampa, wschamp,  samshoot, wschamp,  0,        ROT0, "Sammy USA Corporation", "Wing Shooting Championship V1.01",             GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS )
28632883GAME( 2002, trophyh,  0,        samshoot, trophyh,  0,        ROT0, "Sammy USA Corporation", "Trophy Hunting - Bear & Moose V1.0",           GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS )
28642884GAME( 2001, funcube2, 0,        funcube,  funcube,  funcube2, ROT0, "Namco",                 "Funcube 2 (v1.1)",                             GAME_NO_SOUND )
src/mame/drivers/zn.c
r4939r4940
11331133
11341134static WRITE32_HANDLER( bank_coh1000t_w )
11351135{
1136   mb3773_set_ck( ( data & 0x20 ) >> 5 );
1136   const device_config *mb3773 = devtag_get_device(space->machine, "mb3773");
1137   mb3773_set_ck(mb3773, 0, (data & 0x20) >> 5);
11371138   verboselog( space->machine, 1, "bank_coh1000t_w( %08x, %08x, %08x )\n", offset, data, mem_mask );
11381139   memory_set_bankptr(space->machine,  1, memory_region( space->machine, "user2" ) + ( ( data & 3 ) * 0x800000 ) );
11391140}
r4939r4940
11701171   memory_install_readwrite32_handler( cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x1fbe0000, 0x1fbe0000 + ( taitofx1_eeprom_size1 - 1 ), 0, 0, (read32_space_func)SMH_BANK(2), (write32_space_func)SMH_BANK(2) );
11711172
11721173   zn_driver_init(machine);
1173   mb3773_init(machine);
11741174}
11751175
11761176static MACHINE_RESET( coh1000ta )
r4939r4940
12341234   MDRV_SOUND_ROUTE(0, "rspeaker", 0.25)
12351235   MDRV_SOUND_ROUTE(1, "lspeaker",  1.0)
12361236   MDRV_SOUND_ROUTE(2, "rspeaker", 1.0)
1237
1238   MDRV_MB3773_ADD("mb3773")
12371239MACHINE_DRIVER_END
12381240
12391241static WRITE32_HANDLER( taitofx1b_volume_w )
r4939r4940
12671269   memory_install_readwrite32_handler( cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x1fbe0000, 0x1fbe0000 + ( taitofx1_eeprom_size2 - 1 ), 0, 0, (read32_space_func)SMH_BANK(3), (write32_space_func)SMH_BANK(3) );
12681270
12691271   zn_driver_init(machine);
1270   mb3773_init(machine);
12711272}
12721273
12731274static MACHINE_RESET( coh1000tb )
r4939r4940
13021303
13031304   MDRV_MACHINE_RESET( coh1000tb )
13041305   MDRV_NVRAM_HANDLER( coh1000tb )
1306
1307   MDRV_MB3773_ADD("mb3773")
13051308MACHINE_DRIVER_END
13061309
13071310/*
src/mame/drivers/megadriv.c
r4939r4940
8484
8585#define SEGACD_CLOCK      12500000
8686
87#define HAZE_MD 0 // to make appear / disappear the Region DipSwitch
88
8789/* timing details */
8890static int megadriv_framerate;
8991static int megadrive_total_scanlines;
r4939r4940
14431445UINT8 (*megadrive_io_read_data_port_ptr)(running_machine *machine, int offset);
14441446void (*megadrive_io_write_data_port_ptr)(running_machine *machine, int offset, UINT16 data);
14451447
1446INPUT_PORTS_START( megadri6 )
1447   PORT_START("PAD1")      /* Joypad 1 (6 button + start + mode) NOT READ DIRECTLY */
1448/*
1449
1450    A10001h = A0         Version register
1451
1452    A10003h = 7F         Data register for port A
1453    A10005h = 7F         Data register for port B
1454    A10007h = 7F         Data register for port C
1455
1456    A10009h = 00         Ctrl register for port A
1457    A1000Bh = 00         Ctrl register for port B
1458    A1000Dh = 00         Ctrl register for port C
1459
1460    A1000Fh = FF         TxData register for port A
1461    A10011h = 00         RxData register for port A
1462    A10013h = 00         S-Ctrl register for port A
1463
1464    A10015h = FF         TxData register for port B
1465    A10017h = 00         RxData register for port B
1466    A10019h = 00         S-Ctrl register for port B
1467
1468    A1001Bh = FF         TxData register for port C
1469    A1001Dh = 00         RxData register for port C
1470    A1001Fh = 00         S-Ctrl register for port C
1471
1472
1473
1474
1475 Bit 7 - (Not connected)
1476 Bit 6 - TH
1477 Bit 5 - TL
1478 Bit 4 - TR
1479 Bit 3 - RIGHT
1480 Bit 2 - LEFT
1481 Bit 1 - DOWN
1482 Bit 0 - UP
1483
1484
1485*/
1486
1487INPUT_PORTS_START( md_common )
1488   PORT_START("PAD1")      /* Joypad 1 (3 button + start) NOT READ DIRECTLY */
14481489   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
14491490   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
14501491   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
14511492   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
1452   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 A") // a
1453   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 B") // b
1454   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_NAME("P1 C") // c
1493   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 B") // b
1494   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_NAME("P1 C") // c
1495   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 A") // a
14551496   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_NAME("P1 START") // start
1456   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1) PORT_NAME("P1 X") // x
1457   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(1) PORT_NAME("P1 Y") // y
1458   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_PLAYER(1) PORT_NAME("P1 Z") // z
1459   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_PLAYER(1) PORT_NAME("P1 MODE") // mode
14601497
1461
1462   PORT_START("PAD2")      /* Joypad 2 (6 button + start + mode) NOT READ DIRECTLY */
1498   PORT_START("PAD2")      /* Joypad 2 (3 button + start) NOT READ DIRECTLY */
14631499   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
14641500   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
14651501   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
14661502   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
1467   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 A") // a
1468   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 B") // b
1469   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 C") // c
1503   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 B") // b
1504   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 C") // c
1505   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 A") // a
14701506   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_NAME("P2 START") // start
1471   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2) PORT_NAME("P2 X") // x
1472   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(2) PORT_NAME("P2 Y") // y
1473   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_PLAYER(2) PORT_NAME("P2 Z") // z
1474   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_PLAYER(2) PORT_NAME("P2 MODE") // mode
1507INPUT_PORTS_END
14751508
1476   PORT_START("IN0")      /* 3rd I/O port */
14771509
1510INPUT_PORTS_START( megadriv )
1511   PORT_INCLUDE( md_common )
1512
14781513   PORT_START("RESET")      /* Buttons on Genesis Console */
14791514   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("Reset Button") PORT_IMPULSE(1) // reset, resets 68k (and..?)
14801515
1481   PORT_START("REGION")   /* Buttons on Genesis Console */
1516   #if HAZE_MD
1517   PORT_START("REGION")   /* Region setting for Console */
14821518   /* Region setting for Console */
14831519   PORT_DIPNAME( 0x000f, 0x0000, DEF_STR( Region ) )
14841520   PORT_DIPSETTING(      0x0000, "Use HazeMD Default Choice" )
14851521   PORT_DIPSETTING(      0x0001, "US (NTSC, 60fps)" )
14861522   PORT_DIPSETTING(      0x0002, "JAPAN (NTSC, 60fps)" )
14871523   PORT_DIPSETTING(      0x0003, "EUROPE (PAL, 50fps)" )
1524   #endif
14881525INPUT_PORTS_END
14891526
1527INPUT_PORTS_START( megadri6 )
1528   PORT_INCLUDE( megadriv )
14901529
1530   PORT_START("EXTRA1")   /* Extra buttons for Joypad 1 (6 button + start + mode) NOT READ DIRECTLY */
1531   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_PLAYER(1) PORT_NAME("P1 Z") // z
1532   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(1) PORT_NAME("P1 Y") // y
1533   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1) PORT_NAME("P1 X") // x
1534   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_PLAYER(1) PORT_NAME("P1 MODE") // mode
14911535
1536   PORT_START("EXTRA2")   /* Extra buttons for Joypad 2 (6 button + start + mode) NOT READ DIRECTLY */
1537   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_PLAYER(2) PORT_NAME("P2 Z") // z
1538   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(2) PORT_NAME("P2 Y") // y
1539   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2) PORT_NAME("P2 X") // x
1540   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_PLAYER(2) PORT_NAME("P2 MODE") // mode
1541INPUT_PORTS_END
14921542
14931543INPUT_PORTS_START( ssf2ghw )
1494   PORT_START("PAD1")      /* Joypad 1 (6 button + start + mode) NOT READ DIRECTLY */
1495   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
1496   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
1497   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
1498   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
1499   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
1500   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
1501   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
1544   PORT_INCLUDE( md_common )
1545
1546   PORT_MODIFY("PAD1")
1547   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
1548   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
1549   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
15021550   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
1503   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
1504   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1)
1505   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(1)
1506   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNUSED )
15071551
1552   PORT_MODIFY("PAD2")
1553   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
1554   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
1555   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1556   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
15081557
1509   PORT_START("PAD2")      /* Joypad 1 (6 button + start + mode) NOT READ DIRECTLY */
1510   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
1511   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
1512   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
1513   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
1514   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1515   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
1516   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
1517   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START2 )
1518   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
1519   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2)
1520   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(2)
1521   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_UNUSED )
1558   PORT_START("EXTRA1")   /* Extra buttons for Joypad 1 (6 button + start + mode) NOT READ DIRECTLY */
1559   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(1)
1560   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1)
1561   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
1562   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED )
15221563
1564   PORT_START("EXTRA2")   /* Extra buttons for Joypad 2 (6 button + start + mode) NOT READ DIRECTLY */
1565   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(2)
1566   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2)
1567   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
1568   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED )
1569
15231570   PORT_START("IN0")      /* 3rd I/O port */
15241571   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
15251572   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
15261573
1527//  PORT_START("RESET")     /* Buttons on Genesis Console */
1528//  PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("Reset Button") PORT_IMPULSE(1) // reset, resets 68k (and..?)
1529
1530//  PORT_START("REGION")    /* Buttons on Genesis Console */
1531//  /* Region setting for Console */
1532//  PORT_DIPNAME( 0x000f, 0x0000, DEF_STR( Region ) )
1533//  PORT_DIPSETTING(      0x0000, "Use HazeMD Default Choice" )
1534//  PORT_DIPSETTING(      0x0001, "US (NTSC, 60fps)" )
1535//  PORT_DIPSETTING(      0x0002, "JAPAN (NTSC, 60fps)" )
1536//  PORT_DIPSETTING(      0x0003, "EUROPE (PAL, 50fps)" )
1537
15381574   PORT_START("DSWA")
15391575   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
15401576   PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )
r4939r4940
15781614INPUT_PORTS_END
15791615
15801616
1581
1582
1583
1584/*
1585
1586    A10001h = A0         Version register
1587
1588    A10003h = 7F         Data register for port A
1589    A10005h = 7F         Data register for port B
1590    A10007h = 7F         Data register for port C
1591
1592    A10009h = 00         Ctrl register for port A
1593    A1000Bh = 00         Ctrl register for port B
1594    A1000Dh = 00         Ctrl register for port C
1595
1596    A1000Fh = FF         TxData register for port A
1597    A10011h = 00         RxData register for port A
1598    A10013h = 00         S-Ctrl register for port A
1599
1600    A10015h = FF         TxData register for port B
1601    A10017h = 00         RxData register for port B
1602    A10019h = 00         S-Ctrl register for port B
1603
1604    A1001Bh = FF         TxData register for port C
1605    A1001Dh = 00         RxData register for port C
1606    A1001Fh = 00         S-Ctrl register for port C
1607
1608
1609
1610
1611 Bit 7 - (Not connected)
1612 Bit 6 - TH
1613 Bit 5 - TL
1614 Bit 4 - TR
1615 Bit 3 - RIGHT
1616 Bit 2 - LEFT
1617 Bit 1 - DOWN
1618 Bit 0 - UP
1619
1620
1621*/
1622
1623INPUT_PORTS_START( megadriv )
1624   PORT_START("PAD1")      /* Joypad 1 (3 button + start) NOT READ DIRECTLY */
1625   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
1626   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
1627   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
1628   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
1629   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 A") // a
1630   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 B") // b
1631   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_NAME("P1 C") // c
1632   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1) PORT_NAME("P1 START") // start
1633
1634   PORT_START("PAD2")      /* Joypad 2 (3 button + start) NOT READ DIRECTLY */
1635   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
1636   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
1637   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
1638   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
1639   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 A") // a
1640   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 B") // b
1641   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 C") // c
1642   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2) PORT_NAME("P2 START") // start
1643
1644   PORT_START("IN0")      /* 3rd I/O port */
1645
1646   PORT_START("RESET")      /* Buttons on Genesis Console */
1647   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("Reset Button") PORT_IMPULSE(1) // reset, resets 68k (and..?)
1648
1649   PORT_START("REGION")   /* Region setting for Console */
1650   /* Region setting for Console */
1651   PORT_DIPNAME( 0x000f, 0x0000, DEF_STR( Region ) )
1652   PORT_DIPSETTING(      0x0000, "Use HazeMD Default Choice" )
1653   PORT_DIPSETTING(      0x0001, "US (NTSC, 60fps)" )
1654   PORT_DIPSETTING(      0x0002, "JAPAN (NTSC, 60fps)" )
1655   PORT_DIPSETTING(      0x0003, "EUROPE (PAL, 50fps)" )
1656INPUT_PORTS_END
1657
1658
16591617INPUT_PORTS_START( aladbl )
1660   PORT_START("PAD1")      /* Joypad 1 (3 button + start) NOT READ DIRECTLY */
1661   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
1662   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
1663   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
1664   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
1618   PORT_INCLUDE( md_common )
1619
1620   PORT_MODIFY("PAD1")      /* Joypad 1 (3 button + start) NOT READ DIRECTLY */
16651621   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_NAME("P1 Throw") // a
16661622   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("P1 Sword") // b
16671623   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_NAME("P1 Jump") // c
16681624   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 ) // start
16691625
1670   PORT_START("PAD2")      /* Joypad 2 (3 button + start) NOT READ DIRECTLY - not used */
1671//  PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
1672//  PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
1673//  PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
1674//  PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
1675//  PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_NAME("P2 Throw") // a
1676//  PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_NAME("P2 Sword") // b
1677//  PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_NAME("P2 Jump") // c
1678//  PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START2 ) // start
1626   PORT_MODIFY("PAD2")      /* Joypad 2 (3 button + start) NOT READ DIRECTLY - not used */
1627   PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
16791628
1680   PORT_START("IN0")      /* 3rd I/O port */
1681
1682//  PORT_START("RESET")     /* Buttons on Genesis Console */
1683//  PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("Reset Button") PORT_IMPULSE(1) // reset, resets 68k (and..?)
1684
1685//  PORT_START("REGION")    /* Region setting for Console */
1686//  /* Region setting for Console */
1687//  PORT_DIPNAME( 0x000f, 0x0000, DEF_STR( Region ) )
1688//  PORT_DIPSETTING(      0x0000, "Use HazeMD Default Choice" )
1689//  PORT_DIPSETTING(      0x0001, "US (NTSC, 60fps)" )
1690//  PORT_DIPSETTING(      0x0002, "JAPAN (NTSC, 60fps)" )
1691//  PORT_DIPSETTING(      0x0003, "EUROPE (PAL, 50fps)" )
1692
16931629    /* As I don't know how it is on real hardware, this is more a guess than anything */
16941630   PORT_START("MCU")
16951631   PORT_DIPNAME( 0x07, 0x01, DEF_STR( Coinage ) )          /* code at 0x1b2a50 - unsure if there are so many settings */
r4939r4940
17011637   PORT_DIPSETTING(    0x05, DEF_STR( 1C_5C ) )
17021638   PORT_DIPSETTING(    0x06, DEF_STR( 1C_6C ) )
17031639    PORT_DIPSETTING(    0x07, DEF_STR( 1C_7C ) )
1704   //PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_SPECIAL )         /* to avoid it being changed and corrupting Coinage settings */
1640//  PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_SPECIAL )         /* to avoid it being changed and corrupting Coinage settings */
17051641   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ) )       /* code at 0x1b2680 */
17061642   PORT_DIPSETTING(    0x10, DEF_STR( Easy ) )             /* "PRACTICE" */
17071643   PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )           /* "NORMAL" */
r4939r4940
17121648   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1)     /* needed to avoid credits getting mad */
17131649INPUT_PORTS_END
17141650
1715/* xxx_BUTTONs are used with player = 0, 1, 2, 3 so we need to return 0 for the missing 4th I/O port  */
1716static const char *const padnames[] = { "PAD1", "PAD2", "IN0", "UNK" };
1717
1718#define MODE_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0800) >> 11)
1719#define Z_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0400) >> 10)
1720#define Y_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0200) >> 9 )
1721#define X_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0100) >> 8 )
1722
1723#define START_BUTTON(machine,player) ((input_port_read_safe(machine, padnames[player], 0) & 0x0080) >> 7 )
1724#define C_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0040) >> 6 )
1725#define B_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0020) >> 5 )
1726#define A_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0010) >> 4 )
1727#define RIGHT_BUTTON(machine,player) ((input_port_read_safe(machine, padnames[player], 0) & 0x0008) >> 3 )
1728#define LEFT_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0004) >> 2 )
1729#define DOWN_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0002) >> 1 )
1730#define UP_BUTTON(machine,player)    ((input_port_read_safe(machine, padnames[player], 0) & 0x0001) >> 0 )
1731#define MD_RESET_BUTTON(machine)       ((input_port_read_safe(machine, "RESET", 0x00) & 0x01) >> 0 )
1732
17331651UINT8 megadrive_io_data_regs[3];
17341652UINT8 megadrive_io_ctrl_regs[3];
17351653static UINT8 megadrive_io_tx_regs[3];
r4939r4940
17461664   megadrive_io_tx_regs[1] = 0xff;
17471665   megadrive_io_tx_regs[2] = 0xff;
17481666
1749   if (machine->gamedrv->ipt==ipt_megadri6)
1667   if (machine->gamedrv->ipt == ipt_megadri6)
17501668      init_megadri6_io(machine);
17511669
1752   if (machine->gamedrv->ipt==ipt_ssf2ghw)
1670   if (machine->gamedrv->ipt == ipt_ssf2ghw)
17531671      init_megadri6_io(machine);
17541672}
17551673
1756/************* 6 button version **************************/
1674/************* 6 buttons version **************************/
17571675static UINT8 megadrive_io_read_data_port_6button(running_machine *machine, int portnum)
17581676{
1759   UINT8 retdata;
1677   UINT8 retdata, helper = (megadrive_io_ctrl_regs[portnum] & 0x7f) | 0xc0; // bits 6 & 7 always come from megadrive_io_data_regs
1678   static const char *pad3names[] = { "PAD1", "PAD2", "IN0", "UNK" };
1679   static const char *pad6names[] = { "EXTRA1", "EXTRA2", "IN0", "UNK" };
17601680
1761   if (megadrive_io_data_regs[portnum]&0x40)
1681   if (megadrive_io_data_regs[portnum] & 0x40)
17621682   {
1763      if (io_stage[portnum]==2)
1683      if (io_stage[portnum] == 2)
17641684      {
1765         retdata = ( megadrive_io_data_regs[portnum] & 0x80) |
1766                   (1 <<6) |
1767                   ((megadrive_io_ctrl_regs[portnum]&0x20)?(megadrive_io_data_regs[portnum]&0x20):(C_BUTTON(machine,portnum)<<5)) |
1768                   ((megadrive_io_ctrl_regs[portnum]&0x10)?(megadrive_io_data_regs[portnum]&0x10):(B_BUTTON(machine,portnum)<<4)) |
1769                   ((megadrive_io_ctrl_regs[portnum]&0x08)?(megadrive_io_data_regs[portnum]&0x08):(MODE_BUTTON(machine,portnum)<<3)) |
1770                   ((megadrive_io_ctrl_regs[portnum]&0x04)?(megadrive_io_data_regs[portnum]&0x04):(X_BUTTON(machine,portnum)<<2)) |
1771                   ((megadrive_io_ctrl_regs[portnum]&0x02)?(megadrive_io_data_regs[portnum]&0x02):(Y_BUTTON(machine,portnum)<<1)) |
1772                   ((megadrive_io_ctrl_regs[portnum]&0x01)?(megadrive_io_data_regs[portnum]&0x01):(Z_BUTTON(machine,portnum)<<0));
1685         /* here we read B, C & the additional buttons */
1686         retdata = (megadrive_io_data_regs[portnum] & helper) |
1687                  (((input_port_read_safe(machine, pad3names[portnum], 0) & 0x30) |
1688                     (input_port_read_safe(machine, pad6names[portnum], 0) & 0x0f)) & ~helper);
17731689      }
17741690      else
17751691      {
1776         retdata = ( megadrive_io_data_regs[portnum] & 0x80) |
1777                   (1 << 6) |
1778                   ((megadrive_io_ctrl_regs[portnum]&0x20)?(megadrive_io_data_regs[portnum]&0x20):(C_BUTTON(machine,portnum)<<5)) |
1779                   ((megadrive_io_ctrl_regs[portnum]&0x10)?(megadrive_io_data_regs[portnum]&0x10):(B_BUTTON(machine,portnum)<<4)) |
1780                   ((megadrive_io_ctrl_regs[portnum]&0x08)?(megadrive_io_data_regs[portnum]&0x08):(RIGHT_BUTTON(machine,portnum)<<3)) |
1781                   ((megadrive_io_ctrl_regs[portnum]&0x04)?(megadrive_io_data_regs[portnum]&0x04):(LEFT_BUTTON(machine,portnum)<<2)) |
1782                   ((megadrive_io_ctrl_regs[portnum]&0x02)?(megadrive_io_data_regs[portnum]&0x02):(DOWN_BUTTON(machine,portnum)<<1)) |
1783                   ((megadrive_io_ctrl_regs[portnum]&0x01)?(megadrive_io_data_regs[portnum]&0x01):(UP_BUTTON(machine,portnum)<<0));
1692         /* here we read B, C & the directional buttons */
1693         retdata = (megadrive_io_data_regs[portnum] & helper) |
1694                  ((input_port_read_safe(machine, pad3names[portnum], 0) & 0x3f) & ~helper);
17841695      }
17851696   }
17861697   else
17871698   {
1788      if (io_stage[portnum]==1)
1699      if (io_stage[portnum] == 1)
17891700      {
1790         retdata = ( megadrive_io_data_regs[portnum] & 0x80) |
1791                   ( 0<<6 ) |
1792                   ((megadrive_io_ctrl_regs[portnum]&0x20)?(megadrive_io_data_regs[portnum]&0x20):(START_BUTTON(machine,portnum)<<5)) |
1793                   ((megadrive_io_ctrl_regs[portnum]&0x10)?(megadrive_io_data_regs[portnum]&0x10):(A_BUTTON(machine,portnum)<<4)) |
1794                   ((megadrive_io_ctrl_regs[portnum]&0x08)?(megadrive_io_data_regs[portnum]&0x08):(0<<3)) |
1795                   ((megadrive_io_ctrl_regs[portnum]&0x04)?(megadrive_io_data_regs[portnum]&0x04):(0<<2)) |
1796                   ((megadrive_io_ctrl_regs[portnum]&0x02)?(megadrive_io_data_regs[portnum]&0x02):(0<<1)) |
1797                     ((megadrive_io_ctrl_regs[portnum]&0x01)?(megadrive_io_data_regs[portnum]&0x01):(0<<0));
1701         /* here we read ((Start & A) >> 2) | 0x00 */
1702         retdata = (megadrive_io_data_regs[portnum] & helper) |
1703                  (((input_port_read_safe(machine, pad3names[portnum], 0) & 0xc0) >> 2) & ~helper);
17981704      }
17991705      else if (io_stage[portnum]==2)
18001706      {
1801         retdata = ( megadrive_io_data_regs[portnum] & 0x80) |
1802                   ( 0<<6 ) |
1803                   ((megadrive_io_ctrl_regs[portnum]&0x20)?(megadrive_io_data_regs[portnum]&0x20):(START_BUTTON(machine,portnum)<<5)) |
1804                   ((megadrive_io_ctrl_regs[portnum]&0x10)?(megadrive_io_data_regs[portnum]&0x10):(A_BUTTON(machine,portnum)<<4)) |
1805                   ((megadrive_io_ctrl_regs[portnum]&0x08)?(megadrive_io_data_regs[portnum]&0x08):(1<<3)) |
1806                   ((megadrive_io_ctrl_regs[portnum]&0x04)?(megadrive_io_data_regs[portnum]&0x04):(1<<2)) |
1807                   ((megadrive_io_ctrl_regs[portnum]&0x02)?(megadrive_io_data_regs[portnum]&0x02):(1<<1)) |
1808                     ((megadrive_io_ctrl_regs[portnum]&0x01)?(megadrive_io_data_regs[portnum]&0x01):(1<<0));
1707         /* here we read ((Start & A) >> 2) | 0x0f */
1708         retdata = (megadrive_io_data_regs[portnum] & helper) |
1709                  ((((input_port_read_safe(machine, pad3names[portnum], 0) & 0xc0) >> 2) | 0x0f) & ~helper);
18091710      }
18101711      else
18111712      {
1812         retdata = ( megadrive_io_data_regs[portnum] & 0x80) |
1813                   ( 0<<6 ) |
1814                   ((megadrive_io_ctrl_regs[portnum]&0x20)?(megadrive_io_data_regs[portnum]&0x20):(START_BUTTON(machine,portnum)<<5)) |
1815                   ((megadrive_io_ctrl_regs[portnum]&0x10)?(megadrive_io_data_regs[portnum]&0x10):(A_BUTTON(machine,portnum)<<4)) |
1816                   ((megadrive_io_ctrl_regs[portnum]&0x08)?(megadrive_io_data_regs[portnum]&0x08):(0<<3)) |
1817                   ((megadrive_io_ctrl_regs[portnum]&0x04)?(megadrive_io_data_regs[portnum]&0x04):(0<<2)) |
1818                   ((megadrive_io_ctrl_regs[portnum]&0x02)?(megadrive_io_data_regs[portnum]&0x02):(DOWN_BUTTON(machine,portnum)<<1)) |
1819                     ((megadrive_io_ctrl_regs[portnum]&0x01)?(megadrive_io_data_regs[portnum]&0x01):(UP_BUTTON(machine,portnum)<<0));
1713         /* here we read ((Start & A) >> 2) | Up and Down */
1714         retdata = (megadrive_io_data_regs[portnum] & helper) |
1715                  ((((input_port_read_safe(machine, pad3names[portnum], 0) & 0xc0) >> 2) |
1716                     (input_port_read_safe(machine, pad3names[portnum], 0) & 0x02)) & ~helper);
18201717      }
18211718   }
18221719
18231720//  mame_printf_debug("read io data port stage %d port %d %02x\n",io_stage[portnum],portnum,retdata);
18241721
1825
1826   return retdata|(retdata<<8);
1722   return retdata | (retdata << 8);
18271723}
1828/************* end 6 button version ********************************************/
18291724
1725
1726/************* 3 buttons version **************************/
18301727static UINT8 megadrive_io_read_data_port_3button(running_machine *machine, int portnum)
18311728{
1832   UINT8 retdata;
1729   UINT8 retdata, helper = (megadrive_io_ctrl_regs[portnum] & 0x3f) | 0xc0; // bits 6 & 7 always come from megadrive_io_data_regs
1730   static const char *pad3names[] = { "PAD1", "PAD2", "IN0", "UNK" };
18331731
1834
18351732   if (megadrive_io_data_regs[portnum]&0x40)
18361733   {
1837      retdata = ( megadrive_io_data_regs[portnum] & 0x80) |
1838                ((megadrive_io_ctrl_regs[portnum]&0x40)?(megadrive_io_data_regs[portnum]&0x40):(0x40)) |
1839                ((megadrive_io_ctrl_regs[portnum]&0x20)?(megadrive_io_data_regs[portnum]&0x20):(C_BUTTON(machine,portnum)<<5)) |
1840                ((megadrive_io_ctrl_regs[portnum]&0x10)?(megadrive_io_data_regs[portnum]&0x10):(B_BUTTON(machine,portnum)<<4)) |
1841                ((megadrive_io_ctrl_regs[portnum]&0x08)?(megadrive_io_data_regs[portnum]&0x08):(RIGHT_BUTTON(machine,portnum)<<3)) |
1842                ((megadrive_io_ctrl_regs[portnum]&0x04)?(megadrive_io_data_regs[portnum]&0x04):(LEFT_BUTTON(machine,portnum)<<2)) |
1843                ((megadrive_io_ctrl_regs[portnum]&0x02)?(megadrive_io_data_regs[portnum]&0x02):(DOWN_BUTTON(machine,portnum)<<1)) |
1844                ((megadrive_io_ctrl_regs[portnum]&0x01)?(megadrive_io_data_regs[portnum]&0x01):(UP_BUTTON(machine,portnum)<<0));
1734      /* here we read B, C & the directional buttons */
1735      retdata = (megadrive_io_data_regs[portnum] & helper) |
1736               ((input_port_read_safe(machine, pad3names[portnum], 0) & 0x3f) & ~helper);
18451737   }
18461738   else
18471739   {
1848      retdata = ( megadrive_io_data_regs[portnum] & 0x80) |
1849                ((megadrive_io_ctrl_regs[portnum]&0x40)?(megadrive_io_data_regs[portnum]&0x40):(0x40)) |
1850                ((megadrive_io_ctrl_regs[portnum]&0x20)?(megadrive_io_data_regs[portnum]&0x20):(START_BUTTON(machine,portnum)<<5)) |
1851                ((megadrive_io_ctrl_regs[portnum]&0x10)?(megadrive_io_data_regs[portnum]&0x10):(A_BUTTON(machine,portnum)<<4)) |
1852                ((megadrive_io_ctrl_regs[portnum]&0x08)?(megadrive_io_data_regs[portnum]&0x08):(0<<3)) |
1853                ((megadrive_io_ctrl_regs[portnum]&0x04)?(megadrive_io_data_regs[portnum]&0x04):(0<<2)) |
1854                ((megadrive_io_ctrl_regs[portnum]&0x02)?(megadrive_io_data_regs[portnum]&0x02):(DOWN_BUTTON(machine,portnum)<<1)) |
1855                ((megadrive_io_ctrl_regs[portnum]&0x01)?(megadrive_io_data_regs[portnum]&0x01):(UP_BUTTON(machine,portnum)<<0));
1740      /* here we read ((Start & A) >> 2) | Up and Down */
1741      retdata = (megadrive_io_data_regs[portnum] & helper) |
1742               ((((input_port_read_safe(machine, pad3names[portnum], 0) & 0xc0) >> 2) |
1743                  (input_port_read_safe(machine, pad3names[portnum], 0) & 0x02)) & ~helper);
18561744   }
18571745
18581746   return retdata;
r4939r4940
18631751{
18641752   UINT8 retdata;
18651753
1866   if (ctrl==0x55)
1754   if (ctrl == 0x55)
18671755   {
1868         retdata = (1<<0) |
1869                 (1<<1) |
1870                 (A_BUTTON(machine,1)<<2) |
1871                 (1<<3) |
1872                 (A_BUTTON(machine,0)<<4) |
1873                 (1<<5) |
1874                 (1<<6) |
1875                 (1<<7);
1756         /* A keys */
1757         retdata = ((input_port_read(machine, "PAD1") & 0x40) >> 2) |
1758            ((input_port_read(machine, "PAD2") & 0x40) >> 4) | 0xeb;
18761759   }
18771760   else
18781761   {
1879      if (offset==0)
1762      if (offset == 0)
18801763      {
1881         retdata = (UP_BUTTON(machine,0)<<0) |
1882                 (DOWN_BUTTON(machine,0)<<1) |
1883                 (LEFT_BUTTON(machine,0)<<2) |
1884                 (RIGHT_BUTTON(machine,0)<<3) |
1885                 (B_BUTTON(machine,0)<<4) |
1886                 (C_BUTTON(machine,0)<<5) |
1887                 (UP_BUTTON(machine,1)<<6) |
1888                 (DOWN_BUTTON(machine,1)<<7);
1764         retdata = (input_port_read(machine, "PAD1") & 0x3f) | ((input_port_read(machine, "PAD2") & 0x03) << 6);
18891765      }
18901766      else
18911767      {
1892         retdata = (LEFT_BUTTON(machine,1)<<0) |
1893                 (RIGHT_BUTTON(machine,1)<<1) |
1894                 (B_BUTTON(machine,1)<<2) |
1895                 (C_BUTTON(machine,1)<<3) |
1896                 (1<<4) |
1897                 (1<<5) |
1898                 (1<<6) |
1899                 (1<<7);
1768         retdata = ((input_port_read(machine, "PAD2") & 0x3c) >> 2) | 0xf0;
19001769      }
19011770
19021771   }
r4939r4940
19081777READ8_HANDLER (megatech_sms_ioport_dc_r)
19091778{
19101779   running_machine *machine = space->machine;
1911   return (DOWN_BUTTON(machine,1)  << 7) |
1912         (UP_BUTTON(machine,1)    << 6) |
1913         (B_BUTTON(machine,0)     << 5) | // TR-A
1914         (A_BUTTON(machine,0)     << 4) | // TL-A
1915         (RIGHT_BUTTON(machine,0) << 3) |
1916         (LEFT_BUTTON(machine,0)  << 2) |
1917         (DOWN_BUTTON(machine,0)  << 1) |
1918         (UP_BUTTON(machine,0)    << 0);
1780   /* 2009-05 FP: would it be worth to give separate inputs to SMS? SMS has only 2 keys A,B (which are B,C on megadrive) */
1781   /* bit 4: TL-A; bit 5: TR-A */
1782   return (input_port_read(machine, "PAD1") & 0x3f) | ((input_port_read(machine, "PAD2") & 0x03) << 6);
19191783}
19201784
19211785READ8_HANDLER (megatech_sms_ioport_dd_r)
19221786{
19231787   running_machine *machine = space->machine;
1924   return (0               << 7) | // TH-B
1925         (0               << 6) | // TH-A
1926         (0               << 5) | // unused
1927         (1               << 4) | // RESET button
1928         (B_BUTTON(machine,1)     << 3) | // TR-B
1929         (A_BUTTON(machine,1)     << 2) | // TL-B
1930         (RIGHT_BUTTON(machine,1) << 1) |
1931         (LEFT_BUTTON(machine,1)  << 0);
1788   /* 2009-05 FP: would it be worth to give separate inputs to SMS? SMS has only 2 keys A,B (which are B,C on megadrive) */
1789   /* bit 2: TL-B; bit 3: TR-B; bit 4: RESET; bit 5: unused; bit 6: TH-A; bit 7: TH-B*/
1790   return ((input_port_read(machine, "PAD2") & 0x3c) >> 2) | 0x10;
19321791}
19331792
19341793static UINT8 megadrive_io_read_ctrl_port(int portnum)
r4939r4940
19371796   retdata = megadrive_io_ctrl_regs[portnum];
19381797   //mame_printf_debug("read io ctrl port %d %02x\n",portnum,retdata);
19391798
1940   return retdata|(retdata<<8);
1799   return retdata | (retdata << 8);
19411800}
19421801
19431802static UINT8 megadrive_io_read_tx_port(int portnum)
19441803{
19451804   UINT8 retdata;
19461805   retdata = megadrive_io_tx_regs[portnum];
1947   return retdata|(retdata<<8);
1806   return retdata | (retdata << 8);
19481807}
19491808
19501809static UINT8 megadrive_io_read_rx_port(int portnum)
r4939r4940
20201879
20211880   }
20221881
2023   return retdata | (retdata<<8);
1882   return retdata | (retdata << 8);
20241883}
20251884
20261885
r4939r4940
20321891}
20331892
20341893
2035/******************************6 button version*****************************/
1894/****************************** 6 buttons version*****************************/
20361895
20371896static void megadrive_io_write_data_port_6button(running_machine *machine, int portnum, UINT16 data)
20381897{
r4939r4940
20511910
20521911}
20531912
2054/***************************end 6 button version ****************************/
20551913
1914/*************************** 3 buttons version ****************************/
1915
20561916static void megadrive_io_write_ctrl_port(running_machine *machine, int portnum, UINT16 data)
20571917{
20581918   megadrive_io_ctrl_regs[portnum] = data;
r4939r4940
60655925   megadrive_imode_odd_frame^=1;
60665926//  cputag_set_input_line(machine, "genesis_snd_z80", 0, CLEAR_LINE); // if the z80 interrupt hasn't happened by now, clear it..
60675927
6068   if (MD_RESET_BUTTON(machine))  cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE);
5928   if (input_port_read_safe(machine, "RESET", 0x00) & 0x01)
5929      cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE);
60695930
60705931/*
60715932int megadrive_total_scanlines = 262;
r4939r4940
62466107
62476108   MDRV_SCREEN_ADD("megadriv", RASTER)
62486109   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB15)
6249   MDRV_SCREEN_REFRESH_RATE(60)
6110   MDRV_SCREEN_REFRESH_RATE(50)
62506111   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) // Vblank handled manually.
62516112   MDRV_SCREEN_SIZE(64*8, 64*8)
62526113   MDRV_SCREEN_VISIBLE_AREA(0, 32*8-1, 0, 28*8-1)
src/mame/drivers/trackfld.c
r4939r4940
505505   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
506506
507507   PORT_START("DSW1")
508   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )
508   PORT_DIPNAME( 0x0f, 0x0f, DEF_STR( Coin_A ) )   PORT_DIPLOCATION("SW1:1,2,3,4")
509509   PORT_DIPSETTING(    0x02, DEF_STR( 4C_1C ) )
510510   PORT_DIPSETTING(    0x05, DEF_STR( 3C_1C ) )
511511   PORT_DIPSETTING(    0x08, DEF_STR( 2C_1C ) )
r4939r4940
523523   PORT_DIPSETTING(    0x09, DEF_STR( 1C_7C ) )
524524   PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )   PORT_CONDITION("DSW1", 0xf0, PORTCOND_EQUALS, 0x00)
525525   PORT_DIPSETTING(    0x00, "No Coin A" )            PORT_CONDITION("DSW1", 0xf0, PORTCOND_NOTEQUALS, 0x00)
526   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )
526   PORT_DIPNAME( 0xf0, 0xf0, DEF_STR( Coin_B ) )   PORT_DIPLOCATION("SW1:5,6,7,8")
527527   PORT_DIPSETTING(    0x20, DEF_STR( 4C_1C ) )
528528   PORT_DIPSETTING(    0x50, DEF_STR( 3C_1C ) )
529529   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
r4939r4940
544544   /* No Coin X = coin slot X open (coins produce sound), but no effect on coin counter */
545545
546546   PORT_START("DSW2")
547   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
547   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )   PORT_DIPLOCATION("SW2:1,2")
548548   PORT_DIPSETTING(    0x03, "3" )
549549   PORT_DIPSETTING(    0x02, "4" )
550550   PORT_DIPSETTING(    0x01, "5" )
551551   PORT_DIPSETTING(    0x00, "6" )
552   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
553   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
554   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
555   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
556   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
557   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
558   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
559   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
560   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
561   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
562   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
563   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
564   PORT_DIPNAME( 0x40, 0x40, "Show Correct Answer" )
552   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW2:3")
553   PORT_DIPSETTING(    0x00, "8,000 Points" )
554   PORT_DIPSETTING(    0x04, "10,000 Points" )
555   PORT_DIPUNUSED_DIPLOC( 0x0008, 0x0008, "SW2:4" ) /* Listed as "not used" */
556   PORT_DIPUNUSED_DIPLOC( 0x0010, 0x0010, "SW2:5" ) /* Listed as "not used" */
557   PORT_DIPUNUSED_DIPLOC( 0x0020, 0x0020, "SW2:6" ) /* Listed as "not used" */
558   PORT_DIPNAME( 0x40, 0x40, "Show Correct Answer" )   PORT_DIPLOCATION("SW2:7")
565559   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
566560   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
567   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
568   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
569   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
561   PORT_DIPNAME( 0x80, 0x80, "Credit Limit" )   PORT_DIPLOCATION("SW2:8")
562   PORT_DIPSETTING(    0x80, "99 Credits" )
563   PORT_DIPSETTING(    0x00, "9 Credits" )
570564INPUT_PORTS_END
571565
572566static INPUT_PORTS_START( reaktor )
src/mame/drivers/mpu4.c
r4939r4940
462462   const device_config *pia6 = devtag_get_device(device->machine, "pia_ic6");
463463   const device_config *pia7 = devtag_get_device(device->machine, "pia_ic7");
464464   const device_config *pia8 = devtag_get_device(device->machine, "pia_ic8");
465   const device_config *ptm6840 = devtag_get_device(device->machine, "6840ptm");
465466
466467   /* The PIA and PTM IRQ lines are all connected to a common PCB track, leading directly to the 6809 IRQ line. */
467468   int combined_state = pia6821_get_irq_a(pia3) | pia6821_get_irq_b(pia3) |
r4939r4940
470471                   pia6821_get_irq_a(pia6) | pia6821_get_irq_b(pia6) |
471472                   pia6821_get_irq_a(pia7) | pia6821_get_irq_b(pia7) |
472473                   pia6821_get_irq_a(pia8) | pia6821_get_irq_b(pia8) |
473                   ptm6840_get_irq(0);
474                   ptm6840_get_irq(ptm6840);
474475
475476   if (!serial_card_connected)
476477   {
r4939r4940
484485   }
485486}
486487
487static void cpu0_irq_m6840(running_machine *machine, int state)
488static WRITE_LINE_DEVICE_HANDLER( cpu0_irq_m6840 )
488489{
489   cpu0_irq(devtag_get_device(machine, "pia_ic3"), state);
490   cpu0_irq(devtag_get_device(device->machine, "pia_ic3"), state);
490491}
491492
492493
r4939r4940
504505
505506
506507/* IC2 6840 PTM handler */
507static WRITE8_HANDLER( ic2_o1_callback )
508static WRITE8_DEVICE_HANDLER( ic2_o1_callback )
508509{
509   ptm6840_set_c2(space->machine,0,data);
510   ptm6840_set_c2(device, 0, data);
510511
511512   /* copy output value to IC2 c2
512513    this output is the clock for timer2 */
513514}
514515
515516
516static WRITE8_HANDLER( ic2_o2_callback )
517static WRITE8_DEVICE_HANDLER( ic2_o2_callback )
517518{
518   const device_config *pia = devtag_get_device(space->machine, "pia_ic3");
519   const device_config *pia = devtag_get_device(device->machine, "pia_ic3");
519520   pia6821_ca1_w(pia, 0, data); /* copy output value to IC3 ca1 */
520521
521522   /* the output from timer2 is the input clock for timer3 */
522   ptm6840_set_c3(   space->machine, 0, data);
523   ptm6840_set_c3(device, 0, data);
523524}
524525
525526
526static WRITE8_HANDLER( ic2_o3_callback )
527static WRITE8_DEVICE_HANDLER( ic2_o3_callback )
527528{
528529   /* the output from timer3 is used as a square wave for the alarm output
529530    and as an external clock source for timer 1! */
530531
531   ptm6840_set_c1(    space->machine, 0, data);
532   ptm6840_set_c1(device, 0, data);
532533}
533534
534535
535536static const ptm6840_interface ptm_ic2_intf =
536537{
537   MPU4_MASTER_CLOCK/4,
538   { 0,0,0 },
539   { ic2_o1_callback, ic2_o2_callback, ic2_o3_callback },
540   cpu0_irq_m6840
538   MPU4_MASTER_CLOCK / 4,
539   { 0, 0, 0 },
540   { DEVCB_HANDLER(ic2_o1_callback),
541     DEVCB_HANDLER(ic2_o2_callback),
542     DEVCB_HANDLER(ic2_o3_callback) },
543   DEVCB_LINE(cpu0_irq_m6840)
541544};
542545
543546
r4939r4940
15351538static void mpu4_config_common(running_machine *machine)
15361539{
15371540   ic24_timer = timer_alloc(machine, ic24_timeout, NULL);
1538   /* setup 6840ptm */
1539   ptm6840_config(machine, 0, &ptm_ic2_intf );
15401541}
15411542
15421543static MACHINE_START( mpu4mod2 )
r4939r4940
17531754
17541755   AM_RANGE(0x0850, 0x0850) AM_READWRITE(bankswitch_r,bankswitch_w)   /* write bank (rom page select) */
17551756
1756/*  AM_RANGE(0x08E0, 0x08E7) AM_READWRITE(68681_duart_r,68681_duart_w) */
1757/*  AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w) */
17571758
1758   AM_RANGE(0x0900, 0x0907) AM_READWRITE(ptm6840_0_r,ptm6840_0_w) /* 6840PTM */
1759   AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE("6840ptm", ptm6840_read, ptm6840_write) /* 6840PTM */
17591760
1760   AM_RANGE(0x0A00, 0x0A03) AM_DEVREADWRITE("pia_ic3", pia6821_r,pia6821_w)        /* PIA6821 IC3 */
1761   AM_RANGE(0x0B00, 0x0B03) AM_DEVREADWRITE("pia_ic4", pia6821_r,pia6821_w)        /* PIA6821 IC4 */
1762   AM_RANGE(0x0C00, 0x0C03) AM_DEVREADWRITE("pia_ic5", pia6821_r,pia6821_w)        /* PIA6821 IC5 */
1763   AM_RANGE(0x0D00, 0x0D03) AM_DEVREADWRITE("pia_ic6", pia6821_r,pia6821_w)      /* PIA6821 IC6 */
1764   AM_RANGE(0x0E00, 0x0E03) AM_DEVREADWRITE("pia_ic7", pia6821_r,pia6821_w)      /* PIA6821 IC7 */
1765   AM_RANGE(0x0F00, 0x0F03) AM_DEVREADWRITE("pia_ic8", pia6821_r,pia6821_w)      /* PIA6821 IC8 */
1761   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE("pia_ic3", pia6821_r, pia6821_w)        /* PIA6821 IC3 */
1762   AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE("pia_ic4", pia6821_r, pia6821_w)        /* PIA6821 IC4 */
1763   AM_RANGE(0x0c00, 0x0c03) AM_DEVREADWRITE("pia_ic5", pia6821_r, pia6821_w)        /* PIA6821 IC5 */
1764   AM_RANGE(0x0d00, 0x0d03) AM_DEVREADWRITE("pia_ic6", pia6821_r, pia6821_w)      /* PIA6821 IC6 */
1765   AM_RANGE(0x0e00, 0x0e03) AM_DEVREADWRITE("pia_ic7", pia6821_r, pia6821_w)      /* PIA6821 IC7 */
1766   AM_RANGE(0x0f00, 0x0f03) AM_DEVREADWRITE("pia_ic8", pia6821_r, pia6821_w)      /* PIA6821 IC8 */
17661767
17671768   AM_RANGE(0x1000, 0xffff) AM_READ(SMH_BANK(1))   /* 64k  paged ROM (4 pages)  */
17681769ADDRESS_MAP_END
r4939r4940
17761777
17771778   AM_RANGE(0x0880, 0x0881) AM_DEVWRITE( "ym2413", ym2413_w )
17781779
1779//  AM_RANGE(0x08E0, 0x08E7) AM_READWRITE(68681_duart_r,68681_duart_w)
1780//  AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w)
17801781
1781   AM_RANGE(0x0900, 0x0907) AM_READWRITE(ptm6840_0_r,ptm6840_0_w)   // 6840PTM
1782   AM_RANGE(0x0A00, 0x0A03) AM_DEVREADWRITE("pia_ic3", pia6821_r,pia6821_w)        /* PIA6821 IC3 */
1783   AM_RANGE(0x0B00, 0x0B03) AM_DEVREADWRITE("pia_ic4", pia6821_r,pia6821_w)        /* PIA6821 IC4 */
1784   AM_RANGE(0x0C00, 0x0C03) AM_DEVREADWRITE("pia_ic5", pia6821_r,pia6821_w)        /* PIA6821 IC5 */
1785   AM_RANGE(0x0D00, 0x0D03) AM_DEVREADWRITE("pia_ic6", pia6821_r,pia6821_w)      /* PIA6821 IC6 */
1786   AM_RANGE(0x0E00, 0x0E03) AM_DEVREADWRITE("pia_ic7", pia6821_r,pia6821_w)      /* PIA6821 IC7 */
1787   AM_RANGE(0x0F00, 0x0F03) AM_DEVREADWRITE("pia_ic8", pia6821_r,pia6821_w)      /* PIA6821 IC8 */
1782   AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE("6840ptm", ptm6840_read, ptm6840_write) /* 6840PTM */
17881783
1784   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE("pia_ic3", pia6821_r, pia6821_w)        /* PIA6821 IC3 */
1785   AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE("pia_ic4", pia6821_r, pia6821_w)        /* PIA6821 IC4 */
1786   AM_RANGE(0x0c00, 0x0c03) AM_DEVREADWRITE("pia_ic5", pia6821_r, pia6821_w)        /* PIA6821 IC5 */
1787   AM_RANGE(0x0d00, 0x0d03) AM_DEVREADWRITE("pia_ic6", pia6821_r, pia6821_w)      /* PIA6821 IC6 */
1788   AM_RANGE(0x0e00, 0x0e03) AM_DEVREADWRITE("pia_ic7", pia6821_r, pia6821_w)      /* PIA6821 IC7 */
1789   AM_RANGE(0x0f00, 0x0f03) AM_DEVREADWRITE("pia_ic8", pia6821_r, pia6821_w)      /* PIA6821 IC8 */
1790
17891791   AM_RANGE(0x1000, 0xffff) AM_READ(SMH_BANK(1))   // 64k  paged ROM (4 pages)
17901792ADDRESS_MAP_END
17911793
r4939r4940
17981800
17991801   AM_RANGE(0x0880, 0x0883) AM_DEVREADWRITE("pia_gamebd", pia6821_r,pia6821_w)      // PIA6821 on game board
18001802
1801//  AM_RANGE(0x08C0, 0x08C7) AM_READERITE(ptm6840_1_r,ptm6840_1_w)  // 6840PTM on game board
1803//  AM_RANGE(0x08c0, 0x08c7) AM_DEVREADWRITE("??", ptm6840_read, ptm6840_write)  // 6840PTM on game board
18021804
1803//  AM_RANGE(0x08E0, 0x08E7) AM_READWRITE(68681_duart_r,68681_duart_w)
1805//  AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w)
18041806
1805   AM_RANGE(0x0900, 0x0907) AM_READWRITE(ptm6840_0_r,ptm6840_0_w)   // 6840PTM
1806   AM_RANGE(0x0A00, 0x0A03) AM_DEVREADWRITE("pia_ic3", pia6821_r,pia6821_w)        /* PIA6821 IC3 */
1807   AM_RANGE(0x0B00, 0x0B03) AM_DEVREADWRITE("pia_ic4", pia6821_r,pia6821_w)        /* PIA6821 IC4 */
1808   AM_RANGE(0x0C00, 0x0C03) AM_DEVREADWRITE("pia_ic5", pia6821_r,pia6821_w)        /* PIA6821 IC5 */
1809   AM_RANGE(0x0D00, 0x0D03) AM_DEVREADWRITE("pia_ic6", pia6821_r,pia6821_w)      /* PIA6821 IC6 */
1810   AM_RANGE(0x0E00, 0x0E03) AM_DEVREADWRITE("pia_ic7", pia6821_r,pia6821_w)      /* PIA6821 IC7 */
1811   AM_RANGE(0x0F00, 0x0F03) AM_DEVREADWRITE("pia_ic8", pia6821_r,pia6821_w)      /* PIA6821 IC8 */
1807   AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE("6840ptm", ptm6840_read, ptm6840_write) /* 6840PTM */
18121808
1809   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE("pia_ic3", pia6821_r, pia6821_w)        /* PIA6821 IC3 */
1810   AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE("pia_ic4", pia6821_r, pia6821_w)        /* PIA6821 IC4 */
1811   AM_RANGE(0x0c00, 0x0c03) AM_DEVREADWRITE("pia_ic5", pia6821_r, pia6821_w)        /* PIA6821 IC5 */
1812   AM_RANGE(0x0d00, 0x0d03) AM_DEVREADWRITE("pia_ic6", pia6821_r, pia6821_w)      /* PIA6821 IC6 */
1813   AM_RANGE(0x0e00, 0x0e03) AM_DEVREADWRITE("pia_ic7", pia6821_r, pia6821_w)      /* PIA6821 IC7 */
1814   AM_RANGE(0x0f00, 0x0f03) AM_DEVREADWRITE("pia_ic8", pia6821_r, pia6821_w)      /* PIA6821 IC8 */
1815
18131816   AM_RANGE(0x1000, 0xffff) AM_READ(SMH_BANK(1))   // 64k  paged ROM (4 pages)
18141817ADDRESS_MAP_END
18151818
r4939r4940
18241827   AM_RANGE(0x0850, 0x0850) AM_WRITE(bankswitch_w)   // write bank (rom page select)
18251828   AM_RANGE(0x0880, 0x0883) AM_DEVREADWRITE("pia_gamebd", pia6821_r,pia6821_w)      // PIA6821 on game board
18261829
1827//  AM_RANGE(0x08C0, 0x08C7) AM_READERITE(ptm6840_2_r,ptm6840_2_w)  // 6840PTM on game board
1830//  AM_RANGE(0x08c0, 0x08c7) AM_DEVREADWRITE("??", ptm6840_read, ptm6840_write)  // 6840PTM on game board
18281831
1829//  AM_RANGE(0x08E0, 0x08E7) AM_READWRITE(68681_duart_r,68681_duart_w)
1832//  AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w)
18301833
1831   AM_RANGE(0x0900, 0x0907) AM_READWRITE(ptm6840_0_r,ptm6840_0_w)   // 6840PTM
1832   AM_RANGE(0x0A00, 0x0A03) AM_DEVREADWRITE("pia_ic3", pia6821_r,pia6821_w)        /* PIA6821 IC3 */
1833   AM_RANGE(0x0B00, 0x0B03) AM_DEVREADWRITE("pia_ic4", pia6821_r,pia6821_w)        /* PIA6821 IC4 */
1834   AM_RANGE(0x0C00, 0x0C03) AM_DEVREADWRITE("pia_ic5", pia6821_r,pia6821_w)        /* PIA6821 IC5 */
1835   AM_RANGE(0x0D00, 0x0D03) AM_DEVREADWRITE("pia_ic6", pia6821_r,pia6821_w)      /* PIA6821 IC6 */
1836   AM_RANGE(0x0E00, 0x0E03) AM_DEVREADWRITE("pia_ic7", pia6821_r,pia6821_w)      /* PIA6821 IC7 */
1837   AM_RANGE(0x0F00, 0x0F03) AM_DEVREADWRITE("pia_ic8", pia6821_r,pia6821_w)      /* PIA6821 IC8 */
1834   AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE("6840ptm", ptm6840_read, ptm6840_write) /* 6840PTM */
18381835
1836   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE("pia_ic3", pia6821_r, pia6821_w)        /* PIA6821 IC3 */
1837   AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE("pia_ic4", pia6821_r, pia6821_w)        /* PIA6821 IC4 */
1838   AM_RANGE(0x0c00, 0x0c03) AM_DEVREADWRITE("pia_ic5", pia6821_r, pia6821_w)        /* PIA6821 IC5 */
1839   AM_RANGE(0x0d00, 0x0d03) AM_DEVREADWRITE("pia_ic6", pia6821_r, pia6821_w)      /* PIA6821 IC6 */
1840   AM_RANGE(0x0e00, 0x0e03) AM_DEVREADWRITE("pia_ic7", pia6821_r, pia6821_w)      /* PIA6821 IC7 */
1841   AM_RANGE(0x0f00, 0x0f03) AM_DEVREADWRITE("pia_ic8", pia6821_r, pia6821_w)      /* PIA6821 IC8 */
1842
18391843   AM_RANGE(0x1000, 0xffff) AM_READ(SMH_BANK(1))   // 64k paged ROM (4 pages)
18401844ADDRESS_MAP_END
18411845
r4939r4940
18601864
18611865   MDRV_TIMER_ADD_PERIODIC("50hz",gen_50hz, HZ(100))
18621866
1867   /* 6840 PTM */
1868   MDRV_PTM6840_ADD("6840ptm", ptm_ic2_intf)
1869
18631870   MDRV_PIA6821_ADD("pia_ic3", pia_ic3_intf)
18641871   MDRV_PIA6821_ADD("pia_ic4", pia_ic4_intf)
18651872   MDRV_PIA6821_ADD("pia_ic5", pia_ic5_intf)
src/mame/drivers/polepos.c
r4939r4940
917917   MDRV_CPU_PROGRAM_MAP(z8002_map)
918918   MDRV_CPU_VBLANK_INT("screen", irq0_line_assert)
919919
920   MDRV_NAMCO_51XX_ADD("51xx", 18432000/12, namco_51xx_intf)      /* 1.536 MHz */
921   MDRV_NAMCO_52XX_ADD("52xx", 18432000/12, namco_52xx_intf)      /* 1.536 MHz */
922   MDRV_NAMCO_53XX_ADD("53xx", 18432000/12, namco_53xx_intf)      /* 1.536 MHz */
923   MDRV_NAMCO_54XX_ADD("54xx", 18432000/12, "discrete", NODE_01)   /* 1.536 MHz */
920   MDRV_NAMCO_51XX_ADD("51xx", 18432000/6/2, namco_51xx_intf)      /* 1.536 MHz */
921   MDRV_NAMCO_52XX_ADD("52xx", 18432000/6/2, namco_52xx_intf)      /* 1.536 MHz */
922   MDRV_NAMCO_53XX_ADD("53xx", 18432000/6/2, namco_53xx_intf)      /* 1.536 MHz */
923   MDRV_NAMCO_54XX_ADD("54xx", 18432000/6/2, "discrete", NODE_01)   /* 1.536 MHz */
924924
925   MDRV_NAMCO_06XX_ADD("06xx", "maincpu", "51xx", "53xx", "52xx", "54xx")
925   MDRV_NAMCO_06XX_ADD("06xx", 18432000/6/64, "maincpu", "51xx", "53xx", "52xx", "54xx")
926926
927927   MDRV_WATCHDOG_VBLANK_INIT(16)   // 128V clocks the same as VBLANK
928928
src/mame/drivers/cps1.c
r4939r4940
54525452   ROM_LOAD( "sou1",         0x0000, 0x0117, CRC(84f4b2fe) SHA1(dcc9e86cc36316fe42eace02d6df75d08bc8bb6d) )
54535453ROM_END
54545454
5455/*  Bootleg manufactured by TAB Austria
5456
5457 -------------------------------------------------------
5458 |    ROM1    *2  *3                         ROM5 ROM9 |
5459 |    ROM2                                   ROM6 ROM8 |
5460 |            *1                              1B   1D  |
5461 |      6295                                  1A   1C  |
5462 |  YM                               ROM4     1F   1H  |
5463 |    ROM3                                    1E   1G  |
5464--     Z80                                    1J   1L  |
5465--                                            1I   1K  |
5466--                                                     |
5467--                                                     |
5468--                     TAB                             |
5469--                    AUSTRIA                          |
5470 | DIP8 6                                              |
5471 |      8  ROM10  ROM9                                 |
5472 | DIP8 0  ROM12  ROM11                                |
5473 |      0                                              |
5474 | DIP8 0                                              |
5475 |------------------------------------------------------
5476
5477   *1 = 12.000 Mhz
5478   *2 = 3.579545 Mhz
5479   *3 = 16.000 Mhz
5480
5481*/
5482ROM_START( sf2ebbl )
5483   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
5484   ROM_LOAD16_BYTE( "12.bin",   0x00000, 0x40000, CRC(a258b4d5) SHA1(3433b6493794c98bb35c1b27cc65bb5f13d52e9b) )
5485   ROM_LOAD16_BYTE( "09.bin",   0x00001, 0x40000, CRC(59ccd474) SHA1(7bb28c28ee722435fdbb18eb73e52bd65b419103) )
5486   ROM_LOAD16_BYTE( "11.bin",   0x80000, 0x40000, CRC(82097d63) SHA1(881e7ffb78197f6794b5d41f5c2c87da35e8cb15) )
5487   ROM_LOAD16_BYTE( "10.bin",   0x80001, 0x40000, CRC(0c83844d) SHA1(4c25ba4a50d62c62789d026e3d304ed1dfb3c248) )
5488
5489   ROM_REGION( 0x600000, "gfx", 0 )
5490   /* The 12 MASK roms on this PCB match the original roms exactly */
5491   ROMX_LOAD( "1b_yf082.bin", 0x000000, 0x80000, CRC(22c9cc8e) SHA1(b9194fb337b30502c1c9501cd6c64ae4035544d4) , ROM_GROUPWORD | ROM_SKIP(6) )
5492   ROMX_LOAD( "1d_yf028.bin", 0x000002, 0x80000, CRC(57213be8) SHA1(3759b851ac0904ec79cbb67a2264d384b6f2f9f9) , ROM_GROUPWORD | ROM_SKIP(6) )
5493   ROMX_LOAD( "1a_yf087.bin", 0x000004, 0x80000, CRC(ba529b4f) SHA1(520840d727161cf09ca784919fa37bc9b54cc3ce) , ROM_GROUPWORD | ROM_SKIP(6) )
5494   ROMX_LOAD( "1c_yf088.bin", 0x000006, 0x80000, CRC(4b1b33a8) SHA1(2360cff890551f76775739e2d6563858bff80e41) , ROM_GROUPWORD | ROM_SKIP(6) )
5495   ROMX_LOAD( "1f_yf085.bin", 0x200000, 0x80000, CRC(2c7e2229) SHA1(357c2275af9133fd0bd6fbb1fa9ad5e0b490b3a2) , ROM_GROUPWORD | ROM_SKIP(6) )
5496   ROMX_LOAD( "1h_yf115.bin", 0x200002, 0x80000, CRC(b5548f17) SHA1(baa92b91cf616bc9e2a8a66adc777ffbf962a51b) , ROM_GROUPWORD | ROM_SKIP(6) )
5497   ROMX_LOAD( "1e_yf111.bin", 0x200004, 0x80000, CRC(14b84312) SHA1(2eea16673e60ba7a10bd4d8f6c217bb2441a5b0e) , ROM_GROUPWORD | ROM_SKIP(6) )
5498   ROMX_LOAD( "1g_yf002.bin", 0x200006, 0x80000, CRC(5e9cd89a) SHA1(f787aab98668d4c2c54fc4ba677c0cb808e4f31e) , ROM_GROUPWORD | ROM_SKIP(6) )
5499   ROMX_LOAD( "1j_yf117.bin", 0x400000, 0x80000, CRC(994bfa58) SHA1(5669b845f624b10e7be56bfc89b76592258ce48b) , ROM_GROUPWORD | ROM_SKIP(6) )
5500   ROMX_LOAD( "1l_ye040.bin", 0x400002, 0x80000, CRC(3e66ad9d) SHA1(9af9df0826988872662753e9717c48d46f2974b0) , ROM_GROUPWORD | ROM_SKIP(6) )
5501   ROMX_LOAD( "1i_yf038.bin", 0x400004, 0x80000, CRC(c1befaa8) SHA1(a6a7f4725e52678cbd8d557285c01cdccb2c2602) , ROM_GROUPWORD | ROM_SKIP(6) )
5502   ROMX_LOAD( "1k_ye039.bin", 0x400006, 0x80000, CRC(0627c831) SHA1(f9a92d614e8877d648449de2612fc8b43c85e4c2) , ROM_GROUPWORD | ROM_SKIP(6) )
5503   /* These map over the MASK roms on this bootleg to get rid of the CAPCOM logo (wasteful, but correct) */
5504   ROMX_LOAD( "05.bin", 0x400000, 0x10000, CRC(a505621e) SHA1(8ffa8cedad54948870bbd8f629d927332dc9fcf6) , ROM_SKIP(7) )
5505   ROM_CONTINUE(        0x400004, 0x10000 )
5506   ROMX_LOAD( "07.bin", 0x400002, 0x10000, CRC(de6271fb) SHA1(574ec5d9992941a405fd00abe52da41aba4b29a7) , ROM_SKIP(7) )
5507   ROM_CONTINUE(        0x400006, 0x10000 )
5508   ROMX_LOAD( "06.bin", 0x400001, 0x10000, CRC(23775344) SHA1(0d6b54f66cd64c3f48c88c8e17a19fdb2002afb0) , ROM_SKIP(7) )
5509   ROM_CONTINUE(        0x400005, 0x10000 )
5510   ROMX_LOAD( "08.bin", 0x400003, 0x10000, CRC(81c9550f) SHA1(2d75e329148caadfff35c8f2f91b352f14dbe08a) , ROM_SKIP(7) )
5511   ROM_CONTINUE(        0x400007, 0x10000 )
5512
5513   ROM_REGION( 0x18000, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */
5514   ROM_LOAD( "03.bin",    0x00000, 0x08000, CRC(a4823a1b) SHA1(7b6bf59dfd578bfbbdb64c27988796783442d659) )
5515   ROM_CONTINUE(              0x10000, 0x08000 )
5516
5517   ROM_REGION( 0x20000, "user1", 0 ) /* unknown (bootleg priority?) */
5518   ROM_LOAD( "04.bin",    0x00000, 0x10000, CRC(13ea1c44) SHA1(5b05fe4c3920e33d94fac5f59e09ff14b3e427fe) )
5519
5520   ROM_REGION( 0x40000, "oki", 0 )   /* Samples */
5521   ROM_LOAD( "02.bin",    0x00000, 0x20000, CRC(7f162009) SHA1(346bf42992b4c36c593e21901e22c87ae4a7d86d) )
5522   ROM_LOAD( "01.bin",    0x20000, 0x20000, CRC(beade53f) SHA1(277c397dc12752719ec6b47d2224750bd1c07f79) )
5523ROM_END
5524
54555525/* B-Board 89624B */
54565526ROM_START( 3wonders )
54575527   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
r4939r4940
84298499GAME( 1990, nemoj,    nemo,     cps1_10MHz, nemo,     cps1,     ROT0,   "Capcom", "Nemo (Japan 901120)", 0 )
84308500GAME( 1991, sf2,      0,        cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910522)" , 0)   // "ETC"
84318501GAME( 1991, sf2eb,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (World 910214)" , 0)   // "ETC"
8502GAME( 1992, sf2ebbl,  sf2,      cps1_10MHz, sf2hack,  sf2hack,  ROT0,   "bootleg","Street Fighter II - The World Warrior (World 910214, TAB Austria bootleg)", 0 )
84328503GAME( 1991, sf2ua,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910206)", 0 )
84338504GAME( 1991, sf2ub,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910214)", 0 )
84348505GAME( 1991, sf2ud,    sf2,      cps1_10MHz, sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II - The World Warrior (US 910318)", 0 )
src/mame/drivers/scobra.c
r4939r4940
280280
281281static ADDRESS_MAP_START( anteatgb_map, ADDRESS_SPACE_PROGRAM, 8 )
282282   AM_RANGE(0x0000, 0x03ff) AM_ROM
283   AM_RANGE(0x0400, 0x0bff) AM_ROM
283   AM_RANGE(0x0400, 0x0bff) AM_RAM
284284   AM_RANGE(0x0c00, 0x0fff) AM_RAM_WRITE(galaxold_videoram_w) AM_BASE(&galaxold_videoram)
285285   AM_RANGE(0x1171, 0x1171) AM_WRITE(galaxold_nmi_enable_w)
286286   AM_RANGE(0x1174, 0x1174) AM_WRITE(galaxold_stars_enable_w)
src/mame/drivers/hnayayoi.c
r4939r4940
515515
516516static void irqhandler(const device_config *device, int irq)
517517{
518popmessage("irq");
519//  cpu_set_input_line(device->machine->cpu[2],0,irq ? ASSERT_LINE : CLEAR_LINE);
518   popmessage("irq");
519//  cputag_set_input_line(device->machine, "maincpu",0,irq ? ASSERT_LINE : CLEAR_LINE);
520520}
521521
522522
src/mame/drivers/tmnt.c
r4939r4940
309309
310310static void sound_nmi_callback( int param )
311311{
312   cpu_set_input_line(Machine->cpu[1], INPUT_LINE_NMI, ( sound_nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE );
312   cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ( sound_nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE );
313313
314314   sound_nmi_enabled = 0;
315315}
src/mame/drivers/namcos12.c
r4939r4940
23042304   ROM_LOAD32_WORD( "teg3rom2e.11", 0x2000000, 0x800000, CRC(6e5c3428) SHA1(e3cdb60a4445406877b2e273385f34bfb0974220) )
23052305   ROM_LOAD32_WORD( "teg3rom2o.15", 0x2000002, 0x800000, CRC(21ce9dfa) SHA1(f27e8210ee236c327aa3e1ce4dd408abc6580a1b) )
23062306
2307   ROM_LOAD32_BYTE( "teg3flel.4",   0x3000000, 0x200000, CRC(88b3823c) SHA1(6f31acb642c57daccbfdb87b790037e261c8c73c) )
2308   ROM_LOAD32_BYTE( "teg3fleu.5",   0x3000001, 0x200000, CRC(36df0867) SHA1(6bec8560ad4c122dc909daa83aa9089ba5b281f7) )
2309   ROM_LOAD32_BYTE( "teg3flol.6",   0x3000002, 0x200000, CRC(03a76765) SHA1(ae35ae28375f2a3e52d72b77ec09750c326cc269) )
2310   ROM_LOAD32_BYTE( "teg3flou.7",   0x3000003, 0x200000, CRC(6d6947d1) SHA1(2f307bc4070fadb510c0473bc91d917b2d845ca5) )
2307   ROM_LOAD32_BYTE( "teg1flel.4",   0x3000000, 0x200000, NO_DUMP )
2308   ROM_LOAD32_BYTE( "teg1fleu.5",   0x3000001, 0x200000, NO_DUMP )
2309   ROM_LOAD32_BYTE( "teg1flol.6",   0x3000002, 0x200000, NO_DUMP )
2310   ROM_LOAD32_BYTE( "teg1flou.7",   0x3000003, 0x200000, NO_DUMP )
23112311
23122312   ROM_REGION( 0x0080000, "sub", 0 ) /* sound prg */
23132313   ROM_LOAD16_WORD_SWAP( "teg3verb.11s", 0x0000000, 0x080000, CRC(67d0c469) SHA1(da164702fc21b9f46a9e32c89e7b1d36070ddf79) )
r4939r4940
23302330   ROM_LOAD32_WORD( "teg3rom2e.11", 0x2000000, 0x800000, CRC(6e5c3428) SHA1(e3cdb60a4445406877b2e273385f34bfb0974220) )
23312331   ROM_LOAD32_WORD( "teg3rom2o.15", 0x2000002, 0x800000, CRC(21ce9dfa) SHA1(f27e8210ee236c327aa3e1ce4dd408abc6580a1b) )
23322332
2333   ROM_LOAD32_BYTE( "teg3flel.4",   0x3000000, 0x200000, CRC(88b3823c) SHA1(6f31acb642c57daccbfdb87b790037e261c8c73c) )
2334   ROM_LOAD32_BYTE( "teg3fleu.5",   0x3000001, 0x200000, CRC(36df0867) SHA1(6bec8560ad4c122dc909daa83aa9089ba5b281f7) )
2335   ROM_LOAD32_BYTE( "teg3flol.6",   0x3000002, 0x200000, CRC(03a76765) SHA1(ae35ae28375f2a3e52d72b77ec09750c326cc269) )
2336   ROM_LOAD32_BYTE( "teg3flou.7",   0x3000003, 0x200000, CRC(6d6947d1) SHA1(2f307bc4070fadb510c0473bc91d917b2d845ca5) )
2333   ROM_LOAD32_BYTE( "teg1flel.4",   0x3000000, 0x200000, NO_DUMP )
2334   ROM_LOAD32_BYTE( "teg1fleu.5",   0x3000001, 0x200000, NO_DUMP )
2335   ROM_LOAD32_BYTE( "teg1flol.6",   0x3000002, 0x200000, NO_DUMP )
2336   ROM_LOAD32_BYTE( "teg1flou.7",   0x3000003, 0x200000, NO_DUMP )
23372337
23382338   ROM_REGION( 0x0080000, "sub", 0 ) /* sound prg */
23392339   ROM_LOAD16_WORD_SWAP( "teg3verb.11s", 0x0000000, 0x080000, CRC(67d0c469) SHA1(da164702fc21b9f46a9e32c89e7b1d36070ddf79) )
src/mame/drivers/cchasm.c
r4939r4940
3333
3434static ADDRESS_MAP_START( memmap, ADDRESS_SPACE_PROGRAM, 16 )
3535   AM_RANGE(0x000000, 0x00ffff) AM_ROM
36   AM_RANGE(0x040000, 0x04000f) AM_READWRITE(ptm6840_0_lsb_r,ptm6840_0_lsb_w)
36   AM_RANGE(0x040000, 0x04000f) AM_DEVREADWRITE8("6840ptm", ptm6840_read, ptm6840_write, 0xff)
3737   AM_RANGE(0x050000, 0x050001) AM_WRITE(cchasm_refresh_control_w)
3838   AM_RANGE(0x060000, 0x060001) AM_READ_PORT("DSW") AM_WRITE(cchasm_led_w)
3939   AM_RANGE(0x070000, 0x070001) AM_WRITE(watchdog_reset16_w)
r4939r4940
6666   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE("ctc", z80ctc_r, z80ctc_w)
6767ADDRESS_MAP_END
6868
69static void cchasm_6840_irq(running_machine *machine, int state)
69static WRITE_LINE_DEVICE_HANDLER( cchasm_6840_irq )
7070{
71   cputag_set_input_line(machine, "maincpu", 4, state ? ASSERT_LINE : CLEAR_LINE);
71   cputag_set_input_line(device->machine, "maincpu", 4, state ? ASSERT_LINE : CLEAR_LINE);
7272}
73
7374static const ptm6840_interface cchasm_6840_intf =
7475{
7576   CCHASM_68K_CLOCK/10,
76   { 0,CCHASM_68K_CLOCK/10,0 },
77   { NULL, NULL, NULL },
78   cchasm_6840_irq
77   { 0, CCHASM_68K_CLOCK / 10, 0 },
78   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
79   DEVCB_LINE(cchasm_6840_irq)
7980};
8081
8182/*************************************
r4939r4940
130131   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Test 3, not used in cchasm */
131132INPUT_PORTS_END
132133
133static MACHINE_START( cchasm )
134{
135   ptm6840_config(machine, 0, &cchasm_6840_intf );
136}
137134
138
139
140135/*************************************
141136 *
142137 *  CPU config
r4939r4940
170165
171166   MDRV_Z80CTC_ADD("ctc", 3584229 /* same as "audiocpu" */, cchasm_ctc_intf)
172167
173   MDRV_MACHINE_START(cchasm)
174
175168   /* video hardware */
176169   MDRV_SCREEN_ADD("screen", VECTOR)
177170   MDRV_SCREEN_REFRESH_RATE(40)
r4939r4940
197190
198191   MDRV_SOUND_ADD("dac2", DAC, 0)
199192   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
193
194   /* 6840 PTM */
195   MDRV_PTM6840_ADD("6840ptm", cchasm_6840_intf)
200196MACHINE_DRIVER_END
201197
202198
src/mame/drivers/suprgolf.c
r4939r4940
1/***************************************************************************
1/************************************************************************************
22
3 Super Golf
3 Super Crowns Golf
44 preliminary WIP driver
5 by Tomasz Slanina
5 by Tomasz Slanina & Angelo Salese
66
7 maybe vidram banking
8 plenty of things unknown still
7 TODO:
8 - remove the patch and understand what needs to be modified for the gfxs, game
9   doesn't crash anymore;
10 - inputs not fully understood, sometimes analog inputs gets stuck;
911
10 sometimes extra bits are written to bank registers..
12 Notes:
13 - The game uses special control panel with 1 golf club shaped device to select shot
14 strength (0,1,2,3), and 6 buttons (direction L&R, select angle of club head, club
15 select, shot, and power to use items). -YO
1116
12 its a z80 game.. i wonder if there is a palette or it should have proms
13               -- the rest of the hardware makes me fear so
17************************************************************************************/
1418
15***************************************************************************/
16
1719#include "driver.h"
1820#include "cpu/z80/z80.h"
1921#include "sound/2203intf.h"
r4939r4940
2123
2224static tilemap *suprgolf_tilemap;
2325static UINT8 *suprgolf_bg_vram;
24static UINT8 *suprgolf_bg_pen;
26static UINT16 *suprgolf_bg_fb,*suprgolf_fg_fb;
2527static int suprgolf_rom_bank;
2628static UINT8 suprgolf_bg_bank;
27static UINT8 suprgolf_vreg;
29static UINT8 suprgolf_vreg_bank;
2830static UINT8 msm5205next,msm_nmi_mask;
31static UINT8 suprgolf_vreg_pen;
2932
3033static TILE_GET_INFO( get_tile_info )
3134{
r4939r4940
3942      0);
4043}
4144
42static READ8_HANDLER( rom_bank_select_r )
43{
44    return suprgolf_rom_bank;
45}
46
47static WRITE8_HANDLER( rom_bank_select_w )
48{
49   UINT8 *region_base = memory_region(space->machine, "user1");
50
51   suprgolf_rom_bank = data;
52
53   //popmessage("%08x %02x",((data & 0x3f) * 0x4000),data);
54
55   mame_printf_debug("ROM_BANK 0x8000 - %X @%X\n",data,cpu_get_previouspc(space->cpu));
56   memory_set_bankptr(space->machine, 2, region_base + (data&0x3f ) * 0x4000);
57
58   msm_nmi_mask = data & 0x40;
59   flip_screen_set(space->machine, data & 0x80);
60}
61
62static WRITE8_HANDLER( rom2_bank_select_w )
63{
64   UINT8 *region_base = memory_region(space->machine, "user2");
65   mame_printf_debug("ROM_BANK 0x4000 - %X @%X\n",data,cpu_get_previouspc(space->cpu));
66//  if(data == 0) data = 1; //test hack
67   memory_set_bankptr(space->machine, 1, region_base + (data&0x0f ) * 0x4000);
68
69   if(data & 0xf0)
70      printf("Rom bank select 2 with data %02x activated\n",data);
71}
72
73static MACHINE_RESET( suprgolf )
74{
75
76}
77
7845static VIDEO_START( suprgolf )
7946{
8047   suprgolf_tilemap = tilemap_create( machine, get_tile_info,tilemap_scan_rows,8,8,32,32 );
8148   paletteram = auto_alloc_array(machine, UINT8, 0x1000);
8249   suprgolf_bg_vram = auto_alloc_array(machine, UINT8, 0x2000*0x20);
83   suprgolf_bg_pen = auto_alloc_array(machine, UINT8, 0x2000*0x20);
50   suprgolf_bg_fb = auto_alloc_array(machine, UINT16, 0x2000*0x20);
51   suprgolf_fg_fb = auto_alloc_array(machine, UINT16, 0x2000*0x20);
8452
8553   tilemap_set_transparent_pen(suprgolf_tilemap,15);
8654}
8755
88/* TODO: fix this.*/
89static void bg_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,UINT8 starting_offs)
56static VIDEO_UPDATE( suprgolf )
9057{
91   int x,y,trans;
92   UINT32 count;
58   int x,y,count,color;
59   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
9360
94   count = starting_offs<<16;
95   trans = starting_offs;
96
97   for(y=0;y<256;y++)
9861   {
99      for(x=0;x<512;x+=2)
100      {
101         UINT16 color;
62      count = 0;
10263
103         color = ((suprgolf_bg_pen[count] & 0xff)<<4) | ((suprgolf_bg_vram[count] & 0xf0)>>4);
104         //color+= ((suprgolf_bg_pen[count+0x10000])<<4);
105         //if((x)<video_screen_get_visible_area(machine)->max_x && ((y)+0)<video_screen_get_visible_area(machine)->max_y)
106         if(x+1 < 256)
64      for(y=0;y<256;y++)
65      {
66         for(x=0;x<512;x++)
10767         {
108            if(trans)
109            {
110               if((suprgolf_bg_vram[count] & 0xf0) != 0xf0)
111                  *BITMAP_ADDR32(bitmap, y, x+1) = machine->pens[(color & 0x7ff)];
112            }
113            else
114               *BITMAP_ADDR32(bitmap, y, x+1) = machine->pens[(color & 0x7ff)];
68            color = suprgolf_bg_fb[count];
69
70            if(x <= cliprect->max_x && y <= cliprect->max_y)
71               *BITMAP_ADDR16(bitmap, y, x) = screen->machine->pens[(color & 0x7ff)];
72
73            count++;
11574         }
75      }
76   }
11677
117         color = ((suprgolf_bg_pen[count] & 0xff)<<4) | (suprgolf_bg_vram[count] & 0x0f);
118         //color+= ((suprgolf_bg_pen[count+0x10000])<<4);
78   {
79      count = 0;
11980
120         //if((x+1)<video_screen_get_visible_area(screen)->max_x && ((y)+0)<video_screen_get_visible_area(screen)->max_y)
121         if(x < 256)
81      for(y=0;y<256;y++)
82      {
83         for(x=0;x<512;x++)
12284         {
123            if(trans)
124            {
125               if((suprgolf_bg_vram[count] & 0x0f) != 0x0f)
126                  *BITMAP_ADDR32(bitmap, y, x) = machine->pens[(color & 0x7ff)];
127            }
128            else
129               *BITMAP_ADDR32(bitmap, y, x) = machine->pens[(color & 0x7ff)];
130         }
85            color = suprgolf_fg_fb[count];
13186
132         count++;
87            if(((suprgolf_fg_fb[count] & 0x0f) != 0x0f) && (x <= cliprect->max_x && y <= cliprect->max_y))
88               *BITMAP_ADDR16(bitmap, y, x) = screen->machine->pens[(color & 0x7ff)];
89
90            count++;
91         }
13392      }
13493   }
135}
13694
137static VIDEO_UPDATE( suprgolf )
138{
139   bg_draw(screen->machine,bitmap,cliprect,0);
140   //bg_draw(screen->machine,bitmap,cliprect,1);
141   bg_draw(screen->machine,bitmap,cliprect,2); //this probably should be putted over the fg tilemap too.
142
14395   tilemap_draw(bitmap,cliprect,suprgolf_tilemap,0,0);
96
14497   return 0;
14598}
14699
r4939r4940
163116      offset>>=1;
164117      datax=paletteram[offset*2]+256*paletteram[offset*2+1];
165118
166      b=(datax & 0x8000) ? 0 : ((datax)&0x001f)>>0;
167      g=(datax & 0x8000) ? 0 : ((datax)&0x03e0)>>5;
168      r=(datax & 0x8000) ? 0 : ((datax)&0x7c00)>>10;
119      b = (datax & 0x8000) ? 0 : ((datax)&0x001f)>>0;
120      g = (datax & 0x8000) ? 0 : ((datax)&0x03e0)>>5;
121      r = (datax & 0x8000) ? 0 : ((datax)&0x7c00)>>10;
169122
170123      palette_set_color_rgb(space->machine, offset, pal5bit(r), pal5bit(g), pal5bit(b));
171124   }
r4939r4940
178131
179132static READ8_HANDLER( suprgolf_vregs_r )
180133{
181   return suprgolf_vreg;
134   return suprgolf_vreg_bank;
182135}
183136
137static UINT8 suprgolf_bg_vreg_test;
138
184139static WRITE8_HANDLER( suprgolf_vregs_w )
185140{
186141   //bits 0,1,2 and probably 3 controls the background vram banking
187   suprgolf_vreg = data;
142   suprgolf_vreg_bank = data;
188143   palette_switch = (data & 0x80);
189144   suprgolf_bg_bank = (data & 0x1f);
190145
146   suprgolf_bg_vreg_test = data & 0x20;
147
191148   //if(data & 0x60)
192149   //  printf("Video regs with data %02x activated\n",data);
193150}
194151
195static UINT8 pen;
196
197152static READ8_HANDLER( suprgolf_bg_vram_r )
198153{
199154   return suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000];
r4939r4940
201156
202157static WRITE8_HANDLER( suprgolf_bg_vram_w )
203158{
204   suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] = data;
205   suprgolf_bg_pen[offset+suprgolf_bg_bank*0x2000] = data ? pen : 0;
159   static UINT8 hi_nibble,lo_nibble;
160   static UINT8 hi_dirty_dot,lo_dirty_dot; // helpers
161
162   hi_nibble = data & 0xf0;
163   lo_nibble = data & 0x0f;
164   hi_dirty_dot = 1;
165   lo_dirty_dot = 1;
166
167   if(hi_nibble == 0xf0)
168   {
169      hi_nibble = suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] & 0xf0;
170      if(!(suprgolf_vreg_pen & 0x80) && (!(suprgolf_bg_bank & 0x10)))
171         hi_dirty_dot = 0;
172   }
173
174   if(lo_nibble == 0x0f)
175   {
176      lo_nibble = suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] & 0x0f;
177      if(!(suprgolf_vreg_pen & 0x80) && (!(suprgolf_bg_bank & 0x10)))
178         lo_dirty_dot = 0;
179   }
180
181   if(suprgolf_vreg_pen & 0x80 || suprgolf_bg_bank & 0x10)
182      suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] = data;
183   else
184      suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] = hi_nibble|lo_nibble;
185
186   if(suprgolf_bg_bank & 0x10)
187   {
188      if(hi_dirty_dot)
189         suprgolf_fg_fb[(offset+(suprgolf_bg_bank & 0x0f)*0x2000)*2+1] = (suprgolf_vreg_pen & 0x7f)<<4 | ((suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] & 0xf0)>>4);
190      if(lo_dirty_dot)
191         suprgolf_fg_fb[(offset+(suprgolf_bg_bank & 0x0f)*0x2000)*2+0] = (suprgolf_vreg_pen & 0x7f)<<4 | ((suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] & 0x0f)>>0);
192   }
193   else
194   {
195      if(hi_dirty_dot)
196         suprgolf_bg_fb[(offset+(suprgolf_bg_bank & 0x0f)*0x2000)*2+1] = (suprgolf_vreg_pen & 0x7f)<<4 | ((suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] & 0xf0)>>4);
197      if(lo_dirty_dot)
198         suprgolf_bg_fb[(offset+(suprgolf_bg_bank & 0x0f)*0x2000)*2+0] = (suprgolf_vreg_pen & 0x7f)<<4 | ((suprgolf_bg_vram[offset+suprgolf_bg_bank*0x2000] & 0x0f)>>0);
199   }
206200}
207201
208/* maybe bit 7 isn't actually for the pen? */
209202static WRITE8_HANDLER( suprgolf_pen_w )
210203{
211   pen = data;
204   suprgolf_vreg_pen = data;
212205}
213206
214207static WRITE8_HANDLER( adpcm_data_w )
r4939r4940
216209   msm5205next = data;
217210}
218211
212static READ8_HANDLER( rom_bank_select_r )
213{
214    return suprgolf_rom_bank;
215}
216
217static WRITE8_HANDLER( rom_bank_select_w )
218{
219   UINT8 *region_base = memory_region(space->machine, "user1");
220
221   suprgolf_rom_bank = data;
222
223   //popmessage("%08x %02x",((data & 0x3f) * 0x4000),data);
224
225   mame_printf_debug("ROM_BANK 0x8000 - %X @%X\n",data,cpu_get_previouspc(space->cpu));
226   memory_set_bankptr(space->machine, 2, region_base + (data&0x3f ) * 0x4000);
227
228   msm_nmi_mask = data & 0x40;
229   flip_screen_set(space->machine, data & 0x80);
230}
231
232static WRITE8_HANDLER( rom2_bank_select_w )
233{
234   UINT8 *region_base = memory_region(space->machine, "user2");
235   mame_printf_debug("ROM_BANK 0x4000 - %X @%X\n",data,cpu_get_previouspc(space->cpu));
236//  if(data == 0) data = 1; //test hack
237   memory_set_bankptr(space->machine, 1, region_base + (data&0x0f ) * 0x4000);
238
239   if(data & 0xf0)
240      printf("Rom bank select 2 with data %02x activated\n",data);
241}
242
243static READ8_HANDLER( pedal_extra_bits_r )
244{
245   static UINT8 p1_pedal_hi,p1_sht_sw,p2_pedal_hi,p2_sht_sw;
246
247   /* TODO: check this */
248   p1_pedal_hi = (input_port_read(space->machine, "P1_PEDAL") & 0x10)>>3;
249   p1_sht_sw = (input_port_read(space->machine, "P1_PEDAL") & 0x80)>>7;
250   p2_pedal_hi = (input_port_read(space->machine, "P2_PEDAL") & 0x10)<<1;
251   p2_sht_sw = (input_port_read(space->machine, "P2_PEDAL") & 0x80)>>3;
252
253   return p1_pedal_hi | p1_sht_sw | p2_pedal_hi | p2_sht_sw;
254}
255
256static READ8_HANDLER( p1_r )
257{
258   return (input_port_read(space->machine, "P1") & 0xf0) | ((input_port_read(space->machine, "P1_PEDAL") & 0xf));
259}
260
261static READ8_HANDLER( p2_r )
262{
263   return (input_port_read(space->machine, "P2") & 0xf0) | ((input_port_read(space->machine, "P2_PEDAL") & 0xf));
264}
265
219266static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
220267   AM_RANGE(0x0000, 0x3fff) AM_ROM
221268   AM_RANGE(0x4000, 0x7fff) AM_ROMBANK(1)
r4939r4940
227274   AM_RANGE(0xf800, 0xffff) AM_RAM
228275ADDRESS_MAP_END
229276
277
230278static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 )
231279   ADDRESS_MAP_GLOBAL_MASK(0xff)
232   AM_RANGE(0x00, 0x00) AM_READ_PORT("P1")
233   AM_RANGE(0x01, 0x01) AM_READ_PORT("P2")
234   AM_RANGE(0x02, 0x02) AM_READ_PORT("IN2") // ??
280   AM_RANGE(0x00, 0x00) AM_READ(p1_r)
281   AM_RANGE(0x01, 0x01) AM_READ(p2_r)
282   AM_RANGE(0x02, 0x02) AM_READ(pedal_extra_bits_r)
235283//  AM_RANGE(0x03, 0x03)
236284   AM_RANGE(0x04, 0x04) AM_READ_PORT("SYSTEM")
237285   AM_RANGE(0x05, 0x05) AM_READ(rom_bank_select_r) AM_WRITE(rom_bank_select_w)
238   AM_RANGE(0x06, 0x06) AM_READWRITE( suprgolf_vregs_r,suprgolf_vregs_w ) // game locks up or crashes? if this doesn't return right values?
286   AM_RANGE(0x06, 0x06) AM_READWRITE( suprgolf_vregs_r,suprgolf_vregs_w )
239287//  AM_RANGE(0x07, 0x07)
240288   AM_RANGE(0x08, 0x09) AM_DEVREADWRITE("ym", ym2203_r, ym2203_w)
241289   AM_RANGE(0x0c, 0x0c) AM_WRITE(adpcm_data_w)
r4939r4940
243291
244292static INPUT_PORTS_START( suprgolf )
245293   PORT_START("P1")
246   PORT_DIPNAME( 0x01, 0x01, "0" ) //USED!
247   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
248   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
249   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
250   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
251   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
252   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
253   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
254   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
255   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
256   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
257   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
294   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_SPECIAL ) /* low port of P1 Pedal */
258295   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)       /* D.L */
259296   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)       /* D.R */
260   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)         /* CNT */
297   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)         /* CNT - shot switch */
261298   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)         /* SEL */
262299
300   PORT_START("P1_PEDAL")
301   PORT_BIT( 0x1f, 0x00, IPT_PEDAL ) PORT_MINMAX(0x00,0x1f) PORT_SENSITIVITY(5) PORT_KEYDELTA(5) PORT_PLAYER(1)
302   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)         /* release power? */
303
263304   PORT_START("P2")
264   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN ) //USED!
265   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
266   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
267   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
305   PORT_BIT( 0x0f, IP_ACTIVE_LOW, IPT_SPECIAL ) /* low port of P2 Pedal */
268306   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)       /* D.L */
269307   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)       /* D.R */
270   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)         /* CNT */
308   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)         /* CNT - shot switch */
271309   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)         /* SEL */
272310
273   PORT_START("IN2")
274   PORT_DIPNAME( 0x01, 0x01, "2" )
275   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
276   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
277   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
278   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
279   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
280   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
281   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
282   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
283   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
284   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
285   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
286   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
287   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
288   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
289   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
290   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
291   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
292   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
293   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
294   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
295   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
296   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
297   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
311   PORT_START("P2_PEDAL")
312   PORT_BIT( 0x1f, 0x00, IPT_PEDAL ) PORT_MINMAX(0x00,0x1f) PORT_SENSITIVITY(5) PORT_KEYDELTA(5) PORT_PLAYER(2)
313   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)         /* release power? */
298314
299315   PORT_START("SYSTEM")
300316   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )                        /* 1P */
r4939r4940
310326   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
311327   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
312328
313   PORT_START("IN4")
314   PORT_DIPNAME( 0x01, 0x01, "4" )
315   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
316   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
317   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
318   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
319   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
320   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
321   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
322   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
323   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
324   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
325   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
326   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
327   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
328   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
329   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
330   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
331   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
332   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
333   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
334   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
335   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
336   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
337   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
338
339329   PORT_START("DSW0")
340   PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) )
330   PORT_DIPNAME( 0x03, 0x01, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:1,2")
341331   PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )
342332   PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) )
343333   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
344334   PORT_DIPSETTING(    0x00, DEF_STR( 1C_5C ) )
345   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
346   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
347   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
348   PORT_DIPNAME( 0x08, 0x08, "Tutorial" )
335   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW1:3")
336   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
337   PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
338   /* According to the manual, 4 and 5 are for Indoor Practice tries, but doesn't suit well...different version? */
339   PORT_DIPNAME( 0x08, 0x08, "Indoor Practice" )  PORT_DIPLOCATION("SW1:4")
349340   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
350341   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
351   PORT_DIPNAME( 0x30, 0x30, "Number of Balls" )
342   PORT_DIPNAME( 0x30, 0x30, "Number of Balls" ) PORT_DIPLOCATION("SW1:5,6")
352343   PORT_DIPSETTING(    0x00, "1" )
353344   PORT_DIPSETTING(    0x10, "2" )
354345   PORT_DIPSETTING(    0x30, "3" )
355346   PORT_DIPSETTING(    0x20, "4" )
356   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
357   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
358   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
359   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )
347   PORT_DIPUNUSED_DIPLOC( 0x40, 0x00, "SW1:7" )
348   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SW1:8")
360349   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
361350   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
362351
363352   PORT_START("DSW1")
364   PORT_SERVICE( 0x01, IP_ACTIVE_LOW )
365   PORT_DIPNAME( 0x02, 0x02, "DSW1" )
366   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
367   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
368   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
369   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
370   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
371   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Flip_Screen ) )
353   PORT_SERVICE( 0x01, IP_ACTIVE_LOW ) PORT_DIPLOCATION("SW2:1")
354   PORT_DIPNAME( 0x06, 0x00, "Percentage of wind over 10m/s" ) PORT_DIPLOCATION("SW2:2,3")
355   PORT_DIPSETTING(    0x00, "30%" )
356   PORT_DIPSETTING(    0x04, "40%" )
357   PORT_DIPSETTING(    0x02, "50%" )
358   PORT_DIPSETTING(    0x06, "60%" )
359   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW2:4")
372360   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
373361   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
374   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
375   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
376   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
377   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
378   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
379   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
380   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
381   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
382   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
383   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
384   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
385   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
362   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SW2:5")
363   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
364   PORT_DIPSETTING(    0x10, DEF_STR( Yes ) )
365   PORT_DIPUNUSED_DIPLOC( 0x20, 0x00, "SW2:6" )
366   PORT_DIPUNUSED_DIPLOC( 0x40, 0x00, "SW2:7" )
367   PORT_DIPUNUSED_DIPLOC( 0x80, 0x00, "SW2:8" )
386368INPUT_PORTS_END
387369
388370static WRITE8_DEVICE_HANDLER( suprgolf_writeA )
r4939r4940
453435   GFXDECODE_ENTRY( "gfx1", 0, gfxlayout,   0, 0x80 )
454436GFXDECODE_END
455437
438static MACHINE_RESET( suprgolf )
439{
440   msm_nmi_mask = 0;
441}
442
456443static MACHINE_DRIVER_START( suprgolf )
457444   /* basic machine hardware */
458445   MDRV_CPU_ADD("maincpu", Z80,4000000) /* guess */
r4939r4940
469456   MDRV_SCREEN_ADD("screen", RASTER)
470457   MDRV_SCREEN_REFRESH_RATE(60)
471458   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
472   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
459   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
473460   MDRV_SCREEN_SIZE(256, 256)
474461   MDRV_SCREEN_VISIBLE_AREA(0, 255, 0, 191)
475462
476463   MDRV_GFXDECODE(suprgolf)
477   MDRV_PALETTE_LENGTH(0x1000)
464   MDRV_PALETTE_LENGTH(0x800)
478465
479466   /* sound hardware */
480467   MDRV_SPEAKER_STANDARD_MONO("mono")
r4939r4940
543530
544531   ROM_REGION( 0x70000, "gfx1", ROMREGION_DISPOSE )
545532   ROM_LOAD( "cg18.3k",0x60000, 0x10000, CRC(36edd88e) SHA1(374c95721198a88831d6f7e0b71d05e2f8465271) )
546   ROM_LOAD( "cg17.5f",0x50000, 0x10000, CRC(d27f87b5) SHA1(5b2927e89615589540e3853593aeff517584b6a0))
533   ROM_LOAD( "cg17.5f",0x50000, 0x10000, CRC(d27f87b5) SHA1(5b2927e89615589540e3853593aeff517584b6a0) )
547534   ROM_LOAD( "cg16.5g",0x40000, 0x10000, CRC(0498aa2e) SHA1(988965c3a584dac17ad8c7e504fa1f1e49775611) )
548535   ROM_LOAD( "cg15.5j",0x30000, 0x10000, CRC(0fb88270) SHA1(d85a7f1bc5b3c4b13bbd887cea4c055541cbb737) )
549536   ROM_LOAD( "cg14.5k",0x20000, 0x10000, CRC(ca12e01d) SHA1(9c627fb527c8966e16dc6bdb99ec0b9728b5c5f9) )
r4939r4940
551538   ROM_LOAD( "cg12.6k",0x00000, 0x10000, CRC(5707b3d5) SHA1(9102a40fefb6426f2cd9d92d66fdc77e078e3f4c) )
552539ROM_END
553540
554GAME( 1989, suprgolf, 0, suprgolf,  suprgolf,  0, ROT0, "Nasco", "Super Crowns Golf (Japan)", GAME_NOT_WORKING | GAME_NO_COCKTAIL )
541static DRIVER_INIT( suprgolf )
542{
543   UINT8 *ROM = memory_region(machine, "user2");
544
545   ROM[0x74f4-0x4000] = 0x00;
546   ROM[0x74f5-0x4000] = 0x00;
547}
548
549GAME( 1989, suprgolf, 0, suprgolf,  suprgolf,  suprgolf, ROT0, "Nasco", "Super Crowns Golf (Japan)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_COCKTAIL )
src/mame/drivers/toaplan2.c
r4939r4940
298298static WRITE16_HANDLER( batsugun_share2_w );
299299#endif
300300
301static const device_config *sub_cpu = NULL;
302
301303/***************************************************************************
302304  Initialisation handlers
303305***************************************************************************/
304306
305307static void toaplan2_reset(const device_config *device)
306308{
307   if (device->machine->cpu[1] != NULL)
308      cpu_set_input_line(device->machine->cpu[1], INPUT_LINE_RESET, PULSE_LINE);
309   if (sub_cpu != NULL)
310      cpu_set_input_line(sub_cpu, INPUT_LINE_RESET, PULSE_LINE);
309311}
310312
311313static MACHINE_RESET( toaplan2 )
r4939r4940
368370static DRIVER_INIT( T2_Z80 )      /* init_t2_Z80(); */
369371{
370372   toaplan2_sub_cpu = CPU_2_Z80;
373   sub_cpu = cputag_get_cpu(machine, "audiocpu");
371374   register_state_save(machine);
372375}
373376
374377static DRIVER_INIT( T2_Z180 )
375378{
376379   toaplan2_sub_cpu = CPU_2_HD647180;
380   sub_cpu = cputag_get_cpu(machine, "mcu");
377381   register_state_save(machine);
378382}
379383
380384static DRIVER_INIT( T2_V25 )
381385{
382386   toaplan2_sub_cpu = CPU_2_V25;
387   if (cputag_get_cpu(machine, "mcu") != NULL)
388      sub_cpu = cputag_get_cpu(machine, "mcu");
389   else if (cputag_get_cpu(machine, "audiocpu") != NULL)
390      sub_cpu = cputag_get_cpu(machine, "audiocpu");
383391   register_state_save(machine);
384392}
385393
r4939r4940
392400static DRIVER_INIT( fixeight )
393401{
394402   #if USE_V25
395
403   sub_cpu = cputag_get_cpu(machine, "audiocpu");
396404   #else
397405   memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x28f002, 0x28fbff, 0, 0, (read16_space_func)SMH_BANK(2), (write16_space_func)SMH_BANK(2) );
398406   memory_set_bankptr(machine, 2, fixeight_sec_cpu_mem);
r4939r4940
490498   }
491499
492500   toaplan2_sub_cpu = CPU_2_Z80;
501   sub_cpu = cputag_get_cpu(machine, "audiocpu");
493502   register_state_save(machine);
494503}
495504
r4939r4940
497506{
498507   raizing_sndirq_line = 4;
499508   toaplan2_sub_cpu = CPU_2_Z80;
509   sub_cpu = cputag_get_cpu(machine, "audiocpu");
500510   register_state_save(machine);
501511}
502512
r4939r4940
505515   bbakraid_unlimited_ver = 0;
506516   raizing_sndirq_line = 2;
507517   toaplan2_sub_cpu = CPU_2_Z80;
518   sub_cpu = cputag_get_cpu(machine, "audiocpu");
508519   register_state_save(machine);
509520}
510521
r4939r4940
513524   bbakraid_unlimited_ver = 1;
514525   raizing_sndirq_line = 2;
515526   toaplan2_sub_cpu = CPU_2_Z80;
527   sub_cpu = cputag_get_cpu(machine, "audiocpu");
516528   register_state_save(machine);
517529}
518530
r4939r4940
617629
618630      #if USE_V25
619631      /* only the ram-based V25 based games access the following bits */
620      //cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_RESET, (data & 0x0020) ? CLEAR_LINE : ASSERT_LINE );
621      cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_HALT,  (data & 0x0010) ? CLEAR_LINE : ASSERT_LINE);
632      //cpu_set_input_line(sub_cpu, INPUT_LINE_RESET, (data & 0x0020) ? CLEAR_LINE : ASSERT_LINE );
633      cpu_set_input_line(sub_cpu, INPUT_LINE_HALT,  (data & 0x0010) ? CLEAR_LINE : ASSERT_LINE);
622634      #endif
623635
624636   }
r4939r4940
10161028   if (ACCESSING_BITS_0_7)
10171029   {
10181030      soundlatch_w(space, offset, data & 0xff);
1019      cpu_set_input_line(space->machine->cpu[1], 0, HOLD_LINE);
1031      cpu_set_input_line(sub_cpu, 0, HOLD_LINE);
10201032   }
10211033}
10221034
r4939r4940
11311143   if (ACCESSING_BITS_0_7)
11321144   {
11331145      soundlatch_w(space, offset, data & 0xff);
1134      cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_NMI, ASSERT_LINE);
1146      cpu_set_input_line(sub_cpu, INPUT_LINE_NMI, ASSERT_LINE);
11351147   }
11361148}
11371149
r4939r4940
11411153   if (ACCESSING_BITS_0_7)
11421154   {
11431155      soundlatch2_w(space, offset, data & 0xff);
1144      cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_NMI, ASSERT_LINE);
1156      cpu_set_input_line(sub_cpu, INPUT_LINE_NMI, ASSERT_LINE);
11451157   }
11461158}
11471159
r4939r4940
11701182
11711183static WRITE8_HANDLER( raizing_clear_nmi_w )
11721184{
1173   cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_NMI, CLEAR_LINE);
1185   cpu_set_input_line(sub_cpu, INPUT_LINE_NMI, CLEAR_LINE);
11741186}
11751187
11761188
r4939r4940
14951507WRITE16_HANDLER( fixeight_subcpu_ctrl )
14961508{
14971509   /* 0x18 used */
1498   cpu_set_input_line(space->machine->cpu[1], INPUT_LINE_HALT,  (data & 0x0010) ? CLEAR_LINE : ASSERT_LINE);
1510   cpu_set_input_line(sub_cpu, INPUT_LINE_HALT,  (data & 0x0010) ? CLEAR_LINE : ASSERT_LINE);
14991511}
15001512#endif
15011513
r4939r4940
33423354
33433355static void irqhandler(const device_config *device, int linestate)
33443356{
3345   cpu_set_input_line(device->machine->cpu[1],0,linestate);
3357   if (sub_cpu != NULL)      // wouldn't tekipaki have problem without this? "mcu" is not generally added
3358      cpu_set_input_line(sub_cpu, 0, linestate);
33463359}
33473360
33483361static const ym3812_interface ym3812_config =
r4939r4940
38323845static MACHINE_RESET(batsugun)
38333846{
38343847   #if USE_V25
3835   cpu_set_input_line(machine->cpu[1], INPUT_LINE_HALT, ASSERT_LINE);
3848   cpu_set_input_line(sub_cpu, INPUT_LINE_HALT, ASSERT_LINE);
38363849   #endif
38373850}
38383851
r4939r4940
52585271GAME( 1998, batridja, batrid,   batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Japan) (Mon Dec 22 1997)", GAME_SUPPORTS_SAVE )
52595272
52605273// Battle Bakraid
5261// the 'unlimited' version is a newer revisino of the code.
5274// the 'unlimited' version is a newer revision of the code.
52625275GAME( 1999, bkraidu,  0,       bbakraid, bbakraid, bbakradu, ROT270, "Eighting", "Battle Bakraid - Unlimited Version (U.S.A.) (Tue Jun 8 1999)", GAME_SUPPORTS_SAVE )
52635276GAME( 1999, bkraiduj, bkraidu, bbakraid, bbakraid, bbakradu, ROT270, "Eighting", "Battle Bakraid - Unlimited Version (Japan) (Tue Jun 8 1999)", GAME_SUPPORTS_SAVE )
52645277// older revision of the code
src/mame/drivers/dmndrby.c
r4939r4940
489489/*Main Z80 is IM 0,HW-latched irqs. */
490490static INTERRUPT_GEN( dderby_irq )
491491{
492   cpu_set_input_line_and_vector(cputag_get_cpu(device->machine, "maincpu"), 0, HOLD_LINE, 0xd7); /* RST 10h */
492   cputag_set_input_line_and_vector(device->machine, "maincpu", 0, HOLD_LINE, 0xd7); /* RST 10h */
493493}
494494
495495static INTERRUPT_GEN( dderby_timer_irq )
496496{
497   cpu_set_input_line_and_vector(cputag_get_cpu(device->machine, "maincpu"), 0, HOLD_LINE, 0xcf); /* RST 08h */
497   cputag_set_input_line_and_vector(device->machine, "maincpu", 0, HOLD_LINE, 0xcf); /* RST 08h */
498498}
499499
500500static MACHINE_DRIVER_START( dderby )
src/mame/drivers/tmaster.c
r4939r4940
10681068   ROM_LOAD( "tm5k_sound.u8", 0x00000, 0x100000, CRC(c6070a60) SHA1(2dc20bf2217a36374b5a691133ad43f53dbe29ca) ) /* Mask rom labeled 5341-15951-03 U8 VIDEO IMAGE */
10691069ROM_END
10701070
1071ROM_START( tm5kca ) /* California only version */
1072   ROM_REGION( 0x200000, "maincpu", 0 ) // 68000 Code
1073   ROM_LOAD16_BYTE( "tm5kca_v7_10.u51", 0x000000, 0x100000, CRC(7c03708f) SHA1(e1f8198bc03c1f9d2a00662b589fd66fdcc7a2de) ) /* TOUCHMASTER 5000 U51 CALIFORNIA 7.10 (CA. 10-9-98) (tan label) */
1074   ROM_LOAD16_BYTE( "tm5kca_v7_10.u52", 0x000001, 0x100000, CRC(f1413295) SHA1(ad6b57c590bdae063b0e4a1abcb3b13ee52cd6db) ) /* TOUCHMASTER 5000 U52 CALIFORNIA 7.10 (CA. 10-9-98) (tan label) */
1075
1076   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1077   ROM_LOAD16_BYTE( "tm5k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* Mask rom labeled 5341-15951-07 U38 VIDEO IMAGE */
1078   ROM_LOAD16_BYTE( "tm5k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* Mask rom labeled 5341-15951-06 U36 VIDEO IMAGE */
1079   ROM_LOAD16_BYTE( "tm5k_graphic.u39", 0x200000, 0x100000, CRC(1349fdc7) SHA1(5118983be584455320f0d6006133f38e6a8ee0d8) ) /* Mask rom labeled 5341-15951-05 U39 VIDEO IMAGE */
1080   ROM_LOAD16_BYTE( "tm5k_graphic.u37", 0x200001, 0x100000, CRC(8bcc376c) SHA1(0588f6f96090b26a3ce0eb3a933a5cc9d8ce742d) ) /* Mask rom labeled 5341-15951-04 U37 VIDEO IMAGE */
1081   ROM_LOAD16_BYTE( "tm5k_graphic.u41", 0x400000, 0x100000, CRC(c8717fef) SHA1(fbd13321db0f35b7bdf207468f28792a7666bb2e) ) /* Mask rom labeled 5341-15951-09 U41 VIDEO IMAGE */
1082   ROM_LOAD16_BYTE( "tm5k_graphic.u40", 0x400001, 0x100000, CRC(cff3f962) SHA1(2389d94ffa0eaf2d2f62315822273db031eea033) ) /* Mask rom labeled 5341-15951-08 U40 VIDEO IMAGE */
1083
1084   ROM_REGION( 0x100000, "oki", 0 ) // Samples
1085   ROM_LOAD( "tm5k_sound.u8", 0x00000, 0x100000, CRC(c6070a60) SHA1(2dc20bf2217a36374b5a691133ad43f53dbe29ca) ) /* Mask rom labeled 5341-15951-03 U8 VIDEO IMAGE */
1086ROM_END
1087
10711088/***************************************************************************
10721089
10731090Touchmaster 7000
r4939r4940
11331150   ROM_LOAD( "tm7k_sound.u8", 0x00000, 0x100000, CRC(c6070a60) SHA1(2dc20bf2217a36374b5a691133ad43f53dbe29ca) ) /* Labeled SOUND U8  8.0 (orange label) */
11341151ROM_END
11351152
1153ROM_START( tm7keval ) /* FREEPLAY ONLY / NOT FOR RELEASE / FOR EVALUATION ONLY */
1154   ROM_REGION( 0x200000, "maincpu", 0 ) // 68000 Code
1155   ROM_LOAD16_BYTE( "tm7k_v81x.u51", 0x000000, 0x100000, CRC(57c88287) SHA1(1008bbcd137ede321be4cc2ad22e3982d880471b) ) /* TOUCHMASTER 7000 U51 8.1X (ASI Standard 03/08/99) (white label) */
1156   ROM_LOAD16_BYTE( "tm7k_v81x.u52", 0x000001, 0x100000, CRC(e45d69bb) SHA1(9e8a42924a9cd573cbd2f3164d0fb468eee7ff51) ) /* TOUCHMASTER 7000 U52 8.1X (ASI Standard 03/08/99) (white label) */
1157
1158   ROM_REGION( 0x600000, "gfx1", 0 )   // Blitter gfx
1159   ROM_LOAD16_BYTE( "tm7k_graphic.u38", 0x000000, 0x100000, CRC(93038e7c) SHA1(448f69bf51ac992f6b35b471cba9675c67984cd7) ) /* TOUCHMASTER EDCE V8.X U38 (white label) */
1160   ROM_LOAD16_BYTE( "tm7k_graphic.u36", 0x000001, 0x100000, CRC(5453a44a) SHA1(094439a56336ca933b0b7ede8c057546d1d490b2) ) /* TOUCHMASTER DB7F V8.X U36 (white label) */
1161   ROM_LOAD16_BYTE( "tm7k_graphic.u39", 0x200000, 0x100000, CRC(26af8da8) SHA1(02555b1597a4962f1fd0c3ffc89e5c8338aa3085) ) /* TOUCHMASTER 2BB6 V8.X U39 (white label) */
1162   ROM_LOAD16_BYTE( "tm7k_graphic.u37", 0x200001, 0x100000, CRC(9a705043) SHA1(cffb31859544c1c4082be78b3bca5ad9cd0d2a45) ) /* TOUCHMASTER 7461 V8.X U37 (white label) */
1163   ROM_LOAD16_BYTE( "tm7k_v8x.u41",     0x400000, 0x100000, CRC(d15757f0) SHA1(d09a83dc00812a4208d5684e8cfba1f5d1e3f097) ) /* TOUCHMASTER 335E V8.X U41 (white label) */
1164   ROM_LOAD16_BYTE( "tm7k_v8x.u40",     0x400001, 0x100000, CRC(d3596f63) SHA1(a2474bc1a73b5782f8169b0529a535269ea82440) ) /* TOUCHMASTER 7987 V8.X U40 (white label) */
1165
1166   ROM_REGION( 0x100000, "oki", 0 ) // Samples
1167   ROM_LOAD( "tm7k_sound.u8", 0x00000, 0x100000, CRC(c6070a60) SHA1(2dc20bf2217a36374b5a691133ad43f53dbe29ca) ) /* Labeled SOUND U8  8.0 (orange label) */
1168ROM_END
1169
11361170/***************************************************************************
11371171
11381172Touchmaster 8000
r4939r4940
12791313
12801314}
12811315
1316static DRIVER_INIT( tm5kca )
1317{
1318   UINT16 *ROM = (UINT16 *)memory_region( machine, "maincpu" );
1319
1320   // protection
1321   ROM[0x95ffe/2] = 0x4e75;
1322
1323   ROM[0x95fcc/2] = 0x6002;
1324   ROM[0x95ff4/2] = 0x6002;
1325
1326}
1327
12821328static DRIVER_INIT( tm7k )
12831329{
12841330   UINT16 *ROM = (UINT16 *)memory_region( machine, "maincpu" );
r4939r4940
13251371
13261372}
13271373
1374static DRIVER_INIT( tm7keval ) /* kit came with a security key labeled A-21657-004, which is a TM5000 key */
1375{
1376   UINT16 *ROM = (UINT16 *)memory_region( machine, "maincpu" );
1377
1378   // protection
1379   ROM[0x8949e/2] = 0x4e75;
1380
1381   ROM[0x8946c/2] = 0x6002;
1382   ROM[0x89494/2] = 0x6002;
1383/*
1384Protection starts:
1385
1386 8945A: addi.w  #$384, D0       0640 0384
1387 8945E: move.w  D0, $2074E4.l   33C0 0020 74E4
1388 89464: moveq   #$f, D0         700F
1389 89466: and.w   (A4), D0        C054
1390 89468: cmpi.w  #$3, D0         0C40 0003
1391 8946C: bcs     $89470          6502          <-- First patch goes here
1392
1393*/
1394
1395}
1396
13281397static DRIVER_INIT( tm8k )
13291398{
13301399   UINT16 *ROM = (UINT16 *)memory_region( machine, "maincpu" );
r4939r4940
13641433GAME( 1997, tm3ka,    tm3k, tm3k,     tmaster,  0,        ROT0, "Midway",                         "Touchmaster 3000 (v5.01 Standard)",  0 )
13651434GAME( 1998, tm4k,     0,    tm3k,     tmaster,  tm4k,     ROT0, "Midway",                         "Touchmaster 4000 (v6.02 Standard)",  0 )
13661435GAME( 1998, tm5k,     0,    tm3k,     tmaster,  tm5k,     ROT0, "Midway",                         "Touchmaster 5000 (v7.10 Standard)",  0 )
1436GAME( 1998, tm5kca,   tm5k, tm3k,     tmaster,  tm5kca,   ROT0, "Midway",                         "Touchmaster 5000 (v7.10 California)",  0 )
13671437GAME( 1999, tm7k,     0,    tm3k,     tmaster,  tm7k,     ROT0, "Midway",                         "Touchmaster 7000 (v8.04 Standard)",  0 )
13681438GAME( 1999, tm7ka,    tm7k, tm3k,     tmaster,  tm7ka,    ROT0, "Midway",                         "Touchmaster 7000 (v8.00 Standard)",  0 )
1439GAME( 1999, tm7keval, tm7k, tm3k,     tmaster,  tm7keval, ROT0, "Midway",                         "Touchmaster 7000 (v8.1X Evaluation)",  0 )
13691440GAME( 2000, tm8k,     0,    tm3k,     tmaster,  tm8k,     ROT0, "Midway",                         "Touchmaster 8000 (v9.04 Standard)",  0 )
13701441GAME( 1998, galgbios, 0,    galgames, galgames, galgames, ROT0, "Creative Electonics & Software", "Galaxy Games (BIOS v1.90)", GAME_IS_BIOS_ROOT )
src/mame/drivers/mpu4drvr.c
r4939r4940
365365};
366366
367367
368static void cpu1_ptm_irq(running_machine *machine, int state)
368static WRITE_LINE_DEVICE_HANDLER( cpu1_ptm_irq )
369369{
370370   m6840_irq_state = state;
371   update_mpu68_interrupts(machine);
371   update_mpu68_interrupts(device->machine);
372372}
373373
374374
375static WRITE8_HANDLER( vid_o1_callback )
375static WRITE8_DEVICE_HANDLER( vid_o1_callback )
376376{
377   ptm6840_set_c2(   space->machine, 1, data); /* this output is the clock for timer2 */
377   ptm6840_set_c2(device, 0, data); /* this output is the clock for timer2 */
378378
379379   if (data)
380380   {
381      const device_config *acia_0 = devtag_get_device(space->machine, "acia6850_0");
382      const device_config *acia_1 = devtag_get_device(space->machine, "acia6850_1");
381      const device_config *acia_0 = devtag_get_device(device->machine, "acia6850_0");
382      const device_config *acia_1 = devtag_get_device(device->machine, "acia6850_1");
383383      acia6850_tx_clock_in(acia_0);
384384      acia6850_rx_clock_in(acia_0);
385385      acia6850_tx_clock_in(acia_1);
r4939r4940
388388}
389389
390390
391static WRITE8_HANDLER( vid_o2_callback )
391static WRITE8_DEVICE_HANDLER( vid_o2_callback )
392392{
393   ptm6840_set_c3(   space->machine, 1, data); /* this output is the clock for timer3 */
393   ptm6840_set_c3(device, 0, data); /* this output is the clock for timer3 */
394394}
395395
396396
397static WRITE8_HANDLER( vid_o3_callback )
397static WRITE8_DEVICE_HANDLER( vid_o3_callback )
398398{
399   ptm6840_set_c1(   space->machine, 1, data); /* this output is the clock for timer1 */
399   ptm6840_set_c1(device, 0, data); /* this output is the clock for timer1 */
400400}
401401
402402
403403static const ptm6840_interface ptm_vid_intf =
404404{
405   VIDEO_MASTER_CLOCK/10, /* 68k E clock */
406   { 0,0,0 },
407   { vid_o1_callback, vid_o2_callback, vid_o3_callback },
408   cpu1_ptm_irq
405   VIDEO_MASTER_CLOCK / 10, /* 68k E clock */
406   { 0, 0, 0 },
407   { DEVCB_HANDLER(vid_o1_callback),
408     DEVCB_HANDLER(vid_o2_callback),
409     DEVCB_HANDLER(vid_o3_callback) },
410   DEVCB_LINE(cpu1_ptm_irq)
409411};
410412
411413
r4939r4940
13811383{
13821384   mpu4_config_common(machine);
13831385
1384   ptm6840_config(machine, 1, &ptm_vid_intf );
1385
13861386   /* setup communications */
1387   serial_card_connected=1;
1387   serial_card_connected = 1;
13881388
13891389   /* setup 8 mechanical meters */
13901390   Mechmtr_init(8);
r4939r4940
13981398
13991399   /* setup the standard oki MSC1937 display */
14001400
1401   ROC10937_init(0, MSC1937,0);
1401   ROC10937_init(0, MSC1937, 0);
14021402}
14031403
14041404/*
r4939r4940
14661466    AM_RANGE(0xff8000, 0xff8001) AM_DEVREADWRITE8("acia6850_1", acia6850_stat_r, acia6850_ctrl_w, 0xff)
14671467    AM_RANGE(0xff8002, 0xff8003) AM_DEVREADWRITE8("acia6850_1", acia6850_data_r, acia6850_data_w, 0xff)
14681468
1469   AM_RANGE(0xff9000, 0xff900f) AM_READWRITE(ptm6840_1_lsb_r,ptm6840_1_lsb_w)   /* 6840PTM */
1469   /* 6840PTM */
1470   AM_RANGE(0xff9000, 0xff900f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_read, ptm6840_write, 0xff)
14701471
14711472   AM_RANGE(0xffd000, 0xffd00f) AM_READWRITE(characteriser16_r, characteriser16_w) /* characterizer */
14721473ADDRESS_MAP_END
14731474
14741475/* TODO: Fix up MPU4 map*/
14751476static ADDRESS_MAP_START( mpu4_6809_map, ADDRESS_SPACE_PROGRAM, 8 )
1476   AM_RANGE(0x0000, 0x07FF) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
1477   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size)
14771478
14781479   AM_RANGE(0x0800, 0x0800) AM_DEVREADWRITE("acia6850_0", acia6850_stat_r, acia6850_ctrl_w)
14791480   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("acia6850_0", acia6850_data_r, acia6850_data_w)
14801481
14811482   AM_RANGE(0x0880, 0x0881) AM_NOP /* Could be a UART datalogger is here. */
14821483
1483   AM_RANGE(0x0900, 0x0907) AM_READWRITE(ptm6840_0_r,ptm6840_0_w) /* 6840PTM */
1484   AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE("6840ptm", ptm6840_read, ptm6840_write) /* 6840PTM */
14841485
1485   AM_RANGE(0x0A00, 0x0A03) AM_DEVREADWRITE("pia_ic3", pia6821_r,pia6821_w)        /* PIA6821 IC3 */
1486   AM_RANGE(0x0B00, 0x0B03) AM_DEVREADWRITE("pia_ic4", pia6821_r,pia6821_w)        /* PIA6821 IC4 */
1487   AM_RANGE(0x0C00, 0x0C03) AM_DEVREADWRITE("pia_ic5", pia6821_r,pia6821_w)        /* PIA6821 IC5 */
1488   AM_RANGE(0x0D00, 0x0D03) AM_DEVREADWRITE("pia_ic6", pia6821_r,pia6821_w)      /* PIA6821 IC6 */
1489   AM_RANGE(0x0E00, 0x0E03) AM_DEVREADWRITE("pia_ic7", pia6821_r,pia6821_w)      /* PIA6821 IC7 */
1490   AM_RANGE(0x0F00, 0x0F03) AM_DEVREADWRITE("pia_ic8", pia6821_r,pia6821_w)      /* PIA6821 IC8 */
1486   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE("pia_ic3", pia6821_r, pia6821_w)        /* PIA6821 IC3 */
1487   AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE("pia_ic4", pia6821_r, pia6821_w)        /* PIA6821 IC4 */
1488   AM_RANGE(0x0c00, 0x0c03) AM_DEVREADWRITE("pia_ic5", pia6821_r, pia6821_w)        /* PIA6821 IC5 */
1489   AM_RANGE(0x0d00, 0x0d03) AM_DEVREADWRITE("pia_ic6", pia6821_r, pia6821_w)      /* PIA6821 IC6 */
1490   AM_RANGE(0x0e00, 0x0e03) AM_DEVREADWRITE("pia_ic7", pia6821_r, pia6821_w)      /* PIA6821 IC7 */
1491   AM_RANGE(0x0f00, 0x0f03) AM_DEVREADWRITE("pia_ic8", pia6821_r, pia6821_w)      /* PIA6821 IC8 */
14911492
1492   AM_RANGE(0x4000, 0x40FF) AM_RAM /* it actually runs code from here... */
1493   AM_RANGE(0x4000, 0x40ff) AM_RAM /* it actually runs code from here... */
14931494
1494   AM_RANGE(0xBE00, 0xBFFF) AM_RAM /* 00 written on startup */
1495   AM_RANGE(0xC000, 0xFFFF) AM_ROM   AM_REGION("maincpu",0)  /* 64k EPROM on board, only this region read */
1495   AM_RANGE(0xbe00, 0xbfff) AM_RAM /* 00 written on startup */
1496   AM_RANGE(0xc000, 0xffff) AM_ROM   AM_REGION("maincpu",0)  /* 64k EPROM on board, only this region read */
14961497ADDRESS_MAP_END
14971498
14981499static ADDRESS_MAP_START( vp_68k_map, ADDRESS_SPACE_PROGRAM, 16 )
r4939r4940
15221523    AM_RANGE(0xff8000, 0xff8001) AM_DEVREADWRITE8("acia6850_1", acia6850_stat_r, acia6850_ctrl_w, 0xff)
15231524    AM_RANGE(0xff8002, 0xff8003) AM_DEVREADWRITE8("acia6850_1", acia6850_data_r, acia6850_data_w, 0xff)
15241525
1525   AM_RANGE(0xff9000, 0xff900f) AM_READ(  ptm6840_1_lsb_r)
1526   AM_RANGE(0xff9000, 0xff900f) AM_WRITE( ptm6840_1_lsb_w)
1526   /* 6840PTM */
1527   AM_RANGE(0xff9000, 0xff900f) AM_DEVREADWRITE8("6840ptm_68k", ptm6840_read, ptm6840_write, 0xff)
15271528
15281529   /* characterizer */
15291530/*  AM_RANGE(0xffd000, 0xffd00f) AM_READWRITE(characteriser16_r, characteriser16_w) Word-based version of old CHR??? */
r4939r4940
16621663   AM_RANGE(0x0800, 0x0800) AM_DEVWRITE("crtc", mc6845_address_w)
16631664   AM_RANGE(0x0801, 0x0801) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
16641665
1665/*  AM_RANGE(0x08E0, 0x08E7) AM_READWRITE(68681_duart_r,68681_duart_w) */
1666/*  AM_RANGE(0x08e0, 0x08e7) AM_READWRITE(68681_duart_r,68681_duart_w) */
16661667
1667   AM_RANGE(0x0900, 0x0907) AM_READWRITE(ptm6840_0_r,ptm6840_0_w) /* 6840PTM */
1668   AM_RANGE(0x0900, 0x0907) AM_DEVREADWRITE("6840ptm", ptm6840_read, ptm6840_write) /* 6840PTM */
16681669
1669   AM_RANGE(0x0A00, 0x0A03) AM_DEVREADWRITE("pia_ic3", pia6821_r,pia6821_w)        /* PIA6821 IC3 */
1670   AM_RANGE(0x0B00, 0x0B03) AM_DEVREADWRITE("pia_ic4", pia6821_r,pia6821_w)        /* PIA6821 IC4 */
1671   AM_RANGE(0x0C00, 0x0C03) AM_DEVREADWRITE("pia_ic5", pia6821_r,pia6821_w)        /* PIA6821 IC5 */
1672   AM_RANGE(0x0D00, 0x0D03) AM_DEVREADWRITE("pia_ic6", pia6821_r,pia6821_w)      /* PIA6821 IC6 */
1673   AM_RANGE(0x0E00, 0x0E03) AM_DEVREADWRITE("pia_ic7", pia6821_r,pia6821_w)      /* PIA6821 IC7 */
1674   AM_RANGE(0x0F00, 0x0F03) AM_DEVREADWRITE("pia_ic8", pia6821_r,pia6821_w)      /* PIA6821 IC8 */
1670   AM_RANGE(0x0a00, 0x0a03) AM_DEVREADWRITE("pia_ic3", pia6821_r, pia6821_w)        /* PIA6821 IC3 */
1671   AM_RANGE(0x0b00, 0x0b03) AM_DEVREADWRITE("pia_ic4", pia6821_r, pia6821_w)        /* PIA6821 IC4 */
1672   AM_RANGE(0x0c00, 0x0c03) AM_DEVREADWRITE("pia_ic5", pia6821_r, pia6821_w)        /* PIA6821 IC5 */
1673   AM_RANGE(0x0d00, 0x0d03) AM_DEVREADWRITE("pia_ic6", pia6821_r, pia6821_w)      /* PIA6821 IC6 */
1674   AM_RANGE(0x0e00, 0x0e03) AM_DEVREADWRITE("pia_ic7", pia6821_r, pia6821_w)      /* PIA6821 IC7 */
1675   AM_RANGE(0x0f00, 0x0f03) AM_DEVREADWRITE("pia_ic8", pia6821_r, pia6821_w)      /* PIA6821 IC8 */
16751676
16761677   AM_RANGE(0x1000, 0x2fff) AM_RAM AM_BASE(&dealem_videoram)
16771678   AM_RANGE(0x8000, 0xffff) AM_ROM   AM_WRITENOP/* 64k  paged ROM (4 pages) */
r4939r4940
16851686
16861687   MDRV_NVRAM_HANDLER(generic_0fill)            /* confirm */
16871688
1689   /* 6840 PTM */
1690   MDRV_PTM6840_ADD("6840ptm", ptm_ic2_intf)
1691
16881692   MDRV_PIA6821_ADD("pia_ic3", pia_ic3_intf)
16891693   MDRV_PIA6821_ADD("pia_ic4", pia_ic4_intf)
16901694   MDRV_PIA6821_ADD("pia_ic5", pia_ic5_intf)
r4939r4940
17121716
17131717   MDRV_PALETTE_LENGTH(16)
17141718
1719   /* 6840 PTM */
1720   MDRV_PTM6840_ADD("6840ptm_68k", ptm_vid_intf)
1721
17151722   MDRV_SPEAKER_STANDARD_MONO("mono")
17161723   MDRV_SOUND_ADD("ay8913",AY8913, MPU4_MASTER_CLOCK/4)
17171724   MDRV_SOUND_CONFIG(ay8910_config)
r4939r4940
17431750
17441751   MDRV_TIMER_ADD_PERIODIC("50hz",gen_50hz, HZ(100))
17451752
1753   /* 6840 PTM */
1754   MDRV_PTM6840_ADD("6840ptm", ptm_ic2_intf)
1755
17461756   MDRV_PIA6821_ADD("pia_ic3", pia_ic3_intf)
17471757   MDRV_PIA6821_ADD("pia_ic4", pia_ic4_intf)
17481758   MDRV_PIA6821_ADD("pia_ic5", pia_ic5_intf)
src/mame/drivers/midvunit.c
r4939r4940
88        * Cruis'n USA (1994)        [3 sets]
99        * Cruis'n World (1996)      [4 sets]
1010        * War Gods (1996)
11        * Off Road Challenge (1997) [3 sets]
11        * Off Road Challenge (1997) [4 sets]
1212
1313    Known bugs:
1414        * textures for automatic/manual selection get overwritten in Cruis'n World
r4939r4940
13911391ROM_END
13921392
13931393
1394ROM_START( offroadc ) /* Version 1.40, Mon 10-06-97 */
1394ROM_START( offroadc ) /* Version 1.63, Tue 03-03-98 */
13951395   ROM_REGION16_LE( 0x1000000, "dcs", ROMREGION_ERASEFF )   /* sound data */
13961396   ROM_LOAD16_BYTE( "offroadc.u2",  0x000000, 0x80000, CRC(69976e9d) SHA1(63c886ac2563c43a10840f49f929f8613cd94de2) )
13971397   ROM_LOAD16_BYTE( "offroadc.u3",  0x200000, 0x80000, CRC(2db9b548) SHA1(4f454a3e6a8851b0ef5d325dd28102d57ea11a11) )
r4939r4940
14031403   ROM_LOAD16_BYTE( "offroadc.u9",  0xe00000, 0x80000, CRC(7ad27f69) SHA1(b33665d0593a95b58d529720aae49e90449bf714) )
14041404
14051405   ROM_REGION32_LE( 0x1000000, "user1", 0 )
1406   ROM_LOAD32_BYTE( "orc-1_63.u10", 0x0000000, 0x100000, CRC(faaf81b8) SHA1(d0bd40b2cf5d07db9f668826cc7f0ed84c4e84bf) ) /* Version 1.63 program roms */
1407   ROM_LOAD32_BYTE( "orc-1_63.u11", 0x0000001, 0x100000, CRC(f68e9655) SHA1(e29926ea24cfbd228a2136d04a63a92eba0098d7) )
1408   ROM_LOAD32_BYTE( "orc-1_63.u12", 0x0000002, 0x100000, CRC(6a5295b3) SHA1(ac72fe205ffb306598400e8b1d9c98ae67b0bab9) )
1409   ROM_LOAD32_BYTE( "orc-1_63.u13", 0x0000003, 0x100000, CRC(cb9233b5) SHA1(2d23b6a2312a75dbaa44de3224512c844aaac7b5) )
1410   ROM_LOAD32_BYTE( "offroadc.u14", 0x0400000, 0x100000, CRC(1e41d14b) SHA1(3f7c5fae1f8b82ddd811720837fa298785a8dd27) )
1411   ROM_LOAD32_BYTE( "offroadc.u15", 0x0400001, 0x100000, CRC(654d623d) SHA1(a944b8f8d71b099d7b5bbd7df6effb90afc3aec8) )
1412   ROM_LOAD32_BYTE( "offroadc.u16", 0x0400002, 0x100000, CRC(259774d8) SHA1(90cdf659324b84b3c2c59497cc5611e8f12629a6) )
1413   ROM_LOAD32_BYTE( "offroadc.u17", 0x0400003, 0x100000, CRC(50c61434) SHA1(52bc603101b4f88b7d892af683b7c8358cabbf4a) )
1414   ROM_LOAD32_BYTE( "offroadc.u18", 0x0800000, 0x100000, CRC(015be91c) SHA1(1624537068c6bc5fa6235bf0b0343347c337e8d8) )
1415   ROM_LOAD32_BYTE( "offroadc.u19", 0x0800001, 0x100000, CRC(cfc6b70e) SHA1(8c5ad84c50ca142726db0595153cf04caaabec9c) )
1416   ROM_LOAD32_BYTE( "offroadc.u20", 0x0800002, 0x100000, CRC(f48d6e33) SHA1(8b9c205e24f217ac110cdd82388c056ebbbb09b0) )
1417   ROM_LOAD32_BYTE( "offroadc.u21", 0x0800003, 0x100000, CRC(17794b56) SHA1(8bfd8f5b43056bfe7f62524bb8c3a8564a3a9413) )
1418   ROM_LOAD32_BYTE( "offroadc.u22", 0x0c00000, 0x100000, CRC(f2a6e622) SHA1(a7d7004e95b058124cc02e8073dab8fbed8813c5) )
1419   ROM_LOAD32_BYTE( "offroadc.u23", 0x0c00001, 0x100000, CRC(1cba6e20) SHA1(a7c9c58bfc4d26decb08979d83cccedb27528eb6) )
1420   ROM_LOAD32_BYTE( "offroadc.u24", 0x0c00002, 0x100000, CRC(fd3ce11f) SHA1(78c65267712488784bc6dc14eef98a90494a9553) )
1421   ROM_LOAD32_BYTE( "offroadc.u25", 0x0c00003, 0x100000, CRC(78f8e5db) SHA1(7ec2a5add27d66c43ba5cb7182554321007f5798) )
1422ROM_END
1423
1424
1425ROM_START( offrodc4 ) /* Version 1.40, Mon 10-06-97 */
1426   ROM_REGION16_LE( 0x1000000, "dcs", ROMREGION_ERASEFF )   /* sound data */
1427   ROM_LOAD16_BYTE( "offroadc.u2",  0x000000, 0x80000, CRC(69976e9d) SHA1(63c886ac2563c43a10840f49f929f8613cd94de2) )
1428   ROM_LOAD16_BYTE( "offroadc.u3",  0x200000, 0x80000, CRC(2db9b548) SHA1(4f454a3e6a8851b0ef5d325dd28102d57ea11a11) )
1429   ROM_LOAD16_BYTE( "offroadc.u4",  0x400000, 0x80000, CRC(42bdf9d0) SHA1(04add0f0ee7fa61de1913cc0b988345d3d430cde) )
1430   ROM_LOAD16_BYTE( "offroadc.u5",  0x600000, 0x80000, CRC(569cc84b) SHA1(08b917cc41fae6b6a3e9d9461a783d3d2865e72a) )
1431   ROM_LOAD16_BYTE( "offroadc.u6",  0x800000, 0x80000, CRC(0896f679) SHA1(dde39ef17834256909ef2c9fcd5b5fb9939d5178) )
1432   ROM_LOAD16_BYTE( "offroadc.u7",  0xa00000, 0x80000, CRC(fe242d6a) SHA1(8fbac22ed23044841f309ce58c5b1affcdd5d114) )
1433   ROM_LOAD16_BYTE( "offroadc.u8",  0xc00000, 0x80000, CRC(5da13f12) SHA1(2bb5e929e8bc6c70cb4475024a6b0bb07ac25244) )
1434   ROM_LOAD16_BYTE( "offroadc.u9",  0xe00000, 0x80000, CRC(7ad27f69) SHA1(b33665d0593a95b58d529720aae49e90449bf714) )
1435
1436   ROM_REGION32_LE( 0x1000000, "user1", 0 )
14061437   ROM_LOAD32_BYTE( "orc-1_4.u10",  0x0000000, 0x100000, CRC(d263b078) SHA1(d376e120e05cf8526b002300db345fd0b9775702) ) /* Version 1.40 program roms */
14071438   ROM_LOAD32_BYTE( "orc-1_4.u11",  0x0000001, 0x100000, CRC(1b443a72) SHA1(0e16d923f0e97f21e92c8d5b431fcaa0815b2c87) )
14081439   ROM_LOAD32_BYTE( "orc-1_4.u12",  0x0000002, 0x100000, CRC(4e82a34b) SHA1(c22a3f638b7e226add511147982339b1f59821e9) )
r4939r4940
16541685GAME( 1996, crusnw20, crusnwld, midvunit, crusnwld, crusnwld, ROT0, "Midway", "Cruis'n World (rev L2.0)", GAME_SUPPORTS_SAVE )
16551686GAME( 1996, crusnw17, crusnwld, midvunit, crusnwld, crusnwld, ROT0, "Midway", "Cruis'n World (rev L1.7)", GAME_SUPPORTS_SAVE )
16561687GAME( 1996, crusnw13, crusnwld, midvunit, crusnwld, crusnwld, ROT0, "Midway", "Cruis'n World (rev L1.3)", GAME_SUPPORTS_SAVE )
1657GAME( 1997, offroadc, 0,        midvunit, offroadc, offroadc, ROT0, "Midway", "Off Road Challenge (v1.40)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
1688GAME( 1997, offroadc, 0,        midvunit, offroadc, offroadc, ROT0, "Midway", "Off Road Challenge (v1.63)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
1689GAME( 1997, offrodc4, offroadc, midvunit, offroadc, offroadc, ROT0, "Midway", "Off Road Challenge (v1.40)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
16581690GAME( 1997, offrodc3, offroadc, midvunit, offroadc, offroadc, ROT0, "Midway", "Off Road Challenge (v1.30)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
16591691GAME( 1997, offrodc1, offroadc, midvunit, offroadc, offroadc, ROT0, "Midway", "Off Road Challenge (v1.10)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
16601692
src/mame/drivers/cvs.c
r4939r4940
11711171   CVS_COMMON_ROMS
11721172ROM_END
11731173
1174ROM_START( hunchbak )
1174ROM_START( hunchbak ) // actual ROM label has "Century Elect. Ltd. (c)1981", and some label has HB/HB2 handwritten
11751175   ROM_REGION( 0x8000, "maincpu", 0 )
11761176   ROM_LOAD_STAGGERED( "hb-gp1.bin", 0x0000, CRC(af801d54) SHA1(68e31561e98f7e2caa337dd764941d08f075b559) )
11771177   ROM_LOAD_STAGGERED( "hb-gp2.bin", 0x0400, CRC(b448cc8e) SHA1(ed94f662c0e08a3a0aca073fbec29ae1fbd0328e) )
r4939r4940
11801180   ROM_LOAD_STAGGERED( "hb-gp5.bin", 0x1000, CRC(1dd5755c) SHA1(b1e158d52bd9a238e3e32ed3024e495df2292dcb) )
11811181
11821182   ROM_REGION( 0x8000, "audiocpu", 0 )
1183   ROM_LOAD( "hb-sdp1.bin", 0x0000, 0x1000, CRC(f9ba2854) SHA1(d041198e2e8b8c3e668bd1610310f8d25c5b1119) )
1183   ROM_LOAD( "6c.sdp1", 0x0000, 0x1000, CRC(f9ba2854) SHA1(d041198e2e8b8c3e668bd1610310f8d25c5b1119) )
11841184
1185   CVS_ROM_REGION_SPEECH_DATA( "hb-sp1.bin", 0x0800, CRC(ed1cd201) SHA1(6cc3842dda1bfddc06ffb436c55d14276286bd67) )
1185   CVS_ROM_REGION_SPEECH_DATA( "8a.sp1", 0x0800, CRC(ed1cd201) SHA1(6cc3842dda1bfddc06ffb436c55d14276286bd67) )
11861186
11871187   ROM_REGION( 0x1800, "gfx1", 0 )
1188   ROM_LOAD( "hb-cp1.bin", 0x0000, 0x0800, CRC(f256b047) SHA1(02d79882bad37ffdd58ef478e2658a1369c32ebc) )
1189   ROM_LOAD( "hb-cp2.bin", 0x0800, 0x0800, CRC(b870c64f) SHA1(ce4f8de87568782ce02bba754edff85df7f5c393) )
1190   ROM_LOAD( "hb-cp3.bin", 0x1000, 0x0800, CRC(9a7dab88) SHA1(cd39a9d4f982a7f49c478db1408d7e07335f2ddc) )
1188   ROM_LOAD( "11a.cp1", 0x0000, 0x0800, CRC(f256b047) SHA1(02d79882bad37ffdd58ef478e2658a1369c32ebc) )
1189   ROM_LOAD( "10a.cp2", 0x0800, 0x0800, CRC(b870c64f) SHA1(ce4f8de87568782ce02bba754edff85df7f5c393) )
1190   ROM_LOAD( "9a.cp3",  0x1000, 0x0800, CRC(9a7dab88) SHA1(cd39a9d4f982a7f49c478db1408d7e07335f2ddc) )
11911191
11921192   CVS_COMMON_ROMS
11931193ROM_END
11941194
11951195ROM_START( hunchbka )
11961196   ROM_REGION( 0x8000, "maincpu", 0 )
1197   ROM_LOAD_STAGGERED( "1b.bin", 0x0000, CRC(c816860b) SHA1(1109639645496d4644564d21c816b8baf8c84cf7) )
1198   ROM_LOAD_STAGGERED( "2a.bin", 0x0400, CRC(cab1e524) SHA1(c3fd7ac9ce5893fd2602a15ad0f6e3267a4ca122) )
1199   ROM_LOAD_STAGGERED( "3a.bin", 0x0800, CRC(b2adcfeb) SHA1(3090e2c6b945857c1e48dea395015a05c6165cd9) )
1200   ROM_LOAD_STAGGERED( "4c.bin", 0x0c00, CRC(229a8b71) SHA1(ea3815eb69d4927da356eada0add8382735feb48) )
1201   ROM_LOAD_STAGGERED( "5a.bin", 0x1000, CRC(cb4f0313) SHA1(1ef63cbe62e7a54d45e0afbc398c9d9b601e6403) )
1197   ROM_LOAD_STAGGERED( "1b.gp1", 0x0000, CRC(c816860b) SHA1(1109639645496d4644564d21c816b8baf8c84cf7) )
1198   ROM_LOAD_STAGGERED( "2a.gp2", 0x0400, CRC(cab1e524) SHA1(c3fd7ac9ce5893fd2602a15ad0f6e3267a4ca122) )
1199   ROM_LOAD_STAGGERED( "3a.gp3", 0x0800, CRC(b2adcfeb) SHA1(3090e2c6b945857c1e48dea395015a05c6165cd9) )
1200   ROM_LOAD_STAGGERED( "4c.gp4", 0x0c00, CRC(229a8b71) SHA1(ea3815eb69d4927da356eada0add8382735feb48) )
1201   ROM_LOAD_STAGGERED( "5a.gp5", 0x1000, CRC(cb4f0313) SHA1(1ef63cbe62e7a54d45e0afbc398c9d9b601e6403) )
12021202
12031203   ROM_REGION( 0x8000, "audiocpu", 0 )
1204   ROM_LOAD( "hb-sdp1.bin", 0x0000, 0x1000, CRC(f9ba2854) SHA1(d041198e2e8b8c3e668bd1610310f8d25c5b1119) )
1204   ROM_LOAD( "6c.sdp1", 0x0000, 0x1000, CRC(f9ba2854) SHA1(d041198e2e8b8c3e668bd1610310f8d25c5b1119) )
12051205
1206   CVS_ROM_REGION_SPEECH_DATA( "hb-sp1.bin", 0x0800, CRC(ed1cd201) SHA1(6cc3842dda1bfddc06ffb436c55d14276286bd67) )
1206   CVS_ROM_REGION_SPEECH_DATA( "8a.sp1", 0x0800, CRC(ed1cd201) SHA1(6cc3842dda1bfddc06ffb436c55d14276286bd67) )
12071207
12081208   ROM_REGION( 0x1800, "gfx1", 0 )
1209   ROM_LOAD( "hb-cp1.bin", 0x0000, 0x0800, CRC(f256b047) SHA1(02d79882bad37ffdd58ef478e2658a1369c32ebc) )
1210   ROM_LOAD( "hb-cp2.bin", 0x0800, 0x0800, CRC(b870c64f) SHA1(ce4f8de87568782ce02bba754edff85df7f5c393) )
1211   ROM_LOAD( "hb-cp3.bin", 0x1000, 0x0800, CRC(9a7dab88) SHA1(cd39a9d4f982a7f49c478db1408d7e07335f2ddc) )
1209   ROM_LOAD( "11a.cp1", 0x0000, 0x0800, CRC(f256b047) SHA1(02d79882bad37ffdd58ef478e2658a1369c32ebc) )
1210   ROM_LOAD( "10a.cp2", 0x0800, 0x0800, CRC(b870c64f) SHA1(ce4f8de87568782ce02bba754edff85df7f5c393) )
1211   ROM_LOAD( "9a.cp3",  0x1000, 0x0800, CRC(9a7dab88) SHA1(cd39a9d4f982a7f49c478db1408d7e07335f2ddc) )
12121212
12131213   CVS_COMMON_ROMS
12141214ROM_END
r4939r4940
14231423   CVS_COMMON_ROMS
14241424ROM_END
14251425
1426ROM_START( logger )
1426ROM_START( logger ) // actual ROM label has "Century Elect. Ltd. (c)1981", and LOG3 is handwritten
14271427   ROM_REGION( 0x8000, "maincpu", 0 )
1428   ROM_LOAD_STAGGERED( "lg-gp1.bin", 0x0000, CRC(0022b9ed) SHA1(4b94d2663f802a8140e8eae1b66ee78fdfa654f5) )
1429   ROM_LOAD_STAGGERED( "lg-gp2.bin", 0x0400, CRC(23c5c8dc) SHA1(37fb6a62cb798d96de20078fe4a3af74a2be0e66) )
1430   ROM_LOAD_STAGGERED( "lg-gp3.bin", 0x0800, CRC(f9288f74) SHA1(8bb588194186fc0e0c2d61ed2746542c978ebb76) )
1431   ROM_LOAD_STAGGERED( "lg-gp4.bin", 0x0c00, CRC(e52ef7bf) SHA1(df5509b6847d6b9520a9d83b15083546898a981e) )
1432   ROM_LOAD_STAGGERED( "lg-gp5.bin", 0x1000, CRC(4ee04359) SHA1(a592d4b280ac0ad5f06d68a7809092548261f123) )
1428   ROM_LOAD_STAGGERED( "1clog3.gp1", 0x0000, CRC(0022b9ed) SHA1(4b94d2663f802a8140e8eae1b66ee78fdfa654f5) )
1429   ROM_LOAD_STAGGERED( "2clog3.gp2", 0x0400, CRC(23c5c8dc) SHA1(37fb6a62cb798d96de20078fe4a3af74a2be0e66) )
1430   ROM_LOAD_STAGGERED( "3clog3.gp3", 0x0800, CRC(f9288f74) SHA1(8bb588194186fc0e0c2d61ed2746542c978ebb76) )
1431   ROM_LOAD_STAGGERED( "4clog3.gp4", 0x0c00, CRC(e52ef7bf) SHA1(df5509b6847d6b9520a9d83b15083546898a981e) )
1432   ROM_LOAD_STAGGERED( "5clog3.gp5", 0x1000, CRC(4ee04359) SHA1(a592d4b280ac0ad5f06d68a7809092548261f123) )
14331433
14341434   ROM_REGION( 0x8000, "audiocpu", 0 )
1435   ROM_LOAD( "lg-sdp1.bin", 0x0000, 0x1000, CRC(5af8da17) SHA1(357f02cdf38c6659aca51fa0a8534542fc29623c) )
1435   ROM_LOAD( "6clog3.sdp1", 0x0000, 0x1000, CRC(5af8da17) SHA1(357f02cdf38c6659aca51fa0a8534542fc29623c) )
14361436
1437   CVS_ROM_REGION_SPEECH_DATA( "lg-sp1.bin", 0x0800, CRC(74f67815) SHA1(6a26a16c27a7e4d58b611e5127115005a60cff91) )
1437   CVS_ROM_REGION_SPEECH_DATA( "8clog3.sp1", 0x0800, CRC(74f67815) SHA1(6a26a16c27a7e4d58b611e5127115005a60cff91) )
14381438
14391439   ROM_REGION( 0x1800, "gfx1", 0 )
1440   ROM_LOAD( "lg-cp1.bin", 0x0000, 0x0800, CRC(e4ede80e) SHA1(62f2bc78106a057b6a8420d40421908df609bf29) )
1441   ROM_LOAD( "lg-cp2.bin", 0x0800, 0x0800, CRC(d3de8e5b) SHA1(f95320e001869c42e51195d9cc11e4f2555e153f) )
1442   ROM_LOAD( "lg-cp3.bin", 0x1000, 0x0800, CRC(9b8d1031) SHA1(87ef12aeae80cc0f240dead651c6222848f8dccc) )
1440   ROM_LOAD( "11clog3.cp1", 0x0000, 0x0800, CRC(e4ede80e) SHA1(62f2bc78106a057b6a8420d40421908df609bf29) )
1441   ROM_LOAD( "10clog3.cp2", 0x0800, 0x0800, CRC(d3de8e5b) SHA1(f95320e001869c42e51195d9cc11e4f2555e153f) )
1442   ROM_LOAD( "9clog3.cp3",  0x1000, 0x0800, CRC(9b8d1031) SHA1(87ef12aeae80cc0f240dead651c6222848f8dccc) )
14431443
14441444   CVS_COMMON_ROMS
14451445ROM_END
src/mame/drivers/goal92.c
r4939r4940
6868   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(goal92_text_w) AM_BASE(&goal92_textram)
6969   AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE(&paletteram16)
7070   AM_RANGE(0x104000, 0x13ffff) AM_RAM
71   AM_RANGE(0x140000, 0x1407ff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
71   AM_RANGE(0x140000, 0x1407ff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
7272   AM_RANGE(0x140800, 0x140801) AM_WRITENOP
7373   AM_RANGE(0x140802, 0x140803) AM_WRITENOP
7474   AM_RANGE(0x180000, 0x18000f) AM_READ(goal92_inputs_r)
7575   AM_RANGE(0x180008, 0x180009) AM_WRITE(goal92_sound_command_w)
7676   AM_RANGE(0x18000a, 0x18000b) AM_WRITENOP
77   AM_RANGE(0x180010, 0x180017) AM_WRITE(SMH_RAM) AM_BASE(&goal92_scrollram16)
77   AM_RANGE(0x180010, 0x180017) AM_WRITEONLY AM_BASE(&goal92_scrollram16)
7878   AM_RANGE(0x18001c, 0x18001d) AM_READWRITE(goal92_fg_bank_r, goal92_fg_bank_w)
7979ADDRESS_MAP_END
8080
r4939r4940
228228/* handler called by the 2203 emulator when the internal timers cause an IRQ */
229229static void irqhandler(const device_config *device, int irq)
230230{
231   cputag_set_input_line(device->machine, "audiocpu", INPUT_LINE_NMI, irq ? ASSERT_LINE : CLEAR_LINE);
231   /* NMI writes to MSM ports *only*! -AS */
232   //cputag_set_input_line(device->machine, "audiocpu", INPUT_LINE_NMI, irq ? ASSERT_LINE : CLEAR_LINE);
232233}
233234
234235static const ym2203_interface ym2203_config =
src/mame/drivers/galdrvr.c
r4939r4940
27302730   ROM_LOAD( "warofbug.clr", 0x0000, 0x0020, CRC(8688e64b) SHA1(ed13414257f580b98b50c9892a14159c55e7838d) )
27312731ROM_END
27322732
2733ROM_START( redufo )
2733ROM_START( redufo ) /* Galaxian bootleg hardware known as Artic Multi-System */
27342734   ROM_REGION( 0x4000, "maincpu", 0 )
27352735   ROM_LOAD( "ru1a",         0x0000, 0x0800, CRC(5a8e4f37) SHA1(c0957ede91e2dc3f80e4912b877843aed5d15779) )
27362736   ROM_LOAD( "ru2a",         0x0800, 0x0800, CRC(c624f52d) SHA1(119a660513ad33e35c9bdaecd588219bf8026d82) )
r4939r4940
30263026   ROM_LOAD( "sk.bpr",       0x0000, 0x0020, CRC(bce79607) SHA1(49d60fde149240bcd025f721b0fbbbdbc549a42f) )
30273027ROM_END
30283028
3029ROM_START( pacmanbl )
3029ROM_START( pacmanbl ) /* Galaxian bootleg hardware known as Artic Multi-System */
30303030   ROM_REGION( 0x10000, "maincpu", 0 )
30313031   ROM_LOAD( "blpac1b",      0x0000, 0x0800, CRC(6718df42) SHA1(ee15c3f583d381fba4878f824f83d04479a0cee5) )
30323032   ROM_LOAD( "blpac2b",      0x0800, 0x0800, CRC(33be3648) SHA1(50175889cf37fe8a81c931e009b55d10f8d0444a) )
src/mame/drivers/galaga.c
r4939r4940
16691669   MDRV_CPU_ADD("sub2", Z80, MASTER_CLOCK/6)   /* 3.072 MHz */
16701670   MDRV_CPU_PROGRAM_MAP(bosco_map)
16711671
1672   MDRV_NAMCO_50XX_ADD("50xx_1", MASTER_CLOCK/12)   /* 1.536 MHz */
1673   MDRV_NAMCO_50XX_ADD("50xx_2", MASTER_CLOCK/12)   /* 1.536 MHz */
1674   MDRV_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/12, namco_51xx_intf)      /* 1.536 MHz */
1675   MDRV_NAMCO_52XX_ADD("52xx", MASTER_CLOCK/12, namco_52xx_intf)      /* 1.536 MHz */
1676   MDRV_NAMCO_54XX_ADD("54xx", MASTER_CLOCK/12, "discrete", NODE_01)   /* 1.536 MHz */
1672   MDRV_NAMCO_50XX_ADD("50xx_1", MASTER_CLOCK/6/2)   /* 1.536 MHz */
1673   MDRV_NAMCO_50XX_ADD("50xx_2", MASTER_CLOCK/6/2)   /* 1.536 MHz */
1674   MDRV_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/6/2, namco_51xx_intf)      /* 1.536 MHz */
1675   MDRV_NAMCO_52XX_ADD("52xx", MASTER_CLOCK/6/2, namco_52xx_intf)      /* 1.536 MHz */
1676   MDRV_NAMCO_54XX_ADD("54xx", MASTER_CLOCK/6/2, "discrete", NODE_01)   /* 1.536 MHz */
16771677
1678   MDRV_NAMCO_06XX_ADD("06xx_0", "maincpu", "51xx",   NULL,   "50xx_1", "54xx")
1679   MDRV_NAMCO_06XX_ADD("06xx_1", "sub",     "50xx_2", "52xx", NULL,     NULL)
1678   MDRV_NAMCO_06XX_ADD("06xx_0", MASTER_CLOCK/6/64, "maincpu", "51xx",   NULL,   "50xx_1", "54xx")
1679   MDRV_NAMCO_06XX_ADD("06xx_1", MASTER_CLOCK/6/64, "sub",     "50xx_2", "52xx", NULL,     NULL)
16801680
16811681   MDRV_WATCHDOG_VBLANK_INIT(8)
16821682   MDRV_QUANTUM_TIME(HZ(6000))   /* 100 CPU slices per frame - an high value to ensure proper */
r4939r4940
16861686
16871687   /* video hardware */
16881688   MDRV_SCREEN_ADD("screen", RASTER)
1689   MDRV_SCREEN_REFRESH_RATE(60.606060)
1690   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
16911689   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1692   MDRV_SCREEN_SIZE(36*8, 272)      /* guess */
1693   MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 2*8, 30*8-1)
1690   MDRV_SCREEN_RAW_PARAMS(MASTER_CLOCK/3, 384, 0, 288, 264, 16, 224+16)
16941691
16951692   MDRV_GFXDECODE(bosco)
16961693   MDRV_PALETTE_LENGTH(64*4+64*4+4+64)
r4939r4940
17281725   MDRV_CPU_ADD("sub2", Z80, MASTER_CLOCK/6)   /* 3.072 MHz */
17291726   MDRV_CPU_PROGRAM_MAP(galaga_map)
17301727
1731   MDRV_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/12, namco_51xx_intf)      /* 1.536 MHz */
1732   MDRV_NAMCO_54XX_ADD("54xx", MASTER_CLOCK/12, "discrete", NODE_01)   /* 1.536 MHz */
1728   MDRV_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/6/2, namco_51xx_intf)      /* 1.536 MHz */
1729   MDRV_NAMCO_54XX_ADD("54xx", MASTER_CLOCK/6/2, "discrete", NODE_01)   /* 1.536 MHz */
17331730
1734   MDRV_NAMCO_06XX_ADD("06xx", "maincpu", "51xx", NULL, NULL, "54xx")
1731   MDRV_NAMCO_06XX_ADD("06xx", MASTER_CLOCK/6/64, "maincpu", "51xx", NULL, NULL, "54xx")
17351732
17361733   MDRV_WATCHDOG_VBLANK_INIT(8)
17371734   MDRV_QUANTUM_TIME(HZ(6000))   /* 100 CPU slices per frame - an high value to ensure proper */
r4939r4940
17411738
17421739   /* video hardware */
17431740   MDRV_SCREEN_ADD("screen", RASTER)
1744   MDRV_SCREEN_REFRESH_RATE(60.606060)
1745   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
17461741   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1747   MDRV_SCREEN_SIZE(36*8, 272)      /* guess */
1748   MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1)
1742   MDRV_SCREEN_RAW_PARAMS(MASTER_CLOCK/3, 384, 0, 288, 264, 0, 224)
17491743
17501744   MDRV_GFXDECODE(galaga)
17511745   MDRV_PALETTE_LENGTH(64*4+64*4+64)
r4939r4940
17971791   MDRV_CPU_ADD("sub2", Z80, MASTER_CLOCK/6)   /* 3.072 MHz */
17981792   MDRV_CPU_PROGRAM_MAP(xevious_map)
17991793
1800   MDRV_NAMCO_50XX_ADD("50xx", MASTER_CLOCK/12)   /* 1.536 MHz */
1801   MDRV_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/12, namco_51xx_intf)      /* 1.536 MHz */
1802   MDRV_NAMCO_54XX_ADD("54xx", MASTER_CLOCK/12, "discrete", NODE_01)   /* 1.536 MHz */
1794   MDRV_NAMCO_50XX_ADD("50xx", MASTER_CLOCK/6/2)   /* 1.536 MHz */
1795   MDRV_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/6/2, namco_51xx_intf)      /* 1.536 MHz */
1796   MDRV_NAMCO_54XX_ADD("54xx", MASTER_CLOCK/6/2, "discrete", NODE_01)   /* 1.536 MHz */
18031797
1804   MDRV_NAMCO_06XX_ADD("06xx", "maincpu", "51xx", NULL, "50xx", "54xx")
1798   MDRV_NAMCO_06XX_ADD("06xx", MASTER_CLOCK/6/64, "maincpu", "51xx", NULL, "50xx", "54xx")
18051799
18061800   MDRV_WATCHDOG_VBLANK_INIT(8)
18071801   MDRV_QUANTUM_TIME(HZ(60000))   /* 1000 CPU slices per frame - an high value to ensure proper */
r4939r4940
18111805
18121806   /* video hardware */
18131807   MDRV_SCREEN_ADD("screen", RASTER)
1814   MDRV_SCREEN_REFRESH_RATE(60.606060)
1815   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
18161808   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1817   MDRV_SCREEN_SIZE(36*8, 272)      /* guess */
1818   MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1)
1809   MDRV_SCREEN_RAW_PARAMS(MASTER_CLOCK/3, 384, 0, 288, 264, 0, 224)
18191810
18201811   MDRV_GFXDECODE(xevious)
18211812   MDRV_PALETTE_LENGTH(128*4+64*8+64*2)
r4939r4940
18771868   MDRV_CPU_ADD("sub2", Z80, MASTER_CLOCK/6)   /* 3.072 MHz */
18781869   MDRV_CPU_PROGRAM_MAP(digdug_map)
18791870
1880   MDRV_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/12, namco_51xx_intf)      /* 1.536 MHz */
1881   MDRV_NAMCO_53XX_ADD("53xx", MASTER_CLOCK/12, namco_53xx_intf)      /* 1.536 MHz */
1871   MDRV_NAMCO_51XX_ADD("51xx", MASTER_CLOCK/6/2, namco_51xx_intf)      /* 1.536 MHz */
1872   MDRV_NAMCO_53XX_ADD("53xx", MASTER_CLOCK/6/2, namco_53xx_intf)      /* 1.536 MHz */
18821873
1883   MDRV_NAMCO_06XX_ADD("06xx", "maincpu", "51xx", "53xx", NULL, NULL)
1874   MDRV_NAMCO_06XX_ADD("06xx", MASTER_CLOCK/6/64, "maincpu", "51xx", "53xx", NULL, NULL)
18841875
18851876   MDRV_QUANTUM_TIME(HZ(6000))   /* 100 CPU slices per frame - an high value to ensure proper */
18861877                     /* synchronization of the CPUs */
r4939r4940
18911882
18921883   /* video hardware */
18931884   MDRV_SCREEN_ADD("screen", RASTER)
1894   MDRV_SCREEN_REFRESH_RATE(60.606060)
1895   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
18961885   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1897   MDRV_SCREEN_SIZE(36*8, 272)      /* guess */
1898   MDRV_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 0*8, 28*8-1)
1886   MDRV_SCREEN_RAW_PARAMS(MASTER_CLOCK/3, 384, 0, 288, 264, 0, 224)
18991887
19001888   MDRV_GFXDECODE(digdug)
19011889   MDRV_PALETTE_LENGTH(16*2+64*4+64*4)
src/mame/drivers/8080bw.c
r4939r4940
19811981
19821982ROM_START( moonbase )
19831983   ROM_REGION( 0x10000, "maincpu", 0 )
1984   ROM_LOAD( "ze3-1.bin",    0x0000, 0x0400, CRC(82dbf2c7) SHA1(c767d8b866db4a5059bd79f962a90ce3a962e1e6) )
1985   ROM_LOAD( "ze3-2.bin",    0x0400, 0x0400, CRC(c867f5b4) SHA1(686318fda6edde297aecaf33f480bfa075fa6eca) )
1986   ROM_LOAD( "ze3-3.bin",    0x0800, 0x0400, CRC(cb23ccc1) SHA1(86be2d14d52b3404e1a25c573bd25b97729d82a1) )
1987   ROM_LOAD( "ze3-4.bin",    0x0c00, 0x0400, CRC(9a11abe2) SHA1(f5337183c7f279d75ddeeab24f4f132aa2ee103b) )
1988   ROM_LOAD( "ze3-5.bin",    0x1000, 0x0400, CRC(2b105ed3) SHA1(fa0767089b3aaec25be39e950e7163ecbdc2f39f) )
1989   ROM_LOAD( "ze3-6.bin",    0x1400, 0x0400, CRC(cb3d6dcb) SHA1(b4923b12a141c76b7d50274f19a3224db26a5669) )
1990   ROM_LOAD( "ze3-7.bin",    0x1800, 0x0400, CRC(774b52c9) SHA1(ddbbba874ac069fb930b364a890c45675ec389f7) )
1991   ROM_LOAD( "ze3-8.bin",    0x1c00, 0x0400, CRC(e88ea83b) SHA1(ef05be4783c860369ee5ecd4844837207e99ad9f) )
1992   ROM_LOAD( "ze3-9.bin",    0x4000, 0x0400, CRC(2dd5adfa) SHA1(62cb98cad1e48de0e0cbf30392d35834b38dadbd) )
1993   ROM_LOAD( "ze3-10.bin",   0x4400, 0x0400, CRC(1e7c22a4) SHA1(b34173375494ffbf5400dd4014a683a9807f4f08) )
1984   ROM_LOAD( "ze3-1.a4",     0x0000, 0x0400, CRC(82dbf2c7) SHA1(c767d8b866db4a5059bd79f962a90ce3a962e1e6) )
1985   ROM_LOAD( "ze3-2.c4",     0x0400, 0x0400, CRC(c867f5b4) SHA1(686318fda6edde297aecaf33f480bfa075fa6eca) )
1986   ROM_LOAD( "ze3-3.e4",     0x0800, 0x0400, CRC(cb23ccc1) SHA1(86be2d14d52b3404e1a25c573bd25b97729d82a1) )
1987   ROM_LOAD( "ze3-4.f4",     0x0c00, 0x0400, CRC(9a11abe2) SHA1(f5337183c7f279d75ddeeab24f4f132aa2ee103b) )
1988   ROM_LOAD( "ze3-5.h4",     0x1000, 0x0400, CRC(2b105ed3) SHA1(fa0767089b3aaec25be39e950e7163ecbdc2f39f) )
1989   ROM_LOAD( "ze3-6.l4",     0x1400, 0x0400, CRC(cb3d6dcb) SHA1(b4923b12a141c76b7d50274f19a3224db26a5669) )
1990   ROM_LOAD( "ze3-7.a5",     0x1800, 0x0400, CRC(774b52c9) SHA1(ddbbba874ac069fb930b364a890c45675ec389f7) )
1991   ROM_LOAD( "ze3-8.c5",     0x1c00, 0x0400, CRC(e88ea83b) SHA1(ef05be4783c860369ee5ecd4844837207e99ad9f) )
1992   ROM_LOAD( "ze3-9.e5",     0x4000, 0x0400, CRC(2dd5adfa) SHA1(62cb98cad1e48de0e0cbf30392d35834b38dadbd) )
1993   ROM_LOAD( "ze3-10.f5",    0x4400, 0x0400, CRC(1e7c22a4) SHA1(b34173375494ffbf5400dd4014a683a9807f4f08) )
19941994
19951995   ROM_REGION( 0x0800, "proms", 0 )      /* color maps player 1/player 2 */
1996   ROM_LOAD( "n02prm.6a",    0x0000, 0x0400, CRC(2bdf83a0) SHA1(01ffbd43964c41987e7d44816271308f9a70802b) )
1997   ROM_LOAD( "n01prm.6b",    0x0400, 0x0400, CRC(aac24f34) SHA1(ad110e776547fb48baac568bb50d61854537ca34) )
1996   ROM_LOAD( "cv02.h7",      0x0000, 0x0400, CRC(2bdf83a0) SHA1(01ffbd43964c41987e7d44816271308f9a70802b) ) /* NEC B406 or compatible BPROM, like the 82S137 */
1997   ROM_LOAD( "cv01.g7",      0x0400, 0x0400, CRC(aac24f34) SHA1(ad110e776547fb48baac568bb50d61854537ca34) ) /* NEC B406 or compatible BPROM, like the 82S137 */
19981998ROM_END
19991999
20002000ROM_START( invrvnge )
r4939r4940
20232023
20242024ROM_START( intruder )
20252025   ROM_REGION( 0x10000, "maincpu", 0 )
2026   ROM_LOAD( "la01-1",       0x0000, 0x0800, CRC(bedc0078) SHA1(a5bb0cbbb8e3f27d03beb8101b2be1111d73689d) )
2027   ROM_LOAD( "la02-1",       0x0800, 0x0800, CRC(43bc65c5) SHA1(5f9827c02c2d221e1607359c840374ff7fb92fbf) )
2028   ROM_LOAD( "la03-1",       0x1000, 0x0800, CRC(278ef9cf) SHA1(74a9c1d3500ea28e50d07363a547c381999c84fa) )
2029   ROM_LOAD( "la04-1",       0x1800, 0x0800, CRC(5116b234) SHA1(b165b2574cbcb26a5bb43f91df5f8be5f111f486) )
2026   ROM_LOAD( "la01-1.36",    0x0000, 0x0800, CRC(bedc0078) SHA1(a5bb0cbbb8e3f27d03beb8101b2be1111d73689d) )
2027   ROM_LOAD( "la02-1.35",    0x0800, 0x0800, CRC(43bc65c5) SHA1(5f9827c02c2d221e1607359c840374ff7fb92fbf) )
2028   ROM_LOAD( "la03-1.34",    0x1000, 0x0800, CRC(278ef9cf) SHA1(74a9c1d3500ea28e50d07363a547c381999c84fa) )
2029   ROM_LOAD( "la04-1.33",    0x1800, 0x0800, CRC(5116b234) SHA1(b165b2574cbcb26a5bb43f91df5f8be5f111f486) )
20302030ROM_END
20312031
20322032ROM_START( laser )
src/mame/drivers/esripsys.c
r4939r4940
7676 *
7777 *************************************/
7878
79static void ptm_irq(running_machine *machine, int state)
79static WRITE_LINE_DEVICE_HANDLER( ptm_irq )
8080{
81   cputag_set_input_line(machine, "sound_cpu", M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
81   cputag_set_input_line(device->machine, "sound_cpu", M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
8282}
8383
8484static const ptm6840_interface ptm_intf =
8585{
8686   XTAL_8MHz / 4,
8787   { 0, 0, 0 },
88   { NULL, NULL, NULL },
89   ptm_irq
88   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
89   DEVCB_LINE(ptm_irq)
9090};
9191
9292
r4939r4940
653653   AM_RANGE(0x200d, 0x200d) AM_WRITE(control_w)
654654   AM_RANGE(0x200e, 0x200e) AM_READWRITE(s_200e_r, s_200e_w)
655655   AM_RANGE(0x200f, 0x200f) AM_READWRITE(s_200f_r, s_200f_w)
656   AM_RANGE(0x2020, 0x2027) AM_READWRITE(ptm6840_0_r, ptm6840_0_w)
656   AM_RANGE(0x2020, 0x2027) AM_DEVREADWRITE("6840ptm", ptm6840_read, ptm6840_write)
657657   AM_RANGE(0x8000, 0x9fff) AM_ROMBANK(2)
658658   AM_RANGE(0xa000, 0xbfff) AM_ROMBANK(3)
659659   AM_RANGE(0xc000, 0xdfff) AM_ROMBANK(4)
r4939r4940
680680   fdt_b = auto_alloc_array(machine, UINT8, FDT_RAM_SIZE);
681681   cmos_ram = auto_alloc_array(machine, UINT8, CMOS_RAM_SIZE);
682682
683   ptm6840_config(machine, 0, &ptm_intf);
684
685683   memory_set_bankptr(machine, 2, &rom[0x0000]);
686684   memory_set_bankptr(machine, 3, &rom[0x4000]);
687685   memory_set_bankptr(machine, 4, &rom[0x8000]);
r4939r4940
768766
769767   MDRV_SOUND_ADD("tms5220nl", TMS5220, 640000)
770768   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
769
770   /* 6840 PTM */
771   MDRV_PTM6840_ADD("6840ptm", ptm_intf)
771772MACHINE_DRIVER_END
772773
773774
src/mame/drivers/thedeep.c
r4939r4940
352352static MACHINE_DRIVER_START( thedeep )
353353
354354   /* basic machine hardware */
355   MDRV_CPU_ADD("maincpu", Z80, 6000000)      /* 6MHz */
355   MDRV_CPU_ADD("maincpu", Z80, XTAL_12MHz/2)      /* verified on pcb */
356356   MDRV_CPU_PROGRAM_MAP(main_map)
357357   MDRV_CPU_VBLANK_INT_HACK(thedeep_interrupt,2)   /* IRQ by MCU, NMI by vblank (maskable) */
358358
359    MDRV_CPU_ADD("audiocpu", M65C02, 2000000)   /* 2MHz */
359    MDRV_CPU_ADD("audiocpu", M65C02, XTAL_12MHz/8)      /* verified on pcb */
360360   MDRV_CPU_PROGRAM_MAP(audio_map)
361361   /* IRQ by YM2203, NMI by when sound latch written by main cpu */
362362
363   /* CPU3 is a i8751 */
363   /* CPU3 is a i8751 running at 8Mhz (8mhz xtal)*/
364364
365365   MDRV_MACHINE_RESET(thedeep)
366366
r4939r4940
382382   /* sound hardware */
383383   MDRV_SPEAKER_STANDARD_MONO("mono")
384384
385   MDRV_SOUND_ADD("ym", YM2203, 3000000)
385   MDRV_SOUND_ADD("ym", YM2203, XTAL_12MHz/4)  /* verified on pcb */
386386   MDRV_SOUND_CONFIG(thedeep_ym2203_intf)
387387   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
388388MACHINE_DRIVER_END
src/mame/drivers/zr107.c
r4939r4940
282282
283283static CUSTOM_INPUT( adcdo_r )
284284{
285   return adc083x_do_read(field->port->machine, 0);
285   const device_config *adc0838 = devtag_get_device(field->port->machine, "adc0838");
286   return adc083x_do_read(adc0838, 0);
286287}
287288
288289static READ8_HANDLER( sysreg_r )
289290{
290291   UINT32 r = 0;
292   const device_config *adc0838 = devtag_get_device(space->machine, "adc0838");
291293   static const char *const portnames[] = { "IN0", "IN1", "IN2", "IN3" };
292294
293295   switch (offset)
r4939r4940
306308                0x20 = SARS (A/D busy flag)
307309                0x10 = EEPDO (EEPROM DO)
308310            */
309         r = (adc083x_sars_read(space->machine, 0) << 5) | (eeprom_read_bit() << 4);
311         r = (adc083x_sars_read(adc0838, 0) << 5) | (eeprom_read_bit() << 4);
310312         break;
311313
312314      case 5:   /* Parallel data port */
r4939r4940
317319
318320static WRITE8_HANDLER( sysreg_w )
319321{
322   const device_config *adc0838 = devtag_get_device(space->machine, "adc0838");
323
320324   switch (offset)
321325   {
322326      case 0:   /* LED Register 0 */
r4939r4940
365369         if (data & 0x40)   /* CG Board 0 IRQ Ack */
366370            cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_IRQ0, CLEAR_LINE);
367371         set_cgboard_id((data >> 4) & 3);
368         adc083x_cs_write(space->machine, 0, (data >> 2) & 1);
369         adc083x_di_write(space->machine, 0, (data >> 1) & 1);
370         adc083x_clk_write(space->machine, 0, (data >> 0) & 1);
372         adc083x_cs_write(adc0838, 0, (data >> 2) & 1);
373         adc083x_di_write(adc0838, 0, (data >> 1) & 1);
374         adc083x_clk_write(adc0838, 0, (data >> 0) & 1);
371375         mame_printf_debug("System register 1 = %02X\n", data);
372376         break;
373377
r4939r4940
382386   }
383387}
384388
385static double adc0838_callback(running_machine *machine, int input)
386{
387   switch (input)
388   {
389      case ADC083X_CH0:
390         return (double)(5 * input_port_read(machine, "ANALOG1")) / 255.0;
391      case ADC083X_CH1:
392         return (double)(5 * input_port_read(machine, "ANALOG2")) / 255.0;
393      case ADC083X_CH2:
394         return (double)(5 * input_port_read(machine, "ANALOG3")) / 255.0;
395      case ADC083X_CH3:
396         return 0;
397      case ADC083X_COM:
398         return 0;
399      case ADC083X_AGND:
400         return 0;
401      case ADC083X_VREF:
402         return 5;
403   }
404   return 0;
405}
406
407389static int ccu_vcth = 0;
408390static int ccu_vctl = 0;
409391static READ32_HANDLER( ccu_r )
r4939r4940
697679   BOOT_MODE_EPROM
698680};
699681
682
683/* ADC0838 Interface */
684
685static double adc0838_callback( const device_config *device, UINT8 input )
686{
687   switch (input)
688   {
689   case ADC083X_CH0:
690      return (double)(5 * input_port_read(device->machine, "ANALOG1")) / 255.0;
691   case ADC083X_CH1:
692      return (double)(5 * input_port_read(device->machine, "ANALOG2")) / 255.0;
693   case ADC083X_CH2:
694      return (double)(5 * input_port_read(device->machine, "ANALOG3")) / 255.0;
695   case ADC083X_CH3:
696      return 0;
697   case ADC083X_COM:
698      return 0;
699   case ADC083X_AGND:
700      return 0;
701   case ADC083X_VREF:
702      return 5;
703   }
704   return 0;
705}
706
707
708static const adc0831_interface zr107_adc_interface = {
709   adc0838_callback
710};
711
712
700713/* PowerPC interrupts
701714
702715    IRQ0:  Vblank
r4939r4940
756769   MDRV_SOUND_CONFIG(k054539_config)
757770   MDRV_SOUND_ROUTE(0, "lspeaker", 0.75)
758771   MDRV_SOUND_ROUTE(1, "rspeaker", 0.75)
772
773   MDRV_ADC0838_ADD("adc0838", zr107_adc_interface)
759774MACHINE_DRIVER_END
760775
761776static MACHINE_DRIVER_START( jetwave )
r4939r4940
801816   MDRV_SOUND_CONFIG(k054539_config)
802817   MDRV_SOUND_ROUTE(0, "lspeaker", 0.75)
803818   MDRV_SOUND_ROUTE(1, "rspeaker", 0.75)
819
820   MDRV_ADC0838_ADD("adc0838", zr107_adc_interface)
804821MACHINE_DRIVER_END
805822
806823/*****************************************************************************/
r4939r4940
826843   K001005_preprocess_texture_data(memory_region(machine, "gfx1"), memory_region_length(machine, "gfx1"), 0);
827844
828845   K056800_init(machine, sound_irq_callback);
829
830   adc083x_init(machine, 0, ADC0838, adc0838_callback);
831846}
832847
833848static DRIVER_INIT(zr107)
src/mame/drivers/ksys573.c
r4939r4940
351351static READ32_HANDLER( jamma_r )
352352{
353353   running_machine *machine = space->machine;
354   const device_config *adc0834 = devtag_get_device(space->machine, "adc0834");
354355   UINT32 data = 0;
355356
356357   switch (offset)
r4939r4940
368369         data |= ds2401_read( machine, security_cart_number ) << 14;
369370      }
370371
371      data |= adc083x_do_read( machine, 0 ) << 16;
372      data |= adc083x_do_read(adc0834, 0) << 16;
372373
373374      switch( chiptype[ security_cart_number ] )
374375      {
r4939r4940
411412static WRITE32_HANDLER( jamma_w )
412413{
413414   running_machine *machine = space->machine;
415   const device_config *adc0834 = devtag_get_device(space->machine, "adc0834");
414416   verboselog( machine, 2, "jamma_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
415417
416418   switch( offset )
417419   {
418420   case 0:
419      adc083x_cs_write( machine, 0, ( data >> 1 ) & 1 );
420      adc083x_clk_write( machine, 0, ( data >> 2 ) & 1 );
421      adc083x_di_write( machine, 0, ( data >> 0 ) & 1 );
422      adc083x_se_write( machine, 0, 0 );
421      adc083x_cs_write(adc0834, 0, (data >> 1) & 1);
422      adc083x_clk_write(adc0834, 0, (data >> 2) & 1);
423      adc083x_di_write(adc0834, 0, (data >> 0) & 1);
424      adc083x_se_write(adc0834, 0, 0);
423425      break;
424426
425427   default:
r4939r4940
13841386ADDRESS_MAP_END
13851387
13861388
1389
13871390static void flash_init( running_machine *machine )
13881391{
13891392   int i;
r4939r4940
14401443   state_save_register_global(machine,  control );
14411444}
14421445
1443static double analogue_inputs_callback( running_machine *machine, int input )
1444{
1445   switch( input )
1446   {
1447   case ADC083X_CH0:
1448      return (double) ( input_port_read_safe(machine,  "analog0", 0 ) * 5 ) / 255;
1449   case ADC083X_CH1:
1450      return (double) ( input_port_read_safe(machine,  "analog1", 0 ) * 5 ) / 255;
1451   case ADC083X_CH2:
1452      return (double) ( input_port_read_safe(machine,  "analog2", 0 ) * 5 ) / 255;
1453   case ADC083X_CH3:
1454      return (double) ( input_port_read_safe(machine,  "analog3", 0 ) * 5 ) / 255;
1455   case ADC083X_AGND:
1456      return 0;
1457   case ADC083X_VREF:
1458      return 5;
1459   }
1460   return 0;
1461}
1462
14631446static void *atapi_get_device(void)
14641447{
14651448   void *ret;
r4939r4940
15701553   state_save_register_item_array( machine, "KSYS573", NULL, 0, m_p_n_root_target );
15711554   state_save_register_item_array( machine, "KSYS573", NULL, 0, m_p_n_root_start );
15721555
1573   adc083x_init( machine, 0, ADC0834, analogue_inputs_callback );
15741556   flash_init(machine);
15751557}
15761558
r4939r4940
16621644
16631645static READ32_HANDLER( ge765pwbba_r )
16641646{
1647   const device_config *upd4701 = devtag_get_device(space->machine, "upd4701");
16651648   UINT32 data = 0;
16661649
1667   switch( offset )
1650   switch (offset)
16681651   {
16691652   case 0x26:
1670      uPD4701_y_add( 0, input_port_read_safe(space->machine,  "uPD4701_y", 0 ) );
1671      uPD4701_switches_set( 0, input_port_read_safe(space->machine,  "uPD4701_switches", 0 ) );
1653      upd4701_y_add(upd4701, 0, input_port_read_safe(space->machine, "uPD4701_y", 0), 0xffff);
1654      upd4701_switches_set(upd4701, 0, input_port_read_safe(space->machine, "uPD4701_switches", 0));
16721655
1673      uPD4701_cs_w( 0, 0 );
1674      uPD4701_xy_w( 0, 1 );
1656      upd4701_cs_w(upd4701, 0, 0);
1657      upd4701_xy_w(upd4701, 0, 1);
16751658
1676      if( ACCESSING_BITS_0_7 )
1659      if (ACCESSING_BITS_0_7)
16771660      {
1678         uPD4701_ul_w( 0, 0 );
1679         data |= uPD4701_d_r( 0 ) << 0;
1661         upd4701_ul_w(upd4701, 0, 0);
1662         data |= upd4701_d_r(upd4701, 0, 0xffff) << 0;
16801663      }
16811664
1682      if( ACCESSING_BITS_16_23 )
1665      if (ACCESSING_BITS_16_23)
16831666      {
1684         uPD4701_ul_w( 0, 1 );
1685         data |= uPD4701_d_r( 0 ) << 16;
1667         upd4701_ul_w(upd4701, 0, 1);
1668         data |= upd4701_d_r(upd4701, 0, 0xffff) << 16;
16861669      }
16871670
1688      uPD4701_cs_w( 0, 1 );
1671      upd4701_cs_w(upd4701, 0, 1);
16891672      break;
16901673
16911674   default:
1692      verboselog( space->machine, 0, "ge765pwbba_r: unhandled offset %08x %08x\n", offset, mem_mask );
1675      verboselog(space->machine, 0, "ge765pwbba_r: unhandled offset %08x %08x\n", offset, mem_mask);
16931676      break;
16941677   }
16951678
1696   verboselog( space->machine, 2, "ge765pwbba_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
1679   verboselog(space->machine, 2, "ge765pwbba_r( %08x, %08x ) %08x\n", offset, mem_mask, data);
16971680   return data;
16981681}
16991682
17001683static WRITE32_HANDLER( ge765pwbba_w )
17011684{
1702   switch( offset )
1685   const device_config *upd4701 = devtag_get_device(space->machine, "upd4701");
1686   switch (offset)
17031687   {
17041688   case 0x04:
17051689      break;
17061690
17071691   case 0x20:
1708      if( ACCESSING_BITS_0_7 )
1692      if (ACCESSING_BITS_0_7)
17091693      {
1710         output_set_value( "motor", data & 0xff );
1694         output_set_value("motor", data & 0xff);
17111695      }
17121696      break;
17131697
17141698   case 0x22:
1715      if( ACCESSING_BITS_0_7 )
1699      if (ACCESSING_BITS_0_7)
17161700      {
1717         output_set_value( "brake", data & 0xff );
1701         output_set_value("brake", data & 0xff);
17181702      }
17191703      break;
17201704
17211705   case 0x28:
1722      if( ACCESSING_BITS_0_7 )
1706      if (ACCESSING_BITS_0_7)
17231707      {
1724         uPD4701_resety_w( 0, 1 );
1725         uPD4701_resety_w( 0, 0 );
1708         upd4701_resety_w(upd4701, 0, 1);
1709         upd4701_resety_w(upd4701, 0, 0);
17261710      }
17271711      break;
17281712
17291713   default:
1730      verboselog( space->machine, 0, "ge765pwbba_w: unhandled offset %08x %08x %08x\n", offset, mem_mask, data );
1714      verboselog(space->machine, 0, "ge765pwbba_w: unhandled offset %08x %08x %08x\n", offset, mem_mask, data);
17311715      break;
17321716   }
17331717
1734   verboselog( space->machine, 2, "ge765pwbba_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
1718   verboselog(space->machine, 2, "ge765pwbba_w( %08x, %08x, %08x )\n", offset, mem_mask, data);
17351719}
17361720
17371721static DRIVER_INIT( ge765pwbba )
17381722{
17391723   DRIVER_INIT_CALL(konami573);
1740
1741   uPD4701_init( machine, 0 );
1742
17431724   memory_install_readwrite32_handler( cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x1f640000, 0x1f6400ff, 0, 0, ge765pwbba_r, ge765pwbba_w );
17441725}
17451726
r4939r4940
27832764   state_save_register_global(machine,  salarymc_lamp_clk );
27842765}
27852766
2767
2768
2769/* ADC0834 Interface */
2770
2771static double analogue_inputs_callback( const device_config *device, UINT8 input )
2772{
2773   switch (input)
2774   {
2775   case ADC083X_CH0:
2776      return (double)(5 * input_port_read_safe(device->machine,  "analog0", 0)) / 255.0;
2777   case ADC083X_CH1:
2778      return (double)(5 * input_port_read_safe(device->machine,  "analog1", 0)) / 255.0;
2779   case ADC083X_CH2:
2780      return (double)(5 * input_port_read_safe(device->machine,  "analog2", 0)) / 255.0;
2781   case ADC083X_CH3:
2782      return (double)(5 * input_port_read_safe(device->machine,  "analog3", 0)) / 255.0;
2783   case ADC083X_AGND:
2784      return 0;
2785   case ADC083X_VREF:
2786      return 5;
2787   }
2788   return 0;
2789}
2790
2791
2792static const adc0831_interface konami573_adc_interface = {
2793   analogue_inputs_callback
2794};
2795
27862796static MACHINE_DRIVER_START( konami573 )
27872797   /* basic machine hardware */
27882798   MDRV_CPU_ADD("maincpu",  PSXCPU, XTAL_67_7376MHz )
r4939r4940
28192829   MDRV_SOUND_ROUTE( 1, "rspeaker", 1.0 )
28202830
28212831   MDRV_M48T58_ADD( "m48t58" )
2832
2833   MDRV_ADC0834_ADD( "adc0834", konami573_adc_interface )
28222834MACHINE_DRIVER_END
28232835
2836
2837static MACHINE_DRIVER_START( k573bait )
2838   MDRV_IMPORT_FROM(konami573)
2839
2840   /* Additional NEC Encoder */
2841   MDRV_UPD4701_ADD( "upd4701" )
2842MACHINE_DRIVER_END
2843
28242844static INPUT_PORTS_START( konami573 )
28252845   PORT_START("IN0")
28262846   PORT_BIT( 0xffffffff, IP_ACTIVE_LOW, IPT_UNKNOWN )
r4939r4940
30703090   PORT_BIT( 0x08000000, IP_ACTIVE_LOW, IPT_UNUSED ) /* P2 BUTTON6 */
30713091INPUT_PORTS_END
30723092
3093
30733094#define SYS573_BIOS_A ROM_LOAD( "700a01.22g",   0x0000000, 0x080000, CRC(11812ef8) SHA1(e1284add4aaddd5337bd7f4e27614460d52b5b48))
30743095
30753096// BIOS
r4939r4940
45424563GAME( 1998, sys573,   0,        konami573, konami573, konami573,  ROT0, "Konami", "System 573 BIOS", GAME_IS_BIOS_ROOT )
45434564
45444565GAME( 1998, darkhleg, sys573,   konami573, konami573, konami573,  ROT0, "Konami", "Dark Horse Legend (GX706 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4545GAME( 1998, fbaitbc,  sys573,   konami573, fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - A Bass Challenge (GE765 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4546GAME( 1998, bassangl, fbaitbc,  konami573, fbaitbc,   ge765pwbba, ROT0, "Konami", "Bass Angler (GE765 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4566GAME( 1998, fbaitbc,  sys573,   k573bait,  fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - A Bass Challenge (GE765 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4567GAME( 1998, bassangl, fbaitbc,  k573bait,  fbaitbc,   ge765pwbba, ROT0, "Konami", "Bass Angler (GE765 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45474568GAME( 1998, pbballex, sys573,   konami573, konami573, konami573,  ROT0, "Konami", "Powerful Pro Baseball EX (GX802 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45484569GAME( 1998, konam80s, sys573,   konami573, konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. EAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45494570GAME( 1998, konam80u, konam80s, konami573, konami573, konami573,  ROT90, "Konami", "Konami 80's AC Special (GC826 VER. UAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
r4939r4940
45564577GAME( 1998, ddrja,    dstage,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
45574578GAME( 1998, ddrjb,    dstage,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GC845 VER. JAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
45584579GAME( 1999, ddra,     dstage,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution (GN845 VER. AAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4559GAME( 1998, fbait2bc, sys573,   konami573, fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait 2 - A Bass Challenge (GE865 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4580GAME( 1998, fbait2bc, sys573,   k573bait, fbaitbc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait 2 - A Bass Challenge (GE865 VER. UAB)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45604581GAME( 1999, drmn,     sys573,   konami573, drmn,      drmn,       ROT0, "Konami", "DrumMania (GQ881 VER. JAD)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
45614582GAME( 1999, gtrfrks,  sys573,   konami573, gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. EAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45624583GAME( 1999, gtrfrksu, gtrfrks,  konami573, gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. UAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45634584GAME( 1999, gtrfrksj, gtrfrks,  konami573, gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. JAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45644585GAME( 1999, gtrfrksa, gtrfrks,  konami573, gtrfrks,   gtrfrks,    ROT0, "Konami", "Guitar Freaks (GQ886 VER. AAC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4565GAME( 1999, fbaitmc,  sys573,   konami573, fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. EA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4566GAME( 1999, fbaitmcu, fbaitmc,  konami573, fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. UA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4567GAME( 1999, fbaitmcj, fbaitmc,  konami573, fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. JA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4568GAME( 1999, fbaitmca, fbaitmc,  konami573, fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. AA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4586GAME( 1999, fbaitmc,  sys573,   k573bait,  fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. EA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4587GAME( 1999, fbaitmcu, fbaitmc,  k573bait,  fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. UA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4588GAME( 1999, fbaitmcj, fbaitmc,  k573bait,  fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. JA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
4589GAME( 1999, fbaitmca, fbaitmc,  k573bait,  fbaitmc,   ge765pwbba, ROT0, "Konami", "Fisherman's Bait - Marlin Challenge (GX889 VER. AA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45694590GAME( 1999, ddr2m,    sys573,   konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix (GN895 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45704591GAME( 1999, ddrbocd,  ddr2m,    konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution Best of Cool Dancers (GE892 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
45714592GAME( 1999, ddr2ml,   ddr2m,    konami573, ddr,       ddr,        ROT0, "Konami", "Dance Dance Revolution 2nd Mix - Link Ver (GE885 VER. JAA)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
src/mame/drivers/srumbler.c
r4939r4940
66
77  M6809 for game, Z80 and YM-2203 for sound.
88
92009/06 - DIP Location and Defaults verified against Speed Rumbler manual.
10
911***************************************************************************/
1012
1113#include "driver.h"
r4939r4940
143145   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
144146
145147   PORT_START("DSW1")
146   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_B ) )
148   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_B ) )  PORT_DIPLOCATION("SW1:1,2,3")
147149   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
148150   PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) )
149151   PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
r4939r4940
152154   PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
153155   PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
154156   PORT_DIPSETTING(    0x03, DEF_STR( 1C_6C ) )
155   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_A ) )
157   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_A ) )  PORT_DIPLOCATION("SW1:4,5,6")
156158   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )
157159   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )
158160   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
r4939r4940
161163   PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )
162164   PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
163165   PORT_DIPSETTING(    0x18, DEF_STR( 1C_6C ) )
164   PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
165   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )
166   PORT_SERVICE( 0x40, IP_ACTIVE_LOW )  PORT_DIPLOCATION("SW1:7")
167   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )  PORT_DIPLOCATION("SW1:8")
166168   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
167169   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
168170
169171   PORT_START("DSW2")
170   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
172   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )  PORT_DIPLOCATION("SW2:1,2")
171173   PORT_DIPSETTING(    0x03, "3" )
172174   PORT_DIPSETTING(    0x02, "4" )
173175   PORT_DIPSETTING(    0x01, "5" )
174176   PORT_DIPSETTING(    0x00, "7" )
175   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )
177   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Cabinet ) )  PORT_DIPLOCATION("SW2:3")
176178   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
177179   PORT_DIPSETTING(    0x04, DEF_STR( Cocktail ) )
178   PORT_DIPNAME( 0x18, 0x18, DEF_STR( Bonus_Life ) )
180   PORT_DIPNAME( 0x18, 0x10, DEF_STR( Bonus_Life ) )  PORT_DIPLOCATION("SW2:4,5")
179181   PORT_DIPSETTING(    0x18, "20k 70k and every 70k" )
180182   PORT_DIPSETTING(    0x10, "30k 80k and every 80k" )
181183   PORT_DIPSETTING(    0x08, "20k 80k" )
182184   PORT_DIPSETTING(    0x00, "30k 80k" )
183   PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )
185   PORT_DIPNAME( 0x60, 0x60, DEF_STR( Difficulty ) )  PORT_DIPLOCATION("SW2:6,7")
184186   PORT_DIPSETTING(    0x40, DEF_STR( Easy ) )
185187   PORT_DIPSETTING(    0x60, DEF_STR( Normal ) )
186   PORT_DIPSETTING(    0x20, DEF_STR( Hard ) )
187   PORT_DIPSETTING(    0x00, DEF_STR( Very_Hard ) )
188   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
188   PORT_DIPSETTING(    0x20, DEF_STR( Difficult ) )
189   PORT_DIPSETTING(    0x00, DEF_STR( Very_Difficult ) )
190   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Allow_Continue ) )  PORT_DIPLOCATION("SW2:8")
189191   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
190192   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
191193INPUT_PORTS_END
src/mame/drivers/olibochu.c
r4939r4940
88- main->sound cpu communication is completely wrong, commands don't play the
99  intended sound.
1010
11============================================================================
12PSG table:
13data0 |data1   |sample            | possible data trigger
14----------------------------------------------------------
150x80  |0x00    | coin             |
160x08  |0x00    | opening melody   |
170x40  |0x00    | bgm              |
180x04  |0x00    | hi-score melody  |
190x02  |0x00    | ending melody    |
200x01  |0x00    | spot melody      |
210x10  |0x00    | clear melody     |
220x20  |0x00    | race trap melody |
230x00  |0x80    | extend sound     |
240x00  |0x40    | oli paralyze     |
250x00  |0x04    | chu out          |
260x00  |0x08    | mystery sound    |
270x00  |0x01    | oli out          |
280x00  |0x10    | chu has food     |
290x00  |0x00    | <stop playing>   |
30-----------------------------------------------------------
31       0x02?                        *0xb doesn't do nothing
32       0x20?                        *0xc doesn't do nothing
33
34$7004 writes, related to $7000 reads
350x00-0x0f <don't care (retains previous value>
360x10-0x1f 0x28
370x20-0x2f 0x00
380x30-0x3f 0x48
390x40-0x4f 0x00
400x50-0x5f 0x80
410x60-0x6f 0x3a
420x70-0x7f 0x70
430x80-0x8f 0x0f
440x90-0x9f 0x0a
450xa0-0xaf 0x3a
460xb0-0xbf 0x61
470xc0-0xcf 0xca
480xd0-0xdf 0x01
490xe0-0xef 0x14
500xf0-0xff 0x32
51
1152***************************************************************************/
1253
1354#include "driver.h"
r4939r4940
181222   AM_RANGE(0x0000, 0x7fff) AM_ROM
182223   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(olibochu_videoram_w) AM_BASE(&videoram)
183224   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(olibochu_colorram_w) AM_BASE(&colorram)
225   AM_RANGE(0x9000, 0x903f) AM_RAM //???
226   AM_RANGE(0x9800, 0x983f) AM_RAM //???
184227   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
185228   AM_RANGE(0xa001, 0xa001) AM_READ_PORT("IN1")
186229   AM_RANGE(0xa002, 0xa002) AM_READ_PORT("IN2")
r4939r4940
199242   AM_RANGE(0x6000, 0x63ff) AM_RAM
200243   AM_RANGE(0x7000, 0x7000) AM_READ(soundlatch_r)   /* likely ay8910 input port, not direct */
201244   AM_RANGE(0x7000, 0x7001) AM_DEVWRITE("ay", ay8910_address_data_w)
245   AM_RANGE(0x7004, 0x7004) AM_WRITENOP //sound filter?
246   AM_RANGE(0x7006, 0x7006) AM_WRITENOP //irq ack?
202247ADDRESS_MAP_END
203248
204249
src/mame/drivers/taito_z.c
r4939r4940
27882788static void irqhandlerb(const device_config *device, int irq)
27892789{
27902790   // DG: this is probably specific to Z80 and wrong?
2791//  cpu_set_input_line(device->machine->cpu[1],0,irq ? ASSERT_LINE : CLEAR_LINE);
2791//  cpu_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
27922792}
27932793
27942794static const ym2610_interface ym2610_config =
src/mame/drivers/superqix.c
r4939r4940
14361436GAME( 1986, pbillian, 0,        pbillian, pbillian, pbillian, ROT0,  "Taito", "Prebillian", GAME_SUPPORTS_SAVE )
14371437GAME( 1987, hotsmash, 0,        hotsmash, hotsmash, hotsmash, ROT90, "Taito", "Vs. Hot Smash", GAME_SUPPORTS_SAVE )
14381438GAME( 1987, sqix,     0,        sqix,     superqix, sqix,     ROT90, "Taito", "Super Qix (World, Rev 2)", GAME_SUPPORTS_SAVE )
1439GAME( 1987, sqixr1,   sqix,     sqix,     superqix, sqixa,    ROT90, "Taito", "Super Qix (World, Rev 1)", GAME_SUPPORTS_SAVE )
1439GAME( 1987, sqixr1,   sqix,     sqix,     superqix, sqix,     ROT90, "Taito", "Super Qix (World, Rev 1)", GAME_SUPPORTS_SAVE )
14401440GAME( 1987, sqixu,    sqix,     sqixu,    superqix, 0,        ROT90, "Taito (Romstar License)", "Super Qix (US)", GAME_SUPPORTS_SAVE )
14411441GAME( 1987, sqixb1,   sqix,     sqix,     superqix, sqixa,    ROT90, "bootleg", "Super Qix (bootleg set 1)", GAME_SUPPORTS_SAVE )
14421442GAME( 1987, sqixb2,   sqix,     sqixbl,   superqix, 0,        ROT90, "bootleg", "Super Qix (bootleg set 2)", GAME_SUPPORTS_SAVE )
src/mame/drivers/playch10.c
r4939r4940
684684};
685685
686686
687/* RP5H01 interface */
688static const rp5h01_interface rp5h01_intf =
689{
690   "user1",
691   0
692};
693
687694static MACHINE_DRIVER_START( playch10 )
688695   // basic machine hardware
689696   MDRV_CPU_ADD("maincpu", Z80, 8000000/2)   // 4 MHz
r4939r4940
727734
728735   MDRV_SOUND_ADD("dac", DAC, 0)
729736   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
737
738   MDRV_RP5H01_ADD("rp5h01", rp5h01_intf)
730739MACHINE_DRIVER_END
731740
732741static MACHINE_DRIVER_START( playchnv )
src/mame/drivers/badlands.c
r4939r4940
192192
193193static void update_interrupts(running_machine *machine)
194194{
195   cpu_set_input_line(machine->cpu[0], 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE);
196   cpu_set_input_line(machine->cpu[0], 2, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE);
195   cputag_set_input_line(machine, "maincpu", 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE);
196   cputag_set_input_line(machine, "maincpu", 2, atarigen_sound_int_state ? ASSERT_LINE : CLEAR_LINE);
197197}
198198
199199
200200static void scanline_update(const device_config *screen, int scanline)
201201{
202   const address_space *space = cpu_get_address_space(screen->machine->cpu[1], ADDRESS_SPACE_PROGRAM);
202   const address_space *space = cputag_get_address_space(screen->machine, "audiocpu", ADDRESS_SPACE_PROGRAM);
203203
204204   /* sound IRQ is on 32V */
205205   if (scanline & 32)
206206      atarigen_6502_irq_ack_r(space, 0);
207207   else if (!(input_port_read(screen->machine, "FE4000") & 0x40))
208      atarigen_6502_irq_gen(screen->machine->cpu[1]);
208      atarigen_6502_irq_gen(cputag_get_cpu(screen->machine, "audiocpu"));
209209}
210210
211211
r4939r4940
217217   atarigen_interrupt_reset(update_interrupts);
218218   atarigen_scanline_timer_reset(machine->primary_screen, scanline_update, 32);
219219
220   atarigen_sound_io_reset(machine->cpu[1]);
220   atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu"));
221221   memcpy(bank_base, &bank_source_data[0x0000], 0x1000);
222222}
223223
r4939r4940
676676
677677static void update_interrupts_bootleg(running_machine *machine)
678678{
679   cpu_set_input_line(machine->cpu[0], 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE);
679   cputag_set_input_line(machine, "maincpu", 1, atarigen_video_int_state ? ASSERT_LINE : CLEAR_LINE);
680680}
681681
682682
r4939r4940
686686//  if (scanline & 32)
687687//      atarigen_6502_irq_ack_r(screen->machine, 0);
688688//  else if (!(input_port_read(machine, "FE4000") & 0x40))
689//      atarigen_6502_irq_gen(screen->machine->cpu[1]);
689//      atarigen_6502_irq_gen(cputag_get_cpu(screen->machine, "audiocpu"));
690690}
691691
692692
r4939r4940
699699   atarigen_interrupt_reset(update_interrupts_bootleg);
700700   atarigen_scanline_timer_reset(machine->primary_screen, scanline_update_bootleg, 32);
701701
702//  atarigen_sound_io_reset(machine->cpu[1]);
702//  atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu"));
703703//  memcpy(bank_base, &bank_source_data[0x0000], 0x1000);
704704}
705705
src/mame/drivers/boogwing.c
r4939r4940
385385   ROM_LOAD( "kj-00.15n",    0x000000, 0x00400, CRC(add4d50b) SHA1(080e5a8192a146d5141aef5c8d9996ddf8cd3ab4) )
386386ROM_END
387387
388ROM_START( boogwina )
388ROM_START( boogwina ) /* VER 1.5 ASA 92.12.07 */
389389   ROM_REGION( 0x100000, "maincpu", 0 ) /* DE102 code (encrypted) */
390390   ROM_LOAD16_BYTE( "km_00-2.2b",    0x000000, 0x040000, CRC(71ab71c6) SHA1(00bfd71dd9ae5f12c574ab0ecc07d85898930c4b) )
391391   ROM_LOAD16_BYTE( "km_02-2.2e",    0x000001, 0x040000, CRC(e90f07f9) SHA1(1e8bd3983ed875f4752cbf2ab1c7e748d3df019c) )
src/mame/drivers/mirax.c
r4939r4940
7575
7676static VIDEO_UPDATE(mirax)
7777{
78   const gfx_element *gfx = screen->machine->gfx[0];
79   int count = 0x00000;
80
81   int y,x;
82
83
84   for (y=0;y<32;y++)
85   {
86      for (x=0;x<32;x++)
87      {
88         int tile = videoram[count];
89         //int colour = tile>>12;
90         drawgfx(bitmap,gfx,tile & 0xff,0,0,0,x*8,y*8,cliprect,TRANSPARENCY_NONE,0);
91
92         count++;
93      }
94   }
95
96
97
7898#ifdef MAME_DEBUG
7999   //audio tester
80100   if(input_code_pressed_once(KEYCODE_Q))
81101   {
82      cputag_set_input_line(screen->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
102      cputag_set_input_line(screen->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
83103   }
84104#endif
85105   return 0;
r4939r4940
112132
113133static WRITE8_DEVICE_HANDLER(ay_sel)
114134{
115   if(cpu_get_previouspc(cputag_get_cpu(device->machine, "maincpu"))==0x309)
135   if(cpu_get_previouspc(cputag_get_cpu(device->machine, "audiocpu"))==0x309)
116136   {
117137      ay8910_address_w(device,0,nAyCtrl);
118138      ay8910_data_w(device,0,nAyData);
119139   }
120140}
121141
122static ADDRESS_MAP_START( memory_map, ADDRESS_SPACE_PROGRAM, 8 )
142static READ8_HANDLER( unk_r )
143{
144   return mame_rand(space->machine);
145}
146
147static ADDRESS_MAP_START( mirax_main_map, ADDRESS_SPACE_PROGRAM, 8 )
148   AM_RANGE(0x0000, 0xbfff) AM_ROM AM_WRITENOP //shoudn't write there!
149   //AM_RANGE(0xc000, 0xc7ff) AM_RAM
150   //AM_RANGE(0xc800, 0xcfff) AM_RAM //probably spriteram
151   AM_RANGE(0xd000, 0xd7ff) AM_RAM
152   //AM_RANGE(0xd800, 0xdfff) AM_RAM
153   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE(&videoram)
154   AM_RANGE(0xf300, 0xf300) AM_READ(unk_r) //watchdog?
155ADDRESS_MAP_END
156
157static ADDRESS_MAP_START( mirax_io_map, ADDRESS_SPACE_IO, 8 )
158
159ADDRESS_MAP_END
160
161static ADDRESS_MAP_START( mirax_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
123162   AM_RANGE(0x0000, 0x1fff) AM_ROM
124163   AM_RANGE(0x8000, 0x8fff) AM_RAM
125164   AM_RANGE(0xa000, 0xa000) AM_READ(snd_read)
r4939r4940
136175
137176ADDRESS_MAP_END
138177
139static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 )
178static ADDRESS_MAP_START( mirax_sound_io_map, ADDRESS_SPACE_IO, 8 )
140179
141180ADDRESS_MAP_END
142181
r4939r4940
204243}
205244
206245static MACHINE_DRIVER_START( mirax )
207   MDRV_CPU_ADD("maincpu", Z80, 12000000) // audio cpu ?
208   MDRV_CPU_PROGRAM_MAP(memory_map)
209   MDRV_CPU_IO_MAP(io_map)
246   MDRV_CPU_ADD("maincpu", Z80, 12000000) // ceramic potted module, encrypted z80
247   MDRV_CPU_PROGRAM_MAP(mirax_main_map)
248   MDRV_CPU_IO_MAP(mirax_io_map)
249   //MDRV_CPU_VBLANK_INT("screen",nmi_line_pulse)
250
251   MDRV_CPU_ADD("audiocpu", Z80, 12000000) // audio cpu ?
252   MDRV_CPU_PROGRAM_MAP(mirax_sound_map)
253   MDRV_CPU_IO_MAP(mirax_sound_io_map)
210254   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold, 2)
211255
212256   /* video hardware */
r4939r4940
234278MACHINE_DRIVER_END
235279
236280ROM_START( mirax )
237   ROM_REGION( 0x10000, "maincpu", 0 )
281   ROM_REGION( 0xc000, "maincpu", 0 ) // encrypted code
282   ROM_LOAD( "mxp5-42.rom",   0x0000, 0x4000, CRC(716410a0) SHA1(55171376e1e164b1d5e728789da6e04a3a33c172) )
283   ROM_LOAD( "mxr5-4v.rom",   0x4000, 0x4000, CRC(c9484fc3) SHA1(101c5e4b9d49d2424ad80970eb3bdb87949a9966) )
284   ROM_LOAD( "mxs5-4v.rom",   0x8000, 0x4000, CRC(e0085f91) SHA1(cf143b94048e1ebb5c899b94b500e193dfd42e18) )
285
286   ROM_REGION( 0x10000, "audiocpu", 0 )
238287   ROM_LOAD( "mxr2-4v.rom",   0x0000, 0x2000, CRC(cd2d52dc) SHA1(0d4181dc68beac338f47a2065c7b755008877896) )
239288
240289   ROM_REGION( 0xc000, "gfx1", ROMREGION_DISPOSE )
r4939r4940
252301   ROM_LOAD( "mxi3-4v.rom",   0x4000, 0x4000, CRC(20fb2099) SHA1(da6bbd5d2218ba49b8ef98e7affdcab912f84ade) )
253302   ROM_LOAD( "mxl3-4v.rom",   0x8000, 0x4000, CRC(918487aa) SHA1(47ba6914722a253f65c733b5edff4d15e73ea6c2) )
254303
255   ROM_REGION( 0xc000, "user1", 0 )
256   ROM_LOAD( "mxp5-42.rom",   0x0000, 0x4000, CRC(716410a0) SHA1(55171376e1e164b1d5e728789da6e04a3a33c172) )
257   ROM_LOAD( "mxr5-4v.rom",   0x4000, 0x4000, CRC(c9484fc3) SHA1(101c5e4b9d49d2424ad80970eb3bdb87949a9966) )
258   ROM_LOAD( "mxs5-4v.rom",   0x8000, 0x4000, CRC(e0085f91) SHA1(cf143b94048e1ebb5c899b94b500e193dfd42e18) )
259
260304   ROM_REGION( 0x0060, "proms", 0 ) // data ? encrypted roms for cpu1 ?
261305   ROM_LOAD( "mra3.prm",   0x0000, 0x0020, CRC(ae7e1a63) SHA1(f5596db77c1e352ef7845465db3e54e19cd5df9e) )
262306   ROM_LOAD( "mrb3.prm",   0x0020, 0x0020, CRC(e3f3d0f5) SHA1(182b06c9db5bec1e3030f705247763bd2380ba83) )
263307   ROM_LOAD( "mirax.prm",   0x0040, 0x0020, NO_DUMP )
264
265308ROM_END
266309
267GAME( 1985, mirax,  0,      mirax, mirax, 0, ROT90, "Current Technologies", "Mirax", GAME_NOT_WORKING)
310
311static DRIVER_INIT( mirax )
312{
313   UINT8 *ROM = memory_region(machine, "maincpu");
314   int i;
315
316   for(i=0;i<0xc000;i++)
317      ROM[i] = BITSWAP8(ROM[i], 1, 3, 7, 0, 5, 6, 4, 2) ^ 0xff;
318}
319
320GAME( 1985, mirax,  0,      mirax, mirax, mirax, ROT90, "Current Technologies", "Mirax", GAME_NOT_WORKING)
src/mame/drivers/mystwarr.c
r4939r4940
603603   AM_RANGE(0x482000, 0x482007) AM_WRITE(K056832_b_word_w)   // VSCCS
604604   AM_RANGE(0x484000, 0x484003) AM_WRITE(ddd_053936_clip_w)
605605   AM_RANGE(0x486000, 0x48601f) AM_WRITE(K053252_word_w)
606   AM_RANGE(0x488000, 0x4880ff) AM_WRITE(K055555_word_w)
606607   AM_RANGE(0x48a00c, 0x48a00d) AM_WRITE(sound_cmd1_msb_w)
607608   AM_RANGE(0x48a00e, 0x48a00f) AM_WRITE(sound_cmd2_msb_w)
608609   AM_RANGE(0x48a014, 0x48a015) AM_READ(sound_status_msb_r)
src/mame/drivers/neogeo.c
r4939r4940
252252 *
253253 *************************************/
254254
255static void calendar_clock(void);
256255static void set_output_latch(running_machine *machine, UINT8 data);
257256static void set_output_data(UINT8 data);
258257
r4939r4940
362361
363362static TIMER_CALLBACK( vblank_interrupt_callback )
364363{
364   const device_config *upd4990a = devtag_get_device(machine, "upd4990a");
365
365366   if (LOG_VIDEO_SYSTEM) logerror("+++ VBLANK @ %d,%d\n", video_screen_get_vpos(machine->primary_screen), video_screen_get_hpos(machine->primary_screen));
366367
367368   /* add a timer tick to the pd4990a */
368   calendar_clock();
369   upd4990a_addretrace(upd4990a);
369370
370371   vblank_interrupt_pending = 1;
371372
r4939r4940
469470
470471static WRITE16_HANDLER( io_control_w )
471472{
473   const device_config *upd4990a = devtag_get_device(space->machine, "upd4990a");
474
472475   switch (offset)
473476   {
474477   case 0x00: select_controller(data & 0x00ff); break;
475478   case 0x18: set_output_latch(space->machine, data & 0x00ff); break;
476479   case 0x20: set_output_data(data & 0x00ff); break;
477   case 0x28: pd4990a_control_16_w(space, 0, data, mem_mask); break;
480   case 0x28: upd4990a_control_16_w(upd4990a, 0, data, mem_mask); break;
478481//  case 0x30: break; // coin counters
479482//  case 0x31: break; // coin counters
480483//  case 0x32: break; // coin lockout
r4939r4940
523526 *
524527 *************************************/
525528
526static void calendar_init(running_machine *machine)
527{
528   /* set the celander IC to 'right now' */
529   mame_system_time systime;
530   mame_system_tm time;
531
532   mame_get_base_datetime(machine, &systime);
533   time = systime.local_time;
534
535   pd4990a.seconds = ((time.second / 10) << 4) + (time.second % 10);
536   pd4990a.minutes = ((time.minute / 10) << 4) + (time.minute % 10);
537   pd4990a.hours = ((time.hour / 10) <<4 ) + (time.hour % 10);
538   pd4990a.days = ((time.mday / 10) << 4) + (time.mday % 10);
539   pd4990a.month = time.month + 1;
540   pd4990a.year = ((((time.year - 1900) % 100) / 10) << 4) + ((time.year - 1900) % 10);
541   pd4990a.weekday = time.weekday;
542}
543
544
545static void calendar_clock(void)
546{
547   pd4990a_addretrace();
548}
549
550
551529static CUSTOM_INPUT( get_calendar_status )
552530{
553   const address_space *space = cputag_get_address_space(field->port->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
554   return (pd4990a_databit_r(space, 0) << 1) | pd4990a_testbit_r(space, 0);
531   const device_config *upd4990a = devtag_get_device(field->port->machine, "upd4990a");
532   return (upd4990a_databit_r(upd4990a, 0) << 1) | upd4990a_testbit_r(upd4990a, 0);
555533}
556534
557535
r4939r4940
10711049
10721050   create_interrupt_timers(machine);
10731051
1074   /* initialize the celander IC to 'right now' */
1075   calendar_init(machine);
1076
10771052   /* initialize the memcard data structure */
10781053   memcard_data = auto_alloc_array_clear(machine, UINT8, MEMCARD_SIZE);
10791054
r4939r4940
13681343   MDRV_SOUND_ROUTE(0, "rspeaker", 0.60)
13691344   MDRV_SOUND_ROUTE(1, "lspeaker",  1.0)
13701345   MDRV_SOUND_ROUTE(2, "rspeaker", 1.0)
1346
1347   /* NEC uPD4990A RTC */
1348   MDRV_UPD4990A_ADD("upd4990a")
13711349MACHINE_DRIVER_END
13721350
13731351/*************************************
src/mame/drivers/konamigx.c
r4939r4940
848848
849849static READ32_HANDLER( adc0834_r )
850850{
851   return adc083x_do_read( space->machine, 0 ) << 24;
851   const device_config *adc0834 = devtag_get_device(space->machine, "adc0834");
852   return adc083x_do_read(adc0834, 0) << 24;
852853}
853854
854855static WRITE32_HANDLER( adc0834_w )
855856{
856   running_machine *machine = space->machine;
857   adc083x_clk_write( machine, 0, ( data >> 24 ) & 1 );
858   adc083x_di_write( machine, 0, ( data >> 25 ) & 1 );
859   adc083x_cs_write( machine, 0, ( data >> 26 ) & 1 );
857   const device_config *adc0834 = devtag_get_device(space->machine, "adc0834");
858   adc083x_clk_write(adc0834, 0, (data >> 24) & 1);
859   adc083x_di_write(adc0834, 0, (data >> 25) & 1);
860   adc083x_cs_write(adc0834, 0, (data >> 26) & 1);
860861}
861862
862static double adc0834_callback( running_machine *machine, int input )
863static double adc0834_callback( const device_config *device, UINT8 input )
863864{
864   switch( input )
865   switch (input)
865866   {
866867   case ADC083X_CH0:
867      return ( (double)5 * input_port_read(machine, "AN0" ) ) / 255; // steer
868      return (double)(5 * input_port_read(device->machine, "AN0")) / 255.0; // steer
868869   case ADC083X_CH1:
869      return ( (double)5 * input_port_read(machine, "AN1" ) ) / 255; // gas
870      return (double)(5 * input_port_read(device->machine, "AN1")) / 255.0; // gas
870871   case ADC083X_VREF:
871872      return 5;
872873   }
873874   return 0;
874875}
875876
877static const adc0831_interface konamigx_adc_interface = {
878   adc0834_callback
879};
880
881
876882static READ32_HANDLER( le2_gun_H_r )
877883{
878884   int p1x = input_port_read(space->machine, "LIGHT0_X")*290/0xff+20;
r4939r4940
13921398   MDRV_SOUND_CONFIG(k054539_config)
13931399   MDRV_SOUND_ROUTE(0, "lspeaker", 1.0)
13941400   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
1401
1402   MDRV_ADC0834_ADD( "adc0834", konamigx_adc_interface )
13951403MACHINE_DRIVER_END
13961404
13971405static MACHINE_DRIVER_START( dragoonj )
r4939r4940
34103418   int i, match;
34113419   int readback = 0;
34123420
3413   adc083x_init( machine, 0, ADC0834, adc0834_callback );
3414
34153421   konamigx_cfgport = -1;
34163422   last_prot_op = -1;
34173423   last_prot_clk = 0;
src/mame/drivers/parodius.c
r4939r4940
109109
110110static void sound_nmi_callback( int param )
111111{
112   cpu_set_input_line(Machine->cpu[1], INPUT_LINE_NMI, ( nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE );
112   cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, ( nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE );
113113
114114   nmi_enabled = 0;
115115}
src/mame/drivers/moo.c
r4939r4940
662662ROM_START( bucky )
663663   ROM_REGION( 0x240000, "maincpu", 0 )
664664   /* main program */
665   ROM_LOAD16_BYTE( "173ea.b01", 0x000000,  0x40000, CRC(7785ac8a) SHA1(ef78d14f54d3a0b724b9702a18c67891e2d366a7) )
666   ROM_LOAD16_BYTE( "173ea.b02", 0x000001,  0x40000, CRC(9b45f122) SHA1(325af1612e6f90ef9ae9353c43dc645be1f3465c) )
665   ROM_LOAD16_BYTE( "173_ea_b01.q5", 0x000000,  0x40000, CRC(7785ac8a) SHA1(ef78d14f54d3a0b724b9702a18c67891e2d366a7) )
666   ROM_LOAD16_BYTE( "173_ea_b02.q6", 0x000001,  0x40000, CRC(9b45f122) SHA1(325af1612e6f90ef9ae9353c43dc645be1f3465c) )
667667
668668   /* data */
669669   ROM_LOAD16_BYTE( "t5", 0x200000,  0x20000, CRC(cd724026) SHA1(525445499604b713da4d8bc0a88e428654ceab95) )
r4939r4940
695695ROM_START( buckyua )
696696   ROM_REGION( 0x240000, "maincpu", 0 )
697697   /* main program */
698   ROM_LOAD16_BYTE( "q5", 0x000000,  0x40000, CRC(dcaecca0) SHA1(c41847c9d89cdaf7cfa81ad9cc018c32592a882f) )
699   ROM_LOAD16_BYTE( "q6", 0x000001,  0x40000, CRC(e3c856a6) SHA1(33cc8a29643e44b31ee280015c0c994bed72a0e3) )
698   ROM_LOAD16_BYTE( "173_ua_b01.q5", 0x000000,  0x40000, CRC(dcaecca0) SHA1(c41847c9d89cdaf7cfa81ad9cc018c32592a882f) )
699   ROM_LOAD16_BYTE( "173_ua_b02.q6", 0x000001,  0x40000, CRC(e3c856a6) SHA1(33cc8a29643e44b31ee280015c0c994bed72a0e3) )
700700
701701   /* data */
702702   ROM_LOAD16_BYTE( "t5", 0x200000,  0x20000, CRC(cd724026) SHA1(525445499604b713da4d8bc0a88e428654ceab95) )
r4939r4940
725725   ROM_LOAD("173a09.a6", 0x200000, 0x200000, CRC(c93697c4) SHA1(0528a604868267a30d281b822c187df118566691) )
726726ROM_END
727727
728ROM_START( buckyaa )
729   ROM_REGION( 0x240000, "maincpu", 0 )
730   /* main program */
731   ROM_LOAD16_BYTE( "173_aa_b01.q5", 0x000000,  0x40000, CRC(9193e89f) SHA1(574d6eb4097cd10c3dea99060ee09f220d41f1dc) )
732   ROM_LOAD16_BYTE( "173_aa_b02.q6", 0x000001,  0x40000, CRC(2567f3eb) SHA1(ccdb2a4b3ad1464f70d1442df8a3a7a7e34f6cd7) )
728733
734   /* data */
735   ROM_LOAD16_BYTE( "t5", 0x200000,  0x20000, CRC(cd724026) SHA1(525445499604b713da4d8bc0a88e428654ceab95) )
736   ROM_LOAD16_BYTE( "t6", 0x200001,  0x20000, CRC(7dd54d6f) SHA1(b0ee8ec445b92254bca881eefd4449972fed506a) )
737
738   ROM_REGION( 0x050000, "soundcpu", 0 )
739   /* Z80 sound program */
740   ROM_LOAD("173.a07", 0x000000, 0x40000, CRC(4cdaee71) SHA1(bdc05d4475415f6fac65d7cdbc48df398e57845e) )
741   ROM_RELOAD(         0x010000, 0x040000 )
742
743   ROM_REGION( 0x200000, "gfx1", 0 )
744   /* tilemaps */
745   ROM_LOAD( "173a05.t8",  0x000000, 0x100000, CRC(d14333b4) SHA1(d1a15ead2d156e1fceca0bf202ab3962411caf11) )
746   ROM_LOAD( "173a06.t10", 0x100000, 0x100000, CRC(6541a34f) SHA1(15cf481498e3b7e0b2f7bfe5434121cc3bd65662) )
747
748   ROM_REGION( 0x800000, "gfx2", 0 )
749   /* sprites */
750   ROM_LOAD( "173a10.b8",  0x000000, 0x200000, CRC(42fb0a0c) SHA1(d68c932cfabdec7896698b433525fe47ef4698d0) )
751   ROM_LOAD( "173a11.a8",  0x200000, 0x200000, CRC(b0d747c4) SHA1(0cf1ee1b9a35ded31a81c321df2a076f7b588971) )
752   ROM_LOAD( "173a12.b10", 0x400000, 0x200000, CRC(0fc2ad24) SHA1(6eda1043ee1266b8ba938a03a90bc7787210a936) )
753   ROM_LOAD( "173a13.a10", 0x600000, 0x200000, CRC(4cf85439) SHA1(8c298bf0e659a830a1830a1180f4ce71215ade45) )
754
755   ROM_REGION( 0x400000, "konami", 0 )
756   /* K054539 samples */
757   ROM_LOAD("173a08.b6", 0x000000, 0x200000, CRC(dcdded95) SHA1(8eeb546a0b60a35a6dce36c5ee872e6c93c577c9) )
758   ROM_LOAD("173a09.a6", 0x200000, 0x200000, CRC(c93697c4) SHA1(0528a604868267a30d281b822c187df118566691) )
759ROM_END
760
761
729762static DRIVER_INIT( moo )
730763{
731764   konami_rom_deinterleave_2(machine, "gfx1");
r4939r4940
791824GAME( 1992, moobl,   moo,     moobl,   moo,     moo,      ROT0, "<unknown>", "Wild West C.O.W.-Boys of Moo Mesa (bootleg ver AA)", GAME_NOT_WORKING)
792825GAME( 1992, bucky,   0,       bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver EA)", 0)
793826GAME( 1992, buckyua, bucky,   bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver UA)", 0)
827GAME( 1992, buckyaa, bucky,   bucky,   bucky,   moo,      ROT0, "Konami", "Bucky O'Hare (ver AA)", 0)
src/mame/drivers/nwk-tr.c
r4939r4940
675675
676676/*****************************************************************************/
677677
678static double adc12138_input_callback(running_machine *machine, int input)
679{
680   int value = 0;
681   switch (input)
682   {
683      case 0:      value = input_port_read(machine, "ANALOG1") - 0x800; break;
684      case 1:      value = input_port_read(machine, "ANALOG2"); break;
685      case 2:      value = input_port_read(machine, "ANALOG3"); break;
686      case 3:      value = input_port_read(machine, "ANALOG4"); break;
687      case 4:      value = input_port_read(machine, "ANALOG5"); break;
688   }
689
690   return (double)(value) / 2047.0;
691}
692
693678static READ32_HANDLER( sysreg_r )
694679{
680   const device_config *adc12138 = devtag_get_device(space->machine, "adc12138");
695681   UINT32 r = 0;
696682   if (offset == 0)
697683   {
r4939r4940
709695      }
710696      if (ACCESSING_BITS_0_7)
711697      {
712         r |= (adc1213x_do_r(0)) | (adc1213x_eoc_r(0) << 2);
698         r |= adc1213x_do_r(adc12138, 0) | (adc1213x_eoc_r(adc12138, 0) << 2);
713699      }
714700   }
715701   else if (offset == 1)
r4939r4940
724710
725711static WRITE32_HANDLER( sysreg_w )
726712{
713   const device_config *adc12138 = devtag_get_device(space->machine, "adc12138");
727714   if( offset == 0 )
728715   {
729716      if (ACCESSING_BITS_24_31)
r4939r4940
745732         int di = (data >> 25) & 0x1;
746733         int sclk = (data >> 24) & 0x1;
747734
748         adc1213x_cs_w(space->machine, 0, cs);
749         adc1213x_conv_w(0, conv);
750         adc1213x_di_w(0, di);
751         adc1213x_sclk_w(0, sclk);
735         adc1213x_cs_w(adc12138, 0, cs);
736         adc1213x_conv_w(adc12138, 0, conv);
737         adc1213x_di_w(adc12138, 0, di);
738         adc1213x_sclk_w(adc12138, 0, sclk);
752739      }
753740      if (ACCESSING_BITS_0_7)
754741      {
r4939r4940
10221009   BOOT_MODE_EPROM
10231010};
10241011
1012
1013static double adc12138_input_callback( const device_config *device, UINT8 input )
1014{
1015   int value = 0;
1016   switch (input)
1017   {
1018      case 0:      value = input_port_read(device->machine, "ANALOG1") - 0x800; break;
1019      case 1:      value = input_port_read(device->machine, "ANALOG2"); break;
1020      case 2:      value = input_port_read(device->machine, "ANALOG3"); break;
1021      case 3:      value = input_port_read(device->machine, "ANALOG4"); break;
1022      case 4:      value = input_port_read(device->machine, "ANALOG5"); break;
1023   }
1024
1025   return (double)(value) / 2047.0;
1026}
1027
1028static const adc12138_interface nwktr_adc_interface = {
1029   adc12138_input_callback
1030};
1031
1032
10251033static MACHINE_RESET( nwktr )
10261034{
10271035   cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
r4939r4940
10701078   MDRV_SOUND_ROUTE(1, "rspeaker", 1.0)
10711079
10721080   MDRV_M48T58_ADD( "m48t58" )
1081
1082   MDRV_ADC12138_ADD( "adc12138", nwktr_adc_interface )
10731083MACHINE_DRIVER_END
10741084
10751085/*****************************************************************************/
r4939r4940
10931103   K056800_init(machine, sound_irq_callback);
10941104   K033906_init(machine);
10951105
1096   adc1213x_init(0, adc12138_input_callback);
10971106   lanc2_init(machine);
10981107}
10991108
src/mame/drivers/jpmsys5.c
r4939r4940
286286   AM_RANGE(0x046000, 0x046001) AM_WRITENOP
287287   AM_RANGE(0x046020, 0x046021) AM_DEVREADWRITE8("acia6850_0", acia6850_stat_r, acia6850_ctrl_w, 0xff)
288288   AM_RANGE(0x046022, 0x046023) AM_DEVREADWRITE8("acia6850_0", acia6850_data_r, acia6850_data_w, 0xff)
289   AM_RANGE(0x046040, 0x04604f) AM_READWRITE(ptm6840_0_lsb_r, ptm6840_0_lsb_w)
289   AM_RANGE(0x046040, 0x04604f) AM_DEVREADWRITE8("6840ptm", ptm6840_read, ptm6840_write, 0xff)
290290   AM_RANGE(0x046060, 0x046061) AM_READ_PORT("DIRECT") AM_WRITENOP
291291   AM_RANGE(0x046062, 0x046063) AM_WRITENOP
292292   AM_RANGE(0x046064, 0x046065) AM_WRITENOP
r4939r4940
458458 *
459459 *************************************/
460460
461static void ptm_irq(running_machine *machine, int state)
461static WRITE_LINE_DEVICE_HANDLER( ptm_irq )
462462{
463   cputag_set_input_line(machine, "maincpu", INT_6840PTM, state ? ASSERT_LINE : CLEAR_LINE);
463   cputag_set_input_line(device->machine, "maincpu", INT_6840PTM, state ? ASSERT_LINE : CLEAR_LINE);
464464}
465465
466466static const ptm6840_interface ptm_intf =
467467{
468468   1000000,
469469   { 0, 0, 0 },
470   { 0, 0, 0 },
471   ptm_irq
470   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
471   DEVCB_LINE(ptm_irq)
472472};
473473
474474
r4939r4940
576576static MACHINE_START( jpmsys5v )
577577{
578578   memory_set_bankptr(machine, 1, memory_region(machine, "maincpu"));
579   ptm6840_config(machine, 0, &ptm_intf);
580579   touch_timer = timer_alloc(machine, touch_cb, NULL);
581580}
582581
r4939r4940
625624   /* Earlier revisions use an SAA1099 */
626625   MDRV_SOUND_ADD("ym2413", YM2413, 4000000 ) /* Unconfirmed */
627626   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
627
628   /* 6840 PTM */
629   MDRV_PTM6840_ADD("6840ptm", ptm_intf)
628630MACHINE_DRIVER_END
629631
630632
src/mame/drivers/guab.c
r4939r4940
5757 *
5858 *************************************/
5959
60static void ptm_irq(running_machine *machine, int state)
60static WRITE_LINE_DEVICE_HANDLER( ptm_irq )
6161{
62   cputag_set_input_line(machine, "maincpu", INT_6840PTM, state);
62   cputag_set_input_line(device->machine, "maincpu", INT_6840PTM, state);
6363}
6464
6565static const ptm6840_interface ptm_intf =
6666{
6767   1000000,
6868   { 0, 0, 0 },
69   { 0, 0, 0 },
70   ptm_irq
69   { DEVCB_NULL, DEVCB_NULL, DEVCB_NULL },
70   DEVCB_LINE(ptm_irq)
7171};
7272
7373
r4939r4940
661661   AM_RANGE(0x0c0000, 0x0c007f) AM_READWRITE(io_r, io_w)
662662   AM_RANGE(0x0c0080, 0x0c0083) AM_NOP /* ACIA 1 */
663663   AM_RANGE(0x0c00a0, 0x0c00a3) AM_NOP /* ACIA 2 */
664   AM_RANGE(0x0c00c0, 0x0c00cf) AM_READWRITE(ptm6840_0_lsb_r, ptm6840_0_lsb_w)
664   AM_RANGE(0x0c00c0, 0x0c00cf) AM_DEVREADWRITE8("6840ptm", ptm6840_read, ptm6840_write, 0xff)
665665   AM_RANGE(0x0c00e0, 0x0c00e7) AM_READWRITE(wd1770_r, wd1770_w)
666666   AM_RANGE(0x080000, 0x080fff) AM_RAM
667667   AM_RANGE(0x100000, 0x100003) AM_READWRITE(ef9369_r, ef9369_w)
r4939r4940
752752 static MACHINE_START( guab )
753753{
754754   fdc_timer = timer_alloc(machine, fdc_data_callback, NULL);
755   ptm6840_config(machine, 0, &ptm_intf);
756755}
757756
758757static MACHINE_RESET( guab )
r4939r4940
786785   /* TODO: Verify clock */
787786   MDRV_SOUND_ADD("sn", SN76489, 2000000)
788787   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
788
789   /* 6840 PTM */
790   MDRV_PTM6840_ADD("6840ptm", ptm_intf)
789791MACHINE_DRIVER_END
790792
791793
src/mame/drivers/twin16.c
r4939r4940
150150   if (twin16_CPUA_register != old)
151151   {
152152      if ((old & 0x08) == 0 && (twin16_CPUA_register & 0x08))
153         cpu_set_input_line_and_vector(cputag_get_cpu(space->machine, "audiocpu"), 0, HOLD_LINE, 0xff);
153         cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
154154
155155      if ((old & 0x40) && (twin16_CPUA_register & 0x40) == 0)
156156         twin16_spriteram_process();
r4939r4940
190190   if (twin16_CPUA_register != old)
191191   {
192192      if ((old & 0x08) == 0 && (twin16_CPUA_register & 0x08))
193         cpu_set_input_line_and_vector(cputag_get_cpu(space->machine, "audiocpu"), 0, HOLD_LINE, 0xff);   // trigger IRQ on sound CPU
193         cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);   // trigger IRQ on sound CPU
194194   }
195195}
196196
src/mame/drivers/bigfghtr.c
r4939r4940
332332   AM_RANGE(0x080000, 0x0805ff) AM_RAM AM_BASE(&spriteram16) AM_SIZE(&spriteram_size)
333333   AM_RANGE(0x080600, 0x080fff) AM_READ(sharedram_r) AM_WRITE(sharedram_w) AM_BASE(&sharedram16)
334334   AM_RANGE(0x081000, 0x085fff) AM_RAM //??
335   AM_RANGE(0x086000, 0x086fff) AM_READONLY AM_WRITE(bg_videoram_w) AM_BASE(&bg_videoram)
336   AM_RANGE(0x087000, 0x087fff) AM_READONLY AM_WRITE(fg_videoram_w) AM_BASE(&fg_videoram)
337   AM_RANGE(0x088000, 0x089fff) AM_READONLY AM_WRITE(text_videoram_w) AM_BASE(&text_videoram)
338   AM_RANGE(0x08a000, 0x08afff) AM_READONLY AM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE(&paletteram16)
335   AM_RANGE(0x086000, 0x086fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE(&bg_videoram)
336   AM_RANGE(0x087000, 0x087fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE(&fg_videoram)
337   AM_RANGE(0x088000, 0x089fff) AM_RAM_WRITE(text_videoram_w) AM_BASE(&text_videoram)
338   AM_RANGE(0x08a000, 0x08afff) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE(&paletteram16)
339339   AM_RANGE(0x08b000, 0x08bfff) AM_RAM //??
340340   AM_RANGE(0x08c000, 0x08c001) AM_READ_PORT("P1")
341341   AM_RANGE(0x08c002, 0x08c003) AM_READ_PORT("P2")
src/mame/drivers/hvyunit.c
r4939r4940
458458   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
459459   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
460460   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
461   /*copied from DJ Boy, WRONG */
461   /*copied from DJ Boy, WRONG
462
463HEAVY UNIT
464Manufacturer: Taito
465Year: 1988 - Genre: Shooter
466Orientation: Horizontal
467Conversion Class: JAMMA
468DIP Switch Settings:
469SW#1
470--------------------------------------------------------------------
471DESCRIPTION                           1   2   3   4   5   6   7   8
472--------------------------------------------------------------------
473CABINET TYPE       TABLE             OFF
474                   UPRIGHT           ON
475--------------------------------------------------------------------
476VIDEO SCREEN       NORMAL                OFF
477                   FLIP                  ON
478--------------------------------------------------------------------
479TEST MODE          NORMAL                    OFF
480                   TEST                      ON
481--------------------------------------------------------------------
482COIN/CREDIT
483COIN #1            1C/1P                             OFF OFF
484                   1C/2P                             ON  OFF
485                   2C/1P                             OFF ON
486                   2C/3P                             ON  ON
487
488COIN #2            1C/1P                                     OFF OFF
489                   1C/2P                                     ON  OFF
490                   2C/1P                                     OFF ON
491                   2C/3P                                     ON  ON
492--------------------------------------------------------------------
493NOT USED           SW#4 ALWAYS OFF
494--------------------------------------------------------------------
495
496
497SW#2
498--------------------------------------------------------------------
499DESCRIPTION                           1   2   3   4   5   6   7   8
500--------------------------------------------------------------------
501DIFFICULTY         NORMAL            OFF OFF
502                   EASY              ON  OFF
503                   HARD              OFF ON
504                   HARDEST           ON  ON
505--------------------------------------------------------------------
506CONTINUE           YES                       OFF
507                   NO                        ON
508--------------------------------------------------------------------
509BONUS              NO                            OFF
510                   YES                           ON
511--------------------------------------------------------------------
512# LIVES            3                                 OFF OFF
513                   4                                 ON  OFF
514                   5                                 OFF ON
515                   7                                 ON  ON
516--------------------------------------------------------------------
517DEMO SOUND         YES                                       OFF
518                   NO                                        ON
519--------------------------------------------------------------------
520NOT USED           SW#8 ALWAYS OFF
521--------------------------------------------------------------------
522
523*/
462524   PORT_START("DSW1")
463   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
464   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
465   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
466   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
467   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
468   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
525   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
526   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
527   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
528   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
529   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
530   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
469531   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Service_Mode ) )
470532   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
471533   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
472534   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
473535   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
474536   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
475   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
476   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
477   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
478   PORT_DIPSETTING(    0x30, DEF_STR( 2C_3C ) )
479   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
480   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
481   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
482   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
483   PORT_DIPSETTING(    0xc0, DEF_STR( 2C_3C ) )
484   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
537   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) )
538   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
539   PORT_DIPSETTING(    0x30, DEF_STR( 1C_1C ) )
540   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
541   PORT_DIPSETTING(    0x20, DEF_STR( 1C_2C ) )
542   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) )
543   PORT_DIPSETTING(    0x40, DEF_STR( 2C_1C ) )
544   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_1C ) )
545   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
546   PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) )
485547   PORT_START("DSW2")
486   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
487   PORT_DIPSETTING(    0x01, DEF_STR( Easy ) )
488   PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )
489   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
490   PORT_DIPSETTING(    0x03, DEF_STR( Hardest ) )
491   PORT_DIPNAME( 0x0c, 0x00, "Bonus" )
492   PORT_DIPSETTING(    0x00, "10,30,50,70,90" )
493   PORT_DIPSETTING(    0x04, "10,20,30,40,50,60,70,80,90" )
494   PORT_DIPSETTING(    0x08, "20,50" )
495   PORT_DIPSETTING(    0x0c, DEF_STR( None ) )
496   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) )
497   PORT_DIPSETTING(    0x10, "3" )
498   PORT_DIPSETTING(    0x00, "5" )
499   PORT_DIPSETTING(    0x20, "7" )
500   PORT_DIPSETTING(    0x30, "9" )
501   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Demo_Sounds ) )
502   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
503   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
504   PORT_DIPNAME( 0x80, 0x80, "Stereo Sound" )
548   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
549   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
550   PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
551   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
552   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
553   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Allow_Continue ) )
554   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
555   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
556   PORT_DIPNAME( 0x08, 0x08, "Bonus" )
557   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
558   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
559   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
560   PORT_DIPSETTING(    0x30, "3" )
561   PORT_DIPSETTING(    0x20, "4" )
562   PORT_DIPSETTING(    0x10, "5" )
563   PORT_DIPSETTING(    0x00, "7" )
564   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
565   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
566   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
567   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
505568   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
506569   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
507570   PORT_START("TEST")
src/emu/cpu/cpu.mak
r4939r4940
689689
690690
691691#-------------------------------------------------
692# Manchester Small-Scale Experimental Machine
693#-------------------------------------------------
694
695ifneq ($(filter SSEM,$(CPUS)),)
696OBJDIRS += $(CPUOBJ)/ssem
697CPUOBJS += $(CPUOBJ)/ssem/ssem.o
698DBGOBJS += $(CPUOBJ)/ssem/ssemdasm.o
699endif
700
701$(CPUOBJ)/ssem/ssem.o:   $(CPUSRC)/ssem/ssem.c \
702         $(CPUSRC)/ssem/ssem.h
703
704
705
706#-------------------------------------------------
692707# Fujitsu MB88xx
693708#-------------------------------------------------
694709
r4939r4940
719734
720735
721736#-------------------------------------------------
722# Manchester Small-Scale Experimental Machine
723#-------------------------------------------------
724
725ifneq ($(filter SSEM,$(CPUS)),)
726OBJDIRS += $(CPUOBJ)/ssem
727CPUOBJS += $(CPUOBJ)/ssem/ssem.o
728DBGOBJS += $(CPUOBJ)/ssem/ssemdasm.o
729endif
730
731$(CPUOBJ)/ssem/ssem.o:   $(CPUSRC)/ssem/ssem.c \
732         $(CPUSRC)/ssem/ssem.h
733
734
735
736#-------------------------------------------------
737737# Microchip PIC16C5x
738738#-------------------------------------------------
739739
src/emu/cpu/ssem/ssem.h
r4939r4940
1/*
2    Manchester Small-Scale Experimental Machine (SSEM) emulator
3
4    Written by MooglyGuy
5*/
6
17#pragma once
28
39#ifndef __SSEM_H__
src/emu/devtempl.h
r0r4940
1/***************************************************************************
2
3    devtempl.h
4
5    Template include for defining devices.
6
7    Copyright Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10****************************************************************************
11
12    Typical usage is as follows:
13
14static const char *DEVTEMPLATE_SOURCE = __FILE__;
15
16// for a primary device....
17#define DEVTEMPLATE_ID(p,s)             p##devicenameprefix##s
18#define DEVTEMPLATE_FEATURES            DT_HAS_xxx | DT_HAS_yyy | ...
19#define DEVTEMPLATE_NAME                "Device Name String"
20#define DEVTEMPLATE_FAMILY              "Device Family String"
21#define DEVTEMPLATE_CLASS               DEVICE_CLASS_xxxx
22#include "devtempl.h"
23
24// for a derived device....
25#define DEVTEMPLATE_DERIVED_ID(p,s)     p##derivednameprefix##s
26#define DEVTEMPLATE_DERIVED_FEATURES    DT_HAS_xxx | DT_HAS_yyy | ...
27#define DEVTEMPLATE_NAME                "Derived Name String"
28#include "devtempl.h"
29
30****************************************************************************
31
32    Parameters are as follows:
33
34    DEVTEMPLATE_ID(p,s) - required - macro to produce device function and
35        type names with a prefix of 'p' and a suffix of 's'
36
37    DEVTEMPLATE_FEATURES - required - bitmask consisting of one of the
38        DT_HAS_* flags, indicating which standard-named callbacks or
39        pointers are specified by this device (everything else is assumed
40        to be NULL, which is the default)
41
42    DEVTEMPLATE_NAME - required - a string describing the device
43
44    DEVTEMPLATE_FAMILY - required - a string describing the device family
45        name
46
47    DEVTEMPLATE_STATE - optional - the name of the device's state
48        structure; by default, this is assumed to be
49        DEVTEMPLATE_ID(,_state)
50
51    DEVTEMPLATE_CLASS - optional - the device's class (default is
52        DEVICE_CLASS_PERIPHERAL)
53
54    DEVTEMPLATE_VERSION - optional - the device's version string (default
55        is "1.0")
56
57    DEVTEMPLATE_CREDITS - optional - the device's credit string (default
58        is "Copyright Nicola Salmoria and the MAME Team")
59
60    DEVTEMPLATE_INLINE_CONFIG - optional - the name of the device's
61        inline configuration structure; by default, it is assumed the
62        device does not have any inline configuration
63
64***************************************************************************/
65
66
67/* flag bits for DEVTEMPLATE_FEATURES */
68#define DT_HAS_START         0x0001
69#define DT_HAS_RESET         0x0002
70#define DT_HAS_STOP            0x0004
71#define DT_HAS_EXECUTE         0x0008
72#define DT_HAS_NVRAM         0x0010
73#define DT_HAS_VALIDITY_CHECK   0x0020
74#define DT_HAS_CUSTOM_CONFIG   0x0040
75#define DT_HAS_ROM_REGION      0x0080
76#define DT_HAS_MACHINE_CONFIG   0x0100
77#define DT_HAS_INLINE_CONFIG   0x0200
78
79
80/* verify core stuff is specified */
81#ifndef DEVTEMPLATE_ID
82#error DEVTEMPLATE_ID must be specified!
83#endif
84
85#ifndef DEVTEMPLATE_FEATURES
86#error DEVTEMPLATE_FEATURES must be specified!
87#endif
88
89#if ((DEVTEMPLATE_FEATURES & DT_HAS_START) == 0)
90#error Device start routine is required!
91#endif
92
93#ifndef DEVTEMPLATE_NAME
94#error DEVTEMPLATE_NAME must be specified!
95#endif
96
97#ifndef DEVTEMPLATE_FAMILY
98#error DEVTEMPLATE_FAMILY must be specified!
99#endif
100
101#ifdef DEVTEMPLATE_DERIVED_FEATURES
102#ifndef DEVTEMPLATE_DERIVED_NAME
103#error DEVTEMPLATE_DERIVED_NAME must be specified!
104#endif
105#endif
106
107
108/* primary device case */
109#ifndef DEVTEMPLATE_DERIVED_FEATURES
110
111/* derive standard state name (unless explicitly provided) */
112#ifndef DEVTEMPLATE_STATE
113#define DEVTEMPLATE_STATE      DEVTEMPLATE_ID(,_state)
114#endif
115
116/* default to DEVICE_CLASS_PERIPHERAL */
117#ifndef DEVTEMPLATE_CLASS
118#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
119#endif
120
121/* default to version 1.0 */
122#ifndef DEVTEMPLATE_VERSION
123#define DEVTEMPLATE_VERSION      "1.0"
124#endif
125
126/* default to the standard copyright attribution */
127#ifndef DEVTEMPLATE_CREDITS
128#define DEVTEMPLATE_CREDITS    "Copyright Nicola Salmoria and the MAME Team"
129#endif
130
131/* declare callback functions */
132static DEVICE_START( DEVTEMPLATE_ID(,) );
133#if ((DEVTEMPLATE_FEATURES) & DT_HAS_RESET)
134static DEVICE_RESET( DEVTEMPLATE_ID(,) );
135#endif
136#if ((DEVTEMPLATE_FEATURES) & DT_HAS_STOP)
137static DEVICE_STOP( DEVTEMPLATE_ID(,) );
138#endif
139#if ((DEVTEMPLATE_FEATURES) & DT_HAS_EXECUTE)
140static DEVICE_EXECUTE( DEVTEMPLATE_ID(,) );
141#endif
142#if ((DEVTEMPLATE_FEATURES) & DT_HAS_NVRAM)
143static DEVICE_NVRAM( DEVTEMPLATE_ID(,) );
144#endif
145#if ((DEVTEMPLATE_FEATURES) & DT_HAS_VALIDITY_CHECK)
146static DEVICE_VALIDITY_CHECK( DEVTEMPLATE_ID(,) );
147#endif
148#if ((DEVTEMPLATE_FEATURES) & DT_HAS_CUSTOM_CONFIG)
149static DEVICE_CUSTOM_CONFIG( DEVTEMPLATE_ID(,) );
150#endif
151
152/* the actual get_info function */
153DEVICE_GET_INFO( DEVTEMPLATE_ID(,) )
154{
155   switch (state)
156   {
157      /* --- the following bits of info are returned as 64-bit signed integers --- */
158      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(DEVTEMPLATE_STATE);                     break;
159#if ((DEVTEMPLATE_FEATURES) & DT_HAS_INLINE_CONFIG)
160      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = sizeof(DEVTEMPLATE_ID(,_config));                  break;
161#endif
162      case DEVINFO_INT_CLASS:               info->i = DEVTEMPLATE_CLASS;                           break;
163
164      /* --- the following bits of info are returned as pointers --- */
165#if ((DEVTEMPLATE_FEATURES) & DT_HAS_ROM_REGION)
166      case DEVINFO_PTR_ROM_REGION:         info->romregion = DEVTEMPLATE_ID(rom_,);                  break;
167#endif
168#if ((DEVTEMPLATE_FEATURES) & DT_HAS_MACHINE_CONFIG)
169      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = DEVTEMPLATE_ID(machine_config_,);      break;
170#endif
171
172      /* --- the following bits of info are returned as pointers to data or functions --- */
173#if ((DEVTEMPLATE_FEATURES) & DT_HAS_START)
174      case DEVINFO_FCT_START:               info->start = DEVTEMPLATE_ID(device_start_,);                break;
175#endif
176#if ((DEVTEMPLATE_FEATURES) & DT_HAS_RESET)
177      case DEVINFO_FCT_RESET:               info->reset = DEVTEMPLATE_ID(device_reset_,);                break;
178#endif
179#if ((DEVTEMPLATE_FEATURES) & DT_HAS_STOP)
180      case DEVINFO_FCT_STOP:               info->stop = DEVTEMPLATE_ID(device_stop_,);                break;
181#endif
182#if ((DEVTEMPLATE_FEATURES) & DT_HAS_EXECUTE)
183      case DEVINFO_FCT_EXECUTE:            info->execute = DEVTEMPLATE_ID(device_execute_,);             break;
184#endif
185#if ((DEVTEMPLATE_FEATURES) & DT_HAS_NVRAM)
186      case DEVINFO_FCT_NVRAM:               info->nvram = DEVTEMPLATE_ID(device_nvram_,);                break;
187#endif
188#if ((DEVTEMPLATE_FEATURES) & DT_HAS_VALIDITY_CHECK)
189      case DEVINFO_FCT_VALIDITY_CHECK:      info->validity_check = DEVTEMPLATE_ID(device_validity_check_,);   break;
190#endif
191#if ((DEVTEMPLATE_FEATURES) & DT_HAS_CUSTOM_CONFIG)
192      case DEVINFO_FCT_CUSTOM_CONFIG:         info->custom_config = DEVTEMPLATE_ID(device_custom_config_,);   break;
193#endif
194
195      /* --- the following bits of info are returned as NULL-terminated strings --- */
196      case DEVINFO_STR_NAME:               strcpy(info->s, DEVTEMPLATE_NAME);                        break;
197      case DEVINFO_STR_FAMILY:            strcpy(info->s, DEVTEMPLATE_FAMILY);                     break;
198      case DEVINFO_STR_VERSION:            strcpy(info->s, DEVTEMPLATE_VERSION);                     break;
199      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, DEVTEMPLATE_SOURCE);                     break;
200      case DEVINFO_STR_CREDITS:            strcpy(info->s, DEVTEMPLATE_CREDITS);                      break;
201   }
202}
203
204
205/* derived device case */
206#else
207
208/* declare callback functions */
209#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_START)
210static DEVICE_START( DEVTEMPLATE_DERIVED_ID(,) );
211#endif
212#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_RESET)
213static DEVICE_RESET( DEVTEMPLATE_DERIVED_ID(,) );
214#endif
215#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_STOP)
216static DEVICE_STOP( DEVTEMPLATE_DERIVED_ID(,) );
217#endif
218#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_EXECUTE)
219static DEVICE_EXECUTE( DEVTEMPLATE_DERIVED_ID(,) );
220#endif
221#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_NVRAM)
222static DEVICE_NVRAM( DEVTEMPLATE_DERIVED_ID(,) );
223#endif
224#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_VALIDITY_CHECK)
225static DEVICE_VALIDITY_CHECK( DEVTEMPLATE_DERIVED_ID(,) );
226#endif
227#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_CUSTOM_CONFIG)
228static DEVICE_CUSTOM_CONFIG( DEVTEMPLATE_DERIVED_ID(,) );
229#endif
230
231/* the actual get_info function */
232DEVICE_GET_INFO( DEVTEMPLATE_DERIVED_ID(,) )
233{
234   switch (state)
235   {
236      /* --- the following bits of info are returned as pointers --- */
237#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_ROM_REGION)
238      case DEVINFO_PTR_ROM_REGION:         info->romregion = DEVTEMPLATE_DERIVED_ID(rom_,);                  break;
239#endif
240#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_MACHINE_CONFIG)
241      case DEVINFO_PTR_MACHINE_CONFIG:      info->machine_config = DEVTEMPLATE_DERIVED_ID(machine_config_,);       break;
242#endif
243
244      /* --- the following bits of info are returned as pointers to data or functions --- */
245#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_START)
246      case DEVINFO_FCT_START:               info->start = DEVTEMPLATE_DERIVED_ID(device_start_,);                break;
247#endif
248#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_RESET)
249      case DEVINFO_FCT_RESET:               info->reset = DEVTEMPLATE_DERIVED_ID(device_reset_,);                break;
250#endif
251#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_STOP)
252      case DEVINFO_FCT_STOP:               info->stop = DEVTEMPLATE_DERIVED_ID(device_stop_,);                break;
253#endif
254#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_EXECUTE)
255      case DEVINFO_FCT_EXECUTE:            info->execute = DEVTEMPLATE_DERIVED_ID(device_execute_,);             break;
256#endif
257#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_NVRAM)
258      case DEVINFO_FCT_NVRAM:               info->nvram = DEVTEMPLATE_DERIVED_ID(device_nvram_,);                break;
259#endif
260#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_VALIDITY_CHECK)
261      case DEVINFO_FCT_VALIDITY_CHECK:      info->validity_check = DEVTEMPLATE_DERIVED_ID(device_validity_check_,); break;
262#endif
263#if ((DEVTEMPLATE_DERIVED_FEATURES) & DT_HAS_CUSTOM_CONFIG)
264      case DEVINFO_FCT_CUSTOM_CONFIG:         info->custom_config = DEVTEMPLATE_DERIVED_ID(device_custom_config_,);    break;
265#endif
266
267      /* --- the following bits of info are returned as NULL-terminated strings --- */
268      case DEVINFO_STR_NAME:               strcpy(info->s, DEVTEMPLATE_DERIVED_NAME);                        break;
269      default:                        DEVICE_GET_INFO_CALL(DEVTEMPLATE_ID(,));                        break;
270   }
271}
272
273#endif
274
275
276
277#undef DT_HAS_RESET
278#undef DT_HAS_STOP
279#undef DT_HAS_EXECUTE
280#undef DT_HAS_NVRAM
281#undef DT_HAS_VALIDITY_CHECK
282#undef DT_HAS_CUSTOM_CONFIG
283#undef DT_HAS_ROM_REGION
284#undef DT_HAS_MACHINE_CONFIG
285
286#undef DEVTEMPLATE_DERIVED_ID
287#undef DEVTEMPLATE_DERIVED_FEATURES
288#undef DEVTEMPLATE_DERIVED_NAME
src/emu/video/voodoo.c
r4939r4940
46434643
46444644
46454645/*-------------------------------------------------
4646    device get info callback
4646    device definition
46474647-------------------------------------------------*/
46484648
4649DEVICE_GET_INFO( voodoo )
4649INLINE const char *get_voodoo_name(const device_config *device)
46504650{
46514651   const voodoo_config *config = (device != NULL) ? (const voodoo_config *)device->inline_config : NULL;
4652   switch (state)
4652   switch (config->type)
46534653   {
4654      /* --- the following bits of info are returned as 64-bit signed integers --- */
4655      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(voodoo_state);         break;
4656      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = sizeof(voodoo_config);      break;
4657      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;         break;
4658
4659      /* --- the following bits of info are returned as pointers to data or functions --- */
4660      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(voodoo); break;
4661      case DEVINFO_FCT_STOP:               info->stop = DEVICE_STOP_NAME(voodoo); break;
4662      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(voodoo);break;
4663
4664      /* --- the following bits of info are returned as NULL-terminated strings --- */
4665      case DEVINFO_STR_NAME:
4666         switch (config->type)
4667         {
4668            default:
4669            case VOODOO_1:               strcpy(info->s, "3dfx Voodoo Graphics");break;
4670            case VOODOO_2:               strcpy(info->s, "3dfx Voodoo 2");      break;
4671            case VOODOO_BANSHEE:         strcpy(info->s, "3dfx Voodoo Banshee");   break;
4672            case VOODOO_3:               strcpy(info->s, "3dfx Voodoo 3");      break;
4673         }
4674         break;
4675      case DEVINFO_STR_FAMILY:            strcpy(info->s, "3dfx Voodoo Graphics");break;
4676      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");               break;
4677      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);            break;
4678      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break;
4654      default:
4655      case VOODOO_1:               return "3dfx Voodoo Graphics";
4656      case VOODOO_2:               return "3dfx Voodoo 2";
4657      case VOODOO_BANSHEE:         return "3dfx Voodoo Banshee";
4658      case VOODOO_3:               return "3dfx Voodoo 3";
46794659   }
46804660}
46814661
4662static const char *DEVTEMPLATE_SOURCE = __FILE__;
46824663
4664#define DEVTEMPLATE_ID(p,s)      p##voodoo##s
4665#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET | DT_HAS_STOP | DT_HAS_INLINE_CONFIG
4666#define DEVTEMPLATE_NAME      get_voodoo_name(device)
4667#define DEVTEMPLATE_FAMILY      "3dfx Voodoo Graphics"
4668#define DEVTEMPLATE_CLASS      DEVICE_CLASS_VIDEO
4669#include "devtempl.h"
46834670
4671
4672
46844673/***************************************************************************
46854674    COMMAND HANDLERS
46864675***************************************************************************/
src/emu/info.c
r4939r4940
100100}
101101
102102/*-------------------------------------------------
103    print_game_adjusters - print the Analog
104   Adjusters for a game
103    print_game_adjusters - print the Analog
104    Adjusters for a game
105105-------------------------------------------------*/
106106
107107static void print_game_adjusters(FILE *out, const game_driver *game, const input_port_config *portlist)
src/emu/memory.h
r4939r4940
776776#define AM_RAM                        AM_READWRITE(SMH_RAM, SMH_RAM)
777777#define AM_RAMBANK(_bank)               AM_READWRITE(SMH_BANK(_bank), SMH_BANK(_bank))
778778#define AM_RAM_WRITE(_write)            AM_READWRITE(SMH_RAM, _write)
779#define AM_READONLY                     AM_READ(SMH_RAM)
780779#define AM_WRITEONLY                  AM_WRITE(SMH_RAM)
781780
782781#define AM_UNMAP                     AM_READWRITE(SMH_UNMAP, SMH_UNMAP)
src/emu/machine/adc1213x.c
r4939r4940
1/*
2    ADC12130/ADC12132/ADC12138
1/***************************************************************************
32
4    Self-calibrating 12-bit Plus Sign Serial I/O A/D Converters with MUX and Sample/Hold
3    National Semiconductor ADC12130 / ADC12132 / ADC12138
54
5    Self-calibrating 12-bit Plus Sign Serial I/O A/D Converters with MUX
6        and Sample/Hold
7
68    TODO:
79        - Only ADC12138 currently supported
8*/
910
11    2009-06 Converted to be a device
12
13***************************************************************************/
14
1015#include "driver.h"
1116#include "adc1213x.h"
1217
13#define MAX_ADC1213X_CHIPS      4
1418
15typedef struct
19/***************************************************************************
20    TYPE DEFINITIONS
21***************************************************************************/
22
23typedef struct _adc12138_state adc12138_state;
24struct _adc12138_state
1625{
26   adc1213x_input_convert_func input_callback_r;
27
1728   int cycle;
1829   int data_out;
1930   int data_in;
r4939r4940
2637   int input_shift_reg;
2738   int output_shift_reg;
2839   int end_conv;
40};
2941
30   double (*input_callback)(running_machine *machine, int input);
31} ADC1213X;
3242
33static ADC1213X adc1213x[MAX_ADC1213X_CHIPS];
34
3543#define ADC1213X_CONV_MODE_12_MSB_FIRST         0
3644#define ADC1213X_CONV_MODE_16_MSB_FIRST         1
3745#define ADC1213X_CONV_MODE_12_LSB_FIRST         2
r4939r4940
4250#define ADC1213X_ACQUISITION_TIME_18_CCLK      2
4351#define ADC1213X_ACQUISITION_TIME_34_CCLK      3
4452
45int adc1213x_do_r(int chip)
53/***************************************************************************
54    INLINE FUNCTIONS
55***************************************************************************/
56
57INLINE adc12138_state *get_safe_token(const device_config *device)
4658{
47   //printf("ADC: DO\n");
48   return adc1213x[chip].data_out;
59   assert(device != NULL);
60   assert(device->token != NULL);
61   assert((device->type == ADC12130) || (device->type == ADC12132) || (device->type == ADC12138));
62   return (adc12138_state *)device->token;
4963}
5064
51void adc1213x_di_w(int chip, int state)
65INLINE const adc12138_interface *get_interface(const device_config *device)
5266{
53   adc1213x[chip].data_in = state & 1;
67   assert(device != NULL);
68   assert((device->type == ADC12130) || (device->type == ADC12132) || (device->type == ADC12138));
69   return (const adc12138_interface *) device->static_config;
5470}
5571
56static void adc1213x_convert(running_machine *machine, int chip, int channel, int bits16, int lsbfirst)
72
73/***************************************************************************
74    IMPLEMENTATION
75***************************************************************************/
76
77/*-------------------------------------------------
78    adc1213x_di_w
79-------------------------------------------------*/
80
81WRITE8_DEVICE_HANDLER( adc1213x_di_w )
5782{
83   adc12138_state *adc1213x = get_safe_token(device);
84   adc1213x->data_in = data & 1;
85}
86
87/*-------------------------------------------------
88    adc1213x_convert
89-------------------------------------------------*/
90
91static void adc1213x_convert(const device_config *device, int channel, int bits16, int lsbfirst)
92{
93   adc12138_state *adc1213x = get_safe_token(device);
5894   int i;
5995   int bits;
6096   int input_value;
61   double input;
97   double input = 0;
6298
6399   if (bits16)
64100      fatalerror("ADC1213X: 16-bit mode not supported\n");
r4939r4940
70106   {
71107      case 0x8:      // H L L L - CH0 (single-ended)
72108      {
73         input = adc1213x[chip].input_callback(machine, 0);
109         input = adc1213x->input_callback_r(device, 0);
74110         break;
75111      }
76112      case 0xc:      // H H L L - CH1 (single-ended)
77113      {
78         input = adc1213x[chip].input_callback(machine, 1);
114         input = adc1213x->input_callback_r(device, 1);
79115         break;
80116      }
81117      case 0x9:      // H L L H - CH2 (single-ended)
82118      {
83         input = adc1213x[chip].input_callback(machine, 2);
119         input = adc1213x->input_callback_r(device, 2);
84120         break;
85121      }
86122      case 0xd:      // H H L H - CH3 (single-ended)
87123      {
88         input = adc1213x[chip].input_callback(machine, 3);
124         input = adc1213x->input_callback_r(device, 3);
89125         break;
90126      }
91127      case 0xa:      // H L H L - CH4 (single-ended)
92128      {
93         input = adc1213x[chip].input_callback(machine, 4);
129         input = adc1213x->input_callback_r(device, 4);
94130         break;
95131      }
96132      case 0xe:      // H H H L - CH5 (single-ended)
97133      {
98         input = adc1213x[chip].input_callback(machine, 5);
134         input = adc1213x->input_callback_r(device, 5);
99135         break;
100136      }
101137      case 0xb:      // H L H H - CH6 (single-ended)
102138      {
103         input = adc1213x[chip].input_callback(machine, 6);
139         input = adc1213x->input_callback_r(device, 6);
104140         break;
105141      }
106142      case 0xf:      // H H H H - CH7 (single-ended)
107143      {
108         input = adc1213x[chip].input_callback(machine, 7);
144         input = adc1213x->input_callback_r(device, 7);
109145         break;
110146      }
111147      default:
r4939r4940
119155   bits = 12;
120156
121157   // sign-extend if needed
122   if (adc1213x[chip].data_out_sign)
158   if (adc1213x->data_out_sign)
123159   {
124160      input_value = input_value | ((input_value & 0x800) << 1);
125161      bits++;
126162   }
127163
128   adc1213x[chip].output_shift_reg = 0;
164   adc1213x->output_shift_reg = 0;
129165
130166   for (i=0; i < bits; i++)
131167   {
132168      if (input_value & (1 << ((bits-1) - i)))
133169      {
134         adc1213x[chip].output_shift_reg |= (1 << i);
170         adc1213x->output_shift_reg |= (1 << i);
135171      }
136172   }
137173
138   adc1213x[chip].data_out = adc1213x[chip].output_shift_reg & 1;
139   adc1213x[chip].output_shift_reg >>= 1;
174   adc1213x->data_out = adc1213x->output_shift_reg & 1;
175   adc1213x->output_shift_reg >>= 1;
140176}
141177
142void adc1213x_cs_w(running_machine *machine, int chip, int state)
178/*-------------------------------------------------
179    adc1213x_cs_w
180-------------------------------------------------*/
181
182WRITE8_DEVICE_HANDLER( adc1213x_cs_w )
143183{
144   if (state)
184   adc12138_state *adc1213x = get_safe_token(device);
185
186   if (data)
145187   {
146188      //printf("ADC: CS\n");
147189
148      if (adc1213x[chip].cycle >= 7)
190      if (adc1213x->cycle >= 7)
149191      {
150         int mode = adc1213x[chip].input_shift_reg >> (adc1213x[chip].cycle - 8);
192         int mode = adc1213x->input_shift_reg >> (adc1213x->cycle - 8);
151193
152194         switch (mode & 0xf)
153195         {
154196            case 0x0:      // X X X X L L L L - 12 or 13 Bit MSB First conversion
155197            {
156               adc1213x_convert(machine, chip, (mode >> 4) & 0xf, 0, 0);
198               adc1213x_convert(device, (mode >> 4) & 0xf, 0, 0);
157199               break;
158200            }
159201            case 0x1:      // X X X X L L L H - 16 or 17 Bit MSB First conversion
160202            {
161               adc1213x_convert(machine, chip, (mode >> 4) & 0xf, 1, 0);
203               adc1213x_convert(device, (mode >> 4) & 0xf, 1, 0);
162204               break;
163205            }
164206            case 0x4:      // X X X X L H L L - 12 or 13 Bit LSB First conversion
165207            {
166               adc1213x_convert(machine, chip, (mode >> 4) & 0xf, 0, 1);
208               adc1213x_convert(device, (mode >> 4) & 0xf, 0, 1);
167209               break;
168210            }
169211            case 0x5:      // X X X X L H L H - 16 or 17 Bit LSB First conversion
170212            {
171               adc1213x_convert(machine, chip, (mode >> 4) & 0xf, 1, 1);
213               adc1213x_convert(device, (mode >> 4) & 0xf, 1, 1);
172214               break;
173215            }
174216
r4939r4940
178220               {
179221                  case 0x08:      // L L L L H L L L - Auto cal
180222                  {
181                     adc1213x[chip].auto_cal = 1;
223                     adc1213x->auto_cal = 1;
182224                     break;
183225                  }
184226
185227                  case 0x0e:      // L L L L H H H L - Acquisition time 6 CCLK cycles
186228                  {
187                     adc1213x[chip].acq_time = ADC1213X_ACQUISITION_TIME_6_CCLK;
229                     adc1213x->acq_time = ADC1213X_ACQUISITION_TIME_6_CCLK;
188230                     break;
189231                  }
190232
191233                  case 0x8d:      // H L L L H H L H - Data out with sign
192234                  {
193                     adc1213x[chip].data_out_sign = 1;
235                     adc1213x->data_out_sign = 1;
194236                     break;
195237                  }
196238
r4939r4940
204246         }
205247      }
206248
207      adc1213x[chip].cycle = 0;
208      adc1213x[chip].input_shift_reg = 0;
249      adc1213x->cycle = 0;
250      adc1213x->input_shift_reg = 0;
209251
210      adc1213x[chip].end_conv = 0;
252      adc1213x->end_conv = 0;
211253   }
212254}
213255
214void adc1213x_sclk_w(int chip, int state)
256/*-------------------------------------------------
257    adc1213x_sclk_w
258-------------------------------------------------*/
259
260WRITE8_DEVICE_HANDLER( adc1213x_sclk_w )
215261{
216   if (state)
262   adc12138_state *adc1213x = get_safe_token(device);
263
264   if (data)
217265   {
218      //printf("ADC: cycle %d, DI = %d\n", adc1213x[chip].cycle, adc1213x[chip].data_in);
266      //printf("ADC: cycle %d, DI = %d\n", adc1213x->cycle, adc1213x->data_in);
219267
220      adc1213x[chip].input_shift_reg <<= 1;
221      adc1213x[chip].input_shift_reg |= adc1213x[chip].data_in;
268      adc1213x->input_shift_reg <<= 1;
269      adc1213x->input_shift_reg |= adc1213x->data_in;
222270
223      adc1213x[chip].data_out = adc1213x[chip].output_shift_reg & 1;
224      adc1213x[chip].output_shift_reg >>= 1;
271      adc1213x->data_out = adc1213x->output_shift_reg & 1;
272      adc1213x->output_shift_reg >>= 1;
225273
226      adc1213x[chip].cycle++;
274      adc1213x->cycle++;
227275   }
228276}
229277
230void adc1213x_conv_w(int chip, int state)
278/*-------------------------------------------------
279    adc1213x_conv_w
280-------------------------------------------------*/
281
282WRITE8_DEVICE_HANDLER( adc1213x_conv_w )
231283{
232   adc1213x[chip].end_conv = 1;
284   adc12138_state *adc1213x = get_safe_token(device);
285   adc1213x->end_conv = 1;
233286}
234287
235int adc1213x_eoc_r(int chip)
288/*-------------------------------------------------
289    adc1213x_do_r
290-------------------------------------------------*/
291
292READ8_DEVICE_HANDLER( adc1213x_do_r )
236293{
237   return adc1213x[chip].end_conv;
294   adc12138_state *adc1213x = get_safe_token(device);
295
296   //printf("ADC: DO\n");
297   return adc1213x->data_out;
238298}
239299
240void adc1213x_init(int chip, double (*input_callback)( running_machine *machine, int input ))
300/*-------------------------------------------------
301    adc1213x_eoc_r
302-------------------------------------------------*/
303
304READ8_DEVICE_HANDLER( adc1213x_eoc_r )
241305{
242   memset(&adc1213x[chip], 0, sizeof(ADC1213X));
306   adc12138_state *adc1213x = get_safe_token(device);
307   return adc1213x->end_conv;
308}
243309
244   adc1213x[chip].conv_mode = ADC1213X_CONV_MODE_12_MSB_FIRST;
245   adc1213x[chip].data_out_sign = 1;
246   adc1213x[chip].auto_cal = 0;
247   adc1213x[chip].auto_zero = 0;
248   adc1213x[chip].acq_time = ADC1213X_ACQUISITION_TIME_10_CCLK;
310/*-------------------------------------------------
311    DEVICE_START( adc1213x )
312-------------------------------------------------*/
249313
250   adc1213x[chip].input_callback = input_callback;
314static DEVICE_START( adc12138 )
315{
316   adc12138_state *adc1213x = get_safe_token(device);
317   const adc12138_interface *intf = get_interface(device);
318
319   /* resolve callbacks */
320   adc1213x->input_callback_r = intf->input_callback_r;
321
322   /* register for state saving */
323   state_save_register_device_item(device, 0, adc1213x->cycle);
324   state_save_register_device_item(device, 0, adc1213x->data_out);
325   state_save_register_device_item(device, 0, adc1213x->data_in);
326   state_save_register_device_item(device, 0, adc1213x->conv_mode);
327   state_save_register_device_item(device, 0, adc1213x->auto_cal);
328   state_save_register_device_item(device, 0, adc1213x->auto_zero);
329   state_save_register_device_item(device, 0, adc1213x->acq_time);
330   state_save_register_device_item(device, 0, adc1213x->data_out_sign);
331   state_save_register_device_item(device, 0, adc1213x->mode);
332   state_save_register_device_item(device, 0, adc1213x->input_shift_reg);
333   state_save_register_device_item(device, 0, adc1213x->output_shift_reg);
334   state_save_register_device_item(device, 0, adc1213x->end_conv);
251335}
336
337
338/*-------------------------------------------------
339    DEVICE_RESET( adc1213x )
340-------------------------------------------------*/
341
342static DEVICE_RESET( adc12138 )
343{
344   adc12138_state *adc1213x = get_safe_token(device);
345
346   adc1213x->conv_mode = ADC1213X_CONV_MODE_12_MSB_FIRST;
347   adc1213x->data_out_sign = 1;
348   adc1213x->auto_cal = 0;
349   adc1213x->auto_zero = 0;
350   adc1213x->acq_time = ADC1213X_ACQUISITION_TIME_10_CCLK;
351}
352
353/*-------------------------------------------------
354    device definition
355-------------------------------------------------*/
356
357static const char *DEVTEMPLATE_SOURCE = __FILE__;
358
359#define DEVTEMPLATE_ID(p,s)      p##adc12138##s
360#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
361#define DEVTEMPLATE_NAME      "A/D Converter 12138"
362#define DEVTEMPLATE_FAMILY      "National Semiconductor A/D Converters 1213x"
363#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
364#include "devtempl.h"
365
366#define DEVTEMPLATE_DERIVED_ID(p,s)      p##adc12130##s
367#define DEVTEMPLATE_DERIVED_FEATURES   0
368#define DEVTEMPLATE_DERIVED_NAME      "A/D Converter 12130"
369#include "devtempl.h"
370
371#define DEVTEMPLATE_DERIVED_ID(p,s)      p##adc12132##s
372#define DEVTEMPLATE_DERIVED_FEATURES   0
373#define DEVTEMPLATE_DERIVED_NAME      "A/D Converter 12132"
374#include "devtempl.h"
src/emu/machine/6821pia.c
r4939r4940
1111    TYPE DEFINITIONS
1212***************************************************************************/
1313
14typedef struct _pia6821 pia6821;
15struct _pia6821
14typedef struct _pia6821_state pia6821_state;
15struct _pia6821_state
1616{
1717   devcb_resolved_read8 in_a_func;
1818   devcb_resolved_read8 in_b_func;
r4939r4940
106106    INLINE FUNCTIONS
107107***************************************************************************/
108108
109INLINE pia6821 *get_token(const device_config *device)
109INLINE pia6821_state *get_token(const device_config *device)
110110{
111111   assert(device != NULL);
112112   assert((device->type == PIA6821) || (device->type == PIA6822));
113   return (pia6821 *) device->token;
113   return (pia6821_state *) device->token;
114114}
115115
116116
r4939r4940
127127***************************************************************************/
128128
129129/*-------------------------------------------------
130    DEVICE_START( pia )
130    DEVICE_START( pia6821 )
131131-------------------------------------------------*/
132132
133static DEVICE_START( pia )
133static DEVICE_START( pia6821 )
134134{
135   pia6821 *p = get_token(device);
135   pia6821_state *p = get_token(device);
136136   const pia6821_interface *intf = get_interface(device);
137137
138138   /* clear structure */
r4939r4940
188188
189189
190190/*-------------------------------------------------
191    DEVICE_RESET( pia )
191    DEVICE_RESET( pia6821 )
192192-------------------------------------------------*/
193193
194static DEVICE_RESET( pia )
194static DEVICE_RESET( pia6821 )
195195{
196   pia6821 *p = get_token(device);
196   pia6821_state *p = get_token(device);
197197
198198   /*
199199     * set default read values.
r4939r4940
253253
254254static void update_interrupts(const device_config *device)
255255{
256   pia6821 *p = get_token(device);
256   pia6821_state *p = get_token(device);
257257   int new_state;
258258
259259   /* start with IRQ A */
r4939r4940
282282
283283static UINT8 get_in_a_value(const device_config *device)
284284{
285   pia6821 *p = get_token(device);
285   pia6821_state *p = get_token(device);
286286   UINT8 port_a_data = 0;
287287   UINT8 ret;
288288
r4939r4940
323323
324324static UINT8 get_in_b_value(const device_config *device)
325325{
326   pia6821 *p = get_token(device);
326   pia6821_state *p = get_token(device);
327327   UINT8 ret;
328328
329329   if (p->ddr_b == 0xff)
r4939r4940
367367
368368static UINT8 get_out_a_value(const device_config *device)
369369{
370   pia6821 *p = get_token(device);
370   pia6821_state *p = get_token(device);
371371   UINT8 ret;
372372
373373   if (p->ddr_a == 0xff)
r4939r4940
387387
388388static UINT8 get_out_b_value(const device_config *device)
389389{
390   pia6821 *p = get_token(device);
390   pia6821_state *p = get_token(device);
391391
392392   /* input pins are high-impedance - we just send them as zeros for backwards compatibility */
393393   return p->out_b & p->ddr_b;
r4939r4940
400400
401401static void set_out_ca2(const device_config *device, int data)
402402{
403   pia6821 *p = get_token(device);
403   pia6821_state *p = get_token(device);
404404
405405   if (data != p->out_ca2)
406406   {
r4939r4940
426426
427427static void set_out_cb2(const device_config *device, int data)
428428{
429   pia6821 *p = get_token(device);
429   pia6821_state *p = get_token(device);
430430
431431   int z = pia6821_get_output_cb2_z(device);
432432
r4939r4940
455455
456456static UINT8 port_a_r(const device_config *device)
457457{
458   pia6821 *p = get_token(device);
458   pia6821_state *p = get_token(device);
459459
460460   UINT8 ret = get_in_a_value(device);
461461
r4939r4940
487487
488488static UINT8 ddr_a_r(const device_config *device)
489489{
490   pia6821 *p = get_token(device);
490   pia6821_state *p = get_token(device);
491491
492492   UINT8 ret = p->ddr_a;
493493
r4939r4940
503503
504504static UINT8 port_b_r(const device_config *device)
505505{
506   pia6821 *p = get_token(device);
506   pia6821_state *p = get_token(device);
507507
508508   UINT8 ret = get_in_b_value(device);
509509
r4939r4940
531531
532532static UINT8 ddr_b_r(const device_config *device)
533533{
534   pia6821 *p = get_token(device);
534   pia6821_state *p = get_token(device);
535535
536536   UINT8 ret = p->ddr_b;
537537
r4939r4940
547547
548548static UINT8 control_a_r(const device_config *device)
549549{
550   pia6821 *p = get_token(device);
550   pia6821_state *p = get_token(device);
551551   UINT8 ret;
552552
553553   /* update CA1 & CA2 if callback exists, these in turn may update IRQ's */
r4939r4940
589589
590590static UINT8 control_b_r(const device_config *device)
591591{
592   pia6821 *p = get_token(device);
592   pia6821_state *p = get_token(device);
593593   UINT8 ret;
594594
595595   /* update CB1 & CB2 if callback exists, these in turn may update IRQ's */
r4939r4940
631631
632632READ8_DEVICE_HANDLER( pia6821_r )
633633{
634   pia6821 *p = get_token(device);
634   pia6821_state *p = get_token(device);
635635   UINT8 ret;
636636
637637   switch (offset & 0x03)
r4939r4940
680680
681681UINT8 pia6821_get_port_b_z_mask(const device_config *device)
682682{
683   pia6821 *p = get_token(device);
683   pia6821_state *p = get_token(device);
684684   return ~p->ddr_b;
685685}
686686
r4939r4940
691691
692692static void send_to_out_a_func(const device_config *device, const char* message)
693693{
694   pia6821 *p = get_token(device);
694   pia6821_state *p = get_token(device);
695695
696696   /* input pins are pulled high */
697697   UINT8 data = get_out_a_value(device);
r4939r4940
716716
717717static void send_to_out_b_func(const device_config *device, const char* message)
718718{
719   pia6821 *p = get_token(device);
719   pia6821_state *p = get_token(device);
720720
721721   /* input pins are high-impedance - we just send them as zeros for backwards compatibility */
722722   UINT8 data = get_out_b_value(device);
r4939r4940
741741
742742static void port_a_w(const device_config *device, UINT8 data)
743743{
744   pia6821 *p = get_token(device);
744   pia6821_state *p = get_token(device);
745745
746746   /* buffer the output value */
747747   p->out_a = data;
r4939r4940
756756
757757static void ddr_a_w(const device_config *device, UINT8 data)
758758{
759   pia6821 *p = get_token(device);
759   pia6821_state *p = get_token(device);
760760
761761   if (data == 0x00)
762762      LOG(("PIA #%s: DDR A write = %02X (input mode)\n", device->tag, data));
r4939r4940
781781
782782static void port_b_w(const device_config *device, UINT8 data)
783783{
784   pia6821 *p = get_token(device);
784   pia6821_state *p = get_token(device);
785785
786786   /* buffer the output value */
787787   p->out_b = data;
r4939r4940
807807
808808static void ddr_b_w(const device_config *device, UINT8 data)
809809{
810   pia6821 *p = get_token(device);
810   pia6821_state *p = get_token(device);
811811
812812   if (data == 0x00)
813813      LOG(("PIA #%s: DDR B write = %02X (input mode)\n", device->tag, data));
r4939r4940
832832
833833static void control_a_w(const device_config *device, UINT8 data)
834834{
835   pia6821 *p = get_token(device);
835   pia6821_state *p = get_token(device);
836836
837837   /* bit 7 and 6 are read only */
838838   data &= 0x3f;
r4939r4940
868868
869869static void control_b_w(const device_config *device, UINT8 data)
870870{
871   pia6821 *p = get_token(device);
871   pia6821_state *p = get_token(device);
872872   int temp;
873873
874874   /* bit 7 and 6 are read only */
r4939r4940
899899
900900WRITE8_DEVICE_HANDLER( pia6821_w )
901901{
902   pia6821 *p = get_token(device);
902   pia6821_state *p = get_token(device);
903903
904904   switch (offset & 0x03)
905905   {
r4939r4940
945945
946946void pia6821_set_port_a_z_mask(const device_config *device, UINT8 data)
947947{
948   pia6821 *p = get_token(device);
948   pia6821_state *p = get_token(device);
949949
950950   p->port_a_z_mask = data;
951951}
r4939r4940
957957
958958READ8_DEVICE_HANDLER( pia6821_porta_r )
959959{
960   pia6821 *p = get_token(device);
960   pia6821_state *p = get_token(device);
961961
962962   return p->in_a;
963963}
r4939r4940
969969
970970void pia6821_set_input_a(const device_config *device, UINT8 data, UINT8 z_mask)
971971{
972   pia6821 *p = get_token(device);
972   pia6821_state *p = get_token(device);
973973
974974   assert_always(p->in_a_func.read == NULL, "pia6821_porta_w() called when in_a_func implemented");
975975
r4939r4940
997997
998998UINT8 pia6821_get_output_a(const device_config *device)
999999{
1000   pia6821 *p = get_token(device);
1000   pia6821_state *p = get_token(device);
10011001
10021002   p->out_a_needs_pulled = FALSE;
10031003
r4939r4940
10111011
10121012READ8_DEVICE_HANDLER( pia6821_ca1_r )
10131013{
1014   pia6821 *p = get_token(device);
1014   pia6821_state *p = get_token(device);
10151015
10161016   return p->in_ca1;
10171017}
r4939r4940
10231023
10241024WRITE8_DEVICE_HANDLER( pia6821_ca1_w )
10251025{
1026   pia6821 *p = get_token(device);
1026   pia6821_state *p = get_token(device);
10271027
10281028   /* limit the data to 0 or 1 */
10291029   data = data ? TRUE : FALSE;
r4939r4940
10591059
10601060READ8_DEVICE_HANDLER( pia6821_ca2_r )
10611061{
1062   pia6821 *p = get_token(device);
1062   pia6821_state *p = get_token(device);
10631063
10641064   return p->in_ca2;
10651065}
r4939r4940
10711071
10721072WRITE8_DEVICE_HANDLER( pia6821_ca2_w )
10731073{
1074   pia6821 *p = get_token(device);
1074   pia6821_state *p = get_token(device);
10751075
10761076   /* limit the data to 0 or 1 */
10771077   data = data ? 1 : 0;
r4939r4940
11041104
11051105int pia6821_get_output_ca2(const device_config *device)
11061106{
1107   pia6821 *p = get_token(device);
1107   pia6821_state *p = get_token(device);
11081108
11091109   p->out_ca2_needs_pulled = FALSE;
11101110
r4939r4940
11201120
11211121int pia6821_get_output_ca2_z(const device_config *device)
11221122{
1123   pia6821 *p = get_token(device);
1123   pia6821_state *p = get_token(device);
11241124
11251125   p->out_ca2_needs_pulled = FALSE;
11261126
r4939r4940
11371137
11381138READ8_DEVICE_HANDLER( pia6821_portb_r )
11391139{
1140   pia6821 *p = get_token(device);
1140   pia6821_state *p = get_token(device);
11411141
11421142   return p->in_b;
11431143}
r4939r4940
11491149
11501150WRITE8_DEVICE_HANDLER( pia6821_portb_w )
11511151{
1152   pia6821 *p = get_token(device);
1152   pia6821_state *p = get_token(device);
11531153
11541154   assert_always(p->in_b_func.read == NULL, "pia_set_input_b() called when in_b_func implemented");
11551155
r4939r4940
11661166
11671167UINT8 pia6821_get_output_b(const device_config *device)
11681168{
1169   pia6821 *p = get_token(device);
1169   pia6821_state *p = get_token(device);
11701170
11711171   p->out_b_needs_pulled = FALSE;
11721172
r4939r4940
11801180
11811181READ8_DEVICE_HANDLER( pia6821_cb1_r )
11821182{
1183   pia6821 *p = get_token(device);
1183   pia6821_state *p = get_token(device);
11841184
11851185   return p->in_cb1;
11861186}
r4939r4940
11921192
11931193WRITE8_DEVICE_HANDLER( pia6821_cb1_w )
11941194{
1195   pia6821 *p = get_token(device);
1195   pia6821_state *p = get_token(device);
11961196
11971197   /* limit the data to 0 or 1 */
11981198   data = data ? 1 : 0;
r4939r4940
12291229
12301230READ8_DEVICE_HANDLER( pia6821_cb2_r )
12311231{
1232   pia6821 *p = get_token(device);
1232   pia6821_state *p = get_token(device);
12331233
12341234   return p->in_cb2;
12351235}
r4939r4940
12411241
12421242WRITE8_DEVICE_HANDLER( pia6821_cb2_w )
12431243{
1244   pia6821 *p = get_token(device);
1244   pia6821_state *p = get_token(device);
12451245
12461246   /* limit the data to 0 or 1 */
12471247   data = data ? 1 : 0;
r4939r4940
12741274
12751275int pia6821_get_output_cb2(const device_config *device)
12761276{
1277   pia6821 *p = get_token(device);
1277   pia6821_state *p = get_token(device);
12781278
12791279   p->out_cb2_needs_pulled = FALSE;
12801280
r4939r4940
12881288
12891289int pia6821_get_output_cb2_z(const device_config *device)
12901290{
1291   pia6821 *p = get_token(device);
1291   pia6821_state *p = get_token(device);
12921292
12931293   return !C2_OUTPUT(p->ctl_b);
12941294}
r4939r4940
13001300
13011301int pia6821_get_irq_a(const device_config *device)
13021302{
1303   pia6821 *p = get_token(device);
1303   pia6821_state *p = get_token(device);
13041304
13051305   return p->irq_a_state;
13061306}
r4939r4940
13121312
13131313int pia6821_get_irq_b(const device_config *device)
13141314{
1315   pia6821 *p = get_token(device);
1315   pia6821_state *p = get_token(device);
13161316
13171317   return p->irq_b_state;
13181318}
13191319
13201320
13211321/*-------------------------------------------------
1322    DEVICE_GET_INFO( pia6821 )
1322    device definition
13231323-------------------------------------------------*/
13241324
1325DEVICE_GET_INFO(pia6821)
1326{
1327   switch (state)
1328   {
1329      /* --- the following bits of info are returned as 64-bit signed integers --- */
1330      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(pia6821);               break;
1331      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
1332      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
1325static const char *DEVTEMPLATE_SOURCE = __FILE__;
13331326
1334      /* --- the following bits of info are returned as pointers to data or functions --- */
1335      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(pia);      break;
1336      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
1337      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(pia);      break;
1327#define DEVTEMPLATE_ID(p,s)            p##pia6821##s
1328#define DEVTEMPLATE_FEATURES         DT_HAS_START | DT_HAS_RESET
1329#define DEVTEMPLATE_NAME            "6821 PIA"
1330#define DEVTEMPLATE_FAMILY            "6821 PIA"
1331#include "devtempl.h"
13381332
1339      /* --- the following bits of info are returned as NULL-terminated strings --- */
1340      case DEVINFO_STR_NAME:                     strcpy(info->s, "6821 PIA");            break;
1341      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "6821 PIA");            break;
1342      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
1343      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
1344      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
1345   }
1346}
1347
1348
1349/*-------------------------------------------------
1350    DEVICE_GET_INFO( pia6822 )
1351-------------------------------------------------*/
1352
1353DEVICE_GET_INFO(pia6822)
1354{
1355   switch (state)
1356   {
1357      case DEVINFO_STR_NAME:                     strcpy(info->s, "6822 PIA");            break;
1358      default:                               DEVICE_GET_INFO_CALL(pia6821);            break;
1359   }
1360}
1333#define DEVTEMPLATE_DERIVED_ID(p,s)      p##pia6822##s
1334#define DEVTEMPLATE_DERIVED_FEATURES   0
1335#define DEVTEMPLATE_DERIVED_NAME      "6822 PIA"
1336#include "devtempl.h"
src/emu/machine/adc1213x.h
r4939r4940
1/*
2    ADC12130/ADC12132/ADC12138
1/***************************************************************************
32
4    Self-calibrating 12-bit Plus Sign Serial I/O A/D Converters with MUX and Sample/Hold
5*/
3    National Semiconductor ADC12130 / ADC12132 / ADC12138
64
7#ifndef ADC1213X_H
8#define ADC1213X_H
5    Self-calibrating 12-bit Plus Sign Serial I/O A/D Converters with MUX
6        and Sample/Hold
97
10int adc1213x_do_r(int chip);
11void adc1213x_di_w(int chip, int state);
12void adc1213x_cs_w(running_machine *machine, int chip, int state);
13void adc1213x_sclk_w(int chip, int state);
14void adc1213x_conv_w(int chip, int state);
15int adc1213x_eoc_r(int chip);
16void adc1213x_init(int chip, double (*input_callback)( running_machine *machine, int input ));
8***************************************************************************/
179
18#endif
10#ifndef __ADC1213X_H__
11#define __ADC1213X_H__
12
13#include "devcb.h"
14
15/***************************************************************************
16    MACROS / CONSTANTS
17***************************************************************************/
18
19#define ADC12130      DEVICE_GET_INFO_NAME(adc12130)
20#define ADC12132      DEVICE_GET_INFO_NAME(adc12132)
21#define ADC12138      DEVICE_GET_INFO_NAME(adc12138)
22
23#define MDRV_ADC12130_ADD(_tag, _config) \
24   MDRV_DEVICE_ADD(_tag, ADC12130, 0) \
25   MDRV_DEVICE_CONFIG(_config)
26
27#define MDRV_ADC12130_REMOVE(_tag) \
28   MDRV_DEVICE_REMOVE(_tag)
29
30#define MDRV_ADC12132_ADD(_tag, _config) \
31   MDRV_DEVICE_ADD(_tag, ADC12132, 0) \
32   MDRV_DEVICE_CONFIG(_config)
33
34#define MDRV_ADC12132_REMOVE(_tag) \
35   MDRV_DEVICE_REMOVE(_tag)
36
37#define MDRV_ADC12138_ADD(_tag, _config) \
38   MDRV_DEVICE_ADD(_tag, ADC12138, 0) \
39   MDRV_DEVICE_CONFIG(_config)
40
41#define MDRV_ADC12138_REMOVE(_tag) \
42   MDRV_DEVICE_REMOVE(_tag)
43
44
45/***************************************************************************
46    TYPE DEFINITIONS
47***************************************************************************/
48
49typedef double (*adc1213x_input_convert_func)(const device_config *device, UINT8 input);
50
51typedef struct _adc12138_interface adc12138_interface;
52struct _adc12138_interface
53{
54   adc1213x_input_convert_func input_callback_r;
55};
56
57/***************************************************************************
58    PROTOTYPES
59***************************************************************************/
60
61/* device interface */
62DEVICE_GET_INFO( adc12130 );
63DEVICE_GET_INFO( adc12132 );
64DEVICE_GET_INFO( adc12138 );
65
66extern WRITE8_DEVICE_HANDLER( adc1213x_di_w );
67extern WRITE8_DEVICE_HANDLER( adc1213x_cs_w );
68extern WRITE8_DEVICE_HANDLER( adc1213x_sclk_w );
69extern WRITE8_DEVICE_HANDLER( adc1213x_conv_w );
70extern READ8_DEVICE_HANDLER( adc1213x_do_r );
71extern READ8_DEVICE_HANDLER( adc1213x_eoc_r );
72
73#endif   /* __ADC1213X_H__ */
src/emu/machine/6840ptm.c
r4939r4940
1/**********************************************************************
1/***************************************************************************
22
3    Motorola 6840 (PTM)
34
4    Motorola 6840 PTM interface and emulation
5    Programmable Timer Module
56
6    This function is a simple emulation of up to 4 MC6840
7    Programmable Timer Modules
8
97    Written By J.Wallace based on previous work by Aaron Giles,
108   'Re-Animator' and Mathis Rosenhauer.
119
r4939r4940
3028    should be used instead if necessary (This should allow the VBLANK
3129    clock on the MCR units to operate).
3230
33**********************************************************************/
3431
32    2009-06 Converted to be a device
33
34***************************************************************************/
35
3536#include "driver.h"
3637#include "6840ptm.h"
3738
38// Defines /////////////////////////////////////////////////////////////
3939
4040#define PTMVERBOSE 0
4141#define PLOG(x) do { if (PTMVERBOSE) logerror x; } while (0)
4242
43/***************************************************************************
44    PARAMETERS / PROTOTYPES
45***************************************************************************/
46
4347enum
4448{
4549   PTM_6840_CTRL1   = 0,
r4939r4940
5357   PTM_6840_LSB3    = 7,
5458};
5559
60static const char *const opmode[] =
61{
62   "000 continous mode",
63   "001 freq comparison mode",
64   "010 continous mode",
65   "011 pulse width comparison mode",
66   "100 single shot mode",
67   "101 freq comparison mode",
68   "110 single shot mode",
69   "111 pulse width comparison mode"
70};
5671
57typedef struct _ptm6840
72static void ptm6840_timeout(const device_config *device, int idx);
73
74/***************************************************************************
75    TYPE DEFINITIONS
76***************************************************************************/
77
78typedef struct _ptm6840_state ptm6840_state;
79struct _ptm6840_state
5880{
59   const ptm6840_interface *intf;
81   int internal_clock;
82   int external_clock[3];
83   devcb_resolved_write8 out_func[3];   // function to call when output[idx] changes
84   devcb_resolved_write_line irq_func;   // function called if IRQ line changes
6085
6186   UINT8 control_reg[3];
6287   UINT8 output[3]; /* Output states */
r4939r4940
7398   UINT8 lsb_buffer;
7499   UINT8 msb_buffer;
75100
76   int internal_clock;
77   int external_clock[3];
78
79101   /* Each PTM has 3 timers */
80102   emu_timer *timer[3];
81103
82104   UINT16 latch[3];
83105   UINT16 counter[3];
84} ptm6840;
106};
85107
86// Local prototypes ///////////////////////////////////////////////////////
87108
88static void ptm6840_timeout(running_machine *machine, int which, int idx);
89static TIMER_CALLBACK( ptm6840_timer_cb );
109/***************************************************************************
110    INLINE FUNCTIONS
111***************************************************************************/
90112
91// Local vars /////////////////////////////////////////////////////////////
113INLINE ptm6840_state *get_safe_token(const device_config *device)
114{
115   assert(device != NULL);
116   assert(device->token != NULL);
117   assert((device->type == PTM6840));
118   return (ptm6840_state *)device->token;
119}
92120
93static ptm6840 ptm[PTM_6840_MAX];
94
95static const char *const opmode[] =
121INLINE const ptm6840_interface *get_interface(const device_config *device)
96122{
97   "000 continous mode",
98   "001 freq comparison mode",
99   "010 continous mode",
100   "011 pulse width comparison mode",
101   "100 single shot mode",
102   "101 freq comparison mode",
103   "110 single shot mode",
104   "111 pulse width comparison mode"
105};
123   assert(device != NULL);
124   assert((device->type == PTM6840));
125   return (const ptm6840_interface *) device->static_config;
126}
106127
107///////////////////////////////////////////////////////////////////////////
108//                                                                       //
109// Get enabled status                                                    //
110//                                                                       //
111///////////////////////////////////////////////////////////////////////////
112128
113int ptm6840_get_status(int which, int clock)
129/***************************************************************************
130    IMPLEMENTATION
131***************************************************************************/
132
133/*-------------------------------------------------
134    ptm6840_get_status - Get enabled status
135-------------------------------------------------*/
136
137int ptm6840_get_status( const device_config *device, int clock )
114138{
115   ptm6840 *p = ptm + which;
116   return p->enabled[clock - 1];
139   ptm6840_state *ptm6840 = get_safe_token(device);
140   return ptm6840->enabled[clock - 1];
117141}
118142
119///////////////////////////////////////////////////////////////////////////
120//                                                                       //
121// ptm6840_get_irq: get IRQ state                                        //
122//                                                                       //
123///////////////////////////////////////////////////////////////////////////
143/*-------------------------------------------------
144    ptm6840_get_irq - Get IRQ state
145-------------------------------------------------*/
124146
125int ptm6840_get_irq(int which)
147int ptm6840_get_irq( const device_config *device )
126148{
127   ptm6840 *p = ptm + which;
128   return p->IRQ;
149   ptm6840_state *ptm6840 = get_safe_token(device);
150   return ptm6840->IRQ;
129151}
130152
131///////////////////////////////////////////////////////////////////////////
132//                                                                       //
133// Subtract from Counter                                                 //
134//                                                                       //
135///////////////////////////////////////////////////////////////////////////
153/*-------------------------------------------------
154    subtract_from_counter - Subtract from Counter
155-------------------------------------------------*/
136156
137static void subtract_from_counter(running_machine *machine, int which, int counter, int count)
157static void subtract_from_counter( const device_config *device, int counter, int count )
138158{
159   ptm6840_state *ptm6840 = get_safe_token(device);
139160   int clock;
140161   attotime duration;
141162
142   ptm6840 *currptr = ptm + which;
143
144163   /* Determine the clock frequency for this timer */
145   if (currptr->control_reg[counter] & 0x02)
146      clock = currptr->internal_clock;
164   if (ptm6840->control_reg[counter] & 0x02)
165      clock = ptm6840->internal_clock;
147166   else
148      clock = currptr->external_clock[counter];
167      clock = ptm6840->external_clock[counter];
149168
150169   /* Dual-byte mode */
151   if (currptr->control_reg[counter] & 0x04)
170   if (ptm6840->control_reg[counter] & 0x04)
152171   {
153      int lsb = currptr->counter[counter] & 0xff;
154      int msb = currptr->counter[counter] >> 8;
172      int lsb = ptm6840->counter[counter] & 0xff;
173      int msb = ptm6840->counter[counter] >> 8;
155174
156175      /* Count the clocks */
157176      lsb -= count;
r4939r4940
160179      while (lsb < 0)
161180      {
162181         /* Borrow from the MSB */
163         lsb += (currptr->latch[counter] & 0xff) + 1;
182         lsb += (ptm6840->latch[counter] & 0xff) + 1;
164183         msb--;
165184
166185         /* If MSB goes less than zero, we've expired */
167186         if (msb < 0)
168187         {
169            ptm6840_timeout(machine, which, counter);
170            msb = (currptr->latch[counter] >> 8) + 1;
188            ptm6840_timeout(device, counter);
189            msb = (ptm6840->latch[counter] >> 8) + 1;
171190         }
172191      }
173192
174193      /* Store the result */
175      currptr->counter[counter] = (msb << 8) | lsb;
194      ptm6840->counter[counter] = (msb << 8) | lsb;
176195   }
177196
178197   /* Word mode */
179198   else
180199   {
181      int word = currptr->counter[counter];
200      int word = ptm6840->counter[counter];
182201
183202      /* Count the clocks */
184203      word -= count;
r4939r4940
187206      while (word < 0)
188207      {
189208         /* Borrow from the MSB */
190         word += currptr->latch[counter] + 1;
209         word += ptm6840->latch[counter] + 1;
191210
192211         /* We've expired */
193         ptm6840_timeout(machine, which, counter);
212         ptm6840_timeout(device, counter);
194213      }
195214
196215      /* Store the result */
197      currptr->counter[counter] = word;
216      ptm6840->counter[counter] = word;
198217   }
199218
200   if (currptr->enabled[counter])
219   if (ptm6840->enabled[counter])
201220   {
202      duration = attotime_mul(ATTOTIME_IN_HZ(clock), currptr->counter[counter]);
221      duration = attotime_mul(ATTOTIME_IN_HZ(clock), ptm6840->counter[counter]);
203222
204223      if (counter == 2)
205         duration = attotime_mul(duration, currptr->t3_divisor);
224         duration = attotime_mul(duration, ptm6840->t3_divisor);
206225
207      timer_adjust_oneshot(currptr->timer[counter], duration, which);
226      timer_adjust_oneshot(ptm6840->timer[counter], duration, 0);
208227   }
209228}
210229
211static void ptm_tick(running_machine *machine, int which, int counter, int count)
230/*-------------------------------------------------
231    ptm_tick
232-------------------------------------------------*/
233
234static void ptm_tick( const device_config *device, int counter, int count )
212235{
213   ptm6840 *currptr = ptm + which;
236   ptm6840_state *ptm6840 = get_safe_token(device);
214237
215238   if (counter == 2)
216239   {
217      currptr->t3_scaler += count;
240      ptm6840->t3_scaler += count;
218241
219      if ( currptr->t3_scaler > currptr->t3_divisor - 1)
242      if ( ptm6840->t3_scaler > ptm6840->t3_divisor - 1)
220243      {
221         subtract_from_counter(machine, which, counter, 1);
222         currptr->t3_scaler = 0;
244         subtract_from_counter(device, counter, 1);
245         ptm6840->t3_scaler = 0;
223246      }
224247   }
225248   else
226249   {
227      subtract_from_counter(machine, which, counter, count);
250      subtract_from_counter(device, counter, count);
228251   }
229252}
230253
231///////////////////////////////////////////////////////////////////////////
232//                                                                       //
233// Update Internal Interrupts                                            //
234//                                                                       //
235///////////////////////////////////////////////////////////////////////////
254/*-------------------------------------------------
255    update_interrupts - Update Internal Interrupts
256-------------------------------------------------*/
236257
237INLINE void update_interrupts(running_machine *machine, int which)
258INLINE void update_interrupts( const device_config *device )
238259{
260   ptm6840_state *ptm6840 = get_safe_token(device);
239261   int new_state;
240   ptm6840 *currptr = ptm + which;
241262
242   new_state = ((currptr->status_reg & 0x01) && (currptr->control_reg[0] & 0x40)) ||
243            ((currptr->status_reg & 0x02) && (currptr->control_reg[1] & 0x40)) ||
244            ((currptr->status_reg & 0x04) && (currptr->control_reg[2] & 0x40));
263   new_state = ((ptm6840->status_reg & 0x01) && (ptm6840->control_reg[0] & 0x40)) ||
264            ((ptm6840->status_reg & 0x02) && (ptm6840->control_reg[1] & 0x40)) ||
265            ((ptm6840->status_reg & 0x04) && (ptm6840->control_reg[2] & 0x40));
245266
246//  if (new_state != currptr->IRQ)
267//  if (new_state != ptm6840->IRQ)
247268   {
248      currptr->IRQ = new_state;
269      ptm6840->IRQ = new_state;
249270
250      if (currptr->IRQ)
251         currptr->status_reg |= 0x80;
271      if (ptm6840->IRQ)
272         ptm6840->status_reg |= 0x80;
252273      else
253         currptr->status_reg &= ~0x80;
274         ptm6840->status_reg &= ~0x80;
254275
255      if (currptr->intf->irq_func)
256         (currptr->intf->irq_func)(machine, currptr->IRQ);
276      devcb_call_write_line(&ptm6840->irq_func, ptm6840->IRQ);
257277   }
258278}
259279
260///////////////////////////////////////////////////////////////////////////
261//                                                                       //
262// Compute Counter                                                       //
263//                                                                       //
264///////////////////////////////////////////////////////////////////////////
280/*-------------------------------------------------
281    compute_counter - Compute Counter
282-------------------------------------------------*/
265283
266static UINT16 compute_counter(int which, int counter)
284static UINT16 compute_counter( const device_config *device, int counter )
267285{
268   ptm6840 *currptr = ptm + which;
269
286   ptm6840_state *ptm6840 = get_safe_token(device);
270287   int clock;
271   int remaining=0;
288   int remaining = 0;
272289
273290   /* If there's no timer, return the count */
274   if (!currptr->enabled[counter])
291   if (!ptm6840->enabled[counter])
275292   {
276      PLOG(("MC6840 #%d: read counter(%d): %d\n", which, counter, currptr->counter[counter]));
277      return currptr->counter[counter];
293      PLOG(("MC6840 #%s: read counter(%d): %d\n", device->tag, counter, ptm6840->counter[counter]));
294      return ptm6840->counter[counter];
278295   }
279296
280297   /* determine the clock frequency for this timer */
281   if (currptr->control_reg[counter] & 0x02)
298   if (ptm6840->control_reg[counter] & 0x02)
282299   {
283      clock = currptr->internal_clock;
284      PLOG(("MC6840 #%d: %d internal clock freq %d \n", which, counter, clock));
300      clock = ptm6840->internal_clock;
301      PLOG(("MC6840 #%s: %d internal clock freq %d \n", device->tag, counter, clock));
285302   }
286303   else
287304   {
288      clock = currptr->external_clock[counter];
289      PLOG(("MC6840 #%d: %d external clock freq %d \n", which, counter, clock));
305      clock = ptm6840->external_clock[counter];
306      PLOG(("MC6840 #%s: %d external clock freq %d \n", device->tag, counter, clock));
290307   }
291308   /* See how many are left */
292   remaining = attotime_to_double(attotime_mul(timer_timeleft(currptr->timer[counter]), clock));
309   remaining = attotime_to_double(attotime_mul(timer_timeleft(ptm6840->timer[counter]), clock));
293310
294311   /* Adjust the count for dual byte mode */
295   if (currptr->control_reg[counter] & 0x04)
312   if (ptm6840->control_reg[counter] & 0x04)
296313   {
297      int divisor = (currptr->counter[counter] & 0xff) + 1;
314      int divisor = (ptm6840->counter[counter] & 0xff) + 1;
298315      int msb = remaining / divisor;
299316      int lsb = remaining % divisor;
300317      remaining = (msb << 8) | lsb;
301318   }
302   PLOG(("MC6840 #%d: read counter(%d): %d\n", which, counter, remaining));
319   PLOG(("MC6840 #%s: read counter(%d): %d\n", device->tag, counter, remaining));
303320   return remaining;
304321}
305322
306///////////////////////////////////////////////////////////////////////////
307//                                                                       //
308// Reload Counter                                                        //
309//                                                                       //
310///////////////////////////////////////////////////////////////////////////
323/*-------------------------------------------------
324    reload_count - Reload Counter
325-------------------------------------------------*/
311326
312static void reload_count(running_machine *machine, int which, int idx)
327static void reload_count( const device_config *device, int idx )
313328{
314   /* temporary hack until this is converted to a device */
315   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
329   ptm6840_state *ptm6840 = get_safe_token(device);
316330   int clock;
317331   int count;
318332   attotime duration;
319   ptm6840 *currptr = ptm + which;
320333
321334   /* Copy the latched value in */
322   currptr->counter[idx] = currptr->latch[idx];
335   ptm6840->counter[idx] = ptm6840->latch[idx];
323336
324337   /* Determine the clock frequency for this timer */
325   if (currptr->control_reg[idx] & 0x02)
338   if (ptm6840->control_reg[idx] & 0x02)
326339   {
327      clock = currptr->internal_clock;
328      PLOG(("MC6840 #%d: %d internal clock freq %d \n", which,idx, clock));
340      clock = ptm6840->internal_clock;
341      PLOG(("MC6840 #%s: %d internal clock freq %d \n", device->tag, idx, clock));
329342   }
330343   else
331344   {
332      clock = currptr->external_clock[idx];
333      PLOG(("MC6840 #%d: %d external clock freq %d \n", which,idx, clock));
345      clock = ptm6840->external_clock[idx];
346      PLOG(("MC6840 #%s: %d external clock freq %d \n", device->tag, idx, clock));
334347   }
335348
336349   /* Determine the number of clock periods before we expire */
337   count = currptr->counter[idx];
338   if (currptr->control_reg[idx] & 0x04)
350   count = ptm6840->counter[idx];
351   if (ptm6840->control_reg[idx] & 0x04)
339352      count = ((count >> 8) + 1) * ((count & 0xff) + 1);
340353   else
341354      count = count + 1;
342355
343   currptr->fired[idx]=0;
356   ptm6840->fired[idx] = 0;
344357
345   if ((currptr->mode[idx] == 4)||(currptr->mode[idx] == 6))
358   if ((ptm6840->mode[idx] == 4) || (ptm6840->mode[idx] == 6))
346359   {
347      currptr->output[idx] = 1;
348      if ( currptr->intf->out_func[idx] ) currptr->intf->out_func[idx](space, 0, currptr->output[idx]);
360      ptm6840->output[idx] = 1;
361      if (ptm6840->out_func[idx].write != NULL)
362         devcb_call_write8(&ptm6840->out_func[idx], 0, ptm6840->output[idx]);
349363   }
350364
351365   /* Set the timer */
352   PLOG(("MC6840 #%d: reload_count(%d): clock = %d  count = %d\n", which, idx, clock, count));
366   PLOG(("MC6840 #%s: reload_count(%d): clock = %d  count = %d\n", device->tag, idx, clock, count));
353367
354368   duration = attotime_mul(ATTOTIME_IN_HZ(clock), count);
355   if (idx == 2) duration = attotime_mul(duration, currptr->t3_divisor);
356   PLOG(("MC6840 #%d: reload_count(%d): output = %lf\n", which, idx, attotime_to_double(duration)));
369   if (idx == 2)
370      duration = attotime_mul(duration, ptm6840->t3_divisor);
357371
358   if (!(currptr->control_reg[idx] & 0x02))
372   PLOG(("MC6840 #%s: reload_count(%d): output = %lf\n", device->tag, idx, attotime_to_double(duration)));
373
374   if (!(ptm6840->control_reg[idx] & 0x02))
359375   {
360      if (!currptr->intf->external_clock[idx])
376      if (!ptm6840->external_clock[idx])
361377      {
362         currptr->enabled[idx] = 0;
363         timer_enable(currptr->timer[idx],FALSE);
378         ptm6840->enabled[idx] = 0;
379         timer_enable(ptm6840->timer[idx],FALSE);
364380      }
365381   }
366382   else
367383   {
368      currptr->enabled[idx] = 1;
369      timer_adjust_oneshot(currptr->timer[idx], duration, which);
370      timer_enable(currptr->timer[idx],TRUE);
384      ptm6840->enabled[idx] = 1;
385      timer_adjust_oneshot(ptm6840->timer[idx], duration, 0);
386      timer_enable(ptm6840->timer[idx], TRUE);
371387   }
372388}
373389
374///////////////////////////////////////////////////////////////////////////
375//                                                                       //
376// Configure Timer                                                       //
377//                                                                       //
378///////////////////////////////////////////////////////////////////////////
379390
380void ptm6840_config(running_machine *machine, int which, const ptm6840_interface *intf)
381{
382   int i;
383   ptm6840 *currptr = ptm + which;
391/*-------------------------------------------------
392    ptm6840_read - Read Timer
393-------------------------------------------------*/
384394
385   assert_always(mame_get_phase(machine) == MAME_PHASE_INIT, "Can only call ptm6840_config at init time!");
386   assert_always((which >= 0) && (which < PTM_6840_MAX), "ptm6840_config called on an invalid PTM!");
387   assert_always(intf, "ptm6840_config called with an invalid interface!");
388   ptm[which].intf = intf;
389   ptm[which].internal_clock = currptr->intf->internal_clock;
390
391   for (i = 0; i < 3; i++)
392   {
393      if ( currptr->intf->external_clock[i] )
394         ptm[which].external_clock[i] = currptr->intf->external_clock[i];
395      else
396         ptm[which].external_clock[i] = 1;
397   }
398
399   for (i = 0; i < 3; i++)
400   {
401      ptm[which].timer[i] = timer_alloc(machine, ptm6840_timer_cb, (void*)(FPTR)i);
402      timer_enable(ptm[which].timer[i], FALSE);
403   }
404
405   state_save_register_item(machine, "6840ptm", NULL, which, currptr->lsb_buffer);
406   state_save_register_item(machine, "6840ptm", NULL, which, currptr->msb_buffer);
407   state_save_register_item(machine, "6840ptm", NULL, which, currptr->status_read_since_int);
408   state_save_register_item(machine, "6840ptm", NULL, which, currptr->status_reg);
409   state_save_register_item(machine, "6840ptm", NULL, which, currptr->t3_divisor);
410   state_save_register_item(machine, "6840ptm", NULL, which, currptr->t3_scaler);
411   state_save_register_item(machine, "6840ptm", NULL, which, currptr->internal_clock);
412   state_save_register_item(machine, "6840ptm", NULL, which, currptr->IRQ);
413
414   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->control_reg);
415   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->output);
416   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->gate);
417   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->clock);
418   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->mode);
419   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->fired);
420   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->enabled);
421   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->external_clock);
422   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->counter);
423   state_save_register_item_array(machine, "6840ptm", NULL, which, currptr->latch);
424
425   ptm6840_reset(which);
426}
427
428///////////////////////////////////////////////////////////////////////////
429//                                                                       //
430// Reset Timer                                                           //
431//                                                                       //
432///////////////////////////////////////////////////////////////////////////
433
434void ptm6840_reset(int which)
395READ8_DEVICE_HANDLER( ptm6840_read )
435396{
436   int i;
437
438   ptm[which].control_reg[2]       = 0;
439   ptm[which].control_reg[1]       = 0;
440   ptm[which].control_reg[0]       = 1;
441   ptm[which].status_reg          = 0;
442   ptm[which].t3_divisor          = 1;
443   ptm[which].status_read_since_int = 0;
444   ptm[which].IRQ                   = 0;
445
446   for (i = 0; i < 3; i++)
447   {
448      ptm[which].counter[i] = 0xffff;
449      ptm[which].latch[i]   = 0xffff;
450      ptm[which].output[i]  = 0;
451      ptm[which].fired[i]   = 0;
452   }
453}
454
455///////////////////////////////////////////////////////////////////////////
456//                                                                       //
457// Read Timer                                                            //
458//                                                                       //
459///////////////////////////////////////////////////////////////////////////
460
461int ptm6840_read(running_machine *machine, int which, int offset)
462{
397   ptm6840_state *ptm6840 = get_safe_token(device);
463398   int val;
464   ptm6840 *currptr = ptm + which;
465399
466400   switch ( offset )
467401   {
r4939r4940
473407
474408      case PTM_6840_STATUS:
475409      {
476         PLOG(("%s: MC6840 #%d: Status read = %04X\n", cpuexec_describe_context(machine), which, currptr->status_reg));
477         currptr->status_read_since_int |= currptr->status_reg & 0x07;
478         val = currptr->status_reg;
410         PLOG(("%s: MC6840 #%s: Status read = %04X\n", cpuexec_describe_context(device->machine), device->tag, ptm6840->status_reg));
411         ptm6840->status_read_since_int |= ptm6840->status_reg & 0x07;
412         val = ptm6840->status_reg;
479413         break;
480414      }
481415
r4939r4940
484418      case PTM_6840_MSBBUF3:
485419      {
486420         int idx = (offset - 2) / 2;
487         int result = compute_counter(which, idx);
421         int result = compute_counter(device, idx);
488422
489423         /* Clear the interrupt if the status has been read */
490         if (currptr->status_read_since_int & (1 << idx))
424         if (ptm6840->status_read_since_int & (1 << idx))
491425         {
492            currptr->status_reg &= ~(1 << idx);
493            update_interrupts(machine, which);
426            ptm6840->status_reg &= ~(1 << idx);
427            update_interrupts(device);
494428         }
495429
496         currptr->lsb_buffer = result & 0xff;
430         ptm6840->lsb_buffer = result & 0xff;
497431
498         PLOG(("%s: MC6840 #%d: Counter %d read = %04X\n", cpuexec_describe_context(machine), which, idx, result >> 8));
432         PLOG(("%s: MC6840 #%s: Counter %d read = %04X\n", cpuexec_describe_context(device->machine), device->tag, idx, result >> 8));
499433         val = result >> 8;
500434         break;
501435      }
r4939r4940
504438      case PTM_6840_LSB2:
505439      case PTM_6840_LSB3:
506440      {
507         val = currptr->lsb_buffer;
441         val = ptm6840->lsb_buffer;
508442         break;
509443      }
510444
r4939r4940
518452   return val;
519453}
520454
521///////////////////////////////////////////////////////////////////////////
522//                                                                       //
523// Write Timer                                                           //
524//                                                                       //
525///////////////////////////////////////////////////////////////////////////
455/*-------------------------------------------------
456    ptm6840_write - Write Timer
457-------------------------------------------------*/
526458
527void ptm6840_write (running_machine *machine, int which, int offset, int data)
459WRITE8_DEVICE_HANDLER( ptm6840_write )
528460{
529   /* temporary hack until this is converted to a device */
530   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
531   ptm6840 *currptr = ptm + which;
532
461   ptm6840_state *ptm6840 = get_safe_token(device);
533462   int idx;
534463   int i;
535464   UINT8 diffs;
r4939r4940
539468      case PTM_6840_CTRL1:
540469      case PTM_6840_CTRL2:
541470      {
542         idx = (offset == 1) ? 1 : (currptr->control_reg[1] & 0x01) ? 0 : 2;
543         diffs = data ^ currptr->control_reg[idx];
544         currptr->t3_divisor = (currptr->control_reg[2] & 0x01) ? 8 : 1;
545         currptr->mode[idx] = (data >> 3) & 0x07;
546         currptr->control_reg[idx] = data;
471         idx = (offset == 1) ? 1 : (ptm6840->control_reg[1] & 0x01) ? 0 : 2;
472         diffs = data ^ ptm6840->control_reg[idx];
473         ptm6840->t3_divisor = (ptm6840->control_reg[2] & 0x01) ? 8 : 1;
474         ptm6840->mode[idx] = (data >> 3) & 0x07;
475         ptm6840->control_reg[idx] = data;
547476
548         PLOG(("MC6840 #%d : Control register %d selected\n", which, idx));
549         PLOG(("operation mode   = %s\n", opmode[ currptr->mode[idx] ]));
550         PLOG(("value            = %04X\n", currptr->control_reg[idx]));
551         PLOG(("t3divisor        = %d\n", currptr->t3_divisor));
477         PLOG(("MC6840 #%s : Control register %d selected\n", device->tag, idx));
478         PLOG(("operation mode   = %s\n", opmode[ ptm6840->mode[idx] ]));
479         PLOG(("value            = %04X\n", ptm6840->control_reg[idx]));
480         PLOG(("t3divisor        = %d\n", ptm6840->t3_divisor));
552481
553         if (!(currptr->control_reg[idx] & 0x80 ))
482         if (!(ptm6840->control_reg[idx] & 0x80 ))
554483         {
555484            /* Output cleared */
556            if ( currptr->intf )
557            {
558               if ( currptr->intf->out_func[idx] )
559                  currptr->intf->out_func[idx](space, 0, 0);
560            }
485            if (ptm6840->out_func[idx].write != NULL)
486               devcb_call_write8(&ptm6840->out_func[idx], 0, 0);
561487         }
562488         /* Reset? */
563489         if (idx == 0 && (diffs & 0x01))
r4939r4940
565491            /* Holding reset down */
566492            if (data & 0x01)
567493            {
568               PLOG(("MC6840 #%d : Timer reset\n", which));
494               PLOG(("MC6840 #%s : Timer reset\n", device->tag));
569495               for (i = 0; i < 3; i++)
570496               {
571                  timer_enable(currptr->timer[i], FALSE);
572                  currptr->enabled[i] = 0;
497                  timer_enable(ptm6840->timer[i], FALSE);
498                  ptm6840->enabled[i] = 0;
573499               }
574500            }
575501            /* Releasing reset */
576502            else
577503            {
578504               for (i = 0; i < 3; i++)
579                  reload_count(machine, which, i);
505                  reload_count(device, i);
580506            }
581507
582            currptr->status_reg = 0;
583            update_interrupts(machine, which);
508            ptm6840->status_reg = 0;
509            update_interrupts(device);
584510
585511            /* Changing the clock source? (e.g. Zwackery) */
586512            if (diffs & 0x02)
587               reload_count(machine, which, idx);
513               reload_count(device, idx);
588514         }
589515         break;
590516      }
r4939r4940
593519      case PTM_6840_MSBBUF2:
594520      case PTM_6840_MSBBUF3:
595521      {
596         PLOG(("MC6840 #%d msbbuf%d = %02X\n", which, offset / 2, data));
597         currptr->msb_buffer = data;
522         PLOG(("MC6840 #%s msbbuf%d = %02X\n", device->tag, offset / 2, data));
523         ptm6840->msb_buffer = data;
598524         break;
599525      }
600526
r4939r4940
603529      case PTM_6840_LSB3:
604530      {
605531         idx = (offset - 3) / 2;
606         currptr->latch[idx] = (currptr->msb_buffer << 8) | (data & 0xff);
532         ptm6840->latch[idx] = (ptm6840->msb_buffer << 8) | (data & 0xff);
607533
608534         /* Clear the interrupt */
609         currptr->status_reg &= ~(1 << idx);
610         update_interrupts(machine, which);
535         ptm6840->status_reg &= ~(1 << idx);
536         update_interrupts(device);
611537
612538         /* Reload the count if in an appropriate mode */
613         if (!(currptr->control_reg[idx] & 0x10))
614            reload_count(machine, which,idx);
539         if (!(ptm6840->control_reg[idx] & 0x10))
540            reload_count(device,idx);
615541
616         PLOG(("%s:MC6840 #%d: Counter %d latch = %04X\n", cpuexec_describe_context(machine), which, idx, currptr->latch[idx]));
542         PLOG(("%s:MC6840 #%s: Counter %d latch = %04X\n", cpuexec_describe_context(device->machine), device->tag, idx, ptm6840->latch[idx]));
617543         break;
618544      }
619545   }
620546}
621547
622///////////////////////////////////////////////////////////////////////////
623//                                                                       //
624// ptm6840_timeout: called if timer is mature                            //
625//                                                                       //
626///////////////////////////////////////////////////////////////////////////
548/*-------------------------------------------------
549    ptm6840_timeout - Called if timer is mature
550-------------------------------------------------*/
627551
628static void ptm6840_timeout(running_machine *machine, int which, int idx)
552static void ptm6840_timeout( const device_config *device, int idx )
629553{
630   /* temporary hack until this is converted to a device */
631   const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM);
632   ptm6840 *p = ptm + which;
554   ptm6840_state *ptm6840 = get_safe_token(device);
633555
634   PLOG(("**ptm6840 %d t%d timeout**\n", which, idx + 1));
556   PLOG(("**ptm6840 %s t%d timeout**\n", device->tag, idx + 1));
635557
636   if ( p->control_reg[idx] & 0x40 )
558   if ( ptm6840->control_reg[idx] & 0x40 )
637559   {
638560      /* Interrupt enabled */
639      p->status_reg |= (1 << idx);
640      p->status_read_since_int &= ~(1 << idx);
641      update_interrupts(machine, which);
561      ptm6840->status_reg |= (1 << idx);
562      ptm6840->status_read_since_int &= ~(1 << idx);
563      update_interrupts(device);
642564   }
643565
644   if ( p->control_reg[idx] & 0x80 )
566   if ( ptm6840->control_reg[idx] & 0x80 )
645567   {
646      /* Output enabled */
647      if ( p->intf )
568      if ((ptm6840->mode[idx] == 0)||(ptm6840->mode[idx] == 2))
648569      {
649         if ((p->mode[idx] == 0)||(p->mode[idx] == 2))
650         {
651            p->output[idx] = p->output[idx]?0:1;
652            PLOG(("**ptm6840 %d t%d output %d **\n", which, idx + 1, p->output[idx]));
570         ptm6840->output[idx] = ptm6840->output[idx] ? 0 : 1;
571         PLOG(("**ptm6840 %s t%d output %d **\n", device->tag, idx + 1, ptm6840->output[idx]));
653572
654            if ( p->intf->out_func[idx] )
655               p->intf->out_func[idx](space, 0, p->output[idx]);
656         }
657         if ((p->mode[idx] == 4)||(p->mode[idx] == 6))
573         if (ptm6840->out_func[idx].write != NULL)
574            devcb_call_write8(&ptm6840->out_func[idx], 0, ptm6840->output[idx]);
575      }
576      if ((ptm6840->mode[idx] == 4)||(ptm6840->mode[idx] == 6))
577      {
578         if (!ptm6840->fired[idx])
658579         {
659            if (!p->fired[idx])
660            {
661               p->output[idx] = 1;
662               PLOG(("**ptm6840 %d t%d output %d **\n", which, idx + 1, p->output[idx]));
580            ptm6840->output[idx] = 1;
581            PLOG(("**ptm6840 %s t%d output %d **\n", device->tag, idx + 1, ptm6840->output[idx]));
663582
664               if ( p->intf->out_func[idx] )
665                  p->intf->out_func[idx](space, 0, p->output[idx]);
583            if (ptm6840->out_func[idx].write != NULL)
584               devcb_call_write8(&ptm6840->out_func[idx], 0, ptm6840->output[idx]);
666585
667               /* No changes in output until reinit */
668               p->fired[idx] = 1;
669            }
586            /* No changes in output until reinit */
587            ptm6840->fired[idx] = 1;
670588         }
671589      }
672590   }
673   p->enabled[idx]= 0;
674   reload_count(machine, which, idx);
591   ptm6840->enabled[idx]= 0;
592   reload_count(device, idx);
675593}
676594
677static TIMER_CALLBACK( ptm6840_timer_cb ) { ptm6840_timeout(machine, param, (int)(FPTR)ptr); }
595/*-------------------------------------------------
596    TIMER_CALLBACKs for Timer 1, 2 & 3
597-------------------------------------------------*/
678598
679///////////////////////////////////////////////////////////////////////////
680//                                                                       //
681// ptm6840_set_gate: set gate status (0 or 1)                            //
682//                                                                       //
683///////////////////////////////////////////////////////////////////////////
599static TIMER_CALLBACK( ptm6840_timer1_cb )
600{
601   const device_config *device = (const device_config *)ptr;
602   ptm6840_timeout(device, 0);
603}
684604
685INLINE void ptm6840_set_gate(running_machine *machine, int which, int state, int idx)
605static TIMER_CALLBACK( ptm6840_timer2_cb )
686606{
687   ptm6840 *p = ptm + which;
607   const device_config *device = (const device_config *)ptr;
608   ptm6840_timeout(device, 1);
609}
688610
689   if ( (p->mode[idx] == 0) || (p->mode[idx] == 2) || (p->mode[0] == 4) || (p->mode[idx] == 6) )
611static TIMER_CALLBACK( ptm6840_timer3_cb )
612{
613   const device_config *device = (const device_config *)ptr;
614   ptm6840_timeout(device, 2);
615}
616
617
618/*-------------------------------------------------
619    ptm6840_set_gate - set gate status (0 or 1)
620-------------------------------------------------*/
621
622INLINE void ptm6840_set_gate( const device_config *device, int state, int idx )
623{
624   ptm6840_state *ptm6840 = get_safe_token(device);
625
626   if ( (ptm6840->mode[idx] == 0) || (ptm6840->mode[idx] == 2) || (ptm6840->mode[0] == 4) || (ptm6840->mode[idx] == 6) )
690627   {
691      if (state == 0 && p->gate[idx])
692         reload_count(machine, which,idx);
628      if (state == 0 && ptm6840->gate[idx])
629         reload_count(device,idx);
693630   }
694   p->gate[idx] = state;
631   ptm6840->gate[idx] = state;
695632}
696633
697void ptm6840_set_g1(running_machine *machine, int which, int state) { ptm6840_set_gate(machine, which, state, 0); }
698void ptm6840_set_g2(running_machine *machine, int which, int state) { ptm6840_set_gate(machine, which, state, 1); }
699void ptm6840_set_g3(running_machine *machine, int which, int state) { ptm6840_set_gate(machine, which, state, 2); }
634/*-------------------------------------------------
635    WRITE8_DEVICE_HANDLERs for Gate 1, 2 & 3
636-------------------------------------------------*/
700637
701///////////////////////////////////////////////////////////////////////////
702//                                                                       //
703// ptm6840_set_clock: set clock status (0 or 1)                          //
704//                                                                       //
705///////////////////////////////////////////////////////////////////////////
638WRITE8_DEVICE_HANDLER( ptm6840_set_g1 )
639{
640   ptm6840_set_gate(device, data, 0);
641}
706642
707INLINE void ptm6840_set_clock(running_machine *machine, int which, int state, int idx)
643WRITE8_DEVICE_HANDLER( ptm6840_set_g2 )
708644{
709   ptm6840 *p = ptm + which;
645   ptm6840_set_gate(device, data, 1);
646}
710647
711   p->clock[idx] = state;
648WRITE8_DEVICE_HANDLER( ptm6840_set_g3 )
649{
650   ptm6840_set_gate(device, data, 2);
651}
712652
713   if (!(p->control_reg[idx] & 0x02))
653/*-------------------------------------------------
654    ptm6840_set_clock - set clock status (0 or 1)
655-------------------------------------------------*/
656
657INLINE void ptm6840_set_clock( const device_config *device, int state, int idx )
658{
659   ptm6840_state *ptm6840 = get_safe_token(device);
660
661   ptm6840->clock[idx] = state;
662
663   if (!(ptm6840->control_reg[idx] & 0x02))
714664   {
715665      if (state)
716         ptm_tick(machine, which, idx, 1);
666         ptm_tick(device, idx, 1);
717667   }
718668}
719669
720///////////////////////////////////////////////////////////////////////////
721//                                                                       //
722// ptm6840_get_count: get count value                                    //
723//                                                                       //
724///////////////////////////////////////////////////////////////////////////
670/*-------------------------------------------------
671    WRITE8_DEVICE_HANDLERs for Clock 1, 2 & 3
672-------------------------------------------------*/
725673
726UINT16 ptm6840_get_count(int which,int counter)
674WRITE8_DEVICE_HANDLER( ptm6840_set_c1 )
727675{
728   return compute_counter(which, counter);
676   ptm6840_set_clock(device, data, 0);
729677}
730678
731///////////////////////////////////////////////////////////////////////////
732//                                                                       //
733// ptm6840_set_ext_clock: set external clock frequency                   //
734//                                                                       //
735///////////////////////////////////////////////////////////////////////////
679WRITE8_DEVICE_HANDLER( ptm6840_set_c2 )
680{
681   ptm6840_set_clock(device, data, 1);
682}
736683
737void ptm6840_set_ext_clock(int which, int counter, int clock)
684WRITE8_DEVICE_HANDLER( ptm6840_set_c3 )
738685{
739   ptm6840 *currptr = ptm + which;
740   currptr->external_clock[counter] = clock;
686   ptm6840_set_clock(device, data, 2);
687}
741688
742   if (!(currptr->control_reg[counter] & 0x02))
689
690/*-------------------------------------------------
691    ptm6840_get_count - get count value
692-------------------------------------------------*/
693
694UINT16 ptm6840_get_count( const device_config *device, int counter )
695{
696   return compute_counter(device, counter);
697}
698
699/*------------------------------------------------------------
700    ptm6840_set_ext_clock - set external clock frequency
701------------------------------------------------------------*/
702
703void ptm6840_set_ext_clock( const device_config *device, int counter, int clock )
704{
705   ptm6840_state *ptm6840 = get_safe_token(device);
706
707   ptm6840->external_clock[counter] = clock;
708
709   if (!(ptm6840->control_reg[counter] & 0x02))
743710   {
744      if (!currptr->intf->external_clock[counter])
711      if (!ptm6840->external_clock[counter])
745712      {
746         currptr->enabled[counter] = 0;
747         timer_enable(currptr->timer[counter], FALSE);
713         ptm6840->enabled[counter] = 0;
714         timer_enable(ptm6840->timer[counter], FALSE);
748715      }
749716   }
750717   else
r4939r4940
753720      attotime duration;
754721
755722      /* Determine the number of clock periods before we expire */
756      count = currptr->counter[counter];
723      count = ptm6840->counter[counter];
757724
758      if (currptr->control_reg[counter] & 0x04)
725      if (ptm6840->control_reg[counter] & 0x04)
759726         count = ((count >> 8) + 1) * ((count & 0xff) + 1);
760727      else
761728         count = count + 1;
r4939r4940
763730      duration = attotime_mul(ATTOTIME_IN_HZ(clock), count);
764731
765732      if (counter == 2)
766         duration = attotime_mul(duration, currptr->t3_divisor);
733         duration = attotime_mul(duration, ptm6840->t3_divisor);
767734
768      currptr->enabled[counter] = 1;
769      timer_adjust_oneshot(currptr->timer[counter], duration, which);
770      timer_enable(currptr->timer[counter], TRUE);
735      ptm6840->enabled[counter] = 1;
736      timer_adjust_oneshot(ptm6840->timer[counter], duration, 0);
737      timer_enable(ptm6840->timer[counter], TRUE);
771738   }
772739}
773740
774///////////////////////////////////////////////////////////////////////////
775//                                                                       //
776// ptm6840_get_ext_clock: get external clock frequency                   //
777//                                                                       //
778///////////////////////////////////////////////////////////////////////////
741/*------------------------------------------------------------
742    ptm6840_get_ext_clock - get external clock frequency
743------------------------------------------------------------*/
779744
780int ptm6840_get_ext_clock(int which, int counter)
745int ptm6840_get_ext_clock( const device_config *device, int counter )
781746{
782   ptm6840 *currptr = ptm + which;
783   return currptr->external_clock[counter];
747   ptm6840_state *ptm6840 = get_safe_token(device);
748   return ptm6840->external_clock[counter];
784749}
785750
786void ptm6840_set_c1(running_machine *machine, int which, int state) { ptm6840_set_clock(machine, which, state, 0); }
787void ptm6840_set_c2(running_machine *machine, int which, int state) { ptm6840_set_clock(machine, which, state, 1); }
788void ptm6840_set_c3(running_machine *machine, int which, int state) { ptm6840_set_clock(machine, which, state, 2); }
789751
790/////////////////////////////////////////////////////////////////////////////////
752/*-------------------------------------------------
753    DEVICE_START( ptm6840 )
754-------------------------------------------------*/
791755
792READ8_HANDLER( ptm6840_0_r ) { return ptm6840_read(space->machine, 0, offset); }
793READ8_HANDLER( ptm6840_1_r ) { return ptm6840_read(space->machine, 1, offset); }
794READ8_HANDLER( ptm6840_2_r ) { return ptm6840_read(space->machine, 2, offset); }
795READ8_HANDLER( ptm6840_3_r ) { return ptm6840_read(space->machine, 3, offset); }
756static DEVICE_START( ptm6840 )
757{
758   ptm6840_state *ptm6840 = get_safe_token(device);
759   const ptm6840_interface *intf = get_interface(device);
760   int i;
796761
797WRITE8_HANDLER( ptm6840_0_w ) { ptm6840_write(space->machine, 0, offset, data); }
798WRITE8_HANDLER( ptm6840_1_w ) { ptm6840_write(space->machine, 1, offset, data); }
799WRITE8_HANDLER( ptm6840_2_w ) { ptm6840_write(space->machine, 2, offset, data); }
800WRITE8_HANDLER( ptm6840_3_w ) { ptm6840_write(space->machine, 3, offset, data); }
762   ptm6840->internal_clock = intf->internal_clock;
801763
802READ16_HANDLER( ptm6840_0_msb_r ) { return ptm6840_read(space->machine, 0, offset) << 8; }
803READ16_HANDLER( ptm6840_1_msb_r ) { return ptm6840_read(space->machine, 1, offset) << 8; }
804READ16_HANDLER( ptm6840_2_msb_r ) { return ptm6840_read(space->machine, 2, offset) << 8; }
805READ16_HANDLER( ptm6840_3_msb_r ) { return ptm6840_read(space->machine, 3, offset) << 8; }
764   /* resolve callbacks */
765   for (i = 0; i < 3; i++)
766   {
767      devcb_resolve_write8(&ptm6840->out_func[i], &intf->out_func[i], device);
768   }
806769
807WRITE16_HANDLER( ptm6840_0_msb_w ) { if (ACCESSING_BITS_8_15) ptm6840_write(space->machine, 0, offset, data >> 8); }
808WRITE16_HANDLER( ptm6840_1_msb_w ) { if (ACCESSING_BITS_8_15) ptm6840_write(space->machine, 1, offset, data >> 8); }
809WRITE16_HANDLER( ptm6840_2_msb_w ) { if (ACCESSING_BITS_8_15) ptm6840_write(space->machine, 2, offset, data >> 8); }
810WRITE16_HANDLER( ptm6840_3_msb_w ) { if (ACCESSING_BITS_8_15) ptm6840_write(space->machine, 3, offset, data >> 8); }
770   for (i = 0; i < 3; i++)
771   {
772      if ( intf->external_clock[i] )
773         ptm6840->external_clock[i] = intf->external_clock[i];
774      else
775         ptm6840->external_clock[i] = 1;
776   }
811777
812READ16_HANDLER( ptm6840_0_lsb_r ) { return ptm6840_read(space->machine, 0, offset); }
813READ16_HANDLER( ptm6840_1_lsb_r ) { return ptm6840_read(space->machine, 1, offset); }
814READ16_HANDLER( ptm6840_2_lsb_r ) { return ptm6840_read(space->machine, 2, offset); }
815READ16_HANDLER( ptm6840_3_lsb_r ) { return ptm6840_read(space->machine, 3, offset); }
816778
817WRITE16_HANDLER( ptm6840_0_lsb_w ) { if (ACCESSING_BITS_0_7) ptm6840_write(space->machine, 0, offset, data & 0xff); }
818WRITE16_HANDLER( ptm6840_1_lsb_w ) { if (ACCESSING_BITS_0_7) ptm6840_write(space->machine, 1, offset, data & 0xff); }
819WRITE16_HANDLER( ptm6840_2_lsb_w ) { if (ACCESSING_BITS_0_7) ptm6840_write(space->machine, 2, offset, data & 0xff); }
820WRITE16_HANDLER( ptm6840_3_lsb_w ) { if (ACCESSING_BITS_0_7) ptm6840_write(space->machine, 3, offset, data & 0xff); }
779   ptm6840->timer[0] = timer_alloc(device->machine, ptm6840_timer1_cb, (void *)device);
780   ptm6840->timer[1] = timer_alloc(device->machine, ptm6840_timer2_cb, (void *)device);
781   ptm6840->timer[2] = timer_alloc(device->machine, ptm6840_timer3_cb, (void *)device);
782
783   for (i = 0; i < 3; i++)
784   {
785      timer_enable(ptm6840->timer[i], FALSE);
786   }
787
788   devcb_resolve_write_line(&ptm6840->irq_func, &intf->irq_func, device);
789
790   /* register for state saving */
791   state_save_register_device_item(device, 0, ptm6840->lsb_buffer);
792   state_save_register_device_item(device, 0, ptm6840->msb_buffer);
793   state_save_register_device_item(device, 0, ptm6840->status_read_since_int);
794   state_save_register_device_item(device, 0, ptm6840->status_reg);
795   state_save_register_device_item(device, 0, ptm6840->t3_divisor);
796   state_save_register_device_item(device, 0, ptm6840->t3_scaler);
797   state_save_register_device_item(device, 0, ptm6840->internal_clock);
798   state_save_register_device_item(device, 0, ptm6840->IRQ);
799
800   state_save_register_device_item_array(device, 0, ptm6840->control_reg);
801   state_save_register_device_item_array(device, 0, ptm6840->output);
802   state_save_register_device_item_array(device, 0, ptm6840->gate);
803   state_save_register_device_item_array(device, 0, ptm6840->clock);
804   state_save_register_device_item_array(device, 0, ptm6840->mode);
805   state_save_register_device_item_array(device, 0, ptm6840->fired);
806   state_save_register_device_item_array(device, 0, ptm6840->enabled);
807   state_save_register_device_item_array(device, 0, ptm6840->external_clock);
808   state_save_register_device_item_array(device, 0, ptm6840->counter);
809   state_save_register_device_item_array(device, 0, ptm6840->latch);
810}
811
812/*-------------------------------------------------
813    DEVICE_RESET( ptm6840 )
814-------------------------------------------------*/
815
816static DEVICE_RESET( ptm6840 )
817{
818   ptm6840_state *ptm6840 = get_safe_token(device);
819   int i;
820
821   ptm6840->control_reg[2]       = 0;
822   ptm6840->control_reg[1]       = 0;
823   ptm6840->control_reg[0]       = 1;
824   ptm6840->status_reg          = 0;
825   ptm6840->t3_divisor          = 1;
826   ptm6840->status_read_since_int = 0;
827   ptm6840->IRQ                   = 0;
828
829   for (i = 0; i < 3; i++)
830   {
831      ptm6840->counter[i] = 0xffff;
832      ptm6840->latch[i]   = 0xffff;
833      ptm6840->output[i]  = 0;
834      ptm6840->fired[i]   = 0;
835   }
836}
837
838/*-------------------------------------------------
839    device definition
840-------------------------------------------------*/
841
842static const char *DEVTEMPLATE_SOURCE = __FILE__;
843
844#define DEVTEMPLATE_ID(p,s)      p##ptm6840##s
845#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
846#define DEVTEMPLATE_NAME      "6840 PTM"
847#define DEVTEMPLATE_FAMILY      "Motorola Programmable Timer Modules"
848#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
849#include "devtempl.h"
src/emu/machine/6840ptm.h
r4939r4940
1/**********************************************************************
1/***************************************************************************
22
3    Motorola 6840 PTM interface and emulation
3    Motorola 6840 (PTM)
44
5    This function is a simple emulation of up to 4 MC6840 PTM
6    (Programmable Timer Module)
5    Programmable Timer Module
76
8**********************************************************************/
7***************************************************************************/
98
10#ifndef PTM_6840
11#define PTM_6840
9#ifndef __6840PTM_H__
10#define __6840PTM_H__
1211
13#define PTM_6840_MAX 4      // maximum number of chips to emulate
12#include "devcb.h"
1413
14/***************************************************************************
15    MACROS / CONSTANTS
16***************************************************************************/
17
18#define PTM6840      DEVICE_GET_INFO_NAME(ptm6840)
19
20#define MDRV_PTM6840_ADD(_tag, _config) \
21   MDRV_DEVICE_ADD(_tag, PTM6840, 0) \
22   MDRV_DEVICE_CONFIG(_config)
23
24#define MDRV_PTM6840_REMOVE(_tag) \
25   MDRV_DEVICE_REMOVE(_tag)
26
27/***************************************************************************
28    TYPE DEFINITIONS
29***************************************************************************/
30
31
1532typedef struct _ptm6840_interface ptm6840_interface;
1633struct _ptm6840_interface
1734{
1835   int internal_clock;
1936   int external_clock[3];
2037
21   write8_space_func   out_func[3];   // function to call when output[idx] changes
22
23   void (*irq_func)(running_machine *machine, int state);   // function called if IRQ line changes
38   devcb_write8 out_func[3];   // function to call when output[idx] changes
39   devcb_write_line irq_func;   // function called if IRQ line changes
2440};
2541
26void ptm6840_config( running_machine *machine, int which, const ptm6840_interface *intf);
27void ptm6840_reset(  int which);
28int  ptm6840_read(   running_machine *machine, int which, int offset);
29void ptm6840_write(  running_machine *machine, int which, int offset, int data);
3042
31int ptm6840_get_status(int which, int clock);   // get whether timer is enabled
32int ptm6840_get_irq(int which);               // get IRQ state
33UINT16 ptm6840_get_count(int which,int counter);// get counter value
34void ptm6840_set_ext_clock(int which, int counter, int clock); // set clock frequency
35int ptm6840_get_ext_clock(int which, int counter);// get clock frequency
43/***************************************************************************
44    PROTOTYPES
45***************************************************************************/
3646
37void ptm6840_set_g1(running_machine *machine, int which, int state);      // set gate1  state
38void ptm6840_set_c1(running_machine *machine, int which, int state);      // set clock1 state
47/* device interface */
48DEVICE_GET_INFO( ptm6840 );
3949
40void ptm6840_set_g2(running_machine *machine, int which, int state);      // set gate2  state
41void ptm6840_set_c2(running_machine *machine, int which, int state);      // set clock2 state
50int ptm6840_get_status( const device_config *device, int clock );   // get whether timer is enabled
51int ptm6840_get_irq( const device_config *device );               // get IRQ state
52UINT16 ptm6840_get_count( const device_config *device, int counter );// get counter value
53void ptm6840_set_ext_clock( const device_config *device, int counter, int clock ); // set clock frequency
54int ptm6840_get_ext_clock( const device_config *device, int counter );// get clock frequency
4255
43void ptm6840_set_g3(running_machine *machine, int which, int state);      // set gate3  state
44void ptm6840_set_c3(running_machine *machine, int which, int state);      // set clock3 state
56WRITE8_DEVICE_HANDLER( ptm6840_set_g1 );   // set gate1 state
57WRITE8_DEVICE_HANDLER( ptm6840_set_g2 );   // set gate2 state
58WRITE8_DEVICE_HANDLER( ptm6840_set_g3 );   // set gate3 state
59WRITE8_DEVICE_HANDLER( ptm6840_set_c1 );   // set clock1 state
60WRITE8_DEVICE_HANDLER( ptm6840_set_c2 );   // set clock2 state
61WRITE8_DEVICE_HANDLER( ptm6840_set_c3 );   // set clock3 state
4562
46/*-------------------------------------------------------------------------*/
63WRITE8_DEVICE_HANDLER( ptm6840_write );
64READ8_DEVICE_HANDLER( ptm6840_read );
4765
48READ8_HANDLER( ptm6840_0_r );
49READ8_HANDLER( ptm6840_1_r );
50READ8_HANDLER( ptm6840_2_r );
51READ8_HANDLER( ptm6840_3_r );
52
53READ16_HANDLER( ptm6840_0_lsb_r );
54READ16_HANDLER( ptm6840_1_lsb_r );
55READ16_HANDLER( ptm6840_2_lsb_r );
56READ16_HANDLER( ptm6840_3_lsb_r );
57
58READ16_HANDLER( ptm6840_0_msb_r );
59READ16_HANDLER( ptm6840_1_msb_r );
60READ16_HANDLER( ptm6840_2_msb_r );
61READ16_HANDLER( ptm6840_3_msb_r );
62
63WRITE8_HANDLER( ptm6840_0_w );
64WRITE8_HANDLER( ptm6840_1_w );
65WRITE8_HANDLER( ptm6840_2_w );
66WRITE8_HANDLER( ptm6840_3_w );
67
68WRITE16_HANDLER( ptm6840_0_lsb_w );
69WRITE16_HANDLER( ptm6840_1_lsb_w );
70WRITE16_HANDLER( ptm6840_2_lsb_w );
71WRITE16_HANDLER( ptm6840_3_lsb_w );
72
73WRITE16_HANDLER( ptm6840_0_msb_w );
74WRITE16_HANDLER( ptm6840_1_msb_w );
75WRITE16_HANDLER( ptm6840_2_msb_w );
76WRITE16_HANDLER( ptm6840_3_msb_w );
77
78#endif /* PTM_6840 */
66#endif /* __6840PTM_H__ */
src/emu/machine/pd4990a.c
r4939r4940
1/*
2 *  Emulation for the NEC PD4990A.
3 *
4 *  The PD4990A is a serial I/O Calendar & Clock IC used in the
5 *      NEO GEO and probably a couple of other machines.
1/***************************************************************************
62
3    NEC uPD4990A
74
8  Completed by ElSemi.
5    Serial I/O Calendar & Clock IC used in the
6        NEO GEO and probably a couple of other machines.
97
10  I haven't found any schematics for this device
11  so I had to make some assumptions about how it works.
128
13  The three input bits seem to be used for a serial protocol
9  Completed by ElSemi.
1410
11    I haven't found any schematics for this device
12    so I had to make some assumptions about how it works.
13
14    The three input bits seem to be used for a serial protocol
15
1516    bit 0 - data
1617    bit 1 - clock
1718    bit 2 - command end (?)
1819
19  the commands I've found so far are:
20    the commands I've found so far are:
2021
21  0x0 - ?? sent after 2
22  0x1 - Reset the (probable) shift register used for output
23  0x2 - Store the contents of the shift reg to the current date
24  0x3 - Load Shift register with current date
22    0x0 - ?? sent after 2
23    0x1 - Reset the (probable) shift register used for output
24    0x2 - Store the contents of the shift reg to the current date
25    0x3 - Load Shift register with current date
2526
26  0x7 - Switch test bit every frame
27  0x8 - Switch test bit every half-second
27    0x7 - Switch test bit every frame
28    0x8 - Switch test bit every half-second
2829
2930
31    2009-06 Converted to be a device
3032
31 */
33***************************************************************************/
3234
3335#include "driver.h"
3436#include "machine/pd4990a.h"
3537
3638
37/* Set the data in the chip to Monday 09/09/73 00:00:00     */
38/* If you ever read this Leejanne, you know what I mean :-) */
39static const struct pd4990a_s pd4990a_initval =
39/***************************************************************************
40    CONSTANTS
41***************************************************************************/
42
43#define DATA_BIT   0x01
44#define CLOCK_BIT   0x02
45#define END_BIT      0x04
46
47/***************************************************************************
48    TYPE DEFINITIONS
49***************************************************************************/
50
51typedef struct _upd4990a_state upd4990a_state;
52struct _upd4990a_state
4053{
41   0x00,   /* seconds BCD */
42   0x00,   /* minutes BCD */
43   0x00,   /* hours   BCD */
44   0x09,   /* days    BCD */
45   9,      /* month   Hexadecimal form */
46   0x73,   /* year    BCD */
47   1      /* weekday BCD */
54   int seconds;   /* seconds BCD */
55   int minutes;   /* minutes BCD */
56   int hours;      /* hours   BCD */
57   int days;      /* days    BCD */
58   int month;      /* month   Hexadecimal form */
59   int year;      /* year    BCD */
60   int weekday;   /* weekday BCD */
61
62   UINT32 shiftlo;
63   UINT32 shifthi;
64
65   int retraces;   /* Assumes 60 retraces a second */
66   int testwaits;
67   int maxwaits;   /* Switch test every frame*/
68   int testbit;   /* Pulses a bit in order to simulate test output */
69
70   int outputbit;
71   int bitno;
72   INT8 reading;
73   INT8 writing;
74
75   int clock_line;
76   int command_line;   //??
4877};
4978
50struct pd4990a_s pd4990a;
5179
52static UINT32 shiftlo,shifthi;
5380
54static int retraces = 0;   /* Assumes 60 retraces a second */
55static int testwaits= 0;
56static int maxwaits= 0;   /*switch test every frame*/
57static int testbit = 0;   /* Pulses a bit in order to simulate */
58               /* test output */
59static int outputbit=0;
60static int bitno=0;
61static INT8 reading=0;
62static INT8 writting=0;
81/***************************************************************************
82    INLINE FUNCTIONS
83***************************************************************************/
6384
64static int clock_line=0;
65static int command_line=0;   //??
85INLINE upd4990a_state *get_safe_token(const device_config *device)
86{
87   assert(device != NULL);
88   assert(device->token != NULL);
89   assert((device->type == UPD4990A));
90   return (upd4990a_state *)device->token;
91}
6692
67#define DATA_BIT   0x1
68#define CLOCK_BIT   0x2
69#define END_BIT      0x4
93INLINE UINT8 convert_to_bcd(int val)
94{
95   return ((val / 10) << 4) | (val % 10);
96}
7097
71void pd4990a_addretrace()
98
99/***************************************************************************
100    IMPLEMENTATION
101***************************************************************************/
102
103/*-------------------------------------------------
104    upd4990a_increment_month
105-------------------------------------------------*/
106
107void upd4990a_increment_month( const device_config *device )
72108{
73   ++testwaits;
74   if(testwaits>=maxwaits)
109   upd4990a_state *upd4990a = get_safe_token(device);
110
111   upd4990a->month++;
112   if (upd4990a->month == 13)
75113   {
76      testbit ^= 1;
77      testwaits=0;
114      upd4990a->month = 1;
115      upd4990a->year++;
116      if ((upd4990a->year & 0x0f) >= 10)
117      {
118         upd4990a->year &= 0xf0;
119         upd4990a->year += 0x10;
120      }
121      if (upd4990a->year == 0xA0)
122         upd4990a->year = 0;
78123   }
79   retraces++;
80   if (retraces < 60)
81      return;
82   retraces = 0;
83   pd4990a.seconds++;
84   if ( (pd4990a.seconds & 0x0f) < 10 )
85      return;
86   pd4990a.seconds &= 0xf0;
87   pd4990a.seconds += 0x10;
88   if (pd4990a.seconds < 0x60)
89      return;
90   pd4990a.seconds = 0;
91   pd4990a.minutes++;
92   if ( (pd4990a.minutes & 0x0f) < 10 )
93      return;
94   pd4990a.minutes &= 0xf0;
95   pd4990a.minutes += 0x10;
96   if (pd4990a.minutes < 0x60)
97      return;
98   pd4990a.minutes = 0;
99   pd4990a.hours++;
100   if ( (pd4990a.hours & 0x0f) < 10 )
101      return;
102   pd4990a.hours &= 0xf0;
103   pd4990a.hours += 0x10;
104   if (pd4990a.hours < 0x24)
105      return;
106   pd4990a.hours = 0;
107   pd4990a_increment_day();
108124}
109125
110void pd4990a_increment_day(void)
126/*-------------------------------------------------
127    upd4990a_increment_day
128-------------------------------------------------*/
129
130void upd4990a_increment_day( const device_config *device )
111131{
132   upd4990a_state *upd4990a = get_safe_token(device);
112133   int real_year;
113134
114   pd4990a.days++;
115   if ((pd4990a.days & 0x0f) >= 10)
135   upd4990a->days++;
136   if ((upd4990a->days & 0x0f) >= 10)
116137   {
117      pd4990a.days &= 0xf0;
118      pd4990a.days += 0x10;
138      upd4990a->days &= 0xf0;
139      upd4990a->days += 0x10;
119140   }
120141
121   pd4990a.weekday++;
122   if (pd4990a.weekday == 7)
123      pd4990a.weekday=0;
142   upd4990a->weekday++;
143   if (upd4990a->weekday == 7)
144      upd4990a->weekday = 0;
124145
125   switch(pd4990a.month)
146   switch (upd4990a->month)
126147   {
127   case 1: case 3: case 5: case 7: case 8: case 10: case 12:
128      if (pd4990a.days == 0x32)
129      {
130         pd4990a.days = 1;
131         pd4990a_increment_month();
132      }
133      break;
134   case 2:
135      real_year = (pd4990a.year>>4)*10 + (pd4990a.year&0xf);
136      if ((real_year % 4) && (!(real_year % 100) || (real_year % 400)))
137      {
138         if (pd4990a.days == 0x29)
148      case 1: case 3: case 5: case 7: case 8: case 10: case 12:
149         if (upd4990a->days == 0x32)
139150         {
140            pd4990a.days = 1;
141            pd4990a_increment_month();
151            upd4990a->days = 1;
152            upd4990a_increment_month(device);
142153         }
143      }
144      else
145      {
146         if (pd4990a.days == 0x30)
154         break;
155      case 2:
156         real_year = (upd4990a->year >> 4) * 10 + (upd4990a->year & 0xf);
157         if ((real_year % 4) && (!(real_year % 100) || (real_year % 400)))
147158         {
148            pd4990a.days = 1;
149            pd4990a_increment_month();
159            if (upd4990a->days == 0x29)
160            {
161               upd4990a->days = 1;
162               upd4990a_increment_month(device);
163            }
150164         }
151      }
152      break;
153   case 4: case 6: case 9: case 11:
154      if (pd4990a.days == 0x31)
155      {
156         pd4990a.days = 1;
157         pd4990a_increment_month();
158      }
159      break;
165         else
166         {
167            if (upd4990a->days == 0x30)
168            {
169               upd4990a->days = 1;
170               upd4990a_increment_month(device);
171            }
172         }
173         break;
174      case 4: case 6: case 9: case 11:
175         if (upd4990a->days == 0x31)
176         {
177            upd4990a->days = 1;
178            upd4990a_increment_month(device);
179         }
180         break;
160181   }
161182}
162183
163void pd4990a_increment_month(void)
184/*-------------------------------------------------
185    upd4990a_addretrace
186-------------------------------------------------*/
187
188void upd4990a_addretrace( const device_config *device )
164189{
165   pd4990a.month++;
166   if (pd4990a.month == 13)
190   upd4990a_state *upd4990a = get_safe_token(device);
191
192   ++upd4990a->testwaits;
193   if(upd4990a->testwaits >= upd4990a->maxwaits)
167194   {
168      pd4990a.month = 1;
169      pd4990a.year++;
170      if ( (pd4990a.year & 0x0f) >= 10 )
171      {
172         pd4990a.year &= 0xf0;
173         pd4990a.year += 0x10;
174      }
175      if (pd4990a.year == 0xA0)
176         pd4990a.year = 0;
195      upd4990a->testbit ^= 1;
196      upd4990a->testwaits = 0;
177197   }
198
199   upd4990a->retraces++;
200   if (upd4990a->retraces < 60)
201      return;
202
203   upd4990a->retraces = 0;
204   upd4990a->seconds++;
205   if ((upd4990a->seconds & 0x0f) < 10)
206      return;
207
208   upd4990a->seconds &= 0xf0;
209   upd4990a->seconds += 0x10;
210   if (upd4990a->seconds < 0x60)
211      return;
212
213   upd4990a->seconds = 0;
214   upd4990a->minutes++;
215   if ((upd4990a->minutes & 0x0f) < 10)
216      return;
217
218   upd4990a->minutes &= 0xf0;
219   upd4990a->minutes += 0x10;
220   if (upd4990a->minutes < 0x60)
221      return;
222
223   upd4990a->minutes = 0;
224   upd4990a->hours++;
225   if ((upd4990a->hours & 0x0f) < 10)
226      return;
227
228   upd4990a->hours &= 0xf0;
229   upd4990a->hours += 0x10;
230   if (upd4990a->hours < 0x24)
231      return;
232
233   upd4990a->hours = 0;
234   upd4990a_increment_day(device);
178235}
179236
180READ8_HANDLER( pd4990a_testbit_r )
237/*-------------------------------------------------
238    upd4990a_testbit_r
239-------------------------------------------------*/
240
241READ8_DEVICE_HANDLER( upd4990a_testbit_r )
181242{
182   return (testbit);
243   upd4990a_state *upd4990a = get_safe_token(device);
244   return upd4990a->testbit;
183245}
184246
185READ8_HANDLER( pd4990a_databit_r )
247/*-------------------------------------------------
248    upd4990a_databit_r
249-------------------------------------------------*/
250
251READ8_DEVICE_HANDLER( upd4990a_databit_r )
186252{
187   return (outputbit);
253   upd4990a_state *upd4990a = get_safe_token(device);
254   return upd4990a->outputbit;
188255}
189256
190static void pd4990a_readbit(void)
257/*-------------------------------------------------
258    upd4990a_readbit
259-------------------------------------------------*/
260
261static void upd4990a_readbit( const device_config *device )
191262{
192   switch(bitno)
263   upd4990a_state *upd4990a = get_safe_token(device);
264
265   switch (upd4990a->bitno)
193266   {
194267      case 0x00: case 0x01: case 0x02: case 0x03:
195268      case 0x04: case 0x05: case 0x06: case 0x07:
196         outputbit=(pd4990a.seconds >> bitno) & 0x01;
269         upd4990a->outputbit = (upd4990a->seconds >> upd4990a->bitno) & 0x01;
197270         break;
198271      case 0x08: case 0x09: case 0x0a: case 0x0b:
199272      case 0x0c: case 0x0d: case 0x0e: case 0x0f:
200         outputbit=(pd4990a.minutes >> (bitno-0x08)) & 0x01;
273         upd4990a->outputbit = (upd4990a->minutes >> (upd4990a->bitno - 0x08)) & 0x01;
201274         break;
202275      case 0x10: case 0x11: case 0x12: case 0x13:
203276      case 0x14: case 0x15: case 0x16: case 0x17:
204         outputbit=(pd4990a.hours >> (bitno-0x10)) & 0x01;
277         upd4990a->outputbit = (upd4990a->hours >> (upd4990a->bitno - 0x10)) & 0x01;
205278         break;
206279      case 0x18: case 0x19: case 0x1a: case 0x1b:
207280      case 0x1c: case 0x1d: case 0x1e: case 0x1f:
208         outputbit=(pd4990a.days >> (bitno-0x18)) & 0x01;
281         upd4990a->outputbit = (upd4990a->days >> (upd4990a->bitno - 0x18)) & 0x01;
209282         break;
210283      case 0x20: case 0x21: case 0x22: case 0x23:
211         outputbit=(pd4990a.weekday >> (bitno-0x20)) & 0x01;
284         upd4990a->outputbit = (upd4990a->weekday >> (upd4990a->bitno - 0x20)) & 0x01;
212285         break;
213286      case 0x24: case 0x25: case 0x26: case 0x27:
214         outputbit=(pd4990a.month >> (bitno-0x24)) & 0x01;
287         upd4990a->outputbit = (upd4990a->month >> (upd4990a->bitno - 0x24)) & 0x01;
215288         break;
216289      case 0x28: case 0x29: case 0x2a: case 0x2b:
217290      case 0x2c: case 0x2d: case 0x2e: case 0x2f:
218         outputbit=(pd4990a.year >> (bitno-0x28)) & 0x01;
291         upd4990a->outputbit = (upd4990a->year >> (upd4990a->bitno - 0x28)) & 0x01;
219292         break;
220293      case 0x30: case 0x31: case 0x32: case 0x33:
221294         //unknown
r4939r4940
223296   }
224297}
225298
299/*-------------------------------------------------
300    upd4990a_resetbitstream
301-------------------------------------------------*/
226302
303static void upd4990a_resetbitstream( const device_config *device )
304{
305   upd4990a_state *upd4990a = get_safe_token(device);
227306
228
229static void pd4990a_resetbitstream(void)
230{
231   shiftlo=0;
232   shifthi=0;
233   bitno=0;
307   upd4990a->shiftlo = 0;
308   upd4990a->shifthi = 0;
309   upd4990a->bitno = 0;
234310}
235311
236static void pd4990a_writebit(UINT8 bit)
312/*-------------------------------------------------
313    upd4990a_writebit
314-------------------------------------------------*/
315
316static void upd4990a_writebit( const device_config *device , UINT8 bit )
237317{
238   if(bitno<=31)   //low part
239      shiftlo|=bit<<bitno;
318   upd4990a_state *upd4990a = get_safe_token(device);
319   if (upd4990a->bitno <= 31)   //low part
320      upd4990a->shiftlo |= bit << upd4990a->bitno;
240321   else   //high part
241      shifthi|=bit<<(bitno-32);
322      upd4990a->shifthi |= bit << (upd4990a->bitno - 32);
242323}
243324
244static void pd4990a_nextbit(void)
325/*-------------------------------------------------
326    upd4990a_nextbit
327-------------------------------------------------*/
328
329static void upd4990a_nextbit( const device_config *device )
245330{
246   ++bitno;
247   if(reading)
248      pd4990a_readbit();
249   if(reading && bitno==0x34)
331   upd4990a_state *upd4990a = get_safe_token(device);
332   ++upd4990a->bitno;
333
334   if (upd4990a->reading)
335      upd4990a_readbit(device);
336
337   if (upd4990a->reading && upd4990a->bitno == 0x34)
250338   {
251      reading=0;
252      pd4990a_resetbitstream();
339      upd4990a->reading = 0;
340      upd4990a_resetbitstream(device);
253341   }
254342
255343}
256344
257static UINT8 pd4990a_getcommand(void)
345/*-------------------------------------------------
346    upd4990a_getcommand
347-------------------------------------------------*/
348
349static UINT8 upd4990a_getcommand( const device_config *device )
258350{
351   upd4990a_state *upd4990a = get_safe_token(device);
259352   //Warning: problems if the 4 bits are in different
260353   //parts, It's very strange that this case could happen.
261   if(bitno<=31)
262      return shiftlo>>(bitno-4);
354   if(upd4990a->bitno <= 31)
355      return upd4990a->shiftlo >> (upd4990a->bitno - 4);
263356   else
264      return shifthi>>(bitno-32-4);
357      return upd4990a->shifthi >> (upd4990a->bitno - 32 - 4);
265358}
266359
267static void pd4990a_update_date(void)
360/*-------------------------------------------------
361    upd4990a_update_date
362-------------------------------------------------*/
363
364static void upd4990a_update_date( const device_config *device )
268365{
269   pd4990a.seconds=(shiftlo>>0 )&0xff;
270   pd4990a.minutes=(shiftlo>>8 )&0xff;
271   pd4990a.hours  =(shiftlo>>16)&0xff;
272   pd4990a.days   =(shiftlo>>24)&0xff;
273   pd4990a.weekday=(shifthi>>0 )&0x0f;
274   pd4990a.month  =(shifthi>>4 )&0x0f;
275   pd4990a.year   =(shifthi>>8 )&0xff;
366   upd4990a_state *upd4990a = get_safe_token(device);
367
368   upd4990a->seconds = (upd4990a->shiftlo >> 0 ) & 0xff;
369   upd4990a->minutes = (upd4990a->shiftlo >> 8 ) & 0xff;
370   upd4990a->hours   = (upd4990a->shiftlo >> 16) & 0xff;
371   upd4990a->days    = (upd4990a->shiftlo >> 24) & 0xff;
372   upd4990a->weekday = (upd4990a->shifthi >> 0 ) & 0x0f;
373   upd4990a->month   = (upd4990a->shifthi >> 4 ) & 0x0f;
374   upd4990a->year    = (upd4990a->shifthi >> 8 ) & 0xff;
276375}
277376
278static void pd4990a_process_command(void)
377/*-------------------------------------------------
378    upd4990a_process_command
379-------------------------------------------------*/
380
381static void upd4990a_process_command( const device_config *device )
279382{
280   switch(pd4990a_getcommand())
383   upd4990a_state *upd4990a = get_safe_token(device);
384
385   switch(upd4990a_getcommand(device))
281386   {
282387      case 0x1:   //load output register
283         bitno=0;
284         if(reading)
285            pd4990a_readbit();   //prepare first bit
286         shiftlo=0;
287         shifthi=0;
388         upd4990a->bitno = 0;
389         if (upd4990a->reading)
390            upd4990a_readbit(device);   //prepare first bit
391         upd4990a->shiftlo = 0;
392         upd4990a->shifthi = 0;
288393         break;
289394      case 0x2:
290         writting=0;   //store register to current date
291         pd4990a_update_date();
395         upd4990a->writing = 0;   //store register to current date
396         upd4990a_update_date(device);
292397         break;
293398      case 0x3:   //start reading
294         reading=1;
399         upd4990a->reading = 1;
295400         break;
296401      case 0x7:   //switch testbit every frame
297         maxwaits=1;
402         upd4990a->maxwaits = 1;
298403         break;
299404      case 0x8:   //switch testbit every half-second
300         maxwaits=30;
405         upd4990a->maxwaits = 30;
301406         break;
302407   }
303   pd4990a_resetbitstream();
408   upd4990a_resetbitstream(device);
304409}
305410
411/*-------------------------------------------------
412    upd4990a_serial_control
413-------------------------------------------------*/
306414
307static void pd4990a_serial_control(UINT8 data)
415static void upd4990a_serial_control( const device_config *device, UINT8 data )
308416{
417   upd4990a_state *upd4990a = get_safe_token(device);
418
309419   //Check for command end
310   if(command_line && !(data&END_BIT)) //end of command
420   if(upd4990a->command_line && !(data & END_BIT)) //end of command
311421   {
312      pd4990a_process_command();
422      upd4990a_process_command(device);
313423   }
314   command_line=data&END_BIT;
424   upd4990a->command_line = data & END_BIT;
315425
316   if(clock_line && !(data&CLOCK_BIT))   //clock lower edge
426   if(upd4990a->clock_line && !(data & CLOCK_BIT))   //clock lower edge
317427   {
318      pd4990a_writebit(data&DATA_BIT);
319      pd4990a_nextbit();
428      upd4990a_writebit(device, data & DATA_BIT);
429      upd4990a_nextbit(device);
320430   }
321   clock_line=data&CLOCK_BIT;
431   upd4990a->clock_line = data & CLOCK_BIT;
322432}
323433
324WRITE16_HANDLER( pd4990a_control_16_w )
434/*-------------------------------------------------
435    upd4990a_control_16_w
436-------------------------------------------------*/
437
438WRITE16_DEVICE_HANDLER( upd4990a_control_16_w )
325439{
326   pd4990a_serial_control(data&0x7);
440   upd4990a_serial_control(device, data & 0x7);
327441}
328442
329void pd4990a_init(running_machine *machine)
443
444/*-------------------------------------------------
445    DEVICE_START( upd4990a )
446-------------------------------------------------*/
447
448static DEVICE_START( upd4990a )
330449{
331   pd4990a = pd4990a_initval;
332   shiftlo = 0;
333   shifthi = 0;
334   retraces = 0;
335   testwaits = 0;
336   maxwaits = 1;
337   testbit = 0;
338   outputbit = 0;
339   bitno = 0;
340   reading = 0;
341   writting = 0;
342   clock_line = 0;
343   command_line =0;
450   upd4990a_state *upd4990a = get_safe_token(device);
344451
345   state_save_register_item(machine, "pd4990a", NULL, 0, pd4990a.seconds);
346   state_save_register_item(machine, "pd4990a", NULL, 0, pd4990a.minutes);
347   state_save_register_item(machine, "pd4990a", NULL, 0, pd4990a.hours);
348   state_save_register_item(machine, "pd4990a", NULL, 0, pd4990a.days);
349   state_save_register_item(machine, "pd4990a", NULL, 0, pd4990a.month);
350   state_save_register_item(machine, "pd4990a", NULL, 0, pd4990a.year);
351   state_save_register_item(machine, "pd4990a", NULL, 0, pd4990a.weekday);
452   mame_system_time curtime, *systime = &curtime;
453   mame_get_current_datetime(device->machine, &curtime);
352454
353   state_save_register_item(machine, "pd4990a", NULL, 0, shiftlo);
354   state_save_register_item(machine, "pd4990a", NULL, 0, shifthi);
455#if 0
456   upd4990a->seconds = 0x00;
457   upd4990a->minutes = 0x00;
458   upd4990a->hours = 0x00;
459   upd4990a->days = 0x09;
460   upd4990a->month = 9;
461   upd4990a->year = 0x73;
462   upd4990a->weekday = 1;
463#endif
464   /* HACK: load time counter from system time */
465   upd4990a->seconds = convert_to_bcd(systime->local_time.second);
466   upd4990a->minutes = convert_to_bcd(systime->local_time.minute);
467   upd4990a->hours = convert_to_bcd(systime->local_time.hour);
468   upd4990a->days = convert_to_bcd(systime->local_time.mday);
469   upd4990a->month = systime->local_time.month + 1;
470   upd4990a->year = ((((systime->local_time.year - 1900) % 100) / 10) << 4) | ((systime->local_time.year - 1900) % 10);
471   upd4990a->weekday = systime->local_time.weekday;
355472
356   state_save_register_item(machine, "pd4990a", NULL, 0, retraces);
357   state_save_register_item(machine, "pd4990a", NULL, 0, testwaits);
358   state_save_register_item(machine, "pd4990a", NULL, 0, maxwaits);
359   state_save_register_item(machine, "pd4990a", NULL, 0, testbit);
473   /* register for state saving */
474   state_save_register_device_item(device, 0, upd4990a->seconds);
475   state_save_register_device_item(device, 0, upd4990a->minutes);
476   state_save_register_device_item(device, 0, upd4990a->hours);
477   state_save_register_device_item(device, 0, upd4990a->days);
478   state_save_register_device_item(device, 0, upd4990a->month);
479   state_save_register_device_item(device, 0, upd4990a->year);
480   state_save_register_device_item(device, 0, upd4990a->weekday);
360481
361   state_save_register_item(machine, "pd4990a", NULL, 0, outputbit);
362   state_save_register_item(machine, "pd4990a", NULL, 0, bitno);
363   state_save_register_item(machine, "pd4990a", NULL, 0, reading);
364   state_save_register_item(machine, "pd4990a", NULL, 0, writting);
482   state_save_register_device_item(device, 0, upd4990a->shiftlo);
483   state_save_register_device_item(device, 0, upd4990a->shifthi);
365484
366   state_save_register_item(machine, "pd4990a", NULL, 0, clock_line);
367   state_save_register_item(machine, "pd4990a", NULL, 0, command_line);
485   state_save_register_device_item(device, 0, upd4990a->retraces);
486   state_save_register_device_item(device, 0, upd4990a->testwaits);
487   state_save_register_device_item(device, 0, upd4990a->maxwaits);
488   state_save_register_device_item(device, 0, upd4990a->testbit);
489
490   state_save_register_device_item(device, 0, upd4990a->outputbit);
491   state_save_register_device_item(device, 0, upd4990a->bitno);
492   state_save_register_device_item(device, 0, upd4990a->reading);
493   state_save_register_device_item(device, 0, upd4990a->writing);
494
495   state_save_register_device_item(device, 0, upd4990a->clock_line);
496   state_save_register_device_item(device, 0, upd4990a->command_line);
368497}
498
499
500/*-------------------------------------------------
501    DEVICE_RESET( upd4990a )
502-------------------------------------------------*/
503
504static DEVICE_RESET( upd4990a )
505{
506   upd4990a_state *upd4990a = get_safe_token(device);
507
508   upd4990a->shiftlo = 0;
509   upd4990a->shifthi = 0;
510
511   upd4990a->retraces = 0;
512   upd4990a->testwaits = 0;
513   upd4990a->maxwaits = 1;
514   upd4990a->testbit = 0;
515
516   upd4990a->outputbit = 0;
517   upd4990a->bitno = 0;
518   upd4990a->reading = 0;
519   upd4990a->writing = 0;
520
521   upd4990a->clock_line = 0;
522   upd4990a->command_line = 0;
523}
524
525/*-------------------------------------------------
526    device definition
527-------------------------------------------------*/
528
529static const char *DEVTEMPLATE_SOURCE = __FILE__;
530
531#define DEVTEMPLATE_ID(p,s)      p##upd4990a##s
532#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
533#define DEVTEMPLATE_NAME      "NEC uPD4990A"
534#define DEVTEMPLATE_FAMILY      "NEC uPD4990A Calendar & Clock"
535#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
536#include "devtempl.h"
src/emu/machine/pd4990a.h
r4939r4940
1/*
2 *  Header file for the PD4990A Serial I/O calendar & clock.
3 */
1/***************************************************************************
42
3    NEC uPD4990A
54
6struct pd4990a_s
7{
8   int seconds;
9   int minutes;
10   int hours;
11   int days;
12   int month;
13   int year;
14   int weekday;
15};
5    Serial I/O Calendar & Clock IC
166
17extern struct pd4990a_s pd4990a;
7***************************************************************************/
188
19void pd4990a_addretrace (void);
20void pd4990a_init(running_machine *machine);
21READ8_HANDLER( pd4990a_testbit_r );
22READ8_HANDLER( pd4990a_databit_r );
23WRITE16_HANDLER( pd4990a_control_16_w );
24void pd4990a_increment_day(void);
25void pd4990a_increment_month(void);
9#ifndef __PD4990A_H__
10#define __PD4990A_H__
2611
12
13/***************************************************************************
14    MACROS / CONSTANTS
15***************************************************************************/
16
17#define UPD4990A      DEVICE_GET_INFO_NAME(upd4990a)
18
19#define MDRV_UPD4990A_ADD(_tag) \
20   MDRV_DEVICE_ADD(_tag, UPD4990A, 0)
21
22#define MDRV_UPD4990A_REMOVE(_tag) \
23   MDRV_DEVICE_REMOVE(_tag)
24
25
26/***************************************************************************
27    PROTOTYPES
28***************************************************************************/
29
30/* device interface */
31DEVICE_GET_INFO( upd4990a );
32
33/* this should be refactored, once RTCs get unified */
34extern void upd4990a_addretrace( const device_config *device );
35
36extern READ8_DEVICE_HANDLER( upd4990a_testbit_r );
37extern READ8_DEVICE_HANDLER( upd4990a_databit_r );
38extern WRITE16_DEVICE_HANDLER( upd4990a_control_16_w );
39
40
41#endif   /*__PD4990A_H__*/
src/emu/machine/ds1302.c
r4939r4940
1/************************************************************
2
3    DALLAS DS1302
4
5    RTC + BACKUP RAM
6
7
8
9    Emulation by ElSemi
10
11
12    Missing Features:
13      - Burst Mode
14      - Clock programming (useless)
15
16
17
18    2009-05 Converted to be a device
19
20************************************************************/
21
22
123#include "driver.h"
224#include "ds1302.h"
325
4/********************
5    DALLAS
6    DS1302
726
8   RTC+BACKUP RAM
27/***************************************************************************
28    TYPE DEFINITIONS
29***************************************************************************/
930
10   Emulation by ElSemi
11********************/
31typedef struct _ds1302_state ds1302_state;
32struct _ds1302_state
33{
1234
13/********************
14Missing:
15Burst Mode
16Clock programming   (useless)
17********************/
35   UINT32 shift_in;
36   UINT8  shift_out;
37   UINT8  icount;
38   UINT8  last_clk;
39   UINT8  last_cmd;
40   UINT8  sram[0x20];
41};
1842
19static UINT32 ShiftIn=0;
20static UINT8 ShiftOut=0;
21static UINT8 ICount=0;
22static UINT8 LastClk;
23static UINT8 LastCmd=0;
24static UINT8 SRAM[0x20];
43/***************************************************************************
44    INLINE FUNCTIONS
45***************************************************************************/
2546
47INLINE ds1302_state *get_safe_token(const device_config *device)
48{
49   assert(device != NULL);
50   assert(device->token != NULL);
51   assert(device->type == DS1302);
52   return (ds1302_state *)device->token;
53}
2654
27void DS1302_RST(UINT8 val)
55INLINE UINT8 convert_to_bcd(int val)
2856{
29   if(!val)
30   {
31      ICount=0;
32      LastClk=0;
33      ShiftIn=0;
34      LastCmd=0;
35   }
57   return ((val / 10) << 4) | (val % 10);
3658}
3759
38void DS1302_DAT(UINT8 val)
60
61/***************************************************************************
62    IMPLEMENTATION
63***************************************************************************/
64
65/*-------------------------------------------------
66    ds1302_dat_w
67-------------------------------------------------*/
68
69WRITE8_DEVICE_HANDLER( ds1302_dat_w )
3970{
40   if(val)
41      ShiftIn|=(1<<ICount);
71   ds1302_state *ds1302 = get_safe_token(device);
72
73   if (data)
74      ds1302->shift_in |= (1 << ds1302->icount);
4275   else
43      ShiftIn&=~(1<<ICount);
76      ds1302->shift_in &= ~(1 << ds1302->icount);
4477}
4578
46static UINT8 bcd(UINT8 v)
79
80/*-------------------------------------------------
81    ds1302_clk_w
82-------------------------------------------------*/
83
84WRITE8_DEVICE_HANDLER( ds1302_clk_w )
4785{
48   return ((v/10)<<4)|(v%10);
49}
86   ds1302_state *ds1302 = get_safe_token(device);
5087
51void DS1302_CLK(running_machine *machine, UINT8 val)
52{
53   if(val!=LastClk)
88   if (data != ds1302->last_clk)
5489   {
55      if(val)   //Rising, shift in command
90      if (data)   //Rising, shift in command
5691      {
57         ICount++;
58         if(ICount==8)   //Command start
92         ds1302->icount++;
93         if(ds1302->icount == 8)   //Command start
5994         {
6095            mame_system_time systime;
61            mame_get_base_datetime(machine, &systime);
96            mame_get_base_datetime(device->machine, &systime);
6297
63            switch(ShiftIn)
98            switch(ds1302->shift_in)
6499            {
65100               case 0x81:   //Sec
66                  ShiftOut=bcd(systime.local_time.second);
101                  ds1302->shift_out = convert_to_bcd(systime.local_time.second);
67102                  break;
68103               case 0x83:   //Min
69                  ShiftOut=bcd(systime.local_time.minute);
104                  ds1302->shift_out = convert_to_bcd(systime.local_time.minute);
70105                  break;
71106               case 0x85:   //Hour
72                  ShiftOut=bcd(systime.local_time.hour);
107                  ds1302->shift_out = convert_to_bcd(systime.local_time.hour);
73108                  break;
74109               case 0x87:   //Day
75                  ShiftOut=bcd(systime.local_time.mday);
110                  ds1302->shift_out = convert_to_bcd(systime.local_time.mday);
76111                  break;
77112               case 0x89:   //Month
78                  ShiftOut=bcd(systime.local_time.month+1);
113                  ds1302->shift_out = convert_to_bcd(systime.local_time.month + 1);
79114                  break;
80115               case 0x8b:   //weekday
81                  ShiftOut=bcd(systime.local_time.weekday);
116                  ds1302->shift_out = convert_to_bcd(systime.local_time.weekday);
82117                  break;
83118               case 0x8d:   //Year
84                  ShiftOut=bcd(systime.local_time.year%100);
119                  ds1302->shift_out = convert_to_bcd(systime.local_time.year % 100);
85120                  break;
86121               default:
87                  ShiftOut=0x0;
122                  ds1302->shift_out = 0x0;
88123            }
89            if(ShiftIn>0xc0)
90               ShiftOut=SRAM[(ShiftIn>>1)&0x1f];
91            LastCmd=ShiftIn&0xff;
92            ICount++;
124
125            if(ds1302->shift_in > 0xc0)
126               ds1302->shift_out = ds1302->sram[(ds1302->shift_in >> 1) & 0x1f];
127            ds1302->last_cmd = ds1302->shift_in & 0xff;
128            ds1302->icount++;
93129         }
94         if(ICount==17 && !(LastCmd&1))
130
131         if(ds1302->icount == 17 && !(ds1302->last_cmd & 1))
95132         {
96            UINT8 val=(ShiftIn>>9)&0xff;
133            UINT8 val = (ds1302->shift_in >> 9) & 0xff;
97134
98            switch(LastCmd)
135            switch(ds1302->last_cmd)
99136            {
100137               case 0x80:   //Sec
101138
r4939r4940
119156
120157                  break;
121158               default:
122                  ShiftOut=0x0;
159                  ds1302->shift_out = 0x0;
123160            }
124            if(LastCmd>0xc0)
161            if(ds1302->last_cmd > 0xc0)
125162            {
126               SRAM[(LastCmd>>1)&0x1f]=val;
163               ds1302->sram[(ds1302->last_cmd >> 1) & 0x1f] = val;
127164            }
128165
129166
r4939r4940
131168         }
132169      }
133170   }
134   LastClk=val;
171   ds1302->last_clk = data;
135172}
136173
137UINT8 DS1302_RD(void)
174
175/*-------------------------------------------------
176    ds1302_read
177-------------------------------------------------*/
178
179READ8_DEVICE_HANDLER( ds1302_read )
138180{
139   return (ShiftOut&(1<<(ICount-9)))?1:0;
181   ds1302_state *ds1302 = get_safe_token(device);
182   return (ds1302->shift_out & (1 << (ds1302->icount - 9))) ? 1 : 0;
140183}
184
185
186/*-------------------------------------------------
187    DEVICE_START( ds1302 )
188-------------------------------------------------*/
189
190static DEVICE_START( ds1302 )
191{
192   ds1302_state *ds1302 = get_safe_token(device);
193
194   /* register for state saving */
195   state_save_register_device_item(device, 0, ds1302->shift_in);
196   state_save_register_device_item(device, 0, ds1302->shift_out);
197   state_save_register_device_item(device, 0, ds1302->icount);
198   state_save_register_device_item(device, 0, ds1302->last_clk);
199   state_save_register_device_item(device, 0, ds1302->last_cmd);
200   state_save_register_device_item_array(device, 0, ds1302->sram);
201}
202
203/*-------------------------------------------------
204    DEVICE_START( ds1302 )
205-------------------------------------------------*/
206
207static DEVICE_RESET( ds1302 )
208{
209   ds1302_state *ds1302 = get_safe_token(device);
210
211   ds1302->shift_in  = 0;
212   ds1302->shift_out = 0;
213   ds1302->icount    = 0;
214   ds1302->last_clk  = 0;
215   ds1302->last_cmd  = 0;
216}
217
218/*-------------------------------------------------
219    DEVICE_GET_INFO( ds1302 )
220-------------------------------------------------*/
221
222static const char *DEVTEMPLATE_SOURCE = __FILE__;
223
224#define DEVTEMPLATE_ID(p,s)      p##ds1302##s
225#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
226#define DEVTEMPLATE_NAME      "Dallas DS1302 RTC"
227#define DEVTEMPLATE_FAMILY      "Dallas DS1302 RTC"
228#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
229#include "devtempl.h"
src/emu/machine/rp5h01.c
r4939r4940
1/***************************************************************************
2
3    RP5H01
4
5
6    2009-06 Converted to be a device
7
8***************************************************************************/
9
110#include "driver.h"
211#include "machine/rp5h01.h"
312
4/****************************************************************************/
513
6/* local copy of the interface pointer */
7static const struct RP5H01_interface *intf;
14/***************************************************************************
15    PARAMETERS
16***************************************************************************/
817
918/* these also work as the address masks */
1019enum {
r4939r4940
1221   COUNTER_MODE_7_BITS = 0x7f
1322};
1423
15typedef struct _RP5H01 {
24
25/***************************************************************************
26    TYPE DEFINITIONS
27***************************************************************************/
28
29typedef struct _rp5h01_state rp5h01_state;
30struct _rp5h01_state
31{
1632   int counter;
1733   int counter_mode;   /* test pin */
1834   int enabled;      /* chip enable */
1935   int old_reset;      /* reset pin state (level-triggered) */
2036   int old_clock;      /* clock pin state (level-triggered) */
2137   UINT8 *data;
22} RP5H01;
38};
2339
24static RP5H01 RP5H01_state[MAX_RP5H01];
40/***************************************************************************
41    INLINE FUNCTIONS
42***************************************************************************/
2543
26/****************************************************************************/
44INLINE rp5h01_state *get_safe_token(const device_config *device)
45{
46   assert(device != NULL);
47   assert(device->token != NULL);
48   assert((device->type == RP5H01));
49   return (rp5h01_state *)device->token;
50}
2751
28int RP5H01_init( running_machine *machine, const struct RP5H01_interface *interface ) {
29   int i;
30
31   /* setup our local copy of the interface */
32   intf = interface;
33
34   if ( intf->num > MAX_RP5H01 ) {
35      logerror( "Requested number of RP5H01's is bigger than the supported amount\n" );
36      return -1;
37   }
38
39   /* initialize the state */
40   for( i = 0; i < intf->num; i++ ) {
41      RP5H01_state[i].counter = 0;
42      RP5H01_state[i].counter_mode = COUNTER_MODE_6_BITS;
43      RP5H01_state[i].data = &( memory_region( machine, intf->region[i] )[ intf->offset[i] ] );
44      RP5H01_state[i].enabled = 0;
45      RP5H01_state[i].old_reset = -1;
46      RP5H01_state[i].old_clock = -1;
47   }
48
49   return 0;
52INLINE const rp5h01_interface *get_interface(const device_config *device)
53{
54   assert(device != NULL);
55   assert((device->type == RP5H01));
56   return (const rp5h01_interface *) device->static_config;
5057}
5158
52/****************************************************************************/
59/***************************************************************************
60    IMPLEMENTATION
61***************************************************************************/
5362
54void RP5H01_enable_w( int which, int data ) {
55   RP5H01   *chip;
63/*-------------------------------------------------
64    rp5h01_enable_w
65-------------------------------------------------*/
5666
57   if ( which >= intf->num ) {
58      logerror( "RP5H01_enable: trying to access an unmapped chip\n" );
59      return;
60   }
67WRITE8_DEVICE_HANDLER( rp5h01_enable_w )
68{
69   rp5h01_state *rp5h01 = get_safe_token(device);
6170
62   /* get the chip */
63   chip = &RP5H01_state[which];
64
6571   /* process the /CE signal and enable/disable the IC */
66   chip->enabled = ( data == 0 ) ? 1 : 0;
72   rp5h01->enabled = (data == 0) ? 1 : 0;
6773}
6874
69void RP5H01_reset_w( int which, int data ) {
70   RP5H01   *chip;
71   int      newstate = ( data == 0 ) ? 0 : 1;
75/*-------------------------------------------------
76    rp5h01_reset_w
77-------------------------------------------------*/
7278
73   if ( which >= intf->num ) {
74      logerror( "RP5H01_enable: trying to access an unmapped chip\n" );
75      return;
76   }
79WRITE8_DEVICE_HANDLER( rp5h01_reset_w )
80{
81   rp5h01_state *rp5h01 = get_safe_token(device);
82   int newstate = (data == 0) ? 0 : 1;
7783
78   /* get the chip */
79   chip = &RP5H01_state[which];
80
8184   /* if it's not enabled, ignore */
82   if ( !chip->enabled )
85   if (!rp5h01->enabled)
8386      return;
8487
8588   /* now look for a 0->1 transition */
86   if ( chip->old_reset == 0 && newstate == 1 ) {
89   if (rp5h01->old_reset == 0 && newstate == 1)
90   {
8791      /* reset the counter */
88      chip->counter = 0;
92      rp5h01->counter = 0;
8993   }
9094
9195   /* update the pin */
92   chip->old_reset = newstate;
96   rp5h01->old_reset = newstate;
9397}
9498
95void RP5H01_clock_w( int which, int data ) {
96   RP5H01   *chip;
97   int      newstate = ( data == 0 ) ? 0 : 1;
99/*-------------------------------------------------
100    rp5h01_clock_w
101-------------------------------------------------*/
98102
99   if ( which >= intf->num ) {
100      logerror( "RP5H01_enable: trying to access an unmapped chip\n" );
101      return;
102   }
103WRITE8_DEVICE_HANDLER( rp5h01_clock_w )
104{
105   rp5h01_state *rp5h01 = get_safe_token(device);
106   int newstate = (data == 0) ? 0 : 1;
103107
104   /* get the chip */
105   chip = &RP5H01_state[which];
106
107108   /* if it's not enabled, ignore */
108   if ( !chip->enabled )
109   if (!rp5h01->enabled)
109110      return;
110111
111112   /* now look for a 1->0 transition */
112   if ( chip->old_clock == 1 && newstate == 0 ) {
113   if (rp5h01->old_clock == 1 && newstate == 0)
114   {
113115      /* increment the counter, and mask it with the mode */
114      chip->counter++;
116      rp5h01->counter++;
115117   }
116118
117119   /* update the pin */
118   chip->old_clock = newstate;
120   rp5h01->old_clock = newstate;
119121}
120122
121void RP5H01_test_w( int which, int data ) {
122   RP5H01   *chip;
123/*-------------------------------------------------
124    rp5h01_test_w
125-------------------------------------------------*/
123126
124   if ( which >= intf->num ) {
125      logerror( "RP5H01_enable: trying to access an unmapped chip\n" );
126      return;
127   }
127WRITE8_DEVICE_HANDLER( rp5h01_test_w )
128{
129   rp5h01_state *rp5h01 = get_safe_token(device);
128130
129   /* get the chip */
130   chip = &RP5H01_state[which];
131
132131   /* if it's not enabled, ignore */
133   if ( !chip->enabled )
132   if (!rp5h01->enabled)
134133      return;
135134
136135   /* process the test signal and change the counter mode */
137   chip->counter_mode = ( data == 0 ) ? COUNTER_MODE_6_BITS : COUNTER_MODE_7_BITS;
136   rp5h01->counter_mode = (data == 0) ? COUNTER_MODE_6_BITS : COUNTER_MODE_7_BITS;
138137}
139138
140int RP5H01_counter_r( int which ) {
141   RP5H01   *chip;
139/*-------------------------------------------------
140    rp5h01_counter_r
141-------------------------------------------------*/
142142
143   if ( which >= intf->num ) {
144      logerror( "RP5H01_enable: trying to access an unmapped chip\n" );
145      return 0;
146   }
143READ8_DEVICE_HANDLER( rp5h01_counter_r )
144{
145   rp5h01_state *rp5h01 = get_safe_token(device);
147146
148   /* get the chip */
149   chip = &RP5H01_state[which];
150
151147   /* if it's not enabled, ignore */
152   if ( !chip->enabled )
148   if (!rp5h01->enabled)
153149      return 0; /* ? (should be high impedance) */
154150
155151   /* return A5 */
156   return ( chip->counter >> 5 ) & 1;
152   return (rp5h01->counter >> 5) & 1;
157153}
158154
159int RP5H01_data_r( int which ) {
160   RP5H01   *chip;
161   int      byte, bit;
155/*-------------------------------------------------
156    rp5h01_data_r
157-------------------------------------------------*/
162158
163   if ( which >= intf->num ) {
164      logerror( "RP5H01_enable: trying to access an unmapped chip\n" );
165      return 0;
166   }
159READ8_DEVICE_HANDLER( rp5h01_data_r )
160{
161   rp5h01_state *rp5h01 = get_safe_token(device);
162   int byte, bit;
167163
168   /* get the chip */
169   chip = &RP5H01_state[which];
170
171164   /* if it's not enabled, ignore */
172   if ( !chip->enabled )
165   if (!rp5h01->enabled)
173166      return 0; /* ? (should be high impedance) */
174167
175168   /* get the byte offset and bit offset */
176   byte = ( chip->counter & chip->counter_mode) >> 3;
177   bit = 7 - ( chip->counter & 7 );
169   byte = (rp5h01->counter & rp5h01->counter_mode) >> 3;
170   bit = 7 - (rp5h01->counter & 7);
178171
179172   /* return the data */
180   return ( chip->data[byte] >> bit ) & 1;
173   return (rp5h01->data[byte] >> bit) & 1;
181174}
182175
183/****************************************************************************/
176/*-------------------------------------------------
177    DEVICE_START( rp5h01 )
178-------------------------------------------------*/
184179
185WRITE8_HANDLER( RP5H01_0_enable_w ) {
186   RP5H01_enable_w( 0, data );
187}
180static DEVICE_START( rp5h01 )
181{
182   rp5h01_state *rp5h01 = get_safe_token(device);
183   const rp5h01_interface *intf = get_interface(device);
188184
189WRITE8_HANDLER( RP5H01_0_reset_w ) {
190   RP5H01_reset_w( 0, data );
191}
185   rp5h01->data = &(memory_region(device->machine, intf->region)[intf->offset]);
192186
193WRITE8_HANDLER( RP5H01_0_clock_w ) {
194   RP5H01_clock_w( 0, data );
187   /* register for state saving */
188   state_save_register_device_item(device, 0, rp5h01->counter);
189   state_save_register_device_item(device, 0, rp5h01->counter_mode);
190   state_save_register_device_item(device, 0, rp5h01->enabled);
191   state_save_register_device_item(device, 0, rp5h01->old_reset);
192   state_save_register_device_item(device, 0, rp5h01->old_clock);
195193}
196194
197WRITE8_HANDLER( RP5H01_0_test_w ) {
198   RP5H01_test_w( 0, data );
199}
195/*-------------------------------------------------
196    DEVICE_RESET( rp5h01 )
197-------------------------------------------------*/
200198
201READ8_HANDLER( RP5H01_0_counter_r ) {
202   return RP5H01_counter_r( 0 );
199static DEVICE_RESET( rp5h01 )
200{
201   rp5h01_state *rp5h01 = get_safe_token(device);
202
203   rp5h01->counter = 0;
204   rp5h01->counter_mode = COUNTER_MODE_6_BITS;
205   rp5h01->enabled = 0;
206   rp5h01->old_reset = -1;
207   rp5h01->old_clock = -1;
203208}
204209
205READ8_HANDLER( RP5H01_0_data_r ) {
206   return RP5H01_data_r( 0 );
207}
210/*-------------------------------------------------
211    device definition
212-------------------------------------------------*/
213
214static const char *DEVTEMPLATE_SOURCE = __FILE__;
215
216#define DEVTEMPLATE_ID(p,s)      p##rp5h01##s
217#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
218#define DEVTEMPLATE_NAME      "RP5H01"
219#define DEVTEMPLATE_FAMILY      "RP5H01"
220#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
221#include "devtempl.h"
src/emu/machine/ds1302.h
r4939r4940
1extern void DS1302_RST(UINT8 val);
2extern void DS1302_DAT(UINT8 val);
3extern void DS1302_CLK(running_machine *machine, UINT8 val);
4extern UINT8 DS1302_RD(void);
1/**********************************************************************
52
3    DALLAS DS1302
4
5    RTC + BACKUP RAM
6
7**********************************************************************/
8
9#ifndef __DS1302_H__
10#define __DS1302_H__
11
12/***************************************************************************
13    MACROS / CONSTANTS
14***************************************************************************/
15
16#define DS1302      DEVICE_GET_INFO_NAME(ds1302)
17
18#define MDRV_DS1302_ADD(_tag) \
19   MDRV_DEVICE_ADD(_tag, DS1302, 0)
20
21#define MDRV_DS1302_REMOVE(_tag) \
22   MDRV_DEVICE_REMOVE(_tag)
23
24
25/***************************************************************************
26    PROTOTYPES
27***************************************************************************/
28
29/* device interface */
30DEVICE_GET_INFO( ds1302 );
31
32extern WRITE8_DEVICE_HANDLER( ds1302_dat_w );
33extern WRITE8_DEVICE_HANDLER( ds1302_clk_w );
34extern READ8_DEVICE_HANDLER( ds1302_read );
35
36
37#endif /* __DS1302_H__ */
src/emu/machine/rp5h01.h
r4939r4940
1/***************************************************************************
2
3    RP5H01
4
5
6***************************************************************************/
7
18#ifndef __RP5H01_H__
29#define __RP5H01_H__
310
4/* max simultaneous chips supported. change if you need more */
5#define MAX_RP5H01   1
11/***************************************************************************
12    MACROS / CONSTANTS
13***************************************************************************/
614
7struct RP5H01_interface {
8   int num;               /* number of chips */
9   const char *region[MAX_RP5H01];      /* memory region where data resides */
10   int offset[MAX_RP5H01];      /* memory offset within the above region where data resides */
15#define RP5H01      DEVICE_GET_INFO_NAME(rp5h01)
16
17#define MDRV_RP5H01_ADD(_tag, _config) \
18   MDRV_DEVICE_ADD(_tag, RP5H01, 0) \
19   MDRV_DEVICE_CONFIG(_config)
20
21#define MDRV_RP5H01_REMOVE(_tag) \
22   MDRV_DEVICE_REMOVE(_tag)
23
24
25/***************************************************************************
26    TYPE DEFINITIONS
27***************************************************************************/
28
29typedef struct _rp5h01_interface rp5h01_interface;
30struct _rp5h01_interface
31{
32   const char *region;      /* memory region where data resides */
33   int offset;      /* memory offset within the above region where data resides */
1134};
1235
13int RP5H01_init( running_machine *machine, const struct RP5H01_interface *interface );
14void RP5H01_enable_w( int which, int data );            /* /CE */
15void RP5H01_reset_w( int which, int data );            /* RESET */
16void RP5H01_clock_w( int which, int data );            /* DATA CLOCK (active low) */
17void RP5H01_test_w( int which, int data );            /* TEST */
18int RP5H01_counter_r( int which );                  /* COUNTER OUT */
19int RP5H01_data_r( int which );                     /* DATA */
36/***************************************************************************
37    PROTOTYPES
38***************************************************************************/
2039
21/* direct-access stubs */
22WRITE8_HANDLER( RP5H01_0_enable_w );
23WRITE8_HANDLER( RP5H01_0_reset_w );
24WRITE8_HANDLER( RP5H01_0_clock_w );
25WRITE8_HANDLER( RP5H01_0_test_w );
26READ8_HANDLER( RP5H01_0_counter_r );
27READ8_HANDLER( RP5H01_0_data_r );
40/* device interface */
41DEVICE_GET_INFO( rp5h01 );
2842
43WRITE8_DEVICE_HANDLER( rp5h01_enable_w );   /* /CE */
44WRITE8_DEVICE_HANDLER( rp5h01_reset_w );   /* RESET */
45WRITE8_DEVICE_HANDLER( rp5h01_clock_w );   /* DATA CLOCK (active low) */
46WRITE8_DEVICE_HANDLER( rp5h01_test_w );      /* TEST */
47READ8_DEVICE_HANDLER( rp5h01_counter_r );   /* COUNTER OUT */
48READ8_DEVICE_HANDLER( rp5h01_data_r );      /* DATA */
49
2950#endif /* __RP5H01_H__ */
src/emu/machine/adc083x.c
r4939r4940
1/*
2 * ADC0831/ADC0832/ADC0834/ADC0838
3 *
4 * 8-Bit Serial I/O A/D Converters with Muliplexer Options
5 *
6 */
1/***************************************************************************
72
8#include <stdarg.h>
3    National Semiconductor ADC0831 / ADC0832 / ADC0834 / ADC0838
4
5    8-Bit serial I/O A/D Converters with Muliplexer Options
6
7
8    2009-06 Converted to be a device
9
10***************************************************************************/
11
912#include "driver.h"
10#include "machine/adc083x.h"
13#include "adc083x.h"
1114
12#define VERBOSE_LEVEL ( 0 )
15#define VERBOSE_LEVEL (0)
1316
1417INLINE void ATTR_PRINTF(3,4) verboselog( running_machine *machine, int n_level, const char *s_fmt, ... )
1518{
16   if( VERBOSE_LEVEL >= n_level )
19   if (VERBOSE_LEVEL >= n_level)
1720   {
1821      va_list v;
1922      char buf[ 32768 ];
20      va_start( v, s_fmt );
21      vsprintf( buf, s_fmt, v );
22      va_end( v );
23      logerror( "%s: %s", cpuexec_describe_context(machine), buf );
23      va_start(v, s_fmt);
24      vsprintf(buf, s_fmt, v);
25      va_end(v);
26      logerror("%s: %s", cpuexec_describe_context(machine), buf);
2427   }
2528}
2629
27struct adc083x_chip
30/***************************************************************************
31    PARAMETERS
32***************************************************************************/
33
34enum
2835{
29   int type;
30   double (*input_callback)(running_machine *machine, int input);
31   INT32 CS;
32   INT32 CLK;
33   INT32 DI;
34   INT32 SE;
35   INT32 SARS;
36   INT32 DO;
37   INT32 SGL;
38   INT32 ODD;
39   INT32 SEL1;
40   INT32 SEL0;
36   STATE_IDLE,
37   STATE_WAIT_FOR_START,
38   STATE_SHIFT_MUX,
39   STATE_MUX_SETTLE,
40   STATE_OUTPUT_MSB_FIRST,
41   STATE_WAIT_FOR_SE,
42   STATE_OUTPUT_LSB_FIRST,
43   STATE_FINISHED
44};
45
46/***************************************************************************
47    TYPE DEFINITIONS
48***************************************************************************/
49
50typedef struct _adc0831_state adc0831_state;
51struct _adc0831_state
52{
53   adc083x_input_convert_func input_callback_r;
54
55   INT32 cs;
56   INT32 clk;
57   INT32 di;
58   INT32 se;
59   INT32 sars;
60   INT32 _do;
61   INT32 sgl;
62   INT32 odd;
63   INT32 sel1;
64   INT32 sel0;
4165   INT32 state;
4266   INT32 bit;
4367   INT32 output;
4468   INT32 mux_bits;
4569};
4670
47#define STATE_IDLE ( 0 )
48#define STATE_WAIT_FOR_START ( 1 )
49#define STATE_SHIFT_MUX ( 2 )
50#define STATE_MUX_SETTLE ( 3 )
51#define STATE_OUTPUT_MSB_FIRST ( 4 )
52#define STATE_WAIT_FOR_SE ( 5 )
53#define STATE_OUTPUT_LSB_FIRST ( 6 )
54#define STATE_FINISHED ( 7 )
5571
56static struct adc083x_chip adc083x[ MAX_ADC083X_CHIPS ];
5772
58void adc083x_init( running_machine *machine, int chip, int type, double (*input_callback)(running_machine *machine, int input) )
73/***************************************************************************
74    INLINE FUNCTIONS
75***************************************************************************/
76
77INLINE adc0831_state *get_safe_token(const device_config *device)
5978{
60   struct adc083x_chip *c;
79   assert(device != NULL);
80   assert(device->token != NULL);
81   assert((device->type == ADC0831) || (device->type == ADC0832) || (device->type == ADC0834) || (device->type == ADC0838));
82   return (adc0831_state *)device->token;
83}
6184
62   if( chip >= MAX_ADC083X_CHIPS )
63   {
64      verboselog( machine, 0, "adc083x_init( %d ) chip out of range\n", chip );
65      return;
66   }
85INLINE const adc0831_interface *get_interface(const device_config *device)
86{
87   assert(device != NULL);
88   assert((device->type == ADC0831) || (device->type == ADC0832) || (device->type == ADC0834) || (device->type == ADC0838));
89   return (const adc0831_interface *) device->static_config;
90}
6791
68   c = &adc083x[ chip ];
6992
70   c->type = type;
71   c->input_callback = input_callback;
72   c->CS = 0;
73   c->CLK = 0;
74   c->DI = 0;
75   c->SE = 0;
76   if( c->type == ADC0834 || c->type == ADC0838 )
77   {
78      c->SARS = 1;
79   }
80   else
81   {
82      c->SARS = 0;
83   }
84   c->DO = 1;
85   c->SGL = 0;
86   c->ODD = 0;
87   c->SEL1 = 0;
88   c->SEL0 = 0;
89   c->state = STATE_IDLE;
90   c->bit = 0;
91   c->output = 0;
93/***************************************************************************
94    IMPLEMENTATION
95***************************************************************************/
9296
93   switch( c->type )
94   {
95   case ADC0831:
96      c->mux_bits = 0;
97      break;
98   case ADC0832:
99      c->mux_bits = 2;
100      break;
101   case ADC0834:
102      c->mux_bits = 3;
103      break;
104   case ADC0838:
105      c->mux_bits = 4;
106      break;
107   }
97/*-------------------------------------------------
98    adc083x_cs_write
99-------------------------------------------------*/
108100
109   state_save_register_item( machine, "adc083x", NULL, chip, c->CS );
110   state_save_register_item( machine, "adc083x", NULL, chip, c->CLK );
111   state_save_register_item( machine, "adc083x", NULL, chip, c->DI );
112   state_save_register_item( machine, "adc083x", NULL, chip, c->SE );
113   state_save_register_item( machine, "adc083x", NULL, chip, c->SARS );
114   state_save_register_item( machine, "adc083x", NULL, chip, c->DO );
115   state_save_register_item( machine, "adc083x", NULL, chip, c->SGL );
116   state_save_register_item( machine, "adc083x", NULL, chip, c->ODD );
117   state_save_register_item( machine, "adc083x", NULL, chip, c->SEL1 );
118   state_save_register_item( machine, "adc083x", NULL, chip, c->SEL0 );
119   state_save_register_item( machine, "adc083x", NULL, chip, c->state );
120   state_save_register_item( machine, "adc083x", NULL, chip, c->bit );
121   state_save_register_item( machine, "adc083x", NULL, chip, c->output );
122}
123
124void adc083x_cs_write( running_machine *machine, int chip, int cs )
101WRITE8_DEVICE_HANDLER( adc083x_cs_write )
125102{
126   struct adc083x_chip *c;
103   adc0831_state *adc083x = get_safe_token(device);
127104
128   if( chip >= MAX_ADC083X_CHIPS )
105   if (adc083x->cs != data)
129106   {
130      verboselog( machine, 0, "adc083x_cs_write( %d ) chip out of range\n", chip );
131      return;
107      verboselog(device->machine, 2, "adc083x_cs_write( %s, %d )\n", device->tag, data);
132108   }
133109
134   c = &adc083x[ chip ];
135
136   if( c->CS != cs )
110   if (adc083x->cs == 0 && data != 0)
137111   {
138      verboselog( machine, 2, "adc083x_cs_write( %d, %d )\n", chip, cs );
139   }
140
141   if( c->CS == 0 && cs != 0 )
142   {
143      c->state = STATE_IDLE;
144      if( c->type == ADC0834 || c->type == ADC0838 )
112      adc083x->state = STATE_IDLE;
113      if (device->type == ADC0834 || device->type == ADC0838)
145114      {
146         c->SARS = 1;
115         adc083x->sars = 1;
147116      }
148      c->DO = 1;
117      adc083x->_do = 1;
149118   }
150   if( c->CS != 0 && cs == 0 )
119   if (adc083x->cs != 0 && data == 0)
151120   {
152      if( c->type == ADC0831 )
121      if (device->type == ADC0831)
153122      {
154         c->state = STATE_MUX_SETTLE;
123         adc083x->state = STATE_MUX_SETTLE;
155124      }
156125      else
157126      {
158         c->state = STATE_WAIT_FOR_START;
127         adc083x->state = STATE_WAIT_FOR_START;
159128      }
160      if( c->type == ADC0834 || c->type == ADC0838 )
129
130      if (device->type == ADC0834 || device->type == ADC0838)
161131      {
162         c->SARS = 1;
132         adc083x->sars = 1;
163133      }
164      c->DO = 1;
134      adc083x->_do = 1;
165135   }
166136
167   c->CS = cs;
137   adc083x->cs = data;
168138}
169139
170static int adc083x_conversion( running_machine *machine, int chip )
140/*-------------------------------------------------
141    adc083x_conversion
142-------------------------------------------------*/
143
144static UINT8 adc083x_conversion( const device_config *device )
171145{
172   struct adc083x_chip *c = &adc083x[ chip ];
146   adc0831_state *adc083x = get_safe_token(device);
173147   int result;
174148   int positive_channel = ADC083X_AGND;
175149   int negative_channel = ADC083X_AGND;
176150   double positive = 0;
177151   double negative = 0;
178   double gnd = c->input_callback( machine, ADC083X_AGND );
179   double vref = c->input_callback( machine, ADC083X_VREF );
152   double vref = adc083x->input_callback_r(device, ADC083X_VREF);
153   double gnd = adc083x->input_callback_r(device, ADC083X_VREF);
180154
181   switch( c->type )
155   if (device->type == ADC0831)
182156   {
183   case ADC0831:
184157      positive_channel = ADC083X_CH0;
185158      negative_channel = ADC083X_CH1;
186      break;
187   case ADC0832:
188      positive_channel = ADC083X_CH0 + c->ODD;
189      if( c->SGL == 0 )
159   }
160
161   else if (device->type == ADC0832)
162   {
163      positive_channel = ADC083X_CH0 + adc083x->odd;
164      if (adc083x->sgl == 0)
190165      {
191166         negative_channel = positive_channel ^ 1;
192167      }
r4939r4940
194169      {
195170         negative_channel = ADC083X_AGND;
196171      }
197      break;
198   case ADC0834:
199      positive_channel = ADC083X_CH0 + c->ODD + ( c->SEL1 * 2 );
200      if( c->SGL == 0 )
172   }
173   else if (device->type == ADC0834)
174   {
175      positive_channel = ADC083X_CH0 + adc083x->odd + (adc083x->sel1 * 2);
176      if (adc083x->sgl == 0)
201177      {
202178         negative_channel = positive_channel ^ 1;
203179      }
r4939r4940
205181      {
206182         negative_channel = ADC083X_AGND;
207183      }
208      break;
209   case ADC0838:
210      positive_channel = ADC083X_CH0 + c->ODD + ( c->SEL0 * 2 ) + ( c->SEL1 * 4 );
211      if( c->SGL == 0 )
184      }
185   else if (device->type == ADC0838)
186   {
187      positive_channel = ADC083X_CH0 + adc083x->odd + (adc083x->sel0 * 2) + (adc083x->sel1 * 4);
188      if (adc083x->sgl == 0)
212189      {
213190         negative_channel = positive_channel ^ 1;
214191      }
r4939r4940
216193      {
217194         negative_channel = ADC083X_COM;
218195      }
219      break;
220196   }
221197
222   if( positive_channel != ADC083X_AGND )
198   if (positive_channel != ADC083X_AGND)
223199   {
224      positive = c->input_callback( machine, positive_channel ) - gnd;
200      positive = adc083x->input_callback_r(device, positive_channel) - gnd;
225201   }
226   if( negative_channel != ADC083X_AGND )
202   if (negative_channel != ADC083X_AGND)
227203   {
228      negative = c->input_callback( machine, negative_channel ) - gnd;
204      negative = adc083x->input_callback_r(device, negative_channel) - gnd;
229205   }
230206
231   result = (int)( ( ( positive - negative ) * 255 ) / vref );
232   if( result < 0 )
207   result = (int)(((positive - negative) * 255) / vref);
208   logerror("%d", result);
209   if (result < 0)
233210   {
234211      result = 0;
235212   }
236   else if( result > 255 )
213   else if (result > 255)
237214   {
238215      result = 255;
239216   }
r4939r4940
241218   return result;
242219}
243220
244void adc083x_clk_write( running_machine *machine, int chip, int clk )
221/*-------------------------------------------------
222    adc083x_clk_write
223-------------------------------------------------*/
224
225WRITE8_DEVICE_HANDLER( adc083x_clk_write )
245226{
246   struct adc083x_chip *c;
227   adc0831_state *adc083x = get_safe_token(device);
247228
248   if( chip >= MAX_ADC083X_CHIPS )
229   if (adc083x->clk != data)
249230   {
250      verboselog( machine, 0, "adc083x_clk_write( %d ) chip out of range\n", chip );
251      return;
231      verboselog(device->machine, 2, "adc083x_clk_write( %s, %d )\n", device->tag, data);
252232   }
253233
254   c = &adc083x[ chip ];
255
256   if( c->CLK != clk )
234   if (adc083x->cs == 0)
257235   {
258      verboselog( machine, 2, "adc083x_clk_write( %d, %d )\n", chip, clk );
259   }
260
261   if( c->CS == 0 )
262   {
263      if( c->CLK == 0 && clk != 0 )
236      if (adc083x->clk == 0 && data != 0)
264237      {
265         switch( c->state )
238         switch (adc083x->state)
266239         {
267240         case STATE_WAIT_FOR_START:
268            if( c->DI != 0 )
241            if (adc083x->di != 0)
269242            {
270               verboselog( machine, 1, "adc083x %d got start bit\n", chip );
271               c->state = STATE_SHIFT_MUX;
272               c->SARS = 0;
273               c->SGL = 0;
274               c->ODD = 0;
275               c->SEL1 = 0;
276               c->SEL0 = 0;
277               c->bit = 0;
243               verboselog(device->machine, 1, "adc083x %s got start bit\n", device->tag);
244               adc083x->state = STATE_SHIFT_MUX;
245               adc083x->sars = 0;
246               adc083x->sgl = 0;
247               adc083x->odd = 0;
248               adc083x->sel1 = 0;
249               adc083x->sel0 = 0;
250               adc083x->bit = 0;
278251            }
279252            else
280253            {
281               verboselog( machine, 1, "adc083x %d not start bit\n", chip );
254               verboselog(device->machine, 1, "adc083x %s not start bit\n", device->tag);
282255            }
283256            break;
284257         case STATE_SHIFT_MUX:
285            switch( c->bit )
258            switch (adc083x->bit)
286259            {
287260            case 0:
288               if( c->DI != 0 )
261               if (adc083x->di != 0)
289262               {
290                  c->SGL = 1;
263                  adc083x->sgl = 1;
291264               }
292               verboselog( machine, 1, "adc083x %d SGL <- %d\n", chip, c->SGL );
265               verboselog(device->machine, 1, "adc083x %s sgl <- %d\n", device->tag, adc083x->sgl);
293266               break;
294267            case 1:
295               if( c->DI != 0 )
268               if (adc083x->di != 0)
296269               {
297                  c->ODD = 1;
270                  adc083x->odd = 1;
298271               }
299               verboselog( machine, 1, "adc083x %d ODD <- %d\n", chip, c->ODD );
272               verboselog(device->machine, 1, "adc083x %s odd <- %d\n", device->tag, adc083x->odd);
300273               break;
301274            case 2:
302               if( c->DI != 0 )
275               if (adc083x->di != 0)
303276               {
304                  c->SEL1 = 1;
277                  adc083x->sel1 = 1;
305278               }
306               verboselog( machine, 1, "adc083x %d SEL1 <- %d\n", chip, c->SEL1 );
279               verboselog(device->machine, 1, "adc083x %s sel1 <- %d\n", device->tag, adc083x->sel1);
307280               break;
308281            case 3:
309               if( c->DI != 0 )
282               if (adc083x->di != 0)
310283               {
311                  c->SEL0 = 1;
284                  adc083x->sel0 = 1;
312285               }
313               verboselog( machine, 1, "adc083x %d SEL0 <- %d\n", chip, c->SEL0 );
286               verboselog(device->machine, 1, "adc083x %s sel0 <- %d\n", device->tag, adc083x->sel0);
314287               break;
315288            }
316            c->bit++;
317            if( c->bit == c->mux_bits )
289            adc083x->bit++;
290            if (adc083x->bit == adc083x->mux_bits)
318291            {
319               c->state = STATE_MUX_SETTLE;
292               adc083x->state = STATE_MUX_SETTLE;
320293            }
321294            break;
322295         case STATE_WAIT_FOR_SE:
323            c->SARS = 0;
324            if( c->type == ADC0838 && c->SE != 0 )
296            adc083x->sars = 0;
297            if (device->type == ADC0838 && adc083x->se != 0)
325298            {
326               verboselog( machine, 1, "adc083x %d not SE\n", chip );
299               verboselog(device->machine, 1, "adc083x %s not se\n", device->tag);
327300            }
328301            else
329302            {
330               verboselog( machine, 1, "adc083x %d got SE\n", chip );
331               c->state = STATE_OUTPUT_LSB_FIRST;
332               c->bit = 1;
303               verboselog(device->machine, 1, "adc083x %s got se\n", device->tag);
304               adc083x->state = STATE_OUTPUT_LSB_FIRST;
305               adc083x->bit = 1;
333306            }
334307            break;
335308         }
336309      }
337      if( c->CLK != 0 && clk == 0 )
310      if (adc083x->clk != 0 && data == 0)
338311      {
339         switch( c->state )
312         switch (adc083x->state)
340313         {
341314         case STATE_MUX_SETTLE:
342            verboselog( machine, 1, "adc083x %d mux settle\n", chip );
343            c->output = adc083x_conversion( machine, chip );
344            c->state = STATE_OUTPUT_MSB_FIRST;
345            c->bit = 7;
346            if( c->type == ADC0834 || c->type == ADC0838 )
315            verboselog(device->machine, 1, "adc083x %s mux settle\n", device->tag);
316            adc083x->output = adc083x_conversion(device);
317            adc083x->state = STATE_OUTPUT_MSB_FIRST;
318            adc083x->bit = 7;
319            if (device->type == ADC0834 || device->type == ADC0838)
347320            {
348               c->SARS = 1;
321               adc083x->sars = 1;
349322            }
350            c->DO = 0;
323            adc083x->_do = 0;
351324            break;
352325         case STATE_OUTPUT_MSB_FIRST:
353            c->DO = ( c->output >> c->bit ) & 1;
354            verboselog( machine, 1, "adc083x %d msb %d -> %d\n", chip, c->bit, c->DO );
355            c->bit--;
356            if( c->bit < 0 )
326            adc083x->_do = (adc083x->output >> adc083x->bit) & 1;
327            verboselog(device->machine, 1, "adc083x %s msb %d -> %d\n", device->tag, adc083x->bit, adc083x->_do);
328            adc083x->bit--;
329            if (adc083x->bit < 0)
357330            {
358               if( c->type == ADC0831 )
331               if (device->type == ADC0831)
359332               {
360                  c->state = STATE_FINISHED;
333                  adc083x->state = STATE_FINISHED;
361334               }
362335               else
363336               {
364                  c->state = STATE_WAIT_FOR_SE;
337                  adc083x->state = STATE_WAIT_FOR_SE;
365338               }
366339            }
367340            break;
368341         case STATE_OUTPUT_LSB_FIRST:
369            c->DO = ( c->output >> c->bit ) & 1;
370            verboselog( machine, 1, "adc083x %d lsb %d -> %d\n", chip, c->bit, c->DO );
371            c->bit++;
372            if( c->bit == 8 )
342            adc083x->_do = (adc083x->output >> adc083x->bit) & 1;
343            verboselog(device->machine, 1, "adc083x %s lsb %d -> %d\n", device->tag, adc083x->bit, adc083x->_do);
344            adc083x->bit++;
345            if (adc083x->bit == 8)
373346            {
374               c->state = STATE_FINISHED;
347               adc083x->state = STATE_FINISHED;
375348            }
376349            break;
377350         case STATE_FINISHED:
378            c->state = STATE_IDLE;
379            c->DO = 0;
351            adc083x->state = STATE_IDLE;
352            adc083x->_do = 0;
380353            break;
381354         }
382355      }
383356   }
384357
385   c->CLK = clk;
358   adc083x->clk = data;
386359}
387360
388void adc083x_di_write( running_machine *machine, int chip, int di )
361/*-------------------------------------------------
362    adc083x_di_write
363-------------------------------------------------*/
364
365WRITE8_DEVICE_HANDLER( adc083x_di_write )
389366{
390   struct adc083x_chip *c;
367   adc0831_state *adc083x = get_safe_token(device);
391368
392   if( chip >= MAX_ADC083X_CHIPS )
369   if (adc083x->di != data)
393370   {
394      verboselog( machine, 0, "adc083x_di_write( %d ) chip out of range\n", chip );
395      return;
371      verboselog(device->machine, 2, "adc083x_di_write( %s, %d )\n", device->tag, data);
396372   }
397373
398   c = &adc083x[ chip ];
374   adc083x->di = data;
375}
399376
400   if( c->DI != di )
377/*-------------------------------------------------
378    adc083x_se_write
379-------------------------------------------------*/
380
381WRITE8_DEVICE_HANDLER( adc083x_se_write )
382{
383   adc0831_state *adc083x = get_safe_token(device);
384
385   if (adc083x->se != data)
401386   {
402      verboselog( machine, 2, "adc083x_di_write( %d, %d )\n", chip, di );
387      verboselog(device->machine, 2, "adc083x_se_write( %s, %d )\n", device->tag, data);
403388   }
404389
405   c->DI = di;
390   adc083x->se = data;
406391}
407392
408void adc083x_se_write( running_machine *machine, int chip, int se )
393/*-------------------------------------------------
394    adc083x_sars_read
395-------------------------------------------------*/
396
397READ8_DEVICE_HANDLER( adc083x_sars_read )
409398{
410   struct adc083x_chip *c;
399   adc0831_state *adc083x = get_safe_token(device);
411400
412   if( chip >= MAX_ADC083X_CHIPS )
413   {
414      verboselog( machine, 0, "adc083x_se_write( %d ) chip out of range\n", chip );
415      return;
416   }
401   verboselog(device->machine, 1, "adc083x_sars_read( %s ) %d\n", device->tag, adc083x->sars);
402   return adc083x->sars;
403}
417404
418   c = &adc083x[ chip ];
405/*-------------------------------------------------
406    adc083x_do_read
407-------------------------------------------------*/
419408
420   if( c->SE != se )
421   {
422      verboselog( machine, 2, "adc083x_se_write( %d, %d )\n", chip, se );
423   }
409READ8_DEVICE_HANDLER( adc083x_do_read )
410{
411   adc0831_state *adc083x = get_safe_token(device);
424412
425   c->SE = se;
413   verboselog(device->machine, 1, "adc083x_sars_read( %s ) %d\n", device->tag, adc083x->_do);
414   return adc083x->_do;
426415}
427416
428int adc083x_sars_read( running_machine *machine, int chip )
417
418/*-------------------------------------------------
419    DEVICE_START( adc083x )
420-------------------------------------------------*/
421
422static DEVICE_START( adc0831 )
429423{
430   struct adc083x_chip *c;
424   adc0831_state *adc083x = get_safe_token(device);
425   const adc0831_interface *intf = get_interface(device);
431426
432   if( chip >= MAX_ADC083X_CHIPS )
427   if (device->type == ADC0831)
433428   {
434      verboselog( machine, 0, "adc083x_sars_read( %d ) chip out of range\n", chip );
435      return 0;
429      adc083x->sars = 1;
430      adc083x->mux_bits = 0;
436431   }
432   else if (device->type == ADC0832)
433   {
434         adc083x->sars = 1;
435         adc083x->mux_bits = 2;
436   }
437   else if (device->type == ADC0834)
438   {
439         adc083x->sars = 0;
440         adc083x->mux_bits = 3;
441   }
442   else if (device->type == ADC0838)
443   {
444         adc083x->sars = 0;
445         adc083x->mux_bits = 4;
446   }
437447
438   c = &adc083x[ chip ];
448   /* resolve callbacks */
449   adc083x->input_callback_r = intf->input_callback_r;
439450
440   verboselog( machine, 1, "adc083x_sars_read( %d ) %d\n", chip, c->SARS );
441   return c->SARS;
451   /* register for state saving */
452   state_save_register_device_item(device, 0, adc083x->cs);
453   state_save_register_device_item(device, 0, adc083x->clk);
454   state_save_register_device_item(device, 0, adc083x->di);
455   state_save_register_device_item(device, 0, adc083x->se);
456   state_save_register_device_item(device, 0, adc083x->sars);
457   state_save_register_device_item(device, 0, adc083x->_do);
458   state_save_register_device_item(device, 0, adc083x->sgl);
459   state_save_register_device_item(device, 0, adc083x->odd);
460   state_save_register_device_item(device, 0, adc083x->sel1);
461   state_save_register_device_item(device, 0, adc083x->sel0);
462   state_save_register_device_item(device, 0, adc083x->state);
463   state_save_register_device_item(device, 0, adc083x->bit);
464   state_save_register_device_item(device, 0, adc083x->output);
465   state_save_register_device_item(device, 0, adc083x->mux_bits);
442466}
443467
444int adc083x_do_read( running_machine *machine, int chip )
468
469/*-------------------------------------------------
470    DEVICE_RESET( adc083x )
471-------------------------------------------------*/
472
473static DEVICE_RESET( adc0831 )
445474{
446   struct adc083x_chip *c;
475   adc0831_state *adc083x = get_safe_token(device);
447476
448   if( chip >= MAX_ADC083X_CHIPS )
449   {
450      verboselog( machine, 0, "adc083x_do_read( %d ) chip out of range\n", chip );
451      return 0;
452   }
477   adc083x->cs = 0;
478   adc083x->clk = 0;
479   adc083x->di = 0;
480   adc083x->se = 0;
481   adc083x->_do = 1;
482   adc083x->sgl = 0;
483   adc083x->odd = 0;
484   adc083x->sel1 = 0;
485   adc083x->sel0 = 0;
486   adc083x->state = STATE_IDLE;
487   adc083x->bit = 0;
488   adc083x->output = 0;
489}
453490
454   c = &adc083x[ chip ];
491/*-------------------------------------------------
492    device definition
493-------------------------------------------------*/
455494
456   verboselog( machine, 1, "adc083x_do_read( %d ) %d\n", chip, c->DO );
457   return c->DO;
458}
495static const char *DEVTEMPLATE_SOURCE = __FILE__;
496
497#define DEVTEMPLATE_ID(p,s)      p##adc0831##s
498#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
499#define DEVTEMPLATE_NAME      "A/D Converters 0831"
500#define DEVTEMPLATE_FAMILY      "National Semiconductor A/D Converters 083x"
501#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
502#include "devtempl.h"
503
504#define DEVTEMPLATE_DERIVED_ID(p,s)      p##adc0832##s
505#define DEVTEMPLATE_DERIVED_FEATURES   0
506#define DEVTEMPLATE_DERIVED_NAME      "A/D Converters 0832"
507#include "devtempl.h"
508
509#define DEVTEMPLATE_DERIVED_ID(p,s)      p##adc0834##s
510#define DEVTEMPLATE_DERIVED_FEATURES   0
511#define DEVTEMPLATE_DERIVED_NAME      "A/D Converters 0834"
512#include "devtempl.h"
513
514#define DEVTEMPLATE_DERIVED_ID(p,s)      p##adc0838##s
515#define DEVTEMPLATE_DERIVED_FEATURES   0
516#define DEVTEMPLATE_DERIVED_NAME      "A/D Converters 0838"
517#include "devtempl.h"
src/emu/machine/adc083x.h
r4939r4940
1/*
2 * ADC0831/ADC0832/ADC0834/ADC0838
3 *
4 * 8-Bit Serial I/O A/D Converters with Muliplexer Options
5 *
6 */
1/***************************************************************************
72
8#if !defined( ADC083X_H )
9#define ADC083X_H ( 1 )
3    National Semiconductor ADC0831 / ADC0832 / ADC0834 / ADC0838
104
11#define MAX_ADC083X_CHIPS ( 1 )
5    8-Bit serial I/O A/D Converters with Muliplexer Options
126
13#define ADC083X_CH0 ( 0 )
14#define ADC083X_CH1 ( 1 )
15#define ADC083X_CH2 ( 2 )
16#define ADC083X_CH3 ( 3 )
17#define ADC083X_CH4 ( 4 )
18#define ADC083X_CH5 ( 5 )
19#define ADC083X_CH6 ( 6 )
20#define ADC083X_CH7 ( 7 )
21#define ADC083X_COM ( 8 )
22#define ADC083X_AGND ( 9 )
23#define ADC083X_VREF ( 10 )
7***************************************************************************/
248
25#define ADC0831 ( 0 )
26#define ADC0832 ( 1 )
27#define ADC0834 ( 2 )
28#define ADC0838 ( 3 )
9#ifndef __ADC083X_H__
10#define __ADC083X_H__
2911
30void adc083x_init( running_machine *machine, int chip, int type, double (*input_callback)( running_machine *machine, int input ) );
31extern void adc083x_cs_write( running_machine *machine, int chip, int cs );
32extern void adc083x_clk_write( running_machine *machine, int chip, int clk );
33extern void adc083x_di_write( running_machine *machine, int chip, int di );
34extern void adc083x_se_write( running_machine *machine, int chip, int se );
35extern int adc083x_sars_read( running_machine *machine, int chip );
36extern int adc083x_do_read( running_machine *machine, int chip );
12#include "devcb.h"
3713
38#endif
14/***************************************************************************
15    CONSTANTS
16***************************************************************************/
17
18#define ADC083X_CH0      0
19#define ADC083X_CH1      1
20#define ADC083X_CH2      2
21#define ADC083X_CH3      3
22#define ADC083X_CH4      4
23#define ADC083X_CH5      5
24#define ADC083X_CH6      6
25#define ADC083X_CH7      7
26#define ADC083X_COM      8
27#define ADC083X_AGND   9
28#define ADC083X_VREF   10
29
30/***************************************************************************
31    MACROS / CONSTANTS
32***************************************************************************/
33
34#define ADC0831      DEVICE_GET_INFO_NAME(adc0831)
35#define ADC0832      DEVICE_GET_INFO_NAME(adc0832)
36#define ADC0834      DEVICE_GET_INFO_NAME(adc0834)
37#define ADC0838      DEVICE_GET_INFO_NAME(adc0838)
38
39#define MDRV_ADC0831_ADD(_tag, _config) \
40   MDRV_DEVICE_ADD(_tag, ADC0831, 0) \
41   MDRV_DEVICE_CONFIG(_config)
42
43#define MDRV_ADC0831_REMOVE(_tag) \
44   MDRV_DEVICE_REMOVE(_tag)
45
46#define MDRV_ADC0832_ADD(_tag, _config) \
47   MDRV_DEVICE_ADD(_tag, ADC0832, 0) \
48   MDRV_DEVICE_CONFIG(_config)
49
50#define MDRV_ADC0832_REMOVE(_tag) \
51   MDRV_DEVICE_REMOVE(_tag)
52
53#define MDRV_ADC0834_ADD(_tag, _config) \
54   MDRV_DEVICE_ADD(_tag, ADC0834, 0) \
55   MDRV_DEVICE_CONFIG(_config)
56
57#define MDRV_ADC0834_REMOVE(_tag) \
58   MDRV_DEVICE_REMOVE(_tag)
59
60#define MDRV_ADC0838_ADD(_tag, _config) \
61   MDRV_DEVICE_ADD(_tag, ADC0838, 0) \
62   MDRV_DEVICE_CONFIG(_config)
63
64#define MDRV_ADC0838_REMOVE(_tag) \
65   MDRV_DEVICE_REMOVE(_tag)
66
67
68/***************************************************************************
69    TYPE DEFINITIONS
70***************************************************************************/
71
72typedef double (*adc083x_input_convert_func)(const device_config *device, UINT8 input);
73
74typedef struct _adc0831_interface adc0831_interface;
75struct _adc0831_interface
76{
77   adc083x_input_convert_func input_callback_r;
78};
79
80
81/***************************************************************************
82    PROTOTYPES
83***************************************************************************/
84
85/* device interface */
86DEVICE_GET_INFO( adc0831 );
87DEVICE_GET_INFO( adc0832 );
88DEVICE_GET_INFO( adc0834 );
89DEVICE_GET_INFO( adc0838 );
90
91extern WRITE8_DEVICE_HANDLER( adc083x_cs_write );
92extern WRITE8_DEVICE_HANDLER( adc083x_clk_write );
93extern WRITE8_DEVICE_HANDLER( adc083x_di_write );
94extern WRITE8_DEVICE_HANDLER( adc083x_se_write );
95extern READ8_DEVICE_HANDLER( adc083x_sars_read );
96extern READ8_DEVICE_HANDLER( adc083x_do_read );
97
98#endif   /* __ADC083X_H__ */
src/emu/machine/mb3773.c
r4939r4940
1/*
2 * mb3773 - Power Supply Monitor with Watch Dog Timer
3 *
4 * Todo:
5 *  Calculate the timeout from parameters.
6 *
7 */
1/***************************************************************************
82
3    Fujitsu MB3773
4
5    Power Supply Monitor with Watch Dog Timer (i.e. Reset IC)
6
7
8    Todo:
9        Calculate the timeout from parameters.
10
11
12    2009-06 Converted to be a device
13
14***************************************************************************/
15
916#include "driver.h"
10#include "machine/mb3773.h"
17#include "mb3773.h"
1118
12static emu_timer *watchdog_timer;
13static UINT8 ck = 0;
19/***************************************************************************
20    TYPE DEFINITIONS
21***************************************************************************/
1422
23typedef struct _mb3773_state mb3773_state;
24struct _mb3773_state
25{
26   emu_timer *watchdog_timer;
27   UINT8 ck;
28};
29
30/***************************************************************************
31    INLINE FUNCTIONS
32***************************************************************************/
33
34INLINE mb3773_state *get_safe_token(const device_config *device)
35{
36   assert(device != NULL);
37   assert(device->token != NULL);
38   assert((device->type == MB3773));
39   return (mb3773_state *)device->token;
40}
41
42/***************************************************************************
43    IMPLEMENTATION
44***************************************************************************/
45
46/*-------------------------------------------------
47    TIMER_CALLBACK( watchdog_timeout )
48-------------------------------------------------*/
49
1550static TIMER_CALLBACK( watchdog_timeout )
1651{
1752   mame_schedule_soft_reset(machine);
1853}
1954
20static void reset_timer( void )
55/*-------------------------------------------------
56    reset_timer
57-------------------------------------------------*/
58
59static void reset_timer( const device_config *device )
2160{
22   timer_adjust_oneshot( watchdog_timer, ATTOTIME_IN_SEC( 5 ), 0 );
61   mb3773_state *mb3773 = get_safe_token(device);
62   timer_adjust_oneshot(mb3773->watchdog_timer, ATTOTIME_IN_SEC( 5 ), 0);
2363}
2464
25void mb3773_set_ck( UINT8 new_ck )
65/*-------------------------------------------------
66    mb3773_set_ck
67-------------------------------------------------*/
68
69WRITE8_DEVICE_HANDLER( mb3773_set_ck )
2670{
27   if( new_ck == 0 && ck != 0 )
71   mb3773_state *mb3773 = get_safe_token(device);
72   if( data == 0 && mb3773->ck != 0 )
2873   {
29      reset_timer();
74      reset_timer(device);
3075   }
31   ck = new_ck;
76   mb3773->ck = data;
3277}
3378
34void mb3773_init( running_machine *machine )
79/*-------------------------------------------------
80    DEVICE_START( mb3773 )
81-------------------------------------------------*/
82
83static DEVICE_START( mb3773 )
3584{
36   watchdog_timer = timer_alloc(machine, watchdog_timeout, NULL);
37   reset_timer();
38   state_save_register_global(machine,  ck );
85   mb3773_state *mb3773 = get_safe_token(device);
86
87   /* create the timer */
88   mb3773->watchdog_timer = timer_alloc(device->machine, watchdog_timeout, NULL);
89   reset_timer(device);
90
91   /* register for state saving */
92   state_save_register_device_item(device, 0, mb3773->ck);
3993}
94
95/*-------------------------------------------------
96    DEVICE_RESET( mb3773 )
97-------------------------------------------------*/
98
99static DEVICE_RESET( mb3773 )
100{
101   mb3773_state *mb3773 = get_safe_token(device);
102   mb3773->ck = 0;
103}
104
105/*-------------------------------------------------
106    DEVICE_GET_INFO( mb3773 )
107-------------------------------------------------*/
108
109static const char *DEVTEMPLATE_SOURCE = __FILE__;
110
111#define DEVTEMPLATE_ID(p,s)      p##mb3773##s
112#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
113#define DEVTEMPLATE_NAME      "Fujistu MB3773"
114#define DEVTEMPLATE_FAMILY      "Fujistu Power Supply Monitor"
115#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
116#include "devtempl.h"
src/emu/machine/mb3773.h
r4939r4940
1/*
2 * mb3773 - Power Supply Monitor with Watch Dog Timer
3 *
4 */
1/***************************************************************************
52
6#if !defined( MB3773_H )
7#define MB3773_H ( 1 )
3    Fujistu MB3773
84
9extern void mb3773_set_ck( UINT8 new_ck );
10extern void mb3773_init( running_machine *machine );
5    Power Supply Monitor with Watch Dog Timer (i.e. Reset IC)
116
12#endif
7***************************************************************************/
8
9#ifndef __MB3773_H__
10#define __MB3773_H__
11
12
13/***************************************************************************
14    MACROS / CONSTANTS
15***************************************************************************/
16
17#define MB3773      DEVICE_GET_INFO_NAME(mb3773)
18
19#define MDRV_MB3773_ADD(_tag) \
20   MDRV_DEVICE_ADD(_tag, MB3773, 0)
21
22#define MDRV_MB3773_REMOVE(_tag) \
23   MDRV_DEVICE_REMOVE(_tag)
24
25
26/***************************************************************************
27    PROTOTYPES
28***************************************************************************/
29
30/* device interface */
31DEVICE_GET_INFO( mb3773 );
32
33extern WRITE8_DEVICE_HANDLER( mb3773_set_ck );
34
35#endif   /* __MB3773_H__ */
src/emu/machine/upd4701.c
r4939r4940
1/*
2 * uPD4701
3 *
4 * Incremental Encoder Control
5 *
6 */
1/***************************************************************************
72
3    NEC uPD4701
4
5    Incremental Encoder Control
6
7    2009-06 Converted to be a device
8
9***************************************************************************/
10
811#include "driver.h"
9#include "machine/upd4701.h"
12#include "upd4701.h"
1013
11struct uPD4701_chip
14/***************************************************************************
15    TYPE DEFINITIONS
16***************************************************************************/
17
18typedef struct _upd4701_state upd4701_state;
19struct _upd4701_state
1220{
1321   int cs;
1422   int xy;
r4939r4940
2634   int cf;
2735};
2836
29static struct uPD4701_chip uPD4701[ UPD4701_MAXCHIP ];
37/* x,y increments can be 12bit (see MASK_COUNTER), hence we need a couple of
3816bit handlers in the following  */
3039
3140#define MASK_SWITCHES ( 7 )
3241#define MASK_COUNTER ( 0xfff )
3342
34void uPD4701_init( running_machine *machine, int chip )
35{
36   struct uPD4701_chip *c;
3743
38   if( chip < 0 || chip >= UPD4701_MAXCHIP )
39   {
40      logerror( "uPD4701_init( machine, %d ) invalid chip\n", chip );
41      return;
42   }
44/***************************************************************************
45    INLINE FUNCTIONS
46***************************************************************************/
4347
44   c = &uPD4701[ chip ];
45
46   c->cs = 1;
47   c->xy = 0;
48   c->ul = 0;
49   c->resetx = 0;
50   c->resety = 0;
51   c->latchx = 0;
52   c->latchy = 0;
53   c->startx = 0;
54   c->starty = 0;
55   c->x = 0;
56   c->y = 0;
57   c->switches = 0;
58   c->latchswitches = 0;
59   c->cf = 1;
60
61   state_save_register_item( machine, "uPD4701", NULL, chip, c->cs );
62   state_save_register_item( machine, "uPD4701", NULL, chip, c->xy );
63   state_save_register_item( machine, "uPD4701", NULL, chip, c->ul );
64   state_save_register_item( machine, "uPD4701", NULL, chip, c->resetx );
65   state_save_register_item( machine, "uPD4701", NULL, chip, c->resety );
66   state_save_register_item( machine, "uPD4701", NULL, chip, c->latchx );
67   state_save_register_item( machine, "uPD4701", NULL, chip, c->latchy );
68   state_save_register_item( machine, "uPD4701", NULL, chip, c->startx );
69   state_save_register_item( machine, "uPD4701", NULL, chip, c->starty );
70   state_save_register_item( machine, "uPD4701", NULL, chip, c->x );
71   state_save_register_item( machine, "uPD4701", NULL, chip, c->y );
72   state_save_register_item( machine, "uPD4701", NULL, chip, c->switches );
73   state_save_register_item( machine, "uPD4701", NULL, chip, c->latchswitches );
74   state_save_register_item( machine, "uPD4701", NULL, chip, c->cf );
48INLINE upd4701_state *get_safe_token(const device_config *device)
49{
50   assert(device != NULL);
51   assert(device->token != NULL);
52   assert((device->type == UPD4701));
53   return (upd4701_state *)device->token;
7554}
7655
77void uPD4701_ul_w( int chip, int ul )
78{
79   struct uPD4701_chip *c;
8056
81   if( chip < 0 || chip >= UPD4701_MAXCHIP )
82   {
83      logerror( "uPD4701_ul_w( %d ) invalid chip\n", chip );
84      return;
85   }
57/***************************************************************************
58    IMPLEMENTATION
59***************************************************************************/
8660
87   c = &uPD4701[ chip ];
88   c->ul = ul;
89}
61/*-------------------------------------------------
62    upd4701_ul_w
63-------------------------------------------------*/
9064
91void uPD4701_xy_w( int chip, int xy )
65WRITE8_DEVICE_HANDLER( upd4701_ul_w )
9266{
93   struct uPD4701_chip *c;
67   upd4701_state *upd4701 = get_safe_token(device);
68   upd4701->ul = data;
69}
9470
95   if( chip < 0 || chip >= UPD4701_MAXCHIP )
96   {
97      logerror( "uPD4701_xy_w( %d ) invalid chip\n", chip );
98      return;
99   }
71/*-------------------------------------------------
72    upd4701_xy_w
73-------------------------------------------------*/
10074
101   c = &uPD4701[ chip ];
102   c->xy = xy;
75WRITE8_DEVICE_HANDLER( upd4701_xy_w )
76{
77   upd4701_state *upd4701 = get_safe_token(device);
78   upd4701->xy = data;
10379}
10480
105void uPD4701_cs_w( int chip, int cs )
81/*-------------------------------------------------
82    upd4701_cs_w
83-------------------------------------------------*/
84
85WRITE8_DEVICE_HANDLER( upd4701_cs_w )
10686{
107   struct uPD4701_chip *c;
87   upd4701_state *upd4701 = get_safe_token(device);
10888
109   if( chip < 0 || chip >= UPD4701_MAXCHIP )
89   if (data != upd4701->cs)
11090   {
111      logerror( "uPD4701_cs_w( %d ) invalid chip\n", chip );
112      return;
113   }
91      upd4701->cs = data;
11492
115   c = &uPD4701[ chip ];
116   if( cs != c->cs )
117   {
118      c->cs = cs;
119
120      if( !c->cs )
93      if (!upd4701->cs)
12194      {
122         c->latchx = ( c->x - c->startx ) & MASK_COUNTER;
123         c->latchy = ( c->y - c->starty ) & MASK_COUNTER;
95         upd4701->latchx = (upd4701->x - upd4701->startx) & MASK_COUNTER;
96         upd4701->latchy = (upd4701->y - upd4701->starty) & MASK_COUNTER;
12497
125         c->latchswitches = ( ~c->switches ) & MASK_SWITCHES;
126         if( c->latchswitches != 0 )
98         upd4701->latchswitches = (~upd4701->switches) & MASK_SWITCHES;
99         if (upd4701->latchswitches != 0)
127100         {
128            c->latchswitches |= 8;
101            upd4701->latchswitches |= 8;
129102         }
130103
131         c->cf = 1;
104         upd4701->cf = 1;
132105      }
133106   }
134107}
135108
136void uPD4701_resetx_w( int chip, int resetx )
109/*-------------------------------------------------
110    upd4701_resetx_w
111-------------------------------------------------*/
112
113WRITE8_DEVICE_HANDLER( upd4701_resetx_w )
137114{
138   struct uPD4701_chip *c;
115   upd4701_state *upd4701 = get_safe_token(device);
139116
140   if( chip < 0 || chip >= UPD4701_MAXCHIP )
117   if (upd4701->resetx != data)
141118   {
142      logerror( "uPD4701_resetx_w( %d ) invalid chip\n", chip );
143      return;
119      upd4701->resetx = data;
120
121      if (upd4701->resetx)
122      {
123         upd4701->startx = upd4701->x;
124      }
144125   }
126}
145127
146   c = &uPD4701[ chip ];
147   if( c->resetx != resetx )
128/*-------------------------------------------------
129    upd4701_resety_w
130-------------------------------------------------*/
131
132WRITE8_DEVICE_HANDLER( upd4701_resety_w )
133{
134   upd4701_state *upd4701 = get_safe_token(device);
135
136   if (upd4701->resety != data)
148137   {
149      c->resetx = resetx;
138      upd4701->resety = data;
150139
151      if( c->resetx )
140      if (upd4701->resety)
152141      {
153         c->startx = c->x;
142         upd4701->starty = upd4701->y;
154143      }
155144   }
156145}
157146
158void uPD4701_resety_w( int chip, int resety )
147/*-------------------------------------------------
148    upd4701_x_add
149-------------------------------------------------*/
150
151WRITE16_DEVICE_HANDLER( upd4701_x_add )
159152{
160   struct uPD4701_chip *c;
153   upd4701_state *upd4701 = get_safe_token(device);
161154
162   if( chip < 0 || chip >= UPD4701_MAXCHIP )
155   if (!upd4701->resetx && data != 0)
163156   {
164      logerror( "uPD4701_resety_w( %d ) invalid chip\n", chip );
165      return;
157      upd4701->x += data;
158
159      if (upd4701->cs)
160      {
161         upd4701->cf = 0;
162      }
166163   }
164}
167165
168   c = &uPD4701[ chip ];
169   if( c->resety != resety )
166/*-------------------------------------------------
167    upd4701_y_add
168-------------------------------------------------*/
169
170WRITE16_DEVICE_HANDLER( upd4701_y_add )
171{
172   upd4701_state *upd4701 = get_safe_token(device);
173
174   if (!upd4701->resety && data != 0)
170175   {
171      c->resety = resety;
176      upd4701->y += data;
172177
173      if( c->resety )
178      if (upd4701->cs)
174179      {
175         c->starty = c->y;
180         upd4701->cf = 0;
176181      }
177182   }
178183}
179184
180int uPD4701_d_r( int chip )
185/*-------------------------------------------------
186    upd4701_switches_set
187-------------------------------------------------*/
188
189WRITE8_DEVICE_HANDLER( upd4701_switches_set )
181190{
191   upd4701_state *upd4701 = get_safe_token(device);
192   upd4701->switches = data;
193}
194
195/*-------------------------------------------------
196    upd4701_d_r
197-------------------------------------------------*/
198
199READ16_DEVICE_HANDLER( upd4701_d_r )
200{
201   upd4701_state *upd4701 = get_safe_token(device);
182202   int data;
183   struct uPD4701_chip *c;
184203
185   if( chip < 0 || chip >= UPD4701_MAXCHIP )
204   if (upd4701->cs)
186205   {
187      logerror( "uPD4701_d_r( %d ) invalid chip\n", chip );
188      return 0;
189   }
190
191   c = &uPD4701[ chip ];
192   if( c->cs )
193   {
194206      return 0xff;
195207   }
196208
197   if( c->xy )
209   if (upd4701->xy)
198210   {
199      data = c->latchy;
211      data = upd4701->latchy;
200212   }
201213   else
202214   {
203      data = c->latchx;
215      data = upd4701->latchx;
204216   }
205217
206   data |= c->latchswitches << 12;
218   data |= upd4701->latchswitches << 12;
207219
208   if( c->ul )
220   if (upd4701->ul)
209221   {
210222      return data >> 8;
211223   }
r4939r4940
215227   }
216228}
217229
218int uPD4701_sf_r( int chip )
230/*-------------------------------------------------
231    upd4701_sf_r
232-------------------------------------------------*/
233
234READ8_DEVICE_HANDLER( upd4701_sf_r )
219235{
220   struct uPD4701_chip *c;
236   upd4701_state *upd4701 = get_safe_token(device);
221237
222   if( chip < 0 || chip >= UPD4701_MAXCHIP )
238   if ((upd4701->switches & MASK_SWITCHES) != MASK_SWITCHES)
223239   {
224      logerror( "uPD4701_sf_r( %d ) invalid chip\n", chip );
225240      return 0;
226241   }
227242
228   c = &uPD4701[ chip ];
229   if( ( c->switches & MASK_SWITCHES ) != MASK_SWITCHES )
230   {
231      return 0;
232   }
233
234243   return 1;
235244}
236245
237int uPD4701_cf_r( int chip )
246/*-------------------------------------------------
247    upd4701_cf_r
248-------------------------------------------------*/
249
250READ8_DEVICE_HANDLER( upd4701_cf_r )
238251{
239   struct uPD4701_chip *c;
252   upd4701_state *upd4701 = get_safe_token(device);
253   return upd4701->cf;
254}
240255
241   if( chip < 0 || chip >= UPD4701_MAXCHIP )
242   {
243      logerror( "uPD4701_cf_r( %d ) invalid chip\n", chip );
244      return 0;
245   }
256/*-------------------------------------------------
257    DEVICE_START( upd4701 )
258-------------------------------------------------*/
246259
247   c = &uPD4701[ chip ];
248   return c->cf;
249}
250
251void uPD4701_x_add( int chip, int dx )
260static DEVICE_START( upd4701 )
252261{
253   struct uPD4701_chip *c;
262   upd4701_state *upd4701 = get_safe_token(device);
254263
255   if( chip < 0 || chip >= UPD4701_MAXCHIP )
256   {
257      logerror( "uPD4701_x_add( %d ) invalid chip\n", chip );
258      return;
259   }
264   /* register for state saving */
265   state_save_register_device_item(device, 0, upd4701->cs);
266   state_save_register_device_item(device, 0, upd4701->xy);
267   state_save_register_device_item(device, 0, upd4701->ul);
268   state_save_register_device_item(device, 0, upd4701->resetx);
269   state_save_register_device_item(device, 0, upd4701->resety);
270   state_save_register_device_item(device, 0, upd4701->latchx);
271   state_save_register_device_item(device, 0, upd4701->latchy);
272   state_save_register_device_item(device, 0, upd4701->startx);
273   state_save_register_device_item(device, 0, upd4701->starty);
274   state_save_register_device_item(device, 0, upd4701->x);
275   state_save_register_device_item(device, 0, upd4701->y);
276   state_save_register_device_item(device, 0, upd4701->switches);
277   state_save_register_device_item(device, 0, upd4701->latchswitches);
278   state_save_register_device_item(device, 0, upd4701->cf);
279}
260280
261   c = &uPD4701[ chip ];
262   if( !c->resetx && dx != 0 )
263   {
264      c->x += dx;
281/*-------------------------------------------------
282    DEVICE_RESET( upd4701 )
283-------------------------------------------------*/
265284
266      if( c->cs )
267      {
268         c->cf = 0;
269      }
270   }
271}
272
273void uPD4701_y_add( int chip, int dy )
285static DEVICE_RESET( upd4701 )
274286{
275   struct uPD4701_chip *c;
287   upd4701_state *upd4701 = get_safe_token(device);
276288
277   if( chip < 0 || chip >= UPD4701_MAXCHIP )
278   {
279      logerror( "uPD4701_y_add( %d ) invalid chip\n", chip );
280      return;
281   }
282
283   c = &uPD4701[ chip ];
284   if( !c->resety && dy != 0 )
285   {
286      c->y += dy;
287
288      if( c->cs )
289      {
290         c->cf = 0;
291      }
292   }
289   upd4701->cs = 1;
290   upd4701->xy = 0;
291   upd4701->ul = 0;
292   upd4701->resetx = 0;
293   upd4701->resety = 0;
294   upd4701->latchx = 0;
295   upd4701->latchy = 0;
296   upd4701->startx = 0;
297   upd4701->starty = 0;
298   upd4701->x = 0;
299   upd4701->y = 0;
300   upd4701->switches = 0;
301   upd4701->latchswitches = 0;
302   upd4701->cf = 1;
293303}
294304
295void uPD4701_switches_set( int chip, int switches )
296{
297   struct uPD4701_chip *c;
305/*-------------------------------------------------
306    device definition
307-------------------------------------------------*/
298308
299   if( chip < 0 || chip >= UPD4701_MAXCHIP )
300   {
301      logerror( "uPD4701_switches_set( %d ) invalid chip\n", chip );
302      return;
303   }
309static const char *DEVTEMPLATE_SOURCE = __FILE__;
304310
305   c = &uPD4701[ chip ];
306   c->switches = switches;
307}
311#define DEVTEMPLATE_ID(p,s)      p##upd4701##s
312#define DEVTEMPLATE_FEATURES   DT_HAS_START | DT_HAS_RESET
313#define DEVTEMPLATE_NAME      "NEC uPD4701 Encoder"
314#define DEVTEMPLATE_FAMILY      "NEC uPD4701 Encoder"
315#define DEVTEMPLATE_CLASS      DEVICE_CLASS_PERIPHERAL
316#include "devtempl.h"
src/emu/machine/upd4701.h
r4939r4940
1/*
2 * uPD4701
3 *
4 * Incremental Encoder Control
5 *
6 */
1/***************************************************************************
72
8#if !defined( UPD4701_H )
3   NEC uPD4701
94
10#define UPD4701_MAXCHIP ( 1 )
5    Incremental Encoder Control
116
12extern void uPD4701_init( running_machine *machine, int chip );
13extern void uPD4701_cs_w( int chip, int cs );
14extern void uPD4701_xy_w( int chip, int xy );
15extern void uPD4701_ul_w( int chip, int ul );
16extern void uPD4701_resetx_w( int chip, int resetx );
17extern void uPD4701_resety_w( int chip, int resety );
18extern int uPD4701_d_r( int chip );
19extern int uPD4701_cf_r( int chip );
20extern int uPD4701_sf_r( int chip );
7***************************************************************************/
218
22extern void uPD4701_x_add( int chip, int dx );
23extern void uPD4701_y_add( int chip, int dy );
24extern void uPD4701_switches_set( int chip, int switches );
9#ifndef __UPD4701_H__
10#define __UPD4701_H__
2511
26#define UPD4701_H
27#endif
12/***************************************************************************
13    MACROS / CONSTANTS
14***************************************************************************/
15
16#define UPD4701      DEVICE_GET_INFO_NAME(upd4701)
17
18#define MDRV_UPD4701_ADD(_tag) \
19   MDRV_DEVICE_ADD(_tag, UPD4701, 0)
20
21#define MDRV_UPD4701_REMOVE(_tag) \
22   MDRV_DEVICE_REMOVE(_tag)
23
24
25/***************************************************************************
26    PROTOTYPES
27***************************************************************************/
28
29/* device interface */
30DEVICE_GET_INFO( upd4701 );
31
32extern WRITE8_DEVICE_HANDLER( upd4701_cs_w );
33extern WRITE8_DEVICE_HANDLER( upd4701_xy_w );
34extern WRITE8_DEVICE_HANDLER( upd4701_ul_w );
35extern WRITE8_DEVICE_HANDLER( upd4701_resetx_w );
36extern WRITE8_DEVICE_HANDLER( upd4701_resety_w );
37extern WRITE16_DEVICE_HANDLER( upd4701_x_add );
38extern WRITE16_DEVICE_HANDLER( upd4701_y_add );
39extern WRITE8_DEVICE_HANDLER( upd4701_switches_set );
40
41extern READ16_DEVICE_HANDLER( upd4701_d_r );
42extern READ8_DEVICE_HANDLER( upd4701_cf_r );
43extern READ8_DEVICE_HANDLER( upd4701_sf_r );
44
45
46#endif   /* __UPD4701_H__ */
src/emu/devintrf.h
r4939r4940
120120#define DEVICE_EXECUTE(name)      INT32 DEVICE_EXECUTE_NAME(name)(const device_config *device, INT32 clocks)
121121#define DEVICE_EXECUTE_CALL(name)   DEVICE_EXECUTE_NAME(name)(device, clocks)
122122
123#define DEVICE_NVRAM_NAME(name)      device_NVRAM_##name
123#define DEVICE_NVRAM_NAME(name)      device_nvram_##name
124124#define DEVICE_NVRAM(name)         void DEVICE_NVRAM_NAME(name)(const device_config *device, mame_file *file, int read_or_write)
125125#define DEVICE_NVRAM_CALL(name)      DEVICE_NVRAM_NAME(name)(device, file, read_or_write)
126126
src/emu/sound/digitalk.c
r4939r4940
418418   digitalker_write(dg, &wpos, vol, dac);
419419
420420   for(k=7; k >= 0; k--) {
421      int limit = k ? 0 : 1;
421422      bits = (bits << 8) | (k ? dg->rom[dg->apos+k] : 0x80);
422      for(l=3; l>=0; l--) {
423      for(l=3; l>=limit; l--) {
423424         dac -= delta1[(bits >> (6+2*l)) & 15];
424425         digitalker_write(dg, &wpos, vol, dac);
425426      }
r4939r4940
428429   digitalker_write(dg, &wpos, vol, dac);
429430
430431   for(k=1; k != 9; k++) {
432      int start = k == 1 ? 1 : 0;
431433      bits |= dg->rom[dg->apos+k] << 8;
432      for(l=0; l<4; l++) {
434      for(l=start; l<4; l++) {
433435         dac += delta1[(bits >> (6+2*l)) & 15];
434436         digitalker_write(dg, &wpos, vol, dac);
435437      }
r4939r4940
439441   digitalker_write(dg, &wpos, vol, dac);
440442
441443   for(k=7; k >= 0; k--) {
444      int limit = k ? 0 : 1;
442445      bits = (bits << 8) | (k ? dg->rom[dg->apos+k] : 0x80);
443      for(l=3; l>=0; l--) {
446      for(l=3; l>=limit; l--) {
444447         dac -= delta1[(bits >> (6+2*l)) & 15];
445448         digitalker_write(dg, &wpos, vol, dac);
446449      }
src/mess/messdriv.c
r4939r4940
210210    DRIVER( pasogo )    /* KOEI PasoGo                                      */
211211
212212    /* SNK */
213    DRIVER( ngp )       /* NeoGeo Pocket                                    */
214    DRIVER( ngpc )      /* NeoGeo Pocket Color                              */
215    DRIVER( aes )       /* NeoGeo AES                                       */
216    DRIVER( neocd )     /* NeoGeo CD                                        */
217    DRIVER( neocdz )    /* NeoGeo CDZ                                       */
213//0131u4    DRIVER( ngp )       /* NeoGeo Pocket                                    */
214//0131u4    DRIVER( ngpc )      /* NeoGeo Pocket Color                              */
215//0131u4    DRIVER( aes )       /* NeoGeo AES                                       */
216//0131u4    DRIVER( neocd )     /* NeoGeo CD                                        */
217//0131u4    DRIVER( neocdz )    /* NeoGeo CDZ                                       */
218218
219219    /* Philips */
220220    DRIVER( cdi )       /* Philips CD-i                                     */
src/mess/mess.mak
r4939r4940
314314   $(MESSOBJ)/necpc.a \
315315   $(MESSOBJ)/nintendo.a \
316316   $(MESSOBJ)/nokia.a \
317   $(MESSOBJ)/olivetti.a \
317318   $(MESSOBJ)/ondra.a \
318   $(MESSOBJ)/olivetti.a \
319319   $(MESSOBJ)/orion.a \
320320   $(MESSOBJ)/osborne.a \
321321   $(MESSOBJ)/osi.a \
r4939r4940
323323   $(MESSOBJ)/palm.a \
324324   $(MESSOBJ)/pasogo.a \
325325   $(MESSOBJ)/pc.a \
326   $(MESSOBJ)/pc8401a.a \
326327   $(MESSOBJ)/pcm.a \
327328   $(MESSOBJ)/pcshare.a \
328   $(MESSOBJ)/pc8401a.a \
329329   $(MESSOBJ)/pdp1.a \
330330   $(MESSOBJ)/pel.a \
331331   $(MESSOBJ)/pk8020.a \
r4939r4940
345345   $(MESSOBJ)/sharp.a \
346346   $(MESSOBJ)/sinclair.a \
347347   $(MESSOBJ)/skeleton.a \
348   $(MESSOBJ)/snk.a \
349348   $(MESSOBJ)/sony.a \
350349   $(MESSOBJ)/sord.a \
351350   $(MESSOBJ)/special.a \
r4939r4940
372371   $(MESSOBJ)/vector06.a \
373372   $(MESSOBJ)/votrax.a \
374373   $(MESSOBJ)/vtech.a \
374   $(MESSOBJ)/xerox.a \
375375   $(MESSOBJ)/z80ne.a \
376   $(MESSOBJ)/xerox.a \
377376   $(MESSOBJ)/shared.a \
378377
378#   $(MESSOBJ)/snk.a \
379379
380380
381381
docs/messnew.txt
r4939r4940
189189
190190- [SYM1] Added BASIC and Assembler ROM's, and version 1.0 monitor [Miodrag Milanovic]
191191
192
193
192194User Interface Changes:
193195-----------------------
194196(none)
r4939r4940
203205
204206Source Changes:
205207----------------
206- The core is based on MAME 0.131u3.  This incorporates all features of the
208- The core is based on MAME 0.131u4.  This incorporates all features of the
207209  update to this core.  [MAME team]
208210
209211- Converted the WAVE sound device to stereo. [Curt Coder]
r4939r4940
215217  devices which could have been connected to the real thing. [Fabio Priuli]
216218
217219
220
2182210.131
219222
220223New System Drivers Supported (in no particular order):

Previous 15994 Revisions Next


© 1998-2018 The MESS Team