// Path: core/src/main/java/net/panuska/tlappy/awt/BufferedImage.java
// public class BufferedImage {
//     private Bitmap b;
//     private Graphics g;
//     public static final int TYPE_INT_RGB = Bitmap.Config.ARGB_8888.ordinal();
// 
//     public BufferedImage(BitmapDrawable d) {
//         Bitmap immb = d.getBitmap();
//         b = immb.copy(Bitmap.Config.ARGB_8888, false);
//     }
// 
//     public BufferedImage(int width,
//                          int height,
//                          int imageType) {
//         b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
//         g = new Graphics(b);
//     }
// 
//     private BufferedImage(Bitmap b) {
//         this.b = b;
//     }
// 
//     public Graphics getGraphics() {
//         return g;
//     }
// 
//     public Bitmap getBitmap() {
//         return b;
//     }
// 
//     public BufferedImage getSubimage (int x, int y, int w, int h) {
//         Bitmap b = Bitmap.createBitmap(this.b, x, y, w, h);
//         return new BufferedImage(b);
//     }
// 
//     /**
//      * Returns a copy of this image rotated by 90 degrees.
//      * @return
//      */
//     public BufferedImage getRotatedImage() {
//         Matrix matrix = new Matrix();
//         matrix.postRotate(90);
//         Bitmap b = Bitmap.createBitmap(this.getBitmap(), 0, 0, this.getWidth(), this.getHeight(),  matrix, false);
//         return new BufferedImage(b);
//     }
// 
//     /**
//      * Returns a copy of this image mirrored by vertical axis
//      * @return
//      */
//     public BufferedImage getMirroredImage() {
//         Matrix matrix = new Matrix();
//         matrix.preScale(-1, 1);
//         Bitmap b = Bitmap.createBitmap(this.getBitmap(), 0, 0, this.getWidth(), this.getHeight(),  matrix, false);
//         return new BufferedImage(b);
//     }
// 
//     /**
//      * Returns 16x16 subimage starting at x, y
//      * @param x
//      * @param y
//      * @return
//      */
//     public BufferedImage getSubimage (int x, int y) {
//         return getSubimage(x, y, 16, 16);
//     }
// 
//     public int getWidth() {
//         return b.getWidth();
//     }
// 
//     public int getHeight() {
//         return b.getHeight();
//     }
// }
// 
// Path: core/src/main/java/net/panuska/tlappy/awt/Color.java
// public enum Color {
//     BLACK(0xff000000),
//     RED(0xffff0000),
//     BLUE(0xff0000ff),
//     YELLOW(0xffffff00),
//     WHITE(0xffffffff),
//     DARK_GRAY(0xff404040),
//     LIGHT_GRAY(0xffc0c0c0),
//     TRANSPARENT(0x00000000),
// 
//     black(0xff000000),
//     red(0xffff0000),
//     blue(0xff0000ff),
//     yellow(0xffffff00),
//     white(0xffffffff),
//     dark_gray(0xff404040);
// 
//     private final int color;
//     Color(int color) { this.color = color; }
//     public int getValue() { return color; }
// }
// 
// Path: core/src/main/java/net/panuska/tlappy/Device.java
// public static VRAM vram;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int DOWN = 40;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int LEFT = 37;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int RIGHT = 39;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int SPACE_BAR = 32;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int UP = 38;


