Motion interpolation
[mercenary-reloaded.git] / src / mercenary / mercenary3.c
index c652c08..c2ca7f1 100644 (file)
 /* interrupt CPU execution at special break points and tell emulation what to do */
 const struct cpu_stop mercenary_stop_at[] = {
        { 0x5a826,      STOP_AT_WAIT_VBL },                     /* done with rendering, waiting for VBL */
-       { 0x55d8c,      STOP_AT_WAIT_VBL },                     /* after pressing 'HELP' key before showing menu line on benson */
-       { 0x56398,      STOP_AT_WAIT_VBL },                     /* waiting for menu command */
-       { 0x55d94,      STOP_AT_WAIT_VBL },                     /* after pressing 'HELP' key while showing menu line on benson */
-       { 0x563a6,      STOP_AT_WAIT_VBL },                     /* after pressing 'RETURN' while game waits for other key to resume */
+       { 0x55d8c,      STOP_AT_WAIT_INPUT },                   /* after pressing 'HELP' key before showing menu line on benson */
+       { 0x56398,      STOP_AT_WAIT_INPUT },                   /* waiting for menu command */
+       { 0x55d94,      STOP_AT_WAIT_INPUT },                   /* after pressing 'HELP' key while showing menu line on benson */
+       { 0x563a6,      STOP_AT_WAIT_INPUT },                   /* after pressing 'RETURN' while game waits for other key to resume */
        { 0x52946,      STOP_AT_WAIT_VBL },                     /* after dying, waiting for VBL to fade out palette */
        { 0x5A456,      STOP_AT_CLEAR_SCREEN1 },                /* clear the screen (here we know the color 8, this is wy we cannot do it earlier) */
        { 0x5A48E,      STOP_AT_CLEAR_SCREEN1 },
@@ -52,6 +52,11 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x5A770,      STOP_AT_CLEAR_SCREEN3 },                /* special case where we are in universe and do not have any ground */
        { 0x56E00,      STOP_AT_DRAW_GROUND },                  /* the ground is rendered. the color index is captured at CLEAR_SCREEN */
        { 0x5A4AA,      STOP_AT_DRAW_GROUND },                  /* at this point there is ground rendered, because game uses raster split for ground color, but we do render opengl */
+       { 0x53FE2,      STOP_AT_INFO_OBJECT_MOVING },           /* get ID and position of next object */
+       { 0x53E42,      STOP_AT_INFO_OBJECT_FIX },              /* next object is FIX (taxi/bus/intercity) */
+       { 0x53E8E,      STOP_AT_INFO_OBJECT_FIX },
+       { 0x54330,      STOP_AT_TAG_IS_OBJECT_1 },              /* indicates that the next tag is an object */
+       { 0x54334,      STOP_AT_TAG_IS_OBJECT_0 },              /* indicates that the tag of object was rendered */
        { 0x542B2,      STOP_AT_COORD_OBJECT },                 /* object coordinates are ready */
        { 0x5431a,      STOP_AT_POLY_OBJECT_M3 },               /* object polygon is rendered */
        { 0x54342,      STOP_AT_LINE_OBJECT },                  /* object line is rendered */
@@ -88,9 +93,9 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x54C54,      STOP_AT_POLY_TAGS1 },                   /* tag's polygon is rendered (new color D0) */
        { 0x54C30,      STOP_AT_POLY_TAGS2 },                   /* tag's polygon is rendered (use last color) */
        { 0x53A1E,      STOP_AT_COORD_PLANET },                 /* planet's coordinates are ready (viewed from ground) */
-       { 0x53A44,      STOP_AT_MATRIX_COMET },                 /* what rotation matrix to use */
+       { 0x53A44,      STOP_AT_MATRIX_PLANET },                /* what rotation matrix to use */
        { 0x53712,      STOP_AT_COORD_PLANET },                 /* planet's coordinates are ready (viewed from universe) */
-       { 0x537A4,      STOP_AT_MATRIX_COMET },                 /* what rotation matrix to use */
+       { 0x537A4,      STOP_AT_MATRIX_PLANET },                /* what rotation matrix to use */
        { 0x53A9A,      STOP_AT_DRAW_PLANET },                  /* planet's sphere is rendered, D0 is color (viewed from ground) */
        { 0x53960,      STOP_AT_DRAW_PLANET },                  /* planet's sphere is rendered, D0 is color (viewed from universe) */
        { 0x4FB8C,      STOP_AT_DRAW_COMET },                   /* comet's sphere is rendered */
@@ -103,8 +108,8 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x572E8,      STOP_AT_LINE_ISLANDS },
        { 0x5214E,      STOP_AT_DRAW_SIGHTS },                  /* when sights are rendered */
        { 0x4F748,      STOP_AT_POLY_UKN2 },
-       { 0x543B8,      STOP_AT_PLANET_UKN1 },
-       { 0x4CBF8,      STOP_AT_PLANET_UKN2 },
+       { 0x54362,      STOP_AT_EXPLOSION },                    /* explosion debris */
+       { 0x4CA18,      STOP_AT_EXPLOSION },
        { 0x0,          STOP_AT_END },                          /* end */
 };
 
@@ -228,7 +233,7 @@ void mercenary_get_orientation_raw(int16_t *pitch, uint16_t *yaw)
        *yaw = m68k_read_memory_16(DS_0+0x1E2a);
 }
 
-void mercenary_get_orientation_planet(double *inclination, double *rotation)
+void mercenary_get_orientation_planet(double *inclination, double *azimuth)
 {
        int16_t r;
 
@@ -236,7 +241,22 @@ void mercenary_get_orientation_planet(double *inclination, double *rotation)
        r = (int16_t)((m68k_read_memory_16(0x42C70)) & 0x3ff);
        *inclination = (double)r / 1024.0 * 2 * M_PI;
        r = (int16_t)((m68k_read_memory_16(0x42C6c)) & 0x3ff);
-       *rotation = -(double)r / 1024.0 * 2 * M_PI;
+       *azimuth = -(double)r / 1024.0 * 2 * M_PI;
+}
+
+void mercenary_get_location(int32_t *east, int32_t *height, int32_t *north)
+{
+       *east = (int32_t)m68k_read_memory_32(DS_0+0x1E1A);
+       *height = (int32_t)m68k_read_memory_32(DS_0+0x1DBA);
+       *north = (int32_t)m68k_read_memory_32(DS_0+0x1E22);
+}
+
+void mercenary_get_object_info(int *id, int32_t *east, int32_t *height, int32_t *north)
+{
+       *id = REG_A[0];
+       *east = (int32_t)m68k_read_memory_32(REG_A[0] + 22556);
+       *height = (int32_t)m68k_read_memory_32(REG_A[0] + 23580);
+       *north = (int32_t)m68k_read_memory_32(REG_A[0] + 24604);
 }
 
 void mercenary_coord_building_interior(int16_t *east, int32_t *height1, int32_t *height2, int32_t *height3, int32_t *height4, int16_t *north)
@@ -250,11 +270,6 @@ void mercenary_coord_building_interior(int16_t *east, int32_t *height1, int32_t
 
 }
 
-void mercenary_get_height(int32_t *height)
-{
-       *height = (int32_t)m68k_read_memory_32(DS_0+0x1DBA);
-}
-
 int mercenary_street_color_index(void)
 {
        return (m68k_read_memory_16(DS_0+0x1f70) >> 5) & 0xf;