src/mess/video/pc_mda.c
| r10666 | r10667 | |
| 8 | 8 | #include "pc_mda.h" |
| 9 | 9 | #include "video/mc6845.h" |
| 10 | 10 | |
| 11 | #define MDA_SCREEN_NAME "mda_screen" |
| 12 | #define MDA_MC6845_NAME "mc6845_mda" |
| 13 | |
| 14 | /* |
| 15 | Hercules video card |
| 16 | */ |
| 17 | #define HERCULES_SCREEN_NAME "hercules_screen" |
| 18 | #define HERCULES_MC6845_NAME "mc6845_hercules" |
| 19 | |
| 11 | 20 | #define VERBOSE_MDA 0 /* MDA (Monochrome Display Adapter) */ |
| 12 | 21 | |
| 13 | 22 | #define MDA_CLOCK 16257000 |
| r10666 | r10667 | |
| 17 | 26 | if(VERBOSE_MDA>=N) \ |
| 18 | 27 | { \ |
| 19 | 28 | if( M ) \ |
| 20 | | logerror("%11.6f: %-24s",machine->time().as_double(),(char*)M ); \ |
| 29 | logerror("%11.6f: %-24s",device->machine->time().as_double(),(char*)M ); \ |
| 21 | 30 | logerror A; \ |
| 22 | 31 | } \ |
| 23 | 32 | } while (0) |
| r10666 | r10667 | |
| 30 | 39 | { 0x00,0xff,0x00 } |
| 31 | 40 | }; |
| 32 | 41 | |
| 33 | | static struct |
| 34 | | { |
| 35 | | UINT8 status; |
| 36 | | |
| 37 | | int pc_framecnt; |
| 38 | | |
| 39 | | UINT8 mode_control, configuration_switch; //hercules |
| 40 | | |
| 41 | | mc6845_update_row_func update_row; |
| 42 | | UINT8 *chr_gen; |
| 43 | | UINT8 vsync; |
| 44 | | UINT8 hsync; |
| 45 | | UINT8 *videoram; |
| 46 | | } mda; |
| 47 | | |
| 48 | | /* Initialise the mda palette */ |
| 49 | | static PALETTE_INIT( pc_mda ) |
| 50 | | { |
| 51 | | int i; |
| 52 | | for(i = 0; i < (sizeof(mda_palette) / 3); i++) |
| 53 | | palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]); |
| 54 | | } |
| 55 | | |
| 56 | | static VIDEO_START( pc_mda ); |
| 57 | 42 | static SCREEN_UPDATE( mc6845_mda ); |
| 58 | | static READ8_HANDLER( pc_MDA_r ); |
| 59 | | static WRITE8_HANDLER( pc_MDA_w ); |
| 43 | static READ8_DEVICE_HANDLER( pc_MDA_r ); |
| 44 | static WRITE8_DEVICE_HANDLER( pc_MDA_w ); |
| 60 | 45 | static MC6845_UPDATE_ROW( mda_update_row ); |
| 61 | 46 | static WRITE_LINE_DEVICE_HANDLER( mda_hsync_changed ); |
| 62 | 47 | static WRITE_LINE_DEVICE_HANDLER( mda_vsync_changed ); |
| 63 | 48 | |
| 49 | /* F4 Character Displayer */ |
| 50 | static const gfx_layout pc_16_charlayout = |
| 51 | { |
| 52 | 8, 16, /* 8 x 16 characters */ |
| 53 | 256, /* 256 characters */ |
| 54 | 1, /* 1 bits per pixel */ |
| 55 | { 0 }, /* no bitplanes */ |
| 56 | /* x offsets */ |
| 57 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 58 | /* y offsets */ |
| 59 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 2048*8, 2049*8, 2050*8, 2051*8, 2052*8, 2053*8, 2054*8, 2055*8 }, |
| 60 | 8*8 /* every char takes 2 x 8 bytes */ |
| 61 | }; |
| 62 | |
| 63 | static const gfx_layout pc_8_charlayout = |
| 64 | { |
| 65 | 8, 8, /* 8 x 8 characters */ |
| 66 | 512, /* 512 characters */ |
| 67 | 1, /* 1 bits per pixel */ |
| 68 | { 0 }, /* no bitplanes */ |
| 69 | /* x offsets */ |
| 70 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 71 | /* y offsets */ |
| 72 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, |
| 73 | 8*8 /* every char takes 8 bytes */ |
| 74 | }; |
| 75 | |
| 76 | static GFXDECODE_START( pcmda ) |
| 77 | GFXDECODE_ENTRY( "mda:gfx1", 0x0000, pc_16_charlayout, 1, 1 ) |
| 78 | GFXDECODE_ENTRY( "mda:gfx1", 0x1000, pc_8_charlayout, 1, 1 ) |
| 79 | GFXDECODE_END |
| 80 | |
| 64 | 81 | static const mc6845_interface mc6845_mda_intf = |
| 65 | 82 | { |
| 66 | | MDA_SCREEN_NAME, /* screen number */ |
| 83 | MDA_SCREEN_NAME, /* screen number */ |
| 67 | 84 | 9, /* number of pixels per video memory address */ |
| 68 | 85 | NULL, /* begin_update */ |
| 69 | 86 | mda_update_row, /* update_row */ |
| r10666 | r10667 | |
| 81 | 98 | MCFG_SCREEN_RAW_PARAMS(MDA_CLOCK, 882, 0, 720, 370, 0, 350 ) |
| 82 | 99 | MCFG_SCREEN_UPDATE( mc6845_mda) |
| 83 | 100 | |
| 84 | | MCFG_PALETTE_LENGTH( sizeof(mda_palette) / 3 ) |
| 85 | | MCFG_PALETTE_INIT(pc_mda) |
| 86 | | |
| 87 | 101 | MCFG_MC6845_ADD( MDA_MC6845_NAME, MC6845, MDA_CLOCK/9, mc6845_mda_intf) |
| 88 | 102 | |
| 89 | | MCFG_VIDEO_START( pc_mda ) |
| 103 | MCFG_GFXDECODE(pcmda) |
| 90 | 104 | MACHINE_CONFIG_END |
| 91 | 105 | |
| 106 | ROM_START( mda ) |
| 107 | /* IBM 1501981(CGA) and 1501985(MDA) Character rom */ |
| 108 | ROM_REGION(0x08100,"gfx1", 0) |
| 109 | ROM_LOAD("5788005.u33", 0x00000, 0x02000, CRC(0bf56d70) SHA1(c2a8b10808bf51a3c123ba3eb1e9dd608231916f)) /* "AMI 8412PI // 5788005 // (C) IBM CORP. 1981 // KOREA" */ |
| 110 | ROM_END |
| 92 | 111 | |
| 93 | | /*************************************************************************** |
| 112 | //************************************************************************** |
| 113 | // GLOBAL VARIABLES |
| 114 | //************************************************************************** |
| 115 | |
| 116 | const device_type ISA8_MDA = isa8_mda_device_config::static_alloc_device_config; |
| 117 | |
| 118 | //************************************************************************** |
| 119 | // DEVICE CONFIGURATION |
| 120 | //************************************************************************** |
| 121 | |
| 122 | //------------------------------------------------- |
| 123 | // isa8_mda_device_config - constructor |
| 124 | //------------------------------------------------- |
| 125 | |
| 126 | isa8_mda_device_config::isa8_mda_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 127 | : device_config(mconfig, static_alloc_device_config, "ISA8_MDA", tag, owner, clock), |
| 128 | device_config_isa8_card_interface(mconfig, *this) |
| 129 | { |
| 130 | m_shortname = "mda"; |
| 131 | } |
| 132 | |
| 133 | //------------------------------------------------- |
| 134 | // static_alloc_device_config - allocate a new |
| 135 | // configuration object |
| 136 | //------------------------------------------------- |
| 137 | |
| 138 | device_config *isa8_mda_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 139 | { |
| 140 | return global_alloc(isa8_mda_device_config(mconfig, tag, owner, clock)); |
| 141 | } |
| 142 | |
| 143 | //------------------------------------------------- |
| 144 | // alloc_device - allocate a new device object |
| 145 | //------------------------------------------------- |
| 146 | |
| 147 | device_t *isa8_mda_device_config::alloc_device(running_machine &machine) const |
| 148 | { |
| 149 | return auto_alloc(&machine, isa8_mda_device(machine, *this)); |
| 150 | } |
| 151 | |
| 152 | //------------------------------------------------- |
| 153 | // machine_config_additions - device-specific |
| 154 | // machine configurations |
| 155 | //------------------------------------------------- |
| 94 | 156 | |
| 95 | | Monochrome Display Adapter (MDA) section |
| 157 | machine_config_constructor isa8_mda_device_config::machine_config_additions() const |
| 158 | { |
| 159 | return MACHINE_CONFIG_NAME( pcvideo_mda ); |
| 160 | } |
| 96 | 161 | |
| 97 | | ***************************************************************************/ |
| 162 | //------------------------------------------------- |
| 163 | // rom_region - device-specific ROM region |
| 164 | //------------------------------------------------- |
| 98 | 165 | |
| 99 | | VIDEO_START( pc_mda ) |
| 166 | const rom_entry *isa8_mda_device_config::rom_region() const |
| 100 | 167 | { |
| 168 | return ROM_NAME( mda ); |
| 169 | } |
| 170 | |
| 171 | //************************************************************************** |
| 172 | // LIVE DEVICE |
| 173 | //************************************************************************** |
| 174 | |
| 175 | //------------------------------------------------- |
| 176 | // isa8_mda_device - constructor |
| 177 | //------------------------------------------------- |
| 178 | |
| 179 | isa8_mda_device::isa8_mda_device(running_machine &_machine, const isa8_mda_device_config &config) : |
| 180 | device_t(_machine, config), |
| 181 | device_isa8_card_interface( _machine, config, *this ), |
| 182 | m_config(config) |
| 183 | { |
| 184 | } |
| 185 | |
| 186 | //------------------------------------------------- |
| 187 | // device_start - device-specific startup |
| 188 | //------------------------------------------------- |
| 189 | |
| 190 | void isa8_mda_device::device_start() |
| 191 | { |
| 101 | 192 | int buswidth; |
| 102 | 193 | address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM); |
| 103 | 194 | |
| r10666 | r10667 | |
| 105 | 196 | switch(buswidth) |
| 106 | 197 | { |
| 107 | 198 | case 8: |
| 108 | | memory_install_readwrite_bank(space, 0xb0000, 0xb0fff, 0, 0x07000, "bank11" ); |
| 109 | | memory_install_read8_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), 0x3b0, 0x3bf, 0, 0, pc_MDA_r ); |
| 110 | | memory_install_write8_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), 0x3b0, 0x3bf, 0, 0, pc_MDA_w ); |
| 199 | memory_install_readwrite_bank(space, 0xb0000, 0xb0fff, 0, 0x07000, "bank_mda" ); |
| 200 | memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), this, 0x3b0, 0x3bf, 0, 0, pc_MDA_r, pc_MDA_w ); |
| 111 | 201 | break; |
| 112 | 202 | |
| 113 | 203 | default: |
| r10666 | r10667 | |
| 115 | 205 | break; |
| 116 | 206 | } |
| 117 | 207 | |
| 118 | | memset( &mda, 0, sizeof(mda)); |
| 119 | | mda.update_row = NULL; |
| 120 | | mda.chr_gen = machine->region( "gfx1" )->base(); |
| 208 | videoram = auto_alloc_array(machine, UINT8, 0x1000); |
| 209 | |
| 210 | memory_set_bankptr(machine,"bank_mda", videoram); |
| 121 | 211 | |
| 122 | | mda.videoram = auto_alloc_array(machine, UINT8, 0x1000); |
| 123 | | memory_set_bankptr(machine,"bank11", mda.videoram); |
| 212 | /* Initialise the mda palette */ |
| 213 | for(int i = 0; i < (sizeof(mda_palette) / 3); i++) |
| 214 | palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]); |
| 124 | 215 | } |
| 216 | |
| 217 | //------------------------------------------------- |
| 218 | // device_reset - device-specific reset |
| 219 | //------------------------------------------------- |
| 220 | |
| 221 | void isa8_mda_device::device_reset() |
| 222 | { |
| 223 | update_row = NULL; |
| 224 | framecnt = 0; |
| 225 | mode_control = 0; |
| 226 | vsync = 0; |
| 227 | hsync = 0; |
| 228 | |
| 229 | astring tempstring; |
| 230 | chr_gen = machine->region(subtag(tempstring, "gfx1"))->base(); |
| 231 | } |
| 125 | 232 | |
| 233 | /*************************************************************************** |
| 126 | 234 | |
| 235 | Monochrome Display Adapter (MDA) section |
| 236 | |
| 237 | ***************************************************************************/ |
| 238 | |
| 127 | 239 | static SCREEN_UPDATE( mc6845_mda ) |
| 128 | 240 | { |
| 129 | | device_t *devconf = screen->machine->device(MDA_MC6845_NAME); |
| 241 | device_t *devconf = screen->owner()->subdevice(MDA_MC6845_NAME); |
| 130 | 242 | mc6845_update( devconf, bitmap, cliprect ); |
| 131 | 243 | return 0; |
| 132 | 244 | } |
| r10666 | r10667 | |
| 140 | 252 | |
| 141 | 253 | static MC6845_UPDATE_ROW( mda_text_inten_update_row ) |
| 142 | 254 | { |
| 143 | | UINT8 *videoram = mda.videoram; |
| 255 | isa8_mda_device *mda = downcast<isa8_mda_device *>(device->owner()); |
| 144 | 256 | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 145 | 257 | UINT16 chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra; |
| 146 | 258 | int i; |
| 147 | | running_machine *machine = device->machine; |
| 148 | 259 | |
| 149 | 260 | if ( y == 0 ) MDA_LOG(1,"mda_text_inten_update_row",("\n")); |
| 150 | 261 | for ( i = 0; i < x_count; i++ ) |
| 151 | 262 | { |
| 152 | 263 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF; |
| 153 | | UINT8 chr = videoram[ offset ]; |
| 154 | | UINT8 attr = videoram[ offset + 1 ]; |
| 155 | | UINT8 data = mda.chr_gen[ chr_base + chr * 8 ]; |
| 264 | UINT8 chr = mda->videoram[ offset ]; |
| 265 | UINT8 attr = mda->videoram[ offset + 1 ]; |
| 266 | UINT8 data = mda->chr_gen[ chr_base + chr * 8 ]; |
| 156 | 267 | UINT8 fg = ( attr & 0x08 ) ? 3 : 2; |
| 157 | 268 | UINT8 bg = 0; |
| 158 | 269 | |
| r10666 | r10667 | |
| 181 | 292 | break; |
| 182 | 293 | } |
| 183 | 294 | |
| 184 | | if ( ( i == cursor_x && ( mda.pc_framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 ) |
| 295 | if ( ( i == cursor_x && ( mda->framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 ) |
| 185 | 296 | { |
| 186 | 297 | data = 0xFF; |
| 187 | 298 | } |
| r10666 | r10667 | |
| 214 | 325 | |
| 215 | 326 | static MC6845_UPDATE_ROW( mda_text_blink_update_row ) |
| 216 | 327 | { |
| 217 | | UINT8 *videoram = mda.videoram; |
| 328 | isa8_mda_device *mda = downcast<isa8_mda_device *>(device->owner()); |
| 218 | 329 | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 219 | 330 | UINT16 chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra; |
| 220 | 331 | int i; |
| 221 | | running_machine *machine = device->machine; |
| 222 | 332 | |
| 223 | 333 | if ( y == 0 ) MDA_LOG(1,"mda_text_blink_update_row",("\n")); |
| 224 | 334 | for ( i = 0; i < x_count; i++ ) |
| 225 | 335 | { |
| 226 | 336 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF; |
| 227 | | UINT8 chr = videoram[ offset ]; |
| 228 | | UINT8 attr = videoram[ offset + 1 ]; |
| 229 | | UINT8 data = mda.chr_gen[ chr_base + chr * 8 ]; |
| 337 | UINT8 chr = mda->videoram[ offset ]; |
| 338 | UINT8 attr = mda->videoram[ offset + 1 ]; |
| 339 | UINT8 data = mda->chr_gen[ chr_base + chr * 8 ]; |
| 230 | 340 | UINT8 fg = ( attr & 0x08 ) ? 3 : 2; |
| 231 | 341 | UINT8 bg = 0; |
| 232 | 342 | |
| r10666 | r10667 | |
| 256 | 366 | |
| 257 | 367 | if ( i == cursor_x ) |
| 258 | 368 | { |
| 259 | | if ( mda.pc_framecnt & 0x08 ) |
| 369 | if ( mda->framecnt & 0x08 ) |
| 260 | 370 | { |
| 261 | 371 | data = 0xFF; |
| 262 | 372 | } |
| 263 | 373 | } |
| 264 | 374 | else |
| 265 | 375 | { |
| 266 | | if ( ( attr & 0x80 ) && ( mda.pc_framecnt & 0x10 ) ) |
| 376 | if ( ( attr & 0x80 ) && ( mda->framecnt & 0x10 ) ) |
| 267 | 377 | { |
| 268 | 378 | data = 0x00; |
| 269 | 379 | } |
| r10666 | r10667 | |
| 291 | 401 | |
| 292 | 402 | static MC6845_UPDATE_ROW( mda_update_row ) |
| 293 | 403 | { |
| 294 | | if ( mda.update_row ) |
| 404 | isa8_mda_device *mda = downcast<isa8_mda_device *>(device->owner()); |
| 405 | if ( mda->update_row ) |
| 295 | 406 | { |
| 296 | | mda.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 407 | mda->update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 297 | 408 | } |
| 298 | 409 | } |
| 299 | 410 | |
| 300 | 411 | |
| 301 | 412 | static WRITE_LINE_DEVICE_HANDLER( mda_hsync_changed ) |
| 302 | 413 | { |
| 303 | | mda.hsync = state ? 1 : 0; |
| 414 | isa8_mda_device *mda = downcast<isa8_mda_device *>(device->owner()); |
| 415 | mda->hsync = state ? 1 : 0; |
| 304 | 416 | } |
| 305 | 417 | |
| 306 | 418 | |
| 307 | 419 | static WRITE_LINE_DEVICE_HANDLER( mda_vsync_changed ) |
| 308 | 420 | { |
| 309 | | mda.vsync = state ? 0x80 : 0; |
| 421 | isa8_mda_device *mda = downcast<isa8_mda_device *>(device->owner()); |
| 422 | mda->vsync = state ? 0x80 : 0; |
| 310 | 423 | if ( state ) |
| 311 | 424 | { |
| 312 | | mda.pc_framecnt++; |
| 425 | mda->framecnt++; |
| 313 | 426 | } |
| 314 | 427 | } |
| 315 | 428 | |
| r10666 | r10667 | |
| 317 | 430 | /* |
| 318 | 431 | * rW MDA mode control register (see #P138) |
| 319 | 432 | */ |
| 320 | | static void mda_mode_control_w(running_machine *machine, int data) |
| 433 | static WRITE8_DEVICE_HANDLER(mda_mode_control_w) |
| 321 | 434 | { |
| 435 | isa8_mda_device *mda = downcast<isa8_mda_device *>(device); |
| 322 | 436 | MDA_LOG(1,"MDA_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n", |
| 323 | 437 | data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1)); |
| 324 | | mda.mode_control = data; |
| 438 | mda->mode_control = data; |
| 325 | 439 | |
| 326 | | switch( mda.mode_control & 0x2a ) |
| 440 | switch( mda->mode_control & 0x2a ) |
| 327 | 441 | { |
| 328 | 442 | case 0x08: |
| 329 | | mda.update_row = mda_text_inten_update_row; |
| 443 | mda->update_row = mda_text_inten_update_row; |
| 330 | 444 | break; |
| 331 | 445 | case 0x28: |
| 332 | | mda.update_row = mda_text_blink_update_row; |
| 446 | mda->update_row = mda_text_blink_update_row; |
| 333 | 447 | break; |
| 334 | 448 | default: |
| 335 | | mda.update_row = NULL; |
| 449 | mda->update_row = NULL; |
| 336 | 450 | } |
| 337 | 451 | } |
| 338 | 452 | |
| r10666 | r10667 | |
| 348 | 462 | * 2-1 reserved |
| 349 | 463 | * 0 horizontal drive enable |
| 350 | 464 | */ |
| 351 | | static int pc_mda_status_r(void) |
| 465 | static READ8_DEVICE_HANDLER(mda_status_r) |
| 352 | 466 | { |
| 353 | | int data = 0x08 | mda.hsync; |
| 354 | | return data; |
| 467 | isa8_mda_device *mda = downcast<isa8_mda_device *>(device); |
| 468 | return 0x08 | mda->hsync; |
| 355 | 469 | } |
| 356 | 470 | |
| 357 | 471 | |
| r10666 | r10667 | |
| 361 | 475 | * monochrome display adapter |
| 362 | 476 | * |
| 363 | 477 | *************************************************************************/ |
| 364 | | WRITE8_HANDLER ( pc_MDA_w ) |
| 478 | WRITE8_DEVICE_HANDLER ( pc_MDA_w ) |
| 365 | 479 | { |
| 366 | | device_t *devconf = space->machine->device(MDA_MC6845_NAME); |
| 480 | device_t *devconf = device->subdevice(MDA_MC6845_NAME); |
| 367 | 481 | switch( offset ) |
| 368 | 482 | { |
| 369 | 483 | case 0: case 2: case 4: case 6: |
| r10666 | r10667 | |
| 373 | 487 | mc6845_register_w( devconf, offset, data ); |
| 374 | 488 | break; |
| 375 | 489 | case 8: |
| 376 | | mda_mode_control_w(space->machine, data); |
| 490 | mda_mode_control_w(device, offset, data); |
| 377 | 491 | break; |
| 378 | 492 | } |
| 379 | 493 | } |
| 380 | 494 | |
| 381 | | READ8_HANDLER ( pc_MDA_r ) |
| 495 | READ8_DEVICE_HANDLER ( pc_MDA_r ) |
| 382 | 496 | { |
| 383 | | device_t *devconf = space->machine->device(MDA_MC6845_NAME); |
| 384 | 497 | int data = 0xff; |
| 498 | device_t *devconf = device->subdevice(MDA_MC6845_NAME); |
| 385 | 499 | switch( offset ) |
| 386 | 500 | { |
| 387 | 501 | case 0: case 2: case 4: case 6: |
| r10666 | r10667 | |
| 391 | 505 | data = mc6845_register_r( devconf, offset ); |
| 392 | 506 | break; |
| 393 | 507 | case 10: |
| 394 | | data = pc_mda_status_r(); |
| 508 | data = mda_status_r(device, offset); |
| 395 | 509 | break; |
| 396 | 510 | /* 12, 13, 14 are the LPT1 ports */ |
| 397 | 511 | } |
| r10666 | r10667 | |
| 399 | 513 | } |
| 400 | 514 | |
| 401 | 515 | |
| 402 | | |
| 403 | 516 | /*************************************************************************** |
| 404 | 517 | |
| 405 | 518 | Hercules Display Adapter section (re-uses parts from the MDA section) |
| 406 | 519 | |
| 407 | 520 | ***************************************************************************/ |
| 408 | 521 | |
| 409 | | static VIDEO_START( pc_hercules ); |
| 410 | 522 | static SCREEN_UPDATE( mc6845_hercules ); |
| 411 | | static READ8_HANDLER( pc_hercules_r ); |
| 412 | | static WRITE8_HANDLER( pc_hercules_w ); |
| 523 | static READ8_DEVICE_HANDLER( hercules_r ); |
| 524 | static WRITE8_DEVICE_HANDLER( hercules_w ); |
| 413 | 525 | |
| 414 | 526 | /* |
| 415 | 527 | When the Hercules changes to graphics mode, the number of pixels per access and |
| r10666 | r10667 | |
| 433 | 545 | NULL |
| 434 | 546 | }; |
| 435 | 547 | |
| 548 | static GFXDECODE_START( pcherc ) |
| 549 | GFXDECODE_ENTRY( "hercules:gfx1", 0x0000, pc_16_charlayout, 1, 1 ) |
| 550 | GFXDECODE_END |
| 551 | |
| 436 | 552 | MACHINE_CONFIG_FRAGMENT( pcvideo_hercules ) |
| 437 | 553 | MCFG_SCREEN_ADD( HERCULES_SCREEN_NAME, RASTER) |
| 438 | 554 | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 439 | 555 | MCFG_SCREEN_RAW_PARAMS(MDA_CLOCK, 882, 0, 720, 370, 0, 350 ) |
| 440 | 556 | MCFG_SCREEN_UPDATE( mc6845_hercules ) |
| 441 | 557 | |
| 442 | | MCFG_PALETTE_LENGTH( sizeof(mda_palette) / 3 ) |
| 443 | | |
| 444 | | MCFG_PALETTE_INIT(pc_mda) |
| 445 | | |
| 446 | 558 | MCFG_MC6845_ADD( HERCULES_MC6845_NAME, MC6845, MDA_CLOCK/9, mc6845_hercules_intf) |
| 447 | 559 | |
| 448 | | MCFG_VIDEO_START( pc_hercules ) |
| 560 | MCFG_GFXDECODE(pcherc) |
| 449 | 561 | MACHINE_CONFIG_END |
| 450 | 562 | |
| 563 | ROM_START( hercules ) |
| 564 | ROM_REGION(0x1000,"gfx1", 0) |
| 565 | ROM_LOAD("um2301.bin", 0x00000, 0x1000, CRC(0827bdac) SHA1(15f1aceeee8b31f0d860ff420643e3c7f29b5ffc)) |
| 566 | ROM_END |
| 451 | 567 | |
| 452 | | static VIDEO_START( pc_hercules ) |
| 568 | //************************************************************************** |
| 569 | // GLOBAL VARIABLES |
| 570 | //************************************************************************** |
| 571 | |
| 572 | const device_type ISA8_HERCULES = isa8_hercules_device_config::static_alloc_device_config; |
| 573 | |
| 574 | //************************************************************************** |
| 575 | // DEVICE CONFIGURATION |
| 576 | //************************************************************************** |
| 577 | |
| 578 | //------------------------------------------------- |
| 579 | // isa8_mda_device_config - constructor |
| 580 | //------------------------------------------------- |
| 581 | |
| 582 | isa8_hercules_device_config::isa8_hercules_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 583 | : isa8_mda_device_config(mconfig, tag, owner, clock) |
| 453 | 584 | { |
| 585 | m_shortname = "hercules"; |
| 586 | } |
| 587 | |
| 588 | //------------------------------------------------- |
| 589 | // static_alloc_device_config - allocate a new |
| 590 | // configuration object |
| 591 | //------------------------------------------------- |
| 592 | |
| 593 | device_config *isa8_hercules_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock) |
| 594 | { |
| 595 | return global_alloc(isa8_hercules_device_config(mconfig, tag, owner, clock)); |
| 596 | } |
| 597 | |
| 598 | //------------------------------------------------- |
| 599 | // alloc_device - allocate a new device object |
| 600 | //------------------------------------------------- |
| 601 | |
| 602 | device_t *isa8_hercules_device_config::alloc_device(running_machine &machine) const |
| 603 | { |
| 604 | return auto_alloc(&machine, isa8_hercules_device(machine, *this)); |
| 605 | } |
| 606 | |
| 607 | //------------------------------------------------- |
| 608 | // machine_config_additions - device-specific |
| 609 | // machine configurations |
| 610 | //------------------------------------------------- |
| 611 | |
| 612 | machine_config_constructor isa8_hercules_device_config::machine_config_additions() const |
| 613 | { |
| 614 | return MACHINE_CONFIG_NAME( pcvideo_hercules ); |
| 615 | } |
| 616 | |
| 617 | //------------------------------------------------- |
| 618 | // rom_region - device-specific ROM region |
| 619 | //------------------------------------------------- |
| 620 | |
| 621 | const rom_entry *isa8_hercules_device_config::rom_region() const |
| 622 | { |
| 623 | return ROM_NAME( hercules ); |
| 624 | } |
| 625 | |
| 626 | //************************************************************************** |
| 627 | // LIVE DEVICE |
| 628 | //************************************************************************** |
| 629 | |
| 630 | //------------------------------------------------- |
| 631 | // isa8_hercules_device - constructor |
| 632 | //------------------------------------------------- |
| 633 | |
| 634 | isa8_hercules_device::isa8_hercules_device(running_machine &_machine, const isa8_hercules_device_config &config) : |
| 635 | isa8_mda_device(_machine, config), |
| 636 | m_config(config) |
| 637 | { |
| 638 | } |
| 639 | |
| 640 | //------------------------------------------------- |
| 641 | // device_start - device-specific startup |
| 642 | //------------------------------------------------- |
| 643 | |
| 644 | void isa8_hercules_device::device_start() |
| 645 | { |
| 454 | 646 | int buswidth; |
| 455 | 647 | address_space *space = cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_PROGRAM); |
| 456 | 648 | |
| 457 | 649 | buswidth = device_memory(machine->firstcpu)->space_config(AS_PROGRAM)->m_databus_width; |
| 458 | 650 | switch(buswidth) |
| 459 | 651 | { |
| 460 | | case 8: |
| 461 | | memory_install_readwrite_bank(space, 0xb0000, 0xbffff, 0, 0, "bank11" ); |
| 462 | | memory_install_read8_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), 0x3b0, 0x3bf, 0, 0, pc_hercules_r ); |
| 463 | | memory_install_write8_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), 0x3b0, 0x3bf, 0, 0, pc_hercules_w ); |
| 464 | | break; |
| 652 | case 8: |
| 653 | memory_install_readwrite_bank(space, 0xb0000, 0xbffff, 0, 0, "bank_hercules" ); |
| 654 | memory_install_readwrite8_device_handler(cpu_get_address_space(machine->firstcpu, ADDRESS_SPACE_IO), this, 0x3b0, 0x3bf, 0, 0, hercules_r, hercules_w ); |
| 655 | break; |
| 465 | 656 | |
| 466 | | default: |
| 467 | | fatalerror("Hercules: Bus width %d not supported", buswidth); |
| 468 | | break; |
| 657 | default: |
| 658 | fatalerror("MDA: Bus width %d not supported", buswidth); |
| 659 | break; |
| 469 | 660 | } |
| 470 | 661 | |
| 471 | | memset( &mda, 0, sizeof(mda)); |
| 472 | | mda.update_row = NULL; |
| 473 | | mda.chr_gen = machine->region( "gfx1" )->base(); |
| 662 | videoram = auto_alloc_array(machine, UINT8, 0x10000); |
| 663 | |
| 664 | memory_set_bankptr(machine,"bank_hercules", videoram); |
| 474 | 665 | |
| 475 | | mda.videoram = auto_alloc_array(machine, UINT8, 0x10000); |
| 476 | | memory_set_bankptr(machine,"bank11", mda.videoram); |
| 666 | /* Initialise the mda palette */ |
| 667 | for(int i = 0; i < (sizeof(mda_palette) / 3); i++) |
| 668 | palette_set_color_rgb(machine, i, mda_palette[i][0], mda_palette[i][1], mda_palette[i][2]); |
| 477 | 669 | } |
| 670 | |
| 671 | //------------------------------------------------- |
| 672 | // device_reset - device-specific reset |
| 673 | //------------------------------------------------- |
| 674 | |
| 675 | void isa8_hercules_device::device_reset() |
| 676 | { |
| 677 | isa8_mda_device::device_reset(); |
| 678 | configuration_switch = 0; |
| 478 | 679 | |
| 680 | astring tempstring; |
| 681 | chr_gen = machine->region(subtag(tempstring, "gfx1"))->base(); |
| 682 | } |
| 479 | 683 | |
| 480 | 684 | /*************************************************************************** |
| 481 | 685 | Draw graphics with 720x348 pixels (default); so called Hercules gfx. |
| r10666 | r10667 | |
| 486 | 690 | |
| 487 | 691 | static MC6845_UPDATE_ROW( hercules_gfx_update_row ) |
| 488 | 692 | { |
| 489 | | UINT8 *videoram = mda.videoram; |
| 693 | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device->owner()); |
| 490 | 694 | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 491 | | UINT16 gfx_base = ( ( mda.mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 ); |
| 695 | UINT16 gfx_base = ( ( herc->mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 ); |
| 492 | 696 | int i; |
| 493 | | running_machine *machine = device->machine; |
| 494 | | |
| 495 | 697 | if ( y == 0 ) MDA_LOG(1,"hercules_gfx_update_row",("\n")); |
| 496 | 698 | for ( i = 0; i < x_count; i++ ) |
| 497 | 699 | { |
| 498 | | UINT8 data = videoram[ gfx_base + ( ( ma + i ) << 1 ) ]; |
| 700 | UINT8 data = herc->videoram[ gfx_base + ( ( ma + i ) << 1 ) ]; |
| 499 | 701 | |
| 500 | 702 | *p = ( data & 0x80 ) ? 2 : 0; p++; |
| 501 | 703 | *p = ( data & 0x40 ) ? 2 : 0; p++; |
| r10666 | r10667 | |
| 506 | 708 | *p = ( data & 0x02 ) ? 2 : 0; p++; |
| 507 | 709 | *p = ( data & 0x01 ) ? 2 : 0; p++; |
| 508 | 710 | |
| 509 | | data = videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ]; |
| 711 | data = herc->videoram[ gfx_base + ( ( ma + i ) << 1 ) + 1 ]; |
| 510 | 712 | |
| 511 | 713 | *p = ( data & 0x80 ) ? 2 : 0; p++; |
| 512 | 714 | *p = ( data & 0x40 ) ? 2 : 0; p++; |
| r10666 | r10667 | |
| 522 | 724 | |
| 523 | 725 | static SCREEN_UPDATE( mc6845_hercules ) |
| 524 | 726 | { |
| 525 | | device_t *devconf = screen->machine->device(HERCULES_MC6845_NAME); |
| 727 | device_t *devconf = screen->owner()->subdevice(HERCULES_MC6845_NAME); |
| 728 | |
| 526 | 729 | mc6845_update( devconf, bitmap, cliprect ); |
| 527 | 730 | return 0; |
| 528 | 731 | } |
| 529 | 732 | |
| 530 | 733 | |
| 531 | | static void hercules_mode_control_w(running_machine *machine, int data) |
| 734 | static WRITE8_DEVICE_HANDLER(hercules_mode_control_w) |
| 532 | 735 | { |
| 533 | | device_t *devconf = machine->device(HERCULES_MC6845_NAME); |
| 736 | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device->owner()); |
| 534 | 737 | |
| 535 | 738 | MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n", |
| 536 | 739 | data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1)); |
| 537 | | mda.mode_control = data; |
| 740 | herc->mode_control = data; |
| 538 | 741 | |
| 539 | | switch( mda.mode_control & 0x2a ) |
| 742 | switch( herc->mode_control & 0x2a ) |
| 540 | 743 | { |
| 541 | 744 | case 0x08: |
| 542 | | mda.update_row = mda_text_inten_update_row; |
| 745 | herc->update_row = mda_text_inten_update_row; |
| 543 | 746 | break; |
| 544 | 747 | case 0x28: |
| 545 | | mda.update_row = mda_text_blink_update_row; |
| 748 | herc->update_row = mda_text_blink_update_row; |
| 546 | 749 | break; |
| 547 | 750 | case 0x0A: /* Hercules modes */ |
| 548 | 751 | case 0x2A: |
| 549 | | mda.update_row = hercules_gfx_update_row; |
| 752 | herc->update_row = hercules_gfx_update_row; |
| 550 | 753 | break; |
| 551 | 754 | default: |
| 552 | | mda.update_row = NULL; |
| 755 | herc->update_row = NULL; |
| 553 | 756 | } |
| 554 | 757 | |
| 555 | | mc6845_set_clock( devconf, mda.mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 ); |
| 556 | | mc6845_set_hpixels_per_column( devconf, mda.mode_control & 0x02 ? 16 : 9 ); |
| 758 | mc6845_set_clock( device, herc->mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 ); |
| 759 | mc6845_set_hpixels_per_column( device, herc->mode_control & 0x02 ? 16 : 9 ); |
| 557 | 760 | } |
| 558 | 761 | |
| 559 | 762 | |
| 560 | | static void hercules_config_w(running_machine *machine, int data) |
| 763 | static WRITE8_DEVICE_HANDLER(hercules_config_w) |
| 561 | 764 | { |
| 765 | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device); |
| 562 | 766 | MDA_LOG(1,"HGC_config_w",("$%02x\n", data)); |
| 563 | | mda.configuration_switch = data; |
| 767 | herc->configuration_switch = data; |
| 564 | 768 | } |
| 565 | 769 | |
| 566 | 770 | |
| 567 | | static WRITE8_HANDLER ( pc_hercules_w ) |
| 771 | static WRITE8_DEVICE_HANDLER ( hercules_w ) |
| 568 | 772 | { |
| 569 | | device_t *devconf = space->machine->device(HERCULES_MC6845_NAME); |
| 570 | | |
| 773 | device_t *devconf = device->subdevice(HERCULES_MC6845_NAME); |
| 571 | 774 | switch( offset ) |
| 572 | 775 | { |
| 573 | 776 | case 0: case 2: case 4: case 6: |
| r10666 | r10667 | |
| 577 | 780 | mc6845_register_w( devconf, offset, data ); |
| 578 | 781 | break; |
| 579 | 782 | case 8: |
| 580 | | hercules_mode_control_w(space->machine, data); |
| 783 | hercules_mode_control_w(devconf, offset, data); |
| 581 | 784 | break; |
| 582 | 785 | case 15: |
| 583 | | hercules_config_w(space->machine, data); |
| 786 | hercules_config_w(device, offset, data); |
| 584 | 787 | break; |
| 585 | 788 | } |
| 586 | 789 | } |
| r10666 | r10667 | |
| 597 | 800 | * 2-1 reserved |
| 598 | 801 | * 0 horizontal drive enable |
| 599 | 802 | */ |
| 600 | | static int pc_hercules_status_r(void) |
| 803 | static READ8_DEVICE_HANDLER(hercules_status_r) |
| 601 | 804 | { |
| 602 | | int data = mda.vsync | 0x08 | mda.hsync; |
| 603 | | return data; |
| 805 | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device); |
| 806 | return herc->vsync | 0x08 | herc->hsync; |
| 604 | 807 | } |
| 605 | 808 | |
| 606 | 809 | |
| 607 | | static READ8_HANDLER ( pc_hercules_r ) |
| 810 | static READ8_DEVICE_HANDLER ( hercules_r ) |
| 608 | 811 | { |
| 609 | | device_t *devconf = space->machine->device(HERCULES_MC6845_NAME); |
| 610 | 812 | int data = 0xff; |
| 611 | | |
| 813 | device_t *devconf = device->subdevice(HERCULES_MC6845_NAME); |
| 612 | 814 | switch( offset ) |
| 613 | 815 | { |
| 614 | 816 | case 0: case 2: case 4: case 6: |
| r10666 | r10667 | |
| 618 | 820 | data = mc6845_register_r( devconf, offset ); |
| 619 | 821 | break; |
| 620 | 822 | case 10: |
| 621 | | data = pc_hercules_status_r(); |
| 823 | data = hercules_status_r(device, offset); |
| 622 | 824 | break; |
| 623 | 825 | /* 12, 13, 14 are the LPT1 ports */ |
| 624 | 826 | } |
| 625 | 827 | return data; |
| 626 | 828 | } |
| 627 | | |