// Vplot(x, y, c)...ドットのプロット x:0-95, y:0-79, c:0(黒) 1(白) 2(反転) void Vplot(uint8_t x, uint8_t y, uint8_t c){ uint16_t i=(x>>3) + (y<<3)+(y<<2); // i=x/8 + y*12 if(c==0) vram[i]&= ~(1<<(7-x&7)); // black else if(c==1) vram[i]|= (1<<(7-x&7)); // white else if(c==2) vram[i]^= (1<<(7-x&7)); // invert } // Vset(x, y)...表示情報の読み取り x:0-95, y:0-79 戻り値:0(黒)または非0(白) uint8_t Vset(uint8_t x, uint8_t y){ uint16_t i=(x>>3) + (y<<3)+(y<<2); // i=x/8 + y*12 return(vram[i] & 1<<(7-x&7)); } // Vline(x1,y1,x2,y2,c)...線の描画 x1/x2:0-63, y1/y2:0-63, c:0(黒) 1(白) 2(反転) uint8_t Vline(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t c){ uint8_t x,y, i, t, xchg; uint16_t dx,dy; int16_t s1,s2, e; x=x1; y=y1; dx=abs(x2-x1); dy=abs(y2-y1); s1=((x2>=x1)?1:-1); s2=((y2>=y1)?1:-1); xchg=0; if(dy>dx){ t=dx; dx=dy; dy=t; xchg=1; } e=(dy<<1)-dx; for(i=0;i<=dx;i++){ Vplot(x,y,c); if(e>=0){ if(xchg==1) x+=s1; else y+=s2; e-=(dx<<1); } if(xchg==1) y+=s2; else x+=s1; e+=(dy<<1); } } // Vputc(x, y, c)...文字の描画 x:0-95のFONT_Wの倍数, y:0-79, c:文字コード void Vputc(uint8_t x, uint8_t y, uint8_t c){ // xは8の倍数 uint8_t j; uint16_t i=(x>>3) + (y<<3)+(y<<2); // i=x/8 + y*12 if(c<0x20) c=0; // ' ' else if(c<=0x7e) c-=0x20; // ' '〜'~' else if(c<=0xa0) c=0; // ' ' else if(c<=0xdf) c-=(0xa1-95); // '。'〜'゚' else c=0; // ' ' for(j=0;j>3) + (y<<3)+(y<<2); // i=x/8 + y*12 for(j=0;j>8; vram[i+1]=v&0xff; } } // Vputs(x, y, *s)...文字列の描画 x:0-95のFONT_Wの倍数, y:0-79, s:文字列 void Vputs(uint8_t x, uint8_t y, prog_uint8_t *s){ // xはFONT_Wの倍数 uint8_t i,c,c2; for(i=0; (c=pgm_read_byte(&s[i++]))!=0;){ if(c>=0x80 && c<0xa0 || c>=0xe0){ // SJIS c2=pgm_read_byte(&s[i++]); Vputw(x,y,c*256+c2); x+=16; }else{ Vputc(x,y,c); x+=8; } } }