Graphics.prototype.setFontSuperMario256 = function() {
  // Actual height 26 (25 - 0)
  return this.setFontCustom(
    E.toString(require('heatshrink').decompress(atob('[encoded data, 4696 characters]'))),
    32,
    atob("DQgHFhMQFwMGBwcLBAsIDw4SExAUEQ8TEA8ICBYKFg4YExAQEQ8PERIJEhARHhIUERQSExUTFhsUEBEGDAkKEw0TEBARDw4REgkSEBEeEhQRFBITFRMWGxQQEREEERYA"),
    26|65536
  );
};

Graphics.prototype.setFontSuperPlumberBrothers = function() {
  // Actual height 20 (19 - 0)
  return this.setFontCustom(
    E.toString(require('heatshrink').decompress(atob('ABcP//v//+/4EBBIXAgH8AgYJLgfegE98AiBgH/+AECBJYYCAAMB/8/n/z+f/3/8nEzIIM/7/x/gZBGwMAn/wn//v4BC54BC4H/wEPwEA+AWBv+/MwIADhwCBH4PwDoMP8AVDNBMHDogABCgQABAgIjBAAX3AQKBCmBQBBwItB/wiBAgIJBgcQEAwEDRYgyCBwyRDEYMfwEB/AIEjwESEQoKHJwKrBVIqnB4CnCAIIACBwKpFQYodCFQRQBBgqQDEQb4BG4Uf/8HFIP4//+h9/wDgDh/vawLbChw2G342CgIXBv6PB+AmBUgLdGU4RKB/P8/+f//5//zwH/n4EBCgMf/j+DCYIADCYW///7fIOfCYQrBToIgBAIIABT4vAHYQnKAAf3BwITDngyCG4PwnATJgPh8EejwECBIsfwPhYIIABewMDSAWAh98gPj8E8j8HwATCg+egF58AERDAXA/E+j8B+fgh5MBGII2CHYITCAwL/Bh/zc4P+MoL5BE4JTDSA/xfgN/x/3DAN/94ECj4dBEQXgDQMDF4N/fQ0AEAIADBwJEBIoIAGh8PCYzaCAgI0BE4gTBAIJMCh67CE44TCE4oTKHYPwEoIEDJ5ZkB+ASBAgSYCJ5P8BQPH/98v47JEYIJICZIyCOQQuCBIJtFYAQxeCgJqBAgrlJDoXzBJDvHDpYTJd5DbRBIJxBDIN/4DHMHZByFFhRUJ5/v/gKBGAMOFgIPB+4DBn5UCF4gsHHIgODKgjqOx//HgQTGBIWAE54dJGI4AEVQIJICYXAh/+BwS+CAAQJCYQfwg//gf/+IhE/ABBh/8XpaNDh5pBGwQCBWQICCgE/DoM/CYMQXAgkIA='))),
    32,
    atob("BQQIDAgJCQQFBQgKBAoECQgGCAgJCAgICAgEBAgKCAgNCAgICAgICAgECAgIDAgICAoICAgICAwICAgFCQU="),
    20|65536
  );
};

