Esempio n. 1
0
        public void Init(GifCube program)
        {
            stack = new Stack <GifStackFrame>();
            //stack = new List<GifStackFrame>() { new GifStackFrame(program, ColorRGB.Black, ColorDir.PlusR) };
            for (int x = 0; x < 16; x++)
            {
                for (int y = 0; y < 16; y++)
                {
                    for (int z = 0; z < 16; z++)
                    {
                        registerTargets[x, y, z] = new GifCube();
                    }
                }
            }

            runningRegister = ColorRGB.White;
            registerTargets[runningRegister.R16, runningRegister.G16, runningRegister.B16] = program;
            registerTargets[8, 8, 8] = registerPositions;
            current = new GifValue_Readonly(ColorRGB.Black);
            halted  = false;
        }
Esempio n. 2
0
        public void Tick()
        {
            if (halted)
            {
                return;
            }

            ColorRGB programPosition = registerPositions[runningRegister];
            GifCube  program         = GetRegisterTarget(runningRegister);
            ColorRGB instruction     = program[programPosition];
            ColorRGB currentColor    = current.Read();

            // point to the next instruction
            bool overflow;

            registerPositions[runningRegister] = registerPositions[runningRegister].Increment(out overflow);

            if (overflow)
            {
                halted = true;
                return;
            }

            switch (instruction.hexSignature)
            {
            case 0x000:     // Return
                DoReturn(current);
                break;

            case 0xCCC:     // Assign
                stack.Push(new GifStackFrame(current, 0xCCC, runningRegister));
                break;

            case 0xC8C:     // Call
                stack.Push(new GifStackFrame(current, 0xC8C, runningRegister));
                break;

            case 0xC04:     // Load GIF
                break;

            case 0xC84:     // Save GIF
                //registerTargets[currentColor.R16, currentColor.G16, currentColor.B16].Save(GetRegisterName(currentColor) + ".gif");
                break;

            case 0xCC4:     // Retarget
                stack.Push(new GifStackFrame(current, 0xCC4, runningRegister));
                break;

            case 0x00C:     // RegisterPos
                current = new GifCursor(currentColor, currentColor, registerPositions);
                break;

            case 0x08C:     // RegisterVal
                current = new GifCursor(currentColor, registerPositions[currentColor], registerTargets[currentColor.R16, currentColor.G16, currentColor.B16]);
                break;

            case 0x0CC:     // Data
                current = new GifCursor(ColorRGB.White, currentColor, registerTargets[15, 15, 15]);
                break;

            case 0xC0C:     // Modify
                bool failed;
                registerPositions[runningRegister] = registerPositions[runningRegister] + new ColorRGB(48, 0, 0);
                current = Modify(currentColor,
                                 new ColorRGB[] {
                    program[programPosition + new ColorRGB(16, 0, 0)],
                    program[programPosition + new ColorRGB(32, 0, 0)],
                    program[programPosition + new ColorRGB(48, 0, 0)]
                },
                                 out failed
                                 );

                if (failed)
                {
                    DoReturn(current);
                }
                break;

            default:
                current = new GifCursor(runningRegister, programPosition, program);
                break;
            }
        }
Esempio n. 3
0
 public GifCursor(ColorRGB register, ColorRGB position, GifCube cube)
 {
     this.register = register;
     this.position = position;
     this.cube     = cube;
 }