mirror of
https://github.com/digarok/gsplus.git
synced 2024-05-28 13:41:31 +00:00
eliminate the g_fatal_log array since fatal_printf() shows warning messages immediately.
This commit is contained in:
parent
f842678e43
commit
1a06196ae7
|
@ -44,7 +44,6 @@ extern byte *g_rom_fc_ff_ptr;
|
||||||
extern byte *g_rom_cards_ptr;
|
extern byte *g_rom_cards_ptr;
|
||||||
extern double g_cur_dcycs;
|
extern double g_cur_dcycs;
|
||||||
extern int g_rom_version;
|
extern int g_rom_version;
|
||||||
extern int g_fatal_log;
|
|
||||||
|
|
||||||
extern word32 g_adb_repeat_vbl;
|
extern word32 g_adb_repeat_vbl;
|
||||||
|
|
||||||
|
@ -3183,9 +3182,6 @@ void config_control_panel() {
|
||||||
g_cfg_slotdrive = -1;
|
g_cfg_slotdrive = -1;
|
||||||
g_cfg_select_partition = -1;
|
g_cfg_select_partition = -1;
|
||||||
while(g_config_control_panel & !(halt_sim&HALT_WANTTOQUIT)) {
|
while(g_config_control_panel & !(halt_sim&HALT_WANTTOQUIT)) {
|
||||||
if(g_fatal_log > 0) {
|
|
||||||
x_show_alert(0, 0);
|
|
||||||
}
|
|
||||||
cfg_home();
|
cfg_home();
|
||||||
line = 1;
|
line = 1;
|
||||||
max_line = 1;
|
max_line = 1;
|
||||||
|
|
|
@ -421,7 +421,6 @@ void x_dialog_create_gsport_conf(const char *str) {
|
||||||
int x_show_alert(int is_fatal, const char *str) {
|
int x_show_alert(int is_fatal, const char *str) {
|
||||||
// Not implemented yet
|
// Not implemented yet
|
||||||
adb_all_keys_up();
|
adb_all_keys_up();
|
||||||
clear_fatal_logs();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void x_toggle_status_lines(void) {
|
void x_toggle_status_lines(void) {
|
||||||
|
|
26
src/glog.c
26
src/glog.c
|
@ -14,11 +14,6 @@
|
||||||
|
|
||||||
extern int x_show_alert(int fatal, const char *str);
|
extern int x_show_alert(int fatal, const char *str);
|
||||||
|
|
||||||
#define MAX_FATAL_LOGS 20
|
|
||||||
|
|
||||||
int g_fatal_log = 0;
|
|
||||||
char *g_fatal_log_strs[MAX_FATAL_LOGS];
|
|
||||||
|
|
||||||
int glog(const char *s) {
|
int glog(const char *s) {
|
||||||
time_t timer;
|
time_t timer;
|
||||||
char buffer[26];
|
char buffer[26];
|
||||||
|
@ -63,33 +58,12 @@ int fatal_printf(const char *fmt, ...) {
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
if(g_fatal_log < 0) {
|
|
||||||
g_fatal_log = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = vsnprintf(buffer, sizeof(buffer), fmt, ap);
|
ret = vsnprintf(buffer, sizeof(buffer), fmt, ap);
|
||||||
|
|
||||||
glog(buffer);
|
glog(buffer);
|
||||||
|
|
||||||
x_show_alert(1, buffer);
|
x_show_alert(1, buffer);
|
||||||
/*
|
|
||||||
if (g_fatal_log < MAX_FATAL_LOGS) {
|
|
||||||
g_fatal_log_strs[g_fatal_log++] = strdup(buffer);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void clear_fatal_logs() {
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for(i = 0; i < g_fatal_log; i++) {
|
|
||||||
free(g_fatal_log_strs[i]);
|
|
||||||
g_fatal_log_strs[i] = 0;
|
|
||||||
}
|
|
||||||
g_fatal_log = 0;
|
|
||||||
}
|
|
|
@ -5,7 +5,6 @@ extern "C" {
|
||||||
int glogf(const char *s, ...);
|
int glogf(const char *s, ...);
|
||||||
|
|
||||||
int fatal_printf(const char *fmt, ...);
|
int fatal_printf(const char *fmt, ...);
|
||||||
void clear_fatal_logs(void);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,19 +79,15 @@ extern int g_screen_mdepth;
|
||||||
Ptr g_mac_fullscreen_state = 0;
|
Ptr g_mac_fullscreen_state = 0;
|
||||||
Rect g_main_window_saved_rect;
|
Rect g_main_window_saved_rect;
|
||||||
|
|
||||||
extern char *g_fatal_log_strs[];
|
|
||||||
extern int g_fatal_log;
|
|
||||||
|
|
||||||
int x_show_alert(int is_fatal, const char *str) {
|
int x_show_alert(int is_fatal, const char *str) {
|
||||||
DialogRef alert;
|
DialogRef alert;
|
||||||
DialogItemIndex out_item_hit;
|
DialogItemIndex out_item_hit;
|
||||||
CFStringRef cfstrref, cfstrref2;
|
CFStringRef cfstrref;
|
||||||
CFStringRef okstrref;
|
CFStringRef okstrref;
|
||||||
AlertStdCFStringAlertParamRec alert_param;
|
AlertStdCFStringAlertParamRec alert_param;
|
||||||
OSStatus osstat;
|
OSStatus osstat;
|
||||||
char *bufptr, *buf2ptr;
|
|
||||||
int sum, len;
|
if (!str || !*str) return 0;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* The dialog eats all events--including key-up events */
|
/* The dialog eats all events--including key-up events */
|
||||||
/* Call adb_all_keys_up() to prevent annoying key-repeat problems */
|
/* Call adb_all_keys_up() to prevent annoying key-repeat problems */
|
||||||
|
@ -100,36 +96,14 @@ int x_show_alert(int is_fatal, const char *str) {
|
||||||
/* auto-repeat will repeat the key, and the dialog re-appears...*/
|
/* auto-repeat will repeat the key, and the dialog re-appears...*/
|
||||||
adb_all_keys_up();
|
adb_all_keys_up();
|
||||||
|
|
||||||
sum = 20;
|
|
||||||
for(i = 0; i < g_fatal_log; i++) {
|
|
||||||
sum += strlen(g_fatal_log_strs[i]);
|
|
||||||
}
|
|
||||||
bufptr = (char*)malloc(sum);
|
|
||||||
buf2ptr = bufptr;
|
|
||||||
for(i = 0; i < g_fatal_log; i++) {
|
|
||||||
len = strlen(g_fatal_log_strs[i]);
|
|
||||||
len = MIN(len, sum);
|
|
||||||
len = MAX(len, 0);
|
|
||||||
memcpy(bufptr, g_fatal_log_strs[i], MIN(len, sum));
|
|
||||||
bufptr += len;
|
|
||||||
bufptr[0] = 0;
|
|
||||||
sum = sum - len;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfstrref = CFStringCreateWithCString(NULL, buf2ptr,
|
cfstrref = CFStringCreateWithCString(NULL, str,
|
||||||
kCFStringEncodingMacRoman);
|
kCFStringEncodingMacRoman);
|
||||||
|
|
||||||
printf("buf2ptr: :%s:\n", buf2ptr);
|
|
||||||
|
|
||||||
osstat = GetStandardAlertDefaultParams(&alert_param,
|
osstat = GetStandardAlertDefaultParams(&alert_param,
|
||||||
kStdCFStringAlertVersionOne);
|
kStdCFStringAlertVersionOne);
|
||||||
|
|
||||||
if(str) {
|
|
||||||
// Provide an extra option--create a file
|
|
||||||
cfstrref2 = CFStringCreateWithFormat(kCFAllocatorDefault, NULL,
|
|
||||||
CFSTR("Create ./%s"), str);
|
|
||||||
alert_param.otherText = cfstrref2;
|
|
||||||
}
|
|
||||||
okstrref = CFSTR("Click OK to continue");
|
okstrref = CFSTR("Click OK to continue");
|
||||||
if(is_fatal) {
|
if(is_fatal) {
|
||||||
okstrref = CFSTR("Click OK to exit GSplus");
|
okstrref = CFSTR("Click OK to exit GSplus");
|
||||||
|
@ -138,12 +112,9 @@ int x_show_alert(int is_fatal, const char *str) {
|
||||||
&alert_param, &alert);
|
&alert_param, &alert);
|
||||||
out_item_hit = -1;
|
out_item_hit = -1;
|
||||||
RunStandardAlert(alert, NULL, &out_item_hit);
|
RunStandardAlert(alert, NULL, &out_item_hit);
|
||||||
printf("out_item_hit: %d\n", out_item_hit);
|
|
||||||
free(buf2ptr);
|
|
||||||
|
|
||||||
clear_fatal_logs(); /* free the fatal_log string memory */
|
CFRelease(cfstrref);
|
||||||
return (out_item_hit >= 3);
|
return (out_item_hit >= 3);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,28 +130,18 @@ pascal OSStatus quit_event_handler(EventHandlerCallRef call_ref, EventRef event,
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_simple_alert(char *str1, char *str2, char *str3, int num) {
|
void show_simple_alert(char *str1, char *str2, char *str3, int num) {
|
||||||
char buf[256];
|
char buf[4096];
|
||||||
|
|
||||||
g_fatal_log_strs[0] = gsplus_malloc_str(str1);
|
if (num) {
|
||||||
g_fatal_log_strs[1] = gsplus_malloc_str(str2);
|
snprintf(buffer, sizeof(buffer), "%s%s%s: %d", str1, str2, str3, num);
|
||||||
g_fatal_log_strs[2] = gsplus_malloc_str(str3);
|
} else {
|
||||||
g_fatal_log = 3;
|
snprintf(buffer, sizeof(buffer), "%s%s%s", str1, str2, str3);
|
||||||
if(num != 0) {
|
|
||||||
snprintf(buf, 250, ": %d", num);
|
|
||||||
g_fatal_log_strs[g_fatal_log++] = gsplus_malloc_str(buf);
|
|
||||||
}
|
}
|
||||||
x_show_alert(0, 0);
|
x_show_alert(0, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void x_dialog_create_gsport_conf(const char *str) {
|
void x_dialog_create_gsport_conf(const char *str) {
|
||||||
char *path;
|
config_write_config_gsplus_file();
|
||||||
char tmp_buf[512];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = x_show_alert(1, str);
|
|
||||||
if(ret) {
|
|
||||||
config_write_config_gsplus_file();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -698,11 +659,6 @@ CantGetNibRef:
|
||||||
|
|
||||||
void xdriver_end() {
|
void xdriver_end() {
|
||||||
|
|
||||||
printf("xdriver_end\n");
|
|
||||||
|
|
||||||
if(g_fatal_log >= 0) {
|
|
||||||
x_show_alert(1, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,6 @@ void scc_socket_open_outgoing(int port, double dcycs) {
|
||||||
#endif
|
#endif
|
||||||
scc_socket_close_handle(sockfd);
|
scc_socket_close_handle(sockfd);
|
||||||
scc_socket_close(port, 1, dcycs);
|
scc_socket_close(port, 1, dcycs);
|
||||||
x_show_alert(0, 0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(&sa_in.sin_addr.s_addr, hostentptr->h_addr,
|
memcpy(&sa_in.sin_addr.s_addr, hostentptr->h_addr,
|
||||||
|
|
|
@ -1011,7 +1011,6 @@ int gsplusmain(int argc, char **argv) {
|
||||||
iwm_shut();
|
iwm_shut();
|
||||||
fixed_memory_ptrs_shut();
|
fixed_memory_ptrs_shut();
|
||||||
load_roms_shut_memory();
|
load_roms_shut_memory();
|
||||||
clear_fatal_logs();
|
|
||||||
|
|
||||||
// OG Not needed anymore : the emulator will quit gently
|
// OG Not needed anymore : the emulator will quit gently
|
||||||
//my_exit(0);
|
//my_exit(0);
|
||||||
|
@ -1184,8 +1183,6 @@ void setup_gsplus_file(char *outname, int maxlen, int ok_if_missing, int can_cre
|
||||||
x_dialog_create_gsport_conf(*name_ptr);
|
x_dialog_create_gsport_conf(*name_ptr);
|
||||||
can_create_file = 0;
|
can_create_file = 0;
|
||||||
|
|
||||||
// But clear out the fatal_printfs first
|
|
||||||
clear_fatal_logs();
|
|
||||||
setup_gsplus_file(outname, maxlen, ok_if_missing, can_create_file, name_ptr);
|
setup_gsplus_file(outname, maxlen, ok_if_missing, can_create_file, name_ptr);
|
||||||
// It's one-level of recursion--it cannot loop since we
|
// It's one-level of recursion--it cannot loop since we
|
||||||
// clear can_create_file.
|
// clear can_create_file.
|
||||||
|
|
|
@ -58,6 +58,7 @@ void x_dialog_create_gsport_conf(const char *str) {
|
||||||
int x_show_alert(int is_fatal, const char *str) {
|
int x_show_alert(int is_fatal, const char *str) {
|
||||||
|
|
||||||
if (str && *str) {
|
if (str && *str) {
|
||||||
|
adb_all_keys_up();
|
||||||
MessageBox(NULL, str, "GS+", is_fatal ? MB_ICONERROR : MB_ICONWARNING);
|
MessageBox(NULL, str, "GS+", is_fatal ? MB_ICONERROR : MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -143,10 +144,6 @@ int main(int argc, char **argv) {
|
||||||
size.cx, size.cy,
|
size.cx, size.cy,
|
||||||
NULL, NULL, GetModuleHandle(NULL), NULL);
|
NULL, NULL, GetModuleHandle(NULL), NULL);
|
||||||
|
|
||||||
printf("g_hwnd_main = %p, height = %d\n", hwnd, size.cx);
|
|
||||||
GetWindowRect(hwnd, &rect);
|
|
||||||
printf("...rect is: %ld, %ld, %ld, %ld\n", rect.left, rect.top,
|
|
||||||
rect.right, rect.bottom);
|
|
||||||
|
|
||||||
// Enable non-blocking, character-at-a-time console I/O.
|
// Enable non-blocking, character-at-a-time console I/O.
|
||||||
// win_nonblock_read_stdin() expects this behavior.
|
// win_nonblock_read_stdin() expects this behavior.
|
||||||
|
|
|
@ -254,7 +254,6 @@ int x_show_alert(int is_fatal, const char *str) {
|
||||||
/* Not implemented yet */
|
/* Not implemented yet */
|
||||||
adb_all_keys_up();
|
adb_all_keys_up();
|
||||||
|
|
||||||
clear_fatal_logs();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user