Amiberry GUI on Android comes up (#563)
* Uses C++14 standard lib instead of GNU GNU lead to compilation errors. * Removes variables Those are in the main Android.mk now and relative. * Creates header file for amiberry_filesys for reuse in other files * Adds prefix_with_application_directory_path for Android support * Uses path prefixer to fix some crashes on Android * Adds pattern for Android Studio (jetbrains) working file * Removes unused compiler directive LIBMPEG2_PATH from Makefile * Fixes startup behavior for Android We are using the applications directory as our working directory now, because SDCARD access will be limited in the future of Android. Coming with that, we're also relying on `start_path_data` being set correctly at startup instead of working around it during loading of settings. * Workaround for crash during startup * Workaround for another crash during startup on Android * Adds new code file scp.cpp to Android build * Adds orig files to gitignore * Fixes behaviour of prefix_with_application_directory_path * Enables redirection of logs to Android's logcat * Fixes misspelled compiler directive
This commit is contained in:
parent
8b15040881
commit
a57736e2cd
11 changed files with 104 additions and 42 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -212,3 +212,5 @@ Thumbs.db
|
|||
|
||||
.com.apple.timemachine.supported
|
||||
*.user
|
||||
*___jb_old___
|
||||
*.orig
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#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)
|
||||
|
|
60
src/osdep/amiberry_filesys.hpp
Normal file
60
src/osdep/amiberry_filesys.hpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
#ifndef AMIBERRY_ANDROID_AMIBERRY_FILESYS_HPP
|
||||
#define AMIBERRY_ANDROID_AMIBERRY_FILESYS_HPP
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#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
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue