- Change the way to refresh the overlapping LCD.

This commit is contained in:
dgis 2019-08-13 21:01:45 +02:00
parent 2463b91d7e
commit f9199a03ed
6 changed files with 30 additions and 111 deletions

View file

@ -58,7 +58,7 @@ Version 1.7 (2019-08-XX)
- Allow to take a screenshot of the fullscreen including the skin. - Allow to take a screenshot of the fullscreen including the skin.
- Add the KML Icon if present in the navigation menu header (only support PNG or 32bits BMP in the ICO file). - Add the KML Icon if present in the navigation menu header (only support PNG or 32bits BMP in the ICO file).
- Allow an optional overlapping LCD part stuck to the screen when swiping the 2 calc parts. - Add an optional overlapping LCD part stuck to the screen when swiping the 2 calc parts (Experimental).
Version 1.6 (2019-07-15) Version 1.6 (2019-07-15)
@ -165,16 +165,14 @@ The Eric's Real scripts ("real*.kml" and "real*.bmp/png") are embedded in this a
TODO TODO
- Retain a key by right clicking if it is from a mouse.
- Add the name of the file in the toast "State saved". - Add the name of the file in the toast "State saved".
- Add the KML icon in the navigation menu header. - The clock seems unsynchronized sometimes.
- Retain a key by right clicking if it is from a mouse.
- Add the possibility to load and save the flash in another file. - Add the possibility to load and save the flash in another file.
- Add the possibility to deactivate the zoom.
- Sometimes, the calculator seems to lag and finally freeze. - Sometimes, the calculator seems to lag and finally freeze.
- In Chrome OS: - In Chrome OS:
- The timezone seems to be GMT (localtime_r not right?)! - The timezone seems to be GMT (localtime_r not right?)!
- sometimes there is no OK button in the KML Script Compilation Result. - sometimes there is no OK button in the KML Script Compilation Result.
- The clock seems unsynchronized sometimes.
- Add KML script loading dependencies fallback to the inner ROM (and may be KML include?). - Add KML script loading dependencies fallback to the inner ROM (and may be KML include?).
- Add a separation between the pixels (Suggestion from Jaime Meza). - Add a separation between the pixels (Suggestion from Jaime Meza).

View file

