trunk/src/mame/machine/galaxold.c
| r26338 | r26339 | |
| 126 | 126 | set_led_status(machine(), offset,data & 1); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | | |
| 130 | | #ifdef UNUSED_FUNCTION |
| 131 | | READ8_MEMBER(galaxold_state::checkmaj_protection_r) |
| 132 | | { |
| 133 | | switch (space.device().safe_pc()) |
| 134 | | { |
| 135 | | case 0x0f15: return 0xf5; |
| 136 | | case 0x0f8f: return 0x7c; |
| 137 | | case 0x10b3: return 0x7c; |
| 138 | | case 0x10e0: return 0x00; |
| 139 | | case 0x10f1: return 0xaa; |
| 140 | | case 0x1402: return 0xaa; |
| 141 | | default: |
| 142 | | logerror("Unknown protection read. PC=%04X\n",space.device().safe_pc()); |
| 143 | | } |
| 144 | | |
| 145 | | return 0; |
| 146 | | } |
| 147 | | |
| 148 | | |
| 149 | | /* Zig Zag can swap ROMs 2 and 3 as a form of copy protection */ |
| 150 | | WRITE8_MEMBER(galaxold_state::zigzag_sillyprotection_w) |
| 151 | | { |
| 152 | | if (data) |
| 153 | | { |
| 154 | | /* swap ROM 2 and 3! */ |
| 155 | | membank("bank1")->set_entry(1); |
| 156 | | membank("bank2")->set_entry(0); |
| 157 | | } |
| 158 | | else |
| 159 | | { |
| 160 | | membank("bank1")->set_entry(0); |
| 161 | | membank("bank2")->set_entry(1); |
| 162 | | } |
| 163 | | } |
| 164 | | |
| 165 | | DRIVER_INIT_MEMBER(galaxold_state,zigzag) |
| 166 | | { |
| 167 | | UINT8 *RAM = memregion("maincpu")->base(); |
| 168 | | membank("bank1")->configure_entries(0, 2, &RAM[0x2000], 0x1000); |
| 169 | | membank("bank2")->configure_entries(0, 2, &RAM[0x2000], 0x1000); |
| 170 | | membank("bank1")->set_entry(0); |
| 171 | | membank("bank2")->set_entry(1); |
| 172 | | } |
| 173 | | |
| 174 | | |
| 175 | | |
| 176 | | READ8_MEMBER(galaxold_state::dingo_3000_r) |
| 177 | | { |
| 178 | | return 0xaa; |
| 179 | | } |
| 180 | | |
| 181 | | READ8_MEMBER(galaxold_state::dingo_3035_r) |
| 182 | | { |
| 183 | | return 0x8c; |
| 184 | | } |
| 185 | | |
| 186 | | READ8_MEMBER(galaxold_state::dingoe_3001_r) |
| 187 | | { |
| 188 | | return 0xaa; |
| 189 | | } |
| 190 | | |
| 191 | | |
| 192 | | DRIVER_INIT_MEMBER(galaxold_state,dingoe) |
| 193 | | { |
| 194 | | offs_t i; |
| 195 | | UINT8 *rom = memregion("maincpu")->base(); |
| 196 | | |
| 197 | | for (i = 0; i < 0x3000; i++) |
| 198 | | { |
| 199 | | UINT8 data_xor; |
| 200 | | |
| 201 | | /* XOR bit 2 with 4 and 5 with 0 */ |
| 202 | | data_xor = BIT(rom[i], 2) << 4 | BIT(rom[i], 5) << 0; |
| 203 | | rom[i] ^= data_xor; |
| 204 | | |
| 205 | | |
| 206 | | /* Invert bit 1 */ |
| 207 | | if (~rom[i] & 0x02) |
| 208 | | rom[i] = rom[i] | 0x02; |
| 209 | | else |
| 210 | | rom[i] = rom[i] & 0xfd; |
| 211 | | |
| 212 | | |
| 213 | | /* Swap bit0 with bit4 */ |
| 214 | | if ((i & 0x0f) == 0x02 || (i & 0x0f) == 0x0a || (i & 0x0f) == 0x03 || (i & 0x0f) == 0x0b || (i & 0x0f) == 0x06 || (i & 0x0f) == 0x0e || (i & 0x0f) == 0x07 || (i & 0x0f) == 0x0f) /* Swap Bit 0 and 4 */ |
| 215 | | rom[i] = BITSWAP8(rom[i],7,6,5,0,3,2,1,4); |
| 216 | | } |
| 217 | | |
| 218 | | m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x3001, 0x3001, FUNC(dingoe_3001_r)); /* Protection check */ |
| 219 | | |
| 220 | | } |
| 221 | | #endif |
| 222 | | |
| 223 | | |
| 224 | 129 | READ8_MEMBER(galaxold_state::scramblb_protection_1_r) |
| 225 | 130 | { |
| 226 | 131 | switch (space.device().safe_pc()) |
| r26338 | r26339 | |
| 260 | 165 | return (ioport(portnames[m__4in1_bank])->read() & bit_mask) ? 0x01 : 0x00; |
| 261 | 166 | } |
| 262 | 167 | |
| 263 | | #ifdef UNUSED_FUNCTION |
| 264 | | DRIVER_INIT_MEMBER(galaxold_state,pisces) |
| 265 | | { |
| 266 | | /* the coin lockout was replaced */ |
| 267 | | m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x6002, 0x6002, FUNC(galaxold_gfxbank_w)); |
| 268 | | } |
| 269 | | |
| 270 | | DRIVER_INIT_MEMBER(galaxold_state,checkmaj) |
| 271 | | { |
| 272 | | /* for the title screen */ |
| 273 | | m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x3800, 0x3800, FUNC(checkmaj_protection_r)); |
| 274 | | } |
| 275 | | |
| 276 | | DRIVER_INIT_MEMBER(galaxold_state,dingo) |
| 277 | | { |
| 278 | | m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x3000, 0x3000, FUNC(dingo_3000_r)); |
| 279 | | m_maincpu->space(AS_PROGRAM).install_legacy_read_handler(0x3035, 0x3035, FUNC(dingo_3035_r)); |
| 280 | | } |
| 281 | | |
| 282 | | |
| 283 | | UINT8 galaxold_state::decode_mooncrst(UINT8 data,offs_t addr) |
| 284 | | { |
| 285 | | UINT8 res; |
| 286 | | |
| 287 | | res = data; |
| 288 | | if (BIT(data,1)) res ^= 0x40; |
| 289 | | if (BIT(data,5)) res ^= 0x04; |
| 290 | | if ((addr & 1) == 0) |
| 291 | | res = (res & 0xbb) | (BIT(res,6) << 2) | (BIT(res,2) << 6); |
| 292 | | return res; |
| 293 | | } |
| 294 | | |
| 295 | | DRIVER_INIT_MEMBER(galaxold_state,mooncrsu) |
| 296 | | { |
| 297 | | m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0xa000, 0xa002, FUNC(galaxold_gfxbank_w)); |
| 298 | | } |
| 299 | | |
| 300 | | DRIVER_INIT_MEMBER(galaxold_state,mooncrst) |
| 301 | | { |
| 302 | | offs_t i, len = memregion("maincpu")->bytes(); |
| 303 | | UINT8 *rom = memregion("maincpu")->base(); |
| 304 | | |
| 305 | | |
| 306 | | for (i = 0;i < len;i++) |
| 307 | | rom[i] = decode_mooncrst(rom[i],i); |
| 308 | | |
| 309 | | DRIVER_INIT_CALL(mooncrsu); |
| 310 | | } |
| 311 | | |
| 312 | | DRIVER_INIT_MEMBER(galaxold_state,mooncrgx) |
| 313 | | { |
| 314 | | m_maincpu->space(AS_PROGRAM).install_legacy_write_handler(0x6000, 0x6002, FUNC(galaxold_gfxbank_w)); |
| 315 | | } |
| 316 | | |
| 317 | | DRIVER_INIT_MEMBER(galaxold_state,moonqsr) |
| 318 | | { |
| 319 | | offs_t i; |
| 320 | | address_space &space = m_maincpu->space(AS_PROGRAM); |
| 321 | | UINT8 *rom = memregion("maincpu")->base(); |
| 322 | | UINT8 *decrypt = auto_alloc_array(machine(), UINT8, 0x8000); |
| 323 | | |
| 324 | | space.set_decrypted_region(0x0000, 0x7fff, decrypt); |
| 325 | | |
| 326 | | for (i = 0;i < 0x8000;i++) |
| 327 | | decrypt[i] = decode_mooncrst(rom[i],i); |
| 328 | | } |
| 329 | | |
| 330 | | DRIVER_INIT_MEMBER(galaxold_state,checkman) |
| 331 | | { |
| 332 | | /* |
| 333 | | Encryption Table |
| 334 | | ---------------- |
| 335 | | +---+---+---+------+------+------+------+------+------+------+------+ |
| 336 | | |A2 |A1 |A0 |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0 | |
| 337 | | +---+---+---+------+------+------+------+------+------+------+------+ |
| 338 | | | 0 | 0 | 0 |D7 |D6 |D5 |D4 |D3 |D2 |D1 |D0^^D6| |
| 339 | | | 0 | 0 | 1 |D7 |D6 |D5 |D4 |D3 |D2 |D1^^D5|D0 | |
| 340 | | | 0 | 1 | 0 |D7 |D6 |D5 |D4 |D3 |D2^^D4|D1^^D6|D0 | |
| 341 | | | 0 | 1 | 1 |D7 |D6 |D5 |D4^^D2|D3 |D2 |D1 |D0^^D5| |
| 342 | | | 1 | 0 | 0 |D7 |D6^^D4|D5^^D1|D4 |D3 |D2 |D1 |D0 | |
| 343 | | | 1 | 0 | 1 |D7 |D6^^D0|D5^^D2|D4 |D3 |D2 |D1 |D0 | |
| 344 | | | 1 | 1 | 0 |D7 |D6 |D5 |D4 |D3 |D2^^D0|D1 |D0 | |
| 345 | | | 1 | 1 | 1 |D7 |D6 |D5 |D4^^D1|D3 |D2 |D1 |D0 | |
| 346 | | +---+---+---+------+------+------+------+------+------+------+------+ |
| 347 | | |
| 348 | | For example if A2=1, A1=1 and A0=0 then D2 to the CPU would be an XOR of |
| 349 | | D2 and D0 from the ROM's. Note that D7 and D3 are not encrypted. |
| 350 | | |
| 351 | | Encryption PAL 16L8 on cardridge |
| 352 | | +--- ---+ |
| 353 | | OE --| U |-- VCC |
| 354 | | ROMD0 --| |-- D0 |
| 355 | | ROMD1 --| |-- D1 |
| 356 | | ROMD2 --|VER 5.2|-- D2 |
| 357 | | A0 --| |-- NOT USED |
| 358 | | A1 --| |-- A2 |
| 359 | | ROMD4 --| |-- D4 |
| 360 | | ROMD5 --| |-- D5 |
| 361 | | ROMD6 --| |-- D6 |
| 362 | | GND --| |-- M1 (NOT USED) |
| 363 | | +-------+ |
| 364 | | Pin layout is such that links can replace the PAL if encryption is not used. |
| 365 | | |
| 366 | | */ |
| 367 | | static const UINT8 xortable[8][4] = |
| 368 | | { |
| 369 | | { 6,0,6,0 }, |
| 370 | | { 5,1,5,1 }, |
| 371 | | { 4,2,6,1 }, |
| 372 | | { 2,4,5,0 }, |
| 373 | | { 4,6,1,5 }, |
| 374 | | { 0,6,2,5 }, |
| 375 | | { 0,2,0,2 }, |
| 376 | | { 1,4,1,4 } |
| 377 | | }; |
| 378 | | |
| 379 | | offs_t i, len = memregion("maincpu")->bytes(); |
| 380 | | UINT8 *rom = memregion("maincpu")->base(); |
| 381 | | |
| 382 | | |
| 383 | | for (i = 0; i < len; i++) |
| 384 | | { |
| 385 | | UINT8 data_xor; |
| 386 | | int line = i & 0x07; |
| 387 | | |
| 388 | | data_xor = (BIT(rom[i],xortable[line][0]) << xortable[line][1]) | |
| 389 | | (BIT(rom[i],xortable[line][2]) << xortable[line][3]); |
| 390 | | |
| 391 | | rom[i] ^= data_xor; |
| 392 | | } |
| 393 | | } |
| 394 | | #endif |
| 395 | | |
| 396 | 168 | DRIVER_INIT_MEMBER(galaxold_state,4in1) |
| 397 | 169 | { |
| 398 | 170 | address_space &space = m_maincpu->space(AS_PROGRAM); |
trunk/src/mame/machine/namcos1.c
| r26338 | r26339 | |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | |
| 85 | | // used by faceoff and tankforce 4 player (input multiplex) |
| 86 | | static DECLARE_READ8_HANDLER( faceoff_inputs_r ); |
| 87 | | |
| 88 | 85 | static READ8_HANDLER( no_key_r ) |
| 89 | 86 | { |
| 90 | 87 | popmessage("CPU %s PC %08x: keychip read %04x\n", space.device().tag(), space.device().safe_pc(), offset); |
| r26338 | r26339 | |
| 1217 | 1214 | }; |
| 1218 | 1215 | namcos1_driver_init(machine(), &tankfrce_specific); |
| 1219 | 1216 | |
| 1220 | | m_mcu->space(AS_PROGRAM).install_legacy_read_handler(0x1400, 0x1401, FUNC(faceoff_inputs_r)); |
| 1217 | m_mcu->space(AS_PROGRAM).install_read_handler(0x1400, 0x1401, read8_delegate(FUNC(namcos1_state::faceoff_inputs_r), this)); |
| 1221 | 1218 | } |
| 1222 | 1219 | |
| 1223 | 1220 | /******************************************************************************* |
| r26338 | r26339 | |
| 1273 | 1270 | /******************************************************************************* |
| 1274 | 1271 | * Quester specific * |
| 1275 | 1272 | *******************************************************************************/ |
| 1276 | | static READ8_HANDLER( quester_paddle_r ) |
| 1273 | READ8_MEMBER( namcos1_state::quester_paddle_r ) |
| 1277 | 1274 | { |
| 1278 | 1275 | static int qnum=0, qstrobe=0; |
| 1279 | 1276 | |
| r26338 | r26339 | |
| 1282 | 1279 | int ret; |
| 1283 | 1280 | |
| 1284 | 1281 | if (!qnum) |
| 1285 | | ret = (space.machine().root_device().ioport("CONTROL0")->read()&0x90) | qstrobe | (space.machine().root_device().ioport("PADDLE0")->read()&0x0f); |
| 1282 | ret = (ioport("CONTROL0")->read()&0x90) | qstrobe | (ioport("PADDLE0")->read()&0x0f); |
| 1286 | 1283 | else |
| 1287 | | ret = (space.machine().root_device().ioport("CONTROL0")->read()&0x90) | qstrobe | (space.machine().root_device().ioport("PADDLE1")->read()&0x0f); |
| 1284 | ret = (ioport("CONTROL0")->read()&0x90) | qstrobe | (ioport("PADDLE1")->read()&0x0f); |
| 1288 | 1285 | |
| 1289 | 1286 | qstrobe ^= 0x40; |
| 1290 | 1287 | |
| r26338 | r26339 | |
| 1295 | 1292 | int ret; |
| 1296 | 1293 | |
| 1297 | 1294 | if (!qnum) |
| 1298 | | ret = (space.machine().root_device().ioport("CONTROL1")->read()&0x90) | qnum | (space.machine().root_device().ioport("PADDLE0")->read()>>4); |
| 1295 | ret = (ioport("CONTROL1")->read()&0x90) | qnum | (ioport("PADDLE0")->read()>>4); |
| 1299 | 1296 | else |
| 1300 | | ret = (space.machine().root_device().ioport("CONTROL1")->read()&0x90) | qnum | (space.machine().root_device().ioport("PADDLE1")->read()>>4); |
| 1297 | ret = (ioport("CONTROL1")->read()&0x90) | qnum | (ioport("PADDLE1")->read()>>4); |
| 1301 | 1298 | |
| 1302 | 1299 | if (!qstrobe) qnum ^= 0x20; |
| 1303 | 1300 | |
| r26338 | r26339 | |
| 1308 | 1305 | DRIVER_INIT_MEMBER(namcos1_state,quester) |
| 1309 | 1306 | { |
| 1310 | 1307 | namcos1_driver_init(machine(), NULL); |
| 1311 | | m_mcu->space(AS_PROGRAM).install_legacy_read_handler(0x1400, 0x1401, FUNC(quester_paddle_r)); |
| 1308 | m_mcu->space(AS_PROGRAM).install_read_handler(0x1400, 0x1401, read8_delegate(FUNC(namcos1_state::quester_paddle_r), this)); |
| 1312 | 1309 | } |
| 1313 | 1310 | |
| 1314 | 1311 | |
| r26338 | r26339 | |
| 1317 | 1314 | * Beraboh Man specific * |
| 1318 | 1315 | *******************************************************************************/ |
| 1319 | 1316 | |
| 1320 | | static READ8_HANDLER( berabohm_buttons_r ) |
| 1317 | READ8_MEMBER( namcos1_state::berabohm_buttons_r ) |
| 1321 | 1318 | { |
| 1322 | 1319 | int res; |
| 1323 | 1320 | static int input_count, strobe, strobe_count; |
| r26338 | r26339 | |
| 1327 | 1324 | { |
| 1328 | 1325 | int inp = input_count; |
| 1329 | 1326 | |
| 1330 | | if (inp == 4) res = space.machine().root_device().ioport("CONTROL0")->read(); |
| 1327 | if (inp == 4) res = ioport("CONTROL0")->read(); |
| 1331 | 1328 | else |
| 1332 | 1329 | { |
| 1333 | 1330 | char portname[40]; |
| r26338 | r26339 | |
| 1336 | 1333 | static int counter[4]; |
| 1337 | 1334 | |
| 1338 | 1335 | sprintf(portname,"IN%d",inp); /* IN0-IN3 */ |
| 1339 | | res = space.machine().root_device().ioport(portname)->read(); |
| 1336 | res = ioport(portname)->read(); |
| 1340 | 1337 | if (res & 0x80) |
| 1341 | 1338 | { |
| 1342 | 1339 | if (counter[inp] >= 0) |
| r26338 | r26339 | |
| 1360 | 1357 | counter[inp] = -1; |
| 1361 | 1358 | #else |
| 1362 | 1359 | sprintf(portname,"IN%d",inp); /* IN0-IN3 */ |
| 1363 | | res = space.machine().root_device().ioport(portname)->read(); |
| 1360 | res = ioport(portname)->read(); |
| 1364 | 1361 | if (res & 1) res = 0x7f; /* weak */ |
| 1365 | 1362 | else if (res & 2) res = 0x48; /* medium */ |
| 1366 | 1363 | else if (res & 4) res = 0x40; /* strong */ |
| r26338 | r26339 | |
| 1371 | 1368 | } |
| 1372 | 1369 | else |
| 1373 | 1370 | { |
| 1374 | | res = space.machine().root_device().ioport("CONTROL1")->read() & 0x8f; |
| 1371 | res = ioport("CONTROL1")->read() & 0x8f; |
| 1375 | 1372 | |
| 1376 | 1373 | /* the strobe cannot happen too often, otherwise the MCU will waste too |
| 1377 | 1374 | much time reading the inputs and won't have enough cycles to play two |
| r26338 | r26339 | |
| 1397 | 1394 | DRIVER_INIT_MEMBER(namcos1_state,berabohm) |
| 1398 | 1395 | { |
| 1399 | 1396 | namcos1_driver_init(machine(), NULL); |
| 1400 | | m_mcu->space(AS_PROGRAM).install_legacy_read_handler(0x1400, 0x1401, FUNC(berabohm_buttons_r)); |
| 1397 | m_mcu->space(AS_PROGRAM).install_read_handler(0x1400, 0x1401, read8_delegate(FUNC(namcos1_state::berabohm_buttons_r), this)); |
| 1401 | 1398 | } |
| 1402 | 1399 | |
| 1403 | 1400 | |
| r26338 | r26339 | |
| 1406 | 1403 | * Face Off specific * |
| 1407 | 1404 | *******************************************************************************/ |
| 1408 | 1405 | |
| 1409 | | static READ8_HANDLER( faceoff_inputs_r ) |
| 1406 | // used by faceoff and tankforce 4 player (input multiplex) |
| 1407 | |
| 1408 | READ8_MEMBER( namcos1_state::faceoff_inputs_r ) |
| 1410 | 1409 | { |
| 1411 | 1410 | int res; |
| 1412 | 1411 | static int input_count, strobe_count, stored_input[2]; |
| 1413 | 1412 | |
| 1414 | 1413 | if (offset == 0) |
| 1415 | 1414 | { |
| 1416 | | res = (space.machine().root_device().ioport("CONTROL0")->read() & 0x80) | stored_input[0]; |
| 1415 | res = (ioport("CONTROL0")->read() & 0x80) | stored_input[0]; |
| 1417 | 1416 | |
| 1418 | 1417 | return res; |
| 1419 | 1418 | } |
| 1420 | 1419 | else |
| 1421 | 1420 | { |
| 1422 | | res = space.machine().root_device().ioport("CONTROL1")->read() & 0x80; |
| 1421 | res = ioport("CONTROL1")->read() & 0x80; |
| 1423 | 1422 | |
| 1424 | 1423 | /* the strobe cannot happen too often, otherwise the MCU will waste too |
| 1425 | 1424 | much time reading the inputs and won't have enough cycles to play two |
| r26338 | r26339 | |
| 1434 | 1433 | switch (input_count) |
| 1435 | 1434 | { |
| 1436 | 1435 | case 0: |
| 1437 | | stored_input[0] = space.machine().root_device().ioport("IN0")->read() & 0x1f; |
| 1438 | | stored_input[1] = (space.machine().root_device().ioport("IN3")->read() & 0x07) << 3; |
| 1436 | stored_input[0] = ioport("IN0")->read() & 0x1f; |
| 1437 | stored_input[1] = (ioport("IN3")->read() & 0x07) << 3; |
| 1439 | 1438 | break; |
| 1440 | 1439 | |
| 1441 | 1440 | case 3: |
| 1442 | | stored_input[0] = space.machine().root_device().ioport("IN2")->read() & 0x1f; |
| 1441 | stored_input[0] = ioport("IN2")->read() & 0x1f; |
| 1443 | 1442 | break; |
| 1444 | 1443 | |
| 1445 | 1444 | case 4: |
| 1446 | | stored_input[0] = space.machine().root_device().ioport("IN1")->read() & 0x1f; |
| 1447 | | stored_input[1] = space.machine().root_device().ioport("IN3")->read() & 0x18; |
| 1445 | stored_input[0] = ioport("IN1")->read() & 0x1f; |
| 1446 | stored_input[1] = ioport("IN3")->read() & 0x18; |
| 1448 | 1447 | break; |
| 1449 | 1448 | |
| 1450 | 1449 | default: |
| r26338 | r26339 | |
| 1467 | 1466 | DRIVER_INIT_MEMBER(namcos1_state,faceoff) |
| 1468 | 1467 | { |
| 1469 | 1468 | namcos1_driver_init(machine(), NULL); |
| 1470 | | m_mcu->space(AS_PROGRAM).install_legacy_read_handler(0x1400, 0x1401, FUNC(faceoff_inputs_r)); |
| 1469 | m_mcu->space(AS_PROGRAM).install_read_handler(0x1400, 0x1401, read8_delegate(FUNC(namcos1_state::faceoff_inputs_r), this)); |
| 1471 | 1470 | } |