Windows 版の SetPixel を使った直線を描画する関数 DirectDrawLine は以下のようになります。DirectDrawLineTo は連続した直線を描くときに使います。
X68000 で直接メモリーに書き込む形で描画するには、スーパーバイザモードに切り替えなければいけません。これが C++ でできるのかよくわからないので、インラインアセンブラの中でやろうと考えています。そうすると描画処理はアセンブリ言語で書く必要があります。いったんコンパイルした結果をインラインアセンブラの中に組み込めばできそうなので、まずこの方法でやってみたいと思います。
void DirectDrawLine(HDC hdc, int x1, int y1, int x2, int y2, COLORREF color) { int w = x2 - x1; int h = y2 - y1; if (abs(h) < abs(w)) { int d = w >= 0 ? 1 : -1; for (int x = x1; x * d < x2 * d; x += d) { int y = y1 + (h * (x - x1)) / w; SetPixel(hdc, x, y, color); } } else { int d = h >= 0 ? 1 : -1; for (int y = y1; y * d < y2 * d; y += d) { int x = x1 + (w * (y - y1)) / h; SetPixel(hdc, x, y, color); } } } int direct_draw_x = -1; int direct_draw_y = -1; void DirectDrawLineInit() { direct_draw_x = -1; direct_draw_y = -1; } void DirectDrawLineTo(HDC hdc, int x2, int y2, COLORREF color) { if (direct_draw_x >= 0 && direct_draw_y >= 0) { DirectDrawLine(hdc, direct_draw_x, direct_draw_y, x2, y2, color); } direct_draw_x = x2; direct_draw_y = y2; }




