trunk/src/mame/drivers/glass.c
r17651 | r17652 | |
79 | 79 | |
80 | 80 | static ADDRESS_MAP_START( glass_map, AS_PROGRAM, 16, glass_state ) |
81 | 81 | AM_RANGE(0x000000, 0x07ffff) AM_ROM /* ROM */ |
82 | | AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(glass_vram_w) AM_SHARE("videoram") /* Video RAM */ |
| 82 | AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(glass_vram_w) AM_SHARE("videoram") /* Video RAM */ |
83 | 83 | AM_RANGE(0x102000, 0x102fff) AM_RAM /* Extra Video RAM */ |
84 | | AM_RANGE(0x108000, 0x108007) AM_WRITEONLY AM_SHARE("vregs") /* Video Registers */ |
| 84 | AM_RANGE(0x108000, 0x108007) AM_WRITEONLY AM_SHARE("vregs") /* Video Registers */ |
85 | 85 | AM_RANGE(0x108008, 0x108009) AM_WRITE(clr_int_w) /* CLR INT Video */ |
86 | 86 | AM_RANGE(0x200000, 0x2007ff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_word_w) AM_SHARE("paletteram") /* Palette */ |
87 | | AM_RANGE(0x440000, 0x440fff) AM_RAM AM_SHARE("spriteram") /* Sprite RAM */ |
| 87 | AM_RANGE(0x440000, 0x440fff) AM_RAM AM_SHARE("spriteram") /* Sprite RAM */ |
88 | 88 | AM_RANGE(0x700000, 0x700001) AM_READ_PORT("DSW2") |
89 | 89 | AM_RANGE(0x700002, 0x700003) AM_READ_PORT("DSW1") |
90 | 90 | AM_RANGE(0x700004, 0x700005) AM_READ_PORT("P1") |
91 | 91 | AM_RANGE(0x700006, 0x700007) AM_READ_PORT("P2") |
92 | 92 | AM_RANGE(0x700008, 0x700009) AM_WRITE(glass_blitter_w) /* serial blitter */ |
93 | 93 | AM_RANGE(0x70000c, 0x70000d) AM_WRITE(OKIM6295_bankswitch_w) /* OKI6295 bankswitch */ |
94 | | AM_RANGE(0x70000e, 0x70000f) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff) /* OKI6295 status register */ |
| 94 | AM_RANGE(0x70000e, 0x70000f) AM_DEVREADWRITE8("oki", okim6295_device, read, write, 0x00ff) /* OKI6295 status register */ |
95 | 95 | AM_RANGE(0x70000a, 0x70004b) AM_WRITE(glass_coin_w) /* Coin Counters/Lockout */ |
96 | | AM_RANGE(0xfec000, 0xfeffff) AM_RAM /* Work RAM (partially shared with DS5002FP) */ |
| 96 | AM_RANGE(0xfec000, 0xfeffff) AM_RAM AM_SHARE("mainram") /* Work RAM (partially shared with DS5002FP) */ |
97 | 97 | ADDRESS_MAP_END |
98 | 98 | |
99 | 99 | |
r17651 | r17652 | |
310 | 310 | } |
311 | 311 | } |
312 | 312 | |
| 313 | /* How does the protection work? |
| 314 | |
| 315 | We know in World Rally it shares the whole of main RAM with the Dallas, with subtle reads and writes / values being checked.. so I guess this will be similar at least |
| 316 | and thus very hard to figure out if done properly |
| 317 | |
| 318 | */ |
| 319 | |
| 320 | READ16_MEMBER( glass_state::glass_mainram_r ) |
| 321 | { |
| 322 | UINT16 ret = m_mainram[offset]; |
| 323 | int pc = cpu_get_pc(&space.device()); |
| 324 | |
| 325 | if (offset == (0xfede96 - 0xfec000)>>1) |
| 326 | { |
| 327 | // this address seems important, the game will abort with 'power failure' depending on some reads, presumably refering to the power to the battery |
| 328 | |
| 329 | // there are also various code segments like the one below |
| 330 | /* |
| 331 | start: |
| 332 | tst.b this address |
| 333 | bne end |
| 334 | tst.b $fede1d.l |
| 335 | nop << why? |
| 336 | bne start |
| 337 | end: |
| 338 | */ |
| 339 | return 0x0000; |
| 340 | //printf("%06x read %06x - %04x %04x\n", pc , (offset*2 + 0xfec000), ret, mem_mask); |
| 341 | } |
| 342 | else if (offset == (0xfede1c - 0xfec000)>>1) |
| 343 | { |
| 344 | // related to above, could also be some command ack? |
| 345 | logerror("%06x read %06x - %04x %04x\n", pc, (offset*2 + 0xfec000), ret, mem_mask); |
| 346 | } |
| 347 | else if (offset == (0xfede26 - 0xfec000)>>1) |
| 348 | { |
| 349 | logerror("%06x read %06x - %04x %04x\n", pc, (offset*2 + 0xfec000), ret, mem_mask); |
| 350 | } |
| 351 | return ret; |
| 352 | } |
| 353 | |
| 354 | WRITE16_MEMBER( glass_state::glass_mainram_w ) |
| 355 | { |
| 356 | int pc = cpu_get_pc(&space.device()); |
| 357 | |
| 358 | COMBINE_DATA(&m_mainram[offset]); |
| 359 | |
| 360 | if (offset == (0xfede02 - 0xfec000)>>1) |
| 361 | { |
| 362 | // printf("%06x write %06x - %04x %04x\n", pc, (offset*2 + 0xfec000), data, mem_mask); |
| 363 | // several checks write here then expect it to appear mirrored, might be some kind of command + command ack |
| 364 | if (mem_mask & 0xff00) // sometimes mask 0xff00, but not in cases which poll for change |
| 365 | { |
| 366 | mem_mask = 0x00ff; |
| 367 | data >>=8; |
| 368 | COMBINE_DATA(&m_mainram[offset]); |
| 369 | } |
| 370 | return; |
| 371 | } |
| 372 | else if (offset == (0xfede1c - 0xfec000)>>1) |
| 373 | { |
| 374 | // see notes about 0xfede96 in read, this address seems important |
| 375 | logerror("%06x write %06x - %04x %04x\n", pc, (offset*2 + 0xfec000), data, mem_mask); |
| 376 | if (mem_mask == 0x00ff) |
| 377 | { |
| 378 | int realdata = data; |
| 379 | |
| 380 | // don't store the bits written, game checks they get cleared? |
| 381 | data &= 0xff00; |
| 382 | COMBINE_DATA(&m_mainram[offset]); |
| 383 | |
| 384 | // a command? |
| 385 | if (realdata == 0x0002) |
| 386 | { |
| 387 | // there is a check on address 0xfede26 just after writing 0002 here.. |
| 388 | offset = (0xfede26 - 0xfec000) >> 1; |
| 389 | data = 0xff00; |
| 390 | mem_mask = 0xff00; |
| 391 | COMBINE_DATA(&m_mainram[offset]); |
| 392 | } |
| 393 | } |
| 394 | return; |
| 395 | } |
| 396 | |
| 397 | } |
| 398 | |
| 399 | |
313 | 400 | DRIVER_INIT_MEMBER(glass_state,glass) |
314 | 401 | { |
315 | 402 | /* |
r17651 | r17652 | |
329 | 416 | |
330 | 417 | /* split ROM H11 */ |
331 | 418 | glass_ROM16_split_gfx(machine(), "gfx2", "gfx1", 0x0200000, 0x0200000, 0x0200000, 0x0300000); |
| 419 | |
| 420 | /* install custom handler over RAM for protection */ |
| 421 | machine().device("maincpu")->memory().space(AS_PROGRAM)->install_readwrite_handler(0xfec000, 0xfeffff, read16_delegate(FUNC(glass_state::glass_mainram_r), this), write16_delegate(FUNC(glass_state::glass_mainram_w),this)); |
| 422 | |
332 | 423 | } |
333 | 424 | |
334 | | GAME( 1993, glass, 0, glass, glass, glass_state, glass, ROT0, "Gaelco", "Glass (Ver 1.1)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) |
335 | | GAME( 1993, glass10, glass, glass, glass, glass_state, glass, ROT0, "Gaelco", "Glass (Ver 1.0)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) |
336 | | GAME( 1993, glassbrk, glass, glass, glass, glass_state, glass, ROT0, "Gaelco", "Glass (Ver 1.0, Break Edition)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) |
| 425 | GAME( 1993, glass, 0, glass, glass, glass_state, glass, ROT0, "OMK / Gaelco", "Glass (Ver 1.1)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) |
| 426 | GAME( 1993, glass10, glass, glass, glass, glass_state, glass, ROT0, "OMK / Gaelco", "Glass (Ver 1.0)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) |
| 427 | GAME( 1993, glassbrk, glass, glass, glass, glass_state, glass, ROT0, "OMK / Gaelco", "Glass (Ver 1.0, Break Edition)", GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) |