src/mess/video/m6847.c
| r5922 | r5923 | |
| 69 | 69 | #include "debug/debugcpu.h" |
| 70 | 70 | #include "debug/debugcon.h" |
| 71 | 71 | |
| 72 | enum |
| 73 | { |
| 74 | M6847_AG = 0x80, |
| 75 | M6847_AS = 0x40, |
| 76 | M6847_INTEXT = 0x20, |
| 77 | M6847_INV = 0x10, |
| 78 | M6847_CSS = 0x08, |
| 79 | M6847_GM2 = 0x04, |
| 80 | M6847_GM1 = 0x02, |
| 81 | M6847_GM0 = 0x01 |
| 82 | }; |
| 72 | 83 | |
| 84 | |
| 85 | |
| 73 | 86 | #define LOG_FS 0 |
| 74 | 87 | #define LOG_HS 0 |
| 75 | 88 | #define LOG_STATS 0 |
| 76 | | #define LOG_PREPARE |
| 89 | #define LOG_PREPARE 1 |
| 77 | 90 | |
| 78 | 91 | typedef struct _m6847_variant m6847_variant; |
| 79 | 92 | struct _m6847_variant |
| r5922 | r5923 | |
| 102 | 115 | UINT8 attr; |
| 103 | 116 | }; |
| 104 | 117 | |
| 105 | | typedef struct _m6847_vdg m6847_vdg; |
| 106 | | struct _m6847_vdg |
| 118 | typedef struct _mc6847_state mc6847_state; |
| 119 | struct _mc6847_state |
| 107 | 120 | { |
| 108 | 121 | /* callbacks */ |
| 109 | | void (*horizontal_sync_callback)(running_machine *machine, int line); |
| 110 | | void (*field_sync_callback)(running_machine *machine, int line); |
| 111 | | UINT8 (*get_attributes)(running_machine *machine, UINT8 c,int scanline, int pos); |
| 112 | | const UINT8 *(*get_video_ram)(running_machine *machine, int scanline); |
| 113 | | int (*new_frame_callback)(void); /* returns whether the M6847 is in charge of this frame */ |
| 122 | devcb_resolved_read8 in_dd_func; |
| 123 | |
| 124 | devcb_resolved_read_line in_gm2_func; |
| 125 | devcb_resolved_read_line in_gm1_func; |
| 126 | devcb_resolved_read_line in_gm0_func; |
| 127 | devcb_resolved_read_line in_intext_func; |
| 128 | devcb_resolved_read_line in_inv_func; |
| 129 | devcb_resolved_read_line in_as_func; |
| 130 | devcb_resolved_read_line in_ag_func; |
| 131 | devcb_resolved_read_line in_css_func; |
| 132 | |
| 133 | devcb_resolved_write_line out_fs_func; |
| 134 | devcb_resolved_write_line out_hs_func; |
| 135 | devcb_resolved_write_line out_rs_func; |
| 136 | |
| 137 | /* state of mode control lines */ |
| 138 | unsigned int gm2 : 1; |
| 139 | unsigned int gm1 : 1; |
| 140 | unsigned int gm0 : 1; |
| 141 | unsigned int intext : 1; |
| 142 | unsigned int inv : 1; |
| 143 | unsigned int as : 1; |
| 144 | unsigned int ag : 1; |
| 145 | unsigned int css : 1; |
| 146 | |
| 147 | /* sync control line status */ |
| 148 | unsigned int fs : 1; |
| 149 | unsigned int hs : 1; |
| 150 | |
| 151 | /* to be cleaned up... */ |
| 152 | int (*new_frame_callback)(running_machine *machine); /* returns whether the M6847 is in charge of this frame */ |
| 114 | 153 | void (*custom_prepare_scanline)(int scanline); |
| 115 | 154 | UINT8 (*get_char_rom)(running_machine *machine, UINT8 ch,int line); |
| 116 | 155 | |
| r5922 | r5923 | |
| 158 | 197 | |
| 159 | 198 | static void apply_artifacts(running_machine *machine, UINT32 *line); |
| 160 | 199 | |
| 161 | | static m6847_vdg *m6847; |
| 162 | 200 | |
| 163 | | |
| 164 | 201 | static const UINT8 pal_round_fontdata8x12[] = |
| 165 | 202 | { |
| 166 | 203 | 0x00, 0x00, 0x38, 0x44, 0x04, 0x34, 0x4C, 0x4C, 0x38, 0x00, 0x00, 0x00, |
| r5922 | r5923 | |
| 1031 | 1068 | |
| 1032 | 1069 | |
| 1033 | 1070 | |
| 1071 | /***************************************************************************** |
| 1072 | INLINE FUNCTIONS |
| 1073 | *****************************************************************************/ |
| 1074 | |
| 1075 | INLINE mc6847_state *get_safe_token(const device_config *device) |
| 1076 | { |
| 1077 | assert(device != NULL); |
| 1078 | assert(device->token != NULL); |
| 1079 | assert(device->type == MC6847); |
| 1080 | |
| 1081 | return (mc6847_state *)device->token; |
| 1082 | } |
| 1083 | |
| 1084 | |
| 1034 | 1085 | /************************************* |
| 1035 | 1086 | * |
| 1036 | 1087 | * Utilities |
| 1037 | 1088 | * |
| 1038 | 1089 | *************************************/ |
| 1039 | 1090 | |
| 1040 | | static UINT32 color(int c) |
| 1091 | static UINT32 color(const device_config *device, int c) |
| 1041 | 1092 | { |
| 1042 | | return m6847->palette[c]; |
| 1093 | mc6847_state *mc6847 = get_safe_token(device); |
| 1094 | return mc6847->palette[c]; |
| 1043 | 1095 | } |
| 1044 | 1096 | |
| 1045 | | |
| 1046 | | |
| 1047 | | static int attr_index_from_attribute(UINT8 attr) |
| 1097 | static int attr_index_from_attribute(const device_config *device, UINT8 attr) |
| 1048 | 1098 | { |
| 1099 | mc6847_state *mc6847 = get_safe_token(device); |
| 1049 | 1100 | int result; |
| 1050 | 1101 | |
| 1051 | 1102 | result = ((attr & (M6847_AG | M6847_AS | M6847_INTEXT | M6847_INV | M6847_CSS)) >> 3) |
| 1052 | 1103 | | ((attr & (M6847_GM1 | M6847_GM0)) << 5); |
| 1053 | 1104 | |
| 1054 | 1105 | /* sanity check */ |
| 1055 | | assert(result < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0])); |
| 1106 | assert(result < ARRAY_LENGTH(mc6847->fontdata)); |
| 1056 | 1107 | return result; |
| 1057 | 1108 | } |
| 1058 | 1109 | |
| 1110 | static UINT8 attribute_from_attr_index(const device_config *device, int attr_index) |
| 1111 | { |
| 1112 | mc6847_state *mc6847 = get_safe_token(device); |
| 1059 | 1113 | |
| 1060 | | |
| 1061 | | static UINT8 attribute_from_attr_index(int attr_index) |
| 1062 | | { |
| 1063 | 1114 | /* sanity check */ |
| 1064 | 1115 | assert(attr_index >= 0); |
| 1065 | | assert(attr_index < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0])); |
| 1116 | assert(attr_index < ARRAY_LENGTH(mc6847->fontdata)); |
| 1066 | 1117 | |
| 1067 | 1118 | return (UINT8) ((attr_index & 0x1F) << 3) |
| 1068 | 1119 | | ((attr_index & 0x60) >> 5); |
| r5922 | r5923 | |
| 1072 | 1123 | |
| 1073 | 1124 | /************************************* |
| 1074 | 1125 | * |
| 1126 | * Scanline operations |
| 1127 | * |
| 1128 | *************************************/ |
| 1129 | |
| 1130 | static int get_scanline(mc6847_state *mc6847) |
| 1131 | { |
| 1132 | int result; |
| 1133 | attotime duration; |
| 1134 | |
| 1135 | /* get the time since last field sync */ |
| 1136 | duration = attotime_sub( |
| 1137 | timer_starttime(mc6847->hs_rise_timer), |
| 1138 | timer_starttime(mc6847->fs_rise_timer)); |
| 1139 | assert_always(duration.seconds == 0, "get_scanline(): duration exceeds one second"); |
| 1140 | |
| 1141 | if (duration.attoseconds < mc6847->vblank_period) |
| 1142 | { |
| 1143 | result = -1; /* vblank */ |
| 1144 | } |
| 1145 | else |
| 1146 | { |
| 1147 | result = (duration.attoseconds - mc6847->vblank_period) |
| 1148 | / mc6847->scanline_period; |
| 1149 | } |
| 1150 | return result; |
| 1151 | } |
| 1152 | |
| 1153 | |
| 1154 | |
| 1155 | static offs_t scanline_to_address(mc6847_state *mc6847, int scanline) |
| 1156 | { |
| 1157 | if (mc6847->ag) |
| 1158 | { |
| 1159 | /* graphics */ |
| 1160 | int gm = (mc6847->gm0 << 2) | (mc6847->gm1 << 1) | mc6847->gm2; |
| 1161 | |
| 1162 | switch (gm) |
| 1163 | { |
| 1164 | case 0: return (scanline / 3) * 0x10; |
| 1165 | case 1: return (scanline / 3) * 0x10; |
| 1166 | case 2: return (scanline / 3) * 0x20; |
| 1167 | case 3: return (scanline / 2) * 0x20; |
| 1168 | case 4: return (scanline / 2) * 0x20; |
| 1169 | case 5: return (scanline / 1) * 0x10; |
| 1170 | case 6: return (scanline / 1) * 0x20; |
| 1171 | case 7: return (scanline / 1) * 0x20; |
| 1172 | } |
| 1173 | } |
| 1174 | else |
| 1175 | { |
| 1176 | /* text, semi-graphics */ |
| 1177 | return (scanline / 12) * 0x20; |
| 1178 | } |
| 1179 | |
| 1180 | /* we never get here */ |
| 1181 | return 0; |
| 1182 | } |
| 1183 | |
| 1184 | |
| 1185 | /* TODO: attributes should be read on demand rather then all at once */ |
| 1186 | static UINT8 update_attributes(mc6847_state *mc6847) |
| 1187 | { |
| 1188 | if (mc6847->in_gm0_func.read != NULL) |
| 1189 | mc6847->gm0 = devcb_call_read_line(&mc6847->in_gm0_func); |
| 1190 | if (mc6847->in_gm1_func.read != NULL) |
| 1191 | mc6847->gm1 = devcb_call_read_line(&mc6847->in_gm1_func); |
| 1192 | if (mc6847->in_gm2_func.read != NULL) |
| 1193 | mc6847->gm2 = devcb_call_read_line(&mc6847->in_gm2_func); |
| 1194 | if (mc6847->in_css_func.read != NULL) |
| 1195 | mc6847->css = devcb_call_read_line(&mc6847->in_css_func); |
| 1196 | if (mc6847->in_inv_func.read != NULL) |
| 1197 | mc6847->inv = devcb_call_read_line(&mc6847->in_inv_func); |
| 1198 | if (mc6847->in_intext_func.read != NULL) |
| 1199 | mc6847->intext = devcb_call_read_line(&mc6847->in_intext_func); |
| 1200 | if (mc6847->in_as_func.read != NULL) |
| 1201 | mc6847->as = devcb_call_read_line(&mc6847->in_as_func); |
| 1202 | if (mc6847->in_ag_func.read != NULL) |
| 1203 | mc6847->ag = devcb_call_read_line(&mc6847->in_ag_func); |
| 1204 | |
| 1205 | return (mc6847->ag << 7) | (mc6847->as << 6) | (mc6847->intext << 5) | (mc6847->inv << 4) | |
| 1206 | (mc6847->css << 3) | (mc6847->gm2 << 2) | (mc6847->gm1 << 1) | mc6847->gm0; |
| 1207 | } |
| 1208 | |
| 1209 | |
| 1210 | INLINE void prepare_scanline(running_machine *machine, mc6847_state *mc6847, int xpos) |
| 1211 | { |
| 1212 | UINT8 attrs, data, attr; |
| 1213 | int scanline; |
| 1214 | int i, border_color; |
| 1215 | int dirty; |
| 1216 | m6847_pixel *scanline_data; |
| 1217 | |
| 1218 | scanline = get_scanline(mc6847); |
| 1219 | |
| 1220 | if (LOG_PREPARE) |
| 1221 | logerror("m6847_prepare_scanline(): scanline=%d xpos=%d\n", scanline, xpos); |
| 1222 | |
| 1223 | if ((scanline >= 0) && (scanline < (mc6847->top_border_scanlines |
| 1224 | + mc6847->display_scanlines + mc6847->bottom_border_scanlines))) |
| 1225 | { |
| 1226 | if (mc6847->using_custom) |
| 1227 | { |
| 1228 | mc6847->custom_prepare_scanline(scanline); |
| 1229 | } |
| 1230 | else |
| 1231 | { |
| 1232 | /* has the border color changed? */ |
| 1233 | attrs = update_attributes(mc6847); |
| 1234 | |
| 1235 | if (attrs != mc6847->attrs[scanline]) |
| 1236 | { |
| 1237 | mc6847->dirty = TRUE; |
| 1238 | mc6847->attrs[scanline] = attrs; |
| 1239 | |
| 1240 | /* choose the border color */ |
| 1241 | if (attrs & M6847_AG) |
| 1242 | border_color = (attrs & M6847_CSS) ? BUFF : GREEN; |
| 1243 | else if (mc6847->has_lowercase && (attrs & M6847_GM2)) |
| 1244 | border_color = (attrs & M6847_CSS) ? LTORANGE : LTGREEN; |
| 1245 | else |
| 1246 | border_color = BLACK; |
| 1247 | |
| 1248 | /* need to use palette table directly; border colors are constant */ |
| 1249 | mc6847->border[scanline] = mc6847->palette[border_color]; |
| 1250 | } |
| 1251 | |
| 1252 | /* is this a display scanline? */ |
| 1253 | scanline -= mc6847->top_border_scanlines; |
| 1254 | if ((scanline >= 0) && (scanline < mc6847->display_scanlines)) |
| 1255 | { |
| 1256 | offs_t addr = scanline_to_address(mc6847, scanline); |
| 1257 | dirty = mc6847->dirty; |
| 1258 | scanline_data = mc6847->screendata[scanline]; |
| 1259 | |
| 1260 | for (i = xpos; i < 32; i++) |
| 1261 | { |
| 1262 | data = devcb_call_read8(&mc6847->in_dd_func, addr + i); |
| 1263 | attr = update_attributes(mc6847); |
| 1264 | |
| 1265 | if ((data != scanline_data[i].data) || (attr != scanline_data[i].attr)) |
| 1266 | { |
| 1267 | dirty = TRUE; |
| 1268 | scanline_data[i].data = data; |
| 1269 | scanline_data[i].attr = attr; |
| 1270 | } |
| 1271 | } |
| 1272 | mc6847->dirty = dirty; |
| 1273 | } |
| 1274 | } |
| 1275 | } |
| 1276 | } |
| 1277 | |
| 1278 | |
| 1279 | |
| 1280 | void m6847_video_changed(void) |
| 1281 | { |
| 1282 | /* NPW 2-May-2006 - Commenting this out until we properly fix bug #878 */ |
| 1283 | /* prepare_scanline(get_beamx() / 8); */ |
| 1284 | } |
| 1285 | |
| 1286 | |
| 1287 | |
| 1288 | /************************************* |
| 1289 | * |
| 1290 | * Field sync/Horizontal sync timers |
| 1291 | * |
| 1292 | *************************************/ |
| 1293 | |
| 1294 | static TIMER_CALLBACK( hs_fall ) |
| 1295 | { |
| 1296 | mc6847_state *mc6847 = (mc6847_state *) ptr; |
| 1297 | |
| 1298 | if (LOG_HS) |
| 1299 | logerror("hs_fall(): time=%s\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION)); |
| 1300 | |
| 1301 | mc6847->hs = CLEAR_LINE; |
| 1302 | devcb_call_write_line(&mc6847->out_hs_func, CLEAR_LINE); |
| 1303 | } |
| 1304 | |
| 1305 | static TIMER_CALLBACK( hs_rise ) |
| 1306 | { |
| 1307 | mc6847_state *mc6847 = (mc6847_state *) ptr; |
| 1308 | |
| 1309 | if (LOG_HS) |
| 1310 | logerror("hs_rise(): time=%s\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION)); |
| 1311 | |
| 1312 | timer_adjust_oneshot(mc6847->hs_rise_timer, |
| 1313 | attotime_make(0, mc6847->scanline_period), 0); |
| 1314 | timer_adjust_oneshot(mc6847->hs_fall_timer, |
| 1315 | attotime_make(0, mc6847->horizontal_sync_period), 0); |
| 1316 | |
| 1317 | mc6847->hs = ASSERT_LINE; |
| 1318 | devcb_call_write_line(&mc6847->out_hs_func, ASSERT_LINE); |
| 1319 | |
| 1320 | prepare_scanline(machine, mc6847, 0); |
| 1321 | } |
| 1322 | |
| 1323 | static TIMER_CALLBACK( fs_fall ) |
| 1324 | { |
| 1325 | mc6847_state *mc6847 = (mc6847_state *) ptr; |
| 1326 | |
| 1327 | if (LOG_FS) |
| 1328 | logerror("fs_fall(): time=%s scanline=%d\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION), get_scanline(mc6847)); |
| 1329 | |
| 1330 | mc6847->fs = CLEAR_LINE; |
| 1331 | devcb_call_write_line(&mc6847->out_fs_func, CLEAR_LINE); |
| 1332 | } |
| 1333 | |
| 1334 | static TIMER_CALLBACK( fs_rise ) |
| 1335 | { |
| 1336 | mc6847_state *mc6847 = (mc6847_state *) ptr; |
| 1337 | |
| 1338 | if (LOG_FS) |
| 1339 | logerror("fs_rise(): time=%s scanline=%d\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION), get_scanline(mc6847)); |
| 1340 | |
| 1341 | /* adjust field sync falling edge timer */ |
| 1342 | timer_adjust_oneshot(mc6847->fs_fall_timer, |
| 1343 | attotime_make(0, mc6847->field_sync_period), 0); |
| 1344 | |
| 1345 | /* adjust horizontal sync rising timer */ |
| 1346 | timer_adjust_oneshot(mc6847->hs_rise_timer, attotime_zero, 0); |
| 1347 | |
| 1348 | /* this is a hook for the CoCo 3 code to extend this stuff */ |
| 1349 | if (mc6847->new_frame_callback) |
| 1350 | mc6847->using_custom = !mc6847->new_frame_callback(machine); |
| 1351 | |
| 1352 | mc6847->fs = ASSERT_LINE; |
| 1353 | devcb_call_write_line(&mc6847->out_fs_func, ASSERT_LINE); |
| 1354 | } |
| 1355 | |
| 1356 | |
| 1357 | |
| 1358 | #if 0 |
| 1359 | /************************************* |
| 1360 | * |
| 1361 | * Debugging |
| 1362 | * |
| 1363 | *************************************/ |
| 1364 | |
| 1365 | |
| 1366 | static int get_beamx(mc6847_state *mc6847) |
| 1367 | { |
| 1368 | attotime scanline_time; |
| 1369 | int result; |
| 1370 | |
| 1371 | scanline_time = timer_timeelapsed(mc6847->hs_rise_timer); |
| 1372 | if (scanline_time.seconds != 0) |
| 1373 | return 0; |
| 1374 | assert(attotime_to_attoseconds(scanline_time) < mc6847->scanline_period); |
| 1375 | |
| 1376 | if (attotime_to_attoseconds(scanline_time) < (mc6847->clock_period * 42)) |
| 1377 | { |
| 1378 | /* hsync */ |
| 1379 | result = 0; |
| 1380 | } |
| 1381 | else if (attotime_to_attoseconds(scanline_time) < (mc6847->clock_period * 95 / 2)) |
| 1382 | { |
| 1383 | /* left border */ |
| 1384 | result = 0; |
| 1385 | } |
| 1386 | else if (attotime_to_attoseconds(scanline_time) < (mc6847->clock_period * 351 / 2)) |
| 1387 | { |
| 1388 | /* body */ |
| 1389 | result = (attotime_to_attoseconds(scanline_time) - (mc6847->clock_period * 95 / 2)) |
| 1390 | / mc6847->clock_period * 2; |
| 1391 | } |
| 1392 | else |
| 1393 | { |
| 1394 | /* right border */ |
| 1395 | result = 256; |
| 1396 | } |
| 1397 | return result; |
| 1398 | } |
| 1399 | |
| 1400 | |
| 1401 | static void execute_m6847_dumpscanline(const device_config *device, int ref, int params, const char **param) |
| 1402 | { |
| 1403 | mc6847_state *mc6847 = get_safe_token(device); |
| 1404 | |
| 1405 | int i; |
| 1406 | int beamx = get_beamx(mc6847) / 8; |
| 1407 | int scanline = get_scanline(mc6847); |
| 1408 | const m6847_pixel *pixel = mc6847->screendata[scanline]; |
| 1409 | |
| 1410 | for (i = 0; i < beamx; i++) |
| 1411 | { |
| 1412 | debug_console_printf(device->machine, "[%02d]: 0x%02X (", i, pixel[i].data); |
| 1413 | |
| 1414 | if (pixel[i].attr & M6847_AG) debug_console_printf(device->machine, " AG"); |
| 1415 | if (pixel[i].attr & M6847_AS) debug_console_printf(device->machine, " AS"); |
| 1416 | if (pixel[i].attr & M6847_INTEXT) debug_console_printf(device->machine, " INTEXT"); |
| 1417 | if (pixel[i].attr & M6847_INV) debug_console_printf(device->machine, " INV"); |
| 1418 | if (pixel[i].attr & M6847_CSS) debug_console_printf(device->machine, " CSS"); |
| 1419 | if (pixel[i].attr & M6847_GM2) debug_console_printf(device->machine, " GM2"); |
| 1420 | if (pixel[i].attr & M6847_GM1) debug_console_printf(device->machine, " GM1"); |
| 1421 | if (pixel[i].attr & M6847_GM0) debug_console_printf(device->machine, " GM0"); |
| 1422 | |
| 1423 | debug_console_printf(device->machine, " )\n"); |
| 1424 | } |
| 1425 | } |
| 1426 | #endif |
| 1427 | |
| 1428 | |
| 1429 | |
| 1430 | /************************************* |
| 1431 | * |
| 1432 | * Initialization |
| 1433 | * |
| 1434 | *************************************/ |
| 1435 | |
| 1436 | static const UINT8 *find_char(const m6847_variant *v, |
| 1437 | UINT8 byte, UINT8 attr, int *fg, int *bg) |
| 1438 | { |
| 1439 | int ch; |
| 1440 | size_t offset = 0; |
| 1441 | |
| 1442 | if (attr & M6847_AS) |
| 1443 | { |
| 1444 | /* semigraphics */ |
| 1445 | *bg = BLACK; |
| 1446 | |
| 1447 | if (!v->has_lowercase && (attr & M6847_INTEXT)) |
| 1448 | { |
| 1449 | /* semigraphics 6 */ |
| 1450 | ch = (byte & 0x3F) + 0x60; |
| 1451 | *fg = ((byte >> 6) & 0x03) + ((attr & M6847_CSS) ? BUFF : GREEN); |
| 1452 | } |
| 1453 | else |
| 1454 | { |
| 1455 | /* semigraphics 4 */ |
| 1456 | ch = (byte & 0x0F) + 0xA0; |
| 1457 | *fg = ((byte >> 4) & 0x07) + GREEN; |
| 1458 | } |
| 1459 | } |
| 1460 | else |
| 1461 | { |
| 1462 | /* text */ |
| 1463 | ch = (byte & 0x3F) + 0x00; |
| 1464 | |
| 1465 | if (v->has_lowercase) |
| 1466 | { |
| 1467 | if ((ch < 0x20) && (attr & M6847_GM0) && !(attr & M6847_INV)) |
| 1468 | { |
| 1469 | /* this is a lowercase character */ |
| 1470 | attr |= M6847_INV; |
| 1471 | ch += 0x40; |
| 1472 | } |
| 1473 | |
| 1474 | if ((ch > 0x20) && (attr & M6847_GM0) && !(attr & M6847_INV)) { |
| 1475 | ch += 0x20; |
| 1476 | } |
| 1477 | |
| 1478 | if (attr & M6847_GM1) |
| 1479 | attr ^= M6847_INV; |
| 1480 | |
| 1481 | } |
| 1482 | |
| 1483 | if (attr & M6847_INV) |
| 1484 | { |
| 1485 | /* dark foreground, light background */ |
| 1486 | *fg = (attr & M6847_CSS) ? DKORANGE : DKGREEN; |
| 1487 | *bg = (attr & M6847_CSS) ? LTORANGE : LTGREEN; |
| 1488 | } |
| 1489 | else |
| 1490 | { |
| 1491 | /* light foreground, dark background */ |
| 1492 | *fg = (attr & M6847_CSS) ? LTORANGE : LTGREEN; |
| 1493 | *bg = (attr & M6847_CSS) ? DKORANGE : DKGREEN; |
| 1494 | } |
| 1495 | |
| 1496 | offset = v->text_offset; |
| 1497 | } |
| 1498 | |
| 1499 | return &v->fontdata[ch * 12] + offset; |
| 1500 | } |
| 1501 | |
| 1502 | |
| 1503 | |
| 1504 | static void build_fontdata(const device_config *device, const m6847_variant *v) |
| 1505 | { |
| 1506 | mc6847_state *mc6847 = get_safe_token(device); |
| 1507 | |
| 1508 | int attr_index, row; |
| 1509 | int fg, bg; |
| 1510 | int byte; |
| 1511 | const UINT8 *char_data; |
| 1512 | |
| 1513 | for (attr_index = 0; attr_index < ARRAY_LENGTH(mc6847->fontdata); attr_index++) |
| 1514 | { |
| 1515 | UINT8 attr = attribute_from_attr_index(device, attr_index); |
| 1516 | |
| 1517 | for (byte = 0; byte < 256; byte++) |
| 1518 | { |
| 1519 | char_data = find_char(v, byte, attr, &fg, &bg); |
| 1520 | |
| 1521 | /* specify colors */ |
| 1522 | mc6847->colordata[attr_index][byte / 16][0] = bg; |
| 1523 | mc6847->colordata[attr_index][byte / 16][1] = fg; |
| 1524 | |
| 1525 | for (row = 0; row < 12; row++) |
| 1526 | { |
| 1527 | mc6847->fontdata[attr_index][byte][row] = char_data[row]; |
| 1528 | } |
| 1529 | } |
| 1530 | } |
| 1531 | } |
| 1532 | |
| 1533 | |
| 1534 | |
| 1535 | /************************************* |
| 1536 | * |
| 1075 | 1537 | * Video modes |
| 1076 | 1538 | * |
| 1077 | 1539 | *************************************/ |
| 1078 | 1540 | |
| 1079 | | static void graphics_color_64(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1541 | static void graphics_color_64(const device_config *device, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1080 | 1542 | { |
| 1081 | 1543 | int x; |
| 1082 | 1544 | UINT8 byte, attr; |
| r5922 | r5923 | |
| 1086 | 1548 | byte = video_data[x].data; |
| 1087 | 1549 | attr = video_data[x].attr; |
| 1088 | 1550 | |
| 1089 | | line[ 0] = line[ 1] = line[ 2] = line[ 3] = color(((byte >> 6) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1090 | | line[ 4] = line[ 5] = line[ 6] = line[ 7] = color(((byte >> 4) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1091 | | line[ 8] = line[ 9] = line[10] = line[11] = color(((byte >> 2) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1092 | | line[12] = line[13] = line[14] = line[15] = color(((byte >> 0) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1551 | line[ 0] = line[ 1] = line[ 2] = line[ 3] = color(device, ((byte >> 6) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1552 | line[ 4] = line[ 5] = line[ 6] = line[ 7] = color(device, ((byte >> 4) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1553 | line[ 8] = line[ 9] = line[10] = line[11] = color(device, ((byte >> 2) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1554 | line[12] = line[13] = line[14] = line[15] = color(device, ((byte >> 0) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1093 | 1555 | line += 16; |
| 1094 | 1556 | } |
| 1095 | 1557 | } |
| 1096 | 1558 | |
| 1097 | 1559 | |
| 1098 | 1560 | |
| 1099 | | static void graphics_color_128(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1561 | static void graphics_color_128(const device_config *device, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1100 | 1562 | { |
| 1101 | 1563 | int x; |
| 1102 | 1564 | UINT8 byte, attr; |
| r5922 | r5923 | |
| 1106 | 1568 | byte = video_data[x].data; |
| 1107 | 1569 | attr = video_data[x].attr; |
| 1108 | 1570 | |
| 1109 | | line[ 0] = line[ 1] = color(((byte >> 6) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1110 | | line[ 2] = line[ 3] = color(((byte >> 4) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1111 | | line[ 4] = line[ 5] = color(((byte >> 2) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1112 | | line[ 6] = line[ 7] = color(((byte >> 0) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1571 | line[ 0] = line[ 1] = color(device, ((byte >> 6) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1572 | line[ 2] = line[ 3] = color(device, ((byte >> 4) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1573 | line[ 4] = line[ 5] = color(device, ((byte >> 2) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1574 | line[ 6] = line[ 7] = color(device, ((byte >> 0) & 0x03) + (attr & M6847_CSS ? BUFF : GREEN)); |
| 1113 | 1575 | line += 8; |
| 1114 | 1576 | } |
| 1115 | 1577 | } |
| 1116 | 1578 | |
| 1117 | 1579 | |
| 1118 | 1580 | |
| 1119 | | static void graphics_bw_128(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1581 | static void graphics_bw_128(const device_config *device, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1120 | 1582 | { |
| 1121 | 1583 | int x; |
| 1122 | 1584 | UINT8 byte, attr; |
| r5922 | r5923 | |
| 1127 | 1589 | byte = video_data[x].data; |
| 1128 | 1590 | attr = video_data[x].attr; |
| 1129 | 1591 | |
| 1130 | | bg = color(attr & M6847_CSS ? 10 : 8); |
| 1131 | | fg = color(attr & M6847_CSS ? 11 : 9); |
| 1592 | bg = color(device, attr & M6847_CSS ? 10 : 8); |
| 1593 | fg = color(device, attr & M6847_CSS ? 11 : 9); |
| 1132 | 1594 | |
| 1133 | 1595 | line[ 0] = line[ 1] = ((byte >> 7) & 0x01) ? fg : bg; |
| 1134 | 1596 | line[ 2] = line[ 3] = ((byte >> 6) & 0x01) ? fg : bg; |
| r5922 | r5923 | |
| 1144 | 1606 | |
| 1145 | 1607 | |
| 1146 | 1608 | |
| 1147 | | static void graphics_bw_256(UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1609 | static void graphics_bw_256(const device_config *device, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1148 | 1610 | { |
| 1149 | 1611 | int x; |
| 1150 | 1612 | UINT8 byte, attr; |
| r5922 | r5923 | |
| 1155 | 1617 | byte = video_data[x].data; |
| 1156 | 1618 | attr = video_data[x].attr; |
| 1157 | 1619 | |
| 1158 | | bg = color(attr & M6847_CSS ? 10 : 8); |
| 1159 | | fg = color(attr & M6847_CSS ? 11 : 9); |
| 1620 | bg = color(device, attr & M6847_CSS ? 10 : 8); |
| 1621 | fg = color(device, attr & M6847_CSS ? 11 : 9); |
| 1160 | 1622 | |
| 1161 | 1623 | line[0] = ((byte >> 7) & 0x01) ? fg : bg; |
| 1162 | 1624 | line[1] = ((byte >> 6) & 0x01) ? fg : bg; |
| r5922 | r5923 | |
| 1172 | 1634 | |
| 1173 | 1635 | |
| 1174 | 1636 | |
| 1175 | | static void (*const graphics_modes[8])(UINT32 *line, const m6847_pixel *video_data) = |
| 1637 | static void (*const graphics_modes[8])(const device_config *device, UINT32 *line, const m6847_pixel *video_data) = |
| 1176 | 1638 | { |
| 1177 | 1639 | graphics_color_64, graphics_bw_128, |
| 1178 | 1640 | graphics_color_128, graphics_bw_128, |
| r5922 | r5923 | |
| 1182 | 1644 | |
| 1183 | 1645 | |
| 1184 | 1646 | |
| 1185 | | static void text_mode(running_machine *machine, int scanline, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1647 | static void text_mode(const device_config *device, int scanline, UINT32 *RESTRICT line, const m6847_pixel *RESTRICT video_data) |
| 1186 | 1648 | { |
| 1649 | mc6847_state *mc6847 = get_safe_token(device); |
| 1187 | 1650 | int x; |
| 1188 | 1651 | UINT8 byte, attr; |
| 1189 | 1652 | int attr_index; |
| r5922 | r5923 | |
| 1195 | 1658 | byte = video_data[x].data; |
| 1196 | 1659 | attr = video_data[x].attr; |
| 1197 | 1660 | |
| 1198 | | attr_index = attr_index_from_attribute(attr); |
| 1661 | attr_index = attr_index_from_attribute(device, attr); |
| 1199 | 1662 | |
| 1200 | | bg_color = color(m6847->colordata[attr_index][byte / 16][0]); |
| 1201 | | fg_color = color(m6847->colordata[attr_index][byte / 16][1]); |
| 1663 | bg_color = color(device, mc6847->colordata[attr_index][byte / 16][0]); |
| 1664 | fg_color = color(device, mc6847->colordata[attr_index][byte / 16][1]); |
| 1202 | 1665 | |
| 1203 | | if( (!m6847->has_lowercase) && (attr & M6847_INTEXT) && !(attr & M6847_AS)) { |
| 1204 | | if (m6847->get_char_rom) { |
| 1205 | | char_data = m6847->get_char_rom(machine,byte,scanline % 12); |
| 1666 | if( (!mc6847->has_lowercase) && (attr & M6847_INTEXT) && !(attr & M6847_AS)) { |
| 1667 | if (mc6847->get_char_rom) { |
| 1668 | char_data = mc6847->get_char_rom(device->machine,byte,scanline % 12); |
| 1206 | 1669 | } else { |
| 1207 | 1670 | char_data = 0xff; |
| 1208 | 1671 | } |
| 1209 | 1672 | } else { |
| 1210 | | if (m6847->get_char_rom) |
| 1211 | | char_data = m6847->get_char_rom(machine,byte,scanline % 12); |
| 1673 | if (mc6847->get_char_rom) |
| 1674 | char_data = mc6847->get_char_rom(device->machine,byte,scanline % 12); |
| 1212 | 1675 | else |
| 1213 | | char_data = m6847->fontdata[attr_index][byte][scanline % 12]; |
| 1676 | char_data = mc6847->fontdata[attr_index][byte][scanline % 12]; |
| 1214 | 1677 | } |
| 1215 | 1678 | |
| 1216 | 1679 | line[x*8+0] = (char_data & 0x80) ? fg_color : bg_color; |
| r5922 | r5923 | |
| 1226 | 1689 | |
| 1227 | 1690 | |
| 1228 | 1691 | |
| 1229 | | static void render_scanline(running_machine *machine, bitmap_t *bitmap, int scanline) |
| 1692 | static void render_scanline(const device_config *device, bitmap_t *bitmap, int scanline) |
| 1230 | 1693 | { |
| 1694 | mc6847_state *mc6847 = get_safe_token(device); |
| 1231 | 1695 | UINT32 border_color; |
| 1232 | 1696 | UINT32 *line; |
| 1233 | 1697 | UINT8 attrs; |
| r5922 | r5923 | |
| 1238 | 1702 | line = BITMAP_ADDR32(bitmap, scanline, 0); |
| 1239 | 1703 | |
| 1240 | 1704 | /* choose the border color */ |
| 1241 | | border_color = m6847->border[scanline]; |
| 1242 | | attrs = m6847->attrs[scanline]; |
| 1705 | border_color = mc6847->border[scanline]; |
| 1706 | attrs = mc6847->attrs[scanline]; |
| 1243 | 1707 | |
| 1244 | 1708 | /* is this a border scanline? */ |
| 1245 | | scanline -= m6847->top_border_scanlines; |
| 1246 | | if ((scanline >= 0) && (scanline < m6847->display_scanlines)) |
| 1709 | scanline -= mc6847->top_border_scanlines; |
| 1710 | if ((scanline >= 0) && (scanline < mc6847->display_scanlines)) |
| 1247 | 1711 | { |
| 1248 | | video_data = m6847->screendata[scanline]; |
| 1712 | video_data = mc6847->screendata[scanline]; |
| 1249 | 1713 | |
| 1250 | 1714 | /* left border */ |
| 1251 | 1715 | for (x = 0; x < 32; x++) |
| r5922 | r5923 | |
| 1255 | 1719 | { |
| 1256 | 1720 | /* graphics */ |
| 1257 | 1721 | mode = attrs & (M6847_GM2|M6847_GM1|M6847_GM0); |
| 1258 | | graphics_modes[mode](line + 32, video_data); |
| 1722 | graphics_modes[mode](device, line + 32, video_data); |
| 1259 | 1723 | } |
| 1260 | 1724 | else |
| 1261 | 1725 | { |
| 1262 | 1726 | /* text/semigraphics */ |
| 1263 | | text_mode(machine, scanline, line + 32, video_data); |
| 1727 | text_mode(device, scanline, line + 32, video_data); |
| 1264 | 1728 | } |
| 1265 | 1729 | |
| 1266 | 1730 | /* right border */ |
| r5922 | r5923 | |
| 1271 | 1735 | if ((attrs & (M6847_AG|M6847_GM2|M6847_GM1|M6847_GM0)) |
| 1272 | 1736 | == (M6847_AG|M6847_GM2|M6847_GM1|M6847_GM0)) |
| 1273 | 1737 | { |
| 1274 | | apply_artifacts(machine, line + 32); |
| 1738 | apply_artifacts(device->machine, line + 32); |
| 1275 | 1739 | } |
| 1276 | 1740 | } |
| 1277 | 1741 | else |
| r5922 | r5923 | |
| 1284 | 1748 | |
| 1285 | 1749 | |
| 1286 | 1750 | |
| 1287 | | static void set_dirty(void) |
| 1751 | static void set_dirty(mc6847_state *mc6847) |
| 1288 | 1752 | { |
| 1289 | | m6847->dirty = TRUE; |
| 1753 | mc6847->dirty = TRUE; |
| 1290 | 1754 | } |
| 1291 | 1755 | |
| 1292 | 1756 | |
| 1293 | 1757 | |
| 1758 | /***************************************************************************** |
| 1759 | DEVICE INTERFACE |
| 1760 | *****************************************************************************/ |
| 1761 | |
| 1762 | static STATE_POSTLOAD( mc6847_postload ) |
| 1763 | { |
| 1764 | set_dirty(param); |
| 1765 | } |
| 1766 | |
| 1767 | static DEVICE_START( mc6847 ) |
| 1768 | { |
| 1769 | mc6847_state *mc6847 = get_safe_token(device); |
| 1770 | const mc6847_interface *intf = device->static_config; |
| 1771 | const mc6847_config *cfg = device->inline_config; |
| 1772 | |
| 1773 | const m6847_variant *v; |
| 1774 | UINT32 frequency; |
| 1775 | attoseconds_t period, frame_period, cpu0_clock_period = 0; |
| 1776 | double total_scanlines; |
| 1777 | |
| 1778 | /* validate some basic stuff */ |
| 1779 | assert(device->static_config != NULL); |
| 1780 | assert(device->inline_config != NULL); |
| 1781 | |
| 1782 | |
| 1783 | |
| 1784 | /* identify proper M6847 variant */ |
| 1785 | assert(cfg->type < ARRAY_LENGTH(variants)); |
| 1786 | v = &variants[cfg->type]; |
| 1787 | |
| 1788 | /* allocate instance */ |
| 1789 | set_dirty(mc6847); |
| 1790 | |
| 1791 | /* copy configuration */ |
| 1792 | mc6847->new_frame_callback = cfg->new_frame_callback; |
| 1793 | mc6847->custom_prepare_scanline = cfg->custom_prepare_scanline; |
| 1794 | mc6847->has_lowercase = v->has_lowercase; |
| 1795 | mc6847->get_char_rom = cfg->get_char_rom; |
| 1796 | |
| 1797 | /* assert our assumptions */ |
| 1798 | assert((v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME) |
| 1799 | == (UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME)); |
| 1800 | assert((v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE) |
| 1801 | == (UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE)); |
| 1802 | assert((v->scanlines_per_frame * v->clocks_per_scanline * GROSS_FACTOR) |
| 1803 | == (UINT32) (v->scanlines_per_frame * v->clocks_per_scanline * GROSS_FACTOR)); |
| 1804 | |
| 1805 | /* choose palette */ |
| 1806 | if (cfg->custom_palette) |
| 1807 | { |
| 1808 | mc6847->has_custom_palette = 1; |
| 1809 | mc6847->palette = cfg->custom_palette; |
| 1810 | } |
| 1811 | else |
| 1812 | { |
| 1813 | mc6847->palette = palette; |
| 1814 | } |
| 1815 | |
| 1816 | /* allocate timers */ |
| 1817 | mc6847->fs_rise_timer = timer_alloc(device->machine, fs_rise, mc6847); |
| 1818 | mc6847->fs_fall_timer = timer_alloc(device->machine, fs_fall, mc6847); |
| 1819 | mc6847->hs_rise_timer = timer_alloc(device->machine, hs_rise, mc6847); |
| 1820 | mc6847->hs_fall_timer = timer_alloc(device->machine, hs_fall, mc6847); |
| 1821 | |
| 1822 | /* setup dimensions */ |
| 1823 | mc6847->top_border_scanlines = v->top_border_scanlines; |
| 1824 | mc6847->display_scanlines = v->display_scanlines; |
| 1825 | mc6847->bottom_border_scanlines = v->bottom_border_scanlines; |
| 1826 | |
| 1827 | /* compute frequency and period */ |
| 1828 | frequency = v->frames_per_second |
| 1829 | * ((UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME)) |
| 1830 | * ((UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE)); |
| 1831 | period = ATTOSECONDS_PER_SECOND / frequency; |
| 1832 | |
| 1833 | /* choose CPU clock, if specified */ |
| 1834 | if (cfg->cpu0_timing_factor > 0) |
| 1835 | { |
| 1836 | cpu0_clock_period = period * cfg->cpu0_timing_factor * GROSS_FACTOR; |
| 1837 | cpu_set_clock(device->machine->firstcpu, ATTOSECONDS_PER_SECOND / cpu0_clock_period); |
| 1838 | } |
| 1839 | |
| 1840 | /* calculate timing */ |
| 1841 | total_scanlines = v->vblank_scanlines |
| 1842 | + v->top_border_scanlines |
| 1843 | + v->display_scanlines |
| 1844 | + v->bottom_border_scanlines |
| 1845 | + v->vretrace_scanlines; |
| 1846 | mc6847->clock_period = period * GROSS_FACTOR; |
| 1847 | mc6847->scanline_period = period * (UINT32) (v->clocks_per_scanline * GROSS_FACTOR); |
| 1848 | mc6847->field_sync_period = period * (UINT32) (v->clocks_per_scanline * v->field_sync_scanlines * GROSS_FACTOR); |
| 1849 | mc6847->horizontal_sync_period = period * GROSS_FACTOR * 33 / 2; |
| 1850 | mc6847->vblank_period = period * (UINT32) (v->clocks_per_scanline * v->vblank_scanlines * GROSS_FACTOR); |
| 1851 | |
| 1852 | /* setup timing */ |
| 1853 | frame_period = period * |
| 1854 | (UINT32) (v->clocks_per_scanline * total_scanlines * GROSS_FACTOR); |
| 1855 | timer_adjust_periodic(mc6847->fs_rise_timer, attotime_zero, 0, attotime_make(0, frame_period)); |
| 1856 | |
| 1857 | /* build font */ |
| 1858 | build_fontdata(device, v); |
| 1859 | |
| 1860 | /* dump stats */ |
| 1861 | if (LOG_STATS) |
| 1862 | { |
| 1863 | logerror("m6847_init():\n"); |
| 1864 | logerror("\tclock: %30s sec\n", attotime_string(attotime_make(0, period * GROSS_FACTOR), ATTOTIME_STRING_PRECISION)); |
| 1865 | if (cpu0_clock_period > 0) |
| 1866 | logerror("\tCPU0 clock: %30s sec\n", attotime_string(attotime_make(0, cpu0_clock_period), ATTOTIME_STRING_PRECISION)); |
| 1867 | logerror("\tscanline: %30s sec\n", attotime_string(attotime_make(0, mc6847->scanline_period), ATTOTIME_STRING_PRECISION)); |
| 1868 | logerror("\tfield sync: %30s sec\n", attotime_string(attotime_make(0, mc6847->field_sync_period), ATTOTIME_STRING_PRECISION)); |
| 1869 | logerror("\thorz sync: %30s sec\n", attotime_string(attotime_make(0, mc6847->horizontal_sync_period), ATTOTIME_STRING_PRECISION)); |
| 1870 | logerror("\tvblank: %30s sec\n", attotime_string(attotime_make(0, mc6847->vblank_period), ATTOTIME_STRING_PRECISION)); |
| 1871 | logerror("\tframe: %30s sec\n", attotime_string(attotime_make(0, frame_period), ATTOTIME_STRING_PRECISION)); |
| 1872 | logerror("\n"); |
| 1873 | } |
| 1874 | |
| 1875 | #if 0 |
| 1876 | /* setup debug commands */ |
| 1877 | if (device->machine->debug_flags & DEBUG_FLAG_ENABLED) |
| 1878 | debug_console_register_command(device->machine, "m6847_dumpscanline", CMDFLAG_NONE, 0, 0, 0, execute_m6847_dumpscanline); |
| 1879 | #endif |
| 1880 | |
| 1881 | |
| 1882 | /* resolve callbacks */ |
| 1883 | devcb_resolve_read8(&mc6847->in_dd_func, &intf->in_dd_func, device); |
| 1884 | devcb_resolve_read_line(&mc6847->in_gm2_func, &intf->in_gm2_func, device); |
| 1885 | devcb_resolve_read_line(&mc6847->in_gm1_func, &intf->in_gm1_func, device); |
| 1886 | devcb_resolve_read_line(&mc6847->in_gm0_func, &intf->in_gm0_func, device); |
| 1887 | devcb_resolve_read_line(&mc6847->in_intext_func, &intf->in_intext_func, device); |
| 1888 | devcb_resolve_read_line(&mc6847->in_inv_func, &intf->in_inv_func, device); |
| 1889 | devcb_resolve_read_line(&mc6847->in_as_func, &intf->in_as_func, device); |
| 1890 | devcb_resolve_read_line(&mc6847->in_ag_func, &intf->in_ag_func, device); |
| 1891 | devcb_resolve_write_line(&mc6847->out_fs_func, &intf->out_fs_func, device); |
| 1892 | devcb_resolve_write_line(&mc6847->out_hs_func, &intf->out_hs_func, device); |
| 1893 | devcb_resolve_read_line(&mc6847->in_css_func, &intf->in_css_func, device); |
| 1894 | |
| 1895 | /* setup save states */ |
| 1896 | state_save_register_postload(device->machine, mc6847_postload, mc6847); |
| 1897 | } |
| 1898 | |
| 1899 | static DEVICE_RESET( mc6847 ) |
| 1900 | { |
| 1901 | mc6847_state *mc6847 = get_safe_token(device); |
| 1902 | |
| 1903 | mc6847->gm2 = 0; |
| 1904 | mc6847->gm1 = 0; |
| 1905 | mc6847->gm0 = 0; |
| 1906 | mc6847->intext = 0; |
| 1907 | mc6847->inv = 0; |
| 1908 | mc6847->as = 0; |
| 1909 | mc6847->ag = 0; |
| 1910 | mc6847->css = 0; |
| 1911 | } |
| 1912 | |
| 1913 | DEVICE_GET_INFO( mc6847 ) |
| 1914 | { |
| 1915 | switch (state) |
| 1916 | { |
| 1917 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1918 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(mc6847_state); break; |
| 1919 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(mc6847_config); break; |
| 1920 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_OTHER; break; |
| 1921 | |
| 1922 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1923 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mc6847); break; |
| 1924 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 1925 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(mc6847); break; |
| 1926 | |
| 1927 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1928 | case DEVINFO_STR_NAME: strcpy(info->s, "Motorola 6847"); break; |
| 1929 | case DEVINFO_STR_FAMILY: strcpy(info->s, "MC6847 VDG"); break; |
| 1930 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 1931 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 1932 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright MESS Team"); break; |
| 1933 | } |
| 1934 | } |
| 1935 | |
| 1936 | |
| 1937 | /*************************************************************************** |
| 1938 | IMPLEMENTATION |
| 1939 | ***************************************************************************/ |
| 1940 | |
| 1941 | WRITE_LINE_DEVICE_HANDLER( mc6847_gm2_w ) |
| 1942 | { |
| 1943 | mc6847_state *mc6847 = get_safe_token(device); |
| 1944 | mc6847->gm2 = state; |
| 1945 | } |
| 1946 | |
| 1947 | WRITE_LINE_DEVICE_HANDLER( mc6847_gm1_w ) |
| 1948 | { |
| 1949 | mc6847_state *mc6847 = get_safe_token(device); |
| 1950 | mc6847->gm1 = state; |
| 1951 | } |
| 1952 | |
| 1953 | WRITE_LINE_DEVICE_HANDLER( mc6847_gm0_w ) |
| 1954 | { |
| 1955 | mc6847_state *mc6847 = get_safe_token(device); |
| 1956 | mc6847->gm0 = state; |
| 1957 | } |
| 1958 | |
| 1959 | WRITE_LINE_DEVICE_HANDLER( mc6847_intext_w ) |
| 1960 | { |
| 1961 | mc6847_state *mc6847 = get_safe_token(device); |
| 1962 | mc6847->intext = state; |
| 1963 | } |
| 1964 | |
| 1965 | WRITE_LINE_DEVICE_HANDLER( mc6847_inv_w ) |
| 1966 | { |
| 1967 | mc6847_state *mc6847 = get_safe_token(device); |
| 1968 | mc6847->inv = state; |
| 1969 | } |
| 1970 | |
| 1971 | WRITE_LINE_DEVICE_HANDLER( mc6847_as_w ) |
| 1972 | { |
| 1973 | mc6847_state *mc6847 = get_safe_token(device); |
| 1974 | mc6847->as = state; |
| 1975 | } |
| 1976 | |
| 1977 | WRITE_LINE_DEVICE_HANDLER( mc6847_ag_w ) |
| 1978 | { |
| 1979 | mc6847_state *mc6847 = get_safe_token(device); |
| 1980 | mc6847->ag = state; |
| 1981 | } |
| 1982 | |
| 1983 | WRITE_LINE_DEVICE_HANDLER( mc6847_css_w ) |
| 1984 | { |
| 1985 | mc6847_state *mc6847 = get_safe_token(device); |
| 1986 | mc6847->css = state; |
| 1987 | } |
| 1988 | |
| 1989 | READ_LINE_DEVICE_HANDLER( mc6847_fs_r ) |
| 1990 | { |
| 1991 | mc6847_state *mc6847 = get_safe_token(device); |
| 1992 | return mc6847->fs; |
| 1993 | } |
| 1994 | |
| 1995 | READ_LINE_DEVICE_HANDLER( mc6847_hs_r ) |
| 1996 | { |
| 1997 | mc6847_state *mc6847 = get_safe_token(device); |
| 1998 | return mc6847->hs; |
| 1999 | } |
| 2000 | |
| 2001 | |
| 2002 | void mc6847_set_palette(const device_config *device, UINT32 *palette) |
| 2003 | { |
| 2004 | mc6847_state *mc6847 = get_safe_token(device); |
| 2005 | mc6847->has_custom_palette = 1; |
| 2006 | mc6847->palette = palette; |
| 2007 | } |
| 2008 | |
| 2009 | |
| 1294 | 2010 | /************************************* |
| 1295 | 2011 | * |
| 1296 | 2012 | * Artifacting hack; should be in core |
| r5922 | r5923 | |
| 1422 | 2138 | |
| 1423 | 2139 | static INPUT_CHANGED( artifacting_changed ) |
| 1424 | 2140 | { |
| 1425 | | set_dirty(); |
| 2141 | /* TODO: not sure how to do this with a device... */ |
| 2142 | // set_dirty(); |
| 1426 | 2143 | } |
| 1427 | 2144 | |
| 1428 | 2145 | |
| r5922 | r5923 | |
| 1437 | 2154 | |
| 1438 | 2155 | |
| 1439 | 2156 | |
| 1440 | | /************************************* |
| 1441 | | * |
| 1442 | | * Scanline operations |
| 1443 | | * |
| 1444 | | *************************************/ |
| 1445 | 2157 | |
| 1446 | | static int get_scanline(void) |
| 2158 | UINT32 mc6847_update(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect) |
| 1447 | 2159 | { |
| 1448 | | int result; |
| 1449 | | attotime duration; |
| 1450 | | |
| 1451 | | /* get the time since last field sync */ |
| 1452 | | duration = attotime_sub( |
| 1453 | | timer_starttime(m6847->hs_rise_timer), |
| 1454 | | timer_starttime(m6847->fs_rise_timer)); |
| 1455 | | assert_always(duration.seconds == 0, "get_scanline(): duration exceeds one second"); |
| 1456 | | |
| 1457 | | if (duration.attoseconds < m6847->vblank_period) |
| 1458 | | { |
| 1459 | | result = -1; /* vblank */ |
| 1460 | | } |
| 1461 | | else |
| 1462 | | { |
| 1463 | | result = (duration.attoseconds - m6847->vblank_period) |
| 1464 | | / m6847->scanline_period; |
| 1465 | | } |
| 1466 | | return result; |
| 1467 | | } |
| 1468 | | |
| 1469 | | |
| 1470 | | static int get_beamx(void) |
| 1471 | | { |
| 1472 | | attotime scanline_time; |
| 1473 | | int result; |
| 1474 | | |
| 1475 | | scanline_time = timer_timeelapsed(m6847->hs_rise_timer); |
| 1476 | | if (scanline_time.seconds != 0) |
| 1477 | | return 0; |
| 1478 | | assert(attotime_to_attoseconds(scanline_time) < m6847->scanline_period); |
| 1479 | | |
| 1480 | | if (attotime_to_attoseconds(scanline_time) < (m6847->clock_period * 42)) |
| 1481 | | { |
| 1482 | | /* hsync */ |
| 1483 | | result = 0; |
| 1484 | | } |
| 1485 | | else if (attotime_to_attoseconds(scanline_time) < (m6847->clock_period * 95 / 2)) |
| 1486 | | { |
| 1487 | | /* left border */ |
| 1488 | | result = 0; |
| 1489 | | } |
| 1490 | | else if (attotime_to_attoseconds(scanline_time) < (m6847->clock_period * 351 / 2)) |
| 1491 | | { |
| 1492 | | /* body */ |
| 1493 | | result = (attotime_to_attoseconds(scanline_time) - (m6847->clock_period * 95 / 2)) |
| 1494 | | / m6847->clock_period * 2; |
| 1495 | | } |
| 1496 | | else |
| 1497 | | { |
| 1498 | | /* right border */ |
| 1499 | | result = 256; |
| 1500 | | } |
| 1501 | | return result; |
| 1502 | | } |
| 1503 | | |
| 1504 | | |
| 1505 | | INLINE void prepare_scanline(running_machine *machine, int xpos) |
| 1506 | | { |
| 1507 | | UINT8 attrs, data, attr; |
| 1508 | | int scanline; |
| 1509 | | int i, border_color; |
| 1510 | | int dirty; |
| 1511 | | const UINT8 *RESTRICT video_ram; |
| 1512 | | m6847_pixel *scanline_data; |
| 1513 | | |
| 1514 | | scanline = get_scanline(); |
| 1515 | | |
| 1516 | | if (LOG_PREPARE) |
| 1517 | | logerror("m6847_prepare_scanline(): scanline=%d xpos=%d\n", scanline, xpos); |
| 1518 | | |
| 1519 | | if ((scanline >= 0) && (scanline < (m6847->top_border_scanlines |
| 1520 | | + m6847->display_scanlines + m6847->bottom_border_scanlines))) |
| 1521 | | { |
| 1522 | | if (m6847->using_custom) |
| 1523 | | { |
| 1524 | | m6847->custom_prepare_scanline(scanline); |
| 1525 | | } |
| 1526 | | else |
| 1527 | | { |
| 1528 | | /* has the border color changed? */ |
| 1529 | | attrs = (*m6847->get_attributes)(machine, 0, 0, 0); |
| 1530 | | if (attrs != m6847->attrs[scanline]) |
| 1531 | | { |
| 1532 | | m6847->dirty = TRUE; |
| 1533 | | m6847->attrs[scanline] = attrs; |
| 1534 | | |
| 1535 | | /* choose the border color */ |
| 1536 | | if (attrs & M6847_AG) |
| 1537 | | border_color = (attrs & M6847_CSS) ? BUFF : GREEN; |
| 1538 | | else if (m6847->has_lowercase && (attrs & M6847_GM2)) |
| 1539 | | border_color = (attrs & M6847_CSS) ? LTORANGE : LTGREEN; |
| 1540 | | else |
| 1541 | | border_color = BLACK; |
| 1542 | | |
| 1543 | | /* need to use palette table directly; border colors are constant */ |
| 1544 | | m6847->border[scanline] = m6847->palette[border_color]; |
| 1545 | | } |
| 1546 | | |
| 1547 | | /* is this a display scanline? */ |
| 1548 | | scanline -= m6847->top_border_scanlines; |
| 1549 | | if ((scanline >= 0) && (scanline < m6847->display_scanlines)) |
| 1550 | | { |
| 1551 | | video_ram = m6847->get_video_ram(machine,scanline); |
| 1552 | | dirty = m6847->dirty; |
| 1553 | | scanline_data = m6847->screendata[scanline]; |
| 1554 | | |
| 1555 | | for (i = xpos; i < 32; i++) |
| 1556 | | { |
| 1557 | | data = video_ram[i]; |
| 1558 | | attr = (*m6847->get_attributes)(machine, data, scanline, i); |
| 1559 | | |
| 1560 | | if ((data != scanline_data[i].data) || (attr != scanline_data[i].attr)) |
| 1561 | | { |
| 1562 | | dirty = TRUE; |
| 1563 | | scanline_data[i].data = data; |
| 1564 | | scanline_data[i].attr = attr; |
| 1565 | | } |
| 1566 | | } |
| 1567 | | m6847->dirty = dirty; |
| 1568 | | } |
| 1569 | | } |
| 1570 | | } |
| 1571 | | } |
| 1572 | | |
| 1573 | | |
| 1574 | | |
| 1575 | | void m6847_video_changed(void) |
| 1576 | | { |
| 1577 | | /* NPW 2-May-2006 - Commenting this out until we properly fix bug #878 */ |
| 1578 | | /* prepare_scanline(get_beamx() / 8); */ |
| 1579 | | } |
| 1580 | | |
| 1581 | | |
| 1582 | | |
| 1583 | | /************************************* |
| 1584 | | * |
| 1585 | | * Sync callbacks |
| 1586 | | * |
| 1587 | | *************************************/ |
| 1588 | | |
| 1589 | | int m6847_get_horizontal_sync(running_machine *machine) |
| 1590 | | { |
| 1591 | | attotime fire_time = timer_firetime(m6847->hs_fall_timer); |
| 1592 | | return attotime_compare(fire_time, timer_get_time(machine)) > 0; |
| 1593 | | } |
| 1594 | | |
| 1595 | | |
| 1596 | | |
| 1597 | | static void set_horizontal_sync(running_machine *machine) |
| 1598 | | { |
| 1599 | | attotime fire_time = timer_firetime(m6847->hs_fall_timer); |
| 1600 | | int horizontal_sync = attotime_compare(fire_time, timer_get_time(machine)) > 0; |
| 1601 | | if (m6847->horizontal_sync_callback) |
| 1602 | | m6847->horizontal_sync_callback(machine, !horizontal_sync); |
| 1603 | | } |
| 1604 | | |
| 1605 | | |
| 1606 | | |
| 1607 | | int m6847_get_field_sync(running_machine *machine) |
| 1608 | | { |
| 1609 | | attotime fire_time = timer_firetime(m6847->fs_fall_timer); |
| 1610 | | return attotime_compare(fire_time, timer_get_time(machine)) > 0; |
| 1611 | | } |
| 1612 | | |
| 1613 | | |
| 1614 | | |
| 1615 | | static void set_field_sync(running_machine *machine) |
| 1616 | | { |
| 1617 | | attotime fire_time = timer_firetime(m6847->fs_fall_timer); |
| 1618 | | int field_sync = attotime_compare(fire_time, timer_get_time(machine)) > 0; |
| 1619 | | if (m6847->field_sync_callback) |
| 1620 | | m6847->field_sync_callback(machine,field_sync); |
| 1621 | | } |
| 1622 | | |
| 1623 | | |
| 1624 | | |
| 1625 | | /************************************* |
| 1626 | | * |
| 1627 | | * Field sync/Horizontal sync timers |
| 1628 | | * |
| 1629 | | *************************************/ |
| 1630 | | |
| 1631 | | static TIMER_CALLBACK(hs_fall) |
| 1632 | | { |
| 1633 | | if (LOG_HS) |
| 1634 | | logerror("hs_fall(): time=%s\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION)); |
| 1635 | | |
| 1636 | | set_horizontal_sync(machine); |
| 1637 | | } |
| 1638 | | |
| 1639 | | static TIMER_CALLBACK(hs_rise) |
| 1640 | | { |
| 1641 | | if (LOG_HS) |
| 1642 | | logerror("hs_rise(): time=%s\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION)); |
| 1643 | | |
| 1644 | | timer_adjust_oneshot(m6847->hs_rise_timer, |
| 1645 | | attotime_make(0, m6847->scanline_period), 0); |
| 1646 | | timer_adjust_oneshot(m6847->hs_fall_timer, |
| 1647 | | attotime_make(0, m6847->horizontal_sync_period), 0); |
| 1648 | | |
| 1649 | | set_horizontal_sync(machine); |
| 1650 | | prepare_scanline(machine,0); |
| 1651 | | } |
| 1652 | | |
| 1653 | | static TIMER_CALLBACK(fs_fall) |
| 1654 | | { |
| 1655 | | if (LOG_FS) |
| 1656 | | logerror("fs_fall(): time=%s scanline=%d\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION), get_scanline()); |
| 1657 | | |
| 1658 | | set_field_sync(machine); |
| 1659 | | } |
| 1660 | | |
| 1661 | | static TIMER_CALLBACK(fs_rise) |
| 1662 | | { |
| 1663 | | if (LOG_FS) |
| 1664 | | logerror("fs_rise(): time=%s scanline=%d\n", attotime_string(timer_get_time(machine), ATTOTIME_STRING_PRECISION), get_scanline()); |
| 1665 | | |
| 1666 | | /* adjust field sync falling edge timer */ |
| 1667 | | timer_adjust_oneshot(m6847->fs_fall_timer, |
| 1668 | | attotime_make(0, m6847->field_sync_period), 0); |
| 1669 | | |
| 1670 | | /* adjust horizontal sync rising timer */ |
| 1671 | | timer_adjust_oneshot(m6847->hs_rise_timer, attotime_zero, 0); |
| 1672 | | |
| 1673 | | /* this is a hook for the CoCo 3 code to extend this stuff */ |
| 1674 | | if (m6847->new_frame_callback) |
| 1675 | | m6847->using_custom = !m6847->new_frame_callback(); |
| 1676 | | |
| 1677 | | set_field_sync(machine); |
| 1678 | | } |
| 1679 | | |
| 1680 | | |
| 1681 | | |
| 1682 | | /************************************* |
| 1683 | | * |
| 1684 | | * Debugging |
| 1685 | | * |
| 1686 | | *************************************/ |
| 1687 | | |
| 1688 | | |
| 1689 | | static void execute_m6847_dumpscanline(running_machine *machine, int ref, int params, const char **param) |
| 1690 | | { |
| 1691 | | int i; |
| 1692 | | int beamx = get_beamx() / 8; |
| 1693 | | int scanline = get_scanline(); |
| 1694 | | const m6847_pixel *pixel = m6847->screendata[scanline]; |
| 1695 | | |
| 1696 | | for (i = 0; i < beamx; i++) |
| 1697 | | { |
| 1698 | | debug_console_printf(machine, "[%02d]: 0x%02X (", i, pixel[i].data); |
| 1699 | | |
| 1700 | | if (pixel[i].attr & M6847_AG) debug_console_printf(machine, " AG"); |
| 1701 | | if (pixel[i].attr & M6847_AS) debug_console_printf(machine, " AS"); |
| 1702 | | if (pixel[i].attr & M6847_INTEXT) debug_console_printf(machine, " INTEXT"); |
| 1703 | | if (pixel[i].attr & M6847_INV) debug_console_printf(machine, " INV"); |
| 1704 | | if (pixel[i].attr & M6847_CSS) debug_console_printf(machine, " CSS"); |
| 1705 | | if (pixel[i].attr & M6847_GM2) debug_console_printf(machine, " GM2"); |
| 1706 | | if (pixel[i].attr & M6847_GM1) debug_console_printf(machine, " GM1"); |
| 1707 | | if (pixel[i].attr & M6847_GM0) debug_console_printf(machine, " GM0"); |
| 1708 | | |
| 1709 | | debug_console_printf(machine, " )\n"); |
| 1710 | | } |
| 1711 | | } |
| 1712 | | |
| 1713 | | |
| 1714 | | |
| 1715 | | |
| 1716 | | /************************************* |
| 1717 | | * |
| 1718 | | * Initialization |
| 1719 | | * |
| 1720 | | *************************************/ |
| 1721 | | |
| 1722 | | static const UINT8 *find_char(const m6847_variant *v, |
| 1723 | | UINT8 byte, UINT8 attr, int *fg, int *bg) |
| 1724 | | { |
| 1725 | | int ch; |
| 1726 | | size_t offset = 0; |
| 1727 | | |
| 1728 | | if (attr & M6847_AS) |
| 1729 | | { |
| 1730 | | /* semigraphics */ |
| 1731 | | *bg = BLACK; |
| 1732 | | |
| 1733 | | if (!v->has_lowercase && (attr & M6847_INTEXT)) |
| 1734 | | { |
| 1735 | | /* semigraphics 6 */ |
| 1736 | | ch = (byte & 0x3F) + 0x60; |
| 1737 | | *fg = ((byte >> 6) & 0x03) + ((attr & M6847_CSS) ? BUFF : GREEN); |
| 1738 | | } |
| 1739 | | else |
| 1740 | | { |
| 1741 | | /* semigraphics 4 */ |
| 1742 | | ch = (byte & 0x0F) + 0xA0; |
| 1743 | | *fg = ((byte >> 4) & 0x07) + GREEN; |
| 1744 | | } |
| 1745 | | } |
| 1746 | | else |
| 1747 | | { |
| 1748 | | /* text */ |
| 1749 | | ch = (byte & 0x3F) + 0x00; |
| 1750 | | |
| 1751 | | if (v->has_lowercase) |
| 1752 | | { |
| 1753 | | if ((ch < 0x20) && (attr & M6847_GM0) && !(attr & M6847_INV)) |
| 1754 | | { |
| 1755 | | /* this is a lowercase character */ |
| 1756 | | attr |= M6847_INV; |
| 1757 | | ch += 0x40; |
| 1758 | | } |
| 1759 | | |
| 1760 | | if ((ch > 0x20) && (attr & M6847_GM0) && !(attr & M6847_INV)) { |
| 1761 | | ch += 0x20; |
| 1762 | | } |
| 1763 | | |
| 1764 | | if (attr & M6847_GM1) |
| 1765 | | attr ^= M6847_INV; |
| 1766 | | |
| 1767 | | } |
| 1768 | | |
| 1769 | | if (attr & M6847_INV) |
| 1770 | | { |
| 1771 | | /* dark foreground, light background */ |
| 1772 | | *fg = (attr & M6847_CSS) ? DKORANGE : DKGREEN; |
| 1773 | | *bg = (attr & M6847_CSS) ? LTORANGE : LTGREEN; |
| 1774 | | } |
| 1775 | | else |
| 1776 | | { |
| 1777 | | /* light foreground, dark background */ |
| 1778 | | *fg = (attr & M6847_CSS) ? LTORANGE : LTGREEN; |
| 1779 | | *bg = (attr & M6847_CSS) ? DKORANGE : DKGREEN; |
| 1780 | | } |
| 1781 | | |
| 1782 | | offset = v->text_offset; |
| 1783 | | } |
| 1784 | | |
| 1785 | | return &v->fontdata[ch * 12] + offset; |
| 1786 | | } |
| 1787 | | |
| 1788 | | |
| 1789 | | |
| 1790 | | static void build_fontdata(const m6847_variant *v) |
| 1791 | | { |
| 1792 | | int attr_index, row; |
| 1793 | | int fg, bg; |
| 1794 | | int byte; |
| 1795 | | const UINT8 *char_data; |
| 1796 | | |
| 1797 | | for (attr_index = 0; attr_index < sizeof(m6847->fontdata) / sizeof(m6847->fontdata[0]); attr_index++) |
| 1798 | | { |
| 1799 | | UINT8 attr = attribute_from_attr_index(attr_index); |
| 1800 | | |
| 1801 | | for (byte = 0; byte < 256; byte++) |
| 1802 | | { |
| 1803 | | char_data = find_char(v, byte, attr, &fg, &bg); |
| 1804 | | |
| 1805 | | /* specify colors */ |
| 1806 | | m6847->colordata[attr_index][byte / 16][0] = bg; |
| 1807 | | m6847->colordata[attr_index][byte / 16][1] = fg; |
| 1808 | | |
| 1809 | | for (row = 0; row < 12; row++) |
| 1810 | | { |
| 1811 | | m6847->fontdata[attr_index][byte][row] = char_data[row]; |
| 1812 | | } |
| 1813 | | } |
| 1814 | | } |
| 1815 | | } |
| 1816 | | |
| 1817 | | |
| 1818 | | |
| 1819 | | static STATE_POSTLOAD( m6847_postload ) |
| 1820 | | { |
| 1821 | | set_field_sync(machine); |
| 1822 | | set_horizontal_sync(machine); |
| 1823 | | set_dirty(); |
| 1824 | | } |
| 1825 | | |
| 1826 | | |
| 1827 | | |
| 1828 | | void m6847_init(running_machine *machine, const m6847_config *cfg) |
| 1829 | | { |
| 1830 | | const m6847_variant *v; |
| 1831 | | UINT32 frequency; |
| 1832 | | attoseconds_t period, frame_period, cpu0_clock_period = 0; |
| 1833 | | double total_scanlines; |
| 1834 | | |
| 1835 | | /* identify proper M6847 variant */ |
| 1836 | | assert(cfg->type < sizeof(variants) / sizeof(variants[0])); |
| 1837 | | v = &variants[cfg->type]; |
| 1838 | | |
| 1839 | | /* allocate instance */ |
| 1840 | | m6847 = auto_alloc_clear(machine, m6847_vdg); |
| 1841 | | set_dirty(); |
| 1842 | | |
| 1843 | | /* copy configuration */ |
| 1844 | | m6847->get_attributes = cfg->get_attributes; |
| 1845 | | m6847->get_video_ram = cfg->get_video_ram; |
| 1846 | | m6847->horizontal_sync_callback = cfg->horizontal_sync_callback; |
| 1847 | | m6847->field_sync_callback = cfg->field_sync_callback; |
| 1848 | | m6847->new_frame_callback = cfg->new_frame_callback; |
| 1849 | | m6847->custom_prepare_scanline = cfg->custom_prepare_scanline; |
| 1850 | | m6847->has_lowercase = v->has_lowercase; |
| 1851 | | m6847->get_char_rom = cfg->get_char_rom; |
| 1852 | | |
| 1853 | | /* assert our assumptions */ |
| 1854 | | assert((v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME) |
| 1855 | | == (UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME)); |
| 1856 | | assert((v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE) |
| 1857 | | == (UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE)); |
| 1858 | | assert((v->scanlines_per_frame * v->clocks_per_scanline * GROSS_FACTOR) |
| 1859 | | == (UINT32) (v->scanlines_per_frame * v->clocks_per_scanline * GROSS_FACTOR)); |
| 1860 | | |
| 1861 | | /* choose palette */ |
| 1862 | | if (cfg->custom_palette) |
| 1863 | | { |
| 1864 | | m6847->has_custom_palette = 1; |
| 1865 | | m6847->palette = cfg->custom_palette; |
| 1866 | | } |
| 1867 | | else |
| 1868 | | { |
| 1869 | | m6847->palette = palette; |
| 1870 | | } |
| 1871 | | |
| 1872 | | /* allocate timers */ |
| 1873 | | m6847->fs_rise_timer = timer_alloc(machine, fs_rise, NULL); |
| 1874 | | m6847->fs_fall_timer = timer_alloc(machine, fs_fall, NULL); |
| 1875 | | m6847->hs_rise_timer = timer_alloc(machine, hs_rise, NULL); |
| 1876 | | m6847->hs_fall_timer = timer_alloc(machine, hs_fall, NULL); |
| 1877 | | |
| 1878 | | /* setup dimensions */ |
| 1879 | | m6847->top_border_scanlines = v->top_border_scanlines; |
| 1880 | | m6847->display_scanlines = v->display_scanlines; |
| 1881 | | m6847->bottom_border_scanlines = v->bottom_border_scanlines; |
| 1882 | | |
| 1883 | | /* compute frequency and period */ |
| 1884 | | frequency = v->frames_per_second |
| 1885 | | * ((UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME)) |
| 1886 | | * ((UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE)); |
| 1887 | | period = ATTOSECONDS_PER_SECOND / frequency; |
| 1888 | | |
| 1889 | | /* choose CPU clock, if specified */ |
| 1890 | | if (cfg->cpu0_timing_factor > 0) |
| 1891 | | { |
| 1892 | | cpu0_clock_period = period * cfg->cpu0_timing_factor * GROSS_FACTOR; |
| 1893 | | cpu_set_clock(machine->firstcpu, ATTOSECONDS_PER_SECOND / cpu0_clock_period); |
| 1894 | | } |
| 1895 | | |
| 1896 | | /* calculate timing */ |
| 1897 | | total_scanlines = v->vblank_scanlines |
| 1898 | | + v->top_border_scanlines |
| 1899 | | + v->display_scanlines |
| 1900 | | + v->bottom_border_scanlines |
| 1901 | | + v->vretrace_scanlines; |
| 1902 | | m6847->clock_period = period * GROSS_FACTOR; |
| 1903 | | m6847->scanline_period = period * (UINT32) (v->clocks_per_scanline * GROSS_FACTOR); |
| 1904 | | m6847->field_sync_period = period * (UINT32) (v->clocks_per_scanline * v->field_sync_scanlines * GROSS_FACTOR); |
| 1905 | | m6847->horizontal_sync_period = period * GROSS_FACTOR * 33 / 2; |
| 1906 | | m6847->vblank_period = period * (UINT32) (v->clocks_per_scanline * v->vblank_scanlines * GROSS_FACTOR); |
| 1907 | | |
| 1908 | | /* setup timing */ |
| 1909 | | frame_period = period * |
| 1910 | | (UINT32) (v->clocks_per_scanline * total_scanlines * GROSS_FACTOR); |
| 1911 | | timer_adjust_periodic(m6847->fs_rise_timer, attotime_zero, 0, attotime_make(0, frame_period)); |
| 1912 | | |
| 1913 | | /* setup save states */ |
| 1914 | | state_save_register_postload(machine, m6847_postload, NULL); |
| 1915 | | |
| 1916 | | /* build font */ |
| 1917 | | build_fontdata(v); |
| 1918 | | |
| 1919 | | /* dump stats */ |
| 1920 | | if (LOG_STATS) |
| 1921 | | { |
| 1922 | | logerror("m6847_init():\n"); |
| 1923 | | logerror("\tclock: %30s sec\n", attotime_string(attotime_make(0, period * GROSS_FACTOR), ATTOTIME_STRING_PRECISION)); |
| 1924 | | if (cpu0_clock_period > 0) |
| 1925 | | logerror("\tCPU0 clock: %30s sec\n", attotime_string(attotime_make(0, cpu0_clock_period), ATTOTIME_STRING_PRECISION)); |
| 1926 | | logerror("\tscanline: %30s sec\n", attotime_string(attotime_make(0, m6847->scanline_period), ATTOTIME_STRING_PRECISION)); |
| 1927 | | logerror("\tfield sync: %30s sec\n", attotime_string(attotime_make(0, m6847->field_sync_period), ATTOTIME_STRING_PRECISION)); |
| 1928 | | logerror("\thorz sync: %30s sec\n", attotime_string(attotime_make(0, m6847->horizontal_sync_period), ATTOTIME_STRING_PRECISION)); |
| 1929 | | logerror("\tvblank: %30s sec\n", attotime_string(attotime_make(0, m6847->vblank_period), ATTOTIME_STRING_PRECISION)); |
| 1930 | | logerror("\tframe: %30s sec\n", attotime_string(attotime_make(0, frame_period), ATTOTIME_STRING_PRECISION)); |
| 1931 | | logerror("\n"); |
| 1932 | | } |
| 1933 | | |
| 1934 | | /* setup debug commands */ |
| 1935 | | if (machine->debug_flags & DEBUG_FLAG_ENABLED) |
| 1936 | | debug_console_register_command(machine, "m6847_dumpscanline", CMDFLAG_NONE, 0, 0, 0, execute_m6847_dumpscanline); |
| 1937 | | } |
| 1938 | | |
| 1939 | | |
| 1940 | | |
| 1941 | | VIDEO_UPDATE(m6847) |
| 1942 | | { |
| 2160 | mc6847_state *mc6847 = get_safe_token(device); |
| 1943 | 2161 | int row, i; |
| 1944 | 2162 | UINT32 rc = 0; |
| 1945 | 2163 | |
| 1946 | 2164 | /* if we have a custom palette, check to see if it has changed */ |
| 1947 | | if (!m6847->dirty && m6847->has_custom_palette) |
| 2165 | if (!mc6847->dirty && mc6847->has_custom_palette) |
| 1948 | 2166 | { |
| 1949 | 2167 | for (i = 0; i < 16; i++) |
| 1950 | 2168 | { |
| 1951 | | if (m6847->palette[i] != m6847->saved_palette[i]) |
| 2169 | if (mc6847->palette[i] != mc6847->saved_palette[i]) |
| 1952 | 2170 | { |
| 1953 | | m6847->dirty = TRUE; |
| 2171 | mc6847->dirty = TRUE; |
| 1954 | 2172 | break; |
| 1955 | 2173 | } |
| 1956 | 2174 | } |
| 1957 | 2175 | } |
| 1958 | 2176 | |
| 1959 | | if (m6847->dirty) |
| 2177 | if (mc6847->dirty) |
| 1960 | 2178 | { |
| 1961 | 2179 | /* this frame is dirty; render it */ |
| 1962 | | m6847->dirty = FALSE; |
| 2180 | mc6847->dirty = FALSE; |
| 1963 | 2181 | |
| 1964 | 2182 | /* copy palette if we have a custom palete */ |
| 1965 | | if (m6847->has_custom_palette) |
| 2183 | if (mc6847->has_custom_palette) |
| 1966 | 2184 | { |
| 1967 | 2185 | for (i = 0; i < 16; i++) |
| 1968 | | m6847->saved_palette[i] = m6847->palette[i]; |
| 2186 | mc6847->saved_palette[i] = mc6847->palette[i]; |
| 1969 | 2187 | } |
| 1970 | 2188 | |
| 1971 | 2189 | /* the video RAM has been dirtied; need to draw */ |
| 1972 | 2190 | for (row = cliprect->min_y; row <= cliprect->max_y; row++) |
| 1973 | | render_scanline(screen->machine, bitmap, row); |
| 2191 | render_scanline(device, bitmap, row); |
| 1974 | 2192 | } |
| 1975 | 2193 | else |
| 1976 | 2194 | { |
| r5922 | r5923 | |
| 1998 | 2216 | |
| 1999 | 2217 | |
| 2000 | 2218 | |
| 2001 | | static attotime interval(m6847_timing_type timing) |
| 2219 | static attotime interval(const device_config *device, m6847_timing_type timing) |
| 2002 | 2220 | { |
| 2221 | mc6847_state *mc6847 = get_safe_token(device); |
| 2003 | 2222 | attotime result; |
| 2004 | 2223 | |
| 2005 | 2224 | switch(timing) |
| 2006 | 2225 | { |
| 2007 | 2226 | case M6847_CLOCK: |
| 2008 | | result = attotime_make(0, m6847->clock_period); |
| 2227 | result = attotime_make(0, mc6847->clock_period); |
| 2009 | 2228 | break; |
| 2010 | 2229 | case M6847_HSYNC: |
| 2011 | | result = attotime_make(0, m6847->scanline_period); |
| 2230 | result = attotime_make(0, mc6847->scanline_period); |
| 2012 | 2231 | break; |
| 2013 | 2232 | default: |
| 2014 | 2233 | fatalerror("invalid timing type"); |
| r5922 | r5923 | |
| 2019 | 2238 | |
| 2020 | 2239 | |
| 2021 | 2240 | |
| 2022 | | UINT64 m6847_time(running_machine *machine, m6847_timing_type timing) |
| 2241 | UINT64 m6847_time(const device_config *device, m6847_timing_type timing) |
| 2023 | 2242 | { |
| 2024 | | attotime current_time = timer_get_time(machine); |
| 2025 | | attotime divisor = interval(timing); |
| 2243 | attotime current_time = timer_get_time(device->machine); |
| 2244 | attotime divisor = interval(device, timing); |
| 2026 | 2245 | return divide_mame_time(current_time, divisor); |
| 2027 | 2246 | } |
| 2028 | 2247 | |
| 2029 | 2248 | |
| 2030 | 2249 | |
| 2031 | | attotime m6847_time_until(running_machine *machine, m6847_timing_type timing, UINT64 target_time) |
| 2250 | attotime m6847_time_until(const device_config *device, m6847_timing_type timing, UINT64 target_time) |
| 2032 | 2251 | { |
| 2033 | 2252 | attotime target_mame_time, current_time; |
| 2034 | | target_mame_time = attotime_mul(interval(timing), target_time); |
| 2035 | | current_time = timer_get_time(machine); |
| 2253 | target_mame_time = attotime_mul(interval(device, timing), target_time); |
| 2254 | current_time = timer_get_time(device->machine); |
| 2036 | 2255 | |
| 2037 | 2256 | if (attotime_compare(target_mame_time, current_time) < 0) |
| 2038 | 2257 | fatalerror("m6847_time_until(): cannot target past times"); |
| r5922 | r5923 | |
| 2042 | 2261 | |
| 2043 | 2262 | |
| 2044 | 2263 | |
| 2045 | | attotime m6847_scanline_time(int scanline) |
| 2264 | attotime m6847_scanline_time(const device_config *device, int scanline) |
| 2046 | 2265 | { |
| 2047 | | return attotime_make(0, m6847->scanline_period * |
| 2266 | mc6847_state *mc6847 = get_safe_token(device); |
| 2267 | |
| 2268 | return attotime_make(0, mc6847->scanline_period * |
| 2048 | 2269 | (13 /* FIXME */ + scanline)); |
| 2049 | 2270 | } |
| 2050 | 2271 | |
| r5922 | r5923 | |
| 2060 | 2281 | void m6847_set_dirty(void) { set_dirty(); } |
| 2061 | 2282 | int m6847_get_scanline(void) { return get_scanline(); } |
| 2062 | 2283 | #endif |
| 2284 | |
| 2285 | int mc6847_get_scanline(const device_config *device) |
| 2286 | { |
| 2287 | mc6847_state *mc6847 = get_safe_token(device); |
| 2288 | return get_scanline(mc6847) - mc6847->top_border_scanlines; |
| 2289 | } |
src/mess/drivers/coco.c
| r5922 | r5923 | |
| 541 | 541 | PORT_CONFSETTING( 0x00, "Disto" ) |
| 542 | 542 | PORT_CONFSETTING( 0x01, "Cloud-9" ) |
| 543 | 543 | |
| 544 | | /* Port Condition is used because you can plug Hi-Res joystick, |
| 544 | /* Port Condition is used because you can plug Hi-Res joystick, |
| 545 | 545 | Rat Mouse and Lightgun in either ports, but not both */ |
| 546 | 546 | /* Fix me: should Rat Mouse and Diecom Light Gun be available also for coco & coco2? */ |
| 547 | 547 | PORT_START("ctrl_sel") /* Select Controller Type */ |
| r5922 | r5923 | |
| 660 | 660 | PORT_CONFSETTING( 0x00, "Disto" ) |
| 661 | 661 | PORT_CONFSETTING( 0x01, "Cloud-9" ) |
| 662 | 662 | |
| 663 | | /* Port Condition is used because you can plug Hi-Res joystick, |
| 663 | /* Port Condition is used because you can plug Hi-Res joystick, |
| 664 | 664 | Rat Mouse and Lightgun in either ports, but not both */ |
| 665 | 665 | /* Fix me: should Rat Mouse and Diecom Light Gun be available also for coco & coco2? */ |
| 666 | 666 | PORT_START("ctrl_sel") /* Select Controller Type */ |
| r5922 | r5923 | |
| 771 | 771 | DO_NOT_KEEP_GEOMETRY |
| 772 | 772 | }; |
| 773 | 773 | |
| 774 | static const mc6847_interface coco_mc6847_intf = |
| 775 | { |
| 776 | DEVCB_HANDLER(coco_mc6847_videoram_r), |
| 777 | DEVCB_NULL, |
| 778 | DEVCB_NULL, |
| 779 | DEVCB_NULL, |
| 780 | DEVCB_NULL, |
| 781 | DEVCB_NULL, |
| 782 | DEVCB_NULL, |
| 783 | DEVCB_NULL, |
| 784 | DEVCB_NULL, |
| 785 | DEVCB_DEVICE_HANDLER("pia_0", pia6821_cb1_w), |
| 786 | DEVCB_DEVICE_HANDLER("pia_0", pia6821_ca1_w), |
| 787 | DEVCB_NULL |
| 788 | }; |
| 789 | |
| 790 | static const mc6847_interface coco3_mc6847_intf = |
| 791 | { |
| 792 | DEVCB_HANDLER(coco3_mc6847_videoram_r), |
| 793 | DEVCB_NULL, |
| 794 | DEVCB_NULL, |
| 795 | DEVCB_NULL, |
| 796 | DEVCB_NULL, |
| 797 | DEVCB_NULL, |
| 798 | DEVCB_NULL, |
| 799 | DEVCB_NULL, |
| 800 | DEVCB_NULL, |
| 801 | DEVCB_LINE(coco3_fs_w), |
| 802 | DEVCB_LINE(coco3_hs_w), |
| 803 | DEVCB_NULL |
| 804 | }; |
| 805 | |
| 774 | 806 | static MACHINE_DRIVER_START( dragon32 ) |
| 775 | 807 | /* basic machine hardware */ |
| 776 | 808 | MDRV_CPU_ADD("maincpu", M6809E, COCO_CPU_SPEED_HZ * 4) /* 0,894886 MHz */ |
| r5922 | r5923 | |
| 782 | 814 | MDRV_DRIVER_DATA( coco_state ) |
| 783 | 815 | |
| 784 | 816 | /* video hardware */ |
| 785 | | MDRV_VIDEO_START(dragon) |
| 786 | | MDRV_VIDEO_UPDATE(m6847) |
| 787 | 817 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 788 | 818 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 789 | 819 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 790 | 820 | |
| 821 | MDRV_VIDEO_UPDATE(coco) |
| 822 | |
| 823 | MDRV_MC6847_ADD("mc6847", coco_mc6847_intf) |
| 824 | MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL) |
| 825 | |
| 791 | 826 | /* sound hardware */ |
| 792 | 827 | MDRV_IMPORT_FROM( coco_sound ) |
| 793 | 828 | |
| r5922 | r5923 | |
| 798 | 833 | MDRV_SNAPSHOT_ADD("snapshot", coco_pak, "pak", 0) |
| 799 | 834 | |
| 800 | 835 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 801 | | |
| 836 | |
| 802 | 837 | MDRV_PIA6821_ADD( "pia_0", dragon32_pia_intf_0 ) |
| 803 | 838 | MDRV_PIA6821_ADD( "pia_1", dragon32_pia_intf_1 ) |
| 804 | 839 | |
| 805 | 840 | MDRV_SAM6883_ADD("sam", coco_sam_intf) |
| 806 | | |
| 841 | |
| 807 | 842 | MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot") |
| 808 | 843 | MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w) |
| 809 | 844 | MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 810 | 845 | MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 811 | | |
| 846 | |
| 812 | 847 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 813 | 848 | MACHINE_DRIVER_END |
| 814 | 849 | |
| r5922 | r5923 | |
| 821 | 856 | MDRV_DRIVER_DATA( coco_state ) |
| 822 | 857 | |
| 823 | 858 | /* video hardware */ |
| 824 | | MDRV_VIDEO_START(dragon) |
| 825 | | MDRV_VIDEO_UPDATE(m6847) |
| 826 | 859 | MDRV_SCREEN_ADD("screen", RASTER) |
| 827 | 860 | MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND) |
| 828 | 861 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 829 | 862 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 830 | 863 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 831 | 864 | |
| 865 | MDRV_VIDEO_UPDATE(coco) |
| 866 | |
| 867 | MDRV_MC6847_ADD("mc6847", coco_mc6847_intf) |
| 868 | MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL) |
| 869 | |
| 832 | 870 | /* sound hardware */ |
| 833 | 871 | MDRV_IMPORT_FROM( coco_sound ) |
| 834 | 872 | |
| r5922 | r5923 | |
| 843 | 881 | |
| 844 | 882 | /* acia */ |
| 845 | 883 | MDRV_ACIA6551_ADD("acia") |
| 846 | | |
| 884 | |
| 847 | 885 | MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf_0 ) |
| 848 | 886 | MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf_1 ) |
| 849 | 887 | |
| 850 | 888 | MDRV_SAM6883_ADD("sam", coco_sam_intf) |
| 851 | | |
| 889 | |
| 852 | 890 | MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot") |
| 853 | 891 | MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w) |
| 854 | 892 | MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 855 | 893 | MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 856 | | |
| 894 | |
| 857 | 895 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 858 | 896 | MACHINE_DRIVER_END |
| 859 | 897 | |
| r5922 | r5923 | |
| 866 | 904 | MDRV_DRIVER_DATA( coco_state ) |
| 867 | 905 | |
| 868 | 906 | /* video hardware */ |
| 869 | | MDRV_VIDEO_START(dragon) |
| 870 | | MDRV_VIDEO_UPDATE(m6847) |
| 871 | 907 | MDRV_SCREEN_ADD("screen", RASTER) |
| 872 | 908 | MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND) |
| 873 | 909 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 874 | 910 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 875 | 911 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 876 | 912 | |
| 913 | MDRV_VIDEO_UPDATE(coco) |
| 914 | |
| 915 | MDRV_MC6847_ADD("mc6847", coco_mc6847_intf) |
| 916 | MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL) |
| 917 | |
| 877 | 918 | /* sound hardware */ |
| 878 | 919 | MDRV_IMPORT_FROM( coco_sound ) |
| 879 | 920 | |
| r5922 | r5923 | |
| 888 | 929 | |
| 889 | 930 | /* acia */ |
| 890 | 931 | MDRV_ACIA6551_ADD("acia") |
| 891 | | |
| 932 | |
| 892 | 933 | MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf_0 ) |
| 893 | 934 | MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf_1 ) |
| 894 | 935 | |
| 895 | 936 | MDRV_SAM6883_ADD("sam", coco_sam_intf) |
| 896 | | |
| 937 | |
| 897 | 938 | MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot") |
| 898 | 939 | MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w) |
| 899 | 940 | MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 900 | 941 | MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 901 | | |
| 942 | |
| 902 | 943 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 903 | 944 | MACHINE_DRIVER_END |
| 904 | 945 | |
| r5922 | r5923 | |
| 911 | 952 | MDRV_DRIVER_DATA( coco_state ) |
| 912 | 953 | |
| 913 | 954 | /* video hardware */ |
| 914 | | MDRV_VIDEO_START(dragon) |
| 915 | | MDRV_VIDEO_UPDATE(m6847) |
| 916 | 955 | MDRV_SCREEN_ADD("screen", RASTER) |
| 917 | 956 | MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND) |
| 918 | 957 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 919 | 958 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 920 | 959 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 921 | 960 | |
| 961 | MDRV_VIDEO_UPDATE(coco) |
| 962 | |
| 963 | MDRV_MC6847_ADD("mc6847", coco_mc6847_intf) |
| 964 | MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL) |
| 965 | |
| 922 | 966 | /* sound hardware */ |
| 923 | 967 | MDRV_IMPORT_FROM( coco_sound ) |
| 924 | 968 | MDRV_SOUND_ADD("ay8912", AY8912, 1000000) |
| r5922 | r5923 | |
| 939 | 983 | |
| 940 | 984 | /* acia */ |
| 941 | 985 | MDRV_ACIA6551_ADD("acia") |
| 942 | | |
| 986 | |
| 943 | 987 | MDRV_PIA6821_ADD( "pia_0", dgnalpha_pia_intf_0 ) |
| 944 | 988 | MDRV_PIA6821_ADD( "pia_1", dgnalpha_pia_intf_1 ) |
| 945 | 989 | MDRV_PIA6821_ADD( "pia_2", dgnalpha_pia_intf_2 ) |
| 946 | 990 | |
| 947 | 991 | MDRV_SAM6883_ADD("sam", coco_sam_intf) |
| 948 | | |
| 992 | |
| 949 | 993 | MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot") |
| 950 | 994 | MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w) |
| 951 | 995 | MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 952 | 996 | MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 953 | | |
| 997 | |
| 954 | 998 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 955 | 999 | MACHINE_DRIVER_END |
| 956 | 1000 | |
| r5922 | r5923 | |
| 963 | 1007 | MDRV_DRIVER_DATA( coco_state ) |
| 964 | 1008 | |
| 965 | 1009 | /* video hardware */ |
| 966 | | MDRV_VIDEO_START(dragon) |
| 967 | | MDRV_VIDEO_UPDATE(m6847) |
| 968 | 1010 | MDRV_SCREEN_ADD("screen", RASTER) |
| 969 | 1011 | MDRV_SCREEN_REFRESH_RATE(COCO_FRAMES_PER_SECOND) /* Tano Dragon 64 is NTSC */ |
| 970 | 1012 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 971 | 1013 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 972 | 1014 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 973 | 1015 | |
| 1016 | MDRV_VIDEO_UPDATE(coco) |
| 1017 | |
| 1018 | MDRV_MC6847_ADD("mc6847", coco_mc6847_intf) |
| 1019 | MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_PAL) |
| 1020 | |
| 974 | 1021 | /* sound hardware */ |
| 975 | 1022 | MDRV_IMPORT_FROM( coco_sound ) |
| 976 | 1023 | |
| r5922 | r5923 | |
| 985 | 1032 | |
| 986 | 1033 | /* acia */ |
| 987 | 1034 | MDRV_ACIA6551_ADD("acia") |
| 988 | | |
| 1035 | |
| 989 | 1036 | MDRV_PIA6821_ADD( "pia_0", dragon64_pia_intf_0 ) |
| 990 | 1037 | MDRV_PIA6821_ADD( "pia_1", dragon64_pia_intf_1 ) |
| 991 | 1038 | |
| 992 | 1039 | MDRV_SAM6883_ADD("sam", coco_sam_intf) |
| 993 | | |
| 1040 | |
| 994 | 1041 | MDRV_DRAGON_CARTRIDGE_ADD("coco_cartslot") |
| 995 | 1042 | MDRV_DRAGON_CARTRIDGE_CART_CALLBACK(coco_cart_w) |
| 996 | 1043 | MDRV_DRAGON_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 997 | 1044 | MDRV_DRAGON_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 998 | | |
| 1045 | |
| 999 | 1046 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 1000 | 1047 | MACHINE_DRIVER_END |
| 1001 | 1048 | |
| r5922 | r5923 | |
| 1010 | 1057 | /* video hardware */ |
| 1011 | 1058 | MDRV_SCREEN_ADD("screen", RASTER) |
| 1012 | 1059 | MDRV_SCREEN_REFRESH_RATE(M6847_NTSC_FRAMES_PER_SECOND) |
| 1013 | | MDRV_VIDEO_START(coco) |
| 1014 | | MDRV_VIDEO_UPDATE(m6847) |
| 1015 | 1060 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 1016 | 1061 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 1017 | 1062 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 1018 | 1063 | |
| 1064 | MDRV_VIDEO_UPDATE(coco) |
| 1065 | |
| 1066 | MDRV_MC6847_ADD("mc6847", coco_mc6847_intf) |
| 1067 | MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_NTSC) |
| 1068 | MDRV_MC6847_TIMING_FACTOR(4) |
| 1069 | |
| 1019 | 1070 | /* sound hardware */ |
| 1020 | 1071 | MDRV_IMPORT_FROM( coco_sound ) |
| 1021 | 1072 | |
| r5922 | r5923 | |
| 1028 | 1079 | |
| 1029 | 1080 | /* cassette */ |
| 1030 | 1081 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 1031 | | |
| 1082 | |
| 1032 | 1083 | MDRV_PIA6821_ADD( "pia_0", coco_pia_intf_0 ) |
| 1033 | 1084 | MDRV_PIA6821_ADD( "pia_1", coco_pia_intf_1 ) |
| 1034 | 1085 | |
| 1035 | 1086 | MDRV_SAM6883_ADD("sam", coco_sam_intf) |
| 1036 | | |
| 1087 | |
| 1037 | 1088 | MDRV_COCO_CARTRIDGE_ADD("coco_cartslot") |
| 1038 | 1089 | MDRV_COCO_CARTRIDGE_CART_CALLBACK(coco_cart_w) |
| 1039 | 1090 | MDRV_COCO_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 1040 | 1091 | MDRV_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 1041 | | |
| 1092 | |
| 1042 | 1093 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 1043 | 1094 | MACHINE_DRIVER_END |
| 1044 | 1095 | |
| r5922 | r5923 | |
| 1056 | 1107 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 1057 | 1108 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 1058 | 1109 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 1059 | | MDRV_VIDEO_START(coco) |
| 1060 | | MDRV_VIDEO_UPDATE(m6847) |
| 1061 | 1110 | |
| 1111 | MDRV_VIDEO_UPDATE(coco) |
| 1112 | |
| 1113 | MDRV_MC6847_ADD("mc6847", coco_mc6847_intf) |
| 1114 | MDRV_MC6847_TYPE(M6847_VERSION_ORIGINAL_NTSC) |
| 1115 | MDRV_MC6847_TIMING_FACTOR(4) |
| 1116 | |
| 1062 | 1117 | /* sound hardware */ |
| 1063 | 1118 | MDRV_IMPORT_FROM( coco_sound ) |
| 1064 | 1119 | |
| r5922 | r5923 | |
| 1071 | 1126 | |
| 1072 | 1127 | /* cassette */ |
| 1073 | 1128 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 1074 | | |
| 1129 | |
| 1075 | 1130 | MDRV_PIA6821_ADD( "pia_0", coco2_pia_intf_0 ) |
| 1076 | 1131 | MDRV_PIA6821_ADD( "pia_1", coco2_pia_intf_1 ) |
| 1077 | 1132 | |
| 1078 | 1133 | MDRV_SAM6883_ADD("sam", coco_sam_intf) |
| 1079 | | |
| 1134 | |
| 1080 | 1135 | MDRV_COCO_CARTRIDGE_ADD("coco_cartslot") |
| 1081 | 1136 | MDRV_COCO_CARTRIDGE_CART_CALLBACK(coco_cart_w) |
| 1082 | 1137 | MDRV_COCO_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 1083 | 1138 | MDRV_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 1084 | | |
| 1139 | |
| 1085 | 1140 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 1086 | 1141 | MACHINE_DRIVER_END |
| 1087 | 1142 | |
| r5922 | r5923 | |
| 1099 | 1154 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| 1100 | 1155 | MDRV_SCREEN_SIZE(320, 25+192+26) |
| 1101 | 1156 | MDRV_SCREEN_VISIBLE_AREA(0, 319, 1, 239) |
| 1102 | | MDRV_VIDEO_START(coco2b) |
| 1103 | | MDRV_VIDEO_UPDATE(m6847) |
| 1104 | 1157 | |
| 1158 | MDRV_VIDEO_UPDATE(coco) |
| 1159 | |
| 1160 | MDRV_MC6847_ADD("mc6847", coco_mc6847_intf) |
| 1161 | MDRV_MC6847_TYPE(M6847_VERSION_M6847T1_NTSC) |
| 1162 | MDRV_MC6847_TIMING_FACTOR(4) |
| 1163 | |
| 1105 | 1164 | /* sound hardware */ |
| 1106 | 1165 | MDRV_IMPORT_FROM( coco_sound ) |
| 1107 | 1166 | |
| r5922 | r5923 | |
| 1114 | 1173 | |
| 1115 | 1174 | /* cassette */ |
| 1116 | 1175 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 1117 | | |
| 1176 | |
| 1118 | 1177 | MDRV_PIA6821_ADD( "pia_0", coco2_pia_intf_0 ) |
| 1119 | 1178 | MDRV_PIA6821_ADD( "pia_1", coco2_pia_intf_1 ) |
| 1120 | 1179 | |
| 1121 | 1180 | MDRV_SAM6883_ADD("sam", coco_sam_intf) |
| 1122 | | |
| 1181 | |
| 1123 | 1182 | MDRV_COCO_CARTRIDGE_ADD("coco_cartslot") |
| 1124 | 1183 | MDRV_COCO_CARTRIDGE_CART_CALLBACK(coco_cart_w) |
| 1125 | 1184 | MDRV_COCO_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 1126 | 1185 | MDRV_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 1127 | | |
| 1186 | |
| 1128 | 1187 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 1129 | 1188 | MACHINE_DRIVER_END |
| 1130 | 1189 | |
| r5922 | r5923 | |
| 1154 | 1213 | MDRV_SCREEN_SIZE(640, 25+192+26) |
| 1155 | 1214 | MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 239) |
| 1156 | 1215 | |
| 1216 | MDRV_MC6847_ADD("mc6847", coco3_mc6847_intf) |
| 1217 | MDRV_MC6847_TYPE(M6847_VERSION_GIME_NTSC) |
| 1218 | MDRV_MC6847_TIMING_FACTOR(4) |
| 1219 | MDRV_MC6847_FRAME_CALLBACK(coco3_new_frame) |
| 1220 | MDRV_MC6847_PREPARE_SCANLINE(coco3_prepare_scanline) |
| 1221 | |
| 1157 | 1222 | MDRV_PIA6821_ADD( "pia_0", coco3_pia_intf_0 ) |
| 1158 | 1223 | MDRV_PIA6821_ADD( "pia_1", coco3_pia_intf_1 ) |
| 1159 | 1224 | |
| r5922 | r5923 | |
| 1172 | 1237 | |
| 1173 | 1238 | /* cassette */ |
| 1174 | 1239 | MDRV_CASSETTE_ADD( "cassette", coco_cassette_config ) |
| 1175 | | |
| 1240 | |
| 1176 | 1241 | MDRV_SAM6883_GIME_ADD("sam", coco3_sam_intf) |
| 1177 | | |
| 1242 | |
| 1178 | 1243 | MDRV_COCO_CARTRIDGE_ADD("coco_cartslot") |
| 1179 | 1244 | MDRV_COCO_CARTRIDGE_CART_CALLBACK(coco3_cart_w) |
| 1180 | 1245 | MDRV_COCO_CARTRIDGE_HALT_CALLBACK(coco_halt_w) |
| 1181 | 1246 | MDRV_COCO_CARTRIDGE_NMI_CALLBACK(coco_nmi_w) |
| 1182 | | |
| 1247 | |
| 1183 | 1248 | MDRV_FLOPPY_4_DRIVES_ADD(coco_floppy_config) |
| 1184 | 1249 | MACHINE_DRIVER_END |
| 1185 | 1250 | |
| r5922 | r5923 | |
| 1187 | 1252 | MDRV_IMPORT_FROM( coco3 ) |
| 1188 | 1253 | |
| 1189 | 1254 | /* video hardware */ |
| 1190 | | MDRV_VIDEO_START(coco3p) |
| 1191 | | MDRV_VIDEO_UPDATE(coco3) |
| 1192 | 1255 | MDRV_SCREEN_MODIFY("composite") |
| 1193 | 1256 | MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND) |
| 1194 | 1257 | MDRV_SCREEN_MODIFY("rgb") |
| 1195 | 1258 | MDRV_SCREEN_REFRESH_RATE(M6847_PAL_FRAMES_PER_SECOND) |
| 1259 | |
| 1260 | MDRV_DEVICE_MODIFY("mc6847") |
| 1261 | MDRV_MC6847_TYPE(M6847_VERSION_GIME_PAL) |
| 1196 | 1262 | MACHINE_DRIVER_END |
| 1197 | 1263 | |
| 1198 | 1264 | static MACHINE_DRIVER_START( coco3h ) |
| r5922 | r5923 | |
| 1384 | 1450 | CONFIG_RAM_DEFAULT (64 * 1024) |
| 1385 | 1451 | SYSTEM_CONFIG_END |
| 1386 | 1452 | |
| 1387 | | static SYSTEM_CONFIG_START(dgnalpha) |
| 1453 | static SYSTEM_CONFIG_START(dgnalpha) |
| 1388 | 1454 | CONFIG_RAM_DEFAULT (64 * 1024) |
| 1389 | 1455 | SYSTEM_CONFIG_END |
| 1390 | 1456 | |