Skip to content

Commit 9311fa5

Browse files
author
Maciek
committed
Rewind progress bar optimisations, desc fixes
1 parent 5cb58a8 commit 9311fa5

File tree

5 files changed

+55
-31
lines changed

5 files changed

+55
-31
lines changed

main.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,25 @@ void mainloop(void)
260260
if( get_nShortcutKey(paddata.buttons) == 8 ){ // 8 == REWIND_SHORTCUT KEY
261261

262262
wavout_enable=0;
263-
263+
int refreshProgress = 0;
264264
while(1){
265265
renderer_set_msg(get_rewind_progress_bar());
266266
//begin rewinds
267267
if( read_rewind_state() > 0 ){
268-
268+
refreshProgress = 1;
269269
for(line=0; line<154; line++) //emulate a frame
270270
gb_run();
271271

272272
pgScreenFlip();
273+
}else{
274+
if(refreshProgress){
275+
for(line=0; line<154; line++) //emulate a frame
276+
gb_run();
277+
278+
pgScreenFlip();
279+
refreshProgress = 0;
280+
}
273281
}
274-
275282
sceKernelDelayThread(WAIT_MILIS);
276283

277284

menu_credits.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ static unsigned long get_text_color() {
1111
static char* credits[] = {
1212
" RIN REWIND MOD CREDITS AND VERSION HISTORY",
1313
"",
14-
"",
1514
"Mr. Mirakichi - 2005/08/22",
1615
" Original version of RIN 1.32",
1716
"",
@@ -22,7 +21,8 @@ static char* credits[] = {
2221
" Rewind mod v2 (this version):",
2322
" - Sources ported to latest PSP SDK,",
2423
" - Dedicated menu for rewind,",
25-
" - Support for extra memory (PSP Slim),",
24+
" - Support for extra memory (PSP Slim and higher,",
25+
" PS Vita with Adrenaline)",
2626
" - Adjustable memory and states amount in rewind,",
2727
" - Progress bar for actual rewind status,",
2828
" - Fixed crash when loading game with a different",

menu_rewind.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static void print_rewind_states_limit_line(unsigned long *x, unsigned long *y, c
173173

174174
static void print_rewind_states_help(unsigned long *x, unsigned long *y, const SETTING *local, const long sel) {
175175
#define HELP_COLOR RGB(26, 163, 255)
176-
unsigned help_y = 15;
176+
unsigned help_y = 13;
177177
unsigned help_x = 4;
178178
char tmpString[MAX_MENU_ENTRY_LENGTH] = {0};
179179
if(local->rewind_always_use_max_states){
@@ -184,15 +184,19 @@ static void print_rewind_states_help(unsigned long *x, unsigned long *y, const S
184184

185185
pgPrintf(help_x,help_y,HELP_COLOR, "---------------------------------------------------");
186186
help_y += 2;
187-
pgPrintf(help_x,help_y,HELP_COLOR, "On newer PSP models more memory for rewind can be ");
187+
pgPrintf(help_x,help_y,HELP_COLOR, "On newer PSP models (PSP Slim and higher), more");
188188
help_y += 1;
189-
pgPrintf(help_x,help_y,HELP_COLOR, "enabled by using CFW with extra memory for homebrew");
189+
pgPrintf(help_x,help_y,HELP_COLOR, "memory for rewind can be enabled by using CFW with");
190190
help_y += 1;
191-
pgPrintf(help_x,help_y,HELP_COLOR, "support. Enter recovery menu and enable:");
191+
pgPrintf(help_x,help_y,HELP_COLOR, "extra memory for homebrew support.");
192+
help_y += 1;
193+
pgPrintf(help_x,help_y,HELP_COLOR, "Enter recovery menu and enable:");
192194
help_y += 1;
193195
pgPrintf(help_x,help_y,HELP_COLOR, "\"Advanced/Force High Memory Layout\".");
196+
help_y += 1;
197+
pgPrintf(help_x,help_y,HELP_COLOR, "The same applies to PS Vita with Adrenaline.");
194198
help_y += 2;
195-
pgPrintf(help_x,help_y,HELP_COLOR, "---------------------------------------------------");
199+
pgPrintf(help_x,help_y,HELP_COLOR, "----------------------------------------------------");
196200
help_y += 1;
197201
pgPrintf(help_x,help_y,HELP_COLOR, "");
198202
}

rewind.c

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ e-mail: efengeler@gmail.com
1010

1111
int num_rwnd_states = 0;
1212
int rwnd_state_size = 0;
13+
int number_of_used_states = 0;
1314
const int TOTAL_REWIND_MEMORY = 5*1024*1024; //reserves 5 MB for rewind states
1415
const int SAFE_MEMORY_MARGIN = 1*1024*1024;//left for system to use
1516
unsigned max_rewind_memory = 5*1024*1024;
@@ -25,17 +26,23 @@ struct rewind_state{
2526
struct rewind_state *ptr_rewind_states, *prev_state, *next_state;
2627

2728
int get_used_rewind_states_number(){
28-
int retVal = 0;
29-
if(setting.rewind_enabled && ptr_rewind_states != NULL){
30-
struct rewind_state* act = ptr_rewind_states->next;
31-
while(act != ptr_rewind_states){
32-
if(act->have_data){
33-
retVal++;
34-
}
35-
act = act->next;
36-
}
37-
}
38-
return retVal;
29+
// int retVal = 0;
30+
// if(setting.rewind_enabled && ptr_rewind_states != NULL){
31+
// if(ptr_rewind_states->have_data){
32+
// retVal++;
33+
// }
34+
// struct rewind_state* act = ptr_rewind_states->next;
35+
// while(act != ptr_rewind_states){
36+
// if(act->have_data){
37+
// retVal++;
38+
// }
39+
// act = act->next;
40+
// }
41+
// }
42+
// return retVal;
43+
// printf("NUM STATES DIRECT: %d\n",retVal);
44+
// printf("NUM STATES VARIAB: %d\n\n",number_of_used_states);
45+
return number_of_used_states;
3946
}
4047

4148
char* get_rewind_progress_bar(){
@@ -75,6 +82,7 @@ void allocate_rewind_states(void){
7582
created_state->next = first_state;
7683
first_state->prev = created_state;
7784
ptr_rewind_states = first_state;
85+
number_of_used_states = 0;
7886
}
7987

8088
print_rewind_debug_info(setting,"allocate_rewind_states");
@@ -100,9 +108,9 @@ static void set_number_of_rewind_states(int *number_of_states) {
100108
}
101109

102110
void free_rewind_states(void){
103-
104-
struct rewind_state *now_state;
105-
111+
112+
struct rewind_state *now_state;
113+
106114
now_state = ptr_rewind_states;
107115
if(ptr_rewind_states){
108116
prev_state = now_state->prev;
@@ -117,25 +125,30 @@ void free_rewind_states(void){
117125
now_state = next_state;
118126
}
119127
ptr_rewind_states = NULL;
128+
number_of_used_states = 0;
120129
}
121130
}
122131

123132

124133
void save_rewind_state(void){
125-
134+
126135
gb_save_state(ptr_rewind_states->data); //declared in "gbcore/gb.h"
136+
if(!ptr_rewind_states->have_data){
137+
number_of_used_states++;
138+
}
127139
ptr_rewind_states->have_data = 1;
128140
ptr_rewind_states = ptr_rewind_states->next;
129141
}
130142

131143
int read_rewind_state(void){
132-
144+
133145
int ret_val = -999;
134146
prev_state = ptr_rewind_states->prev;
135147

136148
if (prev_state->have_data > 0 ){
137149
load_state_tmp( prev_state->data); //declarado en "saveload.h"
138150
prev_state->have_data = 0;
151+
number_of_used_states--;
139152
ptr_rewind_states = ptr_rewind_states->prev;
140153
ret_val = 1;
141154
}

tools.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ char *get_progress_bar(int max, int act) {
1414
const char ACT_CHAR = 9;
1515
const char BUILD_CHAR = 10;
1616
static char progress[MAX_PROGRESS];
17-
static char string[MAX_STR];
17+
// static char string[MAX_STR];
1818
if (max == 0) {
19-
string[0] = '\0';
19+
progress[0] = '\0';
2020
} else {
2121
memset(progress, BUILD_CHAR, MAX_PROGRESS);
2222

@@ -33,11 +33,11 @@ char *get_progress_bar(int max, int act) {
3333
}
3434
progress[actInBar] = ACT_CHAR;
3535

36-
memset(string, 0, MAX_STR);
36+
// memset(string, 0, MAX_STR);
3737
// snprintf(string, MAX_STR, " Rewind :%s", progress);
38-
snprintf(string, MAX_STR, "%s", progress);
38+
// snprintf(string, MAX_STR, "%s", progress);
3939
}
40-
return string;
40+
return progress;
4141
}
4242

4343
//#define TESTING

0 commit comments

Comments
 (0)