Subversion Repositories Shiroi

Rev

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

Rev 20 Rev 28
Line 1... Line 1...
1
/* $Id: text.c 20 2024-08-31 06:50:57Z nishi $ */
1
/* $Id: text.c 28 2024-08-31 12:49:20Z nishi $ */
2
 
2
 
3
#include "text.h"
3
#include "text.h"
4
 
4
 
5
#include "video.h"
5
#include "video.h"
6
#include "math.h"
6
#include "math.h"
Line 8... Line 8...
8
#include "../char.h"
8
#include "../char.h"
9
#include "../io.h"
9
#include "../io.h"
10
 
10
 
11
char caps;
11
char caps;
12
 
12
 
13
unsigned short posx;
13
short posx;
14
unsigned short posy;
14
short posy;
15
unsigned short curx;
15
short curx;
16
unsigned short cury;
16
short cury;
17
unsigned char cursorcolor;
17
unsigned char cursorcolor;
18
unsigned char cursorindex;
18
unsigned char cursorindex;
19
 
19
 
20
short text_kbd_data;
20
short text_kbd_data;
21
 
21
 
Line 77... Line 77...
77
		putchar(hex[(p & 0xf000) >> 12]);
77
		putchar(hex[(p & 0xf000) >> 12]);
78
		p = p << 4;
78
		p = p << 4;
79
	}
79
	}
80
}
80
}
81
 
81
 
-
 
82
unsigned short charbuf;
-
 
83
 
82
void cursor(void){
84
void cursor(void){
83
	setvramaddr(muli(posy, scrwidth) + posx);
85
	setvramaddr(muli(posy, scrwidth) + posx);
84
	_vramchar(136 + 8 * cursorcolor);
86
	_vramchar(136 + 8 * cursorcolor);
85
	cursorindex++;
87
	cursorindex++;
86
	if(cursorindex == 2){
88
	if(cursorindex == 2){
Line 96... Line 98...
96
	}
98
	}
97
}
99
}
98
 
100
 
99
void killcursor(void){
101
void killcursor(void){
100
	setvramaddr(muli(cury, scrwidth) + curx);
102
	setvramaddr(muli(cury, scrwidth) + curx);
-
 
103
	if(charbuf == 0xffff){
101
	vramchar(' ');
104
		vramchar(' ');
-
 
105
	}else{
-
 
106
		vramchar(charbuf & 0xff);
-
 
107
	}
102
}
108
}
103
 
109
 
104
void putchar(char c){
110
void putchar(char c){
105
	if(c == '\r'){
111
	if(c == '\r'){
106
		posx = 0;
112
		posx = 0;
107
	}else if(c == '\n'){
113
	}else if(c == '\n'){
108
		posy++;
114
		posy++;
-
 
115
	}else if(c == 0x08){
-
 
116
		if(posx > 0){
-
 
117
			posx--;
-
 
118
		}else{
-
 
119
			posy--;
-
 
120
			posx = scrwidth - 1;
-
 
121
		}
-
 
122
		setreadvramaddr(muli(posy, scrwidth) + posx);
-
 
123
		charbuf = getvramchar();
109
	}else{
124
	}else{
110
		setvramaddr(muli(posy, scrwidth) + posx);
125
		setvramaddr(muli(posy, scrwidth) + posx);
111
		vramchar(c);
126
		vramchar(c);
112
		posx++;
127
		posx++;
113
		if(posx == scrwidth){
128
		if(posx == scrwidth){
Line 133... Line 148...
133
	curx = 0;
148
	curx = 0;
134
	cury = 0;
149
	cury = 0;
135
	caps = 0;
150
	caps = 0;
136
	cursorcolor = 0;
151
	cursorcolor = 0;
137
	cursorindex = 0;
152
	cursorindex = 0;
-
 
153
	charbuf = 0xffff;
138
}
154
}
139
 
155
 
140
void text_card(int t, int port){
156
void text_card(int t, int port){
141
	if(t == 0x22){
157
	if(t == 0x22){
142
		text_kbd_data = port - 2;
158
		text_kbd_data = port - 2;