src/mess/video/isa_mda.c
| r14390 | r14391 | |
| 174 | 174 | void isa8_mda_device::device_start() |
| 175 | 175 | { |
| 176 | 176 | set_isa_device(); |
| 177 | | videoram = auto_alloc_array(machine(), UINT8, 0x1000); |
| 177 | m_videoram = auto_alloc_array(machine(), UINT8, 0x1000); |
| 178 | 178 | m_isa->install_device(0x3b0, 0x3bf, 0, 0, read8_delegate( FUNC(isa8_mda_device::io_read), this ), write8_delegate( FUNC(isa8_mda_device::io_write), this ) ); |
| 179 | | m_isa->install_bank(0xb0000, 0xb0fff, 0, 0x07000, "bank_mda", videoram); |
| 179 | m_isa->install_bank(0xb0000, 0xb0fff, 0, 0x07000, "bank_mda", m_videoram); |
| 180 | 180 | |
| 181 | 181 | /* Initialise the mda palette */ |
| 182 | 182 | for(int i = 0; i < (sizeof(mda_palette) / 3); i++) |
| r14390 | r14391 | |
| 189 | 189 | |
| 190 | 190 | void isa8_mda_device::device_reset() |
| 191 | 191 | { |
| 192 | | update_row = NULL; |
| 193 | | framecnt = 0; |
| 194 | | mode_control = 0; |
| 195 | | vsync = 0; |
| 196 | | hsync = 0; |
| 192 | m_update_row = NULL; |
| 193 | m_framecnt = 0; |
| 194 | m_mode_control = 0; |
| 195 | m_vsync = 0; |
| 196 | m_hsync = 0; |
| 197 | 197 | m_pixel = 0; |
| 198 | 198 | |
| 199 | 199 | astring tempstring; |
| 200 | | chr_gen = machine().region(subtag(tempstring, "gfx1"))->base(); |
| 200 | m_chr_gen = machine().region(subtag(tempstring, "gfx1"))->base(); |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /*************************************************************************** |
| r14390 | r14391 | |
| 224 | 224 | for ( i = 0; i < x_count; i++ ) |
| 225 | 225 | { |
| 226 | 226 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF; |
| 227 | | UINT8 chr = mda->videoram[ offset ]; |
| 228 | | UINT8 attr = mda->videoram[ offset + 1 ]; |
| 229 | | UINT8 data = mda->chr_gen[ chr_base + chr * 8 ]; |
| 227 | UINT8 chr = mda->m_videoram[ offset ]; |
| 228 | UINT8 attr = mda->m_videoram[ offset + 1 ]; |
| 229 | UINT8 data = mda->m_chr_gen[ chr_base + chr * 8 ]; |
| 230 | 230 | UINT8 fg = ( attr & 0x08 ) ? 3 : 2; |
| 231 | 231 | UINT8 bg = 0; |
| 232 | 232 | |
| r14390 | r14391 | |
| 255 | 255 | break; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | | if ( ( i == cursor_x && ( mda->framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 ) |
| 258 | if ( ( i == cursor_x && ( mda->m_framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 ) |
| 259 | 259 | { |
| 260 | 260 | data = 0xFF; |
| 261 | 261 | } |
| r14390 | r14391 | |
| 298 | 298 | for ( i = 0; i < x_count; i++ ) |
| 299 | 299 | { |
| 300 | 300 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF; |
| 301 | | UINT8 chr = mda->videoram[ offset ]; |
| 302 | | UINT8 attr = mda->videoram[ offset + 1 ]; |
| 303 | | UINT8 data = mda->chr_gen[ chr_base + chr * 8 ]; |
| 301 | UINT8 chr = mda->m_videoram[ offset ]; |
| 302 | UINT8 attr = mda->m_videoram[ offset + 1 ]; |
| 303 | UINT8 data = mda->m_chr_gen[ chr_base + chr * 8 ]; |
| 304 | 304 | UINT8 fg = ( attr & 0x08 ) ? 3 : 2; |
| 305 | 305 | UINT8 bg = 0; |
| 306 | 306 | |
| r14390 | r14391 | |
| 330 | 330 | |
| 331 | 331 | if ( i == cursor_x ) |
| 332 | 332 | { |
| 333 | | if ( mda->framecnt & 0x08 ) |
| 333 | if ( mda->m_framecnt & 0x08 ) |
| 334 | 334 | { |
| 335 | 335 | data = 0xFF; |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | else |
| 339 | 339 | { |
| 340 | | if ( ( attr & 0x80 ) && ( mda->framecnt & 0x10 ) ) |
| 340 | if ( ( attr & 0x80 ) && ( mda->m_framecnt & 0x10 ) ) |
| 341 | 341 | { |
| 342 | 342 | data = 0x00; |
| 343 | 343 | } |
| r14390 | r14391 | |
| 366 | 366 | static MC6845_UPDATE_ROW( mda_update_row ) |
| 367 | 367 | { |
| 368 | 368 | isa8_mda_device *mda = downcast<isa8_mda_device *>(device->owner()); |
| 369 | | if ( mda->update_row ) |
| 369 | if ( mda->m_update_row ) |
| 370 | 370 | { |
| 371 | | mda->update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 371 | mda->m_update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 372 | 372 | } |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
| 376 | 376 | WRITE_LINE_MEMBER( isa8_mda_device::hsync_changed ) |
| 377 | 377 | { |
| 378 | | hsync = state ? 1 : 0; |
| 378 | m_hsync = state ? 1 : 0; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | |
| 382 | 382 | WRITE_LINE_MEMBER( isa8_mda_device::vsync_changed ) |
| 383 | 383 | { |
| 384 | | vsync = state ? 0x80 : 0; |
| 384 | m_vsync = state ? 0x80 : 0; |
| 385 | 385 | if ( state ) |
| 386 | 386 | { |
| 387 | | framecnt++; |
| 387 | m_framecnt++; |
| 388 | 388 | } |
| 389 | 389 | } |
| 390 | 390 | |
| r14390 | r14391 | |
| 394 | 394 | */ |
| 395 | 395 | WRITE8_MEMBER( isa8_mda_device::mode_control_w ) |
| 396 | 396 | { |
| 397 | | mode_control = data; |
| 397 | m_mode_control = data; |
| 398 | 398 | |
| 399 | | switch( mode_control & 0x2a ) |
| 399 | switch( m_mode_control & 0x2a ) |
| 400 | 400 | { |
| 401 | 401 | case 0x08: |
| 402 | | update_row = mda_text_inten_update_row; |
| 402 | m_update_row = mda_text_inten_update_row; |
| 403 | 403 | break; |
| 404 | 404 | case 0x28: |
| 405 | | update_row = mda_text_blink_update_row; |
| 405 | m_update_row = mda_text_blink_update_row; |
| 406 | 406 | break; |
| 407 | 407 | default: |
| 408 | | update_row = NULL; |
| 408 | m_update_row = NULL; |
| 409 | 409 | } |
| 410 | 410 | } |
| 411 | 411 | |
| r14390 | r14391 | |
| 426 | 426 | // Faking pixel stream here |
| 427 | 427 | m_pixel++; |
| 428 | 428 | |
| 429 | | return 0xF0 | (m_pixel & 0x08) | hsync; |
| 429 | return 0xF0 | (m_pixel & 0x08) | m_hsync; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | |
| r14390 | r14391 | |
| 581 | 581 | |
| 582 | 582 | void isa8_hercules_device::device_start() |
| 583 | 583 | { |
| 584 | | videoram = auto_alloc_array(machine(), UINT8, 0x10000); |
| 584 | m_videoram = auto_alloc_array(machine(), UINT8, 0x10000); |
| 585 | 585 | set_isa_device(); |
| 586 | 586 | m_isa->install_device(this, 0x3b0, 0x3bf, 0, 0, FUNC(hercules_r), FUNC(hercules_w) ); |
| 587 | | m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", videoram); |
| 587 | m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", m_videoram); |
| 588 | 588 | |
| 589 | 589 | /* Initialise the mda palette */ |
| 590 | 590 | for(int i = 0; i < (sizeof(mda_palette) / 3); i++) |
| r14390 | r14391 | |
| 598 | 598 | void isa8_hercules_device::device_reset() |
| 599 | 599 | { |
| 600 | 600 | isa8_mda_device::device_reset(); |
| 601 | | configuration_switch = 0; |
| 601 | m_configuration_switch = 0; |
| 602 | 602 | |
| 603 | 603 | astring tempstring; |
| 604 | | chr_gen = machine().region(subtag(tempstring, "gfx1"))->base(); |
| 604 | m_chr_gen = machine().region(subtag(tempstring, "gfx1"))->base(); |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /*************************************************************************** |
| r14390 | r14391 | |
| 616 | 616 | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device->owner()); |
| 617 | 617 | const rgb_t *palette = palette_entry_list_raw(bitmap.palette()); |
| 618 | 618 | UINT32 *p = &bitmap.pix32(y); |
| 619 | | UINT16 gfx_base = ( ( herc->mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 ); |
| 619 | UINT16 gfx_base = ( ( herc->m_mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 ); |
| 620 | 620 | int i; |
| 621 | 621 | if ( y == 0 ) MDA_LOG(1,"hercules_gfx_update_row",("\n")); |
| 622 | 622 | for ( i = 0; i < x_count; i++ ) |
| 623 | 623 | { |
| 624 | | UINT8 data = herc->videoram[ gfx_base + ( ( ma + i ) << 1 ) ]; |
| 624 | UINT8 data = herc->m_videoram[ gfx_base + ( ( ma + i ) << 1 ) ]; |
| 625 | 625 | |
| 626 | 626 | *p = palette[( data & 0x80 ) ? 2 : 0]; p++; |
| 627 | 627 | *p = palette[( data & 0x40 ) ? 2 : 0]; p++; |
| r14390 | r14391 | |
| 632 | 632 | *p = palette[( data & 0x02 ) ? 2 : 0]; p++; |
| 633 | 633 | *p = palette[( data & 0x01 ) ? 2 : 0]; p++; |
| 634 | 634 | |
| 635 | | data = herc->videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ]; |
| 635 | data = herc->m_videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ]; |
| 636 | 636 | |
| 637 | 637 | *p = palette[( data & 0x80 ) ? 2 : 0]; p++; |
| 638 | 638 | *p = palette[( data & 0x40 ) ? 2 : 0]; p++; |
| r14390 | r14391 | |
| 652 | 652 | |
| 653 | 653 | MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n", |
| 654 | 654 | data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1)); |
| 655 | | herc->mode_control = data; |
| 655 | herc->m_mode_control = data; |
| 656 | 656 | |
| 657 | | switch( herc->mode_control & 0x2a ) |
| 657 | switch( herc->m_mode_control & 0x2a ) |
| 658 | 658 | { |
| 659 | 659 | case 0x08: |
| 660 | | herc->update_row = mda_text_inten_update_row; |
| 660 | herc->m_update_row = mda_text_inten_update_row; |
| 661 | 661 | break; |
| 662 | 662 | case 0x28: |
| 663 | | herc->update_row = mda_text_blink_update_row; |
| 663 | herc->m_update_row = mda_text_blink_update_row; |
| 664 | 664 | break; |
| 665 | 665 | case 0x0A: /* Hercules modes */ |
| 666 | 666 | case 0x2A: |
| 667 | | herc->update_row = hercules_gfx_update_row; |
| 667 | herc->m_update_row = hercules_gfx_update_row; |
| 668 | 668 | break; |
| 669 | 669 | default: |
| 670 | | herc->update_row = NULL; |
| 670 | herc->m_update_row = NULL; |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | | downcast<mc6845_device *>(device)->set_clock( herc->mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 ); |
| 674 | | downcast<mc6845_device *>(device)->set_hpixels_per_column( herc->mode_control & 0x02 ? 16 : 9 ); |
| 673 | downcast<mc6845_device *>(device)->set_clock( herc->m_mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 ); |
| 674 | downcast<mc6845_device *>(device)->set_hpixels_per_column( herc->m_mode_control & 0x02 ? 16 : 9 ); |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | |
| r14390 | r14391 | |
| 679 | 679 | { |
| 680 | 680 | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device); |
| 681 | 681 | MDA_LOG(1,"HGC_config_w",("$%02x\n", data)); |
| 682 | | herc->configuration_switch = data; |
| 682 | herc->m_configuration_switch = data; |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | |
| r14390 | r14391 | |
| 723 | 723 | static READ8_DEVICE_HANDLER(hercules_status_r) |
| 724 | 724 | { |
| 725 | 725 | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device); |
| 726 | | return herc->vsync | 0x08 | herc->hsync; |
| 726 | |
| 727 | // Faking pixel stream here |
| 728 | herc->m_pixel++; |
| 729 | |
| 730 | return herc->m_vsync | ( herc->m_pixel & 0x08 ) | herc->m_hsync; |
| 727 | 731 | } |
| 728 | 732 | |
| 729 | 733 | |