• R/O
  • HTTP
  • SSH
  • HTTPS

HeavyOSECPU: Commit


Commit MetaInfo

Revisiónf26f3c31cf3d5cd80d2be5d7056c15f3eb382957 (tree)
Tiempo2014-03-13 14:49:53
Autorttwilb <ttwilb@user...>
Commiterttwilb

Log Message

API comment added

Cambiar Resumen

Diferencia incremental

--- a/function.c
+++ b/function.c
@@ -44,6 +44,7 @@ void devFunc0001(int len, unsigned char *puc, HOSECPU_RuntimeEnvironment *r)
4444 return;
4545 }
4646
47+// drawString
4748 void devFunc0006(int mod, int sx, int sy, int x, int y, int c, int len, unsigned char *puc, HOSECPU_RuntimeEnvironment *r)
4849 {
4950 int xx;
@@ -269,7 +270,8 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
269270 printf("R31=%d(dec)\n", r->ireg[0x31]);
270271 break;
271272
272- case 0xff01:
273+ case 0xff01: // junkApi_fopenRead(_filesize, _p, arg) R31=arg; PCALL(P28); _filesize=R30; _p=P31
274+
273275 /* return: R30, P31 */
274276 if (r->buf0 == NULL){
275277 r->buf0 = malloc(1024 * 1024);
@@ -296,7 +298,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
296298 r->ireg[0x30] = i;
297299 break;
298300
299- case 0xff02:
301+ case 0xff02: // junkApi_fopenWrite(arg, filesize, p) R31=arg; R32=filesize; P31=p;
300302 /* return: none */
301303 if (r->mainArgc <= r->ireg[0x31]) {
302304 fprintf(stderr, "devFunc: error: R30=ff02: argc error: R31=%08X\n", r->ireg[0x31]);
@@ -315,7 +317,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
315317 fclose(fp);
316318 break;
317319
318- case 0xff03:
320+ case 0xff03: // junkApi_allocBuf(_p) _p=P31
319321 /* return: P31 */
320322 if (r->buf1 == NULL){
321323 r->buf1 = malloc(1024 * 1024);
@@ -329,23 +331,23 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
329331 printf("P31.(p-p0)=%d(dec)\n", (int)(r->preg[0x31].p - r->preg[0x31].p0));
330332 break;
331333
332- case 0xff05:
334+ case 0xff05: // junkApi_writeStdout(len, p) R31=len; P31=p;
333335 fwrite(r->preg[0x31].p, 1, r->ireg[0x31], stdout);
334336 break;
335337
336- case 0xff06:
338+ case 0xff06: // jnukApi_exit(i) R31=i;
337339 // R31はリターンコード.
338340 // これを反映すべきだが、現状は手抜きでいつも正常終了.
339341 longjmp(*(r->setjmpEnv), 1);
340342 break;
341343
342- case 0xff07:
344+ case 0xff07: // junkApi_putConstString0(s) DB(0xff,0x00,0x00); DB%(s,0x00);
343345 // マシになった文字列表示.OSASK文字列に対応.offにすれば通常の文字列処理もできる.現状はonのみサポート.
344346 checkString(r, 0x31, 0x31);
345347 devFunc0001(r->ireg[0x31], r->preg[0x31].p, r);
346348 break;
347349
348- case 0xff08:
350+ case 0xff08: // junkApi_jitc2(_rc, _p, mod, lev, di1, len, s) R31=mod; R32=lev; R33=di1; R34=len; P31=s; _rc=R30; _p=P31
349351 // JITC on JITC
350352 // R31: 言語(back-end, front-end, ...
351353 // R32: level
@@ -380,14 +382,14 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
380382 r->ireg[0x30] = -1;
381383 break;
382384
383- case 0xff09:
385+ case 0xff09: //putStringDec
384386 // たぶんbit7を使ったテキストはうまく処理できない(これはもはや仕様にしても問題ないかも).
385387 checkString(r, 0x31, 0x31);
386388 len = devFunc0016(sizeof pucbuf, pucbuf, r->ireg[0x31], r->preg[0x31].p, r->ireg[0x32], (int *)r->preg[0x32].p, r);
387389 devFunc0001(len, pucbuf, r);
388390 break;
389391
390- case 0xff40:
392+ case 0xff40: // junkApi_openWin(xsiz, ysiz) R31=xsiz; R32=ysiz;
391393 /* R31とR32でサイズを指定 */
392394 mainWindow.xsize = r->ireg[0x31];
393395 mainWindow.ysize = r->ireg[0x32];
@@ -405,7 +407,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
405407 }
406408 break;
407409
408- case 0xff41:
410+ case 0xff41: // junkApi_flushWin(xsiz, ysiz, x0, y0) R31=xsiz; R32=ysiz; R33=x0; R34=y0
409411 /* R31とR32でサイズを指定、R33とR34でx0,y0指定 */
410412 if (r->ireg[0x31] == -1) {
411413 r->ireg[0x31] = mainWindow.xsize; r->ireg[0x33] &= 0;
@@ -417,7 +419,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
417419 drv_flshWin(r->ireg[0x31], r->ireg[0x32], r->ireg[0x33], r->ireg[0x34]);
418420 break;
419421
420- case 0xff42:
422+ case 0xff42: // junkApi_sleep(opt, msec) R31=opt; R32=msec
421423 if (r->ireg[0x32] == -1) {
422424 r->autoSleep = 1;
423425 longjmp(*(r->setjmpEnv), 1);
@@ -441,7 +443,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
441443 }
442444 break;
443445
444- case 0xff43:
446+ case 0xff43: // junkApi_inkey(_i, mod) R31=mod; _i=R30
445447 // 1:peek
446448 // 2:stdin
447449 // 4,8: ソース指定.
@@ -475,7 +477,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
475477 if (r->ireg[0x30] == 4135) r->ireg[0x33]++;
476478 break;
477479
478- case 0xff44:
480+ case 0xff44: // junkApi_drawPoint(mod, x, y, c) R31=mod; R32=x; R33=y; R34=c
479481 c = loadColor(r, 0x34);
480482 if (r->ireg[0x32] < 0 || r->ireg[0x32] >= mainWindow.xsize ||
481483 r->ireg[0x33] < 0 || r->ireg[0x33] >= mainWindow.ysize){
@@ -498,7 +500,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
498500 }
499501 break;
500502
501- case 0xff45:
503+ case 0xff45: // junkApi_drawLine(mod, x0, y0, x1, y1, c) DB(0xfe,0x05,0x01); DDBE(0x0003); R30=0xff45; R31=mod; R32=x0; R33=y0; R34=x1; R35=y1; R36=c
502504 //drawLine
503505 c = loadColor(r, 0x36);
504506 if (r->ireg[0x32] < 0 || r->ireg[0x32] >= mainWindow.xsize ||
@@ -654,7 +656,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
654656 devFunc0006(r->ireg[0x31], r->ireg[0x32], r->ireg[0x33], r->ireg[0x34], r->ireg[0x35], loadColor(r, 0x36), r->ireg[0x37], r->preg[0x31].p, r);
655657 break;
656658
657- case 0xff49:
659+ case 0xff49: // junkApi_rand(_r, range) R31=range; _r=R30
658660 // **** junkApi_rand(i, max) ****
659661 // 0 <= i <= maxとなるiを返す。
660662 // max==0のとき、iはSINT32全体を範囲とする乱数となる。
@@ -672,7 +674,7 @@ void devFunc(HOSECPU_RuntimeEnvironment *r)
672674 r->ireg[0x30] = (int)(time(NULL) ^ (long)0x55555555);
673675 break;
674676
675- case 0xff4c:
677+ case 0xff4c: // drawStringDec
676678 checkString(r, 0x37, 0x31);
677679 len = devFunc0016(sizeof pucbuf, pucbuf, r->ireg[0x37], r->preg[0x31].p, r->ireg[0x38], (int *)r->preg[0x32].p, r);
678680 devFunc0006(r->ireg[0x31], r->ireg[0x32], r->ireg[0x33], r->ireg[0x34], r->ireg[0x35], loadColor(r, 0x36), len, pucbuf, r);
--- a/main.c
+++ b/main.c
@@ -118,10 +118,12 @@ int HeavyOSECPUMain(int argc, char **argv)
118118 if (cp != NULL){
119119 stacksiz = strtol(cp, NULL, 0);
120120 }
121+
122+ // jitbufは先頭。 jpは現在位置
121123 jp = jitbuf; /* JIT-pointer */
122124
123125 /* フロントエンドコードをバックエンドコードに変換する */
124- if ((env.appBin[2] & 0xf0) != 0) {
126+ if ((env.appBin[2] & 0xf0) != 0) { // 3バイト目が00なら処理しない
125127 systmp0[0] = env.appBin[0];
126128 systmp0[1] = env.appBin[1];
127129 env.preg[2].p = systmp0 + 2;
@@ -190,10 +192,13 @@ int HeavyOSECPUMain(int argc, char **argv)
190192 }
191193
192194 env.buf0 = env.buf1 = NULL;
193- env.preg[0x28].p = p28;
195+
196+ // p28にapiをコールするアドレスを設定
197+ env.preg[0x28].p = p28; // p28には、devFuncをコールするコードが書かれている
194198 env.preg[0x28].typ = 0; // TYP_CODE
195- env.preg[0x28].p0 = p28;
196- env.preg[0x28].p1 = p28 + 1;
199+ env.preg[0x28].p0 = p28; // アドレス演算できる範囲を制限
200+ env.preg[0x28].p1 = p28 + 1; // アドレス演算できる範囲を制限
201+
197202 //env.preg[0x00].p = malloc(1024 * 1024) + (1024 * 1024 - 32);
198203 env.junkStack = malloc(stacksiz << 20);
199204 env.junkStack1 = env.junkStack + (stacksiz << 20);
Show on old repository browser