26 static short int X, Y;
27 static const short int MX = 80, MY = 40;
28 static u32 bgcolor, fontcolor, cursorcolor;
29 static short int cursor;
31 static u32 defcols[16];
53 static int debug_detect_signal()
57 return ((romname[4] ==
'E') ? 1 : 0);
60 static void Init_GS(
int interlace,
int omode,
int ffmd)
67 SetGsCrt(interlace, omode, ffmd);
70 static void SetVideoMode(
void)
87 static inline void Dma02Wait(
void)
92 static void DmaReset(
void)
95 *((vu32 *)0x1000a080) = 0;
117 static inline void progdma(
const void *addr,
int size)
124 void scr_setbgcolor(u32 color)
129 void scr_setfontcolor(u32 color)
134 static int hex2int(
char c)
136 if (c >=
'0' && c <=
'9')
141 if (c >=
'A' && c <=
'F')
147 void scr_change_defaultcolor(
int index, u32 color) {
148 defcols[index] = color;
151 void scr_setfontcolorescape(
char n1,
char n2)
153 int bg = hex2int(n1);
154 int fg = hex2int(n2);
157 bgcolor = defcols[bg];
160 fontcolor = defcols[fg];
163 void scr_setcursorcolor(u32 color)
168 static const struct t_setupscr g_setupscr_template = {
169 {0x100000000000800E, 0xE, 0xA0000, 0x4C, 0x8C, 0x4E},
173 {0x40, 1, 0x1a, 1, 0x46, 0, 0x45, 0x70000,
174 0x47, 0x30000, 0x47, 6, 0, 0x3F80000000000000, 1, 0x79006C00, 5,
175 0x87009400, 5, 0x70000, 0x47}
182 *((
struct t_setupscr *)UNCACHED_SEG(&setupscr)) = g_setupscr_template;
185 scr_setfontcolor(0xffffff);
186 scr_setcursorcolor(0xffffff);
187 defcols[0] = 0x000000;
188 defcols[1] = 0xDA3700;
189 defcols[2] = 0xDD963A;
190 defcols[3] = 0x981788;
191 defcols[4] = 0x1F0FC5;
192 defcols[5] = 0xCCCCCC;
193 defcols[6] = 0x009CC1;
194 defcols[7] = 0x767676;
195 defcols[8] = 0xFF783B;
196 defcols[9] = 0xD6D661;
197 defcols[10] = 0x0CC616;
198 defcols[11] = 0x9E00B4;
199 defcols[12] = 0x5648E7;
200 defcols[13] = 0xF2F2F2;
201 defcols[14] = 0xA5F1F9;
202 defcols[15] = 0xFFFFFF;
207 Init_GS(1, debug_detect_signal() == 1 ? 3 : 2, 0);
215 extern const u8 msx[];
217 static const struct t_setupchar g_setupchar_template = {
218 {0x1000000000000004, 0xE, 0xA000000000000, 0x50},
224 {0x52, 0, 0x53, 0x800000000008010, 0}
227 void scr_putchar(
int x,
int y, u32 color,
int ch)
236 *((
struct t_setupchar *)UNCACHED_SEG(&setupchar)) = g_setupchar_template;
237 ((
struct t_setupchar *)UNCACHED_SEG(&setupchar))->x = x;
238 ((
struct t_setupchar *)UNCACHED_SEG(&setupchar))->y = y;
243 for (i = l = 0; i < 8; i++, l += 8, font++) {
244 for (j = 0; j < 8; j++) {
245 pixel = ((*font & (128 >> j))) ? color : bgcolor;
246 *(u32 *)UNCACHED_SEG(&charmap[l + j]) = pixel;
252 progdma(charmap, (8 * 8 * 4) / 16);
256 void scr_clearchar(
int X,
int Y)
258 scr_putchar(X * 8, Y * 8, bgcolor,
' ');
261 void scr_clearline(
int Y)
264 for (i = 0; i < MX; i++)
265 scr_putchar(i * 8, Y * 8, bgcolor,
' ');
268 void scr_printf(
const char *format, ...)
271 va_start(opt, format);
272 scr_vprintf(format, opt);
276 void scr_vprintf(
const char *format, va_list opt)
282 bufsz = vsnprintf(buff,
sizeof(buff), format, opt);
284 for (i = 0; i < bufsz; i++) {
296 for (j = 0; j < 5; j++) {
297 scr_putchar(X * 7, Y * 8, fontcolor,
' ');
305 if (i+2 < bufsz && isxdigit((
unsigned char)buff[i+1]) && isxdigit((
unsigned char)buff[i+2])) {
306 scr_setfontcolorescape(buff[i+1], buff[i+2]);
311 scr_putchar(X * 7, Y * 8, fontcolor, c);
323 scr_putchar(X * 7, Y * 8, cursorcolor, 219);
326 void scr_setXY(
int x,
int y)
328 if (x < MX && x >= 0)
330 if (y < MY && y >= 0)
347 for (y = 0; y < MY; y++)
352 void scr_setCursor(
int enable)