Motion interpolation
[mercenary-reloaded.git] / src / mercenary / mercenary2.c
index db87556..1267c75 100644 (file)
 /* interrupt CPU execution at special break points and tell emulation what to do */
 const struct cpu_stop mercenary_stop_at[] = {
        { 0x59a4e,      STOP_AT_WAIT_VBL },                     /* done with rendering, waiting for VBL */
-       { 0x54c26,      STOP_AT_WAIT_VBL },                     /* after pressing 'HELP' key before showing menu line on benson */
-       { 0x55438,      STOP_AT_WAIT_VBL },                     /* waiting for menu command */
-       { 0x54c2e,      STOP_AT_WAIT_VBL },                     /* after pressing 'HELP' key while showing menu line on benson */
-       { 0x55446,      STOP_AT_WAIT_VBL },                     /* after pressing 'RETURN' while game waits for other key to resume */
+       { 0x54c26,      STOP_AT_WAIT_INPUT },                   /* after pressing 'HELP' key before showing menu line on benson */
+       { 0x55438,      STOP_AT_WAIT_INPUT },                   /* waiting for menu command */
+       { 0x54c2e,      STOP_AT_WAIT_INPUT },                   /* after pressing 'HELP' key while showing menu line on benson */
+       { 0x55446,      STOP_AT_WAIT_INPUT },                   /* after pressing 'RETURN' while game waits for other key to resume */
        { 0x51620,      STOP_AT_WAIT_VBL },                     /* after dying, waiting for VBL to fade out palette */
        { 0x596BC,      STOP_AT_CLEAR_SCREEN1 },                /* clear the screen (here we know the color 8, this is wy we cannot do it earlier) */
        { 0x596F4,      STOP_AT_CLEAR_SCREEN1 },
@@ -46,6 +46,10 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x59982,      STOP_AT_CLEAR_SCREEN3 },                /* special case where we are in universe and do not have any ground */
        { 0x55F2E,      STOP_AT_DRAW_GROUND },                  /* the ground is rendered. the color index is captured at CLEAR_SCREEN */
        { 0x59710,      STOP_AT_DRAW_GROUND },                  /* at this point there is ground rendered, because game uses raster split for ground color, but we do render opengl */
+       { 0x531EA,      STOP_AT_INFO_OBJECT_MOVING },           /* get ID and position of next object */
+       /* note: there a no fix objects in this game (no taxi/bus/intercity) */
+       { 0x534EA,      STOP_AT_TAG_IS_OBJECT_1 },              /* indicates that the next tag is an object */
+       { 0x534EE,      STOP_AT_TAG_IS_OBJECT_0 },              /* indicates that the tag of object was rendered */
        { 0x5346E,      STOP_AT_COORD_OBJECT },                 /* object coordinates are ready */
        { 0x534F6,      STOP_AT_POLY_OBJECT_M2 },               /* object polygon is rendered */
        { 0x534F0,      STOP_AT_LINE_OBJECT },                  /* object line is rendered */
@@ -81,9 +85,9 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x53CFA,      STOP_AT_LINE_TAGS2 },                   /* tag's line is rendered (use last color) */
        { 0x53CF0,      STOP_AT_POLY_TAGS2 },                   /* tag's polygon is rendered (use last color) */
        { 0x52BF4,      STOP_AT_COORD_PLANET },                 /* planet's coordinates are ready (viewed from ground) */
-       { 0x52C1A,      STOP_AT_MATRIX_COMET },                 /* what rotation matrix to use */
+       { 0x52C1A,      STOP_AT_MATRIX_PLANET },                /* what rotation matrix to use */
        { 0x52756,      STOP_AT_COORD_PLANET },                 /* planet's coordinates are ready (viewed from universe) */
-       { 0x5277C,      STOP_AT_MATRIX_COMET },                 /* what rotation matrix to use */
+       { 0x5277C,      STOP_AT_MATRIX_PLANET },                /* what rotation matrix to use */
        { 0x52C70,      STOP_AT_DRAW_PLANET },                  /* planet's sphere is rendered, D0 is color (viewed from ground) */
        { 0x52B36,      STOP_AT_DRAW_PLANET },                  /* planet's sphere is rendered, D0 is color (viewed from universe) */
        { 0x4F4E6,      STOP_AT_DRAW_COMET },                   /* comet's sphere is rendered */
@@ -98,6 +102,8 @@ const struct cpu_stop mercenary_stop_at[] = {
        { 0x56416,      STOP_AT_POLY_ISLANDS },                 /* island's polygon is rendered */
        { 0x56410,      STOP_AT_LINE_ISLANDS },
        { 0x511FE,      STOP_AT_DRAW_SIGHTS },                  /* when sights are rendered */
+       { 0x5351A,      STOP_AT_EXPLOSION },                    /* explosion debris */
+       { 0x4C514,      STOP_AT_EXPLOSION },
        { 0x0,          STOP_AT_END },                          /* end */
 };
 
@@ -190,7 +196,7 @@ void mercenary_get_orientation_raw(int16_t *pitch, uint16_t *yaw)
        *yaw = m68k_read_memory_16(0x007AA2);
 }
 
-void mercenary_get_orientation_planet(double *inclination, double *rotation)
+void mercenary_get_orientation_planet(double *inclination, double *azimuth)
 {
        int16_t r;
 
@@ -198,7 +204,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(0x7a92);
+       *height = (int32_t)m68k_read_memory_32(0x7a30);
+       *north = (int32_t)m68k_read_memory_32(0x7a9a);
+}
+
+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] + 25512);
+       *height = (int32_t)m68k_read_memory_32(REG_A[0] + 26536);
+       *north = (int32_t)m68k_read_memory_32(REG_A[0] + 27560);
 }
 
 void mercenary_coord_building_interior(int16_t *east, int32_t *height1, int32_t *height2, int32_t *height3, int32_t *height4, int16_t *north)
@@ -211,11 +232,6 @@ void mercenary_coord_building_interior(int16_t *east, int32_t *height1, int32_t
        *height4 = (int16_t)m68k_read_memory_16(0x7B2A) - (int16_t)m68k_read_memory_16(0x79AC);
 }
 
-void mercenary_get_height(int32_t *height)
-{
-       *height = (int32_t)m68k_read_memory_32(0x7A30);
-}
-
 int mercenary_street_color_index(void)
 {
        return (m68k_read_memory_16(0x7BE2) >> 5) & 0xf;