@ -424,87 +424,6 @@ JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_changeBitmap(JNIEn
} }
} }
JNIEXPORT jboolean JNICALL Java_org_emulator_calculator_NativeLib_copyLCD(JNIEnv *env, jobject thisz, jobject bitmapLCD) {
if(!bitmapLCD)
return JNI_FALSE;
AndroidBitmapInfo bitmapLCDInfo;
int ret = AndroidBitmap_getInfo(env, bitmapLCD, &bitmapLCDInfo);
if (ret < 0) {
LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
return JNI_FALSE;
}
// INT nxSize, nySize;
// GetSizeLcdBitmap(&nxSize,&nySize); // get LCD size
void *pixelsDestination;
if ((ret = AndroidBitmap_lockPixels(env, bitmapLCD, &pixelsDestination)) < 0) {
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
return JNI_FALSE;
}
if(hLcdDC && hLcdDC->selectedBitmap) {
HBITMAP hBitmapSource = hLcdDC->selectedBitmap;
void * pixelsSource = (void *) hBitmapSource->bitmapBits;
BOOL reverseHeight = hBitmapSource->bitmapInfoHeader->biHeight < 0;
int sourceWidth = hBitmapSource->bitmapInfoHeader->biWidth;
int sourceHeight = abs(hBitmapSource->bitmapInfoHeader->biHeight); // Can be < 0
UINT sourceBitCount = hBitmapSource->bitmapInfoHeader->biBitCount;
int sourceStride = 4 * ((sourceWidth * hBitmapSource->bitmapInfoHeader->biBitCount + 31) / 32);
HPALETTE palette = hLcdDC->realizedPalette;
if(!palette)
palette = hLcdDC->selectedPalette;
PALETTEENTRY * palPalEntry = palette && palette->paletteLog && palette->paletteLog->palPalEntry ?
palette->paletteLog->palPalEntry : NULL;
if(!palPalEntry && sourceBitCount <= 8 && hBitmapSource->bitmapInfoHeader->biClrUsed > 0)
palPalEntry = (PALETTEENTRY *)hBitmapSource->bitmapInfo->bmiColors;
int destinationWidth = bitmapLCDInfo.width;
int destinationHeight = bitmapLCDInfo.height;
int destinationBitCount = 32;
int destinationStride = bitmapLCDInfo.stride;
EnterCriticalSection(&csGDILock); // solving NT GDI problems
UINT nLines = MAINSCREENHEIGHT;
// copy header display area
StretchBltInternal(0, 0, 131*nLcdZoom*nGdiXZoom, Chipset.d0size*nLcdZoom*nGdiYZoom, pixelsDestination, destinationBitCount,
destinationStride, destinationWidth, destinationHeight,
Chipset.d0offset, 0, 131, Chipset.d0size, pixelsSource, sourceBitCount,
sourceStride, sourceWidth, sourceHeight,
SRCCOPY, reverseHeight, palPalEntry, 0, 0);
// copy main display area
StretchBltInternal(0, Chipset.d0size*nLcdZoom*nGdiYZoom, 131*nLcdZoom*nGdiXZoom, nLines*nLcdZoom*nGdiYZoom, pixelsDestination, destinationBitCount,
destinationStride, destinationWidth, destinationHeight,
Chipset.boffset, Chipset.d0size, 131, nLines, pixelsSource, sourceBitCount,
sourceStride, sourceWidth, sourceHeight,
SRCCOPY, reverseHeight, palPalEntry, 0, 0);
// copy menu display area
StretchBltInternal(0, (nLines+Chipset.d0size)*nLcdZoom*nGdiYZoom, 131*nLcdZoom*nGdiXZoom, MENUHEIGHT*nLcdZoom*nGdiYZoom, pixelsDestination, destinationBitCount,
destinationStride, destinationWidth, destinationHeight,
0, (nLines+Chipset.d0size), 131, MENUHEIGHT, pixelsSource, sourceBitCount,
sourceStride, sourceWidth, sourceHeight,
SRCCOPY, reverseHeight, palPalEntry, 0, 0);
LeaveCriticalSection(&csGDILock);
AndroidBitmap_unlockPixels(env, bitmapLCD);
return JNI_TRUE;
}
return JNI_FALSE;
}
JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_draw(JNIEnv *env, jobject thisz) { JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_draw(JNIEnv *env, jobject thisz) {
draw(); draw();
} }

View file

