「10日くらいでできる!プログラミング言語自作入門」の続編#1-6b

(1) HL-16b






#include <acl.c>

AWindow *win;

void sub_print(int i)                  { printf("%d\n", i); }
void sub_time()                        { printf("time: %.3f[sec]\n", clock() / (double) CLOCKS_PER_SEC); }
int  sub_aRgb8(int r, int g, int b)    { return aRgb8(r, g, b); }
int  sub_XorShift()                    { return aXorShift32(); }
int  sub_aGetPix(int x, int y)         { return aGetPix(win, x, y); }
int  sub_f16Sin(int x)                 { return (int) (sin(x * (2 * 3.14159265358979323 / 65536)) * 65536); }
int  sub_f16Cos(int x)                 { return (int) (cos(x * (2 * 3.14159265358979323 / 65536)) * 65536); }
int  sub_aInkey(int opt)               { return aInkey(win, opt); }
void sub_prints(char *s)               { printf("%s\n", s); }
void sub_aSetPix0(int x, int y, int c) { aSetPix0(win, x, y, c); }
void sub_aFilRct0(int xsz, int ysz, int x0, int y0, int c)  { aFillRect0(win, xsz, ysz, x0, y0, c); }
void sub_aDrwStr0(int x, int y, int c, int b, char *s)      { aDrawStr0(win, x, y, c, b, s); }
void sub_gprDec(int x, int y, int w, int c, int b, int i)   { char s[100]; sprintf(s, "%*d", w, i); aDrawStr0(win, x, y, c, b, s); }

int sub_OpnWin(int xsz, int ysz, char *s)
{
    win = aOpenWin(xsz, ysz, s, 0);
    return 0;
}

int sub_aWait(int msec)
{
    aWait(msec);
    return 0;
}

void sub_bitblt(int xsz, int ysz, int x0, int y0, int *a)
{
    AInt32 *p32 = &win->buf[x0 + y0 * win->xsiz];
    int i, j;
    for (j = 0; j < ysz; j++) {
        for (i = 0; i < xsz; i++) {
            p32[i] = a[i];
        }
        a += xsz;
        p32 += win->xsiz;
    }
}

AInt *sub_aryNew(int n)
{
    int *p = malloc(n * sizeof (AInt));
    memset((char *) p, 0, n * sizeof (AInt));
    return p;
}

void sub_aryInit(AInt *a, AInt *ip, int n)
{
    memcpy((char *) a, (char *) ip, n * sizeof (AInt));
}

(2) プログラムの説明

次回に続く

こめんと欄


コメントお名前NameLink

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS