BASIC compiler/interpreter for PIC32MX/MZ-80K (suspended)
| Revision | 140 (tree) |
|---|---|
| Time | 2016-07-24 12:28:39 |
| Author | kmorimatsu |
Reset data/read when executing BASIC code.
| @@ -139,13 +139,7 @@ | ||
| 139 | 139 | |
| 140 | 140 | static const char bastext[]= |
| 141 | 141 | "CLS\n" |
| 142 | -"PRINT \"\\x21\",\n" | |
| 143 | -"PRINT \"\\x2A\",\n" | |
| 144 | -"PRINT \"\\xA2\",\n" | |
| 145 | -"PRINT \"\\x2a\",\n" | |
| 146 | -"PRINT \"\\xa2\",\n" | |
| 147 | -"PRINT \"\\\"\",\n" | |
| 148 | -"PRINT \"\\\\\",\n" | |
| 142 | +"for i=1 to 9:print rnd(),:next\n" | |
| 149 | 143 | "\n"; |
| 150 | 144 | |
| 151 | 145 | /* |
| @@ -38,10 +38,16 @@ | ||
| 38 | 38 | } |
| 39 | 39 | break; |
| 40 | 40 | case 1: |
| 41 | - default: | |
| 42 | 41 | // label is pointer |
| 43 | 42 | i=label; |
| 44 | 43 | break; |
| 44 | + case 2: | |
| 45 | + default: | |
| 46 | + // Reset data/read | |
| 47 | + pos=0; | |
| 48 | + in_data=0; | |
| 49 | + skip=0; | |
| 50 | + return 0; | |
| 45 | 51 | } |
| 46 | 52 | i-=(int)(&g_object[0]); |
| 47 | 53 | pos=i/4; |
| @@ -97,6 +103,10 @@ | ||
| 97 | 103 | } |
| 98 | 104 | } |
| 99 | 105 | |
| 106 | +void reset_dataread(){ | |
| 107 | + lib_read(2,1); | |
| 108 | +} | |
| 109 | + | |
| 100 | 110 | char* lib_midstr(int var_num, int pos, int len){ |
| 101 | 111 | int i; |
| 102 | 112 | char* str; |
| @@ -208,6 +208,7 @@ | ||
| 208 | 208 | char* float_function(void); |
| 209 | 209 | |
| 210 | 210 | void call_library(void); |
| 211 | +void reset_dataread(); | |
| 211 | 212 | |
| 212 | 213 | void free_temp_str(char* str); |
| 213 | 214 | void* alloc_memory(int size, int var_num); |
| @@ -241,7 +241,7 @@ | ||
| 241 | 241 | ACOS#(x#) |
| 242 | 242 | x# の逆余弦を実数値で返す。 |
| 243 | 243 | ARGS#(x) |
| 244 | - サブルーチン中で、GOSUBに渡されたx番目の引数を整数値として取り出す。 | |
| 244 | + サブルーチン中で、GOSUBに渡されたx番目の引数を実数値として取り出す。 | |
| 245 | 245 | ASIN#(x#) |
| 246 | 246 | x# の逆正弦を実数値で返す。 |
| 247 | 247 | ATAN#(x#) |
| @@ -271,7 +271,7 @@ | ||
| 271 | 271 | LOG10#(x#) |
| 272 | 272 | x# の常用対数を実数値で返す。 |
| 273 | 273 | MODF#(x#) |
| 274 | - x# の整数部を実数値で返す。 | |
| 274 | + x# の小数部を実数値で返す。 | |
| 275 | 275 | PI# |
| 276 | 276 | 3.141593を返す。 |
| 277 | 277 | POW#(x#,y#) |
| @@ -333,9 +333,9 @@ | ||
| 333 | 333 | x % y |
| 334 | 334 | 整数剰余 |
| 335 | 335 | x >> y |
| 336 | + xの値をyビット右シフト | |
| 337 | +x << y | |
| 336 | 338 | xの値をyビット左シフト |
| 337 | -x << y | |
| 338 | - xの値をyビット右シフト | |
| 339 | 339 | x = y |
| 340 | 340 | 2つの整数値が等しい場合に1、そうでないときに0 |
| 341 | 341 | x != y |
| @@ -122,6 +122,8 @@ | ||
| 122 | 122 | for(i=0;i<256;i++){ |
| 123 | 123 | ps2keystatus[i]=0; |
| 124 | 124 | } |
| 125 | + // Reset data/read. | |
| 126 | + reset_dataread(); | |
| 125 | 127 | |
| 126 | 128 | // Assign memory |
| 127 | 129 | set_free_area((void*)(g_object+g_objpos),(void*)(&RAM[RAMSIZE])); |
| @@ -10,10 +10,16 @@ | ||
| 10 | 10 | #include "api.h" |
| 11 | 11 | #include "keyinput.h" |
| 12 | 12 | |
| 13 | -int lib_read(unsigned int label){ | |
| 13 | +int lib_read(int mode,unsigned int label){ | |
| 14 | 14 | unsigned int i,code; |
| 15 | 15 | static unsigned int pos=0; |
| 16 | 16 | static unsigned int in_data=0; |
| 17 | + if (mode==2) { | |
| 18 | + // Reset data/read | |
| 19 | + pos=0; | |
| 20 | + in_data=0; | |
| 21 | + return 0; | |
| 22 | + } | |
| 17 | 23 | if (label) { |
| 18 | 24 | // RESTORE function |
| 19 | 25 | i=(int)search_label(label); |
| @@ -54,6 +60,10 @@ | ||
| 54 | 60 | } |
| 55 | 61 | } |
| 56 | 62 | |
| 63 | +void reset_dataread(){ | |
| 64 | + lib_read(2,1); | |
| 65 | +} | |
| 66 | + | |
| 57 | 67 | char* lib_midstr(int var_num, int pos, int len){ |
| 58 | 68 | int i; |
| 59 | 69 | char* str; |
| @@ -520,10 +530,10 @@ | ||
| 520 | 530 | case LIB_DRAWCOUNT: |
| 521 | 531 | return drawcount; |
| 522 | 532 | case LIB_RESTORE: |
| 523 | - lib_read(v0); | |
| 533 | + lib_read(0,v0); | |
| 524 | 534 | return; |
| 525 | 535 | case LIB_READ: |
| 526 | - return lib_read(0); | |
| 536 | + return lib_read(0,0); | |
| 527 | 537 | case LIB_LABEL: |
| 528 | 538 | return (int)lib_label(v0); |
| 529 | 539 | case LIB_INPUT: |
| @@ -124,6 +124,8 @@ | ||
| 124 | 124 | for(i=0;i<256;i++){ |
| 125 | 125 | ps2keystatus[i]=0; |
| 126 | 126 | } |
| 127 | + // Reset data/read. | |
| 128 | + reset_dataread(); | |
| 127 | 129 | |
| 128 | 130 | // Assign memory |
| 129 | 131 | set_free_area((void*)(g_object+g_objpos),(void*)(&RAM[RAMSIZE])); |
| @@ -128,6 +128,7 @@ | ||
| 128 | 128 | char* str_function(void); |
| 129 | 129 | |
| 130 | 130 | void call_library(void); |
| 131 | +void reset_dataread(); | |
| 131 | 132 | |
| 132 | 133 | void free_temp_str(char* str); |
| 133 | 134 | void* alloc_memory(int size, int var_num); |