非専門的シンギュラリティー研究所

無限に動き続けるシステムを表す方法を AI なども使って考えていきます。

X68000(31)

さらにコンパイラの出力から関数を作成しました。

楕円の扇型を描画する関数(インラインアセンブラ)

asm(
    "drawpiex_a:\n\t"
    "subq.l #4,%sp\n\t"
    "movem.l #7966,-(%sp)\n\t"
    "move.l 44(%sp),%d5\n\t"
    "move.l 48(%sp),%a6\n\t"
    "move.l 52(%sp),%d7\n\t"
    "move.l 56(%sp),%a4\n\t"
    "move.l 60(%sp),%a5\n\t"
    "move.l 64(%sp),36(%sp)\n\t"
    "move.l 68(%sp),%a3\n\t"
    "move.l 72(%sp),%d6\n\t"
    "moveq #-1,%d0\n\t"
    "move.l %d0,direct_draw_x\n\t"
    "move.l %a5,%d4\n\t"
    "jpl dpixL146\n\t"
    "addq.l #1,%d4\n\t"
    "dpixL146:\n\t"
    "asr.l #1,%d4\n\t"
    "add.l %d7,%d4\n\t"
    "move.l %a4,%d3\n\t"
    "jpl dpixL147\n\t"
    "addq.l #1,%d3\n\t"
    "dpixL147:\n\t"
    "asr.l #1,%d3\n\t"
    "add.l %a6,%d3\n\t"
    "move.l %d6,-(%sp)\n\t"
    "move.l %d4,-(%sp)\n\t"
    "move.l %d3,-(%sp)\n\t"
    "move.l %d5,-(%sp)\n\t"
    "jsr drawlinetox_a\n\t"
    "move.l %d6,-(%sp)\n\t"
    "move.l %a3,-(%sp)\n\t"
    "move.l 60(%sp),-(%sp)\n\t"
    "move.l %a5,-(%sp)\n\t"
    "move.l %a4,-(%sp)\n\t"
    "move.l %d7,-(%sp)\n\t"
    "move.l %a6,-(%sp)\n\t"
    "move.l %d5,-(%sp)\n\t"
    "jsr drawarctox_a\n\t"
    "lea (48,%sp),%sp\n\t"
    "move.l %d6,56(%sp)\n\t"
    "move.l %d4,52(%sp)\n\t"
    "move.l %d3,48(%sp)\n\t"
    "move.l %d5,44(%sp)\n\t"
    "movem.l (%sp)+,#30968\n\t"
    "addq.l #4,%sp\n\t"
    "jra drawlinetox_a\n\t"
);

楕円の扇型を描画する関数(インラインアセンブラの関数を呼び出す)

void drawpiex(int x1, int y1, int w, int h, int start_angle, int sweep_angle, COLORREF color) {
    asm(
        "move.l   %0, g_x1\n\t"
        "move.l   %1, g_y1\n\t"
        "move.l   %2, g_w\n\t"
        "move.l   %3, g_h\n\t"
        "move.l   %4, g_start_angle\n\t"
        "move.l   %5, g_sweep_angle\n\t"
        "move.w   %6, g_color\n\t"

        "clr.l	  -(%%sp)\n\t"
        "dc.w	  0xff20\n\t"      // _SUPER (スーパーバイザーモードへ)
        "move.l   %%d0, (%%sp)\n\t"

        "move.w   g_color, -(%%sp)\n\t"
        "move.l   g_sweep_angle, -(%%sp)\n\t"
        "move.l   g_start_angle, -(%%sp)\n\t"
        "move.l   g_h, -(%%sp)\n\t"
        "move.l   g_w, -(%%sp)\n\t"
        "move.l   g_y1, -(%%sp)\n\t"
        "move.l   g_x1, -(%%sp)\n\t"
        "move.l   #0, -(%%sp)\n\t"
        "jsr      drawpiex_a\n\t"
        "add.l    #30,%%sp\n\t"

        "dc.w	  0xff20\n\t"      // _SUPER (スーパーバイザーモードから戻る)
        "addq.l   #4, %%sp\n\t"
        :                        // 出力
        : "r"(x1), "r"(y1), "r"(w), "r"(h), "r"(start_angle), "r"(sweep_angle), "r"(color) // 入力
        : "d0"                   // 使用するレジスタ
        );
}

角が丸い四角形を描画する関数(インラインアセンブラ)

