src/mess/video/smsvdp.c
| r13342 | r13343 | |
| 127 | 127 | devcb_resolved_write_line m_int_callback; |
| 128 | 128 | devcb_resolved_write_line m_pause_callback; |
| 129 | 129 | emu_timer *m_smsvdp_display_timer; |
| 130 | screen_device *m_screen; |
| 130 | 131 | }; |
| 131 | 132 | |
| 132 | 133 | static TIMER_CALLBACK( smsvdp_display_callback ); |
| r13342 | r13343 | |
| 163 | 164 | { |
| 164 | 165 | smsvdp_t *smsvdp = get_safe_token(device); |
| 165 | 166 | |
| 166 | | screen_device *screen = device->machine().first_screen(); |
| 167 | | int height = screen->height(); |
| 167 | int height = smsvdp->m_screen->height(); |
| 168 | 168 | int M1, M2, M3, M4; |
| 169 | 169 | M1 = smsvdp->m_reg[0x01] & 0x10; |
| 170 | 170 | M2 = smsvdp->m_reg[0x00] & 0x02; |
| r13342 | r13343 | |
| 232 | 232 | READ8_DEVICE_HANDLER( sms_vdp_vcount_r ) |
| 233 | 233 | { |
| 234 | 234 | smsvdp_t *smsvdp = get_safe_token(device); |
| 235 | | int vpos = device->machine().primary_screen->vpos(); |
| 235 | int vpos = smsvdp->m_screen->vpos(); |
| 236 | 236 | |
| 237 | | if (device->machine().primary_screen->hpos() < VCOUNT_CHANGE_HPOS) |
| 237 | if (smsvdp->m_screen->hpos() < VCOUNT_CHANGE_HPOS) |
| 238 | 238 | { |
| 239 | 239 | vpos--; |
| 240 | 240 | if (vpos < 0) |
| 241 | | vpos += device->machine().primary_screen->height(); |
| 241 | vpos += smsvdp->m_screen->height(); |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | return (smsvdp->m_sms_frame_timing[INIT_VCOUNT] + vpos) & 0xff; |
| r13342 | r13343 | |
| 318 | 318 | smsvdp_t *smsvdp = (smsvdp_t *) ptr; |
| 319 | 319 | |
| 320 | 320 | rectangle rec; |
| 321 | | int vpos = machine.primary_screen->vpos(); |
| 321 | int vpos = smsvdp->m_screen->vpos(); |
| 322 | 322 | int vpos_limit = smsvdp->m_sms_frame_timing[VERTICAL_BLANKING] + smsvdp->m_sms_frame_timing[TOP_BLANKING] |
| 323 | 323 | + smsvdp->m_sms_frame_timing[TOP_BORDER] + smsvdp->m_sms_frame_timing[ACTIVE_DISPLAY_V] |
| 324 | 324 | + smsvdp->m_sms_frame_timing[BOTTOM_BORDER] + smsvdp->m_sms_frame_timing[BOTTOM_BLANKING]; |
| r13342 | r13343 | |
| 350 | 350 | { |
| 351 | 351 | if (vpos == vpos_limit) |
| 352 | 352 | { |
| 353 | | machine.scheduler().timer_set(machine.primary_screen->time_until_pos(vpos, HINT_HPOS), FUNC(smsvdp_check_hint),0 ,smsvdp); |
| 353 | machine.scheduler().timer_set(smsvdp->m_screen->time_until_pos(vpos, HINT_HPOS), FUNC(smsvdp_check_hint),0 ,smsvdp); |
| 354 | 354 | } |
| 355 | 355 | else |
| 356 | 356 | { |
| r13342 | r13343 | |
| 359 | 359 | |
| 360 | 360 | if (vpos == vpos_limit + 1) |
| 361 | 361 | { |
| 362 | | machine.scheduler().timer_set(machine.primary_screen->time_until_pos(vpos, VINT_FLAG_HPOS), FUNC(smsvdp_set_status), (int)STATUS_VINT, smsvdp); |
| 363 | | machine.scheduler().timer_set(machine.primary_screen->time_until_pos(vpos, VINT_HPOS), FUNC(smsvdp_check_vint), 0, smsvdp); |
| 362 | machine.scheduler().timer_set(smsvdp->m_screen->time_until_pos(vpos, VINT_FLAG_HPOS), FUNC(smsvdp_set_status), (int)STATUS_VINT, smsvdp); |
| 363 | machine.scheduler().timer_set(smsvdp->m_screen->time_until_pos(vpos, VINT_HPOS), FUNC(smsvdp_check_vint), 0, smsvdp); |
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | sms_update_palette(smsvdp); |
| r13342 | r13343 | |
| 392 | 392 | smsvdp->m_reg9copy = smsvdp->m_reg[0x09]; |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | | machine.scheduler().timer_set(machine.primary_screen->time_until_pos(vpos, HINT_HPOS), FUNC(smsvdp_check_hint),0, smsvdp); |
| 395 | machine.scheduler().timer_set(smsvdp->m_screen->time_until_pos(vpos, HINT_HPOS), FUNC(smsvdp_check_hint),0, smsvdp); |
| 396 | 396 | |
| 397 | 397 | sms_update_palette(smsvdp); |
| 398 | 398 | |
| r13342 | r13343 | |
| 561 | 561 | |
| 562 | 562 | if (reg_num == 1) |
| 563 | 563 | { |
| 564 | | device->machine().scheduler().timer_set(device->machine().primary_screen->time_until_pos(device->machine().primary_screen->vpos(), VINT_HPOS), FUNC(smsvdp_check_vint),0 ,smsvdp); |
| 564 | device->machine().scheduler().timer_set(smsvdp->m_screen->time_until_pos(smsvdp->m_screen->vpos(), VINT_HPOS), FUNC(smsvdp_check_vint),0 ,smsvdp); |
| 565 | 565 | } |
| 566 | 566 | smsvdp->m_addrmode = 0; |
| 567 | 567 | break; |
| r13342 | r13343 | |
| 702 | 702 | else if (line >= 0 && line < smsvdp->m_sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 703 | 703 | { |
| 704 | 704 | /* Too many sprites per line */ |
| 705 | | machine.scheduler().timer_set(machine.primary_screen->time_until_pos(pixel_plot_y + line, SPROVR_HPOS), FUNC(smsvdp_set_status), (int)STATUS_SPROVR, smsvdp); |
| 705 | machine.scheduler().timer_set(smsvdp->m_screen->time_until_pos(pixel_plot_y + line, SPROVR_HPOS), FUNC(smsvdp_set_status), (int)STATUS_SPROVR, smsvdp); |
| 706 | 706 | } |
| 707 | 707 | sprite_buffer_count++; |
| 708 | 708 | } |
| r13342 | r13343 | |
| 857 | 857 | } |
| 858 | 858 | } |
| 859 | 859 | if (sprite_col_occurred) |
| 860 | | machine.scheduler().timer_set(machine.primary_screen->time_until_pos(pixel_plot_y + line, SPRCOL_BASEHPOS + sprite_col_x), FUNC(smsvdp_set_status), (int)STATUS_SPRCOL, smsvdp); |
| 860 | machine.scheduler().timer_set(smsvdp->m_screen->time_until_pos(pixel_plot_y + line, SPRCOL_BASEHPOS + sprite_col_x), FUNC(smsvdp_set_status), (int)STATUS_SPRCOL, smsvdp); |
| 861 | 861 | } |
| 862 | 862 | |
| 863 | 863 | /* Fill column 0 with overscan color from m_reg[0x07] */ |
| r13342 | r13343 | |
| 909 | 909 | else if (line >= 0 && line < smsvdp->m_sms_frame_timing[ACTIVE_DISPLAY_V]) |
| 910 | 910 | { |
| 911 | 911 | /* Too many sprites per line */ |
| 912 | | machine.scheduler().timer_set(machine.primary_screen->time_until_pos(pixel_plot_y + line, SPROVR_HPOS), FUNC(smsvdp_set_status), (int)STATUS_SPROVR, smsvdp); |
| 912 | machine.scheduler().timer_set(smsvdp->m_screen->time_until_pos(pixel_plot_y + line, SPROVR_HPOS), FUNC(smsvdp_set_status), (int)STATUS_SPROVR, smsvdp); |
| 913 | 913 | } |
| 914 | 914 | sprite_buffer_count++; |
| 915 | 915 | } |
| r13342 | r13343 | |
| 1121 | 1121 | } |
| 1122 | 1122 | } |
| 1123 | 1123 | if (sprite_col_occurred) |
| 1124 | | machine.scheduler().timer_set(machine.primary_screen->time_until_pos(pixel_plot_y + line, SPRCOL_BASEHPOS + sprite_col_x), FUNC(smsvdp_set_status), (int)STATUS_SPRCOL, smsvdp); |
| 1124 | machine.scheduler().timer_set(smsvdp->m_screen->time_until_pos(pixel_plot_y + line, SPRCOL_BASEHPOS + sprite_col_x), FUNC(smsvdp_set_status), (int)STATUS_SPRCOL, smsvdp); |
| 1125 | 1125 | } |
| 1126 | 1126 | } |
| 1127 | 1127 | |
| r13342 | r13343 | |
| 1423 | 1423 | smsvdp_t *smsvdp = get_safe_token(device); |
| 1424 | 1424 | const smsvdp_interface *intf = get_interface(device); |
| 1425 | 1425 | |
| 1426 | | screen_device *screen = device->machine().first_screen(); |
| 1427 | | int width = screen->width(); |
| 1428 | | int height = screen->height(); |
| 1426 | smsvdp->m_screen = device->machine().device<screen_device>( intf->screen_tag ); |
| 1427 | int width = smsvdp->m_screen->width(); |
| 1428 | int height = smsvdp->m_screen->height(); |
| 1429 | 1429 | |
| 1430 | 1430 | smsvdp->m_features = intf->model; |
| 1431 | 1431 | |
| r13342 | r13343 | |
| 1445 | 1445 | smsvdp->m_tmpbitmap = auto_bitmap_alloc(device->machine(), width, height, BITMAP_FORMAT_INDEXED32); |
| 1446 | 1446 | |
| 1447 | 1447 | smsvdp->m_smsvdp_display_timer = device->machine().scheduler().timer_alloc(FUNC(smsvdp_display_callback), smsvdp); |
| 1448 | | smsvdp->m_smsvdp_display_timer->adjust(screen->time_until_pos(0, DISPLAY_CB_HPOS), 0, screen->scan_period()); |
| 1448 | smsvdp->m_smsvdp_display_timer->adjust(smsvdp->m_screen->time_until_pos(0, DISPLAY_CB_HPOS), 0, smsvdp->m_screen->scan_period()); |
| 1449 | 1449 | |
| 1450 | 1450 | device->save_item(NAME(smsvdp->m_status)); |
| 1451 | 1451 | device->save_item(NAME(smsvdp->m_reg9copy)); |