Subversion Repositories Tewi

Rev

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

Rev 191 Rev 193
Line 1... Line 1...
1
/* $Id: main.c 191 2024-09-29 05:11:20Z nishi $ */
1
/* $Id: main.c 193 2024-09-29 05:55:18Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "../config.h"
5
#include "../config.h"
6
 
6
 
Line 306... Line 306...
306
int tt_width;
306
int tt_width;
307
int tt_height;
307
int tt_height;
308
 
308
 
309
void tt_putstr(const char* str) {
309
void tt_putstr(const char* str) {
310
	int i;
310
	int i;
311
	for(i = 0; str[i] != 0; i++){
311
	for(i = 0; str[i] != 0; i++) {
312
		tvram[tt_y * tt_width + tt_x] = str[i];
312
		tvram[tt_y * tt_width + tt_x] = str[i];
313
		if(str[i] == '\n'){
313
		if(str[i] == '\n') {
314
			tt_x = 0;
314
			tt_x = 0;
315
			tt_y++;
315
			tt_y++;
316
		}else{
316
		} else {
317
			tt_x++;
317
			tt_x++;
318
			if(tt_x == tt_width){
318
			if(tt_x == tt_width) {
319
				tt_x = 0;
319
				tt_x = 0;
320
				tt_y++;
320
				tt_y++;
321
			}
321
			}
322
		}
322
		}
323
		if(tt_y == tt_height){
323
		if(tt_y == tt_height) {
324
			tt_y--;
324
			tt_y--;
325
			int x, y;
325
			int x, y;
326
			for(y = 0; y < tt_height - 1; y++){
326
			for(y = 0; y < tt_height - 1; y++) {
327
				for(x = 0; x < tt_width; x++){
327
				for(x = 0; x < tt_width; x++) {
328
					tvram[y * tt_width + x] = tvram[(y + 1) * tt_width + x];
328
					tvram[y * tt_width + x] = tvram[(y + 1) * tt_width + x];
329
				}
329
				}
330
			}
330
			}
331
			for(x = 0; x < tt_width; x++){
331
			for(x = 0; x < tt_width; x++) {
332
				tvram[(tt_height - 1) * tt_width + x] = 0;
332
				tvram[(tt_height - 1) * tt_width + x] = 0;
333
			}
333
			}
334
		}
334
		}
335
	}
335
	}
336
}
336
}
337
 
337
 
338
void tt_putchar(struct rsx_buffer* buffer, int x, int y, uint8_t c){
338
void tt_putchar(struct rsx_buffer* buffer, int x, int y, uint8_t c) {
339
	int i, j;
339
	int i, j;
340
	if(c < 0x20) c = 0x20;
340
	if(c < 0x20) c = 0x20;
341
	if(c >= 0x7f) c = 0x20;
341
	if(c >= 0x7f) c = 0x20;
342
	for(i = 0; i < 7; i++){
342
	for(i = 0; i < 7; i++) {
343
		uint8_t l = font[(c - 0x20) * 8 + i];
343
		uint8_t l = font[(c - 0x20) * 8 + i];
344
		for(j = 0; j < 5; j++){
344
		for(j = 0; j < 5; j++) {
345
			uint32_t c = 0;
345
			uint32_t c = 0;
346
			if(l & (1 << 7)){
346
			if(l & (1 << 7)) {
347
				c = 0xffffff;
347
				c = 0xffffff;
348
			}
348
			}
349
			l = l << 1;
349
			l = l << 1;
350
			buffer->ptr[(y * 8 + i) * buffer->width + x * 6 + j] = c;
350
			buffer->ptr[(y * 8 + i) * buffer->width + x * 6 + j] = c;
351
		}
351
		}
Line 385... Line 385...
385
	cbuf[1] = 0;
385
	cbuf[1] = 0;
386
	char* log = cm_strdup("");
386
	char* log = cm_strdup("");
387
	for(i = 0; tmpl[i] != 0; i++) {
387
	for(i = 0; tmpl[i] != 0; i++) {
388
		if(tmpl[i] == '%') {
388
		if(tmpl[i] == '%') {
389
			i++;
389
			i++;
390
			if(tmpl[i] == 's'){
390
			if(tmpl[i] == 's') {
391
				char* tmp = log;
391
				char* tmp = log;
392
				log = cm_strcat(tmp, va_arg(va, char*));
392
				log = cm_strcat(tmp, va_arg(va, char*));
393
				free(tmp);
393
				free(tmp);
394
			}else if(tmpl[i] == 'd'){
394
			} else if(tmpl[i] == 'd') {
395
				char buf[513];
395
				char buf[513];
396
				sprintf(buf, "%d", va_arg(va, int));
396
				sprintf(buf, "%d", va_arg(va, int));
397
				char* tmp = log;
397
				char* tmp = log;
398
				log = cm_strcat(tmp, buf);
398
				log = cm_strcat(tmp, buf);
399
				free(tmp);
399
				free(tmp);
400
			}else if(tmpl[i] == '%'){
400
			} else if(tmpl[i] == '%') {
401
				char* tmp = log;
401
				char* tmp = log;
402
				log = cm_strcat(tmp, "%");
402
				log = cm_strcat(tmp, "%");
403
				free(tmp);
403
				free(tmp);
404
			}
404
			}
405
		} else {
405
		} else {