Add Android JNI files

This commit is contained in:
twinaphex 2017-03-24 06:43:45 +01:00
parent 4680a59d32
commit 46f8007077
5 changed files with 459 additions and 425 deletions

View File

@ -46,4 +46,4 @@ SOURCES_C := \
$(CORE_DIR)/libretro/sdl_wrapp/sdl_primitives.c \
$(CORE_DIR)/libretro/sdl_wrapp/bmp.c \
$(CORE_DIR)/libretro/core/libretro-core.c \
$(CORE_DIR)/libretro/core/core-mapper.o
$(CORE_DIR)/libretro/core/core-mapper.c

35
jni/Android.mk Normal file
View File

@ -0,0 +1,35 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
GIT_VERSION ?= " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown")
LOCAL_CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
ifeq ($(TARGET_ARCH),arm)
LOCAL_CFLAGS += -DANDROID_ARM
LOCAL_ARM_MODE := arm
endif
ifeq ($(TARGET_ARCH),x86)
LOCAL_CFLAGS += -DANDROID_X86
endif
ifeq ($(TARGET_ARCH),mips)
LOCAL_CFLAGS += -DANDROID_MIPS
endif
CORE_DIR := ..
LOCAL_MODULE := libretro
include $(CORE_DIR)/Makefile.common
LOCAL_SRC_FILES = $(SOURCES_CXX) $(SOURCES_C)
LOCAL_CFLAGS += -DANDROID -D__LIBRETRO__ $(INCFLAGS)
LOCAL_LDLIBS += -lz
LOCAL_C_INCLUDES = $(CORE_DIR)/libfreedo $(INCFLAGS)
include $(BUILD_SHARED_LIBRARY)

1
jni/Application.mk Normal file
View File

@ -0,0 +1 @@
APP_ABI := all

View File

