From 97506679583cafafb5b09b19e2cfb808b57d585f Mon Sep 17 00:00:00 2001 From: James Sanford Date: Mon, 6 Aug 2012 16:56:51 -0700 Subject: [PATCH] Initial changes for __ANDROID__ --- jni/dis.c | 5 ++++- jni/joystick_driver.c | 4 ++++ jni/sim65816.c | 12 +++++++----- jni/sound.c | 14 ++++++++------ jni/sound.h | 2 +- jni/sound_driver.c | 10 +++++++--- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/jni/dis.c b/jni/dis.c index 75b9a27..e146b31 100644 --- a/jni/dis.c +++ b/jni/dis.c @@ -14,6 +14,8 @@ const char rcsid_dis_c[] = "@(#)$KmKId: dis.c,v 1.103 2004-11-24 16:41:41-05 ken #include "defc.h" #include +#include + #include "disas.h" #define LINE_SIZE 160 @@ -1170,8 +1172,9 @@ halt_printf(const char *fmt, ...) va_list args; va_start(args, fmt); - vprintf(fmt, args); + __android_log_vprint(ANDROID_LOG_ERROR,"libkegs",fmt,args); va_end(args); + while(1) { sleep(600); } // sleep forever set_halt(1); } diff --git a/jni/joystick_driver.c b/jni/joystick_driver.c index 53f64e2..fec60db 100644 --- a/jni/joystick_driver.c +++ b/jni/joystick_driver.c @@ -13,9 +13,11 @@ const char rcsid_joystick_driver_c[] = "@(#)$KmKId: joystick_driver.c,v 1.12 200 #include "defc.h" #include +#ifndef __ANDROID__ #ifdef __linux__ # include #endif +#endif #ifdef _WIN32 # include @@ -37,6 +39,7 @@ int g_joystick_num_axes = 0; int g_joystick_num_buttons = 0; +#ifndef __ANDROID__ #ifdef __linux__ # define JOYSTICK_DEFINED void @@ -128,6 +131,7 @@ joystick_update_buttons() { } #endif /* LINUX */ +#endif #ifdef _WIN32 # define JOYSTICK_DEFINED diff --git a/jni/sim65816.c b/jni/sim65816.c index 484e691..54d9d42 100644 --- a/jni/sim65816.c +++ b/jni/sim65816.c @@ -21,11 +21,13 @@ const char rcsid_sim65816_c[] = "@(#)$KmKId: sim65816.c,v 1.367 2004-11-22 02:39 char g_argv0_path[256] = "./"; -const char *g_kegs_default_paths[] = { "", "./", "${HOME}/", - "${HOME}/Library/KEGS/", - "${0}/Contents/Resources/", "/usr/local/lib/", - "/usr/local/kegs/", "/usr/local/lib/kegs/", "/usr/share/kegs/", - "/var/lib/", "/usr/lib/kegs/", "${0}/", 0 }; +const char *g_kegs_default_paths[] = { "", "./", "/mnt/sdcard/KEGS/", + "/sdcard/KEGS/", + "/storage/sdcard0/KEGS/", + "/mnt/sdcard/kegs/", + "/sdcard/kegs/", + "/storage/sdcard0/kegs/", + "${0}/", 0 }; #define MAX_EVENTS 64 diff --git a/jni/sound.c b/jni/sound.c index 4d5ea51..153f879 100644 --- a/jni/sound.c +++ b/jni/sound.c @@ -45,7 +45,7 @@ int g_queued_samps = 0; int g_queued_nonsamps = 0; int g_num_osc_interrupting = 0; -#if defined(HPUX) || defined(__linux__) || defined(_WIN32) || defined(MAC) +#if defined(HPUX) || (defined(__linux__) && !defined(__ANDROID__)) || defined(_WIN32) || defined(MAC) int g_audio_enable = -1; #else # if defined(OSS) @@ -237,7 +237,7 @@ sound_init() void sound_init_general() { -#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC) +#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC) && !defined(__ANDROID__) int pid; int shmid; int tmp; @@ -247,7 +247,7 @@ sound_init_general() int size; int ret; -#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC) +#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC) && !defined(__ANDROID__) if(!g_use_shmem) { if(g_audio_enable < 0) { printf("Defaulting audio off for slow X display\n"); @@ -264,7 +264,7 @@ sound_init_general() size = SOUND_SHM_SAMP_SIZE * SAMPLE_CHAN_SIZE; -#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC) +#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC) && !defined(__ANDROID__) shmid = shmget(IPC_PRIVATE, size, IPC_CREAT | 0777); if(shmid < 0) { printf("sound_init: shmget ret: %d, errno: %d\n", shmid, @@ -295,7 +295,7 @@ sound_init_general() fflush(stdout); -#if !defined(MAC) && !defined(_WIN32) && !defined(__CYGWIN__) +#if !defined(MAC) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__ANDROID__) /* prepare pipe so parent can signal child each other */ /* pipe[0] = read side, pipe[1] = write end */ ret = pipe(&g_pipe_fd[0]); @@ -348,8 +348,10 @@ sound_init_general() # ifdef MAC macsnd_init(shmaddr); # else +# if !defined(__ANDROID__) /* windows */ win32snd_init(shmaddr); +# endif # endif #endif /* _WIN32 */ @@ -1009,7 +1011,7 @@ sound_play(double dsamps) outptr += 2; -#if defined(__linux__) || defined(OSS) +#if (defined(__linux__) && !defined(__ANDROID__)) || defined(OSS) /* Linux seems to expect little-endian */ /* samples always, even on PowerPC */ # ifdef KEGS_LITTLE_ENDIAN diff --git a/jni/sound.h b/jni/sound.h index 552d5cf..09c2f2c 100644 --- a/jni/sound.h +++ b/jni/sound.h @@ -12,7 +12,7 @@ const char rcsid_sound_h[] = "@(#)$KmKId: sound.h,v 1.17 2003-11-21 15:15:57-05 kentd Exp $"; #endif -#if !defined(_WIN32) && !defined(__CYGWIN__) +#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__ANDROID__) # include # include #endif diff --git a/jni/sound_driver.c b/jni/sound_driver.c index c36d8ad..fa5265f 100644 --- a/jni/sound_driver.c +++ b/jni/sound_driver.c @@ -17,7 +17,7 @@ const char rcsid_sound_driver_c[] = "@(#)$KmKId: sound_driver.c,v 1.17 2004-09-2 # include #endif -#if defined(__linux__) || defined(OSS) +#if (defined(__linux__) && !defined(__ANDROID__)) || defined(OSS) # include #endif @@ -128,10 +128,14 @@ child_sound_loop(int read_fd, int write_fd, word32 *shm_addr) g_childsnd_vbl = 0; g_childsnd_shm_addr = shm_addr; +#if defined(__ANDROID__) + return; +#endif + #ifdef HPUX child_sound_init_hpdev(); #endif -#if defined(__linux__) || defined(OSS) +#if (defined(__linux__) && !defined(__ANDROID__)) || defined(OSS) child_sound_init_linux(); #endif #ifdef _WIN32 @@ -351,7 +355,7 @@ child_sound_init_hpdev() } #endif /* HPUX */ -#if defined(__linux__) || defined(OSS) +#if (defined(__linux__) && !defined(__ANDROID__)) || defined(OSS) void child_sound_init_linux() {