Subversion Repositories Krakow BASIC

Rev

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

Rev 9 Rev 28
Line 1... Line 1...
1
/* $Id: basic.c 9 2024-09-04 15:25:47Z nishi $ */
1
/* $Id: basic.c 28 2024-09-05 00:13:42Z nishi $ */
2
 
2
 
3
/* Krakow BASIC - Multi-platform simple BASIC */
3
/* Krakow BASIC - Multi-platform simple BASIC */
4
 
4
 
5
#if defined(PLATFORM_SHIROI)
5
#if defined(PLATFORM_SHIROI)
6
 
6
 
Line 16... Line 16...
16
 
16
 
17
#elif defined(PLATFORM_UNIX) || defined(PLATFORM_WINDOWS) || defined(PLATFORM_ARDUINO) || defined(PLATFORM_C64) || defined(PLATFORM_A800XL) || defined(PLATFORM_APPLE2) || defined(PLATFORM_PET)
17
#elif defined(PLATFORM_UNIX) || defined(PLATFORM_WINDOWS) || defined(PLATFORM_ARDUINO) || defined(PLATFORM_C64) || defined(PLATFORM_A800XL) || defined(PLATFORM_APPLE2) || defined(PLATFORM_PET)
18
 
18
 
19
#if defined(PLATFORM_WINDOWS)
19
#if defined(PLATFORM_WINDOWS)
20
#define PLATFORM "Windows"
20
#define PLATFORM "Windows"
-
 
21
#define NO_PEEKPOKE
21
#elif defined(PLATFORM_UNIX)
22
#elif defined(PLATFORM_UNIX)
22
#define PLATFORM "Unix"
23
#define PLATFORM "Unix"
-
 
24
#define NO_PEEKPOKE
23
#elif defined(PLATFORM_ARDUINO)
25
#elif defined(PLATFORM_ARDUINO)
24
#define PLATFORM "Arduino"
26
#define PLATFORM "Arduino"
25
#define NEWLINE "\r\n"
27
#define NEWLINE "\r\n"
26
#define BREAKKEY
28
#define BREAKKEY
27
#elif defined(PLATFORM_C64)
29
#elif defined(PLATFORM_C64)
Line 349... Line 351...
349
				stack[sp] += hexnum(ownbuf[i]);
351
				stack[sp] += hexnum(ownbuf[i]);
350
			} else {
352
			} else {
351
				stack[sp] += ownbuf[i] - '0';
353
				stack[sp] += ownbuf[i] - '0';
352
			}
354
			}
353
			put = 1;
355
			put = 1;
-
 
356
#ifndef NO_PEEKPOKE
354
		} else if(ownbuf[i] == 'R') {
357
		} else if(ownbuf[i] == 'R') {
355
			put = 0;
358
			put = 0;
356
			hex = 0;
359
			hex = 0;
357
			if(sp < 1) {
360
			if(sp < 1) {
358
				return -1;
361
				return -1;
359
			} else {
362
			} else {
360
				int top = stack[--sp];
363
				int top = stack[--sp];
361
				stack[sp++] = (int)*(unsigned char*)top;
364
				stack[sp++] = (int)*(unsigned char*)top;
362
			}
365
			}
363
			stack[sp] = 0;
366
			stack[sp] = 0;
-
 
367
#endif
364
		} else if(ownbuf[i] == '+' || ownbuf[i] == '-' || ownbuf[i] == '*' || ownbuf[i] == '/') {
368
		} else if(ownbuf[i] == '+' || ownbuf[i] == '-' || ownbuf[i] == '*' || ownbuf[i] == '/') {
365
			put = 0;
369
			put = 0;
366
			hex = 0;
370
			hex = 0;
367
			if(sp < 2) {
371
			if(sp < 2) {
368
				return -1;
372
				return -1;
Line 506... Line 510...
506
				putnum(linenum);
510
				putnum(linenum);
507
			}
511
			}
508
			putstr(NEWLINE);
512
			putstr(NEWLINE);
509
			return 1;
513
			return 1;
510
		}
514
		}
-
 
515
#ifndef NO_PEEKPOKE
511
	} else if(strcaseequ(rcmd, "POKE")) {
516
	} else if(strcaseequ(rcmd, "POKE")) {
512
		int argc = 0;
517
		int argc = 0;
513
		char* farg = 0;
518
		char* farg = 0;
514
		char* sarg = 0;
519
		char* sarg = 0;
515
		int addr, data, ret0, ret1;
520
		int addr, data, ret0, ret1;
Line 572... Line 577...
572
				putnum(linenum);
577
				putnum(linenum);
573
			}
578
			}
574
			putstr(NEWLINE);
579
			putstr(NEWLINE);
575
			return 1;
580
			return 1;
576
		}
581
		}
-
 
582
#endif
577
	} else if(num == 0 && strcaseequ(rcmd, "LIST")) {
583
	} else if(num == 0 && strcaseequ(rcmd, "LIST")) {
578
		int addr = BUFFER_SIZE - 1;
584
		int addr = BUFFER_SIZE - 1;
579
		int saddr = 0;
585
		int saddr = 0;
580
		int lbuf[LINES];
586
		int lbuf[LINES];
581
		int shift[LINES];
587
		int shift[LINES];