Cosmos icon indicating copy to clipboard operation
Cosmos copied to clipboard

YASM!

Open CorgiMasterEpic opened this issue 1 year ago • 3 comments

Area of Cosmos - What area of Cosmos are we dealing with?

Compiling with yasm?

Expected Behaviour - What do you think that should happen?

Compile.

Actual Behaviour - What unexpectedly happens?

"yasm.exe" exited with code 1.

Reproduction - How did you get this error to appear?

this code:

using ZincOS.Core;
using System.Drawing;

namespace ZincOS.Graphics.Images {
    public static class Cursor {
        private static readonly int Width = 12;
        private static readonly int Height = 18;

        // Final pre-rendered cursor with shadow + AA
        private static Color[,] buffer = new Color[Width, Height];

        static Cursor() {
            // First pass: draw main cursor shape
            foreach (var p in points) {
                buffer[p.x, p.y] = p.color;
            }

            // Second pass: shadow (blurred)
            foreach (var p in points) {
                int sx = p.x + 2;
                int sy = p.y + 2;
                if (sx < Width && sy < Height) {
                    // Blend shadow only if no cursor pixel there
                    if (buffer[sx, sy] == Color.Empty) {
                        buffer[sx, sy] = Color.FromArgb(120, 0, 0, 0); // semi-transparent black
                    }
                }
            }

            // Third pass: simple anti-alias edges
            foreach (var p in points) {
                foreach (var (ox, oy) in new (int, int)[] { (-1, 0), (1, 0), (0, -1), (0, 1) }) {
                    int nx = p.x + ox;
                    int ny = p.y + oy;
                    if (nx >= 0 && ny >= 0 && nx < Width && ny < Height && buffer[nx, ny] == Color.Empty) {
                        buffer[nx, ny] = Color.FromArgb(80, p.color); // faint edge pixel
                    }
                }
            }
        }

        // Draw precomputed buffer at position
        public static void DrawCursor(int x, int y) {
            for (int py = 0; py < Height; py++) {
                for (int px = 0; px < Width; px++) {
                    var c = buffer[px, py];
                    if (c != Color.Empty) {
                        Kernel.zinc.gui.zebra.canvas.DrawPoint(c, x + px, y + py);
                    }
                }
            }
        }

        // Original definition of cursor points
        private struct Point {
            public Color color;
            public int x, y;
            public Point(Color color, int x, int y) {
                this.color = color;
                this.x = x;
                this.y = y;
            }
        }

        private static Point[] points = new Point[] {
            // Lots of points but its long so i am not going to input it here.
        };
    }
}

Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?

Gen2 dev kit.

CorgiMasterEpic avatar Aug 26 '25 21:08 CorgiMasterEpic

private static Color[,] buffer = new Color[Width, Height];

you need to make this a 1d array (i would go with this option) or and array of arrays

zarlo avatar Aug 27 '25 02:08 zarlo

private static Color[,] buffer = new Color[Width, Height];

you need to make this a 1d array (i would go with this option) or and array of arrays

thanks that makes sense i guess yasm needs work.

CorgiMasterEpic avatar Aug 29 '25 13:08 CorgiMasterEpic

i guess yasm needs work

no, il2cpu does

9xbt avatar Aug 30 '25 18:08 9xbt