Exemple #1
0
        public LcdController(GameboyAdvance gba)
        {
            this.gba = gba;


            frameBuffer0 = new DirectBitmap(Screen_X_Resolution, Screen_Y_Resolution);
            frameBuffer1 = new DirectBitmap(Screen_X_Resolution, Screen_Y_Resolution);
            FrameBuffer = frameBuffer0;
            drawBuffer = frameBuffer1;

            this.Palettes = new Palettes();

            DisplayControlRegister = new DisplayControlRegister(this);
            DispStatRegister = new DisplayStatusRegister(this);
            BgControlRegisters = new BgControlRegister[4];
            Bg = new Background[4];
            for (int i = 0; i < 4; i++)
            {
                BgControlRegisters[i] = new BgControlRegister(this, i);
                Bg[i] = new Background(gba, i, BgControlRegisters[i]);

                priorityObjList[i] = new List<Obj>();
            }

            Obj = new Obj[Max_Sprites];
            for (int i = 0; i < Max_Sprites; i++)
            {
                Obj[i] = new Obj(gba, new ObjAttributes(gba, i * 8, gba.Memory.OamRam));
            }

            OamAffineMatrices = new OamAffineMatrix[Max_OAM_Matrices];
            UInt32 address = 0x00000006;
            for (int i = 0; i < 32; i++)
            {
                OamAffineMatrices[i] = new OamAffineMatrix(gba.Memory.OamRam, address);

                address += 0x20;
            }

            Windows = new Window[4];
            for (int i = 0; i < 4; i++)
            {
                Windows[i] = new Window(gba);
            }

#if THREADED_SCANLINE
            drawScanline = false;
            exitThread = false;
            scanlineThread = new Thread(new ThreadStart(ScanlineThread));
            scanlineThread.Start();
#endif
        }
Exemple #2
0
        public LcdController(GameboyAdvance gba)
        {
            this.gba = gba;


            frameBuffer0 = new DirectBitmap(Screen_X_Resolution, Screen_Y_Resolution);
            frameBuffer1 = new DirectBitmap(Screen_X_Resolution, Screen_Y_Resolution);
            FrameBuffer = frameBuffer0;
            drawBuffer = frameBuffer1;

            this.Palettes = new Palettes();

            DisplayControlRegister = new DisplayControlRegister(gba, this);
            DispStatRegister = new DisplayStatusRegister(gba, this);
            
            Bg = new Background[4];
            UInt32 scrollBaseAddress = 0x4000010;
            for (int i = 0; i < 4; i++)
            {
                BgControlRegister cntReg = new BgControlRegister(gba, this, i, (UInt32) (0x4000008 + (i * 2)));
                MemoryRegister16 scrollXReg = new MemoryRegister16(gba.Memory, scrollBaseAddress, false, true, 0x01);
                MemoryRegister16 scrollYReg = new MemoryRegister16(gba.Memory, scrollBaseAddress + 2, false, true, 0x01);
                Bg[i] = new Background(gba, i, cntReg, scrollXReg, scrollYReg);

                scrollBaseAddress += 4;
            }

            VCount = new MemoryRegister8(gba.Memory, 0x04000006, true, false);

            this.ObjController = new ObjController(gba);

            Windows = new Window[4];
            Windows[0] = new Window(gba, 0x4000040, 0x4000048);
            Windows[1] = new Window(gba, 0x4000042, 0x4000049);
            Windows[2] = new Window(gba, 0, 0x400004A);
            Windows[3] = new Window(gba, 0, 0x400004B);

            this.BlendControlRegister = new BlendControlRegister(this, gba);
            BlendingCoefficientRegister = new PixelCoefficientRegister(this, gba, 0x4000052);
            BrightnessCoefficientRegister = new PixelCoefficientRegister(this, gba, 0x4000054);

#if THREADED_SCANLINE
            //Interlocked.Exchange(ref drawScanline, 0);
            drawScanline = 0;
            exitThread = false;
            scanlineThread = new Thread(new ThreadStart(ScanlineThread));
            scanlineThread.Priority = ThreadPriority.Highest;
            scanlineThread.Start();
#endif
        }
Exemple #3
0
 public DispStatRegister(LcdController lcd, DisplayStatusRegister dspStat, Memory memory, UInt32 address) :
     base(memory, address, true, true)
 {
     this.lcd     = lcd;
     this.dspStat = dspStat;
 }