Graphics.prototype.setFontKirbyClassic = function() {
  // Actual height 16 (15 - 0)
  return this.setFontCustom(
    E.toString(require('heatshrink').decompress(atob('AC0P+cH/OABg88gEfA4kD8ARHoEDkUBz8A/8D/kB+Vgjfwj/gn1AjcggOQgAxGsEenEfxkI4Uf//ijGBx3A8/AgABBKQYBB4EEkECiHB/HAvPAgOAgeAg84g8/g0xwUQoEMsBZGnEAv0D2eD+HBzEgw0QoOImFsjkcgFPgE/wEcoEIkEAiH4DgKHCgInDv+A//w8Ec4EDNwsMgEjwFwCAKFBBwxaBOISaBgEwgEsgEyCYsQgEIgEEgECHoOAj/8g/+gBNCCAgAHGIQZBBAZdCA4NAD4QAGsBECXIc/gH4g/gWIJ6D4F/+F//k8n0cg8Px+H//B//ATwIUBhzcD/8H//H//hQ4LGCnE8EAM+j1/h1/EIPD/vg/nwhDYBXQMeGAOP2fHznj/3w//4IIMevjvEnjUCv8AvvA//8v/+n//CATxBSwMB4H9EYN4v88n+Ojvvh3/w8/wePMYUfcAP8j/+j/nh9zCAPBz/gRwISBuA+Bh0en8PMof/wLVBeIN4KYTeBQ4IBB4e88PcuBnBn4yBCoJpCgfwgf84J4B894vYSCh/8gf4cQUxwEY4DlF4Fj4ExBQ0BwB8BgBaBJANsgEzgEREIUMmEMjEGhgcFgEJTgOAgVAgI7ByEApEAkkAiQQGDowAB4OAsHAjFghlggUwgOYgHYbgTNBhx7BDQgJBIgMEjuCjnBxinCDAIAEfQP/wHAGIVH41n+cjjGRglIwUkv8Tv+YwFIsFgjlggbgCegMAn+Bbgf94F/8C2BgDjBh7gCKIP/8P/+DcBuecnfOj7rCwPvwAVBn+Av/wbQM+j0cg8Pg+H8/D+fA/LRCuAWB/whBh//w+B4fh8H/8E/IYJUDAYNwGgJUBIYXnnBDBnGOgECFAU4Kg+AnPAjjRD/0B//AGQPwvFwjk8v0ev8HL4MPwDNDEIN//hUBIZQpBCAZlBGQScBh/AgYQBnDsBCAX+h4lBVI8fPQP8j8/h0HU4KUBKwIQCGQJKCZAWAgOABwghB+EB/kD/0HAIP/4IQBj/4gEYaIRUCg4JB/4wBIYk/Z4UH/gfBOwWA8PAuHwCAP8h4yBD4JGDXQ874Ef4EH8EBFISUB4F/+BlBnEfjkH58H8///I/CPgLmCKgcP/+HnkD35WB8B2Bj0+gEGCwMB4eD/Ph/nx984uf8nn8h08CAKbEKgoyBZwKMCCAP/CAKaCgF4bg8D4CxBTgPAn/4WwRSCVIIQBJIQSCbgTJDgbRB/+An5DEv56ChkCh+Hw4uBAIKYDvxnBj0ACAJUBEYXgn/wIYN/gCIBjhlDgfDw/h54yD7k/h0eg8EgY5CKgP//n//1AgMggAMDMoRjBg4EBviiCAAUIgEkgETbwQTBAAQA=='))),
    32,
    atob("CQcIDgsQDwQHBwkOBQYFBgoHCgkLCgkKCgkDBg4ODgkRCgoKCgkJCQsECQkHDAkKCgoLCAkICgwJCQkHBgc="),
    17|65536
  );
};

Graphics.prototype.setFontKirbyClassicBig = function() {
  // Actual height 58 (57 - 0)
  return this.setFontCustom(
    E.toString(require('heatshrink').decompress(atob('[encoded data, 8100 characters]'))),
    32,
    atob("HhgcMiY5NQ4XFx4yExQTFCQZIyEoIyEjIyEKFDIyMiA8JCMjJCAfICYNHx4aKR4jIyMnHR8dIikfHyAXFBc="),
    60|65536
  );
};


Graphics.prototype.setFontZapf = function() {
  // Actual height 56 (55 - 0)
  return this.setFontCustom(
    E.toString(require('heatshrink').decompress(atob('[encoded data, 9680 characters]'))),
    32,
    atob("EhQVLiUwNQsXFx4yEhcSESUlJSUlJSUlJSUUFDIyMh47Ky8pMismLzQaGTInOi4uKy4vJSstKzsnKCgXERc="),
    60|65536
  );
};

