src/mess/drivers/pc8801.c
| r15715 | r15716 | |
| 317 | 317 | |
| 318 | 318 | }; |
| 319 | 319 | |
| 320 | |
| 321 | static void pc8801_dynamic_res_change(running_machine &machine); |
| 322 | |
| 320 | 323 | /* |
| 321 | 324 | CRTC command params: |
| 322 | 325 | 0. CRTC reset |
| 323 | 326 | |
| 327 | [0] *--- ---- <unknown> |
| 324 | 328 | [0] -xxx xxxx screen columns (+2) |
| 329 | |
| 325 | 330 | [1] xx-- ---- blink speed (in frame unit) (+1, << 3) |
| 326 | 331 | [1] --xx xxxx screen lines (+1) |
| 332 | |
| 327 | 333 | [2] x--- ---- "skip line" |
| 328 | 334 | [2] -x-- ---- cursor style (reverse on / underscore off) |
| 329 | 335 | [2] --x- ---- cursor blink on/off |
| 336 | [2] ---x xxxx lines per character (+1) |
| 330 | 337 | |
| 338 | [3] xxx- ---- Vertical Retrace (+1) |
| 339 | [3] ---x xxxx Horizontal Retrace (+2) |
| 340 | |
| 331 | 341 | [4] x--- ---- attribute not separate flag |
| 332 | 342 | [4] -x-- ---- attribute color flag |
| 333 | 343 | [4] --x- ---- attribute not special flag (invalidates next register) |
| 334 | 344 | [4] ---x xxxx attribute size (+1) |
| 335 | 345 | */ |
| 336 | 346 | |
| 347 | #define screen_width ((state->m_crtc.param[0][0] & 0x7f) + 2) * 8 |
| 348 | |
| 337 | 349 | #define blink_speed ((((state->m_crtc.param[0][1] & 0xc0) >> 6) + 1) << 3) |
| 350 | #define screen_height ((state->m_crtc.param[0][1] & 0x3f) + 1) |
| 351 | |
| 352 | #define lines_per_char ((state->m_crtc.param[0][2] & 0x1f) + 1) |
| 353 | |
| 354 | #define vretrace (((state->m_crtc.param[0][3] & 0xe0) >> 5) + 1) |
| 355 | #define hretrace ((state->m_crtc.param[0][3] & 0x1f) + 2) |
| 356 | |
| 338 | 357 | #define text_color_flag (state->m_crtc.param[0][4] & 0x40) |
| 339 | | #define monitor_24KHz ((state->m_gfx_ctrl & 0x19) == 0x08) |
| 358 | #define monitor_24KHz ((state->m_gfx_ctrl & 0x19) == 0x08) /* TODO: this is most likely to be WRONG */ |
| 340 | 359 | |
| 341 | 360 | static VIDEO_START( pc8801 ) |
| 342 | 361 | { |
| 343 | 362 | |
| 344 | 363 | } |
| 345 | 364 | |
| 346 | | static void draw_bitmap_3bpp(running_machine &machine, bitmap_ind16 &bitmap) |
| 365 | static void draw_bitmap_3bpp(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect) |
| 347 | 366 | { |
| 367 | pc8801_state *state = machine.driver_data<pc8801_state>(); |
| 348 | 368 | int x,y,xi; |
| 349 | 369 | UINT32 count; |
| 350 | 370 | UINT8 *gvram = machine.root_device().memregion("gvram")->base(); |
| 371 | UINT16 y_size; |
| 372 | UINT16 y_double; |
| 351 | 373 | |
| 352 | 374 | count = 0; |
| 353 | 375 | |
| 354 | | for(y=0;y<200;y++) |
| 376 | y_double = ((lines_per_char & 0x10) >> 4); // TODO: true condition of this? |
| 377 | y_size = (y_double+1) * 200; |
| 378 | |
| 379 | for(y=0;y<y_size;y+=(y_double+1)) |
| 355 | 380 | { |
| 356 | 381 | for(x=0;x<640;x+=8) |
| 357 | 382 | { |
| r15715 | r15716 | |
| 366 | 391 | pen |= ((gvram[count+0x4000] >> (7-xi)) & 1) << 1; |
| 367 | 392 | pen |= ((gvram[count+0x8000] >> (7-xi)) & 1) << 2; |
| 368 | 393 | |
| 369 | | bitmap.pix16(y, x+xi) = machine.pens[pen & 7]; |
| 394 | if(y_double) |
| 395 | { |
| 396 | if(cliprect.contains(x+xi, y+0)) |
| 397 | bitmap.pix16(y+0, x+xi) = machine.pens[pen & 7]; |
| 398 | |
| 399 | if(cliprect.contains(x+xi, y+1)) |
| 400 | bitmap.pix16(y+1, x+xi) = machine.pens[pen & 7]; |
| 401 | } |
| 402 | else |
| 403 | { |
| 404 | if(cliprect.contains(x+xi, y+0)) |
| 405 | bitmap.pix16(y, x+xi) = machine.pens[pen & 7]; |
| 406 | } |
| 370 | 407 | } |
| 371 | 408 | |
| 372 | 409 | count++; |
| r15715 | r15716 | |
| 490 | 527 | pc8801_state *state = machine.driver_data<pc8801_state>(); |
| 491 | 528 | int xi,yi; |
| 492 | 529 | UINT8 *vram = state->memregion("wram")->base(); |
| 530 | UINT8 *gfx_rom = machine.root_device().memregion("gfx1")->base(); |
| 493 | 531 | UINT8 is_cursor; |
| 494 | | UINT8 y_height; |
| 532 | UINT8 y_height, y_double; |
| 495 | 533 | |
| 496 | | y_height = y_size == 20 ? 10 : 8; |
| 534 | y_height = lines_per_char; |
| 535 | y_double = (lines_per_char & 0x10) >> 4; // TODO: find correct condition |
| 497 | 536 | |
| 498 | 537 | for(yi=0;yi<y_height;yi++) |
| 499 | 538 | { |
| r15715 | r15716 | |
| 511 | 550 | res_x = x*8+xi*(width+1); |
| 512 | 551 | res_y = y*y_height*(height+1)+yi*(height+1); |
| 513 | 552 | |
| 553 | if(!machine.primary_screen->visible_area().contains(res_x, res_y)) |
| 554 | continue; |
| 555 | |
| 514 | 556 | if(gfx_mode) |
| 515 | 557 | { |
| 516 | 558 | UINT8 mask; |
| r15715 | r15716 | |
| 522 | 564 | else |
| 523 | 565 | { |
| 524 | 566 | UINT8 char_data; |
| 525 | | UINT8 *gfx_rom = machine.root_device().memregion("gfx1")->base(); |
| 526 | 567 | |
| 527 | | if(yi >= 8 || secret) |
| 528 | | char_data = 0; |
| 568 | if(y_double) |
| 569 | { |
| 570 | if(yi >= 16 || secret) |
| 571 | char_data = 0; |
| 572 | else |
| 573 | char_data = (gfx_rom[tile*8+(yi >> 1)] >> (7-xi)) & 1; |
| 574 | } |
| 529 | 575 | else |
| 530 | | char_data = (gfx_rom[tile*8+yi] >> (7-xi)) & 1; |
| 576 | { |
| 577 | if(yi >= 8 || secret) |
| 578 | char_data = 0; |
| 579 | else |
| 580 | char_data = (gfx_rom[tile*8+yi] >> (7-xi)) & 1; |
| 581 | } |
| 531 | 582 | |
| 532 | 583 | if(yi == 0 && upper) |
| 533 | 584 | char_data = 1; |
| r15715 | r15716 | |
| 541 | 592 | color = char_data ? pal : -1; |
| 542 | 593 | } |
| 543 | 594 | |
| 544 | | if(!machine.primary_screen->visible_area().contains(res_x, res_y)) |
| 545 | | continue; |
| 546 | | |
| 547 | 595 | if(color != -1) |
| 548 | 596 | bitmap.pix16(res_y, res_x) = machine.pens[color]; |
| 549 | 597 | |
| r15715 | r15716 | |
| 635 | 683 | if(state->m_gfx_ctrl & 8) |
| 636 | 684 | { |
| 637 | 685 | if(state->m_gfx_ctrl & 0x10) |
| 638 | | draw_bitmap_3bpp(screen.machine(),bitmap); |
| 686 | draw_bitmap_3bpp(screen.machine(),bitmap,cliprect); |
| 639 | 687 | else |
| 640 | 688 | draw_bitmap_1bpp(screen.machine(),bitmap); |
| 641 | 689 | } |
| r15715 | r15716 | |
| 1004 | 1052 | { |
| 1005 | 1053 | pc8801_state *state = machine.driver_data<pc8801_state>(); |
| 1006 | 1054 | rectangle visarea; |
| 1055 | int xsize,ysize; |
| 1007 | 1056 | |
| 1008 | | visarea.set(0, 640 - 1, 0, ((monitor_24KHz) ? 400 : 200) - 1); |
| 1057 | //printf("H %d V %d (%d x %d) HR %d VR %d (%d %d)\n",screen_width,screen_height * lines_per_char,screen_height,lines_per_char, |
| 1058 | // hretrace,vretrace, screen_width + hretrace,screen_height * lines_per_char + vretrace * lines_per_char); |
| 1059 | //printf("%02x %02x dyn res\n",monitor_24KHz,state->m_gfx_ctrl); |
| 1009 | 1060 | |
| 1061 | xsize = screen_width; |
| 1062 | ysize = screen_height * lines_per_char; |
| 1063 | |
| 1064 | visarea.set(0, xsize - 1, 0, ysize - 1); |
| 1065 | |
| 1010 | 1066 | machine.primary_screen->configure(640, 480, visarea, machine.primary_screen->frame_period().attoseconds); |
| 1011 | 1067 | } |
| 1012 | 1068 | |
| r15715 | r15716 | |
| 1174 | 1230 | if(m_crtc.param_count < 5) |
| 1175 | 1231 | { |
| 1176 | 1232 | m_crtc.param[m_crtc.cmd][m_crtc.param_count] = data; |
| 1233 | if(m_crtc.cmd == 0) |
| 1234 | pc8801_dynamic_res_change(machine()); |
| 1235 | |
| 1177 | 1236 | m_crtc.param_count++; |
| 1178 | 1237 | } |
| 1179 | 1238 | } |