manually redoing Kelvin's glogf work

This commit is contained in:
Dagen Brock 2017-01-20 13:28:09 -06:00
parent e584e82f35
commit aa240efdc8
11 changed files with 58 additions and 44 deletions

View File

@ -181,8 +181,7 @@ adb_init()
for(i = 0; i < 128; i++) {
keycode = a2_key_to_ascii[i][0];
if(keycode != i) {
gloghead(); printf("ADB keycode lost/skipped: i=%x: keycode=%x\n",
i, keycode);
glogf("ADB keycode lost/skipped: i=%x: keycode=%x\n", i, keycode);
my_exit(1);
}
}
@ -497,12 +496,12 @@ adb_set_config(word32 val0, word32 val1, word32 val2)
new_mouse = val0 >> 4;
new_kbd = val0 & 0xf;
if(new_mouse != g_mouse_ctl_addr) {
gloghead(); printf("ADB config: mouse from %x to %x!\n", g_mouse_ctl_addr, new_mouse);
glogf("ADB config: mouse from %x to %x!\n", g_mouse_ctl_addr, new_mouse);
adb_error();
g_mouse_ctl_addr = new_mouse;
}
if(new_kbd != g_kbd_ctl_addr) {
gloghead(); printf("ADB config: kbd from %x to %x!\n", g_kbd_ctl_addr, new_kbd);
glogf("ADB config: kbd from %x to %x!\n", g_kbd_ctl_addr, new_kbd);
adb_error();
g_kbd_ctl_addr = new_kbd;
}
@ -565,7 +564,7 @@ void
adb_set_new_mode(word32 val)
{
if(val & 0x03) {
gloghead(); printf("Disabling keyboard/mouse:%02x!\n", val);
glogf("Disabling keyboard/mouse:%02x!\n", val);
}
if(val & 0xa2) {
@ -1577,7 +1576,7 @@ adb_read_c000()
/* got one */
if((g_kbd_read_no_update++ > 5) && (g_kbd_chars_buffered > 1)) {
/* read 5 times, keys pending, let's move it along */
gloghead(); printf("Read %02x %d times, tossing\n", g_kbd_buf[0],
glogf("Read %02x %d times, tossing\n", g_kbd_buf[0],
g_kbd_read_no_update);
adb_access_c010();
}
@ -1664,7 +1663,7 @@ adb_increment_speed()
str = "... 8.0MHz";
break;
}
gloghead(); printf("Setting g_limit_speed = %d %s\n", g_limit_speed, str);
glogf("Setting g_limit_speed = %d %s\n", g_limit_speed, str);
}
void
@ -1730,7 +1729,7 @@ adb_physical_key_update(int a2code, int is_up)
/* Only process reset requests here */
if(is_up == 0 && a2code == 0x7f && CTRL_DOWN) {
/* Reset pressed! */
gloghead(); printf("Reset pressed since CTRL_DOWN: %d\n", CTRL_DOWN);
glogf("Reset pressed since CTRL_DOWN: %d\n", CTRL_DOWN);
do_reset();
return;
}
@ -1764,7 +1763,7 @@ adb_physical_key_update(int a2code, int is_up)
break;
case 0x07: /* F7 - fast disk emul */
g_fast_disk_emul = !g_fast_disk_emul;
gloghead(); printf("g_fast_disk_emul is now %d\n",
glogf("g_fast_disk_emul is now %d\n",
g_fast_disk_emul);
break;
case 0x08: /* F8 - warp pointer */
@ -1777,11 +1776,11 @@ adb_physical_key_update(int a2code, int is_up)
case 0x09: /* F9 - swap paddles */
if(SHIFT_DOWN) {
g_swap_paddles = !g_swap_paddles;
gloghead(); printf("Swap paddles is now: %d\n",
glogf("Swap paddles is now: %d\n",
g_swap_paddles);
} else {
g_invert_paddles = !g_invert_paddles;
gloghead(); printf("Invert paddles is now: %d\n",
glogf("Invert paddles is now: %d\n",
g_invert_paddles);
}
break;

View File

@ -725,7 +725,7 @@ config_parse_option(char *buf, int pos, int len, int line)
}
// find "name" as first contiguous string
gloghead(); printf("...parse_option: line %d, len:%d \"%s\"\n", line, len, &buf[pos]);
glogf("...parse_option: line %d, len:%d \"%s\"\n", line, len, &buf[pos]);
// printf("...parse_option: line %d, %p,%p = %s (%s) len:%d\n", line, &buf[pos], buf, &buf[pos], buf, len);
@ -889,7 +889,7 @@ config_load_roms()
return;
}
gloghead(); printf("Read: %d bytes of ROM\n", ret);
glogf("Read: %d bytes of ROM\n", ret);
if(ret != len) {
fatal_printf("errno: %d\n", errno);
g_config_control_panel = 1;
@ -1274,7 +1274,7 @@ config_write_config_gsplus_file()
int slot, drive;
int i;
gloghead(); printf("Writing configuration file to %s\n", g_config_gsplus_name);
glogf("Writing configuration file to %s\n", g_config_gsplus_name);
fconf = fopen(g_config_gsplus_name, "w+");
if(fconf == 0) {
@ -1540,7 +1540,7 @@ insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
if(buf_2img[0] == '2' && buf_2img[1] == 'I' && buf_2img[2] == 'M' &&
buf_2img[3] == 'G') {
/* It's a 2IMG disk */
gloghead(); printf("Image named %s is in 2IMG format\n", dsk->name_ptr);
glogf("Image named %s is in 2IMG format\n", dsk->name_ptr);
image_identified = 1;
if(buf_2img[12] == 0) {
@ -1555,7 +1555,7 @@ insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
}
if((buf_2img[17] & 1) && (dsk->image_type == DSK_TYPE_DOS33)) {
dsk->vol_num = buf_2img[16];
gloghead(); printf("Setting DOS 3.3 vol num to %d\n", dsk->vol_num);
glogf("Setting DOS 3.3 vol num to %d\n", dsk->vol_num);
}
// Some 2IMG archives have the size byte reversed
size = (buf_2img[31] << 24) + (buf_2img[30] << 16) +
@ -1579,7 +1579,7 @@ insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
(buf_2img[0x42] << 8) + buf_2img[0x43];
if((size >= (exp_size + 0x54)) && (tmp == exp_size)) {
/* It's diskcopy since data size field matches */
gloghead(); printf("Image named %s is in Mac diskcopy format\n", dsk->name_ptr);
glogf("Image named %s is in Mac diskcopy format\n", dsk->name_ptr);
image_identified = 1;
dsk->image_start += 0x54;
dsk->image_size = exp_size;
@ -1652,8 +1652,7 @@ insert_disk(int slot, int drive, const char *name, int ejected, int force_size,
nibs = len;
}
if(size != 35*len) {
gloghead(); fatal_printf("Disk 5.25 error: size is %d, not 140K. "
"Will try to mount anyway\n", size, 35*len);
glogf("Disk 5.25 error: size is %d, not 140K. Will try to mount anyway\n", size, 35*len);
}
for(i = 0; i < 35; i++) {
iwm_move_to_track(dsk, 4*i);
@ -1741,7 +1740,7 @@ eject_disk(Disk *dsk)
iwm_flush_disk_to_unix(dsk);
gloghead(); printf("Ejecting disk: %s\n", dsk->name_ptr);
glogf("Ejecting disk: %s\n", dsk->name_ptr);
/* Free all memory, close file */

View File

@ -757,7 +757,7 @@ void debug_init()
{
if (g_dbg_enable_port > 0) {
// g_dbg_enable_port should be enabled by
gloghead(); printf("Debug port enabled on: %d\n", g_dbg_enable_port);
glogf("Debug port enabled on: %d\n", g_dbg_enable_port);
debug_setup_socket();
debug_server_poll();
debug_wait_hello();

View File

@ -1,7 +1,10 @@
#include <stdio.h>
#include <time.h>
#include <stdarg.h>
int glog(char *s) {
#include "glog.h"
int glog(const char *s) {
time_t timer;
char buffer[26];
struct tm* tm_info;
@ -15,8 +18,9 @@ int glog(char *s) {
return 0;
}
// only print partial, interim solution for not supporting printf style calling
void gloghead() {
int glogf(const char *fmt, ...) {
time_t timer;
char buffer[26];
struct tm* tm_info;
@ -25,5 +29,13 @@ void gloghead() {
tm_info = localtime(&timer);
strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", tm_info);
printf("%s - ", buffer);
va_list ap;
va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);
fputc('\n', stdout);
return 0;
}

View File

@ -1,2 +1,8 @@
int glog(char *s);
void gloghead();
#ifdef __cplusplus
extern "C" {
#endif
int glog(const char *s);
int glogf(const char *s, ...);
#ifdef __cplusplus
}
#endif

View File

@ -266,7 +266,7 @@ joystick_init()
{
int i;
if( SDL_Init( SDL_INIT_JOYSTICK ) < 0 ) {
gloghead(); printf( "SDL could not initialize joystick! SDL Error: %s\n", SDL_GetError() );
glogf( "SDL could not initialize joystick! SDL Error: %s\n", SDL_GetError() );
} else {
glog("SDL2 joystick initialized");
}
@ -278,7 +278,7 @@ joystick_init()
// @todo: add multiple controller support
gGameController = SDL_JoystickOpen( 0 );
if( gGameController == NULL ) {
gloghead(); printf( "Warning: Unable to open game controller! SDL Error: %s\n", SDL_GetError() );
glogf( "Warning: Unable to open game controller! SDL Error: %s\n", SDL_GetError() );
}
}
g_joystick_native_type = 2;

View File

@ -42,6 +42,7 @@
#include "printer.h"
#include <math.h>
#include "glog.h"
#include "support.h"
//#include "png.h"
//#pragma comment( lib, "libpng.lib" )
@ -69,7 +70,7 @@ extern "C" char* g_printer_font_courier;
extern "C" char* g_printer_font_prestige;
extern "C" char* g_printer_font_script;
extern "C" char* g_printer_font_ocra;
extern "C" void gloghead();
Bit8u paramc = '0';
#include "printer_charmaps.h"
@ -367,9 +368,7 @@ void CPrinter::updateFont()
if (FT_New_Face(FTlib, fontName, 0, &curFont))
{
gloghead();
printf("Unable to load font\n");
//LOG_MSG("Unable to load font %s", fontName);
glogf("Unable to load font %s", fontName);
curFont = NULL;
}

View File

@ -300,7 +300,7 @@ dev_video_init_sdl()
// Check that the window was successfully created
if (window == NULL) {
// In the case that the window could not be made...
gloghead(); printf("Could not create window: %s\n", SDL_GetError());
glogf("Could not create window: %s\n", SDL_GetError());
//@todo die, i guess
} else {
glog("SDL2 graphics initialized");
@ -633,8 +633,7 @@ void make_next_screenshot_filename()
// workaround is this horrible hack of saving the bmp -> load bmp -> save png
void x_take_screenshot() {
make_next_screenshot_filename();
gloghead();
printf("Taking screenshot - %s\n", screenshot_filename);
glogf("Taking screenshot - %s\n", screenshot_filename);
SDL_Surface *sshot = SDL_CreateRGBSurface(0, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
SDL_LockSurface(sshot);
int read = SDL_RenderReadPixels(renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch);
@ -707,7 +706,7 @@ int clipboard_get_char(void) {
c = g_clipboard[g_clipboard_pos++];
} while (c & 0x80);
/* windows -- skip the \n in \r\n. */
/* windows -- skip the \n in \r\n. */
if (c == '\r' && g_clipboard[g_clipboard_pos] == '\n')
g_clipboard_pos++;
@ -718,7 +717,7 @@ int clipboard_get_char(void) {
free(g_clipboard);
g_clipboard = NULL;
g_clipboard_pos = 0;
return 0;
return 0;
}
return c | 0x80;

View File

@ -85,7 +85,7 @@ sound_write_sdl(int real_samps, int size)
SDL_UnlockAudio();
}
if(g_sound_paused && (g_playbuf_buffered > 0)) {
gloghead(); printf("Unpausing sound, %d buffered\n",g_playbuf_buffered);
glogf("Unpausing sound, %d buffered\n",g_playbuf_buffered);
g_sound_paused = 0;
SDL_PauseAudio(0);
}
@ -178,7 +178,7 @@ sound_init_device_sdl()
goto snd_error;
g_playbuf_buffered = 0;
gloghead(); printf("Sound shared memory size=%d\n",
glogf("Sound shared memory size=%d\n",
SOUND_SHM_SAMP_SIZE * SAMPLE_CHAN_SIZE);
g_sound_shm_addr = malloc(SOUND_SHM_SAMP_SIZE * SAMPLE_CHAN_SIZE);

View File

@ -746,7 +746,7 @@ void my_exit(int ret)
end_screen();
imagewriter_close();
printer_close();
gloghead(); printf("exiting (ret=%d)\n",ret);
glogf("exiting (ret=%d)\n",ret);
fatalExit(ret);
}
@ -894,7 +894,7 @@ memory_ptr_init()
*/
g_memory_ptr = memalloc_align(mem_size, 256, &g_memory_alloc_ptr);
gloghead(); printf("RAM size is 0 - %06x (%.2fMB)\n", mem_size,
glogf("RAM size is 0 - %06x (%.2fMB)\n", mem_size,
(double)mem_size/(1024.0*1024.0));
}
@ -1332,7 +1332,7 @@ void setup_gsplus_file(char *outname, int maxlen, int ok_if_missing, int can_cre
strcpy(outname, &(local_path[0]));
strncat(outname, *cur_name_ptr, 255-strlen(outname));
if(!ok_if_missing) { // ??
gloghead(); printf("Trying '%s'\n", outname);
glogf("Trying '%s'\n", outname);
}
ret = stat(outname, &stat_buf);
if(ret == 0) {
@ -1358,7 +1358,7 @@ void setup_gsplus_file(char *outname, int maxlen, int ok_if_missing, int can_cre
fatal_printf(" %s\n", *path_ptr++);
}
*/
gloghead(); printf("Could not find required file \"%s\" !!!\n", *name_ptr);
glogf("Could not find required file \"%s\" !!!\n", *name_ptr);
if (strcmp(*name_ptr, "ROM")) {
glog(" IIgs will likely hang now!");
glog(" Get an Apple IIgs firmware ROM image from somewhere like:");

View File

@ -229,7 +229,7 @@ child_sound_playit(word32 tmp)
reliable_buf_write(g_childsnd_shm_addr, g_childsnd_pos, size);
if(g_sound_paused) {
gloghead(); printf("Unpausing sound, zb: %d\n", g_zeroes_buffered);
glogf("Unpausing sound, zb: %d\n", g_zeroes_buffered);
g_sound_paused = 0;
}