trunk/src/mame/drivers/csplayh5.c
| r24080 | r24081 | |
| 31 | 31 | public: |
| 32 | 32 | csplayh5_state(const machine_config &mconfig, device_type type, const char *tag) |
| 33 | 33 | : driver_device(mconfig, type, tag), |
| 34 | | m_maincpu(*this,"maincpu"), |
| 35 | | m_v9958(*this,"v9958"), |
| 34 | m_maincpu(*this, "maincpu"), |
| 35 | m_tmp68301(*this, "tmp68301"), |
| 36 | m_v9958(*this, "v9958"), |
| 36 | 37 | m_dac1(*this, "dac1"), |
| 37 | 38 | m_dac2(*this, "dac2") |
| 38 | 39 | { } |
| r24080 | r24081 | |
| 42 | 43 | UINT8 m_pio_latch[5]; |
| 43 | 44 | |
| 44 | 45 | required_device<cpu_device> m_maincpu; |
| 46 | required_device<tmp68301_device> m_tmp68301; |
| 45 | 47 | required_device<v9958_device> m_v9958; |
| 46 | 48 | DECLARE_READ16_MEMBER(csplayh5_mux_r); |
| 47 | 49 | DECLARE_WRITE16_MEMBER(csplayh5_mux_w); |
| r24080 | r24081 | |
| 144 | 146 | |
| 145 | 147 | AM_RANGE(0xc00000, 0xc7ffff) AM_RAM AM_SHARE("nvram") AM_MIRROR(0x380000) // work RAM |
| 146 | 148 | |
| 147 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 149 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 148 | 150 | ADDRESS_MAP_END |
| 149 | 151 | |
| 150 | 152 | #if USE_H8 |
| r24080 | r24081 | |
| 629 | 631 | MCFG_CPU_ADD("maincpu",M68000,16000000) /* TMP68301-16 */ |
| 630 | 632 | MCFG_CPU_PROGRAM_MAP(csplayh5_map) |
| 631 | 633 | MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", csplayh5_state, csplayh5_irq, "screen", 0, 1) |
| 634 | |
| 635 | MCFG_TMP68301_ADD("tmp68301") |
| 632 | 636 | |
| 633 | 637 | #if USE_H8 |
| 634 | 638 | MCFG_CPU_ADD("subcpu", H83002, 16000000) /* unknown clock */ |
trunk/src/mame/drivers/seta2.c
| r24080 | r24081 | |
| 109 | 109 | #include "emu.h" |
| 110 | 110 | #include "includes/seta2.h" |
| 111 | 111 | #include "cpu/m68000/m68000.h" |
| 112 | | #include "machine/tmp68301.h" |
| 113 | 112 | #include "cpu/h83002/h8.h" |
| 114 | 113 | #include "sound/okim9810.h" |
| 115 | 114 | #include "machine/eeprom.h" |
| r24080 | r24081 | |
| 173 | 172 | AM_RANGE(0xc50000, 0xc5ffff) AM_RAM // cleared |
| 174 | 173 | AM_RANGE(0xc60000, 0xc6003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") // Video Registers |
| 175 | 174 | AM_RANGE(0xe00010, 0xe0001f) AM_WRITE(seta2_sound_bank_w) // Samples Banks |
| 176 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 175 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 177 | 176 | ADDRESS_MAP_END |
| 178 | 177 | |
| 179 | 178 | /*************************************************************************** |
| r24080 | r24081 | |
| 212 | 211 | AM_RANGE(0xc60000, 0xc6003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") // Video Registers |
| 213 | 212 | AM_RANGE(0xe00010, 0xe0001f) AM_WRITE(seta2_sound_bank_w) // Samples Banks |
| 214 | 213 | AM_RANGE(0xfffd0a, 0xfffd0b) AM_READWRITE(gundamex_eeprom_r,gundamex_eeprom_w) // parallel data register |
| 215 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 214 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 216 | 215 | ADDRESS_MAP_END |
| 217 | 216 | |
| 218 | 217 | |
| r24080 | r24081 | |
| 268 | 267 | AM_RANGE(0xc00000, 0xc3ffff) AM_RAM AM_SHARE("spriteram") // Sprites |
| 269 | 268 | AM_RANGE(0xc40000, 0xc4ffff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_word_w) AM_SHARE("paletteram") // Palette |
| 270 | 269 | AM_RANGE(0xc60000, 0xc6003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") // Video Registers |
| 271 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 270 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 272 | 271 | ADDRESS_MAP_END |
| 273 | 272 | |
| 274 | 273 | |
| r24080 | r24081 | |
| 291 | 290 | AM_RANGE(0xc00000, 0xc3ffff) AM_RAM AM_SHARE("spriteram") // Sprites |
| 292 | 291 | AM_RANGE(0xc40000, 0xc4ffff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_word_w) AM_SHARE("paletteram") // Palette |
| 293 | 292 | AM_RANGE(0xc60000, 0xc6003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") // Video Registers |
| 294 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 293 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 295 | 294 | ADDRESS_MAP_END |
| 296 | 295 | |
| 297 | 296 | |
| r24080 | r24081 | |
| 314 | 313 | AM_RANGE(0xd00000, 0xd3ffff) AM_RAM AM_SHARE("spriteram") // Sprites |
| 315 | 314 | AM_RANGE(0xd40000, 0xd4ffff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_word_w) AM_SHARE("paletteram") // Palette |
| 316 | 315 | AM_RANGE(0xd60000, 0xd6003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") // Video Registers |
| 317 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 316 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 318 | 317 | ADDRESS_MAP_END |
| 319 | 318 | |
| 320 | 319 | |
| r24080 | r24081 | |
| 359 | 358 | AM_RANGE(0x840000, 0x84ffff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_word_w) AM_SHARE("paletteram") // Palette |
| 360 | 359 | AM_RANGE(0x860000, 0x86003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") // Video Registers |
| 361 | 360 | AM_RANGE(0x900000, 0x903fff) AM_DEVREADWRITE("x1snd", x1_010_device, word_r, word_w) // Sound |
| 362 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 361 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 363 | 362 | ADDRESS_MAP_END |
| 364 | 363 | |
| 365 | 364 | |
| r24080 | r24081 | |
| 385 | 384 | AM_RANGE(0xb40000, 0xb4ffff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_word_w) AM_SHARE("paletteram") // Palette |
| 386 | 385 | AM_RANGE(0xb60000, 0xb6003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") |
| 387 | 386 | AM_RANGE(0xa00000, 0xa03fff) AM_DEVREADWRITE("x1snd", x1_010_device, word_r, word_w) // Sound |
| 388 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 387 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 389 | 388 | ADDRESS_MAP_END |
| 390 | 389 | |
| 391 | 390 | |
| r24080 | r24081 | |
| 444 | 443 | AM_RANGE(0xc40000, 0xc4ffff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_word_w) AM_SHARE("paletteram") // Palette |
| 445 | 444 | AM_RANGE(0xc60000, 0xc6003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") // Video Registers |
| 446 | 445 | AM_RANGE(0xfffd0a, 0xfffd0b) AM_WRITE(reelquak_leds_w ) // parallel data register (leds) |
| 447 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 446 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 448 | 447 | ADDRESS_MAP_END |
| 449 | 448 | |
| 450 | 449 | |
| r24080 | r24081 | |
| 458 | 457 | AM_RANGE(0x200000, 0x20ffff) AM_RAM // RAM |
| 459 | 458 | AM_RANGE(0xc00000, 0xc3ffff) AM_RAM AM_SHARE("spriteram") // Sprites |
| 460 | 459 | AM_RANGE(0xc60000, 0xc6003f) AM_WRITE(seta2_vregs_w) AM_SHARE("vregs") // Video Registers |
| 461 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 460 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 462 | 461 | ADDRESS_MAP_END |
| 463 | 462 | |
| 464 | 463 | |
| r24080 | r24081 | |
| 504 | 503 | AM_RANGE( 0x900000, 0x903fff ) AM_DEVREADWRITE("x1snd", x1_010_device, word_r, word_w) // Sound |
| 505 | 504 | |
| 506 | 505 | AM_RANGE( 0xfffd0a, 0xfffd0b ) AM_READ_PORT("DSW2") // parallel data register (DSW 2) |
| 507 | | AM_RANGE( 0xfffc00, 0xffffff ) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 506 | AM_RANGE( 0xfffc00, 0xffffff ) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 508 | 507 | ADDRESS_MAP_END |
| 509 | 508 | |
| 510 | 509 | |
| r24080 | r24081 | |
| 1978 | 1977 | INTERRUPT_GEN_MEMBER(seta2_state::seta2_interrupt) |
| 1979 | 1978 | { |
| 1980 | 1979 | /* VBlank is connected to INT0 (external interrupts pin 0) */ |
| 1981 | | tmp68301_external_interrupt_0(machine()); |
| 1980 | m_tmp68301->external_interrupt_0(); |
| 1982 | 1981 | } |
| 1983 | 1982 | |
| 1984 | 1983 | INTERRUPT_GEN_MEMBER(seta2_state::samshoot_interrupt) |
| 1985 | 1984 | { |
| 1986 | | tmp68301_external_interrupt_2(machine()); // to do: hook up x1-10 interrupts |
| 1985 | m_tmp68301->external_interrupt_2(); // to do: hook up x1-10 interrupts |
| 1987 | 1986 | } |
| 1988 | 1987 | |
| 1989 | 1988 | static const x1_010_interface x1_010_sound_intf = |
| r24080 | r24081 | |
| 1996 | 1995 | MCFG_CPU_PROGRAM_MAP(mj4simai_map) |
| 1997 | 1996 | MCFG_CPU_VBLANK_INT_DRIVER("screen", seta2_state, seta2_interrupt) |
| 1998 | 1997 | |
| 1999 | | MCFG_MACHINE_START( tmp68301 ) |
| 2000 | | MCFG_MACHINE_RESET( tmp68301 ) |
| 1998 | MCFG_TMP68301_ADD("tmp68301") |
| 1999 | |
| 2001 | 2000 | |
| 2002 | 2001 | // video hardware |
| 2003 | 2002 | MCFG_SCREEN_ADD("screen", RASTER) |
| r24080 | r24081 | |
| 2241 | 2240 | MCFG_CPU_PROGRAM_MAP(namcostr_map) |
| 2242 | 2241 | MCFG_CPU_VBLANK_INT_DRIVER("screen", seta2_state, seta2_interrupt) |
| 2243 | 2242 | |
| 2244 | | MCFG_MACHINE_START( tmp68301 ) |
| 2245 | | MCFG_MACHINE_RESET( tmp68301 ) |
| 2243 | MCFG_TMP68301_ADD("tmp68301") |
| 2244 | |
| 2246 | 2245 | |
| 2247 | 2246 | // video hardware |
| 2248 | 2247 | MCFG_SCREEN_ADD("screen", RASTER) |
trunk/src/mame/drivers/realbrk.c
| r24080 | r24081 | |
| 43 | 43 | |
| 44 | 44 | #include "emu.h" |
| 45 | 45 | #include "cpu/m68000/m68000.h" |
| 46 | | #include "machine/tmp68301.h" |
| 47 | 46 | #include "includes/realbrk.h" |
| 48 | 47 | #include "sound/2413intf.h" |
| 49 | 48 | #include "sound/ymz280b.h" |
| r24080 | r24081 | |
| 163 | 162 | AM_RANGE(0x605000, 0x61ffff) AM_RAM // |
| 164 | 163 | AM_RANGE(0x800000, 0x800003) AM_DEVREADWRITE8("ymz", ymz280b_device, read, write, 0xff00) // YMZ280 |
| 165 | 164 | AM_RANGE(0xfe0000, 0xfeffff) AM_RAM // RAM |
| 166 | | AM_RANGE(0xfffc00, 0xffffff) AM_READWRITE_LEGACY(tmp68301_regs_r, tmp68301_regs_w) // TMP68301 Registers |
| 165 | AM_RANGE(0xfffc00, 0xffffff) AM_DEVREADWRITE("tmp68301", tmp68301_device, regs_r, regs_w) // TMP68301 Registers |
| 167 | 166 | ADDRESS_MAP_END |
| 168 | 167 | |
| 169 | 168 | /*realbrk specific memory map*/ |
| r24080 | r24081 | |
| 749 | 748 | INTERRUPT_GEN_MEMBER(realbrk_state::realbrk_interrupt) |
| 750 | 749 | { |
| 751 | 750 | /* VBlank is connected to INT1 (external interrupts pin 1) */ |
| 752 | | tmp68301_external_interrupt_1(machine()); |
| 751 | m_tmp68301->external_interrupt_1(); |
| 753 | 752 | } |
| 754 | 753 | |
| 755 | 754 | static MACHINE_CONFIG_START( realbrk, realbrk_state ) |
| r24080 | r24081 | |
| 759 | 758 | MCFG_CPU_PROGRAM_MAP(realbrk_mem) |
| 760 | 759 | MCFG_CPU_VBLANK_INT_DRIVER("screen", realbrk_state, realbrk_interrupt) |
| 761 | 760 | |
| 762 | | MCFG_MACHINE_START( tmp68301 ) |
| 763 | | MCFG_MACHINE_RESET( tmp68301 ) |
| 764 | | |
| 761 | MCFG_TMP68301_ADD("tmp68301") |
| 762 | |
| 765 | 763 | /* video hardware */ |
| 766 | 764 | MCFG_SCREEN_ADD("screen", RASTER) |
| 767 | 765 | MCFG_SCREEN_REFRESH_RATE(60) |
trunk/src/emu/machine/tmp68301.c
| r24080 | r24081 | |
| 11 | 11 | #include "emu.h" |
| 12 | 12 | #include "machine/tmp68301.h" |
| 13 | 13 | |
| 14 | | static UINT16 tmp68301_regs[0x400]; |
| 14 | const device_type TMP68301 = &device_creator<tmp68301_device>; |
| 15 | 15 | |
| 16 | | static UINT8 tmp68301_IE[3]; // 3 External Interrupt Lines |
| 17 | | static emu_timer *tmp68301_timer[3]; // 3 Timers |
| 16 | tmp68301_device::tmp68301_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 17 | : device_t(mconfig, TMP68301, "TMP68301", tag, owner, clock, "tmp68301", __FILE__) |
| 18 | { |
| 19 | } |
| 18 | 20 | |
| 19 | | static int tmp68301_irq_vector[8]; |
| 21 | //------------------------------------------------- |
| 22 | // device_config_complete - perform any |
| 23 | // operations now that the configuration is |
| 24 | // complete |
| 25 | //------------------------------------------------- |
| 20 | 26 | |
| 21 | | static void tmp68301_update_timer( running_machine &machine, int i ); |
| 27 | void tmp68301_device::device_config_complete() |
| 28 | { |
| 29 | } |
| 22 | 30 | |
| 23 | | static IRQ_CALLBACK(tmp68301_irq_callback) |
| 31 | //------------------------------------------------- |
| 32 | // device_start - device-specific startup |
| 33 | //------------------------------------------------- |
| 34 | |
| 35 | void tmp68301_device::device_start() |
| 24 | 36 | { |
| 25 | | int vector = tmp68301_irq_vector[irqline]; |
| 37 | int i; |
| 38 | for (i = 0; i < 3; i++) |
| 39 | m_tmp68301_timer[i] = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(tmp68301_device::timer_callback), this)); |
| 40 | } |
| 41 | |
| 42 | //------------------------------------------------- |
| 43 | // device_reset - device-specific reset |
| 44 | //------------------------------------------------- |
| 45 | |
| 46 | void tmp68301_device::device_reset() |
| 47 | { |
| 48 | int i; |
| 49 | |
| 50 | for (i = 0; i < 3; i++) |
| 51 | m_IE[i] = 0; |
| 52 | |
| 53 | machine().firstcpu->set_irq_acknowledge_callback(device_irq_acknowledge_delegate(FUNC(tmp68301_device::irq_callback),this)); |
| 54 | } |
| 55 | |
| 56 | |
| 57 | IRQ_CALLBACK_MEMBER(tmp68301_device::irq_callback) |
| 58 | { |
| 59 | int vector = m_irq_vector[irqline]; |
| 26 | 60 | // logerror("%s: irq callback returns %04X for level %x\n",machine.describe_context(),vector,int_level); |
| 27 | 61 | return vector; |
| 28 | 62 | } |
| 29 | 63 | |
| 30 | | static TIMER_CALLBACK( tmp68301_timer_callback ) |
| 64 | TIMER_CALLBACK_MEMBER( tmp68301_device::timer_callback ) |
| 31 | 65 | { |
| 32 | 66 | int i = param; |
| 33 | | UINT16 TCR = tmp68301_regs[(0x200 + i * 0x20)/2]; |
| 34 | | UINT16 IMR = tmp68301_regs[0x94/2]; // Interrupt Mask Register (IMR) |
| 35 | | UINT16 ICR = tmp68301_regs[0x8e/2+i]; // Interrupt Controller Register (ICR7..9) |
| 36 | | UINT16 IVNR = tmp68301_regs[0x9a/2]; // Interrupt Vector Number Register (IVNR) |
| 67 | UINT16 TCR = m_regs[(0x200 + i * 0x20)/2]; |
| 68 | UINT16 IMR = m_regs[0x94/2]; // Interrupt Mask Register (IMR) |
| 69 | UINT16 ICR = m_regs[0x8e/2+i]; // Interrupt Controller Register (ICR7..9) |
| 70 | UINT16 IVNR = m_regs[0x9a/2]; // Interrupt Vector Number Register (IVNR) |
| 37 | 71 | |
| 38 | 72 | // logerror("s: callback timer %04X, j = %d\n",machine.describe_context(),i,tcount); |
| 39 | 73 | |
| r24080 | r24081 | |
| 44 | 78 | int level = ICR & 0x0007; |
| 45 | 79 | |
| 46 | 80 | // Interrupt Vector Number Register (IVNR) |
| 47 | | tmp68301_irq_vector[level] = IVNR & 0x00e0; |
| 48 | | tmp68301_irq_vector[level] += 4+i; |
| 81 | m_irq_vector[level] = IVNR & 0x00e0; |
| 82 | m_irq_vector[level] += 4+i; |
| 49 | 83 | |
| 50 | | machine.firstcpu->set_input_line(level,HOLD_LINE); |
| 84 | machine().firstcpu->set_input_line(level,HOLD_LINE); |
| 51 | 85 | } |
| 52 | 86 | |
| 53 | 87 | if (TCR & 0x0080) // N/1 |
| 54 | 88 | { |
| 55 | 89 | // Repeat |
| 56 | | tmp68301_update_timer(machine, i); |
| 90 | update_timer(i); |
| 57 | 91 | } |
| 58 | 92 | else |
| 59 | 93 | { |
| r24080 | r24081 | |
| 61 | 95 | } |
| 62 | 96 | } |
| 63 | 97 | |
| 64 | | static void tmp68301_update_timer( running_machine &machine, int i ) |
| 98 | void tmp68301_device::update_timer( int i ) |
| 65 | 99 | { |
| 66 | | UINT16 TCR = tmp68301_regs[(0x200 + i * 0x20)/2]; |
| 67 | | UINT16 MAX1 = tmp68301_regs[(0x204 + i * 0x20)/2]; |
| 68 | | UINT16 MAX2 = tmp68301_regs[(0x206 + i * 0x20)/2]; |
| 100 | UINT16 TCR = m_regs[(0x200 + i * 0x20)/2]; |
| 101 | UINT16 MAX1 = m_regs[(0x204 + i * 0x20)/2]; |
| 102 | UINT16 MAX2 = m_regs[(0x206 + i * 0x20)/2]; |
| 69 | 103 | |
| 70 | 104 | int max = 0; |
| 71 | 105 | attotime duration = attotime::zero; |
| 72 | 106 | |
| 73 | | tmp68301_timer[i]->adjust(attotime::never,i); |
| 107 | m_tmp68301_timer[i]->adjust(attotime::never,i); |
| 74 | 108 | |
| 75 | 109 | // timers 1&2 only |
| 76 | 110 | switch( (TCR & 0x0030)>>4 ) // MR2..1 |
| r24080 | r24081 | |
| 90 | 124 | { |
| 91 | 125 | int scale = (TCR & 0x3c00)>>10; // P4..1 |
| 92 | 126 | if (scale > 8) scale = 8; |
| 93 | | duration = attotime::from_hz(machine.firstcpu->unscaled_clock()) * ((1 << scale) * max); |
| 127 | duration = attotime::from_hz(machine().firstcpu->unscaled_clock()) * ((1 << scale) * max); |
| 94 | 128 | } |
| 95 | 129 | break; |
| 96 | 130 | } |
| 97 | 131 | |
| 98 | | // logerror("%s: TMP68301 Timer %d, duration %lf, max %04X\n",machine.describe_context(),i,duration,max); |
| 132 | // logerror("%s: TMP68301 Timer %d, duration %lf, max %04X\n",machine().describe_context(),i,duration,max); |
| 99 | 133 | |
| 100 | 134 | if (!(TCR & 0x0002)) // CS |
| 101 | 135 | { |
| 102 | 136 | if (duration != attotime::zero) |
| 103 | | tmp68301_timer[i]->adjust(duration,i); |
| 137 | m_tmp68301_timer[i]->adjust(duration,i); |
| 104 | 138 | else |
| 105 | | logerror("%s: TMP68301 error, timer %d duration is 0\n",machine.describe_context(),i); |
| 139 | logerror("%s: TMP68301 error, timer %d duration is 0\n",machine().describe_context(),i); |
| 106 | 140 | } |
| 107 | 141 | } |
| 108 | 142 | |
| 109 | | MACHINE_START( tmp68301 ) |
| 110 | | { |
| 111 | | int i; |
| 112 | | for (i = 0; i < 3; i++) |
| 113 | | tmp68301_timer[i] = machine.scheduler().timer_alloc(FUNC(tmp68301_timer_callback)); |
| 114 | | } |
| 115 | | |
| 116 | | MACHINE_RESET( tmp68301 ) |
| 117 | | { |
| 118 | | int i; |
| 119 | | |
| 120 | | for (i = 0; i < 3; i++) |
| 121 | | tmp68301_IE[i] = 0; |
| 122 | | |
| 123 | | machine.firstcpu->set_irq_acknowledge_callback(tmp68301_irq_callback); |
| 124 | | } |
| 125 | | |
| 126 | 143 | /* Update the IRQ state based on all possible causes */ |
| 127 | | static void update_irq_state(running_machine &machine) |
| 144 | void tmp68301_device::update_irq_state() |
| 128 | 145 | { |
| 129 | 146 | int i; |
| 130 | 147 | |
| 131 | 148 | /* Take care of external interrupts */ |
| 132 | 149 | |
| 133 | | UINT16 IMR = tmp68301_regs[0x94/2]; // Interrupt Mask Register (IMR) |
| 134 | | UINT16 IVNR = tmp68301_regs[0x9a/2]; // Interrupt Vector Number Register (IVNR) |
| 150 | UINT16 IMR = m_regs[0x94/2]; // Interrupt Mask Register (IMR) |
| 151 | UINT16 IVNR = m_regs[0x9a/2]; // Interrupt Vector Number Register (IVNR) |
| 135 | 152 | |
| 136 | 153 | for (i = 0; i < 3; i++) |
| 137 | 154 | { |
| 138 | | if ( (tmp68301_IE[i]) && |
| 155 | if ( (m_IE[i]) && |
| 139 | 156 | !(IMR & (1<<i)) |
| 140 | 157 | ) |
| 141 | 158 | { |
| 142 | | UINT16 ICR = tmp68301_regs[0x80/2+i]; // Interrupt Controller Register (ICR0..2) |
| 159 | UINT16 ICR = m_regs[0x80/2+i]; // Interrupt Controller Register (ICR0..2) |
| 143 | 160 | |
| 144 | 161 | // Interrupt Controller Register (ICR0..2) |
| 145 | 162 | int level = ICR & 0x0007; |
| 146 | 163 | |
| 147 | 164 | // Interrupt Vector Number Register (IVNR) |
| 148 | | tmp68301_irq_vector[level] = IVNR & 0x00e0; |
| 149 | | tmp68301_irq_vector[level] += i; |
| 165 | m_irq_vector[level] = IVNR & 0x00e0; |
| 166 | m_irq_vector[level] += i; |
| 150 | 167 | |
| 151 | | tmp68301_IE[i] = 0; // Interrupts are edge triggerred |
| 168 | m_IE[i] = 0; // Interrupts are edge triggerred |
| 152 | 169 | |
| 153 | | machine.firstcpu->set_input_line(level,HOLD_LINE); |
| 170 | machine().firstcpu->set_input_line(level,HOLD_LINE); |
| 154 | 171 | } |
| 155 | 172 | } |
| 156 | 173 | } |
| 157 | 174 | |
| 158 | | READ16_HANDLER( tmp68301_regs_r ) |
| 175 | READ16_MEMBER( tmp68301_device::regs_r ) |
| 159 | 176 | { |
| 160 | | return tmp68301_regs[offset]; |
| 177 | return m_regs[offset]; |
| 161 | 178 | } |
| 162 | 179 | |
| 163 | | WRITE16_HANDLER( tmp68301_regs_w ) |
| 180 | WRITE16_MEMBER( tmp68301_device::regs_w ) |
| 164 | 181 | { |
| 165 | | COMBINE_DATA(&tmp68301_regs[offset]); |
| 182 | COMBINE_DATA(&m_regs[offset]); |
| 166 | 183 | |
| 167 | 184 | if (!ACCESSING_BITS_0_7) return; |
| 168 | 185 | |
| r24080 | r24081 | |
| 177 | 194 | { |
| 178 | 195 | int i = ((offset*2) >> 5) & 3; |
| 179 | 196 | |
| 180 | | tmp68301_update_timer( space.machine(), i ); |
| 197 | update_timer( i ); |
| 181 | 198 | } |
| 182 | 199 | break; |
| 183 | 200 | } |
| 184 | 201 | } |
| 185 | 202 | |
| 186 | | void tmp68301_external_interrupt_0(running_machine &machine) { tmp68301_IE[0] = 1; update_irq_state(machine); } |
| 187 | | void tmp68301_external_interrupt_1(running_machine &machine) { tmp68301_IE[1] = 1; update_irq_state(machine); } |
| 188 | | void tmp68301_external_interrupt_2(running_machine &machine) { tmp68301_IE[2] = 1; update_irq_state(machine); } |
| 203 | void tmp68301_device::external_interrupt_0() { m_IE[0] = 1; update_irq_state(); } |
| 204 | void tmp68301_device::external_interrupt_1() { m_IE[1] = 1; update_irq_state(); } |
| 205 | void tmp68301_device::external_interrupt_2() { m_IE[2] = 1; update_irq_state(); } |