import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.KeyEvent;
import android.view.SurfaceView;
import net.panuska.tlappy.awt.BufferedImage;
import net.panuska.tlappy.awt.Color;
import net.panuska.tlappy.mobile.R;
import static net.panuska.tlappy.Device.vram;
import static net.panuska.tlappy.FullscreenActivity.DOWN;
import static net.panuska.tlappy.FullscreenActivity.LEFT;
import static net.panuska.tlappy.FullscreenActivity.RIGHT;
import static net.panuska.tlappy.FullscreenActivity.SPACE_BAR;
import static net.panuska.tlappy.FullscreenActivity.UP;
                    printMessageInCenter(20, message, Color.YELLOW);
                    printMessageInCenter(22, systemMessage, Color.RED);
                    vram.refresh();
                    sleep(16 * 6);
                }
                finish();
                return null;
            }
        }.execute();
    }

    @Override
    protected void onPause() {
        super.onPause();
        game.cancel(true);
        game = null;
    }

    private int step = 0;
    private void switchState() {
        state = STATES[step];
        message = getString(MESSAGES[step]);
        selectedAnimation = animation[step];
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            systemMessage = null;
            if (event.isSystem()) {
// Path: core/src/main/java/net/panuska/tlappy/awt/BufferedImage.java
// public class BufferedImage {
//     private Bitmap b;
//     private Graphics g;
//     public static final int TYPE_INT_RGB = Bitmap.Config.ARGB_8888.ordinal();
// 
//     public BufferedImage(BitmapDrawable d) {
//         Bitmap immb = d.getBitmap();
//         b = immb.copy(Bitmap.Config.ARGB_8888, false);
//     }
// 
//     public BufferedImage(int width,
//                          int height,
//                          int imageType) {
//         b = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
//         g = new Graphics(b);
//     }
// 
//     private BufferedImage(Bitmap b) {
//         this.b = b;
//     }
// 
//     public Graphics getGraphics() {
//         return g;
//     }
// 
//     public Bitmap getBitmap() {
//         return b;
//     }
// 
//     public BufferedImage getSubimage (int x, int y, int w, int h) {
//         Bitmap b = Bitmap.createBitmap(this.b, x, y, w, h);
//         return new BufferedImage(b);
//     }
// 
//     /**
//      * Returns a copy of this image rotated by 90 degrees.
//      * @return
//      */
//     public BufferedImage getRotatedImage() {
//         Matrix matrix = new Matrix();
//         matrix.postRotate(90);
//         Bitmap b = Bitmap.createBitmap(this.getBitmap(), 0, 0, this.getWidth(), this.getHeight(),  matrix, false);
//         return new BufferedImage(b);
//     }
// 
//     /**
//      * Returns a copy of this image mirrored by vertical axis
//      * @return
//      */
//     public BufferedImage getMirroredImage() {
//         Matrix matrix = new Matrix();
//         matrix.preScale(-1, 1);
//         Bitmap b = Bitmap.createBitmap(this.getBitmap(), 0, 0, this.getWidth(), this.getHeight(),  matrix, false);
//         return new BufferedImage(b);
//     }
// 
//     /**
//      * Returns 16x16 subimage starting at x, y
//      * @param x
//      * @param y
//      * @return
//      */
//     public BufferedImage getSubimage (int x, int y) {
//         return getSubimage(x, y, 16, 16);
//     }
// 
//     public int getWidth() {
//         return b.getWidth();
//     }
// 
//     public int getHeight() {
//         return b.getHeight();
//     }
// }
// 
// Path: core/src/main/java/net/panuska/tlappy/awt/Color.java
// public enum Color {
//     BLACK(0xff000000),
//     RED(0xffff0000),
//     BLUE(0xff0000ff),
//     YELLOW(0xffffff00),
//     WHITE(0xffffffff),
//     DARK_GRAY(0xff404040),
//     LIGHT_GRAY(0xffc0c0c0),
//     TRANSPARENT(0x00000000),
// 
//     black(0xff000000),
//     red(0xffff0000),
//     blue(0xff0000ff),
//     yellow(0xffffff00),
//     white(0xffffffff),
//     dark_gray(0xff404040);
// 
//     private final int color;
//     Color(int color) { this.color = color; }
//     public int getValue() { return color; }
// }
// 
// Path: core/src/main/java/net/panuska/tlappy/Device.java
// public static VRAM vram;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int DOWN = 40;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int LEFT = 37;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int RIGHT = 39;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int SPACE_BAR = 32;
// 
// Path: mobile/src/main/java/net/panuska/tlappy/FullscreenActivity.java
// static final int UP = 38;


// Path: mobile/src/main/java/net/panuska/tlappy/CustomControlsActivity.java
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.KeyEvent;
import android.view.SurfaceView;
import net.panuska.tlappy.awt.BufferedImage;
import net.panuska.tlappy.awt.Color;
import net.panuska.tlappy.mobile.R;
import static net.panuska.tlappy.Device.vram;
import static net.panuska.tlappy.FullscreenActivity.DOWN;
import static net.panuska.tlappy.FullscreenActivity.LEFT;
import static net.panuska.tlappy.FullscreenActivity.RIGHT;
import static net.panuska.tlappy.FullscreenActivity.SPACE_BAR;
import static net.panuska.tlappy.FullscreenActivity.UP;

                    printMessageInCenter(20, message, Color.YELLOW);
                    printMessageInCenter(22, systemMessage, Color.RED);
                    vram.refresh();
                    sleep(16 * 6);
                }
                finish();
                return null;
            }
        }.execute();
    }

    @Override
    protected void onPause() {
        super.onPause();
        game.cancel(true);
        game = null;
    }

    private int step = 0;
    private void switchState() {
        state = STATES[step];
        message = getString(MESSAGES[step]);
        selectedAnimation = animation[step];
    }

    @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            systemMessage = null;
            if (event.isSystem()) {
                systemMessage = getString(R.string.cant_record);