src/mess/video/wswan.c
| r1902 | r1903 | |
| 9 | 9 | |
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 | #include "driver.h" |
| 12 | | #include "deprecat.h" |
| 13 | 12 | #include "includes/wswan.h" |
| 14 | 13 | |
| 15 | 14 | static int pal[16][16]; |
| r1902 | r1903 | |
| 67 | 66 | } |
| 68 | 67 | } |
| 69 | 68 | |
| 70 | | static void wswan_draw_background(void) { |
| 69 | static void wswan_draw_background( running_machine *machine ) { |
| 71 | 70 | UINT16 map_addr; |
| 72 | 71 | UINT8 start_column; |
| 73 | 72 | int column; |
| r1902 | r1903 | |
| 137 | 136 | if ( vdp.colors_16 ) { |
| 138 | 137 | if ( col ) { |
| 139 | 138 | if ( vdp.color_mode ) { |
| 140 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 139 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 141 | 140 | } else { |
| 142 | 141 | /* Hmmmm, what should we do here... Is this correct?? */ |
| 143 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 142 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 144 | 143 | } |
| 145 | 144 | } |
| 146 | 145 | } else { |
| 147 | 146 | if ( col || !(tile_palette & 4 ) ) { |
| 148 | 147 | if ( vdp.color_mode ) { |
| 149 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 148 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 150 | 149 | } else { |
| 151 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 150 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 152 | 151 | } |
| 153 | 152 | } |
| 154 | 153 | } |
| r1902 | r1903 | |
| 157 | 156 | } |
| 158 | 157 | } |
| 159 | 158 | |
| 160 | | static void wswan_draw_foreground_0( void ) { |
| 159 | static void wswan_draw_foreground_0( running_machine *machine ) { |
| 161 | 160 | UINT16 map_addr; |
| 162 | 161 | UINT8 start_column; |
| 163 | 162 | int column; |
| r1902 | r1903 | |
| 224 | 223 | if ( vdp.colors_16 ) { |
| 225 | 224 | if ( col ) { |
| 226 | 225 | // if ( vdp.color_mode ) { |
| 227 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 226 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 228 | 227 | // } else { |
| 229 | 228 | // /* Hmmmm, what should we do here... Is this correct?? */ |
| 230 | | // wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 229 | // wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 231 | 230 | // } |
| 232 | 231 | } |
| 233 | 232 | } else { |
| 234 | 233 | if ( col || !(tile_palette & 4 ) ) { |
| 235 | 234 | if ( vdp.color_mode ) { |
| 236 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 235 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 237 | 236 | } else { |
| 238 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 237 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 239 | 238 | } |
| 240 | 239 | } |
| 241 | 240 | } |
| r1902 | r1903 | |
| 244 | 243 | } |
| 245 | 244 | } |
| 246 | 245 | |
| 247 | | static void wswan_draw_foreground_2( void ) { |
| 246 | static void wswan_draw_foreground_2( running_machine *machine ) { |
| 248 | 247 | UINT16 map_addr; |
| 249 | 248 | UINT8 start_column; |
| 250 | 249 | int column; |
| r1902 | r1903 | |
| 311 | 310 | if ( vdp.colors_16 ) { |
| 312 | 311 | if ( col ) { |
| 313 | 312 | if ( vdp.color_mode ) { |
| 314 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 313 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 315 | 314 | } else { |
| 316 | 315 | /* Hmmmm, what should we do here... Is this correct?? */ |
| 317 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 316 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 318 | 317 | } |
| 319 | 318 | } |
| 320 | 319 | } else { |
| 321 | 320 | if ( col || !(tile_palette & 4 ) ) { |
| 322 | 321 | if ( vdp.color_mode ) { |
| 323 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 322 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 324 | 323 | } else { |
| 325 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 324 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 326 | 325 | } |
| 327 | 326 | } |
| 328 | 327 | } |
| r1902 | r1903 | |
| 331 | 330 | } |
| 332 | 331 | } |
| 333 | 332 | |
| 334 | | static void wswan_draw_foreground_3( void ) { |
| 333 | static void wswan_draw_foreground_3( running_machine *machine ) { |
| 335 | 334 | UINT16 map_addr; |
| 336 | 335 | UINT8 start_column; |
| 337 | 336 | int column; |
| r1902 | r1903 | |
| 398 | 397 | if ( vdp.colors_16 ) { |
| 399 | 398 | if ( col ) { |
| 400 | 399 | if ( vdp.color_mode ) { |
| 401 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 400 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 402 | 401 | } else { |
| 403 | 402 | /* Hmmmm, what should we do here... Is this correct?? */ |
| 404 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 403 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 405 | 404 | } |
| 406 | 405 | } |
| 407 | 406 | } else { |
| 408 | 407 | if ( col || !(tile_palette & 4 ) ) { |
| 409 | 408 | if ( vdp.color_mode ) { |
| 410 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 409 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 411 | 410 | } else { |
| 412 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 411 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 413 | 412 | } |
| 414 | 413 | } |
| 415 | 414 | } |
| r1902 | r1903 | |
| 418 | 417 | } |
| 419 | 418 | } |
| 420 | 419 | |
| 421 | | static void wswan_handle_sprites( int mask ) { |
| 420 | static void wswan_handle_sprites( running_machine *machine, int mask ) { |
| 422 | 421 | int i; |
| 423 | 422 | if ( vdp.sprite_count == 0 ) |
| 424 | 423 | return; |
| r1902 | r1903 | |
| 515 | 514 | if ( vdp.colors_16 ) { |
| 516 | 515 | if ( col ) { |
| 517 | 516 | if ( vdp.color_mode ) { |
| 518 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 517 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 519 | 518 | } else { |
| 520 | 519 | /* Hmmmm, what should we do here... Is this correct?? */ |
| 521 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 520 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 522 | 521 | } |
| 523 | 522 | } |
| 524 | 523 | } else { |
| 525 | 524 | if ( col || !(tile_palette & 4 ) ) { |
| 526 | 525 | if ( vdp.color_mode ) { |
| 527 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[pal[tile_palette][col]] ); |
| 526 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[pal[tile_palette][col]] ); |
| 528 | 527 | } else { |
| 529 | | wswan_plot_pixel( x_offset, vdp.current_line, Machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 528 | wswan_plot_pixel( x_offset, vdp.current_line, machine->pens[vdp.main_palette[pal[tile_palette][col]]] ); |
| 530 | 529 | } |
| 531 | 530 | } |
| 532 | 531 | } |
| r1902 | r1903 | |
| 536 | 535 | } |
| 537 | 536 | } |
| 538 | 537 | |
| 539 | | void wswan_refresh_scanline(void) |
| 538 | void wswan_refresh_scanline( running_machine *machine ) |
| 540 | 539 | { |
| 541 | 540 | rectangle rec; |
| 542 | 541 | |
| r1902 | r1903 | |
| 548 | 547 | if ( ws_portram[0x14] ) { |
| 549 | 548 | /* Not sure if these background color checks and settings are correct */ |
| 550 | 549 | if ( vdp.color_mode && vdp.colors_16 ) { |
| 551 | | wswan_fillbitmap( Machine->pens[ pal[ws_portram[0x01]>>4][ws_portram[0x01]&0x0F] ], &rec ); |
| 550 | wswan_fillbitmap( machine->pens[ pal[ws_portram[0x01]>>4][ws_portram[0x01]&0x0F] ], &rec ); |
| 552 | 551 | } else { |
| 553 | | wswan_fillbitmap( Machine->pens[ vdp.main_palette[ws_portram[0x01]&0x07] ], &rec ); |
| 552 | wswan_fillbitmap( machine->pens[ vdp.main_palette[ws_portram[0x01]&0x07] ], &rec ); |
| 554 | 553 | } |
| 555 | 554 | } else { |
| 556 | | wswan_fillbitmap( Machine->pens[ 0 ], &rec ); |
| 555 | wswan_fillbitmap( machine->pens[ 0 ], &rec ); |
| 557 | 556 | return; |
| 558 | 557 | } |
| 559 | 558 | |
| r1902 | r1903 | |
| 561 | 560 | * Draw background layer |
| 562 | 561 | */ |
| 563 | 562 | if ( vdp.layer_bg_enable ) { |
| 564 | | wswan_draw_background(); |
| 563 | wswan_draw_background( machine ); |
| 565 | 564 | } |
| 566 | 565 | |
| 567 | 566 | /* |
| 568 | 567 | * Draw sprites between background and foreground layers |
| 569 | 568 | */ |
| 570 | 569 | if ( vdp.sprites_enable ) { |
| 571 | | wswan_handle_sprites( 0 ); |
| 570 | wswan_handle_sprites( machine, 0 ); |
| 572 | 571 | } |
| 573 | 572 | |
| 574 | 573 | /* |
| r1902 | r1903 | |
| 577 | 576 | if ( vdp.layer_fg_enable ) { |
| 578 | 577 | switch( vdp.window_fg_mode ) { |
| 579 | 578 | case 0: /* FG inside & outside window area */ |
| 580 | | wswan_draw_foreground_0(); |
| 579 | wswan_draw_foreground_0( machine ); |
| 581 | 580 | break; |
| 582 | 581 | case 1: /* ??? */ |
| 583 | 582 | logerror( "Unknown foreground mode 1 set\n" ); |
| 584 | 583 | break; |
| 585 | 584 | case 2: /* FG only inside window area */ |
| 586 | 585 | if ( vdp.current_line >= vdp.window_fg_top && vdp.current_line <= vdp.window_fg_bottom ) { |
| 587 | | wswan_draw_foreground_2(); |
| 586 | wswan_draw_foreground_2( machine ); |
| 588 | 587 | } |
| 589 | 588 | break; |
| 590 | 589 | case 3: /* FG only outside window area */ |
| 591 | 590 | if ( vdp.current_line < vdp.window_fg_top || vdp.current_line > vdp.window_fg_bottom ) { |
| 592 | | wswan_draw_foreground_0(); |
| 591 | wswan_draw_foreground_0( machine ); |
| 593 | 592 | } else { |
| 594 | | wswan_draw_foreground_3(); |
| 593 | wswan_draw_foreground_3( machine ); |
| 595 | 594 | } |
| 596 | 595 | break; |
| 597 | 596 | } |
| r1902 | r1903 | |
| 601 | 600 | * Draw sprites in front of foreground layer |
| 602 | 601 | */ |
| 603 | 602 | if ( vdp.sprites_enable ) { |
| 604 | | wswan_handle_sprites( 0x2000 ); |
| 603 | wswan_handle_sprites( machine, 0x2000 ); |
| 605 | 604 | } |
| 606 | 605 | } |
| 607 | 606 | |
src/mess/machine/wswan.c
| r1902 | r1903 | |
| 16 | 16 | ***************************************************************************/ |
| 17 | 17 | |
| 18 | 18 | #include "driver.h" |
| 19 | | #include "deprecat.h" |
| 20 | 19 | #include "includes/wswan.h" |
| 21 | 20 | #include "image.h" |
| 22 | 21 | |
| r1902 | r1903 | |
| 125 | 124 | 0xea, 0xc0, 0xff, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 |
| 126 | 125 | }; |
| 127 | 126 | |
| 128 | | static void wswan_handle_irqs( void ) { |
| 127 | static void wswan_handle_irqs( running_machine *machine ) { |
| 129 | 128 | if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_HBLTMR ) { |
| 130 | | cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_HBLTMR ); |
| 129 | cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_HBLTMR ); |
| 131 | 130 | } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_VBL ) { |
| 132 | | cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_VBL ); |
| 131 | cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_VBL ); |
| 133 | 132 | } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_VBLTMR ) { |
| 134 | | cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_VBLTMR ); |
| 133 | cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_VBLTMR ); |
| 135 | 134 | } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_LCMP ) { |
| 136 | | cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_LCMP ); |
| 135 | cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_LCMP ); |
| 137 | 136 | } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_SRX ) { |
| 138 | | cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_SRX ); |
| 137 | cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_SRX ); |
| 139 | 138 | } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_RTC ) { |
| 140 | | cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_RTC ); |
| 139 | cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_RTC ); |
| 141 | 140 | } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_KEY ) { |
| 142 | | cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_KEY ); |
| 141 | cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_KEY ); |
| 143 | 142 | } else if ( ws_portram[0xb2] & ws_portram[0xb6] & WSWAN_IFLAG_STX ) { |
| 144 | | cpunum_set_input_line_and_vector( Machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_STX ); |
| 143 | cpunum_set_input_line_and_vector( machine, 0, 0, HOLD_LINE, ws_portram[0xb0] + WSWAN_INT_STX ); |
| 145 | 144 | } else { |
| 146 | | cpunum_set_input_line(Machine, 0, 0, CLEAR_LINE ); |
| 145 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE ); |
| 147 | 146 | } |
| 148 | 147 | } |
| 149 | 148 | |
| 150 | | static void wswan_set_irq_line(int irq) { |
| 149 | static void wswan_set_irq_line( running_machine *machine, int irq) { |
| 151 | 150 | if ( ws_portram[0xb2] & irq ) { |
| 152 | 151 | ws_portram[0xb6] |= irq; |
| 153 | | wswan_handle_irqs(); |
| 152 | wswan_handle_irqs( machine ); |
| 154 | 153 | } |
| 155 | 154 | } |
| 156 | 155 | |
| 157 | | static void wswan_clear_irq_line(int irq) { |
| 156 | static void wswan_clear_irq_line( running_machine *machine, int irq) { |
| 158 | 157 | ws_portram[0xb6] &= ~irq; |
| 159 | | wswan_handle_irqs(); |
| 158 | wswan_handle_irqs( machine ); |
| 160 | 159 | } |
| 161 | 160 | |
| 162 | 161 | static TIMER_CALLBACK(wswan_rtc_callback) |
| r1902 | r1903 | |
| 963 | 962 | Bit 6 - VBlank interrupt acknowledge |
| 964 | 963 | Bit 7 - HBlank timer interrupt acknowledge |
| 965 | 964 | */ |
| 966 | | wswan_clear_irq_line( data ); |
| 965 | wswan_clear_irq_line( machine, data ); |
| 967 | 966 | data = ws_portram[0xB6]; |
| 968 | 967 | break; |
| 969 | 968 | case 0xba: /* Internal EEPROM data (low) |
| r1902 | r1903 | |
| 1357 | 1356 | INTERRUPT_GEN(wswan_scanline_interrupt) |
| 1358 | 1357 | { |
| 1359 | 1358 | if( vdp.current_line < 144 ) { |
| 1360 | | wswan_refresh_scanline(); |
| 1359 | wswan_refresh_scanline( machine ); |
| 1361 | 1360 | } |
| 1362 | 1361 | |
| 1363 | 1362 | /* Decrement 12kHz (HBlank) counter */ |
| r1902 | r1903 | |
| 1371 | 1370 | vdp.timer_hblank_reload = 0; |
| 1372 | 1371 | } |
| 1373 | 1372 | logerror( "trigerring hbltmr interrupt\n" ); |
| 1374 | | wswan_set_irq_line( WSWAN_IFLAG_HBLTMR ); |
| 1373 | wswan_set_irq_line( machine, WSWAN_IFLAG_HBLTMR ); |
| 1375 | 1374 | } |
| 1376 | 1375 | } |
| 1377 | 1376 | |
| r1902 | r1903 | |
| 1389 | 1388 | // vdp.current_line = (vdp.current_line + 1) % 159; |
| 1390 | 1389 | |
| 1391 | 1390 | if( vdp.current_line == 144 ) { |
| 1392 | | wswan_set_irq_line( WSWAN_IFLAG_VBL ); |
| 1391 | wswan_set_irq_line( machine, WSWAN_IFLAG_VBL ); |
| 1393 | 1392 | /* Decrement 75Hz (VBlank) counter */ |
| 1394 | 1393 | if ( vdp.timer_vblank_enable && vdp.timer_vblank_reload != 0 ) { |
| 1395 | 1394 | vdp.timer_vblank_count--; |
| r1902 | r1903 | |
| 1401 | 1400 | vdp.timer_vblank_reload = 0; |
| 1402 | 1401 | } |
| 1403 | 1402 | logerror( "triggering vbltmr interrupt\n" ); |
| 1404 | | wswan_set_irq_line( WSWAN_IFLAG_VBLTMR ); |
| 1403 | wswan_set_irq_line( machine, WSWAN_IFLAG_VBLTMR ); |
| 1405 | 1404 | } |
| 1406 | 1405 | } |
| 1407 | 1406 | } |
| r1902 | r1903 | |
| 1409 | 1408 | // vdp.current_line = (vdp.current_line + 1) % 159; |
| 1410 | 1409 | |
| 1411 | 1410 | if ( vdp.current_line == vdp.line_compare ) { |
| 1412 | | wswan_set_irq_line( WSWAN_IFLAG_LCMP ); |
| 1411 | wswan_set_irq_line( machine, WSWAN_IFLAG_LCMP ); |
| 1413 | 1412 | } |
| 1414 | 1413 | |
| 1415 | 1414 | vdp.current_line = (vdp.current_line + 1) % 159; |