10 Commits

Author SHA1 Message Date
Aaron Culliney
63b6e0a29a Fix my blended rendering on Tegra 2 (and arguably globally) 2015-11-07 10:36:20 -08:00
Aaron Culliney
f423c2dbe6 Work around broken Tegra 2 GPU 2015-11-06 22:18:16 -08:00
Aaron Culliney
dd7727f757 Simplify fragment shader and remove dead macro 2015-11-06 21:20:33 -08:00
Aaron Culliney
e9bae19e9e Bump Android version to 1.0.3 2015-11-04 21:15:12 -08:00
Aaron Culliney
bc96417091 DO NOT use API 23 yet ... we need to fix text relocations first!
- This prevents crashing on Marshmallow (for the time being)
2015-11-04 20:03:28 -08:00
Aaron Culliney
fb4d6f466b Splash screen is not dismissable during first time initialization or crash reporting 2015-11-03 22:47:35 -08:00
Aaron Culliney
a6ac111707 lightly refactor two-phase first-time launch 2015-11-03 22:42:24 -08:00
Aaron Culliney
d0319bd2ff Splash screen may be dismissable (or not) 2015-11-03 22:41:50 -08:00
Aaron Culliney
9b56050c1e All the Broken Adrenos! 2015-11-02 20:46:16 -08:00
Aaron Culliney
871762975a Bump Android version to 1.0.2 2015-11-01 22:03:39 -08:00
9 changed files with 138 additions and 75 deletions

View File

@@ -71,8 +71,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/21.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
@@ -88,10 +88,10 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-annotations-23.1.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.0" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.0" level="project" />
</component>
</module>

View File

