「PC-98/sint」の編集履歴(バックアップ)一覧はこちら

PC-98/sint - (2021/03/17 (水) 17:44:43) の1つ前との変更点

追加された行は緑色になります。

削除された行は赤色になります。

開発環境 -QuickC JavaScriptプロトタイプ https://jsfiddle.net/gm1zvoer/ sint.c #highlight(c){{ #include <conio.h> #include <dos.h> #include <math.h> #define PI 3.141592653589793 #define BASE 0x100 #define CYCLE 256 #define FOV 40 typedef unsigned char BYTE; typedef unsigned short WORD; typedef signed short SWORD; typedef signed long SDWORD; typedef struct { SWORD x; SWORD y; } vec2; typedef struct { BYTE d; } CAR; // 関数プロトタイプ宣言 void setup(); void draw(); void pset(BYTE x, BYTE y); void flip(); void cls(); SWORD mul(SWORD x, SWORD y); // 外部変数 WORD page = 0; SWORD sint[CYCLE]; CAR car = { 0 }; int main() { setup(); while (! kbhit()) { draw(); car.d++; } page = 0; flip(); return 0; } void setup() { union REGS inregs, outregs; float x; int i; inregs.h.ah = 0x0a; // テキスト画面モードの設定 inregs.h.al = 0x04; // 簡易グラフ int86(0x18, &inregs, &outregs); inregs.h.ah = 0x16; // テキストVRAMのクリア inregs.h.dh = 0x91; // アトリビュートデータ inregs.h.dl = 0x00; // ANK文字コード int86(0x18, &inregs, &outregs); for (i = 0; i < CYCLE; i++) { x = sin(2 * PI * i / CYCLE); sint[i] = (SWORD)(x * BASE + .5); } } void draw() { BYTE t, px, py; SWORD s, c, x; vec2 rd; int i; t = car.d; s = sint[t]; t += (CYCLE/4); c = sint[t]; cls(); x = -BASE; for (i = 0; i < FOV; i++) { rd.x = mul(c, x) + s; rd.y = c - mul(s, x); px = (BYTE)(80 + rd.x * 30 / BASE); py = (BYTE)(50 - rd.y * 30 / BASE); pset(px, py); x += (2 * BASE / FOV); } flip(); page ^= 0x1000; } void pset(BYTE x, BYTE y) { BYTE xh, xl, yh, yl; char far* lp; if (x >= 160 || y >= 100) return; xh = x & 0xfe; xl = (x & 0x01) << 2; yh = y / 4; yl = y - yh * 4; lp = (char far*)(0xa0000000 + page + yh * 160 + xh); *lp |= 1 << (xl + yl); } void flip() { union REGS inregs, outregs; inregs.h.ah = 0x0e; // テキスト画面表示領域設定 inregs.x.dx = page; // T-VRAMの表示する領域の先頭アドレス int86(0x18, &inregs, &outregs); } void cls() { _asm { push di push es mov ax, 0a000h mov es, ax mov ax, 0000h mov di, page mov cx, 2000 cld rep stosw pop es pop di } } SWORD mul(SWORD x, SWORD y) { return (SWORD)((SDWORD)x * (SDWORD)y / BASE); } }} mk.bat #highlight(txt){{ qcl /c sint.c link sint; }} &image(sint.png)
開発環境 -QuickC [[JavaScript]]プロトタイプ https://jsfiddle.net/gm1zvoer/ sint.c #highlight(c){{ #include <conio.h> #include <dos.h> #include <math.h> #define PI 3.141592653589793 #define BASE 0x100 #define CYCLE 256 #define FOV 40 typedef unsigned char BYTE; typedef unsigned short WORD; typedef signed short SWORD; typedef signed long SDWORD; typedef struct { SWORD x; SWORD y; } vec2; typedef struct { BYTE d; } CAR; // 関数プロトタイプ宣言 void setup(); void draw(); void pset(BYTE x, BYTE y); void flip(); void cls(); SWORD mul(SWORD x, SWORD y); // 外部変数 WORD page = 0; SWORD sint[CYCLE]; CAR car = { 0 }; int main() { setup(); while (! kbhit()) { draw(); car.d++; } page = 0; flip(); return 0; } void setup() { union REGS inregs, outregs; float x; int i; inregs.h.ah = 0x0a; // テキスト画面モードの設定 inregs.h.al = 0x04; // 簡易グラフ int86(0x18, &inregs, &outregs); inregs.h.ah = 0x16; // テキストVRAMのクリア inregs.h.dh = 0x91; // アトリビュートデータ inregs.h.dl = 0x00; // ANK文字コード int86(0x18, &inregs, &outregs); for (i = 0; i < CYCLE; i++) { x = sin(2 * PI * i / CYCLE); sint[i] = (SWORD)(x * BASE + .5); } } void draw() { BYTE t, px, py; SWORD s, c, x; vec2 rd; int i; t = car.d; s = sint[t]; t += (CYCLE/4); c = sint[t]; cls(); x = -BASE; for (i = 0; i < FOV; i++) { rd.x = mul(c, x) + s; rd.y = c - mul(s, x); px = (BYTE)(80 + rd.x * 30 / BASE); py = (BYTE)(50 - rd.y * 30 / BASE); pset(px, py); x += (2 * BASE / FOV); } flip(); page ^= 0x1000; } void pset(BYTE x, BYTE y) { BYTE xh, xl, yh, yl; char far* lp; if (x >= 160 || y >= 100) return; xh = x & 0xfe; xl = (x & 0x01) << 2; yh = y / 4; yl = y - yh * 4; lp = (char far*)(0xa0000000 + page + yh * 160 + xh); *lp |= 1 << (xl + yl); } void flip() { union REGS inregs, outregs; inregs.h.ah = 0x0e; // テキスト画面表示領域設定 inregs.x.dx = page; // T-VRAMの表示する領域の先頭アドレス int86(0x18, &inregs, &outregs); } void cls() { _asm { push di push es mov ax, 0a000h mov es, ax mov ax, 0000h mov di, page mov cx, 2000 cld rep stosw pop es pop di } } SWORD mul(SWORD x, SWORD y) { return (SWORD)((SDWORD)x * (SDWORD)y / BASE); } }} mk.bat #highlight(txt){{ qcl /c sint.c link sint; }} &image(sint.png)

表示オプション

横に並べて表示:
変化行の前後のみ表示: