Subversion Repositories Shiroi

Rev

Rev 3 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 4
Line 1... Line 1...
1
/* $Id: shiroi.c 3 2024-08-28 09:19:04Z nishi $ */
1
/* $Id: shiroi.c 4 2024-08-28 10:07:23Z nishi $ */
2
 
2
 
3
unsigned char inp(unsigned char);
3
unsigned char inp(unsigned char);
4
void outp(unsigned char, unsigned char);
4
void outp(unsigned char, unsigned char);
5
void write_vram(unsigned short);
5
void write_vram(unsigned short);
6
void putchar(char);
6
void putchar(char);
Line 21... Line 21...
21
short psg_data;
21
short psg_data;
22
short fpu_addr;
22
short fpu_addr;
23
short fpu_data;
23
short fpu_data;
24
short text_kbd_data;
24
short text_kbd_data;
25
 
25
 
-
 
26
char caps;
-
 
27
 
-
 
28
unsigned char keylist[13 * 4];
-
 
29
unsigned char keylist_caps[13 * 4];
-
 
30
 
26
unsigned char basicbuffer[1024 * 30];
31
unsigned char basicbuffer[1024 * 30];
27
 
32
 
28
void main(void){
33
void main(void){
29
	int i;
34
	int i;
-
 
35
	caps = 0;
-
 
36
 
-
 
37
/*
-
 
38
 * / 1 2 3 4 5 6 7 8 9 10 11 12 13
-
 
39
 * 1 1 2 3 4 5 6 7 8 9 0  -  =  
-
 
40
 * 2 q w e r t y u i o p  [  ]  rt
-
 
41
 * 3 a s d f g h j k l ;  '  \  cl
-
 
42
 * 4 z x c v b n m , . /  sp
-
 
43
 */
-
 
44
	const char* keys;
-
 
45
 
-
 
46
	keys = "1234567890-= ";
-
 
47
	for(i = 0; i < 13; i++){
-
 
48
		keylist[i] = keys[i];
-
 
49
	}
-
 
50
	keys = "qwertyuiop[]\n";
-
 
51
	for(i = 0; i < 13; i++){
-
 
52
		keylist[13 + i] = keys[i];
-
 
53
	}
-
 
54
	keys = "asdfghjkl;'\\!";
-
 
55
	for(i = 0; i < 13; i++){
-
 
56
		keylist[26 + i] = keys[i];
-
 
57
	}
-
 
58
	keys = "zxcvbnm,./    ";
-
 
59
	for(i = 0; i < 13; i++){
-
 
60
		keylist[39 + i] = keys[i];
-
 
61
	}
-
 
62
 
-
 
63
	keys = "!@#$%^&*()_+ ";
-
 
64
	for(i = 0; i < 13; i++){
-
 
65
		keylist_caps[i] = keys[i];
-
 
66
	}
-
 
67
	keys = "QWERTYUIOP{}\n";
-
 
68
	for(i = 0; i < 13; i++){
-
 
69
		keylist_caps[13 + i] = keys[i];
-
 
70
	}
-
 
71
	keys = "ASDFGHJKL:\"|!";
-
 
72
	for(i = 0; i < 13; i++){
-
 
73
		keylist_caps[26 + i] = keys[i];
-
 
74
	}
-
 
75
	keys = "ZXCVBNM<>?    ";
-
 
76
	for(i = 0; i < 13; i++){
-
 
77
		keylist_caps[39 + i] = keys[i];
-
 
78
	}
30
 
79
 
31
	posx = 0;
80
	posx = 0;
32
	posy = 0;
81
	posy = 0;
33
 
82
 
34
	vdp_addr = -1;
83
	vdp_addr = -1;
Line 64... Line 113...
64
	outp(vdp_addr, 0x87);
113
	outp(vdp_addr, 0x87);
65
 
114
 
66
	write_vram(0);
115
	write_vram(0);
67
	for(i = 0; i < 0x800; i++) outp(vdp_data, *((unsigned char*)(0x6000 - 2048 + i)));
116
	for(i = 0; i < 0x800; i++) outp(vdp_data, *((unsigned char*)(0x6000 - 2048 + i)));
68
 
117
 
69
	beep();
118
//	beep();
70
 
119
 
71
	putstr("Shiroi Microcomputer BASIC\r\n");
120
	putstr("Shiroi Microcomputer BASIC\r\n");
72
	if(psg_addr == -1){
121
	if(psg_addr == -1){
73
		putstr("Sound Card Mark I not present\r\n");
122
		putstr("Sound Card Mark I not present\r\n");
74
	}else{
123
	}else{
75
		putstr("Sound Card Mark I present\r\n");
124
		putstr("Sound Card Mark I     present\r\n");
76
	}
125
	}
77
	if(fpu_addr == -1){
126
	if(fpu_addr == -1){
78
		putstr("Math  Card Mark I not present\r\n");
127
		putstr("Math  Card Mark I not present\r\n");
79
	}else{
128
	}else{
80
		putstr("Math  Card Mark I present\r\n");
129
		putstr("Math  Card Mark I     present\r\n");
81
	}
130
	}
82
	if(text_kbd_data == -1){
131
	if(text_kbd_data == -1){
83
		putstr("Text  Card Mark I not present\r\n");
132
		putstr("Text  Card Mark I not present\r\n");
84
		putstr("Text  Card Mark I is required to use the BASIC\r\n");
133
		putstr("Text  Card Mark I is required to use the BASIC\r\n");
85
		putstr("Halted. Get one.\r\n");
134
		putstr("Halted. Get one.\r\n");
86
		while(1);
135
		while(1);
87
	}else{
136
	}else{
88
		putstr("Text  Card Mark I present\r\n");
137
		putstr("Text  Card Mark I     present\r\n");
89
	}
138
	}
90
 
139
 
91
	write_vram(0x800 + 40 * 12);
-
 
92
	for(i = 0; i < 0x100; i++) outp(vdp_data, i);
-
 
93
	while(1){
140
	while(1){
94
		putchar(getch());
141
		putchar(getch());
95
	}
142
	}
96
}
143
}
97
 
144
 
98
char getch(void){
145
char getch(void){
99
	char k = 0;
146
	char k = 0;
-
 
147
rep:
100
	while((k = inp(text_kbd_data)) == 0);
148
	while((k = inp(text_kbd_data)) == 0);
101
	while(inp(text_kbd_data) != 0);
149
	while(inp(text_kbd_data) != 0);
-
 
150
	unsigned char top = (k & 0xf0) >> 4;
-
 
151
	unsigned char bot = (k & 0x0f);
-
 
152
	top--;
-
 
153
	bot--;
-
 
154
	if(keylist[top * 13 + bot] == '!'){
-
 
155
		caps = caps == 0 ? 1 : 0;
102
	return k;
156
		goto rep;
-
 
157
	}
-
 
158
	return caps ? keylist_caps[top * 13 + bot] : keylist[top * 13 + bot];
103
}
159
}
104
 
160
 
105
void print_ptr(void* ptr){
161
void print_ptr(void* ptr){
106
	unsigned short p = (unsigned short)ptr;
162
	unsigned short p = (unsigned short)ptr;
107
	int i;
163
	int i;