@@ -1,7 +1,7 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
compileSdkVersion 21
buildToolsVersion "21.1.2"
signingConfigs {
release {
@@ -26,9 +26,9 @@ android {
defaultConfig {
applicationId "org.deadc0de.apple2ix.basic"
minSdkVersion 10
targetSdkVersion 23
versionCode 4
versionName "1.0.1"
targetSdkVersion 21
versionCode 6
versionName "1.0.3"
ndk {
moduleName "apple2ix"
}
@@ -37,5 +37,5 @@ android {
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:appcompat-v7:21.0.0'
}

View File

@@ -43,6 +43,7 @@ public class Apple2Activity extends Activity {
private static volatile boolean DEBUG_STRICT = false;
private Apple2View mView = null;
private Runnable mGraphicsInitializedRunnable = null;
private Apple2SplashScreen mSplashScreen = null;
private Apple2MainMenu mMainMenu = null;
private Apple2SettingsMenu mSettingsMenu = null;
@@ -147,12 +148,32 @@ public class Apple2Activity extends Activity {
String dataDir = Apple2DisksMenu.getDataDir(this);
nativeOnCreate(dataDir, sampleRate, monoBufferSize, stereoBufferSize);
showSplashScreen();
Apple2CrashHandler.getInstance().checkForCrashes(Apple2Activity.this);
final boolean firstTime = !Apple2Preferences.FIRST_TIME_CONFIGURED.booleanValue(this);
Apple2Preferences.FIRST_TIME_CONFIGURED.saveBoolean(this, true);
// first-time initializations #1
if (!Apple2Preferences.FIRST_TIME_CONFIGURED.booleanValue(this)) {
Apple2DisksMenu.firstTime(this);
showSplashScreen(!firstTime);
Apple2CrashHandler.getInstance().checkForCrashes(this);
mGraphicsInitializedRunnable = new Runnable() {
@Override
public void run() {
if (firstTime) {
Apple2Preferences.KeypadPreset.IJKM_SPACE.apply(Apple2Activity.this);
}
Apple2Preferences.loadPreferences(Apple2Activity.this);
}
};
// first-time initializations
if (firstTime) {
new Thread(new Runnable() {
@Override
public void run() {
Apple2DisksMenu.firstTime(Apple2Activity.this);
mSplashScreen.setDismissable(true);
Log.d(TAG, "Finished first time copying...");
}
}).start();
}
mSettingsMenu = new Apple2SettingsMenu(this);
@@ -180,8 +201,8 @@ public class Apple2Activity extends Activity {
}
Log.d(TAG, "onResume()");
showSplashScreen();
Apple2CrashHandler.getInstance().checkForCrashes(Apple2Activity.this); // NOTE : needs to be called again to clean-up
showSplashScreen(/*dismissable:*/true);
Apple2CrashHandler.getInstance().checkForCrashes(this); // NOTE : needs to be called again to clean-up
}
@Override
@@ -415,11 +436,15 @@ public class Apple2Activity extends Activity {
});
}
private void showSplashScreen() {
public Apple2SplashScreen getSplashScreen() {
return mSplashScreen;
}
private void showSplashScreen(boolean dismissable) {
if (mSplashScreen != null) {
return;
}
mSplashScreen = new Apple2SplashScreen(Apple2Activity.this);
mSplashScreen = new Apple2SplashScreen(this, dismissable);
mSplashScreen.show();
}
@@ -428,7 +453,8 @@ public class Apple2Activity extends Activity {
boolean glViewFirstTime = false;
if (mView == null) {
glViewFirstTime = true;
mView = new Apple2View(this);
mView = new Apple2View(this, mGraphicsInitializedRunnable);
mGraphicsInitializedRunnable = null;
mMainMenu = new Apple2MainMenu(this, mView);
}

View File

@@ -181,14 +181,12 @@ public class Apple2CrashHandler {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
final Button startButton = (Button) activity.findViewById(R.id.startButton);
final Button prefsButton = (Button) activity.findViewById(R.id.prefsButton);
final Button disksButton = (Button) activity.findViewById(R.id.disksButton);
final Apple2SplashScreen splashScreen = activity.getSplashScreen();
if (splashScreen != null) {
splashScreen.setDismissable(false);
}
final ProgressBar bar = (ProgressBar) activity.findViewById(R.id.crash_progressBar);
try {
startButton.setEnabled(false);
prefsButton.setEnabled(false);
disksButton.setEnabled(false);
bar.setVisibility(View.VISIBLE);
} catch (NullPointerException npe) {
/* could happen on early lifecycle crashes */
@@ -354,9 +352,7 @@ public class Apple2CrashHandler {
public void run() {
try {
bar.setVisibility(View.INVISIBLE);
startButton.setEnabled(true);
prefsButton.setEnabled(true);
disksButton.setEnabled(true);
splashScreen.setDismissable(true);
} catch (NullPointerException npe) {
/* could happen on early lifecycle crashes */
}

View File

@@ -30,6 +30,7 @@ import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import org.json.JSONArray;
@@ -135,6 +136,14 @@ public class Apple2DisksMenu implements Apple2MenuView {
}
public static void firstTime(Apple2Activity activity) {
final ProgressBar bar = (ProgressBar) activity.findViewById(R.id.crash_progressBar);
try {
bar.setVisibility(View.VISIBLE);
bar.setIndeterminate(true);
} catch (NullPointerException npe) {
Log.v(TAG, "Whoa, avoided NPE in first time #1");
}
getDataDir(activity);
Log.d(TAG, "First time copying stuff-n-things out of APK for ease-of-NDK access...");
@@ -149,6 +158,18 @@ public class Apple2DisksMenu implements Apple2MenuView {
if (sExternalFilesDir != null) {
recursivelyCopyAPKAssets(activity, /*from APK directory:*/"keyboards", /*to location:*/sExternalFilesDir.getAbsolutePath());
}
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
bar.setVisibility(View.INVISIBLE);
bar.setIndeterminate(false);
} catch (NullPointerException npe) {
Log.v(TAG, "Whoa, avoided NPE in first time #2");
}
}
});
}
public static void exposeSymbols(Apple2Activity activity) {

View File

@@ -23,11 +23,13 @@ public class Apple2SplashScreen implements Apple2MenuView {
private final static String TAG = "Apple2SplashScreen";
private Apple2Activity mActivity = null;
private boolean mDismissable = true;
private View mSettingsView = null;
public Apple2SplashScreen(Apple2Activity activity) {
public Apple2SplashScreen(Apple2Activity activity, boolean dismissable) {
mActivity = activity;
setup();
setDismissable(dismissable);
}
private void setup() {
@@ -61,6 +63,21 @@ public class Apple2SplashScreen implements Apple2MenuView {
});
}
public void setDismissable(boolean dismissable) {
mDismissable = dismissable;
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
Button startButton = (Button) mSettingsView.findViewById(R.id.startButton);
startButton.setEnabled(mDismissable);
Button prefsButton = (Button) mSettingsView.findViewById(R.id.prefsButton);
prefsButton.setEnabled(mDismissable);
Button disksButton = (Button) mSettingsView.findViewById(R.id.disksButton);
disksButton.setEnabled(mDismissable);
}
});
}
public final boolean isCalibrating() {
return false;
}
@@ -77,7 +94,9 @@ public class Apple2SplashScreen implements Apple2MenuView {
}
public void dismiss() {
mActivity.popApple2View(this);
if (mDismissable) {
mActivity.popApple2View(this);
}
}
public void dismissAll() {

View File

@@ -22,8 +22,6 @@ import android.opengl.GLSurfaceView;
import android.util.Log;
import android.view.ViewTreeObserver;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
@@ -53,7 +51,7 @@ class Apple2View extends GLSurfaceView {
private final static boolean DEBUG = false;
private Apple2Activity mActivity = null;
private AtomicBoolean mInitialLaunch = new AtomicBoolean(true);
private Runnable mGraphicsInitializedRunnable = null;
private static native void nativeGraphicsInitialized(int width, int height);
@@ -61,9 +59,10 @@ class Apple2View extends GLSurfaceView {
private static native void nativeRender();
public Apple2View(Apple2Activity activity) {
public Apple2View(Apple2Activity activity, Runnable graphicsInitializedRunnable) {
super(activity.getApplication());
mActivity = activity;
mGraphicsInitializedRunnable = graphicsInitializedRunnable;
/* By default, GLSurfaceView() creates a RGB_565 opaque surface.
* If we want a translucent one, we should change the surface's
@@ -347,16 +346,9 @@ class Apple2View extends GLSurfaceView {
nativeGraphicsInitialized(width, height);
// first-time initializations #2
if (!Apple2Preferences.FIRST_TIME_CONFIGURED.booleanValue(Apple2View.this.mActivity)) {
Apple2Preferences.KeypadPreset.IJKM_SPACE.apply(Apple2View.this.mActivity);
Apple2Preferences.FIRST_TIME_CONFIGURED.saveBoolean(Apple2View.this.mActivity, true);
}
// load preferences on each new process creation
if (mInitialLaunch.get()) {
mInitialLaunch.set(false);
Apple2Preferences.loadPreferences(Apple2View.this.mActivity);
if (Apple2View.this.mGraphicsInitializedRunnable != null) {
Apple2View.this.mGraphicsInitializedRunnable.run();
Apple2View.this.mGraphicsInitializedRunnable = null;
}
Apple2View.this.mActivity.maybeResumeCPU();

View File

@@ -24,18 +24,12 @@ uniform float aValue;
uniform sampler2D texture;
#if __VERSION__ >= 140
#define OUTPUT_TEXTURE(TEX) \
vec4 tex = texture(TEX, varTexcoord.st, 0.0); \
fragColor = vec4(tex.r, tex.g, tex.b, tex.a*aValue)
#define OUTPUT_RED() \
fragColor = vec4(1.0, 0.0, 0.0, 1.0)
#define OUTPUT_TEXTURE(TEX) vec4 tex = texture(TEX, varTexcoord.st, 0.0); fragColor = vec4(tex.r, tex.g, tex.b, tex.a*aValue)
#else
#define OUTPUT_TEXTURE(TEX) vec4 tex = texture2D(TEX, varTexcoord.st, 0.0); gl_FragColor = vec4(tex.r, tex.g, tex.b, tex.a*aValue)
#define OUTPUT_RED() gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0)
#endif
void main(void)
{
OUTPUT_TEXTURE(texture);
//OUTPUT_RED(); -- WTF is this failing?
}

View File

@@ -46,6 +46,9 @@ static GLuint texcoordBufferName = UNINITIALIZED_GL;
static GLuint elementBufferName = UNINITIALIZED_GL;
static GLModel *crtModel = NULL;
static GLuint vertexShader = UNINITIALIZED_GL;
static GLuint fragShader = UNINITIALIZED_GL;
static video_backend_s glvideo_backend = { 0 };
#if USE_GLUT
@@ -323,7 +326,7 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc
sprintf(sourceString, "%s", vertexSource->string);
}
GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
vertexShader = glCreateShader(GL_VERTEX_SHADER);
glShaderSource(vertexShader, 1, (const GLchar **)&(sourceString), NULL);
glCompileShader(vertexShader);
glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &logLength);
@@ -362,7 +365,7 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc
sprintf(sourceString, "%s", fragmentSource->string);
}
GLuint fragShader = glCreateShader(GL_FRAGMENT_SHADER);
fragShader = glCreateShader(GL_FRAGMENT_SHADER);
glShaderSource(fragShader, 1, (const GLchar **)&(sourceString), NULL);
glCompileShader(fragShader);
glGetShaderiv(fragShader, GL_INFO_LOG_LENGTH, &logLength);
@@ -398,17 +401,6 @@ static GLuint _build_program(demoSource *vertexSource, demoSource *fragmentSourc
free(log);
}
glDetachShader(prgName, vertexShader);
glDetachShader(prgName, fragShader);
// Delete the vertex shader since it is now attached and linked
// to the program, which will retain a reference to it
glDeleteShader(vertexShader);
// Delete the fragment shader since it is now attached and linked
// to the program, which will retain a reference to it
glDeleteShader(fragShader);
glGetProgramiv(prgName, GL_LINK_STATUS, &status);
if (status == 0) {
LOG("Failed to link program");
@@ -551,10 +543,19 @@ static void _gldriver_setup_hackarounds(void) {
break;
}
regex_t twoHundredXXRegex = { 0 };
err = regcomp(&twoHundredXXRegex, "2[2-9][0-9]", REG_ICASE|REG_NOSUB|REG_EXTENDED);
if (err) {
LOG("Cannot compile regex : %d", err);
break;
}
int found200 = !regexec(&twoHundredRegex, renderer, /*nmatch:*/0, /*pmatch:*/NULL, /*eflags:*/0);
int found205 = !regexec(&twoHundredFiveRegex, renderer, /*nmatch:*/0, /*pmatch:*/NULL, /*eflags:*/0);
int found2XX = !regexec(&twoHundredXXRegex, renderer, /*nmatch:*/0, /*pmatch:*/NULL, /*eflags:*/0);
regfree(&twoHundredRegex);
regfree(&twoHundredFiveRegex);
regfree(&twoHundredXXRegex);
if (found200) {
LOG("HACKING AROUND BROKEN ADRENO 200");
@@ -567,6 +568,11 @@ static void _gldriver_setup_hackarounds(void) {
hackAroundBrokenAdreno205 = true;
break;
}
if (found2XX) {
LOG("HACKING AROUND BROKEN ADRENO 2XX");
hackAroundBrokenAdreno200 = true;
break;
}
} while (0);
}
@@ -627,15 +633,13 @@ static void gldriver_init_common(void) {
// ----------------------------
// setup static OpenGL state
// Depth test will always be enabled
glEnable(GL_DEPTH_TEST);
// We will always cull back faces for better performance
glEnable(GL_CULL_FACE);
// Always use this clear color
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Set up to do blending of texture quads. Disabling DEPTH/CULL appears to fix blended quad/texture rendering on
// finicky Tegra 2. This generally appears to be the correct way to do it accoring to NVIDIA forums and:
// http://www.learnopengles.com/android-lesson-five-an-introduction-to-blending/
glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -673,6 +677,17 @@ static void _gldriver_shutdown(void) {
mdlDestroyModel(&crtModel);
// detach and delete the main shaders
// 2015/11/06 NOTE : Tegra 2 for mobile has a bug whereby you cannot detach/delete shaders immediately after
// creating the program. So we delete them during the shutdown sequence instead.
// https://code.google.com/p/android/issues/detail?id=61832
glDetachShader(mainShaderProgram, vertexShader);
glDetachShader(mainShaderProgram, fragShader);
glDeleteShader(vertexShader);
glDeleteShader(fragShader);
vertexShader = UNINITIALIZED_GL;
fragShader = UNINITIALIZED_GL;
glUseProgram(0);
if (mainShaderProgram != UNINITIALIZED_GL) {
glDeleteProgram(mainShaderProgram);
@@ -735,7 +750,7 @@ static void gldriver_render(void) {
return;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT);
#if MOBILE_DEVICE
glViewport(viewportX, viewportY, viewportWidth, viewportHeight);
#endif
@@ -889,7 +904,7 @@ static void gldriver_reshape(int w, int h) {
#if USE_GLUT
static void gldriver_init_glut(GLuint fbo) {
glutInit(&argc, argv);
glutInitDisplayMode(/*GLUT_DOUBLE|*/GLUT_RGBA|GLUT_DEPTH);
glutInitDisplayMode(/*GLUT_DOUBLE|*/GLUT_RGBA);
glutInitWindowSize(windowWidth, windowHeight);
//glutInitContextVersion(4, 0); -- Is this needed?
glutInitContextProfile(GLUT_CORE_PROFILE);