Add command line option for various game rendering improvements
authorAndreas Eversberg <jolly@eversberg.eu>
Fri, 27 Apr 2018 19:15:50 +0000 (21:15 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Fri, 27 Apr 2018 19:21:18 +0000 (21:21 +0200)
- extend roads
- smooth planet rotation
- rotate stars
- fix dusk/dawn of planets when flying

src/mercenary/main.c
src/mercenary/render.c
src/mercenary/render.h

index e1515e6..631bb15 100644 (file)
@@ -76,7 +76,8 @@ static int config_debug_opengl = 0;
 /* render improvements */
 static int config_improve_extend_roads = 1;    /* set to 1 to extend roads */
 static int config_improve_smooth_planets = 1;  /* set to 1 to rotate planets smoothly */
-static int config_fix_sky_rotation = 0;                /* set to 1 to fix sky rotation */
+static int config_improve_stars_rotation = 1;  /* set to 1 to improve star rendering */
+static int config_improve_fix_sky_rotation = 0;        /* set to 1 to fix sky rotation */
 
 #define CPU_SPEED      7093790.0;
 
@@ -163,11 +164,23 @@ int parse_args(int argc, char *argv[])
                        print_info("        Set field-of-view. Default is %.0f.\n", FOV_NOVAGEN);
                        print_info(" -i --skip-intro\n");
                        print_info("        Skip intro sequence approaching to Eris space port.\n");
-                       print_info("    --fix-sky-rotation\n");
-                       print_info("        Sky rotates in the wrong direction, if flying over surface. This is\n");
+                       print_info("Improvement options:\n");
+                       print_info("    --extend-roads 1 | 0\n");
+                       print_info("        Roads in the distance end in a single point. This was ok for low\n");
+                       print_info("        resolution, but for OpenGL we want equal width all the way.\n");
+                       print_info("        This requires OpenGL rendering. (default = %d)\n", config_improve_extend_roads);
+                       print_info("    --smooth-planets 1 | 0\n");
+                       print_info("        Planet's rotation uses integer value, so they judder in the original\n");
+                       print_info("        game rendering. This option requires OpenGL rendering. (default = %d)\n", config_improve_smooth_planets);
+                       print_info("    --stars-rotation 1 | 0\n");
+                       print_info("        Stars are rendered originally by using a fast routine. Use this option\n");
+                       print_info("        to make them render on a sphere. They also rotate with the sky then.\n");
+                       print_info("        This requires OpenGL rendering and is default with VR. (default = %d)\n", config_improve_stars_rotation);
+                       print_info("    --fix-sky-rotation 1 | 0\n");
+                       print_info("        Sky rotates in the wrong direction, if flying over planet. This is\n");
                        print_info("        fixed by rotating all sky object by 180 degrees. The original (wrong)\n");
                        print_info("        rotation is default, because it preserves the game's spirit!\n");
-                       print_info("        This requires OpenGL rendering\n");
+                       print_info("        This option requires OpenGL rendering. (default = %d)\n", config_improve_fix_sky_rotation);
                        print_info("Debug options:\n");
                        print_info(" -o --debug-opengl\n");
                        print_info("        Use split screen to display both Amiga and OpenGL rendering.\n");
@@ -270,8 +283,29 @@ illegal_parameter:
                if (!strcmp(argv[i], "-i") || !strcmp(argv[i], "--skip-intro")) {
                        config_skip_intro = 1;
                } else
+               if (!strcmp(argv[i], "--extend-roads")) {
+                       i++;
+                       if (argc == i)
+                               goto missing_parameter;
+                       config_improve_extend_roads = atoi(argv[i]);
+               } else
+               if (!strcmp(argv[i], "--smooth-planets")) {
+                       i++;
+                       if (argc == i)
+                               goto missing_parameter;
+                       config_improve_smooth_planets = atoi(argv[i]);
+               } else
+               if (!strcmp(argv[i], "--stars-rotation")) {
+                       i++;
+                       if (argc == i)
+                               goto missing_parameter;
+                       config_improve_stars_rotation = atoi(argv[i]);
+               } else
                if (!strcmp(argv[i], "--fix-sky-rotation")) {
-                       config_fix_sky_rotation = 1;
+                       i++;
+                       if (argc == i)
+                               goto missing_parameter;
+                       config_improve_fix_sky_rotation = atoi(argv[i]);
                } else
                if (!strcmp(argv[i], "-o") || !strcmp(argv[i], "--debug-opengl")) {
                        config_debug_opengl = 1;
@@ -607,7 +641,7 @@ static void main_loop(void)
                        frame_render = 0;
                        /* start capturing for improved graphics */
                        if (render_improved)
-                               render_capture_start(config_fov, config_improve_extend_roads, config_improve_smooth_planets, config_fix_sky_rotation, config_debug_transparent);
+                               render_capture_start(config_fov, config_improve_extend_roads, config_improve_smooth_planets, config_improve_stars_rotation, config_improve_fix_sky_rotation, config_debug_transparent);
 
                        /* execute until the rendered image is ready (wait for VBL) */
                        cycle_count = 0;
index daa07cb..bd9c2c5 100644 (file)
@@ -237,6 +237,7 @@ typedef struct interpolation {
 
 /* rendering options */
 static int extend_roads; /* extend roads in its original width, rather than just using a single point */
+static int improve_stars; /* stars are rendered spherical */
 static int fix_sky_rotation; /* sky will rotate correctly by rotating planets/comet by 180 degrees */
 static double fov;
 static double debug_opacity;
@@ -289,7 +290,7 @@ static void flush_old_items(void)
 }
 
 /* rendering starts, initialize variables */
-void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, int _fix_sky_rotation, int debug)
+void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, int _improve_stars, int _fix_sky_rotation, int debug)
 {
 #if defined(DEBUG_COLOR) || defined(DEBUG_VERTEX)
        printf("start rendering a new frame...\n");
@@ -310,6 +311,7 @@ void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, i
        fov = _fov;
        extend_roads = _extend_roads;
        fix_sky_rotation = _fix_sky_rotation;
+       improve_stars = _improve_stars;
        /* set some transpareny, if debugging is enabled */
        debug_opacity = (debug) ? 0.5 : 1.0;
 
@@ -2301,7 +2303,7 @@ void render_one_item(render_item_t *render_item, int vr)
                for (i = 0; i < 16; i++)
                        color[i] = m68k_read_memory_16(mercenary_palette_stars() + (i << 2));
 
-               if (!vr) {
+               if (!vr && !improve_stars) {
                        /* render legacy stars (as with the original game) */
 
                        /* table offset is 91, so we substract it and add it back with different FOV, so table begins at later
index 568a3e3..aa87f39 100644 (file)
@@ -1,5 +1,5 @@
 
-void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, int _fix_sky_rotation, int debug);
+void render_capture_start(double _fov, int _extend_roads, int _smooth_planets, int _improve_stars, int _fix_sky_rotation, int debug);
 void render_capture_stop(void);
 void render_capture_event(int event);
 int render_all_items(double inter, int vr);