Graphics.prototype.setFontNES = function() {
  // Actual height 12 (11 - 0)
  return this.setFontCustom(
    E.toString(require('heatshrink').decompress(atob('ACsPwH/3/7AQOA/AOFg/AvkHA4YFBwFwCAnh5//AAXh50cBBEAgeMplP/9Go98gIeCgfgkMCmce8EYg0Bx8xiERgHzg0ws3bs02sdt2YIBsEbgEwgZVFthTBJooAEkE/4xdBiEAwEWg0/4ANBgNghkD+EMAoIYCKAMQAQP/AogeBBwXwj8BEAQAKgeAnACKCo9wLpcHgfj8ANB/E/4f8sF2gdgm8DBATiBDIkzgcwm//v/3/6VDmBLCg9x+8fsf2ndn237v838c4CIUAgwyBg68B8duBwN3+9/sPgCIV4HYP4nOHzFxw44DgOAjBeB418u/Htk24YCCt/2/8HEYf+n/z/92eQL1Cs/2v8BCISOCAQNhBYIOB8F8g/ATQcDzg+CEAQCCBAU5agS9BvxlBCIlvv/nIILLIgeHnFzw4MHgMM8FAAwbsC4EkTgNGhkgCocCoEkARAOCCgNGDQMkEAM4EwJBFgFggx9B21gsxiBBwngv+H/F/8f/n/3/wICnwSDBYKwBuOGjFhw8YBAUP+CwCboaeMgH4n/j/1wu0DsE2gdwu8HmFgEYwOCsE3g8/4f8h5bCGpQCCsEwCI6NBAQqGCI4YsBI4ljs/2v9nNY4ZBDgVgBAV/CIQABKwhfHI4UAjkB+EfgALCAQIjDR4Q1EaAP+h/jz9w+8HEYkAHwjtBmACFEYzgB/EPwbyBLIoRIwE+CI0D/hlGLIk/LI9hw0YAQV/w/4FgIjIjdh20Pv/H/k/2AjIj1h81/v3398+NYUDw1+u/nfAc3sc3+d/gPgYojSCFIgIDB4UH/wLCTwp9DEYUH+BiCgfgj7dBR4IIBv4jDa4ngUJUHg99+/fTALFC/gICuFwLId8g/gvzuBHoV+BAN8B4UGg9h+0fs/2/dv2/jvk34dwR4QAB//4gOAiEAuBLBAIMHwEYgP/JQQ='))),
    32,
    atob("DAwMDAgLDAwFBQYKDAwMBAwMDAwMDAwMDAwMBAoKCgwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwFBAU="),
    12|65536
  );
};

