LIB=$ROOT/external/lib
BIN=$ROOT/bin
-CXXFLAGS="`pkg-config sdl2 --cflags` `pkg-config SDL2_mixer --cflags` `pkg-config SDL2_image --cflags` `pkg-config SDL2_ttf --cflags`"
+CXXFLAGS="-g `pkg-config sdl2 --cflags` `pkg-config SDL2_mixer --cflags` `pkg-config SDL2_image --cflags` `pkg-config SDL2_ttf --cflags`"
LDFLAGS="`pkg-config sdl2 --libs` `pkg-config SDL2_image --libs` `pkg-config SDL2_ttf --libs` `pkg-config SDL2_mixer --libs`"
INCLUDE="-I$ROOT/external/zero/include -I$ROOT/vndc/include"
com.gamemaker.game
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.github.chaoskagami.vnds"
+ package="com.github.chaoskagami.vndc"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto">
<activity android:name="VNDCActivity"
android:label="@string/app_name"
android:configChanges="keyboardHidden|orientation"
+ android:screenOrientation="landscape"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</application>
<!-- Android 2.3.3 -->
- <uses-sdk android:minSdkVersion="12" android:targetSdkVersion="12" />
+ <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="12" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />
Data.cpp \
Loop.cpp \
Parse.cpp \
-VNDC.cpp \
AudioManager.cpp \
ContextManager.cpp \
TextManager.cpp \
-UDisplayable.cpp
-
-
+UDisplayable.cpp \
+../SDL/src/main/android/SDL_android_main.c \
+VNDC.cpp
LOCAL_SHARED_LIBRARIES := SDL2 SDL2_mixer SDL2_ttf SDL2_image
#include <windows.h>
#endif
+#include <gitrev.hpp>
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <SDL_mixer.h>
#include <SDL_ttf.h>
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ #define RED_MASK 0xff000000
+ #define GREEN_MASK 0x00ff0000
+ #define BLUE_MASK 0x0000ff00
+ #define ALPHA_MASK 0x000000ff
+#else
+ #define RED_MASK 0x000000ff
+ #define GREEN_MASK 0x0000ff00
+ #define BLUE_MASK 0x00ff0000
+ #define ALPHA_MASK 0xff000000
+#endif
+
#include "AudioManager.hpp"
#include "ContextManager.hpp"
#include "TextManager.hpp"
}
else {
_InitWindowSW(width, height, fulls);
- this->surface_o = SDL_CreateRGBSurface(0, width, height, 32, 0, 0, 0, 0);
+ this->surface_o = SDL_CreateRGBSurface(0, width, height, 32, RED_MASK, GREEN_MASK, BLUE_MASK, ALPHA_MASK);
+ SDL_SetSurfaceBlendMode(this->surface_o, SDL_BLENDMODE_BLEND);
}
txtMgr = new TextManager(this);
void ContextManager::_InitWindowSW(int width, int height, bool fulls) {
// Add title setting function.
- this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN);
+ if(!fulls)
+ this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN);
+ else
+ this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_FULLSCREEN);
if(this->window == NULL) {
fprintf(stderr, "[E] Error creating window. Info:\n");
fprintf(stderr, "[E] %s\n", SDL_GetError());
}
else {
SDL_SetHintWithPriority(SDL_HINT_RENDER_VSYNC, "1", SDL_HINT_OVERRIDE);
- if(!SDL_CreateRenderer( this->window, -1, SDL_RENDERER_ACCELERATED )) {
+ if(!SDL_CreateRenderer( this->window, -1, 0 )) {
fprintf(stderr, "[E] Error creating renderer. Info:\n");
fprintf(stderr, "[E] %s\n", SDL_GetError());
fprintf(stderr, "[E] This is fatal. Dying.");
exit(-1);
}
+
+ this->logicalRender = false;
}
}
void ContextManager::_InitWindowAC(int width, int height, bool fulls) {
this->accelerate = true;
- this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN);
+ if(!fulls)
+ this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_SHOWN);
+ else
+ this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, SDL_WINDOW_FULLSCREEN);
if(this->window == NULL) {
fprintf(stderr, "[E] Error creating window. Info:\n");
fprintf(stderr, "[E] %s\n", SDL_GetError());
}
else {
_InitWindowLogicalSW(width_win, height_win, width_log, height_log, fulls);
- this->surface_o = SDL_CreateRGBSurface(0, width_win, height_win, 32, 0, 0, 0, 0);
+ this->surface_o = SDL_CreateRGBSurface(0, width_win, height_win, 32, RED_MASK, GREEN_MASK, BLUE_MASK, ALPHA_MASK);
+ SDL_SetSurfaceBlendMode(this->surface_o, SDL_BLENDMODE_BLEND);
}
txtMgr = new TextManager(this);
// Init window with a logical size and a real one.
void ContextManager::_InitWindowLogicalSW(int width_win, int height_win, int width_log, int height_log, bool fulls) {
- this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width_win, height_win, SDL_WINDOW_SHOWN);
+ if(!fulls)
+ this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width_win, height_win, SDL_WINDOW_SHOWN);
+ else
+ this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width_win, height_win, SDL_WINDOW_FULLSCREEN);
if(this->window == NULL) {
fprintf(stderr, "[E] Error creating window. Info:\n");
fprintf(stderr, "[E] %s\n", SDL_GetError());
exit(-1);
}
else {
- this->renderer = SDL_CreateRenderer( this->window, -1, SDL_RENDERER_ACCELERATED );
+ this->renderer = SDL_CreateRenderer( this->window, -1, 0 );
if(this->renderer == NULL) {
fprintf(stderr, "[E] Error creating renderer. Info:\n");
fprintf(stderr, "[E] %s\n", SDL_GetError());
else {
this->logicalRender = true;
- this->surface = SDL_CreateRGBSurface(0, width_log, height_log, 32, 0, 0, 0, 0);
+ this->surface = SDL_CreateRGBSurface(0, width_log, height_log, 32, RED_MASK, GREEN_MASK, BLUE_MASK, ALPHA_MASK);
}
}
}
// Init window with a logical size and a real one.
void ContextManager::_InitWindowLogicalAC(int width_win, int height_win, int width_log, int height_log, bool fulls) {
this->accelerate = true;
-
- this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width_win, height_win, SDL_WINDOW_SHOWN);
+ if(!fulls)
+ this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width_win, height_win, SDL_WINDOW_SHOWN);
+ else
+ this->window = SDL_CreateWindow("Zero", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width_win, height_win, SDL_WINDOW_FULLSCREEN);
if(this->window == NULL) {
fprintf(stderr, "[E] Error creating window. Info:\n");
fprintf(stderr, "[E] %s\n", SDL_GetError());
else {
if (logicalRender)
SDL_FillRect(this->surface, NULL, SDL_MapRGB(this->surface->format, 0x0, 0x0, 0x0));
- SDL_FillRect(this->surface_o, NULL, SDL_MapRGB(this->surface_o->format, 0x0, 0x0, 0x0));
+
+ SDL_FillRect(this->surface_o, NULL, SDL_MapRGBA(this->surface_o->format, 0x0, 0x0, 0x0, 0x0));
SDL_FillRect(SDL_GetWindowSurface(this->window), NULL, SDL_MapRGB(SDL_GetWindowSurface(this->window)->format, 0x0, 0x0, 0x0));
}
SDL_SetRenderTarget(renderer, NULL);
}
else {
- SDL_FillRect(this->surface_o, NULL, SDL_MapRGB(this->surface_o->format, 0x0, 0x0, 0x0));
+ SDL_FillRect(this->surface_o, NULL, SDL_MapRGBA(this->surface_o->format, 0, 0, 0, 0));
}
}
TTF_SetFontOutline(fonts[current_font], 0);
}
- SDL_Texture *tmp1 = NULL, *tmp2 = NULL;
-
- tmp1 = SDL_CreateTextureFromSurface(ctx->Renderer(), sf1);
- if(outline)
- tmp2 = SDL_CreateTextureFromSurface(ctx->Renderer(), sf2);
-
SDL_Rect src, dst, src2, dst2;
src.x = 0;
src.y = 0;
dst2.y = y - (outline_px);
dst2.w = src2.w;
dst2.h = src2.h;
- SDL_FreeSurface(sf2);
+ }
+
+ if(ctx->Accelerated()) {
+ SDL_Texture *tmp1 = NULL, *tmp2 = NULL;
+
+ tmp1 = SDL_CreateTextureFromSurface(ctx->Renderer(), sf1);
+ if(outline)
+ tmp2 = SDL_CreateTextureFromSurface(ctx->Renderer(), sf2);
+
ctx->OverlayBlit(tmp2, &src2, &dst2);
+ ctx->OverlayBlit(tmp1, &src, &dst);
+
SDL_DestroyTexture(tmp2);
+ SDL_DestroyTexture(tmp1);
+
+ }
+ else {
+ ctx->OverlayBlit(sf2, &src, &dst);
+ ctx->OverlayBlit(sf1, &src, &dst);
}
+ SDL_FreeSurface(sf2);
SDL_FreeSurface(sf1);
- ctx->OverlayBlit(tmp1, &src, &dst);
- SDL_DestroyTexture(tmp1);
+
}
// Sets the Displayable's mode.
UDisplayable::UDisplayable(ContextManager* cx, UDisplayableMode mode, char* fname) {
- UDisplayable(cx, fname);
+ // UDisplayable(cx, fname);
+
+
+ DefaultVars();
+
+ SDL_Surface* bitmap_tmp = IMG_Load(fname);
+
+ if(!bitmap_tmp) {
+ printf("[UDisplayable::Ctor] File could not be loaded, this->Error set.\n");
+ Error = true;
+ }
+ else {
+ this->x = 0;
+ this->y = 0;
+ this->loc.x = 0;
+ this->loc.y = 0;
+ this->ctx = cx;
+ this->frameWidth = bitmap_tmp->w;
+ this->bmp_w = bitmap_tmp->w;
+ this->bmp_h = bitmap_tmp->h;
+
+ // We still allocate the two arrays, regardless.
+
+ // These values are unused, but we'll default them so it will operate normally.
+ hitbox = (int*)calloc(sizeof(int), 4);
+
+ // By default, it will fill this with 0, 0, W, H.
+ // This will behave identically to a displayable.
+ hitbox[0] = 0;
+ hitbox[1] = 0;
+ hitbox[2] = bitmap_tmp->w;
+ hitbox[3] = bitmap_tmp->h;
+
+ this->loc.w = bitmap_tmp->w;
+ this->loc.h = bitmap_tmp->w;
+
+ frame = (int*)calloc(sizeof(int), 4);
+
+ frame[0] = 0;
+ frame[1] = 0;
+ frame[2] = cx->GetWidth();
+ frame[3] = cx->GetHeight();
+
+ // Determine if we're on an accelerated context. If so, we create a texture out of the bitmap.
+ // Then we store what we'll use to the void* bitmap, either Tex or Surf.
+
+ if (cx->Accelerated()) {
+ SDL_Texture* tex = SDL_CreateTextureFromSurface(ctx->Renderer(), bitmap_tmp);
+ this->bitmap = (void*)tex;
+ SDL_FreeSurface(bitmap_tmp);
+ }
+ else {
+ this->bitmap = (void*)bitmap_tmp;
+ }
+ }
+ #ifdef DEBUG_OVERKILL
+ printf("[UDisplayable~Ctor] accel:%d\n", cx->Accelerated());
+ #endif
+
this->dispMode = mode;
}
printf("[UDisplayable::Blit]\n");
#endif
+ SDL_Rect src;
+ src.x = 0;
+ src.y = 0;
+ src.w = frameWidth;
+ src.h = bmp_h;
+
if (frameIndex == -1) {
- ctx->Blit(bitmap, NULL, &loc_adj);
+ ctx->Blit(bitmap, &src, &loc_adj);
return;
}
bool verbose;
int currentLine;
bool skip_key_on;
+ bool sw_rendering;
bool eof;
char* window_name;
char* next_line; // Used for voice-detect.
#include "gitrev.hpp"
-// No output capabilities.
-#ifdef WITH_ANDROID
-# define printf(...)
-#endif
-
#include "Data.hpp"
void Parse(); // This reads commands from files.
#ifndef GIT_REV_HDR
#define GIT_REV_HDR
-#define GIT_REV "c7ef31d2ee1c2c24b2c76369d203ac024dfae5f9"
+#define GIT_REV "456cf80a21b450122572c15584e45b8d502cab45"
#endif
verbose = false;
currentLine = 0;
skip_key_on = false;
+ #ifdef USE_ANDROID
+ sw_rendering = true;
+ #else
+ sw_rendering = false;
+ #endif
eof = false;
next_line = NULL; // Used for voice-detect.
// It's impossible to parse without lookahead.
void Setup() {
// Init window
- GetData()->ctx->InitWindowLogical(GetData()->physical_w, GetData()->physical_h, GetData()->screen_w, GetData()->screen_h, false, true);
+ GetData()->ctx->InitWindowLogical(GetData()->physical_w, GetData()->physical_h, GetData()->screen_w, GetData()->screen_h, false, !(GetData()->sw_rendering));
GetData()->window_name = (char*)calloc(sizeof(char), 400);
sprintf(GetData()->window_name, "%s", "VNDC Interpreter ");
bool enable_v = false;
bool newgame = false;
char c;
+ #ifdef USE_ANDROID
+ bool software = true;
+ #else
+ bool software = false;
+ #endif
- while((c = getopt(argc, argv, "nbvx:y:d:m:s:ch")) != -1) {
+ while((c = getopt(argc, argv, "wnbvx:y:d:m:s:ch")) != -1) {
switch(c) {
+ case 'w':
+ #ifdef USE_ANDROID
+ printf("[info] Forcing Hardware Acceleration.\n");
+ #else
+ printf("[info] Utilizing Software Rendering.\n");
+ #endif
+ software = !software;
+ break;
case 'n':
printf("[info] New game, not reloading save.\n");
- newgame = true;
+ newgame = true;
+ break;
case 'v':
printf("[info] Script commands will be echoed.\n");
enable_v = true;
break;
case 'h':
printf("-x size -y size\tStretch display window to WxH\n");
+ printf("-w\t\tUse Software Rendering (on android: force HW render)\n");
printf("-n\t\tNew Game. Do not reload default save.\n");
printf("-d dir\t\tChange to directory/Run game in directory\n");
printf("-b\t\tDebug Mode. Hit Ctrl+C on console for shell\n");
}
GetData()->vndc_enabled = vndc_extensions;
GetData()->verbose = enable_v;
+ GetData()->sw_rendering = software;
if(debug_enable) {
signal(SIGINT, DebugTrap);
GetData()->debug_mode = true;
//printf("Attempt to load file %s as BG\n", path);
// Load displayable.
- SDL_Surface* sfc = IMG_Load(GetData()->current_bg);
+
+ UDisplayable* disp = new UDisplayable(GetData()->ctx, GetData()->current_bg);
+
+ // SDL_Surface* sfc = IMG_Load(GetData()->current_bg);
uint8_t transp_incr = 16;
if(fadetime != NULL)
// Transition effect.
- SDL_Texture* tx = NULL;
- tx = SDL_CreateTextureFromSurface(GetData()->ctx->Renderer(), sfc);
- SDL_SetTextureBlendMode(tx, SDL_BLENDMODE_BLEND);
+ // SDL_Texture* tx = NULL;
+ // tx = SDL_CreateTextureFromSurface(GetData()->ctx->Renderer(), sfc);
+ // SDL_SetTextureBlendMode(tx, SDL_BLENDMODE_BLEND);
- SDL_FreeSurface(sfc);
+ // SDL_FreeSurface(sfc);
int delay = 1;
- for(int tr = 0; tr < 255; tr += transp_incr) {
- SDL_SetTextureAlphaMod(tx, tr);
- GetData()->ctx->Blit(tx, NULL, NULL);
+ for(int tr = 0; tr < 255; tr += transp_incr) {
+ disp->Blit();
op_delay(&delay);
}
- SDL_DestroyTexture(tx);
+// SDL_DestroyTexture(tx);
}
int width_dr = (GetData()->render_x2 - GetData()->render_x1 + 20);
int height_dr = (GetData()->render_y2 - GetData()->render_y1 + 30 + 20);
- SDL_Surface* sfc = SDL_CreateRGBSurface(0, width_dr, height_dr, 32, 0, 0, 0, 0);
- SDL_FillRect(sfc, NULL, SDL_MapRGBA(sfc->format, 0, 0, 0, 128));
+ // if(! GetData()->ctx->Accelerated()) return;
+ SDL_Surface* sfc = SDL_CreateRGBSurface(0, width_dr, height_dr, 32, RED_MASK, GREEN_MASK, BLUE_MASK, ALPHA_MASK);
+ SDL_FillRect(sfc, NULL, SDL_MapRGBA(sfc->format, 0, 0, 0, 100));
+ if(!GetData()->ctx->Accelerated()) {
+ }
SDL_Rect src;
src.x = 0;
src.w = sfc->w;
src.h = sfc->h;
- SDL_Texture* dim = SDL_CreateTextureFromSurface(GetData()->ctx->Renderer(), sfc);
- SDL_SetTextureBlendMode(dim, SDL_BLENDMODE_BLEND);
- SDL_SetTextureAlphaMod(dim, 128);
-
- SDL_FreeSurface(sfc);
-
SDL_Rect dst;
dst.x = GetData()->render_x1 - 10;
dst.y = GetData()->render_y1 - 10;
dst.w = src.w;
dst.h = src.h;
- GetData()->ctx->OverlayBlit(dim, &src, &dst);
+ if(GetData()->ctx->Accelerated()) {
+ SDL_Texture* dim = SDL_CreateTextureFromSurface(GetData()->ctx->Renderer(), sfc);
+ //SDL_SetTextureBlendMode(dim, SDL_BLENDMODE_BLEND);
+ //SDL_SetTextureAlphaMod(dim, 128);
+
+ GetData()->ctx->OverlayBlit(dim, &src, &dst);
+
+ SDL_DestroyTexture(dim);
+ }
+ else {
+ GetData()->ctx->OverlayBlit(sfc, &src, &dst);
+ }
+
+ SDL_FreeSurface(sfc);
- SDL_DestroyTexture(dim);
}
/*