src/mess/video/sed1330.c
| r4846 | r4847 | |
| 11 | 11 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | | - pc8500 writes data expecting the CSRDIR to be +1 or +AP but does not set it |
| 15 | 14 | - reset behavior |
| 16 | 15 | - busy flag timing |
| 17 | 16 | - cursor flashing |
| 17 | - display page flashing |
| 18 | 18 | - internal chargen ROM |
| 19 | - horizontal dot scroll |
| 19 | 20 | - XOR/AND/Priority-OR compositions |
| 20 | 21 | - text mode character display |
| 21 | 22 | - single panel text mode |
| r4846 | r4847 | |
| 30 | 31 | PARAMETERS |
| 31 | 32 | ***************************************************************************/ |
| 32 | 33 | |
| 33 | | #define LOG |
| 34 | #define LOG 1 |
| 34 | 35 | |
| 35 | 36 | #define SED1330_INSTRUCTION_SYSTEM_SET 0x40 |
| 36 | 37 | #define SED1330_INSTRUCTION_SLEEP_IN 0x53 /* unimplemented */ |
| r4846 | r4847 | |
| 52 | 53 | |
| 53 | 54 | #define SED1330_CSRDIR_RIGHT 0x00 |
| 54 | 55 | #define SED1330_CSRDIR_LEFT 0x01 |
| 55 | | #define SED1330_CSRDIR_UP 0x10 |
| 56 | | #define SED1330_CSRDIR_DOWN 0x11 |
| 56 | #define SED1330_CSRDIR_UP 0x02 |
| 57 | #define SED1330_CSRDIR_DOWN 0x03 |
| 57 | 58 | |
| 58 | 59 | #define SED1330_MX_OR 0x00 |
| 59 | 60 | #define SED1330_MX_XOR 0x01 /* unimplemented */ |
| 60 | | #define SED1330_MX_AND 0x10 /* unimplemented */ |
| 61 | | #define SED1330_MX_PRIORITY_OR 0x11 /* unimplemented */ |
| 61 | #define SED1330_MX_AND 0x02 /* unimplemented */ |
| 62 | #define SED1330_MX_PRIORITY_OR 0x03 /* unimplemented */ |
| 62 | 63 | |
| 63 | 64 | #define SED1330_FC_OFF 0x00 /* unimplemented */ |
| 64 | | #define SED1330_FC_NO_FLASH 0x01 /* unimplemented */ |
| 65 | | #define SED1330_FC_FLASH_32 0x10 /* unimplemented */ |
| 66 | | #define SED1330_FC_FLASH_16 0x11 /* unimplemented */ |
| 65 | #define SED1330_FC_SOLID 0x01 /* unimplemented */ |
| 66 | #define SED1330_FC_FLASH_32 0x02 /* unimplemented */ |
| 67 | #define SED1330_FC_FLASH_64 0x03 /* unimplemented */ |
| 67 | 68 | |
| 68 | 69 | /*************************************************************************** |
| 69 | 70 | TYPE DEFINITIONS |
| r4846 | r4847 | |
| 75 | 76 | devcb_resolved_read8 in_vd_func; |
| 76 | 77 | devcb_resolved_write8 out_vd_func; |
| 77 | 78 | |
| 78 | | /* registers */ |
| 79 | 79 | int bf; /* busy flag */ |
| 80 | |
| 80 | 81 | UINT8 ir; /* instruction register */ |
| 81 | 82 | UINT8 dor; /* data output register */ |
| 82 | 83 | int pbc; /* parameter byte counter */ |
| r4846 | r4847 | |
| 106 | 107 | int sl1; /* display block 1 height in lines */ |
| 107 | 108 | int sl2; /* display block 2 height in lines */ |
| 108 | 109 | int hdotscr; /* horizontal dot scroll in pixels */ |
| 110 | int fp; /* display page flash control */ |
| 109 | 111 | |
| 110 | 112 | UINT16 csr; /* cursor address register */ |
| 111 | 113 | int cd; /* cursor increment direction */ |
| r4846 | r4847 | |
| 113 | 115 | int cry; /* cursor height or location */ |
| 114 | 116 | int cm; /* cursor shape (0=underscore, 1=block) */ |
| 115 | 117 | int fc; /* cursor flash control */ |
| 116 | | int fp; /* cursor flash control */ |
| 117 | 118 | |
| 118 | 119 | int mx; /* screen layer composition method */ |
| 119 | | int dm; /* display mode for screen blocks 1, 3 */ |
| 120 | int dm; /* display mode for pages 1, 3 */ |
| 120 | 121 | int ov; /* graphics mode layer composition */ |
| 121 | 122 | |
| 122 | 123 | /* devices */ |
| 123 | 124 | const device_config *screen; |
| 124 | | |
| 125 | | /* timers */ |
| 126 | | emu_timer *busy_timer; |
| 127 | 125 | }; |
| 128 | 126 | |
| 129 | 127 | /*************************************************************************** |
| r4846 | r4847 | |
| 171 | 169 | ***************************************************************************/ |
| 172 | 170 | |
| 173 | 171 | /*------------------------------------------------- |
| 174 | | TIMER_CALLBACK( busy_tick ) |
| 175 | | -------------------------------------------------*/ |
| 176 | | |
| 177 | | static TIMER_CALLBACK( busy_tick ) |
| 178 | | { |
| 179 | | const device_config *device = ptr; |
| 180 | | sed1330_t *sed1330 = get_safe_token(device); |
| 181 | | |
| 182 | | /* clear busy flag */ |
| 183 | | sed1330->bf = 0; |
| 184 | | } |
| 185 | | |
| 186 | | /*------------------------------------------------- |
| 187 | | set_busy_flag - set busy flag and arm timer |
| 188 | | to clear it later |
| 189 | | -------------------------------------------------*/ |
| 190 | | #ifdef UNUSED_FUNCTION |
| 191 | | static void set_busy_flag(sed1330_t *sed1330, int period) |
| 192 | | { |
| 193 | | /* set busy flag */ |
| 194 | | sed1330->bf = 1; |
| 195 | | |
| 196 | | /* adjust busy timer */ |
| 197 | | timer_adjust_oneshot(sed1330->busy_timer, ATTOTIME_IN_USEC(period), 0); |
| 198 | | } |
| 199 | | #endif |
| 200 | | /*------------------------------------------------- |
| 201 | 172 | sed1330_status_r - status read |
| 202 | 173 | -------------------------------------------------*/ |
| 203 | 174 | |
| r4846 | r4847 | |
| 220 | 191 | |
| 221 | 192 | sed1330->ir = data; |
| 222 | 193 | sed1330->pbc = 0; |
| 194 | |
| 195 | switch (sed1330->ir) |
| 196 | { |
| 197 | /* |
| 198 | case SED1330_INSTRUCTION_SLEEP_IN: |
| 199 | break; |
| 200 | */ |
| 201 | case SED1330_INSTRUCTION_CSRDIR_RIGHT: |
| 202 | case SED1330_INSTRUCTION_CSRDIR_LEFT: |
| 203 | case SED1330_INSTRUCTION_CSRDIR_UP: |
| 204 | case SED1330_INSTRUCTION_CSRDIR_DOWN: |
| 205 | sed1330->cd = data & 0x03; |
| 206 | |
| 207 | if (LOG) |
| 208 | { |
| 209 | switch (sed1330->cd) |
| 210 | { |
| 211 | case SED1330_CSRDIR_RIGHT: logerror("SED1330 '%s' Cursor Direction: Right\n", device->tag); break; |
| 212 | case SED1330_CSRDIR_LEFT: logerror("SED1330 '%s' Cursor Direction: Left\n", device->tag); break; |
| 213 | case SED1330_CSRDIR_UP: logerror("SED1330 '%s' Cursor Direction: Up\n", device->tag); break; |
| 214 | case SED1330_CSRDIR_DOWN: logerror("SED1330 '%s' Cursor Direction: Down\n", device->tag); break; |
| 215 | } |
| 216 | } |
| 217 | break; |
| 218 | } |
| 223 | 219 | } |
| 224 | 220 | |
| 225 | 221 | /*------------------------------------------------- |
| r4846 | r4847 | |
| 315 | 311 | logerror("SED1330 '%s' Invalid parameter byte %02x\n", device->tag, data); |
| 316 | 312 | } |
| 317 | 313 | break; |
| 318 | | /* |
| 319 | | case SED1330_INSTRUCTION_SLEEP_IN: |
| 320 | | break; |
| 321 | | */ |
| 314 | |
| 322 | 315 | case SED1330_INSTRUCTION_DISP_ON: |
| 323 | 316 | case SED1330_INSTRUCTION_DISP_OFF: |
| 324 | 317 | sed1330->d = BIT(data, 0); |
| r4846 | r4847 | |
| 327 | 320 | if (LOG) |
| 328 | 321 | { |
| 329 | 322 | logerror("SED1330 '%s' Display: %s\n", device->tag, BIT(data, 0) ? "enabled" : "disabled"); |
| 323 | |
| 324 | switch (sed1330->fc) |
| 325 | { |
| 326 | case SED1330_FC_OFF: logerror("SED1330 '%s' Cursor: disabled\n", device->tag); break; |
| 327 | case SED1330_FC_SOLID: logerror("SED1330 '%s' Cursor: solid\n", device->tag); break; |
| 328 | case SED1330_FC_FLASH_32: logerror("SED1330 '%s' Cursor: fFR/32\n", device->tag); break; |
| 329 | case SED1330_FC_FLASH_64: logerror("SED1330 '%s' Cursor: fFR/64\n", device->tag); break; |
| 330 | } |
| 331 | |
| 332 | switch (sed1330->fp & 0x03) |
| 333 | { |
| 334 | case SED1330_FC_OFF: logerror("SED1330 '%s' Display Page 1: disabled\n", device->tag); break; |
| 335 | case SED1330_FC_SOLID: logerror("SED1330 '%s' Display Page 1: enabled\n", device->tag); break; |
| 336 | case SED1330_FC_FLASH_32: logerror("SED1330 '%s' Display Page 1: flash fFR/32\n", device->tag); break; |
| 337 | case SED1330_FC_FLASH_64: logerror("SED1330 '%s' Display Page 1: flash fFR/64\n", device->tag); break; |
| 338 | } |
| 339 | |
| 340 | switch ((sed1330->fp >> 2) & 0x03) |
| 341 | { |
| 342 | case SED1330_FC_OFF: logerror("SED1330 '%s' Display Page 2/4: disabled\n", device->tag); break; |
| 343 | case SED1330_FC_SOLID: logerror("SED1330 '%s' Display Page 2/4: enabled\n", device->tag); break; |
| 344 | case SED1330_FC_FLASH_32: logerror("SED1330 '%s' Display Page 2/4: flash fFR/32\n", device->tag); break; |
| 345 | case SED1330_FC_FLASH_64: logerror("SED1330 '%s' Display Page 2/4: flash fFR/64\n", device->tag); break; |
| 346 | } |
| 347 | |
| 348 | switch ((sed1330->fp >> 4) & 0x03) |
| 349 | { |
| 350 | case SED1330_FC_OFF: logerror("SED1330 '%s' Display Page 3: disabled\n", device->tag); break; |
| 351 | case SED1330_FC_SOLID: logerror("SED1330 '%s' Display Page 3: enabled\n", device->tag); break; |
| 352 | case SED1330_FC_FLASH_32: logerror("SED1330 '%s' Display Page 3: flash fFR/32\n", device->tag); break; |
| 353 | case SED1330_FC_FLASH_64: logerror("SED1330 '%s' Display Page 3: flash fFR/64\n", device->tag); break; |
| 354 | } |
| 330 | 355 | } |
| 331 | 356 | break; |
| 332 | 357 | |
| r4846 | r4847 | |
| 344 | 369 | |
| 345 | 370 | case 2: |
| 346 | 371 | sed1330->sl1 = data + 1; |
| 347 | | if (LOG) logerror("SED1330 '%s' Display Page 1 Screen Lines: %u\n", device->tag, sed1330->sl1); |
| 372 | if (LOG) logerror("SED1330 '%s' Display Block 1 Screen Lines: %u\n", device->tag, sed1330->sl1); |
| 348 | 373 | break; |
| 349 | 374 | |
| 350 | 375 | case 3: |
| r4846 | r4847 | |
| 358 | 383 | |
| 359 | 384 | case 5: |
| 360 | 385 | sed1330->sl2 = data + 1; |
| 361 | | if (LOG) logerror("SED1330 '%s' Display Page 2 Screen Lines: %u\n", device->tag, sed1330->sl2); |
| 386 | if (LOG) logerror("SED1330 '%s' Display Block 2 Screen Lines: %u\n", device->tag, sed1330->sl2); |
| 362 | 387 | break; |
| 363 | 388 | |
| 364 | 389 | case 6: |
| r4846 | r4847 | |
| 405 | 430 | default: |
| 406 | 431 | logerror("SED1330 '%s' Invalid parameter byte %02x\n", device->tag, data); |
| 407 | 432 | } |
| 408 | | sed1330->cd = SED1330_CSRDIR_DOWN; // HACK |
| 433 | // sed1330->cd = SED1330_CSRDIR_DOWN; // HACK |
| 409 | 434 | break; |
| 410 | 435 | |
| 411 | 436 | case SED1330_INSTRUCTION_CGRAM_ADR: |
| r4846 | r4847 | |
| 425 | 450 | } |
| 426 | 451 | break; |
| 427 | 452 | |
| 428 | | case SED1330_INSTRUCTION_CSRDIR_RIGHT: |
| 429 | | case SED1330_INSTRUCTION_CSRDIR_LEFT: |
| 430 | | case SED1330_INSTRUCTION_CSRDIR_UP: |
| 431 | | case SED1330_INSTRUCTION_CSRDIR_DOWN: |
| 432 | | sed1330->cd = data & 0x03; |
| 433 | | if (LOG) |
| 434 | | { |
| 435 | | switch (sed1330->cd) |
| 436 | | { |
| 437 | | case SED1330_CSRDIR_RIGHT: logerror("SED1330 '%s' Cursor Direction: Right\n", device->tag); break; |
| 438 | | case SED1330_CSRDIR_LEFT: logerror("SED1330 '%s' Cursor Direction: Left\n", device->tag); break; |
| 439 | | case SED1330_CSRDIR_UP: logerror("SED1330 '%s' Cursor Direction: Up\n", device->tag); break; |
| 440 | | case SED1330_CSRDIR_DOWN: logerror("SED1330 '%s' Cursor Direction: Down\n", device->tag); break; |
| 441 | | } |
| 442 | | } |
| 443 | | break; |
| 444 | | |
| 445 | 453 | case SED1330_INSTRUCTION_HDOT_SCR: |
| 446 | 454 | sed1330->hdotscr = data & 0x07; |
| 447 | 455 | if (LOG) logerror("SED1330 '%s' Horizontal Dot Scroll: %u\n", device->tag, sed1330->hdotscr); |
| r4846 | r4847 | |
| 456 | 464 | { |
| 457 | 465 | switch (sed1330->mx) |
| 458 | 466 | { |
| 459 | | case SED1330_MX_OR: |
| 460 | | logerror("SED1330 '%s' Layered Screen Composition Method: OR\n", device->tag); |
| 461 | | break; |
| 462 | | |
| 463 | | case SED1330_MX_XOR: |
| 464 | | logerror("SED1330 '%s' Layered Screen Composition Method: Exclusive-OR\n", device->tag); |
| 465 | | break; |
| 466 | | |
| 467 | | case SED1330_MX_AND: |
| 468 | | logerror("SED1330 '%s' Layered Screen Composition Method: AND\n", device->tag); |
| 469 | | break; |
| 470 | | |
| 471 | | case SED1330_MX_PRIORITY_OR: |
| 472 | | logerror("SED1330 '%s' Layered Screen Composition Method: Priority-OR\n", device->tag); |
| 473 | | break; |
| 467 | case SED1330_MX_OR: logerror("SED1330 '%s' Display Composition Method: OR\n", device->tag); break; |
| 468 | case SED1330_MX_XOR: logerror("SED1330 '%s' Display Composition Method: Exclusive-OR\n", device->tag); break; |
| 469 | case SED1330_MX_AND: logerror("SED1330 '%s' Display Composition Method: AND\n", device->tag); break; |
| 470 | case SED1330_MX_PRIORITY_OR: logerror("SED1330 '%s' Display Composition Method: Priority-OR\n", device->tag); break; |
| 474 | 471 | } |
| 475 | 472 | |
| 476 | 473 | logerror("SED1330 '%s' Display Page 1 Mode: %s\n", device->tag, BIT(data, 2) ? "Graphics" : "Text"); |
| r4846 | r4847 | |
| 484 | 481 | { |
| 485 | 482 | case 0: |
| 486 | 483 | sed1330->csr = (sed1330->csr & 0xff00) | data; |
| 487 | | if (LOG) logerror("SED1330 '%s' Cursor Address Low %02x %04x %u\n", device->tag, data, sed1330->csr, sed1330->csr/80); |
| 488 | 484 | break; |
| 489 | 485 | |
| 490 | 486 | case 1: |
| 491 | 487 | sed1330->csr = (data << 8) | (sed1330->csr & 0xff); |
| 492 | | if (LOG) logerror("SED1330 '%s' Cursor Address High %02x %04x %u\n", device->tag, data, sed1330->csr, sed1330->csr/80); |
| 488 | if (LOG) logerror("SED1330 '%s' Cursor Address %04x\n", device->tag, sed1330->csr); |
| 493 | 489 | break; |
| 494 | 490 | |
| 495 | 491 | default: |
| r4846 | r4847 | |
| 501 | 497 | break; |
| 502 | 498 | */ |
| 503 | 499 | case SED1330_INSTRUCTION_MWRITE: |
| 504 | | if (LOG) logerror("SED1330 '%s' Memory Write %02x to %04x\n", device->tag, data, sed1330->csr); |
| 500 | if (LOG) logerror("SED1330 '%s' Memory Write %02x to %04x (row %u col %u line %u)\n", device->tag, data, sed1330->csr, sed1330->csr/80/8, sed1330->csr%80, sed1330->csr/80); |
| 505 | 501 | |
| 506 | 502 | devcb_call_write8(&sed1330->out_vd_func, sed1330->csr, data); |
| 507 | 503 | |
| r4846 | r4847 | |
| 538 | 534 | { |
| 539 | 535 | for (x = 0; x < sed1330->crx; x++) |
| 540 | 536 | { |
| 541 | | *BITMAP_ADDR16(bitmap, y, sed1330->hdotscr + (sx * sed1330->fx) + x) = 1; |
| 537 | *BITMAP_ADDR16(bitmap, y, (sx * sed1330->fx) + x) = 1; |
| 542 | 538 | } |
| 543 | 539 | } |
| 544 | 540 | } |
| r4846 | r4847 | |
| 549 | 545 | { |
| 550 | 546 | for (x = 0; x < sed1330->crx; x++) |
| 551 | 547 | { |
| 552 | | *BITMAP_ADDR16(bitmap, y, sed1330->hdotscr + (sx * sed1330->fx) + x) = 1; |
| 548 | *BITMAP_ADDR16(bitmap, y, (sx * sed1330->fx) + x) = 1; |
| 553 | 549 | } |
| 554 | 550 | } |
| 555 | 551 | } |
| r4846 | r4847 | |
| 571 | 567 | |
| 572 | 568 | for (x = 0; x < sed1330->fx; x++) |
| 573 | 569 | { |
| 574 | | *BITMAP_ADDR16(bitmap, y, sed1330->hdotscr + (sx * sed1330->fx) + x) = BIT(data, 7); |
| 570 | *BITMAP_ADDR16(bitmap, y, (sx * sed1330->fx) + x) = BIT(data, 7); |
| 575 | 571 | data <<= 1; |
| 576 | 572 | } |
| 577 | 573 | } |
| r4846 | r4847 | |
| 655 | 651 | sed1330->screen = devtag_get_device(device->machine, intf->screen_tag); |
| 656 | 652 | assert(sed1330->screen != NULL); |
| 657 | 653 | |
| 658 | | /* create the busy timer */ |
| 659 | | sed1330->busy_timer = timer_alloc(device->machine, busy_tick, (void *)device); |
| 660 | | |
| 661 | 654 | /* register for state saving */ |
| 662 | 655 | state_save_register_device_item(device, 0, sed1330->bf); |
| 663 | 656 | state_save_register_device_item(device, 0, sed1330->ir); |