Previous 199869 Revisions Next

r17652 Wednesday 5th September, 2012 at 09:33:11 UTC by Tafoid
An attempt to understand sand document ome of the protection in 'glass' before I decided it was pointless and a completely lost cause.  From Haze (nw)
[src/mame/drivers]glass.c
[src/mame/includes]glass.h

trunk/src/mame/includes/glass.h
r17651r17652
1111      : driver_device(mconfig, type, tag) ,
1212      m_videoram(*this, "videoram"),
1313      m_vregs(*this, "vregs"),
14      m_spriteram(*this, "spriteram"){ }
14      m_spriteram(*this, "spriteram"),
15      m_mainram(*this, "mainram")
16   { }
1517
1618   /* memory pointers */
1719   required_shared_ptr<UINT16> m_videoram;
1820   required_shared_ptr<UINT16> m_vregs;
1921   required_shared_ptr<UINT16> m_spriteram;
22   required_shared_ptr<UINT16> m_mainram;
2023//      UINT16 *    m_paletteram;    // currently this uses generic palette handling
2124
2225   /* video-related */
r17651r17652
3336   DECLARE_WRITE16_MEMBER(glass_coin_w);
3437   DECLARE_WRITE16_MEMBER(glass_blitter_w);
3538   DECLARE_WRITE16_MEMBER(glass_vram_w);
39
40   DECLARE_READ16_MEMBER( glass_mainram_r );
41   DECLARE_WRITE16_MEMBER( glass_mainram_w );
42
3643   DECLARE_DRIVER_INIT(glass);
3744};
3845
trunk/src/mame/drivers/glass.c
r17651r17652
7979
8080static ADDRESS_MAP_START( glass_map, AS_PROGRAM, 16, glass_state )
8181   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 */
8383   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 */
8585   AM_RANGE(0x108008, 0x108009) AM_WRITE(clr_int_w)                                          /* CLR INT Video */
8686   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 */
8888   AM_RANGE(0x700000, 0x700001) AM_READ_PORT("DSW2")
8989   AM_RANGE(0x700002, 0x700003) AM_READ_PORT("DSW1")
9090   AM_RANGE(0x700004, 0x700005) AM_READ_PORT("P1")
9191   AM_RANGE(0x700006, 0x700007) AM_READ_PORT("P2")
9292   AM_RANGE(0x700008, 0x700009) AM_WRITE(glass_blitter_w)                                       /* serial blitter */
9393   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 */
9595   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) */
9797ADDRESS_MAP_END
9898
9999
r17651r17652
310310   }
311311}
312312
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
320READ16_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
354WRITE16_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
313400DRIVER_INIT_MEMBER(glass_state,glass)
314401{
315402   /*
r17651r17652
329416
330417   /* split ROM H11 */
331418   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
332423}
333424
334GAME( 1993, glass,    0,     glass, glass, glass_state, glass, ROT0, "Gaelco", "Glass (Ver 1.1)",                GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
335GAME( 1993, glass10,  glass, glass, glass, glass_state, glass, ROT0, "Gaelco", "Glass (Ver 1.0)",                GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
336GAME( 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 )
425GAME( 1993, glass,    0,     glass, glass, glass_state, glass, ROT0, "OMK / Gaelco", "Glass (Ver 1.1)",                GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
426GAME( 1993, glass10,  glass, glass, glass, glass_state, glass, ROT0, "OMK / Gaelco", "Glass (Ver 1.0)",                GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
427GAME( 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 )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team