trunk/src/mame/drivers/pirates.c
| r243604 | r243605 | |
| 8 | 8 | - EEPROM doesn't work. I'm not sure what the program is trying to do. |
| 9 | 9 | The EEPROM handling might actually be related to the protection which |
| 10 | 10 | makes the game hang. |
| 11 | | See pirates_in1_r() for code which would work around the protection, |
| 11 | See prot_r() for code which would work around the protection, |
| 12 | 12 | but makes the game periodically hang for a couple of seconds; therefore, |
| 13 | 13 | for now I'm just patching out the protection check. |
| 14 | 14 | |
| r243604 | r243605 | |
| 48 | 48 | Inputs mapped by Stephh |
| 49 | 49 | |
| 50 | 50 | The game hanging is an interesting issue, the board owner has 2 copies of this game, one a prototype, |
| 51 | | on the final released version. The roms on both boards are the same, however the prototype locks up |
| 51 | one the final released version. The roms on both boards are the same, however the prototype locks up |
| 52 | 52 | just as it does in Mame at the moment. The final board does not. It would appear the prototype |
| 53 | 53 | board does not have the protection hardware correctly in place |
| 54 | 54 | |
| r243604 | r243605 | |
| 94 | 94 | #include "includes/pirates.h" |
| 95 | 95 | |
| 96 | 96 | |
| 97 | | WRITE16_MEMBER(pirates_state::pirates_out_w) |
| 97 | WRITE16_MEMBER(pirates_state::out_w) |
| 98 | 98 | { |
| 99 | 99 | if (ACCESSING_BITS_0_7) |
| 100 | 100 | { |
| r243604 | r243605 | |
| 121 | 121 | // logerror("%s: IN1_r\n",machine().describe_context()); |
| 122 | 122 | |
| 123 | 123 | #if 0 |
| 124 | | /* Pirates protection workaround. It more complicated than this... see code at |
| 124 | /* Pirates protection workaround. It's more complicated than this... see code at |
| 125 | 125 | 602e and 62a6 */ |
| 126 | 126 | /* For Genix, see 6576 for setting values and 67c2,d3b4 and dbc2 for tests. */ |
| 127 | 127 | |
| r243604 | r243605 | |
| 156 | 156 | // AM_RANGE(0x500000, 0x5007ff) AM_RAM |
| 157 | 157 | AM_RANGE(0x500000, 0x5007ff) AM_WRITEONLY AM_SHARE("spriteram") |
| 158 | 158 | // AM_RANGE(0x500800, 0x50080f) AM_WRITENOP |
| 159 | | AM_RANGE(0x600000, 0x600001) AM_WRITE(pirates_out_w) |
| 159 | AM_RANGE(0x600000, 0x600001) AM_WRITE(out_w) |
| 160 | 160 | AM_RANGE(0x700000, 0x700001) AM_WRITEONLY AM_SHARE("scroll") // scroll reg |
| 161 | 161 | AM_RANGE(0x800000, 0x803fff) AM_RAM_DEVWRITE("palette", palette_device, write) AM_SHARE("palette") |
| 162 | 162 | AM_RANGE(0x900000, 0x90017f) AM_RAM // more of tilemaps ? |
| 163 | | AM_RANGE(0x900180, 0x90137f) AM_RAM_WRITE(pirates_tx_tileram_w) AM_SHARE("tx_tileram") |
| 164 | | AM_RANGE(0x901380, 0x902a7f) AM_RAM_WRITE(pirates_fg_tileram_w) AM_SHARE("fg_tileram") |
| 163 | AM_RANGE(0x900180, 0x90137f) AM_RAM_WRITE(tx_tileram_w) AM_SHARE("tx_tileram") |
| 164 | AM_RANGE(0x901380, 0x902a7f) AM_RAM_WRITE(fg_tileram_w) AM_SHARE("fg_tileram") |
| 165 | 165 | // AM_RANGE(0x902580, 0x902a7f) AM_RAM // more of tilemaps ? |
| 166 | | AM_RANGE(0x902a80, 0x904187) AM_RAM_WRITE(pirates_bg_tileram_w) AM_SHARE("bg_tileram") |
| 166 | AM_RANGE(0x902a80, 0x904187) AM_RAM_WRITE(bg_tileram_w) AM_SHARE("bg_tileram") |
| 167 | 167 | // AM_RANGE(0x903c80, 0x904187) AM_RAM // more of tilemaps ? |
| 168 | 168 | AM_RANGE(0xa00000, 0xa00001) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff) |
| 169 | 169 | ADDRESS_MAP_END |
| r243604 | r243605 | |
| 261 | 261 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) |
| 262 | 262 | MCFG_SCREEN_SIZE(36*8, 32*8) |
| 263 | 263 | MCFG_SCREEN_VISIBLE_AREA(0*8, 36*8-1, 2*8, 30*8-1) |
| 264 | | MCFG_SCREEN_UPDATE_DRIVER(pirates_state, screen_update_pirates) |
| 264 | MCFG_SCREEN_UPDATE_DRIVER(pirates_state, screen_update) |
| 265 | 265 | MCFG_SCREEN_PALETTE("palette") |
| 266 | 266 | |
| 267 | 267 | MCFG_PALETTE_ADD("palette", 0x2000) |
| r243604 | r243605 | |
| 323 | 323 | |
| 324 | 324 | /* Init */ |
| 325 | 325 | |
| 326 | | void pirates_state::pirates_decrypt_68k() |
| 326 | void pirates_state::decrypt_68k() |
| 327 | 327 | { |
| 328 | 328 | UINT16 *rom = (UINT16 *)memregion("maincpu")->base(); |
| 329 | 329 | size_t rom_size = memregion("maincpu")->bytes(); |
| r243604 | r243605 | |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | | void pirates_state::pirates_decrypt_p() |
| 349 | void pirates_state::decrypt_p() |
| 350 | 350 | { |
| 351 | 351 | int rom_size; |
| 352 | 352 | UINT8 *rom; |
| r243604 | r243605 | |
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | | void pirates_state::pirates_decrypt_s() |
| 372 | void pirates_state::decrypt_s() |
| 373 | 373 | { |
| 374 | 374 | int rom_size; |
| 375 | 375 | UINT8 *rom; |
| r243604 | r243605 | |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
| 396 | | void pirates_state::pirates_decrypt_oki() |
| 396 | void pirates_state::decrypt_oki() |
| 397 | 397 | { |
| 398 | 398 | int rom_size; |
| 399 | 399 | UINT8 *rom; |
| r243604 | r243605 | |
| 418 | 418 | { |
| 419 | 419 | UINT16 *rom = (UINT16 *)memregion("maincpu")->base(); |
| 420 | 420 | |
| 421 | | pirates_decrypt_68k(); |
| 422 | | pirates_decrypt_p(); |
| 423 | | pirates_decrypt_s(); |
| 424 | | pirates_decrypt_oki(); |
| 421 | decrypt_68k(); |
| 422 | decrypt_p(); |
| 423 | decrypt_s(); |
| 424 | decrypt_oki(); |
| 425 | 425 | |
| 426 | 426 | /* patch out protection check */ |
| 427 | 427 | rom[0x62c0/2] = 0x6006; // beq -> bra |
| r243604 | r243605 | |
| 431 | 431 | |
| 432 | 432 | DRIVER_INIT_MEMBER(pirates_state,genix) |
| 433 | 433 | { |
| 434 | | pirates_decrypt_68k(); |
| 435 | | pirates_decrypt_p(); |
| 436 | | pirates_decrypt_s(); |
| 437 | | pirates_decrypt_oki(); |
| 434 | decrypt_68k(); |
| 435 | decrypt_p(); |
| 436 | decrypt_s(); |
| 437 | decrypt_oki(); |
| 438 | 438 | |
| 439 | 439 | /* If this value is increased then something has gone wrong and the protection failed */ |
| 440 | 440 | /* Write-protect it for now */ |
| r243604 | r243605 | |
| 444 | 444 | |
| 445 | 445 | /* GAME */ |
| 446 | 446 | |
| 447 | | GAME( 1994, pirates, 0, pirates, pirates, pirates_state, pirates, 0, "NIX", "Pirates", 0 ) |
| 448 | | GAME( 1994, genix, 0, pirates, pirates, pirates_state, genix, 0, "NIX", "Genix Family", 0 ) |
| 447 | GAME( 1994, pirates, 0, pirates, pirates, pirates_state, pirates, 0, "NIX", "Pirates", GAME_SUPPORTS_SAVE ) |
| 448 | GAME( 1994, genix, 0, pirates, pirates, pirates_state, genix, 0, "NIX", "Genix Family", GAME_SUPPORTS_SAVE ) |
trunk/src/mame/includes/pirates.h
| r243604 | r243605 | |
| 6 | 6 | public: |
| 7 | 7 | pirates_state(const machine_config &mconfig, device_type type, const char *tag) |
| 8 | 8 | : driver_device(mconfig, type, tag), |
| 9 | m_maincpu(*this, "maincpu"), |
| 10 | m_eeprom(*this, "eeprom"), |
| 11 | m_oki(*this, "oki"), |
| 12 | m_gfxdecode(*this, "gfxdecode"), |
| 13 | m_palette(*this, "palette"), |
| 9 | 14 | m_spriteram(*this, "spriteram"), |
| 10 | 15 | m_scroll(*this, "scroll"), |
| 11 | 16 | m_tx_tileram(*this, "tx_tileram"), |
| 12 | 17 | m_fg_tileram(*this, "fg_tileram"), |
| 13 | | m_bg_tileram(*this, "bg_tileram"), |
| 14 | | m_maincpu(*this, "maincpu"), |
| 15 | | m_eeprom(*this, "eeprom"), |
| 16 | | m_oki(*this, "oki"), |
| 17 | | m_gfxdecode(*this, "gfxdecode"), |
| 18 | | m_palette(*this, "palette") { } |
| 18 | m_bg_tileram(*this, "bg_tileram") { } |
| 19 | 19 | |
| 20 | required_device<cpu_device> m_maincpu; |
| 21 | required_device<eeprom_serial_93cxx_device> m_eeprom; |
| 22 | required_device<okim6295_device> m_oki; |
| 23 | required_device<gfxdecode_device> m_gfxdecode; |
| 24 | required_device<palette_device> m_palette; |
| 25 | |
| 20 | 26 | required_shared_ptr<UINT16> m_spriteram; |
| 21 | 27 | required_shared_ptr<UINT16> m_scroll; |
| 22 | 28 | required_shared_ptr<UINT16> m_tx_tileram; |
| 23 | 29 | required_shared_ptr<UINT16> m_fg_tileram; |
| 24 | 30 | required_shared_ptr<UINT16> m_bg_tileram; |
| 31 | |
| 25 | 32 | tilemap_t *m_tx_tilemap; |
| 26 | 33 | tilemap_t *m_fg_tilemap; |
| 27 | 34 | tilemap_t *m_bg_tilemap; |
| 28 | | DECLARE_WRITE16_MEMBER(pirates_out_w); |
| 35 | |
| 36 | DECLARE_WRITE16_MEMBER(out_w); |
| 37 | DECLARE_WRITE16_MEMBER(tx_tileram_w); |
| 38 | DECLARE_WRITE16_MEMBER(fg_tileram_w); |
| 39 | DECLARE_WRITE16_MEMBER(bg_tileram_w); |
| 29 | 40 | DECLARE_READ16_MEMBER(genix_prot_r); |
| 30 | | DECLARE_WRITE16_MEMBER(pirates_tx_tileram_w); |
| 31 | | DECLARE_WRITE16_MEMBER(pirates_fg_tileram_w); |
| 32 | | DECLARE_WRITE16_MEMBER(pirates_bg_tileram_w); |
| 41 | |
| 33 | 42 | DECLARE_CUSTOM_INPUT_MEMBER(prot_r); |
| 43 | |
| 34 | 44 | DECLARE_DRIVER_INIT(pirates); |
| 35 | 45 | DECLARE_DRIVER_INIT(genix); |
| 46 | |
| 36 | 47 | TILE_GET_INFO_MEMBER(get_tx_tile_info); |
| 37 | 48 | TILE_GET_INFO_MEMBER(get_fg_tile_info); |
| 38 | 49 | TILE_GET_INFO_MEMBER(get_bg_tile_info); |
| 50 | |
| 39 | 51 | virtual void video_start(); |
| 40 | | UINT32 screen_update_pirates(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 52 | |
| 53 | UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 41 | 54 | void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 42 | | void pirates_decrypt_68k(); |
| 43 | | void pirates_decrypt_p(); |
| 44 | | void pirates_decrypt_s(); |
| 45 | | void pirates_decrypt_oki(); |
| 46 | | required_device<cpu_device> m_maincpu; |
| 47 | | required_device<eeprom_serial_93cxx_device> m_eeprom; |
| 48 | | required_device<okim6295_device> m_oki; |
| 49 | | required_device<gfxdecode_device> m_gfxdecode; |
| 50 | | required_device<palette_device> m_palette; |
| 55 | |
| 56 | void decrypt_68k(); |
| 57 | void decrypt_p(); |
| 58 | void decrypt_s(); |
| 59 | void decrypt_oki(); |
| 51 | 60 | }; |