Previous 199869 Revisions Next

r25413 Tuesday 24th September, 2013 at 15:55:45 UTC by hap
1943.c: Improved protection emulation [Dave]
[src/mame/drivers]1943.c
[src/mame/includes]1943.h

trunk/src/mame/includes/1943.h
r25412r25413
99public:
1010   _1943_state(const machine_config &mconfig, device_type type, const char *tag)
1111      : driver_device(mconfig, type, tag),
12      m_maincpu(*this, "maincpu"),
1213      m_videoram(*this, "videoram"),
1314      m_colorram(*this, "colorram"),
1415      m_scrollx(*this, "scrollx"),
1516      m_scrolly(*this, "scrolly"),
1617      m_bgscrollx(*this, "bgscrollx"),
17      m_spriteram(*this, "spriteram"),
18      m_maincpu(*this, "maincpu") { }
18      m_spriteram(*this, "spriteram")
19   { }
1920
20   /* memory pointers */
21   /* devices / memory pointers */
22   required_device<cpu_device> m_maincpu;
2123   required_shared_ptr<UINT8> m_videoram;
2224   required_shared_ptr<UINT8> m_colorram;
2325   required_shared_ptr<UINT8> m_scrollx;
r25412r25413
3335   int     m_obj_on;
3436   int     m_bg1_on;
3537   int     m_bg2_on;
38
39   /* protection */
40   UINT8    m_prot_value;
41   DECLARE_WRITE8_MEMBER(c1943_protection_w);
3642   DECLARE_READ8_MEMBER(c1943_protection_r);
3743   DECLARE_READ8_MEMBER(_1943b_c007_r);
44
3845   DECLARE_WRITE8_MEMBER(c1943_videoram_w);
3946   DECLARE_WRITE8_MEMBER(c1943_colorram_w);
4047   DECLARE_WRITE8_MEMBER(c1943_c804_w);
r25412r25413
4451   TILE_GET_INFO_MEMBER(c1943_get_bg2_tile_info);
4552   TILE_GET_INFO_MEMBER(c1943_get_bg_tile_info);
4653   TILE_GET_INFO_MEMBER(c1943_get_fg_tile_info);
54   virtual void machine_start();
4755   virtual void machine_reset();
4856   virtual void video_start();
4957   virtual void palette_init();
5058   UINT32 screen_update_1943(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
5159   void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority );
52   required_device<cpu_device> m_maincpu;
5360};
trunk/src/mame/drivers/1943.c
r25412r25413
3434#include "includes/1943.h"
3535
3636
37/* Read/Write Handlers */
37/* Protection Handlers */
3838
39WRITE8_MEMBER(_1943_state::c1943_protection_w)
40{
41   m_prot_value = data;
42}
43
3944READ8_MEMBER(_1943_state::c1943_protection_r)
4045{
41   /*
42       This is a protection check. The game crashes (thru a jump to 0x8000)
43       if a read from this address doesn't return the value it expects.
44   */
46   // The game crashes (through a jump to 0x8000) if the return value is not what it expects..
4547
46   int data = space.device().state().state_int(Z80_BC) >> 8;
47//  logerror("protection read, PC: %04x Result:%02x\n", space.device().safe_pc(), data);
48   return data;
48   switch (m_prot_value)
49   {
50      // This data comes from a table at $21a containing 64 entries, even is "case", odd is return value.
51      case 0x24: return 0x1d;
52      case 0x60: return 0xf7;
53      case 0x01: return 0xac;
54      case 0x55: return 0x50;
55      case 0x56: return 0xe2;
56      case 0x2a: return 0x58;
57      case 0xa8: return 0x13;
58      case 0x22: return 0x3e;
59      case 0x3b: return 0x5a;
60      case 0x1e: return 0x1b;
61      case 0xe9: return 0x41;
62      case 0x7d: return 0xd5;
63      case 0x43: return 0x54;
64      case 0x37: return 0x6f;
65      case 0x4c: return 0x59;
66      case 0x5f: return 0x56;
67      case 0x3f: return 0x2f;
68      case 0x3e: return 0x3d;
69      case 0xfb: return 0x36;
70      case 0x1d: return 0x3b;
71      case 0x27: return 0xae;
72      case 0x26: return 0x39;
73      case 0x58: return 0x3c;
74      case 0x32: return 0x51;
75      case 0x1a: return 0xa8;
76      case 0xbc: return 0x33;
77      case 0x30: return 0x4a;
78      case 0x64: return 0x12;
79      case 0x11: return 0x40;
80      case 0x33: return 0x35;
81      case 0x09: return 0x17;
82      case 0x25: return 0x04;
83   }
84
85   return 0;
4986}
5087
88// The bootleg expects 0x00 to be returned from the protection reads because the protection has been patched out.
89READ8_MEMBER(_1943_state::_1943b_c007_r)
90{
91   return 0;
92}
93
94
5195/* Memory Maps */
5296
5397static ADDRESS_MAP_START( c1943_map, AS_PROGRAM, 8, _1943_state )
r25412r25413
62106   AM_RANGE(0xc800, 0xc800) AM_WRITE(soundlatch_byte_w)
63107   AM_RANGE(0xc804, 0xc804) AM_WRITE(c1943_c804_w) // ROM bank switch, screen flip
64108   AM_RANGE(0xc806, 0xc806) AM_WRITE(watchdog_reset_w)
65   AM_RANGE(0xc807, 0xc807) AM_WRITENOP // ???
109   AM_RANGE(0xc807, 0xc807) AM_WRITE(c1943_protection_w)
66110   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(c1943_videoram_w) AM_SHARE("videoram")
67111   AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(c1943_colorram_w) AM_SHARE("colorram")
68112   AM_RANGE(0xd800, 0xd801) AM_RAM AM_SHARE("scrollx")
r25412r25413
243287
244288/* Machine Driver */
245289
290void _1943_state::machine_start()
291{
292   save_item(NAME(m_prot_value));
293}
294
246295void _1943_state::machine_reset()
247296{
248297   m_char_on = 0;
249298   m_obj_on = 0;
250299   m_bg1_on = 0;
251300   m_bg2_on = 0;
301   m_prot_value = 0;
252302}
253303
254304static MACHINE_CONFIG_START( 1943, _1943_state )
255305
256306   // basic machine hardware
257   MCFG_CPU_ADD("maincpu", Z80, XTAL_24MHz/4) /* verified on pcb */
307   MCFG_CPU_ADD("maincpu", Z80, XTAL_24MHz/4) /* verified on pcb */
258308   MCFG_CPU_PROGRAM_MAP(c1943_map)
259309   MCFG_CPU_VBLANK_INT_DRIVER("screen", _1943_state,  irq0_line_hold)
260310
261311   MCFG_CPU_ADD("audiocpu", Z80, XTAL_24MHz/8) /* verified on pcb */
262312   MCFG_CPU_PROGRAM_MAP(sound_map)
263   MCFG_CPU_PERIODIC_INT_DRIVER(_1943_state, irq0_line_hold, 4*60)
313   MCFG_CPU_PERIODIC_INT_DRIVER(_1943_state, irq0_line_hold, 4*60)
264314
265
266315   // video hardware
267316   MCFG_SCREEN_ADD("screen", RASTER)
268317   MCFG_SCREEN_REFRESH_RATE(60)
r25412r25413
274323   MCFG_GFXDECODE(1943)
275324   MCFG_PALETTE_LENGTH(32*4+16*16+16*16+16*16)
276325
277
278326   // sound hardware
279327   MCFG_SPEAKER_STANDARD_MONO("mono")
280328
281   MCFG_SOUND_ADD("ym1", YM2203, XTAL_24MHz/16)    /* verified on pcb */
329   MCFG_SOUND_ADD("ym1", YM2203, XTAL_24MHz/16) /* verified on pcb */
282330   MCFG_SOUND_ROUTE(0, "mono", 0.15)
283331   MCFG_SOUND_ROUTE(1, "mono", 0.15)
284332   MCFG_SOUND_ROUTE(2, "mono", 0.15)
285333   MCFG_SOUND_ROUTE(3, "mono", 0.10)
286334
287   MCFG_SOUND_ADD("ym2", YM2203, XTAL_24MHz/16)    /* verified on pcb */
335   MCFG_SOUND_ADD("ym2", YM2203, XTAL_24MHz/16) /* verified on pcb */
288336   MCFG_SOUND_ROUTE(0, "mono", 0.15)
289337   MCFG_SOUND_ROUTE(1, "mono", 0.15)
290338   MCFG_SOUND_ROUTE(2, "mono", 0.15)
r25412r25413
642690   membank("bank1")->configure_entries(0, 8, &ROM[0x10000], 0x4000);
643691}
644692
645READ8_MEMBER(_1943_state::_1943b_c007_r){ return 0; }
646
647693DRIVER_INIT_MEMBER(_1943_state,1943b)
648694{
649695   DRIVER_INIT_CALL(1943);
650   //it expects 0x00 to be returned from the protection reads because the protection has been patched out.
651   //AM_RANGE(0xc007, 0xc007) AM_READ(c1943_protection_r)
696
652697   m_maincpu->space(AS_PROGRAM).install_read_handler(0xc007, 0xc007, read8_delegate(FUNC(_1943_state::_1943b_c007_r),this));
653
654698}
655699
656700/* Game Drivers */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team