public VByte UpdateSingleTile(Func <IOperand> x, Func <IOperand> y, Func <IOperand> color, VByte temp)
 {
     CPU6502.CLD(); CPU6502.CLD(); CPU6502.CLD(); CPU6502.CLD(); CPU6502.CLD();
     temp.Set(A.Set(x()).Divide(32));
     temp.Set(z => A.Set(y()).Divide(4).And(0b00111000).Or(z));
     Stack.Preserve(A, () => {                   //preserve attr index, wait to put into X, because X is needed as an index to X() and Y() values
         Comment("temp = attr tile mask index");
         temp.Set(A.Set(x()).Divide(16).And(1));
         temp.Set(z => A.Set(y()).Divide(8).And(0b10).Or(z));
     });
Beispiel #2
0
        public void Reset()
        {
            NES.IRQ.Disable();
            CPU6502.CLD();
            NES.APU.FrameCounter.Set(0x40);
            Stack.Reset();
            NES.PPU.Control.Set(0);
            NES.PPU.Mask.Set(0);
            NES.APU.DMC.Disable();
            //NES.APU.SetChannelsEnabled(NES.APU.Channels.DMC | NES.APU.Channels.Pulse1);

            Hardware.WaitForVBlank();
            Hardware.ClearRAM();
            Hardware.WaitForVBlank();

            ////TODO: move this to title, along with datasection
            //Comment("Load palettes");
            //Hardware.LoadPalettes(Palettes);

            Module <SceneManager>().Load(Module <Scenes.Title>());
            Hardware.WaitForVBlank();
            NES.PPU.Control.Set(NES.PPU.LazyControl);
            NES.PPU.Mask.Set(NES.PPU.LazyMask);
            ScrollUtil.Update();
            Loop.Infinite(_ => {
                Comment("Main Loop");

                Module <Gamepads>().Update();

                Module <SceneManager>().Step();

                A.Set(nmiCount);
                Loop.Do_old().While(() => nmiCount.Equals(A));

                Module <SceneManager>().CheckLoadNeeded();

                //Set shadow OAM address
                NES.PPU.OAM.Address.Set(0x00);                  //low byte of RAM address
                NES.PPU.OAM.DMA.Set(0x02);                      //high byte of RAM address
            });
        }