sdccでmsx その３

#概要
sdccでmsxに、日本語表示してみた。
#開発環境
SDCC : ver2.8.1
ruMSX : ver0.41
#写真
![nihon.jpg](https://qiita-image-store.s3.amazonaws.com/0/18104/b497b56f-ce66-b0aa-2d39-939856917cde.jpeg)

#MakeFile
```
All : nihon.hex nihon.rom
nihon.hex : nihon.o
	sdcc -V -mz80 --no-std-crt0 --code-loc 0x4020 --data-loc 0x8000 -o nihon.hex  nihon.o
nihon.rom : nihon.hex
	hex2rom nihon.hex nihon.rom
nihon.o : nihon.c
	sdcc -V -mz80 nihon.c
```
#サンプルコード
```
#define	CHPUT	    #0x00A2
#define	CHGET 	    #0x009F
#define	CHGMOD 	    #0x005F
#define	WRTVRM 	    #0x004D
#define	RDVRM 	    #0x004A
void pset(int x, int y);
int vramr(unsigned int ad);
void vram(unsigned int ad, char c);
void setg(char c);
void wait(int t);
void putchar(char c);
int  getchar();
void main(void)	
{
    unsigned int ad;
    char t[] = {
0x30, 0x31, 0x32, 0x33, 0x34, 0x31, 0x32, 0x33, 0x35, 0x36, 0x37, 0x38, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 
0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x3b, 0x42, 0x43, 0x44, 0x3b, 0x45, 0x33, 0x46, 0x47, 0x48, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 
0x3e, 0x3f, 0x40, 0x41, 0x3b, 0x42, 0x43, 0x49, 0x4a, 0x4b, 0x33, 0x4c, 0x31, 0x32, 0x33, 0x4d, 0x4e, 0x3b, 0x39, 0x3a, 
0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x3b, 0x42, 0x43, 0x4f, 0x50, 0x4b, 0x33, 0x4c, 0x31, 0x32, 0x33, 0x51, 0x52, 
0x53, 0x54, 0x37, 0x55, 0x56, 0x57, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x3b, 0x42, 0x43, 0x58, 0x4b,
 0x33, 0x4c, 0x31, 0x32, 0x33, 0x3b, 0x59, 0x5a, 0x3b, 0x33, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 
0x3e, 0x3f, 0x40, 0x41, 0x3b, 0x42, 0x43, 0x60, 0x61, 0x62, 0x4b, 0x33, 0x4c, 0x31, 0x32, 0x33, 0x51, 0x52, 0x53, 0x63, 
0x33, 0x64, 0x65, 0x54, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x3b, 0x42, 0x43, 0x66, 0x40, 0x67, 0x48,
 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x37, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x3b, 0x42, 0x43, 0x6d, 0x62, 0x4b, 0x33, 0x4c, 0x31, 
0x32, 0x33, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x3d, 0x3e, 0x3f, 0x40, 0x41,
 0x3b, 0x42, 0x43, 0x46, 0x56, 0x57, 0x40, 0x7b, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x3b, 0x42, 0x43, 
0x7c, 0x7d, 0x4b, 0x33, 0x4c, 0x31, 0x32, 0x33, 0x4d, 0x7e, 0x7f, 0x80, 0x81, 0x3b, 0x76, 0x82, 0x83, 0x84, 0x3b, 0x81, 
0x5f, 0x6a, 0x6b, 0x41, 0x75, 0x5d, 0x85, 0x3b, 0x42, 0x43, 0x6d, 0x4a, 0x86, 0x33, 0x87, 0x4a, 0x86, 0x33, 0x88, 0x4a, 
0x86, 0x33, 0x49, 0x89, 0x8a, 0x8b, 0x5d, 0x33, 0x8c, 0x85, 0x89, 0x8a, 0x8b, 0x5d, 0x33, 0x8d, 0x8e, 0x86, 0x33, 0x8f, 
0x61, 0x86, 0x33, 0x90, 0x91, 0x89, 0x8a, 0x8b, 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c, 0x50, 0xbe, 0x0, 
0x3e, 0x42, 0xde, 0x56, 0x5e, 0x42, 0x46, 0x0, 
0x10, 0xfe, 0x44, 0x44, 0xaa, 0xfe, 0x10, 0x0, 
0x50, 0xdc, 0x28, 0xc8, 0x3e, 0xc8, 0xc8, 0x0, 
0x10, 0xfe, 0x92, 0x7c, 0x28, 0x18, 0xe6, 0x0, 
0x3c, 0x8, 0x10, 0x3c, 0x42, 0x32, 0x3c, 0x0, 
0x0, 0x3c, 0x0, 0x0, 0x20, 0x40, 0x3e, 0x0, 
0x4, 0x8, 0x30, 0x40, 0x30, 0x8, 0x4, 0x0, 
0x66, 0xbe, 0x56, 0xde, 0x76, 0x7c, 0x44, 0x0, 
0x28, 0xfe, 0x28, 0xfe, 0x10, 0x7c, 0x7c, 0x0, 
0x54, 0xfe, 0x92, 0x7c, 0x14, 0x24, 0xcc, 0x0, 
0x20, 0x10, 0x20, 0x64, 0x62, 0xa4, 0x3c, 0x0, 
0xee, 0x42, 0xe2, 0xee, 0xa8, 0xea, 0xee, 0x0, 
0x54, 0xfc, 0x54, 0x7e, 0xd4, 0x7c, 0xc4, 0x0, 
0xf4, 0x26, 0x5a, 0xfa, 0x6a, 0x34, 0xca, 0x0, 
0x0, 0x38, 0x54, 0x92, 0xa2, 0x44, 0x18, 0x0, 
0x3a, 0x6e, 0xfe, 0x6e, 0x7a, 0x42, 0x6a, 0x0, 
0x28, 0xfe, 0x38, 0xfe, 0x44, 0xba, 0x38, 0x0, 
0x30, 0x8, 0x40, 0x5c, 0x62, 0x2, 0x3c, 0x0 
        };
	char c;
	int i, x, y;
	putchar(12);
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	putchar('\n');
	i = 0;
	ad = 0x1800;
    	for (i = 0;i <= 439; i++)    
        {
		vram(ad, t[i]);
		ad = ad + 1;
        }
	ad = 0x0180;
        for (i = 0; i <= 139 * 8; i++)    
        {
		vram(ad,f[i]);
		ad = ad + 1;
	}
	putchar(getchar());
}
void putchar(char c)	
{
	_asm
	ld	a, 4(ix)
	call	CHPUT
	_endasm;
}
int getchar()	
{
	_asm
	call		CHGET
	ld		l, a
	ld		h, #0
	_endasm;
}
void wait(int t)	
{
	while(t--);
}
void setg(char c)	
{
	_asm
	ld	        a, 4(ix)
	call		CHGMOD
	_endasm;
}
void vram(unsigned int ad, char c)	
{
	_asm
	ld		l, 4(ix)
	ld		h, 5(ix)
	ld		a, 6(ix)
	call		WRTVRM 
	_endasm;
}
int vramr(unsigned int ad)	
{
	_asm
	ld		l, 4(ix)
	ld		h, 5(ix)
	call		RDVRM
	ld		l, a
	ld		h, #0
	_endasm;
}
void pset(int x, int y)
{
	unsigned int ad;
	char b, c;
	int i, j, k;
	c = 0x01;
	ad = (x / 8) * 8 + (y % 8) + (y / 8) * 256;
	i = x % 8;
	if (i== 7) c = 0x01;
	if (i== 6) c = 0x02;
	if (i== 5) c = 0x04;
	if (i== 4) c = 0x08;
 	if (i== 3) c = 0x10;
	if (i== 2) c = 0x20;
	if (i== 1) c = 0x40;
	if (i== 0) c = 0x80;
	j = vramr(ad);
	c = c | j;
	vram(ad, c);
}

```