return value;
}
-static void store_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y, int32_t z)
+static void store_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y, int32_t z, double scale)
{
if ((vertex & 3)) {
print_info("Vertex %d is not a multiple of four!\n", vertex);
printf("storing %s coordinates: vertex=%d, x=%d, y=%d, z=%d\n", what, vertex, x, y, z);
#endif
/* use absolute position */
- x += motion_new.position_east;
- y += motion_new.position_height;
- z += motion_new.position_north;
- render_item->u.vertices.x[vertex] = x;
- render_item->u.vertices.y[vertex] = y;
- render_item->u.vertices.z[vertex] = z;
+ render_item->u.vertices.x[vertex] = (double)x * scale + motion_new.position_east;
+ render_item->u.vertices.y[vertex] = (double)y * scale + motion_new.position_height;
+ render_item->u.vertices.z[vertex] = (double)z * scale + motion_new.position_north;
}
static void store_planets_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y, int32_t z)
y += (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += (int32_t)REG_A[3];
- store_coord("object", REG_A[0], x, y, z);
+ store_coord("object", REG_A[0], x, y, z, 1.0);
}
/* polygon of object */
x = (int32_t)(REG_D[3] << 4) / 16;
y = (int32_t)(REG_D[4] << 4) / 16;
z = (int32_t)(REG_D[5] << 4) / 16;
- store_coord("beacon", 0, x, y, z);
+ store_coord("beacon", 0, x, y, z, 1.0);
}
/* point of beacon */
x = (int32_t)REG_D[3];
y = (int32_t)REG_D[4];
z = (int32_t)REG_D[5];
- store_coord("building exterior", REG_A[0], x, y, z);
+ store_coord("building exterior", REG_A[0], x, y, z, 1.0);
}
/* polygon of building (exterior) */
x = REG_D[3];
y = -motion_new.position_height;
z = REG_D[5];
- store_coord("road", REG_A[0], x, y, z);
+ store_coord("road", REG_A[0], x, y, z, 1.0);
}
/* line of road */
y = -motion_new.position_height;
z = m68k_read_memory_32(576 + REG_A[0]);
z -= REG_A[3];
- store_coord("road/place", REG_A[0], x, y, z);
+ store_coord("road/place", REG_A[0], x, y, z, 1.0);
}
/* polygon of road */
y += (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += (int32_t)REG_A[3];
- store_coord("tags", REG_A[0], x, y, z);
+ store_coord("tags", REG_A[0], x, y, z, 1.0);
}
/* coordinates ready for large tags */
y += 2 * (int32_t)REG_A[2];
z = (int16_t)REG_D[5];
z += 2 * (int32_t)REG_A[3];
- store_coord("large tags", REG_A[0], x, y, z);
+ /* note that large tags have double distance, so the resolution is vitrually doubled.
+ * since we use interpolation and VR, we need to scale the vertex back to normal distance.
+ */
+ store_coord("large tags", REG_A[0], x, y, z, 0.5);
}
/* line of tag */
y = -motion_new.position_height;
z = ((int16_t)m68k_read_memory_16(REG_A[4]) * 65536);
z += (int32_t)REG_A[3];
- store_coord("island", REG_A[0], x, y, z);
+ store_coord("island", REG_A[0], x, y, z, 1.0);
}
/* polygon of island */