BASIC compiler/interpreter for PIC32MX/MZ-80K (suspended)
| Revision | 144 (tree) |
|---|---|
| Time | 2016-07-31 11:59:17 |
| Author | kmorimatsu |
1) ver: KM-1200 2) "USEGRAPHIC 0" feature modification 3) Shift current point after GPRINT statement
| @@ -137,9 +137,10 @@ | ||
| 137 | 137 | 様々なシステム値の設定を行なう。<SYSTEM>の項を参照。 |
| 138 | 138 | USEGRAPHIC [x] |
| 139 | 139 | グラフィックディスプレイを使用、もしくは使用停止する。x=0で使用停止、 |
| 140 | - x=1で使用、x=2でキャラクターをリセットして使用、x=3でグラフィック領域 | |
| 141 | - を確保するが表示はキャラクターディスプレイのまま。xを省略した場合は、 | |
| 142 | - x=1と同じ。 | |
| 140 | + x=1で使用、x=2で画面とパレットをクリアーして使用、x=3でグラフィック領 | |
| 141 | + 域を確保するが表示はキャラクターディスプレイのまま。ただし、グラフィッ | |
| 142 | + クディスプレイ未使用の状態でx=0の場合は、領域を確保する。xを省略した場 | |
| 143 | + 合は、x=1と同じ。 | |
| 143 | 144 | USEPCG [x] |
| 144 | 145 | PCGを使用、もしくは使用停止する。x=0で使用停止、x=1で使用、x=2で |
| 145 | 146 | キャラクターをリセットして使用。xを省略した場合は、x=1と同じ。 |
| @@ -475,7 +476,7 @@ | ||
| 475 | 476 | SYSTEM$(1) |
| 476 | 477 | MachiKania バージョン文字列、"1.0"等を返す。 |
| 477 | 478 | SYSTEM$(2) |
| 478 | - BASIC バージョン文字列、"KM-1130"等を返す。 | |
| 479 | + BASIC バージョン文字列、"KM-1200"等を返す。 | |
| 479 | 480 | SYSTEM$(3) |
| 480 | 481 | 現在実行中のHEXファイル名、"ZOEA.HEX"等を返す。 |
| 481 | 482 | SYSTEM(20) |
| @@ -541,7 +542,7 @@ | ||
| 541 | 542 | てみて下さい。 |
| 542 | 543 | |
| 543 | 544 | <バージョン履歴> |
| 544 | -・KM-1130 2016年公開。 | |
| 545 | +・KM-1200 2016年8月公開。 | |
| 545 | 546 | 1.グラフィックディスプレイ機能および、関連のステートメント群を追加。 |
| 546 | 547 | 2.浮動小数点演算機能、及び、算術演算関数群を追加。 |
| 547 | 548 | 3.VAR, BREAK, SYSTEMステートメントを追加。 |
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | |
| 8 | 8 | #define SYSVER1 "Zoea" |
| 9 | 9 | #define SYSVER2 "0.5" |
| 10 | -#define BASVER "KM-1130" | |
| 10 | +#define BASVER "KM-1200" | |
| 11 | 11 | |
| 12 | 12 | #define FILENAME_FLASH_ADDRESS 0x9D005800 |
| 13 | 13 | #define PIC32MX_RAMSIZE 0x10000 |
| @@ -501,14 +501,28 @@ | ||
| 501 | 501 | } |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | +void allocate_graphic_area(){ | |
| 505 | + if (!g_graphic_area) { | |
| 506 | + // Use this pointer like unsigned short GVRAM[G_H_WORD*G_Y_RES] __attribute__ ((aligned (4))); | |
| 507 | + g_graphic_area=(unsigned short*)alloc_memory(G_H_WORD*G_Y_RES/2,ALLOC_GRAPHIC_BLOCK); | |
| 508 | + // Start graphic and clear screen | |
| 509 | + init_graphic(g_graphic_area); | |
| 510 | + // Move current point to (0,0) | |
| 511 | + g_prev_x=g_prev_y=0; | |
| 512 | + } | |
| 513 | +} | |
| 514 | + | |
| 504 | 515 | void lib_usegraphic(int mode){ |
| 505 | 516 | // Modes; 0: stop GRAPHIC, 1: use GRAPHIC, 2: reset GRAPHIC and use it |
| 506 | 517 | switch(mode){ |
| 507 | 518 | case 0: |
| 508 | - // Stop GRAPHIC | |
| 509 | 519 | if (g_use_graphic){ |
| 520 | + // Stop GRAPHIC if used | |
| 510 | 521 | set_graphmode(0); |
| 511 | 522 | g_use_graphic=0; |
| 523 | + } else { | |
| 524 | + // Prepare GRAPHIC area if not used and not allcated. | |
| 525 | + allocate_graphic_area(); | |
| 512 | 526 | } |
| 513 | 527 | break; |
| 514 | 528 | case 2: |
| @@ -519,12 +533,8 @@ | ||
| 519 | 533 | case 3: |
| 520 | 534 | default: |
| 521 | 535 | // Use GRAPHIC |
| 522 | - if (!g_graphic_area) { | |
| 523 | - // Use this pointer like unsigned short GVRAM[G_H_WORD*G_Y_RES] __attribute__ ((aligned (4))); | |
| 524 | - g_graphic_area=(unsigned short*)alloc_memory(G_H_WORD*G_Y_RES/2,ALLOC_GRAPHIC_BLOCK); | |
| 525 | - // Start graphic and clear screen | |
| 526 | - init_graphic(g_graphic_area); | |
| 527 | - } | |
| 536 | + allocate_graphic_area(); | |
| 537 | + // Start showing GRAPHIC with mode 1, but not with mode 3 | |
| 528 | 538 | if (mode !=3 && !g_use_graphic){ |
| 529 | 539 | set_graphmode(1); |
| 530 | 540 | g_use_graphic=1; |
| @@ -534,6 +544,7 @@ | ||
| 534 | 544 | } |
| 535 | 545 | |
| 536 | 546 | int lib_graphic(int a0, int a1, int v0){ |
| 547 | + unsigned char b; | |
| 537 | 548 | enum functions func=(enum functions)(a0>>24); |
| 538 | 549 | int x1=(a0>>12)&0x0FFF; |
| 539 | 550 | int y1=a0&0x0FFF; |
| @@ -586,6 +597,16 @@ | ||
| 586 | 597 | break; |
| 587 | 598 | case FUNC_GPRINT:// X1,Y1,C,BC,S$ |
| 588 | 599 | g_printstr(x1,y1,x2,y2,(unsigned char*)v0); |
| 600 | + // Move current X,Y according to the string | |
| 601 | + while(b=((unsigned char*)v0)[0]){ | |
| 602 | + v0++; | |
| 603 | + if (b==0x0d) { | |
| 604 | + x1=0; | |
| 605 | + y1+=8; | |
| 606 | + } else { | |
| 607 | + x1+=8; | |
| 608 | + } | |
| 609 | + } | |
| 589 | 610 | g_prev_x=x1; |
| 590 | 611 | g_prev_y=y1; |
| 591 | 612 | break; |
| @@ -928,6 +949,7 @@ | ||
| 928 | 949 | return v0; |
| 929 | 950 | case LIB_GCLS: |
| 930 | 951 | if (g_graphic_area) g_clearscreen(); |
| 952 | + g_prev_x=g_prev_y=0; | |
| 931 | 953 | return v0; |
| 932 | 954 | case LIB_COLOR: |
| 933 | 955 | setcursorcolor(v0); |