src/mame/audio/dkong.c
| r3514 | r3515 | |
| 18 | 18 | |
| 19 | 19 | /* Set to 1 to disable DAC and post-mixer filters */ |
| 20 | 20 | #define DK_NO_FILTERS (0) |
| 21 | /* Set to 1 to use faster custom mixer */ |
| 22 | #define DK_USE_CUSTOM (1) |
| 21 | 23 | |
| 22 | 24 | /* Issue surrounded by this define need to be analyzed and |
| 23 | 25 | * reviewed at a lator time. |
| r3514 | r3515 | |
| 50 | 52 | |
| 51 | 53 | #define DS_SOUND0 NODE_208 |
| 52 | 54 | #define DS_SOUND1 NODE_209 |
| 53 | | #define DS_SOUND2 NODE_210 |
| 54 | | #define DS_SOUND6 NODE_211 |
| 55 | | #define DS_SOUND7 NODE_212 |
| 56 | | #define DS_SOUND9 NODE_213 |
| 55 | #define DS_SOUND6 NODE_210 |
| 56 | #define DS_SOUND7 NODE_211 |
| 57 | #define DS_SOUND9 NODE_212 |
| 57 | 58 | |
| 58 | 59 | #define DS_ADJ_DAC NODE_240 |
| 59 | 60 | |
| r3514 | r3515 | |
| 183 | 184 | 0 /* Output bit */ |
| 184 | 185 | }; |
| 185 | 186 | |
| 187 | static const double dkong_diode_mix_table[2] = {DK_1N5553_V, DK_1N5553_V * 2}; |
| 188 | |
| 186 | 189 | static const discrete_mixer_desc dkong_rc_jump_desc = |
| 187 | 190 | { |
| 188 | 191 | DISC_MIXER_IS_RESISTOR, |
| r3514 | r3515 | |
| 252 | 255 | CAP_N(22), CAP_N(10), 0 |
| 253 | 256 | }; |
| 254 | 257 | |
| 258 | #if DK_USE_CUSTOM |
| 259 | /************************************************************************ |
| 260 | * |
| 261 | * Custom dkong mixer |
| 262 | * |
| 263 | * input[0] - In1 (Logic) |
| 264 | * input[1] - In2 |
| 265 | * input[2] - R1 |
| 266 | * input[3] - R2 |
| 267 | * input[4] - R3 |
| 268 | * input[5] - R4 |
| 269 | * input[6] - C |
| 270 | * input[7] - B+ |
| 271 | * |
| 272 | * V (B+) V (B+) |
| 273 | * v v |
| 274 | * | Node Output <----. .-- | ----- |
| 275 | * Z | | Z |
| 276 | * Z R1 | | Z 5k |
| 277 | * Z | | Z 555 |
| 278 | * |\ | R2 R4 | | internal |
| 279 | * In1 >---| >o--+---/\/\/\--+---/\/\/\---+-----------+ CV |
| 280 | * |/ | | | |
| 281 | * | --- | Z |
| 282 | * R3 | --- C | Z 10k |
| 283 | * In2 >----/\/\/\-----------' | | Z |
| 284 | * | '-- | ----- |
| 285 | * Gnd Gnd |
| 286 | * |
| 287 | ************************************************************************/ |
| 288 | #define DKONG_CUSTOM_IN1 (*(node->input[0])) |
| 289 | #define DKONG_CUSTOM_IN2 (*(node->input[1])) |
| 290 | #define DKONG_CUSTOM_R1 (*(node->input[2])) |
| 291 | #define DKONG_CUSTOM_R2 (*(node->input[3])) |
| 292 | #define DKONG_CUSTOM_R3 (*(node->input[4])) |
| 293 | #define DKONG_CUSTOM_R4 (*(node->input[5])) |
| 294 | #define DKONG_CUSTOM_C (*(node->input[6])) |
| 295 | #define DKONG_CUSTOM_V (*(node->input[7])) |
| 296 | |
| 297 | struct dkong_custom_mixer_context |
| 298 | { |
| 299 | double i_in1[2]; |
| 300 | double r_in[2]; |
| 301 | double r_total[2]; |
| 302 | double exp[2]; |
| 303 | }; |
| 304 | |
| 305 | static void dkong_custom_mixer_step(node_description *node) |
| 306 | { |
| 307 | struct dkong_custom_mixer_context *context = node->context; |
| 308 | |
| 309 | int in_1 = (int)DKONG_CUSTOM_IN1; |
| 310 | |
| 311 | /* start of with 555 current */ |
| 312 | double i_total = DKONG_CUSTOM_V / RES_K(5); |
| 313 | /* add in current from In1 */ |
| 314 | i_total += context->i_in1[in_1]; |
| 315 | /* add in current from In2 */ |
| 316 | i_total += DKONG_CUSTOM_IN2 / DKONG_CUSTOM_R3; |
| 317 | /* charge cap */ |
| 318 | /* node->output is cap voltage, (i_total * context->r_total[in_1]) is current charge voltage */ |
| 319 | node->output[0] += (i_total * context->r_total[in_1] - node->output[0]) * context->exp[in_1]; |
| 320 | } |
| 321 | |
| 322 | #define NE555_CV_R RES_2_PARALLEL(RES_K(5), RES_K(10)) |
| 323 | |
| 324 | static void dkong_custom_mixer_reset(node_description *node) |
| 325 | { |
| 326 | struct dkong_custom_mixer_context *context = node->context; |
| 327 | |
| 328 | /* everything is based on the input to the O.C. inverter */ |
| 329 | /* precalculate current from In1 */ |
| 330 | context->i_in1[0] = DKONG_CUSTOM_V / (DKONG_CUSTOM_R1 + DKONG_CUSTOM_R2); |
| 331 | context->i_in1[1] = 0; |
| 332 | /* precalculate total resistance for input circuit */ |
| 333 | context->r_in[0] = RES_2_PARALLEL((DKONG_CUSTOM_R1 + DKONG_CUSTOM_R2), DKONG_CUSTOM_R3); |
| 334 | context->r_in[1] = RES_2_PARALLEL(DKONG_CUSTOM_R2, DKONG_CUSTOM_R3); |
| 335 | /* precalculate total charging resistance */ |
| 336 | context->r_total[0] = RES_2_PARALLEL(context->r_in[0] + DKONG_CUSTOM_R4, NE555_CV_R); |
| 337 | context->r_total[1] = RES_2_PARALLEL((context->r_in[1] + DKONG_CUSTOM_R4), NE555_CV_R); |
| 338 | /* precalculate charging exponents */ |
| 339 | context->exp[0] = RC_CHARGE_EXP(context->r_total[0] * DKONG_CUSTOM_C); |
| 340 | context->exp[1] = RC_CHARGE_EXP(context->r_total[1] * DKONG_CUSTOM_C); |
| 341 | |
| 342 | node->output[0] = 0; |
| 343 | } |
| 344 | |
| 345 | static const discrete_custom_info dkong_custom_mixer_info = |
| 346 | { |
| 347 | &dkong_custom_mixer_reset, |
| 348 | &dkong_custom_mixer_step, |
| 349 | sizeof(struct dkong_custom_mixer_context), |
| 350 | NULL |
| 351 | }; |
| 352 | #endif |
| 353 | |
| 255 | 354 | static DISCRETE_SOUND_START(dkong2b) |
| 256 | 355 | |
| 257 | 356 | /************************************************/ |
| r3514 | r3515 | |
| 259 | 358 | /************************************************/ |
| 260 | 359 | |
| 261 | 360 | /* DISCRETE_INPUT_DATA */ |
| 262 | | DISCRETE_INPUT_NOT(DS_SOUND2_INV) |
| 263 | | DISCRETE_INPUT_NOT(DS_SOUND1_INV) |
| 264 | | DISCRETE_INPUT_NOT(DS_SOUND0_INV) |
| 265 | | DISCRETE_INPUT_NOT(DS_DISCHARGE_INV) |
| 266 | | DISCRETE_INPUT_DATA(DS_DAC) |
| 361 | DISCRETE_INPUT_NOT(DS_SOUND2_INV) |
| 362 | DISCRETE_INPUT_NOT(DS_SOUND1_INV) /* IC 6J, pin 12 */ |
| 363 | DISCRETE_INPUT_NOT(DS_SOUND0_INV) /* IC 6J, pin 2 */ |
| 364 | DISCRETE_INPUT_NOT(DS_DISCHARGE_INV) |
| 365 | DISCRETE_INPUT_DATA(DS_DAC) |
| 267 | 366 | /* Mixing - DAC */ |
| 268 | 367 | DISCRETE_ADJUSTMENT_TAG(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2") |
| 269 | 368 | |
| 270 | 369 | /************************************************/ |
| 271 | | /* SIGNALS */ |
| 272 | | /************************************************/ |
| 273 | | |
| 274 | | DISCRETE_LOGIC_INVERT(DS_SOUND0,1,DS_SOUND0_INV) |
| 275 | | DISCRETE_LOGIC_INVERT(DS_SOUND1,1,DS_SOUND1_INV) |
| 276 | | DISCRETE_LOGIC_INVERT(DS_SOUND2,1,DS_SOUND2_INV) |
| 277 | | |
| 278 | | /************************************************/ |
| 279 | 370 | /* Stomp */ |
| 280 | 371 | /************************************************/ |
| 281 | 372 | /* Noise */ |
| r3514 | r3515 | |
| 287 | 378 | /* C21 is discharged via Q5 BE */ |
| 288 | 379 | DISCRETE_RCDISC_MODULATED(NODE_15,DS_SOUND2_INV,0,DK_R10,0,0,DK_R9,DK_C21,DK_SUP_V) |
| 289 | 380 | /* Q5 */ |
| 290 | | DISCRETE_TRANSFORM2(NODE_16, NODE_15, 0.6, "01>") |
| 291 | | DISCRETE_RCDISC2(NODE_17,NODE_16,DK_SUP_V,DK_R8+DK_R7,0.0,DK_R7,DK_C20) |
| 381 | DISCRETE_TRANSFORM2(NODE_16, NODE_15, 0.6, "01>") |
| 382 | DISCRETE_RCDISC2(NODE_17,NODE_16,DK_SUP_V,DK_R8+DK_R7,0.0,DK_R7,DK_C20) |
| 292 | 383 | |
| 293 | | DISCRETE_DIODE_MIXER2(NODE_18, DK_1N5553_V, NODE_13, NODE_13) /* D3 */ |
| 294 | | DISCRETE_DIODE_MIXER2(NODE_20, DK_1N5553_V, NODE_17, NODE_18) /* D1, D2 */ |
| 384 | DISCRETE_DIODE_MIXER2(NODE_20, NODE_17, NODE_13, &dkong_diode_mix_table) /* D1, D2 + D3 */ |
| 295 | 385 | |
| 296 | | DISCRETE_RCINTEGRATE(NODE_22,NODE_20,DK_R5, RES_2_PARALLEL(DK_R4+DK_R3,DK_R6),0,DK_C19,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 297 | | DISCRETE_MULTIPLY(DS_OUT_SOUND0,1,NODE_22,DK_R3/R_SERIES(DK_R3,DK_R4)) |
| 386 | DISCRETE_RCINTEGRATE(NODE_22,NODE_20,DK_R5, RES_2_PARALLEL(DK_R4+DK_R3,DK_R6),0,DK_C19,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 387 | DISCRETE_MULTIPLY(DS_OUT_SOUND0,1,NODE_22,DK_R3/R_SERIES(DK_R3,DK_R4)) |
| 298 | 388 | |
| 299 | 389 | /************************************************/ |
| 300 | 390 | /* Jump */ |
| 301 | 391 | /************************************************/ |
| 302 | 392 | /* tt */ |
| 303 | | DISCRETE_MULTIPLY(NODE_24,1,DS_SOUND1,DK_SUP_V) |
| 304 | 393 | /* 4049B Inverter Oscillator build from 3 inverters */ |
| 305 | 394 | DISCRETE_INVERTER_OSC(NODE_25,1,0,DK_R38,DK_R39,DK_C26,0,&dkong_inverter_osc_desc_jump) |
| 306 | 395 | |
| 396 | #if DK_USE_CUSTOM |
| 397 | /* custom mixer for 555 CV voltage */ |
| 398 | DISCRETE_CUSTOM8(NODE_28, DS_SOUND1_INV, NODE_25, |
| 399 | DK_R32, DK_R50, DK_R51, DK_R49, DK_C24, DK_SUP_V, &dkong_custom_mixer_info) |
| 400 | #else |
| 401 | DISCRETE_LOGIC_INVERT(DS_SOUND1,1,DS_SOUND1_INV) |
| 402 | DISCRETE_MULTIPLY(NODE_24,1,DS_SOUND1,DK_SUP_V) |
| 307 | 403 | DISCRETE_TRANSFORM3(NODE_26,DS_SOUND1,DK_R32,DK_R49+DK_R50,"01*2+") |
| 308 | 404 | DISCRETE_MIXER4(NODE_28, 1, NODE_24, NODE_25, DK_SUP_V, 0,&dkong_rc_jump_desc) |
| 309 | | /* 555 Voltage controlled */ |
| 310 | | DISCRETE_555_ASTABLE_CV(NODE_29, 1, RES_K(47), RES_K(27), CAP_N(47), NODE_28, |
| 311 | | &dkong_555_vco_desc) |
| 405 | #endif |
| 406 | /* 555 Voltage controlled */ |
| 407 | DISCRETE_555_ASTABLE_CV(NODE_29, 1, RES_K(47), RES_K(27), CAP_N(47), NODE_28, |
| 408 | &dkong_555_vco_desc) |
| 312 | 409 | |
| 313 | 410 | /* Jump trigger */ |
| 314 | 411 | DISCRETE_RCDISC_MODULATED(NODE_33,DS_SOUND1_INV,0,DK_R32,0,0,DK_R31,DK_C18,DK_SUP_V) |
| 315 | 412 | |
| 316 | | DISCRETE_TRANSFORM2(NODE_34, NODE_33, 0.6, "01>") |
| 317 | | DISCRETE_RCDISC2(NODE_35, NODE_34,DK_SUP_V,R_SERIES(DK_R30,DK_R29),0.0,DK_R29,DK_C17) |
| 413 | DISCRETE_TRANSFORM2(NODE_34, NODE_33, 0.6, "01>") |
| 414 | DISCRETE_RCDISC2(NODE_35, NODE_34,DK_SUP_V,R_SERIES(DK_R30,DK_R29),0.0,DK_R29,DK_C17) |
| 318 | 415 | |
| 319 | | DISCRETE_DIODE_MIXER2(NODE_36, DK_1N5553_V, NODE_29, NODE_29) |
| 320 | | DISCRETE_DIODE_MIXER2(NODE_38, DK_1N5553_V, NODE_36, NODE_35) |
| 416 | DISCRETE_DIODE_MIXER2(NODE_38, NODE_35, NODE_29, &dkong_diode_mix_table) |
| 321 | 417 | |
| 322 | | DISCRETE_RCINTEGRATE(NODE_39,NODE_38,DK_R27, RES_2_PARALLEL(DK_R28,DK_R26+DK_R25),0,DK_C16,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 323 | | DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_39,DK_R25/(DK_R26+DK_R25)) |
| 418 | DISCRETE_RCINTEGRATE(NODE_39,NODE_38,DK_R27, RES_2_PARALLEL(DK_R28,DK_R26+DK_R25),0,DK_C16,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 419 | DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_39,DK_R25/(DK_R26+DK_R25)) |
| 324 | 420 | |
| 325 | 421 | /************************************************/ |
| 326 | 422 | /* Walk */ |
| 327 | 423 | /************************************************/ |
| 328 | | DISCRETE_MULTIPLY(NODE_50,1,DS_SOUND0,DK_SUP_V) |
| 329 | 424 | DISCRETE_INVERTER_OSC(NODE_51,1,0,DK_R47,DK_R48,DK_C30,0,&dkong_inverter_osc_desc_walk) |
| 330 | 425 | |
| 426 | #if DK_USE_CUSTOM |
| 427 | /* custom mixer for 555 CV voltage */ |
| 428 | DISCRETE_CUSTOM8(NODE_54, DS_SOUND0_INV, NODE_51, |
| 429 | DK_R36, DK_R45, DK_R46, DK_R44, DK_C29, DK_SUP_V, &dkong_custom_mixer_info) |
| 430 | #else |
| 431 | DISCRETE_LOGIC_INVERT(DS_SOUND0,1,DS_SOUND0_INV) |
| 432 | DISCRETE_MULTIPLY(NODE_50,1,DS_SOUND0,DK_SUP_V) |
| 331 | 433 | DISCRETE_TRANSFORM3(NODE_52,DS_SOUND0,DK_R46,R_SERIES(DK_R44,DK_R45),"01*2+") |
| 332 | 434 | DISCRETE_MIXER4(NODE_54, 1, NODE_50, NODE_51, DK_SUP_V, 0,&dkong_rc_walk_desc) |
| 435 | #endif |
| 333 | 436 | |
| 334 | | /* 555 Voltage controlled */ |
| 335 | | DISCRETE_555_ASTABLE_CV(NODE_55, 1, RES_K(47), RES_K(27), CAP_N(33), NODE_54, &dkong_555_vco_desc) |
| 437 | /* 555 Voltage controlled */ |
| 438 | DISCRETE_555_ASTABLE_CV(NODE_55, 1, RES_K(47), RES_K(27), CAP_N(33), NODE_54, &dkong_555_vco_desc) |
| 336 | 439 | /* Trigger */ |
| 337 | 440 | DISCRETE_RCDISC_MODULATED(NODE_60,DS_SOUND0_INV,NODE_55,DK_R36,DK_R18,DK_R35,DK_R17,DK_C25,DK_SUP_V) |
| 338 | 441 | /* Filter and divide - omitted C22 */ |
| r3514 | r3515 | |
| 372 | 475 | |
| 373 | 476 | /* Amplifier: internal amplifier */ |
| 374 | 477 | DISCRETE_ADDER2(NODE_289,1,NODE_288,5.0*43.0/(100.0+43.0)) |
| 375 | | DISCRETE_RCINTEGRATE(NODE_294,NODE_289,0,150,1000, CAP_U(33),DK_SUP_V,DISC_RC_INTEGRATE_TYPE3) |
| 376 | | DISCRETE_CRFILTER(NODE_295,1,NODE_294, RES_K(50), DK_C13) |
| 478 | DISCRETE_RCINTEGRATE(NODE_294,NODE_289,0,150,1000, CAP_U(33),DK_SUP_V,DISC_RC_INTEGRATE_TYPE3) |
| 479 | DISCRETE_CRFILTER(NODE_295,1,NODE_294, RES_K(50), DK_C13) |
| 377 | 480 | /*DISCRETE_CRFILTER(NODE_295,1,NODE_294, 1000, DK_C13) */ |
| 378 | 481 | /* EZV20 equivalent filter circuit ... */ |
| 379 | 482 | DISCRETE_CRFILTER(NODE_296,1,NODE_295, RES_K(1), CAP_U(4.7)) |
| r3514 | r3515 | |
| 515 | 618 | /************************************************/ |
| 516 | 619 | |
| 517 | 620 | /* DISCRETE_INPUT_DATA */ |
| 518 | | DISCRETE_INPUT_NOT(DS_SOUND0_INV) |
| 519 | | DISCRETE_INPUT_NOT(DS_SOUND1_INV) |
| 520 | | DISCRETE_INPUT_NOT(DS_SOUND2_INV) |
| 521 | | DISCRETE_INPUT_NOT(DS_SOUND6_INV) |
| 522 | | DISCRETE_INPUT_NOT(DS_SOUND7_INV) |
| 523 | | DISCRETE_INPUT_NOT(DS_DISCHARGE_INV) |
| 524 | | DISCRETE_INPUT_DATA(DS_DAC) |
| 621 | DISCRETE_INPUT_NOT(DS_SOUND0_INV) |
| 622 | DISCRETE_INPUT_NOT(DS_SOUND1_INV) |
| 623 | DISCRETE_INPUT_NOT(DS_SOUND2_INV) |
| 624 | DISCRETE_INPUT_NOT(DS_SOUND6_INV) |
| 625 | DISCRETE_INPUT_NOT(DS_SOUND7_INV) |
| 626 | DISCRETE_INPUT_NOT(DS_DISCHARGE_INV) |
| 627 | DISCRETE_INPUT_DATA(DS_DAC) |
| 525 | 628 | |
| 526 | 629 | /* Mixing - DAC */ |
| 527 | 630 | DISCRETE_ADJUSTMENT_TAG(DS_ADJ_DAC, 0, 1, DISC_LINADJ, "VR2") |
| r3514 | r3515 | |
| 550 | 653 | /* C21 is discharged via Q5 BE */ |
| 551 | 654 | |
| 552 | 655 | DISCRETE_RCDISC_MODULATED(NODE_16,DS_SOUND2_INV,0,RS_R_NN01,0,0,RS_R9*2,RS_C20,DK_SUP_V) |
| 553 | | DISCRETE_TRANSFORM2(NODE_17, NODE_16, 0.6, "01>") /* TR2 */ |
| 554 | | DISCRETE_RCDISC2(NODE_18,NODE_17,DK_SUP_V,RS_R8+RS_R7,0.0,RS_R7,RS_C19) |
| 656 | DISCRETE_TRANSFORM2(NODE_17, NODE_16, 0.6, "01>") /* TR2 */ |
| 657 | DISCRETE_RCDISC2(NODE_18,NODE_17,DK_SUP_V,RS_R8+RS_R7,0.0,RS_R7,RS_C19) |
| 555 | 658 | |
| 556 | | DISCRETE_DIODE_MIXER2(NODE_19, DK_1N5553_V, NODE_13, NODE_13) /* D3 */ |
| 557 | | DISCRETE_DIODE_MIXER2(NODE_20, DK_1N5553_V, NODE_18, NODE_19) /* D1, D2 */ |
| 659 | DISCRETE_DIODE_MIXER2(NODE_20, NODE_18, NODE_13, &dkong_diode_mix_table) /* D1, D2 + D3 */ |
| 558 | 660 | |
| 559 | | DISCRETE_RCINTEGRATE(NODE_22,NODE_20,RS_R5, RES_2_PARALLEL(RS_R4+RS_R3,RS_R6),0,RS_C18,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 560 | | DISCRETE_MULTIPLY(DS_OUT_SOUND2,1,NODE_22,RS_R3/R_SERIES(RS_R3,RS_R4)) |
| 661 | DISCRETE_RCINTEGRATE(NODE_22,NODE_20,RS_R5, RES_2_PARALLEL(RS_R4+RS_R3,RS_R6),0,RS_C18,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 662 | DISCRETE_MULTIPLY(DS_OUT_SOUND2,1,NODE_22,RS_R3/R_SERIES(RS_R3,RS_R4)) |
| 561 | 663 | |
| 562 | 664 | /************************************************/ |
| 563 | 665 | /* SOUND1 */ |
| r3514 | r3515 | |
| 566 | 668 | /* C21 is discharged via Q5 BE */ |
| 567 | 669 | |
| 568 | 670 | DISCRETE_RCDISC_MODULATED(NODE_26,DS_SOUND1_INV,0,RS_R_NN02,0,0,RS_R32,RS_C31,DK_SUP_V) |
| 569 | | DISCRETE_TRANSFORM2(NODE_27, NODE_26, 0.6, "01>") /* TR5 */ |
| 570 | | DISCRETE_RCDISC2(NODE_28,NODE_27,DK_SUP_V,RS_R31+RS_R30,0.0,RS_R30,RS_C30) |
| 671 | DISCRETE_TRANSFORM2(NODE_27, NODE_26, 0.6, "01>") /* TR5 */ |
| 672 | DISCRETE_RCDISC2(NODE_28,NODE_27,DK_SUP_V,RS_R31+RS_R30,0.0,RS_R30,RS_C30) |
| 571 | 673 | |
| 572 | | DISCRETE_DIODE_MIXER2(NODE_29, DK_1N5553_V, NODE_14, NODE_14) /* D3 */ |
| 573 | | DISCRETE_DIODE_MIXER2(NODE_30, DK_1N5553_V, NODE_28, NODE_29) /* D1, D2 */ |
| 674 | DISCRETE_DIODE_MIXER2(NODE_30, NODE_28, NODE_14, &dkong_diode_mix_table) /* D1, D2 + D3 */ |
| 574 | 675 | |
| 575 | | DISCRETE_RCINTEGRATE(NODE_31,NODE_30,RS_R28, RES_2_PARALLEL(RS_R27+RS_R26,RS_R29),0,RS_C29,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 576 | | DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_31,RS_R26/R_SERIES(RS_R26,RS_R27)) |
| 676 | DISCRETE_RCINTEGRATE(NODE_31,NODE_30,RS_R28, RES_2_PARALLEL(RS_R27+RS_R26,RS_R29),0,RS_C29,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 677 | DISCRETE_MULTIPLY(DS_OUT_SOUND1,1,NODE_31,RS_R26/R_SERIES(RS_R26,RS_R27)) |
| 577 | 678 | |
| 578 | 679 | /************************************************/ |
| 579 | 680 | /* SOUND0 */ |
| r3514 | r3515 | |
| 582 | 683 | DISCRETE_INVERTER_OSC(NODE_41,1,0,RS_R57,RS_R58,RS_C53,0,&radarscp_inverter_osc_desc_0) |
| 583 | 684 | DISCRETE_MIXER3(NODE_42, 1, NODE_41, DK_SUP_V, 0,&radarscp_mixer_desc_0) |
| 584 | 685 | |
| 585 | | /* 555 Voltage controlled */ |
| 586 | | DISCRETE_555_ASTABLE_CV(NODE_43, DS_SOUND6, RES_K(47), RES_K(27), RS_C49, NODE_42, &radarscp_555_vco_desc) |
| 686 | /* 555 Voltage controlled */ |
| 687 | DISCRETE_555_ASTABLE_CV(NODE_43, DS_SOUND6, RES_K(47), RES_K(27), RS_C49, NODE_42, &radarscp_555_vco_desc) |
| 587 | 688 | |
| 588 | 689 | DISCRETE_RCDISC_MODULATED(NODE_44,DS_SOUND0_INV,NODE_43,RS_R39,RS_R18,RS_R37,RS_R38,RS_C22,DK_SUP_V) |
| 589 | 690 | DISCRETE_CRFILTER(NODE_45, 1, NODE_44, RS_R15+RS_R16, RS_C33) |
| r3514 | r3515 | |
| 598 | 699 | DISCRETE_INVERTER_OSC(NODE_52,1,0,RS_R48,RS_R49,RS_C47,0,&radarscp_inverter_osc_desc_7) |
| 599 | 700 | |
| 600 | 701 | DISCRETE_MIXER3(NODE_53, 1, NODE_51, DK_SUP_V, 0,&radarscp_mixer_desc_7) |
| 601 | | /* 555 Voltage controlled */ |
| 602 | | DISCRETE_555_ASTABLE_CV(NODE_54, DS_SOUND7, RES_K(47), RES_K(27), RS_C48, NODE_53, &radarscp_555_vco_desc) |
| 702 | /* 555 Voltage controlled */ |
| 703 | DISCRETE_555_ASTABLE_CV(NODE_54, DS_SOUND7, RES_K(47), RES_K(27), RS_C48, NODE_53, &radarscp_555_vco_desc) |
| 603 | 704 | |
| 604 | | DISCRETE_RCINTEGRATE(NODE_55,NODE_52,RS_R46, RS_R46,0,RS_C45,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 605 | | DISCRETE_TRANSFORM4(NODE_56, NODE_55, DS_SOUND7,NODE_54,2.5, "01*23<*") |
| 705 | DISCRETE_RCINTEGRATE(NODE_55,NODE_52,RS_R46, RS_R46,0,RS_C45,DK_SUP_V,DISC_RC_INTEGRATE_TYPE1) |
| 706 | DISCRETE_TRANSFORM4(NODE_56, NODE_55, DS_SOUND7,NODE_54,2.5, "01*23<*") |
| 606 | 707 | DISCRETE_CRFILTER(NODE_57, 1, NODE_56, RS_R43+RS_R44, RS_C46) |
| 607 | 708 | DISCRETE_MULTIPLY(DS_OUT_SOUND7, 1, NODE_57, RS_R44/(RS_R43+RS_R44)) |
| 608 | 709 | |
| r3514 | r3515 | |
| 634 | 735 | |
| 635 | 736 | /* Amplifier: internal amplifier */ |
| 636 | 737 | DISCRETE_ADDER2(NODE_289,1,NODE_288,5.0*43.0/(100.0+43.0)) |
| 637 | | DISCRETE_RCINTEGRATE(NODE_294,NODE_289,0,150,1000, CAP_U(33),DK_SUP_V,DISC_RC_INTEGRATE_TYPE3) |
| 738 | DISCRETE_RCINTEGRATE(NODE_294,NODE_289,0,150,1000, CAP_U(33),DK_SUP_V,DISC_RC_INTEGRATE_TYPE3) |
| 638 | 739 | DISCRETE_CRFILTER(NODE_295,1,NODE_294, 1000, DK_C13) |
| 639 | 740 | DISCRETE_OUTPUT(NODE_295, 32767.0/5.0 * 3) |
| 640 | 741 | |
| r3514 | r3515 | |
| 748 | 849 | /************************************************/ |
| 749 | 850 | |
| 750 | 851 | /* DISCRETE_INPUT_DATA */ |
| 751 | | DISCRETE_INPUT_NOT(DS_SOUND0_INV) |
| 752 | | DISCRETE_INPUT_NOT(DS_SOUND1_INV) |
| 753 | | DISCRETE_INPUT_NOT(DS_SOUND2_INV) |
| 754 | | DISCRETE_INPUT_NOT(DS_SOUND6_INV) |
| 755 | | DISCRETE_INPUT_NOT(DS_SOUND7_INV) |
| 756 | | DISCRETE_INPUT_NOT(DS_SOUND9_INV) |
| 757 | | DISCRETE_INPUT_NOT(DS_DISCHARGE_INV) |
| 758 | | DISCRETE_INPUT_DATA(DS_DAC) |
| 852 | DISCRETE_INPUT_NOT(DS_SOUND0_INV) |
| 853 | DISCRETE_INPUT_NOT(DS_SOUND1_INV) |
| 854 | DISCRETE_INPUT_NOT(DS_SOUND2_INV) |
| 855 | DISCRETE_INPUT_NOT(DS_SOUND6_INV) |
| 856 | DISCRETE_INPUT_NOT(DS_SOUND7_INV) |
| 857 | DISCRETE_INPUT_NOT(DS_SOUND9_INV) |
| 858 | DISCRETE_INPUT_NOT(DS_DISCHARGE_INV) |
| 859 | DISCRETE_INPUT_DATA(DS_DAC) |
| 759 | 860 | |
| 760 | 861 | /************************************************/ |
| 761 | 862 | /* SIGNALS */ |
| 762 | 863 | /************************************************/ |
| 763 | 864 | |
| 764 | | DISCRETE_LOGIC_INVERT(DS_SOUND7,1,DS_SOUND7_INV) |
| 865 | DISCRETE_LOGIC_INVERT(DS_SOUND7,1,DS_SOUND7_INV) |
| 765 | 866 | DISCRETE_LOGIC_INVERT(DS_SOUND9,1,DS_SOUND9_INV) |
| 766 | 867 | |
| 767 | 868 | /************************************************/ |
| r3514 | r3515 | |
| 872 | 973 | * |
| 873 | 974 | ****************************************************************/ |
| 874 | 975 | |
| 875 | | SOUND_START( dkong) |
| 976 | static SOUND_START( dkong) |
| 876 | 977 | { |
| 877 | 978 | dkong_state *state = machine->driver_data; |
| 878 | 979 | |
| r3514 | r3515 | |
| 1052 | 1153 | |
| 1053 | 1154 | static ADDRESS_MAP_START( dkong_sound_io_map, ADDRESS_SPACE_IO, 8 ) |
| 1054 | 1155 | AM_RANGE(0x00, 0xFF) AM_DEVREAD(LATCH8, "ls175.3d", dkong_tune_r) |
| 1055 | | AM_WRITE(dkong_voice_w) |
| 1156 | AM_WRITE(dkong_voice_w) |
| 1056 | 1157 | AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_DEVREAD(LATCH8, "ls175.3d", dkong_tune_r) |
| 1057 | | AM_WRITE(dkong_voice_w) |
| 1158 | AM_WRITE(dkong_voice_w) |
| 1058 | 1159 | AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(dkong_p1_w) /* only write to dac */ |
| 1059 | 1160 | AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_LATCH8_READWRITE("virtual_p2") |
| 1060 | 1161 | AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_LATCH8_READBIT("ls259.6h", 5) |
| r3514 | r3515 | |
| 1073 | 1174 | AM_RANGE(0x00, 0x00) AM_MIRROR(0xff) AM_DEVREAD(LATCH8, "ls175.3d", latch8_r) |
| 1074 | 1175 | AM_RANGE(0x00, 0xff) AM_WRITE(dkong_p1_w) /* DAC here */ |
| 1075 | 1176 | AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_LATCH8_READ("virtual_p1") |
| 1076 | | AM_WRITE(M58817_command_w) |
| 1177 | AM_WRITE(M58817_command_w) |
| 1077 | 1178 | AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_LATCH8_WRITE("virtual_p2") |
| 1078 | 1179 | AM_RANGE(MCS48_PORT_T0, MCS48_PORT_T0) AM_LATCH8_READBIT("ls259.6h", 5) |
| 1079 | 1180 | AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_LATCH8_READBIT("ls259.6h", 4) |
src/mame/drivers/megadriv.c
| r3514 | r3515 | |
| 94 | 94 | static int _32x_slave_cpu_number; |
| 95 | 95 | static int _32x_is_connected; |
| 96 | 96 | |
| 97 | static int sh2_are_running; |
| 98 | static int _32x_adapter_enabled; |
| 99 | static int _32x_access_auth; |
| 100 | static int _32x_screenshift; |
| 101 | |
| 102 | static int sh2_master_vint_enable, sh2_slave_vint_enable; |
| 103 | static int sh2_master_hint_enable, sh2_slave_hint_enable; |
| 104 | static int sh2_master_cmdint_enable, sh2_slave_cmdint_enable; |
| 105 | static int sh2_master_pwmint_enable, sh2_slave_pwnint_enable; |
| 106 | |
| 107 | |
| 108 | #define SH2_VRES_IRQ_LEVEL 14 |
| 109 | #define SH2_VINT_IRQ_LEVEL 12 |
| 110 | #define SH2_HINT_IRQ_LEVEL 10 |
| 111 | #define SH2_CINT_IRQ_LEVEL 8 |
| 112 | #define SH2_PINT_IRQ_LEVEL 6 |
| 113 | |
| 114 | |
| 97 | 115 | static UINT16* _32x_dram0; |
| 98 | 116 | static UINT16* _32x_dram1; |
| 99 | 117 | static UINT16 *_32x_display_dram, *_32x_access_dram; |
| r3514 | r3515 | |
| 107 | 125 | |
| 108 | 126 | static int _genesis_snd_z80_cpu_number; |
| 109 | 127 | |
| 110 | | int segac2_bg_pal_lookup[4] = { 0x00, 0x10, 0x20, 0x30 }; |
| 111 | | int segac2_sp_pal_lookup[4] = { 0x00, 0x10, 0x20, 0x30 }; |
| 128 | int segac2_bg_pal_lookup[4]; |
| 129 | int segac2_sp_pal_lookup[4]; |
| 112 | 130 | |
| 113 | 131 | // hacks for C2 |
| 114 | | int genvdp_use_cram = 1; // c2 uses it's own palette ram |
| 132 | int genvdp_use_cram = 0; // c2 uses it's own palette ram |
| 115 | 133 | int genesis_has_z80; |
| 116 | 134 | int genesis_always_irq6 = 0; // c2 never enables the irq6, different source?? |
| 117 | | int genesis_other_hacks = 1; // misc hacks |
| 135 | int genesis_other_hacks = 0; // misc hacks |
| 118 | 136 | |
| 119 | 137 | INLINE UINT16 get_hposition(void); |
| 120 | 138 | |
| r3514 | r3515 | |
| 2507 | 2525 | /****************************************** 32X related ******************************************/ |
| 2508 | 2526 | |
| 2509 | 2527 | |
| 2528 | |
| 2529 | static READ16_HANDLER( _32x_68k_palette_r ) |
| 2530 | { |
| 2531 | return _32x_palette[offset]; |
| 2532 | } |
| 2533 | |
| 2534 | static WRITE16_HANDLER( _32x_68k_palette_w ) |
| 2535 | { |
| 2536 | int r,g,b, p; |
| 2537 | |
| 2538 | COMBINE_DATA(&_32x_palette[offset]); |
| 2539 | data = _32x_palette[offset]; |
| 2540 | |
| 2541 | r = ((data >> 0) & 0x1f); |
| 2542 | g = ((data >> 5) & 0x1f); |
| 2543 | b = ((data >> 10) & 0x1f); |
| 2544 | p = ((data >> 15) & 0x01); // priority 'through' bit |
| 2545 | |
| 2546 | _32x_palette_lookup[offset] = (r << 10) | (g << 5) | (b << 0); |
| 2547 | |
| 2548 | palette_set_color_rgb(Machine,offset+0x40,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 2549 | |
| 2550 | } |
| 2551 | |
| 2552 | static WRITE32_HANDLER( _32x_sh2_palette_w) |
| 2553 | { |
| 2554 | |
| 2555 | if (ACCESSING_BITS_16_31) |
| 2556 | { |
| 2557 | _32x_68k_palette_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 2558 | } |
| 2559 | |
| 2560 | if (ACCESSING_BITS_0_15) |
| 2561 | { |
| 2562 | _32x_68k_palette_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 2563 | } |
| 2564 | } |
| 2565 | |
| 2566 | |
| 2567 | static READ16_HANDLER( _32x_68k_dram_r ) |
| 2568 | { |
| 2569 | return _32x_access_dram[offset]; |
| 2570 | } |
| 2571 | |
| 2572 | static WRITE16_HANDLER( _32x_68k_dram_w ) |
| 2573 | { |
| 2574 | COMBINE_DATA(&_32x_access_dram[offset]); |
| 2575 | } |
| 2576 | |
| 2577 | |
| 2578 | static WRITE32_HANDLER( _32x_sh2_dram_w) |
| 2579 | { |
| 2580 | |
| 2581 | if (ACCESSING_BITS_16_31) |
| 2582 | { |
| 2583 | _32x_68k_dram_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 2584 | } |
| 2585 | |
| 2586 | if (ACCESSING_BITS_0_15) |
| 2587 | { |
| 2588 | _32x_68k_dram_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 2589 | } |
| 2590 | } |
| 2591 | |
| 2592 | |
| 2593 | static WRITE16_HANDLER( _32x_68k_dram_overwrite_w ) |
| 2594 | { |
| 2595 | if (ACCESSING_BITS_8_15) |
| 2596 | { |
| 2597 | if (data & 0xff00) |
| 2598 | { |
| 2599 | _32x_access_dram[offset] = (_32x_access_dram[offset]&0x00ff) | (data & 0xff00); |
| 2600 | } |
| 2601 | } |
| 2602 | |
| 2603 | if (ACCESSING_BITS_0_7) |
| 2604 | { |
| 2605 | if (data & 0x00ff) |
| 2606 | { |
| 2607 | _32x_access_dram[offset] = (_32x_access_dram[offset]&0xff00) | (data & 0x00ff); |
| 2608 | } |
| 2609 | } |
| 2610 | } |
| 2611 | |
| 2612 | static WRITE32_HANDLER( _32x_sh2_dram_overwrite_w ) |
| 2613 | { |
| 2614 | if (ACCESSING_BITS_16_31) |
| 2615 | { |
| 2616 | _32x_68k_dram_overwrite_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 2617 | } |
| 2618 | |
| 2619 | if (ACCESSING_BITS_0_15) |
| 2620 | { |
| 2621 | _32x_68k_dram_overwrite_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 2622 | } |
| 2623 | } |
| 2624 | |
| 2625 | |
| 2626 | |
| 2627 | static READ32_HANDLER( _32x_sh2_dram_r ) |
| 2628 | { |
| 2629 | UINT32 retvalue = 0x00000000; |
| 2630 | |
| 2631 | if (ACCESSING_BITS_16_31) // 4108 |
| 2632 | { |
| 2633 | UINT16 ret = 0x0000; |
| 2634 | ret = _32x_68k_dram_r(machine,offset*2,(mem_mask>>16)&0xffff); |
| 2635 | retvalue |= ret << 16; |
| 2636 | } |
| 2637 | |
| 2638 | if (ACCESSING_BITS_0_15) // 4108 |
| 2639 | { |
| 2640 | UINT16 ret = 0x0000; |
| 2641 | ret = _32x_68k_dram_r(machine,offset*2+1,(mem_mask>>0)&0xffff); |
| 2642 | retvalue |= ret << 0; |
| 2643 | } |
| 2644 | |
| 2645 | return retvalue; |
| 2646 | } |
| 2647 | |
| 2648 | |
| 2649 | /* |
| 2650 | a1518a / 410a |
| 2651 | |
| 2652 | vhp- ---- ---- --fb |
| 2653 | |
| 2654 | v = 1=vblank r/o |
| 2655 | h = 1=hblank r/o |
| 2656 | p = 0=palette access approval r/o |
| 2657 | - = unused |
| 2658 | f = 0=MD framebuffer access, 1 = SH2 r/o |
| 2659 | b = 0=DRAM0 accessed by VDP, 1=DRAM1 r/w |
| 2660 | */ |
| 2661 | static UINT16 _32x_a1518a_reg; |
| 2662 | static READ16_HANDLER( _32x_68k_fbcontrol_r ) |
| 2663 | { |
| 2664 | UINT16 retdata = _32x_a1518a_reg; |
| 2665 | UINT16 hpos = get_hposition(); |
| 2666 | int megadrive_hblank_flag = 0; |
| 2667 | |
| 2668 | if (megadrive_vblank_flag) retdata |= 0x8000; |
| 2669 | |
| 2670 | if (hpos>400) megadrive_hblank_flag = 1; |
| 2671 | if (hpos>460) megadrive_hblank_flag = 0; |
| 2672 | |
| 2673 | if (megadrive_hblank_flag) retdata |= 0x4000; |
| 2674 | |
| 2675 | // printf("_32x_68k_fbcontrol_r\n"); |
| 2676 | |
| 2677 | |
| 2678 | return retdata; |
| 2679 | } |
| 2680 | |
| 2681 | static WRITE16_HANDLER( _32x_68k_fbcontrol_w ) |
| 2682 | { |
| 2683 | // bit 0 is the framebuffer select; |
| 2684 | _32x_a1518a_reg = (_32x_a1518a_reg & 0xfffe) | (data & 1); |
| 2685 | |
| 2686 | if (_32x_a1518a_reg & 1) |
| 2687 | { |
| 2688 | _32x_access_dram = _32x_dram0; |
| 2689 | _32x_display_dram = _32x_dram1; |
| 2690 | } |
| 2691 | else |
| 2692 | { |
| 2693 | _32x_display_dram = _32x_dram0; |
| 2694 | _32x_access_dram = _32x_dram1; |
| 2695 | } |
| 2696 | } |
| 2697 | |
| 2698 | |
| 2699 | static READ32_HANDLER( sh2_4108_410a_r ) |
| 2700 | { |
| 2701 | UINT32 retvalue = 0x00000000; |
| 2702 | if (ACCESSING_BITS_16_31) // 4108 |
| 2703 | { |
| 2704 | UINT16 ret = 0x0000; |
| 2705 | printf("sh2 read access 4108\n"); |
| 2706 | retvalue |= (ret << 16); |
| 2707 | } |
| 2708 | if (ACCESSING_BITS_0_15) // 410a |
| 2709 | { |
| 2710 | UINT16 ret = 0x0000; |
| 2711 | ret = _32x_68k_fbcontrol_r(machine, offset*2+1, mem_mask); |
| 2712 | retvalue |= ret; |
| 2713 | |
| 2714 | } |
| 2715 | return retvalue; |
| 2716 | } |
| 2717 | |
| 2718 | |
| 2719 | static WRITE32_HANDLER( sh2_4108_410a_w ) |
| 2720 | { |
| 2721 | if (ACCESSING_BITS_16_31) // 4108 |
| 2722 | { |
| 2723 | printf("sh2 write access 4108\n"); |
| 2724 | } |
| 2725 | if (ACCESSING_BITS_0_15) // 410a |
| 2726 | { |
| 2727 | _32x_68k_fbcontrol_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 2728 | } |
| 2729 | } |
| 2730 | |
| 2731 | static READ16_HANDLER( _32x_4100_r ) |
| 2732 | { |
| 2733 | return 0x0000; |
| 2734 | } |
| 2735 | |
| 2736 | static READ16_HANDLER( _32x_4102_r ) |
| 2737 | { |
| 2738 | return 0x0000; |
| 2739 | } |
| 2740 | |
| 2741 | static READ32_HANDLER( sh2_4100_4102_r ) |
| 2742 | { |
| 2743 | UINT32 retvalue = 0x00000000; |
| 2744 | if (ACCESSING_BITS_16_31) // 4100 |
| 2745 | { |
| 2746 | UINT16 ret = 0x0000; |
| 2747 | ret = _32x_4100_r(machine, offset*2, mem_mask>>16); |
| 2748 | retvalue |= (ret << 16); |
| 2749 | } |
| 2750 | if (ACCESSING_BITS_0_15) // 4102 |
| 2751 | { |
| 2752 | UINT16 ret = 0x0000; |
| 2753 | ret = _32x_4102_r(machine, offset*2+1, mem_mask); |
| 2754 | retvalue |= ret; |
| 2755 | |
| 2756 | } |
| 2757 | return retvalue; |
| 2758 | } |
| 2759 | |
| 2760 | |
| 2761 | static WRITE16_HANDLER( _32x_4100_w ) |
| 2762 | { |
| 2763 | |
| 2764 | } |
| 2765 | |
| 2766 | static WRITE16_HANDLER( _32x_4102_w ) |
| 2767 | { |
| 2768 | _32x_screenshift = data & 1; // allows 1 pixel shifting |
| 2769 | //printf("screenshift %d\n",_32x_screenshift); |
| 2770 | } |
| 2771 | |
| 2772 | static WRITE32_HANDLER( sh2_4100_4102_w ) |
| 2773 | { |
| 2774 | if (ACCESSING_BITS_16_31) // 4100 |
| 2775 | { |
| 2776 | _32x_4100_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 2777 | } |
| 2778 | if (ACCESSING_BITS_0_15) // 4102 |
| 2779 | { |
| 2780 | _32x_4102_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 2781 | } |
| 2782 | } |
| 2783 | |
| 2784 | |
| 2510 | 2785 | static ADDRESS_MAP_START( sh2_main_map, ADDRESS_SPACE_PROGRAM, 32 ) |
| 2511 | | AM_RANGE(0x0000000 , 0x0003fff) AM_ROM |
| 2786 | AM_RANGE(0x00000000, 0x00003fff) AM_ROM |
| 2787 | |
| 2788 | AM_RANGE(0x00004100, 0x00004103) AM_READWRITE( sh2_4100_4102_r, sh2_4100_4102_w ) |
| 2789 | AM_RANGE(0x00004108, 0x0000410b) AM_READWRITE( sh2_4108_410a_r, sh2_4108_410a_w ) |
| 2790 | |
| 2791 | AM_RANGE(0x00004200, 0x000043ff) AM_WRITE(_32x_sh2_palette_w) |
| 2792 | AM_RANGE(0x04000000, 0x0401ffff) AM_READWRITE(_32x_sh2_dram_r, _32x_sh2_dram_w) |
| 2793 | AM_RANGE(0x04020000, 0x0403ffff) AM_WRITE(_32x_sh2_dram_overwrite_w) |
| 2794 | |
| 2795 | AM_RANGE(0x06000000, 0x0603ffff) AM_RAM AM_SHARE(10) |
| 2796 | AM_RANGE(0x02000000, 0x023fffff) AM_ROM AM_REGION("gamecart_sh2", 0) |
| 2797 | |
| 2798 | AM_RANGE(0xc0000000, 0xc00003ff) AM_RAM |
| 2512 | 2799 | ADDRESS_MAP_END |
| 2513 | 2800 | |
| 2514 | 2801 | static ADDRESS_MAP_START( sh2_slave_map, ADDRESS_SPACE_PROGRAM, 32 ) |
| 2515 | | AM_RANGE(0x0000000 , 0x0003fff) AM_ROM |
| 2802 | AM_RANGE(0x00000000, 0x00003fff) AM_ROM |
| 2803 | |
| 2804 | AM_RANGE(0x00004108, 0x0000410b) AM_READWRITE( sh2_4108_410a_r, sh2_4108_410a_w ) |
| 2805 | |
| 2806 | AM_RANGE(0x00004200, 0x000043ff) AM_WRITE(_32x_sh2_palette_w) |
| 2807 | AM_RANGE(0x04000000, 0x0401ffff) AM_READWRITE(_32x_sh2_dram_r, _32x_sh2_dram_w) |
| 2808 | AM_RANGE(0x04020000, 0x0403ffff) AM_WRITE(_32x_sh2_dram_overwrite_w) |
| 2809 | |
| 2810 | AM_RANGE(0x06000000, 0x0603ffff) AM_RAM AM_SHARE(10) |
| 2811 | AM_RANGE(0x02000000, 0x023fffff) AM_ROM AM_REGION("gamecart_sh2", 0) |
| 2812 | |
| 2813 | AM_RANGE(0xc0000000, 0xc00003ff) AM_RAM |
| 2516 | 2814 | ADDRESS_MAP_END |
| 2517 | 2815 | |
| 2518 | 2816 | static ADDRESS_MAP_START( segacd_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| r3514 | r3515 | |
| 4340 | 4638 | if (_32x_is_connected) |
| 4341 | 4639 | { |
| 4342 | 4640 | UINT32 lineoffs; |
| 4641 | int start; |
| 4642 | |
| 4343 | 4643 | lineoffs = _32x_display_dram[scanline]; |
| 4344 | 4644 | |
| 4345 | | for (x=0;x<320;x++) |
| 4645 | if (_32x_screenshift == 0) start=0; |
| 4646 | else start = -1; |
| 4647 | |
| 4648 | for (x=start;x<320;x++) |
| 4346 | 4649 | { |
| 4347 | 4650 | UINT16 coldata; |
| 4348 | 4651 | coldata = _32x_display_dram[lineoffs]; |
| 4349 | 4652 | |
| 4350 | 4653 | { |
| 4351 | | if ((_32x_palette[(coldata & 0xff00)>>8] & 0x8000)==0x8000) |
| 4352 | | lineptr[x] = _32x_palette_lookup[(coldata & 0xff00)>>8]; |
| 4654 | if (x>=0) |
| 4655 | if ((_32x_palette[(coldata & 0xff00)>>8] & 0x8000)==0x8000) |
| 4656 | lineptr[x] = _32x_palette_lookup[(coldata & 0xff00)>>8]; |
| 4353 | 4657 | |
| 4354 | 4658 | x++; |
| 4355 | 4659 | |
| 4356 | | if ((_32x_palette[(coldata & 0x00ff)>>0] & 0x8000)==0x8000) |
| 4357 | | lineptr[x] = _32x_palette_lookup[(coldata & 0x00ff)]; |
| 4660 | if (x>=0) |
| 4661 | if ((_32x_palette[(coldata & 0x00ff)>>0] & 0x8000)==0x8000) |
| 4662 | lineptr[x] = _32x_palette_lookup[(coldata & 0x00ff)]; |
| 4358 | 4663 | } |
| 4359 | 4664 | |
| 4360 | 4665 | lineoffs++; |
| r3514 | r3515 | |
| 4706 | 5011 | timer_adjust_oneshot(irq6_on_timer, ATTOTIME_IN_USEC(6), 0); |
| 4707 | 5012 | megadrive_irq6_pending = 1; |
| 4708 | 5013 | megadrive_vblank_flag = 1; |
| 5014 | |
| 5015 | // 32x interrupt! |
| 5016 | if (_32x_is_connected) |
| 5017 | { |
| 5018 | if (sh2_master_vint_enable) cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_VINT_IRQ_LEVEL,ASSERT_LINE); |
| 5019 | if (sh2_slave_vint_enable) cpunum_set_input_line(machine, _32x_slave_cpu_number,SH2_VINT_IRQ_LEVEL,ASSERT_LINE); |
| 5020 | } |
| 5021 | |
| 4709 | 5022 | } |
| 4710 | 5023 | |
| 4711 | 5024 | if (megadrive_vblank_flag>=224) |
| r3514 | r3515 | |
| 4872 | 5185 | if (_32x_master_cpu_number != -1) |
| 4873 | 5186 | { |
| 4874 | 5187 | cpunum_set_input_line(machine, _32x_master_cpu_number, INPUT_LINE_RESET, ASSERT_LINE); |
| 4875 | | cpunum_set_input_line(machine, _32x_master_cpu_number, INPUT_LINE_HALT, ASSERT_LINE); |
| 4876 | 5188 | } |
| 4877 | 5189 | |
| 4878 | 5190 | if (_32x_slave_cpu_number != -1) |
| 4879 | 5191 | { |
| 4880 | 5192 | cpunum_set_input_line(machine, _32x_slave_cpu_number, INPUT_LINE_RESET, ASSERT_LINE); |
| 4881 | | cpunum_set_input_line(machine, _32x_slave_cpu_number, INPUT_LINE_HALT, ASSERT_LINE); |
| 4882 | 5193 | } |
| 4883 | 5194 | |
| 4884 | 5195 | if (_segacd_68k_cpu_number != -1 ) |
| r3514 | r3515 | |
| 5184 | 5495 | MDRV_CPU_ADD("32x_slave_sh2", SH2, (MASTER_CLOCK_NTSC*3)/7 ) |
| 5185 | 5496 | MDRV_CPU_PROGRAM_MAP(sh2_slave_map, 0) |
| 5186 | 5497 | MDRV_CPU_CONFIG(sh2_conf_slave) |
| 5498 | |
| 5187 | 5499 | MACHINE_DRIVER_END |
| 5188 | 5500 | |
| 5189 | 5501 | MACHINE_DRIVER_START( genesis_scd ) |
| r3514 | r3515 | |
| 5435 | 5747 | // these are tests for 'special case' hardware to make sure I don't break anything while rearranging things |
| 5436 | 5748 | // |
| 5437 | 5749 | |
| 5438 | | /* |
| 5439 | | a1518a / 410a |
| 5750 | static UINT16 _32x_autofill_length; |
| 5751 | static UINT16 _32x_autofill_address; |
| 5752 | static UINT16 _32x_autofill_data; |
| 5440 | 5753 | |
| 5441 | | vhp- ---- ---- --fb |
| 5754 | static UINT16 _32x_a15104; |
| 5442 | 5755 | |
| 5443 | | v = 1=vblank r/o |
| 5444 | | h = 1=hblank r/o |
| 5445 | | p = 0=palette access approval r/o |
| 5446 | | - = unused |
| 5447 | | f = 0=MD framebuffer access, 1 = SH2 r/o |
| 5448 | | b = 0=DRAM0 accessed by VDP, 1=DRAM1 r/w |
| 5449 | | */ |
| 5450 | | static UINT16 _32x_a1518a_reg; |
| 5451 | | static READ16_HANDLER( _32x_68k_fbcontrol_r ) |
| 5452 | | { |
| 5756 | // 4014 VRES IRQ Clear Register |
| 5757 | static WRITE16_HANDLER( sh2_master_4014_w ){cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_VRES_IRQ_LEVEL,CLEAR_LINE);} |
| 5758 | static WRITE16_HANDLER( sh2_slave_4014_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_VRES_IRQ_LEVEL,CLEAR_LINE);} |
| 5759 | // 4016 VINT IRQ Clear Register |
| 5760 | static WRITE16_HANDLER( sh2_master_4016_w ){cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_VINT_IRQ_LEVEL,CLEAR_LINE);} |
| 5761 | static WRITE16_HANDLER( sh2_slave_4016_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_VINT_IRQ_LEVEL,CLEAR_LINE);} |
| 5762 | // 4018 HINT IRQ Clear Register |
| 5763 | static WRITE16_HANDLER( sh2_master_4018_w ){ cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_HINT_IRQ_LEVEL,CLEAR_LINE);} |
| 5764 | static WRITE16_HANDLER( sh2_slave_4018_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_HINT_IRQ_LEVEL,CLEAR_LINE);} |
| 5765 | // 401A CMD IRQ Clear Register |
| 5766 | static WRITE16_HANDLER( sh2_master_401a_w ){ cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_CINT_IRQ_LEVEL,CLEAR_LINE);} |
| 5767 | static WRITE16_HANDLER( sh2_slave_401a_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_CINT_IRQ_LEVEL,CLEAR_LINE);} |
| 5768 | // 401C PWM IRQ Clear Register |
| 5769 | static WRITE16_HANDLER( sh2_master_401c_w ){ cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_PINT_IRQ_LEVEL,CLEAR_LINE);} |
| 5770 | static WRITE16_HANDLER( sh2_slave_401c_w ) { cpunum_set_input_line(machine, _32x_slave_cpu_number, SH2_PINT_IRQ_LEVEL,CLEAR_LINE);} |
| 5453 | 5771 | |
| 5454 | | UINT16 retdata = _32x_a1518a_reg; |
| 5455 | | UINT16 hpos = get_hposition(); |
| 5456 | | int megadrive_hblank_flag = 0; |
| 5457 | 5772 | |
| 5458 | | if (megadrive_vblank_flag) retdata |= 0x8000; |
| 5773 | static READ32_HANDLER( sh2_master_4014_4016_r ) |
| 5774 | { |
| 5775 | if (ACCESSING_BITS_16_31) |
| 5776 | { |
| 5777 | sh2_master_4014_w(machine,offset*2,(0x0000>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 5778 | } |
| 5459 | 5779 | |
| 5460 | | if (hpos>400) megadrive_hblank_flag = 1; |
| 5461 | | if (hpos>460) megadrive_hblank_flag = 0; |
| 5780 | if (ACCESSING_BITS_0_15) |
| 5781 | { |
| 5782 | sh2_master_4016_w(machine,offset*2+1,(0x0000>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 5783 | } |
| 5462 | 5784 | |
| 5463 | | if (megadrive_hblank_flag) retdata |= 0x4000; |
| 5464 | | |
| 5465 | | return retdata; |
| 5785 | return 0x0000; |
| 5466 | 5786 | } |
| 5467 | 5787 | |
| 5468 | | static WRITE16_HANDLER( _32x_68k_fbcontrol_w ) |
| 5788 | static WRITE32_HANDLER( sh2_master_4014_4016_w ) |
| 5469 | 5789 | { |
| 5470 | | // bit 0 is the framebuffer select; |
| 5471 | | _32x_a1518a_reg = (_32x_a1518a_reg & 0xfffe) | (data & 1); |
| 5790 | if (ACCESSING_BITS_16_31) |
| 5791 | { |
| 5792 | sh2_master_4014_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 5793 | } |
| 5472 | 5794 | |
| 5473 | | if (_32x_a1518a_reg & 1) |
| 5795 | if (ACCESSING_BITS_0_15) |
| 5474 | 5796 | { |
| 5475 | | _32x_access_dram = _32x_dram0; |
| 5476 | | _32x_display_dram = _32x_dram1; |
| 5797 | sh2_master_4016_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 5477 | 5798 | } |
| 5478 | | else |
| 5799 | } |
| 5800 | |
| 5801 | static WRITE32_HANDLER( sh2_slave_4014_4016_w ) |
| 5802 | { |
| 5803 | if (ACCESSING_BITS_16_31) |
| 5479 | 5804 | { |
| 5480 | | _32x_display_dram = _32x_dram0; |
| 5481 | | _32x_access_dram = _32x_dram1; |
| 5805 | sh2_slave_4014_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 5482 | 5806 | } |
| 5483 | 5807 | |
| 5808 | if (ACCESSING_BITS_0_15) |
| 5809 | { |
| 5810 | sh2_slave_4016_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 5811 | } |
| 5484 | 5812 | } |
| 5485 | 5813 | |
| 5814 | static WRITE32_HANDLER( sh2_master_4018_401a_w ) |
| 5815 | { |
| 5816 | if (ACCESSING_BITS_16_31) |
| 5817 | { |
| 5818 | printf("master 4018\n"); |
| 5819 | sh2_master_4018_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 5820 | } |
| 5486 | 5821 | |
| 5822 | if (ACCESSING_BITS_0_15) |
| 5823 | { |
| 5824 | printf("master 401a\n"); |
| 5487 | 5825 | |
| 5826 | sh2_master_401a_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 5827 | } |
| 5828 | } |
| 5488 | 5829 | |
| 5830 | static WRITE32_HANDLER( sh2_slave_4018_401a_w ) |
| 5831 | { |
| 5832 | if (ACCESSING_BITS_16_31) |
| 5833 | { |
| 5834 | printf("slave 4018\n"); |
| 5835 | sh2_slave_4018_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 5836 | } |
| 5489 | 5837 | |
| 5490 | | static READ16_HANDLER( _32x_68k_dram_r ) |
| 5838 | if (ACCESSING_BITS_0_15) |
| 5839 | { |
| 5840 | printf("slave 401a\n"); |
| 5841 | sh2_slave_401a_w(machine,offset*2+1,(data>>0)&0xffff,(mem_mask>>0)&0xffff); |
| 5842 | } |
| 5843 | } |
| 5844 | |
| 5845 | static WRITE32_HANDLER( sh2_master_401c_401e_w ) |
| 5491 | 5846 | { |
| 5492 | | return _32x_access_dram[offset]; |
| 5847 | if (ACCESSING_BITS_16_31) |
| 5848 | { |
| 5849 | sh2_master_401c_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 5850 | } |
| 5851 | |
| 5852 | if (ACCESSING_BITS_0_15) |
| 5853 | { |
| 5854 | printf("401e master write?! %08x %08x\n",data,mem_mask); |
| 5855 | } |
| 5493 | 5856 | } |
| 5494 | 5857 | |
| 5495 | | static WRITE16_HANDLER( _32x_68k_dram_w ) |
| 5858 | static WRITE32_HANDLER( sh2_slave_401c_401e_w ) |
| 5496 | 5859 | { |
| 5497 | | COMBINE_DATA(&_32x_access_dram[offset]); |
| 5860 | if (ACCESSING_BITS_16_31) |
| 5861 | { |
| 5862 | sh2_slave_401c_w(machine,offset*2,(data>>16)&0xffff,(mem_mask>>16)&0xffff); |
| 5863 | } |
| 5864 | |
| 5865 | if (ACCESSING_BITS_0_15) |
| 5866 | { |
| 5867 | printf("401e slave write?! %08x %08x\n",data,mem_mask); |
| 5868 | } |
| 5498 | 5869 | } |
| 5870 | /* |
| 5499 | 5871 | |
| 5500 | | static READ16_HANDLER( _32x_68k_palette_r ) |
| 5872 | ------------------------------------------------------------------------------------------------- |
| 5873 | 4000 (sh2 side) |
| 5874 | ------------------------------------------------------------------------------------------------- |
| 5875 | |
| 5876 | f--- --ec h--- VHCP |
| 5877 | |
| 5878 | f = framebuffer permission (0 md, 1 sh2) |
| 5879 | e = Adapter enabled (0 no, 1 yes) |
| 5880 | c = Cart Inserted (0 yes, 1 no) |
| 5881 | h = H Interrupt allowed within Vblank (0 no, 1 yes) |
| 5882 | |
| 5883 | *** these are independent for each SH2 *** |
| 5884 | V = V Interrupt Mask (0 masked, 1 allowed) |
| 5885 | H = H Interrupt Mask (0 masked, 1 allowed) |
| 5886 | C = Command Interrupt Mask (0 masked, 1 allowed) |
| 5887 | P = PWM Interrupt Mask (0 masked, 1 allowed) |
| 5888 | |
| 5889 | ------------------------------------------------------------------------------------------------- |
| 5890 | 4002 Stand By Change Register |
| 5891 | ------------------------------------------------------------------------------------------------- |
| 5892 | |
| 5893 | Write Only |
| 5894 | Prohibited from Application |
| 5895 | |
| 5896 | ------------------------------------------------------------------------------------------------- |
| 5897 | 4004 H Count Register (H Interrupt) |
| 5898 | ------------------------------------------------------------------------------------------------- |
| 5899 | 0 = every line |
| 5900 | |
| 5901 | ------------------------------------------------------------------------------------------------- |
| 5902 | 4006 DReq Control Register |
| 5903 | ------------------------------------------------------------------------------------------------- |
| 5904 | |
| 5905 | ------------------------------------------------------------------------------------------------- |
| 5906 | 4008 68k To SH2 DReq Source Address Register ( High Bits ) |
| 5907 | ------------------------------------------------------------------------------------------------- |
| 5908 | |
| 5909 | ------------------------------------------------------------------------------------------------- |
| 5910 | 400A 68k To SH2 DReq Source Address Register ( Low Bits ) |
| 5911 | ------------------------------------------------------------------------------------------------- |
| 5912 | |
| 5913 | ------------------------------------------------------------------------------------------------- |
| 5914 | 400C 68k To SH2 DReq Destination Address Register ( High Bits ) |
| 5915 | ------------------------------------------------------------------------------------------------- |
| 5916 | |
| 5917 | ------------------------------------------------------------------------------------------------- |
| 5918 | 400E 68k To SH2 DReq Destination Address Register ( Low Bits ) |
| 5919 | ------------------------------------------------------------------------------------------------- |
| 5920 | |
| 5921 | ------------------------------------------------------------------------------------------------- |
| 5922 | 4010 68k To SH2 DReq Length Register |
| 5923 | ------------------------------------------------------------------------------------------------- |
| 5924 | |
| 5925 | ------------------------------------------------------------------------------------------------- |
| 5926 | 4012 FIFO Register |
| 5927 | ------------------------------------------------------------------------------------------------- |
| 5928 | |
| 5929 | ------------------------------------------------------------------------------------------------- |
| 5930 | 4014 VRES IRQ Clear Register |
| 5931 | ------------------------------------------------------------------------------------------------- |
| 5932 | Clears Interrupt which is caused by pressing RESET button |
| 5933 | |
| 5934 | ------------------------------------------------------------------------------------------------- |
| 5935 | 4016 VINT IRQ Clear Register |
| 5936 | ------------------------------------------------------------------------------------------------- |
| 5937 | Clears Vertical Blank Interrupt |
| 5938 | |
| 5939 | ------------------------------------------------------------------------------------------------- |
| 5940 | 4018 HINT IRQ Clear Register |
| 5941 | ------------------------------------------------------------------------------------------------- |
| 5942 | Clears Horizontal Blank Interrupt |
| 5943 | |
| 5944 | ------------------------------------------------------------------------------------------------- |
| 5945 | 401A CMD IRQ Clear Register |
| 5946 | ------------------------------------------------------------------------------------------------- |
| 5947 | Clears 'Command' Interrupt |
| 5948 | |
| 5949 | ------------------------------------------------------------------------------------------------- |
| 5950 | 401C PWM IRQ Clear Register |
| 5951 | ------------------------------------------------------------------------------------------------- |
| 5952 | Clears 'PWM' (Sound / Timer) Interrupt |
| 5953 | |
| 5954 | ------------------------------------------------------------------------------------------------- |
| 5955 | 401E ?????????????????????? |
| 5956 | ------------------------------------------------------------------------------------------------- |
| 5957 | |
| 5958 | ------------------------------------------------------------------------------------------------- |
| 5959 | 4020 Comms Reg 1 |
| 5960 | ------------------------------------------------------------------------------------------------ |
| 5961 | 4022 Comms Reg 2 |
| 5962 | ------------------------------------------------------------------------------------------------ |
| 5963 | 4024 Comms Reg 3 |
| 5964 | ------------------------------------------------------------------------------------------------ |
| 5965 | 4026 Comms Reg 4 |
| 5966 | ------------------------------------------------------------------------------------------------ |
| 5967 | 4028 Comms Reg 5 |
| 5968 | ------------------------------------------------------------------------------------------------ |
| 5969 | 402A Comms Reg 6 |
| 5970 | ------------------------------------------------------------------------------------------------ |
| 5971 | 402C Comms Reg 7 |
| 5972 | ------------------------------------------------------------------------------------------------ |
| 5973 | 402E Comms Reg 8 |
| 5974 | ------------------------------------------------------------------------------------------------ |
| 5975 | |
| 5976 | ------------------------------------------------------------------------------------------------ |
| 5977 | 4030 PWM Control Register |
| 5978 | ------------------------------------------------------------------------------------------------ |
| 5979 | |
| 5980 | ------------------------------------------------------------------------------------------------ |
| 5981 | 4032 Cycle Register |
| 5982 | ------------------------------------------------------------------------------------------------ |
| 5983 | |
| 5984 | ------------------------------------------------------------------------------------------------ |
| 5985 | 4034 LCH Pulse Width Register |
| 5986 | ------------------------------------------------------------------------------------------------ |
| 5987 | |
| 5988 | ------------------------------------------------------------------------------------------------ |
| 5989 | 4036 RCH Pulse Width Register |
| 5990 | ------------------------------------------------------------------------------------------------ |
| 5991 | |
| 5992 | ------------------------------------------------------------------------------------------------ |
| 5993 | 4038 Mono Pulse Width Register |
| 5994 | ------------------------------------------------------------------------------------------------ |
| 5995 | |
| 5996 | |
| 5997 | ------------------------------------------------------------------------------------------------ |
| 5998 | 4100 Bitmap Mode Register |
| 5999 | ------------------------------------------------------------------------------------------------ |
| 6000 | |
| 6001 | ------------------------------------------------------------------------------------------------ |
| 6002 | 4102 Screen Shift Control Register |
| 6003 | ------------------------------------------------------------------------------------------------ |
| 6004 | |
| 6005 | ------------------------------------------------------------------------------------------------ |
| 6006 | 4104 Auto Fill Length Register |
| 6007 | ------------------------------------------------------------------------------------------------ |
| 6008 | |
| 6009 | ------------------------------------------------------------------------------------------------ |
| 6010 | 4106 Auto Fill Start Address Register |
| 6011 | ------------------------------------------------------------------------------------------------ |
| 6012 | |
| 6013 | ------------------------------------------------------------------------------------------------ |
| 6014 | 4108 Auto Fill Data Register |
| 6015 | ------------------------------------------------------------------------------------------------ |
| 6016 | |
| 6017 | ------------------------------------------------------------------------------------------------ |
| 6018 | 410A Frame Buffer Control Register |
| 6019 | ------------------------------------------------------------------------------------------------ |
| 6020 | |
| 6021 | |
| 6022 | */ |
| 6023 | |
| 6024 | |
| 6025 | /* |
| 6026 | |
| 6027 | 15106 DREQ |
| 6028 | |
| 6029 | ---- ---- F--- -K0R |
| 6030 | |
| 6031 | F = Fifo FULL |
| 6032 | K = 68k CPU Write mode (0 = no, 1 = CPU write) |
| 6033 | 0 = always 0 |
| 6034 | R = RV (0 = no operation, 1 = DMA Start allowed) |
| 6035 | |
| 6036 | */ |
| 6037 | |
| 6038 | static UINT16 a15106_reg; |
| 6039 | |
| 6040 | |
| 6041 | static READ16_HANDLER( _32x_68k_a15106_r) |
| 5501 | 6042 | { |
| 5502 | | return _32x_palette[offset]; |
| 6043 | UINT16 retval; |
| 6044 | |
| 6045 | retval = a15106_reg; |
| 6046 | |
| 6047 | //if (fifo_full) retval |= 0x0080; |
| 6048 | |
| 6049 | return retval; |
| 5503 | 6050 | } |
| 5504 | 6051 | |
| 5505 | | static WRITE16_HANDLER( _32x_68k_palette_w ) |
| 6052 | static WRITE16_HANDLER( _32x_68k_a15106_w ) |
| 5506 | 6053 | { |
| 5507 | | int r,g,b, p; |
| 6054 | if (ACCESSING_BITS_0_7) |
| 6055 | { |
| 6056 | a15106_reg = data & 0x5; |
| 6057 | printf("_32x_68k_a15106_w %04x\n", data); |
| 5508 | 6058 | |
| 5509 | | COMBINE_DATA(&_32x_palette[offset]); |
| 5510 | | data = _32x_palette[offset]; |
| 6059 | if (a15106_reg & 0x4) |
| 6060 | printf(" --- 68k Write Mode enabled\n"); |
| 6061 | else |
| 6062 | printf(" --- 68k Write Mode disabled\n"); |
| 5511 | 6063 | |
| 5512 | | r = ((data >> 0) & 0x1f); |
| 5513 | | g = ((data >> 5) & 0x1f); |
| 5514 | | b = ((data >> 10) & 0x1f); |
| 5515 | | p = ((data >> 15) & 0x01); // priority 'through' bit |
| 6064 | if (a15106_reg & 0x1) |
| 6065 | printf(" --- DMA Start Allowed \n"); |
| 6066 | else |
| 6067 | printf(" --- DMA Start No Operation\n"); |
| 5516 | 6068 | |
| 5517 | | _32x_palette_lookup[offset] = (r << 10) | (g << 5) | (b << 0); |
| 6069 | } |
| 5518 | 6070 | |
| 5519 | | palette_set_color_rgb(Machine,offset+0x40,pal5bit(r),pal5bit(g),pal5bit(b)); |
| 5520 | 6071 | |
| 5521 | 6072 | } |
| 5522 | 6073 | |
| 5523 | | /* |
| 6074 | |
| 6075 | |
| 6076 | |
| 6077 | |
| 6078 | |
| 6079 | |
| 6080 | |
| 6081 | |
| 6082 | |
| 6083 | |
| 6084 | |
| 6085 | |
| 5524 | 6086 | // returns MARS, the system ID of the 32x |
| 5525 | 6087 | static READ16_HANDLER( _32x_68k_MARS_r ) |
| 5526 | 6088 | { |
| r3514 | r3515 | |
| 5535 | 6097 | |
| 5536 | 6098 | return 0x0000; |
| 5537 | 6099 | } |
| 5538 | | */ |
| 5539 | 6100 | |
| 5540 | | DRIVER_INIT( _32x ) |
| 6101 | UINT16 comms_port[8]; |
| 6102 | |
| 6103 | static READ32_HANDLER( sh2_commsport_r ) |
| 5541 | 6104 | { |
| 5542 | | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10); |
| 5543 | | memory_set_bankptr( 10, memory_region(machine, "gamecart") ); |
| 6105 | timer_call_after_resynch(NULL, 0, NULL); |
| 6106 | return (comms_port[offset*2] << 16) | (comms_port[offset*2+1]); |
| 6107 | } |
| 5544 | 6108 | |
| 5545 | | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0880000, 0x08fffff, 0, 0, SMH_BANK11, SMH_BANK11); // 'fixed' 512kb rom bank |
| 5546 | | memory_set_bankptr( 11, memory_region(machine, "gamecart") ); |
| 5547 | 6109 | |
| 5548 | | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0900000, 0x09fffff, 0, 0, SMH_BANK12, SMH_BANK12); // 'bankable' 1024kb rom bank |
| 5549 | | memory_set_bankptr( 12, memory_region(machine, "gamecart") ); |
| 6110 | static READ16_HANDLER( _32x_68k_comms_r ) |
| 6111 | { |
| 6112 | timer_call_after_resynch(NULL, 0, NULL); |
| 6113 | return comms_port[offset]; |
| 6114 | } |
| 5550 | 6115 | |
| 5551 | | // memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x00000ff, 0, 0, SMH_BANK10, SMH_BANK10); |
| 5552 | | // memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000100, 0x03fffff, 0, 0, SMH_NOP, SMH_NOP ); |
| 5553 | | // memory_set_bankptr( 10, memory_region(machine, "32x_68k_bios") ); |
| 6116 | static WRITE16_HANDLER( _32x_68k_comms_w ) |
| 6117 | { |
| 6118 | COMBINE_DATA(&comms_port[offset]); |
| 6119 | timer_call_after_resynch(NULL, 0, NULL); |
| 5554 | 6120 | |
| 6121 | } |
| 6122 | |
| 6123 | |
| 6124 | static WRITE32_HANDLER( sh2_commsport_w ) |
| 6125 | { |
| 6126 | // printf("comms write %d %08x %08x\n",offset, data, mem_mask); |
| 6127 | |
| 6128 | if (ACCESSING_BITS_16_31) |
| 6129 | { |
| 6130 | _32x_68k_comms_w(machine,offset*2, (data >> 16) & 0xffff, (mem_mask >> 16) & 0xffff); |
| 6131 | } |
| 6132 | if (ACCESSING_BITS_0_15) |
| 6133 | { |
| 6134 | _32x_68k_comms_w(machine,offset*2+1, (data) & 0xffff, (mem_mask) & 0xffff); |
| 6135 | } |
| 6136 | } |
| 6137 | |
| 6138 | //static int sh2_master_vint_enable, sh2_slave_vint_enable; |
| 6139 | //static int sh2_master_hint_enable, sh2_slave_hint_enable; |
| 6140 | //static int sh2_master_cmdint_enable, sh2_slave_cmdint_enable; |
| 6141 | //static int sh2_master_pwmint_enable, sh2_slave_pwnint_enable; |
| 6142 | |
| 6143 | |
| 6144 | static WRITE16_HANDLER( _sh2_master_irq_control_w ) |
| 6145 | { |
| 6146 | if (ACCESSING_BITS_8_15) |
| 6147 | { |
| 6148 | //printf("_sh2_master_irq_control_w adapter use stuff write\n"); |
| 6149 | |
| 6150 | _32x_access_auth = (data &0x80) >> 7; |
| 6151 | } |
| 6152 | |
| 6153 | if (ACCESSING_BITS_0_7) |
| 6154 | { |
| 6155 | sh2_master_vint_enable = data & 0x8; |
| 6156 | sh2_master_hint_enable = data & 0x4; |
| 6157 | sh2_master_cmdint_enable = data & 0x2; |
| 6158 | sh2_master_pwmint_enable = data & 0x1; |
| 6159 | } |
| 6160 | } |
| 6161 | |
| 6162 | static WRITE16_HANDLER( _sh2_slave_irq_control_w ) |
| 6163 | { |
| 6164 | if (ACCESSING_BITS_8_15) |
| 6165 | { |
| 6166 | //printf("_sh2_slave_irq_control_w adapter use stuff write\n"); |
| 6167 | _32x_access_auth = (data &0x80) >> 7; |
| 6168 | |
| 6169 | } |
| 6170 | |
| 6171 | if (ACCESSING_BITS_0_7) |
| 6172 | { |
| 6173 | sh2_slave_vint_enable = data & 0x8; |
| 6174 | sh2_slave_hint_enable = data & 0x4; |
| 6175 | sh2_slave_cmdint_enable = data & 0x2; |
| 6176 | sh2_slave_pwnint_enable = data & 0x1; |
| 6177 | } |
| 6178 | } |
| 6179 | |
| 6180 | |
| 6181 | static WRITE32_HANDLER( sh2_4000_master_w ) |
| 6182 | { |
| 6183 | if (ACCESSING_BITS_16_31) // 4000 |
| 6184 | { |
| 6185 | //printf("sh2_4000_master_w %08x %08x\n",data,mem_mask); |
| 6186 | _sh2_master_irq_control_w(machine, offset*2, (data >> 16) & 0xffff, (mem_mask >> 16) & 0xffff); |
| 6187 | |
| 6188 | } |
| 6189 | |
| 6190 | if (ACCESSING_BITS_0_15) // 4002 |
| 6191 | { |
| 6192 | //printf("sh2_4002_master_w %08x %08x\n",data,mem_mask); |
| 6193 | } |
| 6194 | |
| 6195 | } |
| 6196 | |
| 6197 | static WRITE32_HANDLER( sh2_4000_slave_w ) |
| 6198 | { |
| 6199 | if (ACCESSING_BITS_16_31) // 4000 |
| 6200 | { |
| 6201 | //printf("sh2_4000_slave_w %08x %08x\n",data,mem_mask); |
| 6202 | _sh2_slave_irq_control_w(machine, offset*2, (data >> 16) & 0xffff, (mem_mask >> 16) & 0xffff); |
| 6203 | |
| 6204 | } |
| 6205 | |
| 6206 | if (ACCESSING_BITS_0_15) // 4002 |
| 6207 | { |
| 6208 | //printf("sh2_4002_slave_w %08x %08x\n",data,mem_mask); |
| 6209 | } |
| 6210 | } |
| 6211 | |
| 6212 | /* 4000 - 4002 reads */ |
| 6213 | |
| 6214 | static READ16_HANDLER( _32x_4000_master_r ) |
| 6215 | { |
| 6216 | UINT16 retvalue = 0x0200; |
| 6217 | retvalue |= _32x_access_auth << 15; |
| 6218 | return retvalue; |
| 6219 | } |
| 6220 | |
| 6221 | static READ16_HANDLER( _32x_4000_slave_r ) |
| 6222 | { |
| 6223 | UINT16 retvalue = 0x0200; |
| 6224 | retvalue |= _32x_access_auth << 15; |
| 6225 | return retvalue; |
| 6226 | } |
| 6227 | |
| 6228 | static READ16_HANDLER( _32x_4002_r ) |
| 6229 | { |
| 6230 | printf("read 4002\n"); |
| 6231 | return 0x0000; |
| 6232 | } |
| 6233 | |
| 6234 | static READ32_HANDLER( sh2_4000_master_r ) |
| 6235 | { |
| 6236 | UINT32 retvalue = 0x00000000; |
| 6237 | |
| 6238 | if (ACCESSING_BITS_16_31) // 4000 |
| 6239 | { |
| 6240 | UINT16 ret = 0x0000; |
| 6241 | ret = _32x_4000_master_r(machine,offset*2,(mem_mask>>16)&0xffff); |
| 6242 | retvalue |= ret << 16; |
| 6243 | } |
| 6244 | |
| 6245 | if (ACCESSING_BITS_0_15) // 4002 |
| 6246 | { |
| 6247 | UINT16 ret = 0x0000; |
| 6248 | ret = _32x_4002_r(machine,offset*2+1,(mem_mask>>0)&0xffff); |
| 6249 | retvalue |= ret << 0; |
| 6250 | } |
| 6251 | |
| 6252 | return retvalue; |
| 6253 | } |
| 6254 | |
| 6255 | |
| 6256 | static READ32_HANDLER( sh2_4000_slave_r ) |
| 6257 | { |
| 6258 | UINT32 retvalue = 0x00000000; |
| 6259 | |
| 6260 | if (ACCESSING_BITS_16_31) // 4000 |
| 6261 | { |
| 6262 | UINT16 ret = 0x0000; |
| 6263 | ret = _32x_4000_slave_r(machine,offset*2,(mem_mask>>16)&0xffff); |
| 6264 | retvalue |= ret << 16; |
| 6265 | } |
| 6266 | |
| 6267 | if (ACCESSING_BITS_0_15) // 4002 |
| 6268 | { |
| 6269 | UINT16 ret = 0x0000; |
| 6270 | ret = _32x_4002_r(machine,offset*2+1,(mem_mask>>0)&0xffff); |
| 6271 | retvalue |= ret << 0; |
| 6272 | } |
| 6273 | |
| 6274 | return retvalue; |
| 6275 | } |
| 6276 | |
| 6277 | |
| 6278 | |
| 6279 | |
| 6280 | |
| 6281 | |
| 6282 | |
| 6283 | |
| 6284 | |
| 6285 | |
| 6286 | |
| 6287 | |
| 6288 | |
| 6289 | static READ16_HANDLER( _32x_68k_a15184_r ) |
| 6290 | { |
| 6291 | return _32x_autofill_length; |
| 6292 | } |
| 6293 | |
| 6294 | static WRITE16_HANDLER( _32x_68k_a15184_w ) |
| 6295 | { |
| 6296 | if (ACCESSING_BITS_0_7) |
| 6297 | { |
| 6298 | _32x_autofill_length = data & 0xff; |
| 6299 | printf("32x set autofill length to %02x\n",_32x_autofill_length); |
| 6300 | } |
| 6301 | |
| 6302 | if (ACCESSING_BITS_8_15) |
| 6303 | { |
| 6304 | |
| 6305 | } |
| 6306 | } |
| 6307 | |
| 6308 | static READ16_HANDLER( _32x_68k_a15186_r ) |
| 6309 | { |
| 6310 | return _32x_autofill_address; |
| 6311 | } |
| 6312 | |
| 6313 | static WRITE16_HANDLER( _32x_68k_a15186_w ) |
| 6314 | { |
| 6315 | if (ACCESSING_BITS_0_7) |
| 6316 | { |
| 6317 | _32x_autofill_address = (_32x_autofill_address & 0xff00) | (data & 0x00ff); |
| 6318 | } |
| 6319 | |
| 6320 | if (ACCESSING_BITS_8_15) |
| 6321 | { |
| 6322 | _32x_autofill_address = (_32x_autofill_address & 0x00ff) | (data & 0xff00); |
| 6323 | } |
| 6324 | |
| 6325 | printf("32x set autofill address to %04x\n",_32x_autofill_address); |
| 6326 | } |
| 6327 | |
| 6328 | static READ16_HANDLER( _32x_68k_a15188_r ) |
| 6329 | { |
| 6330 | return _32x_autofill_data; |
| 6331 | } |
| 6332 | |
| 6333 | static WRITE16_HANDLER( _32x_68k_a15188_w ) |
| 6334 | { |
| 6335 | if (ACCESSING_BITS_0_7) |
| 6336 | { |
| 6337 | _32x_autofill_data = (_32x_autofill_data & 0xff00) | (data & 0x00ff); |
| 6338 | } |
| 6339 | |
| 6340 | if (ACCESSING_BITS_8_15) |
| 6341 | { |
| 6342 | _32x_autofill_data = (_32x_autofill_data & 0x00ff) | (data & 0xff00); |
| 6343 | } |
| 6344 | |
| 6345 | printf("32x set autofill data to %04x (performing fill)\n",_32x_autofill_data); |
| 6346 | } |
| 6347 | |
| 6348 | |
| 6349 | |
| 6350 | |
| 6351 | |
| 6352 | static READ16_HANDLER( _32x_68k_a15104_r ) |
| 6353 | { |
| 6354 | return _32x_a15104; |
| 6355 | } |
| 6356 | |
| 6357 | static WRITE16_HANDLER( _32x_68k_a15104_w ) |
| 6358 | { |
| 6359 | if (ACCESSING_BITS_0_7) |
| 6360 | { |
| 6361 | _32x_a15104 = (_32x_a15104 & 0xff00) | (data & 0x00ff); |
| 6362 | } |
| 6363 | |
| 6364 | if (ACCESSING_BITS_8_15) |
| 6365 | { |
| 6366 | _32x_a15104 = (_32x_a15104 & 0x00ff) | (data & 0xff00); |
| 6367 | } |
| 6368 | |
| 6369 | memory_set_bankptr( 12, memory_region(machine, "gamecart")+((_32x_a15104&0x3)*0x100000) ); |
| 6370 | |
| 6371 | |
| 6372 | } |
| 6373 | |
| 6374 | |
| 6375 | static UINT16 a15100_reg; |
| 6376 | |
| 6377 | static READ16_HANDLER( _32x_68k_a15100_r ) |
| 6378 | { |
| 6379 | return (_32x_access_auth<<15) | 0x0080; |
| 6380 | } |
| 6381 | |
| 6382 | static READ16_HANDLER( _32x_68k_bitmapmode_r ) |
| 6383 | { |
| 6384 | return 0x8001; |
| 6385 | } |
| 6386 | |
| 6387 | static WRITE16_HANDLER( _32x_68k_bitmapmode_w ) |
| 6388 | { |
| 6389 | printf("_32x_68k_bitmapmode_w (a15180) %04x %04x\n",data,mem_mask); |
| 6390 | } |
| 6391 | |
| 6392 | static WRITE16_HANDLER( _32x_68k_a15100_w ) |
| 6393 | { |
| 6394 | printf("_32x_68k_a15100_w\n"); |
| 6395 | |
| 6396 | if (ACCESSING_BITS_0_7) |
| 6397 | { |
| 6398 | a15100_reg = (a15100_reg & 0xff00) | (data & 0x00ff); |
| 6399 | |
| 6400 | if (data & 0x02) |
| 6401 | { |
| 6402 | cpunum_set_input_line(machine, _32x_master_cpu_number, INPUT_LINE_RESET, CLEAR_LINE); |
| 6403 | cpunum_set_input_line(machine, _32x_slave_cpu_number, INPUT_LINE_RESET, CLEAR_LINE); |
| 6404 | } |
| 6405 | |
| 6406 | if (data & 0x01) |
| 6407 | { |
| 6408 | _32x_adapter_enabled = 1; |
| 6409 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0880000, 0x08fffff, 0, 0, SMH_BANK11, SMH_BANK11); // 'fixed' 512kb rom bank |
| 6410 | memory_set_bankptr( 11, memory_region(machine, "gamecart") ); |
| 6411 | |
| 6412 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0900000, 0x09fffff, 0, 0, SMH_BANK12, SMH_BANK12); // 'bankable' 1024kb rom bank |
| 6413 | memory_set_bankptr( 12, memory_region(machine, "gamecart") ); |
| 6414 | |
| 6415 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10); |
| 6416 | memory_set_bankptr( 10, memory_region(machine, "32x_68k_bios") ); |
| 6417 | |
| 6418 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15184, 0x0a15185, 0, 0, _32x_68k_a15184_r, _32x_68k_a15184_w); // autofill length reg |
| 6419 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15186, 0x0a15187, 0, 0, _32x_68k_a15186_r, _32x_68k_a15186_w); // autofill address reg |
| 6420 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15188, 0x0a15189, 0, 0, _32x_68k_a15188_r, _32x_68k_a15188_w); // autofill data reg / start fill |
| 6421 | |
| 6422 | |
| 6423 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15180, 0x0a15181, 0, 0, _32x_68k_bitmapmode_r, _32x_68k_bitmapmode_w); // mode control regs |
| 6424 | |
| 6425 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a1518a, 0x0a1518b, 0, 0, _32x_68k_fbcontrol_r, _32x_68k_fbcontrol_w); // framebuffer control regs |
| 6426 | |
| 6427 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0840000, 0x085ffff, 0, 0, _32x_68k_dram_r, _32x_68k_dram_w); // access to 'display ram' (framebuffer) |
| 6428 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15200, 0x0a153ff, 0, 0, _32x_68k_palette_r, _32x_68k_palette_w); // access to 'palette' xRRRRRGGGGGBBBBB |
| 6429 | |
| 6430 | |
| 6431 | } |
| 6432 | else |
| 6433 | { |
| 6434 | _32x_adapter_enabled = 0; |
| 6435 | |
| 6436 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10); |
| 6437 | memory_set_bankptr( 10, memory_region(machine, "gamecart") ); |
| 6438 | |
| 6439 | |
| 6440 | } |
| 6441 | } |
| 6442 | |
| 6443 | if (ACCESSING_BITS_8_15) |
| 6444 | { |
| 6445 | a15100_reg = (a15100_reg & 0x00ff) | (data & 0xff00); |
| 6446 | _32x_access_auth = (data & 0x8000)>>15; |
| 6447 | } |
| 6448 | } |
| 6449 | |
| 6450 | static int a15102_reg; |
| 6451 | |
| 6452 | static READ16_HANDLER( _32x_68k_a15102_r ) |
| 6453 | { |
| 6454 | printf("_32x_68k_a15102_r\n"); |
| 6455 | return a15102_reg; |
| 6456 | } |
| 6457 | |
| 6458 | static WRITE16_HANDLER( _32x_68k_a15102_w ) |
| 6459 | { |
| 6460 | if (ACCESSING_BITS_0_7) |
| 6461 | { |
| 6462 | a15102_reg = data; |
| 6463 | |
| 6464 | if (data&0x1) |
| 6465 | { |
| 6466 | printf("68k -> SH2 master int command\n"); |
| 6467 | if (sh2_master_cmdint_enable) cpunum_set_input_line(machine, _32x_master_cpu_number,SH2_CINT_IRQ_LEVEL,ASSERT_LINE); |
| 6468 | } |
| 6469 | |
| 6470 | if (data&0x2) |
| 6471 | { |
| 6472 | printf("68k -> SH2 slave int command\n"); |
| 6473 | cpunum_set_input_line(machine, _32x_slave_cpu_number,SH2_CINT_IRQ_LEVEL,ASSERT_LINE); |
| 6474 | } |
| 6475 | } |
| 6476 | } |
| 6477 | |
| 6478 | |
| 6479 | |
| 6480 | DRIVER_INIT( _32x ) |
| 6481 | { |
| 6482 | |
| 6483 | |
| 5555 | 6484 | _32x_dram0 = auto_malloc(0x20000); |
| 5556 | 6485 | _32x_dram1 = auto_malloc(0x20000); |
| 5557 | 6486 | |
| r3514 | r3515 | |
| 5568 | 6497 | _32x_display_dram = _32x_dram0; |
| 5569 | 6498 | _32x_access_dram = _32x_dram1; |
| 5570 | 6499 | |
| 5571 | | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0840000, 0x085ffff, 0, 0, _32x_68k_dram_r, _32x_68k_dram_w); // access to 'display ram' (framebuffer) |
| 6500 | _32x_adapter_enabled = 0; |
| 5572 | 6501 | |
| 5573 | | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a15200, 0x0a153ff, 0, 0, _32x_68k_palette_r, _32x_68k_palette_w); // access to 'palette' xRRRRRGGGGGBBBBB |
| 6502 | if (_32x_adapter_enabled == 0) |
| 6503 | { |
| 6504 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0000000, 0x03fffff, 0, 0, SMH_BANK10, SMH_BANK10); |
| 6505 | memory_set_bankptr( 10, memory_region(machine, "gamecart") ); |
| 6506 | }; |
| 5574 | 6507 | |
| 6508 | |
| 6509 | a15100_reg = 0x0000; |
| 6510 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15100, 0xa15101, 0, 0, _32x_68k_a15100_r, _32x_68k_a15100_w); // framebuffer control regs |
| 6511 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15102, 0xa15103, 0, 0, _32x_68k_a15102_r, _32x_68k_a15102_w); // send irq to sh2 |
| 6512 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15104, 0xa15105, 0, 0, _32x_68k_a15104_r, _32x_68k_a15104_w); // 68k BANK rom set |
| 6513 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15106, 0xa15107, 0, 0, _32x_68k_a15106_r, _32x_68k_a15106_w); // dreq stuff |
| 6514 | |
| 6515 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xa15120, 0xa1512f, 0, 0, _32x_68k_comms_r, _32x_68k_comms_w); // comms regs |
| 6516 | |
| 6517 | memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a130ec, 0x0a130ef, 0, 0, _32x_68k_MARS_r); // system ID |
| 6518 | |
| 6519 | |
| 6520 | |
| 6521 | /* SH2 stuff */ |
| 6522 | memory_install_readwrite32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x4000, 0x4003, 0, 0, sh2_4000_master_r, sh2_4000_master_w); |
| 6523 | memory_install_readwrite32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x4000, 0x4003, 0, 0, sh2_4000_slave_r, sh2_4000_slave_w ); |
| 6524 | |
| 6525 | /* Install Interrupt Clear Registers */ |
| 6526 | memory_install_readwrite32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x4014, 0x4017, 0, 0, sh2_master_4014_4016_r, sh2_master_4014_4016_w ); |
| 6527 | memory_install_write32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x4014, 0x4017, 0, 0, sh2_slave_4014_4016_w ); |
| 6528 | memory_install_write32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x4018, 0x401b, 0, 0, sh2_master_4018_401a_w ); |
| 6529 | memory_install_write32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x4018, 0x401b, 0, 0, sh2_slave_4018_401a_w ); |
| 6530 | memory_install_write32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x401c, 0x401f, 0, 0, sh2_master_401c_401e_w ); |
| 6531 | memory_install_write32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x401c, 0x401f, 0, 0, sh2_slave_401c_401e_w ); |
| 6532 | |
| 6533 | |
| 6534 | memory_install_readwrite32_handler(machine, 2, ADDRESS_SPACE_PROGRAM, 0x4020, 0x402f, 0, 0, sh2_commsport_r, sh2_commsport_w ); |
| 6535 | memory_install_readwrite32_handler(machine, 3, ADDRESS_SPACE_PROGRAM, 0x4020, 0x402f, 0, 0, sh2_commsport_r, sh2_commsport_w ); |
| 6536 | |
| 6537 | /* Interrupts are masked / disabled at first */ |
| 6538 | sh2_master_vint_enable = sh2_slave_vint_enable = 0; |
| 6539 | sh2_master_hint_enable = sh2_slave_hint_enable = 0; |
| 6540 | sh2_master_cmdint_enable = sh2_slave_cmdint_enable = 0; |
| 6541 | sh2_master_pwmint_enable = sh2_slave_pwnint_enable = 0; |
| 6542 | |
| 6543 | // start in a reset state |
| 6544 | sh2_are_running = 0; |
| 6545 | |
| 5575 | 6546 | _32x_a1518a_reg = 0x00; // inital value |
| 5576 | | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a1518a, 0x0a1518b, 0, 0, _32x_68k_fbcontrol_r, _32x_68k_fbcontrol_w); // framebuffer control regs |
| 6547 | _32x_a15104 = 0x00; |
| 5577 | 6548 | |
| 5578 | | // memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0a130ec, 0x0a151ef, 0, 0, _32x_68k_MARS_r); // system ID |
| 6549 | _32x_autofill_length = 0; |
| 6550 | _32x_autofill_address = 0; |
| 6551 | _32x_autofill_data = 0; |
| 6552 | _32x_screenshift = 0; |
| 5579 | 6553 | |
| 5580 | | |
| 5581 | 6554 | DRIVER_INIT_CALL(megadriv); |
| 5582 | 6555 | } |
| 5583 | 6556 | |
| 5584 | | #if |
| 6557 | #if 1 |
| 5585 | 6558 | |
| 5586 | 6559 | ROM_START( 32x_bios ) |
| 5587 | 6560 | ROM_REGION16_BE( 0x400000, "main", ROMREGION_ERASE00 ) |
| 5588 | 6561 | |
| 5589 | 6562 | ROM_REGION16_BE( 0x400000, "gamecart", 0 ) /* 68000 Code */ |
| 5590 | | ROM_LOAD( "32xquin.rom", 0x000000, 0x005d124, CRC(93d4b0a3) SHA1(128bd0b6e048c749da1a2f4c3abd6a867539a293)) |
| 6563 | // ROM_LOAD( "32xquin.rom", 0x000000, 0x005d124, CRC(93d4b0a3) SHA1(128bd0b6e048c749da1a2f4c3abd6a867539a293)) |
| 5591 | 6564 | // ROM_LOAD( "32x_babe.rom", 0x000000, 0x14f80, CRC(816b0cb4) SHA1(dc16d3170d5809b57192e03864b7136935eada64) ) |
| 5592 | 6565 | // ROM_LOAD( "32xhot.rom", 0x000000, 0x01235c, CRC(da9c93c9) SHA1(a62652eb8ad8c62b36f6b1ffb96922d045c4e3ac)) |
| 5593 | 6566 | // ROM_LOAD( "knux.rom", 0x000000, 0x300000, CRC(d0b0b842) SHA1(0c2fff7bc79ed26507c08ac47464c3af19f7ced7) ) |
| 6567 | // ROM_LOAD( "32x_g_bios.bin", 0x000000, 0x000100, CRC(5c12eae8) SHA1(dbebd76a448447cb6e524ac3cb0fd19fc065d944) ) |
| 6568 | // ROM_LOAD( "32x_rot.bin", 0x000000, 0x0001638, CRC(98c25033) SHA1(8d9ab3084bd29e60b8cdf4b9f1cb755eb4c88d29) ) |
| 6569 | // ROM_LOAD( "32x_3d.bin", 0x000000, 0x6568, CRC(0171743e) SHA1(bbe6fec182baae5e4d47d263fae6b419db5366ae) ) |
| 6570 | // ROM_LOAD( "32x_spin.bin", 0x000000, 0x012c28, CRC(3d1d1191) SHA1(221a74408653e18cef8ce2f9b4d33ed93e4218b7) ) |
| 6571 | // ROM_LOAD( "32x_doom.bin", 0x000000, 0x300000, CRC(208332fd) SHA1(b68e9c7af81853b8f05b8696033dfe4c80327e38) ) |
| 6572 | ROM_LOAD( "32x_koli.bin", 0x000000, 0x300000, CRC(20ca53ef) SHA1(191ae0b525ecf32664086d8d748e0b35f776ddfe) ) // works but stutters.. probably flags |
| 6573 | // ROM_LOAD( "32x_head.bin", 0x000000, 0x300000, CRC(1) SHA1(1) ) // works but stutters.. probably flags |
| 5594 | 6574 | |
| 6575 | ROM_REGION32_BE( 0x400000, "gamecart_sh2", 0 ) /* Copy for the SH2 */ |
| 6576 | ROM_COPY( "gamecart", 0x0, 0x0, 0x400000) |
| 6577 | |
| 5595 | 6578 | ROM_REGION16_BE( 0x400000, "32x_68k_bios", 0 ) /* 68000 Code */ |
| 6579 | // ROM_COPY( "gamecart", 0x0, 0x0, 0x400000) |
| 5596 | 6580 | ROM_LOAD( "32x_g_bios.bin", 0x000000, 0x000100, CRC(5c12eae8) SHA1(dbebd76a448447cb6e524ac3cb0fd19fc065d944) ) |
| 5597 | 6581 | |
| 5598 | 6582 | ROM_REGION( 0x400000, "32x_master_sh2", 0 ) /* SH2 Code */ |
| r3514 | r3515 | |
| 5641 | 6625 | ROM_LOAD( "g_virrea.bin", 0x000000, 0x200000, CRC(5a943df9) SHA1(2c08ea556c79d48e88ff5202944c161ae1b41c63) ) |
| 5642 | 6626 | ROM_END |
| 5643 | 6627 | |
| 5644 | | GAME( 1994, 32x_bios, 0, genesis_32x, megadriv, _32x, ROT0, "Sega", "32X Bios", GAME_NOT_WORKING ) |
| 5645 | | GAME( 1994, segacd, 0, genesis_scd, megadriv, megadriv,ROT0, "Sega", "Sega-CD Model 2 BIOS V2.11 (U)", GAME_NOT_WORKING ) |
| 5646 | | GAME( 1994, 32x_scd, 0, genesis_32x_scd, megadriv, _32x, ROT0, "Sega", "Sega-CD Model 2 BIOS V2.11 (U) (with 32X)", GAME_NOT_WORKING ) |
| 6628 | //GAME( 1994, 32x_bios, 0, genesis_32x, megadriv, _32x, ROT0, "Sega", "32X Bios", GAME_NOT_WORKING ) |
| 6629 | //GAME( 1994, segacd, 0, genesis_scd, megadriv, megadriv,ROT0, "Sega", "Sega-CD Model 2 BIOS V2.11 (U)", GAME_NOT_WORKING ) |
| 6630 | //GAME( 1994, 32x_scd, 0, genesis_32x_scd, megadriv, _32x, ROT0, "Sega", "Sega-CD Model 2 BIOS V2.11 (U) (with 32X)", GAME_NOT_WORKING ) |
| 5647 | 6631 | GAME( 1994, g_virr, 0, megdsvp, megadriv, megadriv, ROT0, "Sega", "Virtua Racing (U) [!]", 0 ) |
| 5648 | 6632 | GAME( 1994, g_virrj , g_virr, megdsvp, megadriv, megadrij, ROT0, "Sega", "Virtua Racing (J) [!]", 0 ) |
| 5649 | 6633 | GAME( 1994, g_virre , g_virr, megdsvppal, megadriv, megadrie, ROT0, "Sega", "Virtua Racing (E) [!]", 0 ) |
src/mame/drivers/astrof.c
| r3514 | r3515 | |
| 42 | 42 | Known issues/to-do's: |
| 43 | 43 | * Is Astro Fighter supposed to have a blue background??? |
| 44 | 44 | * Analog sound in all games |
| 45 | | * Verify DIPs for clones |
| 46 | | * Figure out unknown DIPs for Space Fighter Mark II (set 2) |
| 47 | 45 | |
| 48 | 46 | ****************************************************************************/ |
| 49 | 47 | |
| r3514 | r3515 | |
| 567 | 565 | |
| 568 | 566 | PORT_START("P1") |
| 569 | 567 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY |
| 570 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY |
| 568 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY |
| 571 | 569 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 572 | 570 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 573 | 571 | |
| 574 | 572 | PORT_START("P2") |
| 575 | 573 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL |
| 576 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL |
| 574 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL |
| 577 | 575 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL |
| 578 | 576 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 579 | 577 | |
| 580 | 578 | PORT_START("DSW") |
| 581 | | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2") |
| 579 | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2") |
| 582 | 580 | PORT_DIPSETTING( 0x00, "3" ) |
| 583 | 581 | PORT_DIPSETTING( 0x01, "4" ) |
| 584 | 582 | PORT_DIPSETTING( 0x02, "5" ) |
| 585 | 583 | PORT_DIPSETTING( 0x03, "6" ) |
| 586 | | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 584 | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 587 | 585 | PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) ) |
| 588 | | /*PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) )*/ |
| 586 | // PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) ) /* duplicate settings */ |
| 589 | 587 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) |
| 590 | 588 | PORT_DIPSETTING( 0x04, DEF_STR( 1C_2C ) ) |
| 591 | | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") |
| 592 | | PORT_DIPSETTING( 0x00, "3000" ) |
| 593 | | PORT_DIPSETTING( 0x10, "5000" ) |
| 594 | | PORT_DIPSETTING( 0x20, "7000" ) |
| 589 | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") /* table at 0xf6b2 */ |
| 590 | PORT_DIPSETTING( 0x00, "5000" ) |
| 591 | PORT_DIPSETTING( 0x10, "7000" ) |
| 592 | PORT_DIPSETTING( 0x20, "10000" ) |
| 595 | 593 | PORT_DIPSETTING( 0x30, DEF_STR( None ) ) |
| 596 | | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7") |
| 594 | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7") |
| 597 | 595 | PORT_DIPSETTING( 0x00, DEF_STR( Easy ) ) |
| 598 | 596 | PORT_DIPSETTING( 0x40, DEF_STR( Hard ) ) |
| 599 | 597 | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK ) |
| 600 | 598 | |
| 601 | 599 | PORT_START("CAB") |
| 602 | | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 600 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 603 | 601 | PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) |
| 604 | 602 | PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) |
| 605 | 603 | PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| r3514 | r3515 | |
| 610 | 608 | PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 611 | 609 | INPUT_PORTS_END |
| 612 | 610 | |
| 613 | | |
| 611 | /* same as 'astrof', but inputs are ACTIVE_HIGH instead of ACTIVE_LOW */ |
| 614 | 612 | static INPUT_PORTS_START( abattle ) |
| 615 | 613 | PORT_START("IN") |
| 616 | 614 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 ) |
| r3514 | r3515 | |
| 620 | 618 | |
| 621 | 619 | PORT_START("P1") |
| 622 | 620 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY |
| 623 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY |
| 621 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY |
| 624 | 622 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 ) |
| 625 | 623 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 626 | 624 | |
| 627 | 625 | PORT_START("P2") |
| 628 | 626 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL |
| 629 | | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL |
| 627 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL |
| 630 | 628 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL |
| 631 | 629 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 632 | 630 | |
| 633 | 631 | PORT_START("DSW") |
| 634 | | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2") |
| 632 | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2") |
| 635 | 633 | PORT_DIPSETTING( 0x00, "3" ) |
| 636 | 634 | PORT_DIPSETTING( 0x01, "4" ) |
| 637 | 635 | PORT_DIPSETTING( 0x02, "5" ) |
| 638 | 636 | PORT_DIPSETTING( 0x03, "6" ) |
| 639 | | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 637 | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 640 | 638 | PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) ) |
| 641 | | /*PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) )*/ |
| 639 | // PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) ) /* duplicate settings */ |
| 642 | 640 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) |
| 643 | 641 | PORT_DIPSETTING( 0x04, DEF_STR( 1C_2C ) ) |
| 644 | | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") |
| 642 | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") /* table at 0xf87a */ |
| 645 | 643 | PORT_DIPSETTING( 0x00, "5000" ) |
| 646 | 644 | PORT_DIPSETTING( 0x10, "7000" ) |
| 647 | 645 | PORT_DIPSETTING( 0x20, "10000" ) |
| 648 | 646 | PORT_DIPSETTING( 0x30, DEF_STR( None ) ) |
| 649 | | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7") |
| 647 | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7") |
| 650 | 648 | PORT_DIPSETTING( 0x00, DEF_STR( Easy ) ) |
| 651 | 649 | PORT_DIPSETTING( 0x40, DEF_STR( Hard ) ) |
| 652 | 650 | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK ) |
| 653 | 651 | |
| 654 | 652 | PORT_START("CAB") |
| 655 | | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 653 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 656 | 654 | PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) |
| 657 | 655 | PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) |
| 658 | 656 | PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| r3514 | r3515 | |
| 673 | 671 | |
| 674 | 672 | PORT_START("P1") |
| 675 | 673 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY |
| 676 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY |
| 674 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY |
| 677 | 675 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 678 | 676 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 679 | 677 | |
| 680 | 678 | PORT_START("P2") |
| 681 | 679 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL |
| 682 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL |
| 680 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL |
| 683 | 681 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL |
| 684 | 682 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 685 | 683 | |
| 686 | 684 | PORT_START("DSW") |
| 687 | | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW:1") /* most likely not used */ |
| 688 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 689 | | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| 690 | | PORT_DIPNAME( 0x02, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:2") |
| 685 | PORT_DIPUNUSED_DIPLOC( 0x01, 0x00, "SW:1" ) |
| 686 | PORT_DIPNAME( 0x02, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:2") |
| 691 | 687 | PORT_DIPSETTING( 0x00, "3" ) |
| 692 | 688 | PORT_DIPSETTING( 0x02, "5" ) |
| 693 | | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 689 | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 694 | 690 | PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) ) |
| 695 | | /*PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) )*/ |
| 691 | // PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) ) /* duplicate settings */ |
| 696 | 692 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) |
| 697 | 693 | PORT_DIPSETTING( 0x04, DEF_STR( 1C_2C ) ) |
| 698 | | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") |
| 694 | PORT_DIPNAME( 0x30, 0x00, "Free Credit" ) PORT_DIPLOCATION("SW:5,6") /* table at 0xfa58 */ |
| 699 | 695 | PORT_DIPSETTING( 0x00, "1500" ) |
| 700 | 696 | PORT_DIPSETTING( 0x10, "2000" ) |
| 701 | 697 | PORT_DIPSETTING( 0x20, "2500" ) |
| 702 | 698 | PORT_DIPSETTING( 0x30, "3000" ) |
| 703 | | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW:7") /* most likely not used */ |
| 704 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 705 | | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 699 | PORT_DIPUNUSED_DIPLOC( 0x40, 0x00, "SW:7" ) |
| 706 | 700 | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK ) |
| 707 | 701 | |
| 708 | 702 | PORT_START("CAB") |
| 709 | | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 703 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 710 | 704 | PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) |
| 711 | 705 | PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) |
| 712 | 706 | PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| r3514 | r3515 | |
| 717 | 711 | PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 718 | 712 | INPUT_PORTS_END |
| 719 | 713 | |
| 720 | | |
| 721 | 714 | static INPUT_PORTS_START( spfgmk22 ) |
| 722 | 715 | PORT_START("IN") |
| 723 | 716 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) |
| r3514 | r3515 | |
| 727 | 720 | |
| 728 | 721 | PORT_START("P1") |
| 729 | 722 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY |
| 730 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY |
| 723 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY |
| 731 | 724 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 732 | 725 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 733 | 726 | |
| r3514 | r3515 | |
| 738 | 731 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 739 | 732 | |
| 740 | 733 | PORT_START("DSW") |
| 741 | | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW:1") /* used */ |
| 742 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 743 | | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| 744 | | PORT_DIPNAME( 0x02, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:2") |
| 734 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:1") |
| 735 | PORT_DIPSETTING( 0x00, DEF_STR( Easy ) ) |
| 736 | PORT_DIPSETTING( 0x01, DEF_STR( Hard ) ) |
| 737 | PORT_DIPNAME( 0x02, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:2") |
| 745 | 738 | PORT_DIPSETTING( 0x00, "3" ) |
| 746 | 739 | PORT_DIPSETTING( 0x02, "5" ) |
| 747 | | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 740 | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 748 | 741 | PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) ) |
| 749 | | /*PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) )*/ |
| 742 | // PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) ) /* duplicate settings */ |
| 750 | 743 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) |
| 751 | 744 | PORT_DIPSETTING( 0x04, DEF_STR( 1C_2C ) ) |
| 752 | | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") |
| 745 | PORT_DIPNAME( 0x30, 0x00, "Free Credit" ) PORT_DIPLOCATION("SW:5,6") /* table at 0xf9f8 */ |
| 753 | 746 | PORT_DIPSETTING( 0x00, "2000" ) |
| 754 | 747 | PORT_DIPSETTING( 0x10, "3000" ) |
| 755 | 748 | PORT_DIPSETTING( 0x20, "4000" ) |
| 756 | 749 | PORT_DIPSETTING( 0x30, "5000" ) |
| 757 | | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) PORT_DIPLOCATION("SW:7") /* used */ |
| 758 | | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 759 | | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 750 | PORT_DIPNAME( 0x40, 0x00, "Kill Saucer after Invaders" ) PORT_DIPLOCATION("SW:7") |
| 751 | PORT_DIPSETTING( 0x00, DEF_STR( No ) ) |
| 752 | PORT_DIPSETTING( 0x40, DEF_STR( Yes ) ) /* if saucer lands, game is over */ |
| 760 | 753 | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK ) |
| 761 | 754 | |
| 762 | 755 | PORT_START("CAB") |
| 763 | | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 756 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 764 | 757 | PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) |
| 765 | 758 | PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) |
| 766 | 759 | PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| r3514 | r3515 | |
| 781 | 774 | |
| 782 | 775 | PORT_START("P1") |
| 783 | 776 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY |
| 784 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 785 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 786 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY |
| 777 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 778 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 779 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY |
| 787 | 780 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 788 | 781 | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 789 | 782 | |
| 790 | 783 | PORT_START("P2") |
| 791 | 784 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY PORT_COCKTAIL |
| 792 | | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL |
| 793 | | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL |
| 794 | | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL |
| 785 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL |
| 786 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL |
| 787 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL |
| 795 | 788 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL |
| 796 | 789 | PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 797 | 790 | |
| 798 | 791 | PORT_START("DSW") |
| 799 | | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2") |
| 792 | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW:1,2") |
| 800 | 793 | PORT_DIPSETTING( 0x00, "3" ) |
| 801 | 794 | PORT_DIPSETTING( 0x01, "4" ) |
| 802 | 795 | PORT_DIPSETTING( 0x02, "5" ) |
| 803 | 796 | PORT_DIPSETTING( 0x03, "6" ) |
| 804 | | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 797 | PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW:3,4") |
| 805 | 798 | PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) ) |
| 806 | | /*PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) )*/ |
| 799 | // PORT_DIPSETTING( 0x0c, DEF_STR( 2C_1C ) ) /* duplicate settings */ |
| 807 | 800 | PORT_DIPSETTING( 0x00, DEF_STR( 1C_1C ) ) |
| 808 | 801 | PORT_DIPSETTING( 0x04, DEF_STR( 1C_2C ) ) |
| 809 | | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") |
| 802 | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") /* table at 0xf428 */ |
| 810 | 803 | PORT_DIPSETTING( 0x00, "5000" ) |
| 811 | 804 | PORT_DIPSETTING( 0x10, "7000" ) |
| 812 | 805 | PORT_DIPSETTING( 0x20, "10000" ) |
| 813 | 806 | PORT_DIPSETTING( 0x30, DEF_STR( None ) ) |
| 814 | | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7") |
| 807 | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW:7") |
| 815 | 808 | PORT_DIPSETTING( 0x00, DEF_STR( Easy ) ) |
| 816 | 809 | PORT_DIPSETTING( 0x40, DEF_STR( Hard ) ) |
| 817 | 810 | PORT_BIT ( 0x80, IP_ACTIVE_LOW, IPT_VBLANK ) |
| 818 | 811 | |
| 819 | 812 | PORT_START("CAB") |
| 820 | | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 813 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW:8") |
| 821 | 814 | PORT_DIPSETTING( 0x00, DEF_STR( Upright ) ) |
| 822 | 815 | PORT_DIPSETTING( 0x01, DEF_STR( Cocktail ) ) |
| 823 | 816 | PORT_BIT( 0xfe, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| r3514 | r3515 | |
| 828 | 821 | PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 829 | 822 | INPUT_PORTS_END |
| 830 | 823 | |
| 824 | static INPUT_PORTS_START( tomahaw1 ) |
| 825 | PORT_INCLUDE( tomahawk ) |
| 831 | 826 | |
| 827 | PORT_MODIFY("DSW") |
| 828 | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW:5,6") /* table at 0xf3c8 */ |
| 829 | PORT_DIPSETTING( 0x00, "3000" ) |
| 830 | PORT_DIPSETTING( 0x10, "5000" ) |
| 831 | PORT_DIPSETTING( 0x20, "7000" ) |
| 832 | PORT_DIPSETTING( 0x30, DEF_STR( None ) ) |
| 833 | PORT_DIPUNUSED_DIPLOC( 0x40, 0x00, "SW:7" ) |
| 834 | INPUT_PORTS_END |
| 832 | 835 | |
| 836 | |
| 837 | |
| 833 | 838 | /************************************* |
| 834 | 839 | * |
| 835 | 840 | * Machine drivers |
| r3514 | r3515 | |
| 1237 | 1242 | GAME( 1979, spfghmk2, 0, spfghmk2, spfghmk2, 0, ROT90, "Data East", "Space Fighter Mark II (set 1)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 1238 | 1243 | GAME( 1979, spfgmk22, spfghmk2, spfghmk2, spfgmk22, 0, ROT90, "Data East", "Space Fighter Mark II (set 2)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 1239 | 1244 | GAME( 1980, tomahawk, 0, tomahawk, tomahawk, 0, ROT90, "Data East", "Tomahawk 777 (rev 5)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 1240 | | GAME( 1980, tomahaw1, tomahawk, tomahawk, tomahawk, 0, ROT90, "Data East", "Tomahawk 777 (rev 1)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 1245 | GAME( 1980, tomahaw1, tomahawk, tomahawk, tomahaw1, 0, ROT90, "Data East", "Tomahawk 777 (rev 1)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
src/mame/drivers/toaplan2.c
| r3514 | r3515 | |
| 15 | 15 | Name Board No Maker Game name |
| 16 | 16 | ---------------------------------------------------------------------------- |
| 17 | 17 | tekipaki TP-020 Toaplan Teki Paki |
| 18 | | ghox TP-021 Toaplan Ghox |
| 18 | ghox TP-021 Toaplan Ghox (Spinner with single up/down axis control) |
| 19 | ghoxj TP-021 Toaplan Ghox (8-Way Joystick controls) |
| 19 | 20 | dogyuun TP-022 Toaplan Dogyuun |
| 20 | 21 | kbash TP-023 Toaplan Knuckle Bash |
| 21 | 22 | kbash2 bootleg Toaplan Knuckle Bash 2 |
| r3514 | r3515 | |
| 251 | 252 | #include "sound/3812intf.h" |
| 252 | 253 | #include "sound/okim6295.h" |
| 253 | 254 | #include "sound/ymz280b.h" |
| 255 | #include "includes/toaplan2.h" |
| 254 | 256 | |
| 255 | 257 | |
| 256 | 258 | /**************** Machine stuff ******************/ |
| r3514 | r3515 | |
| 269 | 271 | static UINT16 *V25_shared_ram; /* Really 8bit RAM connected to Z180 */ |
| 270 | 272 | static UINT16 *fixeight_sec_cpu_mem; |
| 271 | 273 | |
| 272 | | /************ Video RAM related values ************/ |
| 273 | | extern UINT16 *toaplan2_txvideoram16; |
| 274 | | extern UINT16 *toaplan2_txvideoram16_offs; |
| 275 | | extern UINT16 *toaplan2_txscrollram16; |
| 276 | | extern UINT16 *toaplan2_tx_gfxram16; |
| 277 | | size_t toaplan2_tx_vram_size; |
| 278 | | size_t toaplan2_tx_offs_vram_size; |
| 279 | | size_t toaplan2_tx_scroll_vram_size; |
| 280 | | size_t batrider_paletteram16_size; |
| 281 | | |
| 282 | 274 | /********** Status related values **********/ |
| 283 | 275 | int toaplan2_sub_cpu = 0; |
| 284 | | static int mcu_data = 0; |
| 285 | | static int video_status; |
| 276 | static UINT16 mcu_data = 0; |
| 277 | static UINT16 video_status; |
| 286 | 278 | static INT8 old_p1_paddle_h; /* For Ghox */ |
| 287 | 279 | static INT8 old_p2_paddle_h; |
| 288 | | static int current_bank; /* Z80 bank used in Battle Garegga and Batrider */ |
| 280 | static INT8 current_bank; /* Z80 bank used in Battle Garegga and Batrider */ |
| 289 | 281 | static int raizing_sndirq_line; /* IRQ4 for batrider, IRQ2 for bbakraid */ |
| 290 | | static int raizing_Z80_busreq; |
| 282 | static UINT16 raizing_Z80_busreq; |
| 291 | 283 | static int bbakraid_unlimited_ver; |
| 292 | 284 | |
| 293 | | /**************** Video stuff ******************/ |
| 294 | | WRITE16_HANDLER( toaplan2_0_voffs_w ); |
| 295 | | WRITE16_HANDLER( toaplan2_1_voffs_w ); |
| 296 | | |
| 297 | | READ16_HANDLER ( toaplan2_0_videoram16_r ); |
| 298 | | READ16_HANDLER ( toaplan2_1_videoram16_r ); |
| 299 | | WRITE16_HANDLER( toaplan2_0_videoram16_w ); |
| 300 | | WRITE16_HANDLER( toaplan2_1_videoram16_w ); |
| 301 | | |
| 302 | | READ16_HANDLER ( toaplan2_txvideoram16_r ); |
| 303 | | WRITE16_HANDLER( toaplan2_txvideoram16_w ); |
| 304 | | READ16_HANDLER ( toaplan2_txvideoram16_offs_r ); |
| 305 | | WRITE16_HANDLER( toaplan2_txvideoram16_offs_w ); |
| 306 | | READ16_HANDLER ( toaplan2_txscrollram16_r ); |
| 307 | | WRITE16_HANDLER( toaplan2_txscrollram16_w ); |
| 308 | | READ16_HANDLER ( toaplan2_tx_gfxram16_r ); |
| 309 | | WRITE16_HANDLER( toaplan2_tx_gfxram16_w ); |
| 310 | | READ16_HANDLER ( raizing_tx_gfxram16_r ); |
| 311 | | WRITE16_HANDLER( raizing_tx_gfxram16_w ); |
| 312 | | |
| 313 | | WRITE16_HANDLER( toaplan2_0_scroll_reg_select_w ); |
| 314 | | WRITE16_HANDLER( toaplan2_1_scroll_reg_select_w ); |
| 315 | | WRITE16_HANDLER( toaplan2_0_scroll_reg_data_w ); |
| 316 | | WRITE16_HANDLER( toaplan2_1_scroll_reg_data_w ); |
| 317 | | |
| 318 | | WRITE16_HANDLER( batrider_objectbank_w ); |
| 319 | | WRITE16_HANDLER( batrider_textdata_decode ); |
| 320 | | |
| 321 | | VIDEO_EOF( toaplan2_0 ); |
| 322 | | VIDEO_EOF( toaplan2_1 ); |
| 323 | | VIDEO_START( toaplan2_0 ); |
| 324 | | VIDEO_START( toaplan2_1 ); |
| 325 | | VIDEO_START( truxton2_0 ); |
| 326 | | VIDEO_START( bgaregga_0 ); |
| 327 | | VIDEO_START( batrider_0 ); |
| 328 | | VIDEO_UPDATE( toaplan2_0 ); |
| 329 | | VIDEO_UPDATE( truxton2_0 ); |
| 330 | | VIDEO_UPDATE( dogyuun_1 ); |
| 331 | | VIDEO_UPDATE( batsugun_1 ); |
| 332 | | VIDEO_UPDATE( batrider_0 ); |
| 333 | | VIDEO_UPDATE( mahoudai_0 ); |
| 334 | | |
| 335 | | |
| 336 | | /********* Video wrappers for PIPIBIBI *********/ |
| 337 | | READ16_HANDLER ( pipibibi_videoram16_r ); |
| 338 | | WRITE16_HANDLER( pipibibi_videoram16_w ); |
| 339 | | READ16_HANDLER ( pipibibi_spriteram16_r ); |
| 340 | | WRITE16_HANDLER( pipibibi_spriteram16_w ); |
| 341 | | WRITE16_HANDLER( pipibibi_scroll_w ); |
| 342 | | |
| 343 | | |
| 344 | | /***************** Sound stuff *****************/ |
| 345 | | void dogyuun_okisnd_w(running_machine *machine, int data); |
| 346 | | void kbash_okisnd_w(running_machine *machine, int data); |
| 347 | | void fixeight_okisnd_w(running_machine *machine, int data); |
| 348 | | void batsugun_okisnd_w(running_machine *machine, int data); |
| 349 | | |
| 350 | 285 | static MACHINE_RESET(batsugun); |
| 351 | 286 | #if USE_V25 |
| 352 | 287 | static READ16_HANDLER( batsugun_share_r ); |
| r3514 | r3515 | |
| 401 | 336 | UINT8 *Z80 = (UINT8 *)memory_region(machine, "audio"); |
| 402 | 337 | |
| 403 | 338 | // Set Z80 bank switch - default bank is 2 |
| 404 | | current_bank = 2; |
| 405 | | memory_set_bankptr(1, &Z80[0x10000]); |
| 339 | current_bank = 4; |
| 340 | memory_configure_bank(1, 0, 10, Z80, 0x4000); |
| 341 | memory_set_bank(1, 4); |
| 406 | 342 | |
| 407 | 343 | if (memory_region(machine, "oki1") != NULL) |
| 408 | 344 | NMK112_init(0, "oki1", "oki2"); |
| r3514 | r3515 | |
| 411 | 347 | MACHINE_RESET_CALL(toaplan2); |
| 412 | 348 | } |
| 413 | 349 | |
| 350 | static void register_state_save(void) |
| 351 | { |
| 352 | state_save_register_global(mcu_data); |
| 353 | state_save_register_global(video_status); |
| 354 | state_save_register_global(old_p1_paddle_h); |
| 355 | state_save_register_global(old_p2_paddle_h); |
| 356 | state_save_register_global(current_bank); |
| 357 | state_save_register_global(raizing_Z80_busreq); |
| 358 | } |
| 359 | |
| 414 | 360 | static DRIVER_INIT( T2_Z80 ) /* init_t2_Z80(); */ |
| 415 | 361 | { |
| 416 | 362 | toaplan2_sub_cpu = CPU_2_Z80; |
| 363 | register_state_save(); |
| 417 | 364 | } |
| 418 | 365 | |
| 419 | 366 | static DRIVER_INIT( T2_Z180 ) |
| 420 | 367 | { |
| 421 | 368 | toaplan2_sub_cpu = CPU_2_HD647180; |
| 369 | register_state_save(); |
| 422 | 370 | } |
| 423 | 371 | |
| 424 | 372 | static DRIVER_INIT( T2_V25 ) |
| 425 | 373 | { |
| 426 | 374 | toaplan2_sub_cpu = CPU_2_V25; |
| 375 | register_state_save(); |
| 427 | 376 | } |
| 428 | 377 | |
| 429 | 378 | static DRIVER_INIT( T2_noZ80 ) |
| 430 | 379 | { |
| 431 | 380 | toaplan2_sub_cpu = CPU_2_NONE; |
| 381 | register_state_save(); |
| 432 | 382 | } |
| 433 | 383 | |
| 434 | 384 | static DRIVER_INIT( fixeight ) |
| r3514 | r3515 | |
| 441 | 391 | #endif |
| 442 | 392 | |
| 443 | 393 | toaplan2_sub_cpu = CPU_2_V25; |
| 394 | register_state_save(); |
| 444 | 395 | } |
| 445 | 396 | |
| 446 | 397 | static DRIVER_INIT( fixeighb ) |
| r3514 | r3515 | |
| 449 | 400 | memory_set_bankptr(1, &bgdata[0x40000]); /* $80000 - $fffff */ |
| 450 | 401 | |
| 451 | 402 | toaplan2_sub_cpu = CPU_2_NONE; |
| 403 | register_state_save(); |
| 452 | 404 | } |
| 453 | 405 | |
| 454 | 406 | static DRIVER_INIT( pipibibi ) |
| r3514 | r3515 | |
| 530 | 482 | } |
| 531 | 483 | |
| 532 | 484 | toaplan2_sub_cpu = CPU_2_Z80; |
| 485 | register_state_save(); |
| 533 | 486 | } |
| 534 | 487 | |
| 535 | 488 | static DRIVER_INIT( batrider ) |
| 536 | 489 | { |
| 537 | 490 | raizing_sndirq_line = 4; |
| 538 | 491 | toaplan2_sub_cpu = CPU_2_Z80; |
| 492 | register_state_save(); |
| 539 | 493 | } |
| 540 | 494 | |
| 541 | 495 | static DRIVER_INIT( bbakraid ) |
| r3514 | r3515 | |
| 543 | 497 | bbakraid_unlimited_ver = 0; |
| 544 | 498 | raizing_sndirq_line = 2; |
| 545 | 499 | toaplan2_sub_cpu = CPU_2_Z80; |
| 500 | register_state_save(); |
| 546 | 501 | } |
| 547 | 502 | |
| 548 | 503 | static DRIVER_INIT( bbakradu ) |
| r3514 | r3515 | |
| 550 | 505 | bbakraid_unlimited_ver = 1; |
| 551 | 506 | raizing_sndirq_line = 2; |
| 552 | 507 | toaplan2_sub_cpu = CPU_2_Z80; |
| 508 | register_state_save(); |
| 553 | 509 | } |
| 554 | 510 | |
| 555 | 511 | |
| r3514 | r3515 | |
| 1076 | 1032 | |
| 1077 | 1033 | static WRITE8_HANDLER( bgaregga_bankswitch_w ) |
| 1078 | 1034 | { |
| 1079 | | UINT8 *RAM = (UINT8 *)memory_region(machine, "audio"); |
| 1080 | | int bankaddress; |
| 1081 | | int bank; |
| 1035 | int bank = (data & 0x0f) - 10 + 4; |
| 1082 | 1036 | |
| 1083 | | bank = (data & 0x0f) - 10; |
| 1084 | | |
| 1085 | 1037 | if (bank != current_bank) |
| 1086 | 1038 | { |
| 1087 | 1039 | current_bank = bank; |
| 1088 | | bankaddress = 0x10000 + 0x4000 * current_bank; |
| 1089 | | memory_set_bankptr(1, &RAM[bankaddress]); |
| 1040 | memory_set_bank(1, bank); |
| 1090 | 1041 | } |
| 1091 | 1042 | } |
| 1092 | 1043 | |
| r3514 | r3515 | |
| 1123 | 1074 | |
| 1124 | 1075 | static WRITE8_HANDLER( batrider_bankswitch_w ) |
| 1125 | 1076 | { |
| 1126 | | UINT8 *RAM = (UINT8 *)memory_region(machine, "audio"); |
| 1127 | | int bankaddress; |
| 1128 | | int bank; |
| 1077 | int bank = data & 0x0f; |
| 1078 | bank = (bank > 1) ? bank + 2 : bank; |
| 1129 | 1079 | |
| 1130 | | bank = data & 0x0f; |
| 1131 | | |
| 1132 | 1080 | if (bank != current_bank) |
| 1133 | 1081 | { |
| 1134 | 1082 | current_bank = bank; |
| 1135 | | logerror("Z80 cpu set bank #%d\n", bank); |
| 1136 | | if (bank > 1) |
| 1137 | | bankaddress = 0x10000 + 0x4000 * (current_bank - 2); |
| 1138 | | else |
| 1139 | | bankaddress = 0x4000 * current_bank; |
| 1140 | | memory_set_bankptr(1, &RAM[bankaddress]); |
| 1083 | memory_set_bank(1, bank); |
| 1141 | 1084 | } |
| 1142 | 1085 | } |
| 1143 | 1086 | |
| r3514 | r3515 | |
| 4200 | 4143 | ROM_END |
| 4201 | 4144 | |
| 4202 | 4145 | |
| 4203 | | ROM_START( ghox ) |
| 4146 | ROM_START( ghox ) /* Spinner with single axis (up/down) controls */ |
| 4204 | 4147 | ROM_REGION( 0x040000, "main", 0 ) /* Main 68K code */ |
| 4205 | 4148 | ROM_LOAD16_BYTE( "tp021-01.u10", 0x000000, 0x020000, CRC(9e56ac67) SHA1(daf241d9e55a6e60fc004ed61f787641595b1e62) ) |
| 4206 | 4149 | ROM_LOAD16_BYTE( "tp021-02.u11", 0x000001, 0x020000, CRC(15cac60f) SHA1(6efa3a50a5dfe6ef4072738d6a7d0d95dca8a675) ) |
| r3514 | r3515 | |
| 4217 | 4160 | ROM_END |
| 4218 | 4161 | |
| 4219 | 4162 | |
| 4220 | | ROM_START( ghoxa ) |
| 4163 | ROM_START( ghoxj ) /* 8-way joystick for controls */ |
| 4221 | 4164 | ROM_REGION( 0x040000, "main", 0 ) /* Main 68K code */ |
| 4222 | 4165 | ROM_LOAD16_BYTE( "tp021-01a.u10", 0x000000, 0x020000, CRC(c11b13c8) SHA1(da7defc1d3b6ddded910ba56c31fbbdb5ed57b09) ) |
| 4223 | 4166 | ROM_LOAD16_BYTE( "tp021-02a.u11", 0x000001, 0x020000, CRC(8d426767) SHA1(1ed4a8bcbf4352257e7d58cb5c2c91eb48c2f047) ) |
| r3514 | r3515 | |
| 5048 | 4991 | /* Whoopee init to be changed to T2_Z180 when (if) HD647180 is dumped */ |
| 5049 | 4992 | |
| 5050 | 4993 | /* ( YEAR NAME PARENT MACHINE INPUT INIT MONITOR COMPANY FULLNAME FLAGS ) */ |
| 5051 | | GAME( 1991, tekipaki, 0, tekipaki, tekipaki, T2_Z180, ROT0, "Toaplan", "Teki Paki", GAME_NO_SOUND ) |
| 5052 | | GAME( 1991, ghox, 0, ghox, ghox, T2_Z180, ROT270, "Toaplan", "Ghox (set 1)", GAME_NO_SOUND ) |
| 5053 | | GAME( 1991, ghoxa, ghox, ghox, ghox, T2_Z180, ROT270, "Toaplan", "Ghox (set 2)", GAME_NO_SOUND ) |
| 5054 | | GAME( 1992, dogyuun, 0, dogyuun, dogyuun, T2_V25, ROT270, "Toaplan", "Dogyuun", GAME_NO_SOUND ) |
| 5055 | | GAME( 1993, kbash, 0, kbash, kbash, T2_V25, ROT0, "Toaplan", "Knuckle Bash", GAME_IMPERFECT_SOUND ) |
| 5056 | | GAME( 1999, kbash2, 0, kbash2, kbash2, T2_noZ80, ROT0, "bootleg", "Knuckle Bash 2 (bootleg)", 0 ) |
| 5057 | | GAME( 1992, truxton2, 0, truxton2, truxton2, T2_noZ80, ROT270, "Toaplan", "Truxton II / Tatsujin Oh", 0 ) |
| 5058 | | GAME( 1991, pipibibs, 0, pipibibs, pipibibs, T2_Z80, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu)", 0 ) |
| 5059 | | GAME( 1991, whoopee, pipibibs, whoopee, whoopee, T2_Z80, ROT0, "Toaplan", "Whoopee!! / Pipi & Bibis", 0 ) |
| 5060 | | GAME( 1991, pipibibi, pipibibs, pipibibi, pipibibi, pipibibi, ROT0, "[Toaplan] Ryouta Kikaku", "Pipi & Bibis / Whoopee!! (bootleg ?)", 0 ) |
| 5061 | | GAME( 1992, fixeight, 0, fixeight, fixeight, fixeight, ROT270, "Toaplan", "FixEight", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING ) |
| 5062 | | GAME( 1992, fixeighb, fixeight, fixeighb, fixeighb, fixeighb, ROT270, "bootleg", "FixEight (bootleg)", 0 ) |
| 5063 | | GAME( 1992, grindstm, vfive, vfive, grindstm, T2_V25, ROT270, "Toaplan", "Grind Stormer", GAME_NO_SOUND ) |
| 5064 | | GAME( 1992, grindsta, vfive, vfive, grindstm, T2_V25, ROT270, "Toaplan", "Grind Stormer (older set)", GAME_NO_SOUND ) |
| 5065 | | GAME( 1993, vfive, 0, vfive, vfive, T2_V25, ROT270, "Toaplan", "V-Five (Japan)", GAME_NO_SOUND ) |
| 5066 | | GAME( 1993, batsugun, 0, batsugun, batsugun, T2_V25, ROT270, "Toaplan", "Batsugun (set 1)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 5067 | | GAME( 1993, batsugna, batsugun, batsugun, batsugun, T2_V25, ROT270, "Toaplan", "Batsugun (set 2)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 5068 | | GAME( 1993, batugnsp, batsugun, batsugun, batsugun, T2_V25, ROT270, "Toaplan", "Batsugun (Special Ver.)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS ) |
| 5069 | | GAME( 1994, snowbro2, 0, snowbro2, snowbro2, T2_noZ80, ROT0, "[Toaplan] Hanafram", "Snow Bros. 2 - With New Elves / Otenki Paradise", 0 ) |
| 5070 | | GAME( 1993, mahoudai, 0, mahoudai, mahoudai, T2_Z80, ROT270, "Raizing (Able license)", "Mahou Daisakusen (Japan)", 0 ) |
| 5071 | | GAME( 1993, sstriker, mahoudai, mahoudai, sstriker, T2_Z80, ROT270, "Raizing", "Sorcer Striker (World)" , 0) // from korean board |
| 5072 | | GAME( 1993, sstrikra, mahoudai, mahoudai, sstriker, T2_Z80, ROT270, "Raizing", "Sorcer Striker (World, alt)" , 0) // verified on two different PCBs |
| 5073 | | GAME( 1994, shippumd, 0, shippumd, shippumd, T2_Z80, ROT270, "Raizing / Eighting", "Shippu Mahou Daisakusen (Japan)", 0 ) |
| 5074 | | GAME( 1994, kingdmgp, shippumd, shippumd, kingdmgp, T2_Z80, ROT270, "Raizing / Eighting", "Kingdom Grandprix (World)" , 0) // from korean board, missing letters on credits screen but this is correct |
| 5075 | | GAME( 1996, bgaregga, 0, bgaregga, bgaregga, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga (Europe / USA / Japan / Asia) (Sat Feb 3 1996)", 0 ) |
| 5076 | | GAME( 1996, bgareghk, bgaregga, bgaregga, bgareghk, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga (Austria / Hong Kong) (Sat Feb 3 1996)", 0 ) |
| 5077 | | GAME( 1996, bgaregnv, bgaregga, bgaregga, bgareghk, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga - New Version (Austria / Hong Kong) (Sat Mar 2 1996)" , 0) // displays New Version only when set to HK |
| 5078 | | GAME( 1996, bgaregt2, bgaregga, bgaregga, bgaregga, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Europe / USA / Japan / Asia) (Sat Mar 2 1996)" , 0) // displays Type 2 only when set to Europe |
| 5079 | | GAME( 1996, bgaregcn, bgaregga, bgaregga, bgaregcn, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Denmark / China) (Tue Apr 2 1996)", 0 ) // displays Type 2 only when set to Denmark |
| 5080 | | GAME( 1998, batrider, 0, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider - B Version (Japan) (Fri Feb 13 1998)", 0 ) |
| 5081 | | GAME( 1998, batridra, batrider, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Japan) (Mon Dec 22 1997)", 0 ) |
| 5082 | | GAME( 1998, batridrk, batrider, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Korea) (Fri Feb 13 1998)", 0 ) |
| 5083 | | GAME( 1999, bbakraid, 0, bbakraid, bbakraid, bbakraid, ROT270, "Eighting", "Battle Bakraid (Japan) (Wed Apr 7 1999)", 0) |
| 5084 | | GAME( 1999, bbakradu, bbakraid, bbakraid, bbakraid, bbakradu, ROT270, "Eighting", "Battle Bakraid - Unlimited Version (Japan) (Tue Jun 8 1999)", 0) |
| 4994 | GAME( 1991, tekipaki, 0, tekipaki, tekipaki, T2_Z180, ROT0, "Toaplan", "Teki Paki", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 4995 | GAME( 1991, ghox, 0, ghox, ghox, T2_Z180, ROT270, "Toaplan", "Ghox (Spinner with Up/Down Axis)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 4996 | GAME( 1991, ghoxj, ghox, ghox, ghox, T2_Z180, ROT270, "Toaplan", "Ghox (8-Way Joystick)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 4997 | GAME( 1992, dogyuun, 0, dogyuun, dogyuun, T2_V25, ROT270, "Toaplan", "Dogyuun", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 4998 | GAME( 1993, kbash, 0, kbash, kbash, T2_V25, ROT0, "Toaplan", "Knuckle Bash", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
| 4999 | GAME( 1999, kbash2, 0, kbash2, kbash2, T2_noZ80, ROT0, "bootleg", "Knuckle Bash 2 (bootleg)", GAME_SUPPORTS_SAVE ) |
| 5000 | GAME( 1992, truxton2, 0, truxton2, truxton2, T2_noZ80, ROT270, "Toaplan", "Truxton II / Tatsujin Oh", GAME_SUPPORTS_SAVE ) |
| 5001 | GAME( 1991, pipibibs, 0, pipibibs, pipibibs, T2_Z80, ROT0, "Toaplan", "Pipi & Bibis / Whoopee!! (Z80 sound cpu)", GAME_SUPPORTS_SAVE ) |
| 5002 | GAME( 1991, whoopee, pipibibs, whoopee, whoopee, T2_Z80, ROT0, "Toaplan", "Whoopee!! / Pipi & Bibis", GAME_SUPPORTS_SAVE ) |
| 5003 | GAME( 1991, pipibibi, pipibibs, pipibibi, pipibibi, pipibibi, ROT0, "[Toaplan] Ryouta Kikaku", "Pipi & Bibis / Whoopee!! (bootleg ?)", GAME_SUPPORTS_SAVE ) |
| 5004 | GAME( 1992, fixeight, 0, fixeight, fixeight, fixeight, ROT270, "Toaplan", "FixEight", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) |
| 5005 | GAME( 1992, fixeighb, fixeight, fixeighb, fixeighb, fixeighb, ROT270, "bootleg", "FixEight (bootleg)", GAME_SUPPORTS_SAVE ) |
| 5006 | GAME( 1992, grindstm, vfive, vfive, grindstm, T2_V25, ROT270, "Toaplan", "Grind Stormer", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 5007 | GAME( 1992, grindsta, vfive, vfive, grindstm, T2_V25, ROT270, "Toaplan", "Grind Stormer (older set)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 5008 | GAME( 1993, vfive, 0, vfive, vfive, T2_V25, ROT270, "Toaplan", "V-Five (Japan)", GAME_NO_SOUND | GAME_SUPPORTS_SAVE ) |
| 5009 | GAME( 1993, batsugun, 0, batsugun, batsugun, T2_V25, ROT270, "Toaplan", "Batsugun (set 1)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) |
| 5010 | GAME( 1993, batsugna, batsugun, batsugun, batsugun, T2_V25, ROT270, "Toaplan", "Batsugun (set 2)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) |
| 5011 | GAME( 1993, batugnsp, batsugun, batsugun, batsugun, T2_V25, ROT270, "Toaplan", "Batsugun (Special Ver.)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) |
| 5012 | GAME( 1994, snowbro2, 0, snowbro2, snowbro2, T2_noZ80, ROT0, "[Toaplan] Hanafram", "Snow Bros. 2 - With New Elves / Otenki Paradise", GAME_SUPPORTS_SAVE ) |
| 5013 | GAME( 1993, mahoudai, 0, mahoudai, mahoudai, T2_Z80, ROT270, "Raizing (Able license)", "Mahou Daisakusen (Japan)", GAME_SUPPORTS_SAVE ) |
| 5014 | GAME( 1993, sstriker, mahoudai, mahoudai, sstriker, T2_Z80, ROT270, "Raizing", "Sorcer Striker (World)" , GAME_SUPPORTS_SAVE ) // from korean board |
| 5015 | GAME( 1993, sstrikra, mahoudai, mahoudai, sstriker, T2_Z80, ROT270, "Raizing", "Sorcer Striker (World, alt)" , GAME_SUPPORTS_SAVE ) // verified on two different PCBs |
| 5016 | GAME( 1994, shippumd, 0, shippumd, shippumd, T2_Z80, ROT270, "Raizing / Eighting", "Shippu Mahou Daisakusen (Japan)", GAME_SUPPORTS_SAVE ) |
| 5017 | GAME( 1994, kingdmgp, shippumd, shippumd, kingdmgp, T2_Z80, ROT270, "Raizing / Eighting", "Kingdom Grandprix (World)" , GAME_SUPPORTS_SAVE ) // from korean board, missing letters on credits screen but this is correct |
| 5018 | GAME( 1996, bgaregga, 0, bgaregga, bgaregga, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga (Europe / USA / Japan / Asia) (Sat Feb 3 1996)", GAME_SUPPORTS_SAVE ) |
| 5019 | GAME( 1996, bgareghk, bgaregga, bgaregga, bgareghk, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga (Austria / Hong Kong) (Sat Feb 3 1996)", GAME_SUPPORTS_SAVE ) |
| 5020 | GAME( 1996, bgaregnv, bgaregga, bgaregga, bgareghk, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga - New Version (Austria / Hong Kong) (Sat Mar 2 1996)" , GAME_SUPPORTS_SAVE ) // displays New Version only when set to HK |
| 5021 | GAME( 1996, bgaregt2, bgaregga, bgaregga, bgaregga, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Europe / USA / Japan / Asia) (Sat Mar 2 1996)" , GAME_SUPPORTS_SAVE ) // displays Type 2 only when set to Europe |
| 5022 | GAME( 1996, bgaregcn, bgaregga, bgaregga, bgaregcn, T2_Z80, ROT270, "Raizing / Eighting", "Battle Garegga - Type 2 (Denmark / China) (Tue Apr 2 1996)", GAME_SUPPORTS_SAVE ) // displays Type 2 only when set to Denmark |
| 5023 | GAME( 1998, batrider, 0, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider - B Version (Japan) (Fri Feb 13 1998)", GAME_SUPPORTS_SAVE ) |
| 5024 | GAME( 1998, batridra, batrider, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Japan) (Mon Dec 22 1997)", GAME_SUPPORTS_SAVE ) |
| 5025 | GAME( 1998, batridrk, batrider, batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Korea) (Fri Feb 13 1998)", GAME_SUPPORTS_SAVE ) |
| 5026 | GAME( 1999, bbakraid, 0, bbakraid, bbakraid, bbakraid, ROT270, "Eighting", "Battle Bakraid (Japan) (Wed Apr 7 1999)", GAME_SUPPORTS_SAVE ) |
| 5027 | GAME( 1999, bbakradu, bbakraid, bbakraid, bbakraid, bbakradu, ROT270, "Eighting", "Battle Bakraid - Unlimited Version (Japan) (Tue Jun 8 1999)", GAME_SUPPORTS_SAVE ) |
src/mame/drivers/jalmah.c
| r3514 | r3515 | |
| 18 | 18 | adding a value to these RAM areas according to what button is pressed. |
| 19 | 19 | |
| 20 | 20 | TODO: |
| 21 | | -Understand what are RANGE registers for.They seems to be related to the scroll |
| 22 | | registers; |
| 23 | | -In all the games there are square gaps during gameplay,maybe we can call a simple fillbitmap and |
| 24 | | remove the jalmah_tilemap_draw custom code; |
| 25 | | -Fix kakumei2 GFX3 rom region,maybe bad dump (half length)? |
| 26 | 21 | -Fully understand priorities,chances are that it just uses a mix between the priority |
| 27 | | number and 1+ prom(s); |
| 28 | | -Fix daireika GFX rom loading and check if urashima has a "mode 3" for the layer 0 |
| 29 | | tilemap; |
| 22 | number,1+ prom(s) and the color number inside the video ram.Might need a test with the proper hardware; |
| 23 | -In all the games there are square gaps during gameplay,caused by the imperfect priority system (see above); |
| 24 | -Check if urashima has a "mode 3" for the layer 0 tilemap; |
| 30 | 25 | -Complete the dip-switches in the first version of this board; |
| 31 | 26 | -There could be timing issues caused by MCU simulation at $80004; |
| 32 | | -daireika/kakumei2/urashima have problems with the tx layer vertical scrolling during the attract |
| 33 | | mode, likely to be a paging issue; |
| 34 | | -Fix the sound banking in the first version of the MCU.A bank issue? |
| 35 | | -urashima might use three layers instead of two or it's all mirrored.It can be checked when you win |
| 36 | | a match in particular circumstances because there's a write in a unmapped region; |
| 37 | | -Massive clean-ups needed for the MCU snippet programs; |
| 27 | -Fix the sound banking in the first version of the MCU.Protection-related (should be somewhere on the work ram/shared ram) |
| 28 | -Fix kakumei2 GFX3 rom region,maybe it's a bad dump (half length)? |
| 29 | -urashima: might use three/four layers instead of two.It can be checked when you win |
| 30 | a match in particular circumstances because there's a write in the 94000-9bfff region; |
| 31 | -kakumei: inserting two credits will give an "informaion" with A-E button choices and nothing appears |
| 32 | to work,protection? |
| 33 | -Fix the sound banking in urashima/mjzoomin/daireika; |
| 34 | -Massive clean-ups needed for the MCU snippet programs and the input-ports; |
| 38 | 35 | |
| 39 | 36 | Notes (1st MCU ver.): |
| 40 | 37 | -$f000e is bogus,maybe the program snippets can modify this value,or the MCU itself can |
| r3514 | r3515 | |
| 107 | 104 | #include "cpu/m68000/m68000.h" |
| 108 | 105 | #include "sound/okim6295.h" |
| 109 | 106 | |
| 110 | | static tilemap *sc3_tilemap, *sc0_tilemap,*sc1_tilemap,*sc2_tilemap; |
| 111 | | static UINT16 *sc3_vram, *sc0_vram,*sc1_vram,*sc2_vram; |
| 112 | | static UINT16 *jm_regs,*jm_ram,*jm_mcu_code; |
| 107 | /****************************************************************************************** |
| 108 | |
| 109 | Video Hardware start |
| 110 | |
| 111 | ******************************************************************************************/ |
| 112 | |
| 113 | static tilemap *sc3_tilemap_0,*sc3_tilemap_2,*sc3_tilemap_3, |
| 114 | *sc0_tilemap_0,*sc0_tilemap_1,*sc0_tilemap_2,*sc0_tilemap_3, |
| 115 | *sc1_tilemap_0,*sc1_tilemap_1,*sc1_tilemap_2,*sc1_tilemap_3, |
| 116 | *sc2_tilemap_0,*sc2_tilemap_1,*sc2_tilemap_2,*sc2_tilemap_3; |
| 117 | static UINT16 *sc3_vram,*sc0_vram,*sc1_vram,*sc2_vram; |
| 113 | 118 | static UINT16 *jm_scrollram,*jm_vregs; |
| 114 | 119 | static UINT16 sc0bank,pri; |
| 115 | | /* |
| 116 | | MCU program number,different for each game(n.b. the numbering scheme is *mine*,do not |
| 117 | | take it seriously...): |
| 118 | | 0x11 = daireika |
| 119 | | 0x12 = urashima |
| 120 | | 0x13 = mjzoomin |
| 121 | | 0x21 = kakumei |
| 122 | | 0x22 = kakumei2 |
| 123 | | 0x23 = suchipi |
| 124 | 120 | |
| 125 | | xxxx ---- MCU program revision |
| 126 | | ---- xxxx MCU program number assignment for each game. |
| 127 | | */ |
| 128 | | static UINT8 mcu_prg; |
| 129 | | #define DAIREIKA_MCU (0x11) |
| 130 | | #define URASHIMA_MCU (0x12) |
| 131 | | #define MJZOOMIN_MCU (0x13) |
| 132 | | #define KAKUMEI_MCU (0x21) |
| 133 | | #define KAKUMEI2_MCU (0x22) |
| 134 | | #define SUCHIPI_MCU (0x23) |
| 121 | /*4096x512 tilemap*/ |
| 122 | static TILEMAP_MAPPER( range0_16x16 ) |
| 123 | { |
| 124 | /* logical (col,row) -> memory offset */ |
| 125 | return (row & 0x0f) + ((col & 0xff) << 4) + ((row & 0x70) << 8); |
| 126 | } |
| 135 | 127 | |
| 136 | | static int respcount; |
| 128 | /*2048x1024 tilemap*/ |
| 129 | static TILEMAP_MAPPER( range1_16x16 ) |
| 130 | { |
| 131 | /* logical (col,row) -> memory offset */ |
| 132 | return (row & 0x0f) + ((col & 0x7f) << 4) + ((row & 0xf0) << 7); |
| 133 | } |
| 137 | 134 | |
| 138 | | static TILEMAP_MAPPER( bg_scan ) |
| 135 | /*1024x2048 tilemap*/ |
| 136 | static TILEMAP_MAPPER( range2_16x16 ) |
| 139 | 137 | { |
| 140 | 138 | /* logical (col,row) -> memory offset */ |
| 141 | | return (row & 0x0f) + ((col & 0xff) << 4) + ((row & 0x70) << 8); |
| 139 | return (row & 0x0f) + ((col & 0x3f) << 4) + ((row & 0x1f0) << 6); |
| 142 | 140 | } |
| 143 | 141 | |
| 142 | /*512x4096 tilemap*/ |
| 143 | static TILEMAP_MAPPER( range3_16x16 ) |
| 144 | { |
| 145 | /* logical (col,row) -> memory offset */ |
| 146 | return (row & 0x0f) + ((col & 0x1f) << 4) + ((row & 0x3f0) << 5); |
| 147 | } |
| 148 | |
| 149 | |
| 150 | /*1024x512 tilemap*/ |
| 151 | static TILEMAP_MAPPER( range2_8x8 ) |
| 152 | { |
| 153 | /* logical (col,row) -> memory offset */ |
| 154 | return (row & 0x1f) + ((col & 0x7f) * 0x20) + ((row & 0x20) * 0x80); |
| 155 | } |
| 156 | |
| 157 | /*512x1024 tilemap*/ |
| 158 | static TILEMAP_MAPPER( range3_8x8 ) |
| 159 | { |
| 160 | return (row & 0x1f) + ((col & 0x3f) * 0x20) + ((row & 0x60) * 0x40); |
| 161 | } |
| 162 | |
| 144 | 163 | static TILE_GET_INFO( get_sc0_tile_info ) |
| 145 | 164 | { |
| 146 | 165 | int code = sc0_vram[tile_index]; |
| r3514 | r3515 | |
| 151 | 170 | 0); |
| 152 | 171 | } |
| 153 | 172 | |
| 154 | | static TILE_GET_INFO( get_sc3_tile_info ) |
| 173 | static TILE_GET_INFO( get_sc1_tile_info ) |
| 155 | 174 | { |
| 156 | | int code = sc3_vram[tile_index]; |
| 175 | int code = sc1_vram[tile_index]; |
| 157 | 176 | SET_TILE_INFO( |
| 158 | | 0, |
| 177 | 2, |
| 159 | 178 | code & 0xfff, |
| 160 | 179 | code >> 12, |
| 161 | 180 | 0); |
| r3514 | r3515 | |
| 171 | 190 | 0); |
| 172 | 191 | } |
| 173 | 192 | |
| 174 | | static TILE_GET_INFO( get_sc1_tile_info ) |
| 193 | static TILE_GET_INFO( get_sc3_tile_info ) |
| 175 | 194 | { |
| 176 | | int code = sc1_vram[tile_index]; |
| 195 | int code = sc3_vram[tile_index]; |
| 177 | 196 | SET_TILE_INFO( |
| 178 | | 2, |
| 197 | 0, |
| 179 | 198 | code & 0xfff, |
| 180 | 199 | code >> 12, |
| 181 | 200 | 0); |
| r3514 | r3515 | |
| 183 | 202 | |
| 184 | 203 | static VIDEO_START( jalmah ) |
| 185 | 204 | { |
| 186 | | sc0_tilemap = tilemap_create(get_sc0_tile_info,bg_scan,16,16,256,32); |
| 187 | | sc1_tilemap = tilemap_create(get_sc1_tile_info,bg_scan,16,16,256,32); |
| 188 | | sc2_tilemap = tilemap_create(get_sc2_tile_info,bg_scan,16,16,256,32); |
| 189 | | sc3_tilemap = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,256,32); |
| 205 | sc0_tilemap_0 = tilemap_create(get_sc0_tile_info,range0_16x16,16,16,256,32); |
| 206 | sc0_tilemap_1 = tilemap_create(get_sc0_tile_info,range1_16x16,16,16,128,64); |
| 207 | sc0_tilemap_2 = tilemap_create(get_sc0_tile_info,range2_16x16,16,16,64,128); |
| 208 | sc0_tilemap_3 = tilemap_create(get_sc0_tile_info,range3_16x16,16,16,32,256); |
| 190 | 209 | |
| 210 | sc1_tilemap_0 = tilemap_create(get_sc1_tile_info,range0_16x16,16,16,256,32); |
| 211 | sc1_tilemap_1 = tilemap_create(get_sc1_tile_info,range1_16x16,16,16,128,64); |
| 212 | sc1_tilemap_2 = tilemap_create(get_sc1_tile_info,range2_16x16,16,16,64,128); |
| 213 | sc1_tilemap_3 = tilemap_create(get_sc1_tile_info,range3_16x16,16,16,32,256); |
| 214 | |
| 215 | sc2_tilemap_0 = tilemap_create(get_sc2_tile_info,range0_16x16,16,16,256,32); |
| 216 | sc2_tilemap_1 = tilemap_create(get_sc2_tile_info,range1_16x16,16,16,128,64); |
| 217 | sc2_tilemap_2 = tilemap_create(get_sc2_tile_info,range2_16x16,16,16,64,128); |
| 218 | sc2_tilemap_3 = tilemap_create(get_sc2_tile_info,range3_16x16,16,16,32,256); |
| 219 | |
| 220 | sc3_tilemap_0 = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,256,32); |
| 221 | // sc3_tilemap_1 = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,256,32); |
| 222 | sc3_tilemap_2 = tilemap_create(get_sc3_tile_info,range2_8x8,8,8,128,64); |
| 223 | sc3_tilemap_3 = tilemap_create(get_sc3_tile_info,range3_8x8,8,8,64,128); |
| 224 | |
| 191 | 225 | jm_scrollram = auto_malloc(0x80); |
| 192 | 226 | jm_vregs = auto_malloc(0x40); |
| 193 | 227 | |
| 194 | | tilemap_set_transparent_pen(sc0_tilemap,15); |
| 195 | | tilemap_set_transparent_pen(sc1_tilemap,15); |
| 196 | | tilemap_set_transparent_pen(sc2_tilemap,15); |
| 197 | | tilemap_set_transparent_pen(sc3_tilemap,15); |
| 228 | tilemap_set_transparent_pen(sc0_tilemap_0,15); |
| 229 | tilemap_set_transparent_pen(sc0_tilemap_1,15); |
| 230 | tilemap_set_transparent_pen(sc0_tilemap_2,15); |
| 231 | tilemap_set_transparent_pen(sc0_tilemap_3,15); |
| 232 | |
| 233 | tilemap_set_transparent_pen(sc1_tilemap_0,15); |
| 234 | tilemap_set_transparent_pen(sc1_tilemap_1,15); |
| 235 | tilemap_set_transparent_pen(sc1_tilemap_2,15); |
| 236 | tilemap_set_transparent_pen(sc1_tilemap_3,15); |
| 237 | |
| 238 | tilemap_set_transparent_pen(sc2_tilemap_0,15); |
| 239 | tilemap_set_transparent_pen(sc2_tilemap_1,15); |
| 240 | tilemap_set_transparent_pen(sc2_tilemap_2,15); |
| 241 | tilemap_set_transparent_pen(sc2_tilemap_3,15); |
| 242 | |
| 243 | tilemap_set_transparent_pen(sc3_tilemap_0,15); |
| 244 | tilemap_set_transparent_pen(sc3_tilemap_2,15); |
| 245 | tilemap_set_transparent_pen(sc3_tilemap_3,15); |
| 198 | 246 | } |
| 199 | 247 | |
| 200 | | /*two tilemaps instead of four*/ |
| 201 | 248 | static VIDEO_START( urashima ) |
| 202 | 249 | { |
| 203 | | sc0_tilemap = tilemap_create(get_sc0_tile_info,bg_scan,16,16,256,32); |
| 204 | | // sc1_tilemap = tilemap_create(get_sc1_tile_info,bg_scan,TILEMAP_TRANSPARENT,16,16,256,32); |
| 205 | | // sc2_tilemap = tilemap_create(get_sc2_tile_info,bg_scan,TILEMAP_TRANSPARENT,16,16,256,32); |
| 206 | | sc3_tilemap = tilemap_create(get_sc3_tile_info,tilemap_scan_cols,8,8,256,32); |
| 250 | sc0_tilemap_0 = tilemap_create(get_sc0_tile_info,range0_16x16,16,16,256,32); |
| 251 | sc3_tilemap_0 = tilemap_create(get_sc3_tile_info,range2_8x8,8,8,128,64); |
| 207 | 252 | |
| 208 | 253 | jm_scrollram = auto_malloc(0x80); |
| 209 | 254 | jm_vregs = auto_malloc(0x40); |
| 210 | 255 | |
| 211 | | tilemap_set_transparent_pen(sc0_tilemap,15); |
| 212 | | // tilemap_set_transparent_pen(sc1_tilemap,15); |
| 213 | | // tilemap_set_transparent_pen(sc2_tilemap,15); |
| 214 | | tilemap_set_transparent_pen(sc3_tilemap,15); |
| 256 | tilemap_set_transparent_pen(sc0_tilemap_0,15); |
| 257 | tilemap_set_transparent_pen(sc3_tilemap_0,15); |
| 215 | 258 | } |
| 216 | 259 | |
| 260 | static UINT8 sc0_prin,sc1_prin,sc2_prin,sc3_prin; |
| 261 | |
| 262 | static void jalmah_priority_system(void) |
| 263 | { |
| 264 | // UINT8 *pri_rom = memory_region(Machine, "user1"); |
| 265 | /* |
| 266 | Case by case priorities: |
| 267 | kakumei: title screen = 0/23 (0-1 unused) |
| 268 | attract mode = 0/0123 (?) |
| 269 | card table = 0/013 (2 unused) |
| 270 | gameplay = 0/0123 |
| 271 | kakumei2:title screen = 0/0123 |
| 272 | attract mode = 4/013 (2 unused) also 4/0213 |
| 273 | card table = 9/013 (2 unused) |
| 274 | character screen = 9/013 (2 unused) |
| 275 | gameplay = 2/03 (1-2 unused) also 2/013 (2 unused) |
| 276 | continue screen = 9/013 (2 unused) |
| 277 | suchipi: title screen = 0/03 (1-2 unused) |
| 278 | attract mode = 6/103 (2 unused) also 6/1023 |
| 279 | card table = 1/013 (2 unused) |
| 280 | character screen = 4/0213 |
| 281 | victory screen = 6/0123 also 6/1023 |
| 282 | gameplay = d/0123 |
| 283 | mjzoomin doesn't seem to use the priority number (0/0123) |
| 284 | daireika/urashima uses priority number with the protection device |
| 285 | daireika: gameplay = x/103 (2 unused),might be 6 |
| 286 | good results: |
| 287 | 0/0123 |
| 288 | 4/0213 |
| 289 | 6/1023 |
| 290 | */ |
| 291 | static const UINT16 pri_scheme[0x10] = { 0x0123, 0x0123, 0x0123, 0x0123, 0x0213, 0x0123, 0x1023, 0x0123, |
| 292 | 0x0123, 0x1203, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123, 0x0123 }; |
| 293 | // UINT8 prinum[0x10]; |
| 294 | |
| 295 | // for(i=0;i<0x10;i++) |
| 296 | // prinum[i] = pri_rom[i+pri*0x10]; |
| 297 | sc0_prin = (pri_scheme[pri] & 0xf000) >> 12; |
| 298 | sc1_prin = (pri_scheme[pri] & 0x0f00) >> 8; |
| 299 | sc2_prin = (pri_scheme[pri] & 0x00f0) >> 4; |
| 300 | sc3_prin = (pri_scheme[pri] & 0x000f) >> 0; |
| 301 | |
| 302 | // popmessage("%04x",pri); |
| 303 | /* |
| 304 | popmessage("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x %02x" |
| 305 | ,prinum[0x00],prinum[0x01],prinum[0x02],prinum[0x03] |
| 306 | ,prinum[0x04],prinum[0x05],prinum[0x06],prinum[0x07] |
| 307 | ,prinum[0x08],prinum[0x09],prinum[0x0a],prinum[0x0b] |
| 308 | ,prinum[0x0c],prinum[0x0d],prinum[0x0e],prinum[0x0f],pri); |
| 309 | */ |
| 310 | } |
| 311 | |
| 312 | static void draw_sc0_layer(bitmap_t *bitmap, const rectangle *cliprect,int trans) |
| 313 | { |
| 314 | switch(jm_vregs[0] & 3) |
| 315 | { |
| 316 | case 0: tilemap_draw(bitmap,cliprect,sc0_tilemap_0,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 317 | case 1: tilemap_draw(bitmap,cliprect,sc0_tilemap_1,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 318 | case 2: tilemap_draw(bitmap,cliprect,sc0_tilemap_2,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 319 | case 3: tilemap_draw(bitmap,cliprect,sc0_tilemap_3,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | static void draw_sc1_layer(bitmap_t *bitmap, const rectangle *cliprect,int trans) |
| 324 | { |
| 325 | switch(jm_vregs[1] & 3) |
| 326 | { |
| 327 | case 0: tilemap_draw(bitmap,cliprect,sc1_tilemap_0,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 328 | case 1: tilemap_draw(bitmap,cliprect,sc1_tilemap_1,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 329 | case 2: tilemap_draw(bitmap,cliprect,sc1_tilemap_2,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 330 | case 3: tilemap_draw(bitmap,cliprect,sc1_tilemap_3,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | static void draw_sc2_layer(bitmap_t *bitmap, const rectangle *cliprect,int trans) |
| 335 | { |
| 336 | switch(jm_vregs[2] & 3) |
| 337 | { |
| 338 | case 0: tilemap_draw(bitmap,cliprect,sc2_tilemap_0,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 339 | case 1: tilemap_draw(bitmap,cliprect,sc2_tilemap_1,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 340 | case 2: tilemap_draw(bitmap,cliprect,sc2_tilemap_2,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 341 | case 3: tilemap_draw(bitmap,cliprect,sc2_tilemap_3,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | static void draw_sc3_layer(bitmap_t *bitmap, const rectangle *cliprect,int trans) |
| 346 | { |
| 347 | switch(jm_vregs[3] & 3) |
| 348 | { |
| 349 | case 0: |
| 350 | case 1: tilemap_draw(bitmap,cliprect,sc3_tilemap_0,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 351 | case 2: tilemap_draw(bitmap,cliprect,sc3_tilemap_2,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 352 | case 3: tilemap_draw(bitmap,cliprect,sc3_tilemap_3,(trans > 0) ? 0 : TILEMAP_DRAW_OPAQUE,0); break; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | static VIDEO_UPDATE( jalmah ) |
| 357 | { |
| 358 | static UINT8 cur_prin; |
| 359 | jalmah_priority_system(); |
| 360 | |
| 361 | tilemap_set_scrollx( sc0_tilemap_0, 0, jm_scrollram[0] & 0xfff); |
| 362 | tilemap_set_scrollx( sc0_tilemap_1, 0, jm_scrollram[0] & 0x7ff); |
| 363 | tilemap_set_scrollx( sc0_tilemap_2, 0, jm_scrollram[0] & 0x3ff); |
| 364 | tilemap_set_scrollx( sc0_tilemap_3, 0, jm_scrollram[0] & 0x1ff); |
| 365 | |
| 366 | tilemap_set_scrollx( sc1_tilemap_0, 0, jm_scrollram[1] & 0xfff); |
| 367 | tilemap_set_scrollx( sc1_tilemap_1, 0, jm_scrollram[1] & 0x7ff); |
| 368 | tilemap_set_scrollx( sc1_tilemap_2, 0, jm_scrollram[1] & 0x3ff); |
| 369 | tilemap_set_scrollx( sc1_tilemap_3, 0, jm_scrollram[1] & 0x1ff); |
| 370 | |
| 371 | tilemap_set_scrollx( sc2_tilemap_0, 0, jm_scrollram[2] & 0xfff); |
| 372 | tilemap_set_scrollx( sc2_tilemap_1, 0, jm_scrollram[2] & 0x7ff); |
| 373 | tilemap_set_scrollx( sc2_tilemap_2, 0, jm_scrollram[2] & 0x3ff); |
| 374 | tilemap_set_scrollx( sc2_tilemap_3, 0, jm_scrollram[2] & 0x1ff); |
| 375 | |
| 376 | tilemap_set_scrollx( sc3_tilemap_0, 0, jm_scrollram[3] & 0x7ff); |
| 377 | // empty |
| 378 | tilemap_set_scrollx( sc3_tilemap_2, 0, jm_scrollram[3] & 0x3ff); |
| 379 | tilemap_set_scrollx( sc3_tilemap_3, 0, jm_scrollram[3] & 0x1ff); |
| 380 | |
| 381 | |
| 382 | tilemap_set_scrolly( sc0_tilemap_0, 0, jm_scrollram[4] & 0x1ff); |
| 383 | tilemap_set_scrolly( sc0_tilemap_1, 0, jm_scrollram[4] & 0x3ff); |
| 384 | tilemap_set_scrolly( sc0_tilemap_2, 0, jm_scrollram[4] & 0x7ff); |
| 385 | tilemap_set_scrolly( sc0_tilemap_3, 0, jm_scrollram[4] & 0xfff); |
| 386 | |
| 387 | tilemap_set_scrolly( sc1_tilemap_0, 0, jm_scrollram[5] & 0x1ff); |
| 388 | tilemap_set_scrolly( sc1_tilemap_1, 0, jm_scrollram[5] & 0x3ff); |
| 389 | tilemap_set_scrolly( sc1_tilemap_2, 0, jm_scrollram[5] & 0x7ff); |
| 390 | tilemap_set_scrolly( sc1_tilemap_3, 0, jm_scrollram[5] & 0xfff); |
| 391 | |
| 392 | tilemap_set_scrolly( sc2_tilemap_0, 0, jm_scrollram[6] & 0x1ff); |
| 393 | tilemap_set_scrolly( sc2_tilemap_1, 0, jm_scrollram[6] & 0x3ff); |
| 394 | tilemap_set_scrolly( sc2_tilemap_2, 0, jm_scrollram[6] & 0x7ff); |
| 395 | tilemap_set_scrolly( sc2_tilemap_3, 0, jm_scrollram[6] & 0xfff); |
| 396 | |
| 397 | tilemap_set_scrolly( sc3_tilemap_0, 0, jm_scrollram[7] & 0xff); |
| 398 | // empty |
| 399 | tilemap_set_scrolly( sc3_tilemap_2, 0, jm_scrollram[7] & 0x1ff); |
| 400 | tilemap_set_scrolly( sc3_tilemap_3, 0, jm_scrollram[7] & 0x3ff); |
| 401 | |
| 402 | fillbitmap(bitmap, Machine->pens[0x10f], cliprect);//selectable by a ram address? |
| 403 | |
| 404 | for(cur_prin=0;cur_prin<4;cur_prin++) |
| 405 | { |
| 406 | if(cur_prin==sc0_prin) { draw_sc0_layer(bitmap,cliprect,sc0_prin); } |
| 407 | if(cur_prin==sc1_prin) { draw_sc1_layer(bitmap,cliprect,sc1_prin); } |
| 408 | if(cur_prin==sc2_prin) { draw_sc2_layer(bitmap,cliprect,sc2_prin); } |
| 409 | if(cur_prin==sc3_prin) { draw_sc3_layer(bitmap,cliprect,sc3_prin); } |
| 410 | } |
| 411 | |
| 412 | return 0; |
| 413 | } |
| 414 | |
| 415 | static VIDEO_UPDATE( urashima ) |
| 416 | { |
| 417 | /*this game doesn't use the RANGE register at all.*/ |
| 418 | tilemap_set_scrollx( sc0_tilemap_0, 0, jm_scrollram[0]); |
| 419 | tilemap_set_scrollx( sc3_tilemap_0, 0, jm_scrollram[3]); |
| 420 | tilemap_set_scrolly( sc0_tilemap_0, 0, jm_scrollram[4]); |
| 421 | tilemap_set_scrolly( sc3_tilemap_0, 0, jm_scrollram[7]); |
| 422 | |
| 423 | fillbitmap(bitmap, Machine->pens[0x1ff], cliprect);//selectable by a ram address? |
| 424 | if(jm_vregs[0] & 1) { tilemap_draw(bitmap,cliprect,sc0_tilemap_0,0,0); } |
| 425 | if(jm_vregs[3] & 1) { tilemap_draw(bitmap,cliprect,sc3_tilemap_0,0,0); } |
| 426 | return 0; |
| 427 | } |
| 428 | |
| 429 | static WRITE16_HANDLER( sc0_vram_w ) |
| 430 | { |
| 431 | COMBINE_DATA(&sc0_vram[offset]); |
| 432 | /*2048x256 tilemap*/ |
| 433 | tilemap_mark_tile_dirty(sc0_tilemap_0,offset); |
| 434 | /*1024x512 tilemap*/ |
| 435 | tilemap_mark_tile_dirty(sc0_tilemap_1,offset); |
| 436 | /*512x1024 tilemap*/ |
| 437 | tilemap_mark_tile_dirty(sc0_tilemap_2,offset); |
| 438 | /*256x2048 tilemap*/ |
| 439 | tilemap_mark_tile_dirty(sc0_tilemap_3,offset); |
| 440 | } |
| 441 | |
| 442 | static WRITE16_HANDLER( sc3_vram_w ) |
| 443 | { |
| 444 | COMBINE_DATA(&sc3_vram[offset]); |
| 445 | /*2048x256 tilemap*/ |
| 446 | tilemap_mark_tile_dirty(sc3_tilemap_0,offset); |
| 447 | /*1024x512 tilemap*/ |
| 448 | tilemap_mark_tile_dirty(sc3_tilemap_2,offset); |
| 449 | /*512x1024 tilemap*/ |
| 450 | tilemap_mark_tile_dirty(sc3_tilemap_3,offset); |
| 451 | } |
| 452 | |
| 453 | static WRITE16_HANDLER( sc1_vram_w ) |
| 454 | { |
| 455 | COMBINE_DATA(&sc1_vram[offset]); |
| 456 | /*2048x256 tilemap*/ |
| 457 | tilemap_mark_tile_dirty(sc1_tilemap_0,offset); |
| 458 | /*1024x512 tilemap*/ |
| 459 | tilemap_mark_tile_dirty(sc1_tilemap_1,offset); |
| 460 | /*512x1024 tilemap*/ |
| 461 | tilemap_mark_tile_dirty(sc1_tilemap_2,offset); |
| 462 | /*256x2048 tilemap*/ |
| 463 | tilemap_mark_tile_dirty(sc1_tilemap_3,offset); |
| 464 | } |
| 465 | |
| 466 | static WRITE16_HANDLER( sc2_vram_w ) |
| 467 | { |
| 468 | COMBINE_DATA(&sc2_vram[offset]); |
| 469 | /*2048x256 tilemap*/ |
| 470 | tilemap_mark_tile_dirty(sc2_tilemap_0,offset); |
| 471 | /*1024x512 tilemap*/ |
| 472 | tilemap_mark_tile_dirty(sc2_tilemap_1,offset); |
| 473 | /*512x1024 tilemap*/ |
| 474 | tilemap_mark_tile_dirty(sc2_tilemap_2,offset); |
| 475 | /*256x2048 tilemap*/ |
| 476 | tilemap_mark_tile_dirty(sc2_tilemap_3,offset); |
| 477 | } |
| 478 | |
| 479 | static WRITE16_HANDLER( jalmah_tilebank_w ) |
| 480 | { |
| 481 | /* |
| 482 | xxxx ---- fg bank (used by suchipi) |
| 483 | ---- xxxx Priority number (trusted,see mjzoomin) |
| 484 | */ |
| 485 | //popmessage("Write to tilebank %02x",data); |
| 486 | if (ACCESSING_BITS_0_7) |
| 487 | { |
| 488 | if (sc0bank != ((data & 0xf0) >> 4)) |
| 489 | { |
| 490 | sc0bank = (data & 0xf0) >> 4; |
| 491 | tilemap_mark_all_tiles_dirty(sc0_tilemap_0); |
| 492 | tilemap_mark_all_tiles_dirty(sc0_tilemap_1); |
| 493 | tilemap_mark_all_tiles_dirty(sc0_tilemap_2); |
| 494 | tilemap_mark_all_tiles_dirty(sc0_tilemap_3); |
| 495 | } |
| 496 | if (pri != (data & 0x0f)) |
| 497 | pri = data & 0x0f; |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | static WRITE16_HANDLER( jalmah_scroll_w ) |
| 502 | { |
| 503 | //logerror("[%04x]<-%04x\n",(offset+0x10)*2,data); |
| 504 | switch(offset+(0x10)) |
| 505 | { |
| 506 | /*These 4 are just video regs,see mjzoomin test*/ |
| 507 | /* |
| 508 | ---x ---- Always on,8x8 tiles switch? |
| 509 | ---- --xx RANGE registers |
| 510 | */ |
| 511 | case (0x24/2): jm_vregs[0] = data; break; |
| 512 | case (0x2c/2): jm_vregs[1] = data; break; |
| 513 | case (0x34/2): jm_vregs[2] = data; break; |
| 514 | case (0x3c/2): jm_vregs[3] = data; break; |
| 515 | |
| 516 | case (0x20/2): jm_scrollram[0] = data; break; |
| 517 | case (0x28/2): jm_scrollram[1] = data; break; |
| 518 | case (0x30/2): jm_scrollram[2] = data; break; |
| 519 | case (0x38/2): jm_scrollram[3] = data; break; |
| 520 | case (0x22/2): jm_scrollram[4] = data; break; |
| 521 | case (0x2a/2): jm_scrollram[5] = data; break; |
| 522 | case (0x32/2): jm_scrollram[6] = data; break; |
| 523 | case (0x3a/2): jm_scrollram[7] = data; break; |
| 524 | //default: popmessage("[%04x]<-%04x",offset+0x10,data); |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | static WRITE16_HANDLER( urashima_bank_w ) |
| 529 | { |
| 530 | if (ACCESSING_BITS_0_7) |
| 531 | { |
| 532 | if (sc0bank != (data & 0x0f)) |
| 533 | { |
| 534 | sc0bank = (data & 0x0f); |
| 535 | tilemap_mark_all_tiles_dirty(sc0_tilemap_0); |
| 536 | //tilemap_mark_all_tiles_dirty(sc0_tilemap_2); |
| 537 | //tilemap_mark_all_tiles_dirty(sc0_tilemap_3); |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | |
| 542 | static WRITE16_HANDLER( urashima_sc0_vram_w ) |
| 543 | { |
| 544 | COMBINE_DATA(&sc0_vram[offset]); |
| 545 | tilemap_mark_tile_dirty(sc0_tilemap_0,offset); |
| 546 | } |
| 547 | |
| 548 | static WRITE16_HANDLER( urashima_sc3_vram_w ) |
| 549 | { |
| 550 | COMBINE_DATA(&sc3_vram[offset]); |
| 551 | tilemap_mark_tile_dirty(sc3_tilemap_0,offset); |
| 552 | } |
| 553 | |
| 554 | /*Urashima Mahjong uses a bigger (and mostly unused/wasted) video register ram.*/ |
| 555 | static WRITE16_HANDLER( urashima_vregs_w ) |
| 556 | { |
| 557 | //logerror("[%04x]<-%04x\n",(offset)*2,data); |
| 558 | switch(offset) |
| 559 | { |
| 560 | case 0x082/2: jm_vregs[0] = data; break; //sc0 plane enable |
| 561 | case 0x084/2: jm_scrollram[0] = data; break; //sc0 x offset |
| 562 | case 0x086/2: jm_scrollram[4] = data; break; //sc0 y offset |
| 563 | |
| 564 | // case 0x182/2: jm_vregs[0] = data; break; |
| 565 | // case 0x184/2: jm_scrollram[0] = data; break; |
| 566 | // case 0x186/2: jm_scrollram[4] = data; break; |
| 567 | |
| 568 | // case 0x382/2: jm_vregs[0] = data; break; |
| 569 | // case 0x384/2: jm_scrollram[0] = data; break; |
| 570 | // case 0x386/2: jm_scrollram[4] = data; break; |
| 571 | |
| 572 | case 0x882/2: jm_vregs[3] = data; break; //sc3 plane enable |
| 573 | case 0x884/2: jm_scrollram[3] = data; break; //sc3 x offset |
| 574 | case 0x886/2: jm_scrollram[7] = data; break; //sc3 y offset |
| 575 | |
| 576 | /*WRONG!*/ |
| 577 | case 0x602/2: jm_vregs[0] = data; break; |
| 578 | case 0x604/2: jm_scrollram[0] = data; break; |
| 579 | case 0x606/2: jm_scrollram[4] = data; break; |
| 580 | |
| 581 | case 0x77a/2: jm_vregs[0] = data; break; //sc0 plane enable,flip screen |
| 582 | case 0x77c/2: jm_scrollram[0] = data; break; //sc0 x offset,flip screen |
| 583 | case 0x77e/2: jm_scrollram[4] = data; break; //sc0 y offset,flip screen |
| 584 | |
| 585 | case 0xf7a/2: jm_vregs[3] = data; break; //sc3 plane enable,flip screen |
| 586 | case 0xf7c/2: jm_scrollram[3] = data; break; //sc3 x offset,flip screen |
| 587 | case 0xf7e/2: jm_scrollram[7] = data; break; //sc3 y offset,flip screen |
| 588 | default: break; |
| 589 | } |
| 590 | //popmessage("%04x %04x %04x %04x %02x %02x",jm_scrollram[0],jm_scrollram[4],jm_scrollram[3],jm_scrollram[7],jm_vregs[0],jm_vregs[3]); |
| 591 | } |
| 592 | |
| 593 | /****************************************************************************************** |
| 594 | |
| 595 | Protection file start |
| 596 | |
| 597 | ******************************************************************************************/ |
| 598 | |
| 599 | static UINT16 *jm_shared_ram,*jm_mcu_code; |
| 600 | |
| 601 | /* |
| 602 | MCU program number,different for each game(n.b. the numbering scheme is *mine*,do not |
| 603 | take it seriously...): |
| 604 | 0x11 = daireika |
| 605 | 0x12 = urashima |
| 606 | 0x13 = mjzoomin |
| 607 | 0x21 = kakumei |
| 608 | 0x22 = kakumei2 |
| 609 | 0x23 = suchipi |
| 610 | |
| 611 | xxxx ---- MCU program revision |
| 612 | ---- xxxx MCU program number assignment for each game. |
| 613 | */ |
| 614 | |
| 615 | static UINT8 mcu_prg; |
| 616 | #define DAIREIKA_MCU (0x11) |
| 617 | #define URASHIMA_MCU (0x12) |
| 618 | #define MJZOOMIN_MCU (0x13) |
| 619 | #define KAKUMEI_MCU (0x21) |
| 620 | #define KAKUMEI2_MCU (0x22) |
| 621 | #define SUCHIPI_MCU (0x23) |
| 622 | |
| 623 | static int respcount; |
| 624 | |
| 217 | 625 | #define MCU_READ(tag, _bit_, _offset_, _retval_) \ |
| 218 | | if((0xffff - input_port_read(machine, tag)) & _bit_) { jm_regs[_offset_] = _retval_; } |
| 626 | if((0xffff - input_port_read(machine, tag)) & _bit_) { jm_shared_ram[_offset_] = _retval_; } |
| 219 | 627 | |
| 628 | /*Funky "DMA" / protection thing*/ |
| 629 | /*---- -x-- "DMA" execute.*/ |
| 630 | /*---- ---x used too very often,I don't have any clue of what it is,it might just be the source or the destination address.*/ |
| 631 | static WRITE16_HANDLER( urashima_dma_w ) |
| 632 | { |
| 633 | if(data & 4) |
| 634 | { |
| 635 | UINT32 i; |
| 636 | for(i=0;i<0x200;i+=2) |
| 637 | program_write_word(0x88200+i,program_read_word(0x88400+i)); |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | /*same as $f00c0 sub-routine,but with additional work-around,to remove from here...*/ |
| 642 | static void daireika_palette_dma(running_machine *machine,UINT16 val) |
| 643 | { |
| 644 | UINT32 index_1,index_2,src_addr,tmp_addr; |
| 645 | /*a0=301c0+jm_shared_ram[0x540/2] & 0xf00 */ |
| 646 | /*a1=88000*/ |
| 647 | src_addr = 0x301c0 + (val * 0x40); |
| 648 | // popmessage("%08x",src_addr); |
| 649 | for(index_1=0;index_1<0x200;index_1+=0x20) |
| 650 | { |
| 651 | tmp_addr = src_addr; |
| 652 | src_addr = program_read_dword(src_addr); |
| 653 | |
| 654 | for(index_2=0;index_2<0x20;index_2+=2) |
| 655 | program_write_word(0x88000+index_2+index_1,program_read_word(src_addr+index_2)); |
| 656 | |
| 657 | src_addr = tmp_addr + 4; |
| 658 | } |
| 659 | } |
| 660 | |
| 220 | 661 | /*RAM-based protection handlings*/ |
| 221 | 662 | static void daireika_mcu_run(running_machine *machine) |
| 222 | 663 | { |
| 664 | static UINT16 prg_prot,dma_old; |
| 665 | |
| 666 | if(((jm_shared_ram[0x550/2] & 0xf00) == 0x700) && ((jm_shared_ram[0x540/2] & 0xf00) != dma_old)) |
| 667 | { |
| 668 | dma_old = jm_shared_ram[0x540/2] & 0xf00; |
| 669 | daireika_palette_dma(machine,((jm_shared_ram[0x540/2] & 0x0f00) >> 8)); |
| 670 | } |
| 671 | |
| 672 | if((0xffff - input_port_read(machine, "SYSTEM")) & 0x0008) //service_mode |
| 673 | { |
| 674 | jm_shared_ram[0x000/2] = input_port_read(machine, "KEY0"); |
| 675 | jm_shared_ram[0x002/2] = input_port_read(machine, "KEY1"); |
| 676 | jm_shared_ram[0x004/2] = input_port_read(machine, "KEY2"); |
| 677 | jm_shared_ram[0x006/2] = input_port_read(machine, "KEY3"); |
| 678 | jm_shared_ram[0x008/2] = input_port_read(machine, "KEY4"); |
| 679 | jm_shared_ram[0x00a/2] = input_port_read(machine, "KEY5"); |
| 680 | } |
| 681 | else |
| 682 | { |
| 683 | jm_shared_ram[0x000/2] = 0x0000; |
| 684 | MCU_READ("KEY1", 0x0001, 0x000/2, 0x00); /*FF*/ |
| 685 | MCU_READ("KEY2", 0x0400, 0x000/2, 0x01); /*A*/ |
| 686 | MCU_READ("KEY2", 0x1000, 0x000/2, 0x02); /*B*/ |
| 687 | MCU_READ("KEY2", 0x0200, 0x000/2, 0x03); /*C*/ |
| 688 | MCU_READ("KEY2", 0x0800, 0x000/2, 0x04); /*D*/ |
| 689 | MCU_READ("KEY2", 0x0004, 0x000/2, 0x05); /*E*/ |
| 690 | MCU_READ("KEY2", 0x0010, 0x000/2, 0x06); /*F*/ |
| 691 | MCU_READ("KEY2", 0x0002, 0x000/2, 0x07); /*G*/ |
| 692 | MCU_READ("KEY2", 0x0008, 0x000/2, 0x08); /*H*/ |
| 693 | MCU_READ("KEY1", 0x0400, 0x000/2, 0x09); /*I*/ |
| 694 | MCU_READ("KEY1", 0x1000, 0x000/2, 0x0a); /*J*/ |
| 695 | MCU_READ("KEY1", 0x0200, 0x000/2, 0x0b); /*K*/ |
| 696 | MCU_READ("KEY1", 0x0800, 0x000/2, 0x0c); /*L*/ |
| 697 | MCU_READ("KEY1", 0x0004, 0x000/2, 0x0d); /*M*/ |
| 698 | MCU_READ("KEY1", 0x0010, 0x000/2, 0x0e); /*N*/ |
| 699 | MCU_READ("KEY0", 0x0200, 0x000/2, 0x0f); /*RON (trusted)*/ |
| 700 | MCU_READ("KEY0", 0x1000, 0x000/2, 0x10); /*REACH (trusted)*/ |
| 701 | MCU_READ("KEY0", 0x0400, 0x000/2, 0x11); /*KAN */ |
| 702 | MCU_READ("KEY1", 0x0008, 0x000/2, 0x12); /*PON */ |
| 703 | MCU_READ("KEY1", 0x0002, 0x000/2, 0x13); /*CHI (trusted)*/ |
| 704 | MCU_READ("KEY0", 0x0004, 0x000/2, 0x14); /*START1*/ |
| 705 | } |
| 706 | prg_prot++; |
| 707 | if(prg_prot > 0x10) { prg_prot = 0; } |
| 708 | jm_shared_ram[0x00e/2] = prg_prot; |
| 709 | } |
| 710 | |
| 711 | static void mjzoomin_mcu_run(running_machine *machine) |
| 712 | { |
| 223 | 713 | static UINT16 prg_prot; |
| 224 | 714 | |
| 225 | 715 | if((0xffff - input_port_read(machine, "SYSTEM")) & 0x0008) //service_mode |
| 226 | 716 | { |
| 227 | | jm_regs[0x000/2] = input_port_read(machine, "KEY0"); |
| 228 | | jm_regs[0x002/2] = input_port_read(machine, "KEY1"); |
| 229 | | jm_regs[0x004/2] = input_port_read(machine, "KEY2"); |
| 230 | | jm_regs[0x006/2] = input_port_read(machine, "KEY3"); |
| 231 | | jm_regs[0x008/2] = input_port_read(machine, "KEY4"); |
| 232 | | jm_regs[0x00a/2] = input_port_read(machine, "KEY5"); |
| 717 | jm_shared_ram[0x000/2] = input_port_read(machine, "KEY0"); |
| 718 | jm_shared_ram[0x002/2] = input_port_read(machine, "KEY1"); |
| 719 | jm_shared_ram[0x004/2] = input_port_read(machine, "KEY2"); |
| 720 | jm_shared_ram[0x006/2] = input_port_read(machine, "KEY3"); |
| 721 | jm_shared_ram[0x008/2] = input_port_read(machine, "KEY4"); |
| 722 | jm_shared_ram[0x00a/2] = input_port_read(machine, "KEY5"); |
| 233 | 723 | } |
| 234 | 724 | else |
| 235 | 725 | { |
| 236 | | jm_regs[0x000/2] = 0x0000; |
| 726 | jm_shared_ram[0x000/2] = 0x0000; |
| 237 | 727 | MCU_READ("KEY1", 0x0001, 0x000/2, 0x00); /*FF*/ |
| 238 | 728 | MCU_READ("KEY2", 0x0400, 0x000/2, 0x01); /*A*/ |
| 239 | 729 | MCU_READ("KEY2", 0x1000, 0x000/2, 0x02); /*B*/ |
| r3514 | r3515 | |
| 256 | 746 | MCU_READ("KEY1", 0x0002, 0x000/2, 0x13); /*CHI (trusted)*/ |
| 257 | 747 | MCU_READ("KEY0", 0x0004, 0x000/2, 0x14); /*START1*/ |
| 258 | 748 | } |
| 259 | | if(MJZOOMIN_MCU) |
| 260 | | jm_regs[0x00c/2] = mame_rand(machine) & 0xffff; |
| 749 | jm_shared_ram[0x00c/2] = mame_rand(machine) & 0xffff; |
| 261 | 750 | prg_prot++; |
| 262 | 751 | if(prg_prot > 0x10) { prg_prot = 0; } |
| 263 | | jm_regs[0x00e/2] = prg_prot; |
| 264 | | |
| 752 | jm_shared_ram[0x00e/2] = prg_prot; |
| 265 | 753 | } |
| 266 | 754 | |
| 267 | 755 | static void urashima_mcu_run(running_machine *machine) |
| r3514 | r3515 | |
| 270 | 758 | |
| 271 | 759 | if((0xffff - input_port_read(machine, "SYSTEM")) & 0x0008) //service_mode |
| 272 | 760 | { |
| 273 | | jm_regs[0x300/2] = input_port_read(machine, "KEY0"); |
| 274 | | jm_regs[0x302/2] = input_port_read(machine, "KEY1"); |
| 275 | | jm_regs[0x304/2] = input_port_read(machine, "KEY2"); |
| 276 | | jm_regs[0x306/2] = input_port_read(machine, "KEY3"); |
| 277 | | jm_regs[0x308/2] = input_port_read(machine, "KEY4"); |
| 278 | | jm_regs[0x30a/2] = input_port_read(machine, "KEY5"); |
| 761 | jm_shared_ram[0x300/2] = input_port_read(machine, "KEY0"); |
| 762 | jm_shared_ram[0x302/2] = input_port_read(machine, "KEY1"); |
| 763 | jm_shared_ram[0x304/2] = input_port_read(machine, "KEY2"); |
| 764 | jm_shared_ram[0x306/2] = input_port_read(machine, "KEY3"); |
| 765 | jm_shared_ram[0x308/2] = input_port_read(machine, "KEY4"); |
| 766 | jm_shared_ram[0x30a/2] = input_port_read(machine, "KEY5"); |
| 279 | 767 | } |
| 280 | 768 | else |
| 281 | 769 | { |
| 282 | | jm_regs[0x300/2] = 0x0000; |
| 770 | jm_shared_ram[0x300/2] = 0x0000; |
| 283 | 771 | MCU_READ("KEY1", 0x0001, 0x300/2, 0x00); /*FF*/ |
| 284 | 772 | MCU_READ("KEY2", 0x0400, 0x300/2, 0x01); /*A*/ |
| 285 | 773 | MCU_READ("KEY2", 0x1000, 0x300/2, 0x02); /*B*/ |
| r3514 | r3515 | |
| 302 | 790 | MCU_READ("KEY1", 0x0002, 0x300/2, 0x13); /*CHI (trusted)*/ |
| 303 | 791 | MCU_READ("KEY0", 0x0004, 0x300/2, 0x14); /*START1*/ |
| 304 | 792 | } |
| 305 | | jm_regs[0x30c/2] = mame_rand(machine) & 0xffff; |
| 793 | jm_shared_ram[0x30c/2] = mame_rand(machine) & 0xffff; |
| 306 | 794 | prg_prot++; |
| 307 | 795 | if(prg_prot > 0x10) { prg_prot = 0; } |
| 308 | | jm_regs[0x30e/2] = prg_prot; |
| 796 | jm_shared_ram[0x30e/2] = prg_prot; |
| 309 | 797 | } |
| 310 | 798 | |
| 311 | 799 | static void second_mcu_run(running_machine *machine) |
| 312 | 800 | { |
| 313 | 801 | if((0xffff - input_port_read(machine, "DSW")) & 0x0004) //service_mode |
| 314 | 802 | { |
| 315 | | jm_regs[0x200/2] = input_port_read(machine, "KEY0"); |
| 316 | | jm_regs[0x202/2] = input_port_read(machine, "KEY1"); |
| 317 | | jm_regs[0x204/2] = input_port_read(machine, "KEY2"); |
| 803 | jm_shared_ram[0x200/2] = input_port_read(machine, "KEY0"); |
| 804 | jm_shared_ram[0x202/2] = input_port_read(machine, "KEY1"); |
| 805 | jm_shared_ram[0x204/2] = input_port_read(machine, "KEY2"); |
| 318 | 806 | } |
| 319 | 807 | else |
| 320 | 808 | { |
| 321 | | jm_regs[0x200/2] = 0x0000; |
| 809 | jm_shared_ram[0x200/2] = 0x0000; |
| 322 | 810 | MCU_READ("KEY1", 0x0001, 0x200/2, 0x00); /*FF*/ |
| 323 | 811 | MCU_READ("KEY2", 0x0400, 0x200/2, 0x01); /*A*/ |
| 324 | 812 | MCU_READ("KEY2", 0x1000, 0x200/2, 0x02); /*B*/ |
| r3514 | r3515 | |
| 343 | 831 | |
| 344 | 832 | // MCU_READ("KEY0", 0x0004, 0x7b8/2, 0x03); /*START1(correct?) */ |
| 345 | 833 | } |
| 346 | | jm_regs[0x20c/2] = mame_rand(machine) & 0xffff; //kakumei2 |
| 834 | jm_shared_ram[0x20c/2] = mame_rand(machine) & 0xffff; //kakumei2 |
| 347 | 835 | |
| 348 | 836 | } |
| 349 | 837 | |
| 350 | | #define jalmah_tilemap_draw(_tilemap_) \ |
| 351 | | tilemap_draw(bitmap,cliprect,_tilemap_,(opaque & 1) ? 0 : TILEMAP_DRAW_OPAQUE,0); \ |
| 352 | | if(!opaque) { opaque = 1; } |
| 353 | | |
| 354 | | static VIDEO_UPDATE( jalmah ) |
| 838 | static TIMER_DEVICE_CALLBACK( jalmah_mcu_sim ) |
| 355 | 839 | { |
| 356 | | int opaque = 0; |
| 357 | | #ifdef MAME_DEBUG |
| 358 | | static UINT8 sc_db; |
| 359 | | #endif |
| 360 | | |
| 361 | | tilemap_set_scrollx( sc0_tilemap, 0, jm_scrollram[0] + ((jm_vregs[0] & 3) ? ((jm_scrollram[4] & 0x200) * 4) : 0)); |
| 362 | | tilemap_set_scrollx( sc1_tilemap, 0, jm_scrollram[1] + ((jm_vregs[1] & 3) ? ((jm_scrollram[5] & 0x200) * 4) : 0)); |
| 363 | | tilemap_set_scrollx( sc2_tilemap, 0, jm_scrollram[2] + ((jm_vregs[2] & 3) ? ((jm_scrollram[6] & 0x200) * 4) : 0)); |
| 364 | | tilemap_set_scrollx( sc3_tilemap, 0, jm_scrollram[3] + ((jm_vregs[3] & 3) ? ((jm_scrollram[7] & 0x200) * 4) : 0)); |
| 365 | | tilemap_set_scrolly( sc0_tilemap, 0, jm_scrollram[4] & 0x1ff); |
| 366 | | tilemap_set_scrolly( sc1_tilemap, 0, jm_scrollram[5] & 0x1ff); |
| 367 | | tilemap_set_scrolly( sc2_tilemap, 0, jm_scrollram[6] & 0x1ff); |
| 368 | | tilemap_set_scrolly( sc3_tilemap, 0, jm_scrollram[7] & 0x1ff); |
| 369 | | |
| 370 | | #ifdef MAME_DEBUG |
| 371 | | if(input_code_pressed_once(JOYCODE_Y_UP_SWITCH)) |
| 372 | | sc_db++; |
| 373 | | if(input_code_pressed_once(JOYCODE_Y_DOWN_SWITCH)) |
| 374 | | sc_db--; |
| 375 | | if(sc_db > 3) |
| 376 | | sc_db = 3; |
| 377 | | //popmessage("%04x %04x %04x %04x %04x %04x",jm_vregs[0],jm_vregs[1],jm_vregs[2],jm_vregs[3],sc0bank,pri); |
| 378 | | popmessage("%04d %04d %04x %02x %01x",jm_scrollram[0+sc_db],jm_scrollram[4+sc_db],jm_vregs[0+sc_db],sc_db,pri); |
| 379 | | #endif |
| 380 | | /* |
| 381 | | Case by case priorities: |
| 382 | | kakumei: title screen = 0/23 (0-1 unused) |
| 383 | | attract mode = 0/0123 (?) |
| 384 | | card table = 0/013 (2 unused) |
| 385 | | gameplay = 0/0123 |
| 386 | | kakumei2:title screen = 0/0123 |
| 387 | | attract mode = 4/013 (2 unused) also 4/0213 |
| 388 | | card table = 9/013 (2 unused) |
| 389 | | character screen = 9/013 (2 unused) |
| 390 | | gameplay = 2/03 (1-2 unused) also 2/013 (2 unused) |
| 391 | | continue screen = 9/013 (2 unused) |
| 392 | | suchipi: title screen = 0/03 (1-2 unused) |
| 393 | | attract mode = 6/103 (2 unused) also 6/1023 |
| 394 | | card table = 1/013 (2 unused) |
| 395 | | character screen = 4/0213 |
| 396 | | victory screen = 6/0123 also 6/1023 |
| 397 | | gameplay = d/0123 |
| 398 | | mjzoomin doesn't seem to use the priority number (0/0123) |
| 399 | | daireika/urashima uses priority number with the protection device |
| 400 | | daireika: gameplay = x/103 (2 unused),might be 6 |
| 401 | | good results: |
| 402 | | 0/0123 |
| 403 | | 4/0213 |
| 404 | | 6/1023 |
| 405 | | */ |
| 406 | | if(!(pri & 2) || (pri & 0x8)) { jalmah_tilemap_draw(sc0_tilemap); } |
| 407 | | if(!(pri & 4) || (pri & 0x8)) { jalmah_tilemap_draw(sc1_tilemap); } |
| 408 | | if(!(pri & 2) || (pri & 0x8)) { jalmah_tilemap_draw(sc2_tilemap); } |
| 409 | | if(pri & 4 && (!(pri & 0x8))) { jalmah_tilemap_draw(sc1_tilemap); } |
| 410 | | if(pri & 2 && (!(pri & 0x8))) { jalmah_tilemap_draw(sc0_tilemap); } |
| 411 | | if(pri & 2 && (!(pri & 0x8))) { jalmah_tilemap_draw(sc2_tilemap); } |
| 412 | | jalmah_tilemap_draw(sc3_tilemap); |
| 413 | | return 0; |
| 414 | | } |
| 415 | | |
| 416 | | VIDEO_UPDATE( urashima ) |
| 417 | | { |
| 418 | | int opaque = 0; |
| 419 | | |
| 420 | | /*this game doesn't use the RANGE register at all.*/ |
| 421 | | tilemap_set_scrollx( sc0_tilemap, 0, jm_scrollram[0]); |
| 422 | | tilemap_set_scrollx( sc3_tilemap, 0, jm_scrollram[3]); |
| 423 | | tilemap_set_scrolly( sc0_tilemap, 0, jm_scrollram[4] & 0x1ff); |
| 424 | | tilemap_set_scrolly( sc3_tilemap, 0, jm_scrollram[7] & 0x1ff); |
| 425 | | |
| 426 | | fillbitmap(bitmap, Machine->pens[0], cliprect); |
| 427 | | if(jm_vregs[0] & 1) { jalmah_tilemap_draw(sc0_tilemap); } |
| 428 | | if(jm_vregs[3] & 1) { jalmah_tilemap_draw(sc3_tilemap); } |
| 429 | | return 0; |
| 430 | | } |
| 431 | | |
| 432 | | static VIDEO_EOF( jalmah ) |
| 433 | | { |
| 434 | 840 | switch(mcu_prg) |
| 435 | 841 | { |
| 436 | 842 | /* |
| r3514 | r3515 | |
| 441 | 847 | #define KAKUMEI2_MCU (0x22) |
| 442 | 848 | #define SUCHIPI_MCU (0x23) |
| 443 | 849 | */ |
| 444 | | case MJZOOMIN_MCU: |
| 445 | | case DAIREIKA_MCU: daireika_mcu_run(machine); break; |
| 446 | | case URASHIMA_MCU: urashima_mcu_run(machine); break; |
| 850 | case MJZOOMIN_MCU: mjzoomin_mcu_run(timer->machine); break; |
| 851 | case DAIREIKA_MCU: daireika_mcu_run(timer->machine); break; |
| 852 | case URASHIMA_MCU: urashima_mcu_run(timer->machine); break; |
| 447 | 853 | case KAKUMEI_MCU: |
| 448 | 854 | case KAKUMEI2_MCU: |
| 449 | | case SUCHIPI_MCU: second_mcu_run(machine); break; |
| 855 | case SUCHIPI_MCU: second_mcu_run(timer->machine); break; |
| 450 | 856 | } |
| 451 | 857 | } |
| 452 | 858 | |
| 453 | | static WRITE16_HANDLER( sc0_vram_w ) |
| 454 | | { |
| 455 | | COMBINE_DATA(&sc0_vram[offset]); |
| 456 | | tilemap_mark_tile_dirty(sc0_tilemap,offset); |
| 457 | | } |
| 859 | /****************************************************************************************** |
| 458 | 860 | |
| 459 | | static WRITE16_HANDLER( sc1_vram_w ) |
| 460 | | { |
| 461 | | COMBINE_DATA(&sc1_vram[offset]); |
| 462 | | tilemap_mark_tile_dirty(sc1_tilemap,offset); |
| 463 | | } |
| 861 | Basic driver start |
| 464 | 862 | |
| 465 | | static WRITE16_HANDLER( sc3_vram_w ) |
| 466 | | { |
| 467 | | COMBINE_DATA(&sc3_vram[offset]); |
| 468 | | tilemap_mark_tile_dirty(sc3_tilemap,offset); |
| 469 | | } |
| 863 | ******************************************************************************************/ |
| 470 | 864 | |
| 471 | | static WRITE16_HANDLER( sc2_vram_w ) |
| 472 | | { |
| 473 | | COMBINE_DATA(&sc2_vram[offset]); |
| 474 | | tilemap_mark_tile_dirty(sc2_tilemap,offset); |
| 475 | | } |
| 865 | static UINT8 oki_rom,oki_bank,oki_za; |
| 476 | 866 | |
| 477 | | static WRITE16_HANDLER( jalmah_tilebank_w ) |
| 478 | | { |
| 479 | | /* |
| 480 | | xxxx ---- fg bank (used by suchipi) |
| 481 | | ---- xxxx Priority number (trusted,see mjzoomin) |
| 482 | | */ |
| 483 | | //popmessage("Write to tilebank %02x",data); |
| 484 | | if (ACCESSING_BITS_0_7) |
| 485 | | { |
| 486 | | if (sc0bank != ((data & 0xf0) >> 4)) |
| 487 | | { |
| 488 | | sc0bank = (data & 0xf0) >> 4; |
| 489 | | tilemap_mark_all_tiles_dirty(sc0_tilemap); |
| 490 | | } |
| 491 | | if (pri != (data & 0x0f)) |
| 492 | | pri = data & 0x0f; |
| 493 | | } |
| 494 | | } |
| 495 | | |
| 496 | | #ifdef UNUSED_FUNCTION |
| 497 | | static WRITE16_HANDLER( jalmah_reg_w ) |
| 498 | | { |
| 499 | | COMBINE_DATA(&jm_regs[offset]); |
| 500 | | } |
| 501 | | #endif |
| 502 | | |
| 503 | | static WRITE16_HANDLER( jalmah_scroll_w ) |
| 504 | | { |
| 505 | | logerror("[%04x]<-%04x\n",(offset+0x10)*2,data); |
| 506 | | switch(offset+(0x10)) |
| 507 | | { |
| 508 | | /*These 4 are just video regs,see mjzoomin test*/ |
| 509 | | /* |
| 510 | | ---x ---- Always on,8x8 tiles switch? |
| 511 | | ---- --xx RANGE registers |
| 512 | | */ |
| 513 | | case (0x24/2): jm_vregs[0] = data; break; |
| 514 | | case (0x2c/2): jm_vregs[1] = data; break; |
| 515 | | case (0x34/2): jm_vregs[2] = data; break; |
| 516 | | case (0x3c/2): jm_vregs[3] = data; break; |
| 517 | | |
| 518 | | case (0x20/2): jm_scrollram[0] = data; break; |
| 519 | | case (0x28/2): jm_scrollram[1] = data; break; |
| 520 | | case (0x30/2): jm_scrollram[2] = data; break; |
| 521 | | case (0x38/2): jm_scrollram[3] = data; break; |
| 522 | | case (0x22/2): jm_scrollram[4] = data; break; |
| 523 | | case (0x2a/2): jm_scrollram[5] = data; break; |
| 524 | | case (0x32/2): jm_scrollram[6] = data; break; |
| 525 | | case (0x3a/2): jm_scrollram[7] = data; break; |
| 526 | | //default: popmessage("[%04x]<-%04x",offset+0x10,data); |
| 527 | | } |
| 528 | | } |
| 529 | | |
| 530 | | /*Urashima Mahjong uses a bigger (and mostly unused/wasted) video register ram.*/ |
| 531 | | static WRITE16_HANDLER( urashima_sc0vregs_w ) |
| 532 | | { |
| 533 | | //logerror("[%04x]<-%04x\n",(offset+0x10)*2,data); |
| 534 | | switch(offset) |
| 535 | | { |
| 536 | | //case 0: break; |
| 537 | | /*---- ---x plane enable*/ |
| 538 | | case 1: jm_vregs[0] = data; break; /*plane enable*/ |
| 539 | | case 2: jm_scrollram[0] = data; break; |
| 540 | | case 3: break; |
| 541 | | } |
| 542 | | } |
| 543 | | |
| 544 | | static WRITE16_HANDLER( urashima_sc3vregs_w ) |
| 545 | | { |
| 546 | | //logerror("[%04x]<-%04x\n",(offset+0x10)*2,data); |
| 547 | | switch(offset) |
| 548 | | { |
| 549 | | /*---- ---x plane enable*/ |
| 550 | | //case 0: |
| 551 | | case 1: jm_vregs[3] = data; break; |
| 552 | | case 2: jm_scrollram[7] = data; break; |
| 553 | | case 3: jm_scrollram[3] = data; break; |
| 554 | | } |
| 555 | | } |
| 556 | | |
| 557 | | static UINT8 oki_rom,oki_bank; |
| 558 | | |
| 559 | 867 | static WRITE16_HANDLER( jalmah_okirom_w ) |
| 560 | 868 | { |
| 561 | 869 | if(ACCESSING_BITS_0_7) |
| 562 | 870 | { |
| 563 | 871 | UINT8 *oki = memory_region(machine, "oki"); |
| 564 | 872 | oki_rom = data & 1; |
| 565 | | memcpy(&oki[0x20000], &oki[(oki_rom * 0x80000) + (oki_bank * 0x20000) + 0x40000], 0x20000); |
| 873 | /*ZA appears to be related to the banking*/ |
| 874 | oki_za = (data & 2) ? 1 : 0; |
| 875 | memcpy(&oki[0x20000], &oki[(oki_rom * 0x80000) + ((oki_bank+oki_za) * 0x20000) + 0x40000], 0x20000); |
| 566 | 876 | } |
| 567 | | |
| 568 | | /*what "ZA" stands for? Used by Kakumei 2.*/ |
| 569 | | if(data & 2) |
| 570 | | mame_printf_debug("ZA = 2\n"); |
| 877 | //popmessage("PC=%06x %02x %02x %02x",activecpu_get_pc(),oki_rom,oki_za,oki_bank); |
| 571 | 878 | } |
| 572 | 879 | |
| 573 | 880 | static WRITE16_HANDLER( jalmah_okibank_w ) |
| r3514 | r3515 | |
| 576 | 883 | { |
| 577 | 884 | UINT8 *oki = memory_region(machine, "oki"); |
| 578 | 885 | oki_bank = data & 3; |
| 579 | | memcpy(&oki[0x20000], &oki[(oki_rom * 0x80000) + (oki_bank * 0x20000) + 0x40000], 0x20000); |
| 886 | memcpy(&oki[0x20000], &oki[(oki_rom * 0x80000) + ((oki_bank+oki_za) * 0x20000) + 0x40000], 0x20000); |
| 580 | 887 | } |
| 888 | //popmessage("PC=%06x %02x %02x %02x",activecpu_get_pc(),oki_rom,oki_za,oki_bank); |
| 581 | 889 | } |
| 582 | 890 | |
| 583 | 891 | static WRITE16_HANDLER( jalmah_flip_screen_w ) |
| r3514 | r3515 | |
| 588 | 896 | // popmessage("%04x",data); |
| 589 | 897 | } |
| 590 | 898 | |
| 591 | | /*Funky "DMA" / protection thing*/ |
| 592 | | /*---- -x-- "DMA" execute.*/ |
| 593 | | /*---- ---x used too very often,I don't have any clue of what it is,it might just be the source or the destination address.*/ |
| 594 | | WRITE16_HANDLER( urashima_dma_w ) |
| 595 | | { |
| 596 | | if(data & 4) |
| 597 | | { |
| 598 | | UINT32 i; |
| 599 | | for(i=0;i<0x200;i+=2) |
| 600 | | program_write_word(0x88200+i,program_read_word(0x88400+i)); |
| 601 | | } |
| 602 | | } |
| 603 | | |
| 604 | | WRITE16_HANDLER( urashima_bank_w ) |
| 605 | | { |
| 606 | | if (ACCESSING_BITS_0_7) |
| 607 | | { |
| 608 | | if (sc0bank != (data & 0x0f)) |
| 609 | | { |
| 610 | | sc0bank = (data & 0x0f); |
| 611 | | tilemap_mark_all_tiles_dirty(sc0_tilemap); |
| 612 | | } |
| 613 | | } |
| 614 | | } |
| 615 | | |
| 616 | 899 | static ADDRESS_MAP_START( jalmah, ADDRESS_SPACE_PROGRAM, 16 ) |
| 617 | 900 | AM_RANGE(0x000000, 0x07ffff) AM_ROM |
| 618 | 901 | AM_RANGE(0x080000, 0x080001) AM_READ_PORT("SYSTEM") |
| r3514 | r3515 | |
| 632 | 915 | AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(sc1_vram_w) AM_BASE(&sc1_vram) |
| 633 | 916 | AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(sc2_vram_w) AM_BASE(&sc2_vram) |
| 634 | 917 | AM_RANGE(0x09c000, 0x09ffff) AM_RAM_WRITE(sc3_vram_w) AM_BASE(&sc3_vram) |
| 635 | | AM_RANGE(0x0f0000, 0x0f0fff) AM_RAM AM_BASE(&jm_regs)/*shared with MCU*/ |
| 636 | | AM_RANGE(0x0f1000, 0x0fffff) AM_RAM AM_BASE(&jm_ram) |
| 918 | AM_RANGE(0x0f0000, 0x0f0fff) AM_RAM AM_BASE(&jm_shared_ram)/*shared with MCU*/ |
| 919 | AM_RANGE(0x0f1000, 0x0fffff) AM_RAM /*Work Ram*/ |
| 637 | 920 | AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&jm_mcu_code)/*extra RAM for MCU code prg (NOT ON REAL HW!!!)*/ |
| 638 | 921 | ADDRESS_MAP_END |
| 639 | 922 | |
| r3514 | r3515 | |
| 652 | 935 | AM_RANGE(0x080040, 0x080041) AM_READWRITE(okim6295_status_0_lsb_r, okim6295_data_0_lsb_w) |
| 653 | 936 | // 0x084000, 0x084001 ? |
| 654 | 937 | AM_RANGE(0x088000, 0x0887ff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE(&paletteram16) /* Palette RAM */ |
| 655 | | AM_RANGE(0x090000, 0x09bfff) AM_RAM_WRITE(sc0_vram_w) AM_BASE(&sc0_vram) |
| 656 | | // AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(sc0_vram_w) |
| 657 | | // AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(sc0_vram_w) |
| 658 | | // AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(sc1_vram_w) AM_BASE(&sc1_vram)/*unused*/ |
| 659 | | // AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(sc2_vram_w) AM_BASE(&sc2_vram)/*unused*/ |
| 938 | AM_RANGE(0x090000, 0x093fff) AM_RAM_WRITE(urashima_sc0_vram_w) AM_BASE(&sc0_vram) |
| 939 | AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(urashima_sc0_vram_w) |
| 940 | AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(urashima_sc0_vram_w) |
| 941 | // AM_RANGE(0x094000, 0x097fff) AM_RAM_WRITE(urashima_sc1_vram_w) AM_BASE(&sc1_vram)/*unused*/ |
| 942 | // AM_RANGE(0x098000, 0x09bfff) AM_RAM_WRITE(urashima_sc2_vram_w) AM_BASE(&sc2_vram)/*unused*/ |
| 660 | 943 | /*$9c000-$9cfff Video Registers*/ |
| 661 | | /**/AM_RANGE(0x09c080, 0x09c09f) AM_READ(SMH_RAM) AM_WRITE(urashima_sc0vregs_w) |
| 944 | /**/AM_RANGE(0x09c000, 0x09dfff) AM_WRITE(urashima_vregs_w) |
| 662 | 945 | /**///AM_RANGE(0x09c480, 0x09c49f) AM_READ(SMH_RAM) AM_WRITE(urashima_sc2vregs_w) |
| 663 | | /**/AM_RANGE(0x09c880, 0x09c89f) AM_READ(SMH_RAM) AM_WRITE(urashima_sc3vregs_w) |
| 664 | | AM_RANGE(0x09e000, 0x0a1fff) AM_RAM_WRITE(sc3_vram_w) AM_BASE(&sc3_vram) |
| 665 | | AM_RANGE(0x0f0000, 0x0f0fff) AM_RAM AM_BASE(&jm_regs)/*shared with MCU*/ |
| 666 | | AM_RANGE(0x0f1000, 0x0fffff) AM_RAM AM_BASE(&jm_ram) |
| 946 | AM_RANGE(0x09e000, 0x0a1fff) AM_RAM_WRITE(urashima_sc3_vram_w) AM_BASE(&sc3_vram) |
| 947 | AM_RANGE(0x0f0000, 0x0f0fff) AM_RAM AM_BASE(&jm_shared_ram)/*shared with MCU*/ |
| 948 | AM_RANGE(0x0f1000, 0x0fffff) AM_RAM /*Work Ram*/ |
| 667 | 949 | AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&jm_mcu_code)/*extra RAM for MCU code prg (NOT ON REAL HW!!!)*/ |
| 668 | 950 | ADDRESS_MAP_END |
| 669 | 951 | |
| r3514 | r3515 | |
| 928 | 1210 | /*different color offsets*/ |
| 929 | 1211 | static GFXDECODE_START( urashima ) |
| 930 | 1212 | GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0x000, 16 ) |
| 931 | | GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0x300, 16 ) |
| 932 | | GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 0x200, 16 ) |
| 1213 | GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0x100, 16 ) |
| 1214 | GFXDECODE_ENTRY( "gfx3", 0, tilelayout, 0x100, 16 ) |
| 933 | 1215 | GFXDECODE_ENTRY( "gfx4", 0, tilelayout, 0x100, 16 ) |
| 934 | 1216 | GFXDECODE_END |
| 935 | 1217 | |
| r3514 | r3515 | |
| 959 | 1241 | |
| 960 | 1242 | MDRV_VIDEO_START(jalmah) |
| 961 | 1243 | MDRV_VIDEO_UPDATE(jalmah) |
| 962 | | MDRV_VIDEO_EOF(jalmah) |
| 963 | 1244 | |
| 1245 | MDRV_TIMER_ADD_PERIODIC("mcusim", jalmah_mcu_sim, HZ(10000)) // not real, but for simulating the MCU |
| 1246 | |
| 964 | 1247 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 965 | | |
| 966 | 1248 | MDRV_SOUND_ADD("oki", OKIM6295, 4000000) |
| 967 | 1249 | MDRV_SOUND_CONFIG(okim6295_interface_pin7low) |
| 968 | 1250 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| r3514 | r3515 | |
| 994 | 1276 | ROM_LOAD16_BYTE( "um-1.15c", 0x00001, 0x20000, CRC(5f5c8f39) SHA1(cef663965c3112f87788d6a871e609c0b10ef9a2) ) |
| 995 | 1277 | ROM_RELOAD( 0x40001, 0x20000 ) |
| 996 | 1278 | |
| 1279 | ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */ |
| 1280 | ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP ) |
| 1281 | |
| 997 | 1282 | ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */ |
| 998 | | ROM_LOAD( "um-3.22c", 0x00000, 0x80000, CRC(9fd8c8fa) SHA1(0346f74c03a4daa7a84b64c9edf0e54297c82fd9) ) |
| 999 | | ROM_RELOAD( 0x40000, 0x80000 ) |
| 1283 | ROM_LOAD( "um-3.22c", 0x40000, 0x80000, CRC(9fd8c8fa) SHA1(0346f74c03a4daa7a84b64c9edf0e54297c82fd9) ) |
| 1284 | ROM_COPY( "oki" , 0x40000, 0x00000, 0x40000 ) |
| 1000 | 1285 | |
| 1001 | 1286 | ROM_REGION( 0x20000, "gfx1", ROMREGION_DISPOSE ) |
| 1002 | 1287 | ROM_LOAD( "um-5.22j", 0x000000, 0x020000, CRC(991776a2) SHA1(56740553d7d26aaeb9bec8557727030950bb01f7) ) /* 8x8 tiles */ |
| r3514 | r3515 | |
| 1039 | 1324 | ROM_LOAD16_BYTE( "mj2.bin", 0x00000, 0x20000, CRC(c54d2f9b) SHA1(d59fc5a9e5bbb96b3b6a43378f4f2215c368b671) ) |
| 1040 | 1325 | ROM_RELOAD( 0x40000, 0x20000 ) |
| 1041 | 1326 | |
| 1327 | ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */ |
| 1328 | ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP ) |
| 1329 | |
| 1042 | 1330 | ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */ |
| 1043 | | ROM_LOAD( "mj3.bin", 0x00000, 0x80000, CRC(65bb350c) SHA1(e77866f2d612a0973adc616717e7c89a37d6c48e) ) |
| 1044 | | ROM_RELOAD( 0x40000, 0x80000 ) |
| 1331 | ROM_LOAD( "mj3.bin", 0x40000, 0x80000, CRC(65bb350c) SHA1(e77866f2d612a0973adc616717e7c89a37d6c48e) ) |
| 1332 | ROM_COPY( "oki" , 0x40000, 0x00000, 0x40000 ) |
| 1045 | 1333 | |
| 1046 | 1334 | ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */ |
| 1047 | 1335 | ROM_LOAD( "mj14.bin", 0x00000, 0x10000, CRC(c84c5577) SHA1(6437368d3be39739d62158590ecd373aa070a9b2) ) |
| r3514 | r3515 | |
| 1051 | 1339 | ROM_LOAD( "mj10.bin", 0x00000, 0x80000, CRC(1f5509a5) SHA1(4dcdee0e159956cf73f5f85ce278479be2a9ca9f) ) |
| 1052 | 1340 | |
| 1053 | 1341 | ROM_REGION( 0x40000, "gfx3", 0 ) /* BG2 */ |
| 1054 | | ROM_LOAD( "mj11.bin", 0x00000, 0x20000, CRC(14867c51) SHA1(b282b5048a55c9ad72ceb0d23f010a0fee78704f) ) |
| 1055 | | ROM_COPY( "gfx4", 0x20000, 0x20000, 0x20000 )/*mj10.bin*/ |
| 1056 | | |
| 1057 | | ROM_REGION( 0x40000, "gfx2", 0 ) /* BG1 */ |
| 1058 | | ROM_COPY( "gfx3", 0x00000, 0x00000, 0x20000 )/*mj10.bin*/ |
| 1342 | // ROM_COPY( "gfx4", 0x20000, 0x20000, 0x20000 )/*mj10.bin*/ |
| 1343 | ROM_LOAD( "mj11.bin", 0x00000, 0x20000, CRC(14867c51) SHA1(b282b5048a55c9ad72ceb0d23f010a0fee78704f) ) |
| 1059 | 1344 | ROM_LOAD( "mj12.bin", 0x20000, 0x20000, CRC(236f809f) SHA1(9e15dd8a810a9d4f7f75f084d6bd277ea7d0e40a) ) |
| 1060 | 1345 | |
| 1346 | ROM_REGION( 0x10000, "gfx2", 0 ) /* BG1 */ |
| 1347 | ROM_COPY( "gfx1", 0x10000, 0x00000, 0x10000 )/*mj12.bin*/ |
| 1348 | |
| 1061 | 1349 | ROM_REGION( 0x220, "user1", 0 ) /* Proms */ |
| 1062 | 1350 | ROM_LOAD( "mj15.bpr", 0x000, 0x100, CRC(ebac41f9) SHA1(9d1629d977849663392cbf03a3ddf76665f88608) ) |
| 1063 | 1351 | ROM_LOAD( "mj16.bpr", 0x100, 0x100, CRC(8d5dc1f6) SHA1(9f723e7cd44f8c09ec30b04725644346484ec753) ) |
| r3514 | r3515 | |
| 1078 | 1366 | ROM_LOAD16_BYTE( "zoomin-2.bin", 0x00000, 0x20000, CRC(c7eb982c) SHA1(9006ded2aa1fef38bde114110d76b20747c32658) ) |
| 1079 | 1367 | ROM_RELOAD( 0x40000, 0x20000 ) |
| 1080 | 1368 | |
| 1369 | ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */ |
| 1370 | ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP ) |
| 1371 | |
| 1081 | 1372 | ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */ |
| 1082 | | ROM_LOAD( "zoomin-3.bin", 0x00000, 0x80000, CRC(07d7b8cd) SHA1(e05ce80ffb945b04f93f8c49d0c840b0bff6310b) ) |
| 1083 | | ROM_RELOAD( 0x40000, 0x80000 ) |
| 1373 | ROM_LOAD( "zoomin-3.bin", 0x40000, 0x80000, CRC(07d7b8cd) SHA1(e05ce80ffb945b04f93f8c49d0c840b0bff6310b) ) |
| 1374 | ROM_COPY( "oki" , 0x40000, 0x00000, 0x40000 ) |
| 1084 | 1375 | |
| 1085 | 1376 | ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */ |
| 1086 | 1377 | ROM_LOAD( "zoomin14.bin", 0x00000, 0x20000, CRC(4e32aa45) SHA1(450a3449ca8b4f0dfe8b62cceaee9366eaf3dc3d) ) |
| r3514 | r3515 | |
| 1115 | 1406 | ROM_LOAD16_BYTE( "mj-re-2.bin", 0x00000, 0x20000, CRC(37eff266) SHA1(1d9e88c0270daadfafff1f73eb617e77b1d199d6) ) |
| 1116 | 1407 | ROM_RELOAD( 0x40000, 0x20000 ) |
| 1117 | 1408 | |
| 1409 | ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */ |
| 1410 | ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP ) |
| 1411 | |
| 1118 | 1412 | ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */ |
| 1119 | 1413 | ROM_LOAD( "rom3.bin", 0x00000, 0x40000, CRC(c9b7a526) SHA1(edec57e66d4ff601c8fdef7b1405af84a3f3d883) ) |
| 1120 | 1414 | ROM_RELOAD( 0x40000, 0x40000 ) |
| r3514 | r3515 | |
| 1149 | 1443 | ROM_LOAD16_BYTE( "mj-8956.1", 0x00001, 0x40000, CRC(db4ce32f) SHA1(1ae13627b9922143f462b1c3bbed87374f6e1667) ) |
| 1150 | 1444 | ROM_LOAD16_BYTE( "mj-8956.2", 0x00000, 0x40000, CRC(0f942507) SHA1(7ec2fbeb9a34dfc80c4df3de8397388db13f5c7c) ) |
| 1151 | 1445 | |
| 1446 | ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */ |
| 1447 | ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP ) |
| 1448 | |
| 1152 | 1449 | ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */ |
| 1153 | | ROM_LOAD( "92000-01.3", 0x00000, 0x80000, CRC(4b0ed440) SHA1(11961d217a41f92b60d5083a5e346c245f7db620) ) |
| 1154 | | ROM_RELOAD( 0x40000, 0x80000 ) |
| 1450 | ROM_LOAD( "92000-01.3", 0x040000, 0x80000, CRC(4b0ed440) SHA1(11961d217a41f92b60d5083a5e346c245f7db620) ) |
| 1451 | ROM_COPY( "oki" , 0x040000, 0x00000, 0x40000 ) |
| 1155 | 1452 | |
| 1156 | 1453 | ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */ |
| 1157 | 1454 | ROM_LOAD( "mj-8956.14", 0x00000, 0x20000, CRC(2b2fe999) SHA1(d9d601e2c008791f5bff6e7b1340f754dd094201) ) |
| r3514 | r3515 | |
| 1161 | 1458 | |
| 1162 | 1459 | ROM_REGION( 0x40000, "gfx3", 0 ) /* BG2 */ |
| 1163 | 1460 | ROM_LOAD( "mj-8956.12", 0x00000, 0x20000, BAD_DUMP CRC(43f7853d) SHA1(54fb523b27e79aa295900c478f09cc080fea0adf) ) |
| 1164 | | /*0x20000-0x40000 used maybe above rom is bad? */ |
| 1461 | /*0x20000-0x40000 used,above rom is likely to be bad (half length) */ |
| 1462 | ROM_COPY( "gfx3", 0x00000, 0x20000, 0x08000 )/*mj-8956.12*/ |
| 1463 | ROM_COPY( "gfx3", 0x08000, 0x28000, 0x08000 )/*mj-8956.12*/ |
| 1464 | ROM_COPY( "gfx3", 0x10000, 0x30000, 0x08000 )/*mj-8956.12*/ |
| 1465 | ROM_COPY( "gfx3", 0x18000, 0x38000, 0x08000 )/*mj-8956.12*/ |
| 1165 | 1466 | |
| 1166 | 1467 | ROM_REGION( 0x80000, "gfx4", 0 ) /* BG3 */ |
| 1167 | 1468 | ROM_LOAD( "92000-02.10", 0x00000, 0x80000, CRC(338fa9b2) SHA1(05ba4b3c44249cf92be238bf53d6345dc49b0881) ) |
| r3514 | r3515 | |
| 1220 | 1521 | ROM_LOAD16_BYTE( "1.bin", 0x00001, 0x40000, CRC(e37cc745) SHA1(73b3314d27a0332068e0d2bbc08d7401e371da1b) ) |
| 1221 | 1522 | ROM_LOAD16_BYTE( "2.bin", 0x00000, 0x40000, CRC(42ecf88a) SHA1(7bb85470bc9f94c867646afeb91c4730599ea299) ) |
| 1222 | 1523 | |
| 1524 | ROM_REGION( 0x1000, "mcu", 0 ) /* M50747 MCU Code */ |
| 1525 | ROM_LOAD( "mcu", 0x0000, 0x1000, NO_DUMP ) |
| 1526 | |
| 1223 | 1527 | ROM_REGION( 0x140000, "oki", ROMREGION_ERASEFF ) /* Samples */ |
| 1224 | | ROM_LOAD( "3.bin", 0x00000, 0x80000, CRC(691b5387) SHA1(b8bc9f904eab7653566042b18d89276d537ba586) ) |
| 1225 | | ROM_RELOAD( 0x40000, 0x80000 ) |
| 1528 | ROM_LOAD( "3.bin", 0x40000, 0x80000, CRC(691b5387) SHA1(b8bc9f904eab7653566042b18d89276d537ba586) ) |
| 1226 | 1529 | ROM_LOAD( "4.bin", 0xc0000, 0x80000, CRC(3fe932a1) SHA1(9e768b901738ee9eba207a67c4fd19efb0035a68) ) |
| 1530 | ROM_COPY( "oki" , 0x40000, 0x00000, 0x40000 ) |
| 1227 | 1531 | |
| 1228 | 1532 | ROM_REGION( 0x20000, "gfx1", 0 ) /* BG0 */ |
| 1229 | 1533 | ROM_LOAD( "14.bin", 0x00000, 0x20000, CRC(e465a540) SHA1(10e19599ab90b0c0b6ef6ee41f16620bd1ba6800) ) |
| r3514 | r3515 | |
| 1250 | 1554 | |
| 1251 | 1555 | /****************************************************************************************** |
| 1252 | 1556 | |
| 1253 | | MCU simulations |
| 1557 | MCU code snippets |
| 1254 | 1558 | |
| 1255 | 1559 | ******************************************************************************************/ |
| 1256 | 1560 | |
| r3514 | r3515 | |
| 1271 | 1575 | res = resp[respcount++]; |
| 1272 | 1576 | if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0; |
| 1273 | 1577 | |
| 1274 | | logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res); |
| 1578 | // logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res); |
| 1275 | 1579 | |
| 1276 | 1580 | return res; |
| 1277 | 1581 | } |
| r3514 | r3515 | |
| 1283 | 1587 | { |
| 1284 | 1588 | if(ACCESSING_BITS_0_7 && data) |
| 1285 | 1589 | { |
| 1286 | | //jm_regs[0x30e/2] = ? |
| 1287 | | |
| 1288 | | //popmessage("%04x %02x",jm_regs[0x030e/2],data); |
| 1289 | | |
| 1290 | 1590 | /******************************************************* |
| 1291 | 1591 | 1st M68k code uploaded by the MCU (sound prg) |
| 1292 | 1592 | *******************************************************/ |
| 1293 | | jm_regs[0x0320/2] = 0x4ef9; |
| 1294 | | jm_regs[0x0322/2] = 0x0010; |
| 1295 | | jm_regs[0x0324/2] = 0x2000;//jmp $102000 |
| 1593 | jm_shared_ram[0x0320/2] = 0x4ef9; |
| 1594 | jm_shared_ram[0x0322/2] = 0x0010; |
| 1595 | jm_shared_ram[0x0324/2] = 0x2000;//jmp $102000 |
| 1296 | 1596 | |
| 1297 | 1597 | jm_mcu_code[0x2000/2] = 0x0040; |
| 1298 | 1598 | jm_mcu_code[0x2002/2] = 0x0080;//ori $80,D0 |
| r3514 | r3515 | |
| 1318 | 1618 | *******************************************************/ |
| 1319 | 1619 | /*similar to mjzoomin but with offset summed with 0x300?*/ |
| 1320 | 1620 | /*tx scrollx = $200*/ |
| 1321 | | jm_regs[0x03c6/2] = 0x6008;//bra $+10 |
| 1322 | | jm_regs[0x03d0/2] = 0x4ef9; |
| 1323 | | jm_regs[0x03d2/2] = 0x0010; |
| 1324 | | jm_regs[0x03d4/2] = 0x0000;//jmp $100000 |
| 1621 | jm_shared_ram[0x03c6/2] = 0x6008;//bra $+10 |
| 1622 | jm_shared_ram[0x03d0/2] = 0x4ef9; |
| 1623 | jm_shared_ram[0x03d2/2] = 0x0010; |
| 1624 | jm_shared_ram[0x03d4/2] = 0x0000;//jmp $100000 |
| 1325 | 1625 | jm_mcu_code[0x0000/2] = 0x4E71;//0x33fc;//CAREFUL!!! |
| 1326 | 1626 | jm_mcu_code[0x0002/2] = 0x4E71;//0x0400; |
| 1327 | 1627 | jm_mcu_code[0x0004/2] = 0x4E71;//0x0008; |
| r3514 | r3515 | |
| 1343 | 1643 | /******************************************************* |
| 1344 | 1644 | 2nd M68k code uploaded by the MCU (tile upload) |
| 1345 | 1645 | *******************************************************/ |
| 1346 | | jm_regs[0x03ca/2] = 0x4ef9; |
| 1347 | | jm_regs[0x03cc/2] = 0x0010; |
| 1348 | | jm_regs[0x03ce/2] = 0x0800;//jmp $100800 |
| 1646 | jm_shared_ram[0x03ca/2] = 0x4ef9; |
| 1647 | jm_shared_ram[0x03cc/2] = 0x0010; |
| 1648 | jm_shared_ram[0x03ce/2] = 0x0800;//jmp $100800 |
| 1349 | 1649 | jm_mcu_code[0x0800/2] = 0x32da; |
| 1350 | 1650 | jm_mcu_code[0x0802/2] = 0x51c8; |
| 1351 | 1651 | jm_mcu_code[0x0804/2] = 0xfffc; |
| r3514 | r3515 | |
| 1353 | 1653 | /******************************************************* |
| 1354 | 1654 | 3rd M68k code uploaded by the MCU (palette upload) |
| 1355 | 1655 | *******************************************************/ |
| 1356 | | jm_regs[0x03c0/2] = 0x4ef9; |
| 1357 | | jm_regs[0x03c2/2] = 0x0010; |
| 1358 | | jm_regs[0x03c4/2] = 0x1000;//jmp $101000 |
| 1656 | jm_shared_ram[0x03c0/2] = 0x4ef9; |
| 1657 | jm_shared_ram[0x03c2/2] = 0x0010; |
| 1658 | jm_shared_ram[0x03c4/2] = 0x1000;//jmp $101000 |
| 1359 | 1659 | |
| 1360 | 1660 | |
| 1361 | 1661 | jm_mcu_code[0x1000/2] = 0x4e71;//0x92fc; |
| r3514 | r3515 | |
| 1491 | 1791 | res = resp[respcount++]; |
| 1492 | 1792 | if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0; |
| 1493 | 1793 | |
| 1494 | | logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res); |
| 1794 | // logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res); |
| 1495 | 1795 | |
| 1496 | 1796 | return res; |
| 1497 | 1797 | } |
| r3514 | r3515 | |
| 1507 | 1807 | static UINT16 i; |
| 1508 | 1808 | if(ACCESSING_BITS_0_7 && data) |
| 1509 | 1809 | { |
| 1510 | | /*MCU program upload complete/upload kind*/ |
| 1511 | | //jm_regs[0x000e/2] = 0x0005; |
| 1512 | | |
| 1513 | 1810 | /******************************************************* |
| 1514 | 1811 | 1st M68k code uploaded by the MCU. |
| 1515 | 1812 | random number generator (guess) |
| 1516 | 1813 | *******************************************************/ |
| 1517 | | jm_regs[0x0140/2] = 0x4ef9; |
| 1518 | | jm_regs[0x0142/2] = 0x0010; |
| 1519 | | jm_regs[0x0144/2] = 0x0800; |
| 1814 | jm_shared_ram[0x0140/2] = 0x4ef9; |
| 1815 | jm_shared_ram[0x0142/2] = 0x0010; |
| 1816 | jm_shared_ram[0x0144/2] = 0x0800; |
| 1520 | 1817 | |
| 1521 | 1818 | /* |
| 1522 | 1819 | 33c5 0010 07fe move.w D5, $1007fe.l |
| 1523 | 1820 | 3A39 000F 000C move.w $f000c, D5 |
| 1524 | | da86 add.w D6,D5 |
| 1525 | | 0245 003f and.w $3f,D5 |
| 1821 | da86 add.w D6,D5 |
| 1822 | 0245 003f and.w $3f,D5 |
| 1526 | 1823 | 33C5 000F 000C move.w D5, $f000c.l |
| 1527 | 1824 | 3a39 0010 07fe move.w $1007fe, D5 |
| 1528 | | 4e75 rts |
| 1825 | 4e75 rts |
| 1529 | 1826 | */ |
| 1530 | 1827 | for(i=0;i<0x11;i++) |
| 1531 | 1828 | jm_mcu_code[(0x0800/2)+i] = dai_mcu_code[i]; |
| r3514 | r3515 | |
| 1533 | 1830 | /******************************************************* |
| 1534 | 1831 | 2nd M68k code uploaded by the MCU. |
| 1535 | 1832 | *******************************************************/ |
| 1536 | | jm_regs[0x0020/2] = 0x4ef9; |
| 1537 | | jm_regs[0x0022/2] = 0x0010; |
| 1538 | | jm_regs[0x0024/2] = 0x2000;//jmp $102000 |
| 1833 | jm_shared_ram[0x0020/2] = 0x4ef9; |
| 1834 | jm_shared_ram[0x0022/2] = 0x0010; |
| 1835 | jm_shared_ram[0x0024/2] = 0x2000;//jmp $102000 |
| 1539 | 1836 | jm_mcu_code[0x2000/2] = 0x0040; |
| 1540 | 1837 | jm_mcu_code[0x2002/2] = 0x0080;//ori $80,D0 |
| 1541 | 1838 | jm_mcu_code[0x2004/2] = 0x33c0; |
| r3514 | r3515 | |
| 1559 | 1856 | 3rd M68k code uploaded by the MCU. |
| 1560 | 1857 | see mjzoomin_mcu_w |
| 1561 | 1858 | *******************************************************/ |
| 1562 | | jm_regs[0x00c6/2] = 0x6000; |
| 1563 | | jm_regs[0x00c8/2] = 0x0008;//bra +$8,needed because we have only two bytes here |
| 1859 | jm_shared_ram[0x00c6/2] = 0x6000; |
| 1860 | jm_shared_ram[0x00c8/2] = 0x0008;//bra +$8,needed because we have only two bytes here |
| 1564 | 1861 | //and we need three... |
| 1565 | | jm_regs[0x00d0/2] = 0x4ef9; |
| 1566 | | jm_regs[0x00d2/2] = 0x0010; |
| 1567 | | jm_regs[0x00d4/2] = 0x0000;//jmp $100000 |
| 1568 | | //jm_regs[0x00cc/2] = 0x4e75;//rts //needed? we can use jmp instead of jsr... |
| 1862 | jm_shared_ram[0x00d0/2] = 0x4ef9; |
| 1863 | jm_shared_ram[0x00d2/2] = 0x0010; |
| 1864 | jm_shared_ram[0x00d4/2] = 0x0000;//jmp $100000 |
| 1865 | //jm_shared_ram[0x00cc/2] = 0x4e75;//rts //needed? we can use jmp instead of jsr... |
| 1569 | 1866 | jm_mcu_code[0x0000/2] = 0x2050;//movea.l (A0),A0 |
| 1570 | 1867 | jm_mcu_code[0x0002/2] = 0x32d8;//move.w (A0)+,(A1)+ |
| 1571 | 1868 | jm_mcu_code[0x0004/2] = 0x51c9; |
| r3514 | r3515 | |
| 1576 | 1873 | They seem video code cleaning functions |
| 1577 | 1874 | *******************************************************/ |
| 1578 | 1875 | //108800 |
| 1579 | | jm_regs[0x0100/2] = 0x4ef9; |
| 1580 | | jm_regs[0x0102/2] = 0x0010; |
| 1581 | | jm_regs[0x0104/2] = 0x8800; |
| 1876 | jm_shared_ram[0x0100/2] = 0x4ef9; |
| 1877 | jm_shared_ram[0x0102/2] = 0x0010; |
| 1878 | jm_shared_ram[0x0104/2] = 0x8800; |
| 1582 | 1879 | |
| 1583 | 1880 | jm_mcu_code[0x8800/2] = 0x4df9; |
| 1584 | 1881 | jm_mcu_code[0x8802/2] = 0x0009; |
| r3514 | r3515 | |
| 1599 | 1896 | jm_mcu_code[0x8820/2] = 0x4e75; //rts |
| 1600 | 1897 | |
| 1601 | 1898 | //108880 |
| 1602 | | jm_regs[0x0108/2] = 0x4ef9; |
| 1603 | | jm_regs[0x010a/2] = 0x0010; |
| 1604 | | jm_regs[0x010c/2] = 0x8880; |
| 1899 | jm_shared_ram[0x0108/2] = 0x4ef9; |
| 1900 | jm_shared_ram[0x010a/2] = 0x0010; |
| 1901 | jm_shared_ram[0x010c/2] = 0x8880; |
| 1605 | 1902 | |
| 1606 | 1903 | jm_mcu_code[0x8880/2] = 0x4df9; |
| 1607 | 1904 | jm_mcu_code[0x8882/2] = 0x0009; |
| r3514 | r3515 | |
| 1622 | 1919 | jm_mcu_code[0x88a0/2] = 0x4e75; //rts |
| 1623 | 1920 | |
| 1624 | 1921 | //108900 |
| 1625 | | jm_regs[0x0110/2] = 0x4ef9; |
| 1626 | | jm_regs[0x0112/2] = 0x0010; |
| 1627 | | jm_regs[0x0114/2] = 0x8900; |
| 1922 | jm_shared_ram[0x0110/2] = 0x4ef9; |
| 1923 | jm_shared_ram[0x0112/2] = 0x0010; |
| 1924 | jm_shared_ram[0x0114/2] = 0x8900; |
| 1628 | 1925 | |
| 1629 | 1926 | jm_mcu_code[0x8900/2] = 0x4df9; |
| 1630 | 1927 | jm_mcu_code[0x8902/2] = 0x0009; |
| r3514 | r3515 | |
| 1645 | 1942 | jm_mcu_code[0x8920/2] = 0x4e75; //rts |
| 1646 | 1943 | |
| 1647 | 1944 | /*TX function?*/ |
| 1648 | | jm_regs[0x0126/2] = 0x4ef9; |
| 1649 | | jm_regs[0x0128/2] = 0x0010; |
| 1650 | | jm_regs[0x012a/2] = 0x8980; |
| 1945 | jm_shared_ram[0x0126/2] = 0x4ef9; |
| 1946 | jm_shared_ram[0x0128/2] = 0x0010; |
| 1947 | jm_shared_ram[0x012a/2] = 0x8980; |
| 1651 | 1948 | |
| 1652 | 1949 | //pri $f0590 |
| 1653 | 1950 | jm_mcu_code[0x8980/2] = 0x33fc; |
| r3514 | r3515 | |
| 1673 | 1970 | jm_mcu_code[0x89a8/2] = 0x4e75; //rts |
| 1674 | 1971 | |
| 1675 | 1972 | /* |
| 1676 | | jm_regs[0x0100/2] = 0x4ef9; |
| 1677 | | jm_regs[0x0102/2] = 0x0010; |
| 1678 | | jm_regs[0x0104/2] = 0x1000;//jmp $101000 |
| 1679 | | //jm_regs[0x00c6/2] = 0x4e75;//rts |
| 1973 | jm_shared_ram[0x0100/2] = 0x4ef9; |
| 1974 | jm_shared_ram[0x0102/2] = 0x0010; |
| 1975 | jm_shared_ram[0x0104/2] = 0x1000;//jmp $101000 |
| 1976 | //jm_shared_ram[0x00c6/2] = 0x4e75;//rts |
| 1680 | 1977 | jm_mcu_code[0x1000/2] = 0x33c2; |
| 1681 | 1978 | jm_mcu_code[0x1002/2] = 0x0010; |
| 1682 | 1979 | jm_mcu_code[0x1004/2] = 0x17fe; //move.w D2,$1017fe |
| r3514 | r3515 | |
| 1699 | 1996 | /******************************************************* |
| 1700 | 1997 | 5th M68k code uploaded by the MCU (palette upload) |
| 1701 | 1998 | *******************************************************/ |
| 1702 | | jm_regs[0x00c0/2] = 0x4ef9; |
| 1703 | | jm_regs[0x00c2/2] = 0x0010; |
| 1704 | | jm_regs[0x00c4/2] = 0x1000;//jmp $101000 |
| 1705 | | //jm_regs[0x00c6/2] = 0x4e75;//rts |
| 1999 | jm_shared_ram[0x00c0/2] = 0x4ef9; |
| 2000 | jm_shared_ram[0x00c2/2] = 0x0010; |
| 2001 | jm_shared_ram[0x00c4/2] = 0x1000;//jmp $101000 |
| 2002 | //jm_shared_ram[0x00c6/2] = 0x4e75;//rts |
| 1706 | 2003 | jm_mcu_code[0x1000/2] = 0x33c2; |
| 1707 | 2004 | jm_mcu_code[0x1002/2] = 0x0010; |
| 1708 | 2005 | jm_mcu_code[0x1004/2] = 0x17fe; //move.w D2,$1017fe |
| r3514 | r3515 | |
| 1735 | 2032 | /******************************************************* |
| 1736 | 2033 | 6th M68k code uploaded by the MCU (tile upload) |
| 1737 | 2034 | *******************************************************/ |
| 1738 | | jm_regs[0x00ca/2] = 0x4ef9; |
| 1739 | | jm_regs[0x00cc/2] = 0x0010; |
| 1740 | | jm_regs[0x00ce/2] = 0x1800;//jmp $101800 |
| 1741 | | //jm_regs[0x00c6/2] = 0x4e75;//rts |
| 2035 | jm_shared_ram[0x00ca/2] = 0x4ef9; |
| 2036 | jm_shared_ram[0x00cc/2] = 0x0010; |
| 2037 | jm_shared_ram[0x00ce/2] = 0x1800;//jmp $101800 |
| 2038 | //jm_shared_ram[0x00c6/2] = 0x4e75;//rts |
| 1742 | 2039 | |
| 1743 | 2040 | jm_mcu_code[0x1800/2] = 0x22da;//move.l (A2)+,(A1)+ |
| 1744 | 2041 | jm_mcu_code[0x1802/2] = 0xb5fc; |
| r3514 | r3515 | |
| 1770 | 2067 | res = resp[respcount++]; |
| 1771 | 2068 | if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0; |
| 1772 | 2069 | |
| 1773 | | logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res); |
| 2070 | // logerror("%04x: mcu_r %02x\n",activecpu_get_pc(),res); |
| 1774 | 2071 | |
| 1775 | 2072 | return res; |
| 1776 | 2073 | } |
| 1777 | 2074 | |
| 1778 | | /*4eb9*/ |
| 1779 | 2075 | /* |
| 1780 | 2076 | data value is REQ under mjzoomin video test menu.It is related to the MCU? |
| 1781 | 2077 | */ |
| r3514 | r3515 | |
| 1783 | 2079 | { |
| 1784 | 2080 | if(ACCESSING_BITS_0_7 && data) |
| 1785 | 2081 | { |
| 1786 | | /******************************************************* |
| 2082 | /****************************************************** |
| 1787 | 2083 | 1st M68k code uploaded by the MCU(Service Mode PC=2a56). |
| 1788 | | Program passes some parameters before entering into the sub-routine (jsr) |
| 2084 | Program passes some parameters before entering into |
| 2085 | the sub-routine (jsr) |
| 1789 | 2086 | D1 = 0xf |
| 1790 | 2087 | A0 = 1026e |
| 1791 | 2088 | A1 = 88600 |
| 1792 | | (A0) is the vector number for take the real palette address. |
| 1793 | | *******************************************************/ |
| 1794 | | jm_regs[0x00c6/2] = 0x4ef9; |
| 1795 | | jm_regs[0x00c8/2] = 0x0010; |
| 1796 | | jm_regs[0x00ca/2] = 0x0000;//jsr $100000 |
| 1797 | | //jm_regs[0x00cc/2] = 0x4e75;//rts //needed? we can use jmp instead of jsr... |
| 2089 | (A0) is the vector number for take the real palette |
| 2090 | address. |
| 2091 | ******************************************************/ |
| 2092 | jm_shared_ram[0x00c6/2] = 0x4ef9; |
| 2093 | jm_shared_ram[0x00c8/2] = 0x0010; |
| 2094 | jm_shared_ram[0x00ca/2] = 0x0000;//jsr $100000 |
| 2095 | //jm_shared_ram[0x00cc/2] = 0x4e75;//rts //needed? we can use jmp instead of jsr... |
| 1798 | 2096 | jm_mcu_code[0x0000/2] = 0x2050;//movea.l (A0),A0 |
| 1799 | 2097 | jm_mcu_code[0x0002/2] = 0x32d8;//move.w (A0)+,(A1)+ |
| 1800 | 2098 | jm_mcu_code[0x0004/2] = 0x51c9; |
| r3514 | r3515 | |
| 1804 | 2102 | 2nd M68k code uploaded by the MCU (Sound read/write) |
| 1805 | 2103 | (Note:copied from suchipi,check here the sound banking) |
| 1806 | 2104 | *******************************************************/ |
| 1807 | | jm_regs[0x0020/2] = 0x4ef9; |
| 1808 | | jm_regs[0x0022/2] = 0x0010; |
| 1809 | | jm_regs[0x0024/2] = 0x1800;//jmp $101800 |
| 1810 | | jm_mcu_code[0x1800/2] = 0x0040; |
| 1811 | | jm_mcu_code[0x1802/2] = 0x0080;//ori $80,D0 |
| 1812 | | jm_mcu_code[0x1804/2] = 0x33c0; |
| 1813 | | jm_mcu_code[0x1806/2] = 0x0008; |
| 1814 | | jm_mcu_code[0x1808/2] = 0x0040; |
| 1815 | | jm_mcu_code[0x180a/2] = 0x4e71;//= 0x6100; |
| 1816 | | jm_mcu_code[0x180c/2] = 0x4e71;//= 0x000c; |
| 1817 | | jm_mcu_code[0x180e/2] = 0x33fc; |
| 1818 | | jm_mcu_code[0x1810/2] = 0x0010; |
| 1819 | | jm_mcu_code[0x1812/2] = 0x0008; |
| 2105 | jm_shared_ram[0x0020/2] = 0x4ef9; |
| 2106 | jm_shared_ram[0x0022/2] = 0x0010; |
| 2107 | jm_shared_ram[0x0024/2] = 0x1800;//jmp $101800 |
| 2108 | |
| 2109 | /*Wrong,it reads from the rom...*/ |
| 2110 | //0x33c2 0011 80fe move.w D2,$1180fe |
| 2111 | //0x0642 addi.w $1,D2 |
| 2112 | //0x0001 |
| 2113 | //0x0242 andi.w $3,D2 ;might be not needed |
| 2114 | //0x0003 |
| 2115 | |
| 2116 | //0x33c2 move.w D2,$80018 ;sound bank |
| 2117 | //0x0008 |
| 2118 | //0x0018 |
| 2119 | //0x3439 0011 80fe move.w $1180fe,D2 |
| 2120 | jm_mcu_code[0x1800/2] = 0x33c2; |
| 2121 | jm_mcu_code[0x1802/2] = 0x0011; |
| 2122 | jm_mcu_code[0x1804/2] = 0x80fe; |
| 2123 | jm_mcu_code[0x1806/2] = 0x0642; |
| 2124 | jm_mcu_code[0x1808/2] = 0x0001; |
| 2125 | jm_mcu_code[0x180a/2] = 0x0242; |
| 2126 | jm_mcu_code[0x180c/2] = 0x0003; |
| 2127 | jm_mcu_code[0x180e/2] = 0x33c2; |
| 2128 | jm_mcu_code[0x1810/2] = 0x0008; |
| 2129 | jm_mcu_code[0x1812/2] = 0x0018; |
| 1820 | 2130 | jm_mcu_code[0x1814/2] = 0x0040; |
| 1821 | | jm_mcu_code[0x1816/2] = 0x4e75; |
| 1822 | | jm_mcu_code[0x1818/2] = 0x3239; |
| 2131 | jm_mcu_code[0x1816/2] = 0x0080;//ori $80,D0 |
| 2132 | jm_mcu_code[0x1818/2] = 0x33c0;//move.w D0,$80040 |
| 1823 | 2133 | jm_mcu_code[0x181a/2] = 0x0008; |
| 1824 | 2134 | jm_mcu_code[0x181c/2] = 0x0040; |
| 1825 | | jm_mcu_code[0x181e/2] = 0x0241; |
| 1826 | | jm_mcu_code[0x1820/2] = 0x0001; |
| 1827 | | jm_mcu_code[0x1822/2] = 0x66f4; |
| 1828 | | jm_mcu_code[0x1824/2] = 0x4e75; |
| 2135 | jm_mcu_code[0x181e/2] = 0x33fc;//move.w $10,$80040 |
| 2136 | jm_mcu_code[0x1820/2] = 0x0010; |
| 2137 | jm_mcu_code[0x1822/2] = 0x0008; |
| 2138 | jm_mcu_code[0x1824/2] = 0x0040; |
| 2139 | jm_mcu_code[0x1826/2] = 0x3439; |
| 2140 | jm_mcu_code[0x1828/2] = 0x0011; |
| 2141 | jm_mcu_code[0x182a/2] = 0x80fe; |
| 2142 | jm_mcu_code[0x182c/2] = 0x4e75; |
| 2143 | //jm_mcu_code[0x1818/2] = 0x3239; |
| 2144 | //jm_mcu_code[0x181a/2] = 0x0008; |
| 2145 | //jm_mcu_code[0x181c/2] = 0x0040; |
| 2146 | //jm_mcu_code[0x181e/2] = 0x0241; |
| 2147 | //jm_mcu_code[0x1820/2] = 0x0001; |
| 2148 | //jm_mcu_code[0x1822/2] = 0x66f4; |
| 2149 | //jm_mcu_code[0x1824/2] = 0x4e75; |
| 1829 | 2150 | /******************************************************* |
| 1830 | | 3rd M68k code uploaded by the MCU(palette upload, 99,(9)% |
| 1831 | | sure on this ;-) |
| 2151 | 3rd M68k code uploaded by the MCU(palette upload) |
| 1832 | 2152 | *******************************************************/ |
| 1833 | | jm_regs[0x00c0/2] = 0x4ef9; |
| 1834 | | jm_regs[0x00c2/2] = 0x0010; |
| 1835 | | jm_regs[0x00c4/2] = 0x1000;//jmp $101000 |
| 1836 | | //jm_regs[0x00c6/2] = 0x4e75;//rts |
| 2153 | jm_shared_ram[0x00c0/2] = 0x4ef9; |
| 2154 | jm_shared_ram[0x00c2/2] = 0x0010; |
| 2155 | jm_shared_ram[0x00c4/2] = 0x1000;//jmp $101000 |
| 2156 | //jm_shared_ram[0x00c6/2] = 0x4e75;//rts |
| 1837 | 2157 | jm_mcu_code[0x1000/2] = 0x33c2; |
| 1838 | 2158 | jm_mcu_code[0x1002/2] = 0x0010; |
| 1839 | 2159 | jm_mcu_code[0x1004/2] = 0x17fe; //move.w D2,$1017fe |
| r3514 | r3515 | |
| 1882 | 2202 | res = resp[respcount++]; |
| 1883 | 2203 | if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0; |
| 1884 | 2204 | |
| 1885 | | //popmessage("%04x: mcu_r %02x",activecpu_get_pc(),res); |
| 2205 | // popmessage("%04x: mcu_r %02x",activecpu_get_pc(),res); |
| 1886 | 2206 | |
| 1887 | 2207 | return res; |
| 1888 | 2208 | } |
| r3514 | r3515 | |
| 1903 | 2223 | res = resp[respcount++]; |
| 1904 | 2224 | if (respcount >= sizeof(resp)/sizeof(resp[0])) respcount = 0; |
| 1905 | 2225 | |
| 1906 | | //popmessage("%04x: mcu_r %02x",activecpu_get_pc(),res); |
| 2226 | // popmessage("%04x: mcu_r %02x",activecpu_get_pc(),res); |
| 1907 | 2227 | |
| 1908 | 2228 | return res; |
| 1909 | 2229 | } |
| r3514 | r3515 | |
| 1953 | 2273 | } |
| 1954 | 2274 | |
| 1955 | 2275 | /*First version of the MCU*/ |
| 1956 | | GAME( 1989, urashima, 0, urashima, jalmah, urashima, ROT0, "UPL", "Otogizoushi Urashima Mahjong", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 1957 | | GAME( 1989, daireika, 0, jalmah, jalmah, daireika, ROT0, "Jaleco / NMK", "Mahjong Daireikai", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 1958 | | GAME( 1990, mjzoomin, 0, jalmah, jalmah, mjzoomin, ROT0, "Jaleco", "Mahjong Channel Zoom In", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 2276 | GAME( 1989, urashima, 0, urashima, jalmah, urashima, ROT0, "UPL", "Otogizoushi Urashima Mahjong", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 2277 | GAME( 1989, daireika, 0, jalmah, jalmah, daireika, ROT0, "Jaleco / NMK", "Mahjong Daireikai", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 2278 | GAME( 1990, mjzoomin, 0, jalmah, jalmah, mjzoomin, ROT0, "Jaleco", "Mahjong Channel Zoom In", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 1959 | 2279 | /*Second version of the MCU*/ |
| 1960 | | GAME( 1990, kakumei, 0, jalmah, jalmah2, kakumei, ROT0, "Jaleco", "Mahjong Kakumei", GAME_IMPERFECT_GRAPHICS ) |
| 1961 | | GAME( 1992, kakumei2, 0, jalmah, jalmah2a,kakumei2, ROT0, "Jaleco", "Mahjong Kakumei 2 - Princess League", GAME_IMPERFECT_GRAPHICS ) |
| 1962 | | GAME( 1993, suchipi, 0, jalmah, jalmah2a,suchipi, ROT0, "Jaleco", "Idol Janshi Su-Chi-Pie Special", GAME_IMPERFECT_GRAPHICS ) |
| 2280 | GAME( 1990, kakumei, 0, jalmah, jalmah2, kakumei, ROT0, "Jaleco", "Mahjong Kakumei", GAME_IMPERFECT_GRAPHICS ) |
| 2281 | GAME( 1992, kakumei2, 0, jalmah, jalmah2a, kakumei2, ROT0, "Jaleco", "Mahjong Kakumei 2 - Princess League", GAME_IMPERFECT_GRAPHICS ) |
| 2282 | GAME( 1993, suchipi, 0, jalmah, jalmah2a, suchipi, ROT0, "Jaleco", "Idol Janshi Su-Chi-Pie Special", GAME_IMPERFECT_GRAPHICS ) |
src/mame/drivers/re900.c
| r0 | r3515 | |
| 1 | /*********************************************************************************** |
| 2 | |
| 3 | re900.c |
| 4 | |
| 5 | Ruleta RE-900 - Entretenimientos GEMINIS & GENATRON (C) 1993 |
| 6 | |
| 7 | Driver by Grull Osgo. |
| 8 | Additional work by Roberto Fresca. |
| 9 | |
| 10 | Games running on this hardware: |
| 11 | |
| 12 | * Ruleta RE-900, 1993, Entretenimientos GEMINIS. |
| 13 | * Buena Suerte '94 1994, Entretenimientos GEMINIS. |
| 14 | |
| 15 | |
| 16 | ************************************************************************************ |
| 17 | |
| 18 | Hardware Info |
| 19 | ============= |
| 20 | |
| 21 | * Main board: |
| 22 | |
| 23 | 1x AMD P80C31BH Main CPU. |
| 24 | 1x AY-3-8910 Sound & I/O System. |
| 25 | 1x TMS-9129-NL Video System. |
| 26 | |
| 27 | 1x 27C512 EPROM Program ROM. |
| 28 | 1x MS6264L-10PC (8Kx8) SRAM Data Memory (Battery Backed RAM). |
| 29 | 2x TMS4416-15NL (64Kx4) DRAM Video Memory. |
| 30 | |
| 31 | 1x 11.0592 MHz Crystal CPU clock. |
| 32 | 1x 10.738635 MHz. Crystal Video System clock. |
| 33 | 1x MAX691CPE Power supervisor system, Data RAM Protect and Watchdog. |
| 34 | |
| 35 | 1x 3.6 Ni-Cd Battery Data Memory. |
| 36 | 1x LM380N-8 1 Channel Audio Amplifier. |
| 37 | |
| 38 | |
| 39 | ************************************************************************************ |
| 40 | |
| 41 | Game Info |
| 42 | ========= |
| 43 | |
| 44 | * RE-900 Electronic Roulette.- 6 Players - W/ Random Bonus Multiplier (up to 10x) |
| 45 | |
| 46 | How to play... |
| 47 | |
| 48 | This Roulette allow up to 6 players. To start the machine, turn the Operator Key |
| 49 | (the the Operator Key light will turn green). Whilest this key is turned ON, you |
| 50 | can insert credits, play, and payout. Once the key is turned OFF (red light), you |
| 51 | can play, but credits can't be entered/taken. |
| 52 | |
| 53 | You can select the player number through key "L" (the respective player light will |
| 54 | lite on). Key-In for all 6 players are keys 1-2-3-4-5-6 and Key-Out are Q-W-E-R-T-Y |
| 55 | respectively. Up-Down-Left-Right to place cursor, and left CTRL to place a bet. |
| 56 | After a short time without activity, the roulette start to play, simulating the ball |
| 57 | with an array of leds... |
| 58 | |
| 59 | We made a full artwork that allow you to play this game with bells and whistles. |
| 60 | |
| 61 | |
| 62 | * Buena Suerte ?94 Video Poker Game w/ Double Up feature - 1 Player. |
| 63 | |
| 64 | This game is a reprogrammed version of the Buena Suerte! poker game, to run on this |
| 65 | GEMINIS RE900 hardware. |
| 66 | |
| 67 | Graphics are worse than original BS, but sounds are improved through the AY-8910. |
| 68 | |
| 69 | |
| 70 | ***********************************************************************************/ |
| 71 | |
| 72 | |
| 73 | #define MAIN_CLOCK XTAL_11_0592MHz |
| 74 | #define VDP_CLOCK XTAL_10_730MHz |
| 75 | #define TMS_CLOCK VDP_CLOCK / 24 |
| 76 | |
| 77 | #include "driver.h" |
| 78 | #include "cpu/mcs51/mcs51.h" |
| 79 | #include "video/tms9928a.h" |
| 80 | #include "sound/ay8910.h" |
| 81 | #include "re900.lh" |
| 82 | |
| 83 | static UINT8 *re900_rom; |
| 84 | static UINT8 psg_pa, psg_pb = 0, mux_data = 0, ledant = 0, player = 1, stat_a= 1; |
| 85 | |
| 86 | |
| 87 | /**************** |
| 88 | * Read Handlers * |
| 89 | ****************/ |
| 90 | |
| 91 | static READ8_HANDLER (re_psg_portA_r) |
| 92 | { |
| 93 | if ((input_port_read(machine, "IN0") & 0x01) == 0) |
| 94 | { |
| 95 | output_set_lamp_value(0,1); // Operator Key ON |
| 96 | } |
| 97 | |
| 98 | else |
| 99 | { |
| 100 | output_set_lamp_value(0,0); // Operator Key OFF |
| 101 | } |
| 102 | |
| 103 | return input_port_read(machine, "IN0"); |
| 104 | } |
| 105 | |
| 106 | static READ8_HANDLER (re_psg_portB_r) |
| 107 | { |
| 108 | UINT8 retval = 0xff; |
| 109 | logerror("llamada a re_psg_portB_r\n"); |
| 110 | /* This is a hack to select the active player due to Keyboard size restrictions */ |
| 111 | |
| 112 | output_set_lamp_value(player,1); |
| 113 | |
| 114 | if (input_port_read(machine, "IN_S")) |
| 115 | { |
| 116 | if (!stat_a) |
| 117 | { |
| 118 | output_set_lamp_value(1, 0); |
| 119 | output_set_lamp_value(2, 0); |
| 120 | output_set_lamp_value(3, 0); |
| 121 | output_set_lamp_value(4, 0); |
| 122 | output_set_lamp_value(5, 0); |
| 123 | output_set_lamp_value(6, 0); |
| 124 | player++; |
| 125 | |
| 126 | if (player == 7) |
| 127 | { |
| 128 | player = 1; |
| 129 | } |
| 130 | |
| 131 | output_set_lamp_value(player, 1); /* It shows active player via layout buttons */ |
| 132 | stat_a = 1; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | else |
| 137 | { |
| 138 | stat_a = 0; |
| 139 | } |
| 140 | /* End of Select Player Hack */ |
| 141 | |
| 142 | /* "INA": Unified port to share the player Keys among all players - Key In & Key Out have their own buttons on keyboard. */ |
| 143 | switch( mux_data ) |
| 144 | { |
| 145 | case 0x01: retval = (input_port_read(machine, "IN6") | 0x80 ) - (( player == 6 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 6 */ |
| 146 | case 0x02: retval = (input_port_read(machine, "IN5") | 0x80 ) - (( player == 5 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 5 */ |
| 147 | case 0x04: retval = (input_port_read(machine, "IN4") | 0x80 ) - (( player == 4 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 4 */ |
| 148 | case 0x08: retval = (input_port_read(machine, "IN3") | 0x80 ) - (( player == 3 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 3 */ |
| 149 | case 0x10: retval = (input_port_read(machine, "IN2") | 0x80 ) - (( player == 2 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 2 */ |
| 150 | case 0x20: retval = (input_port_read(machine, "IN1") | 0x80 ) - (( player == 1 ) ? (input_port_read(machine, "INA") | 0x80 ) ^ 0xff: 0x00 ); break; /* Player 1 */ |
| 151 | } |
| 152 | |
| 153 | return retval; |
| 154 | } |
| 155 | |
| 156 | static READ8_HANDLER (bs94_portA_r) |
| 157 | { |
| 158 | return input_port_read(machine, "IN0"); |
| 159 | } |
| 160 | |
| 161 | static READ8_HANDLER (bs94_portB_r) |
| 162 | { |
| 163 | return input_port_read(machine, "IN1"); |
| 164 | } |
| 165 | |
| 166 | static READ8_HANDLER (rom_r) |
| 167 | { |
| 168 | return re900_rom[offset]; |
| 169 | } |
| 170 | |
| 171 | |
| 172 | /*********************** |
| 173 | * Write Handlers * |
| 174 | ***********************/ |
| 175 | |
| 176 | static WRITE8_HANDLER (re_mux_port_A_w) |
| 177 | { |
| 178 | psg_pa = data; |
| 179 | mux_data = ((data >> 2) & 0x3f) ^ 0x3f; |
| 180 | } |
| 181 | |
| 182 | static WRITE8_HANDLER (re_mux_port_B_w) |
| 183 | { |
| 184 | UINT8 led; |
| 185 | psg_pb = data; |
| 186 | led = (psg_pa >> 2) & 0x3f; |
| 187 | |
| 188 | if (data == 0x7f) |
| 189 | { |
| 190 | output_set_lamp_value(20 + led, 1); |
| 191 | |
| 192 | if (led != ledant) |
| 193 | { |
| 194 | output_set_lamp_value(20 + ledant, 0); |
| 195 | ledant = led; |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | static WRITE8_HANDLER (cpu_port_0_w) |
| 201 | { |
| 202 | // output_set_lamp_value(7,1 ^ ( (data >> 4) & 1)); /* Cont. Sal */ |
| 203 | // output_set_lamp_value(8,1 ^ ( (data >> 5) & 1)); /* Cont. Ent */ |
| 204 | } |
| 205 | |
| 206 | static WRITE8_HANDLER(re900_watchdog_reset_w) |
| 207 | { |
| 208 | //watchdog_reset_w(machine,0,0); /* To do! */ |
| 209 | } |
| 210 | |
| 211 | |
| 212 | /******************************* |
| 213 | * Memory Map Information * |
| 214 | *******************************/ |
| 215 | |
| 216 | static ADDRESS_MAP_START( mem_prg, ADDRESS_SPACE_PROGRAM, 8 ) |
| 217 | AM_RANGE(0x0000, 0xffff) AM_ROM AM_BASE(&re900_rom) |
| 218 | ADDRESS_MAP_END |
| 219 | |
| 220 | static ADDRESS_MAP_START( mem_io, ADDRESS_SPACE_IO, 8 ) |
| 221 | AM_RANGE(0x0000, 0xbfff) AM_READ (rom_r) |
| 222 | AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) |
| 223 | AM_RANGE(0xe000, 0xe000) AM_WRITE(TMS9928A_vram_w) |
| 224 | AM_RANGE(0xe001, 0xe001) AM_WRITE(TMS9928A_register_w) |
| 225 | AM_RANGE(0xe800, 0xe800) AM_WRITE(ay8910_control_port_0_w) |
| 226 | AM_RANGE(0xe801, 0xe801) AM_WRITE(ay8910_write_port_0_w) |
| 227 | AM_RANGE(0xe802, 0xe802) AM_READ(ay8910_read_port_0_r) |
| 228 | AM_RANGE(0xe000, 0xefff) AM_WRITE(re900_watchdog_reset_w) |
| 229 | AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P0) AM_WRITE(cpu_port_0_w) |
| 230 | AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_NOP |
| 231 | AM_RANGE(MCS51_PORT_P3, MCS51_PORT_P3) AM_NOP |
| 232 | ADDRESS_MAP_END |
| 233 | |
| 234 | |
| 235 | static INTERRUPT_GEN( re900_video_interrupt ) |
| 236 | { |
| 237 | TMS9928A_interrupt(machine); |
| 238 | } |
| 239 | |
| 240 | static void vdp_interrupt (running_machine *machine, int state) |
| 241 | { |
| 242 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE ); |
| 243 | } |
| 244 | |
| 245 | |
| 246 | /************************ |
| 247 | * Input ports * |
| 248 | ************************/ |
| 249 | |
| 250 | INPUT_PORTS_START( re900 ) |
| 251 | |
| 252 | PORT_START("IN0") |
| 253 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Operator Key") PORT_TOGGLE PORT_CODE(KEYCODE_0) |
| 254 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Auditor Key") PORT_TOGGLE PORT_CODE(KEYCODE_9) |
| 255 | |
| 256 | PORT_START("INA") |
| 257 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Bet") |
| 258 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT) |
| 259 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT) |
| 260 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Up") PORT_CODE(KEYCODE_UP) |
| 261 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN) |
| 262 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 263 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 264 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 265 | |
| 266 | PORT_START("IN1") |
| 267 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 268 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 269 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 270 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 271 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 272 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P1 Key-In") PORT_CODE(KEYCODE_1) |
| 273 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P1 Key-Out") PORT_CODE(KEYCODE_Q) |
| 274 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 275 | |
| 276 | PORT_START("IN2") |
| 277 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 278 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 279 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 280 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 281 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 282 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P2 Key-In") PORT_CODE(KEYCODE_2) |
| 283 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P2 Key-Out") PORT_CODE(KEYCODE_W) |
| 284 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 285 | |
| 286 | PORT_START("IN3") |
| 287 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 288 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 289 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 290 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 291 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 292 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P3 Key-In") PORT_CODE(KEYCODE_3) |
| 293 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P3 Key-Out") PORT_CODE(KEYCODE_E) |
| 294 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 295 | |
| 296 | PORT_START("IN4") |
| 297 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 298 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 299 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 300 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 301 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 302 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P4 Key-In") PORT_CODE(KEYCODE_4) |
| 303 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P4 Key-Out") PORT_CODE(KEYCODE_R) |
| 304 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 305 | |
| 306 | PORT_START("IN5") |
| 307 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 308 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 309 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 310 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 311 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 312 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P5 Key-In") PORT_CODE(KEYCODE_5) |
| 313 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P5 Key-Out") PORT_CODE(KEYCODE_T) |
| 314 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 315 | |
| 316 | PORT_START("IN6") |
| 317 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 318 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 319 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 320 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 321 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 322 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P6 Key-In") PORT_CODE(KEYCODE_6) |
| 323 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("P6 Key-Out") PORT_CODE(KEYCODE_Y) |
| 324 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 325 | |
| 326 | PORT_START("IN_S") |
| 327 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("Player Select") PORT_CODE(KEYCODE_L) |
| 328 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 329 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 330 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 331 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 332 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 333 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 334 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 335 | INPUT_PORTS_END |
| 336 | |
| 337 | INPUT_PORTS_START( bs94 ) |
| 338 | PORT_START("IN0") |
| 339 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Bet") PORT_CODE(KEYCODE_2) |
| 340 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Double") PORT_CODE(KEYCODE_3) |
| 341 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Deal/Draw") PORT_CODE(KEYCODE_1) |
| 342 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 5") PORT_CODE(KEYCODE_B) |
| 343 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Take") PORT_CODE(KEYCODE_4) |
| 344 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Hold 4") PORT_CODE(KEYCODE_V) |
| 345 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Cancel") PORT_CODE(KEYCODE_N) |
| 346 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Hold 3") PORT_CODE(KEYCODE_C) |
| 347 | |
| 348 | PORT_START("IN1") |
| 349 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Operator") PORT_TOGGLE PORT_CODE(KEYCODE_0) |
| 350 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Hold 2") PORT_CODE(KEYCODE_X) |
| 351 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Card High") PORT_CODE(KEYCODE_A) |
| 352 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Hold 1") PORT_CODE(KEYCODE_Z) |
| 353 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_NAME("Card Low") PORT_CODE(KEYCODE_S) |
| 354 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Key In") PORT_CODE(KEYCODE_5) |
| 355 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON7 ) PORT_NAME("Key Out") PORT_CODE(KEYCODE_8) |
| 356 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON8 ) PORT_NAME("Auditor") PORT_CODE(KEYCODE_9) |
| 357 | INPUT_PORTS_END |
| 358 | |
| 359 | |
| 360 | /*************************** |
| 361 | * TMS9928a Interfase * |
| 362 | ***************************/ |
| 363 | |
| 364 | static const TMS9928a_interface tms9928a_interface = |
| 365 | { |
| 366 | TMS99x8A, /* TMS9128NL on pcb */ |
| 367 | 0x4000, |
| 368 | 0, 0, |
| 369 | vdp_interrupt |
| 370 | }; |
| 371 | |
| 372 | |
| 373 | /************************* |
| 374 | * AY8910 Interfase * |
| 375 | *************************/ |
| 376 | |
| 377 | static const ay8910_interface ay8910_re900 = |
| 378 | { |
| 379 | AY8910_LEGACY_OUTPUT, |
| 380 | AY8910_DEFAULT_LOADS, |
| 381 | re_psg_portA_r, |
| 382 | re_psg_portB_r, |
| 383 | re_mux_port_A_w, |
| 384 | re_mux_port_B_w |
| 385 | }; |
| 386 | |
| 387 | static const ay8910_interface ay8910_bs94 = |
| 388 | { |
| 389 | AY8910_LEGACY_OUTPUT, |
| 390 | AY8910_DEFAULT_LOADS, |
| 391 | bs94_portA_r, |
| 392 | bs94_portB_r, |
| 393 | 0, |
| 394 | 0 |
| 395 | }; |
| 396 | |
| 397 | /*************************** |
| 398 | * Machine Driver * |
| 399 | ***************************/ |
| 400 | |
| 401 | static MACHINE_DRIVER_START( re900 ) |
| 402 | |
| 403 | /* basic machine hardware */ |
| 404 | MDRV_CPU_ADD("main", I8051, MAIN_CLOCK) |
| 405 | MDRV_CPU_PROGRAM_MAP(mem_prg, 0) |
| 406 | MDRV_CPU_IO_MAP(mem_io, 0) |
| 407 | MDRV_CPU_VBLANK_INT("main", re900_video_interrupt) |
| 408 | |
| 409 | /* video hardware */ |
| 410 | MDRV_IMPORT_FROM(tms9928a) |
| 411 | MDRV_SCREEN_MODIFY("main") |
| 412 | MDRV_SCREEN_REFRESH_RATE(60) |
| 413 | |
| 414 | MDRV_NVRAM_HANDLER(generic_0fill) |
| 415 | |
| 416 | /* sound hardware */ |
| 417 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 418 | MDRV_SOUND_ADD("ay_re900", AY8910, TMS_CLOCK) /* From TMS9128NL - Pin 37 (GROMCLK) */ |
| 419 | MDRV_SOUND_CONFIG(ay8910_re900) |
| 420 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) |
| 421 | MACHINE_DRIVER_END |
| 422 | |
| 423 | static MACHINE_DRIVER_START( bs94 ) |
| 424 | |
| 425 | MDRV_IMPORT_FROM(re900) |
| 426 | |
| 427 | /* sound hardware */ |
| 428 | MDRV_SOUND_MODIFY("ay_re900") |
| 429 | MDRV_SOUND_CONFIG(ay8910_bs94) |
| 430 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.5) |
| 431 | MACHINE_DRIVER_END |
| 432 | |
| 433 | |
| 434 | /************************* |
| 435 | * Rom Load * |
| 436 | *************************/ |
| 437 | |
| 438 | ROM_START( re900 ) |
| 439 | ROM_REGION( 0x10000, "main", 0 ) |
| 440 | ROM_LOAD( "re900.bin", 0x0000, 0x10000, CRC(967ae944) SHA1(104bab79fd50a8e38ae15058dbe47a59f1ec4b05) ) |
| 441 | ROM_END |
| 442 | |
| 443 | ROM_START( bs94 ) |
| 444 | ROM_REGION( 0x10000, "main", 0 ) |
| 445 | ROM_LOAD( "bs94.bin", 0x0000, 0x10000, CRC(bbd484ce) SHA1(4128e488ca806842c3639e05c4c9cf4c0da2990d) ) |
| 446 | ROM_END |
| 447 | |
| 448 | |
| 449 | /************************ |
| 450 | * Driver Init * |
| 451 | ************************/ |
| 452 | |
| 453 | static DRIVER_INIT( re900 ) |
| 454 | { |
| 455 | TMS9928A_configure(&tms9928a_interface); |
| 456 | player = 1; |
| 457 | stat_a = 1; |
| 458 | } |
| 459 | |
| 460 | |
| 461 | /************************* |
| 462 | * Game Drivers * |
| 463 | *************************/ |
| 464 | |
| 465 | /* YEAR NAME PARENT MACHINE INPUT INIT ROT COMPANY FULLNAME FLAGS LAYOUT */ |
| 466 | GAMEL( 1993, re900, 0, re900, re900, re900, ROT90, "Entretenimientos GEMINIS", "Ruleta RE-900", 0, layout_re900) |
| 467 | GAME ( 1994, bs94 , 0, bs94, bs94 , re900, ROT0, "Entretenimientos GEMINIS", "Buena Suerte '94", 0) |
src/mame/drivers/acommand.c
| r3514 | r3515 | |
| 4 | 4 | |
| 5 | 5 | driver by Angelo Salese |
| 6 | 6 | |
| 7 | | seems like a particular version of the NMK16 board. |
| 7 | Similar (same?) to the Cisco Heat board type. |
| 8 | 8 | |
| 9 | 9 | TODO: |
| 10 | | -Understand what "devices" area needs to make this working... |
| 10 | -Understand what "devices" area needs to make this working.It's likely that the upper switches |
| 11 | controls the UFO's and the lower switches the astronauts. |
| 12 | -Back tilemap paging is likely to be incorrect. |
| 13 | -3D Artworks for the UFO's,Astronauts etc. |
| 14 | -Merge to the Cisco Heat driver. |
| 11 | 15 | |
| 12 | | -Complete sound |
| 16 | Notes: |
| 17 | -The real HW is a redemption machine with two guns,similar to the "Cosmo Gang the Video" |
| 18 | (Namco) bonus games. |
| 13 | 19 | |
| 14 | | -Back tilemap paging is likely to be incorrect... |
| 15 | | |
| 16 | | |
| 17 | 20 | m68k irq table vectors |
| 18 | 21 | lev 1 : 0x64 : 0000 04f0 - rte |
| 19 | 22 | lev 2 : 0x68 : 0000 044a - vblank |
| r3514 | r3515 | |
| 157 | 160 | } |
| 158 | 161 | |
| 159 | 162 | |
| 160 | | /*copied from drivers/gticlub.c,to be completed*/ |
| 161 | 163 | #define LED_ON 0x01c00 |
| 162 | | #define SHOW_LEDS 0 |
| 164 | #define LED_OFF 0x00000 |
| 165 | /* |
| 166 | a |
| 167 | --- |
| 168 | f | | b |
| 169 | -g- |
| 170 | e | | c |
| 171 | --- |
| 172 | d |
| 173 | a & 1 |
| 174 | b & 2 |
| 175 | c & 4 |
| 176 | d & 8 |
| 177 | e & 10 |
| 178 | f & 20 |
| 179 | g & 40 |
| 180 | 7f |
| 181 | */ |
| 182 | /* 0 1 2 3 4 5 6 7 8 9 a b c d e f*/ |
| 183 | static const UINT8 led_fill[0x10] = { 0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x00,0x00,0x00,0x00,0x00}; |
| 163 | 184 | |
| 164 | | #if SHOW_LEDS |
| 165 | 185 | static void draw_led(bitmap_t *bitmap, int x, int y,UINT8 value) |
| 166 | 186 | { |
| 167 | | plot_box(bitmap, x, y, 5, 9, 0x00000000); |
| 187 | plot_box(bitmap, x, y, 6, 10, 0x00000000); |
| 168 | 188 | |
| 169 | | /* Top */ |
| 170 | | if( (value & 0x40) == 0 ) { |
| 171 | | *BITMAP_ADDR16(bitmap, y+0, x+1) = LED_ON; |
| 172 | | *BITMAP_ADDR16(bitmap, y+0, x+2) = LED_ON; |
| 173 | | *BITMAP_ADDR16(bitmap, y+0, x+3) = LED_ON; |
| 174 | | } |
| 175 | | /* Middle */ |
| 176 | | if( (value & 0x01) == 0 ) { |
| 177 | | *BITMAP_ADDR16(bitmap, y+4, x+1) = LED_ON; |
| 178 | | *BITMAP_ADDR16(bitmap, y+4, x+2) = LED_ON; |
| 179 | | *BITMAP_ADDR16(bitmap, y+4, x+3) = LED_ON; |
| 180 | | } |
| 181 | | /* Bottom */ |
| 182 | | if( (value & 0x08) == 0 ) { |
| 183 | | *BITMAP_ADDR16(bitmap, y+8, x+1) = LED_ON; |
| 184 | | *BITMAP_ADDR16(bitmap, y+8, x+2) = LED_ON; |
| 185 | | *BITMAP_ADDR16(bitmap, y+8, x+3) = LED_ON; |
| 186 | | } |
| 187 | | /* Top Left */ |
| 188 | | if( (value & 0x02) == 0 ) { |
| 189 | | *BITMAP_ADDR16(bitmap, y+1, x+0) = LED_ON; |
| 190 | | *BITMAP_ADDR16(bitmap, y+2, x+0) = LED_ON; |
| 191 | | *BITMAP_ADDR16(bitmap, y+3, x+0) = LED_ON; |
| 192 | | } |
| 193 | | /* Top Right */ |
| 194 | | if( (value & 0x20) == 0 ) { |
| 195 | | *BITMAP_ADDR16(bitmap, y+1, x+4) = LED_ON; |
| 196 | | *BITMAP_ADDR16(bitmap, y+2, x+4) = LED_ON; |
| 197 | | *BITMAP_ADDR16(bitmap, y+3, x+4) = LED_ON; |
| 198 | | } |
| 199 | | /* Bottom Left */ |
| 200 | | if( (value & 0x04) == 0 ) { |
| 201 | | *BITMAP_ADDR16(bitmap, y+5, x+0) = LED_ON; |
| 202 | | *BITMAP_ADDR16(bitmap, y+6, x+0) = LED_ON; |
| 203 | | *BITMAP_ADDR16(bitmap, y+7, x+0) = LED_ON; |
| 204 | | } |
| 205 | | /* Bottom Right */ |
| 206 | | if( (value & 0x10) == 0 ) { |
| 207 | | *BITMAP_ADDR16(bitmap, y+5, x+4) = LED_ON; |
| 208 | | *BITMAP_ADDR16(bitmap, y+6, x+4) = LED_ON; |
| 209 | | *BITMAP_ADDR16(bitmap, y+7, x+4) = LED_ON; |
| 210 | | } |
| 189 | /*a*/ |
| 190 | *BITMAP_ADDR16(bitmap, y+0, x+1) = ((led_fill[value] & 0x0001) ? LED_ON : LED_OFF); |
| 191 | *BITMAP_ADDR16(bitmap, y+0, x+2) = ((led_fill[value] & 0x0001) ? LED_ON : LED_OFF); |
| 192 | *BITMAP_ADDR16(bitmap, y+0, x+3) = ((led_fill[value] & 0x0001) ? LED_ON : LED_OFF); |
| 193 | /*b*/ |
| 194 | *BITMAP_ADDR16(bitmap, y+1, x+4) = ((led_fill[value] & 0x0002) ? LED_ON : LED_OFF); |
| 195 | *BITMAP_ADDR16(bitmap, y+2, x+4) = ((led_fill[value] & 0x0002) ? LED_ON : LED_OFF); |
| 196 | *BITMAP_ADDR16(bitmap, y+3, x+4) = ((led_fill[value] & 0x0002) ? LED_ON : LED_OFF); |
| 197 | /*c*/ |
| 198 | *BITMAP_ADDR16(bitmap, y+5, x+4) = ((led_fill[value] & 0x0004) ? LED_ON : LED_OFF); |
| 199 | *BITMAP_ADDR16(bitmap, y+6, x+4) = ((led_fill[value] & 0x0004) ? LED_ON : LED_OFF); |
| 200 | *BITMAP_ADDR16(bitmap, y+7, x+4) = ((led_fill[value] & 0x0004) ? LED_ON : LED_OFF); |
| 201 | /*d*/ |
| 202 | *BITMAP_ADDR16(bitmap, y+8, x+1) = ((led_fill[value] & 0x0008) ? LED_ON : LED_OFF); |
| 203 | *BITMAP_ADDR16(bitmap, y+8, x+2) = ((led_fill[value] & 0x0008) ? LED_ON : LED_OFF); |
| 204 | *BITMAP_ADDR16(bitmap, y+8, x+3) = ((led_fill[value] & 0x0008) ? LED_ON : LED_OFF); |
| 205 | /*e*/ |
| 206 | *BITMAP_ADDR16(bitmap, y+5, x+0) = ((led_fill[value] & 0x0010) ? LED_ON : LED_OFF); |
| 207 | *BITMAP_ADDR16(bitmap, y+6, x+0) = ((led_fill[value] & 0x0010) ? LED_ON : LED_OFF); |
| 208 | *BITMAP_ADDR16(bitmap, y+7, x+0) = ((led_fill[value] & 0x0010) ? LED_ON : LED_OFF); |
| 209 | /*f*/ |
| 210 | *BITMAP_ADDR16(bitmap, y+1, x+0) = ((led_fill[value] & 0x0020) ? LED_ON : LED_OFF); |
| 211 | *BITMAP_ADDR16(bitmap, y+2, x+0) = ((led_fill[value] & 0x0020) ? LED_ON : LED_OFF); |
| 212 | *BITMAP_ADDR16(bitmap, y+3, x+0) = ((led_fill[value] & 0x0020) ? LED_ON : LED_OFF); |
| 213 | /*g*/ |
| 214 | *BITMAP_ADDR16(bitmap, y+4, x+1) = ((led_fill[value] & 0x0040) ? LED_ON : LED_OFF); |
| 215 | *BITMAP_ADDR16(bitmap, y+4, x+2) = ((led_fill[value] & 0x0040) ? LED_ON : LED_OFF); |
| 216 | *BITMAP_ADDR16(bitmap, y+4, x+3) = ((led_fill[value] & 0x0040) ? LED_ON : LED_OFF); |
| 211 | 217 | } |
| 212 | | #endif |
| 213 | | static UINT16 led0; |
| 214 | 218 | |
| 219 | static UINT16 led0,led1; |
| 220 | |
| 215 | 221 | static VIDEO_UPDATE( acommand ) |
| 216 | 222 | { |
| 217 | 223 | tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); |
| 218 | 224 | draw_sprites(screen->machine,bitmap,cliprect,0,0); |
| 219 | 225 | tilemap_draw(bitmap,cliprect,tx_tilemap,0,0); |
| 220 | 226 | |
| 221 | | #if SHOW_LEDS |
| 222 | | draw_led(bitmap, 3, 53, (led0 & 0xff00) >> 8); |
| 223 | | popmessage("%04x",led0); |
| 224 | | #endif |
| 227 | /*Order might be wrong,but these for sure are the led numbers tested*/ |
| 228 | draw_led(bitmap, 0, 20, (led0 & 0x0f00) >> 8); |
| 229 | draw_led(bitmap, 6, 20, (led0 & 0x00f0) >> 4); |
| 230 | draw_led(bitmap, 12, 20, (led0 & 0x000f)); |
| 231 | |
| 232 | draw_led(bitmap, 256-18,20,(led0 & 0xf000) >> 12); |
| 233 | draw_led(bitmap, 256-12,20,(led1 & 0xf0) >> 4); |
| 234 | draw_led(bitmap, 256-6,20, (led1 & 0xf)); |
| 225 | 235 | return 0; |
| 226 | 236 | } |
| 227 | 237 | |
| r3514 | r3515 | |
| 262 | 272 | |
| 263 | 273 | static UINT16 *ac_devram; |
| 264 | 274 | |
| 265 | | |
| 266 | 275 | static READ16_HANDLER(ac_devices_r) |
| 267 | 276 | { |
| 268 | | // popmessage("(PC=%06x) read at %04x",activecpu_get_pc(),offset*2); |
| 277 | logerror("(PC=%06x) read at %04x\n",activecpu_get_pc(),offset*2); |
| 278 | |
| 269 | 279 | switch(offset) |
| 270 | 280 | { |
| 271 | 281 | case 0x0008/2: |
| r3514 | r3515 | |
| 283 | 293 | */ |
| 284 | 294 | return input_port_read(machine, "IN0"); |
| 285 | 295 | case 0x0014/2: |
| 286 | | /* |
| 287 | | write 0x40,read (~0x08) |
| 288 | | write 0x08,read (~0x01) |
| 289 | | |
| 290 | | ---- ---- ---- ---x Boss Door - limit switch |
| 291 | | */ |
| 292 | | return (ac_devram[offset]); |
| 293 | 296 | case 0x0016/2: |
| 294 | 297 | return okim6295_status_0_r(machine,0); |
| 295 | 298 | case 0x0018/2: |
| 296 | | /* |
| 297 | | ---- ---- ---- x--- Astronaut - switch |
| 298 | | */ |
| 299 | | return ac_devram[offset]; |
| 300 | 299 | case 0x001a/2: |
| 301 | 300 | return okim6295_status_1_r(machine,0); |
| 302 | 301 | case 0x0040/2: |
| 303 | 302 | /* |
| 304 | | x-x- x-x- x-x- xx-- (ACTIVE HIGH?) [eori #$aaac, D0] |
| 303 | "Upper switch / Under Switch" |
| 304 | xx-x ---- xx-x xx-x |
| 305 | -x-- ---- ---- ---- Catch Switch - 3 |
| 306 | --x- ---- ---- ---- Lower Switch - 3 |
| 307 | ---x ---- ---- ---- Upper Switch - 3 |
| 308 | ---- -x-- ---- ---- Catch Switch - 2 |
| 309 | ---- --x- ---- ---- Lower Switch - 2 |
| 310 | ---- ---x ---- ---- Upper Switch - 2 |
| 311 | ---- ---- -x-- ---- Catch Switch - 1 |
| 312 | ---- ---- --x- ---- Lower Switch - 1 (active high) |
| 313 | ---- ---- ---x ---- Upper Switch - 1 (active low) |
| 305 | 314 | ---- ---- ---- --xx Boss Door - Motor |
| 306 | 315 | */ |
| 307 | | return ac_devram[offset]; |
| 316 | //22dc8 |
| 317 | { |
| 318 | static UINT16 ufo_sw1; |
| 319 | ufo_sw1 = ac_devram[offset] & 3; |
| 320 | if(ac_devram[offset] & 0x10) |
| 321 | ufo_sw1|= 0x10; |
| 322 | if(ac_devram[offset] & 0x40) |
| 323 | ufo_sw1|= 0x20; |
| 324 | if(ac_devram[offset] & 0x100) |
| 325 | ufo_sw1|=0x100; |
| 326 | if(ac_devram[offset] & 0x400) |
| 327 | ufo_sw1|=0x200; |
| 328 | if(ac_devram[offset] & 0x1000) |
| 329 | ufo_sw1|=0x1000; |
| 330 | if(ac_devram[offset] & 0x4000) |
| 331 | ufo_sw1|=0x2000; |
| 332 | // if(ac_devram[0x0048/2] & 0x0001) |
| 333 | // ufo_sw1|=0x0040; |
| 334 | // if(ac_devram[0x0048/2] & 0x0004) |
| 335 | // ufo_sw1|=0x0400; |
| 336 | // if(ac_devram[0x0048/2] & 0x0100) |
| 337 | // ufo_sw1|=0x4000; |
| 338 | return ufo_sw1; |
| 339 | } |
| 308 | 340 | case 0x0044/2: |
| 309 | 341 | /* |
| 310 | | xxxx xxxx x-x- x-x- (ACTIVE HIGH?) [eori #$ffaa, D0] |
| 342 | ---- ---- --x- ---- Lower Switch - 5 |
| 343 | ---- ---- ---x ---- Upper Switch - 5 |
| 344 | ---- ---- ---- --x- Lower Switch - 4 (active high) |
| 345 | ---- ---- ---- ---x Upper Switch - 4 (active low) |
| 311 | 346 | */ |
| 347 | { |
| 348 | static UINT16 ufo_sw2; |
| 349 | ufo_sw2 = 0; |
| 350 | if(ac_devram[offset] & 0x01) |
| 351 | ufo_sw2|= 1; |
| 352 | if(ac_devram[offset] & 0x04) |
| 353 | ufo_sw2|= 2; |
| 354 | if(ac_devram[offset] & 0x10) |
| 355 | ufo_sw2|=0x10; |
| 356 | if(ac_devram[offset] & 0x40) |
| 357 | ufo_sw2|=0x20; |
| 358 | return ufo_sw2; |
| 359 | } |
| 360 | case 0x0048/2: |
| 312 | 361 | return ac_devram[offset]; |
| 313 | 362 | case 0x005c/2: |
| 314 | 363 | /* |
| r3514 | r3515 | |
| 325 | 374 | COMBINE_DATA(&ac_devram[offset]); |
| 326 | 375 | switch(offset) |
| 327 | 376 | { |
| 377 | case 0x00/2: |
| 378 | if (ACCESSING_BITS_0_7) |
| 379 | { |
| 380 | okim6295_set_bank_base(0, 0x40000 * (data & 0x3)); |
| 381 | okim6295_set_bank_base(1, 0x40000 * (data & 0x30) >> 4); |
| 382 | } |
| 383 | break; |
| 384 | case 0x14/2: |
| 328 | 385 | case 0x16/2: |
| 329 | 386 | if(ACCESSING_BITS_0_7) |
| 330 | | { |
| 331 | | logerror("Request to play sample %02x with rom 2\n",data); |
| 332 | 387 | okim6295_data_0_w(machine,0,data); |
| 333 | | } |
| 334 | 388 | break; |
| 389 | case 0x18/2: |
| 335 | 390 | case 0x1a/2: |
| 336 | 391 | if(ACCESSING_BITS_0_7) |
| 337 | | { |
| 338 | | logerror("Request to play sample %02x with rom 1\n",data); |
| 339 | 392 | okim6295_data_1_w(machine,0,data); |
| 340 | | } |
| 341 | 393 | break; |
| 342 | 394 | case 0x1c/2: |
| 343 | 395 | /*IRQ mask?*/ |
| r3514 | r3515 | |
| 347 | 399 | case 0x44/2: |
| 348 | 400 | break; |
| 349 | 401 | case 0x48/2: |
| 402 | break; |
| 403 | case 0x50/2: |
| 350 | 404 | led0 = ac_devram[offset]; |
| 405 | //popmessage("%04x",led0); |
| 351 | 406 | break; |
| 407 | case 0x54/2: |
| 408 | led1 = ac_devram[offset]; |
| 409 | //popmessage("%04x",led0); |
| 410 | break; |
| 352 | 411 | } |
| 353 | | logerror("%04x %04x\n",offset*2,data); |
| 354 | 412 | } |
| 355 | 413 | |
| 356 | 414 | /*This is always zero ATM*/ |
| r3514 | r3515 | |
| 360 | 418 | popmessage("UNK-2 enabled %04x",data); |
| 361 | 419 | } |
| 362 | 420 | |
| 363 | | static ADDRESS_MAP_START( acommand, ADDRESS_SPACE_PROGRAM, 16 ) |
| 421 | static ADDRESS_MAP_START( acommand_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| 364 | 422 | AM_RANGE(0x000000, 0x03ffff) AM_ROM |
| 365 | 423 | AM_RANGE(0x082000, 0x082005) AM_WRITE(ac_bgscroll_w) |
| 366 | 424 | AM_RANGE(0x082100, 0x082105) AM_WRITE(ac_txscroll_w) |
| r3514 | r3515 | |
| 376 | 434 | |
| 377 | 435 | static INPUT_PORTS_START( acommand ) |
| 378 | 436 | PORT_START("IN0") |
| 379 | | PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) ) |
| 380 | | PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) |
| 381 | | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 382 | | PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) |
| 383 | | PORT_DIPSETTING( 0x0002, DEF_STR( Off ) ) |
| 384 | | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 385 | | PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) ) |
| 386 | | PORT_DIPSETTING( 0x0004, DEF_STR( Off ) ) |
| 387 | | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 388 | | PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) ) |
| 389 | | PORT_DIPSETTING( 0x0008, DEF_STR( Off ) ) |
| 390 | | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 391 | | PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) ) |
| 392 | | PORT_DIPSETTING( 0x0010, DEF_STR( Off ) ) |
| 393 | | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 394 | | PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) ) |
| 395 | | PORT_DIPSETTING( 0x0020, DEF_STR( Off ) ) |
| 396 | | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 397 | | PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) ) |
| 437 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 ) |
| 438 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START2 ) |
| 439 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 440 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_COIN2 ) |
| 441 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_SERVICE1 ) |
| 442 | PORT_SERVICE_NO_TOGGLE( 0x0020, IP_ACTIVE_LOW ) |
| 443 | PORT_DIPNAME( 0x0040, 0x0040, "IN0" ) |
| 398 | 444 | PORT_DIPSETTING( 0x0040, DEF_STR( Off ) ) |
| 399 | 445 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 400 | 446 | PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) ) |
| 401 | 447 | PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) |
| 402 | 448 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 403 | | PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) ) |
| 404 | | PORT_DIPSETTING( 0x0100, DEF_STR( Off ) ) |
| 405 | | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 449 | PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 406 | 450 | PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) ) |
| 407 | 451 | PORT_DIPSETTING( 0x0200, DEF_STR( Off ) ) |
| 408 | 452 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 409 | | PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) ) |
| 410 | | PORT_DIPSETTING( 0x0400, DEF_STR( Off ) ) |
| 411 | | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 453 | PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) |
| 412 | 454 | PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) ) |
| 413 | 455 | PORT_DIPSETTING( 0x0800, DEF_STR( Off ) ) |
| 414 | 456 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 415 | | PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) ) |
| 457 | PORT_DIPNAME( 0x1000, 0x1000, "Ticket Dispenser - 1" ) |
| 416 | 458 | PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) |
| 417 | 459 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 418 | | PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) ) |
| 460 | PORT_DIPNAME( 0x2000, 0x2000, "Ticket Dispenser - 2") |
| 419 | 461 | PORT_DIPSETTING( 0x2000, DEF_STR( Off ) ) |
| 420 | 462 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 421 | 463 | PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) ) |
| r3514 | r3515 | |
| 426 | 468 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 427 | 469 | |
| 428 | 470 | PORT_START("IN1") |
| 429 | | PORT_DIPNAME( 0x0001, 0x0001, DEF_STR( Unknown ) ) |
| 471 | PORT_DIPNAME( 0x0001, 0x0001, "IN2" ) |
| 430 | 472 | PORT_DIPSETTING( 0x0001, DEF_STR( Off ) ) |
| 431 | 473 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 432 | 474 | PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) ) |
| r3514 | r3515 | |
| 508 | 550 | |
| 509 | 551 | static INTERRUPT_GEN( acommand_irq ) |
| 510 | 552 | { |
| 511 | | if (cpu_getiloops() == 0) |
| 512 | | cpunum_set_input_line(machine, 0, 2, HOLD_LINE); |
| 513 | | else if (cpu_getiloops() == 1) |
| 514 | | cpunum_set_input_line(machine, 0, 3, HOLD_LINE); |
| 553 | switch ( cpu_getiloops() ) |
| 554 | { |
| 555 | case 0: cpunum_set_input_line(machine, 0, 3, HOLD_LINE); |
| 556 | case 1: cpunum_set_input_line(machine, 0, 2, HOLD_LINE); |
| 557 | } |
| 515 | 558 | } |
| 516 | 559 | |
| 517 | 560 | static MACHINE_DRIVER_START( acommand ) |
| 518 | 561 | |
| 519 | 562 | /* basic machine hardware */ |
| 520 | 563 | MDRV_CPU_ADD("main",M68000,12000000) |
| 521 | | MDRV_CPU_PROGRAM_MAP(acommand,0) |
| 564 | MDRV_CPU_PROGRAM_MAP(acommand_map,0) |
| 522 | 565 | MDRV_CPU_VBLANK_INT_HACK(acommand_irq,2) |
| 523 | 566 | |
| 524 | 567 | /* video hardware */ |
| r3514 | r3515 | |
| 535 | 578 | MDRV_VIDEO_UPDATE(acommand) |
| 536 | 579 | |
| 537 | 580 | /* sound hardware */ |
| 538 | | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 581 | MDRV_SPEAKER_STANDARD_STEREO("left", "right") |
| 539 | 582 | |
| 540 | | MDRV_SOUND_ADD("oki1", OKIM6295, 2400000) |
| 541 | | MDRV_SOUND_CONFIG(okim6295_interface_pin7low) |
| 542 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 583 | MDRV_SOUND_ADD("oki1", OKIM6295, 2112000) |
| 584 | MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified |
| 585 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0) |
| 586 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0) |
| 543 | 587 | |
| 544 | | MDRV_SOUND_ADD("oki2", OKIM6295, 2400000) |
| 545 | | MDRV_SOUND_CONFIG(okim6295_interface_pin7low) |
| 546 | | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) |
| 588 | MDRV_SOUND_ADD("oki2", OKIM6295, 2112000) |
| 589 | MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified |
| 590 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0) |
| 591 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0) |
| 547 | 592 | MACHINE_DRIVER_END |
| 548 | 593 | |
| 549 | 594 | /*************************************************************************** |
| r3514 | r3515 | |
| 573 | 618 | ROM_LOAD16_BYTE( "jalgp7.bin", 0x300000, 0x080000, CRC(44b71098) SHA1(a6ec2573f9a266d4f8f315f6e99b12525011f512) ) |
| 574 | 619 | ROM_LOAD16_BYTE( "jalgp8.bin", 0x300001, 0x080000, CRC(ce0b7838) SHA1(46e34971cb62565a3948d8c0a18086648c32e13b) ) |
| 575 | 620 | |
| 576 | | ROM_REGION( 0x100000, "oki2", 0 ) |
| 621 | ROM_REGION( 0x100000, "oki1", 0 ) /* M6295 samples */ |
| 622 | ROM_LOAD( "jalcf2.bin", 0x000000, 0x100000, CRC(b982fd97) SHA1(35ee5b1b9be762ccfefda24d73e329ceea876deb) ) |
| 623 | |
| 624 | ROM_REGION( 0x100000, "oki2", 0 ) /* M6295 samples */ |
| 577 | 625 | ROM_LOAD( "jalcf1.bin", 0x000000, 0x100000, CRC(24af21d3) SHA1(f68ab81a6c833b57ae9eef916a1c8578f3d893dd) ) |
| 578 | 626 | |
| 579 | | ROM_REGION( 0x100000, "oki1", 0 ) |
| 580 | | ROM_LOAD( "jalcf2.bin", 0x000000, 0x100000, CRC(b982fd97) SHA1(35ee5b1b9be762ccfefda24d73e329ceea876deb) ) |
| 581 | | |
| 582 | 627 | ROM_REGION( 0x100000, "user1", 0 ) /* ? these two below are identical*/ |
| 583 | 628 | ROM_LOAD( "jalmr14.bin", 0x000000, 0x080000, CRC(9d428fb7) SHA1(02f72938d73db932bd217620a175a05215f6016a) ) |
| 584 | 629 | ROM_LOAD( "jalmr17.bin", 0x080000, 0x080000, CRC(9d428fb7) SHA1(02f72938d73db932bd217620a175a05215f6016a) ) |
| 585 | 630 | ROM_END |
| 586 | 631 | |
| 587 | | GAME( 1990, acommand, 0, acommand, acommand, 0, ROT0, "Jaleco", "Alien Command" , GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 632 | GAME( 1994, acommand, 0, acommand, acommand, 0, ROT0, "Jaleco", "Alien Command" , GAME_NOT_WORKING ) |
src/mame/drivers/twin16.c
| r3514 | r3515 | |
| 18 | 18 | |
| 19 | 19 | Known Issues: |
| 20 | 20 | - some rogue sprites in Devil World |
| 21 | | - sprite-background priority isn't correct (see intro screen of Devil World) |
| 21 | - sprite-background priority is guessed |
| 22 | 22 | |
| 23 | 23 | 68000 Memory Map for Konami Twin System |
| 24 | 24 | |
| r3514 | r3515 | |
| 68 | 68 | extern VIDEO_START( fround ); |
| 69 | 69 | extern VIDEO_UPDATE( twin16 ); |
| 70 | 70 | extern VIDEO_EOF( twin16 ); |
| 71 | | extern VIDEO_UPDATE( vulcan ); |
| 72 | 71 | |
| 73 | 72 | |
| 74 | 73 | extern void twin16_spriteram_process( void ); |
| r3514 | r3515 | |
| 98 | 97 | |
| 99 | 98 | enum |
| 100 | 99 | { |
| 101 | | CPU_SOUND, |
| 100 | CPU_A, |
| 102 | 101 | CPU_B, |
| 103 | | CPU_A |
| 102 | CPU_SOUND |
| 104 | 103 | }; |
| 105 | 104 | |
| 106 | 105 | |
| r3514 | r3515 | |
| 210 | 209 | if( twin16_CPUA_register!=old ) |
| 211 | 210 | { |
| 212 | 211 | if( (old&0x08)==0 && (twin16_CPUA_register&0x08) ) |
| 213 | | cpunum_set_input_line_and_vector(machine, CPU_SOUND, 0, HOLD_LINE, 0xff ); // trigger IRQ on sound CPU |
| 212 | cpunum_set_input_line_and_vector(machine, 1, 0, HOLD_LINE, 0xff ); // trigger IRQ on sound CPU |
| 214 | 213 | } |
| 215 | 214 | } |
| 216 | 215 | |
| r3514 | r3515 | |
| 907 | 906 | |
| 908 | 907 | static MACHINE_DRIVER_START( twin16 ) |
| 909 | 908 | // basic machine hardware |
| 910 | | MDRV_CPU_ADD("audio", Z80, 3579545) |
| 911 | | MDRV_CPU_PROGRAM_MAP(sound_map,0) |
| 909 | MDRV_CPU_ADD("main", M68000, XTAL_18_432MHz/2) |
| 910 | MDRV_CPU_PROGRAM_MAP(main_map,0) |
| 911 | MDRV_CPU_VBLANK_INT("main", CPUA_interrupt) |
| 912 | 912 | |
| 913 | 913 | MDRV_CPU_ADD("sub", M68000, XTAL_18_432MHz/2) |
| 914 | 914 | MDRV_CPU_PROGRAM_MAP(sub_map,0) |
| 915 | 915 | MDRV_CPU_VBLANK_INT("main", CPUB_interrupt) |
| 916 | 916 | |
| 917 | | MDRV_CPU_ADD("main", M68000, XTAL_18_432MHz/2) |
| 918 | | MDRV_CPU_PROGRAM_MAP(main_map,0) |
| 919 | | MDRV_CPU_VBLANK_INT("main", CPUA_interrupt) |
| 917 | MDRV_CPU_ADD("audio", Z80, 3579545) |
| 918 | MDRV_CPU_PROGRAM_MAP(sound_map,0) |
| 920 | 919 | |
| 921 | 920 | MDRV_INTERLEAVE(100) |
| 922 | 921 | |
| r3514 | r3515 | |
| 956 | 955 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.20) |
| 957 | 956 | MACHINE_DRIVER_END |
| 958 | 957 | |
| 959 | | static MACHINE_DRIVER_START( heavysync ) |
| 958 | static MACHINE_DRIVER_START( devilw ) |
| 960 | 959 | MDRV_IMPORT_FROM(twin16) |
| 961 | 960 | MDRV_INTERLEAVE(1000) |
| 962 | 961 | MACHINE_DRIVER_END |
| 963 | 962 | |
| 964 | 963 | static MACHINE_DRIVER_START( fround ) |
| 965 | 964 | /* basic machine hardware */ |
| 966 | | MDRV_CPU_ADD("audio", Z80, 3579545) |
| 967 | | MDRV_CPU_PROGRAM_MAP(sound_map,0) |
| 968 | | |
| 969 | 965 | MDRV_CPU_ADD("main", M68000, 10000000) |
| 970 | 966 | MDRV_CPU_PROGRAM_MAP(fround_map,0) |
| 971 | 967 | MDRV_CPU_VBLANK_INT("main", CPUA_interrupt) |
| 972 | 968 | |
| 969 | MDRV_CPU_ADD("audio", Z80, 3579545) |
| 970 | MDRV_CPU_PROGRAM_MAP(sound_map,0) |
| 971 | |
| 973 | 972 | MDRV_INTERLEAVE(100) |
| 974 | 973 | |
| 975 | 974 | /* video hardware */ |
| r3514 | r3515 | |
| 1013 | 1012 | MDRV_VIDEO_START(fround) |
| 1014 | 1013 | MACHINE_DRIVER_END |
| 1015 | 1014 | |
| 1016 | | static MACHINE_DRIVER_START( mia ) |
| 1015 | static MACHINE_DRIVER_START( miaj ) |
| 1017 | 1016 | MDRV_IMPORT_FROM(twin16) |
| 1018 | 1017 | MDRV_SCREEN_MODIFY("main") |
| 1019 | 1018 | MDRV_SCREEN_VISIBLE_AREA(1*8, 39*8-1, 2*8, 30*8-1) |
| 1020 | 1019 | MDRV_VIDEO_START(fround) |
| 1021 | | |
| 1022 | 1020 | MACHINE_DRIVER_END |
| 1023 | 1021 | |
| 1024 | | static MACHINE_DRIVER_START( vulcan ) |
| 1025 | | MDRV_IMPORT_FROM(twin16) |
| 1026 | | MDRV_VIDEO_UPDATE(vulcan ) |
| 1027 | | MACHINE_DRIVER_END |
| 1028 | | |
| 1029 | 1022 | static MACHINE_DRIVER_START( cuebrckj ) |
| 1030 | 1023 | MDRV_IMPORT_FROM(twin16) |
| 1031 | 1024 | MDRV_SCREEN_MODIFY("main") |
| r3514 | r3515 | |
| 1037 | 1030 | /* ROMs */ |
| 1038 | 1031 | |
| 1039 | 1032 | ROM_START( devilw ) |
| 1040 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1041 | | ROM_LOAD( "687_l03.10a", 0x00000, 0x8000, CRC(7201983c) SHA1(06d089406d2f702e8d51ffdfbf34e4727a28d506) ) |
| 1033 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1034 | ROM_LOAD16_BYTE( "687_t05.6n", 0x00000, 0x10000, CRC(8ab7dc61) SHA1(de8e93f04f22fa07ea6c379eeae12f8fcb48f751) ) |
| 1035 | ROM_LOAD16_BYTE( "687_t04.4n", 0x00001, 0x10000, CRC(c69924da) SHA1(9b7220eac95fd92f32fec92b21f4f02f871c5d43) ) |
| 1036 | ROM_LOAD16_BYTE( "687_t09.6r", 0x20000, 0x10000, CRC(fae97de0) SHA1(25b085c9de0943a0112d76447ca0504ed57cad85) ) |
| 1037 | ROM_LOAD16_BYTE( "687_t08.4r", 0x20001, 0x10000, CRC(8c898d67) SHA1(0dd1a4467f97c993ea8d40398f46c3fc88c889bd) ) |
| 1042 | 1038 | |
| 1043 | 1039 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1044 | 1040 | ROM_LOAD16_BYTE( "687_q07.10n", 0x00000, 0x10000, CRC(53110c0b) SHA1(a473486f7c99ab758187376d5bd89581e0b7cbdf) ) |
| r3514 | r3515 | |
| 1046 | 1042 | ROM_LOAD16_BYTE( "687_q13.10s", 0x20000, 0x10000, CRC(36ae6014) SHA1(102d4c3215fb5f199ce6f93ce92725b5cce0b01d) ) |
| 1047 | 1043 | ROM_LOAD16_BYTE( "687_q12.8s", 0x20001, 0x10000, CRC(6d012167) SHA1(d608e29e0b2e834c099386b6ebb667e4bfc40ce7) ) |
| 1048 | 1044 | |
| 1049 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1050 | | ROM_LOAD16_BYTE( "687_t05.6n", 0x00000, 0x10000, CRC(8ab7dc61) SHA1(de8e93f04f22fa07ea6c379eeae12f8fcb48f751) ) |
| 1051 | | ROM_LOAD16_BYTE( "687_t04.4n", 0x00001, 0x10000, CRC(c69924da) SHA1(9b7220eac95fd92f32fec92b21f4f02f871c5d43) ) |
| 1052 | | ROM_LOAD16_BYTE( "687_t09.6r", 0x20000, 0x10000, CRC(fae97de0) SHA1(25b085c9de0943a0112d76447ca0504ed57cad85) ) |
| 1053 | | ROM_LOAD16_BYTE( "687_t08.4r", 0x20001, 0x10000, CRC(8c898d67) SHA1(0dd1a4467f97c993ea8d40398f46c3fc88c889bd) ) |
| 1045 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1046 | ROM_LOAD( "687_l03.10a", 0x00000, 0x8000, CRC(7201983c) SHA1(06d089406d2f702e8d51ffdfbf34e4727a28d506) ) |
| 1054 | 1047 | |
| 1055 | 1048 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1056 | 1049 | ROM_LOAD( "687_m14.d8", 0x00000, 0x4000, CRC(d7338557) SHA1(9b384baafabaab3888a0139674f0b530303684ca) ) // characters |
| r3514 | r3515 | |
| 1065 | 1058 | ROM_LOAD16_BYTE( "687_l11.10r", 0x00000, 0x10000, CRC(399deee8) SHA1(dcc65e95f28ae4e9b671e70ce0bd5ba0fe178506) ) |
| 1066 | 1059 | ROM_LOAD16_BYTE( "687_l10.8r", 0x00001, 0x10000, CRC(117c91ee) SHA1(dcf8efb25fc73cff916b66b7bcfd3c1fb2556a53) ) |
| 1067 | 1060 | |
| 1068 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1061 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1069 | 1062 | ROM_LOAD( "687_i01.5a", 0x00000, 0x20000, CRC(d4992dfb) SHA1(c65bef07b6adb9ab6328d679595450945dbf6a88) ) |
| 1070 | 1063 | |
| 1071 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1064 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1072 | 1065 | ROM_LOAD( "687_i02.7c", 0x00000, 0x20000, CRC(e5947501) SHA1(9ec7319bd97711981db60af6f477c2ba2ec7e6b8) ) |
| 1073 | 1066 | ROM_END |
| 1074 | 1067 | |
| 1075 | 1068 | ROM_START( majuu ) |
| 1076 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1077 | | ROM_LOAD( "687_l03.10a", 0x00000, 0x8000, CRC(7201983c) SHA1(06d089406d2f702e8d51ffdfbf34e4727a28d506) ) |
| 1069 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1070 | ROM_LOAD16_BYTE( "687_s05.6n", 0x00000, 0x10000, CRC(bd99b434) SHA1(4dbcf3a57ff0b4c3a160e2a60c2ee3fd38f5a95d) ) |
| 1071 | ROM_LOAD16_BYTE( "687_s04.4n", 0x00001, 0x10000, CRC(3df732e2) SHA1(32e42edbc6f9dfba6ff881c72b8b014b6905e7f3) ) |
| 1072 | ROM_LOAD16_BYTE( "687_s09.6r", 0x20000, 0x10000, CRC(1f6efec3) SHA1(4177d300877e3ffcb481f534ef7b3e4bdc160be0) ) |
| 1073 | ROM_LOAD16_BYTE( "687_s08.4r", 0x20001, 0x10000, CRC(8a16c8c6) SHA1(df3af1c137632eab98b1eea538cc4ef5b134f44f) ) |
| 1078 | 1074 | |
| 1079 | 1075 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1080 | 1076 | ROM_LOAD16_BYTE( "687_q07.10n", 0x00000, 0x10000, CRC(53110c0b) SHA1(a473486f7c99ab758187376d5bd89581e0b7cbdf) ) |
| r3514 | r3515 | |
| 1082 | 1078 | ROM_LOAD16_BYTE( "687_q13.10s", 0x20000, 0x10000, CRC(36ae6014) SHA1(102d4c3215fb5f199ce6f93ce92725b5cce0b01d) ) |
| 1083 | 1079 | ROM_LOAD16_BYTE( "687_q12.8s", 0x20001, 0x10000, CRC(6d012167) SHA1(d608e29e0b2e834c099386b6ebb667e4bfc40ce7) ) |
| 1084 | 1080 | |
| 1085 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1086 | | ROM_LOAD16_BYTE( "687_s05.6n", 0x00000, 0x10000, CRC(bd99b434) SHA1(4dbcf3a57ff0b4c3a160e2a60c2ee3fd38f5a95d) ) |
| 1087 | | ROM_LOAD16_BYTE( "687_s04.4n", 0x00001, 0x10000, CRC(3df732e2) SHA1(32e42edbc6f9dfba6ff881c72b8b014b6905e7f3) ) |
| 1088 | | ROM_LOAD16_BYTE( "687_s09.6r", 0x20000, 0x10000, CRC(1f6efec3) SHA1(4177d300877e3ffcb481f534ef7b3e4bdc160be0) ) |
| 1089 | | ROM_LOAD16_BYTE( "687_s08.4r", 0x20001, 0x10000, CRC(8a16c8c6) SHA1(df3af1c137632eab98b1eea538cc4ef5b134f44f) ) |
| 1081 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1082 | ROM_LOAD( "687_l03.10a", 0x00000, 0x8000, CRC(7201983c) SHA1(06d089406d2f702e8d51ffdfbf34e4727a28d506) ) |
| 1090 | 1083 | |
| 1091 | 1084 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1092 | 1085 | ROM_LOAD( "687_l14.d8", 0x00000, 0x4000, CRC(20ecccd6) SHA1(b8ac3186de5ea81ae1c64b9511b7a0718aabab48) ) // characters |
| r3514 | r3515 | |
| 1101 | 1094 | ROM_LOAD16_BYTE( "687_l11.10r", 0x00000, 0x10000, CRC(399deee8) SHA1(dcc65e95f28ae4e9b671e70ce0bd5ba0fe178506) ) |
| 1102 | 1095 | ROM_LOAD16_BYTE( "687_l10.8r", 0x00001, 0x10000, CRC(117c91ee) SHA1(dcf8efb25fc73cff916b66b7bcfd3c1fb2556a53) ) |
| 1103 | 1096 | |
| 1104 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1097 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1105 | 1098 | ROM_LOAD( "687_i01.5a", 0x00000, 0x20000, CRC(d4992dfb) SHA1(c65bef07b6adb9ab6328d679595450945dbf6a88) ) |
| 1106 | 1099 | |
| 1107 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1100 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1108 | 1101 | ROM_LOAD( "687_i02.7c", 0x00000, 0x20000, CRC(e5947501) SHA1(9ec7319bd97711981db60af6f477c2ba2ec7e6b8) ) |
| 1109 | 1102 | ROM_END |
| 1110 | 1103 | |
| 1111 | 1104 | ROM_START( darkadv ) |
| 1112 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1113 | | ROM_LOAD( "687_n03.10a", 0x00000, 0x8000, CRC(a24c682f) SHA1(cf053270d3f77448ff802db832598ae3cf7dae6c) ) |
| 1105 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1106 | ROM_LOAD16_BYTE( "687_n05.6n", 0x00000, 0x10000, CRC(a9195b0b) SHA1(a5b30c93dc962b5aef33bab7e257ed606f00c9f2) ) |
| 1107 | ROM_LOAD16_BYTE( "687_n04.4n", 0x00001, 0x10000, CRC(65b55105) SHA1(ef102eebf34cceebafb55b04003ab9173af43458) ) |
| 1108 | ROM_LOAD16_BYTE( "687_n09.6r", 0x20000, 0x10000, CRC(1c6b594c) SHA1(06e4eab7f544170ac40e8c77b9ebb236a6094367) ) |
| 1109 | ROM_LOAD16_BYTE( "687_n08.4r", 0x20001, 0x10000, CRC(a9603196) SHA1(a3ab00a446531d370809d8e405cabe2d74cb612b) ) |
| 1114 | 1110 | |
| 1115 | 1111 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1116 | 1112 | ROM_LOAD16_BYTE( "687_n07.10n", 0x00000, 0x10000, CRC(6154322a) SHA1(e84c75b4d346ade2cfb5d56454282fafb04c2d77) ) |
| r3514 | r3515 | |
| 1118 | 1114 | ROM_LOAD16_BYTE( "687_n13.10s", 0x20000, 0x10000, CRC(f1c252af) SHA1(dbe78352ae5b284870becc92139773f66c52ed7d) ) |
| 1119 | 1115 | ROM_LOAD16_BYTE( "687_n12.8s", 0x20001, 0x10000, CRC(da221944) SHA1(c288ee583414a077f0d8b815b8e01b7f19a5fafe) ) |
| 1120 | 1116 | |
| 1121 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1122 | | ROM_LOAD16_BYTE( "687_n05.6n", 0x00000, 0x10000, CRC(a9195b0b) SHA1(a5b30c93dc962b5aef33bab7e257ed606f00c9f2) ) |
| 1123 | | ROM_LOAD16_BYTE( "687_n04.4n", 0x00001, 0x10000, CRC(65b55105) SHA1(ef102eebf34cceebafb55b04003ab9173af43458) ) |
| 1124 | | ROM_LOAD16_BYTE( "687_n09.6r", 0x20000, 0x10000, CRC(1c6b594c) SHA1(06e4eab7f544170ac40e8c77b9ebb236a6094367) ) |
| 1125 | | ROM_LOAD16_BYTE( "687_n08.4r", 0x20001, 0x10000, CRC(a9603196) SHA1(a3ab00a446531d370809d8e405cabe2d74cb612b) ) |
| 1117 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1118 | ROM_LOAD( "687_n03.10a", 0x00000, 0x8000, CRC(a24c682f) SHA1(cf053270d3f77448ff802db832598ae3cf7dae6c) ) |
| 1126 | 1119 | |
| 1127 | 1120 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1128 | 1121 | ROM_LOAD( "687_n14.d8", 0x0000, 0x4000, CRC(c76ac6d2) SHA1(d8fec255f1f7177a3716a5894fb679cbe172b6ea) ) // characters |
| r3514 | r3515 | |
| 1137 | 1130 | ROM_LOAD16_BYTE( "687_l11.10r", 0x00000, 0x10000, CRC(399deee8) SHA1(dcc65e95f28ae4e9b671e70ce0bd5ba0fe178506) ) |
| 1138 | 1131 | ROM_LOAD16_BYTE( "687_l10.8r", 0x00001, 0x10000, CRC(117c91ee) SHA1(dcf8efb25fc73cff916b66b7bcfd3c1fb2556a53) ) |
| 1139 | 1132 | |
| 1140 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1133 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1141 | 1134 | ROM_LOAD( "687_i01.5a", 0x00000, 0x20000, CRC(d4992dfb) SHA1(c65bef07b6adb9ab6328d679595450945dbf6a88) ) |
| 1142 | 1135 | |
| 1143 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1136 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1144 | 1137 | ROM_LOAD( "687_i02.7c", 0x00000, 0x20000, CRC(e5947501) SHA1(9ec7319bd97711981db60af6f477c2ba2ec7e6b8) ) |
| 1145 | 1138 | ROM_END |
| 1146 | 1139 | |
| 1147 | 1140 | ROM_START( vulcan ) |
| 1148 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1149 | | ROM_LOAD( "785_g03.10a", 0x00000, 0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) ) |
| 1141 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1142 | ROM_LOAD16_BYTE( "785_w05.6n", 0x00000, 0x10000, CRC(6e0e99cd) SHA1(f9f4ef617aee83397b0ac98a5cc92f60d3a3d5ed) ) |
| 1143 | ROM_LOAD16_BYTE( "785_w04.4n", 0x00001, 0x10000, CRC(23ec74ca) SHA1(901c7c798b113232f20e24f61940ed6ef5148599) ) |
| 1144 | ROM_LOAD16_BYTE( "785_w09.6r", 0x20000, 0x10000, CRC(377e4f28) SHA1(d3af2e52c38b5d618cac2e66df99ab7950638fbc) ) |
| 1145 | ROM_LOAD16_BYTE( "785_w08.4r", 0x20001, 0x10000, CRC(813d41ea) SHA1(58ba0e4b1afec3e5674286c44da14244591f1312) ) |
| 1150 | 1146 | |
| 1151 | 1147 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1152 | 1148 | ROM_LOAD16_BYTE( "785_p07.10n", 0x00000, 0x10000, CRC(686d549d) SHA1(9687be801c4fb963bf6b0199e2ae9f5051213f7a) ) |
| r3514 | r3515 | |
| 1154 | 1150 | ROM_LOAD16_BYTE( "785_p13.10s", 0x20000, 0x10000, CRC(478fdb0a) SHA1(2e285ad6dcfc67f3e24d231e0e1be19036ce64d2) ) |
| 1155 | 1151 | ROM_LOAD16_BYTE( "785_p12.8s", 0x20001, 0x10000, CRC(38ea402a) SHA1(90ff2bd71435988cde967704ce3b1401de206683) ) |
| 1156 | 1152 | |
| 1157 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1158 | | ROM_LOAD16_BYTE( "785_w05.6n", 0x00000, 0x10000, CRC(6e0e99cd) SHA1(f9f4ef617aee83397b0ac98a5cc92f60d3a3d5ed) ) |
| 1159 | | ROM_LOAD16_BYTE( "785_w04.4n", 0x00001, 0x10000, CRC(23ec74ca) SHA1(901c7c798b113232f20e24f61940ed6ef5148599) ) |
| 1160 | | ROM_LOAD16_BYTE( "785_w09.6r", 0x20000, 0x10000, CRC(377e4f28) SHA1(d3af2e52c38b5d618cac2e66df99ab7950638fbc) ) |
| 1161 | | ROM_LOAD16_BYTE( "785_w08.4r", 0x20001, 0x10000, CRC(813d41ea) SHA1(58ba0e4b1afec3e5674286c44da14244591f1312) ) |
| 1153 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1154 | ROM_LOAD( "785_g03.10a", 0x00000, 0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) ) |
| 1162 | 1155 | |
| 1163 | 1156 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1164 | 1157 | ROM_LOAD( "785_h14.d8", 0x0000, 0x4000, CRC(02f4b16f) SHA1(45addc99f520770f38c6aa69aef9af59cfc410b5) ) // characters |
| r3514 | r3515 | |
| 1171 | 1164 | |
| 1172 | 1165 | ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 ) // tile data; mapped at 0x80000 on CPUB |
| 1173 | 1166 | |
| 1174 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1167 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1175 | 1168 | ROM_LOAD( "785_f01.5a", 0x00000, 0x20000, CRC(a0d8d69e) SHA1(2994e5740b7c099d55fb162a363a26ef1995c756) ) |
| 1176 | 1169 | |
| 1177 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1170 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1178 | 1171 | ROM_LOAD( "785_f02.7c", 0x00000, 0x20000, CRC(c39f5ca4) SHA1(92ebea11b7d3a72d0f58c456f16a6ff36d6b3062) ) |
| 1179 | 1172 | ROM_END |
| 1180 | 1173 | |
| 1181 | 1174 | ROM_START( gradius2 ) |
| 1182 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1183 | | ROM_LOAD( "785_g03.10a", 0x00000, 0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) ) |
| 1175 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1176 | ROM_LOAD16_BYTE( "785_x05.6n", 0x00000, 0x10000, CRC(8a23a7b8) SHA1(9846272c011715b17f146d5265a09e790d6e37cd) ) |
| 1177 | ROM_LOAD16_BYTE( "785_x04.4n", 0x00001, 0x10000, CRC(88e466ce) SHA1(3a7d098b851bcf6dc8e7ff601d11563406c56666) ) |
| 1178 | ROM_LOAD16_BYTE( "785_x09.6r", 0x20000, 0x10000, CRC(3f3d7d7a) SHA1(8e3acf980179e749ec642b6ff211c4ba57c6c592) ) |
| 1179 | ROM_LOAD16_BYTE( "785_x08.4r", 0x20001, 0x10000, CRC(c39c8efd) SHA1(372dbb254525a7334fe79a42ba9851eafa856847) ) |
| 1184 | 1180 | |
| 1185 | 1181 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1186 | 1182 | ROM_LOAD16_BYTE( "785_p07.10n", 0x00000, 0x10000, CRC(686d549d) SHA1(9687be801c4fb963bf6b0199e2ae9f5051213f7a) ) |
| r3514 | r3515 | |
| 1188 | 1184 | ROM_LOAD16_BYTE( "785_p13.10s", 0x20000, 0x10000, CRC(478fdb0a) SHA1(2e285ad6dcfc67f3e24d231e0e1be19036ce64d2) ) |
| 1189 | 1185 | ROM_LOAD16_BYTE( "785_p12.8s", 0x20001, 0x10000, CRC(38ea402a) SHA1(90ff2bd71435988cde967704ce3b1401de206683) ) |
| 1190 | 1186 | |
| 1191 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1192 | | ROM_LOAD16_BYTE( "785_x05.6n", 0x00000, 0x10000, CRC(8a23a7b8) SHA1(9846272c011715b17f146d5265a09e790d6e37cd) ) |
| 1193 | | ROM_LOAD16_BYTE( "785_x04.4n", 0x00001, 0x10000, CRC(88e466ce) SHA1(3a7d098b851bcf6dc8e7ff601d11563406c56666) ) |
| 1194 | | ROM_LOAD16_BYTE( "785_x09.6r", 0x20000, 0x10000, CRC(3f3d7d7a) SHA1(8e3acf980179e749ec642b6ff211c4ba57c6c592) ) |
| 1195 | | ROM_LOAD16_BYTE( "785_x08.4r", 0x20001, 0x10000, CRC(c39c8efd) SHA1(372dbb254525a7334fe79a42ba9851eafa856847) ) |
| 1187 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1188 | ROM_LOAD( "785_g03.10a", 0x00000, 0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) ) |
| 1196 | 1189 | |
| 1197 | 1190 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1198 | 1191 | ROM_LOAD( "785_g14.d8", 0x0000, 0x4000, CRC(9dcdad9d) SHA1(22f457408b453a71b7e91974aee1b1e735ff887f) ) // characters |
| r3514 | r3515 | |
| 1205 | 1198 | |
| 1206 | 1199 | ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 ) // tile data; mapped at 0x80000 on CPUB |
| 1207 | 1200 | |
| 1208 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1201 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1209 | 1202 | ROM_LOAD( "785_f01.5a", 0x00000, 0x20000, CRC(a0d8d69e) SHA1(2994e5740b7c099d55fb162a363a26ef1995c756) ) |
| 1210 | 1203 | |
| 1211 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1204 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1212 | 1205 | ROM_LOAD( "785_f02.7c", 0x00000, 0x20000, CRC(c39f5ca4) SHA1(92ebea11b7d3a72d0f58c456f16a6ff36d6b3062) ) |
| 1213 | 1206 | ROM_END |
| 1214 | 1207 | |
| 1215 | 1208 | ROM_START( grdius2a ) |
| 1216 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1217 | | ROM_LOAD( "785_g03.10a", 0x00000, 0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) ) |
| 1209 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1210 | ROM_LOAD16_BYTE( "785_p05.6n", 0x00000, 0x10000, CRC(4db0e736) SHA1(45edf094da448d039af18a7b47a592a3de02f17b) ) |
| 1211 | ROM_LOAD16_BYTE( "785_p04.4n", 0x00001, 0x10000, CRC(765b99e6) SHA1(4acae0cf2bf23f8a1cf7b650b018d22a9ae947c9) ) |
| 1212 | ROM_LOAD16_BYTE( "785_t09.6r", 0x20000, 0x10000, CRC(4e3f4965) SHA1(130da6db0590779948a29fd5010f0e628e4f2ee6) ) |
| 1213 | ROM_LOAD16_BYTE( "785_j08.4r", 0x20001, 0x10000, CRC(2b1c9108) SHA1(3d367a1b60f95798b478dc4a84daa9b362271d4d) ) |
| 1218 | 1214 | |
| 1219 | 1215 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1220 | 1216 | ROM_LOAD16_BYTE( "785_p07.10n", 0x00000, 0x10000, CRC(686d549d) SHA1(9687be801c4fb963bf6b0199e2ae9f5051213f7a) ) |
| r3514 | r3515 | |
| 1222 | 1218 | ROM_LOAD16_BYTE( "785_p13.10s", 0x20000, 0x10000, CRC(478fdb0a) SHA1(2e285ad6dcfc67f3e24d231e0e1be19036ce64d2) ) |
| 1223 | 1219 | ROM_LOAD16_BYTE( "785_p12.8s", 0x20001, 0x10000, CRC(38ea402a) SHA1(90ff2bd71435988cde967704ce3b1401de206683) ) |
| 1224 | 1220 | |
| 1225 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1226 | | ROM_LOAD16_BYTE( "785_p05.6n", 0x00000, 0x10000, CRC(4db0e736) SHA1(45edf094da448d039af18a7b47a592a3de02f17b) ) |
| 1227 | | ROM_LOAD16_BYTE( "785_p04.4n", 0x00001, 0x10000, CRC(765b99e6) SHA1(4acae0cf2bf23f8a1cf7b650b018d22a9ae947c9) ) |
| 1228 | | ROM_LOAD16_BYTE( "785_t09.6r", 0x20000, 0x10000, CRC(4e3f4965) SHA1(130da6db0590779948a29fd5010f0e628e4f2ee6) ) |
| 1229 | | ROM_LOAD16_BYTE( "785_j08.4r", 0x20001, 0x10000, CRC(2b1c9108) SHA1(3d367a1b60f95798b478dc4a84daa9b362271d4d) ) |
| 1221 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1222 | ROM_LOAD( "785_g03.10a", 0x00000, 0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) ) |
| 1230 | 1223 | |
| 1231 | 1224 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1232 | 1225 | ROM_LOAD( "785_g14.d8", 0x0000, 0x4000, CRC(9dcdad9d) SHA1(22f457408b453a71b7e91974aee1b1e735ff887f) ) // characters |
| r3514 | r3515 | |
| 1239 | 1232 | |
| 1240 | 1233 | ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 ) // tile data; mapped at 0x80000 on CPUB |
| 1241 | 1234 | |
| 1242 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1235 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1243 | 1236 | ROM_LOAD( "785_f01.5a", 0x00000, 0x20000, CRC(a0d8d69e) SHA1(2994e5740b7c099d55fb162a363a26ef1995c756) ) |
| 1244 | 1237 | |
| 1245 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1238 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1246 | 1239 | ROM_LOAD( "785_f02.7c", 0x00000, 0x20000, CRC(c39f5ca4) SHA1(92ebea11b7d3a72d0f58c456f16a6ff36d6b3062) ) |
| 1247 | 1240 | ROM_END |
| 1248 | 1241 | |
| 1249 | 1242 | ROM_START( grdius2b ) |
| 1250 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1251 | | ROM_LOAD( "785_g03.10a", 0x00000, 0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) ) |
| 1243 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1244 | ROM_LOAD16_BYTE( "785_p05.6n", 0x00000, 0x10000, CRC(4db0e736) SHA1(45edf094da448d039af18a7b47a592a3de02f17b) ) |
| 1245 | ROM_LOAD16_BYTE( "785_p04.4n", 0x00001, 0x10000, CRC(765b99e6) SHA1(4acae0cf2bf23f8a1cf7b650b018d22a9ae947c9) ) |
| 1246 | ROM_LOAD16_BYTE( "785_j09.6r", 0x20000, 0x10000, CRC(6d96a7e3) SHA1(cc1362f5922cf1e348a58d54d03320f394a2aeab) ) |
| 1247 | ROM_LOAD16_BYTE( "785_j08.4r", 0x20001, 0x10000, CRC(2b1c9108) SHA1(3d367a1b60f95798b478dc4a84daa9b362271d4d) ) |
| 1252 | 1248 | |
| 1253 | | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1249 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1254 | 1250 | ROM_LOAD16_BYTE( "785_p07.10n", 0x00000, 0x10000, CRC(686d549d) SHA1(9687be801c4fb963bf6b0199e2ae9f5051213f7a) ) |
| 1255 | 1251 | ROM_LOAD16_BYTE( "785_p06.8n" , 0x00001, 0x10000, CRC(70c94bee) SHA1(951e00ca4d3a47a21b4db05bcdc8ead45b42c3f1) ) |
| 1256 | 1252 | ROM_LOAD16_BYTE( "785_p13.10s", 0x20000, 0x10000, CRC(478fdb0a) SHA1(2e285ad6dcfc67f3e24d231e0e1be19036ce64d2) ) |
| 1257 | 1253 | ROM_LOAD16_BYTE( "785_p12.8s", 0x20001, 0x10000, CRC(38ea402a) SHA1(90ff2bd71435988cde967704ce3b1401de206683) ) |
| 1258 | 1254 | |
| 1259 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1260 | | ROM_LOAD16_BYTE( "785_p05.6n", 0x00000, 0x10000, CRC(4db0e736) SHA1(45edf094da448d039af18a7b47a592a3de02f17b) ) |
| 1261 | | ROM_LOAD16_BYTE( "785_p04.4n", 0x00001, 0x10000, CRC(765b99e6) SHA1(4acae0cf2bf23f8a1cf7b650b018d22a9ae947c9) ) |
| 1262 | | ROM_LOAD16_BYTE( "785_j09.6r", 0x20000, 0x10000, CRC(6d96a7e3) SHA1(cc1362f5922cf1e348a58d54d03320f394a2aeab) ) |
| 1263 | | ROM_LOAD16_BYTE( "785_j08.4r", 0x20001, 0x10000, CRC(2b1c9108) SHA1(3d367a1b60f95798b478dc4a84daa9b362271d4d) ) |
| 1255 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1256 | ROM_LOAD( "785_g03.10a", 0x00000, 0x8000, CRC(67a3b50d) SHA1(3c83f3b0df73d9361ec3cda26a6c4c603a088419) ) |
| 1264 | 1257 | |
| 1265 | 1258 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1266 | 1259 | ROM_LOAD( "785_g14.d8", 0x0000, 0x4000, CRC(9dcdad9d) SHA1(22f457408b453a71b7e91974aee1b1e735ff887f) ) // characters |
| r3514 | r3515 | |
| 1273 | 1266 | |
| 1274 | 1267 | ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 ) // tile data; mapped at 0x80000 on CPUB |
| 1275 | 1268 | |
| 1276 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1269 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1277 | 1270 | ROM_LOAD( "785_f01.5a", 0x00000, 0x20000, CRC(a0d8d69e) SHA1(2994e5740b7c099d55fb162a363a26ef1995c756) ) |
| 1278 | 1271 | |
| 1279 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1272 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1280 | 1273 | ROM_LOAD( "785_f02.7c", 0x00000, 0x20000, CRC(c39f5ca4) SHA1(92ebea11b7d3a72d0f58c456f16a6ff36d6b3062) ) |
| 1281 | 1274 | ROM_END |
| 1282 | 1275 | |
| 1283 | 1276 | ROM_START( fround ) |
| 1284 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1285 | | ROM_LOAD( "870_f03.10a", 0x00000, 0x8000, CRC(a645c727) SHA1(e173e79130f187d090766664f1c478d47062749c) ) |
| 1286 | | |
| 1287 | 1277 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1288 | 1278 | ROM_LOAD16_BYTE( "870_m21.bin", 0x00000, 0x20000, CRC(436dbffb) SHA1(be8c8544f4d8ae86f216095753c6178a3cbf0e8d) ) |
| 1289 | 1279 | ROM_LOAD16_BYTE( "870_m20.bin", 0x00001, 0x20000, CRC(b1c79d6a) SHA1(76e95e87eaa96ba694675fde7706540c584a36fb) ) |
| 1290 | 1280 | |
| 1281 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1282 | ROM_LOAD( "870_f03.10a", 0x00000, 0x8000, CRC(a645c727) SHA1(e173e79130f187d090766664f1c478d47062749c) ) |
| 1283 | |
| 1291 | 1284 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1292 | 1285 | ROM_LOAD( "870_f14.d8", 0x0000, 0x4000, CRC(c9b46615) SHA1(c0cddb1af47b8e0865055624cf4e89a111ac1b0f) ) // characters |
| 1293 | 1286 | |
| 1294 | 1287 | ROM_REGION16_LE( 0x200000, "gfx2", 0 ) // gfx data used at runtime |
| 1295 | | ROM_LOAD16_WORD("870c18.p18", 0x000000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) ) |
| 1296 | | ROM_LOAD16_WORD("870c17.p16", 0x080000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) ) |
| 1297 | | ROM_LOAD16_WORD("870c16.p15", 0x100000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) ) |
| 1298 | | ROM_LOAD16_WORD("870c15.p13", 0x180000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) ) |
| 1288 | ROM_LOAD16_WORD("870c18.p18", 0x000000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) ) |
| 1289 | ROM_LOAD16_WORD("870c17.p16", 0x080000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) ) |
| 1290 | ROM_LOAD16_WORD("870c16.p15", 0x100000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) ) |
| 1291 | ROM_LOAD16_WORD("870c15.p13", 0x180000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) ) |
| 1299 | 1292 | |
| 1300 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1293 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1301 | 1294 | ROM_LOAD( "870_c01.5a", 0x00000, 0x20000, CRC(6af96546) SHA1(63b49b28c0f2ef8f52bc4c5955ad6a633dd553cf) ) |
| 1302 | 1295 | |
| 1303 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1296 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1304 | 1297 | ROM_LOAD( "870_c02.7c", 0x00000, 0x20000, CRC(54e12c6d) SHA1(8171441aeb1a1dc4d65fae59c7c217f992f70cbc) ) |
| 1305 | 1298 | ROM_END |
| 1306 | 1299 | |
| 1307 | 1300 | ROM_START( froundl ) |
| 1308 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1309 | | ROM_LOAD( "870_f03.10a", 0x00000, 0x8000, CRC(a645c727) SHA1(e173e79130f187d090766664f1c478d47062749c) ) |
| 1310 | | |
| 1311 | 1301 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1312 | 1302 | ROM_LOAD16_BYTE( "870_l21.bin", 0x00000, 0x20000, CRC(e21a3a19) SHA1(5f5793c88093bc8632eab673f5e0d954ac9b9177) ) |
| 1313 | 1303 | ROM_LOAD16_BYTE( "870_l20.bin", 0x00001, 0x20000, CRC(0ce9786f) SHA1(0fb0eef999ed09dd50eed403255887103fc35461) ) |
| 1314 | 1304 | |
| 1305 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1306 | ROM_LOAD( "870_f03.10a", 0x00000, 0x8000, CRC(a645c727) SHA1(e173e79130f187d090766664f1c478d47062749c) ) |
| 1307 | |
| 1315 | 1308 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1316 | 1309 | ROM_LOAD( "870_f14.d8", 0x0000, 0x4000, CRC(c9b46615) SHA1(c0cddb1af47b8e0865055624cf4e89a111ac1b0f) ) // characters |
| 1317 | 1310 | |
| 1318 | 1311 | ROM_REGION16_LE( 0x200000, "gfx2", 0 ) // gfx data used at runtime |
| 1319 | | ROM_LOAD16_WORD("870c18.p18", 0x000000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) ) |
| 1320 | | ROM_LOAD16_WORD("870c17.p16", 0x080000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) ) |
| 1321 | | ROM_LOAD16_WORD("870c16.p15", 0x100000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) ) |
| 1322 | | ROM_LOAD16_WORD("870c15.p13", 0x180000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) ) |
| 1312 | ROM_LOAD16_WORD("870c18.p18", 0x000000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) ) |
| 1313 | ROM_LOAD16_WORD("870c17.p16", 0x080000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) ) |
| 1314 | ROM_LOAD16_WORD("870c16.p15", 0x100000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) ) |
| 1315 | ROM_LOAD16_WORD("870c15.p13", 0x180000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) ) |
| 1323 | 1316 | |
| 1324 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1317 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1325 | 1318 | ROM_LOAD( "870_c01.5a", 0x00000, 0x20000, CRC(6af96546) SHA1(63b49b28c0f2ef8f52bc4c5955ad6a633dd553cf) ) |
| 1326 | 1319 | |
| 1327 | 1320 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| r3514 | r3515 | |
| 1329 | 1322 | ROM_END |
| 1330 | 1323 | |
| 1331 | 1324 | ROM_START( hpuncher ) |
| 1332 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1333 | | ROM_LOAD( "870_g03.10a", 0x00000, 0x8000, CRC(db9c10c8) SHA1(b2ec4d6800a4ab00dfcc8d3cd4abf9b9d7c5544a) ) |
| 1334 | | |
| 1335 | | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1336 | | ROM_LOAD16_BYTE( "870_h07.10n", 0x00000, 0x10000, CRC(b4dda612) SHA1(e9612af11a151de1f0236629c84679f80936cae9) ) |
| 1337 | | ROM_LOAD16_BYTE( "870_h06.8n", 0x00001, 0x10000, CRC(696ba702) SHA1(e35c9aeab4305d828a347eaddf4abc806a889fa3) ) |
| 1338 | | |
| 1339 | 1325 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1340 | 1326 | ROM_LOAD16_BYTE( "870_h05.6n", 0x00000, 0x10000, CRC(2bcfeef3) SHA1(8843e795a310e1a79b7b65226d9526197c2144ef) ) |
| 1341 | 1327 | ROM_LOAD16_BYTE( "870_h04.4n", 0x00001, 0x10000, CRC(b9f97fd3) SHA1(d15a659f753f9f475dfd4f7e96789bacc54cb1f9) ) |
| 1342 | 1328 | ROM_LOAD16_BYTE( "870_h09.6r", 0x20000, 0x10000, CRC(96a4f8b1) SHA1(2709f5236235b1b69c3367054fb998c1beb35625) ) |
| 1343 | 1329 | ROM_LOAD16_BYTE( "870_h08.4r", 0x20001, 0x10000, CRC(46d65156) SHA1(6dd9d97a8e3394db668da1fc6a46c166bca1f456) ) |
| 1344 | 1330 | |
| 1331 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1332 | ROM_LOAD16_BYTE( "870_h07.10n", 0x00000, 0x10000, CRC(b4dda612) SHA1(e9612af11a151de1f0236629c84679f80936cae9) ) |
| 1333 | ROM_LOAD16_BYTE( "870_h06.8n", 0x00001, 0x10000, CRC(696ba702) SHA1(e35c9aeab4305d828a347eaddf4abc806a889fa3) ) |
| 1334 | |
| 1335 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1336 | ROM_LOAD( "870_g03.10a", 0x00000, 0x8000, CRC(db9c10c8) SHA1(b2ec4d6800a4ab00dfcc8d3cd4abf9b9d7c5544a) ) |
| 1337 | |
| 1345 | 1338 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1346 | 1339 | ROM_LOAD( "870_f14.d8", 0x0000, 0x4000, CRC(c9b46615) SHA1(c0cddb1af47b8e0865055624cf4e89a111ac1b0f) ) // characters |
| 1347 | 1340 | |
| 1348 | 1341 | ROM_REGION16_LE( 0x200000, "gfx2", 0 ) // gfx data used at runtime |
| 1349 | | ROM_LOAD16_WORD("870c17.p16", 0x000000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) ) |
| 1350 | | ROM_LOAD16_WORD("870c18.p18", 0x080000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) ) |
| 1351 | | ROM_LOAD16_WORD("870c15.p13", 0x100000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) ) |
| 1352 | | ROM_LOAD16_WORD("870c16.p15", 0x180000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) ) |
| 1342 | ROM_LOAD16_WORD("870c17.p16", 0x000000, 0x80000, CRC(2bc99ff8) SHA1(9a06502317a71ca5662b79aedf47379b8e5434a9) ) |
| 1343 | ROM_LOAD16_WORD("870c18.p18", 0x080000, 0x80000, CRC(07927fe8) SHA1(0ab5e0e785347fbed5c4b930a32876d6ce2bef4a) ) |
| 1344 | ROM_LOAD16_WORD("870c15.p13", 0x100000, 0x80000, CRC(8c9281df) SHA1(5e3d80be414db108d5363d0ea1b74021ba942c33) ) |
| 1345 | ROM_LOAD16_WORD("870c16.p15", 0x180000, 0x80000, CRC(41df6a1b) SHA1(32e0fdeb53628d18adde851e4496dd01ac6ec68f) ) |
| 1353 | 1346 | |
| 1354 | 1347 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1355 | 1348 | ROM_LOAD( "870_c01.5a", 0x00000, 0x20000, CRC(6af96546) SHA1(63b49b28c0f2ef8f52bc4c5955ad6a633dd553cf) ) |
| 1356 | 1349 | |
| 1357 | | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1350 | ROM_REGION( 0x20000, "upd", 0 ) // samples |
| 1358 | 1351 | ROM_LOAD( "870_c02.7c", 0x00000, 0x20000, CRC(54e12c6d) SHA1(8171441aeb1a1dc4d65fae59c7c217f992f70cbc) ) |
| 1359 | 1352 | ROM_END |
| 1360 | 1353 | |
| 1361 | 1354 | ROM_START( miaj ) |
| 1362 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1363 | | ROM_LOAD( "808_e03.10a", 0x00000, 0x8000, CRC(3d93a7cd) SHA1(dcdd327e78f32436b276d0666f62a5b733b296e8) ) |
| 1355 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1356 | ROM_LOAD16_BYTE("808_r05.6n", 0x00000, 0x10000, CRC(91fd83f4) SHA1(12cba5828d1d752efe4fc1972bed0205ac277850) ) |
| 1357 | ROM_LOAD16_BYTE("808_r04.4n", 0x00001, 0x10000, CRC(f1c8c597) SHA1(4e8e87aedc9dac4ed05816989210de49f4dd60d2) ) |
| 1358 | ROM_LOAD16_BYTE("808_r09.6r", 0x20000, 0x10000, CRC(f74d4467) SHA1(2b2491ee7ece979f2ec849075b0c30b6c1ed6bae) ) |
| 1359 | ROM_LOAD16_BYTE("808_r08.4r", 0x20001, 0x10000, CRC(26f21704) SHA1(123cb2e4bcb25d82faa75e4505f9859c10bca754) ) |
| 1364 | 1360 | |
| 1365 | | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1361 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1366 | 1362 | ROM_LOAD16_BYTE("808_e07.10n", 0x00000, 0x10000, CRC(297bdcea) SHA1(41ed650cbc4f56777fa352812e9a560554459f90) ) |
| 1367 | | ROM_LOAD16_BYTE("808_e06.8n", 0x00001, 0x10000, CRC(8f576b33) SHA1(cd8c9a45626c30571ca12d0241cccc092c0903a0) ) |
| 1363 | ROM_LOAD16_BYTE("808_e06.8n", 0x00001, 0x10000, CRC(8f576b33) SHA1(cd8c9a45626c30571ca12d0241cccc092c0903a0) ) |
| 1368 | 1364 | ROM_LOAD16_BYTE("808_e13.10s", 0x20000, 0x10000, CRC(1fa708f4) SHA1(9511a19f50fb61571c2986c72d1a85e87b8d0495) ) |
| 1369 | | ROM_LOAD16_BYTE("808_e12.8s", 0x20001, 0x10000, CRC(d62f1fde) SHA1(1e55084f1294b6ac7c152fcd1800511fcab5d360) ) |
| 1365 | ROM_LOAD16_BYTE("808_e12.8s", 0x20001, 0x10000, CRC(d62f1fde) SHA1(1e55084f1294b6ac7c152fcd1800511fcab5d360) ) |
| 1370 | 1366 | |
| 1371 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1372 | | ROM_LOAD16_BYTE("808_r05.6n", 0x00000, 0x10000, CRC(91fd83f4) SHA1(12cba5828d1d752efe4fc1972bed0205ac277850) ) |
| 1373 | | ROM_LOAD16_BYTE("808_r04.4n", 0x00001, 0x10000, CRC(f1c8c597) SHA1(4e8e87aedc9dac4ed05816989210de49f4dd60d2) ) |
| 1374 | | ROM_LOAD16_BYTE("808_r09.6r", 0x20000, 0x10000, CRC(f74d4467) SHA1(2b2491ee7ece979f2ec849075b0c30b6c1ed6bae) ) |
| 1375 | | ROM_LOAD16_BYTE("808_r08.4r", 0x20001, 0x10000, CRC(26f21704) SHA1(123cb2e4bcb25d82faa75e4505f9859c10bca754) ) |
| 1367 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1368 | ROM_LOAD( "808_e03.10a", 0x00000, 0x8000, CRC(3d93a7cd) SHA1(dcdd327e78f32436b276d0666f62a5b733b296e8) ) |
| 1376 | 1369 | |
| 1377 | 1370 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1378 | 1371 | ROM_LOAD("808_e14.d8", 0x0000, 0x4000, CRC(b9d36525) SHA1(53291c4911d7e1a5110539e4c57a11d0d530dc6f) ) // characters |
| 1379 | 1372 | |
| 1380 | 1373 | ROM_REGION16_LE( 0x200000, "gfx2", 0 ) // gfx data used at runtime |
| 1381 | | ROM_LOAD16_WORD("808d17.p16", 0x000000, 0x80000, CRC(d1299082) SHA1(c3c07b0517e7428ccd1cdf9e15aaf16d98e7c4cd) ) |
| 1382 | | ROM_LOAD16_WORD("808d15.p13", 0x100000, 0x80000, CRC(2b22a6b6) SHA1(8e1af0627a4eac045128c4096e2cfb59c3d2f5ef) ) |
| 1374 | ROM_LOAD16_WORD("808d17.p16", 0x000000, 0x80000, CRC(d1299082) SHA1(c3c07b0517e7428ccd1cdf9e15aaf16d98e7c4cd) ) |
| 1375 | ROM_LOAD16_WORD("808d15.p13", 0x100000, 0x80000, CRC(2b22a6b6) SHA1(8e1af0627a4eac045128c4096e2cfb59c3d2f5ef) ) |
| 1383 | 1376 | |
| 1384 | | ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 ) // tile data; mapped at 0x80000 on CPUB |
| 1377 | ROM_REGION( 0x20000, "gfx3", ROMREGION_ERASE00 ) // tile data; mapped at 0x80000 on CPUB |
| 1385 | 1378 | |
| 1386 | | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1379 | ROM_REGION( 0x20000, "konami", 0 ) // samples |
| 1387 | 1380 | ROM_LOAD("808_d01.5a", 0x00000, 0x20000, CRC(fd4d37c0) SHA1(ef91c6e7bb57c27a9a51729fffd1bfe3e806fb61) ) |
| 1388 | 1381 | |
| 1389 | | ROM_REGION( 0x20000, "upd", ROMREGION_ERASE00 ) // samples |
| 1382 | ROM_REGION( 0x20000, "upd", ROMREGION_ERASE00 ) // samples |
| 1390 | 1383 | ROM_END |
| 1391 | 1384 | |
| 1392 | 1385 | ROM_START( cuebrckj ) |
| 1393 | | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1394 | | ROM_LOAD( "903_d03.10a", 0x00000, 0x8000, CRC(455e855a) SHA1(cfdd54a5071862653ee94c0455301f4a7245fbd8) ) |
| 1386 | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1387 | ROM_LOAD16_BYTE( "903_e05.6n", 0x00000, 0x10000, CRC(8b556220) SHA1(dbe24133e74018c4fe9332519394cbb882c4ed5a) ) |
| 1388 | ROM_LOAD16_BYTE( "903_e04.4n", 0x00001, 0x10000, CRC(bf9c7927) SHA1(3a594b8846f7e6074ca54f8cd5fe2ba3b64ba740) ) |
| 1389 | ROM_LOAD16_BYTE( "903_e09.6r", 0x20000, 0x10000, CRC(2a77554d) SHA1(53eee99737333c8c4bbb9c757fd12488b6c4d3d8) ) |
| 1390 | ROM_LOAD16_BYTE( "903_e08.4r", 0x20001, 0x10000, CRC(c0a430c1) SHA1(bef737f12e9a79781a4cd795ffc108899757901d) ) |
| 1395 | 1391 | |
| 1396 | | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1392 | ROM_REGION( 0x40000, "sub", 0 ) // 68000 code (CPU B) |
| 1397 | 1393 | ROM_LOAD16_BYTE( "903_d07.10n", 0x00000, 0x10000, CRC(fc0edce7) SHA1(57e969a42c48a9464ec370d4605eaecb690d58ab) ) |
| 1398 | 1394 | ROM_LOAD16_BYTE( "903_d06.8n", 0x00001, 0x10000, CRC(b2cef6fe) SHA1(27d1d15f3a408e6166745cb6a159704a8cbb4584) ) |
| 1399 | 1395 | ROM_LOAD16_BYTE( "903_e13.10s", 0x20000, 0x10000, CRC(4fb5fb80) SHA1(3a59dae3846341289c31aa106684ebc45488ca45) ) |
| 1400 | 1396 | ROM_LOAD16_BYTE( "903_e12.8s", 0x20001, 0x10000, CRC(883e3097) SHA1(fe0fa1a2881a67223d741c400bb8c1a0c67946c1) ) |
| 1401 | 1397 | |
| 1402 | | ROM_REGION( 0x40000, "main", 0 ) // 68000 code (CPU A) |
| 1403 | | ROM_LOAD16_BYTE( "903_e05.6n", 0x00000, 0x10000, CRC(8b556220) SHA1(dbe24133e74018c4fe9332519394cbb882c4ed5a) ) |
| 1404 | | ROM_LOAD16_BYTE( "903_e04.4n", 0x00001, 0x10000, CRC(bf9c7927) SHA1(3a594b8846f7e6074ca54f8cd5fe2ba3b64ba740) ) |
| 1405 | | ROM_LOAD16_BYTE( "903_e09.6r", 0x20000, 0x10000, CRC(2a77554d) SHA1(53eee99737333c8c4bbb9c757fd12488b6c4d3d8) ) |
| 1406 | | ROM_LOAD16_BYTE( "903_e08.4r", 0x20001, 0x10000, CRC(c0a430c1) SHA1(bef737f12e9a79781a4cd795ffc108899757901d) ) |
| 1398 | ROM_REGION( 0x10000, "audio", 0 ) // Z80 code (sound CPU) |
| 1399 | ROM_LOAD( "903_d03.10a", 0x00000, 0x8000, CRC(455e855a) SHA1(cfdd54a5071862653ee94c0455301f4a7245fbd8) ) |
| 1407 | 1400 | |
| 1408 | 1401 | ROM_REGION( 0x4000, "gfx1", ROMREGION_DISPOSE ) |
| 1409 | 1402 | ROM_LOAD( "903_e14.d8", 0x0000, 0x4000, CRC(ddbebbd5) SHA1(df532f19a08cabb28d693e4cd445c47c9e35e5ff) ) // characters |
| r3514 | r3515 | |
| 1411 | 1404 | ROM_REGION( 0x200000, "gfx2", ROMREGION_ERASE00 ) // gfx data used at runtime |
| 1412 | 1405 | // unpopulated |
| 1413 | 1406 | |
| 1414 | | ROM_REGION16_BE( 0x20000, "gfx3", 0 ) // tile data; mapped at 0x80000 on CPUB |
| 1407 | ROM_REGION16_BE( 0x20000, "gfx3", 0 ) // tile data; mapped at 0x80000 on CPUB |
| 1415 | 1408 | ROM_LOAD16_BYTE( "903_e11.10r", 0x00000, 0x10000, CRC(5c41faf8) SHA1(f9eee6a7b92d3b3aa4320747da6390310522a2cf) ) |
| 1416 | 1409 | ROM_LOAD16_BYTE( "903_e10.8r", 0x00001, 0x10000, CRC(417576d4) SHA1(e84762743e3a1117b6ef7ea0b304877e4a719f75) ) |
| 1417 | 1410 | |
| 1418 | | ROM_REGION( 0x20000, "konami", ROMREGION_ERASE00 ) // samples |
| 1411 | ROM_REGION( 0x20000, "konami", ROMREGION_ERASE00 ) // samples |
| 1419 | 1412 | // unpopulated |
| 1420 | 1413 | |
| 1421 | | ROM_REGION( 0x20000, "upd", ROMREGION_ERASE00 ) // samples |
| 1414 | ROM_REGION( 0x20000, "upd", ROMREGION_ERASE00 ) // samples |
| 1422 | 1415 | // unpopulated |
| 1423 | 1416 | ROM_END |
| 1424 | 1417 | |
| r3514 | r3515 | |
| 1471 | 1464 | |
| 1472 | 1465 | /* Game Drivers */ |
| 1473 | 1466 | |
| 1474 | | GAME( 1987, devilw, 0, heavysync, devilw, twin16, ROT0, "Konami", "Devil World", 0 ) |
| 1475 | | GAME( 1987, majuu, devilw, heavysync, devilw, twin16, ROT0, "Konami", "Majuu no Ohkoku", 0 ) |
| 1476 | | GAME( 1987, darkadv, devilw, heavysync, darkadv, twin16, ROT0, "Konami", "Dark Adventure", 0 ) |
| 1477 | | GAME( 1988, vulcan, 0, vulcan, vulcan, twin16, ROT0, "Konami", "Vulcan Venture", 0 ) |
| 1478 | | GAME( 1988, gradius2, vulcan, vulcan, gradius2, twin16, ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan New Ver.)", 0 ) |
| 1479 | | GAME( 1988, grdius2a, vulcan, vulcan, vulcan, twin16, ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan Old Ver.)", 0 ) |
| 1480 | | GAME( 1988, grdius2b, vulcan, vulcan, vulcan, twin16, ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan Older Ver.)", 0 ) |
| 1467 | GAME( 1987, devilw, 0, devilw, devilw, twin16, ROT0, "Konami", "Devil World", 0 ) |
| 1468 | GAME( 1987, majuu, devilw, devilw, devilw, twin16, ROT0, "Konami", "Majuu no Ohkoku", 0 ) |
| 1469 | GAME( 1987, darkadv, devilw, devilw, darkadv, twin16, ROT0, "Konami", "Dark Adventure", 0 ) |
| 1470 | GAME( 1988, vulcan, 0, twin16, vulcan, twin16, ROT0, "Konami", "Vulcan Venture", 0 ) |
| 1471 | GAME( 1988, gradius2, vulcan, twin16, gradius2, twin16, ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan New Ver.)", 0 ) |
| 1472 | GAME( 1988, grdius2a, vulcan, twin16, vulcan, twin16, ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan Old Ver.)", 0 ) |
| 1473 | GAME( 1988, grdius2b, vulcan, twin16, vulcan, twin16, ROT0, "Konami", "Gradius II - GOFER no Yabou (Japan Older Ver.)", 0 ) |
| 1481 | 1474 | |
| 1482 | 1475 | GAME( 1988, fround, 0, fround, fround, fround, ROT0, "Konami", "The Final Round (version M)", 0 ) |
| 1483 | 1476 | GAME( 1988, froundl, fround, fround, fround, fround, ROT0, "Konami", "The Final Round (version L)", 0 ) |
| 1484 | 1477 | GAME( 1988, hpuncher, fround, hpuncher, fround, hpuncher, ROT0, "Konami", "Hard Puncher (Japan)", 0 ) |
| 1485 | | GAME( 1989, miaj, mia, mia, miaj, hpuncher, ROT0, "Konami", "M.I.A. - Missing in Action (Japan)", 0 ) |
| 1478 | GAME( 1989, miaj, mia, miaj, miaj, hpuncher, ROT0, "Konami", "M.I.A. - Missing in Action (Japan)", 0 ) |
| 1486 | 1479 | GAME( 1989, cuebrckj, cuebrick, cuebrckj, cuebrckj, cuebrckj, ROT0, "Konami", "Cue Brick (Japan)", 0 ) |
src/tools/src2html.c
| r3514 | r3515 | |
| 5 | 5 | Copyright Nicola Salmoria and the MAME Team. |
| 6 | 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | 7 | |
| 8 | **************************************************************************** |
| 9 | |
| 10 | Template file format: |
| 11 | |
| 12 | <html header> |
| 13 | <!--PATH--> = insert path |
| 14 | <!--CONTENT--> = insert content |
| 15 | <html footer> |
| 16 | |
| 8 | 17 | ***************************************************************************/ |
| 9 | 18 | |
| 10 | 19 | #include <stdio.h> |
| r3514 | r3515 | |
| 20 | 29 | CONSTANTS & DEFINES |
| 21 | 30 | ***************************************************************************/ |
| 22 | 31 | |
| 23 | | #define COMMENT_STYLE "color:#b30000" |
| 24 | | #define STRING_STYLE "color:#666" |
| 25 | | #define PREPROCESSOR_STYLE "color:#0000b3" |
| 26 | | #define KEYWORD_STYLE "color:#0000b3" |
| 27 | | #define MAMEWORD_STYLE "color:#7f007f" |
| 28 | | #define LINENUM_STYLE "color:#999" |
| 32 | #define PREPROC_CLASS "preproc" |
| 33 | #define KEYWORD_CLASS "keyword" |
| 34 | #define CUSTOM_CLASS "custom" |
| 29 | 35 | |
| 30 | 36 | |
| 31 | 37 | |
| r3514 | r3515 | |
| 97 | 103 | |
| 98 | 104 | static const token_entry dummy_token_table[] = |
| 99 | 105 | { |
| 100 | | { NULL, KEYWORD_STYLE } |
| 106 | { NULL, KEYWORD_CLASS } |
| 101 | 107 | }; |
| 102 | 108 | |
| 103 | 109 | |
| 104 | 110 | static const token_entry c_token_table[] = |
| 105 | 111 | { |
| 106 | | { "#define", PREPROCESSOR_STYLE }, |
| 107 | | { "#elif", PREPROCESSOR_STYLE }, |
| 108 | | { "#else", PREPROCESSOR_STYLE }, |
| 109 | | { "#endif", PREPROCESSOR_STYLE }, |
| 110 | | { "#error", PREPROCESSOR_STYLE }, |
| 111 | | { "#if", PREPROCESSOR_STYLE }, |
| 112 | | { "#ifdef", PREPROCESSOR_STYLE }, |
| 113 | | { "#ifndef", PREPROCESSOR_STYLE }, |
| 114 | | { "#include", PREPROCESSOR_STYLE }, |
| 115 | | { "#line", PREPROCESSOR_STYLE }, |
| 116 | | { "#pragma", PREPROCESSOR_STYLE }, |
| 117 | | { "#undef", PREPROCESSOR_STYLE }, |
| 112 | { "#define", PREPROC_CLASS }, |
| 113 | { "#elif", PREPROC_CLASS }, |
| 114 | { "#else", PREPROC_CLASS }, |
| 115 | { "#endif", PREPROC_CLASS }, |
| 116 | { "#error", PREPROC_CLASS }, |
| 117 | { "#if", PREPROC_CLASS }, |
| 118 | { "#ifdef", PREPROC_CLASS }, |
| 119 | { "#ifndef", PREPROC_CLASS }, |
| 120 | { "#include", PREPROC_CLASS }, |
| 121 | { "#line", PREPROC_CLASS }, |
| 122 | { "#pragma", PREPROC_CLASS }, |
| 123 | { "#undef", PREPROC_CLASS }, |
| 118 | 124 | |
| 119 | | { "auto", KEYWORD_STYLE }, |
| 120 | | { "break", KEYWORD_STYLE }, |
| 121 | | { "case", KEYWORD_STYLE }, |
| 122 | | { "char", KEYWORD_STYLE }, |
| 123 | | { "const", KEYWORD_STYLE }, |
| 124 | | { "continue", KEYWORD_STYLE }, |
| 125 | | { "default", KEYWORD_STYLE }, |
| 126 | | { "do", KEYWORD_STYLE }, |
| 127 | | { "double", KEYWORD_STYLE }, |
| 128 | | { "else", KEYWORD_STYLE }, |
| 129 | | { "enum", KEYWORD_STYLE }, |
| 130 | | { "extern", KEYWORD_STYLE }, |
| 131 | | { "float", KEYWORD_STYLE }, |
| 132 | | { "for", KEYWORD_STYLE }, |
| 133 | | { "goto", KEYWORD_STYLE }, |
| 134 | | { "if", KEYWORD_STYLE }, |
| 135 | | { "int", KEYWORD_STYLE }, |
| 136 | | { "long", KEYWORD_STYLE }, |
| 137 | | { "register", KEYWORD_STYLE }, |
| 138 | | { "return", KEYWORD_STYLE }, |
| 139 | | { "short", KEYWORD_STYLE }, |
| 140 | | { "signed", KEYWORD_STYLE }, |
| 141 | | { "sizeof", KEYWORD_STYLE }, |
| 142 | | { "static", KEYWORD_STYLE }, |
| 143 | | { "struct", KEYWORD_STYLE }, |
| 144 | | { "switch", KEYWORD_STYLE }, |
| 145 | | { "typedef", KEYWORD_STYLE }, |
| 146 | | { "union", KEYWORD_STYLE }, |
| 147 | | { "unsigned", KEYWORD_STYLE }, |
| 148 | | { "void", KEYWORD_STYLE }, |
| 149 | | { "volatile", KEYWORD_STYLE }, |
| 150 | | { "while", KEYWORD_STYLE }, |
| 125 | { "auto", KEYWORD_CLASS }, |
| 126 | { "break", KEYWORD_CLASS }, |
| 127 | { "case", KEYWORD_CLASS }, |
| 128 | { "char", KEYWORD_CLASS }, |
| 129 | { "const", KEYWORD_CLASS }, |
| 130 | { "continue", KEYWORD_CLASS }, |
| 131 | { "default", KEYWORD_CLASS }, |
| 132 | { "do", KEYWORD_CLASS }, |
| 133 | { "double", KEYWORD_CLASS }, |
| 134 | { "else", KEYWORD_CLASS }, |
| 135 | { "enum", KEYWORD_CLASS }, |
| 136 | { "extern", KEYWORD_CLASS }, |
| 137 | { "float", KEYWORD_CLASS }, |
| 138 | { "for", KEYWORD_CLASS }, |
| 139 | { "goto", KEYWORD_CLASS }, |
| 140 | { "if", KEYWORD_CLASS }, |
| 141 | { "int", KEYWORD_CLASS }, |
| 142 | { "long", KEYWORD_CLASS }, |
| 143 | { "register", KEYWORD_CLASS }, |
| 144 | { "return", KEYWORD_CLASS }, |
| 145 | { "short", KEYWORD_CLASS }, |
| 146 | { "signed", KEYWORD_CLASS }, |
| 147 | { "sizeof", KEYWORD_CLASS }, |
| 148 | { "static", KEYWORD_CLASS }, |
| 149 | { "struct", KEYWORD_CLASS }, |
| 150 | { "switch", KEYWORD_CLASS }, |
| 151 | { "typedef", KEYWORD_CLASS }, |
| 152 | { "union", KEYWORD_CLASS }, |
| 153 | { "unsigned", KEYWORD_CLASS }, |
| 154 | { "void", KEYWORD_CLASS }, |
| 155 | { "volatile", KEYWORD_CLASS }, |
| 156 | { "while", KEYWORD_CLASS }, |
| 151 | 157 | |
| 152 | 158 | /* |
| 153 | | { "INLINE", MAMEWORD_STYLE }, |
| 154 | | { "INT8", MAMEWORD_STYLE }, |
| 155 | | { "UINT8", MAMEWORD_STYLE }, |
| 156 | | { "INT16", MAMEWORD_STYLE }, |
| 157 | | { "UINT16", MAMEWORD_STYLE }, |
| 158 | | { "INT32", MAMEWORD_STYLE }, |
| 159 | | { "UINT32", MAMEWORD_STYLE }, |
| 160 | | { "INT64", MAMEWORD_STYLE }, |
| 161 | | { "UINT64", MAMEWORD_STYLE }, |
| 162 | | { "ARRAY_LENGTH", MAMEWORD_STYLE }, |
| 159 | { "INLINE", CUSTOM_CLASS }, |
| 160 | { "INT8", CUSTOM_CLASS }, |
| 161 | { "UINT8", CUSTOM_CLASS }, |
| 162 | { "INT16", CUSTOM_CLASS }, |
| 163 | { "UINT16", CUSTOM_CLASS }, |
| 164 | { "INT32", CUSTOM_CLASS }, |
| 165 | { "UINT32", CUSTOM_CLASS }, |
| 166 | { "INT64", CUSTOM_CLASS }, |
| 167 | { "UINT64", CUSTOM_CLASS }, |
| 168 | { "ARRAY_LENGTH", CUSTOM_CLASS }, |
| 163 | 169 | */ |
| 164 | | { NULL, KEYWORD_STYLE } |
| 170 | { NULL, KEYWORD_CLASS } |
| 165 | 171 | }; |
| 166 | 172 | |
| 167 | 173 | |
| r3514 | r3515 | |
| 171 | 177 | ***************************************************************************/ |
| 172 | 178 | |
| 173 | 179 | /* core output functions */ |
| 174 | | static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir); |
| 175 | | static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file); |
| 180 | static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir, const astring *tempheader, const astring *tempfooter); |
| 181 | static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file, const astring *tempheader, const astring *tempfooter); |
| 176 | 182 | |
| 177 | 183 | /* HTML helpers */ |
| 178 | | static core_file *create_file_and_output_header(const astring *filename, const char *title, const char *subtitle); |
| 179 | | static void output_footer_and_close_file(core_file *file); |
| 184 | static core_file *create_file_and_output_header(const astring *filename, const astring *template, const astring *path); |
| 185 | static void output_footer_and_close_file(core_file *file, const astring *template, const astring *path); |
| 180 | 186 | |
| 181 | 187 | /* path helpers */ |
| 182 | 188 | static const astring *normalized_subpath(const astring *path, int start); |
| r3514 | r3515 | |
| 195 | 201 | |
| 196 | 202 | int main(int argc, char *argv[]) |
| 197 | 203 | { |
| 198 | | astring *srcdir = NULL, *dstdir = NULL; |
| 204 | astring *srcdir = NULL, *dstdir = NULL, *tempfilename = NULL, *tempheader = NULL, *tempfooter = NULL; |
| 205 | core_file *tempfile; |
| 199 | 206 | int unadorned = 0; |
| 200 | 207 | int result; |
| 201 | 208 | int argnum; |
| r3514 | r3515 | |
| 228 | 235 | dstdir = astring_dupc(arg); |
| 229 | 236 | unadorned++; |
| 230 | 237 | } |
| 238 | else if (arg[0] != '-' && unadorned == 2) |
| 239 | { |
| 240 | tempfilename = astring_dupc(arg); |
| 241 | unadorned++; |
| 242 | } |
| 231 | 243 | else |
| 232 | 244 | goto usage; |
| 233 | 245 | } |
| 234 | 246 | |
| 235 | | /* make sure we got 2 parameters */ |
| 236 | | if (srcdir == NULL || dstdir == NULL) |
| 247 | /* make sure we got 3 parameters */ |
| 248 | if (srcdir == NULL || dstdir == NULL || tempfilename == NULL) |
| 237 | 249 | goto usage; |
| 238 | 250 | |
| 251 | /* read the template file into an astring */ |
| 252 | if (core_fopen(astring_c(tempfilename), OPEN_FLAG_READ, &tempfile) == FILERR_NONE) |
| 253 | { |
| 254 | UINT64 filesize = core_fsize(tempfile); |
| 255 | void *buffer = malloc(filesize); |
| 256 | if (buffer != NULL) |
| 257 | { |
| 258 | core_fread(tempfile, buffer, filesize); |
| 259 | tempheader = astring_dupch(buffer, filesize); |
| 260 | free(buffer); |
| 261 | } |
| 262 | core_fclose(tempfile); |
| 263 | } |
| 264 | |
| 265 | /* verify the template */ |
| 266 | if (tempheader == NULL) |
| 267 | { |
| 268 | fprintf(stderr, "Unable to read template file\n"); |
| 269 | return 1; |
| 270 | } |
| 271 | result = astring_findc(tempheader, 0, "<!--CONTENT-->"); |
| 272 | if (result == -1) |
| 273 | { |
| 274 | fprintf(stderr, "Template is missing a <!--CONTENT--> marker\n"); |
| 275 | return 1; |
| 276 | } |
| 277 | tempfooter = astring_substr(astring_dup(tempheader), result + 14, -1); |
| 278 | tempheader = astring_substr(tempheader, 0, result); |
| 279 | |
| 239 | 280 | /* recurse over subdirectories */ |
| 240 | | result = recurse_dir(astring_len(srcdir), astring_len(dstdir), srcdir, dstdir); |
| 281 | result = recurse_dir(astring_len(srcdir), astring_len(dstdir), srcdir, dstdir, tempheader, tempfooter); |
| 241 | 282 | |
| 242 | 283 | /* free source and destination directories */ |
| 243 | 284 | astring_free(srcdir); |
| 244 | 285 | astring_free(dstdir); |
| 286 | astring_free(tempfilename); |
| 287 | astring_free(tempheader); |
| 288 | astring_free(tempfooter); |
| 245 | 289 | return result; |
| 246 | 290 | |
| 247 | 291 | usage: |
| 248 | | fprintf(stderr, "Usage:\n%s <srcroot> <destroot> [-Iincpath [-Iincpath [...]]]\n", argv[0]); |
| 292 | fprintf(stderr, "Usage:\n%s <srcroot> <destroot> <template.html> [-Iincpath [-Iincpath [...]]]\n", argv[0]); |
| 249 | 293 | return 1; |
| 250 | 294 | } |
| 251 | 295 | |
| r3514 | r3515 | |
| 267 | 311 | recurse_dir - recurse through a directory |
| 268 | 312 | -------------------------------------------------*/ |
| 269 | 313 | |
| 270 | | static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir) |
| 314 | static int recurse_dir(int srcrootlen, int dstrootlen, const astring *srcdir, const astring *dstdir, const astring *tempheader, const astring *tempfooter) |
| 271 | 315 | { |
| 272 | 316 | static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE }; |
| 273 | 317 | const astring *srcdir_subpath; |
| r3514 | r3515 | |
| 284 | 328 | /* create an index file */ |
| 285 | 329 | indexname = astring_alloc(); |
| 286 | 330 | astring_printf(indexname, "%s%c%s", astring_c(dstdir), PATH_SEPARATOR[0], "index.html"); |
| 287 | | indexfile = create_file_and_output_header(indexname, "MAME Source Code", astring_c(srcdir_subpath)); |
| 331 | indexfile = create_file_and_output_header(indexname, tempheader, srcdir_subpath); |
| 288 | 332 | astring_free(indexname); |
| 289 | 333 | |
| 290 | 334 | /* output the directory navigation */ |
| 291 | 335 | core_fprintf(indexfile, "<h3>Viewing Directory: "); |
| 292 | 336 | output_path_as_links(indexfile, srcdir_subpath, TRUE, FALSE); |
| 293 | 337 | core_fprintf(indexfile, "</h3>"); |
| 294 | | astring_free((astring *)srcdir_subpath); |
| 295 | 338 | |
| 296 | 339 | /* iterate first over directories, then over files */ |
| 297 | 340 | for (entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++) |
| 298 | 341 | { |
| 299 | 342 | osd_dir_entry_type entry_type = typelist[entindex]; |
| 300 | 343 | const osd_directory_entry *entry; |
| 344 | list_entry **listarray = NULL; |
| 301 | 345 | list_entry *list = NULL; |
| 302 | | list_entry **listarray; |
| 303 | 346 | list_entry *curlist; |
| 304 | 347 | osd_directory *dir; |
| 305 | 348 | int found = 0; |
| r3514 | r3515 | |
| 346 | 389 | listarray[found]->next = list; |
| 347 | 390 | list = listarray[found]; |
| 348 | 391 | } |
| 392 | free(listarray); |
| 349 | 393 | |
| 350 | 394 | /* iterate through each file */ |
| 351 | 395 | for (curlist = list; curlist != NULL && result == 0; curlist = curlist->next) |
| r3514 | r3515 | |
| 381 | 425 | astring_printf(dstfile, "%s%c%s.html", astring_c(dstdir), PATH_SEPARATOR[0], astring_c(curlist->name)); |
| 382 | 426 | if (indexfile != NULL) |
| 383 | 427 | core_fprintf(indexfile, "\t<li><a href=\"%s.html\">%s</a></li>\n", astring_c(curlist->name), astring_c(curlist->name)); |
| 384 | | result = output_file(type, srcrootlen, dstrootlen, srcfile, dstfile, astring_cmp(srcdir, dstdir) == 0); |
| 428 | result = output_file(type, srcrootlen, dstrootlen, srcfile, dstfile, astring_cmp(srcdir, dstdir) == 0, tempheader, tempfooter); |
| 385 | 429 | } |
| 386 | 430 | } |
| 387 | 431 | |
| r3514 | r3515 | |
| 391 | 435 | astring_printf(dstfile, "%s%c%s", astring_c(dstdir), PATH_SEPARATOR[0], astring_c(curlist->name)); |
| 392 | 436 | if (indexfile != NULL) |
| 393 | 437 | core_fprintf(indexfile, "\t<li><a href=\"%s/index.html\">%s/</a></li>\n", astring_c(curlist->name), astring_c(curlist->name)); |
| 394 | | result = recurse_dir(srcrootlen, dstrootlen, srcfile, dstfile); |
| 438 | result = recurse_dir(srcrootlen, dstrootlen, srcfile, dstfile, tempheader, tempfooter); |
| 395 | 439 | } |
| 396 | 440 | |
| 397 | 441 | /* free memory for the names */ |
| r3514 | r3515 | |
| 415 | 459 | |
| 416 | 460 | error: |
| 417 | 461 | if (indexfile != NULL) |
| 418 | | output_footer_and_close_file(indexfile); |
| 462 | output_footer_and_close_file(indexfile, tempfooter, srcdir_subpath); |
| 463 | astring_free((astring *)srcdir_subpath); |
| 419 | 464 | return result; |
| 420 | 465 | } |
| 421 | 466 | |
| r3514 | r3515 | |
| 425 | 470 | HTML |
| 426 | 471 | -------------------------------------------------*/ |
| 427 | 472 | |
| 428 | | static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file) |
| 473 | static int output_file(file_type type, int srcrootlen, int dstrootlen, const astring *srcfile, const astring *dstfile, int link_to_file, const astring *tempheader, const astring *tempfooter) |
| 429 | 474 | { |
| 430 | 475 | const char *comment_start, *comment_end, *comment_inline, *token_chars; |
| 431 | 476 | const char *comment_start_esc, *comment_end_esc, *comment_inline_esc; |
| r3514 | r3515 | |
| 497 | 542 | } |
| 498 | 543 | |
| 499 | 544 | /* open the output file */ |
| 500 | | dst = create_file_and_output_header(dstfile, "MAME Source Code", astring_c(srcfile_subpath)); |
| 545 | dst = create_file_and_output_header(dstfile, tempheader, srcfile_subpath); |
| 501 | 546 | if (dst == NULL) |
| 502 | 547 | { |
| 503 | 548 | fprintf(stderr, "Unable to write file '%s'\n", astring_c(dstfile)); |
| r3514 | r3515 | |
| 509 | 554 | core_fprintf(dst, "<h3>Viewing File: "); |
| 510 | 555 | output_path_as_links(dst, srcfile_subpath, FALSE, link_to_file); |
| 511 | 556 | core_fprintf(dst, "</h3>"); |
| 512 | | astring_free((astring *)srcfile_subpath); |
| 513 | 557 | |
| 514 | 558 | /* start with some tags */ |
| 515 | | core_fprintf(dst, "\t<pre style=\"font-family:'Courier New','Courier',monospace; font-size:12px;\">\n"); |
| 559 | core_fprintf(dst, "\t<pre class=\"source\">\n"); |
| 516 | 560 | |
| 517 | 561 | /* iterate over lines in the source file */ |
| 518 | 562 | while (core_fgets(srcline, ARRAY_LENGTH(srcline), src) != NULL) |
| r3514 | r3515 | |
| 526 | 570 | int curcol = 0; |
| 527 | 571 | |
| 528 | 572 | /* start with the line number */ |
| 529 | | dstptr += sprintf(dstptr, "<span style=\"" LINENUM_STYLE "\">%5d</span> ", linenum++); |
| 573 | dstptr += sprintf(dstptr, "<span class=\"linenum\">%5d</span> ", linenum++); |
| 530 | 574 | |
| 531 | 575 | /* iterate over characters in the source line */ |
| 532 | 576 | for (srcptr = srcline; *srcptr != 0; ) |
| r3514 | r3515 | |
| 538 | 582 | { |
| 539 | 583 | if (!in_comment && ch == comment_start[0] && strncmp(srcptr - 1, comment_start, strlen(comment_start)) == 0) |
| 540 | 584 | { |
| 541 | | dstptr += sprintf(dstptr, "<span style=\"" COMMENT_STYLE "\">%s", comment_start_esc); |
| 585 | dstptr += sprintf(dstptr, "<span class=\"comment\">%s", comment_start_esc); |
| 542 | 586 | curcol += strlen(comment_start); |
| 543 | 587 | srcptr += strlen(comment_start) - 1; |
| 544 | 588 | ch = 0; |
| r3514 | r3515 | |
| 557 | 601 | /* track whether or not we are within an inline (C++-style) comment */ |
| 558 | 602 | if (!in_quotes && !in_comment && !in_inline_comment && ch == comment_inline[0] && strncmp(srcptr - 1, comment_inline, strlen(comment_inline)) == 0) |
| 559 | 603 | { |
| 560 | | dstptr += sprintf(dstptr, "<span style=\"" COMMENT_STYLE "\">%s", comment_inline_esc); |
| 604 | dstptr += sprintf(dstptr, "<span class=\"comment\">%s", comment_inline_esc); |
| 561 | 605 | curcol += strlen(comment_inline); |
| 562 | 606 | srcptr += strlen(comment_inline) - 1; |
| 563 | 607 | ch = 0; |
| r3514 | r3515 | |
| 581 | 625 | for (curtoken = token_table; curtoken->token != NULL; curtoken++) |
| 582 | 626 | if (strncmp(srcptr - 1, curtoken->token, toklength) == 0 && strlen(curtoken->token) == toklength) |
| 583 | 627 | { |
| 584 | | dstptr += sprintf(dstptr, "<span style=\"%s\">%s</span>", curtoken->color, curtoken->token); |
| 628 | dstptr += sprintf(dstptr, "<span class=\"%s\">%s</span>", curtoken->color, curtoken->token); |
| 585 | 629 | curcol += strlen(curtoken->token); |
| 586 | 630 | srcptr += strlen(curtoken->token) - 1; |
| 587 | 631 | ch = 0; |
| r3514 | r3515 | |
| 613 | 657 | if (!in_comment && !in_inline_comment && !in_quotes && (ch == '"' || ch == '\'')) |
| 614 | 658 | { |
| 615 | 659 | if (color_quotes) |
| 616 | | dstptr += sprintf(dstptr, "<span style=\"" STRING_STYLE "\">%c", ch); |
| 660 | dstptr += sprintf(dstptr, "<span class=\"string\">%c", ch); |
| 617 | 661 | else |
| 618 | 662 | *dstptr++ = ch; |
| 619 | 663 | in_quotes = ch; |
| r3514 | r3515 | |
| 679 | 723 | core_fprintf(dst, "\t</pre>\n"); |
| 680 | 724 | |
| 681 | 725 | /* close the file */ |
| 682 | | output_footer_and_close_file(dst); |
| 726 | output_footer_and_close_file(dst, tempfooter, srcfile_subpath); |
| 727 | astring_free((astring *)srcfile_subpath); |
| 683 | 728 | core_fclose(src); |
| 684 | 729 | return 0; |
| 685 | 730 | } |
| r3514 | r3515 | |
| 695 | 740 | HTML file with a standard header |
| 696 | 741 | -------------------------------------------------*/ |
| 697 | 742 | |
| 698 | | static core_file *create_file_and_output_header(const astring *filename, const char *title, const char *subtitle) |
| 743 | static core_file *create_file_and_output_header(const astring *filename, const astring *template, const astring *path) |
| 699 | 744 | { |
| 745 | astring *modified; |
| 700 | 746 | core_file *file; |
| 701 | 747 | |
| 702 | 748 | /* create the indexfile */ |
| r3514 | r3515 | |
| 704 | 750 | return NULL; |
| 705 | 751 | |
| 706 | 752 | /* print a header */ |
| 707 | | core_fprintf(file, |
| 708 | | "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" |
| 709 | | "\n" |
| 710 | | "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" |
| 711 | | "<head>\n" |
| 712 | | "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" |
| 713 | | "\t<title>%s</title>\n" |
| 714 | | "\t<link rel=\"stylesheet\" href=\"http://mamedev.org/styles-site.css\" type=\"text/css\" />\n" |
| 715 | | "</head>\n" |
| 716 | | "\n" |
| 717 | | "<body>\n" |
| 718 | | "\t<div id=\"outer\">\n" |
| 719 | | "\n" |
| 720 | | "\t<div id=\"banner\">\n" |
| 721 | | "\t<h1>%s</h1>\n" |
| 722 | | "\t<h2>%s</h2>\n" |
| 723 | | "\t</div>\n" |
| 724 | | "\n" |
| 725 | | "\t<div id=\"left\">\n" |
| 726 | | "\t<div class=\"sidebar\">\n" |
| 727 | | "\t<!--#include virtual=\"/links.txt\" -->\n" |
| 728 | | "\t</div>\n" |
| 729 | | "\t</div>\n" |
| 730 | | "\n" |
| 731 | | "\t<div id=\"center\">\n" |
| 732 | | "\t<div class=\"content\">\n" |
| 733 | | "\n", |
| 734 | | title, title, (subtitle == NULL) ? " " : subtitle |
| 735 | | ); |
| 753 | modified = astring_dup(template); |
| 754 | astring_replacec(modified, 0, "<!--PATH-->", astring_c(path)); |
| 755 | core_fwrite(file, astring_c(modified), astring_len(modified)); |
| 736 | 756 | |
| 737 | 757 | /* return the file */ |
| 758 | astring_free(modified); |
| 738 | 759 | return file; |
| 739 | 760 | } |
| 740 | 761 | |
| r3514 | r3515 | |
| 744 | 765 | standard footer to an HTML file and close it |
| 745 | 766 | -------------------------------------------------*/ |
| 746 | 767 | |
| 747 | | static void output_footer_and_close_file(core_file *file) |
| 768 | static void output_footer_and_close_file(core_file *file, const astring *template, const astring *path) |
| 748 | 769 | { |
| 749 | | core_fprintf(file, |
| 750 | | "\n" |
| 751 | | "\t</div>\n" |
| 752 | | "\t</div>\n" |
| 753 | | "\t</div>\n" |
| 754 | | "</body>" |
| 755 | | "\n" |
| 756 | | "</html>\n" |
| 757 | | ); |
| 770 | astring *modified; |
| 771 | |
| 772 | modified = astring_dup(template); |
| 773 | astring_replacec(modified, 0, "<!--PATH-->", astring_c(path)); |
| 774 | core_fwrite(file, astring_c(modified), astring_len(modified)); |
| 775 | astring_free(modified); |
| 758 | 776 | core_fclose(file); |
| 759 | 777 | } |
| 760 | 778 | |
src/emu/cpu/mcs51/mcs51.c
| r0 | r3515 | |
| 1 | /***************************************************************************** |
| 2 | * |
| 3 | * i8051.c |
| 4 | * Portable MCS-51 Family Emulator |
| 5 | * |
| 6 | * Chips in the family: |
| 7 | * 8051 Product Line (8031,8051,8751) |
| 8 | * 8052 Product Line (8032,8052,8752) |
| 9 | * 8054 Product Line (8054) |
| 10 | * 8058 Product Line (8058) |
| 11 | * |
| 12 | * Copyright Steve Ellenoff, all rights reserved. |
| 13 | * |
| 14 | * - This source code is released as freeware for non-commercial purposes. |
| 15 | * - You are free to use and redistribute this code in modified or |
| 16 | * unmodified form, provided you list me in the credits. |
| 17 | * - If you modify this source code, you must add a notice to each modified |
| 18 | * source file that it has been changed. If you're a nice person, you |
| 19 | * will clearly mark each change too. :) |
| 20 | * - If you wish to use this for commercial purposes, please contact me at |
| 21 | * sellenoff@hotmail.com |
| 22 | * - The author of this copywritten work reserves the right to change the |
| 23 | * terms of its usage and license at any time, including retroactively |
| 24 | * - This entire notice must remain in the source code. |
| 25 | * |
| 26 | * This work is based on: |
| 27 | * #1) 'Intel(tm) MC51 Microcontroller Family Users Manual' and |
| 28 | * #2) 8051 simulator by Travis Marlatte |
| 29 | * #3) Portable UPI-41/8041/8741/8042/8742 emulator V0.1 by Juergen Buchmueller (MAME CORE) |
| 30 | * |
| 31 | *****************************************************************************/ |
| 32 | |
| 33 | /****************************************************************************** |
| 34 | * Notes: |
| 35 | * *Important*: Internal ROM needs to be treated the same as external rom by the programmer |
| 36 | * creating the driver (ie, use standard cpu rom region) |
| 37 | * |
| 38 | * The term cycles is used here to really refer to clock oscilations, because 1 machine cycle |
| 39 | * actually takes 12 oscilations. |
| 40 | * |
| 41 | * Read/Write/Modify Instruction - |
| 42 | * Data is read from the Port Latch (not the Port Pin!), possibly modified, and |
| 43 | * written back to (the pin? and) the latch! |
| 44 | * |
| 45 | * The following all perform this on a port address.. |
| 46 | * (anl, orl, xrl, jbc, cpl, inc, dec, djnz, mov px.y,c, clr px.y, setb px.y) |
| 47 | * |
| 48 | * Serial UART emulation is not really accurate, but faked enough to work as far as i can tell |
| 49 | * |
| 50 | * August 27,2003: Currently support for only 8031/8051/8751 chips (ie 128 RAM) |
| 51 | * October 14,2003: Added initial support for the 8752 (ie 256 RAM) |
| 52 | * October 22,2003: Full support for the 8752 (ie 256 RAM) |
| 53 | * July 28,2004: Fixed MOVX command and added External Ram Paging Support |
| 54 | * July 31,2004: Added Serial Mode 0 Support & Fixed Interrupt Flags for Serial Port |
| 55 | * |
| 56 | * NOW Implemented: RAM paging using hardware configured addressing... |
| 57 | * (July 28,2004) the "MOVX a,@R0/R1" and "MOVX @R0/R1,a" commands can use any of the other ports |
| 58 | * to output a page offset into external ram, but it is totally based on the hardware setup. |
| 59 | * |
| 60 | * Timing needs to be implemented via MAME timers perhaps? |
| 61 | * |
| 62 | * October, 2008, Couriersud - Major rewrite |
| 63 | * |
| 64 | *****************************************************************************/ |
| 65 | |
| 66 | /* TODO: Varios |
| 67 | * - EA pin - defined by architecture, must implement: |
| 68 | * 1 means external access, bypassing internal ROM |
| 69 | * - T0 output clock ? |
| 70 | * |
| 71 | * - Implement 80C52 extended serial capabilities |
| 72 | * - Full Timer support (all modes) |
| 73 | * - Fix serial communication - This is a big hack (but working) right now. |
| 74 | * - Implement 83C751 in sslam.c |
| 75 | * - Fix cardline.c |
| 76 | * - Fix sslam.c and cardline.c |
| 77 | * most likely due to different behaviour of I/O pins. The boards |
| 78 | * actually use 80CXX, i.e. CMOS versions. |
| 79 | * "Normal" 805X will return a 0 if reading from a output port which has |
| 80 | * a 0 written to it's latch. At least cardline expects a 1 here. |
| 81 | * |
| 82 | * Done: |
| 83 | * - Implemented cmos features |
| 84 | * - Implemented 80C52 interrupt handling |
| 85 | * - Fix segas18.c (segaic16.c) memory handling. |
| 86 | * - Fix sslam.c |
| 87 | * - Fix limenko.c videopkr.c : Issue with core allocation of ram (duplicate savestate) |
| 88 | * - Handle internal ram better (debugger visible) |
| 89 | * - Fixed port reading |
| 90 | * - Rewrote Macros for better readibility |
| 91 | * - Fixed and rewrote Interrupt handling |
| 92 | * - Now returns INTERNAL_DIVIDER, adjusted cycle counts |
| 93 | * - Remove unnecessary and duplicated code |
| 94 | * - Remove unnecessary functions |
| 95 | * - Rewrite to have sfr-registers stored in int_ram. |
| 96 | * - Debugger may now watch sfr-registers as well. |
| 97 | * - implemented interrupt callbacks (HOLD_LINE now supported) |
| 98 | * - Runtime switch for processor type - remove ifdefs |
| 99 | * - internal memory maps for internal rom versions (internal ram now displayed in debugger) |
| 100 | * - more timer cleanups from manual |
| 101 | */ |
| 102 | |
| 103 | #include "debugger.h" |
| 104 | #include "deprecat.h" |
| 105 | #include "mcs51.h" |
| 106 | |
| 107 | #define VERBOSE 1 |
| 108 | |
| 109 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 110 | |
| 111 | /*************************************************************************** |
| 112 | CONSTANTS |
| 113 | ***************************************************************************/ |
| 114 | |
| 115 | enum |
| 116 | { |
| 117 | FEATURE_NONE = 0x00, |
| 118 | FEATURE_I8052 = 0x01, |
| 119 | FEATURE_CMOS = 0x02, |
| 120 | FEATURE_I80C52 = 0x04, |
| 121 | FEATURE_DS5002FP = 0x08, |
| 122 | }; |
| 123 | |
| 124 | /* Internal address in SFR of registers */ |
| 125 | enum |
| 126 | { |
| 127 | ADDR_PSW = 0xd0, |
| 128 | ADDR_ACC = 0xe0, |
| 129 | ADDR_B = 0xf0, |
| 130 | |
| 131 | ADDR_P0 = 0x80, |
| 132 | ADDR_SP = 0x81, |
| 133 | ADDR_DPL = 0x82, |
| 134 | ADDR_DPH = 0x83, |
| 135 | ADDR_PCON = 0x87, |
| 136 | ADDR_TCON = 0x88, |
| 137 | ADDR_TMOD = 0x89, |
| 138 | ADDR_TL0 = 0x8a, |
| 139 | ADDR_TL1 = 0x8b, |
| 140 | ADDR_TH0 = 0x8c, |
| 141 | ADDR_TH1 = 0x8d, |
| 142 | ADDR_P1 = 0x90, |
| 143 | ADDR_SCON = 0x98, |
| 144 | ADDR_SBUF = 0x99, |
| 145 | ADDR_P2 = 0xa0, |
| 146 | ADDR_IE = 0xa8, |
| 147 | ADDR_P3 = 0xb0, |
| 148 | ADDR_IP = 0xb8, |
| 149 | |
| 150 | /* 8052 Only registers */ |
| 151 | ADDR_T2CON = 0xc8, |
| 152 | ADDR_RCAP2L = 0xca, |
| 153 | ADDR_RCAP2H = 0xcb, |
| 154 | ADDR_TL2 = 0xcc, |
| 155 | ADDR_TH2 = 0xcd, |
| 156 | |
| 157 | /* 80C52 Only registers */ |
| 158 | ADDR_IPH = 0xb7, |
| 159 | ADDR_SADDR = 0xa9, |
| 160 | ADDR_SADEN = 0xb9, |
| 161 | |
| 162 | /* Philips 80C52 */ |
| 163 | ADDR_AUXR = 0x8e, |
| 164 | ADDR_AUXR1 = 0xa2, |
| 165 | |
| 166 | /* DS5002FP */ |
| 167 | ADDR_CRCR = 0xc1, |
| 168 | ADDR_CRCL = 0xc2, |
| 169 | ADDR_CRCH = 0xc3, |
| 170 | ADDR_MCON = 0xc6, |
| 171 | ADDR_TA = 0xc7, |
| 172 | ADDR_RNR = 0xcf, |
| 173 | ADDR_RPCTL = 0xd8, |
| 174 | ADDR_RPS = 0xda, |
| 175 | |
| 176 | }; |
| 177 | |
| 178 | /* PC vectors */ |
| 179 | |
| 180 | enum |
| 181 | { |
| 182 | V_RESET = 0x000, /* power on address */ |
| 183 | V_IE0 = 0x003, /* External Interrupt 0 */ |
| 184 | V_TF0 = 0x00b, /* Timer 0 Overflow */ |
| 185 | V_IE1 = 0x013, /* External Interrupt 1 */ |
| 186 | V_TF1 = 0x01b, /* Timer 1 Overflow */ |
| 187 | V_RITI = 0x023, /* Serial Receive/Transmit */ |
| 188 | |
| 189 | /* 8052 Only Vectors */ |
| 190 | V_TF2 = 0x02b, /* Timer 2 Overflow */ |
| 191 | |
| 192 | /* DS5002FP */ |
| 193 | V_PFI = 0x02b, /* Power Failure Interrupt */ |
| 194 | }; |
| 195 | |
| 196 | /*************************************************************************** |
| 197 | TYPE DEFINITIONS |
| 198 | ***************************************************************************/ |
| 199 | |
| 200 | typedef struct _mcs51_uart mcs51_uart; |
| 201 | struct _mcs51_uart |
| 202 | { |
| 203 | UINT8 data_out; //Data to send out |
| 204 | UINT8 bits_to_send; //How many bits left to send when transmitting out the serial port |
| 205 | |
| 206 | int smod_div; /* signal divided by 2^SMOD */ |
| 207 | int rx_clk; /* rx clock */ |
| 208 | int tx_clk; /* tx clock */ |
| 209 | UINT8 delay_cycles; //Gross Hack; |
| 210 | }; |
| 211 | |
| 212 | typedef struct _mcs51_regs mcs51_regs; |
| 213 | struct _mcs51_regs |
| 214 | { |
| 215 | //Internal stuff |
| 216 | UINT16 ppc; //previous pc |
| 217 | UINT16 pc; //current pc |
| 218 | UINT16 features; //features of this cpu |
| 219 | UINT8 rwm; //Signals that the current instruction is a read/write/modify instruction |
| 220 | |
| 221 | int inst_cycles; /* cycles for the current instruction */ |
| 222 | int ram_mask; /* second ram bank for indirect access available ? */ |
| 223 | int num_interrupts; /* number of interrupts supported */ |
| 224 | int recalc_parity; /* recalculate parity before next instruction */ |
| 225 | UINT32 last_line_state; /* last state of input lines line */ |
| 226 | int t0_cnt; /* number of 0->1 transistions on T0 line */ |
| 227 | int t1_cnt; /* number of 0->1 transistions on T1 line */ |
| 228 | int t2_cnt; /* number of 0->1 transistions on T2 line */ |
| 229 | int t2ex_cnt; /* number of 0->1 transistions on T2EX line */ |
| 230 | int cur_irq_prio; /* Holds value of the current IRQ Priority Level; -1 if no irq */ |
| 231 | UINT8 irq_active; /* mask which irq levels are serviced */ |
| 232 | UINT8 irq_prio[8]; /* interrupt priority */ |
| 233 | |
| 234 | mcs51_uart uart; /* internal uart */ |
| 235 | |
| 236 | /* Internal Ram */ |
| 237 | UINT8 *internal_ram; /* 128 RAM (8031/51) + 128 RAM in second bank (8032/52) */ |
| 238 | UINT8 *sfr_ram; /* 128 SFR - these are in 0x80 - 0xFF */ |
| 239 | |
| 240 | /* SFR Callbacks */ |
| 241 | void (*sfr_write)(size_t offset, UINT8 data); |
| 242 | UINT8 (*sfr_read)(size_t offset); |
| 243 | |
| 244 | /* Interrupt Callback */ |
| 245 | int (*irq_callback)(int irqline); |
| 246 | |
| 247 | /* Serial Port TX/RX Callbacks */ |
| 248 | // TODO: Move to special port r/w |
| 249 | void (*serial_tx_callback)(int data); //Call back funciton when sending data out of serial port |
| 250 | int (*serial_rx_callback)(void); //Call back function to retrieve data when receiving serial port data |
| 251 | |
| 252 | /* DS5002FP */ |
| 253 | struct { |
| 254 | UINT8 previous_ta; /* Previous Timed Access value */ |
| 255 | UINT8 ta_window; /* Limed Access window */ |
| 256 | UINT8 range; /* Memory Range */ |
| 257 | const ds5002fp_config *config; /* Bootstrap Configuration */ |
| 258 | } ds5002fp; |
| 259 | |
| 260 | |
| 261 | }; |
| 262 | |
| 263 | /*************************************************************************** |
| 264 | MACROS |
| 265 | ***************************************************************************/ |
| 266 | |
| 267 | #undef change_pc |
| 268 | #define change_pc(x) |
| 269 | |
| 270 | /* Read Opcode/Opcode Arguments from Program Code */ |
| 271 | #define ROP(pc) cpu_readop(pc) |
| 272 | #define ROP_ARG(pc) cpu_readop_arg(pc) |
| 273 | |
| 274 | /* Read a byte from External Code Memory (Usually Program Rom(s) Space) */ |
| 275 | #define CODEMEM_R(a) (UINT8)program_read_byte_8le(a) |
| 276 | |
| 277 | /* Read/Write a byte from/to External Data Memory (Usually RAM or other I/O) */ |
| 278 | #define DATAMEM_R(a) (UINT8)io_read_byte_8le(a) |
| 279 | #define DATAMEM_W(a,v) io_write_byte_8le(a,v) |
| 280 | //#define DATAMEM_R(a) (UINT8)data_read_byte_8le(a) |
| 281 | //#define DATAMEM_W(a,v) data_write_byte_8le(a,v) |
| 282 | |
| 283 | /* Read/Write a byte from/to the Internal RAM */ |
| 284 | |
| 285 | #define IRAM_R(a) iram_read(a) |
| 286 | #define IRAM_W(a, d) iram_write(a, d) |
| 287 | |
| 288 | /* Read/Write a byte from/to the Internal RAM indirectly */ |
| 289 | /* (called from indirect addressing) */ |
| 290 | #define IRAM_IR(a) data_read_byte_8le((a) & mcs51.ram_mask) |
| 291 | #define IRAM_IW(a, d) data_write_byte_8le((a) & mcs51.ram_mask, d) |
| 292 | |
| 293 | /* Form an Address to Read/Write to External RAM indirectly */ |
| 294 | /* (called from indirect addressing) */ |
| 295 | #define ERAM_ADDR(a,m) external_ram_iaddr(a,m) |
| 296 | |
| 297 | /* Read/Write a bit from Bit Addressable Memory */ |
| 298 | #define BIT_R(a) bit_address_r(a) |
| 299 | #define BIT_W(a,v) bit_address_w(a,v) |
| 300 | |
| 301 | /* Input/Output a byte from given I/O port */ |
| 302 | #define IN(port) ((UINT8)io_read_byte(port)) |
| 303 | #define OUT(port,value) io_write_byte(port,value) |
| 304 | |
| 305 | |
| 306 | /*************************************************************************** |
| 307 | SHORTCUTS |
| 308 | ***************************************************************************/ |
| 309 | |
| 310 | #define PPC mcs51.ppc |
| 311 | #define PC mcs51.pc |
| 312 | #define RWM mcs51.rwm |
| 313 | |
| 314 | /* SFR Registers - These are accessed directly for speed on read */ |
| 315 | /* Read accessors */ |
| 316 | |
| 317 | #define SFR_A(a) mcs51.sfr_ram[(a)] |
| 318 | #define SET_SFR_A(a,v) do { SFR_A(a) = (v); } while (0) |
| 319 | |
| 320 | #define ACC ((const UINT8) SFR_A(ADDR_ACC)) |
| 321 | #define PSW ((const UINT8) SFR_A(ADDR_PSW)) |
| 322 | |
| 323 | #define P0 ((const UINT8) SFR_A(ADDR_P0)) |
| 324 | #define P1 ((const UINT8) SFR_A(ADDR_P1)) |
| 325 | #define P2 ((const UINT8) SFR_A(ADDR_P2)) |
| 326 | #define P3 ((const UINT8) SFR_A(ADDR_P3)) |
| 327 | |
| 328 | #define SP SFR_A(ADDR_SP) |
| 329 | #define DPL SFR_A(ADDR_DPL) |
| 330 | #define DPH SFR_A(ADDR_DPH) |
| 331 | #define PCON SFR_A(ADDR_PCON) |
| 332 | #define TCON SFR_A(ADDR_TCON) |
| 333 | #define TMOD SFR_A(ADDR_TMOD) |
| 334 | #define TL0 SFR_A(ADDR_TL0) |
| 335 | #define TL1 SFR_A(ADDR_TL1) |
| 336 | #define TH0 SFR_A(ADDR_TH0) |
| 337 | #define TH1 SFR_A(ADDR_TH1) |
| 338 | #define SCON SFR_A(ADDR_SCON) |
| 339 | #define IE SFR_A(ADDR_IE) |
| 340 | #define IP SFR_A(ADDR_IP) |
| 341 | #define B SFR_A(ADDR_B) |
| 342 | #define SBUF SFR_A(ADDR_SBUF) |
| 343 | |
| 344 | #define R_REG(r) mcs51.internal_ram[(r) | (PSW & 0x18)] |
| 345 | #define DPTR ((DPH<<8) | DPL) |
| 346 | |
| 347 | /* 8052 Only registers */ |
| 348 | #define T2CON SFR_A(ADDR_T2CON) |
| 349 | #define RCAP2L SFR_A(ADDR_RCAP2L) |
| 350 | #define RCAP2H SFR_A(ADDR_RCAP2H) |
| 351 | #define TL2 SFR_A(ADDR_TL2) |
| 352 | #define TH2 SFR_A(ADDR_TH2) |
| 353 | |
| 354 | /* 80C52 Only registers */ |
| 355 | #define IPH SFR_A(ADDR_IPH) |
| 356 | #define SADDR SFR_A(ADDR_SADDR) |
| 357 | #define SADEN SFR_A(ADDR_SADEN) |
| 358 | |
| 359 | /* Philips 80C52 */ |
| 360 | /* ============= */ |
| 361 | /* Reduced EMI Mode |
| 362 | * The AO bit (AUXR.0) in the AUXR register when set disables the |
| 363 | * ALE output. |
| 364 | */ |
| 365 | #define AUXR SFR_A(ADDR_AUXR) |
| 366 | |
| 367 | /* The dual DPTR structure (see Figure 12) is a way by which the |
| 368 | * 80C52/54/58 will specify the address of an external data memory |
| 369 | * location. There are two 16-bit DPTR registers that address the |
| 370 | * external memory, and a single bit called DPS = AUXR1/bit0 that |
| 371 | * allows the program code to switch between them. |
| 372 | */ |
| 373 | #define AUXR1 SFR_A(ADDR_AUXR1) |
| 374 | |
| 375 | /* DS5002FP only registers */ |
| 376 | #define CRCR SFR_A(ADDR_CRCR) |
| 377 | #define CRCL SFR_A(ADDR_CRCL) |
| 378 | #define CRCH SFR_A(ADDR_CRCH) |
| 379 | #define MCON SFR_A(ADDR_MCON) |
| 380 | #define TA SFR_A(ADDR_TA) |
| 381 | #define RNR SFR_A(ADDR_RNR) |
| 382 | #define RPCTL SFR_A(ADDR_RPCTL) |
| 383 | #define RPS SFR_A(ADDR_RPS) |
| 384 | |
| 385 | |
| 386 | /* WRITE accessors */ |
| 387 | |
| 388 | /* Shortcuts */ |
| 389 | |
| 390 | #define SET_PSW(v) do { SFR_A(ADDR_PSW) = (v); SET_PARITY(); } while (0) |
| 391 | #define SET_ACC(v) do { SFR_A(ADDR_ACC) = (v); SET_PARITY(); } while (0) |
| 392 | |
| 393 | /* These trigger actions on modification and have to be written through SFR_W */ |
| 394 | #define SET_P0(v) IRAM_W(ADDR_P0, v) |
| 395 | #define SET_P1(v) IRAM_W(ADDR_P1, v) |
| 396 | #define SET_P2(v) IRAM_W(ADDR_P2, v) |
| 397 | #define SET_P3(v) IRAM_W(ADDR_P3, v) |
| 398 | |
| 399 | /* Within the cpu core, do not trigger a send */ |
| 400 | #define SET_SBUF(v) SET_SFR_A(ADDR_SBUF, v) |
| 401 | |
| 402 | /* No actions triggered on write */ |
| 403 | #define SET_REG(r, v) do { mcs51.internal_ram[(r) | (PSW & 0x18)] = (v); } while (0) |
| 404 | |
| 405 | #define SET_DPTR(n) do { DPH = ((n) >> 8) & 0xff; DPL = (n) & 0xff; } while (0) |
| 406 | |
| 407 | /* Macros for Setting Flags */ |
| 408 | #define SET_X(R, v) do { R = (v);} while (0) |
| 409 | |
| 410 | #define SET_CY(n) SET_PSW((PSW & 0x7f) | (n<<7)) //Carry Flag |
| 411 | #define SET_AC(n) SET_PSW((PSW & 0xbf) | (n<<6)) //Aux.Carry Flag |
| 412 | #define SET_FO(n) SET_PSW((PSW & 0xdf) | (n<<5)) //User Flag |
| 413 | #define SET_RS(n) SET_PSW((PSW & 0xe7) | (n<<3)) //R Bank Select |
| 414 | #define SET_OV(n) SET_PSW((PSW & 0xfb) | (n<<2)) //Overflow Flag |
| 415 | #define SET_P(n) SET_PSW((PSW & 0xfe) | (n<<0)) //Parity Flag |
| 416 | |
| 417 | #define SET_BIT(R, n, v) do { R = (R & ~(1<<(n))) | ((v) << (n));} while (0) |
| 418 | #define GET_BIT(R, n) (((R)>>(n)) & 0x01) |
| 419 | |
| 420 | #define SET_EA(n) SET_BIT(IE, 7, n) //Global Interrupt Enable/Disable |
| 421 | #define SET_ES(n) SET_BIT(IE, 4, v) //Serial Interrupt Enable/Disable |
| 422 | #define SET_ET1(n) SET_BIT(IE, 3, n) //Timer 1 Interrupt Enable/Disable |
| 423 | #define SET_EX1(n) SET_BIT(IE, 2, n) //External Int 1 Interrupt Enable/Disable |
| 424 | #define SET_ET0(n) SET_BIT(IE, 1, n) //Timer 0 Interrupt Enable/Disable |
| 425 | #define SET_EX0(n) SET_BIT(IE, 0, n) //External Int 0 Interrupt Enable/Disable |
| 426 | /* 8052 Only flags */ |
| 427 | #define SET_ET2(n) SET_BIT(IE, 5, n) //Timer 2 Interrupt Enable/Disable |
| 428 | |
| 429 | /* 8052 Only flags */ |
| 430 | #define SET_PT2(n) SET_BIT(IP, 5, n); //Set Timer 2 Priority Level |
| 431 | |
| 432 | #define SET_PS0(n) SET_BIT(IP, 4, n) //Set Serial Priority Level |
| 433 | #define SET_PT1(n) SET_BIT(IP, 3, n) //Set Timer 1 Priority Level |
| 434 | #define SET_PX1(n) SET_BIT(IP, 2, n) //Set External Int 1 Priority Level |
| 435 | #define SET_PT0(n) SET_BIT(IP, 1, n) //Set Timer 0 Priority Level |
| 436 | #define SET_PX0(n) SET_BIT(IP, 0, n) //Set External Int 0 Priority Level |
| 437 | |
| 438 | #define SET_TF1(n) SET_BIT(TCON, 7, n) //Indicated Timer 1 Overflow Int Triggered |
| 439 | #define SET_TR1(n) SET_BIT(TCON, 6, n) //IndicateS Timer 1 is running |
| 440 | #define SET_TF0(n) SET_BIT(TCON, 5, n) //Indicated Timer 0 Overflow Int Triggered |
| 441 | #define SET_TR0(n) SET_BIT(TCON, 4, n) //IndicateS Timer 0 is running |
| 442 | #define SET_IE1(n) SET_BIT(TCON, 3, n) //Indicated External Int 1 Triggered |
| 443 | #define SET_IT1(n) SET_BIT(TCON, 2, n) //Indicates how External Int 1 is Triggered |
| 444 | #define SET_IE0(n) SET_BIT(TCON, 1, n) //Indicated External Int 0 Triggered |
| 445 | #define SET_IT0(n) SET_BIT(TCON, 0, n) //Indicates how External Int 0 is Triggered |
| 446 | |
| 447 | #define SET_SM0(n) SET_BIT(SCON, 7, n) //Sets Serial Port Mode |
| 448 | #define SET_SM1(n) SET_BIT(SCON, 6, n) //Sets Serial Port Mode |
| 449 | #define SET_SM2(n) SET_BIT(SCON, 5, n) //Sets Serial Port Mode (Multiprocesser mode) |
| 450 | #define SET_REN(n) SET_BIT(SCON, 4, n) //Sets Serial Port Receive Enable |
| 451 | #define SET_TB8(n) SET_BIT(SCON, 3, n) //Transmit 8th Bit |
| 452 | #define SET_RB8(n) SET_BIT(SCON, 2, n) //Receive 8th Bit |
| 453 | #define SET_TI(n) SET_BIT(SCON, 1, n) //Indicates Transmit Interrupt Occurred |
| 454 | #define SET_RI(n) SET_BIT(SCON, 0, n) //Indicates Receive Interrupt Occurred |
| 455 | |
| 456 | #define SET_GATE1(n) SET_BIT(TMOD, 7, n) //Timer 1 Gate Mode |
| 457 | #define SET_CT1(n) SET_BIT(TMOD, 6, n) //Timer 1 Counter Mode |
| 458 | #define SET_M1_1(n) SET_BIT(TMOD, 5, n) //Timer 1 Timer Mode Bit 1 |
| 459 | #define SET_M1_0(n) SET_BIT(TMOD, 4, n) //Timer 1 Timer Mode Bit 0 |
| 460 | #define SET_GATE0(n) SET_BIT(TMOD, 3, n) //Timer 0 Gate Mode |
| 461 | #define SET_CT0(n) SET_BIT(TMOD, 2, n) //Timer 0 Counter Mode |
| 462 | #define SET_M0_1(n) SET_BIT(TMOD, 1, n) //Timer 0 Timer Mode Bit 1 |
| 463 | #define SET_M0_0(n) SET_BIT(TMOD, 0, n) //Timer 0 Timer Mode Bit 0 |
| 464 | |
| 465 | |
| 466 | |
| 467 | /* 8052 Only flags - T2CON Flags */ |
| 468 | #define SET_TF2(n) SET_BIT(T2CON, 7, n) //Indicated Timer 2 Overflow Int Triggered |
| 469 | #define SET_EXF2(n) SET_BIT(T2CON, 6, n) //Indicates Timer 2 External Flag |
| 470 | #define SET_RCLK(n) SET_BIT(T2CON, 5, n) //Receive Clock |
| 471 | #define SET_TCLK(n) SET_BIT(T2CON, 4, n) //Transmit Clock |
| 472 | #define SET_EXEN2(n) SET_BIT(T2CON, 3, n) //Timer 2 External Interrupt Enable |
| 473 | #define SET_TR2(n) SET_BIT(T2CON, 2, n) //Indicates Timer 2 is running |
| 474 | #define SET_CT2(n) SET_BIT(T2CON, 1, n) //Sets Timer 2 Counter/Timer Mode |
| 475 | #define SET_CP(n) SET_BIT(T2CON, 0, n) //Sets Timer 2 Capture/Reload Mode |
| 476 | |
| 477 | #define SET_GF1(n) SET_BIT(PCON, 3, n) |
| 478 | #define SET_GF0(n) SET_BIT(PCON, 2, n) |
| 479 | #define SET_PD(n) SET_BIT(PCON, 1, n) |
| 480 | #define SET_IDL(n) SET_BIT(PCON, 0, n) |
| 481 | |
| 482 | /* Macros for accessing flags */ |
| 483 | |
| 484 | #define GET_CY GET_BIT(PSW, 7) |
| 485 | #define GET_AC GET_BIT(PSW, 6) |
| 486 | #define GET_FO GET_BIT(PSW, 5) |
| 487 | #define GET_RS GET_BIT(PSW, 3) |
| 488 | #define GET_OV GET_BIT(PSW, 2) |
| 489 | #define GET_P GET_BIT(PSW, 0) |
| 490 | |
| 491 | #define GET_EA GET_BIT(IE, 7) |
| 492 | #define GET_ET2 GET_BIT(IE, 5) |
| 493 | #define GET_ES GET_BIT(IE, 4) |
| 494 | #define GET_ET1 GET_BIT(IE, 3) |
| 495 | #define GET_EX1 GET_BIT(IE, 2) |
| 496 | #define GET_ET0 GET_BIT(IE, 1) |
| 497 | #define GET_EX0 GET_BIT(IE, 0) |
| 498 | |
| 499 | /* 8052 Only flags */ |
| 500 | #define GET_PT2 GET_BIT(IP, 5) |
| 501 | |
| 502 | #define GET_PS GET_BIT(IP, 4) |
| 503 | #define GET_PT1 GET_BIT(IP, 3) |
| 504 | #define GET_PX1 GET_BIT(IP, 2) |
| 505 | #define GET_PT0 GET_BIT(IP, 1) |
| 506 | #define GET_PX0 GET_BIT(IP, 0) |
| 507 | |
| 508 | #define GET_TF1 GET_BIT(TCON, 7) |
| 509 | #define GET_TR1 GET_BIT(TCON, 6) |
| 510 | #define GET_TF0 GET_BIT(TCON, 5) |
| 511 | #define GET_TR0 GET_BIT(TCON, 4) |
| 512 | #define GET_IE1 GET_BIT(TCON, 3) |
| 513 | #define GET_IT1 GET_BIT(TCON, 2) |
| 514 | #define GET_IE0 GET_BIT(TCON, 1) |
| 515 | #define GET_IT0 GET_BIT(TCON, 0) |
| 516 | |
| 517 | #define GET_SM0 GET_BIT(SCON, 7) |
| 518 | #define GET_SM1 GET_BIT(SCON, 6) |
| 519 | #define GET_SM2 GET_BIT(SCON, 5) |
| 520 | #define GET_REN GET_BIT(SCON, 4) |
| 521 | #define GET_TB8 GET_BIT(SCON, 3) |
| 522 | #define GET_RB8 GET_BIT(SCON, 2) |
| 523 | #define GET_TI GET_BIT(SCON, 1) |
| 524 | #define GET_RI GET_BIT(SCON, 0) |
| 525 | |
| 526 | #define GET_GATE1 GET_BIT(TMOD, 7) |
| 527 | #define GET_CT1 GET_BIT(TMOD, 6) |
| 528 | #define GET_M1_1 GET_BIT(TMOD, 5) |
| 529 | #define GET_M1_0 GET_BIT(TMOD, 4) |
| 530 | #define GET_GATE0 GET_BIT(TMOD, 3) |
| 531 | #define GET_CT0 GET_BIT(TMOD, 2) |
| 532 | #define GET_M0_1 GET_BIT(TMOD, 1) |
| 533 | #define GET_M0_0 GET_BIT(TMOD, 0) |
| 534 | |
| 535 | #define GET_SMOD GET_BIT(PCON, 7) |
| 536 | |
| 537 | /* Only in 80C51BH & other cmos */ |
| 538 | |
| 539 | #define GET_GF1 GET_BIT(PCON, 3) |
| 540 | #define GET_GF0 GET_BIT(PCON, 2) |
| 541 | #define GET_PD GET_BIT(PCON, 1) |
| 542 | #define GET_IDL (GET_BIT(PCON, 0) & ~(GET_PD)) /* PD takes precedence! */ |
| 543 | |
| 544 | /* 8052 Only flags */ |
| 545 | #define GET_TF2 GET_BIT(T2CON, 7) |
| 546 | #define GET_EXF2 GET_BIT(T2CON, 6) |
| 547 | #define GET_RCLK GET_BIT(T2CON, 5) |
| 548 | #define GET_TCLK GET_BIT(T2CON, 4) |
| 549 | #define GET_EXEN2 GET_BIT(T2CON, 3) |
| 550 | #define GET_TR2 GET_BIT(T2CON, 2) |
| 551 | #define GET_CT2 GET_BIT(T2CON, 1) |
| 552 | #define GET_CP GET_BIT(T2CON, 0) |
| 553 | |
| 554 | /* DS5002FP Only flags */ |
| 555 | |
| 556 | /* PCON Flags - DS5002FP */ |
| 557 | |
| 558 | #define GET_POR GET_BIT(PCON, 6) |
| 559 | #define GET_PFW GET_BIT(PCON, 5) |
| 560 | #define GET_WTR GET_BIT(PCON, 4) |
| 561 | #define GET_EPFW GET_BIT(PCON, 3) |
| 562 | #define GET_EWT GET_BIT(PCON, 2) |
| 563 | |
| 564 | #define SET_PFW(n) SET_BIT(PCON, 5, n) |
| 565 | |
| 566 | /* MCON Flags - DS5002FP */ |
| 567 | |
| 568 | #define GET_PA ((MCON & 0xf0)>>4) |
| 569 | #define GET_RG1 GET_BIT(MCON, 3) |
| 570 | #define GET_PES GET_BIT(MCON, 2) |
| 571 | #define GET_PM GET_BIT(MCON, 1) |
| 572 | #define GET_SL GET_BIT(MCON, 0) |
| 573 | |
| 574 | /* RPCTL Flags - DS5002FP */ |
| 575 | #define GET_RNR GET_BIT(RPCTL, 7) /* Bit 6 ?? */ |
| 576 | #define GET_EXBS GET_BIT(RPCTL, 5) |
| 577 | #define GET_AE GET_BIT(RPCTL, 4) |
| 578 | #define GET_IBI GET_BIT(RPCTL, 3) |
| 579 | #define GET_DMA GET_BIT(RPCTL, 2) |
| 580 | #define GET_RPCON GET_BIT(RPCTL, 1) |
| 581 | #define GET_RG0 GET_BIT(RPCTL, 0) |
| 582 | |
| 583 | |
| 584 | /*Add and Subtract Flag settings*/ |
| 585 | #define DO_ADD_FLAGS(a,d,c) do_add_flags(a,d,c) |
| 586 | #define DO_SUB_FLAGS(a,d,c) do_sub_flags(a,d,c) |
| 587 | |
| 588 | #define SET_PARITY() do {mcs51.recalc_parity |= 1;} while (0) |
| 589 | #define PUSH_PC() push_pc() |
| 590 | #define POP_PC() pop_pc() |
| 591 | |
| 592 | #if 0 |
| 593 | /* Any pending IRQ */ |
| 594 | #define SERIALPORT_IRQ ((R_SCON & 0x03) && GET_ES) |
| 595 | #define TIMERS_IRQ ((GET_TF0 && GET_ET0) || (GET_TF1 && GET_ET1)) |
| 596 | #define EXTERNAL_IRQ ((GET_IE0 && GET_EX0) || (GET_IE1 && GET_EX1)) |
| 597 | |
| 598 | #if (HAS_I8052 || HAS_I8752) |
| 599 | #define NO_PENDING_IRQ !(TIMERS_IRQ) && !(EXTERNAL_IRQ) && !(SERIALPORT_IRQ) && !(GET_ET2 && (GET_TF2 || GET_EXF2)) |
| 600 | #else |
| 601 | #define NO_PENDING_IRQ !(TIMERS_IRQ) && !(EXTERNAL_IRQ) && !(SERIALPORT_IRQ) |
| 602 | #endif |
| 603 | #endif |
| 604 | |
| 605 | /* Clear Current IRQ */ |
| 606 | #define CLEAR_CURRENT_IRQ() clear_current_irq() |
| 607 | |
| 608 | /*************************************************************************** |
| 609 | GLOBAL VARIABLES |
| 610 | ***************************************************************************/ |
| 611 | |
| 612 | static int mcs51_icount; |
| 613 | |
| 614 | static mcs51_regs mcs51; |
| 615 | |
| 616 | |
| 617 | /*************************************************************************** |
| 618 | FUNCTION PROTOTYPES |
| 619 | ***************************************************************************/ |
| 620 | |
| 621 | static void check_irqs(void); |
| 622 | INLINE void serial_transmit(UINT8 data); |
| 623 | |
| 624 | /* Hold callback functions so they can be set by caller (before the cpu reset) */ |
| 625 | |
| 626 | static void (*hold_serial_tx_callback)(int data); |
| 627 | static int (*hold_serial_rx_callback)(void); |
| 628 | |
| 629 | /*************************************************************************** |
| 630 | INLINE FUNCTIONS |
| 631 | ***************************************************************************/ |
| 632 | |
| 633 | INLINE void clear_current_irq(void) |
| 634 | { |
| 635 | //printf("reti cip %d, act %02x\n",mcs51.cur_irq_prio, mcs51.irq_active); |
| 636 | //assert(mcs51.cur_irq_prio >= 0 && mcs51.irq_active); |
| 637 | |
| 638 | if (mcs51.cur_irq_prio >= 0) |
| 639 | mcs51.irq_active &= ~(1 << mcs51.cur_irq_prio); |
| 640 | if (mcs51.irq_active & 4) |
| 641 | mcs51.cur_irq_prio = 2; |
| 642 | else if (mcs51.irq_active & 2) |
| 643 | mcs51.cur_irq_prio = 1; |
| 644 | else if (mcs51.irq_active & 1) |
| 645 | mcs51.cur_irq_prio = 0; |
| 646 | else |
| 647 | mcs51.cur_irq_prio = -1; |
| 648 | LOG(("New: %d %02x\n", mcs51.cur_irq_prio, mcs51.irq_active)); |
| 649 | } |
| 650 | |
| 651 | INLINE UINT8 r_acc(void) { return SFR_A(ADDR_ACC); } |
| 652 | |
| 653 | INLINE UINT8 r_psw(void) { return SFR_A(ADDR_PSW); } |
| 654 | |
| 655 | INLINE void update_ptrs(void) |
| 656 | { |
| 657 | mcs51.internal_ram = memory_get_write_ptr(cpu_getactivecpu(), ADDRESS_SPACE_DATA, 0x00); |
| 658 | mcs51.sfr_ram = memory_get_write_ptr(cpu_getactivecpu(), ADDRESS_SPACE_DATA, 0x100); |
| 659 | } |
| 660 | |
| 661 | |
| 662 | /* Generate an external ram address for read/writing using indirect addressing mode */ |
| 663 | /*The lowest 8 bits of the address are passed in (from the R0/R1 register), however |
| 664 | the hardware can be configured to set the rest of the address lines to any available output port pins, which |
| 665 | means the only way we can implement this is to allow the driver to setup a callback to generate the |
| 666 | address as defined by the specific hardware setup. We'll assume the address won't be bigger than 32 bits |
| 667 | |
| 668 | Couriersud, October 2008: |
| 669 | There is no way external hardware can distinguish between 8bit access and 16 bit access. |
| 670 | During 16bit access the high order byte of the address is output on port 2. We therefore |
| 671 | assume that most hardware will use port 2 for 8bit access as well. |
| 672 | |
| 673 | On configurations where 8 bit access in conjunction with other ports is used, |
| 674 | it is up to the driver to use AM_MIRROR to mask out the high level address and |
| 675 | provide it's own mapping. |
| 676 | */ |
| 677 | |
| 678 | INLINE offs_t external_ram_iaddr(offs_t offset, offs_t mem_mask) |
| 679 | { |
| 680 | if (mem_mask == 0x00ff) |
| 681 | return (offset & mem_mask) | (P2 << 8); |
| 682 | #if 0 |
| 683 | if(mcs51.eram_iaddr_callback) |
| 684 | return mcs51.eram_iaddr_callback(machine,offset,mem_mask); |
| 685 | else |
| 686 | if (mem_mask <= 0x100) LOG(("mcs51 #%d: external ram address requested (8 bit offset=%02x), but no callback available! at PC:%04x\n", cpu_getactivecpu(), offset, PC)); |
| 687 | #endif |
| 688 | return offset; |
| 689 | } |
| 690 | |
| 691 | /* Internal ram read/write */ |
| 692 | |
| 693 | INLINE UINT8 iram_read(size_t offset) |
| 694 | { |
| 695 | return (((offset) < 0x80) ? data_read_byte_8le(offset) : mcs51.sfr_read(offset)); |
| 696 | } |
| 697 | |
| 698 | INLINE void iram_write(size_t offset, UINT8 data) |
| 699 | { |
| 700 | if ((offset) < 0x80) |
| 701 | data_write_byte_8le(offset, data); |
| 702 | else |
| 703 | mcs51.sfr_write(offset, data); |
| 704 | } |
| 705 | |
| 706 | /*Push the current PC to the stack*/ |
| 707 | INLINE void push_pc(void) |
| 708 | { |
| 709 | UINT8 tmpSP = SP+1; //Grab and Increment Stack Pointer |
| 710 | IRAM_IW(tmpSP, (PC & 0xff)); //Store low byte of PC to Internal Ram (Use IRAM_IW to store stack above 128 bytes) |
| 711 | tmpSP++; // "" |
| 712 | SP = tmpSP; // "" |
| 713 | IRAM_IW(tmpSP, ( (PC & 0xff00) >> 8)); //Store hi byte of PC to next address in Internal Ram (Use IRAM_IW to store stack above 128 bytes) |
| 714 | } |
| 715 | |
| 716 | /*Pop the current PC off the stack and into the pc*/ |
| 717 | INLINE void pop_pc(void) |
| 718 | { |
| 719 | UINT8 tmpSP = SP; //Grab Stack Pointer |
| 720 | PC = (IRAM_IR(tmpSP--) & 0xff) << 8; //Store hi byte to PC (must use IRAM_IR to access stack pointing above 128 bytes) |
| 721 | PC = PC | IRAM_IR(tmpSP--); //Store lo byte to PC (must use IRAM_IR to access stack pointing above 128 bytes) |
| 722 | SP = tmpSP; //Decrement Stack Pointer |
| 723 | change_pc(PC); |
| 724 | } |
| 725 | |
| 726 | //Set the PSW Parity Flag |
| 727 | INLINE void set_parity(void) |
| 728 | { |
| 729 | //This flag will be set when the accumulator contains an odd # of bits set.. |
| 730 | UINT8 p = 0; |
| 731 | int i; |
| 732 | UINT8 a = ACC; |
| 733 | |
| 734 | for (i=0; i<8; i++) { //Test for each of the 8 bits in the ACC! |
| 735 | p ^= (a & 1); |
| 736 | a = (a >> 1); |
| 737 | } |
| 738 | |
| 739 | SET_P(p & 1); |
| 740 | } |
| 741 | |
| 742 | INLINE UINT8 bit_address_r(UINT8 offset) |
| 743 | { |
| 744 | UINT8 word; |
| 745 | UINT8 mask; |
| 746 | int bit_pos; |
| 747 | int distance; /* distance between bit addressable words */ |
| 748 | /* 1 for normal bits, 8 for sfr bit addresses */ |
| 749 | |
| 750 | //User defined bit addresses 0x20-0x2f (values are 0x0-0x7f) |
| 751 | if (offset < 0x80) { |
| 752 | distance = 1; |
| 753 | word = ( (offset & 0x78) >> 3) * distance + 0x20; |
| 754 | bit_pos = offset & 0x7; |
| 755 | mask = (0x1 << bit_pos); |
| 756 | return((IRAM_R(word) & mask) >> bit_pos); |
| 757 | } |
| 758 | //SFR bit addressable registers |
| 759 | else { |
| 760 | distance = 8; |
| 761 | word = ( (offset & 0x78) >> 3) * distance + 0x80; |
| 762 | bit_pos = offset & 0x7; |
| 763 | mask = (0x1 << bit_pos); |
| 764 | return ((IRAM_R(word) & mask) >> bit_pos); |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | |
| 769 | INLINE void bit_address_w(UINT8 offset, UINT8 bit) |
| 770 | { |
| 771 | int word; |
| 772 | UINT8 mask; |
| 773 | int bit_pos; |
| 774 | UINT8 result; |
| 775 | int distance; |
| 776 | |
| 777 | /* User defined bit addresses 0x20-0x2f (values are 0x0-0x7f) */ |
| 778 | if (offset < 0x80) { |
| 779 | distance = 1; |
| 780 | word = ((offset & 0x78) >> 3) * distance + 0x20; |
| 781 | bit_pos = offset & 0x7; |
| 782 | bit = (bit & 0x1) << bit_pos; |
| 783 | mask = ~(1 << bit_pos) & 0xff; |
| 784 | result = IRAM_R(word) & mask; |
| 785 | result = result | bit; |
| 786 | IRAM_W(word, result); |
| 787 | } |
| 788 | /* SFR bit addressable registers */ |
| 789 | else { |
| 790 | distance = 8; |
| 791 | word = ((offset & 0x78) >> 3) * distance + 0x80; |
| 792 | bit_pos = offset & 0x7; |
| 793 | bit = (bit & 0x1) << bit_pos; |
| 794 | mask = ~(1 << bit_pos) & 0xff; |
| 795 | result = IRAM_R(word) & mask; |
| 796 | result = result | bit; |
| 797 | IRAM_W(word, result); |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | INLINE void do_add_flags(UINT8 a, UINT8 data, UINT8 c) |
| 802 | { |
| 803 | UINT16 result = a+data+c; |
| 804 | INT16 result1 = (INT8)a+(INT8)data+c; |
| 805 | |
| 806 | SET_CY((result & 0x100) >> 8); |
| 807 | result = (a&0x0f)+(data&0x0f)+c; |
| 808 | SET_AC((result & 0x10) >> 4); |
| 809 | SET_OV(result1 < -128 || result1 > 127); |
| 810 | } |
| 811 | |
| 812 | INLINE void do_sub_flags(UINT8 a, UINT8 data, UINT8 c) |
| 813 | { |
| 814 | UINT16 result = a-(data+c); |
| 815 | INT16 result1 = (INT8)a-(INT8)(data+c); |
| 816 | |
| 817 | SET_CY((result & 0x100) >> 8); |
| 818 | result = (a&0x0f)-((data&0x0f)+c); |
| 819 | SET_AC((result & 0x10) >> 4); |
| 820 | SET_OV((result1 < -128 || result1 > 127)); |
| 821 | } |
| 822 | |
| 823 | INLINE void transmit_receive(int source) |
| 824 | { |
| 825 | int mode = (GET_SM0<<1) | GET_SM1; |
| 826 | |
| 827 | if (source == 1) /* timer1 */ |
| 828 | mcs51.uart.smod_div = (mcs51.uart.smod_div + 1) & (2-GET_SMOD); |
| 829 | |
| 830 | switch(mode) { |
| 831 | //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12 |
| 832 | case 0: |
| 833 | mcs51.uart.rx_clk += (source == 0) ? 16 : 0; /* clock / 12 */ |
| 834 | mcs51.uart.tx_clk += (source == 0) ? 16 : 0; /* clock / 12 */ |
| 835 | break; |
| 836 | //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2 |
| 837 | case 1: |
| 838 | case 3: |
| 839 | if (source == 1) |
| 840 | { |
| 841 | mcs51.uart.tx_clk += (GET_TCLK ? 0 : !mcs51.uart.smod_div); |
| 842 | mcs51.uart.rx_clk += (GET_RCLK ? 0 : !mcs51.uart.smod_div); |
| 843 | } |
| 844 | if (source == 2) |
| 845 | { |
| 846 | mcs51.uart.tx_clk += (GET_TCLK ? 1 : 0); |
| 847 | mcs51.uart.rx_clk += (GET_RCLK ? 1 : 0); |
| 848 | } |
| 849 | break; |
| 850 | //9 bit uart |
| 851 | case 2: |
| 852 | mcs51.uart.rx_clk += (source == 0) ? (GET_SMOD ? 6 : 3) : 0; /* clock / 12 * 3 / 8 (16) = clock / 32 (64)*/ |
| 853 | mcs51.uart.tx_clk += (source == 0) ? (GET_SMOD ? 6 : 3) : 0; /* clock / 12 */ |
| 854 | break; |
| 855 | } |
| 856 | /* transmit ? */ |
| 857 | if (mcs51.uart.tx_clk >= 16) |
| 858 | { |
| 859 | mcs51.uart.tx_clk &= 0x0f; |
| 860 | if(mcs51.uart.bits_to_send) |
| 861 | { |
| 862 | mcs51.uart.bits_to_send--; |
| 863 | if(mcs51.uart.bits_to_send == 0) { |
| 864 | //printf("Here1 %d\n", mcs51.uart.bits_to_send); |
| 865 | //Call the callback function |
| 866 | if(mcs51.serial_tx_callback) |
| 867 | mcs51.serial_tx_callback(mcs51.uart.data_out); |
| 868 | //Set Interrupt Flag |
| 869 | SET_TI(1); |
| 870 | //Note: we'll let the main loop catch the interrupt |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | } |
| 875 | /* receive */ |
| 876 | if (mcs51.uart.rx_clk >= 16) |
| 877 | { |
| 878 | mcs51.uart.rx_clk &= 0x0f; |
| 879 | if (mcs51.uart.delay_cycles>0) |
| 880 | { |
| 881 | mcs51.uart.delay_cycles--; |
| 882 | if (mcs51.uart.delay_cycles == 0) |
| 883 | { |
| 884 | int data = 0; |
| 885 | //Call our callball function to retrieve the data |
| 886 | if(mcs51.serial_rx_callback) |
| 887 | data = mcs51.serial_rx_callback(); |
| 888 | //printf("RX Deliver %d\n", data); |
| 889 | SET_SBUF(data); |
| 890 | //Flag the IRQ |
| 891 | SET_RI(1); |
| 892 | } |
| 893 | } |
| 894 | } |
| 895 | } |
| 896 | |
| 897 | |
| 898 | INLINE void update_timer_t0(int cycles) |
| 899 | { |
| 900 | int mode = (GET_M0_1<<1) | GET_M0_0; |
| 901 | UINT32 count = 0; |
| 902 | |
| 903 | if (GET_TR0) |
| 904 | { |
| 905 | UINT32 delta; |
| 906 | |
| 907 | /* counter / external input */ |
| 908 | delta = GET_CT0 ? mcs51.t0_cnt : cycles; |
| 909 | /* taken, reset */ |
| 910 | mcs51.t0_cnt = 0; |
| 911 | /* TODO: Not sure about IE0. The manual specifies INT0=high, |
| 912 | * which in turn means CLEAR_LINE. |
| 913 | * IE0 may be edge triggered depending on IT0 */ |
| 914 | if (GET_GATE0 && !GET_IE0) |
| 915 | delta = 0; |
| 916 | |
| 917 | switch(mode) { |
| 918 | case 0: /* 13 Bit Timer Mode */ |
| 919 | count = ((TH0<<5) | ( TL0 & 0x1f ) ); |
| 920 | count += delta; |
| 921 | if ( count & 0xffffe000 ) /* Check for overflow */ |
| 922 | SET_TF0(1); |
| 923 | TH0 = (count>>5) & 0xff; |
| 924 | TL0 = count & 0x1f ; |
| 925 | break; |
| 926 | case 1: /* 16 Bit Timer Mode */ |
| 927 | count = ((TH0<<8) | TL0); |
| 928 | count += delta; |
| 929 | if ( count & 0xffff0000 ) /* Check for overflow */ |
| 930 | SET_TF0(1); |
| 931 | TH0 = (count>>8) & 0xff; |
| 932 | TL0 = count & 0xff; |
| 933 | break; |
| 934 | case 2: /* 8 Bit Autoreload */ |
| 935 | count = ((UINT32) TL0) + delta; |
| 936 | if ( count & 0xffffff00 ) /* Check for overflow */ |
| 937 | { |
| 938 | SET_TF0(1); |
| 939 | count += TH0; /* Reload timer */ |
| 940 | } |
| 941 | /* Update new values of the counter */ |
| 942 | TL0 = count & 0xff; |
| 943 | break; |
| 944 | case 3: |
| 945 | /* Split Timer 1 */ |
| 946 | count = ((UINT32) TL0) + delta; |
| 947 | if ( count & 0xffffff00 ) /* Check for overflow */ |
| 948 | SET_TF0(1); |
| 949 | TL0 = count & 0xff; /* Update new values of the counter */ |
| 950 | break; |
| 951 | } |
| 952 | } |
| 953 | if (GET_TR1) |
| 954 | { |
| 955 | switch(mode) |
| 956 | { |
| 957 | case 3: |
| 958 | /* Split Timer 2 */ |
| 959 | count = ((UINT32) TH0) + cycles; /* No gate control or counting !*/ |
| 960 | if ( count & 0xffffff00 ) /* Check for overflow */ |
| 961 | SET_TF1(1); |
| 962 | TH0 = count & 0xff; /* Update new values of the counter */ |
| 963 | break; |
| 964 | } |
| 965 | } |
| 966 | } |
| 967 | |
| 968 | /* From the DS5002FP User Manual |
| 969 | When Timer 1 is selected for operation in Mode 3, it stops counting and holds its current value. This |
| 970 | action is the same as setting TR1 = 0. When Timer 0 is selected in Mode 3, Timer 1???s control bits are |
| 971 | stolen as described above. As a result, Timer 1???s functions are limited in this MODE. It is forced to |
| 972 | operate as a timer whose clock in-put is 12 tCLK and it cannot generate an interrupt on overflow. In |
| 973 | addition, it also cannot be used with the GATE function. However, it can be started and stopped by |
| 974 | switching it into or out of Mode 3 or it can be assigned as a baud rate generator for the serial port. |
| 975 | */ |
| 976 | |
| 977 | /* Intel documentation: |
| 978 | * Timer 1 may still be used in modes 0, 1, and 2, while timer 0 |
| 979 | * is in mode 3. With one important exception: No interrupts |
| 980 | * will be generated by timer 1 while timer 0 is using the TF1 |
| 981 | * overflow flag |
| 982 | */ |
| 983 | |
| 984 | INLINE void update_timer_t1(int cycles) |
| 985 | { |
| 986 | UINT8 mode = (GET_M1_1<<1) | GET_M1_0; |
| 987 | UINT8 mode_0 = (GET_M0_1<<1) | GET_M0_0; |
| 988 | UINT32 count = 0; |
| 989 | |
| 990 | if (mode_0 != 3) |
| 991 | { |
| 992 | if (GET_TR1) |
| 993 | { |
| 994 | UINT32 delta; |
| 995 | UINT32 overflow = 0; |
| 996 | |
| 997 | /* counter / external input */ |
| 998 | delta = GET_CT1 ? mcs51.t1_cnt : cycles; |
| 999 | /* taken, reset */ |
| 1000 | mcs51.t1_cnt = 0; |
| 1001 | /* TODO: Not sure about IE0. The manual specifies INT0=high, |
| 1002 | * which in turn means CLEAR_LINE. Change to access last_state? |
| 1003 | * IE0 may be edge triggered depending on IT0 */ |
| 1004 | if (GET_GATE1 && !GET_IE1) |
| 1005 | delta = 0; |
| 1006 | |
| 1007 | //printf("mode: %d\n", mode); |
| 1008 | switch(mode) { |
| 1009 | case 0: /* 13 Bit Timer Mode */ |
| 1010 | count = ((TH1<<5) | ( TL1 & 0x1f ) ); |
| 1011 | count += delta; |
| 1012 | overflow = count & 0xffffe000; /* Check for overflow */ |
| 1013 | TH1 = (count>>5) & 0xff; |
| 1014 | TL1 = count & 0x1f ; |
| 1015 | break; |
| 1016 | case 1: /* 16 Bit Timer Mode */ |
| 1017 | count = ((TH1<<8) | TL1); |
| 1018 | count += delta; |
| 1019 | overflow = count & 0xffff0000; /* Check for overflow */ |
| 1020 | TH1 = (count>>8) & 0xff; |
| 1021 | TL1 = count & 0xff; |
| 1022 | break; |
| 1023 | case 2: /* 8 Bit Autoreload */ |
| 1024 | count = ((UINT32) TL1) + delta; |
| 1025 | overflow = count & 0xffffff00; /* Check for overflow */ |
| 1026 | if ( overflow ) |
| 1027 | { |
| 1028 | count += TH1; /* Reload timer */ |
| 1029 | } |
| 1030 | /* Update new values of the counter */ |
| 1031 | TL1 = count & 0xff; |
| 1032 | break; |
| 1033 | case 3: |
| 1034 | /* do nothing */ |
| 1035 | break; |
| 1036 | } |
| 1037 | if (overflow) |
| 1038 | { |
| 1039 | SET_TF1(1); |
| 1040 | transmit_receive(1); |
| 1041 | } |
| 1042 | } |
| 1043 | } |
| 1044 | else |
| 1045 | { |
| 1046 | UINT32 delta; |
| 1047 | UINT32 overflow = 0; |
| 1048 | |
| 1049 | delta = cycles; |
| 1050 | /* taken, reset */ |
| 1051 | mcs51.t1_cnt = 0; |
| 1052 | switch(mode) { |
| 1053 | case 0: /* 13 Bit Timer Mode */ |
| 1054 | count = ((TH1<<5) | ( TL1 & 0x1f ) ); |
| 1055 | count += delta; |
| 1056 | overflow = count & 0xffffe000; /* Check for overflow */ |
| 1057 | TH1 = (count>>5) & 0xff; |
| 1058 | TL1 = count & 0x1f ; |
| 1059 | break; |
| 1060 | case 1: /* 16 Bit Timer Mode */ |
| 1061 | count = ((TH1<<8) | TL1); |
| 1062 | count += delta; |
| 1063 | overflow = count & 0xffff0000; /* Check for overflow */ |
| 1064 | TH1 = (count>>8) & 0xff; |
| 1065 | TL1 = count & 0xff; |
| 1066 | break; |
| 1067 | case 2: /* 8 Bit Autoreload */ |
| 1068 | count = ((UINT32) TL1) + delta; |
| 1069 | overflow = count & 0xffffff00; /* Check for overflow */ |
| 1070 | if ( overflow ) |
| 1071 | { |
| 1072 | count += TH1; /* Reload timer */ |
| 1073 | } |
| 1074 | /* Update new values of the counter */ |
| 1075 | TL1 = count & 0xff; |
| 1076 | break; |
| 1077 | case 3: |
| 1078 | /* do nothing */ |
| 1079 | break; |
| 1080 | } |
| 1081 | if (overflow) |
| 1082 | { |
| 1083 | transmit_receive(1); |
| 1084 | } |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | INLINE void update_timer_t2(int cycles) |
| 1089 | { |
| 1090 | /* Update Timer 2 */ |
| 1091 | if(GET_TR2) { |
| 1092 | int mode = ((GET_TCLK | GET_RCLK) << 1) | GET_CP; |
| 1093 | int delta = GET_CT2 ? mcs51.t2_cnt : (mode & 2) ? cycles * (12/2) : cycles; |
| 1094 | |
| 1095 | UINT32 count = ((TH2<<8) | TL2) + delta; |
| 1096 | mcs51.t2_cnt = 0; |
| 1097 | |
| 1098 | switch (mode) |
| 1099 | { |
| 1100 | case 0: /* 16 Bit Auto Reload */ |
| 1101 | if ( count & 0xffff0000 ) |
| 1102 | { |
| 1103 | SET_TF2(1); |
| 1104 | count += ((RCAP2H<<8) | RCAP2L); |
| 1105 | } |
| 1106 | else if (GET_EXEN2 && mcs51.t2ex_cnt>0) |
| 1107 | { |
| 1108 | count += ((RCAP2H<<8) | RCAP2L); |
| 1109 | mcs51.t2ex_cnt = 0; |
| 1110 | } |
| 1111 | TH2 = (count>>8) & 0xff; |
| 1112 | TL2 = count & 0xff; |
| 1113 | break; |
| 1114 | case 1: /* 16 Bit Capture */ |
| 1115 | if ( count & 0xffff0000 ) |
| 1116 | SET_TF2(1); |
| 1117 | TH2 = (count>>8) & 0xff; |
| 1118 | TL2 = count & 0xff; |
| 1119 | |
| 1120 | if (GET_EXEN2 && mcs51.t2ex_cnt>0) |
| 1121 | { |
| 1122 | RCAP2H = TH2; |
| 1123 | RCAP2L = TL2; |
| 1124 | mcs51.t2ex_cnt = 0; |
| 1125 | } |
| 1126 | break; |
| 1127 | case 2: |
| 1128 | case 3: /* Baud rate */ |
| 1129 | if ( count & 0xffff0000 ) |
| 1130 | { |
| 1131 | count += ((RCAP2H<<8) | RCAP2L); |
| 1132 | transmit_receive(2); |
| 1133 | } |
| 1134 | TH2 = (count>>8) & 0xff; |
| 1135 | TL2 = count & 0xff; |
| 1136 | break; |
| 1137 | } |
| 1138 | } |
| 1139 | } |
| 1140 | |
| 1141 | INLINE void update_timers(int cycles) |
| 1142 | { |
| 1143 | /* Update Timer 0 */ |
| 1144 | update_timer_t0(cycles); |
| 1145 | update_timer_t1(cycles); |
| 1146 | |
| 1147 | if (mcs51.features & FEATURE_I8052) |
| 1148 | { |
| 1149 | update_timer_t2(cycles); |
| 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | //Set up to transmit data out of serial port |
| 1154 | //NOTE: Enable Serial Port Interrupt bit is NOT required to send/receive data! |
| 1155 | |
| 1156 | INLINE void serial_transmit(UINT8 data) |
| 1157 | { |
| 1158 | int mode = (GET_SM0<<1) | GET_SM1; |
| 1159 | |
| 1160 | //Flag that we're sending data |
| 1161 | mcs51.uart.data_out = data; |
| 1162 | //printf("serial_tansmit: %x %x\n", mode, data); |
| 1163 | switch(mode) { |
| 1164 | //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12 |
| 1165 | case 0: |
| 1166 | mcs51.uart.bits_to_send = 8+2; |
| 1167 | break; |
| 1168 | //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2 |
| 1169 | case 1: |
| 1170 | mcs51.uart.bits_to_send = 8+2; |
| 1171 | break; |
| 1172 | //9 bit uart |
| 1173 | case 2: |
| 1174 | case 3: |
| 1175 | LOG(("Serial mode %d not supported in mcs51!\n", mode)); |
| 1176 | break; |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | INLINE void serial_receive(void) |
| 1181 | { |
| 1182 | int mode = (GET_SM0<<1) | GET_SM1; |
| 1183 | |
| 1184 | if(GET_ES && GET_REN) { |
| 1185 | switch(mode) { |
| 1186 | //8 bit shifter ( + start,stop bit ) - baud set by clock freq / 12 |
| 1187 | case 0: |
| 1188 | mcs51.uart.delay_cycles = 8+2; |
| 1189 | break; |
| 1190 | //8 bit uart ( + start,stop bit ) - baud set by timer1 or timer2 |
| 1191 | case 1: |
| 1192 | mcs51.uart.delay_cycles = 8+2; |
| 1193 | break; |
| 1194 | //9 bit uart |
| 1195 | case 2: |
| 1196 | case 3: |
| 1197 | LOG(("Serial mode %d not supported in mcs51!\n", mode)); |
| 1198 | break; |
| 1199 | } |
| 1200 | } |
| 1201 | } |
| 1202 | |
| 1203 | /* Check and update status of serial port */ |
| 1204 | INLINE void update_serial(int cycles) |
| 1205 | { |
| 1206 | while (--cycles>=0) |
| 1207 | transmit_receive(0); |
| 1208 | } |
| 1209 | |
| 1210 | /* Check and update status of serial port */ |
| 1211 | INLINE void update_irq_prio(UINT8 ipl, UINT8 iph) |
| 1212 | { |
| 1213 | int i; |
| 1214 | for (i=0; i<8; i++) |
| 1215 | mcs51.irq_prio[i] = ((ipl >> i) & 1) | (((iph >>i ) & 1) << 1); |
| 1216 | } |
| 1217 | |
| 1218 | /*************************************************************************** |
| 1219 | CALLBACKS - TODO: Remove |
| 1220 | ***************************************************************************/ |
| 1221 | |
| 1222 | |
| 1223 | void i8051_set_serial_tx_callback(void (*callback)(int data)) |
| 1224 | { |
| 1225 | //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean |
| 1226 | hold_serial_tx_callback = callback; |
| 1227 | } |
| 1228 | |
| 1229 | void i8051_set_serial_rx_callback(int (*callback)(void)) |
| 1230 | { |
| 1231 | //Hold in static variable since this function can get called before reset has run, which wipes i8051 memory clean |
| 1232 | hold_serial_rx_callback = callback; |
| 1233 | } |
| 1234 | |
| 1235 | /*************************************************************************** |
| 1236 | OPCODES |
| 1237 | ***************************************************************************/ |
| 1238 | |
| 1239 | #include "mcs51ops.c" |
| 1240 | |
| 1241 | |
| 1242 | static void execute_op(UINT8 op) |
| 1243 | { |
| 1244 | if (mcs51.recalc_parity) |
| 1245 | { |
| 1246 | set_parity(); |
| 1247 | mcs51.recalc_parity = 0; |
| 1248 | } |
| 1249 | |
| 1250 | switch( op ) |
| 1251 | { |
| 1252 | |
| 1253 | case 0x00: nop(); break; //NOP |
| 1254 | case 0x01: ajmp(op); break; //AJMP code addr |
| 1255 | case 0x02: ljmp(); break; //LJMP code addr |
| 1256 | case 0x03: rr_a(); break; //RR A |
| 1257 | case 0x04: inc_a(); break; //INC A |
| 1258 | case 0x05: RWM=1; inc_mem(); RWM=0; break; //INC data addr |
| 1259 | |
| 1260 | case 0x06: |
| 1261 | case 0x07: inc_ir(op&1); break; //INC @R0/@R1 |
| 1262 | |
| 1263 | case 0x08: |
| 1264 | case 0x09: |
| 1265 | case 0x0a: |
| 1266 | case 0x0b: |
| 1267 | case 0x0c: |
| 1268 | case 0x0d: |
| 1269 | case 0x0e: |
| 1270 | case 0x0f: inc_r(op&7); break; //INC R0 to R7 |
| 1271 | |
| 1272 | case 0x10: RWM=1; jbc(); RWM=0; break; //JBC bit addr, code addr |
| 1273 | case 0x11: acall(op); break; //ACALL code addr |
| 1274 | case 0x12: lcall(); break; //LCALL code addr |
| 1275 | case 0x13: rrc_a(); break; //RRC A |
| 1276 | case 0x14: dec_a(); break; //DEC A |
| 1277 | case 0x15: RWM=1; dec_mem(); RWM=0; break; //DEC data addr |
| 1278 | |
| 1279 | case 0x16: |
| 1280 | case 0x17: dec_ir(op&1); break; //DEC @R0/@R1 |
| 1281 | |
| 1282 | case 0x18: |
| 1283 | case 0x19: |
| 1284 | case 0x1a: |
| 1285 | case 0x1b: |
| 1286 | case 0x1c: |
| 1287 | case 0x1d: |
| 1288 | case 0x1e: |
| 1289 | case 0x1f: dec_r(op&7); break; //DEC R0 to R7 |
| 1290 | |
| 1291 | case 0x20: jb(); break; //JB bit addr, code addr |
| 1292 | case 0x21: ajmp(op); break; //AJMP code addr |
| 1293 | case 0x22: ret(); break; //RET |
| 1294 | case 0x23: rl_a(); break; //RL A |
| 1295 | case 0x24: add_a_byte(); break; //ADD A, #data |
| 1296 | case 0x25: add_a_mem(); break; //ADD A, data addr |
| 1297 | |
| 1298 | case 0x26: |
| 1299 | case 0x27: add_a_ir(op&1); break; //ADD A, @R0/@R1 |
| 1300 | |
| 1301 | case 0x28: |
| 1302 | case 0x29: |
| 1303 | case 0x2a: |
| 1304 | case 0x2b: |
| 1305 | case 0x2c: |
| 1306 | case 0x2d: |
| 1307 | case 0x2e: |
| 1308 | case 0x2f: add_a_r(op&7); break; //ADD A, R0 to R7 |
| 1309 | |
| 1310 | case 0x30: jnb(); break; //JNB bit addr, code addr |
| 1311 | case 0x31: acall(op); break; //ACALL code addr |
| 1312 | case 0x32: reti(); break; //RETI |
| 1313 | case 0x33: rlc_a(); break; //RLC A |
| 1314 | case 0x34: addc_a_byte(); break; //ADDC A, #data |
| 1315 | case 0x35: addc_a_mem(); break; //ADDC A, data addr |
| 1316 | |
| 1317 | case 0x36: |
| 1318 | case 0x37: addc_a_ir(op&1); break; //ADDC A, @R0/@R1 |
| 1319 | |
| 1320 | case 0x38: |
| 1321 | case 0x39: |
| 1322 | case 0x3a: |
| 1323 | case 0x3b: |
| 1324 | case 0x3c: |
| 1325 | case 0x3d: |
| 1326 | case 0x3e: |
| 1327 | case 0x3f: addc_a_r(op&7); break; //ADDC A, R0 to R7 |
| 1328 | |
| 1329 | case 0x40: jc(); break; //JC code addr |
| 1330 | case 0x41: ajmp(op); break; //AJMP code addr |
| 1331 | case 0x42: RWM=1; orl_mem_a(); RWM=0; break; //ORL data addr, A |
| 1332 | case 0x43: RWM=1; orl_mem_byte(); RWM=0; break; //ORL data addr, #data |
| 1333 | case 0x44: orl_a_byte(); break; |
| 1334 | case 0x45: orl_a_mem(); break; //ORL A, data addr |
| 1335 | |
| 1336 | case 0x46: |
| 1337 | case 0x47: orl_a_ir(op&1); break; //ORL A, @RO/@R1 |
| 1338 | |
| 1339 | case 0x48: |
| 1340 | case 0x49: |
| 1341 | case 0x4a: |
| 1342 | case 0x4b: |
| 1343 | case 0x4c: |
| 1344 | case 0x4d: |
| 1345 | case 0x4e: |
| 1346 | case 0x4f: orl_a_r(op&7); break; //ORL A, RO to R7 |
| 1347 | |
| 1348 | case 0x50: jnc(); break; //JNC code addr |
| 1349 | case 0x51: acall(op); break; //ACALL code addr |
| 1350 | case 0x52: RWM=1; anl_mem_a(); RWM=0; break; //ANL data addr, A |
| 1351 | case 0x53: RWM=1; anl_mem_byte(); RWM=0; break; //ANL data addr, #data |
| 1352 | case 0x54: anl_a_byte(); break; //ANL A, #data |
| 1353 | case 0x55: anl_a_mem(); break; //ANL A, data addr |
| 1354 | |
| 1355 | case 0x56: |
| 1356 | case 0x57: anl_a_ir(op&1); break; //ANL A, @RO/@R1 |
| 1357 | |
| 1358 | case 0x58: |
| 1359 | case 0x59: |
| 1360 | case 0x5a: |
| 1361 | case 0x5b: |
| 1362 | case 0x5c: |
| 1363 | case 0x5d: |
| 1364 | case 0x5e: |
| 1365 | case 0x5f: anl_a_r(op&7); break; //ANL A, RO to R7 |
| 1366 | |
| 1367 | case 0x60: jz(); break; //JZ code addr |
| 1368 | case 0x61: ajmp(op); break; //AJMP code addr |
| 1369 | case 0x62: RWM=1; xrl_mem_a(); RWM=0; break; //XRL data addr, A |
| 1370 | case 0x63: RWM=1; xrl_mem_byte(); RWM=0; break; //XRL data addr, #data |
| 1371 | case 0x64: xrl_a_byte(); break; //XRL A, #data |
| 1372 | case 0x65: xrl_a_mem(); break; //XRL A, data addr |
| 1373 | |
| 1374 | case 0x66: |
| 1375 | case 0x67: xrl_a_ir(op&1); break; //XRL A, @R0/@R1 |
| 1376 | |
| 1377 | case 0x68: |
| 1378 | case 0x69: |
| 1379 | case 0x6a: |
| 1380 | case 0x6b: |
| 1381 | case 0x6c: |
| 1382 | case 0x6d: |
| 1383 | case 0x6e: |
| 1384 | case 0x6f: xrl_a_r(op&7); break; //XRL A, R0 to R7 |
| 1385 | |
| 1386 | case 0x70: jnz(); break; //JNZ code addr |
| 1387 | case 0x71: acall(op); break; //ACALL code addr |
| 1388 | case 0x72: orl_c_bitaddr(); break; //ORL C, bit addr |
| 1389 | case 0x73: jmp_iadptr(); break; //JMP @A+DPTR |
| 1390 | case 0x74: mov_a_byte(); break; //MOV A, #data |
| 1391 | case 0x75: mov_mem_byte(); break; //MOV data addr, #data |
| 1392 | |
| 1393 | case 0x76: |
| 1394 | case 0x77: mov_ir_byte(op&1); break; //MOV @R0/@R1, #data |
| 1395 | |
| 1396 | case 0x78: |
| 1397 | case 0x79: |
| 1398 | case 0x7a: |
| 1399 | case 0x7b: |
| 1400 | case 0x7c: |
| 1401 | case 0x7d: |
| 1402 | case 0x7e: |
| 1403 | case 0x7f: mov_r_byte(op&7); break; //MOV R0 to R7, #data |
| 1404 | |
| 1405 | case 0x80: sjmp(); break; //SJMP code addr |
| 1406 | case 0x81: ajmp(op); break; //AJMP code addr |
| 1407 | case 0x82: anl_c_bitaddr(); break; //ANL C, bit addr |
| 1408 | case 0x83: movc_a_iapc(); break; //MOVC A, @A + PC |
| 1409 | case 0x84: div_ab(); break; //DIV AB |
| 1410 | case 0x85: mov_mem_mem(); break; //MOV data addr, data addr |
| 1411 | |
| 1412 | case 0x86: |
| 1413 | case 0x87: mov_mem_ir(op&1); break; //MOV data addr, @R0/@R1 |
| 1414 | |
| 1415 | case 0x88: |
| 1416 | case 0x89: |
| 1417 | case 0x8a: |
| 1418 | case 0x8b: |
| 1419 | case 0x8c: |
| 1420 | case 0x8d: |
| 1421 | case 0x8e: |
| 1422 | case 0x8f: mov_mem_r(op&7); break; //MOV data addr,R0 to R7 |
| 1423 | |
| 1424 | case 0x90: mov_dptr_byte(); break; //MOV DPTR, #data |
| 1425 | case 0x91: acall(op); break; //ACALL code addr |
| 1426 | case 0x92: RWM = 1; mov_bitaddr_c(); RWM = 0; break; //MOV bit addr, C |
| 1427 | case 0x93: movc_a_iadptr(); break; //MOVC A, @A + DPTR |
| 1428 | case 0x94: subb_a_byte(); break; //SUBB A, #data |
| 1429 | case 0x95: subb_a_mem(); break; //SUBB A, data addr |
| 1430 | |
| 1431 | case 0x96: |
| 1432 | case 0x97: subb_a_ir(op&1); break; //SUBB A, @R0/@R1 |
| 1433 | |
| 1434 | case 0x98: |
| 1435 | case 0x99: |
| 1436 | case 0x9a: |
| 1437 | case 0x9b: |
| 1438 | case 0x9c: |
| 1439 | case 0x9d: |
| 1440 | case 0x9e: |
| 1441 | case 0x9f: subb_a_r(op&7); break; //SUBB A, R0 to R7 |
| 1442 | |
| 1443 | case 0xa0: orl_c_nbitaddr(); break; //ORL C, /bit addr |
| 1444 | case 0xa1: ajmp(op); break; //AJMP code addr |
| 1445 | case 0xa2: mov_c_bitaddr(); break; //MOV C, bit addr |
| 1446 | case 0xa3: inc_dptr(); break; //INC DPTR |
| 1447 | case 0xa4: mul_ab(); break; //MUL AB |
| 1448 | case 0xa5: illegal(op); break; //reserved |
| 1449 | |
| 1450 | case 0xa6: |
| 1451 | case 0xa7: mov_ir_mem(op&1); break; //MOV @R0/@R1, data addr |
| 1452 | |
| 1453 | case 0xa8: |
| 1454 | case 0xa9: |
| 1455 | case 0xaa: |
| 1456 | case 0xab: |
| 1457 | case 0xac: |
| 1458 | case 0xad: |
| 1459 | case 0xae: |
| 1460 | case 0xaf: mov_r_mem(op&7); break; //MOV R0 to R7, data addr |
| 1461 | |
| 1462 | case 0xb0: anl_c_nbitaddr(); break; //ANL C,/bit addr |
| 1463 | case 0xb1: acall(op); break; //ACALL code addr |
| 1464 | case 0xb2: RWM=1; cpl_bitaddr(); RWM=0; break; //CPL bit addr |
| 1465 | case 0xb3: cpl_c(); break; //CPL C |
| 1466 | case 0xb4: cjne_a_byte(); break; //CJNE A, #data, code addr |
| 1467 | case 0xb5: cjne_a_mem(); break; //CJNE A, data addr, code addr |
| 1468 | |
| 1469 | case 0xb6: |
| 1470 | case 0xb7: cjne_ir_byte(op&1); break; //CJNE @R0/@R1, #data, code addr |
| 1471 | |
| 1472 | case 0xb8: |
| 1473 | case 0xb9: |
| 1474 | case 0xba: |
| 1475 | case 0xbb: |
| 1476 | case 0xbc: |
| 1477 | case 0xbd: |
| 1478 | case 0xbe: |
| 1479 | case 0xbf: cjne_r_byte(op&7); break; //CJNE R0 to R7, #data, code addr |
| 1480 | |
| 1481 | case 0xc0: push(); break; //PUSH data addr |
| 1482 | case 0xc1: ajmp(op); break; //AJMP code addr |
| 1483 | case 0xc2: RWM=1; clr_bitaddr(); RWM=0; break; //CLR bit addr |
| 1484 | case 0xc3: clr_c(); break; //CLR C |
| 1485 | case 0xc4: swap_a(); break; //SWAP A |
| 1486 | case 0xc5: xch_a_mem(); break; //XCH A, data addr |
| 1487 | |
| 1488 | case 0xc6: |
| 1489 | case 0xc7: xch_a_ir(op&1); break; //XCH A, @RO/@R1 |
| 1490 | |
| 1491 | case 0xc8: |
| 1492 | case 0xc9: |
| 1493 | case 0xca: |
| 1494 | case 0xcb: |
| 1495 | case 0xcc: |
| 1496 | case 0xcd: |
| 1497 | case 0xce: |
| 1498 | case 0xcf: xch_a_r(op&7); break; //XCH A, RO to R7 |
| 1499 | |
| 1500 | case 0xd0: pop(); break; //POP data addr |
| 1501 | case 0xd1: acall(op); break; //ACALL code addr |
| 1502 | case 0xd2: RWM=1; setb_bitaddr(); RWM=0; break; //SETB bit addr |
| 1503 | case 0xd3: setb_c(); break; //SETB C |
| 1504 | case 0xd4: da_a(); break; //DA A |
| 1505 | case 0xd5: RWM=1; djnz_mem(); RWM=0; break; //DJNZ data addr, code addr |
| 1506 | |
| 1507 | case 0xd6: |
| 1508 | case 0xd7: xchd_a_ir(op&1); break; //XCHD A, @R0/@R1 |
| 1509 | |
| 1510 | case 0xd8: |
| 1511 | case 0xd9: |
| 1512 | case 0xda: |
| 1513 | case 0xdb: |
| 1514 | case 0xdc: |
| 1515 | case 0xdd: |
| 1516 | case 0xde: |
| 1517 | case 0xdf: djnz_r(op&7); break; //DJNZ R0 to R7,code addr |
| 1518 | |
| 1519 | case 0xe0: movx_a_idptr(); break; //MOVX A,@DPTR |
| 1520 | case 0xe1: ajmp(op); break; //AJMP code addr |
| 1521 | |
| 1522 | case 0xe2: |
| 1523 | case 0xe3: movx_a_ir(op&1); break; //MOVX A, @R0/@R1 |
| 1524 | |
| 1525 | case 0xe4: clr_a(); break; //CLR A |
| 1526 | case 0xe5: mov_a_mem(); break; //MOV A, data addr |
| 1527 | case 0xe6: |
| 1528 | case 0xe7: mov_a_ir(op&1); break; //MOV A,@RO/@R1 |
| 1529 | |
| 1530 | case 0xe8: |
| 1531 | case 0xe9: |
| 1532 | case 0xea: |
| 1533 | case 0xeb: |
| 1534 | case 0xec: |
| 1535 | case 0xed: |
| 1536 | case 0xee: |
| 1537 | case 0xef: mov_a_r(op&7); break; //MOV A,R0 to R7 |
| 1538 | |
| 1539 | case 0xf0: movx_idptr_a(); break; //MOVX @DPTR,A |
| 1540 | case 0xf1: acall(op); break; //ACALL code addr |
| 1541 | |
| 1542 | case 0xf2: |
| 1543 | case 0xf3: movx_ir_a(op&1); break; //MOVX @R0/@R1,A |
| 1544 | |
| 1545 | case 0xf4: cpl_a(); break; //CPL A |
| 1546 | case 0xf5: mov_mem_a(); break; //MOV data addr, A |
| 1547 | |
| 1548 | case 0xf6: |
| 1549 | case 0xf7: mov_ir_a(op&1); break; //MOV @R0/@R1, A |
| 1550 | |
| 1551 | case 0xf8: |
| 1552 | case 0xf9: |
| 1553 | case 0xfa: |
| 1554 | case 0xfb: |
| 1555 | case 0xfc: |
| 1556 | case 0xfd: |
| 1557 | case 0xfe: |
| 1558 | case 0xff: mov_r_a(op&7); break; //MOV R0 to R7, A |
| 1559 | default: |
| 1560 | illegal(op); |
| 1561 | } |
| 1562 | } |
| 1563 | |
| 1564 | /*************************************************************************** |
| 1565 | OPCODE CYCLES |
| 1566 | ***************************************************************************/ |
| 1567 | |
| 1568 | /* # of oscilations each opcode requires*/ |
| 1569 | static const UINT8 mcs51_cycles[] = { |
| 1570 | 1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1571 | 2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1572 | 2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1573 | 2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1574 | 2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1575 | 2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1576 | 2,2,1,2,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1577 | 2,2,2,2,1,2,1,1,1,1,1,1,1,1,1,1, |
| 1578 | 2,2,2,2,4,2,2,2,2,2,2,2,2,2,2,2, |
| 1579 | 2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1580 | 2,2,1,2,4,1,2,2,2,2,2,2,2,2,2,2, |
| 1581 | 2,2,1,1,2,2,2,2,2,2,2,2,2,2,2,2, |
| 1582 | 2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1583 | 2,2,1,1,1,2,1,1,2,2,2,2,2,2,2,2, |
| 1584 | 2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1, |
| 1585 | 2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1 |
| 1586 | }; |
| 1587 | |
| 1588 | /*********************************************************************************** |
| 1589 | Check for pending Interrupts and process - returns # of cycles used for the int |
| 1590 | |
| 1591 | Note about priority & interrupting interrupts.. |
| 1592 | 1) A high priority interrupt cannot be interrupted by anything! |
| 1593 | 2) A low priority interrupt can ONLY be interrupted by a high priority interrupt |
| 1594 | 3) If more than 1 Interrupt Flag is set (ie, 2 simultaneous requests occur), |
| 1595 | the following logic works as follows: |
| 1596 | 1) If two requests come in of different priority levels, the higher one is selected.. |
| 1597 | 2) If the requests are of the same level, an internal order is used: |
| 1598 | a) IEO |
| 1599 | b) TFO |
| 1600 | c) IE1 |
| 1601 | d) TF1 |
| 1602 | e) RI+TI |
| 1603 | f) TF2+EXF2 |
| 1604 | **********************************************************************************/ |
| 1605 | static void check_irqs(void) |
| 1606 | { |
| 1607 | UINT8 ints = (GET_IE0 | (GET_TF0<<1) | (GET_IE1<<2) | (GET_TF1<<3) |
| 1608 | | ((GET_RI|GET_TI)<<4)); |
| 1609 | UINT8 int_vec = 0; |
| 1610 | UINT8 int_mask = 0; |
| 1611 | int priority_request = -1; |
| 1612 | int i; |
| 1613 | |
| 1614 | //If All Inerrupts Disabled or no pending abort.. |
| 1615 | int_mask = (GET_EA ? IE : 0x00); |
| 1616 | |
| 1617 | if (mcs51.features & FEATURE_I8052) |
| 1618 | ints |= ((GET_TF2|GET_EXF2)<<5); |
| 1619 | |
| 1620 | if (mcs51.features & FEATURE_DS5002FP) |
| 1621 | { |
| 1622 | printf("Here\n"); |
| 1623 | ints |= ((GET_PFW)<<5); |
| 1624 | mcs51.irq_prio[6] = 3; /* force highest priority */ |
| 1625 | /* mask out interrupts not enabled */ |
| 1626 | ints &= ((int_mask & 0x1f) | ((GET_EPFW)<<5)); |
| 1627 | } |
| 1628 | else |
| 1629 | { |
| 1630 | /* mask out interrupts not enabled */ |
| 1631 | ints &= int_mask; |
| 1632 | } |
| 1633 | |
| 1634 | if (!ints) return; |
| 1635 | |
| 1636 | /* CLear IDL - got enabled interrupt */ |
| 1637 | if (mcs51.features & FEATURE_CMOS) |
| 1638 | { |
| 1639 | /* any interrupt terminates idle mode */ |
| 1640 | SET_IDL(0); |
| 1641 | /* external interrupt wakes up */ |
| 1642 | if (ints & (GET_IE0 | GET_IE1)) |
| 1643 | /* but not the DS5002FP */ |
| 1644 | if (!(mcs51.features & FEATURE_DS5002FP)) |
| 1645 | SET_PD(0); |
| 1646 | } |
| 1647 | |
| 1648 | for (i=0; i<mcs51.num_interrupts; i++) |
| 1649 | { |
| 1650 | if (ints & (1<<i)) |
| 1651 | { |
| 1652 | if (mcs51.irq_prio[i] > priority_request) |
| 1653 | { |
| 1654 | priority_request = mcs51.irq_prio[i]; |
| 1655 | int_vec = (i<<3) | 3; |
| 1656 | } |
| 1657 | } |
| 1658 | } |
| 1659 | |
| 1660 | /* Skip the interrupt request if currently processing interrupt |
| 1661 | * and the new request does not have a higher priority |
| 1662 | */ |
| 1663 | |
| 1664 | LOG(("Request: %d\n", priority_request)); |
| 1665 | if (mcs51.irq_active && (priority_request <= mcs51.cur_irq_prio)) |
| 1666 | { |
| 1667 | LOG(("higher or equal priority irq in progress already, skipping ...\n")); |
| 1668 | return; |
| 1669 | } |
| 1670 | |
| 1671 | //Save current pc to stack, set pc to new interrupt vector |
| 1672 | push_pc(); |
| 1673 | PC = int_vec; |
| 1674 | change_pc(PC); |
| 1675 | |
| 1676 | /* interrupts take 24 cycles */ |
| 1677 | mcs51.inst_cycles += 2; |
| 1678 | |
| 1679 | //Set current Irq & Priority being serviced |
| 1680 | mcs51.cur_irq_prio = priority_request; |
| 1681 | mcs51.irq_active |= (1 << priority_request); |
| 1682 | |
| 1683 | LOG(("Take: %d %02x\n", mcs51.cur_irq_prio, mcs51.irq_active)); |
| 1684 | |
| 1685 | //printf("irq cip %d, act %02x\n",mcs51.cur_irq_prio, mcs51.irq_active); |
| 1686 | |
| 1687 | //Clear any interrupt flags that should be cleared since we're servicing the irq! |
| 1688 | switch(int_vec) { |
| 1689 | case V_IE0: |
| 1690 | //External Int Flag only cleared when configured as Edge Triggered.. |
| 1691 | if(GET_IT0) /* for some reason having this, breaks alving dmd games */ |
| 1692 | SET_IE0(0); |
| 1693 | |
| 1694 | /* indicate we took the external IRQ */ |
| 1695 | if (mcs51.irq_callback != NULL) |
| 1696 | (*mcs51.irq_callback)(0); |
| 1697 | |
| 1698 | break; |
| 1699 | case V_TF0: |
| 1700 | //Timer 0 - Always clear Flag |
| 1701 | SET_TF0(0); |
| 1702 | break; |
| 1703 | case V_IE1: |
| 1704 | //External Int Flag only cleared when configured as Edge Triggered.. |
| 1705 | if(GET_IT1) /* for some reason having this, breaks alving dmd games */ |
| 1706 | SET_IE1(0); |
| 1707 | /* indicate we took the external IRQ */ |
| 1708 | if (mcs51.irq_callback != NULL) |
| 1709 | (*mcs51.irq_callback)(1); |
| 1710 | |
| 1711 | break; |
| 1712 | case V_TF1: |
| 1713 | //Timer 1 - Always clear Flag |
| 1714 | SET_TF1(0); |
| 1715 | break; |
| 1716 | case V_RITI: |
| 1717 | /* no flags are cleared, TI and RI remain set until reset by software */ |
| 1718 | break; |
| 1719 | /* I8052 specific */ |
| 1720 | case V_TF2: |
| 1721 | /* no flags are cleared according to manual */ |
| 1722 | break; |
| 1723 | /* DS5002FP specific */ |
| 1724 | /* case V_PFI: |
| 1725 | * no flags are cleared, PFW is reset by software |
| 1726 | * This has the same vector as V_TF2. |
| 1727 | */ |
| 1728 | |
| 1729 | } |
| 1730 | } |
| 1731 | |
| 1732 | INLINE void burn_cycles(int cycles) |
| 1733 | { |
| 1734 | /* Update Timer (if any timers are running) */ |
| 1735 | update_timers(cycles); |
| 1736 | |
| 1737 | /* Update Serial (only for mode 0) */ |
| 1738 | update_serial(cycles); |
| 1739 | |
| 1740 | /* check_irqs */ |
| 1741 | check_irqs(); |
| 1742 | } |
| 1743 | |
| 1744 | static void mcs51_set_irq_line(int irqline, int state) |
| 1745 | { |
| 1746 | /* From the manual: |
| 1747 | * |
| 1748 | * <cite>In operatiom all the interrupt tlags are latched into the |
| 1749 | * interrupt control system during State 5 of every ma- |
| 1750 | * chine cycle. The samples are polled during the follow- |
| 1751 | * ing machine cycle.</cite> |
| 1752 | * |
| 1753 | * ==> Since we do not emulate substates, this assumes that the signal is present |
| 1754 | * for at least one cycle (12 states) |
| 1755 | * |
| 1756 | */ |
| 1757 | UINT32 new_state = (mcs51.last_line_state & ~(1 << irqline)) | ((state != CLEAR_LINE) << irqline); |
| 1758 | /* detect 0->1 transistions */ |
| 1759 | UINT32 tr_state = (~mcs51.last_line_state) & new_state; |
| 1760 | |
| 1761 | switch( irqline ) |
| 1762 | { |
| 1763 | //External Interrupt 0 |
| 1764 | case MCS51_INT0_LINE: |
| 1765 | //Line Asserted? |
| 1766 | if (state != CLEAR_LINE) { |
| 1767 | //Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT0 active lo! |
| 1768 | if (GET_IT0) { |
| 1769 | if (GET_BIT(tr_state, MCS51_INT0_LINE)) |
| 1770 | SET_IE0(1); |
| 1771 | } |
| 1772 | else |
| 1773 | SET_IE0(1); //Nope, just set it.. |
| 1774 | } |
| 1775 | else |
| 1776 | { |
| 1777 | if (!GET_IT0) /* clear if level triggered */ |
| 1778 | SET_IE0(0); |
| 1779 | } |
| 1780 | |
| 1781 | break; |
| 1782 | |
| 1783 | //External Interrupt 1 |
| 1784 | case MCS51_INT1_LINE: |
| 1785 | |
| 1786 | //Line Asserted? |
| 1787 | if (state != CLEAR_LINE) { |
| 1788 | //Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT1 active lo! |
| 1789 | if(GET_IT1){ |
| 1790 | if (GET_BIT(tr_state, MCS51_INT1_LINE)) |
| 1791 | SET_IE1(1); |
| 1792 | } |
| 1793 | else |
| 1794 | SET_IE1(1); //Nope, just set it.. |
| 1795 | } |
| 1796 | else |
| 1797 | { |
| 1798 | if (!GET_IT1) /* clear if level triggered */ |
| 1799 | SET_IE1(0); |
| 1800 | } |
| 1801 | break; |
| 1802 | |
| 1803 | case MCS51_T0_LINE: |
| 1804 | if (GET_BIT(tr_state, MCS51_T0_LINE)) |
| 1805 | mcs51.t0_cnt++; |
| 1806 | break; |
| 1807 | |
| 1808 | case MCS51_T1_LINE: |
| 1809 | if (GET_BIT(tr_state, MCS51_T1_LINE)) |
| 1810 | mcs51.t1_cnt++; |
| 1811 | break; |
| 1812 | |
| 1813 | case MCS51_T2_LINE: |
| 1814 | if (mcs51.features & FEATURE_I8052) |
| 1815 | { |
| 1816 | if (GET_BIT(tr_state, MCS51_T2_LINE)) |
| 1817 | mcs51.t2_cnt++; |
| 1818 | } |
| 1819 | else |
| 1820 | fatalerror("mcs51: Trying to set T2_LINE on a non I8052 type cpu.\n"); |
| 1821 | break; |
| 1822 | |
| 1823 | case MCS51_T2EX_LINE: |
| 1824 | if (mcs51.features & FEATURE_I8052) |
| 1825 | { |
| 1826 | if (GET_BIT(tr_state, MCS51_T2EX_LINE)) |
| 1827 | { |
| 1828 | SET_EXF2(1); |
| 1829 | mcs51.t2ex_cnt++; |
| 1830 | } |
| 1831 | } |
| 1832 | else |
| 1833 | fatalerror("mcs51: Trying to set T2EX_LINE on a non I8052 type cpu.\n"); |
| 1834 | break; |
| 1835 | |
| 1836 | case MCS51_RX_LINE: /* Serial Port Receive */ |
| 1837 | /* Is the enable flags for this interrupt set? */ |
| 1838 | if (state != CLEAR_LINE) |
| 1839 | { |
| 1840 | serial_receive(); |
| 1841 | } |
| 1842 | break; |
| 1843 | |
| 1844 | /* Power Fail Interrupt */ |
| 1845 | case DS5002FP_PFI_LINE: |
| 1846 | if (mcs51.features & FEATURE_DS5002FP) |
| 1847 | { |
| 1848 | /* Need cleared->active line transition? (Logical 1-0 Pulse on the line) - CLEAR->ASSERT Transition since INT1 active lo! */ |
| 1849 | if (GET_BIT(tr_state, MCS51_INT1_LINE)) |
| 1850 | SET_PFW(1); |
| 1851 | } |
| 1852 | else |
| 1853 | fatalerror("mcs51: Trying to set DS5002FP_PFI_LINE on a non DS5002FP type cpu.\n"); |
| 1854 | break; |
| 1855 | } |
| 1856 | mcs51.last_line_state = new_state; |
| 1857 | } |
| 1858 | |
| 1859 | /* Execute cycles - returns number of cycles actually run */ |
| 1860 | static int mcs51_execute(int cycles) |
| 1861 | { |
| 1862 | UINT8 op; |
| 1863 | |
| 1864 | mcs51_icount = cycles; |
| 1865 | |
| 1866 | /* external interrupts may have been set since we last checked */ |
| 1867 | mcs51.inst_cycles = 0; |
| 1868 | check_irqs(); |
| 1869 | |
| 1870 | /* if in powerdown, just return */ |
| 1871 | if ((mcs51.features & FEATURE_CMOS) && GET_PD) |
| 1872 | { |
| 1873 | mcs51_icount = 0; |
| 1874 | return cycles; |
| 1875 | } |
| 1876 | |
| 1877 | mcs51_icount -= mcs51.inst_cycles; |
| 1878 | burn_cycles(mcs51.inst_cycles); |
| 1879 | |
| 1880 | if ((mcs51.features & FEATURE_CMOS) && GET_IDL) |
| 1881 | { |
| 1882 | do |
| 1883 | { |
| 1884 | /* burn the cycles */ |
| 1885 | mcs51_icount--; |
| 1886 | burn_cycles(1); |
| 1887 | } while( mcs51_icount > 0 ); |
| 1888 | return cycles - mcs51_icount; |
| 1889 | } |
| 1890 | |
| 1891 | do |
| 1892 | { |
| 1893 | /* Read next opcode */ |
| 1894 | PPC = PC; |
| 1895 | debugger_instruction_hook(Machine, PC); |
| 1896 | op = cpu_readop(PC++); |
| 1897 | |
| 1898 | /* process opcode and count cycles */ |
| 1899 | mcs51.inst_cycles = mcs51_cycles[op]; |
| 1900 | execute_op(op); |
| 1901 | |
| 1902 | /* burn the cycles */ |
| 1903 | mcs51_icount -= mcs51.inst_cycles; |
| 1904 | |
| 1905 | /* if in powerdown, just return */ |
| 1906 | if ((mcs51.features & FEATURE_CMOS) && GET_PD) |
| 1907 | return cycles - mcs51_icount; |
| 1908 | |
| 1909 | burn_cycles(mcs51.inst_cycles); |
| 1910 | |
| 1911 | /* decrement the timed access window */ |
| 1912 | if (mcs51.features & FEATURE_DS5002FP) |
| 1913 | mcs51.ds5002fp.ta_window = (mcs51.ds5002fp.ta_window ? mcs51.ds5002fp.ta_window-- : 0x00); |
| 1914 | |
| 1915 | /* If the chip entered in idle mode, end the loop */ |
| 1916 | if ((mcs51.features & FEATURE_CMOS) && GET_IDL) |
| 1917 | return cycles - mcs51_icount; |
| 1918 | |
| 1919 | } while( mcs51_icount > 0 ); |
| 1920 | |
| 1921 | return cycles - mcs51_icount; |
| 1922 | } |
| 1923 | |
| 1924 | |
| 1925 | /**************************************************************************** |
| 1926 | * MCS51/8051 Section |
| 1927 | ****************************************************************************/ |
| 1928 | |
| 1929 | static void mcs51_sfr_write(size_t offset, UINT8 data) |
| 1930 | { |
| 1931 | /* update register */ |
| 1932 | assert(offset >= 0x80 && offset <= 0xff); |
| 1933 | |
| 1934 | /* TODO: Move to memory map */ |
| 1935 | switch (offset) |
| 1936 | { |
| 1937 | case ADDR_P0: OUT(MCS51_PORT_P0,data); break; |
| 1938 | case ADDR_P1: OUT(MCS51_PORT_P1,data); break; |
| 1939 | case ADDR_P2: OUT(MCS51_PORT_P2,data); break; |
| 1940 | case ADDR_P3: OUT(MCS51_PORT_P3,data); break; |
| 1941 | case ADDR_SBUF: serial_transmit(data); break; |
| 1942 | case ADDR_PSW: SET_PARITY(); break; |
| 1943 | case ADDR_ACC: SET_PARITY(); break; |
| 1944 | case ADDR_IP: update_irq_prio(data, 0); break; |
| 1945 | /* R_SBUF = data; //This register is used only for "Receiving data coming in!" */ |
| 1946 | |
| 1947 | case ADDR_B: |
| 1948 | case ADDR_SP: |
| 1949 | case ADDR_DPL: |
| 1950 | case ADDR_DPH: |
| 1951 | case ADDR_PCON: |
| 1952 | case ADDR_TCON: |
| 1953 | case ADDR_TMOD: |
| 1954 | case ADDR_IE: |
| 1955 | case ADDR_TL0: |
| 1956 | case ADDR_TL1: |
| 1957 | case ADDR_TH0: |
| 1958 | case ADDR_TH1: |
| 1959 | case ADDR_SCON: |
| 1960 | break; |
| 1961 | default: |
| 1962 | LOG(("mcs51 #%d: attemping to write to an invalid/non-implemented SFR address: %zx at 0x%04x, data=%x\n", cpu_getactivecpu(), offset,PC,data)); |
| 1963 | /* no write in this case according to manual */ |
| 1964 | return; |
| 1965 | } |
| 1966 | data_write_byte_8le((size_t)offset | 0x100, data); |
| 1967 | } |
| 1968 | |
| 1969 | static UINT8 mcs51_sfr_read(size_t offset) |
| 1970 | { |
| 1971 | assert(offset >= 0x80 && offset <= 0xff); |
| 1972 | |
| 1973 | switch (offset) |
| 1974 | { |
| 1975 | /* Read/Write/Modify operations read the port latch ! */ |
| 1976 | /* Move to memory map */ |
| 1977 | case ADDR_P0: return RWM ? P0 : P0 & IN(MCS51_PORT_P0); |
| 1978 | case ADDR_P1: return RWM ? P1 : P1 & IN(MCS51_PORT_P1); |
| 1979 | case ADDR_P2: return RWM ? P2 : P2 & IN(MCS51_PORT_P2); |
| 1980 | case ADDR_P3: return RWM ? P3 : P3 & IN(MCS51_PORT_P3); |
| 1981 | |
| 1982 | case ADDR_PSW: |
| 1983 | case ADDR_ACC: |
| 1984 | case ADDR_B: |
| 1985 | case ADDR_SP: |
| 1986 | case ADDR_DPL: |
| 1987 | case ADDR_DPH: |
| 1988 | case ADDR_PCON: |
| 1989 | case ADDR_TCON: |
| 1990 | case ADDR_TMOD: |
| 1991 | case ADDR_TL0: |
| 1992 | case ADDR_TL1: |
| 1993 | case ADDR_TH0: |
| 1994 | case ADDR_TH1: |
| 1995 | case ADDR_SCON: |
| 1996 | case ADDR_SBUF: |
| 1997 | case ADDR_IE: |
| 1998 | case ADDR_IP: |
| 1999 | return data_read_byte_8le((size_t) offset | 0x100); |
| 2000 | /* Illegal or non-implemented sfr */ |
| 2001 | default: |
| 2002 | LOG(("mcs51 #%d: attemping to read an invalid/non-implemented SFR address: %zx at 0x%04x\n", cpu_getactivecpu(), offset,PC)); |
| 2003 | /* according to the manual, the read may return random bits */ |
| 2004 | return 0xff; |
| 2005 | } |
| 2006 | } |
| 2007 | |
| 2008 | |
| 2009 | static void mcs51_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 2010 | { |
| 2011 | mcs51.irq_callback = irqcallback; |
| 2012 | |
| 2013 | mcs51.features = FEATURE_NONE; |
| 2014 | mcs51.ram_mask = 0x7F; /* 128 bytes of ram */ |
| 2015 | mcs51.num_interrupts = 5; /* 5 interrupts */ |
| 2016 | mcs51.sfr_read = mcs51_sfr_read; |
| 2017 | mcs51.sfr_write = mcs51_sfr_write; |
| 2018 | |
| 2019 | /* Save states */ |
| 2020 | state_save_register_item("mcs51", index, mcs51.ppc); |
| 2021 | state_save_register_item("mcs51", index, mcs51.pc); |
| 2022 | state_save_register_item("mcs51", index, mcs51.rwm ); |
| 2023 | state_save_register_item("mcs51", index, mcs51.cur_irq_prio ); |
| 2024 | state_save_register_item("mcs51", index, mcs51.last_line_state ); |
| 2025 | state_save_register_item("mcs51", index, mcs51.t0_cnt ); |
| 2026 | state_save_register_item("mcs51", index, mcs51.t1_cnt ); |
| 2027 | state_save_register_item("mcs51", index, mcs51.t2_cnt ); |
| 2028 | state_save_register_item("mcs51", index, mcs51.t2ex_cnt ); |
| 2029 | state_save_register_item("mcs51", index, mcs51.recalc_parity ); |
| 2030 | state_save_register_item_array("mcs51", index, mcs51.irq_prio ); |
| 2031 | state_save_register_item("mcs51", index, mcs51.irq_active ); |
| 2032 | } |
| 2033 | |
| 2034 | static void i80c51_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 2035 | { |
| 2036 | mcs51_init(index, clock, config, irqcallback); |
| 2037 | |
| 2038 | mcs51.features |= FEATURE_CMOS; |
| 2039 | } |
| 2040 | |
| 2041 | /* Reset registers to the initial values */ |
| 2042 | static void mcs51_reset(void) |
| 2043 | { |
| 2044 | update_ptrs(); |
| 2045 | //Set up serial call back handlers |
| 2046 | mcs51.serial_tx_callback = hold_serial_tx_callback; |
| 2047 | hold_serial_tx_callback = NULL; |
| 2048 | mcs51.serial_rx_callback = hold_serial_rx_callback; |
| 2049 | hold_serial_rx_callback = NULL; |
| 2050 | |
| 2051 | mcs51.last_line_state = 0; |
| 2052 | mcs51.t0_cnt = 0; |
| 2053 | mcs51.t1_cnt = 0; |
| 2054 | mcs51.t2_cnt = 0; |
| 2055 | mcs51.t2ex_cnt = 0; |
| 2056 | /* Flag as NO IRQ in Progress */ |
| 2057 | mcs51.irq_active = 0; |
| 2058 | mcs51.cur_irq_prio = -1; |
| 2059 | |
| 2060 | /* these are all defined reset states */ |
| 2061 | PC = 0; |
| 2062 | SP = 0x7; |
| 2063 | SET_PSW(0); |
| 2064 | SET_ACC(0); |
| 2065 | DPH = 0; |
| 2066 | DPL = 0; |
| 2067 | B = 0; |
| 2068 | IP = 0; |
| 2069 | update_irq_prio(IP, 0); |
| 2070 | IE = 0; |
| 2071 | SCON = 0; |
| 2072 | TCON = 0; |
| 2073 | TMOD = 0; |
| 2074 | PCON = 0; |
| 2075 | TH1 = 0; |
| 2076 | TH0 = 0; |
| 2077 | TL1 = 0; |
| 2078 | TL0 = 0; |
| 2079 | /* set the port configurations to all 1's */ |
| 2080 | SET_P3(0xff); |
| 2081 | SET_P2(0xff); |
| 2082 | SET_P1(0xff); |
| 2083 | SET_P0(0xff); |
| 2084 | |
| 2085 | /* 8052 Only registers */ |
| 2086 | if (mcs51.features & FEATURE_I8052) |
| 2087 | { |
| 2088 | T2CON = 0; |
| 2089 | RCAP2L = 0; |
| 2090 | RCAP2H = 0; |
| 2091 | TL2 = 0; |
| 2092 | TH2 = 0; |
| 2093 | } |
| 2094 | |
| 2095 | /* 80C52 Only registers */ |
| 2096 | if (mcs51.features & FEATURE_I80C52) |
| 2097 | { |
| 2098 | IPH = 0; |
| 2099 | update_irq_prio(IP, IPH); |
| 2100 | SADDR = 0; |
| 2101 | SADEN = 0; |
| 2102 | } |
| 2103 | |
| 2104 | /* DS5002FP Only registers */ |
| 2105 | if (mcs51.features & FEATURE_DS5002FP) |
| 2106 | { |
| 2107 | // set initial values (some of them are set using the bootstrap loader) |
| 2108 | PCON = 0; |
| 2109 | MCON = mcs51.ds5002fp.config->mcon & 0xfb; |
| 2110 | RPCTL = mcs51.ds5002fp.config->rpctl & 0x01; |
| 2111 | RPS = 0; |
| 2112 | RNR = 0; |
| 2113 | CRCR = mcs51.ds5002fp.config->crc & 0xf0; |
| 2114 | CRCL = 0; |
| 2115 | CRCH = 0; |
| 2116 | TA = 0; |
| 2117 | |
| 2118 | // set internal CPU state |
| 2119 | mcs51.ds5002fp.previous_ta = 0; |
| 2120 | mcs51.ds5002fp.ta_window = 0; |
| 2121 | mcs51.ds5002fp.range = (GET_RG1 << 1) | GET_RG0; |
| 2122 | } |
| 2123 | |
| 2124 | } |
| 2125 | |
| 2126 | /* Shut down CPU core */ |
| 2127 | static void mcs51_exit(void) |
| 2128 | { |
| 2129 | /* nothing to do */ |
| 2130 | } |
| 2131 | |
| 2132 | /**************************************************************************** |
| 2133 | * 8052 Section |
| 2134 | ****************************************************************************/ |
| 2135 | |
| 2136 | static void i8052_sfr_write(size_t offset, UINT8 data) |
| 2137 | { |
| 2138 | switch (offset) |
| 2139 | { |
| 2140 | /* 8052 family specific */ |
| 2141 | case ADDR_T2CON: |
| 2142 | case ADDR_RCAP2L: |
| 2143 | case ADDR_RCAP2H: |
| 2144 | case ADDR_TL2: |
| 2145 | case ADDR_TH2: |
| 2146 | data_write_byte_8le((size_t) offset | 0x100, data); |
| 2147 | break; |
| 2148 | |
| 2149 | default: |
| 2150 | mcs51_sfr_write(offset, data); |
| 2151 | } |
| 2152 | } |
| 2153 | |
| 2154 | static UINT8 i8052_sfr_read(size_t offset) |
| 2155 | { |
| 2156 | switch (offset) |
| 2157 | { |
| 2158 | /* 8052 family specific */ |
| 2159 | case ADDR_T2CON: |
| 2160 | case ADDR_RCAP2L: |
| 2161 | case ADDR_RCAP2H: |
| 2162 | case ADDR_TL2: |
| 2163 | case ADDR_TH2: |
| 2164 | return data_read_byte_8le((size_t) offset | 0x100); |
| 2165 | default: |
| 2166 | return mcs51_sfr_read(offset); |
| 2167 | } |
| 2168 | } |
| 2169 | |
| 2170 | static void i8052_init (int index, int clock, const void *config, int (*irqcallback)(int)) |
| 2171 | { |
| 2172 | mcs51_init(index, clock, config, irqcallback); |
| 2173 | |
| 2174 | mcs51.ram_mask = 0xFF; /* 256 bytes of ram */ |
| 2175 | mcs51.num_interrupts = 6; /* 6 interrupts */ |
| 2176 | |
| 2177 | mcs51.features |= FEATURE_I8052; |
| 2178 | mcs51.sfr_read = i8052_sfr_read; |
| 2179 | mcs51.sfr_write = i8052_sfr_write; |
| 2180 | } |
| 2181 | |
| 2182 | /**************************************************************************** |
| 2183 | * 80C52 Section |
| 2184 | ****************************************************************************/ |
| 2185 | |
| 2186 | static void i80c52_sfr_write(size_t offset, UINT8 data) |
| 2187 | { |
| 2188 | switch (offset) |
| 2189 | { |
| 2190 | /* 80c52 family specific */ |
| 2191 | case ADDR_IP: |
| 2192 | update_irq_prio(data, IPH); |
| 2193 | break; |
| 2194 | case ADDR_IPH: |
| 2195 | update_irq_prio(IP, data); |
| 2196 | break; |
| 2197 | case ADDR_SADDR: |
| 2198 | case ADDR_SADEN: |
| 2199 | break; |
| 2200 | |
| 2201 | default: |
| 2202 | i8052_sfr_write(offset, data); |
| 2203 | return; |
| 2204 | } |
| 2205 | data_write_byte_8le((size_t) offset | 0x100, data); |
| 2206 | } |
| 2207 | |
| 2208 | static UINT8 i80c52_sfr_read(size_t offset) |
| 2209 | { |
| 2210 | switch (offset) |
| 2211 | { |
| 2212 | /* 80c52 family specific */ |
| 2213 | case ADDR_IPH: |
| 2214 | case ADDR_SADDR: |
| 2215 | case ADDR_SADEN: |
| 2216 | return data_read_byte_8le((size_t) offset | 0x100); |
| 2217 | default: |
| 2218 | return i8052_sfr_read(offset); |
| 2219 | } |
| 2220 | } |
| 2221 | |
| 2222 | static void i80c52_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 2223 | { |
| 2224 | i8052_init(index, clock, config, irqcallback); |
| 2225 | |
| 2226 | mcs51.features |= (FEATURE_I80C52 | FEATURE_CMOS); |
| 2227 | mcs51.sfr_read = i80c52_sfr_read; |
| 2228 | mcs51.sfr_write = i80c52_sfr_write; |
| 2229 | } |
| 2230 | |
| 2231 | static void i80c31_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 2232 | { |
| 2233 | i80c52_init(index, clock, config, irqcallback); |
| 2234 | |
| 2235 | mcs51.ram_mask = 0x7F; /* 128 bytes of ram */ |
| 2236 | } |
| 2237 | |
| 2238 | /**************************************************************************** |
| 2239 | * DS5002FP Section |
| 2240 | ****************************************************************************/ |
| 2241 | #if 0 |
| 2242 | |
| 2243 | #define DS5_LOGW(a, d) LOG(("ds5002fp #%d: write to " # a " register at 0x%04x, data=%x\n", cpu_getactivecpu(), PC, d)) |
| 2244 | #define DS5_LOGR(a, d) LOG(("ds5002fp #%d: read from " # a " register at 0x%04x\n", cpu_getactivecpu(), PC)) |
| 2245 | |
| 2246 | INLINE UINT8 ds5002fp_protected(size_t offset, UINT8 data, UINT8 ta_mask, UINT8 mask) |
| 2247 | { |
| 2248 | UINT8 is_timed_access; |
| 2249 | |
| 2250 | is_timed_access = (mcs51.ds5002fp.ta_window > 0) && (TA == 0x55); |
| 2251 | if (is_timed_access) |
| 2252 | { |
| 2253 | ta_mask = 0xff; |
| 2254 | } |
| 2255 | data = (mcs51.sfr_ram[offset] & (~ta_mask)) | (data & ta_mask); |
| 2256 | return (mcs51.sfr_ram[offset] & (~mask)) | (data & mask); |
| 2257 | } |
| 2258 | |
| 2259 | static void ds5002fp_sfr_write(size_t offset, UINT8 data) |
| 2260 | { |
| 2261 | switch (offset) |
| 2262 | { |
| 2263 | |
| 2264 | case ADDR_TA: |
| 2265 | mcs51.ds5002fp.previous_ta = TA; |
| 2266 | /* init the time window after having wrote 0xaa */ |
| 2267 | if ((data == 0xaa) && (mcs51.ds5002fp.ta_window == 0)) |
| 2268 | { |
| 2269 | mcs51.ds5002fp.ta_window = 6; /* 4*12 + 2*12 */ |
| 2270 | LOG(("ds5002fp #%d: TA window initiated at 0x%04x\n", cpu_getactivecpu(), PC)); |
| 2271 | } |
| 2272 | break; |
| 2273 | case ADDR_MCON: data = ds5002fp_protected(ADDR_MCON, data, 0x0f, 0xf7); DS5_LOGW(MCON, data); break; |
| 2274 | case ADDR_RPCTL: data = ds5002fp_protected(ADDR_RPCTL, data, 0xef, 0xfe); DS5_LOGW(RPCTL, data); break; |
| 2275 | case ADDR_CRCR: data = ds5002fp_protected(ADDR_CRCR, data, 0xff, 0x0f); DS5_LOGW(CRCR, data); break; |
| 2276 | case ADDR_PCON: data = ds5002fp_protected(ADDR_PCON, data, 0xb9, 0xff); break; |
| 2277 | case ADDR_IP: data = ds5002fp_protected(ADDR_IP, data, 0x7f, 0xff); break; |
| 2278 | case ADDR_CRCL: DS5_LOGW(CRCL, data); break; |
| 2279 | case ADDR_CRCH: DS5_LOGW(CRCH, data); break; |
| 2280 | case ADDR_RNR: DS5_LOGW(RNR, data); break; |
| 2281 | case ADDR_RPS: DS5_LOGW(RPS, data); break; |
| 2282 | default: |
| 2283 | mcs51_sfr_write(offset, data); |
| 2284 | return; |
| 2285 | } |
| 2286 | data_write_byte_8le((size_t) offset | 0x100, data); |
| 2287 | } |
| 2288 | |
| 2289 | static UINT8 ds5002fp_sfr_read(size_t offset) |
| 2290 | { |
| 2291 | switch (offset) |
| 2292 | { |
| 2293 | case ADDR_CRCR: DS5_LOGR(CRCR, data); break; |
| 2294 | case ADDR_CRCL: DS5_LOGR(CRCL, data); break; |
| 2295 | case ADDR_CRCH: DS5_LOGR(CRCH, data); break; |
| 2296 | case ADDR_MCON: DS5_LOGR(MCON, data); break; |
| 2297 | case ADDR_TA: DS5_LOGR(TA, data); break; |
| 2298 | case ADDR_RNR: DS5_LOGR(RNR, data); break; |
| 2299 | case ADDR_RPCTL: DS5_LOGR(RPCTL, data); break; |
| 2300 | case ADDR_RPS: DS5_LOGR(RPS, data); break; |
| 2301 | case ADDR_PCON: |
| 2302 | SET_PFW(0); /* reset PFW flag */ |
| 2303 | return mcs51_sfr_read(offset); /* FIXME: cmos features ??? */ |
| 2304 | default: |
| 2305 | return mcs51_sfr_read(offset); /* FIXME: cmos features ??? */ |
| 2306 | } |
| 2307 | return data_read_byte_8le((size_t) offset | 0x100); |
| 2308 | } |
| 2309 | |
| 2310 | static void ds5002fp_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 2311 | { |
| 2312 | /* default configuration */ |
| 2313 | static const ds5002fp_config default_config = { 0x00, 0x00, 0x00 }; |
| 2314 | const ds5002fp_config *sconfig = config ? config : &default_config; |
| 2315 | |
| 2316 | mcs51_init(index, clock, config, irqcallback); |
| 2317 | |
| 2318 | mcs51.ds5002fp.config = sconfig; |
| 2319 | mcs51.features |= (FEATURE_DS5002FP | FEATURE_CMOS); |
| 2320 | mcs51.sfr_read = ds5002fp_sfr_read; |
| 2321 | mcs51.sfr_write = ds5002fp_sfr_write; |
| 2322 | |
| 2323 | state_save_register_item("mcs51", index, mcs51.ds5002fp.previous_ta ); |
| 2324 | state_save_register_item("mcs51", index, mcs51.ds5002fp.ta_window ); |
| 2325 | state_save_register_item("mcs51", index, mcs51.ds5002fp.range ); |
| 2326 | |
| 2327 | } |
| 2328 | #endif |
| 2329 | |
| 2330 | /*************************************************************************** |
| 2331 | ADDRESS MAPS |
| 2332 | ***************************************************************************/ |
| 2333 | |
| 2334 | |
| 2335 | /* FIXME: the memory maps should probably support rom banking for EA */ |
| 2336 | static ADDRESS_MAP_START(program_12bit, ADDRESS_SPACE_PROGRAM, 8) |
| 2337 | AM_RANGE(0x00, 0x0fff) AM_ROM |
| 2338 | ADDRESS_MAP_END |
| 2339 | |
| 2340 | static ADDRESS_MAP_START(program_13bit, ADDRESS_SPACE_PROGRAM, 8) |
| 2341 | AM_RANGE(0x00, 0x1fff) AM_ROM |
| 2342 | ADDRESS_MAP_END |
| 2343 | |
| 2344 | static ADDRESS_MAP_START(data_7bit, ADDRESS_SPACE_DATA, 8) |
| 2345 | AM_RANGE(0x0000, 0x007f) AM_RAM |
| 2346 | AM_RANGE(0x0100, 0x01ff) AM_RAM /* SFR */ |
| 2347 | ADDRESS_MAP_END |
| 2348 | |
| 2349 | static ADDRESS_MAP_START(data_8bit, ADDRESS_SPACE_DATA, 8) |
| 2350 | AM_RANGE(0x0000, 0x00ff) AM_RAM |
| 2351 | AM_RANGE(0x0100, 0x01ff) AM_RAM /* SFR */ |
| 2352 | ADDRESS_MAP_END |
| 2353 | |
| 2354 | |
| 2355 | /*************************************************************************** |
| 2356 | GENERAL CONTEXT ACCESS |
| 2357 | ***************************************************************************/ |
| 2358 | |
| 2359 | static void mcs51_get_context(void *dst) |
| 2360 | { |
| 2361 | if( dst ) |
| 2362 | memcpy(dst, &mcs51, sizeof(mcs51_regs)); |
| 2363 | } |
| 2364 | |
| 2365 | static void mcs51_set_context(void *src) |
| 2366 | { |
| 2367 | if( src ) |
| 2368 | memcpy(&mcs51, src, sizeof(mcs51_regs)); |
| 2369 | change_pc(PC); |
| 2370 | update_ptrs(); |
| 2371 | } |
| 2372 | |
| 2373 | /************************************************************************** |
| 2374 | * Generic set_info |
| 2375 | **************************************************************************/ |
| 2376 | |
| 2377 | static void mcs51_set_info(UINT32 state, cpuinfo *info) |
| 2378 | { |
| 2379 | switch (state) |
| 2380 | { |
| 2381 | /* --- the following bits of info are set as 64-bit signed integers --- */ |
| 2382 | case CPUINFO_INT_PC: PC = info->i; break; |
| 2383 | case CPUINFO_INT_SP: SP = info->i; break; |
| 2384 | |
| 2385 | case CPUINFO_INT_INPUT_STATE + MCS51_INT0_LINE: mcs51_set_irq_line(MCS51_INT0_LINE, info->i); break; |
| 2386 | case CPUINFO_INT_INPUT_STATE + MCS51_INT1_LINE: mcs51_set_irq_line(MCS51_INT1_LINE, info->i); break; |
| 2387 | case CPUINFO_INT_INPUT_STATE + MCS51_T0_LINE: mcs51_set_irq_line(MCS51_T0_LINE, info->i); break; |
| 2388 | case CPUINFO_INT_INPUT_STATE + MCS51_T1_LINE: mcs51_set_irq_line(MCS51_T1_LINE, info->i); break; |
| 2389 | case CPUINFO_INT_INPUT_STATE + MCS51_RX_LINE: mcs51_set_irq_line(MCS51_RX_LINE, info->i); break; |
| 2390 | |
| 2391 | case CPUINFO_INT_REGISTER + MCS51_PC: PC = info->i; break; |
| 2392 | case CPUINFO_INT_REGISTER + MCS51_SP: SP = info->i; break; |
| 2393 | case CPUINFO_INT_REGISTER + MCS51_PSW: SET_PSW(info->i); break; |
| 2394 | case CPUINFO_INT_REGISTER + MCS51_ACC: SET_ACC(info->i); break; |
| 2395 | case CPUINFO_INT_REGISTER + MCS51_B: B = info->i; break; |
| 2396 | case CPUINFO_INT_REGISTER + MCS51_DPH: DPH = info->i; break; |
| 2397 | case CPUINFO_INT_REGISTER + MCS51_DPL: DPL = info->i; break; |
| 2398 | case CPUINFO_INT_REGISTER + MCS51_IE: IE = info->i; break; |
| 2399 | case CPUINFO_INT_REGISTER + MCS51_R0: SET_REG(0, info->i); break; |
| 2400 | case CPUINFO_INT_REGISTER + MCS51_R1: SET_REG(1, info->i); break; |
| 2401 | case CPUINFO_INT_REGISTER + MCS51_R2: SET_REG(2, info->i); break; |
| 2402 | case CPUINFO_INT_REGISTER + MCS51_R3: SET_REG(3, info->i); break; |
| 2403 | case CPUINFO_INT_REGISTER + MCS51_R4: SET_REG(4, info->i); break; |
| 2404 | case CPUINFO_INT_REGISTER + MCS51_R5: SET_REG(5, info->i); break; |
| 2405 | case CPUINFO_INT_REGISTER + MCS51_R6: SET_REG(6, info->i); break; |
| 2406 | case CPUINFO_INT_REGISTER + MCS51_R7: SET_REG(7, info->i); break; |
| 2407 | case CPUINFO_INT_REGISTER + MCS51_RB: SET_RS(info->i); break; |
| 2408 | } |
| 2409 | } |
| 2410 | |
| 2411 | |
| 2412 | |
| 2413 | /************************************************************************** |
| 2414 | * Generic get_info |
| 2415 | **************************************************************************/ |
| 2416 | |
| 2417 | static void mcs51_get_info(UINT32 state, cpuinfo *info) |
| 2418 | { |
| 2419 | mcs51_regs *r = &mcs51; |
| 2420 | |
| 2421 | switch (state) |
| 2422 | { |
| 2423 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 2424 | case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(mcs51); break; |
| 2425 | case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; |
| 2426 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_LE; break; |
| 2427 | case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break; |
| 2428 | case CPUINFO_INT_CLOCK_DIVIDER: info->i = 12; break; |
| 2429 | case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 1; break; |
| 2430 | case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 5; break; |
| 2431 | case CPUINFO_INT_MIN_CYCLES: info->i = 1; break; |
| 2432 | case CPUINFO_INT_MAX_CYCLES: info->i = 20; /* rough guess */ break; |
| 2433 | case CPUINFO_INT_INPUT_LINES: info->i = 3; break; |
| 2434 | |
| 2435 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 8; break; |
| 2436 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 16; break; |
| 2437 | case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 0; break; |
| 2438 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA: info->i = 8; break; |
| 2439 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA: info->i = 9; /* due to sfr mapping */ break; |
| 2440 | case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA: info->i = 0; break; |
| 2441 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO: info->i = 8; break; |
| 2442 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO: info->i = 17; break; |
| 2443 | case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO: info->i = 0; break; |
| 2444 | |
| 2445 | case CPUINFO_INT_PREVIOUSPC: info->i = PPC; break; |
| 2446 | case CPUINFO_INT_PC: info->i = PC; break; |
| 2447 | case CPUINFO_INT_SP: info->i = SP; break; |
| 2448 | |
| 2449 | case CPUINFO_INT_REGISTER + MCS51_PC: info->i = PC; break; |
| 2450 | case CPUINFO_INT_REGISTER + MCS51_SP: info->i = SP; break; |
| 2451 | case CPUINFO_INT_REGISTER + MCS51_PSW: info->i = PSW; break; |
| 2452 | case CPUINFO_INT_REGISTER + MCS51_ACC: info->i = ACC; break; |
| 2453 | case CPUINFO_INT_REGISTER + MCS51_B: info->i = B; break; |
| 2454 | case CPUINFO_INT_REGISTER + MCS51_DPH: info->i = DPH; break; |
| 2455 | case CPUINFO_INT_REGISTER + MCS51_DPL: info->i = DPL; break; |
| 2456 | case CPUINFO_INT_REGISTER + MCS51_IE: info->i = IE; break; |
| 2457 | case CPUINFO_INT_REGISTER + MCS51_R0: info->i = R_REG(0); break; |
| 2458 | case CPUINFO_INT_REGISTER + MCS51_R1: info->i = R_REG(1); break; |
| 2459 | case CPUINFO_INT_REGISTER + MCS51_R2: info->i = R_REG(2); break; |
| 2460 | case CPUINFO_INT_REGISTER + MCS51_R3: info->i = R_REG(3); break; |
| 2461 | case CPUINFO_INT_REGISTER + MCS51_R4: info->i = R_REG(4); break; |
| 2462 | case CPUINFO_INT_REGISTER + MCS51_R5: info->i = R_REG(5); break; |
| 2463 | case CPUINFO_INT_REGISTER + MCS51_R6: info->i = R_REG(6); break; |
| 2464 | case CPUINFO_INT_REGISTER + MCS51_R7: info->i = R_REG(7); break; |
| 2465 | case CPUINFO_INT_REGISTER + MCS51_RB: info->i = R_REG(8); break; |
| 2466 | |
| 2467 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 2468 | case CPUINFO_PTR_SET_INFO: info->setinfo = mcs51_set_info; break; |
| 2469 | case CPUINFO_PTR_GET_CONTEXT: info->getcontext = mcs51_get_context; break; |
| 2470 | case CPUINFO_PTR_SET_CONTEXT: info->setcontext = mcs51_set_context; break; |
| 2471 | case CPUINFO_PTR_INIT: info->init = mcs51_init; break; |
| 2472 | case CPUINFO_PTR_RESET: info->reset = mcs51_reset; break; |
| 2473 | case CPUINFO_PTR_EXIT: info->exit = mcs51_exit; break; |
| 2474 | case CPUINFO_PTR_EXECUTE: info->execute = mcs51_execute; break; |
| 2475 | case CPUINFO_PTR_BURN: info->burn = NULL; break; |
| 2476 | case CPUINFO_PTR_DISASSEMBLE: info->disassemble = i8051_dasm; break; |
| 2477 | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &mcs51_icount; break; |
| 2478 | |
| 2479 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = NULL; break; |
| 2480 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = NULL; break; |
| 2481 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_IO: info->internal_map8 = NULL; break; |
| 2482 | |
| 2483 | case CPUINFO_STR_NAME: strcpy(info->s, "I8051"); break; |
| 2484 | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "MCS-51"); break; |
| 2485 | case CPUINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break; |
| 2486 | case CPUINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break; |
| 2487 | case CPUINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Steve Ellenoff"); break; |
| 2488 | |
| 2489 | case CPUINFO_STR_FLAGS: |
| 2490 | sprintf(info->s, "%c%c%c%c%c%c%c%c", |
| 2491 | PSW & 0x80 ? 'C':'.', |
| 2492 | PSW & 0x40 ? 'A':'.', |
| 2493 | PSW & 0x20 ? 'F':'.', |
| 2494 | PSW & 0x10 ? '0':'.', |
| 2495 | PSW & 0x08 ? '1':'.', |
| 2496 | PSW & 0x04 ? 'V':'.', |
| 2497 | PSW & 0x02 ? '?':'.', |
| 2498 | PSW & 0x01 ? 'P':'.'); |
| 2499 | break; |
| 2500 | |
| 2501 | case CPUINFO_STR_REGISTER + MCS51_PC: sprintf(info->s, "PC:%04X", r->pc); break; |
| 2502 | case CPUINFO_STR_REGISTER + MCS51_SP: sprintf(info->s, "SP:%02X", SP); break; |
| 2503 | case CPUINFO_STR_REGISTER + MCS51_PSW: sprintf(info->s, "PSW:%02X", PSW); break; |
| 2504 | case CPUINFO_STR_REGISTER + MCS51_ACC: sprintf(info->s, "A:%02X", ACC); break; |
| 2505 | case CPUINFO_STR_REGISTER + MCS51_B: sprintf(info->s, "B:%02X", B); break; |
| 2506 | case CPUINFO_STR_REGISTER + MCS51_DPH: sprintf(info->s, "DPH:%02X", DPH); break; |
| 2507 | case CPUINFO_STR_REGISTER + MCS51_DPL: sprintf(info->s, "DPL:%02X", DPL); break; |
| 2508 | case CPUINFO_STR_REGISTER + MCS51_IE: sprintf(info->s, "IE:%02X", IE); break; |
| 2509 | case CPUINFO_STR_REGISTER + MCS51_R0: sprintf(info->s, "R0:%02X", R_REG(0)); break; |
| 2510 | case CPUINFO_STR_REGISTER + MCS51_R1: sprintf(info->s, "R1:%02X", R_REG(1)); break; |
| 2511 | case CPUINFO_STR_REGISTER + MCS51_R2: sprintf(info->s, "R2:%02X", R_REG(2)); break; |
| 2512 | case CPUINFO_STR_REGISTER + MCS51_R3: sprintf(info->s, "R3:%02X", R_REG(3)); break; |
| 2513 | case CPUINFO_STR_REGISTER + MCS51_R4: sprintf(info->s, "R4:%02X", R_REG(4)); break; |
| 2514 | case CPUINFO_STR_REGISTER + MCS51_R5: sprintf(info->s, "R5:%02X", R_REG(5)); break; |
| 2515 | case CPUINFO_STR_REGISTER + MCS51_R6: sprintf(info->s, "R6:%02X", R_REG(6)); break; |
| 2516 | case CPUINFO_STR_REGISTER + MCS51_R7: sprintf(info->s, "R7:%02X", R_REG(7)); break; |
| 2517 | case CPUINFO_STR_REGISTER + MCS51_RB: sprintf(info->s, "RB:%02X", ((PSW & 0x18)>>3)); break; |
| 2518 | } |
| 2519 | } |
| 2520 | |
| 2521 | /************************************************************************** |
| 2522 | * Specific get_info |
| 2523 | **************************************************************************/ |
| 2524 | |
| 2525 | void i8031_get_info(UINT32 state, cpuinfo *info) |
| 2526 | { |
| 2527 | switch (state) |
| 2528 | { |
| 2529 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = address_map_data_7bit; break; |
| 2530 | |
| 2531 | case CPUINFO_STR_NAME: strcpy(info->s, "I8031"); break; |
| 2532 | default: mcs51_get_info(state, info); break; |
| 2533 | } |
| 2534 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2535 | } |
| 2536 | |
| 2537 | void i8051_get_info(UINT32 state, cpuinfo *info) |
| 2538 | { |
| 2539 | switch (state) |
| 2540 | { |
| 2541 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_12bit; break; |
| 2542 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = address_map_data_7bit; break; |
| 2543 | |
| 2544 | case CPUINFO_STR_NAME: strcpy(info->s, "I8051"); break; |
| 2545 | default: mcs51_get_info(state, info); break; |
| 2546 | } |
| 2547 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 2548 | } |
| 2549 | |
| 2550 | void i8032_get_info(UINT32 state, cpuinfo *info) |
| 2551 | { |
| 2552 | switch (state) |
| 2553 | { |
| 2554 | case CPUINFO_PTR_INIT: info->init = i8052_init; break; |
| 2555 | |
| 2556 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = address_map_data_8bit; break; |
| 2557 | |
| 2558 | case CPUINFO_STR_NAME: strcpy(info->s, "I8032"); break; |
| 2559 | |
| 2560 | default: mcs51_get_info(state, info); break; |
| 2561 | } |
| 2562 | } |
| 2563 | |
| 2564 | void i8052_get_info(UINT32 state, cpuinfo *info) |
| 2565 | { |
| 2566 | switch (state) |
| 2567 | { |
| 2568 | case CPUINFO_PTR_INIT: info->init = i8052_init; break; |
| 2569 | |
| 2570 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_13bit; break; |
| 2571 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = address_map_data_8bit; break; |
| 2572 | |
| 2573 | case CPUINFO_STR_NAME: strcpy(info->s, "I8052"); break; |
| 2574 | |
| 2575 | default: mcs51_get_info(state, info); break; |
| 2576 | } |
| 2577 | } |
| 2578 | |
| 2579 | void i8751_get_info(UINT32 state, cpuinfo *info) |
| 2580 | { |
| 2581 | switch (state) |
| 2582 | { |
| 2583 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_12bit; break; |
| 2584 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = address_map_data_7bit; break; |
| 2585 | |
| 2586 | case CPUINFO_STR_NAME: strcpy(info->s, "I8751"); break; |
| 2587 | |
| 2588 | default: mcs51_get_info(state, info); break; |
| 2589 | } |
| 2590 | } |
| 2591 | |
| 2592 | void i8752_get_info(UINT32 state, cpuinfo *info) |
| 2593 | { |
| 2594 | switch (state) |
| 2595 | { |
| 2596 | case CPUINFO_PTR_INIT: info->init = i8052_init; break; |
| 2597 | |
| 2598 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = address_map_program_13bit; break; |
| 2599 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = address_map_data_8bit; break; |
| 2600 | |
| 2601 | case CPUINFO_STR_NAME: strcpy(info->s, "I8752"); break; |
| 2602 | |
| 2603 | default: mcs51_get_info(state, info); break; |
| 2604 | } |
| 2605 | } |
| 2606 | |
| 2607 | /************************************************************************** |
| 2608 | * CMOS get_info |
| 2609 | **************************************************************************/ |
| 2610 | |
| 2611 | void i80c31_get_info(UINT32 state, cpuinfo *info) |
| 2612 | { |
| 2613 | /* according to PHILIPS datasheet this is a stripped down version |
| 2614 | * of i80c52 with 128 bytes internal ram */ |
| 2615 | switch (state) |
| 2616 | { |
| 2617 | case CPUINFO_PTR_INIT: info->init = i80c31_init; break; |
| 2618 | |
| 2619 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map8 = NULL; break; |
| 2620 | case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_DATA: info->internal_map8 = address_map_data_7bit; break; |
| 2621 | |
| 2622 | case CPUINFO_STR_NAME: strcpy(info->s, "I80C31"); break; |
| 2623 | default: i8031_get_info(state, info); break; |
| 2624 | } |
| 2625 | } |
| 2626 | |
| 2627 | void i80c51_get_info(UINT32 state, cpuinfo *info) |
| 2628 | { |
| 2629 | switch (state) |
| 2630 | { |
| 2631 | case CPUINFO_PTR_INIT: info->init = i80c51_init; break; |
| 2632 | case CPUINFO_STR_NAME: strcpy(info->s, "I80C51"); break; |
| 2633 | default: i8051_get_info(state, info); break; |
| 2634 | } |
| 2635 | } |
| 2636 | |
| 2637 | void i80c32_get_info(UINT32 state, cpuinfo *info) |
| 2638 | { |
| 2639 | switch (state) |
| 2640 | { |
| 2641 | case CPUINFO_PTR_INIT: info->init = i80c52_init; break; |
| 2642 | case CPUINFO_STR_NAME: strcpy(info->s, "I80C32"); break; |
| 2643 | default: i8032_get_info(state, info); break; |
| 2644 | } |
| 2645 | } |
| 2646 | |
| 2647 | void i80c52_get_info(UINT32 state, cpuinfo *info) |
| 2648 | { |
| 2649 | switch (state) |
| 2650 | { |
| 2651 | case CPUINFO_PTR_INIT: info->init = i80c52_init; break; |
| 2652 | case CPUINFO_STR_NAME: strcpy(info->s, "I80C52"); break; |
| 2653 | default: i8052_get_info(state, info); break; |
| 2654 | } |
| 2655 | } |
| 2656 | |
| 2657 | void i87c51_get_info(UINT32 state, cpuinfo *info) |
| 2658 | { |
| 2659 | switch (state) |
| 2660 | { |
| 2661 | case CPUINFO_PTR_INIT: info->init = i80c51_init; break; |
| 2662 | case CPUINFO_STR_NAME: strcpy(info->s, "I87C51"); break; |
| 2663 | default: i8751_get_info(state, info); break; |
| 2664 | } |
| 2665 | } |
| 2666 | |
| 2667 | void i87c52_get_info(UINT32 state, cpuinfo *info) |
| 2668 | { |
| 2669 | switch (state) |
| 2670 | { |
| 2671 | case CPUINFO_PTR_INIT: info->init = i80c52_init; break; |
| 2672 | case CPUINFO_STR_NAME: strcpy(info->s, "I87C52"); break; |
| 2673 | default: i8752_get_info(state, info); break; |
| 2674 | } |
| 2675 | } |
| 2676 | |
| 2677 | /************************************************************************** |
| 2678 | * Other variants get_info |
| 2679 | **************************************************************************/ |
| 2680 | |
| 2681 | void at89c4051_get_info(UINT32 state, cpuinfo *info) |
| 2682 | { |
| 2683 | switch (state) |
| 2684 | { |
| 2685 | case CPUINFO_PTR_INIT: info->init = i80c51_init; break; |
| 2686 | case CPUINFO_STR_NAME: strcpy(info->s, "AT89C4051"); break; |
| 2687 | default: i8051_get_info(state, info); break; |
| 2688 | } |
| 2689 | } |
src/emu/cpu/mcs51/mcs51ops.c
| r0 | r3515 | |
| 1 | /******************************************************************************************* |
| 2 | NOTE: All registers are accessed directly, instead of using the SFR_R() function for speed |
| 3 | Direct register access is availabe from the R_(register name) macros.. ex: ACC for the ACC |
| 4 | with the exception of the PC |
| 5 | ********************************************************************************************/ |
| 6 | |
| 7 | //ACALL code addr /* 1: aaa1 0001 */ |
| 8 | INLINE void acall(UINT8 op) |
| 9 | { |
| 10 | UINT8 addr = ROP_ARG(PC++); //Grab code address byte |
| 11 | PUSH_PC(); //Save PC to the stack |
| 12 | //Thanks Gerrit for help with this! :) |
| 13 | PC = (PC & 0xf800) | ((op & 0xe0) << 3) | addr; |
| 14 | change_pc(PC); |
| 15 | } |
| 16 | |
| 17 | //ADD A, #data /* 1: 0010 0100 */ |
| 18 | INLINE void add_a_byte(void) |
| 19 | { |
| 20 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 21 | UINT8 result = ACC + data; //Add data to accumulator |
| 22 | DO_ADD_FLAGS(ACC,data,0); //Set Flags |
| 23 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 24 | } |
| 25 | |
| 26 | //ADD A, data addr /* 1: 0010 0101 */ |
| 27 | INLINE void add_a_mem(void) |
| 28 | { |
| 29 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 30 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 31 | UINT8 result = ACC + data; //Add data to accumulator |
| 32 | DO_ADD_FLAGS(ACC,data,0); //Set Flags |
| 33 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 34 | } |
| 35 | |
| 36 | //ADD A, @R0/@R1 /* 1: 0010 011i */ |
| 37 | INLINE void add_a_ir(int r) |
| 38 | { |
| 39 | UINT8 data = IRAM_IR(R_REG(r)); //Grab data from memory pointed to by R0 or R1 |
| 40 | UINT8 result = ACC + data; //Add data to accumulator |
| 41 | DO_ADD_FLAGS(ACC,data,0); //Set Flags |
| 42 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 43 | } |
| 44 | |
| 45 | //ADD A, R0 to R7 /* 1: 0010 1rrr */ |
| 46 | INLINE void add_a_r(int r) |
| 47 | { |
| 48 | UINT8 data = R_REG(r); //Grab data from R0 - R7 |
| 49 | UINT8 result = ACC + data; //Add data to accumulator |
| 50 | DO_ADD_FLAGS(ACC,data,0); //Set Flags |
| 51 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 52 | } |
| 53 | |
| 54 | //ADDC A, #data /* 1: 0011 0100 */ |
| 55 | INLINE void addc_a_byte(void) |
| 56 | { |
| 57 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 58 | UINT8 result = ACC + data + GET_CY; //Add data + carry flag to accumulator |
| 59 | DO_ADD_FLAGS(ACC,data,GET_CY); //Set Flags |
| 60 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 61 | } |
| 62 | |
| 63 | //ADDC A, data addr /* 1: 0011 0101 */ |
| 64 | INLINE void addc_a_mem(void) |
| 65 | { |
| 66 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 67 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 68 | UINT8 result = ACC + data + GET_CY; //Add data + carry flag to accumulator |
| 69 | DO_ADD_FLAGS(ACC,data,GET_CY); //Set Flags |
| 70 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 71 | } |
| 72 | |
| 73 | //ADDC A, @R0/@R1 /* 1: 0011 011i */ |
| 74 | INLINE void addc_a_ir(int r) |
| 75 | { |
| 76 | UINT8 data = IRAM_IR(R_REG(r)); //Grab data from memory pointed to by R0 or R1 |
| 77 | UINT8 result = ACC + data + GET_CY; //Add data + carry flag to accumulator |
| 78 | DO_ADD_FLAGS(ACC,data,GET_CY); //Set Flags |
| 79 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 80 | } |
| 81 | |
| 82 | //ADDC A, R0 to R7 /* 1: 0011 1rrr */ |
| 83 | INLINE void addc_a_r(int r) |
| 84 | { |
| 85 | UINT8 data = R_REG(r); //Grab data from R0 - R7 |
| 86 | UINT8 result = ACC + data + GET_CY; //Add data + carry flag to accumulator |
| 87 | DO_ADD_FLAGS(ACC,data,GET_CY); //Set Flags |
| 88 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 89 | } |
| 90 | |
| 91 | //AJMP code addr /* 1: aaa0 0001 */ |
| 92 | INLINE void ajmp(UINT8 op) |
| 93 | { |
| 94 | UINT8 addr = ROP_ARG(PC++); //Grab code address byte |
| 95 | //Thanks Gerrit for help with this! :) |
| 96 | PC = (PC & 0xf800) | ((op & 0xe0) << 3) | addr; |
| 97 | change_pc(PC); |
| 98 | } |
| 99 | |
| 100 | //ANL data addr, A /* 1: 0101 0010 */ |
| 101 | INLINE void anl_mem_a(void) |
| 102 | { |
| 103 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 104 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 105 | IRAM_W(addr,data & ACC); //Set data address value to it's value Logical AND with ACC |
| 106 | } |
| 107 | |
| 108 | //ANL data addr, #data /* 1: 0101 0011 */ |
| 109 | INLINE void anl_mem_byte(void) |
| 110 | { |
| 111 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 112 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 113 | UINT8 srcdata = IRAM_R(addr); //Grab data from data address |
| 114 | IRAM_W(addr,srcdata & data); //Set data address value to it's value Logical AND with Data |
| 115 | } |
| 116 | |
| 117 | //ANL A, #data /* 1: 0101 0100 */ |
| 118 | INLINE void anl_a_byte(void) |
| 119 | { |
| 120 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 121 | SET_ACC(ACC & data); //Set ACC to value of ACC Logical AND with Data |
| 122 | } |
| 123 | |
| 124 | //ANL A, data addr /* 1: 0101 0101 */ |
| 125 | INLINE void anl_a_mem(void) |
| 126 | { |
| 127 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 128 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 129 | SET_ACC(ACC & data); //Set ACC to value of ACC Logical AND with Data |
| 130 | } |
| 131 | |
| 132 | //ANL A, @RO/@R1 /* 1: 0101 011i */ |
| 133 | INLINE void anl_a_ir(int r) |
| 134 | { |
| 135 | UINT8 data = IRAM_IR(R_REG(r)); //Grab data from address R0 or R1 points to |
| 136 | SET_ACC(ACC & data); //Set ACC to value of ACC Logical AND with Data |
| 137 | } |
| 138 | |
| 139 | //ANL A, RO to R7 /* 1: 0101 1rrr */ |
| 140 | INLINE void anl_a_r(int r) |
| 141 | { |
| 142 | UINT8 data = R_REG(r); //Grab data from R0 - R7 |
| 143 | SET_ACC(ACC & data); //Set ACC to value of ACC Logical AND with Data |
| 144 | } |
| 145 | |
| 146 | //ANL C, bit addr /* 1: 1000 0010 */ |
| 147 | INLINE void anl_c_bitaddr(void) |
| 148 | { |
| 149 | int cy = GET_CY; |
| 150 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 151 | UINT8 bit = BIT_R(addr); //Grab bit data from bit address |
| 152 | SET_CY( (cy & bit) ); //Set Carry flag to Carry Flag Value Logical AND with Bit |
| 153 | } |
| 154 | |
| 155 | //ANL C,/bit addr /* 1: 1011 0000 */ |
| 156 | INLINE void anl_c_nbitaddr(void) |
| 157 | { |
| 158 | int cy = GET_CY; |
| 159 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 160 | UINT8 bit = BIT_R(addr); //Grab bit data from bit address |
| 161 | bit = ((~bit)&1); //Complement bit |
| 162 | SET_CY( (cy & bit) ); //Set Carry flag to Carry Flag Value Logical AND with Complemented Bit |
| 163 | } |
| 164 | |
| 165 | //CJNE A, #data, code addr /* 1: 1011 0100 */ |
| 166 | INLINE void cjne_a_byte(void) |
| 167 | { |
| 168 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 169 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 170 | |
| 171 | if(ACC != data) //Jump if values are not equal |
| 172 | { |
| 173 | PC = PC + rel_addr; |
| 174 | change_pc(PC); |
| 175 | } |
| 176 | |
| 177 | //Set carry flag to 1 if 1st compare value is < 2nd compare value |
| 178 | SET_CY( (ACC < data) ); |
| 179 | } |
| 180 | |
| 181 | //CJNE A, data addr, code addr /* 1: 1011 0101 */ |
| 182 | INLINE void cjne_a_mem(void) |
| 183 | { |
| 184 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 185 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 186 | UINT8 data = IRAM_R(addr); //Pull value from data address |
| 187 | |
| 188 | if(ACC != data) //Jump if values are not equal |
| 189 | { |
| 190 | PC = PC + rel_addr; |
| 191 | change_pc(PC); |
| 192 | } |
| 193 | |
| 194 | //Set carry flag to 1 if 1st compare value is < 2nd compare value |
| 195 | SET_CY( (ACC < data) ); |
| 196 | } |
| 197 | |
| 198 | //CJNE @R0/@R1, #data, code addr /* 1: 1011 011i */ |
| 199 | INLINE void cjne_ir_byte(int r) |
| 200 | { |
| 201 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 202 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 203 | UINT8 srcdata = IRAM_IR(R_REG(r)); //Grab value pointed to by R0 or R1 |
| 204 | |
| 205 | if(srcdata != data) //Jump if values are not equal |
| 206 | { |
| 207 | PC = PC + rel_addr; |
| 208 | change_pc(PC); |
| 209 | } |
| 210 | |
| 211 | //Set carry flag to 1 if 1st compare value is < 2nd compare value |
| 212 | SET_CY( (srcdata < data) ); |
| 213 | } |
| 214 | |
| 215 | //CJNE R0 to R7, #data, code addr /* 1: 1011 1rrr */ |
| 216 | INLINE void cjne_r_byte(int r) |
| 217 | { |
| 218 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 219 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 220 | UINT8 srcdata = R_REG(r); //Grab value of R0 - R7 |
| 221 | |
| 222 | if(srcdata != data) //Jump if values are not equal |
| 223 | { |
| 224 | PC = PC + rel_addr; |
| 225 | change_pc(PC); |
| 226 | } |
| 227 | |
| 228 | //Set carry flag to 1 if 1st compare value is < 2nd compare value |
| 229 | SET_CY( (srcdata < data) ); |
| 230 | } |
| 231 | |
| 232 | //CLR bit addr /* 1: 1100 0010 */ |
| 233 | INLINE void clr_bitaddr(void) |
| 234 | { |
| 235 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 236 | BIT_W(addr,0); //Clear bit at specified bit address |
| 237 | } |
| 238 | |
| 239 | //CLR C /* 1: 1100 0011 */ |
| 240 | INLINE void clr_c(void) |
| 241 | { |
| 242 | SET_CY(0); //Clear Carry Flag |
| 243 | } |
| 244 | |
| 245 | //CLR A /* 1: 1110 0100 */ |
| 246 | INLINE void clr_a(void) |
| 247 | { |
| 248 | SET_ACC(0); //Clear Accumulator |
| 249 | } |
| 250 | |
| 251 | //CPL bit addr /* 1: 1011 0010 */ |
| 252 | INLINE void cpl_bitaddr(void) |
| 253 | { |
| 254 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 255 | UINT8 data = (~BIT_R(addr))&1; |
| 256 | BIT_W(addr,data); //Complement bit at specified bit address |
| 257 | } |
| 258 | |
| 259 | //CPL C /* 1: 1011 0011 */ |
| 260 | INLINE void cpl_c(void) |
| 261 | { |
| 262 | UINT8 bit = (~GET_CY)&1; //Complement Carry Flag |
| 263 | SET_CY(bit); |
| 264 | } |
| 265 | |
| 266 | //CPL A /* 1: 1111 0100 */ |
| 267 | INLINE void cpl_a(void) |
| 268 | { |
| 269 | UINT8 data = ((~ACC)&0xff); |
| 270 | SET_ACC(data); //Complement Accumulator |
| 271 | } |
| 272 | |
| 273 | //DA A /* 1: 1101 0100 */ |
| 274 | INLINE void da_a(void) |
| 275 | { |
| 276 | /*From several sources, since none said the same thing: |
| 277 | The decimal adjust instruction is associated with the use of the ADD and ADDC instructions. |
| 278 | The eight-bit value in the accumulator is adjusted to form two BCD digits of four bits each. |
| 279 | If the accumulator contents bits 0-3 are greater than 9, OR the AC flag is set, then six is added to |
| 280 | produce a proper BCD digit. |
| 281 | If the carry is set, OR the four high bits 4-7 exceed nine, six is added to the value of these bits. |
| 282 | The carry flag will be set if the result is > 0x99, but not cleared otherwise */ |
| 283 | |
| 284 | UINT16 new_acc = ACC & 0xff; |
| 285 | if(GET_AC || (new_acc & 0x0f) > 0x09) |
| 286 | new_acc += 0x06; |
| 287 | if(GET_CY || ((new_acc & 0xf0) > 0x90) || (new_acc & ~0xff)) |
| 288 | new_acc += 0x60; |
| 289 | SET_ACC(new_acc&0xff); |
| 290 | if(new_acc & ~0xff) |
| 291 | SET_CY(1); |
| 292 | } |
| 293 | |
| 294 | //DEC A /* 1: 0001 0100 */ |
| 295 | INLINE void dec_a(void) |
| 296 | { |
| 297 | SET_ACC(ACC-1); |
| 298 | } |
| 299 | |
| 300 | //DEC data addr /* 1: 0001 0101 */ |
| 301 | INLINE void dec_mem(void) |
| 302 | { |
| 303 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 304 | UINT8 data = IRAM_R(addr); |
| 305 | IRAM_W(addr,data-1); |
| 306 | } |
| 307 | |
| 308 | //DEC @R0/@R1 /* 1: 0001 011i */ |
| 309 | INLINE void dec_ir(int r) |
| 310 | { |
| 311 | UINT8 data = IRAM_IR(R_REG(r)); |
| 312 | IRAM_W(R_REG(r),data-1); |
| 313 | } |
| 314 | |
| 315 | //DEC R0 to R7 /* 1: 0001 1rrr */ |
| 316 | INLINE void dec_r(int r) |
| 317 | { |
| 318 | SET_REG(r, R_REG(r) - 1); |
| 319 | } |
| 320 | |
| 321 | //DIV AB /* 1: 1000 0100 */ |
| 322 | INLINE void div_ab(void) |
| 323 | { |
| 324 | if( B == 0 ) { |
| 325 | //Overflow flag is set! |
| 326 | SET_OV(1); |
| 327 | //Really the values are undefined according to the manual, but we'll just leave them as is.. |
| 328 | //SET_ACC(0xff); |
| 329 | //SFR_W(B,0xff); |
| 330 | } |
| 331 | else { |
| 332 | int a = (int)ACC / B; |
| 333 | int b = (int)ACC % B; |
| 334 | //A gets quotient byte, B gets remainder byte |
| 335 | SET_ACC(a); |
| 336 | B = b; |
| 337 | //Overflow flag is cleared |
| 338 | SET_OV(0); |
| 339 | } |
| 340 | //Carry Flag is always cleared |
| 341 | SET_CY(0); |
| 342 | } |
| 343 | |
| 344 | //DJNZ data addr, code addr /* 1: 1101 0101 */ |
| 345 | INLINE void djnz_mem(void) |
| 346 | { |
| 347 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 348 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 349 | IRAM_W(addr,IRAM_R(addr) - 1); //Decrement value contained at data address |
| 350 | if(IRAM_R(addr) != 0) //Branch if contents of data address is not 0 |
| 351 | { |
| 352 | PC = PC + rel_addr; |
| 353 | change_pc(PC); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | //DJNZ R0 to R7,code addr /* 1: 1101 1rrr */ |
| 358 | INLINE void djnz_r(int r) |
| 359 | { |
| 360 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 361 | SET_REG(r ,R_REG(r) - 1); //Decrement value |
| 362 | if(R_REG(r) != 0) //Branch if contents of R0 - R7 is not 0 |
| 363 | { |
| 364 | PC = PC + rel_addr; |
| 365 | change_pc(PC); |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | //INC A /* 1: 0000 0100 */ |
| 370 | INLINE void inc_a(void) |
| 371 | { |
| 372 | SET_ACC(ACC+1); |
| 373 | } |
| 374 | |
| 375 | //INC data addr /* 1: 0000 0101 */ |
| 376 | INLINE void inc_mem(void) |
| 377 | { |
| 378 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 379 | UINT8 data = IRAM_R(addr); |
| 380 | IRAM_W(addr,data+1); |
| 381 | } |
| 382 | |
| 383 | //INC @R0/@R1 /* 1: 0000 011i */ |
| 384 | INLINE void inc_ir(int r) |
| 385 | { |
| 386 | UINT8 data = IRAM_IR(R_REG(r)); |
| 387 | IRAM_W(R_REG(r),data+1); |
| 388 | } |
| 389 | |
| 390 | //INC R0 to R7 /* 1: 0000 1rrr */ |
| 391 | INLINE void inc_r(int r) |
| 392 | { |
| 393 | UINT8 data = R_REG(r); |
| 394 | SET_REG(r, data + 1); |
| 395 | } |
| 396 | |
| 397 | //INC DPTR /* 1: 1010 0011 */ |
| 398 | INLINE void inc_dptr(void) |
| 399 | { |
| 400 | UINT16 dptr = (DPTR)+1; |
| 401 | SET_DPTR(dptr); |
| 402 | } |
| 403 | |
| 404 | //JB bit addr, code addr /* 1: 0010 0000 */ |
| 405 | INLINE void jb(void) |
| 406 | { |
| 407 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 408 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 409 | if(BIT_R(addr)) //If bit set at specified bit address, jump |
| 410 | { |
| 411 | PC = PC + rel_addr; |
| 412 | change_pc(PC); |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | //JBC bit addr, code addr /* 1: 0001 0000 */ |
| 417 | INLINE void jbc(void) |
| 418 | { |
| 419 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 420 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 421 | if(BIT_R(addr)) { //If bit set at specified bit address, jump |
| 422 | PC = PC + rel_addr; |
| 423 | BIT_W(addr,0); //Clear Bit also |
| 424 | change_pc(PC); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | //JC code addr /* 1: 0100 0000 */ |
| 429 | INLINE void jc(void) |
| 430 | { |
| 431 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 432 | if(GET_CY) //Jump if Carry Flag Set |
| 433 | { |
| 434 | PC = PC + rel_addr; |
| 435 | change_pc(PC); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | //JMP @A+DPTR /* 1: 0111 0011 */ |
| 440 | INLINE void jmp_iadptr(void) |
| 441 | { |
| 442 | PC = ACC + DPTR; |
| 443 | change_pc(PC); |
| 444 | } |
| 445 | |
| 446 | //JNB bit addr, code addr /* 1: 0011 0000 */ |
| 447 | INLINE void jnb(void) |
| 448 | { |
| 449 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 450 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 451 | if(!BIT_R(addr)) //If bit NOT set at specified bit address, jump |
| 452 | { |
| 453 | PC = PC + rel_addr; |
| 454 | change_pc(PC); |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | //JNC code addr /* 1: 0101 0000 */ |
| 459 | INLINE void jnc(void) |
| 460 | { |
| 461 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 462 | if(!GET_CY) //Jump if Carry Flag not set |
| 463 | { |
| 464 | PC = PC + rel_addr; |
| 465 | change_pc(PC); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | //JNZ code addr /* 1: 0111 0000 */ |
| 470 | INLINE void jnz(void) |
| 471 | { |
| 472 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 473 | if(ACC != 0) //Branch if ACC is not 0 |
| 474 | { |
| 475 | PC = PC+rel_addr; |
| 476 | change_pc(PC); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | //JZ code addr /* 1: 0110 0000 */ |
| 481 | INLINE void jz(void) |
| 482 | { |
| 483 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 484 | if(ACC == 0) //Branch if ACC is 0 |
| 485 | { |
| 486 | PC = PC+rel_addr; |
| 487 | change_pc(PC); |
| 488 | } |
| 489 | } |
| 490 | |
| 491 | //LCALL code addr /* 1: 0001 0010 */ |
| 492 | INLINE void lcall(void) |
| 493 | { |
| 494 | UINT8 addr_hi, addr_lo; |
| 495 | addr_hi = ROP_ARG(PC++); |
| 496 | addr_lo = ROP_ARG(PC++); |
| 497 | PUSH_PC(); |
| 498 | PC = (UINT16)((addr_hi<<8) | addr_lo); |
| 499 | change_pc(PC); |
| 500 | } |
| 501 | |
| 502 | //LJMP code addr /* 1: 0000 0010 */ |
| 503 | INLINE void ljmp(void) |
| 504 | { |
| 505 | UINT8 addr_hi, addr_lo; |
| 506 | addr_hi = ROP_ARG(PC++); |
| 507 | addr_lo = ROP_ARG(PC++); |
| 508 | PC = (UINT16)((addr_hi<<8) | addr_lo); |
| 509 | change_pc(PC); |
| 510 | } |
| 511 | |
| 512 | //MOV A, #data /* 1: 0111 0100 */ |
| 513 | INLINE void mov_a_byte(void) |
| 514 | { |
| 515 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 516 | SET_ACC(data); //Store data to ACC |
| 517 | } |
| 518 | |
| 519 | //MOV A, data addr /* 1: 1110 0101 */ |
| 520 | INLINE void mov_a_mem(void) |
| 521 | { |
| 522 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 523 | SET_ACC(IRAM_R(addr)); //Store contents of data address to ACC |
| 524 | } |
| 525 | |
| 526 | //MOV A,@RO/@R1 /* 1: 1110 011i */ |
| 527 | INLINE void mov_a_ir(int r) |
| 528 | { |
| 529 | SET_ACC(IRAM_IR(R_REG(r))); //Store contents of address pointed by R0 or R1 to ACC |
| 530 | } |
| 531 | |
| 532 | //MOV A,R0 to R7 /* 1: 1110 1rrr */ |
| 533 | INLINE void mov_a_r(int r) |
| 534 | { |
| 535 | SET_ACC(R_REG(r)); //Store contents of R0 - R7 to ACC |
| 536 | } |
| 537 | |
| 538 | //MOV data addr, #data /* 1: 0111 0101 */ |
| 539 | INLINE void mov_mem_byte(void) |
| 540 | { |
| 541 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 542 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 543 | IRAM_W(addr,data); //Store data to data address location |
| 544 | } |
| 545 | |
| 546 | //MOV data addr, data addr /* 1: 1000 0101 */ |
| 547 | INLINE void mov_mem_mem(void) |
| 548 | { |
| 549 | //1st address is src, 2nd is dst, but the mov command works as mov dst,src) |
| 550 | UINT8 src,dst; |
| 551 | src = ROP_ARG(PC++); //Grab source data address |
| 552 | dst = ROP_ARG(PC++); //Grab destination data address |
| 553 | IRAM_W(dst,IRAM_R(src)); //Read source address contents and store to destination address |
| 554 | } |
| 555 | |
| 556 | //MOV @R0/@R1, #data /* 1: 0111 011i */ |
| 557 | INLINE void mov_ir_byte(int r) |
| 558 | { |
| 559 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 560 | IRAM_IW(R_REG(r),data); //Store data to address pointed by R0 or R1 |
| 561 | } |
| 562 | |
| 563 | //MOV R0 to R7, #data /* 1: 0111 1rrr */ |
| 564 | INLINE void mov_r_byte(int r) |
| 565 | { |
| 566 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 567 | SET_REG(r, data); //Store to R0 - R7 |
| 568 | } |
| 569 | |
| 570 | //MOV data addr, @R0/@R1 /* 1: 1000 011i */ |
| 571 | INLINE void mov_mem_ir(int r) |
| 572 | { |
| 573 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 574 | IRAM_W(addr,IRAM_IR(R_REG(r))); //Store contents pointed to by R0 or R1 to data address |
| 575 | } |
| 576 | |
| 577 | //MOV data addr,R0 to R7 /* 1: 1000 1rrr */ |
| 578 | INLINE void mov_mem_r(int r) |
| 579 | { |
| 580 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 581 | IRAM_W(addr,R_REG(r)); //Store contents of R0 - R7 to data address |
| 582 | } |
| 583 | |
| 584 | //MOV DPTR, #data16 /* 1: 1001 0000 */ |
| 585 | INLINE void mov_dptr_byte(void) |
| 586 | { |
| 587 | UINT8 data_hi, data_lo; |
| 588 | data_hi = ROP_ARG(PC++); //Grab hi byte |
| 589 | data_lo = ROP_ARG(PC++); //Grab lo byte |
| 590 | SET_DPTR((UINT16)((data_hi<<8)|data_lo)); //Store to DPTR |
| 591 | } |
| 592 | |
| 593 | //MOV bit addr, C /* 1: 1001 0010 */ |
| 594 | INLINE void mov_bitaddr_c(void) |
| 595 | { |
| 596 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 597 | BIT_W(addr,GET_CY); //Store Carry Flag to Bit Address |
| 598 | } |
| 599 | |
| 600 | //MOV @R0/@R1, data addr /* 1: 1010 011i */ |
| 601 | INLINE void mov_ir_mem(int r) |
| 602 | { |
| 603 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 604 | IRAM_IW(R_REG(r),IRAM_R(addr)); //Store data from data address to address pointed to by R0 or R1 |
| 605 | } |
| 606 | |
| 607 | //MOV R0 to R7, data addr /* 1: 1010 1rrr */ |
| 608 | INLINE void mov_r_mem(int r) |
| 609 | { |
| 610 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 611 | SET_REG(r, IRAM_R(addr)); //Store to R0 - R7 |
| 612 | } |
| 613 | |
| 614 | //MOV data addr, A /* 1: 1111 0101 */ |
| 615 | INLINE void mov_mem_a(void) |
| 616 | { |
| 617 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 618 | IRAM_W(addr,ACC); //Store A to data address |
| 619 | } |
| 620 | |
| 621 | //MOV @R0/@R1, A /* 1: 1111 011i */ |
| 622 | INLINE void mov_ir_a(int r) |
| 623 | { |
| 624 | IRAM_IW(R_REG(r),ACC); //Store A to location pointed to by R0 or R1 |
| 625 | } |
| 626 | |
| 627 | //MOV R0 to R7, A /* 1: 1111 1rrr */ |
| 628 | INLINE void mov_r_a(int r) |
| 629 | { |
| 630 | SET_REG(r, ACC); //Store A to R0-R7 |
| 631 | } |
| 632 | |
| 633 | //MOVC A, @A + PC /* 1: 1000 0011 */ |
| 634 | INLINE void movc_a_iapc(void) |
| 635 | { |
| 636 | UINT8 data; |
| 637 | data = CODEMEM_R(ACC+PC); //Move a byte from CODE(Program) Memory and store to ACC |
| 638 | SET_ACC(data); |
| 639 | } |
| 640 | |
| 641 | //MOV C, bit addr /* 1: 1010 0010 */ |
| 642 | INLINE void mov_c_bitaddr(void) |
| 643 | { |
| 644 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 645 | SET_CY( (BIT_R(addr)) ); //Store Bit from Bit Address to Carry Flag |
| 646 | } |
| 647 | |
| 648 | //MOVC A, @A + DPTR /* 1: 1001 0011 */ |
| 649 | INLINE void movc_a_iadptr(void) |
| 650 | { |
| 651 | UINT8 data; |
| 652 | data = CODEMEM_R(ACC + DPTR); //Move a byte from CODE(Program) Memory and store to ACC |
| 653 | SET_ACC(data); |
| 654 | } |
| 655 | |
| 656 | //MOVX A,@DPTR /* 1: 1110 0000 */ |
| 657 | //(Move External Ram 16 bit address to A) |
| 658 | INLINE void movx_a_idptr(void) |
| 659 | { |
| 660 | // UINT8 byte = DATAMEM_R(R_DPTR); //Grab 1 byte from External DATA memory pointed to by dptr |
| 661 | UINT32 addr = ERAM_ADDR(DPTR, 0xFFFF); |
| 662 | UINT8 byte = DATAMEM_R(addr); //Grab 1 byte from External DATA memory pointed to by dptr |
| 663 | SET_ACC(byte); //Store to ACC |
| 664 | } |
| 665 | |
| 666 | //MOVX A, @R0/@R1 /* 1: 1110 001i */ |
| 667 | //(Move External Ram 8 bit address to A) |
| 668 | INLINE void movx_a_ir(int r) |
| 669 | { |
| 670 | UINT32 addr = ERAM_ADDR(R_REG(r),0xFF); //Grab address by reading location pointed to by R0 or R1 |
| 671 | UINT8 byte = DATAMEM_R(addr); //Grab 1 byte from External DATA memory pointed to by address |
| 672 | SET_ACC(byte); //Store to ACC |
| 673 | } |
| 674 | |
| 675 | //MOVX @DPTR,A /* 1: 1111 0000 */ |
| 676 | //(Move A to External Ram 16 bit address) |
| 677 | INLINE void movx_idptr_a(void) |
| 678 | { |
| 679 | // DATAMEM_W(R_DPTR, ACC); //Store ACC to External DATA memory address pointed to by DPTR |
| 680 | UINT32 addr = ERAM_ADDR(DPTR, 0xFFFF); |
| 681 | DATAMEM_W(addr, ACC); //Store ACC to External DATA memory address pointed to by DPTR |
| 682 | } |
| 683 | |
| 684 | //MOVX @R0/@R1,A /* 1: 1111 001i */ |
| 685 | //(Move A to External Ram 8 bit address) |
| 686 | INLINE void movx_ir_a(int r) |
| 687 | { |
| 688 | UINT32 addr = ERAM_ADDR(R_REG(r),0xFF); //Grab address by reading location pointed to by R0 or R1 |
| 689 | DATAMEM_W(addr, ACC); //Store ACC to External DATA memory address |
| 690 | } |
| 691 | |
| 692 | //MUL AB /* 1: 1010 0100 */ |
| 693 | INLINE void mul_ab(void) |
| 694 | { |
| 695 | UINT16 result = ACC * B; |
| 696 | //A gets lo bits, B gets hi bits of result |
| 697 | B = (UINT8) ((result & 0xFF00) >> 8); |
| 698 | SET_ACC((UINT8)(result & 0x00FF)); |
| 699 | //Set flags |
| 700 | SET_OV( ((result & 0x100) >> 8) ); //Set/Clear Overflow Flag if result > 255 |
| 701 | SET_CY(0); //Carry Flag always cleared |
| 702 | } |
| 703 | |
| 704 | //NOP /* 1: 0000 0000 */ |
| 705 | INLINE void nop(void) |
| 706 | { |
| 707 | } |
| 708 | |
| 709 | //ORL data addr, A /* 1: 0100 0010 */ |
| 710 | INLINE void orl_mem_a(void) |
| 711 | { |
| 712 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 713 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 714 | IRAM_W(addr,data | ACC); //Set data address value to it's value Logical OR with ACC |
| 715 | } |
| 716 | |
| 717 | //ORL data addr, #data /* 1: 0100 0011 */ |
| 718 | INLINE void orl_mem_byte(void) |
| 719 | { |
| 720 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 721 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 722 | UINT8 srcdata = IRAM_R(addr); //Grab data from data address |
| 723 | IRAM_W(addr,srcdata | data); //Set data address value to it's value Logical OR with Data |
| 724 | } |
| 725 | |
| 726 | //ORL A, #data /* 1: 0100 0100 */ |
| 727 | INLINE void orl_a_byte(void) |
| 728 | { |
| 729 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 730 | SET_ACC(ACC | data); //Set ACC to value of ACC Logical OR with Data |
| 731 | } |
| 732 | |
| 733 | //ORL A, data addr /* 1: 0100 0101 */ |
| 734 | INLINE void orl_a_mem(void) |
| 735 | { |
| 736 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 737 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 738 | SET_ACC(ACC | data); //Set ACC to value of ACC Logical OR with Data |
| 739 | } |
| 740 | |
| 741 | //ORL A, @RO/@R1 /* 1: 0100 011i */ |
| 742 | INLINE void orl_a_ir(int r) |
| 743 | { |
| 744 | UINT8 data = IRAM_IR(R_REG(r)); //Grab data from address R0 or R1 points to |
| 745 | SET_ACC(ACC | data); //Set ACC to value of ACC Logical OR with Data |
| 746 | } |
| 747 | |
| 748 | //ORL A, RO to R7 /* 1: 0100 1rrr */ |
| 749 | INLINE void orl_a_r(int r) |
| 750 | { |
| 751 | UINT8 data = R_REG(r); //Grab data from R0 - R7 |
| 752 | SET_ACC(ACC | data); //Set ACC to value of ACC Logical OR with Data |
| 753 | } |
| 754 | |
| 755 | //ORL C, bit addr /* 1: 0111 0010 */ |
| 756 | INLINE void orl_c_bitaddr(void) |
| 757 | { |
| 758 | int cy = GET_CY; |
| 759 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 760 | UINT8 bit = BIT_R(addr); //Grab bit data from bit address |
| 761 | SET_CY( (cy | bit) ); //Set Carry flag to Carry Flag Value Logical OR with Bit |
| 762 | } |
| 763 | |
| 764 | //ORL C, /bit addr /* 1: 1010 0000 */ |
| 765 | INLINE void orl_c_nbitaddr(void) |
| 766 | { |
| 767 | int cy = GET_CY; |
| 768 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 769 | UINT8 bit = BIT_R(addr); //Grab bit data from bit address |
| 770 | bit = ((~bit)&1); //Complement bit |
| 771 | SET_CY( (cy | bit) ); //Set Carry flag to Carry Flag Value Logical OR with Complemented Bit |
| 772 | } |
| 773 | |
| 774 | //POP data addr /* 1: 1101 0000 */ |
| 775 | INLINE void pop(void) |
| 776 | { |
| 777 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 778 | IRAM_W(addr, IRAM_IR(SP)); //Store to contents of data addr, data pointed to by Stack - IRAM_IR needed to access upper 128 bytes of stack |
| 779 | //IRAM_IW(addr, IRAM_IR(R_SP)); //Store to contents of data addr, data pointed to by Stack - doesn't work, sfr's are not restored this way and it's not an indirect access anyway |
| 780 | SP = SP-1; //Decrement SP |
| 781 | } |
| 782 | |
| 783 | //PUSH data addr /* 1: 1100 0000 */ |
| 784 | INLINE void push(void) |
| 785 | { |
| 786 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 787 | UINT8 tmpSP = SP+1; //Grab and Increment Stack Pointer |
| 788 | SP = tmpSP; // "" |
| 789 | IRAM_IW(tmpSP, IRAM_R(addr)); //Store to stack contents of data address - IRAM_IW needed to store to upper 128 bytes of stack, however, can't use IRAM_IR because that won't store the sfrs and it's not an indirect access anyway |
| 790 | } |
| 791 | |
| 792 | //RET /* 1: 0010 0010 */ |
| 793 | INLINE void ret(void) |
| 794 | { |
| 795 | POP_PC(); |
| 796 | } |
| 797 | |
| 798 | //RETI /* 1: 0011 0010 */ |
| 799 | INLINE void reti(void) |
| 800 | { |
| 801 | POP_PC(); |
| 802 | CLEAR_CURRENT_IRQ(); |
| 803 | } |
| 804 | |
| 805 | //RL A /* 1: 0010 0011 */ |
| 806 | INLINE void rl_a(void) |
| 807 | { |
| 808 | //Left Shift A, Bit 7 carries to Bit 0 |
| 809 | int carry = ((ACC & 0x80) >> 7); |
| 810 | int data = (ACC<<1) & 0xfe; |
| 811 | SET_ACC( data | carry); |
| 812 | } |
| 813 | |
| 814 | //RLC A /* 1: 0011 0011 */ |
| 815 | INLINE void rlc_a(void) |
| 816 | { |
| 817 | //Left Shift A, Bit 7 goes to Carry Flag, Original Carry Flag goes to Bit 0 of ACC |
| 818 | int carry = ((ACC & 0x80) >> 7); |
| 819 | int data = ((ACC<<1) & 0xfe) | GET_CY; |
| 820 | SET_ACC( data); |
| 821 | SET_CY(carry); |
| 822 | } |
| 823 | |
| 824 | //RR A /* 1: 0000 0011 */ |
| 825 | INLINE void rr_a(void) |
| 826 | { |
| 827 | //Right Shift A, Bit 0 carries to Bit 7 |
| 828 | int carry = ((ACC & 1) << 7); |
| 829 | int data = (ACC>>1) & 0x7f; |
| 830 | SET_ACC( data | carry); |
| 831 | } |
| 832 | |
| 833 | //RRC A /* 1: 0001 0011 */ |
| 834 | INLINE void rrc_a(void) |
| 835 | { |
| 836 | //Right Shift A, Bit 0 goes to Carry Flag, Bit 7 of ACC gets set to original Carry Flag |
| 837 | int carry = (ACC & 1); |
| 838 | int data = ((ACC>>1) & 0x7f) | (GET_CY<<7); |
| 839 | SET_ACC( data); |
| 840 | SET_CY(carry); |
| 841 | } |
| 842 | |
| 843 | //SETB C /* 1: 1101 0011 */ |
| 844 | INLINE void setb_c(void) |
| 845 | { |
| 846 | SET_CY(1); //Set Carry Flag |
| 847 | } |
| 848 | |
| 849 | //SETB bit addr /* 1: 1101 0010 */ |
| 850 | INLINE void setb_bitaddr(void) |
| 851 | { |
| 852 | UINT8 addr = ROP_ARG(PC++); //Grab bit address |
| 853 | BIT_W(addr,1); //Set Bit at Bit Address |
| 854 | } |
| 855 | |
| 856 | //SJMP code addr /* 1: 1000 0000 */ |
| 857 | INLINE void sjmp(void) |
| 858 | { |
| 859 | INT8 rel_addr = ROP_ARG(PC++); //Grab relative code address |
| 860 | PC = PC + rel_addr; //Update PC |
| 861 | change_pc(PC); |
| 862 | } |
| 863 | |
| 864 | //SUBB A, #data /* 1: 1001 0100 */ |
| 865 | INLINE void subb_a_byte(void) |
| 866 | { |
| 867 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 868 | UINT8 result = ACC - data - GET_CY; //Subtract data & carry flag from accumulator |
| 869 | DO_SUB_FLAGS(ACC,data,GET_CY); //Set Flags |
| 870 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 871 | |
| 872 | } |
| 873 | |
| 874 | //SUBB A, data addr /* 1: 1001 0101 */ |
| 875 | INLINE void subb_a_mem(void) |
| 876 | { |
| 877 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 878 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 879 | UINT8 result = ACC - data - GET_CY; //Subtract data & carry flag from accumulator |
| 880 | DO_SUB_FLAGS(ACC,data,GET_CY); //Set Flags |
| 881 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 882 | } |
| 883 | |
| 884 | //SUBB A, @R0/@R1 /* 1: 1001 011i */ |
| 885 | INLINE void subb_a_ir(int r) |
| 886 | { |
| 887 | UINT8 data = IRAM_IR(R_REG(r)); //Grab data from memory pointed to by R0 or R1 |
| 888 | UINT8 result = ACC - data - GET_CY; //Subtract data & carry flag from accumulator |
| 889 | DO_SUB_FLAGS(ACC,data,GET_CY); //Set Flags |
| 890 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 891 | } |
| 892 | |
| 893 | //SUBB A, R0 to R7 /* 1: 1001 1rrr */ |
| 894 | INLINE void subb_a_r(int r) |
| 895 | { |
| 896 | UINT8 data = R_REG(r); //Grab data from R0 - R7 |
| 897 | UINT8 result = ACC - data - GET_CY; //Subtract data & carry flag from accumulator |
| 898 | DO_SUB_FLAGS(ACC,data,GET_CY); //Set Flags |
| 899 | SET_ACC(result); //Store 8 bit result of addtion in ACC |
| 900 | } |
| 901 | |
| 902 | //SWAP A /* 1: 1100 0100 */ |
| 903 | INLINE void swap_a(void) |
| 904 | { |
| 905 | UINT8 a_nib_lo, a_nib_hi; |
| 906 | a_nib_hi = (ACC & 0x0f) << 4; //Grab lo byte of ACC and move to hi |
| 907 | a_nib_lo = (ACC & 0xf0) >> 4; //Grab hi byte of ACC and move to lo |
| 908 | SET_ACC( a_nib_hi | a_nib_lo); |
| 909 | } |
| 910 | |
| 911 | //XCH A, data addr /* 1: 1100 0101 */ |
| 912 | INLINE void xch_a_mem(void) |
| 913 | { |
| 914 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 915 | UINT8 data = IRAM_R(addr); //Grab data |
| 916 | UINT8 oldACC = ACC; //Hold value of ACC |
| 917 | SET_ACC(data); //Sets ACC to data |
| 918 | IRAM_W(addr,oldACC); //Sets data address to old value of ACC |
| 919 | } |
| 920 | |
| 921 | //XCH A, @RO/@R1 /* 1: 1100 011i */ |
| 922 | INLINE void xch_a_ir(int r) |
| 923 | { |
| 924 | UINT8 data = IRAM_IR(R_REG(r)); //Grab data pointed to by R0 or R1 |
| 925 | UINT8 oldACC = ACC; //Hold value of ACC |
| 926 | SET_ACC(data); //Sets ACC to data |
| 927 | IRAM_W(R_REG(r),oldACC); //Sets data address to old value of ACC |
| 928 | } |
| 929 | |
| 930 | //XCH A, RO to R7 /* 1: 1100 1rrr */ |
| 931 | INLINE void xch_a_r(int r) |
| 932 | { |
| 933 | UINT8 data = R_REG(r); //Grab data from R0-R7 |
| 934 | UINT8 oldACC = ACC; //Hold value of ACC |
| 935 | SET_ACC(data); //Sets ACC to data |
| 936 | SET_REG(r, oldACC); //Sets data address to old value of ACC |
| 937 | } |
| 938 | |
| 939 | //XCHD A, @R0/@R1 /* 1: 1101 011i */ |
| 940 | INLINE void xchd_a_ir(int r) |
| 941 | { |
| 942 | UINT8 acc, ir_data; |
| 943 | ir_data = IRAM_IR(R_REG(r)); //Grab data pointed to by R0 or R1 |
| 944 | acc = ACC; //Grab ACC value |
| 945 | SET_ACC( (acc & 0xf0) | (ir_data & 0x0f) ); //Set ACC to lower nibble of data pointed to by R0 or R1 |
| 946 | IRAM_W(R_REG(r), (ir_data & 0xf0) | (acc & 0x0f) ); //Set data pointed to by R0 or R1 to lower nibble of ACC |
| 947 | } |
| 948 | |
| 949 | //XRL data addr, A /* 1: 0110 0010 */ |
| 950 | INLINE void xrl_mem_a(void) |
| 951 | { |
| 952 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 953 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 954 | IRAM_W(addr,data ^ ACC); //Set data address value to it's value Logical XOR with ACC |
| 955 | } |
| 956 | |
| 957 | //XRL data addr, #data /* 1: 0110 0011 */ |
| 958 | INLINE void xrl_mem_byte(void) |
| 959 | { |
| 960 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 961 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 962 | UINT8 srcdata = IRAM_R(addr); //Grab data from data address |
| 963 | IRAM_W(addr,srcdata ^ data); //Set data address value to it's value Logical XOR with Data |
| 964 | } |
| 965 | |
| 966 | //XRL A, #data /* 1: 0110 0100 */ |
| 967 | INLINE void xrl_a_byte(void) |
| 968 | { |
| 969 | UINT8 data = ROP_ARG(PC++); //Grab data |
| 970 | SET_ACC(ACC ^ data); //Set ACC to value of ACC Logical XOR with Data |
| 971 | } |
| 972 | |
| 973 | //XRL A, data addr /* 1: 0110 0101 */ |
| 974 | INLINE void xrl_a_mem(void) |
| 975 | { |
| 976 | UINT8 addr = ROP_ARG(PC++); //Grab data address |
| 977 | UINT8 data = IRAM_R(addr); //Grab data from data address |
| 978 | SET_ACC(ACC ^ data); //Set ACC to value of ACC Logical XOR with Data |
| 979 | } |
| 980 | |
| 981 | //XRL A, @R0/@R1 /* 1: 0110 011i */ |
| 982 | INLINE void xrl_a_ir(int r) |
| 983 | { |
| 984 | UINT8 data = IRAM_IR(R_REG(r)); //Grab data from address R0 or R1 points to |
| 985 | SET_ACC(ACC ^ data); //Set ACC to value of ACC Logical XOR with Data |
| 986 | } |
| 987 | |
| 988 | //XRL A, R0 to R7 /* 1: 0110 1rrr */ |
| 989 | INLINE void xrl_a_r(int r) |
| 990 | { |
| 991 | UINT8 data = R_REG(r); //Grab data from R0 - R7 |
| 992 | SET_ACC(ACC ^ data); //Set ACC to value of ACC Logical XOR with Data |
| 993 | } |
| 994 | |
| 995 | //illegal opcodes |
| 996 | INLINE void illegal(UINT8 op) |
| 997 | { |
| 998 | LOG(("i8051 #%d: illegal opcode at 0x%03x: %02x\n", cpu_getactivecpu(), PC-1, op)); |
| 999 | } |
src/emu/cpu/mcs51/mcs51dasm.c
| r0 | r3515 | |
| 1 | /***************************************************************************** |
| 2 | * |
| 3 | * i8051dasm.c |
| 4 | * Portable MCS-51 Family Emulator |
| 5 | * |
| 6 | * Chips in the family: |
| 7 | * 8051 Product Line (8031,8051,8751) |
| 8 | * 8052 Product Line (8032,8052,8752) |
| 9 | * 8054 Product Line (8054) |
| 10 | * 8058 Product Line (8058) |
| 11 | * |
| 12 | * Copyright Steve Ellenoff, all rights reserved. |
| 13 | * |
| 14 | * - This source code is released as freeware for non-commercial purposes. |
| 15 | * - You are free to use and redistribute this code in modified or |
| 16 | * unmodified form, provided you list me in the credits. |
| 17 | * - If you modify this source code, you must add a notice to each modified |
| 18 | * source file that it has been changed. If you're a nice person, you |
| 19 | * will clearly mark each change too. :) |
| 20 | * - If you wish to use this for commercial purposes, please contact me at |
| 21 | * sellenoff@hotmail.com |
| 22 | * - The author of this copywritten work reserves the right to change the |
| 23 | * terms of its usage and license at any time, including retroactively |
| 24 | * - This entire notice must remain in the source code. |
| 25 | * |
| 26 | * This work is based on: |
| 27 | * #1) 'Intel(tm) MC51 Microcontroller Family Users Manual' and |
| 28 | * #2) 8051 simulator by Travis Marlatte |
| 29 | * #3) Portable UPI-41/8041/8741/8042/8742 emulator V0.1 by Juergen Buchmueller (MAME CORE) |
| 30 | * |
| 31 | ***************************************************************************** |
| 32 | * Symbol Memory Name Tables borrowed from: |
| 33 | * D52 8052 Disassembler - Copyright Jeffery L. Post |
| 34 | *****************************************************************************/ |
| 35 | |
| 36 | #include "debugger.h" |
| 37 | #include "mcs51.h" |
| 38 | |
| 39 | #define SHOW_MEMORY_NAMES 1 |
| 40 | |
| 41 | #ifdef SHOW_MEMORY_NAMES |
| 42 | |
| 43 | /*Display the memory address names for data & bit address access*/ |
| 44 | |
| 45 | //SFR Names |
| 46 | static const char sfr[128][7] = { |
| 47 | "p0", "sp", "dpl", "dph", /* 80 - 83 */ |
| 48 | "adat", "85h", "86h", "pcon", /* 84 - 87 */ |
| 49 | "tcon", "tmod", "tl0", "tl1", /* 88 - 8b */ |
| 50 | "th0", "th1", "pwcm", "pwmp", /* 8a - 8f */ |
| 51 | "p1", "91h", "92h", "93h", /* 90 - 93 */ |
| 52 | "94h", "95h", "96h", "97h", /* 94 - 97 */ |
| 53 | "scon", "sbuf", "9ah", "9bh", /* 98 - 9b */ |
| 54 | "9ch", "9dh", "9eh", "9fh", /* 9c - 9f */ |
| 55 | "p2", "0a1h", "0a2h", "0a3h", /* a0 - a3 */ |
| 56 | "0a4h", "0a5h", "0a6h", "0a7h", /* a4 - a7 */ |
| 57 | "ie", "cml0", "cml1", "cml2", /* a8 - ab */ |
| 58 | "ctl0", "ctl1", "ctl2", "ctl3", /* ac - af */ |
| 59 | "p3", "0b1h", "0b2h", "0b3h", /* b0 - b3 */ |
| 60 | "0b4h", "0b5h", "0b6h", "0b7h", /* b4 - b7 */ |
| 61 | "ip", "0b9h", "0bah", "0bbh", /* b8 - bb */ |
| 62 | "0bch", "0bdh", "0beh", "0bfh", /* bc - bf */ |
| 63 | "p4", "0c1h", "0c2h", "0c3h", /* c0 - c3 */ |
| 64 | "p5", "adcon", "adch", "0c7h", /* c4 - c7 */ |
| 65 | "t2con", "cmh0", "rcap2l", "rcap2h", /* c8 - cb */ |
| 66 | "tl2", "th2", "cth2", "cth3", /* cc - cf */ |
| 67 | "psw", "0d1h", "0d2h", "0d3h", /* d0 - d3 */ |
| 68 | "0d4h", "0d5h", "0d6h", "0d7h", /* d4 - d7 */ |
| 69 | "i2cfg", "s1sta", "s1dat", "s1adr", /* d8 - db */ |
| 70 | "0dch", "0ddh", "0deh", "0dfh", /* dc - df */ |
| 71 | "acc", "0e1h", "0e2h", "0e3h", /* e0 - e3 */ |
| 72 | "0e4h", "0e5h", "0e6h", "0e7h", /* e4 - e7 */ |
| 73 | "csr", "0e9h", "tm2con", "ctcon", /* e8 - eb */ |
| 74 | "tml2", "tmh2", "ste", "rte", /* ec - ef */ |
| 75 | "b", "0f1h", "0f2h", "0f3h", /* f0 - f3 */ |
| 76 | "0f4h", "0f5h", "0f6h", "0f7h", /* f4 - f7 */ |
| 77 | "i2sta", "0f9h", "0fah", "0fbh", /* f8 - fb */ |
| 78 | "pwm0", "pwm1", "pwena", "t3" /* fc - ff */ |
| 79 | }; |
| 80 | |
| 81 | //SFR Addressable bits |
| 82 | static const char sfrbits[128][8] = { |
| 83 | "p0.0", "p0.1", "p0.2", "p0.3", /* 80 - 83 */ |
| 84 | "p0.4", "p0.5", "p0.6", "p0.7", /* 84 - 87 */ |
| 85 | "it0", "ie0", "it1", "ie1", /* 88 - 8b */ |
| 86 | "tr0", "tf0", "tr1", "tf1", /* 8c - 8f */ |
| 87 | "p1.0", "p1.1", "p1.2", "p1.3", /* 90 - 93 */ |
| 88 | "p1.4", "p1.5", "p1.6", "p1.7", /* 94 - 97 */ |
| 89 | "ri", "ti", "rb8", "tb8", /* 98 - 9b */ |
| 90 | "ren", "sm2", "sm1", "sm0", /* 9c - 9f */ |
| 91 | "p2.0", "p2.1", "p2.2", "p2.3", /* a0 - a3 */ |
| 92 | "p2.4", "p2.5", "p2.6", "p2.7", /* a4 - a7 */ |
| 93 | "ex0", "et0", "ex1", "et1", /* a8 - ab */ |
| 94 | "es", "ie.5", "ie.6", "ea", /* ac - af */ |
| 95 | "rxd", "txd", "int0", "int1", /* b0 - b3 */ |
| 96 | "t0", "t1", "wr", "rd", /* b4 - b7 */ |
| 97 | "px0", "pt0", "px1", "pt1", /* b8 - bb */ |
| 98 | "ps", "ip.5", "ip.6", "ip.7", /* bc - bf */ |
| 99 | "0c0h.0", "0c0h.1", "0c0h.2", "0c0h.3", /* c0 - c3 */ |
| 100 | "0c0h.4", "0c0h.5", "0c0h.6", "0c0h.7", /* c4 - c7 */ |
| 101 | "cprl2", "ct2", "tr2", "exen2", /* c8 - cb */ |
| 102 | "tclk", "rclk", "exf2", "tf2", /* cc - cf */ |
| 103 | "p", "psw.1", "ov", "rs0", /* d0 - d3 */ |
| 104 | "rs1", "f0", "ac", "cy", /* d4 - d7 */ |
| 105 | "ct0", "ct1", "i2cfg.2","i2cfg.3",/* d8 - db */ |
| 106 | "tirun", "clrti", "mastrq", "slaven", /* dc - df */ |
| 107 | "acc.0", "acc.1", "acc.2", "acc.3", /* e0 - e3 */ |
| 108 | "acc.4", "acc.5", "acc.6", "acc.7", /* e4 - e7 */ |
| 109 | "ibf", "obf", "idsm", "obfc", /* e8 - eb */ |
| 110 | "ma0", "ma1", "mb0", "mb1", /* ec - ef */ |
| 111 | "b.0", "b.1", "b.2", "b.3", /* f0 - f3 */ |
| 112 | "b.4", "b.5", "b.6", "b.7", /* f4 - f7 */ |
| 113 | "xstp", "xstr", "makstp", "makstr", /* f8 - fb */ |
| 114 | "xactv", "xdata", "idle", "i2sta.7" /* fc - ff */ |
| 115 | } ; |
| 116 | |
| 117 | //Names for bit addressable memory |
| 118 | static const char membits[128][6] = { |
| 119 | "20h.0", "20h.1", "20h.2", "20h.3", |
| 120 | "20h.4", "20h.5", "20h.6", "20h.7", |
| 121 | "21h.0", "21h.1", "21h.2", "21h.3", |
| 122 | "21h.4", "21h.5", "21h.6", "21h.7", |
| 123 | "22h.0", "22h.1", "22h.2", "22h.3", |
| 124 | "22h.4", "22h.5", "22h.6", "22h.7", |
| 125 | "23h.0", "23h.1", "23h.2", "23h.3", |
| 126 | "23h.4", "23h.5", "23h.6", "23h.7", |
| 127 | "24h.0", "24h.1", "24h.2", "24h.3", |
| 128 | "24h.4", "24h.5", "24h.6", "24h.7", |
| 129 | "25h.0", "25h.1", "25h.2", "25h.3", |
| 130 | "25h.4", "25h.5", "25h.6", "25h.7", |
| 131 | "26h.0", "26h.1", "26h.2", "26h.3", |
| 132 | "26h.4", "26h.5", "26h.6", "26h.7", |
| 133 | "27h.0", "27h.1", "27h.2", "27h.3", |
| 134 | "27h.4", "27h.5", "27h.6", "27h.7", |
| 135 | "28h.0", "28h.1", "28h.2", "28h.3", |
| 136 | "28h.4", "28h.5", "28h.6", "28h.7", |
| 137 | "29h.0", "29h.1", "29h.2", "29h.3", |
| 138 | "29h.4", "29h.5", "29h.6", "29h.7", |
| 139 | "2ah.0", "2ah.1", "2ah.2", "2ah.3", |
| 140 | "2ah.4", "2ah.5", "2ah.6", "2ah.7", |
| 141 | "2bh.0", "2bh.1", "2bh.2", "2bh.3", |
| 142 | "2bh.4", "2bh.5", "2bh.6", "2bh.7", |
| 143 | "2ch.0", "2ch.1", "2ch.2", "2ch.3", |
| 144 | "2ch.4", "2ch.5", "2ch.6", "2ch.7", |
| 145 | "2dh.0", "2dh.1", "2dh.2", "2dh.3", |
| 146 | "2dh.4", "2dh.5", "2dh.6", "2dh.7", |
| 147 | "2eh.0", "2eh.1", "2eh.2", "2eh.3", |
| 148 | "2eh.4", "2eh.5", "2eh.6", "2eh.7", |
| 149 | "2fh.0", "2fh.1", "2fh.2", "2fh.3", |
| 150 | "2fh.4", "2fh.5", "2fh.6", "2fh.7" |
| 151 | }; |
| 152 | |
| 153 | //Regiser Bank memory names |
| 154 | static const char regbank[][6] = { |
| 155 | "rb0r0", "rb0r1", "rb0r2", "rb0r3", |
| 156 | "rb0r4", "rb0r5", "rb0r6", "rb0r7", |
| 157 | "rb1r0", "rb1r1", "rb1r2", "rb1r3", |
| 158 | "rb1r4", "rb1r5", "rb1r6", "rb1r7", |
| 159 | "rb2r0", "rb2r1", "rb2r2", "rb2r3", |
| 160 | "rb2r4", "rb2r5", "rb2r6", "rb2r7", |
| 161 | "rb3r0", "rb3r1", "rb3r2", "rb3r3", |
| 162 | "rb3r4", "rb3r5", "rb3r6", "rb3r7" |
| 163 | }; |
| 164 | |
| 165 | static const char *get_data_address( UINT8 arg ) |
| 166 | { |
| 167 | char *buffer = cpuintrf_temp_str(); |
| 168 | |
| 169 | if(arg < 0x80) |
| 170 | { |
| 171 | //Ram locations 0-0x1F are considered register access in 3 banks |
| 172 | if(arg < 0x1f) |
| 173 | sprintf(buffer,"%s",regbank[arg]); |
| 174 | else |
| 175 | sprintf(buffer,"$%02X",arg); |
| 176 | } |
| 177 | else |
| 178 | sprintf(buffer,"%s",sfr[arg-0x80]); |
| 179 | return buffer; |
| 180 | } |
| 181 | |
| 182 | static const char *get_bit_address( UINT8 arg ) |
| 183 | { |
| 184 | char *buffer = cpuintrf_temp_str(); |
| 185 | |
| 186 | if(arg < 0x80) |
| 187 | { |
| 188 | //Bit address 0-7F can be referred to as 20.0, 20.1, to 20.7 for address 0, and 2f.0,2f.1 to 2f.7 for address 7f |
| 189 | if(arg < 0x7f) |
| 190 | sprintf(buffer,"%s",membits[arg]); |
| 191 | else |
| 192 | sprintf(buffer,"$%02X",arg); |
| 193 | } |
| 194 | else |
| 195 | sprintf(buffer,"%s",sfrbits[arg-0x80]); |
| 196 | return buffer; |
| 197 | } |
| 198 | |
| 199 | #else |
| 200 | |
| 201 | /*Just display the actual memory address for data & bit address access*/ |
| 202 | |
| 203 | static const char *get_data_address( UINT8 arg ) |
| 204 | { |
| 205 | char *buffer = cpuintrf_temp_str(); |
| 206 | sprintf(buffer,"$%02X",arg); |
| 207 | return buffer; |
| 208 | } |
| 209 | |
| 210 | static const char *get_bit_address( UINT8 arg ) |
| 211 | { |
| 212 | char *buffer = cpuintrf_temp_str(); |
| 213 | sprintf(buffer,"$%02X",arg); |
| 214 | return buffer; |
| 215 | } |
| 216 | |
| 217 | #endif |
| 218 | |
| 219 | |
| 220 | unsigned i8051_dasm(char *dst, unsigned pc, const UINT8 *oprom, const UINT8 *opram) |
| 221 | { |
| 222 | UINT32 flags = 0; |
| 223 | unsigned PC = pc; |
| 224 | const char *sym, *sym2; |
| 225 | UINT8 op, data; |
| 226 | UINT16 addr; |
| 227 | INT8 rel; |
| 228 | |
| 229 | op = oprom[PC++ - pc]; |
| 230 | switch( op ) |
| 231 | { |
| 232 | //NOP |
| 233 | case 0x00: /* 1: 0000 0000 */ |
| 234 | sprintf(dst, "nop"); |
| 235 | break; |
| 236 | |
| 237 | //AJMP code addr /* 1: aaa0 0001 */ |
| 238 | case 0x01: |
| 239 | case 0x21: |
| 240 | case 0x41: |
| 241 | case 0x61: |
| 242 | case 0x81: |
| 243 | case 0xa1: |
| 244 | case 0xc1: |
| 245 | case 0xe1: |
| 246 | addr = opram[PC++ - pc]; |
| 247 | addr|= (PC & 0xf800) | ((op & 0xe0) << 3); |
| 248 | sprintf(dst, "ajmp $%04X", addr); |
| 249 | break; |
| 250 | |
| 251 | //LJMP code addr |
| 252 | case 0x02: /* 1: 0000 0010 */ |
| 253 | addr = (opram[PC++ - pc]<<8) & 0xff00; |
| 254 | addr|= opram[PC++ - pc]; |
| 255 | sprintf(dst, "ljmp $%04X", addr); |
| 256 | break; |
| 257 | |
| 258 | //RR A |
| 259 | case 0x03: /* 1: 0000 0011 */ |
| 260 | sprintf(dst, "rr a"); |
| 261 | break; |
| 262 | |
| 263 | //INC A |
| 264 | case 0x04: /* 1: 0000 0100 */ |
| 265 | sprintf(dst, "inc a"); |
| 266 | break; |
| 267 | |
| 268 | //INC data addr |
| 269 | case 0x05: /* 1: 0000 0101 */ |
| 270 | sym = get_data_address(opram[PC++ - pc]); |
| 271 | sprintf(dst, "inc %s", sym); |
| 272 | break; |
| 273 | |
| 274 | //INC @R0/@R1 /* 1: 0000 011i */ |
| 275 | case 0x06: |
| 276 | case 0x07: |
| 277 | sprintf(dst, "inc @r%d", op&1); |
| 278 | break; |
| 279 | |
| 280 | //INC R0 to R7 /* 1: 0000 1rrr */ |
| 281 | case 0x08: |
| 282 | case 0x09: |
| 283 | case 0x0a: |
| 284 | case 0x0b: |
| 285 | case 0x0c: |
| 286 | case 0x0d: |
| 287 | case 0x0e: |
| 288 | case 0x0f: |
| 289 | sprintf(dst, "inc r%d", op&7); |
| 290 | break; |
| 291 | |
| 292 | //JBC bit addr, code addr |
| 293 | case 0x10: /* 1: 0001 0000 */ |
| 294 | sym = get_bit_address(opram[PC++ - pc]); |
| 295 | rel = opram[PC++ - pc]; |
| 296 | sprintf(dst, "jbc %s,$%04X", sym, PC + rel); |
| 297 | break; |
| 298 | |
| 299 | //ACALL code addr /* 1: aaa1 0001 */ |
| 300 | case 0x11: |
| 301 | case 0x31: |
| 302 | case 0x51: |
| 303 | case 0x71: |
| 304 | case 0x91: |
| 305 | case 0xb1: |
| 306 | case 0xd1: |
| 307 | case 0xf1: |
| 308 | sprintf(dst, "acall $%04X", (PC & 0xf800) | ((op & 0xe0) << 3) | opram[PC - pc]); |
| 309 | PC++; |
| 310 | flags = DASMFLAG_STEP_OVER; |
| 311 | break; |
| 312 | |
| 313 | //LCALL code addr |
| 314 | case 0x12: /* 1: 0001 0010 */ |
| 315 | addr = (opram[PC++ - pc]<<8) & 0xff00; |
| 316 | addr|= opram[PC++ - pc]; |
| 317 | sprintf(dst, "lcall $%04X", addr); |
| 318 | flags = DASMFLAG_STEP_OVER; |
| 319 | break; |
| 320 | |
| 321 | //RRC A |
| 322 | case 0x13: /* 1: 0001 0011 */ |
| 323 | sprintf(dst, "rrc a"); |
| 324 | break; |
| 325 | |
| 326 | //DEC A |
| 327 | case 0x14: /* 1: 0001 0100 */ |
| 328 | sprintf(dst, "dec a"); |
| 329 | break; |
| 330 | |
| 331 | //DEC data addr |
| 332 | case 0x15: /* 1: 0001 0101 */ |
| 333 | sym = get_data_address(opram[PC++ - pc]); |
| 334 | sprintf(dst, "dec %s", sym); |
| 335 | break; |
| 336 | |
| 337 | //Unable to test |
| 338 | //DEC @R0/@R1 /* 1: 0001 011i */ |
| 339 | case 0x16: |
| 340 | case 0x17: |
| 341 | sprintf(dst, "dec @r%d", op&1); |
| 342 | break; |
| 343 | |
| 344 | //DEC R0 to R7 /* 1: 0001 1rrr */ |
| 345 | case 0x18: |
| 346 | case 0x19: |
| 347 | case 0x1a: |
| 348 | case 0x1b: |
| 349 | case 0x1c: |
| 350 | case 0x1d: |
| 351 | case 0x1e: |
| 352 | case 0x1f: |
| 353 | sprintf(dst, "dec r%d", op&7); |
| 354 | break; |
| 355 | |
| 356 | //JB bit addr, code addr |
| 357 | case 0x20: /* 1: 0010 0000 */ |
| 358 | sym = get_bit_address(opram[PC++ - pc]); |
| 359 | rel = opram[PC++ - pc]; |
| 360 | sprintf(dst, "jb %s,$%04X", sym, (PC + rel)); |
| 361 | break; |
| 362 | |
| 363 | //RET |
| 364 | case 0x22: /* 1: 0010 0010 */ |
| 365 | sprintf(dst, "ret"); |
| 366 | flags = DASMFLAG_STEP_OUT; |
| 367 | break; |
| 368 | |
| 369 | //RL A |
| 370 | case 0x23: /* 1: 0010 0011 */ |
| 371 | sprintf(dst, "rl a"); |
| 372 | break; |
| 373 | |
| 374 | //ADD A, #data |
| 375 | case 0x24: /* 1: 0010 0100 */ |
| 376 | sprintf(dst, "add a,#$%02X", opram[PC++ - pc]); |
| 377 | break; |
| 378 | |
| 379 | //ADD A, data addr |
| 380 | case 0x25: /* 1: 0010 0101 */ |
| 381 | sym = get_data_address(opram[PC++ - pc]); |
| 382 | sprintf(dst, "add a,%s", sym); |
| 383 | break; |
| 384 | |
| 385 | //Unable to Test |
| 386 | //ADD A, @R0/@R1 /* 1: 0010 011i */ |
| 387 | case 0x26: |
| 388 | case 0x27: |
| 389 | sprintf(dst, "add a,@r%d", op&1); |
| 390 | break; |
| 391 | |
| 392 | //ADD A, R0 to R7 /* 1: 0010 1rrr */ |
| 393 | case 0x28: |
| 394 | case 0x29: |
| 395 | case 0x2a: |
| 396 | case 0x2b: |
| 397 | case 0x2c: |
| 398 | case 0x2d: |
| 399 | case 0x2e: |
| 400 | case 0x2f: |
| 401 | sprintf(dst, "add a,r%d", op&7); |
| 402 | break; |
| 403 | |
| 404 | //JNB bit addr, code addr |
| 405 | case 0x30: /* 1: 0011 0000 */ |
| 406 | sym = get_bit_address(opram[PC++ - pc]); |
| 407 | rel = opram[PC++ - pc]; |
| 408 | sprintf(dst, "jnb %s,$%04X", sym, (PC + rel)); |
| 409 | break; |
| 410 | |
| 411 | //RETI |
| 412 | case 0x32: /* 1: 0011 0010 */ |
| 413 | sprintf(dst, "reti"); |
| 414 | flags = DASMFLAG_STEP_OUT; |
| 415 | break; |
| 416 | |
| 417 | //RLC A |
| 418 | case 0x33: /* 1: 0011 0011 */ |
| 419 | sprintf(dst, "rlc a"); |
| 420 | break; |
| 421 | |
| 422 | //ADDC A, #data |
| 423 | case 0x34: /* 1: 0011 0100 */ |
| 424 | sprintf(dst, "addc a,#$%02X", opram[PC++ - pc]); |
| 425 | break; |
| 426 | |
| 427 | //ADDC A, data addr |
| 428 | case 0x35: /* 1: 0011 0101 */ |
| 429 | sym = get_data_address(opram[PC++ - pc]); |
| 430 | sprintf(dst, "addc a,%s", sym); |
| 431 | break; |
| 432 | |
| 433 | //ADDC A, @R0/@R1 /* 1: 0011 011i */ |
| 434 | case 0x36: |
| 435 | case 0x37: |
| 436 | sprintf(dst, "addc a,@r%d", op&1); |
| 437 | break; |
| 438 | |
| 439 | //ADDC A, R0 to R7 /* 1: 0011 1rrr */ |
| 440 | case 0x38: |
| 441 | case 0x39: |
| 442 | case 0x3a: |
| 443 | case 0x3b: |
| 444 | case 0x3c: |
| 445 | case 0x3d: |
| 446 | case 0x3e: |
| 447 | case 0x3f: |
| 448 | sprintf(dst, "addc a,r%d", op&7); |
| 449 | break; |
| 450 | |
| 451 | //JC code addr |
| 452 | case 0x40: /* 1: 0100 0000 */ |
| 453 | rel = opram[PC++ - pc]; |
| 454 | sprintf(dst, "jc $%04X", PC + rel); |
| 455 | break; |
| 456 | |
| 457 | //ORL data addr, A |
| 458 | case 0x42: /* 1: 0100 0010 */ |
| 459 | sym = get_data_address(opram[PC++ - pc]); |
| 460 | sprintf(dst, "orl %s,a", sym); |
| 461 | break; |
| 462 | |
| 463 | //ORL data addr, #data |
| 464 | case 0x43: /* 1: 0100 0011 */ |
| 465 | sym = get_data_address(opram[PC++ - pc]); |
| 466 | sprintf(dst, "orl %s,#$%02X", sym, opram[PC++ - pc]); |
| 467 | break; |
| 468 | |
| 469 | //Unable to Test |
| 470 | //ORL A, #data |
| 471 | case 0x44: /* 1: 0100 0100 */ |
| 472 | sprintf(dst, "orl a,#$%02X", opram[PC++ - pc]); |
| 473 | break; |
| 474 | |
| 475 | //ORL A, data addr |
| 476 | case 0x45: /* 1: 0100 0101 */ |
| 477 | sym = get_data_address(opram[PC++ - pc]); |
| 478 | sprintf(dst, "orl a,%s", sym); |
| 479 | break; |
| 480 | |
| 481 | //ORL A, @RO/@R1 /* 1: 0100 011i */ |
| 482 | case 0x46: |
| 483 | case 0x47: |
| 484 | sprintf(dst, "orl a,@r%d", op&1); |
| 485 | break; |
| 486 | |
| 487 | //ORL A, RO to R7 /* 1: 0100 1rrr */ |
| 488 | case 0x48: |
| 489 | case 0x49: |
| 490 | case 0x4a: |
| 491 | case 0x4b: |
| 492 | case 0x4c: |
| 493 | case 0x4d: |
| 494 | case 0x4e: |
| 495 | case 0x4f: |
| 496 | sprintf(dst, "orl a,r%d", op&7); |
| 497 | break; |
| 498 | |
| 499 | //JNC code addr |
| 500 | case 0x50: /* 1: 0101 0000 */ |
| 501 | rel = opram[PC++ - pc]; |
| 502 | sprintf(dst, "jnc $%04X", PC + rel); |
| 503 | break; |
| 504 | |
| 505 | //Unable to test |
| 506 | //ANL data addr, A |
| 507 | case 0x52: /* 1: 0101 0010 */ |
| 508 | sym = get_data_address(opram[PC++ - pc]); |
| 509 | sprintf(dst, "anl %s,a", sym); |
| 510 | break; |
| 511 | |
| 512 | //Unable to test |
| 513 | //ANL data addr, #data |
| 514 | case 0x53: /* 1: 0101 0011 */ |
| 515 | sym = get_data_address(opram[PC++ - pc]); |
| 516 | sprintf(dst, "anl %s,#$%02X", sym, opram[PC++ - pc]); |
| 517 | break; |
| 518 | |
| 519 | //ANL A, #data |
| 520 | case 0x54: /* 1: 0101 0100 */ |
| 521 | sprintf(dst, "anl a,#$%02X", opram[PC++ - pc]); |
| 522 | break; |
| 523 | |
| 524 | //ANL A, data addr |
| 525 | case 0x55: /* 1: 0101 0101 */ |
| 526 | sym = get_data_address(opram[PC++ - pc]); |
| 527 | sprintf(dst, "anl a,%s", sym); |
| 528 | break; |
| 529 | |
| 530 | //Unable to test |
| 531 | //ANL A, @RO/@R1 /* 1: 0101 011i */ |
| 532 | case 0x56: |
| 533 | case 0x57: |
| 534 | sprintf(dst, "anl a,@r%d", op&1); |
| 535 | break; |
| 536 | |
| 537 | //ANL A, RO to R7 /* 1: 0101 1rrr */ |
| 538 | case 0x58: |
| 539 | case 0x59: |
| 540 | case 0x5a: |
| 541 | case 0x5b: |
| 542 | case 0x5c: |
| 543 | case 0x5d: |
| 544 | case 0x5e: |
| 545 | case 0x5f: |
| 546 | sprintf(dst, "anl a,r%d", op&7); |
| 547 | break; |
| 548 | |
| 549 | //JZ code addr |
| 550 | case 0x60: /* 1: 0110 0000 */ |
| 551 | rel = opram[PC++ - pc]; |
| 552 | sprintf(dst, "jz $%04X", PC + rel); |
| 553 | break; |
| 554 | |
| 555 | //Unable to test |
| 556 | //XRL data addr, A |
| 557 | case 0x62: /* 1: 0110 0010 */ |
| 558 | sym = get_data_address(opram[PC++ - pc]); |
| 559 | sprintf(dst, "xrl %s,a", sym); |
| 560 | break; |
| 561 | |
| 562 | //XRL data addr, #data |
| 563 | case 0x63: /* 1: 0110 0011 */ |
| 564 | sym = get_data_address(opram[PC++ - pc]); |
| 565 | sprintf(dst, "xrl %s,#$%02X", sym, opram[PC++ - pc]); |
| 566 | break; |
| 567 | |
| 568 | //XRL A, #data |
| 569 | case 0x64: /* 1: 0110 0100 */ |
| 570 | sprintf(dst, "xrl a,#$%02X", opram[PC++ - pc]); |
| 571 | break; |
| 572 | |
| 573 | //XRL A, data addr |
| 574 | case 0x65: /* 1: 0110 0101 */ |
| 575 | sym = get_data_address(opram[PC++ - pc]); |
| 576 | sprintf(dst, "xrl a,%s", sym); |
| 577 | break; |
| 578 | |
| 579 | //Unable to test |
| 580 | //XRL A, @R0/@R1 /* 1: 0110 011i */ |
| 581 | case 0x66: |
| 582 | case 0x67: |
| 583 | sprintf(dst, "xrl a,@r%d", op&1); |
| 584 | break; |
| 585 | |
| 586 | //XRL A, R0 to R7 /* 1: 0110 1rrr */ |
| 587 | case 0x68: |
| 588 | case 0x69: |
| 589 | case 0x6a: |
| 590 | case 0x6b: |
| 591 | case 0x6c: |
| 592 | case 0x6d: |
| 593 | case 0x6e: |
| 594 | case 0x6f: |
| 595 | sprintf(dst, "xrl a,r%d", op&7); |
| 596 | break; |
| 597 | |
| 598 | //JNZ code addr |
| 599 | case 0x70: /* 1: 0111 0000 */ |
| 600 | rel = opram[PC++ - pc]; |
| 601 | sprintf(dst, "jnz $%04X", PC + rel); |
| 602 | break; |
| 603 | |
| 604 | //Unable to test |
| 605 | //ORL C, bit addr |
| 606 | case 0x72: /* 1: 0111 0010 */ |
| 607 | sym = get_bit_address(opram[PC++ - pc]); |
| 608 | sprintf(dst, "orl c,%s", sym); |
| 609 | break; |
| 610 | |
| 611 | //Unable to test |
| 612 | //JMP @A+DPTR |
| 613 | case 0x73: /* 1: 0111 0011 */ |
| 614 | sprintf(dst, "jmp @a+dptr"); |
| 615 | break; |
| 616 | |
| 617 | //MOV A, #data |
| 618 | case 0x74: /* 1: 0111 0100 */ |
| 619 | sprintf(dst, "mov a,#$%02X", opram[PC++ - pc]); |
| 620 | break; |
| 621 | |
| 622 | //MOV data addr, #data |
| 623 | case 0x75: /* 1: 0111 0101 */ |
| 624 | sym = get_data_address(opram[PC++ - pc]); |
| 625 | sprintf(dst, "mov %s,#$%02X", sym, opram[PC++ - pc]); |
| 626 | break; |
| 627 | |
| 628 | //Unable to test |
| 629 | //MOV @R0/@R1, #data /* 1: 0111 011i */ |
| 630 | case 0x76: |
| 631 | case 0x77: |
| 632 | sprintf(dst, "mov @r%d,#$%02X", op&1, opram[PC++ - pc]); |
| 633 | break; |
| 634 | |
| 635 | //MOV R0 to R7, #data /* 1: 0111 1rrr */ |
| 636 | case 0x78: |
| 637 | case 0x79: |
| 638 | case 0x7a: |
| 639 | case 0x7b: |
| 640 | case 0x7c: |
| 641 | case 0x7d: |
| 642 | case 0x7e: |
| 643 | case 0x7f: |
| 644 | sprintf(dst, "mov r%d,#$%02X", (op & 7), opram[PC++ - pc]); |
| 645 | break; |
| 646 | |
| 647 | //SJMP code addr |
| 648 | case 0x80: /* 1: 1000 0000 */ |
| 649 | rel = opram[PC++ - pc]; |
| 650 | sprintf(dst, "sjmp $%04X", PC + rel); |
| 651 | break; |
| 652 | |
| 653 | //ANL C, bit addr |
| 654 | case 0x82: /* 1: 1000 0010 */ |
| 655 | sym = get_bit_address(opram[PC++ - pc]); |
| 656 | sprintf(dst, "anl c,%s", sym); |
| 657 | break; |
| 658 | |
| 659 | //MOVC A, @A + PC |
| 660 | case 0x83: /* 1: 1000 0011 */ |
| 661 | sprintf(dst, "movc a,@a+pc"); |
| 662 | break; |
| 663 | |
| 664 | //DIV AB |
| 665 | case 0x84: /* 1: 1000 0100 */ |
| 666 | sprintf(dst, "div ab"); |
| 667 | break; |
| 668 | |
| 669 | //MOV data addr, data addr (Note: 1st address is src, 2nd is dst, but the mov command works as mov dst,src) |
| 670 | case 0x85: /* 1: 1000 0101 */ |
| 671 | sym = get_data_address(opram[PC++ - pc]); |
| 672 | sym2 = get_data_address(opram[PC++ - pc]); |
| 673 | sprintf(dst, "mov %s,%s", sym2, sym); |
| 674 | break; |
| 675 | |
| 676 | //Unable to test |
| 677 | //MOV data addr, @R0/@R1/* 1: 1000 011i */ |
| 678 | case 0x86: |
| 679 | case 0x87: |
| 680 | sym = get_data_address(opram[PC++ - pc]); |
| 681 | sprintf(dst, "mov %s,@r%d", sym, op&1); |
| 682 | break; |
| 683 | |
| 684 | //MOV data addr,R0 to R7/* 1: 1000 1rrr */ |
| 685 | case 0x88: |
| 686 | case 0x89: |
| 687 | case 0x8a: |
| 688 | case 0x8b: |
| 689 | case 0x8c: |
| 690 | case 0x8d: |
| 691 | case 0x8e: |
| 692 | case 0x8f: |
| 693 | sym = get_data_address(opram[PC++ - pc]); |
| 694 | sprintf(dst, "mov %s,r%d", sym, op&7); |
| 695 | break; |
| 696 | |
| 697 | //MOV DPTR, #data16 |
| 698 | case 0x90: /* 1: 1001 0000 */ |
| 699 | addr = (opram[PC++ - pc]<<8) & 0xff00; |
| 700 | addr|= opram[PC++ - pc]; |
| 701 | sprintf(dst, "mov dptr,#$%04X", addr); |
| 702 | break; |
| 703 | |
| 704 | //MOV bit addr, C |
| 705 | case 0x92: /* 1: 1001 0010 */ |
| 706 | sym = get_bit_address(opram[PC++ - pc]); |
| 707 | sprintf(dst, "mov %s,c", sym); |
| 708 | break; |
| 709 | |
| 710 | //MOVC A, @A + DPTR |
| 711 | case 0x93: /* 1: 1001 0011 */ |
| 712 | sprintf(dst, "movc a,@a+dptr"); |
| 713 | break; |
| 714 | |
| 715 | //SUBB A, #data |
| 716 | case 0x94: /* 1: 1001 0100 */ |
| 717 | sprintf(dst, "subb a,#$%02X", opram[PC++ - pc]); |
| 718 | break; |
| 719 | |
| 720 | //SUBB A, data addr |
| 721 | case 0x95: /* 1: 1001 0101 */ |
| 722 | sym = get_data_address(opram[PC++ - pc]); |
| 723 | sprintf(dst, "subb a,%s", sym); |
| 724 | break; |
| 725 | |
| 726 | //Unable to test |
| 727 | //SUBB A, @R0/@R1 /* 1: 1001 011i */ |
| 728 | case 0x96: |
| 729 | case 0x97: |
| 730 | sprintf(dst, "subb a,@r%d", op&1); |
| 731 | break; |
| 732 | |
| 733 | //SUBB A, R0 to R7 /* 1: 1001 1rrr */ |
| 734 | case 0x98: |
| 735 | case 0x99: |
| 736 | case 0x9a: |
| 737 | case 0x9b: |
| 738 | case 0x9c: |
| 739 | case 0x9d: |
| 740 | case 0x9e: |
| 741 | case 0x9f: |
| 742 | sprintf(dst, "subb a,r%d", op&7); |
| 743 | break; |
| 744 | |
| 745 | //Unable to test |
| 746 | //ORL C, /bit addr |
| 747 | case 0xa0: /* 1: 1010 0000 */ |
| 748 | sym = get_bit_address(opram[PC++ - pc]); |
| 749 | sprintf(dst, "orl c,/%s", sym); |
| 750 | break; |
| 751 | |
| 752 | //MOV C, bit addr |
| 753 | case 0xa2: /* 1: 1010 0010 */ |
| 754 | sym = get_bit_address(opram[PC++ - pc]); |
| 755 | sprintf(dst, "mov c,%s", sym); |
| 756 | break; |
| 757 | |
| 758 | //INC DPTR |
| 759 | case 0xa3: /* 1: 1010 0011 */ |
| 760 | sprintf(dst, "inc dptr"); |
| 761 | break; |
| 762 | |
| 763 | //MUL AB |
| 764 | case 0xa4: /* 1: 1010 0100 */ |
| 765 | sprintf(dst, "mul ab"); |
| 766 | break; |
| 767 | |
| 768 | //reserved |
| 769 | case 0xa5: /* 1: 1010 0101 */ |
| 770 | sprintf(dst, "ill/rsv"); |
| 771 | break; |
| 772 | |
| 773 | //Unable to test |
| 774 | //MOV @R0/@R1, data addr /* 1: 1010 011i */ |
| 775 | case 0xa6: |
| 776 | case 0xa7: |
| 777 | sym = get_data_address(opram[PC++ - pc]); |
| 778 | sprintf(dst, "mov @r%d,%s", op&1, sym); |
| 779 | break; |
| 780 | |
| 781 | //MOV R0 to R7, data addr /* 1: 1010 1rrr */ |
| 782 | case 0xa8: |
| 783 | case 0xa9: |
| 784 | case 0xaa: |
| 785 | case 0xab: |
| 786 | case 0xac: |
| 787 | case 0xad: |
| 788 | case 0xae: |
| 789 | case 0xaf: |
| 790 | sym = get_data_address(opram[PC++ - pc]); |
| 791 | sprintf(dst, "mov r%d,%s", op&7, sym); |
| 792 | break; |
| 793 | |
| 794 | //ANL C,/bit addr |
| 795 | case 0xb0: /* 1: 1011 0000 */ |
| 796 | sym = get_bit_address(opram[PC++ - pc]); |
| 797 | sprintf(dst, "anl c,/%s", sym); |
| 798 | break; |
| 799 | |
| 800 | //CPL bit addr |
| 801 | case 0xb2: /* 1: 1011 0010 */ |
| 802 | sym = get_bit_address(opram[PC++ - pc]); |
| 803 | sprintf(dst, "cpl %s", sym); |
| 804 | break; |
| 805 | |
| 806 | //Unable to test |
| 807 | //CPL C |
| 808 | case 0xb3: /* 1: 1011 0011 */ |
| 809 | sprintf(dst, "cpl c"); |
| 810 | break; |
| 811 | |
| 812 | //CJNE A, #data, code addr |
| 813 | case 0xb4: /* 1: 1011 0100 */ |
| 814 | data = opram[PC++ - pc]; |
| 815 | rel = opram[PC++ - pc]; |
| 816 | sprintf(dst, "cjne a,#$%02X,$%04X", data, PC + rel); |
| 817 | break; |
| 818 | |
| 819 | //CJNE A, data addr, code addr |
| 820 | case 0xb5: /* 1: 1011 0101 */ |
| 821 | sym = get_data_address(opram[PC++ - pc]); |
| 822 | rel = opram[PC++ - pc]; |
| 823 | sprintf(dst, "cjne a,%s,$%04X", sym, PC + rel); |
| 824 | break; |
| 825 | |
| 826 | //Unable to test |
| 827 | //CJNE @R0/@R1, #data, code addr /* 1: 1011 011i */ |
| 828 | case 0xb6: |
| 829 | case 0xb7: |
| 830 | data = opram[PC++ - pc]; |
| 831 | rel = opram[PC++ - pc]; |
| 832 | sprintf(dst, "cjne @r%d,#$%02X,$%04X", op&1, data, PC + rel); |
| 833 | break; |
| 834 | |
| 835 | //CJNE R0 to R7, #data, code addr/* 1: 1011 1rrr */ |
| 836 | case 0xb8: |
| 837 | case 0xb9: |
| 838 | case 0xba: |
| 839 | case 0xbb: |
| 840 | case 0xbc: |
| 841 | case 0xbd: |
| 842 | case 0xbe: |
| 843 | case 0xbf: |
| 844 | data = opram[PC++ - pc]; |
| 845 | rel = opram[PC++ - pc]; |
| 846 | sprintf(dst, "cjne r%d,#$%02X,$%04X", op&7, data, PC + rel); |
| 847 | break; |
| 848 | |
| 849 | //PUSH data addr |
| 850 | case 0xc0: /* 1: 1100 0000 */ |
| 851 | sym = get_data_address(opram[PC++ - pc]); |
| 852 | sprintf(dst, "push %s", sym); |
| 853 | break; |
| 854 | |
| 855 | //CLR bit addr |
| 856 | case 0xc2: /* 1: 1100 0010 */ |
| 857 | sym = get_bit_address(opram[PC++ - pc]); |
| 858 | sprintf(dst, "clr %s", sym); |
| 859 | break; |
| 860 | |
| 861 | //CLR C |
| 862 | case 0xc3: /* 1: 1100 0011 */ |
| 863 | sprintf(dst, "clr c"); |
| 864 | break; |
| 865 | |
| 866 | //SWAP A |
| 867 | case 0xc4: /* 1: 1100 0100 */ |
| 868 | sprintf(dst, "swap a"); |
| 869 | break; |
| 870 | |
| 871 | //XCH A, data addr |
| 872 | case 0xc5: /* 1: 1100 0101 */ |
| 873 | sym = get_data_address(opram[PC++ - pc]); |
| 874 | sprintf(dst, "xch a,%s", sym); |
| 875 | break; |
| 876 | |
| 877 | //XCH A, @RO/@R1 /* 1: 1100 011i */ |
| 878 | case 0xc6: |
| 879 | case 0xc7: |
| 880 | sprintf(dst, "xch a,@r%d", op&1); |
| 881 | break; |
| 882 | |
| 883 | //XCH A, RO to R7 /* 1: 1100 1rrr */ |
| 884 | case 0xc8: |
| 885 | case 0xc9: |
| 886 | case 0xca: |
| 887 | case 0xcb: |
| 888 | case 0xcc: |
| 889 | case 0xcd: |
| 890 | case 0xce: |
| 891 | case 0xcf: |
| 892 | sprintf(dst, "xch a,r%d", op&7); |
| 893 | break; |
| 894 | |
| 895 | //POP data addr |
| 896 | case 0xd0: /* 1: 1101 0000 */ |
| 897 | sym = get_data_address(opram[PC++ - pc]); |
| 898 | sprintf(dst, "pop %s", sym); |
| 899 | break; |
| 900 | |
| 901 | //SETB bit addr |
| 902 | case 0xd2: /* 1: 1101 0010 */ |
| 903 | sym = get_bit_address(opram[PC++ - pc]); |
| 904 | sprintf(dst, "setb %s", sym); |
| 905 | break; |
| 906 | |
| 907 | //SETB C |
| 908 | case 0xd3: /* 1: 1101 0011 */ |
| 909 | sprintf(dst, "setb c"); |
| 910 | break; |
| 911 | |
| 912 | //Unable to test |
| 913 | //DA A |
| 914 | case 0xd4: /* 1: 1101 0100 */ |
| 915 | sprintf(dst, "da a"); |
| 916 | break; |
| 917 | |
| 918 | //DJNZ data addr, code addr |
| 919 | case 0xd5: /* 1: 1101 0101 */ |
| 920 | sym = get_data_address(opram[PC++ - pc]); |
| 921 | rel = opram[PC++ - pc]; |
| 922 | sprintf(dst, "djnz %s,$%04X", sym, PC + rel); |
| 923 | flags = DASMFLAG_STEP_OVER; |
| 924 | break; |
| 925 | |
| 926 | //XCHD A, @R0/@R1 /* 1: 1101 011i */ |
| 927 | case 0xd6: |
| 928 | case 0xd7: |
| 929 | sprintf(dst, "xchd a,@r%d", op&1); |
| 930 | break; |
| 931 | |
| 932 | //DJNZ R0 to R7,code addr /* 1: 1101 1rrr */ |
| 933 | case 0xd8: |
| 934 | case 0xd9: |
| 935 | case 0xda: |
| 936 | case 0xdb: |
| 937 | case 0xdc: |
| 938 | case 0xdd: |
| 939 | case 0xde: |
| 940 | case 0xdf: |
| 941 | rel = opram[PC++ - pc]; |
| 942 | sprintf(dst, "djnz r%d,$%04X", op&7, (PC + rel)); |
| 943 | flags = DASMFLAG_STEP_OVER; |
| 944 | break; |
| 945 | |
| 946 | //MOVX A,@DPTR |
| 947 | case 0xe0: /* 1: 1110 0000 */ |
| 948 | sprintf(dst, "movx a,@dptr"); |
| 949 | break; |
| 950 | |
| 951 | //Unable to test |
| 952 | //MOVX A, @R0/@R1 /* 1: 1110 001i */ |
| 953 | case 0xe2: |
| 954 | case 0xe3: |
| 955 | sprintf(dst, "movx a,@r%d", op&1); |
| 956 | break; |
| 957 | |
| 958 | //CLR A |
| 959 | case 0xe4: /* 1: 1110 0100 */ |
| 960 | sprintf(dst, "clr a"); |
| 961 | break; |
| 962 | |
| 963 | //MOV A, data addr |
| 964 | case 0xe5: /* 1: 1110 0101 */ |
| 965 | sym = get_data_address(opram[PC++ - pc]); |
| 966 | sprintf(dst, "mov a,%s", sym); |
| 967 | break; |
| 968 | |
| 969 | //Unable to test |
| 970 | //MOV A,@RO/@R1 /* 1: 1110 011i */ |
| 971 | case 0xe6: |
| 972 | case 0xe7: |
| 973 | sprintf(dst, "mov a,@r%d", op&1); |
| 974 | break; |
| 975 | |
| 976 | //MOV A,R0 to R7 /* 1: 1110 1rrr */ |
| 977 | case 0xe8: |
| 978 | case 0xe9: |
| 979 | case 0xea: |
| 980 | case 0xeb: |
| 981 | case 0xec: |
| 982 | case 0xed: |
| 983 | case 0xee: |
| 984 | case 0xef: |
| 985 | sprintf(dst, "mov a,r%d", op&7); |
| 986 | break; |
| 987 | |
| 988 | //MOVX @DPTR,A |
| 989 | case 0xf0: /* 1: 1111 0000 */ |
| 990 | sprintf(dst, "movx @dptr,a"); |
| 991 | break; |
| 992 | |
| 993 | //Unable to test |
| 994 | //MOVX @R0/@R1,A /* 1: 1111 001i */ |
| 995 | case 0xf2: |
| 996 | case 0xf3: |
| 997 | sprintf(dst, "movx @r%d,a", op&1); |
| 998 | break; |
| 999 | |
| 1000 | //CPL A |
| 1001 | case 0xf4: /* 1: 1111 0100 */ |
| 1002 | sprintf(dst, "cpl a"); |
| 1003 | break; |
| 1004 | |
| 1005 | //MOV data addr, A |
| 1006 | case 0xf5: /* 1: 1111 0101 */ |
| 1007 | sym = get_data_address(opram[PC++ - pc]); |
| 1008 | sprintf(dst, "mov %s,a", sym); |
| 1009 | break; |
| 1010 | |
| 1011 | //MOV @R0/@R1, A /* 1: 1111 011i */ |
| 1012 | case 0xf6: |
| 1013 | case 0xf7: |
| 1014 | sprintf(dst, "mov @r%d,a", op&1); |
| 1015 | break; |
| 1016 | |
| 1017 | //MOV R0 to R7, A /* 1: 1111 1rrr */ |
| 1018 | case 0xf8: |
| 1019 | case 0xf9: |
| 1020 | case 0xfa: |
| 1021 | case 0xfb: |
| 1022 | case 0xfc: |
| 1023 | case 0xfd: |
| 1024 | case 0xfe: |
| 1025 | case 0xff: |
| 1026 | sprintf(dst, "mov r%d,a", op&7); |
| 1027 | break; |
| 1028 | |
| 1029 | default: |
| 1030 | sprintf(dst, "illegal"); |
| 1031 | } |
| 1032 | return (PC - pc) | flags | DASMFLAG_SUPPORTED; |
| 1033 | } |
src/emu/cpu/m6502/6502dasm.c
| r3514 | r3515 | |
| 80 | 80 | bsr, |
| 81 | 81 | /* 6510 + 65c02 mnemonics */ |
| 82 | 82 | anc, asr, ast, arr, asx, axa, dcp, dea, |
| 83 | | dop, ina, isc, lax, phx, phy, plx, ply, |
| 83 | dop, ina, isb, lax, phx, phy, plx, ply, |
| 84 | 84 | rla, rra, sax, slo, sre, sah, say, ssh, |
| 85 | 85 | sxh, syh, top, oal, kil, |
| 86 | 86 | /* 65ce02 mnemonics */ |
| r3514 | r3515 | |
| 115 | 115 | "bsr", |
| 116 | 116 | /* 6510 mnemonics */ |
| 117 | 117 | "anc", "asr", "ast", "arr", "asx", "axa", "dcp", "dea", |
| 118 | | "dop", "ina", "isc", "lax", "phx", "phy", "plx", "ply", |
| 118 | "dop", "ina", "isb", "lax", "phx", "phy", "plx", "ply", |
| 119 | 119 | "rla", "rra", "sax", "slo", "sre", "sah", "say", "ssh", |
| 120 | 120 | "sxh", "syh", "top", "oal", "kil", |
| 121 | 121 | /* 65ce02 mnemonics */ |
| r3514 | r3515 | |
| 141 | 141 | |
| 142 | 142 | static const struct op6502_info op6502[256] = { |
| 143 | 143 | {m6502_brk,imm},{ora,idx},{kil,non},{slo,idx},/* 00 */ |
| 144 | | {dop,imm},{ora,zpg},{asl,zpg},{slo,zpg}, |
| 144 | {nop,zpg},{ora,zpg},{asl,zpg},{slo,zpg}, |
| 145 | 145 | {php,imp},{ora,imm},{asl,acc},{anc,imm}, |
| 146 | | {top,iw2},{ora,aba},{asl,aba},{slo,aba}, |
| 147 | | {bpl,rel},{ora,idy},{nop,imp},{slo,idy},/* 10 */ |
| 148 | | {dop,imm},{ora,zpx},{asl,zpx},{slo,zpx}, |
| 149 | | {clc,imp},{ora,aby},{kil,non},{slo,aby}, |
| 150 | | {top,iw2},{ora,abx},{asl,abx},{slo,abx}, |
| 146 | {nop,aba},{ora,aba},{asl,aba},{slo,aba}, |
| 147 | {bpl,rel},{ora,idy},{kil,non},{slo,idy},/* 10 */ |
| 148 | {nop,zpx},{ora,zpx},{asl,zpx},{slo,zpx}, |
| 149 | {clc,imp},{ora,aby},{nop,imp},{slo,aby}, |
| 150 | {nop,abx},{ora,abx},{asl,abx},{slo,abx}, |
| 151 | 151 | {jsr,adr},{and,idx},{kil,non},{rla,idx},/* 20 */ |
| 152 | 152 | {bit,zpg},{and,zpg},{rol,zpg},{rla,zpg}, |
| 153 | 153 | {plp,imp},{and,imm},{rol,acc},{anc,imm}, |
| 154 | 154 | {bit,aba},{and,aba},{rol,aba},{rla,aba}, |
| 155 | 155 | {bmi,rel},{and,idy},{kil,non},{rla,idy},/* 30 */ |
| 156 | | {dop,imm},{and,zpx},{rol,zpx},{rla,zpx}, |
| 156 | {nop,zpx},{and,zpx},{rol,zpx},{rla,zpx}, |
| 157 | 157 | {sec,imp},{and,aby},{nop,imp},{rla,aby}, |
| 158 | | {top,iw2},{and,abx},{rol,abx},{rla,abx}, |
| 158 | {nop,abx},{and,abx},{rol,abx},{rla,abx}, |
| 159 | 159 | {rti,imp},{eor,idx},{kil,non},{sre,idx},/* 40 */ |
| 160 | | {dop,imm},{eor,zpg},{lsr,zpg},{sre,zpg}, |
| 160 | {nop,zpg},{eor,zpg},{lsr,zpg},{sre,zpg}, |
| 161 | 161 | {pha,imp},{eor,imm},{lsr,acc},{asr,imm}, |
| 162 | 162 | {jmp,adr},{eor,aba},{lsr,aba},{sre,aba}, |
| 163 | 163 | {bvc,rel},{eor,idy},{kil,non},{sre,idy},/* 50 */ |
| 164 | | {dop,imm},{eor,zpx},{lsr,zpx},{sre,zpx}, |
| 164 | {nop,zpx},{eor,zpx},{lsr,zpx},{sre,zpx}, |
| 165 | 165 | {cli,imp},{eor,aby},{nop,imp},{sre,aby}, |
| 166 | | {top,iw2},{eor,abx},{lsr,abx},{sre,abx}, |
| 166 | {nop,abx},{eor,abx},{lsr,abx},{sre,abx}, |
| 167 | 167 | {rts,imp},{adc,idx},{kil,non},{rra,idx},/* 60 */ |
| 168 | | {dop,imm},{adc,zpg},{ror,zpg},{rra,zpg}, |
| 168 | {nop,zpg},{adc,zpg},{ror,zpg},{rra,zpg}, |
| 169 | 169 | {pla,imp},{adc,imm},{ror,acc},{arr,imm}, |
| 170 | 170 | {jmp,ind},{adc,aba},{ror,aba},{rra,aba}, |
| 171 | 171 | {bvs,rel},{adc,idy},{kil,non},{rra,idy},/* 70 */ |
| 172 | | {dop,imm},{adc,zpx},{ror,zpx},{rra,zpx}, |
| 172 | {nop,zpx},{adc,zpx},{ror,zpx},{rra,zpx}, |
| 173 | 173 | {sei,imp},{adc,aby},{nop,imp},{rra,aby}, |
| 174 | | {top,iw2},{adc,abx},{ror,abx},{rra,abx}, |
| 175 | | {dop,imm},{sta,idx},{dop,imm},{sax,idx},/* 80 */ |
| 174 | {nop,abx},{adc,abx},{ror,abx},{rra,abx}, |
| 175 | {nop,imm},{sta,idx},{nop,imm},{sax,idx},/* 80 */ |
| 176 | 176 | {sty,zpg},{sta,zpg},{stx,zpg},{sax,zpg}, |
| 177 | | {dey,imp},{dop,imm},{txa,imp},{axa,imm}, |
| 177 | {dey,imp},{nop,imm},{txa,imp},{axa,imm}, |
| 178 | 178 | {sty,aba},{sta,aba},{stx,aba},{sax,aba}, |
| 179 | 179 | {bcc,rel},{sta,idy},{kil,non},{say,idy},/* 90 */ |
| 180 | | {sty,zpx},{sta,zpx},{stx,zpy},{sax,zpx}, |
| 180 | {sty,zpx},{sta,zpx},{stx,zpy},{sax,zpy}, |
| 181 | 181 | {tya,imp},{sta,aby},{txs,imp},{ssh,aby}, |
| 182 | 182 | {syh,abx},{sta,abx},{sxh,aby},{sah,aby}, |
| 183 | 183 | {ldy,imm},{lda,idx},{ldx,imm},{lax,idx},/* a0 */ |
| r3514 | r3515 | |
| 185 | 185 | {tay,imp},{lda,imm},{tax,imp},{oal,imm}, |
| 186 | 186 | {ldy,aba},{lda,aba},{ldx,aba},{lax,aba}, |
| 187 | 187 | {bcs,rel},{lda,idy},{kil,non},{lax,idy},/* b0 */ |
| 188 | | {ldy,zpx},{lda,zpx},{ldx,zpy},{lax,zpx}, |
| 188 | {ldy,zpx},{lda,zpx},{ldx,zpy},{lax,zpy}, |
| 189 | 189 | {clv,imp},{lda,aby},{tsx,imp},{ast,aby}, |
| 190 | | {ldy,abx},{lda,abx},{ldx,aby},{lax,abx}, |
| 191 | | {cpy,imm},{cmp,idx},{dop,imm},{dcp,idx},/* c0 */ |
| 190 | {ldy,abx},{lda,abx},{ldx,aby},{lax,aby}, |
| 191 | {cpy,imm},{cmp,idx},{nop,imm},{dcp,idx},/* c0 */ |
| 192 | 192 | {cpy,zpg},{cmp,zpg},{dec,zpg},{dcp,zpg}, |
| 193 | 193 | {iny,imp},{cmp,imm},{dex,imp},{asx,imm}, |
| 194 | 194 | {cpy,aba},{cmp,aba},{dec,aba},{dcp,aba}, |
| 195 | 195 | {bne,rel},{cmp,idy},{kil,non},{dcp,idy},/* d0 */ |
| 196 | | {dop,imm},{cmp,zpx},{dec,zpx},{dcp,zpx}, |
| 196 | {nop,zpx},{cmp,zpx},{dec,zpx},{dcp,zpx}, |
| 197 | 197 | {cld,imp},{cmp,aby},{nop,imp},{dcp,aby}, |
| 198 | | {top,iw2},{cmp,abx},{dec,abx},{dcp,abx}, |
| 199 | | {cpx,imm},{sbc,idx},{dop,imm},{isc,idx},/* e0 */ |
| 200 | | {cpx,zpg},{sbc,zpg},{inc,zpg},{isc,zpg}, |
| 198 | {nop,abx},{cmp,abx},{dec,abx},{dcp,abx}, |
| 199 | {cpx,imm},{sbc,idx},{nop,imm},{isb,idx},/* e0 */ |
| 200 | {cpx,zpg},{sbc,zpg},{inc,zpg},{isb,zpg}, |
| 201 | 201 | {inx,imp},{sbc,imm},{nop,imp},{sbc,imm}, |
| 202 | | {cpx,aba},{sbc,aba},{inc,aba},{isc,aba}, |
| 203 | | {beq,rel},{sbc,idy},{kil,non},{isc,idy},/* f0 */ |
| 204 | | {dop,imm},{sbc,zpx},{inc,zpx},{isc,zpx}, |
| 205 | | {sed,imp},{sbc,aby},{nop,imp},{isc,aby}, |
| 206 | | {top,iw2},{sbc,abx},{inc,abx},{isc,abx} |
| 202 | {cpx,aba},{sbc,aba},{inc,aba},{isb,aba}, |
| 203 | {beq,rel},{sbc,idy},{kil,non},{isb,idy},/* f0 */ |
| 204 | {nop,zpx},{sbc,zpx},{inc,zpx},{isb,zpx}, |
| 205 | {sed,imp},{sbc,aby},{nop,imp},{isb,aby}, |
| 206 | {nop,abx},{sbc,abx},{inc,abx},{isb,abx} |
| 207 | 207 | }; |
| 208 | 208 | |
| 209 | 209 | static const struct op6502_info op65c02[256] = { |
src/emu/cpu/nec/nec.c
| r3514 | r3515 | |
| 167 | 167 | |
| 168 | 168 | const nec_config *config; |
| 169 | 169 | |
| 170 | UINT8 prefetch_size; |
| 171 | UINT8 prefetch_cycles; |
| 172 | INT8 prefetch_count; |
| 173 | UINT8 prefetch_reset; |
| 174 | UINT32 chip_type; |
| 170 | 175 | |
| 176 | UINT32 prefix_base; /* base address of the latest prefix segment */ |
| 177 | UINT8 seg_prefix; /* prefix segment indicator */ |
| 178 | |
| 171 | 179 | } nec_Regs; |
| 172 | 180 | |
| 173 | 181 | /***************************************************************************/ |
| r3514 | r3515 | |
| 178 | 186 | |
| 179 | 187 | static nec_Regs I; |
| 180 | 188 | |
| 181 | | static UINT32 chip_type; |
| 182 | | static UINT32 prefix_base; /* base address of the latest prefix segment */ |
| 183 | | static char seg_prefix; /* prefix segment indicator */ |
| 184 | 189 | |
| 185 | 190 | |
| 186 | 191 | /* The interrupt number of a pending external interrupt pending NMI is 2. */ |
| r3514 | r3515 | |
| 189 | 194 | #define INT_IRQ 0x01 |
| 190 | 195 | #define NMI_IRQ 0x02 |
| 191 | 196 | |
| 197 | INLINE void prefetch(void) |
| 198 | { |
| 199 | I.prefetch_count--; |
| 200 | } |
| 201 | |
| 202 | static void do_prefetch(int previous_ICount) |
| 203 | { |
| 204 | int diff = previous_ICount - (int) nec_ICount; |
| 205 | |
| 206 | /* The implementation is not accurate, but comes close. |
| 207 | * It does not respect that the V30 will fetch two bytes |
| 208 | * at once directly, but instead uses only 2 cycles instead |
| 209 | * of 4. There are however only very few sources publicy |
| 210 | * available and they are vague. |
| 211 | */ |
| 212 | while (I.prefetch_count<0) |
| 213 | { |
| 214 | I.prefetch_count++; |
| 215 | if (diff>I.prefetch_cycles) |
| 216 | diff -= I.prefetch_cycles; |
| 217 | else |
| 218 | nec_ICount -= I.prefetch_cycles; |
| 219 | } |
| 220 | |
| 221 | if (I.prefetch_reset) |
| 222 | { |
| 223 | I.prefetch_count = 0; |
| 224 | I.prefetch_reset = 0; |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | while (diff>=I.prefetch_cycles && I.prefetch_count < I.prefetch_size) |
| 229 | { |
| 230 | diff -= I.prefetch_cycles; |
| 231 | I.prefetch_count++; |
| 232 | } |
| 233 | |
| 234 | } |
| 235 | |
| 236 | INLINE UINT8 fetch(void) |
| 237 | { |
| 238 | prefetch(); |
| 239 | return cpu_readop_arg(FETCH_XOR((I.sregs[PS]<<4)+I.ip++)); |
| 240 | } |
| 241 | |
| 242 | INLINE UINT16 fetchword(void) |
| 243 | { |
| 244 | UINT16 r = FETCH(); |
| 245 | r |= (FETCH()<<8); |
| 246 | return r; |
| 247 | } |
| 248 | |
| 192 | 249 | #include "necinstr.h" |
| 193 | 250 | #include "necea.h" |
| 194 | 251 | #include "necmodrm.h" |
| r3514 | r3515 | |
| 199 | 256 | |
| 200 | 257 | static UINT8 fetchop(void) |
| 201 | 258 | { |
| 202 | | UINT8 ret = cpu_readop( FETCH_XOR( ( I.sregs[PS]<<4)+I.ip++)); |
| 259 | UINT8 ret; |
| 203 | 260 | |
| 261 | prefetch(); |
| 262 | ret = cpu_readop( FETCH_XOR( ( I.sregs[PS]<<4)+I.ip++)); |
| 263 | |
| 204 | 264 | if (I.MF == 1) |
| 205 | 265 | if (I.config->v25v35_decryptiontable) |
| 206 | 266 | { |
| r3514 | r3515 | |
| 210 | 270 | } |
| 211 | 271 | |
| 212 | 272 | |
| 273 | |
| 213 | 274 | /***************************************************************************/ |
| 214 | 275 | |
| 215 | 276 | static void nec_reset (void) |
| 216 | 277 | { |
| 217 | | const nec_config *config; |
| 218 | 278 | unsigned int i,j,c; |
| 219 | 279 | static const BREGS reg_name[8]={ AL, CL, DL, BL, AH, CH, DH, BH }; |
| 220 | | int (*save_irqcallback)(int); |
| 221 | | memory_interface save_mem; |
| 222 | 280 | |
| 223 | | save_irqcallback = I.irq_callback; |
| 224 | | save_mem = I.mem; |
| 225 | | config = I.config; |
| 226 | | memset( &I, 0, sizeof(I) ); |
| 227 | | I.irq_callback = save_irqcallback; |
| 228 | | I.mem = save_mem; |
| 229 | | I.config = config; |
| 281 | memset( &I.regs.w, 0, sizeof(I.regs.w)); |
| 282 | memset( &I.sregs, 0, sizeof(I.sregs)); |
| 230 | 283 | |
| 284 | I.ip = 0; |
| 285 | I.TF = 0; |
| 286 | I.IF = 0; |
| 287 | I.DF = 0; |
| 288 | I.MF = 0; |
| 289 | I.SignVal = 0; |
| 290 | I.int_vector = 0; |
| 291 | I.pending_irq = 0; |
| 292 | I.nmi_state = 0; |
| 293 | I.irq_state = 0; |
| 294 | I.poll_state = 0; |
| 295 | I.AuxVal = 0; |
| 296 | I.OverVal = 0; |
| 297 | I.ZeroVal = 0; |
| 298 | I.CarryVal = 0; |
| 299 | I.ParityVal = 0; |
| 231 | 300 | |
| 301 | |
| 232 | 302 | I.sregs[PS] = 0xffff; |
| 233 | 303 | |
| 234 | 304 | CHANGE_PC; |
| r3514 | r3515 | |
| 336 | 406 | OP( 0x0d, i_or_axd16 ) { DEF_axd16; ORW; I.regs.w[AW]=dst; CLKS(4,4,2); } |
| 337 | 407 | OP( 0x0e, i_push_cs ) { PUSH(I.sregs[PS]); CLKS(12,8,3); } |
| 338 | 408 | OP( 0x0f, i_pre_nec ) { UINT32 ModRM, tmp, tmp2; |
| 339 | | switch (FETCH) { |
| 409 | switch (FETCH()) { |
| 340 | 410 | case 0x10 : BITOP_BYTE; CLKS(3,3,4); tmp2 = I.regs.b[CL] & 0x7; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */ |
| 341 | 411 | case 0x11 : BITOP_WORD; CLKS(3,3,4); tmp2 = I.regs.b[CL] & 0xf; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */ |
| 342 | 412 | case 0x12 : BITOP_BYTE; CLKS(5,5,4); tmp2 = I.regs.b[CL] & 0x7; tmp &= ~(1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Clr */ |
| r3514 | r3515 | |
| 346 | 416 | case 0x16 : BITOP_BYTE; CLKS(4,4,4); tmp2 = I.regs.b[CL] & 0x7; BIT_NOT; PutbackRMByte(ModRM,tmp); break; /* Not */ |
| 347 | 417 | case 0x17 : BITOP_WORD; CLKS(4,4,4); tmp2 = I.regs.b[CL] & 0xf; BIT_NOT; PutbackRMWord(ModRM,tmp); break; /* Not */ |
| 348 | 418 | |
| 349 | | case 0x18 : BITOP_BYTE; CLKS(4,4,4); tmp2 = (FETCH) & 0x7; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */ |
| 350 | | case 0x19 : BITOP_WORD; CLKS(4,4,4); tmp2 = (FETCH) & 0xf; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */ |
| 351 | | case 0x1a : BITOP_BYTE; CLKS(6,6,4); tmp2 = (FETCH) & 0x7; tmp &= ~(1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Clr */ |
| 352 | | case 0x1b : BITOP_WORD; CLKS(6,6,4); tmp2 = (FETCH) & 0xf; tmp &= ~(1<<tmp2); PutbackRMWord(ModRM,tmp); break; /* Clr */ |
| 353 | | case 0x1c : BITOP_BYTE; CLKS(5,5,4); tmp2 = (FETCH) & 0x7; tmp |= (1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Set */ |
| 354 | | case 0x1d : BITOP_WORD; CLKS(5,5,4); tmp2 = (FETCH) & 0xf; tmp |= (1<<tmp2); PutbackRMWord(ModRM,tmp); break; /* Set */ |
| 355 | | case 0x1e : BITOP_BYTE; CLKS(5,5,4); tmp2 = (FETCH) & 0x7; BIT_NOT; PutbackRMByte(ModRM,tmp); break; /* Not */ |
| 356 | | case 0x1f : BITOP_WORD; CLKS(5,5,4); tmp2 = (FETCH) & 0xf; BIT_NOT; PutbackRMWord(ModRM,tmp); break; /* Not */ |
| 419 | case 0x18 : BITOP_BYTE; CLKS(4,4,4); tmp2 = (FETCH()) & 0x7; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */ |
| 420 | case 0x19 : BITOP_WORD; CLKS(4,4,4); tmp2 = (FETCH()) & 0xf; I.ZeroVal = (tmp & (1<<tmp2)) ? 1 : 0; I.CarryVal=I.OverVal=0; break; /* Test */ |
| 421 | case 0x1a : BITOP_BYTE; CLKS(6,6,4); tmp2 = (FETCH()) & 0x7; tmp &= ~(1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Clr */ |
| 422 | case 0x1b : BITOP_WORD; CLKS(6,6,4); tmp2 = (FETCH()) & 0xf; tmp &= ~(1<<tmp2); PutbackRMWord(ModRM,tmp); break; /* Clr */ |
| 423 | case 0x1c : BITOP_BYTE; CLKS(5,5,4); tmp2 = (FETCH()) & 0x7; tmp |= (1<<tmp2); PutbackRMByte(ModRM,tmp); break; /* Set */ |
| 424 | case 0x1d : BITOP_WORD; CLKS(5,5,4); tmp2 = (FETCH()) & 0xf; tmp |= (1<<tmp2); PutbackRMWord(ModRM,tmp); break; /* Set */ |
| 425 | case 0x1e : BITOP_BYTE; CLKS(5,5,4); tmp2 = (FETCH()) & 0x7; BIT_NOT; PutbackRMByte(ModRM,tmp); break; /* Not */ |
| 426 | case 0x1f : BITOP_WORD; CLKS(5,5,4); tmp2 = (FETCH()) & 0xf; BIT_NOT; PutbackRMWord(ModRM,tmp); break; /* Not */ |
| 357 | 427 | |
| 358 | 428 | case 0x20 : ADD4S; CLKS(7,7,2); break; |
| 359 | 429 | case 0x22 : SUB4S; CLKS(7,7,2); break; |
| 360 | 430 | case 0x26 : CMP4S; CLKS(7,7,2); break; |
| 361 | | case 0x28 : ModRM = FETCH; tmp = GetRMByte(ModRM); tmp <<= 4; tmp |= I.regs.b[AL] & 0xf; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | ((tmp>>8)&0xf); tmp &= 0xff; PutbackRMByte(ModRM,tmp); CLKM(13,13,9,28,28,15); break; |
| 362 | | case 0x2a : ModRM = FETCH; tmp = GetRMByte(ModRM); tmp2 = (I.regs.b[AL] & 0xf)<<4; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | (tmp&0xf); tmp = tmp2 | (tmp>>4); PutbackRMByte(ModRM,tmp); CLKM(17,17,13,32,32,19); break; |
| 363 | | case 0x31 : ModRM = FETCH; ModRM=0; logerror("%06x: Unimplemented bitfield INS\n",activecpu_get_pc()); break; |
| 364 | | case 0x33 : ModRM = FETCH; ModRM=0; logerror("%06x: Unimplemented bitfield EXT\n",activecpu_get_pc()); break; |
| 431 | case 0x28 : ModRM = FETCH(); tmp = GetRMByte(ModRM); tmp <<= 4; tmp |= I.regs.b[AL] & 0xf; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | ((tmp>>8)&0xf); tmp &= 0xff; PutbackRMByte(ModRM,tmp); CLKM(13,13,9,28,28,15); break; |
| 432 | case 0x2a : ModRM = FETCH(); tmp = GetRMByte(ModRM); tmp2 = (I.regs.b[AL] & 0xf)<<4; I.regs.b[AL] = (I.regs.b[AL] & 0xf0) | (tmp&0xf); tmp = tmp2 | (tmp>>4); PutbackRMByte(ModRM,tmp); CLKM(17,17,13,32,32,19); break; |
| 433 | case 0x31 : ModRM = FETCH(); ModRM=0; logerror("%06x: Unimplemented bitfield INS\n",activecpu_get_pc()); break; |
| 434 | case 0x33 : ModRM = FETCH(); ModRM=0; logerror("%06x: Unimplemented bitfield EXT\n",activecpu_get_pc()); break; |
| 365 | 435 | case 0x92 : CLK(2); break; /* V25/35 FINT */ |
| 366 | | case 0xe0 : ModRM = FETCH; ModRM=0; logerror("%06x: V33 unimplemented BRKXA (break to expansion address)\n",activecpu_get_pc()); break; |
| 367 | | case 0xf0 : ModRM = FETCH; ModRM=0; logerror("%06x: V33 unimplemented RETXA (return from expansion address)\n",activecpu_get_pc()); break; |
| 368 | | case 0xff : ModRM = FETCH; ModRM=0; logerror("%06x: unimplemented BRKEM (break to 8080 emulation mode)\n",activecpu_get_pc()); break; |
| 436 | case 0xe0 : ModRM = FETCH(); ModRM=0; logerror("%06x: V33 unimplemented BRKXA (break to expansion address)\n",activecpu_get_pc()); break; |
| 437 | case 0xf0 : ModRM = FETCH(); ModRM=0; logerror("%06x: V33 unimplemented RETXA (return from expansion address)\n",activecpu_get_pc()); break; |
| 438 | case 0xff : ModRM = FETCH(); ModRM=0; logerror("%06x: unimplemented BRKEM (break to 8080 emulation mode)\n",activecpu_get_pc()); break; |
| 369 | 439 | default: logerror("%06x: Unknown V20 instruction\n",activecpu_get_pc()); break; |
| 370 | 440 | } |
| 371 | 441 | } |
| r3514 | r3515 | |
| 394 | 464 | OP( 0x23, i_and_r16w ) { DEF_r16w; ANDW; RegWord(ModRM)=dst; CLKR(15,15,8,15,11,6,2,EA); } |
| 395 | 465 | OP( 0x24, i_and_ald8 ) { DEF_ald8; ANDB; I.regs.b[AL]=dst; CLKS(4,4,2); } |
| 396 | 466 | OP( 0x25, i_and_axd16) { DEF_axd16; ANDW; I.regs.w[AW]=dst; CLKS(4,4,2); } |
| 397 | | OP( 0x26, i_es ) { seg_prefix=TRUE; prefix_base=I.sregs[DS1]<<4; CLK(2); nec_instruction[fetchop()](); seg_prefix=FALSE; } |
| 467 | OP( 0x26, i_es ) { I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS1]<<4; CLK(2); nec_instruction[fetchop()](); I.seg_prefix=FALSE; } |
| 398 | 468 | OP( 0x27, i_daa ) { ADJ4(6,0x60); CLKS(3,3,2); } |
| 399 | 469 | |
| 400 | 470 | OP( 0x28, i_sub_br8 ) { DEF_br8; SUBB; PutbackRMByte(ModRM,dst); CLKM(2,2,2,16,16,7); } |
| r3514 | r3515 | |
| 403 | 473 | OP( 0x2b, i_sub_r16w ) { DEF_r16w; SUBW; RegWord(ModRM)=dst; CLKR(15,15,8,15,11,6,2,EA); } |
| 404 | 474 | OP( 0x2c, i_sub_ald8 ) { DEF_ald8; SUBB; I.regs.b[AL]=dst; CLKS(4,4,2); } |
| 405 | 475 | OP( 0x2d, i_sub_axd16) { DEF_axd16; SUBW; I.regs.w[AW]=dst; CLKS(4,4,2); } |
| 406 | | OP( 0x2e, i_cs ) { seg_prefix=TRUE; prefix_base=I.sregs[PS]<<4; CLK(2); nec_instruction[fetchop()](); seg_prefix=FALSE; } |
| 476 | OP( 0x2e, i_cs ) { I.seg_prefix=TRUE; I.prefix_base=I.sregs[PS]<<4; CLK(2); nec_instruction[fetchop()](); I.seg_prefix=FALSE; } |
| 407 | 477 | OP( 0x2f, i_das ) { ADJ4(-6,-0x60); CLKS(3,3,2); } |
| 408 | 478 | |
| 409 | 479 | OP( 0x30, i_xor_br8 ) { DEF_br8; XORB; PutbackRMByte(ModRM,dst); CLKM(2,2,2,16,16,7); } |
| r3514 | r3515 | |
| 412 | 482 | OP( 0x33, i_xor_r16w ) { DEF_r16w; XORW; RegWord(ModRM)=dst; CLKR(15,15,8,15,11,6,2,EA); } |
| 413 | 483 | OP( 0x34, i_xor_ald8 ) { DEF_ald8; XORB; I.regs.b[AL]=dst; CLKS(4,4,2); } |
| 414 | 484 | OP( 0x35, i_xor_axd16) { DEF_axd16; XORW; I.regs.w[AW]=dst; CLKS(4,4,2); } |
| 415 | | OP( 0x36, i_ss ) { seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; CLK(2); nec_instruction[fetchop()](); seg_prefix=FALSE; } |
| 485 | OP( 0x36, i_ss ) { I.seg_prefix=TRUE; I.prefix_base=I.sregs[SS]<<4; CLK(2); nec_instruction[fetchop()](); I.seg_prefix=FALSE; } |
| 416 | 486 | OP( 0x37, i_aaa ) { ADJB(6, (I.regs.b[AL] > 0xf9) ? 2 : 1); CLKS(7,7,4); } |
| 417 | 487 | |
| 418 | 488 | OP( 0x38, i_cmp_br8 ) { DEF_br8; SUBB; CLKM(2,2,2,11,11,6); } |
| r3514 | r3515 | |
| 421 | 491 | OP( 0x3b, i_cmp_r16w ) { DEF_r16w; SUBW; CLKR(15,15,8,15,11,6,2,EA); } |
| 422 | 492 | OP( 0x3c, i_cmp_ald8 ) { DEF_ald8; SUBB; CLKS(4,4,2); } |
| 423 | 493 | OP( 0x3d, i_cmp_axd16) { DEF_axd16; SUBW; CLKS(4,4,2); } |
| 424 | | OP( 0x3e, i_ds ) { seg_prefix=TRUE; prefix_base=I.sregs[DS0]<<4; CLK(2); nec_instruction[fetchop()](); seg_prefix=FALSE; } |
| 494 | OP( 0x3e, i_ds ) { I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS0]<<4; CLK(2); nec_instruction[fetchop()](); I.seg_prefix=FALSE; } |
| 425 | 495 | OP( 0x3f, i_aas ) { ADJB(-6, (I.regs.b[AL] < 6) ? -2 : -1); CLKS(7,7,4); } |
| 426 | 496 | |
| 427 | 497 | OP( 0x40, i_inc_ax ) { IncWordReg(AW); CLK(2); } |
| r3514 | r3515 | |
| 496 | 566 | nec_ICount-=20; |
| 497 | 567 | logerror("%06x: bound %04x high %04x low %04x tmp\n",activecpu_get_pc(),high,low,tmp); |
| 498 | 568 | } |
| 499 | | OP( 0x63, i_brkn ) { nec_interrupt(FETCH,1); CLKS(50,50,24); } // timing not verified, used by riskchal / gussun |
| 569 | OP( 0x63, i_brkn ) { nec_interrupt(FETCH(),1); CLKS(50,50,24); } // timing not verified, used by riskchal / gussun |
| 500 | 570 | OP( 0x64, i_repnc ) { UINT32 next = fetchop(); UINT16 c = I.regs.w[CW]; |
| 501 | 571 | switch(next) { /* Segments */ |
| 502 | | case 0x26: seg_prefix=TRUE; prefix_base=I.sregs[DS1]<<4; next = fetchop(); CLK(2); break; |
| 503 | | case 0x2e: seg_prefix=TRUE; prefix_base=I.sregs[PS]<<4; next = fetchop(); CLK(2); break; |
| 504 | | case 0x36: seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; next = fetchop(); CLK(2); break; |
| 505 | | case 0x3e: seg_prefix=TRUE; prefix_base=I.sregs[DS0]<<4; next = fetchop(); CLK(2); break; |
| 572 | case 0x26: I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS1]<<4; next = fetchop(); CLK(2); break; |
| 573 | case 0x2e: I.seg_prefix=TRUE; I.prefix_base=I.sregs[PS]<<4; next = fetchop(); CLK(2); break; |
| 574 | case 0x36: I.seg_prefix=TRUE; I.prefix_base=I.sregs[SS]<<4; next = fetchop(); CLK(2); break; |
| 575 | case 0x3e: I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS0]<<4; next = fetchop(); CLK(2); break; |
| 506 | 576 | } |
| 507 | 577 | |
| 508 | 578 | switch(next) { |
| r3514 | r3515 | |
| 522 | 592 | case 0xaf: CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && !CF); I.regs.w[CW]=c; break; |
| 523 | 593 | default: logerror("%06x: REPNC invalid\n",activecpu_get_pc()); nec_instruction[next](); |
| 524 | 594 | } |
| 525 | | seg_prefix=FALSE; |
| 595 | I.seg_prefix=FALSE; |
| 526 | 596 | } |
| 527 | 597 | |
| 528 | 598 | OP( 0x65, i_repc ) { UINT32 next = fetchop(); UINT16 c = I.regs.w[CW]; |
| 529 | 599 | switch(next) { /* Segments */ |
| 530 | | case 0x26: seg_prefix=TRUE; prefix_base=I.sregs[DS1]<<4; next = fetchop(); CLK(2); break; |
| 531 | | case 0x2e: seg_prefix=TRUE; prefix_base=I.sregs[PS]<<4; next = fetchop(); CLK(2); break; |
| 532 | | case 0x36: seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; next = fetchop(); CLK(2); break; |
| 533 | | case 0x3e: seg_prefix=TRUE; prefix_base=I.sregs[DS0]<<4; next = fetchop(); CLK(2); break; |
| 600 | case 0x26: I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS1]<<4; next = fetchop(); CLK(2); break; |
| 601 | case 0x2e: I.seg_prefix=TRUE; I.prefix_base=I.sregs[PS]<<4; next = fetchop(); CLK(2); break; |
| 602 | case 0x36: I.seg_prefix=TRUE; I.prefix_base=I.sregs[SS]<<4; next = fetchop(); CLK(2); break; |
| 603 | case 0x3e: I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS0]<<4; next = fetchop(); CLK(2); break; |
| 534 | 604 | } |
| 535 | 605 | |
| 536 | 606 | switch(next) { |
| r3514 | r3515 | |
| 550 | 620 | case 0xaf: CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && CF); I.regs.w[CW]=c; break; |
| 551 | 621 | default: logerror("%06x: REPC invalid\n",activecpu_get_pc()); nec_instruction[next](); |
| 552 | 622 | } |
| 553 | | seg_prefix=FALSE; |
| 623 | I.seg_prefix=FALSE; |
| 554 | 624 | } |
| 555 | 625 | |
| 556 | | OP( 0x68, i_push_d16 ) { UINT32 tmp; FETCHWORD(tmp); PUSH(tmp); CLKW(12,12,5,12,8,5,I.regs.w[SP]); } |
| 557 | | OP( 0x69, i_imul_d16 ) { UINT32 tmp; DEF_r16w; FETCHWORD(tmp); dst = (INT32)((INT16)src)*(INT32)((INT16)tmp); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1); RegWord(ModRM)=(WORD)dst; nec_ICount-=(ModRM >=0xc0 )?38:47;} |
| 558 | | OP( 0x6a, i_push_d8 ) { UINT32 tmp = (WORD)((INT16)((INT8)FETCH)); PUSH(tmp); CLKW(11,11,5,11,7,3,I.regs.w[SP]); } |
| 559 | | OP( 0x6b, i_imul_d8 ) { UINT32 src2; DEF_r16w; src2= (WORD)((INT16)((INT8)FETCH)); dst = (INT32)((INT16)src)*(INT32)((INT16)src2); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1); RegWord(ModRM)=(WORD)dst; nec_ICount-=(ModRM >=0xc0 )?31:39; } |
| 626 | OP( 0x68, i_push_d16 ) { UINT32 tmp; tmp = FETCHWORD(); PUSH(tmp); CLKW(12,12,5,12,8,5,I.regs.w[SP]); } |
| 627 | OP( 0x69, i_imul_d16 ) { UINT32 tmp; DEF_r16w; tmp = FETCHWORD(); dst = (INT32)((INT16)src)*(INT32)((INT16)tmp); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1); RegWord(ModRM)=(WORD)dst; nec_ICount-=(ModRM >=0xc0 )?38:47;} |
| 628 | OP( 0x6a, i_push_d8 ) { UINT32 tmp = (WORD)((INT16)((INT8)FETCH())); PUSH(tmp); CLKW(11,11,5,11,7,3,I.regs.w[SP]); } |
| 629 | OP( 0x6b, i_imul_d8 ) { UINT32 src2; DEF_r16w; src2= (WORD)((INT16)((INT8)FETCH())); dst = (INT32)((INT16)src)*(INT32)((INT16)src2); I.CarryVal = I.OverVal = (((INT32)dst) >> 15 != 0) && (((INT32)dst) >> 15 != -1); RegWord(ModRM)=(WORD)dst; nec_ICount-=(ModRM >=0xc0 )?31:39; } |
| 560 | 630 | OP( 0x6c, i_insb ) { PutMemB(DS1,I.regs.w[IY],read_port_byte(I.regs.w[DW])); I.regs.w[IY]+= -2 * I.DF + 1; CLK(8); } |
| 561 | 631 | OP( 0x6d, i_insw ) { PutMemW(DS1,I.regs.w[IY],read_port_word(I.regs.w[DW])); I.regs.w[IY]+= -4 * I.DF + 2; CLKS(18,10,8); } |
| 562 | 632 | OP( 0x6e, i_outsb ) { write_port_byte(I.regs.w[DW],GetMemB(DS0,I.regs.w[IX])); I.regs.w[IX]+= -2 * I.DF + 1; CLK(8); } |
| r3514 | r3515 | |
| 579 | 649 | OP( 0x7e, i_jle ) { JMP((ZF)||(SF!=OF)); CLKS(4,4,3); } |
| 580 | 650 | OP( 0x7f, i_jnle ) { JMP((SF==OF)&&(!ZF)); CLKS(4,4,3); } |
| 581 | 651 | |
| 582 | | OP( 0x80, i_80pre ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = FETCH; |
| 652 | OP( 0x80, i_80pre ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = FETCH(); |
| 583 | 653 | if (ModRM >=0xc0 ) CLKS(4,4,2) else if ((ModRM & 0x38)==0x38) CLKS(13,13,6) else CLKS(18,18,7) |
| 584 | 654 | switch (ModRM & 0x38) { |
| 585 | 655 | case 0x00: ADDB; PutbackRMByte(ModRM,dst); break; |
| r3514 | r3515 | |
| 593 | 663 | } |
| 594 | 664 | } |
| 595 | 665 | |
| 596 | | OP( 0x81, i_81pre ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = FETCH; src+= (FETCH << 8); |
| 666 | OP( 0x81, i_81pre ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = FETCH(); src+= (FETCH() << 8); |
| 597 | 667 | if (ModRM >=0xc0 ) CLKS(4,4,2) else if ((ModRM & 0x38)==0x38) CLKW(17,17,8,17,13,6,EA) else CLKW(26,26,11,26,18,7,EA) |
| 598 | 668 | switch (ModRM & 0x38) { |
| 599 | 669 | case 0x00: ADDW; PutbackRMWord(ModRM,dst); break; |
| r3514 | r3515 | |
| 607 | 677 | } |
| 608 | 678 | } |
| 609 | 679 | |
| 610 | | OP( 0x82, i_82pre ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = (BYTE)((INT8)FETCH); |
| 680 | OP( 0x82, i_82pre ) { UINT32 dst, src; GetModRM; dst = GetRMByte(ModRM); src = (BYTE)((INT8)FETCH()); |
| 611 | 681 | if (ModRM >=0xc0 ) CLKS(4,4,2) else if ((ModRM & 0x38)==0x38) CLKS(13,13,6) else CLKS(18,18,7) |
| 612 | 682 | switch (ModRM & 0x38) { |
| 613 | 683 | case 0x00: ADDB; PutbackRMByte(ModRM,dst); break; |
| r3514 | r3515 | |
| 621 | 691 | } |
| 622 | 692 | } |
| 623 | 693 | |
| 624 | | OP( 0x83, i_83pre ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = (WORD)((INT16)((INT8)FETCH)); |
| 694 | OP( 0x83, i_83pre ) { UINT32 dst, src; GetModRM; dst = GetRMWord(ModRM); src = (WORD)((INT16)((INT8)FETCH())); |
| 625 | 695 | if (ModRM >=0xc0 ) CLKS(4,4,2) else if ((ModRM & 0x38)==0x38) CLKW(17,17,8,17,13,6,EA) else CLKW(26,26,11,26,18,7,EA) |
| 626 | 696 | switch (ModRM & 0x38) { |
| 627 | 697 | case 0x00: ADDW; PutbackRMWord(ModRM,dst); break; |
| r3514 | r3515 | |
| 645 | 715 | OP( 0x8a, i_mov_r8b ) { UINT8 src; GetModRM; src = GetRMByte(ModRM); RegByte(ModRM)=src; CLKM(2,2,2,11,11,5); } |
| 646 | 716 | OP( 0x8b, i_mov_r16w ) { UINT16 src; GetModRM; src = GetRMWord(ModRM); RegWord(ModRM)=src; CLKR(15,15,7,15,11,5,2,EA); } |
| 647 | 717 | OP( 0x8c, i_mov_wsreg ) { GetModRM; PutRMWord(ModRM,I.sregs[(ModRM & 0x38) >> 3]); CLKR(14,14,5,14,10,3,2,EA); } |
| 648 | | OP( 0x8d, i_lea ) { UINT16 ModRM = FETCH; (void)(*GetEA[ModRM])(); RegWord(ModRM)=EO; CLKS(4,4,2); } |
| 718 | OP( 0x8d, i_lea ) { UINT16 ModRM = FETCH(); (void)(*GetEA[ModRM])(); RegWord(ModRM)=EO; CLKS(4,4,2); } |
| 649 | 719 | OP( 0x8e, i_mov_sregw ) { UINT16 src; GetModRM; src = GetRMWord(ModRM); CLKR(15,15,7,15,11,5,2,EA); |
| 650 | 720 | switch (ModRM & 0x38) { |
| 651 | 721 | case 0x00: I.sregs[DS1] = src; break; /* mov es,ew */ |
| r3514 | r3515 | |
| 657 | 727 | I.no_interrupt=1; |
| 658 | 728 | } |
| 659 | 729 | OP( 0x8f, i_popw ) { UINT16 tmp; GetModRM; POP(tmp); PutRMWord(ModRM,tmp); nec_ICount-=21; } |
| 660 | | OP( 0x90, i_nop ) { CLK(3); |
| 661 | | /* Cycle skip for idle loops (0: NOP 1: JMP 0) */ |
| 662 | | if (I.no_interrupt==0 && nec_ICount>0 && (I.pending_irq==0) && (PEEKOP((I.sregs[PS]<<4)+I.ip))==0xeb && (PEEK((I.sregs[PS]<<4)+I.ip+1))==0xfd) |
| 663 | | nec_ICount%=15; |
| 664 | | } |
| 730 | OP( 0x90, i_nop ) { CLK(3); } |
| 665 | 731 | OP( 0x91, i_xchg_axcx ) { XchgAWReg(CW); CLK(3); } |
| 666 | 732 | OP( 0x92, i_xchg_axdx ) { XchgAWReg(DW); CLK(3); } |
| 667 | 733 | OP( 0x93, i_xchg_axbx ) { XchgAWReg(BW); CLK(3); } |
| r3514 | r3515 | |
| 672 | 738 | |
| 673 | 739 | OP( 0x98, i_cbw ) { I.regs.b[AH] = (I.regs.b[AL] & 0x80) ? 0xff : 0; CLK(2); } |
| 674 | 740 | OP( 0x99, i_cwd ) { I.regs.w[DW] = (I.regs.b[AH] & 0x80) ? 0xffff : 0; CLK(4); } |
| 675 | | OP( 0x9a, i_call_far ) { UINT32 tmp, tmp2; FETCHWORD(tmp); FETCHWORD(tmp2); PUSH(I.sregs[PS]); PUSH(I.ip); I.ip = (WORD)tmp; I.sregs[PS] = (WORD)tmp2; CHANGE_PC; CLKW(29,29,13,29,21,9,I.regs.w[SP]); } |
| 741 | OP( 0x9a, i_call_far ) { UINT32 tmp, tmp2; tmp = FETCHWORD(); tmp2 = FETCHWORD(); PUSH(I.sregs[PS]); PUSH(I.ip); I.ip = (WORD)tmp; I.sregs[PS] = (WORD)tmp2; CHANGE_PC; CLKW(29,29,13,29,21,9,I.regs.w[SP]); } |
| 676 | 742 | OP( 0x9b, i_wait ) { if (!I.poll_state) I.ip--; CLK(5); } |
| 677 | 743 | OP( 0x9c, i_pushf ) { UINT16 tmp = CompressFlags(); PUSH( tmp ); CLKS(12,8,3); } |
| 678 | 744 | OP( 0x9d, i_popf ) { UINT32 tmp; POP(tmp); ExpandFlags(tmp); CLKS(12,8,5); if (I.TF) nec_trap(); } |
| 679 | 745 | OP( 0x9e, i_sahf ) { UINT32 tmp = (CompressFlags() & 0xff00) | (I.regs.b[AH] & 0xd5); ExpandFlags(tmp); CLKS(3,3,2); } |
| 680 | 746 | OP( 0x9f, i_lahf ) { I.regs.b[AH] = CompressFlags() & 0xff; CLKS(3,3,2); } |
| 681 | 747 | |
| 682 | | OP( 0xa0, i_mov_aldisp ) { UINT32 addr; FETCHWORD(addr); I.regs.b[AL] = GetMemB(DS0, addr); CLKS(10,10,5); } |
| 683 | | OP( 0xa1, i_mov_axdisp ) { UINT32 addr; FETCHWORD(addr); I.regs.w[AW] = GetMemW(DS0, addr); CLKW(14,14,7,14,10,5,addr); } |
| 684 | | OP( 0xa2, i_mov_dispal ) { UINT32 addr; FETCHWORD(addr); PutMemB(DS0, addr, I.regs.b[AL]); CLKS(9,9,3); } |
| 685 | | OP( 0xa3, i_mov_dispax ) { UINT32 addr; FETCHWORD(addr); PutMemW(DS0, addr, I.regs.w[AW]); CLKW(13,13,5,13,9,3,addr); } |
| 748 | OP( 0xa0, i_mov_aldisp ) { UINT32 addr; addr = FETCHWORD(); I.regs.b[AL] = GetMemB(DS0, addr); CLKS(10,10,5); } |
| 749 | OP( 0xa1, i_mov_axdisp ) { UINT32 addr; addr = FETCHWORD(); I.regs.w[AW] = GetMemW(DS0, addr); CLKW(14,14,7,14,10,5,addr); } |
| 750 | OP( 0xa2, i_mov_dispal ) { UINT32 addr; addr = FETCHWORD(); PutMemB(DS0, addr, I.regs.b[AL]); CLKS(9,9,3); } |
| 751 | OP( 0xa3, i_mov_dispax ) { UINT32 addr; addr = FETCHWORD(); PutMemW(DS0, addr, I.regs.w[AW]); CLKW(13,13,5,13,9,3,addr); } |
| 686 | 752 | OP( 0xa4, i_movsb ) { UINT32 tmp = GetMemB(DS0,I.regs.w[IX]); PutMemB(DS1,I.regs.w[IY], tmp); I.regs.w[IY] += -2 * I.DF + 1; I.regs.w[IX] += -2 * I.DF + 1; CLKS(8,8,6); } |
| 687 | 753 | OP( 0xa5, i_movsw ) { UINT32 tmp = GetMemW(DS0,I.regs.w[IX]); PutMemW(DS1,I.regs.w[IY], tmp); I.regs.w[IY] += -4 * I.DF + 2; I.regs.w[IX] += -4 * I.DF + 2; CLKS(16,16,10); } |
| 688 | 754 | OP( 0xa6, i_cmpsb ) { UINT32 src = GetMemB(DS1, I.regs.w[IY]); UINT32 dst = GetMemB(DS0, I.regs.w[IX]); SUBB; I.regs.w[IY] += -2 * I.DF + 1; I.regs.w[IX] += -2 * I.DF + 1; CLKS(14,14,14); } |
| r3514 | r3515 | |
| 697 | 763 | OP( 0xae, i_scasb ) { UINT32 src = GetMemB(DS1, I.regs.w[IY]); UINT32 dst = I.regs.b[AL]; SUBB; I.regs.w[IY] += -2 * I.DF + 1; CLKS(4,4,3); } |
| 698 | 764 | OP( 0xaf, i_scasw ) { UINT32 src = GetMemW(DS1, I.regs.w[IY]); UINT32 dst = I.regs.w[AW]; SUBW; I.regs.w[IY] += -4 * I.DF + 2; CLKW(8,8,5,8,4,3,I.regs.w[IY]); } |
| 699 | 765 | |
| 700 | | OP( 0xb0, i_mov_ald8 ) { I.regs.b[AL] = FETCH; CLKS(4,4,2); } |
| 701 | | OP( 0xb1, i_mov_cld8 ) { I.regs.b[CL] = FETCH; CLKS(4,4,2); } |
| 702 | | OP( 0xb2, i_mov_dld8 ) { I.regs.b[DL] = FETCH; CLKS(4,4,2); } |
| 703 | | OP( 0xb3, i_mov_bld8 ) { I.regs.b[BL] = FETCH; CLKS(4,4,2); } |
| 704 | | OP( 0xb4, i_mov_ahd8 ) { I.regs.b[AH] = FETCH; CLKS(4,4,2); } |
| 705 | | OP( 0xb5, i_mov_chd8 ) { I.regs.b[CH] = FETCH; CLKS(4,4,2); } |
| 706 | | OP( 0xb6, i_mov_dhd8 ) { I.regs.b[DH] = FETCH; CLKS(4,4,2); } |
| 707 | | OP( 0xb7, i_mov_bhd8 ) { I.regs.b[BH] = FETCH; CLKS(4,4,2); } |
| 766 | OP( 0xb0, i_mov_ald8 ) { I.regs.b[AL] = FETCH(); CLKS(4,4,2); } |
| 767 | OP( 0xb1, i_mov_cld8 ) { I.regs.b[CL] = FETCH(); CLKS(4,4,2); } |
| 768 | OP( 0xb2, i_mov_dld8 ) { I.regs.b[DL] = FETCH(); CLKS(4,4,2); } |
| 769 | OP( 0xb3, i_mov_bld8 ) { I.regs.b[BL] = FETCH(); CLKS(4,4,2); } |
| 770 | OP( 0xb4, i_mov_ahd8 ) { I.regs.b[AH] = FETCH(); CLKS(4,4,2); } |
| 771 | OP( 0xb5, i_mov_chd8 ) { I.regs.b[CH] = FETCH(); CLKS(4,4,2); } |
| 772 | OP( 0xb6, i_mov_dhd8 ) { I.regs.b[DH] = FETCH(); CLKS(4,4,2); } |
| 773 | OP( 0xb7, i_mov_bhd8 ) { I.regs.b[BH] = FETCH(); CLKS(4,4,2); } |
| 708 | 774 | |
| 709 | | OP( 0xb8, i_mov_axd16 ) { I.regs.b[AL] = FETCH; I.regs.b[AH] = FETCH; CLKS(4,4,2); } |
| 710 | | OP( 0xb9, i_mov_cxd16 ) { I.regs.b[CL] = FETCH; I.regs.b[CH] = FETCH; CLKS(4,4,2); } |
| 711 | | OP( 0xba, i_mov_dxd16 ) { I.regs.b[DL] = FETCH; I.regs.b[DH] = FETCH; CLKS(4,4,2); } |
| 712 | | OP( 0xbb, i_mov_bxd16 ) { I.regs.b[BL] = FETCH; I.regs.b[BH] = FETCH; CLKS(4,4,2); } |
| 713 | | OP( 0xbc, i_mov_spd16 ) { I.regs.b[SPL] = FETCH; I.regs.b[SPH] = FETCH; CLKS(4,4,2); } |
| 714 | | OP( 0xbd, i_mov_bpd16 ) { I.regs.b[BPL] = FETCH; I.regs.b[BPH] = FETCH; CLKS(4,4,2); } |
| 715 | | OP( 0xbe, i_mov_sid16 ) { I.regs.b[IXL] = FETCH; I.regs.b[IXH] = FETCH; CLKS(4,4,2); } |
| 716 | | OP( 0xbf, i_mov_did16 ) { I.regs.b[IYL] = FETCH; I.regs.b[IYH] = FETCH; CLKS(4,4,2); } |
| 775 | OP( 0xb8, i_mov_axd16 ) { I.regs.b[AL] = FETCH(); I.regs.b[AH] = FETCH(); CLKS(4,4,2); } |
| 776 | OP( 0xb9, i_mov_cxd16 ) { I.regs.b[CL] = FETCH(); I.regs.b[CH] = FETCH(); CLKS(4,4,2); } |
| 777 | OP( 0xba, i_mov_dxd16 ) { I.regs.b[DL] = FETCH(); I.regs.b[DH] = FETCH(); CLKS(4,4,2); } |
| 778 | OP( 0xbb, i_mov_bxd16 ) { I.regs.b[BL] = FETCH(); I.regs.b[BH] = FETCH(); CLKS(4,4,2); } |
| 779 | OP( 0xbc, i_mov_spd16 ) { I.regs.b[SPL] = FETCH(); I.regs.b[SPH] = FETCH(); CLKS(4,4,2); } |
| 780 | OP( 0xbd, i_mov_bpd16 ) { I.regs.b[BPL] = FETCH(); I.regs.b[BPH] = FETCH(); CLKS(4,4,2); } |
| 781 | OP( 0xbe, i_mov_sid16 ) { I.regs.b[IXL] = FETCH(); I.regs.b[IXH] = FETCH(); CLKS(4,4,2); } |
| 782 | OP( 0xbf, i_mov_did16 ) { I.regs.b[IYL] = FETCH(); I.regs.b[IYH] = FETCH(); CLKS(4,4,2); } |
| 717 | 783 | |
| 718 | 784 | OP( 0xc0, i_rotshft_bd8 ) { |
| 719 | 785 | UINT32 src, dst; UINT8 c; |
| 720 | 786 | GetModRM; src = (unsigned)GetRMByte(ModRM); dst=src; |
| 721 | | c=FETCH; |
| 787 | c=FETCH(); |
| 722 | 788 | CLKM(7,7,2,19,19,6); |
| 723 | 789 | if (c) switch (ModRM & 0x38) { |
| 724 | 790 | case 0x00: do { ROL_BYTE; c--; CLK(1); } while (c>0); PutbackRMByte(ModRM,(BYTE)dst); break; |
| r3514 | r3515 | |
| 735 | 801 | OP( 0xc1, i_rotshft_wd8 ) { |
| 736 | 802 | UINT32 src, dst; UINT8 c; |
| 737 | 803 | GetModRM; src = (unsigned)GetRMWord(ModRM); dst=src; |
| 738 | | c=FETCH; |
| 804 | c=FETCH(); |
| 739 | 805 | CLKM(7,7,2,27,19,6); |
| 740 | 806 | if (c) switch (ModRM & 0x38) { |
| 741 | 807 | case 0x00: do { ROL_WORD; c--; CLK(1); } while (c>0); PutbackRMWord(ModRM,(WORD)dst); break; |
| r3514 | r3515 | |
| 749 | 815 | } |
| 750 | 816 | } |
| 751 | 817 | |
| 752 | | OP( 0xc2, i_ret_d16 ) { UINT32 count = FETCH; count += FETCH << 8; POP(I.ip); I.regs.w[SP]+=count; CHANGE_PC; CLKS(24,24,10); } |
| 818 | OP( 0xc2, i_ret_d16 ) { UINT32 count = FETCH(); count += FETCH() << 8; POP(I.ip); I.regs.w[SP]+=count; CHANGE_PC; CLKS(24,24,10); } |
| 753 | 819 | OP( 0xc3, i_ret ) { POP(I.ip); CHANGE_PC; CLKS(19,19,10); } |
| 754 | 820 | OP( 0xc4, i_les_dw ) { GetModRM; WORD tmp = GetRMWord(ModRM); RegWord(ModRM)=tmp; I.sregs[DS1] = GetnextRMWord; CLKW(26,26,14,26,18,10,EA); } |
| 755 | 821 | OP( 0xc5, i_lds_dw ) { GetModRM; WORD tmp = GetRMWord(ModRM); RegWord(ModRM)=tmp; I.sregs[DS0] = GetnextRMWord; CLKW(26,26,14,26,18,10,EA); } |
| r3514 | r3515 | |
| 757 | 823 | OP( 0xc7, i_mov_wd16 ) { GetModRM; PutImmRMWord(ModRM); nec_ICount-=(ModRM >=0xc0 )?4:15; } |
| 758 | 824 | |
| 759 | 825 | OP( 0xc8, i_enter ) { |
| 760 | | UINT32 nb = FETCH; |
| 826 | UINT32 nb = FETCH(); |
| 761 | 827 | UINT32 i,level; |
| 762 | 828 | |
| 763 | 829 | nec_ICount-=23; |
| 764 | | nb += FETCH << 8; |
| 765 | | level = FETCH; |
| 830 | nb += FETCH() << 8; |
| 831 | level = FETCH(); |
| 766 | 832 | PUSH(I.regs.w[BP]); |
| 767 | 833 | I.regs.w[BP]=I.regs.w[SP]; |
| 768 | 834 | I.regs.w[SP] -= nb; |
| r3514 | r3515 | |
| 777 | 843 | POP(I.regs.w[BP]); |
| 778 | 844 | nec_ICount-=8; |
| 779 | 845 | } |
| 780 | | OP( 0xca, i_retf_d16 ) { UINT32 count = FETCH; count += FETCH << 8; POP(I.ip); POP(I.sregs[PS]); I.regs.w[SP]+=count; CHANGE_PC; CLKS(32,32,16); } |
| 846 | OP( 0xca, i_retf_d16 ) { UINT32 count = FETCH(); count += FETCH() << 8; POP(I.ip); POP(I.sregs[PS]); I.regs.w[SP]+=count; CHANGE_PC; CLKS(32,32,16); } |
| 781 | 847 | OP( 0xcb, i_retf ) { POP(I.ip); POP(I.sregs[PS]); CHANGE_PC; CLKS(29,29,16); } |
| 782 | 848 | OP( 0xcc, i_int3 ) { nec_interrupt(3,0); CLKS(50,50,24); } |
| 783 | | OP( 0xcd, i_int ) { nec_interrupt(FETCH,0); CLKS(50,50,24); } |
| 849 | OP( 0xcd, i_int ) { nec_interrupt(FETCH(),0); CLKS(50,50,24); } |
| 784 | 850 | OP( 0xce, i_into ) { if (OF) { nec_interrupt(4,0); CLKS(52,52,26); } else CLK(3); } |
| 785 | 851 | OP( 0xcf, i_iret ) { POP(I.ip); POP(I.sregs[PS]); i_popf(); SetMD(1); CHANGE_PC; CLKS(39,39,19); } |
| 786 | 852 | |
| r3514 | r3515 | |
| 846 | 912 | } |
| 847 | 913 | } |
| 848 | 914 | |
| 849 | | OP( 0xd4, i_aam ) { UINT32 mult=FETCH; mult=0; I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLKS(15,15,12); } |
| 850 | | OP( 0xd5, i_aad ) { UINT32 mult=FETCH; mult=0; I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLKS(7,7,8); } |
| 915 | OP( 0xd4, i_aam ) { UINT32 mult=FETCH(); mult=0; I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLKS(15,15,12); } |
| 916 | OP( 0xd5, i_aad ) { UINT32 mult=FETCH(); mult=0; I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLKS(7,7,8); } |
| 851 | 917 | OP( 0xd6, i_setalc ) { I.regs.b[AL] = (CF)?0xff:0x00; nec_ICount-=3; logerror("%06x: Undefined opcode (SETALC)\n",activecpu_get_pc()); } |
| 852 | 918 | OP( 0xd7, i_trans ) { UINT32 dest = (I.regs.w[BW]+I.regs.b[AL])&0xffff; I.regs.b[AL] = GetMemB(DS0, dest); CLKS(9,9,5); } |
| 853 | 919 | OP( 0xd8, i_fpo ) { GetModRM; nec_ICount-=2; logerror("%06x: Unimplemented floating point control %04x\n",activecpu_get_pc(),ModRM); } |
| 854 | 920 | |
| 855 | | OP( 0xe0, i_loopne ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if (!ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(14,14,6); } else CLKS(5,5,3); } |
| 856 | | OP( 0xe1, i_loope ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if ( ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(14,14,6); } else CLKS(5,5,3); } |
| 857 | | OP( 0xe2, i_loop ) { INT8 disp = (INT8)FETCH; I.regs.w[CW]--; if (I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(13,13,6); } else CLKS(5,5,3); } |
| 858 | | OP( 0xe3, i_jcxz ) { INT8 disp = (INT8)FETCH; if (I.regs.w[CW] == 0) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(13,13,6); } else CLKS(5,5,3); } |
| 859 | | OP( 0xe4, i_inal ) { UINT8 port = FETCH; I.regs.b[AL] = read_port_byte(port); CLKS(9,9,5); } |
| 860 | | OP( 0xe5, i_inax ) { UINT8 port = FETCH; I.regs.w[AW] = read_port_word(port); CLKW(13,13,7,13,9,5,port); } |
| 861 | | OP( 0xe6, i_outal ) { UINT8 port = FETCH; write_port_byte(port, I.regs.b[AL]); CLKS(8,8,3); } |
| 862 | | OP( 0xe7, i_outax ) { UINT8 port = FETCH; write_port_word(port, I.regs.w[AW]); CLKW(12,12,5,12,8,3,port); } |
| 921 | OP( 0xe0, i_loopne ) { INT8 disp = (INT8)FETCH(); I.regs.w[CW]--; if (!ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(14,14,6); } else CLKS(5,5,3); } |
| 922 | OP( 0xe1, i_loope ) { INT8 disp = (INT8)FETCH(); I.regs.w[CW]--; if ( ZF && I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(14,14,6); } else CLKS(5,5,3); } |
| 923 | OP( 0xe2, i_loop ) { INT8 disp = (INT8)FETCH(); I.regs.w[CW]--; if (I.regs.w[CW]) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(13,13,6); } else CLKS(5,5,3); } |
| 924 | OP( 0xe3, i_jcxz ) { INT8 disp = (INT8)FETCH(); if (I.regs.w[CW] == 0) { I.ip = (WORD)(I.ip+disp); /*CHANGE_PC;*/ CLKS(13,13,6); } else CLKS(5,5,3); } |
| 925 | OP( 0xe4, i_inal ) { UINT8 port = FETCH(); I.regs.b[AL] = read_port_byte(port); CLKS(9,9,5); } |
| 926 | OP( 0xe5, i_inax ) { UINT8 port = FETCH(); I.regs.w[AW] = read_port_word(port); CLKW(13,13,7,13,9,5,port); } |
| 927 | OP( 0xe6, i_outal ) { UINT8 port = FETCH(); write_port_byte(port, I.regs.b[AL]); CLKS(8,8,3); } |
| 928 | OP( 0xe7, i_outax ) { UINT8 port = FETCH(); write_port_word(port, I.regs.w[AW]); CLKW(12,12,5,12,8,3,port); } |
| 863 | 929 | |
| 864 | | OP( 0xe8, i_call_d16 ) { UINT32 tmp; FETCHWORD(tmp); PUSH(I.ip); I.ip = (WORD)(I.ip+(INT16)tmp); CHANGE_PC; nec_ICount-=24; } |
| 865 | | OP( 0xe9, i_jmp_d16 ) { UINT32 tmp; FETCHWORD(tmp); I.ip = (WORD)(I.ip+(INT16)tmp); CHANGE_PC; nec_ICount-=15; } |
| 866 | | OP( 0xea, i_jmp_far ) { UINT32 tmp,tmp1; FETCHWORD(tmp); FETCHWORD(tmp1); I.sregs[PS] = (WORD)tmp1; I.ip = (WORD)tmp; CHANGE_PC; nec_ICount-=27; } |
| 867 | | OP( 0xeb, i_jmp_d8 ) { int tmp = (int)((INT8)FETCH); nec_ICount-=12; I.ip = (WORD)(I.ip+tmp); } |
| 930 | OP( 0xe8, i_call_d16 ) { UINT32 tmp; tmp = FETCHWORD(); PUSH(I.ip); I.ip = (WORD)(I.ip+(INT16)tmp); CHANGE_PC; nec_ICount-=24; } |
| 931 | OP( 0xe9, i_jmp_d16 ) { UINT32 tmp; tmp = FETCHWORD(); I.ip = (WORD)(I.ip+(INT16)tmp); CHANGE_PC; nec_ICount-=15; } |
| 932 | OP( 0xea, i_jmp_far ) { UINT32 tmp,tmp1; tmp = FETCHWORD(); tmp1 = FETCHWORD(); I.sregs[PS] = (WORD)tmp1; I.ip = (WORD)tmp; CHANGE_PC; nec_ICount-=27; } |
| 933 | OP( 0xeb, i_jmp_d8 ) { int tmp = (int)((INT8)FETCH()); nec_ICount-=12; I.ip = (WORD)(I.ip+tmp); } |
| 868 | 934 | OP( 0xec, i_inaldx ) { I.regs.b[AL] = read_port_byte(I.regs.w[DW]); CLKS(8,8,5);} |
| 869 | 935 | OP( 0xed, i_inaxdx ) { I.regs.w[AW] = read_port_word(I.regs.w[DW]); CLKW(12,12,7,12,8,5,I.regs.w[DW]); } |
| 870 | 936 | OP( 0xee, i_outdxal ) { write_port_byte(I.regs.w[DW], I.regs.b[AL]); CLKS(8,8,3); } |
| r3514 | r3515 | |
| 873 | 939 | OP( 0xf0, i_lock ) { logerror("%06x: Warning - BUSLOCK\n",activecpu_get_pc()); I.no_interrupt=1; CLK(2); } |
| 874 | 940 | OP( 0xf2, i_repne ) { UINT32 next = fetchop(); UINT16 c = I.regs.w[CW]; |
| 875 | 941 | switch(next) { /* Segments */ |
| 876 | | case 0x26: seg_prefix=TRUE; prefix_base=I.sregs[DS1]<<4; next = fetchop(); CLK(2); break; |
| 877 | | case 0x2e: seg_prefix=TRUE; prefix_base=I.sregs[PS]<<4; next = fetchop(); CLK(2); break; |
| 878 | | case 0x36: seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; next = fetchop(); CLK(2); break; |
| 879 | | case 0x3e: seg_prefix=TRUE; prefix_base=I.sregs[DS0]<<4; next = fetchop(); CLK(2); break; |
| 942 | case 0x26: I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS1]<<4; next = fetchop(); CLK(2); break; |
| 943 | case 0x2e: I.seg_prefix=TRUE; I.prefix_base=I.sregs[PS]<<4; next = fetchop(); CLK(2); break; |
| 944 | case 0x36: I.seg_prefix=TRUE; I.prefix_base=I.sregs[SS]<<4; next = fetchop(); CLK(2); break; |
| 945 | case 0x3e: I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS0]<<4; next = fetchop(); CLK(2); break; |
| 880 | 946 | } |
| 881 | 947 | |
| 882 | 948 | switch(next) { |
| r3514 | r3515 | |
| 896 | 962 | case 0xaf: CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && ZF==0); I.regs.w[CW]=c; break; |
| 897 | 963 | default: logerror("%06x: REPNE invalid\n",activecpu_get_pc()); nec_instruction[next](); |
| 898 | 964 | } |
| 899 | | seg_prefix=FALSE; |
| 965 | I.seg_prefix=FALSE; |
| 900 | 966 | } |
| 901 | 967 | OP( 0xf3, i_repe ) { UINT32 next = fetchop(); UINT16 c = I.regs.w[CW]; |
| 902 | 968 | switch(next) { /* Segments */ |
| 903 | | case 0x26: seg_prefix=TRUE; prefix_base=I.sregs[DS1]<<4; next = fetchop(); CLK(2); break; |
| 904 | | case 0x2e: seg_prefix=TRUE; prefix_base=I.sregs[PS]<<4; next = fetchop(); CLK(2); break; |
| 905 | | case 0x36: seg_prefix=TRUE; prefix_base=I.sregs[SS]<<4; next = fetchop(); CLK(2); break; |
| 906 | | case 0x3e: seg_prefix=TRUE; prefix_base=I.sregs[DS0]<<4; next = fetchop(); CLK(2); break; |
| 969 | case 0x26: I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS1]<<4; next = fetchop(); CLK(2); break; |
| 970 | case 0x2e: I.seg_prefix=TRUE; I.prefix_base=I.sregs[PS]<<4; next = fetchop(); CLK(2); break; |
| 971 | case 0x36: I.seg_prefix=TRUE; I.prefix_base=I.sregs[SS]<<4; next = fetchop(); CLK(2); break; |
| 972 | case 0x3e: I.seg_prefix=TRUE; I.prefix_base=I.sregs[DS0]<<4; next = fetchop(); CLK(2); break; |
| 907 | 973 | } |
| 908 | 974 | |
| 909 | 975 | switch(next) { |
| r3514 | r3515 | |
| 923 | 989 | case 0xaf: CLK(2); if (c) do { i_scasw(); c--; } while (c>0 && ZF==1); I.regs.w[CW]=c; break; |
| 924 | 990 | default: logerror("%06x: REPE invalid\n",activecpu_get_pc()); nec_instruction[next](); |
| 925 | 991 | } |
| 926 | | seg_prefix=FALSE; |
| 992 | I.seg_prefix=FALSE; |
| 927 | 993 | } |
| 928 | 994 | OP( 0xf4, i_hlt ) { logerror("%06x: HALT\n",activecpu_get_pc()); nec_ICount=0; } |
| 929 | 995 | OP( 0xf5, i_cmc ) { I.CarryVal = !CF; CLK(2); } |
| 930 | 996 | OP( 0xf6, i_f6pre ) { UINT32 tmp; UINT32 uresult,uresult2; INT32 result,result2; |
| 931 | 997 | GetModRM; tmp = GetRMByte(ModRM); |
| 932 | 998 | switch (ModRM & 0x38) { |
| 933 | | case 0x00: tmp &= FETCH; I.CarryVal = I.OverVal = 0; SetSZPF_Byte(tmp); nec_ICount-=(ModRM >=0xc0 )?4:11; break; /* TEST */ |
| 999 | case 0x00: tmp &= FETCH(); I.CarryVal = I.OverVal = 0; SetSZPF_Byte(tmp); nec_ICount-=(ModRM >=0xc0 )?4:11; break; /* TEST */ |
| 934 | 1000 | case 0x08: logerror("%06x: Undefined opcode 0xf6 0x08\n",activecpu_get_pc()); break; |
| 935 | 1001 | case 0x10: PutbackRMByte(ModRM,~tmp); nec_ICount-=(ModRM >=0xc0 )?2:16; break; /* NOT */ |
| 936 | 1002 | case 0x18: I.CarryVal=(tmp!=0); tmp=(~tmp)+1; SetSZPF_Byte(tmp); PutbackRMByte(ModRM,tmp&0xff); nec_ICount-=(ModRM >=0xc0 )?2:16; break; /* NEG */ |
| r3514 | r3515 | |
| 944 | 1010 | OP( 0xf7, i_f7pre ) { UINT32 tmp,tmp2; UINT32 uresult,uresult2; INT32 result,result2; |
| 945 | 1011 | GetModRM; tmp = GetRMWord(ModRM); |
| 946 | 1012 | switch (ModRM & 0x38) { |
| 947 | | case 0x00: FETCHWORD(tmp2); tmp &= tmp2; I.CarryVal = I.OverVal = 0; SetSZPF_Word(tmp); nec_ICount-=(ModRM >=0xc0 )?4:11; break; /* TEST */ |
| 1013 | case 0x00: tmp2 = FETCHWORD(); tmp &= tmp2; I.CarryVal = I.OverVal = 0; SetSZPF_Word(tmp); nec_ICount-=(ModRM >=0xc0 )?4:11; break; /* TEST */ |
| 948 | 1014 | case 0x08: logerror("%06x: Undefined opcode 0xf7 0x08\n",activecpu_get_pc()); break; |
| 949 | 1015 | case 0x10: PutbackRMWord(ModRM,~tmp); nec_ICount-=(ModRM >=0xc0 )?2:16; break; /* NOT */ |
| 950 | 1016 | case 0x18: I.CarryVal=(tmp!=0); tmp=(~tmp)+1; SetSZPF_Word(tmp); PutbackRMWord(ModRM,tmp&0xffff); nec_ICount-=(ModRM >=0xc0 )?2:16; break; /* NEG */ |
| r3514 | r3515 | |
| 1162 | 1228 | } |
| 1163 | 1229 | #endif |
| 1164 | 1230 | |
| 1231 | static int necv_execute(int cycles) |
| 1232 | { |
| 1233 | int prev_ICount; |
| 1165 | 1234 | |
| 1166 | | /* Wrappers for the different CPU types */ |
| 1167 | | #if (HAS_V20||HAS_V25) |
| 1168 | | static void v20_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 1169 | | { |
| 1170 | | nec_init(index, clock, config, irqcallback, 0); |
| 1171 | | configure_memory_8bit(); |
| 1172 | | } |
| 1173 | | static int v20_execute(int cycles) |
| 1174 | | { |
| 1175 | 1235 | nec_ICount=cycles; |
| 1176 | | chip_type=V20; |
| 1177 | 1236 | |
| 1178 | 1237 | while(nec_ICount>0) { |
| 1179 | 1238 | /* Dispatch IRQ */ |
| r3514 | r3515 | |
| 1190 | 1249 | I.no_interrupt--; |
| 1191 | 1250 | |
| 1192 | 1251 | debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip); |
| 1252 | prev_ICount = nec_ICount; |
| 1193 | 1253 | nec_instruction[fetchop()](); |
| 1254 | do_prefetch(prev_ICount); |
| 1194 | 1255 | } |
| 1195 | 1256 | return cycles - nec_ICount; |
| 1196 | 1257 | } |
| 1258 | |
| 1259 | /* Wrappers for the different CPU types */ |
| 1260 | #if (HAS_V20||HAS_V25) |
| 1261 | static void v20_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 1262 | { |
| 1263 | nec_init(index, clock, config, irqcallback, 0); |
| 1264 | configure_memory_8bit(); |
| 1265 | I.chip_type=V20; |
| 1266 | I.prefetch_size = 4; /* 3 words */ |
| 1267 | I.prefetch_cycles = 4; /* four cycles per byte */ |
| 1268 | } |
| 1197 | 1269 | #endif |
| 1198 | 1270 | |
| 1199 | 1271 | #if (HAS_V30||HAS_V35) |
| r3514 | r3515 | |
| 1201 | 1273 | { |
| 1202 | 1274 | nec_init(index, clock, config, irqcallback, 1); |
| 1203 | 1275 | configure_memory_16bit(); |
| 1204 | | } |
| 1205 | | static int v30_execute(int cycles) { |
| 1206 | | nec_ICount=cycles; |
| 1207 | | chip_type=V30; |
| 1276 | I.chip_type=V30; |
| 1277 | I.prefetch_size = 6; /* 3 words */ |
| 1278 | I.prefetch_cycles = 2; /* two cycles per byte / four per word */ |
| 1208 | 1279 | |
| 1209 | | while(nec_ICount>0) { |
| 1210 | | /* Dispatch IRQ */ |
| 1211 | | if (I.pending_irq && I.no_interrupt==0) |
| 1212 | | { |
| 1213 | | if (I.pending_irq & NMI_IRQ) |
| 1214 | | external_int(); |
| 1215 | | else if (I.IF) |
| 1216 | | external_int(); |
| 1217 | | } |
| 1218 | | |
| 1219 | | /* No interrupt allowed between last instruction and this one */ |
| 1220 | | if (I.no_interrupt) |
| 1221 | | I.no_interrupt--; |
| 1222 | | |
| 1223 | | debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip); |
| 1224 | | nec_instruction[fetchop()](); |
| 1225 | | } |
| 1226 | | return cycles - nec_ICount; |
| 1227 | 1280 | } |
| 1228 | 1281 | #endif |
| 1229 | 1282 | |
| r3514 | r3515 | |
| 1231 | 1284 | static void v33_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 1232 | 1285 | { |
| 1233 | 1286 | nec_init(index, clock, config, irqcallback, 2); |
| 1287 | I.chip_type=V33; |
| 1288 | I.prefetch_size = 6; /* ???? */ |
| 1289 | I.prefetch_cycles = 2; /* two cycles per byte / four per word */ |
| 1290 | |
| 1234 | 1291 | configure_memory_16bit(); |
| 1235 | 1292 | } |
| 1236 | | static int v33_execute(int cycles) |
| 1237 | | { |
| 1238 | | nec_ICount=cycles; |
| 1239 | | chip_type=V33; |
| 1240 | | |
| 1241 | | while(nec_ICount>0) { |
| 1242 | | /* Dispatch IRQ */ |
| 1243 | | if (I.pending_irq && I.no_interrupt==0) |
| 1244 | | { |
| 1245 | | if (I.pending_irq & NMI_IRQ) |
| 1246 | | external_int(); |
| 1247 | | else if (I.IF) |
| 1248 | | external_int(); |
| 1249 | | } |
| 1250 | | |
| 1251 | | /* No interrupt allowed between last instruction and this one */ |
| 1252 | | if (I.no_interrupt) |
| 1253 | | I.no_interrupt--; |
| 1254 | | |
| 1255 | | debugger_instruction_hook(Machine, (I.sregs[PS]<<4) + I.ip); |
| 1256 | | nec_instruction[fetchop()](); |
| 1257 | | } |
| 1258 | | |
| 1259 | | return cycles - nec_ICount; |
| 1260 | | } |
| 1261 | 1293 | #endif |
| 1262 | 1294 | |
| 1263 | 1295 | |
| r3514 | r3515 | |
| 1383 | 1415 | case CPUINFO_PTR_INIT: /* set per-CPU */ break; |
| 1384 | 1416 | case CPUINFO_PTR_RESET: info->reset = nec_reset; break; |
| 1385 | 1417 | case CPUINFO_PTR_EXIT: info->exit = nec_exit; break; |
| 1386 | | case CPUINFO_PTR_EXECUTE: /* set per-CPU */ break; |
| 1418 | case CPUINFO_PTR_EXECUTE: info->execute = necv_execute; break; |
| 1387 | 1419 | case CPUINFO_PTR_BURN: info->burn = NULL; break; |
| 1388 | 1420 | case CPUINFO_PTR_DISASSEMBLE: info->disassemble = nec_dasm; break; |
| 1389 | 1421 | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &nec_ICount; break; |
| r3514 | r3515 | |
| 1451 | 1483 | |
| 1452 | 1484 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1453 | 1485 | case CPUINFO_PTR_INIT: info->init = v20_init; break; |
| 1454 | | case CPUINFO_PTR_EXECUTE: info->execute = v20_execute; break; |
| 1455 | 1486 | |
| 1456 | 1487 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1457 | 1488 | case CPUINFO_STR_NAME: strcpy(info->s, "V20"); break; |
| r3514 | r3515 | |
| 1477 | 1508 | |
| 1478 | 1509 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1479 | 1510 | case CPUINFO_PTR_INIT: info->init = v20_init; break; |
| 1480 | | case CPUINFO_PTR_EXECUTE: info->execute = v20_execute; break; |
| 1481 | 1511 | |
| 1482 | 1512 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1483 | 1513 | case CPUINFO_STR_NAME: strcpy(info->s, "V25"); break; |
| r3514 | r3515 | |
| 1499 | 1529 | { |
| 1500 | 1530 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1501 | 1531 | case CPUINFO_PTR_INIT: info->init = v30_init; break; |
| 1502 | | case CPUINFO_PTR_EXECUTE: info->execute = v30_execute; break; |
| 1503 | 1532 | |
| 1504 | 1533 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1505 | 1534 | case CPUINFO_STR_NAME: strcpy(info->s, "V30"); break; |
| r3514 | r3515 | |
| 1521 | 1550 | { |
| 1522 | 1551 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1523 | 1552 | case CPUINFO_PTR_INIT: info->init = v33_init; break; |
| 1524 | | case CPUINFO_PTR_EXECUTE: info->execute = v33_execute; break; |
| 1525 | 1553 | |
| 1526 | 1554 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1527 | 1555 | case CPUINFO_STR_NAME: strcpy(info->s, "V33"); break; |
| r3514 | r3515 | |
| 1543 | 1571 | { |
| 1544 | 1572 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1545 | 1573 | case CPUINFO_PTR_INIT: info->init = v30_init; break; |
| 1546 | | case CPUINFO_PTR_EXECUTE: info->execute = v30_execute; break; |
| 1547 | 1574 | |
| 1548 | 1575 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1549 | 1576 | case CPUINFO_STR_NAME: strcpy(info->s, "V35"); break; |
src/emu/sound/discrete.h
| r3514 | r3515 | |
| 238 | 238 | * DISCRETE_TRANSFORM4(NODE,INP0,INP1,INP2,INP3,FUNCT) |
| 239 | 239 | * DISCRETE_TRANSFORM5(NODE,INP0,INP1,INP2,INP3,INP4,FUNCT) |
| 240 | 240 | * |
| 241 | | * DISCRETE_COMP_ADDER(NODE,ENAB,DATA,TABLE) |
| 241 | * DISCRETE_COMP_ADDER(NODE,DATA,TABLE) |
| 242 | 242 | * DISCRETE_DAC_R1(NODE,ENAB,DATA,VDATA,LADDER) |
| 243 | | * DISCRETE_DIODE_MIXER2(NODE,VJUNC,IN0,IN1) |
| 244 | | * DISCRETE_DIODE_MIXER3(NODE,VJUNC,IN0,IN1,IN2) |
| 245 | | * DISCRETE_DIODE_MIXER4(NODE,VJUNC,IN0,IN1,IN2,IN3) |
| 243 | * DISCRETE_DIODE_MIXER2(NODE,IN0,IN1,TABLE) |
| 244 | * DISCRETE_DIODE_MIXER3(NODE,IN0,IN1,IN2,TABLE) |
| 245 | * DISCRETE_DIODE_MIXER4(NODE,IN0,IN1,IN2,IN3,TABLE) |
| 246 | 246 | * DISCRETE_INTEGRATE(NODE,TRG0,TRG1,INFO) |
| 247 | 247 | * DISCRETE_MIXER2(NODE,ENAB,IN0,IN1,INFO) |
| 248 | 248 | * DISCRETE_MIXER3(NODE,ENAB,IN0,IN1,IN2,INFO) |
| r3514 | r3515 | |
| 300 | 300 | * DISCRETE_555_VCO1_CV(NODE,RESET,VIN,CTRLV,OPTIONS) |
| 301 | 301 | * DISCRETE_566(NODE,ENAB,VMOD,R,C,OPTIONS) |
| 302 | 302 | * |
| 303 | | * DISCRETE_CUSTOM1(NODE,ENAB,IN0,INFO) |
| 304 | | * DISCRETE_CUSTOM2(NODE,ENAB,IN0,IN1,INFO) |
| 305 | | * DISCRETE_CUSTOM3(NODE,ENAB,IN0,IN1,IN2,INFO) |
| 306 | | * DISCRETE_CUSTOM4(NODE,ENAB,IN0,IN1,IN2,IN3,INFO) |
| 307 | | * DISCRETE_CUSTOM5(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,INFO) |
| 303 | * DISCRETE_CUSTOM1(NODE,IN0,INFO) |
| 304 | * DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO) |
| 305 | * DISCRETE_CUSTOM3(NODE,IN0,IN1,IN2,INFO) |
| 306 | * DISCRETE_CUSTOM4(NODE,IN0,IN1,IN2,IN3,INFO) |
| 307 | * DISCRETE_CUSTOM5(NODE,IN0,IN1,IN2,IN3,IN4,INFO) |
| 308 | * DISCRETE_CUSTOM6(NODE,IN0,IN1,IN2,IN3,IN4,IN5,INFO) |
| 309 | * DISCRETE_CUSTOM7(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO) |
| 310 | * DISCRETE_CUSTOM8(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO) |
| 311 | * DISCRETE_CUSTOM9(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,INFO) |
| 308 | 312 | * |
| 309 | 313 | * DISCRETE_CSVLOG1(NODE1) |
| 310 | 314 | * DISCRETE_CSVLOG2(NODE1,NODE2) |
| r3514 | r3515 | |
| 1683 | 1687 | * Declaration syntax |
| 1684 | 1688 | * |
| 1685 | 1689 | * DISCRETE_COMP_ADDER(name of node, |
| 1686 | | * enable node or static value, |
| 1687 | 1690 | * data node (static value is useless), |
| 1688 | 1691 | * address of discrete_comp_adder_table structure) |
| 1689 | 1692 | * |
| 1690 | 1693 | * discrete_comp_adder_table = {type, cDefault, length, c{}} |
| 1694 | * note: length can be a maximum of 8 |
| 1691 | 1695 | * |
| 1692 | 1696 | * Circuit Types: |
| 1693 | 1697 | * DISC_COMP_P_CAPACITOR - parallel capacitors |
| r3514 | r3515 | |
| 1760 | 1764 | * Declaration syntax |
| 1761 | 1765 | * |
| 1762 | 1766 | * DISCRETE_DIODE_MIXERx(name of node, |
| 1763 | | * (x = 2/3/4) voltage drop of the diode junction (static value), |
| 1764 | | * input 0 node, |
| 1767 | * (x = 2/3/4) input 0 node, |
| 1765 | 1768 | * input 1 node, |
| 1766 | | * ...) |
| 1769 | * ..., |
| 1770 | * address of v_junction table) |
| 1767 | 1771 | * |
| 1772 | * v_junction table can be set to NULL if you want all diodes to |
| 1773 | * default to a 0.5V drop. Otherwise use a |
| 1774 | * table of doubles to specify juntion voltages. |
| 1775 | * |
| 1768 | 1776 | * EXAMPLES: see dkong |
| 1769 | 1777 | * |
| 1770 | 1778 | *********************************************************************** |
| r3514 | r3515 | |
| 2681 | 2689 | * enable, |
| 2682 | 2690 | * input node (or value), |
| 2683 | 2691 | * switch node (or value), |
| 2684 | | * R in Ohms, |
| 2685 | | * C1 in Farads, |
| 2686 | | * C2 in Farads, |
| 2687 | | * C3 in Farads, |
| 2688 | | * C4 in Farads) |
| 2692 | * R in Ohms (static value), |
| 2693 | * C1 in Farads (static value), |
| 2694 | * C2 in Farads (static value), |
| 2695 | * C3 in Farads (static value), |
| 2696 | * C4 in Farads (static value)) |
| 2689 | 2697 | * |
| 2690 | 2698 | * This is a typical filter circuit in circusc or scramble. |
| 2691 | 2699 | * Switches are usually CD4066 with a "open" resistance of |
| r3514 | r3515 | |
| 3095 | 3103 | * DISC_566_OUT_TRIANGLE - Pin 4 Triangle Wave Output |
| 3096 | 3104 | * DISC_566_OUT_LOGIC - Internal Flip/Flop Output |
| 3097 | 3105 | * |
| 3106 | * EXAMPLES: see Starship 1 |
| 3107 | * |
| 3098 | 3108 | *********************************************************************** |
| 3099 | 3109 | * |
| 3100 | 3110 | * DISCRETE_74LS624 - VCO. |
| r3514 | r3515 | |
| 3142 | 3152 | *********************************************************************** |
| 3143 | 3153 | * |
| 3144 | 3154 | * DISCRETE_CUSTOMx - Link to custom code |
| 3145 | | * where x = 1 to 5 |
| 3155 | * where x = 1 to 9 |
| 3146 | 3156 | * |
| 3147 | 3157 | * Declaration syntax |
| 3148 | 3158 | * |
| 3149 | 3159 | * DISCRETE_CUSTOMx(name of node, |
| 3150 | | * enable node or static value, |
| 3151 | 3160 | * input 0 node or static value, ...) |
| 3152 | 3161 | * |
| 3153 | 3162 | * discrete_custom_info = {reset, step, contextsize, custom} |
| 3154 | 3163 | * reset = address called to reset a node after creation or system reset |
| 3155 | 3164 | * step = address called to execute one time delta of output update |
| 3156 | 3165 | * contextsize = size of context to create |
| 3157 | | * custom = address of specific initialisation data |
| 3166 | * custom = address of specific initialization data |
| 3158 | 3167 | * |
| 3168 | * EXAMPLES: see Donkey Kong |
| 3169 | * |
| 3159 | 3170 | *********************************************************************** |
| 3160 | 3171 | ======================================================================= |
| 3161 | 3172 | * Debugging modules. |
| r3514 | r3515 | |
| 3236 | 3247 | * |
| 3237 | 3248 | ************************************************************************/ |
| 3238 | 3249 | |
| 3250 | #include "streams.h" |
| 3251 | #include "wavwrite.h" |
| 3239 | 3252 | |
| 3253 | |
| 3254 | |
| 3240 | 3255 | /************************************* |
| 3241 | 3256 | * |
| 3257 | * macros |
| 3258 | * see also: emu\machine\rescap.h |
| 3259 | * |
| 3260 | *************************************/ |
| 3261 | |
| 3262 | /* calculate charge exponent using discrete sample time */ |
| 3263 | #define RC_CHARGE_EXP(rc) (1.0 - exp(discrete_current_context->neg_sample_time / (rc))) |
| 3264 | /* calculate charge exponent using given sample time */ |
| 3265 | #define RC_CHARGE_EXP_DT(rc, dt) (1.0 - exp(-(dt) / (rc))) |
| 3266 | #define RC_CHARGE_NEG_EXP_DT(rc, dt) (1.0 - exp((dt) / (rc))) |
| 3267 | |
| 3268 | /* calculate discharge exponent using discrete sample time */ |
| 3269 | #define RC_DISCHARGE_EXP(rc) (exp(discrete_current_context->neg_sample_time / (rc))) |
| 3270 | /* calculate discharge exponent using given sample time */ |
| 3271 | #define RC_DISCHARGE_EXP_DT(rc, dt) (exp(-(dt) / (rc))) |
| 3272 | #define RC_DISCHARGE_NEG_EXP_DT(rc, dt) (exp((dt) / (rc))) |
| 3273 | |
| 3274 | |
| 3275 | /************************************* |
| 3276 | * |
| 3242 | 3277 | * Profiling Nodes |
| 3243 | 3278 | * |
| 3244 | 3279 | *************************************/ |
| r3514 | r3515 | |
| 3521 | 3556 | }; |
| 3522 | 3557 | |
| 3523 | 3558 | |
| 3559 | /************************************* |
| 3560 | * |
| 3561 | * Core runtime info |
| 3562 | * |
| 3563 | * this structure is exposed mainly |
| 3564 | * to read the sample rate info |
| 3565 | * and possibly context info |
| 3566 | * |
| 3567 | *************************************/ |
| 3524 | 3568 | |
| 3569 | typedef struct _discrete_info discrete_info; |
| 3570 | struct _discrete_info |
| 3571 | { |
| 3572 | /* emulation info */ |
| 3573 | int sndindex; |
| 3574 | int sample_rate; |
| 3575 | double sample_time; |
| 3576 | double neg_sample_time; |
| 3577 | |
| 3578 | /* internal node tracking */ |
| 3579 | int node_count; |
| 3580 | node_description **running_order; |
| 3581 | node_description **indexed_node; |
| 3582 | node_description *node_list; |
| 3583 | |
| 3584 | /* the input streams */ |
| 3585 | int discrete_input_streams; |
| 3586 | stream_sample_t *input_stream_data[DISCRETE_MAX_OUTPUTS]; |
| 3587 | |
| 3588 | /* output node tracking */ |
| 3589 | int discrete_outputs; |
| 3590 | node_description *output_node[DISCRETE_MAX_OUTPUTS]; |
| 3591 | |
| 3592 | /* the output stream */ |
| 3593 | sound_stream *discrete_stream; |
| 3594 | |
| 3595 | /* debugging statics */ |
| 3596 | FILE *disclogfile; |
| 3597 | |
| 3598 | /* csvlog tracking */ |
| 3599 | int num_csvlogs; |
| 3600 | FILE *disc_csv_file[DISCRETE_MAX_CSVLOGS]; |
| 3601 | node_description *csvlog_node[DISCRETE_MAX_CSVLOGS]; |
| 3602 | INT64 sample_num; |
| 3603 | |
| 3604 | /* wavelog tracking */ |
| 3605 | int num_wavelogs; |
| 3606 | wav_file *disc_wav_file[DISCRETE_MAX_WAVELOGS]; |
| 3607 | node_description *wavelog_node[DISCRETE_MAX_WAVELOGS]; |
| 3608 | }; |
| 3609 | |
| 3610 | |
| 3525 | 3611 | /************************************* |
| 3526 | 3612 | * |
| 3527 | 3613 | * Node-specific struct types |
| r3514 | r3515 | |
| 4102 | 4188 | #define DISCRETE_TRANSFORM4(NODE,INP0,INP1,INP2,INP3,FUNCT) { NODE, DST_TRANSFORM , 4, { INP0,INP1,INP2,INP3 }, { INP0,INP1,INP2,INP3 }, FUNCT, "DISCRETE_TRANSFORM4" }, |
| 4103 | 4189 | #define DISCRETE_TRANSFORM5(NODE,INP0,INP1,INP2,INP3,INP4,FUNCT) { NODE, DST_TRANSFORM , 5, { INP0,INP1,INP2,INP3,INP4 }, { INP0,INP1,INP2,INP3,INP4 }, FUNCT, "DISCRETE_TRANSFORM5" }, |
| 4104 | 4190 | /* Component specific */ |
| 4105 | | #define DISCRETE_COMP_ADDER(NODE,ENAB,DATA,TABLE) { NODE, DST_COMP_ADDER , 2, { ENAB,DATA }, { ENAB,DATA }, TABLE, "DISCRETE_COMP_ADDER" }, |
| 4191 | #define DISCRETE_COMP_ADDER(NODE,DATA,TABLE) { NODE, DST_COMP_ADDER , 1, { DATA }, { DATA }, TABLE, "DISCRETE_COMP_ADDER" }, |
| 4106 | 4192 | #define DISCRETE_DAC_R1(NODE,ENAB,DATA,VDATA,LADDER) { NODE, DST_DAC_R1 , 3, { ENAB,DATA,VDATA }, { ENAB,DATA,VDATA }, LADDER, "DISCRETE_DAC_R1" }, |
| 4107 | | #define DISCRETE_DIODE_MIXER2(NODE,VJUNC,IN0,IN1) { NODE, DST_DIODE_MIX , 3, { NODE_NC,IN0,IN1 }, { VJUNC,IN0,IN1 }, NULL, "DISCRETE_DIODE_MIXER2" }, |
| 4108 | | #define DISCRETE_DIODE_MIXER3(NODE,VJUNC,IN0,IN1,IN2) { NODE, DST_DIODE_MIX , 4, { NODE_NC,IN0,IN1,IN2 }, { VJUNC,IN0,IN1,IN2 }, INFO, "DISCRETE_DIODE_MIXER3" }, |
| 4109 | | #define DISCRETE_DIODE_MIXER4(NODE,VJUNC,IN0,IN1,IN2,IN3) { NODE, DST_DIODE_MIX , 5, { NODE_NC,IN0,IN1,IN2,IN3 }, { VJUNC,IN0,IN1,IN2,IN3 }, INFO, "DISCRETE_DIODE_MIXER4" }, |
| 4193 | #define DISCRETE_DIODE_MIXER2(NODE,IN0,IN1,TABLE) { NODE, DST_DIODE_MIX , 3, { IN0,IN1 }, { IN0,IN1 }, TABLE, "DISCRETE_DIODE_MIXER2" }, |
| 4194 | #define DISCRETE_DIODE_MIXER3(NODE,IN0,IN1,IN2,TABLE) { NODE, DST_DIODE_MIX , 4, { IN0,IN1,IN2 }, { IN0,IN1,IN2 }, TABLE, "DISCRETE_DIODE_MIXER3" }, |
| 4195 | #define DISCRETE_DIODE_MIXER4(NODE,IN0,IN1,IN2,IN3,TABLE) { NODE, DST_DIODE_MIX , 5, { IN0,IN1,IN2,IN3 }, { IN0,IN1,IN2,IN3 }, TABLE, "DISCRETE_DIODE_MIXER4" }, |
| 4110 | 4196 | #define DISCRETE_INTEGRATE(NODE,TRG0,TRG1,INFO) { NODE, DST_INTEGRATE , 2, { TRG0,TRG1 }, { TRG0,TRG1 }, INFO, "DISCRETE_INTEGRATE" }, |
| 4111 | 4197 | #define DISCRETE_MIXER2(NODE,ENAB,IN0,IN1,INFO) { NODE, DST_MIXER , 3, { ENAB,IN0,IN1 }, { ENAB,IN0,IN1 }, INFO, "DISCRETE_MIXER2" }, |
| 4112 | 4198 | #define DISCRETE_MIXER3(NODE,ENAB,IN0,IN1,IN2,INFO) { NODE, DST_MIXER , 4, { ENAB,IN0,IN1,IN2 }, { ENAB,IN0,IN1,IN2 }, INFO, "DISCRETE_MIXER3" }, |
| r3514 | r3515 | |
| 4136 | 4222 | #define DISCRETE_RCDISC5(NODE,ENAB,INP0,RVAL,CVAL) { NODE, DST_RCDISC5 , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCDISC5" }, |
| 4137 | 4223 | #define DISCRETE_RCDISC_MODULATED(NODE,INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP) { NODE, DST_RCDISC_MOD, 8, { INP0,INP1,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { INP0,INP1,RVAL0,RVAL1,RVAL2,RVAL3,CVAL,VP }, NULL, "DISCRETE_RCDISC_MODULATED" }, |
| 4138 | 4224 | #define DISCRETE_RCFILTER(NODE,ENAB,INP0,RVAL,CVAL) { NODE, DST_RCFILTER , 4, { ENAB,INP0,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL }, NULL, "DISCRETE_RCFILTER" }, |
| 4139 | | #define DISCRETE_RCFILTER_SW(NODE,ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4) { NODE, DST_RCFILTER_SW, 8, { ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4 }, { ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4 }, NULL, "DISCRETE_RCFILTER_SW" }, |
| 4225 | #define DISCRETE_RCFILTER_SW(NODE,ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4) { NODE, DST_RCFILTER_SW, 8, { ENAB,INP0,SW,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,SW,RVAL,CVAL1,CVAL2,CVAL3,CVAL4 }, NULL, "DISCRETE_RCFILTER_SW" }, |
| 4140 | 4226 | #define DISCRETE_RCFILTER_VREF(NODE,ENAB,INP0,RVAL,CVAL,VREF) { NODE, DST_RCFILTER , 5, { ENAB,INP0,NODE_NC,NODE_NC,NODE_NC }, { ENAB,INP0,RVAL,CVAL,VREF }, NULL, "DISCRETE_RCFILTER_VREF" }, |
| 4141 | 4227 | #define DISCRETE_RCINTEGRATE(NODE,INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE) { NODE, DST_RCINTEGRATE , 7, { INP0,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC,NODE_NC }, { INP0,RVAL0,RVAL1,RVAL2,CVAL,vP,TYPE }, NULL, "DISCRETE_RCINTEGRATE" }, |
| 4142 | 4228 | /* For testing - seem to be buggered. Use versions not ending in N. */ |
| r3514 | r3515 | |
| 4146 | 4232 | |
| 4147 | 4233 | /* from disc_dev.c */ |
| 4148 | 4234 | /* generic modules */ |
| 4149 | | #define DISCRETE_CUSTOM1(NODE,ENAB,IN0,INFO) { NODE, DST_CUSTOM , 2, { ENAB,IN0 }, { ENAB,IN0 }, INFO, "DISCRETE_CUSTOM1" }, |
| 4150 | | #define DISCRETE_CUSTOM2(NODE,ENAB,IN0,IN1,INFO) { NODE, DST_CUSTOM , 3, { ENAB,IN0,IN1 }, { ENAB,IN0,IN1 }, INFO, "DISCRETE_CUSTOM2" }, |
| 4151 | | #define DISCRETE_CUSTOM3(NODE,ENAB,IN0,IN1,IN2,INFO) { NODE, DST_CUSTOM , 4, { ENAB,IN0,IN1,IN2 }, { ENAB,IN0,IN1,IN2 }, INFO, "DISCRETE_CUSTOM3" }, |
| 4152 | | #define DISCRETE_CUSTOM4(NODE,ENAB,IN0,IN1,IN2,IN3,INFO) { NODE, DST_CUSTOM , 5, { ENAB,IN0,IN1,IN2,IN3 }, { ENAB,IN0,IN1,IN2,IN3 }, INFO, "DISCRETE_CUSTOM4" }, |
| 4153 | | #define DISCRETE_CUSTOM5(NODE,ENAB,IN0,IN1,IN2,IN3,IN4,INFO) { NODE, DST_CUSTOM , 6, { ENAB,IN0,IN1,IN2,IN3,IN4 }, { ENAB,IN0,IN1,IN2,IN3,IN4 }, INFO, "DISCRETE_CUSTOM5" }, |
| 4235 | #define DISCRETE_CUSTOM1(NODE,IN0,INFO) { NODE, DST_CUSTOM , 1, { IN0 }, { IN0 }, INFO, "DISCRETE_CUSTOM1" }, |
| 4236 | #define DISCRETE_CUSTOM2(NODE,IN0,IN1,INFO) { NODE, DST_CUSTOM , 2, { IN0,IN1 }, { IN0,IN1 }, INFO, "DISCRETE_CUSTOM2" }, |
| 4237 | #define DISCRETE_CUSTOM3(NODE,IN0,IN1,IN2,INFO) { NODE, DST_CUSTOM , 3, { IN0,IN1,IN2 }, { IN0,IN1,IN2 }, INFO, "DISCRETE_CUSTOM3" }, |
| 4238 | #define DISCRETE_CUSTOM4(NODE,IN0,IN1,IN2,IN3,INFO) { NODE, DST_CUSTOM , 4, { IN0,IN1,IN2,IN3 }, { IN0,IN1,IN2,IN3 }, INFO, "DISCRETE_CUSTOM4" }, |
| 4239 | #define DISCRETE_CUSTOM5(NODE,IN0,IN1,IN2,IN3,IN4,INFO) { NODE, DST_CUSTOM , 5, { IN0,IN1,IN2,IN3,IN4 }, { IN0,IN1,IN2,IN3,IN4 }, INFO, "DISCRETE_CUSTOM5" }, |
| 4240 | #define DISCRETE_CUSTOM6(NODE,IN0,IN1,IN2,IN3,IN4,IN5,INFO) { NODE, DST_CUSTOM , 6, { IN0,IN1,IN2,IN3,IN4,IN5 }, { IN0,IN1,IN2,IN3,IN4,IN5 }, INFO, "DISCRETE_CUSTOM6" }, |
| 4241 | #define DISCRETE_CUSTOM7(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,INFO) { NODE, DST_CUSTOM , 7, { IN0,IN1,IN2,IN3,IN4,IN5,IN6 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6 }, INFO, "DISCRETE_CUSTOM7" }, |
| 4242 | #define DISCRETE_CUSTOM8(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,INFO) { NODE, DST_CUSTOM , 8, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7 }, INFO, "DISCRETE_CUSTOM8" }, |
| 4243 | #define DISCRETE_CUSTOM9(NODE,IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8,INFO) { NODE, DST_CUSTOM , 9, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 }, { IN0,IN1,IN2,IN3,IN4,IN5,IN6,IN7,IN8 }, INFO, "DISCRETE_CUSTOM9" }, |
| 4154 | 4244 | /* Component specific */ |
| 4155 | 4245 | #define DISCRETE_555_ASTABLE(NODE,RESET,R1,R2,C,OPTIONS) { NODE, DSD_555_ASTBL , 5, { RESET,R1,R2,C,NODE_NC }, { RESET,R1,R2,C,-1 }, OPTIONS, "DISCRETE_555_ASTABLE" }, |
| 4156 | 4246 | #define DISCRETE_555_ASTABLE_CV(NODE,RESET,R1,R2,C,CTRLV,OPTIONS) { NODE, DSD_555_ASTBL , 5, { RESET,R1,R2,C,CTRLV }, { RESET,R1,R2,C,CTRLV }, OPTIONS, "DISCRETE_555_ASTABLE_CV" }, |
| r3514 | r3515 | |
| 4182 | 4272 | * |
| 4183 | 4273 | *************************************/ |
| 4184 | 4274 | |
| 4275 | extern discrete_info *discrete_current_context; |
| 4276 | |
| 4185 | 4277 | node_description *discrete_find_node(void *chip, int node); |
| 4186 | 4278 | |
| 4187 | 4279 | WRITE8_HANDLER(discrete_sound_w); |
| 4188 | | READ8_HANDLER(discrete_sound_r); |
| 4280 | READ8_HANDLER( discrete_sound_r); |
| 4189 | 4281 | |
| 4190 | 4282 | #endif /* __DISCRETE_H__ */ |
src/emu/sound/fm.c
| r3514 | r3515 | |
| 7 | 7 | ** Copyright Jarek Burczynski (bujar at mame dot net) |
| 8 | 8 | ** Copyright Tatsuyuki Satoh , MultiArcadeMachineEmulator development |
| 9 | 9 | ** |
| 10 | | ** Version 1.4 (final beta) |
| 10 | ** Version 1.4.2 (final beta) |
| 11 | 11 | ** |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | /* |
| 15 | 15 | ** History: |
| 16 | 16 | ** |
| 17 | | ** 2006-2008 Eke-Eke (Genesis Plus port), MAME backport by R. Belmont |
| 17 | ** 2006-2008 Eke-Eke (Genesis Plus GX), MAME backport by R. Belmont. |
| 18 | 18 | ** - implemented PG overflow, aka "detune bug" (Ariel, Comix Zone, Shaq Fu, Spiderman,...), credits to Nemesis |
| 19 | 19 | ** - fixed SSG-EG support, credits to Nemesis and additional fixes from Alone Coder |
| 20 | 20 | ** - modified EG rates and frequency, tested by Nemesis on real hardware |
| 21 | | ** - fixed EG attenuation level on KEY ON (Ecco 2 splash sound) |
| 22 | | ** - fixed LFO phase update for CH3 special mode (Warlock, Alladin), thanks to AamirM |
| 21 | ** - implemented LFO phase update for CH3 special mode (Warlock birds, Alladin bug sound) |
| 22 | ** - fixed Attack Rate update (Batman & Robin intro) |
| 23 | ** - fixed attenuation level at the start of Substain (Gynoug explosions) |
| 24 | ** - fixed EG decay->substain transition to handle special cases, like SL=0 and Decay rate is very slow (Mega Turrican tracks 03,09...) |
| 23 | 25 | ** |
| 24 | 26 | ** 06-23-2007 Zsolt Vasvari: |
| 25 | 27 | ** - changed the timing not to require the use of floating point calculations |
| r3514 | r3515 | |
| 701 | 703 | but LFO works with one more bit of a precision so we really need 4096 elements */ |
| 702 | 704 | |
| 703 | 705 | UINT32 fn_table[4096]; /* fnumber->increment counter */ |
| 706 | UINT32 fn_max; /* maximal phase increment (used for phase overflow) */ |
| 704 | 707 | |
| 705 | | |
| 706 | 708 | /* LFO */ |
| 707 | 709 | UINT32 lfo_cnt; |
| 708 | 710 | UINT32 lfo_inc; |
| r3514 | r3515 | |
| 726 | 728 | static UINT32 LFO_AM; /* runtime LFO calculations helper */ |
| 727 | 729 | static INT32 LFO_PM; /* runtime LFO calculations helper */ |
| 728 | 730 | |
| 729 | | static int fn_max; /* maximal phase increment (used for phase overflow) */ |
| 730 | | |
| 731 | 731 | /* log output level */ |
| 732 | 732 | #define LOG_ERR 3 /* ERROR */ |
| 733 | 733 | #define LOG_WAR 2 /* WARNING */ |
| r3514 | r3515 | |
| 922 | 922 | { |
| 923 | 923 | SLOT->key = 1; |
| 924 | 924 | SLOT->phase = 0; /* restart Phase Generator */ |
| 925 | SLOT->ssgn = (SLOT->ssg & 0x04) >> 1; |
| 925 | 926 | |
| 926 | 927 | if ((type == TYPE_YM2612) || (type == TYPE_YM2608)) |
| 927 | 928 | { |
| 928 | 929 | if( (SLOT->ar + SLOT->ksr) < 32+62 ) |
| 929 | 930 | { |
| 930 | 931 | SLOT->state = EG_ATT; /* phase -> Attack */ |
| 931 | | SLOT->volume = MAX_ATT_INDEX; /* fix Ecco 2 splash sound */ |
| 932 | 932 | } |
| 933 | 933 | else |
| 934 | 934 | { |
| 935 | 935 | /* directly switch to Decay */ |
| 936 | SLOT->volume = MIN_ATT_INDEX; |
| 936 | 937 | SLOT->state = EG_DEC; |
| 937 | | SLOT->volume = MIN_ATT_INDEX; |
| 938 | 938 | } |
| 939 | 939 | } |
| 940 | 940 | else |
| r3514 | r3515 | |
| 1075 | 1075 | SLOT->eg_sh_ar = eg_rate_shift [SLOT->ar + SLOT->ksr ]; |
| 1076 | 1076 | if ((type == TYPE_YM2612) || (type == TYPE_YM2608)) |
| 1077 | 1077 | { |
| 1078 | SLOT->eg_sh_ar = eg_rate_shift [SLOT->ar + SLOT->ksr ]; |
| 1078 | 1079 | SLOT->eg_sel_ar = eg_rate_select2612[SLOT->ar + SLOT->ksr ]; |
| 1079 | 1080 | } |
| 1080 | 1081 | else |
| r3514 | r3515 | |
| 1168 | 1169 | INLINE void advance_lfo(FM_OPN *OPN) |
| 1169 | 1170 | { |
| 1170 | 1171 | UINT8 pos; |
| 1171 | | UINT8 prev_pos; |
| 1172 | 1172 | |
| 1173 | 1173 | if (OPN->lfo_inc) /* LFO enabled ? */ |
| 1174 | 1174 | { |
| 1175 | | prev_pos = OPN->lfo_cnt>>LFO_SH & 127; |
| 1176 | | |
| 1177 | 1175 | OPN->lfo_cnt += OPN->lfo_inc; |
| 1178 | 1176 | |
| 1179 | 1177 | pos = (OPN->lfo_cnt >> LFO_SH) & 127; |
| r3514 | r3515 | |
| 1181 | 1179 | |
| 1182 | 1180 | /* update AM when LFO output changes */ |
| 1183 | 1181 | |
| 1184 | | /*if (prev_pos != pos)*/ |
| 1185 | 1182 | /* actually I can't optimize is this way without rewritting chan_calc() |
| 1186 | 1183 | to use chip->lfo_am instead of global lfo_am */ |
| 1187 | 1184 | { |
| r3514 | r3515 | |
| 1195 | 1192 | } |
| 1196 | 1193 | |
| 1197 | 1194 | /* PM works with 4 times slower clock */ |
| 1198 | | prev_pos >>= 2; |
| 1199 | 1195 | pos >>= 2; |
| 1200 | 1196 | /* update PM when LFO output changes */ |
| 1201 | 1197 | /*if (prev_pos != pos)*/ /* can't use global lfo_pm for this optimization, must be chip->lfo_pm instead*/ |
| r3514 | r3515 | |
| 1222 | 1218 | i = 4; /* four operators per channel */ |
| 1223 | 1219 | do |
| 1224 | 1220 | { |
| 1221 | /* reset SSG-EG swap flag */ |
| 1222 | swap_flag = 0; |
| 1223 | |
| 1225 | 1224 | switch(SLOT->state) |
| 1226 | 1225 | { |
| 1227 | 1226 | case EG_ATT: /* attack phase */ |
| r3514 | r3515 | |
| 1240 | 1239 | break; |
| 1241 | 1240 | |
| 1242 | 1241 | case EG_DEC: /* decay phase */ |
| 1243 | | if (SLOT->ssg&0x08) /* SSG EG type envelope selected */ |
| 1242 | if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608)) |
| 1244 | 1243 | { |
| 1245 | | if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) ) |
| 1244 | if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) ) |
| 1245 | { |
| 1246 | if (SLOT->ssg&0x08) /* SSG EG type envelope selected */ |
| 1247 | { |
| 1248 | SLOT->volume += 6 * eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)]; |
| 1249 | } |
| 1250 | else |
| 1251 | { |
| 1252 | SLOT->volume += eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)]; |
| 1253 | } |
| 1254 | } |
| 1255 | |
| 1256 | /* check transition even if no volume update: this fixes the case when SL = MIN_ATT_INDEX */ |
| 1257 | if ( SLOT->volume >= (INT32)(SLOT->sl) ) |
| 1246 | 1258 | { |
| 1247 | | SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)]; |
| 1248 | | |
| 1249 | | if ( SLOT->volume >= (INT32)(SLOT->sl) ) |
| 1250 | | SLOT->state = EG_SUS; |
| 1259 | SLOT->volume = (INT32)(SLOT->sl); |
| 1260 | SLOT->state = EG_SUS; |
| 1251 | 1261 | } |
| 1252 | 1262 | } |
| 1253 | 1263 | else |
| 1254 | 1264 | { |
| 1255 | | if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) ) |
| 1265 | if (SLOT->ssg&0x08) /* SSG EG type envelope selected */ |
| 1256 | 1266 | { |
| 1257 | | SLOT->volume += eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)]; |
| 1267 | if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) ) |
| 1268 | { |
| 1269 | SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)]; |
| 1258 | 1270 | |
| 1259 | | if ( SLOT->volume >= (INT32)(SLOT->sl) ) |
| 1260 | | SLOT->state = EG_SUS; |
| 1271 | if ( SLOT->volume >= (INT32)(SLOT->sl) ) |
| 1272 | SLOT->state = EG_SUS; |
| 1273 | } |
| 1261 | 1274 | } |
| 1275 | else |
| 1276 | { |
| 1277 | if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d1r)-1) ) ) |
| 1278 | { |
| 1279 | SLOT->volume += eg_inc[SLOT->eg_sel_d1r + ((OPN->eg_cnt>>SLOT->eg_sh_d1r)&7)]; |
| 1280 | |
| 1281 | if ( SLOT->volume >= (INT32)(SLOT->sl) ) |
| 1282 | SLOT->state = EG_SUS; |
| 1283 | } |
| 1284 | } |
| 1262 | 1285 | } |
| 1263 | 1286 | break; |
| 1264 | 1287 | |
| r3514 | r3515 | |
| 1267 | 1290 | { |
| 1268 | 1291 | if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_d2r)-1) ) ) |
| 1269 | 1292 | { |
| 1270 | | SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d2r + ((OPN->eg_cnt>>SLOT->eg_sh_d2r)&7)]; |
| 1271 | 1293 | |
| 1272 | | if ( SLOT->volume >= 512 ) |
| 1294 | if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608)) |
| 1273 | 1295 | { |
| 1274 | | SLOT->volume = MAX_ATT_INDEX; |
| 1296 | SLOT->volume += 6 * eg_inc[SLOT->eg_sel_d2r + ((OPN->eg_cnt>>SLOT->eg_sh_d2r)&7)]; |
| 1297 | } |
| 1298 | else |
| 1299 | { |
| 1300 | SLOT->volume += 4 * eg_inc[SLOT->eg_sel_d2r + ((OPN->eg_cnt>>SLOT->eg_sh_d2r)&7)]; |
| 1301 | } |
| 1275 | 1302 | |
| 1303 | if ( SLOT->volume >= ENV_QUIET ) |
| 1304 | { |
| 1305 | if ((OPN->type != TYPE_YM2612) && (OPN->type != TYPE_YM2608)) |
| 1306 | { |
| 1307 | SLOT->volume = MAX_ATT_INDEX; |
| 1308 | } |
| 1309 | |
| 1276 | 1310 | if (SLOT->ssg&0x01) /* bit 0 = hold */ |
| 1277 | 1311 | { |
| 1278 | 1312 | if (SLOT->ssgn&1) /* have we swapped once ??? */ |
| r3514 | r3515 | |
| 1287 | 1321 | { |
| 1288 | 1322 | /* same as KEY-ON operation */ |
| 1289 | 1323 | |
| 1290 | | /* restart of the Phase Generator should be here, |
| 1291 | | only if AR is not maximum ??? */ |
| 1324 | /* restart of the Phase Generator should be here */ |
| 1292 | 1325 | SLOT->phase = 0; |
| 1293 | 1326 | |
| 1294 | | /* phase -> Attack */ |
| 1295 | | SLOT->volume = 511; |
| 1296 | | SLOT->state = EG_ATT; |
| 1327 | if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608)) |
| 1328 | { |
| 1329 | if ((SLOT->ar + SLOT->ksr) < 94 /*32+62*/) |
| 1330 | { |
| 1331 | SLOT->state = EG_ATT; /* phase -> Attack */ |
| 1332 | } |
| 1333 | else |
| 1334 | { |
| 1335 | /* Attack Rate is maximal: directly switch to Decay (or Substain) */ |
| 1336 | SLOT->volume = MIN_ATT_INDEX; |
| 1337 | SLOT->state = (SLOT->sl == MIN_ATT_INDEX) ? EG_SUS : EG_DEC; |
| 1338 | } |
| 1339 | } |
| 1340 | else |
| 1341 | { |
| 1342 | /* phase -> Attack */ |
| 1343 | SLOT->volume = 511; |
| 1344 | SLOT->state = EG_ATT; |
| 1345 | } |
| 1297 | 1346 | |
| 1298 | 1347 | swap_flag = (SLOT->ssg&0x02); /* bit 1 = alternate */ |
| 1299 | 1348 | } |
| r3514 | r3515 | |
| 1319 | 1368 | case EG_REL: /* release phase */ |
| 1320 | 1369 | if ( !(OPN->eg_cnt & ((1<<SLOT->eg_sh_rr)-1) ) ) |
| 1321 | 1370 | { |
| 1322 | | SLOT->volume += eg_inc[SLOT->eg_sel_rr + ((OPN->eg_cnt>>SLOT->eg_sh_rr)&7)]; |
| 1371 | /* SSG-EG affects Release phase also (Nemesis) */ |
| 1372 | if ((SLOT->ssg&0x08) && ((OPN->type = TYPE_YM2612) || (OPN->type = TYPE_YM2608))) |
| 1373 | { |
| 1374 | SLOT->volume += 6 * eg_inc[SLOT->eg_sel_rr + ((OPN->eg_cnt>>SLOT->eg_sh_rr)&7)]; |
| 1375 | } |
| 1376 | else |
| 1377 | { |
| 1378 | SLOT->volume += eg_inc[SLOT->eg_sel_rr + ((OPN->eg_cnt>>SLOT->eg_sh_rr)&7)]; |
| 1379 | } |
| 1323 | 1380 | |
| 1324 | 1381 | if ( SLOT->volume >= MAX_ATT_INDEX ) |
| 1325 | 1382 | { |
| r3514 | r3515 | |
| 1331 | 1388 | |
| 1332 | 1389 | } |
| 1333 | 1390 | |
| 1334 | | out = SLOT->tl + ((UINT32)SLOT->volume); |
| 1335 | 1391 | |
| 1336 | | if ((SLOT->ssg&0x08) && (SLOT->ssgn&2) && (SLOT->state != EG_OFF)) /* negate output (changes come from alternate bit, init comes from attack bit) */ |
| 1337 | | out ^= 511; // was ((1<<ENV_BITS)-1); /* 1023 */ |
| 1392 | out = ((UINT32)SLOT->volume); |
| 1338 | 1393 | |
| 1394 | /* negate output (changes come from alternate bit, init comes from attack bit) */ |
| 1395 | if ((SLOT->ssg&0x08) && (SLOT->ssgn&2) && (SLOT->state > EG_REL)) |
| 1396 | out ^= MAX_ATT_INDEX; |
| 1397 | |
| 1339 | 1398 | /* we need to store the result here because we are going to change ssgn |
| 1340 | 1399 | in next instruction */ |
| 1341 | | SLOT->vol_out = out; |
| 1400 | SLOT->vol_out = out + SLOT->tl; |
| 1342 | 1401 | |
| 1402 | /* reverse SLOT inversion flag */ |
| 1343 | 1403 | SLOT->ssgn ^= swap_flag; |
| 1344 | 1404 | |
| 1345 | 1405 | SLOT++; |
| r3514 | r3515 | |
| 1375 | 1435 | fc = (OPN->fn_table[fn]>>(7-blk)) + SLOT->DT[kc]; |
| 1376 | 1436 | |
| 1377 | 1437 | /* detects frequency overflow (credits to Nemesis) */ |
| 1378 | | if (fc < 0) fc += fn_max; |
| 1438 | if (fc < 0) fc += OPN->fn_max; |
| 1379 | 1439 | |
| 1380 | 1440 | /* update phase */ |
| 1381 | 1441 | SLOT->phase += (fc * SLOT->mul) >> 1; |
| r3514 | r3515 | |
| 1413 | 1473 | /* detects frequency overflow (credits to Nemesis) */ |
| 1414 | 1474 | finc = fc + CH->SLOT[SLOT1].DT[kc]; |
| 1415 | 1475 | |
| 1416 | | if (finc < 0) finc += fn_max; |
| 1476 | if (finc < 0) finc += OPN->fn_max; |
| 1417 | 1477 | CH->SLOT[SLOT1].phase += (finc*CH->SLOT[SLOT1].mul) >> 1; |
| 1418 | 1478 | |
| 1419 | 1479 | finc = fc + CH->SLOT[SLOT2].DT[kc]; |
| 1420 | | if (finc < 0) finc += fn_max; |
| 1480 | if (finc < 0) finc += OPN->fn_max; |
| 1421 | 1481 | CH->SLOT[SLOT2].phase += (finc*CH->SLOT[SLOT2].mul) >> 1; |
| 1422 | 1482 | |
| 1423 | 1483 | finc = fc + CH->SLOT[SLOT3].DT[kc]; |
| 1424 | | if (finc < 0) finc += fn_max; |
| 1484 | if (finc < 0) finc += OPN->fn_max; |
| 1425 | 1485 | CH->SLOT[SLOT3].phase += (finc*CH->SLOT[SLOT3].mul) >> 1; |
| 1426 | 1486 | |
| 1427 | 1487 | finc = fc + CH->SLOT[SLOT4].DT[kc]; |
| 1428 | | if (finc < 0) finc += fn_max; |
| 1488 | if (finc < 0) finc += OPN->fn_max; |
| 1429 | 1489 | CH->SLOT[SLOT4].phase += (finc*CH->SLOT[SLOT4].mul) >> 1; |
| 1430 | 1490 | } |
| 1431 | 1491 | else /* LFO phase modulation = zero */ |
| r3514 | r3515 | |
| 1512 | 1572 | } |
| 1513 | 1573 | |
| 1514 | 1574 | /* update phase increment and envelope generator */ |
| 1515 | | INLINE void refresh_fc_eg_slot(UINT8 type, FM_SLOT *SLOT , int fc , int kc ) |
| 1575 | INLINE void refresh_fc_eg_slot(FM_OPN *OPN, FM_SLOT *SLOT , int fc , int kc ) |
| 1516 | 1576 | { |
| 1517 | 1577 | int ksr = kc >> SLOT->KSR; |
| 1518 | 1578 | |
| 1519 | 1579 | fc += SLOT->DT[kc]; |
| 1520 | 1580 | |
| 1521 | 1581 | /* detects frequency overflow (credits to Nemesis) */ |
| 1522 | | if (fc < 0) fc += fn_max; |
| 1582 | if (fc < 0) fc += OPN->fn_max; |
| 1523 | 1583 | |
| 1524 | 1584 | /* (frequency) phase increment counter */ |
| 1525 | 1585 | SLOT->Incr = (fc * SLOT->mul) >> 1; |
| r3514 | r3515 | |
| 1532 | 1592 | if ((SLOT->ar + SLOT->ksr) < 32+62) |
| 1533 | 1593 | { |
| 1534 | 1594 | SLOT->eg_sh_ar = eg_rate_shift [SLOT->ar + SLOT->ksr ]; |
| 1535 | | if ((type == TYPE_YM2612) || (type == TYPE_YM2608)) |
| 1595 | if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608)) |
| 1536 | 1596 | { |
| 1537 | 1597 | SLOT->eg_sel_ar = eg_rate_select2612[SLOT->ar + SLOT->ksr ]; |
| 1538 | 1598 | } |
| r3514 | r3515 | |
| 1551 | 1611 | SLOT->eg_sh_d2r = eg_rate_shift [SLOT->d2r + SLOT->ksr]; |
| 1552 | 1612 | SLOT->eg_sh_rr = eg_rate_shift [SLOT->rr + SLOT->ksr]; |
| 1553 | 1613 | |
| 1554 | | if ((type == TYPE_YM2612) || (type == TYPE_YM2608)) |
| 1614 | if ((OPN->type == TYPE_YM2612) || (OPN->type == TYPE_YM2608)) |
| 1555 | 1615 | { |
| 1556 | 1616 | SLOT->eg_sel_d1r= eg_rate_select2612[SLOT->d1r + SLOT->ksr]; |
| 1557 | 1617 | SLOT->eg_sel_d2r= eg_rate_select2612[SLOT->d2r + SLOT->ksr]; |
| r3514 | r3515 | |
| 1568 | 1628 | |
| 1569 | 1629 | /* update phase increment counters */ |
| 1570 | 1630 | /* Changed from INLINE to static to work around gcc 4.2.1 codegen bug */ |
| 1571 | | static void refresh_fc_eg_chan(UINT8 type, FM_CH *CH ) |
| 1631 | static void refresh_fc_eg_chan(FM_OPN *OPN, FM_CH *CH ) |
| 1572 | 1632 | { |
| 1573 | 1633 | if( CH->SLOT[SLOT1].Incr==-1){ |
| 1574 | 1634 | int fc = CH->fc; |
| 1575 | 1635 | int kc = CH->kcode; |
| 1576 | | refresh_fc_eg_slot(type, &CH->SLOT[SLOT1] , fc , kc ); |
| 1577 | | refresh_fc_eg_slot(type, &CH->SLOT[SLOT2] , fc , kc ); |
| 1578 | | refresh_fc_eg_slot(type, &CH->SLOT[SLOT3] , fc , kc ); |
| 1579 | | refresh_fc_eg_slot(type, &CH->SLOT[SLOT4] , fc , kc ); |
| 1636 | refresh_fc_eg_slot(OPN, &CH->SLOT[SLOT1] , fc , kc ); |
| 1637 | refresh_fc_eg_slot(OPN, &CH->SLOT[SLOT2] , fc , kc ); |
| 1638 | refresh_fc_eg_slot(OPN, &CH->SLOT[SLOT3] , fc , kc ); |
| 1639 | refresh_fc_eg_slot(OPN, &CH->SLOT[SLOT4] , fc , kc ); |
| 1580 | 1640 | } |
| 1581 | 1641 | } |
| 1582 | 1642 | |
| r3514 | r3515 | |
| 1761 | 1821 | /* CSM Key Controll */ |
| 1762 | 1822 | INLINE void CSMKeyControll(UINT8 type, FM_CH *CH) |
| 1763 | 1823 | { |
| 1764 | | /* this is wrong, atm */ |
| 1765 | | |
| 1766 | | /* all key on */ |
| 1767 | | FM_KEYON(type, CH,SLOT1); |
| 1768 | | FM_KEYON(type, CH,SLOT2); |
| 1769 | | FM_KEYON(type, CH,SLOT3); |
| 1770 | | FM_KEYON(type, CH,SLOT4); |
| 1824 | /* all key on then off (only for operators which were OFF!) */ |
| 1825 | if (!CH->SLOT[SLOT1].key) |
| 1826 | { |
| 1827 | FM_KEYON(type, CH,SLOT1); |
| 1828 | FM_KEYOFF(CH, SLOT1); |
| 1829 | } |
| 1830 | if (!CH->SLOT[SLOT2].key) |
| 1831 | { |
| 1832 | FM_KEYON(type, CH,SLOT2); |
| 1833 | FM_KEYOFF(CH, SLOT2); |
| 1834 | } |
| 1835 | if (!CH->SLOT[SLOT3].key) |
| 1836 | { |
| 1837 | FM_KEYON(type, CH,SLOT3); |
| 1838 | FM_KEYOFF(CH, SLOT3); |
| 1839 | } |
| 1840 | if (!CH->SLOT[SLOT4].key) |
| 1841 | { |
| 1842 | FM_KEYON(type, CH,SLOT4); |
| 1843 | FM_KEYOFF(CH, SLOT4); |
| 1844 | } |
| 1771 | 1845 | } |
| 1772 | 1846 | |
| 1773 | 1847 | #ifdef __STATE_H__ |
| r3514 | r3515 | |
| 1861 | 1935 | #endif |
| 1862 | 1936 | } |
| 1863 | 1937 | |
| 1864 | | /* maximal frequency, used for overflow, best setting with BLOCK=5 (notaz) */ |
| 1865 | | fn_max = ((UINT32)((double)OPN->fn_table[0x7ff*2] / OPN->ST.freqbase) >> 2); |
| 1938 | /* maximal frequency is required for Phase overflow calculation, register size is 17 bits (Nemesis) */ |
| 1939 | OPN->fn_max = (UINT32)( (double)0x20000 * OPN->ST.freqbase * (1<<(FREQ_SH-10)) ); |
| 1866 | 1940 | |
| 1867 | 1941 | /* LFO freq. table */ |
| 1868 | 1942 | for(i = 0; i < 8; i++) |
| r3514 | r3515 | |
| 2204 | 2278 | |
| 2205 | 2279 | |
| 2206 | 2280 | /* refresh PG and EG */ |
| 2207 | | refresh_fc_eg_chan( OPN->type, cch[0] ); |
| 2208 | | refresh_fc_eg_chan( OPN->type, cch[1] ); |
| 2281 | refresh_fc_eg_chan( OPN, cch[0] ); |
| 2282 | refresh_fc_eg_chan( OPN, cch[1] ); |
| 2209 | 2283 | if( (F2203->OPN.ST.mode & 0xc0) ) |
| 2210 | 2284 | { |
| 2211 | 2285 | /* 3SLOT MODE */ |
| 2212 | 2286 | if( cch[2]->SLOT[SLOT1].Incr==-1) |
| 2213 | 2287 | { |
| 2214 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 2215 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 2216 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 2217 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode ); |
| 2288 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 2289 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 2290 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 2291 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode ); |
| 2218 | 2292 | } |
| 2219 | | }else refresh_fc_eg_chan( OPN->type, cch[2] ); |
| 2293 | }else refresh_fc_eg_chan( OPN, cch[2] ); |
| 2220 | 2294 | |
| 2221 | 2295 | |
| 2222 | 2296 | /* YM2203 doesn't have LFO so we must keep these globals at 0 level */ |
| r3514 | r3515 | |
| 3386 | 3460 | pcmsizeA = F2608->pcm_size; |
| 3387 | 3461 | |
| 3388 | 3462 | /* refresh PG and EG */ |
| 3389 | | refresh_fc_eg_chan( OPN->type, cch[0] ); |
| 3390 | | refresh_fc_eg_chan( OPN->type, cch[1] ); |
| 3463 | refresh_fc_eg_chan( OPN, cch[0] ); |
| 3464 | refresh_fc_eg_chan( OPN, cch[1] ); |
| 3391 | 3465 | if( (OPN->ST.mode & 0xc0) ) |
| 3392 | 3466 | { |
| 3393 | 3467 | /* 3SLOT MODE */ |
| 3394 | 3468 | if( cch[2]->SLOT[SLOT1].Incr==-1) |
| 3395 | 3469 | { |
| 3396 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 3397 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 3398 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 3399 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode ); |
| 3470 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 3471 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 3472 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 3473 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode ); |
| 3400 | 3474 | } |
| 3401 | | }else refresh_fc_eg_chan( OPN->type, cch[2] ); |
| 3402 | | refresh_fc_eg_chan( OPN->type, cch[3] ); |
| 3403 | | refresh_fc_eg_chan( OPN->type, cch[4] ); |
| 3404 | | refresh_fc_eg_chan( OPN->type, cch[5] ); |
| 3475 | }else refresh_fc_eg_chan( OPN, cch[2] ); |
| 3476 | refresh_fc_eg_chan( OPN, cch[3] ); |
| 3477 | refresh_fc_eg_chan( OPN, cch[4] ); |
| 3478 | refresh_fc_eg_chan( OPN, cch[5] ); |
| 3405 | 3479 | |
| 3406 | 3480 | |
| 3407 | 3481 | /* buffering */ |
| r3514 | r3515 | |
| 3421 | 3495 | out_fm[4] = 0; |
| 3422 | 3496 | out_fm[5] = 0; |
| 3423 | 3497 | |
| 3424 | | /* advance envelope generator */ |
| 3425 | | OPN->eg_timer += OPN->eg_timer_add; |
| 3426 | | while (OPN->eg_timer >= OPN->eg_timer_overflow) |
| 3427 | | { |
| 3428 | | OPN->eg_timer -= OPN->eg_timer_overflow; |
| 3429 | | OPN->eg_cnt++; |
| 3430 | | |
| 3431 | | advance_eg_channel(OPN, &cch[0]->SLOT[SLOT1]); |
| 3432 | | advance_eg_channel(OPN, &cch[1]->SLOT[SLOT1]); |
| 3433 | | advance_eg_channel(OPN, &cch[2]->SLOT[SLOT1]); |
| 3434 | | advance_eg_channel(OPN, &cch[3]->SLOT[SLOT1]); |
| 3435 | | advance_eg_channel(OPN, &cch[4]->SLOT[SLOT1]); |
| 3436 | | advance_eg_channel(OPN, &cch[5]->SLOT[SLOT1]); |
| 3437 | | } |
| 3438 | | |
| 3439 | 3498 | /* calculate FM */ |
| 3440 | 3499 | chan_calc(OPN, cch[0], 0 ); |
| 3441 | 3500 | chan_calc(OPN, cch[1], 1 ); |
| r3514 | r3515 | |
| 3455 | 3514 | ADPCMA_calc_chan( F2608, &F2608->adpcm[j]); |
| 3456 | 3515 | } |
| 3457 | 3516 | |
| 3517 | /* advance envelope generator */ |
| 3518 | OPN->eg_timer += OPN->eg_timer_add; |
| 3519 | while (OPN->eg_timer >= OPN->eg_timer_overflow) |
| 3520 | { |
| 3521 | OPN->eg_timer -= OPN->eg_timer_overflow; |
| 3522 | OPN->eg_cnt++; |
| 3523 | |
| 3524 | advance_eg_channel(OPN, &cch[0]->SLOT[SLOT1]); |
| 3525 | advance_eg_channel(OPN, &cch[1]->SLOT[SLOT1]); |
| 3526 | advance_eg_channel(OPN, &cch[2]->SLOT[SLOT1]); |
| 3527 | advance_eg_channel(OPN, &cch[3]->SLOT[SLOT1]); |
| 3528 | advance_eg_channel(OPN, &cch[4]->SLOT[SLOT1]); |
| 3529 | advance_eg_channel(OPN, &cch[5]->SLOT[SLOT1]); |
| 3530 | } |
| 3531 | |
| 3458 | 3532 | /* buffering */ |
| 3459 | 3533 | { |
| 3460 | 3534 | int lt,rt; |
| r3514 | r3515 | |
| 3940 | 4014 | #endif |
| 3941 | 4015 | |
| 3942 | 4016 | /* refresh PG and EG */ |
| 3943 | | refresh_fc_eg_chan( OPN->type, cch[0] ); |
| 4017 | refresh_fc_eg_chan( OPN, cch[0] ); |
| 3944 | 4018 | if( (OPN->ST.mode & 0xc0) ) |
| 3945 | 4019 | { |
| 3946 | 4020 | /* 3SLOT MODE */ |
| 3947 | 4021 | if( cch[1]->SLOT[SLOT1].Incr==-1) |
| 3948 | 4022 | { |
| 3949 | | refresh_fc_eg_slot(OPN->type, &cch[1]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 3950 | | refresh_fc_eg_slot(OPN->type, &cch[1]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 3951 | | refresh_fc_eg_slot(OPN->type, &cch[1]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 3952 | | refresh_fc_eg_slot(OPN->type, &cch[1]->SLOT[SLOT4] , cch[1]->fc , cch[1]->kcode ); |
| 4023 | refresh_fc_eg_slot(OPN, &cch[1]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 4024 | refresh_fc_eg_slot(OPN, &cch[1]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 4025 | refresh_fc_eg_slot(OPN, &cch[1]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 4026 | refresh_fc_eg_slot(OPN, &cch[1]->SLOT[SLOT4] , cch[1]->fc , cch[1]->kcode ); |
| 3953 | 4027 | } |
| 3954 | | }else refresh_fc_eg_chan( OPN->type, cch[1] ); |
| 3955 | | refresh_fc_eg_chan( OPN->type, cch[2] ); |
| 3956 | | refresh_fc_eg_chan( OPN->type, cch[3] ); |
| 4028 | }else refresh_fc_eg_chan( OPN, cch[1] ); |
| 4029 | refresh_fc_eg_chan( OPN, cch[2] ); |
| 4030 | refresh_fc_eg_chan( OPN, cch[3] ); |
| 3957 | 4031 | |
| 3958 | 4032 | /* buffering */ |
| 3959 | 4033 | for(i=0; i < length ; i++) |
| r3514 | r3515 | |
| 4069 | 4143 | pcmsizeA = F2610->pcm_size; |
| 4070 | 4144 | |
| 4071 | 4145 | /* refresh PG and EG */ |
| 4072 | | refresh_fc_eg_chan( OPN->type, cch[0] ); |
| 4073 | | refresh_fc_eg_chan( OPN->type, cch[1] ); |
| 4146 | refresh_fc_eg_chan( OPN, cch[0] ); |
| 4147 | refresh_fc_eg_chan( OPN, cch[1] ); |
| 4074 | 4148 | if( (OPN->ST.mode & 0xc0) ) |
| 4075 | 4149 | { |
| 4076 | 4150 | /* 3SLOT MODE */ |
| 4077 | 4151 | if( cch[2]->SLOT[SLOT1].Incr==-1) |
| 4078 | 4152 | { |
| 4079 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 4080 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 4081 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 4082 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode ); |
| 4153 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 4154 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 4155 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 4156 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode ); |
| 4083 | 4157 | } |
| 4084 | | }else refresh_fc_eg_chan( OPN->type, cch[2] ); |
| 4085 | | refresh_fc_eg_chan( OPN->type, cch[3] ); |
| 4086 | | refresh_fc_eg_chan( OPN->type, cch[4] ); |
| 4087 | | refresh_fc_eg_chan( OPN->type, cch[5] ); |
| 4158 | }else refresh_fc_eg_chan( OPN, cch[2] ); |
| 4159 | refresh_fc_eg_chan( OPN, cch[3] ); |
| 4160 | refresh_fc_eg_chan( OPN, cch[4] ); |
| 4161 | refresh_fc_eg_chan( OPN, cch[5] ); |
| 4088 | 4162 | |
| 4089 | 4163 | /* buffering */ |
| 4090 | 4164 | for(i=0; i < length ; i++) |
| r3514 | r3515 | |
| 4590 | 4664 | dacen = F2612->dacen; |
| 4591 | 4665 | |
| 4592 | 4666 | /* refresh PG and EG */ |
| 4593 | | refresh_fc_eg_chan( OPN->type, cch[0] ); |
| 4594 | | refresh_fc_eg_chan( OPN->type, cch[1] ); |
| 4667 | refresh_fc_eg_chan( OPN, cch[0] ); |
| 4668 | refresh_fc_eg_chan( OPN, cch[1] ); |
| 4595 | 4669 | if( (OPN->ST.mode & 0xc0) ) |
| 4596 | 4670 | { |
| 4597 | 4671 | /* 3SLOT MODE */ |
| 4598 | 4672 | if( cch[2]->SLOT[SLOT1].Incr==-1) |
| 4599 | 4673 | { |
| 4600 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 4601 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 4602 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 4603 | | refresh_fc_eg_slot(OPN->type, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode ); |
| 4674 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT1] , OPN->SL3.fc[1] , OPN->SL3.kcode[1] ); |
| 4675 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT2] , OPN->SL3.fc[2] , OPN->SL3.kcode[2] ); |
| 4676 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT3] , OPN->SL3.fc[0] , OPN->SL3.kcode[0] ); |
| 4677 | refresh_fc_eg_slot(OPN, &cch[2]->SLOT[SLOT4] , cch[2]->fc , cch[2]->kcode ); |
| 4604 | 4678 | } |
| 4605 | | }else refresh_fc_eg_chan( OPN->type, cch[2] ); |
| 4606 | | refresh_fc_eg_chan( OPN->type, cch[3] ); |
| 4607 | | refresh_fc_eg_chan( OPN->type, cch[4] ); |
| 4608 | | refresh_fc_eg_chan( OPN->type, cch[5] ); |
| 4679 | }else refresh_fc_eg_chan( OPN, cch[2] ); |
| 4680 | refresh_fc_eg_chan( OPN, cch[3] ); |
| 4681 | refresh_fc_eg_chan( OPN, cch[4] ); |
| 4682 | refresh_fc_eg_chan( OPN, cch[5] ); |
| 4609 | 4683 | |
| 4610 | 4684 | /* buffering */ |
| 4611 | 4685 | for(i=0; i < length ; i++) |
| r3514 | r3515 | |
| 4621 | 4695 | out_fm[4] = 0; |
| 4622 | 4696 | out_fm[5] = 0; |
| 4623 | 4697 | |
| 4698 | /* calculate FM */ |
| 4699 | chan_calc(OPN, cch[0], 0 ); |
| 4700 | chan_calc(OPN, cch[1], 1 ); |
| 4701 | chan_calc(OPN, cch[2], 2 ); |
| 4702 | chan_calc(OPN, cch[3], 3 ); |
| 4703 | chan_calc(OPN, cch[4], 4 ); |
| 4704 | if( dacen ) |
| 4705 | *cch[5]->connect4 += dacout; |
| 4706 | else |
| 4707 | chan_calc(OPN, cch[5], 5 ); |
| 4708 | |
| 4624 | 4709 | /* advance envelope generator */ |
| 4625 | 4710 | OPN->eg_timer += OPN->eg_timer_add; |
| 4626 | 4711 | while (OPN->eg_timer >= OPN->eg_timer_overflow) |
| r3514 | r3515 | |
| 4636 | 4721 | advance_eg_channel(OPN, &cch[5]->SLOT[SLOT1]); |
| 4637 | 4722 | } |
| 4638 | 4723 | |
| 4639 | | /* calculate FM */ |
| 4640 | | chan_calc(OPN, cch[0], 0 ); |
| 4641 | | chan_calc(OPN, cch[1], 1 ); |
| 4642 | | chan_calc(OPN, cch[2], 2 ); |
| 4643 | | chan_calc(OPN, cch[3], 3 ); |
| 4644 | | chan_calc(OPN, cch[4], 4 ); |
| 4645 | | if( dacen ) |
| 4646 | | *cch[5]->connect4 += dacout; |
| 4647 | | else |
| 4648 | | chan_calc(OPN, cch[5], 5 ); |
| 4649 | | |
| 4650 | 4724 | { |
| 4651 | 4725 | int lt,rt; |
| 4652 | 4726 | |