Subversion Repositories Shiroi

Rev

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

Rev 2 Rev 3
Line 1... Line 1...
1
/* $Id: shiroi.c 2 2024-08-28 08:12:18Z nishi $ */
1
/* $Id: shiroi.c 3 2024-08-28 09:19:04Z 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);
7
void putstr(char*);
7
void putstr(char*);
8
void scroll_y(void);
8
void scroll_y(void);
9
void beep(void);
9
void beep(void);
10
void _beep(unsigned long howlong);
10
void _beep(unsigned long howlong);
11
void init_cards(void);
11
void init_cards(void);
-
 
12
void print_ptr(void*);
-
 
13
char getch(void);
12
 
14
 
13
unsigned short posx;
15
unsigned short posx;
14
unsigned short posy;
16
unsigned short posy;
15
 
17
 
16
short vdp_addr;
18
short vdp_addr;
17
short vdp_data;
19
short vdp_data;
18
short psg_addr;
20
short psg_addr;
19
short psg_data;
21
short psg_data;
20
short fpu_addr;
22
short fpu_addr;
21
short fpu_data;
23
short fpu_data;
-
 
24
short text_kbd_data;
-
 
25
 
-
 
26
unsigned char basicbuffer[1024 * 30];
22
 
27
 
23
void main(void){
28
void main(void){
24
	int i;
29
	int i;
25
 
30
 
26
	posx = 0;
31
	posx = 0;
27
	posy = 0;
32
	posy = 0;
28
 
33
 
29
	vdp_addr = -1;
34
	vdp_addr = -1;
30
	psg_addr = -1;
35
	psg_addr = -1;
31
	fpu_addr = -1;
36
	fpu_addr = -1;
-
 
37
	text_kbd_data = -1;
32
 
38
 
33
	init_cards();
39
	init_cards();
34
 
40
 
35
	if(vdp_addr == -1){
41
	if(vdp_addr == -1){
36
		int i;
42
		int i;
Line 56... Line 62...
56
 
62
 
57
	outp(vdp_addr, 0xf4);
63
	outp(vdp_addr, 0xf4);
58
	outp(vdp_addr, 0x87);
64
	outp(vdp_addr, 0x87);
59
 
65
 
60
	write_vram(0);
66
	write_vram(0);
61
	for(i = 0; i < 0x800; i++) outp(vdp_data, *((unsigned char*)(0x2000 + i)));
67
	for(i = 0; i < 0x800; i++) outp(vdp_data, *((unsigned char*)(0x6000 - 2048 + i)));
62
 
68
 
63
	beep();
69
	beep();
64
 
70
 
65
	putstr("Shiroi Microcomputer BASIC\r\n");
71
	putstr("Shiroi Microcomputer BASIC\r\n");
66
	if(fpu_addr == -1){
-
 
67
		putstr("Math Card Mark I not present\r\n");
-
 
68
	}else{
-
 
69
		putstr("Math Card Mark I present\r\n");
-
 
70
	}
-
 
71
	if(psg_addr == -1){
72
	if(psg_addr == -1){
72
		putstr("Sound Card Mark I not present\r\n");
73
		putstr("Sound Card Mark I not present\r\n");
73
	}else{
74
	}else{
74
		putstr("Sound Card Mark I present\r\n");
75
		putstr("Sound Card Mark I present\r\n");
75
	}
76
	}
-
 
77
	if(fpu_addr == -1){
-
 
78
		putstr("Math  Card Mark I not present\r\n");
-
 
79
	}else{
-
 
80
		putstr("Math  Card Mark I present\r\n");
-
 
81
	}
-
 
82
	if(text_kbd_data == -1){
-
 
83
		putstr("Text  Card Mark I not present\r\n");
-
 
84
		putstr("Text  Card Mark I is required to use the BASIC\r\n");
-
 
85
		putstr("Halted. Get one.\r\n");
-
 
86
		while(1);
-
 
87
	}else{
-
 
88
		putstr("Text  Card Mark I present\r\n");
-
 
89
	}
76
 
90
 
77
	write_vram(0x800 + 40 * 12);
91
	write_vram(0x800 + 40 * 12);
78
	for(i = 0; i < 0x100; i++) outp(vdp_data, i);
92
	for(i = 0; i < 0x100; i++) outp(vdp_data, i);
-
 
93
	while(1){
-
 
94
		putchar(getch());
-
 
95
	}
-
 
96
}
-
 
97
 
-
 
98
char getch(void){
-
 
99
	char k = 0;
-
 
100
	while((k = inp(text_kbd_data)) == 0);
-
 
101
	while(inp(text_kbd_data) != 0);
-
 
102
	return k;
-
 
103
}
79
 
104
 
-
 
105
void print_ptr(void* ptr){
-
 
106
	unsigned short p = (unsigned short)ptr;
80
	while(1);
107
	int i;
-
 
108
	const char hex[] = "0123456789ABCDEF";
-
 
109
	putstr("0x");
-
 
110
	for(i = 0; i < 4; i++){
-
 
111
		putchar(hex[(p & 0xf000) >> 12]);
-
 
112
		p = p << 4;
-
 
113
	}
81
}
114
}
82
 
115
 
83
void init_cards(void){
116
void init_cards(void){
84
	int i;
117
	int i;
85
	int port = 2;
118
	int port = 2;
Line 93... Line 126...
93
				psg_addr = port - 2;
126
				psg_addr = port - 2;
94
				psg_data = port - 1;
127
				psg_data = port - 1;
95
			}else if(t == 0x21){
128
			}else if(t == 0x21){
96
				fpu_addr = port - 2;
129
				fpu_addr = port - 2;
97
				fpu_data = port - 1;
130
				fpu_data = port - 1;
-
 
131
			}else if(t == 0x22){
-
 
132
				text_kbd_data = port - 2;
98
			}
133
			}
-
 
134
 
99
		}
135
		}
100
		port += 3;
136
		port += 3;
101
	}
137
	}
102
}
138
}
103
 
139