Subversion Repositories Shiroi

Rev

Rev 9 | Rev 12 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 nishi 1
/* $Id: shiroi.c 10 2024-08-29 01:39:27Z nishi $ */
2
 
8 nishi 3
#include "io.h"
9 nishi 4
#include "math.h"
5
#include "sound.h"
8 nishi 6
#include "video.h"
7
#include "text.h"
8
#include "char.h"
9
 
1 nishi 10
void init_cards(void);
7 nishi 11
void basic(void);
1 nishi 12
 
8 nishi 13
extern short vdp_addr;
14
extern short vdp_data;
15
extern short vdg_addr;
16
extern short vdg_data;
7 nishi 17
 
8 nishi 18
extern short psg_addr;
19
extern short psg_data;
7 nishi 20
 
8 nishi 21
extern short fpu_stack;
22
extern short fpu_command;
7 nishi 23
 
8 nishi 24
extern short text_kbd_data;
1 nishi 25
 
8 nishi 26
extern int scrwidth;
27
extern int scrheight;
1 nishi 28
 
8 nishi 29
extern char caps;
7 nishi 30
 
4 nishi 31
unsigned char keylist[13 * 4];
32
unsigned char keylist_caps[13 * 4];
33
 
2 nishi 34
void main(void){
1 nishi 35
	int i;
36
 
4 nishi 37
/*
38
 * / 1 2 3 4 5 6 7 8 9 10 11 12 13
7 nishi 39
 * 1 1 2 3 4 5 6 7 8 9 0  -  =  bs
4 nishi 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
5 nishi 43
 *
44
 * When Caps Lock
45
 *
46
 * / 1 2 3 4 5 6 7 8 9 10 11 12 13
7 nishi 47
 * 1 ! @ # $ % ^ & * ( )  _  +  bs
5 nishi 48
 * 2 Q W E R T Y U I O P  {  }  rt
49
 * 3 A S D F G H J K L :  "  |  cl
50
 * 4 Z X C V B N M < > ?  sp
4 nishi 51
 */
52
	const char* keys;
53
 
7 nishi 54
	keys = "1234567890-=\x08";
4 nishi 55
	for(i = 0; i < 13; i++){
56
		keylist[i] = keys[i];
57
	}
58
	keys = "qwertyuiop[]\n";
59
	for(i = 0; i < 13; i++){
60
		keylist[13 + i] = keys[i];
61
	}
62
	keys = "asdfghjkl;'\\!";
63
	for(i = 0; i < 13; i++){
64
		keylist[26 + i] = keys[i];
65
	}
66
	keys = "zxcvbnm,./    ";
67
	for(i = 0; i < 13; i++){
68
		keylist[39 + i] = keys[i];
69
	}
70
 
7 nishi 71
	keys = "!@#$%^&*()_+\x08";
4 nishi 72
	for(i = 0; i < 13; i++){
73
		keylist_caps[i] = keys[i];
74
	}
75
	keys = "QWERTYUIOP{}\n";
76
	for(i = 0; i < 13; i++){
77
		keylist_caps[13 + i] = keys[i];
78
	}
79
	keys = "ASDFGHJKL:\"|!";
80
	for(i = 0; i < 13; i++){
81
		keylist_caps[26 + i] = keys[i];
82
	}
83
	keys = "ZXCVBNM<>?    ";
84
	for(i = 0; i < 13; i++){
85
		keylist_caps[39 + i] = keys[i];
86
	}
87
 
1 nishi 88
	vdp_addr = -1;
7 nishi 89
	vdg_addr = -1;
1 nishi 90
	psg_addr = -1;
7 nishi 91
	fpu_stack = -1;
3 nishi 92
	text_kbd_data = -1;
1 nishi 93
 
94
	init_cards();
95
 
8 nishi 96
#ifdef ONLY_VDP
97
	if(vdp_addr == -1){
98
#else
7 nishi 99
	if(vdp_addr == -1 && vdg_addr == -1){
8 nishi 100
#endif
1 nishi 101
		int i;
2 nishi 102
		for(i = 0; i < 3; i++){
1 nishi 103
			_beep(3L * 1024);
104
			unsigned long j;
2 nishi 105
			for(j = 0; j < 3L * 1024; j++);
1 nishi 106
		}
2 nishi 107
		while(1);
1 nishi 108
	}
109
 
8 nishi 110
	video_init();
111
	text_init();
1 nishi 112
 
7 nishi 113
	clear();
1 nishi 114
 
10 nishi 115
	beep();
1 nishi 116
 
3 nishi 117
	if(text_kbd_data == -1){
118
		putstr("Text  Card Mark I not present\r\n");
119
		putstr("Text  Card Mark I is required to use the BASIC\r\n");
120
		putstr("Halted. Get one.\r\n");
121
		while(1);
122
	}
7 nishi 123
	if(fpu_stack == -1){
124
		putstr("Math  Card Mark I not present\r\n");
125
		putstr("Math  Card Mark I is required to use the BASIC\r\n");
126
		putstr("Halted. Get one.\r\n");
127
		while(1);
128
	}
1 nishi 129
 
7 nishi 130
	int incr;
131
	int move = 0;
132
	char k;
133
	int wait = 0;
134
 
135
	const char* title;
136
 
8 nishi 137
#ifdef ONLY_VDP
7 nishi 138
	if(vdp_addr != -1){
8 nishi 139
#else
140
	if(vdp_addr != -1 || vdg_addr != -1){
141
#endif
7 nishi 142
		title = "Shiroi Microcomputer";
8 nishi 143
		setvramaddr(scrwidth / 2 - strlen(title) / 2 + mull((scrheight - 9) / 2 - 1 + 3, scrwidth));
144
		for(i = 0; title[i] != 0; i++) vramchar(title[i]);
7 nishi 145
 
8 nishi 146
		if(vdp_addr != -1){
147
			title = "\x82 2024 Nishi";
148
		}else if(vdg_addr != -1){
149
			title = "(C) 2024 Nishi";
150
		}
151
		setvramaddr(scrwidth / 2 - strlen(title) / 2 + mull(scrheight - 2, scrwidth));
152
		for(i = 0; title[i] != 0; i++) vramchar(title[i]);
7 nishi 153
 
154
		title = "Press any key to begin";
8 nishi 155
		setvramaddr(scrwidth / 2 - strlen(title) / 2 + mull((scrheight - 9) / 2 + 1 + 3, scrwidth));
156
		for(i = 0; title[i] != 0; i++) vramchar(title[i]);
7 nishi 157
	}
158
 
159
move_bar:
160
	if(vdp_addr != -1){
8 nishi 161
	}
162
#ifndef ONLY_VDP
163
	else if(vdg_addr != -1){
7 nishi 164
		goto skip;
165
	}
8 nishi 166
#endif
7 nishi 167
	incr = move;
168
	for(i = 0; i < 16; i++){
169
		int j;
170
		for(j = 0; j < 3; j++){
171
			int p = incr;
172
			if(p >= 15) p = p - 15;
173
			if(wait == 0){
8 nishi 174
				setvramaddr(i * 2 + j * 32);
175
				_vramchar((p + 1) * 8 + 0x80);
176
				_vramchar((p + 1) * 8 + 0x80);
177
				setvramaddr(i * 2 + 32 * 20 - j * 32);
178
				_vramchar((p + 1) * 8 + 0x80);
179
				_vramchar((p + 1) * 8 + 0x80);
7 nishi 180
			}else{
181
				if(i * 2 - 1 < 0){
8 nishi 182
					setvramaddr(i * 2 + j * 32);
183
					_vramchar((p + 1) * 8 + 0x80);
7 nishi 184
				}else{
8 nishi 185
					setvramaddr(i * 2 + j * 32 - 1);
186
					_vramchar((p + 1) * 8 + 0x80);
187
					_vramchar((p + 1) * 8 + 0x80);
7 nishi 188
				}
189
				if(i * 2 - 1 < 0){
8 nishi 190
					setvramaddr(i * 2 + 32 * 20 - j * 32);
191
					_vramchar((p + 1) * 8 + 0x80);
7 nishi 192
				}else{
8 nishi 193
					setvramaddr(i * 2 + 32 * 20 - j * 32 - 1);
194
					_vramchar((p + 1) * 8 + 0x80);
195
					_vramchar((p + 1) * 8 + 0x80);
7 nishi 196
				}
197
			}
198
		}
199
		incr++;
200
		if(incr == 15) incr = 0;
201
	}
202
	wait++;
203
	if(wait == 2){
204
		wait = 0;
205
		move++;
206
		if(move == 15) move = 0;
207
	}
208
	for(i = 0; i < 3 * 1024; i++);
209
 
210
skip:
211
	if((k = inp(text_kbd_data)) == 0) goto move_bar;
212
	while(inp(text_kbd_data) != 0);
213
 
214
	if(vdp_addr == -1){
215
		outp(vdp_addr, 0xf0);
216
		outp(vdp_addr, 0x87);
217
	}
218
 
8 nishi 219
	basic();
3 nishi 220
}
1 nishi 221
 
2 nishi 222
void init_cards(void){
1 nishi 223
	int i;
224
	int port = 2;
2 nishi 225
	for(i = 0; i < 256 / 3; i++){
1 nishi 226
		int t = inp(port);
2 nishi 227
		if(t != 0){
8 nishi 228
			video_card(t, port);
9 nishi 229
			sound_card(t, port);
230
			math_card(t, port);
8 nishi 231
			text_card(t, port);
1 nishi 232
		}
233
		port += 3;
234
	}
235
}