Subversion Repositories Shiroi

Rev

Rev 9 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9 Rev 12
Line 1... Line 1...
1
/* $Id: text.c 9 2024-08-28 16:35:27Z nishi $ */
1
/* $Id: text.c 12 2024-08-29 04:19:08Z nishi $ */
2
 
2
 
3
#include "text.h"
3
#include "text.h"
4
 
4
 
5
#include "char.h"
5
#include "char.h"
6
#include "video.h"
6
#include "video.h"
Line 11... Line 11...
11
 
11
 
12
unsigned short posx;
12
unsigned short posx;
13
unsigned short posy;
13
unsigned short posy;
14
unsigned short curx;
14
unsigned short curx;
15
unsigned short cury;
15
unsigned short cury;
-
 
16
unsigned char cursorcolor;
-
 
17
unsigned char cursorindex;
16
 
18
 
17
short text_kbd_data;
19
short text_kbd_data;
18
 
20
 
19
extern int scrwidth;
21
extern int scrwidth;
20
extern int scrheight;
22
extern int scrheight;
21
 
23
 
22
extern unsigned char keylist[];
24
extern unsigned char keylist[];
23
extern unsigned char keylist_caps[];
25
extern unsigned char keylist_caps[];
24
 
26
 
-
 
27
char agetch(void){
-
 
28
	char k;
-
 
29
rep:
-
 
30
	if((k = inp(text_kbd_data)) == 0) return 0;
-
 
31
	while(inp(text_kbd_data) != 0);
-
 
32
	unsigned char top = (k & 0xf0) >> 4;
-
 
33
	unsigned char bot = (k & 0x0f);
-
 
34
	top--;
-
 
35
	bot--;
-
 
36
	if(keylist[top * 13 + bot] == '!'){
-
 
37
		caps = caps == 0 ? 1 : 0;
-
 
38
		goto rep;
-
 
39
	}
-
 
40
	return caps ? keylist_caps[top * 13 + bot] : keylist[top * 13 + bot];
-
 
41
}
-
 
42
 
25
char getch(void){
43
char getch(void){
26
	char k = 0;
44
	char k = 0;
27
rep:
45
rep:
28
	while((k = inp(text_kbd_data)) == 0);
46
	while((k = inp(text_kbd_data)) == 0);
29
	while(inp(text_kbd_data) != 0);
47
	while(inp(text_kbd_data) != 0);
Line 70... Line 88...
70
	}
88
	}
71
}
89
}
72
 
90
 
73
void cursor(void){
91
void cursor(void){
74
	setvramaddr(mull(posy, scrwidth) + posx);
92
	setvramaddr(mull(posy, scrwidth) + posx);
-
 
93
	_vramchar(136 + 8 * cursorcolor);
75
	vramchar(248);
94
	cursorindex++;
-
 
95
	if(cursorindex == 2){
-
 
96
		cursorcolor++;
-
 
97
		cursorindex = 0;
-
 
98
		if(cursorcolor == 15) cursorcolor = 0;
-
 
99
	}
76
	curx = posx;
100
	curx = posx;
77
	cury = posy;
101
	cury = posy;
78
	if(curx == scrwidth){
102
	if(curx == scrwidth){
79
		curx = 0;
103
		curx = 0;
80
		cury++;
104
		cury++;
Line 116... Line 140...
116
	posx = 0;
140
	posx = 0;
117
	posy = 0;
141
	posy = 0;
118
	curx = 0;
142
	curx = 0;
119
	cury = 0;
143
	cury = 0;
120
	caps = 0;
144
	caps = 0;
-
 
145
	cursorcolor = 0;
-
 
146
	cursorindex = 0;
121
}
147
}
122
 
148
 
123
void text_card(int t, int port){
149
void text_card(int t, int port){
124
	if(t == 0x22){
150
	if(t == 0x22){
125
		text_kbd_data = port - 2;
151
		text_kbd_data = port - 2;