return false;
}
-static bool do_render_slice(int mode, int slicecnt)
+static bool do_render_slice(int mode, int slicecnt, int lastline)
{
- draw_lines(vpos, slicecnt);
+ draw_lines(lastline, slicecnt);
render_screen(0, mode, true);
return true;
}
return;
int diff = vsync_hblank / (nextline - currline);
int us = 1000000 / diff;
- if (us < 1300) { // spin if less than 1.3ms
+ if (us < target_sleep_nanos(-1)) { // spin if less than minimum sleep time
target_spin(nextline - currline - 1);
return;
}
frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase;
is_syncline = 0;
- maybe_process_pull_audio();
if (is_last_line()) {
- do_render_slice(-1, 0);
+ do_render_slice(-1, 0, vpos - 1);
while (!currprefs.turbo_emulation && sync_timeout_check(maxtime)) {
maybe_process_pull_audio();
target_spin(0);
return false;
}
-
static bool linesync_beam_multi_dual(void)
{
+ frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase;
static int vsyncnextscanline;
static int nextwaitvpos;
static int display_slice_cnt;
static int display_slice_lines;
static int display_slices;
static bool display_rendered;
- frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase;
bool input_read_done = false;
bool was_syncline = is_syncline != 0;
if (display_slice_cnt == 0) {
if (!was_syncline) {
- do_render_slice(1, display_slice_cnt);
+ do_render_slice(is_last_line() ? 1 : 2, display_slice_cnt, vpos - 1);
display_rendered = true;
}
while (!currprefs.turbo_emulation && sync_timeout_check(maxtime)) {
if (!currprefs.turbo_emulation) {
if (!was_syncline && !display_rendered) {
- do_render_slice(0, display_slice_cnt);
+ do_render_slice(0, display_slice_cnt, vpos - 1);
display_rendered = true;
}
while(sync_timeout_check(maxtime)) {
static bool linesync_beam_multi_single(void)
{
+ frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase;
static int vsyncnextscanline;
static int vsyncnextscanline_add;
static int nextwaitvpos;
static int display_slice_lines;
static int display_slices;
static bool display_rendered;
- frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase;
bool input_read_done = false;
bool was_syncline = is_syncline != 0;
if (is_last_line()) {
if (!was_syncline && !display_rendered) {
- do_render_slice(0, display_slice_cnt);
+ do_render_slice(1, display_slice_cnt, vpos - 1);
display_rendered = true;
}
// if 2 slices: make sure we are out of vblank.
if (!currprefs.turbo_emulation) {
if (!was_syncline) {
- do_render_slice(1, display_slice_cnt);
+ do_render_slice(2, display_slice_cnt, vpos - 1);
display_rendered = true;
}
if (!currprefs.turbo_emulation) {
if (!was_syncline) {
- do_render_slice(1, display_slice_cnt);
+ do_render_slice(2, display_slice_cnt, vpos - 1);
display_rendered = true;
}
int vp2 = target_get_display_scanline(-1);
if (!currprefs.turbo_emulation && (currprefs.m68k_speed < 0 || vp2 < vsyncnextscanline - vsyncnextscanline_add / 10)) {
if (!was_syncline && !display_rendered) {
- do_render_slice(0, display_slice_cnt);
+ do_render_slice(0, display_slice_cnt, vpos - 1);
display_rendered = true;
}
while (sync_timeout_check(maxtime)) {
refresh_indicator_update(vb);
}
+extern bool beamracer_debug;
+
void draw_lines(int end, int section)
{
int monid = 0;
int y_start = -1;
int y_end = -1;
+ static bool section_toggle;
+
+ if (section == 0)
+ section_toggle = !section_toggle;
+
end -= minfirstline;
if (end < 0)
return;
return;
}
+ int section_color_cnt = 4;
+
vidinfo->outbuffer = vb;
if (!lockscr(vb, false, vb->last_drawn_line ? false : true))
return;
hposblank = 0;
pfield_draw_line(vb, line, whereline, wherenext);
-#if 0
- static const int section_colors[] = { 0x777, 0xf00, 0x0f0, 0x00f };
- int color = section_colors[section & 3];
- xlinebuffer = row_map[whereline];
- for (int x = 0; x < 4; x++) {
- putpixel(xlinebuffer, NULL, vidinfo->drawbuffer.pixbytes, x, xcolors[color], 1);
+#if 1
+ if (beamracer_debug) {
+ if (vb->last_drawn_line == end - 4) {
+ section_color_cnt = 4;
+ }
+ if (section_color_cnt > 0) {
+ section_color_cnt--;
+ static const int section_colors[] = { 0x777, 0xf00, 0x0f0, 0x00f };
+ int color = section_toggle ? section_colors[section & 3] : 0;
+ xlinebuffer = row_map[whereline];
+ for (int x = 0; x < 4; x++) {
+ putpixel(xlinebuffer, NULL, vidinfo->drawbuffer.pixbytes, x, xcolors[color], 1);
+ }
+ }
}
#endif
}
if (multimon && locked) {
unlockscr(out, -1, -1);
- render_screen(out->monitor_id, 0, true);
+ render_screen(out->monitor_id, 1, true);
show_screen(out->monitor_id, 0);
}
}
memset (buf, 0, sizeof (struct vidbuffer));
}
-void reset_drawing (void)
+void reset_drawing(void)
{
int monid = 0;
struct amigadisplay *ad = &adisplays[monid];
extern void target_restart (void);
extern void target_getdate(int *y, int *m, int *d);
extern void target_cpu_speed(void);
-extern void target_sleep_nanos(int);
+extern int target_sleep_nanos(int);
extern bool get_plugin_path (TCHAR *out, int size, const TCHAR *path);
extern void stripslashes (TCHAR *p);
extern void fixtrailing (TCHAR *p);
return true;
}
-static void setupscenecoords (struct d3dstruct *d3d)
+static void setupscenecoords (struct d3dstruct *d3d, bool normalrender)
{
int monid = d3d - d3ddata;
struct vidbuf_description *vidinfo = &adisplays[monid].gfxvidinfo;
float dw, dh;
static RECT sr2[MAX_AMIGAMONITORS], dr2[MAX_AMIGAMONITORS], zr2[MAX_AMIGAMONITORS];
+ if (!normalrender)
+ return;
+
//write_log (_T("%dx%d %dx%d %dx%d\n"), tin_w, tin_h, tin_w, tin_h, window_w, window_h);
getfilterrect2 (monid, &dr, &sr, &zr, d3d->window_w, d3d->window_h, d3d->tin_w / d3d->dmult, d3d->tin_h / d3d->dmult, d3d->dmult, d3d->tin_w, d3d->tin_h);
if (!isd3d (d3d) || !d3d->texture)
return;
- if (mode > 0)
+ bool normalrender = mode < 0 || (mode & 1);
+
+ if (mode > 0 && (mode & 2))
d3d->slicecnt = 0;
else if (mode < 0)
d3d->slicecnt = d3d->slicecnt == 2 ? 0 : d3d->slicecnt;
masktexture = s->masktexture;
}
- setupscenecoords (d3d);
+ setupscenecoords(d3d, normalrender);
hr = d3d->d3ddev->SetTransform (D3DTS_PROJECTION, &d3d->m_matProj);
hr = d3d->d3ddev->SetTransform (D3DTS_VIEW, &d3d->m_matView);
hr = d3d->d3ddev->SetTransform (D3DTS_WORLD, &d3d->m_matWorld);
} else {
// non-shader version
- setupscenecoords (d3d);
+ setupscenecoords (d3d, normalrender);
hr = d3d->d3ddev->SetTransform (D3DTS_PROJECTION, &d3d->m_matProj);
hr = d3d->d3ddev->SetTransform (D3DTS_VIEW, &d3d->m_matView);
hr = d3d->d3ddev->SetTransform (D3DTS_WORLD, &d3d->m_matWorld);
return true;
}
-static void setupscenecoords(struct d3d11struct *d3d)
+static void setupscenecoords(struct d3d11struct *d3d, bool normalrender)
{
RECT sr, dr, zr;
+ if (!normalrender)
+ return;
+
getfilterrect2(d3d - d3d11data, &dr, &sr, &zr, d3d->m_screenWidth, d3d->m_screenHeight, d3d->m_bitmapWidth / d3d->dmult, d3d->m_bitmapHeight / d3d->dmult, d3d->dmult, d3d->m_bitmapWidth, d3d->m_bitmapHeight);
if (!memcmp(&sr, &d3d->sr2, sizeof RECT) && !memcmp(&dr, &d3d->dr2, sizeof RECT) && !memcmp(&zr, &d3d->zr2, sizeof RECT)) {
xD3DXMatrixLookAtLH(&d3d->m_viewMatrix, &position, &lookAt, &up);
}
-static bool GraphicsClass_Render(struct d3d11struct *d3d, float rotation)
+static bool GraphicsClass_Render(struct d3d11struct *d3d, float rotation, bool normalrender)
{
bool result;
- setupscenecoords(d3d);
+ setupscenecoords(d3d, normalrender);
// Generate the view matrix based on the camera's position.
CameraClass_Render(d3d);
d3d->frames_since_init++;
- if (mode > 0)
+ if (mode > 0 && (mode & 2))
d3d->slicecnt = 0;
else if (mode < 0)
d3d->slicecnt = d3d->slicecnt == 2 ? 0 : d3d->slicecnt;
if (d3d->delayedfs || !d3d->texture2d || !d3d->d3dinit_done)
return false;
- GraphicsClass_Render(d3d, 0);
+ GraphicsClass_Render(d3d, 0, mode < 0 || (mode & 1));
if (d3d->filenotificationhandle != NULL) {
bool notify = false;
d3d->delayedrestore = true;
}
- setupscenecoords(d3d);
+ setupscenecoords(d3d, true);
changed_prefs.leds_on_screen |= STATUSLINE_TARGET;
currprefs.leds_on_screen |= STATUSLINE_TARGET;
static ULONG ActualTimerResolution;
-void target_sleep_nanos(int nanos)
+int target_sleep_nanos(int nanos)
{
static bool init;
if (!init) {
init = true;
}
if (pNtDelayExecution) {
+ if (nanos < 0)
+ return 800;
LARGE_INTEGER interval;
int start = read_processor_time();
nanos *= 10;
pNtDelayExecution(false, &interval);
idletime += read_processor_time() - start;
} else {
+ if (nanos < 0)
+ return 1300;
sleep_millis_main(1);
}
+ return 0;
}
static uae_u64 spincount;
} else { /* null */
if (amiga_depth == dst_depth) {
- uae_u8 *d = dptr, *s = sptr;
- int y;
int w = aw * dst_depth / 8;
- for (y = 0; y < ah && d + w <= enddptr; y++) {
- memcpy (d, s, w);
- s += vb->rowbytes;
- d += pitch;
+ if (y_start < 0) {
+ uae_u8 *d = dptr;
+ uae_u8 *s = sptr;
+ for (int y = 0; y < ah && d + w <= enddptr; y++) {
+ memcpy(d, s, w);
+ s += vb->rowbytes;
+ d += pitch;
+ }
+ } else {
+ uae_u8 *d = dptr + y_start * pitch;
+ uae_u8 *s = sptr + y_start * vb->rowbytes;
+ for (int y = y_start; y < ah && y < y_end && d + w <= enddptr; y++) {
+ memcpy(d, s, w);
+ s += vb->rowbytes;
+ d += pitch;
+ }
}
}
ok = 1;
int vsync_activeheight, vsync_totalheight;
float vsync_vblank, vsync_hblank;
+bool beamracer_debug;
int reopen(struct AmigaMonitor *, int, bool);
if (isfullscreen () != 0)
setmouseactive(mon->monitor_id, -1);
+ if (D3D_debug) {
+ D3D_debug(0, beamracer_debug);
+ }
+
return 1;
oops:
bool toggle_3d_debug(void)
{
if (isvsync_chipset() < 0) {
+ beamracer_debug = !beamracer_debug;
if (D3D_debug) {
- int d = D3D_debug(0, 0);
- D3D_debug(0, d ? 0 : 1);
+ D3D_debug(0, beamracer_debug);
}
+ reset_drawing();
return true;
}
return false;