2017-01-22 13:46:38 +01:00
|
|
|
package org.warp.picalculator.gui.graphicengine.cpu;
|
2016-09-02 20:32:37 +02:00
|
|
|
|
|
|
|
import java.awt.FontMetrics;
|
2017-01-31 22:29:49 +01:00
|
|
|
import java.awt.GraphicsEnvironment;
|
2016-09-02 20:32:37 +02:00
|
|
|
import java.awt.image.BufferedImage;
|
2017-01-31 22:29:49 +01:00
|
|
|
import java.io.IOException;
|
2016-09-02 20:32:37 +02:00
|
|
|
|
2017-06-25 00:23:49 +02:00
|
|
|
import javax.swing.UIManager;
|
|
|
|
import javax.swing.UnsupportedLookAndFeelException;
|
|
|
|
|
2016-09-02 20:32:37 +02:00
|
|
|
import org.warp.picalculator.Main;
|
2016-11-02 21:56:40 +01:00
|
|
|
import org.warp.picalculator.Utils;
|
2017-01-31 22:29:49 +01:00
|
|
|
import org.warp.picalculator.gui.DisplayManager;
|
2017-05-16 22:02:44 +02:00
|
|
|
import org.warp.picalculator.gui.graphicengine.BinaryFont;
|
2017-02-02 10:30:45 +01:00
|
|
|
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
|
2017-05-16 22:02:44 +02:00
|
|
|
import org.warp.picalculator.gui.graphicengine.Renderer;
|
2017-02-02 10:30:45 +01:00
|
|
|
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
|
|
|
|
import org.warp.picalculator.gui.graphicengine.Skin;
|
2016-09-02 20:32:37 +02:00
|
|
|
|
2017-02-02 10:30:45 +01:00
|
|
|
public class CPUEngine implements GraphicEngine {
|
2016-09-02 20:32:37 +02:00
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
private SwingWindow INSTANCE;
|
|
|
|
public int[] size = new int[] { 1, 1 };
|
|
|
|
public BufferedImage g = new BufferedImage(size[0], size[1], BufferedImage.TYPE_INT_RGB);
|
2016-11-02 21:56:40 +01:00
|
|
|
static int[] canvas2d = new int[1];
|
2017-01-31 22:29:49 +01:00
|
|
|
public int color = 0xFF000000;
|
|
|
|
public volatile boolean initialized = false;
|
|
|
|
private final CPURenderer r = new CPURenderer();
|
2016-09-02 20:32:37 +02:00
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void setTitle(String title) {
|
2016-09-02 20:32:37 +02:00
|
|
|
INSTANCE.setTitle(title);
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void setResizable(boolean r) {
|
2016-09-02 20:32:37 +02:00
|
|
|
INSTANCE.setResizable(r);
|
2017-01-31 22:29:49 +01:00
|
|
|
if (!r) {
|
2016-09-02 20:32:37 +02:00
|
|
|
INSTANCE.setUndecorated(true);
|
2017-01-31 22:29:49 +01:00
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void setDisplayMode(final int ww, final int wh) {
|
2016-09-02 20:32:37 +02:00
|
|
|
INSTANCE.setSize(ww, wh);
|
|
|
|
size = new int[] { ww, wh };
|
|
|
|
canvas2d = new int[ww * wh];
|
|
|
|
g = new BufferedImage(ww, wh, BufferedImage.TYPE_INT_ARGB);
|
|
|
|
INSTANCE.wasResized = false;
|
|
|
|
}
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void create() {
|
2017-03-03 23:06:43 +01:00
|
|
|
INSTANCE = new SwingWindow(this);
|
2017-01-31 22:29:49 +01:00
|
|
|
setResizable(Utils.debugOn & !Utils.debugThirdScreen);
|
2017-01-22 13:46:38 +01:00
|
|
|
setDisplayMode(Main.screenSize[0], Main.screenSize[1]);
|
2016-09-02 20:32:37 +02:00
|
|
|
INSTANCE.setVisible(true);
|
|
|
|
initialized = true;
|
|
|
|
}
|
2017-01-31 22:29:49 +01:00
|
|
|
|
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public boolean wasResized() {
|
2016-09-02 20:32:37 +02:00
|
|
|
if (INSTANCE.wasResized) {
|
|
|
|
size = new int[] { INSTANCE.getWidth(), INSTANCE.getHeight() };
|
|
|
|
canvas2d = new int[size[0] * size[1]];
|
|
|
|
g = new BufferedImage(size[0], size[1], BufferedImage.TYPE_INT_ARGB);
|
|
|
|
INSTANCE.wasResized = false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public int getWidth() {
|
2017-01-31 22:29:49 +01:00
|
|
|
return INSTANCE.getWidth() - Main.screenPos[0];
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public int getHeight() {
|
2017-01-31 22:29:49 +01:00
|
|
|
return INSTANCE.getHeight() - Main.screenPos[1];
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void destroy() {
|
2016-09-02 20:32:37 +02:00
|
|
|
initialized = false;
|
|
|
|
INSTANCE.setVisible(false);
|
|
|
|
INSTANCE.dispose();
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public void start(RenderingLoop d) {
|
2017-03-03 23:06:43 +01:00
|
|
|
INSTANCE.setRenderingLoop(d);
|
2017-04-10 22:50:43 +02:00
|
|
|
final Thread th = new Thread(() -> {
|
2017-01-31 22:29:49 +01:00
|
|
|
try {
|
|
|
|
double extratime = 0;
|
|
|
|
while (initialized) {
|
|
|
|
final long start = System.currentTimeMillis();
|
|
|
|
repaint();
|
|
|
|
final long end = System.currentTimeMillis();
|
|
|
|
final double delta = (end - start) / 1000d;
|
|
|
|
final int deltaInt = (int) Math.floor(delta);
|
|
|
|
final int extraTimeInt = (int) Math.floor(extratime);
|
|
|
|
if (extraTimeInt + deltaInt < 50) {
|
|
|
|
Thread.sleep(50 - (extraTimeInt + deltaInt));
|
|
|
|
extratime = 0;
|
|
|
|
} else {
|
|
|
|
extratime += delta - 50d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (final InterruptedException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
});
|
2017-02-06 21:38:17 +01:00
|
|
|
th.setName("CPU rendering thread");
|
2017-01-31 22:29:49 +01:00
|
|
|
th.setDaemon(true);
|
|
|
|
th.start();
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Deprecated()
|
2017-01-22 13:46:38 +01:00
|
|
|
public void refresh() {
|
2017-01-31 22:29:49 +01:00
|
|
|
if (DisplayManager.screen == null || (DisplayManager.error != null && DisplayManager.error.length() > 0) || DisplayManager.screen == null || DisplayManager.screen.mustBeRefreshed()) {
|
|
|
|
INSTANCE.c.repaint();
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void repaint() {
|
2017-01-31 22:29:49 +01:00
|
|
|
INSTANCE.c.repaint();
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
2016-10-03 22:00:58 +02:00
|
|
|
|
2017-01-22 13:46:38 +01:00
|
|
|
public abstract class Startable {
|
2016-09-02 20:32:37 +02:00
|
|
|
public Startable() {
|
2017-01-31 22:29:49 +01:00
|
|
|
force = false;
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Startable(boolean force) {
|
|
|
|
this.force = force;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean force = false;
|
|
|
|
|
|
|
|
public abstract void run();
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
public class CPURenderer implements Renderer {
|
2017-01-22 13:46:38 +01:00
|
|
|
public int clearcolor = 0xFFc5c2af;
|
2017-01-31 22:29:49 +01:00
|
|
|
public CPUFont currentFont;
|
|
|
|
public CPUSkin currentSkin;
|
2016-09-02 20:32:37 +02:00
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void glColor3i(int r, int gg, int b) {
|
2016-11-25 22:40:43 +01:00
|
|
|
glColor4i(r, gg, b, 255);
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void glColor(int c) {
|
2016-09-02 20:32:37 +02:00
|
|
|
color = c & 0xFFFFFFFF;
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void glClearColor(int c) {
|
2016-09-02 20:32:37 +02:00
|
|
|
clearcolor = c & 0xFFFFFFFF;
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-01-22 13:46:38 +01:00
|
|
|
public void glColor4i(int red, int green, int blue, int alpha) {
|
2016-09-02 20:32:37 +02:00
|
|
|
color = (alpha << 24) + (red << 16) + (green << 8) + (blue);
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
|
|
|
public void glClearColor4i(int red, int green, int blue, int alpha) {
|
2016-09-02 20:32:37 +02:00
|
|
|
clearcolor = (alpha << 24) + (red << 16) + (green << 8) + (blue);
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
|
|
|
public void glClearColor4f(float red, float green, float blue, float alpha) {
|
2017-04-10 22:50:43 +02:00
|
|
|
clearcolor = ((int) (alpha * 255) << 24) + ((int) (red * 255) << 16) + ((int) (green * 255) << 8) + ((int) (blue * 255));
|
2017-01-31 22:29:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void glClear(int screenWidth, int screenHeight) {
|
|
|
|
for (int x = 0; x < screenWidth; x++) {
|
|
|
|
for (int y = 0; y < screenHeight; y++) {
|
2016-09-02 20:32:37 +02:00
|
|
|
canvas2d[x + y * size[0]] = clearcolor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
private void glDrawSkin(int x0, int y0, int s0, int t0, int s1, int t1, boolean transparent) {
|
|
|
|
x0 += Main.screenPos[0];
|
|
|
|
y0 += Main.screenPos[1];
|
2016-09-12 16:30:51 +02:00
|
|
|
int oldColor;
|
|
|
|
int newColor;
|
2017-01-31 22:29:49 +01:00
|
|
|
final int onex = s0 <= s1 ? 1 : -1;
|
|
|
|
final int oney = t0 <= t1 ? 1 : -1;
|
2016-09-12 16:30:51 +02:00
|
|
|
int width = 0;
|
|
|
|
int height = 0;
|
|
|
|
if (onex == -1) {
|
2017-01-31 22:29:49 +01:00
|
|
|
final int s00 = s0;
|
2016-09-12 16:30:51 +02:00
|
|
|
s0 = s1;
|
|
|
|
s1 = s00;
|
2017-01-31 22:29:49 +01:00
|
|
|
width = s1 - s0;
|
2016-09-12 16:30:51 +02:00
|
|
|
}
|
|
|
|
if (oney == -1) {
|
2017-01-31 22:29:49 +01:00
|
|
|
final int t00 = t0;
|
2016-09-12 16:30:51 +02:00
|
|
|
t0 = t1;
|
|
|
|
t1 = t00;
|
2017-01-31 22:29:49 +01:00
|
|
|
height = t1 - t0;
|
2016-09-12 16:30:51 +02:00
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
if (x0 >= size[0] || y0 >= size[0]) {
|
|
|
|
return;
|
|
|
|
}
|
2016-09-12 16:30:51 +02:00
|
|
|
if (x0 + width >= size[0]) {
|
2016-09-02 20:32:37 +02:00
|
|
|
s1 = size[0] - x0 + s0;
|
|
|
|
}
|
2016-09-12 16:30:51 +02:00
|
|
|
if (y0 + height >= size[1]) {
|
2016-09-02 20:32:37 +02:00
|
|
|
t1 = size[1] - y0 + t0;
|
|
|
|
}
|
2016-09-12 16:30:51 +02:00
|
|
|
if (x0 < 0) {
|
|
|
|
if (onex == -1) {
|
|
|
|
width += x0;
|
|
|
|
s1 += x0 + 1;
|
|
|
|
} else {
|
|
|
|
s0 -= x0;
|
|
|
|
}
|
|
|
|
x0 = 0;
|
|
|
|
}
|
|
|
|
if (y0 < 0) {
|
|
|
|
if (oney == -1) {
|
|
|
|
height += y0;
|
|
|
|
t1 += y0 + 1;
|
|
|
|
} else {
|
|
|
|
t0 -= y0;
|
|
|
|
}
|
|
|
|
y0 = 0;
|
|
|
|
}
|
2017-01-31 22:29:49 +01:00
|
|
|
int pixelX;
|
|
|
|
int pixelY;
|
2016-09-02 20:32:37 +02:00
|
|
|
for (int texx = 0; texx < s1 - s0; texx++) {
|
|
|
|
for (int texy = 0; texy < t1 - t0; texy++) {
|
2017-01-31 22:29:49 +01:00
|
|
|
pixelX = (x0 + texx * onex + width);
|
|
|
|
pixelY = (y0 + texy * oney + height);
|
|
|
|
if (pixelX - (pixelX % size[0]) == 0) {
|
|
|
|
newColor = currentSkin.skinData[(s0 + texx) + (t0 + texy) * currentSkin.skinSize[0]];
|
|
|
|
if (transparent) {
|
|
|
|
oldColor = canvas2d[pixelX + pixelY * size[0]];
|
|
|
|
final float a2 = (newColor >> 24 & 0xFF) / 255f;
|
|
|
|
final float a1 = 1f - a2;
|
|
|
|
final int r = (int) ((oldColor >> 16 & 0xFF) * a1 + (newColor >> 16 & 0xFF) * a2);
|
|
|
|
final int g = (int) ((oldColor >> 8 & 0xFF) * a1 + (newColor >> 8 & 0xFF) * a2);
|
|
|
|
final int b = (int) ((oldColor & 0xFF) * a1 + (newColor & 0xFF) * a2);
|
|
|
|
newColor = 0xFF000000 | r << 16 | g << 8 | b;
|
|
|
|
}
|
|
|
|
canvas2d[pixelX + pixelY * size[0]] = newColor;
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public void glDrawLine(float x0, float y0, float x1, float y1) {
|
2017-01-31 22:29:49 +01:00
|
|
|
x0 += Main.screenPos[0];
|
|
|
|
x1 += Main.screenPos[0];
|
|
|
|
y0 += Main.screenPos[1];
|
|
|
|
y1 += Main.screenPos[1];
|
2017-02-02 10:30:45 +01:00
|
|
|
final int ix0 = (int) x0;
|
|
|
|
final int ix1 = (int) x1;
|
|
|
|
final int iy0 = (int) y0;
|
|
|
|
final int iy1 = (int) y1;
|
|
|
|
if (ix0 >= size[0] || iy0 >= size[0]) {
|
2016-09-02 20:32:37 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-02-02 10:30:45 +01:00
|
|
|
if (iy0 == iy1) {
|
|
|
|
for (int x = 0; x <= ix1 - ix0; x++) {
|
2017-04-10 22:50:43 +02:00
|
|
|
if ((ix0 + x < size[0]) & (iy0 < size[1])) {
|
2017-03-26 22:44:09 +02:00
|
|
|
canvas2d[ix0 + x + iy0 * size[0]] = color;
|
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
2017-02-02 10:30:45 +01:00
|
|
|
} else if (ix0 == ix1) {
|
|
|
|
for (int y = 0; y <= iy1 - iy0; y++) {
|
2017-04-10 22:50:43 +02:00
|
|
|
if ((ix0 < size[0]) & (iy0 + y < size[1])) {
|
2017-03-26 22:44:09 +02:00
|
|
|
canvas2d[ix0 + (iy0 + y) * size[0]] = color;
|
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
} else {
|
2017-02-02 10:30:45 +01:00
|
|
|
final int m = (iy1 - iy0) / (ix1 - ix0);
|
|
|
|
for (int texx = 0; texx <= ix1 - ix0; texx++) {
|
|
|
|
if (ix0 + texx < size[0] && iy0 + (m * texx) < size[1]) {
|
2017-03-26 22:44:09 +02:00
|
|
|
if ((ix0 + texx < size[0]) & ((iy0 + (m * texx)) < size[1])) {
|
|
|
|
canvas2d[(ix0 + texx) + (iy0 + (m * texx)) * size[0]] = color;
|
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth,
|
2017-01-31 22:29:49 +01:00
|
|
|
float uvHeight) {
|
|
|
|
if (currentSkin != null) {
|
2017-02-02 10:30:45 +01:00
|
|
|
glDrawSkin((int) x, (int) y, (int) uvX, (int) uvY, (int) (uvWidth + uvX), (int) (uvHeight + uvY), true);
|
2017-01-31 22:29:49 +01:00
|
|
|
} else {
|
|
|
|
glFillColor(x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public void glFillColor(float x, float y, float width, float height) {
|
2017-01-31 22:29:49 +01:00
|
|
|
x += Main.screenPos[0];
|
|
|
|
y += Main.screenPos[1];
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2017-02-02 10:30:45 +01:00
|
|
|
final int ix = (int) x;
|
|
|
|
final int iy = (int) y;
|
|
|
|
final int iw = (int) width;
|
|
|
|
final int ih = (int) height;
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2017-05-16 22:02:44 +02:00
|
|
|
int x0 = ix;
|
|
|
|
int y0 = iy;
|
2017-02-02 10:30:45 +01:00
|
|
|
int x1 = ix + iw;
|
|
|
|
int y1 = iy + ih;
|
|
|
|
if (ix >= size[0] || iy >= size[0]) {
|
2016-09-02 20:32:37 +02:00
|
|
|
return;
|
|
|
|
}
|
2017-05-16 22:02:44 +02:00
|
|
|
if (x0 < 0) {
|
|
|
|
x0 = 0;
|
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
if (x1 >= size[0]) {
|
|
|
|
x1 = size[0];
|
|
|
|
}
|
2017-05-16 22:02:44 +02:00
|
|
|
if (y0 < 0) {
|
|
|
|
y0 = 0;
|
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
if (y1 >= size[1]) {
|
|
|
|
y1 = size[1];
|
|
|
|
}
|
|
|
|
final int sizeW = size[0];
|
2017-05-16 22:02:44 +02:00
|
|
|
for (int px = x0; px < x1; px++) {
|
|
|
|
for (int py = y0; py < y1; py++) {
|
2017-01-31 22:29:49 +01:00
|
|
|
canvas2d[(px) + (py) * sizeW] = color;
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public void glDrawStringLeft(float x, float y, String textString) {
|
2017-01-31 22:29:49 +01:00
|
|
|
x += Main.screenPos[0];
|
|
|
|
y += Main.screenPos[1];
|
|
|
|
|
2017-02-02 10:30:45 +01:00
|
|
|
final int ix = (int) x;
|
|
|
|
final int iy = (int) y;
|
2017-04-10 22:50:43 +02:00
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
final int[] text = currentFont.getCharIndexes(textString);
|
|
|
|
final int[] screen = canvas2d;
|
|
|
|
final int[] screenSize = size;
|
|
|
|
final int screenLength = screen.length;
|
|
|
|
int screenPos = 0;
|
|
|
|
|
|
|
|
int currentInt;
|
|
|
|
int currentIntBitPosition;
|
|
|
|
int bitData;
|
|
|
|
int cpos;
|
|
|
|
int j;
|
|
|
|
final int l = text.length;
|
|
|
|
for (int i = 0; i < l; i++) {
|
|
|
|
cpos = (i * (currentFont.charW + 1));
|
|
|
|
final int charIndex = text[i];
|
|
|
|
for (int dy = 0; dy < currentFont.charH; dy++) {
|
|
|
|
for (int dx = 0; dx < currentFont.charW; dx++) {
|
2017-02-02 10:30:45 +01:00
|
|
|
j = ix + cpos + dx;
|
2017-01-31 22:29:49 +01:00
|
|
|
if (j > 0 & j < screenSize[0]) {
|
|
|
|
final int bit = dx + dy * currentFont.charW;
|
|
|
|
currentInt = (int) (Math.floor(bit) / (CPUFont.intBits));
|
|
|
|
currentIntBitPosition = bit - (currentInt * CPUFont.intBits);
|
|
|
|
bitData = (currentFont.chars32[charIndex * currentFont.charIntCount + currentInt] >> currentIntBitPosition) & 1;
|
2017-02-02 10:30:45 +01:00
|
|
|
screenPos = ix + cpos + dx + (iy + dy) * screenSize[0];
|
2017-01-31 22:29:49 +01:00
|
|
|
if (bitData == 1 & screenLength > screenPos) {
|
|
|
|
screen[screenPos] = color;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public void glDrawStringCenter(float x, float y, String text) {
|
2017-01-31 22:29:49 +01:00
|
|
|
glDrawStringLeft(x - (currentFont.getStringWidth(text) / 2), y, text);
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public void glDrawStringRight(float x, float y, String text) {
|
2017-01-31 22:29:49 +01:00
|
|
|
glDrawStringLeft(x - currentFont.getStringWidth(text), y, text);
|
2016-11-02 21:56:40 +01:00
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Deprecated
|
2017-01-22 13:46:38 +01:00
|
|
|
public int glGetFontWidth(FontMetrics fm, String text) {
|
2016-09-02 20:32:37 +02:00
|
|
|
return fm.stringWidth(text);
|
|
|
|
}
|
|
|
|
|
2016-11-25 22:40:43 +01:00
|
|
|
@Deprecated
|
2017-01-22 13:46:38 +01:00
|
|
|
public int glGetCurrentFontHeight() {
|
2016-10-02 16:01:41 +02:00
|
|
|
return currentFont.charH;
|
|
|
|
}
|
|
|
|
|
2017-01-22 13:46:38 +01:00
|
|
|
@Override
|
|
|
|
public int glGetClearColor() {
|
|
|
|
return clearcolor;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public BinaryFont getCurrentFont() {
|
2017-01-22 13:46:38 +01:00
|
|
|
return currentFont;
|
|
|
|
}
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
@Override
|
|
|
|
public void glColor3f(float red, float green, float blue) {
|
|
|
|
glColor3i((int) (red * 255f), (int) (green * 255f), (int) (blue * 255f));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void glColor4f(float red, float green, float blue, float alpha) {
|
|
|
|
glColor4i((int) (red * 255f), (int) (green * 255f), (int) (blue * 255f), (int) (alpha * 255f));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void glClearSkin() {
|
|
|
|
currentSkin = null;
|
|
|
|
}
|
|
|
|
|
2017-03-03 23:06:43 +01:00
|
|
|
@Override
|
|
|
|
public void glDrawCharLeft(int x, int y, char ch) {
|
2017-04-10 22:50:43 +02:00
|
|
|
glDrawStringLeft(x, y, ch + "");
|
2017-03-03 23:06:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void glDrawCharCenter(int x, int y, char ch) {
|
2017-04-10 22:50:43 +02:00
|
|
|
glDrawStringCenter(x, y, ch + "");
|
2017-03-03 23:06:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void glDrawCharRight(int x, int y, char ch) {
|
2017-04-10 22:50:43 +02:00
|
|
|
glDrawStringRight(x, y, ch + "");
|
2017-03-03 23:06:43 +01:00
|
|
|
}
|
|
|
|
|
2017-01-22 13:46:38 +01:00
|
|
|
}
|
2017-01-31 22:29:49 +01:00
|
|
|
|
2017-01-22 13:46:38 +01:00
|
|
|
@Override
|
|
|
|
public int[] getSize() {
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isInitialized() {
|
|
|
|
return initialized;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-01-31 22:29:49 +01:00
|
|
|
public CPURenderer getRenderer() {
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public BinaryFont loadFont(String file) throws IOException {
|
2017-01-31 22:29:49 +01:00
|
|
|
return new CPUFont(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-02-02 10:30:45 +01:00
|
|
|
public Skin loadSkin(String file) throws IOException {
|
2017-01-31 22:29:49 +01:00
|
|
|
return new CPUSkin(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void waitUntilExit() {
|
|
|
|
try {
|
|
|
|
do {
|
|
|
|
Thread.sleep(500);
|
2017-04-10 22:50:43 +02:00
|
|
|
} while (initialized);
|
|
|
|
} catch (final InterruptedException e) {
|
|
|
|
|
2017-01-31 22:29:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isSupported() {
|
|
|
|
return GraphicsEnvironment.isHeadless() == false;
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|
2017-02-06 21:38:17 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean doesRefreshPauses() {
|
|
|
|
return true;
|
|
|
|
}
|
2016-09-02 20:32:37 +02:00
|
|
|
}
|