Previous 199869 Revisions Next

r20962 Monday 11th February, 2013 at 22:09:11 UTC by Wilbert Pol
backfire.c: Reduce tagmap lookups (nw)
[src/mame/drivers]backfire.c

trunk/src/mame/drivers/backfire.c
r20961r20962
2121#include "rendlay.h"
2222#include "video/decospr.h"
2323
24
2425class backfire_state : public driver_device
2526{
2627public:
r20961r20962
3031      m_left_priority(*this, "left_priority"),
3132      m_right_priority(*this, "right_priority"),
3233      m_sprgen(*this, "spritegen"),
33      m_sprgen2(*this, "spritegen2")
34      m_sprgen2(*this, "spritegen2"),
35      m_maincpu(*this, "maincpu"),
36      m_deco_tilegen1(*this, "tilegen1"),
37      m_deco_tilegen2(*this, "tilegen2"),
38      m_lscreen(*this, "lscreen"),
39      m_rscreen(*this, "rscreen"),
40      m_eeprom(*this, "eeprom"),
41      m_io_in0(*this, "IN0"),
42      m_io_in1(*this, "IN1"),
43      m_io_in2(*this, "IN2"),
44      m_io_in3(*this, "IN3")
3445   { }
3546
3647   /* memory pointers */
r20961r20962
4758   bitmap_ind16  *m_right;
4859
4960   /* devices */
50   cpu_device *m_maincpu;
51   device_t *m_deco_tilegen1;
52   device_t *m_deco_tilegen2;
61   required_device<cpu_device> m_maincpu;
62   required_device<device_t> m_deco_tilegen1;
63   required_device<device_t> m_deco_tilegen2;
5364
54   device_t *m_lscreen;
55   device_t *m_rscreen;
56   eeprom_device *m_eeprom;
65   required_device<device_t> m_lscreen;
66   required_device<device_t> m_rscreen;
67   required_device<eeprom_device> m_eeprom;
5768
5869   /* memory */
5970   UINT16    m_pf1_rowscroll[0x0800/2];
r20961r20962
8899   UINT32 screen_update_backfire_right(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
89100   INTERRUPT_GEN_MEMBER(deco32_vbl_interrupt);
90101   void descramble_sound();
102
103   required_ioport m_io_in0;
104   required_ioport m_io_in1;
105   required_ioport m_io_in2;
106   required_ioport m_io_in3;
91107};
92108
93109//UINT32 *backfire_180010, *backfire_188010;
r20961r20962
182198
183199READ32_MEMBER(backfire_state::backfire_eeprom_r)
184200{
185   device_t *device = machine().device("eeprom");
186201   /* some kind of screen indicator?  checked by backfirea set before it will boot */
187202   int backfire_screen = machine().rand() & 1;
188   eeprom_device *eeprom = downcast<eeprom_device *>(device);
189   return ((eeprom->read_bit() << 24) | machine().root_device().ioport("IN0")->read()
190         | ((machine().root_device().ioport("IN2")->read() & 0xbf) << 16)
191         | ((machine().root_device().ioport("IN3")->read() & 0x40) << 16)) ^ (backfire_screen << 26) ;
203   return ((m_eeprom->read_bit() << 24) | m_io_in0->read()
204         | ((m_io_in2->read() & 0xbf) << 16)
205         | ((m_io_in3->read() & 0x40) << 16)) ^ (backfire_screen << 26) ;
192206}
193207
194208READ32_MEMBER(backfire_state::backfire_control2_r)
195209{
196210//  logerror("%08x:Read eprom %08x (%08x)\n", space.device().safe_pc(), offset << 1, mem_mask);
197   return (m_eeprom->read_bit() << 24) | ioport("IN1")->read() | (ioport("IN1")->read() << 16);
211   return (m_eeprom->read_bit() << 24) | m_io_in1->read() | (m_io_in1->read() << 16);
198212}
199213
200214#ifdef UNUSED_FUNCTION
201215READ32_MEMBER(backfire_state::backfire_control3_r)
202216{
203217//  logerror("%08x:Read eprom %08x (%08x)\n", space.device().safe_pc(), offset << 1, mem_mask);
204   return (m_eeprom->read_bit() << 24) | ioport("IN2")->read() | (ioport("IN2")->read() << 16);
218   return (m_eeprom->read_bit() << 24) | m_io_in2->read() | (m_io_in2->read() << 16);
205219}
206220#endif
207221
208222
209223WRITE32_MEMBER(backfire_state::backfire_eeprom_w)
210224{
211   device_t *device = machine().device("eeprom");
212225   logerror("%s:write eprom %08x (%08x) %08x\n",machine().describe_context(),offset<<1,mem_mask,data);
213226   if (ACCESSING_BITS_0_7)
214227   {
215      eeprom_device *eeprom = downcast<eeprom_device *>(device);
216      eeprom->set_clock_line(BIT(data, 1) ? ASSERT_LINE : CLEAR_LINE);
217      eeprom->write_bit(BIT(data, 0));
218      eeprom->set_cs_line(BIT(data, 2) ? CLEAR_LINE : ASSERT_LINE);
228      m_eeprom->set_clock_line(BIT(data, 1) ? ASSERT_LINE : CLEAR_LINE);
229      m_eeprom->write_bit(BIT(data, 0));
230      m_eeprom->set_cs_line(BIT(data, 2) ? CLEAR_LINE : ASSERT_LINE);
219231   }
220232}
221233
r20961r20962
476488
477489void backfire_state::machine_start()
478490{
479   m_maincpu = machine().device<cpu_device>("maincpu");
480   m_deco_tilegen1 = machine().device("tilegen1");
481   m_deco_tilegen2 = machine().device("tilegen2");
482   m_lscreen = machine().device("lscreen");
483   m_rscreen = machine().device("rscreen");
484   m_eeprom = machine().device<eeprom_device>("eeprom");
485491}
486492
487493UINT16 backfire_pri_callback(UINT16 x)
r20961r20962
711717   deco56_decrypt_gfx(machine(), "gfx1"); /* 141 */
712718   deco56_decrypt_gfx(machine(), "gfx2"); /* 141 */
713719   deco156_decrypt(machine());
714   machine().device("maincpu")->set_clock_scale(4.0f); /* core timings aren't accurate */
720   m_maincpu->set_clock_scale(4.0f); /* core timings aren't accurate */
715721   descramble_sound();
716   machine().device("maincpu")->memory().space(AS_PROGRAM).install_read_handler(0x0170018, 0x017001b, read32_delegate(FUNC(backfire_state::backfire_speedup_r), this));
722   m_maincpu->space(AS_PROGRAM).install_read_handler(0x0170018, 0x017001b, read32_delegate(FUNC(backfire_state::backfire_speedup_r), this));
717723}
718724
719725GAME( 1995, backfire,  0,        backfire,   backfire, backfire_state, backfire, ROT0, "Data East Corporation", "Backfire! (set 1)", GAME_SUPPORTS_SAVE )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team