Previous 199869 Revisions Next

r21480 Thursday 28th February, 2013 at 17:24:45 UTC by Angelo Salese
Added irq cause/mask
[src/mame/drivers]gunpey.c

trunk/src/mame/drivers/gunpey.c
r21479r21480
1/*
1/********************************************************************************************
2
3
4=============================================================================================
5
26Gunpey
37Banpresto, 2000
48
r21479r21480
7175Operating frequency:             Up to 76MHz
7276Release:                         November 1999
7377
74*/
78********************************************************************************************/
7579
7680#include "emu.h"
7781#include "cpu/nec/nec.h"
r21479r21480
8387{
8488public:
8589   gunpey_state(const machine_config &mconfig, device_type type, const char *tag)
86      : driver_device(mconfig, type, tag) { }
90      : driver_device(mconfig, type, tag),
91      m_maincpu(*this, "maincpu")
92      { }
8793
94   required_device<cpu_device> m_maincpu;
95
8896   UINT16 *m_blit_buffer;
8997   UINT16 m_blit_ram[0x10];
98   UINT8 m_irq_cause, m_irq_mask;
9099   DECLARE_WRITE8_MEMBER(gunpey_status_w);
91100   DECLARE_READ8_MEMBER(gunpey_status_r);
92101   DECLARE_READ8_MEMBER(gunpey_inputs_r);
r21479r21480
95104   virtual void video_start();
96105   virtual void palette_init();
97106   UINT32 screen_update_gunpey(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
98   INTERRUPT_GEN_MEMBER(gunpey_interrupt);
107   TIMER_DEVICE_CALLBACK_MEMBER(gunpey_scanline);
108   void gunpey_irq_check(UINT8 irq_type);
99109};
100110
101111
r21479r21480
127137         if(cliprect.contains(x, y))
128138            bitmap.pix32(y, x) = b | (g<<8) | (r<<16);
129139
130
131140         count++;
132141      }
133142   }
r21479r21480
135144   return 0;
136145}
137146
147void gunpey_state::gunpey_irq_check(UINT8 irq_type)
148{
149   m_irq_cause |= irq_type;
150
151   if(m_irq_cause & m_irq_mask)
152      m_maincpu->set_input_line_and_vector(0, HOLD_LINE, 0x200/4);
153   else
154      m_maincpu->set_input_line_and_vector(0, CLEAR_LINE, 0x200/4);
155}
156
138157WRITE8_MEMBER(gunpey_state::gunpey_status_w)
139158{
159   if(offset == 1)
160   {
161      m_irq_cause &= ~data;
162      gunpey_irq_check(0);
163   }
164
165   if(offset == 0)
166   {
167      m_irq_mask = data;
168      gunpey_irq_check(0);
169   }
140170}
141171
142172READ8_MEMBER(gunpey_state::gunpey_status_r)
143173{
144174   if(offset == 1)
145      return 0x54;
175      return m_irq_cause;
146176
147   return 0x00;
177   return m_irq_mask;
148178}
149179
150180READ8_MEMBER(gunpey_state::gunpey_inputs_r)
r21479r21480
356386
357387}
358388
359INTERRUPT_GEN_MEMBER(gunpey_state::gunpey_interrupt)
389
390/* Four irqs:
3910x01 really an irq?
3920x04
3930x10
3940x40 almost certainly vblank (reads inputs)
3950x80
396*/
397TIMER_DEVICE_CALLBACK_MEMBER(gunpey_state::gunpey_scanline)
360398{
361   device.execute().set_input_line_and_vector(0,HOLD_LINE,0x200/4);
399   int scanline = param;
400
401   /* TODO */
402   if(scanline == 480)
403      gunpey_irq_check(0x54);
362404}
363405
364406/***************************************************************************************/
r21479r21480
368410   MCFG_CPU_ADD("maincpu", V30, 57242400 / 4)
369411   MCFG_CPU_PROGRAM_MAP(mem_map)
370412   MCFG_CPU_IO_MAP(io_map)
371   MCFG_CPU_VBLANK_INT_DRIVER("screen", gunpey_state, gunpey_interrupt)
413   MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", gunpey_state, gunpey_scanline, "screen", 0, 1)
372414
373415   /* video hardware */
416   /* TODO: screen params */
374417   MCFG_SCREEN_ADD("screen", RASTER)
375418   MCFG_SCREEN_REFRESH_RATE(60)
376419   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500))
377   MCFG_SCREEN_SIZE(512, 512)
378   MCFG_SCREEN_VISIBLE_AREA(0*8, 512-1, 0*8, 512-1)
420   MCFG_SCREEN_SIZE(818, 525)
421   MCFG_SCREEN_VISIBLE_AREA(0*8, 640-1, 0*8, 480-1)
379422   MCFG_SCREEN_UPDATE_DRIVER(gunpey_state, screen_update_gunpey)
380423
381424   MCFG_PALETTE_LENGTH(0x800)
382425
383
384426   MCFG_SPEAKER_STANDARD_STEREO("lspeaker","rspeaker")
385427
386428   MCFG_OKIM6295_ADD("oki", XTAL_16_9344MHz / 8, OKIM6295_PIN7_LOW)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team