src/mess/video/ted7360.c
| r1925 | r1926 | |
| 355 | 355 | #include <math.h> |
| 356 | 356 | #include <stdio.h> |
| 357 | 357 | #include "driver.h" |
| 358 | | #include "deprecat.h" |
| 359 | 358 | #include "utils.h" |
| 360 | 359 | #include "sound/custom.h" |
| 361 | 360 | |
| r1925 | r1926 | |
| 508 | 507 | static bitmap_t *ted7360_bitmap; |
| 509 | 508 | static int rasterline = 0, lastline = 0; |
| 510 | 509 | static double rastertime; |
| 511 | | static void ted7360_drawlines (int first, int last); |
| 510 | static void ted7360_drawlines (running_machine *machine, int first, int last); |
| 512 | 511 | |
| 513 | 512 | static UINT32 cursorcolortable[2] = |
| 514 | 513 | {0}; |
| r1925 | r1926 | |
| 686 | 685 | case 6: |
| 687 | 686 | if (ted7360[offset] != data) |
| 688 | 687 | { |
| 689 | | ted7360_drawlines (lastline, rasterline); |
| 688 | ted7360_drawlines (machine, lastline, rasterline); |
| 690 | 689 | ted7360[offset] = data; |
| 691 | 690 | if (LINES25) |
| 692 | 691 | { |
| r1925 | r1926 | |
| 704 | 703 | case 7: |
| 705 | 704 | if (ted7360[offset] != data) |
| 706 | 705 | { |
| 707 | | ted7360_drawlines (lastline, rasterline); |
| 706 | ted7360_drawlines (machine, lastline, rasterline); |
| 708 | 707 | ted7360[offset] = data; |
| 709 | 708 | if (COLUMNS40) |
| 710 | 709 | { |
| r1925 | r1926 | |
| 750 | 749 | case 0xb: |
| 751 | 750 | if (data != ted7360[offset]) |
| 752 | 751 | { |
| 753 | | ted7360_drawlines (lastline, rasterline); |
| 752 | ted7360_drawlines (machine, lastline, rasterline); |
| 754 | 753 | ted7360[offset] = data; |
| 755 | 754 | /* DBG_LOG(1,"set rasterline lo",("soll:%d\n",RASTERLINE)); */ |
| 756 | 755 | } |
| r1925 | r1926 | |
| 759 | 758 | case 0xd: |
| 760 | 759 | if (ted7360[offset] != data) |
| 761 | 760 | { |
| 762 | | ted7360_drawlines (lastline, rasterline); |
| 761 | ted7360_drawlines (machine, lastline, rasterline); |
| 763 | 762 | ted7360[offset] = data; |
| 764 | 763 | } |
| 765 | 764 | break; |
| 766 | 765 | case 0x12: |
| 767 | 766 | if (ted7360[offset] != data) |
| 768 | 767 | { |
| 769 | | ted7360_drawlines (lastline, rasterline); |
| 768 | ted7360_drawlines (machine, lastline, rasterline); |
| 770 | 769 | ted7360[offset] = data; |
| 771 | 770 | bitmapaddr = BITMAPADDR; |
| 772 | 771 | chargenaddr = CHARGENADDR; |
| r1925 | r1926 | |
| 777 | 776 | case 0x13: |
| 778 | 777 | if (ted7360[offset] != data) |
| 779 | 778 | { |
| 780 | | ted7360_drawlines (lastline, rasterline); |
| 779 | ted7360_drawlines (machine, lastline, rasterline); |
| 781 | 780 | ted7360[offset] = data; |
| 782 | 781 | chargenaddr = CHARGENADDR; |
| 783 | 782 | DBG_LOG (3, "ted7360_port_w", ("chargen %.4x %s %d\n", |
| r1925 | r1926 | |
| 788 | 787 | case 0x14: |
| 789 | 788 | if (ted7360[offset] != data) |
| 790 | 789 | { |
| 791 | | ted7360_drawlines (lastline, rasterline); |
| 790 | ted7360_drawlines (machine, lastline, rasterline); |
| 792 | 791 | ted7360[offset] = data; |
| 793 | 792 | videoaddr = VIDEOADDR; |
| 794 | 793 | DBG_LOG (3, "ted7360_port_w", ("videoram %.4x\n", |
| r1925 | r1926 | |
| 798 | 797 | case 0x15: /* backgroundcolor */ |
| 799 | 798 | if (ted7360[offset] != data) |
| 800 | 799 | { |
| 801 | | ted7360_drawlines (lastline, rasterline); |
| 800 | ted7360_drawlines (machine, lastline, rasterline); |
| 802 | 801 | ted7360[offset] = data; |
| 803 | 802 | monoinversed[1] = mono[0] = bitmapmulti[0] = multi[0] = colors[0] = |
| 804 | | Machine->pens[BACKGROUNDCOLOR]; |
| 803 | machine->pens[BACKGROUNDCOLOR]; |
| 805 | 804 | } |
| 806 | 805 | break; |
| 807 | 806 | case 0x16: /* foregroundcolor */ |
| 808 | 807 | if (ted7360[offset] != data) |
| 809 | 808 | { |
| 810 | | ted7360_drawlines (lastline, rasterline); |
| 809 | ted7360_drawlines (machine, lastline, rasterline); |
| 811 | 810 | ted7360[offset] = data; |
| 812 | | bitmapmulti[3] = multi[1] = colors[1] = Machine->pens[FOREGROUNDCOLOR]; |
| 811 | bitmapmulti[3] = multi[1] = colors[1] = machine->pens[FOREGROUNDCOLOR]; |
| 813 | 812 | } |
| 814 | 813 | break; |
| 815 | 814 | case 0x17: /* multicolor 1 */ |
| 816 | 815 | if (ted7360[offset] != data) |
| 817 | 816 | { |
| 818 | | ted7360_drawlines (lastline, rasterline); |
| 817 | ted7360_drawlines (machine, lastline, rasterline); |
| 819 | 818 | ted7360[offset] = data; |
| 820 | | multi[2] = colors[2] = Machine->pens[MULTICOLOR1]; |
| 819 | multi[2] = colors[2] = machine->pens[MULTICOLOR1]; |
| 821 | 820 | } |
| 822 | 821 | break; |
| 823 | 822 | case 0x18: /* multicolor 2 */ |
| 824 | 823 | if (ted7360[offset] != data) |
| 825 | 824 | { |
| 826 | | ted7360_drawlines (lastline, rasterline); |
| 825 | ted7360_drawlines (machine, lastline, rasterline); |
| 827 | 826 | ted7360[offset] = data; |
| 828 | | colors[3] = Machine->pens[MULTICOLOR2]; |
| 827 | colors[3] = machine->pens[MULTICOLOR2]; |
| 829 | 828 | } |
| 830 | 829 | break; |
| 831 | 830 | case 0x19: /* framecolor */ |
| 832 | 831 | if (ted7360[offset] != data) |
| 833 | 832 | { |
| 834 | | ted7360_drawlines (lastline, rasterline); |
| 833 | ted7360_drawlines (machine, lastline, rasterline); |
| 835 | 834 | ted7360[offset] = data; |
| 836 | | colors[4] = Machine->pens[FRAMECOLOR]; |
| 835 | colors[4] = machine->pens[FRAMECOLOR]; |
| 837 | 836 | } |
| 838 | 837 | break; |
| 839 | 838 | case 0x1c: |
| r1925 | r1926 | |
| 916 | 915 | val |= 1; |
| 917 | 916 | break; |
| 918 | 917 | case 0x1c: /*rasterline */ |
| 919 | | ted7360_drawlines (lastline, rasterline); |
| 918 | ted7360_drawlines (machine, lastline, rasterline); |
| 920 | 919 | val = ((RASTERLINE_2_C16 (rasterline) & 0x100) >> 8) | 0xfe; /* expected by matrix */ |
| 921 | 920 | break; |
| 922 | 921 | case 0x1d: /*rasterline */ |
| 923 | | ted7360_drawlines (lastline, rasterline); |
| 922 | ted7360_drawlines (machine, lastline, rasterline); |
| 924 | 923 | val = RASTERLINE_2_C16 (rasterline) & 0xff; |
| 925 | 924 | break; |
| 926 | 925 | case 0x1e: /*rastercolumn */ |
| r1925 | r1926 | |
| 959 | 958 | add_exit_callback(machine, ted7360_video_stop); |
| 960 | 959 | } |
| 961 | 960 | |
| 962 | | static void ted7360_draw_character (int ybegin, int yend, int ch, int yoff, int xoff, |
| 961 | static void ted7360_draw_character (running_machine *machine, int ybegin, int yend, int ch, int yoff, int xoff, |
| 963 | 962 | UINT16 *color) |
| 964 | 963 | { |
| 965 | 964 | int y, code; |
| r1925 | r1926 | |
| 967 | 966 | for (y = ybegin; y <= yend; y++) |
| 968 | 967 | { |
| 969 | 968 | if (INROM) |
| 970 | | code = vic_dma_read_rom (Machine, chargenaddr + ch * 8 + y); |
| 969 | code = vic_dma_read_rom (machine, chargenaddr + ch * 8 + y); |
| 971 | 970 | else |
| 972 | | code = vic_dma_read (Machine, chargenaddr + ch * 8 + y); |
| 971 | code = vic_dma_read (machine, chargenaddr + ch * 8 + y); |
| 973 | 972 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 0 + xoff) = color[code >> 7]; |
| 974 | 973 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 1 + xoff) = color[(code >> 6) & 1]; |
| 975 | 974 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 2 + xoff) = color[(code >> 5) & 1]; |
| r1925 | r1926 | |
| 981 | 980 | } |
| 982 | 981 | } |
| 983 | 982 | |
| 984 | | static void ted7360_draw_character_multi (int ybegin, int yend, int ch, int yoff, |
| 983 | static void ted7360_draw_character_multi (running_machine *machine, int ybegin, int yend, int ch, int yoff, |
| 985 | 984 | int xoff) |
| 986 | 985 | { |
| 987 | 986 | int y, code; |
| r1925 | r1926 | |
| 989 | 988 | for (y = ybegin; y <= yend; y++) |
| 990 | 989 | { |
| 991 | 990 | if (INROM) |
| 992 | | code = vic_dma_read_rom (Machine, chargenaddr + ch * 8 + y); |
| 991 | code = vic_dma_read_rom (machine, chargenaddr + ch * 8 + y); |
| 993 | 992 | else |
| 994 | | code = vic_dma_read (Machine, chargenaddr + ch * 8 + y); |
| 993 | code = vic_dma_read (machine, chargenaddr + ch * 8 + y); |
| 995 | 994 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 0 + xoff) = |
| 996 | 995 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 1 + xoff) = multi[code >> 6]; |
| 997 | 996 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 2 + xoff) = |
| r1925 | r1926 | |
| 1003 | 1002 | } |
| 1004 | 1003 | } |
| 1005 | 1004 | |
| 1006 | | static void ted7360_draw_bitmap (int ybegin, int yend, |
| 1005 | static void ted7360_draw_bitmap (running_machine *machine, int ybegin, int yend, |
| 1007 | 1006 | int ch, int yoff, int xoff) |
| 1008 | 1007 | { |
| 1009 | 1008 | int y, code; |
| 1010 | 1009 | |
| 1011 | 1010 | for (y = ybegin; y <= yend; y++) |
| 1012 | 1011 | { |
| 1013 | | code = vic_dma_read (Machine, bitmapaddr + ch * 8 + y); |
| 1012 | code = vic_dma_read (machine, bitmapaddr + ch * 8 + y); |
| 1014 | 1013 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 0 + xoff) = c16_bitmap[code >> 7]; |
| 1015 | 1014 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 1 + xoff) = c16_bitmap[(code >> 6) & 1]; |
| 1016 | 1015 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 2 + xoff) = c16_bitmap[(code >> 5) & 1]; |
| r1925 | r1926 | |
| 1022 | 1021 | } |
| 1023 | 1022 | } |
| 1024 | 1023 | |
| 1025 | | static void ted7360_draw_bitmap_multi (int ybegin, int yend, |
| 1024 | static void ted7360_draw_bitmap_multi (running_machine *machine, int ybegin, int yend, |
| 1026 | 1025 | int ch, int yoff, int xoff) |
| 1027 | 1026 | { |
| 1028 | 1027 | int y, code; |
| 1029 | 1028 | |
| 1030 | 1029 | for (y = ybegin; y <= yend; y++) |
| 1031 | 1030 | { |
| 1032 | | code = vic_dma_read (Machine, bitmapaddr + ch * 8 + y); |
| 1031 | code = vic_dma_read (machine, bitmapaddr + ch * 8 + y); |
| 1033 | 1032 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 0 + xoff) = |
| 1034 | 1033 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 1 + xoff) = bitmapmulti[code >> 6]; |
| 1035 | 1034 | *BITMAP_ADDR16(ted7360_bitmap, y + yoff, 2 + xoff) = |
| r1925 | r1926 | |
| 1052 | 1051 | } |
| 1053 | 1052 | } |
| 1054 | 1053 | |
| 1055 | | static void ted7360_drawlines (int first, int last) |
| 1054 | static void ted7360_drawlines (running_machine *machine, int first, int last) |
| 1056 | 1055 | { |
| 1057 | 1056 | int line, vline, end; |
| 1058 | 1057 | int attr, ch, c1, c2, ecm; |
| r1925 | r1926 | |
| 1075 | 1074 | if (!SCREENON) |
| 1076 | 1075 | { |
| 1077 | 1076 | for (line = first; (line < last) && (line < ted7360_bitmap->height); line++) |
| 1078 | | memset16 (BITMAP_ADDR16(ted7360_bitmap, line, 0), Machine->pens[0], ted7360_bitmap->width); |
| 1077 | memset16 (BITMAP_ADDR16(ted7360_bitmap, line, 0), machine->pens[0], ted7360_bitmap->width); |
| 1079 | 1078 | return; |
| 1080 | 1079 | } |
| 1081 | 1080 | |
| r1925 | r1926 | |
| 1090 | 1089 | end = y_begin + YPOS; |
| 1091 | 1090 | { |
| 1092 | 1091 | for (line = first; line < end; line++) |
| 1093 | | memset16 (BITMAP_ADDR16(ted7360_bitmap, line, 0), Machine->pens[FRAMECOLOR], |
| 1092 | memset16 (BITMAP_ADDR16(ted7360_bitmap, line, 0), machine->pens[FRAMECOLOR], |
| 1094 | 1093 | ted7360_bitmap->width); |
| 1095 | 1094 | } |
| 1096 | 1095 | if (LINES25) |
| r1925 | r1926 | |
| 1118 | 1117 | { |
| 1119 | 1118 | if (HIRESON) |
| 1120 | 1119 | { |
| 1121 | | ch = vic_dma_read (Machine, (videoaddr | 0x400) + offs); |
| 1122 | | attr = vic_dma_read (Machine, ((videoaddr) + offs)); |
| 1120 | ch = vic_dma_read (machine, (videoaddr | 0x400) + offs); |
| 1121 | attr = vic_dma_read (machine, ((videoaddr) + offs)); |
| 1123 | 1122 | c1 = ((ch >> 4) & 0xf) | (attr << 4); |
| 1124 | 1123 | c2 = (ch & 0xf) | (attr & 0x70); |
| 1125 | | bitmapmulti[1] = c16_bitmap[1] = Machine->pens[c1 & 0x7f]; |
| 1126 | | bitmapmulti[2] = c16_bitmap[0] = Machine->pens[c2 & 0x7f]; |
| 1124 | bitmapmulti[1] = c16_bitmap[1] = machine->pens[c1 & 0x7f]; |
| 1125 | bitmapmulti[2] = c16_bitmap[0] = machine->pens[c2 & 0x7f]; |
| 1127 | 1126 | if (MULTICOLORON) |
| 1128 | 1127 | { |
| 1129 | | ted7360_draw_bitmap_multi (ybegin, yend, offs, yoff, xoff); |
| 1128 | ted7360_draw_bitmap_multi (machine, ybegin, yend, offs, yoff, xoff); |
| 1130 | 1129 | } |
| 1131 | 1130 | else |
| 1132 | 1131 | { |
| 1133 | | ted7360_draw_bitmap (ybegin, yend, offs, yoff, xoff); |
| 1132 | ted7360_draw_bitmap (machine, ybegin, yend, offs, yoff, xoff); |
| 1134 | 1133 | } |
| 1135 | 1134 | } |
| 1136 | 1135 | else |
| 1137 | 1136 | { |
| 1138 | | ch = vic_dma_read (Machine, (videoaddr | 0x400) + offs); |
| 1139 | | attr = vic_dma_read (Machine, ((videoaddr) + offs)); |
| 1137 | ch = vic_dma_read (machine, (videoaddr | 0x400) + offs); |
| 1138 | attr = vic_dma_read (machine, ((videoaddr) + offs)); |
| 1140 | 1139 | // levente harsfalvi's docu says cursor off in ecm and multicolor |
| 1141 | 1140 | if (ECMON) |
| 1142 | 1141 | { |
| 1143 | 1142 | // hardware reverse off |
| 1144 | 1143 | ecm = ch >> 6; |
| 1145 | 1144 | ecmcolor[0] = colors[ecm]; |
| 1146 | | ecmcolor[1] = Machine->pens[attr & 0x7f]; |
| 1147 | | ted7360_draw_character (ybegin, yend, ch & ~0xC0, yoff, xoff, ecmcolor); |
| 1145 | ecmcolor[1] = machine->pens[attr & 0x7f]; |
| 1146 | ted7360_draw_character (machine, ybegin, yend, ch & ~0xC0, yoff, xoff, ecmcolor); |
| 1148 | 1147 | } |
| 1149 | 1148 | else if (MULTICOLORON) |
| 1150 | 1149 | { |
| 1151 | 1150 | // hardware reverse off |
| 1152 | 1151 | if (attr & 8) |
| 1153 | 1152 | { |
| 1154 | | multi[3] = Machine->pens[attr & 0x77]; |
| 1155 | | ted7360_draw_character_multi (ybegin, yend, ch, yoff, xoff); |
| 1153 | multi[3] = machine->pens[attr & 0x77]; |
| 1154 | ted7360_draw_character_multi (machine, ybegin, yend, ch, yoff, xoff); |
| 1156 | 1155 | } |
| 1157 | 1156 | else |
| 1158 | 1157 | { |
| 1159 | | mono[1] = Machine->pens[attr & 0x7f]; |
| 1160 | | ted7360_draw_character (ybegin, yend, ch, yoff, xoff, mono); |
| 1158 | mono[1] = machine->pens[attr & 0x7f]; |
| 1159 | ted7360_draw_character (machine, ybegin, yend, ch, yoff, xoff, mono); |
| 1161 | 1160 | } |
| 1162 | 1161 | } |
| 1163 | 1162 | else if (cursor1 && (offs == CURSOR1POS)) |
| 1164 | 1163 | { |
| 1165 | 1164 | #ifndef GFX |
| 1166 | 1165 | ted7360_draw_cursor (ybegin, yend, yoff, xoff, |
| 1167 | | Machine->pens[attr & 0x7f]); |
| 1166 | machine->pens[attr & 0x7f]); |
| 1168 | 1167 | #else |
| 1169 | | drawgfx (ted7360_bitmap, cursorelement, 0, Machine->pens[attr & 0x7f], 0, 0, |
| 1168 | drawgfx (ted7360_bitmap, cursorelement, 0, machine->pens[attr & 0x7f], 0, 0, |
| 1170 | 1169 | xoff, yoff, 0, TRANSPARENCY_NONE, 0); |
| 1171 | 1170 | #endif |
| 1172 | 1171 | } |
| 1173 | 1172 | else if (REVERSEON && (ch & 0x80)) |
| 1174 | 1173 | { |
| 1175 | | monoinversed[0] = Machine->pens[attr & 0x7f]; |
| 1174 | monoinversed[0] = machine->pens[attr & 0x7f]; |
| 1176 | 1175 | if (cursor1 && (attr & 0x80)) |
| 1177 | 1176 | ted7360_draw_cursor (ybegin, yend, yoff, xoff, monoinversed[0]); |
| 1178 | 1177 | else |
| 1179 | | ted7360_draw_character (ybegin, yend, ch & ~0x80, yoff, xoff, |
| 1178 | ted7360_draw_character (machine, ybegin, yend, ch & ~0x80, yoff, xoff, |
| 1180 | 1179 | monoinversed); |
| 1181 | 1180 | } |
| 1182 | 1181 | else |
| 1183 | 1182 | { |
| 1184 | | mono[1] = Machine->pens[attr & 0x7f]; |
| 1183 | mono[1] = machine->pens[attr & 0x7f]; |
| 1185 | 1184 | if (cursor1 && (attr & 0x80)) |
| 1186 | 1185 | ted7360_draw_cursor (ybegin, yend, yoff, xoff, mono[0]); |
| 1187 | 1186 | else |
| 1188 | | ted7360_draw_character (ybegin, yend, ch, yoff, xoff, mono); |
| 1187 | ted7360_draw_character (machine, ybegin, yend, ch, yoff, xoff, mono); |
| 1189 | 1188 | } |
| 1190 | 1189 | } |
| 1191 | 1190 | } |
| 1192 | 1191 | |
| 1193 | 1192 | for (i = ybegin; i <= yend; i++) |
| 1194 | 1193 | { |
| 1195 | | memset16 (BITMAP_ADDR16(ted7360_bitmap, yoff + i, 0), Machine->pens[FRAMECOLOR], xbegin); |
| 1196 | | memset16 (BITMAP_ADDR16(ted7360_bitmap, yoff + i, xend), Machine->pens[FRAMECOLOR], ted7360_bitmap->width - xend); |
| 1194 | memset16 (BITMAP_ADDR16(ted7360_bitmap, yoff + i, 0), machine->pens[FRAMECOLOR], xbegin); |
| 1195 | memset16 (BITMAP_ADDR16(ted7360_bitmap, yoff + i, xend), machine->pens[FRAMECOLOR], ted7360_bitmap->width - xend); |
| 1197 | 1196 | } |
| 1198 | 1197 | } |
| 1199 | 1198 | |
| r1925 | r1926 | |
| 1204 | 1203 | |
| 1205 | 1204 | for (; line < end; line++) |
| 1206 | 1205 | { |
| 1207 | | memset16 (BITMAP_ADDR16(ted7360_bitmap, line, 0), Machine->pens[FRAMECOLOR], ted7360_bitmap->width); |
| 1206 | memset16 (BITMAP_ADDR16(ted7360_bitmap, line, 0), machine->pens[FRAMECOLOR], ted7360_bitmap->width); |
| 1208 | 1207 | } |
| 1209 | 1208 | } |
| 1210 | 1209 | |
| r1925 | r1926 | |
| 1215 | 1214 | if (rasterline >= lines) |
| 1216 | 1215 | { |
| 1217 | 1216 | rasterline = 0; |
| 1218 | | ted7360_drawlines (lastline, TED7360_LINES); |
| 1217 | ted7360_drawlines (machine, lastline, TED7360_LINES); |
| 1219 | 1218 | lastline = 0; |
| 1220 | 1219 | } |
| 1221 | 1220 | if (rasterline == C16_2_RASTERLINE (RASTERLINE)) |
| 1222 | 1221 | { |
| 1223 | | ted7360_drawlines (lastline, rasterline); |
| 1222 | ted7360_drawlines (machine, lastline, rasterline); |
| 1224 | 1223 | ted7360_set_interrupt (2); |
| 1225 | 1224 | } |
| 1226 | 1225 | } |