/* dn_scrcolor.c original code: SASANO Takayoshi --- public domain, no warranty. */ #include #include #include #include #include #include #include #include LOCAL TC Target[] = {TK_S, TK_C, TK_R, TK_E, TK_E, TK_N, TK_NULL}; #define MAX_COLOR 4096 LOCAL COLOR ColorMap[MAX_COLOR]; EXPORT WERR main(W argc, TC *argv[]) { WERR err; W i, max, dd, rsz; /* 領域の初期化 */ memset(ColorMap, 0, sizeof(ColorMap)); /* デバイスをオープン */ err = opn_dev(Target, D_READ, NULL); if (err < ER_OK) { printf("/* opn_dev(): %d */\n", err); goto fin0; } dd = err; /* 必要最低限のエントリを取得 */ for (max = 1; max < MAX_COLOR; max++) { err = rea_dev(dd, DN_SCRCOLOR, (UB *)ColorMap, max * sizeof(COLOR), &rsz, NULL); if (err == ER_OK) break; } /* エントリが無い */ if (err < ER_OK) { printf("/* no entry */\n"); goto fin1; } printf("/* %d %s */\n", max, (max > 1) ? "entries" : "entry"); printf("{\n"); /* エントリの内容を表示 */ for (i = 0; i < max; i++) { if(!(i % 4)) printf("\t"); printf("0x%08x, ", ColorMap[i]); if((i % 4) == 3) printf("\n"); } printf("}\n"); err = ER_OK; fin1: cls_dev(dd, 0, NULL); fin0: return err; }