Update GodDoodle.ZC

Run code through https://techiedelight.com/tools/clike
This commit is contained in:
Arsenic Blood 2023-10-08 22:40:37 -04:00 committed by GitHub
parent fcedd4b421
commit f0df38f5c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,8 +3,10 @@
U0 GodDoodleDraw(CTask *task, CDC *dc)
{
GrBlot(dc, 0, 0, god.doodle_dc);
if (Blink) {
if (god.doodle_done) {
if (Blink)
{
if (god.doodle_done)
{
dc->color = RED;
GrPrint(dc, (task->pix_width - FONT_WIDTH * 29) >> 1,
(task->pix_height - 3 * FONT_HEIGHT) >> 1,
@ -12,7 +14,9 @@ U0 GodDoodleDraw(CTask *task,CDC *dc)
GrPrint(dc, (task->pix_width - FONT_WIDTH * 39) >> 1,
(task->pix_height - 3 * FONT_HEIGHT) >> 1 + 2 * FONT_HEIGHT,
"Press <SHIFT-ESC> to throw-away sprite.");
} else {
}
else
{
dc->color = GREEN;
GrPrint(dc, (task->pix_width - FONT_WIDTH * 25) >> 1,
(task->pix_height - FONT_HEIGHT) >> 1,
@ -27,41 +31,51 @@ U0 GodDoodleSmooth(I64 num)
god.doodle_dc->width - 1, god.doodle_dc->height - 1);
I64 i, x, y, x1, y1, c, histogram[16], best, best_cnt, c_old = god.doodle_dc->color;
for (y = 0; y < god.doodle_dc->height; y++)
for (x=0;x<god.doodle_dc->width;x++) {
for (x = 0; x < god.doodle_dc->width; x++)
{
MemSet(histogram, 0, sizeof(histogram));
for (y1 = y - num; y1 <= y + num; y1++)
for (x1=x-num;x1<=x+num;x1++) {
for (x1 = x - num; x1 <= x + num; x1++)
{
c = GrPeek(dc, x1, y1);
if (0 <= c <= 15)
histogram[c]++;
}
best = BLACK;
best_cnt = -1;
for (i = 0; i < 16; i++)
if (histogram[i]>best_cnt) {
if (histogram[i] > best_cnt)
{
best = i;
best_cnt = histogram[i];
}
god.doodle_dc->color = best;
GrPlot(god.doodle_dc, x, y);
}
god.doodle_dc->color = c_old;
DCDel(dc);
}
U0 GodDoodleBitsIns(I64 num_bits, I64 n)
{//Insert bits into God doodle bit fifo.
{
//Insert bits into God doodle bit fifo.
I64 i;
for (i=0;i<num_bits;i++) {
for (i = 0; i < num_bits; i++)
{
FifoU8Insert(god.doodle_fifo, n & 1);
n >>= 1;
}
}
U0 GodDoodleHexIns(U8 *st)
{//Insert hex record into God doodle bit fifo.
{
//Insert hex record into God doodle bit fifo.
U8 buf[2];
if (st) {
if (st)
{
buf[1] = 0;
while (*buf = *st++)
if (Bt(char_bmp_hex_numeric, *buf))
@ -73,32 +87,41 @@ I64 GodDoodleBits(I64 num_bits)
{
U8 b;
I64 res = 0;
while (num_bits) {
if (FifoU8Remove(god.doodle_fifo,&b)) {
while (num_bits)
{
if (FifoU8Remove(god.doodle_fifo, &b))
{
res = res << 1 + b;
num_bits--;
} else {
}
else
{
god.doodle_ch = CharGet(, FALSE);
if (god.doodle_ch == CH_ESC || god.doodle_ch == CH_SHIFT_ESC)
throw;
else if (god.doodle_ch=='\n') {
else if (god.doodle_ch == '\n')
{
DCFill(god.doodle_dc, WHITE);
FifoU8Flush(god.doodle_fifo);
} else if ('0'<=god.doodle_ch<='9')
}
else if ('0' <= god.doodle_ch <= '9')
GodDoodleSmooth(god.doodle_ch - '0');
else
GodDoodleBitsIns(GOD_GOOD_BITS, KbdMouseEventTime >> GOD_BAD_BITS);
}
}
return res;
}
public U8 *GodDoodleSprite(U8 *hex = NULL)
{//Make God draw sprite. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
{
//Make God draw sprite. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
I64 i, j, w, h, x, y, ch;
U8 *elems;
if (god.doodle_dc) return NULL;
if (god.doodle_dc)
return NULL;
god.doodle_done = FALSE;
SettingsPush; //See $LK,"SettingsPush",A="MN:SettingsPush"$
AutoComplete;
@ -118,11 +141,14 @@ public U8 *GodDoodleSprite(U8 *hex=NULL)
Fs->draw_it = &GodDoodleDraw;
FifoU8Flush(god.doodle_fifo);
GodDoodleHexIns(hex);
try {
for (i=0;i<3;i++) {
try
{
for (i = 0; i < 3; i++)
{
god.doodle_dc->color = RED;
for (j = 0; j < 29; j++)
switch [GodDoodleBits(3)] {
switch[GodDoodleBits(3)]
{
case 0:
GrEllipse3(god.doodle_dc,
(w - 1) * GodDoodleBits(5) / 15.5 - w / 2,
@ -147,29 +173,49 @@ public U8 *GodDoodleSprite(U8 *hex=NULL)
(w - 1) * GodDoodleBits(4) / 15, (h - 1) * GodDoodleBits(4) / 15, 0);
break;
}
for (j=0;j<6;j++) {
for (j = 0; j < 6; j++)
{
x = (w - 1) * GodDoodleBits(5) / 31 + w / 64;
y = (h - 1) * GodDoodleBits(5) / 31 + h / 64;
switch [GodDoodleBits(2)] {
case 0: god.doodle_dc->color=BLACK; break;
case 1: god.doodle_dc->color=DKGRAY; break;
case 2: god.doodle_dc->color=LTGRAY; break;
case 3: god.doodle_dc->color=WHITE; break;
switch[GodDoodleBits(2)]
{
case 0:
god.doodle_dc->color = BLACK;
break;
case 1:
god.doodle_dc->color = DKGRAY;
break;
case 2:
god.doodle_dc->color = LTGRAY;
break;
case 3:
god.doodle_dc->color = WHITE;
break;
}
GrFloodFill3(god.doodle_dc, x, y, 0);
}
GodDoodleSmooth(3);
}
god.doodle_done = TRUE;
if (!hex) {
if (!hex)
{
do ch = CharGet(, FALSE);
while (ch != CH_ESC && ch != CH_SHIFT_ESC);
} else
}
else
ch = CH_ESC;
} catch {
}
catch
{
Fs->catch_except = TRUE;
ch = CH_SHIFT_ESC;
}
DCFill;
SettingsPop;
if (ch == CH_ESC)
@ -183,9 +229,11 @@ public U8 *GodDoodleSprite(U8 *hex=NULL)
#help_index "God"
public U0 GodDoodle(U8 *hex = NULL)
{//Make God draw sprite, insert in doc. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
{
//Make God draw sprite, insert in doc. $LK+PU,"Holy Spirit Instructions",A="FI:::/Adam/God/HSNotes.DD"$
U8 *elems;
if (elems=GodDoodleSprite(hex)) {
if (elems = GodDoodleSprite(hex))
{
Sprite(elems);
Free(elems);
}