BASIC compiler/interpreter for PIC32MX/MZ-80K (suspended)
| Revision | 138 (tree) |
|---|---|
| Time | 2016-07-18 11:19:12 |
| Author | kmorimatsu |
Avoid reading PORTB in PS/2 keyboard mode.
| @@ -333,7 +333,7 @@ | ||
| 333 | 333 | while(vkey!=0); |
| 334 | 334 | // Get string as a line |
| 335 | 335 | lineinput(str,63); |
| 336 | - if (g_disable_break==0 && (ps2keystatus[0x03] || (PORTB&0x4c80)==0)) err_break(); | |
| 336 | + check_break(); | |
| 337 | 337 | return str; |
| 338 | 338 | } |
| 339 | 339 |
| @@ -451,7 +451,7 @@ | ||
| 451 | 451 | dcount=drawcount; |
| 452 | 452 | while(dcount==drawcount){ |
| 453 | 453 | asm ("wait"); |
| 454 | - if (g_disable_break==0 && (ps2keystatus[0x03] || (PORTB&0x4c80)==0)) err_break(); | |
| 454 | + check_break(); | |
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | } |
| @@ -466,7 +466,7 @@ | ||
| 466 | 466 | int _call_library(int a0,int a1,int v0,enum libs a3){ |
| 467 | 467 | // usage: call_lib_code(LIB_XXXX); |
| 468 | 468 | // Above code takes 2 words. |
| 469 | - if (g_disable_break==0 && (ps2keystatus[0x03] || (PORTB&0x4c80)==0)) err_break(); | |
| 469 | + check_break(); | |
| 470 | 470 | switch(a3){ |
| 471 | 471 | case LIB_DIV0: |
| 472 | 472 | err_div_zero(); |
| @@ -113,11 +113,17 @@ | ||
| 113 | 113 | wait60thsec(15); |
| 114 | 114 | |
| 115 | 115 | // Initialize the other parameters |
| 116 | + // Random seed | |
| 116 | 117 | g_rnd_seed=0x3045; |
| 118 | + // Clear variables | |
| 117 | 119 | for(i=0;i<ALLOC_BLOCK_NUM;i++){ |
| 118 | 120 | g_var_mem[i]=0; |
| 119 | 121 | g_var_size[i]=0; |
| 120 | 122 | } |
| 123 | + // Clear key input buffer | |
| 124 | + for(i=0;i<256;i++){ | |
| 125 | + ps2keystatus[i]=0; | |
| 126 | + } | |
| 121 | 127 | |
| 122 | 128 | // Assign memory |
| 123 | 129 | set_free_area((void*)(g_object+g_objpos),(void*)(&RAM[RAMSIZE])); |
| @@ -191,3 +191,15 @@ | ||
| 191 | 191 | // Divide by 36 (valid for 32 bits) |
| 192 | 192 | #define div36_32(x) div32(x,0xe38e38e4,37) |
| 193 | 193 | #define rem36_32(x) (x-36*div36_32(x)) |
| 194 | + | |
| 195 | +// Check break key or buttons when executing BASIC code. | |
| 196 | +// In PS/2 mode, detect ctrl-break. | |
| 197 | +// In button mode, detect pushing four buttons are pushed simultaneously. | |
| 198 | +#define check_break() \ | |
| 199 | + if (g_disable_break==0) {\ | |
| 200 | + if (inPS2MODE()) {\ | |
| 201 | + if (ps2keystatus[0x03]) err_break();\ | |
| 202 | + } else {\ | |
| 203 | + if ((PORTB&0x4c80)==0) err_break();\ | |
| 204 | + }\ | |
| 205 | + } |