Files
Sprinter-SDCC/tests/bgitest/bgitest.c
T
snark13 25cb7ba554 libc: BGI Фаза 2d-1 — getimage/putimage/imagesize (спрайты)
Растровые образы: imagesize (4 байта заголовка w,h + w*h пикселей),
getimage (захват прямоугольника), putimage с COPY/XOR/OR/AND/NOT_PUT.
Блит идёт raw в одной W3-скобке — добавлен _gfx_getpixel256_raw в gfx +
leaf _bgi_read_raw в drv256. Проверено в MAME (tests/bgitest): захват
спрайта, 3 COPY-копии, XOR/OR/COPY поверх фона.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 16:09:51 +03:00

56 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* bgitest — демонстрация BGI-слоя graphics.h (режим 320×256×256).
* Фаза 2d-1: getimage/putimage/imagesize (спрайты, COPY/XOR/OR).
*/
#include <graphics.h>
static unsigned char buf[2048];
int main(void)
{
int mx, my;
initgraph();
mx = getmaxx();
my = getmaxy();
cleardevice();
setcolor(WHITE);
rectangle(0, 0, mx, my);
setcolor(YELLOW);
outtextxy(88, 6, "BGI image / sprite");
/* Исходный спрайт 40×30 в левом верхнем углу. */
setfillstyle(SOLID_FILL, LIGHTBLUE);
bar(12, 28, 51, 57);
setcolor(YELLOW);
rectangle(12, 28, 51, 57);
setcolor(LIGHTRED);
line(12, 28, 51, 57);
setfillstyle(SOLID_FILL, LIGHTGREEN);
fillellipse(31, 42, 8, 8);
setcolor(WHITE);
outtextxy(12, 60, "src");
/* Захват и раскладка копий (COPY_PUT). */
getimage(12, 28, 51, 57, buf);
putimage(80, 28, buf, COPY_PUT);
putimage(130, 28, buf, COPY_PUT);
putimage(180, 28, buf, COPY_PUT);
setcolor(WHITE);
outtextxy(80, 60, "copy x3");
/* XOR и OR поверх серого фона. */
setfillstyle(SOLID_FILL, DARKGRAY);
bar(20, 110, 240, 170);
putimage(30, 122, buf, XOR_PUT);
outtextxy(30, 176, "xor");
putimage(110, 122, buf, OR_PUT);
outtextxy(110, 176, "or");
putimage(190, 122, buf, COPY_PUT);
outtextxy(190, 176, "copy");
for (;;) { }
}