trunk/src/mess/drivers/gamate.c
| r242494 | r242495 | |
| 19 | 19 | , m_cart(*this, "cartslot") |
| 20 | 20 | // , m_gfxdecode(*this, "gfxdecode") |
| 21 | 21 | , m_io_joy(*this, "JOY") |
| 22 | | , m_palette(*this, "palette") |
| 23 | | , m_cart_rom(*this, "cart_rom") |
| 22 | , m_palette(*this, "palette") |
| 24 | 23 | , m_bios(*this, "bios") |
| 25 | 24 | { } |
| 26 | 25 | |
| r242494 | r242495 | |
| 28 | 27 | DECLARE_READ8_MEMBER(protection_r); |
| 29 | 28 | DECLARE_READ8_MEMBER(gamate_cart_protection_r); |
| 30 | 29 | DECLARE_WRITE8_MEMBER(gamate_cart_protection_w); |
| 30 | DECLARE_WRITE8_MEMBER(cart_bankswitch_w); |
| 31 | 31 | DECLARE_READ8_MEMBER(gamate_video_r); |
| 32 | 32 | DECLARE_READ8_MEMBER(gamate_pad_r); |
| 33 | 33 | DECLARE_WRITE8_MEMBER(gamate_video_w); |
| r242494 | r242495 | |
| 49 | 49 | struct { |
| 50 | 50 | bool write; |
| 51 | 51 | bool page2; // else page1 |
| 52 | | UINT8 ypos, xpos/*tennis*/; |
| 52 | UINT8 ypos, xpos/*tennis*/; |
| 53 | 53 | UINT8 data[2][0x100][0x20]; |
| 54 | 54 | } bitmap; |
| 55 | 55 | UINT8 x, y; |
| r242494 | r242495 | |
| 69 | 69 | // required_device<gfxdecode_device> m_gfxdecode; |
| 70 | 70 | required_ioport m_io_joy; |
| 71 | 71 | required_device<palette_device> m_palette; |
| 72 | | required_shared_ptr<UINT8> m_cart_rom; |
| 73 | 72 | required_shared_ptr<UINT8> m_bios; |
| 74 | 73 | emu_timer *timer1; |
| 75 | 74 | emu_timer *timer2; |
| r242494 | r242495 | |
| 82 | 81 | card_protection.failed= card_protection.failed || ((card_protection.cartridge_byte&0x80)!=0) != ((data&4)!=0); |
| 83 | 82 | card_protection.bit_shifter++; |
| 84 | 83 | if (card_protection.bit_shifter>=8) { |
| 85 | | card_protection.cartridge_byte=m_cart_rom[card_protection.address++]; |
| 84 | card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++]; |
| 86 | 85 | card_protection.bit_shifter=0; |
| 87 | 86 | } |
| 88 | 87 | break; |
| r242494 | r242495 | |
| 98 | 97 | card_protection.bit_shifter++; |
| 99 | 98 | if (card_protection.bit_shifter>=8) { |
| 100 | 99 | card_protection.bit_shifter=0; |
| 101 | | card_protection.cartridge_byte=m_cart_rom[card_protection.address++]; |
| 100 | card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++]; |
| 102 | 101 | card_protection.unprotected=true; |
| 103 | 102 | if (!card_protection.failed) { |
| 104 | 103 | } // now protection chip on cartridge activates cartridge chip select on cpu accesses |
| r242494 | r242495 | |
| 135 | 134 | } |
| 136 | 135 | } |
| 137 | 136 | |
| 137 | WRITE8_MEMBER( gamate_state::cart_bankswitch_w ) |
| 138 | { |
| 139 | membank("bank")->set_base(m_cart->get_rom_base()+0x4000*data); |
| 140 | } |
| 141 | |
| 138 | 142 | READ8_MEMBER( gamate_state::gamate_video_r ) |
| 139 | 143 | { |
| 140 | 144 | if (offset!=6) return 0; |
| r242494 | r242495 | |
| 177 | 181 | AM_RANGE(0x5000, 0x5007) AM_READWRITE(gamate_video_r, gamate_video_w) |
| 178 | 182 | AM_RANGE(0x5a00, 0x5a00) AM_READ(protection_r) |
| 179 | 183 | |
| 180 | | AM_RANGE(0x6000, 0xdfff) AM_ROM AM_SHARE("cart_rom") |
| 184 | AM_RANGE(0x6000, 0x9fff) AM_ROM |
| 185 | AM_RANGE(0xa000, 0xdfff) AM_READ_BANK("bank") |
| 186 | |
| 181 | 187 | AM_RANGE(0x6000, 0x6002) AM_READWRITE(gamate_cart_protection_r, gamate_cart_protection_w) |
| 182 | 188 | // AM_RANGE(0x6000, 0xdfff) AM_READWRITE(gamate_cart_r, gamate_cart_w) |
| 189 | AM_RANGE(0xc000, 0xc000) AM_WRITE(cart_bankswitch_w) |
| 190 | |
| 183 | 191 | AM_RANGE(0xf000, 0xffff) AM_ROM AM_SHARE("bios") |
| 184 | 192 | ADDRESS_MAP_END |
| 185 | 193 | |
| r242494 | r242495 | |
| 259 | 267 | UINT32 gamate_state::screen_update_gamate(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 260 | 268 | { |
| 261 | 269 | int x, y, j; |
| 262 | | for (y=0;y<160;y++) { |
| 263 | | for (x=0, j=0;x<160;x+=8, j++) { |
| 264 | | // UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)&0xff][j+video.bitmap.xpos/8]; |
| 265 | | // UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)&0xff][j+video.bitmap.xpos/8]; |
| 266 | | UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)%200][j]; // kill shot, tornade |
| 267 | | UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)%200][j]; |
| 268 | | BlitPlane(&bitmap.pix16(y, x+4), d1, d2); |
| 269 | | BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4); |
| 270 | for (y=0;y<152;y++) { |
| 271 | for (x=-(video.bitmap.xpos&7), j=0;x<160;x+=8, j++) { |
| 272 | UINT8 d1=video.bitmap.data[0][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; |
| 273 | UINT8 d2=video.bitmap.data[1][(y+video.bitmap.ypos)&0xff][(j+video.bitmap.xpos/8)&0x1f]; |
| 274 | BlitPlane(&bitmap.pix16(y, x+4), d1, d2); |
| 275 | BlitPlane(&bitmap.pix16(y, x), d1>>4, d2>>4); |
| 270 | 276 | } |
| 271 | 277 | } |
| 272 | | return 0; |
| 278 | return 0; |
| 273 | 279 | } |
| 274 | 280 | |
| 275 | 281 | DRIVER_INIT_MEMBER(gamate_state,gamate) |
| r242494 | r242495 | |
| 284 | 290 | void gamate_state::machine_start() |
| 285 | 291 | { |
| 286 | 292 | if (m_cart->exists()) { |
| 287 | | m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0xdfff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart)); |
| 293 | m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x9fff, read8_delegate(FUNC(generic_slot_device::read_rom),(generic_slot_device*)m_cart)); |
| 288 | 294 | // m_maincpu->space(AS_PROGRAM).install_read_handler(0x6000, 0x6000, READ8_DELEGATE(gamate_state, gamate_cart_protection_r)); |
| 295 | membank("bank")->set_base(m_cart->get_rom_base()+0x4000); |
| 289 | 296 | } |
| 290 | 297 | m_bios[0xdf1]=0xea; m_bios[0xdf2]=0xea; // $47 protection readback |
| 291 | 298 | card_protection.address=0x6005-0x6001; |
| 292 | 299 | card_protection.bit_shifter=0; |
| 293 | | card_protection.cartridge_byte=m_cart_rom[card_protection.address++]; |
| 300 | card_protection.cartridge_byte=m_cart->get_rom_base()[card_protection.address++];//m_cart_rom[card_protection.address++]; |
| 294 | 301 | card_protection.failed=false; |
| 295 | 302 | card_protection.unprotected=false; |
| 296 | 303 | timer2->enable(TRUE); |
| r242494 | r242495 | |
| 335 | 342 | |
| 336 | 343 | MCFG_SCREEN_ADD("screen", LCD) |
| 337 | 344 | MCFG_SCREEN_REFRESH_RATE(60) |
| 338 | | #ifdef SHOW_TILEMAP |
| 339 | | MCFG_SCREEN_SIZE(256, 152+256) |
| 340 | | MCFG_SCREEN_VISIBLE_AREA(0, 256-1, 0, 152+256-1) |
| 341 | | #else |
| 342 | 345 | MCFG_SCREEN_SIZE(160, 152) |
| 343 | 346 | MCFG_SCREEN_VISIBLE_AREA(0, 160-1, 0, 152-1) |
| 344 | | #endif |
| 345 | 347 | MCFG_SCREEN_UPDATE_DRIVER(gamate_state, screen_update_gamate) |
| 346 | 348 | MCFG_SCREEN_PALETTE("palette") |
| 347 | 349 | |