Subversion Repositories Shiroi

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8 nishi 1
/* $Id: basic.c 29 2024-08-31 17:41:43Z nishi $ */
2
 
18 nishi 3
#include "dri/text.h"
8 nishi 4
 
29 nishi 5
#include "char.h"
8 nishi 6
 
29 nishi 7
#define BUFFER_SIZE (1024 * 16)
8
 
9
unsigned char basicbuffer[BUFFER_SIZE];
10
char linebuf[1024];
11
 
8 nishi 12
void basic(void){
13
	clear();
14
 
15
	putstr("Shiroi Microcomputer BASIC\r\n");
19 nishi 16
	putstr("Copyright 2024 by Nishi\r\n");
29 nishi 17
	putnum(BUFFER_SIZE);
18
	putstr(" bytes free\r\n");
8 nishi 19
	cursor();
29 nishi 20
	linebuf[0] = 0;
28 nishi 21
	int lineind = 0;
8 nishi 22
	while(1){
12 nishi 23
		char c = agetch();
20 nishi 24
		if(c != 0) killcursor();
25
		if(c == 1){
26
			putstr("Break\r\n");
28 nishi 27
			lineind = 0;
20 nishi 28
		}else if(c == '\n'){
29 nishi 29
			linebuf[lineind] = 0;
8 nishi 30
			putstr("\r\n");
28 nishi 31
			lineind = 0;
32
		}else if(c == 0x8){
33
			if(lineind > 0){
34
				putstr("\x08 \x08");
35
				lineind--;
36
			}
12 nishi 37
		}else if(c != 0){
8 nishi 38
			putchar(c);
29 nishi 39
			linebuf[lineind++] = c;
8 nishi 40
		}
41
		cursor();
42
	}
43
}