src/mess/image.c
| r1980 | r1981 | |
| 106 | 106 | image_init - initialize the core image system |
| 107 | 107 | -------------------------------------------------*/ |
| 108 | 108 | |
| 109 | | int image_init(void) |
| 109 | int image_init(running_machine *machine) |
| 110 | 110 | { |
| 111 | 111 | int err; |
| 112 | 112 | int count, indx, i, j; |
| r1980 | r1981 | |
| 118 | 118 | |
| 119 | 119 | /* first count all images, and identify multiply defined devices */ |
| 120 | 120 | count = 0; |
| 121 | | for (i = 0; Machine->devices[i].type < IO_COUNT; i++) |
| 121 | for (i = 0; machine->devices[i].type < IO_COUNT; i++) |
| 122 | 122 | { |
| 123 | 123 | /* check to see if this device type is used multiple times */ |
| 124 | | mask = 1 << Machine->devices[i].type; |
| 124 | mask = 1 << machine->devices[i].type; |
| 125 | 125 | if (dev_mask & mask) |
| 126 | 126 | multiple_dev_mask |= mask; |
| 127 | 127 | else |
| 128 | 128 | dev_mask |= mask; |
| 129 | 129 | |
| 130 | 130 | /* increment the count */ |
| 131 | | count += Machine->devices[i].count; |
| 131 | count += machine->devices[i].count; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /* allocate the array */ |
| r1980 | r1981 | |
| 140 | 140 | |
| 141 | 141 | /* initialize the devices */ |
| 142 | 142 | indx = 0; |
| 143 | | for (i = 0; Machine->devices[i].type < IO_COUNT; i++) |
| 143 | for (i = 0; machine->devices[i].type < IO_COUNT; i++) |
| 144 | 144 | { |
| 145 | | for (j = 0; j < Machine->devices[i].count; j++) |
| 145 | for (j = 0; j < machine->devices[i].count; j++) |
| 146 | 146 | { |
| 147 | 147 | images[indx + j].mempool = pool_alloc(memory_error); |
| 148 | 148 | |
| 149 | 149 | /* setup the device */ |
| 150 | 150 | tagpool_init(&images[indx + j].tagpool); |
| 151 | | images[indx + j].dev = &Machine->devices[i]; |
| 151 | images[indx + j].dev = &machine->devices[i]; |
| 152 | 152 | |
| 153 | | if (Machine->devices[i].init) |
| 153 | if (machine->devices[i].init) |
| 154 | 154 | { |
| 155 | | err = Machine->devices[i].init(&images[indx + j]); |
| 155 | err = machine->devices[i].init(&images[indx + j]); |
| 156 | 156 | if (err != INIT_PASS) |
| 157 | 157 | return err; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | } |
| 161 | | indx += Machine->devices[i].count; |
| 161 | indx += machine->devices[i].count; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | | add_exit_callback(Machine, image_exit); |
| 164 | add_exit_callback(machine, image_exit); |
| 165 | 165 | return INIT_PASS; |
| 166 | 166 | } |
| 167 | 167 | |
| r1980 | r1981 | |
| 535 | 535 | image_load_internal - core image loading |
| 536 | 536 | -------------------------------------------------*/ |
| 537 | 537 | |
| 538 | | static int image_load_internal(mess_image *image, const char *path, |
| 538 | static int image_load_internal(running_machine *machine, mess_image *image, const char *path, |
| 539 | 539 | int is_create, int create_format, option_resolution *create_args) |
| 540 | 540 | { |
| 541 | 541 | image_error_t err; |
| r1980 | r1981 | |
| 563 | 563 | |
| 564 | 564 | /* do we need to reset the CPU? */ |
| 565 | 565 | if ((attotime_compare(timer_get_time(), attotime_zero) > 0) && image->dev->reset_on_load) |
| 566 | | mame_schedule_hard_reset(Machine); |
| 566 | mame_schedule_hard_reset(machine); |
| 567 | 567 | |
| 568 | 568 | /* determine open plan */ |
| 569 | 569 | determine_open_plan(image, is_create, open_plan); |
| r1980 | r1981 | |
| 574 | 574 | software_path = software_path_list; |
| 575 | 575 | do |
| 576 | 576 | { |
| 577 | | gamedrv = Machine->gamedrv; |
| 577 | gamedrv = machine->gamedrv; |
| 578 | 578 | while(!is_loaded(image) && gamedrv) |
| 579 | 579 | { |
| 580 | 580 | /* open the file */ |
| r1980 | r1981 | |
| 662 | 662 | |
| 663 | 663 | int image_load(mess_image *image, const char *path) |
| 664 | 664 | { |
| 665 | | return image_load_internal(image, path, FALSE, 0, NULL); |
| 665 | return image_load_internal(Machine, image, path, FALSE, 0, NULL); |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | |
| r1980 | r1981 | |
| 673 | 673 | |
| 674 | 674 | int image_create(mess_image *image, const char *path, int create_format, option_resolution *create_args) |
| 675 | 675 | { |
| 676 | | return image_load_internal(image, path, TRUE, create_format, create_args); |
| 676 | return image_load_internal(Machine, image, path, TRUE, create_format, create_args); |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | 679 | |
| r1980 | r1981 | |
| 752 | 752 | mess_image *image; |
| 753 | 753 | |
| 754 | 754 | if (!ispreload) |
| 755 | | mess_options_extract(); |
| 755 | mess_options_extract(Machine); |
| 756 | 756 | |
| 757 | 757 | /* normalize ispreload */ |
| 758 | 758 | ispreload = ispreload ? 1 : 0; |
src/mess/video/smsvdp.c
| r1980 | r1981 | |
| 110 | 110 | } smsvdp; |
| 111 | 111 | |
| 112 | 112 | static TIMER_CALLBACK(smsvdp_display_callback); |
| 113 | | static void sms_refresh_line(bitmap_t *bitmap, int offsetx, int offsety, int line); |
| 113 | static void sms_refresh_line(running_machine *machine, bitmap_t *bitmap, int offsetx, int offsety, int line); |
| 114 | 114 | static void sms_update_palette(void); |
| 115 | 115 | |
| 116 | 116 | static void set_display_settings( running_machine *machine ) { |
| r1980 | r1981 | |
| 281 | 281 | /* Draw middle of the border */ |
| 282 | 282 | /* We need to do this through the regular drawing function so it will */ |
| 283 | 283 | /* be included in the gamegear scaling functions */ |
| 284 | | sms_refresh_line( tmpbitmap, LBORDER_START + LBORDER_X_PIXELS, vpos_limit - smsvdp.sms_frame_timing[ACTIVE_DISPLAY_V], vpos - ( vpos_limit - smsvdp.sms_frame_timing[ACTIVE_DISPLAY_V] ) ); |
| 284 | sms_refresh_line( machine, tmpbitmap, LBORDER_START + LBORDER_X_PIXELS, vpos_limit - smsvdp.sms_frame_timing[ACTIVE_DISPLAY_V], vpos - ( vpos_limit - smsvdp.sms_frame_timing[ACTIVE_DISPLAY_V] ) ); |
| 285 | 285 | return; |
| 286 | 286 | } |
| 287 | 287 | |
| r1980 | r1981 | |
| 323 | 323 | rec.min_x = LBORDER_START + LBORDER_X_PIXELS + 256; |
| 324 | 324 | rec.max_x = rec.min_x + RBORDER_X_PIXELS - 1; |
| 325 | 325 | fillbitmap( tmpbitmap, machine->pens[smsvdp.current_palette[BACKDROP_COLOR]], &rec ); |
| 326 | | sms_refresh_line( tmpbitmap, LBORDER_START + LBORDER_X_PIXELS, vpos_limit, vpos - vpos_limit ); |
| 326 | sms_refresh_line( machine, tmpbitmap, LBORDER_START + LBORDER_X_PIXELS, vpos_limit, vpos - vpos_limit ); |
| 327 | 327 | } |
| 328 | 328 | return; |
| 329 | 329 | } |
| r1980 | r1981 | |
| 347 | 347 | /* Draw middle of the border */ |
| 348 | 348 | /* We need to do this through the regular drawing function so it will */ |
| 349 | 349 | /* be included in the gamegear scaling functions */ |
| 350 | | sms_refresh_line( tmpbitmap, LBORDER_START + LBORDER_X_PIXELS, vpos_limit + smsvdp.sms_frame_timing[TOP_BORDER], vpos - ( vpos_limit + smsvdp.sms_frame_timing[TOP_BORDER] ) ); |
| 350 | sms_refresh_line( machine, tmpbitmap, LBORDER_START + LBORDER_X_PIXELS, vpos_limit + smsvdp.sms_frame_timing[TOP_BORDER], vpos - ( vpos_limit + smsvdp.sms_frame_timing[TOP_BORDER] ) ); |
| 351 | 351 | return; |
| 352 | 352 | } |
| 353 | 353 | } |
| r1980 | r1981 | |
| 913 | 913 | sms_refresh_tms9918_sprites( lineBuffer, line ); |
| 914 | 914 | } |
| 915 | 915 | |
| 916 | | static void sms_refresh_line( bitmap_t *bitmap, int pixelOffsetX, int pixelPlotY, int line ) { |
| 916 | static void sms_refresh_line( running_machine *machine, bitmap_t *bitmap, int pixelOffsetX, int pixelPlotY, int line ) { |
| 917 | 917 | int x; |
| 918 | 918 | int *blitLineBuffer = smsvdp.line_buffer; |
| 919 | 919 | |
| r1980 | r1981 | |
| 992 | 992 | line4 = smsvdp.line_buffer + ( ( ( myLine - 0 ) & 0x03 ) + 1 ) * 256; |
| 993 | 993 | |
| 994 | 994 | for( x = 0+48; x < 160+48; x++ ) { |
| 995 | | rgb_t c1 = Machine->pens[line1[x]]; |
| 996 | | rgb_t c2 = Machine->pens[line2[x]]; |
| 997 | | rgb_t c3 = Machine->pens[line3[x]]; |
| 998 | | rgb_t c4 = Machine->pens[line4[x]]; |
| 995 | rgb_t c1 = machine->pens[line1[x]]; |
| 996 | rgb_t c2 = machine->pens[line2[x]]; |
| 997 | rgb_t c3 = machine->pens[line3[x]]; |
| 998 | rgb_t c4 = machine->pens[line4[x]]; |
| 999 | 999 | *BITMAP_ADDR32( bitmap, pixelPlotY, pixelOffsetX + x) = |
| 1000 | 1000 | MAKE_RGB( ( RGB_RED(c1)/6 + RGB_RED(c2)/3 + RGB_RED(c3)/3 + RGB_RED(c4)/6 ), |
| 1001 | 1001 | ( RGB_GREEN(c1)/6 + RGB_GREEN(c2)/3 + RGB_GREEN(c3)/3 + RGB_GREEN(c4)/6 ), |
| r1980 | r1981 | |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | for( x = 0; x < 256; x++ ) { |
| 1010 | | *BITMAP_ADDR32( bitmap, pixelPlotY + line, pixelOffsetX + x) = Machine->pens[blitLineBuffer[x]]; |
| 1010 | *BITMAP_ADDR32( bitmap, pixelPlotY + line, pixelOffsetX + x) = machine->pens[blitLineBuffer[x]]; |
| 1011 | 1011 | } |
| 1012 | 1012 | } |
| 1013 | 1013 | |
src/mess/video/intv.c
| r1980 | r1981 | |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /* |
| 449 | | static void draw_background(bitmap_t *bitmap, int transparency) |
| 449 | static void draw_background(running_machine *machine, bitmap_t *bitmap, int transparency) |
| 450 | 450 | { |
| 451 | 451 | // First, draw the background |
| 452 | 452 | int offs = 0; |
| r1980 | r1981 | |
| 487 | 487 | if (colorb == 7) colorb = intv_color_stack[3]; |
| 488 | 488 | if (colorc == 7) colorc = intv_color_stack[3]; |
| 489 | 489 | if (colord == 7) colord = intv_color_stack[3]; |
| 490 | | plot_box(bitmap,col*16,row*16,8,8,Machine->pens[colora]); |
| 491 | | plot_box(bitmap,col*16+8,row*16,8,8,Machine->pens[colorb]); |
| 492 | | plot_box(bitmap,col*16,row*16+8,8,8,Machine->pens[colorc]); |
| 493 | | plot_box(bitmap,col*16+8,row*16+8,8,8,Machine->pens[colord]); |
| 490 | plot_box(bitmap,col*16,row*16,8,8,machine->pens[colora]); |
| 491 | plot_box(bitmap,col*16+8,row*16,8,8,machine->pens[colorb]); |
| 492 | plot_box(bitmap,col*16,row*16+8,8,8,machine->pens[colorc]); |
| 493 | plot_box(bitmap,col*16+8,row*16+8,8,8,machine->pens[colord]); |
| 494 | 494 | } |
| 495 | 495 | else // normal color stack mode |
| 496 | 496 | { |
| r1980 | r1981 | |
| 513 | 513 | code %= 64; // keep from going outside the array |
| 514 | 514 | //if (intv_gramdirtybytes[code] == 1) |
| 515 | 515 | { |
| 516 | | decodechar(Machine->gfx[1], |
| 516 | decodechar(machine->gfx[1], |
| 517 | 517 | code, |
| 518 | 518 | intv_gram, |
| 519 | | Machine->config->gfxdecodeinfo[1].gfxlayout); |
| 519 | machine->config->gfxdecodeinfo[1].gfxlayout); |
| 520 | 520 | intv_gramdirtybytes[code] = 0; |
| 521 | 521 | } |
| 522 | 522 | // Draw GRAM char |
| 523 | | drawgfx(bitmap,Machine->gfx[1], |
| 523 | drawgfx(bitmap,machine->gfx[1], |
| 524 | 524 | code, |
| 525 | 525 | bgcolor*16+fgcolor, |
| 526 | 526 | 0,0,col*16,row*16, |
| r1980 | r1981 | |
| 528 | 528 | |
| 529 | 529 | for(j=0;j<8;j++) |
| 530 | 530 | { |
| 531 | | //intv_plot_pixel(bitmap, col*16+j*2, row*16+7*2+1, Machine->pens[1]); |
| 532 | | //intv_plot_pixel(bitmap, col*16+j*2+1, row*16+7*2+1, Machine->pens[1]); |
| 531 | //intv_plot_pixel(bitmap, col*16+j*2, row*16+7*2+1, machine->pens[1]); |
| 532 | //intv_plot_pixel(bitmap, col*16+j*2+1, row*16+7*2+1, machine->pens[1]); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | } |
| 536 | 536 | else // read from grom |
| 537 | 537 | { |
| 538 | | drawgfx(bitmap,Machine->gfx[0], |
| 538 | drawgfx(bitmap,machine->gfx[0], |
| 539 | 539 | code, |
| 540 | 540 | bgcolor*16+fgcolor, |
| 541 | 541 | 0,0,col*16,row*16, |
| r1980 | r1981 | |
| 543 | 543 | |
| 544 | 544 | for(j=0;j<8;j++) |
| 545 | 545 | { |
| 546 | | //intv_plot_pixel(bitmap, col*16+j*2, row*16+7*2+1, Machine->pens[2]); |
| 547 | | //intv_plot_pixel(bitmap, col*16+j*2+1, row*16+7*2+1, Machine->pens[2]); |
| 546 | //intv_plot_pixel(bitmap, col*16+j*2, row*16+7*2+1, machine->pens[2]); |
| 547 | //intv_plot_pixel(bitmap, col*16+j*2+1, row*16+7*2+1, machine->pens[2]); |
| 548 | 548 | } |
| 549 | 549 | } |
| 550 | 550 | } |
| r1980 | r1981 | |
| 568 | 568 | { |
| 569 | 569 | //if (intv_gramdirtybytes[code] == 1) |
| 570 | 570 | { |
| 571 | | decodechar(Machine->gfx[1], |
| 571 | decodechar(machine->gfx[1], |
| 572 | 572 | code, |
| 573 | 573 | intv_gram, |
| 574 | | Machine->config->gfxdecodeinfo[1].gfxlayout); |
| 574 | machine->config->gfxdecodeinfo[1].gfxlayout); |
| 575 | 575 | intv_gramdirtybytes[code] = 0; |
| 576 | 576 | } |
| 577 | 577 | // Draw GRAM char |
| 578 | | drawgfx(bitmap,Machine->gfx[1], |
| 578 | drawgfx(bitmap,machine->gfx[1], |
| 579 | 579 | code, |
| 580 | 580 | bgcolor*16+fgcolor, |
| 581 | 581 | 0,0,col*16,row*16, |
| r1980 | r1981 | |
| 583 | 583 | } |
| 584 | 584 | else // read from GROM |
| 585 | 585 | { |
| 586 | | drawgfx(bitmap,Machine->gfx[0], |
| 586 | drawgfx(bitmap,machine->gfx[0], |
| 587 | 587 | code, |
| 588 | 588 | bgcolor*16+fgcolor, |
| 589 | 589 | 0,0,col*16,row*16, |
| r1980 | r1981 | |
| 598 | 598 | |
| 599 | 599 | /* TBD: need to handle sprites behind foreground? */ |
| 600 | 600 | /* |
| 601 | | static void draw_sprites(bitmap_t *bitmap, int behind_foreground) |
| 601 | static void draw_sprites(running_machine *machine, bitmap_t *bitmap, int behind_foreground) |
| 602 | 602 | { |
| 603 | 603 | int i; |
| 604 | 604 | int code; |
| r1980 | r1981 | |
| 616 | 616 | { |
| 617 | 617 | //if (intv_gramdirtybytes[code] == 1) |
| 618 | 618 | { |
| 619 | | decodechar(Machine->gfx[1], |
| 619 | decodechar(machine->gfx[1], |
| 620 | 620 | code, |
| 621 | 621 | intv_gram, |
| 622 | | Machine->config->gfxdecodeinfo[1].gfxlayout); |
| 622 | machine->config->gfxdecodeinfo[1].gfxlayout); |
| 623 | 623 | intv_gramdirtybytes[code] = 0; |
| 624 | 624 | } |
| 625 | 625 | // Draw GRAM char |
| 626 | | drawgfxzoom(bitmap,Machine->gfx[1], |
| 626 | drawgfxzoom(bitmap,machine->gfx[1], |
| 627 | 627 | code, |
| 628 | 628 | s->color, |
| 629 | 629 | s->xflip,s->yflip, |
| 630 | 630 | s->xpos*2-16,s->ypos*2-16, |
| 631 | | &Machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 631 | &machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 632 | 632 | 0x8000*s->xsize, 0x8000*s->ysize); |
| 633 | 633 | } |
| 634 | 634 | else |
| 635 | 635 | { |
| 636 | 636 | //if ((intv_gramdirtybytes[code] == 1) || (intv_gramdirtybytes[code+1] == 1)) |
| 637 | 637 | { |
| 638 | | decodechar(Machine->gfx[1], |
| 638 | decodechar(machine->gfx[1], |
| 639 | 639 | code, |
| 640 | 640 | intv_gram, |
| 641 | | Machine->config->gfxdecodeinfo[1].gfxlayout); |
| 642 | | decodechar(Machine->gfx[1], |
| 641 | machine->config->gfxdecodeinfo[1].gfxlayout); |
| 642 | decodechar(machine->gfx[1], |
| 643 | 643 | code+1, |
| 644 | 644 | intv_gram, |
| 645 | | Machine->config->gfxdecodeinfo[1].gfxlayout); |
| 645 | machine->config->gfxdecodeinfo[1].gfxlayout); |
| 646 | 646 | intv_gramdirtybytes[code] = 0; |
| 647 | 647 | intv_gramdirtybytes[code+1] = 0; |
| 648 | 648 | } |
| 649 | 649 | // Draw GRAM char |
| 650 | | drawgfxzoom(bitmap,Machine->gfx[1], |
| 650 | drawgfxzoom(bitmap,machine->gfx[1], |
| 651 | 651 | code, |
| 652 | 652 | s->color, |
| 653 | 653 | s->xflip,s->yflip, |
| 654 | 654 | s->xpos*2-16,s->ypos*2-16+(s->yflip)*s->ysize*8, |
| 655 | | &Machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 655 | &machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 656 | 656 | 0x8000*s->xsize, 0x8000*s->ysize); |
| 657 | | drawgfxzoom(bitmap,Machine->gfx[1], |
| 657 | drawgfxzoom(bitmap,machine->gfx[1], |
| 658 | 658 | code+1, |
| 659 | 659 | s->color, |
| 660 | 660 | s->xflip,s->yflip, |
| 661 | 661 | s->xpos*2-16,s->ypos*2-16+(1-s->yflip)*s->ysize*8, |
| 662 | | &Machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 662 | &machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 663 | 663 | 0x8000*s->xsize, 0x8000*s->ysize); |
| 664 | 664 | } |
| 665 | 665 | } |
| r1980 | r1981 | |
| 668 | 668 | if (s->yres == 1) |
| 669 | 669 | { |
| 670 | 670 | // Draw GROM char |
| 671 | | drawgfxzoom(bitmap,Machine->gfx[0], |
| 671 | drawgfxzoom(bitmap,machine->gfx[0], |
| 672 | 672 | code, |
| 673 | 673 | s->color, |
| 674 | 674 | s->xflip,s->yflip, |
| 675 | 675 | s->xpos*2-16,s->ypos*2-16, |
| 676 | | &Machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 676 | &machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 677 | 677 | 0x8000*s->xsize, 0x8000*s->ysize); |
| 678 | 678 | } |
| 679 | 679 | else |
| 680 | 680 | { |
| 681 | | drawgfxzoom(bitmap,Machine->gfx[0], |
| 681 | drawgfxzoom(bitmap,machine->gfx[0], |
| 682 | 682 | code, |
| 683 | 683 | s->color, |
| 684 | 684 | s->xflip,s->yflip, |
| 685 | 685 | s->xpos*2-16,s->ypos*2-16+(s->yflip)*s->ysize*8, |
| 686 | | &Machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 686 | &machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 687 | 687 | 0x8000*s->xsize, 0x8000*s->ysize); |
| 688 | | drawgfxzoom(bitmap,Machine->gfx[0], |
| 688 | drawgfxzoom(bitmap,machine->gfx[0], |
| 689 | 689 | code+1, |
| 690 | 690 | s->color, |
| 691 | 691 | s->xflip,s->yflip, |
| 692 | 692 | s->xpos*2-16,s->ypos*2-16+(1-s->yflip)*s->ysize*8, |
| 693 | | &Machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 693 | &machine->screen[0].visarea,TRANSPARENCY_PEN,0, |
| 694 | 694 | 0x8000*s->xsize, 0x8000*s->ysize); |
| 695 | 695 | } |
| 696 | 696 | } |
src/mess/video/ted7360.c
| r1980 | r1981 | |
| 546 | 546 | vic_dma_read_rom = dma_read_rom; |
| 547 | 547 | } |
| 548 | 548 | |
| 549 | | static void ted7360_set_interrupt (int mask) |
| 549 | static void ted7360_set_interrupt (running_machine *machine, int mask) |
| 550 | 550 | { |
| 551 | 551 | /* kernel itself polls for timer 2 shot (interrupt disabled!) |
| 552 | 552 | * when cassette loading */ |
| r1980 | r1981 | |
| 557 | 557 | { |
| 558 | 558 | DBG_LOG (1, "ted7360", ("irq start %.2x\n", mask)); |
| 559 | 559 | ted7360[9] |= 0x80; |
| 560 | | c16_interrupt (1); |
| 560 | c16_interrupt (machine, 1); |
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | ted7360[9] |= mask; |
| 564 | 564 | } |
| 565 | 565 | |
| 566 | | static void ted7360_clear_interrupt (int mask) |
| 566 | static void ted7360_clear_interrupt (running_machine *machine, int mask) |
| 567 | 567 | { |
| 568 | 568 | ted7360[9] &= ~mask; |
| 569 | 569 | if ((ted7360[9] & 0x80) && !(ted7360[9] & ted7360[0xa] & 0x5e)) |
| 570 | 570 | { |
| 571 | 571 | DBG_LOG (1, "ted7360", ("irq end %.2x\n", mask)); |
| 572 | 572 | ted7360[9] &= ~0x80; |
| 573 | | c16_interrupt (0); |
| 573 | c16_interrupt (machine, 0); |
| 574 | 574 | } |
| 575 | 575 | } |
| 576 | 576 | |
| r1980 | r1981 | |
| 590 | 590 | // prooved by digisound of several intros like eoroidpro |
| 591 | 591 | timer_adjust_oneshot(timer1, TEDTIME_IN_CYCLES (TIMER1), 1); |
| 592 | 592 | timer1_active = 1; |
| 593 | | ted7360_set_interrupt (8); |
| 593 | ted7360_set_interrupt (machine, 8); |
| 594 | 594 | break; |
| 595 | 595 | case 2: |
| 596 | 596 | timer_adjust_oneshot(timer2, TEDTIME_IN_CYCLES (0x10000), 2); |
| 597 | 597 | timer2_active = 1; |
| 598 | | ted7360_set_interrupt (0x10); |
| 598 | ted7360_set_interrupt (machine, 0x10); |
| 599 | 599 | break; |
| 600 | 600 | case 3: |
| 601 | 601 | timer_adjust_oneshot(timer3, TEDTIME_IN_CYCLES (0x10000), 3); |
| 602 | 602 | timer3_active = 1; |
| 603 | | ted7360_set_interrupt (0x40); |
| 603 | ted7360_set_interrupt (machine, 0x40); |
| 604 | 604 | break; |
| 605 | 605 | } |
| 606 | 606 | } |
| r1980 | r1981 | |
| 725 | 725 | break; |
| 726 | 726 | case 9: |
| 727 | 727 | if (data & 8) |
| 728 | | ted7360_clear_interrupt (8); |
| 728 | ted7360_clear_interrupt (machine, 8); |
| 729 | 729 | if (data & 0x10) |
| 730 | | ted7360_clear_interrupt (0x10); |
| 730 | ted7360_clear_interrupt (machine, 0x10); |
| 731 | 731 | if (data & 0x40) |
| 732 | | ted7360_clear_interrupt (0x40); |
| 732 | ted7360_clear_interrupt (machine, 0x40); |
| 733 | 733 | if (data & 2) |
| 734 | | ted7360_clear_interrupt (2); |
| 734 | ted7360_clear_interrupt (machine, 2); |
| 735 | 735 | break; |
| 736 | 736 | case 0xa: |
| 737 | 737 | old = data; |
| r1980 | r1981 | |
| 739 | 739 | #if 0 |
| 740 | 740 | ted7360[9] = (ted7360[9] & 0xa1) | (ted7360[9] & data & 0x5e); |
| 741 | 741 | if (ted7360[9] & 0x80) |
| 742 | | ted7360_clear_interrupt (0); |
| 742 | ted7360_clear_interrupt (machine, 0); |
| 743 | 743 | #endif |
| 744 | 744 | if ((data ^ old) & 1) |
| 745 | 745 | { |
| r1980 | r1981 | |
| 1220 | 1220 | if (rasterline == C16_2_RASTERLINE (RASTERLINE)) |
| 1221 | 1221 | { |
| 1222 | 1222 | ted7360_drawlines (machine, lastline, rasterline); |
| 1223 | | ted7360_set_interrupt (2); |
| 1223 | ted7360_set_interrupt (machine, 2); |
| 1224 | 1224 | } |
| 1225 | 1225 | } |
| 1226 | 1226 | |
src/mess/machine/dgn_beta.c
| r1980 | r1981 | |
| 120 | 120 | static void d_pia2_irq_a(int state); |
| 121 | 121 | static void d_pia2_irq_b(int state); |
| 122 | 122 | |
| 123 | | static void cpu0_recalc_irq(int state); |
| 124 | | static void cpu0_recalc_firq(int state); |
| 123 | static void cpu0_recalc_irq(running_machine *machine, int state); |
| 124 | static void cpu0_recalc_firq(running_machine *machine, int state); |
| 125 | 125 | |
| 126 | | static void cpu1_recalc_firq(int state); |
| 126 | static void cpu1_recalc_firq(running_machine *machine, int state); |
| 127 | 127 | |
| 128 | 128 | static int Keyboard[NoKeyrows]; /* Keyboard bit array */ |
| 129 | 129 | static int RowShifter; /* shift register to select row */ |
| r1980 | r1981 | |
| 649 | 649 | |
| 650 | 650 | static void d_pia0_irq_a(int state) |
| 651 | 651 | { |
| 652 | | cpu0_recalc_irq(state); |
| 652 | cpu0_recalc_irq(Machine, state); |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | static void d_pia0_irq_b(int state) |
| 656 | 656 | { |
| 657 | | cpu0_recalc_firq(state); |
| 657 | cpu0_recalc_firq(Machine, state); |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /* PIA #1 at $FC24-$FC27 I63 |
| r1980 | r1981 | |
| 741 | 741 | |
| 742 | 742 | static void d_pia1_irq_a(int state) |
| 743 | 743 | { |
| 744 | | cpu0_recalc_irq(state); |
| 744 | cpu0_recalc_irq(Machine, state); |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | static void d_pia1_irq_b(int state) |
| 748 | 748 | { |
| 749 | | cpu0_recalc_irq(state); |
| 749 | cpu0_recalc_irq(Machine, state); |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /* PIA #2 at FCC0-FCC3 I28 |
| r1980 | r1981 | |
| 845 | 845 | static void d_pia2_irq_a(int state) |
| 846 | 846 | { |
| 847 | 847 | logerror("PIA2 IRQ1 state=%02X\n",state); |
| 848 | | cpu0_recalc_irq(state); |
| 848 | cpu0_recalc_irq(Machine, state); |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | static void d_pia2_irq_b(int state) |
| 852 | 852 | { |
| 853 | 853 | logerror("PIA2 IRQ2 state=%02X\n",state); |
| 854 | | cpu0_recalc_irq(state); |
| 854 | cpu0_recalc_irq(Machine, state); |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /************************************ Recalculate CPU inturrupts ****************************/ |
| 858 | 858 | /* CPU 0 */ |
| 859 | | static void cpu0_recalc_irq(int state) |
| 859 | static void cpu0_recalc_irq(running_machine *machine, int state) |
| 860 | 860 | { |
| 861 | 861 | UINT8 pia0_irq_a = pia_get_irq_a(0); |
| 862 | 862 | UINT8 pia1_irq_a = pia_get_irq_a(1); |
| r1980 | r1981 | |
| 870 | 870 | else |
| 871 | 871 | IRQ = CLEAR_LINE; |
| 872 | 872 | |
| 873 | | cpunum_set_input_line(Machine, 0, M6809_IRQ_LINE, IRQ); |
| 873 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, IRQ); |
| 874 | 874 | LOG_INTS(("cpu0 IRQ : %d\n",IRQ)); |
| 875 | 875 | } |
| 876 | 876 | |
| 877 | | static void cpu0_recalc_firq(int state) |
| 877 | static void cpu0_recalc_firq(running_machine *machine, int state) |
| 878 | 878 | { |
| 879 | 879 | UINT8 pia0_irq_b = pia_get_irq_b(0); |
| 880 | 880 | UINT8 FIRQ; |
| r1980 | r1981 | |
| 884 | 884 | else |
| 885 | 885 | FIRQ = CLEAR_LINE; |
| 886 | 886 | |
| 887 | | cpunum_set_input_line(Machine, 0, M6809_FIRQ_LINE, FIRQ); |
| 887 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, FIRQ); |
| 888 | 888 | |
| 889 | 889 | LOG_INTS(("cpu0 FIRQ : %d\n",FIRQ)); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | /* CPU 1 */ |
| 893 | 893 | |
| 894 | | static void cpu1_recalc_firq(int state) |
| 894 | static void cpu1_recalc_firq(running_machine *machine, int state) |
| 895 | 895 | { |
| 896 | | cpunum_set_input_line(Machine, 1, M6809_FIRQ_LINE, state); |
| 896 | cpunum_set_input_line(machine, 1, M6809_FIRQ_LINE, state); |
| 897 | 897 | LOG_INTS(("cpu1 FIRQ : %d\n",state)); |
| 898 | 898 | } |
| 899 | 899 | |
| r1980 | r1981 | |
| 916 | 916 | break; |
| 917 | 917 | case WD17XX_DRQ_CLR: |
| 918 | 918 | /*wd2797_drq=CLEAR_LINE;*/ |
| 919 | | cpu1_recalc_firq(CLEAR_LINE); |
| 919 | cpu1_recalc_firq(machine, CLEAR_LINE); |
| 920 | 920 | break; |
| 921 | 921 | case WD17XX_DRQ_SET: |
| 922 | 922 | /*wd2797_drq=ASSERT_LINE;*/ |
| 923 | | cpu1_recalc_firq(ASSERT_LINE); |
| 923 | cpu1_recalc_firq(machine, ASSERT_LINE); |
| 924 | 924 | break; |
| 925 | 925 | } |
| 926 | 926 | |
| r1980 | r1981 | |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | 1016 | /* VBlank inturrupt */ |
| 1017 | | void dgn_beta_frame_interrupt (int data) |
| 1017 | void dgn_beta_frame_interrupt (running_machine *machine, int data) |
| 1018 | 1018 | { |
| 1019 | | running_machine *machine = Machine; |
| 1020 | | |
| 1021 | 1019 | /* Set PIA line, so it recognises inturrupt */ |
| 1022 | 1020 | if (!data) |
| 1023 | 1021 | { |
src/mess/machine/apple2gs.c
| r1980 | r1981 | |
| 310 | 310 | |
| 311 | 311 | |
| 312 | 312 | |
| 313 | | static void apple2gs_add_irq(UINT8 irq_mask) |
| 313 | static void apple2gs_add_irq(running_machine *machine, UINT8 irq_mask) |
| 314 | 314 | { |
| 315 | 315 | if ((apple2gs_pending_irqs & irq_mask) == 0x00) |
| 316 | 316 | { |
| r1980 | r1981 | |
| 318 | 318 | logerror("apple2gs_add_irq(): adding %s\n", apple2gs_irq_name(irq_mask)); |
| 319 | 319 | |
| 320 | 320 | apple2gs_pending_irqs |= irq_mask; |
| 321 | | cpunum_set_input_line(Machine, 0, G65816_LINE_IRQ, apple2gs_pending_irqs ? ASSERT_LINE : CLEAR_LINE); |
| 321 | cpunum_set_input_line(machine, 0, G65816_LINE_IRQ, apple2gs_pending_irqs ? ASSERT_LINE : CLEAR_LINE); |
| 322 | 322 | } |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
| 326 | 326 | |
| 327 | | static void apple2gs_remove_irq(UINT8 irq_mask) |
| 327 | static void apple2gs_remove_irq(running_machine *machine, UINT8 irq_mask) |
| 328 | 328 | { |
| 329 | 329 | if (apple2gs_pending_irqs & irq_mask) |
| 330 | 330 | { |
| r1980 | r1981 | |
| 332 | 332 | logerror("apple2gs_remove_irq(): removing %s\n", apple2gs_irq_name(irq_mask)); |
| 333 | 333 | |
| 334 | 334 | apple2gs_pending_irqs &= ~irq_mask; |
| 335 | | cpunum_set_input_line(Machine, 0, G65816_LINE_IRQ, apple2gs_pending_irqs ? ASSERT_LINE : CLEAR_LINE); |
| 335 | cpunum_set_input_line(machine, 0, G65816_LINE_IRQ, apple2gs_pending_irqs ? ASSERT_LINE : CLEAR_LINE); |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| r1980 | r1981 | |
| 340 | 340 | { |
| 341 | 341 | if (state) |
| 342 | 342 | { |
| 343 | | apple2gs_add_irq(IRQ_DOC); |
| 343 | apple2gs_add_irq(Machine, IRQ_DOC); |
| 344 | 344 | } |
| 345 | 345 | else |
| 346 | 346 | { |
| 347 | | apple2gs_remove_irq(IRQ_DOC); |
| 347 | apple2gs_remove_irq(Machine, IRQ_DOC); |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | |
| r1980 | r1981 | |
| 355 | 355 | if ((apple2gs_vgcint & 0x04) && !(apple2gs_vgcint & 0x40)) |
| 356 | 356 | { |
| 357 | 357 | apple2gs_vgcint |= 0xc0; |
| 358 | | apple2gs_add_irq(IRQ_VGC_SECOND); |
| 358 | apple2gs_add_irq(machine, IRQ_VGC_SECOND); |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| r1980 | r1981 | |
| 366 | 366 | if ((apple2gs_inten & 0x10) && !(apple2gs_intflag & 0x10)) |
| 367 | 367 | { |
| 368 | 368 | apple2gs_intflag |= 0x10; |
| 369 | | apple2gs_add_irq(IRQ_INTEN_QSECOND); |
| 369 | apple2gs_add_irq(machine, IRQ_INTEN_QSECOND); |
| 370 | 370 | } |
| 371 | 371 | } |
| 372 | 372 | |
| r1980 | r1981 | |
| 697 | 697 | |
| 698 | 698 | |
| 699 | 699 | |
| 700 | | static UINT8 adb_read_mousedata(void) |
| 700 | static UINT8 adb_read_mousedata(running_machine *machine) |
| 701 | 701 | { |
| 702 | 702 | UINT8 result = 0x00; |
| 703 | 703 | UINT8 absolute; |
| r1980 | r1981 | |
| 710 | 710 | absolute = apple2gs_mouse_y; |
| 711 | 711 | delta = apple2gs_mouse_dy; |
| 712 | 712 | adb_kmstatus &= ~0x82; |
| 713 | | apple2gs_remove_irq(IRQ_ADB_MOUSE); |
| 713 | apple2gs_remove_irq(machine, IRQ_ADB_MOUSE); |
| 714 | 714 | } |
| 715 | 715 | else |
| 716 | 716 | { |
| r1980 | r1981 | |
| 743 | 743 | |
| 744 | 744 | |
| 745 | 745 | |
| 746 | | static void adb_check_mouse(void) |
| 746 | static void adb_check_mouse(running_machine *machine) |
| 747 | 747 | { |
| 748 | 748 | UINT8 new_mouse_x, new_mouse_y; |
| 749 | 749 | |
| r1980 | r1981 | |
| 763 | 763 | adb_kmstatus |= 0x80; |
| 764 | 764 | adb_kmstatus &= ~0x02; |
| 765 | 765 | if (adb_kmstatus & 0x40) |
| 766 | | apple2gs_add_irq(IRQ_ADB_MOUSE); |
| 766 | apple2gs_add_irq(machine, IRQ_ADB_MOUSE); |
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | |
| 772 | 772 | |
| 773 | | static void apple2gs_set_scanint(UINT8 data) |
| 773 | static void apple2gs_set_scanint(running_machine *machine, UINT8 data) |
| 774 | 774 | { |
| 775 | 775 | /* second interrupt */ |
| 776 | 776 | if ((apple2gs_vgcint & 0x40) && !(data & 0x40)) |
| 777 | 777 | { |
| 778 | | apple2gs_remove_irq(IRQ_VGC_SECOND); |
| 778 | apple2gs_remove_irq(machine, IRQ_VGC_SECOND); |
| 779 | 779 | apple2gs_vgcint &= ~0xC0; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /* scanline interrupt */ |
| 783 | 783 | if ((apple2gs_vgcint & 0x20) && !(data & 0x20)) |
| 784 | 784 | { |
| 785 | | apple2gs_remove_irq(IRQ_VGC_SCANLINE); |
| 785 | apple2gs_remove_irq(machine, IRQ_VGC_SCANLINE); |
| 786 | 786 | apple2gs_vgcint &= ~0xA0; |
| 787 | 787 | } |
| 788 | 788 | |
| r1980 | r1981 | |
| 812 | 812 | if (scb & 0x40) |
| 813 | 813 | { |
| 814 | 814 | apple2gs_vgcint |= 0xa0; |
| 815 | | apple2gs_add_irq(IRQ_VGC_SCANLINE); |
| 815 | apple2gs_add_irq(machine, IRQ_VGC_SCANLINE); |
| 816 | 816 | } |
| 817 | 817 | } |
| 818 | 818 | |
| r1980 | r1981 | |
| 822 | 822 | if ((apple2gs_inten & 0x08) && !(apple2gs_intflag & 0x08)) |
| 823 | 823 | { |
| 824 | 824 | apple2gs_intflag |= 0x08; |
| 825 | | apple2gs_add_irq(IRQ_INTEN_VBL); |
| 825 | apple2gs_add_irq(machine, IRQ_INTEN_VBL); |
| 826 | 826 | } |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | /* check the mouse status */ |
| 830 | 830 | if ((scanline % 8) == 0) |
| 831 | 831 | { |
| 832 | | adb_check_mouse(); |
| 832 | adb_check_mouse(machine); |
| 833 | 833 | |
| 834 | 834 | /* call Apple II interrupt handler */ |
| 835 | 835 | if ((video_screen_get_vpos(0) % 8) == 7) |
| r1980 | r1981 | |
| 979 | 979 | break; |
| 980 | 980 | |
| 981 | 981 | case 0x24: /* C024 - MOUSEDATA */ |
| 982 | | result = adb_read_mousedata(); |
| 982 | result = adb_read_mousedata(machine); |
| 983 | 983 | break; |
| 984 | 984 | |
| 985 | 985 | case 0x25: /* C025 - KEYMODREG */ |
| r1980 | r1981 | |
| 1153 | 1153 | break; |
| 1154 | 1154 | |
| 1155 | 1155 | case 0x32: /* C032 - SCANINT */ |
| 1156 | | apple2gs_set_scanint(data); |
| 1156 | apple2gs_set_scanint(machine, data); |
| 1157 | 1157 | break; |
| 1158 | 1158 | |
| 1159 | 1159 | case 0x33: /* C033 - CLOCKDATA */ |
| r1980 | r1981 | |
| 1197 | 1197 | case 0x41: /* C041 - INTEN */ |
| 1198 | 1198 | apple2gs_inten = data & 0x1F; |
| 1199 | 1199 | if ((apple2gs_inten & 0x10) == 0x00) |
| 1200 | | apple2gs_remove_irq(IRQ_INTEN_QSECOND); |
| 1200 | apple2gs_remove_irq(machine, IRQ_INTEN_QSECOND); |
| 1201 | 1201 | if ((apple2gs_inten & 0x08) == 0x00) |
| 1202 | | apple2gs_remove_irq(IRQ_INTEN_VBL); |
| 1202 | apple2gs_remove_irq(machine, IRQ_INTEN_VBL); |
| 1203 | 1203 | break; |
| 1204 | 1204 | |
| 1205 | 1205 | case 0x47: /* C047 - CLRVBLINT */ |
| 1206 | 1206 | apple2gs_intflag &= ~0x18; |
| 1207 | | apple2gs_remove_irq(IRQ_INTEN_QSECOND); |
| 1208 | | apple2gs_remove_irq(IRQ_INTEN_VBL); |
| 1207 | apple2gs_remove_irq(machine, IRQ_INTEN_QSECOND); |
| 1208 | apple2gs_remove_irq(machine, IRQ_INTEN_VBL); |
| 1209 | 1209 | break; |
| 1210 | 1210 | |
| 1211 | 1211 | case 0x68: /* C068 - STATEREG */ |
src/mess/machine/mac.c
| r1980 | r1981 | |
| 138 | 138 | |
| 139 | 139 | static int scc_interrupt, via_interrupt; |
| 140 | 140 | |
| 141 | | static void mac_field_interrupts(void) |
| 141 | static void mac_field_interrupts(running_machine *machine) |
| 142 | 142 | { |
| 143 | 143 | if (scc_interrupt) |
| 144 | 144 | /* SCC interrupt */ |
| 145 | | cpunum_set_input_line(Machine, 0, 2, ASSERT_LINE); |
| 145 | cpunum_set_input_line(machine, 0, 2, ASSERT_LINE); |
| 146 | 146 | else if (via_interrupt) |
| 147 | 147 | /* VIA interrupt */ |
| 148 | | cpunum_set_input_line(Machine, 0, 1, ASSERT_LINE); |
| 148 | cpunum_set_input_line(machine, 0, 1, ASSERT_LINE); |
| 149 | 149 | else |
| 150 | 150 | /* clear all interrupts */ |
| 151 | | cpunum_set_input_line(Machine, 0, 7, CLEAR_LINE); |
| 151 | cpunum_set_input_line(machine, 0, 7, CLEAR_LINE); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | | static void set_scc_interrupt(int value) |
| 154 | static void set_scc_interrupt(running_machine *machine, int value) |
| 155 | 155 | { |
| 156 | 156 | scc_interrupt = value; |
| 157 | | mac_field_interrupts(); |
| 157 | mac_field_interrupts(machine); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | | static void set_via_interrupt(int value) |
| 160 | static void set_via_interrupt(running_machine *machine, int value) |
| 161 | 161 | { |
| 162 | 162 | via_interrupt = value; |
| 163 | | mac_field_interrupts(); |
| 163 | mac_field_interrupts(machine); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
| r1980 | r1981 | |
| 557 | 557 | |
| 558 | 558 | static int mouse_bit_x = 0, mouse_bit_y = 0; |
| 559 | 559 | |
| 560 | | static void mouse_callback(void) |
| 560 | static void mouse_callback(running_machine *machine) |
| 561 | 561 | { |
| 562 | 562 | static int last_mx = 0, last_my = 0; |
| 563 | 563 | static int count_x = 0, count_y = 0; |
| r1980 | r1981 | |
| 631 | 631 | |
| 632 | 632 | if (x_needs_update || y_needs_update) |
| 633 | 633 | /* assert Port B External Interrupt on the SCC */ |
| 634 | | mac_scc_mouse_irq( x_needs_update, y_needs_update ); |
| 634 | mac_scc_mouse_irq( machine, x_needs_update, y_needs_update ); |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /* ************************************************************************* |
| r1980 | r1981 | |
| 716 | 716 | |
| 717 | 717 | static void mac_scc_ack(void) |
| 718 | 718 | { |
| 719 | | set_scc_interrupt(0); |
| 719 | set_scc_interrupt(Machine, 0); |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | |
| 723 | 723 | |
| 724 | | void mac_scc_mouse_irq( int x, int y) |
| 724 | void mac_scc_mouse_irq(running_machine *machine, int x, int y) |
| 725 | 725 | { |
| 726 | 726 | static int last_was_x = 0; |
| 727 | 727 | |
| r1980 | r1981 | |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | //cpunum_set_input_line(machine, 0, 2, ASSERT_LINE); |
| 746 | | set_scc_interrupt(1); |
| 746 | set_scc_interrupt(machine, 1); |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | |
| r1980 | r1981 | |
| 1249 | 1249 | { |
| 1250 | 1250 | /* interrupt the 68k (level 1) */ |
| 1251 | 1251 | //cpunum_set_input_line(machine, 0, 1, state); |
| 1252 | | set_via_interrupt(state); |
| 1252 | set_via_interrupt(Machine, state); |
| 1253 | 1253 | } |
| 1254 | 1254 | |
| 1255 | 1255 | READ16_HANDLER ( mac_via_r ) |
| r1980 | r1981 | |
| 1471 | 1471 | |
| 1472 | 1472 | /* check for mouse changes at 10 irqs per frame */ |
| 1473 | 1473 | if (!(scanline % 10)) |
| 1474 | | mouse_callback(); |
| 1474 | mouse_callback(machine); |
| 1475 | 1475 | |
| 1476 | 1476 | timer_adjust_oneshot(mac_scanline_timer, video_screen_get_time_until_pos(0, (scanline+1) % MAC_V_TOTAL, 0), 0); |
| 1477 | 1477 | |
src/mess/machine/mc6850.c
| r1980 | r1981 | |
| 11 | 11 | **********************************************************************/ |
| 12 | 12 | |
| 13 | 13 | #include "driver.h" |
| 14 | | #include "deprecat.h" |
| 15 | 14 | #include "mc6850.h" |
| 16 | 15 | |
| 17 | 16 | struct acia6850 |
| r1980 | r1981 | |
| 36 | 35 | { |
| 37 | 36 | } |
| 38 | 37 | |
| 39 | | int acia6850_read (int which, int offset) |
| 38 | int acia6850_read (running_machine *machine, int which, int offset) |
| 40 | 39 | { |
| 41 | 40 | struct acia6850 *currptr = acia + which; |
| 42 | 41 | int val = 0; |
| r1980 | r1981 | |
| 45 | 44 | { |
| 46 | 45 | case ACIA_6850_CTRL: |
| 47 | 46 | if ((*(*currptr).intf).in_status_func) |
| 48 | | val = (*(*currptr).intf).in_status_func(Machine, 0); |
| 47 | val = (*(*currptr).intf).in_status_func(machine, 0); |
| 49 | 48 | break; |
| 50 | 49 | case ACIA_6850_DATA: |
| 51 | 50 | if ((*(*currptr).intf).in_recv_func) |
| 52 | | val = (*(*currptr).intf).in_recv_func(Machine, 0); |
| 51 | val = (*(*currptr).intf).in_recv_func(machine, 0); |
| 53 | 52 | break; |
| 54 | 53 | } |
| 55 | 54 | return (val); |
| 56 | 55 | } |
| 57 | 56 | |
| 58 | | void acia6850_write (int which, int offset, int data) |
| 57 | void acia6850_write (running_machine *machine, int which, int offset, int data) |
| 59 | 58 | { |
| 60 | 59 | struct acia6850 *currptr = acia + which; |
| 61 | 60 | |
| r1980 | r1981 | |
| 63 | 62 | { |
| 64 | 63 | case ACIA_6850_CTRL: |
| 65 | 64 | if ((*(*currptr).intf).out_status_func) |
| 66 | | (*(*currptr).intf).out_status_func(Machine, 0, data); |
| 65 | (*(*currptr).intf).out_status_func(machine, 0, data); |
| 67 | 66 | break; |
| 68 | 67 | case ACIA_6850_DATA: |
| 69 | 68 | if ((*(*currptr).intf).out_tran_func) |
| 70 | | (*(*currptr).intf).out_tran_func(Machine, 0, data); |
| 69 | (*(*currptr).intf).out_tran_func(machine, 0, data); |
| 71 | 70 | break; |
| 72 | 71 | } |
| 73 | 72 | } |
| 74 | 73 | |
| 75 | | READ8_HANDLER( acia6850_0_r ) { return acia6850_read (0, offset); } |
| 76 | | READ8_HANDLER( acia6850_1_r ) { return acia6850_read (1, offset); } |
| 77 | | READ8_HANDLER( acia6850_2_r ) { return acia6850_read (2, offset); } |
| 78 | | READ8_HANDLER( acia6850_3_r ) { return acia6850_read (3, offset); } |
| 74 | READ8_HANDLER( acia6850_0_r ) { return acia6850_read (machine, 0, offset); } |
| 75 | READ8_HANDLER( acia6850_1_r ) { return acia6850_read (machine, 1, offset); } |
| 76 | READ8_HANDLER( acia6850_2_r ) { return acia6850_read (machine, 2, offset); } |
| 77 | READ8_HANDLER( acia6850_3_r ) { return acia6850_read (machine, 3, offset); } |
| 79 | 78 | |
| 80 | | WRITE8_HANDLER( acia6850_0_w ) { acia6850_write (0, offset, data); } |
| 81 | | WRITE8_HANDLER( acia6850_1_w ) { acia6850_write (1, offset, data); } |
| 82 | | WRITE8_HANDLER( acia6850_2_w ) { acia6850_write (2, offset, data); } |
| 83 | | WRITE8_HANDLER( acia6850_3_w ) { acia6850_write (3, offset, data); } |
| 79 | WRITE8_HANDLER( acia6850_0_w ) { acia6850_write (machine, 0, offset, data); } |
| 80 | WRITE8_HANDLER( acia6850_1_w ) { acia6850_write (machine, 1, offset, data); } |
| 81 | WRITE8_HANDLER( acia6850_2_w ) { acia6850_write (machine, 2, offset, data); } |
| 82 | WRITE8_HANDLER( acia6850_3_w ) { acia6850_write (machine, 3, offset, data); } |
| 84 | 83 | |
| 85 | 84 | |
| 86 | 85 | |
src/mess/machine/coco.c
| r1980 | r1981 | |
| 706 | 706 | COCO3_INT_ALL = 0x3f |
| 707 | 707 | }; |
| 708 | 708 | |
| 709 | | static void d_recalc_irq(void) |
| 709 | static void d_recalc_irq(running_machine *machine) |
| 710 | 710 | { |
| 711 | 711 | UINT8 pia0_irq_a = pia_get_irq_a(0); |
| 712 | 712 | UINT8 pia0_irq_b = pia_get_irq_b(0); |
| 713 | 713 | |
| 714 | 714 | if (pia0_irq_a || pia0_irq_b) |
| 715 | | cpunum_set_input_line(Machine, 0, M6809_IRQ_LINE, ASSERT_LINE); |
| 715 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, ASSERT_LINE); |
| 716 | 716 | else |
| 717 | | cpunum_set_input_line(Machine, 0, M6809_IRQ_LINE, CLEAR_LINE); |
| 717 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, CLEAR_LINE); |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | | static void d_recalc_firq(void) |
| 720 | static void d_recalc_firq(running_machine *machine) |
| 721 | 721 | { |
| 722 | 722 | UINT8 pia1_firq_a = pia_get_irq_a(1); |
| 723 | 723 | UINT8 pia1_firq_b = pia_get_irq_b(1); |
| r1980 | r1981 | |
| 725 | 725 | UINT8 pia2_firq_b = pia_get_irq_b(2); |
| 726 | 726 | |
| 727 | 727 | if (pia1_firq_a || pia1_firq_b || pia2_firq_a || pia2_firq_b) |
| 728 | | cpunum_set_input_line(Machine, 0, M6809_FIRQ_LINE, ASSERT_LINE); |
| 728 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, ASSERT_LINE); |
| 729 | 729 | else |
| 730 | | cpunum_set_input_line(Machine, 0, M6809_FIRQ_LINE, CLEAR_LINE); |
| 730 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, CLEAR_LINE); |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | | static void coco3_recalc_irq(void) |
| 733 | static void coco3_recalc_irq(running_machine *machine) |
| 734 | 734 | { |
| 735 | 735 | if ((coco3_gimereg[0] & 0x20) && gime_irq) |
| 736 | | cpunum_set_input_line(Machine, 0, M6809_IRQ_LINE, ASSERT_LINE); |
| 736 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, ASSERT_LINE); |
| 737 | 737 | else |
| 738 | | d_recalc_irq(); |
| 738 | d_recalc_irq(machine); |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | | static void coco3_recalc_firq(void) |
| 741 | static void coco3_recalc_firq(running_machine *machine) |
| 742 | 742 | { |
| 743 | 743 | if ((coco3_gimereg[0] & 0x10) && gime_firq) |
| 744 | | cpunum_set_input_line(Machine, 0, M6809_FIRQ_LINE, ASSERT_LINE); |
| 744 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, ASSERT_LINE); |
| 745 | 745 | else |
| 746 | | d_recalc_firq(); |
| 746 | d_recalc_firq(machine); |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | static void d_pia0_irq_a(int state) |
| 750 | 750 | { |
| 751 | | d_recalc_irq(); |
| 751 | d_recalc_irq(Machine); |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | static void d_pia0_irq_b(int state) |
| 755 | 755 | { |
| 756 | | d_recalc_irq(); |
| 756 | d_recalc_irq(Machine); |
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | static void d_pia1_firq_a(int state) |
| 760 | 760 | { |
| 761 | | d_recalc_firq(); |
| 761 | d_recalc_firq(Machine); |
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | static void d_pia1_firq_b(int state) |
| 765 | 765 | { |
| 766 | | d_recalc_firq(); |
| 766 | d_recalc_firq(Machine); |
| 767 | 767 | } |
| 768 | 768 | |
| 769 | 769 | /* Dragon Alpha second PIA IRQ lines also cause FIRQ */ |
| 770 | 770 | static void d_pia2_firq_a(int state) |
| 771 | 771 | { |
| 772 | | d_recalc_firq(); |
| 772 | d_recalc_firq(Machine); |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | 775 | static void d_pia2_firq_b(int state) |
| 776 | 776 | { |
| 777 | | d_recalc_firq(); |
| 777 | d_recalc_firq(Machine); |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | static void coco3_pia0_irq_a(int state) |
| 781 | 781 | { |
| 782 | | coco3_recalc_irq(); |
| 782 | coco3_recalc_irq(Machine); |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | static void coco3_pia0_irq_b(int state) |
| 786 | 786 | { |
| 787 | | coco3_recalc_irq(); |
| 787 | coco3_recalc_irq(Machine); |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | static void coco3_pia1_firq_a(int state) |
| 791 | 791 | { |
| 792 | | coco3_recalc_firq(); |
| 792 | coco3_recalc_firq(Machine); |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | static void coco3_pia1_firq_b(int state) |
| 796 | 796 | { |
| 797 | | coco3_recalc_firq(); |
| 797 | coco3_recalc_firq(Machine); |
| 798 | 798 | } |
| 799 | 799 | |
| 800 | | static void coco3_raise_interrupt(UINT8 mask, int state) |
| 800 | static void coco3_raise_interrupt(running_machine *machine, UINT8 mask, int state) |
| 801 | 801 | { |
| 802 | 802 | int lowtohigh; |
| 803 | 803 | |
| r1980 | r1981 | |
| 813 | 813 | if ((coco3_gimereg[0] & 0x20) && (coco3_gimereg[2] & mask)) |
| 814 | 814 | { |
| 815 | 815 | gime_irq |= (coco3_gimereg[2] & mask); |
| 816 | | coco3_recalc_irq(); |
| 816 | coco3_recalc_irq(machine); |
| 817 | 817 | |
| 818 | 818 | if (LOG_INT_COCO3) |
| 819 | 819 | logerror("CoCo3 Interrupt: Raising IRQ; scanline=%i\n", video_screen_get_vpos(0)); |
| r1980 | r1981 | |
| 821 | 821 | if ((coco3_gimereg[0] & 0x10) && (coco3_gimereg[3] & mask)) |
| 822 | 822 | { |
| 823 | 823 | gime_firq |= (coco3_gimereg[3] & mask); |
| 824 | | coco3_recalc_firq(); |
| 824 | coco3_recalc_firq(machine); |
| 825 | 825 | |
| 826 | 826 | if (LOG_INT_COCO3) |
| 827 | 827 | logerror("CoCo3 Interrupt: Raising FIRQ; scanline=%i\n", video_screen_get_vpos(0)); |
| r1980 | r1981 | |
| 834 | 834 | void coco3_horizontal_sync_callback(int data) |
| 835 | 835 | { |
| 836 | 836 | pia_0_ca1_w(Machine, 0, data); |
| 837 | | coco3_raise_interrupt(COCO3_INT_HBORD, data); |
| 837 | coco3_raise_interrupt(Machine, COCO3_INT_HBORD, data); |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | |
| r1980 | r1981 | |
| 844 | 844 | pia_0_cb1_w(Machine, 0, data); |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | | void coco3_gime_field_sync_callback(void) |
| 847 | void coco3_gime_field_sync_callback(running_machine *machine) |
| 848 | 848 | { |
| 849 | 849 | /* the CoCo 3 VBORD interrupt triggers right after the display */ |
| 850 | | coco3_raise_interrupt(COCO3_INT_VBORD, 1); |
| 851 | | coco3_raise_interrupt(COCO3_INT_VBORD, 0); |
| 850 | coco3_raise_interrupt(machine, COCO3_INT_VBORD, 1); |
| 851 | coco3_raise_interrupt(machine, COCO3_INT_VBORD, 0); |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | |
| r1980 | r1981 | |
| 859 | 859 | |
| 860 | 860 | static TIMER_CALLBACK(d_recalc_interrupts) |
| 861 | 861 | { |
| 862 | | d_recalc_firq(); |
| 863 | | d_recalc_irq(); |
| 862 | d_recalc_firq(machine); |
| 863 | d_recalc_irq(machine); |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | static TIMER_CALLBACK(coco3_recalc_interrupts) |
| 867 | 867 | { |
| 868 | | coco3_recalc_firq(); |
| 869 | | coco3_recalc_irq(); |
| 868 | coco3_recalc_firq(machine); |
| 869 | coco3_recalc_irq(machine); |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | static timer_fired_func recalc_interrupts; |
| 873 | 873 | |
| 874 | | void coco_set_halt_line(int halt_line) |
| 874 | #ifdef UNUSED_FUNCTION |
| 875 | void coco_set_halt_line(running_machine *machine, int halt_line) |
| 875 | 876 | { |
| 876 | 877 | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, halt_line); |
| 877 | 878 | if (halt_line == CLEAR_LINE) |
| 878 | 879 | timer_set(ATTOTIME_IN_CYCLES(1,0), NULL, 0, recalc_interrupts); |
| 879 | 880 | } |
| 881 | #endif |
| 880 | 882 | |
| 881 | | |
| 882 | 883 | /*************************************************************************** |
| 883 | 884 | Input device abstractions |
| 884 | 885 | ***************************************************************************/ |
| r1980 | r1981 | |
| 1336 | 1337 | /* the CoCo 3 keyboard update routine must also check for the GIME EI1 interrupt */ |
| 1337 | 1338 | UINT8 porta; |
| 1338 | 1339 | porta = coco_update_keyboard(); |
| 1339 | | coco3_raise_interrupt(COCO3_INT_EI1, ((porta & 0x7F) == 0x7F) ? CLEAR_LINE : ASSERT_LINE); |
| 1340 | coco3_raise_interrupt(Machine, COCO3_INT_EI1, ((porta & 0x7F) == 0x7F) ? CLEAR_LINE : ASSERT_LINE); |
| 1340 | 1341 | return porta; |
| 1341 | 1342 | } |
| 1342 | 1343 | |
| r1980 | r1981 | |
| 2052 | 2053 | { |
| 2053 | 2054 | coco3_timer_reset(); |
| 2054 | 2055 | coco3_vh_blink(); |
| 2055 | | coco3_raise_interrupt(COCO3_INT_TMR, 1); |
| 2056 | | coco3_raise_interrupt(COCO3_INT_TMR, 0); |
| 2056 | coco3_raise_interrupt(machine, COCO3_INT_TMR, 1); |
| 2057 | coco3_raise_interrupt(machine, COCO3_INT_TMR, 0); |
| 2057 | 2058 | } |
| 2058 | 2059 | |
| 2059 | 2060 | |
| r1980 | r1981 | |
| 2272 | 2273 | result = gime_irq; |
| 2273 | 2274 | if (result) { |
| 2274 | 2275 | gime_irq = 0; |
| 2275 | | coco3_recalc_irq(); |
| 2276 | coco3_recalc_irq(machine); |
| 2276 | 2277 | } |
| 2277 | 2278 | break; |
| 2278 | 2279 | |
| r1980 | r1981 | |
| 2280 | 2281 | result = gime_firq; |
| 2281 | 2282 | if (result) { |
| 2282 | 2283 | gime_firq = 0; |
| 2283 | | coco3_recalc_firq(); |
| 2284 | coco3_recalc_firq(machine); |
| 2284 | 2285 | } |
| 2285 | 2286 | break; |
| 2286 | 2287 | |
| r1980 | r1981 | |
| 2596 | 2597 | static TIMER_CALLBACK(coco3_cart_timer_proc) |
| 2597 | 2598 | { |
| 2598 | 2599 | int data = param; |
| 2599 | | coco3_raise_interrupt(COCO3_INT_EI0, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE); |
| 2600 | coco3_raise_interrupt(machine, COCO3_INT_EI0, (data & 0x01) ? ASSERT_LINE : CLEAR_LINE); |
| 2600 | 2601 | coco_cart_timer_w(machine, data); |
| 2601 | 2602 | } |
| 2602 | 2603 | |
src/mess/machine/concept.c
| r1980 | r1981 | |
| 82 | 82 | write8_machine_func rom_write; |
| 83 | 83 | } expansion_slots[4]; |
| 84 | 84 | |
| 85 | | static void concept_fdc_init(int slot); |
| 85 | static void concept_fdc_init(running_machine *machine, int slot); |
| 86 | 86 | static void concept_hdc_init(int slot); |
| 87 | 87 | |
| 88 | 88 | MACHINE_START(concept) |
| r1980 | r1981 | |
| 97 | 97 | |
| 98 | 98 | /* initialize clock interface */ |
| 99 | 99 | clock_enable = 0/*1*/; |
| 100 | | mm58274c_init(0, 0); |
| 100 | mm58274c_init(machine, 0, 0); |
| 101 | 101 | |
| 102 | 102 | /* clear keyboard interface state */ |
| 103 | 103 | KeyQueueHead = KeyQueueLen = 0; |
| r1980 | r1981 | |
| 107 | 107 | memset(expansion_slots, 0, sizeof(expansion_slots)); |
| 108 | 108 | |
| 109 | 109 | concept_hdc_init(1); /* Flat cable Hard Disk Controller in Slot 2 */ |
| 110 | | concept_fdc_init(2); /* Floppy Disk Controller in Slot 3 */ |
| 110 | concept_fdc_init(machine, 2); /* Floppy Disk Controller in Slot 3 */ |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | static void install_expansion_slot(int slot, |
| r1980 | r1981 | |
| 142 | 142 | return 0; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | | static void concept_set_interrupt(int level, int state) |
| 145 | static void concept_set_interrupt(running_machine *machine, int level, int state) |
| 146 | 146 | { |
| 147 | 147 | int interrupt_mask; |
| 148 | 148 | int final_level; |
| r1980 | r1981 | |
| 157 | 157 | |
| 158 | 158 | if (final_level) |
| 159 | 159 | /* assert interrupt */ |
| 160 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_1+final_level-1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 160 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_1+final_level-1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 161 | 161 | else |
| 162 | 162 | /* clear all interrupts */ |
| 163 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 163 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | INLINE void post_in_KeyQueue(int keycode) |
| r1980 | r1981 | |
| 169 | 169 | KeyQueueLen++; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | | static void poll_keyboard(void) |
| 172 | static void poll_keyboard(running_machine *machine) |
| 173 | 173 | { |
| 174 | 174 | UINT32 keystate; |
| 175 | 175 | UINT32 key_transitions; |
| r1980 | r1981 | |
| 201 | 201 | KeyStateSave[i] &= ~ (1 << j); |
| 202 | 202 | |
| 203 | 203 | post_in_KeyQueue(keycode); |
| 204 | | concept_set_interrupt(KEYINT_level, 1); |
| 204 | concept_set_interrupt(machine, KEYINT_level, 1); |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | } |
| r1980 | r1981 | |
| 210 | 210 | |
| 211 | 211 | INTERRUPT_GEN( concept_interrupt ) |
| 212 | 212 | { |
| 213 | | poll_keyboard(); |
| 213 | poll_keyboard(machine); |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /* |
| r1980 | r1981 | |
| 276 | 276 | */ |
| 277 | 277 | static void via_irq_func(int state) |
| 278 | 278 | { |
| 279 | | concept_set_interrupt(TIMINT_level, state); |
| 279 | concept_set_interrupt(Machine, TIMINT_level, state); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | READ16_HANDLER(concept_io_r) |
| r1980 | r1981 | |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | if (!KeyQueueLen) |
| 365 | | concept_set_interrupt(KEYINT_level, 0); |
| 365 | concept_set_interrupt(machine, KEYINT_level, 0); |
| 366 | 366 | |
| 367 | 367 | return reply; |
| 368 | 368 | |
| r1980 | r1981 | |
| 574 | 574 | static WRITE8_HANDLER(concept_fdc_reg_w); |
| 575 | 575 | static READ8_HANDLER(concept_fdc_rom_r); |
| 576 | 576 | |
| 577 | | static void concept_fdc_init(int slot) |
| 577 | static void concept_fdc_init(running_machine *machine, int slot) |
| 578 | 578 | { |
| 579 | 579 | fdc_local_status = 0; |
| 580 | 580 | fdc_local_command = 0; |
| 581 | 581 | |
| 582 | | wd17xx_init(Machine, WD_TYPE_179X, fdc_callback, NULL); |
| 582 | wd17xx_init(machine, WD_TYPE_179X, fdc_callback, NULL); |
| 583 | 583 | |
| 584 | 584 | install_expansion_slot(slot, concept_fdc_reg_r, concept_fdc_reg_w, concept_fdc_rom_r, NULL); |
| 585 | 585 | } |
src/mess/machine/ins8154.c
| r1980 | r1981 | |
| 11 | 11 | ****************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | #include "driver.h" |
| 14 | | #include "deprecat.h" |
| 15 | 14 | #include "ins8154.h" |
| 16 | 15 | |
| 17 | 16 | #define MAX_INS8154 2 |
| r1980 | r1981 | |
| 49 | 48 | |
| 50 | 49 | |
| 51 | 50 | /* Config */ |
| 52 | | void ins8154_config(int which, const ins8154_interface *intf) |
| 51 | void ins8154_config(running_machine *machine, int which, const ins8154_interface *intf) |
| 53 | 52 | { |
| 54 | | assert_always(mame_get_phase(Machine) == MAME_PHASE_INIT, |
| 53 | assert_always(mame_get_phase(machine) == MAME_PHASE_INIT, |
| 55 | 54 | "Can only call ins8154_config at init time!"); |
| 56 | 55 | assert_always(which < MAX_INS8154, |
| 57 | 56 | "'which' exceeds maximum number of configured INS8154s!"); |
| r1980 | r1981 | |
| 77 | 76 | } |
| 78 | 77 | |
| 79 | 78 | |
| 80 | | static UINT8 ins8154_read(int which, offs_t offset) |
| 79 | static UINT8 ins8154_read(running_machine *machine, int which, offs_t offset) |
| 81 | 80 | { |
| 82 | 81 | ins8154_state *i = &ins8154[which]; |
| 83 | 82 | UINT8 val = 0xff; |
| r1980 | r1981 | |
| 93 | 92 | { |
| 94 | 93 | case 0x20: |
| 95 | 94 | if (i->intf->in_a_func) |
| 96 | | val = i->intf->in_a_func(Machine, 0); |
| 95 | val = i->intf->in_a_func(machine, 0); |
| 97 | 96 | i->in_a = val; |
| 98 | 97 | break; |
| 99 | 98 | |
| 100 | 99 | case 0x21: |
| 101 | 100 | if (i->intf->in_b_func) |
| 102 | | val = i->intf->in_b_func(Machine, 0); |
| 101 | val = i->intf->in_b_func(machine, 0); |
| 103 | 102 | i->in_b = val; |
| 104 | 103 | break; |
| 105 | 104 | |
| r1980 | r1981 | |
| 107 | 106 | if (offset < 0x08) |
| 108 | 107 | { |
| 109 | 108 | if (i->intf->in_a_func) |
| 110 | | val = (i->intf->in_a_func(Machine, 0) << (8 - offset)) & 0x80; |
| 109 | val = (i->intf->in_a_func(machine, 0) << (8 - offset)) & 0x80; |
| 111 | 110 | i->in_a = val; |
| 112 | 111 | } |
| 113 | 112 | else |
| 114 | 113 | { |
| 115 | 114 | if (i->intf->in_a_func) |
| 116 | | val = (i->intf->in_a_func(Machine, 0) << (8 - (offset >> 4))) & 0x80; |
| 115 | val = (i->intf->in_a_func(machine, 0) << (8 - (offset >> 4))) & 0x80; |
| 117 | 116 | i->in_b = val; |
| 118 | 117 | } |
| 119 | 118 | break; |
| r1980 | r1981 | |
| 123 | 122 | } |
| 124 | 123 | |
| 125 | 124 | |
| 126 | | static void ins8154_write_port_a(int which, int data) |
| 125 | static void ins8154_write_port_a(running_machine *machine, int which, int data) |
| 127 | 126 | { |
| 128 | 127 | ins8154_state *i = &ins8154[which]; |
| 129 | 128 | |
| r1980 | r1981 | |
| 133 | 132 | if (i->odra) |
| 134 | 133 | { |
| 135 | 134 | if (i->intf->out_a_func) |
| 136 | | i->intf->out_a_func(Machine, 0, (data & i->odra) | (i->odra ^ 0xff)); |
| 135 | i->intf->out_a_func(machine, 0, (data & i->odra) | (i->odra ^ 0xff)); |
| 137 | 136 | else |
| 138 | 137 | logerror("INS8154 chip #%d (%08x): Write to port A but no write handler defined!\n", |
| 139 | 138 | which, safe_activecpu_get_pc()); |
| r1980 | r1981 | |
| 141 | 140 | } |
| 142 | 141 | |
| 143 | 142 | |
| 144 | | static void ins8154_write_port_b(int which, int data) |
| 143 | static void ins8154_write_port_b(running_machine *machine, int which, int data) |
| 145 | 144 | { |
| 146 | 145 | ins8154_state *i = &ins8154[which]; |
| 147 | 146 | |
| r1980 | r1981 | |
| 151 | 150 | if (i->odrb) |
| 152 | 151 | { |
| 153 | 152 | if (i->intf->out_b_func) |
| 154 | | i->intf->out_b_func(Machine, 0, (data & i->odrb) | (i->odrb ^ 0xff)); |
| 153 | i->intf->out_b_func(machine, 0, (data & i->odrb) | (i->odrb ^ 0xff)); |
| 155 | 154 | else |
| 156 | 155 | logerror("INS8154 chip #%d (%08x): Write to port B but no write handler defined!\n", |
| 157 | 156 | which, safe_activecpu_get_pc()); |
| r1980 | r1981 | |
| 159 | 158 | } |
| 160 | 159 | |
| 161 | 160 | |
| 162 | | static void ins8154_write(int which, offs_t offset, UINT8 data) |
| 161 | static void ins8154_write(running_machine *machine, int which, offs_t offset, UINT8 data) |
| 163 | 162 | { |
| 164 | 163 | ins8154_state *i = &ins8154[which]; |
| 165 | 164 | |
| r1980 | r1981 | |
| 173 | 172 | switch (offset) |
| 174 | 173 | { |
| 175 | 174 | case 0x20: |
| 176 | | ins8154_write_port_a(which, data); |
| 175 | ins8154_write_port_a(machine, which, data); |
| 177 | 176 | break; |
| 178 | 177 | |
| 179 | 178 | case 0x21: |
| 180 | | ins8154_write_port_b(which, data); |
| 179 | ins8154_write_port_b(machine, which, data); |
| 181 | 180 | break; |
| 182 | 181 | |
| 183 | 182 | case 0x22: |
| r1980 | r1981 | |
| 204 | 203 | /* Set bit */ |
| 205 | 204 | if (offset < 0x08) |
| 206 | 205 | { |
| 207 | | ins8154_write_port_a(which, i->out_a |= offset & 0x07); |
| 206 | ins8154_write_port_a(machine, which, i->out_a |= offset & 0x07); |
| 208 | 207 | } |
| 209 | 208 | else |
| 210 | 209 | { |
| 211 | | ins8154_write_port_b(which, i->out_b |= (offset >> 4) & 0x07); |
| 210 | ins8154_write_port_b(machine, which, i->out_b |= (offset >> 4) & 0x07); |
| 212 | 211 | } |
| 213 | 212 | } |
| 214 | 213 | else |
| r1980 | r1981 | |
| 216 | 215 | /* Clear bit */ |
| 217 | 216 | if (offset < 0x08) |
| 218 | 217 | { |
| 219 | | ins8154_write_port_a(which, i->out_a & ~(offset & 0x07)); |
| 218 | ins8154_write_port_a(machine, which, i->out_a & ~(offset & 0x07)); |
| 220 | 219 | } |
| 221 | 220 | else |
| 222 | 221 | { |
| 223 | | ins8154_write_port_b(which, i->out_b & ~((offset >> 4) & 0x07)); |
| 224 | | } |
| 222 | ins8154_write_port_b(machine, which, i->out_b & ~((offset >> 4) & 0x07)); |
| 223 | } |
| 225 | 224 | } |
| 226 | 225 | |
| 227 | 226 | break; |
| r1980 | r1981 | |
| 232 | 231 | |
| 233 | 232 | /******************* Standard 8-bit CPU interfaces, D0-D7 *******************/ |
| 234 | 233 | |
| 235 | | WRITE8_HANDLER( ins8154_0_w ) { ins8154_write(0, offset, data); } |
| 236 | | WRITE8_HANDLER( ins8154_1_w ) { ins8154_write(1, offset, data); } |
| 234 | WRITE8_HANDLER( ins8154_0_w ) { ins8154_write(machine, 0, offset, data); } |
| 235 | WRITE8_HANDLER( ins8154_1_w ) { ins8154_write(machine, 1, offset, data); } |
| 237 | 236 | |
| 238 | | READ8_HANDLER( ins8154_0_r ) { return ins8154_read(0, offset); } |
| 239 | | READ8_HANDLER( ins8154_1_r ) { return ins8154_read(1, offset); } |
| 237 | READ8_HANDLER( ins8154_0_r ) { return ins8154_read(machine, 0, offset); } |
| 238 | READ8_HANDLER( ins8154_1_r ) { return ins8154_read(machine, 1, offset); } |
src/mess/machine/ti990.c
| r1980 | r1981 | |
| 18 | 18 | intlines = 0; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | | void ti990_set_int_line(int line, int state) |
| 21 | void ti990_set_int_line(running_machine *machine, int line, int state) |
| 22 | 22 | { |
| 23 | 23 | int level; |
| 24 | 24 | |
| r1980 | r1981 | |
| 32 | 32 | { |
| 33 | 33 | for (level = 0; ! (intlines & (1 << level)); level++) |
| 34 | 34 | ; |
| 35 | | cpunum_set_input_line_and_vector(Machine, 0, 0, ASSERT_LINE, level); /* interrupt it, baby */ |
| 35 | cpunum_set_input_line_and_vector(machine, 0, 0, ASSERT_LINE, level); /* interrupt it, baby */ |
| 36 | 36 | } |
| 37 | 37 | else |
| 38 | | cpunum_set_input_line(Machine, 0, 0, CLEAR_LINE); |
| 38 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | void ti990_set_int2(int state) |
| 42 | 42 | { |
| 43 | | ti990_set_int_line(2, state); |
| 43 | ti990_set_int_line(Machine, 2, state); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | void ti990_set_int3(int state) |
| 47 | 47 | { |
| 48 | | ti990_set_int_line(3, state); |
| 48 | ti990_set_int_line(Machine, 3, state); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | void ti990_set_int6(int state) |
| 52 | 52 | { |
| 53 | | ti990_set_int_line(6, state); |
| 53 | ti990_set_int_line(Machine, 6, state); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | void ti990_set_int7(int state) |
| 57 | 57 | { |
| 58 | | ti990_set_int_line(7, state); |
| 58 | ti990_set_int_line(Machine, 7, state); |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | void ti990_set_int9(int state) |
| 62 | 62 | { |
| 63 | | ti990_set_int_line(9, state); |
| 63 | ti990_set_int_line(Machine, 9, state); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | void ti990_set_int10(int state) |
| 67 | 67 | { |
| 68 | | ti990_set_int_line(10, state); |
| 68 | ti990_set_int_line(Machine, 10, state); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | void ti990_set_int13(int state) |
| 72 | 72 | { |
| 73 | | ti990_set_int_line(13, state); |
| 73 | ti990_set_int_line(Machine, 13, state); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /* |
| r1980 | r1981 | |
| 99 | 99 | void ti990_line_interrupt(void) |
| 100 | 100 | { |
| 101 | 101 | if (ckon_state) |
| 102 | | ti990_set_int_line(5, 1); |
| 102 | ti990_set_int_line(Machine, 5, 1); |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | void ti990_ckon_ckof_callback(int state) |
| 106 | 106 | { |
| 107 | 107 | ckon_state = state; |
| 108 | 108 | if (! ckon_state) |
| 109 | | ti990_set_int_line(5, 0); |
| 109 | ti990_set_int_line(Machine, 5, 0); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
src/mess/machine/vc1541.c
| r1980 | r1981 | |
| 959 | 959 | ADDRESS_MAP_END |
| 960 | 960 | |
| 961 | 961 | |
| 962 | | static void c1551x_write_data (TPI6525 *This, int data) |
| 962 | static void c1551x_write_data (running_machine *machine, TPI6525 *This, int data) |
| 963 | 963 | { |
| 964 | 964 | DBG_LOG(1, "c1551 cpu", ("%d write data %.2x\n", |
| 965 | 965 | cpu_getactivecpu (), data)); |
| 966 | 966 | #ifdef CPU_SYNC |
| 967 | 967 | cpu_sync(); |
| 968 | 968 | #endif |
| 969 | | tpi6525_0_port_a_w(Machine, 0,data); |
| 969 | tpi6525_0_port_a_w(machine, 0,data); |
| 970 | 970 | } |
| 971 | 971 | |
| 972 | | static int c1551x_read_data (TPI6525 *This) |
| 972 | static int c1551x_read_data (running_machine *machine, TPI6525 *This) |
| 973 | 973 | { |
| 974 | 974 | int data=0xff; |
| 975 | 975 | #ifdef CPU_SYNC |
| 976 | 976 | cpu_sync (); |
| 977 | 977 | #endif |
| 978 | | data=tpi6525_0_port_a_r(Machine, 0); |
| 978 | data=tpi6525_0_port_a_r(machine, 0); |
| 979 | 979 | DBG_LOG(2, "c1551 cpu",("%d read data %.2x\n", |
| 980 | 980 | cpu_getactivecpu (), data)); |
| 981 | 981 | return data; |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | | static void c1551x_write_handshake (TPI6525 *This, int data) |
| 984 | static void c1551x_write_handshake (running_machine *machine, TPI6525 *This, int data) |
| 985 | 985 | { |
| 986 | 986 | DBG_LOG(1, "c1551 cpu",("%d write handshake %.2x\n", |
| 987 | 987 | cpu_getactivecpu (), data)); |
| 988 | 988 | #ifdef CPU_SYNC |
| 989 | 989 | cpu_sync(); |
| 990 | 990 | #endif |
| 991 | | tpi6525_0_port_c_w(Machine, 0,data&0x40?0xff:0x7f); |
| 991 | tpi6525_0_port_c_w(machine, 0,data&0x40?0xff:0x7f); |
| 992 | 992 | } |
| 993 | 993 | |
| 994 | | static int c1551x_read_handshake (TPI6525 *This) |
| 994 | static int c1551x_read_handshake (running_machine *machine, TPI6525 *This) |
| 995 | 995 | { |
| 996 | 996 | int data=0xff; |
| 997 | 997 | #ifdef CPU_SYNC |
| 998 | 998 | cpu_sync(); |
| 999 | 999 | #endif |
| 1000 | | data=tpi6525_0_port_c_r(Machine, 0)&8?0x80:0; |
| 1000 | data=tpi6525_0_port_c_r(machine, 0)&8?0x80:0; |
| 1001 | 1001 | DBG_LOG(2, "c1551 cpu",("%d read handshake %.2x\n", |
| 1002 | 1002 | cpu_getactivecpu (), data)); |
| 1003 | 1003 | return data; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | | static int c1551x_read_status (TPI6525 *This) |
| 1006 | static int c1551x_read_status (running_machine *machine, TPI6525 *This) |
| 1007 | 1007 | { |
| 1008 | 1008 | int data=0xff; |
| 1009 | 1009 | #ifdef CPU_SYNC |
| 1010 | 1010 | cpu_sync(); |
| 1011 | 1011 | #endif |
| 1012 | | data=tpi6525_0_port_c_r(Machine, 0)&3; |
| 1012 | data=tpi6525_0_port_c_r(machine, 0)&3; |
| 1013 | 1013 | DBG_LOG(1, "c1551 cpu",("%d read status %.2x\n", |
| 1014 | 1014 | cpu_getactivecpu (), data)); |
| 1015 | 1015 | return data; |
| r1980 | r1981 | |
| 1017 | 1017 | |
| 1018 | 1018 | void c1551x_0_write_data (int data) |
| 1019 | 1019 | { |
| 1020 | | c1551x_write_data(tpi6525, data); |
| 1020 | c1551x_write_data(Machine, tpi6525, data); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | int c1551x_0_read_data (void) |
| 1024 | 1024 | { |
| 1025 | | return c1551x_read_data(tpi6525); |
| 1025 | return c1551x_read_data(Machine, tpi6525); |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | void c1551x_0_write_handshake (int data) |
| 1029 | 1029 | { |
| 1030 | | c1551x_write_handshake(tpi6525, data); |
| 1030 | c1551x_write_handshake(Machine, tpi6525, data); |
| 1031 | 1031 | } |
| 1032 | 1032 | |
| 1033 | 1033 | int c1551x_0_read_handshake (void) |
| 1034 | 1034 | { |
| 1035 | | return c1551x_read_handshake(tpi6525); |
| 1035 | return c1551x_read_handshake(Machine, tpi6525); |
| 1036 | 1036 | } |
| 1037 | 1037 | |
| 1038 | 1038 | int c1551x_0_read_status (void) |
| 1039 | 1039 | { |
| 1040 | | return c1551x_read_status(tpi6525); |
| 1040 | return c1551x_read_status(Machine, tpi6525); |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | MACHINE_DRIVER_START( cpu_vc1540 ) |
src/mess/machine/thomson.c
| r1980 | r1981 | |
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | |
| 60 | | static void thom_set_irq ( int line, int state ) |
| 60 | static void thom_set_irq ( running_machine *machine, int line, int state ) |
| 61 | 61 | { |
| 62 | 62 | int old = thom_irq; |
| 63 | 63 | |
| r1980 | r1981 | |
| 71 | 71 | if ( old && !thom_irq ) |
| 72 | 72 | LOG_IRQ(( "%f thom_set_irq: irq line down %i\n", attotime_to_double(timer_get_time()), line )); |
| 73 | 73 | |
| 74 | | cpunum_set_input_line(Machine, 0, M6809_IRQ_LINE, thom_irq ? ASSERT_LINE : CLEAR_LINE ); |
| 74 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, thom_irq ? ASSERT_LINE : CLEAR_LINE ); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | |
| 79 | | static void thom_set_firq ( int line, int state ) |
| 79 | static void thom_set_firq ( running_machine *machine, int line, int state ) |
| 80 | 80 | { |
| 81 | 81 | int old = thom_irq; |
| 82 | 82 | |
| r1980 | r1981 | |
| 90 | 90 | if ( old && !thom_firq ) |
| 91 | 91 | LOG_IRQ(( "%f thom_set_firq: firq line down %i\n", attotime_to_double(timer_get_time()), line )); |
| 92 | 92 | |
| 93 | | cpunum_set_input_line(Machine, 0, M6809_FIRQ_LINE, thom_firq ? ASSERT_LINE : CLEAR_LINE ); |
| 93 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, thom_firq ? ASSERT_LINE : CLEAR_LINE ); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
| 97 | 97 | |
| 98 | | static void thom_irq_reset ( void ) |
| 98 | static void thom_irq_reset ( running_machine *machine ) |
| 99 | 99 | { |
| 100 | 100 | thom_irq = 0; |
| 101 | 101 | thom_firq = 0; |
| 102 | | cpunum_set_input_line(Machine, 0, M6809_IRQ_LINE, CLEAR_LINE ); |
| 103 | | cpunum_set_input_line(Machine, 0, M6809_FIRQ_LINE, CLEAR_LINE ); |
| 102 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, CLEAR_LINE ); |
| 103 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, CLEAR_LINE ); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | |
| r1980 | r1981 | |
| 115 | 115 | |
| 116 | 116 | static void thom_irq_0 ( int state ) |
| 117 | 117 | { |
| 118 | | thom_set_irq ( 0, state ); |
| 118 | thom_set_irq ( Machine, 0, state ); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | static void thom_irq_1 ( int state ) |
| 122 | 122 | { |
| 123 | | thom_set_irq ( 1, state ); |
| 123 | thom_set_irq ( Machine, 1, state ); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | static void thom_irq_3 ( int state ) |
| 127 | 127 | { |
| 128 | | thom_set_irq ( 3, state ); |
| 128 | thom_set_irq ( Machine, 3, state ); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | static void thom_firq_1 ( int state ) |
| 132 | 132 | { |
| 133 | | thom_set_firq ( 1, state ); |
| 133 | thom_set_firq ( Machine, 1, state ); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | static void thom_firq_2 ( int state ) |
| 137 | 137 | { |
| 138 | | thom_set_firq ( 2, state ); |
| 138 | thom_set_firq ( Machine, 2, state ); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | #ifdef CHARDEV |
| 142 | 142 | static void thom_irq_4 ( int state ) |
| 143 | 143 | { |
| 144 | | thom_set_irq ( 4, state ); |
| 144 | thom_set_irq ( Machine, 4, state ); |
| 145 | 145 | } |
| 146 | 146 | #endif |
| 147 | 147 | |
| r1980 | r1981 | |
| 1253 | 1253 | LOG (( "to7: machine reset called\n" )); |
| 1254 | 1254 | |
| 1255 | 1255 | /* subsystems */ |
| 1256 | | thom_irq_reset(); |
| 1256 | thom_irq_reset(machine); |
| 1257 | 1257 | pia_reset(); |
| 1258 | 1258 | mc6846_reset(); |
| 1259 | 1259 | to7_game_reset(); |
| r1980 | r1981 | |
| 1485 | 1485 | LOG (( "to770: machine reset called\n" )); |
| 1486 | 1486 | |
| 1487 | 1487 | /* subsystems */ |
| 1488 | | thom_irq_reset(); |
| 1488 | thom_irq_reset(machine); |
| 1489 | 1489 | pia_reset(); |
| 1490 | 1490 | mc6846_reset(); |
| 1491 | 1491 | to7_game_reset(); |
| r1980 | r1981 | |
| 1833 | 1833 | LOG (( "mo5: machine reset called\n" )); |
| 1834 | 1834 | |
| 1835 | 1835 | /* subsystems */ |
| 1836 | | thom_irq_reset(); |
| 1836 | thom_irq_reset(machine); |
| 1837 | 1837 | pia_reset(); |
| 1838 | 1838 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0x5f ); |
| 1839 | 1839 | to7_game_reset(); |
| r1980 | r1981 | |
| 2107 | 2107 | { |
| 2108 | 2108 | static int old_bank = -1; |
| 2109 | 2109 | int bank = 0; |
| 2110 | | int slot = ( mc6846_get_output_port() >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2110 | int slot = ( mc6846_get_output_port(Machine) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2111 | 2111 | |
| 2112 | 2112 | /* reset cartridge read handler */ |
| 2113 | 2113 | memory_install_read8_handler( 0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x0003, 0, 0, (read8_machine_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| r1980 | r1981 | |
| 2153 | 2153 | /* write signal to 0000-1fff generates a bank switch */ |
| 2154 | 2154 | WRITE8_HANDLER ( to9_cartridge_w ) |
| 2155 | 2155 | { |
| 2156 | | int slot = ( mc6846_get_output_port() >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2156 | int slot = ( mc6846_get_output_port(machine) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2157 | 2157 | |
| 2158 | 2158 | if ( offset >= 0x2000 ) |
| 2159 | 2159 | return; |
| r1980 | r1981 | |
| 2182 | 2182 | static void to9_update_ram_bank ( void ) |
| 2183 | 2183 | { |
| 2184 | 2184 | static int old_bank = -1; |
| 2185 | | UINT8 port = mc6846_get_output_port(); |
| 2185 | UINT8 port = mc6846_get_output_port(Machine); |
| 2186 | 2186 | UINT8 portb = pia_get_port_b_z_mask( THOM_PIA_SYS ); |
| 2187 | 2187 | UINT8 disk = ((port >> 2) & 1) | ((port >> 5) & 2); /* bits 6,2: RAM bank */ |
| 2188 | 2188 | int bank; |
| r1980 | r1981 | |
| 2770 | 2770 | LOG (( "to9: machine reset called\n" )); |
| 2771 | 2771 | |
| 2772 | 2772 | /* subsystems */ |
| 2773 | | thom_irq_reset(); |
| 2773 | thom_irq_reset(machine); |
| 2774 | 2774 | pia_reset(); |
| 2775 | 2775 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe ); |
| 2776 | 2776 | mc6846_reset(); |
| r1980 | r1981 | |
| 3695 | 3695 | LOG (( "to8: machine reset called\n" )); |
| 3696 | 3696 | |
| 3697 | 3697 | /* subsystems */ |
| 3698 | | thom_irq_reset(); |
| 3698 | thom_irq_reset(machine); |
| 3699 | 3699 | pia_reset(); |
| 3700 | 3700 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe ); |
| 3701 | 3701 | mc6846_reset(); |
| r1980 | r1981 | |
| 3857 | 3857 | LOG (( "to9p: machine reset called\n" )); |
| 3858 | 3858 | |
| 3859 | 3859 | /* subsystems */ |
| 3860 | | thom_irq_reset(); |
| 3860 | thom_irq_reset(machine); |
| 3861 | 3861 | pia_reset(); |
| 3862 | 3862 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe ); |
| 3863 | 3863 | mc6846_reset(); |
| r1980 | r1981 | |
| 4430 | 4430 | LOG (( "mo6: machine reset called\n" )); |
| 4431 | 4431 | |
| 4432 | 4432 | /* subsystems */ |
| 4433 | | thom_irq_reset(); |
| 4433 | thom_irq_reset(machine); |
| 4434 | 4434 | pia_reset(); |
| 4435 | 4435 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0x75 ); |
| 4436 | 4436 | mo6_game_reset(); |
| r1980 | r1981 | |
| 4697 | 4697 | LOG (( "mo5nr: machine reset called\n" )); |
| 4698 | 4698 | |
| 4699 | 4699 | /* subsystems */ |
| 4700 | | thom_irq_reset(); |
| 4700 | thom_irq_reset(machine); |
| 4701 | 4701 | pia_reset(); |
| 4702 | 4702 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0x65 ); |
| 4703 | 4703 | mo5nr_game_reset(); |
src/mess/machine/lisa.c
| r1980 | r1981 | |
| 216 | 216 | Interrupt handling |
| 217 | 217 | */ |
| 218 | 218 | |
| 219 | | static void lisa_field_interrupts(void) |
| 219 | static void lisa_field_interrupts(running_machine *machine) |
| 220 | 220 | { |
| 221 | 221 | if (parity_error_pending) |
| 222 | 222 | return; /* don't touch anything... */ |
| 223 | 223 | |
| 224 | 224 | /*if (RSIR) |
| 225 | 225 | // serial interrupt |
| 226 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_6, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 226 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_6, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 227 | 227 | else if (int0) |
| 228 | 228 | // external interrupt |
| 229 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_5, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 229 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_5, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 230 | 230 | else if (int1) |
| 231 | 231 | // external interrupt |
| 232 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_4, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 232 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_4, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 233 | 233 | else if (int2) |
| 234 | 234 | // external interrupt |
| 235 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 235 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 236 | 236 | else*/ if (KBIR) |
| 237 | 237 | /* COPS VIA interrupt */ |
| 238 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 238 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 239 | 239 | else if (FDIR || VTIR) |
| 240 | 240 | /* floppy disk or VBl */ |
| 241 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 241 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 242 | 242 | else |
| 243 | 243 | /* clear all interrupts */ |
| 244 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 244 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | | static void set_parity_error_pending(int value) |
| 247 | static void set_parity_error_pending(running_machine *machine, int value) |
| 248 | 248 | { |
| 249 | 249 | #if 0 |
| 250 | 250 | /* does not work well due to bugs in 68k cores */ |
| 251 | 251 | parity_error_pending = value; |
| 252 | 252 | if (parity_error_pending) |
| 253 | 253 | { |
| 254 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 254 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 255 | 255 | } |
| 256 | 256 | else |
| 257 | 257 | { |
| r1980 | r1981 | |
| 261 | 261 | /* work-around... */ |
| 262 | 262 | if ((! parity_error_pending) && value) |
| 263 | 263 | { |
| 264 | | parity_error_pending = TRUE; |
| 265 | | cpunum_set_input_line_and_vector(Machine, 0, M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 264 | parity_error_pending = 1; |
| 265 | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 266 | 266 | } |
| 267 | 267 | else if (parity_error_pending && (! value)) |
| 268 | 268 | { |
| 269 | | parity_error_pending = FALSE; |
| 270 | | lisa_field_interrupts(); |
| 269 | parity_error_pending = 0; |
| 270 | lisa_field_interrupts(machine); |
| 271 | 271 | } |
| 272 | 272 | #endif |
| 273 | 273 | } |
| 274 | 274 | |
| 275 | | INLINE void set_VTIR(int value) |
| 275 | INLINE void set_VTIR(running_machine *machine, int value) |
| 276 | 276 | { |
| 277 | 277 | if (VTIR != value) |
| 278 | 278 | { |
| 279 | 279 | VTIR = value; |
| 280 | | lisa_field_interrupts(); |
| 280 | lisa_field_interrupts(machine); |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| r1980 | r1981 | |
| 519 | 519 | { |
| 520 | 520 | int command; |
| 521 | 521 | |
| 522 | | COPS_Ready = FALSE; |
| 522 | COPS_Ready = 0; |
| 523 | 523 | |
| 524 | 524 | /*logerror("read_COPS_command : trying to send data to VIA\n");*/ |
| 525 | 525 | COPS_send_data_if_possible(); |
| r1980 | r1981 | |
| 687 | 687 | /* this timer callback raises the COPS Ready line, which tells the COPS is about to read a command */ |
| 688 | 688 | static TIMER_CALLBACK(set_COPS_ready) |
| 689 | 689 | { |
| 690 | | COPS_Ready = TRUE; |
| 690 | COPS_Ready = 1; |
| 691 | 691 | |
| 692 | 692 | /* impulsion width : +/- 20us */ |
| 693 | 693 | timer_set(ATTOTIME_IN_USEC(20), NULL, 0, read_COPS_command); |
| r1980 | r1981 | |
| 751 | 751 | /* called at power-up */ |
| 752 | 752 | static void init_COPS(void) |
| 753 | 753 | { |
| 754 | | COPS_Ready = FALSE; |
| 754 | COPS_Ready = 0; |
| 755 | 755 | |
| 756 | 756 | /* read command every ms (don't know the real value) */ |
| 757 | 757 | timer_pulse(ATTOTIME_IN_MSEC(1), NULL, 0, set_COPS_ready); |
| r1980 | r1981 | |
| 819 | 819 | { |
| 820 | 820 | if (COPS_force_unplug) |
| 821 | 821 | { |
| 822 | | COPS_force_unplug = FALSE; |
| 822 | COPS_force_unplug = 0; |
| 823 | 823 | plug_keyboard(); |
| 824 | 824 | } |
| 825 | 825 | } |
| r1980 | r1981 | |
| 827 | 827 | { |
| 828 | 828 | if (! COPS_force_unplug) |
| 829 | 829 | { |
| 830 | | COPS_force_unplug = TRUE; |
| 830 | COPS_force_unplug = 1; |
| 831 | 831 | unplug_keyboard(); |
| 832 | 832 | //reset_COPS(); |
| 833 | 833 | } |
| r1980 | r1981 | |
| 844 | 844 | if (KBIR != val) |
| 845 | 845 | { |
| 846 | 846 | KBIR = val; |
| 847 | | lisa_field_interrupts(); |
| 847 | lisa_field_interrupts(Machine); |
| 848 | 848 | } |
| 849 | 849 | } |
| 850 | 850 | |
| r1980 | r1981 | |
| 1143 | 1143 | |
| 1144 | 1144 | /* init MMU */ |
| 1145 | 1145 | |
| 1146 | | setup = TRUE; |
| 1146 | setup = 1; |
| 1147 | 1147 | |
| 1148 | 1148 | seg = 0; |
| 1149 | 1149 | |
| 1150 | 1150 | /* init parity */ |
| 1151 | 1151 | |
| 1152 | | diag2 = FALSE; |
| 1153 | | test_parity = FALSE; |
| 1154 | | parity_error_pending = FALSE; |
| 1152 | diag2 = 0; |
| 1153 | test_parity = 0; |
| 1154 | parity_error_pending = 0; |
| 1155 | 1155 | |
| 1156 | 1156 | bad_parity_count = 0; |
| 1157 | 1157 | memset(bad_parity_table, 0, 0x40000); /* Clear */ |
| 1158 | 1158 | |
| 1159 | 1159 | /* init video */ |
| 1160 | 1160 | |
| 1161 | | VTMSK = FALSE; |
| 1162 | | set_VTIR(FALSE); |
| 1161 | VTMSK = 0; |
| 1162 | set_VTIR(machine, 0); |
| 1163 | 1163 | |
| 1164 | 1164 | video_address_latch = 0; |
| 1165 | 1165 | videoram_ptr = (UINT16 *) lisa_ram_ptr; |
| r1980 | r1981 | |
| 1296 | 1296 | |
| 1297 | 1297 | /* set VBI */ |
| 1298 | 1298 | if (VTMSK) |
| 1299 | | set_VTIR(TRUE); |
| 1299 | set_VTIR(machine, 1); |
| 1300 | 1300 | |
| 1301 | 1301 | /* do keyboard scan */ |
| 1302 | 1302 | scan_keyboard(); |
| r1980 | r1981 | |
| 1309 | 1309 | cannot support 2 floppy drives)... |
| 1310 | 1310 | */ |
| 1311 | 1311 | |
| 1312 | | INLINE void lisa_fdc_ttl_glue_access(offs_t offset) |
| 1312 | INLINE void lisa_fdc_ttl_glue_access(running_machine *machine, offs_t offset) |
| 1313 | 1313 | { |
| 1314 | 1314 | switch ((offset & 0x000E) >> 1) |
| 1315 | 1315 | { |
| r1980 | r1981 | |
| 1353 | 1353 | break; |
| 1354 | 1354 | case 7: |
| 1355 | 1355 | FDIR = offset & 1; /* Interrupt request to 68k */ |
| 1356 | | lisa_field_interrupts(); |
| 1356 | lisa_field_interrupts(machine); |
| 1357 | 1357 | break; |
| 1358 | 1358 | } |
| 1359 | 1359 | } |
| r1980 | r1981 | |
| 1369 | 1369 | break; |
| 1370 | 1370 | |
| 1371 | 1371 | case 1: /* TTL glue */ |
| 1372 | | lisa_fdc_ttl_glue_access(offset); |
| 1372 | lisa_fdc_ttl_glue_access(machine, offset); |
| 1373 | 1373 | answer = 0; /* ??? */ |
| 1374 | 1374 | break; |
| 1375 | 1375 | |
| r1980 | r1981 | |
| 1394 | 1394 | break; |
| 1395 | 1395 | |
| 1396 | 1396 | case 1: /* TTL glue */ |
| 1397 | | lisa_fdc_ttl_glue_access(offset); |
| 1397 | lisa_fdc_ttl_glue_access(machine, offset); |
| 1398 | 1398 | break; |
| 1399 | 1399 | |
| 1400 | 1400 | case 2: /* writes the PWM register */ |
| r1980 | r1981 | |
| 1546 | 1546 | && (bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))) |
| 1547 | 1547 | { |
| 1548 | 1548 | mem_err_addr_latch = address >> 5; |
| 1549 | | set_parity_error_pending(TRUE); |
| 1549 | set_parity_error_pending(machine, 1); |
| 1550 | 1550 | } |
| 1551 | 1551 | break; |
| 1552 | 1552 | |
| r1980 | r1981 | |
| 1563 | 1563 | && (bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))) |
| 1564 | 1564 | { |
| 1565 | 1565 | mem_err_addr_latch = address >> 5; |
| 1566 | | set_parity_error_pending(TRUE); |
| 1566 | set_parity_error_pending(machine, 1); |
| 1567 | 1567 | } |
| 1568 | 1568 | break; |
| 1569 | 1569 | |
| r1980 | r1981 | |
| 1879 | 1879 | * * |
| 1880 | 1880 | \**************************************************************************************/ |
| 1881 | 1881 | |
| 1882 | | INLINE void cpu_board_control_access(offs_t offset) |
| 1882 | INLINE void cpu_board_control_access(running_machine *machine, offs_t offset) |
| 1883 | 1883 | { |
| 1884 | 1884 | switch ((offset & 0x03ff) << 1) |
| 1885 | 1885 | { |
| r1980 | r1981 | |
| 1887 | 1887 | case 0x0000: /* Reset DIAG1 Latch */ |
| 1888 | 1888 | break; |
| 1889 | 1889 | case 0x0006: /* Set Diag2 Latch */ |
| 1890 | | diag2 = TRUE; |
| 1890 | diag2 = 1; |
| 1891 | 1891 | break; |
| 1892 | 1892 | case 0x0004: /* ReSet Diag2 Latch */ |
| 1893 | | diag2 = FALSE; |
| 1893 | diag2 = 0; |
| 1894 | 1894 | break; |
| 1895 | 1895 | case 0x000A: /* SEG1 Context Selection bit SET */ |
| 1896 | 1896 | /*logerror("seg bit 0 set\n");*/ |
| r1980 | r1981 | |
| 1909 | 1909 | seg &= ~2; |
| 1910 | 1910 | break; |
| 1911 | 1911 | case 0x0010: /* SETUP register SET */ |
| 1912 | | setup = TRUE; |
| 1912 | setup = 1; |
| 1913 | 1913 | break; |
| 1914 | 1914 | case 0x0012: /* SETUP register RESET */ |
| 1915 | | setup = FALSE; |
| 1915 | setup = 0; |
| 1916 | 1916 | break; |
| 1917 | 1917 | case 0x001A: /* Enable Vertical Retrace Interrupt */ |
| 1918 | | VTMSK = TRUE; |
| 1918 | VTMSK = 1; |
| 1919 | 1919 | break; |
| 1920 | 1920 | case 0x0018: /* Disable Vertical Retrace Interrupt */ |
| 1921 | | VTMSK = FALSE; |
| 1922 | | set_VTIR(FALSE); |
| 1921 | VTMSK = 0; |
| 1922 | set_VTIR(machine, 0); |
| 1923 | 1923 | break; |
| 1924 | 1924 | case 0x0016: /* Enable Soft Error Detect. */ |
| 1925 | 1925 | case 0x0014: /* Disable Soft Error Detect. */ |
| 1926 | 1926 | break; |
| 1927 | 1927 | case 0x001E: /* Enable Hard Error Detect */ |
| 1928 | | test_parity = TRUE; |
| 1928 | test_parity = 1; |
| 1929 | 1929 | break; |
| 1930 | 1930 | case 0x001C: /* Disable Hard Error Detect */ |
| 1931 | | test_parity = FALSE; |
| 1932 | | set_parity_error_pending(FALSE); |
| 1931 | test_parity = 0; |
| 1932 | set_parity_error_pending(machine, 0); |
| 1933 | 1933 | break; |
| 1934 | 1934 | } |
| 1935 | 1935 | } |
| r1980 | r1981 | |
| 2004 | 2004 | switch ((offset & 0x0C00) >> 10) |
| 2005 | 2005 | { |
| 2006 | 2006 | case 0x0: /* cpu board control */ |
| 2007 | | cpu_board_control_access(offset & 0x03ff); |
| 2007 | cpu_board_control_access(machine, offset & 0x03ff); |
| 2008 | 2008 | break; |
| 2009 | 2009 | |
| 2010 | 2010 | case 0x1: /* Video Address Latch */ |
| r1980 | r1981 | |
| 2094 | 2094 | switch ((offset & 0x0C00) >> 10) |
| 2095 | 2095 | { |
| 2096 | 2096 | case 0x0: /* cpu board control */ |
| 2097 | | cpu_board_control_access(offset & 0x03ff); |
| 2097 | cpu_board_control_access(machine, offset & 0x03ff); |
| 2098 | 2098 | break; |
| 2099 | 2099 | |
| 2100 | 2100 | case 0x1: /* Video Address Latch */ |
src/mess/machine/spectrum.c
| r1980 | r1981 | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | static unsigned long TapePosition = 0; |
| 40 | | static void spectrum_setup_sna(unsigned char *pSnapshot, unsigned long SnapshotSize); |
| 41 | | static void spectrum_setup_z80(unsigned char *pSnapshot, unsigned long SnapshotSize); |
| 42 | | static void spectrum_setup_sp(unsigned char *pSnapshot, unsigned long SnapshotSize); |
| 40 | static void spectrum_setup_sna(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize); |
| 41 | static void spectrum_setup_z80(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize); |
| 42 | static void spectrum_setup_sp(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize); |
| 43 | 43 | static int spectrum_setup_tap(offs_t address, UINT8 *snapshot_data, int snapshot_length); |
| 44 | 44 | |
| 45 | 45 | TIMEX_CART_TYPE timex_cart_type = TIMEX_CART_NONE; |
| r1980 | r1981 | |
| 110 | 110 | logerror("Invalid .SNA file size.\n"); |
| 111 | 111 | goto error; |
| 112 | 112 | } |
| 113 | | spectrum_setup_sna(snapshot_data, snapshot_size); |
| 113 | spectrum_setup_sna(Machine, snapshot_data, snapshot_size); |
| 114 | 114 | } |
| 115 | 115 | else if (!mame_stricmp(file_type, "sp")) |
| 116 | 116 | { |
| r1980 | r1981 | |
| 119 | 119 | logerror("Invalid .SP signature.\n"); |
| 120 | 120 | goto error; |
| 121 | 121 | } |
| 122 | | spectrum_setup_sp(snapshot_data, snapshot_size); |
| 122 | spectrum_setup_sp(Machine, snapshot_data, snapshot_size); |
| 123 | 123 | } |
| 124 | 124 | else |
| 125 | 125 | { |
| 126 | | spectrum_setup_z80(snapshot_data, snapshot_size); |
| 126 | spectrum_setup_z80(Machine, snapshot_data, snapshot_size); |
| 127 | 127 | } |
| 128 | 128 | free(snapshot_data); |
| 129 | 129 | logerror("Snapshot loaded - new PC = %04x\n", (unsigned) cpunum_get_reg(0, Z80_PC) & 0x0ffff); |
| r1980 | r1981 | |
| 394 | 394 | * 0 IFF1: 0=DI/1=EI |
| 395 | 395 | * |
| 396 | 396 | *******************************************************************/ |
| 397 | | void spectrum_setup_sp(unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 397 | void spectrum_setup_sp(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 398 | 398 | { |
| 399 | 399 | int i; |
| 400 | 400 | UINT8 lo, hi, data; |
| r1980 | r1981 | |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | data = (status & 0x10)>>4; |
| 492 | | cpunum_set_input_line(Machine, 0, 0, data); |
| 493 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_NMI, data); |
| 494 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, 0); |
| 492 | cpunum_set_input_line(machine, 0, 0, data); |
| 493 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, data); |
| 494 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, 0); |
| 495 | 495 | |
| 496 | 496 | spectrum_page_basicrom(); |
| 497 | 497 | |
| r1980 | r1981 | |
| 531 | 531 | * in which case it is included twice. |
| 532 | 532 | * |
| 533 | 533 | *******************************************************************/ |
| 534 | | void spectrum_setup_sna(unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 534 | void spectrum_setup_sna(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 535 | 535 | { |
| 536 | 536 | int i, j, usedbanks[8]; |
| 537 | 537 | long bank_offset; |
| r1980 | r1981 | |
| 592 | 592 | set_last_border_color(pSnapshot[26] & 0x07); |
| 593 | 593 | force_border_redraw(); |
| 594 | 594 | |
| 595 | | cpunum_set_input_line(Machine, 0, 0, data); |
| 596 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_NMI, data); |
| 597 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, 0); |
| 595 | cpunum_set_input_line(machine, 0, 0, data); |
| 596 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, data); |
| 597 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, 0); |
| 598 | 598 | |
| 599 | 599 | if (SnapshotSize == 49179) |
| 600 | 600 | /* 48K Snapshot */ |
| r1980 | r1981 | |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | 789 | /* now supports 48k & 128k .Z80 files */ |
| 790 | | void spectrum_setup_z80(unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 790 | void spectrum_setup_z80(running_machine *machine, unsigned char *pSnapshot, unsigned long SnapshotSize) |
| 791 | 791 | { |
| 792 | 792 | int i; |
| 793 | 793 | unsigned char lo, hi, data; |
| 794 | 794 | SPECTRUM_Z80_SNAPSHOT_TYPE z80_type; |
| 795 | | running_machine *machine = Machine; |
| 796 | 795 | |
| 797 | 796 | z80_type = spectrum_identify_z80(pSnapshot, SnapshotSize); |
| 798 | 797 | |
| r1980 | r1981 | |
| 804 | 803 | case SPECTRUM_Z80_SNAPSHOT_48K_OLD: |
| 805 | 804 | case SPECTRUM_Z80_SNAPSHOT_48K: |
| 806 | 805 | logerror("48K .Z80 file\n"); |
| 807 | | if (!strcmp(Machine->gamedrv->name,"ts2068")) |
| 806 | if (!strcmp(machine->gamedrv->name,"ts2068")) |
| 808 | 807 | logerror("48K .Z80 file in TS2068\n"); |
| 809 | 808 | break; |
| 810 | 809 | case SPECTRUM_Z80_SNAPSHOT_128K: |
| r1980 | r1981 | |
| 814 | 813 | logerror("Not a 48K .Z80 file\n"); |
| 815 | 814 | return; |
| 816 | 815 | } |
| 817 | | if (!strcmp(Machine->gamedrv->name,"ts2068")) |
| 816 | if (!strcmp(machine->gamedrv->name,"ts2068")) |
| 818 | 817 | { |
| 819 | 818 | logerror("Not a TS2068 .Z80 file\n"); |
| 820 | 819 | return; |
| 821 | 820 | } |
| 822 | 821 | break; |
| 823 | 822 | case SPECTRUM_Z80_SNAPSHOT_TS2068: |
| 824 | | logerror("TS2068 .Z80 file\n"); if (strcmp(Machine->gamedrv->name,"ts2068")) |
| 825 | | if (strcmp(Machine->gamedrv->name,"ts2068")) |
| 823 | logerror("TS2068 .Z80 file\n"); |
| 824 | if (strcmp(machine->gamedrv->name,"ts2068")) |
| 826 | 825 | logerror("Not a TS2068 machine\n"); |
| 827 | 826 | break; |
| 828 | 827 | case SPECTRUM_Z80_SNAPSHOT_SAMRAM: |
| r1980 | r1981 | |
| 901 | 900 | /* cpunum_set_reg(0, Z80_IRQ_STATE, 1); */ |
| 902 | 901 | } |
| 903 | 902 | |
| 904 | | cpunum_set_input_line(Machine, 0, 0, data); |
| 905 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_NMI, data); |
| 906 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, 0); |
| 903 | cpunum_set_input_line(machine, 0, 0, data); |
| 904 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, data); |
| 905 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, 0); |
| 907 | 906 | |
| 908 | 907 | /* IFF2 */ |
| 909 | 908 | if (pSnapshot[28] != 0) |
| r1980 | r1981 | |
| 950 | 949 | hi = pSnapshot[33] & 0x0ff; |
| 951 | 950 | cpunum_set_reg(0, Z80_PC, (hi << 8) | lo); |
| 952 | 951 | |
| 953 | | if ((z80_type == SPECTRUM_Z80_SNAPSHOT_128K) || ((z80_type == SPECTRUM_Z80_SNAPSHOT_TS2068) && !strcmp(Machine->gamedrv->name,"ts2068"))) |
| 952 | if ((z80_type == SPECTRUM_Z80_SNAPSHOT_128K) || ((z80_type == SPECTRUM_Z80_SNAPSHOT_TS2068) && !strcmp(machine->gamedrv->name,"ts2068"))) |
| 954 | 953 | { |
| 955 | 954 | /* Only set up sound registers for 128K machine or TS2068! */ |
| 956 | 955 | for (i = 0; i < 16; i++) |
| r1980 | r1981 | |
| 1032 | 1031 | spectrum_128_port_7ffd_data = (pSnapshot[35] & 0x0ff); |
| 1033 | 1032 | spectrum_update_paging(); |
| 1034 | 1033 | } |
| 1035 | | if ((z80_type == SPECTRUM_Z80_SNAPSHOT_48K) && !strcmp(Machine->gamedrv->name,"ts2068")) |
| 1034 | if ((z80_type == SPECTRUM_Z80_SNAPSHOT_48K) && !strcmp(machine->gamedrv->name,"ts2068")) |
| 1036 | 1035 | { |
| 1037 | 1036 | ts2068_port_f4_data = 0x03; |
| 1038 | 1037 | ts2068_port_ff_data = 0x00; |
| 1039 | 1038 | ts2068_update_memory(); |
| 1040 | 1039 | } |
| 1041 | | if (z80_type == SPECTRUM_Z80_SNAPSHOT_TS2068 && !strcmp(Machine->gamedrv->name,"ts2068")) |
| 1040 | if (z80_type == SPECTRUM_Z80_SNAPSHOT_TS2068 && !strcmp(machine->gamedrv->name,"ts2068")) |
| 1042 | 1041 | { |
| 1043 | 1042 | ts2068_port_f4_data = pSnapshot[35]; |
| 1044 | 1043 | ts2068_port_ff_data = pSnapshot[36]; |
src/mess/machine/c128.c
| r1980 | r1981 | |
| 12 | 12 | #include "driver.h" |
| 13 | 13 | #include "includes/c128.h" |
| 14 | 14 | #include "includes/c64.h" |
| 15 | | #include "deprecat.h" |
| 16 | 15 | |
| 17 | 16 | #include "cpu/m6502/m6502.h" |
| 18 | 17 | #include "sound/sid6581.h" |
| r1980 | r1981 | |
| 162 | 161 | } |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | | void c128_bankswitch_64 (int reset) |
| 164 | void c128_bankswitch_64 (running_machine *machine, int reset) |
| 166 | 165 | { |
| 167 | 166 | static int old, exrom, game; |
| 168 | 167 | int data, loram, hiram, charen; |
| r1980 | r1981 | |
| 219 | 218 | else |
| 220 | 219 | memory_set_bankptr(13, c64_memory + 0xd000); |
| 221 | 220 | } |
| 222 | | c128_set_m8502_read_handler(Machine, 0xd000, 0xdfff, rh); |
| 221 | c128_set_m8502_read_handler(machine, 0xd000, 0xdfff, rh); |
| 223 | 222 | |
| 224 | 223 | if (!c64_game && c64_exrom) |
| 225 | 224 | { |
| r1980 | r1981 | |
| 334 | 333 | #endif |
| 335 | 334 | } |
| 336 | 335 | |
| 337 | | static void c128_bankswitch_128 (int reset) |
| 336 | static void c128_bankswitch_128 (running_machine *machine, int reset) |
| 338 | 337 | { |
| 339 | 338 | read8_machine_func rh; |
| 340 | 339 | |
| r1980 | r1981 | |
| 359 | 358 | |
| 360 | 359 | memory_set_bankptr(12, c64_memory + 0xc000); |
| 361 | 360 | |
| 362 | | c128_bankswitch_64 (reset); |
| 361 | c128_bankswitch_64 (machine, reset); |
| 363 | 362 | } |
| 364 | 363 | else |
| 365 | 364 | { |
| r1980 | r1981 | |
| 415 | 414 | else |
| 416 | 415 | c128_ram_top = 0x10000; |
| 417 | 416 | |
| 418 | | c128_set_m8502_read_handler(Machine, 0xff00, 0xff04, c128_mmu8722_ff00_r); |
| 417 | c128_set_m8502_read_handler(machine, 0xff00, 0xff04, c128_mmu8722_ff00_r); |
| 419 | 418 | |
| 420 | 419 | if (MMU_IO_ON) |
| 421 | 420 | { |
| r1980 | r1981 | |
| 427 | 426 | c128_write_io = 0; |
| 428 | 427 | rh = MRA8_BANK13; |
| 429 | 428 | } |
| 430 | | c128_set_m8502_read_handler(Machine, 0xd000, 0xdfff, rh); |
| 429 | c128_set_m8502_read_handler(machine, 0xd000, 0xdfff, rh); |
| 431 | 430 | |
| 432 | 431 | if (MMU_RAM_HI) |
| 433 | 432 | { |
| r1980 | r1981 | |
| 500 | 499 | } |
| 501 | 500 | |
| 502 | 501 | |
| 503 | | static void c128_bankswitch (int reset) |
| 502 | static void c128_bankswitch (running_machine *machine, int reset) |
| 504 | 503 | { |
| 505 | 504 | if (mmu_cpu != MMU_CPU8502) |
| 506 | 505 | { |
| r1980 | r1981 | |
| 511 | 510 | memory_set_context(0); |
| 512 | 511 | c128_bankswitch_z80(); |
| 513 | 512 | memory_set_context(1); |
| 514 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, CLEAR_LINE); |
| 515 | | cpunum_set_input_line(Machine, 1, INPUT_LINE_HALT, ASSERT_LINE); |
| 513 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, CLEAR_LINE); |
| 514 | cpunum_set_input_line(machine, 1, INPUT_LINE_HALT, ASSERT_LINE); |
| 516 | 515 | } |
| 517 | 516 | else |
| 518 | 517 | { |
| 519 | 518 | DBG_LOG (1, "switching to m6502", |
| 520 | 519 | ("active %d\n",cpu_getactivecpu()) ); |
| 521 | 520 | memory_set_context(1); |
| 522 | | c128_bankswitch_128(reset); |
| 521 | c128_bankswitch_128(machine, reset); |
| 523 | 522 | memory_set_context(0); |
| 524 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, ASSERT_LINE); |
| 525 | | cpunum_set_input_line(Machine, 1, INPUT_LINE_HALT, CLEAR_LINE); |
| 523 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, ASSERT_LINE); |
| 524 | cpunum_set_input_line(machine, 1, INPUT_LINE_HALT, CLEAR_LINE); |
| 526 | 525 | |
| 527 | 526 | /* NPW 19-Nov-2005 - In the C128, CPU #0 starts out and hands over |
| 528 | 527 | * control to CPU #1. CPU #1 seems to execute garbage from 0x0000 |
| r1980 | r1981 | |
| 545 | 544 | if (!MMU_CPU8502) |
| 546 | 545 | c128_bankswitch_z80(); |
| 547 | 546 | else |
| 548 | | c128_bankswitch_128(reset); |
| 547 | c128_bankswitch_128(machine, reset); |
| 549 | 548 | } |
| 550 | 549 | |
| 551 | | static void c128_mmu8722_reset (void) |
| 550 | static void c128_mmu8722_reset (running_machine *machine) |
| 552 | 551 | { |
| 553 | 552 | memset(c128_mmu, 0, sizeof (c128_mmu)); |
| 554 | 553 | c128_mmu[5] |= 0x38; |
| r1980 | r1981 | |
| 556 | 555 | mmu_cpu = 0; |
| 557 | 556 | mmu_page0 = 0; |
| 558 | 557 | mmu_page1 = 0x0100; |
| 559 | | c128_bankswitch (1); |
| 558 | c128_bankswitch (machine, 1); |
| 560 | 559 | } |
| 561 | 560 | |
| 562 | 561 | WRITE8_HANDLER( c128_mmu8722_port_w ) |
| r1980 | r1981 | |
| 576 | 575 | case 5: |
| 577 | 576 | case 6: |
| 578 | 577 | c128_mmu[offset] = data; |
| 579 | | c128_bankswitch (0); |
| 578 | c128_bankswitch (machine, 0); |
| 580 | 579 | break; |
| 581 | 580 | case 7: |
| 582 | 581 | c128_mmu[offset] = data; |
| r1980 | r1981 | |
| 585 | 584 | case 9: |
| 586 | 585 | c128_mmu[offset] = data; |
| 587 | 586 | mmu_page1=MMU_PAGE1; |
| 588 | | c128_bankswitch (0); |
| 587 | c128_bankswitch (machine, 0); |
| 589 | 588 | break; |
| 590 | 589 | case 0xb: |
| 591 | 590 | break; |
| r1980 | r1981 | |
| 639 | 638 | { |
| 640 | 639 | case 0: |
| 641 | 640 | c128_mmu[offset] = data; |
| 642 | | c128_bankswitch (0); |
| 641 | c128_bankswitch (machine, 0); |
| 643 | 642 | break; |
| 644 | 643 | case 1: |
| 645 | 644 | case 2: |
| r1980 | r1981 | |
| 650 | 649 | #else |
| 651 | 650 | c128_mmu[0]|= c128_mmu[offset]; |
| 652 | 651 | #endif |
| 653 | | c128_bankswitch (0); |
| 652 | c128_bankswitch (machine, 0); |
| 654 | 653 | break; |
| 655 | 654 | } |
| 656 | 655 | } |
| r1980 | r1981 | |
| 822 | 821 | |
| 823 | 822 | MACHINE_RESET( c128 ) |
| 824 | 823 | { |
| 825 | | c64_common_init_machine (); |
| 824 | c64_common_init_machine(machine); |
| 826 | 825 | c128_vicaddr = c64_vicaddr = c64_memory; |
| 827 | 826 | |
| 828 | 827 | sndti_reset(SOUND_SID6581, 0); |
| r1980 | r1981 | |
| 831 | 830 | c64_rom_load(); |
| 832 | 831 | |
| 833 | 832 | c64mode = 0; |
| 834 | | c128_mmu8722_reset (); |
| 833 | c128_mmu8722_reset (machine); |
| 835 | 834 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, CLEAR_LINE); |
| 836 | 835 | cpunum_set_input_line(machine, 1, INPUT_LINE_HALT, ASSERT_LINE); |
| 837 | 836 | } |
src/mess/machine/pc8801.c
| r1980 | r1981 | |
| 59 | 59 | /* UOP3 (bit 7 -- not yet) */ |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | | static void calender_strobe(void) |
| 62 | static void calender_strobe(running_machine *machine) |
| 63 | 63 | { |
| 64 | 64 | mame_system_time systime; |
| 65 | 65 | |
| r1980 | r1981 | |
| 77 | 77 | break; |
| 78 | 78 | case 3: |
| 79 | 79 | /* get the current date/time from the core */ |
| 80 | | mame_get_current_datetime(Machine, &systime); |
| 80 | mame_get_current_datetime(machine, &systime); |
| 81 | 81 | |
| 82 | 82 | calender_reg[4] = (systime.local_time.month + 1) * 16 + systime.local_time.weekday; |
| 83 | 83 | calender_reg[3] = dec_2_bcd(systime.local_time.mday); |
| r1980 | r1981 | |
| 111 | 111 | static int interrupt_mask_reg; |
| 112 | 112 | static int interrupt_trig_reg; |
| 113 | 113 | |
| 114 | | static void pc8801_update_interrupt(void) |
| 114 | static void pc8801_update_interrupt(running_machine *machine) |
| 115 | 115 | { |
| 116 | 116 | int level, i; |
| 117 | 117 | |
| r1980 | r1981 | |
| 123 | 123 | } |
| 124 | 124 | if (level >= 0 && level<interrupt_level_reg) |
| 125 | 125 | { |
| 126 | | cpunum_set_input_line(Machine, 0, 0, HOLD_LINE); |
| 126 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| r1980 | r1981 | |
| 144 | 144 | WRITE8_HANDLER(pc8801_write_interrupt_level) |
| 145 | 145 | { |
| 146 | 146 | interrupt_level_reg = data&0x0f; |
| 147 | | pc8801_update_interrupt(); |
| 147 | pc8801_update_interrupt(machine); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | WRITE8_HANDLER(pc8801_write_interrupt_mask) |
| r1980 | r1981 | |
| 153 | 153 | | ((data&0x04)>>2) | 0xf8; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | | static void pc8801_raise_interrupt(int level) |
| 156 | static void pc8801_raise_interrupt(running_machine *machine, int level) |
| 157 | 157 | { |
| 158 | 158 | interrupt_trig_reg |= interrupt_mask_reg & (1<<level); |
| 159 | | pc8801_update_interrupt(); |
| 159 | pc8801_update_interrupt(machine); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | INTERRUPT_GEN( pc8801_interrupt ) |
| 163 | 163 | { |
| 164 | | pc8801_raise_interrupt(1); |
| 164 | pc8801_raise_interrupt(machine, 1); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | static TIMER_CALLBACK(pc8801_timer_interrupt) |
| 168 | 168 | { |
| 169 | | pc8801_raise_interrupt(2); |
| 169 | pc8801_raise_interrupt(machine, 2); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | static void pc8801_init_interrupt(void) |
| r1980 | r1981 | |
| 190 | 190 | { |
| 191 | 191 | static int port_save; |
| 192 | 192 | |
| 193 | | if((port_save&0x02) == 0x00 && (data&0x02) != 0x00) calender_strobe(); |
| 193 | if((port_save&0x02) == 0x00 && (data&0x02) != 0x00) calender_strobe(machine); |
| 194 | 194 | if((port_save&0x04) == 0x00 && (data&0x04) != 0x00) calender_shift(); |
| 195 | 195 | port_save=data; |
| 196 | 196 | |
| r1980 | r1981 | |
| 502 | 502 | maptvram=((data&0x10)==0); |
| 503 | 503 | no4throm2=(data&3); |
| 504 | 504 | enable_FM_IRQ=((data & 0x80) == 0x00); |
| 505 | | if(FM_IRQ_save && enable_FM_IRQ) pc8801_raise_interrupt(FM_IRQ_LEVEL); |
| 505 | if(FM_IRQ_save && enable_FM_IRQ) pc8801_raise_interrupt(machine, FM_IRQ_LEVEL); |
| 506 | 506 | pc88sr_disp_32(machine, offset,data); |
| 507 | 507 | pc8801_update_bank(); |
| 508 | 508 | } |
| r1980 | r1981 | |
| 551 | 551 | pc8801_update_bank(); |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | | static void pc8801_init_bank(int hireso) |
| 554 | static void pc8801_init_bank(running_machine *machine, int hireso) |
| 555 | 555 | { |
| 556 | 556 | int i,j; |
| 557 | 557 | int num80,num88,numIO; |
| r1980 | r1981 | |
| 570 | 570 | |
| 571 | 571 | extmem_ctrl[0]=extmem_ctrl[1]=0; |
| 572 | 572 | pc8801_update_bank(); |
| 573 | | pc8801_video_init(Machine, hireso); |
| 573 | pc8801_video_init(machine, hireso); |
| 574 | 574 | |
| 575 | 575 | if(extmem_mode!=readinputport(19)) { |
| 576 | 576 | extmem_mode=readinputport(19); |
| r1980 | r1981 | |
| 691 | 691 | } |
| 692 | 692 | } |
| 693 | 693 | |
| 694 | | static void pc88sr_ch_reset (int hireso) |
| 694 | static void pc88sr_ch_reset (running_machine *machine, int hireso) |
| 695 | 695 | { |
| 696 | 696 | int a; |
| 697 | 697 | |
| r1980 | r1981 | |
| 701 | 701 | pc88sr_is_highspeed = ((a&0x04)!=0x00); |
| 702 | 702 | is_8MHz = ((a&0x08)!=0x00); |
| 703 | 703 | fix_V1V2(); |
| 704 | | pc8801_init_bank(hireso); |
| 704 | pc8801_init_bank(machine, hireso); |
| 705 | 705 | pc8801_init_5fd(); |
| 706 | 706 | pc8801_init_interrupt(); |
| 707 | 707 | beep_set_state(0, 0); |
| r1980 | r1981 | |
| 711 | 711 | |
| 712 | 712 | MACHINE_RESET( pc88srl ) |
| 713 | 713 | { |
| 714 | | pc88sr_ch_reset(0); |
| 714 | pc88sr_ch_reset(machine, 0); |
| 715 | 715 | } |
| 716 | 716 | |
| 717 | 717 | MACHINE_RESET( pc88srh ) |
| 718 | 718 | { |
| 719 | | pc88sr_ch_reset(1); |
| 719 | pc88sr_ch_reset(machine, 1); |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | /* 5 inch floppy drive */ |
| r1980 | r1981 | |
| 837 | 837 | void pc88sr_sound_interupt(int irq) |
| 838 | 838 | { |
| 839 | 839 | FM_IRQ_save=irq; |
| 840 | | if(FM_IRQ_save && enable_FM_IRQ) pc8801_raise_interrupt(FM_IRQ_LEVEL); |
| 840 | if(FM_IRQ_save && enable_FM_IRQ) pc8801_raise_interrupt(Machine, FM_IRQ_LEVEL); |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | /* |
src/mess/machine/oric.c
| r1980 | r1981 | |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | 69 | /* called when ints are changed - cleared/set */ |
| 70 | | static void oric_refresh_ints(void) |
| 70 | static void oric_refresh_ints(running_machine *machine) |
| 71 | 71 | { |
| 72 | 72 | /* telestrat has floppy hardware built-in! */ |
| 73 | 73 | if (oric_is_telestrat==0) |
| r1980 | r1981 | |
| 84 | 84 | /* any irq set? */ |
| 85 | 85 | if ((oric_irqs & 0x0f)!=0) |
| 86 | 86 | { |
| 87 | | cpunum_set_input_line(Machine, 0,0, HOLD_LINE); |
| 87 | cpunum_set_input_line(machine, 0,0, HOLD_LINE); |
| 88 | 88 | } |
| 89 | 89 | else |
| 90 | 90 | { |
| 91 | | cpunum_set_input_line(Machine, 0,0, CLEAR_LINE); |
| 91 | cpunum_set_input_line(machine, 0,0, CLEAR_LINE); |
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | |
| r1980 | r1981 | |
| 197 | 197 | |
| 198 | 198 | |
| 199 | 199 | /* read/write data depending on state of bdir, bc1 pins and data output to psg */ |
| 200 | | static void oric_psg_connection_refresh(void) |
| 200 | static void oric_psg_connection_refresh(running_machine *machine) |
| 201 | 201 | { |
| 202 | | running_machine *machine = Machine; |
| 203 | | |
| 204 | 202 | if (oric_psg_control!=0) |
| 205 | 203 | { |
| 206 | 204 | switch (oric_psg_control) |
| r1980 | r1981 | |
| 239 | 237 | { |
| 240 | 238 | oric_via_port_a_data = data; |
| 241 | 239 | |
| 242 | | oric_psg_connection_refresh(); |
| 240 | oric_psg_connection_refresh(machine); |
| 243 | 241 | |
| 244 | 242 | |
| 245 | 243 | if (oric_psg_control==0) |
| r1980 | r1981 | |
| 342 | 340 | centronics_write_handshake(0, CENTRONICS_SELECT | CENTRONICS_NO_RESET, CENTRONICS_SELECT| CENTRONICS_NO_RESET); |
| 343 | 341 | centronics_write_handshake(0, printer_handshake, CENTRONICS_STROBE); |
| 344 | 342 | |
| 345 | | oric_psg_connection_refresh(); |
| 343 | oric_psg_connection_refresh(machine); |
| 346 | 344 | previous_portb_data = data; |
| 347 | 345 | |
| 348 | 346 | } |
| r1980 | r1981 | |
| 391 | 389 | oric_psg_control |=1; |
| 392 | 390 | } |
| 393 | 391 | |
| 394 | | oric_psg_connection_refresh(); |
| 392 | oric_psg_connection_refresh(machine); |
| 395 | 393 | } |
| 396 | 394 | |
| 397 | 395 | static WRITE8_HANDLER ( oric_via_out_cb2_func ) |
| r1980 | r1981 | |
| 403 | 401 | oric_psg_control |=2; |
| 404 | 402 | } |
| 405 | 403 | |
| 406 | | oric_psg_connection_refresh(); |
| 404 | oric_psg_connection_refresh(machine); |
| 407 | 405 | } |
| 408 | 406 | |
| 409 | 407 | |
| r1980 | r1981 | |
| 421 | 419 | oric_irqs |=(1<<0); |
| 422 | 420 | } |
| 423 | 421 | |
| 424 | | oric_refresh_ints(); |
| 422 | oric_refresh_ints(Machine); |
| 425 | 423 | } |
| 426 | 424 | |
| 427 | 425 | |
| r1980 | r1981 | |
| 585 | 583 | |
| 586 | 584 | |
| 587 | 585 | /* APPLE 2 INTERFACE V2 */ |
| 588 | | static void oric_install_apple2_v2_interface(void) |
| 586 | static void oric_install_apple2_v2_interface(running_machine *machine) |
| 589 | 587 | { |
| 590 | 588 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0300, 0x030f, 0, 0, oric_IO_r); |
| 591 | 589 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_r); |
| r1980 | r1981 | |
| 595 | 593 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_w); |
| 596 | 594 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0380, 0x0383, 0, 0, apple2_v2_interface_w); |
| 597 | 595 | |
| 598 | | apple2_v2_interface_w(Machine, 0, 0); |
| 596 | apple2_v2_interface_w(machine, 0, 0); |
| 599 | 597 | } |
| 600 | 598 | |
| 601 | 599 | /********************/ |
| r1980 | r1981 | |
| 690 | 688 | } |
| 691 | 689 | } |
| 692 | 690 | |
| 693 | | static void oric_jasmin_wd179x_callback(int State) |
| 691 | static void oric_jasmin_wd179x_callback(running_machine *machine, int State) |
| 694 | 692 | { |
| 695 | 693 | switch (State) |
| 696 | 694 | { |
| r1980 | r1981 | |
| 699 | 697 | { |
| 700 | 698 | oric_irqs &=~(1<<1); |
| 701 | 699 | |
| 702 | | oric_refresh_ints(); |
| 700 | oric_refresh_ints(machine); |
| 703 | 701 | } |
| 704 | 702 | break; |
| 705 | 703 | |
| r1980 | r1981 | |
| 707 | 705 | { |
| 708 | 706 | oric_irqs |= (1<<1); |
| 709 | 707 | |
| 710 | | oric_refresh_ints(); |
| 708 | oric_refresh_ints(machine); |
| 711 | 709 | } |
| 712 | 710 | break; |
| 713 | 711 | |
| r1980 | r1981 | |
| 825 | 823 | static unsigned char port_314_w; |
| 826 | 824 | |
| 827 | 825 | |
| 828 | | static void oric_microdisc_refresh_wd179x_ints(void) |
| 826 | static void oric_microdisc_refresh_wd179x_ints(running_machine *machine) |
| 829 | 827 | { |
| 830 | 828 | oric_irqs &=~(1<<1); |
| 831 | 829 | |
| r1980 | r1981 | |
| 836 | 834 | oric_irqs |=(1<<1); |
| 837 | 835 | } |
| 838 | 836 | |
| 839 | | oric_refresh_ints(); |
| 837 | oric_refresh_ints(machine); |
| 840 | 838 | } |
| 841 | 839 | |
| 842 | | static void oric_microdisc_wd179x_callback(int State) |
| 840 | static void oric_microdisc_wd179x_callback(running_machine *machine, int State) |
| 843 | 841 | { |
| 844 | 842 | switch (State) |
| 845 | 843 | { |
| r1980 | r1981 | |
| 849 | 847 | |
| 850 | 848 | oric_wd179x_int_state = 0; |
| 851 | 849 | |
| 852 | | oric_microdisc_refresh_wd179x_ints(); |
| 850 | oric_microdisc_refresh_wd179x_ints(machine); |
| 853 | 851 | } |
| 854 | 852 | break; |
| 855 | 853 | |
| r1980 | r1981 | |
| 859 | 857 | |
| 860 | 858 | oric_wd179x_int_state = 1; |
| 861 | 859 | |
| 862 | | oric_microdisc_refresh_wd179x_ints(); |
| 860 | oric_microdisc_refresh_wd179x_ints(machine); |
| 863 | 861 | } |
| 864 | 862 | break; |
| 865 | 863 | |
| r1980 | r1981 | |
| 1028 | 1026 | wd17xx_set_density(density); |
| 1029 | 1027 | |
| 1030 | 1028 | oric_microdisc_set_mem_0x0c000(); |
| 1031 | | oric_microdisc_refresh_wd179x_ints(); |
| 1029 | oric_microdisc_refresh_wd179x_ints(machine); |
| 1032 | 1030 | } |
| 1033 | 1031 | break; |
| 1034 | 1032 | |
| r1980 | r1981 | |
| 1069 | 1067 | case ORIC_FLOPPY_INTERFACE_APPLE2: |
| 1070 | 1068 | return; |
| 1071 | 1069 | case ORIC_FLOPPY_INTERFACE_MICRODISC: |
| 1072 | | oric_microdisc_wd179x_callback(State); |
| 1070 | oric_microdisc_wd179x_callback(machine, State); |
| 1073 | 1071 | return; |
| 1074 | 1072 | case ORIC_FLOPPY_INTERFACE_JASMIN: |
| 1075 | | oric_jasmin_wd179x_callback(State); |
| 1073 | oric_jasmin_wd179x_callback(machine, State); |
| 1076 | 1074 | return; |
| 1077 | 1075 | } |
| 1078 | 1076 | } |
| r1980 | r1981 | |
| 1174 | 1172 | |
| 1175 | 1173 | case ORIC_FLOPPY_INTERFACE_APPLE2_V2: |
| 1176 | 1174 | { |
| 1177 | | oric_install_apple2_v2_interface(); |
| 1175 | oric_install_apple2_v2_interface(machine); |
| 1178 | 1176 | } |
| 1179 | 1177 | break; |
| 1180 | 1178 | |
| r1980 | r1981 | |
| 1441 | 1439 | oric_irqs |=(1<<2); |
| 1442 | 1440 | } |
| 1443 | 1441 | |
| 1444 | | oric_refresh_ints(); |
| 1442 | oric_refresh_ints(Machine); |
| 1445 | 1443 | } |
| 1446 | 1444 | static const struct via6522_interface telestrat_via2_interface= |
| 1447 | 1445 | { |
| r1980 | r1981 | |
| 1471 | 1469 | oric_irqs |= (1<<3); |
| 1472 | 1470 | } |
| 1473 | 1471 | |
| 1474 | | oric_refresh_ints(); |
| 1472 | oric_refresh_ints(Machine); |
| 1475 | 1473 | } |
| 1476 | 1474 | #endif |
| 1477 | 1475 | |
src/mess/machine/bebox.c
| r1980 | r1981 | |
| 126 | 126 | * |
| 127 | 127 | *************************************/ |
| 128 | 128 | |
| 129 | | static void bebox_update_interrupts(void); |
| 129 | static void bebox_update_interrupts(running_machine *machine); |
| 130 | 130 | |
| 131 | 131 | static void bebox_mbreg32_w(UINT32 *target, UINT64 data, UINT64 mem_mask) |
| 132 | 132 | { |
| r1980 | r1981 | |
| 162 | 162 | logerror("BeBox CPU #0 pc=0x%08X imask=0x%08x\n", |
| 163 | 163 | (unsigned) activecpu_get_reg(REG_PC), bebox_cpu_imask[0]); |
| 164 | 164 | } |
| 165 | | bebox_update_interrupts(); |
| 165 | bebox_update_interrupts(machine); |
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
| r1980 | r1981 | |
| 179 | 179 | logerror("BeBox CPU #1 pc=0x%08X imask=0x%08x\n", |
| 180 | 180 | (unsigned) activecpu_get_reg(REG_PC), bebox_cpu_imask[1]); |
| 181 | 181 | } |
| 182 | | bebox_update_interrupts(); |
| 182 | bebox_update_interrupts(machine); |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| r1980 | r1981 | |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | | static void bebox_update_interrupts(void) |
| 249 | static void bebox_update_interrupts(running_machine *machine) |
| 250 | 250 | { |
| 251 | 251 | int cpunum; |
| 252 | 252 | UINT32 interrupt; |
| r1980 | r1981 | |
| 261 | 261 | bebox_interrupts, bebox_cpu_imask[cpunum], interrupt ? "on" : "off"); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | | cpunum_set_input_line(Machine, cpunum, INPUT_LINE_IRQ0, interrupt ? ASSERT_LINE : CLEAR_LINE); |
| 264 | cpunum_set_input_line(machine, cpunum, INPUT_LINE_IRQ0, interrupt ? ASSERT_LINE : CLEAR_LINE); |
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | |
| 269 | | static void bebox_set_irq_bit(unsigned int interrupt_bit, int val) |
| 269 | static void bebox_set_irq_bit(running_machine *machine, unsigned int interrupt_bit, int val) |
| 270 | 270 | { |
| 271 | 271 | static const char *const interrupt_names[32] = |
| 272 | 272 | { |
| r1980 | r1981 | |
| 325 | 325 | |
| 326 | 326 | /* if interrupt values have changed, update the lines */ |
| 327 | 327 | if (bebox_interrupts != old_interrupts) |
| 328 | | bebox_update_interrupts(); |
| 328 | bebox_update_interrupts(machine); |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
| r1980 | r1981 | |
| 369 | 369 | |
| 370 | 370 | static void bebox_fdc_interrupt(int state) |
| 371 | 371 | { |
| 372 | | bebox_set_irq_bit(13, state); |
| 372 | bebox_set_irq_bit(Machine, 13, state); |
| 373 | 373 | pic8259_set_irq_line(0, 6, state); |
| 374 | 374 | } |
| 375 | 375 | |
| r1980 | r1981 | |
| 409 | 409 | result = pic8259_acknowledge(0); |
| 410 | 410 | if (result == 2) |
| 411 | 411 | result = pic8259_acknowledge(1); |
| 412 | | bebox_set_irq_bit(5, 0); /* HACK */ |
| 412 | bebox_set_irq_bit(machine, 5, 0); /* HACK */ |
| 413 | 413 | return ((UINT64) result) << 56; |
| 414 | 414 | } |
| 415 | 415 | |
| r1980 | r1981 | |
| 421 | 421 | { |
| 422 | 422 | case 0: |
| 423 | 423 | /* Master */ |
| 424 | | bebox_set_irq_bit(5, interrupt); |
| 424 | bebox_set_irq_bit(Machine, 5, interrupt); |
| 425 | 425 | break; |
| 426 | 426 | |
| 427 | 427 | case 1: |
| r1980 | r1981 | |
| 479 | 479 | |
| 480 | 480 | static void bebox_ide_interrupt(int state) |
| 481 | 481 | { |
| 482 | | bebox_set_irq_bit(7, state); |
| 482 | bebox_set_irq_bit(Machine, 7, state); |
| 483 | 483 | pic8259_set_irq_line(1, 6, state); |
| 484 | 484 | } |
| 485 | 485 | |
| r1980 | r1981 | |
| 766 | 766 | |
| 767 | 767 | static void bebox_keyboard_interrupt(int state) |
| 768 | 768 | { |
| 769 | | bebox_set_irq_bit(16, state); |
| 769 | bebox_set_irq_bit(Machine, 16, state); |
| 770 | 770 | pic8259_set_irq_line(0, 1, state); |
| 771 | 771 | } |
| 772 | 772 | |
| r1980 | r1981 | |
| 865 | 865 | |
| 866 | 866 | static void scsi53c810_irq_callback(void) |
| 867 | 867 | { |
| 868 | | bebox_set_irq_bit(21, 1); |
| 869 | | bebox_set_irq_bit(21, 0); |
| 868 | bebox_set_irq_bit(Machine, 21, 1); |
| 869 | bebox_set_irq_bit(Machine, 21, 0); |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | |
src/mess/machine/microtan.c
| r1980 | r1981 | |
| 135 | 135 | }, |
| 136 | 136 | }; |
| 137 | 137 | |
| 138 | | static void microtan_set_irq_line(void) |
| 138 | static void microtan_set_irq_line(running_machine *machine) |
| 139 | 139 | { |
| 140 | 140 | /* The 6502 IRQ line is active low and probably driven |
| 141 | 141 | by open collector outputs (guess). Since MAME/MESS use |
| 142 | 142 | a non-0 value for ASSERT_LINE we OR the signals here */ |
| 143 | | cpunum_set_input_line(Machine, 0, 0, via_0_irq_line | via_1_irq_line | kbd_irq_line); |
| 143 | cpunum_set_input_line(machine, 0, 0, via_0_irq_line | via_1_irq_line | kbd_irq_line); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | static mess_image *cassette_device_image(void) |
| r1980 | r1981 | |
| 219 | 219 | { |
| 220 | 220 | LOG(("microtan_via_0_irq %d\n", state)); |
| 221 | 221 | via_0_irq_line = state; |
| 222 | | microtan_set_irq_line(); |
| 222 | microtan_set_irq_line(Machine); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /************************************************************** |
| r1980 | r1981 | |
| 291 | 291 | { |
| 292 | 292 | LOG(("microtan_via_1_irq %d\n", state)); |
| 293 | 293 | via_1_irq_line = state; |
| 294 | | microtan_set_irq_line(); |
| 294 | microtan_set_irq_line(Machine); |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /************************************************************** |
| r1980 | r1981 | |
| 381 | 381 | LOG(("microtan_bff0_w: %d <- %02x (keyboard IRQ clear )\n", offset, data)); |
| 382 | 382 | microtan_keyboard_ascii &= ~0x80; |
| 383 | 383 | kbd_irq_line = CLEAR_LINE; |
| 384 | | microtan_set_irq_line(); |
| 384 | microtan_set_irq_line(machine); |
| 385 | 385 | break; |
| 386 | 386 | case 1: /* BFF1: write delayed NMI */ |
| 387 | 387 | LOG(("microtan_bff1_w: %d <- %02x (delayed NMI)\n", offset, data)); |
| r1980 | r1981 | |
| 580 | 580 | return INIT_PASS; |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | | static void store_key(int key) |
| 583 | static void store_key(running_machine *machine, int key) |
| 584 | 584 | { |
| 585 | 585 | LOG(("microtan: store key '%c'\n", key)); |
| 586 | 586 | microtan_keyboard_ascii = key | 0x80; |
| 587 | 587 | kbd_irq_line = ASSERT_LINE; |
| 588 | | microtan_set_irq_line(); |
| 588 | microtan_set_irq_line(machine); |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | INTERRUPT_GEN( microtan_interrupt ) |
| r1980 | r1981 | |
| 657 | 657 | if( key ) /* normal key */ |
| 658 | 658 | { |
| 659 | 659 | repeater = 30; |
| 660 | | store_key(key); |
| 660 | store_key(machine, key); |
| 661 | 661 | } |
| 662 | 662 | else |
| 663 | 663 | if( (row == 0) && (chg == 0x04) ) /* Ctrl-@ (NUL) */ |
| 664 | | store_key(0); |
| 664 | store_key(machine, 0); |
| 665 | 665 | keyrows[row] |= new; |
| 666 | 666 | } |
| 667 | 667 | else |
| r1980 | r1981 | |
| 673 | 673 | else |
| 674 | 674 | if ( key && (keyrows[lastrow] & mask) && repeat == 0 ) |
| 675 | 675 | { |
| 676 | | store_key(key); |
| 676 | store_key(machine, key); |
| 677 | 677 | } |
| 678 | 678 | } |
| 679 | 679 | |
| r1980 | r1981 | |
| 690 | 690 | activecpu_set_reg(M6502_S, snapshot_buff[base+6]); |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | | static void microtan_snapshot_copy(UINT8 *snapshot_buff, int snapshot_size) |
| 693 | static void microtan_snapshot_copy(running_machine *machine, UINT8 *snapshot_buff, int snapshot_size) |
| 694 | 694 | { |
| 695 | | running_machine *machine = Machine; |
| 696 | 695 | UINT8 *RAM = memory_region(REGION_CPU1); |
| 697 | 696 | |
| 698 | 697 | /* check for .DMP file format */ |
| r1980 | r1981 | |
| 801 | 800 | if (microtan_varify_snapshot(snapshot_buff, snapshot_size)==IMAGE_VERIFY_FAIL) |
| 802 | 801 | return INIT_FAIL; |
| 803 | 802 | |
| 804 | | microtan_snapshot_copy(snapshot_buff, snapshot_size); |
| 803 | microtan_snapshot_copy(Machine, snapshot_buff, snapshot_size); |
| 805 | 804 | return INIT_PASS; |
| 806 | 805 | } |
| 807 | 806 | |
| r1980 | r1981 | |
| 836 | 835 | else |
| 837 | 836 | rc = parse_zillion_hex(snapshot_buff, buff); |
| 838 | 837 | if (rc == INIT_PASS) |
| 839 | | microtan_snapshot_copy(snapshot_buff, snapshot_size); |
| 838 | microtan_snapshot_copy(Machine, snapshot_buff, snapshot_size); |
| 840 | 839 | free(snapshot_buff); |
| 841 | 840 | return rc; |
| 842 | 841 | } |
src/mess/machine/ti85.c
| r1980 | r1981 | |
| 102 | 102 | static int ti85_send_serial (UINT8*, UINT32); |
| 103 | 103 | |
| 104 | 104 | static void ti85_reset_serial (running_machine *machine); |
| 105 | | static void ti85_update_serial (void); |
| 106 | | static void ti85_send_variables (void); |
| 107 | | static void ti85_send_backup (void); |
| 108 | | static void ti85_receive_variables (void); |
| 109 | | static void ti85_receive_backup (void); |
| 110 | | static void ti85_receive_screen (void); |
| 105 | static void ti85_update_serial (running_machine *machine); |
| 106 | static void ti85_send_variables (running_machine *machine); |
| 107 | static void ti85_send_backup (running_machine *machine); |
| 108 | static void ti85_receive_variables (running_machine *machine); |
| 109 | static void ti85_receive_backup (running_machine *machine); |
| 110 | static void ti85_receive_screen (running_machine *machine); |
| 111 | 111 | |
| 112 | 112 | static TIMER_CALLBACK(ti85_timer_callback) |
| 113 | 113 | { |
| r1980 | r1981 | |
| 336 | 336 | |
| 337 | 337 | READ8_HANDLER ( ti85_port_0007_r ) |
| 338 | 338 | { |
| 339 | | ti85_update_serial(); |
| 339 | ti85_update_serial(machine); |
| 340 | 340 | return (ti85_white_out<<3) | |
| 341 | 341 | (ti85_red_out<<2)| |
| 342 | 342 | ((ti85_white_in&(1-ti85_white_out))<<1)| |
| r1980 | r1981 | |
| 406 | 406 | speaker_level_w(0,( (data>>2)|(data>>3) )&0x01 ); |
| 407 | 407 | ti85_red_out=(data>>2)&0x01; |
| 408 | 408 | ti85_white_out=(data>>3)&0x01; |
| 409 | | ti85_update_serial(); |
| 409 | ti85_update_serial(machine); |
| 410 | 410 | ti85_PCR = data&0xf0; |
| 411 | 411 | } |
| 412 | 412 | |
| r1980 | r1981 | |
| 478 | 478 | TI calculators snapshot files (SAV) |
| 479 | 479 | ***************************************************************************/ |
| 480 | 480 | |
| 481 | | static void ti8x_snapshot_setup_registers (UINT8 * data) |
| 481 | static void ti8x_snapshot_setup_registers (running_machine *machine, UINT8 * data) |
| 482 | 482 | { |
| 483 | 483 | unsigned char lo,hi; |
| 484 | 484 | unsigned char * reg = data + 0x40; |
| r1980 | r1981 | |
| 530 | 530 | |
| 531 | 531 | activecpu_set_input_line(0, 0); |
| 532 | 532 | activecpu_set_input_line(INPUT_LINE_NMI, 0); |
| 533 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, 0); |
| 533 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, 0); |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | | static void ti85_setup_snapshot (UINT8 * data) |
| 536 | static void ti85_setup_snapshot (running_machine *machine, UINT8 * data) |
| 537 | 537 | { |
| 538 | 538 | int i; |
| 539 | 539 | unsigned char lo,hi; |
| 540 | 540 | unsigned char * hdw = data + 0x8000 + 0x94; |
| 541 | 541 | |
| 542 | | ti8x_snapshot_setup_registers (data); |
| 542 | ti8x_snapshot_setup_registers (machine, data); |
| 543 | 543 | |
| 544 | 544 | /* Memory dump */ |
| 545 | 545 | for (i = 0; i < 0x8000; i++) |
| r1980 | r1981 | |
| 572 | 572 | ti85_interrupt_speed = 0x03; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | | static void ti86_setup_snapshot (UINT8 * data) |
| 575 | static void ti86_setup_snapshot (running_machine *machine, UINT8 * data) |
| 576 | 576 | { |
| 577 | 577 | unsigned char lo,hi; |
| 578 | 578 | unsigned char * hdw = data + 0x20000 + 0x94; |
| 579 | 579 | |
| 580 | | ti8x_snapshot_setup_registers (data); |
| 580 | ti8x_snapshot_setup_registers (machine, data); |
| 581 | 581 | |
| 582 | 582 | /* Memory dump */ |
| 583 | 583 | memcpy(ti86_ram, data+0x94, 0x20000); |
| r1980 | r1981 | |
| 638 | 638 | |
| 639 | 639 | switch (ti_calculator_model) |
| 640 | 640 | { |
| 641 | | case TI_85: ti85_setup_snapshot(ti8x_snapshot_data); break; |
| 642 | | case TI_86: ti86_setup_snapshot(ti8x_snapshot_data); break; |
| 641 | case TI_85: ti85_setup_snapshot(Machine, ti8x_snapshot_data); break; |
| 642 | case TI_86: ti86_setup_snapshot(Machine, ti8x_snapshot_data); break; |
| 643 | 643 | } |
| 644 | 644 | free(ti8x_snapshot_data); |
| 645 | 645 | return INIT_PASS; |
| r1980 | r1981 | |
| 792 | 792 | return 1; |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | | void ti85_update_serial (void) |
| 795 | void ti85_update_serial (running_machine *machine) |
| 796 | 796 | { |
| 797 | 797 | if (ti85_serial_status == TI85_SEND_STOP) |
| 798 | 798 | { |
| r1980 | r1981 | |
| 814 | 814 | else |
| 815 | 815 | { |
| 816 | 816 | ti85_receive_serial(NULL, 0); |
| 817 | | ti85_free_serial_data_memory(Machine); |
| 817 | ti85_free_serial_data_memory(machine); |
| 818 | 818 | if (readinputport(10)&0x01) |
| 819 | 819 | { |
| 820 | 820 | ti85_serial_status = TI85_PREPARE_SCREEN_REQUEST; |
| r1980 | r1981 | |
| 827 | 827 | switch (ti85_serial_transfer_type) |
| 828 | 828 | { |
| 829 | 829 | case TI85_SEND_VARIABLES: |
| 830 | | ti85_send_variables(); |
| 830 | ti85_send_variables(machine); |
| 831 | 831 | break; |
| 832 | 832 | case TI85_SEND_BACKUP: |
| 833 | | ti85_send_backup(); |
| 833 | ti85_send_backup(machine); |
| 834 | 834 | break; |
| 835 | 835 | case TI85_RECEIVE_BACKUP: |
| 836 | | ti85_receive_backup(); |
| 836 | ti85_receive_backup(machine); |
| 837 | 837 | break; |
| 838 | 838 | case TI85_RECEIVE_VARIABLES: |
| 839 | | ti85_receive_variables(); |
| 839 | ti85_receive_variables(machine); |
| 840 | 840 | break; |
| 841 | 841 | case TI85_RECEIVE_SCREEN: |
| 842 | | ti85_receive_screen(); |
| 842 | ti85_receive_screen(machine); |
| 843 | 843 | break; |
| 844 | 844 | } |
| 845 | 845 | } |
| r1980 | r1981 | |
| 855 | 855 | ti85_white_out = 0x00; |
| 856 | 856 | ti85_PCR = 0xc0; |
| 857 | 857 | ti85_serial_status = TI85_SEND_RESET; |
| 858 | | ti85_send_variables(); |
| 859 | | ti85_send_backup(); |
| 860 | | ti85_receive_variables(); |
| 861 | | ti85_receive_backup(); |
| 858 | ti85_send_variables(machine); |
| 859 | ti85_send_backup(machine); |
| 860 | ti85_receive_variables(machine); |
| 861 | ti85_receive_backup(machine); |
| 862 | 862 | ti85_serial_status = TI85_SEND_STOP; |
| 863 | 863 | } |
| 864 | | static void ti85_send_variables (void) |
| 864 | static void ti85_send_variables (running_machine *machine) |
| 865 | 865 | { |
| 866 | 866 | static UINT16 variable_number = 0; |
| 867 | 867 | |
| r1980 | r1981 | |
| 914 | 914 | break; |
| 915 | 915 | case 0x03: //out of memory |
| 916 | 916 | variable_number = 0; |
| 917 | | ti85_free_serial_data_memory(Machine); |
| 917 | ti85_free_serial_data_memory(machine); |
| 918 | 918 | ti85_serial_status = TI85_SEND_STOP; |
| 919 | 919 | break; |
| 920 | 920 | } |
| r1980 | r1981 | |
| 928 | 928 | { |
| 929 | 929 | case 0x01: //exit |
| 930 | 930 | variable_number = 0; |
| 931 | | ti85_free_serial_data_memory(Machine); |
| 931 | ti85_free_serial_data_memory(machine); |
| 932 | 932 | ti85_serial_status = TI85_SEND_STOP; |
| 933 | 933 | break; |
| 934 | 934 | case 0x02: //skip |
| r1980 | r1981 | |
| 970 | 970 | { |
| 971 | 971 | logerror ("OK received\n"); |
| 972 | 972 | ti85_convert_stream_to_data (ti85_receive_buffer, 4*8, ti85_receive_data); |
| 973 | | ti85_free_serial_data_memory(Machine); |
| 973 | ti85_free_serial_data_memory(machine); |
| 974 | 974 | ti85_serial_status = TI85_SEND_STOP; |
| 975 | 975 | } |
| 976 | 976 | break; |
| r1980 | r1981 | |
| 980 | 980 | } |
| 981 | 981 | } |
| 982 | 982 | |
| 983 | | static void ti85_send_backup (void) |
| 983 | static void ti85_send_backup (running_machine *machine) |
| 984 | 984 | { |
| 985 | 985 | static UINT16 variable_number = 0; |
| 986 | 986 | |
| r1980 | r1981 | |
| 1020 | 1020 | { |
| 1021 | 1021 | ti85_convert_stream_to_data (ti85_receive_buffer, 5*8, ti85_receive_data); |
| 1022 | 1022 | variable_number = 0; |
| 1023 | | ti85_free_serial_data_memory(Machine); |
| 1023 | ti85_free_serial_data_memory(machine); |
| 1024 | 1024 | ti85_serial_status = TI85_SEND_STOP; |
| 1025 | 1025 | } |
| 1026 | 1026 | break; |
| r1980 | r1981 | |
| 1044 | 1044 | if(!ti85_send_serial(ti85_serial_stream.end,ti85_serial_stream.end_size)) |
| 1045 | 1045 | { |
| 1046 | 1046 | variable_number = 0; |
| 1047 | | ti85_free_serial_data_memory(Machine); |
| 1047 | ti85_free_serial_data_memory(machine); |
| 1048 | 1048 | ti85_serial_status = TI85_SEND_STOP; |
| 1049 | 1049 | } |
| 1050 | 1050 | break; |
| r1980 | r1981 | |
| 1054 | 1054 | } |
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | | static void ti85_receive_variables (void) |
| 1057 | static void ti85_receive_variables (running_machine *machine) |
| 1058 | 1058 | { |
| 1059 | 1059 | static UINT8* var_data = NULL; |
| 1060 | 1060 | static UINT32 var_file_number = 0; |
| r1980 | r1981 | |
| 1080 | 1080 | if(!var_data) |
| 1081 | 1081 | ti85_serial_status = TI85_SEND_STOP; |
| 1082 | 1082 | memcpy (var_data, ti85_receive_data+2, 5); |
| 1083 | | ti85_free_serial_data_memory(Machine); |
| 1083 | ti85_free_serial_data_memory(machine); |
| 1084 | 1084 | if (!ti85_alloc_serial_data_memory(var_data[0]-1)) |
| 1085 | 1085 | { |
| 1086 | 1086 | free(var_data); var_data = NULL; |
| r1980 | r1981 | |
| 1094 | 1094 | { |
| 1095 | 1095 | ti85_convert_stream_to_data (ti85_receive_buffer, (var_data[0]-1)*8, ti85_receive_data); |
| 1096 | 1096 | memcpy (var_data+5, ti85_receive_data, var_data[0]-3); |
| 1097 | | ti85_free_serial_data_memory(Machine); |
| 1097 | ti85_free_serial_data_memory(machine); |
| 1098 | 1098 | if(!ti85_alloc_serial_data_memory (8)) |
| 1099 | 1099 | { |
| 1100 | 1100 | free(var_data); var_data = NULL; |
| r1980 | r1981 | |
| 1114 | 1114 | case TI85_SEND_CONTINUE: |
| 1115 | 1115 | if(!ti85_send_serial(ti85_receive_buffer+4*8, 4*8)) |
| 1116 | 1116 | { |
| 1117 | | ti85_free_serial_data_memory(Machine); |
| 1117 | ti85_free_serial_data_memory(machine); |
| 1118 | 1118 | if(!ti85_alloc_serial_data_memory(4)) |
| 1119 | 1119 | { |
| 1120 | 1120 | free(var_data); var_data = NULL; |
| r1980 | r1981 | |
| 1129 | 1129 | if(!ti85_receive_serial (ti85_receive_buffer, 4*8)) |
| 1130 | 1130 | { |
| 1131 | 1131 | ti85_convert_stream_to_data (ti85_receive_buffer, 4*8, ti85_receive_data); |
| 1132 | | ti85_free_serial_data_memory(Machine); |
| 1132 | ti85_free_serial_data_memory(machine); |
| 1133 | 1133 | if(!ti85_alloc_serial_data_memory(var_data[2]+var_data[3]*256+6)) |
| 1134 | 1134 | { |
| 1135 | 1135 | free(var_data); var_data = NULL; |
| r1980 | r1981 | |
| 1145 | 1145 | { |
| 1146 | 1146 | ti85_convert_stream_to_data (ti85_receive_buffer, (var_data[2]+var_data[3]*256+6)*8, ti85_receive_data); |
| 1147 | 1147 | memcpy (var_data+var_data[0]+2, ti85_receive_data+2, var_data[2]+var_data[3]*256+2); |
| 1148 | | ti85_free_serial_data_memory(Machine); |
| 1148 | ti85_free_serial_data_memory(machine); |
| 1149 | 1149 | if(!ti85_alloc_serial_data_memory (4)) |
| 1150 | 1150 | { |
| 1151 | 1151 | free(var_data); var_data = NULL; |
| r1980 | r1981 | |
| 1160 | 1160 | case TI85_SEND_OK_2: |
| 1161 | 1161 | if(!ti85_send_serial(ti85_receive_buffer, 4*8)) |
| 1162 | 1162 | { |
| 1163 | | ti85_free_serial_data_memory(Machine); |
| 1163 | ti85_free_serial_data_memory(machine); |
| 1164 | 1164 | if(!ti85_alloc_serial_data_memory(7)) |
| 1165 | 1165 | { |
| 1166 | 1166 | free(var_data); var_data = NULL; |
| r1980 | r1981 | |
| 1213 | 1213 | ti85_serial_status = TI85_RECEIVE_HEADER_1; |
| 1214 | 1214 | else |
| 1215 | 1215 | { |
| 1216 | | ti85_free_serial_data_memory(Machine); |
| 1216 | ti85_free_serial_data_memory(machine); |
| 1217 | 1217 | if(!ti85_alloc_serial_data_memory (4)) |
| 1218 | 1218 | { |
| 1219 | 1219 | free(var_data); var_data = NULL; |
| r1980 | r1981 | |
| 1229 | 1229 | case TI85_SEND_OK_3: |
| 1230 | 1230 | if(!ti85_send_serial(ti85_receive_buffer, 4*8)) |
| 1231 | 1231 | { |
| 1232 | | ti85_free_serial_data_memory(Machine); |
| 1232 | ti85_free_serial_data_memory(machine); |
| 1233 | 1233 | variable_number = 0; |
| 1234 | 1234 | ti85_serial_status = TI85_SEND_STOP; |
| 1235 | 1235 | sprintf (var_file_name, "%08d.85g", var_file_number); |
| r1980 | r1981 | |
| 1260 | 1260 | } |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | | static void ti85_receive_backup (void) |
| 1263 | static void ti85_receive_backup (running_machine *machine) |
| 1264 | 1264 | { |
| 1265 | 1265 | static int backup_variable_number = 0; |
| 1266 | 1266 | static int backup_data_size[3]; |
| r1980 | r1981 | |
| 1293 | 1293 | backup_file_data[0x35] = (backup_data_size[0]+backup_data_size[1]+backup_data_size[2]+0x11)&0x00ff; |
| 1294 | 1294 | backup_file_data[0x36] = ((backup_data_size[0]+backup_data_size[1]+backup_data_size[2]+0x11)&0xff00)>>8; |
| 1295 | 1295 | memcpy(backup_file_data+0x37, ti85_receive_data+0x02, 0x0b); |
| 1296 | | ti85_free_serial_data_memory(Machine); |
| 1296 | ti85_free_serial_data_memory(machine); |
| 1297 | 1297 | if(!ti85_alloc_serial_data_memory (8)) |
| 1298 | 1298 | { |
| 1299 | 1299 | free(backup_file_data); backup_file_data = NULL; |
| r1980 | r1981 | |
| 1313 | 1313 | case TI85_SEND_CONTINUE: |
| 1314 | 1314 | if(!ti85_send_serial(ti85_receive_buffer+4*8, 4*8)) |
| 1315 | 1315 | { |
| 1316 | | ti85_free_serial_data_memory(Machine); |
| 1316 | ti85_free_serial_data_memory(machine); |
| 1317 | 1317 | if(!ti85_alloc_serial_data_memory(4)) |
| 1318 | 1318 | { |
| 1319 | 1319 | free(backup_file_data); backup_file_data = NULL; |
| r1980 | r1981 | |
| 1328 | 1328 | if(!ti85_receive_serial (ti85_receive_buffer, 4*8)) |
| 1329 | 1329 | { |
| 1330 | 1330 | ti85_convert_stream_to_data (ti85_receive_buffer, 4*8, ti85_receive_data); |
| 1331 | | ti85_free_serial_data_memory(Machine); |
| 1331 | ti85_free_serial_data_memory(machine); |
| 1332 | 1332 | if(!ti85_alloc_serial_data_memory(backup_data_size[backup_variable_number]+6)) |
| 1333 | 1333 | { |
| 1334 | 1334 | free(backup_file_data); backup_file_data = NULL; |
| r1980 | r1981 | |
| 1355 | 1355 | memcpy(backup_file_data+0x42+backup_data_size[0]+backup_data_size[1]+0x04, ti85_receive_data+0x02, backup_data_size[2]+0x02); |
| 1356 | 1356 | break; |
| 1357 | 1357 | } |
| 1358 | | ti85_free_serial_data_memory(Machine); |
| 1358 | ti85_free_serial_data_memory(machine); |
| 1359 | 1359 | if(!ti85_alloc_serial_data_memory (4)) |
| 1360 | 1360 | { |
| 1361 | 1361 | free(backup_file_data); backup_file_data = NULL; |
| r1980 | r1981 | |
| 1370 | 1370 | case TI85_SEND_OK_2: |
| 1371 | 1371 | if(!ti85_send_serial(ti85_receive_buffer, 4*8)) |
| 1372 | 1372 | { |
| 1373 | | ti85_free_serial_data_memory(Machine); |
| 1373 | ti85_free_serial_data_memory(machine); |
| 1374 | 1374 | backup_variable_number++; |
| 1375 | 1375 | if (backup_variable_number<3) |
| 1376 | 1376 | { |
| r1980 | r1981 | |
| 1411 | 1411 | } |
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | | static void ti85_receive_screen (void) |
| 1414 | static void ti85_receive_screen (running_machine *machine) |
| 1415 | 1415 | { |
| 1416 | 1416 | static UINT32 image_file_number = 0; |
| 1417 | 1417 | char image_file_name[] = "00000000.85i"; |
| r1980 | r1981 | |
| 1433 | 1433 | case TI85_SEND_SCREEN_REQUEST: |
| 1434 | 1434 | if(!ti85_send_serial(ti85_receive_buffer, 4*8)) |
| 1435 | 1435 | { |
| 1436 | | ti85_free_serial_data_memory(Machine); |
| 1436 | ti85_free_serial_data_memory(machine); |
| 1437 | 1437 | if(!ti85_alloc_serial_data_memory (4)) |
| 1438 | 1438 | { |
| 1439 | 1439 | ti85_serial_status = TI85_SEND_STOP; |
| r1980 | r1981 | |
| 1446 | 1446 | if(!ti85_receive_serial (ti85_receive_buffer, 4*8)) |
| 1447 | 1447 | { |
| 1448 | 1448 | ti85_convert_stream_to_data (ti85_receive_buffer, 4*8, ti85_receive_data); |
| 1449 | | ti85_free_serial_data_memory(Machine); |
| 1449 | ti85_free_serial_data_memory(machine); |
| 1450 | 1450 | if(!ti85_alloc_serial_data_memory (1030)) |
| 1451 | 1451 | { |
| 1452 | 1452 | ti85_serial_status = TI85_SEND_STOP; |
| r1980 | r1981 | |
| 1466 | 1466 | image_file_data = malloc (0x49+1008); |
| 1467 | 1467 | if(!image_file_data) |
| 1468 | 1468 | { |
| 1469 | | ti85_free_serial_data_memory(Machine); |
| 1469 | ti85_free_serial_data_memory(machine); |
| 1470 | 1470 | ti85_serial_status = TI85_SEND_OK; |
| 1471 | 1471 | return; |
| 1472 | 1472 | } |
| r1980 | r1981 | |
| 1494 | 1494 | free(image_file_data); |
| 1495 | 1495 | image_file_number++; |
| 1496 | 1496 | } |
| 1497 | | ti85_free_serial_data_memory(Machine); |
| 1497 | ti85_free_serial_data_memory(machine); |
| 1498 | 1498 | if(!ti85_alloc_serial_data_memory (4)) |
| 1499 | 1499 | { |
| 1500 | 1500 | ti85_serial_status = TI85_SEND_STOP; |
| r1980 | r1981 | |
| 1507 | 1507 | case TI85_SEND_OK: |
| 1508 | 1508 | if(!ti85_send_serial(ti85_receive_buffer, 4*8)) |
| 1509 | 1509 | { |
| 1510 | | ti85_free_serial_data_memory(Machine); |
| 1510 | ti85_free_serial_data_memory(machine); |
| 1511 | 1511 | ti85_serial_status = TI85_SEND_STOP; |
| 1512 | 1512 | } |
| 1513 | 1513 | break; |
src/mess/machine/c64.c
| r1980 | r1981 | |
| 12 | 12 | (program write some short test code into the vic sprite register) |
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | | #include <ctype.h> |
| 16 | 15 | #include "driver.h" |
| 17 | 16 | |
| 18 | 17 | #include "cpu/m6502/m6502.h" |
| r1980 | r1981 | |
| 80 | 79 | static UINT8 serial_clock, serial_data, serial_atn; |
| 81 | 80 | static UINT8 vicirq = 0; |
| 82 | 81 | |
| 83 | | static int is_c65(void) |
| 82 | static int is_c65(running_machine *machine) |
| 84 | 83 | { |
| 85 | | return !strncmp(Machine->gamedrv->name, "c65", 3); |
| 84 | return !strncmp(machine->gamedrv->name, "c65", 3); |
| 86 | 85 | } |
| 87 | 86 | |
| 88 | | static int is_c128(void) |
| 87 | static int is_c128(running_machine *machine) |
| 89 | 88 | { |
| 90 | | return !strncmp(Machine->gamedrv->name, "c128", 4); |
| 89 | return !strncmp(machine->gamedrv->name, "c128", 4); |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | | static void c64_nmi(void) |
| 92 | static void c64_nmi(running_machine *machine) |
| 94 | 93 | { |
| 95 | 94 | static int nmilevel = 0; |
| 96 | 95 | int cia1irq = cia_get_irq(1); |
| 97 | 96 | |
| 98 | 97 | if (nmilevel != KEY_RESTORE||cia1irq) |
| 99 | 98 | { |
| 100 | | if (is_c128()) |
| 99 | if (is_c128(machine)) |
| 101 | 100 | { |
| 102 | 101 | if (cpu_getactivecpu()==0) |
| 103 | 102 | { |
| 104 | 103 | /* z80 */ |
| 105 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_NMI, KEY_RESTORE||cia1irq); |
| 104 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, KEY_RESTORE||cia1irq); |
| 106 | 105 | } |
| 107 | 106 | else |
| 108 | 107 | { |
| 109 | | cpunum_set_input_line(Machine, 1, INPUT_LINE_NMI, KEY_RESTORE||cia1irq); |
| 108 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, KEY_RESTORE||cia1irq); |
| 110 | 109 | } |
| 111 | 110 | } |
| 112 | 111 | else |
| 113 | 112 | { |
| 114 | | cpunum_set_input_line(Machine, 0, INPUT_LINE_NMI, KEY_RESTORE||cia1irq); |
| 113 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, KEY_RESTORE||cia1irq); |
| 115 | 114 | } |
| 116 | 115 | nmilevel = KEY_RESTORE||cia1irq; |
| 117 | 116 | } |
| r1980 | r1981 | |
| 269 | 268 | if (JOYSTICK_SWAP) value &= c64_keyline[9]; |
| 270 | 269 | else value &= c64_keyline[8]; |
| 271 | 270 | |
| 272 | | if (is_c128()) |
| 271 | if (is_c128(Machine)) |
| 273 | 272 | { |
| 274 | 273 | if (!vic2e_k0_r ()) |
| 275 | 274 | value &= c128_keyline[0]; |
| r1980 | r1981 | |
| 278 | 277 | if (!vic2e_k2_r ()) |
| 279 | 278 | value &= c128_keyline[2]; |
| 280 | 279 | } |
| 281 | | if (is_c65()) |
| 280 | if (is_c65(Machine)) |
| 282 | 281 | { |
| 283 | 282 | if (!(c65_6511_port&2)) |
| 284 | 283 | value&=c65_keyline; |
| r1980 | r1981 | |
| 292 | 291 | vic2_lightpen_write (data & 0x10); |
| 293 | 292 | } |
| 294 | 293 | |
| 295 | | static void c64_irq (int level) |
| 294 | static void c64_irq (running_machine *machine, int level) |
| 296 | 295 | { |
| 297 | 296 | static int old_level = 0; |
| 298 | 297 | |
| 299 | 298 | if (level != old_level) |
| 300 | 299 | { |
| 301 | 300 | DBG_LOG (3, "mos6510", ("irq %s\n", level ? "start" : "end")); |
| 302 | | if (is_c128()) |
| 301 | if (is_c128(machine)) |
| 303 | 302 | { |
| 304 | 303 | if (0&&(cpu_getactivecpu()==0)) |
| 305 | 304 | { |
| 306 | | cpunum_set_input_line(Machine, 0, 0, level); |
| 305 | cpunum_set_input_line(machine, 0, 0, level); |
| 307 | 306 | } |
| 308 | 307 | else |
| 309 | 308 | { |
| 310 | | cpunum_set_input_line(Machine, 1, M6510_IRQ_LINE, level); |
| 309 | cpunum_set_input_line(machine, 1, M6510_IRQ_LINE, level); |
| 311 | 310 | } |
| 312 | 311 | } |
| 313 | 312 | else |
| 314 | 313 | { |
| 315 | | cpunum_set_input_line(Machine, 0, M6510_IRQ_LINE, level); |
| 314 | cpunum_set_input_line(machine, 0, M6510_IRQ_LINE, level); |
| 316 | 315 | } |
| 317 | 316 | old_level = level; |
| 318 | 317 | } |
| r1980 | r1981 | |
| 325 | 324 | |
| 326 | 325 | static void c64_cia0_interrupt (int level) |
| 327 | 326 | { |
| 328 | | c64_irq (level || vicirq); |
| 327 | c64_irq (Machine, level || vicirq); |
| 329 | 328 | } |
| 330 | 329 | |
| 331 | 330 | void c64_vic_interrupt (int level) |
| r1980 | r1981 | |
| 333 | 332 | #if 1 |
| 334 | 333 | if (level != vicirq) |
| 335 | 334 | { |
| 336 | | c64_irq (level || cia_get_irq(0)); |
| 335 | c64_irq (Machine, level || cia_get_irq(0)); |
| 337 | 336 | vicirq = level; |
| 338 | 337 | } |
| 339 | 338 | #endif |
| r1980 | r1981 | |
| 381 | 380 | cbm_serial_data_write (serial_data = !(data & 0x20)); |
| 382 | 381 | cbm_serial_atn_write (serial_atn = !(data & 8)); |
| 383 | 382 | c64_vicaddr = c64_memory + helper[data & 3]; |
| 384 | | if (is_c128()) |
| 383 | if (is_c128(Machine)) |
| 385 | 384 | { |
| 386 | 385 | c128_vicaddr = c64_memory + helper[data & 3] + c128_va1617; |
| 387 | 386 | } |
| r1980 | r1981 | |
| 389 | 388 | |
| 390 | 389 | static void c64_cia1_interrupt (int level) |
| 391 | 390 | { |
| 392 | | c64_nmi(); |
| 391 | c64_nmi(Machine); |
| 393 | 392 | } |
| 394 | 393 | |
| 395 | 394 | const cia6526_interface c64_cia0 = |
| r1980 | r1981 | |
| 417 | 416 | }; |
| 418 | 417 | |
| 419 | 418 | static void c64_bankswitch (int reset); |
| 420 | | static void c64_robocop2_w(int offset, int value) |
| 419 | static void c64_robocop2_w(running_machine *machine, int offset, int value) |
| 421 | 420 | { |
| 422 | 421 | /* robocop2 0xe00 |
| 423 | 422 | * 80 94 80 94 80 |
| r1980 | r1981 | |
| 435 | 434 | c64_game = c64_exrom = 1; |
| 436 | 435 | } |
| 437 | 436 | |
| 438 | | if (is_c128()) |
| 439 | | c128_bankswitch_64(0); |
| 437 | if (is_c128(machine)) |
| 438 | c128_bankswitch_64(machine, 0); |
| 440 | 439 | else |
| 441 | 440 | c64_bankswitch(0); |
| 442 | 441 | } |
| 443 | 442 | |
| 444 | | static void c64_supergames_w(int offset, int value) |
| 443 | static void c64_supergames_w(running_machine *machine, int offset, int value) |
| 445 | 444 | { |
| 446 | 445 | /* supergam 0xf00 |
| 447 | 446 | * 4 9 4 |
| r1980 | r1981 | |
| 463 | 462 | c64_game = c64_exrom = 0; |
| 464 | 463 | } |
| 465 | 464 | |
| 466 | | if (is_c128()) |
| 467 | | c128_bankswitch_64 (0); |
| 465 | if (is_c128(machine)) |
| 466 | c128_bankswitch_64 (machine, 0); |
| 468 | 467 | else |
| 469 | 468 | c64_bankswitch (0); |
| 470 | 469 | } |
| r1980 | r1981 | |
| 492 | 491 | /* i/o 1 */ |
| 493 | 492 | if (cartridge && (cartridgetype == CartridgeRobocop2)) |
| 494 | 493 | { |
| 495 | | c64_robocop2_w(offset&0xff, data); |
| 494 | c64_robocop2_w(machine, offset&0xff, data); |
| 496 | 495 | } |
| 497 | 496 | else |
| 498 | 497 | DBG_LOG (1, "io write", ("%.3x %.2x\n", offset, data)); |
| r1980 | r1981 | |
| 502 | 501 | /* i/o 2 */ |
| 503 | 502 | if (cartridge && (cartridgetype == CartridgeSuperGames)) |
| 504 | 503 | { |
| 505 | | c64_supergames_w(offset&0xff, data); |
| 504 | c64_supergames_w(machine, offset&0xff, data); |
| 506 | 505 | } |
| 507 | 506 | else |
| 508 | 507 | DBG_LOG (1, "io write", ("%.3x %.2x\n", offset, data)); |
| r1980 | r1981 | |
| 741 | 740 | vc20_tape_motor (data & 0x20); |
| 742 | 741 | } |
| 743 | 742 | } |
| 744 | | if (is_c128()) |
| 745 | | c128_bankswitch_64 (0); |
| 746 | | else if (is_c65()) |
| 743 | if (is_c128(Machine)) |
| 744 | c128_bankswitch_64 (Machine, 0); |
| 745 | else if (is_c65(Machine)) |
| 747 | 746 | { |
| 748 | 747 | // NPW 8-Feb-2004 - Don't know why I have to do this |
| 749 | 748 | //c65_bankswitch(); |
| r1980 | r1981 | |
| 762 | 761 | data &= ~0x10; |
| 763 | 762 | /* WP: motor is always marked as on??? */ |
| 764 | 763 | data &= ~0x20; |
| 765 | | if (is_c128() && !c128_capslock_r ()) |
| 764 | if (is_c128(Machine) && !c128_capslock_r ()) |
| 766 | 765 | data &= ~0x40; |
| 767 | | if (is_c65() && C65_KEY_DIN) |
| 766 | if (is_c65(Machine) && C65_KEY_DIN) |
| 768 | 767 | data &= ~0x40; /*? */ |
| 769 | 768 | return data; |
| 770 | 769 | } |
| r1980 | r1981 | |
| 853 | 852 | return c64_colorram[offset & 0x3ff] & 0xf; |
| 854 | 853 | } |
| 855 | 854 | |
| 856 | | static void c64_common_driver_init (void) |
| 855 | static void c64_common_driver_init (running_machine *machine) |
| 857 | 856 | { |
| 858 | 857 | /* configure the M6510 port */ |
| 859 | 858 | cpunum_set_info_fct(0, CPUINFO_PTR_M6510_PORTREAD, (genf *) c64_m6510_port_read); |
| r1980 | r1981 | |
| 905 | 904 | c64_vic_interrupt); |
| 906 | 905 | } |
| 907 | 906 | cia_reset(); |
| 908 | | add_exit_callback(Machine, c64_driver_shutdown); |
| 907 | add_exit_callback(machine, c64_driver_shutdown); |
| 909 | 908 | } |
| 910 | 909 | |
| 911 | 910 | DRIVER_INIT( c64 ) |
| 912 | 911 | { |
| 913 | | c64_common_driver_init (); |
| 912 | c64_common_driver_init (machine); |
| 914 | 913 | } |
| 915 | 914 | |
| 916 | 915 | DRIVER_INIT( c64pal ) |
| 917 | 916 | { |
| 918 | 917 | c64_pal = 1; |
| 919 | | c64_common_driver_init (); |
| 918 | c64_common_driver_init (machine); |
| 920 | 919 | } |
| 921 | 920 | |
| 922 | 921 | DRIVER_INIT( ultimax ) |
| 923 | 922 | { |
| 924 | 923 | ultimax = 1; |
| 925 | 924 | c64_cia1_on = 0; |
| 926 | | c64_common_driver_init (); |
| 925 | c64_common_driver_init (machine); |
| 927 | 926 | } |
| 928 | 927 | |
| 929 | 928 | DRIVER_INIT( c64gs ) |
| r1980 | r1981 | |
| 931 | 930 | c64_pal = 1; |
| 932 | 931 | c64_tape_on = 0; |
| 933 | 932 | c64_cia1_on = 1; |
| 934 | | c64_common_driver_init (); |
| 933 | c64_common_driver_init (machine); |
| 935 | 934 | } |
| 936 | 935 | |
| 937 | 936 | DRIVER_INIT( sx64 ) |
| r1980 | r1981 | |
| 939 | 938 | VC1541_CONFIG vc1541 = { 1, 8 }; |
| 940 | 939 | c64_tape_on = 0; |
| 941 | 940 | c64_pal = 1; |
| 942 | | c64_common_driver_init (); |
| 941 | c64_common_driver_init (machine); |
| 943 | 942 | vc1541_config (0, 0, &vc1541); |
| 944 | 943 | } |
| 945 | 944 | |
| r1980 | r1981 | |
| 949 | 948 | vc20_tape_close (); |
| 950 | 949 | } |
| 951 | 950 | |
| 952 | | void c64_common_init_machine (void) |
| 951 | void c64_common_init_machine (running_machine *machine) |
| 953 | 952 | { |
| 954 | 953 | #ifdef VC1541 |
| 955 | 954 | vc1541_reset (); |
| r1980 | r1981 | |
| 958 | 957 | if (c64_cia1_on) |
| 959 | 958 | { |
| 960 | 959 | cbm_serial_reset_write (0); |
| 961 | | cbm_drive_0_config (SERIAL, is_c65() ? 10 : 8); |
| 962 | | cbm_drive_1_config (SERIAL, is_c65() ? 11 : 9); |
| 960 | cbm_drive_0_config (SERIAL, is_c65(machine) ? 10 : 8); |
| 961 | cbm_drive_1_config (SERIAL, is_c65(machine) ? 11 : 9); |
| 963 | 962 | serial_clock = serial_data = serial_atn = 1; |
| 964 | 963 | } |
| 965 | 964 | c64_vicaddr = c64_memory; |
| r1980 | r1981 | |
| 992 | 991 | c64_port_data = 0x17; |
| 993 | 992 | |
| 994 | 993 | c64_io_mirror = auto_malloc( 0x1000 ); |
| 995 | | c64_common_init_machine (); |
| 994 | c64_common_init_machine (machine); |
| 996 | 995 | |
| 997 | 996 | c64_rom_recognition (); |
| 998 | 997 | c64_rom_load(); |
| 999 | 998 | |
| 1000 | | if (is_c128()) |
| 1001 | | c128_bankswitch_64 (1); |
| 999 | if (is_c128(machine)) |
| 1000 | c128_bankswitch_64 (machine, 1); |
| 1002 | 1001 | if (!ultimax) |
| 1003 | 1002 | c64_bankswitch (1); |
| 1004 | 1003 | memory_set_opbase_handler( 0, c64_opbase ); |
| r1980 | r1981 | |
| 1137 | 1136 | static int monitor=-1; |
| 1138 | 1137 | int value, value2; |
| 1139 | 1138 | |
| 1140 | | c64_nmi(); |
| 1139 | c64_nmi(machine); |
| 1141 | 1140 | |
| 1142 | | if (is_c128()) |
| 1141 | if (is_c128(machine)) |
| 1143 | 1142 | { |
| 1144 | 1143 | if (MONITOR_TV!=monitor) |
| 1145 | 1144 | { |
| r1980 | r1981 | |
| 1160 | 1159 | } |
| 1161 | 1160 | |
| 1162 | 1161 | value = 0xff; |
| 1163 | | if (is_c128()) |
| 1162 | if (is_c128(machine)) |
| 1164 | 1163 | { |
| 1165 | 1164 | if (C128_KEY_CURSOR_DOWN) |
| 1166 | 1165 | value &= ~0x80; |
| r1980 | r1981 | |
| 1174 | 1173 | value &= ~8; |
| 1175 | 1174 | if (C128_KEY_CURSOR_RIGHT) |
| 1176 | 1175 | value &= ~4; |
| 1177 | | } else if (is_c65()) { |
| 1176 | } else if (is_c65(machine)) { |
| 1178 | 1177 | if (C65_KEY_CURSOR_DOWN) |
| 1179 | 1178 | value &= ~0x80; |
| 1180 | 1179 | if (C65_KEY_F5) |
| r1980 | r1981 | |
| 1304 | 1303 | value &= ~0x40; |
| 1305 | 1304 | if (KEY_EQUALS) |
| 1306 | 1305 | value &= ~0x20; |
| 1307 | | if (is_c128()) |
| 1306 | if (is_c128(machine)) |
| 1308 | 1307 | { |
| 1309 | 1308 | if (C128_KEY_RIGHT_SHIFT) |
| 1310 | 1309 | value &= ~0x10; |
| 1311 | 1310 | } |
| 1312 | | else if (is_c65()) |
| 1311 | else if (is_c65(machine)) |
| 1313 | 1312 | { |
| 1314 | 1313 | if (C65_KEY_RIGHT_SHIFT) |
| 1315 | 1314 | value &= ~0x10; |
| r1980 | r1981 | |
| 1330 | 1329 | c64_keyline[6] = value; |
| 1331 | 1330 | |
| 1332 | 1331 | value = 0xff; |
| 1333 | | if (is_c65()) { |
| 1332 | if (is_c65(machine)) { |
| 1334 | 1333 | if (C65_KEY_STOP) |
| 1335 | 1334 | value &= ~0x80; |
| 1336 | 1335 | if (C65_KEY_SPACE) |
| r1980 | r1981 | |
| 1405 | 1404 | } |
| 1406 | 1405 | c64_keyline[9] = value2; |
| 1407 | 1406 | |
| 1408 | | if (is_c128()) |
| 1407 | if (is_c128(machine)) |
| 1409 | 1408 | { |
| 1410 | 1409 | value = 0xff; |
| 1411 | 1410 | if (KEY_NUM1) |
| r1980 | r1981 | |
| 1465 | 1464 | c128_keyline[2] = value; |
| 1466 | 1465 | } |
| 1467 | 1466 | |
| 1468 | | if (is_c65()) { |
| 1467 | if (is_c65(machine)) { |
| 1469 | 1468 | value = 0xff; |
| 1470 | 1469 | if (C65_KEY_ESCAPE) |
| 1471 | 1470 | value &= ~0x80; |
src/mess/machine/genesis.c
| r1980 | r1981 | |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | 23 | #include "driver.h" |
| 24 | | #include "deprecat.h" |
| 25 | 24 | #include "includes/genesis.h" |
| 26 | 25 | #include "sound/2612intf.h" |
| 27 | 26 | #include "sound/sn76496.h" |
| r1980 | r1981 | |
| 84 | 83 | }; |
| 85 | 84 | |
| 86 | 85 | |
| 87 | | void genesis_vdp_start (genvdp *current_vdp) |
| 86 | static void genesis_vdp_start (running_machine *machine, genvdp *current_vdp) |
| 88 | 87 | { |
| 89 | 88 | int gfx_index=0; |
| 90 | 89 | |
| r1980 | r1981 | |
| 108 | 107 | |
| 109 | 108 | /* find first empty slot to decode gfx */ |
| 110 | 109 | for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) |
| 111 | | if (Machine->gfx[gfx_index] == 0) |
| 110 | if (machine->gfx[gfx_index] == 0) |
| 112 | 111 | break; |
| 113 | 112 | |
| 114 | 113 | // if (gfx_index == MAX_GFX_ELEMENTS) |
| 115 | 114 | // return 1; |
| 116 | 115 | |
| 117 | 116 | /* create the char set (gfx will then be updated dynamically from RAM) */ |
| 118 | | Machine->gfx[gfx_index] = allocgfx(&charlayout); |
| 119 | | decodegfx(Machine->gfx[gfx_index] , (UINT8 *)¤t_vdp->genesis_vdp_vram, 0, 1); |
| 117 | machine->gfx[gfx_index] = allocgfx(&charlayout); |
| 118 | decodegfx(machine->gfx[gfx_index] , (UINT8 *)¤t_vdp->genesis_vdp_vram, 0, 1); |
| 120 | 119 | |
| 121 | 120 | /* set the color information */ |
| 122 | | Machine->gfx[gfx_index]->total_colors = 0x4; |
| 121 | machine->gfx[gfx_index]->total_colors = 0x4; |
| 123 | 122 | current_vdp -> genesis_vdp_index = gfx_index; |
| 124 | 123 | |
| 125 | 124 | } |
| r1980 | r1981 | |
| 179 | 178 | } |
| 180 | 179 | |
| 181 | 180 | |
| 182 | | void genesis_vdp_spritebuffer_scanline (genvdp *current_vdp, int line, int reqpri) |
| 181 | static void genesis_vdp_spritebuffer_scanline (running_machine *machine, genvdp *current_vdp, int line, int reqpri) |
| 183 | 182 | { |
| 184 | | const gfx_element *gfx = Machine->gfx[0]; |
| 183 | const gfx_element *gfx = machine->gfx[0]; |
| 185 | 184 | UINT8 *srcgfx = gfx->gfxdata; |
| 186 | 185 | int shadowmode = genesis_vdp.genesis_vdp_regs[0x0c]&0x08; |
| 187 | 186 | int sbr = genesis_vdp.genesis_vdp_regs[0x05]<<9; |
| r1980 | r1981 | |
| 339 | 338 | c0-ff are unused |
| 340 | 339 | */ |
| 341 | 340 | |
| 342 | | void genesis_vdp_render_scanline (genvdp *current_vdp, int line) |
| 341 | static void genesis_vdp_render_scanline (running_machine *machine, genvdp *current_vdp, int line) |
| 343 | 342 | { |
| 344 | | const gfx_element *gfx = Machine->gfx[0]; |
| 343 | const gfx_element *gfx = machine->gfx[0]; |
| 345 | 344 | |
| 346 | 345 | int _2tileblock; |
| 347 | 346 | UINT8 *srcgfx = gfx->gfxdata; |
| r1980 | r1981 | |
| 738 | 737 | } |
| 739 | 738 | } |
| 740 | 739 | |
| 741 | | genesis_vdp_spritebuffer_scanline(current_vdp, line, 0); |
| 740 | genesis_vdp_spritebuffer_scanline(machine,current_vdp, line, 0); |
| 742 | 741 | |
| 743 | 742 | /* Scroll B High */ |
| 744 | 743 | renderto = current_vdp->genesis_vdp_bg_render_buffer; |
| r1980 | r1981 | |
| 1017 | 1016 | } |
| 1018 | 1017 | } |
| 1019 | 1018 | |
| 1020 | | genesis_vdp_spritebuffer_scanline(current_vdp, line, 1); |
| 1019 | genesis_vdp_spritebuffer_scanline(machine, current_vdp, line, 1); |
| 1021 | 1020 | |
| 1022 | 1021 | |
| 1023 | 1022 | } |
| r1980 | r1981 | |
| 1025 | 1024 | |
| 1026 | 1025 | VIDEO_START(genesis) |
| 1027 | 1026 | { |
| 1028 | | genesis_vdp_start (&genesis_vdp); |
| 1027 | genesis_vdp_start (machine, &genesis_vdp); |
| 1029 | 1028 | oldscreenmode = 0xff; // driver specific |
| 1030 | 1029 | VIDEO_START_CALL(generic_bitmapped); |
| 1031 | 1030 | } |
| r1980 | r1981 | |
| 2215 | 2214 | |
| 2216 | 2215 | */ |
| 2217 | 2216 | |
| 2218 | | void genesis_init_frame(void) |
| 2217 | static void genesis_init_frame(running_machine *machine) |
| 2219 | 2218 | { |
| 2220 | 2219 | int i; |
| 2221 | 2220 | if ((genesis_vdp.genesis_vdp_regs[0x0c]&0x81) != oldscreenmode) |
| r1980 | r1981 | |
| 2238 | 2237 | { |
| 2239 | 2238 | if (genesis_vdp.genesis_vdp_vram_is_dirty[i]) |
| 2240 | 2239 | { |
| 2241 | | decodechar(Machine->gfx[genesis_vdp.genesis_vdp_index], i,(UINT8 *)genesis_vdp.genesis_vdp_vram); |
| 2240 | decodechar(machine->gfx[genesis_vdp.genesis_vdp_index], i,(UINT8 *)genesis_vdp.genesis_vdp_vram); |
| 2242 | 2241 | genesis_vdp.genesis_vdp_vram_is_dirty[i] = 0; |
| 2243 | 2242 | } |
| 2244 | 2243 | } |
| r1980 | r1981 | |
| 2253 | 2252 | |
| 2254 | 2253 | genesis_vdp.irq4_counter--; |
| 2255 | 2254 | |
| 2256 | | if (scan == 0) genesis_init_frame(); // decode gfx tiles etc. |
| 2255 | if (scan == 0) genesis_init_frame(machine); // decode gfx tiles etc. |
| 2257 | 2256 | |
| 2258 | 2257 | if (scan==0) genesis_vdp.irq4_counter = genesis_vdp.genesis_vdp_regs[0x0a]; |
| 2259 | 2258 | |
| r1980 | r1981 | |
| 2281 | 2280 | |
| 2282 | 2281 | if (( scan>=0 ) && ( genesis_vdp.sline <224)) |
| 2283 | 2282 | { |
| 2284 | | genesis_vdp_render_scanline(&genesis_vdp,genesis_vdp.sline); |
| 2283 | genesis_vdp_render_scanline(machine, &genesis_vdp,genesis_vdp.sline); |
| 2285 | 2284 | genesis_vdp_draw_scanline(&genesis_vdp,genesis_vdp.sline); |
| 2286 | 2285 | } |
| 2287 | 2286 | |
src/mess/machine/pce.c
| r1980 | r1981 | |
| 95 | 95 | |
| 96 | 96 | /* prototypes */ |
| 97 | 97 | static void pce_cd_init( void ); |
| 98 | | static void pce_cd_set_irq_line( int num, int state ); |
| 98 | static void pce_cd_set_irq_line( running_machine *machine, int num, int state ); |
| 99 | 99 | static TIMER_CALLBACK( pce_cd_adpcm_dma_timer_callback ); |
| 100 | 100 | |
| 101 | 101 | |
| r1980 | r1981 | |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | pce_cd_reply_status_byte( SCSI_STATUS_OK ); |
| 400 | | pce_cd_set_irq_line( PCE_CD_IRQ_TRANSFER_DONE, ASSERT_LINE ); |
| 400 | pce_cd_set_irq_line( Machine, PCE_CD_IRQ_TRANSFER_DONE, ASSERT_LINE ); |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | /* 0xD9 - SET AUDIO PLAYBACK END POSITION (NEC) */ |
| r1980 | r1981 | |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | pce_cd_reply_status_byte( SCSI_STATUS_OK ); |
| 445 | | pce_cd_set_irq_line( PCE_CD_IRQ_TRANSFER_DONE, ASSERT_LINE ); |
| 445 | pce_cd_set_irq_line( Machine, PCE_CD_IRQ_TRANSFER_DONE, ASSERT_LINE ); |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | /* 0xDA - PAUSE (NEC) */ |
| r1980 | r1981 | |
| 648 | 648 | |
| 649 | 649 | if ( ! pce_cd.scsi_REQ && ! pce_cd.scsi_ACK ) { |
| 650 | 650 | if ( pce_cd.data_buffer_index == pce_cd.data_buffer_size ) { |
| 651 | | pce_cd_set_irq_line( PCE_CD_IRQ_TRANSFER_READY, CLEAR_LINE ); |
| 651 | pce_cd_set_irq_line( Machine, PCE_CD_IRQ_TRANSFER_READY, CLEAR_LINE ); |
| 652 | 652 | if ( pce_cd.data_transferred ) { |
| 653 | 653 | pce_cd.data_transferred = 0; |
| 654 | 654 | pce_cd_reply_status_byte( SCSI_STATUS_OK ); |
| 655 | | pce_cd_set_irq_line( PCE_CD_IRQ_TRANSFER_DONE, ASSERT_LINE ); |
| 655 | pce_cd_set_irq_line( Machine, PCE_CD_IRQ_TRANSFER_DONE, ASSERT_LINE ); |
| 656 | 656 | } |
| 657 | 657 | } else { |
| 658 | 658 | logerror("Transfer byte from offset %d\n", pce_cd.data_buffer_index); |
| r1980 | r1981 | |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | /* Update internal CD statuses */ |
| 686 | | static void pce_cd_update( void ) { |
| 686 | static void pce_cd_update( running_machine *machine ) { |
| 687 | 687 | /* Check for reset of CD unit */ |
| 688 | 688 | if ( pce_cd.scsi_RST != pce_cd.scsi_last_RST ) { |
| 689 | 689 | if ( pce_cd.scsi_RST ) { |
| r1980 | r1981 | |
| 702 | 702 | logerror( "freeing bus\n" ); |
| 703 | 703 | pce_cd.selected = 0; |
| 704 | 704 | pce_cd.scsi_CD = pce_cd.scsi_MSG = pce_cd.scsi_IO = pce_cd.scsi_REQ = 0; |
| 705 | | pce_cd_set_irq_line( PCE_CD_IRQ_TRANSFER_DONE, CLEAR_LINE ); |
| 705 | pce_cd_set_irq_line( machine, PCE_CD_IRQ_TRANSFER_DONE, CLEAR_LINE ); |
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /* Select the CD device */ |
| r1980 | r1981 | |
| 740 | 740 | } |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | | static void pce_cd_set_irq_line( int num, int state ) { |
| 743 | static void pce_cd_set_irq_line( running_machine *machine, int num, int state ) { |
| 744 | 744 | switch( num ) { |
| 745 | 745 | case PCE_CD_IRQ_TRANSFER_DONE: |
| 746 | 746 | if ( state == ASSERT_LINE ) { |
| r1980 | r1981 | |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | if ( pce_cd.regs[0x02] & pce_cd.regs[0x03] & ( PCE_CD_IRQ_TRANSFER_DONE | PCE_CD_IRQ_TRANSFER_READY ) ) { |
| 764 | | cpunum_set_input_line(Machine, 0, 1, ASSERT_LINE ); |
| 764 | cpunum_set_input_line(machine, 0, 1, ASSERT_LINE ); |
| 765 | 765 | } else { |
| 766 | | cpunum_set_input_line(Machine, 0, 1, CLEAR_LINE ); |
| 766 | cpunum_set_input_line(machine, 0, 1, CLEAR_LINE ); |
| 767 | 767 | } |
| 768 | 768 | } |
| 769 | 769 | |
| r1980 | r1981 | |
| 846 | 846 | |
| 847 | 847 | WRITE8_HANDLER( pce_cd_intf_w ) { |
| 848 | 848 | logerror("%04X: write to CD interface offset %02X, data %02X\n", activecpu_get_pc(), offset, data ); |
| 849 | | pce_cd_update(); |
| 849 | pce_cd_update(machine); |
| 850 | 850 | |
| 851 | 851 | switch( offset ) { |
| 852 | 852 | case 0x00: /* CDC status */ |
| 853 | 853 | /* select device (which bits??) */ |
| 854 | 854 | pce_cd.scsi_SEL = 1; |
| 855 | | pce_cd_update(); |
| 855 | pce_cd_update(machine); |
| 856 | 856 | pce_cd.scsi_SEL = 0; |
| 857 | 857 | break; |
| 858 | 858 | case 0x01: /* CDC command / status / data */ |
| r1980 | r1981 | |
| 865 | 865 | /* bit 2 - ?? irq */ |
| 866 | 866 | pce_cd.scsi_ACK = data & 0x80; |
| 867 | 867 | /* Don't set or reset any irq lines, but just verify the current state */ |
| 868 | | pce_cd_set_irq_line( 0, 0 ); |
| 868 | pce_cd_set_irq_line( machine, 0, 0 ); |
| 869 | 869 | break; |
| 870 | 870 | case 0x03: /* BRAM lock / CD status / IRQ - Read Only register */ |
| 871 | 871 | break; |
| r1980 | r1981 | |
| 925 | 925 | return; |
| 926 | 926 | } |
| 927 | 927 | pce_cd.regs[offset] = data; |
| 928 | | pce_cd_update(); |
| 928 | pce_cd_update(machine); |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | static TIMER_CALLBACK( pce_cd_clear_ack ) { |
| 932 | | pce_cd_update(); |
| 932 | pce_cd_update(machine); |
| 933 | 933 | pce_cd.scsi_ACK = 0; |
| 934 | | pce_cd_update(); |
| 934 | pce_cd_update(machine); |
| 935 | 935 | if ( pce_cd.scsi_CD ) { |
| 936 | 936 | pce_cd.regs[0x0B] &= 0xFE; |
| 937 | 937 | } |
| r1980 | r1981 | |
| 958 | 958 | READ8_HANDLER( pce_cd_intf_r ) { |
| 959 | 959 | UINT8 data = pce_cd.regs[offset & 0x0F]; |
| 960 | 960 | |
| 961 | | pce_cd_update(); |
| 961 | pce_cd_update(machine); |
| 962 | 962 | |
| 963 | 963 | logerror("%04X: read from CD interface offset %02X\n", activecpu_get_pc(), offset ); |
| 964 | 964 | switch( offset ) { |
src/mess/machine/atarifdc.c
| r1980 | r1981 | |
| 16 | 16 | #include "sound/pokey.h" |
| 17 | 17 | #include "machine/6821pia.h" |
| 18 | 18 | #include "image.h" |
| 19 | | #include "deprecat.h" |
| 20 | 19 | |
| 21 | 20 | #define VERBOSE_SERIAL 0 |
| 22 | 21 | #define VERBOSE_CHKSUM 0 |
| r1980 | r1981 | |
| 403 | 402 | make_chksum(&atari_fdc.serin_chksum, data); |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | | static void a800_serial_command(void) |
| 405 | static void a800_serial_command(running_machine *machine) |
| 407 | 406 | { |
| 408 | | int i, drive, sector, offset; |
| 407 | int i, drive, sector, offset; |
| 409 | 408 | |
| 410 | 409 | if( !atari_fdc.serout_offs ) |
| 411 | 410 | { |
| r1980 | r1981 | |
| 434 | 433 | { |
| 435 | 434 | logerror("atari unsupported drive #%d\n", drive+1); |
| 436 | 435 | sprintf(atari_frame_message, "DRIVE #%d not supported", drive+1); |
| 437 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 436 | atari_frame_counter = machine->screen[0].refresh/2; |
| 438 | 437 | return; |
| 439 | 438 | } |
| 440 | 439 | |
| r1980 | r1981 | |
| 445 | 444 | { |
| 446 | 445 | case 'S': /* status */ |
| 447 | 446 | sprintf(atari_frame_message, "DRIVE #%d STATUS", drive+1); |
| 448 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 447 | atari_frame_counter = machine->screen[0].refresh/2; |
| 449 | 448 | |
| 450 | 449 | if (VERBOSE_SERIAL) |
| 451 | 450 | logerror("atari status\n"); |
| r1980 | r1981 | |
| 488 | 487 | if( sector < 1 || sector > drv[drive].sectors ) |
| 489 | 488 | { |
| 490 | 489 | sprintf(atari_frame_message, "DRIVE #%d READ SECTOR #%3d - ERR", drive+1, sector); |
| 491 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 490 | atari_frame_counter = machine->screen[0].refresh/2; |
| 492 | 491 | |
| 493 | 492 | if (VERBOSE_SERIAL) |
| 494 | 493 | logerror("atari bad sector #\n"); |
| r1980 | r1981 | |
| 501 | 500 | if (sector < 4) /* sector 1 .. 3 might be different length */ |
| 502 | 501 | { |
| 503 | 502 | sprintf(atari_frame_message, "DRIVE #%d READ SECTOR #%3d - SD", drive+1, sector); |
| 504 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 503 | atari_frame_counter = machine->screen[0].refresh/2; |
| 505 | 504 | offset = (sector - 1) * drv[drive].bseclen + drv[drive].header_skip; |
| 506 | 505 | for (i = 0; i < 128; i++) |
| 507 | 506 | add_serin(drv[drive].image[offset++],1); |
| r1980 | r1981 | |
| 509 | 508 | else |
| 510 | 509 | { |
| 511 | 510 | sprintf(atari_frame_message, "DRIVE #%d READ SECTOR #%3d - %cD", drive+1, sector, (drv[drive].seclen == 128) ? 'S' : 'D'); |
| 512 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 511 | atari_frame_counter = machine->screen[0].refresh/2; |
| 513 | 512 | offset = (sector - 1) * drv[drive].seclen + drv[drive].header_skip; |
| 514 | 513 | for (i = 0; i < drv[drive].seclen; i++) |
| 515 | 514 | add_serin(drv[drive].image[offset++],1); |
| r1980 | r1981 | |
| 526 | 525 | { |
| 527 | 526 | add_serout(drv[drive].bseclen); |
| 528 | 527 | sprintf(atari_frame_message, "DRIVE #%d WRITE SECTOR #%3d - SD", drive+1, sector); |
| 529 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 528 | atari_frame_counter = machine->screen[0].refresh/2; |
| 530 | 529 | } |
| 531 | 530 | else |
| 532 | 531 | { |
| 533 | 532 | add_serout(drv[drive].seclen); |
| 534 | 533 | sprintf(atari_frame_message, "DRIVE #%d WRITE SECTOR #%3d - %cD", drive+1, sector, (drv[drive].seclen == 128) ? 'S' : 'D'); |
| 535 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 534 | atari_frame_counter = machine->screen[0].refresh/2; |
| 536 | 535 | } |
| 537 | 536 | break; |
| 538 | 537 | |
| r1980 | r1981 | |
| 545 | 544 | { |
| 546 | 545 | add_serout(drv[drive].bseclen); |
| 547 | 546 | sprintf(atari_frame_message, "DRIVE #%d PUT SECTOR #%3d - SD", drive+1, sector); |
| 548 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 547 | atari_frame_counter = machine->screen[0].refresh/2; |
| 549 | 548 | } |
| 550 | 549 | else |
| 551 | 550 | { |
| 552 | 551 | add_serout(drv[drive].seclen); |
| 553 | 552 | sprintf(atari_frame_message, "DRIVE #%d PUT SECTOR #%3d - %cD", drive+1, sector, (drv[drive].seclen == 128) ? 'S' : 'D'); |
| 554 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 553 | atari_frame_counter = machine->screen[0].refresh/2; |
| 555 | 554 | } |
| 556 | 555 | break; |
| 557 | 556 | |
| r1980 | r1981 | |
| 560 | 559 | logerror("atari format SD drive #%d\n", drive+1); |
| 561 | 560 | |
| 562 | 561 | sprintf(atari_frame_message, "DRIVE #%d FORMAT SD", drive+1); |
| 563 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 562 | atari_frame_counter = machine->screen[0].refresh/2; |
| 564 | 563 | add_serin('A',0); /* acknowledge */ |
| 565 | 564 | add_serin('C',0); /* completed */ |
| 566 | 565 | for (i = 0; i < 128; i++) |
| r1980 | r1981 | |
| 573 | 572 | logerror("atari format DD drive #%d\n", drive+1); |
| 574 | 573 | |
| 575 | 574 | sprintf(atari_frame_message, "DRIVE #%d FORMAT DD", drive+1); |
| 576 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 575 | atari_frame_counter = machine->screen[0].refresh/2; |
| 577 | 576 | add_serin('A',0); /* acknowledge */ |
| 578 | 577 | add_serin('C',0); /* completed */ |
| 579 | 578 | for (i = 0; i < 256; i++) |
| r1980 | r1981 | |
| 586 | 585 | logerror("atari unknown command #%c\n", atari_fdc.serout_buff[1]); |
| 587 | 586 | |
| 588 | 587 | sprintf(atari_frame_message, "DRIVE #%d UNKNOWN CMD '%c'", drive+1, atari_fdc.serout_buff[1]); |
| 589 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 588 | atari_frame_counter = machine->screen[0].refresh/2; |
| 590 | 589 | add_serin('N',0); /* negative acknowledge */ |
| 591 | 590 | } |
| 592 | 591 | } |
| 593 | 592 | else |
| 594 | 593 | { |
| 595 | 594 | sprintf(atari_frame_message, "serial cmd chksum error"); |
| 596 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 595 | atari_frame_counter = machine->screen[0].refresh/2; |
| 597 | 596 | if (VERBOSE_SERIAL) |
| 598 | 597 | logerror("BAD\n"); |
| 599 | 598 | |
| r1980 | r1981 | |
| 603 | 602 | logerror("atari %d bytes to read\n", atari_fdc.serin_count); |
| 604 | 603 | } |
| 605 | 604 | |
| 606 | | static void a800_serial_write(void) |
| 605 | static void a800_serial_write(running_machine *machine) |
| 607 | 606 | { |
| 608 | 607 | int i, drive, sector, offset; |
| 609 | 608 | |
| r1980 | r1981 | |
| 637 | 636 | for (i = 0; i < 128; i++) |
| 638 | 637 | drv[drive].image[offset++] = atari_fdc.serout_buff[5+i]; |
| 639 | 638 | sprintf(atari_frame_message, "DRIVE #%d WROTE SECTOR #%3d - SD", drive+1, sector); |
| 640 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 639 | atari_frame_counter = machine->screen[0].refresh/2; |
| 641 | 640 | } |
| 642 | 641 | else |
| 643 | 642 | { |
| r1980 | r1981 | |
| 649 | 648 | for (i = 0; i < drv[drive].seclen; i++) |
| 650 | 649 | drv[drive].image[offset++] = atari_fdc.serout_buff[5+i]; |
| 651 | 650 | sprintf(atari_frame_message, "DRIVE #%d WROTE SECTOR #%3d - %cD", drive+1, sector, (drv[drive].seclen == 128) ? 'S' : 'D'); |
| 652 | | atari_frame_counter = Machine->screen[0].refresh/2; |
| 651 | atari_frame_counter = machine->screen[0].refresh/2; |
| 653 | 652 | } |
| 654 | 653 | add_serin('C',0); |
| 655 | 654 | } |
| r1980 | r1981 | |
| 715 | 714 | atari_fdc.serout_chksum ^= data; |
| 716 | 715 | /* if the attention line is high, this should be data */ |
| 717 | 716 | if (pia_get_irq_b(0)) |
| 718 | | a800_serial_write(); |
| 717 | a800_serial_write(machine); |
| 719 | 718 | } |
| 720 | 719 | else |
| 721 | 720 | { |
| r1980 | r1981 | |
| 735 | 734 | else |
| 736 | 735 | { |
| 737 | 736 | atari_fdc.serin_delay = 0; |
| 738 | | a800_serial_command(); |
| 737 | a800_serial_command(machine); |
| 739 | 738 | } |
| 740 | 739 | } |
src/mess/machine/compis.c
| r1980 | r1981 | |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | |
| 606 | | static void update_interrupt_state(void) |
| 606 | static void update_interrupt_state(running_machine *machine) |
| 607 | 607 | { |
| 608 | 608 | int i, j, new_vector = 0; |
| 609 | 609 | |
| r1980 | r1981 | |
| 682 | 682 | /* generate the appropriate interrupt */ |
| 683 | 683 | i186.intr.poll_status = 0x8000 | new_vector; |
| 684 | 684 | if (!i186.intr.pending) |
| 685 | | cpunum_set_input_line(Machine, 2, 0, ASSERT_LINE); |
| 685 | cpunum_set_input_line(machine, 2, 0, ASSERT_LINE); |
| 686 | 686 | i186.intr.pending = 1; |
| 687 | | cpu_trigger(Machine, CPU_RESUME_TRIGGER); |
| 687 | cpu_trigger(machine, CPU_RESUME_TRIGGER); |
| 688 | 688 | if (LOG_OPTIMIZATION) logerror(" - trigger due to interrupt pending\n"); |
| 689 | 689 | if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", attotime_to_double(timer_get_time()), new_vector); |
| 690 | 690 | } |
| r1980 | r1981 | |
| 770 | 770 | if (t->control & 0x2000) |
| 771 | 771 | { |
| 772 | 772 | i186.intr.status |= 0x01 << which; |
| 773 | | update_interrupt_state(); |
| 773 | update_interrupt_state(machine); |
| 774 | 774 | if (LOG_TIMER) logerror(" Generating timer interrupt\n"); |
| 775 | 775 | } |
| 776 | 776 | |
| r1980 | r1981 | |
| 963 | 963 | { |
| 964 | 964 | if (LOG_DMA) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source); |
| 965 | 965 | i186.intr.request |= 0x04 << which; |
| 966 | | update_interrupt_state(); |
| 966 | update_interrupt_state(machine); |
| 967 | 967 | } |
| 968 | 968 | } |
| 969 | 969 | |
| r1980 | r1981 | |
| 1279 | 1279 | if (LOG_PORTS) |
| 1280 | 1280 | logerror("%05X:80186 EOI = %04X\n", activecpu_get_pc(), data16); |
| 1281 | 1281 | handle_eoi(0x8000); |
| 1282 | | update_interrupt_state(); |
| 1282 | update_interrupt_state(machine); |
| 1283 | 1283 | break; |
| 1284 | 1284 | |
| 1285 | 1285 | case 0x24: |
| r1980 | r1981 | |
| 1303 | 1303 | i186.intr.ext[1] = (i186.intr.ext[1] & ~0x08) | ((data16 >> 2) & 0x08); |
| 1304 | 1304 | i186.intr.ext[2] = (i186.intr.ext[2] & ~0x08) | ((data16 >> 3) & 0x08); |
| 1305 | 1305 | i186.intr.ext[3] = (i186.intr.ext[3] & ~0x08) | ((data16 >> 4) & 0x08); |
| 1306 | | update_interrupt_state(); |
| 1306 | update_interrupt_state(machine); |
| 1307 | 1307 | break; |
| 1308 | 1308 | |
| 1309 | 1309 | case 0x2a: |
| 1310 | 1310 | if (LOG_PORTS) logerror("%05X:80186 interrupt priority mask = %04X\n", activecpu_get_pc(), data16); |
| 1311 | 1311 | i186.intr.priority_mask = data16 & 0x0007; |
| 1312 | | update_interrupt_state(); |
| 1312 | update_interrupt_state(machine); |
| 1313 | 1313 | break; |
| 1314 | 1314 | |
| 1315 | 1315 | case 0x2c: |
| 1316 | 1316 | if (LOG_PORTS) logerror("%05X:80186 interrupt in-service = %04X\n", activecpu_get_pc(), data16); |
| 1317 | 1317 | i186.intr.in_service = data16 & 0x00ff; |
| 1318 | | update_interrupt_state(); |
| 1318 | update_interrupt_state(machine); |
| 1319 | 1319 | break; |
| 1320 | 1320 | |
| 1321 | 1321 | case 0x2e: |
| 1322 | 1322 | if (LOG_PORTS) logerror("%05X:80186 interrupt request = %04X\n", activecpu_get_pc(), data16); |
| 1323 | 1323 | i186.intr.request = (i186.intr.request & ~0x00c0) | (data16 & 0x00c0); |
| 1324 | | update_interrupt_state(); |
| 1324 | update_interrupt_state(machine); |
| 1325 | 1325 | break; |
| 1326 | 1326 | |
| 1327 | 1327 | case 0x30: |
| 1328 | 1328 | if (LOG_PORTS) logerror("%05X:WARNING - wrote to 80186 interrupt status = %04X\n", activecpu_get_pc(), data16); |
| 1329 | 1329 | i186.intr.status = (i186.intr.status & ~0x8007) | (data16 & 0x8007); |
| 1330 | | update_interrupt_state(); |
| 1330 | update_interrupt_state(machine); |
| 1331 | 1331 | break; |
| 1332 | 1332 | |
| 1333 | 1333 | case 0x32: |
| r1980 | r1981 | |
| 1592 | 1592 | compis_fdc_reset(); |
| 1593 | 1593 | |
| 1594 | 1594 | /* RTC */ |
| 1595 | | mm58274c_init(0, 0); |
| 1595 | mm58274c_init(machine, 0, 0); |
| 1596 | 1596 | |
| 1597 | 1597 | /* Setup the USART */ |
| 1598 | 1598 | msm8251_init(&compis_usart_interface); |