\r
 static int EmuScanBegin16_ld(unsigned int num)\r
 {\r
-       if ((signed int)(ld_counter - num) > 100)\r
-               ld_counter = 0;\r
+       if ((signed int)(ld_counter - num) > 100) {\r
+               // vsync, offset so that the upscaled image is centered\r
+               ld_counter = 120 - (120-num) * (ld_lines+2)/ld_lines;\r
+               ld_left = ld_lines;\r
+       }\r
 \r
        if (emu_scan_begin)\r
                return emu_scan_begin(ld_counter);\r
        int scalex = 320, scaley = 240;\r
        int ln_offs = 0;\r
 \r
+       /* NTSC always has 224 visible lines, anything smaller has bars */\r
+       if (line_count < 224 && line_count > 144) {\r
+               start_line -= (224-line_count) /2;\r
+               line_count = 224;\r
+       }\r
+\r
        /* line doubling for swscaling, also needed for bg frames */\r
        if (currentConfig.vscaling == EOPT_SCALE_SW && line_count < 240) {\r
                ld_lines = ld_left = 2*line_count / (240 - line_count);\r
 
 /* prepare for MD screen mode change */
 void emu_video_mode_change(int start_line, int line_count, int start_col, int col_count)
 {
+       /* NTSC always has 224 visible lines, anything smaller has bars */
+       if (line_count < 224 && line_count > 144) {
+               start_line -= (224-line_count) /2;
+               line_count = 224;
+       }
+
        out_y = start_line; out_x = start_col;
        out_h = line_count; out_w = col_count;