@ -1592,15 +1592,6 @@ BOOL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl) {
} }
BOOL SetWindowPlacement(HWND hWnd, CONST WINDOWPLACEMENT *lpwndpl) { return 0; } BOOL SetWindowPlacement(HWND hWnd, CONST WINDOWPLACEMENT *lpwndpl) { return 0; }
extern void draw(); extern void draw();
void StretchBltInternal(int xDest, int yDest, int wDest, int hDest, const void *pixelsDestination,
int destinationBitCount, int destinationStride, int destinationWidth,
int destinationHeight, int xSrc, int ySrc, int hSrc, int wSrc,
const void *pixelsSource, UINT sourceBitCount, int sourceStride,
int sourceWidth, int sourceHeight, DWORD rop, BOOL reverseHeight,
const PALETTEENTRY *palPalEntry, COLORREF brushColor,
COLORREF backgroundColor);
BOOL InvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase) { BOOL InvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase) {
// Update when switch the screen off // Update when switch the screen off
draw(); //TODO Need a true WM_PAINT event! draw(); //TODO Need a true WM_PAINT event!

View file

@ -174,16 +174,11 @@ public class LCDOverlappingView extends View {
canvas.drawColor(Color.RED); //TODO to remove canvas.drawColor(Color.RED); //TODO to remove
if(this.overlappingLCDMode > 0 && bitmapLCD != null) { if(this.overlappingLCDMode > 0 && bitmapLCD != null) {
canvas.save(); int x = NativeLib.getScreenPositionX();
if (bitmapLCD.getWidth() > 0 && bitmapLCD.getHeight() > 0) int y = NativeLib.getScreenPositionY();
canvas.scale((float) getWidth() / (float) bitmapLCD.getWidth(), (float) getHeight() / (float) bitmapLCD.getHeight()); srcBitmapCopy.set(x, y, x + NativeLib.getScreenWidth(), y + NativeLib.getScreenHeight());
canvas.drawBitmap(bitmapLCD, 0, 0, paint); dstBitmapCopy.set(0, 0, getWidth(), getHeight());
canvas.restore(); canvas.drawBitmap(mainScreenView.getBitmap(), srcBitmapCopy, dstBitmapCopy, paint);
// int x = NativeLib.getScreenPositionX();
// int y = NativeLib.getScreenPositionY();
// srcBitmapCopy.set(x, y, x + NativeLib.getScreenWidth(), y + NativeLib.getScreenHeight());
// dstBitmapCopy.set(0, 0, getWidth(), getHeight());
// canvas.drawBitmap(mainScreenView.getBitmap(), srcBitmapCopy, dstBitmapCopy, paint);
} }
} }
@ -194,10 +189,8 @@ public class LCDOverlappingView extends View {
case NativeLib.CALLBACK_TYPE_INVALIDATE: case NativeLib.CALLBACK_TYPE_INVALIDATE:
//if(debug) Log.d(TAG, "PAINT updateCallback() postInvalidate()"); //if(debug) Log.d(TAG, "PAINT updateCallback() postInvalidate()");
if(debug) Log.d(TAG, "updateCallback() CALLBACK_TYPE_INVALIDATE"); if(debug) Log.d(TAG, "updateCallback() CALLBACK_TYPE_INVALIDATE");
if(bitmapLCD.getWidth() > 1) { if(bitmapLCD.getWidth() > 1)
NativeLib.copyLCD(bitmapLCD);
postInvalidate(); postInvalidate();
}
break; break;
case NativeLib.CALLBACK_TYPE_WINDOW_RESIZE: case NativeLib.CALLBACK_TYPE_WINDOW_RESIZE:
// New Bitmap size // New Bitmap size

View file

@ -30,7 +30,6 @@ public class NativeLib {
public static native void start(AssetManager mgr, Activity activity); public static native void start(AssetManager mgr, Activity activity);
public static native void stop(); public static native void stop();
public static native void changeBitmap(Bitmap bitmapMainScreen); public static native void changeBitmap(Bitmap bitmapMainScreen);
public static native boolean copyLCD(Bitmap bitmapLCD);
public static native void draw(); public static native void draw();
public static native boolean buttonDown(int x, int y); public static native boolean buttonDown(int x, int y);
public static native void buttonUp(int x, int y); public static native void buttonUp(int x, int y);

View file

@ -24,6 +24,8 @@ import android.content.SharedPreferences;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -1478,16 +1480,33 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
bitmapIcon.copyPixelsFromBuffer(buffer); bitmapIcon.copyPixelsFromBuffer(buffer);
} catch (Exception ex) { } catch (Exception ex) {
// Cannot load the icon // Cannot load the icon
bitmapIcon.recycle(); // bitmapIcon.recycle();
bitmapIcon = null; bitmapIcon = null;
} }
} else if(bitmapIcon != null) { } else if(bitmapIcon != null) {
bitmapIcon.recycle(); // bitmapIcon.recycle();
bitmapIcon = null; bitmapIcon = null;
} }
if(bitmapIcon == null)
// Try to load the app icon
bitmapIcon = getApplicationIconBitmap();
changeHeaderIcon(); changeHeaderIcon();
} }
private Bitmap getApplicationIconBitmap() {
Drawable drawable = getApplicationInfo().loadIcon(getPackageManager());
if (drawable instanceof BitmapDrawable) {
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
if (bitmapDrawable.getBitmap() != null)
return bitmapDrawable.getBitmap();
}
if (drawable.getIntrinsicWidth() <= 0 || drawable.getIntrinsicHeight() <= 0)
return Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888); // Single color bitmap will be created of 1x1 pixel
else
return Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
}
private void setPort1Settings(boolean port1Plugged, boolean port1Writable) { private void setPort1Settings(boolean port1Plugged, boolean port1Writable) {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("settings_port1en", port1Plugged); editor.putBoolean("settings_port1en", port1Plugged);