trunk/src/mame/drivers/lbeach.c
| r0 | r26066 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:hap |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | Olympia / Seletron, Long Beach |
| 6 | |
| 7 | PCB was broken, and there are no known references. |
| 8 | 16MHz XTAL, M6800 @ 500kHz |
| 9 | 2x 5101 sram 256x4bit (256 byte) |
| 10 | 4x 4045 sram 1kx4 (2K byte) |
| 11 | |
| 12 | 6800 hits many illegal opcodes (0x02), though it's harmless. |
| 13 | Maybe they meant to inserts nops (0x01) to remove debug stuff |
| 14 | or to make room for future additions? |
| 15 | |
| 16 | TODO: |
| 17 | - discrete sound? |
| 18 | - correct colors |
| 19 | - unknown writes |
| 20 | - video/nmi timing |
| 21 | |
| 22 | ***************************************************************************/ |
| 23 | |
| 24 | #include "emu.h" |
| 25 | #include "cpu/m6800/m6800.h" |
| 26 | |
| 27 | |
| 28 | class lbeach_state : public driver_device |
| 29 | { |
| 30 | public: |
| 31 | lbeach_state(const machine_config &mconfig, device_type type, const char *tag) |
| 32 | : driver_device(mconfig, type, tag), |
| 33 | m_maincpu(*this, "maincpu"), |
| 34 | m_bg_vram(*this, "bg_vram"), |
| 35 | m_fg_vram(*this, "fg_vram"), |
| 36 | m_scroll_y(*this, "scroll_y"), |
| 37 | m_sprite_x(*this, "sprite_x"), |
| 38 | m_sprite_code(*this, "sprite_code"), |
| 39 | m_collision_bg_car(0), |
| 40 | m_collision_fg_car(0) |
| 41 | { } |
| 42 | |
| 43 | /* devices / memory pointers */ |
| 44 | required_device<cpu_device> m_maincpu; |
| 45 | required_shared_ptr<UINT8> m_bg_vram; |
| 46 | required_shared_ptr<UINT8> m_fg_vram; |
| 47 | required_shared_ptr<UINT8> m_scroll_y; |
| 48 | required_shared_ptr<UINT8> m_sprite_x; |
| 49 | required_shared_ptr<UINT8> m_sprite_code; |
| 50 | |
| 51 | int m_collision_bg_car; |
| 52 | int m_collision_fg_car; |
| 53 | bitmap_ind16 m_colmap_car; |
| 54 | tilemap_t* m_bg_tilemap; |
| 55 | tilemap_t* m_fg_tilemap; |
| 56 | TILE_GET_INFO_MEMBER(get_bg_tile_info); |
| 57 | TILE_GET_INFO_MEMBER(get_fg_tile_info); |
| 58 | |
| 59 | DECLARE_WRITE8_MEMBER(lbeach_bg_vram_w); |
| 60 | DECLARE_WRITE8_MEMBER(lbeach_fg_vram_w); |
| 61 | DECLARE_READ8_MEMBER(lbeach_in1_r); |
| 62 | DECLARE_READ8_MEMBER(lbeach_in2_r); |
| 63 | |
| 64 | virtual void machine_start(); |
| 65 | virtual void machine_reset(); |
| 66 | virtual void video_start(); |
| 67 | virtual void palette_init(); |
| 68 | UINT32 screen_update_lbeach(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 69 | }; |
| 70 | |
| 71 | |
| 72 | |
| 73 | /*************************************************************************** |
| 74 | |
| 75 | Video |
| 76 | |
| 77 | ***************************************************************************/ |
| 78 | |
| 79 | void lbeach_state::palette_init() |
| 80 | { |
| 81 | // This is guesswork. |
| 82 | // The only hints are the gradient on the Seletron screen, |
| 83 | // and the highlighted blocks in testmode. |
| 84 | |
| 85 | // tiles |
| 86 | palette_set_color_rgb(machine(), 0, 0x00, 0x00, 0x00); |
| 87 | palette_set_color_rgb(machine(), 1, 0xff, 0xff, 0xff); |
| 88 | |
| 89 | // road |
| 90 | palette_set_color_rgb(machine(), 2, 0x00, 0x00, 0x00); |
| 91 | palette_set_color_rgb(machine(), 3, 0xff, 0xff, 0xff); |
| 92 | |
| 93 | palette_set_color_rgb(machine(), 4, 0x80, 0x80, 0x80); |
| 94 | palette_set_color_rgb(machine(), 5, 0xff, 0xff, 0xff); |
| 95 | |
| 96 | palette_set_color_rgb(machine(), 6, 0x00, 0x00, 0x00); |
| 97 | palette_set_color_rgb(machine(), 7, 0x80, 0x80, 0x80); |
| 98 | |
| 99 | palette_set_color_rgb(machine(), 8, 0x80, 0x80, 0x80); |
| 100 | palette_set_color_rgb(machine(), 9, 0xff, 0xff, 0xff); |
| 101 | |
| 102 | // player car |
| 103 | palette_set_color_rgb(machine(), 10, 0x00, 0x00, 0x00); |
| 104 | palette_set_color_rgb(machine(), 11, 0xc0, 0xc0, 0xc0); |
| 105 | } |
| 106 | |
| 107 | |
| 108 | TILE_GET_INFO_MEMBER(lbeach_state::get_bg_tile_info) |
| 109 | { |
| 110 | // d0-d4: code |
| 111 | // d5: unused? |
| 112 | // d6,d7: color |
| 113 | UINT8 code = m_bg_vram[tile_index]; |
| 114 | |
| 115 | SET_TILE_INFO_MEMBER(1, code & 0x1f, code >> 6 & 3, 0); |
| 116 | } |
| 117 | |
| 118 | TILE_GET_INFO_MEMBER(lbeach_state::get_fg_tile_info) |
| 119 | { |
| 120 | UINT8 code = m_fg_vram[tile_index]; |
| 121 | |
| 122 | SET_TILE_INFO_MEMBER(0, code, 0, 0); |
| 123 | } |
| 124 | |
| 125 | void lbeach_state::video_start() |
| 126 | { |
| 127 | m_bg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(lbeach_state::get_bg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 16); |
| 128 | |
| 129 | m_fg_tilemap = &machine().tilemap().create(tilemap_get_info_delegate(FUNC(lbeach_state::get_fg_tile_info),this), TILEMAP_SCAN_ROWS, 16, 8, 32, 32); |
| 130 | m_fg_tilemap->set_transparent_pen(0); |
| 131 | |
| 132 | m_screen->register_screen_bitmap(m_colmap_car); |
| 133 | } |
| 134 | |
| 135 | |
| 136 | UINT32 lbeach_state::screen_update_lbeach(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 137 | { |
| 138 | // draw bg layer (road) |
| 139 | m_bg_tilemap->set_scrolly(0, *m_scroll_y); |
| 140 | m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 141 | |
| 142 | // check collision |
| 143 | int sprite_code = *m_sprite_code & 0xf; |
| 144 | int sprite_x = *m_sprite_x * 2 - 4; |
| 145 | int sprite_y = 160; |
| 146 | |
| 147 | m_colmap_car.fill(0, cliprect); |
| 148 | drawgfx_transpen(m_colmap_car, cliprect, machine().gfx[2], sprite_code, 0, 0, 0, sprite_x, sprite_y, 0); |
| 149 | bitmap_ind16 &fg_bitmap = m_fg_tilemap->pixmap(); |
| 150 | |
| 151 | m_collision_bg_car = 0; |
| 152 | m_collision_fg_car = 0; |
| 153 | |
| 154 | for (int y = sprite_y; y < (sprite_y + 16); y++) |
| 155 | { |
| 156 | for (int x = sprite_x; x < (sprite_x + 16) && cliprect.contains(x, y); x++) |
| 157 | { |
| 158 | m_collision_bg_car |= (bitmap.pix16(y, x) & m_colmap_car.pix16(y, x) & 1); |
| 159 | m_collision_fg_car |= (fg_bitmap.pix16(y, x) & m_colmap_car.pix16(y, x) & 1); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | // draw fg layer (tiles) |
| 164 | m_fg_tilemap->draw(screen, bitmap, cliprect, 0, 0); |
| 165 | |
| 166 | // draw player car |
| 167 | drawgfx_transpen(bitmap, cliprect, machine().gfx[2], sprite_code, 0, 0, 0, sprite_x, sprite_y, 0); |
| 168 | |
| 169 | return 0; |
| 170 | } |
| 171 | |
| 172 | |
| 173 | WRITE8_MEMBER(lbeach_state::lbeach_bg_vram_w) |
| 174 | { |
| 175 | m_bg_vram[offset] = data; |
| 176 | m_bg_tilemap->mark_tile_dirty(offset); |
| 177 | } |
| 178 | |
| 179 | WRITE8_MEMBER(lbeach_state::lbeach_fg_vram_w) |
| 180 | { |
| 181 | m_fg_vram[offset] = data; |
| 182 | m_fg_tilemap->mark_tile_dirty(offset); |
| 183 | } |
| 184 | |
| 185 | |
| 186 | |
| 187 | /*************************************************************************** |
| 188 | |
| 189 | Memory Map, I/O |
| 190 | |
| 191 | ***************************************************************************/ |
| 192 | |
| 193 | READ8_MEMBER(lbeach_state::lbeach_in1_r) |
| 194 | { |
| 195 | // d6,7(steering wheel) need to be swapped |
| 196 | return BITSWAP8(ioport("IN1")->read(),6,7,5,4,3,2,1,0); |
| 197 | } |
| 198 | |
| 199 | READ8_MEMBER(lbeach_state::lbeach_in2_r) |
| 200 | { |
| 201 | // d6 and d7 are for collision detection |
| 202 | UINT8 d6 = m_collision_fg_car ? 0x40 : 0; |
| 203 | UINT8 d7 = m_collision_bg_car ? 0x80 : 0; |
| 204 | |
| 205 | return (ioport("IN2")->read() & 0x3f) | d6 | d7; |
| 206 | } |
| 207 | |
| 208 | static ADDRESS_MAP_START( lbeach_map, AS_PROGRAM, 8, lbeach_state ) |
| 209 | AM_RANGE(0x0000, 0x00ff) AM_RAM |
| 210 | AM_RANGE(0x4000, 0x4000) AM_READ(lbeach_in1_r) |
| 211 | AM_RANGE(0x4000, 0x41ff) AM_RAM_WRITE(lbeach_bg_vram_w) AM_SHARE("bg_vram") |
| 212 | AM_RANGE(0x4200, 0x43ff) AM_RAM |
| 213 | AM_RANGE(0x4400, 0x47ff) AM_RAM_WRITE(lbeach_fg_vram_w) AM_SHARE("fg_vram") |
| 214 | AM_RANGE(0x8000, 0x8000) AM_READ(lbeach_in2_r) |
| 215 | AM_RANGE(0x8000, 0x8000) AM_WRITEONLY AM_SHARE("scroll_y") |
| 216 | AM_RANGE(0x8001, 0x8001) AM_WRITEONLY AM_SHARE("sprite_x") |
| 217 | AM_RANGE(0x8002, 0x8002) AM_WRITEONLY AM_SHARE("sprite_code") |
| 218 | // AM_RANGE(0x8003, 0x8003) AM_WRITENOP // ? |
| 219 | // AM_RANGE(0x8004, 0x8004) AM_WRITENOP // ? |
| 220 | // AM_RANGE(0x8005, 0x8005) AM_WRITENOP // ? |
| 221 | AM_RANGE(0x8007, 0x8007) AM_WRITENOP // watchdog? |
| 222 | AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0") |
| 223 | // AM_RANGE(0xa003, 0xa003) AM_READNOP // ? tests d7 at game over |
| 224 | AM_RANGE(0xc000, 0xcfff) AM_ROM |
| 225 | AM_RANGE(0xf000, 0xffff) AM_ROM |
| 226 | ADDRESS_MAP_END |
| 227 | |
| 228 | |
| 229 | |
| 230 | /*************************************************************************** |
| 231 | |
| 232 | Inputs |
| 233 | |
| 234 | ***************************************************************************/ |
| 235 | |
| 236 | static INPUT_PORTS_START( lbeach ) |
| 237 | PORT_START("IN0") |
| 238 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("Gas Pedal") |
| 239 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Shifter 1st Gear") |
| 240 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Shifter 2nd Gear") |
| 241 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Shifter 3rd Gear") |
| 242 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Shifter 4th Gear") |
| 243 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Reset Record") // called RR in testmode |
| 244 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Coin Counter") // called CC in testmode |
| 245 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 246 | |
| 247 | PORT_START("IN1") |
| 248 | PORT_BIT( 0x1f, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 249 | PORT_SERVICE_NO_TOGGLE( 0x20, IP_ACTIVE_LOW ) |
| 250 | PORT_BIT(0xc0, 0x40, IPT_PADDLE ) PORT_INVERT PORT_MINMAX(0x00,0x80) PORT_SENSITIVITY(50) PORT_KEYDELTA(1) PORT_CENTERDELTA(1) |
| 251 | |
| 252 | PORT_START("IN2") |
| 253 | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) ) |
| 254 | PORT_DIPSETTING( 0x03, DEF_STR( 2C_1C ) ) |
| 255 | PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) ) // dupe |
| 256 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) |
| 257 | PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) ) |
| 258 | PORT_DIPNAME( 0x0c, 0x00, "Refueling Point" ) |
| 259 | PORT_DIPSETTING( 0x00, "200 km" ) |
| 260 | PORT_DIPSETTING( 0x04, "250 km" ) |
| 261 | PORT_DIPSETTING( 0x08, "300 km" ) |
| 262 | PORT_DIPSETTING( 0x0c, "350 km" ) |
| 263 | PORT_DIPNAME( 0x30, 0x10, "Fuel Drop Rate" ) |
| 264 | PORT_DIPSETTING( 0x30, "1" ) // slow |
| 265 | PORT_DIPSETTING( 0x20, "2" ) |
| 266 | PORT_DIPSETTING( 0x10, "3" ) |
| 267 | PORT_DIPSETTING( 0x00, "4" ) // fast |
| 268 | PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_SPECIAL ) |
| 269 | INPUT_PORTS_END |
| 270 | |
| 271 | |
| 272 | |
| 273 | /*************************************************************************** |
| 274 | |
| 275 | Machine Config |
| 276 | |
| 277 | ***************************************************************************/ |
| 278 | |
| 279 | static const gfx_layout tile_layout_16x8 = |
| 280 | { |
| 281 | 16,8, |
| 282 | RGN_FRAC(1,1), |
| 283 | 1, |
| 284 | { 0 }, |
| 285 | { STEP16(0,1) }, |
| 286 | { STEP8(0,16) }, |
| 287 | 16*8 |
| 288 | }; |
| 289 | |
| 290 | static const gfx_layout tile_layout_16x16 = |
| 291 | { |
| 292 | 16,16, |
| 293 | RGN_FRAC(1,1), |
| 294 | 1, |
| 295 | { 0 }, |
| 296 | { STEP16(0,1) }, |
| 297 | { STEP16(0,16) }, |
| 298 | 16*16 |
| 299 | }; |
| 300 | |
| 301 | static GFXDECODE_START( lbeach ) |
| 302 | GFXDECODE_ENTRY( "gfx1", 0, tile_layout_16x8, 0, 1 ) |
| 303 | GFXDECODE_ENTRY( "gfx2", 0, tile_layout_16x16, 2, 4 ) |
| 304 | GFXDECODE_ENTRY( "gfx3", 0, tile_layout_16x16, 10, 1 ) |
| 305 | GFXDECODE_END |
| 306 | |
| 307 | |
| 308 | void lbeach_state::machine_start() |
| 309 | { |
| 310 | save_item(NAME(m_collision_bg_car)); |
| 311 | save_item(NAME(m_collision_fg_car)); |
| 312 | } |
| 313 | |
| 314 | void lbeach_state::machine_reset() |
| 315 | { |
| 316 | } |
| 317 | |
| 318 | static MACHINE_CONFIG_START( lbeach, lbeach_state ) |
| 319 | |
| 320 | /* basic machine hardware */ |
| 321 | MCFG_CPU_ADD("maincpu", M6800, XTAL_16MHz / 32) // Motorola MC6800P, 500kHz |
| 322 | MCFG_CPU_PROGRAM_MAP(lbeach_map) |
| 323 | MCFG_CPU_PERIODIC_INT_DRIVER(lbeach_state, nmi_line_pulse, 50) // unknown freq, it affects steering speed |
| 324 | |
| 325 | /* video hardware */ |
| 326 | MCFG_SCREEN_ADD("screen", RASTER) |
| 327 | MCFG_SCREEN_REFRESH_RATE(60) // ? |
| 328 | MCFG_SCREEN_SIZE(512, 256) |
| 329 | MCFG_SCREEN_VISIBLE_AREA(0, 511-32, 0, 255-16) |
| 330 | MCFG_SCREEN_UPDATE_DRIVER(lbeach_state, screen_update_lbeach) |
| 331 | MCFG_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE) // needed for collision detection |
| 332 | |
| 333 | MCFG_GFXDECODE(lbeach) |
| 334 | MCFG_PALETTE_LENGTH(2+8+2) |
| 335 | |
| 336 | /* sound hardware */ |
| 337 | // ... |
| 338 | MACHINE_CONFIG_END |
| 339 | |
| 340 | |
| 341 | |
| 342 | /*************************************************************************** |
| 343 | |
| 344 | Game Drivers |
| 345 | |
| 346 | ***************************************************************************/ |
| 347 | |
| 348 | ROM_START( lbeach ) |
| 349 | ROM_REGION( 0x10000, "maincpu", 0 ) |
| 350 | ROM_LOAD( "x.c1", 0xc000, 0x0800, CRC(767fc287) SHA1(da8d59c4827b8479064084e14fa8a7bf71a65293) ) |
| 351 | ROM_LOAD( "c2.c2", 0xc800, 0x0800, CRC(9f30e0de) SHA1(607873566fd330486d2bc22cabd5623c021b1dc8) ) |
| 352 | ROM_LOAD( "f03.c3", 0xf000, 0x0800, CRC(6728aa45) SHA1(7f41d52f1e63cafd82ad0853a66ecbbdbee070b3) ) |
| 353 | ROM_LOAD( "f47.c4", 0xf800, 0x0800, CRC(950f3154) SHA1(e8bd1a818fe293163466169b65e07ac635ddfdb1) ) |
| 354 | |
| 355 | ROM_REGION( 0x1000, "gfx1", 0 ) |
| 356 | ROM_LOAD( "15.e2", 0x0000, 0x0800, CRC(9f24897c) SHA1(5ae05b06dadf4e935e39ac289f2db7719ff3b230) ) |
| 357 | ROM_LOAD( "s2.d2", 0x0800, 0x0800, CRC(c5d59466) SHA1(663df8397081daa89f9e3f7aec7e07557cf5b310) ) |
| 358 | |
| 359 | ROM_REGION( 0x0400, "gfx2", 0 ) |
| 360 | ROM_LOAD( "r.d1", 0x0000, 0x0400, CRC(07e99395) SHA1(67a68dee8e97ae74ab13af62cdc5279c358dc897) ) |
| 361 | |
| 362 | ROM_REGION( 0x0200, "gfx3", 0 ) |
| 363 | ROM_LOAD( "93448.h4", 0x0000, 0x0200, BAD_DUMP CRC(0dca040d) SHA1(d775cbf9fbb9449881ce4997187a1945d34d3cb6) ) // bad dump: stuck a5 |
| 364 | ROM_END |
| 365 | |
| 366 | |
| 367 | GAME( 1979, lbeach, 0, lbeach, lbeach, driver_device, 0, ROT0, "Olympia / Seletron", "Long Beach", GAME_WRONG_COLORS | GAME_NO_SOUND ) |