• R/O
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamephpguiwindowsc翻訳pythonomegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

BASIC compiler/interpreter for PIC32MX/MZ-80K (suspended)


コミットメタ情報

リビジョン263 (tree)
日時2018-07-30 07:41:27
作者kmorimatsu

ログメッセージ

Import shared codes.

変更サマリ

差分

--- mips/branches/zoea/compiler.h (revision 262)
+++ mips/branches/zoea/compiler.h (revision 263)
@@ -117,6 +117,7 @@
117117 LIB_WIDTH =LIB_STEP*47,
118118 LIB_FILE =LIB_STEP*48,
119119 LIB_PLAYWAVE =LIB_STEP*49,
120+ LIB_PLAYWAVEFUNC =LIB_STEP*50,
120121 LIB_DEBUG =LIB_STEP*127,
121122 };
122123
@@ -245,10 +246,11 @@
245246
246247 void set_sound(unsigned long* data, int flagsLR);
247248 int musicRemaining(int flagsLR);
249+int waveRemaining(int mode);
248250 void set_music(char* str, int flagsLR);
249251 void stop_music(void);
250252 void init_music(void);
251-void play_wave(char* filename);
253+void play_wave(char* filename, int start);
252254
253255 char* statement(void);
254256 char* gosub_statement();
@@ -271,6 +273,7 @@
271273 void* calloc_memory(int size, int var_num);
272274 void move_to_perm_block(int var_num);
273275 void move_from_perm_block(int var_num);
276+int get_permanent_var_num(void);
274277
275278 char* link(void);
276279 char* get_label(void);
--- mips/branches/zoea/debug.c (revision 262)
+++ mips/branches/zoea/debug.c (revision 263)
@@ -61,8 +61,6 @@
6161
6262 printstr("BASIC "BASVER"\n");
6363 wait60thsec(15);
64- // Initialize music
65- init_music();
6664
6765 printstr("Compiling...");
6866
@@ -88,7 +86,6 @@
8886 // Work area (used for A-Z values) is next to the object code area.
8987 start_program((void*)(&(RAM[0])),(void*)(&g_var_mem[0]));
9088 printstr("\nOK\n");
91- set_graphmode(0);
9289 g_use_graphic=0;
9390
9491 return 1;
@@ -224,9 +221,7 @@
224221
225222 static const char bastext[]=
226223 "CLS\n"
227-"DIM S(512)\n"
228-"EXEC 0x8fdd0012, 0x27bd07fc\n"
229-"print s\n"
224+"print NOT(0);IN(0)\n"
230225 "\n";
231226
232227 /*
--- mips/branches/zoea/debug.h (revision 262)
+++ mips/branches/zoea/debug.h (revision 263)
@@ -15,11 +15,16 @@
1515 #define ps2init() not_ps2init_but_init_Timer1()
1616 int not_ps2init_but_init_Timer1();
1717
18-// Do not use set_graphmode()
19-#define set_graphmode(m) (0)
20-
2118 // Do not use asm("wait") but use asm("nop")
2219 #undef WAIT
2320 #define WAIT "nop"
2421
2522 #endif // __DEBUG
23+
24+// key waiting macro
25+
26+#define debug_wait() lineinput((char*)&g_temp,3)
27+#define debug_wait_char(x) do {\
28+ printchar(x); \
29+ lineinput((char*)&g_temp,3);\
30+ } while(0)
--- mips/branches/zoea/envspecific.c (revision 262)
+++ mips/branches/zoea/envspecific.c (revision 263)
@@ -17,6 +17,16 @@
1717 For Zoea, disable PS/2 keyboard and enable tact switches, then read.
1818 */
1919
20+void pre_run(){
21+ // TODO
22+}
23+
24+void post_run(){
25+ // Cool down
26+ set_graphmode(0);
27+ g_use_graphic=0;
28+}
29+
2030 int readbuttons(){
2131 // Enable tact switches
2232 if (inPS2MODE()) {
--- mips/branches/zoea/error.c (revision 262)
+++ mips/branches/zoea/error.c (revision 263)
@@ -69,6 +69,9 @@
6969 void pre_end_addr(int s6){
7070 int i,j;
7171 char str[7];
72+ // Cool down the system
73+ stop_music();
74+ // Resolve line and show it
7275 if (s6<0) s6=s6&0x7fffffff;
7376 g_label=s6;
7477 if (s6<65536) {
@@ -90,6 +93,7 @@
9093 asm volatile("j pre_end_addr")
9194
9295 void err_break(void){
96+ stop_music();
9397 printstr(ERR_BREAK);
9498 end_exec();
9599 }
--- mips/branches/zoea/function.c (revision 262)
+++ mips/branches/zoea/function.c (revision 263)
@@ -362,6 +362,22 @@
362362 return 0;
363363 }
364364
365+char* playwave_function(){
366+ char* err;
367+ next_position();
368+ if (g_source[g_srcpos]!=')') {
369+ // Get param
370+ err=get_value();
371+ if (err) return err;
372+ } else {
373+ // If parameter is omitted, use 0.
374+ check_obj_space(1);
375+ g_object[g_objpos++]=0x24020000; // addiu v0,zero,0
376+ }
377+ call_lib_code(LIB_PLAYWAVEFUNC);
378+ return 0;
379+}
380+
365381 char* float_constant(float val){
366382 volatile int i;
367383 ((float*)(&i))[0]=val;
@@ -545,6 +561,7 @@
545561 "FPUTC(",fputc_statement,
546562 "FREMOVE(",fremove_statement,
547563 "FEOF(",feof_function,
564+ "PLAYWAVE(",playwave_function,
548565 // Additional functions follow
549566 ADDITIONAL_INT_FUNCTIONS
550567 };
--- mips/branches/zoea/library.c (revision 262)
+++ mips/branches/zoea/library.c (revision 263)
@@ -1005,8 +1005,10 @@
10051005 set_music((char*)v0,a0);
10061006 return v0;
10071007 case LIB_PLAYWAVE:
1008- play_wave((char*)v0);
1008+ play_wave((char*)g_libparams[1],v0);
10091009 return v0;
1010+ case LIB_PLAYWAVEFUNC:
1011+ return waveRemaining(v0);
10101012 case LIB_SETDRAWCOUNT:
10111013 drawcount=(v0&0x0000FFFF);
10121014 return v0;
--- mips/branches/zoea/memory.c (revision 262)
+++ mips/branches/zoea/memory.c (revision 263)
@@ -172,4 +172,13 @@
172172 g_var_pointer[var_num]=g_var_pointer[i];
173173 // Clear block
174174 g_var_size[i]=0;
175-}
\ No newline at end of file
175+}
176+
177+int get_permanent_var_num(){
178+ int i;
179+ for (i=ALLOC_PERM_BLOCK;i<ALLOC_BLOCK_NUM;i++) {
180+ if (g_var_size[i]==0) return i;
181+ }
182+ err_no_block();
183+ return 0;
184+}
--- mips/branches/zoea/music.c (revision 262)
+++ mips/branches/zoea/music.c (revision 263)
@@ -12,8 +12,6 @@
1212 /*
1313 Timer3: 1/32 prescaler, toggle mode : 894886.25 Hz
1414 PR3=2047 <-> 437 Hz
15- Timer4: 1/32 prescaler: 1789772.5 Hz
16- Timer4 29737 counts: 262 NTSC lines.
1715 */
1816
1917 /*
@@ -88,7 +86,10 @@
8886 #define start_dma() T4CONSET=0x8000; DCH2CONSET=0x00000080; g_sound_mode=SOUND_MODE_WAVE
8987 #define stop_dma() T4CONCLR=0x8000; DCH2CONCLR=0x00000080; g_sound_mode=SOUND_MODE_MUSIC
9088
91-
89+int waveRemaining(int mode){
90+ // TODO
91+ return 0;
92+}
9293 int musicRemaining(int flagsLR){
9394 // flagsLR is ignored
9495 return (g_musicend-g_musicstart)&31;
@@ -585,7 +586,8 @@
585586 DCH2CONSET=0x00000080;
586587 }
587588
588-void play_wave(char* filename){
589+void play_wave(char* filename, int start){
590+ // TODO: Implement start parameter
589591 int i;
590592 // Stop the previous play
591593 T3CONCLR=0x8000;
--- mips/branches/zoea/reservednames.js (revision 262)
+++ mips/branches/zoea/reservednames.js (revision 263)
@@ -137,12 +137,33 @@
137137 'WEND',
138138 'WHILE',
139139 'WIDTH',
140+ // For megalopa
141+ '// For Megalopa',
142+ 'OUT',
143+ 'OUT8H',
144+ 'OUT8L',
145+ 'OUT16',
146+ 'IN',
147+ 'IN8H',
148+ 'IN8L',
149+ 'IN16',
150+ 'ANALOG',
151+ 'PWM',
152+ 'SERIAL',
153+ 'SPI',
154+ 'SPIOUT',
155+ 'SPIIN',
140156 ];
141157 var result='';
142158 for(key in namearray){
143159 var nameint='0000'+name2int(namearray[key]).toString(16);
144160 nameint=nameint.substr(nameint.length-8);
145- result+="\t0x"+nameint+", //"+namearray[key]+"\r\n";
161+ if (namearray[key].substr(0,2)=='//') {
162+ // This is a comment
163+ result+=namearray[key]+"\r\n";
164+ } else {
165+ result+="\t0x"+nameint+", /*"+namearray[key]+"*/\r\n";
166+ }
146167 }
147168
148169 var fso = new ActiveXObject("Scripting.FileSystemObject");
--- mips/branches/zoea/run.c (revision 262)
+++ mips/branches/zoea/run.c (revision 263)
@@ -73,11 +73,12 @@
7373 g_long_name_var_num=0;
7474 cmpdata_init();
7575
76- printstr("BASIC "BASVER"\n");
77- wait60thsec(15);
7876 // Initialize music system
7977 init_music();
8078
79+ printstr("BASIC "BASVER"\n");
80+ wait60thsec(15);
81+
8182 printstr("Compiling...");
8283
8384 // Compile the file
@@ -134,14 +135,17 @@
134135 // Assign memory
135136 set_free_area((void*)(g_object+g_objpos),(void*)(&RAM[RAMSIZE]));
136137
138+ // Warm up environment
139+ pre_run();
140+
137141 // Execute program
138142 // Start program from the beginning of RAM.
139143 // Work area (used for A-Z values) is next to the object code area.
140144 start_program((void*)(&(RAM[0])),(void*)(&g_var_mem[0]));
141145 printstr("\nOK\n");
142- // Cool down
143- set_graphmode(0);
144- g_use_graphic=0;
146+
147+ // Cool down environment
148+ post_run();
145149 lib_file(FUNC_FINIT,0,0,0);
146150
147151 return 0;
--- mips/branches/zoea/statement.c (revision 262)
+++ mips/branches/zoea/statement.c (revision 263)
@@ -1450,7 +1450,22 @@
14501450 char* err;
14511451 err=get_string();
14521452 if (err) return err;
1453+ check_obj_space(2);
1454+ g_object[g_objpos++]=0x27BDFFFC; // addiu sp,sp,-4
1455+ g_object[g_objpos++]=0xAFA20004; // sw v0,4(sp)
1456+ if (g_source[g_srcpos]==',') {
1457+ g_srcpos++;
1458+ // Get 2nd
1459+ err=get_value();
1460+ if (err) return err;
1461+ } else {
1462+ // If 2rd parameter is omitted, use 0.
1463+ check_obj_space(1);
1464+ g_object[g_objpos++]=0x24020000; // addiu v0,zero,0
1465+ }
14531466 call_lib_code(LIB_PLAYWAVE);
1467+ check_obj_space(1);
1468+ g_object[g_objpos++]=0x27BD0004; // addiu sp,sp,4
14541469 return 0;
14551470 }
14561471