Files
VCCPlusOSS/examples/cmoc/manual/beacon.c
T

42 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Draw a small landing beacon on a CoCo 3. Link bgraph. */
#include <coco.h>
#include <Primitive.h>
/* BGraph's 320x16 routines use 160 bytes per row. We need just 13 rows. */
enum { SIDE = 13, MIDDLE = 6, STRIDE = 160, INK = 3 };
static byte stamp[SIDE * STRIDE];
int main(void)
{
byte x, y;
byte *slots = (byte *) 0xFFB0;
byte oldPaper = slots[0] & 63, oldInk = slots[INK] & 63;
if (!hscreen(2))
return 1;
paletteRGB(0, 0, 0, 0);
paletteRGB(INK, 3, 3, 3);
for (x = 0; x < SIDE; ++x)
{
Primitive_setPixel320x16(x, MIDDLE, INK, stamp);
Primitive_setPixel320x16(MIDDLE, x, INK, stamp);
}
/* Let Disk BASIC find the visible page. Magnify each stamp dot 3 by 3. */
for (y = 0; y < SIDE; ++y)
for (x = 0; x < SIDE; ++x)
{
byte dx, dy;
byte color = Primitive_getPixel320x16(x, y, stamp);
for (dy = 0; dy < 3; ++dy)
for (dx = 0; dx < 3; ++dx)
hset(140 + 3 * x + dx, 76 + 3 * y + dy, color);
}
waitkey(FALSE);
hscreen(0);
palette(0, oldPaper);
palette(INK, oldInk);
printf("BEACON CENTER: %u\n", (unsigned) Primitive_getPixel320x16(MIDDLE, MIDDLE, stamp));
return 0;
}