Skip to content

Commit 3edf32b

Browse files
committed
white space cleanup
Signed-off-by: Vincent-FK <[email protected]>
1 parent 604f9bd commit 3edf32b

File tree

9 files changed

+277
-337
lines changed

9 files changed

+277
-337
lines changed

emu.c

Lines changed: 73 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -44,38 +44,41 @@ rcvar_t emu_exports[] =
4444
/* Quick save and turn off the console */
4545
void quick_save_and_poweroff()
4646
{
47-
/* Vars */
48-
char shell_cmd[1024];
49-
FILE *fp;
50-
51-
/* Send command to kill any previously scheduled shutdown */
52-
sprintf(shell_cmd, "pkill %s", SHELL_CMD_SCHEDULE_POWERDOWN);
53-
fp = popen(shell_cmd, "r");
54-
if (fp == NULL) {
55-
printf("Failed to run command %s\n", shell_cmd);
56-
}
57-
58-
/* Save */
59-
state_file_save(quick_save_file);
60-
61-
/* Write quick load file */
62-
sprintf(shell_cmd, "%s SDL_NOMOUSE=1 \"%s\" --loadStateFile \"%s\" \"%s\"",
63-
SHELL_CMD_WRITE_QUICK_LOAD_CMD, prog_name, quick_save_file, mRomName);
64-
printf("Cmd write quick load file:\n %s\n", shell_cmd);
65-
fp = popen(shell_cmd, "r");
66-
if (fp == NULL) {
67-
printf("Failed to run command %s\n", shell_cmd);
68-
}
69-
70-
/* Clean Poweroff */
71-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
72-
fp = popen(shell_cmd, "r");
73-
if (fp == NULL) {
74-
printf("Failed to run command %s\n", shell_cmd);
75-
}
76-
77-
/* Exit Emulator */
78-
exit(0);
47+
/* Vars */
48+
char shell_cmd[1024];
49+
FILE *fp;
50+
51+
/* Send command to kill any previously scheduled shutdown */
52+
sprintf(shell_cmd, "pkill %s", SHELL_CMD_SCHEDULE_POWERDOWN);
53+
fp = popen(shell_cmd, "r");
54+
if (fp == NULL)
55+
{
56+
printf("Failed to run command %s\n", shell_cmd);
57+
}
58+
59+
/* Save */
60+
state_file_save(quick_save_file);
61+
62+
/* Write quick load file */
63+
sprintf(shell_cmd, "%s SDL_NOMOUSE=1 \"%s\" --loadStateFile \"%s\" \"%s\"",
64+
SHELL_CMD_WRITE_QUICK_LOAD_CMD, prog_name, quick_save_file, mRomName);
65+
printf("Cmd write quick load file:\n %s\n", shell_cmd);
66+
fp = popen(shell_cmd, "r");
67+
if (fp == NULL)
68+
{
69+
printf("Failed to run command %s\n", shell_cmd);
70+
}
71+
72+
/* Clean Poweroff */
73+
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
74+
fp = popen(shell_cmd, "r");
75+
if (fp == NULL)
76+
{
77+
printf("Failed to run command %s\n", shell_cmd);
78+
}
79+
80+
/* Exit Emulator */
81+
exit(0);
7982
}
8083

8184

@@ -127,42 +130,47 @@ void emu_run()
127130
lcd_begin();
128131

