trunk/src/mame/includes/1943.h
| r25412 | r25413 | |
| 9 | 9 | public: |
| 10 | 10 | _1943_state(const machine_config &mconfig, device_type type, const char *tag) |
| 11 | 11 | : driver_device(mconfig, type, tag), |
| 12 | m_maincpu(*this, "maincpu"), |
| 12 | 13 | m_videoram(*this, "videoram"), |
| 13 | 14 | m_colorram(*this, "colorram"), |
| 14 | 15 | m_scrollx(*this, "scrollx"), |
| 15 | 16 | m_scrolly(*this, "scrolly"), |
| 16 | 17 | m_bgscrollx(*this, "bgscrollx"), |
| 17 | | m_spriteram(*this, "spriteram"), |
| 18 | | m_maincpu(*this, "maincpu") { } |
| 18 | m_spriteram(*this, "spriteram") |
| 19 | { } |
| 19 | 20 | |
| 20 | | /* memory pointers */ |
| 21 | /* devices / memory pointers */ |
| 22 | required_device<cpu_device> m_maincpu; |
| 21 | 23 | required_shared_ptr<UINT8> m_videoram; |
| 22 | 24 | required_shared_ptr<UINT8> m_colorram; |
| 23 | 25 | required_shared_ptr<UINT8> m_scrollx; |
| r25412 | r25413 | |
| 33 | 35 | int m_obj_on; |
| 34 | 36 | int m_bg1_on; |
| 35 | 37 | int m_bg2_on; |
| 38 | |
| 39 | /* protection */ |
| 40 | UINT8 m_prot_value; |
| 41 | DECLARE_WRITE8_MEMBER(c1943_protection_w); |
| 36 | 42 | DECLARE_READ8_MEMBER(c1943_protection_r); |
| 37 | 43 | DECLARE_READ8_MEMBER(_1943b_c007_r); |
| 44 | |
| 38 | 45 | DECLARE_WRITE8_MEMBER(c1943_videoram_w); |
| 39 | 46 | DECLARE_WRITE8_MEMBER(c1943_colorram_w); |
| 40 | 47 | DECLARE_WRITE8_MEMBER(c1943_c804_w); |
| r25412 | r25413 | |
| 44 | 51 | TILE_GET_INFO_MEMBER(c1943_get_bg2_tile_info); |
| 45 | 52 | TILE_GET_INFO_MEMBER(c1943_get_bg_tile_info); |
| 46 | 53 | TILE_GET_INFO_MEMBER(c1943_get_fg_tile_info); |
| 54 | virtual void machine_start(); |
| 47 | 55 | virtual void machine_reset(); |
| 48 | 56 | virtual void video_start(); |
| 49 | 57 | virtual void palette_init(); |
| 50 | 58 | UINT32 screen_update_1943(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); |
| 51 | 59 | void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int priority ); |
| 52 | | required_device<cpu_device> m_maincpu; |
| 53 | 60 | }; |
trunk/src/mame/drivers/1943.c
| r25412 | r25413 | |
| 34 | 34 | #include "includes/1943.h" |
| 35 | 35 | |
| 36 | 36 | |
| 37 | | /* Read/Write Handlers */ |
| 37 | /* Protection Handlers */ |
| 38 | 38 | |
| 39 | WRITE8_MEMBER(_1943_state::c1943_protection_w) |
| 40 | { |
| 41 | m_prot_value = data; |
| 42 | } |
| 43 | |
| 39 | 44 | READ8_MEMBER(_1943_state::c1943_protection_r) |
| 40 | 45 | { |
| 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.. |
| 45 | 47 | |
| 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; |
| 49 | 86 | } |
| 50 | 87 | |
| 88 | // The bootleg expects 0x00 to be returned from the protection reads because the protection has been patched out. |
| 89 | READ8_MEMBER(_1943_state::_1943b_c007_r) |
| 90 | { |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | |
| 51 | 95 | /* Memory Maps */ |
| 52 | 96 | |
| 53 | 97 | static ADDRESS_MAP_START( c1943_map, AS_PROGRAM, 8, _1943_state ) |
| r25412 | r25413 | |
| 62 | 106 | AM_RANGE(0xc800, 0xc800) AM_WRITE(soundlatch_byte_w) |
| 63 | 107 | AM_RANGE(0xc804, 0xc804) AM_WRITE(c1943_c804_w) // ROM bank switch, screen flip |
| 64 | 108 | 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) |
| 66 | 110 | AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(c1943_videoram_w) AM_SHARE("videoram") |
| 67 | 111 | AM_RANGE(0xd400, 0xd7ff) AM_RAM_WRITE(c1943_colorram_w) AM_SHARE("colorram") |
| 68 | 112 | AM_RANGE(0xd800, 0xd801) AM_RAM AM_SHARE("scrollx") |
| r25412 | r25413 | |
| 243 | 287 | |
| 244 | 288 | /* Machine Driver */ |
| 245 | 289 | |
| 290 | void _1943_state::machine_start() |
| 291 | { |
| 292 | save_item(NAME(m_prot_value)); |
| 293 | } |
| 294 | |
| 246 | 295 | void _1943_state::machine_reset() |
| 247 | 296 | { |
| 248 | 297 | m_char_on = 0; |
| 249 | 298 | m_obj_on = 0; |
| 250 | 299 | m_bg1_on = 0; |
| 251 | 300 | m_bg2_on = 0; |
| 301 | m_prot_value = 0; |
| 252 | 302 | } |
| 253 | 303 | |
| 254 | 304 | static MACHINE_CONFIG_START( 1943, _1943_state ) |
| 255 | 305 | |
| 256 | 306 | // 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 */ |
| 258 | 308 | MCFG_CPU_PROGRAM_MAP(c1943_map) |
| 259 | 309 | MCFG_CPU_VBLANK_INT_DRIVER("screen", _1943_state, irq0_line_hold) |
| 260 | 310 | |
| 261 | 311 | MCFG_CPU_ADD("audiocpu", Z80, XTAL_24MHz/8) /* verified on pcb */ |
| 262 | 312 | 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) |
| 264 | 314 | |
| 265 | | |
| 266 | 315 | // video hardware |
| 267 | 316 | MCFG_SCREEN_ADD("screen", RASTER) |
| 268 | 317 | MCFG_SCREEN_REFRESH_RATE(60) |
| r25412 | r25413 | |
| 274 | 323 | MCFG_GFXDECODE(1943) |
| 275 | 324 | MCFG_PALETTE_LENGTH(32*4+16*16+16*16+16*16) |
| 276 | 325 | |
| 277 | | |
| 278 | 326 | // sound hardware |
| 279 | 327 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 280 | 328 | |
| 281 | | MCFG_SOUND_ADD("ym1", YM2203, XTAL_24MHz/16) /* verified on pcb */ |
| 329 | MCFG_SOUND_ADD("ym1", YM2203, XTAL_24MHz/16) /* verified on pcb */ |
| 282 | 330 | MCFG_SOUND_ROUTE(0, "mono", 0.15) |
| 283 | 331 | MCFG_SOUND_ROUTE(1, "mono", 0.15) |
| 284 | 332 | MCFG_SOUND_ROUTE(2, "mono", 0.15) |
| 285 | 333 | MCFG_SOUND_ROUTE(3, "mono", 0.10) |
| 286 | 334 | |
| 287 | | MCFG_SOUND_ADD("ym2", YM2203, XTAL_24MHz/16) /* verified on pcb */ |
| 335 | MCFG_SOUND_ADD("ym2", YM2203, XTAL_24MHz/16) /* verified on pcb */ |
| 288 | 336 | MCFG_SOUND_ROUTE(0, "mono", 0.15) |
| 289 | 337 | MCFG_SOUND_ROUTE(1, "mono", 0.15) |
| 290 | 338 | MCFG_SOUND_ROUTE(2, "mono", 0.15) |
| r25412 | r25413 | |
| 642 | 690 | membank("bank1")->configure_entries(0, 8, &ROM[0x10000], 0x4000); |
| 643 | 691 | } |
| 644 | 692 | |
| 645 | | READ8_MEMBER(_1943_state::_1943b_c007_r){ return 0; } |
| 646 | | |
| 647 | 693 | DRIVER_INIT_MEMBER(_1943_state,1943b) |
| 648 | 694 | { |
| 649 | 695 | 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 | |
| 652 | 697 | m_maincpu->space(AS_PROGRAM).install_read_handler(0xc007, 0xc007, read8_delegate(FUNC(_1943_state::_1943b_c007_r),this)); |
| 653 | | |
| 654 | 698 | } |
| 655 | 699 | |
| 656 | 700 | /* Game Drivers */ |