src/mess/machine/svi318.c
| r1182 | r1183 | |
| 23 | 23 | #include "sound/dac.h" |
| 24 | 24 | #include "sound/ay8910.h" |
| 25 | 25 | #include "image.h" |
| 26 | #include "video/crtc6845.h" |
| 26 | 27 | |
| 27 | 28 | enum { |
| 28 | 29 | SVI_INTERNAL = 0, |
| r1182 | r1183 | |
| 405 | 406 | |
| 406 | 407 | /* 80 column card */ |
| 407 | 408 | |
| 408 | | #include "video/m6845.h" |
| 409 | 409 | static int svi318_80col_state; |
| 410 | 410 | static char *svi318_80col_ram = NULL; |
| 411 | 411 | |
| 412 | | static int svi318_6845_RA = 0; |
| 413 | | static int svi318_scr_x = 0; |
| 414 | | static int svi318_scr_y = 0; |
| 415 | | static int svi318_HSync = 0; |
| 416 | | static int svi318_VSync = 0; |
| 417 | | static int svi318_DE = 0; |
| 412 | //static int svi318_6845_RA = 0; |
| 413 | //static int svi318_scr_x = 0; |
| 414 | //static int svi318_scr_y = 0; |
| 415 | //static int svi318_HSync = 0; |
| 416 | //static int svi318_VSync = 0; |
| 417 | //static int svi318_DE = 0; |
| 418 | // |
| 419 | //// called when the 6845 changes the character row |
| 420 | //static void svi318_Set_RA(int offset, int data) |
| 421 | //{ |
| 422 | // svi318_6845_RA=data; |
| 423 | //} |
| 424 | // |
| 425 | // |
| 426 | //// called when the 6845 changes the HSync |
| 427 | //static void svi318_Set_HSync(int offset, int data) |
| 428 | //{ |
| 429 | // svi318_HSync=data; |
| 430 | // if(!svi318_HSync) |
| 431 | // { |
| 432 | // svi318_scr_y++; |
| 433 | // svi318_scr_x = -40; |
| 434 | // } |
| 435 | //} |
| 436 | // |
| 437 | //// called when the 6845 changes the VSync |
| 438 | //static void svi318_Set_VSync(int offset, int data) |
| 439 | //{ |
| 440 | // svi318_VSync=data; |
| 441 | // if (!svi318_VSync) |
| 442 | // { |
| 443 | // svi318_scr_y = 0; |
| 444 | // } |
| 445 | //} |
| 446 | // |
| 447 | //static void svi318_Set_DE(int offset, int data) |
| 448 | //{ |
| 449 | // svi318_DE = data; |
| 450 | //} |
| 451 | // |
| 452 | //static struct m6845_interface |
| 453 | //svi318_m6845_interface= { |
| 454 | // 0,// Memory Address register |
| 455 | // svi318_Set_RA,// Row Address register |
| 456 | // svi318_Set_HSync,// Horizontal status |
| 457 | // svi318_Set_VSync,// Vertical status |
| 458 | // svi318_Set_DE,// Display Enabled status |
| 459 | // 0,// Cursor status |
| 460 | //}; |
| 418 | 461 | |
| 419 | | // called when the 6845 changes the character row |
| 420 | | static void svi318_Set_RA(int offset, int data) |
| 421 | | { |
| 422 | | svi318_6845_RA=data; |
| 462 | static void svi318_crtc6845_update_row(mame_bitmap *bitmap, const rectangle *cliprect, UINT16 ma, |
| 463 | UINT8 ra, UINT16 y, UINT8 x_count, void *param ) { |
| 423 | 464 | } |
| 424 | 465 | |
| 425 | | |
| 426 | | // called when the 6845 changes the HSync |
| 427 | | static void svi318_Set_HSync(int offset, int data) |
| 428 | | { |
| 429 | | svi318_HSync=data; |
| 430 | | if(!svi318_HSync) |
| 431 | | { |
| 432 | | svi318_scr_y++; |
| 433 | | svi318_scr_x = -40; |
| 434 | | } |
| 435 | | } |
| 436 | | |
| 437 | | // called when the 6845 changes the VSync |
| 438 | | static void svi318_Set_VSync(int offset, int data) |
| 439 | | { |
| 440 | | svi318_VSync=data; |
| 441 | | if (!svi318_VSync) |
| 442 | | { |
| 443 | | svi318_scr_y = 0; |
| 444 | | } |
| 445 | | } |
| 446 | | |
| 447 | | static void svi318_Set_DE(int offset, int data) |
| 448 | | { |
| 449 | | svi318_DE = data; |
| 450 | | } |
| 451 | | |
| 452 | | static struct m6845_interface |
| 453 | | svi318_m6845_interface= { |
| 454 | | 0,// Memory Address register |
| 455 | | svi318_Set_RA,// Row Address register |
| 456 | | svi318_Set_HSync,// Horizontal status |
| 457 | | svi318_Set_VSync,// Vertical status |
| 458 | | svi318_Set_DE,// Display Enabled status |
| 459 | | 0,// Cursor status |
| 466 | static const crtc6845_interface svi318_crtc6845_interface = { |
| 467 | 0, |
| 468 | 3579545 /*?*/, |
| 469 | 8 /*?*/, |
| 470 | NULL, |
| 471 | svi318_crtc6845_update_row, |
| 472 | NULL, |
| 473 | NULL |
| 460 | 474 | }; |
| 461 | 475 | |
| 462 | 476 | /* 80 column card init */ |
| r1182 | r1183 | |
| 464 | 478 | { |
| 465 | 479 | /* 2K RAM */ |
| 466 | 480 | svi318_80col_ram = auto_malloc(0x800); |
| 467 | | memset(svi318_80col_ram, 0x40, 0x400); |
| 481 | memset(svi318_80col_ram, 0x40, 0x400); |
| 468 | 482 | /* initialise 6845 */ |
| 469 | | m6845_config(&svi318_m6845_interface); |
| 483 | crtc6845_config( 0, &svi318_crtc6845_interface); |
| 470 | 484 | |
| 471 | 485 | svi318_80col_state=(1<<2)|(1<<1); |
| 472 | 486 | } |
| r1182 | r1183 | |
| 484 | 498 | { |
| 485 | 499 | } |
| 486 | 500 | |
| 487 | | static void svi318_80col_plot_char_line(int x,int y, mame_bitmap *bitmap) |
| 488 | | { |
| 489 | | int w; |
| 490 | | if (svi318_DE) |
| 491 | | { |
| 492 | | unsigned char *data = memory_region(REGION_GFX1); |
| 493 | | unsigned char data_byte; |
| 494 | | int char_code; |
| 495 | | |
| 496 | | char_code = svi318_80col_ram[m6845_memory_address_r(0)&0x07ff]; |
| 497 | | |
| 498 | | data_byte = data[(char_code<<3) + svi318_6845_RA]; |
| 499 | | |
| 500 | | for (w=0; w<8;w++) |
| 501 | | { |
| 502 | | *BITMAP_ADDR16(bitmap, y, x+w) = (data_byte & 0x080) ? 1 : 0; |
| 503 | | |
| 504 | | data_byte = data_byte<<1; |
| 505 | | |
| 506 | | } |
| 507 | | } |
| 508 | | else |
| 509 | | { |
| 510 | | for (w=0; w<8;w++) |
| 511 | | *BITMAP_ADDR16(bitmap, y, x+w) = 0; |
| 512 | | } |
| 513 | | |
| 514 | | } |
| 515 | | |
| 501 | //static void svi318_80col_plot_char_line(int x,int y, mame_bitmap *bitmap) |
| 502 | //{ |
| 503 | // int w; |
| 504 | // if (svi318_DE) |
| 505 | // { |
| 506 | // unsigned char *data = memory_region(REGION_GFX1); |
| 507 | // unsigned char data_byte; |
| 508 | // int char_code; |
| 509 | // |
| 510 | // char_code = svi318_80col_ram[m6845_memory_address_r(0)&0x07ff]; |
| 511 | // |
| 512 | // data_byte = data[(char_code<<3) + svi318_6845_RA]; |
| 513 | // |
| 514 | // for (w=0; w<8;w++) |
| 515 | // { |
| 516 | // *BITMAP_ADDR16(bitmap, y, x+w) = (data_byte & 0x080) ? 1 : 0; |
| 517 | // |
| 518 | // data_byte = data_byte<<1; |
| 519 | // |
| 520 | // } |
| 521 | // } |
| 522 | // else |
| 523 | // { |
| 524 | // for (w=0; w<8;w++) |
| 525 | // *BITMAP_ADDR16(bitmap, y, x+w) = 0; |
| 526 | // } |
| 527 | // |
| 528 | //} |
| 529 | // |
| 516 | 530 | static VIDEO_UPDATE( svi318_80col ) |
| 517 | 531 | { |
| 518 | 532 | long c=0; // this is used to time out the screen redraw, in the case that the 6845 is in some way out state. |
| r1182 | r1183 | |
| 520 | 534 | c=0; |
| 521 | 535 | |
| 522 | 536 | // loop until the end of the Vertical Sync pulse |
| 523 | | while((svi318_VSync)&&(c<33274)) |
| 524 | | { |
| 525 | | // Clock the 6845 |
| 526 | | m6845_clock(); |
| 527 | | c++; |
| 528 | | } |
| 529 | | |
| 530 | | // loop until the Vertical Sync pulse goes high |
| 531 | | // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal) |
| 532 | | while((!svi318_VSync)&&(c<33274)) |
| 533 | | { |
| 534 | | while ((svi318_HSync)&&(c<33274)) |
| 535 | | { |
| 536 | | m6845_clock(); |
| 537 | | c++; |
| 538 | | } |
| 539 | | // Do all the clever split mode changes in here before the next while loop |
| 540 | | |
| 541 | | while ((!svi318_HSync)&&(c<33274)) |
| 542 | | { |
| 543 | | // check that we are on the emulated screen area. |
| 544 | | if ((svi318_scr_x>=0) && (svi318_scr_x<640) && (svi318_scr_y>=0) && (svi318_scr_y<400)) |
| 545 | | { |
| 546 | | svi318_80col_plot_char_line(svi318_scr_x, svi318_scr_y, bitmap); |
| 547 | | } |
| 548 | | |
| 549 | | svi318_scr_x+=8; |
| 550 | | |
| 551 | | // Clock the 6845 |
| 552 | | m6845_clock(); |
| 553 | | c++; |
| 554 | | } |
| 555 | | } |
| 537 | // while((svi318_VSync)&&(c<33274)) |
| 538 | // { |
| 539 | // // Clock the 6845 |
| 540 | // m6845_clock(); |
| 541 | // c++; |
| 542 | // } |
| 543 | // |
| 544 | // // loop until the Vertical Sync pulse goes high |
| 545 | // // or until a timeout (this catches the 6845 with silly register values that would not give a VSYNC signal) |
| 546 | // while((!svi318_VSync)&&(c<33274)) |
| 547 | // { |
| 548 | // while ((svi318_HSync)&&(c<33274)) |
| 549 | // { |
| 550 | // m6845_clock(); |
| 551 | // c++; |
| 552 | // } |
| 553 | // // Do all the clever split mode changes in here before the next while loop |
| 554 | // |
| 555 | // while ((!svi318_HSync)&&(c<33274)) |
| 556 | // { |
| 557 | // // check that we are on the emulated screen area. |
| 558 | // if ((svi318_scr_x>=0) && (svi318_scr_x<640) && (svi318_scr_y>=0) && (svi318_scr_y<400)) |
| 559 | // { |
| 560 | // svi318_80col_plot_char_line(svi318_scr_x, svi318_scr_y, bitmap); |
| 561 | // } |
| 562 | // |
| 563 | // svi318_scr_x+=8; |
| 564 | // |
| 565 | // // Clock the 6845 |
| 566 | // m6845_clock(); |
| 567 | // c++; |
| 568 | // } |
| 569 | // } |
| 556 | 570 | return 0; |
| 557 | 571 | } |
| 558 | 572 | |