diff --git a/.gitignore b/.gitignore index a53d567b..43ce9065 100644 --- a/.gitignore +++ b/.gitignore @@ -212,3 +212,5 @@ Thumbs.db .com.apple.timemachine.supported *.user +*___jb_old___ +*.orig diff --git a/Android.mk b/Android.mk index 3fe1a3a3..1ed73e4b 100644 --- a/Android.mk +++ b/Android.mk @@ -12,10 +12,6 @@ include $(CLEAR_VARS) LOCAL_MODULE := amiberry -SDL_PATH := D:/Github/amiberry-android/app/jni/SDL -#LIBMPEG2_PATH := ../mpeg2 -LIBPNG_PATH := D:/Github/amiberry-android/app/jni/SDL_image/external/libpng-1.6.37 - LOCAL_C_INCLUDES := $(LOCAL_PATH)/src \ $(LOCAL_PATH)/src/osdep \ $(LOCAL_PATH)/src/threaddep \ @@ -33,7 +29,8 @@ else ifeq ($(TARGET_ARCH_ABI),arm64-v8a) LOCAL_CFLAGS := -DCPU_AARCH64 -DAMIBERRY -D_FILE_OFFSET_BITS=64 -DSTATIC_LIBXML endif -LOCAL_CPPFLAGS := -std=gnu++14 -pipe -frename-registers \ +#LOCAL_CPPFLAGS := -std=gnu++14 -pipe -frename-registers +LOCAL_CPPFLAGS := -std=c++14 -pipe -frename-registers \ -Wno-shift-overflow -Wno-narrowing LOCAL_LDFLAGS += -fuse-ld=gold @@ -89,6 +86,7 @@ LOCAL_SRC_FILES := src/archivers/7z/BraIA64.c \ src/rommgr.cpp \ src/rtc.cpp \ src/savestate.cpp \ + src/scp.cpp \ src/scsi.cpp \ src/statusline.cpp \ src/traps.cpp \ diff --git a/src/custom.cpp b/src/custom.cpp index 3e2823c2..2dfed38e 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -4437,6 +4437,8 @@ void compute_framesync(void) hblank_hz = (currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL) / (maxhpos + (islinetoggle() ? 0.5 : 0)); + // Crashes on Android +#ifndef ANDROID write_log (_T("%s mode%s%s V=%.4fHz H=%0.4fHz (%dx%d+%d) IDX=%d (%s) D=%d RTG=%d/%d\n"), isntsc ? _T("NTSC") : _T("PAL"), islace ? _T(" lace") : (lof_lace ? _T(" loflace") : _T("")), @@ -4448,7 +4450,8 @@ void compute_framesync(void) cr != NULL && cr->label != NULL ? cr->label : _T(""), currprefs.gfx_apmode[ad->picasso_on ? 1 : 0].gfx_display, ad->picasso_on, ad->picasso_requested_on ); - +#endif + set_config_changed (); if (target_graphics_buffer_update()) { diff --git a/src/osdep/amiberry.cpp b/src/osdep/amiberry.cpp index 1c6a8a4a..bf50c6b3 100644 --- a/src/osdep/amiberry.cpp +++ b/src/osdep/amiberry.cpp @@ -949,11 +949,7 @@ void load_amiberry_settings(void) { char path[MAX_DPATH]; int i; -#ifdef ANDROID - strncpy(currentDir, getenv("SDCARD"), MAX_DPATH - 1); -#else strncpy(currentDir, start_path_data, MAX_DPATH - 1); -#endif snprintf(config_path, MAX_DPATH, "%s/conf/", start_path_data); snprintf(controllers_path, MAX_DPATH, "%s/controllers/", start_path_data); snprintf(retroarch_file, MAX_DPATH, "%s/conf/retroarch.cfg", start_path_data); @@ -1133,7 +1129,11 @@ int main(int argc, char* argv[]) max_uae_height = 1080; // Get startup path +#ifdef ANDROID + strncpy(start_path_data, getenv("EXTERNAL_FILES_DIR"), MAX_DPATH - 1); +#else getcwd(start_path_data, MAX_DPATH); +#endif rename_old_adfdir(); load_amiberry_settings(); rp9_init(); diff --git a/src/osdep/amiberry_filesys.cpp b/src/osdep/amiberry_filesys.cpp index 656d3651..4631224a 100644 --- a/src/osdep/amiberry_filesys.cpp +++ b/src/osdep/amiberry_filesys.cpp @@ -1,14 +1,13 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "sysdeps.h" -#include "options.h" +#include "amiberry_filesys.hpp" +string prefix_with_application_directory_path(string currentpath) +{ +#ifdef ANDROID + return getenv("EXTERNAL_FILES_DIR") + ("/" + currentpath); +#else + return currentpath; +#endif +} int my_setcurrentdir(const TCHAR* curdir, TCHAR* oldcur) { @@ -44,13 +43,6 @@ int my_rename(const char* oldname, const char* newname) return rename(oldname, newname); } - -struct my_opendir_s -{ - void* h; -}; - - struct my_opendir_s* my_opendir(const char* name) { auto * mod = xmalloc (struct my_opendir_s, 1); @@ -87,12 +79,6 @@ int my_readdir(struct my_opendir_s* mod, char* name) } -struct my_openfile_s -{ - int h; -}; - - void my_close(struct my_openfile_s* mos) { if (mos) diff --git a/src/osdep/amiberry_filesys.hpp b/src/osdep/amiberry_filesys.hpp new file mode 100644 index 00000000..17851a43 --- /dev/null +++ b/src/osdep/amiberry_filesys.hpp @@ -0,0 +1,60 @@ +#ifndef AMIBERRY_ANDROID_AMIBERRY_FILESYS_HPP +#define AMIBERRY_ANDROID_AMIBERRY_FILESYS_HPP + +#include +#include +#include +#include +#include +#include +#include + +#include "sysdeps.h" +#include "options.h" + +struct my_opendir_s +{ + void* h; +}; + + +struct my_openfile_s +{ + int h; +}; + +/** + * Gets the current application directory and appends the given path, + * if necessary on current platform. + * @param currentpath Path without leading '/' + * @return appdir + currentpath OR currentpath + */ +string prefix_with_application_directory_path(string currentpath); + +struct my_opendir_s* my_opendir(const char* name); +int my_setcurrentdir(const TCHAR* curdir, TCHAR* oldcur); +int my_mkdir(const char* name); +int my_rmdir(const char* name); +int my_unlink(const char* name); +int my_rename(const char* oldname, const char* newname); +void my_closedir(struct my_opendir_s* mod); +int my_readdir(struct my_opendir_s* mod, char* name); +void my_close(struct my_openfile_s* mos); +uae_s64 my_lseek(struct my_openfile_s* mos,const uae_s64 offset, const int pos); +uae_s64 my_fsize(struct my_openfile_s* mos); +unsigned int my_read(struct my_openfile_s* mos, void* b, unsigned int size); +unsigned int my_write(struct my_openfile_s* mos, void* b, unsigned int size); +int my_existsfile(const char* name); +int my_existsdir(const char* name); +struct my_openfile_s* my_open(const TCHAR* name, const int flags); +int my_truncate(const TCHAR* name, uae_u64 len); +int my_getvolumeinfo(const char* root); +FILE* my_opentext(const TCHAR* name); +bool my_issamepath(const TCHAR* path1, const TCHAR* path2); +const TCHAR* my_getfilepart(const TCHAR* filename); + +/* Returns 1 if an actual volume-name was found, 2 if no volume-name (so uses some defaults) */ +int target_get_volume_name(struct uaedev_mount_info* mtinf, struct uaedev_config_info* ci, bool inserted, + bool fullcheck, int cnt); + +#endif //AMIBERRY_ANDROID_AMIBERRY_FILESYS_HPP diff --git a/src/osdep/amiberry_mem.cpp b/src/osdep/amiberry_mem.cpp index 62213796..120c336d 100644 --- a/src/osdep/amiberry_mem.cpp +++ b/src/osdep/amiberry_mem.cpp @@ -78,7 +78,9 @@ void alloc_AmigaMem(void) free_AmigaMem(); set_expamem_z3_hack_mode(Z3MAPPING_AUTO); - // First attempt: allocate 16 MB for all memory in 24-bit area +// This crashes on Android +#ifndef ANDROID + // First attempt: allocate 16 MB for all memory in 24-bit area // and additional mem for Z3 and RTG at correct offset natmem_size = 16 * 1024 * 1024; #ifdef AMIBERRY @@ -88,12 +90,12 @@ void alloc_AmigaMem(void) #else regs.natmem_offset = (uae_u8*)valloc(natmem_size + BARRIER); #endif - + if (can_have_1gb()) max_z3fastmem = 1024 * 1024 * 1024; else max_z3fastmem = 512 * 1024 * 1024; - + if (!regs.natmem_offset) { write_log("Can't allocate 16M of virtual address space!?\n"); @@ -156,6 +158,7 @@ void alloc_AmigaMem(void) #endif return; } +#endif // No mem for Z3 or RTG at all natmem_size = 16 * 1024 * 1024; diff --git a/src/osdep/gui/PanelAbout.cpp b/src/osdep/gui/PanelAbout.cpp index 35f7afd4..9d661f49 100644 --- a/src/osdep/gui/PanelAbout.cpp +++ b/src/osdep/gui/PanelAbout.cpp @@ -6,6 +6,7 @@ #include "sysdeps.h" #include "gui_handling.h" +#include "amiberry_filesys.hpp" static gcn::Label* lblEmulatorVersion; static gcn::Icon* icon; @@ -15,7 +16,7 @@ static gcn::ScrollArea* textBoxScrollArea; void InitPanelAbout(const struct _ConfigCategory& category) { - amiberryLogoImage = gcn::Image::load("data/amiberry-logo.png"); + amiberryLogoImage = gcn::Image::load(prefix_with_application_directory_path("data/amiberry-logo.png")); icon = new gcn::Icon(amiberryLogoImage); lblEmulatorVersion = new gcn::Label(get_version_string()); diff --git a/src/osdep/gui/PanelHD.cpp b/src/osdep/gui/PanelHD.cpp index c1387bf4..3f923720 100644 --- a/src/osdep/gui/PanelHD.cpp +++ b/src/osdep/gui/PanelHD.cpp @@ -16,6 +16,7 @@ #include "filesys.h" #include "blkdev.h" #include "gui_handling.h" +#include "amiberry_filesys.hpp" enum { @@ -370,7 +371,7 @@ void InitPanelHD(const struct _ConfigCategory& category) listCmdProps[row]->setId(tmp); listCmdProps[row]->addActionListener(hdEditActionListener); - listCmdDelete[row] = new gcn::ImageButton("data/delete.png"); + listCmdDelete[row] = new gcn::ImageButton(prefix_with_application_directory_path("data/delete.png")); listCmdDelete[row]->setBaseColor(gui_baseCol); listCmdDelete[row]->setSize(SMALL_BUTTON_HEIGHT, SMALL_BUTTON_HEIGHT); snprintf(tmp, 20, "cmdDel%d", row); diff --git a/src/osdep/gui/main_window.cpp b/src/osdep/gui/main_window.cpp index 8884b624..ebaacf7d 100644 --- a/src/osdep/gui/main_window.cpp +++ b/src/osdep/gui/main_window.cpp @@ -17,6 +17,7 @@ #include "uae.h" #include "gui_handling.h" #include "amiberry_gfx.h" +#include "amiberry_filesys.hpp" #include "autoconf.h" #include "inputdevice.h" @@ -288,11 +289,11 @@ void setup_cursor() // Detect resolution and load appropriate cursor image if (strcmp(sdl_video_driver, "x11") != 0 && sdlMode.w > 1280) { - cursor_surface = SDL_LoadBMP("data/cursor-x2.bmp"); + cursor_surface = SDL_LoadBMP(prefix_with_application_directory_path("data/cursor-x2.bmp").c_str()); } else { - cursor_surface = SDL_LoadBMP("data/cursor.bmp"); + cursor_surface = SDL_LoadBMP(prefix_with_application_directory_path("data/cursor.bmp").c_str()); } if (!cursor_surface) @@ -959,7 +960,7 @@ void gui_widgets_init() try { - gui_font = new gcn::SDLTrueTypeFont("data/AmigaTopaz.ttf", 15); + gui_font = new gcn::SDLTrueTypeFont(prefix_with_application_directory_path("data/AmigaTopaz.ttf"), 15); } catch (const std::exception& ex) { @@ -1031,7 +1032,7 @@ void gui_widgets_init() panelFocusListener = new PanelFocusListener(); for (i = 0; categories[i].category != nullptr; ++i) { - categories[i].selector = new gcn::SelectorEntry(categories[i].category, categories[i].imagepath); + categories[i].selector = new gcn::SelectorEntry(categories[i].category, prefix_with_application_directory_path(categories[i].imagepath)); categories[i].selector->setActiveColor(colSelectorActive); categories[i].selector->setInactiveColor(colSelectorInactive); categories[i].selector->setSize(150, 24); diff --git a/src/osdep/writelog.cpp b/src/osdep/writelog.cpp index 84edc523..3747b573 100644 --- a/src/osdep/writelog.cpp +++ b/src/osdep/writelog.cpp @@ -29,6 +29,12 @@ void console_out (const TCHAR *format,...) void write_log (const char *format,...) { + // Redirect logging to Android's logcat +#ifdef ANDROID + va_list parms; + va_start(parms, format); + SDL_Log(format, parms); +#else if (write_logfile) { TCHAR buffer[WRITE_LOG_BUF_SIZE]; @@ -43,6 +49,7 @@ void write_log (const char *format,...) } va_end(parms); } +#endif } void jit_abort (const TCHAR *format,...)