diff --git a/.gitignore b/.gitignore index 1d1690462..e4350c09b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store *.class +*.orig bin/ gen/ diff --git a/README.md b/README.md index e3c867270..2a492efa8 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,13 @@ Let's try to keep everything under a single project :) To build for android -------------------- -``` -cd newdc\android\libnewdc -android update project -p . +Tools required: +* Latest Android SDK and NDK (duh) +* Ant -cd ..\..\..\reicast\android +From project root directory: +``` +cd shell\android android update project -p . ndk-build -j 4 @@ -64,6 +66,7 @@ Team You can check the currently active committers on [the pretty graphs page](https://github.com/reicast/reicast-emulator/graphs/contributors) +Chat on freenode #reicast. The original reicast team consisted of drk||Raziel (mostly just writing code), PsyMan (debugging/testing and everything else) and a little bit of gb_away diff --git a/core/core.mk b/core/core.mk index 446fcbc93..0b337ab30 100755 --- a/core/core.mk +++ b/core/core.mk @@ -52,7 +52,7 @@ else RZDCY_CXXFLAGS := \ $(CFLAGS) -c -g -O3 -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps \ -D_ANDROID -DRELEASE -DTARGET_BEAGLE\ - -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -mfloat-abi=softfp \ + -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 \ -frename-registers -fsingle-precision-constant -ffast-math \ -ftree-vectorize -fomit-frame-pointer -fno-exceptions -fno-rtti -std=gnu++11 endif \ No newline at end of file diff --git a/core/hw/maple/maple_cfg.cpp b/core/hw/maple/maple_cfg.cpp index bb294eba3..16e5a63fe 100644 --- a/core/hw/maple/maple_cfg.cpp +++ b/core/hw/maple/maple_cfg.cpp @@ -78,7 +78,7 @@ void mcfg_CreateDevices() void mcfg_DestroyDevices() { - for (int i=0;i<3;i++) - for (int j=0;j<5;j++) + for (int i=0;i<=3;i++) + for (int j=0;j<=5;j++) delete MapleDevices[i][j]; -} \ No newline at end of file +} diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index d9f35432e..c352db493 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -5,6 +5,8 @@ #include "maple_cfg.h" #include +#include "deps/zlib/zlib.h" + const char* maple_sega_controller_name = "Dreamcast Controller"; const char* maple_sega_vmu_name = "Visual Memory"; const char* maple_sega_kbd_name = "Emulated Dreamcast Keyboard"; @@ -234,6 +236,28 @@ struct maple_sega_controller: maple_base This is pretty much done (?) */ #ifdef HAS_VMU + +u8 vmu_default[] = { + 0x78,0x9c,0xed,0xd2,0x31,0x4e,0x02,0x61,0x10,0x06,0xd0,0x8f,0x04,0x28,0x4c,0x2c, + 0x28,0x2d,0x0c,0xa5,0x57,0xe0,0x16,0x56,0x16,0x76,0x14,0x1e,0xc4,0x03,0x50,0x98, + 0x50,0x40,0x69,0xc1,0x51,0x28,0xbc,0x8e,0x8a,0x0a,0xeb,0xc2,0xcf,0x66,0x13,0x1a, + 0x13,0xa9,0x30,0x24,0xe6,0xbd,0xc9,0x57,0xcc,0x4c,0x33,0xc5,0x2c,0xb3,0x48,0x6e, + 0x67,0x01,0x00,0x00,0x00,0x00,0x00,0x4e,0xaf,0xdb,0xe4,0x7a,0xd2,0xcf,0x53,0x16, + 0x6d,0x46,0x99,0xb6,0xc9,0x78,0x9e,0x3c,0x5f,0x9c,0xfb,0x3c,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x80,0x5f,0xd5,0x45,0xfd,0xef,0xaa,0xca,0x6b,0xde,0xf2,0x9e,0x55, + 0x3e,0xf2,0x99,0xaf,0xac,0xb3,0x49,0x95,0xef,0xd4,0xa9,0x9a,0xdd,0xdd,0x0f,0x9d, + 0x52,0xca,0xc3,0x91,0x7f,0xb9,0x9a,0x0f,0x6e,0x92,0xfb,0xee,0xa1,0x2f,0x6d,0x76, + 0xe9,0x64,0x9b,0xcb,0xf4,0xf2,0x92,0x61,0x33,0x79,0xfc,0xeb,0xb7,0xe5,0x44,0xf6, + 0x77,0x19,0x06,0xef, +}; + struct maple_sega_vmu: maple_base { FILE* file; @@ -266,6 +290,20 @@ struct maple_sega_vmu: maple_base { fread(flash_data,1,sizeof(flash_data),file); } + + u8 sum = 0; + for (int i=0;i TAFifo0; +int ta_parse_cnt = 0; + bool ta_parse_vdrc(TA_context* ctx) { - bool rv=true; + bool rv=false; verify( vd_ctx == 0); vd_ctx = ctx; vd_rc = vd_ctx->rend; - - if (!settings.pvr.ta_skip) + + ta_parse_cnt++; + + if (0 == (ta_parse_cnt % ( settings.pvr.ta_skip + 1))) { TAFifo0.vdec_init(); diff --git a/core/rec-ARM/arm_dyna.cpp b/core/rec-ARM/arm_dyna.cpp index 6058f1081..447516a6c 100755 --- a/core/rec-ARM/arm_dyna.cpp +++ b/core/rec-ARM/arm_dyna.cpp @@ -565,6 +565,22 @@ void ngen_CC_Param(shil_opcode* op,shil_param* par,CanonicalParamType tp) switch(tp) { case CPT_f32rv: + #ifdef ARM_HARDFP + { + if (reg.IsAllocg(*par)) + { + //printf("MOV(reg.map(*par),r0); %d\n",reg.map(*par)); + VMOV(reg.mapg(*par),f0); + } + else if (reg.IsAllocf(*par)) + { + //VMOV(reg.mapf(*par),0,r0); %d\n",reg.map(*par)); + VMOV(reg.mapfs(*par),f0); + } + } + break; + #endif + case CPT_u32rv: case CPT_u64rvL: { @@ -606,6 +622,8 @@ void ngen_CC_Param(shil_opcode* op,shil_param* par,CanonicalParamType tp) void ngen_CC_Call(shil_opcode* op,void* function) { u32 rd=r0; + u32 fd=f0; + for (int i=CC_pars.size();i-->0;) { if (CC_pars[i].type==CPT_ptr) @@ -616,6 +634,25 @@ void ngen_CC_Call(shil_opcode* op,void* function) { if (CC_pars[i].par->is_reg()) { + #ifdef ARM_HARDFP + if (CC_pars[i].type == CPT_f32) + { + if (reg.IsAllocg(*CC_pars[i].par)) + { + //printf("MOV((eReg)rd,reg.map(*CC_pars[i].par)); %d %d\n",rd,reg.map(*CC_pars[i].par)); + VMOV((eFSReg)fd,reg.mapg(*CC_pars[i].par)); + } + else if (reg.IsAllocf(*CC_pars[i].par)) + { + //printf("LoadSh4Reg_mem((eReg)rd, *CC_pars[i].par); %d\n",rd); + VMOV((eFSReg)fd,reg.mapfs(*CC_pars[i].par)); + } + else + die("Must not happen!\n"); + continue; + } + #endif + if (reg.IsAllocg(*CC_pars[i].par)) { //printf("MOV((eReg)rd,reg.map(*CC_pars[i].par)); %d %d\n",rd,reg.map(*CC_pars[i].par)); @@ -631,6 +668,7 @@ void ngen_CC_Call(shil_opcode* op,void* function) } else { + verify(CC_pars[i].type != CPT_f32); //printf("MOV32((eReg)rd, CC_pars[i].par->_imm); %d\n",rd); MOV32((eReg)rd, CC_pars[i].par->_imm); } diff --git a/shell/android/.classpath b/shell/android/.classpath index 0b0840834..d57ec0251 100644 --- a/shell/android/.classpath +++ b/shell/android/.classpath @@ -1,7 +1,7 @@ - + diff --git a/shell/android/AndroidManifest.xml b/shell/android/AndroidManifest.xml index a92719df9..2b1351d7a 100644 --- a/shell/android/AndroidManifest.xml +++ b/shell/android/AndroidManifest.xml @@ -1,7 +1,7 @@ + android:versionName="0.r6" > - + + + diff --git a/shell/android/jni/Android.mk b/shell/android/jni/Android.mk index 97e9cce63..6dcc047b1 100644 --- a/shell/android/jni/Android.mk +++ b/shell/android/jni/Android.mk @@ -32,10 +32,28 @@ LOCAL_MODULE := dc LOCAL_CFLAGS := $(LOCAL_CXXFLAGS) -DHAS_VMU LOCAL_DISABLE_FORMAT_STRING_CHECKS=true LOCAL_ASFLAGS := -fvisibility=hidden -LOCAL_LDLIBS := -llog -lGLESv2 -lEGL -lz +LOCAL_LDLIBS := -llog -lGLESv2 -lEGL -lz #-Wl,-Map,./res/raw/syms.mp3 LOCAL_ARM_MODE := arm +# +# android has poor support for hardfp calling. +# r9b+ is required, and it only works for internal calls +# the opengl drivers would really benefit from this, but they are still using softfp +# the header files tell gcc to automatically use aapcs for calling system/etc +# so there is no real perfomance difference +# +# The way this is implemented is a huge hack on the android/linux side +# (but then again, which part of android isn't a huge hack?) + +#ifneq ($(filter %armeabi-v7a,$(TARGET_ARCH_ABI)),) +#LOCAL_CFLAGS += -mhard-float -D_NDK_MATH_NO_SOFTFP=1 -DARM_HARDFP +#LOCAL_LDLIBS += -lm_hard +#ifeq (,$(filter -fuse-ld=mcld,$(APP_LDFLAGS) $(LOCAL_LDFLAGS))) +#LOCAL_LDFLAGS += -Wl,--no-warn-mismatch +#endif +#endif + include $(BUILD_SHARED_LIBRARY) $(call import-module,android/native_app_glue) diff --git a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp index 3337ac853..8934acaa1 100644 --- a/shell/android/jni/src/Android.cpp +++ b/shell/android/jni/src/Android.cpp @@ -13,6 +13,7 @@ #include "profiler/profiler.h" #include "cfg/cfg.h" #include "rend/TexCache.h" +#include "hw/maple/maple_devs.h" #include "util.h" @@ -29,9 +30,11 @@ extern "C" JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendinit(JNIEnv *env,jobject obj,jint w,jint h) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendframe(JNIEnv *env,jobject obj) __attribute__((visibility("default"))); - JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_kcode(JNIEnv * env, jobject obj,u32 k_code, u32 l_t, u32 r_t, u32 jx, u32 jy) __attribute__((visibility("default"))); + JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_kcode(JNIEnv * env, jobject obj, jintArray k_code, jintArray l_t, jintArray r_t, jintArray jx, jintArray jy) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_vjoy(JNIEnv * env, jobject obj,u32 id,float x, float y, float w, float h) __attribute__((visibility("default"))); //JNIEXPORT jint JNICALL Java_com_reicast_emulator_JNIdc_play(JNIEnv *env,jobject obj,jshortArray result,jint size); + + JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_initControllers(JNIEnv *env, jobject obj, jbooleanArray controllers) __attribute__((visibility("default"))); }; void egl_stealcntx(); @@ -39,6 +42,7 @@ void SetApplicationPath(wchar *path); int dc_init(int argc,wchar* argv[]); void dc_run(); void dc_term(); +void mcfg_Create(MapleDeviceType type,u32 bus,u32 port); bool VramLockedWrite(u8* address); @@ -51,6 +55,9 @@ extern int screen_width,screen_height; static u64 tvs_base; static char CurFileName[256]; +// Additonal controllers 2, 3 and 4 connected ? +static bool add_controllers[3] = { false, false, false }; + u16 kcode[4]; u32 vks[4]; s8 joyx[4],joyy[4]; @@ -84,6 +91,13 @@ static void *ThreadHandler(void *UserData) strcat(Args[2],P); } + // Add additonal controllers + for (int i = 0; i < 3; i++) + { + if (add_controllers[i]) + mcfg_Create(MDT_SegaController,i+1,5); + } + // Run nullDC emulator dc_init(Args[2]? 3:1,Args); } @@ -247,14 +261,28 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendframe(JNIEnv *env,job while(!rend_single_frame()) ; } -JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_kcode(JNIEnv * env, jobject obj,u32 k_code, u32 l_t, u32 r_t, u32 jx, u32 jy) +JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_kcode(JNIEnv * env, jobject obj, jintArray k_code, jintArray l_t, jintArray r_t, jintArray jx, jintArray jy) { - lt[0] = l_t; - rt[0] = r_t; - kcode[0] = k_code; - kcode[3] = kcode[2] = kcode[1] = 0xFFFF; - joyx[0]=jx; - joyy[0]=jy; + jint *k_code_body = env->GetIntArrayElements(k_code, 0); + jint *l_t_body = env->GetIntArrayElements(l_t, 0); + jint *r_t_body = env->GetIntArrayElements(r_t, 0); + jint *jx_body = env->GetIntArrayElements(jx, 0); + jint *jy_body = env->GetIntArrayElements(jy, 0); + + for(int i = 0; i < 4; i++) + { + kcode[i] = k_code_body[i]; + lt[i] = l_t_body[i]; + rt[i] = r_t_body[i]; + joyx[i] = jx_body[i]; + joyy[i] = jy_body[i]; + } + + env->ReleaseIntArrayElements(k_code, k_code_body, 0); + env->ReleaseIntArrayElements(l_t, l_t_body, 0); + env->ReleaseIntArrayElements(r_t, r_t_body, 0); + env->ReleaseIntArrayElements(jx, jx_body, 0); + env->ReleaseIntArrayElements(jy, jy_body, 0); } JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_rendinit(JNIEnv * env, jobject obj, jint w,jint h) @@ -283,6 +311,13 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_vjoy(JNIEnv * env, jobjec } } +JNIEXPORT void JNICALL Java_com_reicast_emulator_JNIdc_initControllers(JNIEnv *env, jobject obj, jbooleanArray controllers) +{ + jboolean *controllers_body = env->GetBooleanArrayElements(controllers, 0); + memcpy(add_controllers, controllers_body, 3); + env->ReleaseBooleanArrayElements(controllers, controllers_body, 0); +} + u32 os_Push(void* frame, u32 amt, bool wait) { verify(amt==SAMPLE_COUNT); @@ -294,4 +329,4 @@ u32 os_Push(void* frame, u32 amt, bool wait) bool os_IsAudioBuffered() { return jenv->CallIntMethod(track,writemid,jsamples,-1)==0; -} \ No newline at end of file +} diff --git a/shell/android/res/layout-v14/configure_fragment.xml b/shell/android/res/layout-v14/configure_fragment.xml index 162881b72..0ddf9c2b9 100644 --- a/shell/android/res/layout-v14/configure_fragment.xml +++ b/shell/android/res/layout-v14/configure_fragment.xml @@ -3,80 +3,182 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > - - + + + android:layout_weight="1" + android:ems="10" + android:text="@string/select_dynarec" /> - + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - - + android:max="5" + android:progress="0" /> + - + + + \ No newline at end of file diff --git a/shell/android/res/layout-v14/controllers_fragment.xml b/shell/android/res/layout-v14/controllers_fragment.xml new file mode 100644 index 000000000..e5857cd4b --- /dev/null +++ b/shell/android/res/layout-v14/controllers_fragment.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + +