Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moved png loader to imagelib and support jpeg loading, too

support multi-touch emulation on pandora (left shoulder = second finger)
fixed makefile
fixed modules (added request_exit functions)
  • Loading branch information...
commit 0b4e573ee7cbad56b26d09060c5d5bc6be51a27c 1 parent ce1bf3b
@crowriot crowriot authored
View
26 apkenv.c
@@ -321,9 +321,7 @@ void system_exit()
int main(int argc, char **argv)
{
-#ifdef APKENV_DEBUG
debug_init();
-#endif
char **tmp;
@@ -453,6 +451,9 @@ int main(int argc, char **argv)
module->init(module, platform_getscreenwidth(), platform_getscreenheight(), data_directory);
+ int emulate_multitouch = 0;
+ const int emulate_finger_id = 2;
+
while (1) {
if (module->requests_exit(module)) {
@@ -467,13 +468,34 @@ int main(int argc, char **argv)
module->deinit(module);
goto finish;
}
+#ifdef PANDORA
+ else if (e.key.keysym.sym==SDLK_RSHIFT) {
+ //emulate_multitouch = 1;
+ module->input(module,ACTION_DOWN, platform_getscreenwidth()>>1, platform_getscreenheight()>>1,emulate_finger_id);
+ }
+ }
+ else if (e.type == SDL_KEYUP) {
+ if (e.key.keysym.sym==SDLK_RSHIFT) {
+ //emulate_multitouch = 0;
+ module->input(module,ACTION_UP, platform_getscreenwidth()>>1, platform_getscreenheight()>>1,emulate_finger_id);
+ }
}
+#endif
else if (e.type == SDL_MOUSEBUTTONDOWN) {
module->input(module, ACTION_DOWN, e.button.x, e.button.y, e.button.which);
+ if (emulate_multitouch) {
+ module->input(module,ACTION_DOWN, platform_getscreenwidth()-e.button.x, platform_getscreenheight()-e.button.y,emulate_finger_id);
+ }
} else if (e.type == SDL_MOUSEBUTTONUP) {
module->input(module, ACTION_UP, e.button.x, e.button.y, e.button.which);
+ if (emulate_multitouch) {
+ module->input(module,ACTION_UP, platform_getscreenwidth()-e.button.x, platform_getscreenheight()-e.button.y,emulate_finger_id);
+ }
} else if (e.type == SDL_MOUSEMOTION) {
module->input(module, ACTION_MOVE, e.motion.x, e.motion.y, e.motion.which);
+ if (emulate_multitouch) {
+ module->input(module,ACTION_MOVE, platform_getscreenwidth()-e.button.x, platform_getscreenheight()-e.button.y,emulate_finger_id);
+ }
} else if (e.type == SDL_QUIT) {
module->deinit(module);
goto finish;
View
2  apkenv.cbp
@@ -15,7 +15,7 @@
<Add option="-g" />
<Add option="-DDEBUG=1" />
<Add option="-DLINKER_DEBUG=2" />
- <Add option="-DAPKENV_DEBUG" />
+ <Add option="-DAPKENV_DEBUGx" />
<Add option="-DAPKENV_GLES" />
</Compiler>
<Linker>
View
3  apkenv.h
@@ -67,7 +67,8 @@ typedef void *(*lookup_symbol_t)(const char *method);
typedef void *(*lookup_lib_symbol_t)(const char *lib, const char *method);
typedef void (*foreach_file_t)(const char *prefix, apk_for_each_file_callback callback);
typedef int (*read_file_t)(const char *filename, char **buffer, size_t *size);
-typedef void (*recursive_mkdir_t)(const char* path);
+typedef void (*recursive_mkdir_t)(const char *path);
+typedef void (*patch_symbol_t)(const char *symbol, void *function);
struct JniLibrary {
struct JniLibrary *next;
View
13 compat/gles_wrappers.c
@@ -3,8 +3,10 @@
#include <assert.h>
#ifdef APKENV_DEBUG
# define WRAPPERS_DEBUG_PRINTF(...) printf(__VA_ARGS__)
+# define GL_TEST_ERROR if (glGetError()!=GL_NO_ERROR) { printf("GL ERROR near %s\n", __FUNCTION__); }
#else
# define WRAPPERS_DEBUG_PRINTF(...)
+# define GL_TEST_ERROR
#endif
void
my_glAlphaFunc(GLenum func, GLclampf ref)
@@ -165,7 +167,10 @@ my_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
void
my_glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
{
- WRAPPERS_DEBUG_PRINTF("glOrthof()\n", left, right, bottom, top, zNear, zFar);
+ WRAPPERS_DEBUG_PRINTF("glOrthof(%f, %f, %f, %f)\n", left, right, bottom, top, zNear, zFar);
+#ifdef LANDSCAPE_TO_PORTRAIT
+ glRotatef(-90,0,0,1);
+#endif
glOrthof(left, right, bottom, top, zNear, zFar);
}
void
@@ -429,7 +434,7 @@ my_glEnable(GLenum cap)
void
my_glEnableClientState(GLenum array)
{
- WRAPPERS_DEBUG_PRINTF("glEnableClientState()\n", array);
+ WRAPPERS_DEBUG_PRINTF("glEnableClientState(0x%x)\n", array);
glEnableClientState(array);
}
void
@@ -868,7 +873,11 @@ void
my_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
{
WRAPPERS_DEBUG_PRINTF("glViewport()\n", x, y, width, height);
+#ifdef LANDSCAPE_TO_PORTRAIT
+ glViewport(x, y, height, width);
+#else
glViewport(x, y, width, height);
+#endif
}
void
my_glPointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *pointer)
View
2  compat/libc_mapping.h
@@ -74,7 +74,7 @@
{"ioctl", ioctl},
{"mmap", mmap},
-{"munmap", my_munmap},
+{"munmap", munmap},
{"poll", poll},
{"mkdir", mkdir},
View
20 compat/libc_wrappers.c
@@ -103,7 +103,7 @@ my_exp(double __x)
int
my_fclose(FILE *__stream)
{
- //WRAPPERS_DEBUG_PRINTF("fclose(%x, %x)\n", __stream, &my___sF);
+ WRAPPERS_DEBUG_PRINTF("fclose(%x, %x)\n", __stream, &my___sF);
int offset = ((void*)__stream - (void*)(&my___sF));
//printf("offset: %d\n", offset);
if (offset < 1000) {
@@ -139,8 +139,10 @@ my_fmod(double __x, double __y)
FILE *
my_fopen(__const char *__restrict __filename, __const char *__restrict __modes)
{
- //WRAPPERS_DEBUG_PRINTF("fopen(%s, %s)\n", __filename, __modes);
- return fopen(__filename, __modes);
+ WRAPPERS_DEBUG_PRINTF("fopen(%s, %s)\n", __filename, __modes);
+ FILE *f = fopen(__filename,__modes);
+ WRAPPERS_DEBUG_PRINTF("fopen(%s, %s) -> %x\n", __filename, __modes, f);
+ return f;
}
int
my_fputc(int __c, FILE *__stream)
@@ -591,7 +593,7 @@ my_strstr(__const char *__haystack, __const char *__needle)
double
my_strtod(__const char *__restrict __nptr, char **__restrict __endptr)
{
- //WRAPPERS_DEBUG_PRINTF("strtod()\n", __nptr, __endptr);
+ WRAPPERS_DEBUG_PRINTF("strtod()\n", __nptr, __endptr);
return strtod(__nptr, __endptr);
}
char *
@@ -671,7 +673,7 @@ my_write(int __fd, __const void *__buf, size_t __n)
int
my_fprintf(FILE *stream, const char *format, ...)
{
- //WRAPPERS_DEBUG_PRINTF("my_fprintf(%x, %s)\n", stream, format);
+ WRAPPERS_DEBUG_PRINTF("my_fprintf(%x, %s)\n", stream, format);
va_list ap;
va_start(ap, format);
int result = vfprintf(stderr, format, ap);
@@ -682,14 +684,14 @@ my_fprintf(FILE *stream, const char *format, ...)
int
my_vfprintf(FILE *stream, const char *format, va_list ap)
{
- //WRAPPERS_DEBUG_PRINTF("my_vfprintf(%x, %s)\n", stream, format);
+ WRAPPERS_DEBUG_PRINTF("my_vfprintf(%x, %s)\n", stream, format);
return vfprintf(stderr, format, ap);
}
int
my_fflush(FILE *stream)
{
- //WRAPPERS_DEBUG_PRINTF("my_fflush(%x)\n", stream);
+ WRAPPERS_DEBUG_PRINTF("my_fflush(%x)\n", stream);
int offset = ((void*)stream - (void*)(&my___sF));
//printf("offset: %d\n", offset);
if (offset < 1000) {
@@ -725,7 +727,3 @@ int my_vsnprintf(char *str, size_t size, const char *format, va_list ap)
return vsnprintf(str, size, format, ap);
}
-int my_munmap(void* __addr, size_t __len)
-{
- return munmap(__addr,__len);
-}
View
36 imagelib/imagelib.h
@@ -0,0 +1,36 @@
+#ifndef IMAGELIB_H
+#define IMAGELIB_h
+
+/// image lib, (c) crow_riot 2013
+
+
+typedef struct {
+ unsigned char* data;
+ int width;
+ int height;
+ int bpp;
+} image_t;
+
+
+typedef struct {
+ /// flip horizontally
+ int swapy;
+ /// convert image data to rgba
+ int forcergba;
+ /// swap red and blue channels (bgr<>rgb)
+ int swaprb;
+ /// the alpha value to be used when image conversion takes place
+ /// and the source file does not provide an alpha
+ unsigned char alpha;
+} imageloadersettings_t;
+
+
+/// load png from disk
+image_t* loadpng(const char *filename, const imageloadersettings_t settings);
+
+/// load jpeg from disk
+/// please not that only rgb jpeg images are suported by the loader, no color indexed ones!
+image_t* loadjpeg(const char *filename, const imageloadersettings_t settings);
+
+
+#endif
View
63 png/loadpng.c → imagelib/loadpng.c
@@ -2,10 +2,11 @@
#include <stdio.h>
#include <libpng12/png.h>
-#include "loadpng.h"
+#include <stdlib.h>
+#include "imagelib.h"
-image_t* loadpng( const char *filepath, int swapy, int force_rgba, int swap_rb)
+image_t* loadpng( const char *filepath, const imageloadersettings_t settings)
{
FILE *fp = fopen(filepath,"rb");
if (!fp)
@@ -13,17 +14,20 @@ image_t* loadpng( const char *filepath, int swapy, int force_rgba, int swap_rb)
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL);
if ( !png_ptr ) {
+ fclose(fp);
return NULL;
}
png_infop info = png_create_info_struct(png_ptr);
if ( !info ) {
png_destroy_read_struct(&png_ptr, NULL, NULL);
+ fclose(fp);
return NULL;
}
if ( setjmp(png_jmpbuf(png_ptr)) ) {
png_destroy_read_struct(&png_ptr, &info, NULL);
+ fclose(fp);
return NULL;
}
@@ -31,7 +35,7 @@ image_t* loadpng( const char *filepath, int swapy, int force_rgba, int swap_rb)
png_set_sig_bytes(png_ptr,0);
- int png_transforms = PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_SWAP_ENDIAN|PNG_TRANSFORM_PACKING|PNG_TRANSFORM_EXPAND|(swap_rb?PNG_TRANSFORM_BGR:0);
+ int png_transforms = PNG_TRANSFORM_STRIP_16|PNG_TRANSFORM_SWAP_ENDIAN|PNG_TRANSFORM_PACKING|PNG_TRANSFORM_EXPAND|(settings.swaprb?PNG_TRANSFORM_BGR:0);
png_read_png(png_ptr, info, png_transforms, NULL);
@@ -56,29 +60,29 @@ image_t* loadpng( const char *filepath, int swapy, int force_rgba, int swap_rb)
}
if ( bytepp==0 ) {
+ fclose(fp);
png_destroy_read_struct(&png_ptr, &info, NULL);
return NULL;
}
- if (bytepp==4)
- force_rgba = 0;
+ int forcergba = settings.forcergba && color_type!=PNG_COLOR_TYPE_RGBA;
image_t* image = malloc(sizeof(image_t));
- image->data = malloc(sizeof(unsigned char)*width*height*(force_rgba?4:bytepp));
+ image->data = malloc(sizeof(unsigned char)*width*height*(forcergba?4:bytepp));
image->width = width;
image->height = height;
image->bpp = bytepp;
- int stride = width*(force_rgba?4:bytepp);
+ int stride = width*(forcergba?4:bytepp);
png_bytepp row_pointers = png_get_rows(png_ptr, info);
int x,y;
- if (!force_rgba) {
- if (swapy) {
+ if (!forcergba) {
+ if (settings.swapy) {
for ( y=0; y<image->height; y++ )
memcpy(image->data+stride*(image->height-1-y), row_pointers[y], rowbytes);
}
@@ -93,16 +97,49 @@ image_t* loadpng( const char *filepath, int swapy, int force_rgba, int swap_rb)
unsigned char* src = row_pointers[y];
unsigned char* trg = image->data+stride*y;
for ( x=0; x<image->width; x++ ) {
- trg[x*4+0] = src[x*bytepp+0];
- trg[x*4+1] = src[x*bytepp+1];
- trg[x*4+2] = src[x*bytepp+2];
- trg[x*4+3] = 255;
+ int tx = x*4;
+ int sx = x*bytepp;
+ trg[tx+0] = src[sx+0];
+ trg[tx+1] = src[sx+1];
+ trg[tx+2] = src[sx+2];
+ trg[tx+3] = settings.alpha;
+ }
+ }
+ }
+ else
+ if (color_type==PNG_COLOR_TYPE_GRAY) {
+ for ( y=0;y<image->height;y++ ) {
+ unsigned char* src = row_pointers[y];
+ unsigned char* trg = image->data+stride*y;
+ for ( x=0; x<image->width; x++ ) {
+ int tx = x*4;
+ int sx = x*bytepp;
+ trg[tx+0] = src[sx];
+ trg[tx+1] = src[sx];
+ trg[tx+2] = src[sx];
+ trg[tx+3] = settings.alpha;
+ }
+ }
+ }
+ else
+ if (color_type==PNG_COLOR_TYPE_GRAY_ALPHA) {
+ for ( y=0;y<image->height;y++ ) {
+ unsigned char* src = row_pointers[y];
+ unsigned char* trg = image->data+stride*y;
+ for ( x=0; x<image->width; x++ ) {
+ int tx = x*4;
+ int sx = x*bytepp;
+ trg[tx+0] = src[sx];
+ trg[tx+1] = src[sx];
+ trg[tx+2] = src[sx];
+ trg[tx+3] = src[sx+1];
}
}
}
}
png_destroy_read_struct(&png_ptr, &info, NULL);
+ fclose(fp);
return image;
}
View
5 jni/jnienv.h
@@ -45,6 +45,11 @@ struct dummy_byte_array {
long size;
};
+struct dummy_float_array {
+ float *data;
+ long size;
+};
+
struct dummy_jclass {
char *name;
};
View
4 linker/linker.c
@@ -159,8 +159,8 @@ const char *linker_get_error(void)
*/
extern void __attribute__((noinline)) rtld_db_dlactivity(void);
-static struct r_debug _r_debug = {1, NULL, &rtld_db_dlactivity,
- RT_CONSISTENT, 0};
+//static struct r_debug _r_debug = {1, NULL, &rtld_db_dlactivity,
+// RT_CONSISTENT, 0};
static struct link_map *r_debug_tail = 0;
static pthread_mutex_t _r_debug_lock = PTHREAD_MUTEX_INITIALIZER;
View
3  linker/linker.h
@@ -34,6 +34,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <elf.h>
+#include <link.h>
#undef PAGE_MASK
#undef PAGE_SIZE
@@ -45,6 +46,7 @@ const char *addr_to_name(unsigned addr);
/* magic shared structures that GDB knows about */
+#if 0
struct link_map
{
uintptr_t l_addr;
@@ -79,6 +81,7 @@ struct r_debug
int32_t r_state;
uintptr_t r_ldbase;
};
+#endif
typedef struct soinfo soinfo;
View
4 makefile
@@ -17,6 +17,9 @@ MODULES_SOURCES=$(wildcard modules/*.c)
# Pandora specific stuff
PANDORA_SOURCES=$(wildcard pandora/*.c)
+# segfault catch
+DEBUG_SOURCES=$(wildcard debug/*.c)
+
TARGET = apkenv
DESTDIR ?= /
@@ -28,6 +31,7 @@ SOURCES += $(LINKER_SOURCES)
SOURCES += $(COMPAT_SOURCES)
SOURCES += $(APKLIB_SOURCES)
SOURCES += $(JNIENV_SOURCES)
+SOURCES += $(DEBUG_SOURCES)
PANDORA ?= 0
ifeq ($(PANDORA),1)
View
163 modules/cuttherope.c
@@ -29,15 +29,11 @@
**/
/**
- * Cut the Rope Lite - incomplete (but loading already works)
- *
- * Needs more love. Looks like they are rendering some things in Java,
- * so in that case, we can't really do much apart from re-implementing
- * everything from scratch - not something I'd do.
+ * Cut the Rope Lite - 0.1 crow_riot based on the works of thp
**/
#include "common.h"
-#include "../png/loadpng.h"
+#include "../imagelib/imagelib.h"
#include <linux/limits.h>
@@ -56,8 +52,11 @@ typedef void (*cuttherope_resize_t)(JNIEnv *env, jobject object, jint width, jin
typedef void (*cuttherope_tick_t)(JNIEnv *env, jobject object, jlong tick) SOFTFP;
typedef void (*cuttherope_render_t)(JNIEnv *env, jobject object) SOFTFP;
typedef void (*cuttherope_videobannerfinished_t)(JNIEnv *env, jobject object) SOFTFP;
-typedef void (*cuttherope_resume_t)(JNIEnv*,jobject);
-typedef void (*cuttherope_imageloaded_t)(JNIEnv*,jobject,jint p1, jbyteArray p2, jint p3, jint p4);
+typedef void (*cuttherope_resume_t)(JNIEnv*,jobject) SOFTFP;
+typedef void (*cuttherope_imageloaded_t)(JNIEnv*,jobject,jint p1, jbyteArray p2, jint p3, jint p4) SOFTFP;
+typedef void (*cuttherope_nativetouchadd_t)(JNIEnv *env, jobject p0, jint p1, jint p2, jfloat p3, jfloat p4) SOFTFP;
+typedef void (*cuttherope_nativetouchprocess_t)(JNIEnv *env, jobject p0) SOFTFP;
+typedef void (*cuttherope_nativeplaybackfinished_t)(JNIEnv *env, jobject p0, jint p1);
struct SupportModulePriv {
@@ -69,6 +68,9 @@ struct SupportModulePriv {
cuttherope_videobannerfinished_t videoBannerFinished;
cuttherope_resume_t nativeResume;
cuttherope_imageloaded_t imageLoaded;
+ cuttherope_nativetouchadd_t nativeTouchAdd;
+ cuttherope_nativetouchprocess_t nativeTouchProcess;
+ cuttherope_nativeplaybackfinished_t nativePlaybackFinished;
struct GlobalState *global;
const char* home;
};
@@ -93,11 +95,10 @@ cuttherope_CallVoidMethodV(JNIEnv *, jobject, jmethodID, va_list) SOFTFP;
static jobject
cuttherope_CallStaticObjectMethodV(JNIEnv *, jclass, jmethodID, va_list) SOFTFP;
-
static jobject
cuttherope_CallObjectMethodV(JNIEnv *env, jobject p1, jmethodID p2, va_list p3)
{
- MODULE_DEBUG_PRINTF("CallObjectMethodV %s\n",p2->name);
+ MODULE_DEBUG_PRINTF("cuttherope_CallObjectMethodV %s (%s)\n",p2->name,p2->sig);
if (strcmp(p2->name, "loadData") == 0) {
struct dummy_jstring *arg;
@@ -129,9 +130,12 @@ cuttherope_CallObjectMethodV(JNIEnv *env, jobject p1, jmethodID p2, va_list p3)
MODULE_DEBUG_PRINTF(" data=%s not found\n",arg->data);
return GLOBAL_J(env);
}
- } else if (strcmp(p2->name, "getBytesOfBitmap") == 0) {
+ }
+ else if (strcmp(p2->name, "getBytesOfBitmap") == 0) {
+
char *buf;
size_t buf_size;
+
if (GLOBAL_J(env)->read_file("assets/zeptolab.png", &buf, &buf_size)) {
struct dummy_byte_array *array;
array = malloc(sizeof(struct dummy_byte_array));
@@ -140,6 +144,23 @@ cuttherope_CallObjectMethodV(JNIEnv *env, jobject p1, jmethodID p2, va_list p3)
return array;
}
}
+ else if (strcmp(p2->name, "getQuadsOfBitmap")==0) {
+ struct dummy_float_array *array;
+ array = malloc(sizeof(struct dummy_float_array));
+ array->data = malloc(4*sizeof(jfloat)); memset(array->data,0,sizeof(jfloat)*4);
+ array->size = 4;
+ return array;
+
+ }
+ else if (strcmp(p2->name, "getFontGenerator")==0) {
+ return (void*)0xF09;
+ }
+ else if (strcmp(p2->name, "getBanner")==0) {
+ return 0;
+ }
+ else if (strcmp(p2->name, "getName")==0) {
+ return (*env)->NewStringUTF(env,"");
+ }
return GLOBAL_J(env);
}
@@ -149,10 +170,18 @@ cuttherope_CallVoidMethodV(JNIEnv* env, jobject p1, jmethodID p2, va_list p3)
if (!p2)
return;
- MODULE_DEBUG_PRINTF("CallVoidMethodV %s\n",p2->name);
+ MODULE_DEBUG_PRINTF("cuttherope_CallVoidMethodV %s\n",p2->name);
if (strcmp(p2->name,"loadImage")==0) {//public void loadImage(String paramString, int paramInt)
+ imageloadersettings_t loadsettings =
+ {
+ .swapy = 0,
+ .forcergba = 1,
+ .alpha = 255,
+ .swaprb = 1,
+ };
+
struct dummy_jstring *filename = va_arg(p3, struct dummy_jstring*);
jint fileId = va_arg(p3, jint);
@@ -173,16 +202,14 @@ cuttherope_CallVoidMethodV(JNIEnv* env, jobject p1, jmethodID p2, va_list p3)
fwrite(buf, buf_size, 1, fp);
fclose(fp);
- image_t* image = loadpng(filepath,0,1,1);
+ image_t* image = 0;
+ if (strstr(filepath,".png")!=0) image = loadpng(filepath,loadsettings);
+ if (strstr(filepath,".jpeg")!=0) image = loadjpeg(filepath,loadsettings);
if (image!=0) {
MODULE_DEBUG_PRINTF("CallVoidMethodV(%s): imageLoaded=%s (%d,%d,%d) (%x)\n",p2->name,filename->data,image->width,image->height,image->bpp,image);
cuttherope_priv.imageLoaded(ENV(cuttherope_priv.global),cuttherope_priv.global,fileId,image,image->width,image->height);
-
- //free(raw);
- //free(image->data);
- //free(image);
}
}
}
@@ -192,21 +219,41 @@ cuttherope_CallVoidMethodV(JNIEnv* env, jobject p1, jmethodID p2, va_list p3)
struct dummy_jstring *filename = va_arg(p3, struct dummy_jstring*);
jint paramInt = va_arg(p3, jint);
- MODULE_DEBUG_PRINTF("CallVoidMethodV(%s): filename=%s param=%d\n",p2->name,filename->data,paramInt);
+ MODULE_DEBUG_PRINTF("cuttherope_CallVoidMethodV(%s): filename=%s param=%d\n",p2->name,filename->data,paramInt);
}
else
if ( strcmp(p2->name, "showBanner") == 0) {
cuttherope_video_banner_finished();
}
+ else
+ if (strcmp(p2->name,"playVideo")==0) {
+
+ struct dummy_jstring *filename = va_arg(p3, struct dummy_jstring*);
+ jint paramInt = va_arg(p3, jint);
+
+ if (cuttherope_priv.nativePlaybackFinished)
+ cuttherope_priv.nativePlaybackFinished(ENV(cuttherope_priv.global),
+ cuttherope_priv.global,paramInt);
+ }
}
static jobject
cuttherope_CallStaticObjectMethodV(JNIEnv *env, jclass p1, jmethodID p2, va_list p3)
{
+ MODULE_DEBUG_PRINTF("cuttherope_CallStaticObjectMethodV %s\n",p2->name);
+
if (strcmp(p2->name, "getAppVersion") == 0) {
return (*env)->NewStringUTF(env, "1.1.0");
}
+ else
+ if (strcmp(p2->name,"getAsString") == 0) {
+ jint param = va_arg(p3, jint);
+ MODULE_DEBUG_PRINTF(" param=%d\n",param);
+ return (*env)->NewStringUTF(env,"en");
+ //MODULE_DEBUG_PRINTF(" string=%s\n",arg->data);
+ //return arg;
+ }
return NULL;
}
@@ -219,6 +266,13 @@ cuttherope_CallIntMethodV(JNIEnv* p0, jobject p1, jmethodID p2, va_list p3)
struct dummy_jstring *arg;
arg = va_arg(p3, struct dummy_jstring*);
MODULE_DEBUG_PRINTF(" key=%s\n",arg->data);
+
+ if (strstr(arg->data,"UNLOCKED_")!=0)
+ return 1;
+ if (strstr(arg->data,"STARS_")!=0)
+ return 3;
+ if (strstr(arg->data,"SCORE_")!=0)
+ return 1;
}
return 0;
}
@@ -236,7 +290,7 @@ static int
cuttherope_try_init(struct SupportModule *self)
{
/*
- Java_com_zeptolab_ctr_CtrRenderer_nativeResize
+ Java_com_zeptolab_ctr_CtrRenderer_nativeResize
Java_com_zeptolab_ctr_CtrRenderer_freeDirect
Java_com_zeptolab_ctr_CtrRenderer_nativeMenuPressed
Java_com_zeptolab_ctr_CtrRenderer_nativeBackPressed
@@ -257,6 +311,41 @@ cuttherope_try_init(struct SupportModule *self)
Java_com_zeptolab_ctr_CtrResourceLoader_imageLoaded
*/
+ /*
+ Java_com_zeptolab_ctr_CtrRenderer_nativePlaybackFinished
+ JNI_OnLoad
+ JNI_OnUnload
+ Java_com_zeptolab_ctr_billing_CtrBillingManager_purchaseTransactionStarted
+ Java_com_zeptolab_ctr_billing_CtrBillingManager_purchaseCanceled
+ Java_com_zeptolab_ctr_billing_CtrBillingManager_purchased
+ Java_com_zeptolab_ctr_CtrRenderer_nativeResize
+ Java_com_zeptolab_ctr_CtrRenderer_videoBannerFinished
+ Java_com_zeptolab_ctr_CtrRenderer_freeDirect
+ Java_com_zeptolab_ctr_CtrRenderer_allocDirect
+ Java_com_zeptolab_ctr_CtrRenderer_nativeMenuPressed
+ Java_com_zeptolab_ctr_CtrRenderer_nativeBackPressed
+ Java_com_zeptolab_ctr_CtrRenderer_nativeDrawFps
+ Java_com_zeptolab_ctr_CtrRenderer_nativeCpuIndex
+ Java_com_zeptolab_ctr_CtrRenderer_nativeTouchProcess
+ Java_com_zeptolab_ctr_CtrRenderer_nativeTouchAdd
+ Java_com_zeptolab_ctr_CtrRenderer_nativeRender
+ Java_com_zeptolab_ctr_CtrRenderer_nativeTick
+ Java_com_zeptolab_ctr_CtrRenderer_nativePause
+ Java_com_zeptolab_ctr_CtrRenderer_nativeResume
+ Java_com_zeptolab_ctr_CtrRenderer_nativeDestroy
+ Java_com_zeptolab_ctr_CtrRenderer_videoBannerRequestAdButton
+ Java_com_zeptolab_ctr_CtrRenderer_nativeInit
+ Java_com_zeptolab_ctr_CtrSaveManager_restoreBroken
+ Java_com_zeptolab_ctr_CtrSaveManager_restoreSuccess
+ Java_com_zeptolab_ctr_testing_ABTestingInterface_setInstance
+ Java_com_zeptolab_ctr_testing_ABTestingInterface_callback
+ Java_com_zeptolab_ctr_remotedata_cartoons_VideoDataManager_rebuildCartoonsSelect
+ Java_com_zeptolab_ctr_CtrView_nativeInitScorer
+ Java_com_zeptolab_ctr_CtrApp_nativeInitRemoteDataManager
+ Java_com_zeptolab_ctr_CtrApp_nativeInitVideoDataManager
+ Java_com_zeptolab_ctr_CtrResourceLoader_getLocalized
+ */
+
self->priv->JNI_OnLoad = (jni_onload_t)LOOKUP_M("JNI_OnLoad");
self->priv->nativeInit = (cuttherope_init_t)LOOKUP_M("CtrRenderer_nativeInit");
@@ -265,8 +354,9 @@ cuttherope_try_init(struct SupportModule *self)
self->priv->nativeRender = (cuttherope_render_t)LOOKUP_M("CtrRenderer_nativeRender");
self->priv->nativeResume = (cuttherope_resume_t)LOOKUP_M("CtrRenderer_nativeResume");
self->priv->imageLoaded = (cuttherope_imageloaded_t)LOOKUP_M("CtrResourceLoader_imageLoaded");
- self->priv->videoBannerFinished = (cuttherope_videobannerfinished_t)LOOKUP_M("videoBannerFinished");
- //self->priv->nativePlaybackFinished;
+ self->priv->nativeTouchAdd = (cuttherope_nativetouchadd_t)LOOKUP_M("CtrRenderer_nativeTouchAdd");
+ self->priv->nativeTouchProcess = (cuttherope_nativetouchprocess_t)LOOKUP_M("CtrRenderer_nativeTouchProcess");
+ self->priv->nativePlaybackFinished = (cuttherope_nativeplaybackfinished_t)LOOKUP_M("CtrRenderer_nativePlaybackFinished");
self->priv->global = GLOBAL_M;
@@ -281,7 +371,10 @@ cuttherope_try_init(struct SupportModule *self)
self->priv->nativeResize != NULL &&
self->priv->nativeTick != NULL &&
self->priv->nativeRender != NULL &&
- self->priv->imageLoaded != NULL
+ //self->priv->imageLoaded != NULL &&
+ self->priv->nativeTouchAdd != NULL &&
+ self->priv->nativeTouchProcess != NULL &&
+ self->priv->nativePlaybackFinished != NULL
);
}
@@ -302,7 +395,11 @@ cuttherope_init(struct SupportModule *self, int width, int height, const char *h
self->priv->JNI_OnLoad(VM_M, NULL);
- self->priv->nativeResize(ENV_M, GLOBAL_M, width, height);
+#ifdef PANDORA
+ self->priv->nativeResize(ENV_M, GLOBAL_M, height, width); //$$$ landscape-to-portrait pandora fix
+#else
+ self->priv->nativeResize(ENV_M, GLOBAL_M, width, height); //$$$ landscape-to-portrait pandora fix
+#endif
self->priv->nativeInit(ENV_M, GLOBAL_M, resourceLoader, soundManager, preferences,
saveManager, flurry, videoPlayer, scorer,
@@ -314,6 +411,26 @@ cuttherope_init(struct SupportModule *self, int width, int height, const char *h
static void
cuttherope_input(struct SupportModule *self, int event, int x, int y, int finger)
{
+#ifdef PANDORA
+ //$$$ landscape-to-portrait pandora fix
+ x = 800-x;
+ y = y;
+ int tmp = x; x = y; y = tmp;
+#endif
+
+ if (event==ACTION_MOVE) {
+ self->priv->nativeTouchAdd(ENV_M,GLOBAL_M,0,2,x,y);
+ }
+ else
+ if (event==ACTION_UP) {
+ self->priv->nativeTouchAdd(ENV_M,GLOBAL_M,0,0,x,y);
+ }
+ else
+ if (event==ACTION_DOWN) {
+ self->priv->nativeTouchAdd(ENV_M,GLOBAL_M,0,1,x,y);
+ }
+
+ self->priv->nativeTouchProcess(ENV_M,GLOBAL_M);
}
static void
View
12 modules/cuttherope.cbp
@@ -37,6 +37,18 @@
<Add option="-DPANDORA" />
<Add option="-DAPKENV_DEBUG" />
</Compiler>
+ <Linker>
+ <Add library="png12" />
+ <Add library="z" />
+ <Add library="jpeg" />
+ </Linker>
+ <Unit filename="../imagelib/imagelib.h" />
+ <Unit filename="../imagelib/loadjpeg.c">
+ <Option compilerVar="CC" />
+ </Unit>
+ <Unit filename="../imagelib/loadpng.c">
+ <Option compilerVar="CC" />
+ </Unit>
<Unit filename="cuttherope.c">
<Option compilerVar="CC" />
</Unit>
View
49 modules/fruitninja.c
@@ -55,7 +55,7 @@ typedef jboolean (*fruitninja_step_t)(JNIEnv *env, jobject obj) SOFTFP;
typedef void (*fruitninja_pause_t)(JNIEnv *env, jobject obj) SOFTFP;
typedef void (*fruitninja_resume_t)(JNIEnv *env, jobject obj) SOFTFP;
typedef void (*fruitninja_saveonexit_t)(JNIEnv *env, jobject obj) SOFTFP;
-typedef void (*fruitninja_gamerequestedquit_t)(JNIEnv *env, jobject obj) SOFTFP;
+typedef jboolean (*fruitninja_gamerequestedquit_t)(JNIEnv *env, jobject obj) SOFTFP;
typedef void (*fruitninja_setapplicensed_t)(JNIEnv *env, jobject obj, jboolean value) SOFTFP;
typedef void (*fruitninja_initfilemanager_t)(JNIEnv *env, jobject obj, jstring paramString1, jstring paramString2, jboolean paramBoolean) SOFTFP;
typedef void (*fruitninja_initjavasoundmanager_t)(JNIEnv *env, jobject obj) SOFTFP;
@@ -72,6 +72,7 @@ struct SupportModulePriv {
fruitninja_setapplicensed_t native_setapplicensed;
fruitninja_initfilemanager_t native_initfilemanager;
fruitninja_initjavasoundmanager_t native_initjavasoundmanager;
+ jmethodID isNetworkConnected;
const char *myHome;
};
static struct SupportModulePriv fruitninja_priv;
@@ -108,7 +109,7 @@ load_sound_callback(const char *filename, char *buffer, size_t size)
}
jobject
-JNIEnv_CallStaticObjectMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3)
+JNIEnv_CallStaticObjectMethodV(JNIEnv*env, jclass p1, jmethodID p2, va_list p3)
{
struct dummy_jclass *jcl = p1;
@@ -135,6 +136,10 @@ JNIEnv_CallStaticObjectMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3)
}
else
+ if (strcmp(p2->name,"GetPackageName")==0){
+ return (*env)->NewStringUTF(env,global->apk_filename);
+ }
+ else
{
MODULE_DEBUG_PRINTF("module_JNIEnv_CallStaticObjectMethodV(%s, %s, %s)\n",
jcl->name, p2->name, p2->sig);
@@ -148,7 +153,7 @@ JNIEnv_CallStaticObjectMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3)
void
extract_files_callback(const char *filename, char *buffer, size_t size)
{
- char* fname = strchr (filename, '/') + 1;
+ char* fname = strrchr (filename, '/') + 1;
char tmp[PATH_MAX];
strcpy(tmp, fruitninja_priv.myHome);
@@ -178,6 +183,9 @@ JNIEnv_CallStaticVoidMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3)
{
struct dummy_jclass *jcl = p1;
+ MODULE_DEBUG_PRINTF("module_JNIEnv_CallStaticVoidMethodV(%x, %s, %s)\n", jcl->name, p2->name, p2->sig);
+
+
if( strcmp( p2->name, "SongPlay" ) == 0 ) // Play some sweet backround music?
{
struct dummy_jstring *str = va_arg(p3,struct dummy_jstring*); //Music file?
@@ -246,8 +254,8 @@ JNIEnv_GetFieldID(JNIEnv* p0, jclass p1, const char* p2, const char* p3)
jclass
JNIEnv_FindClass(JNIEnv* p0, const char* p1)
{
- /*if( !strcmp( p1, "com/openfeint/api/OpenFeint" ) == 0 )
- MODULE_DEBUG_PRINTF("module_JNIEnv_FindClass('%s')\n", p1);*/
+ if( !strcmp( p1, "com/openfeint/api/OpenFeint" ) == 0 )
+ MODULE_DEBUG_PRINTF("module_JNIEnv_FindClass('%s')\n", p1);
struct dummy_jclass *class = malloc(sizeof(struct dummy_jclass));
class->name = strdup(p1);
return class;
@@ -255,6 +263,15 @@ JNIEnv_FindClass(JNIEnv* p0, const char* p1)
jmethodID
JNIEnv_GetStaticMethodID(JNIEnv* p0, jclass clazz, const char* name, const char* sig)
{
+ if (strcmp(name,"isNetworkConnected")==0) {
+ if (fruitninja_priv.isNetworkConnected==0) {
+ fruitninja_priv.isNetworkConnected = malloc(sizeof(struct _jmethodID));
+ fruitninja_priv.isNetworkConnected->clazz = clazz;
+ fruitninja_priv.isNetworkConnected->name = strdup(name);
+ fruitninja_priv.isNetworkConnected->sig = strdup(sig);
+ }
+ return fruitninja_priv.isNetworkConnected;
+ }
MODULE_DEBUG_PRINTF("module_JNIEnv_GetStaticMethodID(%x, %s, %s)\n", clazz, name, sig);
jmethodID id = malloc(sizeof(struct _jmethodID));
id->clazz = clazz;
@@ -266,12 +283,13 @@ jboolean
JNIEnv_CallStaticBooleanMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3)
{
//struct dummy_jclass *clazz = (struct dummy_jclass*)p1;
- if( !strcmp( p2->name, "isNetworkConnected" ) == 0 )
+ if( strcmp( p2->name, "isNetworkConnected" ) != 0 ) {
MODULE_DEBUG_PRINTF("module_JNIEnv_CallStaticBooleanMethodV(%x, %s, %s)\n", p2->clazz, p2->name, p2->sig);
+ }
return 0;
}
-jboolean
-JNIEnv_CallStaticIntMethodMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3)
+jint
+JNIEnv_CallStaticIntMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p3)
{
MODULE_DEBUG_PRINTF("module_JNIEnv_CallStaticIntMethodMethodV(%x, %s, %s)\n", p2->clazz, p2->name, p2->sig);
if (strcmp(p2->name,"GetWifi")==0) return 0;
@@ -281,12 +299,13 @@ JNIEnv_CallStaticIntMethodMethodV(JNIEnv* p0, jclass p1, jmethodID p2, va_list p
void
JNIEnv_ExceptionClear(JNIEnv* p0)
{
- //MODULE_DEBUG_PRINTF("JNIEnv_ExceptionClear()\n");
+ //MODULE_DEBUG_PRINTF("module_JNIEnv_ExceptionClear()\n");
}
+
jthrowable
JNIEnv_ExceptionOccurred(JNIEnv* p0)
{
- //MODULE_DEBUG_PRINTF("JNIEnv_ExceptionOccurred()\n");
+ //MODULE_DEBUG_PRINTF("module_JNIEnv_ExceptionOccurred()\n");
return NULL;
}
@@ -307,6 +326,7 @@ fruitninja_try_init(struct SupportModule *self)
self->priv->native_setapplicensed = (fruitninja_setapplicensed_t)LOOKUP_M("_NativeGameLib_native_1SetAppLicensed");
self->priv->native_initfilemanager = (fruitninja_initfilemanager_t)LOOKUP_M("_NativeGameLib_native_1InitFileManager");
self->priv->native_initjavasoundmanager = (fruitninja_initjavasoundmanager_t)LOOKUP_M("_NativeGameLib_native_1InitJavaSoundManager");
+ self->priv->isNetworkConnected = 0;
/* override for JNIEnv_ */
self->override_env.CallStaticObjectMethodV = JNIEnv_CallStaticObjectMethodV;
@@ -319,7 +339,8 @@ fruitninja_try_init(struct SupportModule *self)
self->override_env.CallStaticBooleanMethodV = JNIEnv_CallStaticBooleanMethodV;
self->override_env.CallStaticVoidMethodV = JNIEnv_CallStaticVoidMethodV;
self->override_env.ExceptionOccurred = JNIEnv_ExceptionOccurred;
- self->override_env.CallStaticIntMethodV = JNIEnv_CallStaticIntMethodMethodV;
+ self->override_env.CallStaticIntMethodV = JNIEnv_CallStaticIntMethodV;
+
return (//self->priv->JNI_OnLoad != NULL &&
self->priv->native_init != NULL &&
@@ -356,7 +377,7 @@ fruitninja_init(struct SupportModule *self, int width, int height, const char *h
global->foreach_file("assets/sound", load_sound_callback);
/* Extract files */
- //global->foreach_file("assets/", extract_files_callback);
+ global->foreach_file("assets/music", extract_files_callback);
#ifdef PANDORA
sync();
@@ -387,8 +408,6 @@ fruitninja_update(struct SupportModule *self)
static void
fruitninja_deinit(struct SupportModule *self)
{
- self->priv->native_gamerequestedquit(ENV_M, GLOBAL_M);
-
if( Mix_PlayingMusic() != 0 ) Mix_FreeMusic( music );
int i;
@@ -415,6 +434,8 @@ fruitninja_resume(struct SupportModule *self)
static int
fruitninja_requests_exit(struct SupportModule *self)
{
+ if (self->priv->native_gamerequestedquit(ENV_M,GLOBAL_M))
+ return 1;
return 0;
}
View
5 modules/generic.c
@@ -78,6 +78,11 @@ static void
generic_resume(struct SupportModule *self)
{
}
+static int
+generic_requests_exit(struct SupportModule *self)
+{
+ return 0;
+}
APKENV_MODULE(generic, MODULE_PRIORITY_GENERIC)
View
6 modules/unity.depend
@@ -1,13 +1,13 @@
# depslib dependency file v1.0
-1358038756 source:/home/xubuntu/Pandora/apkenv/modules/unity.c
+1358284664 source:/home/xubuntu/Pandora/apkenv/modules/unity.c
"common.h"
<string.h>
-1358021242 /home/xubuntu/Pandora/apkenv/modules/common.h
+1358072293 /home/xubuntu/Pandora/apkenv/modules/common.h
"../apkenv.h"
"../jni/jnienv.h"
-1358022504 /home/xubuntu/Pandora/apkenv/apkenv.h
+1358279163 /home/xubuntu/Pandora/apkenv/apkenv.h
"apklib/apklib.h"
"jni/jni.h"
View
6 modules/worldofgoo.c
@@ -275,5 +275,11 @@ worldofgoo_resume(struct SupportModule *self)
{
}
+static int
+worldofgoo_requests_exit(struct SupportModule *self)
+{
+ return 0;
+}
+
APKENV_MODULE(worldofgoo, MODULE_PRIORITY_GAME)
View
8 pandora/platform.c
@@ -69,13 +69,13 @@ int GLES_TestError(const char* msg)
{
EGLint err = eglGetError();
if (err!=EGL_SUCCESS) {
- fprintf(stderr,"EGL ERROR: %x near %s\n",err,msg);
+ fprintf(stderr,"EGL ERROR: 0x%x near %s\n",err,msg);
return 1;
}
err = glGetError();
if(err!=GL_NO_ERROR) {
- fprintf(stderr,"GL ERROR: %x near %s\n",err,msg);
+ fprintf(stderr,"GL ERROR: 0x%x near %s\n",err,msg);
return 1;
}
@@ -105,7 +105,7 @@ const char* platform_getdatadirectory()
const char* platform_getmoduledirectory()
{
- return "./modules/";
+ return "./modules";
}
const char* platform_getinstalldirectory()
@@ -207,7 +207,7 @@ int platform_update()
}
eglSwapBuffers(data->eglDisplay,data->eglSurface);
- GLES_TestError("eglSwapBuffers");
+ // GLES_TestError("eglSwapBuffers");
#ifdef APKENV_DEBUG
// printf("%d swap\n",pthread_self());
#endif
View
22 png/loadpng.h
@@ -1,22 +0,0 @@
-#ifndef LOADPNG_H
-#define LOADPNG_h
-
-/// png loader, (c) crow_riot 2013
-
-
-typedef struct {
- unsigned char* data;
- int width;
- int height;
- int bpp;
-} image_t;
-
-
-
-/// load png from disk
-image_t* loadpng(const char* filename, int swapy, int force_rgba, int swap_rb);
-
-
-
-
-#endif
Please sign in to comment.
Something went wrong with that request. Please try again.