4747#include "e6y.h" //e6y
4848
4949#include "dsda/settings.h"
50+ #include <dsda/configuration.h>
5051
5152//
5253// SCREEN WIPE PACKAGE
@@ -66,6 +67,9 @@ static screeninfo_t wipe_scr;
6667// e6y: resolution limitation is removed
6768static int * y_lookup = NULL ;
6869
70+ static int target_fps ;
71+ extern int capturing_video ;
72+
6973// e6y: resolution limitation is removed
7074void R_InitMeltRes (void )
7175{
@@ -74,11 +78,35 @@ void R_InitMeltRes(void)
7478 y_lookup = Z_Calloc (1 , SCREENWIDTH * sizeof (* y_lookup ));
7579}
7680
81+ int rescale_pixels (int number )
82+ {
83+ int new_number = number * SCREENHEIGHT / 200 ;
84+ return (number >= 1 && new_number < 1 ) ? 1 : (number * SCREENHEIGHT / 200 );
85+ }
86+
87+ int slow_down (int number )
88+ {
89+ int new_number = number * TICRATE / target_fps ;
90+ return new_number < 1 ? 1 : new_number ;
91+ }
92+
93+ int speed_up (int number )
94+ {
95+ return number * target_fps / TICRATE ;
96+ }
97+
7798static int wipe_initMelt (int ticks )
7899{
79100 int i ;
80101 int block_width = WIDE_SCREENWIDTH / 320 ;
81102
103+ if (block_width < 1 )
104+ block_width = 1 ;
105+
106+ // wipe runs at fixed 35fps, but its framerate in the video is changed to cap_fps
107+ // we change its speed depending on cap_fps so it looks the same in the video
108+ target_fps = capturing_video ? dsda_IntConfig (dsda_config_cap_fps ) : TICRATE ;
109+
82110 if (V_IsSoftwareMode ())
83111 {
84112 // copy start screen to main screen
@@ -104,6 +132,13 @@ static int wipe_initMelt(int ticks)
104132 if (y_lookup [i ] == -16 )
105133 y_lookup [i ] = -15 ;
106134 }
135+
136+ for (i = 0 ; i < SCREENWIDTH ; i ++ )
137+ {
138+ // range of values has to be increased along with framerate
139+ // so the pattern retains overall shape
140+ y_lookup [i ] = speed_up (rescale_pixels (y_lookup [i ]));
141+ }
107142 return 0 ;
108143}
109144
@@ -115,7 +150,7 @@ static int wipe_doMelt(int ticks)
115150 while (ticks -- ) {
116151 for (i = 0 ;i < (SCREENWIDTH );i ++ ) {
117152 if (y_lookup [i ]< 0 ) {
118- y_lookup [i ]++ ;
153+ y_lookup [i ] += rescale_pixels ( 1 ) ;
119154 done = false;
120155 continue ;
121156 }
@@ -124,33 +159,38 @@ static int wipe_doMelt(int ticks)
124159 int j , dy ;
125160
126161 /* cph 2001/07/29 -
127- * The original melt rate was 8 pixels/sec, i.e. 25 frames to melt
128- * the whole screen, so make the melt rate depend on SCREENHEIGHT
129- * so it takes no longer in high res
130- */
131- dy = (y_lookup [i ] < 16 ) ? y_lookup [i ]+ 1 : SCREENHEIGHT /25 ;
162+ * The original melt rate was 8 pixels/sec, i.e. 25 frames to melt
163+ * the whole screen, so make the melt rate depend on SCREENHEIGHT
164+ * so it takes no longer in high res
165+ */
166+
167+ // slowing things down by reducing deltas
168+ // so wipe retains duration at higher framerates
169+ dy = (y_lookup [i ] < slow_down (rescale_pixels (16 )))
170+ ? y_lookup [i ] + slow_down (rescale_pixels (1 ))
171+ : slow_down (rescale_pixels (8 ));
132172 if (y_lookup [i ]+ dy >= SCREENHEIGHT )
133173 dy = SCREENHEIGHT - y_lookup [i ];
134174
135- if (V_IsSoftwareMode ()) {
136- s = wipe_scr_end .data + (y_lookup [i ]* wipe_scr_end .pitch + i );
137- d = wipe_scr .data + (y_lookup [i ]* wipe_scr .pitch + i );
138- for (j = dy ;j ;j -- ) {
139- d [0 ] = s [0 ];
140- d += wipe_scr .pitch ;
141- s += wipe_scr_end .pitch ;
175+ if (V_IsSoftwareMode ()) {
176+ s = wipe_scr_end .data + (y_lookup [i ]* wipe_scr_end .pitch + i );
177+ d = wipe_scr .data + (y_lookup [i ]* wipe_scr .pitch + i );
178+ for (j = dy ;j ;j -- ) {
179+ d [0 ] = s [0 ];
180+ d += wipe_scr .pitch ;
181+ s += wipe_scr_end .pitch ;
182+ }
142183 }
143- }
144184 y_lookup [i ] += dy ;
145- if (V_IsSoftwareMode ()) {
146- s = wipe_scr_start .data + i ;
147- d = wipe_scr .data + (y_lookup [i ]* wipe_scr .pitch + i );
148- for (j = SCREENHEIGHT - y_lookup [i ];j ;j -- ) {
149- d [0 ] = s [0 ];
150- d += wipe_scr .pitch ;
151- s += wipe_scr_end .pitch ;
185+ if (V_IsSoftwareMode ()) {
186+ s = wipe_scr_start .data + i ;
187+ d = wipe_scr .data + (y_lookup [i ]* wipe_scr .pitch + i );
188+ for (j = SCREENHEIGHT - y_lookup [i ];j ;j -- ) {
189+ d [0 ] = s [0 ];
190+ d += wipe_scr .pitch ;
191+ s += wipe_scr_end .pitch ;
192+ }
152193 }
153- }
154194 done = false;
155195 }
156196 }
0 commit comments