//////////////////////////////////////// // { PROGRAM NAME } { VERSION } // Author: // License: // Description: //////////////////////////////////////// #include #include #include #include #include #include #include #include #include "qrcode.h" #pragma asm "include \"ti84pce.inc\"" static uint16_t* screen_buf = (uint16_t*)0xD40000; #define SCR_WIDTH 320 #define SCR_HEIGHT 240 typedef uint16_t color_t; color_t globalColor = 0; #define rgb2color(r, g, b) ((color_t)(((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | (b >> 3))) #define gc_drawPixel(x, y) *((uint16_t*)(screen_buf + x + y*SCR_WIDTH)) = globalColor; #define gc_setColorRGB(r, g, b) globalColor = rgb2color(r, g, b); #define BORDER_SIZE 4 #define VERSION_MAX 40 #define MODE_MAX 2 #define min(a,b) (((a)<(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b)) #define SUBS1T1T_SIZE sizeof(subst1T1Tfrom) uint8_t subst1T1Tfrom[]={0x06,0x07,0x08,0x09,0x0A,0x0B,0x0D,0x0E,0x0F,0x10,0x11,0x29,0x2A,0x2B,0x2C,0x2D,0x3A,0x3B,0x3E,0x3F,0x5B,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x7F,0x80,0x81,0x82,0x83,0xAC,0xAE,0xAF,0xB0,0xBC,0xBD,0xEB,0xF0,0xF1}; uint8_t subst1T1Tto []={'[' ,']' ,'{' ,'}' ,'r' ,'o' ,'2' ,'T' ,'3' ,'(' ,')' ,' ' ,'\"',',' ,'i' ,'!' ,'.' ,'E' ,':' ,'\n','q' ,'=' ,'<' ,'>' ,'<' ,'>' ,'=' ,'+' ,'-' ,'#' ,'+' ,'.' ,'*' ,'/' ,'p' ,'\'','?' ,'-' ,'V' ,'V' ,'L' ,'^' ,'V' }; uint16_t qrcapacity[VERSION_MAX+1][MODE_MAX+1]= { // num +alpha +symbols/specials {0, 0, 0}, {41, 25, 17}, {77, 47, 32}, {127, 77, 53}, {187, 114, 78}, {255, 154, 106}, {322, 195, 134}, {370, 224, 154}, {461, 279, 192}, {552, 335, 230}, {652, 395, 271}, {772, 468, 321}, {883, 535, 367}, {1022, 619, 425}, {1101, 667, 458}, {1250, 758, 520}, {1408, 854, 586}, {1548, 938, 644}, {1725, 1046, 718}, {1903, 1153, 792}, {2061, 1249, 858}, {2232, 1352, 929}, {2409, 1460, 1003}, {2620, 1588, 1091}, {2812, 1704, 1171}, {3057, 1853, 1273}, {3283, 1990, 1367}, {3517, 2132, 1465}, {3669, 2223, 1528}, {3909, 2369, 1628}, {4158, 2520, 1732}, {4417, 2677, 1840}, {4686, 2840, 1952}, {4965, 3009, 2068}, {5253, 3183, 2188}, {5529, 3351, 2303}, {5836, 3537, 2431}, {6153, 3729, 2563}, {6479, 3927, 2699}, {6743, 4087, 2809}, {7089, 4296, 2953} }; void gc_drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { if (y1 == y0) { uint16_t *base = screen_buf + min(x0, x1) + y0*SCR_WIDTH; uint16_t end = abs(x0-x1)+1; uint16_t i; for (i = 0; i < end; i++) { *(base++) = globalColor; } } else { int dx = abs(x1-x0), sx = x0dy ? dx : -dy)/2, e2; for(;;) { gc_drawPixel(x0, y0); if (x0 == x1 && y0 == y1) break; e2 = err; if (e2 >-dx) { err -= dy; x0 += sx; } if (e2 < dy) { err += dx; y0 += sy; } } } } void gc_fillRect(uint16_t x, uint16_t y, uint16_t w, uint16_t h) { uint16_t i, j; uint16_t* base = screen_buf + x + y*SCR_WIDTH; for(j=0; j'9') && (!mode || (mode && (buf[i]<'A' || buf[i]>'Z')))) { mode++; i--; } while(qrcapacity[version][mode]