(論理編)16ビット漢字キャラクタージェネレータを作れるから作る(ST7735S)(Arduino UNO))





参考


↓クリック


https://qiita.com/caa45040/items/02051ff7343ffbca84db


↓クリック


https://qiita.com/caa45040/items/39a24cb95585e3bd254e








目的
16x16のMSXのVDPみたいなものを最小限でつくる
キャラクターRAMのサイズは、8列、10行で16ビット

仕様
xを4回、右シフトしたものがキャラクターRAMのx
yを4回、右シフトしたものがキャラクターRAMのy
キャラクターRAMのキャラクターを読み取って
16ビット漢字ROMのxを0x0fでアンドしたものがパターンの列
yを0x0fでアンドしたものがパターンの行
16倍したものが各16ビット漢字ROMの先頭

●　てきとうな、ラクガキ

![o_coq155.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/840352/174bb58f-832b-42b4-5a21-a9df0206891c.jpeg)



オンラインコンパイラ

```c++

#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    printf("\nSTART\n\n");
    for(int y=0;y<16;y++){
        for(int x=0;x<(16*3);x++){
        
        
        printf("%d",0);
        
        
        }//for x
        printf("\n");
    }//for y
    
}//main

```


```


START

000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000

```





オンラインコンパイラ

````c++


//漢字ROM
int ch_data7[16 * 7] = {
0xf7ff, 0xf007, 0xf7f7, 0xf7f7, 0xf7f7, 0xf007, 0xf7f7, 0xf7f7, //月
0xf7f7, 0xf007, 0xf7f7, 0xeff7, 0xdff7, 0xdfc7, 0xbfe7, 0xffff, 
0xfeff, 0xfeff, 0xeef7, 0xeeef, 0xeedf, 0xeebf, 0xeeff, 0xfeff, //火
0xfeff, 0xfeff, 0xfd7f, 0xfbbf, 0xe7df, 0xdfef, 0xbfe7, 0xffff, 
0xffff, 0xfeff, 0xfef7, 0xfecf, 0xc0bf, 0xfc7f, 0xfc7f, 0xfa7f, //水
0xf6bf, 0xf6df, 0xeedf, 0xeeef, 0xdaef, 0xfcf7, 0xfeff, 0xffff, 
0xffff, 0xfeff, 0xfeff, 0xfeff, 0xc007, 0xfc7f, 0xfc7f, 0xfabf, //木
0xfabf, 0xf6df, 0xf6df, 0xeeef, 0xeeef, 0xdef7, 0xfeff, 0xffff, 
0xfe3f, 0xfdbf, 0xfbdf, 0xe7ef, 0x9ff3, 0xf01f, 0xfeff, 0xfeff, //金
0xfeff, 0xe00f, 0xfeff, 0xfeef, 0xf6df, 0xfabf, 0xc007, 0xffff, 
0xffff, 0xffff, 0xfeff, 0xfeff, 0xfeff, 0xfeff, 0xfeff, 0xe00f, //土
0xfeff, 0xfeff, 0xfeff, 0xfeff, 0xfeff, 0xfeff, 0x8003, 0xffff, 
0xffff, 0xc007, 0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xc007, //日
0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xc007, 0xffff
};

#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    printf("\nSTART\n\n");
    int a;int ch;
    for(int y=0;y<16;y++){
        for(int x=0;x<(16*3);x++){
        
        ch = 0;
        a = 0x8000 & (ch_data7[ (y & 0x0f ) + (ch * 16) ] << ( x & 0x0f) ) ;
        a = a >> 15;
        printf("%d ",a);
        
        }//for x
        printf("\n");
    }//for y
    
}//main 













START

1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 
1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 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 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 
1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 0 0 1 1 1 
1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 







//漢字ROM
int ch_data7[16 * 7] = {
0xf7ff, 0xf007, 0xf7f7, 0xf7f7, 0xf7f7, 0xf007, 0xf7f7, 0xf7f7, //月
0xf7f7, 0xf007, 0xf7f7, 0xeff7, 0xdff7, 0xdfc7, 0xbfe7, 0xffff, 
0xfeff, 0xfeff, 0xeef7, 0xeeef, 0xeedf, 0xeebf, 0xeeff, 0xfeff, //火
0xfeff, 0xfeff, 0xfd7f, 0xfbbf, 0xe7df, 0xdfef, 0xbfe7, 0xffff, 
0xffff, 0xfeff, 0xfef7, 0xfecf, 0xc0bf, 0xfc7f, 0xfc7f, 0xfa7f, //水
0xf6bf, 0xf6df, 0xeedf, 0xeeef, 0xdaef, 0xfcf7, 0xfeff, 0xffff, 
0xffff, 0xfeff, 0xfeff, 0xfeff, 0xc007, 0xfc7f, 0xfc7f, 0xfabf, //木
0xfabf, 0xf6df, 0xf6df, 0xeeef, 0xeeef, 0xdef7, 0xfeff, 0xffff, 
0xfe3f, 0xfdbf, 0xfbdf, 0xe7ef, 0x9ff3, 0xf01f, 0xfeff, 0xfeff, //金
0xfeff, 0xe00f, 0xfeff, 0xfeef, 0xf6df, 0xfabf, 0xc007, 0xffff, 
0xffff, 0xffff, 0xfeff, 0xfeff, 0xfeff, 0xfeff, 0xfeff, 0xe00f, //土
0xfeff, 0xfeff, 0xfeff, 0xfeff, 0xfeff, 0xfeff, 0x8003, 0xffff, 
0xffff, 0xc007, 0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xc007, //日
0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xdff7, 0xc007, 0xffff
};

char st_p[3][8] = {
    {'0', '1', '2'},
    {' ', ' ', ' '}
};


#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    printf("\nSTART\n\n");
    int a;int ch;
    for(int y=0;y<16;y++){
        for(int x=0;x<(16*3);x++){
        
        ch = st_p[y >> 4][x >> 4] - '0';;
        a = 0x8000 & (ch_data7[ (y & 0x0f ) + (ch * 16) ] << ( x & 0x0f) ) ;
        a = a >> 15;
        printf("%d ",a);
        
        }//for x
        printf("\n");
    }//for y
    
}//main




START

1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 
1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 0 1 1 1 
1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 1 1 1 1 
1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1 1 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 0 1 1 1 1 1 1 
1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 
1 1 1 1 0 1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