trunk/src/mame/drivers/alinvade.c
| r241954 | r241955 | |
| 5 | 5 | Driver by David Haywood and Mariusz Wojcieszek |
| 6 | 6 | |
| 7 | 7 | TODO: |
| 8 | | - 16 bytes are protected in the c*** range. I'm guessing they used a PROM to protect a |
| 8 | - 16 bytes are protected in the c*** range. I'm guessing they used a PROM to protect a |
| 9 | 9 | simple sub-routine because just after that the program has a left-over located at 0xe000-0xe00f (yup, NOPs + a RTS) |
| 10 | 10 | It's unknown at current stage what it really protects tho ... |
| 11 | 11 | |
| 12 | Sound is entirely guesswork. |
| 13 | |
| 12 | 14 | */ |
| 13 | 15 | |
| 14 | 16 | #include "emu.h" |
| 15 | 17 | #include "cpu/m6502/m6502.h" |
| 18 | #include "sound/discrete.h" |
| 16 | 19 | #include "alinvade.lh" |
| 17 | 20 | |
| 18 | 21 | class alinvade_state : public driver_device |
| 19 | 22 | { |
| 20 | 23 | public: |
| 21 | 24 | alinvade_state(const machine_config &mconfig, device_type type, const char *tag) |
| 22 | | : driver_device(mconfig, type, tag), |
| 23 | | m_maincpu(*this, "maincpu"), |
| 24 | | m_videoram(*this, "videoram") |
| 25 | : driver_device(mconfig, type, tag) |
| 26 | , m_maincpu(*this, "maincpu") |
| 27 | , m_videoram(*this, "videoram") |
| 28 | , m_discrete(*this, "discrete") |
| 25 | 29 | { } |
| 26 | 30 | |
| 27 | | UINT8 irqmask; |
| 28 | | UINT8 irqff; |
| 29 | 31 | DECLARE_READ8_MEMBER(irqmask_r); |
| 30 | 32 | DECLARE_WRITE8_MEMBER(irqmask_w); |
| 33 | DECLARE_WRITE8_MEMBER(sound_w); |
| 34 | DECLARE_WRITE8_MEMBER(sounden_w); |
| 31 | 35 | INTERRUPT_GEN_MEMBER(vblank_irq); |
| 32 | | required_device<cpu_device> m_maincpu; |
| 33 | | required_shared_ptr<UINT8> m_videoram; |
| 36 | UINT32 screen_update_alinvade(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 34 | 37 | |
| 35 | | public: |
| 38 | private: |
| 39 | UINT8 irqmask; |
| 40 | UINT8 irqff; |
| 36 | 41 | virtual void machine_start(); |
| 37 | 42 | virtual void machine_reset(); |
| 38 | | UINT32 screen_update_alinvade(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); |
| 43 | required_device<cpu_device> m_maincpu; |
| 44 | required_shared_ptr<UINT8> m_videoram; |
| 45 | required_device<discrete_device> m_discrete; |
| 39 | 46 | }; |
| 40 | 47 | |
| 48 | static const discrete_dac_r1_ladder alinvade_music_dac = |
| 49 | {3, {0, RES_K(47), RES_K(12)}, 0, 0, 0, CAP_U(0.01)}; |
| 50 | |
| 51 | #define ALINVADE_MUSIC_CLK (75000) |
| 52 | |
| 53 | DISCRETE_SOUND_START(alinvade) |
| 54 | DISCRETE_INPUT_DATA (NODE_01) |
| 55 | |
| 56 | DISCRETE_NOTE(NODE_20, 1, ALINVADE_MUSIC_CLK, NODE_01, 255, 5, DISC_CLK_IS_FREQ) |
| 57 | |
| 58 | // Convert count to 7492 output |
| 59 | DISCRETE_TRANSFORM2(NODE_21, NODE_20, 2, "01>0+") |
| 60 | |
| 61 | DISCRETE_DAC_R1(NODE_22, NODE_21, DEFAULT_TTL_V_LOGIC_1, &alinvade_music_dac) |
| 62 | |
| 63 | DISCRETE_CRFILTER(NODE_80, NODE_22, RES_K(10), CAP_U(0.1)) |
| 64 | |
| 65 | DISCRETE_OUTPUT(NODE_80, 2500) |
| 66 | |
| 67 | DISCRETE_SOUND_END |
| 68 | |
| 69 | WRITE8_MEMBER( alinvade_state::sound_w ) |
| 70 | { |
| 71 | m_discrete->write(space, NODE_01, (data^0x3f)<<2); |
| 72 | } |
| 73 | |
| 74 | WRITE8_MEMBER( alinvade_state::sounden_w ) |
| 75 | { |
| 76 | machine().sound().system_enable(data == 4); |
| 77 | } |
| 78 | |
| 41 | 79 | READ8_MEMBER(alinvade_state::irqmask_r) |
| 42 | 80 | { |
| 43 | 81 | return 0; // TODO: might be anything |
| r241954 | r241955 | |
| 53 | 91 | } |
| 54 | 92 | |
| 55 | 93 | static ADDRESS_MAP_START( alinvade_map, AS_PROGRAM, 8, alinvade_state ) |
| 56 | | AM_RANGE(0x0000, 0x01ff) AM_RAM |
| 57 | | AM_RANGE(0x0400, 0x0bff) AM_RAM AM_SHARE("videoram") |
| 94 | AM_RANGE(0x0000, 0x01ff) AM_RAM |
| 95 | AM_RANGE(0x0400, 0x0bff) AM_RAM AM_SHARE("videoram") |
| 58 | 96 | AM_RANGE(0x0c00, 0x0dff) AM_RAM |
| 59 | | AM_RANGE(0x2000, 0x2000) AM_WRITENOP //?? |
| 60 | | AM_RANGE(0x4000, 0x4000) AM_READ_PORT("COIN") |
| 61 | | AM_RANGE(0x6000, 0x6000) AM_READ_PORT("DSW") |
| 62 | | AM_RANGE(0x8000, 0x8000) AM_READ_PORT("IN0") |
| 63 | | AM_RANGE(0x8001, 0x8001) AM_READ_PORT("IN1") |
| 64 | | AM_RANGE(0x8002, 0x8002) AM_READ_PORT("IN2") |
| 65 | | AM_RANGE(0x8003, 0x8003) AM_READ_PORT("IN3") |
| 66 | | AM_RANGE(0x8004, 0x8004) AM_READ_PORT("IN4") |
| 67 | | AM_RANGE(0xa000, 0xa000) AM_WRITENOP //?? |
| 68 | | AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0xff0) AM_ROM AM_REGION("proms",0) |
| 69 | | AM_RANGE(0xe000, 0xe3ff) AM_ROM |
| 70 | | AM_RANGE(0xe400, 0xe400) AM_WRITENOP //?? |
| 71 | | AM_RANGE(0xe800, 0xe800) AM_READWRITE(irqmask_r,irqmask_w) //?? |
| 72 | | AM_RANGE(0xec00, 0xffff) AM_ROM |
| 97 | AM_RANGE(0x2000, 0x2000) AM_WRITE(sound_w) |
| 98 | AM_RANGE(0x4000, 0x4000) AM_READ_PORT("COIN") |
| 99 | AM_RANGE(0x6000, 0x6000) AM_READ_PORT("DSW") |
| 100 | AM_RANGE(0x8000, 0x8000) AM_READ_PORT("IN0") |
| 101 | AM_RANGE(0x8001, 0x8001) AM_READ_PORT("IN1") |
| 102 | AM_RANGE(0x8002, 0x8002) AM_READ_PORT("IN2") |
| 103 | AM_RANGE(0x8003, 0x8003) AM_READ_PORT("IN3") |
| 104 | AM_RANGE(0x8004, 0x8004) AM_READ_PORT("IN4") |
| 105 | AM_RANGE(0xa000, 0xa000) AM_WRITENOP //?? |
| 106 | AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0xff0) AM_ROM AM_REGION("proms",0) |
| 107 | AM_RANGE(0xe000, 0xe3ff) AM_ROM |
| 108 | AM_RANGE(0xe400, 0xe400) AM_WRITE(sounden_w) |
| 109 | AM_RANGE(0xe800, 0xe800) AM_READWRITE(irqmask_r,irqmask_w) //?? |
| 110 | AM_RANGE(0xec00, 0xffff) AM_ROM |
| 73 | 111 | ADDRESS_MAP_END |
| 74 | 112 | |
| 75 | 113 | |
| 76 | 114 | static INPUT_PORTS_START( alinvade ) |
| 77 | | PORT_START("COIN") |
| 78 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 79 | | PORT_BIT(0xef, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 115 | PORT_START("COIN") |
| 116 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 117 | PORT_BIT(0xef, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 80 | 118 | |
| 81 | | PORT_START("IN0") |
| 82 | | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 83 | | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 119 | PORT_START("IN0") |
| 120 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 121 | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 84 | 122 | |
| 85 | | PORT_START("IN1") |
| 86 | | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(1) |
| 87 | | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 123 | PORT_START("IN1") |
| 124 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(1) |
| 125 | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 88 | 126 | |
| 89 | | PORT_START("IN2") |
| 90 | | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_PLAYER(1) |
| 91 | | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 127 | PORT_START("IN2") |
| 128 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_PLAYER(1) |
| 129 | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 92 | 130 | |
| 93 | | PORT_START("IN3") |
| 94 | | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_START1 ) |
| 95 | | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 131 | PORT_START("IN3") |
| 132 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_START1 ) |
| 133 | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 96 | 134 | |
| 97 | | PORT_START("IN4") |
| 98 | | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_START2 ) |
| 99 | | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 135 | PORT_START("IN4") |
| 136 | PORT_BIT(0x20, IP_ACTIVE_HIGH, IPT_START2 ) |
| 137 | PORT_BIT(0xdf, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
| 100 | 138 | |
| 101 | | PORT_START("DSW") |
| 102 | | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) |
| 103 | | PORT_DIPSETTING( 0x00, "2" ) |
| 104 | | PORT_DIPSETTING( 0x01, "3" ) |
| 105 | | PORT_DIPSETTING( 0x02, "4" ) |
| 106 | | PORT_DIPSETTING( 0x03, "5" ) |
| 107 | | PORT_DIPNAME( 0x04, 0x00, DEF_STR ( Unknown ) ) // read, but not tested afterwards? |
| 108 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 109 | | PORT_DIPSETTING( 0x04, DEF_STR( On ) ) |
| 110 | | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 139 | PORT_START("DSW") |
| 140 | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) |
| 141 | PORT_DIPSETTING( 0x00, "2" ) |
| 142 | PORT_DIPSETTING( 0x01, "3" ) |
| 143 | PORT_DIPSETTING( 0x02, "4" ) |
| 144 | PORT_DIPSETTING( 0x03, "5" ) |
| 145 | PORT_DIPNAME( 0x04, 0x00, DEF_STR ( Unknown ) ) // read, but not tested afterwards? |
| 146 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 147 | PORT_DIPSETTING( 0x04, DEF_STR( On ) ) |
| 148 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 111 | 149 | INPUT_PORTS_END |
| 112 | 150 | |
| 113 | 151 | |
| r241954 | r241955 | |
| 169 | 207 | |
| 170 | 208 | /* sound hardware */ |
| 171 | 209 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 210 | MCFG_DISCRETE_ADD("discrete", 0, alinvade) |
| 211 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 172 | 212 | MACHINE_CONFIG_END |
| 173 | 213 | |
| 174 | 214 | |
| 175 | 215 | |
| 176 | 216 | ROM_START( alinvade ) |
| 177 | 217 | ROM_REGION( 0x10000, "maincpu", 0 ) // todo, check mapping |
| 178 | | ROM_LOAD( "alien28.708", 0xe000, 0x0400, CRC(de376295) SHA1(e8eddbb1be1f8661c6b5b39c0d78a65bded65db2) ) |
| 179 | | ROM_LOAD( "alien29.708", 0xec00, 0x0400, CRC(20212977) SHA1(9d24a6b403d968267079fa6241545bd5a01afebb) ) |
| 180 | | ROM_LOAD( "alien30.708", 0xf000, 0x0400, CRC(734b691c) SHA1(9e562159061eecf4b1dee4ea0ee4752c901a54aa) ) |
| 181 | | ROM_LOAD( "alien31.708", 0xf400, 0x0400, CRC(5a70535c) SHA1(2827e7d4bffca78bd035da04481e1e972ee2da39) ) |
| 182 | | ROM_LOAD( "alien32.708", 0xf800, 0x0400, CRC(332dd234) SHA1(9974668344a2a351868a9e7757d1c3a497dc5621) ) |
| 183 | | ROM_LOAD( "alien33.708", 0xfc00, 0x0400, CRC(e0d57fc7) SHA1(7b8ddcb4a86811592d2d0bbc61b2f19e5caa9ccc) ) |
| 218 | ROM_LOAD( "alien28.708", 0xe000, 0x0400, CRC(de376295) SHA1(e8eddbb1be1f8661c6b5b39c0d78a65bded65db2) ) |
| 219 | ROM_LOAD( "alien29.708", 0xec00, 0x0400, CRC(20212977) SHA1(9d24a6b403d968267079fa6241545bd5a01afebb) ) |
| 220 | ROM_LOAD( "alien30.708", 0xf000, 0x0400, CRC(734b691c) SHA1(9e562159061eecf4b1dee4ea0ee4752c901a54aa) ) |
| 221 | ROM_LOAD( "alien31.708", 0xf400, 0x0400, CRC(5a70535c) SHA1(2827e7d4bffca78bd035da04481e1e972ee2da39) ) |
| 222 | ROM_LOAD( "alien32.708", 0xf800, 0x0400, CRC(332dd234) SHA1(9974668344a2a351868a9e7757d1c3a497dc5621) ) |
| 223 | ROM_LOAD( "alien33.708", 0xfc00, 0x0400, CRC(e0d57fc7) SHA1(7b8ddcb4a86811592d2d0bbc61b2f19e5caa9ccc) ) |
| 184 | 224 | |
| 185 | 225 | ROM_REGION( 0x20, "proms", 0 ) |
| 186 | 226 | ROM_LOAD( "prom", 0, 0x20, NO_DUMP ) |
| 187 | | ROM_FILL( 0x00, 0x0f, 0xea ) |
| 188 | | ROM_FILL( 0x0f, 0x01, 0x60 ) // rts for whole area, interrupt code jumps to various addresses here, check note on top. |
| 227 | ROM_FILL( 0x00, 0x0f, 0xea ) |
| 228 | ROM_FILL( 0x0f, 0x01, 0x60 ) // rts for whole area, interrupt code jumps to various addresses here, check note on top. |
| 189 | 229 | ROM_END |
| 190 | 230 | |
| 191 | 231 | |
| 192 | | GAMEL( 198?, alinvade, 0, alinvade, alinvade, driver_device, 0, ROT90, "Forbes?", "Alien Invaders", GAME_UNEMULATED_PROTECTION | GAME_NO_SOUND, layout_alinvade ) |
| 232 | GAMEL( 198?, alinvade, 0, alinvade, alinvade, driver_device, 0, ROT90, "Forbes?", "Alien Invaders", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND, layout_alinvade ) |