trunk/src/mame/drivers/srmp5.c
| r243427 | r243428 | |
| 68 | 68 | : driver_device(mconfig, type, tag), |
| 69 | 69 | m_gfxdecode(*this, "gfxdecode"), |
| 70 | 70 | m_palette(*this, "palette"), |
| 71 | | m_maincpu(*this,"maincpu"), |
| 72 | | m_subcpu(*this, "sub") |
| 73 | | |
| 71 | m_maincpu(*this,"maincpu"), |
| 72 | m_subcpu(*this, "sub"), |
| 73 | m_chrrom(*this, "chr"), |
| 74 | m_keys(*this, "KEY"), |
| 75 | m_chrbank(0) |
| 74 | 76 | { } |
| 77 | required_device<gfxdecode_device> m_gfxdecode; |
| 78 | required_device<palette_device> m_palette; |
| 79 | required_device<st0016_cpu_device> m_maincpu; |
| 80 | required_device<cpu_device> m_subcpu; |
| 75 | 81 | |
| 76 | | UINT32 m_databank; |
| 82 | required_region_ptr<UINT16> m_chrrom; |
| 83 | |
| 84 | required_ioport_array<4> m_keys; |
| 85 | |
| 86 | UINT32 m_chrbank; |
| 77 | 87 | UINT16 *m_tileram; |
| 78 | | UINT16 *m_palram; |
| 79 | 88 | UINT16 *m_sprram; |
| 80 | 89 | |
| 81 | 90 | UINT8 m_input_select; |
| r243427 | r243428 | |
| 88 | 97 | #ifdef DEBUG_CHAR |
| 89 | 98 | UINT8 m_tileduty[0x2000]; |
| 90 | 99 | #endif |
| 91 | | DECLARE_READ32_MEMBER(srmp5_palette_r); |
| 92 | | DECLARE_WRITE32_MEMBER(srmp5_palette_w); |
| 93 | 100 | DECLARE_WRITE32_MEMBER(bank_w); |
| 94 | 101 | DECLARE_READ32_MEMBER(tileram_r); |
| 95 | 102 | DECLARE_WRITE32_MEMBER(tileram_w); |
| 96 | 103 | DECLARE_READ32_MEMBER(spr_r); |
| 97 | 104 | DECLARE_WRITE32_MEMBER(spr_w); |
| 98 | | DECLARE_READ32_MEMBER(data_r); |
| 105 | DECLARE_READ32_MEMBER(chrrom_r); |
| 99 | 106 | DECLARE_WRITE32_MEMBER(input_select_w); |
| 100 | 107 | DECLARE_READ32_MEMBER(srmp5_inputs_r); |
| 101 | 108 | DECLARE_WRITE32_MEMBER(cmd1_w); |
| r243427 | r243428 | |
| 109 | 116 | DECLARE_READ8_MEMBER(cmd_stat8_r); |
| 110 | 117 | DECLARE_DRIVER_INIT(srmp5); |
| 111 | 118 | UINT32 screen_update_srmp5(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 112 | | required_device<gfxdecode_device> m_gfxdecode; |
| 113 | | required_device<palette_device> m_palette; |
| 114 | | optional_device<st0016_cpu_device> m_maincpu; |
| 115 | | optional_device<cpu_device> m_subcpu; |
| 116 | 119 | |
| 120 | |
| 117 | 121 | DECLARE_WRITE8_MEMBER(st0016_rom_bank_w); |
| 118 | 122 | }; |
| 119 | 123 | |
| r243427 | r243428 | |
| 124 | 128 | UINT16 *sprite_list=m_sprram; |
| 125 | 129 | UINT16 *sprite_list_end=&m_sprram[0x4000]; //guess |
| 126 | 130 | UINT8 *pixels=(UINT8 *)m_tileram; |
| 131 | const pen_t * const pens = m_palette->pens(); |
| 127 | 132 | |
| 128 | 133 | //Table surface seems to be tiles, but display corrupts when switching the scene if always ON. |
| 129 | 134 | //Currently the tiles are OFF. |
| r243427 | r243428 | |
| 146 | 151 | { |
| 147 | 152 | for(x = 0; x < 16; x++) |
| 148 | 153 | { |
| 149 | | UINT8 pen = pixels[address]; |
| 154 | UINT8 pen = pixels[BYTE_XOR_LE(address)]; |
| 150 | 155 | if(pen) |
| 151 | 156 | { |
| 152 | | UINT16 pixdata=m_palram[pen]; |
| 153 | | bitmap.pix32(yw * 16 + y, xw * 16 + x) = ((pixdata&0x7c00)>>7) | ((pixdata&0x3e0)<<6) | ((pixdata&0x1f)<<19); |
| 157 | bitmap.pix32(yw * 16 + y, xw * 16 + x) = pens[pen]; |
| 154 | 158 | } |
| 155 | 159 | address++; |
| 156 | 160 | } |
| r243427 | r243428 | |
| 195 | 199 | ys2 = (sprite_sublist[SPRITE_PALETTE] & 0x4000) ? ys : (sizey - ys); |
| 196 | 200 | for(xs=0;xs<=sizex;xs++) |
| 197 | 201 | { |
| 198 | | UINT8 pen=pixels[address&(0x100000-1)]; |
| 202 | UINT8 pen=pixels[BYTE_XOR_LE(address)&(0x100000-1)]; |
| 199 | 203 | xs2 = (sprite_sublist[SPRITE_PALETTE] & 0x8000) ? (sizex - xs) : xs; |
| 200 | 204 | if(pen) |
| 201 | 205 | { |
| 202 | 206 | if(cliprect.contains(xb+xs2, yb+ys2)) |
| 203 | 207 | { |
| 204 | | UINT16 pixdata=m_palram[pen+((sprite_sublist[SPRITE_PALETTE]&0xff)<<8)]; |
| 205 | | bitmap.pix32(yb+ys2, xb+xs2) = ((pixdata&0x7c00)>>7) | ((pixdata&0x3e0)<<6) | ((pixdata&0x1f)<<19); |
| 208 | bitmap.pix32(yb+ys2, xb+xs2) = pens[pen+((sprite_sublist[SPRITE_PALETTE]&0xff)<<8)]; |
| 206 | 209 | } |
| 207 | 210 | } |
| 208 | 211 | ++address; |
| r243427 | r243428 | |
| 234 | 237 | return 0; |
| 235 | 238 | } |
| 236 | 239 | |
| 237 | | READ32_MEMBER(srmp5_state::srmp5_palette_r) |
| 238 | | { |
| 239 | | return m_palram[offset]; |
| 240 | | } |
| 241 | | |
| 242 | | WRITE32_MEMBER(srmp5_state::srmp5_palette_w) |
| 243 | | { |
| 244 | | COMBINE_DATA(&m_palram[offset]); |
| 245 | | m_palette->set_pen_color(offset, rgb_t(data << 3 & 0xFF, data >> 2 & 0xFF, data >> 7 & 0xFF)); |
| 246 | | } |
| 247 | 240 | WRITE32_MEMBER(srmp5_state::bank_w) |
| 248 | 241 | { |
| 249 | | COMBINE_DATA(&m_databank); |
| 242 | m_chrbank = ((data & 0xf0) >> 4) * (0x100000 / sizeof(UINT16)); |
| 250 | 243 | } |
| 251 | 244 | |
| 252 | 245 | READ32_MEMBER(srmp5_state::tileram_r) |
| r243427 | r243428 | |
| 272 | 265 | m_sprram[offset] = data & 0xFFFF; //lower 16bit only |
| 273 | 266 | } |
| 274 | 267 | |
| 275 | | READ32_MEMBER(srmp5_state::data_r) |
| 268 | READ32_MEMBER(srmp5_state::chrrom_r) |
| 276 | 269 | { |
| 277 | | UINT32 data; |
| 278 | | const UINT8 *usr = memregion("user2")->base(); |
| 279 | | |
| 280 | | data=((m_databank>>4)&0xf)*0x100000; //guess |
| 281 | | data=usr[data+offset*2]+usr[data+offset*2+1]*256; |
| 282 | | return data|(data<<16); |
| 270 | return m_chrrom[m_chrbank + offset]; // lower 16bit only |
| 283 | 271 | } |
| 284 | 272 | |
| 285 | 273 | WRITE32_MEMBER(srmp5_state::input_select_w) |
| r243427 | r243428 | |
| 294 | 282 | switch (m_input_select) |
| 295 | 283 | { |
| 296 | 284 | case 0x01: |
| 297 | | ret = ioport("IN0")->read(); |
| 285 | ret = m_keys[0]->read(); |
| 298 | 286 | break; |
| 299 | 287 | case 0x02: |
| 300 | | ret = ioport("IN1")->read(); |
| 288 | ret = m_keys[1]->read(); |
| 301 | 289 | break; |
| 302 | 290 | case 0x04: |
| 303 | | ret = ioport("IN2")->read(); |
| 291 | ret = m_keys[2]->read(); |
| 304 | 292 | break; |
| 305 | 293 | case 0x00: |
| 306 | 294 | case 0x08: |
| 307 | | ret = ioport("IN3")->read(); |
| 295 | ret = m_keys[3]->read(); |
| 308 | 296 | break; |
| 309 | 297 | } |
| 310 | 298 | return ret; |
| r243427 | r243428 | |
| 363 | 351 | AM_RANGE(0x01802000, 0x01802003) AM_WRITE(cmd1_w) |
| 364 | 352 | AM_RANGE(0x01802004, 0x01802007) AM_WRITE(cmd2_w) |
| 365 | 353 | AM_RANGE(0x01802008, 0x0180200b) AM_READ(cmd_stat32_r) |
| 366 | | AM_RANGE(0x01a00000, 0x01bfffff) AM_READ(data_r) |
| 354 | AM_RANGE(0x01a00000, 0x01bfffff) AM_READ(chrrom_r) |
| 367 | 355 | AM_RANGE(0x01c00000, 0x01c00003) AM_READNOP // debug? 'Toru' |
| 368 | 356 | |
| 369 | 357 | AM_RANGE(0x0a000000, 0x0a0fffff) AM_READWRITE(spr_r, spr_w) |
| 370 | | AM_RANGE(0x0a100000, 0x0a17ffff) AM_READWRITE(srmp5_palette_r, srmp5_palette_w) |
| 358 | AM_RANGE(0x0a100000, 0x0a17ffff) AM_DEVREADWRITE16("palette", palette_device, read, write, 0x0000ffff) AM_SHARE("palette") |
| 371 | 359 | //0?N???A?????????i?????????? |
| 372 | 360 | AM_RANGE(0x0a180000, 0x0a180003) AM_READNOP // write 0x00000400 |
| 373 | 361 | AM_RANGE(0x0a180000, 0x0a18011f) AM_READWRITE(srmp5_vidregs_r, srmp5_vidregs_w) |
| r243427 | r243428 | |
| 375 | 363 | |
| 376 | 364 | AM_RANGE(0x1eff0000, 0x1eff001f) AM_WRITEONLY |
| 377 | 365 | AM_RANGE(0x1eff003c, 0x1eff003f) AM_READ(irq_ack_clear) |
| 378 | | AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("user1", 0) |
| 379 | | AM_RANGE(0x2fc00000, 0x2fdfffff) AM_ROM AM_REGION("user1", 0) |
| 366 | AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("sub", 0) |
| 367 | AM_RANGE(0x2fc00000, 0x2fdfffff) AM_ROM AM_REGION("sub", 0) |
| 380 | 368 | ADDRESS_MAP_END |
| 381 | 369 | |
| 382 | 370 | static ADDRESS_MAP_START( st0016_mem, AS_PROGRAM, 8, srmp5_state ) |
| r243427 | r243428 | |
| 477 | 465 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 478 | 466 | PORT_BIT ( 0xffffff00, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 479 | 467 | |
| 480 | | PORT_START("IN0") |
| 468 | PORT_START("KEY.0") |
| 481 | 469 | PORT_BIT ( 0xfffffff0, IP_ACTIVE_LOW, IPT_UNUSED ) // explicitely discarded |
| 482 | 470 | PORT_BIT ( 0x00000001, IP_ACTIVE_LOW, IPT_MAHJONG_D ) |
| 483 | 471 | PORT_BIT ( 0x00000002, IP_ACTIVE_LOW, IPT_MAHJONG_H ) |
| 484 | 472 | PORT_BIT ( 0x00000004, IP_ACTIVE_LOW, IPT_MAHJONG_L ) |
| 485 | 473 | PORT_BIT ( 0x00000008, IP_ACTIVE_LOW, IPT_MAHJONG_PON ) |
| 486 | 474 | |
| 487 | | PORT_START("IN1") |
| 475 | PORT_START("KEY.1") |
| 488 | 476 | PORT_BIT ( 0xffffffc0, IP_ACTIVE_LOW, IPT_UNUSED ) // explicitely discarded |
| 489 | 477 | PORT_BIT ( 0x00000001, IP_ACTIVE_LOW, IPT_MAHJONG_A ) |
| 490 | 478 | PORT_BIT ( 0x00000002, IP_ACTIVE_LOW, IPT_MAHJONG_E ) |
| r243427 | r243428 | |
| 493 | 481 | PORT_BIT ( 0x00000010, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) |
| 494 | 482 | PORT_BIT ( 0x00000020, IP_ACTIVE_LOW, IPT_START1 ) |
| 495 | 483 | |
| 496 | | PORT_START("IN2") |
| 484 | PORT_START("KEY.2") |
| 497 | 485 | PORT_BIT ( 0xffffffe0, IP_ACTIVE_LOW, IPT_UNUSED ) // explicitely discarded |
| 498 | 486 | PORT_BIT ( 0x00000001, IP_ACTIVE_LOW, IPT_MAHJONG_B ) |
| 499 | 487 | PORT_BIT ( 0x00000002, IP_ACTIVE_LOW, IPT_MAHJONG_F ) |
| r243427 | r243428 | |
| 501 | 489 | PORT_BIT ( 0x00000008, IP_ACTIVE_LOW, IPT_MAHJONG_N ) |
| 502 | 490 | PORT_BIT ( 0x00000010, IP_ACTIVE_LOW, IPT_MAHJONG_REACH ) |
| 503 | 491 | |
| 504 | | PORT_START("IN3") |
| 492 | PORT_START("KEY.3") |
| 505 | 493 | PORT_BIT ( 0xffffff60, IP_ACTIVE_LOW, IPT_UNUSED ) // explicitely discarded |
| 506 | 494 | PORT_BIT ( 0x00000001, IP_ACTIVE_LOW, IPT_MAHJONG_C ) |
| 507 | 495 | PORT_BIT ( 0x00000002, IP_ACTIVE_LOW, IPT_MAHJONG_G ) |
| r243427 | r243428 | |
| 568 | 556 | MCFG_SCREEN_VISIBLE_AREA(0*8, 42*8-1, 2*8, 32*8-1) |
| 569 | 557 | MCFG_SCREEN_UPDATE_DRIVER(srmp5_state, screen_update_srmp5) |
| 570 | 558 | |
| 571 | | MCFG_PALETTE_ADD("palette", 0x1800) |
| 559 | MCFG_PALETTE_ADD("palette", 0x10000) // 0x20000? only first 0x1800 entries seem to be used outside memory test |
| 560 | MCFG_PALETTE_FORMAT(xBBBBBGGGGGRRRRR) |
| 561 | MCFG_PALETTE_MEMBITS(16) |
| 562 | |
| 572 | 563 | #ifdef DEBUG_CHAR |
| 573 | 564 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", srmp5 ) |
| 574 | 565 | #endif |
| 575 | | //MCFG_VIDEO_START_OVERRIDE(st0016_state,st0016) |
| 576 | 566 | |
| 577 | 567 | MACHINE_CONFIG_END |
| 578 | 568 | |
| r243427 | r243428 | |
| 581 | 571 | ROM_LOAD( "sx008-08.bin", 0x000000, 0x200000, CRC(d4ac54f4) SHA1(c3dc76cd71485796a0b6a960294ea96eae8c946e) ) |
| 582 | 572 | ROM_LOAD( "sx008-09.bin", 0x200000, 0x200000, CRC(5a3e6560) SHA1(92ea398f3c5e3035869f0ca5dfe7b05c90095318) ) |
| 583 | 573 | |
| 584 | | ROM_REGION32_BE( 0x200000, "user1", 0 ) |
| 585 | | ROM_LOAD32_BYTE( "sx008-14.bin", 0x00000, 0x80000, CRC(b5c55120) SHA1(0a41351c9563b2c6a00709189a917757bd6e0a24) ) |
| 586 | | ROM_LOAD32_BYTE( "sx008-13.bin", 0x00001, 0x80000, CRC(0af475e8) SHA1(24cddffa0f8c81832ae8870823d772e3b7493194) ) |
| 587 | | ROM_LOAD32_BYTE( "sx008-12.bin", 0x00002, 0x80000, CRC(43e9bb98) SHA1(e46dd98d2e1babfa12ddf2fa9b31377e8691d3a1) ) |
| 588 | | ROM_LOAD32_BYTE( "sx008-11.bin", 0x00003, 0x80000, CRC(ca15ff45) SHA1(5ee610e0bb835568c36898210a6f8394902d5b54) ) |
| 574 | ROM_REGION( 0x200000, "sub", 0 ) // "PRG00" - "PRG03" |
| 575 | ROM_LOAD32_BYTE( "sx008-11.bin", 0x00000, 0x80000, CRC(ca15ff45) SHA1(5ee610e0bb835568c36898210a6f8394902d5b54) ) |
| 576 | ROM_LOAD32_BYTE( "sx008-12.bin", 0x00001, 0x80000, CRC(43e9bb98) SHA1(e46dd98d2e1babfa12ddf2fa9b31377e8691d3a1) ) |
| 577 | ROM_LOAD32_BYTE( "sx008-13.bin", 0x00002, 0x80000, CRC(0af475e8) SHA1(24cddffa0f8c81832ae8870823d772e3b7493194) ) |
| 578 | ROM_LOAD32_BYTE( "sx008-14.bin", 0x00003, 0x80000, CRC(b5c55120) SHA1(0a41351c9563b2c6a00709189a917757bd6e0a24) ) |
| 589 | 579 | |
| 590 | | ROM_REGION( 0xf00000, "user2",0) /* gfx ? */ |
| 580 | ROM_REGION16_LE( 0x1000000, "chr",0) // "CHR00" - "CHR06" |
| 591 | 581 | ROM_LOAD( "sx008-01.bin", 0x000000, 0x200000, CRC(82dabf48) SHA1(c53e9ed0056c431eab13ab362936c25d3cc5abba) ) |
| 592 | 582 | ROM_LOAD( "sx008-02.bin", 0x200000, 0x200000, CRC(cfd2be0f) SHA1(a21f2928e08047c97443123aceba7ff4e95c6d3d) ) |
| 593 | 583 | ROM_LOAD( "sx008-03.bin", 0x400000, 0x200000, CRC(d7323b10) SHA1(94ecc17b6b8b071cf2c61bbef4aec2c6c7693c62) ) |
| r243427 | r243428 | |
| 607 | 597 | |
| 608 | 598 | m_tileram = auto_alloc_array(machine(), UINT16, 0x100000/2); |
| 609 | 599 | m_sprram = auto_alloc_array(machine(), UINT16, 0x080000/2); |
| 610 | | m_palram = auto_alloc_array(machine(), UINT16, 0x040000/2); |
| 611 | 600 | #ifdef DEBUG_CHAR |
| 612 | 601 | memset(m_tileduty, 1, 0x2000); |
| 613 | 602 | #endif |