mk_bsod.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import array
  2. import zlib
  3. import textwrap
  4. import gameduino2 as gd2
  5. class Fragment(gd2.base.GD2):
  6. def __init__(self):
  7. self.commands = ""
  8. self.run()
  9. print "static const PROGMEM uint8_t __%s[%d] = {" % (self.name, len(self.commands))
  10. print textwrap.fill(", ".join(["%d" % ord(c) for c in self.commands]))
  11. print "};"
  12. def c(self, s):
  13. self.commands += s
  14. class Bsod(Fragment):
  15. name = "bsod"
  16. def run(self):
  17. self.cmd_dlstart()
  18. if 1:
  19. self.ClearColorRGB(0, 0, 96)
  20. self.Clear()
  21. self.cmd_text(240, 90, 31, gd2.OPT_CENTER, "ERROR")
  22. else:
  23. self.BitmapLayout(gd2.TEXTVGA, 2 * 60, 17)
  24. self.BitmapSize(gd2.NEAREST, gd2.BORDER, gd2.BORDER, 480, 272)
  25. self.BlendFunc(gd2.ONE, gd2.ZERO)
  26. self.Begin(gd2.BITMAPS)
  27. self.Vertex2ii(0,0,0,0)
  28. full = 60 * "!"
  29. edge = "! !"
  30. text = full + 15 * edge + full
  31. screen = "".join(c + chr(0x1f) for c in text)
  32. cscreen = zlib.compress(screen)
  33. self.cmd_inflate(0)
  34. self.c(cscreen)
  35. class IoMessage(Fragment):
  36. name = "bsod_badfile"
  37. def run(self):
  38. self.cmd_text(240, 148, 29, gd2.OPT_CENTER, "Cannot open file:")
  39. if __name__ == '__main__':
  40. Bsod()
  41. IoMessage()