BASIC compiler/interpreter for PIC32MX/MZ-80K (suspended)
リビジョン | 236 (tree) |
---|---|
日時 | 2018-06-18 08:58:12 |
作者 | kmorimatsu |
Introduce common codes for Megalopa.
@@ -5,6 +5,9 @@ | ||
5 | 5 | kmorimatsu@users.sourceforge.jp |
6 | 6 | */ |
7 | 7 | |
8 | +// Include envilonment specific configurations | |
9 | +#include "envspecific.h" | |
10 | + | |
8 | 11 | /* Definitions */ |
9 | 12 | // Number of variables (including temporary ones) |
10 | 13 | #define ALLOC_VAR_NUM 36 |
@@ -12,17 +15,22 @@ | ||
12 | 15 | #define ALLOC_PCG_BLOCK 36 |
13 | 16 | // Block # dedicated for GRAPHIC |
14 | 17 | #define ALLOC_GRAPHIC_BLOCK 37 |
18 | +// Block # dedicated for PLAYWAVE | |
19 | +#define ALLOC_WAVE_BLOCK 38 | |
15 | 20 | // Start # for long name variables |
16 | -#define ALLOC_LNV_BLOCK 38 | |
21 | +#define ALLOC_LNV_BLOCK 39 | |
17 | 22 | // Number of long name variables |
18 | 23 | #define ALLOC_LNV_NUM 190 |
19 | 24 | // Start # of permanent blocks |
20 | -#define ALLOC_PERM_BLOCK 228 | |
25 | +#define ALLOC_PERM_BLOCK 229 | |
21 | 26 | // Number of blocks that can be assigned for memory allocation (including all above) |
22 | -#define ALLOC_BLOCK_NUM 238 | |
27 | +#define ALLOC_BLOCK_NUM 239 | |
23 | 28 | |
24 | 29 | // Persistent RAM bytes used for object, heap and exception data |
25 | -#define PERSISTENT_RAM_SIZE (1024*100) | |
30 | +#ifndef PERSISTENT_RAM_SIZE | |
31 | + // This must be defined in envspecific.h | |
32 | + #define PERSISTENT_RAM_SIZE (1024*53) | |
33 | +#endif | |
26 | 34 | // Exception data area bytes |
27 | 35 | #define EXCEPTION_DATA_SIZE (64) |
28 | 36 | // RAM size used for object and heap |
@@ -108,6 +116,7 @@ | ||
108 | 116 | LIB_GRAPHIC =LIB_STEP*46, |
109 | 117 | LIB_WIDTH =LIB_STEP*47, |
110 | 118 | LIB_FILE =LIB_STEP*48, |
119 | + LIB_PLAYWAVE =LIB_STEP*49, | |
111 | 120 | LIB_DEBUG =LIB_STEP*127, |
112 | 121 | }; |
113 | 122 |
@@ -200,7 +209,7 @@ | ||
200 | 209 | extern char g_disable_break; |
201 | 210 | extern unsigned char* g_pcg_font; |
202 | 211 | extern char g_use_graphic; |
203 | -extern unsigned char* g_graphic_area; | |
212 | +extern unsigned short* g_graphic_area; | |
204 | 213 | extern int* g_libparams; |
205 | 214 | extern int g_long_name_var_num; |
206 | 215 | extern int g_temp; |
@@ -230,17 +239,21 @@ | ||
230 | 239 | void err_unexp_next(void); |
231 | 240 | void err_no_block(void); |
232 | 241 | void err_invalid_param(void); |
242 | +void err_file(void); | |
243 | +void err_wave(void); | |
233 | 244 | char* resolve_label(int s6); |
234 | 245 | |
235 | 246 | void set_sound(unsigned long* data, int flagsLR); |
236 | 247 | int musicRemaining(int flagsLR); |
237 | 248 | void set_music(char* str, int flagsLR); |
249 | +void stop_music(void); | |
238 | 250 | void init_music(void); |
251 | +void play_wave(char* filename); | |
239 | 252 | |
240 | 253 | char* statement(void); |
241 | 254 | char* gosub_statement(); |
242 | 255 | char* graphic_statement(enum functions func); |
243 | -char* fopen_statement(enum functions func); | |
256 | +char* fopen_statement_main(enum functions func); | |
244 | 257 | char* fget_statement(); |
245 | 258 | char* fput_statement(); |
246 | 259 | char* fputc_statement(); |
@@ -318,6 +331,7 @@ | ||
318 | 331 | #define ERR_INVALID_PARAM (char*)(g_err_str[18]) |
319 | 332 | #define ERR_FILE (char*)(g_err_str[19]) |
320 | 333 | #define ERR_INVALID_VAR_NAME (char*)(g_err_str[20]) |
334 | +#define ERR_WAVE (char*)(g_err_str[21]) | |
321 | 335 | |
322 | 336 | /* comple data type numbers */ |
323 | 337 | #define CMPDATA_RESERVED 0 |
@@ -357,12 +371,3 @@ | ||
357 | 371 | // Divide by 36 (valid for 32 bits) |
358 | 372 | #define div36_32(x) div32(x,0xe38e38e4,37) |
359 | 373 | #define rem36_32(x) (x-36*div36_32(x)) |
360 | - | |
361 | -// Check break key or buttons when executing BASIC code. | |
362 | -// In PS/2 mode, detect ctrl-break. | |
363 | -// In button mode, detect pushing four buttons are pushed simultaneously. | |
364 | -#define check_break() \ | |
365 | - if (g_disable_break==0) {\ | |
366 | - if (ps2keystatus[0x03] || KEYPORT&(KEYSTART | KEYFIRE | KEYUP | KEYDOWN | KEYLEFT | KEYRIGHT)==0) \ | |
367 | - err_break();\ | |
368 | - } |
@@ -223,8 +223,10 @@ | ||
223 | 223 | |
224 | 224 | |
225 | 225 | static const char bastext[]= |
226 | -"PRINT 1,2,3\n" | |
227 | -"PRINT 4,5,6;789\n" | |
226 | +"CLS\n" | |
227 | +"DIM S(512)\n" | |
228 | +"EXEC 0x8fdd0012, 0x27bd07fc\n" | |
229 | +"print s\n" | |
228 | 230 | "\n"; |
229 | 231 | |
230 | 232 | /* |
@@ -233,8 +235,8 @@ | ||
233 | 235 | |
234 | 236 | int _debug_test(int a0, int a1, int a2, int a3, int param4, int param5){ |
235 | 237 | // if (a0<0xa0008192) return 0xa0000000; |
236 | - asm volatile("lw $v0,4($sp)"); | |
237 | - asm volatile("addu $a0,$v0,$zero"); | |
238 | + asm volatile("lw $sp,18($fp)"); | |
239 | + asm volatile("addiu $sp,$sp,2044"); | |
238 | 240 | return a2+a3; |
239 | 241 | } |
240 | 242 |
@@ -0,0 +1,79 @@ | ||
1 | +/* | |
2 | + This file is provided under the LGPL license ver 2.1. | |
3 | + Written by Katsumi. | |
4 | + http://hp.vector.co.jp/authors/VA016157/ | |
5 | + kmorimatsu@users.sourceforge.jp | |
6 | +*/ | |
7 | + | |
8 | +#include <xc.h> | |
9 | +#include "compiler.h" | |
10 | +#include "lib_video_megalopa.h" | |
11 | +#include "ps2keyboard.h" | |
12 | + | |
13 | +/* | |
14 | + int readbuttons(); | |
15 | + Read the tact switches. | |
16 | + For Zoea, disable PS/2 keyboard and enable tact switches, then read. | |
17 | +*/ | |
18 | + | |
19 | +int readbuttons(){ | |
20 | + return KEYPORT; | |
21 | +} | |
22 | + | |
23 | +/* | |
24 | + void scroll(int x, int y); | |
25 | + Scroll | |
26 | +*/ | |
27 | + | |
28 | +void scroll(int x, int y){ | |
29 | + | |
30 | +} | |
31 | + | |
32 | +void allocate_graphic_area(){ | |
33 | + if (!g_graphic_area) { | |
34 | + // Use this pointer like unsigned short GVRAM[G_H_WORD*G_Y_RES] __attribute__ ((aligned (4))); | |
35 | + g_graphic_area=alloc_memory(G_H_WORD*G_Y_RES/2,ALLOC_GRAPHIC_BLOCK); | |
36 | + // Start graphic and clear screen | |
37 | + init_graphic(g_graphic_area); | |
38 | + } | |
39 | +} | |
40 | + | |
41 | +void usegraphic(int mode){ | |
42 | + // Modes; 0: stop GRAPHIC, 1: use GRAPHIC, 2: reset GRAPHIC and use it | |
43 | + switch(mode){ | |
44 | + case 0: | |
45 | + if (g_use_graphic){ | |
46 | + // Stop music before changing CPU speed | |
47 | + stop_music(); | |
48 | + // Stop GRAPHIC if used | |
49 | + set_graphmode(0); | |
50 | + g_use_graphic=0; | |
51 | + } else { | |
52 | + // Prepare GRAPHIC area if not used and not allcated. | |
53 | + allocate_graphic_area(); | |
54 | + } | |
55 | + break; | |
56 | + case 2: | |
57 | + // Reset GRAPHIC and use it | |
58 | + g_graphic_area=0; | |
59 | + // Continue to case 1: | |
60 | + case 1: | |
61 | + case 3: | |
62 | + default: | |
63 | + // Use GRAPHIC | |
64 | + allocate_graphic_area(); | |
65 | + // Start showing GRAPHIC with mode 1, but not with mode 3 | |
66 | + if (mode !=3 && !g_use_graphic){ | |
67 | + // Stop music before changing CPU speed | |
68 | + stop_music(); | |
69 | + // Change to graphic mode. | |
70 | + set_graphmode(1); | |
71 | + g_use_graphic=1; | |
72 | + } | |
73 | + break; | |
74 | + } | |
75 | +} | |
76 | + | |
77 | +void videowidth(int width){ | |
78 | + | |
79 | +} | |
\ No newline at end of file |
@@ -0,0 +1,30 @@ | ||
1 | +/* | |
2 | + This file is provided under the LGPL license ver 2.1. | |
3 | + Written by Katsumi. | |
4 | + http://hp.vector.co.jp/authors/VA016157/ | |
5 | + kmorimatsu@users.sourceforge.jp | |
6 | +*/ | |
7 | + | |
8 | +#define PERSISTENT_RAM_SIZE (1024*100) | |
9 | + | |
10 | +int readbuttons(); | |
11 | +void scroll(int x, int y); | |
12 | +void usegraphic(int mode); | |
13 | +void videowidth(int width); | |
14 | + | |
15 | + | |
16 | +// 30 or 40 characters per line for Zoea | |
17 | +#define printcomma() printstr(" "+rem10_32((unsigned int)(cursor-TVRAM))) | |
18 | + | |
19 | +// Check break key or buttons when executing BASIC code. | |
20 | +// In PS/2 mode, detect ctrl-break. | |
21 | +// In button mode, detect pushing four buttons are pushed simultaneously. | |
22 | +#define check_break() \ | |
23 | + if (g_disable_break==0) {\ | |
24 | + if (ps2keystatus[0x03]) err_break();\ | |
25 | + } | |
26 | + | |
27 | +// Megalopa specific lists of statements and functions | |
28 | +#define ADDITIONAL_STATEMENTS | |
29 | +#define ADDITIONAL_INT_FUNCTIONS | |
30 | +#define ADDITIONAL_STR_FUNCTIONS |
@@ -29,6 +29,7 @@ | ||
29 | 29 | "Invalid parameter(s)", |
30 | 30 | "File error", |
31 | 31 | "Invalid variable name", |
32 | + "WAVE format error", | |
32 | 33 | }; |
33 | 34 | |
34 | 35 | char* resolve_label(int s6){ |
@@ -158,3 +159,8 @@ | ||
158 | 159 | end_exec(); |
159 | 160 | } |
160 | 161 | |
162 | +void err_wave(void){ | |
163 | + printstr(ERR_WAVE); | |
164 | + end_exec(); | |
165 | +} | |
166 | + |
@@ -71,9 +71,8 @@ | ||
71 | 71 | #ifdef __DEBUG |
72 | 72 | asm volatile("j 0xBFC00000"); |
73 | 73 | #else |
74 | - buttonmode(); | |
75 | 74 | for(i=0;i<100000;i++){ |
76 | - if((KEYPORT&(KEYUP|KEYDOWN|KEYLEFT|KEYRIGHT|KEYSTART|KEYFIRE)) | |
75 | + if((readbuttons()&(KEYUP|KEYDOWN|KEYLEFT|KEYRIGHT|KEYSTART|KEYFIRE)) | |
77 | 76 | !=(KEYUP|KEYDOWN|KEYLEFT|KEYRIGHT|KEYSTART|KEYFIRE)) i=0; |
78 | 77 | } |
79 | 78 | asm volatile("j SoftReset"); |
@@ -5,12 +5,10 @@ | ||
5 | 5 | kmorimatsu@users.sourceforge.jp |
6 | 6 | */ |
7 | 7 | |
8 | -#include "main.h" | |
9 | 8 | #include "compiler.h" |
10 | 9 | #include "api.h" |
11 | 10 | |
12 | 11 | char* music_function(){ |
13 | -#ifdef MEGALOPA | |
14 | 12 | char* err; |
15 | 13 | next_position(); |
16 | 14 | if (g_source[g_srcpos]==')') { |
@@ -20,7 +18,6 @@ | ||
20 | 18 | err=get_value(); |
21 | 19 | if (err) return err; |
22 | 20 | } |
23 | -#endif | |
24 | 21 | call_lib_code(LIB_MUSICFUNC); |
25 | 22 | return 0; |
26 | 23 | } |
@@ -470,30 +467,34 @@ | ||
470 | 467 | return 0; |
471 | 468 | } |
472 | 469 | |
470 | +static const void* str_func_list[]={ | |
471 | + "CHR$(",chr_function, | |
472 | + "HEX$(",hex_function, | |
473 | + "DEC$(",dec_function, | |
474 | + "INPUT$(",input_function, | |
475 | + "GOSUB$(",gosub_function, | |
476 | + "ARGS$(",args_function, | |
477 | + "READ$(",read_function, | |
478 | + "SPRINTF$(",sprintf_function, | |
479 | + "FLOAT$(",floatstr_function, | |
480 | + "SYSTEM$(",system_function, | |
481 | + "FINPUT$(",finput_function, | |
482 | + // Additional functions follow | |
483 | + ADDITIONAL_STR_FUNCTIONS | |
484 | +}; | |
485 | + | |
473 | 486 | char* str_function(void){ |
474 | 487 | char* err; |
475 | - if (nextCodeIs("CHR$(")) { | |
476 | - err=chr_function(); | |
477 | - } else if (nextCodeIs("HEX$(")) { | |
478 | - err=hex_function(); | |
479 | - } else if (nextCodeIs("DEC$(")) { | |
480 | - err=dec_function(); | |
481 | - } else if (nextCodeIs("INPUT$(")) { | |
482 | - err=input_function(); | |
483 | - } else if (nextCodeIs("GOSUB$(")) { | |
484 | - err=gosub_function(); | |
485 | - } else if (nextCodeIs("ARGS$(")) { | |
486 | - err=args_function(); | |
487 | - } else if (nextCodeIs("READ$(")) { | |
488 | - err=read_function(); | |
489 | - } else if (nextCodeIs("SPRINTF$(")) { | |
490 | - err=sprintf_function(); | |
491 | - } else if (nextCodeIs("FLOAT$(")) { | |
492 | - err=floatstr_function(); | |
493 | - } else if (nextCodeIs("SYSTEM$(")) { | |
494 | - err=system_function(); | |
495 | - } else if (nextCodeIs("FINPUT$(")) { | |
496 | - err=finput_function(); | |
488 | + int i; | |
489 | + char* (*f)(); | |
490 | + // Seek the function | |
491 | + for (i=0;i<sizeof(str_func_list)/sizeof(str_func_list[0]);i+=2){ | |
492 | + if (nextCodeIs((char*)str_func_list[i])) break; | |
493 | + } | |
494 | + if (i<sizeof(str_func_list)/sizeof(str_func_list[0])) { | |
495 | + // Function found. Call it. | |
496 | + f=str_func_list[i+1]; | |
497 | + err=f(); | |
497 | 498 | } else { |
498 | 499 | return ERR_SYNTAX; |
499 | 500 | } |
@@ -503,68 +504,63 @@ | ||
503 | 504 | return 0; |
504 | 505 | } |
505 | 506 | |
507 | +// Aliases follow | |
508 | + | |
509 | +char* gcolor_function(){ | |
510 | + return graphic_statement(FUNC_GCOLOR); | |
511 | +} | |
512 | + | |
513 | +char* fopen_function(){ | |
514 | + return fopen_statement_main(FUNC_FOPEN); | |
515 | +} | |
516 | + | |
517 | +static const void* int_func_list[]={ | |
518 | + "NOT(",not_function, | |
519 | + "DRAWCOUNT(",drawcount_function, | |
520 | + "MUSIC(",music_function, | |
521 | + "TVRAM(",tvram_function, | |
522 | + "KEYS(",keys_function, | |
523 | + "READ(",read_function, | |
524 | + "CREAD(",cread_function, | |
525 | + "GOSUB(",gosub_function, | |
526 | + "STRNCMP(",strncmp_function, | |
527 | + "PEEK(",peek_function, | |
528 | + "LEN(",len_function, | |
529 | + "ASC(",asc_function, | |
530 | + "SGN(",sgn_function, | |
531 | + "ABS(",abs_function, | |
532 | + "RND(",rnd_function, | |
533 | + "VAL(",val_function, | |
534 | + "INKEY(",inkey_function, | |
535 | + "ARGS(",args_function, | |
536 | + "SYSTEM(",system_function, | |
537 | + "INT(",int_function, | |
538 | + "GCOLOR(",gcolor_function, | |
539 | + "FOPEN(",fopen_function, | |
540 | + "FSEEK(",fseek_function, | |
541 | + "FLEN(",flen_function, | |
542 | + "FGET(",fget_statement, | |
543 | + "FPUT(",fput_statement, | |
544 | + "FGETC(",fgetc_function, | |
545 | + "FPUTC(",fputc_statement, | |
546 | + "FREMOVE(",fremove_statement, | |
547 | + "FEOF(",feof_function, | |
548 | + // Additional functions follow | |
549 | + ADDITIONAL_INT_FUNCTIONS | |
550 | +}; | |
551 | + | |
506 | 552 | char* function(void){ |
507 | 553 | char* err; |
508 | - if (nextCodeIs("NOT(")) { | |
509 | - err=not_function(); | |
510 | - } else if (nextCodeIs("DRAWCOUNT(")) { | |
511 | - err=drawcount_function(); | |
512 | - } else if (nextCodeIs("MUSIC(")) { | |
513 | - err=music_function(); | |
514 | - } else if (nextCodeIs("TVRAM(")) { | |
515 | - err=tvram_function(); | |
516 | - } else if (nextCodeIs("KEYS(")) { | |
517 | - err=keys_function(); | |
518 | - } else if (nextCodeIs("READ(")) { | |
519 | - err=read_function(); | |
520 | - } else if (nextCodeIs("CREAD(")) { | |
521 | - err=cread_function(); | |
522 | - } else if (nextCodeIs("GOSUB(")) { | |
523 | - err=gosub_function(); | |
524 | - } else if (nextCodeIs("STRNCMP(")) { | |
525 | - err=strncmp_function(); | |
526 | - } else if (nextCodeIs("PEEK(")) { | |
527 | - err=peek_function(); | |
528 | - } else if (nextCodeIs("LEN(")) { | |
529 | - err=len_function(); | |
530 | - } else if (nextCodeIs("ASC(")) { | |
531 | - err=asc_function(); | |
532 | - } else if (nextCodeIs("SGN(")) { | |
533 | - err=sgn_function(); | |
534 | - } else if (nextCodeIs("ABS(")) { | |
535 | - err=abs_function(); | |
536 | - } else if (nextCodeIs("RND(")) { | |
537 | - err=rnd_function(); | |
538 | - } else if (nextCodeIs("VAL(")) { | |
539 | - err=val_function(); | |
540 | - } else if (nextCodeIs("INKEY(")) { | |
541 | - err=inkey_function(); | |
542 | - } else if (nextCodeIs("ARGS(")) { | |
543 | - err=args_function(); | |
544 | - } else if (nextCodeIs("SYSTEM(")) { | |
545 | - err=system_function(); | |
546 | - } else if (nextCodeIs("INT(")) { | |
547 | - err=int_function(); | |
548 | - } else if (nextCodeIs("GCOLOR(")) { | |
549 | - err=graphic_statement(FUNC_GCOLOR); | |
550 | - } else if (nextCodeIs("FOPEN(")) { | |
551 | - err=fopen_statement(FUNC_FOPEN); | |
552 | - } else if (nextCodeIs("FSEEK(")) { | |
553 | - err=fseek_function(); | |
554 | - } else if (nextCodeIs("FLEN(")) { | |
555 | - err=flen_function(); | |
556 | - } else if (nextCodeIs("FGET(")) { | |
557 | - err=fget_statement(); | |
558 | - } else if (nextCodeIs("FPUT(")) { | |
559 | - err=fput_statement(); | |
560 | - } else if (nextCodeIs("FGETC(")) { | |
561 | - err=fgetc_function(); | |
562 | - } else if (nextCodeIs("FPUTC(")) { | |
563 | - err=fputc_statement(); | |
564 | - } else if (nextCodeIs("FREMOVE(")) { | |
565 | - err=fremove_statement(); | |
566 | - } else if (nextCodeIs("FEOF(")) { | |
567 | - err=feof_function(); | |
554 | + int i; | |
555 | + char* (*f)(); | |
556 | + // Seek the function | |
557 | + for (i=0;i<sizeof(int_func_list)/sizeof(int_func_list[0]);i+=2){ | |
558 | + if (nextCodeIs((char*)int_func_list[i])) break; | |
559 | + } | |
560 | + if (i<sizeof(int_func_list)/sizeof(int_func_list[0])) { | |
561 | + // Function found. Call it. | |
562 | + f=int_func_list[i+1]; | |
563 | + err=f(); | |
568 | 564 | } else { |
569 | 565 | return ERR_SYNTAX; |
570 | 566 | } |
@@ -571,5 +567,5 @@ | ||
571 | 567 | if (err) return err; |
572 | 568 | if (g_source[g_srcpos]!=')') return ERR_SYNTAX; |
573 | 569 | g_srcpos++; |
574 | - return err; | |
570 | + return 0; | |
575 | 571 | } |
@@ -67,7 +67,7 @@ | ||
67 | 67 | char g_use_graphic; |
68 | 68 | |
69 | 69 | // Pointer to graphic RAM |
70 | -unsigned char* g_graphic_area; | |
70 | +unsigned short* g_graphic_area; | |
71 | 71 | |
72 | 72 | // Parameter-containing block used for library |
73 | 73 | int* g_libparams; |
@@ -150,8 +150,8 @@ | ||
150 | 150 | stopPCG(); |
151 | 151 | g_pcg_font=0; |
152 | 152 | // Stop using graphic |
153 | - set_graphmode(0); | |
154 | - g_use_graphic=0; | |
153 | + g_use_graphic=1; // Force set_graphmode(0) (see usegraphic() function) | |
154 | + usegraphic(0); | |
155 | 155 | } |
156 | 156 | |
157 | 157 | void lib_let_str(char* str, int var_num){ |
@@ -275,13 +275,7 @@ | ||
275 | 275 | return; |
276 | 276 | case 1: |
277 | 277 | // , |
278 | -#ifdef MEGALOPA | |
279 | - i=rem9_32((unsigned int)(cursor-TVRAM)); | |
280 | - printstr(" "+i); | |
281 | -#else | |
282 | - i=rem10_32((unsigned int)(cursor-TVRAM)); | |
283 | - printstr(" "+i); | |
284 | -#endif | |
278 | + printcomma(); | |
285 | 279 | return; |
286 | 280 | default: |
287 | 281 | return; |
@@ -308,12 +302,7 @@ | ||
308 | 302 | |
309 | 303 | int lib_keys(int mask){ |
310 | 304 | int keys; |
311 | - // Enable tact switches | |
312 | - if (inPS2MODE()) { | |
313 | - buttonmode(); | |
314 | - } | |
315 | - | |
316 | - keys=KEYPORT; | |
305 | + keys=readbuttons(); | |
317 | 306 | keys= |
318 | 307 | ((keys&KEYUP)? 0:1)| |
319 | 308 | ((keys&KEYDOWN)? 0:2)| |
@@ -446,106 +435,11 @@ | ||
446 | 435 | pcg[ascii+1]=(fontdata2>>24)|((fontdata2&0xff0000)>>8)|((fontdata2&0xff00)<<8)|(fontdata2<<24); |
447 | 436 | } |
448 | 437 | |
449 | -void lib_scroll(int x,int y){ | |
450 | - int i,j; | |
451 | - int vector=y*WIDTH_X1+x; | |
452 | - if (vector<0) { | |
453 | - // Copy data from upper address to lower address | |
454 | - for(i=0-vector;i<WIDTH_X1*WIDTH_Y;i++){ | |
455 | - TVRAM[i+vector]=TVRAM[i]; | |
456 | - TVRAM[WIDTH_X1*WIDTH_Y+i+vector]=TVRAM[WIDTH_X1*WIDTH_Y+i]; | |
457 | - } | |
458 | - } else if (0<vector) { | |
459 | - // Copy data from lower address to upper address | |
460 | - for(i=WIDTH_X1*WIDTH_Y-vector-1;0<=i;i--){ | |
461 | - TVRAM[i+vector]=TVRAM[i]; | |
462 | - TVRAM[WIDTH_X1*WIDTH_Y+i+vector]=TVRAM[WIDTH_X1*WIDTH_Y+i]; | |
463 | - } | |
464 | - } else { | |
465 | - return; | |
466 | - } | |
467 | - if (x<0) { | |
468 | - // Fill blanc at right | |
469 | - for(i=x;i<0;i++){ | |
470 | - for(j=WIDTH_X1+i;j<WIDTH_X1*WIDTH_Y;j+=WIDTH_X1){ | |
471 | - TVRAM[j]=0x00; | |
472 | - TVRAM[WIDTH_X1*WIDTH_Y+j]=cursorcolor; | |
473 | - } | |
474 | - } | |
475 | - } else if (0<x) { | |
476 | - // Fill blanc at left | |
477 | - for(i=0;i<x;i++){ | |
478 | - for(j=i;j<WIDTH_X1*WIDTH_Y;j+=WIDTH_X1){ | |
479 | - TVRAM[j]=0x00; | |
480 | - TVRAM[WIDTH_X1*WIDTH_Y+j]=cursorcolor; | |
481 | - } | |
482 | - } | |
483 | - } | |
484 | - if (y<0) { | |
485 | - // Fill blanc at bottom | |
486 | - for(i=WIDTH_X1*(WIDTH_Y+y);i<WIDTH_X1*WIDTH_Y;i++){ | |
487 | - TVRAM[i]=0x00; | |
488 | - TVRAM[WIDTH_X1*WIDTH_Y+i]=cursorcolor; | |
489 | - } | |
490 | - } else if (0<y) { | |
491 | - // Fill blanc at top | |
492 | - for(i=0;i<WIDTH_X1*y;i++){ | |
493 | - TVRAM[i]=0x00; | |
494 | - TVRAM[WIDTH_X1*WIDTH_Y+i]=cursorcolor; | |
495 | - } | |
496 | - } | |
438 | +void lib_usegraphic(int mode){ | |
439 | + usegraphic(mode); | |
440 | + // Move current point to (0,0) | |
441 | + g_prev_x=g_prev_y=0; | |
497 | 442 | } |
498 | - | |
499 | -void lib_scroll40(int x,int y){ | |
500 | - int i,j; | |
501 | - int vector=y*WIDTH_X2+x; | |
502 | - if (vector<0) { | |
503 | - // Copy data from upper address to lower address | |
504 | - for(i=0-vector;i<WIDTH_X2*WIDTH_Y;i++){ | |
505 | - TVRAM[i+vector]=TVRAM[i]; | |
506 | - TVRAM[WIDTH_X2*WIDTH_Y+i+vector]=TVRAM[WIDTH_X2*WIDTH_Y+i]; | |
507 | - } | |
508 | - } else if (0<vector) { | |
509 | - // Copy data from lower address to upper address | |
510 | - for(i=WIDTH_X2*WIDTH_Y-vector-1;0<=i;i--){ | |
511 | - TVRAM[i+vector]=TVRAM[i]; | |
512 | - TVRAM[WIDTH_X2*WIDTH_Y+i+vector]=TVRAM[WIDTH_X2*WIDTH_Y+i]; | |
513 | - } | |
514 | - } else { | |
515 | - return; | |
516 | - } | |
517 | - if (x<0) { | |
518 | - // Fill blanc at right | |
519 | - for(i=x;i<0;i++){ | |
520 | - for(j=WIDTH_X2+i;j<WIDTH_X2*WIDTH_Y;j+=WIDTH_X2){ | |
521 | - TVRAM[j]=0x00; | |
522 | - TVRAM[WIDTH_X2*WIDTH_Y+j]=cursorcolor; | |
523 | - } | |
524 | - } | |
525 | - } else if (0<x) { | |
526 | - // Fill blanc at left | |
527 | - for(i=0;i<x;i++){ | |
528 | - for(j=i;j<WIDTH_X2*WIDTH_Y;j+=WIDTH_X2){ | |
529 | - TVRAM[j]=0x00; | |
530 | - TVRAM[WIDTH_X2*WIDTH_Y+j]=cursorcolor; | |
531 | - } | |
532 | - } | |
533 | - } | |
534 | - if (y<0) { | |
535 | - // Fill blanc at bottom | |
536 | - for(i=WIDTH_X2*(WIDTH_Y+y);i<WIDTH_X2*WIDTH_Y;i++){ | |
537 | - TVRAM[i]=0x00; | |
538 | - TVRAM[WIDTH_X2*WIDTH_Y+i]=cursorcolor; | |
539 | - } | |
540 | - } else if (0<y) { | |
541 | - // Fill blanc at top | |
542 | - for(i=0;i<WIDTH_X2*y;i++){ | |
543 | - TVRAM[i]=0x00; | |
544 | - TVRAM[WIDTH_X2*WIDTH_Y+i]=cursorcolor; | |
545 | - } | |
546 | - } | |
547 | -} | |
548 | - | |
549 | 443 | void lib_wait(int period){ |
550 | 444 | int i; |
551 | 445 | unsigned short dcount; |
@@ -558,52 +452,6 @@ | ||
558 | 452 | } |
559 | 453 | } |
560 | 454 | |
561 | -void allocate_graphic_area(){ | |
562 | - if (!g_graphic_area) { | |
563 | - // Use this pointer like unsigned short GVRAM[G_H_WORD*G_Y_RES] __attribute__ ((aligned (4))); | |
564 | - g_graphic_area=alloc_memory(G_H_WORD*G_Y_RES/2,ALLOC_GRAPHIC_BLOCK); | |
565 | - // Start graphic and clear screen | |
566 | - init_graphic(g_graphic_area); | |
567 | - // Move current point to (0,0) | |
568 | - g_prev_x=g_prev_y=0; | |
569 | - } | |
570 | -} | |
571 | - | |
572 | -void lib_usegraphic(int mode){ | |
573 | - // Modes; 0: stop GRAPHIC, 1: use GRAPHIC, 2: reset GRAPHIC and use it | |
574 | - switch(mode){ | |
575 | - case 0: | |
576 | - if (g_use_graphic){ | |
577 | - // Stop GRAPHIC if used | |
578 | - set_graphmode(0); | |
579 | - g_use_graphic=0; | |
580 | - // Set timer4 for tempo | |
581 | - PR4=59473; // 3632*262/16-1 | |
582 | - } else { | |
583 | - // Prepare GRAPHIC area if not used and not allcated. | |
584 | - allocate_graphic_area(); | |
585 | - } | |
586 | - break; | |
587 | - case 2: | |
588 | - // Reset GRAPHIC and use it | |
589 | - g_graphic_area=0; | |
590 | - // Continue to case 1: | |
591 | - case 1: | |
592 | - case 3: | |
593 | - default: | |
594 | - // Use GRAPHIC | |
595 | - allocate_graphic_area(); | |
596 | - // Start showing GRAPHIC with mode 1, but not with mode 3 | |
597 | - if (mode !=3 && !g_use_graphic){ | |
598 | - set_graphmode(1); | |
599 | - g_use_graphic=1; | |
600 | - // Set timer4 for tempo | |
601 | - PR4=55756; // ~=3405*262/16-1(55755.875) | |
602 | - } | |
603 | - break; | |
604 | - } | |
605 | -} | |
606 | - | |
607 | 455 | int lib_graphic(int v0,enum functions func){ |
608 | 456 | unsigned char b; |
609 | 457 | int x1=g_libparams[1]; |
@@ -921,21 +769,6 @@ | ||
921 | 769 | return heap; |
922 | 770 | }; |
923 | 771 | |
924 | -void lib_width(int width){ | |
925 | -#ifdef ZOEA | |
926 | - switch(width){ | |
927 | - case 30: | |
928 | - if (twidth!=30) set_width(0); | |
929 | - break; | |
930 | - case 40: | |
931 | - if (twidth!=40) set_width(1); | |
932 | - break; | |
933 | - default: | |
934 | - break; | |
935 | - } | |
936 | -#endif // ZOEA | |
937 | -} | |
938 | - | |
939 | 772 | int lib_file_textlen(FSFILE* fhandle){ |
940 | 773 | char buff[128]; |
941 | 774 | int i,textlen,len,seek; |
@@ -1197,8 +1030,7 @@ | ||
1197 | 1030 | lib_var_pop(a0,a1,g_libparams); |
1198 | 1031 | return v0; |
1199 | 1032 | case LIB_SCROLL: |
1200 | - if (twidth==40) lib_scroll40(g_libparams[1],v0); | |
1201 | - else lib_scroll(g_libparams[1],v0); | |
1033 | + scroll(g_libparams[1],v0); | |
1202 | 1034 | return v0; |
1203 | 1035 | case LIB_FILE: |
1204 | 1036 | return lib_file((enum functions)(a3 & FUNC_MASK),g_libparams[1],g_libparams[2],v0); |
@@ -1217,6 +1049,9 @@ | ||
1217 | 1049 | case LIB_MUSIC: |
1218 | 1050 | set_music((char*)v0,a0); |
1219 | 1051 | return v0; |
1052 | + case LIB_PLAYWAVE: | |
1053 | + play_wave((char*)v0); | |
1054 | + return v0; | |
1220 | 1055 | case LIB_SETDRAWCOUNT: |
1221 | 1056 | drawcount=(v0&0x0000FFFF); |
1222 | 1057 | return v0; |
@@ -1262,7 +1097,7 @@ | ||
1262 | 1097 | g_prev_x=g_prev_y=0; |
1263 | 1098 | return v0; |
1264 | 1099 | case LIB_WIDTH: |
1265 | - lib_width(v0); | |
1100 | + videowidth(v0); | |
1266 | 1101 | return v0; |
1267 | 1102 | case LIB_COLOR: |
1268 | 1103 | setcursorcolor(v0); |
@@ -596,4 +596,11 @@ | ||
596 | 596 | // Go to next character |
597 | 597 | while(0<g_mstr[g_mspos] && g_mstr[g_mspos]<=0x20 || g_mstr[g_mspos]=='|') g_mspos++; |
598 | 598 | } |
599 | +} | |
600 | + | |
601 | +void play_wave(char* filename){ | |
602 | + | |
603 | +} | |
604 | +void stop_music(){ | |
605 | + | |
599 | 606 | } |
\ No newline at end of file |
@@ -75,7 +75,7 @@ | ||
75 | 75 | |
76 | 76 | printstr("BASIC "BASVER"\n"); |
77 | 77 | wait60thsec(15); |
78 | - // Initialize music | |
78 | + // Initialize music system | |
79 | 79 | init_music(); |
80 | 80 | |
81 | 81 | printstr("Compiling..."); |
@@ -5,7 +5,6 @@ | ||
5 | 5 | kmorimatsu@users.sourceforge.jp |
6 | 6 | */ |
7 | 7 | |
8 | -#include "main.h" | |
9 | 8 | #include "api.h" |
10 | 9 | #include "compiler.h" |
11 | 10 |
@@ -38,8 +37,8 @@ | ||
38 | 37 | if (err) return err; |
39 | 38 | call_lib_code(LIB_LABEL); |
40 | 39 | } |
41 | -#ifdef MEGALOPA | |
42 | 40 | // 2nd param is optional |
41 | + next_position(); | |
43 | 42 | if (g_source[g_srcpos]==',') { |
44 | 43 | g_srcpos++; |
45 | 44 | check_obj_space(2); |
@@ -56,7 +55,6 @@ | ||
56 | 55 | check_obj_space(1); |
57 | 56 | g_object[g_objpos++]=0x24040003; // addiu a0,zero,xx |
58 | 57 | } |
59 | -#endif | |
60 | 58 | call_lib_code(LIB_SOUND); |
61 | 59 | return 0; |
62 | 60 | } |
@@ -64,8 +62,8 @@ | ||
64 | 62 | char *err; |
65 | 63 | err=get_string(); |
66 | 64 | if (err) return err; |
67 | -#ifdef MEGALOPA | |
68 | 65 | // 2nd param is optional |
66 | + next_position(); | |
69 | 67 | if (g_source[g_srcpos]==',') { |
70 | 68 | g_srcpos++; |
71 | 69 | check_obj_space(2); |
@@ -82,7 +80,6 @@ | ||
82 | 80 | check_obj_space(1); |
83 | 81 | g_object[g_objpos++]=0x24040003; // addiu a0,zero,xx |
84 | 82 | } |
85 | -#endif | |
86 | 83 | call_lib_code(LIB_MUSIC); |
87 | 84 | return 0; |
88 | 85 | } |
@@ -696,7 +693,7 @@ | ||
696 | 693 | return 0; |
697 | 694 | } |
698 | 695 | |
699 | -char* print_statement(enum libs lib_printstr, enum libs lib_string){ | |
696 | +char* print_statement_main(enum libs lib_printstr, enum libs lib_string){ | |
700 | 697 | char* err; |
701 | 698 | char b1; |
702 | 699 | int i; |
@@ -1342,7 +1339,7 @@ | ||
1342 | 1339 | return 0; |
1343 | 1340 | } |
1344 | 1341 | |
1345 | -char* fopen_statement(enum functions func){ | |
1342 | +char* fopen_statement_main(enum functions func){ | |
1346 | 1343 | // func is either FUNC_FOPENST or FUNC_FOPEN |
1347 | 1344 | char* err; |
1348 | 1345 | // Get 1st |
@@ -1397,10 +1394,6 @@ | ||
1397 | 1394 | return 0; |
1398 | 1395 | } |
1399 | 1396 | |
1400 | -char* fprint_statement(){ | |
1401 | - return print_statement(LIB_FILE | FUNC_FPRINTSTR,LIB_FILE | FUNC_FSTRING); | |
1402 | -} | |
1403 | - | |
1404 | 1397 | char* fget_statement(){ |
1405 | 1398 | return param2_statement(LIB_FILE | FUNC_FGET); |
1406 | 1399 | } |
@@ -1453,6 +1446,14 @@ | ||
1453 | 1446 | return 0; |
1454 | 1447 | } |
1455 | 1448 | |
1449 | +char* playwave_statement(){ | |
1450 | + char* err; | |
1451 | + err=get_string(); | |
1452 | + if (err) return err; | |
1453 | + call_lib_code(LIB_PLAYWAVE); | |
1454 | + return 0; | |
1455 | +} | |
1456 | + | |
1456 | 1457 | #ifdef __DEBUG |
1457 | 1458 | char* debug_statement(){ |
1458 | 1459 | call_lib_code(LIB_DEBUG); |
@@ -1460,142 +1461,147 @@ | ||
1460 | 1461 | } |
1461 | 1462 | #endif |
1462 | 1463 | |
1464 | +// Aliases follow | |
1463 | 1465 | |
1466 | +char* palette_statement(){ | |
1467 | + return param4_statement(LIB_PALETTE); | |
1468 | +} | |
1469 | + | |
1470 | +char* gpalette_statement(){ | |
1471 | + return param4_statement(LIB_GPALETTE); | |
1472 | +} | |
1473 | + | |
1474 | +char* print_statement(){ | |
1475 | + return print_statement_main(LIB_PRINTSTR,LIB_STRING); | |
1476 | +} | |
1477 | + | |
1478 | +char* pset_statement(){ | |
1479 | + return graphic_statement(FUNC_PSET); | |
1480 | +} | |
1481 | + | |
1482 | +char* line_statement(){ | |
1483 | + return graphic_statement(FUNC_LINE); | |
1484 | +} | |
1485 | + | |
1486 | +char* boxfill_statement(){ | |
1487 | + return graphic_statement(FUNC_BOXFILL); | |
1488 | +} | |
1489 | + | |
1490 | +char* circle_statement(){ | |
1491 | + return graphic_statement(FUNC_CIRCLE); | |
1492 | +} | |
1493 | + | |
1494 | +char* circlefill_statement(){ | |
1495 | + return graphic_statement(FUNC_CIRCLEFILL); | |
1496 | +} | |
1497 | + | |
1498 | +char* gprint_statement(){ | |
1499 | + return graphic_statement(FUNC_GPRINT); | |
1500 | +} | |
1501 | + | |
1502 | +char* putbmp_statement(){ | |
1503 | + return graphic_statement(FUNC_PUTBMP); | |
1504 | +} | |
1505 | + | |
1506 | +char* point_statement(){ | |
1507 | + return graphic_statement(FUNC_POINT); | |
1508 | +} | |
1509 | + | |
1510 | +char* fopen_statement(){ | |
1511 | + return fopen_statement_main(FUNC_FOPENST); | |
1512 | +} | |
1513 | + | |
1514 | +char* fprint_statement(){ | |
1515 | + return print_statement_main(LIB_FILE | FUNC_FPRINTSTR,LIB_FILE | FUNC_FSTRING); | |
1516 | +} | |
1517 | + | |
1518 | +static const void* statement_list[]={ | |
1519 | + "REM",rem_statement, | |
1520 | + "SOUND ",sound_statement, | |
1521 | + "MUSIC ",music_statement, | |
1522 | + "DRAWCOUNT ",drawcount_statement, | |
1523 | + "CURSOR ",cursor_statement, | |
1524 | + "PALETTE ",palette_statement, | |
1525 | + "GPALETTE ",gpalette_statement, | |
1526 | + "BGCOLOR ",bgcolor_statement, | |
1527 | + "CLS",cls_statement, | |
1528 | + "GCLS",gcls_statement, | |
1529 | + "COLOR ",color_statement, | |
1530 | + "GCOLOR ",gcolor_statement, | |
1531 | + "RESTORE ",restore_statement, | |
1532 | + "DATA ",data_statement, | |
1533 | + "CDATA ",cdata_statement, | |
1534 | + "LABEL ",label_statement, | |
1535 | + "DIM ",dim_statement, | |
1536 | + "CLEAR",clear_statement, | |
1537 | + "PRINT",print_statement, | |
1538 | + "IF ",if_statement, | |
1539 | + "ELSEIF ",elseif_statement, | |
1540 | + "ELSE",else_statement, | |
1541 | + "ENDIF",endif_statement, | |
1542 | + "END",end_statement, | |
1543 | + "EXEC ",exec_statement, | |
1544 | + "GOTO ",goto_statement, | |
1545 | + "GOSUB ",gosub_statement, | |
1546 | + "RETURN",return_statement, | |
1547 | + "POKE ",poke_statement, | |
1548 | + "FOR ",for_statement, | |
1549 | + "NEXT",next_statement, | |
1550 | + "LET ",let_statement, | |
1551 | + "PCG ",pcg_statement, | |
1552 | + "USEPCG",usepcg_statement, | |
1553 | + "SCROLL ",scroll_statement, | |
1554 | + "WAIT ",wait_statement, | |
1555 | + "USEGRAPHIC",usegraphic_statement, | |
1556 | + "PSET ",pset_statement, | |
1557 | + "LINE ",line_statement, | |
1558 | + "BOXFILL ",boxfill_statement, | |
1559 | + "CIRCLE ",circle_statement, | |
1560 | + "CIRCLEFILL ",circlefill_statement, | |
1561 | + "GPRINT ",gprint_statement, | |
1562 | + "PUTBMP ",putbmp_statement, | |
1563 | + "POINT ",point_statement, | |
1564 | + "VAR ",var_statement, | |
1565 | + "DO",do_statement, | |
1566 | + "LOOP",loop_statement, | |
1567 | + "WHILE ",while_statement, | |
1568 | + "WEND",wend_statement, | |
1569 | + "BREAK",break_statement, | |
1570 | + "CONTINUE",continue_statement, | |
1571 | + "SYSTEM",system_statement, | |
1572 | + "WIDTH ",width_statement, | |
1573 | + "FOPEN ",fopen_statement, | |
1574 | + "FILE ",file_statement, | |
1575 | + "FCLOSE",fclose_statement, | |
1576 | + "FPRINT ",fprint_statement, | |
1577 | + "FGET ",fget_statement, | |
1578 | + "FPUT ",fput_statement, | |
1579 | + "FPUTC ",fputc_statement, | |
1580 | + "FSEEK ",fseek_statement, | |
1581 | + "FREMOVE ",fremove_statement, | |
1582 | + "USEVAR ",usevar_statement, | |
1583 | + "PLAYWAVE ",playwave_statement, | |
1584 | + // List of additional statements follows | |
1585 | + ADDITIONAL_STATEMENTS | |
1586 | +}; | |
1587 | + | |
1464 | 1588 | char* statement(void){ |
1465 | 1589 | char* err; |
1466 | 1590 | int prevpos; |
1591 | + int i; | |
1592 | + char* (*f)(); | |
1467 | 1593 | // Clear flag for temp area usage. |
1468 | 1594 | g_temp_area_used=0; |
1469 | 1595 | // Initialize stack handler used for value |
1470 | 1596 | g_sdepth=g_maxsdepth=0; |
1471 | - if (nextCodeIs("REM")) { | |
1472 | - err=rem_statement(); | |
1473 | - } else if (nextCodeIs("SOUND ")) { | |
1474 | - err=sound_statement(); | |
1475 | - } else if (nextCodeIs("MUSIC ")) { | |
1476 | - err=music_statement(); | |
1477 | - } else if (nextCodeIs("DRAWCOUNT ")) { | |
1478 | - err=drawcount_statement(); | |
1479 | - } else if (nextCodeIs("CURSOR ")) { | |
1480 | - err=cursor_statement(); | |
1481 | - } else if (nextCodeIs("PALETTE ")) { | |
1482 | - err=param4_statement(LIB_PALETTE); | |
1483 | - } else if (nextCodeIs("GPALETTE ")) { | |
1484 | - err=param4_statement(LIB_GPALETTE); | |
1485 | - } else if (nextCodeIs("BGCOLOR ")) { | |
1486 | - err=bgcolor_statement(); | |
1487 | - } else if (nextCodeIs("CLS")) { | |
1488 | - err=cls_statement(); | |
1489 | - } else if (nextCodeIs("GCLS")) { | |
1490 | - err=gcls_statement(); | |
1491 | - } else if (nextCodeIs("COLOR ")) { | |
1492 | - err=color_statement(); | |
1493 | - } else if (nextCodeIs("GCOLOR ")) { | |
1494 | - err=gcolor_statement(); | |
1495 | - } else if (nextCodeIs("RESTORE ")) { | |
1496 | - err=restore_statement(); | |
1497 | - } else if (nextCodeIs("DATA ")) { | |
1498 | - err=data_statement(); | |
1499 | - } else if (nextCodeIs("CDATA ")) { | |
1500 | - err=cdata_statement(); | |
1501 | - } else if (nextCodeIs("LABEL ")) { | |
1502 | - err=label_statement(); | |
1503 | - } else if (nextCodeIs("DIM ")) { | |
1504 | - err=dim_statement(); | |
1505 | - } else if (nextCodeIs("CLEAR")) { | |
1506 | - err=clear_statement(); | |
1507 | - } else if (nextCodeIs("PRINT")) { | |
1508 | - err=print_statement(LIB_PRINTSTR,LIB_STRING); | |
1509 | - } else if (nextCodeIs("IF ")) { | |
1510 | - err=if_statement(); | |
1511 | - } else if (nextCodeIs("ELSEIF ")) { | |
1512 | - err=elseif_statement(); | |
1513 | - } else if (nextCodeIs("ELSE")) { | |
1514 | - err=else_statement(); | |
1515 | - } else if (nextCodeIs("ENDIF")) { | |
1516 | - err=endif_statement(); | |
1517 | - } else if (nextCodeIs("END")) { | |
1518 | - err=end_statement(); | |
1519 | - } else if (nextCodeIs("EXEC ")) { | |
1520 | - err=exec_statement(); | |
1521 | - } else if (nextCodeIs("GOTO ")) { | |
1522 | - err=goto_statement(); | |
1523 | - } else if (nextCodeIs("GOSUB ")) { | |
1524 | - err=gosub_statement(); | |
1525 | - } else if (nextCodeIs("RETURN")) { | |
1526 | - err=return_statement(); | |
1527 | - } else if (nextCodeIs("POKE ")) { | |
1528 | - err=poke_statement(); | |
1529 | - } else if (nextCodeIs("FOR ")) { | |
1530 | - err=for_statement(); | |
1531 | - } else if (nextCodeIs("NEXT")) { | |
1532 | - err=next_statement(); | |
1533 | - } else if (nextCodeIs("LET ")) { | |
1534 | - err=let_statement(); | |
1535 | - } else if (nextCodeIs("PCG ")) { | |
1536 | - err=pcg_statement(); | |
1537 | - } else if (nextCodeIs("USEPCG")) { | |
1538 | - err=usepcg_statement(); | |
1539 | - } else if (nextCodeIs("SCROLL ")) { | |
1540 | - err=scroll_statement(); | |
1541 | - } else if (nextCodeIs("WAIT ")) { | |
1542 | - err=wait_statement(); | |
1543 | - } else if (nextCodeIs("USEGRAPHIC")) { | |
1544 | - err=usegraphic_statement(); | |
1545 | - } else if (nextCodeIs("PSET ")) { | |
1546 | - err=graphic_statement(FUNC_PSET); | |
1547 | - } else if (nextCodeIs("LINE ")) { | |
1548 | - err=graphic_statement(FUNC_LINE); | |
1549 | - } else if (nextCodeIs("BOXFILL ")) { | |
1550 | - err=graphic_statement(FUNC_BOXFILL); | |
1551 | - } else if (nextCodeIs("CIRCLE ")) { | |
1552 | - err=graphic_statement(FUNC_CIRCLE); | |
1553 | - } else if (nextCodeIs("CIRCLEFILL ")) { | |
1554 | - err=graphic_statement(FUNC_CIRCLEFILL); | |
1555 | - } else if (nextCodeIs("GPRINT ")) { | |
1556 | - err=graphic_statement(FUNC_GPRINT); | |
1557 | - } else if (nextCodeIs("PUTBMP ")) { | |
1558 | - err=graphic_statement(FUNC_PUTBMP); | |
1559 | - } else if (nextCodeIs("POINT ")) { | |
1560 | - err=graphic_statement(FUNC_POINT); | |
1561 | - } else if (nextCodeIs("VAR ")) { | |
1562 | - err=var_statement(); | |
1563 | - } else if (nextCodeIs("DO")) { | |
1564 | - err=do_statement(); | |
1565 | - } else if (nextCodeIs("LOOP")) { | |
1566 | - err=loop_statement(); | |
1567 | - } else if (nextCodeIs("WHILE ")) { | |
1568 | - err=while_statement(); | |
1569 | - } else if (nextCodeIs("WEND")) { | |
1570 | - err=wend_statement(); | |
1571 | - } else if (nextCodeIs("BREAK")) { | |
1572 | - err=break_statement(); | |
1573 | - } else if (nextCodeIs("CONTINUE")) { | |
1574 | - err=continue_statement(); | |
1575 | - } else if (nextCodeIs("SYSTEM")) { | |
1576 | - err=system_statement(); | |
1577 | - } else if (nextCodeIs("WIDTH ")) { | |
1578 | - err=width_statement(); | |
1579 | - } else if (nextCodeIs("FOPEN ")) { | |
1580 | - err=fopen_statement(FUNC_FOPENST); | |
1581 | - } else if (nextCodeIs("FILE ")) { | |
1582 | - err=file_statement(); | |
1583 | - } else if (nextCodeIs("FCLOSE")) { | |
1584 | - err=fclose_statement(); | |
1585 | - } else if (nextCodeIs("FPRINT ")) { | |
1586 | - err=fprint_statement(); | |
1587 | - } else if (nextCodeIs("FGET ")) { | |
1588 | - err=fget_statement(); | |
1589 | - } else if (nextCodeIs("FPUT ")) { | |
1590 | - err=fput_statement(); | |
1591 | - } else if (nextCodeIs("FPUTC ")) { | |
1592 | - err=fputc_statement(); | |
1593 | - } else if (nextCodeIs("FSEEK ")) { | |
1594 | - err=fseek_statement(); | |
1595 | - } else if (nextCodeIs("FREMOVE ")) { | |
1596 | - err=fremove_statement(); | |
1597 | - } else if (nextCodeIs("USEVAR ")) { | |
1598 | - err=usevar_statement(); | |
1597 | + // Seek the statement | |
1598 | + for (i=0;i<sizeof(statement_list)/sizeof(statement_list[0]);i+=2){ | |
1599 | + if (nextCodeIs((char*)statement_list[i])) break; | |
1600 | + } | |
1601 | + if (i<sizeof(statement_list)/sizeof(statement_list[0])) { | |
1602 | + // Statement found. Call it. | |
1603 | + f=statement_list[i+1]; | |
1604 | + err=f(); | |
1599 | 1605 | #ifdef __DEBUG |
1600 | 1606 | } else if (nextCodeIs("DEBUG")) { |
1601 | 1607 | err=debug_statement(); |