129132
/* Load slot */
130-
if(load_state_slot != -1){
131-
printf("LOADING FROM SLOT %d...\n", load_state_slot+1);
132-
state_load(load_state_slot);
133-
printf("LOADED FROM SLOT %d\n", load_state_slot+1);
134-
load_state_slot = -1;
135-
}
136-
/* Load file */
137-
else if(load_state_file != NULL){
138-
printf("LOADING FROM FILE %s...\n", load_state_file);
139-
state_file_load(load_state_file);
140-
printf("LOADED FROM SLOT %s\n", load_state_file);
141-
load_state_file = NULL;
142-
}
143-
/* Load quick save file */
144-
else if(access( quick_save_file, F_OK ) != -1){
145-
printf("Found quick save file: %s\n", quick_save_file);
146-
147-
int resume = launch_resume_menu_loop();
148-
if(resume == RESUME_YES){
149-
printf("Resume game from quick save file: %s\n", quick_save_file);
150-
state_file_load(quick_save_file);
133+
if (load_state_slot != -1)
134+
{
135+
printf("LOADING FROM SLOT %d...\n", load_state_slot+1);
136+
state_load(load_state_slot);
137+
printf("LOADED FROM SLOT %d\n", load_state_slot+1);
138+
load_state_slot = -1;
151139
}
152-
else{
153-
printf("Reset game\n");
154-
155-
/* Remove quicksave file if present */
156-
if (remove(quick_save_file) == 0){
157-
printf("Deleted successfully: %s\n", quick_save_file);
158-
}
159-
else{
160-
printf("Unable to delete the file: %s\n", quick_save_file);
161-
}
140+
/* Load file */
141+
else if (load_state_file != NULL)
142+
{
143+
printf("LOADING FROM FILE %s...\n", load_state_file);
144+
state_file_load(load_state_file);
145+
printf("LOADED FROM SLOT %s\n", load_state_file);
146+
load_state_file = NULL;
147+
}
148+
/* Load quick save file */
149+
else if(access( quick_save_file, F_OK ) != -1)
150+
{
151+
printf("Found quick save file: %s\n", quick_save_file);
152+
153+
int resume = launch_resume_menu_loop();
154+
if (resume == RESUME_YES)
155+
{
156+
printf("Resume game from quick save file: %s\n", quick_save_file);
157+
state_file_load(quick_save_file);
158+
}
159+
else {
160+
printf("Reset game\n");
161+
162+
/* Remove quicksave file if present */
163+
if (remove(quick_save_file) == 0)
164+
{
165+
printf("Deleted successfully: %s\n", quick_save_file);
166+
}
167+
else {
168+
printf("Unable to delete the file: %s\n", quick_save_file);
169+
}
170+
}
162171
}
163-
}
164172

165-
/* Main emulation loop */
173+
/* Main emulation loop */
166174
for (;;)
167175
{
168176
cpu_emulate(2280);
@@ -197,15 +205,3 @@ void emu_run()
197205
emu_step();
198206
}
199207
}
200-
201-
202-
203-
204-
205-
206-
207-
208-
209-
210-
211-

emu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ extern char *quick_save_file;
1414
extern int mQuickSaveAndPoweroff;
1515

1616
#endif
17-
18-

loader.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,3 @@ rcvar_t loader_exports[] =
513513
RCV_INT("memrand", &memrand),
514514
RCV_END
515515
};
516-
517-
518-
519-
520-
521-
522-
523-
524-

loader.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,3 @@ void state_file_load(char *filepath);
3030
int check_savefile(int n, char *savefile);
3131

3232
#endif
33-
34-

main.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ static int bad_signals[] =
181181
/* Handler for SIGUSR1, caused by closing the console */
182182
void handle_sigusr1(int sig)
183183
{
184-
//printf("Caught signal USR1 %d\n", sig);
184+
//printf("Caught signal USR1 %d\n", sig);
185185

186-
/* Exit menu if it was launched */
187-
stop_menu_loop = 1;
186+
/* Exit menu if it was launched */
187+
stop_menu_loop = 1;
188188

189-
/* Signal to quick save and poweoff after next loop */
190-
mQuickSaveAndPoweroff = 1;
189+
/* Signal to quick save and poweoff after next loop */
190+
mQuickSaveAndPoweroff = 1;
191191
}
192192

193193
static void fatalsignal(int s)
@@ -246,21 +246,21 @@ int main(int argc, char *argv[])
246246

247247
/* Save Rom path */
248248
mRomName = rom;
249-
mRomPath = (char *)malloc(strlen(mRomName)+1);
250-
strcpy(mRomPath, mRomName);
251-
char *slash = strrchr ((char*)mRomPath, '/');
252-
*slash = 0;
253-
254-
/* Rom name without extension */
255-
char *point = strrchr ((char*)slash+1, '.');
256-
*point = 0;
257-
258-
/* Set quicksave filename */
259-
quick_save_file = (char *)malloc(strlen(mRomPath) + strlen(slash+1) +
260-
strlen(quick_save_file_extension) + 2 + 1);
261-
sprintf(quick_save_file, "%s/%s.%s",
262-
mRomPath, slash+1, quick_save_file_extension);
263-
printf("Quick_save_file: %s\n", quick_save_file);
249+
mRomPath = (char *) malloc(strlen(mRomName) + 1);
250+
strcpy(mRomPath, mRomName);
251+
char *slash = strrchr((char *) mRomPath, '/');
252+
*slash = 0;
253+
254+
/* Rom name without extension */
255+
char *point = strrchr ((char *) slash + 1, '.');
256+
*point = 0;
257+
258+
/* Set quicksave filename */
259+
quick_save_file = (char *) malloc(strlen(mRomPath) + strlen(slash + 1) +
260+
strlen(quick_save_file_extension) + 2 + 1);
261+
sprintf(quick_save_file, "%s/%s.%s",
262+
mRomPath, slash + 1, quick_save_file_extension);
263+
printf("Quick_save_file: %s\n", quick_save_file);
264264

265265
/* Init USR1 Signal (for quick save and poweroff) */
266266
signal(SIGUSR1, handle_sigusr1);

0 commit comments

Comments
 (0)