Exemplo n.º 1
0
        public override void Step()
        {
            If.Block(c => c
                     .True(_gamepad.IsHeld(NES.Button.Right), () => _charX.Set(z => z.Add(_MoveDist)))
                     .True(_gamepad.IsHeld(NES.Button.Left), () => _charX.Set(z => z.Subtract(_MoveDist)))
                     );
            If.Block(c => c
                     .True(_gamepad.IsHeld(NES.Button.Down), () => _charY.Set(z => z.Add(_MoveDist)))
                     .True(_gamepad.IsHeld(NES.Button.Up), () => _charY.Set(z => z.Subtract(_MoveDist)))
                     );
            If.Block(c => c
                     .True(_gamepad.WasPressed(NES.Button.B), () => {
                _skipOptionIndex.Dec();
                If.True(() => _skipOptionIndex.Equals(255), () => _skipOptionIndex.Set(0));                             //low limit
                GoSub(DrawSkipNum);
            })
                     .True(_gamepad.WasPressed(NES.Button.A), () => {
                _skipOptionIndex.Inc();
                If.True(() => _skipOptionIndex.Equals(_skipOptions.Length), () => _skipOptionIndex.Set(_skipOptions.Length - 1));                               //high limit
                GoSub(DrawSkipNum);
            })
                     );
            Y.Set(0);
            If.True(_gamepad.WasPressed(NES.Button.Select), () => {
                _pattern.Inc();
                If.True(() => _pattern.Equals(3), () => _pattern.Set(0));
            });
            If.True(_gamepad.WasPressed(NES.Button.Start), () => Module <SceneManager>().Queue(Module <Title>()));

            var jx = Temp[1];
            var jy = Temp[2];

            jx.Set(_charX.Subtract(8));
            jy.Set(_charY.Subtract(8));

            NES.PPU.OAM.Object[0].SetPosition(jx, jy);
            NES.PPU.OAM.Object[1].SetPosition(_charX, jy);
            NES.PPU.OAM.Object[2].SetPosition(jx, _charY);
            NES.PPU.OAM.Object[3].SetPosition(_charX, _charY);

            U8 startOffset = 4;

            If.Block(c => c
                     .True(() => _pattern.Equals(0), () => {
                Comment("Single row pattern");
                jx.Set(0x04);
                jy.Set(0x40);

                _processed.Set(0);
                Y.Set(startOffset);

                Loop.Do_old(_ => {
                    var spriteObj = NES.PPU.OAM.Object[Y];
                    Skipterate_PrepareY(startOffset);
                    spriteObj.Tile.Set(_JunkTile);
                    spriteObj.Attr.Set(1);
                    spriteObj.SetPosition(jx, jy);
                    Skipterate_Next();

                    jx.Set(z => z.Add(4));
                    _processed.Inc();
                }).While(() => A.Set(_processed).NotEquals(60));
            })
                     .True(() => _pattern.Equals(1), () => {
                Comment("Four rows pattern");
                U8 xStart = 0x30;
                jx.Set(xStart);
                jy.Set(0x30);

                _processed.Set(0);
                Y.Set(startOffset);

                Loop.Do_old(_ => {
                    var spriteObj = NES.PPU.OAM.Object[Y];
                    Skipterate_PrepareY(startOffset);
                    spriteObj.Tile.Set(_JunkTile);
                    spriteObj.Attr.Set(1);
                    spriteObj.SetPosition(jx, jy);
                    Skipterate_Next();

                    jx.Set(z => z.Add(8));

                    If.Any(() => _processed.Equals(19), () => _processed.Equals(39)).Then(() => {
                        jy.Set(jy.Add(8));
                        jx.Set(xStart);
                    });
                    _processed.Inc();
                }).While(() => A.Set(_processed).NotEquals(60));
            })
                     .Else(() => {
                Comment("Moving scattered objects pattern");
                Y.Set(startOffset);

                Loop.ForEach(X, _scatterSprites, (face, _) => {
                    var spriteObj = NES.PPU.OAM.Object[Y];
                    jx.Set(face.PosX.Add(8));
                    jy.Set(face.PosY.Add(8));

                    Skipterate_PrepareY(startOffset);
                    spriteObj.Tile.Set(_NPCTile0);
                    spriteObj.Attr.Set(1);
                    spriteObj.SetPosition(face.PosX, face.PosY);
                    Skipterate_Next();

                    Skipterate_PrepareY(startOffset);
                    spriteObj.Tile.Set(_NPCTile1);
                    spriteObj.Attr.Set(1);
                    spriteObj.SetPosition(jx, face.PosY);
                    Skipterate_Next();

                    Skipterate_PrepareY(startOffset);
                    spriteObj.Tile.Set(_NPCTile2);
                    spriteObj.Attr.Set(1);
                    spriteObj.SetPosition(face.PosX, jy);
                    Skipterate_Next();

                    Skipterate_PrepareY(startOffset);
                    spriteObj.Tile.Set(_NPCTile3);
                    spriteObj.Attr.Set(1);
                    spriteObj.SetPosition(jx, jy);
                    Skipterate_Next();

                    face.Move();
                });
            })
                     );
            Skipterate_Next();
        }