src/mess/video/ef9345.c
| r8422 | r8423 | |
| 15 | 15 | #include "emu.h" |
| 16 | 16 | #include "ef9345.h" |
| 17 | 17 | |
| 18 | #define MODE24x40 0 |
| 19 | #define MODEVAR40 1 |
| 20 | #define MODE8x80 2 |
| 21 | #define MODE12x80 3 |
| 22 | #define MODE16x40 4 |
| 23 | |
| 18 | 24 | typedef struct _ef9345_t ef9345_t; |
| 19 | 25 | struct _ef9345_t |
| 20 | 26 | { |
| 21 | | const ef9345_config *conf; |
| 27 | screen_device *screen; //screen we are acting on |
| 22 | 28 | |
| 23 | 29 | UINT8 bf; //busy flag |
| 24 | 30 | UINT8 char_mode; //40 or 80 chars for line |
| r8422 | r8423 | |
| 30 | 36 | UINT8 TGS,MAT,PAT,DOR,ROR; //registres acces indirect |
| 31 | 37 | UINT8 border[80]; //caractere du cadre |
| 32 | 38 | UINT8 *block; //pointeur block courant |
| 33 | | UINT8 *matrice; //pointeur matrice caractere courant |
| 34 | 39 | UINT8 *char_ptr[16]; //pointeurs polices de caracteres |
| 35 | 40 | UINT16 blink; //etat du clignotement |
| 36 | 41 | UINT8 dial; //cadran en cours d'affichage |
| r8422 | r8423 | |
| 44 | 49 | |
| 45 | 50 | emu_timer *busy_timer; |
| 46 | 51 | emu_timer *blink_timer; |
| 47 | | |
| 48 | 52 | }; |
| 49 | 53 | |
| 50 | 54 | static TIMER_CALLBACK( ef9345_done ); |
| r8422 | r8423 | |
| 75 | 79 | UINT16 i, j; |
| 76 | 80 | |
| 77 | 81 | /* verify size limit */ |
| 78 | | if (y * 10 >= ef9345->conf->height || x * 8 >= ef9345->conf->width) |
| 82 | if (y * 10 >= ef9345->screen->height() || x * 8 >= ef9345->screen->width()) |
| 79 | 83 | return; |
| 80 | 84 | |
| 81 | 85 | for(i = 0; i < 10; i++) |
| r8422 | r8423 | |
| 91 | 95 | int i, j; |
| 92 | 96 | |
| 93 | 97 | /* verify size limit */ |
| 94 | | if (y * 10 >= ef9345->conf->height || x * 6 >= ef9345->conf->width) |
| 98 | if (y * 10 >= ef9345->screen->height() || x * 6 >= ef9345->screen->width()) |
| 95 | 99 | return; |
| 96 | 100 | |
| 97 | 101 | for(i = 0; i < 10; i++) |
| r8422 | r8423 | |
| 107 | 111 | { |
| 108 | 112 | UINT8 i; |
| 109 | 113 | ef9345->char_mode = ((ef9345->PAT & 0x80) >> 5) | ((ef9345->TGS & 0xc0) >> 6); |
| 114 | UINT16 new_width = (ef9345->char_mode == MODE12x80 || ef9345->char_mode == MODE8x80) ? 492 : 336; |
| 110 | 115 | |
| 116 | if (ef9345->screen->width() != new_width) |
| 117 | { |
| 118 | rectangle visarea = ef9345->screen->visible_area(); |
| 119 | visarea.max_x = new_width - 1; |
| 120 | |
| 121 | ef9345->screen->configure(new_width, ef9345->screen->height(), visarea, ef9345->screen->frame_period().attoseconds); |
| 122 | } |
| 123 | |
| 111 | 124 | //couleur de bordure |
| 112 | 125 | for(i = 0; i < 80; i++) |
| 113 | 126 | ef9345->border[i] = ef9345->MAT & 0x07; |
| r8422 | r8423 | |
| 295 | 308 | } |
| 296 | 309 | |
| 297 | 310 | // Display bichrome character (40 columns) |
| 298 | | void Bichrome40(ef9345_t *ef9345, int iblock, int x, int y, int c0, int c1, int insert, int flash, int conceal, int negative, int underline) |
| 311 | void Bichrome40(ef9345_t *ef9345, UINT8 *matrice, int iblock, int x, int y, int c0, int c1, int insert, int flash, int conceal, int negative, int underline) |
| 299 | 312 | { |
| 300 | 313 | UINT8 i, j, pix[80]; |
| 301 | 314 | |
| r8422 | r8423 | |
| 357 | 370 | |
| 358 | 371 | for(i = 0; i < 10; i++) |
| 359 | 372 | { |
| 360 | | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x01) ? c1 : c0; |
| 361 | | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x02) ? c1 : c0; |
| 362 | | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x04) ? c1 : c0; |
| 363 | | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x08) ? c1 : c0; |
| 364 | | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x10) ? c1 : c0; |
| 365 | | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x20) ? c1 : c0; |
| 366 | | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x40) ? c1 : c0; |
| 367 | | pix[j++] = (*(ef9345->matrice + 4 * i) & 0x80) ? c1 : c0; |
| 373 | pix[j++] = (*(matrice + 4 * i) & 0x01) ? c1 : c0; |
| 374 | pix[j++] = (*(matrice + 4 * i) & 0x02) ? c1 : c0; |
| 375 | pix[j++] = (*(matrice + 4 * i) & 0x04) ? c1 : c0; |
| 376 | pix[j++] = (*(matrice + 4 * i) & 0x08) ? c1 : c0; |
| 377 | pix[j++] = (*(matrice + 4 * i) & 0x10) ? c1 : c0; |
| 378 | pix[j++] = (*(matrice + 4 * i) & 0x20) ? c1 : c0; |
| 379 | pix[j++] = (*(matrice + 4 * i) & 0x40) ? c1 : c0; |
| 380 | pix[j++] = (*(matrice + 4 * i) & 0x80) ? c1 : c0; |
| 368 | 381 | |
| 369 | 382 | } |
| 370 | 383 | |
| r8422 | r8423 | |
| 380 | 393 | if(ef9345->dial > 0) |
| 381 | 394 | zoom(ef9345, pix, ef9345->dial); |
| 382 | 395 | |
| 396 | //doubles the height of the char |
| 397 | if (ef9345->MAT & 0x80) |
| 398 | zoom(ef9345, pix, (y & 0x01) ? 0x0c : 0x03); |
| 399 | |
| 383 | 400 | draw_char_40(ef9345, pix, x + 1 , y + 1); |
| 384 | 401 | } |
| 385 | 402 | |
| r8422 | r8423 | |
| 491 | 508 | void makechar_16x40(ef9345_t *ef9345, int x, int y) |
| 492 | 509 | { |
| 493 | 510 | int i, a, b, type, c0, c1, f, m, n, u, iblock; |
| 511 | UINT8* matrice; |
| 494 | 512 | |
| 495 | 513 | //recherche des octets b, a (precedent si double largeur) |
| 496 | | iblock = indexblock(ef9345, x, y); |
| 514 | iblock = (ef9345->MAT & 0x80 && y > 1) ? indexblock(ef9345, x, y / 2) : indexblock(ef9345, x, y); |
| 497 | 515 | a = ef9345->block[iblock]; |
| 498 | 516 | b = ef9345->block[iblock + 0x800]; |
| 499 | 517 | |
| r8422 | r8423 | |
| 502 | 520 | |
| 503 | 521 | //adresse de la matrice de definition du caractere |
| 504 | 522 | type = ((b & 0x80) >> 4) | ((a & 0x80) >> 6); |
| 505 | | ef9345->matrice = ef9345->char_ptr[type] + ((b & 0x7f) >> 2) * 0x40 + (b & 0x03); |
| 523 | matrice = ef9345->char_ptr[type] + ((b & 0x7f) >> 2) * 0x40 + (b & 0x03); |
| 506 | 524 | if((b & 0xe0) == 0x80) |
| 507 | | ef9345->matrice = ef9345->char_ptr[0x03]; //negative space |
| 525 | matrice = ef9345->char_ptr[0x03]; //negative space |
| 508 | 526 | |
| 509 | 527 | //attributs latches |
| 510 | 528 | if(x == 0) ef9345->latchm = ef9345->latchi = ef9345->latchu = ef9345->latchc0 = 0; |
| r8422 | r8423 | |
| 521 | 539 | u = ef9345->latchu; //underline |
| 522 | 540 | |
| 523 | 541 | //affichage |
| 524 | | Bichrome40(ef9345, iblock, x, y, c0, c1, i, f, m, n, u); |
| 542 | Bichrome40(ef9345, matrice, iblock, x, y, c0, c1, i, f, m, n, u); |
| 525 | 543 | } |
| 526 | 544 | |
| 527 | 545 | // Affichage d'un caractere 24 bits 40 colonnes |
| 528 | 546 | void makechar_24x40(ef9345_t *ef9345, int x, int y) |
| 529 | 547 | { |
| 530 | 548 | int i, a, b, c, c0, c1, f, m, n, u, iblock; |
| 549 | UINT8* matrice; |
| 531 | 550 | |
| 532 | 551 | //recherche des octets c, b, a |
| 533 | | //iblock = (ef9345->MAT & 0x80) ? indexblock(x, y / 2) : indexblock(x, y); |
| 534 | | //la double hauteur est maintenant prise en compte dans Displayscreen() |
| 535 | | iblock = indexblock(ef9345, x, y); |
| 552 | iblock = (ef9345->MAT & 0x80 && y > 1) ? indexblock(ef9345,x, y / 2) : indexblock(ef9345, x, y); |
| 536 | 553 | c = ef9345->block[iblock]; b = ef9345->block[iblock + 0x800]; a = ef9345->block[iblock + 0x1000]; |
| 537 | 554 | if((b & 0xc0) == 0xc0) {Quadrichrome40(ef9345, c, b, a, x, y); return;} |
| 538 | 555 | |
| r8422 | r8423 | |
| 540 | 557 | Cadran(ef9345, x, (b & 0x02) + ((b & 0x08) >> 3)); |
| 541 | 558 | |
| 542 | 559 | //adresse de la matrice de definition du caractere |
| 543 | | ef9345->matrice = ef9345->char_ptr[(b & 0xf0) >> 4] + ((c & 0x7f) >> 2) * 0x40 + (c & 0x03); |
| 560 | matrice = ef9345->char_ptr[(b & 0xf0) >> 4] + ((c & 0x7f) >> 2) * 0x40 + (c & 0x03); |
| 544 | 561 | |
| 545 | 562 | //attributs du caractere |
| 546 | 563 | c0 = a & 0x07; //background |
| r8422 | r8423 | |
| 552 | 569 | u = (((b & 0x60) == 0) || ((b & 0xc0) == 0x40)) ? ((b & 0x10) >> 4) : 0; |
| 553 | 570 | |
| 554 | 571 | //affichage |
| 555 | | Bichrome40(ef9345, iblock, x, y, c0, c1, i, f, m, n, u); |
| 572 | Bichrome40(ef9345, matrice, iblock, x, y, c0, c1, i, f, m, n, u); |
| 556 | 573 | } |
| 557 | 574 | |
| 558 | 575 | |
| r8422 | r8423 | |
| 561 | 578 | { |
| 562 | 579 | int iblock; |
| 563 | 580 | iblock = indexblock(ef9345, x, y); |
| 564 | | Bichrome80(ef9345, ef9345->block[iblock], (ef9345->block[iblock + 0x1000] >> 4) & 0x0f, 2 * x + 2, y + 1); |
| 565 | | Bichrome80(ef9345, ef9345->block[iblock + 0x800], ef9345->block[iblock + 0x1000] & 0x0f, 2 * x + 3, y + 1); |
| 581 | Bichrome80(ef9345, ef9345->block[iblock], (ef9345->block[iblock + 0x1000] >> 4) & 0x0f, 2 * x + 1, y + 1); |
| 582 | Bichrome80(ef9345, ef9345->block[iblock + 0x800], ef9345->block[iblock + 0x1000] & 0x0f, 2 * x + 2, y + 1); |
| 566 | 583 | } |
| 567 | 584 | |
| 568 | 585 | void makechar(ef9345_t *ef9345, int x, int y) |
| 569 | 586 | { |
| 570 | 587 | switch (ef9345->char_mode) |
| 571 | 588 | { |
| 572 | | case 0: |
| 589 | case MODE24x40: |
| 573 | 590 | makechar_24x40(ef9345, x, y); |
| 574 | 591 | break; |
| 575 | | case 3: |
| 592 | case MODEVAR40: |
| 593 | //TODO |
| 594 | break; |
| 595 | case MODE8x80: |
| 596 | //TODO |
| 597 | break; |
| 598 | case MODE12x80: |
| 576 | 599 | makechar_12x80(ef9345, x, y); |
| 577 | 600 | break; |
| 578 | | case 4: |
| 601 | case MODE16x40: |
| 579 | 602 | makechar_16x40(ef9345, x, y); |
| 580 | 603 | break; |
| 581 | 604 | default: |
| r8422 | r8423 | |
| 859 | 882 | ef9345->bf = 0; |
| 860 | 883 | } |
| 861 | 884 | |
| 885 | void draw_border(ef9345_t *ef9345, UINT8 line) |
| 886 | { |
| 887 | UINT8 i; |
| 888 | |
| 889 | if (ef9345->char_mode == MODE12x80 || ef9345->char_mode == MODE8x80) |
| 890 | for(i = 0; i < 82; i++) |
| 891 | draw_char_80(ef9345, ef9345->border, i, line); |
| 892 | else |
| 893 | for(i = 0; i < 42; i++) |
| 894 | draw_char_40(ef9345, ef9345->border, i, line); |
| 895 | } |
| 896 | |
| 862 | 897 | void ef9345_scanline(running_device *device, UINT16 scanline) |
| 863 | 898 | { |
| 864 | 899 | ef9345_t *ef9345 = get_safe_token(device); |
| r8422 | r8423 | |
| 869 | 904 | |
| 870 | 905 | set_busy_flag(ef9345, 104); |
| 871 | 906 | |
| 872 | | draw_char_40(ef9345, ef9345->border, 0, (scanline / 10) + 1); |
| 873 | | draw_char_40(ef9345, ef9345->border, 41, (scanline / 10) + 1); |
| 907 | if (ef9345->char_mode == MODE12x80 || ef9345->char_mode == MODE8x80) |
| 908 | { |
| 909 | draw_char_80(ef9345, ef9345->border, 0, (scanline / 10) + 1); |
| 910 | draw_char_80(ef9345, ef9345->border, 81, (scanline / 10) + 1); |
| 911 | } |
| 912 | else |
| 913 | { |
| 914 | draw_char_40(ef9345, ef9345->border, 0, (scanline / 10) + 1); |
| 915 | draw_char_40(ef9345, ef9345->border, 41, (scanline / 10) + 1); |
| 916 | } |
| 874 | 917 | |
| 875 | 918 | if(scanline == 0) |
| 876 | 919 | { |
| 877 | 920 | ef9345->state |= 0x04; |
| 878 | | for(i = 0; i < 42; i++) |
| 879 | | draw_char_40(ef9345, ef9345->border, i, 0); |
| 880 | | |
| 921 | draw_border(ef9345, 0); |
| 881 | 922 | if(ef9345->PAT & 1) |
| 882 | 923 | for(i = 0; i < 40; i++) |
| 883 | 924 | makechar(ef9345, i, (scanline / 10)); |
| r8422 | r8423 | |
| 891 | 932 | for(i = 0; i < 40; i++) |
| 892 | 933 | makechar(ef9345, i, (scanline / 10)); |
| 893 | 934 | else |
| 894 | | for(i = 0; i < 42; i++) |
| 895 | | draw_char_40(ef9345, ef9345->border, i, (scanline / 10)); |
| 935 | draw_border(ef9345, scanline / 10); |
| 896 | 936 | } |
| 897 | 937 | else if(scanline < 250) |
| 898 | 938 | { |
| r8422 | r8423 | |
| 900 | 940 | for(i = 0; i < 40; i++) |
| 901 | 941 | makechar(ef9345, i, (scanline / 10)); |
| 902 | 942 | else |
| 903 | | for(i = 0; i < 42; i++) |
| 904 | | draw_char_40(ef9345, ef9345->border, i, (scanline / 10)); |
| 943 | draw_border(ef9345, scanline / 10); |
| 905 | 944 | |
| 906 | 945 | if(scanline == 240) |
| 907 | | for(i = 0; i < 42; i++) |
| 908 | | draw_char_40(ef9345, ef9345->border, i, 26); |
| 946 | draw_border(ef9345, 26); |
| 909 | 947 | } |
| 910 | 948 | } |
| 911 | 949 | |
| r8422 | r8423 | |
| 958 | 996 | static DEVICE_START( ef9345 ) |
| 959 | 997 | { |
| 960 | 998 | ef9345_t *ef9345 = get_safe_token(device); |
| 999 | const ef9345_config *config = (ef9345_config*)device->baseconfig().static_config(); |
| 961 | 1000 | |
| 962 | 1001 | /* validate arguments */ |
| 963 | 1002 | assert(device != NULL); |
| 964 | 1003 | |
| 965 | | ef9345->conf = (ef9345_config*)device->baseconfig().static_config(); |
| 1004 | ef9345->charset = memory_region(device->machine, config->charset); |
| 966 | 1005 | |
| 967 | | ef9345->charset = memory_region(device->machine, ef9345->conf->charset); |
| 1006 | ef9345->screen = device->machine->device<screen_device>(config->screen_tag); |
| 1007 | assert(ef9345->screen != NULL); |
| 968 | 1008 | |
| 969 | 1009 | ef9345->busy_timer = timer_alloc(device->machine, ef9345_done, (void *)device); |
| 970 | 1010 | ef9345->blink_timer = timer_alloc(device->machine, blinking, (void *)device); |
| 971 | 1011 | |
| 972 | | ef9345->screen_out = auto_bitmap_alloc(device->machine, ef9345->conf->width , ef9345->conf->height , BITMAP_FORMAT_INDEXED16); |
| 1012 | ef9345->screen_out = auto_bitmap_alloc(device->machine, 496, ef9345->screen->height() , BITMAP_FORMAT_INDEXED16); |
| 973 | 1013 | |
| 974 | 1014 | timer_adjust_periodic(ef9345->blink_timer, ATTOTIME_IN_MSEC(500), 0, ATTOTIME_IN_MSEC(500)); |
| 975 | 1015 | |