trunk/src/mame/drivers/tugboat.c
| r244650 | r244651 | |
| 11 | 11 | but the current implementation is a big kludge, and it still looks wrong. |
| 12 | 12 | - colors might not be entirely accurate |
| 13 | 13 | Suspect berenstn is using the wrong color PROM. |
| 14 | - convert to use the H46505 device. |
| 14 | 15 | |
| 15 | 16 | the problem which caused the controls not to work |
| 16 | 17 | --- |
| r244650 | r244651 | |
| 39 | 40 | tugboat_state(const machine_config &mconfig, device_type type, const char *tag) |
| 40 | 41 | : driver_device(mconfig, type, tag), |
| 41 | 42 | m_maincpu(*this, "maincpu"), |
| 42 | | m_ram(*this, "ram"), |
| 43 | 43 | m_gfxdecode(*this, "gfxdecode"), |
| 44 | 44 | m_screen(*this, "screen"), |
| 45 | | m_palette(*this, "palette") { } |
| 45 | m_palette(*this, "palette"), |
| 46 | m_ram(*this, "ram") { } |
| 46 | 47 | |
| 47 | 48 | required_device<cpu_device> m_maincpu; |
| 48 | | required_shared_ptr<UINT8> m_ram; |
| 49 | 49 | required_device<gfxdecode_device> m_gfxdecode; |
| 50 | 50 | required_device<screen_device> m_screen; |
| 51 | 51 | required_device<palette_device> m_palette; |
| 52 | |
| 53 | required_shared_ptr<UINT8> m_ram; |
| 52 | 54 | |
| 53 | 55 | UINT8 m_hd46505_0_reg[18]; |
| 54 | 56 | UINT8 m_hd46505_1_reg[18]; |
| 55 | 57 | int m_reg0; |
| 56 | 58 | int m_reg1; |
| 57 | 59 | 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 | |
| 63 | 68 | virtual void machine_start(); |
| 64 | 69 | virtual void video_start(); |
| 65 | 70 | virtual void machine_reset(); |
| 66 | 71 | 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); |
| 68 | 74 | void draw_tilemap(bitmap_ind16 &bitmap,const rectangle &cliprect, |
| 69 | 75 | int addr,int gfx0,int gfx1,int transparency); |
| 70 | 76 | |
| r244650 | r244651 | |
| 75 | 81 | |
| 76 | 82 | void tugboat_state::machine_start() |
| 77 | 83 | { |
| 78 | | /*save_item(NAME(m_hd46505_0_reg)); |
| 84 | m_interrupt_timer = timer_alloc(TIMER_INTERRUPT); |
| 85 | |
| 79 | 86 | save_item(NAME(m_hd46505_0_reg)); |
| 87 | save_item(NAME(m_hd46505_1_reg)); |
| 80 | 88 | save_item(NAME(m_reg0)); |
| 81 | 89 | save_item(NAME(m_reg1)); |
| 82 | | save_item(NAME(m_ctrl));*/ |
| 90 | save_item(NAME(m_ctrl)); |
| 83 | 91 | } |
| 84 | 92 | |
| 85 | 93 | void tugboat_state::video_start() |
| r244650 | r244651 | |
| 113 | 121 | |
| 114 | 122 | /* see mc6845.c. That file is only a placeholder, I process the writes here |
| 115 | 123 | because I need the start_addr register to handle scrolling */ |
| 116 | | WRITE8_MEMBER(tugboat_state::tugboat_hd46505_0_w) |
| 124 | WRITE8_MEMBER(tugboat_state::hd46505_0_w) |
| 117 | 125 | { |
| 118 | 126 | if (offset == 0) m_reg0 = data & 0x0f; |
| 119 | 127 | else if (m_reg0 < 18) m_hd46505_0_reg[m_reg0] = data; |
| 120 | 128 | } |
| 121 | | WRITE8_MEMBER(tugboat_state::tugboat_hd46505_1_w) |
| 129 | WRITE8_MEMBER(tugboat_state::hd46505_1_w) |
| 122 | 130 | { |
| 123 | 131 | if (offset == 0) m_reg1 = data & 0x0f; |
| 124 | 132 | else if (m_reg1 < 18) m_hd46505_1_reg[m_reg1] = data; |
| 125 | 133 | } |
| 126 | 134 | |
| 127 | 135 | |
| 128 | | WRITE8_MEMBER(tugboat_state::tugboat_score_w) |
| 136 | WRITE8_MEMBER(tugboat_state::score_w) |
| 129 | 137 | { |
| 130 | 138 | if (offset>=0x8) m_ram[0x291d + 32*offset + 32*(1-8)] = data ^ 0x0f; |
| 131 | 139 | if (offset<0x8 ) m_ram[0x291d + 32*offset + 32*9] = data ^ 0x0f; |
| r244650 | r244651 | |
| 168 | 176 | } |
| 169 | 177 | } |
| 170 | 178 | |
| 171 | | UINT32 tugboat_state::screen_update_tugboat(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 179 | UINT32 tugboat_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 172 | 180 | { |
| 173 | 181 | int startaddr0 = m_hd46505_0_reg[0x0c]*256 + m_hd46505_0_reg[0x0d]; |
| 174 | 182 | int startaddr1 = m_hd46505_1_reg[0x0c]*256 + m_hd46505_1_reg[0x0d]; |
| r244650 | r244651 | |
| 181 | 189 | |
| 182 | 190 | |
| 183 | 191 | |
| 184 | | READ8_MEMBER(tugboat_state::tugboat_input_r) |
| 192 | READ8_MEMBER(tugboat_state::input_r) |
| 185 | 193 | { |
| 186 | 194 | if (~m_ctrl & 0x80) |
| 187 | 195 | return ioport("IN0")->read(); |
| r244650 | r244651 | |
| 195 | 203 | return ioport("IN4")->read(); |
| 196 | 204 | } |
| 197 | 205 | |
| 198 | | WRITE8_MEMBER(tugboat_state::tugboat_ctrl_w) |
| 206 | WRITE8_MEMBER(tugboat_state::ctrl_w) |
| 199 | 207 | { |
| 200 | 208 | m_ctrl = data; |
| 201 | 209 | } |
| r244650 | r244651 | |
| 206 | 214 | { |
| 207 | 215 | case TIMER_INTERRUPT: |
| 208 | 216 | 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()); |
| 210 | 218 | break; |
| 211 | 219 | default: |
| 212 | 220 | assert_always(FALSE, "Unknown id in tugboat_state::device_timer"); |
| r244650 | r244651 | |
| 215 | 223 | |
| 216 | 224 | void tugboat_state::machine_reset() |
| 217 | 225 | { |
| 218 | | timer_set(m_screen->time_until_pos(0), TIMER_INTERRUPT); |
| 226 | m_interrupt_timer->adjust(m_screen->time_until_pos(0)); |
| 219 | 227 | } |
| 220 | 228 | |
| 221 | 229 | |
| r244650 | r244651 | |
| 223 | 231 | ADDRESS_MAP_GLOBAL_MASK(0x7fff) |
| 224 | 232 | AM_RANGE(0x0000, 0x01ff) AM_RAM AM_SHARE("ram") |
| 225 | 233 | 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) |
| 228 | 236 | AM_RANGE(0x11e4, 0x11e7) AM_DEVREADWRITE("pia0", pia6821_device, read, write) |
| 229 | 237 | AM_RANGE(0x11e8, 0x11eb) AM_DEVREADWRITE("pia1", pia6821_device, read, write) |
| 230 | 238 | //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) |
| 232 | 240 | AM_RANGE(0x2000, 0x2fff) AM_RAM /* tilemap RAM */ |
| 233 | 241 | AM_RANGE(0x4000, 0x7fff) AM_ROM |
| 234 | 242 | ADDRESS_MAP_END |
| r244650 | r244651 | |
| 352 | 360 | MCFG_CPU_VBLANK_INT_DRIVER("screen", tugboat_state, nmi_line_pulse) |
| 353 | 361 | |
| 354 | 362 | 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)) |
| 356 | 364 | |
| 357 | 365 | MCFG_DEVICE_ADD("pia1", PIA6821, 0) |
| 358 | 366 | 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)) |
| 360 | 368 | |
| 361 | 369 | MCFG_SCREEN_ADD("screen", RASTER) |
| 362 | 370 | MCFG_SCREEN_REFRESH_RATE(60) |
| 363 | 371 | MCFG_SCREEN_SIZE(32*8,32*8) |
| 364 | 372 | 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) |
| 366 | 374 | MCFG_SCREEN_PALETTE("palette") |
| 367 | 375 | |
| 368 | 376 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", tugboat) |
| r244650 | r244651 | |
| 460 | 468 | ROM_END |
| 461 | 469 | |
| 462 | 470 | |
| 463 | | GAME( 1982, tugboat, 0, tugboat, tugboat, driver_device, 0, ROT90, "Enter-Tech, Ltd.", "Tugboat", GAME_IMPERFECT_GRAPHICS ) |
| 464 | | GAME( 1983, noahsark, 0, tugboat, noahsark, driver_device, 0, ROT90, "Enter-Tech, Ltd.", "Noah's Ark", GAME_IMPERFECT_GRAPHICS ) |
| 465 | | GAME( 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 ) |
| 471 | GAME( 1982, tugboat, 0, tugboat, tugboat, driver_device, 0, ROT90, "Enter-Tech, Ltd.", "Tugboat", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) |
| 472 | GAME( 1983, noahsark, 0, tugboat, noahsark, driver_device, 0, ROT90, "Enter-Tech, Ltd.", "Noah's Ark", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) |
| 473 | GAME( 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 ) |