Previous 199869 Revisions Next

r36139 Saturday 28th February, 2015 at 09:20:26 UTC by Osso
tugboat.c: killed anonymous timer, added save state support (nw)
[src/mame/drivers]tugboat.c

trunk/src/mame/drivers/tugboat.c
r244650r244651
1111  but the current implementation is a big kludge, and it still looks wrong.
1212- colors might not be entirely accurate
1313  Suspect berenstn is using the wrong color PROM.
14- convert to use the H46505 device.
1415
1516the problem which caused the controls not to work
1617---
r244650r244651
3940   tugboat_state(const machine_config &mconfig, device_type type, const char *tag)
4041      : driver_device(mconfig, type, tag),
4142      m_maincpu(*this, "maincpu"),
42      m_ram(*this, "ram"),
4343      m_gfxdecode(*this, "gfxdecode"),
4444      m_screen(*this, "screen"),
45      m_palette(*this, "palette") { }
45      m_palette(*this, "palette"),
46      m_ram(*this, "ram") { }
4647
4748   required_device<cpu_device> m_maincpu;
48   required_shared_ptr<UINT8> m_ram;
4949   required_device<gfxdecode_device> m_gfxdecode;
5050   required_device<screen_device> m_screen;
5151   required_device<palette_device> m_palette;
52   
53   required_shared_ptr<UINT8> m_ram;
5254
5355   UINT8 m_hd46505_0_reg[18];
5456   UINT8 m_hd46505_1_reg[18];
5557   int m_reg0;
5658   int m_reg1;
5759   int m_ctrl;
58   DECLARE_WRITE8_MEMBER(tugboat_hd46505_0_w);
59   DECLARE_WRITE8_MEMBER(tugboat_hd46505_1_w);
60   DECLARE_WRITE8_MEMBER(tugboat_score_w);
61   DECLARE_READ8_MEMBER(tugboat_input_r);
62   DECLARE_WRITE8_MEMBER(tugboat_ctrl_w);
60   emu_timer *m_interrupt_timer;
61   
62   DECLARE_WRITE8_MEMBER(hd46505_0_w);
63   DECLARE_WRITE8_MEMBER(hd46505_1_w);
64   DECLARE_WRITE8_MEMBER(score_w);
65   DECLARE_READ8_MEMBER(input_r);
66   DECLARE_WRITE8_MEMBER(ctrl_w);
67   
6368   virtual void machine_start();
6469   virtual void video_start();
6570   virtual void machine_reset();
6671   DECLARE_PALETTE_INIT(tugboat);
67   UINT32 screen_update_tugboat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
72   
73   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6874   void draw_tilemap(bitmap_ind16 &bitmap,const rectangle &cliprect,
6975      int addr,int gfx0,int gfx1,int transparency);
7076
r244650r244651
7581
7682void tugboat_state::machine_start()
7783{
78   /*save_item(NAME(m_hd46505_0_reg));
84   m_interrupt_timer = timer_alloc(TIMER_INTERRUPT);
85   
7986   save_item(NAME(m_hd46505_0_reg));
87   save_item(NAME(m_hd46505_1_reg));
8088   save_item(NAME(m_reg0));
8189   save_item(NAME(m_reg1));
82   save_item(NAME(m_ctrl));*/
90   save_item(NAME(m_ctrl));
8391}
8492
8593void tugboat_state::video_start()
r244650r244651
113121
114122/* see mc6845.c. That file is only a placeholder, I process the writes here
115123   because I need the start_addr register to handle scrolling */
116WRITE8_MEMBER(tugboat_state::tugboat_hd46505_0_w)
124WRITE8_MEMBER(tugboat_state::hd46505_0_w)
117125{
118126   if (offset == 0) m_reg0 = data & 0x0f;
119127   else if (m_reg0 < 18) m_hd46505_0_reg[m_reg0] = data;
120128}
121WRITE8_MEMBER(tugboat_state::tugboat_hd46505_1_w)
129WRITE8_MEMBER(tugboat_state::hd46505_1_w)
122130{
123131   if (offset == 0) m_reg1 = data & 0x0f;
124132   else if (m_reg1 < 18) m_hd46505_1_reg[m_reg1] = data;
125133}
126134
127135
128WRITE8_MEMBER(tugboat_state::tugboat_score_w)
136WRITE8_MEMBER(tugboat_state::score_w)
129137{
130138      if (offset>=0x8) m_ram[0x291d + 32*offset + 32*(1-8)] = data ^ 0x0f;
131139      if (offset<0x8 ) m_ram[0x291d + 32*offset + 32*9] = data ^ 0x0f;
r244650r244651
168176   }
169177}
170178
171UINT32 tugboat_state::screen_update_tugboat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
179UINT32 tugboat_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
172180{
173181   int startaddr0 = m_hd46505_0_reg[0x0c]*256 + m_hd46505_0_reg[0x0d];
174182   int startaddr1 = m_hd46505_1_reg[0x0c]*256 + m_hd46505_1_reg[0x0d];
r244650r244651
181189
182190
183191
184READ8_MEMBER(tugboat_state::tugboat_input_r)
192READ8_MEMBER(tugboat_state::input_r)
185193{
186194   if (~m_ctrl & 0x80)
187195      return ioport("IN0")->read();
r244650r244651
195203      return ioport("IN4")->read();
196204}
197205
198WRITE8_MEMBER(tugboat_state::tugboat_ctrl_w)
206WRITE8_MEMBER(tugboat_state::ctrl_w)
199207{
200208   m_ctrl = data;
201209}
r244650r244651
206214   {
207215   case TIMER_INTERRUPT:
208216      m_maincpu->set_input_line(0, HOLD_LINE);
209      timer_set(m_screen->frame_period(), TIMER_INTERRUPT);
217      m_interrupt_timer->adjust(m_screen->frame_period());
210218      break;
211219   default:
212220      assert_always(FALSE, "Unknown id in tugboat_state::device_timer");
r244650r244651
215223
216224void tugboat_state::machine_reset()
217225{
218   timer_set(m_screen->time_until_pos(0), TIMER_INTERRUPT);
226   m_interrupt_timer->adjust(m_screen->time_until_pos(0));
219227}
220228
221229
r244650r244651
223231   ADDRESS_MAP_GLOBAL_MASK(0x7fff)
224232   AM_RANGE(0x0000, 0x01ff) AM_RAM AM_SHARE("ram")
225233   AM_RANGE(0x1060, 0x1061) AM_DEVWRITE("aysnd", ay8910_device, address_data_w)
226   AM_RANGE(0x10a0, 0x10a1) AM_WRITE(tugboat_hd46505_0_w)  /* scrolling is performed changing the start_addr register (0C/0D) */
227   AM_RANGE(0x10c0, 0x10c1) AM_WRITE(tugboat_hd46505_1_w)
234   AM_RANGE(0x10a0, 0x10a1) AM_WRITE(hd46505_0_w)  /* scrolling is performed changing the start_addr register (0C/0D) */
235   AM_RANGE(0x10c0, 0x10c1) AM_WRITE(hd46505_1_w)
228236   AM_RANGE(0x11e4, 0x11e7) AM_DEVREADWRITE("pia0", pia6821_device, read, write)
229237   AM_RANGE(0x11e8, 0x11eb) AM_DEVREADWRITE("pia1", pia6821_device, read, write)
230238   //AM_RANGE(0x1700, 0x1fff) AM_RAM
231   AM_RANGE(0x18e0, 0x18ef) AM_WRITE(tugboat_score_w)
239   AM_RANGE(0x18e0, 0x18ef) AM_WRITE(score_w)
232240   AM_RANGE(0x2000, 0x2fff) AM_RAM /* tilemap RAM */
233241   AM_RANGE(0x4000, 0x7fff) AM_ROM
234242ADDRESS_MAP_END
r244650r244651
352360   MCFG_CPU_VBLANK_INT_DRIVER("screen", tugboat_state,  nmi_line_pulse)
353361
354362   MCFG_DEVICE_ADD("pia0", PIA6821, 0)
355   MCFG_PIA_READPA_HANDLER(READ8(tugboat_state,tugboat_input_r))
363   MCFG_PIA_READPA_HANDLER(READ8(tugboat_state,input_r))
356364
357365   MCFG_DEVICE_ADD("pia1", PIA6821, 0)
358366   MCFG_PIA_READPA_HANDLER(IOPORT("DSW"))
359   MCFG_PIA_WRITEPB_HANDLER(WRITE8(tugboat_state, tugboat_ctrl_w))
367   MCFG_PIA_WRITEPB_HANDLER(WRITE8(tugboat_state, ctrl_w))
360368
361369   MCFG_SCREEN_ADD("screen", RASTER)
362370   MCFG_SCREEN_REFRESH_RATE(60)
363371   MCFG_SCREEN_SIZE(32*8,32*8)
364372   MCFG_SCREEN_VISIBLE_AREA(1*8,31*8-1,2*8,30*8-1)
365   MCFG_SCREEN_UPDATE_DRIVER(tugboat_state, screen_update_tugboat)
373   MCFG_SCREEN_UPDATE_DRIVER(tugboat_state, screen_update)
366374   MCFG_SCREEN_PALETTE("palette")
367375
368376   MCFG_GFXDECODE_ADD("gfxdecode", "palette", tugboat)
r244650r244651
460468ROM_END
461469
462470
463GAME( 1982, tugboat,  0, tugboat, tugboat, driver_device,  0, ROT90, "Enter-Tech, Ltd.", "Tugboat",    GAME_IMPERFECT_GRAPHICS )
464GAME( 1983, noahsark, 0, tugboat, noahsark, driver_device, 0, ROT90, "Enter-Tech, Ltd.", "Noah's Ark", GAME_IMPERFECT_GRAPHICS )
465GAME( 1984, berenstn, 0, tugboat, noahsark, driver_device, 0, ROT90, "Enter-Tech, Ltd.", "The Berenstain Bears in Big Paw's Cave", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS )
471GAME( 1982, tugboat,  0, tugboat, tugboat, driver_device,  0, ROT90, "Enter-Tech, Ltd.", "Tugboat",    GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
472GAME( 1983, noahsark, 0, tugboat, noahsark, driver_device, 0, ROT90, "Enter-Tech, Ltd.", "Noah's Ark", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
473GAME( 1984, berenstn, 0, tugboat, noahsark, driver_device, 0, ROT90, "Enter-Tech, Ltd.", "The Berenstain Bears in Big Paw's Cave", GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE )


Previous 199869 Revisions Next


© 1997-2024 The MAME Team