asm(
    "drawroundedrectanglex_a:\n\t"
    "lea (-24,%sp),%sp\n\t"
    "movem.l #7966,-(%sp)\n\t"
    "move.l 64(%sp),%d3\n\t"
    "move.l 68(%sp),%a3\n\t"
    "move.l 72(%sp),%d5\n\t"
    "move.l 80(%sp),44(%sp)\n\t"
    "move.l 84(%sp),%a5\n\t"
    "move.l 88(%sp),%d6\n\t"
    "move.l 92(%sp),%d4\n\t"
    "moveq #-1,%d0\n\t"
    "move.l %d0,direct_draw_x\n\t"
    "move.l %d6,%d0\n\t"
    "add.l %d6,%d0\n\t"
    "move.l %d0,40(%sp)\n\t"
    "move.l %a5,%d7\n\t"
    "add.l %a5,%d7\n\t"
    "move.l %a3,%d0\n\t"
    "add.l 76(%sp),%d0\n\t"
    "move.l %d0,52(%sp)\n\t"
    "move.l %d0,%a0\n\t"
    "sub.l %d7,%a0\n\t"
    "move.l %a0,48(%sp)\n\t"
    "move.l %d4,-(%sp)\n\t"
    "pea 90.w\n\t"
    "clr.l -(%sp)\n\t"
    "move.l 52(%sp),-(%sp)\n\t"
    "move.l %d7,-(%sp)\n\t"
    "move.l %d5,-(%sp)\n\t"
    "move.l %a0,-(%sp)\n\t"
    "move.l %d3,-(%sp)\n\t"
    "lea drawarctox_a,%a4\n\t"
    "jsr (%a4)\n\t"
    "lea (28,%sp),%sp\n\t"
    "move.l %d4,(%sp)\n\t"
    "move.l %d5,-(%sp)\n\t"
    "pea (%a5,%a3.l)\n\t"
    "move.l %d3,-(%sp)\n\t"
    "lea drawlinetox_a,%a6\n\t"
    "jsr (%a6)\n\t"
    "move.l %d4,-(%sp)\n\t"
    "pea 90.w\n\t"
    "pea 90.w\n\t"
    "move.l 68(%sp),-(%sp)\n\t"
    "move.l %d7,-(%sp)\n\t"
    "move.l %d5,-(%sp)\n\t"
    "move.l %a3,-(%sp)\n\t"
    "move.l %d3,-(%sp)\n\t"
    "jsr (%a4)\n\t"
    "move.l %d5,%d0\n\t"
    "add.l 92(%sp),%d0\n\t"
    "move.l %d0,92(%sp)\n\t"
    "sub.l %d6,%d0\n\t"
    "move.l %d0,104(%sp)\n\t"
    "lea (44,%sp),%sp\n\t"
    "move.l %d4,(%sp)\n\t"
    "move.l %d0,-(%sp)\n\t"
    "move.l %a3,-(%sp)\n\t"
    "move.l %d3,-(%sp)\n\t"
    "jsr (%a6)\n\t"
    "move.l 72(%sp),%d0\n\t"
    "sub.l %d6,%d0\n\t"
    "move.l %d4,-(%sp)\n\t"
    "pea 90.w\n\t"
    "pea 180.w\n\t"
    "move.l 68(%sp),-(%sp)\n\t"
    "move.l %d7,-(%sp)\n\t"
    "move.l %d0,-(%sp)\n\t"
    "move.l %a3,-(%sp)\n\t"
    "move.l %d3,-(%sp)\n\t"
    "move.l %d0,84(%sp)\n\t"
    "jsr (%a4)\n\t"
    "lea (44,%sp),%sp\n\t"
    "move.l %d4,(%sp)\n\t"
    "move.l 48(%sp),-(%sp)\n\t"
    "move.l 56(%sp),%a0\n\t"
    "pea (%a0,%a5.l)\n\t"
    "move.l %d3,-(%sp)\n\t"
    "jsr (%a6)\n\t"
    "move.l %d4,-(%sp)\n\t"
    "pea 90.w\n\t"
    "pea 270.w\n\t"
    "move.l 68(%sp),-(%sp)\n\t"
    "move.l %d7,-(%sp)\n\t"
    "move.l 72(%sp),%d0\n\t"
    "move.l %d0,-(%sp)\n\t"
    "move.l 88(%sp),-(%sp)\n\t"
    "move.l %d3,-(%sp)\n\t"
    "jsr (%a4)\n\t"
    "lea (48,%sp),%sp\n\t"
    "move.l %d4,76(%sp)\n\t"
    "add.l %d5,%d6\n\t"
    "move.l %d6,72(%sp)\n\t"
    "move.l 52(%sp),68(%sp)\n\t"
    "move.l %d3,64(%sp)\n\t"
    "movem.l (%sp)+,#30968\n\t"
    "lea (24,%sp),%sp\n\t"
    "jra drawlinetox_a\n\t"
);

角が丸い四角形を描画する関数(インラインアセンブラの関数を呼び出す)

void drawroundedrectanglex(int x1, int y1, int w, int h, int rx, int ry, COLORREF color) {
    asm(
        "move.l   %0, g_x1\n\t"
        "move.l   %1, g_y1\n\t"
        "move.l   %2, g_w\n\t"
        "move.l   %3, g_h\n\t"
        "move.l   %4, g_rx\n\t"
        "move.l   %5, g_ry\n\t"
        "move.w   %6, g_color\n\t"

        "clr.l	  -(%%sp)\n\t"
        "dc.w	  0xff20\n\t"      // _SUPER (スーパーバイザーモードへ)
        "move.l   %%d0, (%%sp)\n\t"

        "move.w   g_color, -(%%sp)\n\t"
        "move.l   g_ry, -(%%sp)\n\t"
        "move.l   g_rx, -(%%sp)\n\t"
        "move.l   g_h, -(%%sp)\n\t"
        "move.l   g_w, -(%%sp)\n\t"
        "move.l   g_y1, -(%%sp)\n\t"
        "move.l   g_x1, -(%%sp)\n\t"
        "move.l   #0, -(%%sp)\n\t"
        "jsr      drawroundedrectanglex_a\n\t"
        "add.l    #30,%%sp\n\t"

        "dc.w	  0xff20\n\t"      // _SUPER (スーパーバイザーモードから戻る)
        "addq.l   #4, %%sp\n\t"
        :                        // 出力
        : "r"(x1), "r"(y1), "r"(w), "r"(h), "r"(rx), "r"(ry), "r"(color) // 入力
        : "d0"                   // 使用するレジスタ
        );
}