src/mess/machine/gamecom.c
| r8932 | r8933 | |
| 68 | 68 | |
| 69 | 69 | static const int gamecom_timer_limit[8] = { 2, 1024, 2048, 4096, 8192, 16384, 32768, 65536 }; |
| 70 | 70 | |
| 71 | | static void gamecom_dma_init(running_machine *machine); |
| 72 | | |
| 73 | 71 | static TIMER_CALLBACK(gamecom_clock_timer_callback) |
| 74 | 72 | { |
| 75 | 73 | UINT8 * RAM = memory_region(machine, "maincpu"); |
| r8932 | r8933 | |
| 87 | 85 | memory_set_bankptr( machine, "bank4", rom ); |
| 88 | 86 | |
| 89 | 87 | cartridge = NULL; |
| 90 | | /* disable DMA and timer */ |
| 91 | | gamecom_dma.enabled = 0; |
| 92 | 88 | } |
| 93 | 89 | |
| 94 | 90 | static void gamecom_set_mmu( running_machine *machine, int mmu, UINT8 data ) |
| r8932 | r8933 | |
| 136 | 132 | } |
| 137 | 133 | else |
| 138 | 134 | { |
| 139 | | RAM[SM8521_P0] = 0xfe | (RAM[SM8521_CLKT]&1); |
| 135 | RAM[SM8521_P0] = 0xFF; |
| 140 | 136 | RAM[SM8521_P1] = ( RAM[SM8521_P1] & 0xFC ) | 3; |
| 141 | 137 | } |
| 142 | 138 | } |
| r8932 | r8933 | |
| 277 | 273 | break; |
| 278 | 274 | |
| 279 | 275 | /* Video hardware and DMA */ |
| 280 | | case SM8521_LCDC: |
| 281 | | // logerror( "%X: Setting LCDC to %X\n", activecpu_get_pc(), data ); |
| 282 | | break; |
| 283 | | case SM8521_LCH: |
| 284 | | break; |
| 285 | | case SM8521_LCV: |
| 286 | | break; |
| 287 | | case SM8521_DMC: |
| 288 | | gamecom_dma.overwrite_mode = data & 0x01; |
| 289 | | gamecom_dma.transfer_mode = data & 0x06; |
| 290 | | gamecom_dma.decrement_x = data & 0x08; |
| 291 | | gamecom_dma.decrement_y = data & 0x10; |
| 292 | | gamecom_dma.enabled = data & 0x80; |
| 293 | | if ( gamecom_dma.enabled ) |
| 294 | | { |
| 295 | | gamecom_dma_init(space->machine); |
| 296 | | } |
| 297 | | break; |
| 298 | | case SM8521_DMX1: |
| 299 | | break; |
| 300 | | case SM8521_DMY1: |
| 301 | | break; |
| 302 | | case SM8521_DMDX: |
| 303 | | break; |
| 304 | | case SM8521_DMDY: |
| 305 | | break; |
| 306 | | case SM8521_DMX2: |
| 307 | | break; |
| 308 | | case SM8521_DMY2: |
| 309 | | break; |
| 310 | | case SM8521_DMPL: |
| 311 | | break; |
| 312 | 276 | case SM8521_DMBR: |
| 313 | 277 | data &= 0x7f; |
| 314 | 278 | break; |
| 315 | | case SM8521_DMVP: |
| 316 | | break; |
| 317 | 279 | case SM8521_TM0D: |
| 318 | 280 | gamecom_timer[0].check_value = data; |
| 319 | 281 | return; |
| r8932 | r8933 | |
| 445 | 407 | |
| 446 | 408 | /* The manual is not conclusive as to which bit of the DMVP register (offset 0x3D) determines |
| 447 | 409 | which page for source or destination is used */ |
| 448 | | static void gamecom_dma_init(running_machine *machine) |
| 410 | /* For now the increment/decrement-x and increment/decrement-y parts are NOT supported. |
| 411 | Their usage is also not explained properly in the manuals. Guess we'll have to wait |
| 412 | for them to show up in some rom images... |
| 413 | */ |
| 414 | void gamecom_handle_dma( running_device *device, int cycles ) |
| 449 | 415 | { |
| 450 | | UINT8 * RAM = memory_region(machine, "maincpu"); |
| 416 | UINT8 * RAM = memory_region(device->machine, "maincpu"); |
| 417 | UINT8 data = RAM[SM8521_DMC]; |
| 418 | gamecom_dma.overwrite_mode = data & 0x01; |
| 419 | gamecom_dma.transfer_mode = data & 0x06; |
| 420 | gamecom_dma.decrement_x = data & 0x08; |
| 421 | gamecom_dma.decrement_y = data & 0x10; |
| 422 | gamecom_dma.enabled = data & 0x80; |
| 423 | if ( !gamecom_dma.enabled ) return; |
| 424 | |
| 425 | |
| 451 | 426 | if ( gamecom_dma.decrement_x || gamecom_dma.decrement_y ) |
| 452 | 427 | { |
| 453 | 428 | logerror( "TODO: Decrement-x and decrement-y are not supported yet\n" ); |
| r8932 | r8933 | |
| 486 | 461 | gamecom_dma.source_mask = 0x3FFF; |
| 487 | 462 | if ( RAM[SM8521_DMBR] < 16 ) |
| 488 | 463 | { |
| 489 | | gamecom_dma.source_bank = memory_region(machine, "kernel") + (RAM[SM8521_DMBR] << 14); |
| 464 | gamecom_dma.source_bank = memory_region(device->machine, "kernel") + (RAM[SM8521_DMBR] << 14); |
| 490 | 465 | } |
| 491 | 466 | else |
| 492 | 467 | { |
| r8932 | r8933 | |
| 515 | 490 | gamecom_dma.source_line = gamecom_dma.source_current; |
| 516 | 491 | gamecom_dma.dest_line = gamecom_dma.dest_current; |
| 517 | 492 | gamecom_dma.state_count = 0; |
| 518 | | } |
| 519 | 493 | |
| 520 | | /* For now the increment/decrement-x and increment/decrement-y parts are NOT supported. |
| 521 | | Their usage is also not explained properly in the manuals. Guess we'll have to wait |
| 522 | | for them to show up in some rom images... |
| 523 | | */ |
| 524 | | void gamecom_handle_dma( running_device *device, int cycles ) |
| 525 | | { |
| 526 | 494 | unsigned y_count, x_count; |
| 527 | | /* If not enabled, ignore */ |
| 528 | | if ( ! gamecom_dma.enabled ) |
| 529 | | { |
| 530 | | return; |
| 531 | | } |
| 495 | |
| 532 | 496 | for( y_count = 0; y_count <= gamecom_dma.width_y; y_count++ ) |
| 533 | 497 | { |
| 534 | 498 | for( x_count = 0; x_count <= gamecom_dma.width_x; x_count++ ) |