src/mess/video/smsvdp.c
| r6981 | r6982 | |
| 59 | 59 | #define STATUS_SPRCOL 0x20 /* Object collision flag */ |
| 60 | 60 | #define STATUS_HINT 0x02 /* Pending horizontal interrupt flag */ |
| 61 | 61 | |
| 62 | | #define HINT_HPOS 24 |
| 63 | | #define VINT_HPOS 1 /* docs says should be near HINT time */ |
| 62 | #define VINT_HPOS 23 |
| 63 | #define HINT_HPOS 23 |
| 64 | #define VCOUNT_CHANGE_HPOS 22 |
| 65 | #define VINT_FLAG_HPOS 7 |
| 66 | #define SPROVR_HPOS 6 |
| 67 | #define SPRCOL_BASEHPOS 42 |
| 68 | #define DISPLAY_CB_HPOS 5 /* fix X-Scroll latchtime (Flubba's VDPTest) */ |
| 64 | 69 | |
| 65 | 70 | #define GG_CRAM_SIZE 0x40 /* 32 colors x 2 bytes per color = 64 bytes */ |
| 66 | 71 | #define SMS_CRAM_SIZE 0x20 /* 32 colors x 1 bytes per color = 32 bytes */ |
| r6981 | r6982 | |
| 106 | 111 | int irq_state; /* The status of the IRQ line of the VDP */ |
| 107 | 112 | int vdp_mode; /* Current mode of the VDP: 0,1,2,3,4 */ |
| 108 | 113 | int y_pixels; /* 192, 224, 240 */ |
| 109 | | int line_counter; |
| 114 | UINT8 line_counter; |
| 110 | 115 | UINT8 hcounter; |
| 111 | 116 | UINT8 *VRAM; /* Pointer to VRAM */ |
| 112 | 117 | UINT8 *CRAM; /* Pointer to CRAM */ |
| r6981 | r6982 | |
| 230 | 235 | READ8_DEVICE_HANDLER( sms_vdp_vcount_r ) |
| 231 | 236 | { |
| 232 | 237 | smsvdp_t *smsvdp = get_safe_token(device); |
| 238 | int vpos = video_screen_get_vpos(device->machine->primary_screen); |
| 233 | 239 | |
| 234 | | return (smsvdp->sms_frame_timing[INIT_VCOUNT] + video_screen_get_vpos(device->machine->primary_screen)) & 0xff; |
| 240 | if (video_screen_get_hpos(device->machine->primary_screen) < VCOUNT_CHANGE_HPOS) |
| 241 | { |
| 242 | vpos--; |
| 243 | if (vpos < 0) |
| 244 | vpos += video_screen_get_height(device->machine->primary_screen); |
| 245 | } |
| 246 | |
| 247 | return (smsvdp->sms_frame_timing[INIT_VCOUNT] + vpos) & 0xff; |
| 235 | 248 | } |
| 236 | 249 | |
| 237 | 250 | |
| r6981 | r6982 | |
| 259 | 272 | } |
| 260 | 273 | |
| 261 | 274 | |
| 262 | | static TIMER_CALLBACK( smsvdp_set_irq ) |
| 275 | static TIMER_CALLBACK( smsvdp_set_status ) |
| 263 | 276 | { |
| 264 | 277 | smsvdp_t *smsvdp = (smsvdp_t *) ptr; |
| 265 | 278 | |
| 266 | | smsvdp->irq_state = 1; |
| 279 | smsvdp->status |= (UINT8) param; |
| 280 | } |
| 267 | 281 | |
| 268 | | if (smsvdp->int_callback) |
| 269 | | smsvdp->int_callback(machine, ASSERT_LINE); |
| 282 | |
| 283 | static TIMER_CALLBACK( smsvdp_check_hint ) |
| 284 | { |
| 285 | smsvdp_t *smsvdp = (smsvdp_t *) ptr; |
| 286 | |
| 287 | if (smsvdp->line_counter == 0x00) |
| 288 | { |
| 289 | smsvdp->line_counter = smsvdp->reg[0x0a]; |
| 290 | smsvdp->status |= STATUS_HINT; |
| 291 | } |
| 292 | else |
| 293 | { |
| 294 | smsvdp->line_counter--; |
| 295 | } |
| 296 | |
| 297 | if ((smsvdp->status & STATUS_HINT) && (smsvdp->reg[0x00] & 0x10)) |
| 298 | { |
| 299 | smsvdp->irq_state = 1; |
| 300 | |
| 301 | if (smsvdp->int_callback) |
| 302 | smsvdp->int_callback(machine, ASSERT_LINE); |
| 303 | } |
| 270 | 304 | } |
| 271 | 305 | |
| 272 | 306 | |
| 307 | static TIMER_CALLBACK( smsvdp_check_vint ) |
| 308 | { |
| 309 | smsvdp_t *smsvdp = (smsvdp_t *) ptr; |
| 310 | |
| 311 | if ((smsvdp->status & STATUS_VINT) && (smsvdp->reg[0x01] & 0x20)) |
| 312 | { |
| 313 | smsvdp->irq_state = 1; |
| 314 | |
| 315 | if (smsvdp->int_callback) |
| 316 | smsvdp->int_callback(machine, ASSERT_LINE); |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | |
| 273 | 321 | static TIMER_CALLBACK( smsvdp_display_callback ) |
| 274 | 322 | { |
| 275 | 323 | smsvdp_t *smsvdp = (smsvdp_t *) ptr; |
| r6981 | r6982 | |
| 308 | 356 | { |
| 309 | 357 | if (vpos == vpos_limit) |
| 310 | 358 | { |
| 311 | | if (smsvdp->line_counter == 0x00) |
| 312 | | { |
| 313 | | smsvdp->line_counter = smsvdp->reg[0x0a]; |
| 314 | | smsvdp->status |= STATUS_HINT; |
| 315 | | |
| 316 | | if (smsvdp->reg[0x00] & 0x10) |
| 317 | | { |
| 318 | | /* Delay triggering of interrupt to allow software to read the status bit before the irq */ |
| 319 | | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, vpos, HINT_HPOS), smsvdp, 0, smsvdp_set_irq); |
| 320 | | } |
| 321 | | } |
| 322 | | else |
| 323 | | { |
| 324 | | smsvdp->line_counter -= 1; |
| 325 | | } |
| 359 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, vpos, HINT_HPOS), smsvdp, 0, smsvdp_check_hint); |
| 326 | 360 | } |
| 327 | 361 | else |
| 328 | 362 | { |
| r6981 | r6982 | |
| 331 | 365 | |
| 332 | 366 | if (vpos == vpos_limit + 1) |
| 333 | 367 | { |
| 334 | | smsvdp->status |= STATUS_VINT; |
| 335 | | |
| 336 | | if (smsvdp->reg[0x01] & 0x20) |
| 337 | | { |
| 338 | | /* Delay triggering of interrupt to allow software to read the status bit before the irq */ |
| 339 | | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, vpos, VINT_HPOS), smsvdp, 0, smsvdp_set_irq); |
| 340 | | } |
| 368 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, vpos, VINT_FLAG_HPOS), smsvdp, (int)STATUS_VINT, smsvdp_set_status); |
| 369 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, vpos, VINT_HPOS), smsvdp, 0, smsvdp_check_vint); |
| 341 | 370 | } |
| 342 | 371 | |
| 343 | 372 | sms_update_palette(smsvdp); |
| r6981 | r6982 | |
| 364 | 393 | /* Check if we're in the active display area */ |
| 365 | 394 | if (vpos >= vpos_limit) |
| 366 | 395 | { |
| 367 | | rgb_t border_color; |
| 368 | | |
| 369 | 396 | if (vpos == vpos_limit) |
| 370 | 397 | { |
| 371 | 398 | smsvdp->reg9copy = smsvdp->reg[0x09]; |
| 372 | 399 | } |
| 373 | 400 | |
| 374 | | if (smsvdp->line_counter == 0x00) |
| 375 | | { |
| 376 | | smsvdp->line_counter = smsvdp->reg[0x0a]; |
| 377 | | smsvdp->status |= STATUS_HINT; |
| 401 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, vpos, HINT_HPOS), smsvdp, 0, smsvdp_check_hint); |
| 378 | 402 | |
| 379 | | if (smsvdp->reg[0x00] & 0x10) |
| 380 | | { |
| 381 | | /* Delay triggering of interrupt to allow software to read the status bit before the irq */ |
| 382 | | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, vpos, HINT_HPOS), smsvdp, 0, smsvdp_set_irq); |
| 383 | | } |
| 384 | | } |
| 385 | | else |
| 386 | | { |
| 387 | | smsvdp->line_counter -= 1; |
| 388 | | } |
| 389 | | |
| 390 | 403 | sms_update_palette(smsvdp); |
| 391 | 404 | |
| 392 | | /* Check if display is disabled */ |
| 393 | | if (!(smsvdp->reg[0x01] & 0x40)) |
| 394 | | border_color = RGB_BLACK; |
| 395 | | else |
| 396 | | border_color = machine->pens[smsvdp->current_palette[BACKDROP_COLOR]]; |
| 397 | | |
| 398 | 405 | /* Draw left border */ |
| 399 | 406 | rec.min_x = LBORDER_START; |
| 400 | 407 | rec.max_x = LBORDER_START + LBORDER_X_PIXELS - 1; |
| 401 | | bitmap_fill(smsvdp->tmpbitmap, &rec, border_color); |
| 408 | bitmap_fill(smsvdp->tmpbitmap, &rec, machine->pens[smsvdp->current_palette[BACKDROP_COLOR]]); |
| 402 | 409 | |
| 403 | 410 | /* Draw right border */ |
| 404 | 411 | rec.min_x = LBORDER_START + LBORDER_X_PIXELS + 256; |
| 405 | 412 | rec.max_x = rec.min_x + RBORDER_X_PIXELS - 1; |
| 406 | | bitmap_fill(smsvdp->tmpbitmap, &rec, border_color); |
| 413 | bitmap_fill(smsvdp->tmpbitmap, &rec, machine->pens[smsvdp->current_palette[BACKDROP_COLOR]]); |
| 407 | 414 | |
| 408 | 415 | sms_refresh_line(machine, smsvdp, smsvdp->tmpbitmap, LBORDER_START + LBORDER_X_PIXELS, vpos_limit, vpos - vpos_limit); |
| 409 | 416 | |
| r6981 | r6982 | |
| 434 | 441 | sms_refresh_line(machine, smsvdp, smsvdp->tmpbitmap, LBORDER_START + LBORDER_X_PIXELS, vpos_limit + smsvdp->sms_frame_timing[TOP_BORDER], vpos - (vpos_limit + smsvdp->sms_frame_timing[TOP_BORDER])); |
| 435 | 442 | return; |
| 436 | 443 | } |
| 444 | |
| 445 | /* we're in the vertical or top blanking area */ |
| 446 | smsvdp->line_counter = smsvdp->reg[0x0a]; |
| 437 | 447 | } |
| 438 | 448 | |
| 439 | 449 | |
| r6981 | r6982 | |
| 554 | 564 | if (reg_num == 0 || reg_num == 1) |
| 555 | 565 | set_display_settings(device); |
| 556 | 566 | |
| 557 | | if ((reg_num == 1) && (smsvdp->reg[0x01] & 0x20) && (smsvdp->status & STATUS_VINT)) |
| 567 | if (reg_num == 1) |
| 558 | 568 | { |
| 559 | | smsvdp->irq_state = 1; |
| 560 | | |
| 561 | | if (smsvdp->int_callback) |
| 562 | | smsvdp->int_callback(device->machine, ASSERT_LINE); |
| 569 | timer_set(device->machine, video_screen_get_time_until_pos(device->machine->primary_screen, video_screen_get_vpos(device->machine->primary_screen), VINT_HPOS), smsvdp, 0, smsvdp_check_vint); |
| 563 | 570 | } |
| 564 | 571 | smsvdp->addrmode = 0; |
| 565 | 572 | break; |
| r6981 | r6982 | |
| 571 | 578 | } |
| 572 | 579 | |
| 573 | 580 | |
| 574 | | static void sms_refresh_line_mode4( smsvdp_t *smsvdp, int *line_buffer, int line ) |
| 581 | static void sms_refresh_line_mode4( smsvdp_t *smsvdp, int *line_buffer, int *priority_selected, int line ) |
| 575 | 582 | { |
| 576 | 583 | int tile_column; |
| 577 | 584 | int x_scroll, y_scroll, x_scroll_start_column; |
| 578 | | int sprite_index; |
| 579 | | int pixel_x, pixel_plot_x, priority_selected[256]; |
| 580 | | int sprite_x, sprite_y, sprite_line, sprite_tile_selected, sprite_height, sprite_zoom; |
| 581 | | int sprite_buffer[8], sprite_buffer_count, sprite_buffer_index; |
| 585 | int pixel_x, pixel_plot_x; |
| 582 | 586 | int bit_plane_0, bit_plane_1, bit_plane_2, bit_plane_3; |
| 583 | 587 | int scroll_mod; |
| 584 | 588 | UINT16 name_table_address; |
| 585 | 589 | UINT8 *name_table; |
| 586 | | UINT8 *sprite_table = smsvdp->VRAM + ((smsvdp->reg[0x05] << 7) & 0x3f00); |
| 587 | 590 | |
| 588 | 591 | if (smsvdp->y_pixels != 192) |
| 589 | 592 | { |
| r6981 | r6982 | |
| 668 | 671 | } |
| 669 | 672 | } |
| 670 | 673 | } |
| 674 | } |
| 671 | 675 | |
| 676 | static void sms_refresh_mode4_sprites( running_machine *machine, smsvdp_t *smsvdp, int *line_buffer, int *priority_selected, int pixel_plot_y, int line ) |
| 677 | { |
| 678 | int sprite_index; |
| 679 | int pixel_x, pixel_plot_x; |
| 680 | int sprite_x, sprite_y, sprite_line, sprite_tile_selected, sprite_height, sprite_zoom; |
| 681 | int sprite_col_occurred, sprite_col_x; |
| 682 | int sprite_buffer[8], sprite_buffer_count, sprite_buffer_index; |
| 683 | int bit_plane_0, bit_plane_1, bit_plane_2, bit_plane_3; |
| 684 | UINT8 *sprite_table = smsvdp->VRAM + ((smsvdp->reg[0x05] << 7) & 0x3f00); |
| 685 | |
| 672 | 686 | /* Draw sprite layer */ |
| 673 | 687 | sprite_height = (smsvdp->reg[0x01] & 0x02 ? 16 : 8); |
| 674 | 688 | sprite_zoom = 1; |
| r6981 | r6982 | |
| 693 | 707 | else if (line >= 0 && line < smsvdp->sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 694 | 708 | { |
| 695 | 709 | /* Too many sprites per line */ |
| 696 | | smsvdp->status |= STATUS_SPROVR; |
| 710 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, pixel_plot_y + line, SPROVR_HPOS), smsvdp, (int)STATUS_SPROVR, smsvdp_set_status); |
| 697 | 711 | } |
| 698 | 712 | sprite_buffer_count++; |
| 699 | 713 | } |
| r6981 | r6982 | |
| 740 | 754 | bit_plane_2 = smsvdp->VRAM[((sprite_tile_selected << 5) + ((sprite_line & 0x07) << 2)) + 0x02]; |
| 741 | 755 | bit_plane_3 = smsvdp->VRAM[((sprite_tile_selected << 5) + ((sprite_line & 0x07) << 2)) + 0x03]; |
| 742 | 756 | |
| 757 | sprite_col_occurred = 0; |
| 758 | sprite_col_x = 0; |
| 759 | |
| 743 | 760 | for (pixel_x = 0; pixel_x < 8 ; pixel_x++) |
| 744 | 761 | { |
| 745 | 762 | UINT8 pen_bit_0, pen_bit_1, pen_bit_2, pen_bit_3; |
| r6981 | r6982 | |
| 790 | 807 | } |
| 791 | 808 | else |
| 792 | 809 | { |
| 793 | | /* sprite collision occurred */ |
| 794 | | smsvdp->status |= STATUS_SPRCOL; |
| 810 | if (!sprite_col_occurred) |
| 811 | { |
| 812 | sprite_col_occurred = 1; |
| 813 | sprite_col_x = pixel_plot_x; |
| 814 | } |
| 795 | 815 | } |
| 796 | 816 | if (smsvdp->collision_buffer[pixel_plot_x + 1] != 1) |
| 797 | 817 | { |
| r6981 | r6982 | |
| 799 | 819 | } |
| 800 | 820 | else |
| 801 | 821 | { |
| 802 | | /* sprite collision occurred */ |
| 803 | | smsvdp->status |= STATUS_SPRCOL; |
| 822 | if (!sprite_col_occurred) |
| 823 | { |
| 824 | sprite_col_occurred = 1; |
| 825 | sprite_col_x = pixel_plot_x; |
| 826 | } |
| 804 | 827 | } |
| 805 | 828 | } |
| 806 | 829 | else |
| r6981 | r6982 | |
| 830 | 853 | } |
| 831 | 854 | else |
| 832 | 855 | { |
| 833 | | /* sprite collision occurred */ |
| 834 | | smsvdp->status |= STATUS_SPRCOL; |
| 856 | if (!sprite_col_occurred) |
| 857 | { |
| 858 | sprite_col_occurred = 1; |
| 859 | sprite_col_x = pixel_plot_x; |
| 860 | } |
| 835 | 861 | } |
| 836 | 862 | } |
| 837 | 863 | } |
| 864 | if (sprite_col_occurred) |
| 865 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, pixel_plot_y + line, SPRCOL_BASEHPOS + sprite_col_x), smsvdp, (int)STATUS_SPRCOL, smsvdp_set_status); |
| 838 | 866 | } |
| 839 | 867 | |
| 840 | 868 | /* Fill column 0 with overscan color from reg[0x07] */ |
| r6981 | r6982 | |
| 852 | 880 | } |
| 853 | 881 | |
| 854 | 882 | |
| 855 | | static void sms_refresh_tms9918_sprites( smsvdp_t *smsvdp, int *line_buffer, int line ) |
| 883 | static void sms_refresh_tms9918_sprites( running_machine *machine, smsvdp_t *smsvdp, int *line_buffer, int pixel_plot_y, int line ) |
| 856 | 884 | { |
| 857 | 885 | int pixel_plot_x; |
| 886 | int sprite_col_occurred, sprite_col_x; |
| 858 | 887 | int sprite_height, sprite_buffer_count, sprite_index, sprite_buffer[4], sprite_buffer_index; |
| 859 | 888 | UINT8 *sprite_table, *sprite_pattern_table; |
| 860 | 889 | |
| r6981 | r6982 | |
| 885 | 914 | else if (line >= 0 && line < smsvdp->sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 886 | 915 | { |
| 887 | 916 | /* Too many sprites per line */ |
| 888 | | smsvdp->status |= STATUS_SPROVR; |
| 917 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, pixel_plot_y + line, SPROVR_HPOS), smsvdp, (int)STATUS_SPROVR, smsvdp_set_status); |
| 889 | 918 | } |
| 890 | 919 | sprite_buffer_count++; |
| 891 | 920 | } |
| r6981 | r6982 | |
| 942 | 971 | |
| 943 | 972 | pattern = sprite_pattern_table[sprite_tile_selected * 8 + sprite_line]; |
| 944 | 973 | |
| 974 | sprite_col_occurred = 0; |
| 975 | sprite_col_x = 0; |
| 976 | |
| 945 | 977 | for (pixel_x = 0; pixel_x < 8; pixel_x++) |
| 946 | 978 | { |
| 947 | 979 | if (smsvdp->reg[0x01] & 0x01) |
| r6981 | r6982 | |
| 962 | 994 | } |
| 963 | 995 | else |
| 964 | 996 | { |
| 965 | | smsvdp->status |= STATUS_SPRCOL; |
| 997 | if (!sprite_col_occurred) |
| 998 | { |
| 999 | sprite_col_occurred = 1; |
| 1000 | sprite_col_x = pixel_plot_x; |
| 1001 | } |
| 966 | 1002 | } |
| 967 | 1003 | |
| 968 | 1004 | line_buffer[pixel_plot_x+1] = smsvdp->current_palette[pen_selected]; |
| r6981 | r6982 | |
| 973 | 1009 | } |
| 974 | 1010 | else |
| 975 | 1011 | { |
| 976 | | smsvdp->status |= STATUS_SPRCOL; |
| 1012 | if (!sprite_col_occurred) |
| 1013 | { |
| 1014 | sprite_col_occurred = 1; |
| 1015 | sprite_col_x = pixel_plot_x; |
| 1016 | } |
| 977 | 1017 | } |
| 978 | 1018 | } |
| 979 | 1019 | } |
| r6981 | r6982 | |
| 996 | 1036 | } |
| 997 | 1037 | else |
| 998 | 1038 | { |
| 999 | | smsvdp->status |= STATUS_SPRCOL; |
| 1039 | if (!sprite_col_occurred) |
| 1040 | { |
| 1041 | sprite_col_occurred = 1; |
| 1042 | sprite_col_x = pixel_plot_x; |
| 1043 | } |
| 1000 | 1044 | } |
| 1001 | 1045 | } |
| 1002 | 1046 | } |
| r6981 | r6982 | |
| 1029 | 1073 | } |
| 1030 | 1074 | else |
| 1031 | 1075 | { |
| 1032 | | smsvdp->status |= STATUS_SPRCOL; |
| 1076 | if (!sprite_col_occurred) |
| 1077 | { |
| 1078 | sprite_col_occurred = 1; |
| 1079 | sprite_col_x = pixel_plot_x; |
| 1080 | } |
| 1033 | 1081 | } |
| 1034 | 1082 | |
| 1035 | 1083 | line_buffer[pixel_plot_x+1] = smsvdp->current_palette[pen_selected]; |
| r6981 | r6982 | |
| 1040 | 1088 | } |
| 1041 | 1089 | else |
| 1042 | 1090 | { |
| 1043 | | smsvdp->status |= STATUS_SPRCOL; |
| 1091 | if (!sprite_col_occurred) |
| 1092 | { |
| 1093 | sprite_col_occurred = 1; |
| 1094 | sprite_col_x = pixel_plot_x; |
| 1095 | } |
| 1044 | 1096 | } |
| 1045 | 1097 | } |
| 1046 | 1098 | } |
| r6981 | r6982 | |
| 1063 | 1115 | } |
| 1064 | 1116 | else |
| 1065 | 1117 | { |
| 1066 | | smsvdp->status |= STATUS_SPRCOL; |
| 1118 | if (!sprite_col_occurred) |
| 1119 | { |
| 1120 | sprite_col_occurred = 1; |
| 1121 | sprite_col_x = pixel_plot_x; |
| 1122 | } |
| 1067 | 1123 | } |
| 1068 | 1124 | } |
| 1069 | 1125 | } |
| 1070 | 1126 | } |
| 1071 | 1127 | } |
| 1128 | if (sprite_col_occurred) |
| 1129 | timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, pixel_plot_y + line, SPRCOL_BASEHPOS + sprite_col_x), smsvdp, (int)STATUS_SPRCOL, smsvdp_set_status); |
| 1072 | 1130 | } |
| 1073 | 1131 | } |
| 1074 | 1132 | |
| r6981 | r6982 | |
| 1120 | 1178 | line_buffer[pixel_plot_x] = smsvdp->current_palette[pen_selected]; |
| 1121 | 1179 | } |
| 1122 | 1180 | } |
| 1123 | | |
| 1124 | | /* Draw sprite layer */ |
| 1125 | | sms_refresh_tms9918_sprites(smsvdp, line_buffer, line); |
| 1126 | 1181 | } |
| 1127 | 1182 | |
| 1128 | 1183 | |
| r6981 | r6982 | |
| 1161 | 1216 | line_buffer[pixel_plot_x] = smsvdp->current_palette[pen_selected]; |
| 1162 | 1217 | } |
| 1163 | 1218 | } |
| 1164 | | |
| 1165 | | /* Draw sprite layer */ |
| 1166 | | sms_refresh_tms9918_sprites(smsvdp, line_buffer, line); |
| 1167 | 1219 | } |
| 1168 | 1220 | |
| 1169 | 1221 | |
| r6981 | r6982 | |
| 1171 | 1223 | { |
| 1172 | 1224 | int x; |
| 1173 | 1225 | int *blitline_buffer = smsvdp->line_buffer; |
| 1226 | int priority_selected[256]; |
| 1174 | 1227 | |
| 1175 | 1228 | switch( smsvdp->vdp_mode ) |
| 1176 | 1229 | { |
| 1177 | 1230 | case 0: |
| 1178 | | sms_refresh_line_mode0(smsvdp, blitline_buffer, line); |
| 1231 | if (line >= 0 && line < smsvdp->sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 1232 | sms_refresh_line_mode0(smsvdp, blitline_buffer, line); |
| 1233 | sms_refresh_tms9918_sprites(machine, smsvdp, blitline_buffer, pixel_plot_y, line); |
| 1179 | 1234 | break; |
| 1180 | 1235 | |
| 1181 | 1236 | case 2: |
| 1182 | | sms_refresh_line_mode2(smsvdp, blitline_buffer, line); |
| 1237 | if (line >= 0 && line < smsvdp->sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 1238 | sms_refresh_line_mode2(smsvdp, blitline_buffer, line); |
| 1239 | sms_refresh_tms9918_sprites(machine, smsvdp, blitline_buffer, pixel_plot_y, line); |
| 1183 | 1240 | break; |
| 1184 | 1241 | |
| 1185 | 1242 | case 4: |
| 1186 | 1243 | default: |
| 1187 | | sms_refresh_line_mode4(smsvdp, blitline_buffer, line); |
| 1244 | memset(priority_selected, 0, sizeof(priority_selected)); |
| 1245 | if (line >= 0 && line < smsvdp->sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 1246 | sms_refresh_line_mode4(smsvdp, blitline_buffer, priority_selected, line); |
| 1247 | sms_refresh_mode4_sprites(machine, smsvdp, blitline_buffer, priority_selected, pixel_plot_y, line); |
| 1188 | 1248 | break; |
| 1189 | 1249 | } |
| 1190 | 1250 | |
| 1191 | | if (line < 0 || line >= smsvdp->sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 1251 | /* Check if display is disabled or we're below/above active area */ |
| 1252 | if (!(smsvdp->reg[0x01] & 0x40) || line < 0 || line >= smsvdp->sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 1192 | 1253 | { |
| 1193 | 1254 | for (x = 0; x < 256; x++) |
| 1194 | 1255 | { |
| 1195 | 1256 | blitline_buffer[x] = smsvdp->current_palette[BACKDROP_COLOR]; |
| 1196 | 1257 | } |
| 1197 | 1258 | } |
| 1198 | | /* Check if display is disabled */ |
| 1199 | | else if (!(smsvdp->reg[0x01] & 0x40)) |
| 1200 | | { |
| 1201 | | for (x = 0; x < 256; x++) |
| 1202 | | { |
| 1203 | | blitline_buffer[x] = 0; |
| 1204 | | } |
| 1205 | | } |
| 1206 | 1259 | |
| 1207 | 1260 | if (IS_GAMEGEAR_VDP && smsvdp->gg_sms_mode) |
| 1208 | 1261 | { |
| r6981 | r6982 | |
| 1459 | 1512 | smsvdp->prev_bitmap = auto_bitmap_alloc(device->machine, width, height, BITMAP_FORMAT_INDEXED32); |
| 1460 | 1513 | |
| 1461 | 1514 | smsvdp->smsvdp_display_timer = timer_alloc(device->machine, smsvdp_display_callback, smsvdp); |
| 1462 | | timer_adjust_periodic(smsvdp->smsvdp_display_timer, video_screen_get_time_until_pos(screen, 0, 0), 0, video_screen_get_scan_period(screen)); |
| 1515 | timer_adjust_periodic(smsvdp->smsvdp_display_timer, video_screen_get_time_until_pos(screen, 0, DISPLAY_CB_HPOS), 0, video_screen_get_scan_period(screen)); |
| 1463 | 1516 | |
| 1464 | 1517 | state_save_register_device_item(device, 0, smsvdp->status); |
| 1465 | 1518 | state_save_register_device_item(device, 0, smsvdp->reg9copy); |