cp437.ino 608 B

123456789101112131415161718192021222324252627282930313233343536
  1. #include <SPI.h>
  2. #include <GD.h>
  3. #include "cp437.h"
  4. static int atxy(int x, int y)
  5. {
  6. return (y << 7) + x;
  7. }
  8. static void drawstr(uint16_t addr, const char *s)
  9. {
  10. while (*s) {
  11. uint16_t w = pgm_read_word(cp437_pic + 2 * *s);
  12. GD.wr(addr, lowByte(w));
  13. GD.wr(addr + 64, highByte(w));
  14. s++, addr++;
  15. }
  16. }
  17. void setup()
  18. {
  19. GD.begin();
  20. GD.uncompress(RAM_CHR, cp437_chr);
  21. GD.uncompress(RAM_PAL, cp437_pal);
  22. drawstr(atxy(0, 0), "Hello");
  23. drawstr(atxy(10, 2), "This is the cp437 font");
  24. for (byte i = 0; i < 14; i++) {
  25. drawstr(atxy(i, 4 + i), " *Gameduino* ");
  26. }
  27. }
  28. void loop()
  29. {
  30. }