{ // must be inside our own scope here so that when we are unloaded everything disappears
  // we also define functions using 'let fn = function() {..}' for the same reason. function decls are global
let drawTimeout;
  
let bg_mario3 = {
  width : 176, height : 165, bpp : 3,
  transparent : 1,
  buffer : require("heatshrink").decompress(atob("kmT0mQtMkyVImmSpMkjQCByUNAQNJgwLCwYLCoOkBAMg6QIBEDpBCwEJBYNAggLCgQsCgIsCgAgCgAgCLwIIBgESBAIgdIIXAgJKBsEANYMwgBrBzEANYNMgBrBk0ANYOTgBrCwEDFIIgdAwOAiAdBgEIDoMAgkYAYMChgDBgMGboWDAYVBwADBkHAAYIgdIIKkeYsZB/yV0gFAm3aRgMbtqtBhu2wEIg3bFgMDtuggUB23QgMA7dogGAtu0EDqDBgGQKYMApBTBBQMSAYMShIDBhMEbwMEwVAeQNBkDyBkGQCAIgdYv7FCIIQUCKAIgCCgRxBEAY1CNAIgCGoRoBIIQgcIIKRBAHpICIP5B/IIThBAALhBAAMQAYUIAYUEAYUCAYUBDwbiDEDxBBpgGBkMmD4WTD4VJCAMEknAD4MSsAfBhMwCAOEzADBoQgeIINJAX4C/AX4C/AX4C/AX4C/AQPtgAABk3EIPU8h//AAUDIPUD//MAgMP/kCIPFOj//n///18/+MIPFI//P//ypP/z/wIPX//n//pB+AAP5IPdOjnP5n//18/+MIPFJgf5n/ypMP/kCIPM8h0EY4UDH24CD9u2gEAk3Ea5XQB4MCthQ6yfASQX/+E5IPOQn/85IEB//AIPPh//zQQPn5/4a5QCux/8IAMkz/5/8EIPJAB5//75B+AAKD88PM/iDB8/P/HEIPGQn+T/4EB//AH2wCCyfA8FPYwPwnJB5yVO7dggECtg+4AX4C/AX4C/AX4C/AX4C/AX4C/AX4C/AX4C/AX4C/AX4C/AX4C/AX4C/AVWTwEYHe/YgEA7BBD8PgiRB1pEJAYMAHYWT//8IO1CAwcCIPY2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AgCwAgCoAgCkEDEAMQgIgBhEAEEUH/xiC/4gC/+eEAP/54gBv/nEALmBEALmBMQTmDEEDF/EH8g+ALByF4BYIFBiQaBj0JDQMPggaBg+CDQOD4IsBoPgFgIgh/+B8jXB4Hya4PgNAMf+BoBh/4NAMH/gsBwf+FgL4BgfJEEPyv4gBvM/EAM8z/5MQNP/ggBk/+EAOT/4gB5P/WwX/EEWAgPAgFAgHggEggFwgEQgE4gEIgEcgEEgEOgECgEHgEBgEDwEAEEHf//H/1v//j/83//x/+b//4//N//8v/m//+n/zv//j/53//x/8EEHySQKkBSQPIcAKSBcAKzBcAIOBcAKzBUgKzBCIKzBCIIg/EEbUBEAOCgAgCgAgCwAgCoAgCkEDEAMQgIgBeoIgig/+MQX/EAX/zwgB//PEAN/84gBcwIgBcwJiCcwYggYv4g/kHwBYOQvALBAoMSDQMehIaBh8EDQMHwQaBwfBFgNB8AsBEEP/wPka4PA+TXB8BoBj/wNAMP/BoBg/8FgOD/wsBfAMD5Igh+V/EAN5n4gBnmf/JiBp/8EAMn/wgByf/EAPJ/62C/4giwEB4EAoEA8EAkEAuEAiEAnEAhEAjkAgkAh0AgUAg8AgMAgeAgAggA=="))
};

let bg_mario2 = {
  width : 176, height : 165, bpp : 3,
  transparent : 1,
  buffer : require("heatshrink").decompress(atob("yVJkgC/AX4C/AX4C/AX4C/AX4C/AX4C/AX4C/AX4C/AX4C8k3SIP8n+Q74tu3/4AB7VJ3//pM2BAX7tpBvm41CAB36INeTt4xC/0AgEHAoP8z4DB8AJB74QC/ukH0smFQMkF4WSoQMEpMhmVJhIYDzMkKYWSv//6Q7bk7yBAoNNNgX2P4QeRgA+B7YcC9IKC3/yIKs///JNAX/+dPIAMSbaggB/OnEAQKBEAJBWC4IjB//AgmR3/AUqtG/8CpEDZgQpDIKk3/R9B/b+DuznX7AFCzO3RIIpBD6lP/xeB/kEHawCKpGfE4Pf/IZTv//zdv8I+fAQcz/u0IYJBU8+T//JIMcn//k+ZBSk/yp837d/I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8RBNyf+SZPf/JfBWBACEBANOQQP+kmYpMSpEABYNM4BGBgmfkn+IJuSuKDJ//8kjyI78SAQYICz/P8MmoVIfYSeBpnCpEEwGZwxBNpGQTwgCEpnTh0AYpEzyfJ+AIEkakCzAmBhMEgAgByUB/2A5//Ypn//AaBIJKvCQYl/8mT//6t/+zf/5MnN4XCAQPDhAWBgAaC4d9/8H5PkyBBKFAP5iRBLYoxBBfgMSIIOQv//IIYRDQYUkwAFBwdx/kH8MkGQJBJyVtIINunAPI//xdgQFB+V//n/+mSpoCC/8//1P/4aEj9P8hcBeQUAyfpIIKDKEYXgt0GOAIAF/GfwLXCAAXgAQP8FwIdBHoP/xIcHDoICCyFAgGD5EkwVBIJVJ/3AKwPfEY+SDQODBQqFBDoZBBDQ//8VNw4EB/0T//wweIIIL3IAQcEwEAgkfEw+SpkAQYXggM/Y4RBFyf/gEDDQjNB44jFj4wBgBBNgEIa4lIggODtukDRQCLg3zv/wBAUCDSRBBAoJBCwFAIIgCYk6+BgGSoEgIKYCDIIWQoA+aAQcT5MgU4MgVoYCXgMADrZoGgGAhIdYgUAUgI+eQAJlBeQQgXwEAghBckEApBiBoEAgSnfEEACeoCnBIPynBiEJIPtJgEAQfxABgRB+AX4C/AX4C/AX4C4A"))
};

let bg_kirby = {
  width : 176, height : 165, bpp : 3,
  transparent : 2,
  buffer : require("heatshrink").decompress(atob("[encoded data, 4396 characters]"))
};

let bg_zelda = {
  width : 176, height : 165, bpp : 8,
  transparent : 254,
  buffer : require("heatshrink").decompress(atob("[encoded data, 6120 characters]"))
};
  
let settings  = Object.assign({
  currentFace : "Mario 3"
}, require("Storage").readJSON("nesclock.json", true) || {});
  
let currentFace = {};
  
if (settings.currentFace == "Mario 3") {
  currentFace = {'fontFace': "SuperMario256",
                 'dateFontFace': "NES",
                 'clockScale': 2,
                 'clockOffsetX': 0,
                 'clockOffsetY': 0,
                 'dateOffsetX': 0,
                 'dateOffsetY': 48,
                 'clockShadowOffsetX': 5,
                 'clockShadowOffsetY': 5,
                 'dateShadowOffsetX': 1,
                 'dateShadowOffsetY': 1,
                 'dateScale': 1,
                 'clockColor': "#4299f4",
                 'dateColor': "#ffffff",
                 'bgColor': "#f5bf66",
                 'bgImage': bg_mario3};
} else if (settings.currentFace == "Mario 2") {
  currentFace = {'fontFace': "SuperPlumberBrothers",
                 'dateFontFace': "NES",
                 'clockScale': 3,
                 'clockOffsetX': 0,
                 'clockOffsetY': -8,
                 'dateOffsetX': 0,
                 'dateOffsetY': 54,
                 'clockShadowOffsetX': 3,
                 'clockShadowOffsetY': 3,
                 'dateShadowOffsetX': 1,
                 'dateShadowOffsetY': 1,
                 'dateScale': 1,
                 'clockColor': "#ffffff",
                 'dateColor': "#ffffff",
                 'bgColor': "#9290ff",
                 'bgImage': bg_mario2};
} else if (settings.currentFace == "Mario 1") {
  currentFace = {'fontFace': "SuperPlumberBrothers",
                 'dateFontFace': "NES",
                 'clockScale': 4,
                 'clockOffsetX': 0,
                 'clockOffsetY': -8,
                 'dateOffsetX': 0,
                 'dateOffsetY': 54,
                 'clockShadowOffsetX': 3,
                 'clockShadowOffsetY': 3,
                 'dateShadowOffsetX': 1,
                 'dateShadowOffsetY': 1,
                 'dateScale': 1,
                 'clockColor': "#aa4e00",
                 'dateColor': "#ffffff",
                 'bgColor': "#9290ff",
                 'bgImage': bg_mario1};
} else if (settings.currentFace == "Kirby") {
  currentFace = {'fontFace': "KirbyClassicBig",
                 'dateFontFace': "KirbyClassic",
                 'clockScale': 1,
                 'clockOffsetX': 0,
                 'clockOffsetY': 0,
                 'dateOffsetX': 0,
                 'dateOffsetY': 54,
                 'clockShadowOffsetX': 3,
                 'clockShadowOffsetY': 3,
                 'dateShadowOffsetX': 2,
                 'dateShadowOffsetY': 2,
                 'dateScale': 1,
                 'clockColor': "#ff00ff",
                 'dateColor': "#fe6ecc",
                 'bgColor': "#ffffff",
                 'bgImage': bg_kirby};
} else if (settings.currentFace == "Zelda") {
  currentFace = {'fontFace': "Zapf",
                 'dateFontFace': "NES",
                 'clockScale': 1,
                 'clockOffsetX': 0,
                 'clockOffsetY': -10,
                 'dateOffsetX': 0,
                 'dateOffsetY': 40,
                 'clockShadowOffsetX': 3,
                 'clockShadowOffsetY': 3,
                 'dateShadowOffsetX': 2,
                 'dateShadowOffsetY': 2,
                 'dateScale': 1,
                 'clockColor': "#994e00",
                 'dateColor': "#0c9300",
                 'bgColor': "#feccc5",
                 'bgImage': bg_zelda};
}

// Actually draw the watch face
let draw = function() {
  var x = g.getWidth() / 2;
  var y = g.getHeight() / 2;
  g.reset().clearRect(Bangle.appRect); // clear whole background (w/o widgets)
  
  //Set Background color for face
  g.setColor(currentFace.bgColor);
  g.fillRect(Bangle.appRect);
  g.drawImage(currentFace.bgImage, 0, 24);
  var date = new Date();
  var timeStr = require("locale").time(date, 1).trim(); // Hour and minute trimmed to center whole text instead of on colon
  var dateStr = require("locale").date(date, 0).toUpperCase()+"\n"+
                require("locale").dow(date, 0).toUpperCase();
  //shadows
  g.setColor(0,0,0);
  g.setFontAlign(0, 0).setFont(currentFace.fontFace, currentFace.clockScale).drawString(timeStr, x+currentFace.clockOffsetX+currentFace.clockShadowOffsetX, y+currentFace.clockOffsetY+currentFace.clockShadowOffsetY);
  g.setFontAlign(0, 0).setFont(currentFace.dateFontFace, currentFace.dateScale).drawString(dateStr, x+currentFace.dateOffsetX+currentFace.dateShadowOffsetX, y+currentFace.dateOffsetY+currentFace.dateShadowOffsetY);
  
  //main text
  g.setColor(currentFace.clockColor);
  g.setFontAlign(0, 0).setFont(currentFace.fontFace, currentFace.clockScale).drawString(timeStr, x+currentFace.clockOffsetX, y+currentFace.clockOffsetY);
  // Show date and day of week
  g.setColor(currentFace.dateColor);
  g.setFontAlign(0, 0).setFont(currentFace.dateFontFace, currentFace.dateScale).drawString(dateStr, x+currentFace.dateOffsetX, y+currentFace.dateOffsetY);


  
  // queue next draw
  if (drawTimeout) clearTimeout(drawTimeout);
  drawTimeout = setTimeout(function() {
    drawTimeout = undefined;
    draw();
  }, 60000 - (Date.now() % 60000));
};

// Show launcher when middle button pressed
Bangle.setUI({
  mode : "clock",
  remove : function() {
    // Called to unload all of the clock app
    if (drawTimeout) clearTimeout(drawTimeout);
    drawTimeout = undefined;
    delete Graphics.prototype.setFontMarioBrosDS;
    delete Graphics.prototype.setFontSuperPlumberBrothers;
    delete Graphics.prototype.setFontKirbyClassic;
    delete Graphics.prototype.setFontKirbyClassicBig;
    delete Graphics.prototype.setFontZapf;
    delete Graphics.prototype.setFontNES;
  }});
// Load widgets
Bangle.loadWidgets();
draw();
setTimeout(Bangle.drawWidgets,0);
}