@ -10,18 +10,18 @@
extern int SurfaceFormat;
typedef struct /**** BMP file header structure ****/
{
{
unsigned short bfType; /* Magic number for file */
unsigned int bfSize; /* Size of file */
unsigned short bfReserved1; /* Reserved */
unsigned short bfReserved2; /* ... */
unsigned int bfOffBits; /* Offset to bitmap data */
} BITMAPFILEHEADER;
} BITMAPFILEHEADER;
# define BF_TYPE 0x4D42 /* "MB" */
typedef struct /**** BMP file info structure ****/
{
{
unsigned int biSize; /* Size of info header */
int biWidth; /* Width of image */
int biHeight; /* Height of image */
@ -33,7 +33,7 @@ typedef struct /**** BMP file info structure ****/
int biYPelsPerMeter; /* Y pixels per meter */
unsigned int biClrUsed; /* Number of colors used */
unsigned int biClrImportant; /* Number of important colors */
} BITMAPINFOHEADER;
} BITMAPINFOHEADER;
/*
* Constants for the biCompression field...
@ -45,42 +45,42 @@ typedef struct /**** BMP file info structure ****/
# define BI_BITFIELDS 3 /* RGB bitmap with RGB masks */
typedef struct /**** Colormap entry structure ****/
{
{
unsigned char rgbBlue; /* Blue value */
unsigned char rgbGreen; /* Green value */
unsigned char rgbRed; /* Red value */
unsigned char rgbReserved; /* Reserved */
} RGBQUAD;
} RGBQUAD;
typedef struct /**** Bitmap information structure ****/
{
{
BITMAPINFOHEADER bmiHeader; /* Image header */
RGBQUAD bmiColors[256]; /* Image colormap */
} BITMAPINFO;
} BITMAPINFO;
/*
* 'read_word()' - Read a 16-bit unsigned integer.
*/
static unsigned short /* O - 16-bit unsigned integer */
static unsigned short /* O - 16-bit unsigned integer */
read_word(FILE *fp) /* I - File to read from */
{
{
unsigned char b0, b1; /* Bytes from file */
b0 = getc(fp);
b1 = getc(fp);
return ((b1 << 8) | b0);
}
}
/*
* 'read_dword()' - Read a 32-bit unsigned integer.
*/
static unsigned int /* O - 32-bit unsigned integer */
static unsigned int /* O - 32-bit unsigned integer */
read_dword(FILE *fp) /* I - File to read from */
{
{
unsigned char b0, b1, b2, b3; /* Bytes from file */
b0 = getc(fp);
@ -89,16 +89,16 @@ read_dword(FILE *fp) /* I - File to read from */
b3 = getc(fp);
return ((((((b3 << 8) | b2) << 8) | b1) << 8) | b0);
}
}
/*
* 'read_long()' - Read a 32-bit signed integer.
*/
static int /* O - 32-bit signed integer */
static int /* O - 32-bit signed integer */
read_long(FILE *fp) /* I - File to read from */
{
{
unsigned char b0, b1, b2, b3; /* Bytes from file */
b0 = getc(fp);
@ -107,49 +107,49 @@ read_long(FILE *fp) /* I - File to read from */
b3 = getc(fp);
return ((int)(((((b3 << 8) | b2) << 8) | b1) << 8) | b0);
}
}
/*
* 'write_word()' - Write a 16-bit unsigned integer.
*/
static int /* O - 0 on success, -1 on error */
static int /* O - 0 on success, -1 on error */
write_word(FILE *fp, /* I - File to write to */
unsigned short w) /* I - Integer to write */
{
{
putc(w, fp);
return (putc(w >> 8, fp));
}
}
/*
* 'write_dword()' - Write a 32-bit unsigned integer.
*/
static int /* O - 0 on success, -1 on error */
static int /* O - 0 on success, -1 on error */
write_dword(FILE *fp, /* I - File to write to */
unsigned int dw) /* I - Integer to write */
{
{
putc(dw, fp);
putc(dw >> 8, fp);
putc(dw >> 16, fp);
return (putc(dw >> 24, fp));
}
}
/*
* 'write_long()' - Write a 32-bit signed integer.
*/
static int /* O - 0 on success, -1 on error */
static int /* O - 0 on success, -1 on error */
write_long(FILE *fp, /* I - File to write to */
int l) /* I - Integer to write */
{
{
putc(l, fp);
putc(l >> 8, fp);
putc(l >> 16, fp);
return (putc(l >> 24, fp));
}
}
@ -199,7 +199,7 @@ int SDL_SaveBMP(SDL_Surface *surface,const char *file){
write_dword(fp, 0/*info->bmiHeader.biClrUsed*/);
write_dword(fp, 0/*info->bmiHeader.biClrImportant*/);
printf("Stype:%d \n",stype);
printf("Stype:%d \n",stype);
if(stype==1){
unsigned char *ptr=(unsigned char*)&surface->pixels;
@ -222,9 +222,9 @@ printf("Stype:%d \n",stype);
temp = (unsigned short int) (*ptr)&0xffff;
#define R5 ((temp>>11)&0x1F)
#define G6 ((temp>>5 )&0x3F)
#define B5 ((temp )&0x1F)
#define R5 ((temp>>11)&0x1F)
#define G6 ((temp>>5 )&0x3F)
#define B5 ((temp )&0x1F)
R8 = ( R5 * 527 + 23 ) >> 6;
G8 = ( G6 * 259 + 33 ) >> 6;
@ -242,14 +242,14 @@ printf("Stype:%d \n",stype);
// RGB to bgr
unsigned int *ptr=(unsigned int*)&surface->pixels;
unsigned temp;
printf("%dx%d %dx%d\n",retrow,retroh,surface->w,surface->h);
printf("%dx%d %dx%d\n",retrow,retroh,surface->w,surface->h);
for (i = 0;i</*retrow*retroh*/surface->w*surface->h;i++){
temp = (unsigned int) (*ptr)&0xffffffff;
#define R8 ((temp>>16)&0xFF)
#define G8 ((temp>>8 )&0xFF)
#define B8 ((temp )&0xFF)
#define R8 ((temp>>16)&0xFF)
#define G8 ((temp>>8 )&0xFF)
#define B8 ((temp )&0xFF)
printf("i:%d temp:%x (%x,%x,%x)\n",i,temp,R8,G8,B8);
ptr++;
@ -260,7 +260,7 @@ printf("%dx%d %dx%d\n",retrow,retroh,surface->w,surface->h);
}
}
printf("ici\n");
printf("ici\n");
const int bw = surface->w/*retrow*/*3;
int pad;
@ -293,6 +293,7 @@ printf("ici\n");
SDL_Surface * SDL_LoadBMP(const char *file)
{
int y, x;
int width,height,size;
SDL_Surface *surf;
RGBQUAD LUT[256];
@ -327,18 +328,18 @@ SDL_Surface * SDL_LoadBMP(const char *file)
return NULL;
}
bmpheader.bfType=fileh[0]|fileh[1]<<8;
bmpheader.bfSize=fileh[2]|fileh[3]<<8|fileh[4]<<16|fileh[5]<<24;
bmpheader.bfReserved1=fileh[6]|fileh[7]<<8;
bmpheader.bfReserved2=fileh[8]|fileh[9]<<8;
bmpheader.bfOffBits=fileh[10]|fileh[11]<<8|fileh[12]<<16|fileh[13]<<24;
bmpheader.bfType=fileh[0]|fileh[1]<<8;
bmpheader.bfSize=fileh[2]|fileh[3]<<8|fileh[4]<<16|fileh[5]<<24;
bmpheader.bfReserved1=fileh[6]|fileh[7]<<8;
bmpheader.bfReserved2=fileh[8]|fileh[9]<<8;
bmpheader.bfOffBits=fileh[10]|fileh[11]<<8|fileh[12]<<16|fileh[13]<<24;
printf(" %x %d %x %x %x \n",
bmpheader.bfType,
bmpheader.bfSize,
bmpheader.bfReserved1,
bmpheader.bfReserved2 ,
bmpheader.bfOffBits );
printf(" %x %d %x %x %x \n",
bmpheader.bfType,
bmpheader.bfSize,
bmpheader.bfReserved1,
bmpheader.bfReserved2 ,
bmpheader.bfOffBits );
result=fread(fileh, 1, 40, fp);
@ -350,30 +351,30 @@ bmpheader.bfOffBits );
return NULL;
}
bmpinfo.biSize=fileh[0]|fileh[1]<<8|fileh[2]<<16|fileh[3]<<24;
bmpinfo.biWidth=fileh[4]|fileh[5]<<8|fileh[6]<<16|fileh[7]<<24;
bmpinfo.biHeight=fileh[8]|fileh[9]<<8|fileh[10]<<16|fileh[11]<<24;
bmpinfo.biPlanes=fileh[12]|fileh[13]<<8;
bmpinfo.biBitCount=fileh[14]|fileh[15]<<8;
bmpinfo.biCompression=fileh[16]|fileh[17]<<8|fileh[18]<<16|fileh[19]<<24;
bmpinfo.biSizeImage=fileh[20]|fileh[21]<<8|fileh[22]<<16|fileh[23]<<24;
bmpinfo.biXPelsPerMeter=fileh[24]|fileh[25]<<8|fileh[26]<<16|fileh[27]<<24;
bmpinfo.biYPelsPerMeter=fileh[28]|fileh[29]<<8|fileh[30]<<16|fileh[31]<<24;
bmpinfo.biClrUsed=fileh[32]|fileh[33]<<8|fileh[34]<<16|fileh[35]<<24;
bmpinfo.biClrImportant=fileh[36]|fileh[37]<<8|fileh[38]<<16|fileh[39]<<24;
bmpinfo.biSize=fileh[0]|fileh[1]<<8|fileh[2]<<16|fileh[3]<<24;
bmpinfo.biWidth=fileh[4]|fileh[5]<<8|fileh[6]<<16|fileh[7]<<24;
bmpinfo.biHeight=fileh[8]|fileh[9]<<8|fileh[10]<<16|fileh[11]<<24;
bmpinfo.biPlanes=fileh[12]|fileh[13]<<8;
bmpinfo.biBitCount=fileh[14]|fileh[15]<<8;
bmpinfo.biCompression=fileh[16]|fileh[17]<<8|fileh[18]<<16|fileh[19]<<24;
bmpinfo.biSizeImage=fileh[20]|fileh[21]<<8|fileh[22]<<16|fileh[23]<<24;
bmpinfo.biXPelsPerMeter=fileh[24]|fileh[25]<<8|fileh[26]<<16|fileh[27]<<24;
bmpinfo.biYPelsPerMeter=fileh[28]|fileh[29]<<8|fileh[30]<<16|fileh[31]<<24;
bmpinfo.biClrUsed=fileh[32]|fileh[33]<<8|fileh[34]<<16|fileh[35]<<24;
bmpinfo.biClrImportant=fileh[36]|fileh[37]<<8|fileh[38]<<16|fileh[39]<<24;
printf(" %x %x %x %x %x %x %x %x %x %x %x\n",
bmpinfo.biSize,
bmpinfo.biWidth,
bmpinfo.biHeight,
bmpinfo.biPlanes,
bmpinfo.biBitCount,
bmpinfo.biCompression,
bmpinfo.biSizeImage,
bmpinfo.biXPelsPerMeter,
bmpinfo.biYPelsPerMeter,
bmpinfo.biClrUsed,
bmpinfo.biClrImportant );
printf(" %x %x %x %x %x %x %x %x %x %x %x\n",
bmpinfo.biSize,
bmpinfo.biWidth,
bmpinfo.biHeight,
bmpinfo.biPlanes,
bmpinfo.biBitCount,
bmpinfo.biCompression,
bmpinfo.biSizeImage,
bmpinfo.biXPelsPerMeter,
bmpinfo.biYPelsPerMeter,
bmpinfo.biClrUsed,
bmpinfo.biClrImportant );
// check if file is actually a bmp
if ( bmpheader.bfType != 'MB' )
@ -383,7 +384,7 @@ bmpinfo.biClrImportant );
return NULL;
}
//printf("IN SDL LOAD BMP after headers read %x %x %x %x %x\n",bmpheader.bfType,bmpinfo.biBitCount,bmpinfo.biSize,bmpinfo.biWidth,bmpinfo.biHeight);
//printf("IN SDL LOAD BMP after headers read %x %x %x %x %x\n",bmpheader.bfType,bmpinfo.biBitCount,bmpinfo.biSize,bmpinfo.biWidth,bmpinfo.biHeight);
// get image measurements
width = bmpinfo.biWidth;
@ -448,7 +449,7 @@ bmpinfo.biClrImportant );
surf=Retro_CreateRGBSurface(width ,height, 8, 0,0,0,0);
}
if(surf==NULL)printf("failed createRGBsurf\n");
//printf("after createsurf\n");
//printf("after createsurf\n");
unsigned coul;
unsigned *pix32=surf->pixels;
@ -456,10 +457,8 @@ bmpinfo.biClrImportant );
unsigned char *pix8=surf->pixels;
long bufpos = 0;
for ( int y = 0; y < height; y++ )
for ( int x = 0; x < width; x++)
for ( y = 0; y < height; y++ )
for ( x = 0; x < width; x++)
{
bufpos = ( height - y - 1 ) * width + x;
@ -479,25 +478,25 @@ bmpinfo.biClrImportant );
if(1/*SurfaceFormat!=0 && SurfaceFormat!=1*/){
SDL_Color *pptr=surf->format->palette->colors;
for ( int y = 0; y < 256; y++ ){
if(y<lutsize){
for ( y = 0; y < 256; y++ ){
if(y<lutsize){
(*pptr).r=LUT[y].rgbRed;
(*pptr).g=LUT[y].rgbGreen;
(*pptr).b=LUT[y].rgbBlue;
(*pptr).a=LUT[y].rgbReserved;
}
else{
}
else{
(*pptr).r=0;
(*pptr).g=0;
(*pptr).b=0;
(*pptr).a=0;
}
}
pptr++;
}
pptr++;
}
}
//printf("Return %d\n",SurfaceFormat);
//printf("Return %d\n",SurfaceFormat);
free(Buffer);
fclose ( fp );
@ -523,10 +522,10 @@ pptr++;
return NULL;
}
//printf("IN SDL LOAD BMP CreateRGBSurface %d %d \n",width ,height);
//printf("IN SDL LOAD BMP CreateRGBSurface %d %d \n",width ,height);
surf=Retro_CreateRGBSurface(width ,height, 16, 0,0,0,0);
if(surf==NULL)printf("failed createRGBsurf\n");
//printf("IN SDL LOAD BMP after CreateRGBSurface\n");
if(surf==NULL)printf("failed createRGBsurf\n");
//printf("IN SDL LOAD BMP after CreateRGBSurface\n");
int padding = 0;
@ -543,8 +542,8 @@ if(surf==NULL)printf("failed createRGBsurf\n");
unsigned short coul;
unsigned short *pix=surf->pixels;
for ( int y = 0; y < height; y++ )
for ( int x = 0; x < 3 * width; x+=3 )
for ( y = 0; y < height; y++ )
for ( x = 0; x < 3 * width; x+=3 )
{
bufpos = ( height - y - 1 ) * psw + x;
@ -557,7 +556,7 @@ if(surf==NULL)printf("failed createRGBsurf\n");
free(Buffer);
fclose ( fp );
//printf("IN SDL LOAD BMP retrun\n");
//printf("IN SDL LOAD BMP retrun\n");
return surf;
}

View File

@ -64,7 +64,6 @@ sys_printf(char *msg, ...)
va_start(argptr, msg);
vsprintf(s, msg, argptr);
va_end(argptr);
printf(s);
}
/*