BASIC compiler/interpreter for PIC32MX/MZ-80K (suspended)
| Revision | 137 (tree) |
|---|---|
| Time | 2016-07-18 11:08:36 |
| Author | kmorimatsu |
Avoid reading PORTB in PS/2 keyboard mode.
| @@ -376,7 +376,7 @@ | ||
| 376 | 376 | while(vkey!=0); |
| 377 | 377 | // Get string as a line |
| 378 | 378 | lineinput(str,63); |
| 379 | - if (g_disable_break==0 && (ps2keystatus[0x03] || (PORTB&0x4c80)==0)) err_break(); | |
| 379 | + check_break(); | |
| 380 | 380 | return str; |
| 381 | 381 | } |
| 382 | 382 |
| @@ -494,7 +494,7 @@ | ||
| 494 | 494 | dcount=drawcount; |
| 495 | 495 | while(dcount==drawcount){ |
| 496 | 496 | asm (WAIT); |
| 497 | - if (g_disable_break==0 && (ps2keystatus[0x03] || (PORTB&0x4c80)==0)) err_break(); | |
| 497 | + check_break(); | |
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | } |
| @@ -825,7 +825,7 @@ | ||
| 825 | 825 | int _call_library(int a0,int a1,int v0,enum libs a3){ |
| 826 | 826 | // usage: call_lib_code(LIB_XXXX); |
| 827 | 827 | // Above code takes 2 words. |
| 828 | - if (g_disable_break==0 && (ps2keystatus[0x03] || (PORTB&0x4c80)==0)) err_break(); | |
| 828 | + check_break(); | |
| 829 | 829 | switch(a3){ |
| 830 | 830 | case LIB_FLOAT: |
| 831 | 831 | return lib_float(a0,v0,(enum operator)a1); // see operator.c |
| @@ -288,3 +288,15 @@ | ||
| 288 | 288 | // Divide by 36 (valid for 32 bits) |
| 289 | 289 | #define div36_32(x) div32(x,0xe38e38e4,37) |
| 290 | 290 | #define rem36_32(x) (x-36*div36_32(x)) |
| 291 | + | |
| 292 | +// Check break key or buttons when executing BASIC code. | |
| 293 | +// In PS/2 mode, detect ctrl-break. | |
| 294 | +// In button mode, detect pushing four buttons are pushed simultaneously. | |
| 295 | +#define check_break() \ | |
| 296 | + if (g_disable_break==0) {\ | |
| 297 | + if (inPS2MODE()) {\ | |
| 298 | + if (ps2keystatus[0x03]) err_break();\ | |
| 299 | + } else {\ | |
| 300 | + if ((PORTB&0x4c80)==0) err_break();\ | |
| 301 | + }\ | |
| 302 | + } |
| @@ -111,11 +111,17 @@ | ||
| 111 | 111 | wait60thsec(15); |
| 112 | 112 | |
| 113 | 113 | // Initialize the other parameters |
| 114 | + // Random seed | |
| 114 | 115 | g_rnd_seed=0x3045; |
| 116 | + // Clear variables | |
| 115 | 117 | for(i=0;i<ALLOC_BLOCK_NUM;i++){ |
| 116 | 118 | g_var_mem[i]=0; |
| 117 | 119 | g_var_size[i]=0; |
| 118 | 120 | } |
| 121 | + // Clear key input buffer | |
| 122 | + for(i=0;i<256;i++){ | |
| 123 | + ps2keystatus[i]=0; | |
| 124 | + } | |
| 119 | 125 | |
| 120 | 126 | // Assign memory |
| 121 | 127 | set_free_area((void*)(g_object+g_objpos),(void*)(&RAM[RAMSIZE])); |